FAForever / server

The servercode for the Forged Alliance Forever lobby
http://www.faforever.com
GNU General Public License v3.0
67 stars 62 forks source link

Newly foed/friended players don't receive necessary game_info messages #1002

Open Askaholic opened 7 months ago

Askaholic commented 7 months ago

Scenario 1 - Adding a foe

Imagine you are hosting a game, a player joins the lobby who is just trolling and you don't want them in the game so you kick them. But they keep joining back into the lobby, so you add them as a foe to keep them out of the lobby. The server will now consider the game to be 'invisible' to that player and will prevent them from joining. But because the game is 'invisible' to them, they will stop receiving updates about the game including the updates that say the game has launched or ended and should be removed from the games view. The lobby will stick around on their client until they re-log.

Scenario 2 - Adding a friend

Similarly, imagine you hosted a game for 'friends only'. Now you want to let someone join who wasn't on your friends list yet, so you add them as a friend. The server now considers the game to be visible to them, however it will not actually send them the game_info message needed to display the game in their client until an update is naturally triggered via another player joining/leaving or the game settings being changed.

Log messages

This can cause the following log message to appear:

Client error: You cannot join games hosted by this player.

Reproduce

Scenario 1

  1. Player 1 host a game
  2. Player 1 add player 2 as a foe

Scenario 2

  1. Player 1 host a game with visibility set to 'friends'
  2. Player 1 add player 2 as a friend

Solution

The social_add command should check if the current player is hosting a game, and if so immediately send a game_info message to the added player as follows:

If the player was foed and the game was previously visible to the player: