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): the second laser used the first laser's template

Olcay Seygan73e3fe2d66f7
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
index 89b31ca8a..d861af71d 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp
@@ -3535,7 +3535,7 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
{
if (TheGameLogic->isInGame())
{
- Int idx;
+ Int idx = -1;
for (Int i = 0; i < ThePlayerList->getPlayerCount(); i++)
{
if (ThePlayerList->getNthPlayer(i) == ThePlayerList->getLocalPlayer())
@@ -3544,6 +3544,14 @@ GameMessageDisposition CommandTranslator::translateGameMessage(const GameMessage
break;
}
}
+ //
+ // The local player is not always one of the players: watching a replay from the
+ // observer seat is the ordinary way to get here that way. idx then kept whatever
+ // was on the stack and went straight into getNthPlayer as an index. Start at the
+ // first player instead, which is where the cycle would have wrapped to anyway.
+ //
+ if (idx < 0)
+ idx = 0;
Int idxOrig = idx;
do
{
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp
index 012fca881..5aef18f03 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/AssistedTargetingUpdate.cpp
@@ -149,9 +149,10 @@ UpdateSleepTime AssistedTargetingUpdate::update( void )
m_laserFromAssisted = TheThingFactory->findTemplate( d->m_laserFromAssistedName );
-
- m_laserToTarget =TheThingFactory->findTemplate( d->m_laserFromAssistedName );
-
+ // ...and the other laser gets the other name. Both of these read m_laserFromAssistedName, so
+ // the LaserToTarget line in the INI was parsed, stored and never looked at, and the beam to the
+ // victim was drawn with the template meant for the beam from the spotter.
+ m_laserToTarget = TheThingFactory->findTemplate( d->m_laserToTargetName );
return UPDATE_SLEEP_FOREVER;
}
@@ -193,7 +194,7 @@ void AssistedTargetingUpdate::loadPostProcess( void )
const AssistedTargetingUpdateModuleData *d = getAssistedTargetingUpdateModuleData();
m_laserFromAssisted = TheThingFactory->findTemplate( d->m_laserFromAssistedName );
- m_laserToTarget =TheThingFactory->findTemplate( d->m_laserFromAssistedName );
+ m_laserToTarget = TheThingFactory->findTemplate( d->m_laserToTargetName ); // see update()
// extend base class
UpdateModule::loadPostProcess();