Skip to content

Commit aaa53e1

Browse files
committed
unify(module): Merge HordeUpdate and related code
1 parent 0bb57b2 commit aaa53e1

File tree

9 files changed

+109
-18
lines changed

9 files changed

+109
-18
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,16 @@ enum TerrainDecalType CPP_11(: Int)
261261
TERRAIN_DECAL_HORDE_VEHICLE,
262262
TERRAIN_DECAL_HORDE_WITH_NATIONALISM_UPGRADE_VEHICLE,
263263
TERRAIN_DECAL_CRATE,
264+
#if RTS_GENERALS && RETAIL_COMPATIBLE_XFER_SAVE
264265
TERRAIN_DECAL_NONE,
266+
TERRAIN_DECAL_HORDE_WITH_FANATICISM_UPGRADE,
267+
TERRAIN_DECAL_CHEMSUIT,
268+
#else
269+
TERRAIN_DECAL_HORDE_WITH_FANATICISM_UPGRADE,
270+
TERRAIN_DECAL_CHEMSUIT,
271+
TERRAIN_DECAL_NONE,
272+
#endif
273+
TERRAIN_DECAL_SHADOW_TEXTURE, //use the shadow texture as the terrain decal.
265274

266275
TERRAIN_DECAL_MAX
267276
};

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class HordeUpdateModuleData : public ModuleData
6969
Bool m_exactMatch; ///< if true, only exact same type of units count towards hordeness
7070
Real m_rubOffRadius;///< If I am this close to another guy who is a true hordesman, it'll rub off on me
7171
HordeActionType m_action; ///< what to do if we get horde-ness
72+
Bool m_allowedNationalism; ///< Nationalism is hard ocded. Yeah! Add to the goodness with this flag instead of rewriting after Alpha.
7273
std::vector<AsciiString> m_flagSubObjNames; ///< name(s) of the flag subobj
7374

7475
HordeUpdateModuleData();
@@ -85,6 +86,7 @@ class HordeUpdateInterface
8586
virtual Bool isInHorde() const = 0;
8687
virtual Bool hasFlag() const = 0;
8788
virtual Bool isTrueHordeMember() const = 0;
89+
virtual Bool isAllowedNationalism() const = 0;
8890

8991
};
9092

@@ -104,6 +106,7 @@ class HordeUpdate : public UpdateModule, public HordeUpdateInterface
104106
virtual void onDrawableBoundToObject();
105107
virtual Bool isInHorde() const { return m_inHorde; }
106108
virtual Bool isTrueHordeMember() const { return m_trueHordeMember && m_inHorde; }
109+
virtual Bool isAllowedNationalism() const;
107110
virtual Bool hasFlag() const { return m_hasFlag; }
108111
virtual UpdateSleepTime update(); ///< update this object's AI
109112

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,11 @@ enum WeaponBonusConditionType CPP_11(: Int)
201201
WEAPONBONUSCONDITION_SOLO_AI_EASY,
202202
WEAPONBONUSCONDITION_SOLO_AI_NORMAL,
203203
WEAPONBONUSCONDITION_SOLO_AI_HARD,
204+
WEAPONBONUSCONDITION_TARGET_FAERIE_FIRE,
205+
WEAPONBONUSCONDITION_FANATICISM, // FOR THE NEW GC INFANTRY GENERAL... adds to nationalism
206+
WEAPONBONUSCONDITION_FRENZY_ONE,
207+
WEAPONBONUSCONDITION_FRENZY_TWO,
208+
WEAPONBONUSCONDITION_FRENZY_THREE,
204209

205210
WEAPONBONUSCONDITION_COUNT
206211
};
@@ -234,6 +239,12 @@ static const char *const TheWeaponBonusNames[] =
234239
"SOLO_AI_EASY",
235240
"SOLO_AI_NORMAL",
236241
"SOLO_AI_HARD",
242+
"TARGET_FAERIE_FIRE",
243+
"FANATICISM", // FOR THE NEW GC INFANTRY GENERAL... adds to nationalism
244+
"FRENZY_ONE",
245+
"FRENZY_TWO",
246+
"FRENZY_THREE",
247+
237248
NULL
238249
};
239250
static_assert(ARRAY_SIZE(TheWeaponBonusNames) == WEAPONBONUSCONDITION_COUNT + 1, "Incorrect array size");

