1
This commit is contained in:
parent
8c2c5c598f
commit
7f802a1e75
@ -142,6 +142,10 @@ func (this *room) getTeamNum() int32 {
|
||||
return int32(len(this.teamUuidHash))
|
||||
}
|
||||
|
||||
func (this *room) getObTeamNum() int32 {
|
||||
return int32(len(this.obTeamUuidHash))
|
||||
}
|
||||
|
||||
func (this *room) canJoin(member common.Player, msg *cs.CMJoinRoom) bool {
|
||||
if this.started() {
|
||||
return false
|
||||
@ -149,9 +153,6 @@ func (this *room) canJoin(member common.Player, msg *cs.CMJoinRoom) bool {
|
||||
if member.GetRoom() != nil {
|
||||
return false
|
||||
}
|
||||
if this.getTeamNum() >= this.config.maxTeamNum {
|
||||
return false
|
||||
}
|
||||
if this.getMember(member.GetAccountId()) != nil {
|
||||
return false
|
||||
}
|
||||
@ -159,8 +160,24 @@ func (this *room) canJoin(member common.Player, msg *cs.CMJoinRoom) bool {
|
||||
return false
|
||||
}
|
||||
t := this.getTeamByUuid(msg.GetTeamUuid())
|
||||
if t != nil && t.getMemberNum() >= constant.ROOM_MAX_TEAM_MEMBER_NUM {
|
||||
return false
|
||||
if t == nil {
|
||||
t = this.getObTeamByUuid(msg.GetTeamUuid())
|
||||
}
|
||||
if t != nil {
|
||||
if t.isFull() {
|
||||
return false
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
if msg.GetIsObserver() != 0 {
|
||||
if this.isObTeamFull() {
|
||||
return false
|
||||
}
|
||||
} else {
|
||||
if this.isTeamFull() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
@ -169,19 +186,37 @@ func (this *room) isTeamFull() bool {
|
||||
return this.getTeamNum() >= this.config.maxTeamNum
|
||||
}
|
||||
|
||||
func (this *room) isObTeamFull() bool {
|
||||
return this.getObTeamNum() >= this.config.maxTeamNum
|
||||
}
|
||||
|
||||
func (this *room) join(hum common.Player, msg *cs.CMJoinRoom) bool {
|
||||
if !this.canJoin(hum, msg) {
|
||||
return false
|
||||
}
|
||||
m := newMember(this, hum)
|
||||
this.addMember(m)
|
||||
t := this.getTeamByUuid(msg.GetTeamUuid())
|
||||
if t == nil {
|
||||
this.addTeam(newTeam(this, this.genTeamId(), msg.GetTeamUuid(), m))
|
||||
} else {
|
||||
t.addMember(m)
|
||||
t = this.getObTeamByUuid(msg.GetTeamUuid())
|
||||
}
|
||||
if t != nil {
|
||||
if t.isFull() {
|
||||
return false
|
||||
}
|
||||
m := newMember(this, hum)
|
||||
this.addMember(m)
|
||||
this.autoStartCountdown()
|
||||
return true
|
||||
}
|
||||
m := newMember(this, hum)
|
||||
this.addMember(m)
|
||||
t = newTeam(this, this.genTeamId(), msg.GetTeamUuid(), m)
|
||||
t.addMember(m)
|
||||
if msg.GetIsObserver() != 0 {
|
||||
this.addObTeam(t)
|
||||
} else {
|
||||
this.addTeam(t)
|
||||
this.autoStartCountdown()
|
||||
}
|
||||
this.autoStartCountdown()
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"cs"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"q5"
|
||||
"main/constant"
|
||||
)
|
||||
|
||||
// TeamInfo from client data
|
||||
@ -163,6 +164,10 @@ func (this *team) isObserver() bool {
|
||||
return this.room.getObTeamById(this.teamId) != nil
|
||||
}
|
||||
|
||||
func (this *team) isFull() bool {
|
||||
return this.getMemberNum() >= constant.ROOM_MAX_TEAM_MEMBER_NUM
|
||||
}
|
||||
|
||||
func newTeam(room *room, teamId int32, teamUuid string, leader *member) *team {
|
||||
t := new(team)
|
||||
t.init(room, teamId, teamUuid)
|
||||
|
Loading…
x
Reference in New Issue
Block a user