Skip to content

Commit

Permalink
Hotfix: fix game end nil pointer dereference
Browse files Browse the repository at this point in the history
  • Loading branch information
jchv committed Jul 5, 2023
1 parent 2fc5a62 commit f0262ae
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions game/server/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ type Conn struct {
currentRoom *room.Room
}

func (c *Conn) triggerUpdate() {
select {
case c.updatePlayer <- struct{}{}:
default:
}
}

func (c *Conn) getLobbyPlayer() gamemodel.LobbyPlayer {
return gamemodel.LobbyPlayer{
PlayerID: uint32(c.player.PlayerID),
Expand Down Expand Up @@ -214,12 +221,7 @@ func (c *Conn) Handle(ctx context.Context) error {
Entry: c.getRoomPlayer(),
Conn: c.ServerConn,
PlayerData: c.getPlayerData(),
UpdateFunc: func() {
select {
case c.updatePlayer <- struct{}{}:
default:
}
},
UpdateFunc: c.triggerUpdate,
})
case *gamepacket.ClientAssistModeToggle:
c.SendMessage(ctx, &gamepacket.ServerAssistModeToggled{})
Expand Down Expand Up @@ -410,6 +412,7 @@ func (c *Conn) Handle(ctx context.Context) error {
Entry: c.getRoomPlayer(),
Conn: c.ServerConn,
PlayerData: c.getPlayerData(),
UpdateFunc: c.triggerUpdate,
})
c.currentRoom = joinRoom
}
Expand Down

0 comments on commit f0262ae

Please sign in to comment.