This commit is contained in:
aozhiwei 2024-03-19 20:00:28 +08:00
parent c2c0644f31
commit a8ff5bf545
2 changed files with 29 additions and 3 deletions

View File

@ -8,6 +8,7 @@ import (
"main/constant"
"sort"
"strings"
"github.com/golang/protobuf/proto"
)
@ -29,8 +30,7 @@ type team struct {
matchTick int64
}
func (this *team) init(copyIdx int32, teamUuid string,
owner common.Player, msg *cs.CMLogin, mapInfo* common.MapInfoRsp) {
func (this *team) init(copyIdx int32, teamUuid string, owner common.Player, mapInfo* common.MapInfoRsp) {
this.sortIdx++
this.teamUuid = teamUuid
this.copyIdx = copyIdx
@ -375,6 +375,27 @@ func (this *team) genStartGameInfo() {
}
func (this *team) genNextCopyTeam() {
nextCopyIdx := this.copyIdx + 1
oldId := q5.ToString(this.zoneId) + "_" +
q5.ToString(this.nodeId) + "_" +
q5.ToString(this.copyIdx) + "_";
newId := q5.ToString(this.zoneId) + "_" +
q5.ToString(this.nodeId) + "_" +
q5.ToString(nextCopyIdx) + "_";
this.nextTeamUuid = strings.Replace(this.GetTeamUuid(), oldId, newId, 0)
if this.nextTeamUuid == this.GetTeamUuid() {
panic("genNextCopyTeam error1")
return
}
if _teamMgr.GetTeamByUuid(this.nextTeamUuid) != nil {
panic("genNextCopyTeam error2")
return
}
nextMapInfo := &common.MapInfoRsp{}
*nextMapInfo = *this.mapInfo
nextTeam := newTeam()
nextTeam.init(nextCopyIdx, this.nextTeamUuid, this.owner, nextMapInfo)
_teamMgr.addTeam(nextTeam)
}
func (this *team) broadcastMsg(msg proto.Message) {

View File

@ -26,11 +26,16 @@ func (this *teamMgr) CreateTeam(hum common.Player, msg *cs.CMLogin, mapInfo* com
var copyIdx int32 = 0
teamUuid := this.genTeamUuid(copyIdx, hum.GetZoneId(), hum.GetNodeId())
team := newTeam()
team.init(copyIdx, teamUuid, hum, msg, mapInfo)
team.init(copyIdx, teamUuid, hum, mapInfo)
this.teamUuidHash[team.teamUuid] = team
this.addTeam(team)
return team
}
func (this *teamMgr) addTeam(team *team) {
this.teamUuidHash[team.teamUuid] = team
}
func (this *teamMgr) genTeamUuid(zoneId int32, nodeId int32, copyIdx int32) string {
teamUuid := ""
for true {