View Issue Details

IDProjectCategoryView StatusLast Update
0003020FSSCPPilot datapublic2014-08-20 10:02
Reporterniffiwan Assigned Toniffiwan  
PriorityhighSeveritymajorReproducibilitysometimes
Status resolvedResolutionfixed 
Product Version3.7.1 
Target Version3.7.2 
Summary0003020: pilot stats not behaving when switching campaigns or cloning
DescriptionYes, the description is vague but I'm still trying to find the root cause.

See attached pilots.
Strobe is the original pilot - played only FSPort until approx "The Darkness & the Light"
Strobe2 was cloned from Strobe while FSPort was active
Strobe2 was cloned after 8 missions in the FSport
Strobe2 was cloned around when "The Hammer and the Anvil" was played.
Strobetest was cloned from Strobe while FS2 was active

Issues that I can identify so far:
If Strobe is selected with FS2 active, he has stats when they should be zero. There is no FS2 campaign file so they are being generated during FSO startup - i.e. this problem is 100% repeatable.

Strobe FS2 craft kills seems to be the intersection of the FS2/FSPort craft - except the Basilisks kill count is 15 (fs2) vs 8 (fsport). And except for the 1x Seth in fsport which doesn't exist in fs2 (???).

Strobe2 with FS2 active has 8000+ points but still ranks as an Ensign - should be Lt (jg). This may be a symptom of the previous problem? i.e. 2nd played (fs2) campaign stats are borked when that campaign is selected.
Steps To Reproduce1st issue is easy enough:

1) delete all Strobe pilots
2) extract zip to data/pilots
3) note that Strobe.FreeSpace2.csg does NOT exist
4) start FSO with "no mod"
5) select Strobe
6) At the prompt "current campaign not found", enter the campaign room & select Freepace2 campaign
7) Enter the barracks
8) Note that Strobe has non-zero stats

Not sure about the other issues yet. Or about what triggers the issue in the 1st place.

i.e.
cloning a new pilot from Strobe with fsport (or fs2) active results in a pilot with zero stats in both fs2 & fsport.

Maybe you need to have played campaign missions in the current session to trigger the bug?
Additional InformationUpdate from Scotty:

I played a few more games with the Strobe pilot today. When I checked Strobe2, his points and kills had increased - despite the fact that I haven't played him at all.

So - that's super wierd, I wonder if there is some wonky fileglob going on, or maybe stats on not being reset correctly when new pilots are selected?


TagsNo tags attached.

Relationships

related to 0003065 resolvedniffiwan redalert data is not cleared when you reset a campaign 

Activities

niffiwan

2014-03-15 03:34

developer  

scotty-Pilots.zip (19,174 bytes)

Goober5000

2014-06-29 23:14

administrator   ~0015942

Assigning to niffiwan to make sure this is included in the 3.7.2 pilotfile roll-up.

niffiwan

2014-08-17 03:15

developer   ~0016226

Last edited: 2014-08-20 09:59

The problem here is that pilot stats were not being reset when a new CSG was created for a campaign that hadn't been played yet (note that a new/cloned pilot is always starting a new campaign). If a pilot with non-zero stats had been loaded in the current session of FSO prior to the campaign switch/new-or-cloned-pilot then the stats would be propagated into the new campaign.

This resolves the issue by clearing in-memory player stats prior to a new CSG being created. A special case was added to prevent campaign resets from clearing stats because that's what retail did (even though a case could be made so say that since we have all-time stats now this doesn't really matter anymore).

To test this issue, do the following;

1) create a new pilot with no-mod
2) skip the 1st 3x training missions of FS2, then play SM1-01 (Surrender Belisarius), getting at least some kills
3) note/record some of the mission stats before accepting the briefing
4) go to the campaign room and reset the campaign
5) go to the barracks and check the stats (should be the same with and without the patch)
6) clone the pilot and check the new stats. Without the patch the cloned pilot should have the same stats as the source pilot
7) exit FSO and restart with another mod
8) go to the campaign room and switch to any new campaign (i.e. non-Freespace2.fc2)
9) go to the barracks and check the stats. Without the patch, the new campaign stats should be the same as the Freespace2 stats (although the ship kill types *might* be messed up if the mod has different ships)

Lastly, please note that this patch will probably conflict with the one from mantis 3065; but is trivial to resolve or apply by hand.

edit: Gah! Note sure about step 6 now, my testing seems to indicate that this is OK without the patch.
edit2: Yeah, forget step 6, I can't reproduce that one. Everything else should be valid though

niffiwan

