diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index d98066d1bf..93470c0745 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -3,12 +3,15 @@ add_library(corei_gameengine_include INTERFACE) add_library(corei_libraries_include INTERFACE) add_library(corei_libraries_source_wwvegas INTERFACE) add_library(corei_libraries_source_wwvegas_wwlib INTERFACE) +add_library(corei_main INTERFACE) add_library(corei_always INTERFACE) target_include_directories(corei_gameengine_include INTERFACE "GameEngine/Include") target_include_directories(corei_libraries_include INTERFACE "Libraries/Include") target_include_directories(corei_libraries_source_wwvegas INTERFACE "Libraries/Source/WWVegas") target_include_directories(corei_libraries_source_wwvegas_wwlib INTERFACE "Libraries/Source/WWVegas/WWLib") +target_include_directories(corei_main INTERFACE "Main") + target_link_libraries(corei_always INTERFACE core_utility corei_libraries_include @@ -24,6 +27,6 @@ add_subdirectory(Libraries) add_subdirectory(GameEngine) # Platform specific GameEngine code -# add_subdirectory(GameEngineDevice) +add_subdirectory(GameEngineDevice) add_subdirectory(Tools) diff --git a/Core/GameEngine/CMakeLists.txt b/Core/GameEngine/CMakeLists.txt index 1a76d97095..f7d09c8ec0 100644 --- a/Core/GameEngine/CMakeLists.txt +++ b/Core/GameEngine/CMakeLists.txt @@ -1,8 +1,8 @@ set(GAMEENGINE_SRC # Include/Common/AcademyStats.h # Include/Common/ActionManager.h -# Include/Common/ArchiveFile.h -# Include/Common/ArchiveFileSystem.h + Include/Common/ArchiveFile.h + Include/Common/ArchiveFileSystem.h # Include/Common/AsciiString.h # Include/Common/AudioAffect.h # Include/Common/AudioEventInfo.h @@ -37,8 +37,8 @@ set(GAMEENGINE_SRC # Include/Common/encrypt.h # Include/Common/Energy.h # Include/Common/Errors.h -# Include/Common/file.h -# Include/Common/FileSystem.h + Include/Common/file.h + Include/Common/FileSystem.h # Include/Common/FunctionLexicon.h # Include/Common/GameAudio.h # Include/Common/GameCommon.h @@ -63,8 +63,8 @@ set(GAMEENGINE_SRC # Include/Common/Language.h # Include/Common/LatchRestore.h # Include/Common/List.h -# Include/Common/LocalFile.h -# Include/Common/LocalFileSystem.h + Include/Common/LocalFile.h + Include/Common/LocalFileSystem.h # Include/Common/MapObject.h # Include/Common/MapReaderWriterInfo.h # Include/Common/MessageStream.h @@ -91,7 +91,7 @@ set(GAMEENGINE_SRC # Include/Common/QuickmatchPreferences.h # Include/Common/QuotedPrintable.h # Include/Common/Radar.h -# Include/Common/RAMFile.h + Include/Common/RAMFile.h # Include/Common/RandomValue.h # Include/Common/Recorder.h # Include/Common/Registry.h @@ -113,7 +113,7 @@ set(GAMEENGINE_SRC # Include/Common/StatsCollector.h # Include/Common/STLTypedefs.h Include/Common/STLUtils.h -# Include/Common/StreamingArchiveFile.h + Include/Common/StreamingArchiveFile.h # Include/Common/SubsystemInterface.h # Include/Common/SystemInfo.h # Include/Common/Team.h @@ -630,8 +630,8 @@ set(GAMEENGINE_SRC # Source/Common/SkirmishBattleHonors.cpp # Source/Common/StateMachine.cpp # Source/Common/StatsCollector.cpp -# Source/Common/System/ArchiveFile.cpp -# Source/Common/System/ArchiveFileSystem.cpp + Source/Common/System/ArchiveFile.cpp + Source/Common/System/ArchiveFileSystem.cpp # Source/Common/System/AsciiString.cpp # Source/Common/System/BuildAssistant.cpp # Source/Common/System/CDManager.cpp @@ -641,8 +641,8 @@ set(GAMEENGINE_SRC # Source/Common/System/Directory.cpp # Source/Common/System/DisabledTypes.cpp # Source/Common/System/encrypt.cpp -# Source/Common/System/File.cpp -# Source/Common/System/FileSystem.cpp + Source/Common/System/File.cpp + Source/Common/System/FileSystem.cpp # Source/Common/System/FunctionLexicon.cpp # Source/Common/System/GameCommon.cpp #Source/Common/System/GameMemory.cpp # is conditionally appended @@ -650,19 +650,19 @@ set(GAMEENGINE_SRC # Source/Common/System/Geometry.cpp # Source/Common/System/KindOf.cpp # Source/Common/System/List.cpp -# Source/Common/System/LocalFile.cpp -# Source/Common/System/LocalFileSystem.cpp + Source/Common/System/LocalFile.cpp + Source/Common/System/LocalFileSystem.cpp #Source/Common/System/MemoryInit.cpp # is conditionally appended # Source/Common/System/ObjectStatusTypes.cpp # Source/Common/System/QuotedPrintable.cpp # Source/Common/System/Radar.cpp -# Source/Common/System/RAMFile.cpp + Source/Common/System/RAMFile.cpp # Source/Common/System/registry.cpp # Source/Common/System/SaveGame/GameState.cpp # Source/Common/System/SaveGame/GameStateMap.cpp # Source/Common/System/Snapshot.cpp # Source/Common/System/StackDump.cpp -# Source/Common/System/StreamingArchiveFile.cpp + Source/Common/System/StreamingArchiveFile.cpp # Source/Common/System/SubsystemInterface.cpp # Source/Common/System/Trig.cpp # Source/Common/System/UnicodeString.cpp diff --git a/GeneralsMD/Code/GameEngine/Include/Common/ArchiveFile.h b/Core/GameEngine/Include/Common/ArchiveFile.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/ArchiveFile.h rename to Core/GameEngine/Include/Common/ArchiveFile.h diff --git a/GeneralsMD/Code/GameEngine/Include/Common/ArchiveFileSystem.h b/Core/GameEngine/Include/Common/ArchiveFileSystem.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/ArchiveFileSystem.h rename to Core/GameEngine/Include/Common/ArchiveFileSystem.h diff --git a/GeneralsMD/Code/GameEngine/Include/Common/FileSystem.h b/Core/GameEngine/Include/Common/FileSystem.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/FileSystem.h rename to Core/GameEngine/Include/Common/FileSystem.h diff --git a/GeneralsMD/Code/GameEngine/Include/Common/LocalFile.h b/Core/GameEngine/Include/Common/LocalFile.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/LocalFile.h rename to Core/GameEngine/Include/Common/LocalFile.h diff --git a/GeneralsMD/Code/GameEngine/Include/Common/LocalFileSystem.h b/Core/GameEngine/Include/Common/LocalFileSystem.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/LocalFileSystem.h rename to Core/GameEngine/Include/Common/LocalFileSystem.h diff --git a/GeneralsMD/Code/GameEngine/Include/Common/RAMFile.h b/Core/GameEngine/Include/Common/RAMFile.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/RAMFile.h rename to Core/GameEngine/Include/Common/RAMFile.h diff --git a/GeneralsMD/Code/GameEngine/Include/Common/StreamingArchiveFile.h b/Core/GameEngine/Include/Common/StreamingArchiveFile.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/StreamingArchiveFile.h rename to Core/GameEngine/Include/Common/StreamingArchiveFile.h diff --git a/GeneralsMD/Code/GameEngine/Include/Common/file.h b/Core/GameEngine/Include/Common/file.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/file.h rename to Core/GameEngine/Include/Common/file.h diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/ArchiveFile.cpp b/Core/GameEngine/Source/Common/System/ArchiveFile.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/System/ArchiveFile.cpp rename to Core/GameEngine/Source/Common/System/ArchiveFile.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/ArchiveFileSystem.cpp b/Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/System/ArchiveFileSystem.cpp rename to Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/File.cpp b/Core/GameEngine/Source/Common/System/File.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/System/File.cpp rename to Core/GameEngine/Source/Common/System/File.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp b/Core/GameEngine/Source/Common/System/FileSystem.cpp similarity index 99% rename from GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp rename to Core/GameEngine/Source/Common/System/FileSystem.cpp index 14ff99f176..164f72ee09 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/FileSystem.cpp +++ b/Core/GameEngine/Source/Common/System/FileSystem.cpp @@ -272,7 +272,7 @@ Bool FileSystem::createDirectory(AsciiString directory) Bool FileSystem::areMusicFilesOnCD() { #if 1 - return TRUE; + return TRUE; #else if (!TheCDManager) { DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - No CD Manager; returning false")); @@ -291,7 +291,11 @@ Bool FileSystem::areMusicFilesOnCD() cdRoot = cdi->getPath(); if (!cdRoot.endsWith("\\")) cdRoot.concat("\\"); +#if RTS_GENERALS + cdRoot.concat("gensec.big"); +#elif RTS_ZEROHOUR cdRoot.concat("genseczh.big"); +#endif DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - checking for %s", cdRoot.str())); File *musicBig = TheLocalFileSystem->openFile(cdRoot.str()); if (musicBig) diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/LocalFile.cpp b/Core/GameEngine/Source/Common/System/LocalFile.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/System/LocalFile.cpp rename to Core/GameEngine/Source/Common/System/LocalFile.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/LocalFileSystem.cpp b/Core/GameEngine/Source/Common/System/LocalFileSystem.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/System/LocalFileSystem.cpp rename to Core/GameEngine/Source/Common/System/LocalFileSystem.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/RAMFile.cpp b/Core/GameEngine/Source/Common/System/RAMFile.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/System/RAMFile.cpp rename to Core/GameEngine/Source/Common/System/RAMFile.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/StreamingArchiveFile.cpp b/Core/GameEngine/Source/Common/System/StreamingArchiveFile.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/System/StreamingArchiveFile.cpp rename to Core/GameEngine/Source/Common/System/StreamingArchiveFile.cpp diff --git a/Core/GameEngineDevice/CMakeLists.txt b/Core/GameEngineDevice/CMakeLists.txt new file mode 100644 index 0000000000..ee4556c332 --- /dev/null +++ b/Core/GameEngineDevice/CMakeLists.txt @@ -0,0 +1,248 @@ +set(GAMEENGINEDEVICE_SRC +# Include/MilesAudioDevice/MilesAudioManager.h +# Include/VideoDevice/Bink/BinkVideoPlayer.h +# Include/W3DDevice/Common/W3DConvert.h +# Include/W3DDevice/Common/W3DFunctionLexicon.h +# Include/W3DDevice/Common/W3DModuleFactory.h +# Include/W3DDevice/Common/W3DRadar.h +# Include/W3DDevice/Common/W3DThingFactory.h +# Include/W3DDevice/GameClient/BaseHeightMap.h +# Include/W3DDevice/GameClient/camerashakesystem.h +# Include/W3DDevice/GameClient/FlatHeightMap.h +# Include/W3DDevice/GameClient/HeightMap.h +# Include/W3DDevice/GameClient/Module/W3DDebrisDraw.h +# Include/W3DDevice/GameClient/Module/W3DDefaultDraw.h +# Include/W3DDevice/GameClient/Module/W3DDependencyModelDraw.h +# Include/W3DDevice/GameClient/Module/W3DLaserDraw.h +# Include/W3DDevice/GameClient/Module/W3DModelDraw.h +# Include/W3DDevice/GameClient/Module/W3DOverlordAircraftDraw.h +# Include/W3DDevice/GameClient/Module/W3DOverlordTankDraw.h +# Include/W3DDevice/GameClient/Module/W3DOverlordTruckDraw.h +# Include/W3DDevice/GameClient/Module/W3DPoliceCarDraw.h +# Include/W3DDevice/GameClient/Module/W3DProjectileStreamDraw.h +# Include/W3DDevice/GameClient/Module/W3DPropDraw.h +# Include/W3DDevice/GameClient/Module/W3DRopeDraw.h +# Include/W3DDevice/GameClient/Module/W3DScienceModelDraw.h +# Include/W3DDevice/GameClient/Module/W3DSupplyDraw.h +# Include/W3DDevice/GameClient/Module/W3DTankDraw.h +# Include/W3DDevice/GameClient/Module/W3DTankTruckDraw.h +# Include/W3DDevice/GameClient/Module/W3DTracerDraw.h +# Include/W3DDevice/GameClient/Module/W3DTreeDraw.h +# Include/W3DDevice/GameClient/Module/W3DTruckDraw.h +# Include/W3DDevice/GameClient/TerrainTex.h +# Include/W3DDevice/GameClient/TileData.h +# Include/W3DDevice/GameClient/W3DAssetManager.h +# Include/W3DDevice/GameClient/W3DAssetManagerExposed.h +# Include/W3DDevice/GameClient/W3DBibBuffer.h +# Include/W3DDevice/GameClient/W3DBridgeBuffer.h +# Include/W3DDevice/GameClient/W3DBufferManager.h +# Include/W3DDevice/GameClient/W3DCustomEdging.h +# Include/W3DDevice/GameClient/W3DCustomScene.h +# Include/W3DDevice/GameClient/W3DDebugDisplay.h +# Include/W3DDevice/GameClient/W3DDebugIcons.h +# Include/W3DDevice/GameClient/W3DDisplay.h +# Include/W3DDevice/GameClient/W3DDisplayString.h +# Include/W3DDevice/GameClient/W3DDisplayStringManager.h +# Include/W3DDevice/GameClient/W3DDynamicLight.h +# Include/W3DDevice/GameClient/W3DFileSystem.h +# Include/W3DDevice/GameClient/W3DGadget.h +# Include/W3DDevice/GameClient/W3DGameClient.h +# Include/W3DDevice/GameClient/W3DGameFont.h +# Include/W3DDevice/GameClient/W3DGameWindow.h +# Include/W3DDevice/GameClient/W3DGameWindowManager.h +# Include/W3DDevice/GameClient/W3DGUICallbacks.h +# Include/W3DDevice/GameClient/W3DInGameUI.h +# Include/W3DDevice/GameClient/W3DMirror.h +# Include/W3DDevice/GameClient/W3DMouse.h +# Include/W3DDevice/GameClient/W3DParticleSys.h +# Include/W3DDevice/GameClient/W3DPoly.h +# Include/W3DDevice/GameClient/W3DProjectedShadow.h +# Include/W3DDevice/GameClient/W3DPropBuffer.h +# Include/W3DDevice/GameClient/W3DRoadBuffer.h +# Include/W3DDevice/GameClient/W3DScene.h +# Include/W3DDevice/GameClient/W3DShaderManager.h +# Include/W3DDevice/GameClient/W3DShadow.h +# Include/W3DDevice/GameClient/W3DShroud.h +# Include/W3DDevice/GameClient/W3DSmudge.h +# Include/W3DDevice/GameClient/W3DSnow.h +# Include/W3DDevice/GameClient/W3DStatusCircle.h +# Include/W3DDevice/GameClient/W3DTerrainBackground.h +# Include/W3DDevice/GameClient/W3DTerrainTracks.h +# Include/W3DDevice/GameClient/W3DTerrainVisual.h +# Include/W3DDevice/GameClient/W3DTreeBuffer.h +# Include/W3DDevice/GameClient/W3DVideobuffer.h +# Include/W3DDevice/GameClient/W3DView.h +# Include/W3DDevice/GameClient/W3DVolumetricShadow.h +# Include/W3DDevice/GameClient/W3DWater.h +# Include/W3DDevice/GameClient/W3DWaterTracks.h +# Include/W3DDevice/GameClient/W3DWaypointBuffer.h +# Include/W3DDevice/GameClient/W3DWebBrowser.h +# Include/W3DDevice/GameClient/WorldHeightMap.h +# Include/W3DDevice/GameLogic/W3DGameLogic.h +# Include/W3DDevice/GameLogic/W3DGhostObject.h +# Include/W3DDevice/GameLogic/W3DTerrainLogic.h + Include/Win32Device/Common/Win32BIGFile.h + Include/Win32Device/Common/Win32BIGFileSystem.h +# Include/Win32Device/Common/Win32CDManager.h +# Include/Win32Device/Common/Win32GameEngine.h + Include/Win32Device/Common/Win32LocalFile.h + Include/Win32Device/Common/Win32LocalFileSystem.h +# Include/Win32Device/GameClient/Win32DIKeyboard.h +# Include/Win32Device/GameClient/Win32DIMouse.h +# Include/Win32Device/GameClient/Win32Mouse.h +# Source/MilesAudioDevice/MilesAudioManager.cpp +# Source/VideoDevice/Bink/BinkVideoPlayer.cpp +# Source/W3DDevice/Common/System/W3DFunctionLexicon.cpp +# Source/W3DDevice/Common/System/W3DRadar.cpp +# Source/W3DDevice/Common/Thing/W3DModuleFactory.cpp +# Source/W3DDevice/Common/Thing/W3DThingFactory.cpp +# Source/W3DDevice/Common/W3DConvert.cpp +# Source/W3DDevice/GameClient/BaseHeightMap.cpp +# Source/W3DDevice/GameClient/camerashakesystem.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DProjectileStreamDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DPropDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DRopeDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DScienceModelDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DSupplyDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DTracerDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DTreeDraw.cpp +# Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp +# Source/W3DDevice/GameClient/FlatHeightMap.cpp +# Source/W3DDevice/GameClient/GUI/Gadget/W3DCheckBox.cpp +# Source/W3DDevice/GameClient/GUI/Gadget/W3DComboBox.cpp +# Source/W3DDevice/GameClient/GUI/Gadget/W3DHorizontalSlider.cpp +# Source/W3DDevice/GameClient/GUI/Gadget/W3DListBox.cpp +# Source/W3DDevice/GameClient/GUI/Gadget/W3DProgressBar.cpp +# Source/W3DDevice/GameClient/GUI/Gadget/W3DPushButton.cpp +# Source/W3DDevice/GameClient/GUI/Gadget/W3DRadioButton.cpp +# Source/W3DDevice/GameClient/GUI/Gadget/W3DStaticText.cpp +# Source/W3DDevice/GameClient/GUI/Gadget/W3DTabControl.cpp +# Source/W3DDevice/GameClient/GUI/Gadget/W3DTextEntry.cpp +# Source/W3DDevice/GameClient/GUI/Gadget/W3DVerticalSlider.cpp +# Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DControlBar.cpp +# Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DMainMenu.cpp +# Source/W3DDevice/GameClient/GUI/GUICallbacks/W3DMOTD.cpp +# Source/W3DDevice/GameClient/GUI/W3DGameFont.cpp +# Source/W3DDevice/GameClient/GUI/W3DGameWindow.cpp +# Source/W3DDevice/GameClient/GUI/W3DGameWindowManager.cpp +# Source/W3DDevice/GameClient/HeightMap.cpp +# Source/W3DDevice/GameClient/Shadow/W3DBufferManager.cpp +# Source/W3DDevice/GameClient/Shadow/W3DProjectedShadow.cpp +# Source/W3DDevice/GameClient/Shadow/W3DShadow.cpp +# Source/W3DDevice/GameClient/Shadow/W3DVolumetricShadow.cpp +# Source/W3DDevice/GameClient/TerrainTex.cpp +# Source/W3DDevice/GameClient/TileData.cpp +# Source/W3DDevice/GameClient/W3DAssetManager.cpp +# Source/W3DDevice/GameClient/W3DAssetManagerExposed.cpp +# Source/W3DDevice/GameClient/W3DBibBuffer.cpp +# Source/W3DDevice/GameClient/W3DBridgeBuffer.cpp +# Source/W3DDevice/GameClient/W3DCustomEdging.cpp +# Source/W3DDevice/GameClient/W3DDebugDisplay.cpp +# Source/W3DDevice/GameClient/W3DDebugIcons.cpp +# Source/W3DDevice/GameClient/W3DDisplay.cpp +# Source/W3DDevice/GameClient/W3DDisplayString.cpp +# Source/W3DDevice/GameClient/W3DDisplayStringManager.cpp +# Source/W3DDevice/GameClient/W3DDynamicLight.cpp +# Source/W3DDevice/GameClient/W3DFileSystem.cpp +# Source/W3DDevice/GameClient/W3DGameClient.cpp +# Source/W3DDevice/GameClient/W3DInGameUI.cpp +# Source/W3DDevice/GameClient/W3DMouse.cpp +# Source/W3DDevice/GameClient/W3DParticleSys.cpp +# Source/W3DDevice/GameClient/W3DPoly.cpp +# Source/W3DDevice/GameClient/W3DPropBuffer.cpp +# Source/W3DDevice/GameClient/W3DRoadBuffer.cpp +# Source/W3DDevice/GameClient/W3DScene.cpp +# Source/W3DDevice/GameClient/W3DShaderManager.cpp +# Source/W3DDevice/GameClient/W3DShroud.cpp +# Source/W3DDevice/GameClient/W3DSmudge.cpp +# Source/W3DDevice/GameClient/W3DSnow.cpp +# Source/W3DDevice/GameClient/W3DStatusCircle.cpp +# Source/W3DDevice/GameClient/W3DTerrainBackground.cpp +# Source/W3DDevice/GameClient/W3DTerrainTracks.cpp +# Source/W3DDevice/GameClient/W3DTerrainVisual.cpp +# Source/W3DDevice/GameClient/W3DTreeBuffer.cpp +# Source/W3DDevice/GameClient/W3DVideoBuffer.cpp +# Source/W3DDevice/GameClient/W3DView.cpp +# Source/W3DDevice/GameClient/W3dWaypointBuffer.cpp +# Source/W3DDevice/GameClient/W3DWebBrowser.cpp +# Source/W3DDevice/GameClient/Water/W3DWater.cpp +# Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp +# Source/W3DDevice/GameClient/WorldHeightMap.cpp +# Source/W3DDevice/GameLogic/W3DGameLogic.cpp +# Source/W3DDevice/GameLogic/W3DGhostObject.cpp +# Source/W3DDevice/GameLogic/W3DTerrainLogic.cpp + Source/Win32Device/Common/Win32BIGFile.cpp + Source/Win32Device/Common/Win32BIGFileSystem.cpp +# Source/Win32Device/Common/Win32CDManager.cpp +# Source/Win32Device/Common/Win32GameEngine.cpp + Source/Win32Device/Common/Win32LocalFile.cpp + Source/Win32Device/Common/Win32LocalFileSystem.cpp +# Source/Win32Device/Common/Win32OSDisplay.cpp +# Source/Win32Device/GameClient/Win32DIKeyboard.cpp + #Source/Win32Device/GameClient/Win32DIMouse.cpp +# Source/Win32Device/GameClient/Win32Mouse.cpp +) + +# Add C++ 17 FileSystem implementation for non-VS6 builds +if(NOT IS_VS6_BUILD) + list(APPEND GAMEENGINEDEVICE_SRC + Include/StdDevice/Common/StdBIGFile.h + Include/StdDevice/Common/StdBIGFileSystem.h + Include/StdDevice/Common/StdLocalFile.h + Include/StdDevice/Common/StdLocalFileSystem.h + Source/StdDevice/Common/StdBIGFile.cpp + Source/StdDevice/Common/StdBIGFileSystem.cpp + Source/StdDevice/Common/StdLocalFile.cpp + Source/StdDevice/Common/StdLocalFileSystem.cpp + ) +endif() + +add_library(corei_gameenginedevice_private INTERFACE) +add_library(corei_gameenginedevice_public INTERFACE) + +target_sources(corei_gameenginedevice_private INTERFACE ${GAMEENGINEDEVICE_SRC}) + +target_include_directories(corei_gameenginedevice_public INTERFACE + Include +) + +target_link_libraries(corei_gameenginedevice_private INTERFACE + corei_always + corei_main +) + +target_link_libraries(corei_gameenginedevice_public INTERFACE + binkstub + corei_gameengine_public + d3d8lib + milesstub +) + +#if(RTS_BUILD_OPTION_FFMPEG) +# find_package(FFMPEG REQUIRED) +# +# if(FFMPEG_FOUND) +# target_sources(z_gameenginedevice PRIVATE +# Include/VideoDevice/FFmpeg/FFmpegFile.h +# Include/VideoDevice/FFmpeg/FFmpegVideoPlayer.h +# Source/VideoDevice/FFmpeg/FFmpegFile.cpp +# Source/VideoDevice/FFmpeg/FFmpegVideoPlayer.cpp +# ) +# +# target_include_directories(z_gameenginedevice PRIVATE ${FFMPEG_INCLUDE_DIRS}) +# target_link_directories(z_gameenginedevice PRIVATE ${FFMPEG_LIBRARY_DIRS}) +# target_link_libraries(z_gameenginedevice PRIVATE ${FFMPEG_LIBRARIES}) +# target_compile_definitions(z_gameenginedevice PUBLIC RTS_HAS_FFMPEG) +# endif() +#endif() diff --git a/GeneralsMD/Code/GameEngineDevice/Include/StdDevice/Common/StdBIGFile.h b/Core/GameEngineDevice/Include/StdDevice/Common/StdBIGFile.h similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Include/StdDevice/Common/StdBIGFile.h rename to Core/GameEngineDevice/Include/StdDevice/Common/StdBIGFile.h diff --git a/GeneralsMD/Code/GameEngineDevice/Include/StdDevice/Common/StdBIGFileSystem.h b/Core/GameEngineDevice/Include/StdDevice/Common/StdBIGFileSystem.h similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Include/StdDevice/Common/StdBIGFileSystem.h rename to Core/GameEngineDevice/Include/StdDevice/Common/StdBIGFileSystem.h diff --git a/GeneralsMD/Code/GameEngineDevice/Include/StdDevice/Common/StdLocalFile.h b/Core/GameEngineDevice/Include/StdDevice/Common/StdLocalFile.h similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Include/StdDevice/Common/StdLocalFile.h rename to Core/GameEngineDevice/Include/StdDevice/Common/StdLocalFile.h diff --git a/GeneralsMD/Code/GameEngineDevice/Include/StdDevice/Common/StdLocalFileSystem.h b/Core/GameEngineDevice/Include/StdDevice/Common/StdLocalFileSystem.h similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Include/StdDevice/Common/StdLocalFileSystem.h rename to Core/GameEngineDevice/Include/StdDevice/Common/StdLocalFileSystem.h diff --git a/GeneralsMD/Code/GameEngineDevice/Include/Win32Device/Common/Win32BIGFile.h b/Core/GameEngineDevice/Include/Win32Device/Common/Win32BIGFile.h similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Include/Win32Device/Common/Win32BIGFile.h rename to Core/GameEngineDevice/Include/Win32Device/Common/Win32BIGFile.h diff --git a/GeneralsMD/Code/GameEngineDevice/Include/Win32Device/Common/Win32BIGFileSystem.h b/Core/GameEngineDevice/Include/Win32Device/Common/Win32BIGFileSystem.h similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Include/Win32Device/Common/Win32BIGFileSystem.h rename to Core/GameEngineDevice/Include/Win32Device/Common/Win32BIGFileSystem.h diff --git a/GeneralsMD/Code/GameEngineDevice/Include/Win32Device/Common/Win32LocalFile.h b/Core/GameEngineDevice/Include/Win32Device/Common/Win32LocalFile.h similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Include/Win32Device/Common/Win32LocalFile.h rename to Core/GameEngineDevice/Include/Win32Device/Common/Win32LocalFile.h diff --git a/GeneralsMD/Code/GameEngineDevice/Include/Win32Device/Common/Win32LocalFileSystem.h b/Core/GameEngineDevice/Include/Win32Device/Common/Win32LocalFileSystem.h similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Include/Win32Device/Common/Win32LocalFileSystem.h rename to Core/GameEngineDevice/Include/Win32Device/Common/Win32LocalFileSystem.h diff --git a/GeneralsMD/Code/GameEngineDevice/Source/StdDevice/Common/StdBIGFile.cpp b/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFile.cpp similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Source/StdDevice/Common/StdBIGFile.cpp rename to Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFile.cpp diff --git a/GeneralsMD/Code/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp b/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp similarity index 99% rename from GeneralsMD/Code/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp rename to Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp index dde8abd519..7cfbaa107f 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp +++ b/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp @@ -33,9 +33,13 @@ #include "Common/GameAudio.h" #include "Common/GameMemory.h" #include "Common/LocalFileSystem.h" + +#if RTS_ZEROHOUR +#include "Common/Registry.h" +#endif + #include "StdDevice/Common/StdBIGFile.h" #include "StdDevice/Common/StdBIGFileSystem.h" -#include "Common/Registry.h" #include "Utility/endian_compat.h" static const char *BIGFileIdentifier = "BIGF"; @@ -54,6 +58,7 @@ void StdBIGFileSystem::init() { loadBigFilesFromDirectory("", "*.big"); +#if RTS_ZEROHOUR // load original Generals assets AsciiString installPath; GetStringFromGeneralsRegistry("", "InstallPath", installPath ); @@ -61,6 +66,7 @@ void StdBIGFileSystem::init() { DEBUG_ASSERTCRASH(installPath != "", ("Be 1337! Go install Generals!")); if (installPath!="") loadBigFilesFromDirectory(installPath, "*.big"); +#endif } void StdBIGFileSystem::reset() { diff --git a/GeneralsMD/Code/GameEngineDevice/Source/StdDevice/Common/StdLocalFile.cpp b/Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFile.cpp similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Source/StdDevice/Common/StdLocalFile.cpp rename to Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFile.cpp diff --git a/GeneralsMD/Code/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp b/Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp rename to Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp diff --git a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFile.cpp b/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFile.cpp similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFile.cpp rename to Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFile.cpp diff --git a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp b/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp similarity index 99% rename from GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp rename to Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp index b6e9e0a73d..3b68aa8e46 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp +++ b/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp @@ -33,9 +33,13 @@ #include "Common/GameAudio.h" #include "Common/GameMemory.h" #include "Common/LocalFileSystem.h" + +#if RTS_ZEROHOUR +#include "Common/Registry.h" +#endif + #include "Win32Device/Common/Win32BIGFile.h" #include "Win32Device/Common/Win32BIGFileSystem.h" -#include "Common/Registry.h" #include "Utility/endian_compat.h" @@ -55,6 +59,7 @@ void Win32BIGFileSystem::init() { loadBigFilesFromDirectory("", "*.big"); +#if RTS_ZEROHOUR // load original Generals assets AsciiString installPath; GetStringFromGeneralsRegistry("", "InstallPath", installPath ); @@ -62,6 +67,7 @@ void Win32BIGFileSystem::init() { DEBUG_ASSERTCRASH(installPath != "", ("Be 1337! Go install Generals!")); if (installPath!="") loadBigFilesFromDirectory(installPath, "*.big"); +#endif } void Win32BIGFileSystem::reset() { diff --git a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFile.cpp b/Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFile.cpp similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFile.cpp rename to Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFile.cpp diff --git a/GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp b/Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp rename to Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp diff --git a/Generals/Code/GameEngine/CMakeLists.txt b/Generals/Code/GameEngine/CMakeLists.txt index eed55eae5b..933d5ab4b0 100644 --- a/Generals/Code/GameEngine/CMakeLists.txt +++ b/Generals/Code/GameEngine/CMakeLists.txt @@ -1,7 +1,7 @@ set(GAMEENGINE_SRC Include/Common/ActionManager.h - Include/Common/ArchiveFile.h - Include/Common/ArchiveFileSystem.h +# Include/Common/ArchiveFile.h +# Include/Common/ArchiveFileSystem.h Include/Common/AsciiString.h Include/Common/AudioAffect.h Include/Common/AudioEventInfo.h @@ -34,8 +34,8 @@ set(GAMEENGINE_SRC Include/Common/encrypt.h Include/Common/Energy.h Include/Common/Errors.h - Include/Common/file.h - Include/Common/FileSystem.h +# Include/Common/file.h +# Include/Common/FileSystem.h Include/Common/FunctionLexicon.h Include/Common/GameAudio.h Include/Common/GameCommon.h @@ -60,8 +60,8 @@ set(GAMEENGINE_SRC Include/Common/Language.h Include/Common/LatchRestore.h Include/Common/List.h - Include/Common/LocalFile.h - Include/Common/LocalFileSystem.h +# Include/Common/LocalFile.h +# Include/Common/LocalFileSystem.h Include/Common/MapObject.h Include/Common/MapReaderWriterInfo.h Include/Common/MessageStream.h @@ -88,7 +88,7 @@ set(GAMEENGINE_SRC Include/Common/QuickmatchPreferences.h Include/Common/QuotedPrintable.h Include/Common/Radar.h - Include/Common/RAMFile.h +# Include/Common/RAMFile.h Include/Common/RandomValue.h Include/Common/Recorder.h # Include/Common/ReplaySimulation.h @@ -107,7 +107,7 @@ set(GAMEENGINE_SRC Include/Common/StateMachine.h Include/Common/StatsCollector.h Include/Common/STLTypedefs.h - Include/Common/StreamingArchiveFile.h +# Include/Common/StreamingArchiveFile.h Include/Common/SubsystemInterface.h Include/Common/SystemInfo.h Include/Common/Team.h @@ -585,8 +585,8 @@ set(GAMEENGINE_SRC Source/Common/SkirmishBattleHonors.cpp Source/Common/StateMachine.cpp Source/Common/StatsCollector.cpp - Source/Common/System/ArchiveFile.cpp - Source/Common/System/ArchiveFileSystem.cpp +# Source/Common/System/ArchiveFile.cpp +# Source/Common/System/ArchiveFileSystem.cpp Source/Common/System/AsciiString.cpp Source/Common/System/BuildAssistant.cpp Source/Common/System/CDManager.cpp @@ -596,8 +596,8 @@ set(GAMEENGINE_SRC Source/Common/System/Directory.cpp Source/Common/System/DisabledTypes.cpp Source/Common/System/encrypt.cpp - Source/Common/System/File.cpp - Source/Common/System/FileSystem.cpp +# Source/Common/System/File.cpp +# Source/Common/System/FileSystem.cpp Source/Common/System/FunctionLexicon.cpp Source/Common/System/GameCommon.cpp #Source/Common/System/GameMemory.cpp @@ -605,19 +605,19 @@ set(GAMEENGINE_SRC Source/Common/System/Geometry.cpp Source/Common/System/KindOf.cpp Source/Common/System/List.cpp - Source/Common/System/LocalFile.cpp - Source/Common/System/LocalFileSystem.cpp +# Source/Common/System/LocalFile.cpp +# Source/Common/System/LocalFileSystem.cpp #Source/Common/System/MemoryInit.cpp Source/Common/System/ObjectStatusTypes.cpp Source/Common/System/QuotedPrintable.cpp Source/Common/System/Radar.cpp - Source/Common/System/RAMFile.cpp +# Source/Common/System/RAMFile.cpp Source/Common/System/registry.cpp Source/Common/System/SaveGame/GameState.cpp Source/Common/System/SaveGame/GameStateMap.cpp Source/Common/System/Snapshot.cpp Source/Common/System/StackDump.cpp - Source/Common/System/StreamingArchiveFile.cpp +# Source/Common/System/StreamingArchiveFile.cpp Source/Common/System/SubsystemInterface.cpp Source/Common/System/Trig.cpp Source/Common/System/UnicodeString.cpp diff --git a/Generals/Code/GameEngine/Include/Common/ArchiveFile.h b/Generals/Code/GameEngine/Include/Common/ArchiveFile.h deleted file mode 100644 index 6838938d79..0000000000 --- a/Generals/Code/GameEngine/Include/Common/ArchiveFile.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////// ArchiveFile.h //////////////////// -// Bryan Cleveland, August 2002 -////////////////////////////////////////// - -#pragma once - -#ifndef __ARCHIVEFILE_H -#define __ARCHIVEFILE_H - -#include "Lib/BaseType.h" -#include "Common/AsciiString.h" -#include "Common/ArchiveFileSystem.h" - -class File; - -/** - * An archive file is itself a collection of sub files. Each file inside the archive file - * has a unique name by which it can be accessed. The ArchiveFile object class is the - * runtime interface to the mix file and the sub files. Each file inside the mix - * file can be accessed by the openFile(). - * - * ArchiveFile interfaces can be created by the TheArchiveFileSystem object. - */ -//=============================== - -class ArchiveFile -{ -public: - ArchiveFile(); - virtual ~ArchiveFile(); - - virtual Bool getFileInfo( const AsciiString& filename, FileInfo *fileInfo) const = 0; ///< fill in the fileInfo struct with info about the file requested. - virtual File* openFile( const Char *filename, Int access = 0) = 0; ///< Open the specified file within the archive file - virtual void closeAllFiles( void ) = 0; ///< Close all file opened in this archive file - virtual AsciiString getName( void ) = 0; ///< Returns the name of the archive file - virtual AsciiString getPath( void ) = 0; ///< Returns full path and name of archive file - virtual void setSearchPriority( Int new_priority ) = 0; ///< Set this archive file's search priority - virtual void close( void ) = 0; ///< Close this archive file - void attachFile(File *file); - - void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; - void getFileListInDirectory(const DetailedArchivedDirectoryInfo *dirInfo, const AsciiString& currentDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; - - void addFile(const AsciiString& path, const ArchivedFileInfo *fileInfo); ///< add this file to our directory tree. - -protected: - const ArchivedFileInfo * getArchivedFileInfo(const AsciiString& filename) const; ///< return the ArchivedFileInfo from the directory tree. - - File *m_file; ///< file pointer to the archive file on disk. Kept open so we don't have to continuously open and close the file all the time. - DetailedArchivedDirectoryInfo m_rootDirectory; -}; - -#endif // __ARCHIVEFILE_H \ No newline at end of file diff --git a/Generals/Code/GameEngine/Include/Common/ArchiveFileSystem.h b/Generals/Code/GameEngine/Include/Common/ArchiveFileSystem.h deleted file mode 100644 index b1f75e7411..0000000000 --- a/Generals/Code/GameEngine/Include/Common/ArchiveFileSystem.h +++ /dev/null @@ -1,191 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: Generals -// -// Module: Archive files -// -// File name: Common/ArchiveFileSystem.h -// -// Created: 11/26/01 TR -// -//---------------------------------------------------------------------------- - -#pragma once - -#ifndef __ARCHIVEFILESYSTEM_H_ -#define __ARCHIVEFILESYSTEM_H_ - -#define MUSIC_BIG "Music.big" - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "Common/SubsystemInterface.h" -#include "Common/AsciiString.h" -#include "Common/FileSystem.h" // for typedefs, etc. -#include "Common/STLTypedefs.h" - -//---------------------------------------------------------------------------- -// Forward References -//---------------------------------------------------------------------------- - -class File; -class ArchiveFile; - -//---------------------------------------------------------------------------- -// Type Defines -//---------------------------------------------------------------------------- - - -//=============================== -// ArchiveFileSystem -//=============================== -/** - * Creates and manages ArchiveFile interfaces. ArchiveFiles can be accessed - * by calling the openArchiveFile() member. ArchiveFiles can be accessed by - * name or by File interface. - * - * openFile() member searches all Archive files for the specified sub file. - */ -//=============================== -class ArchivedDirectoryInfo; -class DetailedArchivedDirectoryInfo; -class ArchivedFileInfo; - -typedef std::map DetailedArchivedDirectoryInfoMap; -typedef std::map ArchivedDirectoryInfoMap; -typedef std::map ArchivedFileInfoMap; -typedef std::map ArchiveFileMap; -typedef std::map ArchivedFileLocationMap; // first string is the file name, second one is the archive filename. - -class ArchivedDirectoryInfo -{ -public: - AsciiString m_directoryName; - ArchivedDirectoryInfoMap m_directories; - ArchivedFileLocationMap m_files; - - void clear() - { - m_directoryName.clear(); - m_directories.clear(); - m_files.clear(); - } - -}; - -class DetailedArchivedDirectoryInfo -{ -public: - AsciiString m_directoryName; - DetailedArchivedDirectoryInfoMap m_directories; - ArchivedFileInfoMap m_files; - - void clear() - { - m_directoryName.clear(); - m_directories.clear(); - m_files.clear(); - } -}; - -class ArchivedFileInfo -{ -public: - AsciiString m_filename; - AsciiString m_archiveFilename; - UnsignedInt m_offset; - UnsignedInt m_size; - - ArchivedFileInfo() - { - clear(); - } - - void clear() - { - m_filename.clear(); - m_archiveFilename.clear(); - m_offset = 0; - m_size = 0; - } -}; - - -class ArchiveFileSystem : public SubsystemInterface -{ - public: - ArchiveFileSystem(); - virtual ~ArchiveFileSystem(); - - virtual void init( void ) = 0; - virtual void update( void ) = 0; - virtual void reset( void ) = 0; - virtual void postProcessLoad( void ) = 0; - - // ArchiveFile operations - virtual ArchiveFile* openArchiveFile( const Char *filename ) = 0; ///< Create new or return existing Archive file from file name - virtual void closeArchiveFile( const Char *filename ) = 0; ///< Close the one specified big file. - virtual void closeAllArchiveFiles( void ) = 0; ///< Close all Archivefiles currently open - - // File operations - virtual File* openFile( const Char *filename, Int access = 0); ///< Search Archive files for specified file name and open it if found - virtual void closeAllFiles( void ) = 0; ///< Close all files associated with ArchiveFiles - virtual Bool doesFileExist(const Char *filename) const; ///< return true if that file exists in an archive file somewhere. - - void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories. Scans each Archive file. - Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const; ///< see FileSystem.h - - virtual Bool loadBigFilesFromDirectory(AsciiString dir, AsciiString fileMask, Bool overwrite = FALSE) = 0; - - // Unprotected this for copy-protection routines - AsciiString getArchiveFilenameForFile(const AsciiString& filename) const; - void loadMods( void ); - -protected: - virtual void loadIntoDirectoryTree(const ArchiveFile *archiveFile, const AsciiString& archiveFilename, Bool overwrite = FALSE ); ///< load the archive file's header information and apply it to the global archive directory tree. - - ArchiveFileMap m_archiveFileMap; - ArchivedDirectoryInfo m_rootDirectory; -}; - - -extern ArchiveFileSystem *TheArchiveFileSystem; - -//---------------------------------------------------------------------------- -// Inlining -//---------------------------------------------------------------------------- - -#endif // __ARCHIVEFILESYSTEM_H_ diff --git a/Generals/Code/GameEngine/Include/Common/FileSystem.h b/Generals/Code/GameEngine/Include/Common/FileSystem.h deleted file mode 100644 index cac342148e..0000000000 --- a/Generals/Code/GameEngine/Include/Common/FileSystem.h +++ /dev/null @@ -1,156 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//----------------------------------------------------------------------------= -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: GameEngine -// -// Module: IO -// -// File name: FileSystem.h -// -// Created: -// -//---------------------------------------------------------------------------- - -#pragma once - -#ifndef __FILESYSTEM_H -#define __FILESYSTEM_H - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "Common/STLTypedefs.h" -#include "Common/SubsystemInterface.h" - -//---------------------------------------------------------------------------- -// Forward References -//---------------------------------------------------------------------------- -class File; - -//---------------------------------------------------------------------------- -// Type Defines -//---------------------------------------------------------------------------- - -typedef std::set > FilenameList; -typedef FilenameList::iterator FilenameListIter; - -//---------------------------------------------------------------------------- -// Type Defines -//---------------------------------------------------------------------------- -//#define W3D_DIR_PATH "../FinalArt/W3D/" ///< .w3d files live here -//#define TGA_DIR_PATH "../FinalArt/Textures/" ///< .tga texture files live here -//#define TERRAIN_TGA_DIR_PATH "../FinalArt/Terrain/" ///< terrain .tga texture files live here -#define W3D_DIR_PATH "Art/W3D/" ///< .w3d files live here -#define TGA_DIR_PATH "Art/Textures/" ///< .tga texture files live here -#define TERRAIN_TGA_DIR_PATH "Art/Terrain/" ///< terrain .tga texture files live here -#define MAP_PREVIEW_DIR_PATH "%sMapPreviews/" ///< We need a common place we can copy the map previews to at runtime. -#define USER_W3D_DIR_PATH "%sW3D/" ///< .w3d files live here -#define USER_TGA_DIR_PATH "%sTextures/" ///< User .tga texture files live here - -// the following defines are only to be used while maintaining legacy compatability -// with old files until they are completely gone and in the regular art set -#ifdef MAINTAIN_LEGACY_FILES -#define LEGACY_W3D_DIR_PATH "../LegacyArt/W3D/" ///< .w3d files live here -#define LEGACY_TGA_DIR_PATH "../LegacyArt/Textures/" ///< .tga texture files live here -#endif // MAINTAIN_LEGACY_FILES - -// LOAD_TEST_ASSETS automatically loads w3d assets from the TEST_W3D_DIR_PATH -// without having to add an INI entry. -///@todo this allows us to use the test art directory, it should be removed for FINAL release -#define LOAD_TEST_ASSETS 1 -#ifdef LOAD_TEST_ASSETS - #define ROAD_DIRECTORY "../TestArt/TestRoad/" - #define TEST_STRING "***TESTING" -// the following directories will be used to look for test art -#define LOOK_FOR_TEST_ART -#define TEST_W3D_DIR_PATH "../TestArt/" ///< .w3d files live here -#define TEST_TGA_DIR_PATH "../TestArt/" ///< .tga texture files live here -#endif - -struct FileInfo { - Int sizeHigh; - Int sizeLow; - Int timestampHigh; - Int timestampLow; -}; - -//=============================== -// FileSystem -//=============================== -/** - * FileSystem is an interface class for creating specific FileSystem objects. - * - * A FileSystem object's implemenation decides what derivative of File object needs to be - * created when FileSystem::Open() gets called. - */ -//=============================== - -class FileSystem : public SubsystemInterface -{ -public: - FileSystem(); - virtual ~FileSystem(); - - void init(); - void reset(); - void update(); - - File* openFile( const Char *filename, Int access = 0 ); ///< opens a File interface to the specified file - Bool doesFileExist(const Char *filename) const; ///< returns TRUE if the file exists. filename should have no directory. - void getFileListInDirectory(const AsciiString& directory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories. - Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const; ///< fills in the FileInfo struct for the file given. returns TRUE if successful. - - Bool createDirectory(AsciiString directory); ///< create a directory of the given name. - - Bool areMusicFilesOnCD(); - void loadMusicFilesFromCD(); - void unloadMusicFilesFromCD(); - AsciiString normalizePath(const AsciiString& path) const; ///< normalizes a file path. The path can refer to a directory. File path must be absolute, but does not need to exist. Returns an empty string on failure. - static Bool isPathInDirectory(const AsciiString& testPath, const AsciiString& basePath); ///< determines if a file path is within a base path. Both paths must be absolute, but do not need to exist. -protected: - - -}; - -extern FileSystem* TheFileSystem; - - - -//---------------------------------------------------------------------------- -// Inlining -//---------------------------------------------------------------------------- - - - -#endif // __WSYS_FILESYSTEM_H diff --git a/Generals/Code/GameEngine/Include/Common/LocalFile.h b/Generals/Code/GameEngine/Include/Common/LocalFile.h deleted file mode 100644 index 0a04bb0967..0000000000 --- a/Generals/Code/GameEngine/Include/Common/LocalFile.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//----------------------------------------------------------------------------= -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: WSYS Library -// -// Module: IO -// -// File name: LocalFile.h -// -// Created: 4/23/01 -// -//---------------------------------------------------------------------------- - -#pragma once - -#ifndef __LOCALFILE_H -#define __LOCALFILE_H - - - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "Common/file.h" - -// srj sez: this was purely an experiment in optimization. -// at the present time, it doesn't appear to be a good one. -// but I am leaving the code in for now. -// if still present in 2003, please nuke. -#define NO_USE_BUFFERED_IO -#ifdef USE_BUFFERED_IO -#include -#endif - -//---------------------------------------------------------------------------- -// Forward References -//---------------------------------------------------------------------------- - - -//---------------------------------------------------------------------------- -// Type Defines -//---------------------------------------------------------------------------- - -//=============================== -// LocalFile -//=============================== -/** - * File abstraction for standard C file operators: open, close, lseek, read, write - */ -//=============================== - -class LocalFile : public File -{ - MEMORY_POOL_GLUE_ABC(LocalFile) - private: - -#ifdef USE_BUFFERED_IO - FILE* m_file; - - enum { BUF_SIZE = 32768 }; - char m_vbuf[BUF_SIZE]; -#else - int m_handle; ///< Local C file handle -#endif - - public: - - LocalFile(); - //virtual ~LocalFile(); - - - virtual Bool open( const Char *filename, Int access = 0 ); ///< Open a file for access - virtual void close( void ); ///< Close the file - virtual Int read( void *buffer, Int bytes ); ///< Read the specified number of bytes in to buffer: See File::read - virtual Int write( const void *buffer, Int bytes ); ///< Write the specified number of bytes from the buffer: See File::write - virtual Int seek( Int new_pos, seekMode mode = CURRENT ); ///< Set file position: See File::seek - virtual void nextLine(Char *buf = NULL, Int bufSize = 0); ///< moves file position to after the next new-line - virtual Bool scanInt(Int &newInt); ///< return what gets read in as an integer at the current file position. - virtual Bool scanReal(Real &newReal); ///< return what gets read in as a float at the current file position. - virtual Bool scanString(AsciiString &newString); ///< return what gets read in as a string at the current file position. - /** - Allocate a buffer large enough to hold entire file, read - the entire file into the buffer, then close the file. - the buffer is owned by the caller, who is responsible - for freeing is (via delete[]). This is a Good Thing to - use because it minimizes memory copies for BIG files. - */ - virtual char* readEntireAndClose(); - virtual File* convertToRAMFile(); - -}; - - - - -//---------------------------------------------------------------------------- -// Inlining -//---------------------------------------------------------------------------- - - -#endif // __LOCALFILE_H diff --git a/Generals/Code/GameEngine/Include/Common/LocalFileSystem.h b/Generals/Code/GameEngine/Include/Common/LocalFileSystem.h deleted file mode 100644 index 87e78f173a..0000000000 --- a/Generals/Code/GameEngine/Include/Common/LocalFileSystem.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////// LocalFileSystem.h //////////////////////////////// -// Bryan Cleveland, August 2002 -////////////////////////////////////////////////////////// - -#pragma once - -#ifndef __LOCALFILESYSTEM_H -#define __LOCALFILESYSTEM_H - -#include "Common/SubsystemInterface.h" -#include "FileSystem.h" // for typedefs, etc. - -class File; - -class LocalFileSystem : public SubsystemInterface -{ -public: - virtual ~LocalFileSystem() {} - - virtual void init() = 0; - virtual void reset() = 0; - virtual void update() = 0; - - virtual File * openFile(const Char *filename, Int access = 0) = 0; - virtual Bool doesFileExist(const Char *filename) const = 0; - virtual void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const = 0; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories. - virtual Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const = 0; ///< see FileSystem.h - virtual Bool createDirectory(AsciiString directory) = 0; ///< see FileSystem.h - virtual AsciiString normalizePath(const AsciiString& filePath) const = 0; ///< see FileSystem.h - -protected: -}; - -extern LocalFileSystem *TheLocalFileSystem; - -#endif // __LOCALFILESYSTEM_H \ No newline at end of file diff --git a/Generals/Code/GameEngine/Include/Common/RAMFile.h b/Generals/Code/GameEngine/Include/Common/RAMFile.h deleted file mode 100644 index f28192aaab..0000000000 --- a/Generals/Code/GameEngine/Include/Common/RAMFile.h +++ /dev/null @@ -1,124 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//----------------------------------------------------------------------------= -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: WSYS Library -// -// Module: IO -// -// File name: wsys/RAMFile.h -// -// Created: 11/08/01 -// -//---------------------------------------------------------------------------- - -#pragma once - -#ifndef __RAMFILE_H -#define __RAMFILE_H - - - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "Common/file.h" - -//---------------------------------------------------------------------------- -// Forward References -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Type Defines -//---------------------------------------------------------------------------- - -//=============================== -// RAMFile -//=============================== -/** - * File abstraction for standard C file operators: open, close, lseek, read, write - */ -//=============================== - -class RAMFile : public File -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(RAMFile, "RAMFile") - protected: - - Char *m_data; ///< File data in memory - Int m_pos; ///< current read position - Int m_size; ///< size of file in memory - - public: - - RAMFile(); - //virtual ~RAMFile(); - - - virtual Bool open( const Char *filename, Int access = 0 ); ///< Open a file for access - virtual void close( void ); ///< Close the file - virtual Int read( void *buffer, Int bytes ); ///< Read the specified number of bytes in to buffer: See File::read - virtual Int write( const void *buffer, Int bytes ); ///< Write the specified number of bytes from the buffer: See File::write - virtual Int seek( Int new_pos, seekMode mode = CURRENT ); ///< Set file position: See File::seek - virtual void nextLine(Char *buf = NULL, Int bufSize = 0); ///< moves current position to after the next new-line - - virtual Bool scanInt(Int &newInt); ///< return what gets read as an integer from the current memory position. - virtual Bool scanReal(Real &newReal); ///< return what gets read as a float from the current memory position. - virtual Bool scanString(AsciiString &newString); ///< return what gets read as a string from the current memory position. - - virtual Bool open( File *file ); ///< Open file for fast RAM access - virtual Bool openFromArchive(File *archiveFile, const AsciiString& filename, Int offset, Int size); ///< copy file data from the given file at the given offset for the given size. - virtual Bool copyDataToFile(File *localFile); ///< write the contents of the RAM file to the given local file. This could be REALLY slow. - - /** - Allocate a buffer large enough to hold entire file, read - the entire file into the buffer, then close the file. - the buffer is owned by the caller, who is responsible - for freeing is (via delete[]). This is a Good Thing to - use because it minimizes memory copies for BIG files. - */ - virtual char* readEntireAndClose(); - virtual File* convertToRAMFile(); -}; - - - - -//---------------------------------------------------------------------------- -// Inlining -//---------------------------------------------------------------------------- - - -#endif // __WSYS_RAMFILE_H diff --git a/Generals/Code/GameEngine/Include/Common/StreamingArchiveFile.h b/Generals/Code/GameEngine/Include/Common/StreamingArchiveFile.h deleted file mode 100644 index 20aa536ab4..0000000000 --- a/Generals/Code/GameEngine/Include/Common/StreamingArchiveFile.h +++ /dev/null @@ -1,119 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//----------------------------------------------------------------------------= -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: RTS 3 -// -// Module: IO -// -// File name: Common/StreamingArchiveFile.h -// -// Created: 11/08/01 -// -//---------------------------------------------------------------------------- - -#pragma once - -#ifndef __STREAMINGARCHIVEFILE_H -#define __STREAMINGARCHIVEFILE_H - - - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "Common/RAMFile.h" - -//---------------------------------------------------------------------------- -// Forward References -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Type Defines -//---------------------------------------------------------------------------- - -//=============================== -// StreamingArchiveFile -//=============================== -/** - * File abstraction for standard C file operators: open, close, lseek, read, write - */ -//=============================== - -class StreamingArchiveFile : public RAMFile -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(StreamingArchiveFile, "StreamingArchiveFile") - protected: - - File *m_file; ///< The archive file that I came from - Int m_startingPos; ///< My starting position in the archive - Int m_size; ///< My length - Int m_curPos; ///< My current position. - - public: - - StreamingArchiveFile(); - //virtual ~StreamingArchiveFile(); - - - virtual Bool open( const Char *filename, Int access = 0 ); ///< Open a file for access - virtual void close( void ); ///< Close the file - virtual Int read( void *buffer, Int bytes ); ///< Read the specified number of bytes in to buffer: See File::read - virtual Int write( const void *buffer, Int bytes ); ///< Write the specified number of bytes from the buffer: See File::write - virtual Int seek( Int new_pos, seekMode mode = CURRENT ); ///< Set file position: See File::seek - - // Ini's should not be parsed with streaming files, that's just dumb. - virtual void nextLine(Char *buf = NULL, Int bufSize = 0) { DEBUG_CRASH(("Should not call nextLine on a streaming file.")); } - virtual Bool scanInt(Int &newInt) { DEBUG_CRASH(("Should not call scanInt on a streaming file.")); return FALSE; } - virtual Bool scanReal(Real &newReal) { DEBUG_CRASH(("Should not call scanReal on a streaming file.")); return FALSE; } - virtual Bool scanString(AsciiString &newString) { DEBUG_CRASH(("Should not call scanString on a streaming file.")); return FALSE; } - - virtual Bool open( File *file ); ///< Open file for fast RAM access - virtual Bool openFromArchive(File *archiveFile, const AsciiString& filename, Int offset, Int size); ///< copy file data from the given file at the given offset for the given size. - virtual Bool copyDataToFile(File *localFile) { DEBUG_CRASH(("Are you sure you meant to copyDataToFile on a streaming file?")); return FALSE; } - - virtual char* readEntireAndClose() { DEBUG_CRASH(("Are you sure you meant to readEntireAndClose on a streaming file?")); return NULL; } - virtual File* convertToRAMFile() { DEBUG_CRASH(("Are you sure you meant to readEntireAndClose on a streaming file?")); return this; } -}; - - - - -//---------------------------------------------------------------------------- -// Inlining -//---------------------------------------------------------------------------- - - -#endif // __STREAMINGARCHIVEFILE_H diff --git a/Generals/Code/GameEngine/Include/Common/file.h b/Generals/Code/GameEngine/Include/Common/file.h deleted file mode 100644 index 878e9519e7..0000000000 --- a/Generals/Code/GameEngine/Include/Common/file.h +++ /dev/null @@ -1,194 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//----------------------------------------------------------------------------= -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: WSYS Library -// -// Module: IO -// -// File name: wsys/File.h -// -// Created: 4/23/01 -// -//---------------------------------------------------------------------------- - -#pragma once - -#ifndef __FILE_H -#define __FILE_H - - - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "Lib/BaseType.h" -#include "Common/AsciiString.h" -#include "Common/GameMemory.h" -// include FileSystem.h as it will be used alot with File.h -//#include "Common/FileSystem.h" - -//---------------------------------------------------------------------------- -// Forward References -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Type Defines -//---------------------------------------------------------------------------- - -//=============================== -// File -//=============================== -/** - * File is an interface class for basic file operations. - * - * All code should use the File class and not its derivatives, unless - * absolutely necessary. Also FS::Open should be used to create File objects and open files. - */ -//=============================== - -class File : public MemoryPoolObject -{ - MEMORY_POOL_GLUE_ABC(File) -// friend doesn't play well with MPO (srj) -// friend class FileSystem; - - public: - - enum access - { - NONE = 0x00000000, - READ = 0x00000001, ///< Access file for reading - WRITE = 0x00000002, ///< Access file for writing - APPEND = 0x00000004, ///< Seek to end of file on open - CREATE = 0x00000008, ///< Create file if it does not exist - TRUNCATE = 0x00000010, ///< Delete all data in file when opened - TEXT = 0x00000020, ///< Access file as text data - BINARY = 0x00000040, ///< Access file as binary data - READWRITE = (READ | WRITE), - ONLYNEW = 0x00000080, ///< Only create file if it does not exist - - // NOTE: STREAMING is Mutually exclusive with WRITE - STREAMING = 0x00000100 ///< Do not read this file into a ram file, read it as requested. - }; - - enum seekMode - { - START, ///< Seek position is relative to start of file - CURRENT, ///< Seek position is relative to current file position - END ///< Seek position is relative from the end of the file - }; - - protected: - - AsciiString m_nameStr; ///< Stores file name - Int m_access; ///< How the file was opened - Bool m_open; ///< Has the file been opened - Bool m_deleteOnClose; ///< delete File object on close() - - - File(); ///< This class can only used as a base class - //virtual ~File(); - - public: - - - Bool eof(); - virtual Bool open( const Char *filename, Int access = 0 ); ///< Open a file for access - virtual void close( void ); ///< Close the file !!! File object no longer valid after this call !!! - - virtual Int read( void *buffer, Int bytes ) = NULL ; /**< Read the specified number of bytes from the file in to the - * memory pointed at by buffer. Returns the number of bytes read. - * Returns -1 if an error occured. - */ - virtual Int write( const void *buffer, Int bytes ) = NULL ; /**< Write the specified number of bytes from the - * memory pointed at by buffer to the file. Returns the number of bytes written. - * Returns -1 if an error occured. - */ - virtual Int seek( Int bytes, seekMode mode = CURRENT ) = NULL; /**< Sets the file position of the next read/write operation. Returns the new file - * position as the number of bytes from the start of the file. - * Returns -1 if an error occured. - * - * seekMode determines how the seek is done: - * - * START : means seek to the specified number of bytes from the start of the file - * CURRENT: means seek the specified the number of bytes from the current file position - * END: means seek the specified number of bytes back from the end of the file - */ - virtual void nextLine(Char *buf = NULL, Int bufSize = 0) = 0; ///< reads until it reaches a new-line character - - virtual Bool scanInt(Int &newInt) = 0; ///< read an integer from the current file position. - virtual Bool scanReal(Real &newReal) = 0; ///< read a real number from the current file position. - virtual Bool scanString(AsciiString &newString) = 0; ///< read a string from the current file position. - - virtual Bool print ( const Char *format, ...); ///< Prints formated string to text file - virtual Int size( void ); ///< Returns the size of the file - virtual Int position( void ); ///< Returns the current read/write position - - - void setName( const char *name ); ///< Set the name of the file - const char* getName( void ) const; ///< Returns a pointer to the name of the file - Int getAccess( void ) const; ///< Returns file's access flags - - void deleteOnClose ( void ); ///< Causes the File object to delete itself when it closes - - /** - Allocate a buffer large enough to hold entire file, read - the entire file into the buffer, then close the file. - the buffer is owned by the caller, who is responsible - for freeing is (via delete[]). This is a Good Thing to - use because it minimizes memory copies for BIG files. - */ - virtual char* readEntireAndClose() = 0; - virtual File* convertToRAMFile() = 0; -}; - - - - -//---------------------------------------------------------------------------- -// Inlining -//---------------------------------------------------------------------------- - -inline const char* File::getName( void ) const { return m_nameStr.str(); } -inline void File::setName( const char *name ) { m_nameStr.set(name); } -inline Int File::getAccess( void ) const { return m_access; } -inline void File::deleteOnClose( void ) { m_deleteOnClose = TRUE; } - - - - - -#endif // __FILE_H diff --git a/Generals/Code/GameEngine/Source/Common/System/ArchiveFile.cpp b/Generals/Code/GameEngine/Source/Common/System/ArchiveFile.cpp deleted file mode 100644 index fab4e08a9e..0000000000 --- a/Generals/Code/GameEngine/Source/Common/System/ArchiveFile.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////ArchiveFile.cpp /////////////////////// -// Bryan Cleveland, August 2002 -//////////////////////////////////////////////// - -#include "PreRTS.h" - -#include "Common/ArchiveFile.h" -#include "Common/ArchiveFileSystem.h" -#include "Common/file.h" -#include "Common/PerfTimer.h" - - -// checks to see if str matches searchString. Search string is done in the -// using * and ? as wildcards. * is used to denote any number of characters, -// and ? is used to denote a single wildcard character. -static Bool SearchStringMatches(AsciiString str, AsciiString searchString) -{ - if (str.getLength() == 0) { - if (searchString.getLength() == 0) { - return TRUE; - } - return FALSE; - } - if (searchString.getLength() == 0) { - return FALSE; - } - - const char *c1 = str.str(); - const char *c2 = searchString.str(); - - while ((*c1 == *c2) || (*c2 == '?') || (*c2 == '*')) { - if ((*c1 == *c2) || (*c2 == '?')) { - ++c1; - ++c2; - } else if (*c2 == '*') { - ++c2; - if (*c2 == 0) { - return TRUE; - } - while (*c1 != 0) { - if (SearchStringMatches(AsciiString(c1), AsciiString(c2))) { - return TRUE; - } - ++c1; - } - } - if (*c1 == 0) { - if (*c2 == 0) { - return TRUE; - } - return FALSE; - } - if (*c2 == 0) { - return FALSE; - } - } - return FALSE; -} - -ArchiveFile::~ArchiveFile() -{ - if (m_file != NULL) { - m_file->close(); - m_file = NULL; - } -} - -ArchiveFile::ArchiveFile() -{ - m_rootDirectory.clear(); -} - -void ArchiveFile::addFile(const AsciiString& path, const ArchivedFileInfo *fileInfo) -{ - AsciiString temp; - temp = path; - temp.toLower(); - AsciiString token; - AsciiString debugpath; - - DetailedArchivedDirectoryInfo *dirInfo = &m_rootDirectory; - - temp.nextToken(&token, "\\/"); - - while (token.getLength() > 0) { - if (dirInfo->m_directories.find(token) == dirInfo->m_directories.end()) - { - dirInfo->m_directories[token].clear(); - dirInfo->m_directories[token].m_directoryName = token; - } - - debugpath.concat(token); - debugpath.concat('\\'); - dirInfo = &(dirInfo->m_directories[token]); - temp.nextToken(&token, "\\/"); - } - - dirInfo->m_files[fileInfo->m_filename] = *fileInfo; - //path.concat(fileInfo->m_filename); -} - -void ArchiveFile::getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const -{ - - AsciiString searchDir; - const DetailedArchivedDirectoryInfo *dirInfo = &m_rootDirectory; - - searchDir = originalDirectory; - searchDir.toLower(); - AsciiString token; - - searchDir.nextToken(&token, "\\/"); - - while (token.getLength() > 0) { - - DetailedArchivedDirectoryInfoMap::const_iterator it = dirInfo->m_directories.find(token); - if (it != dirInfo->m_directories.end()) - { - dirInfo = &it->second; - } - else - { - // if the directory doesn't exist, then there aren't any files to be had. - return; - } - - searchDir.nextToken(&token, "\\/"); - } - - getFileListInDirectory(dirInfo, originalDirectory, searchName, filenameList, searchSubdirectories); -} - -void ArchiveFile::getFileListInDirectory(const DetailedArchivedDirectoryInfo *dirInfo, const AsciiString& currentDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const -{ - DetailedArchivedDirectoryInfoMap::const_iterator diriter = dirInfo->m_directories.begin(); - while (diriter != dirInfo->m_directories.end()) { - const DetailedArchivedDirectoryInfo *tempDirInfo = &(diriter->second); - AsciiString tempdirname; - tempdirname = currentDirectory; - if ((tempdirname.getLength() > 0) && (!tempdirname.endsWith("\\"))) { - tempdirname.concat('\\'); - } - tempdirname.concat(tempDirInfo->m_directoryName); - getFileListInDirectory(tempDirInfo, tempdirname, searchName, filenameList, searchSubdirectories); - diriter++; - } - - ArchivedFileInfoMap::const_iterator fileiter = dirInfo->m_files.begin(); - while (fileiter != dirInfo->m_files.end()) { - if (SearchStringMatches(fileiter->second.m_filename, searchName)) { - AsciiString tempfilename; - tempfilename = currentDirectory; - if ((tempfilename.getLength() > 0) && (!tempfilename.endsWith("\\"))) { - tempfilename.concat('\\'); - } - tempfilename.concat(fileiter->second.m_filename); - if (filenameList.find(tempfilename) == filenameList.end()) { - // only insert into the list if its not already in there. - filenameList.insert(tempfilename); - } - } - fileiter++; - } -} - -void ArchiveFile::attachFile(File *file) -{ - if (m_file != NULL) { - m_file->close(); - m_file = NULL; - } - m_file = file; -} - -const ArchivedFileInfo * ArchiveFile::getArchivedFileInfo(const AsciiString& filename) const -{ - AsciiString path; - path = filename; - path.toLower(); - AsciiString token; - - const DetailedArchivedDirectoryInfo *dirInfo = &m_rootDirectory; - - path.nextToken(&token, "\\/"); - - while ((token.find('.') == NULL) || (path.find('.') != NULL)) { - - DetailedArchivedDirectoryInfoMap::const_iterator it = dirInfo->m_directories.find(token); - if (it != dirInfo->m_directories.end()) - { - dirInfo = &it->second; - } - else - { - return NULL; - } - - path.nextToken(&token, "\\/"); - } - - ArchivedFileInfoMap::const_iterator it = dirInfo->m_files.find(token); - if (it != dirInfo->m_files.end()) - { - return &it->second; - } - else - { - return NULL; - } - -} diff --git a/Generals/Code/GameEngine/Source/Common/System/ArchiveFileSystem.cpp b/Generals/Code/GameEngine/Source/Common/System/ArchiveFileSystem.cpp deleted file mode 100644 index f1a3419e34..0000000000 --- a/Generals/Code/GameEngine/Source/Common/System/ArchiveFileSystem.cpp +++ /dev/null @@ -1,322 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: Generals -// -// Module: Game Engine Common -// -// File name: ArchiveFileSystem.cpp -// -// Created: 11/26/01 TR -// -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "PreRTS.h" -#include "Common/ArchiveFile.h" -#include "Common/ArchiveFileSystem.h" -#include "Common/AsciiString.h" -#include "Common/PerfTimer.h" - - -//---------------------------------------------------------------------------- -// Externals -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Defines -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Types -//---------------------------------------------------------------------------- - - -//---------------------------------------------------------------------------- -// Private Data -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Public Data -//---------------------------------------------------------------------------- - -ArchiveFileSystem *TheArchiveFileSystem = NULL; - - -//---------------------------------------------------------------------------- -// Private Prototypes -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Functions -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Public Functions -//---------------------------------------------------------------------------- - -//------------------------------------------------------ -// ArchivedFileInfo -//------------------------------------------------------ -ArchiveFileSystem::ArchiveFileSystem() -{ -} - -ArchiveFileSystem::~ArchiveFileSystem() -{ - ArchiveFileMap::iterator iter = m_archiveFileMap.begin(); - while (iter != m_archiveFileMap.end()) { - ArchiveFile *file = iter->second; - if (file != NULL) { - delete file; - file = NULL; - } - iter++; - } -} - -void ArchiveFileSystem::loadIntoDirectoryTree(const ArchiveFile *archiveFile, const AsciiString& archiveFilename, Bool overwrite) -{ - - FilenameList filenameList; - - archiveFile->getFileListInDirectory(AsciiString(""), AsciiString(""), AsciiString("*"), filenameList, TRUE); - - FilenameListIter it = filenameList.begin(); - - while (it != filenameList.end()) { - // add this filename to the directory tree. - AsciiString path = *it; - path.toLower(); - AsciiString token; - AsciiString debugpath; - - ArchivedDirectoryInfo *dirInfo = &m_rootDirectory; - - Bool infoInPath; - infoInPath = path.nextToken(&token, "\\/"); - - while (infoInPath && (!token.find('.') || path.find('.'))) { - ArchivedDirectoryInfoMap::iterator tempiter = dirInfo->m_directories.find(token); - if (tempiter == dirInfo->m_directories.end()) - { - dirInfo->m_directories[token].clear(); - dirInfo->m_directories[token].m_directoryName = token; - } - - dirInfo = &(dirInfo->m_directories[token]); - debugpath.concat(token); - debugpath.concat('\\'); - infoInPath = path.nextToken(&token, "\\/"); - } - - // token is the filename, and dirInfo is the directory that this file is in. - if (dirInfo->m_files.find(token) == dirInfo->m_files.end() || overwrite) { - AsciiString path2; - path2 = debugpath; - path2.concat(token); -// DEBUG_LOG(("ArchiveFileSystem::loadIntoDirectoryTree - adding file %s, archived in %s", path2.str(), archiveFilename.str())); - dirInfo->m_files[token] = archiveFilename; - } - - it++; - } -} - -void ArchiveFileSystem::loadMods() { - if (TheGlobalData->m_modBIG.isNotEmpty()) - { - ArchiveFile *archiveFile = openArchiveFile(TheGlobalData->m_modBIG.str()); - - if (archiveFile != NULL) { - DEBUG_LOG(("ArchiveFileSystem::loadMods - loading %s into the directory tree.", TheGlobalData->m_modBIG.str())); - loadIntoDirectoryTree(archiveFile, TheGlobalData->m_modBIG, TRUE); - m_archiveFileMap[TheGlobalData->m_modBIG] = archiveFile; - DEBUG_LOG(("ArchiveFileSystem::loadMods - %s inserted into the archive file map.", TheGlobalData->m_modBIG.str())); - } - else - { - DEBUG_LOG(("ArchiveFileSystem::loadMods - could not openArchiveFile(%s)", TheGlobalData->m_modBIG.str())); - } - } - - if (TheGlobalData->m_modDir.isNotEmpty()) - { -#ifdef DEBUG_LOGGING - Bool ret = -#endif - loadBigFilesFromDirectory(TheGlobalData->m_modDir, "*.big", TRUE); - DEBUG_ASSERTLOG(ret, ("loadBigFilesFromDirectory(%s) returned FALSE!", TheGlobalData->m_modDir.str())); - } -} - -Bool ArchiveFileSystem::doesFileExist(const Char *filename) const -{ - AsciiString path = filename; - path.toLower(); - AsciiString token; - - const ArchivedDirectoryInfo *dirInfo = &m_rootDirectory; - - path.nextToken(&token, "\\/"); - - while (!token.find('.') || path.find('.')) - { - ArchivedDirectoryInfoMap::const_iterator tempiter = dirInfo->m_directories.find(token); - if (tempiter != dirInfo->m_directories.end()) - { - dirInfo = &tempiter->second; - path.nextToken(&token, "\\/"); - } - else - { - // the directory doesn't exist, so return false - return FALSE; - } - } - - // token is the filename, and dirInfo is the directory that this file is in. - if (dirInfo->m_files.find(token) == dirInfo->m_files.end()) { - return FALSE; - } - return TRUE; -} - -File * ArchiveFileSystem::openFile(const Char *filename, Int access /* = 0 */) -{ - AsciiString archiveFilename; - archiveFilename = getArchiveFilenameForFile(AsciiString(filename)); - - if (archiveFilename.getLength() == 0) { - return NULL; - } - - return m_archiveFileMap[archiveFilename]->openFile(filename, access); -} - -Bool ArchiveFileSystem::getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const -{ - if (fileInfo == NULL) { - return FALSE; - } - - if (filename.getLength() <= 0) { - return FALSE; - } - - AsciiString archiveFilename = getArchiveFilenameForFile(filename); - ArchiveFileMap::const_iterator it = m_archiveFileMap.find(archiveFilename); - if (it != m_archiveFileMap.end()) - { - return it->second->getFileInfo(filename, fileInfo); - } - else - { - return FALSE; - } -} - -AsciiString ArchiveFileSystem::getArchiveFilenameForFile(const AsciiString& filename) const -{ - AsciiString path; - path = filename; - path.toLower(); - AsciiString token; - AsciiString debugpath; - - const ArchivedDirectoryInfo *dirInfo = &m_rootDirectory; - - path.nextToken(&token, "\\/"); - - while (!token.find('.') || path.find('.')) { - - ArchivedDirectoryInfoMap::const_iterator it = dirInfo->m_directories.find(token); - if (it != dirInfo->m_directories.end()) - { - dirInfo = &it->second; - } - else - { - // the directory doesn't exist, so return NULL - - // dump the directories; - //DEBUG_LOG(("directory %s not found in %s in archive file system", token.str(), debugpath.str())); - //DEBUG_LOG(("directories in %s in archive file system are:", debugpath.str())); - //ArchivedDirectoryInfoMap::const_iterator it = dirInfo->m_directories.begin(); - //while (it != dirInfo->m_directories.end()) { - // DEBUG_LOG(("\t%s", it->second.m_directoryName.str())); - // it++; - //} - //DEBUG_LOG(("end of directory list.")); - return AsciiString::TheEmptyString; - } - - debugpath.concat(token); - debugpath.concat('\\'); - - path.nextToken(&token, "\\/"); - } - - ArchivedFileLocationMap::const_iterator it = dirInfo->m_files.find(token); - if (it != dirInfo->m_files.end()) - { - return it->second; - } - else - { - return AsciiString::TheEmptyString; - } - -} - -void ArchiveFileSystem::getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const -{ - ArchiveFileMap::const_iterator it = m_archiveFileMap.begin(); - while (it != m_archiveFileMap.end()) { - it->second->getFileListInDirectory(currentDirectory, originalDirectory, searchName, filenameList, searchSubdirectories); - it++; - } -} diff --git a/Generals/Code/GameEngine/Source/Common/System/File.cpp b/Generals/Code/GameEngine/Source/Common/System/File.cpp deleted file mode 100644 index e8ba3441ce..0000000000 --- a/Generals/Code/GameEngine/Source/Common/System/File.cpp +++ /dev/null @@ -1,259 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: WSYS Library -// -// Module: IO_ -// -// File name: IO_File.cpp -// -// Created: 4/23/01 -// -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "PreRTS.h" - -#include -#include -#include -#include - - -#include "Common/file.h" - - -//---------------------------------------------------------------------------- -// Externals -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Defines -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Types -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Data -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Public Data -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Prototypes -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Functions -//---------------------------------------------------------------------------- - -//================================================================= -// File::File -//================================================================= - -File::File() -: m_open(FALSE), - m_deleteOnClose(FALSE), - m_access(NONE) -{ - - setName(""); - -} - - -//---------------------------------------------------------------------------- -// Public Functions -//---------------------------------------------------------------------------- - - -//================================================================= -// File::~File -//================================================================= - -File::~File() -{ - close(); -} - -//================================================================= -// File::open -//================================================================= -/** - * Any derived open() members must first call File::open. If File::open - * succeeds but the derived class's open failes then make sure to call - * File::close() before returning. - */ -//================================================================= - -Bool File::open( const Char *filename, Int access ) -{ - if( m_open ) - { - return FALSE; - } - - setName( filename ); - - if( (access & ( STREAMING | WRITE )) == ( STREAMING | WRITE )) - { - // illegal access - return FALSE; - } - - if( (access & ( TEXT | BINARY)) == ( TEXT | BINARY )) - { - // illegal access - return FALSE; - } - - if ( (access & (READ|WRITE)) == 0 ) - { - access |= READ; - } - - if ( !(access & (READ|APPEND)) ) - { - access |= TRUNCATE; - } - - if ( (access & (TEXT|BINARY)) == 0 ) - { - access |= BINARY; - } - - m_access = access; - m_open = TRUE; - return TRUE; -} - -//================================================================= -// File::close -//================================================================= -/** - * Must call File::close() for each successful File::open() call. - */ -//================================================================= - -void File::close( void ) -{ - if( m_open ) - { - setName( "" ); - m_open = FALSE; - if ( m_deleteOnClose ) - { - deleteInstance(this); // on special cases File object will delete itself when closing - } - } -} - -//================================================================= -// File::size -//================================================================= -/** - * Default implementation of File::size. Derived classes can optimize - * this member function. - */ -//================================================================= - -Int File::size( void ) -{ - Int pos = seek( 0, CURRENT ); - Int size = seek( 0, END ); - - seek( pos, START ); - - return size < 0 ? 0 : size; -} - -//============================================================================ -// File::position -//============================================================================ - -Int File::position( void ) -{ - return seek(0, CURRENT); -} - -//============================================================================ -// File::print -//============================================================================ - -Bool File::print ( const Char *format, ...) -{ - Char buffer[10*1024]; - Int len; - - if ( ! (m_access & TEXT ) ) - { - return FALSE; - } - - va_list args; - va_start( args, format ); /* Initialize variable arguments. */ - len = vsprintf( buffer, format, args ); - va_end( args ); - - if ( len >= sizeof(buffer) ) - { - // Big Problem - assert( FALSE ); - return FALSE; - } - - return (write ( buffer, len ) == len); -} - -Bool File::eof() { - return (position() == size()); -} \ No newline at end of file diff --git a/Generals/Code/GameEngine/Source/Common/System/FileSystem.cpp b/Generals/Code/GameEngine/Source/Common/System/FileSystem.cpp deleted file mode 100644 index f13568ad78..0000000000 --- a/Generals/Code/GameEngine/Source/Common/System/FileSystem.cpp +++ /dev/null @@ -1,374 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: WSYS Library -// -// Module: IO -// -// File name: IO_FileSystem.cpp -// -// Created: 4/23/01 -// -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "PreRTS.h" -#include "Common/file.h" -#include "Common/FileSystem.h" - -#include "Common/ArchiveFileSystem.h" -#include "Common/CDManager.h" -#include "Common/GameAudio.h" -#include "Common/LocalFileSystem.h" -#include "Common/PerfTimer.h" - - -DECLARE_PERF_TIMER(FileSystem) - -//---------------------------------------------------------------------------- -// Externals -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Defines -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Types -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Data -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Public Data -//---------------------------------------------------------------------------- - -//=============================== -// TheFileSystem -//=============================== -/** - * This is the FileSystem's singleton class. All file access - * should be through TheFileSystem, unless code needs to use an explicit - * File or FileSystem derivative. - * - * Using TheFileSystem->open and File exclusively for file access, particularly - * in library or modular code, allows applications to transparently implement - * file access as they see fit. This is particularly important for code that - * needs to be shared between applications, such as games and tools. - */ -//=============================== - -FileSystem *TheFileSystem = NULL; - -//---------------------------------------------------------------------------- -// Private Prototypes -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// Private Functions -//---------------------------------------------------------------------------- - - -//---------------------------------------------------------------------------- -// Public Functions -//---------------------------------------------------------------------------- - - -//============================================================================ -// FileSystem::FileSystem -//============================================================================ - -FileSystem::FileSystem() -{ - -} - -//============================================================================ -// FileSystem::~FileSystem -//============================================================================ - -FileSystem::~FileSystem() -{ - -} - -//============================================================================ -// FileSystem::init -//============================================================================ - -void FileSystem::init( void ) -{ - TheLocalFileSystem->init(); - TheArchiveFileSystem->init(); -} - -//============================================================================ -// FileSystem::update -//============================================================================ - -void FileSystem::update( void ) -{ - USE_PERF_TIMER(FileSystem) - TheLocalFileSystem->update(); - TheArchiveFileSystem->update(); -} - -//============================================================================ -// FileSystem::reset -//============================================================================ - -void FileSystem::reset( void ) -{ - USE_PERF_TIMER(FileSystem) - TheLocalFileSystem->reset(); - TheArchiveFileSystem->reset(); -} - -//============================================================================ -// FileSystem::open -//============================================================================ - -File* FileSystem::openFile( const Char *filename, Int access ) -{ - USE_PERF_TIMER(FileSystem) - File *file = NULL; - - if ( TheLocalFileSystem != NULL ) - { - file = TheLocalFileSystem->openFile( filename, access ); - } - - if ( (TheArchiveFileSystem != NULL) && (file == NULL) ) - { - file = TheArchiveFileSystem->openFile( filename ); - } - - return file; -} - -//============================================================================ -// FileSystem::doesFileExist -//============================================================================ - -Bool FileSystem::doesFileExist(const Char *filename) const -{ - USE_PERF_TIMER(FileSystem) - if (TheLocalFileSystem->doesFileExist(filename)) { - return TRUE; - } - if (TheArchiveFileSystem->doesFileExist(filename)) { - return TRUE; - } - return FALSE; -} - -//============================================================================ -// FileSystem::getFileListInDirectory -//============================================================================ -void FileSystem::getFileListInDirectory(const AsciiString& directory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const -{ - USE_PERF_TIMER(FileSystem) - TheLocalFileSystem->getFileListInDirectory(AsciiString(""), directory, searchName, filenameList, searchSubdirectories); - TheArchiveFileSystem->getFileListInDirectory(AsciiString(""), directory, searchName, filenameList, searchSubdirectories); -} - -//============================================================================ -// FileSystem::getFileInfo -//============================================================================ -Bool FileSystem::getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const -{ - USE_PERF_TIMER(FileSystem) - if (fileInfo == NULL) { - return FALSE; - } - memset(fileInfo, 0, sizeof(*fileInfo)); - - if (TheLocalFileSystem->getFileInfo(filename, fileInfo)) { - return TRUE; - } - - if (TheArchiveFileSystem->getFileInfo(filename, fileInfo)) { - return TRUE; - } - - return FALSE; -} - -//============================================================================ -// FileSystem::createDirectory -//============================================================================ -Bool FileSystem::createDirectory(AsciiString directory) -{ - USE_PERF_TIMER(FileSystem) - if (TheLocalFileSystem != NULL) { - return TheLocalFileSystem->createDirectory(directory); - } - return FALSE; -} - -//============================================================================ -// FileSystem::areMusicFilesOnCD -//============================================================================ -Bool FileSystem::areMusicFilesOnCD() -{ -#if 1 - return TRUE; -#else - if (!TheCDManager) { - DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - No CD Manager; returning false")); - return FALSE; - } - - AsciiString cdRoot; - Int dc = TheCDManager->driveCount(); - for (Int i = 0; i < dc; ++i) { - DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - checking drive %d", i)); - CDDriveInterface *cdi = TheCDManager->getDrive(i); - if (!cdi) { - continue; - } - - cdRoot = cdi->getPath(); - if (!cdRoot.endsWith("\\")) - cdRoot.concat("\\"); - cdRoot.concat("gensec.big"); - DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - checking for %s", cdRoot.str())); - File *musicBig = TheLocalFileSystem->openFile(cdRoot.str()); - if (musicBig) - { - DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - found it!")); - musicBig->close(); - return TRUE; - } - } - return FALSE; -#endif -} -//============================================================================ -// FileSystem::loadMusicFilesFromCD -//============================================================================ -void FileSystem::loadMusicFilesFromCD() -{ - if (!TheCDManager) { - return; - } - - AsciiString cdRoot; - Int dc = TheCDManager->driveCount(); - for (Int i = 0; i < dc; ++i) { - CDDriveInterface *cdi = TheCDManager->getDrive(i); - if (!cdi) { - continue; - } - - cdRoot = cdi->getPath(); - if (TheArchiveFileSystem->loadBigFilesFromDirectory(cdRoot, MUSIC_BIG)) { - break; - } - } -} - -//============================================================================ -// FileSystem::unloadMusicFilesFromCD -//============================================================================ -void FileSystem::unloadMusicFilesFromCD() -{ - if (!(TheAudio && TheAudio->isMusicPlayingFromCD())) { - return; - } - - TheArchiveFileSystem->closeArchiveFile( MUSIC_BIG ); -} - -//============================================================================ -// FileSystem::normalizePath -//============================================================================ -AsciiString FileSystem::normalizePath(const AsciiString& path) const -{ - return TheLocalFileSystem->normalizePath(path); -} - -//============================================================================ -// FileSystem::isPathInDirectory -//============================================================================ -Bool FileSystem::isPathInDirectory(const AsciiString& testPath, const AsciiString& basePath) -{ - AsciiString testPathNormalized = TheFileSystem->normalizePath(testPath); - AsciiString basePathNormalized = TheFileSystem->normalizePath(basePath); - - if (basePathNormalized.isEmpty()) - { - DEBUG_CRASH(("Unable to normalize base directory path '%s'.", basePath.str())); - return false; - } - else if (testPathNormalized.isEmpty()) - { - DEBUG_CRASH(("Unable to normalize file path '%s'.", testPath.str())); - return false; - } - -#ifdef _WIN32 - const char* pathSep = "\\"; -#else - const char* pathSep = "/"; -#endif - - if (!basePathNormalized.endsWith(pathSep)) - { - basePathNormalized.concat(pathSep); - } - -#ifdef _WIN32 - if (!testPathNormalized.startsWithNoCase(basePathNormalized)) -#else - if (!testPathNormalized.startsWith(basePathNormalized)) -#endif - { - return false; - } - - return true; -} \ No newline at end of file diff --git a/Generals/Code/GameEngine/Source/Common/System/LocalFile.cpp b/Generals/Code/GameEngine/Source/Common/System/LocalFile.cpp deleted file mode 100644 index 6ddc2a4133..0000000000 --- a/Generals/Code/GameEngine/Source/Common/System/LocalFile.cpp +++ /dev/null @@ -1,622 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: WSYS Library -// -// Module: IO_ -// -// File name: IO_LocalFile.cpp -// -// Created: 4/23/01 -// -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "PreRTS.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "Common/LocalFile.h" -#include "Common/RAMFile.h" -#include "Lib/BaseType.h" -#include "Common/PerfTimer.h" - - - -//---------------------------------------------------------------------------- -// Externals -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Defines -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Types -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Data -//---------------------------------------------------------------------------- - -static Int s_totalOpen = 0; - -//---------------------------------------------------------------------------- -// Public Data -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Prototypes -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Functions -//---------------------------------------------------------------------------- - -//================================================================= -// LocalFile::LocalFile -//================================================================= - -LocalFile::LocalFile() -#ifdef USE_BUFFERED_IO - : m_file(NULL) -#else - : m_handle(-1) -#endif -{ -} - - -//---------------------------------------------------------------------------- -// Public Functions -//---------------------------------------------------------------------------- - - -//================================================================= -// LocalFile::~LocalFile -//================================================================= - -LocalFile::~LocalFile() -{ -#ifdef USE_BUFFERED_IO - if (m_file) - { - fclose(m_file); - m_file = NULL; - --s_totalOpen; - } -#else - if( m_handle != -1 ) - { - _close( m_handle ); - m_handle = -1; - --s_totalOpen; - } -#endif - - File::close(); - -} - -//================================================================= -// LocalFile::open -//================================================================= -/** - * This function opens a file using the standard C open() call. Access flags - * are mapped to the appropriate open flags. Returns true if file was opened - * successfully. - */ -//================================================================= - -//DECLARE_PERF_TIMER(LocalFile) -Bool LocalFile::open( const Char *filename, Int access ) -{ - //USE_PERF_TIMER(LocalFile) - if( !File::open( filename, access) ) - { - return FALSE; - } - - /* here we translate WSYS file access to the std C equivalent */ -#ifdef USE_BUFFERED_IO - char mode[32]; - char* m = mode; - - if (m_access & APPEND) - { - DEBUG_CRASH(("not yet supported by buffered mode")); - } - - if (m_access & TRUNCATE) - { - DEBUG_CRASH(("not yet supported by buffered mode")); - } - - if((m_access & READWRITE ) == READWRITE ) - { - if (m_access & CREATE) - { - *m++ = 'w'; - *m++ = '+'; - } - else - { - *m++ = 'r'; - *m++ = '+'; - } - } - else if(m_access & WRITE) - { - *m++ = 'w'; - } - else - { - *m++ = 'r'; - DEBUG_ASSERTCRASH(!(m_access & TRUNCATE), ("cannot truncate with read-only")); - } - - if (m_access & TEXT) - { - *m++ = 't'; - } - if (m_access & BINARY) - { - *m++ = 'b'; - } - - *m++ = 0; - - m_file = fopen(filename, mode); - if (m_file == NULL) - { - goto error; - } - - //setvbuf(m_file, m_vbuf, _IOFBF, sizeof(BUF_SIZE)); - -#else - - int flags = 0; - - if (m_access & CREATE) - { - flags |= _O_CREAT; - } - if (m_access & TRUNCATE) - { - flags |= _O_TRUNC; - } - if (m_access & APPEND) - { - flags |= _O_APPEND; - } - if (m_access & TEXT) - { - flags |= _O_TEXT; - } - if (m_access & BINARY) - { - flags |= _O_BINARY; - } - - if((m_access & READWRITE )== READWRITE ) - { - flags |= _O_RDWR; - } - else if(m_access & WRITE) - { - flags |= _O_WRONLY; - flags |= _O_CREAT; - } - else - { - flags |= _O_RDONLY; - } - - m_handle = _open( filename, flags , _S_IREAD | _S_IWRITE); - - if( m_handle == -1 ) - { - goto error; - } - -#endif - - ++s_totalOpen; -/// DEBUG_LOG(("LocalFile::open %s (total %d)",filename,s_totalOpen)); - if ( m_access & APPEND ) - { - if ( seek ( 0, END ) < 0 ) - { - goto error; - } - } - - return TRUE; - -error: - - close(); - - return FALSE; -} - -//================================================================= -// LocalFile::close -//================================================================= -/** - * Closes the current file if it is open. - * Must call LocalFile::close() for each successful LocalFile::open() call. - */ -//================================================================= - -void LocalFile::close( void ) -{ - File::close(); -} - -//================================================================= -// LocalFile::read -//================================================================= - -Int LocalFile::read( void *buffer, Int bytes ) -{ - //USE_PERF_TIMER(LocalFile) - if( !m_open ) - { - return -1; - } - - if (buffer == NULL) - { -#ifdef USE_BUFFERED_IO - fseek(m_file, bytes, SEEK_CUR); -#else - _lseek(m_handle, bytes, SEEK_CUR); -#endif - return bytes; - } - -#ifdef USE_BUFFERED_IO - Int ret = fread(buffer, 1, bytes, m_file); -#else - Int ret = _read( m_handle, buffer, bytes ); -#endif - - return ret; -} - -//================================================================= -// LocalFile::write -//================================================================= - -Int LocalFile::write( const void *buffer, Int bytes ) -{ - - if( !m_open || !buffer ) - { - return -1; - } - -#ifdef USE_BUFFERED_IO - Int ret = fwrite(buffer, 1, bytes, m_file); -#else - Int ret = _write( m_handle, buffer, bytes ); -#endif - return ret; -} - -//================================================================= -// LocalFile::seek -//================================================================= - -Int LocalFile::seek( Int pos, seekMode mode) -{ - int lmode; - - switch( mode ) - { - case START: - lmode = SEEK_SET; - break; - case CURRENT: - lmode = SEEK_CUR; - break; - case END: - DEBUG_ASSERTCRASH(pos <= 0, ("LocalFile::seek - pos should be <= 0 for a seek starting at the end of the file")); - lmode = SEEK_END; - break; - default: - // bad seek mode - return -1; - } - -#ifdef USE_BUFFERED_IO - Int ret = fseek(m_file, pos, lmode); - if (ret == 0) - return ftell(m_file); - else - return -1; -#else - Int ret = _lseek( m_handle, pos, lmode ); -#endif - return ret; -} - -//================================================================= -// LocalFile::scanInt -//================================================================= -// skips preceding whitespace and stops at the first non-number -// or at EOF -Bool LocalFile::scanInt(Int &newInt) -{ - newInt = 0; - AsciiString tempstr; - Char c; - Int val; - - // skip preceding non-numeric characters - do { -#ifdef USE_BUFFERED_IO - val = fread(&c, 1, 1, m_file); -#else - val = _read( m_handle, &c, 1); -#endif - } while ((val != 0) && (((c < '0') || (c > '9')) && (c != '-'))); - - if (val == 0) { - return FALSE; - } - - do { - tempstr.concat(c); -#ifdef USE_BUFFERED_IO - val = fread(&c, 1, 1, m_file); -#else - val = _read( m_handle, &c, 1); -#endif - } while ((val != 0) && ((c >= '0') && (c <= '9'))); - - // put the last read char back, since we didn't use it. - if (val != 0) { -#ifdef USE_BUFFERED_IO - fseek(m_file, -1, SEEK_CUR); -#else - _lseek(m_handle, -1, SEEK_CUR); -#endif - } - - newInt = atoi(tempstr.str()); - return TRUE; -} - -//================================================================= -// LocalFile::scanReal -//================================================================= -// skips preceding whitespace and stops at the first non-number -// or at EOF -Bool LocalFile::scanReal(Real &newReal) -{ - newReal = 0.0; - AsciiString tempstr; - Char c; - Int val; - Bool sawDec = FALSE; - - // skip the preceding white space - do { -#ifdef USE_BUFFERED_IO - val = fread(&c, 1, 1, m_file); -#else - val = _read( m_handle, &c, 1); -#endif - } while ((val != 0) && (((c < '0') || (c > '9')) && (c != '-') && (c != '.'))); - - if (val == 0) { - return FALSE; - } - - do { - tempstr.concat(c); - if (c == '.') { - sawDec = TRUE; - } -#ifdef USE_BUFFERED_IO - val = fread(&c, 1, 1, m_file); -#else - val = _read(m_handle, &c, 1); -#endif - } while ((val != 0) && (((c >= '0') && (c <= '9')) || ((c == '.') && !sawDec))); - - if (val != 0) { -#ifdef USE_BUFFERED_IO - fseek(m_file, -1, SEEK_CUR); -#else - _lseek(m_handle, -1, SEEK_CUR); -#endif - } - - newReal = atof(tempstr.str()); - return TRUE; -} - -//================================================================= -// LocalFile::scanString -//================================================================= -// skips preceding whitespace and stops at the first whitespace -// or at EOF -Bool LocalFile::scanString(AsciiString &newString) -{ - Char c; - Int val; - - newString.clear(); - - // skip the preceding whitespace - do { -#ifdef USE_BUFFERED_IO - val = fread(&c, 1, 1, m_file); -#else - val = _read(m_handle, &c, 1); -#endif - } while ((val != 0) && (isspace(c))); - - if (val == 0) { - return FALSE; - } - - do { - newString.concat(c); -#ifdef USE_BUFFERED_IO - val = fread(&c, 1, 1, m_file); -#else - val = _read(m_handle, &c, 1); -#endif - } while ((val != 0) && (!isspace(c))); - - if (val != 0) { -#ifdef USE_BUFFERED_IO - fseek(m_file, -1, SEEK_CUR); -#else - _lseek(m_handle, -1, SEEK_CUR); -#endif - } - - return TRUE; -} - -//================================================================= -// LocalFile::nextLine -//================================================================= -// scans to the first character after a new-line or at EOF -void LocalFile::nextLine(Char *buf, Int bufSize) -{ - Char c = 0; - Int val; - Int i = 0; - - // seek to the next new-line. - do { - if ((buf == NULL) || (i >= (bufSize-1))) { -#ifdef USE_BUFFERED_IO - val = fread(&c, 1, 1, m_file); -#else - val = _read(m_handle, &c, 1); -#endif - } else { -#ifdef USE_BUFFERED_IO - val = fread(buf + i, 1, 1, m_file); -#else - val = _read(m_handle, buf + i, 1); -#endif - c = buf[i]; - } - ++i; - } while ((val != 0) && (c != '\n')); - - if (buf != NULL) { - if (i < bufSize) { - buf[i] = 0; - } else { - buf[bufSize] = 0; - } - } -} - -//================================================================= -//================================================================= -File* LocalFile::convertToRAMFile() -{ - RAMFile *ramFile = newInstance( RAMFile ); - if (ramFile->open(this)) - { - if (this->m_deleteOnClose) - { - ramFile->deleteOnClose(); - this->close(); // is deleteonclose, so should delete. - } - else - { - this->close(); - deleteInstance(this); - } - return ramFile; - } - else - { - ramFile->close(); - deleteInstance(ramFile); - return this; - } -} - -//================================================================= -// LocalFile::readEntireAndClose -//================================================================= -/** - Allocate a buffer large enough to hold entire file, read - the entire file into the buffer, then close the file. - the buffer is owned by the caller, who is responsible - for freeing is (via delete[]). This is a Good Thing to - use because it minimizes memory copies for BIG files. -*/ -char* LocalFile::readEntireAndClose() -{ - UnsignedInt fileSize = size(); - char* buffer = NEW char[fileSize]; - - read(buffer, fileSize); - - close(); - - return buffer; -} diff --git a/Generals/Code/GameEngine/Source/Common/System/LocalFileSystem.cpp b/Generals/Code/GameEngine/Source/Common/System/LocalFileSystem.cpp deleted file mode 100644 index f912f2ad0d..0000000000 --- a/Generals/Code/GameEngine/Source/Common/System/LocalFileSystem.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: Game Engine -// -// Module: IO -// -// File name: LocalFileSystem.cpp -// -// Created: 4/23/01 -// -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "PreRTS.h" -#include "Common/LocalFileSystem.h" - -//---------------------------------------------------------------------------- -// Externals -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Defines -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Types -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Data -//---------------------------------------------------------------------------- - - -//---------------------------------------------------------------------------- -// Public Data -//---------------------------------------------------------------------------- - -LocalFileSystem *TheLocalFileSystem = NULL; - -//---------------------------------------------------------------------------- -// Private Prototypes -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Functions -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Public Functions -//---------------------------------------------------------------------------- - -void LocalFileSystem::init() { -} - -void LocalFileSystem::reset() { -} - -void LocalFileSystem::update() { -} diff --git a/Generals/Code/GameEngine/Source/Common/System/RAMFile.cpp b/Generals/Code/GameEngine/Source/Common/System/RAMFile.cpp deleted file mode 100644 index a228708073..0000000000 --- a/Generals/Code/GameEngine/Source/Common/System/RAMFile.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: WSYS Library -// -// Module: IO -// -// File name: WSYS_RAMFile.cpp -// -// Created: 11/08/01 -// -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "PreRTS.h" - -#include -#include -#include -#include -#include - -#include "Common/AsciiString.h" -#include "Common/FileSystem.h" -#include "Common/RAMFile.h" -#include "Common/PerfTimer.h" - - -//---------------------------------------------------------------------------- -// Externals -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Defines -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Types -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Data -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Public Data -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Prototypes -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Functions -//---------------------------------------------------------------------------- - -//================================================================= -// RAMFile::RAMFile -//================================================================= - -RAMFile::RAMFile() -: m_size(0), - m_data(NULL), -//Added By Sadullah Nader -//Initializtion(s) inserted - m_pos(0) -// -{ - -} - - -//---------------------------------------------------------------------------- -// Public Functions -//---------------------------------------------------------------------------- - - -//================================================================= -// RAMFile::~RAMFile -//================================================================= - -RAMFile::~RAMFile() -{ - if (m_data != NULL) { - delete [] m_data; - } - - File::close(); - -} - -//================================================================= -// RAMFile::open -//================================================================= -/** - * This function opens a file using the standard C open() call. Access flags - * are mapped to the appropriate open flags. Returns true if file was opened - * successfully. - */ -//================================================================= - -//DECLARE_PERF_TIMER(RAMFile) -Bool RAMFile::open( const Char *filename, Int access ) -{ - //USE_PERF_TIMER(RAMFile) - File *file = TheFileSystem->openFile( filename, access ); - - if ( file == NULL ) - { - return FALSE; - } - - Bool result = open( file ); - - file->close(); - - return result; -} - -//============================================================================ -// RAMFile::open -//============================================================================ - -Bool RAMFile::open( File *file ) -{ - //USE_PERF_TIMER(RAMFile) - if ( file == NULL ) - { - return NULL; - } - - Int access = file->getAccess(); - - if ( !File::open( file->getName(), access )) - { - return FALSE; - } - - // read whole file in to memory - m_size = file->size(); - m_data = MSGNEW("RAMFILE") char [ m_size ]; // pool[]ify - - if ( m_data == NULL ) - { - return FALSE; - } - - m_size = file->read( m_data, m_size ); - - if ( m_size < 0 ) - { - delete [] m_data; - m_data = NULL; - return FALSE; - } - - m_pos = 0; - - return TRUE; -} - -//============================================================================ -// RAMFile::openFromArchive -//============================================================================ -Bool RAMFile::openFromArchive(File *archiveFile, const AsciiString& filename, Int offset, Int size) -{ - //USE_PERF_TIMER(RAMFile) - if (archiveFile == NULL) { - return FALSE; - } - - if (File::open(filename.str(), File::READ | File::BINARY) == FALSE) { - return FALSE; - } - - if (m_data != NULL) { - delete[] m_data; - m_data = NULL; - } - m_data = MSGNEW("RAMFILE") Char [size]; // pool[]ify - m_size = size; - - if (archiveFile->seek(offset, File::START) != offset) { - return FALSE; - } - if (archiveFile->read(m_data, size) != size) { - return FALSE; - } - m_nameStr = filename; - - return TRUE; -} - -//================================================================= -// RAMFile::close -//================================================================= -/** - * Closes the current file if it is open. - * Must call RAMFile::close() for each successful RAMFile::open() call. - */ -//================================================================= - -void RAMFile::close( void ) -{ - if ( m_data ) - { - delete [] m_data; - m_data = NULL; - } - - File::close(); -} - -//================================================================= -// RAMFile::read -//================================================================= -// if buffer is null, just advance the current position by 'bytes' -Int RAMFile::read( void *buffer, Int bytes ) -{ - if( m_data == NULL ) - { - return -1; - } - - Int bytesLeft = m_size - m_pos ; - - if ( bytes > bytesLeft ) - { - bytes = bytesLeft; - } - - if (( bytes > 0 ) && ( buffer != NULL )) - { - memcpy ( buffer, &m_data[m_pos], bytes ); - } - - m_pos += bytes; - - return bytes; -} - -//================================================================= -// RAMFile::write -//================================================================= - -Int RAMFile::write( const void *buffer, Int bytes ) -{ - return -1; -} - -//================================================================= -// RAMFile::seek -//================================================================= - -Int RAMFile::seek( Int pos, seekMode mode) -{ - Int newPos; - - switch( mode ) - { - case START: - newPos = pos; - break; - case CURRENT: - newPos = m_pos + pos; - break; - case END: - DEBUG_ASSERTCRASH(pos <= 0, ("RAMFile::seek - position should be <= 0 for a seek starting from the end.")); - newPos = m_size + pos; - break; - default: - // bad seek mode - return -1; - } - - if ( newPos < 0 ) - { - newPos = 0; - } - else if ( newPos > m_size ) - { - newPos = m_size; - } - - m_pos = newPos; - - return m_pos; - -} - -//================================================================= -// RAMFile::scanInt -//================================================================= -Bool RAMFile::scanInt(Int &newInt) -{ - newInt = 0; - AsciiString tempstr; - - while ((m_pos < m_size) && ((m_data[m_pos] < '0') || (m_data[m_pos] > '9')) && (m_data[m_pos] != '-')) { - ++m_pos; - } - - if (m_pos >= m_size) { - m_pos = m_size; - return FALSE; - } - - do { - tempstr.concat(m_data[m_pos]); - ++m_pos; - } while ((m_pos < m_size) && ((m_data[m_pos] >= '0') && (m_data[m_pos] <= '9'))); - -// if (m_pos < m_size) { -// --m_pos; -// } - - newInt = atoi(tempstr.str()); - return TRUE; -} - -//================================================================= -// RAMFile::scanInt -//================================================================= -Bool RAMFile::scanReal(Real &newReal) -{ - newReal = 0.0; - AsciiString tempstr; - Bool sawDec = FALSE; - - while ((m_pos < m_size) && ((m_data[m_pos] < '0') || (m_data[m_pos] > '9')) && (m_data[m_pos] != '-') && (m_data[m_pos] != '.')) { - ++m_pos; - } - - if (m_pos >= m_size) { - m_pos = m_size; - return FALSE; - } - - do { - tempstr.concat(m_data[m_pos]); - if (m_data[m_pos] == '.') { - sawDec = TRUE; - } - ++m_pos; - } while ((m_pos < m_size) && (((m_data[m_pos] >= '0') && (m_data[m_pos] <= '9')) || ((m_data[m_pos] == '.') && !sawDec))); - -// if (m_pos < m_size) { -// --m_pos; -// } - - newReal = atof(tempstr.str()); - return TRUE; -} - -//================================================================= -// RAMFile::scanString -//================================================================= -Bool RAMFile::scanString(AsciiString &newString) -{ - newString.clear(); - - while ((m_pos < m_size) && isspace(m_data[m_pos])) { - ++m_pos; - } - - if (m_pos >= m_size) { - m_pos = m_size; - return FALSE; - } - - do { - newString.concat(m_data[m_pos]); - ++m_pos; - } while ((m_pos < m_size) && (!isspace(m_data[m_pos]))); - - return TRUE; -} - -//================================================================= -// RAMFile::nextLine -//================================================================= -void RAMFile::nextLine(Char *buf, Int bufSize) -{ - Int i = 0; - // seek to the next new-line character - while ((m_pos < m_size) && (m_data[m_pos] != '\n')) { - if ((buf != NULL) && (i < (bufSize-1))) { - buf[i] = m_data[m_pos]; - ++i; - } - ++m_pos; - } - - // we got to the new-line character, now go one past it. - if (m_pos < m_size) { - if ((buf != NULL) && (i < bufSize)) { - buf[i] = m_data[m_pos]; - ++i; - } - ++m_pos; - } - if (buf != NULL) { - if (i < bufSize) { - buf[i] = 0; - } else { - buf[bufSize] = 0; - } - } - if (m_pos >= m_size) { - m_pos = m_size; - } -} - -//================================================================= -// RAMFile::nextLine -//================================================================= -Bool RAMFile::copyDataToFile(File *localFile) -{ - if (localFile == NULL) { - return FALSE; - } - - if (localFile->write(m_data, m_size) == m_size) { - return TRUE; - } - - - return FALSE; -} - -//================================================================= -//================================================================= -File* RAMFile::convertToRAMFile() -{ - return this; -} - -//================================================================= -// RAMFile::readEntireAndClose -//================================================================= -/** - Allocate a buffer large enough to hold entire file, read - the entire file into the buffer, then close the file. - the buffer is owned by the caller, who is responsible - for freeing is (via delete[]). This is a Good Thing to - use because it minimizes memory copies for BIG files. -*/ -char* RAMFile::readEntireAndClose() -{ - - if (m_data == NULL) - { - DEBUG_CRASH(("m_data is NULL in RAMFile::readEntireAndClose -- should not happen!")); - return NEW char[1]; // just to avoid crashing... - } - - char* tmp = m_data; - m_data = NULL; // will belong to our caller! - - close(); - - return tmp; -} diff --git a/Generals/Code/GameEngine/Source/Common/System/StreamingArchiveFile.cpp b/Generals/Code/GameEngine/Source/Common/System/StreamingArchiveFile.cpp deleted file mode 100644 index 7047997691..0000000000 --- a/Generals/Code/GameEngine/Source/Common/System/StreamingArchiveFile.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: RTS -// -// Module: IO -// -// File name: StreamingArchiveFile.cpp -// -// Created: 12/06/02 -// -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "PreRTS.h" - -#include -#include -#include -#include -#include - -#include "Common/AsciiString.h" -#include "Common/FileSystem.h" -#include "Common/StreamingArchiveFile.h" -#include "Common/PerfTimer.h" - - -//---------------------------------------------------------------------------- -// Externals -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Defines -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Types -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Data -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Public Data -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Prototypes -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Private Functions -//---------------------------------------------------------------------------- - -//================================================================= -// StreamingArchiveFile::StreamingArchiveFile -//================================================================= - -StreamingArchiveFile::StreamingArchiveFile() -: m_file(NULL), - m_startingPos(0), - m_size(0), - m_curPos(0) -{ - -} - - -//---------------------------------------------------------------------------- -// Public Functions -//---------------------------------------------------------------------------- - - -//================================================================= -// StreamingArchiveFile::~StreamingArchiveFile -//================================================================= - -StreamingArchiveFile::~StreamingArchiveFile() -{ - File::close(); -} - -//================================================================= -// StreamingArchiveFile::open -//================================================================= -/** - * This function opens a file using the standard C open() call. Access flags - * are mapped to the appropriate open flags. Returns true if file was opened - * successfully. - */ -//================================================================= - -//DECLARE_PERF_TIMER(StreamingArchiveFile) -Bool StreamingArchiveFile::open( const Char *filename, Int access ) -{ - //USE_PERF_TIMER(StreamingArchiveFile) - File *file = TheFileSystem->openFile( filename, access ); - - if ( file == NULL ) - { - return FALSE; - } - - return (open( file ) != NULL); -} - -//============================================================================ -// StreamingArchiveFile::open -//============================================================================ - -Bool StreamingArchiveFile::open( File *file ) -{ - return TRUE; -} - -//============================================================================ -// StreamingArchiveFile::openFromArchive -//============================================================================ -Bool StreamingArchiveFile::openFromArchive(File *archiveFile, const AsciiString& filename, Int offset, Int size) -{ - //USE_PERF_TIMER(StreamingArchiveFile) - if (archiveFile == NULL) { - return FALSE; - } - - if (File::open(filename.str(), File::READ | File::BINARY | File::STREAMING) == FALSE) { - return FALSE; - } - - m_file = archiveFile; - m_startingPos = offset; - m_size = size; - m_curPos = 0; - - if (m_file->seek(offset, File::START) != offset) { - return FALSE; - } - - if (m_file->seek(size) != m_startingPos + size) { - return FALSE; - } - - // We know this will succeed. - m_file->seek(offset, File::START); - - m_nameStr = filename; - - return TRUE; -} - -//================================================================= -// StreamingArchiveFile::close -//================================================================= -/** - * Closes the current file if it is open. - * Must call StreamingArchiveFile::close() for each successful StreamingArchiveFile::open() call. - */ -//================================================================= - -void StreamingArchiveFile::close( void ) -{ - File::close(); -} - -//================================================================= -// StreamingArchiveFile::read -//================================================================= -// if buffer is null, just advance the current position by 'bytes' -Int StreamingArchiveFile::read( void *buffer, Int bytes ) -{ - if (!m_file) { - return 0; - } - - // There shouldn't be a way that this can fail, because we've already verified that the file - // contains at least this many bits. - m_file->seek(m_startingPos + m_curPos, File::START); - - if (bytes + m_curPos > m_size) - bytes = m_size - m_curPos; - - Int bytesRead = m_file->read(buffer, bytes); - - m_curPos += bytesRead; - - return bytesRead; -} - -//================================================================= -// StreamingArchiveFile::write -//================================================================= - -Int StreamingArchiveFile::write( const void *buffer, Int bytes ) -{ - DEBUG_CRASH(("Cannot write to streaming files.")); - return -1; -} - -//================================================================= -// StreamingArchiveFile::seek -//================================================================= - -Int StreamingArchiveFile::seek( Int pos, seekMode mode) -{ - Int newPos; - - switch( mode ) - { - case START: - newPos = pos; - break; - case CURRENT: - newPos = m_curPos + pos; - break; - case END: - DEBUG_ASSERTCRASH(pos <= 0, ("StreamingArchiveFile::seek - position should be <= 0 for a seek starting from the end.")); - newPos = m_size + pos; - break; - default: - // bad seek mode - return -1; - } - - if ( newPos < 0 ) - { - newPos = 0; - } - else if ( newPos > m_size ) - { - newPos = m_size; - } - - m_curPos = newPos; - - return m_curPos; - -} - diff --git a/Generals/Code/GameEngineDevice/CMakeLists.txt b/Generals/Code/GameEngineDevice/CMakeLists.txt index 66a0f4249f..788db71e84 100644 --- a/Generals/Code/GameEngineDevice/CMakeLists.txt +++ b/Generals/Code/GameEngineDevice/CMakeLists.txt @@ -70,12 +70,12 @@ set(GAMEENGINEDEVICE_SRC Include/W3DDevice/GameLogic/W3DGameLogic.h Include/W3DDevice/GameLogic/W3DGhostObject.h Include/W3DDevice/GameLogic/W3DTerrainLogic.h - Include/Win32Device/Common/Win32BIGFile.h - Include/Win32Device/Common/Win32BIGFileSystem.h +# Include/Win32Device/Common/Win32BIGFile.h +# Include/Win32Device/Common/Win32BIGFileSystem.h Include/Win32Device/Common/Win32CDManager.h Include/Win32Device/Common/Win32GameEngine.h - Include/Win32Device/Common/Win32LocalFile.h - Include/Win32Device/Common/Win32LocalFileSystem.h +# Include/Win32Device/Common/Win32LocalFile.h +# Include/Win32Device/Common/Win32LocalFileSystem.h Include/Win32Device/GameClient/Win32DIKeyboard.h Include/Win32Device/GameClient/Win32Mouse.h Source/MilesAudioDevice/MilesAudioManager.cpp @@ -169,12 +169,12 @@ set(GAMEENGINEDEVICE_SRC Source/W3DDevice/GameLogic/W3DGameLogic.cpp Source/W3DDevice/GameLogic/W3DGhostObject.cpp Source/W3DDevice/GameLogic/W3DTerrainLogic.cpp - Source/Win32Device/Common/Win32BIGFile.cpp - Source/Win32Device/Common/Win32BIGFileSystem.cpp +# Source/Win32Device/Common/Win32BIGFile.cpp +# Source/Win32Device/Common/Win32BIGFileSystem.cpp Source/Win32Device/Common/Win32CDManager.cpp Source/Win32Device/Common/Win32GameEngine.cpp - Source/Win32Device/Common/Win32LocalFile.cpp - Source/Win32Device/Common/Win32LocalFileSystem.cpp +# Source/Win32Device/Common/Win32LocalFile.cpp +# Source/Win32Device/Common/Win32LocalFileSystem.cpp Source/Win32Device/Common/Win32OSDisplay.cpp Source/Win32Device/GameClient/Win32DIKeyboard.cpp Source/Win32Device/GameClient/Win32Mouse.cpp @@ -190,13 +190,12 @@ target_include_directories(g_gameenginedevice PUBLIC ) target_link_libraries(g_gameenginedevice PRIVATE + corei_gameenginedevice_private gi_always gi_main ) target_link_libraries(g_gameenginedevice PUBLIC - binkstub - d3d8lib + corei_gameenginedevice_public g_gameengine - milesstub ) diff --git a/Generals/Code/GameEngineDevice/Include/Win32Device/Common/Win32BIGFile.h b/Generals/Code/GameEngineDevice/Include/Win32Device/Common/Win32BIGFile.h deleted file mode 100644 index be09a7cf01..0000000000 --- a/Generals/Code/GameEngineDevice/Include/Win32Device/Common/Win32BIGFile.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////// Win32BIGFile.h //////////////////////////////////// -// Bryan Cleveland, August 2002 -/////////////////////////////////////////////////////////// - -#pragma once - -#ifndef __WIN32BIGFILE_H -#define __WIN32BIGFILE_H - -#include "Common/ArchiveFile.h" -#include "Common/AsciiString.h" -#include "Common/List.h" - -class Win32BIGFile : public ArchiveFile -{ - public: - Win32BIGFile(); - virtual ~Win32BIGFile(); - - virtual Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const; ///< fill in the fileInfo struct with info about the requested file. - virtual File* openFile( const Char *filename, Int access = 0 );///< Open the specified file within the BIG file - virtual void closeAllFiles( void ); ///< Close all file opened in this BIG file - virtual AsciiString getName( void ); ///< Returns the name of the BIG file - virtual AsciiString getPath( void ); ///< Returns full path and name of BIG file - virtual void setSearchPriority( Int new_priority ); ///< Set this BIG file's search priority - virtual void close( void ); ///< Close this BIG file - - protected: - - AsciiString m_name; ///< BIG file name - AsciiString m_path; ///< BIG file path -}; - -#endif // __WIN32BIGFILE_H \ No newline at end of file diff --git a/Generals/Code/GameEngineDevice/Include/Win32Device/Common/Win32BIGFileSystem.h b/Generals/Code/GameEngineDevice/Include/Win32Device/Common/Win32BIGFileSystem.h deleted file mode 100644 index 70f955e188..0000000000 --- a/Generals/Code/GameEngineDevice/Include/Win32Device/Common/Win32BIGFileSystem.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//////// Win32BIGFileSystem.h /////////////////////////// -// Bryan Cleveland, August 2002 -///////////////////////////////////////////////////////////// - -#pragma once - -#ifndef __WIN32BIGFILESYSTEM_H -#define __WIN32BIGFILESYSTEM_H - -#include "Common/ArchiveFileSystem.h" - -class Win32BIGFileSystem : public ArchiveFileSystem -{ -public: - Win32BIGFileSystem(); - virtual ~Win32BIGFileSystem(); - - virtual void init( void ); - virtual void update( void ); - virtual void reset( void ); - virtual void postProcessLoad( void ); - - // ArchiveFile operations - virtual void closeAllArchiveFiles( void ); ///< Close all Archivefiles currently open - - // File operations - virtual ArchiveFile * openArchiveFile(const Char *filename); - virtual void closeArchiveFile(const Char *filename); - virtual void closeAllFiles( void ); ///< Close all files associated with ArchiveFiles - - virtual Bool loadBigFilesFromDirectory(AsciiString dir, AsciiString fileMask, Bool overwrite = FALSE); -protected: - -}; - -#endif // __WIN32BIGFILESYSTEM_H \ No newline at end of file diff --git a/Generals/Code/GameEngineDevice/Include/Win32Device/Common/Win32LocalFile.h b/Generals/Code/GameEngineDevice/Include/Win32Device/Common/Win32LocalFile.h deleted file mode 100644 index 453d0e9cb1..0000000000 --- a/Generals/Code/GameEngineDevice/Include/Win32Device/Common/Win32LocalFile.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -///// Win32LocalFile.h /////////////////////////// -// Bryan Cleveland, August 2002 -////////////////////////////////////////////////// - -#pragma once - -#ifndef __WIN32LOCALFILE_H -#define __WIN32LOCALFILE_H - -#include "Common/LocalFile.h" - -class Win32LocalFile : public LocalFile -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(Win32LocalFile, "Win32LocalFile") -public: - Win32LocalFile(); - //virtual ~Win32LocalFile(); - -protected: -}; - -#endif // __WIN32LOCALFILE_H \ No newline at end of file diff --git a/Generals/Code/GameEngineDevice/Include/Win32Device/Common/Win32LocalFileSystem.h b/Generals/Code/GameEngineDevice/Include/Win32Device/Common/Win32LocalFileSystem.h deleted file mode 100644 index 4d25d27a10..0000000000 --- a/Generals/Code/GameEngineDevice/Include/Win32Device/Common/Win32LocalFileSystem.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -///// Win32LocalFileSystem.h ////////////////////////////////// -// Bryan Cleveland, August 2002 -/////////////////////////////////////////////////////////////// - -#pragma once - -#ifndef __WIN32LOCALFILESYSTEM_H -#define __WIN32LOCALFILESYSTEM_H -#include "Common/LocalFileSystem.h" - -class Win32LocalFileSystem : public LocalFileSystem -{ -public: - Win32LocalFileSystem(); - virtual ~Win32LocalFileSystem(); - - virtual void init(); - virtual void reset(); - virtual void update(); - - virtual File * openFile(const Char *filename, Int access = 0); ///< open the given file. - virtual Bool doesFileExist(const Char *filename) const; ///< does the given file exist? - - virtual void getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const; ///< search the given directory for files matching the searchName (egs. *.ini, *.rep). Possibly search subdirectories. - virtual Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const; - - virtual Bool createDirectory(AsciiString directory); - virtual AsciiString normalizePath(const AsciiString& filePath) const; - -protected: -}; - -#endif // __WIN32LOCALFILESYSTEM_H \ No newline at end of file diff --git a/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFile.cpp b/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFile.cpp deleted file mode 100644 index f260af84c3..0000000000 --- a/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFile.cpp +++ /dev/null @@ -1,165 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -////// Win32BIGFile.cpp ///////////////////////// -// Bryan Cleveland, August 2002 -///////////////////////////////////////////////////// - -#include "Common/LocalFile.h" -#include "Common/LocalFileSystem.h" -#include "Common/RAMFile.h" -#include "Common/StreamingArchiveFile.h" -#include "Common/GameMemory.h" -#include "Common/PerfTimer.h" -#include "Win32Device/Common/Win32BIGFile.h" - -//============================================================================ -// Win32BIGFile::Win32BIGFile -//============================================================================ - -Win32BIGFile::Win32BIGFile() -{ - -} - -//============================================================================ -// Win32BIGFile::~Win32BIGFile -//============================================================================ - -Win32BIGFile::~Win32BIGFile() -{ - -} - -//============================================================================ -// Win32BIGFile::openFile -//============================================================================ - -File* Win32BIGFile::openFile( const Char *filename, Int access ) -{ - const ArchivedFileInfo *fileInfo = getArchivedFileInfo(AsciiString(filename)); - - if (fileInfo == NULL) { - return NULL; - } - - RAMFile *ramFile = NULL; - - if (BitIsSet(access, File::STREAMING)) - ramFile = newInstance( StreamingArchiveFile ); - else - ramFile = newInstance( RAMFile ); - - ramFile->deleteOnClose(); - if (ramFile->openFromArchive(m_file, fileInfo->m_filename, fileInfo->m_offset, fileInfo->m_size) == FALSE) { - ramFile->close(); - ramFile = NULL; - return NULL; - } - - if ((access & File::WRITE) == 0) { - // requesting read only access. Just return the RAM file. - return ramFile; - } - - // whoever is opening this file wants write access, so copy the file to the local disk - // and return that file pointer. - - File *localFile = TheLocalFileSystem->openFile(filename, access); - if (localFile != NULL) { - ramFile->copyDataToFile(localFile); - } - - ramFile->close(); - ramFile = NULL; - - return localFile; -} - -//============================================================================ -// Win32BIGFile::closeAllFiles -//============================================================================ - -void Win32BIGFile::closeAllFiles( void ) -{ - -} - -//============================================================================ -// Win32BIGFile::getName -//============================================================================ - -AsciiString Win32BIGFile::getName( void ) -{ - return m_name; -} - -//============================================================================ -// Win32BIGFile::getPath -//============================================================================ - -AsciiString Win32BIGFile::getPath( void ) -{ - return m_path; -} - -//============================================================================ -// Win32BIGFile::setSearchPriority -//============================================================================ - -void Win32BIGFile::setSearchPriority( Int new_priority ) -{ - -} - -//============================================================================ -// Win32BIGFile::close -//============================================================================ - -void Win32BIGFile::close( void ) -{ - -} - -//============================================================================ -// Win32BIGFile::getFileInfo -//============================================================================ - -Bool Win32BIGFile::getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const -{ - const ArchivedFileInfo *tempFileInfo = getArchivedFileInfo(filename); - - if (tempFileInfo == NULL) { - return FALSE; - } - - TheLocalFileSystem->getFileInfo(AsciiString(m_file->getName()), fileInfo); - - // fill in the size info. Since the size can't be bigger than a JUNK file, the high Int will always be 0. - fileInfo->sizeHigh = 0; - fileInfo->sizeLow = tempFileInfo->m_size; - - return TRUE; -} - diff --git a/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp b/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp deleted file mode 100644 index b477d4822e..0000000000 --- a/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//////// Win32BIGFileSystem.h /////////////////////////// -// Bryan Cleveland, August 2002 -///////////////////////////////////////////////////////////// - -#include "Common/AudioAffect.h" -#include "Common/ArchiveFile.h" -#include "Common/ArchiveFileSystem.h" -#include "Common/file.h" -#include "Common/GameAudio.h" -#include "Common/GameMemory.h" -#include "Common/LocalFileSystem.h" -#include "Win32Device/Common/Win32BIGFile.h" -#include "Win32Device/Common/Win32BIGFileSystem.h" -#include "Utility/endian_compat.h" - - -static const char *BIGFileIdentifier = "BIGF"; - -Win32BIGFileSystem::Win32BIGFileSystem() : ArchiveFileSystem() { -} - -Win32BIGFileSystem::~Win32BIGFileSystem() { -} - -void Win32BIGFileSystem::init() { - DEBUG_ASSERTCRASH(TheLocalFileSystem != NULL, ("TheLocalFileSystem must be initialized before TheArchiveFileSystem.")); - if (TheLocalFileSystem == NULL) { - return; - } - - loadBigFilesFromDirectory("", "*.big"); -} - -void Win32BIGFileSystem::reset() { -} - -void Win32BIGFileSystem::update() { -} - -void Win32BIGFileSystem::postProcessLoad() { -} - -ArchiveFile * Win32BIGFileSystem::openArchiveFile(const Char *filename) { - File *fp = TheLocalFileSystem->openFile(filename, File::READ | File::BINARY); - AsciiString archiveFileName; - archiveFileName = filename; - archiveFileName.toLower(); - Int archiveFileSize = 0; - Int numLittleFiles = 0; - - DEBUG_LOG(("Win32BIGFileSystem::openArchiveFile - opening BIG file %s", filename)); - - if (fp == NULL) { - DEBUG_CRASH(("Could not open archive file %s for parsing", filename)); - return NULL; - } - - AsciiString asciibuf; - char buffer[_MAX_PATH]; - fp->read(buffer, 4); // read the "BIG" at the beginning of the file. - buffer[4] = 0; - if (strcmp(buffer, BIGFileIdentifier) != 0) { - DEBUG_CRASH(("Error reading BIG file identifier in file %s", filename)); - fp->close(); - fp = NULL; - return NULL; - } - - // read in the file size. - fp->read(&archiveFileSize, 4); - - DEBUG_LOG(("Win32BIGFileSystem::openArchiveFile - size of archive file is %d bytes", archiveFileSize)); - -// char t; - - // read in the number of files contained in this BIG file. - // change the order of the bytes cause the file size is in reverse byte order for some reason. - fp->read(&numLittleFiles, 4); - numLittleFiles = betoh(numLittleFiles); - - DEBUG_LOG(("Win32BIGFileSystem::openArchiveFile - %d are contained in archive", numLittleFiles)); -// for (Int i = 0; i < 2; ++i) { -// t = buffer[i]; -// buffer[i] = buffer[(4-i)-1]; -// buffer[(4-i)-1] = t; -// } - - // seek to the beginning of the directory listing. - fp->seek(0x10, File::START); - // read in each directory listing. - ArchivedFileInfo *fileInfo = NEW ArchivedFileInfo; - // TheSuperHackers @fix Mauller 23/04/2025 Create new file handle when necessary to prevent memory leak - ArchiveFile *archiveFile = NEW Win32BIGFile; - - for (Int i = 0; i < numLittleFiles; ++i) { - Int filesize = 0; - Int fileOffset = 0; - fp->read(&fileOffset, 4); - fp->read(&filesize, 4); - - filesize = betoh(filesize); - fileOffset = betoh(fileOffset); - - fileInfo->m_archiveFilename = archiveFileName; - fileInfo->m_offset = fileOffset; - fileInfo->m_size = filesize; - - // read in the path name of the file. - Int pathIndex = -1; - do { - ++pathIndex; - fp->read(buffer + pathIndex, 1); - } while (buffer[pathIndex] != 0); - - Int filenameIndex = pathIndex; - while ((filenameIndex >= 0) && (buffer[filenameIndex] != '\\') && (buffer[filenameIndex] != '/')) { - --filenameIndex; - } - - fileInfo->m_filename = (char *)(buffer + filenameIndex + 1); - fileInfo->m_filename.toLower(); - buffer[filenameIndex + 1] = 0; - - AsciiString path; - path = buffer; - - AsciiString debugpath; - debugpath = path; - debugpath.concat(fileInfo->m_filename); -// DEBUG_LOG(("Win32BIGFileSystem::openArchiveFile - adding file %s to archive file %s, file number %d", debugpath.str(), fileInfo->m_archiveFilename.str(), i)); - - archiveFile->addFile(path, fileInfo); - } - - archiveFile->attachFile(fp); - - delete fileInfo; - fileInfo = NULL; - - // leave fp open as the archive file will be using it. - - return archiveFile; -} - -void Win32BIGFileSystem::closeArchiveFile(const Char *filename) { - // Need to close the specified big file - ArchiveFileMap::iterator it = m_archiveFileMap.find(filename); - if (it == m_archiveFileMap.end()) { - return; - } - - if (stricmp(filename, MUSIC_BIG) == 0) { - // Stop the current audio - TheAudio->stopAudio(AudioAffect_Music); - - // No need to turn off other audio, as the lookups will just fail. - } - DEBUG_ASSERTCRASH(stricmp(filename, MUSIC_BIG) == 0, ("Attempting to close Archive file '%s', need to add code to handle its shutdown correctly.", filename)); - - // may need to do some other processing here first. - - delete (it->second); - m_archiveFileMap.erase(it); -} - -void Win32BIGFileSystem::closeAllArchiveFiles() { -} - -void Win32BIGFileSystem::closeAllFiles() { -} - -Bool Win32BIGFileSystem::loadBigFilesFromDirectory(AsciiString dir, AsciiString fileMask, Bool overwrite) { - - FilenameList filenameList; - TheLocalFileSystem->getFileListInDirectory(dir, AsciiString(""), fileMask, filenameList, TRUE); - - Bool actuallyAdded = FALSE; - FilenameListIter it = filenameList.begin(); - while (it != filenameList.end()) { - ArchiveFile *archiveFile = openArchiveFile((*it).str()); - - if (archiveFile != NULL) { - DEBUG_LOG(("Win32BIGFileSystem::loadBigFilesFromDirectory - loading %s into the directory tree.", (*it).str())); - loadIntoDirectoryTree(archiveFile, *it, overwrite); - m_archiveFileMap[(*it)] = archiveFile; - DEBUG_LOG(("Win32BIGFileSystem::loadBigFilesFromDirectory - %s inserted into the archive file map.", (*it).str())); - actuallyAdded = TRUE; - } - - it++; - } - - return actuallyAdded; -} diff --git a/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFile.cpp b/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFile.cpp deleted file mode 100644 index a7bca23c87..0000000000 --- a/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFile.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//////// Win32LocalFile.cpp /////////////////////////// -// Bryan Cleveland, August 2002 -/////////////////////////////////////////////////////// - -#include "Win32Device/Common/Win32LocalFile.h" - -Win32LocalFile::Win32LocalFile() : LocalFile() { -} - -Win32LocalFile::~Win32LocalFile() { -} diff --git a/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp b/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp deleted file mode 100644 index 761bd5b53d..0000000000 --- a/Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -///////// Win32LocalFileSystem.cpp ///////////////////////// -// Bryan Cleveland, August 2002 -//////////////////////////////////////////////////////////// - -#include -#include "Common/AsciiString.h" -#include "Common/GameMemory.h" -#include "Common/PerfTimer.h" -#include "Win32Device/Common/Win32LocalFileSystem.h" -#include "Win32Device/Common/Win32LocalFile.h" -#include - -Win32LocalFileSystem::Win32LocalFileSystem() : LocalFileSystem() -{ -} - -Win32LocalFileSystem::~Win32LocalFileSystem() { -} - -//DECLARE_PERF_TIMER(Win32LocalFileSystem_openFile) -File * Win32LocalFileSystem::openFile(const Char *filename, Int access /* = 0 */) -{ - //USE_PERF_TIMER(Win32LocalFileSystem_openFile) - - // sanity check - if (strlen(filename) <= 0) { - return NULL; - } - - if (access & File::WRITE) { - // if opening the file for writing, we need to make sure the directory is there - // before we try to create the file. - AsciiString string; - string = filename; - AsciiString token; - AsciiString dirName; - string.nextToken(&token, "\\/"); - dirName = token; - while ((token.find('.') == NULL) || (string.find('.') != NULL)) { - createDirectory(dirName); - string.nextToken(&token, "\\/"); - dirName.concat('\\'); - dirName.concat(token); - } - } - - // TheSuperHackers @fix Mauller 21/04/2025 Create new file handle when necessary to prevent memory leak - Win32LocalFile *file = newInstance( Win32LocalFile ); - - if (file->open(filename, access) == FALSE) { - file->close(); - deleteInstance(file); - file = NULL; - } else { - file->deleteOnClose(); - } - -// this will also need to play nice with the STREAMING type that I added, if we ever enable this - -// srj sez: this speeds up INI loading, but makes BIG files unusable. -// don't enable it without further tweaking. -// -// unless you like running really slowly. -// if (!(access&File::WRITE)) { -// // Return a ramfile. -// RAMFile *ramFile = newInstance( RAMFile ); -// if (ramFile->open(file)) { -// file->close(); // is deleteonclose, so should delete. -// ramFile->deleteOnClose(); -// return ramFile; -// } else { -// ramFile->close(); -// deleteInstance(ramFile); -// } -// } - - return file; -} - -void Win32LocalFileSystem::update() -{ -} - -void Win32LocalFileSystem::init() -{ -} - -void Win32LocalFileSystem::reset() -{ -} - -//DECLARE_PERF_TIMER(Win32LocalFileSystem_doesFileExist) -Bool Win32LocalFileSystem::doesFileExist(const Char *filename) const -{ - //USE_PERF_TIMER(Win32LocalFileSystem_doesFileExist) - if (_access(filename, 0) == 0) { - return TRUE; - } - return FALSE; -} - -void Win32LocalFileSystem::getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList & filenameList, Bool searchSubdirectories) const -{ - HANDLE fileHandle = NULL; - WIN32_FIND_DATA findData; - - char search[_MAX_PATH]; - AsciiString asciisearch; - asciisearch = originalDirectory; - asciisearch.concat(currentDirectory); - asciisearch.concat(searchName); - strcpy(search, asciisearch.str()); - - Bool done = FALSE; - - fileHandle = FindFirstFile(search, &findData); - done = (fileHandle == INVALID_HANDLE_VALUE); - - while (!done) { - if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - (strcmp(findData.cFileName, ".") && strcmp(findData.cFileName, ".."))) { - // if we haven't already, add this filename to the list. - // a stl set should only allow one copy of each filename - AsciiString newFilename; - newFilename = originalDirectory; - newFilename.concat(currentDirectory); - newFilename.concat(findData.cFileName); - if (filenameList.find(newFilename) == filenameList.end()) { - filenameList.insert(newFilename); - } - } - - done = (FindNextFile(fileHandle, &findData) == 0); - } - FindClose(fileHandle); - - if (searchSubdirectories) { - AsciiString subdirsearch; - subdirsearch = originalDirectory; - subdirsearch.concat(currentDirectory); - subdirsearch.concat("*."); - fileHandle = FindFirstFile(subdirsearch.str(), &findData); - done = fileHandle == INVALID_HANDLE_VALUE; - - while (!done) { - if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - (strcmp(findData.cFileName, ".") && strcmp(findData.cFileName, ".."))) { - - AsciiString tempsearchstr; - tempsearchstr.concat(currentDirectory); - tempsearchstr.concat(findData.cFileName); - tempsearchstr.concat('\\'); - - // recursively add files in subdirectories if required. - getFileListInDirectory(tempsearchstr, originalDirectory, searchName, filenameList, searchSubdirectories); - } - - done = (FindNextFile(fileHandle, &findData) == 0); - } - - FindClose(fileHandle); - } - -} - -Bool Win32LocalFileSystem::getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const -{ - WIN32_FIND_DATA findData; - HANDLE findHandle = NULL; - findHandle = FindFirstFile(filename.str(), &findData); - - if (findHandle == INVALID_HANDLE_VALUE) { - return FALSE; - } - - fileInfo->timestampHigh = findData.ftLastWriteTime.dwHighDateTime; - fileInfo->timestampLow = findData.ftLastWriteTime.dwLowDateTime; - fileInfo->sizeHigh = findData.nFileSizeHigh; - fileInfo->sizeLow = findData.nFileSizeLow; - - FindClose(findHandle); - - return TRUE; -} - -Bool Win32LocalFileSystem::createDirectory(AsciiString directory) -{ - if ((directory.getLength() > 0) && (directory.getLength() < _MAX_DIR)) { - return (CreateDirectory(directory.str(), NULL) != 0); - } - return FALSE; -} - -AsciiString Win32LocalFileSystem::normalizePath(const AsciiString& filePath) const -{ - DWORD retval = GetFullPathNameA(filePath.str(), 0, NULL, NULL); - if (retval == 0) - { - DEBUG_LOG(("Unable to determine buffer size for normalized file path. Error=(%u).", GetLastError())); - return AsciiString::TheEmptyString; - } - - AsciiString normalizedFilePath; - retval = GetFullPathNameA(filePath.str(), retval, normalizedFilePath.getBufferForRead(retval - 1), NULL); - if (retval == 0) - { - DEBUG_LOG(("Unable to normalize file path '%s'. Error=(%u).", filePath.str(), GetLastError())); - return AsciiString::TheEmptyString; - } - - return normalizedFilePath; -} \ No newline at end of file diff --git a/GeneralsMD/Code/GameEngine/CMakeLists.txt b/GeneralsMD/Code/GameEngine/CMakeLists.txt index e2bea3ec54..8b60f752f9 100644 --- a/GeneralsMD/Code/GameEngine/CMakeLists.txt +++ b/GeneralsMD/Code/GameEngine/CMakeLists.txt @@ -1,8 +1,8 @@ set(GAMEENGINE_SRC Include/Common/AcademyStats.h Include/Common/ActionManager.h - Include/Common/ArchiveFile.h - Include/Common/ArchiveFileSystem.h +# Include/Common/ArchiveFile.h +# Include/Common/ArchiveFileSystem.h Include/Common/AsciiString.h Include/Common/AudioAffect.h Include/Common/AudioEventInfo.h @@ -37,8 +37,8 @@ set(GAMEENGINE_SRC Include/Common/encrypt.h Include/Common/Energy.h Include/Common/Errors.h - Include/Common/file.h - Include/Common/FileSystem.h +# Include/Common/file.h +# Include/Common/FileSystem.h Include/Common/FunctionLexicon.h Include/Common/GameAudio.h Include/Common/GameCommon.h @@ -63,8 +63,8 @@ set(GAMEENGINE_SRC Include/Common/Language.h Include/Common/LatchRestore.h Include/Common/List.h - Include/Common/LocalFile.h - Include/Common/LocalFileSystem.h +# Include/Common/LocalFile.h +# Include/Common/LocalFileSystem.h Include/Common/MapObject.h Include/Common/MapReaderWriterInfo.h Include/Common/MessageStream.h @@ -91,7 +91,7 @@ set(GAMEENGINE_SRC Include/Common/QuickmatchPreferences.h Include/Common/QuotedPrintable.h Include/Common/Radar.h - Include/Common/RAMFile.h +# Include/Common/RAMFile.h Include/Common/RandomValue.h Include/Common/Recorder.h # Include/Common/ReplaySimulation.h @@ -112,7 +112,7 @@ set(GAMEENGINE_SRC Include/Common/StateMachine.h Include/Common/StatsCollector.h Include/Common/STLTypedefs.h - Include/Common/StreamingArchiveFile.h +# Include/Common/StreamingArchiveFile.h Include/Common/SubsystemInterface.h Include/Common/SystemInfo.h Include/Common/Team.h @@ -629,8 +629,8 @@ set(GAMEENGINE_SRC Source/Common/SkirmishBattleHonors.cpp Source/Common/StateMachine.cpp Source/Common/StatsCollector.cpp - Source/Common/System/ArchiveFile.cpp - Source/Common/System/ArchiveFileSystem.cpp +# Source/Common/System/ArchiveFile.cpp +# Source/Common/System/ArchiveFileSystem.cpp Source/Common/System/AsciiString.cpp Source/Common/System/BuildAssistant.cpp Source/Common/System/CDManager.cpp @@ -640,8 +640,8 @@ set(GAMEENGINE_SRC Source/Common/System/Directory.cpp Source/Common/System/DisabledTypes.cpp Source/Common/System/encrypt.cpp - Source/Common/System/File.cpp - Source/Common/System/FileSystem.cpp +# Source/Common/System/File.cpp +# Source/Common/System/FileSystem.cpp Source/Common/System/FunctionLexicon.cpp Source/Common/System/GameCommon.cpp #Source/Common/System/GameMemory.cpp @@ -649,19 +649,19 @@ set(GAMEENGINE_SRC Source/Common/System/Geometry.cpp Source/Common/System/KindOf.cpp Source/Common/System/List.cpp - Source/Common/System/LocalFile.cpp - Source/Common/System/LocalFileSystem.cpp +# Source/Common/System/LocalFile.cpp +# Source/Common/System/LocalFileSystem.cpp #Source/Common/System/MemoryInit.cpp Source/Common/System/ObjectStatusTypes.cpp Source/Common/System/QuotedPrintable.cpp Source/Common/System/Radar.cpp - Source/Common/System/RAMFile.cpp +# Source/Common/System/RAMFile.cpp Source/Common/System/registry.cpp Source/Common/System/SaveGame/GameState.cpp Source/Common/System/SaveGame/GameStateMap.cpp Source/Common/System/Snapshot.cpp Source/Common/System/StackDump.cpp - Source/Common/System/StreamingArchiveFile.cpp +# Source/Common/System/StreamingArchiveFile.cpp Source/Common/System/SubsystemInterface.cpp Source/Common/System/Trig.cpp Source/Common/System/UnicodeString.cpp diff --git a/GeneralsMD/Code/GameEngineDevice/CMakeLists.txt b/GeneralsMD/Code/GameEngineDevice/CMakeLists.txt index fa9cafe01b..f9cf165368 100644 --- a/GeneralsMD/Code/GameEngineDevice/CMakeLists.txt +++ b/GeneralsMD/Code/GameEngineDevice/CMakeLists.txt @@ -81,12 +81,12 @@ set(GAMEENGINEDEVICE_SRC Include/W3DDevice/GameLogic/W3DGameLogic.h Include/W3DDevice/GameLogic/W3DGhostObject.h Include/W3DDevice/GameLogic/W3DTerrainLogic.h - Include/Win32Device/Common/Win32BIGFile.h - Include/Win32Device/Common/Win32BIGFileSystem.h +# Include/Win32Device/Common/Win32BIGFile.h +# Include/Win32Device/Common/Win32BIGFileSystem.h Include/Win32Device/Common/Win32CDManager.h Include/Win32Device/Common/Win32GameEngine.h - Include/Win32Device/Common/Win32LocalFile.h - Include/Win32Device/Common/Win32LocalFileSystem.h +# Include/Win32Device/Common/Win32LocalFile.h +# Include/Win32Device/Common/Win32LocalFileSystem.h Include/Win32Device/GameClient/Win32DIKeyboard.h Include/Win32Device/GameClient/Win32DIMouse.h Include/Win32Device/GameClient/Win32Mouse.h @@ -182,32 +182,18 @@ set(GAMEENGINEDEVICE_SRC Source/W3DDevice/GameLogic/W3DGameLogic.cpp Source/W3DDevice/GameLogic/W3DGhostObject.cpp Source/W3DDevice/GameLogic/W3DTerrainLogic.cpp - Source/Win32Device/Common/Win32BIGFile.cpp - Source/Win32Device/Common/Win32BIGFileSystem.cpp +# Source/Win32Device/Common/Win32BIGFile.cpp +# Source/Win32Device/Common/Win32BIGFileSystem.cpp Source/Win32Device/Common/Win32CDManager.cpp Source/Win32Device/Common/Win32GameEngine.cpp - Source/Win32Device/Common/Win32LocalFile.cpp - Source/Win32Device/Common/Win32LocalFileSystem.cpp +# Source/Win32Device/Common/Win32LocalFile.cpp +# Source/Win32Device/Common/Win32LocalFileSystem.cpp Source/Win32Device/Common/Win32OSDisplay.cpp Source/Win32Device/GameClient/Win32DIKeyboard.cpp #Source/Win32Device/GameClient/Win32DIMouse.cpp Source/Win32Device/GameClient/Win32Mouse.cpp ) -# Add C++ 17 FileSystem implementation for non-VS6 builds -if(NOT IS_VS6_BUILD) - list(APPEND GAMEENGINEDEVICE_SRC - Include/StdDevice/Common/StdBIGFile.h - Include/StdDevice/Common/StdBIGFileSystem.h - Include/StdDevice/Common/StdLocalFile.h - Include/StdDevice/Common/StdLocalFileSystem.h - Source/StdDevice/Common/StdBIGFile.cpp - Source/StdDevice/Common/StdBIGFileSystem.cpp - Source/StdDevice/Common/StdLocalFile.cpp - Source/StdDevice/Common/StdLocalFileSystem.cpp - ) -endif() - add_library(z_gameenginedevice STATIC) target_sources(z_gameenginedevice PRIVATE ${GAMEENGINEDEVICE_SRC}) @@ -217,14 +203,13 @@ target_include_directories(z_gameenginedevice PUBLIC ) target_link_libraries(z_gameenginedevice PRIVATE + corei_gameenginedevice_private zi_always zi_main ) target_link_libraries(z_gameenginedevice PUBLIC - binkstub - d3d8lib - milesstub + corei_gameenginedevice_public z_gameengine )