View Issue Details

IDProjectCategoryView StatusLast Update
0002922FSSCPPilot datapublic2013-09-23 05:28
ReporterMacfie Assigned ToGoober5000  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionopen 
PlatformwindowsOSwindows 7OS Version64bit
Product Version3.7.1 
Fixed in Version3.7.2 
Summary0002922: Medals not being retained in pilot data
DescriptionJust noticed a problem with medals. I am playing the FSPort FS1 campaign. The medals display when they are awarded in the debrief and in the medal case but then they disappear from the medal case afterwards. I was awarded three medals but none of them were retained. The data for rank and wings is retained but not medals including the ace awards.
Steps To ReproduceThe same thing happened with each award. I was awarded the good conduct medal it displayed during the debrief and when I checked the medal case. When I was awarded the distinguished flying cross it displayed but the good conduct medal was gone. When I was awarded the Vasudan medal it was displayed but the other medals were not there. When I went to the barracks there were no medals.
Additional InformationProblem appears to have started with the r9800 nightly
TagsNo tags attached.

Activities

Goober5000

2013-09-22 17:34

administrator   ~0015282

I've been scrutinizing the code for several hours and this makes no sense. My changes should not have made any difference to the way medals are loaded or saved.

I did find a bunch of other bugs in the pilot/stats code, though.

Macfie

2013-09-22 18:59

reporter   ~0015283

I went back and played with the 3.7.1 AVX build (based off 9786) and the medals work correctly with this build.

Goober5000

2013-09-22 19:50

administrator   ~0015284

Can you try the nightly based off 9796 too?

I have been working on this problem all day and, although there is definitely something wrong, it is not willing to show itself. And every part of my code is working perfectly fine.

Goober5000

2013-09-22 20:04

administrator   ~0015285

Last edited: 2013-09-22 20:04

*Something* is different because the game crashes on exit on 9800 but doesn't on 9798. I have no idea why though.

Goober5000

2013-09-22 23:36

administrator   ~0015286

Copied from the internal:

---
Oh good grief. It's not just memset you need to watch out for, it's also memcpy. Turns out that copying one stats structure to another (e.g. [tt]memcpy( &mission->stats, &Player->stats, sizeof(Player->stats) );[/tt] in missioncampaign) means that both stats will share the same underlying data in a SCP_vector, even if they use different vectors. This was the cause of Mantis 0002922 found by Macfie in [url=http://www.hard-light.net/forums/index.php?topic=85624.0]this thread[/url].

So, important lesson for anybody working with SCP_vector or SCP_string: you need to thoroughly check the code for uses of memcpy, not just memset.
---

This also explains the crash; it mentioned a heap corruption error but I had no idea how that could be caused. Well, it could be caused by two classes referencing the same heap memory and both trying to clear them.

Goober5000

2013-09-23 05:28

administrator   ~0015287

This is now fixed.

Related Changesets

fs2open: trunk r9813

2013-09-22 20:53

Goober5000


Ported: N/A

Details Diff
use a copy method rather than memcpy to clone stats (Mantis 0002922) Affected Issues
0002922
mod - /trunk/fs2_open/code/fs2netd/fs2netd_client.cpp Diff File
mod - /trunk/fs2_open/code/mission/missioncampaign.cpp Diff File
mod - /trunk/fs2_open/code/pilotfile/csg.cpp Diff File
mod - /trunk/fs2_open/code/pilotfile/plr.cpp Diff File
mod - /trunk/fs2_open/code/playerman/managepilot.cpp Diff File
mod - /trunk/fs2_open/code/stats/scoring.cpp Diff File
mod - /trunk/fs2_open/code/stats/scoring.h Diff File
mod - /trunk/fs2_open/code/stats/stats.cpp Diff File

fs2open: trunk r9814

2013-09-23 01:27

Goober5000


Ported: N/A

Details Diff
scoring_level_init is only supposed to initialize a subset of the stats Affected Issues
0002922
mod - /trunk/fs2_open/code/stats/scoring.cpp Diff File

Issue History

Date Modified Username Field Change
2013-09-22 01:45 Macfie New Issue
2013-09-22 01:55 chief1983 Assigned To => Goober5000
2013-09-22 01:55 chief1983 Status new => assigned
2013-09-22 17:34 Goober5000 Note Added: 0015282
2013-09-22 18:59 Macfie Note Added: 0015283
2013-09-22 19:50 Goober5000 Note Added: 0015284
2013-09-22 20:04 Goober5000 Note Added: 0015285
2013-09-22 20:04 Goober5000 Note Edited: 0015285
2013-09-22 23:36 Goober5000 Note Added: 0015286
2013-09-23 00:36 Goober5000 Changeset attached => fs2open trunk r9813
2013-09-23 05:11 Goober5000 Changeset attached => fs2open trunk r9814
2013-09-23 05:28 Goober5000 Note Added: 0015287
2013-09-23 05:28 Goober5000 Status assigned => resolved
2013-09-23 05:28 Goober5000 Fixed in Version => 3.7.2