This commit is contained in:
aozhiwei 2024-02-05 17:08:28 +08:00
parent 60597631f3
commit bee588b7ea
2 changed files with 15 additions and 2 deletions

View File

@ -23,6 +23,7 @@ type room struct {
nodeId int32
passwd string
maxTeamNum int32
maxObTeamNum int32
}
owner *member
roomState int32
@ -50,7 +51,12 @@ func (this *room) init(roomId string, roomIdx int64, owner common.Player, msg *c
this.config.zoneId = msg.GetZoneId()
this.config.nodeId = msg.GetNodeId()
this.config.passwd = msg.GetPasswd()
this.config.maxTeamNum = constant.ROOM_MAX_TEAM_NUM
if msg.GetMapId() == 12004 {
this.config.maxTeamNum = 2
} else {
this.config.maxTeamNum = 10
}
this.config.maxObTeamNum = 10
this.owner = newMember(this, owner)
this.addMember(this.owner)
this.addTeam(newTeam(this, this.genTeamId(), msg.GetTeamUuid(), this.owner))
@ -189,7 +195,7 @@ func (this *room) isTeamFull() bool {
}
func (this *room) isObTeamFull() bool {
return this.getObTeamNum() >= this.config.maxTeamNum
return this.getObTeamNum() >= this.config.maxObTeamNum
}
func (this *room) join(hum common.Player, msg *cs.CMJoinRoom) bool {

View File

@ -216,6 +216,13 @@ func (this *roomMgr) CMEnterObserver(hdr *f5.MsgHdr, msg *cs.CMEnterObserver) {
return;
}
if roomPtr.isObTeamFull() {
rspMsg.Errcode = proto.Int32(3)
rspMsg.Errmsg = proto.String("ob team is full")
hum.SendMsg(&rspMsg)
return
}
t := memberPtr.team
roomPtr.removeTeam(t)
roomPtr.addObTeam(t)