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
build(cmake): link generals.exe from GameEngineDevice and Main
Olcay Seyganefd2ea4380bc
diff --git a/.gitignore b/.gitignoreindex f1ba2b720..6b565b0a8 100644--- a/.gitignore+++ b/.gitignore@@ -1,2 +1,5 @@# CMake build tree (see CLAUDE.md for the configure/build commands)build/++# Build/test logs from the CMake port loop+*.logdiff --git a/GeneralsMD/Code/CMakeLists.txt b/GeneralsMD/Code/CMakeLists.txtindex a0e0dc56d..dfa707856 100644--- a/GeneralsMD/Code/CMakeLists.txt+++ b/GeneralsMD/Code/CMakeLists.txt@@ -342,6 +342,63 @@ target_link_libraries(gameengine PUBLICbenchmark eabrowserdispatch profile gamespydinput8 wininet imagehlp imm32)+# ===========================================================================+# Phase 4 - GameEngineDevice + Main -> generals.exe+# ===========================================================================+set(GED ${CMAKE_CURRENT_SOURCE_DIR}/GameEngineDevice)+set(STUBS ${CMAKE_CURRENT_SOURCE_DIR}/Stubs)++file(GLOB_RECURSE GAMEENGINEDEVICE_SOURCES ${GED}/Source/*.cpp)+# On disk but absent from GameEngineDevice.dsp: the DirectInput mouse (the+# shipping build uses the Win32 message mouse instead).+list(REMOVE_ITEM GAMEENGINEDEVICE_SOURCES+ ${GED}/Source/Win32Device/GameClient/Win32DIMouse.cpp)+# Miles and Bink are binary-only SDKs that are not in the release, so their two+# device implementations are replaced by the null devices in Stubs/ (PLAN.md+# Phase 4: silence and skipped movies, not a launch blocker).+list(REMOVE_ITEM GAMEENGINEDEVICE_SOURCES+ ${GED}/Source/MilesAudioDevice/MilesAudioManager.cpp+ ${GED}/Source/VideoDevice/Bink/BinkVideoPlayer.cpp)++add_library(gameenginedevice STATIC ${GAMEENGINEDEVICE_SOURCES})++target_include_directories(gameenginedevice PUBLIC+ ${GED}/Include ${STUBS} ${CMAKE_CURRENT_SOURCE_DIR}/Main)+set_target_properties(gameenginedevice PROPERTIES CXX_STANDARD 17)+target_link_libraries(gameenginedevice PUBLIC gameengine ww3d2)++# ---- generals.exe ---------------------------------------------------------+# BuildVersion.h and GeneratedVersion.h are normally written by Tools/+# buildVersionUpdate and Tools/versionUpdate as a pre-build step, from a build+# counter in the source tree. Both are three-line headers, so write them at+# configure time instead - it keeps two more VC6 tools out of the port, and+# Windows wants UAC elevation for exe names containing "version" anyway.+set(GENERATED ${CMAKE_CURRENT_BINARY_DIR}/generated)+file(WRITE ${GENERATED}/BuildVersion.h+"// Generated by CMake, standing in for Tools/buildVersionUpdate.\n"+"#define VERSION_STRING \"1.4.0\"\n"+"#define VERSION_MAJOR 1\n"+"#define VERSION_MINOR 4\n"+"#define VERSION_BUILDNUM 0\n")+file(WRITE ${GENERATED}/GeneratedVersion.h+"// Generated by CMake, standing in for Tools/versionUpdate.\n"+"#define LOCAL_BUILD_STRING \"0\"\n"+"#define VERSION_LOCALBUILDNUM 0\n"+"#define VERSION_BUILDUSER \"cmake\"\n"+"#define VERSION_BUILDLOC \"${CMAKE_HOST_SYSTEM_NAME}\"\n")++add_executable(generals WIN32 ${CMAKE_CURRENT_SOURCE_DIR}/Main/WinMain.cpp+ ${CMAKE_CURRENT_SOURCE_DIR}/Main/RTS.RC)+target_include_directories(generals PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/Main ${GENERATED})+set_target_properties(generals PROPERTIES CXX_STANDARD 17)+target_link_libraries(generals PRIVATE gameenginedevice+ winmm dsound wsock32 ole32 oleaut32 uuid)+# The game reads its data relative to the working directory, so it has to sit+# beside Run/'s .big files to find anything (Phase 5).+add_custom_command(TARGET generals POST_BUILD+ COMMAND ${CMAKE_COMMAND} -E copy_if_different+ $<TARGET_FILE:generals> ${CMAKE_CURRENT_SOURCE_DIR}/../Run/)+# ===========================================================================# Tests. Run with: ctest --test-dir build -C Release --output-on-failure# ===========================================================================diff --git a/GeneralsMD/Code/GameEngine/Include/Common/SafeDisc/.gitignore b/GeneralsMD/Code/GameEngine/Include/Common/SafeDisc/.gitignoreindex 5e7d2734c..faa2ac3ac 100644--- a/GeneralsMD/Code/GameEngine/Include/Common/SafeDisc/.gitignore+++ b/GeneralsMD/Code/GameEngine/Include/Common/SafeDisc/.gitignore@@ -2,3 +2,6 @@*# Except this file!.gitignore+# ...and CdaPfn.h, which is our own stub: the SafeDisc SDK is binary-only and+# absent, and a hand-written file cannot be re-fetched.+!CdaPfn.hdiff --git a/GeneralsMD/Code/GameEngine/Include/Common/SafeDisc/CdaPfn.h b/GeneralsMD/Code/GameEngine/Include/Common/SafeDisc/CdaPfn.hnew file mode 100644index 000000000..c606d8351--- /dev/null+++ b/GeneralsMD/Code/GameEngine/Include/Common/SafeDisc/CdaPfn.h@@ -0,0 +1,32 @@+/*+ * CdaPfn.h - stub for the SafeDisc "protected function" markers.+ *+ * The real header ships with the SafeDisc SDK, which is binary-only and was+ * stripped from the source release. Its macros wrap a function so the+ * copy-protection layer can verify it at runtime; with no SDK there is nothing+ * to verify, so they expand to nothing.+ *+ * WinMain.cpp is the only file in the tree that uses them (munkeeFunc, guarded+ * by _INTERNAL), so this is the whole surface: two macros and the two constants+ * they are called with.+ */++#pragma once++#ifndef __CDAPFN_H_+#define __CDAPFN_H_++#define CDAPFN_OVERHEAD_L1 0+#define CDAPFN_OVERHEAD_L2 0+#define CDAPFN_OVERHEAD_L3 0+#define CDAPFN_OVERHEAD_L4 0+#define CDAPFN_OVERHEAD_L5 0++#define CDAPFN_CONSTRAINT_NONE 0++// expands to an empty declaration - the call site writes the trailing semicolon+#define CDAPFN_DECLARE_GLOBAL( fn, overhead, constraint )++#define CDAPFN_ENDMARK( fn ) ((void)0)++#endif // __CDAPFN_H_diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DGameClient.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DGameClient.hindex af08378eb..c5b7e3af8 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DGameClient.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DGameClient.h@@ -48,7 +48,10 @@#include "W3DDevice/GameClient/W3DGameWindowManager.h"#include "W3DDevice/GameClient/W3DGameFont.h"#include "W3DDevice/GameClient/W3DDisplayStringManager.h"-#include "VideoDevice/Bink/BinkVideoPlayer.h"+// Bink is a binary-only SDK and is not in the source release, so the movies run+// through VideoPlayer itself: it parses Video.ini and then opens nothing, which+// makes every movie a zero-frame one that the callers skip.+#include "GameClient/VideoPlayer.h"#include "Win32Device/GameClient/Win32DIKeyboard.h"#include "Win32Device/GameClient/Win32DIMouse.h"#include "Win32Device/GameClient/Win32Mouse.h"@@ -112,7 +115,7 @@ protected:/// Manager for display stringsvirtual DisplayStringManager *createDisplayStringManager( void ) { return NEW W3DDisplayStringManager; }- virtual VideoPlayerInterface *createVideoPlayer( void ) { return NEW BinkVideoPlayer; }+ virtual VideoPlayerInterface *createVideoPlayer( void ) { return NEW VideoPlayer; }/// factory for creating the TerrainVisualvirtual TerrainVisual *createTerrainVisual( void ) { return NEW W3DTerrainVisual; }diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.hindex 2818820a4..d24082bee 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h@@ -82,7 +82,7 @@ public:static void shutdown(void); ///<release resources used by shadersstatic ChipsetType getChipset(void); ///<return current device chipset.static GraphicsVenderID getCurrentVendor(void) {return m_currentVendor;} ///<return current card vendor.- static getCurrentDriverVersion(void) {return m_driverVersion; } ///<return current driver version.+ static __int64 getCurrentDriverVersion(void) {return m_driverVersion; } ///<return current driver version.static Int getShaderPasses(ShaderTypes shader); ///<rendering passes required for shaderstatic Int setShader(ShaderTypes shader, Int pass); ///<enable specific shader pass.static Int setShroudTex(Int stage); ///<Set shroud in a texture stage.diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/camerashakesystem.h b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/camerashakesystem.hindex 75cbc212a..b20ee5989 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/camerashakesystem.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/camerashakesystem.h@@ -73,10 +73,10 @@ public:bool IsCameraShaking(void);void Update_Camera_Shaker(Vector3 camera_position, Vector3 * shaker_angles);-protected:-+ // public only so that camerashakesystem.cpp's DEFINE_AUTO_POOL can name the+ // type at file scope - VC6 let it reach a protected nested class, MSVC does not./**- ** CameraShakerClass+ ** CameraShakerClass** This class encapsulates the current state of a camera shaker. It is a multi-list object** and is allocated in pools.*/@@ -102,6 +102,8 @@ protected:Vector3 Phi;};+protected:+MultiListClass<CameraShakerClass> CameraShakerList;};diff --git a/GeneralsMD/Code/GameEngineDevice/Include/Win32Device/Common/Win32GameEngine.h b/GeneralsMD/Code/GameEngineDevice/Include/Win32Device/Common/Win32GameEngine.hindex e5cbd2c34..bbe411976 100644--- a/GeneralsMD/Code/GameEngineDevice/Include/Win32Device/Common/Win32GameEngine.h+++ b/GeneralsMD/Code/GameEngineDevice/Include/Win32Device/Common/Win32GameEngine.h@@ -38,7 +38,9 @@#include "Common/GameEngine.h"#include "GameLogic/GameLogic.h"#include "GameNetwork/NetworkInterface.h"-#include "MilesAudioDevice/MilesAudioManager.h"+// The Miles SDK is binary-only and absent from the source release, so the audio+// device is the silent one in Stubs/ instead of MilesAudioManager.+#include "NullAudioManager.h"#include "Win32Device/Common/Win32BIGFileSystem.h"#include "Win32Device/Common/Win32LocalFileSystem.h"#include "W3DDevice/Common/W3DModuleFactory.h"@@ -102,6 +104,6 @@ inline ParticleSystemManager* Win32GameEngine::createParticleSystemManager( voidinline NetworkInterface *Win32GameEngine::createNetwork( void ) { return NetworkInterface::createNetwork(); }inline Radar *Win32GameEngine::createRadar( void ) { return NEW W3DRadar; }inline WebBrowser *Win32GameEngine::createWebBrowser( void ) { return NEW CComObject<W3DWebBrowser>; }-inline AudioManager *Win32GameEngine::createAudioManager( void ) { return NEW MilesAudioManager; }+inline AudioManager *Win32GameEngine::createAudioManager( void ) { return NEW NullAudioManager; }#endif // end __WIN32GAMEENGINE_H_diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cppindex e6dce9d57..da6a5fe6e 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp@@ -1695,6 +1695,7 @@ void BaseHeightMapRenderObjClass::updateShorelineTiles(Int minX, Int minY, Int mshoreLineSortInfosXMajor=TRUE;}+ Int j; // VC6 leaked the 'j' of an earlier for() out to hereif (shoreLineSortInfosXMajor)for (Int i=minX; i<maxX; i++)for (j=minY; j<maxY; j++)@@ -2697,9 +2698,12 @@ void BaseHeightMapRenderObjClass::renderShoreLinesSorted(CameraClass *pCamera)try {//Loop over visible terrain and extract all the tiles that need shoreline blend+ // VC6 let these outlive their for(), and the flushVertexBuffer labels+ // below read them to record how far the batch got.+ Int x, y;if (m_shoreLineSortInfosXMajor) //map is wider than taller.- {- for (Int x=drawStartX; x<drawEdgeX; x++)+ {+ for (x=drawStartX; x<drawEdgeX; x++){ //figure out how many tiles are available in this columnshoreLineTileSortInfo *sortInfo=&m_shoreLineSortInfos[x];@@ -2819,7 +2823,7 @@ flushVertexBuffer0:}else{- for (Int y=drawStartY; y<drawEdgeY; y++)+ for (y=drawStartY; y<drawEdgeY; y++){ //figure out how many tiles are available in this rowshoreLineTileSortInfo *sortInfo=&m_shoreLineSortInfos[y];diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cppindex 9bae981de..f24259492 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp@@ -1074,7 +1074,8 @@ void W3DModelDrawModuleData::validateStuffForTimeAndWeather(const Drawable* drawm_validated |= mode;- for (ModelConditionVector::iterator c_it = m_conditionStates.begin(); c_it != m_conditionStates.end(); ++c_it)+ ModelConditionVector::iterator c_it; // VC6 leaked it out to the transition loop below+ for (c_it = m_conditionStates.begin(); c_it != m_conditionStates.end(); ++c_it){if (!c_it->matchesMode(false, false) && !c_it->matchesMode(night, snowy))continue;@@ -3448,7 +3449,8 @@ Int W3DModelDraw::getPristineBonePositionsForConditionState(Int posCount = 0;Int endIndex = (startIndex == 0) ? 0 : 99;char buffer[256];- for (Int i = startIndex; i <= endIndex; ++i)+ Int i; // VC6 leaked it out to the copy-out loop below+ for (i = startIndex; i <= endIndex; ++i){if (i == 0)strcpy(buffer, boneNamePrefix);@@ -3604,7 +3606,8 @@ Int W3DModelDraw::getCurrentBonePositions(Int posCount = 0;Int endIndex = (startIndex == 0) ? 0 : 99;char buffer[256];- for (Int i = startIndex; i <= endIndex; ++i)+ Int i; // VC6 leaked it out to the copy-out loop below+ for (i = startIndex; i <= endIndex; ++i){if (i == 0)strcpy(buffer, boneNamePrefix);@@ -4303,7 +4306,8 @@ void W3DModelDrawModuleData::xfer( Xfer *x )x->xferInt(&(bone->boneIndex));x->xferUser(&(bone->mtx), sizeof(Matrix3D));}- for (Int i=0; i<MAX_TURRETS; ++i)+ Int i; // VC6 leaked it out to the weapon-slot loop below+ for (i=0; i<MAX_TURRETS; ++i){x->xferInt(&(info->m_turrets[i].m_turretAngleBone));x->xferInt(&(info->m_turrets[i].m_turretPitchBone));diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DBufferManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DBufferManager.cppindex 55d5fe4ab..1be7e5f65 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DBufferManager.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DBufferManager.cpp@@ -62,7 +62,8 @@ W3DBufferManager::W3DBufferManager(void)m_numEmptyIndexSlotsAllocated=0;m_numEmptyIndexBuffersAllocated=0;- for (Int i=0; i<MAX_FVF; i++)+ Int i; // VC6 for-scope leak+ for (i=0; i<MAX_FVF; i++)m_W3DVertexBuffers[i]=NULL;for (i=0; i<MAX_FVF; i++)for (Int j=0; j<MAX_VB_SIZES; j++)diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cppindex 1fc041ff7..66571fd88 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp@@ -701,7 +701,12 @@ Int W3DShadowGeometry::initFromHLOD(RenderObjClass *robj)}-#if (1) //(cnc3)(gth) Support for ShaderMeshes!+// ponytail: off, because wwshade is not built (no .dsp ever linked wwshade.lib+// either, and its bump shaders need the missing shdpp/NVASM tools). ShdMeshClass+// is the only thing that returns CLASSID_SHDMESH, so with wwshade absent this test+// can never be true - keeping it on only costs two unresolved externals at link.+// Turn it back to 1 the day wwshade builds.+#if (0) //(cnc3)(gth) Support for ShaderMeshes!// I'm coding this as a completely independent block rather than re-factoring the code above// because it will probably save us pain in future merges.if (hlod->Peek_Lod_Model(top,i) && hlod->Peek_Lod_Model(top,i)->Class_ID() == RenderObjClass::CLASSID_SHDMESH)diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cppindex 436361f5b..0e7942a6b 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DAssetManager.cpp@@ -440,8 +440,9 @@ static void remapTexture16Bit(Int dx, Int dy, Int pitch, SurfaceClass::SurfaceDeVector3 rgb,v_color((float)((color>>16)&0xff)/255.0f/255.0f,(float)((color>>8)&0xff)/255.0f/255.0f,(float)(color&0xff)/255.0f/255.0f);//Generate a new color gradient palette based on reference color- for (Int y=0; y<TEAM_COLOR_PALETTE_SIZE; y++)- {+ Int y; // VC6 for-scope leak+ for (y=0; y<TEAM_COLOR_PALETTE_SIZE; y++)+ {rgb.X=(Real)houseColorScale[y]*v_color.X;rgb.Y=(Real)houseColorScale[y]*v_color.Y;rgb.Z=(Real)houseColorScale[y]*v_color.Z;@@ -543,8 +544,9 @@ static void remapTexture32Bit(Int dx, Int dy, Int pitch, SurfaceClass::SurfaceDeVector3 rgb,v_color((float)((color>>16)&0xff)/255.0f/255.0f,(float)((color>>8)&0xff)/255.0f/255.0f,(float)(color&0xff)/255.0f/255.0f);//Generate a new color gradient palette based on reference color- for (Int y=0; y<TEAM_COLOR_PALETTE_SIZE; y++)- {+ Int y; // VC6 for-scope leak+ for (y=0; y<TEAM_COLOR_PALETTE_SIZE; y++)+ {rgb.X=(Real)houseColorScale[y]*v_color.X;rgb.Y=(Real)houseColorScale[y]*v_color.Y;rgb.Z=(Real)houseColorScale[y]*v_color.Z;@@ -796,7 +798,7 @@ RenderObjClass * W3DAssetManager::Create_Render_Obj({// If we didn't find one, try to load on demandchar filename [MAX_PATH];- char *mesh_name = ::strchr (name, '.');+ const char *mesh_name = ::strchr (name, '.');if (mesh_name != NULL){::lstrcpyn(filename, name, ((int)mesh_name) - ((int)name) + 1);diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cppindex 5ad225c63..72df7e276 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DDisplay.cpp@@ -1461,7 +1461,7 @@ void W3DDisplay::gatherDebugStats( void )unibuffer.concat( L"\nModelStates: " );ModelConditionFlags mcFlags = draw->getModelConditionFlags();- const numEntriesPerLine = 4;+ const int numEntriesPerLine = 4;int lineCount = 0;for( int i = 0; i < MODELCONDITION_COUNT; i++ )@@ -1557,7 +1557,10 @@ void W3DDisplay::drawCurrentDebugDisplay( void )if ( m_debugDisplay && m_debugDisplayCallback ){m_debugDisplay->reset();- m_debugDisplayCallback( m_debugDisplay, m_debugDisplayUserData );+ // third parameter is the optional dump-to-file the stat dumper uses; on+ // screen there is no file, so NULL - Zero Hour grew the typedef and+ // never updated this one call.+ m_debugDisplayCallback( m_debugDisplay, m_debugDisplayUserData, NULL );}}} // end drawCurrentDebugDisplaydiff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DMouse.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DMouse.cppindex 7e9cb2aee..1f9c2fafb 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DMouse.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DMouse.cpp@@ -244,7 +244,8 @@ void W3DMouse::initD3DAssets(void)void W3DMouse::freeD3DAssets(void){//free pointers to texture surfaces.- for (Int i=0; i<MAX_2D_CURSOR_ANIM_FRAMES; i++)+ Int i; // VC6 for-scope leak+ for (i=0; i<MAX_2D_CURSOR_ANIM_FRAMES; i++)REF_PTR_RELEASE(m_currentD3DSurface[i]);//free textures.diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cppindex 6fd85e4df..3eaf89f51 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DScene.cpp@@ -97,7 +97,8 @@ RTS3DScene::RTS3DScene()setName("RTS3DScene");m_drawTerrainOnly = false;m_numGlobalLights=0;- for (Int i=0; i<LightEnvironmentClass::MAX_LIGHTS; i++)+ Int i; // VC6 for-scope leak+ for (i=0; i<LightEnvironmentClass::MAX_LIGHTS; i++){ m_globalLight[i]=NULL;m_infantryLight[i]=NEW_REF( LightClass, (LightClass::DIRECTIONAL) );}@@ -200,7 +201,8 @@ RTS3DScene::RTS3DScene()//=============================================================================RTS3DScene::~RTS3DScene(){- for (Int i=0; i<LightEnvironmentClass::MAX_LIGHTS; i++)+ Int i; // VC6 for-scope leak+ for (i=0; i<LightEnvironmentClass::MAX_LIGHTS; i++){REF_PTR_RELEASE(m_globalLight[i]);REF_PTR_RELEASE(m_infantryLight[i]);@@ -1340,7 +1342,8 @@ void RTS3DScene::flushOccludedObjectsIntoStencil(RenderInfoClass & rinfo)//Clear pointers into temporary arrays where each player's objects will be stored.//We do this so that all objects are sorted by color which reduces the number of//state changes needed when drawing them.- for (Int i=0; i<MAX_PLAYER_COUNT; i++)+ Int i; // VC6 leaked it out to every loop below+ for (i=0; i<MAX_PLAYER_COUNT; i++){ lastPlayerObject[i]=&playerObjects[i][0];playerColorIndex[i]=-1;}@@ -1559,7 +1562,8 @@ void RTS3DScene::flushOccludedObjects(RenderInfoClass & rinfo)//First draw all the solid colored models///@todo: Optimize this so that the extra passes don't actually install the material since it's all the same.rinfo.Push_Override_Flags(RenderInfoClass::RINFO_OVERRIDE_ADDITIONAL_PASSES_ONLY); //disable textures- for (Int i=0; i<m_occludedObjectsCount; i++)+ Int i; // VC6 leaked it out to the second pass below+ for (i=0; i<m_occludedObjectsCount; i++){robj=m_potentialOccludees[i];diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cppindex 8848153f5..5f0e68948 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp@@ -2694,7 +2694,8 @@ void W3DShaderManager::shutdown(void)m_currentShader = ST_INVALID;m_currentFilter = FT_NULL_FILTER;//release any assets associated with a shader (vertex/pixel shaders, textures, etc.)- for (Int i=0; i<W3DShaderManager::ST_MAX; i++) {+ Int i; // VC6 for-scope leak+ for (i=0; i<W3DShaderManager::ST_MAX; i++) {if (W3DShaders[i]) {W3DShaders[i]->shutdown();}diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cppindex 36f81b271..ed0b0f37f 100644--- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp+++ b/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp@@ -103,7 +103,8 @@ class TestSeismicFilter : public SeismicSimulationFilterBasefor ( Real *t = workspace; t < workspaceEnd; ++t ) *t = 0.0f;// clear the workspace- for (Int x = 0; x < radius; ++x)+ Int x; // VC6 leaked it out to the copy-back loop below+ for (x = 0; x < radius; ++x){for (Int y = 0; y < radius; ++y){diff --git a/GeneralsMD/Code/Libraries/Include/Lib/BaseType.h b/GeneralsMD/Code/Libraries/Include/Lib/BaseType.hindex 63ccc97a6..6332778b7 100644--- a/GeneralsMD/Code/Libraries/Include/Lib/BaseType.h+++ b/GeneralsMD/Code/Libraries/Include/Lib/BaseType.h@@ -169,6 +169,17 @@ inline Real deg2rad(Real rad) { return rad * (PI/180); }//-----------------------------------------------------------------------------// For twiddling bits//-----------------------------------------------------------------------------+// winnt.h claims BitTest for the _bittest intrinsic. Pull it in here (windef.h+// is the smallest header that reaches it) so its include guard is already+// closed, then take the name back: otherwise any header that gets to winnt.h+// after this one silently rewrites every use below into an intrinsic that takes+// a LONG* and the game's bit fields stop compiling. Not <windows.h>: that also+// drags in winsock.h, and the device code includes winsock2.h.+#if defined(_M_IX86) && !defined(_X86_)+#define _X86_ // windows.h does this before it reaches windef.h, and winnt.h+#endif // #errors with "No Target Architecture" without it+#include <windef.h>+#undef BitTest#define BitTest( x, i ) ( ( (x) & (i) ) != 0 )#define BitSet( x, i ) ( (x) |= (i) )#define BitClear( x, i ) ( (x ) &= ~(i) )diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/Except.cpp b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/Except.cppindex 18a1f7a3f..8ed9269dd 100644--- a/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/Except.cpp+++ b/GeneralsMD/Code/Libraries/Source/WWVegas/WWLib/Except.cpp@@ -168,6 +168,12 @@ static char const *ImagehelpFunctionNames[] =* HISTORY: ** 8/22/00 11:42AM ST : Created **=============================================================================================*/+// The debug library replaces _purecall too (debug_purecall.cpp, which reports the+// call through DCRASH_RELEASE instead of an int 3), and the exe links both libs -+// two definitions of a CRT symbol is a hard link error. The debug one wins: it+// says something in a Release build, this one only breaks into a debugger that is+// not attached.+#if 0int __cdecl _purecall(void){int return_code = 0;@@ -182,6 +188,7 @@ int __cdecl _purecall(void)return(return_code);}+#endifdiff --git a/GeneralsMD/Code/Main/RTS.RC b/GeneralsMD/Code/Main/RTS.RCindex a0fb57d2e..7794b3c33 100644--- a/GeneralsMD/Code/Main/RTS.RC+++ b/GeneralsMD/Code/Main/RTS.RC@@ -7,7 +7,10 @@//// Generated from the TEXTINCLUDE 2 resource.//-#include "afxres.h"+// afxres.h is MFC's, and MFC is an optional VS component this port does not+// need - winres.h is the Windows SDK's equivalent for plain resource scripts,+// and the only thing in here is the application icon.+#include <winres.h>/////////////////////////////////////////////////////////////////////////////#undef APSTUDIO_READONLY_SYMBOLSdiff --git a/GeneralsMD/Code/Stubs/NullAudioManager.h b/GeneralsMD/Code/Stubs/NullAudioManager.hnew file mode 100644index 000000000..2078a268b--- /dev/null+++ b/GeneralsMD/Code/Stubs/NullAudioManager.h@@ -0,0 +1,110 @@+/*+ * NullAudioManager - the silent audio device.+ *+ * The shipping game plays sound through MilesAudioManager, which needs the+ * Miles Sound System SDK: binary-only, not part of the source release, and not+ * reconstructible from the headers. So the exe gets an AudioManager that+ * answers every device question with "no provider, no channels, nothing+ * playing" and drops the audio the engine hands it.+ *+ * Everything above the device layer is the real thing - AudioManager's own code+ * still parses the INI files, tracks events and requests, and runs the music and+ * sound managers. Only the part that would have reached a sound card is gone.+ *+ * Swapping in a real OpenAL/miniaudio device later means writing another+ * subclass and changing Win32GameEngine::createAudioManager; nothing else in the+ * game knows which device it got.+ */++#pragma once++#ifndef __NULLAUDIOMANAGER_H_+#define __NULLAUDIOMANAGER_H_++#include "Common/GameAudio.h"+#include "Common/AsciiString.h"++class NullAudioManager : public AudioManager+{+public:+ NullAudioManager() : m_speakerType( 0 ) {}+ virtual ~NullAudioManager() {}++#if defined(_DEBUG) || defined(_INTERNAL)+ virtual void audioDebugDisplay( DebugDisplayInterface *, void *, FILE * = NULL ) {}+#endif++ // stop/pause/resume: nothing is playing, so there is nothing to act on+ virtual void stopAudio( AudioAffect ) {}+ virtual void pauseAudio( AudioAffect ) {}+ virtual void resumeAudio( AudioAffect ) {}+ virtual void pauseAmbient( Bool ) {}++ virtual void killAudioEventImmediately( AudioHandle ) {}++ virtual void nextMusicTrack( void ) {}+ virtual void prevMusicTrack( void ) {}+ virtual Bool isMusicPlaying( void ) const { return FALSE; }+ /* The load screens wait on this one, so a silent device has to claim the+ track finished or the wait never ends. */+ virtual Bool hasMusicTrackCompleted( const AsciiString&, Int ) const { return TRUE; }+ virtual AsciiString getMusicTrackName( void ) const { return AsciiString::TheEmptyString; }++ virtual void openDevice( void ) {}+ virtual void closeDevice( void ) {}+ virtual void *getDevice( void ) { return NULL; }++ virtual void notifyOfAudioCompletion( UnsignedInt, UnsignedInt ) {}++ /* One provider named "Software" keeps the options screen from showing an+ empty list; selecting it is a no-op. */+ virtual UnsignedInt getProviderCount( void ) const { return 1; }+ virtual AsciiString getProviderName( UnsignedInt providerNum ) const+ { return providerNum == 0 ? AsciiString( "Software" ) : AsciiString::TheEmptyString; }+ virtual UnsignedInt getProviderIndex( AsciiString ) const { return 0; }+ virtual void selectProvider( UnsignedInt ) {}+ virtual void unselectProvider( void ) {}+ virtual UnsignedInt getSelectedProvider( void ) const { return 0; }+ virtual void setSpeakerType( UnsignedInt speakerType ) { m_speakerType = speakerType; }+ virtual UnsignedInt getSpeakerType( void ) { return m_speakerType; }++ virtual UnsignedInt getNum2DSamples( void ) const { return 0; }+ virtual UnsignedInt getNum3DSamples( void ) const { return 0; }+ virtual UnsignedInt getNumStreams( void ) const { return 0; }++ /* No channels are in use, so no event can violate a limit or lose a+ priority contest, and nothing is ever already playing. */+ virtual Bool doesViolateLimit( AudioEventRTS * ) const { return FALSE; }+ virtual Bool isPlayingLowerPriority( AudioEventRTS * ) const { return FALSE; }+ virtual Bool isPlayingAlready( AudioEventRTS * ) const { return FALSE; }+ virtual Bool isObjectPlayingVoice( UnsignedInt ) const { return FALSE; }++ virtual void adjustVolumeOfPlayingAudio( AsciiString, Real ) {}+ virtual void removePlayingAudio( AsciiString ) {}+ virtual void removeAllDisabledAudio() {}++ virtual Bool has3DSensitiveStreamsPlaying( void ) const { return FALSE; }++ /* Bink is stubbed out too, so nobody asks for this handle. */+ virtual void *getHandleForBink( void ) { return NULL; }+ virtual void releaseHandleForBink( void ) {}++ virtual void friend_forcePlayAudioEventRTS( const AudioEventRTS * ) {}++ virtual void setPreferredProvider( AsciiString ) {}+ virtual void setPreferredSpeaker( AsciiString ) {}++ /* Scripts time waits off this; a zero-length file just means the wait ends+ on the next frame. */+ virtual Real getFileLengthMS( AsciiString ) const { return 0.0f; }++ virtual void closeAnySamplesUsingFile( const void * ) {}++protected:+ virtual void setDeviceListenerPosition( void ) {}++private:+ UnsignedInt m_speakerType;+};++#endif // __NULLAUDIOMANAGER_H_diff --git a/GeneralsMD/Code/Tests/test_gameengine.cpp b/GeneralsMD/Code/Tests/test_gameengine.cppindex b7a40016a..93ccd23ab 100644--- a/GeneralsMD/Code/Tests/test_gameengine.cpp+++ b/GeneralsMD/Code/Tests/test_gameengine.cpp@@ -159,6 +159,22 @@ TEST(boot_memory_manager)CHECK( wcscmp( u.str(), L"Command & Conquer: Generals" ) == 0 );}+/* winnt.h defines BitTest as the _bittest intrinsic, which takes a LONG*, so if+ windows.h ever gets to redefine the game's macro then every bit-flag test in+ the engine either stops compiling or silently changes meaning. BaseType.h+ pulls windef.h in first and then takes the name back; this fails to compile+ if that ever regresses, and checks the semantics while it is here. */+TEST(bittest_macro_is_the_games_not_the_intrinsics)+{+ UnsignedInt flags = 0x0A; // bits 1 and 3++ CHECK( BitTest( flags, 0x02 ) );+ CHECK( BitTest( flags, 0x08 ) );+ CHECK( BitTest( flags, 0x04 ) == 0 );+ /* the intrinsic takes a bit *index*, the macro takes a mask - 0x0A & 0x0A */+ CHECK( BitTest( flags, 0x0A ) );+}+TEST(name_key_generator_round_trips){CHECK( bootOnce() );