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(w3ddevice): stop the oversize action shrinking terrain, cull lights in map space
Olcay Seygan950f0a0dddea
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4db365095..cbbbe7747 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -429,6 +429,7 @@ found and fixed — EA's own, not port damage.**- One tree in ten stood dead still in the breeze. The number that picks which way a tree sways was drawn from a range one short at the bottom, and the bottom of that range is the slot meaning "no sway at all".- Police car lights flash at their own speed instead of your monitor's. On a fast screen with the frame cap off they were cycling five and a half times too quickly.- Ten more places that wrote terrain, roads, bridges, trees, foundations and scorch marks into a buffer the graphics card had refused to hand over. Every one of them wrote to address zero instead, and a graphics device pulled out from under the game is all it takes; the frame is simply skipped now.+- A mission that asks to see more of the ground gets more of it. The script action for widening the drawn terrain was written when the game drew a square of map around the camera and pushed that square out; this one already draws the whole map, so the same arithmetic handed back a patch a few hundred feet across and the ground ended in mid air - in exactly the cutscenes that asked to see further.- Tank tracks no longer crash the game. The renderer has to borrow the buffer it writes them into, and when that request failed, which is what a graphics device pulled out from under the game does, the tracks were written to address zero anyway. Two more of the same shape went with it: the screenshot path and the texture size lookup both used a pointer that the failing call had never filled in. Three of those texture lookups also leaked the surface they asked about, once per procedural texture, for the life of the process.- Double-clicking a menu button opens the screen once. The button stays live while the old screen animates out, so the second click started the same transition again and the screen opened twice, one copy left drawn over whatever came next and doing nothing sensible when clicked.- A river's banks stop coming out as a hard dark edge. The fog of war was painted onto a river in a pass of its own that redrew the whole rectangle and knew nothing about where the water fades into the shore, so the shore was darkened twice, once as ground and once as river, and the soft edge landed as a straight line with a slab of water inside it. The fog is part of the water now: the bank blends again, and a river under black shroud goes dark instead of leaking a little light through.diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/HeightMap.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/HeightMap.hindex e51499ed0..c40ceafdf 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/HeightMap.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/HeightMap.h@@ -90,7 +90,7 @@ public:virtual void doPartialUpdate(const IRegion2D &partialRange, WorldHeightMap *htMap, RefRenderObjListIterator *pLightsIterator);virtual void oversizeTerrain(Int tilesToOversize);-+virtual int updateBlock(Int x0, Int y0, Int x1, Int y1, WorldHeightMap *pMap, RefRenderObjListIterator *pLightsIterator);protected:diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cppindex 97ad972ca..238b3c7bd 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp@@ -1194,38 +1194,12 @@ void HeightMapRenderObjClass::reset(void)//=============================================================================/** Sets the terrain oversize amount. *///=============================================================================-void HeightMapRenderObjClass::oversizeTerrain(Int tilesToOversize)+void HeightMapRenderObjClass::oversizeTerrain(Int tilesToOversize){- Int width = WorldHeightMap::NORMAL_DRAW_WIDTH;- Int height = WorldHeightMap::NORMAL_DRAW_HEIGHT;- if (tilesToOversize>0 && tilesToOversize<5)- {- width += 32*tilesToOversize;- height += 32*tilesToOversize;- if (width>m_map->getXExtent())- width = m_map->getXExtent();- if (height>m_map->getYExtent())- height = m_map->getYExtent();- }- Int dx = width-m_map->getDrawWidth();- Int dy = height-m_map->getDrawHeight();- m_map->setDrawWidth(width);- m_map->setDrawHeight(height);- dx /= 2;- dy /= 2;- Int newOrgX = m_map->getDrawOrgX()-dx;- Int newOrgy = m_map->getDrawOrgY()-dy;- if (newOrgX<0) newOrgX=0;- if (newOrgy<0) newOrgy=0;- m_map->setDrawOrg(newOrgX,newOrgy);- m_originX = 0;- m_originY = 0;- if (m_shroud)- m_shroud->reset();- //delete m_shroud;- //m_shroud = NULL;- initHeightData(m_map->getDrawWidth(), m_map->getDrawHeight(), m_map, NULL, FALSE);- m_needFullUpdate = true;+ // Nothing left to widen: WorldHeightMap now draws the whole map on every map, so the 129x129+ // window this used to push out to 129+32n no longer exists. Running the old arithmetic+ // anyway set the draw size to 161..257 vertices, which on any map bigger than that took+ // terrain away from the script that asked for more of it.}@@ -1404,10 +1378,16 @@ void HeightMapRenderObjClass::On_Frame_Update(void)Int numDynaLights=0;W3DDynamicLight *enabledLights[MAX_ENABLED_DYNAMIC_LIGHTS];- Int yCoordMin = m_map->getDrawOrgY();- Int yCoordMax = m_y+m_map->getDrawOrgY();- Int xCoordMin = m_map->getDrawOrgX();- Int xCoordMax = m_x+m_map->getDrawOrgX();+ // A light's min/max come from its world position over MAP_XY_FACTOR, which is the map's+ // non-playable border already subtracted. This rectangle used to be built without doing the+ // same, so it sat a whole border away from the lights it was testing: a light within that+ // distance of the low edge was dropped and never lit anything, and one that far past the high+ // edge was processed for nothing. The per-tile tests further down (getYWithOrigin(...) -+ // getBorderSizeInline()) always had it right, which is what the two disagreed about.+ const Int xCoordMin = m_map->getDrawOrgX() - m_map->getBorderSizeInline();+ const Int yCoordMin = m_map->getDrawOrgY() - m_map->getBorderSizeInline();+ const Int xCoordMax = xCoordMin + m_map->getDrawWidth();+ const Int yCoordMax = yCoordMin + m_map->getDrawHeight();for (pDynamicLightsIterator.First(); !pDynamicLightsIterator.Is_Done(); pDynamicLightsIterator.Next()){