Skip to content

Commit df54e43

Browse files
committed
unify(academystats): Move AcademyStats files to Core and merge related required code (#2765)
1 parent 59d4c29 commit df54e43

25 files changed

Lines changed: 161 additions & 28 deletions

File tree

Core/GameEngine/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
set(GAMEENGINE_SRC
2-
# Include/Common/AcademyStats.h
2+
Include/Common/AcademyStats.h
33
# Include/Common/ActionManager.h
44
Include/Common/AddonCompat.h
55
Include/Common/ArchiveFile.h
@@ -621,7 +621,7 @@ set(GAMEENGINE_SRC
621621
Source/Common/RandomValue.cpp
622622
# Source/Common/Recorder.cpp
623623
Source/Common/ReplaySimulation.cpp
624-
# Source/Common/RTS/AcademyStats.cpp
624+
Source/Common/RTS/AcademyStats.cpp
625625
# Source/Common/RTS/ActionManager.cpp
626626
# Source/Common/RTS/Energy.cpp
627627
# Source/Common/RTS/Handicap.cpp
File renamed without changes.

GeneralsMD/Code/GameEngine/Source/Common/RTS/AcademyStats.cpp renamed to Core/GameEngine/Source/Common/RTS/AcademyStats.cpp

File renamed without changes.

Core/GameEngine/Source/GameLogic/AI/AIPathfind.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8778,11 +8778,7 @@ Path *Pathfinder::findClosestPath( Object *obj, const LocomotorSet& locomotorSet
87788778
PathfindCell *ignoreCell = getClippedCell(goalObj->getLayer(), goalObj->getPosition());
87798779
if ( (goalCell->getObstacleID()==ignoreCell->getObstacleID()) && (goalCell->getObstacleID() != INVALID_ID) ) {
87808780
Object* newObstacle = TheGameLogic->findObjectByID(goalCell->getObstacleID());
8781-
#if RTS_GENERALS
8782-
if (newObstacle != nullptr && newObstacle->isKindOf(KINDOF_AIRFIELD))
8783-
#else
87848781
if (newObstacle != nullptr && newObstacle->isKindOf(KINDOF_FS_AIRFIELD))
8785-
#endif
87868782
{
87878783
m_ignoreObstacleID = goalCell->getObstacleID();
87888784
goalOnObstacle = true;

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

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
// INCLUDES ///////////////////////////////////////////////////////////////////////////////////////
3333
#include "Lib/BaseType.h"
3434
#include "Common/BitFlags.h"
35+
#include "Common/BitFlagsIO.h"
3536

3637
//-------------------------------------------------------------------------------------------------
3738
/** Kind of flags for determining groups of things that belong together
@@ -42,7 +43,7 @@ enum KindOfType CPP_11(: Int)
4243
KINDOF_INVALID = -1,
4344

4445
KINDOF_OBSTACLE, ///< an obstacle to land-based pathfinders
45-
KINDOF_SELECTABLE, ///< Selectable
46+
KINDOF_SELECTABLE, ///< Actually means MOUSE-INTERACTABLE (doesn't mean you can select it!)
4647
KINDOF_IMMOBILE, ///< fixed in location
4748
KINDOF_CAN_ATTACK, ///< can attack
4849
KINDOF_STICK_TO_TERRAIN_SLOPE, ///< should be stuck at ground level, aligned to terrain slope. requires that IMMOBILE bit is also set.
@@ -79,7 +80,9 @@ enum KindOfType CPP_11(: Int)
7980
KINDOF_STEALTH_GARRISON, /** enemy teams can't tell that unit is in building.. and if they
8081
garrison that building, they stealth unit will eject. */
8182
KINDOF_CASH_GENERATOR, ///< used to check if the unit generates cash... checked by cash hackers and whatever else comes up
83+
#if RTS_GENERALS
8284
KINDOF_AIRFIELD, ///< unit has a runway that planes can takeoff/land on
85+
#endif
8386
KINDOF_DRAWABLE_ONLY, ///< template is used only to create drawables (not Objects)
8487
KINDOF_MP_COUNT_FOR_VICTORY, ///< If a player loses all his buildings that have this kindof in a multiplayer game, he loses.
8588
KINDOF_REBUILD_HOLE, ///< a GLA rebuild hole
@@ -119,7 +122,7 @@ enum KindOfType CPP_11(: Int)
119122
KINDOF_TECH_BUILDING, ///< Neutral tech building - Oil derrick, Hospital, Radio Station, Refinery.
120123
KINDOF_POWERED, ///< This object gets the Underpowered disabled condition when its owning player has power consumption exceed supply
121124
KINDOF_PRODUCED_AT_HELIPAD, ///< ugh... hacky fix for comanche. (srj)
122-
KINDOF_DRONE, ///< Object drone type -- used for filtering them out of battle plan bonuses and whatever else may come up.
125+
KINDOF_DRONE, ///< Object drone type -- used for filtering them out of battle plan bonuses, making un-snipable, and whatever else may come up.
123126
KINDOF_CAN_SEE_THROUGH_STRUCTURE,///< Structure does not block line of sight.
124127
KINDOF_BALLISTIC_MISSILE, ///< Large ballistic missiles that are specifically large enough to be targetted by base defenses.
125128
KINDOF_CLICK_THROUGH, ///< Objects with this will never be picked by mouse interactions!
@@ -139,6 +142,35 @@ enum KindOfType CPP_11(: Int)
139142
KINDOF_HERO, ///< Any of the single-instance infantry, JarmenKell, BlackLotus, ColonelBurton
140143
KINDOF_IGNORES_SELECT_ALL, ///< Too late to figure out intelligently if something should respond to a Select All command
141144
KINDOF_DONT_AUTO_CRUSH_INFANTRY, ///< These units don't try to crush the infantry if ai.
145+
// TheSuperHackers @info Added in Zero Hour:
146+
KINDOF_CLIFF_JUMPER, ///< Can't climb cliffs, but can jump off of them.
147+
KINDOF_FS_SUPPLY_DROPZONE, ///< A supply dropzone.
148+
KINDOF_FS_SUPERWEAPON, ///< A superweapon structure like a nuke silo, particle uplink cannon, scudstorm.
149+
KINDOF_FS_BLACK_MARKET, ///< Is this object a black market?
150+
KINDOF_FS_SUPPLY_CENTER, ///< Is this object a supply center?
151+
KINDOF_FS_STRATEGY_CENTER, ///< Is this object a strategy center?
152+
KINDOF_MONEY_HACKER, ///< Unit that generates money from air. Needed for things that directly power them up.
153+
KINDOF_ARMOR_SALVAGER, ///< subset of salvager that can get armor upgrades from salvage
154+
KINDOF_REVEALS_ENEMY_PATHS, ///< like the listening outpost... when selected, any enemy drawable will draw show paths when moused over
155+
KINDOF_BOOBY_TRAP, ///< A sticky bomb that gets set off by 5 random and unrelated events.
156+
KINDOF_FS_FAKE, ///< Fake structure!
157+
KINDOF_FS_INTERNET_CENTER, ///< Internet Center.
158+
KINDOF_BLAST_CRATER, ///< deeply gouges out the terrain under object footprint
159+
KINDOF_PROP, ///< A prop, visual only, doesn't interact with other objects (rock, street sign, inert fire hydrant)
160+
KINDOF_OPTIMIZED_TREE, ///< An optimized, client side only tree. (The only good kind of tree. jba)
161+
KINDOF_FS_ADVANCED_TECH, ///< Represents each faction's advanced techtree building -- strategy center, propaganda center, and palace.
162+
KINDOF_FS_BARRACKS, ///< A barracks
163+
KINDOF_FS_WARFACTORY, ///< A war factory or arms dealer.
164+
KINDOF_FS_AIRFIELD, ///< An airfield.
165+
KINDOF_AIRCRAFT_CARRIER, ///< An aircraft carrier.
166+
KINDOF_NO_SELECT, ///< Can't select it but you can mouse over it to see it's health (drones!)
167+
KINDOF_REJECT_UNMANNED, ///< Unit cannot enter an unmanned vehicle.
168+
KINDOF_CANNOT_RETALIATE, ///< Unit will not retaliate if asked.
169+
KINDOF_TECH_BASE_DEFENSE, ///< Tech Building that acts as base defence when captured
170+
KINDOF_EMP_HARDENED, ///< Like a delivery plane (B52, B3, CargoPlane,etc.) or a SpectreGunship, which sort-of IS the weapon...
171+
KINDOF_DEMOTRAP, ///< Added strictly only for disarming purposes. They don't act like mines which have rendering and selection implications!
172+
KINDOF_CONSERVATIVE_BUILDING, ///< Conservative structures aren't considered part of your base for sneak attack boundary calculations...
173+
KINDOF_IGNORE_DOCKING_BONES, ///< Structure will not look up docking bones. Patch 1.03 hack.
142174

143175
KINDOF_COUNT, // total number of kindofs
144176
KINDOF_FIRST = 0,
@@ -186,3 +218,4 @@ inline void FLIP_KINDOFMASK(KindOfMaskType& m)
186218

187219
// defined in Common/System/Kindof.cpp
188220
extern KindOfMaskType KINDOFMASK_NONE; // inits to all zeroes
221+
extern KindOfMaskType KINDOFMASK_FS; // Initializes all FS types for faction structures.

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444

4545
#pragma once
4646

47+
#include "Common/AcademyStats.h"
4748
#include "Common/Debug.h"
4849
#include "Common/Energy.h"
4950
#include "Common/GameType.h"
@@ -519,7 +520,7 @@ class Player : public Snapshot
519520
/**
520521
* Iterate all objects that this player has
521522
*/
522-
void iterateObjects( ObjectIterateFunc func, void *userData );
523+
void iterateObjects( ObjectIterateFunc func, void *userData ) const;
523524

524525
/**
525526
return this player's "default" team.
@@ -651,6 +652,9 @@ class Player : public Snapshot
651652
void setCashBounty(Real percentage) { m_cashBountyPercent = percentage; }
652653
void doBountyForKill(const Object* killer, const Object* victim);
653654

655+
AcademyStats* getAcademyStats() { return &m_academyStats; }
656+
const AcademyStats* getAcademyStats() const { return &m_academyStats; }
657+
654658
//Set via logical message. Options menu sets the client value in global data. Player::update()
655659
//detects a change, and posts a message. When the message gets processed, this value gets set.
656660
Bool isLogicalRetaliationModeEnabled() const { return m_logicalRetaliationModeEnabled; }
@@ -772,6 +776,8 @@ class Player : public Snapshot
772776
PlayerRelationMap *m_playerRelations; ///< allies & enemies
773777
TeamRelationMap *m_teamRelations; ///< allies & enemies
774778

779+
AcademyStats m_academyStats; ///< Keeps track of various statistics in order to provide advice to the player about how to improve playing.
780+
775781
Bool m_canBuildUnits; ///< whether the current player is allowed to build units
776782
Bool m_canBuildBase; ///< whether the current player is allowed to build Base buildings
777783
Bool m_observer;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class PlayerTemplate
8282
UnicodeString getDisplayName() const { return m_displayName; }
8383

8484
AsciiString getSide() const { return m_side; }
85+
AsciiString getBaseSide() const { return m_baseSide; }
8586

8687
/// return the tech tree for the player.
8788
const Handicap *getHandicap() const { return &m_handicap; }
@@ -142,7 +143,7 @@ class PlayerTemplate
142143

143144
NameKeyType m_nameKey;
144145
UnicodeString m_displayName;
145-
AsciiString m_side;
146+
AsciiString m_side, m_baseSide;
146147
Handicap m_handicap; ///< initial baseline for Player capabilities
147148
Money m_money; ///< starting credits, if any
148149
RGBColor m_preferredColor; ///< our preferred starting color

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class ObjectCreationList;
4444
class Object;
4545
enum ScienceType CPP_11(: Int);
4646
struct FieldParse;
47+
enum AcademyClassificationType CPP_11(: Int);
4748

4849
// For SpecialPowerType and SpecialPowerMaskType::s_bitNameList. Part of detangling.
4950
#include "Common/SpecialPowerType.h"
@@ -121,6 +122,7 @@ class SpecialPowerTemplate : public Overridable
121122
Real getViewObjectRange() const { return getFO()->m_viewObjectRange; }
122123
Real getRadiusCursorRadius() const { return getFO()->m_radiusCursorRadius; }
123124
Bool isShortcutPower() const { return getFO()->m_shortcutPower; }
125+
AcademyClassificationType getAcademyClassificationType() const { return m_academyClassificationType; }
124126

125127
private:
126128

@@ -133,6 +135,7 @@ class SpecialPowerTemplate : public Overridable
133135
ScienceType m_requiredScience; ///< science required (if any) to actually execute this power
134136
AudioEventRTS m_initiateSound; ///< sound to play when initiated
135137
AudioEventRTS m_initiateAtLocationSound; ///< sound to play at target location (if any)
138+
AcademyClassificationType m_academyClassificationType; ///< A value used by the academy to evaluate advice based on what players do.
136139
UnsignedInt m_detectionTime; ///< (frames) after using infiltration power (defection, etc.),
137140
///< how long it takes for ex comrades to realize it on their own
138141
UnsignedInt m_viewObjectDuration; ///< Lifetime of a looking object we slap down so you can watch the effect

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Player;
4040
class UpgradeTemplate;
4141
enum NameKeyType CPP_11(: Int);
4242
class Image;
43+
enum AcademyClassificationType CPP_11(: Int);
4344

4445
//-------------------------------------------------------------------------------------------------
4546
//-------------------------------------------------------------------------------------------------
@@ -51,7 +52,7 @@ enum UpgradeStatusType CPP_11(: Int)
5152
};
5253

5354
//The maximum number of upgrades.
54-
// TheSuperHackers @tweak Stubbjax 22/01/2026 Increases max upgrade count from 64 to allow for more upgrades.
55+
// TheSuperHackers @tweak Stubbjax 22/01/2026 Increases max upgrade count from Generals:64, Zero Hour:128 to allow for more upgrades.
5556
// A value of 512 was chosen to allow room for plenty of upgrades while also conserving memory.
5657
#define UPGRADE_MAX_COUNT 512
5758

@@ -178,6 +179,7 @@ class UpgradeTemplate : public MemoryPoolObject
178179
UpgradeType getUpgradeType() const { return m_type; }
179180
const AudioEventRTS* getResearchCompleteSound() const { return &m_researchSound; }
180181
const AudioEventRTS* getUnitSpecificSound() const { return &m_unitSpecificSound; }
182+
AcademyClassificationType getAcademyClassificationType() const { return m_academyClassificationType; }
181183

182184
/// inventory pictures
183185
void cacheButtonImage();
@@ -207,6 +209,7 @@ class UpgradeTemplate : public MemoryPoolObject
207209
UpgradeMaskType m_upgradeMask; ///< Unique bitmask for this upgrade template
208210
AudioEventRTS m_researchSound; ///< Sound played when upgrade researched.
209211
AudioEventRTS m_unitSpecificSound; ///< Secondary sound played when upgrade researched.
212+
AcademyClassificationType m_academyClassificationType; ///< A value used by the academy to evaluate advice based on what players do.
210213

211214
UpgradeTemplate *m_next; ///< next
212215
UpgradeTemplate *m_prev; ///< prev

Generals/Code/GameEngine/Source/Common/RTS/ActionManager.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Bool ActionManager::canGetRepairedAt( const Object *obj, const Object *repairDes
173173
{
174174
// aircraft require an airfield.
175175
if( !obj->isAboveTerrain() ||
176-
repairDest->isKindOf( KINDOF_AIRFIELD ) == FALSE )
176+
repairDest->isKindOf( KINDOF_FS_AIRFIELD ) == FALSE )
177177
return FALSE;
178178
}
179179
else
@@ -577,7 +577,7 @@ Bool ActionManager::canEnterObject( const Object *obj, const Object *objectToEnt
577577
}
578578

579579
// Special case for aircraft.
580-
if( obj->isKindOf( KINDOF_AIRCRAFT ) && objectToEnter->isKindOf( KINDOF_AIRFIELD ) )
580+
if( obj->isKindOf( KINDOF_AIRCRAFT ) && objectToEnter->isKindOf( KINDOF_FS_AIRFIELD ) )
581581
{
582582
if (!obj->isAboveTerrain())
583583
return FALSE;

0 commit comments

Comments
 (0)