diff --git a/.github/workflows/build-toolchain.yml b/.github/workflows/build-toolchain.yml index deee27852da..bc0d11e9dff 100644 --- a/.github/workflows/build-toolchain.yml +++ b/.github/workflows/build-toolchain.yml @@ -28,9 +28,9 @@ on: jobs: build: - name: Preset ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} - runs-on: windows-latest - timeout-minutes: 40 + name: ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} + runs-on: windows-2022 + timeout-minutes: 20 steps: - name: Checkout Code uses: actions/checkout@v4 @@ -66,7 +66,7 @@ jobs: $fileHash = (Get-FileHash -Path VS6_VisualStudio6.7z -Algorithm SHA256).Hash Write-Host "Downloaded file SHA256: $fileHash" Write-Host "Expected file SHA256: $env:EXPECTED_HASH" - if ($hash -ne $env:EXPECTED_HASH) { + if ($fileHash -ne $env:EXPECTED_HASH) { Write-Error "Hash verification failed! File may be corrupted or tampered with." exit 1 } diff --git a/.github/workflows/check-replays.yml b/.github/workflows/check-replays.yml new file mode 100644 index 00000000000..7fceb7dced6 --- /dev/null +++ b/.github/workflows/check-replays.yml @@ -0,0 +1,242 @@ +name: check-replays + +permissions: + contents: read + pull-requests: write + +on: + workflow_call: + inputs: + game: + required: true + type: string + description: "Game to check (only GeneralsMD for now)" + userdata: + required: true + type: string + description: "Path to folder with replays and maps" + preset: + required: true + type: string + description: "CMake preset" + +jobs: + build: + name: ${{ inputs.preset }} + runs-on: windows-latest + timeout-minutes: 15 + env: + GAME_PATH: C:\GameData + GENERALS_PATH: C:\GameData\Generals + GENERALSMD_PATH: C:\GameData\GeneralsMD + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + submodules: true + + - name: Download Game Artifact + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.game }}-${{ inputs.preset }} + path: build + + - name: Cache Game Data + id: cache-gamedata + uses: actions/cache@v4 + with: + path: ${{ env.GAME_PATH }} + key: gamedata-permanent-cache-v4 + + - name: Download Game Data from Cloudflare R2 + if: ${{ steps.cache-gamedata.outputs.cache-hit != 'true' }} + env: + AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} + AWS_ENDPOINT_URL: ${{ secrets.R2_ENDPOINT_URL }} + EXPECTED_HASH_GENERALS: "37A351AA430199D1F05DEB9E404857DCE7B461A6AC272C5D4A0B5652CDB06372" + EXPECTED_HASH_GENERALSMD: "6837FE1E3009A4C239406C39B1598216C0943EE8ED46BB10626767029AC05E21" + shell: pwsh + run: | + # Download trimmed gamedata of both Generals 1.08 and Generals Zero Hour 1.04. + # This data cannot be used for playing because it's + # missing textures, audio and gui files. But it's enough for replay checking. + # It's also encrypted because it's not allowed to distribute these files. + + if (-not $env:AWS_ACCESS_KEY_ID -or -not $env:AWS_SECRET_ACCESS_KEY -or -not $env:AWS_ENDPOINT_URL) { + $ok1 = [bool]$env:AWS_ACCESS_KEY_ID + $ok2 = [bool]$env:AWS_SECRET_ACCESS_KEY + $ok3 = [bool]$env:AWS_ENDPOINT_URL + Write-Host "One or more required secrets are not set or are empty. R2_ACCESS_KEY_ID: $ok1, R2_SECRET_ACCESS_KEY: $ok2, R2_ENDPOINT_URL: $ok3" + exit 1 + } + + # Download Generals Game Files + # The archive contains these files: + # BINKW32.DLL + # English.big + # INI.big + # Maps.big + # mss32.dll + # W3D.big + # Data\Scripts\MultiplayerScripts.scb + # Data\Scripts\SkirmishScripts.scb + + Write-Host "Downloading Game Data for Generals" -ForegroundColor Cyan + aws s3 cp s3://github-ci/generals108_gamedata_trimmed.7z generals108_gamedata_trimmed.7z --endpoint-url $env:AWS_ENDPOINT_URL + + Write-Host "Verifying File Integrity" -ForegroundColor Cyan + $fileHash = (Get-FileHash -Path generals108_gamedata_trimmed.7z -Algorithm SHA256).Hash + Write-Host "Downloaded file SHA256: $fileHash" + Write-Host "Expected file SHA256: $env:EXPECTED_HASH_GENERALS" + if ($fileHash -ne $env:EXPECTED_HASH_GENERALS) { + Write-Error "Hash verification failed! File may be corrupted or tampered with." + exit 1 + } + + Write-Host "Extracting Archive" -ForegroundColor Cyan + $extractPath = $env:GENERALS_PATH + & 7z x generals108_gamedata_trimmed.7z -o"$extractPath" + Remove-Item generals108_gamedata_trimmed.7z -Verbose + + # Download GeneralsMD (ZH) Game Files + # The archive contains these files: + # BINKW32.DLL + # INIZH.big + # MapsZH.big + # mss32.dll + # W3DZH.big + # Data\Scripts\MultiplayerScripts.scb + # Data\Scripts\Scripts.ini + # Data\Scripts\SkirmishScripts.scb + + Write-Host "Downloading Game Data for GeneralsMD" -ForegroundColor Cyan + aws s3 cp s3://github-ci/zerohour104_gamedata_trimmed.7z zerohour104_gamedata_trimmed.7z --endpoint-url $env:AWS_ENDPOINT_URL + + Write-Host "Verifying File Integrity" -ForegroundColor Cyan + $fileHash = (Get-FileHash -Path zerohour104_gamedata_trimmed.7z -Algorithm SHA256).Hash + Write-Host "Downloaded file SHA256: $fileHash" + Write-Host "Expected file SHA256: $env:EXPECTED_HASH_GENERALSMD" + if ($fileHash -ne $env:EXPECTED_HASH_GENERALSMD) { + Write-Error "Hash verification failed! File may be corrupted or tampered with." + exit 1 + } + + Write-Host "Extracting Archive" -ForegroundColor Cyan + $extractPath = $env:GENERALSMD_PATH + & 7z x zerohour104_gamedata_trimmed.7z -o"$extractPath" + Remove-Item zerohour104_gamedata_trimmed.7z -Verbose + + - name: Set Up Game Data + shell: pwsh + run: | + $source = "$env:GAME_PATH\${{ inputs.game }}" + $destination = "build" + Copy-Item -Path $source\* -Destination $destination -Recurse -Force + + - name: Set Generals InstallPath in Registry + shell: pwsh + run: | + # Zero Hour loads some Generals files and needs this registry key to find the + # Generals data files. + + $regPath = "HKCU:\SOFTWARE\Electronic Arts\EA Games\Generals" + $installPath = "$env:GENERALS_PATH\" + + # Ensure the key exists + if (-not (Test-Path $regPath)) { + New-Item -Path $regPath -Force | Out-Null + } + + # Set the InstallPath value + Set-ItemProperty -Path $regPath -Name InstallPath -Value $installPath -Type String + Write-Host "Registry key set: $regPath -> InstallPath = $installPath" + + - name: Move Replays and Maps to User Dir + shell: pwsh + run: | + # These files are expected in the user dir, so we move them here. + + $source = "${{ inputs.userdata }}\Replays" + $destination = "$env:USERPROFILE\Documents\Command and Conquer Generals Zero Hour Data\Replays" + Write-Host "Move replays to $destination" + New-Item -ItemType Directory -Path $destination -Force | Out-Null + Move-Item -Path "$source\*" -Destination $destination -Force + + $source = "${{ inputs.userdata }}\Maps" + $destination = "$env:USERPROFILE\Documents\Command and Conquer Generals Zero Hour Data\Maps" + Write-Host "Move maps to $destination" + New-Item -ItemType Directory -Path $destination -Force | Out-Null + Move-Item -Path "$source\*" -Destination $destination -Force + + - name: Run Replay Compatibility Tests + shell: pwsh + run: | + $exePath = "build/generalszh.exe" + $arguments = "-jobs 4 -headless -replay *.rep" + $timeoutSeconds = 10*60 + $stdoutPath = "stdout.log" + $stderrPath = "stderr.log" + + if (-not (Test-Path $exePath)) { + Write-Host "ERROR: Executable not found at $exePath" + exit 1 + } + + # Note that the game is a gui application. That means we need to redirect console output to a file + # in order to retrieve it. + # Clean previous logs + Remove-Item $stdoutPath, $stderrPath -ErrorAction SilentlyContinue + + # Start the process + Write-Host "Run $exePath $arguments" + $process = Start-Process -FilePath $exePath ` + -ArgumentList $arguments ` + -RedirectStandardOutput $stdoutPath ` + -RedirectStandardError $stderrPath ` + -PassThru + + # Wait with timeout + $exited = $process.WaitForExit($timeoutSeconds * 1000) + + if (-not $exited) { + Write-Host "ERROR: Process still running after $timeoutSeconds seconds. Killing process..." + Stop-Process -Id $process.Id -Force + } + + # Read output + Write-Host "=== STDOUT ===" + Get-Content $stdoutPath + + if ((Test-Path $stderrPath) -and (Get-Item $stderrPath).Length -gt 0) { + Write-Host "`n=== STDERR ===" + Get-Content $stderrPath + } + + if (-not $exited) { + exit 1 + } + + # Check exit code + $exitCode = $process.ExitCode + + # The above doesn't work on all Windows versions. If not, try this: (see https://stackoverflow.com/a/16018287) + #$process.HasExited | Out-Null # Needs to be called for the command below to work correctly + #$exitCode = $process.GetType().GetField('exitCode', 'NonPublic, Instance').GetValue($process) + #Write-Host "exit code $exitCode" + + if ($exitCode -ne 0) { + Write-Host "ERROR: Process failed with exit code $exitCode" + exit $exitCode + } + + Write-Host "Success!" + + - name: Upload Debug Log + if: always() + uses: actions/upload-artifact@v4 + with: + name: Replay-Debug-Log-${{ inputs.preset }} + path: build/DebugLogFile*.txt + retention-days: 30 + if-no-files-found: ignore diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c1d5632409c..d82907e847d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -41,8 +41,7 @@ jobs: generalsmd: - 'GeneralsMD/**' shared: - - '.github/workflows/build-toolchain.yml' - - '.github/workflows/ci.yml' + - '.github/workflows/**' - 'CMakeLists.txt' - 'CMakePresets.json' - 'cmake/**' @@ -100,13 +99,15 @@ jobs: # extras: ${{ matrix.extras }} # secrets: inherit - build-generalsmd: - name: Build GeneralsMD${{ matrix.preset && '' }} - needs: detect-changes - if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generalsmd == 'true' || needs.detect-changes.outputs.shared == 'true' }} - strategy: - matrix: - include: + # Note build-generalsmd is split into two jobs for vc6 and win32 because replaycheck-generalsmd + # only requires the vc6 build and compiling vc6 is much faster than win32 + #build-generalsmd-vc6: + #name: Build GeneralsMD${{ matrix.preset && '' }} + #needs: detect-changes + #if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generalsmd == 'true' || needs.detect-changes.outputs.shared == 'true' }} + #strategy: + #matrix: + #include: # - preset: "vc6" # tools: true # extras: true @@ -116,6 +117,25 @@ jobs: # - preset: "vc6-debug" # tools: true # extras: true + #- preset: "vc6-releaselog" + #tools: true + #extras: true + #fail-fast: false + #uses: ./.github/workflows/build-toolchain.yml + #with: + #game: "GeneralsMD" + #preset: ${{ matrix.preset }} + #tools: ${{ matrix.tools }} + #extras: ${{ matrix.extras }} + #secrets: inherit + + build-generalsmd-win32: + name: Build GeneralsMD${{ matrix.preset && '' }} + needs: detect-changes + if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generalsmd == 'true' || needs.detect-changes.outputs.shared == 'true' }} + strategy: + matrix: + include: - preset: "win32" tools: false extras: true @@ -143,3 +163,20 @@ jobs: tools: ${{ matrix.tools }} extras: ${{ matrix.extras }} secrets: inherit + + #replaycheck-generalsmd: + #name: Replay Check GeneralsMD${{ matrix.preset && '' }} + #needs: build-generalsmd-vc6 + #if: ${{ github.event_name == 'workflow_dispatch' || needs.detect-changes.outputs.generalsmd == 'true' || needs.detect-changes.outputs.shared == 'true' }} + #strategy: + #matrix: + #include: + #- preset: "vc6+t+e" + #- preset: "vc6-releaselog+t+e" # optimized build with logging and crashing enabled should be compatible, so we test that here. + #fail-fast: false + #uses: ./.github/workflows/check-replays.yml + #with: + #game: "GeneralsMD" + #userdata: "GeneralsReplays/GeneralsZH/1.04" + #preset: ${{ matrix.preset }} + #secrets: inherit diff --git a/.gitignore b/.gitignore index e5e550b48da..9ae9ce42880 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ !.gitignore !.gitattributes !.github +!.gitmodules *.user *.ncb diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000000..09d4419ccc5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "GeneralsReplays"] + path = GeneralsReplays + url = https://github.com/TheSuperHackers/GeneralsReplays diff --git a/CMakePresets.json b/CMakePresets.json index 51610bf95ca..6dd63816a84 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -44,6 +44,15 @@ "RTS_BUILD_OPTION_DEBUG": "ON" } }, + { + "name": "vc6-releaselog", + "displayName": "Windows 32bit VC6 Release Logging", + "inherits": "vc6", + "cacheVariables": { + "RTS_DEBUG_LOGGING": "ON", + "RTS_DEBUG_CRASHING": "ON" + } + }, { "name": "default", "displayName": "Default Config (don't use directly!)", @@ -163,6 +172,12 @@ "displayName": "Build Windows 32bit VC6 Debug", "description": "Build Windows 32bit VC6 Debug" }, + { + "name": "vc6-releaselog", + "configurePreset": "vc6-releaselog", + "displayName": "Build Windows 32bit VC6 Release Logging", + "description": "Build Windows 32bit VC6 Release Logging" + }, { "name": "win32", "configurePreset": "win32", @@ -253,6 +268,19 @@ } ] }, + { + "name": "vc6-releaselog", + "steps": [ + { + "type": "configure", + "name": "vc6-releaselog" + }, + { + "type": "build", + "name": "vc6-releaselog" + } + ] + }, { "name": "win32", "steps": [ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3bb276f37e2..84d5b7d70e4 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -60,7 +60,7 @@ The `TheSuperHackers` word and `@keyword` are mandatory. `author` and date can b |------------------|-------------------------------------------------------------| | @bugfix | Fixes a bug | | @fix | Fixes something, but is not a user facing bug | -| @compile | Addresses a compile warning or error | +| @build | Addresses a compile warning or error | | @feature | Adds something new | | @performance | Improves performance | | @refactor | Moves or rewrites code, but does not change the behaviour | @@ -83,11 +83,30 @@ Optionally, the pull request number can be appended to the comment. This can onl ### Pull request documentation -The title of a new Pull Request, and/or commit(s) within, begin with a **[GEN]** and/or **[ZH]** tag, depending on the game(s) it targets. If a change does not target a game, then a tag is not necessary. Furthermore, the title consists of a concise and descriptive sentence about the change and/or commit, beginning with an uppercase letter and ending without a dot. The title ideally begins with a word that describes the action that the change takes, for example `Fix *this*`, `Change *that*`, `Add *those*`, `Refactor *thing*`. +The title of a new Pull Request, and/or commit(s) within, begins with a [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) tag. The tag is followed by a concise and descriptive sentence about the change and/or commit, beginning with an upper case letter and ending without a dot. The sentence ideally begins with a word that describes the action that the change takes, for example `fix *this*`, `change *that*`, `add *those*`, `refactor *thing*`. + +Allowed (extended) commit title types are: +``` +bugfix: +build: +chore: +ci: +docs: +fix: +feat: +perf: +refactor: +style: +test: +tweak: +unify: +``` + +For the optional scope behind the type pick a suitable word that describes the overall area that the change touches. Good: ``` -[GEN][ZH] Fix uninitialized memory access in Get_OS_Info +bugfix(system): fix uninitialized memory access in Get_OS_Info ``` Bad: @@ -95,15 +114,6 @@ Bad: Minimal changes for successful build. ``` -Currently established commit title tags are - -* [GEN] -* [ZH] -* [CORE] -* [CMAKE] -* [GITHUB] -* [LINUX] - If the Pull Request is meant to be merged with rebase, then a note for **Merge with Rebase** should be added to the top of the text body, to help identify the correct merge action when it is ready for merge. All commits of the Pull Request need to be properly named and need the number of the Pull Request added as a suffix in parentheses. Example: **(#333)**. All commits need to be able to compile on their own without dependencies in newer commits of the same Pull Request. Prefer to create changes for **Squash and Merge**, as this will simplify things. The text body begins with links to related issue report(s) and/or Pull Request(s) if applicable. diff --git a/Core/GameEngine/CMakeLists.txt b/Core/GameEngine/CMakeLists.txt index 8a7110946d6..0c91e47cc5d 100644 --- a/Core/GameEngine/CMakeLists.txt +++ b/Core/GameEngine/CMakeLists.txt @@ -21,13 +21,13 @@ set(GAMEENGINE_SRC # Include/Common/CDManager.h # Include/Common/ClientUpdateModule.h # Include/Common/CommandLine.h -# Include/Common/crc.h -# Include/Common/CRCDebug.h + Include/Common/crc.h + Include/Common/CRCDebug.h # Include/Common/CriticalSection.h # Include/Common/CustomMatchPreferences.h # Include/Common/DamageFX.h # Include/Common/DataChunk.h -# Include/Common/Debug.h + Include/Common/Debug.h # Include/Common/Dict.h # Include/Common/Directory.h # Include/Common/DisabledTypes.h @@ -92,7 +92,7 @@ set(GAMEENGINE_SRC # Include/Common/QuotedPrintable.h # Include/Common/Radar.h Include/Common/RAMFile.h -# Include/Common/RandomValue.h + Include/Common/RandomValue.h # Include/Common/Recorder.h # Include/Common/Registry.h Include/Common/ReplaySimulation.h @@ -143,7 +143,7 @@ set(GAMEENGINE_SRC # Include/GameClient/CDCheck.h # Include/GameClient/ChallengeGenerals.h # Include/GameClient/ClientInstance.h -# Include/GameClient/ClientRandomValue.h + Include/GameClient/ClientRandomValue.h # Include/GameClient/Color.h # Include/GameClient/CommandXlat.h # Include/GameClient/ControlBar.h @@ -224,11 +224,11 @@ set(GAMEENGINE_SRC # Include/GameClient/Statistics.h # Include/GameClient/TerrainRoads.h # Include/GameClient/TerrainVisual.h -# Include/GameClient/VideoPlayer.h + Include/GameClient/VideoPlayer.h # Include/GameClient/View.h # Include/GameClient/Water.h # Include/GameClient/WindowLayout.h -# Include/GameClient/WindowVideoManager.h + Include/GameClient/WindowVideoManager.h # Include/GameClient/WindowXlat.h # Include/GameClient/WinInstanceData.h # Include/GameLogic/AI.h @@ -252,7 +252,7 @@ set(GAMEENGINE_SRC # Include/GameLogic/GhostObject.h # Include/GameLogic/Locomotor.h # Include/GameLogic/LocomotorSet.h -# Include/GameLogic/LogicRandomValue.h + Include/GameLogic/LogicRandomValue.h # Include/GameLogic/Module/ActiveBody.h # Include/GameLogic/Module/ActiveShroudUpgrade.h # Include/GameLogic/Module/AIUpdate.h @@ -564,8 +564,8 @@ set(GAMEENGINE_SRC # Source/Common/Bezier/BezierSegment.cpp # Source/Common/BitFlags.cpp # Source/Common/CommandLine.cpp -# Source/Common/crc.cpp -# Source/Common/CRCDebug.cpp + Source/Common/crc.cpp + Source/Common/CRCDebug.cpp # Source/Common/DamageFX.cpp # Source/Common/Dict.cpp # Source/Common/DiscreteCircle.cpp @@ -597,7 +597,7 @@ set(GAMEENGINE_SRC # Source/Common/INI/INITerrainBridge.cpp # Source/Common/INI/INITerrainRoad.cpp # Source/Common/INI/INIUpgrade.cpp -# Source/Common/INI/INIVideo.cpp + Source/Common/INI/INIVideo.cpp # Source/Common/INI/INIWater.cpp # Source/Common/INI/INIWeapon.cpp # Source/Common/INI/INIWebpageURL.cpp @@ -608,7 +608,7 @@ set(GAMEENGINE_SRC # Source/Common/NameKeyGenerator.cpp # Source/Common/PartitionSolver.cpp # Source/Common/PerfTimer.cpp -# Source/Common/RandomValue.cpp + Source/Common/RandomValue.cpp # Source/Common/Recorder.cpp Source/Common/ReplaySimulation.cpp # Source/Common/RTS/AcademyStats.cpp @@ -637,7 +637,7 @@ set(GAMEENGINE_SRC # Source/Common/System/CDManager.cpp # Source/Common/System/CriticalSection.cpp # Source/Common/System/DataChunk.cpp -# Source/Common/System/Debug.cpp + Source/Common/System/Debug.cpp # Source/Common/System/Directory.cpp # Source/Common/System/DisabledTypes.cpp # Source/Common/System/encrypt.cpp @@ -791,7 +791,7 @@ set(GAMEENGINE_SRC # Source/GameClient/GUI/Shell/Shell.cpp # Source/GameClient/GUI/Shell/ShellMenuScheme.cpp # Source/GameClient/GUI/WindowLayout.cpp -# Source/GameClient/GUI/WindowVideoManager.cpp + Source/GameClient/GUI/WindowVideoManager.cpp # Source/GameClient/GUI/WinInstanceData.cpp # Source/GameClient/InGameUI.cpp # Source/GameClient/Input/Keyboard.cpp @@ -823,8 +823,8 @@ set(GAMEENGINE_SRC # Source/GameClient/System/Smudge.cpp # Source/GameClient/Terrain/TerrainRoads.cpp # Source/GameClient/Terrain/TerrainVisual.cpp -# Source/GameClient/VideoPlayer.cpp -# Source/GameClient/VideoStream.cpp + Source/GameClient/VideoPlayer.cpp + Source/GameClient/VideoStream.cpp # Source/GameClient/View.cpp # Source/GameClient/Water.cpp # Source/GameLogic/AI/AI.cpp diff --git a/Core/GameEngine/Include/Common/ArchiveFile.h b/Core/GameEngine/Include/Common/ArchiveFile.h index 741cf2c1d02..b62b61297d8 100644 --- a/Core/GameEngine/Include/Common/ArchiveFile.h +++ b/Core/GameEngine/Include/Common/ArchiveFile.h @@ -40,7 +40,7 @@ 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 + * 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. @@ -74,4 +74,4 @@ class ArchiveFile DetailedArchivedDirectoryInfo m_rootDirectory; }; -#endif // __ARCHIVEFILE_H \ No newline at end of file +#endif // __ARCHIVEFILE_H diff --git a/Core/GameEngine/Include/Common/ArchiveFileSystem.h b/Core/GameEngine/Include/Common/ArchiveFileSystem.h index 5d36cdfeb31..b781a90e0af 100644 --- a/Core/GameEngine/Include/Common/ArchiveFileSystem.h +++ b/Core/GameEngine/Include/Common/ArchiveFileSystem.h @@ -23,12 +23,12 @@ //////////////////////////////////////////////////////////////////////////////// //---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// +// +// Westwood Studios Pacific. +// +// Confidential Information +// Copyright (C) 2001 - All Rights Reserved +// //---------------------------------------------------------------------------- // // Project: Generals @@ -49,7 +49,7 @@ #define MUSIC_BIG "Music.big" //---------------------------------------------------------------------------- -// Includes +// Includes //---------------------------------------------------------------------------- #include "Common/SubsystemInterface.h" @@ -90,7 +90,7 @@ 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 +class ArchivedDirectoryInfo { public: AsciiString m_directoryName; @@ -106,7 +106,7 @@ class ArchivedDirectoryInfo }; -class DetailedArchivedDirectoryInfo +class DetailedArchivedDirectoryInfo { public: AsciiString m_directoryName; @@ -121,7 +121,7 @@ class DetailedArchivedDirectoryInfo } }; -class ArchivedFileInfo +class ArchivedFileInfo { public: AsciiString m_filename; @@ -167,7 +167,7 @@ class ArchiveFileSystem : public SubsystemInterface 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 @@ -185,7 +185,7 @@ class ArchiveFileSystem : public SubsystemInterface extern ArchiveFileSystem *TheArchiveFileSystem; //---------------------------------------------------------------------------- -// Inlining +// Inlining //---------------------------------------------------------------------------- #endif // __ARCHIVEFILESYSTEM_H_ diff --git a/Core/GameEngine/Include/Common/AsciiString.h b/Core/GameEngine/Include/Common/AsciiString.h index 213f0481824..54773bdf6d6 100644 --- a/Core/GameEngine/Include/Common/AsciiString.h +++ b/Core/GameEngine/Include/Common/AsciiString.h @@ -22,14 +22,14 @@ // // //////////////////////////////////////////////////////////////////////////////// -// FILE: AsciiString.h +// FILE: AsciiString.h //----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// +// +// Westwood Studios Pacific. +// +// Confidential Information +// Copyright (C) 2001 - All Rights Reserved +// //----------------------------------------------------------------------------- // // Project: RTS3 @@ -72,7 +72,7 @@ class UnicodeString; type, rather analogous to 'int' -- when passed by value, a new string is created, and modifying the new string doesn't modify the original. This is done fairly efficiently, so that no new memory allocation is done - unless the string is actually modified. + unless the string is actually modified. Naturally, AsciiString handles all memory issues, so there's no need to do anything to free memory... just allow the AsciiString's @@ -84,7 +84,7 @@ class UnicodeString; class AsciiString { private: - + // Note, this is a Plain Old Data Structure... don't // add a ctor/dtor, 'cuz they won't ever be called. struct AsciiStringData @@ -114,8 +114,8 @@ class AsciiString public: - enum - { + enum + { MAX_FORMAT_BUF_LEN = 2048, ///< max total len of string created by format/format_va MAX_LEN = 32767 ///< max total len of any AsciiString, in chars }; @@ -142,7 +142,7 @@ class AsciiString /** Constructor -- from a literal string. Constructs an AsciiString with the given string. Note that a copy of the string is made; - the input ptr is not saved. + the input ptr is not saved. Note that this is no longer explicit, as the conversion is almost always wanted, anyhow. */ @@ -154,9 +154,14 @@ class AsciiString ~AsciiString(); /** - Return the length, in characters (not bytes!), of the string. + Return the length, in characters, of the string up to the first zero or null terminator. */ int getLength() const; + + /** + Return the number of bytes used by the string up to the first zero or null terminator. + */ + int getByteCount() const; /** Return true iff the length of the string is zero. Equivalent to (getLength() == 0) but slightly more efficient. @@ -173,8 +178,8 @@ class AsciiString */ char getCharAt(int index) const; /** - Return a pointer to the (null-terminated) string. Note that this is - a const pointer: do NOT change this! It is imperative that it be + Return a pointer to the (null-terminated) string. Note that this is + a const pointer: do NOT change this! It is imperative that it be impossible (or at least, really difficuly) for someone to change our private data, since it might be shared amongst other AsciiStrings. */ @@ -183,7 +188,7 @@ class AsciiString /** Makes sure there is room for a string of len+1 characters, and returns a pointer to the string buffer. This ensures that the - string buffer is NOT shared. This is intended for the file reader, + string buffer is NOT shared. This is intended for the file reader, that is reading new strings in from a file. jba. */ char* getBufferForRead(Int len); @@ -245,7 +250,7 @@ class AsciiString /** Remove the final character in the string. If the string is empty, - do nothing. (This is a rather dorky method, but used a lot in + do nothing. (This is a rather dorky method, but used a lot in text editing, thus its presence here.) */ void removeLastChar(); @@ -391,6 +396,13 @@ inline int AsciiString::getLength() const return m_data ? strlen(peek()) : 0; } +// ----------------------------------------------------- +inline int AsciiString::getByteCount() const +{ + validate(); + return m_data ? getLength() : 0; +} + // ----------------------------------------------------- inline Bool AsciiString::isEmpty() const { diff --git a/Core/GameEngine/Include/Common/AudioAffect.h b/Core/GameEngine/Include/Common/AudioAffect.h index 492d5d877f7..867ce255f04 100644 --- a/Core/GameEngine/Include/Common/AudioAffect.h +++ b/Core/GameEngine/Include/Common/AudioAffect.h @@ -32,7 +32,7 @@ #include -// if it is set by the options panel, use the system setting parameter. Otherwise, this will be +// if it is set by the options panel, use the system setting parameter. Otherwise, this will be // appended to whatever the current system volume is. enum AudioAffect CPP_11(: Int) { diff --git a/Core/GameEngine/Include/Common/AudioEventInfo.h b/Core/GameEngine/Include/Common/AudioEventInfo.h index 144cddefdac..112db478265 100644 --- a/Core/GameEngine/Include/Common/AudioEventInfo.h +++ b/Core/GameEngine/Include/Common/AudioEventInfo.h @@ -69,7 +69,7 @@ enum SoundType CPP_11(: Int) ST_PLAYER = 0x0020, ST_ALLIES = 0x0040, ST_ENEMIES = 0x0080, - ST_EVERYONE = 0x0100, + ST_EVERYONE = 0x0100, }; extern const char *theAudioControlNames[]; @@ -97,11 +97,11 @@ struct AudioEventInfo : public MemoryPoolObject Real m_minVolume; // Clamped minimum value, useful when muting sound effects Real m_pitchShiftMin; // minimum pitch shift value Real m_pitchShiftMax; // maximum pitch shift value - Int m_delayMin; // minimum delay before we'll fire up another one of these - Int m_delayMax; // maximum delay before we'll fire up another one of these + Int m_delayMin; // minimum delay before we'll fire up another one of these + Int m_delayMax; // maximum delay before we'll fire up another one of these Int m_limit; // Limit to the number of these sounds that can be fired up simultaneously Int m_loopCount; // number of times to loop this sound - + AudioPriority m_priority; // Priority of this sound UnsignedInt m_type; // Type of sound UnsignedInt m_control; // control of sound @@ -119,8 +119,8 @@ struct AudioEventInfo : public MemoryPoolObject Real m_maxDistance; // greater than this distance and the sound behaves as though it is muted AudioType m_soundType; // This should be either Music, Streaming or SoundEffect - - + + // DynamicAudioEventInfo interfacing functions virtual Bool isLevelSpecific() const { return false; } ///< If true, this sound is only defined on the current level and can be deleted when that level ends virtual DynamicAudioEventInfo * getDynamicAudioEventInfo() { return NULL; } ///< If this object is REALLY a DynamicAudioEventInfo, return a pointer to the derived class @@ -129,7 +129,7 @@ struct AudioEventInfo : public MemoryPoolObject /// Is this a permenant sound? That is, if I start this sound up, will it ever end /// "on its own" or only if I explicitly kill it? Bool isPermanentSound() const { return BitIsSet( m_control, AC_LOOP ) && (m_loopCount == 0 ); } - + static const FieldParse m_audioEventInfo[]; ///< the parse table for INI definition const FieldParse *getFieldParse( void ) const { return m_audioEventInfo; } }; diff --git a/Core/GameEngine/Include/Common/AudioEventRTS.h b/Core/GameEngine/Include/Common/AudioEventRTS.h index b420f7de86b..bf52de40b36 100644 --- a/Core/GameEngine/Include/Common/AudioEventRTS.h +++ b/Core/GameEngine/Include/Common/AudioEventRTS.h @@ -61,7 +61,7 @@ enum AudioPriority CPP_11(: Int); // You might want this to be memory pooled (I personally do), but it can't // because we allocate them on the stack frequently. class AudioEventRTS -{ +{ public: AudioEventRTS( ); AudioEventRTS( const AsciiString& eventName ); @@ -78,7 +78,7 @@ class AudioEventRTS const AsciiString& getEventName( void ) const { return m_eventName; } // generateFilename is separate from generatePlayInfo because generatePlayInfo should only be called once - // per triggered event. generateFilename will be called once per loop, or once to get each filename if 'all' is + // per triggered event. generateFilename will be called once per loop, or once to get each filename if 'all' is // specified. void generateFilename( void ); AsciiString getFilename( void ); @@ -97,13 +97,13 @@ class AudioEventRTS PortionToPlay getNextPlayPortion( void ) const; void advanceNextPlayPortion( void ); void setNextPlayPortion( PortionToPlay ptp ); - + void decreaseLoopCount( void ); Bool hasMoreLoops( void ) const; - + void setAudioEventInfo( const AudioEventInfo *eventInfo ) const; const AudioEventInfo *getAudioEventInfo( void ) const; - + void setPlayingHandle( AudioHandle handle ); // for ID of this audio piece. AudioHandle getPlayingHandle( void ); // for ID of this audio piece @@ -115,7 +115,7 @@ class AudioEventRTS Bool isDead() const { return m_ownerType == OT_Dead; } OwnerType getOwnerType() const { return m_ownerType; } - + void setDrawableID( DrawableID drawID ); DrawableID getDrawableID( void ); @@ -147,11 +147,11 @@ class AudioEventRTS void setPlayingAudioIndex( Int pai ) { m_playingAudioIndex = pai; }; Bool getUninterruptable( ) const { return m_uninterruptable; } - void setUninterruptable( Bool uninterruptable ) { m_uninterruptable = uninterruptable; } + void setUninterruptable( Bool uninterruptable ) { m_uninterruptable = uninterruptable; } - // This will retrieve the appropriate position based on type. - const Coord3D *getCurrentPosition( void ); + // This will retrieve the appropriate position based on type. + const Coord3D *getCurrentPosition( void ); // This will return the directory leading up to the appropriate type, including the trailing '\\' // If localized is true, we'll append a language specifc directory to the end of the path. @@ -164,7 +164,7 @@ class AudioEventRTS AsciiString m_filenameToLoad; mutable const AudioEventInfo *m_eventInfo; // Mutable so that it can be modified even on const objects AudioHandle m_playingHandle; - + AudioHandle m_killThisHandle; ///< Sometimes sounds will canabilize other sounds in order to take their handle away. ///< This is one of those instances. @@ -173,7 +173,7 @@ class AudioEventRTS AsciiString m_decayName; ///< This is the filename that should be used during the decay. AudioPriority m_priority; ///< This should be the priority as given by the event info, or the overrided priority. - Real m_volume; ///< This is the override for the volume. It will either be the normal + Real m_volume; ///< This is the override for the volume. It will either be the normal TimeOfDay m_timeOfDay; ///< This should be the current Time Of Day. Coord3D m_positionOfAudio; ///< Position of the sound if no further positional updates are necessary @@ -195,15 +195,15 @@ class AudioEventRTS Int m_loopCount; ///< The current loop count value. Only valid if this is a looping type event or the override has been set. Int m_playingAudioIndex; ///< The sound index we are currently playing. In the case of non-random, we increment this to move to the next sound Int m_allCount; ///< If this sound is an ALL type, then this is how many sounds we have played so far. - + Int m_playerIndex; ///< The index of the player who owns this sound. Used for sounds that should have an owner, but don't have an object, etc. PortionToPlay m_portionToPlayNext; ///< Which portion (attack, sound, decay) should be played next? }; class DynamicAudioEventRTS : public MemoryPoolObject -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(DynamicAudioEventRTS, "DynamicAudioEventRTS" ) +{ + MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(DynamicAudioEventRTS, "DynamicAudioEventRTS" ) public: DynamicAudioEventRTS() { } diff --git a/Core/GameEngine/Include/Common/AudioRequest.h b/Core/GameEngine/Include/Common/AudioRequest.h index 6dd96c9d782..e8a8681644b 100644 --- a/Core/GameEngine/Include/Common/AudioRequest.h +++ b/Core/GameEngine/Include/Common/AudioRequest.h @@ -49,7 +49,7 @@ struct AudioRequest : public MemoryPoolObject public: RequestType m_request; - union + union { AudioEventRTS *m_pendingEvent; AudioHandle m_handleToInteractOn; diff --git a/Core/GameEngine/Include/Common/AudioSettings.h b/Core/GameEngine/Include/Common/AudioSettings.h index 1514a108798..f71e9bfaa66 100644 --- a/Core/GameEngine/Include/Common/AudioSettings.h +++ b/Core/GameEngine/Include/Common/AudioSettings.h @@ -68,7 +68,7 @@ struct AudioSettings UnsignedInt m_maxCacheSize; Real m_minVolume; // At volumes less than this, the sample will be culled. - + AsciiString m_preferred3DProvider[MAX_HW_PROVIDERS + 1]; //Defaults actually don't ever get changed! @@ -98,7 +98,7 @@ struct AudioSettings //Handles changing sound volume whenever the camera is close to the microphone. Real m_zoomMinDistance; //If we're closer than the minimum distance, then apply the full bonus no matter how close. Real m_zoomMaxDistance; //The maximum distance from microphone we need to be before benefiting from any bonus. - + //NOTE: The higher this value is, the lower normal sounds will be! If you specify a sound volume value of 25%, then sounds will play //between 75% and 100%, not 100% to 125%! Real m_zoomSoundVolumePercentageAmount; //The amount of sound volume dedicated to zooming. diff --git a/GeneralsMD/Code/GameEngine/Include/Common/CRCDebug.h b/Core/GameEngine/Include/Common/CRCDebug.h similarity index 99% rename from GeneralsMD/Code/GameEngine/Include/Common/CRCDebug.h rename to Core/GameEngine/Include/Common/CRCDebug.h index a234243ba17..77d806042e7 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/CRCDebug.h +++ b/Core/GameEngine/Include/Common/CRCDebug.h @@ -91,7 +91,7 @@ extern Int lastCRCDebugFrame; extern Int lastCRCDebugIndex; - + extern Bool g_verifyClientCRC; extern Bool g_clientDeepCRC; @@ -130,4 +130,4 @@ extern Int NET_CRC_INTERVAL; extern Int REPLAY_CRC_INTERVAL; extern Bool TheDebugIgnoreSyncErrors; -#endif // __CRCDEBUG_H__ \ No newline at end of file +#endif // __CRCDEBUG_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Debug.h b/Core/GameEngine/Include/Common/Debug.h similarity index 92% rename from GeneralsMD/Code/GameEngine/Include/Common/Debug.h rename to Core/GameEngine/Include/Common/Debug.h index 36d78ffc2e2..67048157c5d 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/Debug.h +++ b/Core/GameEngine/Include/Common/Debug.h @@ -22,14 +22,14 @@ // // //////////////////////////////////////////////////////////////////////////////// -// FILE: Debug.h +// FILE: Debug.h //----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// +// +// Westwood Studios Pacific. +// +// Confidential Information +// Copyright (C) 2001 - All Rights Reserved +// //----------------------------------------------------------------------------- // // Project: RTS3 @@ -61,7 +61,7 @@ class AsciiString; #endif // These are stolen from the WW3D Debug file. REALLY useful. :-) -#define STRING_IT(a) #a +#define STRING_IT(a) #a #define TOKEN_IT(a) STRING_IT(,##a) #define MESSAGE(a) message (__FILE__ "(" TOKEN_IT(__LINE__) ") : " a) @@ -84,7 +84,7 @@ class AsciiString; #if defined(ALLOW_DEBUG_UTILS) && !defined(DEBUG_STACKTRACE) && !defined(DISABLE_DEBUG_STACKTRACE) #define DEBUG_STACKTRACE 1 #ifndef DEBUG_LOGGING - #define DEBUG_LOGGING 1 // TheSuperHackers @compile Stack trace requires logging. + #define DEBUG_LOGGING 1 // TheSuperHackers @build Stack trace requires logging. #endif #endif #if defined(ALLOW_DEBUG_UTILS) && !defined(DEBUG_PROFILE) && !defined(DISABLE_DEBUG_PROFILE) @@ -117,9 +117,9 @@ class AsciiString; #ifdef ALLOW_DEBUG_UTILS - enum + enum { - DEBUG_FLAG_LOG_TO_FILE = 0x01, + DEBUG_FLAG_LOG_TO_FILE = 0x01, DEBUG_FLAG_LOG_TO_CONSOLE = 0x02, DEBUG_FLAG_PREPEND_TIME = 0x04, DEBUG_FLAGS_DEFAULT = (DEBUG_FLAG_LOG_TO_FILE | DEBUG_FLAG_LOG_TO_CONSOLE), @@ -181,7 +181,7 @@ class AsciiString; /* Yeah, it's a sleazy global, since we can't reasonably add - any args to DebugCrash due to the varargs nature of it. + any args to DebugCrash due to the varargs nature of it. We'll just let it slide in this case... */ DEBUG_EXTERN_C char* TheCurrentIgnoreCrashPtr; @@ -253,7 +253,7 @@ class SimpleProfiler prof_##uniqueid.stopAndLog(msg, howoftentolog, howoftentoreset); #else - + #define BEGIN_PROFILE(uniqueid) #define END_PROFILE(uniqueid, msg, howoftentolog, howoftentoreset) diff --git a/Core/GameEngine/Include/Common/FileSystem.h b/Core/GameEngine/Include/Common/FileSystem.h index 621c38a069f..5c8b3a57f8d 100644 --- a/Core/GameEngine/Include/Common/FileSystem.h +++ b/Core/GameEngine/Include/Common/FileSystem.h @@ -23,12 +23,12 @@ //////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------= -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// +// +// Westwood Studios Pacific. +// +// Confidential Information +// Copyright(C) 2001 - All Rights Reserved +// //---------------------------------------------------------------------------- // // Project: GameEngine @@ -37,7 +37,7 @@ // // File name: FileSystem.h // -// Created: +// Created: // //---------------------------------------------------------------------------- @@ -47,7 +47,7 @@ #define __FILESYSTEM_H //---------------------------------------------------------------------------- -// Includes +// Includes //---------------------------------------------------------------------------- #include "Common/file.h" @@ -110,8 +110,8 @@ struct FileInfo { //=============================== /** * FileSystem is an interface class for creating specific FileSystem objects. - * - * A FileSystem object's implemenation decides what derivative of File object needs to be + * + * A FileSystem object's implemenation decides what derivative of File object needs to be * created when FileSystem::Open() gets called. */ //=============================== @@ -121,7 +121,7 @@ class FileSystem : public SubsystemInterface { FileSystem(const FileSystem&); FileSystem& operator=(const FileSystem&); - + public: FileSystem(); virtual ~FileSystem(); @@ -154,7 +154,7 @@ extern FileSystem* TheFileSystem; //---------------------------------------------------------------------------- -// Inlining +// Inlining //---------------------------------------------------------------------------- diff --git a/Core/GameEngine/Include/Common/GameAudio.h b/Core/GameEngine/Include/Common/GameAudio.h index 3b0bc483b06..1aa90880b27 100644 --- a/Core/GameEngine/Include/Common/GameAudio.h +++ b/Core/GameEngine/Include/Common/GameAudio.h @@ -23,12 +23,12 @@ //////////////////////////////////////////////////////////////////////////////// //---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// +// +// Westwood Studios Pacific. +// +// Confidential Information +// Copyright (C) 2001 - All Rights Reserved +// //---------------------------------------------------------------------------- // // Project: RTS 3 @@ -44,7 +44,7 @@ #ifndef __COMMON_GAMEAUDIO_H_ #define __COMMON_GAMEAUDIO_H_ -// Includes +// Includes #include "Lib/BaseType.h" #include "Common/STLTypedefs.h" #include "Common/SubsystemInterface.h" @@ -89,45 +89,45 @@ enum 2) Its guts are copied from elsewhere (for instance, a ThingTemplate, or MiscAudio). 3) It is added to TheAudio via TheAudio->addAudioEvent(...) - The return value from addAudioEvent can be saved in case the sound needs to loop and/or be - terminated at some point. - - To reomve a playing sound, the call TheAudio->removeAudioEvent(...) is used. This will search - the list of currently playing audio for the specified handle, and kill the attached sound. It + The return value from addAudioEvent can be saved in case the sound needs to loop and/or be + terminated at some point. + + To reomve a playing sound, the call TheAudio->removeAudioEvent(...) is used. This will search + the list of currently playing audio for the specified handle, and kill the attached sound. It will play a decay sound, if one is specified. - The important functions of TheAudio, are therefore + The important functions of TheAudio, are therefore GameAudio::addAudioEvent() GameAudio::removeAudioEvent() All other functions exist to support these two basic requirements. In addition to the fundamental requirements, the audio has a fairly complicated sound management - scheme. If all units were always allowed to sound off, the sound engine would be overwhelmed and - would sound awful. Therefore, when an audio event is requested, it goes through a series of - checks to determine if it is near enough to the camera, if it should be heard based on shroud, + scheme. If all units were always allowed to sound off, the sound engine would be overwhelmed and + would sound awful. Therefore, when an audio event is requested, it goes through a series of + checks to determine if it is near enough to the camera, if it should be heard based on shroud, local player affiliation, etc. (The entire list of checks is contained in shouldPlayLocally()). - + In addition, the world and unit audio are never allowed to exceed their footprint, as specified in the audio settings INI file. In order to accomodate this, the audio uses an audio cache. The audio cache will attempt to load a sample, assuming there is enough room. If there is not enough - room, then it goes through and finds any samples that are lower priority, and kills them until - enough room is present for the sample. If it cannot free enough room, nothing happens to the + room, then it goes through and finds any samples that are lower priority, and kills them until + enough room is present for the sample. If it cannot free enough room, nothing happens to the cache. - Although the audio is multithreaded, most of the operations are performed such that the worst + Although the audio is multithreaded, most of the operations are performed such that the worst case scenario for thread miscommunication is that the main thread misses an event for one frame. - One specific case of this is the status of playing audio. Because audio is playing - asynchronously, it can complete at any time. When most audio completes, it sets a flag on the + One specific case of this is the status of playing audio. Because audio is playing + asynchronously, it can complete at any time. When most audio completes, it sets a flag on the event noting that it has completed. During the next update (from the main thread), anything with - that flag set is moved to the stopped list, and then is cleaned up. (Basically, the audio uses - a push model for its multithreadedness, which doesn't require thread safety such as mutexes or + that flag set is moved to the stopped list, and then is cleaned up. (Basically, the audio uses + a push model for its multithreadedness, which doesn't require thread safety such as mutexes or semaphores). - All in all, the best way to learn how the audio works is to track the lifetime of an event - through the system. This will give a better understanding than all the documentation I could + All in all, the best way to learn how the audio works is to track the lifetime of an event + through the system. This will give a better understanding than all the documentation I could write. - -jkmcd + -jkmcd -December 2002 */ @@ -168,7 +168,7 @@ class AudioManager : public SubsystemInterface void addTrackName( const AsciiString& trackName ); AsciiString nextTrackName(const AsciiString& currentTrack ); AsciiString prevTrackName(const AsciiString& currentTrack ); - + // changing music tracks virtual void nextMusicTrack( void ) = 0; virtual void prevMusicTrack( void ) = 0; @@ -184,7 +184,7 @@ class AudioManager : public SubsystemInterface // Really meant for internal purposes only, but cannot be protected. virtual void getInfoForAudioEvent( const AudioEventRTS *eventToFindAndFill ) const; // Note: m_eventInfo is Mutable, and so this function will overwrite it if found - ///< Return whether the current audio is playing or not. + ///< Return whether the current audio is playing or not. ///< NOTE NOTE NOTE !!DO NOT USE THIS IN FOR GAMELOGIC PURPOSES!! NOTE NOTE NOTE virtual Bool isCurrentlyPlaying( AudioHandle handle ); @@ -223,7 +223,7 @@ class AudioManager : public SubsystemInterface virtual void adjustVolumeOfPlayingAudio(AsciiString eventName, Real newVolume) = 0; virtual void removePlayingAudio( AsciiString eventName ) = 0; virtual void removeAllDisabledAudio() = 0; - + // Is the audio device on? We can skip a lot of audio processing if not. virtual Bool isOn( AudioAffect whichToGet ) const; virtual void setOn( Bool turnOn, AudioAffect whichToAffect ); @@ -231,8 +231,8 @@ class AudioManager : public SubsystemInterface // Set and get the device Volume virtual void setVolume( Real volume, AudioAffect whichToAffect ); virtual Real getVolume( AudioAffect whichToGet ); - - // To get a more 3-D feeling from the universe, we adjust the volume of the 3-D samples based + + // To get a more 3-D feeling from the universe, we adjust the volume of the 3-D samples based // on zoom. virtual void set3DVolumeAdjustment( Real volumeAdjustment ); @@ -253,7 +253,7 @@ class AudioManager : public SubsystemInterface virtual void releaseAudioRequest( AudioRequest *requestToRelease ); virtual void appendAudioRequest( AudioRequest *m_request ); virtual void processRequestList( void ); - + virtual AudioEventInfo *newAudioEventInfo( AsciiString newEventName ); virtual void addAudioEventInfo( AudioEventInfo * newEventInfo ); virtual AudioEventInfo *findAudioEventInfo( AsciiString eventName ) const; @@ -288,12 +288,12 @@ class AudioManager : public SubsystemInterface // For the file cache to know when to remove files. virtual void closeAnySamplesUsingFile( const void *fileToClose ) = 0; - + virtual Bool isMusicAlreadyLoaded(void) const; virtual Bool isMusicPlayingFromCD(void) const { return m_musicPlayingFromCD; } Bool getDisallowSpeech( void ) const { return m_disallowSpeech; } - void setDisallowSpeech( Bool disallowSpeech ) { m_disallowSpeech = disallowSpeech; } + void setDisallowSpeech( Bool disallowSpeech ) { m_disallowSpeech = disallowSpeech; } // For Worldbuilder, to build lists from which to select virtual void findAllAudioEventsOfType( AudioType audioType, std::vector& allEvents ); @@ -304,7 +304,7 @@ class AudioManager : public SubsystemInterface // Is the currently selected provider actually HW accelerated? virtual Bool isCurrentProviderHardwareAccelerated(); - + // Is the currently selected speaker type Surround sound? virtual Bool isCurrentSpeakerTypeSurroundSound(); @@ -315,13 +315,13 @@ class AudioManager : public SubsystemInterface virtual void setDeviceListenerPosition( void ) = 0; // For tracking purposes - virtual AudioHandle allocateNewHandle( void ); + virtual AudioHandle allocateNewHandle( void ); // Remove all AudioEventInfo's with the m_isLevelSpecific flag virtual void removeLevelSpecificAudioEventInfos( void ); - + void removeAllAudioRequests( void ); - + protected: AudioSettings *m_audioSettings; MiscAudio *m_miscAudio; @@ -345,16 +345,16 @@ class AudioManager : public SubsystemInterface Real m_scriptSoundVolume; Real m_scriptSound3DVolume; Real m_scriptSpeechVolume; - + Real m_systemMusicVolume; Real m_systemSoundVolume; Real m_systemSound3DVolume; Real m_systemSpeechVolume; Real m_zoomVolume; - + AudioEventRTS *m_silentAudioEvent; - + enum { VOLUME_TYPE_MUSIC, diff --git a/Core/GameEngine/Include/Common/GameMusic.h b/Core/GameEngine/Include/Common/GameMusic.h index f94e94be5ad..1e3218d5baa 100644 --- a/Core/GameEngine/Include/Common/GameMusic.h +++ b/Core/GameEngine/Include/Common/GameMusic.h @@ -23,12 +23,12 @@ //////////////////////////////////////////////////////////////////////////////// //---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// +// +// Westwood Studios Pacific. +// +// Confidential Information +// Copyright (C) 2001 - All Rights Reserved +// //---------------------------------------------------------------------------- // // Project: RTS 3 @@ -46,7 +46,7 @@ //---------------------------------------------------------------------------- -// Includes +// Includes //---------------------------------------------------------------------------- #include "Common/GameAudio.h" @@ -70,8 +70,8 @@ struct FieldParse; //=============================== //------------------------------------------------------------------------------------------------- -/** The MusicTrack struct holds all information about a music track. - * Place data in TrackInfo that is useful to the game code in determining +/** The MusicTrack struct holds all information about a music track. + * Place data in TrackInfo that is useful to the game code in determining * what tracks to play. */ //------------------------------------------------------------------------------------------------- @@ -86,7 +86,7 @@ class MusicTrack : public MemoryPoolObject // virtual destructor prototype defined by memory pool object const FieldParse *getFieldParse( void ) const { return m_musicTrackFieldParseTable; } - + Int index; ///< Track index AsciiString name; ///< Logical name of track AsciiString filename; ///< Filename with extension of music track diff --git a/Core/GameEngine/Include/Common/GameSounds.h b/Core/GameEngine/Include/Common/GameSounds.h index 9f07c25404b..3c7867eaf47 100644 --- a/Core/GameEngine/Include/Common/GameSounds.h +++ b/Core/GameEngine/Include/Common/GameSounds.h @@ -23,12 +23,12 @@ //////////////////////////////////////////////////////////////////////////////// //---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// +// +// Westwood Studios Pacific. +// +// Confidential Information +// Copyright (C) 2001 - All Rights Reserved +// //---------------------------------------------------------------------------- // // Project: RTS 3 @@ -63,12 +63,12 @@ class SoundManager : public SubsystemInterface virtual void loseFocus( void ); ///< Called when application loses focus virtual void regainFocus( void ); ///< Called when application regains focus - + virtual void setListenerPosition( const Coord3D *position ); ///< Set the listener position for map3DSound() calculations virtual void setViewRadius( Real viewRadius );///< Sets the radius of the view from the center of the screen in world coordinate units virtual void setCameraAudibleDistance( Real audibleDistance ); virtual Real getCameraAudibleDistance( void ); - + virtual void addAudioEvent(AudioEventRTS *&eventToAdd); // pre-copied virtual void notifyOf2DSampleStart( void ); @@ -89,7 +89,7 @@ class SoundManager : public SubsystemInterface protected: virtual Bool violatesVoice( AudioEventRTS *event ); virtual Bool isInterrupting( AudioEventRTS *event ); - + protected: UnsignedInt m_num2DSamples; diff --git a/Core/GameEngine/Include/Common/LocalFile.h b/Core/GameEngine/Include/Common/LocalFile.h index 807ae612150..92a574ebb3b 100644 --- a/Core/GameEngine/Include/Common/LocalFile.h +++ b/Core/GameEngine/Include/Common/LocalFile.h @@ -23,12 +23,12 @@ //////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------= -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// +// +// Westwood Studios Pacific. +// +// Confidential Information +// Copyright(C) 2001 - All Rights Reserved +// //---------------------------------------------------------------------------- // // Project: WSYS Library @@ -49,13 +49,13 @@ //---------------------------------------------------------------------------- -// Includes +// Includes //---------------------------------------------------------------------------- #include "Common/file.h" #if USE_BUFFERED_IO -#include +#include "Utility/stdio_adapter.h" #endif //---------------------------------------------------------------------------- @@ -77,7 +77,7 @@ class LocalFile : public File { - MEMORY_POOL_GLUE_ABC(LocalFile) + MEMORY_POOL_GLUE_ABC(LocalFile) private: #if USE_BUFFERED_IO @@ -89,17 +89,23 @@ class LocalFile : public File #else int m_handle; ///< Local C file handle #endif - + public: - - LocalFile(); + + LocalFile(); //virtual ~LocalFile(); virtual Bool open( const Char *filename, Int access = NONE, size_t bufferSize = BUFFERSIZE ); ///< 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 readChar(); ///< Read a character from the file + virtual Int readWideChar(); ///< Read a wide character from the file virtual Int write( const void *buffer, Int bytes ); ///< Write the specified number of bytes from the buffer: See File::write + virtual Int writeFormat( const Char* format, ... ); ///< Write an unterminated formatted string to the file + virtual Int writeFormat( const WideChar* format, ... ); ///< Write an unterminated formatted string to the file + virtual Int writeChar( const Char* character ); ///< Write a character to the file + virtual Int writeChar( const WideChar* character ); ///< Write a wide character to the file virtual Int seek( Int new_pos, seekMode mode = CURRENT ); ///< Set file position: See File::seek virtual Bool flush(); ///< flush data to disk virtual void nextLine(Char *buf = NULL, Int bufSize = 0); ///< moves file position to after the next new-line @@ -107,7 +113,7 @@ class LocalFile : public File 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 + 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 @@ -126,7 +132,7 @@ class LocalFile : public File //---------------------------------------------------------------------------- -// Inlining +// Inlining //---------------------------------------------------------------------------- diff --git a/Core/GameEngine/Include/Common/LocalFileSystem.h b/Core/GameEngine/Include/Common/LocalFileSystem.h index 1a912b7f1bf..ec9fbdc097f 100644 --- a/Core/GameEngine/Include/Common/LocalFileSystem.h +++ b/Core/GameEngine/Include/Common/LocalFileSystem.h @@ -55,4 +55,4 @@ class LocalFileSystem : public SubsystemInterface extern LocalFileSystem *TheLocalFileSystem; -#endif // __LOCALFILESYSTEM_H \ No newline at end of file +#endif // __LOCALFILESYSTEM_H diff --git a/Core/GameEngine/Include/Common/MiscAudio.h b/Core/GameEngine/Include/Common/MiscAudio.h index 5c032f736db..4fbcd0b412e 100644 --- a/Core/GameEngine/Include/Common/MiscAudio.h +++ b/Core/GameEngine/Include/Common/MiscAudio.h @@ -35,7 +35,7 @@ struct MiscAudio { static const FieldParse m_fieldParseTable[]; - + AudioEventRTS m_radarUnitUnderAttackSound; ///< radar sounds to play when unit under attack AudioEventRTS m_radarHarvesterUnderAttackSound; ///< radar sounds to play when harvester under attack AudioEventRTS m_radarStructureUnderAttackSound; ///< radar sounds to play when structure under attack @@ -69,8 +69,8 @@ struct MiscAudio AudioEventRTS m_crateMoney; ///< When money crate is picked up. AudioEventRTS m_unitPromoted; ///< Unit is promoted. AudioEventRTS m_repairSparks; ///< Battle drone repairs unit. - AudioEventRTS m_sabotageShutDownBuilding; ///< When Saboteur hits a building - AudioEventRTS m_sabotageResetTimerBuilding; ///< When Saboteur hits a building + AudioEventRTS m_sabotageShutDownBuilding; ///< When Saboteur hits a building + AudioEventRTS m_sabotageResetTimerBuilding; ///< When Saboteur hits a building AudioEventRTS m_aircraftWheelScreech; ///< When a jet lands on a runway. }; diff --git a/Core/GameEngine/Include/Common/RAMFile.h b/Core/GameEngine/Include/Common/RAMFile.h index 3ad6ca65e3a..cdad7f30f1c 100644 --- a/Core/GameEngine/Include/Common/RAMFile.h +++ b/Core/GameEngine/Include/Common/RAMFile.h @@ -23,12 +23,12 @@ //////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------= -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// +// +// Westwood Studios Pacific. +// +// Confidential Information +// Copyright(C) 2001 - All Rights Reserved +// //---------------------------------------------------------------------------- // // Project: WSYS Library @@ -49,7 +49,7 @@ //---------------------------------------------------------------------------- -// Includes +// Includes //---------------------------------------------------------------------------- #include "Common/file.h" @@ -74,15 +74,15 @@ class RAMFile : public File { - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(RAMFile, "RAMFile") + 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(); @@ -90,7 +90,13 @@ class RAMFile : public File virtual Bool open( const Char *filename, Int access = NONE, size_t bufferSize = 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 readChar(); ///< Read a character from the file + virtual Int readWideChar(); ///< Read a wide character from the file virtual Int write( const void *buffer, Int bytes ); ///< Write the specified number of bytes from the buffer: See File::write + virtual Int writeFormat( const Char* format, ... ); ///< Write the formatted string to the file + virtual Int writeFormat( const WideChar* format, ... ); ///< Write the formatted string to the file + virtual Int writeChar( const Char* character ); ///< Write a character to the file + virtual Int writeChar( const WideChar* character ); ///< Write a wide character to the file virtual Int seek( Int new_pos, seekMode mode = CURRENT ); ///< Set file position: See File::seek virtual Bool flush(); ///< flush data to disk virtual void nextLine(Char *buf = NULL, Int bufSize = 0); ///< moves current position to after the next new-line @@ -104,7 +110,7 @@ class RAMFile : public File 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 + 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 @@ -122,7 +128,7 @@ class RAMFile : public File //---------------------------------------------------------------------------- -// Inlining +// Inlining //---------------------------------------------------------------------------- diff --git a/GeneralsMD/Code/GameEngine/Include/Common/RandomValue.h b/Core/GameEngine/Include/Common/RandomValue.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/RandomValue.h rename to Core/GameEngine/Include/Common/RandomValue.h diff --git a/Core/GameEngine/Include/Common/STLUtils.h b/Core/GameEngine/Include/Common/STLUtils.h index eef1a3a1195..4fae9beef39 100644 --- a/Core/GameEngine/Include/Common/STLUtils.h +++ b/Core/GameEngine/Include/Common/STLUtils.h @@ -20,6 +20,7 @@ #include #include +#include namespace stl { @@ -58,4 +59,18 @@ bool find_and_erase_unordered(Container& container, const typename Container::va return false; } +// Push back value into vector-like container if it does not yet contain that value. +template +bool push_back_unique(Container& container, const typename Container::value_type& value) +{ + typename Container::iterator it = std::find(container.begin(), container.end(), value); + if (it == container.end()) + { + container.push_back(value); + return true; + } + + return false; +} + } // namespace stl diff --git a/Core/GameEngine/Include/Common/StreamingArchiveFile.h b/Core/GameEngine/Include/Common/StreamingArchiveFile.h index 38e683a2299..b1f97c0080f 100644 --- a/Core/GameEngine/Include/Common/StreamingArchiveFile.h +++ b/Core/GameEngine/Include/Common/StreamingArchiveFile.h @@ -23,12 +23,12 @@ //////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------= -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// +// +// Westwood Studios Pacific. +// +// Confidential Information +// Copyright(C) 2001 - All Rights Reserved +// //---------------------------------------------------------------------------- // // Project: RTS 3 @@ -49,7 +49,7 @@ //---------------------------------------------------------------------------- -// Includes +// Includes //---------------------------------------------------------------------------- #include "Common/RAMFile.h" @@ -74,16 +74,16 @@ class StreamingArchiveFile : public RAMFile { - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(StreamingArchiveFile, "StreamingArchiveFile") + 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(); @@ -93,12 +93,12 @@ class StreamingArchiveFile : public RAMFile 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 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. @@ -112,7 +112,7 @@ class StreamingArchiveFile : public RAMFile //---------------------------------------------------------------------------- -// Inlining +// Inlining //---------------------------------------------------------------------------- diff --git a/Core/GameEngine/Include/Common/UnicodeString.h b/Core/GameEngine/Include/Common/UnicodeString.h index b138ab6929f..70940aca9cf 100644 --- a/Core/GameEngine/Include/Common/UnicodeString.h +++ b/Core/GameEngine/Include/Common/UnicodeString.h @@ -22,14 +22,14 @@ // // //////////////////////////////////////////////////////////////////////////////// -// FILE: UnicodeString.h +// FILE: UnicodeString.h //----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// +// +// Westwood Studios Pacific. +// +// Confidential Information +// Copyright (C) 2001 - All Rights Reserved +// //----------------------------------------------------------------------------- // // Project: RTS3 @@ -72,7 +72,7 @@ class AsciiString; type, rather analogous to 'int' -- when passed by value, a new string is created, and modifying the new string doesn't modify the original. This is done fairly efficiently, so that no new memory allocation is done - unless the string is actually modified. + unless the string is actually modified. Naturally, UnicodeString handles all memory issues, so there's no need to do anything to free memory... just allow the UnicodeString's @@ -84,7 +84,7 @@ class AsciiString; class UnicodeString { private: - + // Note, this is a Plain Old Data Structure... don't // add a ctor/dtor, 'cuz they won't ever be called. struct UnicodeStringData @@ -114,8 +114,8 @@ class UnicodeString public: - enum - { + enum + { MAX_FORMAT_BUF_LEN = 2048, ///< max total len of string created by format/format_va MAX_LEN = 32767 ///< max total len of any UnicodeString, in chars }; @@ -154,9 +154,14 @@ class UnicodeString ~UnicodeString(); /** - Return the length, in characters (not bytes!), of the string. + Return the length, in characters, of the string up to the first zero or null terminator. */ int getLength() const; + + /** + Return the number of bytes used by the string up to the first zero or null terminator. + */ + int getByteCount() const; /** Return true iff the length of the string is zero. Equivalent to (getLength() == 0) but slightly more efficient. @@ -173,8 +178,8 @@ class UnicodeString */ WideChar getCharAt(int index) const; /** - Return a pointer to the (null-terminated) string. Note that this is - a const pointer: do NOT change this! It is imperative that it be + Return a pointer to the (null-terminated) string. Note that this is + a const pointer: do NOT change this! It is imperative that it be impossible (or at least, really difficuly) for someone to change our private data, since it might be shared amongst other UnicodeStrings. */ @@ -183,7 +188,7 @@ class UnicodeString /** Makes sure there is room for a string of len+1 characters, and returns a pointer to the string buffer. This ensures that the - string buffer is NOT shared. This is intended for the file reader, + string buffer is NOT shared. This is intended for the file reader, that is reading new strings in from a file. jba. */ WideChar* getBufferForRead(Int len); @@ -240,7 +245,7 @@ class UnicodeString /** Remove the final character in the string. If the string is empty, - do nothing. (This is a rather dorky method, but used a lot in + do nothing. (This is a rather dorky method, but used a lot in text editing, thus its presence here.) */ void removeLastChar(); @@ -341,6 +346,13 @@ inline int UnicodeString::getLength() const return m_data ? wcslen(peek()) : 0; } +// ----------------------------------------------------- +inline int UnicodeString::getByteCount() const +{ + validate(); + return m_data ? getLength() * sizeof(WideChar) : 0; +} + // ----------------------------------------------------- inline Bool UnicodeString::isEmpty() const { diff --git a/Core/GameEngine/Include/Common/WorkerProcess.h b/Core/GameEngine/Include/Common/WorkerProcess.h index 0a0b104f64b..664d4a7f65d 100644 --- a/Core/GameEngine/Include/Common/WorkerProcess.h +++ b/Core/GameEngine/Include/Common/WorkerProcess.h @@ -27,7 +27,7 @@ class WorkerProcess WorkerProcess(); bool startProcess(UnicodeString command); - + void update(); bool isRunning() const; diff --git a/Core/GameEngine/Include/Common/Xfer.h b/Core/GameEngine/Include/Common/Xfer.h index f8f64d95ea8..3f937bf11b0 100644 --- a/Core/GameEngine/Include/Common/Xfer.h +++ b/Core/GameEngine/Include/Common/Xfer.h @@ -76,7 +76,7 @@ enum XferMode CPP_11(: Int) enum XferStatus CPP_11(: Int) { XFER_STATUS_INVALID = 0, - + XFER_OK, ///< all is green and good XFER_EOF, ///< end of file encountered XFER_FILE_NOT_FOUND, ///< requested file does not exist @@ -93,7 +93,7 @@ enum XferStatus CPP_11(: Int) XFER_INVALID_PARAMETERS, ///< invalid parameters XFER_LIST_NOT_EMPTY, ///< trying to xfer into a list that should be empty, but isn't XFER_UNKNOWN_STRING, ///< unrecognized string value - + XFER_ERROR_UNKNOWN, ///< unknown error (isn't that useful!) NUM_XFER_STATUS // please keep this last @@ -189,7 +189,7 @@ class Xfer UnsignedInt m_options; ///< xfer options XferMode m_xferMode; ///< the current xfer mode AsciiString m_identifier; ///< the string identifier - + }; #endif // __XFER_H_ diff --git a/GeneralsMD/Code/GameEngine/Include/Common/crc.h b/Core/GameEngine/Include/Common/crc.h similarity index 96% rename from GeneralsMD/Code/GameEngine/Include/Common/crc.h rename to Core/GameEngine/Include/Common/crc.h index ea100421178..5f8fa51a7fb 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/crc.h +++ b/Core/GameEngine/Include/Common/crc.h @@ -73,17 +73,17 @@ class CRC { if (!buf||len<1) return; - + #if !(defined(_MSC_VER) && _MSC_VER < 1300) // C++ version left in for reference purposes for (UnsignedByte *uintPtr=(UnsignedByte *)buf;len>0;len--,uintPtr++) { int hibit; - if (crc & 0x80000000) + if (crc & 0x80000000) { hibit = 1; - } - else + } + else { hibit = 0; } @@ -116,10 +116,10 @@ class CRC } /// Clears the CRC to 0 - void clear( void ) - { - crc = 0; - } + void clear( void ) + { + crc = 0; + } ///< Get the combined CRC UnsignedInt get( void ) const diff --git a/Core/GameEngine/Include/Common/file.h b/Core/GameEngine/Include/Common/file.h index 4c4da7cea92..536123db4e3 100644 --- a/Core/GameEngine/Include/Common/file.h +++ b/Core/GameEngine/Include/Common/file.h @@ -23,12 +23,12 @@ //////////////////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------= -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright(C) 2001 - All Rights Reserved -// +// +// Westwood Studios Pacific. +// +// Confidential Information +// Copyright(C) 2001 - All Rights Reserved +// //---------------------------------------------------------------------------- // // Project: WSYS Library @@ -49,14 +49,12 @@ //---------------------------------------------------------------------------- -// Includes +// 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 @@ -76,7 +74,7 @@ * * 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. - * + * * TheSuperHackers @feature Adds LINEBUF and FULLBUF modes and buffer size argument for file open. */ //=============================== @@ -88,7 +86,7 @@ class File : public MemoryPoolObject // friend class FileSystem; public: - + enum access { NONE = 0x00000000, ///< Access file. Reading by default @@ -101,12 +99,12 @@ class File : public MemoryPoolObject CREATE = 0x00000008, ///< Create file if it does not exist TRUNCATE = 0x00000010, ///< Delete all data in file when opened - // NOTE: accesses file as text data if neither TEXT and BINARY are set + // NOTE: accesses file as binary data if neither TEXT and BINARY are set TEXT = 0x00000020, ///< Access file as text data BINARY = 0x00000040, ///< Access file as binary data 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. @@ -133,28 +131,52 @@ class File : public MemoryPoolObject 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(); void closeWithoutDelete(); public: - + Bool eof(); virtual Bool open( const Char *filename, Int access = NONE, size_t bufferSize = BUFFERSIZE ); ///< 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 ) = 0 ; /**< Read the specified number of bytes from the file in to the + virtual Int read( void *buffer, Int bytes ) = 0 ; /**< 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 occurred. */ - virtual Int write( const void *buffer, Int bytes ) = 0 ; /**< Write the specified number of bytes from the + virtual Int readChar() = 0 ; /**< Read a character from the file + * Returns the character converted to an integer. + * Returns EOF if an error occurred. + */ + virtual Int readWideChar() = 0 ; /**< Read a wide character from the file + * Returns the wide character converted to an integer. + * Returns wide EOF if an error occurred. + */ + virtual Int write( const void *buffer, Int bytes ) = 0 ; /**< 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 occurred. */ + virtual Int writeFormat( const Char* format, ... ) = 0 ; /**< Write an unterminated formatted string to the file + * Returns the number of bytes written. + * Returns -1 if an error occurred. + */ + virtual Int writeFormat( const WideChar* format, ... ) = 0 ; /**< Write an unterminated formatted wide character string to the file + * Returns the number of bytes written. + * Returns -1 if an error occurred. + */ + virtual Int writeChar( const Char* character ) = 0 ; /**< Write a character to the file + * Returns a copy of the character written. + * Returns EOF if an error occurred. + */ + virtual Int writeChar( const WideChar* character ) = 0 ; /**< Write a wide character to the file + * Returns a copy of the wide character written. + * Returns wide EOF if an error occurred. + */ virtual Int seek( Int bytes, seekMode mode = CURRENT ) = 0; /**< 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 occurred. @@ -184,7 +206,7 @@ class File : public MemoryPoolObject void deleteOnClose ( void ); ///< Causes the File object to delete itself when it closes /** - Allocate a buffer large enough to hold entire file, read + 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 @@ -198,7 +220,7 @@ class File : public MemoryPoolObject //---------------------------------------------------------------------------- -// Inlining +// Inlining //---------------------------------------------------------------------------- inline const char* File::getName( void ) const { return m_nameStr.str(); } diff --git a/Core/GameEngine/Include/Common/simpleplayer.h b/Core/GameEngine/Include/Common/simpleplayer.h index d24cde78741..b7dec2d1d66 100644 --- a/Core/GameEngine/Include/Common/simpleplayer.h +++ b/Core/GameEngine/Include/Common/simpleplayer.h @@ -40,7 +40,7 @@ class CSimplePlayer : public IWMReaderCallback public: CSimplePlayer( HRESULT* phr ); ~CSimplePlayer(); - + virtual HRESULT Play( LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hCompletionEvent, HRESULT *phrCompletion ); // @@ -58,15 +58,15 @@ class CSimplePlayer : public IWMReaderCallback // IWMReaderCallback Implemenation // public: - virtual HRESULT STDMETHODCALLTYPE OnSample( + virtual HRESULT STDMETHODCALLTYPE OnSample( /* [in] */ DWORD dwOutputNum, /* [in] */ QWORD cnsSampleTime, /* [in] */ QWORD cnsSampleDuration, /* [in] */ DWORD dwFlags, /* [in] */ INSSBuffer __RPC_FAR *pSample, /* [in] */ void __RPC_FAR *pvContext); - - virtual HRESULT STDMETHODCALLTYPE OnStatus( + + virtual HRESULT STDMETHODCALLTYPE OnStatus( /* [in] */ WMT_STATUS Status, /* [in] */ HRESULT hr, /* [in] */ WMT_ATTR_DATATYPE dwType, @@ -83,12 +83,12 @@ class CSimplePlayer : public IWMReaderCallback void OnWaveOutMsg( UINT uMsg, DWORD dwParam1, DWORD dwParam2 ); static void CALLBACK WaveProc( - HWAVEOUT hwo, - UINT uMsg, - DWORD dwInstance, - DWORD dwParam1, + HWAVEOUT hwo, + UINT uMsg, + DWORD dwInstance, + DWORD dwParam1, DWORD dwParam2 ); - + HRESULT AddWaveHeader( LPWAVEHDR pwh ); void RemoveWaveHeaders( void ); diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ClientRandomValue.h b/Core/GameEngine/Include/GameClient/ClientRandomValue.h similarity index 98% rename from GeneralsMD/Code/GameEngine/Include/GameClient/ClientRandomValue.h rename to Core/GameEngine/Include/GameClient/ClientRandomValue.h index 5a869e701bf..9a12e3229f4 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/ClientRandomValue.h +++ b/Core/GameEngine/Include/GameClient/ClientRandomValue.h @@ -66,12 +66,12 @@ class GameClientRandomVariable * HIGH_BIAS represents a distribution of random values with * zero probability at low, and maximum probability at high. */ - enum DistributionType - { + enum DistributionType + { CONSTANT, UNIFORM, GAUSSIAN, TRIANGULAR, LOW_BIAS, HIGH_BIAS }; - static const char *DistributionTypeNames[]; + static const char *DistributionTypeNames[]; /// define the range of random values, and the distribution of values void setRange( Real low, Real high, DistributionType type = UNIFORM ); diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/VideoPlayer.h b/Core/GameEngine/Include/GameClient/VideoPlayer.h similarity index 90% rename from GeneralsMD/Code/GameEngine/Include/GameClient/VideoPlayer.h rename to Core/GameEngine/Include/GameClient/VideoPlayer.h index d6ac60588b0..58b35b65db4 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/VideoPlayer.h +++ b/Core/GameEngine/Include/GameClient/VideoPlayer.h @@ -23,12 +23,12 @@ //////////////////////////////////////////////////////////////////////////////// //---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// +// +// Westwood Studios Pacific. +// +// Confidential Information +// Copyright (C) 2001 - All Rights Reserved +// //---------------------------------------------------------------------------- // // Project: Generals @@ -46,7 +46,7 @@ //---------------------------------------------------------------------------- -// Includes +// Includes //---------------------------------------------------------------------------- #include @@ -70,7 +70,7 @@ typedef std::vector