From 0c61ae146aa6a1c1d6780c55131c9ee2c214c5aa Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 13 Sep 2023 12:43:59 +0800 Subject: [PATCH] 1 --- server/hallserver/room/room.go | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/server/hallserver/room/room.go b/server/hallserver/room/room.go index 1fca4410..a57a43d8 100644 --- a/server/hallserver/room/room.go +++ b/server/hallserver/room/room.go @@ -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 +}