Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
cf37fc7401
@ -17,7 +17,7 @@
|
||||
"text": "初来乍到"
|
||||
},
|
||||
"npctxt": {
|
||||
"key": "worldtask_world_task_npctxt_1",
|
||||
"key": "taskcond_rdtask_condi_npctxt_1",
|
||||
"text": "和阿宝聊聊"
|
||||
},
|
||||
"npc": 10010,
|
||||
|
18
comm/core.go
18
comm/core.go
@ -2,10 +2,10 @@ package comm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/rand"
|
||||
"math/rand"
|
||||
|
||||
"fmt"
|
||||
"go_dreamfactory/pb"
|
||||
"math/big"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
@ -93,16 +93,15 @@ func ProtoMarshal(rsp proto.Message, msg *pb.UserMessage) (ok bool) {
|
||||
/// 参数 权重数组 返回值 数组下标
|
||||
func GetRandW(sz []int32) int32 {
|
||||
if len(sz) > 0 {
|
||||
var _totalW int64 // 总权重
|
||||
var _tmpW int64 // 临时权重
|
||||
var _totalW int32 // 总权重
|
||||
var _tmpW int32 // 临时权重
|
||||
for _, v := range sz {
|
||||
_totalW += int64(v)
|
||||
_totalW += v
|
||||
}
|
||||
// 随机权重
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(_totalW))
|
||||
for i, v := range sz {
|
||||
_tmpW += int64(v)
|
||||
if n.Int64() < _tmpW {
|
||||
_tmpW += v
|
||||
if rand.Int31n(_totalW) < _tmpW {
|
||||
return int32(i)
|
||||
}
|
||||
}
|
||||
@ -118,8 +117,7 @@ func GetRandNum(min, max int32) int32 {
|
||||
return min
|
||||
}
|
||||
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(int64(max-min+1))) //+1 是因为 rand方法范围是[0, max)
|
||||
return int32(n.Int64()) + min
|
||||
return rand.Int31n(int32(max-min+1)) + min
|
||||
}
|
||||
|
||||
///通过uid获取用户所在区服
|
||||
|
@ -37,9 +37,8 @@ type MCompConfigure struct {
|
||||
hlock sync.RWMutex
|
||||
_dropMap map[int32][]*cfg.GameDropData // 掉落表 key 是DiropId
|
||||
_sign map[int32]*cfg.GameSignData
|
||||
|
||||
// 新掉落表
|
||||
_group map[int64][]int32 // key 小组ID value cid
|
||||
|
||||
// 类型为1 的数据 该大组中的小组为权重掉落,必定从N个小组中随机出1个小组
|
||||
_lotteryType1 map[int32][]int32 // key 大组ID value cid
|
||||
// 类型为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.LoadConfigure(game_global, cfg.NewGameGlobal)
|
||||
err = this.LoadConfigure(game_initial, cfg.NewGameInitial)
|
||||
//err = this.LoadConfigure(game_gamecolor, cfg.NewGameGameColor)
|
||||
err = this.LoadConfigure(new_hero, cfg.NewGameHero)
|
||||
err = this.LoadConfigure(game_playerlv, cfg.NewGamePlayerlv)
|
||||
|
||||
err = this.LoadConfigure(game_signreset, cfg.NewGameSignReset)
|
||||
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_vip, cfg.NewGameVip)
|
||||
err = this.LoadConfigure(game_lottery, cfg.NewGameLottery)
|
||||
@ -105,6 +102,20 @@ func (this *MCompConfigure) LoadGroupData() {
|
||||
key := int64(value.Lotteryid)<<31 + int64(value.Groupid)
|
||||
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 {
|
||||
this.Btype[value.Lotteryid] = value.Type
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ type GameNavigationData struct {
|
||||
Functionname string
|
||||
NpcName []string
|
||||
Functionicon string
|
||||
Mainscreen string
|
||||
}
|
||||
|
||||
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.Mainscreen, _ok_ = _buf["mainscreen"].(string); !_ok_ { err = errors.New("mainscreen error"); return } }
|
||||
return
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user