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.

perf(gamelogic): superweapon value tests the distance before scouting

Olcay Seygan15458d056249
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp
index 1c007d4d2..2fe5592ac 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/AI/AIPlayer.cpp
@@ -2283,6 +2283,13 @@ Int AIPlayer::getPlayerSuperweaponValue(Coord3D *center, Int playerNdx, Real rad
Object *pObj = iter.cur();
if (!pObj)
continue;
+ // the distance first: the beam steer asks this for 49 points around the beam, and the scouting
+ // test on every object of every enemy made a steer 2.6 ms late in a match, against 0.9 now
+ Coord3D pos = *pObj->getPosition();
+ Real dx = center->x - pos.x;
+ Real dy = center->y - pos.y;
+ if (dx*dx+dy*dy >= radSqr)
+ continue;
if (pObj->isEffectivelyDead())
continue; // a tank in its death throes stays on the team for seconds and held a steered beam on its wreck
if (!observerKnowsAbout(pObj, observerNdx))
@@ -2312,10 +2319,6 @@ Int AIPlayer::getPlayerSuperweaponValue(Coord3D *center, Int playerNdx, Real rad
continue; // Don't target flying aircraft. OK if in the airstrip.
}
}
- Coord3D pos = *pObj->getPosition();
- Real dx = center->x - pos.x;
- Real dy = center->y - pos.y;
- if (dx*dx+dy*dy<radSqr)
{
Real dist = sqrt(dx*dx+dy*dy);
Real factor = 1.0f - (dist/(2*radius)); // 1.0 in center, 0.5 on edges.