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(w3ddevice): scorch marks, heat haze, and a smudge pass nobody needed

Olcay Seygan337d20bb7eac
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d077bec69..535ae0c88 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -383,6 +383,8 @@ found and fixed — EA's own, not port damage.**
- A mission script that waits for a line of speech to finish waits the same length of time on every machine. It used to ask the sound hardware how long the file was, so a player whose sound card was not working, or was turned off, got the answer zero and walked straight through waits that everyone else sat out. That is a different game on two screens, and a replay that stops matching the machine that recorded it. The length now comes out of the file itself: measured on one line of speech, a silent machine said 0 milliseconds and a machine with sound said 3,285. Both say 3,285 now.
- 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.
+- 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".
- 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.
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp
index 58dbeaae0..57990a9bb 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp
@@ -2062,25 +2062,30 @@ void BaseHeightMapRenderObjClass::clearAllScorches(void)
void BaseHeightMapRenderObjClass::addScorch(Vector3 location, Real radius, Scorches type)
{
#ifdef DO_SCORCH
- if (m_numScorches >= MAX_SCORCH_MARKS) {
- Int i;
- for (i=0; i<MAX_SCORCH_MARKS-1; i++) {
- m_scorches[i] = m_scorches[i+1];
- }
- m_numScorches--;
- }
-
+ //
+ // Ask whether this is a duplicate first. Making room came before the check, so a full list
+ // handed the same crater twice threw away its oldest scorch and then returned without adding
+ // anything - a mark on the ground disappeared and nothing took its place. Two tanks firing at
+ // the same spot is all it takes.
+ //
Int i;
Real limit = radius/4;
- for (i=0; i<m_numScorches; i++) {
- if ( abs(location.X-m_scorches[i].location.X) < limit &&
- abs(location.Y-m_scorches[i].location.Y) < limit &&
+ for (i=0; i<m_numScorches; i++) {
+ if ( abs(location.X-m_scorches[i].location.X) < limit &&
+ abs(location.Y-m_scorches[i].location.Y) < limit &&
abs(radius - m_scorches[i].radius) < limit &&
m_scorches[i].scorchType == type) {
return; // basically a duplicate.
}
}
+ if (m_numScorches >= MAX_SCORCH_MARKS) {
+ for (i=0; i<MAX_SCORCH_MARKS-1; i++) {
+ m_scorches[i] = m_scorches[i+1];
+ }
+ m_numScorches--;
+ }
+
m_scorches[m_numScorches].location = location;
m_scorches[m_numScorches].radius = radius;
m_scorches[m_numScorches].scorchType = type;
diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp
index 5f5d9f484..bbd2dea71 100644
--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp
+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp
@@ -309,6 +309,15 @@ void W3DSmudgeManager::render(RenderInfoClass &rinfo)
if (!testHardwareSupport())
return;
+ //
+ // ...and that there is anything to smudge. The list was not looked at until forty lines down,
+ // after the camera matrices, the surface description and, on the copy-rects path, a read of the
+ // back buffer's surface level - all of it every frame of a match with no heat haze anywhere on
+ // the screen, which is most of them.
+ //
+ if (m_usedSmudgeSetList.Head() == NULL)
+ return;
+
CameraClass &camera=rinfo.Camera;
Vector3 vsVert;
Vector4 ssVert;
@@ -413,7 +422,10 @@ void W3DSmudgeManager::render(RenderInfoClass &rinfo)
uvSpanX=verts[3].uv.X - verts[0].uv.X;
uvSpanY=verts[1].uv.Y - verts[0].uv.Y;
verts[4].uv.X=verts[0].uv.X+uvSpanX*(0.5f+smudge->m_offset.X);
- verts[4].uv.Y=verts[0].uv.Y+uvSpanY*(0.5f+smudge->m_offset.X);
+ // .Y, not .X: the vertical offset was rolled, clamped against the top and bottom of the
+ // view a dozen lines up, and then never read - the centre vertex took the horizontal
+ // one on both axes, so every smudge pulled the background along one diagonal.
+ verts[4].uv.Y=verts[0].uv.Y+uvSpanY*(0.5f+smudge->m_offset.Y);
count++; //increment visible smudge count.
smudge=smudge->Succ();