diff --git a/server/hallserver/room/room.go b/server/hallserver/room/room.go index 8c169dd5..96a223a5 100644 --- a/server/hallserver/room/room.go +++ b/server/hallserver/room/room.go @@ -20,6 +20,7 @@ type room struct { zoneId int32 nodeId int32 passwd string + maxTeamNum int32 } owner *member roomState int32 @@ -43,6 +44,7 @@ func (this *room) init(roomId string, roomIdx int64, mapId int32, owner common.P this.config.zoneId = owner.GetZoneId() this.config.nodeId = owner.GetNodeId() this.config.passwd = passwd + this.config.maxTeamNum = constant.ROOM_MAX_TEAM_NUM this.owner = newMember(owner) this.members = map[string]*member{ owner.GetAccountId(): this.owner, @@ -93,7 +95,7 @@ func (this *room) canJoin(member common.Player, passwd string) bool { if member.GetRoom() != nil { return false } - if len(this.teamUuidHash) >= constant.ROOM_MAX_TEAM_NUM { + if int32(len(this.teamUuidHash)) >= this.config.maxTeamNum { return false } if this.getMember(member.GetAccountId()) != nil { @@ -346,13 +348,40 @@ func (this *room) isOwner(hum common.Player) bool { } func (this *room) getNextOwner() *member { - return nil + var minT *member + var maxT *member + for i := int32(1); i <= this.config.maxTeamNum; i++ { + if i != this.owner.team.teamId { + if t, ok := this.teamIdHash[i]; ok { + ownerCandidate := t.getOwnerCandidate() + if ownerCandidate != nil { + if i < this.owner.team.teamId && minT == nil { + minT = ownerCandidate + } + if i > this.owner.team.teamId && maxT == nil { + maxT = ownerCandidate + } + } + } + } + } + if maxT != nil { + return maxT + } else { + return minT + } } func (this *room) genTeamId() int32 { - teamId := int32(1) - for i := 1; i < constant.ROOM_MAX_TEAM_NUM; i++ { - + teamId := int32(-1) + for i := int32(1); i <= this.config.maxTeamNum; i++ { + if _, ok := this.teamIdHash[i]; !ok { + teamId = i + break + } + } + if teamId < 1 { + panic("room.genTeamId error") } return teamId } diff --git a/server/hallserver/room/team.go b/server/hallserver/room/team.go index 4554e6ce..e561b321 100644 --- a/server/hallserver/room/team.go +++ b/server/hallserver/room/team.go @@ -36,6 +36,10 @@ func (this *team) hasAlreadMember() bool { return ok } +func (this *team) getOwnerCandidate() *member { + return nil +} + func newTeam(teamId int32, leader *member) *team { t := new(team) t.teamId = teamId