2014-08-17 08:47

developer  

mantis3020-svn.patch (2,039 bytes)   
Index: code/menuui/readyroom.cpp
===================================================================
--- code/menuui/readyroom.cpp	(revision 11007)
+++ code/menuui/readyroom.cpp	(working copy)
@@ -1533,7 +1533,7 @@
 		strcat(filename, FS_CAMPAIGN_FILE_EXT);
 
 		mission_campaign_savefile_delete(filename);
-		mission_campaign_load(filename);
+		mission_campaign_load(filename, NULL, 1 , false); // retail doesn't reset stats when resetting the campaign
 		mission_campaign_next_mission();
 
 		vm_free(filename);
Index: code/mission/missioncampaign.cpp
===================================================================
--- code/mission/missioncampaign.cpp	(revision 11007)
+++ code/mission/missioncampaign.cpp	(working copy)
@@ -407,7 +407,7 @@
  * this file.  If you change the format of the campaign file, you should be sure these related
  * functions work properly and update them if it breaks them.
  */
-int mission_campaign_load( char *filename, player *pl, int load_savefile )
+int mission_campaign_load( char *filename, player *pl, int load_savefile, bool reset_stats )
 {
 	int len, rval, i;
 	char name[NAME_LENGTH], type[NAME_LENGTH], temp[NAME_LENGTH];
@@ -655,6 +655,10 @@
 			} else {
 				// make sure we initialize red alert data for the new CSG
 				red_alert_clear();
+				// and reset stats when requested
+				if (reset_stats) {
+					pl->stats.init();
+				}
 				Pilot.save_savefile();
 			}
 		}
Index: code/mission/missioncampaign.h
===================================================================
--- code/mission/missioncampaign.h	(revision 11007)
+++ code/mission/missioncampaign.h	(working copy)
@@ -181,7 +181,7 @@
 
 
 // load up and initialize a new campaign
-int mission_campaign_load( char *filename, player *pl = NULL, int load_savefile = 1 );
+int mission_campaign_load( char *filename, player *pl = NULL, int load_savefile = 1, bool reset_stats = true );
 
 // function to save the state of the campaign between missions or to load a campaign save file
 extern int mission_campaign_save( void );
mantis3020-svn.patch (2,039 bytes)   

niffiwan

2014-08-20 10:02

developer   ~0016242

Fix committed to trunk@11011.

Related Changesets

fs2open: trunk r11011

2014-08-20 06:32

niffiwan


Ported: N/A

Details Diff
Fix mantis 3020 (pilot stats issue)

Reset pilot stats when we're creating a new CSG file. Otherwise stats
from the current pilot or campaign will be inherited by the new pilot /
campaign
Affected Issues
0003020
mod - /trunk/fs2_open/code/mission/missioncampaign.h Diff File
mod - /trunk/fs2_open/code/mission/missioncampaign.cpp Diff File
mod - /trunk/fs2_open/code/menuui/readyroom.cpp Diff File

Issue History

Date Modified Username Field Change
2014-03-14 03:41 niffiwan New Issue
2014-03-14 03:43 niffiwan Steps to Reproduce Updated
2014-03-15 03:11 niffiwan Additional Information Updated
2014-03-15 03:34 niffiwan File Added: scotty-Pilots.zip
2014-06-29 23:14 Goober5000 Note Added: 0015942
2014-06-29 23:14 Goober5000 Assigned To => niffiwan
2014-06-29 23:14 Goober5000 Status new => assigned
2014-08-16 03:10 niffiwan Relationship added related to 0003065
2014-08-17 02:57 niffiwan File Added: mantis3020-svn.patch
2014-08-17 03:15 niffiwan Note Added: 0016226
2014-08-17 03:15 niffiwan Status assigned => code review
2014-08-17 03:37 niffiwan Note Edited: 0016226
2014-08-17 04:06 niffiwan Note Edited: 0016226
2014-08-17 04:20 niffiwan File Deleted: mantis3020-svn.patch
2014-08-17 04:20 niffiwan File Added: mantis3020-svn.patch
2014-08-17 08:47 niffiwan File Deleted: mantis3020-svn.patch
2014-08-17 08:47 niffiwan File Added: mantis3020-svn.patch
2014-08-20 09:59 niffiwan Note Edited: 0016226
2014-08-20 10:02 niffiwan Changeset attached => fs2open trunk r11011
2014-08-20 10:02 niffiwan Note Added: 0016242
2014-08-20 10:02 niffiwan Status code review => resolved
2014-08-20 10:02 niffiwan Resolution open => fixed