From 29e2eddb282ea1b815c85d07ab5c0e7a8f989161 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 19 Mar 2024 11:33:09 +0800 Subject: [PATCH] 1 --- server/matchserver/player/player.go | 63 +++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 3 deletions(-) diff --git a/server/matchserver/player/player.go b/server/matchserver/player/player.go index 4c5b5ba2..887184ba 100644 --- a/server/matchserver/player/player.go +++ b/server/matchserver/player/player.go @@ -311,6 +311,7 @@ func (this *player) CMChooseHero(hdr *f5.MsgHdr, msg *cs.CMChooseHero) { if this.GetTeam().Started() { rspMsg.Errcode = proto.Int32(1) rspMsg.Errmsg = proto.String("team already started") + this.SendMsg(rspMsg) return } else { this.updateChoose( @@ -336,11 +337,23 @@ func (this *player) CMChooseMap(hdr *f5.MsgHdr, msg *cs.CMChooseMap) { if this.GetTeam().Started() { rspMsg.Errcode = proto.Int32(1) rspMsg.Errmsg = proto.String("team already started") + this.SendMsg(rspMsg) } else { - //this.GetTeam().SetMapId(msg.GetMapId()) + this.updateMap( + msg.GetMapId(), + func (errCode int32, errMsg string) { + if errCode == 0 { + this.SendMsg(rspMsg) + if this.GetTeam() != nil { + this.GetTeam().SendUpdateNotify() + } + } else { + rspMsg.Errcode = proto.Int32(errCode) + rspMsg.Errmsg = proto.String(errMsg) + this.SendMsg(rspMsg) + } + }) } - this.SendMsg(rspMsg) - this.GetTeam().SendUpdateNotify() } func (this *player) updateChoose(skillId int32, heroUniId string, @@ -389,6 +402,50 @@ func (this *player) updateChoose(skillId int32, heroUniId string, }) } +func (this *player) updateMap(mapId int32, + cb func (int32, string)) { + params := map[string]string{ + "c": "User", + "a": "getMapConf", + "account_id": this.accountId, + "session_id": this.sessionId, + "map_id": q5.ToString(mapId), + } + url := fmt.Sprintf("%s/webapp/index.php", mt.Table.Config.GetById(0).GetGameapiUrl()) + f5.GetHttpCliMgr().SendJsStyleRequest( + url, + params, + func(rsp f5.HttpCliResponse) { + if this.GetTeam() != nil && !this.GetTeam().Started() { + if rsp.GetErr() != nil { + cb(500, "server internal error") + return + } + } + rspObj := common.MapInfoRsp{} + { + f5.GetSysLog().Info("updateMap:%s", rsp.GetRawData()) + err := json.Unmarshal([]byte(rsp.GetRawData()), &rspObj) + if err != nil { + cb(500, "server internal error") + return + } + if rspObj.MapId == 0 { + cb(1, "map error") + return + } + if rspObj.IsOpen == 0 { + cb(2, "map no open") + return + } + { + this.GetTeam().SetMapInfo(&rspObj) + cb(0, "") + } + } + }) +} + func (this *player) CMGrantInvitePermission(hdr *f5.MsgHdr, msg *cs.CMGrantInvitePermission) { rspMsg := &cs.SMGrantInvitePermission{} if this.GetTeam().Started() {