From 4e2973a6c614cca8d9657ac77d72f00f69c89e90 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Sat, 12 Oct 2024 13:57:22 +0800 Subject: [PATCH] 1 --- server/matchserver/common/types.go | 6 +-- server/matchserver/player/player.go | 78 ++++++++++------------------- 2 files changed, 30 insertions(+), 54 deletions(-) diff --git a/server/matchserver/common/types.go b/server/matchserver/common/types.go index b7658cf3..c4b5264f 100644 --- a/server/matchserver/common/types.go +++ b/server/matchserver/common/types.go @@ -16,12 +16,12 @@ type BattleItem struct { } type UserInfo struct { - Activated string `json:"activated"` - RenameCount string `json:"rename_count"` + //Activated string `json:"activated"` + //RenameCount string `json:"rename_count"` AccountId string `json:"account_id"` Name string `json:"name"` HeadId string `json:"head_id"` - HeroId string `json:"hero_id"` + //HeroId string `json:"hero_id"` HeadFrame string `json:"head_frame"` TotalLucky interface{} `json:"total_lucky"` AdmissionItemNum interface{} `json:"admission_item_num"` diff --git a/server/matchserver/player/player.go b/server/matchserver/player/player.go index b5c94adf..9d2896e9 100644 --- a/server/matchserver/player/player.go +++ b/server/matchserver/player/player.go @@ -52,29 +52,35 @@ func (this *player) SendMsg(rspMsg proto.Message) { } } +func (this *player) parseUserInfo(userInfo *common.UserInfo){ + this.name = userInfo.Name + this.avatarUrl = userInfo.HeadId + this.headFrame = userInfo.HeadFrame + q5.DuckToSimple(userInfo.TotalLucky, &this.totalLucky) + q5.DuckToSimple(userInfo.AdmissionItemNum, &this.admissionItemNum) + q5.DuckToSimple(userInfo.CircuitScore, &this.circuitScore) +} + +func (this *player) parseHeroInfo(heroInfo *common.HeroInfo){ + this.hero.heroUniId = heroInfo.HeroUniId + this.hero.heroId = q5.ToInt32(heroInfo.HeroId) + this.hero.quality = q5.ToInt32(heroInfo.Quality) + this.hero.specSkill = q5.ToInt32(heroInfo.SpecSkill) + q5.DuckToSimple(heroInfo.Wealth, &this.hero.wealth) + q5.DuckToSimple(heroInfo.ValidLefttime, &this.hero.validLeftTime) + q5.DuckToSimple(heroInfo.CurrentTimes, &this.hero.currentTimes) + q5.DuckToSimple(heroInfo.TotalTimes, &this.hero.totalTimes) + q5.DuckToSimple(heroInfo.SkinId, &this.hero.skinId) +} + func (this *player) init(req *pendingLoginRequest, rsp *common.LoginRsp){ this.socket = req.hdr.GetSocket() this.accountId = req.msg.GetAccountId() this.sessionId = req.msg.GetSessionId() this.zoneId = req.msg.GetZoneId() this.nodeId = req.msg.GetNodeId() - this.name = rsp.Info.UserInfo.Name - this.avatarUrl = rsp.Info.UserInfo.HeadId - this.headFrame = rsp.Info.UserInfo.HeadFrame - q5.DuckToSimple(rsp.Info.UserInfo.AdmissionItemNum, &this.admissionItemNum) - q5.DuckToSimple(rsp.Info.UserInfo.CircuitScore, &this.circuitScore) - q5.DuckToSimple(rsp.Info.UserInfo.TotalLucky, &this.totalLucky) - { - this.hero.heroUniId = rsp.Info.HeroInfo.HeroUniId - this.hero.heroId = q5.ToInt32(rsp.Info.HeroInfo.HeroId) - this.hero.quality = q5.ToInt32(rsp.Info.HeroInfo.Quality) - this.hero.specSkill = q5.ToInt32(rsp.Info.HeroInfo.SpecSkill) - q5.DuckToSimple(rsp.Info.HeroInfo.Wealth, &this.hero.wealth) - q5.DuckToSimple(rsp.Info.HeroInfo.ValidLefttime, &this.hero.validLeftTime) - q5.DuckToSimple(rsp.Info.HeroInfo.CurrentTimes, &this.hero.currentTimes) - q5.DuckToSimple(rsp.Info.HeroInfo.TotalTimes, &this.hero.totalTimes) - q5.DuckToSimple(rsp.Info.HeroInfo.SkinId, &this.hero.skinId) - } + this.parseUserInfo(&rsp.Info.UserInfo) + this.parseHeroInfo(&rsp.Info.HeroInfo) } func (this *player) againInit(req *pendingLoginRequest, rsp *common.LoginRsp){ @@ -83,23 +89,8 @@ func (this *player) againInit(req *pendingLoginRequest, rsp *common.LoginRsp){ this.sessionId = req.msg.GetSessionId() this.zoneId = req.msg.GetZoneId() this.nodeId = req.msg.GetNodeId() - this.name = rsp.Info.UserInfo.Name - this.avatarUrl = rsp.Info.UserInfo.HeadId - this.headFrame = rsp.Info.UserInfo.HeadFrame - q5.DuckToSimple(rsp.Info.UserInfo.AdmissionItemNum, &this.admissionItemNum) - q5.DuckToSimple(rsp.Info.UserInfo.CircuitScore, &this.circuitScore) - q5.DuckToSimple(rsp.Info.UserInfo.TotalLucky, &this.totalLucky) - { - this.hero.heroUniId = rsp.Info.HeroInfo.HeroUniId - this.hero.heroId = q5.ToInt32(rsp.Info.HeroInfo.HeroId) - this.hero.quality = q5.ToInt32(rsp.Info.HeroInfo.Quality) - this.hero.specSkill = q5.ToInt32(rsp.Info.HeroInfo.SpecSkill) - q5.DuckToSimple(rsp.Info.HeroInfo.Wealth, &this.hero.wealth) - q5.DuckToSimple(rsp.Info.HeroInfo.ValidLefttime, &this.hero.validLeftTime) - q5.DuckToSimple(rsp.Info.HeroInfo.CurrentTimes, &this.hero.currentTimes) - q5.DuckToSimple(rsp.Info.HeroInfo.TotalTimes, &this.hero.totalTimes) - q5.DuckToSimple(rsp.Info.HeroInfo.SkinId, &this.hero.skinId) - } + this.parseUserInfo(&rsp.Info.UserInfo) + this.parseHeroInfo(&rsp.Info.HeroInfo) } func (this *player) GetSocket() f5.WspCliConn { @@ -432,23 +423,8 @@ func (this *player) CMRefreshUser(hdr *f5.MsgHdr, msg *cs.CMRefreshUser) { func(rsp f5.HttpCliResponse) { this.SendMsg(rspMsg) if rsp.GetErr() == nil && rsp.JsonParseOk() { - this.name = rspObj.Info.UserInfo.Name - this.avatarUrl = rspObj.Info.UserInfo.HeadId - this.headFrame = rspObj.Info.UserInfo.HeadFrame - q5.DuckToSimple(rspObj.Info.UserInfo.AdmissionItemNum, &this.admissionItemNum) - q5.DuckToSimple(rspObj.Info.UserInfo.CircuitScore, &this.circuitScore) - q5.DuckToSimple(rspObj.Info.UserInfo.TotalLucky, &this.totalLucky) - { - this.hero.heroUniId = rspObj.Info.HeroInfo.HeroUniId - this.hero.heroId = q5.ToInt32(rspObj.Info.HeroInfo.HeroId) - this.hero.quality = q5.ToInt32(rspObj.Info.HeroInfo.Quality) - this.hero.specSkill = q5.ToInt32(rspObj.Info.HeroInfo.SpecSkill) - q5.DuckToSimple(rspObj.Info.HeroInfo.Wealth, &this.hero.wealth) - q5.DuckToSimple(rspObj.Info.HeroInfo.ValidLefttime, &this.hero.validLeftTime) - q5.DuckToSimple(rspObj.Info.HeroInfo.CurrentTimes, &this.hero.currentTimes) - q5.DuckToSimple(rspObj.Info.HeroInfo.TotalTimes, &this.hero.totalTimes) - q5.DuckToSimple(rspObj.Info.HeroInfo.SkinId, &this.hero.skinId) - } + this.parseUserInfo(&rspObj.Info.UserInfo) + this.parseHeroInfo(&rspObj.Info.HeroInfo) if this.GetTeam() != nil { this.GetTeam().SendUpdateNotify() }