Skip to content

Commit 87a64f7

Browse files
Indicate whether the game is ended by force (!mp end or game disband) when sending ServerGameEnded packets
1 parent 95ad280 commit 87a64f7

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

multiplayer/chat_bot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func handleCommandEndMatch(user *sessions.User, game *Game) string {
283283
return "The match is not currently in progress."
284284
}
285285

286-
game.EndGame()
286+
game.EndGame(true)
287287
return ""
288288
}
289289

multiplayer/game.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ func (game *Game) RemovePlayer(userId int) {
179179
// or if we're in a tournament and someone that is neither a referee or a spectator quit
180180
if game.isAllPlayersFinished() ||
181181
game.Data.IsTournamentMode && playerWasInMatch {
182-
game.EndGame()
182+
game.EndGame(false)
183183
} else if playerWasInMatch && len(game.playersInMatch) == 1 {
184184
game.MoveToSingleplayerSpectate()
185185
}
@@ -435,7 +435,7 @@ func (game *Game) StartGame() {
435435
}
436436

437437
// EndGame Ends the multiplayer game
438-
func (game *Game) EndGame() {
438+
func (game *Game) EndGame(force bool) {
439439
if !game.Data.InProgress {
440440
return
441441
}
@@ -460,7 +460,7 @@ func (game *Game) EndGame() {
460460
game.validateAndCacheSettings()
461461

462462
game.sendBotMessage("The match has ended.")
463-
game.sendPacketToPlayers(packets.NewServerGameEnded())
463+
game.sendPacketToPlayers(packets.NewServerGameEnded(force))
464464
sendLobbyUsersGameInfoPacket(game, true)
465465
}
466466

@@ -745,7 +745,7 @@ func (game *Game) SetPlayerFinished(userId int) {
745745
}
746746

747747
if game.isAllPlayersFinished() {
748-
game.EndGame()
748+
game.EndGame(false)
749749
}
750750
}
751751

@@ -886,7 +886,7 @@ func (game *Game) rotateHost() {
886886

887887
// Handles disbandment of the multiplayer game
888888
func (game *Game) disband() {
889-
game.EndGame()
889+
game.EndGame(true)
890890
game.isDisbanded = true
891891

892892
// Tournament mode games are kept around and deleted manually

packets/ServerGameEnded.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ package packets
22

33
type ServerGameEnded struct {
44
Packet
5+
Force bool `json:"force"`
56
}
67

7-
func NewServerGameEnded() *ServerGameEnded {
8+
func NewServerGameEnded(force bool) *ServerGameEnded {
89
return &ServerGameEnded{
910
Packet{Id: PacketIdServerGameEnded},
11+
force,
1012
}
1113
}

0 commit comments

Comments
 (0)