Skip to content

Commit 2c7701f

Browse files
authored
refactor: Add compatibility macros for override and final keywords and rename conflicting identifiers (#2389)
1 parent b330a0f commit 2c7701f

20 files changed

Lines changed: 58 additions & 56 deletions

File tree

Core/GameEngine/Source/Common/OptionPreferences.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,10 @@ UnsignedShort OptionPreferences::getFirewallPortOverride()
435435
return TheGlobalData->m_firewallPortOverride;
436436
}
437437

438-
Int override = atoi(it->second.str());
439-
if (override < 0 || override > 65535)
440-
override = 0;
441-
return override;
438+
Int portOverride = atoi(it->second.str());
439+
if (portOverride < 0 || portOverride > 65535)
440+
portOverride = 0;
441+
return portOverride;
442442
}
443443

444444
Bool OptionPreferences::getFirewallNeedToRefresh()

Core/GameEngineDevice/Include/W3DDevice/GameClient/Module/W3DDebrisDraw.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class W3DDebrisDraw : public DrawModule, public DebrisDrawInterface
6565
virtual void reactToGeometryChange() { }
6666

6767
virtual void setModelName(AsciiString name, Color color, ShadowType t);
68-
virtual void setAnimNames(AsciiString initial, AsciiString flying, AsciiString final, const FXList* finalFX);
68+
virtual void setAnimNames(AsciiString initial, AsciiString flying, AsciiString finalAnim, const FXList* finalFX);
6969

7070
virtual DebrisDrawInterface* getDebrisDrawInterface() { return this; }
7171
virtual const DebrisDrawInterface* getDebrisDrawInterface() const { return this; }

Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void W3DDebrisDraw::setModelName(AsciiString name, Color color, ShadowType t)
148148
}
149149