Generals/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4434,6 +4434,27 @@ void AIUpdateInterface::evaluateMoraleBonus( void )
44344434
#endif
44354435
Bool horde = FALSE;
44364436
Bool nationalism = FALSE;
4437+
Bool fanaticism = FALSE;
4438+
4439+
Player *player = us->getControllingPlayer();
4440+
4441+
// do we have nationalism
4442+
///@todo Find a better way to represent nationalism without hardcoding here (CBD)
4443+
static const UpgradeTemplate *nationalismTemplate = TheUpgradeCenter->findUpgrade( "Upgrade_Nationalism" );
4444+
if (nationalismTemplate != NULL)
4445+
{
4446+
if( player && player->hasUpgradeComplete( nationalismTemplate ) )
4447+
nationalism = TRUE;
4448+
}
4449+
4450+
// do we have fanaticism
4451+
///@todo Find a better way to represent fanaticism without hardcoding here (MAL)
4452+
static const UpgradeTemplate *fanaticismTemplate = TheUpgradeCenter->findUpgrade( "Upgrade_Fanaticism" );
4453+
if (fanaticismTemplate != NULL)
4454+
{
4455+
if( player && player->hasUpgradeComplete( fanaticismTemplate ) )
4456+
fanaticism = TRUE;
4457+
}
44374458

44384459
// are we in a horde
44394460
HordeUpdateInterface *hui;
@@ -4442,17 +4463,18 @@ void AIUpdateInterface::evaluateMoraleBonus( void )
44424463

44434464
hui = (*u)->getHordeUpdateInterface();
44444465
if( hui && hui->isInHorde() )
4466+
{
44454467
horde = TRUE;
44464468

4447-
}
4469+
if( !hui->isAllowedNationalism() )
4470+
{
4471+
// Sorry CBD and MAL, but the cancer has spread to the lymph nodes. After Alpha, just pump full of painkillers.
4472+
nationalism = FALSE;
4473+
fanaticism = FALSE;
4474+
}
4475+
}
44484476

4449-
// do we have nationalism
4450-
///@todo Find a better way to represent nationalism without hardcoding here (CBD)
4451-
static const UpgradeTemplate *nationalismTemplate = TheUpgradeCenter->findUpgrade( "Upgrade_Nationalism" );
4452-
DEBUG_ASSERTCRASH( nationalismTemplate != NULL, ("AIUpdateInterface::evaluateMoraleBonus - Nationalism upgrade not found") );
4453-
Player *player = us->getControllingPlayer();
4454-
if( player && player->hasUpgradeComplete( nationalismTemplate ) )
4455-
nationalism = TRUE;
4477+
}
44564478

44574479
#ifdef ALLOW_DEMORALIZE
44584480
// if we are are not demoralized we can have horde and nationalism effects
@@ -4481,10 +4503,19 @@ void AIUpdateInterface::evaluateMoraleBonus( void )
44814503

44824504
// nationalism
44834505
if( nationalism )
4506+
{
44844507
us->setWeaponBonusCondition( WEAPONBONUSCONDITION_NATIONALISM );
4508+
// fanaticism
4509+
if ( fanaticism )
4510+
us->setWeaponBonusCondition( WEAPONBONUSCONDITION_FANATICISM );// FOR THE NEW GC INFANTRY GENERAL
4511+
else
4512+
us->clearWeaponBonusCondition( WEAPONBONUSCONDITION_FANATICISM );
4513+
}
44854514
else
44864515
us->clearWeaponBonusCondition( WEAPONBONUSCONDITION_NATIONALISM );
44874516

4517+
4518+
44884519
}
44894520
#ifdef ALLOW_DEMORALIZE
44904521
else
@@ -4503,6 +4534,7 @@ void AIUpdateInterface::evaluateMoraleBonus( void )
45034534

