diff --git a/server/matchserver/common/types.go b/server/matchserver/common/types.go index 895ae654..39fa7c2d 100644 --- a/server/matchserver/common/types.go +++ b/server/matchserver/common/types.go @@ -114,6 +114,7 @@ type Player interface { FillMFTeamMember(*cs.MFTeamMember) GetSortIdx() int32 SetSortIdx(int32) + GenNextCopy() Player } type PlayerMgr interface { diff --git a/server/matchserver/player/player.go b/server/matchserver/player/player.go index 54cca11a..09ba607b 100644 --- a/server/matchserver/player/player.go +++ b/server/matchserver/player/player.go @@ -161,6 +161,25 @@ func (this *player) SetSortIdx(sortIdx int32) { this.sortIdx = sortIdx } +func (this *player) GenNextCopy() common.Player { + nextCopy := newPlayer() + //nextCopy.socket + nextCopy.accountId = this.accountId + nextCopy.sessionId = this.sessionId + nextCopy.zoneId = this.zoneId + nextCopy.nodeId = this.nodeId + nextCopy.name = this.name + nextCopy.avatarUrl = this.avatarUrl + nextCopy.headFrame = this.headFrame + nextCopy.state = 0 + nextCopy.isReady = 0 + nextCopy.permission = 0 + nextCopy.hero = this.hero + nextCopy.team = nil + nextCopy.sortIdx = 0 + return nextCopy +} + func (this *player) FillMFTeamMember(member_pb *cs.MFTeamMember) { member_pb.AccountId = proto.String(this.accountId) member_pb.Name = proto.String(this.name) diff --git a/server/matchserver/team/team.go b/server/matchserver/team/team.go index 57fbb4c0..734a2c50 100644 --- a/server/matchserver/team/team.go +++ b/server/matchserver/team/team.go @@ -30,12 +30,13 @@ type team struct { matchTick int64 } -func (this *team) init(copyIdx int32, teamUuid string, owner common.Player, mapInfo* common.MapInfoRsp) { +func (this *team) init(copyIdx int32, zoneId int32, nodeId int32, + teamUuid string, owner common.Player, mapInfo* common.MapInfoRsp) { this.sortIdx++ this.teamUuid = teamUuid this.copyIdx = copyIdx - this.zoneId = owner.GetZoneId() - this.nodeId = owner.GetNodeId() + this.zoneId = zoneId + this.nodeId = nodeId this.mapInfo = mapInfo this.owner = owner this.owner.SetPermission(1) @@ -394,7 +395,8 @@ func (this *team) genNextCopyTeam() { nextMapInfo := &common.MapInfoRsp{} *nextMapInfo = *this.mapInfo nextTeam := newTeam() - nextTeam.init(nextCopyIdx, this.nextTeamUuid, this.owner, nextMapInfo) + nextTeam.init(nextCopyIdx, this.zoneId, this.nodeId, + this.nextTeamUuid, this.owner.GenNextCopy(), nextMapInfo) _teamMgr.addTeam(nextTeam) } diff --git a/server/matchserver/team/teammgr.go b/server/matchserver/team/teammgr.go index 5b8ba93f..e300a067 100644 --- a/server/matchserver/team/teammgr.go +++ b/server/matchserver/team/teammgr.go @@ -26,7 +26,7 @@ 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, mapInfo) + team.init(copyIdx, hum.GetZoneId(), hum.GetNodeId(), teamUuid, hum, mapInfo) this.teamUuidHash[team.teamUuid] = team this.addTeam(team) return team