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(ww3d2): fall back to the portable D3DX when d3dx9_43.dll is missing
Olcay Seygan4079dde8782b
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 149e3c308..95a1d18a3 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -1298,6 +1298,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same- A model file with no skeleton in it is refused as it loads. It used to load, and the game went down the first time anything asked it for a bone.- Quitting faulted twice every time; it now takes about half a second.- Quitting the game from the score screen crashed it in 2.4.0. The fix that stopped the score music cleanly also ran the sound once more while the game was closing, by which point the battlefield it places the listener on was already gone. The game closes cleanly from there again, and the score music still stops the moment you leave the screen.+- A Windows PC that never installed the 2010 DirectX runtime, as happens with some repacks, crashed at the first texture. The game now draws with its own copy of that library, the one Windows on Arm laptops already use, and plays the same match to the same result.- A long chat message or an unusual map name could kill the process.- A map name the game cannot make sense of is refused as you start, instead of taking the game down later. A path with a space in it and no quotes around it left the loader walking the same step of that path forever, growing a string until it ran out of room, and the game then went on starting with half of itself missing. What you saw was a crash a second later, in the part of the game that runs a match, naming nothing that had anything to do with it. Any failure during start-up now stops the game there and says which one it was.- A downloaded map made for another mod loads instead of crashing as the match starts. Maps can carry their own tweaks to units, and one a player tried gave a wall a setting Zero Hour has never had; one unfamiliar line was enough to take the whole game down. A setting the game does not know is now passed over and the rest of the map's tweaks still apply.diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/d3dx9runtime.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/d3dx9runtime.cppindex 1100cb8a5..cd6008b5b 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/d3dx9runtime.cpp+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/d3dx9runtime.cpp@@ -70,7 +70,7 @@ static bool BoundPortable = false;static void release_module(void);/* The port's own D3DX, for Windows on Arm, which has no DLL: Microsoft shipped d3dx9_43.dll for x86 and- x64 only, and an ARM64 process cannot load either.+ x64 only, and an ARM64 process cannot load either. An x64 machine that lacks the DLL lands here too.- The arithmetic is d3dx9portable.cpp, what macOS and Linux use, held against the DLL bytest_d3dx9portable_oracle on x64. None of it reaches the simulation, whose D3DXVec4Transform isd3dx9math.h's.@@ -212,6 +212,14 @@ static void bind_portable_runtime(void)D3DXVec3Transform = (D3DXVec3TransformFunction)D3DXPortable_Vec3_Transform;}+static bool bind_portable_fallback(void)+{+ bind_portable_runtime();+ BoundPortable = true;+ BindSucceeded = true;+ return true;+}+struct ErrorName{HRESULT Result;@@ -252,15 +260,14 @@ bool Bind_D3DX9_Runtime(void)BindAttempted = true;if (portable_wanted()) {- bind_portable_runtime();- BoundPortable = true;- BindSucceeded = true;- return true;+ return bind_portable_fallback();}+ // A repack that never ran the DirectX June 2010 redistributable has no d3dx9_43.dll. It gets+ // the code Windows on ARM64 runs instead of a null D3DXCreateTexture at the first texture.D3DX9Module = LoadLibraryA(D3DX9_MODULE_NAME);if (D3DX9Module == NULL) {- return false;+ return bind_portable_fallback();}D3DXAssembleShader = (D3DXAssembleShaderFunction)@@ -322,6 +329,7 @@ bool Bind_D3DX9_Runtime(void)if (!BindSucceeded) {release_module();+ return bind_portable_fallback();}return BindSucceeded;}diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/d3dx9runtime.h b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/d3dx9runtime.hindex f3ea9ff90..b2c13681f 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/d3dx9runtime.h+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/d3dx9runtime.h@@ -127,11 +127,10 @@ extern D3DXLoadSurfaceFromSurfaceFunction D3DXLoadSurfaceFromSurface;extern D3DXGetFVFVertexSizeFunction D3DXGetFVFVertexSize;// Loads d3dx9_43.dll and resolves all seventeen entry points, this header's and-// d3dx9math.h's. Returns false and leaves every pointer null if the DLL is missing or-// any one of them is not exported, so a caller that checks the return value never has-// to check the pointers. Calling it a second time is free and reports the first call.-// On ARM64, and on x64 with ZH_D3DX_PORTABLE=1, it binds the port's own bodies instead-// (d3dx9runtime.cpp says which) and returns true.+// d3dx9math.h's. Calling it a second time is free and reports the first call. On ARM64,+// on x64 with ZH_D3DX_PORTABLE=1, and on x64 when the DLL is missing or any one of them+// is not exported, it binds the port's own bodies instead (D3DX9_Runtime_Name says which)+// and returns true, so on Windows it does not fail.bool Bind_D3DX9_Runtime(void);// Frees the DLL and nulls every pointer, so the next Bind_D3DX9_Runtime tries again.diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cppindex d68b0d0a0..41fc9630e 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8wrapper.cpp@@ -480,9 +480,8 @@ bool DX8Wrapper::Init(void * hwnd, bool lite)memset(Shadow_Map,0,sizeof(ZTextureClass*)*MAX_SHADOW_MAPS);// D3DX9 has no import library and is bound by hand, so this has to happen before- // anything reaches a D3DX entry point. A machine without d3dx9_43.dll gets a- // renderer with no texture loading and no shaders rather than a null call, which is- // why the failure is logged here and not left for the first caller to trip over.+ // anything reaches a D3DX entry point. A machine without d3dx9_43.dll binds the+ // port's own D3DX, the one ARM64 runs; W3DDisplay::init logs which one it got.if (!Bind_D3DX9_Runtime()) {WWDEBUG_SAY(("DX8Wrapper: d3dx9_43.dll did not bind; textures and shaders will not load\n"));}diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/test_dx9_smoke.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/test_dx9_smoke.cppindex 2f82f40a0..44c71d3ac 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/test_dx9_smoke.cpp+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/test_dx9_smoke.cpp@@ -363,15 +363,17 @@ int main(int argument_count, char ** arguments)// d3dx9runtime.cpp is what the renderer will bind, so the test binds the same thing// rather than a copy of it: a missing entry point fails here before it fails in a match.BoundD3DX9Runtime d3dx9;+ // Without the DLL the bind lands on the port's own D3DX and still succeeds, so ask what it bound.+ const bool boundDLL = d3dx9.Is_Bound() && strcmp(D3DX9_Runtime_Name(), "d3dx9_43.dll") == 0;#if defined(_M_ARM64)// There is no d3dx9_43.dll for ARM64, so the rest of this - the DLL's assembler, its math against the// signatures, its CPU dispatch - has nothing to run against. The device checks above have run.- if (!d3dx9.Is_Bound()) {+ if (!boundDLL) {printf("SKIP: no d3dx9_43.dll exists for ARM64; the D3DX half of this check needs it\n");return 77;}#endif- if (!d3dx9.Is_Bound()) {+ if (!boundDLL) {printf("FAIL: d3dx9_43.dll did not bind; all seventeen entry points are phase 1 dependencies\n");return 1;}