Repository navigation
fix(coop): write the host's save at once when the PvP client plays the aliens - #237
Merged
Merged
Conversation
A PvP campaign whose client plays the aliens (gamemode 2): the host saves in the fresh campaign, after the alien client crashes and rejoins (quick save, autosave, OPTIONS > SAVE GAME), and after both players reload the host's save. Each save must be written within 15 s.
…e aliens In a PvP campaign whose client plays the aliens (gamemode 2), every host save after the alien client rejoined, or after a resumed campaign, stayed on "Saving..." forever. The host defers a save to ask the client for its world only while its co-op session flag is set. A freshly started campaign never sets it, so those saves wrote at once. A rejoin or a resume runs the COOP_READY handshake, which sets it, so the next quick save, autosave or menu save asked the alien client. That client never places a base: its world holds one unnamed base at 0,0, so it holds its answer until the base is named, which never happens. The alien client has no world of its own to send, and the host's save already embeds a stand-in world for it. Skip the deferral in gamemode 2, as a fresh campaign already did.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In a PvP campaign where the host plays X-COM and the client plays the aliens (gamemode 2), a host save could hang on "Saving..." (the co-op save-wait dialog) with CANCEL showing, and no file was written. This happened to the quick save, the autosave and OPTIONS > SAVE GAME:
A save in a freshly started campaign worked.
Root cause (captured with temporary logging, since removed)
SaveGameStatedefers a host geoscape save so it can ask the client for its world first, but only while the host's co-op session flag is set. The logging printed each part of that condition at every save:A freshly started campaign never sets the flag, so its saves never ask. A rejoin or a resume runs the COOP_READY handshake, which sets it, so every later save asks the alien client. The alien client never places a base. Before and after the rejoin,
geo_stateshows its world holding one base named''at 0,0, withnoBases=True gamemode=2.coopOwnBaseUnnamed()is therefore always true, and the client holds its answer until that base is named, which never happens.The alien client has no world of its own to send. The host's save already embeds a stand-in world for it (
SavedGame::save), and, from reading the code, its receive path rejects a world with no real base (CoopState(994)). So making the client answer is not the fix.Fix
SaveGameStateskips the deferral in gamemode 2 and writes at once, as a freshly started campaign already did. Every other mode is unchanged.Test
tools/coop_test/test_pvp_campaign_save_after_rejoin.py(8 s locally). It runs a gamemode 2 campaign and checks five saves: one in the fresh campaign, a quick save, autosave and menu save after the alien client crashes and rejoins, and a quick save after both players reload the menu save. It also checks that the client comes back on the alien side.main8ccc045: fails 3 of 3.freshpasses.rejoin,autosave,menuandreloadeach fail withhost save ... not written after 15 s: host top CoopState dialog code 54 title 'Saving...'; alien client said ['[coop-save] save request held: own base unnamed'].test_campaign_resume_gm2,test_campaign_battle_gm2,test_pvp_campaign_resume,test_pvp_campaign_reconnect,test_pvp_campaign_month,test_pvp_rehost_mode,test_client_zero_disk.