View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0002808 | FSSCP | Pilot data | public | 2013-03-14 02:29 | 2013-03-23 18:35 |
| Reporter | FUBAR-BDHR | Assigned To | The_E | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | resolved | Resolution | fixed | ||
| Product Version | 3.6.19 | ||||
| Summary | 0002808: Game type always defaults to single no matter what was played last | ||||
| Description | With the new pilot code the game type always comes up as single player forcing you to remember to hit multi every time or go into the barracks and change it. The game should be setting the type to whatever was last used. This used to rely on the registry which was a bad idea as it changed all pilots on all TCs when you changed one. | ||||
| Steps To Reproduce | Launch game, choose multi before going in, go into lobby, exit game, launch game notice that the game type in the pilot selection screen is back to single. | ||||
| Additional Information | The game still gets the last played pilot to put it at the top of the list so maybe setting the single/multi game type from the same source would be possible. | ||||
| Tags | No tags attached. | ||||
|
|
In the original code, the following would happen when you start the game: The engine looks at the "Last Pilot" registry value (or whatever it's called in reality, I don't know at the moment). If that value had an "m" at the end, the game would automatically switch to multi mode and display the list of multi pilots, if there was an "s", it would go into SP mode. The problem here is that the new pilot code makes no distinction between multi and single pilots. I think I disabled the multi/single switching because I wanted to get the thing to work, and wanting to fix it later, which I then promptly forgot to do :| |
|
|
2808.patch (3,183 bytes)
Index: menuui/playermenu.cpp
===================================================================
--- menuui/playermenu.cpp (revision 9592)
+++ menuui/playermenu.cpp (working copy)
@@ -796,9 +796,13 @@
strcpy_s(Player_select_last_pilot,last_player);
}
+ if ( !Pilot.load_player(Pilots[Player_select_pilot], Player) ) {
//// determine if he was a single or multi-player based upon the last character in his callsign
// Player_select_last_is_multi = Player_select_last_pilot[strlen(Player_select_last_pilot)-1] == 'M' ? 1 : 0;
- Player_select_last_is_multi = 0;
+ Player_select_last_is_multi = 0;
+ } else {
+ Player_select_last_is_multi = Player->player_was_multi;
+ }
// handle changing from pre-pilot code to post-pilot code
if (Player_select_last_pilot[strlen(Player_select_last_pilot)-1] == 'M' || Player_select_last_pilot[strlen(Player_select_last_pilot)-1] == 'S') {
Index: pilotfile/pilotfile.h
===================================================================
--- pilotfile/pilotfile.h (revision 9592)
+++ pilotfile/pilotfile.h (working copy)
@@ -41,6 +41,8 @@
SCP_string filename;
player *p;
+ int version;
+
// some sections are required before others...
bool m_have_flags;
bool m_have_info;
Index: pilotfile/plr.cpp
===================================================================
--- pilotfile/plr.cpp (revision 9592)
+++ pilotfile/plr.cpp (working copy)
@@ -25,7 +25,8 @@
// that sort!
//
// 0 - initial version
-static const ubyte PLR_VERSION = 0;
+// 1 - Adding support for the player is multi flag
+static const ubyte PLR_VERSION = 1;
void pilotfile::plr_read_flags()
@@ -44,6 +45,14 @@
// special rank setting (to avoid having to read all stats on verify)
p->stats.rank = cfread_int(cfp);
+
+ if (version > 0)
+ {
+ p->player_was_multi = cfread_int(cfp);
+ } else
+ {
+ p->player_was_multi = 0; // Default to single player
+ }
}
void pilotfile::plr_write_flags()
@@ -65,6 +74,9 @@
// special rank setting (to avoid having to read all stats on verify)
cfwrite_int(p->stats.rank, cfp);
+ // What game mode we were in last on this pilot
+ cfwrite_int(p->player_was_multi, cfp);
+
endSection();
}
@@ -807,9 +819,9 @@
}
// version, should be able to just ignore it
- ubyte plr_ver = cfread_ubyte(cfp);
+ version = cfread_ubyte(cfp);
- mprintf(("PLR => Loading '%s' with version %d...\n", filename.c_str(), (int)plr_ver));
+ mprintf(("PLR => Loading '%s' with version %d...\n", filename.c_str(), version));
plr_reset_data();
Index: playerman/player.h
===================================================================
--- playerman/player.h (revision 9592)
+++ playerman/player.h (working copy)
@@ -203,6 +203,8 @@
control_info lua_ci; // copy of control info for scripting purposes (not to disturb real controls).
button_info lua_bi; // copy of button info for scripting purposes (not to disturb real controls).
button_info lua_bi_full; // gets all the button controls, not just the ones usually allowed
+
+ int player_was_multi; // 1 if the player file was last used in Multiplayer
} player;
extern player Players[MAX_PLAYERS];
|
|
|
Attached a patch for review. This bumps the savefile version to 1, on account of having to save the last play state in the pilot file itself (that being a more elegant way to do things instead of appending a letter to a registry entry) |
|
|
Getting a crash with this patch applied. Last call is from plr.cpp pilotfile::load_player() filename = callsign; filename += ".plr"; Beyond that it's into the library functions and finally assembly. Guess of a cause would be the line above where callsign is a bad pointer. Attached screenshot of the stack etc. |
|
|
|
|
|
I think the problem is this line: if ( !Pilot.load_player(Pilots[Player_select_pilot], Player) ) { I don't think either the Pilots array, or Player is initialised at this point in time. |
|
|
Player doesn't have to be (it's initialized during Pilot.load()), the other one was a stupid oversight on my part. I corrected it, and committed the patch in rev 9594 |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2013-03-14 02:29 | FUBAR-BDHR | New Issue | |
| 2013-03-15 08:11 | The_E | Note Added: 0014765 | |
| 2013-03-15 08:11 | The_E | Assigned To | => The_E |
| 2013-03-15 08:11 | The_E | Status | new => assigned |
| 2013-03-21 18:40 | The_E | File Added: 2808.patch | |
| 2013-03-21 18:41 | The_E | Note Added: 0014794 | |
| 2013-03-21 18:41 | The_E | Status | assigned => code review |
| 2013-03-22 02:28 | FUBAR-BDHR | Note Added: 0014798 | |
| 2013-03-22 02:49 | FUBAR-BDHR | File Added: 2808_crash.jpg | |
| 2013-03-22 02:49 | FUBAR-BDHR | Note Edited: 0014798 | |
| 2013-03-22 10:32 | niffiwan | Note Added: 0014799 | |
| 2013-03-23 18:35 | The_E | Note Added: 0014816 | |
| 2013-03-23 18:35 | The_E | Status | code review => resolved |
| 2013-03-23 18:35 | The_E | Resolution | open => fixed |