This commit is contained in:
liwei1dao 2023-06-03 00:41:51 +08:00
commit cf37fc7401
4 changed files with 26 additions and 15 deletions

View File

@ -17,7 +17,7 @@
"text": "初来乍到" "text": "初来乍到"
}, },
"npctxt": { "npctxt": {
"key": "worldtask_world_task_npctxt_1", "key": "taskcond_rdtask_condi_npctxt_1",
"text": "和阿宝聊聊" "text": "和阿宝聊聊"
}, },
"npc": 10010, "npc": 10010,

View File

@ -2,10 +2,10 @@ package comm
import ( import (
"context" "context"
"crypto/rand" "math/rand"
"fmt" "fmt"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"math/big"
"reflect" "reflect"
"strings" "strings"
@ -93,16 +93,15 @@ func ProtoMarshal(rsp proto.Message, msg *pb.UserMessage) (ok bool) {
/// 参数 权重数组 返回值 数组下标 /// 参数 权重数组 返回值 数组下标
func GetRandW(sz []int32) int32 { func GetRandW(sz []int32) int32 {
if len(sz) > 0 { if len(sz) > 0 {
var _totalW int64 // 总权重 var _totalW int32 // 总权重
var _tmpW int64 // 临时权重 var _tmpW int32 // 临时权重
for _, v := range sz { for _, v := range sz {
_totalW += int64(v) _totalW += v
} }
// 随机权重 // 随机权重
n, _ := rand.Int(rand.Reader, big.NewInt(_totalW))
for i, v := range sz { for i, v := range sz {
_tmpW += int64(v) _tmpW += v
if n.Int64() < _tmpW { if rand.Int31n(_totalW) < _tmpW {
return int32(i) return int32(i)
} }
} }
@ -118,8 +117,7 @@ func GetRandNum(min, max int32) int32 {
return min return min
} }
n, _ := rand.Int(rand.Reader, big.NewInt(int64(max-min+1))) //+1 是因为 rand方法范围是[0, max) return rand.Int31n(int32(max-min+1)) + min
return int32(n.Int64()) + min
} }
///通过uid获取用户所在区服 ///通过uid获取用户所在区服

View File

@ -37,9 +37,8 @@ type MCompConfigure struct {
hlock sync.RWMutex hlock sync.RWMutex
_dropMap map[int32][]*cfg.GameDropData // 掉落表 key 是DiropId _dropMap map[int32][]*cfg.GameDropData // 掉落表 key 是DiropId
_sign map[int32]*cfg.GameSignData _sign map[int32]*cfg.GameSignData
// 新掉落表
_group map[int64][]int32 // key 小组ID value cid _group map[int64][]int32 // key 小组ID value cid
// 类型为1 的数据 该大组中的小组为权重掉落必定从N个小组中随机出1个小组 // 类型为1 的数据 该大组中的小组为权重掉落必定从N个小组中随机出1个小组
_lotteryType1 map[int32][]int32 // key 大组ID value cid _lotteryType1 map[int32][]int32 // key 大组ID value cid
// 类型为2 的数据 有多个小组ID // 类型为2 的数据 有多个小组ID
@ -60,13 +59,11 @@ func (this *MCompConfigure) Init(service core.IService, module core.IModule, com
err = this.ModuleCompBase.Init(service, module, comp, options) err = this.ModuleCompBase.Init(service, module, comp, options)
err = this.LoadConfigure(game_global, cfg.NewGameGlobal) err = this.LoadConfigure(game_global, cfg.NewGameGlobal)
err = this.LoadConfigure(game_initial, cfg.NewGameInitial) err = this.LoadConfigure(game_initial, cfg.NewGameInitial)
//err = this.LoadConfigure(game_gamecolor, cfg.NewGameGameColor)
err = this.LoadConfigure(new_hero, cfg.NewGameHero) err = this.LoadConfigure(new_hero, cfg.NewGameHero)
err = this.LoadConfigure(game_playerlv, cfg.NewGamePlayerlv) err = this.LoadConfigure(game_playerlv, cfg.NewGamePlayerlv)
err = this.LoadConfigure(game_signreset, cfg.NewGameSignReset) err = this.LoadConfigure(game_signreset, cfg.NewGameSignReset)
err = this.LoadConfigure(game_equip, cfg.NewGameEquip) err = this.LoadConfigure(game_equip, cfg.NewGameEquip)
//err = this.LoadConfigure(game_sign, cfg.NewGameSign)
err = this.LoadConfigure(game_item, cfg.NewGameItem) err = this.LoadConfigure(game_item, cfg.NewGameItem)
err = this.LoadConfigure(game_vip, cfg.NewGameVip) err = this.LoadConfigure(game_vip, cfg.NewGameVip)
err = this.LoadConfigure(game_lottery, cfg.NewGameLottery) err = this.LoadConfigure(game_lottery, cfg.NewGameLottery)
@ -105,6 +102,20 @@ func (this *MCompConfigure) LoadGroupData() {
key := int64(value.Lotteryid)<<31 + int64(value.Groupid) key := int64(value.Lotteryid)<<31 + int64(value.Groupid)
this._group[key] = append(this._group[key], value.Id) this._group[key] = append(this._group[key], value.Id)
// 数据安全校验
if value.Min > value.Max {
log.Errorf("value.Min:%d > value.Max :%d ", value.Min, value.Max)
return
}
if value.VIPmin > value.VIPmax {
log.Errorf("value.VIPmin:%d > value.VIPmax :%d ", value.VIPmin, value.VIPmax)
return
}
if value.Playerlvmin > value.Playerlvmax {
log.Errorf("value.Playerlvmin:%d > value.Playerlvmax :%d ", value.Playerlvmin, value.Playerlvmax)
return
}
if _, ok := this.Btype[value.Lotteryid]; !ok { if _, ok := this.Btype[value.Lotteryid]; !ok {
this.Btype[value.Lotteryid] = value.Type this.Btype[value.Lotteryid] = value.Type
} }

View File

@ -18,6 +18,7 @@ type GameNavigationData struct {
Functionname string Functionname string
NpcName []string NpcName []string
Functionicon string Functionicon string
Mainscreen string
} }
const TypeId_GameNavigationData = -800652966 const TypeId_GameNavigationData = -800652966
@ -47,6 +48,7 @@ func (_v *GameNavigationData)Deserialize(_buf map[string]interface{}) (err error
} }
{ var _ok_ bool; if _v.Functionicon, _ok_ = _buf["functionicon"].(string); !_ok_ { err = errors.New("functionicon error"); return } } { var _ok_ bool; if _v.Functionicon, _ok_ = _buf["functionicon"].(string); !_ok_ { err = errors.New("functionicon error"); return } }
{ var _ok_ bool; if _v.Mainscreen, _ok_ = _buf["mainscreen"].(string); !_ok_ { err = errors.New("mainscreen error"); return } }
return return
} }