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): clamp the terrain shade before it spills into the alpha
Olcay Seygan2096925f7787
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex dd0f1f720..5d9b1071b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -385,6 +385,7 @@ found and fixed — EA's own, not port damage.**- Laying a foundation costs less the further up the map you build. Flattening the ground under a new building scanned every row of the map from the bottom edge up to the building, threw all of them away bar the ones actually under it, and did that once per column. It works out the rows it needs now. The ground comes out identical, down to the last unit of height.- EVA announcements that were queued behind another one no longer go quiet. A request waits its turn and expires if its turn never comes, and the sum that worked out when that was could wrap round to zero, retiring the announcement on the frame it was asked for.- "Your base is under attack" fires for the attack you are actually under. The check that decides whether a warning is a repeat of one you just heard was computing something that was not a distance at all, so an attack on the far side of the map could silence the warning for one at your front door, and two hits on the same building could each get their own.+- Scorch marks and tank tracks keep their colour on a brightly lit map. The shade was worked out from the map's own lighting with nothing holding it to a byte, and the red channel sits sixteen bits up, so anything over full brightness spilled into the transparency and the mark came out the wrong colour at the wrong opacity.- Two tanks shelling the same spot no longer wipe a scorch mark off the far side of the map. With the ground already carrying its full quota of marks, a repeat crater threw the oldest one away and then declined to add itself, so a mark vanished and nothing replaced it.- Heat haze wobbles in both directions. The vertical part of the distortion was rolled, clipped against the top and bottom of the screen, and then never used - every shimmer pulled the picture along one diagonal.- 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".diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cppindex 57990a9bb..b74c71f85 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp@@ -1952,6 +1952,14 @@ void BaseHeightMapRenderObjClass::updateScorches(void)shadeR*=255.0f;shadeG*=255.0f;shadeB*=255.0f;+ //+ // Ambient plus half the diffuse can be over 1.0 - a map lit brightly is enough - and nothing+ // held these to a byte. The red channel is shifted up sixteen bits, so anything past 255 ran+ // straight into the alpha byte and the scorch came out the wrong colour and the wrong opacity.+ //+ if (shadeR > 255.0f) shadeR = 255.0f; if (shadeR < 0.0f) shadeR = 0.0f;+ if (shadeG > 255.0f) shadeG = 255.0f; if (shadeG < 0.0f) shadeG = 0.0f;+ if (shadeB > 255.0f) shadeB = 255.0f; if (shadeB < 0.0f) shadeB = 0.0f;Int diffuse=REAL_TO_INT(shadeB) | (REAL_TO_INT(shadeG) << 8) | (REAL_TO_INT(shadeR) << 16) | ((int)255 << 24);m_scorchesInBuffer = 0;for (curScorch=m_numScorches-1; curScorch>=0; curScorch--) {diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cppindex 59b118d9e..8322dd50e 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp@@ -826,6 +826,12 @@ Try improving the fit to vertical surfaces like cliffs.shadeG*=255.0f;shadeB*=255.0f;+ // clamp to a byte, same reason as the scorch marks in BaseHeightMap: the red channel is shifted+ // sixteen bits up and a brightly lit map pushes it past 255, into the alpha the fade writes below+ if (shadeR > 255.0f) shadeR = 255.0f; if (shadeR < 0.0f) shadeR = 0.0f;+ if (shadeG > 255.0f) shadeG = 255.0f; if (shadeG < 0.0f) shadeG = 0.0f;+ if (shadeB > 255.0f) shadeB = 255.0f; if (shadeB < 0.0f) shadeB = 0.0f;+diffuseLight = REAL_TO_INT(shadeB) | (REAL_TO_INT(shadeG) << 8) | (REAL_TO_INT(shadeR) << 16);Real numFadedEdges=m_maxTankTrackEdges-m_maxTankTrackOpaqueEdges;