server icon indicating copy to clipboard operation
server copied to clipboard

Issue/#858 validity in game info

Open Askaholic opened this issue 3 years ago • 1 comments

Adds game validity to the game_info messages. This requires quite a lot of refactoring because the validity needs to be re-evaluated every time any of the attributes that affect validity change. Previously, each of the checks only ran at certain times such as when the game launched or after it was finished. Refactoring this was also made more difficult by the fact that the game handling logic is already such a mess. Hopefully this approach of moving the validation code out of the Game class helps with that, but I'm still not 100% happy with it. There are still some problems with it:

  • The ValidationRules are very tightly coupled to the Game class, some of them even use 'private' variables from Game
  • The validity computation is somewhat expensive as it is likely to be called many times, especially while a game is in the lobby state. It is also extremely difficult to cache because it has so many dependencies that would need to invalidate the cache whenever they change.

Some other issues that came up:

  • Whenever the ScenarioFile game option is set, we need to query the database in order to get the map id and to check if the map is ranked. This is an async operation, but it doesn't otherwise make sense to make set_game_option an async function. So it's a little unclear where exactly the await should happen.
  • Games are marked as dirty quite liberally, even if nothing that affects the to_dict method would actually change
  • We might want to rename some of the validity states since the enum names are used in the protocol

Closes #858

Askaholic avatar Apr 04 '22 06:04 Askaholic

Api returns HAS_AI, but server defined only HAS_AI_PLAYERS

https://github.com/FAForever/server/blob/7c96b3b727867d7ea3aa4893d55f33b97acf3c87/server/games/typedefs.py#L68

image

api: MULTIPLE_TEAMS server : MULTI_TEAM

Eternal-ll avatar Oct 11 '22 07:10 Eternal-ll