Source Code Project Mantis - FSSCP
View Issue Details
0003051FSSCPgameplaypublic2014-05-29 18:252014-06-08 23:28
ReporterAxem 
Assigned ToMageKing17 
PriorityhighSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Product Version3.7.0 RC1 
Target Version3.7.2Fixed in Version3.7.2 
Summary0003051: Campaign Variables do not reset on mission restart
DescriptionCampaign Persistent variables aren't resetting on a failed or replayed mission from the debriefing screen like they should be.

Works properly in 3.6.18 but suddenly has issues in 3.7.0. New pilot code issues maybe?
Steps To Reproducehttp://lazymodders.fsmods.net/files/CPVTest.rar

Run the CPV Test campaign. 5 seconds into the first mission, Variable1 will increment itself by 1. Then jump out. If you don't destroy the container, the campaign will make you replay the mission. On replay the variable should again begin at 0.
Additional Informationhttp://www.hard-light.net/forums/index.php?topic=87667.msg1750194;boardseen#new

This thread for some enlightening conversation
TagsNo tags attached.
Attached Filespatch cpvars2.patch (2,789) 2014-06-05 06:09
http://scp.indiegames.us/mantis/file_download.php?file_id=2371&type=bug
7z CPVTestMKII.7z (2,510) 2014-06-06 05:15
http://scp.indiegames.us/mantis/file_download.php?file_id=2375&type=bug
patch cpvars3.patch (7,574) 2014-06-06 22:04
http://scp.indiegames.us/mantis/file_download.php?file_id=2376&type=bug
patch cpvars.patch (8,191) 2014-06-08 23:24
http://scp.indiegames.us/mantis/file_download.php?file_id=2379&type=bug

Notes
(0015799)
MageKing17   
2014-06-05 05:45   
Couldn't sleep; made a patch that caused the test campaign to function normally. Could really use a more experienced coder looking over what I did (and even if what I did is the correct solution, looking over other usages of mission_campaign_store_goals_and_events_and_variables() to see if they should be similarly changed).
(0015800)
MageKing17   
2014-06-05 06:08   
I am an idiot; somehow completely missed the the debrief_accept() function. Updated patch.
(0015809)
niffiwan   
2014-06-06 05:17   
(Last edited: 2014-06-06 05:37)
Per IRC discussion, I've attached a simple update to the campaign to test red alert missions. I've confirmed that without the patch, the CPV incorrectly increments when you replay the 2nd mission from the 3rd mission red-alert briefing.

edit: Well, my IRC suggestion didn't work. i.e.

1) in red_alert_maybe_move_to_next_mission() change to only store goals & events
2) then in red_alert_button_pressed(), add the "store vars" in the "RA_CONTINUE" case

As I feared, the Sexp_variables data is stale by this point. So maybe the approach to fix this issue will be a return to a "save then maybe rollback" style. With consideration given to groundhog day missions per IRC discussion :)

(0015810)
MageKing17   
2014-06-06 13:55   
I was originally thinking of trying to save a CPV "backup" at the start of Red Alert missions, but after looking into the code a bit more, I think you're probably right; the easiest thing to do would be to restore the pre-3.7 behavior of storing CPVs on a per-mission basis and just adding compatibility for when the next mission is the same as the current mission.
(0015811)
MageKing17   
2014-06-06 15:04   
Either way, it looks like it require a change in the .csg format (and if CPVs are moved back to the missions, some code to load "bugged" campaign saves, unless we want to force everyone to restart every campaign that uses CPVs after this bug gets fixed), which I don't want to even attempt at my current level of understanding.
(0015812)
MageKing17   
2014-06-06 22:05   
New patch that fixes Red Alert by adding a "backup" set of CPVs that gets restored when you replay the previous mission. Tested and seems to be working.
(0015817)
MageKing17   
2014-06-08 22:52   
New patch to catch a couple cases where Campaign.variables get freed (and Campaign.redalert_variables should too).
(0015818)
niffiwan   
2014-06-08 23:26   
Fix committed to trunk@10786.
(0015819)
niffiwan   
2014-06-08 23:27   
Just reopening to say that I've reviewed & tested the patch, it looks good and works as advertised.

Issue History
2014-05-29 18:25AxemNew Issue
2014-05-29 19:44niffiwanAssigned To => niffiwan
2014-05-29 19:44niffiwanStatusnew => assigned
2014-05-30 00:00Goober5000Prioritynormal => high
2014-05-30 00:00Goober5000Target Version => 3.7.2
2014-06-05 05:44MageKing17File Added: cpvars.patch
2014-06-05 05:45MageKing17Note Added: 0015799
2014-06-05 06:08MageKing17Note Added: 0015800
2014-06-05 06:09MageKing17File Added: cpvars2.patch
2014-06-06 05:15niffiwanFile Added: CPVTestMKII.7z
2014-06-06 05:17niffiwanNote Added: 0015809
2014-06-06 05:37niffiwanNote Edited: 0015809bug_revision_view_page.php?bugnote_id=15809#r807
2014-06-06 13:55MageKing17Note Added: 0015810
2014-06-06 15:04MageKing17Note Added: 0015811
2014-06-06 22:04MageKing17File Added: cpvars3.patch
2014-06-06 22:05MageKing17Note Added: 0015812
2014-06-08 21:21niffiwanAssigned Toniffiwan => MageKing17
2014-06-08 21:41MageKing17Statusassigned => code review
2014-06-08 21:41MageKing17File Deleted: cpvars.patch
2014-06-08 22:51MageKing17File Added: cpvars.patch
2014-06-08 22:52MageKing17Note Added: 0015817
2014-06-08 23:24MageKing17File Deleted: cpvars.patch
2014-06-08 23:24MageKing17File Added: cpvars.patch
2014-06-08 23:26niffiwanChangeset attached => fs2open trunk r10786
2014-06-08 23:26niffiwanNote Added: 0015818
2014-06-08 23:26niffiwanStatuscode review => resolved
2014-06-08 23:26niffiwanResolutionopen => fixed
2014-06-08 23:27niffiwanNote Added: 0015819
2014-06-08 23:27niffiwanStatusresolved => feedback
2014-06-08 23:27niffiwanResolutionfixed => reopened
2014-06-08 23:28niffiwanStatusfeedback => resolved
2014-06-08 23:28niffiwanFixed in Version => 3.7.2
2014-06-08 23:28niffiwanResolutionreopened => fixed