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): refuse production from an unfinished or sold factory

Olcay Seygancca68457dded
diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp b/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp
index 5ca2804fc..1786fcfb5 100644
--- a/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/Common/System/BuildAssistant.cpp
@@ -1310,6 +1310,14 @@ CanMakeType BuildAssistant::canMakeUnit( Object *builder, const ThingTemplate *w
if (builder->testScriptStatusBit(OBJECT_STATUS_SCRIPT_DISABLED) || builder->testScriptStatusBit(OBJECT_STATUS_SCRIPT_UNPOWERED))
return CANMAKE_FACTORY_IS_DISABLED;
+ //
+ // a factory that is not finished (or is on its way out) takes no production. The single
+ // select UI never offers the build buttons for one, but a multi select can hold a mix of
+ // finished and unfinished factories and the build has to skip the unfinished ones
+ //
+ if (builder->testStatus(OBJECT_STATUS_UNDER_CONSTRUCTION) || builder->testStatus(OBJECT_STATUS_SOLD))
+ return CANMAKE_FACTORY_IS_DISABLED;
+
ProductionUpdateInterface* pu = builder->getProductionUpdateInterface();
//If our builder is actually constructing an object via a special power, then allow it if the templates match.