一个很坑的bug

This commit is contained in:
meixiongfeng 2023-12-31 20:58:30 +08:00
parent d317cf88f9
commit b05f9e2152
2 changed files with 15 additions and 12 deletions

View File

@ -287,12 +287,10 @@ func (this *ModelUser) computeLevel(change *pb.UserResChangedPush) (lvchange boo
return return
} }
func (this *ModelUser) changelv(session comm.IUserSession, lv int32, exp int64, name string, rewards []*cfg.Gameatn) { func (this *ModelUser) changelv(session comm.IUserSession, lv int32, exp int64, name string) {
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
var ( var (
atno []*pb.UserAtno tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
errdata *pb.ErrorData
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
) )
if err := session.SendMsg(string(this.module.GetType()), UserSubTypeLvChangedPush, if err := session.SendMsg(string(this.module.GetType()), UserSubTypeLvChangedPush,
&pb.UserLvChangedPush{Uid: session.GetUserId(), Exp: exp, Lv: lv}); err != nil { &pb.UserLvChangedPush{Uid: session.GetUserId(), Exp: exp, Lv: lv}); err != nil {
@ -302,17 +300,11 @@ func (this *ModelUser) changelv(session comm.IUserSession, lv int32, exp int64,
log.Field{Key: "lv", Value: lv}, log.Field{Key: "lv", Value: lv},
) )
} }
if errdata, atno = this.module.DispenseAtno(session, rewards, true); errdata != nil {
this.module.Error("资源发放",
log.Field{Key: "uid", Value: session.GetUserId()},
log.Field{Key: "rewards", Value: rewards},
)
}
this.module.chat.SendSysChatToUser(session, comm.ChatSystem12, lv, 0, name) this.module.chat.SendSysChatToUser(session, comm.ChatSystem12, lv, 0, name)
this.module.ModuleSys.CheckOpenCond(session.Clone(), comm.OpencondTypePlatlv, lv) this.module.ModuleSys.CheckOpenCond(session.Clone(), comm.OpencondTypePlatlv, lv)
tasks = append(tasks, comm.GetBuriedParam(comm.Rtype20, lv)) tasks = append(tasks, comm.GetBuriedParam(comm.Rtype20, lv))
this.module.ModuleBuried.TriggerBuried(session, tasks...) this.module.ModuleBuried.TriggerBuried(session, tasks...)
this.module.WriteUserLog(session.GetUserId(), fmt.Sprintf(" lv :%d, exp %d, name %s", lv, exp, name), comm.GMResAddType, "changelv", atno)
}) })
} }

View File

@ -574,7 +574,18 @@ func (this *User) change(session comm.IUserSession, attrs map[string]int32) (atn
} }
change.Exp += int64(add) change.Exp += int64(add)
if lvchange, loseexp, rewards = this.modelUser.computeLevel(change); lvchange { if lvchange, loseexp, rewards = this.modelUser.computeLevel(change); lvchange {
this.modelUser.changelv(session, change.Lv, change.Exp, user.Name, rewards) this.modelUser.changelv(session, change.Lv, change.Exp, user.Name)
defer func() {
go func() {
if err, res := this.DispenseAtno(session, rewards, true); err == nil {
this.WriteUserLog(session.GetUserId(), fmt.Sprintf("userlv change"), comm.GMResAddType, "changelv", res)
} else {
this.Errorf("err:%v", err)
}
}()
}()
} }
temp.N = temp.N - loseexp temp.N = temp.N - loseexp
case comm.VipExp: case comm.VipExp: