This commit is contained in:
aozhiwei 2023-09-13 12:43:59 +08:00
parent 2ca100c006
commit 0c61ae146a

View File

@ -169,6 +169,9 @@ func (this *room) CMStartGame(hdr *f5.MsgHdr, msg *cs.CMStartGame) {
hum.SendMsg(rspMsg)
return
}
if this.canStart() {
this.doStart(1)
}
hum.SendMsg(rspMsg)
}
@ -209,10 +212,10 @@ func (this *room) broadcastMsg(msg proto.Message) {
func (this *room) autoStart() {
if this.roomState == ROOM_INIT_STATE {
if this.getTeamNum() < ROOM_MIN_START_TEAM_NUM {
this.doDisband(0)
} else {
if this.canStart() {
this.doStart(0)
} else {
this.doDisband(0)
}
}
}
@ -272,7 +275,6 @@ func (this *room) notifyGameStart() {
StartTime: int32(this.startTime),
}
q5.NewSlice(&startInfo.TeamList, 0, 10)
this.gameStartNotifyMsg.CustomRoomPayload = proto.String(q5.EncodeJson(&startInfo))
for _, t := range(this.teams) {
if t.hasAlreadMember() {
ele := q5.NewSliceElement(&startInfo.TeamList)
@ -289,6 +291,7 @@ func (this *room) notifyGameStart() {
})
}
}
this.gameStartNotifyMsg.CustomRoomPayload = proto.String(q5.EncodeJson(&startInfo))
}
for _, m := range(this.members) {
if m.state == MEMBER_READY_STATE &&
@ -298,3 +301,13 @@ func (this *room) notifyGameStart() {
}
}
}
func (this *room) canStart() bool {
alreadyNum := 0
for _, t := range(this.teams) {
if t.hasAlreadMember() {
alreadyNum++
}
}
return alreadyNum >- ROOM_MIN_START_TEAM_NUM
}