File tree Expand file tree Collapse file tree 4 files changed +30
-8
lines changed
GeneralsMD/Code/GameEngine/Include Expand file tree Collapse file tree 4 files changed +30
-8
lines changed Original file line number Diff line number Diff line change 42
42
#undef SPARSEMATCH_DEBUG
43
43
#endif
44
44
45
+ typedef UnsignedInt SparseMatchFinderFlags;
46
+ enum SparseMatchFinderFlags_ CPP_11 (: SparseMatchFinderFlags)
47
+ {
48
+ SparseMatchFinderFlags_NoCopy = 1 <<0 ,
49
+ };
50
+
45
51
// -------------------------------------------------------------------------------------------------
46
- template <class MATCHABLE , class BITSET >
52
+ template <class MATCHABLE , class BITSET , SparseMatchFinderFlags FLAGS = 0 >
47
53
class SparseMatchFinder
48
54
{
49
55
private:
@@ -185,9 +191,26 @@ class SparseMatchFinder
185
191
return result;
186
192
}
187
193
188
- // -------------------------------------------------------------------------------------------------
189
194
public:
190
195
196
+
197
+ // -------------------------------------------------------------------------------------------------
198
+ SparseMatchFinder () {}
199
+ SparseMatchFinder (const SparseMatchFinder& other)
200
+ {
201
+ *this = other;
202
+ }
203
+
204
+ // -------------------------------------------------------------------------------------------------
205
+ SparseMatchFinder& operator =(const SparseMatchFinder& other)
206
+ {
207
+ if ((FLAGS & SparseMatchFinderFlags_NoCopy) == 0 && this != &other)
208
+ {
209
+ m_bestMatches = other.m_bestMatches ;
210
+ }
211
+ return *this ;
212
+ }
213
+
191
214
// -------------------------------------------------------------------------------------------------
192
215
void clear ()
193
216
{
Original file line number Diff line number Diff line change @@ -698,6 +698,11 @@ class ThingTemplate : public Overridable
698
698
// Code renderer handles these states now.
699
699
// AsciiString m_inventoryImage[ INV_IMAGE_NUM_IMAGES ]; ///< portrait inventory pictures
700
700
701
+ // TheSuperHackers @bugfix Caball009/xezon 06/07/2025 No longer copy SparseMatchFinder to prevent copied instances linking to unrelated data.
702
+ // This avoids mismatching in certain maps, for example those that spawn units with veterancy.
703
+ typedef SparseMatchFinder<WeaponTemplateSet, WeaponSetFlags, SparseMatchFinderFlags_NoCopy> WeaponTemplateSetFinder;
704
+ typedef SparseMatchFinder<ArmorTemplateSet, ArmorSetFlags, SparseMatchFinderFlags_NoCopy> ArmorTemplateSetFinder;
705
+
701
706
// ---- STL-sized things
702
707
std::vector<ProductionPrerequisite> m_prereqInfo; // /< the unit Prereqs for this tech
703
708
std::vector<AsciiString> m_buildVariations; /* *< if we build a unit of this type via script or ui, randomly choose one
Original file line number Diff line number Diff line change @@ -97,7 +97,4 @@ class ArmorTemplateSet
97
97
// -------------------------------------------------------------------------------------------------
98
98
typedef std::vector<ArmorTemplateSet> ArmorTemplateSetVector;
99
99
100
- // -------------------------------------------------------------------------------------------------
101
- typedef SparseMatchFinder<ArmorTemplateSet, ArmorSetFlags> ArmorTemplateSetFinder;
102
-
103
100
#endif // _ArmorSet_H_
Original file line number Diff line number Diff line change @@ -166,9 +166,6 @@ class WeaponTemplateSet
166
166
// -------------------------------------------------------------------------------------------------
167
167
typedef std::vector<WeaponTemplateSet> WeaponTemplateSetVector;
168
168
169
- // -------------------------------------------------------------------------------------------------
170
- typedef SparseMatchFinder<WeaponTemplateSet, WeaponSetFlags> WeaponTemplateSetFinder;
171
-
172
169
// -------------------------------------------------------------------------------------------------
173
170
enum WeaponChoiceCriteria CPP_11 (: Int)
174
171
{
You can’t perform that action at this time.
0 commit comments