Skip to content

Commit 24be3ed

Browse files
authored
refactor: Add override keyword to virtual function overrides in Generals code (2) (#2604)
1 parent a3fe6c4 commit 24be3ed

37 files changed

Lines changed: 82 additions & 159 deletions

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ class Object;
4545
class Player;
4646
class Thing;
4747
class W3DModelDrawModuleData; // ugh, hack (srj)
48+
class W3DTreeDrawModuleData; // ugh, hack (srj)
4849
struct FieldParse;
4950

5051
// TYPES //////////////////////////////////////////////////////////////////////////////////////////
@@ -109,6 +110,8 @@ class ModuleData : public Snapshot
109110

110111
// ugh, hack
111112
virtual const W3DModelDrawModuleData* getAsW3DModelDrawModuleData() const { return nullptr; }
113+
// ugh, hack
114+
virtual const W3DTreeDrawModuleData* getAsW3DTreeDrawModuleData() const { return nullptr; }
112115
virtual StaticGameLODLevel getMinimumRequiredGameLOD() const { return (StaticGameLODLevel)0;}
113116

114117
static void buildFieldParse(MultiIniFieldParse& p)
@@ -133,20 +136,20 @@ class ModuleData : public Snapshot
133136
#define MAKE_STANDARD_MODULE_MACRO( cls ) \
134137
public: \
135138
static Module* friend_newModuleInstance( Thing *thing, const ModuleData* moduleData ) { return newInstance( cls )( thing, moduleData ); } \
136-
virtual NameKeyType getModuleNameKey() const { static NameKeyType nk = NAMEKEY(#cls); return nk; } \
139+
virtual NameKeyType getModuleNameKey() const override { static NameKeyType nk = NAMEKEY(#cls); return nk; } \
137140
protected: \
138-
virtual void crc( Xfer *xfer ); \
139-
virtual void xfer( Xfer *xfer ); \
140-
virtual void loadPostProcess();
141+
virtual void crc( Xfer *xfer ) override; \
142+
virtual void xfer( Xfer *xfer ) override; \
143+
virtual void loadPostProcess() override;
141144

142145
// ------------------------------------------------------------------------------------------------
143146
// For the creation of abstract module classes
144147
// ------------------------------------------------------------------------------------------------
145148
#define MAKE_STANDARD_MODULE_MACRO_ABC( cls ) \
146149
protected: \
147-
virtual void crc( Xfer *xfer ); \
148-
virtual void xfer( Xfer *xfer ); \
149-
virtual void loadPostProcess();
150+
virtual void crc( Xfer *xfer ) override; \
151+
virtual void xfer( Xfer *xfer ) override; \
152+
virtual void loadPostProcess() override;
150153

151154
//-------------------------------------------------------------------------------------------------
152155
// only use this macro for an ABC. for a real class, use MAKE_STANDARD_MODULE_MACRO_WITH_MODULE_DATA.

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,6 @@ class State : public MemoryPoolObject, public Snapshot
180180
inline void setName(AsciiString n) { m_name = n; }
181181
#endif
182182

183-
protected:
184-
// snapshot interface - pure virtual here.
185-
// Essentially all the member data gets set up on creation and shouldn't change.
186-
// So none of it needs to be saved, and it nicely forces all user states to
187-
// remember to implement crc, xfer & loadPostProcess. jba
188-
virtual void crc( Xfer *xfer )=0;
189-
virtual void xfer( Xfer *xfer )=0;
190-
virtual void loadPostProcess()=0;
191-
192183
private:
193184

194185
struct TransitionInfo

Generals/Code/GameEngine/Include/GameClient/InGameUI.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ friend class Drawable; // for selection/deselection transactions
455455
virtual void disregardDrawable( Drawable *draw ); ///< Drawable is being destroyed, clean up any UI elements associated with it
456456

457457
virtual void preDraw(); ///< Logic which needs to occur before the UI renders
458-
virtual void draw() = 0; ///< Render the in-game user interface
458+
virtual void draw() override = 0; ///< Render the in-game user interface
459459
virtual void postDraw(); ///< Logic which needs to occur after the UI renders
460460
virtual void postWindowDraw(); ///< Logic which needs to occur after the WindowManager has repainted the menus
461461

Generals/Code/GameEngine/Include/GameLogic/AIStateMachine.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ class AIStateMachine : public StateMachine
160160
public: // overrides.
161161
virtual StateReturnType updateStateMachine() override; ///< run one step of the machine
162162
#ifdef STATE_MACHINE_DEBUG
163-
virtual AsciiString getCurrentStateName() const ;
163+
virtual AsciiString getCurrentStateName() const override;
164164
#endif
165165

166166
protected:
@@ -573,7 +573,7 @@ EMPTY_DTOR(AIPickUpCrateState)
573573
virtual void onExit( StateExitType status ) override;
574574
virtual StateReturnType update() override;
575575
#ifdef STATE_MACHINE_DEBUG
576-
virtual AsciiString getName() const ;
576+
virtual AsciiString getName() const override;
577577
#endif
578578

579579
protected:
@@ -681,7 +681,7 @@ class AIAttackFollowWaypointPathState : public AIFollowWaypointPathState
681681
virtual void onExit( StateExitType status ) override;
682682
virtual StateReturnType update() override;
683683
#ifdef STATE_MACHINE_DEBUG
684-
virtual AsciiString getName() const ;
684+
virtual AsciiString getName() const override;
685685
#endif
686686

687687
protected:
@@ -983,7 +983,7 @@ class AIAttackState : public State, public NotifyWeaponFiredInterface
983983
virtual Bool isAttackingObject() const override { return m_isAttackingObject; }
984984
virtual Bool isForceAttacking() const { return m_isForceAttacking; }
985985
#ifdef STATE_MACHINE_DEBUG
986-
virtual AsciiString getName() const ;
986+
virtual AsciiString getName() const override;
987987
#endif
988988

989989
virtual Bool isAttack() const override { return TRUE; }
@@ -1022,7 +1022,7 @@ class AIAttackSquadState : public State
10221022
virtual StateReturnType update() override;
10231023
Object *chooseVictim();
10241024
#ifdef STATE_MACHINE_DEBUG
1025-
virtual AsciiString getName() const ;
1025+
virtual AsciiString getName() const override;
10261026
#endif
10271027

10281028

@@ -1064,7 +1064,7 @@ class AIDockState : public State
10641064
virtual void onExit( StateExitType status ) override;
10651065
virtual StateReturnType update() override;
10661066
#ifdef STATE_MACHINE_DEBUG
1067-
virtual AsciiString getName() const ;
1067+
virtual AsciiString getName() const override;
10681068
#endif
10691069

10701070
protected:
@@ -1135,7 +1135,7 @@ class AIGuardState : public State
11351135
virtual void onExit( StateExitType status ) override;
11361136
virtual StateReturnType update() override;
11371137
#ifdef STATE_MACHINE_DEBUG
1138-
virtual AsciiString getName() const ;
1138+
virtual AsciiString getName() const override;
11391139
#endif
11401140
protected:
11411141
// snapshot interface
@@ -1164,7 +1164,7 @@ class AITunnelNetworkGuardState : public State
11641164
virtual void onExit( StateExitType status ) override;
11651165
virtual StateReturnType update() override;
11661166
#ifdef STATE_MACHINE_DEBUG
1167-
virtual AsciiString getName() const ;
1167+
virtual AsciiString getName() const override;
11681168
#endif
11691169
protected:
11701170
// snapshot interface
@@ -1193,7 +1193,7 @@ class AIHuntState : public State
11931193
virtual void onExit( StateExitType status ) override;
11941194
virtual StateReturnType update() override;
11951195
#ifdef STATE_MACHINE_DEBUG
1196-
virtual AsciiString getName() const ;
1196+
virtual AsciiString getName() const override;
11971197
#endif
11981198

11991199
protected:
@@ -1223,7 +1223,7 @@ class AIAttackAreaState : public State
12231223
virtual void onExit( StateExitType status ) override;
12241224
virtual StateReturnType update() override;
12251225
#ifdef STATE_MACHINE_DEBUG
1226-
virtual AsciiString getName() const ;
1226+
virtual AsciiString getName() const override;
12271227
#endif
12281228

12291229
protected:

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

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -207,43 +207,10 @@ class BodyModule : public BehaviorModule, public BodyModuleInterface
207207
// BehaviorModule
208208
virtual BodyModuleInterface* getBody() override { return this; }
209209

210-
/**
211-
Try to damage this Object. The module's Armor
212-
will be taken into account, so the actual damage done may vary
213-
considerably from what you requested. Also note that (if damage is done)
214-
the DamageFX will be invoked to provide a/v fx as appropriate.
215-
*/
216-
virtual void attemptDamage( DamageInfo *damageInfo ) = 0;
217-
218-
/**
219-
Instead of having negative damage count as healing, or allowing access to the private
220-
changeHealth Method, we will use this parallel to attemptDamage to do healing without hack.
221-
*/
222-
virtual void attemptHealing( DamageInfo *healingInfo ) = 0;
223-
224-
/**
225-
Estimate the (unclipped) damage that would be done to this object
226-
by the given damage (taking bonuses, armor, etc into account),
227-
but DO NOT alter the body in any way. (This is used by the AI system
228-
to choose weapons.)
229-
*/
230-
virtual Real estimateDamage( DamageInfoInput& damageInfo ) const = 0;
231-
232-
virtual Real getHealth() const = 0; ///< get current health
233-
234210
virtual Real getMaxHealth() const override {return 0.0f;} ///< return max health
235211

236212
virtual Real getInitialHealth() const override {return 0.0f;} // return initial health
237213

238-
virtual BodyDamageType getDamageState() const = 0;
239-
virtual void setDamageState( BodyDamageType newState ) = 0; ///< control damage state directly. Will adjust hitpoints.
240-
virtual void setAflame( Bool setting ) = 0;///< This is a major change like a damage state.
241-
242-
virtual void onVeterancyLevelChanged( VeterancyLevel oldLevel, VeterancyLevel newLevel, Bool provideFeedback = FALSE ) = 0; ///< I just achieved this level right this moment
243-
244-
virtual void setArmorSetFlag(ArmorSetType ast) = 0;
245-
virtual void clearArmorSetFlag(ArmorSetType ast) = 0;
246-
247214
virtual const DamageInfo *getLastDamageInfo() const override { return nullptr; } ///< return info on last damage dealt to this object
248215
virtual UnsignedInt getLastDamageTimestamp() const override { return 0; } ///< return frame of last damage dealt
249216
virtual UnsignedInt getLastHealingTimestamp() const override { return 0; } ///< return frame of last healing dealt
@@ -266,15 +233,6 @@ class BodyModule : public BehaviorModule, public BodyModuleInterface
266233
virtual void applyDamageScalar( Real scalar ) override { m_damageScalar *= scalar; }
267234
virtual Real getDamageScalar() const override { return m_damageScalar; }
268235

269-
/**
270-
Change the module's health by the given delta. Note that
271-
the module's DamageFX and Armor are NOT taken into
272-
account, so you should think about what you're bypassing when you
273-
call this directly (especially when when decreasing health, since
274-
you probably want "attemptDamage" or "attemptHealing")
275-
*/
276-
virtual void internalChangeHealth( Real delta ) = 0;
277-
278236
virtual void evaluateVisualCondition() override { }
279237
virtual void updateBodyParticleSystems() override { };// made public for topple anf building collapse updates -ML
280238

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ class CollideModule : public BehaviorModule,
8484
// BehaviorModule
8585
virtual CollideModuleInterface* getCollide() override { return this; }
8686

87-
virtual void onCollide( Object *other, const Coord3D *loc, const Coord3D *normal ) = 0;
88-
8987
/// this is used for things like pilots, to determine if they can "enter" something
9088
virtual Bool wouldLikeToCollideWith(const Object* other) const override { return false; }
9189
virtual Bool isHijackedVehicleCrateCollide() const override { return false; }

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ class CreateModule : public BehaviorModule, public CreateModuleInterface
7373
// BehaviorModule
7474
virtual CreateModuleInterface* getCreate() override { return this; }
7575

76-
virtual void onCreate() = 0; ///< This is called when you become a code Object
7776
virtual void onBuildComplete() override { m_needToRunOnBuildComplete = FALSE; } ///< This is called when you are a finished game object
7877
virtual Bool shouldDoOnBuildComplete() const override { return m_needToRunOnBuildComplete; }
7978

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,13 +97,6 @@ class DamageModule : public BehaviorModule, public DamageModuleInterface
9797
// BehaviorModule
9898
virtual DamageModuleInterface* getDamage() override { return this; }
9999

100-
// damage module callbacks
101-
virtual void onDamage( DamageInfo *damageInfo ) = 0; ///< damage callback
102-
virtual void onHealing( DamageInfo *damageInfo ) = 0; ///< healing callback
103-
virtual void onBodyDamageStateChange( const DamageInfo* damageInfo,
104-
BodyDamageType oldState,
105-
BodyDamageType newState) = 0; ///< state change callback
106-
107100
protected:
108101

109102
};

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ class DestroyModule : public BehaviorModule, public DestroyModuleInterface
5858
// BehaviorModule
5959
virtual DestroyModuleInterface* getDestroy() override { return this; }
6060

61-
virtual void onDestroy() = 0;
62-
6361
protected:
6462

6563
};

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,6 @@ class DieModule : public BehaviorModule, public DieModuleInterface
9797
// BehaviorModule
9898
virtual DieModuleInterface* getDie() override { return this; }
9999

100-
virtual void onDie( const DamageInfo *damageInfo ) = 0;
101-
102100
protected:
103101
Bool isDieApplicable(const DamageInfo *damageInfo) const { return getDieModuleData()->isDieApplicable(getObject(), damageInfo); }
104102

0 commit comments

Comments
 (0)