Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change: [Network] Update NetworkGameInfo only when needed #9196

Merged
merged 3 commits into from May 5, 2021

Conversation

rubidium42
Copy link
Contributor

Motivation / Problem

Currently sending the NetworkGameInfo data to a client entails copying the data from all kinds of locations into a just allocated structure and then throwing it away after that. The problem is that except for 4 things, the rest is pretty must static data. So effort is placed into copying the data, instead of just having it ready and only updating those 4 things.

Description

First move more from NetworkGameInfo to NetworkServerGameInfo. NetworkServerGameInfo already contained "clients_on" and updated that via a global variable of it. After that return and pass that global variable into the serialization functions after updating it. That saves already the copy of that "clients_on" variable from one structure to another.

Next split the "static" and "dynamic" things; clients/companies/spectators on as well as the date are considered dynamic. The rest, such as revision, map size, start date, server name, maximum number of clients and so on are considered "static". These static ones will be updated in a callback of the appropriate settings (most already had one), and upon starting the game.

Bonus: renamed map_set to landscape, as that's more in line with how it's called in other places.

Limitations

None.

Checklist for review

Some things are not automated, and forgotten often. This list is a reminder for the reviewers.

  • The bug fix is important enough to be backported? (label: 'backport requested')
  • This PR affects the save game format? (label 'savegame upgrade')
  • This PR affects the GS/AI API? (label 'needs review: Script API')
    • ai_changelog.hpp, gs_changelog.hpp need updating.
    • The compatibility wrappers (compat_*.nut) need updating.
  • This PR affects the NewGRF API? (label 'needs review: NewGRF')

…rver side and serialize that for the clients
Split the updating in a "static" version that only needs to be called when a new map is loaded or some settings are changed, and a "dynamic" version that updates everything that changes regularly such as the current game date or the number of spectators.
@rubidium42 rubidium42 merged commit ead30dc into OpenTTD:master May 5, 2021
@rubidium42 rubidium42 deleted the more_static_game_info branch May 5, 2021 19:01
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.

None yet

2 participants