From b651cd34068343dec7962b4fb78d80bfd328c008 Mon Sep 17 00:00:00 2001 From: liwei <2211068034@qq.com> Date: Tue, 11 Jul 2023 15:14:38 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=88=98=E6=96=97?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/core.go | 15 ++++++++------- comm/pool.go | 4 ++-- comm/usersession.go | 10 +++++++++- modules/arena/api_challengereward.go | 6 +++--- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/comm/core.go b/comm/core.go index 8253e28e7..33b0f1bce 100644 --- a/comm/core.go +++ b/comm/core.go @@ -24,7 +24,7 @@ type ISC_GateRouteComp interface { PutUserSession(session IUserSession) } -//游戏类资源类型 +// 游戏类资源类型 const ( AttrType = "attr" //用户属性资源 例如货币 经验 之类的 PerType = "per" //用户皮肤,动作,背景 相关资源 @@ -44,13 +44,13 @@ type Autogenerated struct { D []interface{} } -//Api Check 错误返回结构 +// Api Check 错误返回结构 type ErrorCode struct { Code pb.ErrorCode Data interface{} } -//用户会话 +// 用户会话 type IUserSession interface { SetSession(ip, sessionId, stag, sid, uid string) GetSessionId() string @@ -66,10 +66,11 @@ type IUserSession interface { Push() (err error) //警告 api传递过来的会话禁用此接口 Close() (err error) Reset() + Clone() (clone *UserSession) //克隆 ToString() string } -//对protobuf格式的数据进行反序列化 +// 对protobuf格式的数据进行反序列化 func ProtoUnmarshal(msg *pb.UserMessage, req proto.Message) (ok bool) { err := msg.Data.UnmarshalTo(req) if err != nil { @@ -79,7 +80,7 @@ func ProtoUnmarshal(msg *pb.UserMessage, req proto.Message) (ok bool) { return true } -//对protobuf格式的数据进行序列化 +// 对protobuf格式的数据进行序列化 func ProtoMarshal(rsp proto.Message, msg *pb.UserMessage) (ok bool) { any, err := anypb.New(rsp) if err != nil { @@ -90,7 +91,7 @@ func ProtoMarshal(rsp proto.Message, msg *pb.UserMessage) (ok bool) { return true } -/// 参数 权重数组 返回值 数组下标 +// / 参数 权重数组 返回值 数组下标 func GetRandW(sz []int32) int32 { if len(sz) > 0 { var _totalW int64 // 总权重 @@ -137,7 +138,7 @@ func GetRandNum(min, max int32) int32 { return int32(n.Int64()) + min } -///通过uid获取用户所在区服 +// /通过uid获取用户所在区服 func UidToSTag(uid string) (stag string, err error) { s := strings.SplitN(uid, "_", 2) if len(s) < 2 { diff --git a/comm/pool.go b/comm/pool.go index f14642792..9bdedb5af 100644 --- a/comm/pool.go +++ b/comm/pool.go @@ -14,7 +14,7 @@ var buriedParamPool = &sync.Pool{ }, } -//普通任务 +// 普通任务 func GetBuriedParam(t TaskType, vaule int32, p ...int32) *pb.BuriedParam { task := buriedParamPool.Get().(*pb.BuriedParam) task.TaskType = int32(t) @@ -25,7 +25,7 @@ func GetBuriedParam(t TaskType, vaule int32, p ...int32) *pb.BuriedParam { return task } -//统计型任务 +// 统计型任务 func GetBuriedParam2(t TaskType, statistics string, p ...int32) *pb.BuriedParam { task := buriedParamPool.Get().(*pb.BuriedParam) task.TaskType = int32(t) diff --git a/comm/usersession.go b/comm/usersession.go index c97d7a5dd..2da501278 100644 --- a/comm/usersession.go +++ b/comm/usersession.go @@ -159,7 +159,15 @@ func (this *UserSession) Push() (err error) { // 克隆 func (this *UserSession) Clone() (clone *UserSession) { - + clone = &UserSession{ + msgqueue: make([]*pb.UserMessage, 0), + service: this.service, + IP: this.IP, + SessionId: this.SessionId, + GatewayServiceId: this.GatewayServiceId, + ServiceTag: this.ServiceTag, + UserId: this.UserId, + } return } diff --git a/modules/arena/api_challengereward.go b/modules/arena/api_challengereward.go index cf266b34f..ee0e6ce37 100644 --- a/modules/arena/api_challengereward.go +++ b/modules/arena/api_challengereward.go @@ -8,13 +8,13 @@ import ( cfg "go_dreamfactory/sys/configure/structs" ) -//参数校验 +// 参数校验 func (this *apiComp) ChallengeRewardCheck(session comm.IUserSession, req *pb.ArenaChallengeRewardReq) (errdata *pb.ErrorData) { return } -///挑战奖励领取 +// /挑战奖励领取 func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaChallengeRewardReq) (errdata *pb.ErrorData) { var ( reward *cfg.GameArenaActiveRewardData @@ -46,7 +46,7 @@ func (this *apiComp) ChallengeReward(session comm.IUserSession, req *pb.ArenaCha errdata = &pb.ErrorData{ Code: pb.ErrorCode_BattleValidationFailed, Title: pb.ErrorCode_BattleValidationFailed.ToString(), - Message: err.Error(), + Message: "battle iswin fail", } return } From 670ee979522b7e7bbc25a2a0bbe52674ad3b35ec Mon Sep 17 00:00:00 2001 From: liwei <2211068034@qq.com> Date: Tue, 11 Jul 2023 16:01:40 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=9C=8D=E5=8A=A1?= =?UTF-8?q?=E5=99=A8=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/arena/api_info.go | 5 ++--- modules/passon/modelPasson.go | 5 +++-- modules/sys/module.go | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/arena/api_info.go b/modules/arena/api_info.go index 93db6bf8f..7ecaf9452 100644 --- a/modules/arena/api_info.go +++ b/modules/arena/api_info.go @@ -46,9 +46,8 @@ func (this *apiComp) Info(session comm.IUserSession, req *pb.ArenaInfoReq) (errd if err == mgo.MongodbNil { global = this.module.ModuleTools.GetGlobalConf() info = &pb.DBArenaUser{ - Uid: session.GetUserId(), - Name: user.Name, - // Avatar: user.Avatar, + Uid: session.GetUserId(), + Name: user.Name, Lv: user.Lv, Sex: user.Gender, Skin: user.CurSkin, diff --git a/modules/passon/modelPasson.go b/modules/passon/modelPasson.go index 4fcd0135b..a7bd7d91b 100644 --- a/modules/passon/modelPasson.go +++ b/modules/passon/modelPasson.go @@ -57,8 +57,9 @@ func (this *modelPasson) getUserPasson(uid string) (results *pb.DBPasson, err er func (this *modelPasson) updateUserPasson(uid string, data *pb.DBPasson) (err error) { if err = this.Change(uid, map[string]interface{}{ - "teacher": data.Teacher, - "student": data.Student, + "passonlv": data.Passonlv, + "teacher": data.Teacher, + "student": data.Student, }); err != nil { this.module.Error("更新用户任务数据 错误!", log.Field{Key: "err", Value: err.Error()}) return diff --git a/modules/sys/module.go b/modules/sys/module.go index d539bd688..d1599a1bb 100644 --- a/modules/sys/module.go +++ b/modules/sys/module.go @@ -45,7 +45,7 @@ func (this *ModuleSys) Init(service core.IService, module core.IModule, options func (this *ModuleSys) Start() (err error) { err = this.ModuleBase.Start() var module core.IModule - if module, err = this.service.GetModule(comm.ModuleSys); err != nil { + if module, err = this.service.GetModule(comm.ModuleWtask); err != nil { return } this.wtask = module.(comm.IWtask)