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): keep gatherers off piles beside another player's center
Olcay Seyganf625ff2ebf42
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 2f1c9c907..b6aace6a3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -832,6 +832,7 @@ A third pass went through the generals' powers, promotions and unit abilities.- Supply points refill themselves, slowly, and faster the more of a base has grown around them. A warehouse used to be a fixed lump of money that ran out and left the map with nothing to fight over: whoever mined out the middle first had the game, and the second half of every match was played on income neither side could earn any more. Six hundred dollars comes back every forty seconds standing on its own, every twenty with one supply centre built near it, every thirteen with two - up to what the point started with, never past it. A single box was too little to be worth the trip: a hundred dollars every forty seconds is less than the harvester earns going to fetch it, so a mined-out point stayed mined out as far as anybody playing was concerned. Both sides expanding onto the same patch make it richer and then have to decide which of them keeps it.- Your workers tell you a supply point has run dry once a match. With piles refilling, they ran dry again and again, and every time the same worker said so.- Workers stop hesitating on their way in and out. A dock has a queue outside it and a worker treated its place in that queue as a destination: it drove to the spot, stopped dead, waited a frame, drove to the door, stopped again, and only then went in - twice a load, and nearly every load with nothing else queued. With the dock empty it drives straight in. The first version of that also skipped the walk to a supply pile or a GLA stash, which have no door of their own, so a worker a long way off played its loading animation where it stood and was paid anyway. In a four-player test match 72 loads were picked up or dropped off away from the dock, one of them 613 feet from it; now there are none.+- Workers leave other players' supply piles alone. A truck whose pile ran dry went to the nearest pile it could reach, and that was often the one next to a neighbour's supply centre, where it either stood in his queue or stood idle beside the pile with nowhere of its own to carry the boxes. A pile now belongs to whoever has the closest supply centre beside it, and your trucks, Chinooks and workers only pick their own or a free one. The computer counts those piles out too, so it no longer buys trucks for a neighbour's supplies. Across two 4v4 matches on Twilight Flame, trucks were sent to someone else's pile 109 times; now none are, and the money mined stayed within about one percent. A truck you send to a pile yourself still goes where you sent it.- Hackers show how far off the next payout is. So do the black market and the oil derricks.- A hacker already at work stays at work when you tell a group of hackers to hack. It used to fold its laptop away and set it up again, and the payout it was halfway to started over from nothing. One that is packing up takes the order and unpacks again. Replays recorded before this change play out differently.- A hacker working from inside an Internet Center shows what it earns. The green figure floats over the building on every payout, the way it does over one sitting in the field. It never appeared, because the game asked the hacker whether it could be seen and a garrisoned unit is not drawn at all - which is the one place a hacker is meant to work.diff --git a/GeneralsMD/Code/GameEngine/Include/Common/ResourceGatheringManager.h b/GeneralsMD/Code/GameEngine/Include/Common/ResourceGatheringManager.hindex 0bdeab25c..cafabfee4 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/ResourceGatheringManager.h+++ b/GeneralsMD/Code/GameEngine/Include/Common/ResourceGatheringManager.h@@ -38,6 +38,7 @@#include "Common/Snapshot.h"class Object;+class Player;// ------------------------------------------------------------------------------------------------class ResourceGatheringManager : public MemoryPoolObject,@@ -59,6 +60,8 @@ public:Bool claimSuppliesDepletedVoice(); ///< TRUE only the first time a gatherer asks, so the depleted voice plays once a game+ static Bool isPileOfAnotherPlayer( const Player *player, const Object *warehouse ); ///< Is the supply center nearest this pile someone else's?+protected:Object *findBestSupplyCenterInList(Object *queryObject);diff --git a/GeneralsMD/Code/GameEngine/Source/Common/RTS/ResourceGatheringManager.cpp b/GeneralsMD/Code/GameEngine/Source/Common/RTS/ResourceGatheringManager.cppindex 334366970..b48698443 100644--- a/GeneralsMD/Code/GameEngine/Source/Common/RTS/ResourceGatheringManager.cpp+++ b/GeneralsMD/Code/GameEngine/Source/Common/RTS/ResourceGatheringManager.cpp@@ -33,6 +33,7 @@#include "Common/ResourceGatheringManager.h"#include "Common/ActionManager.h"+#include "Common/PlayerList.h"#include "Common/Xfer.h"#include "GameLogic/GameLogic.h"#include "GameLogic/Object.h"@@ -147,6 +148,26 @@ static Real computeRelativeCost( Object *queryObject, Object *destObject, Real *return distSquared;}+/** A pile whose nearest supply center, within a short walk of it, belongs to another player is+ * that player's pile. A gatherer sent there either queues behind the owner's trucks or finds no+ * center of its own to carry to and stands idle beside the pile. */+Bool ResourceGatheringManager::isPileOfAnotherPlayer( const Player *player, const Object *warehouse )+{+ // as far as AIPlayer's SUPPLY_CENTER_CLOSE_DIST, which is where the AI puts a center beside a pile+ const Real PILE_CLAIM_DISTANCE = 200.0f;++ PartitionFilterAcceptByKindOf fCenter( MAKE_KINDOF_MASK( KINDOF_FS_SUPPLY_CENTER ), KINDOFMASK_NONE );+ PartitionFilterAlive fAlive;+ PartitionFilterOnMap fOnMap;+ PartitionFilter *filters[] = { &fCenter, &fAlive, &fOnMap, NULL };+ Object *center = ThePartitionManager->getClosestObject( warehouse, PILE_CLAIM_DISTANCE, FROM_BOUNDINGSPHERE_2D, filters );+ if( center == NULL )+ return FALSE;++ const Player *owner = center->getControllingPlayer();+ return owner != player && owner != ThePlayerList->getNeutralPlayer();+}+Object *ResourceGatheringManager::findBestSupplyWarehouse( Object *queryObject ){Object *bestWarehouse = NULL;@@ -195,7 +216,8 @@ Object *ResourceGatheringManager::findBestSupplyWarehouse( Object *queryObject ){Real distanceSquared;Real currentCost = computeRelativeCost( queryObject, currentWarehouse, &distanceSquared );- if( (currentCost < bestCost) && (distanceSquared < maxDistanceSquared) )+ if( (currentCost < bestCost) && (distanceSquared < maxDistanceSquared) &&+ !isPileOfAnotherPlayer( queryObject->getControllingPlayer(), currentWarehouse ) ){bestWarehouse = currentWarehouse;bestCost = currentCost;diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cppindex ea63522d4..a006ed051 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp@@ -42,6 +42,7 @@#include "Common/ThingFactory.h"#include "Common/PlayerList.h"#include "Common/Recorder.h"+#include "Common/ResourceGatheringManager.h"#include "Common/BuildAssistant.h"#include "Common/ThingTemplate.h"#include "Common/TunnelTracker.h"@@ -618,8 +619,9 @@ void AIPlayer::checkForSupplyCenter( BuildListInfo *info, Object *bldg )}}-/** A warehouse with boxes left, not an enemy's, within reach of this supply center. Any of them:- * this asked the nearest one only, and an emptied pile hid the full one behind it. */+/** A warehouse with boxes left, not an enemy's and not beside another player's center, within reach+ * of this supply center. Any of them: this asked the nearest one only, and an emptied pile hid the+ * full one behind it. */static Bool hasSuppliesNear( Player *player, const Object *supplyCenter, Real reach ){Real radius = reach + supplyCenter->getGeometryInfo().getBoundingCircleRadius();@@ -637,7 +639,8 @@ static Bool hasSuppliesNear( Player *player, const Object *supplyCenter, Real reSupplyWarehouseDockUpdate *warehouseModule = (SupplyWarehouseDockUpdate*)supplySource->findUpdateModule( key_warehouseUpdate );if (!warehouseModule) return TRUE;if (warehouseModule->getBoxesStored()*TheGlobalData->m_baseValuePerSupplyBox > 0 &&- player->getRelationship(supplySource->getTeam()) != ENEMIES) return TRUE;+ player->getRelationship(supplySource->getTeam()) != ENEMIES &&+ !ResourceGatheringManager::isPileOfAnotherPlayer(player, supplySource)) return TRUE;}return FALSE;}