Source Code Project Mantis - FSSCP
View Issue Details
0002951FSSCPdesign flawpublic2013-11-06 12:522013-12-31 00:00
Assigned ToGoober5000 
PlatformOSOS Version
Product Version3.7.1 
Target Version3.7.2Fixed in Version 
Summary0002951: weapon_substitution_pattern is not compatible with POD struct
DescriptionThe weapon_info struct used to be a POD (plain old data) type, but POD types may only contain other POD types. Since weapon_substitution_pattern and weapon_substitution_pattern_names are classes, they violate this requirement.

There are two ways to fix this. One, the fields could be turned into arrays with an accompanying length field, similar to targeting_priorities right above it.

Or two, the weapon_info struct could be turned into a class. Look at object and ship, etc. to see how this should be done. You would need to change "struct" to "class", make all the fields public, add a constructor, and add a clear() method. Then you would have to search the code for all instances of memset, vm_malloc, and vm_free that use weapon_info, and change them to clear(), new, and delete respectively. And if any other structs contain a complete weapon_info struct (as opposed to a pointer to weapon_info), those structs must be changed to classes in the same way.

Your choice how to proceed, but this should be done as soon as possible.
TagsNo tags attached.
Attached Files

2013-11-15 23:28   
Since the feature never would have worked in the first place (for the same reasons as the ship template code -- see issue 0002064), I went ahead and removed it.
2013-12-25 23:44   
Reopening since both Spoon and FOTG need access to the $Substitute feature, and therefore the POD issues need to be resolved ASAP.
2013-12-25 23:46   
I will add that due to the urgent need for this feature, if the POD-specific aspects are not fixed this coming weekend, I will re-add the feature -- but I will add it with plain old arrays with fixed limits, not SCP_vectors.
2013-12-30 23:58   
Latest SVN has the modified feature which no longer has memory corruption issues.

I will say, though, that the weapon_substitution_pattern feature is very badly written and deserves a complete rewrite.
2013-12-31 00:00   
Feature will no longer corrupt memory. Resolving ticket.

Issue History
2013-11-06 12:52Goober5000New Issue
2013-11-06 12:52Goober5000Statusnew => assigned
2013-11-06 12:52Goober5000Assigned To => iss_mneur
2013-11-15 23:24Goober5000Changeset attached => fs2open trunk r10082
2013-11-15 23:28Goober5000Note Added: 0015410
2013-11-15 23:28Goober5000Assigned Toiss_mneur => Goober5000
2013-11-15 23:28Goober5000Statusassigned => resolved
2013-11-15 23:28Goober5000Resolutionopen => fixed
2013-12-25 23:44Goober5000Note Added: 0015530
2013-12-25 23:44Goober5000Assigned ToGoober5000 => iss_mneur
2013-12-25 23:44Goober5000Statusresolved => assigned
2013-12-25 23:44Goober5000Resolutionfixed => open
2013-12-25 23:46Goober5000Note Added: 0015531
2013-12-30 23:57Goober5000Changeset attached => fs2open trunk r10270
2013-12-30 23:57Goober5000Changeset attached => fs2open trunk r10269
2013-12-30 23:58Goober5000Note Added: 0015549
2013-12-31 00:00Goober5000Note Added: 0015550
2013-12-31 00:00Goober5000Assigned Toiss_mneur => Goober5000
2013-12-31 00:00Goober5000Statusassigned => resolved
2013-12-31 00:00Goober5000Resolutionopen => fixed