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(gamelogic): exclusive disabled-type mask, particle beam height, ground FX layer

Olcay Seyganb9773438fb04
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/FXList.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/FXList.cpp
index 8bd434dfc..56fefd635 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/FXList.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/FXList.cpp
@@ -614,6 +614,7 @@ protected:
newPos.x = primary->x + offset.x + radius * cos(angle);
newPos.y = primary->y + offset.y + radius * sin(angle);
+ newPos.z = primary->z + offset.z;
if( m_createAtGroundHeight && TheTerrainLogic )
{
//old way:
@@ -624,7 +625,7 @@ protected:
newPos.z = TheTerrainLogic->getLayerHeight( newPos.x, newPos.y, layer );
}
else
- newPos.z = primary->z + offset.z + m_height.getValue();
+ newPos.z += m_height.getValue();
if (m_orientToObject && mtx)
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp
index cb2805c45..79d14a013 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Object/Update/ParticleUplinkCannonUpdate.cpp
@@ -58,6 +58,10 @@
#include "GameLogic\Module\LaserUpdate.h"
#include "GameLogic\Module\ActiveBody.h"
+// TheSuperHackers @fix Raised from 500.0f so that enormous camera heights
+// cannot see over the top of the beam where it leaves the sky.
+static const Real ORBITAL_BEAM_Z_OFFSET = 3500.0f;
+
#ifdef _INTERNAL
// for occasional debugging...
//#pragma optimize("", off)
@@ -603,7 +607,7 @@ UpdateSleepTime ParticleUplinkCannonUpdate::update()
Coord3D orbitPosition;
orbitPosition.set( &m_currentTargetPosition );
- orbitPosition.z += 500.0f;
+ orbitPosition.z += ORBITAL_BEAM_Z_OFFSET;
Real scorchRadius = 0.0f;
Real damageRadius = 0.0f;
@@ -961,7 +965,7 @@ void ParticleUplinkCannonUpdate::createGroundToOrbitLaser( UnsignedInt growthFra
{
Coord3D orbitPosition;
orbitPosition.set( &m_laserOriginPosition );
- orbitPosition.z += 500.0f;
+ orbitPosition.z += ORBITAL_BEAM_Z_OFFSET;
update->initLaser( NULL, NULL, &m_laserOriginPosition, &orbitPosition, "", growthFrames );
}
}
@@ -997,7 +1001,7 @@ void ParticleUplinkCannonUpdate::createOrbitToTargetLaser( UnsignedInt growthFra
{
Coord3D orbitPosition;
orbitPosition.set( &m_initialTargetPosition );
- orbitPosition.z += 500.0f;
+ orbitPosition.z += ORBITAL_BEAM_Z_OFFSET;
update->initLaser( NULL, NULL, &orbitPosition, &m_initialTargetPosition, "", growthFrames );
}
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp
index a01e6b851..d1f61a70f 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/ScriptEngine/Scripts.cpp
@@ -2162,13 +2162,12 @@ Parameter *Parameter::ReadParameter(DataChunkInput &file)
// quick hack to make loading models with "Fundamentalist" switch to "GLA"
if (pParm->m_string.startsWith("Fundamentalist"))
{
- char oldName[256];
- char newName[256];
- strcpy(oldName, pParm->m_string.str());
- strcpy(newName, "GLA");
- strcat(newName, oldName+strlen("Fundamentalist"));
- pParm->m_string.set(newName);
- DEBUG_LOG(("Changing Script Ref from %s to %s\n", oldName, newName));
+ // TheSuperHackers @fix The old code copied the name into a 256 byte stack buffer first,
+ // which overflows on a longer script reference. AsciiString has no such limit.
+ AsciiString newName = "GLA";
+ newName.concat( pParm->m_string.str() + strlen("Fundamentalist") );
+ DEBUG_LOG(("Changing Script Ref from %s to %s\n", pParm->m_string.str(), newName.str()));
+ pParm->m_string = newName;
}
}
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
index c897f9b7f..c6d60fb87 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/System/GameLogic.cpp
@@ -4355,7 +4355,10 @@ void GameLogic::update( void )
{
UpdateModulePtr u = *it;
DisabledMaskType dis = u->friend_getObject()->getDisabledFlags();
- if (!dis.any() || dis.anyIntersectionWith(u->getDisabledTypesToProcess()))
+ // TheSuperHackers @bugfix The disabled-types-to-process mask is now exclusive. A module
+ // used to keep updating as long as the object carried any one of the types it whitelists,
+ // even while a second, unlisted disable was also in force. Every set bit must be listed.
+ if (!dis.any() || u->getDisabledTypesToProcess().testForAll(dis))
{
USE_PERF_TIMER(GameLogic_update_normal)
@@ -4395,7 +4398,10 @@ void GameLogic::update( void )
UpdateSleepTime sleepLen = UPDATE_SLEEP_NONE; // default, if it is disabled.
DisabledMaskType dis = u->friend_getObject()->getDisabledFlags();
- if (!dis.any() || dis.anyIntersectionWith(u->getDisabledTypesToProcess()))
+ // TheSuperHackers @bugfix The disabled-types-to-process mask is now exclusive. A module
+ // used to keep updating as long as the object carried any one of the types it whitelists,
+ // even while a second, unlisted disable was also in force. Every set bit must be listed.
+ if (!dis.any() || u->getDisabledTypesToProcess().testForAll(dis))
{
USE_PERF_TIMER(GameLogic_update_sleepy)
diff --git a/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp b/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp
index 4f791dd53..02e238454 100644
--- a/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp
+++ b/GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilderDoc.cpp
@@ -439,12 +439,11 @@ void CWorldBuilderDoc::Serialize(CArchive& ar)
AsciiString ConvertToNonGCName(AsciiString name, Bool checkTemplate=true)
{
- char oldName[256];
- char newName[256];
- strcpy(oldName, name.str());
- strcpy(newName, oldName+strlen("GC_"));
+ // TheSuperHackers @fix Skipping the prefix without checking for it walked past the
+ // terminator on a shorter name, and the 256 byte stack copy overflowed on a longer one.
+ const char *prefix = "GC_";
AsciiString swapName;
- swapName.set(newName);
+ swapName.set( name.startsWith( prefix ) ? name.str() + strlen( prefix ) : name.str() );
if (checkTemplate)
{
const ThingTemplate *tt = TheThingFactory->findTemplate(swapName);
@@ -458,13 +457,9 @@ AsciiString ConvertToNonGCName(AsciiString name, Bool checkTemplate=true)
AsciiString ConvertName(AsciiString name)
{
- char oldName[256];
- char newName[256];
- strcpy(oldName, name.str());
- strcpy(newName, "GLA");
- strcat(newName, oldName+strlen("Fundamentalist"));
- AsciiString swapName;
- swapName.set(newName);
+ const char *prefix = "Fundamentalist";
+ AsciiString swapName = "GLA";
+ swapName.concat( name.startsWith( prefix ) ? name.str() + strlen( prefix ) : name.str() );
const ThingTemplate *tt = TheThingFactory->findTemplate(swapName);
if (tt) {
return swapName;
@@ -474,13 +469,9 @@ AsciiString ConvertName(AsciiString name)
AsciiString ConvertFaction(AsciiString name)
{
- char oldName[256];
- char newName[256];
- strcpy(oldName, name.str());
- strcpy(newName, "FactionGLA");
- strcat(newName, oldName+strlen("FactionFundamentalist"));
- AsciiString swapName;
- swapName.set(newName);
+ const char *prefix = "FactionFundamentalist";
+ AsciiString swapName = "FactionGLA";
+ swapName.concat( name.startsWith( prefix ) ? name.str() + strlen( prefix ) : name.str() );
const PlayerTemplate* pt = ThePlayerTemplateStore->findPlayerTemplate(NAMEKEY(swapName));
if (pt) {
return swapName;