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(gamelogic): save the water grid's motion flag and scripted height
Olcay Seyganaf20eee21649
diff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cppindex d6582767d..26f2487eb 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/TerrainLogic.cpp@@ -72,6 +72,7 @@ TerrainLogic *TheTerrainLogic = NULL;// STATIC /////////////////////////////////////////////////////////////////////////////////////////WaterHandle TerrainLogic::m_gridWaterHandle;+static const Int GRID_WATER_TRIGGER_ID = -1; ///< the save's trigger ID for the grid, which has no polygon; map IDs start at 0// Waypoint ///////////////////////////////////////////////////////////////////////////////////////@@ -3047,8 +3048,10 @@ void TerrainLogic::xfer( Xfer *xfer )if( xfer->getXferMode() == XFER_SAVE ){- // write ID of polygon trigger that this water handle is representing- Int triggerID = m_waterToUpdate[ i ].waterTable->m_polygon->getID();+ // write ID of polygon trigger that this water handle is representing; the water grid+ // has no polygon, and EA's save read through its NULL here, so it writes GRID_WATER_TRIGGER_ID+ Int triggerID = m_waterToUpdate[ i ].waterTable == &m_gridWaterHandle ? GRID_WATER_TRIGGER_ID+ : m_waterToUpdate[ i ].waterTable->m_polygon->getID();xfer->xferInt( &triggerID );} // end if, save@@ -3058,31 +3061,37 @@ void TerrainLogic::xfer( Xfer *xfer )// read trigger idInt triggerID;xfer->xferInt( &triggerID );+ if( triggerID == GRID_WATER_TRIGGER_ID )+ m_waterToUpdate[ i ].waterTable = &m_gridWaterHandle;+ else+ {- // find polygon trigger- PolygonTrigger *poly = PolygonTrigger::getPolygonTriggerByID( triggerID );+ // find polygon trigger+ PolygonTrigger *poly = PolygonTrigger::getPolygonTriggerByID( triggerID );- // sanity- if( poly == NULL )- {-- DEBUG_CRASH(( "TerrainLogic::xfer - Unable to find polygon trigger for water table with trigger ID '%d'\n",- triggerID ));- throw SC_INVALID_DATA;+ // sanity+ if( poly == NULL )+ {- } // end if+ DEBUG_CRASH(( "TerrainLogic::xfer - Unable to find polygon trigger for water table with trigger ID '%d'\n",+ triggerID ));+ throw SC_INVALID_DATA;- // set water handle- m_waterToUpdate[ i ].waterTable = poly->getWaterHandle();+ } // end if- // sanity- if( m_waterToUpdate[ i ].waterTable == NULL )- {+ // set water handle+ m_waterToUpdate[ i ].waterTable = poly->getWaterHandle();++ // sanity+ if( m_waterToUpdate[ i ].waterTable == NULL )+ {++ DEBUG_CRASH(( "TerrainLogic::xfer - Polygon trigger to use for water handle has no water handle!\n" ));+ throw SC_INVALID_DATA;- DEBUG_CRASH(( "TerrainLogic::xfer - Polygon trigger to use for water handle has no water handle!\n" ));- throw SC_INVALID_DATA;+ } // end if- } // end if+ } // end else} // end else, loaddiff --git a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/WaterGridMotion.cpp b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/WaterGridMotion.cppindex c7182289c..dd3d66711 100644--- a/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/WaterGridMotion.cpp+++ b/GeneralsMD/Code/GameEngine/Source/GameLogic/Map/WaterGridMotion.cpp@@ -506,13 +506,16 @@ void WaterGrid::crc( Xfer *xfer )// ------------------------------------------------------------------------------------------------/** Xfer, WaterRenderObjClass's bytes, which W3DTerrainVisual::xfer still writes in its block* Version Info:- * 1: Initial version */+ * 1: Initial version+ * 2: The motion flag and the grid's height. EA's version 1 dropped both, so a loaded grid stood+ * still until the next WaveGuide push and sat at GameData's height whatever a script had raised+ * it to, and logic's isUnderwater read those heights. */// ------------------------------------------------------------------------------------------------void WaterGrid::xfer( Xfer *xfer ){// version- XferVersion currentVersion = 1;+ XferVersion currentVersion = 2;XferVersion version = currentVersion;xfer->xferVersion( &version, currentVersion );@@ -556,6 +559,19 @@ void WaterGrid::xfer( Xfer *xfer )} // end for, i+ if( version >= 2 )+ {++ // still settling: the step skips the whole mesh while this is FALSE+ xfer->xferBool( &m_meshInMotion );++ // the grid's height, which a script's water height moves (TerrainLogic::setWaterHeight)+ Real z = m_transform.Get_Z_Translation();+ xfer->xferReal( &z );+ m_transform.Set_Z_Translation( z );++ } // end if+} // end xfer// ------------------------------------------------------------------------------------------------