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(gameengine): four more from the upstream ledger

Olcay Seygan09bf69f52778
diff --git a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
index fc92789ef..5a426cdde 100644
--- a/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
+++ b/GeneralsMD/Code/GameEngine/Include/Common/MessageStream.h
@@ -476,7 +476,8 @@ public:
MSG_MOUSEOVER_LOCATION_HINT, ///< (location) The cursor is not over a drawable, but is here.
MSG_VALID_GUICOMMAND_HINT, ///< posted when the gui command is valid if the user clicked to execute it.
MSG_INVALID_GUICOMMAND_HINT, ///< posted when the gui command is not valid if the user were to click to attempt to execute it.
- MSG_AREA_SELECTION_HINT, ///< (pixelRegion) rectangular selection area under construction, not confirmed
+ MSG_BEGIN_AREA_SELECTION_HINT, ///< (pixelRegion) rectangular selection area under construction, not confirmed
+ MSG_END_AREA_SELECTION_HINT, ///< (pixelRegion) that rectangle is finished
//Command hints
MSG_DO_ATTACK_OBJECT_HINT, ///< (victim objectID) If clicked, an attack would be ordered, "Current Selection" is assumed
@@ -594,7 +595,7 @@ public:
MSG_EXECUTE_RAILED_TRANSPORT, ///< Execute railed transport sequence
MSG_COMBATDROP_AT_LOCATION, ///< dump out all rappellers
MSG_COMBATDROP_AT_OBJECT, ///< dump out all rappellers
- MSG_AREA_SELECTION, ///< (pixelRegion) rectangular selection area
+ MSG_AREA_SELECTION_DEPRECATED, ///< was a network message and never needed to be one; the two hints above carry it now
MSG_DO_ATTACK_OBJECT, ///< (objectID, victim objectID)
MSG_DO_FORCE_ATTACK_OBJECT, ///< force attack the given object if picked
MSG_DO_FORCE_ATTACK_GROUND, ///< (locationID) bombard the given location if picked
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
index c0cb42022..de0261da6 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
@@ -573,7 +573,8 @@ AsciiString GameMessage::getCommandTypeAsAsciiString(GameMessage::Type t)
CHECK_IF(MSG_MOUSEOVER_LOCATION_HINT)
CHECK_IF(MSG_VALID_GUICOMMAND_HINT)
CHECK_IF(MSG_INVALID_GUICOMMAND_HINT)
- CHECK_IF(MSG_AREA_SELECTION_HINT)
+ CHECK_IF(MSG_BEGIN_AREA_SELECTION_HINT)
+ CHECK_IF(MSG_END_AREA_SELECTION_HINT)
CHECK_IF(MSG_DO_ATTACK_OBJECT_HINT)
CHECK_IF(MSG_DO_ATTACK_OBJECT_AFTER_MOVING_HINT)
CHECK_IF(MSG_DO_FORCE_ATTACK_OBJECT_HINT)
@@ -659,7 +660,7 @@ AsciiString GameMessage::getCommandTypeAsAsciiString(GameMessage::Type t)
CHECK_IF(MSG_EXECUTE_RAILED_TRANSPORT)
CHECK_IF(MSG_COMBATDROP_AT_LOCATION)
CHECK_IF(MSG_COMBATDROP_AT_OBJECT)
- CHECK_IF(MSG_AREA_SELECTION)
+ CHECK_IF(MSG_AREA_SELECTION_DEPRECATED)
CHECK_IF(MSG_DO_ATTACK_OBJECT)
CHECK_IF(MSG_DO_FORCE_ATTACK_OBJECT)
CHECK_IF(MSG_DO_FORCE_ATTACK_GROUND)
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HintSpy.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HintSpy.cpp
index 331fdfa6b..d1c3d491b 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HintSpy.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/HintSpy.cpp
@@ -100,15 +100,17 @@ GameMessageDisposition HintSpyTranslator::translateGameMessage(const GameMessage
break;
//-----------------------------------------------------------------------------
- case GameMessage::MSG_AREA_SELECTION_HINT:
+ case GameMessage::MSG_BEGIN_AREA_SELECTION_HINT:
TheInGameUI->beginAreaSelectHint( msg );
+ disp = DESTROY_MESSAGE; // a hint about a rectangle on this screen; nobody downstream wants it
break;
//-----------------------------------------------------------------------------
- // An AREA_SELECTION_HINT is always followed by an AREA_SELECTION, so
+ // A BEGIN_AREA_SELECTION_HINT is always followed by an END_AREA_SELECTION_HINT, so
// watch for it to stop hinting.
- case GameMessage::MSG_AREA_SELECTION:
+ case GameMessage::MSG_END_AREA_SELECTION_HINT:
TheInGameUI->endAreaSelectHint( msg );
+ disp = DESTROY_MESSAGE;
break;
//-----------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
index 9a35876da..e5008de30 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/SelectionXlat.cpp
@@ -443,7 +443,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
if (m_dragSelecting)
{
// insert area selection "hint" message into stream
- GameMessage *hintMsg = TheMessageStream->appendMessage( GameMessage::MSG_AREA_SELECTION_HINT );
+ GameMessage *hintMsg = TheMessageStream->appendMessage( GameMessage::MSG_BEGIN_AREA_SELECTION_HINT );
// build rectangular region defined by the drag selection
IRegion2D pixelRegion;
@@ -542,7 +542,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
TheInGameUI->selectMatchingAcrossScreen();
// emit "picked" message
- GameMessage *pickMsg = TheMessageStream->appendMessage( GameMessage::MSG_AREA_SELECTION );
+ GameMessage *pickMsg = TheMessageStream->appendMessage( GameMessage::MSG_END_AREA_SELECTION_HINT );
pickMsg->appendDrawableIDArgument( picked->getID() ); /// note we are putting in a drawable id
if (TheInGameUI->isInPreferSelectionMode() && !listOfSelectedDrawables.empty()) {
@@ -1054,7 +1054,7 @@ GameMessageDisposition SelectionTranslator::translateGameMessage(const GameMessa
TheInGameUI->endAreaSelectHint(NULL);
// insert area selection message into stream
- GameMessage *dragMsg = TheMessageStream->appendMessage( GameMessage::MSG_AREA_SELECTION );
+ GameMessage *dragMsg = TheMessageStream->appendMessage( GameMessage::MSG_END_AREA_SELECTION_HINT );
IRegion2D selectionRegion;
buildRegion( &m_selectFeedbackAnchor, &msg->getArgument(0)->pixel, &selectionRegion );
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp
index 60fa4a1ad..b372f49f2 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp
@@ -367,7 +367,10 @@ void AIPlayer::onStructureProduced( Object *factory, Object *bldg )
Dict d;
d.setAsciiString(TheKey_objectName, info->getBuildingName());
d.setAsciiString(TheKey_objectScriptAttachment, info->getScript());
- d.setInt(TheKey_objectInitialHealth, info->getHealth());
+ // The build list's health is the health the map author wanted the building to start at.
+ // Writing it here, when construction finishes, throws away whatever the scaffold actually
+ // has: a structure shot at while it was going up comes out at full health, and one the map
+ // wanted damaged comes out damaged twice. Whatever the scaffold ended on is what it keeps.
d.setBool(TheKey_objectUnsellable, info->getUnsellable());
info->setUnderConstruction(false);
@@ -733,7 +736,10 @@ Object *AIPlayer::buildStructureNow(const ThingTemplate *bldgPlan, BuildListInfo
Dict d;
d.setAsciiString(TheKey_objectName, info->getBuildingName());
d.setAsciiString(TheKey_objectScriptAttachment, info->getScript());
- d.setInt(TheKey_objectInitialHealth, info->getHealth());
+ // The build list's health is the health the map author wanted the building to start at.
+ // Writing it here, when construction finishes, throws away whatever the scaffold actually
+ // has: a structure shot at while it was going up comes out at full health, and one the map
+ // wanted damaged comes out damaged twice. Whatever the scaffold ended on is what it keeps.
d.setBool(TheKey_objectUnsellable, info->getUnsellable());
bldg->updateObjValuesFromMapProperties(&d);
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
index d05f20634..1d8edc338 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Body/ActiveBody.cpp
@@ -525,9 +525,11 @@ void ActiveBody::attemptDamage( DamageInfo *damageInfo )
if( !canBeSubdued() )
return;
+ // isSubdued now reads the status, which is set below off this very comparison, so the
+ // question "has this new damage crossed the line" has to be the comparison itself.
Bool wasSubdued = isSubdued();
internalAddSubdualDamage(amount);
- Bool nowSubdued = isSubdued();
+ Bool nowSubdued = m_maxHealth <= m_currentSubdualDamage;
alreadyHandled = TRUE;
allowModifier = FALSE;
@@ -1367,7 +1369,12 @@ void ActiveBody::onSubdualChange( Bool isNowSubdued )
//-------------------------------------------------------------------------------------------------
Bool ActiveBody::isSubdued() const
{
- return m_maxHealth <= m_currentSubdualDamage;
+ /* Ask the status, not the arithmetic. This used to compare subdual damage against max health,
+ which is the rule that decides when to subdue in the first place - so anything that moved
+ health across that line while the object was already subdued (a repair, a heal, a max health
+ upgrade) made the answer disagree with the state the object is actually in, and a Battle Bus
+ could be held down forever. */
+ return getObject()->isDisabledByType( DISABLED_SUBDUED );
}
//-------------------------------------------------------------------------------------------------
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
index 09a1f793e..638ed14fc 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AIUpdate.cpp
@@ -5475,10 +5475,18 @@ void AIUpdateInterface::privateExit( Object *objectToExit, CommandSourceType cmd
if (!objectToExit)
{
objectToExit = us->getContainedBy();
- }
- if (!objectToExit)
- return;
+ if (!objectToExit)
+ return;
+ }
+ else
+ {
+ // An object cannot get out of something it is not inside. The order carries a container
+ // with it, and a stale one - the transport it left last, a building it was told to leave
+ // before somebody else pulled it out - used to be obeyed anyway.
+ if (us->getContainedBy() != objectToExit)
+ return;
+ }
if ( objectToExit->isDisabledByType( DISABLED_SUBDUED ) )
return;
@@ -5504,10 +5512,18 @@ void AIUpdateInterface::privateExitInstantly( Object *objectToExit, CommandSourc
if (!objectToExit)
{
objectToExit = us->getContainedBy();
- }
- if (!objectToExit)
- return;
+ if (!objectToExit)
+ return;
+ }
+ else
+ {
+ // An object cannot get out of something it is not inside. The order carries a container
+ // with it, and a stale one - the transport it left last, a building it was told to leave
+ // before somebody else pulled it out - used to be obeyed anyway.
+ if (us->getContainedBy() != objectToExit)
+ return;
+ }
if ( objectToExit->isDisabledByType( DISABLED_SUBDUED ) )
return;