45044535
// we cannot have nationalism bonus condition
45054536
us->clearWeaponBonusCondition( WEAPONBONUSCONDITION_NATIONALISM );
4537+
us->clearWeaponBonusCondition( WEAPONBONUSCONDITION_FANATICISM );
45064538

45074539
}
45084540
#endif

Generals/Code/GameEngine/Source/GameLogic/Object/Update/HordeUpdate.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ HordeUpdateModuleData::HordeUpdateModuleData() :
120120
m_rubOffRadius(20.0f),
121121
m_alliesOnly(true),
122122
m_exactMatch(false),
123+
m_allowedNationalism(TRUE),
123124
m_action(HORDEACTION_HORDE)
124125
{
125126
}
@@ -140,6 +141,7 @@ HordeUpdateModuleData::HordeUpdateModuleData() :
140141
{ "ExactMatch", INI::parseBool, NULL, offsetof(HordeUpdateModuleData, m_exactMatch) },
141142
{ "Action", INI::parseIndexList, TheHordeActionTypeNames, offsetof(HordeUpdateModuleData, m_action) },
142143
{ "FlagSubObjectNames", INI::parseAsciiStringVector, NULL, offsetof(HordeUpdateModuleData, m_flagSubObjNames) },
144+
{ "AllowedNationalism", INI::parseBool, NULL, offsetof(HordeUpdateModuleData, m_allowedNationalism) },
143145
{ 0, 0, 0, 0 }
144146
};
145147
p.add(dataFieldParse);
@@ -170,6 +172,13 @@ HordeUpdate::~HordeUpdate()
170172

171173
}
172174

175+
//-------------------------------------------------------------------------------------------------
176+
Bool HordeUpdate::isAllowedNationalism() const
177+
{
178+
const HordeUpdateModuleData *data = getHordeUpdateModuleData();
179+
return data->m_allowedNationalism;
180+
}
181+
173182
//-------------------------------------------------------------------------------------------------
174183
/** @todo I think we should model the horde list ... so we can do all this without doing
175184
* all this scanning, plus we can give exactly 1 flag to the right person in the

Generals/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ inline Bool isCommonMaintainFrameFlagSet(Int a, Int b)
266266
// Note: these values are saved in save files, so you MUST NOT REMOVE OR CHANGE
267267
// existing values!
268268
//
269-
static const char *TerrainDecalTextureName[TERRAIN_DECAL_MAX-1]=
269+
static const char *TerrainDecalTextureName[TERRAIN_DECAL_MAX]=
270270
{
271271
#ifdef ALLOW_DEMORALIZE
272272
"DM_RING",//demoralized
@@ -278,6 +278,16 @@ static const char *TerrainDecalTextureName[TERRAIN_DECAL_MAX-1]=
278278
"EXHordeB",//enthusiastic vehicle
279279
"EXHordeB_UP", //enthusiastic vehicle with nationalism
280280
"EXJunkCrate",//Marks a crate as special
281+
#if RTS_GENERALS && RETAIL_COMPATIBLE_XFER_SAVE
282+
"", //dummy entry for TERRAIN_DECAL_NONE
283+
"EXHordeC_UP", //enthusiastic with fanaticism
284+
"EXChemSuit", //Marks a unit as having chemical suit on
285+
#else
286+
"EXHordeC_UP", //enthusiastic with fanaticism
287+
"EXChemSuit", //Marks a unit as having chemical suit on
288+
"", //dummy entry for TERRAIN_DECAL_NONE
289+
#endif
290+
"" //dummy entry for TERRAIN_DECAL_SHADOW_TEXTURE
281291
};
282292

283293
const UnsignedInt NO_NEXT_DURATION = 0xffffffff;

GeneralsMD/Code/GameEngine/Include/GameClient/Drawable.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,15 @@ enum TerrainDecalType CPP_11(: Int)
266266
TERRAIN_DECAL_HORDE_VEHICLE,
267267
TERRAIN_DECAL_HORDE_WITH_NATIONALISM_UPGRADE_VEHICLE,
268268
TERRAIN_DECAL_CRATE,
269-
TERRAIN_DECAL_HORDE_WITH_FANATICISM_UPGRADE,
269+
#if RTS_GENERALS && RETAIL_COMPATIBLE_XFER_SAVE
270+
TERRAIN_DECAL_NONE,
271+
TERRAIN_DECAL_HORDE_WITH_FANATICISM_UPGRADE,
272+
TERRAIN_DECAL_CHEMSUIT,
273+
#else
274+
TERRAIN_DECAL_HORDE_WITH_FANATICISM_UPGRADE,
270275
TERRAIN_DECAL_CHEMSUIT,
271276
TERRAIN_DECAL_NONE,
277+
#endif
272278
TERRAIN_DECAL_SHADOW_TEXTURE, //use the shadow texture as the terrain decal.
273279

274280
TERRAIN_DECAL_MAX

GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4688,20 +4688,25 @@ void AIUpdateInterface::evaluateMoraleBonus( void )
46884688
Bool nationalism = FALSE;
46894689
Bool fanaticism = FALSE;
46904690

4691+
Player *player = us->getControllingPlayer();
4692+
46914693
// do we have nationalism
46924694
///@todo Find a better way to represent nationalism without hardcoding here (CBD)
46934695
static const UpgradeTemplate *nationalismTemplate = TheUpgradeCenter->findUpgrade( "Upgrade_Nationalism" );
4694-
DEBUG_ASSERTCRASH( nationalismTemplate != NULL, ("AIUpdateInterface::evaluateMoraleBonus - Nationalism upgrade not found") );
4695-
Player *player = us->getControllingPlayer();
4696-
if( player && player->hasUpgradeComplete( nationalismTemplate ) )
4697-
nationalism = TRUE;
4696+
if (nationalismTemplate != NULL)
4697+
{
4698+
if( player && player->hasUpgradeComplete( nationalismTemplate ) )
4699+
nationalism = TRUE;
4700+
}
46984701

46994702
// do we have fanaticism
47004703
///@todo Find a better way to represent fanaticism without hardcoding here (MAL)
47014704
static const UpgradeTemplate *fanaticismTemplate = TheUpgradeCenter->findUpgrade( "Upgrade_Fanaticism" );
4702-
DEBUG_ASSERTCRASH( fanaticismTemplate != NULL, ("AIUpdateInterface::evaluateMoraleBonus - Fanaticism upgrade not found") );
4703-
if( player && player->hasUpgradeComplete( fanaticismTemplate ) )
4704-
fanaticism = TRUE;
4705+
if (fanaticismTemplate != NULL)
4706+
{
4707+
if( player && player->hasUpgradeComplete( fanaticismTemplate ) )
4708+
fanaticism = TRUE;
4709+
}
47054710

47064711
// are we in a horde
47074712
HordeUpdateInterface *hui;

GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,9 +278,15 @@ static const char *TerrainDecalTextureName[TERRAIN_DECAL_MAX]=
278278
"EXHordeB",//enthusiastic vehicle
279279
"EXHordeB_UP", //enthusiastic vehicle with nationalism
280280
"EXJunkCrate",//Marks a crate as special
281+
#if RTS_GENERALS && RETAIL_COMPATIBLE_XFER_SAVE
282+
"", //dummy entry for TERRAIN_DECAL_NONE
281283
"EXHordeC_UP", //enthusiastic with fanaticism
282284
"EXChemSuit", //Marks a unit as having chemical suit on
283-
"", //dummy entry for TERRAIN_DECAL_NONE
285+
#else
286+
"EXHordeC_UP", //enthusiastic with fanaticism
287+
"EXChemSuit", //Marks a unit as having chemical suit on
288+
"", //dummy entry for TERRAIN_DECAL_NONE
289+
#endif
284290
"" //dummy entry for TERRAIN_DECAL_SHADOW_TEXTURE
285291
};
286292

0 commit comments

Comments
 (0)