fix 推币机桌面数据校验

This commit is contained in:
sk 2025-01-14 10:13:25 +08:00
parent f23351de24
commit e7cce8205a
1 changed files with 15 additions and 16 deletions

View File

@ -177,20 +177,21 @@ func CSPushCoinPlayerOp(s *netlib.Session, packetid int, data interface{}, sid i
// 有效区 // 有效区
for _, v := range msg.GetOpItem() { for _, v := range msg.GetOpItem() {
id := v.GetItemId() id := v.GetItemId()
val := int64(v.GetItemNum()) val := v.GetItemNum()
switch v.GetItemId() {
case common.ItemIDBigCoin, common.ItemIDCoin1, common.ItemIDCoin2, common.ItemIDCoin3:
val *= srvdata.GameItemMgr.Get(p.Platform, id).GetNum()
id = common.ItemIDCoin
}
if p.WelfData.PushCoin.Items[id] < val { if p.WelfData.PushCoin.Items[id] < val {
logger.Logger.Errorf("获得道具太多: %d, %d", p.WelfData.PushCoin.Items[id], val) logger.Logger.Errorf("获得道具太多: %d, %d", p.WelfData.PushCoin.Items[id], val)
// 刷新桌面余额 // 刷新桌面余额
UpdatePlayerPushCoin(p) //UpdatePlayerPushCoin(p)
goto here goto here
} }
switch v.GetItemId() {
case common.ItemIDBigCoin, common.ItemIDCoin1, common.ItemIDCoin2, common.ItemIDCoin3:
val *= srvdata.GameItemMgr.Get(p.Platform, id).GetNum()
id = common.ItemIDCoin
}
BagMgrSingleton.AddItems(&model.AddItemParam{ BagMgrSingleton.AddItems(&model.AddItemParam{
Platform: p.Platform, Platform: p.Platform,
SnId: p.SnId, SnId: p.SnId,
@ -220,11 +221,11 @@ func CSPushCoinPlayerOp(s *netlib.Session, packetid int, data interface{}, sid i
p.WelfData.PushCoin.Shake -= int32(msg.GetOpParam()) p.WelfData.PushCoin.Shake -= int32(msg.GetOpParam())
case activity.OpCodes_OP_Refresh: case activity.OpCodes_OP_Refresh:
if p.WelfData.PushCoin.Refresh <= 0 { //if p.WelfData.PushCoin.Refresh <= 0 {
InitPlayerPushCoin(p) // InitPlayerPushCoin(p)
} else { //} else {
UpdatePlayerPushCoin(p) // UpdatePlayerPushCoin(p)
} //}
case activity.OpCodes_OP_Exchange: case activity.OpCodes_OP_Exchange:
d := srvdata.PBDB_PropExchangeMgr.GetData(int32(msg.GetOpParam())) d := srvdata.PBDB_PropExchangeMgr.GetData(int32(msg.GetOpParam()))
@ -319,7 +320,7 @@ func InitPlayerPushCoin(p *Player) {
Exchange: make(map[int32]int32), Exchange: make(map[int32]int32),
Items: map[int32]int64{ Items: map[int32]int64{
common.ItemIDVCard: 1, common.ItemIDVCard: 1,
common.ItemIDCoin: 50 * 5000, common.ItemIDCoin1: 50,
common.ItemIDPlum: 1, common.ItemIDPlum: 1,
}, },
} }
@ -329,7 +330,7 @@ func UpdatePlayerPushCoin(p *Player) {
p.WelfData.PushCoin.Refresh++ p.WelfData.PushCoin.Refresh++
// 50个金币 // 50个金币
p.WelfData.PushCoin.Items = map[int32]int64{ p.WelfData.PushCoin.Items = map[int32]int64{
common.ItemIDCoin: 50 * 5000, common.ItemIDCoin1: 50,
} }
} }
@ -429,8 +430,6 @@ func PushCoinAddValue(p *Player, item map[int32]int64) {
for k, v := range item { for k, v := range item {
if v > 0 { if v > 0 {
switch k { switch k {
case common.ItemIDCoin1, common.ItemIDCoin2, common.ItemIDCoin3, common.ItemIDBigCoin:
p.WelfData.PushCoin.Items[common.ItemIDCoin] += v * srvdata.GameItemMgr.Get(p.Platform, k).GetNum()
default: default:
p.WelfData.PushCoin.Items[k] += v p.WelfData.PushCoin.Items[k] += v
} }