View Issue Details

IDProjectCategoryView StatusLast Update
0002813FSSCPPilot datapublic2013-04-01 07:40
ReporterGoober5000 Assigned Toniffiwan  
PrioritynormalSeverityblockReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.19 
Target Version3.7.0 
Summary0002813: Vanishing pilots?
DescriptionToday I tried compiling the latest source in SVN to test out a new mod. First I noticed that the pilot selection screen said that I already had the maximum number of pilots, which seemed odd. So I deleted a few old test pilots and created a new one.

At one point I had to exit the game and re-load it. Unfortunately, when I got back to the pilot selection screen, not only was my new pilot nowhere to be found, but the screen still said that I had the maximum number of pilots. This is despite the fact that I deleted *multiple* old test pilots but only create a single new test pilot. So I did the same thing I did before: delete multiple old test pilots and created a single new one.

To further confuse things, the same exact thing happened when I loaded up the engine a *third* time: my new pilot had vanished, and when I tried to create a new one the screen said that I already had the maximum number.
TagsNo tags attached.

Activities

niffiwan

2013-03-18 07:51

developer   ~0014776

Last edited: 2013-03-18 07:55

Gah - I think I know exactly what is causing this. The pilot conversion routine doesn't respect the max pilot limit, that combined with the fact that FSO only finds the 1st 20 (i.e. max pilot limit) pilot files returned by the OS (in the order *defined* by the OS), means that it's quite possible for newly created pilots to "vanish".

I think the best solution may be to make the pilot conversion routine respect the max pilot limit. Otherwise, the alternative would be to make the find-pilots-and-return-the-1st-20-in-datetime-order grab a total of 40 pilots, and then only return the 1st 20 (but actually, that kinda sucks too)

(I say 40, because the max pilots you should be able to ever have is 20 created with the new pilot code, plus 20 converted from the old pilot code)

niffiwan

2013-03-18 11:01

developer   ~0014777

Can you please test the attached patch? It should stop the problem from occurring in future.

First though, you'll need to remove enough pilots (*.plr & *.csg) from data/players to have <= 20 pilots. I don't think there's any safe way for FSO to delete the pilots of anyone who's got into your situation, the player needs to decide which pilots they want to keep.

Or you can delete pilots one or more at a time from the selection screen & restart FSO (without creating any new pilots) until the missing pilot returns, obviously this may take longer than the 1st approach.

niffiwan

2013-03-19 09:51

developer  

mantis2813-svn.patch (1,214 bytes)   
Index: code/pilotfile/pilotfile_convert.cpp
===================================================================
--- code/pilotfile/pilotfile_convert.cpp	(revision 9585)
+++ code/pilotfile/pilotfile_convert.cpp	(working copy)
@@ -2,6 +2,7 @@
 #include "globalincs/pstypes.h"
 #include "pilotfile/pilotfile_convert.h"
 #include "cfile/cfile.h"
+#include "playerman/managepilot.h"
 
 
 pilotfile_convert::pilotfile_convert()
@@ -71,6 +72,7 @@
 {
 	size_t idx, j, i;
 	size_t count, inf_count;
+	int max_convert, num_converted = 0;
 	SCP_vector<SCP_string> existing;
 	SCP_vector<SCP_string> old_files;
 
@@ -103,8 +105,12 @@
 		}
 	}
 
+	// don't convert enough pilots to exceed the pilot limit
+	max_convert = MAX_PILOTS - existing.size();
+
 	// if everything is already converted then bail
-	if (i == count) {
+	// also bail if MAX_PILOTS (or more!) already exist
+	if (i == count || max_convert <= 0) {
 		return;
 	}
 
@@ -136,9 +142,15 @@
 			for (j = 0; j < savefiles.size(); j++) {
 				pcon->csg_convert(savefiles[j].c_str(), inferno);
 			}
+
+			++num_converted;
 		}
 
 		delete pcon;
+
+		if (num_converted >= max_convert) {
+			break;
+		}
 	}
 
 	mprintf(("PILOT: Pilot file conversion complete!\n"));
mantis2813-svn.patch (1,214 bytes)   

niffiwan

2013-03-19 09:52

developer   ~0014783

Oops. size_t is unsigned. New patch uploaded.

Goober5000

2013-04-01 06:18

administrator   ~0014864

I tested this on IRC last week and it appears to have fixed the problem. The patch can be committed.

niffiwan

2013-04-01 07:40

developer   ~0014865

Fix committed to trunk@9614.

Related Changesets

fs2open: trunk r9614

2013-04-01 04:27

niffiwan


Ported: N/A

Details Diff
Fix for mantis 2813: don't let pilot conversion create more than MAX_PILOTS Affected Issues
0002813
mod - /trunk/fs2_open/code/pilotfile/pilotfile_convert.cpp Diff File

Issue History

Date Modified Username Field Change
2013-03-18 06:52 Goober5000 New Issue
2013-03-18 07:48 niffiwan Assigned To => niffiwan
2013-03-18 07:48 niffiwan Status new => assigned
2013-03-18 07:51 niffiwan Note Added: 0014776
2013-03-18 07:52 niffiwan Note Edited: 0014776
2013-03-18 07:54 niffiwan Note Edited: 0014776
2013-03-18 07:55 niffiwan Note Edited: 0014776
2013-03-18 10:30 niffiwan File Added: mantis2813-svn.patch
2013-03-18 10:37 niffiwan File Deleted: mantis2813-svn.patch
2013-03-18 10:37 niffiwan File Added: mantis2813-svn.patch
2013-03-18 11:01 niffiwan Note Added: 0014777
2013-03-18 11:01 niffiwan Status assigned => feedback
2013-03-19 09:51 niffiwan File Deleted: mantis2813-svn.patch
2013-03-19 09:51 niffiwan File Added: mantis2813-svn.patch
2013-03-19 09:52 niffiwan Note Added: 0014783
2013-04-01 06:18 Goober5000 Note Added: 0014864
2013-04-01 06:18 Goober5000 Status feedback => assigned
2013-04-01 07:40 niffiwan Changeset attached => fs2open trunk r9614
2013-04-01 07:40 niffiwan Note Added: 0014865
2013-04-01 07:40 niffiwan Status assigned => resolved
2013-04-01 07:40 niffiwan Resolution open => fixed