150150
//-------------------------------------------------------------------------------------------------
151-
void W3DDebrisDraw::setAnimNames(AsciiString initial, AsciiString flying, AsciiString final, const FXList* finalFX)
151+
void W3DDebrisDraw::setAnimNames(AsciiString initial, AsciiString flying, AsciiString finalAnim, const FXList* finalFX)
152152
{
153153
int i;
154154
for (i = 0; i < STATECOUNT; ++i)
@@ -159,23 +159,23 @@ void W3DDebrisDraw::setAnimNames(AsciiString initial, AsciiString flying, AsciiS
159159

160160
m_anims[INITIAL] = initial.isEmpty() ? nullptr : W3DDisplay::m_assetManager->Get_HAnim(initial.str());
161161
m_anims[FLYING] = flying.isEmpty() ? nullptr : W3DDisplay::m_assetManager->Get_HAnim(flying.str());
162-
if (stricmp(final.str(), "STOP") == 0)
162+
if (stricmp(finalAnim.str(), "STOP") == 0)
163163
{
164164
m_finalStop = true;
165-
final = flying;
165+
finalAnim = flying;
166166
}
167167
else
168168
{
169169
m_finalStop = false;
170170
}
171-
m_anims[FINAL] = final.isEmpty() ? nullptr : W3DDisplay::m_assetManager->Get_HAnim(final.str());
171+
m_anims[FINAL] = finalAnim.isEmpty() ? nullptr : W3DDisplay::m_assetManager->Get_HAnim(finalAnim.str());
172172
m_state = 0;
173173
m_frames = 0;
174174
m_fxFinal = finalFX;
175175

176176
m_animInitial = initial;
177177
m_animFlying = flying;
178-
m_animFinal = final;
178+
m_animFinal = finalAnim;
179179

180180
}
181181

Dependencies/Utility/Utility/CppMacros.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#define constexpr
3434
#define noexcept
3535
#define nullptr 0
36+
#define override
37+
#define final
3638
#endif
3739

3840
#if __cplusplus >= 201703L

Generals/Code/GameEngine/Include/Common/DrawModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ class DebrisDrawInterface
123123
{
124124
public:
125125
virtual void setModelName(AsciiString name, Color color, ShadowType t) = 0;
126-
virtual void setAnimNames(AsciiString initial, AsciiString flying, AsciiString final, const FXList* finalFX) = 0;
126+
virtual void setAnimNames(AsciiString initial, AsciiString flying, AsciiString finalAnim, const FXList* finalFX) = 0;
127127
};
128128

129129
//-------------------------------------------------------------------------------------------------

Generals/Code/GameEngine/Include/Common/Override.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ template <class T> class OVERRIDE
5454
// Copy constructor
5555
OVERRIDE(OVERRIDE<T> &overridable);
5656
// Operator= for copying from another OVERRIDE and T*
57-
__inline OVERRIDE &operator=( const OVERRIDE<T>& override );
57+
__inline OVERRIDE &operator=( const OVERRIDE<T>& other );
5858
__inline OVERRIDE &operator=( const T* overridable );
5959

6060
// these are the methods which we can use to access data in a pointer. (Dereference*, ->, and cast
@@ -88,9 +88,9 @@ OVERRIDE<T>::OVERRIDE(OVERRIDE<T> &overridable)
8888

8989
//-------------------------------------------------------------------------------------------------
9090
template <class T>
91-
OVERRIDE<T> &OVERRIDE<T>::operator=( const OVERRIDE<T>& override )
91+
OVERRIDE<T> &OVERRIDE<T>::operator=( const OVERRIDE<T>& other )
9292
{
93-
m_overridable = override.m_overridable;
93+
m_overridable = other.m_overridable;
9494
return *this;
9595
}
9696

Generals/Code/GameEngine/Include/GameLogic/Module/ParachuteContain.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class ParachuteContain : public OpenContain
7676
virtual void onCollide( Object *other, const Coord3D *loc, const Coord3D *normal );
7777
virtual void onDie( const DamageInfo * damageInfo );
7878

79-
virtual void setOverrideDestination( const Coord3D *override ); ///< Instead of falling peacefully towards a clear spot, I will now aim here
79+
virtual void setOverrideDestination( const Coord3D *dest ); ///< Instead of falling peacefully towards a clear spot, I will now aim here
8080

8181
protected:
8282

Generals/Code/GameEngine/Source/Common/GlobalData.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,23 +1082,23 @@ Bool GlobalData::setTimeOfDay( TimeOfDay tod )
10821082
GlobalData *GlobalData::newOverride()
10831083
{
10841084
// TheSuperHackers @info This copy is not implemented in VS6 builds
1085-
GlobalData *override = NEW GlobalData;
1085+
GlobalData *overrideData = NEW GlobalData;
10861086

10871087
// copy the data from the latest override (TheWritableGlobalData) to the newly created instance
10881088
DEBUG_ASSERTCRASH( TheWritableGlobalData, ("GlobalData::newOverride() - no existing data") );
1089-
*override = *TheWritableGlobalData;
1089+
*overrideData = *TheWritableGlobalData;
10901090

10911091
//
10921092
// link the override to the previously created one, the link order is important here
10931093
// for the reset function, if you change the way things are linked
10941094
// for overrides make sure you update the reset function
10951095
//
1096-
override->m_next = TheWritableGlobalData;
1096+
overrideData->m_next = TheWritableGlobalData;
10971097

10981098
// set this new instance as the 'most current override' where we will access all data from
1099-
TheWritableGlobalData = override;
1099+
TheWritableGlobalData = overrideData;
11001100

1101-
return override;
1101+
return overrideData;
11021102

11031103
}
11041104

Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/OptionsMenu.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,12 +520,12 @@ static void saveOptions()
520520
UnicodeString uStr = GadgetTextEntryGetText(textEntryFirewallPortOverride);
521521
AsciiString aStr;
522522
aStr.translate(uStr);
523-
Int override = atoi(aStr.str());
524-
if (override < 0 || override > 65535)
525-
override = 0;
526-
if (TheGlobalData->m_firewallPortOverride != override)
527-
{ TheWritableGlobalData->m_firewallPortOverride = override;
528-
aStr.format("%d", override);
523+
Int portOverride = atoi(aStr.str());
524+
if (portOverride < 0 || portOverride > 65535)
525+
portOverride = 0;
526+
if (TheGlobalData->m_firewallPortOverride != portOverride)
527+
{ TheWritableGlobalData->m_firewallPortOverride = portOverride;
528+
aStr.format("%d", portOverride);
529529
(*pref)["FirewallPortOverride"] = aStr;
530530
}
531531
}

Generals/Code/GameEngine/Source/GameLogic/Object/Contain/ParachuteContain.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,10 +569,10 @@ void ParachuteContain::positionContainedObjectsRelativeToContainer()
569569
}
570570

571571
//-------------------------------------------------------------------------------------------------
572-
void ParachuteContain::setOverrideDestination( const Coord3D *override )
572+
void ParachuteContain::setOverrideDestination( const Coord3D *dest )
573573
{
574574
// Instead of trying to float straight down, I am going to nail this spot.
575-
m_landingOverride = *override;
575+
m_landingOverride = *dest;
576576
m_isLandingOverrideSet = TRUE;
577577
}
578578

0 commit comments

Comments
 (0)