Skip to content

fix campaign reset wiping player stats#7430

Draft
Goober5000 wants to merge 1 commit intoscp-fs2open:masterfrom
Goober5000:fix/stats_clearing_bug
Draft

fix campaign reset wiping player stats#7430
Goober5000 wants to merge 1 commit intoscp-fs2open:masterfrom
Goober5000:fix/stats_clearing_bug

Conversation

@Goober5000
Copy link
Copy Markdown
Contributor

campaign_reset() deletes the CSG file before reloading, so mission_campaign_load() finds no savefile and calls csg_reset_data(), which unconditionally zeros p->stats. Save and restore Player->stats around the reset so accumulated score, rank, kills, and medals are preserved regardless of whether the reload succeeds.

Also re-save the CSG file after restoring stats: mission_campaign_load() already wrote a fresh CSG with zeros when it found no existing savefile, so without re-saving the next game load would read zeros from disk.

Also now protects against resetting a campaign that is not the active one.

Follow-up to #1450, #1451, #6238, and #6419.

campaign_reset() deletes the CSG file before reloading, so mission_campaign_load() finds no savefile and calls csg_reset_data(), which unconditionally zeros p->stats.  Save and restore Player->stats around the reset so accumulated score, rank, kills, and medals are preserved regardless of whether the reload succeeds.

Also re-save the CSG file after restoring stats: mission_campaign_load() already wrote a fresh CSG with zeros when it found no existing savefile, so without re-saving the next game load would read zeros from disk.

Also now protects against resetting a campaign that is not the active one.

Follow-up to scp-fs2open#1450, scp-fs2open#1451, scp-fs2open#6238, and scp-fs2open#6419.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@Goober5000 Goober5000 added this to the Release 26.0 milestone May 7, 2026
@Goober5000 Goober5000 added fix A fix for bugs, not-a-bugs, and/or regressions. gameplay A feature or issue that can significantly impact gameplay labels May 7, 2026
Copy link
Copy Markdown
Member

@wookieejedi wookieejedi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find

@Goober5000 Goober5000 marked this pull request as draft May 8, 2026 04:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix A fix for bugs, not-a-bugs, and/or regressions. gameplay A feature or issue that can significantly impact gameplay

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants