Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gamelogic): seven units and weapons that did the wrong thing

Olcay Seyganc8f191f90006
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5acaa8169..dbb5a7292 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -211,6 +211,16 @@ found and fixed — EA's own, not port damage.**
- Fanaticism works without nationalism being bought first.
- Two battle plans stack properly, and plans move with a captured strategy center.
+## Weapons and units that were quietly wrong
+
+- A bunker buster shot down on the way in no longer clears out the building it was aimed at. It emptied the bunker from wherever it happened to be destroyed - a Point Defence Laser did not save you, it just moved the explosion.
+- A Battle Bus in its wrecked form takes attack orders again. Every order you gave it was dropped on the way, because the crew inside are 'held' and held units were skipped.
+- A sniper cannot pick at an empty Stinger Site. The rule that stops snipers hurting empty buildings only counted passengers, and a Stinger Site's men are spawned, not carried.
+- A booby trap shot off a building, or sold with it, releases the building. The mark was only ever cleared when the trap went off, so the building stayed marked for the rest of the match and no second trap could be laid.
+- Something flagged unselectable is unselectable. The flag existed and nothing read it.
+- Double-clicking to grab everything of a kind grabs what a box would, not things you can only click one at a time.
+- A bounty pays what the percentage says. Rounding up a fraction that was already a whole number paid a dollar extra on every kill.
+
## One crate, one collector
- A crate pays once per frame, not once per soldier who touched it.
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpawnBehavior.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpawnBehavior.h
index d6666a61c..ece17bea5 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpawnBehavior.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/SpawnBehavior.h
@@ -128,6 +128,7 @@ public:
virtual Bool areAllSlavesStealthed() const = 0;
virtual void revealSlaves() = 0;
virtual Bool doSlavesHaveFreedom() const = 0;
+ virtual Int getSlaveCount() const = 0;
};
// ------------------------------------------------------------------------------------------------
@@ -183,6 +184,7 @@ public:
virtual Bool areAllSlavesStealthed() const;
virtual void revealSlaves();
virtual Bool doSlavesHaveFreedom() const { return getSpawnBehaviorModuleData()->m_slavesHaveFreeWill; }
+ virtual Int getSlaveCount() const { return m_spawnCount; }
// **********************************************************************************************
// our own methods
diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/StickyBombUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/StickyBombUpdate.h
index e9bfa2194..e5f6434ea 100644
--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/StickyBombUpdate.h
+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/StickyBombUpdate.h
@@ -82,6 +82,7 @@ public:
// virtual destructor prototype provided by memory pool declaration
virtual void onObjectCreated();
+ virtual void onDelete(); ///< this module is going away
virtual UpdateSleepTime update(); ///< called once per frame
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
index fdb20b40b..501379f95 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/Player.cpp
@@ -2460,7 +2460,10 @@ void Player::doBountyForKill(const Object* killer, const Object* victim)
return;
Int costToBuild = victim->getTemplate()->calcCostToBuild(victim->getControllingPlayer());
- Int bounty = REAL_TO_INT_CEIL(costToBuild * m_cashBountyPercent);
+ // Rounding up a product of two floats hands you an extra dollar whenever the multiplication
+ // lands a hair above a whole number - a 10% bounty on a 1000 cost unit paid 101. Take an
+ // epsilon off first, so only a genuine fraction rounds up.
+ Int bounty = REAL_TO_INT_CEIL((costToBuild * m_cashBountyPercent) - WWMATH_EPSILON);
if( bounty )
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
index e98bdc9e5..6745f19a5 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
@@ -533,8 +533,10 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
selectMore->appendBooleanArgument(FALSE);
for (DrawableListIt it = listOfSelectedDrawables.begin(); it != listOfSelectedDrawables.end(); ++it) {
Drawable *draw = *it;
- // buildings and units stay in separate selections
- if (draw && draw->isSelectable() && draw->isKindOf( KINDOF_STRUCTURE ) == picked->isKindOf( KINDOF_STRUCTURE )) {
+ // buildings and units stay in separate selections, and a double click that
+ // gathers everything of a kind may only gather what a box would - things
+ // you can click one at a time but never sweep up used to come along
+ if (draw && draw->isMassSelectable() && draw->isKindOf( KINDOF_STRUCTURE ) == picked->isKindOf( KINDOF_STRUCTURE )) {
TheInGameUI->selectDrawable(draw);
selectMore->appendObjectIDArgument(draw->getObject()->getID());
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp
index 46ab63934..24c3e3b30 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIGroup.cpp
@@ -2162,10 +2162,9 @@ void AIGroup::groupAttackObjectPrivate( Bool forced, Object *victim, Int maxShot
for( i = m_memberList.begin(); i != m_memberList.end(); ++i ) {
Real dx, dy;
Coord3D unitPos = *((*i)->getPosition());
- if ((*i)->isDisabledByType( DISABLED_HELD ) )
- {
- continue; // don't bother telling the occupants to move.
- }
+ // Held units were skipped here on the grounds that there is no point telling a passenger to
+ // walk somewhere - but this is the attack order, not a move, and a unit that is held can
+ // still shoot. A bunkered Battle Bus ignored every attack you gave it.
dx = unitPos.x - victimPos.x;
dy = unitPos.y - victimPos.y;
iter->insert((*i), dx*dx+dy*dy);
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/BunkerBusterBehavior.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/BunkerBusterBehavior.cpp
index f6dba4a4a..ea247621f 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/BunkerBusterBehavior.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Behavior/BunkerBusterBehavior.cpp
@@ -170,6 +170,12 @@ UpdateSleepTime BunkerBusterBehavior::update( void )
// ------------------------------------------------------------------------------------------------
void BunkerBusterBehavior::onDie( const DamageInfo *damageInfo )
{
+ // Only bust the bunker if the missile got there. This fires on any death, so a bunker buster
+ // shot down on the way in - by a Point Defence Laser, say - still cleared out the building it
+ // was aimed at, from wherever it happened to be destroyed.
+ if( !getObject()->testStatus( OBJECT_STATUS_MISSILE_KILLING_SELF ) )
+ return;
+
// do what we came here to do!
bustTheBunker();
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
index 2ac84da1f..cdbebd22b 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Object.cpp
@@ -3050,9 +3050,13 @@ Bool Object::isSelectable() const
return TRUE;
if ( m_isSelectable )
- if ( !testStatus(OBJECT_STATUS_UNSELECTABLE) )
+ if ( !testStatus(OBJECT_STATUS_UNSELECTABLE) )
if ( !isEffectivelyDead() )
- //if ( !getTemplate()->isKindOf(KINDOF_DRONE) )//Most drones are unselectable from being slaved, but the SpyDrone needs help
+ // KINDOF_NO_SELECT says a thing may not be selected, and nothing read it here - so
+ // the flag did nothing and the only way to make something unselectable was to be a
+ // drone. (That is the test this replaces; it was commented out because it caught
+ // the spy drone, which is meant to be selectable.)
+ if ( !getTemplate()->isKindOf(KINDOF_NO_SELECT) )
return TRUE;
return FALSE;
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp
index e3fe0ab8c..3ed296bdf 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/StickyBombUpdate.cpp
@@ -285,6 +285,21 @@ void StickyBombUpdate::detonate()
getObject()->kill();// Most things just fire weapons in their death modules
}
+// ------------------------------------------------------------------------------------------------
+/** The trap is going away without going off - shot off the building, or the building sold. The
+ * status it set on its victim is cleared when it detonates and nowhere else, so the building
+ * stayed marked as trapped for the rest of the match and no second trap could be laid on it. */
+// ------------------------------------------------------------------------------------------------
+void StickyBombUpdate::onDelete()
+{
+ if( getObject()->isKindOf( KINDOF_BOOBY_TRAP ) )
+ {
+ Object *boobyTrappedObject = getTargetObject();
+ if( boobyTrappedObject )
+ boobyTrappedObject->clearStatus( MAKE_OBJECT_STATUS_MASK(OBJECT_STATUS_BOOBY_TRAPPED) );
+ }
+}
+
// ------------------------------------------------------------------------------------------------
/** CRC */
// ------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
index ed384693a..b4d60fe9e 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Weapon.cpp
@@ -62,6 +62,7 @@
#include "GameLogic/Module/BehaviorModule.h"
#include "GameLogic/Module/BodyModule.h"
#include "GameLogic/Module/ContainModule.h"
+#include "GameLogic/Module/SpawnBehavior.h"
#include "GameLogic/Module/LaserUpdate.h"
#include "GameLogic/Module/UpdateModule.h"
#include "GameLogic/Module/SpecialPowerCompletionDie.h"
@@ -599,13 +600,16 @@ Real WeaponTemplate::estimateWeaponTemplateDamage(
// hmm.. must be shooting a firebase or such, if there is noone home to take the bullet, return 0!
+ // The test only looked at passengers, and a Stinger Site's men are not passengers - they are
+ // spawned slaves - so a Stinger Site with nobody left in it still took sniper fire, which is the
+ // one building a sniper has no business hurting.
if ( victimObj->isKindOf( KINDOF_STRUCTURE) && damageType == DAMAGE_SNIPER )
{
- if ( victimObj->getContain() )
- {
- if ( victimObj->getContain()->getContainCount() == 0 )
- return 0.0f;
- }
+ const Bool hasOccupants = victimObj->getContain() && victimObj->getContain()->getContainCount() > 0;
+ const Bool hasSlaves = victimObj->getSpawnBehaviorInterface() && victimObj->getSpawnBehaviorInterface()->getSlaveCount() > 0;
+
+ if ( !hasOccupants && !hasSlaves )
+ return 0.0f;
}