Skip to content

Conversation

@ex4dev
Copy link
Member

@ex4dev ex4dev commented Jul 5, 2025

This is a very old todo that we never really got around to. It eliminates cases where modules treat players as if they just joined the game after switching to a new instance within the same game. Modules should not be using PlayerSpawnEvent to trigger behavior that is supposed to happen when a player joins the game.

This PR also changes PlayerLeaveGameEvent to only be triggered when players join an instance that is not owned by their current game.

The PR changes the way Game#players is handled a bit. The list can now only be modified by calling addPlayer or removePlayer. When you call addPlayer, removePlayer is automatically called for the game the player is currently in. This way, it is impossible for a player to:

  • be stuck in more than one game at a time
  • be added to a game without calling PlayerJoinGameEvent,
  • be removed from a game without calling PlayerLeaveGameEvent
  • falsely be the target of PlayerJoinGameEvent or PlayerLeaveGameEvent after switching instances within the same game

Finally, the PR changes Team#players to address similar concerns.

TODO: make GameEvent not extend Cancellable, so PlayerLeaveGameEvent and PlayerJoinGameEvent can be not cancellable.
TODO: possibly change the cleanup task to use removePlayer instead of _players.remove.

The changes seem to work with the TestQueue but need testing with IPCQueue.

…ases

This makes the updated modules less error-prone for multi-instance games. It should have no effect on single-instance games.
@FluxCapacitor2
Copy link
Member

reminder: make GameEvent not extend Cancellable

@ex4dev ex4dev merged commit f1031ca into main Jul 12, 2025
1 check passed
@FluxCapacitor2 FluxCapacitor2 deleted the playerjoingameevent branch July 12, 2025 04:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants