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
feat(w3ddevice): keep the shadow on fixed scenery in the fog
Olcay Seygan7f0be77ce136
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4f8546297..37d4a78e7 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -188,6 +188,11 @@ found and fixed — EA's own, not port damage.**- 481 base-game textures at four times the resolution now beat Zero Hour's downscaled copies.- A long thin texture loads at the size it was drawn at. Anything wider than eight to one used to be stretched onto a bigger, blurrier one, because that was the limit of a 2002 graphics card; the card is asked now, and modern ones have no such limit.+- Anything standing still keeps its shadow in the fog. A town you have already walked through used+ to sit on flat ground the moment you looked away, buildings and derricks and walls with nothing+ underneath them, because the fog took the shadow off everything. Now only things that move lose+ theirs, which they have to: a shadow crawling across fogged ground is the position of a unit you+ are not meant to see. Ground you have never set foot on is still dark and still empty.- Woodland stops vanishing when you look at too much of it at once. Every tree on screen was written into one buffer that held about 730 of them, and the ones that did not fit were simply not drawn, so scrolling into a dense corner made whole stands of trees blink out and come back when you left. There are four of those buffers now.## Every replay, not just the last onediff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cppindex ac2e38d34..7637c854e 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp@@ -49,6 +49,8 @@#include "GameClient/FXList.h"#include "GameClient/Shadow.h"#include "GameLogic/GameLogic.h" // for real-time frame+#include "Common/Player.h"+#include "Common/PlayerList.h"#include "GameLogic/Object.h"#include "GameLogic/WeaponSet.h"#include "GameLogic/FPUControl.h"@@ -2086,6 +2088,36 @@ void W3DModelDraw::getRenderCostRecursive(RenderCost & rc,RenderObjClass * robj)}#endif //_DEBUG || _INTERNAL+//-------------------------------------------------------------------------------------------------+/** Does this thing keep its shadow when the fog closes over it?++ Anything fixed in place does. A building you have already walked past is still standing there and+ still standing in the same light, and the fog draws it from the snapshot the ghost took: leaving+ the shadow out gave a town in the fog rows of buildings sitting on flat ground with nothing under+ them. Trees, walls and the rest of the scenery are the same case.++ Anything that moves does not, and this is not a detail: a shadow crawling across fogged ground+ is the position of a unit you are not allowed to see.++ Never-seen ground is not fog and gets nothing - the check below asks for the real shroud status+ rather than trusting the obscured flag, which cannot tell the two apart. */+static Bool keepsShadowInFog(const Drawable *draw)+{+ if (draw == NULL)+ return FALSE;++ const Object *obj = draw->getObject();+ if (obj == NULL)+ return FALSE;++ if (!obj->isKindOf(KINDOF_IMMOBILE) || obj->isKindOf(KINDOF_PROJECTILE))+ return FALSE;++ //fogged keeps it, shrouded does not+ const Int localPlayerIndex = ThePlayerList ? ThePlayerList->getLocalPlayer()->getPlayerIndex() : 0;+ return obj->getShroudedStatus(localPlayerIndex) < OBJECTSHROUD_SHROUDED;+}+//-------------------------------------------------------------------------------------------------void W3DModelDraw::setFullyObscuredByShroud(Bool fullyObscured){@@ -2093,8 +2125,11 @@ void W3DModelDraw::setFullyObscuredByShroud(Bool fullyObscured){m_fullyObscuredByShroud = fullyObscured;+ const Bool hideShadow = m_fullyObscuredByShroud && !keepsShadowInFog(getDrawable());+if (m_shadow)- m_shadow->enableShadowInvisible(m_fullyObscuredByShroud);+ m_shadow->enableShadowInvisible(hideShadow);+ //the terrain decal is a marker, not a shadow: it goes with the thing it marksif (m_terrainDecal)m_terrainDecal->enableShadowInvisible(m_fullyObscuredByShroud);