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): a superweapon under construction is not ready yet

Olcay Seygan42b72dff6db6
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
index ce7f5dde6..9a94eb2d3 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp
@@ -1329,6 +1329,11 @@ CommandAvailability ControlBar::getCommandAvailability( const CommandButton *com
// forgot to put it in the object
DEBUG_CRASH(( "Object %s does not contain special power module (%s) to execute. Did you forget to add it to the object INI?\n",
obj->getTemplate()->getName().str(), command->getSpecialPowerTemplate()->getName().str() ));
+
+ // ...and in a release build that assert is nothing, so control used to fall out of
+ // this chain and report the button as available - a power the object cannot even
+ // perform was drawn ready to fire. There is nothing behind it, so hide it.
+ return COMMAND_HIDDEN;
}
else if( mod->isReady() == FALSE )
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp
index b1220f83c..a4420a0ad 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/SpecialPower/SpecialPowerModule.cpp
@@ -299,6 +299,13 @@ Bool SpecialPowerModule::isReady() const
if ( obj && modData )
{
+ // The constructor only starts the recharge for an object that is already built, so a
+ // superweapon still going up has m_availableOnFrame == 0 and used to report itself ready
+ // for the whole build: the button drew as available with no clock, and the structure
+ // snapped out of its ready pose the moment construction finished and the timer started.
+ if ( obj->getStatusBits().test( OBJECT_STATUS_UNDER_CONSTRUCTION ) )
+ return FALSE;
+
Player *player = getObject()->getControllingPlayer();
if ( player )
{