View Issue Details

IDProjectCategoryView StatusLast Update
0002879FSSCPPilot datapublic2013-05-30 08:35
Reporterniffiwan Assigned Toniffiwan  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.19 
Summary0002879: Campaign structure "clearing/reset" is incomplete
DescriptionAs per the summary, mission_campaign_clear() does not reset the entire campaign structure. This has lead to at least two other recent bugs (0002868 & 0002859). As campaign persistent vars were not being cleared, I also wonder if this relates to issues reported with BP2 "Universal Truth" & Shivan comm nodes acting oddly.

The patch clears all parts of the Campaign struct. In theory some other clearing of vars in other parts of the code is no longer necessary, but I've left that alone for now since we don't need regressions at this point of the 3.7.0 release cycle :)

Also, given that this function is part of the mission_campaign_init, it may also reduce the chances of uninitialised vars causing problems.
Steps To ReproduceThis is not addressing a specific bug, it's an attempt to avoid future bugs.
TagsNo tags attached.

Activities

niffiwan

2013-05-25 03:21

developer  

mantis2879-svn.patch (1,702 bytes)   
Index: code/mission/missioncampaign.cpp
===================================================================
--- code/mission/missioncampaign.cpp	(revision 9679)
+++ code/mission/missioncampaign.cpp	(working copy)
@@ -1309,14 +1309,42 @@
 			sexp_unmark_persistent(Campaign.missions[i].formula);		// free any sexpression nodes used by campaign.
 		}
 
+		memset(Campaign.missions[i].briefing_cutscene, 0, NAME_LENGTH);
+		Campaign.missions[i].formula = 0;
 		Campaign.missions[i].completed = 0;
 		Campaign.missions[i].num_goals = 0;
 		Campaign.missions[i].num_events = 0;
 		Campaign.missions[i].num_variables = 0;	// Goober5000
+		Campaign.missions[i].mission_loop_formula = 0;
+		Campaign.missions[i].level = 0;
+		Campaign.missions[i].pos = 0;
+		Campaign.missions[i].flags = 0;
 		Campaign.missions[i].main_hall.clear();
+		Campaign.missions[i].debrief_persona_index = 0;
+		init_scoring_element(&Campaign.missions[i].stats);
 	}
 
+	memset(Campaign.name, 0, NAME_LENGTH);
+	memset(Campaign.filename, 0, MAX_FILENAME_LEN);
+	Campaign.type = 0;
+	Campaign.flags = 0;
 	Campaign.num_missions = 0;
+	Campaign.num_missions_completed = 0;
+	Campaign.current_mission = -1;
+	Campaign.next_mission = -1;
+	Campaign.prev_mission = -1;
+	Campaign.loop_enabled = 0;
+	Campaign.loop_mission = CAMPAIGN_LOOP_MISSION_UNINITIALIZED;
+	Campaign.loop_reentry = 0;
+	Campaign.realign_required = 0;
+	Campaign.num_players = 0;
+	memset( Campaign.ships_allowed, 0, sizeof(Campaign.ships_allowed) );
+	memset( Campaign.weapons_allowed, 0, sizeof(Campaign.weapons_allowed) );
+	Campaign.num_variables = 0;
+	if (Campaign.variables != NULL) {
+		vm_free(Campaign.variables);
+		Campaign.variables = NULL;
+	}
 }
 
 /**
mantis2879-svn.patch (1,702 bytes)   

The_E

2013-05-30 04:46

administrator   ~0015095

Looks good.

niffiwan

2013-05-30 08:31

developer   ~0015096

Thanks :)

niffiwan

2013-05-30 08:35

developer   ~0015097

Fix committed to trunk@9682.

Related Changesets

fs2open: trunk r9682

2013-05-30 05:32

niffiwan


Ported: N/A

Details Diff
Fix for mantis 2879: clear/reset *everything* in Campaign struct Affected Issues
0002879
mod - /trunk/fs2_open/code/mission/missioncampaign.cpp Diff File

Issue History

Date Modified Username Field Change
2013-05-25 03:19 niffiwan New Issue
2013-05-25 03:19 niffiwan Status new => assigned
2013-05-25 03:19 niffiwan Assigned To => niffiwan
2013-05-25 03:21 niffiwan File Added: mantis2879-svn.patch
2013-05-25 03:21 niffiwan Status assigned => code review
2013-05-30 04:46 The_E Note Added: 0015095
2013-05-30 08:31 niffiwan Note Added: 0015096
2013-05-30 08:35 niffiwan Changeset attached => fs2open trunk r9682
2013-05-30 08:35 niffiwan Note Added: 0015097
2013-05-30 08:35 niffiwan Status code review => resolved
2013-05-30 08:35 niffiwan Resolution open => fixed