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): write a scorch into the buffer whole or not at all
Olcay Seyganebb236a42424
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 3cb60cf8b..d9f7991a0 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -468,6 +468,7 @@ found and fixed — EA's own, not port damage.**- "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.+- A crater is drawn whole or not at all. When the ground ran out of room for marks, the last one was drawn up to wherever the room ended and stopped there, a strip of it missing. There is room for four times as much ground under marks before that happens, and when it does, the oldest marks are the ones left out.- Embers and sparks that trail an effect finish their run. When the effect that owned them ended first, they lost track of where it was, were drawn at the corner of the map and died early.- 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/Include/W3DDevice/GameClient/BaseHeightMap.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.hindex a2b7def95..05a1ba0f2 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h@@ -259,8 +259,8 @@ protected:Int m_y; ///< dimensions of heightmap#ifdef DO_SCORCH- enum { MAX_SCORCH_VERTEX=8194,- MAX_SCORCH_INDEX=6*8194,+ enum { MAX_SCORCH_VERTEX=32768,+ MAX_SCORCH_INDEX=65535,MAX_SCORCH_MARKS=500,SCORCH_MARKS_IN_TEXTURE=9,SCORCH_PER_ROW = 3};diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cppindex ed284a56b..882f96c9d 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp@@ -2035,11 +2035,22 @@ void BaseHeightMapRenderObjClass::updateScorches(void)if (maxY > m_map->getYExtent()-m_map->getBorderSizeInline()) {maxY = m_map->getYExtent()-m_map->getBorderSizeInline();}+ Int vertexCountX = maxX-minX;+ Int vertexCountY = maxY-minY;+ if (vertexCountX <= 0 || vertexCountY <= 0) {+ continue;+ }+ // The whole scorch fits or none of it is written. Checking inside the loops left the last+ // one half drawn, a strip of triangles cut off wherever the buffer ran out. Newest first, so+ // what gets dropped when it is full is the oldest marks.+ if (m_curNumScorchVertices + vertexCountX*vertexCountY > MAX_SCORCH_VERTEX ||+ m_curNumScorchIndices + 6*(vertexCountX-1)*(vertexCountY-1) > MAX_SCORCH_INDEX) {+ return;+ }Int startVertex = m_curNumScorchVertices;Int i, j;for (j=minY; j<maxY; j++) {for (i=minX; i<maxX; i++) {- if (m_curNumScorchVertices >= MAX_SCORCH_VERTEX) return;curVb->diffuse = diffuse;Real theZ;theZ = amtToFloat+((float)getClipHeight(i+m_map->getBorderSizeInline(),j+m_map->getBorderSizeInline())*MAP_HEIGHT_SCALE);@@ -2060,7 +2071,6 @@ void BaseHeightMapRenderObjClass::updateScorches(void)Int yOffset = maxX-minX;for (j=0; j<maxY-minY-1; j++) {for (i=0; i<maxX-minX-1; i++) {- if (m_curNumScorchIndices+6 > MAX_SCORCH_INDEX) return;Int xNdx = i+minX+m_map->getBorderSizeInline();Int yNdx = j+minY+m_map->getBorderSizeInline();Bool flipForBlend = m_map->getFlipState(xNdx, yNdx);