View Issue Details

IDProjectCategoryView StatusLast Update
0002832FSSCPPilot datapublic2013-04-06 23:58
Reporterniffiwan Assigned Toniffiwan  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.6.19 
Target Version3.7.0 
Summary0002832: pilotfile conversion doesn't export correct PLR/CSG versions
DescriptionAs per the summary, these are currently set to version 0 for both. Therefore the pilot conversion doesn't create up to date pilots. The only tricky thing about solving this is the need to keep most of the pilot conversion constants quarantined from the rest of FSO.
Steps To ReproduceConvert any pilot and examine the PLR and CSG with a hex editor. Of just look at the code:

void pilotfile_convert::plr_export()
{
    Assert( cfp != NULL );

    // header and version
    cfwrite_int(0x5f524c50, cfp);
    cfwrite_ubyte(0, cfp);


void pilotfile_convert::csg_export()
{
    Assert( cfp != NULL );

    // header and version
    cfwrite_int(0x5f475343, cfp);
    cfwrite_ubyte(0, cfp);
Additional InformationNote that a workaround is to simply select the converted pilot, enter the mainhall (not 100% sure this is required) then exit FSO without doing anything else. FSO then writes the correct file versions. However, if you do anything else then features added to the pilotfiles since version 0 won't work properly.
TagsNo tags attached.

Relationships

related to 0002815 resolvedniffiwan Bug with changing squadrons in barracks 

Activities

The_E

2013-04-05 10:47

administrator   ~0014899

oh goddammit.
I thought I had caught all the version writing things. Guess I was wrong.

niffiwan

2013-04-06 02:12

developer  

mantis2832-svn.patch (3,885 bytes)   
Index: code/pilotfile/csg.cpp
===================================================================
--- code/pilotfile/csg.cpp	(revision 9621)
+++ code/pilotfile/csg.cpp	(working copy)
@@ -25,17 +25,7 @@
 #include <sstream>
 
 
-static const unsigned int CSG_FILE_ID = 0x5f475343;	// "CSG_" in file
 
-// NOTE: Version should be bumped only for adding/removing sections or section
-//       content.  It should *NOT* be bumped for limit bumps or anything of
-//       that sort!
-//
-//   0 - initial version
-//   1 - re-add recent missions
-static const ubyte CSG_VERSION = 1;
-
-
 void pilotfile::csg_read_flags()
 {
 	// tips?
Index: code/pilotfile/csg_convert.cpp
===================================================================
--- code/pilotfile/csg_convert.cpp	(revision 9621)
+++ code/pilotfile/csg_convert.cpp	(working copy)
@@ -1093,8 +1093,8 @@
 	Assert( cfp != NULL );
 
 	// header and version
-	cfwrite_int(0x5f475343, cfp);
-	cfwrite_ubyte(0, cfp);
+	cfwrite_int(CSG_FILE_ID, cfp);
+	cfwrite_ubyte(CSG_VERSION, cfp);
 
 	// flags and info sections go first
 	csg_export_flags();
Index: code/pilotfile/pilotfile.h
===================================================================
--- code/pilotfile/pilotfile.h	(revision 9621)
+++ code/pilotfile/pilotfile.h	(working copy)
@@ -10,6 +10,20 @@
 struct player;
 
 
+// current pilot constants
+static const unsigned int PLR_FILE_ID = 0x5f524c50;	// "PLR_" in file
+static const unsigned int CSG_FILE_ID = 0x5f475343;	// "CSG_" in file
+// NOTE: Version should be bumped only for adding/removing sections or section
+//       content.  It should *NOT* be bumped for limit bumps or anything of
+//       that sort!
+//   0 - initial version
+//   1 - Adding support for the player is multi flag
+static const ubyte PLR_VERSION = 1;
+//   0 - initial version
+//   1 - re-add recent missions
+static const ubyte CSG_VERSION = 1;
+
+
 class pilotfile {
 	public:
 		pilotfile();
Index: code/pilotfile/pilotfile_convert.h
===================================================================
--- code/pilotfile/pilotfile_convert.h	(revision 9621)
+++ code/pilotfile/pilotfile_convert.h	(working copy)
@@ -26,6 +26,7 @@
 #include "mission/missioncampaign.h"
 #include "controlconfig/controlsconfig.h"
 #include "missionui/redalert.h"
+#include "pilotfile/pilotfile.h"
 
 
 
Index: code/pilotfile/plr.cpp
===================================================================
--- code/pilotfile/plr.cpp	(revision 9621)
+++ code/pilotfile/plr.cpp	(working copy)
@@ -18,17 +18,6 @@
 #include "playerman/managepilot.h"
 
 
-static const unsigned int PLR_FILE_ID = 0x5f524c50;	// "PLR_" in file
-
-// NOTE: Version should be bumped only for adding/removing sections or section
-//       content.  It should *NOT* be bumped for limit bumps or anything of
-//       that sort!
-//
-//   0 - initial version
-//   1 - Adding support for the player is multi flag
-static const ubyte PLR_VERSION = 1;
-
-
 void pilotfile::plr_read_flags()
 {
 	// tips?
Index: code/pilotfile/plr_convert.cpp
===================================================================
--- code/pilotfile/plr_convert.cpp	(revision 9621)
+++ code/pilotfile/plr_convert.cpp	(working copy)
@@ -816,8 +816,8 @@
 	Assert( cfp != NULL );
 
 	// header and version
-	cfwrite_int(0x5f524c50, cfp);
-	cfwrite_ubyte(0, cfp);
+	cfwrite_int(PLR_FILE_ID, cfp);
+	cfwrite_ubyte(PLR_VERSION, cfp);
 
 	// flags and info sections go first
 	plr_export_flags();
Index: code/pilotfile/pilotfile_convert.cpp
===================================================================
--- code/pilotfile/pilotfile_convert.cpp	(revision 9621)
+++ code/pilotfile/pilotfile_convert.cpp	(working copy)
@@ -3,6 +3,7 @@
 #include "pilotfile/pilotfile_convert.h"
 #include "cfile/cfile.h"
 #include "playerman/managepilot.h"
+#include "pilotfile/pilotfile.h"
 
 
 pilotfile_convert::pilotfile_convert()
mantis2832-svn.patch (3,885 bytes)   

niffiwan

2013-04-06 02:15

developer   ~0014901

Trivial patch attached. Tested and it works as expected. The only question I would like input on is whether the consts should:

1) be put in pilotfile.h, with the possible danger of someone using some const in the conversion process where it shouldn't be used, and thus breaking the conversion process

2) be put in pilotfile_convert.h as separate consts, the obvious downside being that you must update versions in two different files.

I think 1) is the best approach, but I'm open to hearing other ideas.

The_E

2013-04-06 12:11

administrator   ~0014908

pilotfile.h seems to be the most intuitive place for them.

Zacam

2013-04-06 18:22

administrator   ~0014909

I agree. Nice catch and patch.

niffiwan

2013-04-06 23:58

developer   ~0014910

Fix committed to trunk@9624.

Related Changesets

fs2open: trunk r9624

2013-04-06 20:46

niffiwan


Ported: N/A

Details Diff
Fix mantis 2832: conversion functions now use certain consts from the new pilot code when exporting *only* Affected Issues
0002832
mod - /trunk/fs2_open/code/pilotfile/csg.cpp Diff File
mod - /trunk/fs2_open/code/pilotfile/csg_convert.cpp Diff File
mod - /trunk/fs2_open/code/pilotfile/pilotfile.h Diff File
mod - /trunk/fs2_open/code/pilotfile/pilotfile_convert.h Diff File
mod - /trunk/fs2_open/code/pilotfile/plr.cpp Diff File
mod - /trunk/fs2_open/code/pilotfile/plr_convert.cpp Diff File

Issue History

Date Modified Username Field Change
2013-04-03 10:07 niffiwan New Issue
2013-04-03 10:07 niffiwan Status new => assigned
2013-04-03 10:07 niffiwan Assigned To => niffiwan
2013-04-03 10:10 niffiwan Additional Information Updated
2013-04-03 10:11 niffiwan Additional Information Updated
2013-04-05 09:48 niffiwan Relationship added related to 0002815
2013-04-05 10:47 The_E Note Added: 0014899
2013-04-06 02:12 niffiwan File Added: mantis2832-svn.patch
2013-04-06 02:15 niffiwan Note Added: 0014901
2013-04-06 02:15 niffiwan Status assigned => code review
2013-04-06 12:11 The_E Note Added: 0014908
2013-04-06 18:22 Zacam Note Added: 0014909
2013-04-06 23:58 niffiwan Changeset attached => fs2open trunk r9624
2013-04-06 23:58 niffiwan Note Added: 0014910
2013-04-06 23:58 niffiwan Status code review => resolved
2013-04-06 23:58 niffiwan Resolution open => fixed