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] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=88=98=E6=96=97=E4=BB=A3?= =?UTF-8?q?=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 }