Skip to content

Store multiplayer campaign variables when the campaign moves on - #7892

Open
dustinspace217 wants to merge 1 commit into
scp-fs2open:masterfrom
dustinspace217:multi/standalone-campaign-vars
Open

dustinspace217 wants to merge 1 commit into
scp-fs2open:masterfrom
dustinspace217:multi/standalone-campaign-vars

Conversation

@dustinspace217

Copy link
Copy Markdown
Contributor

Fixes #4989

What?

Multiplayer campaigns now save their campaign variables and containers the way single player does: when the players continue to the next mission or take an optional loop, and not when they replay a mission or the campaign sends them back to retry it.

Why?

Two things were wrong, depending on how the game is hosted:

  • Player-hosted games never saved them. Every mission started from the variables' default values, so anything a campaign carries forward with them (choices, counters, branching) was lost.
  • Standalone servers saved them as soon as the mission ended. If the group picked Replay Mission, or the campaign sent them back to retry, the next attempt started with the values from the failed one.

Both go back to the 2014 change that made single player save these only on accept. The multiplayer paths weren't updated to match.

How?

multi_campaign_do_debrief is where both kinds of server go when everyone continues, so the save moved there. It's skipped when the next mission is the same one (a campaign-forced retry), unless the host picked an optional loop back to that mission, which single player also saves for. The standalone's post-game step now saves only goals and events, like debrief_init already does for a player host.

Testing?

Linux Debug builds, master against this branch, in a private loopback match with retail data and a small three-mission coop test campaign. At the start of each mission an event sets a corvette's hull from the server's variable and list container, so every player can read what the server started with. On both a player host and a standalone:

  • Continue through all three missions: master loses the values on a player host; this branch carries them both times.
  • Continue, then Replay Mission on mission 2: master's standalone restarts it with mission 2's own changes; this branch restarts it with the values from mission 1.
  • A mission the campaign always repeats, adding 1 each attempt: master's standalone climbs 0, 1, 2; this branch starts every attempt at 0.
  • Toss stats and continue: values still carry, since the campaign still moves on.
  • Two human players, with each one accepting first, and the end of the campaign: values carry, no assertions.
  • A player host taking an optional loop back to the same mission keeps its changes, then moves on normally.

The one-player cases ran two or three times each; the two-player and loop cases once or twice. Not covered: eternal variables, red-alert missions in multiplayer, Windows and macOS.

Anything Else?

Two things this doesn't change:

  • Clients still don't receive the saved values when a mission loads, so anything a client evaluates on its own (briefing text with variables, client-side scripts) sees the defaults. Standalone games already worked this way; filed as Multiplayer campaigns: clients never get campaign-persistent variable values #7891.
  • Eternal variables that also save on mission progress go into the host's pilot file, as in single player, and not into the other players'.

Written with Claude Code; the investigation and testing ran on my machine.

Since campaign-persistent variables were split from goals and events
(only stored when a mission is accepted), the multiplayer paths no
longer matched single player: a player-hosted game never stored them,
so they reset every mission, and a standalone stored them as soon as
the mission ended, so a replayed or retried mission kept its changes.

Store variables and containers in multi_campaign_do_debrief when the
players continue to a different mission or take a loop, which both
kinds of server go through, and have the standalone's postgame store
only goals and events, like debrief_init does for a player host.

Fixes scp-fs2open#4989
@BMagnu BMagnu added the LLM-authored For PR's mainly created through LLMs and NOT submitted by badged developers label Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

LLM-authored For PR's mainly created through LLMs and NOT submitted by badged developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Discrepancy between debrief_init and multi_standalone_postgame_init

2 participants