fix:道具数量同步错误
This commit is contained in:
parent
d632386936
commit
8ac802e2a3
|
@ -117,7 +117,7 @@ type Player struct {
|
|||
BlackLevel int32 //todo 使用WBLevel
|
||||
SingleAdjust *model.PlayerSingleAdjust
|
||||
IsLocal bool //是否本地player
|
||||
Items map[int32]int32 //背包数据
|
||||
Items map[int32]int64 //背包数据
|
||||
MatchParams []int32 //比赛参数 排名、段位、假snid、假角色
|
||||
MatchRobotGrades []MatchRobotGrade
|
||||
TestLog []string // 调试日志
|
||||
|
@ -141,7 +141,7 @@ func NewPlayer(sid int64, data []byte, ws, gs *netlib.Session) *Player {
|
|||
cparams: make(map[string]string), //平台登陆数据
|
||||
Iparams: make(map[int]int64), //整形参数
|
||||
sparams: make(map[int]string), //字符参数
|
||||
Items: make(map[int32]int32),
|
||||
Items: make(map[int32]int64),
|
||||
RankScore: make(map[int32]int64),
|
||||
}
|
||||
|
||||
|
@ -448,6 +448,7 @@ func (this *Player) AddCoin(num int64, gainWay int32, syncFlag int, oper, remark
|
|||
return
|
||||
}
|
||||
this.Coin += num
|
||||
this.Items[common.ItemIDCoin] = this.Coin
|
||||
if this.scene != nil {
|
||||
if !this.IsRob && !this.scene.Testing { //机器人log排除掉
|
||||
log := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
|
@ -525,6 +526,7 @@ func (this *Player) AddCoinAsync(num int64, gainWay int32, notifyC, broadcast bo
|
|||
return
|
||||
}
|
||||
this.Coin += num
|
||||
this.Items[common.ItemIDCoin] = this.Coin
|
||||
if this.scene != nil {
|
||||
if !this.IsRob && !this.scene.Testing && writeLog { //机器人log排除掉
|
||||
log := model.NewCoinLogEx(&model.CoinLogParam{
|
||||
|
|
|
@ -639,9 +639,9 @@ func (this *Scene) PlayerLeave(p *Player, reason int, isBill bool) {
|
|||
}
|
||||
}
|
||||
|
||||
pack.Items = make(map[int32]int32)
|
||||
pack.Items = make(map[int32]int64)
|
||||
for id, num := range p.Items {
|
||||
pack.Items[id] = proto.Int32(num)
|
||||
pack.Items[id] = num
|
||||
}
|
||||
pack.RankScore = make(map[int32]int64)
|
||||
for k, v := range p.RankScore {
|
||||
|
@ -2343,7 +2343,7 @@ func (this *Scene) TryBillExGameDrop(p *Player) {
|
|||
num = rand.Int31n(drop.MaxAmount-drop.MinAmount+1) + drop.MinAmount
|
||||
}
|
||||
|
||||
p.Items[drop.ItemId] += num
|
||||
p.Items[drop.ItemId] += int64(num)
|
||||
realDrop[drop.ItemId] = num
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -459,7 +459,7 @@ func CreatePlayerData(p *base.Player) *chesstitians.ChesstitiansPlayerData {
|
|||
if p.Items != nil {
|
||||
pd.Items = make(map[int32]int32)
|
||||
for id, num := range p.Items {
|
||||
pd.Items[id] = proto.Int32(num)
|
||||
pd.Items[id] = int32(num)
|
||||
}
|
||||
}
|
||||
if len(p.MatchParams) > 0 {
|
||||
|
|
|
@ -353,7 +353,7 @@ func (this *CSFishSkillUseReqHandler) Process(s *netlib.Session, packetid int, d
|
|||
itemNum := item[1]
|
||||
//获取背包道具数量
|
||||
num, ok := player.Items[item[0]]
|
||||
if !ok || num < item[1] {
|
||||
if !ok || num < int64(item[1]) {
|
||||
fishlogger.Errorf("道具数量不在 itemId = %v,itemNum = %v,背包数量 = %v", item[0], item[1], num)
|
||||
//判断其他消耗其他物品
|
||||
otherItem := skillTemp.OtherConsumer
|
||||
|
@ -378,18 +378,18 @@ func (this *CSFishSkillUseReqHandler) Process(s *netlib.Session, packetid int, d
|
|||
}
|
||||
player.Diamond -= int64(otherItemNum)
|
||||
} else {
|
||||
if player.Items[otherItemId] < otherItemNum {
|
||||
if player.Items[otherItemId] < int64(otherItemNum) {
|
||||
fishlogger.Tracef("转换物品是其他物品时,物品数量不足!")
|
||||
pack.Result = 1
|
||||
pack.Status = fishing_proto.SCFishSkillUseResp_TOOL_LIMIT
|
||||
player.SendToClient(int(fishing_proto.FIPacketID_FISHING_SC_SKILLUSERESP), pack)
|
||||
return nil
|
||||
}
|
||||
player.Items[otherItemId] = player.Items[otherItemId] - otherItemNum
|
||||
player.Items[otherItemId] = player.Items[otherItemId] - int64(otherItemNum)
|
||||
}
|
||||
fishlogger.Tracef("玩家使用技能当前道具不足 转化物品消耗 skillid = %v,snid = %v,otherItemId = %v,otherItemNum = %v", skillId, player.SnId, otherItemId, otherItemNum)
|
||||
} else {
|
||||
player.Items[itemId] = player.Items[itemId] - itemNum
|
||||
player.Items[itemId] = player.Items[itemId] - int64(itemNum)
|
||||
//记录道具消耗日志
|
||||
fishlogger.Tracef("玩家使用技能,消耗道具!snod = %v, skill = %v,itemId =%v,itemNum = %v", player.SnId, skillId, itemId, itemNum)
|
||||
}
|
||||
|
|
|
@ -373,7 +373,7 @@ func TienLenCreatePlayerData(p *base.Player, rankScore int64) *tienlen.TienLenPl
|
|||
if p.Items != nil {
|
||||
pd.Items = make(map[int32]int32)
|
||||
for id, num := range p.Items {
|
||||
pd.Items[id] = proto.Int32(num)
|
||||
pd.Items[id] = int32(num)
|
||||
}
|
||||
}
|
||||
if len(p.MatchParams) > 0 {
|
||||
|
|
|
@ -1301,7 +1301,7 @@ type WGPlayerEnter struct {
|
|||
SnId int32 `protobuf:"varint,14,opt,name=SnId,proto3" json:"SnId,omitempty"`
|
||||
SingleAdjust []byte `protobuf:"bytes,15,opt,name=SingleAdjust,proto3" json:"SingleAdjust,omitempty"` //单控数据
|
||||
Pos int32 `protobuf:"varint,16,opt,name=Pos,proto3" json:"Pos,omitempty"`
|
||||
Items map[int32]int32 `protobuf:"bytes,17,rep,name=Items,proto3" json:"Items,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||
Items map[int32]int64 `protobuf:"bytes,17,rep,name=Items,proto3" json:"Items,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||
MatchParams []int32 `protobuf:"varint,18,rep,packed,name=MatchParams,proto3" json:"MatchParams,omitempty"` //比赛参数
|
||||
RankScore map[int32]int64 `protobuf:"bytes,19,rep,name=RankScore,proto3" json:"RankScore,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` // 排位积分
|
||||
}
|
||||
|
@ -1450,7 +1450,7 @@ func (x *WGPlayerEnter) GetPos() int32 {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (x *WGPlayerEnter) GetItems() map[int32]int32 {
|
||||
func (x *WGPlayerEnter) GetItems() map[int32]int64 {
|
||||
if x != nil {
|
||||
return x.Items
|
||||
}
|
||||
|
@ -1637,7 +1637,7 @@ type GWPlayerLeave struct {
|
|||
LostTimes int32 `protobuf:"varint,12,opt,name=LostTimes,proto3" json:"LostTimes,omitempty"` //输局
|
||||
TotalConvertibleFlow int64 `protobuf:"varint,13,opt,name=TotalConvertibleFlow,proto3" json:"TotalConvertibleFlow,omitempty"` //流水
|
||||
ValidCacheBetTotal int64 `protobuf:"varint,14,opt,name=ValidCacheBetTotal,proto3" json:"ValidCacheBetTotal,omitempty"` //有效下注缓存
|
||||
Items map[int32]int32 `protobuf:"bytes,15,rep,name=Items,proto3" json:"Items,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||
Items map[int32]int64 `protobuf:"bytes,15,rep,name=Items,proto3" json:"Items,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"`
|
||||
MatchId int32 `protobuf:"varint,16,opt,name=MatchId,proto3" json:"MatchId,omitempty"` //比赛场id
|
||||
CurIsWin int64 `protobuf:"varint,17,opt,name=CurIsWin,proto3" json:"CurIsWin,omitempty"` //本局是否赢 负数:输 0:平局 正数:赢
|
||||
MatchRobotGrades map[int32]int32 `protobuf:"bytes,18,rep,name=MatchRobotGrades,proto3" json:"MatchRobotGrades,omitempty" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //比赛数据
|
||||
|
@ -1774,7 +1774,7 @@ func (x *GWPlayerLeave) GetValidCacheBetTotal() int64 {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (x *GWPlayerLeave) GetItems() map[int32]int32 {
|
||||
func (x *GWPlayerLeave) GetItems() map[int32]int64 {
|
||||
if x != nil {
|
||||
return x.Items
|
||||
}
|
||||
|
@ -8789,7 +8789,7 @@ var file_server_proto_rawDesc = []byte{
|
|||
0x72, 0x65, 0x1a, 0x38, 0x0a, 0x0a, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79,
|
||||
0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b,
|
||||
0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e,
|
||||
0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x1a, 0x3c, 0x0a, 0x0e,
|
||||
0x52, 0x61, 0x6e, 0x6b, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10,
|
||||
0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79,
|
||||
0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||
|
@ -8856,7 +8856,7 @@ var file_server_proto_rawDesc = []byte{
|
|||
0x09, 0x52, 0x61, 0x6e, 0x6b, 0x53, 0x63, 0x6f, 0x72, 0x65, 0x1a, 0x38, 0x0a, 0x0a, 0x49, 0x74,
|
||||
0x65, 0x6d, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18,
|
||||
0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61,
|
||||
0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
|
||||
0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65,
|
||||
0x3a, 0x02, 0x38, 0x01, 0x1a, 0x43, 0x0a, 0x15, 0x4d, 0x61, 0x74, 0x63, 0x68, 0x52, 0x6f, 0x62,
|
||||
0x6f, 0x74, 0x47, 0x72, 0x61, 0x64, 0x65, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a,
|
||||
0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12,
|
||||
|
|
|
@ -225,7 +225,7 @@ message WGPlayerEnter {
|
|||
int32 SnId = 14;
|
||||
bytes SingleAdjust = 15;//单控数据
|
||||
int32 Pos = 16;
|
||||
map<int32, int32> Items = 17;
|
||||
map<int32, int64> Items = 17;
|
||||
repeated int32 MatchParams = 18;//比赛参数
|
||||
map<int32, int64> RankScore = 19;// 排位积分
|
||||
}
|
||||
|
@ -264,7 +264,7 @@ message GWPlayerLeave{
|
|||
int32 LostTimes = 12; //输局
|
||||
int64 TotalConvertibleFlow = 13; //流水
|
||||
int64 ValidCacheBetTotal = 14; //有效下注缓存
|
||||
map<int32, int32> Items = 15;
|
||||
map<int32, int64> Items = 15;
|
||||
int32 MatchId = 16;//比赛场id
|
||||
int64 CurIsWin = 17;//本局是否赢 负数:输 0:平局 正数:赢
|
||||
map<int32, int32> MatchRobotGrades = 18;//比赛数据
|
||||
|
|
|
@ -522,12 +522,12 @@ func (this *Scene) PlayerEnter(p *Player, pos int, ischangeroom bool) bool {
|
|||
// 道具
|
||||
dbItemArr := srvdata.PBDB_GameItemMgr.Datas.Arr
|
||||
if dbItemArr != nil {
|
||||
msg.Items = make(map[int32]int32)
|
||||
msg.Items = make(map[int32]int64)
|
||||
for _, dbItem := range dbItemArr {
|
||||
msg.Items[dbItem.Id] = proto.Int32(0)
|
||||
msg.Items[dbItem.Id] = 0
|
||||
itemInfo := BagMgrSingleton.GetItem(p.SnId, dbItem.Id)
|
||||
if itemInfo != nil {
|
||||
msg.Items[dbItem.Id] = proto.Int32(int32(itemInfo.ItemNum))
|
||||
msg.Items[dbItem.Id] = itemInfo.ItemNum
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue