2019-02-15 21:18 EST

View Issue Details Jump to Notes ] Related Changesets ]
IDProjectCategoryView StatusLast Update
0002951FSSCPdesign flawpublic2013-12-31 00:00
Assigned ToGoober5000 
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




Goober5000 (administrator)

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.


Goober5000 (administrator)

Reopening since both Spoon and FOTG need access to the $Substitute feature, and therefore the POD issues need to be resolved ASAP.


Goober5000 (administrator)

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.


Goober5000 (administrator)

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.


Goober5000 (administrator)

Feature will no longer corrupt memory. Resolving ticket.

+Related Changesets

-Issue History
Date Modified Username Field Change
2013-11-06 12:52 Goober5000 New Issue
2013-11-06 12:52 Goober5000 Status new => assigned
2013-11-06 12:52 Goober5000 Assigned To => iss_mneur
2013-11-15 23:24 Goober5000 Changeset attached => fs2open trunk r10082
2013-11-15 23:28 Goober5000 Note Added: 0015410
2013-11-15 23:28 Goober5000 Assigned To iss_mneur => Goober5000
2013-11-15 23:28 Goober5000 Status assigned => resolved
2013-11-15 23:28 Goober5000 Resolution open => fixed
2013-12-25 23:44 Goober5000 Note Added: 0015530
2013-12-25 23:44 Goober5000 Assigned To Goober5000 => iss_mneur
2013-12-25 23:44 Goober5000 Status resolved => assigned
2013-12-25 23:44 Goober5000 Resolution fixed => open
2013-12-25 23:46 Goober5000 Note Added: 0015531
2013-12-30 23:57 Goober5000 Changeset attached => fs2open trunk r10270
2013-12-30 23:57 Goober5000 Changeset attached => fs2open trunk r10269
2013-12-30 23:58 Goober5000 Note Added: 0015549
2013-12-31 00:00 Goober5000 Note Added: 0015550
2013-12-31 00:00 Goober5000 Assigned To iss_mneur => Goober5000
2013-12-31 00:00 Goober5000 Status assigned => resolved
2013-12-31 00:00 Goober5000 Resolution open => fixed
+Issue History