Skip to content

fix(coop): keep a PvP client's new base in the host's copy of its world (#21) - #234

Merged
NonPolynomialTim merged 1 commit into
mainfrom
fix/issue-21-pvp-second-base
Nov 6, 2026
Merged

NonPolynomialTim merged 1 commit into
mainfrom
fix/issue-21-pvp-second-base

Conversation

@NonPolynomialTim

Copy link
Copy Markdown
Collaborator

Problem

In a PvP campaign where the host plays the alien side, the X-COM player's second base disappears. Reproduced on stock data at main 8ccc045c9: the client builds a second base, then crashes (or loses its connection) and rejoins. The second base is gone from its own base list and from the host's globe. The same happens when the host takes SAVE & QUIT on its waiting dialog after the client dropped and both players reload that save.

Root cause

The X-COM client's world lives on the host as a copy. The host serves that copy to a rejoining client and writes it into a save it makes without asking the client. The client sent its world only at the campaign start, around battles and for soldier gifts. Building a base sent only the globe marker, so the copy stayed at its campaign-start state.

Captured with temporary logging on the host's store and serve paths (since removed):

client 20-16-42.174  pushed client progress to host               (campaign start)
host   20-16-42.237  stored client world hash=8576377044837140726  realBases=['XcomBase']
client 20-16-44.682  lift placed: base 'SecondBase' (gm3 client)   (nothing sent)
host   20-16-47.689  serves stored client world hash=8576377044837140726   (rejoin)

A host save through the save menu or an autosave first asks the client for its current world, so it keeps the base. Only the paths that read the copy directly lose it.

Fix

PlaceLiftState::viewClick: after a PvP player places the access lift of a later base, it sends its world to the host (pushProgressToHostSilently). That call does nothing on the host and on the alien side, and SHARED and SEPARATE campaigns never reach this branch.

Test

tools/coop_test/test_pvp_second_base.py, stock data, both alien sides. It checks both machines after every step: the X-COM machine owns each base once, and the alien machine shows each one once.

  • Host as alien: build SecondBase, client crash and rejoin, month end, build ThirdBase, client crash, host SAVE & QUIT, both reload.
  • Client as alien: build SecondBase, month end, host save, both reload, client crash and rejoin.

On main: red 3 of 3. SecondBase is lost at the rejoin, and ThirdBase is lost from the SAVE & QUIT save. The client-as-alien leg passes. With the fix: green, then 20 of 20 in a row (10 per harness slot, two slots in parallel), about 21 s per run. Related tests pass once each: test_pvp_duplicate_bases, test_pvp_campaign_resume, test_pvp_campaign_battle, test_pvp_campaign_reconnect, test_pvp_campaign_month.

The client-as-alien case from the report (host is X-COM, no battle) does not reproduce on current main, under stock data or X-Com Files 3.9. The host's bases live in its own world, and they survive the month end, the host's save and reload, and a client rejoin.

Fixes #21

…ld (#21)

In a PvP campaign with the host on the alien side, the X-COM client's world
lives on the host as a copy. The host serves that copy when the client rejoins
after a drop, and writes it into a save it makes without asking the client
(SAVE & QUIT on its waiting dialog after the client dropped). The client sent
its world only at the campaign start, around battles and for soldier gifts, so
a base built later was missing from the copy: it vanished from both machines
on a rejoin, and from that save.

The client now sends its world to the host when it places the access lift of
a later base.

test_pvp_second_base covers both alien sides: a later base on both machines
after a client crash and rejoin, the month-end report, and the host's save
reloaded by both players.
@NonPolynomialTim
NonPolynomialTim enabled auto-merge (squash) November 6, 2026 01:46
@NonPolynomialTim
NonPolynomialTim enabled auto-merge (squash) November 6, 2026 02:05
@NonPolynomialTim
NonPolynomialTim merged commit 4efc32c into main Nov 6, 2026
11 checks passed
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.

[Bug] Second Base gets deleted in X-Com Files 3.9.1b when either player plays as Alien

1 participant