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.
C++ cmakecnccommand-and-conquercppdirectx11game-enginegame-preservationgeneralsrtssage-enginex64zero-hour
fix(gameengine): refuse to refund a production batch that has started
Olcay Seygan4f8bda9eab14
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 100464624..7912c6fa6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -285,6 +285,7 @@ found and fixed — EA's own, not port damage.**- 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.+- Cancelling an order of Red Guard after the first soldier has walked out no longer refunds the order. One order is two soldiers for one price, and the refund came back whole, so the first one was free.- 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.- A supply upgrade pays for what arrives. The bonus was a flat sum handed over on arrival, so a truck turning up with one box collected the same as a full load - and a driver dropping off little and often earned several times what the upgrade is worth.diff --git a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ProductionUpdate.h b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ProductionUpdate.hindex bd05b4cc7..e71e46ac8 100644--- a/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ProductionUpdate.h+++ b/GeneralsMD/Code/GameEngine/Include/GameLogic/Module/ProductionUpdate.h@@ -162,7 +162,7 @@ public:virtual Int getQuantityPerOrder( const ThingTemplate *unitType ) const = 0;virtual Bool queueCreateUnit( const ThingTemplate *unitType, ProductionID productionID ) = 0;- virtual void cancelUnitCreate( ProductionID productionID ) = 0;+ virtual Bool cancelUnitCreate( ProductionID productionID ) = 0;virtual void cancelAllUnitsOfType( const ThingTemplate *unitType) = 0;virtual void cancelAndRefundAllProduction( void ) = 0;@@ -220,7 +220,7 @@ public:virtual Int getQuantityPerOrder( const ThingTemplate *unitType ) const; ///< units one paid order hands back, from QuantityModifiervirtual Bool queueCreateUnit( const ThingTemplate *unitType, ProductionID productionID ); ///< queue unit to be produced- virtual void cancelUnitCreate( ProductionID productionID ); ///< cancel construction of unit with matching production ID+ virtual Bool cancelUnitCreate( ProductionID productionID ); ///< cancel construction of unit with matching production IDvirtual void cancelAllUnitsOfType( const ThingTemplate *unitType); ///< cancel all production of type unitTypevirtual void cancelAndRefundAllProduction( void ); ///< cancel and refund anything in the production queuediff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cppindex b129e6d51..1cee65774 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ProductionUpdate.cpp@@ -475,9 +475,10 @@ Bool ProductionUpdate::queueCreateUnit( const ThingTemplate *unitType, Productio} // end queueMakeUnit//--------------------------------------------------------------------------------------------------/** Cancel the construction of the unit with the matching production ID */+/** Cancel the construction of the unit with the matching production ID. Returns FALSE when there+ * is nothing to cancel, or the entry has already put units on the field. *///--------------------------------------------------------------------------------------------------void ProductionUpdate::cancelUnitCreate( ProductionID productionID )+Bool ProductionUpdate::cancelUnitCreate( ProductionID productionID ){// search for the production entry in our queue@@ -492,6 +493,11 @@ void ProductionUpdate::cancelUnitCreate( ProductionID productionID )if( production->m_type == PRODUCTION_UNIT && production->m_productionID == productionID ){+ // One order of Red Guard is two soldiers for one price. Cancelling after the first had+ // walked out refunded the whole order, so the first soldier was free.+ if( production->getProductionQuantityRemaining() < production->getProductionQuantity() )+ return FALSE;+// give the player the cost of the object backPlayer *player = getObject()->getControllingPlayer();Money *money = player->getMoney();@@ -503,12 +509,14 @@ void ProductionUpdate::cancelUnitCreate( ProductionID productionID )// delete the production entryproduction->deleteInstance();- return;+ return TRUE;} // end if} // end for+ return FALSE;+} // end cancelUnitCreate//-------------------------------------------------------------------------------------------------@@ -784,9 +792,9 @@ UpdateSleepTime ProductionUpdate::update( void )if (!production->getProductionObject()->isKindOf(KINDOF_DOZER)){- cancelUnitCreate(production->getProductionID());- return UPDATE_SLEEP_NONE;-+ if( cancelUnitCreate(production->getProductionID()) )+ return UPDATE_SLEEP_NONE;+} // end if} // end if@@ -1246,7 +1254,14 @@ void ProductionUpdate::cancelAndRefundAllProduction( void )ProductionEntry *head = m_productionQueue;if( head->getProductionType() == PRODUCTION_UNIT )- cancelUnitCreate( head->getProductionID() );+ {+ // a batch already under way is not refunded, but it still leaves the queue+ if( !cancelUnitCreate( head->getProductionID() ) )+ {+ removeFromProductionQueue( head );+ head->deleteInstance();+ }+ }else if( head->getProductionType() == PRODUCTION_UPGRADE )cancelUpgrade( head->getProductionUpgrade() );else