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