File tree Expand file tree Collapse file tree 4 files changed +33
-8
lines changed
Generals/Code/GameEngine/Include Expand file tree Collapse file tree 4 files changed +33
-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:
@@ -183,9 +189,29 @@ class SparseMatchFinder
183
189
return result;
184
190
}
185
191
186
- // -------------------------------------------------------------------------------------------------
187
192
public:
188
193
194
+
195
+ // -------------------------------------------------------------------------------------------------
196
+ SparseMatchFinder () {}
197
+ SparseMatchFinder (const SparseMatchFinder& other)
198
+ {
199
+ *this = other;
200
+ }
201
+
202
+ // -------------------------------------------------------------------------------------------------
203
+ SparseMatchFinder& operator =(const SparseMatchFinder& other)
204
+ {
205
+ if CONSTEXPR ((FLAGS & SparseMatchFinderFlags_NoCopy) == 0 )
206
+ {
207
+ if (this != &other)
208
+ {
209
+ m_bestMatches = other.m_bestMatches ;
210
+ }
211
+ }
212
+ return *this ;
213
+ }
214
+
189
215
// -------------------------------------------------------------------------------------------------
190
216
void clear ()
191
217
{
Original file line number Diff line number Diff line change @@ -681,6 +681,11 @@ class ThingTemplate : public Overridable
681
681
// Code renderer handles these states now.
682
682
// AsciiString m_inventoryImage[ INV_IMAGE_NUM_IMAGES ]; ///< portrait inventory pictures
683
683
684
+ // TheSuperHackers @bugfix Caball009/xezon 06/07/2025 No longer copy SparseMatchFinder to prevent copied instances linking to unrelated data.
685
+ // This avoids mismatching in certain maps, for example those that spawn units with veterancy.
686
+ typedef SparseMatchFinder<WeaponTemplateSet, WeaponSetFlags, SparseMatchFinderFlags_NoCopy> WeaponTemplateSetFinder;
687
+ typedef SparseMatchFinder<ArmorTemplateSet, ArmorSetFlags, SparseMatchFinderFlags_NoCopy> ArmorTemplateSetFinder;
688
+
684
689
// ---- STL-sized things
685
690
std::vector<ProductionPrerequisite> m_prereqInfo; // /< the unit Prereqs for this tech
686
691
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 @@ -94,7 +94,4 @@ class ArmorTemplateSet
94
94
// -------------------------------------------------------------------------------------------------
95
95
typedef std::vector<ArmorTemplateSet> ArmorTemplateSetVector;
96
96
97
- // -------------------------------------------------------------------------------------------------
98
- typedef SparseMatchFinder<ArmorTemplateSet, ArmorSetFlags> ArmorTemplateSetFinder;
99
-
100
97
#endif // _ArmorSet_H_
Original file line number Diff line number Diff line change @@ -146,9 +146,6 @@ class WeaponTemplateSet
146
146
// -------------------------------------------------------------------------------------------------
147
147
typedef std::vector<WeaponTemplateSet> WeaponTemplateSetVector;
148
148
149
- // -------------------------------------------------------------------------------------------------
150
- typedef SparseMatchFinder<WeaponTemplateSet, WeaponSetFlags> WeaponTemplateSetFinder;
151
-
152
149
// -------------------------------------------------------------------------------------------------
153
150
enum WeaponChoiceCriteria CPP_11 (: Int)
154
151
{
You can’t perform that action at this time.
0 commit comments