1
This commit is contained in:
parent
c2c0644f31
commit
a8ff5bf545
@ -8,6 +8,7 @@ import (
|
|||||||
"main/constant"
|
"main/constant"
|
||||||
|
|
||||||
"sort"
|
"sort"
|
||||||
|
"strings"
|
||||||
"github.com/golang/protobuf/proto"
|
"github.com/golang/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,8 +30,7 @@ type team struct {
|
|||||||
matchTick int64
|
matchTick int64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *team) init(copyIdx int32, teamUuid string,
|
func (this *team) init(copyIdx int32, teamUuid string, owner common.Player, mapInfo* common.MapInfoRsp) {
|
||||||
owner common.Player, msg *cs.CMLogin, mapInfo* common.MapInfoRsp) {
|
|
||||||
this.sortIdx++
|
this.sortIdx++
|
||||||
this.teamUuid = teamUuid
|
this.teamUuid = teamUuid
|
||||||
this.copyIdx = copyIdx
|
this.copyIdx = copyIdx
|
||||||
@ -375,6 +375,27 @@ func (this *team) genStartGameInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *team) genNextCopyTeam() {
|
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) {
|
func (this *team) broadcastMsg(msg proto.Message) {
|
||||||
|
@ -26,11 +26,16 @@ func (this *teamMgr) CreateTeam(hum common.Player, msg *cs.CMLogin, mapInfo* com
|
|||||||
var copyIdx int32 = 0
|
var copyIdx int32 = 0
|
||||||
teamUuid := this.genTeamUuid(copyIdx, hum.GetZoneId(), hum.GetNodeId())
|
teamUuid := this.genTeamUuid(copyIdx, hum.GetZoneId(), hum.GetNodeId())
|
||||||
team := newTeam()
|
team := newTeam()
|
||||||
team.init(copyIdx, teamUuid, hum, msg, mapInfo)
|
team.init(copyIdx, teamUuid, hum, mapInfo)
|
||||||
this.teamUuidHash[team.teamUuid] = team
|
this.teamUuidHash[team.teamUuid] = team
|
||||||
|
this.addTeam(team)
|
||||||
return 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 {
|
func (this *teamMgr) genTeamUuid(zoneId int32, nodeId int32, copyIdx int32) string {
|
||||||
teamUuid := ""
|
teamUuid := ""
|
||||||
for true {
|
for true {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user