Source Code Project Mantis - FSSCP
View Issue Details
0002753FSSCPuser interfacepublic2012-12-13 19:532013-04-29 04:09
Assigned ToZacam 
Platformx64OSWindows 7OS Version
Product Version3.6.15 
Target Version3.7.0Fixed in Version 
Summary0002753: Custom loadouts not loaded
DescriptionChanges in r9370 appear to be preventing custom loadouts from loading; only default loadouts are loaded.
Steps To ReproduceLoad any mission that allows loadout customization, and make a change to your loadout. Start the mission, exit it, then exit the game to ensure that your loadout is saved. Start the game and load the mission again, and check the loadout. It should be the one that you used earlier, not the default.
TagsNo tags attached.
related to 0002797resolved karajorma Ship/weapon loadout doing TOO good of a job remembering? 
related to 0002802resolved niffiwan A miscalculation in the number of Avengers available. 
related to 0002855resolved niffiwan off-by-one error in csg_read_loadout clamp code 
Attached Filespatch mantis2753-svn.patch (5,501) 2013-04-27 21:32

2012-12-13 22:03   
9370 was a fix by Karajorma. Assigning to him hoping he can take a look.
2012-12-14 03:55   
Fix committed to trunk@9430.
2013-03-09 01:48   
This seems to be broken again in Trunk. I haven't narrowed down a commit revision yet.
2013-03-09 02:48   
It looks like it was broken in 9561, the pilot code commit; it works fine in 9560. It's also broken in the Blue Planet builds, so it's almost certainly a problem with the new pilot code.
2013-04-22 22:09   
The basic issue is that the Player_loadout.filename isn't written to the .csg file until the mission is completed successfully. The game however needs to check if this is the same as the mission currently being played so that it knows that the loadout it has saved in the csg file is valid.
2013-04-23 05:03   
(Last edited: 2013-04-23 05:46)
The new pilotcode added a reset & reread of the .csg after a mission is completed. That's why I re-added a Pilot.save_savefile() for 2809. However, that save occurs too early to save the loadout data. Moving the save to "commit_pressed()" in missionui/missionshipchoice.cpp would help. However, that doesn't seem to be the whole solution, as while some loadout data actually gets saved to the .csg now (e.g. filename & date), the rest seems to be 0xFF?!? (i.e. -1). The Player_loadout struct unit_data/weapon_pool/ship_pool seems borked.

edit: or maybe not, something wierd is going on here...

2013-04-23 07:31   
(Last edited: 2013-04-23 07:41)
I think the problem might be poor/missing initialisation of Player_loadout. e.g. unit_data in my testing had 0 for the ship class of all ships not present in the mission (10 for sm1-01). Zero is a valid ship, probably should be -1. This causes missionui/missionscreencommon.cpp:1089 to abort the loadout restore because there are more Uly's (10) in last_loadout_ships than this_loadout_ships (0).

edit: or maybe a problem with Wss_slots init, I think that's where Player_loadout->unit_data->ship_class initially gets set from. Need to trace the problem when it 1st occurs, but not right now, sleep.

2013-04-23 15:04   
(Last edited: 2013-04-23 16:50)
I traced in MSVC to trip on the saving of the Loadout, which did fire off.

The structure for the storage of the weapons selections made isn't happened. It goes haywire on the data when it gets into the subsystem reading event to generate the data that it should be writing, as a result, nothing gets stored.

To note: when you "Restart" a mission, any custom loadout changes made DO get retained and propagated, so there is storage happening, just not to the CSG as expected.

2013-04-27 21:40   
(Last edited: 2013-04-27 21:44)
I believe the attached patch fixes the issue. When testing, please use a new pilot file as any existing pilot probably has corrupt data in the loadout section.

Changes are:

1) move csg save to be the after the commit is pressed
2) when reading the loadout from the csg, use an int instead of a uint for ship/weapon indexes. With a uint a stored index value of -1 is read as approx 4 billion which corrupts the loadout data.
3) (being defensive) initialise the Player_loadout structure on game start.

note: there's another off-by-one bug in the loadout index "clamp" code that I'll fix after this problem is resolved

2013-04-28 16:39   
Testing. I'd also like to see the patch for that off-by-one, getting them both in would be good.

(We'll probably want a separate Mantis and Code Review set up for that one and note which one requires the other if that is necessary)
2013-04-29 04:08   
Zacam confirmed the fix as good on IRC.
2013-04-29 04:09   
Fix committed to trunk@9657.

Issue History
2012-12-13 19:53YarnNew Issue
2012-12-13 22:03MjnMixaelAssigned To => karajorma
2012-12-13 22:03MjnMixaelStatusnew => assigned
2012-12-13 22:03MjnMixaelNote Added: 0014441
2012-12-14 03:55karajormaChangeset attached => fs2open trunk r9430
2012-12-14 03:55karajormaNote Added: 0014451
2012-12-14 03:55karajormaStatusassigned => resolved
2012-12-14 03:55karajormaResolutionopen => fixed
2013-02-20 15:59Goober5000Relationship addedrelated to 0002797
2013-03-09 01:48MjnMixaelNote Added: 0014758
2013-03-09 01:48MjnMixaelStatusresolved => assigned
2013-03-09 02:48YarnNote Added: 0014759
2013-04-20 21:09MjnMixaelTarget Version => 3.7.0
2013-04-21 23:08niffiwanRelationship addedrelated to 0002802
2013-04-22 22:07karajormaAssigned Tokarajorma => Zacam
2013-04-22 22:09karajormaNote Added: 0014953
2013-04-23 05:03niffiwanNote Added: 0014954
2013-04-23 05:04niffiwanNote Edited: 0014954bug_revision_view_page.php?bugnote_id=14954#r496
2013-04-23 05:04niffiwanNote Edited: 0014954bug_revision_view_page.php?bugnote_id=14954#r497
2013-04-23 05:46niffiwanNote Edited: 0014954bug_revision_view_page.php?bugnote_id=14954#r498
2013-04-23 07:31niffiwanNote Added: 0014955
2013-04-23 07:41niffiwanNote Edited: 0014955bug_revision_view_page.php?bugnote_id=14955#r500
2013-04-23 15:04ZacamNote Added: 0014957
2013-04-23 16:50ZacamNote Edited: 0014957bug_revision_view_page.php?bugnote_id=14957#r502
2013-04-27 21:32niffiwanFile Added: mantis2753-svn.patch
2013-04-27 21:40niffiwanNote Added: 0014966
2013-04-27 21:40niffiwanStatusassigned => code review
2013-04-27 21:43niffiwanNote Edited: 0014966bug_revision_view_page.php?bugnote_id=14966#r504
2013-04-27 21:44niffiwanNote Edited: 0014966bug_revision_view_page.php?bugnote_id=14966#r505
2013-04-28 16:39ZacamNote Added: 0014970
2013-04-28 17:11niffiwanRelationship addedrelated to 0002855
2013-04-29 04:08niffiwanNote Added: 0014973
2013-04-29 04:09niffiwanChangeset attached => fs2open trunk r9657
2013-04-29 04:09niffiwanNote Added: 0014974
2013-04-29 04:09niffiwanStatuscode review => resolved