diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..69fe82afaf --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,167 @@ +# TheSuperHackers @build JohnsterID 15/09/2025 Add clang-tidy configuration for code quality analysis +--- +# Clang-tidy configuration for GeneralsGameCode project +# This configuration is tailored for a legacy C++98/C++20 hybrid codebase +# with Windows-specific code and COM interfaces + +# Enable specific checks that are appropriate for this codebase +Checks: > + -*, + bugprone-*, + -bugprone-easily-swappable-parameters, + -bugprone-implicit-widening-of-multiplication-result, + -bugprone-narrowing-conversions, + -bugprone-signed-char-misuse, + cert-*, + -cert-dcl21-cpp, + -cert-dcl50-cpp, + -cert-dcl58-cpp, + -cert-env33-c, + -cert-err58-cpp, + clang-analyzer-*, + -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling, + cppcoreguidelines-*, + -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-avoid-non-const-global-variables, + -cppcoreguidelines-init-variables, + -cppcoreguidelines-macro-usage, + -cppcoreguidelines-no-malloc, + -cppcoreguidelines-owning-memory, + -cppcoreguidelines-pro-bounds-array-to-pointer-decay, + -cppcoreguidelines-pro-bounds-constant-array-index, + -cppcoreguidelines-pro-bounds-pointer-arithmetic, + -cppcoreguidelines-pro-type-cstyle-cast, + -cppcoreguidelines-pro-type-reinterpret-cast, + -cppcoreguidelines-pro-type-union-access, + -cppcoreguidelines-pro-type-vararg, + -cppcoreguidelines-special-member-functions, + google-*, + -google-build-using-namespace, + -google-explicit-constructor, + -google-readability-casting, + -google-readability-todo, + -google-runtime-int, + -google-runtime-references, + hicpp-*, + -hicpp-avoid-c-arrays, + -hicpp-explicit-conversions, + -hicpp-no-array-decay, + -hicpp-signed-bitwise, + -hicpp-special-member-functions, + -hicpp-uppercase-literal-suffix, + -hicpp-use-auto, + -hicpp-vararg, + misc-*, + -misc-const-correctness, + -misc-include-cleaner, + -misc-non-private-member-variables-in-classes, + -misc-use-anonymous-namespace, + modernize-*, + -modernize-avoid-c-arrays, + -modernize-concat-nested-namespaces, + -modernize-loop-convert, + -modernize-pass-by-value, + -modernize-raw-string-literal, + -modernize-return-braced-init-list, + -modernize-use-auto, + -modernize-use-default-member-init, + -modernize-use-nodiscard, + -modernize-use-trailing-return-type, + performance-*, + -performance-avoid-endl, + portability-*, + readability-*, + -readability-avoid-const-params-in-decls, + -readability-braces-around-statements, + -readability-convert-member-functions-to-static, + -readability-function-cognitive-complexity, + -readability-identifier-length, + -readability-implicit-bool-conversion, + -readability-isolate-declaration, + -readability-magic-numbers, + -readability-named-parameter, + -readability-redundant-access-specifiers, + -readability-uppercase-literal-suffix + +# Treat warnings as errors for CI/CD +WarningsAsErrors: false + +# Header filter to include project headers +HeaderFilterRegex: '(Core|Generals|GeneralsMD|Dependencies)/.*\.(h|hpp)$' + +# Check options for specific rules +CheckOptions: + # Naming conventions - adapted for the existing codebase style + - key: readability-identifier-naming.ClassCase + value: CamelCase + - key: readability-identifier-naming.StructCase + value: CamelCase + - key: readability-identifier-naming.FunctionCase + value: CamelCase + - key: readability-identifier-naming.MethodCase + value: CamelCase + - key: readability-identifier-naming.VariableCase + value: lower_case + - key: readability-identifier-naming.ParameterCase + value: lower_case + - key: readability-identifier-naming.MemberCase + value: lower_case + - key: readability-identifier-naming.MemberPrefix + value: m_ + - key: readability-identifier-naming.ConstantCase + value: UPPER_CASE + - key: readability-identifier-naming.EnumConstantCase + value: UPPER_CASE + - key: readability-identifier-naming.MacroDefinitionCase + value: UPPER_CASE + + # Performance settings + - key: performance-for-range-copy.WarnOnAllAutoCopies + value: true + - key: performance-unnecessary-value-param.AllowedTypes + value: 'AsciiString;UnicodeString;Utf8String;Utf16String' + + # Modernize settings - be conservative for legacy code + - key: modernize-use-nullptr.NullMacros + value: 'NULL' + - key: modernize-replace-auto-ptr.IncludeStyle + value: llvm + + # Readability settings + - key: readability-function-size.LineThreshold + value: 150 + - key: readability-function-size.StatementThreshold + value: 100 + - key: readability-function-size.BranchThreshold + value: 25 + - key: readability-function-size.ParameterThreshold + value: 8 + - key: readability-function-size.NestingThreshold + value: 6 + + # Bugprone settings + - key: bugprone-argument-comment.StrictMode + value: false + - key: bugprone-suspicious-string-compare.WarnOnImplicitComparison + value: true + - key: bugprone-suspicious-string-compare.WarnOnLogicalNotComparison + value: true + + # Google style settings + - key: google-readability-braces-around-statements.ShortStatementLines + value: 2 + - key: google-readability-function-size.StatementThreshold + value: 100 + + # CERT settings + - key: cert-dcl16-c.NewSuffixes + value: 'L;LL;LU;LLU' + - key: cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField + value: false + +# Use .clang-format for formatting suggestions +FormatStyle: file + +# Exclude certain directories and files +# Note: This is handled by HeaderFilterRegex above, but can be extended diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 0000000000..de2ca2326e --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,133 @@ +# AI Coding Agent Instructions + +## Project Overview + +This is the **GeneralsGameCode** project - a community-driven effort to fix and improve the classic RTS games *Command & Conquer: Generals* and *Zero Hour*. The codebase has been modernized from Visual Studio 6/C++98 to Visual Studio 2022/C++20 while maintaining retail compatibility. + +## Architecture + +### Dual Game Structure +- **Generals/**: Original C&C Generals (v1.08) codebase +- **GeneralsMD/**: Zero Hour expansion (v1.04) codebase - **primary focus** +- **Core/**: Shared game engine and libraries used by both games + +### Key Components +- **Core/GameEngine/**: Base game engine with GameClient/GameLogic separation +- **Core/Libraries/**: Internal libraries including WWVegas graphics framework +- **Core/GameEngineDevice/**: Platform-specific rendering (DirectX 8) +- **Core/Tools/**: Development tools (W3DView, texture compression, etc.) +- **Dependencies/**: External dependencies (MaxSDK for VC6, utilities) + +## Build System + +### CMake Presets (Critical) +- **vc6**: Visual Studio 6 compatible build (retail compatibility required) +- **win32**: Modern Visual Studio 2022 build +- **vc6-debug/vc6-profile**: Debug/profiling variants +- Use `cmake --preset ` followed by `cmake --build build/` + +### Build Commands +```bash +# Configure with specific preset +cmake --preset vc6 + +# Build (from project root) +cmake --build build/vc6 + +# Build with tools and extras +cmake --build build/vc6 --target _tools _extras +``` + +### Retail Compatibility +- VC6 builds are required for replay compatibility testing +- Debug builds break retail compatibility +- Use RTS_BUILD_OPTION_DEBUG=OFF for compatibility testing + +## Development Workflow + +### Code Change Documentation +**Every user-facing change requires TheSuperHackers comment format:** +```cpp +// TheSuperHackers @keyword author DD/MM/YYYY Description +``` + +Common keywords: `@bugfix`, `@feature`, `@performance`, `@refactor`, `@tweak`, `@build` + +### Pull Request Guidelines +- Title format: `type: Description starting with action verb` +- Types: `bugfix:`, `feat:`, `fix:`, `refactor:`, `perf:`, `build:` +- Zero Hour changes take precedence over Generals +- Changes must be identical between both games when applicable + +### Code Style +- Maintain consistency with surrounding legacy code +- Prefer C++98 style unless modern features add significant value +- No big refactors mixed with logical changes +- Use present tense in documentation ("Fixes" not "Fixed") + +## Testing + +### Replay Compatibility Testing +Located in `GeneralsReplays/` - critical for ensuring retail compatibility: +```bash +generalszh.exe -jobs 4 -headless -replay subfolder/*.rep +``` +- Requires VC6 optimized build with RTS_BUILD_OPTION_DEBUG=OFF +- Copies replays to `%USERPROFILE%/Documents/Command and Conquer Generals Zero Hour Data/Replays` +- CI automatically tests GeneralsMD builds against known replays + +### Build Validation +- CI tests multiple presets: vc6, vc6-profile, vc6-debug, win32 variants +- Path-based change detection triggers relevant builds +- Tools and extras are built with `+t+e` flags + +## Common Patterns + +### Memory Management +- Manual memory management (delete/delete[]) - this is legacy C++98 code +- STLPort for VC6 compatibility (see `cmake/stlport.cmake`) + +### Game Engine Separation +- **GameLogic**: Game state, rules, simulation +- **GameClient**: Rendering, UI, platform-specific code +- Clean separation maintained for potential future networking + +### Module Structure +``` +Core/ +├── GameEngine/Include/Common/ # Shared interfaces +├── GameEngine/Include/GameLogic/ # Game simulation +├── GameEngine/Include/GameClient/ # Rendering/UI +├── Libraries/Include/rts/ # RTS-specific utilities +└── Libraries/Source/WWVegas/ # Graphics framework +``` + +## External Dependencies + +### Required for Building +- **VC6 builds**: Requires MSVC 6.0 toolchain (automated in CI via itsmattkc/MSVC600) +- **Modern builds**: Visual Studio 2022, Ninja generator +- **vcpkg** (optional): zlib, ffmpeg for enhanced builds + +### Platform-Specific +- **Windows**: DirectX 8, Miles Sound System, Bink Video +- **Registry detection**: Automatic game install path detection from EA registry keys + +## Tools and Utilities + +### Development Scripts (`scripts/cpp/`) +- `fixInludesCase.sh`: Fix include case sensitivity +- `refactor_*.py`: Code refactoring utilities +- `remove_trailing_whitespace.py`: Code cleanup + +### Build Tools +- W3DView: 3D model viewer +- TextureCompress: Asset optimization +- MapCacheBuilder: Map preprocessing + +## Key Files to Understand +- `CMakePresets.json`: All build configurations +- `cmake/config-build.cmake`: Build options and feature flags +- `Core/GameEngine/Include/`: Core engine interfaces +- `**/Code/Main/WinMain.cpp`: Application entry points +- `GeneralsReplays/`: Compatibility test data diff --git a/.github/workflows/build-toolchain.yml b/.github/workflows/build-toolchain.yml index e7f185a078..5999ee132b 100644 --- a/.github/workflows/build-toolchain.yml +++ b/.github/workflows/build-toolchain.yml @@ -30,11 +30,24 @@ jobs: build: name: ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} runs-on: windows-2022 - timeout-minutes: 20 + timeout-minutes: 30 + env: + VCPKG_FILE_CACHE: ${{ github.workspace }}\vcpkg-bincache + VCPKG_BINARY_SOURCES: clear;files,${{ github.workspace }}\vcpkg-bincache,readwrite + VCPKG_FEATURE_FLAGS: manifests,versions,binarycaching steps: - name: Checkout Code uses: actions/checkout@v4 + - name: Cache vcpkg binary artifacts + uses: actions/cache@v4 + with: + path: ${{ github.workspace }}\vcpkg-bincache + key: vcpkg-bincache-${{ runner.os }}-${{ hashFiles('vcpkg.json','vcpkg-lock.json') }}-${{ inputs.preset }} + restore-keys: | + vcpkg-bincache-${{ runner.os }}-${{ hashFiles('vcpkg.json','vcpkg-lock.json') }}- + vcpkg-bincache-${{ runner.os }}- + - name: Cache VC6 Installation if: startsWith(inputs.preset, 'vc6') id: cache-vc6 diff --git a/.github/workflows/check-replays.yml b/.github/workflows/check-replays.yml index 7fceb7dced..0f10f67d85 100644 --- a/.github/workflows/check-replays.yml +++ b/.github/workflows/check-replays.yml @@ -1,4 +1,4 @@ -name: check-replays +name: Check Replays permissions: contents: read @@ -23,7 +23,7 @@ on: jobs: build: name: ${{ inputs.preset }} - runs-on: windows-latest + runs-on: windows-2022 timeout-minutes: 15 env: GAME_PATH: C:\GameData diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2d0a8efd65..0420bc2e27 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -80,16 +80,15 @@ jobs: - preset: "win32-debug" tools: true extras: true - # vcpkg builds have been disabled for now due to excessive build times of 30 minutes per preset - # - preset: "win32-vcpkg" - # tools: true - # extras: true - # - preset: "win32-vcpkg-profile" - # tools: true - # extras: true - # - preset: "win32-vcpkg-debug" - # tools: true - # extras: true + - preset: "win32-vcpkg" + tools: true + extras: true + - preset: "win32-vcpkg-profile" + tools: true + extras: true + - preset: "win32-vcpkg-debug" + tools: true + extras: true fail-fast: false uses: ./.github/workflows/build-toolchain.yml with: @@ -145,16 +144,15 @@ jobs: - preset: "win32-debug" tools: true extras: true - # vcpkg builds have been disabled for now due to excessive build times of 30 minutes per preset - # - preset: "win32-vcpkg" - # tools: true - # extras: true - # - preset: "win32-vcpkg-profile" - # tools: true - # extras: true - # - preset: "win32-vcpkg-debug" - # tools: true - # extras: true + - preset: "win32-vcpkg" + tools: true + extras: true + - preset: "win32-vcpkg-profile" + tools: true + extras: true + - preset: "win32-vcpkg-debug" + tools: true + extras: true fail-fast: false uses: ./.github/workflows/build-toolchain.yml with: diff --git a/.github/workflows/weekly-release.yml b/.github/workflows/weekly-release.yml new file mode 100644 index 0000000000..c127d9e5f0 --- /dev/null +++ b/.github/workflows/weekly-release.yml @@ -0,0 +1,210 @@ +name: Weekly Release + +permissions: + contents: write + pull-requests: write + +on: + workflow_dispatch: + inputs: + build_notes: + description: 'Build notes (optional)' + required: false + default: '' + type: string + known_issues: + description: 'Known issues (optional)' + required: false + default: '' + type: string + force_changed: + description: 'Force build' + required: false + default: 'false' + type: choice + options: + - 'false' + - 'true' + pre-release: + description: 'Mark release as pre-release' + required: false + default: 'false' + type: choice + options: + - 'false' + - 'true' + + schedule: + - cron: '0 9 * * 5' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + get-date: + runs-on: ubuntu-latest + outputs: + date: ${{ steps.date.outputs.date }} + steps: + - name: Get current date + id: date + run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT + + detect-scm-changes: + needs: [get-date] + runs-on: ubuntu-latest + outputs: + changed: ${{ steps.check.outputs.changed }} + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + - id: check + run: | + if [ "${{ github.event.inputs.force_changed }}" = "true" ]; then + echo "changed=true" >> $GITHUB_OUTPUT + exit 0 + fi + + echo LAST TAG: + git describe --tags --abbrev=0 2>/dev/null || echo "" + + LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + if [ -z "$LAST_TAG" ]; then + echo "changed=true" >> $GITHUB_OUTPUT + exit 0 + fi + CHANGED=$(git diff --name-only $LAST_TAG..HEAD | grep -v '.github/workflows/' | wc -l) + if [ "$CHANGED" -eq "0" ]; then + echo "changed=false" >> $GITHUB_OUTPUT + else + echo "changed=true" >> $GITHUB_OUTPUT + fi + + build-generals: + needs: [detect-scm-changes, get-date] + if: needs.detect-scm-changes.outputs.changed == 'true' + name: Build Generals${{ matrix.preset && '' }} + strategy: + matrix: + include: + - preset: "vc6-weekly" + tools: true + extras: false + release: true + fail-fast: false + uses: ./.github/workflows/build-toolchain.yml + with: + game: "Generals" + preset: ${{ matrix.preset }} + tools: ${{ matrix.tools }} + extras: ${{ matrix.extras }} + secrets: inherit + + build-generalsmd: + needs: [detect-scm-changes, get-date] + if: needs.detect-scm-changes.outputs.changed == 'true' + name: Build GeneralsMD${{ matrix.preset && '' }} + strategy: + matrix: + include: + - preset: "vc6-weekly" + tools: true + extras: false + release: true + fail-fast: false + uses: ./.github/workflows/build-toolchain.yml + with: + game: "GeneralsMD" + preset: ${{ matrix.preset }} + tools: ${{ matrix.tools }} + extras: ${{ matrix.extras }} + secrets: inherit + + create-release: + name: Create Release + needs: [build-generals, build-generalsmd, get-date] + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Collect commits since last release + id: changelog + run: | + LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") + if [ -z "$LAST_TAG" ]; then + CHANGELOG_COMMITS=$(git log --pretty="format:- %s" --no-merges HEAD | head -n 10 || true) + else + CHANGELOG_COMMITS=$(git log --pretty="format:- %s" --no-merges "$LAST_TAG"..HEAD || true) + fi + if [ -z "$CHANGELOG_COMMITS" ]; then + CHANGELOG_COMMITS="- No relevant changes detected since the last release." + fi + { + echo 'commits<> "$GITHUB_OUTPUT" + + # Generals vc6 + - name: Download Generals VC6 Artifacts + uses: actions/download-artifact@v4 + with: + name: Generals-vc6-weekly+t + path: generals-vc6-artifacts + + - name: Prepare and Zip Generals VC6 + run: | + zip -jr generals-weekly-${{ needs.get-date.outputs.date }}.zip generals-vc6-artifacts/* + + # GeneralsMD vc6 + - name: Download GeneralsMD VC6 Artifacts + uses: actions/download-artifact@v4 + with: + name: GeneralsMD-vc6-weekly+t + path: generalsmd-vc6-artifacts + + - name: Prepare and Zip GeneralsMD VC6 + run: | + zip -jr generalszh-weekly-${{ needs.get-date.outputs.date }}.zip generalsmd-vc6-artifacts/* + + - name: Generate release notes + id: release_body + run: | + BODY="" + if [ "${{ github.event.inputs.build_notes }}" != "" ]; then + BODY="${BODY}### Build notes\n${{ github.event.inputs.build_notes }}\n" + fi + if [ "${{ github.event.inputs.known_issues }}" != "" ]; then + BODY="${BODY}### Known issues\n${{ github.event.inputs.known_issues }}\n" + fi + BODY="${BODY}### Changelog\n${{ steps.changelog.outputs.commits }}" + echo "body<> $GITHUB_OUTPUT + echo -e "$BODY" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: weekly-${{ needs.get-date.outputs.date }} + name: weekly-${{ needs.get-date.outputs.date }} + prerelease: ${{ github.event.inputs.pre-release == 'true' }} + body: ${{ steps.release_body.outputs.body }} + files: | + generals-weekly-${{ needs.get-date.outputs.date }}.zip + generalszh-weekly-${{ needs.get-date.outputs.date }}.zip + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Clean up release folders + if: always() + run: | + rm -rf generals-vc6-artifacts generalsmd-vc6-artifacts + rm -f generals-weekly-${{ needs.get-date.outputs.date }}.zip + rm -f generalszh-weekly-${{ needs.get-date.outputs.date }}.zip diff --git a/CMakeLists.txt b/CMakeLists.txt index d2b41feab5..4160c918c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,6 @@ if((WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") AND ${CMAKE_SIZEOF_VOID_P} EQU include(cmake/miles.cmake) include(cmake/bink.cmake) include(cmake/dx8.cmake) - include(cmake/dbghelp.cmake) endif() # Define a dummy stlport target when not on VC6. diff --git a/CMakePresets.json b/CMakePresets.json index 35a487789e..3c7b6908ce 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -57,6 +57,14 @@ "RTS_DEBUG_CRASHING": "ON" } }, + { + "name": "vc6-weekly", + "displayName": "Windows 32bit VC6 Weekly Release", + "inherits": "vc6", + "cacheVariables": { + "RTS_BUILD_OPTION_VC6_FULL_DEBUG": "ON" + } + }, { "name": "default", "displayName": "Default Config (don't use directly!)", @@ -182,6 +190,12 @@ "displayName": "Build Windows 32bit VC6 Release Logging", "description": "Build Windows 32bit VC6 Release Logging" }, + { + "name": "vc6-weekly", + "configurePreset": "vc6-weekly", + "displayName": "Build Windows 32bit VC6 Weekly Release", + "description": "Build Windows 32bit VC6 Weekly Release" + }, { "name": "win32", "configurePreset": "win32", @@ -285,6 +299,19 @@ } ] }, + { + "name": "vc6-weekly", + "steps": [ + { + "type": "configure", + "name": "vc6-weekly" + }, + { + "type": "build", + "name": "vc6-weekly" + } + ] + }, { "name": "win32", "steps": [ diff --git a/Core/GameEngine/CMakeLists.txt b/Core/GameEngine/CMakeLists.txt index 5587218f83..a00502b598 100644 --- a/Core/GameEngine/CMakeLists.txt +++ b/Core/GameEngine/CMakeLists.txt @@ -1,6 +1,7 @@ set(GAMEENGINE_SRC # Include/Common/AcademyStats.h # Include/Common/ActionManager.h + Include/Common/AddonCompat.h Include/Common/ArchiveFile.h Include/Common/ArchiveFileSystem.h Include/Common/AsciiString.h @@ -39,6 +40,8 @@ set(GAMEENGINE_SRC # Include/Common/Errors.h Include/Common/file.h Include/Common/FileSystem.h + Include/Common/FramePacer.h + Include/Common/FrameRateLimit.h # Include/Common/FunctionLexicon.h Include/Common/GameAudio.h # Include/Common/GameCommon.h @@ -52,6 +55,7 @@ set(GAMEENGINE_SRC # Include/Common/GameState.h # Include/Common/GameStateMap.h # Include/Common/GameType.h + Include/Common/GameUtility.h # Include/Common/Geometry.h # Include/Common/GlobalData.h # Include/Common/Handicap.h @@ -65,9 +69,10 @@ set(GAMEENGINE_SRC # Include/Common/List.h Include/Common/LocalFile.h Include/Common/LocalFileSystem.h -# Include/Common/MapObject.h + Include/Common/MapObject.h # Include/Common/MapReaderWriterInfo.h # Include/Common/MessageStream.h + Include/Common/MiniDumper.h # Include/Common/MiniLog.h Include/Common/MiscAudio.h # Include/Common/MissionStats.h @@ -77,7 +82,7 @@ set(GAMEENGINE_SRC # Include/Common/Money.h # Include/Common/MultiplayerSettings.h # Include/Common/NameKeyGenerator.h -# Include/Common/ObjectStatusTypes.h + Include/Common/ObjectStatusTypes.h # Include/Common/OSDisplay.h # Include/Common/Overridable.h # Include/Common/Override.h @@ -90,7 +95,7 @@ set(GAMEENGINE_SRC # Include/Common/ProductionPrerequisite.h # Include/Common/QuickmatchPreferences.h # Include/Common/QuotedPrintable.h -# Include/Common/Radar.h + Include/Common/Radar.h Include/Common/RAMFile.h Include/Common/RandomValue.h # Include/Common/Recorder.h @@ -112,7 +117,6 @@ set(GAMEENGINE_SRC # Include/Common/StateMachine.h # Include/Common/StatsCollector.h # Include/Common/STLTypedefs.h - Include/Common/STLUtils.h Include/Common/StreamingArchiveFile.h # Include/Common/SubsystemInterface.h # Include/Common/SystemInfo.h @@ -200,14 +204,14 @@ set(GAMEENGINE_SRC # Include/GameClient/Line2D.h # Include/GameClient/LoadScreen.h # Include/GameClient/LookAtXlat.h -# Include/GameClient/MapUtil.h + Include/GameClient/MapUtil.h # Include/GameClient/MessageBox.h # Include/GameClient/MetaEvent.h # Include/GameClient/Module/AnimatedParticleSysBoneClientUpdate.h # Include/GameClient/Module/BeaconClientUpdate.h # Include/GameClient/Module/SwayClientUpdate.h # Include/GameClient/Mouse.h -# Include/GameClient/ParabolicEase.h + Include/GameClient/ParabolicEase.h # Include/GameClient/ParticleSys.h # Include/GameClient/PlaceEventTranslator.h # Include/GameClient/ProcessAnimateWindow.h @@ -219,14 +223,14 @@ set(GAMEENGINE_SRC # Include/GameClient/Shell.h # Include/GameClient/ShellHooks.h # Include/GameClient/ShellMenuScheme.h -# Include/GameClient/Smudge.h -# Include/GameClient/Snow.h + Include/GameClient/Smudge.h + Include/GameClient/Snow.h # Include/GameClient/Statistics.h -# Include/GameClient/TerrainRoads.h -# Include/GameClient/TerrainVisual.h + Include/GameClient/TerrainRoads.h + Include/GameClient/TerrainVisual.h Include/GameClient/VideoPlayer.h -# Include/GameClient/View.h -# Include/GameClient/Water.h + Include/GameClient/View.h + Include/GameClient/Water.h # Include/GameClient/WindowLayout.h Include/GameClient/WindowVideoManager.h # Include/GameClient/WindowXlat.h @@ -507,59 +511,60 @@ set(GAMEENGINE_SRC # Include/GameLogic/WeaponSetFlags.h # Include/GameLogic/WeaponSetType.h # Include/GameLogic/WeaponStatus.h -# Include/GameNetwork/Connection.h -# Include/GameNetwork/ConnectionManager.h -# Include/GameNetwork/DisconnectManager.h -# Include/GameNetwork/DownloadManager.h -# Include/GameNetwork/FileTransfer.h -# Include/GameNetwork/FirewallHelper.h -# Include/GameNetwork/FrameData.h -# Include/GameNetwork/FrameDataManager.h -# Include/GameNetwork/FrameMetrics.h -# Include/GameNetwork/GameInfo.h -# Include/GameNetwork/GameMessageParser.h -# Include/GameNetwork/GameSpy/BuddyDefs.h -# Include/GameNetwork/GameSpy/BuddyThread.h -# Include/GameNetwork/GameSpy/GameResultsThread.h -# Include/GameNetwork/GameSpy/GSConfig.h -# Include/GameNetwork/GameSpy/LadderDefs.h -# Include/GameNetwork/GameSpy/LobbyUtils.h -# Include/GameNetwork/GameSpy/MainMenuUtils.h -# Include/GameNetwork/GameSpy/PeerDefs.h -# Include/GameNetwork/GameSpy/PeerDefsImplementation.h -# Include/GameNetwork/GameSpy/PeerThread.h -# Include/GameNetwork/GameSpy/PersistentStorageDefs.h -# Include/GameNetwork/GameSpy/PersistentStorageThread.h -# Include/GameNetwork/GameSpy/PingThread.h -# Include/GameNetwork/GameSpy/StagingRoomGameInfo.h -# Include/GameNetwork/GameSpy/ThreadUtils.h -# Include/GameNetwork/GameSpyChat.h -# Include/GameNetwork/GameSpyGameInfo.h -# Include/GameNetwork/GameSpyGP.h -# Include/GameNetwork/GameSpyOverlay.h -# Include/GameNetwork/GameSpyThread.h + Include/GameNetwork/Connection.h + Include/GameNetwork/ConnectionManager.h + Include/GameNetwork/DisconnectManager.h + Include/GameNetwork/DownloadManager.h + Include/GameNetwork/FileTransfer.h + Include/GameNetwork/FirewallHelper.h + Include/GameNetwork/FrameData.h + Include/GameNetwork/FrameDataManager.h + Include/GameNetwork/FrameMetrics.h + Include/GameNetwork/GameInfo.h + Include/GameNetwork/GameMessageParser.h + Include/GameNetwork/GameSpy/BuddyDefs.h + Include/GameNetwork/GameSpy/BuddyThread.h + Include/GameNetwork/GameSpy/GameResultsThread.h + Include/GameNetwork/GameSpy/GSConfig.h + Include/GameNetwork/GameSpy/LadderDefs.h + Include/GameNetwork/GameSpy/LobbyUtils.h + Include/GameNetwork/GameSpy/MainMenuUtils.h + Include/GameNetwork/GameSpy/PeerDefs.h + Include/GameNetwork/GameSpy/PeerDefsImplementation.h + Include/GameNetwork/GameSpy/PeerThread.h + Include/GameNetwork/GameSpy/PersistentStorageDefs.h + Include/GameNetwork/GameSpy/PersistentStorageThread.h + Include/GameNetwork/GameSpy/PingThread.h + Include/GameNetwork/GameSpy/StagingRoomGameInfo.h + Include/GameNetwork/GameSpy/ThreadUtils.h +# Include/GameNetwork/GameSpyChat.h # unused +# Include/GameNetwork/GameSpyGameInfo.h # unused +# Include/GameNetwork/GameSpyGP.h # unused + Include/GameNetwork/GameSpyOverlay.h + Include/GameNetwork/GameSpyThread.h # Include/GameNetwork/GUIUtil.h -# Include/GameNetwork/IPEnumeration.h -# Include/GameNetwork/LANAPI.h -# Include/GameNetwork/LANAPICallbacks.h -# Include/GameNetwork/LANGameInfo.h -# Include/GameNetwork/LANPlayer.h -# Include/GameNetwork/NAT.h -# Include/GameNetwork/NetCommandList.h -# Include/GameNetwork/NetCommandMsg.h -# Include/GameNetwork/NetCommandRef.h -# Include/GameNetwork/NetCommandWrapperList.h -# Include/GameNetwork/NetPacket.h -# Include/GameNetwork/NetworkDefs.h -# Include/GameNetwork/NetworkInterface.h -# Include/GameNetwork/networkutil.h -# Include/GameNetwork/RankPointValue.h -# Include/GameNetwork/Transport.h -# Include/GameNetwork/udp.h -# Include/GameNetwork/User.h -# Include/GameNetwork/WOLBrowser/FEBDispatch.h -# Include/GameNetwork/WOLBrowser/WebBrowser.h + Include/GameNetwork/IPEnumeration.h + Include/GameNetwork/LANAPI.h + Include/GameNetwork/LANAPICallbacks.h + Include/GameNetwork/LANGameInfo.h + Include/GameNetwork/LANPlayer.h + Include/GameNetwork/NAT.h + Include/GameNetwork/NetCommandList.h + Include/GameNetwork/NetCommandMsg.h + Include/GameNetwork/NetCommandRef.h + Include/GameNetwork/NetCommandWrapperList.h + Include/GameNetwork/NetPacket.h + Include/GameNetwork/NetworkDefs.h + Include/GameNetwork/NetworkInterface.h + Include/GameNetwork/networkutil.h + Include/GameNetwork/RankPointValue.h + Include/GameNetwork/Transport.h + Include/GameNetwork/udp.h + Include/GameNetwork/User.h + Include/GameNetwork/WOLBrowser/FEBDispatch.h + Include/GameNetwork/WOLBrowser/WebBrowser.h # Include/Precompiled/PreRTS.h + Source/Common/AddonCompat.cpp Source/Common/Audio/AudioEventRTS.cpp Source/Common/Audio/AudioRequest.cpp Source/Common/Audio/DynamicAudioEventInfo.cpp @@ -577,9 +582,12 @@ set(GAMEENGINE_SRC # Source/Common/DamageFX.cpp # Source/Common/Dict.cpp # Source/Common/DiscreteCircle.cpp + Source/Common/FramePacer.cpp + Source/Common/FrameRateLimit.cpp # Source/Common/GameEngine.cpp # Source/Common/GameLOD.cpp # Source/Common/GameMain.cpp + Source/Common/GameUtility.cpp # Source/Common/GlobalData.cpp # Source/Common/INI/INI.cpp # Source/Common/INI/INIAiData.cpp @@ -661,9 +669,10 @@ set(GAMEENGINE_SRC # Source/Common/System/List.cpp Source/Common/System/LocalFile.cpp Source/Common/System/LocalFileSystem.cpp -# Source/Common/System/ObjectStatusTypes.cpp + Source/Common/System/MiniDumper.cpp + Source/Common/System/ObjectStatusTypes.cpp # Source/Common/System/QuotedPrintable.cpp -# Source/Common/System/Radar.cpp + Source/Common/System/Radar.cpp Source/Common/System/RAMFile.cpp # Source/Common/System/registry.cpp # Source/Common/System/SaveGame/GameState.cpp @@ -806,7 +815,7 @@ set(GAMEENGINE_SRC # Source/GameClient/Input/Mouse.cpp # Source/GameClient/LanguageFilter.cpp # Source/GameClient/Line2D.cpp -# Source/GameClient/MapUtil.cpp + Source/GameClient/MapUtil.cpp # Source/GameClient/MessageStream/CommandXlat.cpp # Source/GameClient/MessageStream/GUICommandTranslator.cpp # Source/GameClient/MessageStream/HintSpy.cpp @@ -816,10 +825,10 @@ set(GAMEENGINE_SRC # Source/GameClient/MessageStream/PlaceEventTranslator.cpp # Source/GameClient/MessageStream/SelectionXlat.cpp # Source/GameClient/MessageStream/WindowXlat.cpp -# Source/GameClient/ParabolicEase.cpp + Source/GameClient/ParabolicEase.cpp # Source/GameClient/RadiusDecal.cpp # Source/GameClient/SelectionInfo.cpp -# Source/GameClient/Snow.cpp + Source/GameClient/Snow.cpp # Source/GameClient/Statistics.cpp # Source/GameClient/System/Anim2D.cpp # Source/GameClient/System/CampaignManager.cpp @@ -828,13 +837,13 @@ set(GAMEENGINE_SRC # Source/GameClient/System/Image.cpp # Source/GameClient/System/ParticleSys.cpp # Source/GameClient/System/RayEffect.cpp -# Source/GameClient/System/Smudge.cpp -# Source/GameClient/Terrain/TerrainRoads.cpp -# Source/GameClient/Terrain/TerrainVisual.cpp + 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/View.cpp -# Source/GameClient/Water.cpp + Source/GameClient/View.cpp + Source/GameClient/Water.cpp # Source/GameLogic/AI/AI.cpp # Source/GameLogic/AI/AIDock.cpp # Source/GameLogic/AI/AIGroup.cpp @@ -1102,53 +1111,53 @@ set(GAMEENGINE_SRC # Source/GameLogic/System/GameLogic.cpp # Source/GameLogic/System/GameLogicDispatch.cpp # Source/GameLogic/System/RankInfo.cpp -# Source/GameNetwork/Connection.cpp -# Source/GameNetwork/ConnectionManager.cpp -# Source/GameNetwork/DisconnectManager.cpp -# Source/GameNetwork/DownloadManager.cpp -# Source/GameNetwork/FileTransfer.cpp -# Source/GameNetwork/FirewallHelper.cpp -# Source/GameNetwork/FrameData.cpp -# Source/GameNetwork/FrameDataManager.cpp -# Source/GameNetwork/FrameMetrics.cpp -# Source/GameNetwork/GameInfo.cpp -# Source/GameNetwork/GameMessageParser.cpp + Source/GameNetwork/Connection.cpp + Source/GameNetwork/ConnectionManager.cpp + Source/GameNetwork/DisconnectManager.cpp + Source/GameNetwork/DownloadManager.cpp + Source/GameNetwork/FileTransfer.cpp + Source/GameNetwork/FirewallHelper.cpp + Source/GameNetwork/FrameData.cpp + Source/GameNetwork/FrameDataManager.cpp + Source/GameNetwork/FrameMetrics.cpp + Source/GameNetwork/GameInfo.cpp + Source/GameNetwork/GameMessageParser.cpp #Source/GameNetwork/GameSpyChat.cpp # unused #Source/GameNetwork/GameSpyGameInfo.cpp # unused #Source/GameNetwork/GameSpyGP.cpp # unused -# Source/GameNetwork/GameSpy/Chat.cpp -# Source/GameNetwork/GameSpy/GSConfig.cpp -# Source/GameNetwork/GameSpy/LadderDefs.cpp -# Source/GameNetwork/GameSpy/LobbyUtils.cpp -# Source/GameNetwork/GameSpy/MainMenuUtils.cpp -# Source/GameNetwork/GameSpy/PeerDefs.cpp -# Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp -# Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp -# Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp -# Source/GameNetwork/GameSpy/Thread/PeerThread.cpp -# Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp -# Source/GameNetwork/GameSpy/Thread/PingThread.cpp -# Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp -# Source/GameNetwork/GameSpyOverlay.cpp + Source/GameNetwork/GameSpy/Chat.cpp + Source/GameNetwork/GameSpy/GSConfig.cpp + Source/GameNetwork/GameSpy/LadderDefs.cpp + Source/GameNetwork/GameSpy/LobbyUtils.cpp + Source/GameNetwork/GameSpy/MainMenuUtils.cpp + Source/GameNetwork/GameSpy/PeerDefs.cpp + Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp + Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp + Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp + Source/GameNetwork/GameSpy/Thread/PeerThread.cpp + Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp + Source/GameNetwork/GameSpy/Thread/PingThread.cpp + Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp + Source/GameNetwork/GameSpyOverlay.cpp # Source/GameNetwork/GUIUtil.cpp -# Source/GameNetwork/IPEnumeration.cpp -# Source/GameNetwork/LANAPI.cpp -# Source/GameNetwork/LANAPICallbacks.cpp -# Source/GameNetwork/LANAPIhandlers.cpp -# Source/GameNetwork/LANGameInfo.cpp -# Source/GameNetwork/NAT.cpp -# Source/GameNetwork/NetCommandList.cpp -# Source/GameNetwork/NetCommandMsg.cpp -# Source/GameNetwork/NetCommandRef.cpp -# Source/GameNetwork/NetCommandWrapperList.cpp -# Source/GameNetwork/NetMessageStream.cpp -# Source/GameNetwork/NetPacket.cpp -# Source/GameNetwork/Network.cpp -# Source/GameNetwork/NetworkUtil.cpp -# Source/GameNetwork/Transport.cpp -# Source/GameNetwork/udp.cpp -# Source/GameNetwork/User.cpp -# Source/GameNetwork/WOLBrowser/WebBrowser.cpp + Source/GameNetwork/IPEnumeration.cpp + Source/GameNetwork/LANAPI.cpp + Source/GameNetwork/LANAPICallbacks.cpp + Source/GameNetwork/LANAPIhandlers.cpp + Source/GameNetwork/LANGameInfo.cpp + Source/GameNetwork/NAT.cpp + Source/GameNetwork/NetCommandList.cpp + Source/GameNetwork/NetCommandMsg.cpp + Source/GameNetwork/NetCommandRef.cpp + Source/GameNetwork/NetCommandWrapperList.cpp + Source/GameNetwork/NetMessageStream.cpp + Source/GameNetwork/NetPacket.cpp + Source/GameNetwork/Network.cpp + Source/GameNetwork/NetworkUtil.cpp + Source/GameNetwork/Transport.cpp + Source/GameNetwork/udp.cpp + Source/GameNetwork/User.cpp + Source/GameNetwork/WOLBrowser/WebBrowser.cpp # Source/Precompiled/PreRTS.cpp ) diff --git a/Core/Libraries/Source/debug/debug.cpp b/Core/GameEngine/Include/Common/AddonCompat.h similarity index 62% rename from Core/Libraries/Source/debug/debug.cpp rename to Core/GameEngine/Include/Common/AddonCompat.h index 16286fd7ae..7b8bc2c9e9 100644 --- a/Core/Libraries/Source/debug/debug.cpp +++ b/Core/GameEngine/Include/Common/AddonCompat.h @@ -1,6 +1,6 @@ /* ** Command & Conquer Generals Zero Hour(tm) -** Copyright 2025 Electronic Arts Inc. +** Copyright 2025 TheSuperHackers ** ** 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 @@ -16,14 +16,10 @@ ** along with this program. If not, see . */ -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/debug/debug.cpp $ -// $Author: mhoffe $ -// $Revision: #1 $ -// $DateTime: 2003/07/03 11:55:26 $ -// -// (c) 2003 Electronic Arts -// -// Debug module main code -////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#pragma once + +namespace addon +{ +extern Bool HasFullviewportDat(); + +} // namespace addon diff --git a/Core/GameEngine/Include/Common/ArchiveFile.h b/Core/GameEngine/Include/Common/ArchiveFile.h index b62b61297d..7c3d1c7a8f 100644 --- a/Core/GameEngine/Include/Common/ArchiveFile.h +++ b/Core/GameEngine/Include/Common/ArchiveFile.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __ARCHIVEFILE_H -#define __ARCHIVEFILE_H - #include "Lib/BaseType.h" #include "Common/AsciiString.h" #include "Common/ArchiveFileSystem.h" @@ -73,5 +70,3 @@ class ArchiveFile 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 diff --git a/Core/GameEngine/Include/Common/ArchiveFileSystem.h b/Core/GameEngine/Include/Common/ArchiveFileSystem.h index b781a90e0a..a482e593b9 100644 --- a/Core/GameEngine/Include/Common/ArchiveFileSystem.h +++ b/Core/GameEngine/Include/Common/ArchiveFileSystem.h @@ -43,9 +43,6 @@ #pragma once -#ifndef __ARCHIVEFILESYSTEM_H_ -#define __ARCHIVEFILESYSTEM_H_ - #define MUSIC_BIG "Music.big" //---------------------------------------------------------------------------- @@ -84,26 +81,19 @@ 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. +typedef std::map DetailedArchivedDirectoryInfoMap; // Archived directory name to detailed archived directory info +typedef std::map ArchivedDirectoryInfoMap; // Archived directory name to archived directory info +typedef std::map ArchivedFileInfoMap; // Archived file name to archived file info +typedef std::map ArchiveFileMap; // Archive file name to archive data +typedef std::multimap ArchivedFileLocationMap; // Archived file name to archive data class ArchivedDirectoryInfo { public: - AsciiString m_directoryName; - ArchivedDirectoryInfoMap m_directories; - ArchivedFileLocationMap m_files; - - void clear() - { - m_directoryName.clear(); - m_directories.clear(); - m_files.clear(); - } - + AsciiString m_path; // The full path to this directory + AsciiString m_directoryName; // The current directory + ArchivedDirectoryInfoMap m_directories; // Contained leaf directories + ArchivedFileLocationMap m_files; // Contained files }; class DetailedArchivedDirectoryInfo @@ -112,13 +102,6 @@ class DetailedArchivedDirectoryInfo AsciiString m_directoryName; DetailedArchivedDirectoryInfoMap m_directories; ArchivedFileInfoMap m_files; - - void clear() - { - m_directoryName.clear(); - m_directories.clear(); - m_files.clear(); - } }; class ArchivedFileInfo @@ -130,23 +113,16 @@ class ArchivedFileInfo UnsignedInt m_size; ArchivedFileInfo() + : m_offset(0) + , m_size(0) { - clear(); - } - - void clear() - { - m_filename.clear(); - m_archiveFilename.clear(); - m_offset = 0; - m_size = 0; } }; class ArchiveFileSystem : public SubsystemInterface { - public: +public: ArchiveFileSystem(); virtual ~ArchiveFileSystem(); @@ -158,24 +134,38 @@ class ArchiveFileSystem : public SubsystemInterface // 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 + virtual void closeAllArchiveFiles( void ) = 0; ///< Close all Archive files 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. + virtual File* openFile( const Char *filename, Int access = 0, FileInstance instance = 0); ///< Search Archive files for specified file name and open it if found + virtual void closeAllFiles( void ) = 0; ///< Close all files associated with Archive files + virtual Bool doesFileExist(const Char *filename, FileInstance instance = 0) 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 + Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo, FileInstance instance = 0) 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; + ArchiveFile* getArchiveFile(const AsciiString& filename, FileInstance instance = 0) const; + void loadMods( void ); + ArchivedDirectoryInfo* friend_getArchivedDirectoryInfo(const Char* directory); + 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. + struct ArchivedDirectoryInfoResult + { + ArchivedDirectoryInfoResult() : dirInfo(NULL) {} + Bool valid() const { return dirInfo != NULL; } + + ArchivedDirectoryInfo* dirInfo; + AsciiString lastToken; ///< Synonymous for file name if the search directory was a file path + }; + + ArchivedDirectoryInfoResult getArchivedDirectoryInfo(const Char* directory); + + virtual void loadIntoDirectoryTree(ArchiveFile *archiveFile, 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; @@ -187,5 +177,3 @@ extern ArchiveFileSystem *TheArchiveFileSystem; //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- - -#endif // __ARCHIVEFILESYSTEM_H_ diff --git a/Core/GameEngine/Include/Common/AsciiString.h b/Core/GameEngine/Include/Common/AsciiString.h index 54773bdf6d..5af9cbe130 100644 --- a/Core/GameEngine/Include/Common/AsciiString.h +++ b/Core/GameEngine/Include/Common/AsciiString.h @@ -45,12 +45,7 @@ #pragma once -#ifndef ASCIISTRING_H -#define ASCIISTRING_H - #include -#include -#include #include "Lib/BaseType.h" #include "Common/Debug.h" #include "Common/Errors.h" @@ -96,13 +91,13 @@ class AsciiString unsigned short m_numCharsAllocated; // length of data allocated // char m_stringdata[]; - inline char* peek() { return (char*)(this+1); } + char* peek() { return (char*)(this+1); } }; #ifdef RTS_DEBUG void validate() const; #else - inline void validate() const { } + void validate() const { } #endif protected: @@ -114,6 +109,10 @@ class AsciiString public: + typedef Char value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + enum { MAX_FORMAT_BUF_LEN = 2048, ///< max total len of string created by format/format_va @@ -126,7 +125,7 @@ class AsciiString string, so we don't need to construct temporaries for such a common thing. */ - static AsciiString TheEmptyString; + static const AsciiString TheEmptyString; /** Default constructor -- construct a new, empty AsciiString. @@ -148,6 +147,12 @@ class AsciiString */ AsciiString(const char* s); + /** + Constructs an AsciiString with the given string and length. + The length must not be larger than the actual string length. + */ + AsciiString(const char* s, int len); + /** Destructor. Not too exciting... clean up the works and such. */ @@ -200,12 +205,20 @@ class AsciiString refcount.) */ void set(const AsciiString& stringSrc); + /** Replace the contents of self with the given string. Note that a copy of the string is made; the input ptr is not saved. */ void set(const char* s); + /** + Replace the contents of self with the given string and length. + Note that a copy of the string is made; the input ptr is not saved. + The length must not be larger than the actual string length. + */ + void set(const char* s, int len); + /** replace contents of self with the given string. Note the nomenclature is translate rather than set; this is because @@ -312,13 +325,13 @@ class AsciiString return true iff self starts with the given string. */ Bool startsWith(const char* p) const; - inline Bool startsWith(const AsciiString& stringSrc) const { return startsWith(stringSrc.str()); } + Bool startsWith(const AsciiString& stringSrc) const { return startsWith(stringSrc.str()); } /** return true iff self starts with the given string. (case insensitive) */ Bool startsWithNoCase(const char* p) const; - inline Bool startsWithNoCase(const AsciiString& stringSrc) const { return startsWithNoCase(stringSrc.str()); } + Bool startsWithNoCase(const AsciiString& stringSrc) const { return startsWithNoCase(stringSrc.str()); } /** return true iff self ends with the given string. @@ -581,5 +594,3 @@ inline Bool operator>=(const AsciiString& s1, const char* s2) { return strcmp(s1.str(), s2) >= 0; } - -#endif // ASCIISTRING_H diff --git a/Core/GameEngine/Include/Common/AudioAffect.h b/Core/GameEngine/Include/Common/AudioAffect.h index 867ce255f0..f58cb9e18b 100644 --- a/Core/GameEngine/Include/Common/AudioAffect.h +++ b/Core/GameEngine/Include/Common/AudioAffect.h @@ -25,10 +25,8 @@ // EA Pacific // John McDonald, Jr // Do not distribute -#pragma once -#ifndef _AUDIOAFFECT_H_ -#define _AUDIOAFFECT_H_ +#pragma once #include @@ -44,5 +42,3 @@ enum AudioAffect CPP_11(: Int) AudioAffect_SystemSetting = 0x10, }; - -#endif // _AUDIOAFFECT_H_ diff --git a/Core/GameEngine/Include/Common/AudioEventInfo.h b/Core/GameEngine/Include/Common/AudioEventInfo.h index 8acf9778aa..dc4317204f 100644 --- a/Core/GameEngine/Include/Common/AudioEventInfo.h +++ b/Core/GameEngine/Include/Common/AudioEventInfo.h @@ -27,8 +27,6 @@ // Author: John K. McDonald, March 2002 #pragma once -#ifndef _H_AUDIOEVENTINFO_ -#define _H_AUDIOEVENTINFO_ #include "Common/AsciiString.h" #include "Common/GameMemory.h" @@ -48,17 +46,19 @@ enum AudioType CPP_11(: Int) AT_SoundEffect }; -extern const char *theAudioPriorityNames[]; +extern const char* const theAudioPriorityNames[]; enum AudioPriority CPP_11(: Int) { AP_LOWEST, AP_LOW, AP_NORMAL, AP_HIGH, - AP_CRITICAL + AP_CRITICAL, + + AP_COUNT }; -extern const char *theSoundTypeNames[]; +extern const char *const theSoundTypeNames[]; enum SoundType CPP_11(: Int) { ST_UI = 0x0001, @@ -72,7 +72,7 @@ enum SoundType CPP_11(: Int) ST_EVERYONE = 0x0100, }; -extern const char *theAudioControlNames[]; +extern const char *const theAudioControlNames[]; enum AudioControl CPP_11(: Int) { AC_LOOP = 0x0001, @@ -134,5 +134,3 @@ struct AudioEventInfo : public MemoryPoolObject static const FieldParse m_audioEventInfo[]; ///< the parse table for INI definition const FieldParse *getFieldParse( void ) const { return m_audioEventInfo; } }; - -#endif /* _H_AUDIOEVENTINFO_ */ diff --git a/Core/GameEngine/Include/Common/AudioEventRTS.h b/Core/GameEngine/Include/Common/AudioEventRTS.h index bf52de40b3..5a6f0f4510 100644 --- a/Core/GameEngine/Include/Common/AudioEventRTS.h +++ b/Core/GameEngine/Include/Common/AudioEventRTS.h @@ -27,8 +27,6 @@ // Author: John K. McDonald, March 2002 #pragma once -#ifndef _H_AUDIOEVENTRTS_ -#define _H_AUDIOEVENTRTS_ #include "Common/AsciiString.h" #include "Common/GameAudio.h" @@ -212,6 +210,3 @@ class DynamicAudioEventRTS : public MemoryPoolObject AudioEventRTS m_event; }; EMPTY_DTOR(DynamicAudioEventRTS) - -#endif /* _H_AUDIOEVENTRTS_ */ - diff --git a/Core/GameEngine/Include/Common/AudioHandleSpecialValues.h b/Core/GameEngine/Include/Common/AudioHandleSpecialValues.h index 0c564b4a99..102f9ed860 100644 --- a/Core/GameEngine/Include/Common/AudioHandleSpecialValues.h +++ b/Core/GameEngine/Include/Common/AudioHandleSpecialValues.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _AUDIOHANDLESPECIALVALUES_H_ -#define _AUDIOHANDLESPECIALVALUES_H_ - enum AudioHandleSpecialValues CPP_11(: Int) { AHSV_Error = 0x00, @@ -41,5 +38,3 @@ enum AudioHandleSpecialValues CPP_11(: Int) AHSV_StopTheMusicFade, AHSV_FirstHandle }; - -#endif // _AUDIOHANDLESPECIALVALUES_H_ diff --git a/Core/GameEngine/Include/Common/AudioRandomValue.h b/Core/GameEngine/Include/Common/AudioRandomValue.h index 263189228c..4efc9c26b3 100644 --- a/Core/GameEngine/Include/Common/AudioRandomValue.h +++ b/Core/GameEngine/Include/Common/AudioRandomValue.h @@ -29,9 +29,6 @@ #pragma once -#ifndef _AUDIO_RANDOM_VALUE_H_ -#define _AUDIO_RANDOM_VALUE_H_ - #include "Lib/BaseType.h" // do NOT use these functions directly, rather use the macros below @@ -43,5 +40,3 @@ extern Real GetGameAudioRandomValueReal( Real lo, Real hi, const char *file, int #define GameAudioRandomValueReal( lo, hi ) GetGameAudioRandomValueReal( lo, hi, __FILE__, __LINE__ ) //-------------------------------------------------------------------------------------------------------------- - -#endif // _AUDIO_RANDOM_VALUE_H_ diff --git a/Core/GameEngine/Include/Common/AudioRequest.h b/Core/GameEngine/Include/Common/AudioRequest.h index e8a8681644..a0321fdb48 100644 --- a/Core/GameEngine/Include/Common/AudioRequest.h +++ b/Core/GameEngine/Include/Common/AudioRequest.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _AUDIOREQUEST_H_ -#define _AUDIOREQUEST_H_ - #include "Common/GameAudio.h" #include "Common/GameMemory.h" @@ -57,5 +54,3 @@ struct AudioRequest : public MemoryPoolObject Bool m_usePendingEvent; Bool m_requiresCheckForSample; }; - -#endif // _AUDIOREQUEST_H_ diff --git a/Core/GameEngine/Include/Common/AudioSettings.h b/Core/GameEngine/Include/Common/AudioSettings.h index f71e9bfaa6..93a485e848 100644 --- a/Core/GameEngine/Include/Common/AudioSettings.h +++ b/Core/GameEngine/Include/Common/AudioSettings.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _AUDIOSETTINGS_H_ -#define _AUDIOSETTINGS_H_ - #include "Common/AsciiString.h" enum { MAX_HW_PROVIDERS = 4 }; @@ -103,5 +100,3 @@ struct AudioSettings //between 75% and 100%, not 100% to 125%! Real m_zoomSoundVolumePercentageAmount; //The amount of sound volume dedicated to zooming. }; - -#endif // _AUDIOSETTINGS_H_ diff --git a/Core/GameEngine/Include/Common/CRCDebug.h b/Core/GameEngine/Include/Common/CRCDebug.h index 77d806042e..1fbeffebe6 100644 --- a/Core/GameEngine/Include/Common/CRCDebug.h +++ b/Core/GameEngine/Include/Common/CRCDebug.h @@ -26,10 +26,7 @@ // Macros/functions/etc to help logging values for tracking down sync errors // Author: Matthew D. Campbell, June 2002 -// no #pragma once - we want to be able to conditionally define NO_DEBUG_CRC in indiv .cpp files - -#ifndef __CRCDEBUG_H__ -#define __CRCDEBUG_H__ +#pragma once #include "Common/Debug.h" @@ -129,5 +126,3 @@ extern Int NET_CRC_INTERVAL; extern Int REPLAY_CRC_INTERVAL; extern Bool TheDebugIgnoreSyncErrors; - -#endif // __CRCDEBUG_H__ diff --git a/Core/GameEngine/Include/Common/Debug.h b/Core/GameEngine/Include/Common/Debug.h index 0548e5fcba..94b3a0c08d 100644 --- a/Core/GameEngine/Include/Common/Debug.h +++ b/Core/GameEngine/Include/Common/Debug.h @@ -45,8 +45,7 @@ #pragma once -#ifndef __DEBUG_H_ -#define __DEBUG_H_ +#include class AsciiString; @@ -195,7 +194,7 @@ class AsciiString; if (!ignoreCrash) { \ TheCurrentIgnoreCrashPtr = &ignoreCrash; \ DebugCrash m ; \ - TheCurrentIgnoreCrashPtr = NULL; \ + TheCurrentIgnoreCrashPtr = nullptr; \ } \ } \ } while (0) @@ -262,5 +261,3 @@ class SimpleProfiler #endif // MACROS ////////////////////////////////////////////////////////////////// - -#endif // __DEBUG_H_ diff --git a/Core/GameEngine/Include/Common/DynamicAudioEventInfo.h b/Core/GameEngine/Include/Common/DynamicAudioEventInfo.h index c13dfbd591..145f895cc6 100644 --- a/Core/GameEngine/Include/Common/DynamicAudioEventInfo.h +++ b/Core/GameEngine/Include/Common/DynamicAudioEventInfo.h @@ -28,10 +28,6 @@ #pragma once - -#ifndef DYNAMICAUDIOEVENTINFO_H_INCLUDED -#define DYNAMICAUDIOEVENTINFO_H_INCLUDED - #include "Common/AudioEventInfo.h" #include "Common/BitFlags.h" @@ -155,8 +151,3 @@ inline Bool DynamicAudioEventInfo::wasPriorityOverriden() const { return m_overriddenFields.test( OVERRIDE_PRIORITY ); } - - - -#endif // DYNAMICAUDIOEVENTINFO_H_INCLUDED - diff --git a/Core/GameEngine/Include/Common/FileSystem.h b/Core/GameEngine/Include/Common/FileSystem.h index 5c8b3a57f8..51bf9153ca 100644 --- a/Core/GameEngine/Include/Common/FileSystem.h +++ b/Core/GameEngine/Include/Common/FileSystem.h @@ -43,9 +43,6 @@ #pragma once -#ifndef __FILESYSTEM_H -#define __FILESYSTEM_H - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -54,6 +51,10 @@ #include "Common/STLTypedefs.h" #include "Common/SubsystemInterface.h" +#include + +#include "mutex.h" + //---------------------------------------------------------------------------- // Forward References //---------------------------------------------------------------------------- @@ -64,6 +65,7 @@ typedef std::set > FilenameList; typedef FilenameList::iterator FilenameListIter; +typedef UnsignedByte FileInstance; //---------------------------------------------------------------------------- // Type Defines @@ -78,7 +80,7 @@ typedef FilenameList::iterator FilenameListIter; #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 +// the following defines are only to be used while maintaining legacy compatibility // 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 @@ -87,18 +89,29 @@ typedef FilenameList::iterator FilenameListIter; // 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 +#if defined(RTS_DEBUG) #define LOAD_TEST_ASSETS 1 +#endif + #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 + // 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 + +#ifndef ENABLE_FILESYSTEM_LOGGING +#define ENABLE_FILESYSTEM_LOGGING (0) #endif + struct FileInfo { + + Int64 size() const { return (Int64)sizeHigh << 32 | sizeLow; } + Int64 timestamp() const { return (Int64)timestampHigh << 32 | timestampLow; } + Int sizeHigh; Int sizeLow; Int timestampHigh; @@ -111,12 +124,17 @@ 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 implementation decides what derivative of File object needs to be * created when FileSystem::Open() gets called. */ +// TheSuperHackers @feature xezon 23/08/2025 Implements file instance access. +// Can be used to access different versions of files in different archives under the same name. +// Instance 0 refers to the top file that shadows all other files under the same name. +// +// TheSuperHackers @bugfix xezon 26/10/2025 Adds a mutex to the file exist map to try prevent +// application hangs during level load after the file exist map was corrupted because of writes +// from multiple threads. //=============================== -#include - class FileSystem : public SubsystemInterface { FileSystem(const FileSystem&); @@ -130,22 +148,35 @@ class FileSystem : public SubsystemInterface void reset(); void update(); - File* openFile( const Char *filename, Int access = File::NONE, size_t bufferSize = File::BUFFERSIZE ); ///< 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. + File* openFile( const Char *filename, Int access = File::NONE, size_t bufferSize = File::BUFFERSIZE, FileInstance instance = 0 ); ///< opens a File interface to the specified file + Bool doesFileExist(const Char *filename, FileInstance instance = 0) 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 getFileInfo(const AsciiString& filename, FileInfo *fileInfo, FileInstance instance = 0) 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 AsciiString normalizePath(const AsciiString& path); ///< 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: #if ENABLE_FILESYSTEM_EXISTENCE_CACHE - mutable std::map m_fileExist; + struct FileExistData + { + FileExistData() : instanceExists(0), instanceDoesNotExist(~FileInstance(0)) {} + FileInstance instanceExists; + FileInstance instanceDoesNotExist; + }; + typedef std::hash_map< + rts::string_key, FileExistData, + rts::string_key_hash, + rts::string_key_equal > FileExistMap; + + mutable FileExistMap m_fileExist; + mutable FastCriticalSectionClass m_fileExistMutex; #endif }; @@ -156,7 +187,3 @@ extern FileSystem* TheFileSystem; //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- - - - -#endif // __WSYS_FILESYSTEM_H diff --git a/Core/GameEngine/Include/Common/FramePacer.h b/Core/GameEngine/Include/Common/FramePacer.h new file mode 100644 index 0000000000..5bba1a704e --- /dev/null +++ b/Core/GameEngine/Include/Common/FramePacer.h @@ -0,0 +1,84 @@ +/* +** Command & Conquer Generals Zero Hour(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 . +*/ + +#pragma once + +#include "Common/FrameRateLimit.h" + + +// TheSuperHackers @todo Use unsigned integers for fps values +// TheSuperHackers @todo Consolidate the GlobalData::m_useFpsLimit and FramePacer::m_enableFpsLimit +// TheSuperHackers @todo Implement new fast forward in here +class FramePacer +{ +public: + + typedef UnsignedInt LogicTimeQueryFlags; + enum LogicTimeQueryFlags_ CPP_11(: LogicTimeQueryFlags) + { + IgnoreFrozenTime = 1<<0, ///< Ignore frozen time for the query + IgnoreHaltedGame = 1<<1, ///< Ignore halted game for the query + }; + + FramePacer(); + ~FramePacer(); + + void update(); ///< Signal that the app/render update is done and wait for the fps limit if applicable. + + void setFramesPerSecondLimit( Int fps ); ///< Set the update fps limit. + Int getFramesPerSecondLimit() const; ///< Get the update fps limit. + void enableFramesPerSecondLimit( Bool enable ); ///< Enable or disable the update fps limit. + Bool isFramesPerSecondLimitEnabled() const; ///< Returns whether the fps limit is enabled here. + Bool isActualFramesPerSecondLimitEnabled() const; ///< Returns whether the fps limit is actually enabled when considering all game settings and setups. + Int getActualFramesPerSecondLimit() const; // Get the actual update fps limit. + + Real getUpdateTime() const; ///< Get the last update delta time in seconds. + Real getUpdateFps() const; ///< Get the last update fps. + Real getBaseOverUpdateFpsRatio(Real minUpdateFps = 5.0f); ///< Get the last engine base over update fps ratio. Used to scale user inputs to a frame rate independent speed. + + void setTimeFrozen(Bool frozen); ///< Set time frozen. Allows scripted camera movement. + void setGameHalted(Bool halted); ///< Set game halted. Does not allow scripted camera movement. + Bool isTimeFrozen() const; + Bool isGameHalted() const; + + void setLogicTimeScaleFps( Int fps ); ///< Set the logic time scale fps and therefore scale the simulation time. Is capped by the max render fps and does not apply to network matches. + Int getLogicTimeScaleFps() const; ///< Get the raw logic time scale fps value. + void enableLogicTimeScale( Bool enable ); ///< Enable or disable the logic time scale setup. If disabled, the simulation time scale is bound to the render frame time or network update time. + Bool isLogicTimeScaleEnabled() const; ///< Check whether the logic time scale setup is enabled. + Int getActualLogicTimeScaleFps(LogicTimeQueryFlags flags = 0) const; ///< Get the real logic time scale fps, depending on the max render fps, network state and enabled state. + Real getActualLogicTimeScaleRatio(LogicTimeQueryFlags flags = 0) const; ///< Get the real logic time scale ratio, depending on the max render fps, network state and enabled state. + Real getActualLogicTimeScaleOverFpsRatio(LogicTimeQueryFlags flags = 0) const; ///< Get the real logic time scale over render fps ratio, used to scale down steps in render updates to match logic updates. + Real getLogicTimeStepSeconds(LogicTimeQueryFlags flags = 0) const; ///< Get the logic time step in seconds + Real getLogicTimeStepMilliseconds(LogicTimeQueryFlags flags = 0) const; ///< Get the logic time step in milliseconds + +protected: + + FrameRateLimit m_frameRateLimit; + + Int m_maxFPS; ///< Maximum frames per second for rendering + Int m_logicTimeScaleFPS; ///< Maximum frames per second for logic time scale + + Real m_updateTime; ///< Last update delta time in seconds + + Bool m_enableFpsLimit; + Bool m_enableLogicTimeScale; + Bool m_isTimeFrozen; + Bool m_isGameHalted; +}; + +extern FramePacer* TheFramePacer; diff --git a/Core/GameEngine/Include/Common/FrameRateLimit.h b/Core/GameEngine/Include/Common/FrameRateLimit.h new file mode 100644 index 0000000000..5bb2b5fd3a --- /dev/null +++ b/Core/GameEngine/Include/Common/FrameRateLimit.h @@ -0,0 +1,78 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#pragma once + +#include "Common/GameCommon.h" + + +class FrameRateLimit +{ +public: + FrameRateLimit(); + + Real wait(UnsignedInt maxFps); + +private: + Int64 m_freq; + Int64 m_start; +}; + + +enum FpsValueChange +{ + FpsValueChange_Increase, + FpsValueChange_Decrease, +}; + + +class RenderFpsPreset +{ +public: + enum CPP_11(: UnsignedInt) + { + UncappedFpsValue = 1000000, + }; + + static UnsignedInt getNextFpsValue(UnsignedInt value); + static UnsignedInt getPrevFpsValue(UnsignedInt value); + static UnsignedInt changeFpsValue(UnsignedInt value, FpsValueChange change); + +private: + static const UnsignedInt s_fpsValues[]; +}; + + +class LogicTimeScaleFpsPreset +{ +public: + enum CPP_11(: UnsignedInt) + { +#if RTS_DEBUG + MinFpsValue = 5, +#else + MinFpsValue = LOGICFRAMES_PER_SECOND, +#endif + StepFpsValue = 5, + }; + + static UnsignedInt getNextFpsValue(UnsignedInt value); + static UnsignedInt getPrevFpsValue(UnsignedInt value); + static UnsignedInt changeFpsValue(UnsignedInt value, FpsValueChange change); +}; + diff --git a/Core/GameEngine/Include/Common/GameAudio.h b/Core/GameEngine/Include/Common/GameAudio.h index 354336da2b..8a9d009326 100644 --- a/Core/GameEngine/Include/Common/GameAudio.h +++ b/Core/GameEngine/Include/Common/GameAudio.h @@ -41,9 +41,6 @@ #pragma once -#ifndef __COMMON_GAMEAUDIO_H_ -#define __COMMON_GAMEAUDIO_H_ - // Includes #include "Lib/BaseType.h" #include "Common/STLTypedefs.h" @@ -431,5 +428,3 @@ class AudioManagerDummy : public AudioManager extern AudioManager *TheAudio; - -#endif // __COMMON_GAMEAUDIO_H_ diff --git a/Core/GameEngine/Include/Common/GameDefines.h b/Core/GameEngine/Include/Common/GameDefines.h index 3df8fb3090..667ea8aa9f 100644 --- a/Core/GameEngine/Include/Common/GameDefines.h +++ b/Core/GameEngine/Include/Common/GameDefines.h @@ -18,9 +18,15 @@ #pragma once +#include "WWDefines.h" + // Note: Retail compatibility must not be broken before this project officially does. // Use RETAIL_COMPATIBLE_CRC and RETAIL_COMPATIBLE_XFER_SAVE to guard breaking changes. +#ifndef PRESERVE_RETAIL_BEHAVIOR +#define PRESERVE_RETAIL_BEHAVIOR (1) // Retain behavior present in retail Generals 1.08 and Zero Hour 1.04 +#endif + #ifndef RETAIL_COMPATIBLE_CRC #define RETAIL_COMPATIBLE_CRC (1) // Game is expected to be CRC compatible with retail Generals 1.08, Zero Hour 1.04 #endif @@ -29,6 +35,13 @@ #define RETAIL_COMPATIBLE_XFER_SAVE (1) // Game is expected to be Xfer Save compatible with retail Generals 1.08, Zero Hour 1.04 #endif +// This is here to easily toggle between the retail compatible with fixed pathfinding fallback and pure fixed pathfinding mode +#if RETAIL_COMPATIBLE_CRC +#define RETAIL_COMPATIBLE_PATHFINDING (1) +#else +#define RETAIL_COMPATIBLE_PATHFINDING (0) +#endif + // This is essentially synonymous for RETAIL_COMPATIBLE_CRC. There is a lot wrong with AIGroup, such as use-after-free, double-free, leaks, // but we cannot touch it much without breaking retail compatibility. Do not shy away from using massive hacks when fixing issues with AIGroup, // but put them behind this macro. @@ -60,6 +73,12 @@ #define ENABLE_FILESYSTEM_EXISTENCE_CACHE (1) #endif +// Enable prioritization of textures by size. This will improve the texture quality of 481 textures in Zero Hour +// by using the larger resolution textures from Generals. Content wise these textures are identical. +#ifndef PRIORITIZE_TEXTURES_BY_SIZE +#define PRIORITIZE_TEXTURES_BY_SIZE (1) +#endif + // Enable obsolete code. This mainly refers to code that existed in Generals but was removed in GeneralsMD. // Disable and remove this when Generals and GeneralsMD are merged. #if RTS_GENERALS @@ -67,3 +86,21 @@ #define USE_OBSOLETE_GENERALS_CODE (1) #endif #endif + +// Overwrite window settings until wnd data files are adapted or fixed. +#ifndef ENABLE_GUI_HACKS +#define ENABLE_GUI_HACKS (1) +#endif + +// Tell our computer identity in the LAN lobby. Disable for privacy. +// Was enabled in the retail game and exposed the computer login and host names. +#ifdef RTS_DEBUG +#ifndef TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY +#define TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY (1) +#endif +#endif + +#define MIN_DISPLAY_BIT_DEPTH 16 +#define DEFAULT_DISPLAY_BIT_DEPTH 32 +#define DEFAULT_DISPLAY_WIDTH 800 // The standard resolution this game was designed for +#define DEFAULT_DISPLAY_HEIGHT 600 // The standard resolution this game was designed for diff --git a/Core/GameEngine/Include/Common/GameMemory.h b/Core/GameEngine/Include/Common/GameMemory.h index 65b1732e52..1ea96161ce 100644 --- a/Core/GameEngine/Include/Common/GameMemory.h +++ b/Core/GameEngine/Include/Common/GameMemory.h @@ -45,9 +45,6 @@ #pragma once -#ifndef _GAME_MEMORY_H_ -#define _GAME_MEMORY_H_ - // Turn off memory pool checkpointing for now. #ifndef DISABLE_MEMORYPOOL_CHECKPOINTING #define DISABLE_MEMORYPOOL_CHECKPOINTING 1 @@ -65,7 +62,7 @@ // SYSTEM INCLUDES //////////////////////////////////////////////////////////// #include -#include +#include #ifdef MEMORYPOOL_OVERRIDE_MALLOC #include #endif @@ -746,8 +743,8 @@ class MemoryPoolObject virtual ~MemoryPoolObject() { } protected: - inline void *operator new(size_t s) { DEBUG_CRASH(("This should be impossible")); return 0; } - inline void operator delete(void *p) { DEBUG_CRASH(("This should be impossible")); } + void *operator new(size_t s) { DEBUG_CRASH(("This should be impossible")); return 0; } + void operator delete(void *p) { DEBUG_CRASH(("This should be impossible")); } protected: @@ -913,6 +910,3 @@ class MemoryPoolObjectHolder #define EMPTY_DTOR(CLASS) inline CLASS::~CLASS() { } - - -#endif // _GAME_MEMORY_H_ diff --git a/Core/GameEngine/Include/Common/GameMemoryNull.h b/Core/GameEngine/Include/Common/GameMemoryNull.h index bf0ee87bc3..5babbf4553 100644 --- a/Core/GameEngine/Include/Common/GameMemoryNull.h +++ b/Core/GameEngine/Include/Common/GameMemoryNull.h @@ -163,3 +163,9 @@ extern void* __cdecl operator new[](size_t size, const char *, int); extern void __cdecl operator delete[](void *p, const char *, int); #endif + +#if defined(_MSC_VER) && _MSC_VER < 1300 +// additional overloads for 'placement new' +inline void* __cdecl operator new[](size_t s, void* p) { return p; } +inline void __cdecl operator delete[](void*, void* p) {} +#endif diff --git a/Core/GameEngine/Include/Common/GameMusic.h b/Core/GameEngine/Include/Common/GameMusic.h index 1e3218d5ba..864c52f82a 100644 --- a/Core/GameEngine/Include/Common/GameMusic.h +++ b/Core/GameEngine/Include/Common/GameMusic.h @@ -41,10 +41,6 @@ #pragma once -#ifndef __COMMON_GAMEMUSIC_H_ -#define __COMMON_GAMEMUSIC_H_ - - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -114,5 +110,3 @@ class MusicManager void setVolume( Real m_volume ); }; - -#endif // __COMMON_GAMEMUSIC_H_ diff --git a/Core/GameEngine/Include/Common/GameSounds.h b/Core/GameEngine/Include/Common/GameSounds.h index 3c7867eaf4..4f3a5f955e 100644 --- a/Core/GameEngine/Include/Common/GameSounds.h +++ b/Core/GameEngine/Include/Common/GameSounds.h @@ -40,8 +40,6 @@ //---------------------------------------------------------------------------- #pragma once -#ifndef __COMMON_GAMESOUNDS_H_ -#define __COMMON_GAMESOUNDS_H_ #include "Common/SubsystemInterface.h" #include "Common/GameAudio.h" @@ -98,6 +96,3 @@ class SoundManager : public SubsystemInterface UnsignedInt m_numPlaying2DSamples; UnsignedInt m_numPlaying3DSamples; }; - -#endif // __COMMON_GAMESOUNDS_H_ - diff --git a/Core/GameEngine/Include/Common/GameUtility.h b/Core/GameEngine/Include/Common/GameUtility.h new file mode 100644 index 0000000000..86790ff484 --- /dev/null +++ b/Core/GameEngine/Include/Common/GameUtility.h @@ -0,0 +1,39 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#pragma once + +#include "Lib/BaseType.h" + +// For miscellaneous game utility functions. + +class Player; +typedef Int PlayerIndex; + +namespace rts +{ + +bool localPlayerHasRadar(); +Player* getObservedOrLocalPlayer(); ///< Get the current observed or local player. Is never null. +Player* getObservedOrLocalPlayer_Safe(); ///< Get the current observed or local player. Is never null, except when the application does not have players. +PlayerIndex getObservedOrLocalPlayerIndex_Safe(); ///< Get the current observed or local player index. Returns 0 when the application does not have players. + +void changeLocalPlayer(Player* player); //< Change local player during game. Must not pass null. +void changeObservedPlayer(Player* player); ///< Change observed player during game. Can pass null: is identical to passing the "ReplayObserver" player. + +} // namespace rts diff --git a/Core/GameEngine/Include/Common/LocalFile.h b/Core/GameEngine/Include/Common/LocalFile.h index 92a574ebb3..db9568ee0e 100644 --- a/Core/GameEngine/Include/Common/LocalFile.h +++ b/Core/GameEngine/Include/Common/LocalFile.h @@ -43,11 +43,6 @@ #pragma once -#ifndef __LOCALFILE_H -#define __LOCALFILE_H - - - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -134,6 +129,3 @@ class LocalFile : public File //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- - - -#endif // __LOCALFILE_H diff --git a/Core/GameEngine/Include/Common/LocalFileSystem.h b/Core/GameEngine/Include/Common/LocalFileSystem.h index ec9fbdc097..08f00af5d2 100644 --- a/Core/GameEngine/Include/Common/LocalFileSystem.h +++ b/Core/GameEngine/Include/Common/LocalFileSystem.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __LOCALFILESYSTEM_H -#define __LOCALFILESYSTEM_H - #include "Common/SubsystemInterface.h" #include "FileSystem.h" // for typedefs, etc. @@ -54,5 +51,3 @@ class LocalFileSystem : public SubsystemInterface }; extern LocalFileSystem *TheLocalFileSystem; - -#endif // __LOCALFILESYSTEM_H diff --git a/GeneralsMD/Code/GameEngine/Include/Common/MapObject.h b/Core/GameEngine/Include/Common/MapObject.h similarity index 99% rename from GeneralsMD/Code/GameEngine/Include/Common/MapObject.h rename to Core/GameEngine/Include/Common/MapObject.h index 64cd77ddac..1438662ecc 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/MapObject.h +++ b/Core/GameEngine/Include/Common/MapObject.h @@ -29,9 +29,6 @@ #pragma once -#ifndef MapObject_H -#define MapObject_H - #include "Common/Dict.h" #include "Common/GameMemory.h" #include "GameClient/TerrainRoads.h" @@ -183,6 +180,3 @@ class MapObject : public MemoryPoolObject static Dict* getWorldDict() { return &TheWorldDict; } static Int countMapObjectsWithOwner(const AsciiString& n); }; - -#endif - diff --git a/Core/GameEngine/Include/Common/MiniDumper.h b/Core/GameEngine/Include/Common/MiniDumper.h new file mode 100644 index 0000000000..44c03e96ef --- /dev/null +++ b/Core/GameEngine/Include/Common/MiniDumper.h @@ -0,0 +1,97 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#pragma once + +#ifdef RTS_ENABLE_CRASHDUMP +#include "DbgHelpLoader.h" + +enum DumpType CPP_11(: Char) +{ + // Smallest dump type with call stacks and some supporting variables + DumpType_Minimal = 'M', + // Largest dump size including complete memory contents of the process + DumpType_Full = 'F', +}; + +class MiniDumper +{ + enum MiniDumperExitCode CPP_11(: Int) + { + MiniDumperExitCode_Success = 0x0, + MiniDumperExitCode_FailureWait = 0x37DA1040, + MiniDumperExitCode_FailureParam = 0x4EA527BB, + MiniDumperExitCode_ForcedTerminate = 0x158B1154, + }; + +public: + MiniDumper(); + Bool IsInitialized() const; + void TriggerMiniDump(DumpType dumpType); + void TriggerMiniDumpForException(_EXCEPTION_POINTERS* e_info, DumpType dumpType); + static void initMiniDumper(const AsciiString& userDirPath); + static void shutdownMiniDumper(); + static LONG WINAPI DumpingExceptionFilter(_EXCEPTION_POINTERS* e_info); + +private: + void Initialize(const AsciiString& userDirPath); + void ShutDown(); + void CreateMiniDump(DumpType dumpType); + void CleanupResources(); + Bool IsDumpThreadStillRunning() const; + void ShutdownDumpThread(); + + // Thread procs + static DWORD WINAPI MiniDumpThreadProc(LPVOID lpParam); + DWORD ThreadProcInternal(); + + // Dump file directory bookkeeping + Bool InitializeDumpDirectory(const AsciiString& userDirPath); + static void KeepNewestFiles(const std::string& directory, const DumpType dumpType, const Int keepCount); + + // Struct to hold file information + struct FileInfo + { + std::string name; + FILETIME lastWriteTime; + }; + + static bool CompareByLastWriteTime(const FileInfo& a, const FileInfo& b); + +private: + Bool m_miniDumpInitialized; + Bool m_loadedDbgHelp; + DumpType m_requestedDumpType; + + // Path buffers + Char m_dumpDir[MAX_PATH]; + Char m_dumpFile[MAX_PATH]; + WideChar m_executablePath[MAX_PATH]; + + // Event handles + HANDLE m_dumpRequested; + HANDLE m_dumpComplete; + HANDLE m_quitting; + + // Thread handles + HANDLE m_dumpThread; + DWORD m_dumpThreadId; +}; + +extern MiniDumper* TheMiniDumper; +#endif diff --git a/Core/GameEngine/Include/Common/MiscAudio.h b/Core/GameEngine/Include/Common/MiscAudio.h index 4317916ce6..cf944fac8f 100644 --- a/Core/GameEngine/Include/Common/MiscAudio.h +++ b/Core/GameEngine/Include/Common/MiscAudio.h @@ -27,9 +27,6 @@ #pragma once -#ifndef _MISCAUDIO_H_ -#define _MISCAUDIO_H_ - #include "Common/AudioEventRTS.h" struct MiscAudio @@ -74,7 +71,3 @@ struct MiscAudio AudioEventRTS m_aircraftWheelScreech; ///< When a jet lands on a runway. AudioEventRTS m_chronoDisabledSoundLoop; ///< When a unit is being disabled/deleted by a chrono gun }; - - -#endif /* _MISCAUDIO_H_ */ - diff --git a/GeneralsMD/Code/GameEngine/Include/Common/ObjectStatusTypes.h b/Core/GameEngine/Include/Common/ObjectStatusTypes.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/Common/ObjectStatusTypes.h rename to Core/GameEngine/Include/Common/ObjectStatusTypes.h index 3ee41e52a2..affa254c9e 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/ObjectStatusTypes.h +++ b/Core/GameEngine/Include/Common/ObjectStatusTypes.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __OBJECT_STATUS_TYPES_H -#define __OBJECT_STATUS_TYPES_H - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Lib/BaseType.h" #include "Common/BitFlags.h" @@ -73,6 +70,9 @@ enum ObjectStatusTypes CPP_11(: Int) OBJECT_STATUS_NO_ATTACK_FROM_AI, ///< attacking this object may not be done from commandSource == CMD_FROM_AI OBJECT_STATUS_IGNORING_STEALTH, ///< temporarily ignoring all stealth bits. (used only for some special-case mine clearing stuff.) OBJECT_STATUS_IS_CARBOMB, ///< Object is now a carbomb. + + // TheSuperHackers @info New statuses added in Zero Hour + // Note: Loading old save games that do not track these flags in objects will not recover them. Expect logic bugs. OBJECT_STATUS_DECK_HEIGHT_OFFSET, ///< Object factors deck height on top of ground altitude. OBJECT_STATUS_RIDER1, OBJECT_STATUS_RIDER2, @@ -141,5 +141,3 @@ inline void FLIP_OBJECT_STATUS_MASK( ObjectStatusMaskType& m ) // defined in Common/System/ObjectStatusTypes.cpp extern ObjectStatusMaskType OBJECT_STATUS_MASK_NONE; // inits to all zeroes - -#endif /* __OBJECT_STATUS_TYPES_H */ diff --git a/Core/GameEngine/Include/Common/RAMFile.h b/Core/GameEngine/Include/Common/RAMFile.h index cdad7f30f1..084aa8d857 100644 --- a/Core/GameEngine/Include/Common/RAMFile.h +++ b/Core/GameEngine/Include/Common/RAMFile.h @@ -43,11 +43,6 @@ #pragma once -#ifndef __RAMFILE_H -#define __RAMFILE_H - - - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -130,6 +125,3 @@ class RAMFile : public File //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- - - -#endif // __WSYS_RAMFILE_H diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Radar.h b/Core/GameEngine/Include/Common/Radar.h similarity index 83% rename from GeneralsMD/Code/GameEngine/Include/Common/Radar.h rename to Core/GameEngine/Include/Common/Radar.h index dcb35d7809..431cfbf166 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/Radar.h +++ b/Core/GameEngine/Include/Common/Radar.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __RADAR_H_ -#define __RADAR_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Lib/BaseType.h" #include "Common/SubsystemInterface.h" @@ -76,15 +73,8 @@ enum RadarEventType CPP_11(: Int) RADAR_EVENT_FAKE, //Internally creates a radar event, but doesn't notify the player (unit lost //for example, so we can use the spacebar to jump to the event). - RADAR_EVENT_NUM_EVENTS // keep this last - -}; + RADAR_EVENT_NUM_EVENTS -enum RadarObjectType CPP_11(: Int) -{ - RadarObjectType_None = 0, - RadarObjectType_Regular, - RadarObjectType_Local, }; // PROTOTYPES ///////////////////////////////////////////////////////////////////////////////////// @@ -105,15 +95,15 @@ class RadarObject : public MemoryPoolObject, // color management void setColor( Color c ) { m_color = c; } - inline Color getColor( void ) const { return m_color; } + Color getColor( void ) const { return m_color; } - inline void friend_setObject( Object *obj ) { m_object = obj; } - inline Object *friend_getObject( void ) { return m_object; } - inline const Object *friend_getObject( void ) const { return m_object; } + void friend_setObject( Object *obj ) { m_object = obj; } + Object *friend_getObject( void ) { return m_object; } + const Object *friend_getObject( void ) const { return m_object; } - inline void friend_setNext( RadarObject *next ) { m_next = next; } - inline RadarObject *friend_getNext( void ) { return m_next; } - inline const RadarObject *friend_getNext( void ) const { return m_next; } + void friend_setNext( RadarObject *next ) { m_next = next; } + RadarObject *friend_getNext( void ) { return m_next; } + const RadarObject *friend_getNext( void ) const { return m_next; } Bool isTemporarilyHidden() const; static Bool isTemporarilyHidden(const Object* obj); @@ -142,10 +132,10 @@ enum RadarPriorityType CPP_11(: Int) RADAR_PRIORITY_UNIT, // unit level drawing priority RADAR_PRIORITY_LOCAL_UNIT_ONLY, // unit priority, but only on the radar if controlled by the local player - RADAR_PRIORITY_NUM_PRIORITIES // keep this last + RADAR_PRIORITY_NUM_PRIORITIES }; #ifdef DEFINE_RADAR_PRIORITY_NAMES -static const char *RadarPriorityNames[] = +static const char *const RadarPriorityNames[] = { "INVALID", // a priority that has not been set (in general it won't show up on the radar) "NOT_ON_RADAR", // object specifically forbidden from being on the radar @@ -153,8 +143,9 @@ static const char *RadarPriorityNames[] = "UNIT", // unit level drawing priority "LOCAL_UNIT_ONLY", // unit priority, but only on the radar if controlled by the local player - NULL // keep this last + NULL }; +static_assert(ARRAY_SIZE(RadarPriorityNames) == RADAR_PRIORITY_NUM_PRIORITIES + 1, "Incorrect array size"); #endif // DEFINE_RADAR_PRIOTITY_NAMES //------------------------------------------------------------------------------------------------- @@ -179,9 +170,9 @@ class Radar : public Snapshot, Bool radarToWorld( const ICoord2D *radar, Coord3D *world ); ///< radar point to world point on terrain Bool radarToWorld2D( const ICoord2D *radar, Coord3D *world ); ///< radar point to world point (x,y only!) Bool worldToRadar( const Coord3D *world, ICoord2D *radar ); ///< translate world point to radar (x,y) - Bool localPixelToRadar( const ICoord2D *pixel, ICoord2D *radar ); ///< translate pixel (with UL of radar being (0,0)) to logical radar coords + Bool localPixelToRadar( const ICoord2D *pixel, ICoord2D *radar ); ///< translate pixel (with UL of radar being (0,0)) to logical radar coordinates Bool screenPixelToWorld( const ICoord2D *pixel, Coord3D *world ); ///< translate pixel (with UL of the screen being (0,0)) to world position in the world - Object *objectUnderRadarPixel( const ICoord2D *pixel ); ///< return the object (if any) represented by the pixel coords passed in + Object *objectUnderRadarPixel( const ICoord2D *pixel ); ///< return the object (if any) represented by the pixel coordinates passed in void findDrawPositions( Int startX, Int startY, Int width, Int height, ICoord2D *ul, ICoord2D *lr ); ///< make translation for screen area of radar square to scaled aspect ratio preserving points inside the radar area @@ -198,23 +189,26 @@ class Radar : public Snapshot, Bool tryEvent( RadarEventType event, const Coord3D *pos ); ///< try to make a "stealth" event // adding and removing objects from the radar - virtual RadarObjectType addObject( Object *obj ); ///< add object to radar - virtual RadarObjectType removeObject( Object *obj ); ///< remove object from radar + virtual Bool addObject( Object *obj ); ///< add object to radar + virtual Bool removeObject( Object *obj ); ///< remove object from radar // radar options - void hide( Bool hide ) { m_radarHidden = hide; } ///< hide/unhide the radar - Bool isRadarHidden( void ) { return m_radarHidden; } ///< is radar hidden + void hide( Int playerIndex, Bool hide ) { m_radarHidden[playerIndex] = hide; } ///< hide/show the radar + Bool isRadarHidden( Int playerIndex ) { return m_radarHidden[playerIndex]; } ///< is radar hidden // other radar option methods here like the ability to show a certain // team, show buildings, show units at all, etc // forcing the radar on/off regardless of player situation - void forceOn( Bool force ) { m_radarForceOn = force; } ///< force the radar to be on - Bool isRadarForced( void ) { return m_radarForceOn; } ///< is radar forced on? + void forceOn( Int playerIndex, Bool force ) { m_radarForceOn[playerIndex] = force; } ///< force the radar to be on + Bool isRadarForced( Int playerIndex ) { return m_radarForceOn[playerIndex]; } ///< is radar forced on? /// refresh the water values for the radar virtual void refreshTerrain( TerrainLogic *terrain ); - /// queue a refresh of the terran at the next available time + /// refresh the radar when the state of world objects changes drastically + virtual void refreshObjects() {}; + + /// queue a refresh of the terrain at the next available time virtual void queueTerrainRefresh( void ); virtual void newMap( TerrainLogic *terrain ); ///< reset radar for new map @@ -238,27 +232,34 @@ class Radar : public Snapshot, void internalCreateEvent( const Coord3D *world, RadarEventType type, Real secondsToLive, const RGBAColorInt *color1, const RGBAColorInt *color2 ); + void deleteList( RadarObject **list ); void deleteListResources( void ); ///< delete list radar resources used Bool deleteFromList( Object *obj, RadarObject **list ); ///< try to remove object from specific list - inline Real getTerrainAverageZ() const { return m_terrainAverageZ; } - inline Real getWaterAverageZ() const { return m_waterAverageZ; } - inline const RadarObject* getObjectList() const { return m_objectList; } - inline const RadarObject* getLocalObjectList() const { return m_localObjectList; } + Real getTerrainAverageZ() const { return m_terrainAverageZ; } + Real getWaterAverageZ() const { return m_waterAverageZ; } void clearAllEvents( void ); ///< remove all radar events in progress - // search the object list for an object that maps to the given logical radar coords + // search the object list for an object that maps to the given logical radar coordinates Object *searchListForRadarLocationMatch( RadarObject *listHead, ICoord2D *radarMatch ); - Bool m_radarHidden; ///< true when radar is not visible - Bool m_radarForceOn; ///< true when radar is forced to be on + void linkRadarObject( RadarObject *newObj, RadarObject **list ); + void assignObjectColorToRadarObject( RadarObject *radarObj, Object *obj ); + + Bool m_radarHidden[MAX_PLAYER_COUNT]; ///< true when radar is not visible + Bool m_radarForceOn[MAX_PLAYER_COUNT]; ///< true when radar is forced to be on + RadarObject *m_objectList; ///< list of objects in the radar RadarObject *m_localObjectList; /** list of objects for the local player, sorted * in exactly the same priority as the regular * object list for all other objects */ -// typedef std::list HeroList; -// HeroList m_heroList; //< list of pointers to objects with radar icon representations + + // TheSuperHackers @bugfix xezon 22/11/2025 Now stores local heroes in a separate list, + // because they are treated with special icons but should otherwise work like all other + // radar objects. In retail version, the cached hero object data was able to dangle + // for a few frames and cause undefined behavior. + RadarObject *m_localHeroObjectList; ///< list of hero objects for the local player Real m_terrainAverageZ; ///< average Z for terrain samples Real m_waterAverageZ; ///< average Z for water samples @@ -309,8 +310,3 @@ class RadarDummy : public Radar virtual void clearShroud() { } virtual void setShroudLevel(Int x, Int y, CellShroudStatus setting) { } }; - -#endif // __RADAR_H_ - - - diff --git a/Core/GameEngine/Include/Common/RandomValue.h b/Core/GameEngine/Include/Common/RandomValue.h index bc174821ff..011477a337 100644 --- a/Core/GameEngine/Include/Common/RandomValue.h +++ b/Core/GameEngine/Include/Common/RandomValue.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _RANDOM_VALUE_H_ -#define _RANDOM_VALUE_H_ - #include "Lib/BaseType.h" extern void InitRandom( void ); @@ -40,5 +37,3 @@ extern UnsignedInt GetGameLogicRandomSeed( void ); ///< Get the seed (used for extern UnsignedInt GetGameLogicRandomSeedCRC( void );///< Get the seed (used for CRCs) //-------------------------------------------------------------------------------------------------------------- - -#endif // _RANDOM_VALUE_H_ diff --git a/Core/GameEngine/Include/Common/StreamingArchiveFile.h b/Core/GameEngine/Include/Common/StreamingArchiveFile.h index b1f97c0080..bf481b1978 100644 --- a/Core/GameEngine/Include/Common/StreamingArchiveFile.h +++ b/Core/GameEngine/Include/Common/StreamingArchiveFile.h @@ -43,11 +43,6 @@ #pragma once -#ifndef __STREAMINGARCHIVEFILE_H -#define __STREAMINGARCHIVEFILE_H - - - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -114,6 +109,3 @@ class StreamingArchiveFile : public RAMFile //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- - - -#endif // __STREAMINGARCHIVEFILE_H diff --git a/Core/GameEngine/Include/Common/UnicodeString.h b/Core/GameEngine/Include/Common/UnicodeString.h index 70940aca9c..ff66edfe47 100644 --- a/Core/GameEngine/Include/Common/UnicodeString.h +++ b/Core/GameEngine/Include/Common/UnicodeString.h @@ -45,12 +45,7 @@ #pragma once -#ifndef UNICODESTRING_H -#define UNICODESTRING_H - #include -#include -#include #include "Lib/BaseType.h" #include "Common/Debug.h" #include "Common/Errors.h" @@ -96,13 +91,13 @@ class UnicodeString unsigned short m_numCharsAllocated; // length of data allocated // WideChar m_stringdata[]; - inline WideChar* peek() { return (WideChar*)(this+1); } + WideChar* peek() { return (WideChar*)(this+1); } }; #ifdef RTS_DEBUG void validate() const; #else - inline void validate() const { } + void validate() const { } #endif protected: @@ -114,6 +109,10 @@ class UnicodeString public: + typedef WideChar value_type; + typedef value_type* pointer; + typedef const value_type* const_pointer; + enum { MAX_FORMAT_BUF_LEN = 2048, ///< max total len of string created by format/format_va @@ -126,7 +125,7 @@ class UnicodeString string, so we don't need to construct temporaries for such a common thing. */ - static UnicodeString TheEmptyString; + static const UnicodeString TheEmptyString; /** Default constructor -- construct a new, empty UnicodeString. @@ -142,11 +141,17 @@ class UnicodeString /** Constructor -- from a literal string. Constructs an UnicodeString with the given string. Note that a copy of the string is made; - the input ptr is not saved. Note also that this is declared - 'explicit' to avoid implicit conversions from const-WideChar-* - (e.g., as input arguments). + the input ptr is not saved. + Note that this is no longer explicit, as the conversion is almost + always wanted, anyhow. + */ + UnicodeString(const WideChar* s); + + /** + Constructs an UnicodeString with the given string and length. + The length must not be larger than the actual string length. */ - explicit UnicodeString(const WideChar* s); + UnicodeString(const WideChar* s, int len); /** Destructor. Not too exciting... clean up the works and such. @@ -200,12 +205,20 @@ class UnicodeString refcount.) */ void set(const UnicodeString& stringSrc); + /** Replace the contents of self with the given string. Note that a copy of the string is made; the input ptr is not saved. */ void set(const WideChar* s); + /** + Replace the contents of self with the given string and length. + Note that a copy of the string is made; the input ptr is not saved. + The length must not be larger than the actual string length. + */ + void set(const WideChar* s, int len); + /** replace contents of self with the given string. Note the nomenclature is translate rather than set; this is because @@ -293,6 +306,30 @@ class UnicodeString */ int compareNoCase(const WideChar* s) const; + /** + return true iff self starts with the given string. + */ + Bool startsWith(const WideChar* p) const; + Bool startsWith(const UnicodeString& stringSrc) const { return startsWith(stringSrc.str()); } + + /** + return true iff self starts with the given string. (case insensitive) + */ + Bool startsWithNoCase(const WideChar* p) const; + Bool startsWithNoCase(const UnicodeString& stringSrc) const { return startsWithNoCase(stringSrc.str()); } + + /** + return true iff self ends with the given string. + */ + Bool endsWith(const WideChar* p) const; + Bool endsWith(const UnicodeString& stringSrc) const { return endsWith(stringSrc.str()); } + + /** + return true iff self ends with the given string. (case insensitive) + */ + Bool endsWithNoCase(const WideChar* p) const; + Bool endsWithNoCase(const UnicodeString& stringSrc) const { return endsWithNoCase(stringSrc.str()); } + /** conceptually similar to strtok(): @@ -483,5 +520,3 @@ inline Bool operator>=(const UnicodeString& s1, const UnicodeString& s2) { return wcscmp(s1.str(), s2.str()) >= 0; } - -#endif // UNICODESTRING_H diff --git a/Core/GameEngine/Include/Common/Xfer.h b/Core/GameEngine/Include/Common/Xfer.h index 3f937bf11b..f9c8228800 100644 --- a/Core/GameEngine/Include/Common/Xfer.h +++ b/Core/GameEngine/Include/Common/Xfer.h @@ -39,9 +39,6 @@ #pragma once -#ifndef __XFER_H_ -#define __XFER_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Common/Science.h" #include "Common/Upgrade.h" @@ -68,7 +65,7 @@ enum XferMode CPP_11(: Int) XFER_LOAD, XFER_CRC, - NUM_XFER_TYPES // please keep this last + NUM_XFER_TYPES }; //------------------------------------------------------------------------------------------------- @@ -96,7 +93,7 @@ enum XferStatus CPP_11(: Int) XFER_ERROR_UNKNOWN, ///< unknown error (isn't that useful!) - NUM_XFER_STATUS // please keep this last + NUM_XFER_STATUS }; // ------------------------------------------------------------------------------------------------ @@ -106,7 +103,7 @@ enum XferOptions CPP_11(: UnsignedInt) XO_NONE = 0x00000000, XO_NO_POST_PROCESSING = 0x00000001, - XO_ALL = 0xFFFFFFFF // keep this last please + XO_ALL = 0xFFFFFFFF }; /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -191,6 +188,3 @@ class Xfer AsciiString m_identifier; ///< the string identifier }; - -#endif // __XFER_H_ - diff --git a/Core/GameEngine/Include/Common/XferCRC.h b/Core/GameEngine/Include/Common/XferCRC.h index 35bee5c6be..b57769e86d 100644 --- a/Core/GameEngine/Include/Common/XferCRC.h +++ b/Core/GameEngine/Include/Common/XferCRC.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __XFERCRC_H_ -#define __XFERCRC_H_ - // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// #include "Common/Xfer.h" @@ -69,6 +66,3 @@ class XferCRC : public Xfer UnsignedInt m_crc; }; - -#endif // __XFERDISKWRITE_H_ - diff --git a/Core/GameEngine/Include/Common/XferDeepCRC.h b/Core/GameEngine/Include/Common/XferDeepCRC.h index 514ea80c1d..7125d41fe0 100644 --- a/Core/GameEngine/Include/Common/XferDeepCRC.h +++ b/Core/GameEngine/Include/Common/XferDeepCRC.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __XFERDEEPCRC_H_ -#define __XFERDEEPCRC_H_ - // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// #include "Common/Xfer.h" #include "Common/XferCRC.h" @@ -64,6 +61,3 @@ class XferDeepCRC : public XferCRC FILE * m_fileFP; ///< pointer to file }; - -#endif // __XFERDEEPCRC_H_ - diff --git a/Core/GameEngine/Include/Common/XferLoad.h b/Core/GameEngine/Include/Common/XferLoad.h index 0d68e29271..4df7a5428d 100644 --- a/Core/GameEngine/Include/Common/XferLoad.h +++ b/Core/GameEngine/Include/Common/XferLoad.h @@ -29,11 +29,7 @@ #pragma once -#ifndef __XFER_LOAD_H_ -#define __XFER_LOAD_H_ - // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// -#include #include "Common/Xfer.h" // FOWARD REFERNCES /////////////////////////////////////////////////////////////////////////////// @@ -68,6 +64,3 @@ class XferLoad : public Xfer FILE * m_fileFP; ///< pointer to file }; - -#endif // __XFER_LOAD_H_ - diff --git a/Core/GameEngine/Include/Common/XferSave.h b/Core/GameEngine/Include/Common/XferSave.h index 58c3a315f4..f836910bee 100644 --- a/Core/GameEngine/Include/Common/XferSave.h +++ b/Core/GameEngine/Include/Common/XferSave.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __XFER_SAVE_H_ -#define __XFER_SAVE_H_ - // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// #include "Common/Xfer.h" @@ -73,6 +70,3 @@ class XferSave : public Xfer XferBlockData *m_blockStack; ///< stack of block data }; - -#endif // __XFER_SAVE_H_ - diff --git a/Core/GameEngine/Include/Common/crc.h b/Core/GameEngine/Include/Common/crc.h index 5f8fa51a7f..0cc7ae74ad 100644 --- a/Core/GameEngine/Include/Common/crc.h +++ b/Core/GameEngine/Include/Common/crc.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _CRC_H_ -#define _CRC_H_ - #include "Lib/BaseType.h" #ifdef RTS_DEBUG @@ -139,5 +136,3 @@ class CRC }; #endif - -#endif // _CRC_H_ diff --git a/Core/GameEngine/Include/Common/file.h b/Core/GameEngine/Include/Common/file.h index 536123db4e..80e6644591 100644 --- a/Core/GameEngine/Include/Common/file.h +++ b/Core/GameEngine/Include/Common/file.h @@ -43,11 +43,6 @@ #pragma once -#ifndef __FILE_H -#define __FILE_H - - - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -227,9 +222,3 @@ 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/Core/GameEngine/Include/Common/simpleplayer.h b/Core/GameEngine/Include/Common/simpleplayer.h index b7dec2d1d6..ff93823701 100644 --- a/Core/GameEngine/Include/Common/simpleplayer.h +++ b/Core/GameEngine/Include/Common/simpleplayer.h @@ -16,9 +16,7 @@ ** along with this program. If not, see . */ - -#ifndef SIMPLEPLAYER_H -#define SIMPLEPLAYER_H +#pragma once #include "wmsdk.h" @@ -119,5 +117,3 @@ class CSimplePlayer : public IWMReaderCallback LPWSTR m_pszUrl; }; - -#endif // SIMPLEPLAYER_H diff --git a/Core/GameEngine/Include/Common/urllaunch.h b/Core/GameEngine/Include/Common/urllaunch.h index 136b6d1412..ca23690143 100644 --- a/Core/GameEngine/Include/Common/urllaunch.h +++ b/Core/GameEngine/Include/Common/urllaunch.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ - -#ifndef URLLAUNCH_H -#define URLLAUNCH_H +#pragma once HRESULT MakeEscapedURL( LPWSTR pszInURL, LPWSTR *ppszOutURL ); HRESULT LaunchURL( LPCWSTR pszURL ); - -#endif // URLLAUNCH_H diff --git a/Core/GameEngine/Include/GameClient/ClientRandomValue.h b/Core/GameEngine/Include/GameClient/ClientRandomValue.h index 9a12e3229f..3222cf4e71 100644 --- a/Core/GameEngine/Include/GameClient/ClientRandomValue.h +++ b/Core/GameEngine/Include/GameClient/ClientRandomValue.h @@ -29,9 +29,6 @@ #pragma once -#ifndef _CLIENT_RANDOM_VALUE_H_ -#define _CLIENT_RANDOM_VALUE_H_ - #include "Lib/BaseType.h" // do NOT use these functions directly, rather use the macros below @@ -68,18 +65,19 @@ class GameClientRandomVariable */ enum DistributionType { - CONSTANT, UNIFORM, GAUSSIAN, TRIANGULAR, LOW_BIAS, HIGH_BIAS + CONSTANT, UNIFORM, GAUSSIAN, TRIANGULAR, LOW_BIAS, HIGH_BIAS, + DISTRIBUTION_COUNT }; - static const char *DistributionTypeNames[]; + static const char *const DistributionTypeNames[]; /// define the range of random values, and the distribution of values void setRange( Real low, Real high, DistributionType type = UNIFORM ); Real getValue( void ) const; ///< return a value from the random distribution - inline Real getMinimumValue( void ) const { return m_low; } - inline Real getMaximumValue( void ) const { return m_high; } - inline DistributionType getDistributionType( void ) const { return m_type; } + Real getMinimumValue( void ) const { return m_low; } + Real getMaximumValue( void ) const { return m_high; } + DistributionType getDistributionType( void ) const { return m_type; } protected: DistributionType m_type; ///< the kind of random distribution Real m_low, m_high; ///< the range of random values @@ -91,5 +89,3 @@ class GameClientRandomVariable }; //-------------------------------------------------------------------------------------------------------------- - -#endif // _CLIENT_RANDOM_VALUE_H_ diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/MapUtil.h b/Core/GameEngine/Include/GameClient/MapUtil.h similarity index 75% rename from GeneralsMD/Code/GameEngine/Include/GameClient/MapUtil.h rename to Core/GameEngine/Include/GameClient/MapUtil.h index 0561d84f77..408333c479 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/MapUtil.h +++ b/Core/GameEngine/Include/GameClient/MapUtil.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __MAPUTIL_H__ -#define __MAPUTIL_H__ - #include "Common/AsciiString.h" #include "Common/UnicodeString.h" @@ -78,9 +75,10 @@ class MapMetaData AsciiString m_nameLookupTag; Region3D m_extent; Int m_numPlayers; - Bool m_isMultiplayer; + Bool m_isMultiplayer; Bool m_isOfficial; + Bool m_doesExist; ///< Flag to indicate whether the map physically exists. Should be true. UnsignedInt m_filesize; UnsignedInt m_CRC; @@ -92,10 +90,20 @@ class MapMetaData AsciiString m_fileName; }; +// TheSuperHackers @performance xezon 02/11/2025 Simplifies and improves the implementation of MapCache +// to prevent expensive reoccurring redundant map cache reads. + class MapCache : public std::map { + typedef std::set MapNameSet; + public: - MapCache() {} + MapCache() + : m_doCreateStandardMapCacheINI(TRUE) + , m_doLoadStandardMapCacheINI(TRUE) + , m_doLoadUserMapCacheINI(TRUE) + {} + void updateCache( void ); AsciiString getMapDir() const; @@ -108,22 +116,27 @@ class MapCache : public std::map void addShippingMap(AsciiString mapName) { mapName.toLower(); m_allowedMaps.insert(mapName); } private: - Bool clearUnseenMaps( AsciiString dirName ); - void loadStandardMaps(void); - Bool loadUserMaps(void); // returns true if we needed to (re)parse a map -// Bool addMap( AsciiString dirName, AsciiString fname, WinTimeStamp timestamp, -// UnsignedInt filesize, Bool isOfficial ); ///< returns true if it had to (re)parse the map - Bool addMap( AsciiString dirName, AsciiString fname, FileInfo *fileInfo, Bool isOfficial); ///< returns true if it had to (re)parse the map - void writeCacheINI( Bool userDir ); - - static const char * m_mapCacheName; - std::map m_seen; - - std::set m_allowedMaps; + void prepareUnseenMaps(const AsciiString &mapDir); + Bool clearUnseenMaps(const AsciiString &mapDir); + void loadMapsFromMapCacheINI(const AsciiString &mapDir); + Bool loadMapsFromDisk(const AsciiString &mapDir, Bool isOfficial, Bool filterByAllowedMaps = FALSE); // returns true if we needed to (re)parse a map + Bool addMap(const AsciiString &mapDir, const AsciiString &fname, const AsciiString &lowerFname, FileInfo &fileInfo, Bool isOfficial); ///< returns true if it had to (re)parse the map + void writeCacheINI(const AsciiString &mapDir); + + static const char *const m_mapCacheName; + + MapNameSet m_allowedMaps; + Bool m_doCreateStandardMapCacheINI; + Bool m_doLoadStandardMapCacheINI; + Bool m_doLoadUserMapCacheINI; }; extern MapCache *TheMapCache; extern TechAndSupplyImages TheSupplyAndTechImageLocations; + +// TheSuperHackers @refactor xezon 28/11/2025 Refactors the map list population implementation +// by breaking it into smaller pieces to make it more maintainable. + Int populateMapListbox( GameWindow *listbox, Bool useSystemMaps, Bool isMultiplayer, AsciiString mapToSelect = AsciiString::TheEmptyString ); /// Read a list of maps from the run directory and fill in the listbox. Return the selected index Int populateMapListboxNoReset( GameWindow *listbox, Bool useSystemMaps, Bool isMultiplayer, AsciiString mapToSelect = AsciiString::TheEmptyString ); /// Read a list of maps from the run directory and fill in the listbox. Return the selected index Bool isValidMap( AsciiString mapName, Bool isMultiplayer ); /// Validate a map @@ -135,4 +148,3 @@ Bool parseMapPreviewChunk(DataChunkInput &file, DataChunkInfo *info, void *userD void findDrawPositions( Int startX, Int startY, Int width, Int height, Region3D extent, ICoord2D *ul, ICoord2D *lr ); Bool WouldMapTransfer( const AsciiString& mapName ); -#endif // __MAPUTIL_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ParabolicEase.h b/Core/GameEngine/Include/GameClient/ParabolicEase.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/GameClient/ParabolicEase.h rename to Core/GameEngine/Include/GameClient/ParabolicEase.h index ef13c49a50..3334def572 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/ParabolicEase.h +++ b/Core/GameEngine/Include/GameClient/ParabolicEase.h @@ -23,9 +23,9 @@ // Ease in and out based on a parabolic function. // Author: Robert Minsk May 12, 2003 // ============================================================================ + #pragma once -#ifndef _PARABOLICEASE_H -#define _PARABOLICEASE_H + // ============================================================================ #include "Lib/BaseType.h" // ============================================================================ @@ -89,4 +89,3 @@ class ParabolicEase }; // ============================================================================ -#endif // _PARABOLICEASE_H diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/Smudge.h b/Core/GameEngine/Include/GameClient/Smudge.h similarity index 89% rename from GeneralsMD/Code/GameEngine/Include/GameClient/Smudge.h rename to Core/GameEngine/Include/GameClient/Smudge.h index 59e5e28878..657736d1f2 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/Smudge.h +++ b/Core/GameEngine/Include/GameClient/Smudge.h @@ -20,9 +20,6 @@ #pragma once -#ifndef _SMUDGE_H_ -#define _SMUDGE_H_ - #include "WW3D2/dllist.h" #include "WWMath/vector2.h" #include "WWMath/vector3.h" @@ -81,9 +78,9 @@ class SmudgeManager SmudgeSet *addSmudgeSet(void); void removeSmudgeSet(SmudgeSet &mySmudge); - inline Int getSmudgeCountLastFrame(void) {return m_smudgeCountLastFrame;} /// TheWaterTransparency; - -#endif // __WATER_H_ - diff --git a/Core/GameEngine/Include/GameClient/WindowVideoManager.h b/Core/GameEngine/Include/GameClient/WindowVideoManager.h index 12ff91f48b..ab0346b3e4 100644 --- a/Core/GameEngine/Include/GameClient/WindowVideoManager.h +++ b/Core/GameEngine/Include/GameClient/WindowVideoManager.h @@ -45,9 +45,6 @@ #pragma once -#ifndef __WINDOWVIDEOMANAGER_H_ -#define __WINDOWVIDEOMANAGER_H_ - //----------------------------------------------------------------------------- // SYSTEM INCLUDES //////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -183,5 +180,3 @@ inline void WindowVideo::setPlayType(WindowVideoPlayType playType){ m_playType = //----------------------------------------------------------------------------- // EXTERNALS ////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- - -#endif // __WINDOWVIDEOMANAGER_H_ diff --git a/Core/GameEngine/Include/GameLogic/LogicRandomValue.h b/Core/GameEngine/Include/GameLogic/LogicRandomValue.h index e11bd811d3..0bc26ef7d1 100644 --- a/Core/GameEngine/Include/GameLogic/LogicRandomValue.h +++ b/Core/GameEngine/Include/GameLogic/LogicRandomValue.h @@ -29,9 +29,6 @@ #pragma once -#ifndef _LOGIC_RANDOM_VALUE_H_ -#define _LOGIC_RANDOM_VALUE_H_ - #include "Lib/BaseType.h" // do NOT use these functions directly, rather use the macros below @@ -68,18 +65,19 @@ class GameLogicRandomVariable */ enum DistributionType { - CONSTANT, UNIFORM, GAUSSIAN, TRIANGULAR, LOW_BIAS, HIGH_BIAS + CONSTANT, UNIFORM, GAUSSIAN, TRIANGULAR, LOW_BIAS, HIGH_BIAS, + DISTRIBUTION_COUNT }; - static const char *DistributionTypeNames[]; + static const char *const DistributionTypeNames[]; /// define the range of random values, and the distribution of values void setRange( Real low, Real high, DistributionType type = UNIFORM ); Real getValue( void ) const; ///< return a value from the random distribution - inline Real getMinimumValue( void ) const { return m_low; } - inline Real getMaximumValue( void ) const { return m_high; } - inline DistributionType getDistributionType( void ) const { return m_type; } + Real getMinimumValue( void ) const { return m_low; } + Real getMaximumValue( void ) const { return m_high; } + DistributionType getDistributionType( void ) const { return m_type; } protected: DistributionType m_type; ///< the kind of random distribution Real m_low, m_high; ///< the range of random values @@ -91,5 +89,3 @@ class GameLogicRandomVariable }; //-------------------------------------------------------------------------------------------------------------- - -#endif // _LOGIC_RANDOM_VALUE_H_ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/Connection.h b/Core/GameEngine/Include/GameNetwork/Connection.h similarity index 98% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/Connection.h rename to Core/GameEngine/Include/GameNetwork/Connection.h index 82d3a83250..660a3dcfbb 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/Connection.h +++ b/Core/GameEngine/Include/GameNetwork/Connection.h @@ -35,9 +35,6 @@ #pragma once -#ifndef __CONNECTION_H -#define __CONNECTION_H - #include "GameNetwork/NetCommandList.h" #include "GameNetwork/User.h" #include "GameNetwork/Transport.h" @@ -102,5 +99,3 @@ class Connection : public MemoryPoolObject Int m_numRetries; ///< The number of retries for the last second. time_t m_retryMetricsTime; ///< The start time of the current retry metrics thing. }; - -#endif diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/ConnectionManager.h b/Core/GameEngine/Include/GameNetwork/ConnectionManager.h similarity index 98% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/ConnectionManager.h rename to Core/GameEngine/Include/GameNetwork/ConnectionManager.h index 0a9629f59c..98b98fe36e 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/ConnectionManager.h +++ b/Core/GameEngine/Include/GameNetwork/ConnectionManager.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __CONNECTIONMANAGER_H -#define __CONNECTIONMANAGER_H - #include "GameNetwork/Connection.h" #include "GameNetwork/NetCommandList.h" #include "GameNetwork/Transport.h" @@ -174,7 +171,7 @@ class ConnectionManager // void doPerFrameMetrics(UnsignedInt frame); void getMinimumFps(Int &minFps, Int &minFpsPlayer); ///< Returns the smallest FPS in the m_fpsAverages list. - Real getMaximumLatency(); ///< This actually sums the two biggest latencies in the m_latencyAverages list. + Real getMaximumLatency(); ///< Returns the highest average latency between players. void requestFrameDataResend(Int playerID, UnsignedInt frame); ///< request of this player that he send the specified frame's data. @@ -217,5 +214,3 @@ class ConnectionManager FileProgressMap s_fileProgressMap[MAX_SLOTS]; // ----------------------------------------------------------------------------- }; - -#endif diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/DisconnectManager.h b/Core/GameEngine/Include/GameNetwork/DisconnectManager.h similarity index 98% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/DisconnectManager.h rename to Core/GameEngine/Include/GameNetwork/DisconnectManager.h index 08c98da11e..cfc1fb952e 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/DisconnectManager.h +++ b/Core/GameEngine/Include/GameNetwork/DisconnectManager.h @@ -22,12 +22,8 @@ // // //////////////////////////////////////////////////////////////////////////////// - #pragma once -#ifndef __DISCONNECTMANAGER_H -#define __DISCONNECTMANAGER_H - #include "GameNetwork/NetCommandRef.h" #include "Lib/BaseType.h" //#include "GameNetwork/ConnectionManager.h" @@ -127,6 +123,3 @@ class DisconnectManager Int m_pingsRecieved; UnsignedInt m_pingFrame; }; - - -#endif // #ifndef __DISCONNECTMANAGER_H diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/DownloadManager.h b/Core/GameEngine/Include/GameNetwork/DownloadManager.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/DownloadManager.h rename to Core/GameEngine/Include/GameNetwork/DownloadManager.h index 8f88e247d4..c4a52edf47 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/DownloadManager.h +++ b/Core/GameEngine/Include/GameNetwork/DownloadManager.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __DOWNLOADMANAGER_H__ -#define __DOWNLOADMANAGER_H__ - #include "WWDownload/downloaddefs.h" #include "WWDownload/Download.h" @@ -94,5 +91,3 @@ class DownloadManager : public IDownload }; extern DownloadManager *TheDownloadManager; - -#endif // __DOWNLOADMANAGER_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/FileTransfer.h b/Core/GameEngine/Include/GameNetwork/FileTransfer.h similarity index 95% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/FileTransfer.h rename to Core/GameEngine/Include/GameNetwork/FileTransfer.h index edca97bae4..474599405f 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/FileTransfer.h +++ b/Core/GameEngine/Include/GameNetwork/FileTransfer.h @@ -29,8 +29,6 @@ /////////////////////////////////////////////////////////////////////////////////////// #pragma once -#ifndef __FILE_TRANSFER_H__ -#define __FILE_TRANSFER_H__ class GameInfo; @@ -48,5 +46,3 @@ AsciiString GetReadmeFromMap( AsciiString path ); // The meat of file (map) transfers Bool DoAnyMapTransfers(GameInfo *game); - -#endif // __FILE_TRANSFER_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/FirewallHelper.h b/Core/GameEngine/Include/GameNetwork/FirewallHelper.h similarity index 96% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/FirewallHelper.h rename to Core/GameEngine/Include/GameNetwork/FirewallHelper.h index d249d20ab3..3a472abcf1 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/FirewallHelper.h +++ b/Core/GameEngine/Include/GameNetwork/FirewallHelper.h @@ -29,7 +29,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /RedAlert2/NAT.CPP $* + * $Archive:: /RedAlert2/NAT.cpp $* * * * $Author:: Steve_t $* * * @@ -48,9 +48,6 @@ #pragma once -#ifndef __FIREWALLHELPER_H -#define __FIREWALLHELPER_H - class UDP; #define NUM_TEST_PORTS 4 @@ -214,28 +211,28 @@ class FirewallHelperClass { /* ** Behavior query functions. */ - inline Bool isNAT(void) { + Bool isNAT(void) { if (m_behavior == FIREWALL_TYPE_UNKNOWN || (m_behavior & FIREWALL_TYPE_SIMPLE) != 0) { return(FALSE); } return(TRUE); }; - inline Bool isNAT(FirewallBehaviorType behavior) { + Bool isNAT(FirewallBehaviorType behavior) { if (behavior == FIREWALL_TYPE_UNKNOWN || (behavior & FIREWALL_TYPE_SIMPLE) != 0) { return(FALSE); } return(TRUE); }; - inline Bool isNetgear(FirewallBehaviorType behavior) { + Bool isNetgear(FirewallBehaviorType behavior) { if ((behavior & FIREWALL_TYPE_NETGEAR_BUG) != 0) { return(TRUE); } return(FALSE); }; - inline Bool isNetgear(void) { + Bool isNetgear(void) { if ((m_behavior & FIREWALL_TYPE_NETGEAR_BUG) != 0) { return(TRUE); } @@ -308,7 +305,3 @@ class FirewallHelperClass { extern FirewallHelperClass *TheFirewallHelper; FirewallHelperClass * createFirewallHelper(); - - -#endif // __FIREWALLHELPER_H - diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/FrameData.h b/Core/GameEngine/Include/GameNetwork/FrameData.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/FrameData.h rename to Core/GameEngine/Include/GameNetwork/FrameData.h index cfbb977659..aa0427967e 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/FrameData.h +++ b/Core/GameEngine/Include/GameNetwork/FrameData.h @@ -22,12 +22,8 @@ // // //////////////////////////////////////////////////////////////////////////////// - #pragma once -#ifndef __FRAMEDATA_H -#define __FRAMEDATA_H - #include "Lib/BaseType.h" #include "GameNetwork/NetCommandList.h" @@ -65,5 +61,3 @@ class FrameData { UnsignedInt m_lastFailedCC; UnsignedInt m_lastFailedFrameCC; }; - -#endif diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/FrameDataManager.h b/Core/GameEngine/Include/GameNetwork/FrameDataManager.h similarity index 96% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/FrameDataManager.h rename to Core/GameEngine/Include/GameNetwork/FrameDataManager.h index 421e493d55..1ad6055da0 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/FrameDataManager.h +++ b/Core/GameEngine/Include/GameNetwork/FrameDataManager.h @@ -22,12 +22,8 @@ // // //////////////////////////////////////////////////////////////////////////////// - #pragma once -#ifndef __FRAMEDATAMANAGER_H -#define __FRAMEDATAMANAGER_H - #include "GameNetwork/NetworkDefs.h" #include "GameNetwork/FrameData.h" @@ -63,5 +59,3 @@ class FrameDataManager : public MemoryPoolObject Bool m_isQuitting; UnsignedInt m_quitFrame; }; - -#endif diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/FrameMetrics.h b/Core/GameEngine/Include/GameNetwork/FrameMetrics.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/FrameMetrics.h rename to Core/GameEngine/Include/GameNetwork/FrameMetrics.h index c13ac38d0e..4a77c0f09d 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/FrameMetrics.h +++ b/Core/GameEngine/Include/GameNetwork/FrameMetrics.h @@ -26,9 +26,6 @@ #pragma once -#ifndef __FRAMEMETRICS_H -#define __FRAMEMETRICS_H - #include "Lib/BaseType.h" #include "GameNetwork/NetworkDefs.h" @@ -70,5 +67,3 @@ class FrameMetrics { UnsignedInt m_cushionIndex; ///< The next index to use for the cushion list. Int m_minimumCushion; ///< The average cushion for the history. }; - -#endif // __FRAMEMETRICS_H diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameInfo.h b/Core/GameEngine/Include/GameNetwork/GameInfo.h similarity index 92% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameInfo.h rename to Core/GameEngine/Include/GameNetwork/GameInfo.h index 5fb3320de7..79831cd16f 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameInfo.h +++ b/Core/GameEngine/Include/GameNetwork/GameInfo.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __GAMEINFO_H__ -#define __GAMEINFO_H__ - #include "Common/Snapshot.h" #include "Common/Money.h" #include "GameNetwork/NetworkDefs.h" @@ -91,22 +88,22 @@ class GameSlot void setTeamNumber( Int teamNumber ) { m_teamNumber = teamNumber; } Int getTeamNumber( void ) const { return m_teamNumber; } - inline void setName( UnicodeString name ) { m_name = name; } - inline UnicodeString getName( void ) const { return m_name; } + void setName( UnicodeString name ) { m_name = name; } + UnicodeString getName( void ) const { return m_name; } - inline void setIP( UnsignedInt IP ) { m_IP = IP; } - inline UnsignedInt getIP( void ) const { return m_IP; } + void setIP( UnsignedInt IP ) { m_IP = IP; } + UnsignedInt getIP( void ) const { return m_IP; } - inline void setPort( UnsignedShort port ) { m_port = port; } - inline UnsignedShort getPort( void ) const { return m_port; } + void setPort( UnsignedShort port ) { m_port = port; } + UnsignedShort getPort( void ) const { return m_port; } - inline void setNATBehavior( FirewallHelperClass::FirewallBehaviorType NATBehavior) { m_NATBehavior = NATBehavior; } - inline FirewallHelperClass::FirewallBehaviorType getNATBehavior() const { return m_NATBehavior; } + void setNATBehavior( FirewallHelperClass::FirewallBehaviorType NATBehavior) { m_NATBehavior = NATBehavior; } + FirewallHelperClass::FirewallBehaviorType getNATBehavior() const { return m_NATBehavior; } void saveOffOriginalInfo( void ); - inline Int getOriginalPlayerTemplate( void ) const { return m_origPlayerTemplate; } - inline Int getOriginalColor( void ) const { return m_origColor; } - inline Int getOriginalStartPos( void ) const { return m_origStartPos; } + Int getOriginalPlayerTemplate( void ) const { return m_origPlayerTemplate; } + Int getOriginalColor( void ) const { return m_origColor; } + Int getOriginalStartPos( void ) const { return m_origStartPos; } Int getApparentPlayerTemplate( void ) const; Int getApparentColor( void ) const; Int getApparentStartPos( void ) const; @@ -218,7 +215,7 @@ class GameInfo // CRC checking hack void setCRCInterval( Int val ) { m_crcInterval = (val<100)?val:100; } - inline Int getCRCInterval( void ) const { return m_crcInterval; } + Int getCRCInterval( void ) const { return m_crcInterval; } Bool haveWeSurrendered(void) { return m_surrendered; } void markAsSurrendered(void) { m_surrendered = TRUE; } @@ -306,5 +303,3 @@ class SkirmishGameInfo : public GameInfo, public Snapshot extern SkirmishGameInfo *TheSkirmishGameInfo; extern SkirmishGameInfo *TheChallengeGameInfo; - -#endif // __GAMEINFO_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameMessageParser.h b/Core/GameEngine/Include/GameNetwork/GameMessageParser.h similarity index 99% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameMessageParser.h rename to Core/GameEngine/Include/GameNetwork/GameMessageParser.h index 75dbfcf29f..e9b5af774e 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameMessageParser.h +++ b/Core/GameEngine/Include/GameNetwork/GameMessageParser.h @@ -22,7 +22,6 @@ // // //////////////////////////////////////////////////////////////////////////////// - #pragma once #include "Common/MessageStream.h" diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/BuddyDefs.h b/Core/GameEngine/Include/GameNetwork/GameSpy/BuddyDefs.h similarity index 94% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/BuddyDefs.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/BuddyDefs.h index 2d032020f8..b6522cba40 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/BuddyDefs.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/BuddyDefs.h @@ -28,10 +28,5 @@ #pragma once -#ifndef __BUDDYDEFS_H__ -#define __BUDDYDEFS_H__ - void HandleBuddyResponses(void); void PopulateOldBuddyMessages(void); - -#endif // __BUDDYDEFS_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/BuddyThread.h b/Core/GameEngine/Include/GameNetwork/GameSpy/BuddyThread.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/BuddyThread.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/BuddyThread.h index 8b94bd9bfe..de175b0e84 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/BuddyThread.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/BuddyThread.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __BUDDYTHREAD_H__ -#define __BUDDYTHREAD_H__ - #include "gamespy/gp/gp.h" #define MAX_BUDDY_CHAT_LEN 128 @@ -53,7 +50,6 @@ class BuddyRequest BUDDYREQUEST_DENYADD, // don't allow someone to add you to their buddy list BUDDYREQUEST_SETSTATUS, // Set our status BUDDYREQUEST_DELETEACCT, // Delete our account - BUDDYREQUEST_MAX } buddyRequestType; union @@ -106,7 +102,6 @@ class BuddyResponse BUDDYRESPONSE_MESSAGE, BUDDYRESPONSE_REQUEST, BUDDYRESPONSE_STATUS, - BUDDYRESPONSE_MAX } buddyResponseType; GPProfile profile; @@ -174,6 +169,3 @@ class GameSpyBuddyMessageQueueInterface }; extern GameSpyBuddyMessageQueueInterface *TheGameSpyBuddyMessageQueue; - - -#endif // __BUDDYTHREAD_H__ diff --git a/Generals/Code/GameEngine/Include/GameNetwork/GameSpy/GSConfig.h b/Core/GameEngine/Include/GameNetwork/GameSpy/GSConfig.h similarity index 95% rename from Generals/Code/GameEngine/Include/GameNetwork/GameSpy/GSConfig.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/GSConfig.h index 561c2f232a..8645d8b445 100644 --- a/Generals/Code/GameEngine/Include/GameNetwork/GameSpy/GSConfig.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/GSConfig.h @@ -1,5 +1,5 @@ /* -** Command & Conquer Generals(tm) +** Command & Conquer Generals Zero Hour(tm) ** Copyright 2025 Electronic Arts Inc. ** ** This program is free software: you can redistribute it and/or modify @@ -29,9 +29,6 @@ #pragma once -#ifndef __GSCONFIG_H__ -#define __GSCONFIG_H__ - #include "Common/AsciiString.h" #include "Common/STLTypedefs.h" @@ -78,5 +75,3 @@ class GameSpyConfigInterface }; extern GameSpyConfigInterface *TheGameSpyConfig; - -#endif // __GSCONFIG_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/GameResultsThread.h b/Core/GameEngine/Include/GameNetwork/GameSpy/GameResultsThread.h similarity index 96% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/GameResultsThread.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/GameResultsThread.h index 76c9167585..d437f58ce5 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/GameResultsThread.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/GameResultsThread.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __GAMERESULTSTHREAD_H__ -#define __GAMERESULTSTHREAD_H__ - #include "Common/SubsystemInterface.h" // this class encapsulates a request for the thread @@ -76,6 +73,3 @@ class GameResultsInterface : public SubsystemInterface }; extern GameResultsInterface *TheGameResultsQueue; - - -#endif // __GAMERESULTSTHREAD_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/LadderDefs.h b/Core/GameEngine/Include/GameNetwork/GameSpy/LadderDefs.h similarity index 96% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/LadderDefs.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/LadderDefs.h index 25d8098c2e..e59aebbd5d 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/LadderDefs.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/LadderDefs.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __LADDERDEFS_H__ -#define __LADDERDEFS_H__ - #include "Common/UnicodeString.h" #include "Common/AsciiString.h" #include "Common/STLTypedefs.h" @@ -84,5 +81,3 @@ class LadderList }; extern LadderList *TheLadderList; - -#endif // __LADDERDEFS_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/LobbyUtils.h b/Core/GameEngine/Include/GameNetwork/GameSpy/LobbyUtils.h similarity index 95% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/LobbyUtils.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/LobbyUtils.h index 678a15fe20..d881d474e4 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/LobbyUtils.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/LobbyUtils.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __LOBBYUTILS_H__ -#define __LOBBYUTILS_H__ - class GameWindow; GameWindow *GetGameListBox( void ); @@ -52,10 +49,7 @@ enum GameSortType CPP_11(: Int) GAMESORT_ALPHA_DESCENDING, GAMESORT_PING_ASCENDING, GAMESORT_PING_DESCENDING, - GAMESORT_MAX, }; Bool HandleSortButton( NameKeyType sortButton ); void PopulateLobbyPlayerListbox(void); - -#endif // __LOBBYUTILS_H__ diff --git a/Generals/Code/GameEngine/Include/GameNetwork/GameSpy/MainMenuUtils.h b/Core/GameEngine/Include/GameNetwork/GameSpy/MainMenuUtils.h similarity index 92% rename from Generals/Code/GameEngine/Include/GameNetwork/GameSpy/MainMenuUtils.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/MainMenuUtils.h index db8f31f05f..9aab07f760 100644 --- a/Generals/Code/GameEngine/Include/GameNetwork/GameSpy/MainMenuUtils.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/MainMenuUtils.h @@ -1,5 +1,5 @@ /* -** Command & Conquer Generals(tm) +** Command & Conquer Generals Zero Hour(tm) ** Copyright 2025 Electronic Arts Inc. ** ** This program is free software: you can redistribute it and/or modify @@ -29,9 +29,6 @@ #pragma once -#ifndef __MAINMENUUTILS_H__ -#define __MAINMENUUTILS_H__ - void HTTPThinkWrapper( void ); void StopAsyncDNSCheck( void ); void StartPatchCheck( void ); @@ -39,6 +36,7 @@ void CancelPatchCheckCallback( void ); void StartDownloadingPatches( void ); void HandleCanceledDownload( Bool resetDropDown = TRUE ); +#if RTS_GENERALS enum OverallStatsPeriod CPP_11(: Int) { STATS_TODAY = 0, @@ -54,11 +52,14 @@ struct OverallStats Int wins[STATS_MAX]; Int losses[STATS_MAX]; }; +#endif void CheckOverallStats( void ); +#if RTS_GENERALS void HandleOverallStats( const OverallStats& USA, const OverallStats& China, const OverallStats& GLA ); +#else +void HandleOverallStats( const char* szHTTPStats, unsigned len ); +#endif void CheckNumPlayersOnline( void ); void HandleNumPlayersOnline( Int numPlayersOnline ); - -#endif // __MAINMENUUTILS_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PeerDefs.h b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerDefs.h similarity index 99% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PeerDefs.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/PeerDefs.h index 2f1c2d6f0a..41332be23a 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PeerDefs.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerDefs.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __PEERDEFS_H__ -#define __PEERDEFS_H__ - #include "gamespy/peer/peer.h" #include "gamespy/gp/gp.h" @@ -168,7 +165,6 @@ enum GameSpyBuddyStatus CPP_11(: Int) { BUDDY_LOADING, BUDDY_PLAYING, BUDDY_MATCHING, - BUDDY_MAX }; // --------------------------------------------------- @@ -299,5 +295,3 @@ extern Int GetAdditionalDisconnectsFromUserFile(Int playerID); void SetUpGameSpy( const char *motdBuffer, const char *configBuffer ); void TearDownGameSpy( void ); - -#endif // __PEERDEFS_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PeerDefsImplementation.h b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerDefsImplementation.h similarity index 98% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PeerDefsImplementation.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/PeerDefsImplementation.h index e26f265f92..470879d939 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PeerDefsImplementation.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerDefsImplementation.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __PEERDEFSIMPLEMENTATION_H__ -#define __PEERDEFSIMPLEMENTATION_H__ - #include "GameNetwork/GameSpy/PeerDefs.h" #include "GameNetwork/GameSpy/PersistentStorageThread.h" @@ -178,5 +175,3 @@ class GameSpyInfo : public GameSpyInfoInterface std::set m_preorderPlayers; Int m_additionalDisconnects; }; - -#endif // __PEERDEFS_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h similarity index 98% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h index bbc5c5b7e8..5178e7d36b 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __PEERTHREAD_H__ -#define __PEERTHREAD_H__ - #include "gamespy/peer/peer.h" #include "GameNetwork/NetworkDefs.h" @@ -197,7 +194,6 @@ enum DisconnectReason CPP_11(: Int) DISCONNECT_GP_NEWUSER_BAD_PASSWORD, DISCONNECT_GP_NEWPROFILE_BAD_NICK, DISCONNECT_GP_NEWPROFILE_BAD_OLD_NICK, - DISCONNECT_MAX, }; enum QMStatus CPP_11(: Int) @@ -388,5 +384,3 @@ class GameSpyPeerMessageQueueInterface }; extern GameSpyPeerMessageQueueInterface *TheGameSpyPeerMessageQueue; - -#endif // __PEERTHREAD_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PersistentStorageDefs.h b/Core/GameEngine/Include/GameNetwork/GameSpy/PersistentStorageDefs.h similarity index 93% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PersistentStorageDefs.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/PersistentStorageDefs.h index e63547b00b..f039a0b2ab 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PersistentStorageDefs.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/PersistentStorageDefs.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __PERSISTENTSTORAGEDEFS_H__ -#define __PERSISTENTSTORAGEDEFS_H__ - enum LocaleType CPP_11(: Int) { LOC_UNKNOWN = 0, @@ -43,5 +40,3 @@ void UpdateLocalPlayerStats(void); void SetLookAtPlayer( Int id, AsciiString nick ); void PopulatePlayerInfoWindows( AsciiString parentWindowName ); - -#endif // __PERSISTENTSTORAGEDEFS_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PersistentStorageThread.h b/Core/GameEngine/Include/GameNetwork/GameSpy/PersistentStorageThread.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PersistentStorageThread.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/PersistentStorageThread.h index 56bbdfe408..d2fa080cd4 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PersistentStorageThread.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/PersistentStorageThread.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __PERSISTENTSTORAGETHREAD_H__ -#define __PERSISTENTSTORAGETHREAD_H__ - #include "gamespy/gstats/gpersist.h" #define MAX_BUDDY_CHAT_LEN 128 @@ -182,6 +179,3 @@ class GameSpyPSMessageQueueInterface }; extern GameSpyPSMessageQueueInterface *TheGameSpyPSMessageQueue; - - -#endif // __PERSISTENTSTORAGETHREAD_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PingThread.h b/Core/GameEngine/Include/GameNetwork/GameSpy/PingThread.h similarity index 96% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PingThread.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/PingThread.h index 4661de891b..df2f7f35c1 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/PingThread.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/PingThread.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __PINGTHREAD_H__ -#define __PINGTHREAD_H__ - // this class encapsulates a request for the thread class PingRequest { @@ -78,6 +75,3 @@ class PingerInterface }; extern PingerInterface *ThePinger; - - -#endif // __PINGTHREAD_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/StagingRoomGameInfo.h b/Core/GameEngine/Include/GameNetwork/GameSpy/StagingRoomGameInfo.h similarity index 66% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/StagingRoomGameInfo.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/StagingRoomGameInfo.h index 650cd03505..a2b298ae47 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/StagingRoomGameInfo.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/StagingRoomGameInfo.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __STAGINGROOMGAMEINFO_H__ -#define __STAGINGROOMGAMEINFO_H__ - #include "GameNetwork/GameInfo.h" #include "GameNetwork/Transport.h" @@ -55,8 +52,8 @@ class GameSpyGameSlot : public GameSlot void setFavoriteSide( Int val ) { m_favoriteSide = val; } void setPingString( AsciiString pingStr ); - inline AsciiString getPingString( void ) const { return m_pingStr; } - inline Int getPingAsInt( void ) const { return m_pingInt; } + AsciiString getPingString( void ) const { return m_pingStr; } + Int getPingAsInt( void ) const { return m_pingInt; } protected: Int m_profileID; @@ -102,37 +99,37 @@ class GameSpyStagingRoom : public GameInfo virtual void reset( void ); void cleanUpSlotPointers(void); - inline void setID(Int id) { m_id = id; } - inline Int getID( void ) const { return m_id; } - - inline void setHasPassword(Bool val) { m_requiresPassword = val; } - inline Bool getHasPassword(void) const { return m_requiresPassword; } - inline void setAllowObservers(Bool val) { m_allowObservers = val; } - inline Bool getAllowObservers(void) const { return m_allowObservers; } - - inline void setVersion(UnsignedInt val) { m_version = val; } - inline UnsignedInt getVersion(void) const { return m_version; } - inline void setExeCRC(UnsignedInt val) { m_exeCRC = val; } - inline UnsignedInt getExeCRC(void) const { return m_exeCRC; } - inline void setIniCRC(UnsignedInt val) { m_iniCRC = val; } - inline UnsignedInt getIniCRC(void) const { return m_iniCRC; } - - inline void setReportedNumPlayers(Int val) { m_reportedNumPlayers = val; } - inline Int getReportedNumPlayers(void) const { return m_reportedNumPlayers; } - - inline void setReportedMaxPlayers(Int val) { m_reportedMaxPlayers = val; } - inline Int getReportedMaxPlayers(void) const { return m_reportedMaxPlayers; } - - inline void setReportedNumObservers(Int val) { m_reportedNumObservers = val; } - inline Int getReportedNumObservers(void) const { return m_reportedNumObservers; } - - inline void setLadderIP( AsciiString ladderIP ) { m_ladderIP = ladderIP; } - inline AsciiString getLadderIP( void ) const { return m_ladderIP; } - inline void setLadderPort( UnsignedShort ladderPort ) { m_ladderPort = ladderPort; } - inline UnsignedShort getLadderPort( void ) const { return m_ladderPort; } + void setID(Int id) { m_id = id; } + Int getID( void ) const { return m_id; } + + void setHasPassword(Bool val) { m_requiresPassword = val; } + Bool getHasPassword(void) const { return m_requiresPassword; } + void setAllowObservers(Bool val) { m_allowObservers = val; } + Bool getAllowObservers(void) const { return m_allowObservers; } + + void setVersion(UnsignedInt val) { m_version = val; } + UnsignedInt getVersion(void) const { return m_version; } + void setExeCRC(UnsignedInt val) { m_exeCRC = val; } + UnsignedInt getExeCRC(void) const { return m_exeCRC; } + void setIniCRC(UnsignedInt val) { m_iniCRC = val; } + UnsignedInt getIniCRC(void) const { return m_iniCRC; } + + void setReportedNumPlayers(Int val) { m_reportedNumPlayers = val; } + Int getReportedNumPlayers(void) const { return m_reportedNumPlayers; } + + void setReportedMaxPlayers(Int val) { m_reportedMaxPlayers = val; } + Int getReportedMaxPlayers(void) const { return m_reportedMaxPlayers; } + + void setReportedNumObservers(Int val) { m_reportedNumObservers = val; } + Int getReportedNumObservers(void) const { return m_reportedNumObservers; } + + void setLadderIP( AsciiString ladderIP ) { m_ladderIP = ladderIP; } + AsciiString getLadderIP( void ) const { return m_ladderIP; } + void setLadderPort( UnsignedShort ladderPort ) { m_ladderPort = ladderPort; } + UnsignedShort getLadderPort( void ) const { return m_ladderPort; } void setPingString( AsciiString pingStr ); - inline AsciiString getPingString( void ) const { return m_pingStr; } - inline Int getPingAsInt( void ) const { return m_pingInt; } + AsciiString getPingString( void ) const { return m_pingStr; } + Int getPingAsInt( void ) const { return m_pingInt; } virtual Bool amIHost( void ) const; ///< Convenience function - is the local player the game host? @@ -150,12 +147,10 @@ class GameSpyStagingRoom : public GameInfo void launchGame( void ); ///< NAT negotiation has finished - really start virtual Int getLocalSlotNum( void ) const; ///< Get the local slot number, or -1 if we're not present - inline void setGameName( UnicodeString name ) { m_gameName = name; } - inline UnicodeString getGameName( void ) const { return m_gameName; } + void setGameName( UnicodeString name ) { m_gameName = name; } + UnicodeString getGameName( void ) const { return m_gameName; } - inline void setLocalName( AsciiString name ) { m_localName = name; } + void setLocalName( AsciiString name ) { m_localName = name; } }; extern GameSpyStagingRoom *TheGameSpyGame; - -#endif // __STAGINGROOMGAMEINFO_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h b/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h similarity index 92% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h rename to Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h index 7dd7c6fa3f..0db2a8df67 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/ThreadUtils.h @@ -28,10 +28,5 @@ #pragma once -#ifndef __GAMESPY_THREADUTILS_H__ -#define __GAMESPY_THREADUTILS_H__ - std::wstring MultiByteToWideCharSingleLine( const char *orig ); std::string WideCharStringToMultiByte( const WideChar *orig ); - -#endif // __GAMESPY_THREADUTILS_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpyOverlay.h b/Core/GameEngine/Include/GameNetwork/GameSpyOverlay.h similarity index 96% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpyOverlay.h rename to Core/GameEngine/Include/GameNetwork/GameSpyOverlay.h index 53526dbf73..b6dd903594 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpyOverlay.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpyOverlay.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __GAMESPYOVERLAY_H__ -#define __GAMESPYOVERLAY_H__ - #include "Common/NameKeyGenerator.h" #include "GameClient/WindowLayout.h" #include "GameClient/Gadget.h" @@ -66,4 +63,3 @@ void GameSpyToggleOverlay( GSOverlayType ); void GameSpyUpdateOverlays( void ); void ReOpenPlayerInfo( void ); void CheckReOpenPlayerInfo(void ); -#endif // __GAMESPYOVERLAY_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpyThread.h b/Core/GameEngine/Include/GameNetwork/GameSpyThread.h similarity index 96% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpyThread.h rename to Core/GameEngine/Include/GameNetwork/GameSpyThread.h index 11e8040027..82434da418 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/GameSpyThread.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpyThread.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __GAMESPYTHREAD_H__ -#define __GAMESPYTHREAD_H__ - #include "mutex.h" #include "thread.h" @@ -63,5 +60,3 @@ class GameSpyThreadClass : public ThreadClass extern GameSpyThreadClass *TheGameSpyThread; extern MutexClass TheGameSpyMutex; - -#endif // __GAMESPYTHREAD_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/IPEnumeration.h b/Core/GameEngine/Include/GameNetwork/IPEnumeration.h similarity index 82% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/IPEnumeration.h rename to Core/GameEngine/Include/GameNetwork/IPEnumeration.h index bb3a03d36d..0b2651d248 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/IPEnumeration.h +++ b/Core/GameEngine/Include/GameNetwork/IPEnumeration.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _IPENUMERATION_H_ -#define _IPENUMERATION_H_ - #include "GameNetwork/Transport.h" /** @@ -43,12 +40,12 @@ class EnumeratedIP : public MemoryPoolObject EnumeratedIP() { m_IPstring = ""; m_next = NULL; m_IP = 0; } // Access functions - inline AsciiString getIPstring( void ) { return m_IPstring; } - inline void setIPstring( AsciiString name ) { m_IPstring = name; } - inline UnsignedInt getIP( void ) { return m_IP; } - inline void setIP( UnsignedInt IP ) { m_IP = IP; } - inline EnumeratedIP *getNext( void ) { return m_next; } - inline void setNext( EnumeratedIP *next ) { m_next = next; } + AsciiString getIPstring( void ) { return m_IPstring; } + void setIPstring( AsciiString name ) { m_IPstring = name; } + UnsignedInt getIP( void ) { return m_IP; } + void setIP( UnsignedInt IP ) { m_IP = IP; } + EnumeratedIP *getNext( void ) { return m_next; } + void setNext( EnumeratedIP *next ) { m_next = next; } protected: AsciiString m_IPstring; @@ -78,6 +75,3 @@ class IPEnumeration EnumeratedIP *m_IPlist; Bool m_isWinsockInitialized; }; - - -#endif // _IPENUMERATION_H_ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/LANAPI.h b/Core/GameEngine/Include/GameNetwork/LANAPI.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/LANAPI.h rename to Core/GameEngine/Include/GameNetwork/LANAPI.h index 3ea69e9e71..eecd1eedba 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/LANAPI.h +++ b/Core/GameEngine/Include/GameNetwork/LANAPI.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _LANAPI_H_ -#define _LANAPI_H_ - #include "GameNetwork/Transport.h" #include "GameNetwork/NetworkInterface.h" #include "GameNetwork/NetworkDefs.h" @@ -75,7 +72,6 @@ class LANAPIInterface : public SubsystemInterface LANCHAT_NORMAL = 0, LANCHAT_EMOTE, LANCHAT_SYSTEM, - LANCHAT_MAX }; // Request functions generate network traffic @@ -110,7 +106,6 @@ class LANAPIInterface : public SubsystemInterface RET_GAME_GONE, // OnGameJoin RET_BUSY, // OnGameCreate/Join/etc if another action is in progress RET_UNKNOWN, // Default message for oddity - RET_MAX }; UnicodeString getErrorStringFromReturnType( ReturnType ret ); @@ -207,9 +202,9 @@ class LANAPI : public LANAPIInterface virtual Bool SetLocalIP( UnsignedInt localIP ); ///< For multiple NIC machines virtual void SetLocalIP( AsciiString localIP ); ///< For multiple NIC machines virtual Bool AmIHost( void ); ///< Am I hosting a game? - virtual inline UnicodeString GetMyName( void ) { return m_name; } ///< What's my name? - virtual inline LANGameInfo* GetMyGame( void ) { return m_currentGame; } ///< What's my Game? - virtual inline UnsignedInt GetLocalIP( void ) { return m_localIP; } ///< What's my IP? + virtual UnicodeString GetMyName( void ) { return m_name; } ///< What's my name? + virtual LANGameInfo* GetMyGame( void ) { return m_currentGame; } ///< What's my Game? + virtual UnsignedInt GetLocalIP( void ) { return m_localIP; } ///< What's my IP? virtual void fillInLANMessage( LANMessage *msg ); ///< Fill in default params virtual void checkMOTD( void ); protected: @@ -220,7 +215,6 @@ class LANAPI : public LANAPIInterface ACT_JOIN, ACT_JOINDIRECTCONNECT, ACT_LEAVE, - ACT_MAX }; static const UnsignedInt s_resendDelta; // in ms @@ -293,7 +287,7 @@ class LANAPI : public LANAPIInterface #pragma pack(push, 1) struct LANMessage { - enum ///< What kind of message are we? + enum Type ///< What kind of message are we? { // Locating everybody MSG_REQUEST_LOCATIONS, ///< Hey, where is everybody? @@ -319,9 +313,7 @@ struct LANMessage MSG_INACTIVE, ///< I've alt-tabbed out. Unaccept me cause I'm a poo-flinging monkey. MSG_REQUEST_GAME_INFO, ///< For direct connect, get the game info from a specific IP Address - - MSG_MAX - } LANMessageType; + } messageType; WideChar name[g_lanPlayerNameLength+1]; ///< My name, for convenience char userName[g_lanLoginNameLength+1]; ///< login name, for convenience @@ -418,6 +410,3 @@ struct LANMessage }; }; #pragma pack(pop) - - -#endif // _LANAPI_H_ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/LANAPICallbacks.h b/Core/GameEngine/Include/GameNetwork/LANAPICallbacks.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/LANAPICallbacks.h rename to Core/GameEngine/Include/GameNetwork/LANAPICallbacks.h index ef31229a2d..394b75dedd 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/LANAPICallbacks.h +++ b/Core/GameEngine/Include/GameNetwork/LANAPICallbacks.h @@ -27,10 +27,8 @@ // Author: Chris Huybregts, October 2001 // Description: LAN API Callbacks header /////////////////////////////////////////////////////////////////////////////////////// -#pragma once -#ifndef _LANAPI_CALLBACKS_H_ -#define _LANAPI_CALLBACKS_H_ +#pragma once #include "Common/NameKeyGenerator.h" #include "GameClient/Shell.h" @@ -74,7 +72,7 @@ extern const Color acceptFalseColor; void lanUpdateSlotList( void ); void updateGameOptions( void ); - +void setLANPlayerTooltip(LANPlayer* player); //Enum is used for the utility function so other windows do not need //to know about controls on LanGameOptions window. @@ -83,7 +81,3 @@ enum PostToLanGameType CPP_11(: Int){ SEND_GAME_OPTS = 0, POST_TO_LAN_GAME_TYPE_COUNT }; //the utility function mentioned above void PostToLanGameOptions(PostToLanGameType post); - - - -#endif //_LANAPI_CALLBACKS_H_ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/LANGameInfo.h b/Core/GameEngine/Include/GameNetwork/LANGameInfo.h similarity index 78% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/LANGameInfo.h rename to Core/GameEngine/Include/GameNetwork/LANGameInfo.h index 55075d36d3..dbdeb0dfc6 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/LANGameInfo.h +++ b/Core/GameEngine/Include/GameNetwork/LANGameInfo.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __LANGAMEINFO_H__ -#define __LANGAMEINFO_H__ - #include "GameNetwork/GameInfo.h" #include "GameNetwork/LANPlayer.h" @@ -51,15 +48,15 @@ class LANGameSlot : public GameSlot Bool isUser( LANPlayer *user ); ///< Does this slot contain the given user? Based off user->name Bool isUser( UnicodeString userName ); ///< Does this slot contain the given user? Bool isLocalPlayer( void ) const; ///< Is this slot me? - inline void setLogin( UnicodeString name ) { m_user.setLogin(name); } - inline void setLogin( AsciiString name ) { m_user.setLogin(name); } - inline void setHost( UnicodeString name ) { m_user.setHost(name); } - inline void setHost( AsciiString name ) { m_user.setHost(name); } - inline void setSerial( AsciiString serial ) { m_serial = serial; } - inline AsciiString getSerial( void ) { return m_serial; } + void setLogin( UnicodeString name ) { m_user.setLogin(name); } + void setLogin( AsciiString name ) { m_user.setLogin(name); } + void setHost( UnicodeString name ) { m_user.setHost(name); } + void setHost( AsciiString name ) { m_user.setHost(name); } + void setSerial( AsciiString serial ) { m_serial = serial; } + AsciiString getSerial( void ) { return m_serial; } - inline void setLastHeard( UnsignedInt t ) { m_lastHeard = t; } - inline UnsignedInt getLastHeard( void ) { return m_lastHeard; } + void setLastHeard( UnsignedInt t ) { m_lastHeard = t; } + UnsignedInt getLastHeard( void ) { return m_lastHeard; } //LANGameSlot& operator=(const LANGameSlot& src); @@ -88,60 +85,60 @@ class LANGameInfo : public GameInfo virtual Int getLocalSlotNum( void ) const; ///< Get the local slot number, or -1 if we're not present Int getSlotNum( UnicodeString userName ); ///< Get the slot number corresponding to a specific user, or -1 if he's not present - inline UnsignedInt getLastHeard( void ) { return m_lastHeard; } - inline void setLastHeard( UnsignedInt lastHeard ) { m_lastHeard = lastHeard; } - inline LANGameInfo *getNext( void ) { return m_next; } - inline void setNext( LANGameInfo *next ) { m_next = next; } + UnsignedInt getLastHeard( void ) { return m_lastHeard; } + void setLastHeard( UnsignedInt lastHeard ) { m_lastHeard = lastHeard; } + LANGameInfo *getNext( void ) { return m_next; } + void setNext( LANGameInfo *next ) { m_next = next; } // Game options void setMap( AsciiString mapName ); ///< Set the map to play on void setSeed( Int seed ); ///< Set the random seed for the game - inline void setName( UnicodeString name ) { m_gameName = name; } ///< Set the Name of the Game - inline UnicodeString getName( void ) { return m_gameName; } ///< Get the Name of the Game + void setName( UnicodeString name ) { m_gameName = name; } ///< Set the Name of the Game + UnicodeString getName( void ) { return m_gameName; } ///< Get the Name of the Game // Convinience functions that interface with the LANPlayer held in the slot list virtual void resetAccepted(void); ///< Reset the accepted flag on all players Bool amIHost( void ); ///< Convenience function - is the local player the game host? /// Get the IP of selected player or return 0 - inline UnsignedInt getIP( int who ) + UnsignedInt getIP( int who ) { return m_LANSlot[who].getIP(); } /// Set the IP of the Selected Player - inline void setIP( int who, UnsignedInt IP ) + void setIP( int who, UnsignedInt IP ) { m_LANSlot[who].setIP(IP); } /// set whether or not this is a direct connect game or not. - inline void setIsDirectConnect(Bool isDirectConnect) + void setIsDirectConnect(Bool isDirectConnect) { m_isDirectConnect = isDirectConnect; } /// returns whether or not this is a direct connect game or not. - inline Bool getIsDirectConnect() + Bool getIsDirectConnect() { return m_isDirectConnect; } /// Set the Player Name - inline void setPlayerName( int who, UnicodeString name ) + void setPlayerName( int who, UnicodeString name ) { m_LANSlot[who].setName(name); } /// Return the Player name or TheEmptyString - inline UnicodeString getPlayerName(int who) + UnicodeString getPlayerName(int who) { return m_LANSlot[who].getName(); } /// Return the time the player was heard from last, or 0 - inline UnsignedInt getPlayerLastHeard( int who ) + UnsignedInt getPlayerLastHeard( int who ) { if (m_LANSlot[who].isHuman()) return m_LANSlot[who].getLastHeard(); @@ -149,7 +146,7 @@ class LANGameInfo : public GameInfo } /// Set the last time we heard from the player - inline void setPlayerLastHeard( int who, UnsignedInt lastHeard ) + void setPlayerLastHeard( int who, UnsignedInt lastHeard ) { DEBUG_LOG(("LANGameInfo::setPlayerLastHeard - changing player %d last heard from %d to %d", who, getPlayerLastHeard(who), lastHeard)); if (m_LANSlot[who].isHuman()) @@ -180,6 +177,3 @@ void LANDisplayGameOptions( void ); ///< Displays the game options according to AsciiString GenerateGameOptionsString( void ); Bool ParseGameOptionsString(LANGameInfo *game, AsciiString options); - - -#endif // __LANGAMEINFO_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/LANPlayer.h b/Core/GameEngine/Include/GameNetwork/LANPlayer.h similarity index 66% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/LANPlayer.h rename to Core/GameEngine/Include/GameNetwork/LANPlayer.h index 032a5992ff..f71e7b18a7 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/LANPlayer.h +++ b/Core/GameEngine/Include/GameNetwork/LANPlayer.h @@ -28,10 +28,6 @@ #pragma once -#ifndef _LANPLAYER_H_ -#define _LANPLAYER_H_ - - /** * LAN player class. This is for players sitting in the lobby. Players are * uniquely identified by their IP addresses. @@ -42,20 +38,20 @@ class LANPlayer LANPlayer() { m_name = m_login = m_host = L""; m_lastHeard = 0; m_next = NULL; m_IP = 0; } // Access functions - inline UnicodeString getName( void ) { return m_name; } - inline void setName( UnicodeString name ) { m_name = name; } - inline UnicodeString getLogin( void ) { return m_login; } - inline void setLogin( UnicodeString name ) { m_login = name; } - inline void setLogin( AsciiString name ) { m_login.translate(name); } - inline UnicodeString getHost( void ) { return m_host; } - inline void setHost( UnicodeString name ) { m_host = name; } - inline void setHost( AsciiString name ) { m_host.translate(name); } - inline UnsignedInt getLastHeard( void ) { return m_lastHeard; } - inline void setLastHeard( UnsignedInt lastHeard ) { m_lastHeard = lastHeard; } - inline LANPlayer *getNext( void ) { return m_next; } - inline void setNext( LANPlayer *next ) { m_next = next; } - inline UnsignedInt getIP( void ) { return m_IP; } - inline void setIP( UnsignedInt IP ) { m_IP = IP; } + UnicodeString getName( void ) { return m_name; } + void setName( UnicodeString name ) { m_name = name; } + UnicodeString getLogin( void ) { return m_login; } + void setLogin( UnicodeString name ) { m_login = name; } + void setLogin( AsciiString name ) { m_login.translate(name); } + UnicodeString getHost( void ) { return m_host; } + void setHost( UnicodeString name ) { m_host = name; } + void setHost( AsciiString name ) { m_host.translate(name); } + UnsignedInt getLastHeard( void ) { return m_lastHeard; } + void setLastHeard( UnsignedInt lastHeard ) { m_lastHeard = lastHeard; } + LANPlayer *getNext( void ) { return m_next; } + void setNext( LANPlayer *next ) { m_next = next; } + UnsignedInt getIP( void ) { return m_IP; } + void setIP( UnsignedInt IP ) { m_IP = IP; } protected: UnicodeString m_name; ///< Player name @@ -65,5 +61,3 @@ class LANPlayer LANPlayer *m_next; ///< Linked list pointer UnsignedInt m_IP; ///< Player's IP }; - -#endif //_LANPLAYER_H_ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NAT.h b/Core/GameEngine/Include/GameNetwork/NAT.h similarity index 99% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/NAT.h rename to Core/GameEngine/Include/GameNetwork/NAT.h index 66b8ee7739..b5eb44c959 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NAT.h +++ b/Core/GameEngine/Include/GameNetwork/NAT.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __NAT_H -#define __NAT_H - #include "Lib/BaseType.h" #include "GameNetwork/NetworkInterface.h" #include "GameNetwork/FirewallHelper.h" @@ -158,5 +155,3 @@ class NAT { }; extern NAT *TheNAT; - -#endif // #ifndef __NAT_H diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetCommandList.h b/Core/GameEngine/Include/GameNetwork/NetCommandList.h similarity index 98% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/NetCommandList.h rename to Core/GameEngine/Include/GameNetwork/NetCommandList.h index ac29cbe1cc..21aa6ff733 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetCommandList.h +++ b/Core/GameEngine/Include/GameNetwork/NetCommandList.h @@ -22,12 +22,8 @@ // // //////////////////////////////////////////////////////////////////////////////// - #pragma once -#ifndef __NETCOMMANDLIST_H -#define __NETCOMMANDLIST_H - #include "Common/GameMemory.h" #include "GameNetwork/NetCommandRef.h" @@ -70,5 +66,3 @@ class NetCommandList : public MemoryPoolObject NetCommandRef *m_last; ///< Tail of the list. NetCommandRef *m_lastMessageInserted; ///< The last message that was inserted to this list. }; - -#endif diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetCommandMsg.h b/Core/GameEngine/Include/GameNetwork/NetCommandMsg.h similarity index 95% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/NetCommandMsg.h rename to Core/GameEngine/Include/GameNetwork/NetCommandMsg.h index fb988e2e65..59b05f88e2 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetCommandMsg.h +++ b/Core/GameEngine/Include/GameNetwork/NetCommandMsg.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __NETCOMMANDMSG_H -#define __NETCOMMANDMSG_H - #include "Lib/BaseType.h" #include "GameNetwork/NetworkDefs.h" #include "Common/UnicodeString.h" @@ -42,16 +39,16 @@ class NetCommandMsg : public MemoryPoolObject public: NetCommandMsg(); //virtual ~NetCommandMsg(); - inline UnsignedInt GetTimestamp() { return m_timestamp; } - inline void SetTimestamp(UnsignedInt timestamp) { m_timestamp = timestamp; } - inline void setExecutionFrame(UnsignedInt frame) { m_executionFrame = frame; } - inline void setPlayerID(UnsignedInt playerID) { m_playerID = playerID; } - inline void setID(UnsignedShort id) { m_id = id; } - inline UnsignedInt getExecutionFrame() { return m_executionFrame; } - inline UnsignedInt getPlayerID() { return m_playerID; } - inline UnsignedShort getID() { return m_id; } - inline void setNetCommandType(NetCommandType type) { m_commandType = type; } - inline NetCommandType getNetCommandType() { return m_commandType; } + UnsignedInt GetTimestamp() { return m_timestamp; } + void SetTimestamp(UnsignedInt timestamp) { m_timestamp = timestamp; } + void setExecutionFrame(UnsignedInt frame) { m_executionFrame = frame; } + void setPlayerID(UnsignedInt playerID) { m_playerID = playerID; } + void setID(UnsignedShort id) { m_id = id; } + UnsignedInt getExecutionFrame() { return m_executionFrame; } + UnsignedInt getPlayerID() { return m_playerID; } + UnsignedShort getID() { return m_id; } + void setNetCommandType(NetCommandType type) { m_commandType = type; } + NetCommandType getNetCommandType() { return m_commandType; } virtual Int getSortNumber(); void attach(); void detach(); @@ -517,4 +514,3 @@ class NetFrameResendRequestCommandMsg : public NetCommandMsg protected: UnsignedInt m_frameToResend; }; -#endif diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetCommandRef.h b/Core/GameEngine/Include/GameNetwork/NetCommandRef.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/NetCommandRef.h rename to Core/GameEngine/Include/GameNetwork/NetCommandRef.h index 5338af0220..33e0d46b2d 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetCommandRef.h +++ b/Core/GameEngine/Include/GameNetwork/NetCommandRef.h @@ -22,12 +22,8 @@ // // //////////////////////////////////////////////////////////////////////////////// - #pragma once -#ifndef __NETCOMMANDREF_H -#define __NETCOMMANDREF_H - #include "GameNetwork/NetCommandMsg.h" #include "Common/GameMemory.h" @@ -148,5 +144,3 @@ inline UnsignedByte NetCommandRef::getRelay() const { return m_relay; } - -#endif // #ifndef __NETCOMMANDREF_H diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetCommandWrapperList.h b/Core/GameEngine/Include/GameNetwork/NetCommandWrapperList.h similarity index 95% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/NetCommandWrapperList.h rename to Core/GameEngine/Include/GameNetwork/NetCommandWrapperList.h index 1997ff5d07..fac7ea7964 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetCommandWrapperList.h +++ b/Core/GameEngine/Include/GameNetwork/NetCommandWrapperList.h @@ -27,9 +27,6 @@ #pragma once -#ifndef __NETCOMMANDWRAPPERLIST_H -#define __NETCOMMANDWRAPPERLIST_H - #include "GameNetwork/NetCommandList.h" class NetCommandWrapperListNode : public MemoryPoolObject @@ -52,7 +49,7 @@ class NetCommandWrapperListNode : public MemoryPoolObject protected: UnsignedShort m_commandID; UnsignedByte *m_data; - UnsignedInt m_dataLength; + UnsignedInt m_totalDataLength; Bool *m_chunksPresent; UnsignedInt m_numChunks; UnsignedInt m_numChunksPresent; @@ -79,5 +76,3 @@ class NetCommandWrapperList : public MemoryPoolObject NetCommandWrapperListNode *m_list; }; - -#endif diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetPacket.h b/Core/GameEngine/Include/GameNetwork/NetPacket.h similarity index 99% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/NetPacket.h rename to Core/GameEngine/Include/GameNetwork/NetPacket.h index 465b88cf6e..f117df083a 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetPacket.h +++ b/Core/GameEngine/Include/GameNetwork/NetPacket.h @@ -32,14 +32,10 @@ for the data, but at least that wouldn't be repeating code, that would be specialized code. */ - - #pragma once -#ifndef __NETPACKET_H -#define __NETPACKET_H - #include "NetworkDefs.h" + #include "GameNetwork/NetCommandList.h" #include "Common/MessageStream.h" #include "Common/GameMemory.h" @@ -236,5 +232,3 @@ class NetPacket : public MemoryPoolObject UnsignedByte m_lastCommandType; UnsignedByte m_lastRelay; }; - -#endif // __NETPACKET_H diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetworkDefs.h b/Core/GameEngine/Include/GameNetwork/NetworkDefs.h similarity index 98% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/NetworkDefs.h rename to Core/GameEngine/Include/GameNetwork/NetworkDefs.h index 20e65b3bba..171f33df3d 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetworkDefs.h +++ b/Core/GameEngine/Include/GameNetwork/NetworkDefs.h @@ -22,12 +22,8 @@ // // //////////////////////////////////////////////////////////////////////////////// - #pragma once -#ifndef __NETWORKDEFS_H -#define __NETWORKDEFS_H - #include "Lib/BaseType.h" #include "Common/MessageStream.h" @@ -36,6 +32,7 @@ static const Int WOL_NAME_LEN = 64; /// Max number of commands per frame static const Int MAX_COMMANDS = 256; +extern Int MIN_LOGIC_FRAMES; extern Int MAX_FRAMES_AHEAD; extern Int MIN_RUNAHEAD; @@ -155,8 +152,6 @@ enum NetCommandType CPP_11(: Int) { NETCOMMANDTYPE_DISCONNECTFRAME, NETCOMMANDTYPE_DISCONNECTSCREENOFF, NETCOMMANDTYPE_DISCONNECTEND, - - NETCOMMANDTYPE_MAX }; enum NetLocalStatus CPP_11(: Int) { @@ -213,5 +208,3 @@ class NetworkInterface; extern NetworkInterface *TheNetwork; #define PRINTF_IP_AS_4_INTS(ip) ((ip) >> 24) & 0xff, ((ip) >> 16) & 0xff, ((ip) >> 8 ) & 0xff, (ip) & 0xff - -#endif diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetworkInterface.h b/Core/GameEngine/Include/GameNetwork/NetworkInterface.h similarity index 98% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/NetworkInterface.h rename to Core/GameEngine/Include/GameNetwork/NetworkInterface.h index 1bc29f705a..c0bf655eb6 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/NetworkInterface.h +++ b/Core/GameEngine/Include/GameNetwork/NetworkInterface.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _NETWORK_INTERFACE_H_ -#define _NETWORK_INTERFACE_H_ - #include "Common/MessageStream.h" #include "GameNetwork/ConnectionManager.h" #include "GameNetwork/User.h" @@ -68,6 +65,7 @@ class NetworkInterface : public SubsystemInterface virtual void setLocalAddress(UnsignedInt ip, UnsignedInt port) = 0; ///< Tell the network what local ip and port to bind to. virtual Bool isFrameDataReady( void ) = 0; ///< Are the commands for the next frame available? + virtual Bool isStalling() = 0; virtual void parseUserList( const GameInfo *game ) = 0; ///< Parse a userlist, creating connections virtual void startGame(void) = 0; ///< Sets the network game frame counter to -1 virtual UnsignedInt getRunAhead(void) = 0; ///< Get the current RunAhead value @@ -136,5 +134,3 @@ class NetworkInterface : public SubsystemInterface * a 32-bit unsigned integer. */ UnsignedInt ResolveIP(AsciiString host); - -#endif // _NETWORK_INTERFACE_H_ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/RankPointValue.h b/Core/GameEngine/Include/GameNetwork/RankPointValue.h similarity index 96% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/RankPointValue.h rename to Core/GameEngine/Include/GameNetwork/RankPointValue.h index b0574ced38..a2f616a2f5 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/RankPointValue.h +++ b/Core/GameEngine/Include/GameNetwork/RankPointValue.h @@ -45,9 +45,6 @@ #pragma once -#ifndef __RANK_POINT_VALUE_H_ -#define __RANK_POINT_VALUE_H_ - //----------------------------------------------------------------------------- // SYSTEM INCLUDES //////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -77,7 +74,7 @@ enum RANK_GENERAL, RANK_COMMANDER_IN_CHIEF, - MAX_RANKS // keep last + MAX_RANKS }; struct RankPoints @@ -101,5 +98,3 @@ Int CalculateRank( const PSPlayerStats& stats ); Int GetFavoriteSide( const PSPlayerStats& stats ); const Image* LookupSmallRankImage(Int side, Int rankPoints); extern RankPoints *TheRankPointValues; - -#endif // __RANK_POINT_VALUE_H_ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/Transport.h b/Core/GameEngine/Include/GameNetwork/Transport.h similarity index 94% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/Transport.h rename to Core/GameEngine/Include/GameNetwork/Transport.h index 27c111da10..bb3caff847 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/Transport.h +++ b/Core/GameEngine/Include/GameNetwork/Transport.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _TRANSPORT_H_ -#define _TRANSPORT_H_ - #include "GameNetwork/udp.h" #include "GameNetwork/NetworkDefs.h" @@ -59,7 +56,7 @@ class Transport //: public MemoryPoolObject Bool queueSend(UnsignedInt addr, UnsignedShort port, const UnsignedByte *buf, Int len /*, NetMessageFlags flags, Int id */); ///< Queue a packet for sending to the specified address and port. This will be sent on the next update() call. - inline Bool allowBroadcasts(Bool val) { if (!m_udpsock) return false; return (m_udpsock->AllowBroadcasts(val))?true:false; } + Bool allowBroadcasts(Bool val) { if (!m_udpsock) return false; return (m_udpsock->AllowBroadcasts(val))?true:false; } // Latency insertion and packet loss void setLatency( Bool val ) { m_useLatency = val; } @@ -101,5 +98,3 @@ class Transport //: public MemoryPoolObject Bool isGeneralsPacket( TransportMessage *msg ); }; - -#endif // _TRANSPORT_H_ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/User.h b/Core/GameEngine/Include/GameNetwork/User.h similarity index 83% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/User.h rename to Core/GameEngine/Include/GameNetwork/User.h index fd0ee0cd0b..d37ec9a52e 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/User.h +++ b/Core/GameEngine/Include/GameNetwork/User.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __USER_H -#define __USER_H - #include "GameNetwork/NetworkDefs.h" #include "Common/UnicodeString.h" @@ -44,12 +41,12 @@ class User : public MemoryPoolObject Bool operator== (const User *other); Bool operator!= (const User *other); - inline UnicodeString GetName() { return m_name; } + UnicodeString GetName() { return m_name; } void setName(UnicodeString name); - inline UnsignedShort GetPort() { return m_port; } - inline UnsignedInt GetIPAddr() { return m_ipaddr; } - inline void SetPort(UnsignedShort port) { m_port = port; } - inline void SetIPAddr(UnsignedInt ipaddr) { m_ipaddr = ipaddr; } + UnsignedShort GetPort() { return m_port; } + UnsignedInt GetIPAddr() { return m_ipaddr; } + void SetPort(UnsignedShort port) { m_port = port; } + void SetIPAddr(UnsignedInt ipaddr) { m_ipaddr = ipaddr; } private: @@ -58,5 +55,3 @@ class User : public MemoryPoolObject UnsignedInt m_ipaddr; }; EMPTY_DTOR(User) - -#endif diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/WOLBrowser/FEBDispatch.h b/Core/GameEngine/Include/GameNetwork/WOLBrowser/FEBDispatch.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/WOLBrowser/FEBDispatch.h rename to Core/GameEngine/Include/GameNetwork/WOLBrowser/FEBDispatch.h index a3d6a0095f..e87de2eb6c 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/WOLBrowser/FEBDispatch.h +++ b/Core/GameEngine/Include/GameNetwork/WOLBrowser/FEBDispatch.h @@ -27,8 +27,7 @@ // IDispatch for a COM object with a type library. // -#ifndef _FEBDISPATCH_H__ -#define _FEBDISPATCH_H__ +#pragma once #include extern CComModule _Module; @@ -102,5 +101,3 @@ public C private: ITypeInfo *m_ptinfo; }; - -#endif diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/WOLBrowser/WebBrowser.h b/Core/GameEngine/Include/GameNetwork/WOLBrowser/WebBrowser.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/WOLBrowser/WebBrowser.h rename to Core/GameEngine/Include/GameNetwork/WOLBrowser/WebBrowser.h index 075df2e479..0338aad5aa 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/WOLBrowser/WebBrowser.h +++ b/Core/GameEngine/Include/GameNetwork/WOLBrowser/WebBrowser.h @@ -42,9 +42,6 @@ #pragma once -#ifndef __WEBBROWSER_H__ -#define __WEBBROWSER_H__ - #include "Common/SubsystemInterface.h" #include #include @@ -125,4 +122,3 @@ class WebBrowser : }; extern CComObject *TheWebBrowser; -#endif // __WEBBROWSER_H__ diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/networkutil.h b/Core/GameEngine/Include/GameNetwork/networkutil.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/networkutil.h rename to Core/GameEngine/Include/GameNetwork/networkutil.h index b202323cf1..944e2ce0a6 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/networkutil.h +++ b/Core/GameEngine/Include/GameNetwork/networkutil.h @@ -22,10 +22,7 @@ // // //////////////////////////////////////////////////////////////////////////////// - #pragma once -#ifndef __NETWORKUTIL_H -#define __NETWORKUTIL_H #include "GameNetwork/NetworkDefs.h" #include "GameNetwork/NetworkInterface.h" @@ -55,5 +52,3 @@ inline UnsignedInt AssembleIp(UnsignedByte a, UnsignedByte b, UnsignedByte c, Un ((UnsignedInt)(c) << 8) | ((UnsignedInt)(d)); } - -#endif diff --git a/GeneralsMD/Code/GameEngine/Include/GameNetwork/udp.h b/Core/GameEngine/Include/GameNetwork/udp.h similarity index 98% rename from GeneralsMD/Code/GameEngine/Include/GameNetwork/udp.h rename to Core/GameEngine/Include/GameNetwork/udp.h index 7b54512d79..38ae9d3d1f 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameNetwork/udp.h +++ b/Core/GameEngine/Include/GameNetwork/udp.h @@ -22,17 +22,13 @@ // // //////////////////////////////////////////////////////////////////////////////// - #pragma once -#ifndef UDP_HEADER -#define UDP_HEADER - #ifdef _UNIX #include #endif -#ifdef _WINDOWS +#ifdef _WIN32 #include #include //#define close _close @@ -127,5 +123,3 @@ class UDP #ifdef DEBUG_LOGGING AsciiString GetWSAErrorString( Int error ); #endif - -#endif diff --git a/Core/GameEngine/Source/Common/AddonCompat.cpp b/Core/GameEngine/Source/Common/AddonCompat.cpp new file mode 100644 index 0000000000..6d88feb47d --- /dev/null +++ b/Core/GameEngine/Source/Common/AddonCompat.cpp @@ -0,0 +1,36 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#include "PreRTS.h" + +#include "Common/AddonCompat.h" +#include "Common/FileSystem.h" + +namespace addon +{ +Bool HasFullviewportDat() +{ + Char value = '0'; + if (File* file = TheFileSystem->openFile("GenTool/fullviewport.dat", File::READ | File::BINARY)) + { + file->read(&value, 1); + } + return value != '0'; +} + +} // namespace addon diff --git a/Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp b/Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp index b9f7f8daa4..eda40c71c7 100644 --- a/Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp +++ b/Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp @@ -36,7 +36,7 @@ /* Revision History: */ /* 3/21/2002 : Initial creation */ /*---------------------------------------------------------------------------*/ -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/AudioEventRTS.h" @@ -329,7 +329,7 @@ void AudioEventRTS::generateFilename( void ) adjustForLocalization(m_filenameToLoad); return; } else { - if (m_eventInfo->m_sounds.size() == 0) { + if (m_eventInfo->m_sounds.empty()) { m_filenameToLoad = AsciiString::TheEmptyString; return; } diff --git a/Core/GameEngine/Source/Common/Audio/AudioRequest.cpp b/Core/GameEngine/Source/Common/Audio/AudioRequest.cpp index 1da07132b2..a3235e1b69 100644 --- a/Core/GameEngine/Source/Common/Audio/AudioRequest.cpp +++ b/Core/GameEngine/Source/Common/Audio/AudioRequest.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/AudioRequest.h" diff --git a/Core/GameEngine/Source/Common/Audio/DynamicAudioEventInfo.cpp b/Core/GameEngine/Source/Common/Audio/DynamicAudioEventInfo.cpp index 6cbeed7855..e045b92e53 100644 --- a/Core/GameEngine/Source/Common/Audio/DynamicAudioEventInfo.cpp +++ b/Core/GameEngine/Source/Common/Audio/DynamicAudioEventInfo.cpp @@ -26,7 +26,7 @@ // Derivation of AudioEventInfo structure, for customized sounds // Author: Ian Barkley-Yeung, June 2003 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/DynamicAudioEventInfo.h" #include "Common/Xfer.h" diff --git a/Core/GameEngine/Source/Common/Audio/GameAudio.cpp b/Core/GameEngine/Source/Common/Audio/GameAudio.cpp index fd9a146fa2..9917266a64 100644 --- a/Core/GameEngine/Source/Common/Audio/GameAudio.cpp +++ b/Core/GameEngine/Source/Common/Audio/GameAudio.cpp @@ -42,7 +42,7 @@ // Includes //---------------------------------------------------------------------------- -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/GameAudio.h" #include "Common/AudioAffect.h" @@ -152,7 +152,6 @@ AudioManager::AudioManager() : m_hardwareAccel(FALSE), m_musicPlayingFromCD(FALSE) { - // Added by Sadullah Nader m_adjustedVolumes.clear(); m_audioRequests.clear(); m_listenerPosition.zero(); @@ -166,8 +165,6 @@ AudioManager::AudioManager() : m_systemSoundVolume = 0.0f; m_systemSpeechVolume = 0.0f; m_volumeHasChanged = FALSE; - // - m_listenerOrientation.set(0.0, 1.0, 0.0); theAudioHandlePool = AHSV_FirstHandle; m_audioSettings = NEW AudioSettings; @@ -184,11 +181,9 @@ AudioManager::~AudioManager() AudioEventInfoHashIt it; for (it = m_allAudioEventInfo.begin(); it != m_allAudioEventInfo.end(); ++it) { AudioEventInfo *eventInfo = (*it).second; - if (eventInfo) { - deleteInstance(eventInfo); - eventInfo = NULL; - } + deleteInstance(eventInfo); } + m_allAudioEventInfo.clear(); delete m_silentAudioEvent; m_silentAudioEvent = NULL; @@ -205,30 +200,29 @@ AudioManager::~AudioManager() delete m_audioSettings; m_audioSettings = NULL; - if (m_savedValues) - delete [] m_savedValues; + delete [] m_savedValues; } //------------------------------------------------------------------------------------------------- void AudioManager::init() { INI ini; - ini.load( AsciiString( "Data\\INI\\AudioSettings.ini" ), INI_LOAD_OVERWRITE, NULL); + ini.loadFileDirectory( "Data\\INI\\AudioSettings", INI_LOAD_OVERWRITE, NULL); - ini.load( AsciiString( "Data\\INI\\Default\\Music.ini" ), INI_LOAD_OVERWRITE, NULL ); - ini.load( AsciiString( "Data\\INI\\Music.ini" ), INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Default\\Music", INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Music", INI_LOAD_OVERWRITE, NULL ); - ini.load( AsciiString( "Data\\INI\\Default\\SoundEffects.ini" ), INI_LOAD_OVERWRITE, NULL ); - ini.load( AsciiString( "Data\\INI\\SoundEffects.ini" ), INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Default\\SoundEffects", INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\SoundEffects", INI_LOAD_OVERWRITE, NULL ); - ini.load( AsciiString( "Data\\INI\\Default\\Speech.ini" ), INI_LOAD_OVERWRITE, NULL ); - ini.load( AsciiString( "Data\\INI\\Speech.ini" ), INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Default\\Speech", INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Speech", INI_LOAD_OVERWRITE, NULL ); - ini.load( AsciiString( "Data\\INI\\Default\\Voice.ini" ), INI_LOAD_OVERWRITE, NULL ); - ini.load( AsciiString( "Data\\INI\\Voice.ini" ), INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Default\\Voice", INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Voice", INI_LOAD_OVERWRITE, NULL ); - // do the miscellaneous sound files last so that we find the audioeventrts associated with the events. - ini.load( AsciiString( "Data\\INI\\MiscAudio.ini" ), INI_LOAD_OVERWRITE, NULL); + // do the miscellaneous sound files last so that we find the AudioEventRTS associated with the events. + ini.loadFileDirectory( "Data\\INI\\MiscAudio", INI_LOAD_OVERWRITE, NULL); // determine if one of the music tracks exists. Since their now BIGd, one implies all. // If they don't exist, then attempt to load them from the CD. @@ -410,7 +404,7 @@ void AudioManager::getInfoForAudioEvent( const AudioEventRTS *eventToFindAndFill //------------------------------------------------------------------------------------------------- AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd) { - if (eventToAdd->getEventName().isEmpty() || eventToAdd->getEventName() == AsciiString("NoSound")) { + if (eventToAdd->getEventName().isEmpty() || eventToAdd->getEventName() == "NoSound") { return AHSV_NoSound; } @@ -807,9 +801,7 @@ AudioRequest *AudioManager::allocateAudioRequest( Bool useAudioEvent ) //------------------------------------------------------------------------------------------------- void AudioManager::releaseAudioRequest( AudioRequest *requestToRelease ) { - if (requestToRelease) { - deleteInstance(requestToRelease); - } + deleteInstance(requestToRelease); } //------------------------------------------------------------------------------------------------- @@ -1089,11 +1081,8 @@ AudioHandle AudioManager::allocateNewHandle( void ) //------------------------------------------------------------------------------------------------- void AudioManager::releaseAudioEventRTS( AudioEventRTS *&eventToRelease ) { - if( eventToRelease ) - { - delete eventToRelease; - eventToRelease = NULL; - } + delete eventToRelease; + eventToRelease = NULL; } //------------------------------------------------------------------------------------------------- diff --git a/Core/GameEngine/Source/Common/Audio/GameMusic.cpp b/Core/GameEngine/Source/Common/Audio/GameMusic.cpp index 6c80f9e0c7..1f0bbe18c0 100644 --- a/Core/GameEngine/Source/Common/Audio/GameMusic.cpp +++ b/Core/GameEngine/Source/Common/Audio/GameMusic.cpp @@ -43,7 +43,7 @@ // Includes //---------------------------------------------------------------------------- -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/GameMusic.h" diff --git a/Core/GameEngine/Source/Common/Audio/GameSounds.cpp b/Core/GameEngine/Source/Common/Audio/GameSounds.cpp index 3f16318ed9..f398941ab3 100644 --- a/Core/GameEngine/Source/Common/Audio/GameSounds.cpp +++ b/Core/GameEngine/Source/Common/Audio/GameSounds.cpp @@ -42,7 +42,7 @@ //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Lib/BaseType.h" #include "Common/GameSounds.h" @@ -50,6 +50,7 @@ #include "Common/AudioEventInfo.h" #include "Common/AudioEventRTS.h" #include "Common/AudioRequest.h" +#include "Common/GameUtility.h" #include "Common/Player.h" #include "Common/PlayerList.h" @@ -228,9 +229,10 @@ Bool SoundManager::canPlayNow( AudioEventRTS *event ) return false; } - Int localPlayerNdx = ThePlayerList->getLocalPlayer()->getPlayerIndex(); + const Int localPlayerIndex = rts::getObservedOrLocalPlayer()->getPlayerIndex(); + if( (event->getAudioEventInfo()->m_type & ST_SHROUDED) && - ThePartitionManager->getShroudStatusForPlayer(localPlayerNdx, pos) != CELLSHROUD_CLEAR ) + ThePartitionManager->getShroudStatusForPlayer(localPlayerIndex, pos) != CELLSHROUD_CLEAR ) { #ifdef INTENSIVE_AUDIO_DEBUG DEBUG_LOG(("- culled due to shroud.")); diff --git a/Core/GameEngine/Source/Common/CRCDebug.cpp b/Core/GameEngine/Source/Common/CRCDebug.cpp index 01bdfe816d..6b46e248bb 100644 --- a/Core/GameEngine/Source/Common/CRCDebug.cpp +++ b/Core/GameEngine/Source/Common/CRCDebug.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/CRCDebug.h" #include "Common/Debug.h" @@ -80,7 +80,7 @@ CRCVerification::~CRCVerification() { if (TheInGameUI) { - TheInGameUI->message(UnicodeString(L"GameLogic changed outside of GameLogic::update() - call Matt (x36804)!")); + TheInGameUI->message(L"GameLogic changed outside of GameLogic::update() - call Matt (x36804)!"); } CRCDEBUG_LOG(("GameLogic changed outside of GameLogic::update()!!!")); } diff --git a/Core/GameEngine/Source/Common/FramePacer.cpp b/Core/GameEngine/Source/Common/FramePacer.cpp new file mode 100644 index 0000000000..d538af0677 --- /dev/null +++ b/Core/GameEngine/Source/Common/FramePacer.cpp @@ -0,0 +1,214 @@ +/* +** Command & Conquer Generals Zero Hour(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 . +*/ +#include "PreRTS.h" + +#include "Common/FramePacer.h" + +#include "GameClient/View.h" + +#include "GameLogic/GameLogic.h" +#include "GameLogic/ScriptEngine.h" + +#include "GameNetwork/NetworkDefs.h" +#include "GameNetwork/NetworkInterface.h" + + +FramePacer* TheFramePacer = NULL; + +FramePacer::FramePacer() +{ + // Set the time slice size to 1 ms. + timeBeginPeriod(1); + + m_maxFPS = BaseFps; + m_logicTimeScaleFPS = LOGICFRAMES_PER_SECOND; + m_updateTime = 1.0f / (Real)BaseFps; // initialized to something to avoid division by zero on first use + m_enableFpsLimit = FALSE; + m_enableLogicTimeScale = FALSE; + m_isTimeFrozen = FALSE; + m_isGameHalted = FALSE; +} + +FramePacer::~FramePacer() +{ + // Restore the previous time slice for Windows. + timeEndPeriod(1); +} + +void FramePacer::update() +{ + // TheSuperHackers @bugfix xezon 05/08/2025 Re-implements the frame rate limiter + // with higher resolution counters to cap the frame rate more accurately to the desired limit. + const UnsignedInt maxFps = getActualFramesPerSecondLimit();// allowFpsLimit ? getFramesPerSecondLimit() : RenderFpsPreset::UncappedFpsValue; + m_updateTime = m_frameRateLimit.wait(maxFps); +} + +void FramePacer::setFramesPerSecondLimit( Int fps ) +{ + DEBUG_LOG(("FramePacer::setFramesPerSecondLimit() - setting max fps to %d (TheGlobalData->m_useFpsLimit == %d)", fps, TheGlobalData->m_useFpsLimit)); + m_maxFPS = fps; +} + +Int FramePacer::getFramesPerSecondLimit() const +{ + return m_maxFPS; +} + +void FramePacer::enableFramesPerSecondLimit( Bool enable ) +{ + m_enableFpsLimit = enable; +} + +Bool FramePacer::isFramesPerSecondLimitEnabled() const +{ + return m_enableFpsLimit; +} + +Bool FramePacer::isActualFramesPerSecondLimitEnabled() const +{ + Bool allowFpsLimit = true; + + if (TheTacticalView != NULL) + { + allowFpsLimit &= TheTacticalView->getTimeMultiplier()<=1 && !TheScriptEngine->isTimeFast(); + } + + if (TheGameLogic != NULL) + { +#if defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE) + allowFpsLimit &= !(!TheGameLogic->isGamePaused() && TheGlobalData->m_TiVOFastMode); +#else //always allow this cheat key if we're in a replay game. + allowFpsLimit &= !(!TheGameLogic->isGamePaused() && TheGlobalData->m_TiVOFastMode && TheGameLogic->isInReplayGame()); +#endif + } + + allowFpsLimit &= TheGlobalData->m_useFpsLimit; + allowFpsLimit &= isFramesPerSecondLimitEnabled(); + + return allowFpsLimit; +} + +Int FramePacer::getActualFramesPerSecondLimit() const +{ + return isActualFramesPerSecondLimitEnabled() ? getFramesPerSecondLimit() : RenderFpsPreset::UncappedFpsValue; +} + +Real FramePacer::getUpdateTime() const +{ + return m_updateTime; +} + +Real FramePacer::getUpdateFps() const +{ + return 1.0f / m_updateTime; +} + +Real FramePacer::getBaseOverUpdateFpsRatio(Real minUpdateFps) +{ + // Update fps is floored to default 5 fps, 200 ms. + // Useful to prevent insane ratios on frame spikes/stalls. + return (Real)BaseFps / std::max(getUpdateFps(), minUpdateFps); +} + +void FramePacer::setTimeFrozen(Bool frozen) +{ + m_isTimeFrozen = frozen; +} + +void FramePacer::setGameHalted(Bool halted) +{ + m_isGameHalted = halted; +} + +Bool FramePacer::isTimeFrozen() const +{ + return m_isTimeFrozen; +} + +Bool FramePacer::isGameHalted() const +{ + return m_isGameHalted; +} + +void FramePacer::setLogicTimeScaleFps( Int fps ) +{ + m_logicTimeScaleFPS = fps; +} + +Int FramePacer::getLogicTimeScaleFps() const +{ + return m_logicTimeScaleFPS; +} + +void FramePacer::enableLogicTimeScale( Bool enable ) +{ + m_enableLogicTimeScale = enable; +} + +Bool FramePacer::isLogicTimeScaleEnabled() const +{ + return m_enableLogicTimeScale; +} + +Int FramePacer::getActualLogicTimeScaleFps(LogicTimeQueryFlags flags) const +{ + if (m_isTimeFrozen && (flags & IgnoreFrozenTime) == 0) + { + return 0; + } + + if (m_isGameHalted && (flags & IgnoreHaltedGame) == 0) + { + return 0; + } + + if (TheNetwork != NULL) + { + return TheNetwork->getFrameRate(); + } + + if (isLogicTimeScaleEnabled()) + { + return getLogicTimeScaleFps(); + } + + // Returns uncapped value to align with the render update as per the original game behavior. + return RenderFpsPreset::UncappedFpsValue; +} + +Real FramePacer::getActualLogicTimeScaleRatio(LogicTimeQueryFlags flags) const +{ + return (Real)getActualLogicTimeScaleFps(flags) / LOGICFRAMES_PER_SECONDS_REAL; +} + +Real FramePacer::getActualLogicTimeScaleOverFpsRatio(LogicTimeQueryFlags flags) const +{ + // TheSuperHackers @info Clamps ratio to min 1, because the logic + // frame rate is currently capped by the render frame rate. + return min(1.0f, (Real)getActualLogicTimeScaleFps(flags) / getUpdateFps()); +} + +Real FramePacer::getLogicTimeStepSeconds(LogicTimeQueryFlags flags) const +{ + return SECONDS_PER_LOGICFRAME_REAL * getActualLogicTimeScaleOverFpsRatio(flags); +} + +Real FramePacer::getLogicTimeStepMilliseconds(LogicTimeQueryFlags flags) const +{ + return MSEC_PER_LOGICFRAME_REAL * getActualLogicTimeScaleOverFpsRatio(flags); +} diff --git a/Core/GameEngine/Source/Common/FrameRateLimit.cpp b/Core/GameEngine/Source/Common/FrameRateLimit.cpp new file mode 100644 index 0000000000..b8c7f1ff7a --- /dev/null +++ b/Core/GameEngine/Source/Common/FrameRateLimit.cpp @@ -0,0 +1,130 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#include "PreRTS.h" +#include "Common/FrameRateLimit.h" + + +FrameRateLimit::FrameRateLimit() +{ + LARGE_INTEGER freq; + LARGE_INTEGER start; + QueryPerformanceFrequency(&freq); + QueryPerformanceCounter(&start); + m_freq = freq.QuadPart; + m_start = start.QuadPart; +} + +Real FrameRateLimit::wait(UnsignedInt maxFps) +{ + LARGE_INTEGER tick; + QueryPerformanceCounter(&tick); + double elapsedSeconds = static_cast(tick.QuadPart - m_start) / m_freq; + const double targetSeconds = 1.0 / maxFps; + const double sleepSeconds = targetSeconds - elapsedSeconds - 0.002; // leave ~2ms for spin wait + + if (sleepSeconds > 0.0) + { + // Non busy wait with Munkee sleep + DWORD dwMilliseconds = static_cast(sleepSeconds * 1000); + Sleep(dwMilliseconds); + } + + // Busy wait for remaining time + do + { + QueryPerformanceCounter(&tick); + elapsedSeconds = static_cast(tick.QuadPart - m_start) / m_freq; + } + while (elapsedSeconds < targetSeconds); + + m_start = tick.QuadPart; + return (Real)elapsedSeconds; +} + + +const UnsignedInt RenderFpsPreset::s_fpsValues[] = { + 30, 50, 56, 60, 65, 70, 72, 75, 80, 85, 90, 100, 110, 120, 144, 240, 480, UncappedFpsValue }; + +static_assert(LOGICFRAMES_PER_SECOND <= 30, "Min FPS values need to be revisited!"); + +UnsignedInt RenderFpsPreset::getNextFpsValue(UnsignedInt value) +{ + const Int first = 0; + const Int last = ARRAY_SIZE(s_fpsValues) - 1; + for (Int i = first; i < last; ++i) + { + if (value >= s_fpsValues[i] && value < s_fpsValues[i + 1]) + { + return s_fpsValues[i + 1]; + } + } + return s_fpsValues[last]; +} + +UnsignedInt RenderFpsPreset::getPrevFpsValue(UnsignedInt value) +{ + const Int first = 0; + const Int last = ARRAY_SIZE(s_fpsValues) - 1; + for (Int i = last; i > first; --i) + { + if (value <= s_fpsValues[i] && value > s_fpsValues[i - 1]) + { + return s_fpsValues[i - 1]; + } + } + return s_fpsValues[first]; +} + +UnsignedInt RenderFpsPreset::changeFpsValue(UnsignedInt value, FpsValueChange change) +{ + switch (change) + { + default: + case FpsValueChange_Increase: return getNextFpsValue(value); + case FpsValueChange_Decrease: return getPrevFpsValue(value); + } +} + + +UnsignedInt LogicTimeScaleFpsPreset::getNextFpsValue(UnsignedInt value) +{ + return value + StepFpsValue; +} + +UnsignedInt LogicTimeScaleFpsPreset::getPrevFpsValue(UnsignedInt value) +{ + if (value - StepFpsValue < MinFpsValue) + { + return MinFpsValue; + } + else + { + return value - StepFpsValue; + } +} + +UnsignedInt LogicTimeScaleFpsPreset::changeFpsValue(UnsignedInt value, FpsValueChange change) +{ + switch (change) + { + default: + case FpsValueChange_Increase: return getNextFpsValue(value); + case FpsValueChange_Decrease: return getPrevFpsValue(value); + } +} diff --git a/Core/GameEngine/Source/Common/GameUtility.cpp b/Core/GameEngine/Source/Common/GameUtility.cpp new file mode 100644 index 0000000000..386fefdb3e --- /dev/null +++ b/Core/GameEngine/Source/Common/GameUtility.cpp @@ -0,0 +1,133 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#include "PreRTS.h" + +#include "Common/GameUtility.h" +#include "Common/PlayerList.h" +#include "Common/Player.h" +#include "Common/Radar.h" + +#include "GameClient/ControlBar.h" +#include "GameClient/GameClient.h" +#include "GameClient/InGameUI.h" +#include "GameClient/ParticleSys.h" + +#include "GameLogic/GameLogic.h" +#include "GameLogic/GhostObject.h" +#include "GameLogic/PartitionManager.h" + +namespace rts +{ + +namespace detail +{ +static void changePlayerCommon(Player* player) +{ + TheParticleSystemManager->setLocalPlayerIndex(player->getPlayerIndex()); + ThePartitionManager->refreshShroudForLocalPlayer(); + TheGhostObjectManager->setLocalPlayerIndex(player->getPlayerIndex()); + TheGameClient->updateFakeDrawables(); + TheRadar->refreshObjects(); + TheInGameUI->deselectAllDrawables(); +} + +} // namespace detail + +bool localPlayerHasRadar() +{ + // Using "local" instead of "observed or local" player because as an observer we prefer + // the radar to be turned on when observing a player that has no radar. + const Player* player = ThePlayerList->getLocalPlayer(); + const PlayerIndex index = player->getPlayerIndex(); + + if (TheRadar->isRadarForced(index)) + return true; + + if (!TheRadar->isRadarHidden(index) && player->hasRadar()) + return true; + + return false; +} + +Player* getObservedOrLocalPlayer() +{ + DEBUG_ASSERTCRASH(TheControlBar != NULL, ("TheControlBar is NULL")); + Player* player = TheControlBar->getObservedPlayer(); + if (player == NULL) + { + DEBUG_ASSERTCRASH(ThePlayerList != NULL, ("ThePlayerList is NULL")); + player = ThePlayerList->getLocalPlayer(); + } + return player; +} + +Player* getObservedOrLocalPlayer_Safe() +{ + Player* player = NULL; + + if (TheControlBar != NULL) + player = TheControlBar->getObservedPlayer(); + + if (player == NULL) + if (ThePlayerList != NULL) + player = ThePlayerList->getLocalPlayer(); + + return player; +} + +PlayerIndex getObservedOrLocalPlayerIndex_Safe() +{ + if (Player* player = getObservedOrLocalPlayer_Safe()) + return player->getPlayerIndex(); + + return 0; +} + +void changeLocalPlayer(Player* player) +{ + DEBUG_ASSERTCRASH(player != NULL, ("Player is NULL")); + + ThePlayerList->setLocalPlayer(player); + TheControlBar->setObserverLookAtPlayer(NULL); + TheControlBar->setObservedPlayer(NULL); + TheControlBar->setControlBarSchemeByPlayer(player); + TheControlBar->initSpecialPowershortcutBar(player); + + detail::changePlayerCommon(player); +} + +void changeObservedPlayer(Player* player) +{ + TheControlBar->setObserverLookAtPlayer(player); + + const Bool canBeginObservePlayer = TheGlobalData->m_enablePlayerObserver && TheGhostObjectManager->trackAllPlayers(); + const Bool canEndObservePlayer = TheControlBar->getObservedPlayer() != NULL && TheControlBar->getObserverLookAtPlayer() == NULL; + + if (canBeginObservePlayer || canEndObservePlayer) + { + TheControlBar->setObservedPlayer(player); + + Player *becomePlayer = player; + if (becomePlayer == NULL) + becomePlayer = ThePlayerList->findPlayerWithNameKey(TheNameKeyGenerator->nameToKey("ReplayObserver")); + detail::changePlayerCommon(becomePlayer); + } +} + +} // namespace rts diff --git a/Core/GameEngine/Source/Common/INI/INIAudioEventInfo.cpp b/Core/GameEngine/Source/Common/INI/INIAudioEventInfo.cpp index 26606556eb..6404e247c0 100644 --- a/Core/GameEngine/Source/Common/INI/INIAudioEventInfo.cpp +++ b/Core/GameEngine/Source/Common/INI/INIAudioEventInfo.cpp @@ -27,7 +27,7 @@ // Desc: Parsing AudioEvent, MusicTrack and DialogEvent INI entries /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/INI.h" #include "Common/GameAudio.h" @@ -65,7 +65,7 @@ void INI::parseMusicTrackDefinition( INI* ini ) // parse the ini definition ini->initFromINI( track, track->getFieldParse() ); -} // end parseMusicTrackDefinition +} //------------------------------------------------------------------------------------------------- void INI::parseAudioEventDefinition( INI* ini ) @@ -92,7 +92,7 @@ void INI::parseAudioEventDefinition( INI* ini ) // parse the ini definition ini->initFromINI( track, track->getFieldParse() ); -} // end parseAudioEventDefinition +} //------------------------------------------------------------------------------------------------- void INI::parseDialogDefinition( INI* ini ) @@ -119,7 +119,7 @@ void INI::parseDialogDefinition( INI* ini ) // parse the ini definition ini->initFromINI( track, track->getFieldParse() ); -} // end parseAudioEventDefinition +} //------------------------------------------------------------------------------------------------- @@ -179,7 +179,7 @@ static void parsePitchShift( INI* ini, void *instance, void *store, const void* // STATIC DEFINIITIONS //////////////////////////////////////////////////////////////////////////// -const char *theAudioPriorityNames[] = +const char *const theAudioPriorityNames[] = { "LOWEST", "LOW", @@ -188,8 +188,9 @@ const char *theAudioPriorityNames[] = "CRITICAL", NULL }; +static_assert(ARRAY_SIZE(theAudioPriorityNames) == AP_COUNT + 1, "Incorrect array size"); -const char *theSoundTypeNames[] = +const char *const theSoundTypeNames[] = { "UI", "WORLD", @@ -203,7 +204,7 @@ const char *theSoundTypeNames[] = NULL }; -const char *theAudioControlNames[] = +const char *const theAudioControlNames[] = { "LOOP", "RANDOM", diff --git a/Core/GameEngine/Source/Common/INI/INIMiscAudio.cpp b/Core/GameEngine/Source/Common/INI/INIMiscAudio.cpp index 75c5505694..5a552591c2 100644 --- a/Core/GameEngine/Source/Common/INI/INIMiscAudio.cpp +++ b/Core/GameEngine/Source/Common/INI/INIMiscAudio.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/MiscAudio.h" #include "Common/INI.h" diff --git a/Core/GameEngine/Source/Common/INI/INIVideo.cpp b/Core/GameEngine/Source/Common/INI/INIVideo.cpp index b25e495b2d..0e7e4d888d 100644 --- a/Core/GameEngine/Source/Common/INI/INIVideo.cpp +++ b/Core/GameEngine/Source/Common/INI/INIVideo.cpp @@ -28,7 +28,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/INI.h" #include "GameClient/VideoPlayer.h" @@ -56,6 +56,6 @@ void INI::parseVideoDefinition( INI* ini ) TheVideoPlayer->addVideo(&video); -} // end parseVideoDefinition +} diff --git a/Core/GameEngine/Source/Common/RandomValue.cpp b/Core/GameEngine/Source/Common/RandomValue.cpp index 86d577e4e3..f1c00982a8 100644 --- a/Core/GameEngine/Source/Common/RandomValue.cpp +++ b/Core/GameEngine/Source/Common/RandomValue.cpp @@ -26,7 +26,7 @@ // Pseudo-random number generators // Author: Michael S. Booth, January 1998 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Lib/BaseType.h" @@ -350,10 +350,11 @@ DEBUG_LOG(( "%d: GetGameAudioRandomValueReal = %f, %s line %d", // GameClientRandomVariable // -/*static*/ const char *GameClientRandomVariable::DistributionTypeNames[] = +const char *const GameClientRandomVariable::DistributionTypeNames[] = { - "CONSTANT", "UNIFORM", "GAUSSIAN", "TRIANGULAR", "LOW_BIAS", "HIGH_BIAS" + "CONSTANT", "UNIFORM", "GAUSSIAN", "TRIANGULAR", "LOW_BIAS", "HIGH_BIAS", NULL }; +static_assert(ARRAY_SIZE(GameClientRandomVariable::DistributionTypeNames) == GameClientRandomVariable::DISTRIBUTION_COUNT + 1, "Incorrect array size"); /** define the range of random values, and the distribution of values @@ -377,7 +378,7 @@ Real GameClientRandomVariable::getValue( void ) const DEBUG_ASSERTLOG(m_low == m_high, ("m_low != m_high for a CONSTANT GameClientRandomVariable")); if (m_low == m_high) { return m_low; - } // else return as though a UNIFORM. + } FALLTHROUGH; case UNIFORM: @@ -395,10 +396,11 @@ Real GameClientRandomVariable::getValue( void ) const // GameLogicRandomVariable // -/*static*/ const char *GameLogicRandomVariable::DistributionTypeNames[] = +const char *const GameLogicRandomVariable::DistributionTypeNames[] = { - "CONSTANT", "UNIFORM", "GAUSSIAN", "TRIANGULAR", "LOW_BIAS", "HIGH_BIAS" + "CONSTANT", "UNIFORM", "GAUSSIAN", "TRIANGULAR", "LOW_BIAS", "HIGH_BIAS", NULL }; +static_assert(ARRAY_SIZE(GameLogicRandomVariable::DistributionTypeNames) == GameLogicRandomVariable::DISTRIBUTION_COUNT + 1, "Incorrect array size"); /** define the range of random values, and the distribution of values @@ -422,7 +424,7 @@ Real GameLogicRandomVariable::getValue( void ) const DEBUG_ASSERTLOG(m_low == m_high, ("m_low != m_high for a CONSTANT GameLogicRandomVariable")); if (m_low == m_high) { return m_low; - } // else return as though a UNIFORM. + } FALLTHROUGH; case UNIFORM: diff --git a/Core/GameEngine/Source/Common/System/ArchiveFile.cpp b/Core/GameEngine/Source/Common/System/ArchiveFile.cpp index 3ea2cc0fb8..c10b42754c 100644 --- a/Core/GameEngine/Source/Common/System/ArchiveFile.cpp +++ b/Core/GameEngine/Source/Common/System/ArchiveFile.cpp @@ -90,50 +90,46 @@ ArchiveFile::~ArchiveFile() } ArchiveFile::ArchiveFile() + : m_file(NULL) { - 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, "\\/"); + AsciiString token; + AsciiString tokenizer = path; + tokenizer.toLower(); + tokenizer.nextToken(&token, "\\/"); - while (token.getLength() > 0) { - if (dirInfo->m_directories.find(token) == dirInfo->m_directories.end()) + while (token.getLength() > 0) + { + DetailedArchivedDirectoryInfoMap::iterator tempiter = dirInfo->m_directories.find(token); + if (tempiter == dirInfo->m_directories.end()) + { + dirInfo = &(dirInfo->m_directories[token]); + dirInfo->m_directoryName = token; + } + else { - dirInfo->m_directories[token].clear(); - dirInfo->m_directories[token].m_directoryName = token; + dirInfo = &tempiter->second; } - debugpath.concat(token); - debugpath.concat('\\'); - dirInfo = &(dirInfo->m_directories[token]); - temp.nextToken(&token, "\\/"); + tokenizer.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, "\\/"); + AsciiString tokenizer = originalDirectory; + tokenizer.toLower(); + tokenizer.nextToken(&token, "\\/"); while (token.getLength() > 0) { @@ -148,7 +144,7 @@ void ArchiveFile::getFileListInDirectory(const AsciiString& currentDirectory, co return; } - searchDir.nextToken(&token, "\\/"); + tokenizer.nextToken(&token, "\\/"); } getFileListInDirectory(dirInfo, originalDirectory, searchName, filenameList, searchSubdirectories); @@ -198,17 +194,15 @@ void ArchiveFile::attachFile(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)) { + AsciiString token; + AsciiString tokenizer = filename; + tokenizer.toLower(); + tokenizer.nextToken(&token, "\\/"); + while (!token.find('.') || tokenizer.find('.')) + { DetailedArchivedDirectoryInfoMap::const_iterator it = dirInfo->m_directories.find(token); if (it != dirInfo->m_directories.end()) { @@ -219,7 +213,7 @@ const ArchivedFileInfo * ArchiveFile::getArchivedFileInfo(const AsciiString& fil return NULL; } - path.nextToken(&token, "\\/"); + tokenizer.nextToken(&token, "\\/"); } ArchivedFileInfoMap::const_iterator it = dirInfo->m_files.find(token); diff --git a/Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp b/Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp index 35f7078098..1d8223a014 100644 --- a/Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp +++ b/Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp @@ -110,70 +110,115 @@ ArchiveFileSystem::~ArchiveFileSystem() ArchiveFileMap::iterator iter = m_archiveFileMap.begin(); while (iter != m_archiveFileMap.end()) { ArchiveFile *file = iter->second; - if (file != NULL) { - delete file; - file = NULL; - } + delete file; iter++; } } -void ArchiveFileSystem::loadIntoDirectoryTree(const ArchiveFile *archiveFile, const AsciiString& archiveFilename, Bool overwrite) +void ArchiveFileSystem::loadIntoDirectoryTree(ArchiveFile *archiveFile, Bool overwrite) { FilenameList filenameList; - archiveFile->getFileListInDirectory(AsciiString(""), AsciiString(""), AsciiString("*"), filenameList, TRUE); + archiveFile->getFileListInDirectory("", "", "*", 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; - + while (it != filenameList.end()) + { ArchivedDirectoryInfo *dirInfo = &m_rootDirectory; - Bool infoInPath; - infoInPath = path.nextToken(&token, "\\/"); + AsciiString path; + AsciiString token; + AsciiString tokenizer = *it; + tokenizer.toLower(); + Bool infoInPath = tokenizer.nextToken(&token, "\\/"); + + while (infoInPath && (!token.find('.') || tokenizer.find('.'))) + { + path.concat(token); + path.concat('\\'); - 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]); + dirInfo->m_path = path; + dirInfo->m_directoryName = token; + } + else + { + dirInfo = &tempiter->second; } - dirInfo = &(dirInfo->m_directories[token]); - debugpath.concat(token); - debugpath.concat('\\'); - infoInPath = path.nextToken(&token, "\\/"); + infoInPath = tokenizer.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; + ArchivedFileLocationMap::iterator fileIt; + if (overwrite) + { + // When overwriting, try place the new value at the beginning of the key list. + fileIt = dirInfo->m_files.find(token); + } + else + { + // Append to the end of the key list. + fileIt = dirInfo->m_files.end(); } + dirInfo->m_files.insert(fileIt, std::make_pair(token, archiveFile)); + +#if defined(DEBUG_LOGGING) && ENABLE_FILESYSTEM_LOGGING + { + const stl::const_range range = stl::get_range(dirInfo->m_files, token, 0); + if (range.distance() >= 2) + { + ArchivedFileLocationMap::const_iterator rangeIt0; + ArchivedFileLocationMap::const_iterator rangeIt1; + + if (overwrite) + { + rangeIt0 = range.begin; + rangeIt1 = std::next(rangeIt0); + + DEBUG_LOG(("ArchiveFileSystem::loadIntoDirectoryTree - adding file %s, archived in %s, overwriting same file in %s", + it->str(), + rangeIt0->second->getName().str(), + rangeIt1->second->getName().str() + )); + } + else + { + rangeIt1 = std::prev(range.end); + rangeIt0 = std::prev(rangeIt1); + + DEBUG_LOG(("ArchiveFileSystem::loadIntoDirectoryTree - adding file %s, archived in %s, overwritten by same file in %s", + it->str(), + rangeIt1->second->getName().str(), + rangeIt0->second->getName().str() + )); + } + } + else + { + DEBUG_LOG(("ArchiveFileSystem::loadIntoDirectoryTree - adding file %s, archived in %s", it->str(), archiveFile->getName().str())); + } + } +#endif + it++; } } -void ArchiveFileSystem::loadMods() { +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); + loadIntoDirectoryTree(archiveFile, TRUE); m_archiveFileMap[TheGlobalData->m_modBIG] = archiveFile; DEBUG_LOG(("ArchiveFileSystem::loadMods - %s inserted into the archive file map.", TheGlobalData->m_modBIG.str())); } @@ -193,51 +238,68 @@ void ArchiveFileSystem::loadMods() { } } -Bool ArchiveFileSystem::doesFileExist(const Char *filename) const +Bool ArchiveFileSystem::doesFileExist(const Char *filename, FileInstance instance) const { - AsciiString path = filename; - path.toLower(); - AsciiString token; + ArchivedDirectoryInfoResult result = const_cast(this)->getArchivedDirectoryInfo(filename); - const ArchivedDirectoryInfo *dirInfo = &m_rootDirectory; + if (!result.valid()) + return false; - path.nextToken(&token, "\\/"); + stl::const_range range = stl::get_range(result.dirInfo->m_files, result.lastToken, instance); - while (!token.find('.') || path.find('.')) + return range.valid(); +} + +ArchivedDirectoryInfo* ArchiveFileSystem::friend_getArchivedDirectoryInfo(const Char* directory) +{ + ArchivedDirectoryInfoResult result = getArchivedDirectoryInfo(directory); + + return result.dirInfo; +} + +ArchiveFileSystem::ArchivedDirectoryInfoResult ArchiveFileSystem::getArchivedDirectoryInfo(const Char* directory) +{ + ArchivedDirectoryInfoResult result; + ArchivedDirectoryInfo* dirInfo = &m_rootDirectory; + + AsciiString token; + AsciiString tokenizer = directory; + tokenizer.toLower(); + Bool infoInPath = tokenizer.nextToken(&token, "\\/"); + + while (infoInPath && (!token.find('.') || tokenizer.find('.'))) { - ArchivedDirectoryInfoMap::const_iterator tempiter = dirInfo->m_directories.find(token); + ArchivedDirectoryInfoMap::iterator tempiter = dirInfo->m_directories.find(token); if (tempiter != dirInfo->m_directories.end()) { dirInfo = &tempiter->second; - path.nextToken(&token, "\\/"); + infoInPath = tokenizer.nextToken(&token, "\\/"); } else { - // the directory doesn't exist, so return false - return FALSE; + // the directory doesn't exist + result.dirInfo = NULL; + result.lastToken = AsciiString::TheEmptyString; + return result; } } - // 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; + result.dirInfo = dirInfo; + result.lastToken = token; + return result; } -File * ArchiveFileSystem::openFile(const Char *filename, Int access /* = 0 */) +File * ArchiveFileSystem::openFile(const Char *filename, Int access, FileInstance instance) { - AsciiString archiveFilename; - archiveFilename = getArchiveFilenameForFile(AsciiString(filename)); + ArchiveFile* archive = getArchiveFile(filename, instance); - if (archiveFilename.getLength() == 0) { + if (archive == NULL) return NULL; - } - return m_archiveFileMap[archiveFilename]->openFile(filename, access); + return archive->openFile(filename, access); } -Bool ArchiveFileSystem::getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const +Bool ArchiveFileSystem::getFileInfo(const AsciiString& filename, FileInfo *fileInfo, FileInstance instance) const { if (fileInfo == NULL) { return FALSE; @@ -247,69 +309,27 @@ Bool ArchiveFileSystem::getFileInfo(const AsciiString& filename, FileInfo *fileI 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 - { + ArchiveFile* archive = getArchiveFile(filename, instance); + + if (archive == NULL) return FALSE; - } + + return archive->getFileInfo(filename, fileInfo); } -AsciiString ArchiveFileSystem::getArchiveFilenameForFile(const AsciiString& filename) const +ArchiveFile* ArchiveFileSystem::getArchiveFile(const AsciiString& filename, FileInstance instance) const { - AsciiString path; - path = filename; - path.toLower(); - AsciiString token; - AsciiString debugpath; - - const ArchivedDirectoryInfo *dirInfo = &m_rootDirectory; - - path.nextToken(&token, "\\/"); + ArchivedDirectoryInfoResult result = const_cast(this)->getArchivedDirectoryInfo(filename.str()); - 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, "\\/"); - } + if (!result.valid()) + return NULL; - ArchivedFileLocationMap::const_iterator it = dirInfo->m_files.find(token); - if (it != dirInfo->m_files.end()) - { - return it->second; - } - else - { - return AsciiString::TheEmptyString; - } + stl::const_range range = stl::get_range(result.dirInfo->m_files, result.lastToken, instance); + if (!range.valid()) + return NULL; + + return range.get()->second; } void ArchiveFileSystem::getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList &filenameList, Bool searchSubdirectories) const diff --git a/Core/GameEngine/Source/Common/System/AsciiString.cpp b/Core/GameEngine/Source/Common/System/AsciiString.cpp index 06e9ec8849..31567ec533 100644 --- a/Core/GameEngine/Source/Common/System/AsciiString.cpp +++ b/Core/GameEngine/Source/Common/System/AsciiString.cpp @@ -42,14 +42,14 @@ // //----------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/CriticalSection.h" // ----------------------------------------------------- -/*static*/ AsciiString AsciiString::TheEmptyString; +/*static*/ const AsciiString AsciiString::TheEmptyString; //----------------------------------------------------------------------------- inline char* skipSeps(char* p, const char* seps) @@ -125,14 +125,20 @@ void AsciiString::ensureUniqueBufferOfSize(int numCharsNeeded, Bool preserveData { validate(); + const int usableNumChars = numCharsNeeded - 1; + if (m_data && m_data->m_refCount == 1 && m_data->m_numCharsAllocated >= numCharsNeeded) { // no buffer manhandling is needed (it's already large enough, and unique to us) if (strToCopy) + { // TheSuperHackers @fix Mauller 04/04/2025 Replace strcpy with safer memmove as memory regions can overlap when part of string is copied to itself - memmove(m_data->peek(), strToCopy, strlen(strToCopy) + 1); + DEBUG_ASSERTCRASH(usableNumChars <= strlen(strToCopy), ("strToCopy is too small")); + memmove(m_data->peek(), strToCopy, usableNumChars); + m_data->peek()[usableNumChars] = 0; + } if (strToCat) strcat(m_data->peek(), strToCat); return; @@ -157,7 +163,11 @@ void AsciiString::ensureUniqueBufferOfSize(int numCharsNeeded, Bool preserveData // do these BEFORE releasing the old buffer, so that self-copies // or self-cats will work correctly. if (strToCopy) - strcpy(newData->peek(), strToCopy); + { + DEBUG_ASSERTCRASH(usableNumChars <= strlen(strToCopy), ("strToCopy is too small")); + strncpy(newData->peek(), strToCopy, usableNumChars); + newData->peek()[usableNumChars] = 0; + } if (strToCat) strcat(newData->peek(), strToCat); @@ -186,11 +196,21 @@ void AsciiString::releaseBuffer() } // ----------------------------------------------------- -AsciiString::AsciiString(const char* s) : m_data(0) +AsciiString::AsciiString(const char* s) : m_data(NULL) { //DEBUG_ASSERTCRASH(isMemoryManagerOfficiallyInited(), ("Initializing AsciiStrings prior to main (ie, as static vars) can cause memory leak reporting problems. Are you sure you want to do this?")); - int len = (s)?strlen(s):0; - if (len) + int len = s ? (int)strlen(s) : 0; + if (len > 0) + { + ensureUniqueBufferOfSize(len + 1, false, s, NULL); + } + validate(); +} + +// ----------------------------------------------------- +AsciiString::AsciiString(const char* s, int len) : m_data(NULL) +{ + if (len > 0) { ensureUniqueBufferOfSize(len + 1, false, s, NULL); } @@ -215,12 +235,18 @@ void AsciiString::set(const AsciiString& stringSrc) // ----------------------------------------------------- void AsciiString::set(const char* s) +{ + int len = s ? strlen(s) : 0; + set(s, len); +} + +// ----------------------------------------------------- +void AsciiString::set(const char* s, int len) { validate(); if (!m_data || s != peek()) { - int len = s ? strlen(s) : 0; - if (len) + if (len > 0) { ensureUniqueBufferOfSize(len + 1, false, s, NULL); } @@ -375,7 +401,7 @@ void AsciiString::truncateBy(const Int charCount) const size_t len = strlen(peek()); if (len > 0) { - ensureUniqueBufferOfSize(len+1, true, NULL, NULL); + ensureUniqueBufferOfSize(len + 1, true, NULL, NULL); size_t count = charCount; if (charCount > len) { @@ -451,57 +477,25 @@ void AsciiString::format_va(const char* format, va_list args) // ----------------------------------------------------- Bool AsciiString::startsWith(const char* p) const { - if (*p == 0) - return true; // everything starts with the empty string - - int lenThis = getLength(); - int lenThat = strlen(p); - if (lenThis < lenThat) - return false; // that must be smaller than this - - return strncmp(peek(), p, lenThat) == 0; + return m_data && ::startsWith(peek(), p); } // ----------------------------------------------------- Bool AsciiString::startsWithNoCase(const char* p) const { - if (*p == 0) - return true; // everything starts with the empty string - - int lenThis = getLength(); - int lenThat = strlen(p); - if (lenThis < lenThat) - return false; // that must be smaller than this - - return strnicmp(peek(), p, lenThat) == 0; + return m_data && ::startsWithNoCase(peek(), p); } // ----------------------------------------------------- Bool AsciiString::endsWith(const char* p) const { - if (*p == 0) - return true; // everything ends with the empty string - - int lenThis = getLength(); - int lenThat = strlen(p); - if (lenThis < lenThat) - return false; // that must be smaller than this - - return strncmp(peek() + lenThis - lenThat, p, lenThat) == 0; + return m_data && ::endsWith(peek(), p); } // ----------------------------------------------------- Bool AsciiString::endsWithNoCase(const char* p) const { - if (*p == 0) - return true; // everything ends with the empty string - - int lenThis = getLength(); - int lenThat = strlen(p); - if (lenThis < lenThat) - return false; // that must be smaller than this - - return strnicmp(peek() + lenThis - lenThat, p, lenThat) == 0; + return m_data && ::endsWithNoCase(peek(), p); } //----------------------------------------------------------------------------- diff --git a/Core/GameEngine/Source/Common/System/Debug.cpp b/Core/GameEngine/Source/Common/System/Debug.cpp index 88a65e228f..33ddbff460 100644 --- a/Core/GameEngine/Source/Common/System/Debug.cpp +++ b/Core/GameEngine/Source/Common/System/Debug.cpp @@ -43,7 +43,7 @@ // ---------------------------------------------------------------------------- // SYSTEM INCLUDES -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine // USER INCLUDES @@ -70,6 +70,9 @@ #if defined(DEBUG_STACKTRACE) || defined(IG_DEBUG_STACKTRACE) #include "Common/StackDump.h" #endif +#ifdef RTS_ENABLE_CRASHDUMP +#include "Common/MiniDumper.h" +#endif // Horrible reference, but we really, really need to know if we are windowed. extern bool DX8Wrapper_IsWindowed; @@ -376,39 +379,47 @@ void DebugInit(int flags) char dirbuf[ _MAX_PATH ]; ::GetModuleFileName( NULL, dirbuf, sizeof( dirbuf ) ); - char *pEnd = dirbuf + strlen( dirbuf ); - while( pEnd != dirbuf ) + if (char *pEnd = strrchr(dirbuf, '\\')) { - if( *pEnd == '\\' ) - { - *(pEnd + 1) = 0; - break; - } - pEnd--; + *(pEnd + 1) = 0; } + static_assert(ARRAY_SIZE(theLogFileNamePrev) >= ARRAY_SIZE(dirbuf), "Incorrect array size"); strcpy(theLogFileNamePrev, dirbuf); - strcat(theLogFileNamePrev, gAppPrefix); - strcat(theLogFileNamePrev, DEBUG_FILE_NAME_PREV); + strlcat(theLogFileNamePrev, gAppPrefix, ARRAY_SIZE(theLogFileNamePrev)); + strlcat(theLogFileNamePrev, DEBUG_FILE_NAME_PREV, ARRAY_SIZE(theLogFileNamePrev)); if (rts::ClientInstance::getInstanceId() > 1u) { size_t offset = strlen(theLogFileNamePrev); snprintf(theLogFileNamePrev + offset, ARRAY_SIZE(theLogFileNamePrev) - offset, "_Instance%.2u", rts::ClientInstance::getInstanceId()); } - strcat(theLogFileNamePrev, ".txt"); + strlcat(theLogFileNamePrev, ".txt", ARRAY_SIZE(theLogFileNamePrev)); + static_assert(ARRAY_SIZE(theLogFileName) >= ARRAY_SIZE(dirbuf), "Incorrect array size"); strcpy(theLogFileName, dirbuf); - strcat(theLogFileName, gAppPrefix); - strcat(theLogFileName, DEBUG_FILE_NAME); + strlcat(theLogFileName, gAppPrefix, ARRAY_SIZE(theLogFileNamePrev)); + strlcat(theLogFileName, DEBUG_FILE_NAME, ARRAY_SIZE(theLogFileNamePrev)); if (rts::ClientInstance::getInstanceId() > 1u) { size_t offset = strlen(theLogFileName); snprintf(theLogFileName + offset, ARRAY_SIZE(theLogFileName) - offset, "_Instance%.2u", rts::ClientInstance::getInstanceId()); } - strcat(theLogFileName, ".txt"); + strlcat(theLogFileName, ".txt", ARRAY_SIZE(theLogFileNamePrev)); remove(theLogFileNamePrev); - rename(theLogFileName, theLogFileNamePrev); + if (rename(theLogFileName, theLogFileNamePrev) != 0) + { +#ifdef DEBUG_LOGGING + DebugLog("Warning: Could not rename buffer file '%s' to '%s'. Will remove instead", theLogFileName, theLogFileNamePrev); +#endif + if (remove(theLogFileName) != 0) + { +#ifdef DEBUG_LOGGING + DebugLog("Warning: Failed to remove file '%s'", theLogFileName); +#endif + } + } + theLogFile = fopen(theLogFileName, "w"); if (theLogFile != NULL) { @@ -509,7 +520,7 @@ void DebugCrash(const char *format, ...) char theCrashBuffer[ LARGE_BUFFER ]; prepBuffer(theCrashBuffer); - strcat(theCrashBuffer, "ASSERTION FAILURE: "); + strlcat(theCrashBuffer, "ASSERTION FAILURE: ", ARRAY_SIZE(theCrashBuffer)); va_list arg; va_start(arg, format); @@ -538,7 +549,7 @@ void DebugCrash(const char *format, ...) #endif } - strcat(theCrashBuffer, "\n\nAbort->exception; Retry->debugger; Ignore->continue"); + strlcat(theCrashBuffer, "\n\nAbort->exception; Retry->debugger; Ignore->continue", ARRAY_SIZE(theCrashBuffer)); const int result = doCrashBox(theCrashBuffer, useLogging); @@ -719,6 +730,22 @@ double SimpleProfiler::getAverageTime() } } + +static void TriggerMiniDump() +{ +#ifdef RTS_ENABLE_CRASHDUMP + if (TheMiniDumper && TheMiniDumper->IsInitialized()) + { + // Create both minimal and full memory dumps + TheMiniDumper->TriggerMiniDump(DumpType_Minimal); + TheMiniDumper->TriggerMiniDump(DumpType_Full); + } + + MiniDumper::shutdownMiniDumper(); +#endif +} + + void ReleaseCrash(const char *reason) { /// do additional reporting on the crash, if possible @@ -729,6 +756,8 @@ void ReleaseCrash(const char *reason) } } + TriggerMiniDump(); + char prevbuf[ _MAX_PATH ]; char curbuf[ _MAX_PATH ]; @@ -736,13 +765,24 @@ void ReleaseCrash(const char *reason) return; // We are shutting down, and TheGlobalData has been freed. jba. [4/15/2003] } - strcpy(prevbuf, TheGlobalData->getPath_UserData().str()); - strcat(prevbuf, RELEASECRASH_FILE_NAME_PREV); - strcpy(curbuf, TheGlobalData->getPath_UserData().str()); - strcat(curbuf, RELEASECRASH_FILE_NAME); + strlcpy(prevbuf, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(prevbuf)); + strlcat(prevbuf, RELEASECRASH_FILE_NAME_PREV, ARRAY_SIZE(prevbuf)); + strlcpy(curbuf, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(curbuf)); + strlcat(curbuf, RELEASECRASH_FILE_NAME, ARRAY_SIZE(curbuf)); remove(prevbuf); - rename(curbuf, prevbuf); + if (rename(curbuf, prevbuf) != 0) + { +#ifdef DEBUG_LOGGING + DebugLog("Warning: Could not rename buffer file '%s' to '%s'. Will remove instead", curbuf, prevbuf); +#endif + if (remove(curbuf) != 0) + { +#ifdef DEBUG_LOGGING + DebugLog("Warning: Failed to remove file '%s'", curbuf); +#endif + } + } theReleaseCrashLogFile = fopen(curbuf, "w"); if (theReleaseCrashLogFile) @@ -794,6 +834,8 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m) return; } + TriggerMiniDump(); + UnicodeString prompt = TheGameText->fetch(p); UnicodeString mesg = TheGameText->fetch(m); @@ -825,13 +867,24 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m) char prevbuf[ _MAX_PATH ]; char curbuf[ _MAX_PATH ]; - strcpy(prevbuf, TheGlobalData->getPath_UserData().str()); - strcat(prevbuf, RELEASECRASH_FILE_NAME_PREV); - strcpy(curbuf, TheGlobalData->getPath_UserData().str()); - strcat(curbuf, RELEASECRASH_FILE_NAME); + strlcpy(prevbuf, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(prevbuf)); + strlcat(prevbuf, RELEASECRASH_FILE_NAME_PREV, ARRAY_SIZE(prevbuf)); + strlcpy(curbuf, TheGlobalData->getPath_UserData().str(), ARRAY_SIZE(curbuf)); + strlcat(curbuf, RELEASECRASH_FILE_NAME, ARRAY_SIZE(curbuf)); remove(prevbuf); - rename(curbuf, prevbuf); + if (rename(curbuf, prevbuf) != 0) + { +#ifdef DEBUG_LOGGING + DebugLog("Warning: Could not rename buffer file '%s' to '%s'. Will remove instead", curbuf, prevbuf); +#endif + if (remove(curbuf) != 0) + { +#ifdef DEBUG_LOGGING + DebugLog("Warning: Failed to remove file '%s'", curbuf); +#endif + } + } theReleaseCrashLogFile = fopen(curbuf, "w"); if (theReleaseCrashLogFile) diff --git a/Core/GameEngine/Source/Common/System/File.cpp b/Core/GameEngine/Source/Common/System/File.cpp index 3efb660b6c..dfb60e80d3 100644 --- a/Core/GameEngine/Source/Common/System/File.cpp +++ b/Core/GameEngine/Source/Common/System/File.cpp @@ -48,9 +48,7 @@ #include "PreRTS.h" #include -#include #include -#include #include "Common/file.h" diff --git a/Core/GameEngine/Source/Common/System/FileSystem.cpp b/Core/GameEngine/Source/Common/System/FileSystem.cpp index a7fc8d2e90..46d468d4a0 100644 --- a/Core/GameEngine/Source/Common/System/FileSystem.cpp +++ b/Core/GameEngine/Source/Common/System/FileSystem.cpp @@ -171,27 +171,48 @@ void FileSystem::reset( void ) // FileSystem::open //============================================================================ -File* FileSystem::openFile( const Char *filename, Int access, size_t bufferSize ) +File* FileSystem::openFile( const Char *filename, Int access, size_t bufferSize, FileInstance instance ) { USE_PERF_TIMER(FileSystem) File *file = NULL; if ( TheLocalFileSystem != NULL ) { - file = TheLocalFileSystem->openFile( filename, access, bufferSize ); - -#if ENABLE_FILESYSTEM_EXISTENCE_CACHE - if (file != NULL && (file->getAccess() & File::CREATE)) + if (instance != 0) { - unsigned key = TheNameKeyGenerator->nameToLowercaseKey(filename); - m_fileExist[key] = true; + if (TheLocalFileSystem->doesFileExist(filename)) + { + --instance; + } } + else + { + file = TheLocalFileSystem->openFile( filename, access, bufferSize ); + +#if ENABLE_FILESYSTEM_EXISTENCE_CACHE + if (file != NULL && (file->getAccess() & File::CREATE)) + { + FastCriticalSectionClass::LockClass lock(m_fileExistMutex); + FileExistMap::iterator it = m_fileExist.find(FileExistMap::key_type::temporary(filename)); + if (it != m_fileExist.end()) + { + ++it->second.instanceExists; + if (it->second.instanceDoesNotExist != ~FileInstance(0)) + ++it->second.instanceDoesNotExist; + } + else + { + m_fileExist[filename]; + } + } #endif + } } if ( (TheArchiveFileSystem != NULL) && (file == NULL) ) { - file = TheArchiveFileSystem->openFile( filename ); + // TheSuperHackers @todo Pass 'access' here? + file = TheArchiveFileSystem->openFile( filename, 0, instance ); } return file; @@ -201,34 +222,59 @@ File* FileSystem::openFile( const Char *filename, Int access, size_t bufferSize // FileSystem::doesFileExist //============================================================================ -Bool FileSystem::doesFileExist(const Char *filename) const +Bool FileSystem::doesFileExist(const Char *filename, FileInstance instance) const { USE_PERF_TIMER(FileSystem) #if ENABLE_FILESYSTEM_EXISTENCE_CACHE - unsigned key=TheNameKeyGenerator->nameToLowercaseKey(filename); - std::map::iterator i=m_fileExist.find(key); - if (i!=m_fileExist.end()) - return i->second; + { + FastCriticalSectionClass::LockClass lock(m_fileExistMutex); + FileExistMap::const_iterator it = m_fileExist.find(FileExistMap::key_type::temporary(filename)); + if (it != m_fileExist.end()) + { + // Must test instanceDoesNotExist first! + if (instance >= it->second.instanceDoesNotExist) + return FALSE; + if (instance <= it->second.instanceExists) + return TRUE; + } + } #endif if (TheLocalFileSystem->doesFileExist(filename)) { + if (instance == 0) + { #if ENABLE_FILESYSTEM_EXISTENCE_CACHE - m_fileExist[key]=true; + { + FastCriticalSectionClass::LockClass lock(m_fileExistMutex); + m_fileExist[filename]; + } #endif - return TRUE; + return TRUE; + } + + --instance; } - if (TheArchiveFileSystem->doesFileExist(filename)) + + if (TheArchiveFileSystem->doesFileExist(filename, instance)) { #if ENABLE_FILESYSTEM_EXISTENCE_CACHE - m_fileExist[key]=true; + { + FastCriticalSectionClass::LockClass lock(m_fileExistMutex); + FileExistMap::mapped_type& value = m_fileExist[filename]; + value.instanceExists = max(value.instanceExists, instance); + } #endif return TRUE; } #if ENABLE_FILESYSTEM_EXISTENCE_CACHE - m_fileExist[key]=false; + { + FastCriticalSectionClass::LockClass lock(m_fileExistMutex); + FileExistMap::mapped_type& value = m_fileExist[filename]; + value.instanceDoesNotExist = min(value.instanceDoesNotExist, instance); + } #endif return FALSE; } @@ -239,26 +285,33 @@ Bool FileSystem::doesFileExist(const Char *filename) const 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); + TheLocalFileSystem->getFileListInDirectory(AsciiString::TheEmptyString, directory, searchName, filenameList, searchSubdirectories); + TheArchiveFileSystem->getFileListInDirectory(AsciiString::TheEmptyString, directory, searchName, filenameList, searchSubdirectories); } //============================================================================ // FileSystem::getFileInfo //============================================================================ -Bool FileSystem::getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const +Bool FileSystem::getFileInfo(const AsciiString& filename, FileInfo *fileInfo, FileInstance instance) const { USE_PERF_TIMER(FileSystem) + + // TheSuperHackers @todo Add file info cache? + if (fileInfo == NULL) { return FALSE; } memset(fileInfo, 0, sizeof(*fileInfo)); if (TheLocalFileSystem->getFileInfo(filename, fileInfo)) { - return TRUE; + if (instance == 0) { + return TRUE; + } + + --instance; } - if (TheArchiveFileSystem->getFileInfo(filename, fileInfo)) { + if (TheArchiveFileSystem->getFileInfo(filename, fileInfo, instance)) { return TRUE; } @@ -358,7 +411,7 @@ void FileSystem::unloadMusicFilesFromCD() //============================================================================ // FileSystem::normalizePath //============================================================================ -AsciiString FileSystem::normalizePath(const AsciiString& path) const +AsciiString FileSystem::normalizePath(const AsciiString& path) { return TheLocalFileSystem->normalizePath(path); } diff --git a/Core/GameEngine/Source/Common/System/GameMemory.cpp b/Core/GameEngine/Source/Common/System/GameMemory.cpp index 81d70b9d55..2ede5c780b 100644 --- a/Core/GameEngine/Source/Common/System/GameMemory.cpp +++ b/Core/GameEngine/Source/Common/System/GameMemory.cpp @@ -42,7 +42,7 @@ // // ---------------------------------------------------------------------------- -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine // SYSTEM INCLUDES @@ -2681,7 +2681,7 @@ MemoryPool *MemoryPoolFactory::findMemoryPool(const char *poolName) { for (MemoryPool *pool = m_firstPoolInFactory; pool; pool = pool->getNextPoolInList()) { - if (!strcmp(poolName, pool->getPoolName())) + if (strcmp(poolName, pool->getPoolName()) == 0) { DEBUG_ASSERTCRASH(poolName == pool->getPoolName(), ("hmm, ptrs should probably match here")); return pool; @@ -2975,8 +2975,8 @@ void MemoryPoolFactory::memoryPoolUsageReport( const char* filename, FILE *appen if( !appendToFileInstead ) { char tmp[256]; - strcpy(tmp,filename); - strcat(tmp,".csv"); + strlcpy(tmp, filename, ARRAY_SIZE(tmp)); + strlcat(tmp, ".csv", ARRAY_SIZE(tmp)); perfStatsFile = fopen(tmp, "w"); } else diff --git a/Core/GameEngine/Source/Common/System/GameMemoryInit.cpp b/Core/GameEngine/Source/Common/System/GameMemoryInit.cpp index 3f559fbdd0..d25872b98c 100644 --- a/Core/GameEngine/Source/Common/System/GameMemoryInit.cpp +++ b/Core/GameEngine/Source/Common/System/GameMemoryInit.cpp @@ -41,7 +41,7 @@ // Desc: Memory manager // // ---------------------------------------------------------------------------- -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine // SYSTEM INCLUDES @@ -113,17 +113,11 @@ void userMemoryManagerInitPools() // we expect. so do it the hard way. char buf[_MAX_PATH]; ::GetModuleFileName(NULL, buf, sizeof(buf)); - char* pEnd = buf + strlen(buf); - while (pEnd != buf) + if (char* pEnd = strrchr(buf, '\\')) { - if (*pEnd == '\\') - { - *pEnd = 0; - break; - } - --pEnd; + *pEnd = 0; } - strcat(buf, "\\Data\\INI\\MemoryPools.ini"); + strlcat(buf, "\\Data\\INI\\MemoryPools.ini", ARRAY_SIZE(buf)); FILE* fp = fopen(buf, "r"); if (fp) diff --git a/Core/GameEngine/Source/Common/System/LocalFile.cpp b/Core/GameEngine/Source/Common/System/LocalFile.cpp index f8047041a1..7ac8cd7a20 100644 --- a/Core/GameEngine/Source/Common/System/LocalFile.cpp +++ b/Core/GameEngine/Source/Common/System/LocalFile.cpp @@ -49,7 +49,6 @@ #include #include -#include #include #include #include diff --git a/Core/GameEngine/Source/Common/System/MiniDumper.cpp b/Core/GameEngine/Source/Common/System/MiniDumper.cpp new file mode 100644 index 0000000000..21ab80e578 --- /dev/null +++ b/Core/GameEngine/Source/Common/System/MiniDumper.cpp @@ -0,0 +1,461 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine + +#ifdef RTS_ENABLE_CRASHDUMP +#include "Common/MiniDumper.h" +#include +#include "gitinfo.h" + +// Globals for storing the pointer to the exception +_EXCEPTION_POINTERS* g_dumpException = NULL; +DWORD g_dumpExceptionThreadId = 0; + +MiniDumper* TheMiniDumper = NULL; + +// Globals containing state about the current exception that's used for context in the mini dump. +// These are populated by MiniDumper::DumpingExceptionFilter to store a copy of the exception in case it goes out of scope +_EXCEPTION_POINTERS g_exceptionPointers = { 0 }; +EXCEPTION_RECORD g_exceptionRecord = { 0 }; +CONTEXT g_exceptionContext = { 0 }; + +constexpr const char* DumpFileNamePrefix = "Crash"; + +void MiniDumper::initMiniDumper(const AsciiString& userDirPath) +{ + DEBUG_ASSERTCRASH(TheMiniDumper == NULL, ("MiniDumper::initMiniDumper called on already created instance")); + + // Use placement new on the process heap so TheMiniDumper is placed outside the MemoryPoolFactory managed area. + // If the crash is due to corrupted MemoryPoolFactory structures, try to mitigate the chances of MiniDumper memory also being corrupted + TheMiniDumper = new (::HeapAlloc(::GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(MiniDumper))) MiniDumper; + TheMiniDumper->Initialize(userDirPath); +} + +void MiniDumper::shutdownMiniDumper() +{ + if (TheMiniDumper) + { + TheMiniDumper->ShutDown(); + TheMiniDumper->~MiniDumper(); + ::HeapFree(::GetProcessHeap(), NULL, TheMiniDumper); + TheMiniDumper = NULL; + } +} + +MiniDumper::MiniDumper() +{ + m_miniDumpInitialized = false; + m_loadedDbgHelp = false; + m_requestedDumpType = DumpType_Minimal; + m_dumpRequested = NULL; + m_dumpComplete = NULL; + m_quitting = NULL; + m_dumpThread = NULL; + m_dumpThreadId = 0; + m_dumpDir[0] = 0; + m_dumpFile[0] = 0; + m_executablePath[0] = 0; +}; + +LONG WINAPI MiniDumper::DumpingExceptionFilter(_EXCEPTION_POINTERS* e_info) +{ + // Store the exception info in the global variables for later use by the dumping thread + g_exceptionRecord = *(e_info->ExceptionRecord); + g_exceptionContext = *(e_info->ContextRecord); + g_exceptionPointers.ContextRecord = &g_exceptionContext; + g_exceptionPointers.ExceptionRecord = &g_exceptionRecord; + g_dumpException = &g_exceptionPointers; + + return EXCEPTION_EXECUTE_HANDLER; +} + +void MiniDumper::TriggerMiniDump(DumpType dumpType) +{ + if (!m_miniDumpInitialized) + { + DEBUG_LOG(("MiniDumper::TriggerMiniDump: Attempted to use an uninitialized instance.")); + return; + } + + __try + { + // Use DebugBreak to raise an exception that can be caught in the __except block + ::DebugBreak(); + } + __except (DumpingExceptionFilter(GetExceptionInformation())) + { + TriggerMiniDumpForException(g_dumpException, dumpType); + } +} + +void MiniDumper::TriggerMiniDumpForException(_EXCEPTION_POINTERS* e_info, DumpType dumpType) +{ + if (!m_miniDumpInitialized) + { + DEBUG_LOG(("MiniDumper::TriggerMiniDumpForException: Attempted to use an uninitialized instance.")); + return; + } + + g_dumpException = e_info; + g_dumpExceptionThreadId = ::GetCurrentThreadId(); + m_requestedDumpType = dumpType; + + DEBUG_ASSERTCRASH(IsDumpThreadStillRunning(), ("MiniDumper::TriggerMiniDumpForException: Dumping thread has exited.")); + ::SetEvent(m_dumpRequested); + DWORD wait = ::WaitForSingleObject(m_dumpComplete, INFINITE); + if (wait != WAIT_OBJECT_0) + { + if (wait == WAIT_FAILED) + { + DEBUG_LOG(("MiniDumper::TriggerMiniDumpForException: Waiting for minidump triggering failed: status=%u, error=%u", wait, ::GetLastError())); + } + else + { + DEBUG_LOG(("MiniDumper::TriggerMiniDumpForException: Waiting for minidump triggering failed: status=%u", wait)); + } + } + + ::ResetEvent(m_dumpComplete); +} + +void MiniDumper::Initialize(const AsciiString& userDirPath) +{ + m_loadedDbgHelp = DbgHelpLoader::load(); + + // We want to only use the dbghelp.dll from the OS installation, as the one bundled with the game does not support MiniDump functionality + if (!(m_loadedDbgHelp && DbgHelpLoader::isLoadedFromSystem())) + { + DEBUG_LOG(("MiniDumper::Initialize: Unable to load system-provided dbghelp.dll, minidump functionality disabled.")); + return; + } + + DWORD executableSize = ::GetModuleFileNameW(NULL, m_executablePath, ARRAY_SIZE(m_executablePath)); + if (executableSize == 0 || executableSize == ARRAY_SIZE(m_executablePath)) + { + DEBUG_LOG(("MiniDumper::Initialize: Could not get executable file name. Returned value=%u", executableSize)); + return; + } + + // Create & store dump folder + if (!InitializeDumpDirectory(userDirPath)) + { + return; + } + + m_dumpRequested = CreateEvent(NULL, TRUE, FALSE, NULL); + m_dumpComplete = CreateEvent(NULL, TRUE, FALSE, NULL); + m_quitting = CreateEvent(NULL, TRUE, FALSE, NULL); + + if (m_dumpRequested == NULL || m_dumpComplete == NULL || m_quitting == NULL) + { + // Something went wrong with the creation of the events.. + DEBUG_LOG(("MiniDumper::Initialize: Unable to create events: error=%u", ::GetLastError())); + return; + } + + m_dumpThread = ::CreateThread(NULL, 0, MiniDumpThreadProc, this, CREATE_SUSPENDED, &m_dumpThreadId); + if (!m_dumpThread) + { + DEBUG_LOG(("MiniDumper::Initialize: Unable to create thread: error=%u", ::GetLastError())); + return; + } + + if (::ResumeThread(m_dumpThread) != 1) + { + DEBUG_LOG(("MiniDumper::Initialize: Unable to resume thread: error=%u", ::GetLastError())); + return; + } + + DEBUG_LOG(("MiniDumper::Initialize: Configured to store crash dumps in '%s'", m_dumpDir)); + m_miniDumpInitialized = true; +} + +Bool MiniDumper::IsInitialized() const +{ + return m_miniDumpInitialized; +} + +Bool MiniDumper::IsDumpThreadStillRunning() const +{ + DWORD exitCode; + if (m_dumpThread != NULL && ::GetExitCodeThread(m_dumpThread, &exitCode) && exitCode == STILL_ACTIVE) + { + return true; + } + + return false; +} + +Bool MiniDumper::InitializeDumpDirectory(const AsciiString& userDirPath) +{ + constexpr const Int MaxFullFileCount = 2; + constexpr const Int MaxMiniFileCount = 10; + + strlcpy(m_dumpDir, userDirPath.str(), ARRAY_SIZE(m_dumpDir)); + strlcat(m_dumpDir, "CrashDumps\\", ARRAY_SIZE(m_dumpDir)); + if (::_access(m_dumpDir, 0) != 0) + { + if (!::CreateDirectory(m_dumpDir, NULL)) + { + DEBUG_LOG(("MiniDumper::Initialize: Unable to create path for crash dumps at '%s': error=%u", m_dumpDir, ::GetLastError())); + return false; + } + } + + // Clean up old files (we keep a maximum of 10 small, 2 full) + KeepNewestFiles(m_dumpDir, DumpType_Full, MaxFullFileCount); + KeepNewestFiles(m_dumpDir, DumpType_Minimal, MaxMiniFileCount); + + return true; +} + +void MiniDumper::ShutdownDumpThread() +{ + if (IsDumpThreadStillRunning()) + { + DEBUG_ASSERTCRASH(m_quitting != NULL, ("MiniDumper::ShutdownDumpThread: Dump thread still running despite m_quitting being NULL")); + ::SetEvent(m_quitting); + + DWORD waitRet = ::WaitForSingleObject(m_dumpThread, 3000); + switch (waitRet) + { + case WAIT_OBJECT_0: + // Wait for thread exit was successful + break; + case WAIT_TIMEOUT: + DEBUG_LOG(("MiniDumper::ShutdownDumpThread: Waiting for dumping thread to exit timed out, killing thread", waitRet)); + ::TerminateThread(m_dumpThread, MiniDumperExitCode_ForcedTerminate); + break; + case WAIT_FAILED: + DEBUG_LOG(("MiniDumper::ShutdownDumpThread: Waiting for minidump triggering failed: status=%u, error=%u", waitRet, ::GetLastError())); + break; + default: + DEBUG_LOG(("MiniDumper::ShutdownDumpThread: Waiting for minidump triggering failed: status=%u", waitRet)); + break; + } + } +} + +void MiniDumper::ShutDown() +{ + ShutdownDumpThread(); + + if (m_dumpThread != NULL) + { + DEBUG_ASSERTCRASH(!IsDumpThreadStillRunning(), ("MiniDumper::ShutDown: ShutdownDumpThread() was unable to stop Dump thread")); + ::CloseHandle(m_dumpThread); + m_dumpThread = NULL; + } + + if (m_quitting != NULL) + { + ::CloseHandle(m_quitting); + m_quitting = NULL; + } + + if (m_dumpComplete != NULL) + { + ::CloseHandle(m_dumpComplete); + m_dumpComplete = NULL; + } + + if (m_dumpRequested != NULL) + { + ::CloseHandle(m_dumpRequested); + m_dumpRequested = NULL; + } + + if (m_loadedDbgHelp) + { + DbgHelpLoader::unload(); + m_loadedDbgHelp = false; + } + + m_miniDumpInitialized = false; +} + +DWORD MiniDumper::ThreadProcInternal() +{ + while (true) + { + HANDLE waitEvents[2] = { m_dumpRequested, m_quitting }; + DWORD event = ::WaitForMultipleObjects(ARRAY_SIZE(waitEvents), waitEvents, FALSE, INFINITE); + switch (event) + { + case WAIT_OBJECT_0 + 0: + // A dump is requested (m_dumpRequested) + ::ResetEvent(m_dumpComplete); + CreateMiniDump(m_requestedDumpType); + ::ResetEvent(m_dumpRequested); + ::SetEvent(m_dumpComplete); + break; + case WAIT_OBJECT_0 + 1: + // Quit (m_quitting) + return MiniDumperExitCode_Success; + case WAIT_FAILED: + DEBUG_LOG(("MiniDumper::ThreadProcInternal: Waiting for events failed: status=%u, error=%u", event, ::GetLastError())); + return MiniDumperExitCode_FailureWait; + default: + DEBUG_LOG(("MiniDumper::ThreadProcInternal: Waiting for events failed: status=%u", event)); + return MiniDumperExitCode_FailureWait; + } + } +} + +DWORD WINAPI MiniDumper::MiniDumpThreadProc(LPVOID lpParam) +{ + if (lpParam == NULL) + { + DEBUG_LOG(("MiniDumper::MiniDumpThreadProc: The provided parameter was NULL, exiting thread.")); + return MiniDumperExitCode_FailureParam; + } + + MiniDumper* dumper = static_cast(lpParam); + return dumper->ThreadProcInternal(); +} + + +void MiniDumper::CreateMiniDump(DumpType dumpType) +{ + // Create a unique dump file name, using the path from m_dumpDir, in m_dumpFile + SYSTEMTIME sysTime; + ::GetLocalTime(&sysTime); +#if RTS_GENERALS + const Char product = 'G'; +#elif RTS_ZEROHOUR + const Char product = 'Z'; +#endif + Char dumpTypeSpecifier = static_cast(dumpType); + DWORD currentProcessId = ::GetCurrentProcessId(); + + // m_dumpDir is stored with trailing backslash in Initialize + snprintf(m_dumpFile, ARRAY_SIZE(m_dumpFile), "%s%s%c%c-%04d%02d%02d-%02d%02d%02d-%s-pid%ld.dmp", + m_dumpDir, DumpFileNamePrefix, dumpTypeSpecifier, product, sysTime.wYear, sysTime.wMonth, + sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond, + GitShortSHA1, currentProcessId); + + HANDLE dumpFile = ::CreateFile(m_dumpFile, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + if (dumpFile == NULL || dumpFile == INVALID_HANDLE_VALUE) + { + DEBUG_LOG(("MiniDumper::CreateMiniDump: Unable to create dump file '%s': error=%u", m_dumpFile, ::GetLastError())); + return; + } + + PMINIDUMP_EXCEPTION_INFORMATION exceptionInfoPtr = NULL; + MINIDUMP_EXCEPTION_INFORMATION exceptionInfo = { 0 }; + if (g_dumpException != NULL) + { + exceptionInfo.ExceptionPointers = g_dumpException; + exceptionInfo.ThreadId = g_dumpExceptionThreadId; + exceptionInfo.ClientPointers = FALSE; + exceptionInfoPtr = &exceptionInfo; + } + + int dumpTypeFlags = MiniDumpNormal; + switch (dumpType) + { + case DumpType_Full: + dumpTypeFlags |= MiniDumpWithFullMemory | MiniDumpWithDataSegs | MiniDumpWithHandleData | + MiniDumpWithThreadInfo | MiniDumpWithFullMemoryInfo | MiniDumpWithPrivateReadWriteMemory; + FALLTHROUGH; + case DumpType_Minimal: + dumpTypeFlags |= MiniDumpWithIndirectlyReferencedMemory | MiniDumpScanMemory; + break; + } + + MINIDUMP_TYPE miniDumpType = static_cast(dumpTypeFlags); + BOOL success = DbgHelpLoader::miniDumpWriteDump( + ::GetCurrentProcess(), + currentProcessId, + dumpFile, + miniDumpType, + exceptionInfoPtr, + NULL, + NULL); + + if (!success) + { + DEBUG_LOG(("MiniDumper::CreateMiniDump: Unable to write minidump file '%s': error=%u", m_dumpFile, ::GetLastError())); + } + else + { + DEBUG_LOG(("MiniDumper::CreateMiniDump: Successfully wrote minidump file to '%s'", m_dumpFile)); + } + + ::CloseHandle(dumpFile); +} + +// Comparator for sorting files by last modified time (newest first) +bool MiniDumper::CompareByLastWriteTime(const FileInfo& a, const FileInfo& b) +{ + return ::CompareFileTime(&a.lastWriteTime, &b.lastWriteTime) > 0; +} + +void MiniDumper::KeepNewestFiles(const std::string& directory, const DumpType dumpType, const Int keepCount) +{ + // directory already contains trailing backslash + std::string searchPath = directory + DumpFileNamePrefix + static_cast(dumpType) + "*"; + WIN32_FIND_DATA findData; + HANDLE hFind = ::FindFirstFile(searchPath.c_str(), &findData); + + if (hFind == INVALID_HANDLE_VALUE) + { + if (::GetLastError() != ERROR_FILE_NOT_FOUND) + { + DEBUG_LOG(("MiniDumper::KeepNewestFiles: Unable to find files in directory '%s': error=%u", searchPath.c_str(), ::GetLastError())); + } + + return; + } + + std::vector files; + do + { + if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) + { + continue; + } + + // Store file info + FileInfo fileInfo; + fileInfo.name = directory + findData.cFileName; + fileInfo.lastWriteTime = findData.ftLastWriteTime; + files.push_back(fileInfo); + + } while (::FindNextFile(hFind, &findData)); + + ::FindClose(hFind); + + // Sort files by last modified time in descending order + std::sort(files.begin(), files.end(), CompareByLastWriteTime); + + // Delete files beyond the newest keepCount + for (size_t i = keepCount; i < files.size(); ++i) + { + if (::DeleteFile(files[i].name.c_str())) + { + DEBUG_LOG(("MiniDumper::KeepNewestFiles: Deleted old dump file '%s'.", files[i].name.c_str())); + } + else + { + DEBUG_LOG(("MiniDumper::KeepNewestFiles: Failed to delete file '%s': error=%u", files[i].name.c_str(), ::GetLastError())); + } + } +} +#endif diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/ObjectStatusTypes.cpp b/Core/GameEngine/Source/Common/System/ObjectStatusTypes.cpp similarity index 90% rename from GeneralsMD/Code/GameEngine/Source/Common/System/ObjectStatusTypes.cpp rename to Core/GameEngine/Source/Common/System/ObjectStatusTypes.cpp index 4e5f9442f3..ab689ad343 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/ObjectStatusTypes.cpp +++ b/Core/GameEngine/Source/Common/System/ObjectStatusTypes.cpp @@ -33,7 +33,7 @@ #include "Common/BitFlagsIO.h" template<> -const char* ObjectStatusMaskType::s_bitNameList[] = +const char* const ObjectStatusMaskType::s_bitNameList[] = { "NONE", "DESTROYED", @@ -64,6 +64,7 @@ const char* ObjectStatusMaskType::s_bitNameList[] = "NO_ATTACK_FROM_AI", "IGNORING_STEALTH", "IS_CARBOMB", + // TheSuperHackers @info New statuses added in Zero Hour "DECK_HEIGHT_OFFSET", "STATUS_RIDER1", "STATUS_RIDER2", @@ -82,5 +83,6 @@ const char* ObjectStatusMaskType::s_bitNameList[] = "DEPLOYED", NULL }; +static_assert(ARRAY_SIZE(ObjectStatusMaskType::s_bitNameList) == ObjectStatusMaskType::NumBits + 1, "Incorrect array size"); ObjectStatusMaskType OBJECT_STATUS_MASK_NONE; // inits to all zeroes diff --git a/Core/GameEngine/Source/Common/System/RAMFile.cpp b/Core/GameEngine/Source/Common/System/RAMFile.cpp index 474e59f906..93d5994b45 100644 --- a/Core/GameEngine/Source/Common/System/RAMFile.cpp +++ b/Core/GameEngine/Source/Common/System/RAMFile.cpp @@ -47,10 +47,8 @@ #include "PreRTS.h" -#include #include #include -#include #include #include "Common/AsciiString.h" @@ -106,10 +104,7 @@ RAMFile::RAMFile() : m_size(0), m_data(NULL), -//Added By Sadullah Nader -//Initializtion(s) inserted m_pos(0) -// { } @@ -216,10 +211,7 @@ Bool RAMFile::openFromArchive(File *archiveFile, const AsciiString& filename, In return FALSE; } - if (m_data != NULL) { - delete[] m_data; - m_data = NULL; - } + delete[] m_data; m_data = MSGNEW("RAMFILE") Char [size]; // pool[]ify m_size = size; diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp b/Core/GameEngine/Source/Common/System/Radar.cpp similarity index 85% rename from GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp rename to Core/GameEngine/Source/Common/System/Radar.cpp index 5344b9d942..86ac2046b8 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/Radar.cpp +++ b/Core/GameEngine/Source/Common/System/Radar.cpp @@ -28,10 +28,11 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/GameAudio.h" #include "Common/GameState.h" +#include "Common/GameUtility.h" #include "Common/MiscAudio.h" #include "Common/Radar.h" #include "Common/Player.h" @@ -61,57 +62,35 @@ Radar *TheRadar = NULL; ///< the radar global singleton #define RADAR_QUEUE_TERRAIN_REFRESH_DELAY (LOGICFRAMES_PER_SECOND * 3.0f) //------------------------------------------------------------------------------------------------- -/** Delete list resources used by the radar and return them to the memory pools */ //------------------------------------------------------------------------------------------------- -void Radar::deleteListResources( void ) +void Radar::deleteList( RadarObject **list ) { - RadarObject *nextObject; - - // delete entries from the local object list - while( m_localObjectList ) + while( *list ) { + RadarObject *nextObject = (*list)->friend_getNext(); + (*list)->friend_getObject()->friend_setRadarData( NULL ); + deleteInstance(*list); + *list = nextObject; + } +} - // get next object - nextObject = m_localObjectList->friend_getNext(); - - // remove radar data from object - m_localObjectList->friend_getObject()->friend_setRadarData( NULL ); - - // delete the head of the list - deleteInstance(m_localObjectList); - - // set head of the list to the next object - m_localObjectList = nextObject; - - } // end while - - // delete entries from the regular object list - while( m_objectList ) - { - - // get next object - nextObject = m_objectList->friend_getNext(); - - // remove radar data from object - m_objectList->friend_getObject()->friend_setRadarData( NULL ); - - // delete the head of the list - deleteInstance(m_objectList); - - // set head of the list to the next object - m_objectList = nextObject; - - } // end while +//------------------------------------------------------------------------------------------------- +/** Delete list resources used by the radar and return them to the memory pools */ +//------------------------------------------------------------------------------------------------- +void Radar::deleteListResources( void ) +{ + deleteList(&m_objectList); + deleteList(&m_localObjectList); + deleteList(&m_localHeroObjectList); - Object *obj; - for( obj = TheGameLogic->getFirstObject(); obj; obj = obj->getNextObject() ) +#ifdef DEBUG_CRASHING + for( Object *obj = TheGameLogic->getFirstObject(); obj; obj = obj->getNextObject() ) { - - DEBUG_ASSERTCRASH( obj->friend_getRadarData() == NULL, ("oops") ); - + DEBUG_ASSERTCRASH( obj->friend_getRadarData() == NULL, + ("Radar::deleteListResources: Unexpectedly an object still has radar data assigned") ); } - -} // end deleteListResources +#endif +} // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------------------------- @@ -156,7 +135,7 @@ Bool RadarObject::isTemporarilyHidden(const Object* obj) void RadarObject::crc( Xfer *xfer ) { -} // end crc +} // ------------------------------------------------------------------------------------------------ /** Xfer method @@ -185,17 +164,17 @@ void RadarObject::xfer( Xfer *xfer ) DEBUG_CRASH(( "RadarObject::xfer - Unable to find object for radar data" )); throw SC_INVALID_DATA; - } // end if + } // tell the object we now have some radar data m_object->friend_setRadarData( this ); - } // end if + } // color xfer->xferColor( &m_color ); -} // end xfer +} // ------------------------------------------------------------------------------------------------ /** Load post process */ @@ -203,7 +182,7 @@ void RadarObject::xfer( Xfer *xfer ) void RadarObject::loadPostProcess( void ) { -} // end loadPostProcess +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -213,8 +192,9 @@ Radar::Radar( void ) m_radarWindow = NULL; m_objectList = NULL; m_localObjectList = NULL; - m_radarHidden = false; - m_radarForceOn = false; + m_localHeroObjectList = NULL; + std::fill(m_radarHidden, m_radarHidden + ARRAY_SIZE(m_radarHidden), false); + std::fill(m_radarForceOn, m_radarForceOn + ARRAY_SIZE(m_radarForceOn), false); m_terrainAverageZ = 0.0f; m_waterAverageZ = 0.0f; m_xSample = 0.0f; @@ -230,7 +210,7 @@ Radar::Radar( void ) // clear the radar events clearAllEvents(); -} // end Radar +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -240,7 +220,7 @@ Radar::~Radar( void ) // delete list resources deleteListResources(); -} // end ~Radar +} //------------------------------------------------------------------------------------------------- /** Clear all radar events */ @@ -274,9 +254,9 @@ void Radar::clearAllEvents( void ) m_event[ i ].radarLoc.y = 0; m_event[ i ].soundPlayed = FALSE; - } // end for i + } -} // end clearAllEvents +} //------------------------------------------------------------------------------------------------- /** Reset radar data */ @@ -290,10 +270,13 @@ void Radar::reset( void ) // clear all events clearAllEvents(); + // TheSuperHackers @todo Reset m_radarHidden? + //std::fill(m_radarHidden, m_radarHidden + ARRAY_SIZE(m_radarHidden), false); + // stop forcing the radar on - m_radarForceOn = false; + std::fill(m_radarForceOn, m_radarForceOn + ARRAY_SIZE(m_radarForceOn), false); -} // end reset +} //------------------------------------------------------------------------------------------------- /** Radar per frame update */ @@ -315,7 +298,7 @@ void Radar::update( void ) thisFrame > m_event[ i ].dieFrame ) m_event[ i ].active = FALSE; - } // end for i + } // see if we should refresh the terrain if( m_queueTerrainRefreshFrame != 0 && @@ -325,9 +308,9 @@ void Radar::update( void ) // refresh the terrain refreshTerrain( TheTerrainLogic ); - } // end if + } -} // end update +} //------------------------------------------------------------------------------------------------- /** Reset the radar for the new map data being given to it */ @@ -358,15 +341,15 @@ void Radar::newMap( TerrainLogic *terrain ) m_waterAverageZ = 0.0f; Coord3D worldPoint; - // since we're averaging let's skip every second sample... - worldPoint.y=0; + // since we're averaging let's skip every second sample... + worldPoint.y=0; for( y = 0; y < RADAR_CELL_HEIGHT; y+=2, worldPoint.y+=2.0*m_ySample ) - { - worldPoint.x=0; - for( x = 0; x < RADAR_CELL_WIDTH; x+=2, worldPoint.x+=2.0*m_xSample ) + { + worldPoint.x=0; + for( x = 0; x < RADAR_CELL_WIDTH; x+=2, worldPoint.x+=2.0*m_xSample ) { // don't use this, we don't really need the - // Z position by this function... radarToWorld( &radarPoint, &worldPoint ); + // Z position by this function... radarToWorld( &radarPoint, &worldPoint ); // and this is done by isUnderwater anyway: z = terrain->getGroundHeight( worldPoint.x, worldPoint.y ); Real z,waterZ; if( terrain->isUnderwater( worldPoint.x, worldPoint.y, &waterZ, &z ) ) @@ -379,9 +362,8 @@ void Radar::newMap( TerrainLogic *terrain ) m_terrainAverageZ += z; terrainSamples++; } - - } // end for x - } + } + } // avoid divide by zeros if( terrainSamples == 0 ) @@ -393,19 +375,19 @@ void Radar::newMap( TerrainLogic *terrain ) m_terrainAverageZ = m_terrainAverageZ / INT_TO_REAL( terrainSamples ); m_waterAverageZ = m_waterAverageZ / INT_TO_REAL( waterSamples ); -} // end newMap +} //------------------------------------------------------------------------------------------------- /** Add an object to the radar list. The object will be sorted in the list to be grouped * using it's radar priority */ //------------------------------------------------------------------------------------------------- -RadarObjectType Radar::addObject( Object *obj ) +Bool Radar::addObject( Object *obj ) { // get the radar priority for this object RadarPriorityType newPriority = obj->getRadarPriority(); if( isPriorityVisible( newPriority ) == FALSE ) - return RadarObjectType_None; + return FALSE; // if this object is on the radar, remove it in favor of the new add RadarObject **list; @@ -423,141 +405,32 @@ RadarObjectType Radar::addObject( Object *obj ) newObj->friend_setObject( obj ); // set color for this object on the radar - const Player *player = obj->getControllingPlayer(); - Bool useIndicatorColor = true; - - if( obj->isKindOf( KINDOF_DISGUISER ) ) - { - //Because we have support for disguised units pretending to be units from another - //team, we need to intercept it here and make sure it's rendered appropriately - //based on which client is rendering it. - StealthUpdate *update = obj->getStealth(); - if( update ) - { - if( update->isDisguised() ) - { - Player *clientPlayer = ThePlayerList->getLocalPlayer(); - Player *disguisedPlayer = ThePlayerList->getNthPlayer( update->getDisguisedPlayerIndex() ); - if( player->getRelationship( clientPlayer->getDefaultTeam() ) != ALLIES && clientPlayer->isPlayerActive() ) - { - //Neutrals and enemies will see this disguised unit as the team it's disguised as. - player = disguisedPlayer; - if( player ) - useIndicatorColor = false; - } - //Otherwise, the color will show up as the team it really belongs to (already set above). - } - } - } - - if( obj->getContain() ) - { - // To handle Stealth garrison, ask containers what color they are drawing with to the local player. - // Local is okay because radar display is not synced. - player = obj->getContain()->getApparentControllingPlayer( ThePlayerList->getLocalPlayer() ); - if( player ) - useIndicatorColor = false; - } - - if( useIndicatorColor || (player == NULL) ) - { - newObj->setColor( obj->getIndicatorColor() ); - } - else - { - newObj->setColor( player->getPlayerColor() ); - } + assignObjectColorToRadarObject( newObj, obj ); // set a chunk of radar data in the object obj->friend_setRadarData( newObj ); - RadarObjectType objectType; // // we will put this on either the local object list for objects that belong to the // local player, or on the regular object list for all other objects // if( obj->isLocallyControlled() ) { - list = &m_localObjectList; - objectType = RadarObjectType_Local; + if ( obj->isHero() ) + list = &m_localHeroObjectList; + else + list = &m_localObjectList; } else { list = &m_objectList; - objectType = RadarObjectType_Regular; } // link object to master list at the head of it's priority section - if( *list == NULL ) - *list = newObj; // trivial case, an empty list - else - { - RadarPriorityType prevPriority, currPriority; - RadarObject *currObject, *prevObject, *nextObject; - - prevObject = NULL; - prevPriority = RADAR_PRIORITY_INVALID; - for( currObject = *list; currObject; currObject = nextObject ) - { - - // get the next object - nextObject = currObject->friend_getNext(); - - // get the priority of this entry in the list (currPriority) - currPriority = currObject->friend_getObject()->getRadarPriority(); - - // - // if there is no previous object, or the previous priority is less than the - // our new priority, and the current object in the list has a priority - // higher than our equal to our own we need to be inserted here - // - if( (prevObject == NULL || prevPriority < newPriority ) && - (currPriority >= newPriority) ) - { - - // insert into the list just ahead of currObject - if( prevObject ) - { - - // the new entry next points to what the previous one used to point to - newObj->friend_setNext( prevObject->friend_getNext() ); - - // the previous one next now points to the new entry - prevObject->friend_setNext( newObj ); - - } // end if - else - { - - // the new object next points to the current object - newObj->friend_setNext( currObject ); - - // new list head is now newObj - *list = newObj; - - } // end else - - break; // exit for, stop the insert - - } // end if - else if( nextObject == NULL ) - { + linkRadarObject(newObj, list); - // at the end of the list, put object here - currObject->friend_setNext( newObj ); - - } // end else if - - // our current object is now the previous object - prevObject = currObject; - prevPriority = currPriority; - - } // end if - - } // end else - - return objectType; -} // end addObject + return TRUE; +} //------------------------------------------------------------------------------------------------- /** Try to delete an object from a specific list */ @@ -588,42 +461,42 @@ Bool Radar::deleteFromList( Object *obj, RadarObject **list ) // all done, object found and deleted return TRUE; - } // end if + } // save this object as previous one encountered in the list prevObject = radarObject; - } // end for, radarObject + } // object was not found in this list return FALSE; -} // end deleteFromList +} //------------------------------------------------------------------------------------------------- /** Remove an object from the radar, the object may reside in any list */ //------------------------------------------------------------------------------------------------- -RadarObjectType Radar::removeObject( Object *obj ) +Bool Radar::removeObject( Object *obj ) { // sanity if( obj->friend_getRadarData() == NULL ) - return RadarObjectType_None; + return FALSE; + if( deleteFromList( obj, &m_localHeroObjectList ) == TRUE ) + return TRUE; if( deleteFromList( obj, &m_localObjectList ) == TRUE ) - return RadarObjectType_Local; + return TRUE; else if( deleteFromList( obj, &m_objectList ) == TRUE ) - return RadarObjectType_Regular; + return TRUE; else { - - // sanity DEBUG_ASSERTCRASH( 0, ("Radar: Tried to remove object '%s' which was not found", obj->getTemplate()->getName().str()) ); - return RadarObjectType_None; - } // end else + return FALSE; + } -} // end removeObject +} //------------------------------------------------------------------------------------------------- /** Translate a 2D spot on the radar (from (0,0) to (RADAR_CELL_WIDTH,RADAR_CELL_HEIGHT) @@ -675,7 +548,7 @@ Bool Radar::radarToWorld( const ICoord2D *radar, Coord3D *world ) return TRUE; // valid translation -} // end radarToWorld +} //------------------------------------------------------------------------------------------------- /** Translate a point in the world to the 2D radar (x,y) @@ -715,7 +588,7 @@ Bool Radar::worldToRadar( const Coord3D *world, ICoord2D *radar ) return TRUE; // valid translation -} // end worldToRadar +} // ------------------------------------------------------------------------------------------------ /** Translate an actual pixel location (relative pixel with (0,0) being the top left of @@ -767,7 +640,7 @@ Bool Radar::localPixelToRadar( const ICoord2D *pixel, ICoord2D *radar ) radar->y = (size.y - radar->y) * RADAR_CELL_HEIGHT / size.y; - } // end if + } else { @@ -783,11 +656,11 @@ Bool Radar::localPixelToRadar( const ICoord2D *pixel, ICoord2D *radar ) // radar->y = (size.y - pixel->y) * RADAR_CELL_HEIGHT / size.y; - } // end else + } return TRUE; -} // end localPixelToRadar +} // ------------------------------------------------------------------------------------------------ /** Translate a screen mouse position to world coords if the screen position is within @@ -819,7 +692,7 @@ Bool Radar::screenPixelToWorld( const ICoord2D *pixel, Coord3D *world ) // translate radar to world return radarToWorld( &radar, world ); -} // end screenPixelToWorld +} // ------------------------------------------------------------------------------------------------ /** Given the pixel coordinates, see if there is an object that is exactly in this @@ -845,17 +718,21 @@ Object *Radar::objectUnderRadarPixel( const ICoord2D *pixel ) // to the radar location // - // search the local object list - obj = searchListForRadarLocationMatch( m_localObjectList, &radar ); + // search the local hero object list + obj = searchListForRadarLocationMatch( m_localHeroObjectList, &radar ); + + // search the local object list if not found + if( obj == NULL ) + obj = searchListForRadarLocationMatch( m_localObjectList, &radar ); - // search all other objects if not found + // search all other objects if still not found if( obj == NULL ) obj = searchListForRadarLocationMatch( m_objectList, &radar ); // return the object found (if any) return obj; -} // end objectUnderRadarPixel +} // ------------------------------------------------------------------------------------------------ /** Search the object list for an object that maps to the given logical radar coords */ @@ -883,7 +760,7 @@ Object *Radar::searchListForRadarLocationMatch( RadarObject *listHead, ICoord2D DEBUG_CRASH(( "Radar::searchListForRadarLocationMatch - NULL object encountered in list" )); continue; - } // end if + } // convert object position to logical radar worldToRadar( obj->getPosition(), &radar ); @@ -895,12 +772,12 @@ Object *Radar::searchListForRadarLocationMatch( RadarObject *listHead, ICoord2D radar.y <= radarMatch->y + 1 ) return obj; - } // end for, radarObject + } // no match found return NULL; -} // end searchListForRadarLocationMatch +} // ------------------------------------------------------------------------------------------------ /** Given the RELATIVE SCREEN start X and Y, the width and height of the area to draw the whole @@ -957,7 +834,7 @@ void Radar::findDrawPositions( Int startX, Int startY, Int width, Int height, lr->x = width; lr->y = height - ul->y; - } // end if + } else if( m_mapExtent.height() > m_mapExtent.width() ) { @@ -978,7 +855,7 @@ void Radar::findDrawPositions( Int startX, Int startY, Int width, Int height, lr->x = width - ul->x; lr->y = height; - } // end else + } else { @@ -987,7 +864,7 @@ void Radar::findDrawPositions( Int startX, Int startY, Int width, Int height, lr->x = width; lr->y = height; - } // end else + } */ // make them pixel positions @@ -996,7 +873,7 @@ void Radar::findDrawPositions( Int startX, Int startY, Int width, Int height, lr->x += startX; lr->y += startY; -} // end findDrawPositions +} //------------------------------------------------------------------------------------------------- /** Radar color lookup table */ @@ -1046,9 +923,9 @@ void Radar::createEvent( const Coord3D *world, RadarEventType type, Real seconds color[ 1 ] = radarColorLookupTable[ i ].color2; break; - } // end if + } - } // end while + } // check for no match found in color table if( radarColorLookupTable[ i ].event == RADAR_EVENT_INVALID ) @@ -1060,12 +937,12 @@ void Radar::createEvent( const Coord3D *world, RadarEventType type, Real seconds color[ 0 ] = color1; color[ 1 ] = color2; - } // end if + } // call the internal method to create the event with these colors internalCreateEvent( world, type, secondsToLive, &color[ 0 ], &color[ 1 ] ); -} // end createEvent +} // ------------------------------------------------------------------------------------------------ /** Create radar event using a specific colors from the player */ @@ -1107,7 +984,7 @@ void Radar::createPlayerEvent( Player *player, const Coord3D *world, // create the events using these colors internalCreateEvent( world, type, secondsToLive, &color[ 0 ], &color[ 1 ] ); -} // end createPlayerEvent +} //------------------------------------------------------------------------------------------------- /** Create a new radar event */ @@ -1149,7 +1026,7 @@ void Radar::internalCreateEvent( const Coord3D *world, RadarEventType type, Real if( m_nextFreeRadarEvent >= MAX_RADAR_EVENTS ) m_nextFreeRadarEvent = 0; -} // end createEvent +} //------------------------------------------------------------------------------------------------- /** Get the last event position, if any. @@ -1167,11 +1044,11 @@ Bool Radar::getLastEventLoc( Coord3D *eventPos ) *eventPos = m_event[ m_lastRadarEvent ].worldLoc; return TRUE; - } // end if + } return FALSE; // no last event -} // end getLastEventLoc +} // ------------------------------------------------------------------------------------------------ /** Try to create a radar event for "we're under attack". This will be called every time @@ -1200,7 +1077,7 @@ void Radar::tryUnderAttackEvent( const Object *obj ) // UI feedback for being under attack (note that we display these messages and audio // queues even if we don't have a radar) // - Player *player = ThePlayerList->getLocalPlayer(); + Player *player = rts::getObservedOrLocalPlayer(); // create a message for the attack event if( obj->isKindOf( KINDOF_INFANTRY ) || obj->isKindOf( KINDOF_VEHICLE ) ) @@ -1225,13 +1102,13 @@ void Radar::tryUnderAttackEvent( const Object *obj ) unitAttackSound.setPlayerIndex(player->getPlayerIndex()); TheAudio->addAudioEvent( &unitAttackSound ); - } // end if + } else if( obj->isKindOf( KINDOF_STRUCTURE ) && obj->isKindOf( KINDOF_MP_COUNT_FOR_VICTORY ) ) { // play EVA. If its our object, play Base under attack. if (obj->getControllingPlayer()->isLocalPlayer()) TheEva->setShouldPlay(EVA_BaseUnderAttack); - else if (ThePlayerList->getLocalPlayer()->getRelationship(obj->getTeam()) == ALLIES) + else if (player->getRelationship(obj->getTeam()) == ALLIES) TheEva->setShouldPlay(EVA_AllyUnderAttack); // display message @@ -1242,7 +1119,7 @@ void Radar::tryUnderAttackEvent( const Object *obj ) structureAttackSound.setPlayerIndex(player->getPlayerIndex()); TheAudio->addAudioEvent( &structureAttackSound ); - } // end else if + } else { @@ -1254,11 +1131,11 @@ void Radar::tryUnderAttackEvent( const Object *obj ) underAttackSound.setPlayerIndex(player->getPlayerIndex()); TheAudio->addAudioEvent( &underAttackSound ); - } // end else + } - } // end if + } -} // end tryUnderAttackEvent +} // ------------------------------------------------------------------------------------------------ /** Try to create a radar event for "infiltration". @@ -1274,8 +1151,10 @@ void Radar::tryInfiltrationEvent( const Object *obj ) return; } + Player *player = rts::getObservedOrLocalPlayer(); + // We should only be warned against infiltrations that are taking place against us. - if( obj->getControllingPlayer() != ThePlayerList->getLocalPlayer() ) + if( obj->getControllingPlayer() != player ) return; // create the radar event @@ -1287,7 +1166,6 @@ void Radar::tryInfiltrationEvent( const Object *obj ) // UI feedback for being under attack (note that we display these messages and audio // queues even if we don't have a radar) // - Player *player = ThePlayerList->getLocalPlayer(); // display message TheInGameUI->message( "RADAR:Infiltration" ); @@ -1297,7 +1175,7 @@ void Radar::tryInfiltrationEvent( const Object *obj ) infiltrationWarningSound.setPlayerIndex(player->getPlayerIndex()); TheAudio->addAudioEvent( &infiltrationWarningSound ); -} // end tryInfiltrationEvent +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -1335,11 +1213,11 @@ Bool Radar::tryEvent( RadarEventType event, const Coord3D *pos ) if( currentFrame - m_event[ i ].createFrame < framesBetweenEvents ) return FALSE; // reject it - } // end if + } - } // end if + } - } // end for i + } // if we got here then we want to create a new event createEvent( pos, event ); @@ -1347,7 +1225,7 @@ Bool Radar::tryEvent( RadarEventType event, const Coord3D *pos ) // return TRUE for successfully created event return TRUE; -} // end tryEvent +} // ------------------------------------------------------------------------------------------------ @@ -1358,7 +1236,7 @@ void Radar::refreshTerrain( TerrainLogic *terrain ) // no future queue is valid now m_queueTerrainRefreshFrame = 0; -} // end refreshTerrain +} // ------------------------------------------------------------------------------------------------ /** Queue a refresh of the radar terrain, we have this so that if there is code that @@ -1379,7 +1257,7 @@ void Radar::queueTerrainRefresh( void ) // m_queueTerrainRefreshFrame = TheGameLogic->getFrame(); -} // end queueTerrainRefresh +} // ------------------------------------------------------------------------------------------------ /** CRC */ @@ -1387,7 +1265,7 @@ void Radar::queueTerrainRefresh( void ) void Radar::crc( Xfer *xfer ) { -} // end crc +} // ------------------------------------------------------------------------------------------------ /** Xfer a radar object list given the head pointer as a parameter @@ -1423,9 +1301,9 @@ static void xferRadarObjectList( Xfer *xfer, RadarObject **head ) // save this object xfer->xferSnapshot( radarObject ); - } // end for, radarObject + } - } // end if, save + } else { @@ -1448,7 +1326,7 @@ static void xferRadarObjectList( Xfer *xfer, RadarObject **head ) DEBUG_CRASH(( "xferRadarObjectList - List head should be NULL, but isn't" )); throw SC_INVALID_DATA; #endif - } // end if + } // read each element for( UnsignedShort i = 0; i < count; ++i ) @@ -1466,40 +1344,88 @@ static void xferRadarObjectList( Xfer *xfer, RadarObject **head ) RadarObject *other; for( other = *head; other->friend_getNext() != NULL; other = other->friend_getNext() ) { - } // end for, other + } // set the end of the list to point to the new object other->friend_setNext( radarObject ); - } // end else + } // load the data xfer->xferSnapshot( radarObject ); - } // end for i + } - } // end else, load + } -} // end xferRadarObjectList +} // ------------------------------------------------------------------------------------------------ /** Xfer Method * Version Info: - * 1: Initial version */ + * 1: Initial version + * 2: TheSuperHackers @tweak Serialize m_radarHidden, m_radarForceOn for each player + * 3: TheSuperHackers @tweak Serialize m_localHeroObjectList + */ // ------------------------------------------------------------------------------------------------ void Radar::xfer( Xfer *xfer ) { // version +#if RETAIL_COMPATIBLE_XFER_SAVE XferVersion currentVersion = 1; +#else + XferVersion currentVersion = 3; +#endif XferVersion version = currentVersion; xfer->xferVersion( &version, currentVersion ); - // radar hidden - xfer->xferBool( &m_radarHidden ); - // radar force on - xfer->xferBool( &m_radarForceOn ); + if (version <= 1) + { + const Int localPlayerIndex = ThePlayerList->getLocalPlayer()->getPlayerIndex(); + Bool value; + + // radar hidden + value = m_radarHidden[localPlayerIndex]; + xfer->xferBool( &value ); + m_radarHidden[localPlayerIndex] = value; + + // radar force on + value = m_radarForceOn[localPlayerIndex]; + xfer->xferBool( &value ); + m_radarForceOn[localPlayerIndex] = value; + } + else + { + static_assert(sizeof(m_radarHidden) == 16, "Increase version if size changes"); + xfer->xferUser(&m_radarHidden, sizeof(m_radarHidden)); + + static_assert(sizeof(m_radarForceOn) == 16, "Increase version if size changes"); + xfer->xferUser(&m_radarForceOn, sizeof(m_radarForceOn)); + } + + if (version <= 2) + { + if (xfer->getXferMode() == XFER_SAVE) + { + // TheSuperHackers @info For legacy xfer compatibility. + // Transfer all local hero objects to local object list. + RadarObject **fromList = &m_localHeroObjectList; + RadarObject **toList = &m_localObjectList; + while (*fromList != NULL) + { + RadarObject* nextObject = (*fromList)->friend_getNext(); + (*fromList)->friend_setNext(NULL); + linkRadarObject(*fromList, toList); + *fromList = nextObject; + } + } + } + else + { + xferRadarObjectList( xfer, &m_localHeroObjectList ); + } // save our local object list xferRadarObjectList( xfer, &m_localObjectList ); @@ -1507,6 +1433,38 @@ void Radar::xfer( Xfer *xfer ) // save the regular object list xferRadarObjectList( xfer, &m_objectList ); + if (version <= 2) + { + // TheSuperHackers @info For legacy xfer compatibility. + // Transfer hero local object(s) back to local hero object list. + // This needs to be done on both load and save. + RadarObject **fromList = &m_localObjectList; + RadarObject **toList = &m_localHeroObjectList; + RadarObject *currObject; + RadarObject *prevObject; + RadarObject *nextObject; + prevObject = NULL; + for (currObject = *fromList; currObject != NULL; currObject = nextObject) + { + nextObject = currObject->friend_getNext(); + if (currObject->friend_getObject()->isHero()) + { + if (prevObject != NULL) + { + prevObject->friend_setNext(nextObject); + } + else + { + *fromList = nextObject; + } + currObject->friend_setNext(NULL); + linkRadarObject(currObject, toList); + continue; + } + prevObject = currObject; + } + } + // save the radar event count and data UnsignedShort eventCountVerify = MAX_RADAR_EVENTS; UnsignedShort eventCount = eventCountVerify; @@ -1518,7 +1476,7 @@ void Radar::xfer( Xfer *xfer ) eventCount, eventCountVerify )); throw SC_INVALID_DATA; - } // end if + } for( UnsignedShort i = 0; i < eventCount; ++i ) { @@ -1534,7 +1492,7 @@ void Radar::xfer( Xfer *xfer ) xfer->xferICoord2D( &m_event[ i ].radarLoc ); xfer->xferBool( &m_event[ i ].soundPlayed ); - } // end for i + } // next event index xfer->xferInt( &m_nextFreeRadarEvent ); @@ -1542,7 +1500,7 @@ void Radar::xfer( Xfer *xfer ) // last event index xfer->xferInt( &m_lastRadarEvent ); -} // end xfer +} // ------------------------------------------------------------------------------------------------ /** Load post process */ @@ -1556,7 +1514,7 @@ void Radar::loadPostProcess( void ) // refreshTerrain( TheTerrainLogic ); -} // end loadPostProcess +} // ------------------------------------------------------------------------------------------------ /** Is the priority type passed in a "visible" one that can show up on the radar */ @@ -1574,6 +1532,124 @@ Bool Radar::isPriorityVisible( RadarPriorityType priority ) default: return TRUE; - } // end switch + } + +} + +// ------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------ +void Radar::linkRadarObject( RadarObject *newObj, RadarObject **list ) +{ + if( *list == NULL ) + { + // trivial case, an empty list + *list = newObj; + return; + } + + RadarPriorityType newPriority = newObj->friend_getObject()->getRadarPriority(); + RadarPriorityType prevPriority; + RadarPriorityType currPriority; + RadarObject *currObject; + RadarObject *prevObject; + RadarObject *nextObject; -} // end isPriorityVisible + DEBUG_ASSERTCRASH(newObj->friend_getNext() == NULL, ("newObj->friend_getNext is not NULL")); + + prevObject = NULL; + prevPriority = RADAR_PRIORITY_INVALID; + for( currObject = *list; currObject; currObject = nextObject ) + { + // get the next object + nextObject = currObject->friend_getNext(); + + // get the priority of this entry in the list (currPriority) + currPriority = currObject->friend_getObject()->getRadarPriority(); + + // + // if there is no previous object, or the previous priority is less than the + // our new priority, and the current object in the list has a priority + // higher than our equal to our own we need to be inserted here + // + if( (prevObject == NULL || prevPriority < newPriority ) && (currPriority >= newPriority) ) + { + // insert into the list just ahead of currObject + if( prevObject ) + { + // the new entry next points to what the previous one used to point to + newObj->friend_setNext( prevObject->friend_getNext() ); + + // the previous one next now points to the new entry + prevObject->friend_setNext( newObj ); + } + else + { + // the new object next points to the current object + newObj->friend_setNext( currObject ); + + // new list head is now newObj + *list = newObj; + } + break; + } + else if( nextObject == NULL ) + { + // at the end of the list, put object here + currObject->friend_setNext( newObj ); + } + + // our current object is now the previous object + prevObject = currObject; + prevPriority = currPriority; + } +} + +// ------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------ +void Radar::assignObjectColorToRadarObject( RadarObject *radarObj, Object *obj ) +{ + const Player *player = obj->getControllingPlayer(); + Player *clientPlayer = rts::getObservedOrLocalPlayer(); + Bool useIndicatorColor = true; + + if( obj->isKindOf( KINDOF_DISGUISER ) ) + { + //Because we have support for disguised units pretending to be units from another + //team, we need to intercept it here and make sure it's rendered appropriately + //based on which client is rendering it. + StealthUpdate *update = obj->getStealth(); + if( update ) + { + if( update->isDisguised() ) + { + Player *disguisedPlayer = ThePlayerList->getNthPlayer( update->getDisguisedPlayerIndex() ); + if( player->getRelationship( clientPlayer->getDefaultTeam() ) != ALLIES && clientPlayer->isPlayerActive() ) + { + //Neutrals and enemies will see this disguised unit as the team it's disguised as. + player = disguisedPlayer; + if( player ) + useIndicatorColor = false; + } + //Otherwise, the color will show up as the team it really belongs to (already set above). + } + } + } + + if( obj->getContain() ) + { + // To handle Stealth garrison, ask containers what color they are drawing with to the local player. + // Local is okay because radar display is not synced. + player = obj->getContain()->getApparentControllingPlayer( clientPlayer ); + if( player ) + useIndicatorColor = false; + } + + if( useIndicatorColor || (player == NULL) ) + { + radarObj->setColor( obj->getIndicatorColor() ); + } + else + { + radarObj->setColor( player->getPlayerColor() ); + } +} diff --git a/Core/GameEngine/Source/Common/System/StreamingArchiveFile.cpp b/Core/GameEngine/Source/Common/System/StreamingArchiveFile.cpp index cfc3faa87c..1fc9f43b2e 100644 --- a/Core/GameEngine/Source/Common/System/StreamingArchiveFile.cpp +++ b/Core/GameEngine/Source/Common/System/StreamingArchiveFile.cpp @@ -47,10 +47,8 @@ #include "PreRTS.h" -#include #include #include -#include #include #include "Common/AsciiString.h" diff --git a/Core/GameEngine/Source/Common/System/UnicodeString.cpp b/Core/GameEngine/Source/Common/System/UnicodeString.cpp index 83857f216b..af1a6317e3 100644 --- a/Core/GameEngine/Source/Common/System/UnicodeString.cpp +++ b/Core/GameEngine/Source/Common/System/UnicodeString.cpp @@ -42,14 +42,14 @@ // //----------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/CriticalSection.h" // ----------------------------------------------------- -/*static*/ UnicodeString UnicodeString::TheEmptyString; +/*static*/ const UnicodeString UnicodeString::TheEmptyString; // ----------------------------------------------------- #ifdef RTS_DEBUG @@ -76,14 +76,20 @@ void UnicodeString::ensureUniqueBufferOfSize(int numCharsNeeded, Bool preserveDa { validate(); + const int usableNumChars = numCharsNeeded - 1; + if (m_data && m_data->m_refCount == 1 && m_data->m_numCharsAllocated >= numCharsNeeded) { // no buffer manhandling is needed (it's already large enough, and unique to us) if (strToCopy) + { // TheSuperHackers @fix Mauller 04/04/2025 Replace wcscpy with safer memmove as memory regions can overlap when part of string is copied to itself - memmove(m_data->peek(), strToCopy, (wcslen(strToCopy) + 1) * sizeof(WideChar)); + DEBUG_ASSERTCRASH(usableNumChars <= wcslen(strToCopy), ("strToCopy is too small")); + memmove(m_data->peek(), strToCopy, usableNumChars * sizeof(WideChar)); + m_data->peek()[usableNumChars] = 0; + } if (strToCat) wcscat(m_data->peek(), strToCat); return; @@ -108,7 +114,11 @@ void UnicodeString::ensureUniqueBufferOfSize(int numCharsNeeded, Bool preserveDa // do these BEFORE releasing the old buffer, so that self-copies // or self-cats will work correctly. if (strToCopy) - wcscpy(newData->peek(), strToCopy); + { + DEBUG_ASSERTCRASH(usableNumChars <= wcslen(strToCopy), ("strToCopy is too small")); + wcsncpy(newData->peek(), strToCopy, usableNumChars); + newData->peek()[usableNumChars] = 0; + } if (strToCat) wcscat(newData->peek(), strToCat); @@ -136,10 +146,20 @@ void UnicodeString::releaseBuffer() } // ----------------------------------------------------- -UnicodeString::UnicodeString(const WideChar* s) : m_data(0) +UnicodeString::UnicodeString(const WideChar* s) : m_data(NULL) +{ + int len = s ? (int)wcslen(s) : 0; + if (len > 0) + { + ensureUniqueBufferOfSize(len + 1, false, s, NULL); + } + validate(); +} + +// ----------------------------------------------------- +UnicodeString::UnicodeString(const WideChar* s, int len) : m_data(NULL) { - int len = wcslen(s); - if (len) + if (len > 0) { ensureUniqueBufferOfSize(len + 1, false, s, NULL); } @@ -164,12 +184,18 @@ void UnicodeString::set(const UnicodeString& stringSrc) // ----------------------------------------------------- void UnicodeString::set(const WideChar* s) +{ + int len = s ? wcslen(s) : 0; + set(s, len); +} + +// ----------------------------------------------------- +void UnicodeString::set(const WideChar* s, int len) { validate(); if (!m_data || s != peek()) { - int len = s ? wcslen(s) : 0; - if (len) + if (len > 0) { ensureUniqueBufferOfSize(len + 1, false, s, NULL); } @@ -307,7 +333,7 @@ void UnicodeString::truncateBy(const Int charCount) const size_t len = wcslen(peek()); if (len > 0) { - ensureUniqueBufferOfSize(len+1, true, NULL, NULL); + ensureUniqueBufferOfSize(len + 1, true, NULL, NULL); size_t count = charCount; if (charCount > len) { @@ -380,6 +406,30 @@ void UnicodeString::format_va(const WideChar* format, va_list args) } } +// ----------------------------------------------------- +Bool UnicodeString::startsWith(const WideChar* p) const +{ + return m_data && ::startsWith(peek(), p); +} + +// ----------------------------------------------------- +Bool UnicodeString::startsWithNoCase(const WideChar* p) const +{ + return m_data && ::startsWithNoCase(peek(), p); +} + +// ----------------------------------------------------- +Bool UnicodeString::endsWith(const WideChar* p) const +{ + return m_data && ::endsWith(peek(), p); +} + +// ----------------------------------------------------- +Bool UnicodeString::endsWithNoCase(const WideChar* p) const +{ + return m_data && ::endsWithNoCase(peek(), p); +} + //----------------------------------------------------------------------------- Bool UnicodeString::nextToken(UnicodeString* tok, UnicodeString delimiters) { @@ -387,7 +437,7 @@ Bool UnicodeString::nextToken(UnicodeString* tok, UnicodeString delimiters) return false; if (delimiters.isEmpty()) - delimiters = UnicodeString(L" \t\n\r"); + delimiters = L" \t\n\r"; Int offset; diff --git a/Core/GameEngine/Source/Common/System/Xfer.cpp b/Core/GameEngine/Source/Common/System/Xfer.cpp index 3de2041997..4427a7dd0a 100644 --- a/Core/GameEngine/Source/Common/System/Xfer.cpp +++ b/Core/GameEngine/Source/Common/System/Xfer.cpp @@ -30,7 +30,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/Upgrade.h" #include "Common/GameState.h" #include "Common/Xfer.h" @@ -45,14 +45,14 @@ Xfer::Xfer( void ) m_options = XO_NONE; m_xferMode = XFER_INVALID; -} // end Xfer +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- Xfer::~Xfer( void ) { -} // end ~Xfer +} // ------------------------------------------------------------------------------------------------ /** Open */ @@ -63,7 +63,7 @@ void Xfer::open( AsciiString identifier ) // save identifier m_identifier = identifier; -} // end open +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -72,7 +72,7 @@ void Xfer::xferByte( Byte *byteData ) xferImplementation( byteData, sizeof( Byte ) ); -} // end xferByte +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -89,9 +89,9 @@ void Xfer::xferVersion( XferVersion *versionData, XferVersion currentVersion ) *versionData, currentVersion )); throw XFER_INVALID_VERSION; - } // end if + } -} // end xferVersion +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -100,7 +100,7 @@ void Xfer::xferUnsignedByte( UnsignedByte *unsignedByteData ) xferImplementation( unsignedByteData, sizeof( UnsignedByte ) ); -} // end xferUnsignedByte +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -109,7 +109,7 @@ void Xfer::xferBool( Bool *boolData ) xferImplementation( boolData, sizeof( Bool ) ); -} // end xferBool +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -118,7 +118,7 @@ void Xfer::xferInt( Int *intData ) xferImplementation( intData, sizeof( Int ) ); -} // end xferInt +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -127,7 +127,7 @@ void Xfer::xferInt64( Int64 *int64Data ) xferImplementation( int64Data, sizeof( Int64 ) ); -} // end xferInt64 +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -136,7 +136,7 @@ void Xfer::xferUnsignedInt( UnsignedInt *unsignedIntData ) xferImplementation( unsignedIntData, sizeof( UnsignedInt ) ); -} // end xferUnsignedInt +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -145,7 +145,7 @@ void Xfer::xferShort( Short *shortData ) xferImplementation( shortData, sizeof( Short ) ); -} // end xferShort +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -154,7 +154,7 @@ void Xfer::xferUnsignedShort( UnsignedShort *unsignedShortData ) xferImplementation( unsignedShortData, sizeof( UnsignedShort ) ); -} // end xferUnsignedShort +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -163,7 +163,7 @@ void Xfer::xferReal( Real *realData ) xferImplementation( realData, sizeof( Real ) ); -} // end xferReal +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -179,7 +179,7 @@ void Xfer::xferMapName( AsciiString *mapNameData ) xferAsciiString(mapNameData); *mapNameData = TheGameState->portableMapPathToRealMapPath(*mapNameData); } -} // end xferAsciiString +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -188,13 +188,13 @@ void Xfer::xferAsciiString( AsciiString *asciiStringData ) xferImplementation( (void *)asciiStringData->str(), sizeof( Byte ) * asciiStringData->getLength() ); -} // end xferAsciiString +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ void Xfer::xferMarkerLabel( AsciiString asciiStringData ) { -} // end xferMarkerLabel +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -203,7 +203,7 @@ void Xfer::xferUnicodeString( UnicodeString *unicodeStringData ) xferImplementation( (void *)unicodeStringData->str(), sizeof( WideChar ) * unicodeStringData->getLength() ); -} // end xferUnicodeString +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -214,7 +214,7 @@ void Xfer::xferCoord3D( Coord3D *coord3D ) xferReal( &coord3D->y ); xferReal( &coord3D->z ); -} // end xferCoord3D +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -225,7 +225,7 @@ void Xfer::xferICoord3D( ICoord3D *iCoord3D ) xferInt( &iCoord3D->y ); xferInt( &iCoord3D->z ); -} // end xferICoor3D +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -235,7 +235,7 @@ void Xfer::xferRegion3D( Region3D *region3D ) xferCoord3D( ®ion3D->lo ); xferCoord3D( ®ion3D->hi ); -} // end xferRegion3D +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -245,7 +245,7 @@ void Xfer::xferIRegion3D( IRegion3D *iRegion3D ) xferICoord3D( &iRegion3D->lo ); xferICoord3D( &iRegion3D->hi ); -} // end xferIRegion3D +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -255,7 +255,7 @@ void Xfer::xferCoord2D( Coord2D *coord2D ) xferReal( &coord2D->x ); xferReal( &coord2D->y ); -} // end xferCoord2D +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -265,7 +265,7 @@ void Xfer::xferICoord2D( ICoord2D *iCoord2D ) xferInt( &iCoord2D->x ); xferInt( &iCoord2D->y ); -} // end xferICoord2D +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -275,7 +275,7 @@ void Xfer::xferRegion2D( Region2D *region2D ) xferCoord2D( ®ion2D->lo ); xferCoord2D( ®ion2D->hi ); -} // end xferRegion2D +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -285,7 +285,7 @@ void Xfer::xferIRegion2D( IRegion2D *iRegion2D ) xferICoord2D( &iRegion2D->lo ); xferICoord2D( &iRegion2D->hi ); -} // end xferIRegion2D +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -295,7 +295,7 @@ void Xfer::xferRealRange( RealRange *realRange ) xferReal( &realRange->lo ); xferReal( &realRange->hi ); -} // end xferRealRange +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -304,7 +304,7 @@ void Xfer::xferColor( Color *color ) xferImplementation( color, sizeof( Color ) ); -} // end xferColor +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -315,7 +315,7 @@ void Xfer::xferRGBColor( RGBColor *rgbColor ) xferReal( &rgbColor->green ); xferReal( &rgbColor->blue ); -} // end xferRGBColor +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -327,7 +327,7 @@ void Xfer::xferRGBAColorReal( RGBAColorReal *rgbaColorReal ) xferReal( &rgbaColorReal->blue ); xferReal( &rgbaColorReal->alpha ); -} // end xferRGBAColorReal +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -339,7 +339,7 @@ void Xfer::xferRGBAColorInt( RGBAColorInt *rgbaColorInt ) xferUnsignedInt( &rgbaColorInt->blue ); xferUnsignedInt( &rgbaColorInt->alpha ); -} // end xferRGBAColorInt +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -348,7 +348,7 @@ void Xfer::xferObjectID( ObjectID *objectID ) xferImplementation( objectID, sizeof( ObjectID ) ); -} // end xferObjeftID +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -357,7 +357,7 @@ void Xfer::xferDrawableID( DrawableID *drawableID ) xferImplementation( drawableID, sizeof( DrawableID ) ); -} // end xferDrawableID +} // ------------------------------------------------------------------------------------------------ @@ -388,20 +388,20 @@ void Xfer::xferSTLObjectIDVector( std::vector *objectIDVectorData ) objectID = *it; xferObjectID( &objectID ); - } // end for + } - } // end if, save + } else if( getXferMode() == XFER_LOAD ) { // sanity, the list should be empty before we transfer more data into it - if( objectIDVectorData->size() != 0 ) + if( !objectIDVectorData->empty() ) { DEBUG_CRASH(( "Xfer::xferSTLObjectIDList - object vector should be empty before loading" )); throw XFER_LIST_NOT_EMPTY; - } // end if + } // read all ids for( UnsignedShort i = 0; i < listCount; ++i ) @@ -410,16 +410,16 @@ void Xfer::xferSTLObjectIDVector( std::vector *objectIDVectorData ) xferObjectID( &objectID ); objectIDVectorData->push_back( objectID ); - } // end for, i + } - } // end else if + } else { DEBUG_CRASH(( "xferSTLObjectIDList - Unknown xfer mode '%d'", getXferMode() )); throw XFER_MODE_UNKNOWN; - } // end else + } } // ------------------------------------------------------------------------------------------------ @@ -455,20 +455,20 @@ void Xfer::xferSTLObjectIDList( std::list< ObjectID > *objectIDListData ) objectID = *it; xferObjectID( &objectID ); - } // end for + } - } // end if, save + } else if( getXferMode() == XFER_LOAD ) { // sanity, the list should be empty before we transfer more data into it - if( objectIDListData->size() != 0 ) + if( !objectIDListData->empty() ) { DEBUG_CRASH(( "Xfer::xferSTLObjectIDList - object list should be empty before loading" )); throw XFER_LIST_NOT_EMPTY; - } // end if + } // read all ids for( UnsignedShort i = 0; i < listCount; ++i ) @@ -477,18 +477,18 @@ void Xfer::xferSTLObjectIDList( std::list< ObjectID > *objectIDListData ) xferObjectID( &objectID ); objectIDListData->push_back( objectID ); - } // end for, i + } - } // end else if + } else { DEBUG_CRASH(( "xferSTLObjectIDList - Unknown xfer mode '%d'", getXferMode() )); throw XFER_MODE_UNKNOWN; - } // end else + } -} // end xferSTLObjectIDList +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -521,20 +521,20 @@ void Xfer::xferSTLIntList( std::list< Int > *intListData ) intData = *it; xferInt( &intData ); - } // end for + } - } // end if, save + } else if( getXferMode() == XFER_LOAD ) { // sanity, the list should be empty before we transfer more data into it - if( intListData->size() != 0 ) + if( !intListData->empty() ) { DEBUG_CRASH(( "Xfer::xferSTLIntList - int list should be empty before loading" )); throw XFER_LIST_NOT_EMPTY; - } // end if + } // read all ids for( UnsignedShort i = 0; i < listCount; ++i ) @@ -543,18 +543,18 @@ void Xfer::xferSTLIntList( std::list< Int > *intListData ) xferInt( &intData ); intListData->push_back( intData ); - } // end for, i + } - } // end else if + } else { DEBUG_CRASH(( "xferSTLIntList - Unknown xfer mode '%d'", getXferMode() )); throw XFER_MODE_UNKNOWN; - } // end else + } -} // end xferSTLIntList +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -574,7 +574,7 @@ void Xfer::xferScienceType( ScienceType *science ) // write the string xferAsciiString( &scienceName ); - } // end if, save + } else if( getXferMode() == XFER_LOAD ) { xferAsciiString( &scienceName ); @@ -587,23 +587,23 @@ void Xfer::xferScienceType( ScienceType *science ) DEBUG_CRASH(( "xferScienceType - Unknown science '%s'", scienceName.str() )); throw XFER_UNKNOWN_STRING; - } // end if + } - } // end else if, load + } else if( getXferMode() == XFER_CRC ) { xferImplementation( science, sizeof( *science ) ); - } // end else if, crc + } else { DEBUG_CRASH(( "xferScienceType - Unknown xfer mode '%d'", getXferMode() )); throw XFER_MODE_UNKNOWN; - } // end else + } -} // end xferScienceType +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -657,17 +657,17 @@ void Xfer::xferScienceVec( ScienceVec *scienceVec ) { ScienceType science = *it; xferImplementation( &science, sizeof( ScienceType ) ); - } // end for, it - } // end else if, crc + } + } else { DEBUG_CRASH(( "xferScienceVec - Unknown xfer mode '%d'", getXferMode() )); throw XFER_MODE_UNKNOWN; - } // end else + } -} // end xferScienceVec +} // ------------------------------------------------------------------------------------------------ /** kind of type, for load/save it is xfered as a string so we can reorder the @@ -691,7 +691,7 @@ void Xfer::xferKindOf( KindOfType *kindOfData ) AsciiString kindOfName = KindOfMaskType::getNameFromSingleBit(*kindOfData); xferAsciiString( &kindOfName ); - } // end if, save + } else if( getXferMode() == XFER_LOAD ) { @@ -704,23 +704,23 @@ void Xfer::xferKindOf( KindOfType *kindOfData ) if (bit != -1) *kindOfData = (KindOfType)bit; - } // end else if, load + } else if( getXferMode() == XFER_CRC ) { // just call the xfer implementation on the data values xferImplementation( kindOfData, sizeof( KindOfType ) ); - } // end else if, crc + } else { DEBUG_CRASH(( "xferKindOf - Unknown xfer mode '%d'", getXferMode() )); throw XFER_MODE_UNKNOWN; - } // end else + } -} // end xferKindOf +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -755,7 +755,7 @@ void Xfer::xferUpgradeMask( UpgradeMaskType *upgradeMaskData ) { count++; } - } // end for, upgradeTemplate + } // write the count xferUnsignedShort( &count ); @@ -768,9 +768,9 @@ void Xfer::xferUpgradeMask( UpgradeMaskType *upgradeMaskData ) { upgradeName = upgradeTemplate->getUpgradeName(); xferAsciiString( &upgradeName ); - } // end if - } // end for, upgradeTemplate - } // end if, save + } + } + } else if( getXferMode() == XFER_LOAD ) { AsciiString upgradeName; @@ -798,30 +798,30 @@ void Xfer::xferUpgradeMask( UpgradeMaskType *upgradeMaskData ) DEBUG_CRASH(( "Xfer::xferUpgradeMask - Unknown upgrade '%s'", upgradeName.str() )); throw XFER_UNKNOWN_STRING; - } // end if + } // set the mask data upgradeMaskData->set( upgradeTemplate->getUpgradeMask() ); - } // end for i + } - } // end else if, load + } else if( getXferMode() == XFER_CRC ) { // just xfer implementation the data itself xferImplementation( upgradeMaskData, sizeof( UpgradeMaskType ) ); - } // end else if, crc + } else { DEBUG_CRASH(( "xferUpgradeMask - Unknown xfer mode '%d'", getXferMode() )); throw XFER_MODE_UNKNOWN; - } // end else + } -} // end xferUpgradeMask +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -830,7 +830,7 @@ void Xfer::xferUser( void *data, Int dataSize ) xferImplementation( data, dataSize ); -} // end xferUser +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ diff --git a/Core/GameEngine/Source/Common/System/XferCRC.cpp b/Core/GameEngine/Source/Common/System/XferCRC.cpp index 83a4959525..520cd2cc4f 100644 --- a/Core/GameEngine/Source/Common/System/XferCRC.cpp +++ b/Core/GameEngine/Source/Common/System/XferCRC.cpp @@ -28,7 +28,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/XferCRC.h" #include "Common/XferDeepCRC.h" @@ -42,18 +42,15 @@ XferCRC::XferCRC( void ) { m_xferMode = XFER_CRC; - //Added By Sadullah Nader - //Initialization(s) inserted m_crc = 0; - // -} // end XferCRC +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- XferCRC::~XferCRC( void ) { -} // end ~XferCRC +} //------------------------------------------------------------------------------------------------- /** Open file 'identifier' for writing */ @@ -67,7 +64,7 @@ void XferCRC::open( AsciiString identifier ) // initialize CRC to brand new one at zero m_crc = 0; -} // end open +} //------------------------------------------------------------------------------------------------- /** Close our current file */ @@ -75,7 +72,7 @@ void XferCRC::open( AsciiString identifier ) void XferCRC::close( void ) { -} // end close +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -84,14 +81,14 @@ Int XferCRC::beginBlock( void ) return 0; -} // end beginBlock +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- void XferCRC::endBlock( void ) { -} // end endBlock +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -100,7 +97,7 @@ void XferCRC::addCRC( UnsignedInt val ) m_crc = (m_crc << 1) + htobe(val) + ((m_crc >> 31) & 0x01); -} // end addCRC +} // ------------------------------------------------------------------------------------------------ /** Entry point for xfering a snapshot */ @@ -113,12 +110,12 @@ void XferCRC::xferSnapshot( Snapshot *snapshot ) return; - } // end if + } // run the crc function of the snapshot snapshot->crc( this ); -} // end xferSnapshot +} //------------------------------------------------------------------------------------------------- /** Perform a single CRC operation on the data passed in */ @@ -154,14 +151,14 @@ void XferCRC::xferImplementation( void *data, Int dataSize ) break; } -} // end xferImplementation +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- void XferCRC::skip( Int dataSize ) { -} // end skip +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -170,7 +167,7 @@ UnsignedInt XferCRC::getCRC( void ) return htobe(m_crc); -} // end skip +} //------------------------------------------------------------------------------------------------- @@ -181,7 +178,7 @@ XferDeepCRC::XferDeepCRC( void ) m_xferMode = XFER_SAVE; m_fileFP = NULL; -} // end XferCRC +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -195,9 +192,9 @@ XferDeepCRC::~XferDeepCRC( void ) DEBUG_CRASH(( "Warning: Xfer file '%s' was left open", m_identifier.str() )); close(); - } // end if + } -} // end ~XferCRC +} //------------------------------------------------------------------------------------------------- /** Open file 'identifier' for writing */ @@ -215,7 +212,7 @@ void XferDeepCRC::open( AsciiString identifier ) identifier.str(), m_identifier.str() )); throw XFER_FILE_ALREADY_OPEN; - } // end if + } // call base class Xfer::open( identifier ); @@ -228,12 +225,12 @@ void XferDeepCRC::open( AsciiString identifier ) DEBUG_CRASH(( "File '%s' not found", identifier.str() )); throw XFER_FILE_NOT_FOUND; - } // end if + } // initialize CRC to brand new one at zero m_crc = 0; -} // end open +} //------------------------------------------------------------------------------------------------- /** Close our current file */ @@ -248,7 +245,7 @@ void XferDeepCRC::close( void ) DEBUG_CRASH(( "Xfer close called, but no file was open" )); throw XFER_FILE_NOT_OPEN; - } // end if + } // close the file fclose( m_fileFP ); @@ -257,7 +254,7 @@ void XferDeepCRC::close( void ) // erase the filename m_identifier.clear(); -} // end close +} //------------------------------------------------------------------------------------------------- /** Perform a single CRC operation on the data passed in */ @@ -281,11 +278,11 @@ void XferDeepCRC::xferImplementation( void *data, Int dataSize ) DEBUG_CRASH(( "XferSave - Error writing to file '%s'", m_identifier.str() )); throw XFER_WRITE_ERROR; - } // end if + } XferCRC::xferImplementation( data, dataSize ); -} // end xferImplementation +} // ------------------------------------------------------------------------------------------------ /** Save ascii string */ @@ -293,7 +290,7 @@ void XferDeepCRC::xferImplementation( void *data, Int dataSize ) void XferDeepCRC::xferMarkerLabel( AsciiString asciiStringData ) { -} // end xferAsciiString +} // ------------------------------------------------------------------------------------------------ /** Save ascii string */ @@ -308,7 +305,7 @@ void XferDeepCRC::xferAsciiString( AsciiString *asciiStringData ) DEBUG_CRASH(( "XferSave cannot save this ascii string because it's too long. Change the size of the length header (but be sure to preserve save file compatability" )); throw XFER_STRING_ERROR; - } // end if + } // save length of string to follow UnsignedShort len = asciiStringData->getLength(); @@ -318,7 +315,7 @@ void XferDeepCRC::xferAsciiString( AsciiString *asciiStringData ) if( len > 0 ) xferUser( (void *)asciiStringData->str(), sizeof( Byte ) * len ); -} // end xferAsciiString +} // ------------------------------------------------------------------------------------------------ /** Save unicodee string */ @@ -333,7 +330,7 @@ void XferDeepCRC::xferUnicodeString( UnicodeString *unicodeStringData ) DEBUG_CRASH(( "XferSave cannot save this unicode string because it's too long. Change the size of the length header (but be sure to preserve save file compatability" )); throw XFER_STRING_ERROR; - } // end if + } // save length of string to follow Byte len = unicodeStringData->getLength(); @@ -343,4 +340,4 @@ void XferDeepCRC::xferUnicodeString( UnicodeString *unicodeStringData ) if( len > 0 ) xferUser( (void *)unicodeStringData->str(), sizeof( WideChar ) * len ); -} // end xferUnicodeString +} diff --git a/Core/GameEngine/Source/Common/System/XferLoad.cpp b/Core/GameEngine/Source/Common/System/XferLoad.cpp index e04705a98e..9b1f1981b3 100644 --- a/Core/GameEngine/Source/Common/System/XferLoad.cpp +++ b/Core/GameEngine/Source/Common/System/XferLoad.cpp @@ -42,7 +42,7 @@ XferLoad::XferLoad( void ) m_xferMode = XFER_LOAD; m_fileFP = NULL; -} // end XferLoad +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -56,9 +56,9 @@ XferLoad::~XferLoad( void ) DEBUG_CRASH(( "Warning: Xfer file '%s' was left open", m_identifier.str() )); close(); - } // end if + } -} // end ~XferLoad +} //------------------------------------------------------------------------------------------------- /** Open file 'identifier' for reading */ @@ -74,7 +74,7 @@ void XferLoad::open( AsciiString identifier ) identifier.str(), m_identifier.str() )); throw XFER_FILE_ALREADY_OPEN; - } // end if + } // call base class Xfer::open( identifier ); @@ -87,9 +87,9 @@ void XferLoad::open( AsciiString identifier ) DEBUG_CRASH(( "File '%s' not found", identifier.str() )); throw XFER_FILE_NOT_FOUND; - } // end if + } -} // end open +} //------------------------------------------------------------------------------------------------- /** Close our current file */ @@ -104,7 +104,7 @@ void XferLoad::close( void ) DEBUG_CRASH(( "Xfer close called, but no file was open" )); throw XFER_FILE_NOT_OPEN; - } // end if + } // close the file fclose( m_fileFP ); @@ -113,7 +113,7 @@ void XferLoad::close( void ) // erase the filename m_identifier.clear(); -} // end close +} //------------------------------------------------------------------------------------------------- /** Read a block size descriptor from the file at the current position */ @@ -133,12 +133,12 @@ Int XferLoad::beginBlock( void ) DEBUG_CRASH(( "Xfer - Error reading block size for '%s'", m_identifier.str() )); return 0; - } // end if + } // return the block size return blockSize; -} // end beginBlock +} // ------------------------------------------------------------------------------------------------ /** End block ... this does nothing when reading */ @@ -146,7 +146,7 @@ Int XferLoad::beginBlock( void ) void XferLoad::endBlock( void ) { -} // end endBlock +} //------------------------------------------------------------------------------------------------- /** Skip forward 'dataSize' bytes in the file */ @@ -166,7 +166,7 @@ void XferLoad::skip( Int dataSize ) if( fseek( m_fileFP, dataSize, SEEK_CUR ) != 0 ) throw XFER_SKIP_ERROR; -} // end skip +} // ------------------------------------------------------------------------------------------------ /** Entry point for xfering a snapshot */ @@ -180,7 +180,7 @@ void XferLoad::xferSnapshot( Snapshot *snapshot ) DEBUG_CRASH(( "XferLoad::xferSnapshot - Invalid parameters" )); throw XFER_INVALID_PARAMETERS; - } // end if + } // run the xfer function of the snapshot snapshot->xfer( this ); @@ -189,7 +189,7 @@ void XferLoad::xferSnapshot( Snapshot *snapshot ) if( BitIsSet( getOptions(), XO_NO_POST_PROCESSING ) == FALSE ) TheGameState->addPostProcessSnapshot( snapshot ); -} // end xferSnapshot +} // ------------------------------------------------------------------------------------------------ /** Read string from file and store in ascii string */ @@ -212,7 +212,7 @@ void XferLoad::xferAsciiString( AsciiString *asciiStringData ) // save into ascii string asciiStringData->set( buffer ); -} // end xferAsciiString +} // ------------------------------------------------------------------------------------------------ /** Read string from file and store in unicode string */ @@ -235,7 +235,7 @@ void XferLoad::xferUnicodeString( UnicodeString *unicodeStringData ) // save into unicode string unicodeStringData->set( buffer ); -} // end xferUnicodeString +} //------------------------------------------------------------------------------------------------- /** Perform the read operation */ @@ -254,7 +254,7 @@ void XferLoad::xferImplementation( void *data, Int dataSize ) DEBUG_CRASH(( "XferLoad - Error reading from file '%s'", m_identifier.str() )); throw XFER_READ_ERROR; - } // end if + } -} // end xferImplementation +} diff --git a/Core/GameEngine/Source/Common/System/XferSave.cpp b/Core/GameEngine/Source/Common/System/XferSave.cpp index 02d01ebd19..292cb6c883 100644 --- a/Core/GameEngine/Source/Common/System/XferSave.cpp +++ b/Core/GameEngine/Source/Common/System/XferSave.cpp @@ -28,7 +28,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/XferSave.h" #include "Common/Snapshot.h" #include "Common/GameMemory.h" @@ -59,7 +59,7 @@ XferSave::XferSave( void ) m_fileFP = NULL; m_blockStack = NULL; -} // end XferSave +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -73,7 +73,7 @@ XferSave::~XferSave( void ) DEBUG_CRASH(( "Warning: Xfer file '%s' was left open", m_identifier.str() )); close(); - } // end if + } // // the block stack should be empty, if it's not that means we started blocks but never @@ -94,11 +94,11 @@ XferSave::~XferSave( void ) deleteInstance(m_blockStack); m_blockStack = next; - } // end while + } - } // end if + } -} // end ~XferSave +} //------------------------------------------------------------------------------------------------- /** Open file 'identifier' for writing */ @@ -114,7 +114,7 @@ void XferSave::open( AsciiString identifier ) identifier.str(), m_identifier.str() )); throw XFER_FILE_ALREADY_OPEN; - } // end if + } // call base class Xfer::open( identifier ); @@ -127,9 +127,9 @@ void XferSave::open( AsciiString identifier ) DEBUG_CRASH(( "File '%s' not found", identifier.str() )); throw XFER_FILE_NOT_FOUND; - } // end if + } -} // end open +} //------------------------------------------------------------------------------------------------- /** Close our current file */ @@ -144,7 +144,7 @@ void XferSave::close( void ) DEBUG_CRASH(( "Xfer close called, but no file was open" )); throw XFER_FILE_NOT_OPEN; - } // end if + } // close the file fclose( m_fileFP ); @@ -153,7 +153,7 @@ void XferSave::close( void ) // erase the filename m_identifier.clear(); -} // end close +} //------------------------------------------------------------------------------------------------- /** Write a placeholder at the current location in the file and store this location @@ -181,7 +181,7 @@ Int XferSave::beginBlock( void ) m_identifier.str() )); return XFER_WRITE_ERROR; - } // end if + } // save this block position on the top of the "stack" XferBlockData *top = newInstance(XferBlockData); @@ -200,7 +200,7 @@ Int XferSave::beginBlock( void ) return XFER_OK; -} // end beginBlock +} //------------------------------------------------------------------------------------------------- /** Do the tail end as described in beginBlock above. Back up to the last begin block, @@ -221,7 +221,7 @@ void XferSave::endBlock( void ) DEBUG_CRASH(( "Xfer end block called, but no matching begin block was found" )); throw XFER_BEGIN_END_MISMATCH; - } // end if + } // save our current file position XferFilePos currentFilePos = ftell( m_fileFP ); @@ -241,7 +241,7 @@ void XferSave::endBlock( void ) DEBUG_CRASH(( "Error writing block size to file '%s'", m_identifier.str() )); throw XFER_WRITE_ERROR; - } // end if + } // place the file pointer back to the current position fseek( m_fileFP, currentFilePos, SEEK_SET ); @@ -249,7 +249,7 @@ void XferSave::endBlock( void ) // delete the block data as it's all used up now deleteInstance(top); -} // end endBlock +} //------------------------------------------------------------------------------------------------- /** Skip forward 'dataSize' bytes in the file */ @@ -265,7 +265,7 @@ void XferSave::skip( Int dataSize ) // skip forward dataSize bytes fseek( m_fileFP, dataSize, SEEK_CUR ); -} // end skip +} // ------------------------------------------------------------------------------------------------ /** Entry point for xfering a snapshot */ @@ -279,12 +279,12 @@ void XferSave::xferSnapshot( Snapshot *snapshot ) DEBUG_CRASH(( "XferSave::xferSnapshot - Invalid parameters" )); throw XFER_INVALID_PARAMETERS; - } // end if + } // run the xfer function of the snapshot snapshot->xfer( this ); -} // end xferSnapshot +} // ------------------------------------------------------------------------------------------------ /** Save ascii string */ @@ -299,7 +299,7 @@ void XferSave::xferAsciiString( AsciiString *asciiStringData ) DEBUG_CRASH(( "XferSave cannot save this unicode string because it's too long. Change the size of the length header (but be sure to preserve save file compatability" )); throw XFER_STRING_ERROR; - } // end if + } // save length of string to follow UnsignedByte len = asciiStringData->getLength(); @@ -309,7 +309,7 @@ void XferSave::xferAsciiString( AsciiString *asciiStringData ) if( len > 0 ) xferUser( (void *)asciiStringData->str(), sizeof( Byte ) * len ); -} // end xferAsciiString +} // ------------------------------------------------------------------------------------------------ /** Save unicodee string */ @@ -324,7 +324,7 @@ void XferSave::xferUnicodeString( UnicodeString *unicodeStringData ) DEBUG_CRASH(( "XferSave cannot save this unicode string because it's too long. Change the size of the length header (but be sure to preserve save file compatability" )); throw XFER_STRING_ERROR; - } // end if + } // save length of string to follow UnsignedByte len = unicodeStringData->getLength(); @@ -334,7 +334,7 @@ void XferSave::xferUnicodeString( UnicodeString *unicodeStringData ) if( len > 0 ) xferUser( (void *)unicodeStringData->str(), sizeof( WideChar ) * len ); -} // end xferUnicodeString +} //------------------------------------------------------------------------------------------------- /** Perform the write operation */ @@ -353,6 +353,6 @@ void XferSave::xferImplementation( void *data, Int dataSize ) DEBUG_CRASH(( "XferSave - Error writing to file '%s'", m_identifier.str() )); throw XFER_WRITE_ERROR; - } // end if + } -} // end xferImplementation +} diff --git a/Core/GameEngine/Source/Common/crc.cpp b/Core/GameEngine/Source/Common/crc.cpp index ddf54fff93..60e71e4b2f 100644 --- a/Core/GameEngine/Source/Common/crc.cpp +++ b/Core/GameEngine/Source/Common/crc.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/crc.h" #include "Common/Debug.h" @@ -78,6 +78,6 @@ UnsignedInt CRC::get( void ) UnsignedInt tcrc = crc; return tcrc; -} // end skip +} #endif diff --git a/Core/GameEngine/Source/GameClient/GUI/WindowVideoManager.cpp b/Core/GameEngine/Source/GameClient/GUI/WindowVideoManager.cpp index 4e53431599..0bbbfde983 100644 --- a/Core/GameEngine/Source/GameClient/GUI/WindowVideoManager.cpp +++ b/Core/GameEngine/Source/GameClient/GUI/WindowVideoManager.cpp @@ -64,7 +64,7 @@ //----------------------------------------------------------------------------- // USER INCLUDES ////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameClient/WindowVideoManager.h" #include "GameClient/GameWindow.h" @@ -101,9 +101,10 @@ WindowVideo::~WindowVideo( void ) m_videoBuffer = NULL; if ( m_videoStream ) + { m_videoStream->close(); - m_videoStream = NULL; - + m_videoStream = NULL; + } } void WindowVideo::init( GameWindow *win, AsciiString movieName, @@ -140,8 +141,7 @@ WindowVideoManager::WindowVideoManager( void ) while(it != m_playingVideos.end()) { WindowVideo *winVid = it->second; - if(winVid) - delete winVid; + delete winVid; it++; } m_playingVideos.clear(); @@ -157,8 +157,7 @@ WindowVideoManager::~WindowVideoManager( void ) while(it != m_playingVideos.end()) { WindowVideo *winVid = it->second; - if(winVid) - delete winVid; + delete winVid; it++; } m_playingVideos.clear(); @@ -180,8 +179,7 @@ void WindowVideoManager::reset( void ) while(it != m_playingVideos.end()) { WindowVideo *winVid = it->second; - if(winVid) - delete winVid; + delete winVid; it++; } m_playingVideos.clear(); @@ -277,8 +275,10 @@ void WindowVideoManager::playMovie( GameWindow *win, AsciiString movieName, Wind videoBuffer = NULL; if ( videoStream ) + { videoStream->close(); - videoStream = NULL; + videoStream = NULL; + } return; } @@ -349,9 +349,7 @@ void WindowVideoManager::stopAndRemoveMovie( GameWindow *win ) if(it != m_playingVideos.end()) { WindowVideo *winVid = it->second; - if(winVid) - delete winVid; - winVid = NULL; + delete winVid; m_playingVideos.erase(it); } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/MapUtil.cpp b/Core/GameEngine/Source/GameClient/MapUtil.cpp similarity index 65% rename from GeneralsMD/Code/GameEngine/Source/GameClient/MapUtil.cpp rename to Core/GameEngine/Source/GameClient/MapUtil.cpp index dfce46a46b..a99f1cdc36 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/MapUtil.cpp +++ b/Core/GameEngine/Source/GameClient/MapUtil.cpp @@ -28,7 +28,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/crc.h" #include "Common/FileSystem.h" @@ -81,27 +81,12 @@ static Coord3DList m_techPositions; static Int m_mapDX = 0; static Int m_mapDY = 0; -static UnsignedInt calcCRC( AsciiString dirName, AsciiString fname ) +static UnsignedInt calcCRC( AsciiString fname ) { CRC theCRC; theCRC.clear(); - // Try the official map dir - AsciiString asciiFile; - char tempBuf[_MAX_PATH]; - char filenameBuf[_MAX_PATH]; - int length = 0; - strcpy(tempBuf, fname.str()); - length = strlen( tempBuf ); - if( length >= 4 ) - { - memset( filenameBuf, '\0', _MAX_PATH); - strncpy( filenameBuf, tempBuf, length - 4); - } - - File *fp; - asciiFile = fname; - fp = TheFileSystem->openFile(asciiFile.str(), File::READ); + File *fp = TheFileSystem->openFile(fname.str(), File::READ); if( !fp ) { DEBUG_CRASH(("Couldn't open '%s'", fname.str())); @@ -173,7 +158,7 @@ static Bool ParseObjectDataChunk(DataChunkInput &file, DataChunkInfo *info, void static Bool ParseObjectsDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData) { file.m_currentObject = NULL; - file.registerParser( AsciiString("Object"), info->label, ParseObjectDataChunk ); + file.registerParser( "Object", info->label, ParseObjectDataChunk ); return (file.parse(userData)); } @@ -232,24 +217,9 @@ static Bool ParseSizeOnlyInChunk(DataChunkInput &file, DataChunkInfo *info, void static Bool loadMap( AsciiString filename ) { - char tempBuf[_MAX_PATH]; - char filenameBuf[_MAX_PATH]; - AsciiString asciiFile; - int length = 0; - - strcpy(tempBuf, filename.str()); - - length = strlen( tempBuf ); - if( length >= 4 ) - { - memset( filenameBuf, '\0', _MAX_PATH); - strncpy( filenameBuf, tempBuf, length - 4); - } - CachedFileInputStream fileStrm; - asciiFile = filename; - if( !fileStrm.open(asciiFile) ) + if( !fileStrm.open(filename) ) { return FALSE; } @@ -260,9 +230,9 @@ static Bool loadMap( AsciiString filename ) m_waypoints = NEW WaypointMap; - file.registerParser( AsciiString("HeightMapData"), AsciiString::TheEmptyString, ParseSizeOnlyInChunk ); - file.registerParser( AsciiString("WorldInfo"), AsciiString::TheEmptyString, ParseWorldDictDataChunk ); - file.registerParser( AsciiString("ObjectsList"), AsciiString::TheEmptyString, ParseObjectsDataChunk ); + file.registerParser( "HeightMapData", AsciiString::TheEmptyString, ParseSizeOnlyInChunk ); + file.registerParser( "WorldInfo", AsciiString::TheEmptyString, ParseWorldDictDataChunk ); + file.registerParser( "ObjectsList", AsciiString::TheEmptyString, ParseObjectsDataChunk ); if (!file.parse(NULL)) { throw(ERROR_CORRUPT_FILE_FORMAT); } @@ -275,17 +245,12 @@ static Bool loadMap( AsciiString filename ) static void resetMap( void ) { - if (m_data) - { - delete[] m_data; - m_data = 0; - } + delete[] m_data; + m_data = NULL; + + delete m_waypoints; + m_waypoints = NULL; - if (m_waypoints) - { - delete m_waypoints; - m_waypoints = 0; - } m_techPositions.clear(); m_supplyPositions.clear(); } @@ -345,11 +310,11 @@ void WaypointMap::update( void ) m_numStartSpots = max(1, m_numStartSpots); } -const char * MapCache::m_mapCacheName = "MapCache.ini"; +const char *const MapCache::m_mapCacheName = "MapCache.ini"; AsciiString MapCache::getMapDir() const { - return AsciiString("Maps"); + return "Maps"; } AsciiString MapCache::getUserMapDir() const @@ -361,21 +326,11 @@ AsciiString MapCache::getUserMapDir() const AsciiString MapCache::getMapExtension() const { - return AsciiString("map"); + return "map"; } -void MapCache::writeCacheINI( Bool userDir ) +void MapCache::writeCacheINI( const AsciiString &mapDir ) { - AsciiString mapDir; - if (!userDir || TheGlobalData->m_buildMapCache) - { - mapDir = getMapDir(); - } - else - { - mapDir = getUserMapDir(); - } - AsciiString filepath = mapDir; filepath.concat('\\'); @@ -387,18 +342,17 @@ void MapCache::writeCacheINI( Bool userDir ) if (fp == NULL) { return; } + fprintf(fp, "; FILE: %s /////////////////////////////////////////////////////////////\n", filepath.str()); fprintf(fp, "; This INI file is auto-generated - do not modify\n"); fprintf(fp, "; /////////////////////////////////////////////////////////////////////////////\n"); - mapDir.toLower(); MapCache::iterator it = begin(); - MapMetaData md; - while (it != end()) + for (; it != end(); ++it) { if (it->first.startsWithNoCase(mapDir.str())) { - md = it->second; + const MapMetaData &md = it->second; fprintf(fp, "\nMapCache %s\n", AsciiStringToQuotedPrintable(it->first.str()).str()); fprintf(fp, " fileSize = %u\n", md.m_filesize); fprintf(fp, " fileCRC = %u\n", md.m_CRC); @@ -413,31 +367,31 @@ void MapCache::writeCacheINI( Bool userDir ) fprintf(fp, " extentMax = X:%2.2f Y:%2.2f Z:%2.2f\n", md.m_extent.hi.x, md.m_extent.hi.y, md.m_extent.hi.z); // BAD AND NOW UNUSED: the mapcache.ini should not contain localized data... using the lookup tag instead -// fprintf(fp, " displayName = %s\n", UnicodeStringToQuotedPrintable(md.m_displayName).str()); +#if RTS_GENERALS + fprintf(fp, " displayName = %s\n", UnicodeStringToQuotedPrintable(md.m_displayName).str()); +#else fprintf(fp, " nameLookupTag = %s\n", md.m_nameLookupTag.str()); +#endif Coord3D pos; - WaypointMap::iterator itw = md.m_waypoints.begin(); - while (itw != md.m_waypoints.end()) + WaypointMap::const_iterator itw = md.m_waypoints.begin(); + for (; itw != md.m_waypoints.end(); ++itw) { pos = itw->second; fprintf(fp, " %s = X:%2.2f Y:%2.2f Z:%2.2f\n", itw->first.str(), pos.x, pos.y, pos.z); - ++itw; } - Coord3DList::iterator itc3d = md.m_techPositions.begin(); - while (itc3d != md.m_techPositions.end()) + Coord3DList::const_iterator itc3d = md.m_techPositions.begin(); + for (; itc3d != md.m_techPositions.end(); ++itc3d) { pos = *itc3d; fprintf(fp, " techPosition = X:%2.2f Y:%2.2f Z:%2.2f\n", pos.x, pos.y, pos.z); - itc3d++; } itc3d = md.m_supplyPositions.begin(); - while (itc3d != md.m_supplyPositions.end()) + for (; itc3d != md.m_supplyPositions.end(); ++itc3d) { pos = *itc3d; fprintf(fp, " supplyPosition = X:%2.2f Y:%2.2f Z:%2.2f\n", pos.x, pos.y, pos.z); - itc3d++; } fprintf(fp, "END\n\n"); } @@ -445,7 +399,6 @@ void MapCache::writeCacheINI( Bool userDir ) { //DEBUG_LOG(("%s does not start %s", mapDir.str(), it->first.str())); } - ++it; } fclose(fp); @@ -455,204 +408,184 @@ void MapCache::updateCache( void ) { setFPMode(); - TheFileSystem->createDirectory(getUserMapDir()); + const AsciiString mapDir = getMapDir(); + const AsciiString userMapDir = getUserMapDir(); - if (loadUserMaps()) + // Create the standard map cache if required. Is only relevant for Mod developers. + // TheSuperHackers @tweak This step is done before loading any other map caches to not poison the cached state. + if (m_doCreateStandardMapCacheINI) { - writeCacheINI( TRUE ); - } - loadStandardMaps(); // we shall overwrite info from matching user maps to prevent munkees from getting rowdy :) #if defined(RTS_DEBUG) - if (TheLocalFileSystem->doesFileExist(getMapDir().str())) + // only create the map cache file if "Maps" folder exists + const Bool buildMapCache = TheLocalFileSystem->doesFileExist(mapDir.str()); +#else + const Bool buildMapCache = TheGlobalData->m_buildMapCache; +#endif + if (buildMapCache) + { + const Bool isOfficial = TRUE; + const Bool filterByAllowedMaps = !m_allowedMaps.empty(); + + if (loadMapsFromDisk(mapDir, isOfficial, filterByAllowedMaps)) + { + writeCacheINI(mapDir); + } + } + m_doCreateStandardMapCacheINI = FALSE; + } + + // Load user map cache first. + if (m_doLoadUserMapCacheINI) { - // only create the map cache file if "Maps" exist - Bool wasBuildMapCache = TheGlobalData->m_buildMapCache; - TheWritableGlobalData->m_buildMapCache = true; - loadUserMaps(); - TheWritableGlobalData->m_buildMapCache = wasBuildMapCache; - writeCacheINI( FALSE ); + loadMapsFromMapCacheINI(userMapDir); + m_doLoadUserMapCacheINI = FALSE; + } + + // Load user maps from disk and update any discrepancies from the map cache. + if (loadMapsFromDisk(userMapDir, FALSE)) + { + writeCacheINI(userMapDir); + m_doLoadStandardMapCacheINI = TRUE; + } + + // Load standard maps from map cache last. + // This overwrites matching user maps to prevent munkees getting rowdy :) + if (m_doLoadStandardMapCacheINI) + { + loadMapsFromMapCacheINI(mapDir); + m_doLoadStandardMapCacheINI = FALSE; } -#endif } -Bool MapCache::clearUnseenMaps( AsciiString dirName ) +void MapCache::prepareUnseenMaps( const AsciiString &mapDir ) { - dirName.toLower(); - Bool erasedSomething = FALSE; + MapCache::iterator it = begin(); + for (; it != end(); ++it) + { + const AsciiString &mapName = it->first; - std::map::iterator it = m_seen.begin(); + if (mapName.startsWithNoCase(mapDir.str())) + { + it->second.m_doesExist = FALSE; + } + } +} + +Bool MapCache::clearUnseenMaps( const AsciiString &mapDir ) +{ + Bool erasedSomething = FALSE; - while (it != m_seen.end()) + MapCache::iterator it = begin(); + while (it != end()) { - AsciiString mapName = it->first; - if (it->second == FALSE && mapName.startsWithNoCase(dirName.str())) + MapCache::iterator next = it; + ++next; + + const AsciiString &mapName = it->first; + const MapMetaData &mapData = it->second; + + if (mapName.startsWithNoCase(mapDir.str()) && !mapData.m_doesExist) { - // not seen in the dir - clear it out. - erase(mapName); + erase(it); erasedSomething = TRUE; } - ++it; + + it = next; } + return erasedSomething; } -void MapCache::loadStandardMaps(void) +void MapCache::loadMapsFromMapCacheINI( const AsciiString &mapDir ) { INI ini; AsciiString fname; - fname.format("%s\\%s", getMapDir().str(), m_mapCacheName); -#if defined(RTS_DEBUG) - File *fp = TheFileSystem->openFile(fname.str(), File::READ); - if (fp != NULL) + fname.format("%s\\%s", mapDir.str(), m_mapCacheName); + + if (TheFileSystem->doesFileExist(fname.str())) { - fp->close(); - fp = NULL; -#endif ini.load( fname, INI_LOAD_OVERWRITE, NULL ); -#if defined(RTS_DEBUG) } -#endif } -Bool MapCache::loadUserMaps() +Bool MapCache::loadMapsFromDisk( const AsciiString &mapDir, Bool isOfficial, Bool filterByAllowedMaps ) { - // Read in map list from disk - AsciiString mapDir; - if (TheGlobalData->m_buildMapCache) - { - mapDir = getMapDir(); - } - else - { - mapDir = getUserMapDir(); + prepareUnseenMaps(mapDir); - INI ini; - AsciiString fname; - fname.format("%s\\%s", mapDir.str(), m_mapCacheName); - File *fp = TheFileSystem->openFile(fname.str(), File::READ); - if (fp) - { - fp->close(); - ini.load( fname, INI_LOAD_OVERWRITE, NULL ); - } - - } - - // mark all as unseen - m_seen.clear(); - MapCache::iterator it = begin(); - while (it != end()) - { - m_seen[it->first] = FALSE; - ++it; - } - - FilenameList filenameList; - FilenameListIter iter; + FilenameList filepathList; + FilenameListIter filepathIt; AsciiString toplevelPattern; toplevelPattern.format("%s\\", mapDir.str()); - Bool parsedAMap = FALSE; + Bool mapListChanged = FALSE; AsciiString filenamepattern; filenamepattern.format("*.%s", getMapExtension().str()); - TheFileSystem->getFileListInDirectory(toplevelPattern, filenamepattern, filenameList, TRUE); + TheFileSystem->getFileListInDirectory(toplevelPattern, filenamepattern, filepathList, TRUE); - iter = filenameList.begin(); + filepathIt = filepathList.begin(); - while (iter != filenameList.end()) { + for (; filepathIt != filepathList.end(); ++filepathIt) + { FileInfo fileInfo; - AsciiString tempfilename; - tempfilename = (*iter); - tempfilename.toLower(); + AsciiString filepathLower = *filepathIt; + filepathLower.toLower(); - const char *s = tempfilename.reverseFind('\\'); - if (!s) + const char *szFilenameLower = filepathLower.reverseFind('\\'); + if (!szFilenameLower) { DEBUG_CRASH(("Couldn't find \\ in map name!")); + continue; } - else + + AsciiString endingStr; + AsciiString filenameLower = szFilenameLower+1; + filenameLower.truncateBy(strlen(mapExtension)); + + if (filterByAllowedMaps && m_allowedMaps.find(filenameLower) == m_allowedMaps.end()) { - AsciiString endingStr; - AsciiString fname = s+1; - fname.truncateBy(strlen(mapExtension)); + DEBUG_CRASH(("Map '%s' has been filtered out", filenameLower.str())); + continue; + } - endingStr.format("%s\\%s%s", fname.str(), fname.str(), mapExtension); + endingStr.format("%s\\%s%s", filenameLower.str(), filenameLower.str(), mapExtension); - Bool skipMap = FALSE; - if (TheGlobalData->m_buildMapCache) - { - std::set::const_iterator sit = m_allowedMaps.find(fname); - if (m_allowedMaps.size() != 0 && sit == m_allowedMaps.end()) - { - //DEBUG_LOG(("Skipping map: '%s'", fname.str())); - skipMap = TRUE; - } - else - { - //DEBUG_LOG(("Parsing map: '%s'", fname.str())); - } - } + if (!filepathLower.endsWithNoCase(endingStr.str())) + { + DEBUG_CRASH(("Found map '%s' in wrong spot (%s)", filenameLower.str(), filepathLower.str())); + continue; + } - if (!skipMap) - { - if (!tempfilename.endsWithNoCase(endingStr.str())) - { - DEBUG_CRASH(("Found map '%s' in wrong spot (%s)", fname.str(), tempfilename.str())); - } - else - { - if (TheFileSystem->getFileInfo(tempfilename, &fileInfo)) { - char funk[_MAX_PATH]; - strcpy(funk, tempfilename.str()); - char *filenameptr = funk; - char *tempchar = funk; - while (*tempchar != 0) { - if ((*tempchar == '\\') || (*tempchar == '/')) { - filenameptr = tempchar+1; - } - ++tempchar; - } - - m_seen[tempfilename] = TRUE; - parsedAMap |= addMap(mapDir, *iter, &fileInfo, TheGlobalData->m_buildMapCache); - } else { - DEBUG_CRASH(("Could not get file info for map %s", (*iter).str())); - } - } - } + if (!TheFileSystem->getFileInfo(*filepathIt, &fileInfo)) + { + DEBUG_CRASH(("Could not get file info for map %s", filepathIt->str())); + continue; } - iter++; + + mapListChanged |= addMap(mapDir, *filepathIt, filepathLower, fileInfo, isOfficial); } - // clean out unseen maps if (clearUnseenMaps(mapDir)) - return TRUE; + { + mapListChanged = TRUE; + } - return parsedAMap; + return mapListChanged; } -//Bool MapCache::addMap( AsciiString dirName, AsciiString fname, WinTimeStamp timestamp, UnsignedInt filesize, Bool isOfficial ) -Bool MapCache::addMap( AsciiString dirName, AsciiString fname, FileInfo *fileInfo, Bool isOfficial) +Bool MapCache::addMap( + const AsciiString &mapDir, + const AsciiString &fname, + const AsciiString &lowerFname, + FileInfo &fileInfo, + Bool isOfficial) { - if (fileInfo == NULL) { - return FALSE; - } - - AsciiString lowerFname; - lowerFname = fname; - lowerFname.toLower(); MapCache::iterator it = find(lowerFname); - - MapMetaData md; - UnsignedInt filesize = fileInfo->sizeLow; - if (it != end()) { - // Found the map in our cache. Check to see if it has changed. - md = it->second; + // Found the map in our cache. Check to see if it has changed. + const MapMetaData& md = it->second; - if ((md.m_filesize == filesize) && - (md.m_CRC != 0)) + if (md.m_filesize == fileInfo.sizeLow && md.m_CRC != 0) { // Force a lookup so that we don't display the English localization in all builds. if (md.m_nameLookupTag.isEmpty()) @@ -679,13 +612,16 @@ Bool MapCache::addMap( AsciiString dirName, AsciiString fname, FileInfo *fileInf (*this)[lowerFname].m_displayName.concat(extension); } } + + it->second.m_doesExist = TRUE; + // DEBUG_LOG(("MapCache::addMap - found match for map %s", lowerFname.str())); return FALSE; // OK, it checks out. } DEBUG_LOG(("%s didn't match file in MapCache", fname.str())); - DEBUG_LOG(("size: %d / %d", filesize, md.m_filesize)); - DEBUG_LOG(("time1: %d / %d", fileInfo->timestampHigh, md.m_timestamp.m_highTimeStamp)); - DEBUG_LOG(("time2: %d / %d", fileInfo->timestampLow, md.m_timestamp.m_lowTimeStamp)); + DEBUG_LOG(("size: %d / %d", fileInfo.sizeLow, md.m_filesize)); + DEBUG_LOG(("time1: %d / %d", fileInfo.timestampHigh, md.m_timestamp.m_highTimeStamp)); + DEBUG_LOG(("time2: %d / %d", fileInfo.timestampLow, md.m_timestamp.m_lowTimeStamp)); // DEBUG_LOG(("size: %d / %d", filesize, md.m_filesize)); // DEBUG_LOG(("time1: %d / %d", timestamp.m_highTimeStamp, md.m_timestamp.m_highTimeStamp)); // DEBUG_LOG(("time2: %d / %d", timestamp.m_lowTimeStamp, md.m_timestamp.m_lowTimeStamp)); @@ -696,22 +632,25 @@ Bool MapCache::addMap( AsciiString dirName, AsciiString fname, FileInfo *fileInf loadMap(fname); // Just load for querying the data, since we aren't playing this map. // The map is now loaded. Pick out what we need. + MapMetaData md; md.m_fileName = lowerFname; - md.m_filesize = filesize; + md.m_filesize = fileInfo.sizeLow; md.m_isOfficial = isOfficial; + md.m_doesExist = TRUE; md.m_waypoints.update(); md.m_numPlayers = md.m_waypoints.m_numStartSpots; md.m_isMultiplayer = (md.m_numPlayers >= 2); - md.m_timestamp.m_highTimeStamp = fileInfo->timestampHigh; - md.m_timestamp.m_lowTimeStamp = fileInfo->timestampLow; + md.m_timestamp.m_highTimeStamp = fileInfo.timestampHigh; + md.m_timestamp.m_lowTimeStamp = fileInfo.timestampLow; md.m_supplyPositions = m_supplyPositions; md.m_techPositions = m_techPositions; - md.m_CRC = calcCRC(dirName, fname); + md.m_CRC = calcCRC(fname); Bool exists = false; - AsciiString munkee = worldDict.getAsciiString(TheKey_mapName, &exists); - md.m_nameLookupTag = munkee; - if (!exists || munkee.isEmpty()) + AsciiString nameLookupTag = worldDict.getAsciiString(TheKey_mapName, &exists); + md.m_nameLookupTag = nameLookupTag; + + if (!exists || nameLookupTag.isEmpty()) { DEBUG_LOG(("Missing TheKey_mapName!")); AsciiString tempdisplayname; @@ -728,11 +667,11 @@ Bool MapCache::addMap( AsciiString dirName, AsciiString fname, FileInfo *fileInf else { AsciiString stringFileName; - stringFileName.format("%s\\%s", dirName.str(), fname.str()); + stringFileName.format("%s\\%s", mapDir.str(), fname.str()); stringFileName.truncateBy(4); stringFileName.concat("\\map.str"); TheGameText->initMapStringFile(stringFileName); - md.m_displayName = TheGameText->fetch(munkee); + md.m_displayName = TheGameText->fetch(nameLookupTag); if (md.m_numPlayers >= 2) { UnicodeString extension; @@ -762,11 +701,10 @@ Bool MapCache::addMap( AsciiString dirName, AsciiString fname, FileInfo *fileInf Coord3D pos; WaypointMap::iterator itw = md.m_waypoints.begin(); - while (itw != md.m_waypoints.end()) + for (; itw != md.m_waypoints.end(); ++itw) { pos = itw->second; DEBUG_LOG((" waypoint %s: (%2.2f,%2.2f)", itw->first.str(), pos.x, pos.y)); - ++itw; } resetMap(); @@ -783,6 +721,187 @@ Bool WouldMapTransfer( const AsciiString& mapName ) return mapName.startsWithNoCase(TheMapCache->getUserMapDir()); } +//------------------------------------------------------------------------------------------------- +typedef std::set > MapNameList; +typedef std::map MapDisplayToFileNameList; + +static void buildMapListForNumPlayers(MapNameList &outMapNames, MapDisplayToFileNameList &outFileNames, Int numPlayers) +{ + MapCache::iterator it = TheMapCache->begin(); + + for (; it != TheMapCache->end(); ++it) + { + const MapMetaData &mapData = it->second; + if (mapData.m_numPlayers == numPlayers) + { + outMapNames.insert(it->second.m_displayName); + outFileNames[it->second.m_displayName] = it->first; + } + } +} + +//------------------------------------------------------------------------------------------------- +struct MapListBoxData +{ + MapListBoxData() + : listbox(NULL) + , numLength(0) + , numColumns(0) + , w(10) + , h(10) + , color(GameMakeColor(255, 255, 255, 255)) + , battleHonors(NULL) + , easyImage(NULL) + , mediumImage(NULL) + , brutalImage(NULL) + , maxBrutalImage(NULL) + , mapToSelect() + , selectionIndex(0) // always select *something* + , isMultiplayer(false) + { + } + + GameWindow *listbox; + Int numLength; + Int numColumns; + Int w; + Int h; + Color color; + const SkirmishBattleHonors *battleHonors; + const Image *easyImage; + const Image *mediumImage; + const Image *brutalImage; + const Image *maxBrutalImage; + AsciiString mapToSelect; + Int selectionIndex; + Bool isMultiplayer; +}; + +//------------------------------------------------------------------------------------------------- +static Bool addMapToMapListbox( + MapListBoxData& lbData, + const AsciiString& mapDir, + const AsciiString& mapName, + const MapMetaData& mapMetaData) +{ + const Bool mapOk = mapName.startsWithNoCase(mapDir.str()) && lbData.isMultiplayer == mapMetaData.m_isMultiplayer && !mapMetaData.m_displayName.isEmpty(); + + if (mapOk) + { + UnicodeString mapDisplayName; + /// @todo: mapDisplayName = TheGameText->fetch(mapMetaData.m_displayName.str()); + mapDisplayName = mapMetaData.m_displayName; + + Int index = -1; + Int imageItemData = -1; + if (lbData.numColumns > 1 && mapMetaData.m_isMultiplayer) + { + const Int numEasy = lbData.battleHonors->getEnduranceMedal(mapName.str(), SLOT_EASY_AI); + const Int numMedium = lbData.battleHonors->getEnduranceMedal(mapName.str(), SLOT_MED_AI); + const Int numBrutal = lbData.battleHonors->getEnduranceMedal(mapName.str(), SLOT_BRUTAL_AI); + if (numBrutal) + { + const Int maxBrutalSlots = mapMetaData.m_numPlayers - 1; + if (lbData.maxBrutalImage != NULL && numBrutal == maxBrutalSlots) + { + index = GadgetListBoxAddEntryImage( lbData.listbox, lbData.maxBrutalImage, index, 0, lbData.w, lbData.h, TRUE); + imageItemData = 4; + } + else + { + index = GadgetListBoxAddEntryImage( lbData.listbox, lbData.brutalImage, index, 0, lbData.w, lbData.h, TRUE); + imageItemData = 3; + } + } + else if (numMedium) + { + imageItemData = 2; + index = GadgetListBoxAddEntryImage( lbData.listbox, lbData.mediumImage, index, 0, lbData.w, lbData.h, TRUE); + } + else if (numEasy) + { + imageItemData = 1; + index = GadgetListBoxAddEntryImage( lbData.listbox, lbData.easyImage, index, 0, lbData.w, lbData.h, TRUE); + } + else + { + imageItemData = 0; + index = GadgetListBoxAddEntryImage( lbData.listbox, NULL, index, 0, lbData.w, lbData.h, TRUE); + } + } + + index = GadgetListBoxAddEntryText( lbData.listbox, mapDisplayName, lbData.color, index, lbData.numColumns-1 ); + DEBUG_ASSERTCRASH(index >= 0, ("Expects valid index")); + + if (mapName == lbData.mapToSelect) + { + lbData.selectionIndex = index; + } + + // now set the char* as the item data. this works because the map cache isn't being + // modified while a map listbox is up. + GadgetListBoxSetItemData( lbData.listbox, (void *)(mapName.str()), index ); + + if (lbData.numColumns > 1) + { + GadgetListBoxSetItemData( lbData.listbox, (void *)imageItemData, index, 1 ); + } + + // TheSuperHackers @performance Now stops processing when the list is full. + if (index == lbData.numLength - 1) + { + return false; + } + } + + return true; +} + +//------------------------------------------------------------------------------------------------- +static Bool addMapCollectionToMapListbox( + MapListBoxData& lbData, + const AsciiString& mapDir, + const MapNameList& mapNames, + const MapDisplayToFileNameList& fileNames) +{ + MapNameList::const_iterator mapNameIt = mapNames.begin(); + + for (; mapNameIt != mapNames.end(); ++mapNameIt) + { + MapDisplayToFileNameList::const_iterator fileNameIt = fileNames.find(*mapNameIt); + DEBUG_ASSERTCRASH(fileNameIt != fileNames.end(), ("Map '%s' not found in file names map", mapNameIt->str())); + + const AsciiString& asciiMapName = fileNameIt->second; + +#if RTS_ZEROHOUR + //Patch 1.03 -- Purposely filter out these broken maps that exist in Generals. + if( !asciiMapName.compare( "maps\\armored fury\\armored fury.map" ) || + !asciiMapName.compare( "maps\\scorched earth\\scorched earth.map" ) ) + { + continue; + } +#endif + + MapCache::iterator mapCacheIt = TheMapCache->find(asciiMapName); + DEBUG_ASSERTCRASH(mapCacheIt != TheMapCache->end(), ("Map '%s' not found in map cache.", mapNameIt->str())); + /* + if (it != TheMapCache->end()) + { + DEBUG_LOG(("populateMapListbox(): looking at %s (displayName = %ls), mp = %d (== %d?) mapDir=%s (ok=%d)", + it->first.str(), it->second.m_displayName.str(), it->second.m_isMultiplayer, isMultiplayer, + mapDir.str(), it->first.startsWith(mapDir.str()))); + } + */ + + const Bool ok = addMapToMapListbox(lbData, mapDir, mapCacheIt->first, mapCacheIt->second); + + if (!ok) + return false; + } + + return true; +} + //------------------------------------------------------------------------------------------------- /** Load the listbox with all the map files available to play */ //------------------------------------------------------------------------------------------------- @@ -794,35 +913,26 @@ Int populateMapListboxNoReset( GameWindow *listbox, Bool useSystemMaps, Bool isM if (!listbox) return -1; - // reset the listbox content - //GadgetListBoxReset( listbox ); - - Int numColumns = GadgetListBoxGetNumColumns( listbox ); - const Image *easyImage = NULL; - const Image *mediumImage = NULL; - const Image *brutalImage = NULL; - const Image *maxBrutalImage = NULL; - SkirmishBattleHonors *battleHonors = NULL; - Int w = 10, h = 10; - if (numColumns > 1) + MapListBoxData lbData; + lbData.listbox = listbox; + lbData.numLength = GadgetListBoxGetListLength( listbox ); + lbData.numColumns = GadgetListBoxGetNumColumns( listbox ); + lbData.mapToSelect = mapToSelect; + lbData.isMultiplayer = isMultiplayer; + + if (lbData.numColumns > 1) { - easyImage = TheMappedImageCollection->findImageByName("Star-Bronze"); - mediumImage = TheMappedImageCollection->findImageByName("Star-Silver"); - brutalImage = TheMappedImageCollection->findImageByName("Star-Gold"); - maxBrutalImage = TheMappedImageCollection->findImageByName("RedYell_Star"); - battleHonors = new SkirmishBattleHonors; - - w = (brutalImage)?brutalImage->getImageWidth():10; - w = min(GadgetListBoxGetColumnWidth(listbox, 0), w); - h = w; + lbData.easyImage = TheMappedImageCollection->findImageByName("Star-Bronze"); + lbData.mediumImage = TheMappedImageCollection->findImageByName("Star-Silver"); + lbData.brutalImage = TheMappedImageCollection->findImageByName("Star-Gold"); + lbData.maxBrutalImage = TheMappedImageCollection->findImageByName("RedYell_Star"); + lbData.battleHonors = new SkirmishBattleHonors; + + lbData.w = lbData.brutalImage ? lbData.brutalImage->getImageWidth() : 10; + lbData.w = min(GadgetListBoxGetColumnWidth(listbox, 0), lbData.w); + lbData.h = lbData.w; } - Color color = GameMakeColor( 255, 255, 255, 255 ); - UnicodeString mapDisplayName; - - Int selectionIndex = 0; // always select *something* - - MapCache::iterator it = TheMapCache->begin(); AsciiString mapDir; if (useSystemMaps) { @@ -835,148 +945,44 @@ Int populateMapListboxNoReset( GameWindow *listbox, Bool useSystemMaps, Bool isM } mapDir.toLower(); -typedef std::set > MapNameList; -typedef MapNameList::iterator MapNameListIter; - -typedef std::map MapDisplayToFileNameList; -typedef MapDisplayToFileNameList::iterator MapDisplayToFileNameListIter; - - MapNameList tempCache; - MapDisplayToFileNameList filenameMap; - UnsignedInt numMapsListed = 0; - UnsignedInt curNumPlayersInMap = 0; - - while (numMapsListed < TheMapCache->size()) { - - DEBUG_LOG(("Adding maps with %d players", curNumPlayersInMap)); - it = TheMapCache->begin(); - while (it != TheMapCache->end()) { - const MapMetaData *md = &(it->second); - if (md != NULL) { - if (md->m_numPlayers == curNumPlayersInMap) { - tempCache.insert(it->second.m_displayName); - filenameMap[it->second.m_displayName] = it->first; - DEBUG_LOG(("Adding map %s to temp cache.", it->first.str())); - ++numMapsListed; - } - } - ++it; - } - - MapNameListIter tempit = tempCache.begin(); - - while (tempit != tempCache.end()) - { - - AsciiString asciiMapName; - asciiMapName = filenameMap[*tempit]; - it = TheMapCache->find(asciiMapName); - /* - if (it != TheMapCache->end()) - { - DEBUG_LOG(("populateMapListbox(): looking at %s (displayName = %ls), mp = %d (== %d?) mapDir=%s (ok=%d)", - it->first.str(), it->second.m_displayName.str(), it->second.m_isMultiplayer, isMultiplayer, - mapDir.str(), it->first.startsWith(mapDir.str()))); - } - */ - - //Patch 1.03 -- Purposely filter out these broken maps that exist in Generals. - if( !asciiMapName.compare( "maps\\armored fury\\armored fury.map" ) || - !asciiMapName.compare( "maps\\scorched earth\\scorched earth.map" ) ) - { - ++tempit; - continue; - } + MapNameList mapNames; + MapDisplayToFileNameList fileNames; + Int curNumPlayersInMap = 1; - DEBUG_ASSERTCRASH(it != TheMapCache->end(), ("Map %s not found in map cache.", tempit->str())); - if (it->first.startsWithNoCase(mapDir.str()) && isMultiplayer == it->second.m_isMultiplayer && !it->second.m_displayName.isEmpty()) - { - /// @todo: mapDisplayName = TheGameText->fetch(it->second.m_displayName.str()); - mapDisplayName = it->second.m_displayName; - Int index = -1; - Int imageItemData = -1; - if (numColumns > 1 && it->second.m_isMultiplayer) - { - Int numEasy = battleHonors->getEnduranceMedal(it->first.str(), SLOT_EASY_AI); - Int numMedium = battleHonors->getEnduranceMedal(it->first.str(), SLOT_MED_AI); - Int numBrutal = battleHonors->getEnduranceMedal(it->first.str(), SLOT_BRUTAL_AI); - if (numBrutal) - { - int maxBrutalSlots = it->second.m_numPlayers - 1; - if (numBrutal == maxBrutalSlots) - { - index = GadgetListBoxAddEntryImage( listbox, maxBrutalImage, index, 0, w, h, TRUE); - imageItemData = 4; - } - else - { - index = GadgetListBoxAddEntryImage( listbox, brutalImage, index, 0, w, h, TRUE); - imageItemData = 3; - } - } - else if (numMedium) - { - imageItemData = 2; - index = GadgetListBoxAddEntryImage( listbox, mediumImage, index, 0, w, h, TRUE); - } - else if (numEasy) - { - imageItemData = 1; - index = GadgetListBoxAddEntryImage( listbox, easyImage, index, 0, w, h, TRUE); - } - else - { - imageItemData = 0; - index = GadgetListBoxAddEntryImage( listbox, NULL, index, 0, w, h, TRUE); - } - } - index = GadgetListBoxAddEntryText( listbox, mapDisplayName, color, index, numColumns-1 ); + for (; curNumPlayersInMap <= MAX_SLOTS; ++curNumPlayersInMap) + { + buildMapListForNumPlayers(mapNames, fileNames, curNumPlayersInMap); - if (it->first == mapToSelect) - { - selectionIndex = index; - } + const Bool ok = addMapCollectionToMapListbox(lbData, mapDir, mapNames, fileNames); - // now set the char* as the item data. this works because the map cache isn't being - // modified while a map listbox is up. - GadgetListBoxSetItemData( listbox, (void *)(it->first.str()), index ); + mapNames.clear(); + fileNames.clear(); - if (numColumns > 1) - { - GadgetListBoxSetItemData( listbox, (void *)imageItemData, index, 1 ); - } - } - ++tempit; - } - - tempCache.clear(); - filenameMap.clear(); - ++curNumPlayersInMap; + if (!ok) + break; } - if (battleHonors) - { - delete battleHonors; - battleHonors = NULL; - } + delete lbData.battleHonors; + lbData.battleHonors = NULL; + + GadgetListBoxSetSelected(listbox, &lbData.selectionIndex, 1); - GadgetListBoxSetSelected(listbox, &selectionIndex, 1); - if (selectionIndex >= 0) + if (lbData.selectionIndex >= 0) { Int topIndex = GadgetListBoxGetTopVisibleEntry(listbox); Int bottomIndex = GadgetListBoxGetBottomVisibleEntry(listbox); Int rowsOnScreen = bottomIndex - topIndex; - if (selectionIndex >= bottomIndex) + if (lbData.selectionIndex >= bottomIndex) { - Int newTop = max( 0, selectionIndex - max( 1, rowsOnScreen / 2 ) ); - //The trouble is that rowsonscreen/2 can be zero if bottom is 1 and top is zero + Int newTop = max( 0, lbData.selectionIndex - max( 1, rowsOnScreen / 2 ) ); + //The trouble is that rowsOnScreen/2 can be zero if bottom is 1 and top is zero GadgetListBoxSetTopVisibleEntry( listbox, newTop ); } } - return selectionIndex; -} // end loadMapListbox + return lbData.selectionIndex; +} //------------------------------------------------------------------------------------------------- /** Load the listbox with all the map files available to play */ @@ -1017,7 +1023,7 @@ Bool isValidMap( AsciiString mapName, Bool isMultiplayer ) } return FALSE; -} // end isValidMap +} //------------------------------------------------------------------------------------------------- /** Find a valid map */ @@ -1029,13 +1035,12 @@ AsciiString getDefaultMap( Bool isMultiplayer ) TheMapCache->updateCache(); MapCache::iterator it = TheMapCache->begin(); - while (it != TheMapCache->end()) + for (; it != TheMapCache->end(); ++it) { if (isMultiplayer == it->second.m_isMultiplayer) { return it->first; } - ++it; } return AsciiString::TheEmptyString; @@ -1049,13 +1054,12 @@ AsciiString getDefaultOfficialMap() TheMapCache->updateCache(); MapCache::iterator it = TheMapCache->begin(); - while (it != TheMapCache->end()) + for (; it != TheMapCache->end(); ++it) { if (it->second.m_isMultiplayer && it->second.m_isOfficial) { return it->first; } - ++it; } return AsciiString::TheEmptyString; } @@ -1095,7 +1099,7 @@ static void copyFromBigToDir( const AsciiString& infile, const AsciiString& outf { DEBUG_CRASH(( "copyFromBigToDir - Error opening source file '%s'", infile.str() )); throw SC_INVALID_DATA; - } // end if + } // how big is the map file Int fileSize = file->seek( 0, File::END ); @@ -1110,14 +1114,14 @@ static void copyFromBigToDir( const AsciiString& infile, const AsciiString& outf { DEBUG_CRASH(( "copyFromBigToDir - Unable to allocate buffer for file '%s'", infile.str() )); throw SC_INVALID_DATA; - } // end if + } // copy the file to the buffer if( file->read( buffer, fileSize ) < fileSize ) { DEBUG_CRASH(( "copyFromBigToDir - Error reading from file '%s'", infile.str() )); throw SC_INVALID_DATA; - } // end if + } // close the BIG file file->close(); @@ -1127,13 +1131,13 @@ static void copyFromBigToDir( const AsciiString& infile, const AsciiString& outf { DEBUG_CRASH(( "copyFromBigToDir - Error writing to file '%s'", outfile.str() )); throw SC_INVALID_DATA; - } // end if + } filenew->close(); // delete the buffer delete [] buffer; -} // end embedPristineMap +} Image *getMapPreviewImage( AsciiString mapName ) { @@ -1143,12 +1147,8 @@ Image *getMapPreviewImage( AsciiString mapName ) AsciiString tgaName = mapName; AsciiString name; AsciiString tempName; - AsciiString filename; tgaName.truncateBy(4); // ".map" - name = tgaName;//.reverseFind('\\') + 1; - filename = tgaName.reverseFind('\\') + 1; - //tgaName = name; - filename.concat(".tga"); + name = tgaName; tgaName.concat(".tga"); AsciiString portableName = TheGameState->realMapPathToPortableMapPath(name); @@ -1233,7 +1233,7 @@ Image *getMapPreviewImage( AsciiString mapName ) mapPreviewImage->setStatus(IMAGE_STATUS_RAW_TEXTURE); // allocate our terrain texture TextureClass * texture = new TextureClass( size.x, size.y, - WW3D_FORMAT_X8R8G8B8, TextureClass::MIP_LEVELS_1 ); + WW3D_FORMAT_X8R8G8B8, MIP_LEVELS_1 ); uv.lo.x = 0.0f; uv.lo.y = 1.0f; uv.hi.x = 1.0f; @@ -1254,7 +1254,7 @@ Image *getMapPreviewImage( AsciiString mapName ) DataChunkInput file( pStrm ); if (file.isValidFileType()) { // Backwards compatible files aren't valid data chunk files. // Read the waypoints. - file.registerParser( AsciiString("MapPreview"), AsciiString::TheEmptyString, parseMapPreviewChunk ); + file.registerParser( "MapPreview", AsciiString::TheEmptyString, parseMapPreviewChunk ); if (!file.parse(NULL)) { DEBUG_ASSERTCRASH(false,("Unable to read MapPreview info.")); deleteInstance(mapPreviewImage); @@ -1344,5 +1344,5 @@ void findDrawPositions( Int startX, Int startY, Int width, Int height, Region3D lr->x += startX; lr->y += startY; -} // end findDrawPositions +} diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/ParabolicEase.cpp b/Core/GameEngine/Source/GameClient/ParabolicEase.cpp similarity index 96% rename from GeneralsMD/Code/GameEngine/Source/GameClient/ParabolicEase.cpp rename to Core/GameEngine/Source/GameClient/ParabolicEase.cpp index cebc09f8f2..ac92ae1977 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/ParabolicEase.cpp +++ b/Core/GameEngine/Source/GameClient/ParabolicEase.cpp @@ -60,7 +60,7 @@ ParabolicEase::setEaseTimes(Real easeInTime, Real easeOutTime) } if (m_in > m_out) { - DEBUG_CRASH(("Ease-in and ease-out overlap (in = %g, out = %g)", m_in, m_out)); + DEBUG_ASSERTCRASH(m_in <= m_out + FLT_EPSILON, ("Ease-in and ease-out overlap (in = %g, out = %g)", m_in, m_out)); m_in = m_out; } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Snow.cpp b/Core/GameEngine/Source/GameClient/Snow.cpp similarity index 96% rename from GeneralsMD/Code/GameEngine/Source/GameClient/Snow.cpp rename to Core/GameEngine/Source/GameClient/Snow.cpp index 92f0890833..46615690a7 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/Snow.cpp +++ b/Core/GameEngine/Source/GameClient/Snow.cpp @@ -27,7 +27,7 @@ // Author: Mark Wilczynski, July 2003 /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the Game +#include "PreRTS.h" // This must go first in EVERY cpp file in the Game #include "GameClient/Snow.h" #include "GameClient/View.h" @@ -96,11 +96,8 @@ SnowManager::~SnowManager() m_startingHeights=NULL; // TheSuperHackers @fix Mauller 13/04/2025 Delete the instance of the weather settings - if (TheWeatherSetting) - { - deleteInstance((WeatherSetting*)TheWeatherSetting.getNonOverloadedPointer()); - TheWeatherSetting=NULL; - } + deleteInstance((WeatherSetting*)TheWeatherSetting.getNonOverloadedPointer()); + TheWeatherSetting=NULL; } OVERRIDE TheWeatherSetting = NULL; diff --git a/Core/GameEngine/Source/GameClient/System/Debug/AudioDebugDisplay.cpp b/Core/GameEngine/Source/GameClient/System/Debug/AudioDebugDisplay.cpp index 0b4a041048..363cde812a 100644 --- a/Core/GameEngine/Source/GameClient/System/Debug/AudioDebugDisplay.cpp +++ b/Core/GameEngine/Source/GameClient/System/Debug/AudioDebugDisplay.cpp @@ -45,7 +45,7 @@ // Includes //---------------------------------------------------------------------------- -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameClient/DebugDisplay.h" #include "Common/GameAudio.h" diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/System/Smudge.cpp b/Core/GameEngine/Source/GameClient/System/Smudge.cpp similarity index 98% rename from GeneralsMD/Code/GameEngine/Source/GameClient/System/Smudge.cpp rename to Core/GameEngine/Source/GameClient/System/Smudge.cpp index 775bc879f5..62b40b491f 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/System/Smudge.cpp +++ b/Core/GameEngine/Source/GameClient/System/Smudge.cpp @@ -27,7 +27,7 @@ // Author: Mark Wilczynski, June 2003 /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the Game +#include "PreRTS.h" // This must go first in EVERY cpp file in the Game #include "GameClient/Smudge.h" diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Terrain/TerrainRoads.cpp b/Core/GameEngine/Source/GameClient/Terrain/TerrainRoads.cpp similarity index 95% rename from GeneralsMD/Code/GameEngine/Source/GameClient/Terrain/TerrainRoads.cpp rename to Core/GameEngine/Source/GameClient/Terrain/TerrainRoads.cpp index a352c248de..ceae1abd30 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/Terrain/TerrainRoads.cpp +++ b/Core/GameEngine/Source/GameClient/Terrain/TerrainRoads.cpp @@ -28,7 +28,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // INCLDUES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #define DEFINE_BODYDAMAGETYPE_NAMES #include "Common/INI.h" @@ -115,7 +115,7 @@ const FieldParse TerrainRoadType::m_terrainBridgeFieldParseTable[] = DEBUG_CRASH(( "Expected Damage/Repair transition keyword" )); throw INI_INVALID_DATA; - } // end else + } // get body damage state token = ini->getNextSubToken( "ToState" ); @@ -135,7 +135,7 @@ const FieldParse TerrainRoadType::m_terrainBridgeFieldParseTable[] = DEBUG_CRASH(( "Effect number max on bridge transitions is '%d'", MAX_BRIDGE_BODY_FX )); throw INI_INVALID_DATA; - } // end if + } // read the string token = ini->getNextSubToken( "OCL" ); @@ -144,7 +144,7 @@ const FieldParse TerrainRoadType::m_terrainBridgeFieldParseTable[] = else theInstance->friend_setRepairedToOCLString( state, effectNum, AsciiString( token ) ); -} // end parseTransitionToOCL +} // ------------------------------------------------------------------------------------------------ /** In the form of @@ -171,7 +171,7 @@ const FieldParse TerrainRoadType::m_terrainBridgeFieldParseTable[] = DEBUG_CRASH(( "Expected Damage/Repair transition keyword" )); throw INI_INVALID_DATA; - } // end else + } // get body damage state token = ini->getNextSubToken( "ToState" ); @@ -191,7 +191,7 @@ const FieldParse TerrainRoadType::m_terrainBridgeFieldParseTable[] = DEBUG_CRASH(( "Effect number max on bridge transitions is '%d'", MAX_BRIDGE_BODY_FX )); throw INI_INVALID_DATA; - } // end if + } // read the string token = ini->getNextSubToken( "FX" ); @@ -200,7 +200,7 @@ const FieldParse TerrainRoadType::m_terrainBridgeFieldParseTable[] = else theInstance->friend_setRepairedToFXString( state, effectNum, AsciiString( token ) ); -} // end parseTransitionToFX +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -219,14 +219,14 @@ TerrainRoadType::TerrainRoadType( void ) m_transitionEffectsHeight = 0.0f; m_numFXPerType = 0; -} // end TerrainRoadType +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- TerrainRoadType::~TerrainRoadType( void ) { -} // end ~TerrainRoadType +} /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -242,7 +242,7 @@ TerrainRoadCollection::TerrainRoadCollection( void ) m_idCounter = 1; ///< MUST start this at 1. -} // end TerrainRoadCollection +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -263,7 +263,7 @@ TerrainRoadCollection::~TerrainRoadCollection( void ) // set the new head of the list m_roadList = temp; - } // end while + } // delete all bridges in the list while( m_bridgeList ) @@ -278,9 +278,9 @@ TerrainRoadCollection::~TerrainRoadCollection( void ) // set the new head of the list m_bridgeList = temp; - } // end while + } -} // end ~TerrainRoadCollection +} //------------------------------------------------------------------------------------------------- /** Find road with matching name */ @@ -295,12 +295,12 @@ TerrainRoadType *TerrainRoadCollection::findRoad( AsciiString name ) if( road->getName() == name ) return road; - } // end for road + } // not found return NULL; -} // end findRoad +} //------------------------------------------------------------------------------------------------- /** Find bridge with matching name */ @@ -315,12 +315,12 @@ TerrainRoadType *TerrainRoadCollection::findBridge( AsciiString name ) if( bridge->getName() == name ) return bridge; - } // end for bridge + } // not found return NULL; -} // end findBridge +} //------------------------------------------------------------------------------------------------- /** Search the roads AND bridge lists for the name */ @@ -334,7 +334,7 @@ TerrainRoadType *TerrainRoadCollection::findRoadOrBridge( AsciiString name ) else return findBridge( name ); -} // end findRoadOrBridge +} //------------------------------------------------------------------------------------------------- /** Allocate a new road, set the name, and link to the road list */ @@ -353,7 +353,7 @@ TerrainRoadType *TerrainRoadCollection::newRoad( AsciiString name ) road->friend_setBridge( FALSE ); // set defaults from the default road - TerrainRoadType *defaultRoad = findRoad( AsciiString( "DefaultRoad" ) ); + TerrainRoadType *defaultRoad = findRoad( "DefaultRoad" ); if( defaultRoad ) { @@ -361,7 +361,7 @@ TerrainRoadType *TerrainRoadCollection::newRoad( AsciiString name ) road->friend_setRoadWidth( defaultRoad->getRoadWidth() ); road->friend_setRoadWidthInTexture( defaultRoad->getRoadWidthInTexture() ); - } // end if + } // link to list road->friend_setNext( m_roadList ); @@ -370,7 +370,7 @@ TerrainRoadType *TerrainRoadCollection::newRoad( AsciiString name ) // return the new road return road; -} // end newRoad +} //------------------------------------------------------------------------------------------------- /** Allocate a new bridge */ @@ -389,7 +389,7 @@ TerrainRoadType *TerrainRoadCollection::newBridge( AsciiString name ) bridge->friend_setBridge( TRUE ); // set defaults from the default bridge - TerrainRoadType *defaultBridge = findBridge( AsciiString( "DefaultBridge" ) ); + TerrainRoadType *defaultBridge = findBridge( "DefaultBridge" ); if( defaultBridge ) { @@ -419,11 +419,11 @@ TerrainRoadType *TerrainRoadCollection::newBridge( AsciiString name ) bridge->friend_setRepairedToOCLString( (BodyDamageType)state, i, bridge->getDamageToOCLString( (BodyDamageType)state, i ) ); bridge->friend_setRepairedToFXString( (BodyDamageType)state, i, bridge->getDamageToOCLString( (BodyDamageType)state, i ) ); - } // end for i + } - } // end for + } - } // end if + } // link to list bridge->friend_setNext( m_bridgeList ); @@ -432,7 +432,7 @@ TerrainRoadType *TerrainRoadCollection::newBridge( AsciiString name ) // return the new bridge return bridge; -} // end newBridge +} //------------------------------------------------------------------------------------------------- /** Return next road in list */ @@ -443,7 +443,7 @@ TerrainRoadType *TerrainRoadCollection::nextRoad( TerrainRoadType *road ) DEBUG_ASSERTCRASH( road->isBridge() == FALSE, ("nextRoad: road not a road") ); return road->friend_getNext(); -} // end nextRoad +} //------------------------------------------------------------------------------------------------- /** Return next bridge in list */ @@ -454,5 +454,5 @@ TerrainRoadType *TerrainRoadCollection::nextBridge( TerrainRoadType *bridge ) DEBUG_ASSERTCRASH( bridge->isBridge() == TRUE, ("nextBridge, bridge is not a bridge") ); return bridge->friend_getNext(); -} // end nextBridge +} diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp b/Core/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp similarity index 96% rename from GeneralsMD/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp rename to Core/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp index 1294a2a9c6..7b200f35d8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp +++ b/Core/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp @@ -27,7 +27,7 @@ // Author: Colin Day, April 2001 /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/Xfer.h" #include "GameClient/TerrainVisual.h" @@ -47,14 +47,14 @@ TerrainVisual *TheTerrainVisual = NULL; TerrainVisual::TerrainVisual() { -} // end TerrainVisual +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- TerrainVisual::~TerrainVisual() { -} // end ~TerrainVisual +} //------------------------------------------------------------------------------------------------- /** initialize the device independent functionality of the visual terrain */ @@ -62,7 +62,7 @@ TerrainVisual::~TerrainVisual() void TerrainVisual::init( void ) { -} // end init +} //------------------------------------------------------------------------------------------------- /** Reset */ @@ -72,7 +72,7 @@ void TerrainVisual::reset( void ) m_filenameString.clear(); -} // end reset +} //------------------------------------------------------------------------------------------------- /** Update */ @@ -80,7 +80,7 @@ void TerrainVisual::reset( void ) void TerrainVisual::update( void ) { // All the interesting stuff happens in load. jba. -} // end update +} //------------------------------------------------------------------------------------------------- /** device independent implementation for common terrain visual systems */ @@ -94,9 +94,9 @@ Bool TerrainVisual::load( AsciiString filename ) m_filenameString = filename; - return TRUE;; // success + return TRUE; // success -} // end load +} // ------------------------------------------------------------------------------------------------ /** CRC */ @@ -104,7 +104,7 @@ Bool TerrainVisual::load( AsciiString filename ) void TerrainVisual::crc( Xfer *xfer ) { -} // end CRC +} // ------------------------------------------------------------------------------------------------ /** Xfer @@ -119,7 +119,7 @@ void TerrainVisual::xfer( Xfer *xfer ) XferVersion version = currentVersion; xfer->xferVersion( &version, currentVersion ); -} // end xfer +} // ------------------------------------------------------------------------------------------------ /** Load post process */ @@ -127,12 +127,7 @@ void TerrainVisual::xfer( Xfer *xfer ) void TerrainVisual::loadPostProcess( void ) { -} // end loadPostProcess - - - - - +} SeismicSimulationFilterBase::SeismicSimStatusCode DomeStyleSeismicFilter::filterCallback( WorldHeightMapInterfaceClass *heightMap, const SeismicSimulationNode *node ) diff --git a/Core/GameEngine/Source/GameClient/VideoPlayer.cpp b/Core/GameEngine/Source/GameClient/VideoPlayer.cpp index 1045618d5b..a756d3c456 100644 --- a/Core/GameEngine/Source/GameClient/VideoPlayer.cpp +++ b/Core/GameEngine/Source/GameClient/VideoPlayer.cpp @@ -45,7 +45,7 @@ // Includes //---------------------------------------------------------------------------- -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Lib/BaseType.h" #include "GameClient/VideoPlayer.h" @@ -182,8 +182,8 @@ void VideoPlayer::init( void ) // Load this here so that WB doesn't have to link to BinkLib, costing us (potentially) // an extra license. INI ini; - ini.load( AsciiString( "Data\\INI\\Default\\Video.ini" ), INI_LOAD_OVERWRITE, NULL ); - ini.load( AsciiString( "Data\\INI\\Video.ini" ), INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Default\\Video", INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Video", INI_LOAD_OVERWRITE, NULL ); } //============================================================================ diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/View.cpp b/Core/GameEngine/Source/GameClient/View.cpp similarity index 90% rename from GeneralsMD/Code/GameEngine/Source/GameClient/View.cpp rename to Core/GameEngine/Source/GameClient/View.cpp index e9ca5dbbf6..9794560208 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/View.cpp +++ b/Core/GameEngine/Source/GameClient/View.cpp @@ -26,7 +26,7 @@ // A "view", or window, into the World // Author: Michael S. Booth, February 2001 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/GameEngine.h" #include "Common/Xfer.h" @@ -41,17 +41,14 @@ View *TheTacticalView = NULL; View::View( void ) { - //Added By Sadullah Nader - //Initialization(s) inserted + m_viewLockedUntilFrame = 0u; m_currentHeightAboveGround = 0.0f; m_defaultAngle = 0.0f; m_defaultPitchAngle = 0.0f; m_heightAboveGround = 0.0f; m_lockDist = 0.0f; m_maxHeightAboveGround = 0.0f; - m_maxZoom = 0.0f; m_minHeightAboveGround = 0.0f; - m_minZoom = 0.0f; m_next = NULL; m_okToAdjustHeight = TRUE; m_originX = 0; @@ -59,7 +56,6 @@ View::View( void ) m_snapImmediate = FALSE; m_terrainHeightUnderCamera = 0.0f; m_zoom = 0.0f; - // m_pos.x = 0; m_pos.y = 0; m_width = 0; @@ -99,9 +95,7 @@ void View::init( void ) m_cameraLockDrawable = NULL; m_zoomLimited = TRUE; - m_maxZoom = 1.3f; - m_minZoom = 0.2f; - m_zoom = m_maxZoom; + m_zoom = 1.0f; m_maxHeightAboveGround = TheGlobalData->m_maxCameraHeight; m_minHeightAboveGround = TheGlobalData->m_minCameraHeight; m_okToAdjustHeight = FALSE; @@ -114,6 +108,8 @@ void View::reset( void ) { // Only fixing the reported bug. Who knows what side effects resetting the rest could have. m_zoomLimited = TRUE; + + m_viewLockedUntilFrame = 0u; } /** @@ -125,14 +121,14 @@ View *View::prependViewToList( View *list ) return this; } -void View::zoomIn( void ) +void View::zoom( Real height ) { - setHeightAboveGround(getHeightAboveGround() - 10.0f); + setHeightAboveGround(getHeightAboveGround() + height); } -void View::zoomOut( void ) +void View::lockViewUntilFrame(UnsignedInt frame) { - setHeightAboveGround(getHeightAboveGround() + 10.0f); + m_viewLockedUntilFrame = frame; } /** @@ -171,14 +167,8 @@ void View::setAngle( Real angle ) */ void View::setPitch( Real angle ) { - m_pitchAngle = angle; - - Real limit = PI/5.0f; - - if (m_pitchAngle < -limit) - m_pitchAngle = -limit; - else if (m_pitchAngle > limit) - m_pitchAngle = limit; + constexpr Real limit = PI/5.0f; + m_pitchAngle = clamp(-limit, angle, limit); } /** @@ -190,6 +180,19 @@ void View::setAngleAndPitchToDefault( void ) m_pitchAngle = m_defaultPitchAngle; } +void View::setHeightAboveGround(Real z) +{ + // if our zoom is limited, we will stay within a predefined distance from the terrain + if( m_zoomLimited ) + { + m_heightAboveGround = clamp(m_minHeightAboveGround, z, m_maxHeightAboveGround); + } + else + { + m_heightAboveGround = z; + } +} + /** * write the view's current location in to the view location object */ @@ -252,7 +255,7 @@ void View::getScreenCornerWorldPointsAtZ( Coord3D *topLeft, Coord3D *topRight, screenToWorldAtZ( &screenBottomLeft, bottomLeft, z ); screenToWorldAtZ( &screenBottomRight, bottomRight, z ); -} // end getScreenCornerWorldPointsAtZ +} // ------------------------------------------------------------------------------------------------ /** Xfer method for a view */ @@ -278,4 +281,4 @@ void View::xfer( Xfer *xfer ) xfer->xferReal( &viewPos.z ); lookAt( &viewPos ); -} // end xfer +} diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/Water.cpp b/Core/GameEngine/Source/GameClient/Water.cpp similarity index 97% rename from GeneralsMD/Code/GameEngine/Source/GameClient/Water.cpp rename to Core/GameEngine/Source/GameClient/Water.cpp index 9f17472f4b..ce17606d22 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/Water.cpp +++ b/Core/GameEngine/Source/GameClient/Water.cpp @@ -28,7 +28,7 @@ /////////////////////////////////////////////////////////////////////////////////////////////////// // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameClient/Water.h" #include "Common/INI.h" @@ -122,13 +122,13 @@ WaterSetting::WaterSetting( void ) m_uScrollPerMs = 0.0f; m_vScrollPerMs = 0.0f; -} // end WaterSetting +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- WaterSetting::~WaterSetting( void ) { -} // end WaterSetting +} diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cpp b/Core/GameEngine/Source/GameNetwork/Connection.cpp similarity index 94% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cpp rename to Core/GameEngine/Source/GameNetwork/Connection.cpp index ebeaef79fa..fe804e5ae8 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Connection.cpp +++ b/Core/GameEngine/Source/GameNetwork/Connection.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/Connection.h" #include "GameNetwork/networkutil.h" @@ -43,30 +43,23 @@ Connection::Connection() { m_frameGrouping = 1; m_isQuitting = false; m_quitTime = 0; - // Added By Sadullah Nader - // clearing out the latency tracker m_averageLatency = 0.0f; Int i; for(i = 0; i < CONNECTION_LATENCY_HISTORY_LENGTH; i++) { m_latencies[i] = 0.0f; } - // End Add } /** * The destructor. */ Connection::~Connection() { - if (m_user != NULL) { - deleteInstance(m_user); - m_user = NULL; - } + deleteInstance(m_user); + m_user = NULL; - if (m_netCommandList != NULL) { - deleteInstance(m_netCommandList); - m_netCommandList = NULL; - } + deleteInstance(m_netCommandList); + m_netCommandList = NULL; } /** @@ -75,10 +68,8 @@ Connection::~Connection() { void Connection::init() { m_transport = NULL; - if (m_user != NULL) { - deleteInstance(m_user); - m_user = NULL; - } + deleteInstance(m_user); + m_user = NULL; if (m_netCommandList == NULL) { m_netCommandList = newInstance(NetCommandList); @@ -123,10 +114,7 @@ void Connection::attachTransport(Transport *transport) { * Assign this connection a user. This is the user to whome we send all our packetized goodies. */ void Connection::setUser(User *user) { - if (m_user != NULL) { - deleteInstance(m_user); - } - + deleteInstance(m_user); m_user = user; } @@ -226,18 +214,19 @@ void Connection::clearCommandsExceptFrom( Int playerIndex ) NetCommandRef *tmp = m_netCommandList->getFirstMessage(); while (tmp) { + NetCommandRef *next = tmp->getNext(); NetCommandMsg *msg = tmp->getCommand(); + if (msg->getPlayerID() != playerIndex) { - DEBUG_LOG(("Connection::clearCommandsExceptFrom(%d) - clearing a command from %d for frame %d", + DEBUG_LOG(("Connection::clearCommandsExceptFrom(%d) - clearing a command from player %d for frame %d", playerIndex, tmp->getCommand()->getPlayerID(), tmp->getCommand()->getExecutionFrame())); + m_netCommandList->removeMessage(tmp); - NetCommandRef *toDelete = tmp; - tmp = tmp->getNext(); - deleteInstance(toDelete); - } else { - tmp = tmp->getNext(); + deleteInstance(tmp); } + + tmp = next; } } @@ -325,9 +314,8 @@ UnsignedInt Connection::doSend() { couldQueue = m_transport->queueSend(packet->getAddr(), packet->getPort(), packet->getData(), packet->getLength()); m_lastTimeSent = curtime; } - if (packet != NULL) { - deleteInstance(packet); // delete the packet now that we're done with it. - } + + deleteInstance(packet); // delete the packet now that we're done with it. } return numpackets; diff --git a/Generals/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp b/Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp similarity index 93% rename from Generals/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp rename to Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp index b78a6f1dfa..7b3450a960 100644 --- a/Generals/Code/GameEngine/Source/GameNetwork/ConnectionManager.cpp +++ b/Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp @@ -1,5 +1,5 @@ /* -** Command & Conquer Generals(tm) +** Command & Conquer Generals Zero Hour(tm) ** Copyright 2025 Electronic Arts Inc. ** ** This program is free software: you can redistribute it and/or modify @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Compression.h" #include "strtok_r.h" @@ -53,63 +53,75 @@ #include "GameClient/DisconnectMenu.h" #include "GameClient/InGameUI.h" +static Bool hasValidTransferFileExtension(const AsciiString& filePath) +{ + static const char* const validExtensions[] = { + "map", + "ini", + "str", + "wak", + "tga", + "txt" + }; + + const char* fileExt = strrchr(filePath.str(), '.'); + + if (fileExt == NULL || fileExt[1] == '\0') + { + return false; + } + + fileExt++; + + for (Int i = 0; i < ARRAY_SIZE(validExtensions); ++i) + { + if (stricmp(fileExt, validExtensions[i]) == 0) + { + return true; + } + } + + return false; +} /** * Le destructor. */ ConnectionManager::~ConnectionManager(void) { - if (m_localUser != NULL) { - deleteInstance(m_localUser); - m_localUser = NULL; - } + deleteInstance(m_localUser); + m_localUser = NULL; -// m_transport = NULL; // Network will delete transports; we just forget them - if (m_transport != NULL) { - delete m_transport; - m_transport = NULL; - } + // Network will delete transports; we just forget them + delete m_transport; + m_transport = NULL; Int i = 0; for (; i < MAX_SLOTS; ++i) { - if (m_frameData[i] != NULL) { - deleteInstance(m_frameData[i]); - m_frameData[i] = NULL; - } + deleteInstance(m_frameData[i]); + m_frameData[i] = NULL; } for (i = 0; i < NUM_CONNECTIONS; ++i) { - if (m_connections[i] != NULL) { - deleteInstance(m_connections[i]); - m_connections[i] = NULL; - } + deleteInstance(m_connections[i]); + m_connections[i] = NULL; } - if (TheDisconnectMenu != NULL) { - // This is done here since TheDisconnectMenu should only be there if we are in a network game. - delete TheDisconnectMenu; - TheDisconnectMenu = NULL; - } + // This is done here since TheDisconnectMenu should only be there if we are in a network game. + delete TheDisconnectMenu; + TheDisconnectMenu = NULL; - if (m_disconnectManager != NULL) { - delete m_disconnectManager; - m_disconnectManager = NULL; - } + delete m_disconnectManager; + m_disconnectManager = NULL; - if (m_pendingCommands != NULL) { - deleteInstance(m_pendingCommands); - m_pendingCommands = NULL; - } + deleteInstance(m_pendingCommands); + m_pendingCommands = NULL; - if (m_relayedCommands != NULL) { - deleteInstance(m_relayedCommands); - m_relayedCommands = NULL; - } + deleteInstance(m_relayedCommands); + m_relayedCommands = NULL; - if (m_netCommandWrapperList != NULL) { - deleteInstance(m_netCommandWrapperList); - m_netCommandWrapperList = NULL; - } + deleteInstance(m_netCommandWrapperList); + m_netCommandWrapperList = NULL; s_fileCommandMap.clear(); s_fileRecipientMaskMap.clear(); @@ -174,10 +186,8 @@ void ConnectionManager::init() } for (i = 0; i < MAX_SLOTS; ++i) { - if (m_frameData[i] != NULL) { - deleteInstance(m_frameData[i]); - m_frameData[i] = NULL; - } + deleteInstance(m_frameData[i]); + m_frameData[i] = NULL; } // m_averageFps = 30; // since 30 fps is the desired rate, we'll start off at that. @@ -221,25 +231,20 @@ void ConnectionManager::reset() // m_transport = new Transport; // } // m_transport->reset(); - if (m_transport != NULL) { - delete m_transport; - m_transport = NULL; - } + + delete m_transport; + m_transport = NULL; UnsignedInt i = 0; for (; i < (UnsignedInt)NUM_CONNECTIONS; ++i) { - if (m_connections[i] != NULL) { - deleteInstance(m_connections[i]); - m_connections[i] = NULL; - } + deleteInstance(m_connections[i]); + m_connections[i] = NULL; } for (i=0; i<(UnsignedInt)MAX_SLOTS; ++i) { - if (m_frameData[i] != NULL) { - deleteInstance(m_frameData[i]); - m_frameData[i] = NULL; - } + deleteInstance(m_frameData[i]); + m_frameData[i] = NULL; } if (m_pendingCommands == NULL) { @@ -301,10 +306,7 @@ Bool ConnectionManager::isPlayerConnected( Int playerID ) } void ConnectionManager::attachTransport(Transport *transport) { - if (m_transport != NULL) { - delete m_transport; - m_transport = NULL; - } + delete m_transport; m_transport = transport; } @@ -418,21 +420,24 @@ void ConnectionManager::doRelay() { */ Bool ConnectionManager::processNetCommand(NetCommandRef *ref) { NetCommandMsg *msg = ref->getCommand(); + NetCommandType cmdType = msg->getNetCommandType(); - if ((msg->getNetCommandType() == NETCOMMANDTYPE_ACKSTAGE1) || - (msg->getNetCommandType() == NETCOMMANDTYPE_ACKSTAGE2) || - (msg->getNetCommandType() == NETCOMMANDTYPE_ACKBOTH)) { - + // Handle ACK commands first (before connection validation) + if ((cmdType == NETCOMMANDTYPE_ACKSTAGE1) || + (cmdType == NETCOMMANDTYPE_ACKSTAGE2) || + (cmdType == NETCOMMANDTYPE_ACKBOTH)) { processAck(msg); return FALSE; } + // Early validation checks if ((m_connections[msg->getPlayerID()] == NULL) && (msg->getPlayerID() != m_localSlot)) { // if this is from a player that is no longer in the game, then ignore them. return TRUE; } - if (msg->getNetCommandType() == NETCOMMANDTYPE_WRAPPER) { + // Handle WRAPPER commands (before second connection validation) + if (cmdType == NETCOMMANDTYPE_WRAPPER) { processWrapper(ref); // need to send the NetCommandRef since we have to construct the relay for the wrapped command. return FALSE; } @@ -449,93 +454,84 @@ Bool ConnectionManager::processNetCommand(NetCommandRef *ref) { // This was a fix for a command count bug where a command would be // executed, then a command for that old frame would be added to the // FrameData for that frame + 256, and would screw up the command count. - - if (IsCommandSynchronized(msg->getNetCommandType())) { + if (IsCommandSynchronized(cmdType)) { if (ref->getCommand()->getExecutionFrame() < TheGameLogic->getFrame()) { return TRUE; } } - if (msg->getNetCommandType() == NETCOMMANDTYPE_FRAMEINFO) { - processFrameInfo((NetFrameCommandMsg *)msg); - - // need to set the relay so we don't send it to ourselves. - UnsignedByte relay = ref->getRelay(); - relay = relay & (0xff ^ (1 << m_localSlot)); - ref->setRelay(relay); - return FALSE; + // Handle disconnect commands as a range + if ((cmdType > NETCOMMANDTYPE_DISCONNECTSTART) && (cmdType < NETCOMMANDTYPE_DISCONNECTEND)) { + m_disconnectManager->processDisconnectCommand(ref, this); + return TRUE; } - if (msg->getNetCommandType() == NETCOMMANDTYPE_PROGRESS) - { - //DEBUG_LOG(("ConnectionManager::processNetCommand - got a progress net command from player %d", msg->getPlayerID())); - processProgress((NetProgressCommandMsg *) msg); + // Process command by type + switch (cmdType) { - // need to set the relay so we don't send it to ourselves. - UnsignedByte relay = ref->getRelay(); - relay = relay & (0xff ^ (1 << m_localSlot)); - ref->setRelay(relay); - return FALSE; - } + case NETCOMMANDTYPE_FRAMEINFO: { + processFrameInfo((NetFrameCommandMsg *)msg); + // need to set the relay so we don't send it to ourselves. + UnsignedByte relay = ref->getRelay(); + relay = relay & (0xff ^ (1 << m_localSlot)); + ref->setRelay(relay); + return FALSE; + } - if (msg->getNetCommandType() == NETCOMMANDTYPE_TIMEOUTSTART) - { - DEBUG_LOG(("ConnectionManager::processNetCommand - got a TimeOut GameStart net command from player %d", msg->getPlayerID())); - processTimeOutGameStart(msg); - return FALSE; - } + case NETCOMMANDTYPE_PROGRESS: { + //DEBUG_LOG(("ConnectionManager::processNetCommand - got a progress net command from player %d", msg->getPlayerID())); + processProgress((NetProgressCommandMsg *) msg); + // need to set the relay so we don't send it to ourselves. + UnsignedByte relay = ref->getRelay(); + relay = relay & (0xff ^ (1 << m_localSlot)); + ref->setRelay(relay); + return FALSE; + } - if (msg->getNetCommandType() == NETCOMMANDTYPE_RUNAHEADMETRICS) { - processRunAheadMetrics((NetRunAheadMetricsCommandMsg *)msg); - return TRUE; - } + case NETCOMMANDTYPE_TIMEOUTSTART: + DEBUG_LOG(("ConnectionManager::processNetCommand - got a TimeOut GameStart net command from player %d", msg->getPlayerID())); + processTimeOutGameStart(msg); + return FALSE; - if (msg->getNetCommandType() == NETCOMMANDTYPE_KEEPALIVE) { - return TRUE; - } + case NETCOMMANDTYPE_RUNAHEADMETRICS: + processRunAheadMetrics((NetRunAheadMetricsCommandMsg *)msg); + return TRUE; - if ((msg->getNetCommandType() > NETCOMMANDTYPE_DISCONNECTSTART) && (msg->getNetCommandType() < NETCOMMANDTYPE_DISCONNECTEND)) { - m_disconnectManager->processDisconnectCommand(ref, this); - return TRUE; - } + case NETCOMMANDTYPE_KEEPALIVE: + return TRUE; - if (msg->getNetCommandType() == NETCOMMANDTYPE_DISCONNECTCHAT) { - processDisconnectChat((NetDisconnectChatCommandMsg *)msg); - } + case NETCOMMANDTYPE_DISCONNECTCHAT: + processDisconnectChat((NetDisconnectChatCommandMsg *)msg); + return FALSE; - if (msg->getNetCommandType() == NETCOMMANDTYPE_LOADCOMPLETE) - { - DEBUG_LOG(("ConnectionManager::processNetCommand - got a Load Complete net command from player %d", msg->getPlayerID())); - processLoadComplete(msg); - return FALSE; - } + case NETCOMMANDTYPE_LOADCOMPLETE: + DEBUG_LOG(("ConnectionManager::processNetCommand - got a Load Complete net command from player %d", msg->getPlayerID())); + processLoadComplete(msg); + return FALSE; - if (msg->getNetCommandType() == NETCOMMANDTYPE_CHAT) { - processChat((NetChatCommandMsg *)msg); - return FALSE; - } + case NETCOMMANDTYPE_CHAT: + processChat((NetChatCommandMsg *)msg); + return FALSE; - if (msg->getNetCommandType() == NETCOMMANDTYPE_FILE) { - processFile((NetFileCommandMsg *)msg); - return FALSE; - } + case NETCOMMANDTYPE_FILE: + processFile((NetFileCommandMsg *)msg); + return FALSE; - if (msg->getNetCommandType() == NETCOMMANDTYPE_FILEANNOUNCE) { - processFileAnnounce((NetFileAnnounceCommandMsg *)msg); - return FALSE; - } + case NETCOMMANDTYPE_FILEANNOUNCE: + processFileAnnounce((NetFileAnnounceCommandMsg *)msg); + return FALSE; - if (msg->getNetCommandType() == NETCOMMANDTYPE_FILEPROGRESS) { - processFileProgress((NetFileProgressCommandMsg *)msg); - return FALSE; - } + case NETCOMMANDTYPE_FILEPROGRESS: + processFileProgress((NetFileProgressCommandMsg *)msg); + return FALSE; - if (msg->getNetCommandType() == NETCOMMANDTYPE_FRAMERESENDREQUEST) { - processFrameResendRequest((NetFrameResendRequestCommandMsg *)msg); - return TRUE; - } + case NETCOMMANDTYPE_FRAMERESENDREQUEST: + processFrameResendRequest((NetFrameResendRequestCommandMsg *)msg); + return TRUE; - return FALSE; + default: + return FALSE; + } } void ConnectionManager::processFrameResendRequest(NetFrameResendRequestCommandMsg *msg) { @@ -655,7 +651,7 @@ void ConnectionManager::processChat(NetChatCommandMsg *msg) const Player *player = ThePlayerList->findPlayerWithNameKey( TheNameKeyGenerator->nameToKey( playerName ) ); if (!player) { - TheInGameUI->message(UnicodeString(L"%ls"), unitext.str()); + TheInGameUI->message(L"%ls", unitext.str()); return; } @@ -667,7 +663,7 @@ void ConnectionManager::processChat(NetChatCommandMsg *msg) { RGBColor rgb; rgb.setFromInt(player->getPlayerColor()); - TheInGameUI->messageColor(&rgb, UnicodeString(L"%ls"), unitext.str()); + TheInGameUI->messageColor(&rgb, L"%ls", unitext.str()); // feedback for received chat messages in-game AudioEventRTS audioEvent("GUICommunicatorIncoming"); @@ -693,6 +689,13 @@ void ConnectionManager::processFile(NetFileCommandMsg *msg) return; } + // TheSuperHackers @security bobtista 06/11/2025 Validate file extension to prevent arbitrary file types + if (!hasValidTransferFileExtension(realFileName)) + { + DEBUG_LOG(("File '%s' has invalid extension for transfer operations.", realFileName.str())); + return; + } + if (TheFileSystem->doesFileExist(realFileName.str())) { DEBUG_LOG(("File exists already!")); @@ -1246,22 +1249,20 @@ void ConnectionManager::updateRunAhead(Int oldRunAhead, Int frameRate, Bool didS // if the minimum fps is within 10% of the desired framerate, then keep the current minimum fps. minFps = frameRate; } - if (minFps < 5) { - minFps = 5; // Absolutely do not run below 5 fps. - } - if (minFps > TheGlobalData->m_framesPerSecondLimit) { - minFps = TheGlobalData->m_framesPerSecondLimit; // Cap to 30 FPS. - } + + // TheSuperHackers @info this clamps the logic time scale fps in network games + minFps = clamp(MIN_LOGIC_FRAMES, minFps, TheGlobalData->m_framesPerSecondLimit); DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("ConnectionManager::updateRunAhead - minFps after adjustment is %d", minFps)); - Int newRunAhead = (Int)((getMaximumLatency() / 2.0) * (Real)minFps); - newRunAhead += (newRunAhead * TheGlobalData->m_networkRunAheadSlack) / 100; // Add in 10% of slack to the run ahead in case of network hiccups. - if (newRunAhead < MIN_RUNAHEAD) { - newRunAhead = MIN_RUNAHEAD; // make sure its at least MIN_RUNAHEAD. - } - if (newRunAhead > (MAX_FRAMES_AHEAD / 2)) { - newRunAhead = MAX_FRAMES_AHEAD / 2; // dont let run ahead get out of hand. - } + // TheSuperHackers @bugfix Mauller 21/08/2025 calculate the runahead so it always follows the latency + // The runahead should always be rounded up to the next integer value to prevent variations in latency from causing stutter + // The network slack pushes the runahead up to the next value when the latency is within the slack percentage of the current runahead + const Real runAheadSlackScale = 1.0f + ( (Real)TheGlobalData->m_networkRunAheadSlack / 100.0f ); + Int newRunAhead = ceilf( getMaximumLatency() * runAheadSlackScale * (Real)minFps ); + + // TheSuperHackers @info if the runahead goes below 3 logic frames it can start to introduce stutter + // We also limit the upper range of the runahead to prevent it getting out of hand + newRunAhead = clamp(MIN_RUNAHEAD, newRunAhead, MAX_FRAMES_AHEAD / 2); NetRunAheadCommandMsg *msg = newInstance(NetRunAheadCommandMsg); msg->setPlayerID(m_localSlot); @@ -1361,24 +1362,15 @@ void ConnectionManager::updateRunAhead(Int oldRunAhead, Int frameRate, Bool didS } Real ConnectionManager::getMaximumLatency() { - // This works for 2 player games because the latency for the packet router is always 0. - Real lat1 = 0.0; - Real lat2 = 0.0; + Real maxLatency = 0.0f; for (Int i = 0; i < MAX_SLOTS; ++i) { - if (isPlayerConnected(i)) { - if (m_latencyAverages[i] != 0.0) { - if (m_latencyAverages[i] > lat1) { - lat2 = lat1; - lat1 = m_latencyAverages[i]; - } else if (m_latencyAverages[i] > lat2) { - lat2 = m_latencyAverages[i]; - } - } + if (isPlayerConnected(i) && m_latencyAverages[i] > maxLatency) { + maxLatency = m_latencyAverages[i]; } } - return (lat1 + lat2); + return maxLatency; } void ConnectionManager::getMinimumFps(Int &minFps, Int &minFpsPlayer) { @@ -1444,10 +1436,8 @@ void ConnectionManager::setLocalAddress(UnsignedInt ip, UnsignedInt port) { void ConnectionManager::initTransport() { DEBUG_ASSERTCRASH((m_transport == NULL), ("m_transport already exists when trying to init it.")); DEBUG_LOG(("ConnectionManager::initTransport - Initializing Transport")); - if (m_transport != NULL) { - delete m_transport; - m_transport = NULL; - } + + delete m_transport; m_transport = new Transport; m_transport->reset(); m_transport->init(m_localAddr, m_localPort); @@ -1794,6 +1784,7 @@ void ConnectionManager::quitGame() { disconnectMsg->detach(); +#if RTS_GENERALS // if we get here, we hit Quit on the disconnect screen. Mark everyone as having disconnected from us // so the online stats can give us appropriate feedback. if (TheGameInfo) @@ -1807,6 +1798,7 @@ void ConnectionManager::quitGame() { } } } +#endif disconnectLocalPlayer(); } @@ -2006,10 +1998,8 @@ void ConnectionManager::parseUserList(const GameInfo *game) return; } - if (list != NULL) { - free(list); // from the strdup above. - list = NULL; - } + free(list); // from the strdup above. + list = NULL; */ } @@ -2130,7 +2120,7 @@ UnsignedShort ConnectionManager::sendFileAnnounce(AsciiString path, UnsignedByte log.format(L"Not sending file '%hs' to %X", path.str(), playerMask); DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("%ls", log.str())); if (TheLAN) - TheLAN->OnChat(UnicodeString(L"sendFile"), 0, log, LANAPI::LANCHAT_SYSTEM); + TheLAN->OnChat(L"sendFile", 0, log, LANAPI::LANCHAT_SYSTEM); return 0; } @@ -2168,7 +2158,7 @@ void ConnectionManager::sendFile(AsciiString path, UnsignedByte playerMask, Unsi log.format(L"Not sending file '%hs' to %X", path.str(), playerMask); DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("%ls", log.str())); if (TheLAN) - TheLAN->OnChat(UnicodeString(L"sendFile"), 0, log, LANAPI::LANCHAT_SYSTEM); + TheLAN->OnChat(L"sendFile", 0, log, LANAPI::LANCHAT_SYSTEM); return; } @@ -2184,7 +2174,7 @@ void ConnectionManager::sendFile(AsciiString path, UnsignedByte playerMask, Unsi compressedSize = CompressionManager::compressData(CompressionManager::getPreferredCompression(), buf, len, compressedBuf, compressedLen); - if (compressedBuf && !compressedSize) + if (!compressedSize) { delete[] compressedBuf; compressedBuf = NULL; @@ -2214,11 +2204,8 @@ void ConnectionManager::sendFile(AsciiString path, UnsignedByte playerMask, Unsi delete[] buf; buf = NULL; #ifdef COMPRESS_TARGAS - if (compressedBuf) - { - delete[] compressedBuf; - compressedBuf = NULL; - } + delete[] compressedBuf; + compressedBuf = NULL; #endif // COMPRESS_TARGAS DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("Sending file: '%s', len %d, to %X", path.str(), len, playerMask)); diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cpp b/Core/GameEngine/Source/GameNetwork/DisconnectManager.cpp similarity index 96% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cpp rename to Core/GameEngine/Source/GameNetwork/DisconnectManager.cpp index 69f630702e..94beda05da 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/DisconnectManager.cpp +++ b/Core/GameEngine/Source/GameNetwork/DisconnectManager.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/Recorder.h" #include "GameClient/DisconnectMenu.h" @@ -38,8 +38,6 @@ DisconnectManager::DisconnectManager() { - // Added By Sadullah Nader - // Initializations missing and needed Int i; m_currentPacketRouterIndex = 0; m_lastFrame = 0; @@ -268,20 +266,38 @@ void DisconnectManager::updateWaitForPacketRouter(ConnectionManager *conMgr) { void DisconnectManager::processDisconnectCommand(NetCommandRef *ref, ConnectionManager *conMgr) { NetCommandMsg *msg = ref->getCommand(); - if (msg->getNetCommandType() == NETCOMMANDTYPE_DISCONNECTKEEPALIVE) { - processDisconnectKeepAlive(msg, conMgr); - } else if (msg->getNetCommandType() == NETCOMMANDTYPE_DISCONNECTPLAYER) { - processDisconnectPlayer(msg, conMgr); - } else if (msg->getNetCommandType() == NETCOMMANDTYPE_PACKETROUTERQUERY) { - processPacketRouterQuery(msg, conMgr); - } else if (msg->getNetCommandType() == NETCOMMANDTYPE_PACKETROUTERACK) { - processPacketRouterAck(msg, conMgr); - } else if (msg->getNetCommandType() == NETCOMMANDTYPE_DISCONNECTVOTE) { - processDisconnectVote(msg, conMgr); - } else if (msg->getNetCommandType() == NETCOMMANDTYPE_DISCONNECTFRAME) { - processDisconnectFrame(msg, conMgr); - } else if (msg->getNetCommandType() == NETCOMMANDTYPE_DISCONNECTSCREENOFF) { - processDisconnectScreenOff(msg, conMgr); + + switch (msg->getNetCommandType()) { + case NETCOMMANDTYPE_DISCONNECTKEEPALIVE: + processDisconnectKeepAlive(msg, conMgr); + break; + + case NETCOMMANDTYPE_DISCONNECTPLAYER: + processDisconnectPlayer(msg, conMgr); + break; + + case NETCOMMANDTYPE_PACKETROUTERQUERY: + processPacketRouterQuery(msg, conMgr); + break; + + case NETCOMMANDTYPE_PACKETROUTERACK: + processPacketRouterAck(msg, conMgr); + break; + + case NETCOMMANDTYPE_DISCONNECTVOTE: + processDisconnectVote(msg, conMgr); + break; + + case NETCOMMANDTYPE_DISCONNECTFRAME: + processDisconnectFrame(msg, conMgr); + break; + + case NETCOMMANDTYPE_DISCONNECTSCREENOFF: + processDisconnectScreenOff(msg, conMgr); + break; + + default: + break; } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/DownloadManager.cpp b/Core/GameEngine/Source/GameNetwork/DownloadManager.cpp similarity index 97% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/DownloadManager.cpp rename to Core/GameEngine/Source/GameNetwork/DownloadManager.cpp index d3cbb7b689..b84abac918 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/DownloadManager.cpp +++ b/Core/GameEngine/Source/GameNetwork/DownloadManager.cpp @@ -26,7 +26,7 @@ // Generals download manager code // Author: Matthew D. Campbell, July 2002 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameClient/GameText.h" #include "GameNetwork/DownloadManager.h" @@ -37,14 +37,7 @@ DownloadManager::DownloadManager() { m_download = NEW CDownload(this); m_wasError = m_sawEnd = false; - - //Added By Sadullah Nader - //Initializations missing and needed - m_queuedDownloads.clear(); - - // - m_statusString = TheGameText->fetch("FTP:StatusIdle"); // ----- Initialize Winsock ----- diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FileTransfer.cpp b/Core/GameEngine/Source/GameNetwork/FileTransfer.cpp similarity index 98% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/FileTransfer.cpp rename to Core/GameEngine/Source/GameNetwork/FileTransfer.cpp index c9bd3f22cd..c64f3118ad 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FileTransfer.cpp +++ b/Core/GameEngine/Source/GameNetwork/FileTransfer.cpp @@ -28,7 +28,7 @@ // Description: File Transfer wrapper using TheNetwork /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameClient/LoadScreen.h" #include "GameClient/Shell.h" diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FirewallHelper.cpp b/Core/GameEngine/Source/GameNetwork/FirewallHelper.cpp similarity index 97% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/FirewallHelper.cpp rename to Core/GameEngine/Source/GameNetwork/FirewallHelper.cpp index 0d864d5722..320b672ee9 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FirewallHelper.cpp +++ b/Core/GameEngine/Source/GameNetwork/FirewallHelper.cpp @@ -29,7 +29,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /RedAlert2/NAT.CPP $* + * $Archive:: /RedAlert2/NAT.cpp $* * * * $Author:: Steve_t $* * * @@ -46,7 +46,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/crc.h" #include "Common/UserPreferences.h" @@ -83,16 +83,12 @@ FirewallHelperClass * createFirewallHelper() FirewallHelperClass::FirewallHelperClass(void) { - //Added Sadullah Nader - //Initializations missing and needed m_currentTry = 0; m_numManglers = 0; m_numResponses = 0; m_packetID = 0; m_timeoutLength = 0; m_timeoutStart = 0; - // - m_behavior = FIREWALL_TYPE_UNKNOWN; m_lastBehavior = FIREWALL_TYPE_UNKNOWN; m_sourcePortAllocationDelta = 0; @@ -204,47 +200,40 @@ Bool FirewallHelperClass::detectFirewall(void) Bool FirewallHelperClass::behaviorDetectionUpdate() { - if (m_currentState == DETECTIONSTATE_IDLE) { - return FALSE; - } - - if (m_currentState == DETECTIONSTATE_DONE) { - return TRUE; - } - - if (m_currentState == DETECTIONSTATE_BEGIN) { - return detectionBeginUpdate(); - } - - if (m_currentState == DETECTIONSTATE_TEST1) { - return detectionTest1Update(); - } - - if (m_currentState == DETECTIONSTATE_TEST2) { - return detectionTest2Update(); - } - - if (m_currentState == DETECTIONSTATE_TEST3) { - return detectionTest3Update(); - } - - if (m_currentState == DETECTIONSTATE_TEST3_WAITFORRESPONSES) { - return detectionTest3WaitForResponsesUpdate(); - } - - if (m_currentState == DETECTIONSTATE_TEST4_1) { - return detectionTest4Stage1Update(); - } - - if (m_currentState == DETECTIONSTATE_TEST4_2) { - return detectionTest4Stage2Update(); - } - - if (m_currentState == DETECTIONSTATE_TEST5) { - return detectionTest5Update(); + switch (m_currentState) { + case DETECTIONSTATE_IDLE: + return FALSE; + + case DETECTIONSTATE_DONE: + return TRUE; + + case DETECTIONSTATE_BEGIN: + return detectionBeginUpdate(); + + case DETECTIONSTATE_TEST1: + return detectionTest1Update(); + + case DETECTIONSTATE_TEST2: + return detectionTest2Update(); + + case DETECTIONSTATE_TEST3: + return detectionTest3Update(); + + case DETECTIONSTATE_TEST3_WAITFORRESPONSES: + return detectionTest3WaitForResponsesUpdate(); + + case DETECTIONSTATE_TEST4_1: + return detectionTest4Stage1Update(); + + case DETECTIONSTATE_TEST4_2: + return detectionTest4Stage2Update(); + + case DETECTIONSTATE_TEST5: + return detectionTest5Update(); + + default: + return TRUE; } - - return TRUE; } /*********************************************************************************************** @@ -548,7 +537,7 @@ void FirewallHelperClass::flagNeedToRefresh(Bool flag) { OptionPreferences pref; - (pref)["FirewallNeedToRefresh"] = flag ? AsciiString("TRUE") : AsciiString("FALSE"); + (pref)["FirewallNeedToRefresh"] = flag ? "TRUE" : "FALSE"; pref.write(); } @@ -679,9 +668,7 @@ Bool FirewallHelperClass::detectionBeginUpdate() { /* ** Do the lookup. */ - char temp_name[256]; - strcpy(temp_name, mangler_name_ptr); - struct hostent *host_info = gethostbyname(temp_name); + struct hostent *host_info = gethostbyname(mangler_name_ptr); if (!host_info) { DEBUG_LOG(("gethostbyname failed! Error code %d", WSAGetLastError())); @@ -1556,10 +1543,8 @@ Bool FirewallHelperClass::openSpareSocket(UnsignedShort port) { void FirewallHelperClass::closeSpareSocket(UnsignedShort port) { for (Int i = 0; i < MAX_SPARE_SOCKETS; ++i) { if (m_spareSockets[i].port == port) { - if (m_spareSockets[i].udp != NULL) { - delete m_spareSockets[i].udp; - m_spareSockets[i].udp = NULL; - } + delete m_spareSockets[i].udp; + m_spareSockets[i].udp = NULL; m_spareSockets[i].port = 0; break; } @@ -1571,12 +1556,8 @@ void FirewallHelperClass::closeSpareSocket(UnsignedShort port) { */ void FirewallHelperClass::closeAllSpareSockets() { for (Int i = 0; i < MAX_SPARE_SOCKETS; ++i) { - if (m_spareSockets[i].port != 0) { - m_spareSockets[i].port = 0; - } - if (m_spareSockets[i].udp != NULL) { - delete (m_spareSockets[i].udp); - m_spareSockets[i].udp = NULL; - } + delete (m_spareSockets[i].udp); + m_spareSockets[i].udp = NULL; + m_spareSockets[i].port = 0; } } diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameData.cpp b/Core/GameEngine/Source/GameNetwork/FrameData.cpp similarity index 95% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameData.cpp rename to Core/GameEngine/Source/GameNetwork/FrameData.cpp index c03ea05e7e..da5fef6e76 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameData.cpp +++ b/Core/GameEngine/Source/GameNetwork/FrameData.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/FrameData.h" #include "GameNetwork/networkutil.h" @@ -37,11 +37,8 @@ FrameData::FrameData() m_commandList = NULL; m_commandCount = 0; m_frameCommandCount = -1; - //Added By Sadullah Nader - //Initializations missing and needed m_lastFailedCC = 0; m_lastFailedFrameCC = 0; - // } /** @@ -49,10 +46,8 @@ FrameData::FrameData() */ FrameData::~FrameData() { - if (m_commandList != NULL) { - deleteInstance(m_commandList); - m_commandList = NULL; - } + deleteInstance(m_commandList); + m_commandList = NULL; } /** diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameDataManager.cpp b/Core/GameEngine/Source/GameNetwork/FrameDataManager.cpp similarity index 97% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameDataManager.cpp rename to Core/GameEngine/Source/GameNetwork/FrameDataManager.cpp index e37ad0eeef..0bc84f74be 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameDataManager.cpp +++ b/Core/GameEngine/Source/GameNetwork/FrameDataManager.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/FrameDataManager.h" #include "GameNetwork/networkutil.h" @@ -47,12 +47,8 @@ FrameDataManager::~FrameDataManager() { for (Int i = 0; i < FRAME_DATA_LENGTH; ++i) { m_frameData[i].reset(); } - - if (m_frameData) - { - delete[] m_frameData; - m_frameData = NULL; - } + delete[] m_frameData; + m_frameData = NULL; } /** diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameMetrics.cpp b/Core/GameEngine/Source/GameNetwork/FrameMetrics.cpp similarity index 91% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameMetrics.cpp rename to Core/GameEngine/Source/GameNetwork/FrameMetrics.cpp index 26f3888250..a9a9aca66e 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/FrameMetrics.cpp +++ b/Core/GameEngine/Source/GameNetwork/FrameMetrics.cpp @@ -24,7 +24,7 @@ /** FrameMetrics.cpp */ -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/FrameMetrics.h" #include "GameClient/Display.h" @@ -32,8 +32,6 @@ FrameMetrics::FrameMetrics() { - //Added By Sadullah Nader - //Initializations missing and needed m_averageFps = 0.0f; m_averageLatency = 0.0f; m_cushionIndex = 0; @@ -44,27 +42,19 @@ FrameMetrics::FrameMetrics() m_pendingLatencies = NEW time_t[MAX_FRAMES_AHEAD]; for(Int i = 0; i < MAX_FRAMES_AHEAD; i++) m_pendingLatencies[i] = 0; - // m_fpsList = NEW Real[TheGlobalData->m_networkFPSHistoryLength]; m_latencyList = NEW Real[TheGlobalData->m_networkLatencyHistoryLength]; } FrameMetrics::~FrameMetrics() { - if (m_fpsList != NULL) { - delete m_fpsList; - m_fpsList = NULL; - } + delete m_fpsList; + m_fpsList = NULL; - if (m_latencyList != NULL) { - delete m_latencyList; - m_latencyList = NULL; - } + delete m_latencyList; + m_latencyList = NULL; - if (m_pendingLatencies) - { - delete[] m_pendingLatencies; - m_pendingLatencies = NULL; - } + delete[] m_pendingLatencies; + m_pendingLatencies = NULL; } void FrameMetrics::init() { diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp b/Core/GameEngine/Source/GameNetwork/GameInfo.cpp similarity index 97% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp rename to Core/GameEngine/Source/GameNetwork/GameInfo.cpp index 4a2526ed45..8551069dae 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameInfo.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameInfo.cpp @@ -26,7 +26,7 @@ // game setup state info // Author: Matthew D. Campbell, December 2001 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/CRCDebug.h" #include "Common/file.h" @@ -211,7 +211,7 @@ void GameSlot::setState( SlotState state, UnicodeString name, UnsignedInt IP ) reset(); m_state = state; m_name = name; - }// state == SLOT_PLAYER + } else { m_state = state; @@ -301,14 +301,12 @@ void GameInfo::reset( void ) m_inGame = false; m_inProgress = false; m_gameID = 0; - m_mapName = AsciiString("NOMAP"); + m_mapName = "NOMAP"; m_mapMask = 0; m_seed = GetTickCount(); //GameClientRandomValue(0, INT_MAX - 1); m_useStats = TRUE; m_surrendered = FALSE; m_oldFactionsOnly = FALSE; - // Added By Sadullah Nader - // Initializations missing and needed // m_localIP = 0; // BGC - actually we don't want this to be reset since the m_localIP is // set properly in the constructor of LANGameInfo which uses this as a base class. m_mapCRC = 0; @@ -316,8 +314,6 @@ void GameInfo::reset( void ) m_superweaponRestriction = 0; m_startingCash = TheGlobalData->m_defaultStartingCash; - // - for (Int i=0; igetMapContentsMask(), newMapName.str(), + game->getMapCRC(), game->getMapSize(), game->getSeed(), game->getCRCInterval()); +#else optionsString.format("US=%d;M=%2.2x%s;MC=%X;MS=%d;SD=%d;C=%d;SR=%u;SC=%u;O=%c;", game->getUseStats(), game->getMapContentsMask(), newMapName.str(), game->getMapCRC(), game->getMapSize(), game->getSeed(), game->getCRCInterval(), game->getSuperweaponRestriction(), game->getStartingCash().countMoney(), game->oldFactionsOnly() ? 'Y' : 'N' ); +#endif //add player info for each slot optionsString.concat(slotListID); @@ -1018,8 +1019,15 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) Money startingCash = TheGlobalData->m_defaultStartingCash; UnsignedShort restriction = 0; // Always the default - Bool sawMap, sawMapCRC, sawMapSize, sawSeed, sawSlotlist, sawUseStats, sawSuperweaponRestriction, sawStartingCash, sawOldFactions; - sawMap = sawMapCRC = sawMapSize = sawSeed = sawSlotlist = sawUseStats = sawSuperweaponRestriction = sawStartingCash = sawOldFactions = FALSE; + Bool sawMap = FALSE; + Bool sawMapCRC = FALSE; + Bool sawMapSize = FALSE; + Bool sawSeed = FALSE; + Bool sawSlotlist = FALSE; + Bool sawUseStats = FALSE; + Bool sawSuperweaponRestriction = FALSE; + Bool sawStartingCash = FALSE; + Bool sawOldFactions = FALSE; //DEBUG_LOG(("Saw options of %s", options.str())); DEBUG_LOG(("ParseAsciiStringToGameInfo - parsing [%s]", options.str())); @@ -1121,7 +1129,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) { UnsignedInt startingCashAmount = strtoul( val.str(), NULL, 10 ); startingCash.init(); - startingCash.deposit( startingCashAmount, FALSE ); + startingCash.deposit( startingCashAmount, FALSE, FALSE ); sawStartingCash = TRUE; } else if (key.compare("O") == 0 ) @@ -1306,7 +1314,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) } newSlot[i].setNATBehavior(NATType); DEBUG_LOG(("ParseAsciiStringToGameInfo - NAT behavior is %X", NATType)); - }// case 'H': + } break; case 'C': { @@ -1347,7 +1355,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) DEBUG_LOG(("ParseAsciiStringToGameInfo - Unknown AI, quitting")); } break; - }//switch(*rawSlot.str()+1) + } //Read color index slotValue = strtok_r(NULL,",",&slotPos); @@ -1433,19 +1441,19 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) newSlot[i].setTeamNumber(team); //DEBUG_LOG(("ParseAsciiStringToGameInfo - team number is %d", team)); - }//case 'C': + } break; case 'O': { newSlot[i].setState( SLOT_OPEN ); //DEBUG_LOG(("ParseAsciiStringToGameInfo - Slot is open")); - }// case 'O': + } break; case 'X': { newSlot[i].setState( SLOT_CLOSED ); //DEBUG_LOG(("ParseAsciiStringToGameInfo - Slot is closed")); - }// case 'X': + } break; default: { @@ -1455,7 +1463,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) break; } } - if(freeMe) + free(freeMe); } else @@ -1464,11 +1472,17 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) break; } } - if( buf ) - free(buf); - //DEBUG_LOG(("Options were ok == %d", optionsOk)); - if (optionsOk && sawMap && sawMapCRC && sawMapSize && sawSeed && sawSlotlist && sawCRC && sawUseStats && sawSuperweaponRestriction && sawStartingCash && sawOldFactions ) + free(buf); + + // TheSuperHackers @tweak The following settings are no longer + // a strict requirement in the Zero Hour Replay file: + // * UseStats + // * SuperweaponRestriction + // * StartingCash + // * OldFactionsOnly + // In Generals they never were. + if (optionsOk && sawMap && sawMapCRC && sawMapSize && sawSeed && sawSlotlist && sawCRC) { // We were setting the Global Data directly here, but Instead, I'm now // first setting the data in game. We'll set the global data when @@ -1488,9 +1502,9 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) game->setSeed(seed); game->setCRCInterval(crc); game->setUseStats(useStats); - game->setSuperweaponRestriction(restriction); - game->setStartingCash( startingCash ); - game->setOldFactionsOnly( oldFactionsOnly ); + game->setSuperweaponRestriction(restriction); + game->setStartingCash(startingCash); + game->setOldFactionsOnly(oldFactionsOnly); return true; } @@ -1510,14 +1524,18 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) // ------------------------------------------------------------------------------------------------ void SkirmishGameInfo::crc( Xfer *xfer ) { -} // end crc +} // ------------------------------------------------------------------------------------------------ /** Xfer Method */ // ------------------------------------------------------------------------------------------------ void SkirmishGameInfo::xfer( Xfer *xfer ) { +#if RTS_GENERALS + const XferVersion currentVersion = 2; +#else const XferVersion currentVersion = 4; +#endif XferVersion version = currentVersion; xfer->xferVersion( &version, currentVersion ); @@ -1615,13 +1633,13 @@ void SkirmishGameInfo::xfer( Xfer *xfer ) m_startingCash = TheGlobalData->m_defaultStartingCash; } -} // end xfer +} // ------------------------------------------------------------------------------------------------ /** Load post process */ // ------------------------------------------------------------------------------------------------ void SkirmishGameInfo::loadPostProcess( void ) { -} // end loadPostProcess +} diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameMessageParser.cpp b/Core/GameEngine/Source/GameNetwork/GameMessageParser.cpp similarity index 97% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/GameMessageParser.cpp rename to Core/GameEngine/Source/GameNetwork/GameMessageParser.cpp index 4569278aaf..9b289c450e 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameMessageParser.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameMessageParser.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/GameMessageParser.h" diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp similarity index 96% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp rename to Core/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp index 8eb5fc7cf3..e3089d6fb6 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp @@ -26,7 +26,7 @@ // Generals GameSpy chat-related code // Author: Matthew D. Campbell, July 2002 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/AudioEventRTS.h" #include "Common/INI.h" @@ -70,7 +70,7 @@ static const FieldParse GameSpyColorFieldParse[] = { "MOTD", INI::parseColorInt, NULL, OFFSET(GSCOLOR_MOTD) }, { "MOTDHeading", INI::parseColorInt, NULL, OFFSET(GSCOLOR_MOTD_HEADING) }, - { NULL, NULL, NULL, 0 } // keep this last + { NULL, NULL, NULL, 0 } }; @@ -89,12 +89,20 @@ Color GameSpyColor[GSCOLOR_MAX] = GameMakeColor(128,128,0,255), // GSCOLOR_GAME GameMakeColor(128,128,128,255), // GSCOLOR_GAME_FULL GameMakeColor(128,128,128,255), // GSCOLOR_GAME_CRCMISMATCH +#if RTS_GENERALS + GameMakeColor(255, 0, 0,255), // GSCOLOR_PLAYER_NORMAL +#else GameMakeColor(255,255,255,255), // GSCOLOR_PLAYER_NORMAL +#endif GameMakeColor(255, 0,255,255), // GSCOLOR_PLAYER_OWNER GameMakeColor(255, 0,128,255), // GSCOLOR_PLAYER_BUDDY GameMakeColor(255, 0, 0,255), // GSCOLOR_PLAYER_SELF GameMakeColor(128,128,128,255), // GSCOLOR_PLAYER_IGNORED +#if RTS_GENERALS + GameMakeColor(255,0,0,255), // GSCOLOR_CHAT_NORMAL +#else GameMakeColor(255,255,255,255), // GSCOLOR_CHAT_NORMAL +#endif GameMakeColor(255,128,0,255), // GSCOLOR_CHAT_EMOTE, GameMakeColor(255,255,0,255), // GSCOLOR_CHAT_OWNER, GameMakeColor(128,255,0,255), // GSCOLOR_CHAT_OWNER_EMOTE, @@ -140,7 +148,7 @@ Bool GameSpyInfo::sendChat( UnicodeString message, Bool isAction, GameWindow *pl } // Get the selections (is this a private message?) - Int maxSel = GadgetListBoxGetListLength(playerListbox); + Int maxSel = GadgetListBoxGetMaxSelectedLength(playerListbox); Int *selections; GadgetListBoxGetSelected(playerListbox, (Int *)&selections); @@ -255,7 +263,7 @@ void GameSpyInfo::addChat( PlayerInfo p, UnicodeString msg, Bool isPublic, Bool if( TheAudio ) { TheAudio->addAudioEvent( &privMsgAudio ); - } // end if + } } } diff --git a/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp similarity index 98% rename from Generals/Code/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp rename to Core/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp index f9b1a3e601..bc2360883a 100644 --- a/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp @@ -1,5 +1,5 @@ /* -** Command & Conquer Generals(tm) +** Command & Conquer Generals Zero Hour(tm) ** Copyright 2025 Electronic Arts Inc. ** ** This program is free software: you can redistribute it and/or modify @@ -29,7 +29,7 @@ /////////////////////////////////////////////////////////////////////////////////////// // INCLUDES /////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/GameState.h" #include "GameClient/MapUtil.h" @@ -336,7 +336,7 @@ m_qmChannel(0) // German2 is missing some maps because of content. But, we need the m_qmMaps // to contain same number of strings as the Retail version so that the // QM Bot thinks that they have the same number of maps. - #if 1 + #if RTS_GENERALS m_qmMaps.push_back(mapName); #else const MapMetaData *md = TheMapCache->findMap(mapName); diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LadderDefs.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/LadderDefs.cpp similarity index 96% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LadderDefs.cpp rename to Core/GameEngine/Source/GameNetwork/GameSpy/LadderDefs.cpp index 9a178ab3d2..c59f0613a2 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LadderDefs.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/LadderDefs.cpp @@ -26,7 +26,7 @@ // Generals ladder code // Author: Matthew D. Campbell, August 2002 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/GameSpy/ThreadUtils.h" #include "GameNetwork/GameSpy/LadderDefs.h" @@ -87,7 +87,7 @@ static LadderInfo *parseLadder(AsciiString raw) line.nextToken(&tokenHomepage, " "); lad->name = MultiByteToWideCharSingleLine(tokenName.str()).c_str(); - lad->name.truncateTo(20); // Per Harvard's request, ladder names are limited to 20 chars + lad->name.truncateTo(20); // Per Harvard's request, ladder names are limited to 20 chars lad->address = tokenAddr; lad->port = atoi(tokenPort.str()); lad->homepageURL = tokenHomepage; @@ -163,7 +163,7 @@ static LadderInfo *parseLadder(AsciiString raw) // end of a ladder if (lad->playersPerTeam >= 1 && lad->playersPerTeam <= MAX_SLOTS/2) { - if (lad->validFactions.size() == 0) + if (lad->validFactions.empty()) { DEBUG_LOG(("No factions specified. Using all.")); lad->validFactions.clear(); @@ -190,7 +190,7 @@ static LadderInfo *parseLadder(AsciiString raw) } } - if (lad->validMaps.size() == 0) + if (lad->validMaps.empty()) { DEBUG_LOG(("No maps specified. Using all.")); std::list qmMaps = TheGameSpyConfig->getQMMaps(); @@ -244,11 +244,7 @@ static LadderInfo *parseLadder(AsciiString raw) } } - if (lad) - { - delete lad; - lad = NULL; - } + delete lad; return NULL; } @@ -448,7 +444,7 @@ void LadderList::loadLocalLadders( void ) AsciiString dirname; dirname.format("%sGeneralsOnline\\Ladders\\", TheGlobalData->getPath_UserData().str()); FilenameList filenameList; - TheFileSystem->getFileListInDirectory(dirname, AsciiString("*.ini"), filenameList, TRUE); + TheFileSystem->getFileListInDirectory(dirname, "*.ini", filenameList, TRUE); Int index = -1; @@ -507,9 +503,9 @@ void LadderList::checkLadder( AsciiString fname, Int index ) return; } - if (li->validMaps.size() == 0) + if (li->validMaps.empty()) { - DEBUG_LOG(("Bailing because of li->validMaps.size() == 0")); + DEBUG_LOG(("Bailing because of li->validMaps.empty()")); delete li; return; } diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp similarity index 97% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp rename to Core/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp index 18bea5bd01..7ac0d39b85 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp @@ -29,7 +29,7 @@ /////////////////////////////////////////////////////////////////////////////////////// // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/GameEngine.h" #include "Common/MultiplayerSettings.h" @@ -72,7 +72,9 @@ enum { COLUMN_NUMPLAYERS, COLUMN_PASSWORD, COLUMN_OBSERVER, +#if !RTS_GENERALS COLUMN_USE_STATS, +#endif COLUMN_PING, }; @@ -247,6 +249,7 @@ static void gameTooltip(GameWindow *window, TheMouse->setCursorTooltip( UnicodeString::TheEmptyString ); return; } +#if !RTS_GENERALS if (col == COLUMN_USE_STATS) { if ( room->getUseStats() ) @@ -259,6 +262,7 @@ static void gameTooltip(GameWindow *window, } return; } +#endif UnicodeString tooltip; @@ -461,8 +465,7 @@ static void populateBuddyGames(void) static void clearBuddyGames(void) { - if (theBuddyGames) - delete theBuddyGames; + delete theBuddyGames; theBuddyGames = NULL; } @@ -610,8 +613,8 @@ static Int insertGame( GameWindow *win, GameSpyStagingRoom *game, Bool showMap ) } else { - GadgetListBoxAddEntryText(win, UnicodeString(L" "), gameColor, index, COLUMN_MAP); - GadgetListBoxAddEntryText(win, UnicodeString(L" "), gameColor, index, COLUMN_LADDER); + GadgetListBoxAddEntryText(win, L" ", gameColor, index, COLUMN_MAP); + GadgetListBoxAddEntryText(win, L" ", gameColor, index, COLUMN_LADDER); } s.format(L"%d/%d", game->getReportedNumPlayers(), game->getReportedMaxPlayers()); @@ -630,7 +633,7 @@ static Int insertGame( GameWindow *win, GameSpyStagingRoom *game, Bool showMap ) } else { - GadgetListBoxAddEntryText(win, UnicodeString(L" "), gameColor, index, COLUMN_PASSWORD); + GadgetListBoxAddEntryText(win, L" ", gameColor, index, COLUMN_PASSWORD); } if (game->getAllowObservers()) @@ -640,17 +643,20 @@ static Int insertGame( GameWindow *win, GameSpyStagingRoom *game, Bool showMap ) } else { - GadgetListBoxAddEntryText(win, UnicodeString(L" "), gameColor, index, COLUMN_OBSERVER); + GadgetListBoxAddEntryText(win, L" ", gameColor, index, COLUMN_OBSERVER); } +#if !RTS_GENERALS { if (game->getUseStats()) { - const Image *img = TheMappedImageCollection->findImageByName("GoodStatsIcon"); - GadgetListBoxAddEntryImage(win, img, index, COLUMN_USE_STATS, img->getImageHeight(), img->getImageWidth()); - } - + if (const Image *img = TheMappedImageCollection->findImageByName("GoodStatsIcon")) + { + GadgetListBoxAddEntryImage(win, img, index, COLUMN_USE_STATS, img->getImageHeight(), img->getImageWidth()); + } + } } +#endif s.format(L"%d", game->getPingAsInt()); GadgetListBoxAddEntryText(win, s, gameColor, index, COLUMN_PING); diff --git a/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp similarity index 94% rename from Generals/Code/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp rename to Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp index d84c449a9c..c6585cef93 100644 --- a/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp @@ -1,5 +1,5 @@ /* -** Command & Conquer Generals(tm) +** Command & Conquer Generals Zero Hour(tm) ** Copyright 2025 Electronic Arts Inc. ** ** This program is free software: you can redistribute it and/or modify @@ -29,7 +29,7 @@ /////////////////////////////////////////////////////////////////////////////////////// // INCLUDES /////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include @@ -95,7 +95,7 @@ void StartDownloadingPatches( void ) } WindowLayout *layout; - layout = TheWindowManager->winCreateLayout( AsciiString( "Menus/DownloadMenu.wnd" ) ); + layout = TheWindowManager->winCreateLayout( "Menus/DownloadMenu.wnd" ); layout->runInit(); layout->hide( FALSE ); layout->bringForward(); @@ -191,7 +191,7 @@ static void startOnline( void ) noPatchBeforeOnlineCallback); return; } - if (queuedDownloads.size()) + if (!queuedDownloads.empty()) { if (!hasWriteAccess()) { @@ -220,16 +220,12 @@ static void startOnline( void ) DEBUG_ASSERTCRASH( !TheGameSpyPeerMessageQueue, ("TheGameSpyPeerMessageQueue exists!") ); DEBUG_ASSERTCRASH( !TheGameSpyInfo, ("TheGameSpyInfo exists!") ); SetUpGameSpy(MOTDBuffer, configBuffer); - if (MOTDBuffer) - { - delete[] MOTDBuffer; - MOTDBuffer = NULL; - } - if (configBuffer) - { - delete[] configBuffer; - configBuffer = NULL; - } + + delete[] MOTDBuffer; + MOTDBuffer = NULL; + + delete[] configBuffer; + configBuffer = NULL; #ifdef ALLOW_NON_PROFILED_LOGIN UserPreferences pref; @@ -237,10 +233,10 @@ static void startOnline( void ) UserPreferences::const_iterator it = pref.find("useProfiles"); if (it != pref.end() && it->second.compareNoCase("yes") == 0) #endif // ALLOW_NON_PROFILED_LOGIN - TheShell->push( AsciiString("Menus/GameSpyLoginProfile.wnd") ); + TheShell->push( "Menus/GameSpyLoginProfile.wnd" ); #ifdef ALLOW_NON_PROFILED_LOGIN else - TheShell->push( AsciiString("Menus/GameSpyLoginQuick.wnd") ); + TheShell->push( "Menus/GameSpyLoginQuick.wnd" ); #endif // ALLOW_NON_PROFILED_LOGIN } @@ -320,12 +316,7 @@ static GHTTPBool motdCallback( GHTTPRequest request, GHTTPResult result, return GHTTPTrue; } - if (MOTDBuffer) - { - delete[] MOTDBuffer; - MOTDBuffer = NULL; - } - + delete[] MOTDBuffer; MOTDBuffer = NEW char[bufferLen]; memcpy(MOTDBuffer, buffer, bufferLen); MOTDBuffer[bufferLen-1] = 0; @@ -360,11 +351,8 @@ static GHTTPBool configCallback( GHTTPRequest request, GHTTPResult result, return GHTTPTrue; } - if (configBuffer) - { - delete[] configBuffer; - configBuffer = NULL; - } + delete[] configBuffer; + configBuffer = NULL; if (result != GHTTPSuccess || bufferLen < 100) { @@ -464,11 +452,8 @@ static GHTTPBool configHeadCallback( GHTTPRequest request, GHTTPResult result, onlineCancelWindow = NULL; } - if (configBuffer) - { - delete[] configBuffer; - configBuffer = NULL; - } + delete[] configBuffer; + configBuffer = NULL; AsciiString fname; fname.format("%sGeneralsOnline\\Config.txt", TheGlobalData->getPath_UserData().str()); @@ -579,16 +564,12 @@ void CancelPatchCheckCallback( void ) onlineCancelWindow = NULL; } queuedDownloads.clear(); - if (MOTDBuffer) - { - delete[] MOTDBuffer; - MOTDBuffer = NULL; - } - if (configBuffer) - { - delete[] configBuffer; - configBuffer = NULL; - } + + delete[] MOTDBuffer; + MOTDBuffer = NULL; + + delete[] configBuffer; + configBuffer = NULL; } /////////////////////////////////////////////////////////////////////////////////////// @@ -601,6 +582,7 @@ static GHTTPBool overallStatsCallback( GHTTPRequest request, GHTTPResult result, return GHTTPTrue; } +#if RTS_GENERALS OverallStats USA, China, GLA; AsciiString message = buffer; @@ -669,6 +651,9 @@ static GHTTPBool overallStatsCallback( GHTTPRequest request, GHTTPResult result, } HandleOverallStats(USA, China, GLA); +#elif RTS_ZEROHOUR + HandleOverallStats( buffer, bufferLen ); +#endif return GHTTPTrue; } @@ -704,16 +689,24 @@ static GHTTPBool numPlayersOnlineCallback( GHTTPRequest request, GHTTPResult res void CheckOverallStats( void ) { - ghttpGet("http://gamestats.gamespy.com/ccgenerals/display.html", - GHTTPFalse, overallStatsCallback, NULL); +#if RTS_GENERALS + const char *const url = "http://gamestats.gamespy.com/ccgenerals/display.html"; +#elif RTS_ZEROHOUR + const char *const url = "http://gamestats.gamespy.com/ccgenzh/display.html"; +#endif + ghttpGet(url, GHTTPFalse, overallStatsCallback, NULL); } /////////////////////////////////////////////////////////////////////////////////////// void CheckNumPlayersOnline( void ) { - ghttpGet("http://launch.gamespyarcade.com/software/launch/arcadecount2.dll?svcname=ccgenerals", - GHTTPFalse, numPlayersOnlineCallback, NULL); +#if RTS_GENERALS + const char *const url = "http://launch.gamespyarcade.com/software/launch/arcadecount2.dll?svcname=ccgenerals"; +#elif RTS_ZEROHOUR + const char *const url = "http://launch.gamespyarcade.com/software/launch/arcadecount2.dll?svcname=ccgenzh"; +#endif + ghttpGet(url, GHTTPFalse, numPlayersOnlineCallback, NULL); } /////////////////////////////////////////////////////////////////////////////////////// diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp similarity index 96% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp rename to Core/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp index f9fa51f5af..cd67390e83 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp @@ -20,7 +20,7 @@ // Generals GameSpy Peer (chat) definitions // Author: Matthew D. Campbell, June 2002 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include #include "Common/GameState.h" @@ -85,12 +85,9 @@ void GameSpyInfo::reset( void ) m_localStagingRoomID = 0; m_localStagingRoom.reset(); m_gotGroupRoomList = false; - m_localName = ""; + m_localName.clear(); m_localProfileID = 0; m_maxMessagesPerUpdate = 100; - - // Added By Sadullah Nader - // Initialization missing and needed m_disallowAsainText = FALSE; m_disallowNonAsianText = FALSE; m_disconReason = 0; @@ -100,15 +97,10 @@ void GameSpyInfo::reset( void ) m_pingString.clear(); m_rawConfig.clear(); m_rawMotd.clear(); - // - m_internalIP = m_externalIP = 0; - m_savedIgnoreMap.clear(); m_preorderPlayers.clear(); - m_cachedLocalPlayerStats.reset(); - m_additionalDisconnects = -1; } @@ -194,7 +186,7 @@ void GameSpyInfo::setGameOptions( void ) req.gameOptions.numPlayers = 0; req.gameOptions.numObservers = 0; Int numOpenSlots = 0; - AsciiString playerInfo = ""; + AsciiString playerInfo; for (i=0; ifetch(groupLabel); m_groupRooms[room.m_groupID] = room; - if ( !stricmp("quickmatch", room.m_name.str()) ) + if ( stricmp("quickmatch", room.m_name.str()) == 0 ) { DEBUG_LOG(("Group room %d (%s) is the QuickMatch room", room.m_groupID, room.m_name.str())); TheGameSpyConfig->setQMChannel(room.m_groupID); @@ -386,7 +378,7 @@ void GameSpyInfo::joinBestGroupRoom( void ) return; } - if (m_groupRooms.size()) + if (!m_groupRooms.empty()) { int minID = -1; int minPlayers = 1000; @@ -678,28 +670,17 @@ void TearDownGameSpy( void ) if (ThePinger) ThePinger->endThreads(); - if(TheRankPointValues) - { - delete TheRankPointValues; - TheRankPointValues = NULL; - } - if (TheGameSpyPSMessageQueue) - { - delete TheGameSpyPSMessageQueue; - TheGameSpyPSMessageQueue = NULL; - } + delete TheRankPointValues; + TheRankPointValues = NULL; - if (TheGameSpyBuddyMessageQueue) - { - delete TheGameSpyBuddyMessageQueue; - TheGameSpyBuddyMessageQueue = NULL; - } + delete TheGameSpyPSMessageQueue; + TheGameSpyPSMessageQueue = NULL; - if (TheGameSpyPeerMessageQueue) - { - delete TheGameSpyPeerMessageQueue; - TheGameSpyPeerMessageQueue = NULL; - } + delete TheGameSpyBuddyMessageQueue; + TheGameSpyBuddyMessageQueue = NULL; + + delete TheGameSpyPeerMessageQueue; + TheGameSpyPeerMessageQueue = NULL; if (TheGameSpyInfo) { @@ -712,23 +693,14 @@ void TearDownGameSpy( void ) TheGameSpyInfo = NULL; } - if (ThePinger) - { - delete ThePinger; - ThePinger = NULL; - } + delete ThePinger; + ThePinger = NULL; - if (TheLadderList) - { - delete TheLadderList; - TheLadderList = NULL; - } + delete TheLadderList; + TheLadderList = NULL; - if (TheGameSpyConfig) - { - delete TheGameSpyConfig; - TheGameSpyConfig = NULL; - } + delete TheGameSpyConfig; + TheGameSpyConfig = NULL; // make sure the notification box doesn't exist deleteNotificationBox(); diff --git a/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp similarity index 98% rename from Generals/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp rename to Core/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp index c444c71552..dc0aea8b3f 100644 --- a/Generals/Code/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp @@ -1,5 +1,5 @@ /* -** Command & Conquer Generals(tm) +** Command & Conquer Generals Zero Hour(tm) ** Copyright 2025 Electronic Arts Inc. ** ** This program is free software: you can redistribute it and/or modify @@ -26,7 +26,7 @@ // Generals GameSpy GameInfo-related code // Author: Matthew D. Campbell, July 2002 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/GameState.h" #include "Common/Player.h" @@ -62,8 +62,6 @@ GameSpyGameSlot::GameSpyGameSlot() m_rankPoints = 0; m_favoriteSide = 0; m_pingInt = 0; - // Added By Sadullah Nader - // Initializations missing and needed m_profileID = 0; m_pingStr.clear(); } @@ -535,10 +533,8 @@ void GameSpyStagingRoom::startGame(Int gameID) UnsignedInt localIP = TheGameSpyInfo->getInternalIP(); setLocalIP(localIP); - if (TheNAT != NULL) { - delete TheNAT; - TheNAT = NULL; - } + delete TheNAT; + TheNAT = NULL; // fill in GS-specific info Int numHumans = 0; @@ -764,8 +760,13 @@ AsciiString GameSpyStagingRoom::generateLadderGameResultsPacket( void ) playerStr.format(",buildingsKilled%d=%d,buildingsLost%d=%d,buildingsBuilt%d=%d", playerID, buildingsKilled, playerID, buildingsLost, playerID, buildingsBuilt); results.concat(playerStr); +#if RTS_GENERALS playerStr.format(",fps%d=%d,cash%d=%d,capturedTech%d=%d,discon%d=%d,side%d=%s,team%d=%d", playerID, fps, playerID, earnings, playerID, techCaptured, playerID, disconnected, playerID, p[i]->getPlayerTemplate()->getSide().str(), playerID, slot->getTeamNumber()); +#elif RTS_ZEROHOUR + playerStr.format(",fps%d=%d,cash%d=%d,capturedTech%d=%d,discon%d=%d,side%d=%s", + playerID, fps, playerID, earnings, playerID, techCaptured, playerID, disconnected, playerID, p[i]->getPlayerTemplate()->getSide().str()); +#endif results.concat(playerStr); ++playerID; @@ -801,10 +802,8 @@ void GameSpyStagingRoom::launchGame( void ) AsciiString userList; DEBUG_ASSERTCRASH(TheNetwork == NULL, ("For some reason TheNetwork isn't NULL at the start of this game. Better look into that.")); - if (TheNetwork != NULL) { - delete TheNetwork; - TheNetwork = NULL; - } + delete TheNetwork; + TheNetwork = NULL; // Time to initialize TheNetwork for this game. TheNetwork = NetworkInterface::createNetwork(); @@ -830,10 +829,10 @@ void GameSpyStagingRoom::launchGame( void ) if (!filesOk || TheMapCache->findMap(getMap()) == NULL) { DEBUG_LOG(("After transfer, we didn't really have the map. Bailing...")); - if (TheNetwork != NULL) { - delete TheNetwork; - TheNetwork = NULL; - } + + delete TheNetwork; + TheNetwork = NULL; + GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:CouldNotTransferMap")); void PopBackToLobby( void ); @@ -865,10 +864,8 @@ void GameSpyStagingRoom::launchGame( void ) sprintf(req.arg.status.locationString, "%s", WideCharStringToMultiByte(TheGameSpyGame->getGameName().str()).c_str()); TheGameSpyBuddyMessageQueue->addRequest(req); - if (TheNAT != NULL) { - delete TheNAT; - TheNAT = NULL; - } + delete TheNAT; + TheNAT = NULL; } void GameSpyStagingRoom::reset(void) diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp similarity index 92% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp rename to Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp index 31156acbcf..da36009076 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp @@ -29,7 +29,7 @@ // the game. // Author: Matthew D. Campbell, June 2002 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/GameSpy/BuddyThread.h" #include "GameNetwork/GameSpy/PeerThread.h" @@ -121,7 +121,6 @@ enum CallbackType CALLBACK_RECVMESSAGE, CALLBACK_RECVREQUEST, CALLBACK_RECVSTATUS, - CALLBACK_MAX }; void callbackWrapper( GPConnection *con, void *arg, void *param ) @@ -181,8 +180,7 @@ void GameSpyBuddyMessageQueue::startThread( void ) void GameSpyBuddyMessageQueue::endThread( void ) { - if (m_thread) - delete m_thread; + delete m_thread; m_thread = NULL; } @@ -262,7 +260,12 @@ void BuddyThreadClass::Thread_Function() try { GPConnection gpCon; GPConnection *con = &gpCon; - gpInitialize( con, 823, 0, GP_PARTNERID_GAMESPY ); +#if RTS_GENERALS + const int productID = 675; +#elif RTS_ZEROHOUR + const int productID = 823; +#endif + gpInitialize( con, productID, 0, GP_PARTNERID_GAMESPY ); m_isConnected = m_isConnecting = false; gpSetCallback( con, GP_ERROR, callbackWrapper, (void *)CALLBACK_ERROR ); @@ -485,8 +488,7 @@ void BuddyThreadClass::errorCallback( GPConnection *con, GPErrorArg *arg ) errorResponse.result = arg->result; errorResponse.arg.error.errorCode = arg->errorCode; errorResponse.arg.error.fatal = arg->fatal; - strncpy(errorResponse.arg.error.errorString, arg->errorString, MAX_BUDDY_CHAT_LEN); - errorResponse.arg.error.errorString[MAX_BUDDY_CHAT_LEN-1] = 0; + strlcpy(errorResponse.arg.error.errorString, arg->errorString, MAX_BUDDY_CHAT_LEN); m_isConnecting = m_isConnected = false; TheGameSpyBuddyMessageQueue->addResponse( errorResponse ); if (m_isdeleting) @@ -502,6 +504,7 @@ void BuddyThreadClass::errorCallback( GPConnection *con, GPErrorArg *arg ) static void getNickForMessage( GPConnection *con, GPGetInfoResponseArg *arg, void *param ) { BuddyResponse *resp = (BuddyResponse *)param; + static_assert(ARRAY_SIZE(resp->arg.message.nick) >= ARRAY_SIZE(arg->nick), "Incorrect array size"); strcpy(resp->arg.message.nick, arg->nick); } @@ -515,8 +518,7 @@ void BuddyThreadClass::messageCallback( GPConnection *con, GPRecvBuddyMessageArg gpGetInfo( con, arg->profile, GP_CHECK_CACHE, GP_BLOCKING, (GPCallback)getNickForMessage, &messageResponse); std::wstring s = MultiByteToWideCharSingleLine( arg->message ); - wcsncpy(messageResponse.arg.message.text, s.c_str(), MAX_BUDDY_CHAT_LEN); - messageResponse.arg.message.text[MAX_BUDDY_CHAT_LEN-1] = 0; + wcslcpy(messageResponse.arg.message.text, s.c_str(), MAX_BUDDY_CHAT_LEN); messageResponse.arg.message.date = arg->date; DEBUG_LOG(("Got a buddy message from %d [%ls]", arg->profile, s.c_str())); TheGameSpyBuddyMessageQueue->addResponse( messageResponse ); @@ -556,9 +558,9 @@ void BuddyThreadClass::connectCallback( GPConnection *con, GPConnectResponseArg DEBUG_LOG(("User Error: Create Account instead of Login. Fixing them...")); BuddyRequest req; req.buddyRequestType = BuddyRequest::BUDDYREQUEST_LOGIN; - strcpy(req.arg.login.nick, m_nick.c_str()); - strcpy(req.arg.login.email, m_email.c_str()); - strcpy(req.arg.login.password, m_pass.c_str()); + strlcpy(req.arg.login.nick, m_nick.c_str(), ARRAY_SIZE(req.arg.login.nick)); + strlcpy(req.arg.login.email, m_email.c_str(), ARRAY_SIZE(req.arg.login.email)); + strlcpy(req.arg.login.password, m_pass.c_str(), ARRAY_SIZE(req.arg.login.password)); req.arg.login.hasFirewall = true; TheGameSpyBuddyMessageQueue->addRequest( req ); return; @@ -617,6 +619,9 @@ static void getInfoResponseForRequest( GPConnection *con, GPGetInfoResponseArg * { BuddyResponse *resp = (BuddyResponse *)param; resp->profile = arg->profile; + static_assert(ARRAY_SIZE(resp->arg.request.nick) >= ARRAY_SIZE(arg->nick), "Incorrect array size"); + static_assert(ARRAY_SIZE(resp->arg.request.email) >= ARRAY_SIZE(arg->email), "Incorrect array size"); + static_assert(ARRAY_SIZE(resp->arg.request.countrycode) >= ARRAY_SIZE(arg->countrycode), "Incorrect array size"); strcpy(resp->arg.request.nick, arg->nick); strcpy(resp->arg.request.email, arg->email); strcpy(resp->arg.request.countrycode, arg->countrycode); @@ -632,8 +637,7 @@ void BuddyThreadClass::requestCallback( GPConnection *con, GPRecvBuddyRequestArg gpGetInfo( con, arg->profile, GP_CHECK_CACHE, GP_BLOCKING, (GPCallback)getInfoResponseForRequest, &response); std::wstring s = MultiByteToWideCharSingleLine( arg->reason ); - wcsncpy(response.arg.request.text, s.c_str(), GP_REASON_LEN); - response.arg.request.text[GP_REASON_LEN-1] = 0; + wcslcpy(response.arg.request.text, s.c_str(), GP_REASON_LEN); TheGameSpyBuddyMessageQueue->addResponse( response ); } @@ -644,6 +648,9 @@ static void getInfoResponseForStatus(GPConnection * connection, GPGetInfoRespons { BuddyResponse *resp = (BuddyResponse *)param; resp->profile = arg->profile; + static_assert(ARRAY_SIZE(resp->arg.status.nick) >= ARRAY_SIZE(arg->nick), "Incorrect array size"); + static_assert(ARRAY_SIZE(resp->arg.status.email) >= ARRAY_SIZE(arg->email), "Incorrect array size"); + static_assert(ARRAY_SIZE(resp->arg.status.countrycode) >= ARRAY_SIZE(arg->countrycode), "Incorrect array size"); strcpy(resp->arg.status.nick, arg->nick); strcpy(resp->arg.status.email, arg->email); strcpy(resp->arg.status.countrycode, arg->countrycode); @@ -660,6 +667,8 @@ void BuddyThreadClass::statusCallback( GPConnection *con, GPRecvBuddyStatusArg * // get user's status GPBuddyStatus status; gpGetBuddyStatus( con, arg->index, &status ); + static_assert(ARRAY_SIZE(response.arg.status.location) >= ARRAY_SIZE(status.locationString), "Incorrect array size"); + static_assert(ARRAY_SIZE(response.arg.status.statusString) >= ARRAY_SIZE(status.statusString), "Incorrect array size"); strcpy(response.arg.status.location, status.locationString); strcpy(response.arg.status.statusString, status.statusString); response.arg.status.status = status.status; diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp similarity index 98% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp rename to Core/GameEngine/Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp index a0e846aa10..6d8cc679b2 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp @@ -26,7 +26,7 @@ // Ping thread // Author: Matthew D. Campbell, August 2002 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include // This one has to be here. Prevents collisions with winsock2.h @@ -130,11 +130,8 @@ void GameResultsQueue::endThreads( void ) { for (Int i=0; isecond); UnsignedShort oldPrivatePort = SBServerGetPrivateQueryPort(it->second); UnsignedInt oldPublicIP = SBServerGetPublicInetAddress(it->second); - if (!strcmp(oldName, newName) && + if (strcmp(oldName, newName) == 0 && oldPrivateIP == newPrivateIP && oldPublicIP == newPublicIP && oldPrivatePort == newPrivatePort) @@ -509,7 +503,6 @@ enum CallbackType CALLBACK_RECVMESSAGE, CALLBACK_RECVREQUEST, CALLBACK_RECVSTATUS, - CALLBACK_MAX }; void connectCallbackWrapper( PEER peer, PEERBool success, int failureReason, void *param ) @@ -565,8 +558,7 @@ void GameSpyPeerMessageQueue::startThread( void ) void GameSpyPeerMessageQueue::endThread( void ) { - if (m_thread) - delete m_thread; + delete m_thread; m_thread = NULL; } @@ -766,7 +758,7 @@ static void QRServerKeyCallback t->stopHostingAlready(peer); #ifdef DEBUG_LOGGING - AsciiString val = ""; + AsciiString val; #define ADD(x) { qr2_buffer_add(buffer, x); val = x; } #define ADDINT(x) { qr2_buffer_add_int(buffer, x); val.format("%d",x); } #else @@ -805,9 +797,11 @@ static void QRServerKeyCallback case OBS_KEY: ADDINT(t->allowObservers()); break; +#if !RTS_GENERALS case USE_STATS_KEY: ADDINT(t->useStats()); break; +#endif case LADIP_KEY: ADD(t->ladderIP().c_str()); break; @@ -858,7 +852,7 @@ static void QRPlayerKeyCallback #undef ADD #undef ADDINT #ifdef DEBUG_LOGGING - AsciiString val = ""; + AsciiString val; #define ADD(x) { qr2_buffer_add(buffer, x); val = x; } #define ADDINT(x) { qr2_buffer_add_int(buffer, x); val.format("%d",x); } #else @@ -952,7 +946,9 @@ static void QRKeyListCallback qr2_keybuffer_add(keyBuffer, INICRC_KEY); qr2_keybuffer_add(keyBuffer, PW_KEY); qr2_keybuffer_add(keyBuffer, OBS_KEY); +#if !RTS_GENERALS qr2_keybuffer_add(keyBuffer, USE_STATS_KEY); +#endif qr2_keybuffer_add(keyBuffer, LADIP_KEY); qr2_keybuffer_add(keyBuffer, LADPORT_KEY); qr2_keybuffer_add(keyBuffer, PINGSTR_KEY); @@ -1099,7 +1095,7 @@ static SerialAuthResult doCDKeyAuthentication( PEER peer ) if (!peer) return retval; - AsciiString s = ""; + AsciiString s; if (GetStringFromRegistry("\\ergc", "", s) && s.isNotEmpty()) { #ifdef SERVER_DEBUGGING @@ -1202,7 +1198,9 @@ void PeerThreadClass::Thread_Function() qr2_register_key(INICRC_KEY, INICRC_STR); qr2_register_key(PW_KEY, PW_STR); qr2_register_key(OBS_KEY, OBS_STR); +#if !RTS_GENERALS qr2_register_key(USE_STATS_KEY, USE_STATS_STR); +#endif qr2_register_key(LADIP_KEY, LADIP_STR); qr2_register_key(LADPORT_KEY, LADPORT_STR); qr2_register_key(PINGSTR_KEY, PINGSTR_STR); @@ -1215,7 +1213,11 @@ void PeerThreadClass::Thread_Function() qr2_register_key(FACTION__KEY, FACTION__STR "_"); qr2_register_key(COLOR__KEY, COLOR__STR "_"); +#if RTS_GENERALS + const Int NumKeys = 14; +#else const Int NumKeys = 15; +#endif unsigned char allKeysArray[NumKeys] = { /* PID__KEY, @@ -1232,7 +1234,9 @@ void PeerThreadClass::Thread_Function() INICRC_KEY, PW_KEY, OBS_KEY, +#if !RTS_GENERALS USE_STATS_KEY, +#endif LADIP_KEY, LADPORT_KEY, PINGSTR_KEY, @@ -1240,7 +1244,7 @@ void PeerThreadClass::Thread_Function() NUMPLAYER_KEY, MAXPLAYER_KEY, HOSTNAME_KEY - }; + }; /* const char *allKeys = "\\pid_\\mapname\\gamever\\gamename" \ @@ -1274,9 +1278,17 @@ void PeerThreadClass::Thread_Function() /********* First step, set our game authentication info We could do: + Generals: + strcpy(gcd_gamename,"ccgenerals"); + strcpy(gcd_secret_key,"h5T2f6"); + ZeroHour: strcpy(gcd_gamename,"ccgenzh"); strcpy(gcd_secret_key,"D6s9k3"); or + Generals: + strcpy(gcd_gamename,"ccgeneralsb"); + strcpy(gcd_secret_key,"g3T9s2"); + ZeroHour: strcpy(gcd_gamename,"ccgeneralsb"); strcpy(gcd_secret_key,"whatever the key is"); ...but this is more secure: @@ -1290,10 +1302,18 @@ void PeerThreadClass::Thread_Function() secretKey[0]='g';secretKey[1]='3';secretKey[2]='T';secretKey[3]='9'; secretKey[4]='s';secretKey[5]='2';secretKey[6]='\0'; /**/ +#if RTS_GENERALS + gameName[0]='c';gameName[1]='c';gameName[2]='g';gameName[3]='e'; + gameName[4]='n';gameName[5]='e';gameName[6]='r';gameName[7]='a'; + gameName[8]='l';gameName[9]='s';gameName[10]='\0'; + secretKey[0]='h';secretKey[1]='5';secretKey[2]='T';secretKey[3]='2'; + secretKey[4]='f';secretKey[5]='6';secretKey[6]='\0'; +#elif RTS_ZEROHOUR gameName[0]='c';gameName[1]='c';gameName[2]='g';gameName[3]='e'; gameName[4]='n';gameName[5]='z';gameName[6]='h';gameName[7]='\0'; secretKey[0]='D';secretKey[1]='6';secretKey[2]='s';secretKey[3]='9'; secretKey[4]='k';secretKey[5]='3';secretKey[6]='\0'; +#endif /**/ // Set the title. @@ -1643,7 +1663,7 @@ void PeerThreadClass::Thread_Function() m_playerFactions[i] = 0; m_playerColors[i] = 0; } - if (incomingRequest.password.length() > 0) + if (!incomingRequest.password.empty()) m_hasPassword = true; else m_hasPassword = false; @@ -1694,7 +1714,7 @@ void PeerThreadClass::Thread_Function() case PeerRequest::PEERREQUEST_UTMPLAYER: { - if (incomingRequest.nick.length() > 0) + if (!incomingRequest.nick.empty()) { peerUTMPlayer( peer, incomingRequest.nick.c_str(), incomingRequest.id.c_str(), incomingRequest.options.c_str(), PEERFalse ); } @@ -1822,7 +1842,7 @@ void PeerThreadClass::handleQMMatch(PEER peer, Int mapIndex, Int seed, Int i=0; for (; iaddResponse(resp); -// PeerThreadClass *t = (PeerThreadClass *)param; -// DEBUG_ASSERTCRASH(t, ("No Peer thread!")); if (t->getQMStatus() != QM_IDLE && t->getQMStatus() != QM_STOPPED) { - if (!stricmp(t->getQMBotName().c_str(), nick)) + if (stricmp(t->getQMBotName().c_str(), nick) == 0) { // matchbot left - bail PeerResponse resp; @@ -2826,7 +2844,11 @@ static void listingGamesCallback(PEER peer, PEERBool success, const char * name, { DEBUG_LOG(("Game name is '%s'", name)); const char *newname = SBServerGetStringValue(server, "gamename", (char *)name); - if (strcmp(newname, "ccgenzh")) +#if RTS_GENERALS + if (strcmp(newname, "ccgenerals") != 0) +#elif RTS_ZEROHOUR + if (strcmp(newname, "ccgenzh") != 0) +#endif name = newname; DEBUG_LOG(("Game name is now '%s'", name)); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp similarity index 97% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp rename to Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp index 412f1548c2..959004fc32 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp @@ -29,7 +29,7 @@ // the game. // Author: Matthew D. Campbell, July 2002 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/UserPreferences.h" #include "Common/PlayerTemplate.h" @@ -102,12 +102,12 @@ static void debugDumpPlayerStats( const PSPlayerStats& stats ) DEBUG_LOG(("gamesAsRandom: %d", stats.gamesAsRandom)); } - if (stats.options.length()) + if (!stats.options.empty()) { DEBUG_LOG(("Options: %s", stats.options.c_str())); } - if (stats.systemSpec.length()) + if (!stats.systemSpec.empty()) { DEBUG_LOG(("systemSpec: %s", stats.systemSpec.c_str())); } @@ -184,7 +184,7 @@ static void debugDumpPlayerStats( const PSPlayerStats& stats ) DEBUG_LOG(("lastLadderPort: %d", stats.lastLadderPort)); } - if (stats.lastLadderHost.length()) + if (!stats.lastLadderHost.empty()) { DEBUG_LOG(("lastLadderHost: %s", stats.lastLadderHost.c_str())); } @@ -246,12 +246,12 @@ void PSPlayerStats::incorporate( const PSPlayerStats& other ) gamesAsRandom = other.gamesAsRandom; } - if (other.options.length()) + if (!other.options.empty()) { options = other.options; } - if (other.systemSpec.length()) + if (!other.systemSpec.empty()) { systemSpec = other.systemSpec; } @@ -325,7 +325,7 @@ void PSPlayerStats::incorporate( const PSPlayerStats& other ) { lastLadderPort = other.lastLadderPort; } - if (other.lastLadderHost.length()) + if (!other.lastLadderHost.empty()) { lastLadderHost = other.lastLadderHost; } @@ -481,8 +481,7 @@ void GameSpyPSMessageQueue::startThread( void ) void GameSpyPSMessageQueue::endThread( void ) { - if (m_thread) - delete m_thread; + delete m_thread; m_thread = NULL; } @@ -810,9 +809,17 @@ void PSThreadClass::Thread_Function() /********* First step, set our game authentication info We could do: + Generals: + strcpy(gcd_gamename,"ccgenerals"); + strcpy(gcd_secret_key,"h5T2f6"); + ZeroHour: strcpy(gcd_gamename,"ccgenzh"); strcpy(gcd_secret_key,"D6s9k3"); or + Generals: + strcpy(gcd_gamename,"ccgeneralsb"); + strcpy(gcd_secret_key,"g3T9s2"); + ZeroHour: strcpy(gcd_gamename,"ccgeneralsb"); strcpy(gcd_secret_key,"whatever the key is"); ...but this is more secure: @@ -824,10 +831,18 @@ void PSThreadClass::Thread_Function() gcd_secret_key[0]='g';gcd_secret_key[1]='3';gcd_secret_key[2]='T';gcd_secret_key[3]='9'; gcd_secret_key[4]='s';gcd_secret_key[5]='2';gcd_secret_key[6]='\0'; /**/ +#if RTS_GENERALS + gcd_gamename[0]='c';gcd_gamename[1]='c';gcd_gamename[2]='g';gcd_gamename[3]='e'; + gcd_gamename[4]='n';gcd_gamename[5]='e';gcd_gamename[6]='r';gcd_gamename[7]='a'; + gcd_gamename[8]='l';gcd_gamename[9]='s';gcd_gamename[10]='\0'; + gcd_secret_key[0]='h';gcd_secret_key[1]='5';gcd_secret_key[2]='T';gcd_secret_key[3]='2'; + gcd_secret_key[4]='f';gcd_secret_key[5]='6';gcd_secret_key[6]='\0'; +#elif RTS_ZEROHOUR gcd_gamename[0]='c';gcd_gamename[1]='c';gcd_gamename[2]='g';gcd_gamename[3]='e'; gcd_gamename[4]='n';gcd_gamename[5]='z';gcd_gamename[6]='h';gcd_gamename[7]='\0'; gcd_secret_key[0]='D';gcd_secret_key[1]='6';gcd_secret_key[2]='s';gcd_secret_key[3]='9'; gcd_secret_key[4]='k';gcd_secret_key[5]='3';gcd_secret_key[6]='\0'; +#endif /**/ //strcpy(StatsServerHostname, "sdkdev.gamespy.com"); @@ -956,7 +971,7 @@ void PSThreadClass::Thread_Function() addedInDesyncs4 + req.addDesync, addedInDiscons4 + req.addDiscon)); } pref.write(); - if (req.password.size() == 0) + if (req.password.empty()) return; } if (!req.player.id) @@ -1092,11 +1107,8 @@ void PSPlayerStats::reset( void ) desyncsInARow = 0; maxDesyncsInARow = 0; lastLadderPort = 0; - - //Added By Sadullah Nader maxQMwinsInARow = 0; QMwinsInARow = 0; - // } //------------------------------------------------------------------------- @@ -1303,7 +1315,7 @@ PSPlayerStats GameSpyPSMessageQueueInterface::parsePlayerKVPairs( std::string kv std::string GameSpyPSMessageQueueInterface::formatPlayerKVPairs( PSPlayerStats stats ) { char kvbuf[256]; - std::string s = ""; + std::string s; PerGeneralMap::iterator it; ITERATE_OVER(wins); @@ -1358,13 +1370,13 @@ std::string GameSpyPSMessageQueueInterface::formatPlayerKVPairs( PSPlayerStats s s.append(kvbuf); } - if (stats.options.length()) + if (!stats.options.empty()) { snprintf(kvbuf, 256, "\\options\\%s", stats.options.c_str()); s.append(kvbuf); } - if (stats.systemSpec.length()) + if (!stats.systemSpec.empty()) { snprintf(kvbuf, 256, "\\systemSpec\\%s", stats.systemSpec.c_str()); s.append(kvbuf); @@ -1460,7 +1472,7 @@ std::string GameSpyPSMessageQueueInterface::formatPlayerKVPairs( PSPlayerStats s sprintf(kvbuf, "\\ladderPort\\%d", stats.lastLadderPort); s.append(kvbuf); } - if (stats.lastLadderHost.length()) + if (!stats.lastLadderHost.empty()) { snprintf(kvbuf, 256, "\\ladderHost\\%s", stats.lastLadderHost.c_str()); s.append(kvbuf); diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PingThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PingThread.cpp similarity index 98% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PingThread.cpp rename to Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PingThread.cpp index 3cf5d38447..a4e3630150 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/GameSpy/Thread/PingThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PingThread.cpp @@ -26,7 +26,7 @@ // Ping thread // Author: Matthew D. Campbell, August 2002 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include // This one has to be here. Prevents collisions with windsock2.h @@ -130,11 +130,8 @@ void Pinger::endThreads( void ) { for (Int i=0; iaddAudioEvent( &buttonClick ); - } // end if + } } if (overlayLayouts[overlay]) { diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/IPEnumeration.cpp b/Core/GameEngine/Source/GameNetwork/IPEnumeration.cpp similarity index 97% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/IPEnumeration.cpp rename to Core/GameEngine/Source/GameNetwork/IPEnumeration.cpp index ed257c37fb..9336b82064 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/IPEnumeration.cpp +++ b/Core/GameEngine/Source/GameNetwork/IPEnumeration.cpp @@ -22,7 +22,7 @@ // // //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/IPEnumeration.h" #include "GameNetwork/networkutil.h" @@ -172,12 +172,12 @@ AsciiString IPEnumeration::getMachineName( void ) int err = WSAStartup(verReq, &wsadata); if (err != 0) { - return NULL; + return ""; } if ((LOBYTE(wsadata.wVersion) != 2) || (HIBYTE(wsadata.wVersion) !=2)) { WSACleanup(); - return NULL; + return ""; } m_isWinsockInitialized = true; } @@ -187,7 +187,7 @@ AsciiString IPEnumeration::getMachineName( void ) if (gethostname(hostname, sizeof(hostname))) { DEBUG_LOG(("Failed call to gethostname; WSAGetLastError returned %d", WSAGetLastError())); - return NULL; + return ""; } return AsciiString(hostname); diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPI.cpp b/Core/GameEngine/Source/GameNetwork/LANAPI.cpp similarity index 87% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPI.cpp rename to Core/GameEngine/Source/GameNetwork/LANAPI.cpp index c0013fade9..86db49cbc7 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPI.cpp +++ b/Core/GameEngine/Source/GameNetwork/LANAPI.cpp @@ -22,7 +22,7 @@ // // //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #define WIN32_LEAN_AND_MEAN // only bare bones windows stuff wanted @@ -92,8 +92,7 @@ LANAPI::LANAPI( void ) : m_transport(NULL) LANAPI::~LANAPI( void ) { reset(); - if (m_transport) - delete m_transport; + delete m_transport; } void LANAPI::init( void ) @@ -113,21 +112,29 @@ void LANAPI::init( void ) m_lastGameopt = ""; - unsigned long bufSize = UNLEN + 1; +#if TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY char userName[UNLEN + 1]; - if (!GetUserName(userName, &bufSize)) + DWORD bufSize = ARRAY_SIZE(userName); + if (GetUserNameA(userName, &bufSize)) { - strcpy(userName, "unknown"); + m_userName.set(userName, bufSize - 1); + } + else + { + m_userName = "unknown"; } - m_userName = userName; - bufSize = MAX_COMPUTERNAME_LENGTH + 1; char computerName[MAX_COMPUTERNAME_LENGTH + 1]; - if (!GetComputerName(computerName, &bufSize)) + bufSize = ARRAY_SIZE(computerName); + if (GetComputerNameA(computerName, &bufSize)) + { + m_hostName.set(computerName, bufSize - 1); + } + else { - strcpy(computerName, "unknown"); + m_hostName = "unknown"; } - m_hostName = computerName; +#endif } void LANAPI::reset( void ) @@ -136,7 +143,7 @@ void LANAPI::reset( void ) { LANMessage msg; fillInLANMessage( &msg ); - msg.LANMessageType = LANMessage::MSG_REQUEST_LOBBY_LEAVE; + msg.messageType = LANMessage::MSG_REQUEST_LOBBY_LEAVE; sendMessage(&msg); } m_transport->update(); @@ -301,7 +308,7 @@ void LANAPI::checkMOTD( void ) UnicodeString uniLine; uniLine.translate(line); - OnChat( UnicodeString(L"MOTD"), 0, uniLine, LANCHAT_SYSTEM ); + OnChat( L"MOTD", 0, uniLine, LANCHAT_SYSTEM ); } } } @@ -348,9 +355,9 @@ void LANAPI::update( void ) } LANMessage *msg = (LANMessage *)(m_transport->m_inBuffer[i].data); - //DEBUG_LOG(("LAN message type %s from %ls (%s@%s)", GetMessageTypeString(msg->LANMessageType).str(), + //DEBUG_LOG(("LAN message type %s from %ls (%s@%s)", GetMessageTypeString(msg->messageType).str(), // msg->name, msg->userName, msg->hostName)); - switch (msg->LANMessageType) + switch (msg->messageType) { // Location specification case LANMessage::MSG_REQUEST_LOCATIONS: // Hey, where is everybody? @@ -419,13 +426,13 @@ void LANAPI::update( void ) break; default: - DEBUG_LOG(("Unknown LAN message type %d", msg->LANMessageType)); + DEBUG_LOG(("Unknown LAN message type %d", msg->messageType)); } // Mark it as read m_transport->m_inBuffer[i].length = 0; } - } // End message handling + } if(LANbuttonPushed) return; // Send out periodic I'm Here messages @@ -446,11 +453,13 @@ void LANAPI::update( void ) } else { +#if TELL_COMPUTER_IDENTITY_IN_LAN_LOBBY AsciiString text; text.format("User=%s", m_userName.str()); RequestGameOptions( text, true ); text.format("Host=%s", m_hostName.str()); RequestGameOptions( text, true ); +#endif RequestGameOptions( "HELLO", false ); } } @@ -509,9 +518,8 @@ void LANAPI::update( void ) // Actually, fake a host leaving message. :) LANMessage msg; fillInLANMessage( &msg ); - msg.LANMessageType = LANMessage::MSG_REQUEST_GAME_LEAVE; - wcsncpy(msg.name, m_currentGame->getPlayerName(0).str(), g_lanPlayerNameLength); - msg.name[g_lanPlayerNameLength] = 0; + msg.messageType = LANMessage::MSG_REQUEST_GAME_LEAVE; + wcslcpy(msg.name, m_currentGame->getPlayerName(0).str(), ARRAY_SIZE(msg.name)); handleRequestGameLeave(&msg, m_currentGame->getIP(0)); UnicodeString text; text = TheGameText->fetch("LAN:HostNotResponding"); @@ -528,9 +536,8 @@ void LANAPI::update( void ) fillInLANMessage( &msg ); UnicodeString theStr; theStr.format(TheGameText->fetch("LAN:PlayerDropped"), m_currentGame->getPlayerName(p).str()); - msg.LANMessageType = LANMessage::MSG_REQUEST_GAME_LEAVE; - wcsncpy(msg.name, m_currentGame->getPlayerName(p).str(), g_lanPlayerNameLength); - msg.name[g_lanPlayerNameLength] = 0; + msg.messageType = LANMessage::MSG_REQUEST_GAME_LEAVE; + wcslcpy(msg.name, m_currentGame->getPlayerName(p).str(), ARRAY_SIZE(msg.name)); handleRequestGameLeave(&msg, m_currentGame->getIP(p)); OnChat(UnicodeString::TheEmptyString, m_localIP, theStr, LANCHAT_SYSTEM); } @@ -605,7 +612,7 @@ void LANAPI::update( void ) void LANAPI::RequestLocations( void ) { LANMessage msg; - msg.LANMessageType = LANMessage::MSG_REQUEST_LOCATIONS; + msg.messageType = LANMessage::MSG_REQUEST_LOCATIONS; fillInLANMessage( &msg ); sendMessage(&msg); } @@ -625,16 +632,15 @@ void LANAPI::RequestGameJoin( LANGameInfo *game, UnsignedInt ip /* = 0 */ ) } LANMessage msg; - msg.LANMessageType = LANMessage::MSG_REQUEST_JOIN; + msg.messageType = LANMessage::MSG_REQUEST_JOIN; fillInLANMessage( &msg ); msg.GameToJoin.gameIP = game->getSlot(0)->getIP(); msg.GameToJoin.exeCRC = TheGlobalData->m_exeCRC; msg.GameToJoin.iniCRC = TheGlobalData->m_iniCRC; - AsciiString s = ""; + AsciiString s; GetStringFromRegistry("\\ergc", "", s); - strncpy(msg.GameToJoin.serial, s.str(), g_maxSerialLength); - msg.GameToJoin.serial[g_maxSerialLength-1] = '\0'; + strlcpy(msg.GameToJoin.serial, s.str(), ARRAY_SIZE(msg.GameToJoin.serial)); sendMessage(&msg, ip); @@ -659,11 +665,10 @@ void LANAPI::RequestGameJoinDirectConnect(UnsignedInt ipaddress) m_directConnectRemoteIP = ipaddress; LANMessage msg; - msg.LANMessageType = LANMessage::MSG_REQUEST_GAME_INFO; + msg.messageType = LANMessage::MSG_REQUEST_GAME_INFO; fillInLANMessage(&msg); msg.PlayerInfo.ip = GetLocalIP(); - wcsncpy(msg.PlayerInfo.playerName, m_name.str(), m_name.getLength()); - msg.PlayerInfo.playerName[m_name.getLength()] = 0; + wcslcpy(msg.PlayerInfo.playerName, m_name.str(), ARRAY_SIZE(msg.PlayerInfo.playerName)); sendMessage(&msg, ipaddress); @@ -674,10 +679,9 @@ void LANAPI::RequestGameJoinDirectConnect(UnsignedInt ipaddress) void LANAPI::RequestGameLeave( void ) { LANMessage msg; - msg.LANMessageType = LANMessage::MSG_REQUEST_GAME_LEAVE; + msg.messageType = LANMessage::MSG_REQUEST_GAME_LEAVE; fillInLANMessage( &msg ); - wcsncpy(msg.GameToLeave.gameName, (m_currentGame)?m_currentGame->getName().str():L"", g_lanGameNameLength); - msg.GameToLeave.gameName[g_lanGameNameLength] = 0; + wcslcpy(msg.PlayerInfo.playerName, m_name.str(), ARRAY_SIZE(msg.PlayerInfo.playerName)); sendMessage(&msg); m_transport->update(); // Send immediately, before OnPlayerLeave below resets everything. @@ -705,12 +709,11 @@ void LANAPI::RequestGameAnnounce( void ) { LANMessage reply; fillInLANMessage( &reply ); - reply.LANMessageType = LANMessage::MSG_GAME_ANNOUNCE; + reply.messageType = LANMessage::MSG_GAME_ANNOUNCE; AsciiString gameOpts = GameInfoToAsciiString(m_currentGame); - strncpy(reply.GameInfo.options,gameOpts.str(),m_lanMaxOptionsLength); - wcsncpy(reply.GameInfo.gameName, m_currentGame->getName().str(), g_lanGameNameLength); - reply.GameInfo.gameName[g_lanGameNameLength] = 0; + strlcpy(reply.GameInfo.options,gameOpts.str(), ARRAY_SIZE(reply.GameInfo.options)); + wcslcpy(reply.GameInfo.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameInfo.gameName)); reply.GameInfo.inProgress = m_currentGame->isGameInProgress(); reply.GameInfo.isDirectConnect = m_currentGame->getIsDirectConnect(); @@ -726,10 +729,9 @@ void LANAPI::RequestAccept( void ) LANMessage msg; fillInLANMessage( &msg ); - msg.LANMessageType = LANMessage::MSG_SET_ACCEPT; + msg.messageType = LANMessage::MSG_SET_ACCEPT; msg.Accept.isAccepted = true; - wcsncpy(msg.Accept.gameName, m_currentGame->getName().str(), g_lanGameNameLength); - msg.Accept.gameName[g_lanGameNameLength] = 0; + wcslcpy(msg.Accept.gameName, m_currentGame->getName().str(), ARRAY_SIZE(msg.Accept.gameName)); sendMessage(&msg); } @@ -740,10 +742,9 @@ void LANAPI::RequestHasMap( void ) LANMessage msg; fillInLANMessage( &msg ); - msg.LANMessageType = LANMessage::MSG_MAP_AVAILABILITY; + msg.messageType = LANMessage::MSG_MAP_AVAILABILITY; msg.MapStatus.hasMap = m_currentGame->getSlot(m_currentGame->getLocalSlotNum())->hasMap(); - wcsncpy(msg.MapStatus.gameName, m_currentGame->getName().str(), g_lanGameNameLength); - msg.MapStatus.gameName[g_lanGameNameLength] = 0; + wcslcpy(msg.MapStatus.gameName, m_currentGame->getName().str(), ARRAY_SIZE(msg.MapStatus.gameName)); CRC mapNameCRC; //mapNameCRC.computeCRC(m_currentGame->getMap().str(), m_currentGame->getMap().getLength()); AsciiString portableMapName = TheGameState->realMapPathToPortableMapPath(m_currentGame->getMap()); @@ -772,7 +773,7 @@ void LANAPI::RequestHasMap( void ) text.format(TheGameText->fetch("GUI:LocalPlayerNoMapWillTransfer"), mapDisplayName.str()); else text.format(TheGameText->fetch("GUI:LocalPlayerNoMap"), mapDisplayName.str()); - OnChat(UnicodeString(L"SYSTEM"), m_localIP, text, LANCHAT_SYSTEM); + OnChat(L"SYSTEM", m_localIP, text, LANCHAT_SYSTEM); } } @@ -780,12 +781,10 @@ void LANAPI::RequestChat( UnicodeString message, ChatType format ) { LANMessage msg; fillInLANMessage( &msg ); - wcsncpy(msg.Chat.gameName, (m_currentGame)?m_currentGame->getName().str():L"", g_lanGameNameLength); - msg.Chat.gameName[g_lanGameNameLength] = 0; - msg.LANMessageType = LANMessage::MSG_CHAT; + wcslcpy(msg.Chat.gameName, (m_currentGame) ? m_currentGame->getName().str() : L"", ARRAY_SIZE(msg.Chat.gameName)); + msg.messageType = LANMessage::MSG_CHAT; msg.Chat.chatType = format; - wcsncpy(msg.Chat.message, message.str(), g_lanMaxChatLength); - msg.Chat.message[g_lanMaxChatLength] = 0; + wcslcpy(msg.Chat.message, message.str(), ARRAY_SIZE(msg.Chat.message)); sendMessage(&msg); OnChat(m_name, m_localIP, message, format); @@ -797,7 +796,7 @@ void LANAPI::RequestGameStart( void ) return; LANMessage msg; - msg.LANMessageType = LANMessage::MSG_GAME_START; + msg.messageType = LANMessage::MSG_GAME_START; fillInLANMessage( &msg ); sendMessage(&msg); m_transport->update(); // force a send @@ -821,7 +820,7 @@ void LANAPI::RequestGameStartTimer( Int seconds ) m_gameStartSeconds = (seconds) ? seconds - 1 : 0; LANMessage msg; - msg.LANMessageType = LANMessage::MSG_GAME_START_TIMER; + msg.messageType = LANMessage::MSG_GAME_START_TIMER; msg.StartTimer.seconds = seconds; fillInLANMessage( &msg ); sendMessage(&msg); @@ -839,9 +838,8 @@ void LANAPI::RequestGameOptions( AsciiString gameOptions, Bool isPublic, Unsigne LANMessage msg; fillInLANMessage( &msg ); - msg.LANMessageType = LANMessage::MSG_GAME_OPTIONS; - strncpy(msg.GameOptions.options, gameOptions.str(), m_lanMaxOptionsLength); - msg.GameOptions.options[m_lanMaxOptionsLength] = 0; + msg.messageType = LANMessage::MSG_GAME_OPTIONS; + strlcpy(msg.GameOptions.options, gameOptions.str(), ARRAY_SIZE(msg.GameOptions.options)); sendMessage(&msg, ip); m_lastGameopt = gameOptions; @@ -923,7 +921,7 @@ void LANAPI::RequestGameCreate( UnicodeString gameName, Bool isDirectConnect ) /// @todo: Need to initialize the players elsewere. /* for (int player = 1; player < MAX_SLOTS; ++player) { - myGame->setPlayerName(player, UnicodeString(L"")); + myGame->setPlayerName(player, L""); myGame->setIP(player, 0); myGame->setAccepted(player, false); }*/ @@ -935,8 +933,7 @@ void LANAPI::RequestGameCreate( UnicodeString gameName, Bool isDirectConnect ) //RequestSlotList(); /* LANMessage msg; - wcsncpy(msg.name, m_name.str(), g_lanPlayerNameLength); - msg.name[g_lanPlayerNameLength] = 0; + wcslcpy(msg.name, m_name.str(), ARRAY_SIZE(msg.name)); wcscpy(msg.GameInfo.gameName, myGame->getName().str()); for (player=0; playergetIP(player); msg.GameInfo.playerAccepted[player] = myGame->getAccepted(player); } - msg.LANMessageType = LANMessage::MSG_GAME_ANNOUNCE; + msg.messageType = LANMessage::MSG_GAME_ANNOUNCE; */ OnGameCreate(LANAPIInterface::RET_OK); } @@ -1006,25 +1003,22 @@ void LANAPI::RequestSlotList( void ) { LANMessage reply; - reply.LANMessageType = LANMessage::MSG_GAME_ANNOUNCE; - wcsncpy(reply.name, m_name.str(), g_lanPlayerNameLength); - reply.name[g_lanPlayerNameLength] = 0; + reply.messageType = LANMessage::MSG_GAME_ANNOUNCE; + wcslcpy(reply.name, m_name.str(), ARRAY_SIZE(reply.name)); int player; for (player = 0; player < MAX_SLOTS; ++player) { - wcsncpy(reply.GameInfo.name[player], m_currentGame->getPlayerName(player).str(), g_lanPlayerNameLength); - reply.GameInfo.name[player][g_lanPlayerNameLength] = 0; + wcslcpy(reply.GameInfo.name[player], m_currentGame->getPlayerName(player).str(), ARRAY_SIZE(reply.GameInfo.name[player])); reply.GameInfo.ip[player] = m_currentGame->getIP(player); reply.GameInfo.playerAccepted[player] = m_currentGame->getSlot(player)->isAccepted(); } - wcsncpy(reply.GameInfo.gameName, m_currentGame->getName().str(), g_lanGameNameLength); - reply.GameInfo.gameName[g_lanGameNameLength] = 0; + wcslcpy(reply.GameInfo.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameInfo.gameName)); reply.GameInfo.inProgress = m_currentGame->isGameInProgress(); sendMessage(&reply); OnSlotList(LANAPIInterface::RET_OK, m_currentGame); -} // void LANAPI::RequestSlotList( void ) +} */ void LANAPI::RequestSetName( UnicodeString newName ) { @@ -1044,7 +1038,7 @@ void LANAPI::RequestSetName( UnicodeString newName ) m_name = newName; LANMessage msg; fillInLANMessage( &msg ); - msg.LANMessageType = LANMessage::MSG_LOBBY_ANNOUNCE; + msg.messageType = LANMessage::MSG_LOBBY_ANNOUNCE; sendMessage(&msg); // Update the interface @@ -1074,18 +1068,15 @@ void LANAPI::fillInLANMessage( LANMessage *msg ) if (!msg) return; - wcsncpy(msg->name, m_name.str(), g_lanPlayerNameLength); - msg->name[g_lanPlayerNameLength] = 0; - strncpy(msg->userName, m_userName.str(), g_lanLoginNameLength); - msg->userName[g_lanLoginNameLength] = 0; - strncpy(msg->hostName, m_hostName.str(), g_lanHostNameLength); - msg->hostName[g_lanHostNameLength] = 0; + wcslcpy(msg->name, m_name.str(), ARRAY_SIZE(msg->name)); + strlcpy(msg->userName, m_userName.str(), ARRAY_SIZE(msg->userName)); + strlcpy(msg->hostName, m_hostName.str(), ARRAY_SIZE(msg->hostName)); } void LANAPI::RequestLobbyLeave( Bool forced ) { LANMessage msg; - msg.LANMessageType = LANMessage::MSG_REQUEST_LOBBY_LEAVE; + msg.messageType = LANMessage::MSG_REQUEST_LOBBY_LEAVE; fillInLANMessage( &msg ); sendMessage(&msg); @@ -1282,7 +1273,7 @@ void LANAPI::setIsActive(Bool isActive) { if ((m_inLobby == FALSE) && (m_currentGame != NULL)) { LANMessage msg; fillInLANMessage( &msg ); - msg.LANMessageType = LANMessage::MSG_INACTIVE; + msg.messageType = LANMessage::MSG_INACTIVE; sendMessage(&msg); DEBUG_LOG(("LANAPI::setIsActive - sent an IsActive message")); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp b/Core/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp similarity index 95% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp rename to Core/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp index 647c00ec83..ee3c87e3bf 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp +++ b/Core/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp @@ -27,7 +27,7 @@ // Author: Chris Huybregts, October 2001 // Description: LAN API Callbacks /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "strtok_r.h" #include "Common/GameEngine.h" @@ -109,14 +109,14 @@ void LANAPI::OnAccept( UnsignedInt playerIP, Bool status ) else m_currentGame->getLANSlot(i)->unAccept(); break; - }// if - }// for + } + } if (i != MAX_SLOTS ) { RequestGameOptions( GenerateGameOptionsString(), false ); lanUpdateSlotList(); } - }//if + } else { //i'm not the host but if the accept came from the host... @@ -124,10 +124,10 @@ void LANAPI::OnAccept( UnsignedInt playerIP, Bool status ) { UnicodeString text; text = TheGameText->fetch("GUI:HostWantsToStart"); - OnChat(UnicodeString(L"SYSTEM"), m_localIP, text, LANCHAT_SYSTEM); + OnChat(L"SYSTEM", m_localIP, text, LANCHAT_SYSTEM); } } -}// void LANAPI::OnAccept( UnicodeString player, Bool status ) +} void LANAPI::OnHasMap( UnsignedInt playerIP, Bool status ) { @@ -140,8 +140,8 @@ void LANAPI::OnHasMap( UnsignedInt playerIP, Bool status ) { m_currentGame->getLANSlot(i)->setMapAvailability( status ); break; - }// if - }// for + } + } if (i != MAX_SLOTS ) { UnicodeString mapDisplayName; @@ -165,12 +165,12 @@ void LANAPI::OnHasMap( UnsignedInt playerIP, Bool status ) text.format(TheGameText->fetch("GUI:PlayerNoMapWillTransfer"), m_currentGame->getLANSlot(i)->getName().str(), mapDisplayName.str()); else text.format(TheGameText->fetch("GUI:PlayerNoMap"), m_currentGame->getLANSlot(i)->getName().str(), mapDisplayName.str()); - OnChat(UnicodeString(L"SYSTEM"), m_localIP, text, LANCHAT_SYSTEM); + OnChat(L"SYSTEM", m_localIP, text, LANCHAT_SYSTEM); } lanUpdateSlotList(); } - }//if -}// void LANAPI::OnHasMap( UnicodeString player, Bool status ) + } +} void LANAPI::OnGameStartTimer( Int seconds ) { @@ -179,7 +179,7 @@ void LANAPI::OnGameStartTimer( Int seconds ) text.format(TheGameText->fetch("LAN:GameStartTimerSingular"), seconds); else text.format(TheGameText->fetch("LAN:GameStartTimerPlural"), seconds); - OnChat(UnicodeString(L"SYSTEM"), m_localIP, text, LANCHAT_SYSTEM); + OnChat(L"SYSTEM", m_localIP, text, LANCHAT_SYSTEM); } void LANAPI::OnGameStart( void ) @@ -210,10 +210,8 @@ void LANAPI::OnGameStart( void ) // Set up the game network DEBUG_ASSERTCRASH(TheNetwork == NULL, ("For some reason TheNetwork isn't NULL at the start of this game. Better look into that.")); - if (TheNetwork != NULL) { - delete TheNetwork; - TheNetwork = NULL; - } + delete TheNetwork; + TheNetwork = NULL; // Time to initialize TheNetwork for this game. TheNetwork = NetworkInterface::createNetwork(); @@ -237,10 +235,10 @@ void LANAPI::OnGameStart( void ) removeGame(m_currentGame); m_currentGame = NULL; m_inLobby = TRUE; - if (TheNetwork != NULL) { - delete TheNetwork; - TheNetwork = NULL; - } + + delete TheNetwork; + TheNetwork = NULL; + OnChat(UnicodeString::TheEmptyString, 0, TheGameText->fetch("GUI:CouldNotTransferMap"), LANCHAT_SYSTEM); return; } @@ -508,7 +506,7 @@ void LANAPI::OnGameJoin( ReturnType ret, LANGameInfo *theGame ) if (ret == RET_OK) { LANbuttonPushed = true; - TheShell->push( AsciiString("Menus/LanGameOptionsMenu.wnd") ); + TheShell->push( "Menus/LanGameOptionsMenu.wnd" ); //lanUpdateSlotList(); LANPreferences pref; @@ -591,7 +589,7 @@ void LANAPI::OnGameList( LANGameInfo *gameList ) { LANDisplayGameList(listboxGames, gameList); } -}//void LANAPI::OnGameList( LANGameInfo *gameList ) +} void LANAPI::OnGameCreate( ReturnType ret ) { @@ -599,7 +597,7 @@ void LANAPI::OnGameCreate( ReturnType ret ) { LANbuttonPushed = true; - TheShell->push( AsciiString("Menus/LanGameOptionsMenu.wnd") ); + TheShell->push( "Menus/LanGameOptionsMenu.wnd" ); RequestLobbyLeave( false ); //RequestGameAnnounce( ); // can't do this here, since we don't have a map set @@ -622,7 +620,7 @@ void LANAPI::OnGameCreate( ReturnType ret ) } } -}//void OnGameCreate( ReturnType ret ) +} void LANAPI::OnPlayerList( LANPlayer *playerList ) { @@ -688,9 +686,7 @@ void LANAPI::OnChat( UnicodeString player, UnsignedInt ip, UnicodeString message switch (format) { case LANAPIInterface::LANCHAT_SYSTEM: - unicodeChat = L""; - unicodeChat.concat(message); - unicodeChat.concat(L""); + unicodeChat = message; index =GadgetListBoxAddEntryText(chatWindow, unicodeChat, chatSystemColor, -1, -1); break; case LANAPIInterface::LANCHAT_EMOTE: diff --git a/Generals/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp b/Core/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp similarity index 78% rename from Generals/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp rename to Core/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp index f2a437f10b..d6dbba0823 100644 --- a/Generals/Code/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp +++ b/Core/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp @@ -1,5 +1,5 @@ /* -** Command & Conquer Generals(tm) +** Command & Conquer Generals Zero Hour(tm) ** Copyright 2025 Electronic Arts Inc. ** ** This program is free software: you can redistribute it and/or modify @@ -28,7 +28,7 @@ // Description: LAN callback handlers /////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/crc.h" #include "Common/GameState.h" @@ -46,7 +46,7 @@ void LANAPI::handleRequestLocations( LANMessage *msg, UnsignedInt senderIP ) { LANMessage reply; fillInLANMessage( &reply ); - reply.LANMessageType = LANMessage::MSG_LOBBY_ANNOUNCE; + reply.messageType = LANMessage::MSG_LOBBY_ANNOUNCE; sendMessage(&reply); m_lastResendTime = timeGetTime(); @@ -60,12 +60,12 @@ void LANAPI::handleRequestLocations( LANMessage *msg, UnsignedInt senderIP ) { LANMessage reply; fillInLANMessage( &reply ); - reply.LANMessageType = LANMessage::MSG_GAME_ANNOUNCE; + reply.messageType = LANMessage::MSG_GAME_ANNOUNCE; AsciiString gameOpts = GenerateGameOptionsString(); - strncpy(reply.GameInfo.options,gameOpts.str(),m_lanMaxOptionsLength); - wcsncpy(reply.GameInfo.gameName, m_currentGame->getName().str(), g_lanGameNameLength); - reply.GameInfo.gameName[g_lanGameNameLength] = 0; + strlcpy(reply.GameInfo.options, gameOpts.str(), ARRAY_SIZE(reply.GameInfo.options)); + wcslcpy(reply.GameInfo.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameInfo.gameName)); reply.GameInfo.inProgress = m_currentGame->isGameInProgress(); + reply.GameInfo.isDirectConnect = m_currentGame->getIsDirectConnect(); sendMessage(&reply); } @@ -127,7 +127,6 @@ void LANAPI::handleGameAnnounce( LANMessage *msg, UnsignedInt senderIP ) // remove from list removeGame(game); delete game; - game = NULL; return; } RequestGameJoin(game, m_directConnectRemoteIP); @@ -191,12 +190,11 @@ void LANAPI::handleRequestGameInfo( LANMessage *msg, UnsignedInt senderIP ) { LANMessage reply; fillInLANMessage( &reply ); - reply.LANMessageType = LANMessage::MSG_GAME_ANNOUNCE; + reply.messageType = LANMessage::MSG_GAME_ANNOUNCE; AsciiString gameOpts = GameInfoToAsciiString(m_currentGame); - strncpy(reply.GameInfo.options,gameOpts.str(),m_lanMaxOptionsLength); - wcsncpy(reply.GameInfo.gameName, m_currentGame->getName().str(), g_lanGameNameLength); - reply.GameInfo.gameName[g_lanGameNameLength] = 0; + strlcpy(reply.GameInfo.options,gameOpts.str(), ARRAY_SIZE(reply.GameInfo.options)); + wcslcpy(reply.GameInfo.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameInfo.gameName)); reply.GameInfo.inProgress = m_currentGame->isGameInProgress(); reply.GameInfo.isDirectConnect = m_currentGame->getIsDirectConnect(); @@ -205,6 +203,51 @@ void LANAPI::handleRequestGameInfo( LANMessage *msg, UnsignedInt senderIP ) } } +static Bool IsInvalidCharForPlayerName(const WideChar c) +{ + return c < L' ' // C0 control chars + || c == L',' || c == L':' || c == L';' // chars used for strtok in ParseAsciiStringToGameInfo + || (c >= L'\x007f' && c <= L'\x009f') // DEL + C1 control chars + || c == L'\x2028' || c == L'\x2029' // line and paragraph separators + || (c >= L'\xdc00' && c <= L'\xdfff') // low surrogate, for chars beyond the Unicode Basic Multilingual Plane + || (c >= L'\xd800' && c <= L'\xdbff'); // high surrogate, for chars beyond the BMP +} + +static Bool IsSpaceCharacter(const WideChar c) +{ + return c == L' ' // space + || c == L'\xA0' // no-break space + || c == L'\x1680' // ogham space mark + || (c >= L'\x2000' && c <= L'\x200A') // en/em spaces, figure, punctuation, thin, hair + || c == L'\x202F' // narrow no-break space + || c == L'\x205F' // medium mathematical space + || c == L'\x3000'; // ideographic space +} + +static Bool ContainsInvalidChars(const WideChar* playerName) +{ + DEBUG_ASSERTCRASH(playerName != NULL, ("playerName is NULL")); + while (*playerName) + { + if (IsInvalidCharForPlayerName(*playerName++)) + return true; + } + + return false; +} + +static Bool ContainsAnyReadableChars(const WideChar* playerName) +{ + DEBUG_ASSERTCRASH(playerName != NULL, ("playerName is NULL")); + while (*playerName) + { + if (!IsSpaceCharacter(*playerName++)) + return true; + } + + return false; +} + void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP ) { UnsignedInt responseIP = senderIP; // need this cause the player may or may not be @@ -220,7 +263,7 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP ) { if (m_currentGame->isGameInProgress()) { - reply.LANMessageType = LANMessage::MSG_JOIN_DENY; + reply.messageType = LANMessage::MSG_JOIN_DENY; reply.GameNotJoined.reason = LANAPIInterface::RET_GAME_STARTED; reply.GameNotJoined.gameIP = m_localIP; reply.GameNotJoined.playerIP = senderIP; @@ -235,18 +278,21 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP ) #if defined(RTS_DEBUG) if (TheGlobalData->m_netMinPlayers > 0) { #endif +// TheSuperHackers @todo Enable CRC checks! +#if !RTS_ZEROHOUR if (msg->GameToJoin.iniCRC != TheGlobalData->m_iniCRC || msg->GameToJoin.exeCRC != TheGlobalData->m_exeCRC) { DEBUG_LOG(("LANAPI::handleRequestJoin - join denied because of CRC mismatch. CRCs are them/us INI:%X/%X exe:%X/%X", msg->GameToJoin.iniCRC, TheGlobalData->m_iniCRC, msg->GameToJoin.exeCRC, TheGlobalData->m_exeCRC)); - reply.LANMessageType = LANMessage::MSG_JOIN_DENY; + reply.messageType = LANMessage::MSG_JOIN_DENY; reply.GameNotJoined.reason = LANAPIInterface::RET_CRC_MISMATCH; reply.GameNotJoined.gameIP = m_localIP; reply.GameNotJoined.playerIP = senderIP; canJoin = false; } +#endif #if defined(RTS_DEBUG) } #endif @@ -277,7 +323,7 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP ) if (!strncmp(s.str(), msg->GameToJoin.serial, g_maxSerialLength)) { // serials match! kick the punk! - reply.LANMessageType = LANMessage::MSG_JOIN_DENY; + reply.messageType = LANMessage::MSG_JOIN_DENY; reply.GameNotJoined.reason = LANAPIInterface::RET_SERIAL_DUPE; reply.GameNotJoined.gameIP = m_localIP; reply.GameNotJoined.playerIP = senderIP; @@ -290,14 +336,32 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP ) } #endif - // We're the host, so see if he has a duplicate name + // TheSuperHackers @bugfix slurmlord 18/09/2025 need to validate the name of the connecting player before + // allowing them to join to prevent messing up the format of game state string. Commas, colons, semicolons etc. + // should not be in a player name. It should also not consist of only space characters. + if (canJoin) + { + if (ContainsInvalidChars(msg->name) || !ContainsAnyReadableChars(msg->name)) + { + // Just deny with a duplicate name reason, for backwards compatibility with retail + reply.messageType = LANMessage::MSG_JOIN_DENY; + reply.GameNotJoined.reason = LANAPIInterface::RET_DUPLICATE_NAME; + reply.GameNotJoined.gameIP = m_localIP; + reply.GameNotJoined.playerIP = senderIP; + canJoin = false; + + DEBUG_LOG(("LANAPI::handleRequestJoin - join denied because of illegal characters in the player name.")); + } + } + + // Then see if the player has a duplicate name for (player = 0; canJoin && playergetLANSlot(player); if (slot->isHuman() && slot->getName().compare(msg->name) == 0) { // just deny duplicates - reply.LANMessageType = LANMessage::MSG_JOIN_DENY; + reply.messageType = LANMessage::MSG_JOIN_DENY; reply.GameNotJoined.reason = LANAPIInterface::RET_DUPLICATE_NAME; reply.GameNotJoined.gameIP = m_localIP; reply.GameNotJoined.playerIP = senderIP; @@ -308,60 +372,38 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP ) } } - // See if there's room - // First get the number of players currently in the room. - Int numPlayers = 0; - for (player = 0; player < MAX_SLOTS; ++player) - { - if (m_currentGame->getLANSlot(player)->isOccupied() - && !(m_currentGame->getLANSlot(player)->getPlayerTemplate() == PLAYERTEMPLATE_OBSERVER)) - { - ++numPlayers; - } - } - - // now get the number of starting spots on the map. - Int numStartingSpots = MAX_SLOTS; - const MapMetaData *md = TheMapCache->findMap(m_currentGame->getMap()); - if (md != NULL) + // TheSuperHackers @bugfix Stubbjax 26/09/2025 Players can now join open slots regardless of starting spots on the map. + for (player = 0; canJoin && playerm_numPlayers; - } - - if (numPlayers < numStartingSpots) { - for (player = 0; canJoin && playergetLANSlot(player)->isOpen()) { - if (m_currentGame->getLANSlot(player)->isOpen()) - { - // OK, add him in. - reply.LANMessageType = LANMessage::MSG_JOIN_ACCEPT; - wcsncpy(reply.GameJoined.gameName, m_currentGame->getName().str(), g_lanGameNameLength); - reply.GameJoined.gameName[g_lanGameNameLength] = 0; - reply.GameJoined.slotPosition = player; - reply.GameJoined.gameIP = m_localIP; - reply.GameJoined.playerIP = senderIP; - - LANGameSlot newSlot; - newSlot.setState(SLOT_PLAYER, UnicodeString(msg->name)); - newSlot.setIP(senderIP); - newSlot.setPort(NETWORK_BASE_PORT_NUMBER); - newSlot.setLastHeard(timeGetTime()); - newSlot.setSerial(msg->GameToJoin.serial); - m_currentGame->setSlot(player,newSlot); - DEBUG_LOG(("LANAPI::handleRequestJoin - added player %ls at ip 0x%08x to the game", msg->name, senderIP)); - - OnPlayerJoin(player, UnicodeString(msg->name)); - responseIP = 0; + // OK, add him in. + reply.messageType = LANMessage::MSG_JOIN_ACCEPT; + wcslcpy(reply.GameJoined.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameJoined.gameName)); + reply.GameJoined.slotPosition = player; + reply.GameJoined.gameIP = m_localIP; + reply.GameJoined.playerIP = senderIP; + + LANGameSlot newSlot; + newSlot.setState(SLOT_PLAYER, UnicodeString(msg->name)); + newSlot.setIP(senderIP); + newSlot.setPort(NETWORK_BASE_PORT_NUMBER); + newSlot.setLastHeard(timeGetTime()); + newSlot.setSerial(msg->GameToJoin.serial); + m_currentGame->setSlot(player,newSlot); + DEBUG_LOG(("LANAPI::handleRequestJoin - added player %ls at ip 0x%08x to the game", msg->name, senderIP)); + + OnPlayerJoin(player, UnicodeString(msg->name)); + responseIP = 0; - break; - } + break; } } + if (canJoin && player == MAX_SLOTS) { - reply.LANMessageType = LANMessage::MSG_JOIN_DENY; - wcsncpy(reply.GameNotJoined.gameName, m_currentGame->getName().str(), g_lanGameNameLength); - reply.GameNotJoined.gameName[g_lanGameNameLength] = 0; + reply.messageType = LANMessage::MSG_JOIN_DENY; + wcslcpy(reply.GameNotJoined.gameName, m_currentGame->getName().str(), ARRAY_SIZE(reply.GameNotJoined.gameName)); reply.GameNotJoined.reason = LANAPIInterface::RET_GAME_FULL; reply.GameNotJoined.gameIP = m_localIP; reply.GameNotJoined.playerIP = senderIP; @@ -371,7 +413,7 @@ void LANAPI::handleRequestJoin( LANMessage *msg, UnsignedInt senderIP ) } else { - reply.LANMessageType = LANMessage::MSG_JOIN_DENY; + reply.messageType = LANMessage::MSG_JOIN_DENY; reply.GameNotJoined.reason = LANAPIInterface::RET_GAME_GONE; reply.GameNotJoined.gameIP = m_localIP; reply.GameNotJoined.playerIP = senderIP; diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANGameInfo.cpp b/Core/GameEngine/Source/GameNetwork/LANGameInfo.cpp similarity index 98% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/LANGameInfo.cpp rename to Core/GameEngine/Source/GameNetwork/LANGameInfo.cpp index ec8eb4ffbd..a34b6ea0e7 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/LANGameInfo.cpp +++ b/Core/GameEngine/Source/GameNetwork/LANGameInfo.cpp @@ -26,7 +26,7 @@ // LAN game setup state info // Author: Matthew D. Campbell, December 2001 -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameClient/GameInfoWindow.h" #include "GameClient/GameText.h" @@ -88,10 +88,9 @@ Bool LANGameSlot::isLocalPlayer( void ) const LANGameInfo::LANGameInfo() { - //Added By Sadullah Nader - //Initializtions missing and needed m_lastHeard = 0; m_next = NULL; + m_isDirectConnect = false; // for (Int i = 0; i< MAX_SLOTS; ++i) setSlotPointer(i, &m_LANSlot[i]); @@ -216,7 +215,6 @@ void LANDisplayGameList( GameWindow *gameListbox, LANGameInfo *gameList ) while (gameList) { UnicodeString txtGName; - txtGName = L""; if( gameList->isGameInProgress() ) { txtGName.concat(L"["); diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NAT.cpp b/Core/GameEngine/Source/GameNetwork/NAT.cpp similarity index 97% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/NAT.cpp rename to Core/GameEngine/Source/GameNetwork/NAT.cpp index 3e3eed5219..03e5855675 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NAT.cpp +++ b/Core/GameEngine/Source/GameNetwork/NAT.cpp @@ -29,7 +29,7 @@ // Desc: Resolves NAT'd IPs and port numbers for the other players in a game. /////////////////////////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/NAT.h" #include "GameNetwork/Transport.h" @@ -144,8 +144,6 @@ NAT *TheNAT = NULL; NAT::NAT() { - //Added By Sadullah Nader - //Initializations inserted m_beenProbed = FALSE; m_connectionPairIndex = 0; m_connectionRound = 0; @@ -161,11 +159,9 @@ NAT::NAT() m_spareSocketPort = 0; m_startingPortNumber = 0; m_targetNodeNumber = 0; - // m_transport = NULL; m_slotList = NULL; m_roundTimeout = 0; - m_maxNumRetriesAllowed = 10; m_packetID = 0x7f00; } @@ -214,10 +210,9 @@ NATStateType NAT::update() { { m_NATState = NATSTATE_DONE; TheEstablishConnectionsMenu->endMenu(); - if (TheFirewallHelper != NULL) { - delete TheFirewallHelper; - TheFirewallHelper = NULL; - } + + delete TheFirewallHelper; + TheFirewallHelper = NULL; } } else if (m_NATState == NATSTATE_DOCONNECTIONPATHS) { if (allConnectionsDoneThisRound() == TRUE) { @@ -241,10 +236,9 @@ NATStateType NAT::update() { /* m_NATState = NATSTATE_DONE; TheEstablishConnectionsMenu->endMenu(); - if (TheFirewallHelper != NULL) { - delete TheFirewallHelper; - TheFirewallHelper = NULL; - } + + delete TheFirewallHelper; + TheFirewallHelper = NULL; */ } else { doThisConnectionRound(); @@ -277,10 +271,8 @@ NATStateType NAT::update() { TheFirewallHelper = NULL; } // we failed to connect, so we don't have to pass on the transport to the network. - if (m_transport != NULL) { - delete m_transport; - m_transport = NULL; - } + delete m_transport; + m_transport = NULL; } } return m_NATState; @@ -911,36 +903,11 @@ void NAT::processManglerResponse(UnsignedShort mangledPort) { // check to see if we've completed all the rounds // this is kind of a cheesy way to check, but it works. Bool NAT::allConnectionsDone() { - if (m_numNodes == 2) { - if (m_connectionRound >= 1) { - return TRUE; - } - } else if (m_numNodes == 3) { - if (m_connectionRound >= 3) { - return TRUE; - } - } else if (m_numNodes == 4) { - if (m_connectionRound >= 3) { - return TRUE; - } - } else if (m_numNodes == 5) { - if (m_connectionRound >= 5) { - return TRUE; - } - } else if (m_numNodes == 6) { - if (m_connectionRound >= 5) { - return TRUE; - } - } else if (m_numNodes == 7) { - if (m_connectionRound >= 7) { - return TRUE; - } - } else if (m_numNodes == 8) { - if (m_connectionRound >= 7) { - return TRUE; - } + if (m_numNodes < 2) { + return FALSE; } - return FALSE; + const Int requiredRounds = (m_numNodes & 1) ? m_numNodes : m_numNodes - 1; + return m_connectionRound >= requiredRounds; } Bool NAT::allConnectionsDoneThisRound() { @@ -1202,7 +1169,7 @@ void NAT::processGlobalMessage(Int slotNum, const char *options) { ++ptr; } DEBUG_LOG(("NAT::processGlobalMessage - got message from slot %d, message is \"%s\"", slotNum, ptr)); - if (!strncmp(ptr, "PROBED", strlen("PROBED"))) { + if (strncmp(ptr, "PROBED", strlen("PROBED")) == 0) { // format: PROBED // a probe has been sent at us, if we are waiting because of a netgear or something, we // should start sending our own probes. @@ -1213,7 +1180,7 @@ void NAT::processGlobalMessage(Int slotNum, const char *options) { } else { DEBUG_LOG(("NAT::processGlobalMessage - probed by node %d, not our target", node)); } - } else if (!strncmp(ptr, "CONNDONE", strlen("CONNDONE"))) { + } else if (strncmp(ptr, "CONNDONE", strlen("CONNDONE")) == 0) { // format: CONNDONE // we should get the node number of the player who's connection is done from the options // and mark that down as part of the connectionStates. @@ -1238,7 +1205,7 @@ void NAT::processGlobalMessage(Int slotNum, const char *options) { } else { DEBUG_LOG(("NAT::processGlobalMessage - got a connection done message that isn't from this round. node: %d sending node: %d", node, sendingNode)); } - } else if (!strncmp(ptr, "CONNFAILED", strlen("CONNFAILED"))) { + } else if (strncmp(ptr, "CONNFAILED", strlen("CONNFAILED")) == 0) { // format: CONNFAILED // we should get the node number of the player who's connection failed from the options // and mark that down as part of the connectionStates. @@ -1247,7 +1214,7 @@ void NAT::processGlobalMessage(Int slotNum, const char *options) { DEBUG_LOG(("NAT::processGlobalMessage - node %d's connection failed, setting connection state to failed", node)); setConnectionState(node, NATCONNECTIONSTATE_FAILED); } - } else if (!strncmp(ptr, "PORT", strlen("PORT"))) { + } else if (strncmp(ptr, "PORT", strlen("PORT")) == 0) { // format: PORT // we should get the node number and the mangled port number of the client we // are supposed to be communicating with and start probing them. No, that was not diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetCommandList.cpp b/Core/GameEngine/Source/GameNetwork/NetCommandList.cpp similarity index 99% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/NetCommandList.cpp rename to Core/GameEngine/Source/GameNetwork/NetCommandList.cpp index f35b2c606e..9df51d77e9 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetCommandList.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetCommandList.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/NetCommandList.h" #include "GameNetwork/networkutil.h" diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetCommandMsg.cpp b/Core/GameEngine/Source/GameNetwork/NetCommandMsg.cpp similarity index 98% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/NetCommandMsg.cpp rename to Core/GameEngine/Source/GameNetwork/NetCommandMsg.cpp index cb6eaeb5ac..ea6d56b728 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetCommandMsg.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetCommandMsg.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/NetCommandMsg.h" #include "Common/GameState.h" @@ -35,13 +35,9 @@ */ NetCommandMsg::NetCommandMsg() { - //Added By Sadullah Nader - //Initializations inserted m_executionFrame = 0; m_id = 0; m_playerID = 0; - - // m_timestamp = 0; m_referenceCount = 1; // start this off as 1. This means that an "attach" is implied by creating a NetCommandMsg object. m_commandType = NETCOMMANDTYPE_UNKNOWN; @@ -90,12 +86,8 @@ Int NetCommandMsg::getSortNumber() { * Constructor with no argument, sets everything to default values. */ NetGameCommandMsg::NetGameCommandMsg() : NetCommandMsg() { - //Added By Sadullah Nader - //Initializations inserted m_argSize = 0; m_numArgs = 0; - // - m_type = (GameMessage::Type)0; m_commandType = NETCOMMANDTYPE_GAMECOMMAND; m_argList = NULL; @@ -161,7 +153,7 @@ static Int indexFromMask(UnsignedInt mask) player = ThePlayerList->getNthPlayer( i ); if( player && player->getPlayerMask() == mask ) return i; - } // end for i + } return -1; } @@ -714,10 +706,7 @@ UnicodeString NetDisconnectChatCommandMsg::getText() { NetChatCommandMsg::NetChatCommandMsg() : NetCommandMsg() { m_commandType = NETCOMMANDTYPE_CHAT; - //added by Sadullah Nader - //Initializations inserted m_playerMask = 0; - // } /** @@ -840,10 +829,8 @@ NetWrapperCommandMsg::NetWrapperCommandMsg() : NetCommandMsg() { } NetWrapperCommandMsg::~NetWrapperCommandMsg() { - if (m_data != NULL) { - delete m_data; - m_data = NULL; - } + delete m_data; + m_data = NULL; } UnsignedByte * NetWrapperCommandMsg::getData() { @@ -852,11 +839,7 @@ UnsignedByte * NetWrapperCommandMsg::getData() { void NetWrapperCommandMsg::setData(UnsignedByte *data, UnsignedInt dataLength) { - if (m_data != NULL) { - delete m_data; - m_data = NULL; - } - + delete m_data; m_data = NEW UnsignedByte[dataLength]; // pool[]ify memcpy(m_data, data, dataLength); m_dataLength = dataLength; @@ -917,10 +900,8 @@ NetFileCommandMsg::NetFileCommandMsg() : NetCommandMsg() { } NetFileCommandMsg::~NetFileCommandMsg() { - if (m_data != NULL) { - delete[] m_data; - m_data = NULL; - } + delete[] m_data; + m_data = NULL; } AsciiString NetFileCommandMsg::getRealFilename() diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetCommandRef.cpp b/Core/GameEngine/Source/GameNetwork/NetCommandRef.cpp similarity index 96% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/NetCommandRef.cpp rename to Core/GameEngine/Source/GameNetwork/NetCommandRef.cpp index 84ddbf9f48..6e767e961a 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetCommandRef.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetCommandRef.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/NetCommandRef.h" diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetCommandWrapperList.cpp b/Core/GameEngine/Source/GameNetwork/NetCommandWrapperList.cpp similarity index 79% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/NetCommandWrapperList.cpp rename to Core/GameEngine/Source/GameNetwork/NetCommandWrapperList.cpp index 521aa3b723..86333e9016 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetCommandWrapperList.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetCommandWrapperList.cpp @@ -25,7 +25,7 @@ ////// NetCommandWrapperList.cpp //////////////////////////////// // Bryan Cleveland -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/NetCommandWrapperList.h" #include "GameNetwork/NetPacket.h" @@ -36,12 +36,7 @@ NetCommandWrapperListNode::NetCommandWrapperListNode(NetWrapperCommandMsg *msg) { - //Added By Sadullah Nader - //Initializations inserted m_next = NULL; - - // - m_numChunks = msg->getNumChunks(); m_chunksPresent = NEW Bool[m_numChunks]; // pool[]ify m_numChunksPresent = 0; @@ -50,22 +45,18 @@ NetCommandWrapperListNode::NetCommandWrapperListNode(NetWrapperCommandMsg *msg) m_chunksPresent[i] = FALSE; } - m_dataLength = msg->getTotalDataLength(); - m_data = NEW UnsignedByte[m_dataLength]; // pool[]ify + m_totalDataLength = msg->getTotalDataLength(); + m_data = NEW UnsignedByte[m_totalDataLength]; // pool[]ify m_commandID = msg->getWrappedCommandID(); } NetCommandWrapperListNode::~NetCommandWrapperListNode() { - if (m_chunksPresent != NULL) { - delete[] m_chunksPresent; - m_chunksPresent = NULL; - } + delete[] m_chunksPresent; + m_chunksPresent = NULL; - if (m_data != NULL) { - delete[] m_data; - m_data = NULL; - } + delete[] m_data; + m_data = NULL; } Bool NetCommandWrapperListNode::isComplete() { @@ -84,7 +75,7 @@ UnsignedShort NetCommandWrapperListNode::getCommandID() { } UnsignedInt NetCommandWrapperListNode::getRawDataLength() { - return m_dataLength; + return m_totalDataLength; } void NetCommandWrapperListNode::copyChunkData(NetWrapperCommandMsg *msg) { @@ -93,22 +84,42 @@ void NetCommandWrapperListNode::copyChunkData(NetWrapperCommandMsg *msg) { return; } - DEBUG_ASSERTCRASH(msg->getChunkNumber() < m_numChunks, ("MunkeeChunk %d of %d", - msg->getChunkNumber(), m_numChunks)); - if (msg->getChunkNumber() >= m_numChunks) + UnsignedInt chunkNumber = msg->getChunkNumber(); + + if (chunkNumber >= m_numChunks) { + DEBUG_CRASH(("Data chunk %u exceeds the expected maximum of %u chunks", chunkNumber, m_numChunks)); return; + } + + // we already received this chunk, no need to recopy it. + if (m_chunksPresent[chunkNumber] == TRUE) { + return; + } - DEBUG_LOG(("NetCommandWrapperListNode::copyChunkData() - copying chunk %d", - msg->getChunkNumber())); + UnsignedInt chunkDataOffset = msg->getDataOffset(); + UnsignedInt chunkDataLength = msg->getDataLength(); - if (m_chunksPresent[msg->getChunkNumber()] == TRUE) { - // we already received this chunk, no need to recopy it. + // TheSuperHackers @security Mauller 04/12/2025 Prevent out of bounds memory access + if (chunkDataOffset >= m_totalDataLength) { + DEBUG_CRASH(("Data chunk offset %u exceeds the total data length %u", chunkDataOffset, m_totalDataLength)); return; } - m_chunksPresent[msg->getChunkNumber()] = TRUE; - UnsignedInt offset = msg->getDataOffset(); - memcpy(m_data + offset, msg->getData(), msg->getDataLength()); + if (chunkDataLength > MAX_PACKET_SIZE ) { + DEBUG_CRASH(("Data Chunk size %u greater than max packet size %u", chunkDataLength, MAX_PACKET_SIZE)); + return; + } + + if (chunkDataOffset + chunkDataLength > m_totalDataLength) { + DEBUG_CRASH(("Data chunk exceeds data array size")); + return; + } + + DEBUG_LOG(("NetCommandWrapperListNode::copyChunkData() - copying chunk %u", chunkNumber)); + + memcpy(m_data + chunkDataOffset, msg->getData(), chunkDataLength); + + m_chunksPresent[chunkNumber] = TRUE; ++m_numChunksPresent; } diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetMessageStream.cpp b/Core/GameEngine/Source/GameNetwork/NetMessageStream.cpp similarity index 98% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/NetMessageStream.cpp rename to Core/GameEngine/Source/GameNetwork/NetMessageStream.cpp index 7cf572cbbb..43f5cd6da2 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetMessageStream.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetMessageStream.cpp @@ -22,7 +22,7 @@ // // //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine // NetMessageStream.cpp diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetPacket.cpp b/Core/GameEngine/Source/GameNetwork/NetPacket.cpp similarity index 89% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/NetPacket.cpp rename to Core/GameEngine/Source/GameNetwork/NetPacket.cpp index 8ae95e235a..be74404bae 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetPacket.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetPacket.cpp @@ -24,7 +24,7 @@ ////////// NetPacket.cpp /////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/NetPacket.h" #include "GameNetwork/NetCommandMsg.h" @@ -32,6 +32,17 @@ #include "GameNetwork/networkutil.h" #include "GameNetwork/GameMessageParser.h" +// TheSuperHackers @refactor BobTista 10/06/2025 Extract magic character literals into named constants for improved readability +typedef UnsignedByte NetPacketFieldType; + +namespace NetPacketFieldTypes { + constexpr const NetPacketFieldType CommandType = 'T'; // NetCommandType field + constexpr const NetPacketFieldType Relay = 'R'; // Relay field + constexpr const NetPacketFieldType PlayerId = 'P'; // Player ID field + constexpr const NetPacketFieldType CommandId = 'C'; // Command ID field + constexpr const NetPacketFieldType Frame = 'F'; // Frame field + constexpr const NetPacketFieldType Data = 'D'; // Data payload field +} // This function assumes that all of the fields are either of default value or are // present in the raw data. @@ -50,37 +61,37 @@ NetCommandRef * NetPacket::ConstructNetCommandMsgFromRawData(UnsignedByte *data, switch (data[offset]) { - case 'T': + case NetPacketFieldTypes::CommandType: ++offset; memcpy(&commandType, data + offset, sizeof(UnsignedByte)); offset += sizeof(UnsignedByte); break; - case 'R': + case NetPacketFieldTypes::Relay: ++offset; memcpy(&relay, data + offset, sizeof(UnsignedByte)); offset += sizeof(UnsignedByte); break; - case 'P': + case NetPacketFieldTypes::PlayerId: ++offset; memcpy(&playerID, data + offset, sizeof(UnsignedByte)); offset += sizeof(UnsignedByte); break; - case 'C': + case NetPacketFieldTypes::CommandId: ++offset; memcpy(&commandID, data + offset, sizeof(UnsignedShort)); offset += sizeof(UnsignedShort); break; - case 'F': + case NetPacketFieldTypes::Frame: ++offset; memcpy(&frame, data + offset, sizeof(UnsignedInt)); offset += sizeof(UnsignedInt); break; - case 'D': + case NetPacketFieldTypes::Data: ++offset; switch (commandType) { @@ -348,7 +359,7 @@ UnsignedInt NetPacket::GetGameCommandSize(NetCommandMsg *msg) { msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // relay msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // command type msglen += sizeof(UnsignedShort) + sizeof(UnsignedByte); // command ID - msglen += sizeof(UnsignedByte); // the 'D' for the data section. + msglen += sizeof(UnsignedByte); // the NetPacketFieldTypes::Data for the data section. GameMessage *gmsg = cmdMsg->constructGameMessage(); GameMessageParser *parser = newInstance(GameMessageParser)(gmsg); @@ -362,7 +373,7 @@ UnsignedInt NetPacket::GetGameCommandSize(NetCommandMsg *msg) { GameMessageArgumentDataType type = arg->getType(); switch (type) { - + case ARGUMENTDATATYPE_INTEGER: msglen += arg->getArgCount() * sizeof(Int); break; @@ -519,7 +530,7 @@ UnsignedInt NetPacket::GetKeepAliveCommandSize(NetCommandMsg *msg) { ++msglen; msglen += sizeof(UnsignedByte); - ++msglen; // For the 'D' + ++msglen; // For the NetPacketFieldTypes::Data return msglen; } @@ -533,7 +544,7 @@ UnsignedInt NetPacket::GetDisconnectKeepAliveCommandSize(NetCommandMsg *msg) { ++msglen; msglen += sizeof(UnsignedByte); - ++msglen; // For the 'D' + ++msglen; // For the NetPacketFieldTypes::Data return msglen; } @@ -548,7 +559,7 @@ UnsignedInt NetPacket::GetDisconnectPlayerCommandSize(NetCommandMsg *msg) { msglen += sizeof(UnsignedByte); msglen += sizeof(UnsignedShort) + sizeof(UnsignedByte); - ++msglen; // the 'D' + ++msglen; // the NetPacketFieldTypes::Data msglen += sizeof(UnsignedByte); // slot number msglen += sizeof(UnsignedInt); // disconnect frame @@ -564,7 +575,7 @@ UnsignedInt NetPacket::GetPacketRouterQueryCommandSize(NetCommandMsg *msg) { ++msglen; msglen += sizeof(UnsignedByte); - ++msglen; // the 'D' + ++msglen; // the NetPacketFieldTypes::Data return msglen; } @@ -578,7 +589,7 @@ UnsignedInt NetPacket::GetPacketRouterAckCommandSize(NetCommandMsg *msg) { ++msglen; msglen += sizeof(UnsignedByte); - ++msglen; // the 'D' + ++msglen; // the NetPacketFieldTypes::Data return msglen; } @@ -593,7 +604,7 @@ UnsignedInt NetPacket::GetDisconnectChatCommandSize(NetCommandMsg *msg) { ++msglen; msglen += sizeof(UnsignedByte); - ++msglen; // the 'D' + ++msglen; // the NetPacketFieldTypes::Data msglen += sizeof(UnsignedByte); // string msglength UnsignedByte textmsglen = cmdMsg->getText().getLength(); msglen += textmsglen * sizeof(UnsignedShort); @@ -611,7 +622,7 @@ UnsignedInt NetPacket::GetDisconnectVoteCommandSize(NetCommandMsg *msg) { msglen += sizeof(UnsignedByte); msglen += sizeof(UnsignedShort) + sizeof(UnsignedByte); - ++msglen; // the 'D' + ++msglen; // the NetPacketFieldTypes::Data msglen += sizeof(UnsignedByte); // slot number msglen += sizeof(UnsignedInt); // vote frame. @@ -630,7 +641,7 @@ UnsignedInt NetPacket::GetChatCommandSize(NetCommandMsg *msg) { msglen += sizeof(UnsignedByte); msglen += sizeof(UnsignedShort) + sizeof(UnsignedByte); - ++msglen; // the 'D' + ++msglen; // the NetPacketFieldTypes::Data msglen += sizeof(UnsignedByte); // string msglength UnsignedByte textmsglen = cmdMsg->getText().getLength(); msglen += textmsglen * sizeof(UnsignedShort); @@ -648,7 +659,7 @@ UnsignedInt NetPacket::GetProgressMessageSize(NetCommandMsg *msg) { ++msglen; msglen += sizeof(UnsignedByte); - ++msglen; // For the 'D' + ++msglen; // For the NetPacketFieldTypes::Data ++msglen; // percentage return msglen; @@ -663,7 +674,7 @@ UnsignedInt NetPacket::GetLoadCompleteMessageSize(NetCommandMsg *msg) { ++msglen; msglen += sizeof(UnsignedByte); - ++msglen; // For the 'D' + ++msglen; // For the NetPacketFieldTypes::Data return msglen; } @@ -677,7 +688,7 @@ UnsignedInt NetPacket::GetTimeOutGameStartMessageSize(NetCommandMsg *msg) { ++msglen; msglen += sizeof(UnsignedByte); - ++msglen; // For the 'D' + ++msglen; // For the NetPacketFieldTypes::Data return msglen; } @@ -686,12 +697,12 @@ UnsignedInt NetPacket::GetTimeOutGameStartMessageSize(NetCommandMsg *msg) { UnsignedInt NetPacket::GetWrapperCommandSize(NetCommandMsg *msg) { UnsignedInt msglen = 0; - ++msglen; // 'T' + ++msglen; // NetPacketFieldTypes::CommandType msglen += sizeof(UnsignedByte); // command type - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'P' and player ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // 'C' and command ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'R' and relay - ++msglen; // 'D' + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::PlayerId and player ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // NetPacketFieldTypes::CommandId and command ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::Relay and relay + ++msglen; // NetPacketFieldTypes::Data msglen += sizeof(UnsignedShort); // m_wrappedCommandID msglen += sizeof(UnsignedInt); // m_chunkNumber @@ -706,12 +717,12 @@ UnsignedInt NetPacket::GetWrapperCommandSize(NetCommandMsg *msg) { UnsignedInt NetPacket::GetFileCommandSize(NetCommandMsg *msg) { NetFileCommandMsg *filemsg = (NetFileCommandMsg *)msg; UnsignedInt msglen = 0; - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'T' and command type - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'P' and player ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // 'C' and command ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'R' and relay + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::CommandType and command type + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::PlayerId and player ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // NetPacketFieldTypes::CommandId and command ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::Relay and relay - ++msglen; // 'D' + ++msglen; // NetPacketFieldTypes::Data msglen += filemsg->getPortableFilename().getLength() + 1; // PORTABLE filename and the terminating 0 msglen += sizeof(UnsignedInt); // file data length @@ -723,12 +734,12 @@ UnsignedInt NetPacket::GetFileCommandSize(NetCommandMsg *msg) { UnsignedInt NetPacket::GetFileAnnounceCommandSize(NetCommandMsg *msg) { NetFileAnnounceCommandMsg *filemsg = (NetFileAnnounceCommandMsg *)msg; UnsignedInt msglen = 0; - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'T' and command type - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'P' and player ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // 'C' and command ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'R' and relay + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::CommandType and command type + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::PlayerId and player ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // NetPacketFieldTypes::CommandId and command ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::Relay and relay - ++msglen; // 'D' + ++msglen; // NetPacketFieldTypes::Data msglen += filemsg->getPortableFilename().getLength() + 1; // PORTABLE filename and the terminating 0 msglen += sizeof(UnsignedShort); // m_fileID @@ -739,12 +750,12 @@ UnsignedInt NetPacket::GetFileAnnounceCommandSize(NetCommandMsg *msg) { UnsignedInt NetPacket::GetFileProgressCommandSize(NetCommandMsg *msg) { UnsignedInt msglen = 0; - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'T' and command type - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'P' and player ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // 'C' and command ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'R' and relay + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::CommandType and command type + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::PlayerId and player ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // NetPacketFieldTypes::CommandId and command ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::Relay and relay - ++msglen; // 'D' + ++msglen; // NetPacketFieldTypes::Data msglen += sizeof(UnsignedShort); // m_fileID msglen += sizeof(Int); // m_progress @@ -754,12 +765,12 @@ UnsignedInt NetPacket::GetFileProgressCommandSize(NetCommandMsg *msg) { UnsignedInt NetPacket::GetDisconnectFrameCommandSize(NetCommandMsg *msg) { UnsignedInt msglen = 0; - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'T' and command type - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'P' and player ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // 'C' and command ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'R' and relay + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::CommandType and command type + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::PlayerId and player ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // NetPacketFieldTypes::CommandId and command ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::Relay and relay - ++msglen; // 'D' + ++msglen; // NetPacketFieldTypes::Data msglen += sizeof(UnsignedInt); // disconnect frame return msglen; @@ -767,12 +778,12 @@ UnsignedInt NetPacket::GetDisconnectFrameCommandSize(NetCommandMsg *msg) { UnsignedInt NetPacket::GetDisconnectScreenOffCommandSize(NetCommandMsg *msg) { UnsignedInt msglen = 0; - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'T' and command type - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'P' and player ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // 'C' and command ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'R' and relay + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::CommandType and command type + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::PlayerId and player ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // NetPacketFieldTypes::CommandId and command ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::Relay and relay - ++msglen; // 'D' + ++msglen; // NetPacketFieldTypes::Data msglen += sizeof(UnsignedInt); // new frame return msglen; @@ -780,12 +791,12 @@ UnsignedInt NetPacket::GetDisconnectScreenOffCommandSize(NetCommandMsg *msg) { UnsignedInt NetPacket::GetFrameResendRequestCommandSize(NetCommandMsg *msg) { UnsignedInt msglen = 0; - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'T' and command type - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'P' and player ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // 'C' and command ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // 'R' and relay + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::CommandType and command type + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::PlayerId and player ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedShort); // NetPacketFieldTypes::CommandId and command ID + msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // NetPacketFieldTypes::Relay and relay - ++msglen; // 'D' + ++msglen; // NetPacketFieldTypes::Data msglen += sizeof(UnsignedInt); // frame to resend return msglen; @@ -886,39 +897,39 @@ void NetPacket::FillBufferWithGameCommand(UnsignedByte *buffer, NetCommandRef *m //DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::FillBufferWithGameCommand for command ID %d", cmdMsg->getID())); // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the execution frame into the packet. - buffer[offset] = 'F'; + buffer[offset] = NetPacketFieldTypes::Frame; ++offset; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(buffer+offset, &newframe, sizeof(UnsignedInt)); offset += sizeof(UnsignedInt); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); offset += sizeof(UnsignedByte); // If necessary, put the playerID into the packet. - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); // If necessary, specify the command ID of this command. - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); offset += sizeof(UnsignedShort); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; // Now copy the GameMessage type into the packet. @@ -1005,8 +1016,7 @@ void NetPacket::FillBufferWithGameCommand(UnsignedByte *buffer, NetCommandRef *m // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addGameMessage - added game message, frame %d, player %d, command ID %d", m_lastFrame, m_lastPlayerID, m_lastCommandID)); - if (gmsg) - deleteInstance(gmsg); + deleteInstance(gmsg); gmsg = NULL; } @@ -1046,18 +1056,18 @@ void NetPacket::FillBufferWithAckCommand(UnsignedByte *buffer, NetCommandRef *ms } - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = type; offset += sizeof(UnsignedByte); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); // Put in the command id of the command we are acking. - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; memcpy(buffer + offset, &commandID, sizeof(UnsignedShort)); offset += sizeof(UnsignedShort); @@ -1073,20 +1083,20 @@ void NetPacket::FillBufferWithFrameCommand(UnsignedByte *buffer, NetCommandRef * // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addFrameCommand - adding frame command for frame %d, command count = %d, command id = %d", cmdMsg->getExecutionFrame(), cmdMsg->getCommandCount(), cmdMsg->getID())); // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the execution frame into the packet. - buffer[offset] = 'F'; + buffer[offset] = NetPacketFieldTypes::Frame; ++offset; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(buffer+offset, &newframe, sizeof(UnsignedInt)); offset += sizeof(UnsignedInt); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); @@ -1094,7 +1104,7 @@ void NetPacket::FillBufferWithFrameCommand(UnsignedByte *buffer, NetCommandRef * // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); @@ -1102,7 +1112,7 @@ void NetPacket::FillBufferWithFrameCommand(UnsignedByte *buffer, NetCommandRef * // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); // If necessary, specify the command ID of this command. - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); @@ -1110,7 +1120,7 @@ void NetPacket::FillBufferWithFrameCommand(UnsignedByte *buffer, NetCommandRef * // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; UnsignedShort cmdCount = cmdMsg->getCommandCount(); memcpy(buffer + offset, &cmdCount, sizeof(UnsignedShort)); @@ -1126,20 +1136,20 @@ void NetPacket::FillBufferWithPlayerLeaveCommand(UnsignedByte *buffer, NetComman // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addPlayerLeaveCommand - adding player leave command for player %d", cmdMsg->getLeavingPlayerID())); // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); offset += sizeof(UnsignedByte); // If necessary, put the execution frame into the packet. - buffer[offset] = 'F'; + buffer[offset] = NetPacketFieldTypes::Frame; ++offset; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(buffer+offset, &newframe, sizeof(UnsignedInt)); @@ -1147,7 +1157,7 @@ void NetPacket::FillBufferWithPlayerLeaveCommand(UnsignedByte *buffer, NetComman // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); @@ -1155,7 +1165,7 @@ void NetPacket::FillBufferWithPlayerLeaveCommand(UnsignedByte *buffer, NetComman // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); // If necessary, specify the command ID of this command. - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); @@ -1163,7 +1173,7 @@ void NetPacket::FillBufferWithPlayerLeaveCommand(UnsignedByte *buffer, NetComman // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; UnsignedByte leavingPlayerID = cmdMsg->getLeavingPlayerID(); memcpy(buffer + offset, &leavingPlayerID, sizeof(UnsignedByte)); @@ -1176,13 +1186,13 @@ void NetPacket::FillBufferWithRunAheadMetricsCommand(UnsignedByte *buffer, NetCo // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addRunAheadMetricsCommand - adding run ahead metrics for player %d, fps = %d, latency = %f", cmdMsg->getPlayerID(), cmdMsg->getAverageFps(), cmdMsg->getAverageLatency())); // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); @@ -1190,7 +1200,7 @@ void NetPacket::FillBufferWithRunAheadMetricsCommand(UnsignedByte *buffer, NetCo // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); @@ -1198,7 +1208,7 @@ void NetPacket::FillBufferWithRunAheadMetricsCommand(UnsignedByte *buffer, NetCo // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); // If necessary, specify the command ID of this command. - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); @@ -1206,7 +1216,7 @@ void NetPacket::FillBufferWithRunAheadMetricsCommand(UnsignedByte *buffer, NetCo // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; // write the average latency Real averageLatency = cmdMsg->getAverageLatency(); @@ -1224,20 +1234,20 @@ void NetPacket::FillBufferWithRunAheadCommand(UnsignedByte *buffer, NetCommandRe //DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::FillBufferWithRunAheadCommand - adding run ahead command")); // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); offset += sizeof(UnsignedByte); // If necessary, put the execution frame into the packet. - buffer[offset] = 'F'; + buffer[offset] = NetPacketFieldTypes::Frame; ++offset; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(buffer+offset, &newframe, sizeof(UnsignedInt)); @@ -1245,7 +1255,7 @@ void NetPacket::FillBufferWithRunAheadCommand(UnsignedByte *buffer, NetCommandRe // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); @@ -1253,7 +1263,7 @@ void NetPacket::FillBufferWithRunAheadCommand(UnsignedByte *buffer, NetCommandRe // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); // If necessary, specify the command ID of this command. - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); @@ -1261,7 +1271,7 @@ void NetPacket::FillBufferWithRunAheadCommand(UnsignedByte *buffer, NetCommandRe // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; UnsignedShort newRunAhead = cmdMsg->getRunAhead(); memcpy(buffer + offset, &newRunAhead, sizeof(UnsignedShort)); @@ -1280,20 +1290,20 @@ void NetPacket::FillBufferWithDestroyPlayerCommand(UnsignedByte *buffer, NetComm // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addRunAheadCommand - adding run ahead command")); // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); offset += sizeof(UnsignedByte); // If necessary, put the execution frame into the packet. - buffer[offset] = 'F'; + buffer[offset] = NetPacketFieldTypes::Frame; ++offset; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(buffer+offset, &newframe, sizeof(UnsignedInt)); @@ -1301,7 +1311,7 @@ void NetPacket::FillBufferWithDestroyPlayerCommand(UnsignedByte *buffer, NetComm // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); @@ -1309,7 +1319,7 @@ void NetPacket::FillBufferWithDestroyPlayerCommand(UnsignedByte *buffer, NetComm // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); // If necessary, specify the command ID of this command. - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); @@ -1317,7 +1327,7 @@ void NetPacket::FillBufferWithDestroyPlayerCommand(UnsignedByte *buffer, NetComm // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; UnsignedInt newVal = cmdMsg->getPlayerIndex(); memcpy(buffer + offset, &newVal, sizeof(UnsignedInt)); @@ -1329,24 +1339,24 @@ void NetPacket::FillBufferWithKeepAliveCommand(UnsignedByte *buffer, NetCommandR UnsignedShort offset = 0; // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); offset += sizeof(UnsignedByte); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; } @@ -1355,25 +1365,25 @@ void NetPacket::FillBufferWithDisconnectKeepAliveCommand(UnsignedByte *buffer, N UnsignedShort offset = 0; // Put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // Put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); offset += sizeof(UnsignedByte); // Put the player ID into the packet. - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; } @@ -1383,13 +1393,13 @@ void NetPacket::FillBufferWithDisconnectPlayerCommand(UnsignedByte *buffer, NetC // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectPlayerCommand - adding run ahead command")); // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); @@ -1397,7 +1407,7 @@ void NetPacket::FillBufferWithDisconnectPlayerCommand(UnsignedByte *buffer, NetC // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); @@ -1405,7 +1415,7 @@ void NetPacket::FillBufferWithDisconnectPlayerCommand(UnsignedByte *buffer, NetC // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); // If necessary, specify the command ID of this command. - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); @@ -1413,7 +1423,7 @@ void NetPacket::FillBufferWithDisconnectPlayerCommand(UnsignedByte *buffer, NetC // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; UnsignedByte slot = cmdMsg->getDisconnectSlot(); memcpy(buffer + offset, &slot, sizeof(slot)); @@ -1430,27 +1440,27 @@ void NetPacket::FillBufferWithPacketRouterQueryCommand(UnsignedByte *buffer, Net // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addPacketRouterQueryCommand - adding packet router query command")); // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); offset += sizeof(UnsignedByte); // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; } @@ -1460,13 +1470,13 @@ void NetPacket::FillBufferWithPacketRouterAckCommand(UnsignedByte *buffer, NetCo // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addPacketRouterAckCommand - adding packet router query command")); // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); @@ -1474,14 +1484,14 @@ void NetPacket::FillBufferWithPacketRouterAckCommand(UnsignedByte *buffer, NetCo // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; } @@ -1491,13 +1501,13 @@ void NetPacket::FillBufferWithDisconnectChatCommand(UnsignedByte *buffer, NetCom // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectChatCommand - adding run ahead command")); // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); @@ -1505,14 +1515,14 @@ void NetPacket::FillBufferWithDisconnectChatCommand(UnsignedByte *buffer, NetCom // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; UnicodeString unitext = cmdMsg->getText(); UnsignedByte length = unitext.getLength(); @@ -1529,13 +1539,13 @@ void NetPacket::FillBufferWithDisconnectVoteCommand(UnsignedByte *buffer, NetCom // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectVoteCommand - adding run ahead command")); // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); @@ -1543,7 +1553,7 @@ void NetPacket::FillBufferWithDisconnectVoteCommand(UnsignedByte *buffer, NetCom // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); @@ -1551,7 +1561,7 @@ void NetPacket::FillBufferWithDisconnectVoteCommand(UnsignedByte *buffer, NetCom // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); // If necessary, specify the command ID of this command. - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); @@ -1559,7 +1569,7 @@ void NetPacket::FillBufferWithDisconnectVoteCommand(UnsignedByte *buffer, NetCom // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; UnsignedByte slot = cmdMsg->getSlot(); memcpy(buffer + offset, &slot, sizeof(slot)); @@ -1576,20 +1586,20 @@ void NetPacket::FillBufferWithChatCommand(UnsignedByte *buffer, NetCommandRef *m // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectChatCommand - adding run ahead command")); // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the execution frame into the packet. - buffer[offset] = 'F'; + buffer[offset] = NetPacketFieldTypes::Frame; ++offset; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(buffer+offset, &newframe, sizeof(UnsignedInt)); offset += sizeof(UnsignedInt); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); @@ -1597,7 +1607,7 @@ void NetPacket::FillBufferWithChatCommand(UnsignedByte *buffer, NetCommandRef *m // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); @@ -1605,7 +1615,7 @@ void NetPacket::FillBufferWithChatCommand(UnsignedByte *buffer, NetCommandRef *m // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); // If necessary, specify the command ID of this command. - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); @@ -1613,7 +1623,7 @@ void NetPacket::FillBufferWithChatCommand(UnsignedByte *buffer, NetCommandRef *m // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; UnicodeString unitext = cmdMsg->getText(); UnsignedByte length = unitext.getLength(); @@ -1633,25 +1643,25 @@ void NetPacket::FillBufferWithProgressMessage(UnsignedByte *buffer, NetCommandRe UnsignedShort offset = 0; // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); offset += sizeof(UnsignedByte); // Put the player ID into the packet. - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; buffer[offset] = cmdMsg->getPercentage(); @@ -1663,31 +1673,31 @@ void NetPacket::FillBufferWithLoadCompleteMessage(UnsignedByte *buffer, NetComma UnsignedShort offset = 0; // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); offset += sizeof(UnsignedByte); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); // If necessary, specify the command ID of this command. - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); offset += sizeof(UnsignedShort); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; } @@ -1696,30 +1706,30 @@ void NetPacket::FillBufferWithTimeOutGameStartMessage(UnsignedByte *buffer, NetC UnsignedShort offset = 0; // If necessary, put the NetCommandType into the packet. - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // If necessary, put the relay into the packet. - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; UnsignedByte newRelay = msg->getRelay(); memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); offset += sizeof(UnsignedByte); - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); // If necessary, specify the command ID of this command. - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); offset += sizeof(UnsignedShort); - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; } @@ -1728,32 +1738,32 @@ void NetPacket::FillBufferWithFileMessage(UnsignedByte *buffer, NetCommandRef *m UnsignedInt offset = 0; // command type - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // relay - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; buffer[offset] = msg->getRelay(); offset += sizeof(UnsignedByte); // player ID - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); // command ID - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(newID)); offset += sizeof(newID); // data - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; AsciiString filename = cmdMsg->getPortableFilename(); // PORTABLE @@ -1777,32 +1787,32 @@ void NetPacket::FillBufferWithFileAnnounceMessage(UnsignedByte *buffer, NetComma UnsignedInt offset = 0; // command type - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // relay - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; buffer[offset] = msg->getRelay(); offset += sizeof(UnsignedByte); // player ID - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); // command ID - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(newID)); offset += sizeof(newID); // data - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; AsciiString filename = cmdMsg->getPortableFilename(); // PORTABLE @@ -1827,32 +1837,32 @@ void NetPacket::FillBufferWithFileProgressMessage(UnsignedByte *buffer, NetComma UnsignedInt offset = 0; // command type - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // relay - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; buffer[offset] = msg->getRelay(); offset += sizeof(UnsignedByte); // player ID - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); // command ID - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(newID)); offset += sizeof(newID); // data - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; UnsignedShort fileID = cmdMsg->getFileID(); @@ -1869,32 +1879,32 @@ void NetPacket::FillBufferWithDisconnectFrameMessage(UnsignedByte *buffer, NetCo UnsignedInt offset = 0; // command type - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // relay - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; buffer[offset] = msg->getRelay(); offset += sizeof(UnsignedByte); // player ID - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); // command ID - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(newID)); offset += sizeof(newID); // data - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; UnsignedInt disconnectFrame = cmdMsg->getDisconnectFrame(); @@ -1907,32 +1917,32 @@ void NetPacket::FillBufferWithDisconnectScreenOffMessage(UnsignedByte *buffer, N UnsignedInt offset = 0; // command type - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // relay - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; buffer[offset] = msg->getRelay(); offset += sizeof(UnsignedByte); // player ID - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); // command ID - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(newID)); offset += sizeof(newID); // data - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; UnsignedInt newFrame = cmdMsg->getNewFrame(); @@ -1945,32 +1955,32 @@ void NetPacket::FillBufferWithFrameResendRequestMessage(UnsignedByte *buffer, Ne UnsignedInt offset = 0; // command type - buffer[offset] = 'T'; + buffer[offset] = NetPacketFieldTypes::CommandType; ++offset; buffer[offset] = cmdMsg->getNetCommandType(); offset += sizeof(UnsignedByte); // relay - buffer[offset] = 'R'; + buffer[offset] = NetPacketFieldTypes::Relay; ++offset; buffer[offset] = msg->getRelay(); offset += sizeof(UnsignedByte); // player ID - buffer[offset] = 'P'; + buffer[offset] = NetPacketFieldTypes::PlayerId; ++offset; buffer[offset] = cmdMsg->getPlayerID(); offset += sizeof(UnsignedByte); // command ID - buffer[offset] = 'C'; + buffer[offset] = NetPacketFieldTypes::CommandId; ++offset; UnsignedShort newID = cmdMsg->getID(); memcpy(buffer + offset, &newID, sizeof(newID)); offset += sizeof(newID); // data - buffer[offset] = 'D'; + buffer[offset] = NetPacketFieldTypes::Data; ++offset; UnsignedInt frameToResend = cmdMsg->getFrameToResend(); @@ -2002,10 +2012,8 @@ NetPacket::NetPacket(TransportMessage *msg) { * Destructor */ NetPacket::~NetPacket() { - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + deleteInstance(m_lastCommand); + m_lastCommand = NULL; } /** @@ -2028,10 +2036,9 @@ void NetPacket::init() { } void NetPacket::reset() { - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + deleteInstance(m_lastCommand); + m_lastCommand = NULL; + init(); } @@ -2136,7 +2143,7 @@ Bool NetPacket::addFrameResendRequestCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -2146,7 +2153,7 @@ Bool NetPacket::addFrameResendRequestCommand(NetCommandRef *msg) { // If necessary, put the execution frame into the packet. if (m_lastFrame != cmdMsg->getExecutionFrame()) { - m_packet[m_packetLen] = 'F'; + m_packet[m_packetLen] = NetPacketFieldTypes::Frame; ++m_packetLen; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(m_packet+m_packetLen, &newframe, sizeof(UnsignedInt)); @@ -2157,7 +2164,7 @@ Bool NetPacket::addFrameResendRequestCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet + m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -2168,7 +2175,7 @@ Bool NetPacket::addFrameResendRequestCommand(NetCommandRef *msg) { // If necessary put the player ID into the packet. if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -2179,7 +2186,7 @@ Bool NetPacket::addFrameResendRequestCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -2187,7 +2194,7 @@ Bool NetPacket::addFrameResendRequestCommand(NetCommandRef *msg) { } m_lastCommandID = cmdMsg->getID(); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnsignedInt frameToResend = cmdMsg->getFrameToResend(); @@ -2197,10 +2204,8 @@ Bool NetPacket::addFrameResendRequestCommand(NetCommandRef *msg) { DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addFrameResendRequest - added frame resend request command from player %d for frame %d, command id = %d", m_lastPlayerID, frameToResend, m_lastCommandID)); ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -2232,7 +2237,7 @@ Bool NetPacket::isRoomForFrameResendRequestMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // for 'D' + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedInt); // for the frame to be resent if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; @@ -2247,7 +2252,7 @@ Bool NetPacket::addDisconnectScreenOffCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -2257,7 +2262,7 @@ Bool NetPacket::addDisconnectScreenOffCommand(NetCommandRef *msg) { // If necessary, put the execution frame into the packet. if (m_lastFrame != cmdMsg->getExecutionFrame()) { - m_packet[m_packetLen] = 'F'; + m_packet[m_packetLen] = NetPacketFieldTypes::Frame; ++m_packetLen; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(m_packet+m_packetLen, &newframe, sizeof(UnsignedInt)); @@ -2268,7 +2273,7 @@ Bool NetPacket::addDisconnectScreenOffCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet + m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -2279,7 +2284,7 @@ Bool NetPacket::addDisconnectScreenOffCommand(NetCommandRef *msg) { // If necessary put the player ID into the packet. if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -2290,7 +2295,7 @@ Bool NetPacket::addDisconnectScreenOffCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -2298,7 +2303,7 @@ Bool NetPacket::addDisconnectScreenOffCommand(NetCommandRef *msg) { } m_lastCommandID = cmdMsg->getID(); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnsignedInt newFrame = cmdMsg->getNewFrame(); @@ -2308,10 +2313,8 @@ Bool NetPacket::addDisconnectScreenOffCommand(NetCommandRef *msg) { DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectScreenOff - added disconnect screen off command from player %d for frame %d, command id = %d", m_lastPlayerID, newFrame, m_lastCommandID)); ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -2343,7 +2346,7 @@ Bool NetPacket::isRoomForDisconnectScreenOffMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // for 'D' + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedInt); // for the disconnect frame if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; @@ -2358,7 +2361,7 @@ Bool NetPacket::addDisconnectFrameCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -2368,7 +2371,7 @@ Bool NetPacket::addDisconnectFrameCommand(NetCommandRef *msg) { // If necessary, put the execution frame into the packet. if (m_lastFrame != cmdMsg->getExecutionFrame()) { - m_packet[m_packetLen] = 'F'; + m_packet[m_packetLen] = NetPacketFieldTypes::Frame; ++m_packetLen; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(m_packet+m_packetLen, &newframe, sizeof(UnsignedInt)); @@ -2379,7 +2382,7 @@ Bool NetPacket::addDisconnectFrameCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet + m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -2390,7 +2393,7 @@ Bool NetPacket::addDisconnectFrameCommand(NetCommandRef *msg) { // If necessary put the player ID into the packet. if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -2401,7 +2404,7 @@ Bool NetPacket::addDisconnectFrameCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -2409,7 +2412,7 @@ Bool NetPacket::addDisconnectFrameCommand(NetCommandRef *msg) { } m_lastCommandID = cmdMsg->getID(); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnsignedInt disconnectFrame = cmdMsg->getDisconnectFrame(); @@ -2417,10 +2420,8 @@ Bool NetPacket::addDisconnectFrameCommand(NetCommandRef *msg) { m_packetLen += sizeof(disconnectFrame); ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -2454,7 +2455,7 @@ Bool NetPacket::isRoomForDisconnectFrameMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // for 'D' + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedInt); // for the disconnect frame if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; @@ -2469,7 +2470,7 @@ Bool NetPacket::addFileCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -2479,7 +2480,7 @@ Bool NetPacket::addFileCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet + m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -2490,7 +2491,7 @@ Bool NetPacket::addFileCommand(NetCommandRef *msg) { // If necessary put the player ID into the packet. if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -2501,7 +2502,7 @@ Bool NetPacket::addFileCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -2510,7 +2511,7 @@ Bool NetPacket::addFileCommand(NetCommandRef *msg) { m_lastCommandID = cmdMsg->getID(); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; AsciiString filename = cmdMsg->getPortableFilename(); // PORTABLE @@ -2525,10 +2526,8 @@ Bool NetPacket::addFileCommand(NetCommandRef *msg) { m_packetLen += fileLength; ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); return TRUE; @@ -2554,7 +2553,7 @@ Bool NetPacket::isRoomForFileMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte) + sizeof(UnsignedShort); } - ++len; // 'D' + ++len; // NetPacketFieldTypes::Data len += cmdMsg->getPortableFilename().getLength() + 1; // PORTABLE filename + the terminating 0 len += sizeof(UnsignedInt); // filedata length len += cmdMsg->getFileLength(); @@ -2573,7 +2572,7 @@ Bool NetPacket::addFileAnnounceCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -2583,7 +2582,7 @@ Bool NetPacket::addFileAnnounceCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet + m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -2594,7 +2593,7 @@ Bool NetPacket::addFileAnnounceCommand(NetCommandRef *msg) { // If necessary put the player ID into the packet. if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -2605,7 +2604,7 @@ Bool NetPacket::addFileAnnounceCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -2614,7 +2613,7 @@ Bool NetPacket::addFileAnnounceCommand(NetCommandRef *msg) { m_lastCommandID = cmdMsg->getID(); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; AsciiString filename = cmdMsg->getPortableFilename(); // PORTABLE @@ -2630,10 +2629,8 @@ Bool NetPacket::addFileAnnounceCommand(NetCommandRef *msg) { m_packetLen += sizeof(playerMask); ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -2663,7 +2660,7 @@ Bool NetPacket::isRoomForFileAnnounceMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte) + sizeof(UnsignedShort); } - ++len; // 'D' + ++len; // NetPacketFieldTypes::Data len += cmdMsg->getPortableFilename().getLength() + 1; // PORTABLE filename + the terminating 0 len += sizeof(UnsignedShort); // m_fileID len += sizeof(UnsignedByte); // m_playerMask @@ -2682,7 +2679,7 @@ Bool NetPacket::addFileProgressCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -2692,7 +2689,7 @@ Bool NetPacket::addFileProgressCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet + m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -2703,7 +2700,7 @@ Bool NetPacket::addFileProgressCommand(NetCommandRef *msg) { // If necessary put the player ID into the packet. if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -2714,7 +2711,7 @@ Bool NetPacket::addFileProgressCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -2723,7 +2720,7 @@ Bool NetPacket::addFileProgressCommand(NetCommandRef *msg) { m_lastCommandID = cmdMsg->getID(); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnsignedShort fileID = cmdMsg->getFileID(); @@ -2735,10 +2732,8 @@ Bool NetPacket::addFileProgressCommand(NetCommandRef *msg) { m_packetLen += sizeof(progress); ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -2765,7 +2760,7 @@ Bool NetPacket::isRoomForFileProgressMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte) + sizeof(UnsignedShort); } - ++len; // 'D' + ++len; // NetPacketFieldTypes::Data len += sizeof(UnsignedShort); // m_fileID len += sizeof(Int); // m_progress @@ -2783,7 +2778,7 @@ Bool NetPacket::addWrapperCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -2793,7 +2788,7 @@ Bool NetPacket::addWrapperCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet + m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -2804,7 +2799,7 @@ Bool NetPacket::addWrapperCommand(NetCommandRef *msg) { // If necessary put the player ID into the packet. if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -2815,7 +2810,7 @@ Bool NetPacket::addWrapperCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -2824,7 +2819,7 @@ Bool NetPacket::addWrapperCommand(NetCommandRef *msg) { m_lastCommandID = cmdMsg->getID(); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; // wrapped command ID @@ -2867,10 +2862,8 @@ Bool NetPacket::addWrapperCommand(NetCommandRef *msg) { m_packetLen += dataLength; ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -2897,7 +2890,7 @@ Bool NetPacket::isRoomForWrapperMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte) + sizeof(UnsignedShort); } - ++len; // 'D' + ++len; // NetPacketFieldTypes::Data len += sizeof(UnsignedShort); // wrapped command ID len += sizeof(UnsignedInt); // chunk number len += sizeof(UnsignedInt); // number of chunks @@ -2923,7 +2916,7 @@ Bool NetPacket::addTimeOutGameStartMessage(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -2933,7 +2926,7 @@ Bool NetPacket::addTimeOutGameStartMessage(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -2943,7 +2936,7 @@ Bool NetPacket::addTimeOutGameStartMessage(NetCommandRef *msg) { } if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -2954,7 +2947,7 @@ Bool NetPacket::addTimeOutGameStartMessage(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -2962,14 +2955,12 @@ Bool NetPacket::addTimeOutGameStartMessage(NetCommandRef *msg) { } m_lastCommandID = cmdMsg->getID(); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -2998,7 +2989,7 @@ Bool NetPacket::isRoomForTimeOutGameStartMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // For the 'D' + ++len; // For the NetPacketFieldTypes::Data if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; } @@ -3017,7 +3008,7 @@ Bool NetPacket::addLoadCompleteMessage(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -3027,7 +3018,7 @@ Bool NetPacket::addLoadCompleteMessage(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -3037,7 +3028,7 @@ Bool NetPacket::addLoadCompleteMessage(NetCommandRef *msg) { } if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -3048,7 +3039,7 @@ Bool NetPacket::addLoadCompleteMessage(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -3056,14 +3047,12 @@ Bool NetPacket::addLoadCompleteMessage(NetCommandRef *msg) { } m_lastCommandID = cmdMsg->getID(); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -3092,7 +3081,7 @@ Bool NetPacket::isRoomForLoadCompleteMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // For the 'D' + ++len; // For the NetPacketFieldTypes::Data if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; } @@ -3111,7 +3100,7 @@ Bool NetPacket::addProgressMessage(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -3121,7 +3110,7 @@ Bool NetPacket::addProgressMessage(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -3131,7 +3120,7 @@ Bool NetPacket::addProgressMessage(NetCommandRef *msg) { } if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -3139,17 +3128,15 @@ Bool NetPacket::addProgressMessage(NetCommandRef *msg) { m_lastPlayerID = cmdMsg->getPlayerID(); } - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPercentage(); ++m_packetLen; ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -3178,7 +3165,7 @@ Bool NetPacket::isRoomForProgressMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // For the 'D' + ++len; // For the NetPacketFieldTypes::Data ++len; // percentage if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; @@ -3199,7 +3186,7 @@ Bool NetPacket::addDisconnectVoteCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -3209,7 +3196,7 @@ Bool NetPacket::addDisconnectVoteCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -3221,7 +3208,7 @@ Bool NetPacket::addDisconnectVoteCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -3234,7 +3221,7 @@ Bool NetPacket::addDisconnectVoteCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -3244,7 +3231,7 @@ Bool NetPacket::addDisconnectVoteCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnsignedByte slot = cmdMsg->getSlot(); memcpy(m_packet + m_packetLen, &slot, sizeof(slot)); @@ -3257,10 +3244,8 @@ Bool NetPacket::addDisconnectVoteCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectVoteCommand - added disconnect vote command, player id %d command id %d, voted slot %d", m_lastPlayerID, m_lastCommandID, slot)); ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); return TRUE; @@ -3291,7 +3276,7 @@ Bool NetPacket::isRoomForDisconnectVoteMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // the 'D' + ++len; // the NetPacketFieldTypes::Data len += sizeof(UnsignedByte); // slot number len += sizeof(UnsignedInt); // vote frame @@ -3311,7 +3296,7 @@ Bool NetPacket::addDisconnectChatCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -3321,7 +3306,7 @@ Bool NetPacket::addDisconnectChatCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -3333,7 +3318,7 @@ Bool NetPacket::addDisconnectChatCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -3343,7 +3328,7 @@ Bool NetPacket::addDisconnectChatCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnicodeString unitext = cmdMsg->getText(); UnsignedByte length = unitext.getLength(); @@ -3356,10 +3341,8 @@ Bool NetPacket::addDisconnectChatCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket - added disconnect chat command")); ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); return TRUE; @@ -3382,7 +3365,7 @@ Bool NetPacket::isRoomForDisconnectChatMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // the 'D' + ++len; // the NetPacketFieldTypes::Data len += sizeof(UnsignedByte); // string length UnsignedByte textLen = cmdMsg->getText().getLength(); len += textLen * sizeof(UnsignedShort); @@ -3400,7 +3383,7 @@ Bool NetPacket::addChatCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -3410,7 +3393,7 @@ Bool NetPacket::addChatCommand(NetCommandRef *msg) { // If necessary, put the execution frame into the packet. if (m_lastFrame != cmdMsg->getExecutionFrame()) { - m_packet[m_packetLen] = 'F'; + m_packet[m_packetLen] = NetPacketFieldTypes::Frame; ++m_packetLen; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(m_packet+m_packetLen, &newframe, sizeof(UnsignedInt)); @@ -3421,7 +3404,7 @@ Bool NetPacket::addChatCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -3433,7 +3416,7 @@ Bool NetPacket::addChatCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -3446,7 +3429,7 @@ Bool NetPacket::addChatCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -3456,7 +3439,7 @@ Bool NetPacket::addChatCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnicodeString unitext = cmdMsg->getText(); UnsignedByte length = unitext.getLength(); @@ -3473,10 +3456,8 @@ Bool NetPacket::addChatCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket - added chat command")); ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); return TRUE; @@ -3507,7 +3488,7 @@ Bool NetPacket::isRoomForChatMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // the 'D' + ++len; // the NetPacketFieldTypes::Data len += sizeof(UnsignedByte); // string length UnsignedByte textLen = cmdMsg->getText().getLength(); len += textLen * sizeof(UnsignedShort); @@ -3526,7 +3507,7 @@ Bool NetPacket::addPacketRouterAckCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -3536,7 +3517,7 @@ Bool NetPacket::addPacketRouterAckCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -3548,7 +3529,7 @@ Bool NetPacket::addPacketRouterAckCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -3558,16 +3539,14 @@ Bool NetPacket::addPacketRouterAckCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket - added packet router ack command, player id %d", m_lastPlayerID)); ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); return TRUE; @@ -3593,7 +3572,7 @@ Bool NetPacket::isRoomForPacketRouterAckMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // the 'D' + ++len; // the NetPacketFieldTypes::Data if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; } @@ -3608,7 +3587,7 @@ Bool NetPacket::addPacketRouterQueryCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -3618,7 +3597,7 @@ Bool NetPacket::addPacketRouterQueryCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -3630,7 +3609,7 @@ Bool NetPacket::addPacketRouterQueryCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -3640,16 +3619,14 @@ Bool NetPacket::addPacketRouterQueryCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket - added packet router query command, player id %d", m_lastPlayerID)); ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); return TRUE; @@ -3675,7 +3652,7 @@ Bool NetPacket::isRoomForPacketRouterQueryMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // the 'D' + ++len; // the NetPacketFieldTypes::Data if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; } @@ -3693,7 +3670,7 @@ Bool NetPacket::addDisconnectPlayerCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -3703,7 +3680,7 @@ Bool NetPacket::addDisconnectPlayerCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -3715,7 +3692,7 @@ Bool NetPacket::addDisconnectPlayerCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -3728,7 +3705,7 @@ Bool NetPacket::addDisconnectPlayerCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -3738,7 +3715,7 @@ Bool NetPacket::addDisconnectPlayerCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnsignedByte slot = cmdMsg->getDisconnectSlot(); memcpy(m_packet + m_packetLen, &slot, sizeof(slot)); @@ -3751,10 +3728,8 @@ Bool NetPacket::addDisconnectPlayerCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectPlayerCommand - added disconnect player command, player id %d command id %d, disconnecting slot %d", m_lastPlayerID, m_lastCommandID, slot)); ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); return TRUE; @@ -3785,7 +3760,7 @@ Bool NetPacket::isRoomForDisconnectPlayerMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // the 'D' + ++len; // the NetPacketFieldTypes::Data len += sizeof(UnsignedByte); // slot number len += sizeof(UnsignedInt); // disconnectFrame if ((len + m_packetLen) > MAX_PACKET_SIZE) { @@ -3804,7 +3779,7 @@ Bool NetPacket::addDisconnectKeepAliveCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -3814,7 +3789,7 @@ Bool NetPacket::addDisconnectKeepAliveCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -3824,7 +3799,7 @@ Bool NetPacket::addDisconnectKeepAliveCommand(NetCommandRef *msg) { } if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -3832,14 +3807,12 @@ Bool NetPacket::addDisconnectKeepAliveCommand(NetCommandRef *msg) { m_lastPlayerID = cmdMsg->getPlayerID(); } - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -3868,7 +3841,7 @@ Bool NetPacket::isRoomForDisconnectKeepAliveMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // For the 'D' + ++len; // For the NetPacketFieldTypes::Data if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; } @@ -3884,7 +3857,7 @@ Bool NetPacket::addKeepAliveCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -3894,7 +3867,7 @@ Bool NetPacket::addKeepAliveCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -3904,7 +3877,7 @@ Bool NetPacket::addKeepAliveCommand(NetCommandRef *msg) { } if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -3912,14 +3885,12 @@ Bool NetPacket::addKeepAliveCommand(NetCommandRef *msg) { m_lastPlayerID = cmdMsg->getPlayerID(); } - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -3948,7 +3919,7 @@ Bool NetPacket::isRoomForKeepAliveMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // For the 'D' + ++len; // For the NetPacketFieldTypes::Data if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; } @@ -3966,7 +3937,7 @@ Bool NetPacket::addRunAheadCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -3976,7 +3947,7 @@ Bool NetPacket::addRunAheadCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -3987,7 +3958,7 @@ Bool NetPacket::addRunAheadCommand(NetCommandRef *msg) { // If necessary, put the execution frame into the packet. if (m_lastFrame != cmdMsg->getExecutionFrame()) { - m_packet[m_packetLen] = 'F'; + m_packet[m_packetLen] = NetPacketFieldTypes::Frame; ++m_packetLen; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(m_packet+m_packetLen, &newframe, sizeof(UnsignedInt)); @@ -3999,7 +3970,7 @@ Bool NetPacket::addRunAheadCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -4012,7 +3983,7 @@ Bool NetPacket::addRunAheadCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -4022,7 +3993,7 @@ Bool NetPacket::addRunAheadCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnsignedShort newRunAhead = cmdMsg->getRunAhead(); memcpy(m_packet + m_packetLen, &newRunAhead, sizeof(UnsignedShort)); @@ -4035,10 +4006,8 @@ Bool NetPacket::addRunAheadCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket - added run ahead command, frame %d, player id %d command id %d", m_lastFrame, m_lastPlayerID, m_lastCommandID)); ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); return TRUE; @@ -4072,7 +4041,7 @@ Bool NetPacket::isRoomForRunAheadMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // for 'D' + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedShort); len += sizeof(UnsignedByte); if ((len + m_packetLen) > MAX_PACKET_SIZE) { @@ -4091,7 +4060,7 @@ Bool NetPacket::addDestroyPlayerCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -4101,7 +4070,7 @@ Bool NetPacket::addDestroyPlayerCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -4112,7 +4081,7 @@ Bool NetPacket::addDestroyPlayerCommand(NetCommandRef *msg) { // If necessary, put the execution frame into the packet. if (m_lastFrame != cmdMsg->getExecutionFrame()) { - m_packet[m_packetLen] = 'F'; + m_packet[m_packetLen] = NetPacketFieldTypes::Frame; ++m_packetLen; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(m_packet+m_packetLen, &newframe, sizeof(UnsignedInt)); @@ -4124,7 +4093,7 @@ Bool NetPacket::addDestroyPlayerCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -4137,7 +4106,7 @@ Bool NetPacket::addDestroyPlayerCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -4147,7 +4116,7 @@ Bool NetPacket::addDestroyPlayerCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnsignedInt newVal = cmdMsg->getPlayerIndex(); memcpy(m_packet + m_packetLen, &newVal, sizeof(UnsignedInt)); @@ -4156,10 +4125,8 @@ Bool NetPacket::addDestroyPlayerCommand(NetCommandRef *msg) { //DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket - added CRC:0x%8.8X info command, frame %d, player id %d command id %d", newCRC, m_lastFrame, m_lastPlayerID, m_lastCommandID)); ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); return TRUE; @@ -4193,7 +4160,7 @@ Bool NetPacket::isRoomForDestroyPlayerMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // for 'D' + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedInt); if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; @@ -4212,7 +4179,7 @@ Bool NetPacket::addRunAheadMetricsCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -4222,7 +4189,7 @@ Bool NetPacket::addRunAheadMetricsCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -4234,7 +4201,7 @@ Bool NetPacket::addRunAheadMetricsCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -4247,7 +4214,7 @@ Bool NetPacket::addRunAheadMetricsCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -4257,7 +4224,7 @@ Bool NetPacket::addRunAheadMetricsCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; // write the average latency Real averageLatency = cmdMsg->getAverageLatency(); @@ -4268,10 +4235,7 @@ Bool NetPacket::addRunAheadMetricsCommand(NetCommandRef *msg) { memcpy(m_packet + m_packetLen, &averageFps, sizeof(averageFps)); m_packetLen += sizeof(averageFps); - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -4304,7 +4268,7 @@ Bool NetPacket::isRoomForRunAheadMetricsMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // 'D' + ++len; // NetPacketFieldTypes::Data len += sizeof(UnsignedShort); len += sizeof(Real); if ((len + m_packetLen) > MAX_PACKET_SIZE) { @@ -4325,7 +4289,7 @@ Bool NetPacket::addPlayerLeaveCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -4335,7 +4299,7 @@ Bool NetPacket::addPlayerLeaveCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -4346,7 +4310,7 @@ Bool NetPacket::addPlayerLeaveCommand(NetCommandRef *msg) { // If necessary, put the execution frame into the packet. if (m_lastFrame != cmdMsg->getExecutionFrame()) { - m_packet[m_packetLen] = 'F'; + m_packet[m_packetLen] = NetPacketFieldTypes::Frame; ++m_packetLen; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(m_packet+m_packetLen, &newframe, sizeof(UnsignedInt)); @@ -4358,7 +4322,7 @@ Bool NetPacket::addPlayerLeaveCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -4371,7 +4335,7 @@ Bool NetPacket::addPlayerLeaveCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -4381,16 +4345,13 @@ Bool NetPacket::addPlayerLeaveCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnsignedByte leavingPlayerID = cmdMsg->getLeavingPlayerID(); memcpy(m_packet + m_packetLen, &leavingPlayerID, sizeof(UnsignedByte)); m_packetLen += sizeof(UnsignedByte); - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -4426,7 +4387,7 @@ Bool NetPacket::isRoomForPlayerLeaveMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // for 'D' + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedByte); if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; @@ -4461,7 +4422,7 @@ Bool NetPacket::addFrameCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -4471,7 +4432,7 @@ Bool NetPacket::addFrameCommand(NetCommandRef *msg) { // If necessary, put the execution frame into the packet. if (m_lastFrame != cmdMsg->getExecutionFrame()) { - m_packet[m_packetLen] = 'F'; + m_packet[m_packetLen] = NetPacketFieldTypes::Frame; ++m_packetLen; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(m_packet+m_packetLen, &newframe, sizeof(UnsignedInt)); @@ -4482,7 +4443,7 @@ Bool NetPacket::addFrameCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -4494,7 +4455,7 @@ Bool NetPacket::addFrameCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -4507,7 +4468,7 @@ Bool NetPacket::addFrameCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -4517,7 +4478,7 @@ Bool NetPacket::addFrameCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnsignedShort cmdCount = cmdMsg->getCommandCount(); memcpy(m_packet + m_packetLen, &cmdCount, sizeof(UnsignedShort)); @@ -4526,10 +4487,7 @@ Bool NetPacket::addFrameCommand(NetCommandRef *msg) { // frameinfodebug // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("outgoing - added frame %d, player %d, command count = %d, command id = %d", cmdMsg->getExecutionFrame(), cmdMsg->getPlayerID(), cmdMsg->getCommandCount(), cmdMsg->getID())); - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -4565,7 +4523,7 @@ Bool NetPacket::isRoomForFrameMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // for 'D' + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedShort); if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; @@ -4632,9 +4590,8 @@ Bool NetPacket::addAckCommand(NetCommandRef *msg, UnsignedShort commandID, Unsig m_packet[m_packetLen] = 'Z'; ++m_packetLen; ++m_numCommands; - deleteInstance(m_lastCommand); - m_lastCommand = NULL; + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); return TRUE; @@ -4644,7 +4601,7 @@ Bool NetPacket::addAckCommand(NetCommandRef *msg, UnsignedShort commandID, Unsig // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addAckCommand - adding ack for command %d for player %d", cmdMsg->getCommandID(), msg->getCommand()->getPlayerID())); // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -4653,7 +4610,7 @@ Bool NetPacket::addAckCommand(NetCommandRef *msg, UnsignedShort commandID, Unsig } if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -4662,17 +4619,14 @@ Bool NetPacket::addAckCommand(NetCommandRef *msg, UnsignedShort commandID, Unsig } // Put in the command id of the command we are acking. - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; memcpy(m_packet + m_packetLen, &commandID, sizeof(UnsignedShort)); m_packetLen += sizeof(UnsignedShort); memcpy(m_packet + m_packetLen, &originalPlayerID, sizeof(UnsignedByte)); m_packetLen += sizeof(UnsignedByte); - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); @@ -4698,7 +4652,7 @@ Bool NetPacket::isRoomForAckMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // for 'D' + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedShort); len += sizeof(UnsignedByte); if ((len + m_packetLen) > MAX_PACKET_SIZE) { @@ -4789,7 +4743,7 @@ Bool NetPacket::addGameCommand(NetCommandRef *msg) { // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { - m_packet[m_packetLen] = 'T'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandType; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getNetCommandType(); m_packetLen += sizeof(UnsignedByte); @@ -4799,7 +4753,7 @@ Bool NetPacket::addGameCommand(NetCommandRef *msg) { // If necessary, put the execution frame into the packet. if (m_lastFrame != cmdMsg->getExecutionFrame()) { - m_packet[m_packetLen] = 'F'; + m_packet[m_packetLen] = NetPacketFieldTypes::Frame; ++m_packetLen; UnsignedInt newframe = cmdMsg->getExecutionFrame(); memcpy(m_packet+m_packetLen, &newframe, sizeof(UnsignedInt)); @@ -4810,7 +4764,7 @@ Bool NetPacket::addGameCommand(NetCommandRef *msg) { // If necessary, put the relay into the packet. if (m_lastRelay != msg->getRelay()) { - m_packet[m_packetLen] = 'R'; + m_packet[m_packetLen] = NetPacketFieldTypes::Relay; ++m_packetLen; UnsignedByte newRelay = msg->getRelay(); memcpy(m_packet+m_packetLen, &newRelay, sizeof(UnsignedByte)); @@ -4821,7 +4775,7 @@ Bool NetPacket::addGameCommand(NetCommandRef *msg) { // If necessary, put the playerID into the packet. if (m_lastPlayerID != cmdMsg->getPlayerID()) { - m_packet[m_packetLen] = 'P'; + m_packet[m_packetLen] = NetPacketFieldTypes::PlayerId; ++m_packetLen; m_packet[m_packetLen] = cmdMsg->getPlayerID(); m_packetLen += sizeof(UnsignedByte); @@ -4833,7 +4787,7 @@ Bool NetPacket::addGameCommand(NetCommandRef *msg) { // If necessary, specify the command ID of this command. if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { - m_packet[m_packetLen] = 'C'; + m_packet[m_packetLen] = NetPacketFieldTypes::CommandId; ++m_packetLen; UnsignedShort newID = cmdMsg->getID(); memcpy(m_packet + m_packetLen, &newID, sizeof(UnsignedShort)); @@ -4841,7 +4795,7 @@ Bool NetPacket::addGameCommand(NetCommandRef *msg) { } m_lastCommandID = cmdMsg->getID(); - m_packet[m_packetLen] = 'D'; + m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; // Now copy the GameMessage type into the packet. @@ -4882,20 +4836,15 @@ Bool NetPacket::addGameCommand(NetCommandRef *msg) { ++m_numCommands; - if (m_lastCommand != NULL) { - deleteInstance(m_lastCommand); - m_lastCommand = NULL; - } + deleteInstance(m_lastCommand); m_lastCommand = NEW_NETCOMMANDREF(msg->getCommand()); m_lastCommand->setRelay(msg->getRelay()); retval = TRUE; } - if (gmsg) { - deleteInstance(gmsg); - gmsg = NULL; - } + deleteInstance(gmsg); + gmsg = NULL; return retval; } @@ -4982,7 +4931,7 @@ Bool NetPacket::isRoomForGameMessage(NetCommandRef *msg, GameMessage *gmsg) { GameMessageParser *parser = newInstance(GameMessageParser)(gmsg); - ++msglen; // for 'D' + ++msglen; // for NetPacketFieldTypes::Data msglen += sizeof(GameMessage::Type); msglen += sizeof(UnsignedByte); // Int numTypes = parser->getNumTypes(); @@ -5064,32 +5013,32 @@ NetCommandList * NetPacket::getCommandList() { switch(m_packet[i]) { - case 'T': + case NetPacketFieldTypes::CommandType: ++i; memcpy(&commandType, m_packet + i, sizeof(UnsignedByte)); i += sizeof(UnsignedByte); break; - case 'F': + case NetPacketFieldTypes::Frame: ++i; memcpy(&frame, m_packet + i, sizeof(UnsignedInt)); i += sizeof(UnsignedInt); break; - case 'P': + case NetPacketFieldTypes::PlayerId: ++i; memcpy(&playerID, m_packet + i, sizeof(UnsignedByte)); i += sizeof(UnsignedByte); break; - case 'R': + case NetPacketFieldTypes::Relay: ++i; memcpy(&relay, m_packet + i, sizeof(UnsignedByte)); i += sizeof(UnsignedByte); break; - case 'C': + case NetPacketFieldTypes::CommandId: ++i; memcpy(&commandID, m_packet + i, sizeof(UnsignedShort)); i += sizeof(UnsignedShort); break; - case 'D': { + case NetPacketFieldTypes::Data: { ++i; NetCommandMsg *msg = NULL; @@ -5233,10 +5182,7 @@ NetCommandList * NetPacket::getCommandList() { DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::getCommandList - failed to set relay for message %d", msg->getID())); } - if (lastCommand != NULL) { - deleteInstance(lastCommand); - lastCommand = NULL; - } + deleteInstance(lastCommand); lastCommand = newInstance(NetCommandRef)(msg); msg->detach(); // Need to detach from new NetCommandMsg created by the "readXMessage" above. @@ -5311,7 +5257,6 @@ NetCommandList * NetPacket::getCommandList() { } deleteInstance(lastCommand); - lastCommand = NULL; // lastCommand = newInstance(NetCommandRef)(msg); lastCommand = NEW_NETCOMMANDREF(msg); @@ -5334,10 +5279,9 @@ NetCommandList * NetPacket::getCommandList() { } - if (lastCommand != NULL) { - deleteInstance(lastCommand); - lastCommand = NULL; - } + deleteInstance(lastCommand); + lastCommand = NULL; + return retval; } @@ -5863,15 +5807,10 @@ NetCommandMsg * NetPacket::readWrapperMessage(UnsignedByte *data, Int &i) { NetCommandMsg * NetPacket::readFileMessage(UnsignedByte *data, Int &i) { NetFileCommandMsg *msg = newInstance(NetFileCommandMsg); char filename[_MAX_PATH]; - char *c = filename; - while (data[i] != 0) { - *c = data[i]; - ++c; - ++i; - } - *c = 0; - ++i; + // TheSuperHackers @security Mauller/Jbremer/SkyAero 11/12/2025 Prevent buffer overflow when copying filepath string + i += strlcpy(filename, reinterpret_cast(data + i), ARRAY_SIZE(filename)); + ++i; //Increment for null terminator msg->setPortableFilename(AsciiString(filename)); // it's transferred as a portable filename UnsignedInt dataLength = 0; @@ -5890,15 +5829,10 @@ NetCommandMsg * NetPacket::readFileMessage(UnsignedByte *data, Int &i) { NetCommandMsg * NetPacket::readFileAnnounceMessage(UnsignedByte *data, Int &i) { NetFileAnnounceCommandMsg *msg = newInstance(NetFileAnnounceCommandMsg); char filename[_MAX_PATH]; - char *c = filename; - while (data[i] != 0) { - *c = data[i]; - ++c; - ++i; - } - *c = 0; - ++i; + // TheSuperHackers @security Mauller/Jbremer/SkyAero 11/12/2025 Prevent buffer overflow when copying filepath string + i += strlcpy(filename, reinterpret_cast(data + i), ARRAY_SIZE(filename)); + ++i; //Increment for null terminator msg->setPortableFilename(AsciiString(filename)); // it's transferred as a portable filename UnsignedShort fileID = 0; diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Network.cpp b/Core/GameEngine/Source/GameNetwork/Network.cpp similarity index 97% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/Network.cpp rename to Core/GameEngine/Source/GameNetwork/Network.cpp index 58e800d861..71d672cfed 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Network.cpp +++ b/Core/GameEngine/Source/GameNetwork/Network.cpp @@ -30,7 +30,7 @@ // SYSTEM INCLUDES //////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/GameEngine.h" #include "Common/MessageStream.h" @@ -112,10 +112,11 @@ class Network : public NetworkInterface Bool deinit( void ); ///< Shutdown connections, release memory void setLocalAddress(UnsignedInt ip, UnsignedInt port); - inline UnsignedInt getRunAhead(void) { return m_runAhead; } - inline UnsignedInt getFrameRate(void) { return m_frameRate; } + UnsignedInt getRunAhead(void) { return m_runAhead; } + UnsignedInt getFrameRate(void) { return m_frameRate; } UnsignedInt getPacketArrivalCushion(void); ///< Returns the smallest packet arrival cushion since this was last called. Bool isFrameDataReady( void ); + virtual Bool isStalling(); void parseUserList( const GameInfo *game ); void startGame(void); ///< Sets the network game frame counter to -1 @@ -206,6 +207,7 @@ class Network : public NetworkInterface __int64 m_nextFrameTime; ///< When did we execute the last frame? For slugging the GameLogic... Bool m_frameDataReady; ///< Is the frame data for the next frame ready to be executed by TheGameLogic? + Bool m_isStalling; // CRC info Bool m_checkCRCsThisFrame; @@ -263,14 +265,11 @@ NetworkInterface *NetworkInterface::createNetwork() */ Network::Network() { - //Added By Sadullah Nader - //Initializations inserted m_checkCRCsThisFrame = FALSE; m_didSelfSlug = FALSE; m_frameDataReady = FALSE; + m_isStalling = FALSE; m_sawCRCMismatch = FALSE; - // - m_conMgr = NULL; m_messageWindow = NULL; @@ -333,6 +332,7 @@ void Network::init() m_lastExecutionFrame = m_runAhead - 1; // subtract 1 since we're starting on frame 0 m_lastFrameCompleted = m_runAhead - 1; // subtract 1 since we're starting on frame 0 m_frameDataReady = FALSE; + m_isStalling = FALSE; m_didSelfSlug = FALSE; m_localStatus = NETLOCALSTATUS_PREGAME; @@ -665,7 +665,12 @@ void Network::processDestroyPlayerCommand(NetDestroyPlayerCommandMsg *msg) if (pPlayer) { GameMessage *msg = newInstance(GameMessage)(GameMessage::MSG_SELF_DESTRUCT); - msg->appendBooleanArgument(FALSE); +#if RETAIL_COMPATIBLE_CRC + const Bool transferAssets = FALSE; +#else + const Bool transferAssets = TRUE; +#endif + msg->appendBooleanArgument(transferAssets); msg->friend_setPlayerIndex(pPlayer->getPlayerIndex()); TheCommandList->appendMessage(msg); } @@ -686,6 +691,7 @@ void Network::update( void ) // 4. If all commands are there, put that frame's commands on TheCommandList. // m_frameDataReady = FALSE; + m_isStalling = FALSE; #if defined(RTS_DEBUG) if (m_networkOn == FALSE) { @@ -717,6 +723,11 @@ void Network::update( void ) m_frameDataReady = TRUE; // Tell the GameEngine to run the commands for the new frame. } } + else { + __int64 curTime; + QueryPerformanceCounter((LARGE_INTEGER *)&curTime); + m_isStalling = curTime >= m_nextFrameTime; + } } void Network::liteupdate() { @@ -740,7 +751,7 @@ void Network::endOfGameCheck() { if (m_conMgr != NULL) { if (m_conMgr->canILeave()) { m_conMgr->disconnectLocalPlayer(); - TheMessageStream->appendMessage(GameMessage::MSG_CLEAR_GAME_DATA); + TheGameLogic->exitGame(); m_localStatus = NETLOCALSTATUS_POSTGAME; DEBUG_LOG(("Network::endOfGameCheck - about to show the shell")); @@ -804,6 +815,11 @@ Bool Network::isFrameDataReady() { return (m_frameDataReady || (m_localStatus == NETLOCALSTATUS_LEFT)); } +Bool Network::isStalling() +{ + return m_isStalling; +} + /** * returns the number of incoming bytes per second averaged over the last 30 sec. */ @@ -926,11 +942,13 @@ void Network::quitGame() { m_conMgr->quitGame(); } +#if !RTS_GENERALS || !RETAIL_COMPATIBLE_CRC // Blow up / Transfer your units when you quit. Like a normal quit menu quit. GameMessage *msg = TheMessageStream->appendMessage(GameMessage::MSG_SELF_DESTRUCT); msg->appendBooleanArgument(TRUE); +#endif - TheMessageStream->appendMessage(GameMessage::MSG_CLEAR_GAME_DATA); + TheGameLogic->exitGame(); m_localStatus = NETLOCALSTATUS_POSTGAME; DEBUG_LOG(("Network::quitGame - quitting game...")); } diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetworkUtil.cpp b/Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp similarity index 96% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/NetworkUtil.cpp rename to Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp index 0b4a6bc707..4d04807d28 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/NetworkUtil.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp @@ -23,12 +23,15 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/networkutil.h" +// TheSuperHackers @tweak Mauller 26/08/2025 reduce the minimum runahead from 10 +// This lets network games run at latencies down to 133ms when the network conditions allow +Int MIN_LOGIC_FRAMES = 5; Int MAX_FRAMES_AHEAD = 128; -Int MIN_RUNAHEAD = 10; +Int MIN_RUNAHEAD = 4; Int FRAME_DATA_LENGTH = (MAX_FRAMES_AHEAD+1)*2; Int FRAMES_TO_KEEP = (MAX_FRAMES_AHEAD/2) + 1; diff --git a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Transport.cpp b/Core/GameEngine/Source/GameNetwork/Transport.cpp similarity index 98% rename from GeneralsMD/Code/GameEngine/Source/GameNetwork/Transport.cpp rename to Core/GameEngine/Source/GameNetwork/Transport.cpp index 0d5c7970c9..26c459f161 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameNetwork/Transport.cpp +++ b/Core/GameEngine/Source/GameNetwork/Transport.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// -#include "PreRTS.h" // This must go first in EVERY cpp file int the GameEngine +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "Common/crc.h" #include "GameNetwork/Transport.h" @@ -104,8 +104,7 @@ Bool Transport::init( UnsignedInt ip, UnsignedShort port ) } // ------- Bind our port -------- - if (m_udpsock) - delete m_udpsock; + delete m_udpsock; m_udpsock = NEW UDP(); if (!m_udpsock) @@ -162,11 +161,8 @@ Bool Transport::init( UnsignedInt ip, UnsignedShort port ) void Transport::reset( void ) { - if (m_udpsock) - { - delete m_udpsock; - m_udpsock = NULL; - } + delete m_udpsock; + m_udpsock = NULL; if (m_winsockInit) { @@ -243,7 +239,7 @@ Bool Transport::doSend() { //DEBUG_LOG(("Transport::doSend returning FALSE")); } } - } // for (i=0; i m_cachedHeroObjectList; //< cache of hero objects for drawing icons in radar overlay }; - - -#endif // __W3DRADAR_H_ diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h b/Core/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h similarity index 98% rename from GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h rename to Core/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h index 7e439de2da..9d3469a36b 100644 --- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h +++ b/Core/GameEngineDevice/Include/W3DDevice/GameClient/BaseHeightMap.h @@ -22,12 +22,8 @@ // // //////////////////////////////////////////////////////////////////////////////// - #pragma once -#ifndef __BASE_HEIGHTMAP_H_ -#define __BASE_HEIGHTMAP_H_ - #include "always.h" #include "rendobj.h" #include "w3d_file.h" @@ -38,7 +34,7 @@ #include "vertmaterial.h" #include "Lib/BaseType.h" #include "Common/GameType.h" -#include "WorldHeightMap.h" +#include "W3DDevice/GameClient/WorldHeightMap.h" #define MAX_ENABLED_DYNAMIC_LIGHTS 20 typedef UnsignedByte HeightSampleType; //type of data to store in heightmap @@ -137,7 +133,7 @@ class BaseHeightMapRenderObjClass : public RenderObjClass, public DX8_CleanupHoo } - inline UnsignedByte getClipHeight(Int x, Int y) const + UnsignedByte getClipHeight(Int x, Int y) const { Int xextent = m_map->getXExtent() - 1; Int yextent = m_map->getYExtent() - 1; @@ -328,7 +324,8 @@ class BaseHeightMapRenderObjClass : public RenderObjClass, public DX8_CleanupHoo void initDestAlphaLUT(void); /// - #include "Lib/BaseType.h" #include "WWLib/refcount.h" #include "Common/AsciiString.h" @@ -104,5 +99,3 @@ class TileData : public RefCountClass Bool hasRGBDataForWidth(Int width); UnsignedByte *getRGBDataForWidth(Int width); }; - -#endif diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DPropBuffer.h b/Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DPropBuffer.h similarity index 98% rename from GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DPropBuffer.h rename to Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DPropBuffer.h index 2c2d0106ac..bab5e660b7 100644 --- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DPropBuffer.h +++ b/Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DPropBuffer.h @@ -44,9 +44,6 @@ #pragma once -#ifndef __W3DPROP_BUFFER_H_ -#define __W3DPROP_BUFFER_H_ - //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- @@ -149,5 +146,3 @@ friend class BaseHeightMapRenderObjClass; void cull(CameraClass * camera); ///< Culls the props. }; - -#endif // end __W3DPROP_BUFFER_H_ diff --git a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h b/Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h similarity index 97% rename from GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h rename to Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h index 3f91cc01ab..90192607a4 100644 --- a/GeneralsMD/Code/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h +++ b/Core/GameEngineDevice/Include/W3DDevice/GameClient/W3DShaderManager.h @@ -33,9 +33,6 @@ #pragma once -#ifndef __W3DSHADERMANAGER_H_ -#define __W3DSHADERMANAGER_H_ - #include "WW3D2/texture.h" enum FilterTypes CPP_11(: Int); enum FilterModes CPP_11(: Int); @@ -81,6 +78,8 @@ class W3DShaderManager W3DShaderManager(void); /// VecICoord2D; @@ -232,20 +229,20 @@ class WorldHeightMap : public RefCountClass, Int getXExtent(void) {return m_width;} ///m_width) m_drawWidthX = m_width;} - inline void setDrawHeight(Int height) {m_drawHeightY = height; if (m_drawHeightY>m_height) m_drawHeightY = m_height;} + Int getDrawWidth(void) {return m_drawWidthX;} + Int getDrawHeight(void) {return m_drawHeightY;} + void setDrawWidth(Int width) {m_drawWidthX = width; if (m_drawWidthX>m_width) m_drawWidthX = m_width;} + void setDrawHeight(Int height) {m_drawHeightY = height; if (m_drawHeightY>m_height) m_drawHeightY = m_height;} virtual Int getBorderSize(void) {return m_borderSize;} - inline Int getBorderSizeInline(void) const { return m_borderSize; } + Int getBorderSizeInline(void) const { return m_borderSize; } /// Get height with the offset that HeightMapRenderObjClass uses built in. - inline UnsignedByte getDisplayHeight(Int x, Int y) { return m_data[x+m_drawOriginX+m_width*(y+m_drawOriginY)];} + UnsignedByte getDisplayHeight(Int x, Int y) { return m_data[x+m_drawOriginX+m_width*(y+m_drawOriginY)];} /// Get height in normal coordinates. - inline UnsignedByte getHeight(Int xIndex, Int yIndex) + UnsignedByte getHeight(Int xIndex, Int yIndex) { Int ndx = (yIndex*m_width)+xIndex; if ((ndx>=0) && (ndx> 3)] & (1<<(xIndex&0x7)); } @@ -320,5 +317,3 @@ class WorldHeightMap : public RefCountClass, void setCliffState(Int xIndex, Int yIndex, Bool state); }; - -#endif diff --git a/Core/GameEngineDevice/Include/Win32Device/Common/Win32BIGFile.h b/Core/GameEngineDevice/Include/Win32Device/Common/Win32BIGFile.h index 13ca71c726..6d77772bbd 100644 --- a/Core/GameEngineDevice/Include/Win32Device/Common/Win32BIGFile.h +++ b/Core/GameEngineDevice/Include/Win32Device/Common/Win32BIGFile.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __WIN32BIGFILE_H -#define __WIN32BIGFILE_H - #include "Common/ArchiveFile.h" #include "Common/AsciiString.h" #include "Common/List.h" @@ -38,7 +35,7 @@ class Win32BIGFile : public ArchiveFile { public: - Win32BIGFile(); + Win32BIGFile(AsciiString name, AsciiString path); virtual ~Win32BIGFile(); virtual Bool getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const; ///< fill in the fileInfo struct with info about the requested file. @@ -54,5 +51,3 @@ class Win32BIGFile : public ArchiveFile AsciiString m_name; ///< BIG file name AsciiString m_path; ///< BIG file path }; - -#endif // __WIN32BIGFILE_H diff --git a/Core/GameEngineDevice/Include/Win32Device/Common/Win32BIGFileSystem.h b/Core/GameEngineDevice/Include/Win32Device/Common/Win32BIGFileSystem.h index a0643b3ae9..fbad69d1ce 100644 --- a/Core/GameEngineDevice/Include/Win32Device/Common/Win32BIGFileSystem.h +++ b/Core/GameEngineDevice/Include/Win32Device/Common/Win32BIGFileSystem.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __WIN32BIGFILESYSTEM_H -#define __WIN32BIGFILESYSTEM_H - #include "Common/ArchiveFileSystem.h" class Win32BIGFileSystem : public ArchiveFileSystem @@ -56,5 +53,3 @@ class Win32BIGFileSystem : public ArchiveFileSystem protected: }; - -#endif // __WIN32BIGFILESYSTEM_H diff --git a/Core/GameEngineDevice/Include/Win32Device/Common/Win32LocalFile.h b/Core/GameEngineDevice/Include/Win32Device/Common/Win32LocalFile.h index dda97c40ad..43faf6ea80 100644 --- a/Core/GameEngineDevice/Include/Win32Device/Common/Win32LocalFile.h +++ b/Core/GameEngineDevice/Include/Win32Device/Common/Win32LocalFile.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __WIN32LOCALFILE_H -#define __WIN32LOCALFILE_H - #include "Common/LocalFile.h" class Win32LocalFile : public LocalFile @@ -42,5 +39,3 @@ class Win32LocalFile : public LocalFile protected: }; - -#endif // __WIN32LOCALFILE_H diff --git a/Core/GameEngineDevice/Include/Win32Device/Common/Win32LocalFileSystem.h b/Core/GameEngineDevice/Include/Win32Device/Common/Win32LocalFileSystem.h index 52f3bda1e2..7adf424986 100644 --- a/Core/GameEngineDevice/Include/Win32Device/Common/Win32LocalFileSystem.h +++ b/Core/GameEngineDevice/Include/Win32Device/Common/Win32LocalFileSystem.h @@ -28,8 +28,6 @@ #pragma once -#ifndef __WIN32LOCALFILESYSTEM_H -#define __WIN32LOCALFILESYSTEM_H #include "Common/LocalFileSystem.h" class Win32LocalFileSystem : public LocalFileSystem @@ -53,5 +51,3 @@ class Win32LocalFileSystem : public LocalFileSystem protected: }; - -#endif // __WIN32LOCALFILESYSTEM_H diff --git a/Core/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp b/Core/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp index 7b31050aba..015e793cec 100644 --- a/Core/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp +++ b/Core/GameEngineDevice/Source/MilesAudioDevice/MilesAudioManager.cpp @@ -74,10 +74,10 @@ static void AILCALLBACK setSampleCompleted( HSAMPLE sampleCompleted ); static void AILCALLBACK set3DSampleCompleted( H3DSAMPLE sample3DCompleted ); static void AILCALLBACK setStreamCompleted( HSTREAM streamCompleted ); -static U32 AILCALLBACK streamingFileOpen(char const *fileName, U32 *file_handle); -static void AILCALLBACK streamingFileClose(U32 fileHandle); -static S32 AILCALLBACK streamingFileSeek(U32 fileHandle, S32 offset, U32 type); -static U32 AILCALLBACK streamingFileRead(U32 fileHandle, void *buffer, U32 bytes); +static U32 AILCALLBACK streamingFileOpen(char const *fileName, void **file_handle); +static void AILCALLBACK streamingFileClose(void *fileHandle); +static S32 AILCALLBACK streamingFileSeek(void *fileHandle, S32 offset, U32 type); +static U32 AILCALLBACK streamingFileRead(void *fileHandle, void *buffer, U32 bytes); //------------------------------------------------------------------------------------------------- MilesAudioManager::MilesAudioManager() : @@ -235,7 +235,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL continue; } - playingArray[AIL_sample_user_data(playing->m_sample, 0)] = playing; + playingArray[(int)AIL_sample_user_data(playing->m_sample, 0)] = playing; } for (Int i = 1; i <= maxChannels && i <= channelCount; ++i) { @@ -296,7 +296,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL continue; } - playingArray[AIL_3D_user_data(playing->m_3DSample, 0)] = playing; + playingArray[(int)AIL_3D_user_data(playing->m_3DSample, 0)] = playing; } for (Int i = 1; i <= maxChannels && i <= channelCount; ++i) @@ -3021,7 +3021,7 @@ void MilesAudioManager::initSamplePools( void ) DEBUG_ASSERTCRASH(sample, ("Couldn't get %d 2D samples", i + 1)); if (sample) { AIL_init_sample(sample); - AIL_set_sample_user_data(sample, 0, i + 1); + AIL_set_sample_user_data(sample, 0, (void *)(i + 1)); m_availableSamples.push_back(sample); ++m_num2DSamples; } @@ -3031,7 +3031,7 @@ void MilesAudioManager::initSamplePools( void ) H3DSAMPLE sample = AIL_allocate_3D_sample_handle(m_provider3D[m_selectedProvider].id); DEBUG_ASSERTCRASH(sample, ("Couldn't get %d 3D samples", i + 1)); if (sample) { - AIL_set_3D_user_data(sample, 0, i + 1); + AIL_set_3D_user_data(sample, 0, (void *)(i + 1)); m_available3DSamples.push_back(sample); ++m_num3DSamples; } @@ -3167,7 +3167,7 @@ void AILCALLBACK setStreamCompleted( HSTREAM streamCompleted ) } //------------------------------------------------------------------------------------------------- -U32 AILCALLBACK streamingFileOpen(char const *fileName, U32 *file_handle) +U32 AILCALLBACK streamingFileOpen(char const *fileName, void **file_handle) { #if defined(RTS_DEBUG) if (sizeof(U32) != sizeof(File*)) { @@ -3175,24 +3175,24 @@ U32 AILCALLBACK streamingFileOpen(char const *fileName, U32 *file_handle) } #endif - (*file_handle) = (U32) TheFileSystem->openFile(fileName, File::READ | File::STREAMING); + (*file_handle) = (void *) TheFileSystem->openFile(fileName, File::READ | File::STREAMING); return ((*file_handle) != 0); } //------------------------------------------------------------------------------------------------- -void AILCALLBACK streamingFileClose(U32 fileHandle) +void AILCALLBACK streamingFileClose(void *fileHandle) { ((File*) fileHandle)->close(); } //------------------------------------------------------------------------------------------------- -S32 AILCALLBACK streamingFileSeek(U32 fileHandle, S32 offset, U32 type) +S32 AILCALLBACK streamingFileSeek(void *fileHandle, S32 offset, U32 type) { return ((File*) fileHandle)->seek(offset, (File::seekMode) type); } //------------------------------------------------------------------------------------------------- -U32 AILCALLBACK streamingFileRead(U32 file_handle, void *buffer, U32 bytes) +U32 AILCALLBACK streamingFileRead(void *file_handle, void *buffer, U32 bytes) { return ((File*) file_handle)->read(buffer, bytes); } diff --git a/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFile.cpp b/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFile.cpp index df81f0bb33..1c988d1298 100644 --- a/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFile.cpp +++ b/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFile.cpp @@ -38,7 +38,9 @@ // StdBIGFile::StdBIGFile //============================================================================ -StdBIGFile::StdBIGFile() +StdBIGFile::StdBIGFile(AsciiString name, AsciiString path) + : m_name(name) + , m_path(path) { } @@ -86,7 +88,7 @@ File* StdBIGFile::openFile( const Char *filename, Int access ) // whoever is opening this file wants write access, so copy the file to the local disk // and return that file pointer. - CONSTEXPR size_t bufferSize = 0; + constexpr size_t bufferSize = 0; File *localFile = TheLocalFileSystem->openFile(filename, access, bufferSize); if (localFile != NULL) { ramFile->copyDataToFile(localFile); diff --git a/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp b/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp index 8a867f6e59..13f7045bb8 100644 --- a/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp +++ b/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp @@ -63,8 +63,8 @@ void StdBIGFileSystem::init() { AsciiString installPath; GetStringFromGeneralsRegistry("", "InstallPath", installPath ); //@todo this will need to be ramped up to a crash for release - DEBUG_ASSERTCRASH(installPath != "", ("Be 1337! Go install Generals!")); - if (installPath!="") + DEBUG_ASSERTCRASH(!installPath.isEmpty(), ("Be 1337! Go install Generals!")); + if (!installPath.isEmpty()) loadBigFilesFromDirectory(installPath, "*.big"); #endif } @@ -86,7 +86,7 @@ ArchiveFile * StdBIGFileSystem::openArchiveFile(const Char *filename) { Int archiveFileSize = 0; Int numLittleFiles = 0; - ArchiveFile *archiveFile = NEW StdBIGFile; + ArchiveFile *archiveFile = NEW StdBIGFile(filename, AsciiString::TheEmptyString); DEBUG_LOG(("StdBIGFileSystem::openArchiveFile - opening BIG file %s", filename)); @@ -210,16 +210,26 @@ void StdBIGFileSystem::closeAllFiles() { Bool StdBIGFileSystem::loadBigFilesFromDirectory(AsciiString dir, AsciiString fileMask, Bool overwrite) { FilenameList filenameList; - TheLocalFileSystem->getFileListInDirectory(dir, AsciiString(""), fileMask, filenameList, TRUE); + TheLocalFileSystem->getFileListInDirectory(dir, "", fileMask, filenameList, TRUE); Bool actuallyAdded = FALSE; FilenameListIter it = filenameList.begin(); while (it != filenameList.end()) { +#if RTS_ZEROHOUR + // TheSuperHackers @bugfix bobtista 18/11/2025 Skip duplicate INIZH.big in Data\INI to prevent CRC mismatches. + // English, Chinese, and Korean SKUs shipped with two INIZH.big files (one in Run directory, one in Run\Data\INI). + // The DeleteFile cleanup doesn't work on EA App/Origin installs because the folder is not writable, so we skip loading it instead. + if (it->endsWithNoCase("Data\\INI\\INIZH.big") || it->endsWithNoCase("Data/INI/INIZH.big")) { + it++; + continue; + } +#endif + ArchiveFile *archiveFile = openArchiveFile((*it).str()); if (archiveFile != NULL) { DEBUG_LOG(("StdBIGFileSystem::loadBigFilesFromDirectory - loading %s into the directory tree.", (*it).str())); - loadIntoDirectoryTree(archiveFile, *it, overwrite); + loadIntoDirectoryTree(archiveFile, overwrite); m_archiveFileMap[(*it)] = archiveFile; DEBUG_LOG(("StdBIGFileSystem::loadBigFilesFromDirectory - %s inserted into the archive file map.", (*it).str())); actuallyAdded = TRUE; diff --git a/Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp b/Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp index 9cacda79bf..119cd94a35 100644 --- a/Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp +++ b/Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp @@ -211,7 +211,6 @@ Bool StdLocalFileSystem::doesFileExist(const Char *filename) const void StdLocalFileSystem::getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList & filenameList, Bool searchSubdirectories) const { - char search[_MAX_PATH]; AsciiString asciisearch; asciisearch = originalDirectory; asciisearch.concat(currentDirectory); @@ -227,24 +226,22 @@ void StdLocalFileSystem::getFileListInDirectory(const AsciiString& currentDirect std::replace(fixedDirectory.begin(), fixedDirectory.end(), '\\', '/'); #endif - strcpy(search, fixedDirectory.c_str()); - Bool done = FALSE; std::error_code ec; - auto iter = std::filesystem::directory_iterator(search, ec); + auto iter = std::filesystem::directory_iterator(fixedDirectory.c_str(), ec); // The default iterator constructor creates an end iterator done = iter == std::filesystem::directory_iterator(); if (ec) { - DEBUG_LOG(("StdLocalFileSystem::getFileListInDirectory - Error opening directory %s", search)); + DEBUG_LOG(("StdLocalFileSystem::getFileListInDirectory - Error opening directory %s", fixedDirectory.c_str())); return; } while (!done) { std::string filenameStr = iter->path().filename().string(); if (!iter->is_directory() && iter->path().extension() == searchExt && - (strcmp(filenameStr.c_str(), ".") && strcmp(filenameStr.c_str(), ".."))) { + (strcmp(filenameStr.c_str(), ".") != 0 && strcmp(filenameStr.c_str(), "..") != 0)) { // if we haven't already, add this filename to the list. // a stl set should only allow one copy of each filename AsciiString newFilename = iter->path().string().c_str(); @@ -271,7 +268,7 @@ void StdLocalFileSystem::getFileListInDirectory(const AsciiString& currentDirect while (!done) { std::string filenameStr = iter->path().filename().string(); if(iter->is_directory() && - (strcmp(filenameStr.c_str(), ".") && strcmp(filenameStr.c_str(), ".."))) { + (strcmp(filenameStr.c_str(), ".") != 0 && strcmp(filenameStr.c_str(), "..") != 0)) { AsciiString tempsearchstr(filenameStr.c_str()); // recursively add files in subdirectories if required. @@ -326,7 +323,7 @@ Bool StdLocalFileSystem::createDirectory(AsciiString directory) std::replace(fixedDirectory.begin(), fixedDirectory.end(), '\\', '/'); #endif - if ((fixedDirectory.length() > 0) && (fixedDirectory.length() < _MAX_DIR)) { + if ((!fixedDirectory.empty()) && (fixedDirectory.length() < _MAX_DIR)) { // Convert to host path std::filesystem::path path(std::move(fixedDirectory)); diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp b/Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp similarity index 91% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp rename to Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp index 3e351de54a..21aea05038 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp @@ -32,6 +32,7 @@ #include "Common/AudioEventRTS.h" #include "Common/Debug.h" #include "Common/GlobalData.h" +#include "Common/GameUtility.h" #include "Common/Player.h" #include "Common/PlayerList.h" @@ -40,6 +41,7 @@ #include "GameLogic/Object.h" #include "GameClient/Color.h" +#include "GameClient/ControlBar.h" #include "GameClient/Display.h" #include "GameClient/GameClient.h" #include "GameClient/GameWindow.h" @@ -83,9 +85,9 @@ static WW3DFormat findFormat(const WW3DFormat formats[]) return formats[ i ]; - } // end if + } - } // end for i + } DEBUG_CRASH(("WW3DRadar: No appropriate texture format") ); return WW3D_FORMAT_UNKNOWN; } @@ -127,7 +129,7 @@ void W3DRadar::initializeTextureFormats( void ) // find a format for the shroud texture m_shroudTextureFormat = findFormat(shroudFormats); -} // end initializeTextureFormats +} //------------------------------------------------------------------------------------------------- /** Delete resources used specifically in this W3D radar implemetation */ @@ -141,8 +143,8 @@ void W3DRadar::deleteResources( void ) if( m_terrainTexture ) m_terrainTexture->Release_Ref(); m_terrainTexture = NULL; - if( m_terrainImage ) - deleteInstance(m_terrainImage); + + deleteInstance(m_terrainImage); m_terrainImage = NULL; // @@ -151,8 +153,8 @@ void W3DRadar::deleteResources( void ) if( m_overlayTexture ) m_overlayTexture->Release_Ref(); m_overlayTexture = NULL; - if( m_overlayImage ) - deleteInstance(m_overlayImage); + + deleteInstance(m_overlayImage); m_overlayImage = NULL; // @@ -161,11 +163,11 @@ void W3DRadar::deleteResources( void ) if( m_shroudTexture ) m_shroudTexture->Release_Ref(); m_shroudTexture = NULL; - if( m_shroudImage ) - deleteInstance(m_shroudImage); + + deleteInstance(m_shroudImage); m_shroudImage = NULL; -} // end deleteResources +} //------------------------------------------------------------------------------------------------- /** Reconstruct the view box given the current camera settings */ @@ -201,16 +203,16 @@ void W3DRadar::reconstructViewBox( void ) m_viewBox[ i ].x = 0; m_viewBox[ i ].y = 0; - } // end if + } else { m_viewBox[ i ].x = radar[ i ].x - radar[ i - 1 ].x; m_viewBox[ i ].y = radar[ i ].y - radar[ i - 1 ].y; - } // end else + } - } // end for i + } // // save the camera settings for this view box, we will need to make it again only @@ -222,7 +224,7 @@ void W3DRadar::reconstructViewBox( void ) m_viewZoom = TheTacticalView->getZoom(); m_reconstructViewBox = FALSE; -} // end reconstructViewBox +} //------------------------------------------------------------------------------------------------- /** Convert radar position to actual pixel coord */ @@ -240,7 +242,7 @@ void W3DRadar::radarToPixel( const ICoord2D *radar, ICoord2D *pixel, // note the "inverted" y here to orient the way our world looks with +x=right and -y=down pixel->y = ((RADAR_CELL_HEIGHT - 1 - radar->y) * radarHeight / RADAR_CELL_HEIGHT) + radarUpperLeftY; -} // end radarToPixel +} //------------------------------------------------------------------------------------------------- @@ -359,7 +361,7 @@ void W3DRadar::drawViewBox( Int pixelX, Int pixelY, Int width, Int height ) TheDisplay->drawLine( clipStart.x, clipStart.y, clipEnd.x, clipEnd.y, lineWidth, bottomColor, topColor ); -} // end drawViewBox +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -391,7 +393,7 @@ void W3DRadar::drawSingleBeaconEvent( Int pixelX, Int pixelY, Int width, Int hei frameDiff = currentFrame - event->createFrame; // compute the size of the event marker, it is largest when it starts and smallest at the end - eventSize = REAL_TO_INT( maxEventSize * ( 1.0f - frameDiff / TIME_FROM_FULL_SIZE_TO_SMALL_SIZE) );; + eventSize = REAL_TO_INT( maxEventSize * ( 1.0f - frameDiff / TIME_FROM_FULL_SIZE_TO_SMALL_SIZE) ); // we never let the event size get too small if( eventSize < minEventSize ) @@ -434,7 +436,7 @@ void W3DRadar::drawSingleBeaconEvent( Int pixelX, Int pixelY, Int width, Int hei a = REAL_TO_UNSIGNEDBYTE( (Real)a * (1.0f - (Real)(currentFrame - event->fadeFrame) / (Real)(event->dieFrame - event->fadeFrame) ) ); - } // end if + } startColor = GameMakeColor( r, g, b, a ); // color 2 ------------------ @@ -448,7 +450,7 @@ void W3DRadar::drawSingleBeaconEvent( Int pixelX, Int pixelY, Int width, Int hei a = REAL_TO_UNSIGNEDBYTE( (Real)a * (1.0f - (Real)(currentFrame - event->fadeFrame) / (Real)(event->dieFrame - event->fadeFrame) ) ); - } // end if + } endColor = GameMakeColor( r, g, b, a ); // draw the lines @@ -490,7 +492,7 @@ void W3DRadar::drawSingleGenericEvent( Int pixelX, Int pixelY, Int width, Int he frameDiff = currentFrame - event->createFrame; // compute the size of the event marker, it is largest when it starts and smallest at the end - eventSize = REAL_TO_INT( maxEventSize * ( 1.0f - frameDiff / TIME_FROM_FULL_SIZE_TO_SMALL_SIZE) );; + eventSize = REAL_TO_INT( maxEventSize * ( 1.0f - frameDiff / TIME_FROM_FULL_SIZE_TO_SMALL_SIZE) ); // we never let the event size get too small if( eventSize < minEventSize ) @@ -533,7 +535,7 @@ void W3DRadar::drawSingleGenericEvent( Int pixelX, Int pixelY, Int width, Int he a = REAL_TO_UNSIGNEDBYTE( (Real)a * (1.0f - (Real)(currentFrame - event->fadeFrame) / (Real)(event->dieFrame - event->fadeFrame) ) ); - } // end if + } startColor = GameMakeColor( r, g, b, a ); // color 2 ------------------ @@ -547,7 +549,7 @@ void W3DRadar::drawSingleGenericEvent( Int pixelX, Int pixelY, Int width, Int he a = REAL_TO_UNSIGNEDBYTE( (Real)a * (1.0f - (Real)(currentFrame - event->fadeFrame) / (Real)(event->dieFrame - event->fadeFrame) ) ); - } // end if + } endColor = GameMakeColor( r, g, b, a ); // draw the lines @@ -579,7 +581,7 @@ void W3DRadar::drawEvents( Int pixelX, Int pixelY, Int width, Int height ) static AudioEventRTS eventSound("RadarEvent"); TheAudio->addAudioEvent( &eventSound ); - } // end if + } m_event[ i ].soundPlayed = TRUE; @@ -588,11 +590,11 @@ void W3DRadar::drawEvents( Int pixelX, Int pixelY, Int width, Int height ) else drawSingleGenericEvent( pixelX, pixelY, width, height, i ); - } // end if + } - } // end for i + } -} // end drawEvents +} //------------------------------------------------------------------------------------------------- @@ -600,109 +602,125 @@ void W3DRadar::drawEvents( Int pixelX, Int pixelY, Int width, Int height ) //------------------------------------------------------------------------------------------------- void W3DRadar::drawIcons( Int pixelX, Int pixelY, Int width, Int height ) { - // draw the hero icons - std::vector::const_iterator iter = m_cachedHeroObjectList.begin(); - while (iter != m_cachedHeroObjectList.end()) + Player *player = rts::getObservedOrLocalPlayer(); + for (RadarObject *heroObj = m_localHeroObjectList; heroObj; heroObj = heroObj->friend_getNext()) { - drawHeroIcon( pixelX, pixelY, width, height, (*iter)->getPosition() ); - ++iter; + if (canRenderObject(heroObj, player)) + { + drawHeroIcon(pixelX, pixelY, width, height, heroObj->friend_getObject()->getPosition()); + } } } //------------------------------------------------------------------------------------------------- -/** Render an object list into the texture passed in */ //------------------------------------------------------------------------------------------------- -void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *texture, Bool calcHero ) +void W3DRadar::updateObjectTexture(TextureClass *texture) { + // reset the overlay texture + SurfaceClass *surface = texture->Get_Surface_Level(); + surface->Clear(); + REF_PTR_RELEASE(surface); - // sanity - if( listHead == NULL || texture == NULL ) - return; + // rebuild the object overlay + renderObjectList( m_objectList, texture ); + renderObjectList( m_localObjectList, texture ); + renderObjectList( m_localHeroObjectList, texture ); +} - // get surface for texture to render into - SurfaceClass *surface = texture->Get_Surface_Level(); +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +Bool W3DRadar::canRenderObject( const RadarObject *rObj, const Player *localPlayer ) +{ + if (rObj->isTemporarilyHidden()) + { + return false; + } - // loop through all objects and draw - ICoord2D radarPoint; + const Int playerIndex = localPlayer->getPlayerIndex(); + const Object *obj = rObj->friend_getObject(); - Player *player = ThePlayerList->getLocalPlayer(); - Int playerIndex=0; - if (player) - playerIndex=player->getPlayerIndex(); + // + // check for shrouded status + // if object is fogged or shrouded, don't render it + // + if (obj->getShroudedStatus(playerIndex) > OBJECTSHROUD_PARTIAL_CLEAR) + { + return false; + } - if( calcHero ) + // + // objects with a local only unit priority will only appear on the radar if they + // are controlled by the local player, or if the local player is an observer (cause + // they are godlike and can see everything) + // + if (obj->getRadarPriority() == RADAR_PRIORITY_LOCAL_UNIT_ONLY && + obj->getControllingPlayer() != localPlayer && + localPlayer->isPlayerActive() ) { - // clear all entries from the cached hero object list - m_cachedHeroObjectList.clear(); + return false; } - for( const RadarObject *rObj = listHead; rObj; rObj = rObj->friend_getNext() ) + // + // ML-- What the heck is this? local-only and neutral-observer-viewed units are stealthy?? Since when? + // Now it twinkles for any stealthed object, whether locally controlled or neutral-observer-viewed + // + if (TheControlBar->getCurrentlyViewedPlayerRelationship(obj->getTeam()) == ENEMIES && + obj->testStatus( OBJECT_STATUS_STEALTHED ) && + !obj->testStatus( OBJECT_STATUS_DETECTED ) && + !obj->testStatus( OBJECT_STATUS_DISGUISED ) ) { + return false; + } - if (rObj->isTemporarilyHidden()) - continue; + return true; +} - // get object - const Object *obj = rObj->friend_getObject(); +//------------------------------------------------------------------------------------------------- +/** Render an object list into the texture passed in */ +//------------------------------------------------------------------------------------------------- +void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *texture ) +{ - // cache hero objects for drawing in icon layer - if( calcHero && obj->isHero() ) - { - m_cachedHeroObjectList.push_back(obj); - } - Bool skip = FALSE; + // sanity + if( listHead == NULL || texture == NULL ) + return; - // check for shrouded status - if (obj->getShroudedStatus(playerIndex) > OBJECTSHROUD_PARTIAL_CLEAR) - skip = TRUE; //object is fogged or shrouded, don't render it. + // get surface for texture to render into + SurfaceClass *surface = texture->Get_Surface_Level(); - // - // objects with a local only unit priority will only appear on the radar if they - // are controlled by the local player, or if the local player is an observer (cause - // they are godlike and can see everything) - // + // loop through all objects and draw + ICoord2D radarPoint; + Player *player = rts::getObservedOrLocalPlayer(); - if( obj->getRadarPriority() == RADAR_PRIORITY_LOCAL_UNIT_ONLY && - obj->getControllingPlayer() != ThePlayerList->getLocalPlayer() && - ThePlayerList->getLocalPlayer()->isPlayerActive() ) - skip = TRUE; + for( const RadarObject *rObj = listHead; rObj; rObj = rObj->friend_getNext() ) + { + if (!canRenderObject(rObj, player)) + continue; // get object position + const Object *obj = rObj->friend_getObject(); const Coord3D *pos = obj->getPosition(); // compute object position as a radar blip radarPoint.x = pos->x / (m_mapExtent.width() / RADAR_CELL_WIDTH); radarPoint.y = pos->y / (m_mapExtent.height() / RADAR_CELL_HEIGHT); - - if ( skip ) - continue; - - // get the color we're going to draw in + // get the color we're going to draw in Color c = rObj->getColor(); - - // adjust the alpha for stealth units so they "fade/blink" on the radar for the controller // if( obj->getRadarPriority() == RADAR_PRIORITY_LOCAL_UNIT_ONLY ) - // ML-- What the heck is this? local-only and neutral-observier-viewed units are stealthy?? Since when? - // Now it twinkles for any stealthed object, whether locally controlled or neutral-observier-viewed + // ML-- What the heck is this? local-only and neutral-observer-viewed units are stealthy?? Since when? + // Now it twinkles for any stealthed object, whether locally controlled or neutral-observer-viewed if( obj->testStatus( OBJECT_STATUS_STEALTHED ) ) { - if ( ThePlayerList->getLocalPlayer()->getRelationship(obj->getTeam()) == ENEMIES ) - if( !obj->testStatus( OBJECT_STATUS_DETECTED ) && !obj->testStatus( OBJECT_STATUS_DISGUISED ) ) - skip = TRUE; - UnsignedByte r, g, b, a; GameGetColorComponents( c, &r, &g, &b, &a ); const UnsignedInt framesForTransition = LOGICFRAMES_PER_SECOND; const UnsignedByte minAlpha = 32; - if (skip) - continue; - Real alphaScale = INT_TO_REAL(TheGameLogic->getFrame() % framesForTransition) / (framesForTransition / 2.0f); if( alphaScale > 0.0f ) a = REAL_TO_UNSIGNEDBYTE( ((alphaScale - 1.0f) * (255.0f - minAlpha)) + minAlpha ); @@ -710,10 +728,7 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text a = REAL_TO_UNSIGNEDBYTE( (alphaScale * (255.0f - minAlpha)) + minAlpha ); c = GameMakeColor( r, g, b, a ); - } // end if - - - + } // draw the blip, but make sure the points are legal if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) @@ -731,10 +746,10 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) surface->DrawPixel( radarPoint.x, radarPoint.y, c ); - } // end for + } REF_PTR_RELEASE(surface); -} // end renderObjectList +} //------------------------------------------------------------------------------------------------- /** Shade the color passed in using the height parameter to lighten and darken it. Colors @@ -774,7 +789,7 @@ void W3DRadar::interpolateColorForHeight( RGBColor *color, colorTarget.green = color->green + (1.0f - color->green) * howBright; colorTarget.blue = color->blue + (1.0f - color->blue) * howBright; - } // end if + } else // interpolate darker { @@ -786,7 +801,7 @@ void W3DRadar::interpolateColorForHeight( RGBColor *color, colorTarget.green = color->green + (0.0f - color->green) * howDark; colorTarget.blue = color->blue + (0.0f - color->blue) * howDark; - } // end else + } // interpolate toward the target color color->red = color->red + (colorTarget.red - color->red) * t; @@ -807,7 +822,7 @@ void W3DRadar::interpolateColorForHeight( RGBColor *color, if( color->blue > 1.0f ) color->blue = 1.0f; -} // end interpolateColorForHeight +} /////////////////////////////////////////////////////////////////////////////////////////////////// // PUBLIC METHODS ///////////////////////////////////////////////////////////////////////////////// @@ -842,9 +857,9 @@ W3DRadar::W3DRadar( void ) m_viewBox[ i ].x = 0; m_viewBox[ i ].y = 0; - } // end for + } -} // end W3DRadar +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -854,7 +869,7 @@ W3DRadar::~W3DRadar( void ) // delete resources used for the W3D radar deleteResources(); -} // end ~W3DRadar +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -889,8 +904,8 @@ void W3DRadar::init( void ) DEBUG_ASSERTCRASH( m_overlayTexture, ("W3DRadar: Unable to allocate overlay texture") ); // set filter type for the overlay texture, try it and see if you like it, I don't ;) -// m_overlayTexture->Set_Min_Filter( TextureClass::FILTER_TYPE_NONE ); -// m_overlayTexture->Set_Mag_Filter( TextureClass::FILTER_TYPE_NONE ); +// m_overlayTexture->Set_Min_Filter( TextureFilterClass::FILTER_TYPE_NONE ); +// m_overlayTexture->Set_Mag_Filter( TextureFilterClass::FILTER_TYPE_NONE ); // allocate our shroud texture m_shroudTexture = MSGNEW("TextureClass") TextureClass( m_textureWidth, m_textureHeight, @@ -952,7 +967,7 @@ void W3DRadar::init( void ) size.y = m_textureHeight; m_shroudImage->setImageSize( &size ); -} // end init +} //------------------------------------------------------------------------------------------------- /** Reset the radar to the initial empty state ready for new data */ @@ -963,8 +978,6 @@ void W3DRadar::reset( void ) // extending functionality, call base class Radar::reset(); - m_cachedHeroObjectList.clear(); - // clear our texture data, but do not delete the resources SurfaceClass *surface; @@ -986,7 +999,7 @@ void W3DRadar::reset( void ) //gs Dude, it's called CLEARshroud. It needs to clear the shroud. clearShroud(); -} // end reset +} //------------------------------------------------------------------------------------------------- /** Update */ @@ -997,37 +1010,6 @@ void W3DRadar::update( void ) // extend base class Radar::update(); -} // end update - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -RadarObjectType W3DRadar::addObject( Object* obj ) -{ - RadarObjectType addedType = Radar::addObject(obj); - - if (addedType == RadarObjectType_Local) - { - if (obj->isHero() && !RadarObject::isTemporarilyHidden(obj)) - { - m_cachedHeroObjectList.push_back(obj); - } - } - - return addedType; -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -RadarObjectType W3DRadar::removeObject( Object* obj ) -{ - RadarObjectType removedType = Radar::removeObject(obj); - - if (removedType == RadarObjectType_Local) - { - stl::find_and_erase_unordered(m_cachedHeroObjectList, obj); - } - - return removedType; } //------------------------------------------------------------------------------------------------- @@ -1049,7 +1031,7 @@ void W3DRadar::newMap( TerrainLogic *terrain ) // build terrain texture buildTerrainTexture( terrain ); -} // end newMap +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -1103,9 +1085,9 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain ) if( body->getDamageState() != BODY_RUBBLE ) workingBridge = TRUE; - } // end if + } - } // end if + } // create a color based on the Z height of the map Real waterZ; @@ -1135,7 +1117,7 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain ) radarToWorld2D( &radarPoint, &worldPoint ); // get color for this Z and add to our sample color - Real underwaterZ; + Real underwaterZ; if( terrain->isUnderwater( worldPoint.x, worldPoint.y, NULL, &underwaterZ ) ) { // this is our "color" for water @@ -1152,15 +1134,15 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain ) sampleColor.blue += color.blue; samples++; - } // end if + } - } // end if + } - } // end for i + } - } // end if + } - } // end for j + } // prevent divide by zeros if( samples == 0 ) @@ -1171,7 +1153,7 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain ) color.green = sampleColor.green / (Real)samples; color.blue = sampleColor.blue / (Real)samples; - } // end if + } else // regular terrain ... { const Int samplesAway = 1; // how many "tiles" from the center tile we will sample away @@ -1225,7 +1207,7 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain ) getTerrainAverageZ(), m_mapExtent.hi.z, m_mapExtent.lo.z ); - } // end if + } else { @@ -1236,7 +1218,7 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain ) interpolateColorForHeight( &color, worldPoint.z, getTerrainAverageZ(), m_mapExtent.hi.z, m_mapExtent.lo.z ); - } // end else + } // add color to our samples sampleColor.red += color.red; @@ -1244,13 +1226,13 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain ) sampleColor.blue += color.blue; samples++; - } // end if + } - } // end for i + } - } // end if + } - } // end for j + } // prevent divide by zeros if( samples == 0 ) @@ -1261,7 +1243,7 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain ) color.green = sampleColor.green / (Real)samples; color.blue = sampleColor.blue / (Real)samples; - } // end else + } // // draw the pixel for the terrain at this point, note that because of the orientation @@ -1277,14 +1259,14 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain ) color.blue * 255, 255 ) ); - } // end for x + } - } // end for y + } // all done with the surface REF_PTR_RELEASE(surface); -} // end buildTerrainTexture +} // ------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------- @@ -1384,10 +1366,8 @@ void W3DRadar::setShroudLevel(Int shroudX, Int shroudY, CellShroudStatus setting //------------------------------------------------------------------------------------------------- void W3DRadar::draw( Int pixelX, Int pixelY, Int width, Int height ) { - // if the local player does not have a radar then we can't draw anything - Player *player = ThePlayerList->getLocalPlayer(); - if( !player->hasRadar() && !TheRadar->isRadarForced() ) + if( !rts::localPlayerHasRadar() ) return; // @@ -1413,7 +1393,7 @@ void W3DRadar::draw( Int pixelX, Int pixelY, Int width, Int height ) TheDisplay->drawLine(pixelX, ul.y, pixelX + width, ul.y, 1, lineColor); TheDisplay->drawLine(pixelX, lr.y + 1, pixelX + width, lr.y + 1, 1, lineColor); - } // end if + } else { @@ -1423,7 +1403,7 @@ void W3DRadar::draw( Int pixelX, Int pixelY, Int width, Int height ) TheDisplay->drawLine(ul.x, pixelY, ul.x, pixelY + height, 1, lineColor); TheDisplay->drawLine(lr.x + 1, pixelY, lr.x + 1, pixelY + height, 1, lineColor); - } // end else + } // draw the terrain texture TheDisplay->drawImage( m_terrainImage, ul.x, ul.y, lr.x, lr.y ); @@ -1431,17 +1411,8 @@ void W3DRadar::draw( Int pixelX, Int pixelY, Int width, Int height ) // refresh the overlay texture once every so many frames if( TheGameClient->getFrame() % OVERLAY_REFRESH_RATE == 0 ) { - - // reset the overlay texture - SurfaceClass *surface = m_overlayTexture->Get_Surface_Level(); - surface->Clear(); - REF_PTR_RELEASE(surface); - - // rebuild the object overlay - renderObjectList( getObjectList(), m_overlayTexture ); - renderObjectList( getLocalObjectList(), m_overlayTexture, TRUE ); - - } // end if + updateObjectTexture(m_overlayTexture); + } // draw the overlay image TheDisplay->drawImage( m_overlayImage, ul.x, ul.y, lr.x, lr.y ); @@ -1474,7 +1445,7 @@ void W3DRadar::draw( Int pixelX, Int pixelY, Int width, Int height ) // draw the view region on top of the radar reconstructing if necessary drawViewBox( ul.x, ul.y, scaledWidth, scaledHeight ); -} // end draw +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -1487,8 +1458,20 @@ void W3DRadar::refreshTerrain( TerrainLogic *terrain ) // rebuild the entire terrain texture buildTerrainTexture( terrain ); -} // end refreshTerrain +} +// ------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------ +void W3DRadar::refreshObjects() +{ + if constexpr (OVERLAY_REFRESH_RATE > 1) + { + if (m_overlayTexture != NULL) + { + updateObjectTexture(m_overlayTexture); + } + } +} @@ -1510,10 +1493,8 @@ void W3DRadar::refreshTerrain( TerrainLogic *terrain ) // loop through all objects and draw ICoord2D radarPoint; - Player *player = ThePlayerList->getLocalPlayer(); - Int playerIndex=0; - if (player) - playerIndex=player->getPlayerIndex(); + Player *player = rts::getObservedOrLocalPlayer(); + const Int playerIndex = player->getPlayerIndex(); UnsignedByte minAlpha = 8; @@ -1544,8 +1525,8 @@ void W3DRadar::refreshTerrain( TerrainLogic *terrain ) // they are godlike and can see everything) // if( obj->getRadarPriority() == RADAR_PRIORITY_LOCAL_UNIT_ONLY && - obj->getControllingPlayer() != ThePlayerList->getLocalPlayer() && - ThePlayerList->getLocalPlayer()->isPlayerActive() ) + obj->getControllingPlayer() != player && + player->isPlayerActive() ) continue; UnsignedByte g = c|a; @@ -1594,7 +1575,7 @@ void W3DRadar::refreshTerrain( TerrainLogic *terrain ) a = REAL_TO_UNSIGNEDBYTE( (alphaScale * (255.0f - minAlpha)) + minAlpha ); c = GameMakeColor( r, g, b, a ); - } // end if + } @@ -1618,10 +1599,10 @@ void W3DRadar::refreshTerrain( TerrainLogic *terrain ) - } // end for + } REF_PTR_RELEASE(surface); -} // end renderObjectList +} * diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp similarity index 98% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp index 98e714b0ba..afb6045e68 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp @@ -46,9 +46,7 @@ // Includes //----------------------------------------------------------------------------- -#include #include -#include #include #include #include @@ -59,6 +57,7 @@ #include #include "Common/GlobalData.h" #include "Common/PerfTimer.h" +#include "Common/Xfer.h" #include "GameClient/TerrainVisual.h" #include "GameClient/View.h" @@ -88,7 +87,6 @@ #include "W3DDevice/GameClient/W3DPoly.h" #include "W3DDevice/GameClient/W3DCustomScene.h" -#include "Common/PerfTimer.h" #include "Common/UnitTimings.h" //Contains the DO_UNIT_TIMINGS define jba. #include "W3DDevice/GameClient/BaseHeightMap.h" @@ -201,46 +199,35 @@ void BaseHeightMapRenderObjClass::drawScorches(void) BaseHeightMapRenderObjClass::~BaseHeightMapRenderObjClass(void) { freeMapResources(); - if (m_treeBuffer) { - delete m_treeBuffer; - m_treeBuffer = NULL; - } - if (m_propBuffer) { - delete m_propBuffer; - m_propBuffer = NULL; - } - if (m_bibBuffer) { - delete m_bibBuffer; - m_bibBuffer = NULL; - } + + delete m_treeBuffer; + m_treeBuffer = NULL; + + delete m_propBuffer; + m_propBuffer = NULL; + + delete m_bibBuffer; + m_bibBuffer = NULL; + #ifdef DO_ROADS - if (m_roadBuffer) { - delete m_roadBuffer; - m_roadBuffer = NULL; - } + delete m_roadBuffer; + m_roadBuffer = NULL; #endif - if (m_bridgeBuffer) { - delete m_bridgeBuffer; - } - if( m_waypointBuffer ) - { - delete m_waypointBuffer; - m_waypointBuffer = NULL; - } - if (m_shroud) { - delete m_shroud; - m_shroud = NULL; - } - if (m_shoreLineTilePositions) { - delete [] m_shoreLineTilePositions; - m_shoreLineTilePositions = NULL; - } - if (m_shoreLineSortInfos) - { - delete [] m_shoreLineSortInfos; - m_shoreLineSortInfos = NULL; - } + delete m_bridgeBuffer; + m_bridgeBuffer = NULL; + + delete m_waypointBuffer; + m_waypointBuffer = NULL; + + delete m_shroud; + m_shroud = NULL; + + delete [] m_shoreLineTilePositions; + m_shoreLineTilePositions = NULL; + + delete [] m_shoreLineSortInfos; + m_shoreLineSortInfos = NULL; } //============================================================================= @@ -1514,8 +1501,7 @@ void BaseHeightMapRenderObjClass::recordShoreLineSortInfos(void) //Check if we need to allocate memory if (!m_shoreLineSortInfos || shoreLineSortInfosSize > m_shoreLineSortInfosSize) { - if (m_shoreLineSortInfos) - delete [] m_shoreLineSortInfos; //old buffer was too small. + delete [] m_shoreLineSortInfos; //old buffer was too small. //Find the major map axis (having the most tiles). m_shoreLineSortInfosSize = shoreLineSortInfosSize; @@ -2602,7 +2588,7 @@ void BaseHeightMapRenderObjClass::renderShoreLines(CameraClass *pCamera) indexCount +=6; } } - }//lock and fill ib/vb + } if (indexCount > 0 && vertexCount > 0) { @@ -2614,7 +2600,7 @@ void BaseHeightMapRenderObjClass::renderShoreLines(CameraClass *pCamera) vertexCount=0; indexCount=0; - }//for all shore tiles + } //Disable writes to destination alpha DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED); @@ -2814,9 +2800,9 @@ void BaseHeightMapRenderObjClass::renderShoreLinesSorted(CameraClass *pCamera) vertexCount +=4; indexCount +=6; shoreInfo++; //advance to next tile. - }//looping over tiles in column + } lastRenderedTile=0; - }//looping over all visible columns. + } flushVertexBuffer0: drawStartX = x; //record how far we've moved so far isDone = x >= drawEdgeX; @@ -2935,14 +2921,14 @@ void BaseHeightMapRenderObjClass::renderShoreLinesSorted(CameraClass *pCamera) vertexCount +=4; indexCount +=6; shoreInfo++; //advance to next tile. - }//looping over tiles in row + } lastRenderedTile=0; - }//looping over all visible rows. + } flushVertexBuffer1: drawStartY = y; //record how far we've moved so far isDone = y >= drawEdgeY; } - }//lock and fill ib/vb + } if (indexCount > 0 && vertexCount > 0) { @@ -2954,7 +2940,7 @@ void BaseHeightMapRenderObjClass::renderShoreLinesSorted(CameraClass *pCamera) vertexCount=0; indexCount=0; - }//for all shore tiles + } //Disable writes to destination alpha DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_BLUE|D3DCOLORWRITEENABLE_GREEN|D3DCOLORWRITEENABLE_RED); @@ -2992,7 +2978,7 @@ void BaseHeightMapRenderObjClass::renderTrees(CameraClass * camera) void BaseHeightMapRenderObjClass::crc( Xfer *xfer ) { // empty. jba [8/11/2003] -} // end CRC +} // ------------------------------------------------------------------------------------------------ /** Xfer @@ -3011,7 +2997,7 @@ void BaseHeightMapRenderObjClass::xfer( Xfer *xfer ) xfer->xferSnapshot( m_propBuffer ); -} // end xfer +} // ------------------------------------------------------------------------------------------------ /** Load post process */ @@ -3019,5 +3005,10 @@ void BaseHeightMapRenderObjClass::xfer( Xfer *xfer ) void BaseHeightMapRenderObjClass::loadPostProcess( void ) { // empty. jba [8/11/2003] -} // end loadPostProcess +} +//============================================================================= +Bool BaseHeightMapRenderObjClass::useCloud() +{ + return TheGlobalData->m_useCloudMap && TheGlobalData->m_timeOfDay != TIME_OF_DAY_NIGHT; +} diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/camerashakesystem.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/CameraShakeSystem.cpp similarity index 99% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/camerashakesystem.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/CameraShakeSystem.cpp index a71ebaad1b..71d7124a47 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/camerashakesystem.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/CameraShakeSystem.cpp @@ -36,9 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#include #include -#include #include #include #include @@ -77,7 +75,7 @@ #include "W3DDevice/GameClient/W3DPoly.h" #include "W3DDevice/GameClient/W3DCustomScene.h" -#include "W3DDevice/GameClient/camerashakesystem.h" +#include "W3DDevice/GameClient/CameraShakeSystem.h" #include "WW3D2/camera.h" //#include "W3DDevice/GameClient/camera.h" diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp similarity index 99% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp index 0c36c530a9..9efb0e4040 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp @@ -254,9 +254,9 @@ W3DLaserDraw::W3DLaserDraw( Thing *thing, const ModuleData* moduleData ) : } - } // end for i + } - } //end segment loop + } } @@ -276,7 +276,7 @@ W3DLaserDraw::~W3DLaserDraw( void ) // delete line REF_PTR_RELEASE( m_line3D[ i ] ); - } // end for i + } delete [] m_line3D; // TheSuperHackers @fix Mauller 11/03/2025 Free reference counted material @@ -565,7 +565,7 @@ void W3DLaserDraw::crc( Xfer *xfer ) // extend base class DrawModule::crc( xfer ); -} // end crc +} // ------------------------------------------------------------------------------------------------ /** Xfer method @@ -586,7 +586,7 @@ void W3DLaserDraw::xfer( Xfer *xfer ) // Kris says there is no data to save for these, go ask him. // m_selfDirty is not saved, is runtime only -} // end xfer +} // ------------------------------------------------------------------------------------------------ /** Load post process */ @@ -599,4 +599,4 @@ void W3DLaserDraw::loadPostProcess( void ) m_selfDirty = true; // so we update the first time after reload -} // end loadPostProcess +} diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPropDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPropDraw.cpp similarity index 98% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPropDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPropDraw.cpp index f04c010289..1347418903 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPropDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPropDraw.cpp @@ -72,7 +72,7 @@ W3DPropDraw::W3DPropDraw( Thing *thing, const ModuleData* moduleData ) : DrawMod m_propAdded(false) { -} // end W3DPropDraw +} //------------------------------------------------------------------------------------------------- @@ -122,7 +122,7 @@ void W3DPropDraw::crc( Xfer *xfer ) // extend base class DrawModule::crc( xfer ); -} // end crc +} // ------------------------------------------------------------------------------------------------ /** Xfer method @@ -142,7 +142,7 @@ void W3DPropDraw::xfer( Xfer *xfer ) // no data to save here, nobody will ever notice -} // end xfer +} // ------------------------------------------------------------------------------------------------ /** Load post process */ @@ -153,4 +153,4 @@ void W3DPropDraw::loadPostProcess( void ) // extend base class DrawModule::loadPostProcess(); -} // end loadPostProcess +} diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTreeDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTreeDraw.cpp similarity index 89% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTreeDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTreeDraw.cpp index c361998f71..81fff43877 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTreeDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTreeDraw.cpp @@ -24,7 +24,7 @@ // FILE: W3DTreeDraw.cpp //////////////////////////////////////////////////////////////////////// // Author: Colin Day, December 2001 -// Desc: Tracer drawing +// Desc: Tree draw /////////////////////////////////////////////////////////////////////////////////////////////////// // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// @@ -109,51 +109,29 @@ void W3DTreeDrawModuleData::buildFieldParse(MultiIniFieldParse& p) //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- -W3DTreeDraw::W3DTreeDraw( Thing *thing, const ModuleData* moduleData ) : DrawModule( thing, moduleData ), -m_treeAdded(false) +W3DTreeDraw::W3DTreeDraw( Thing *thing, const ModuleData* moduleData ) : DrawModule( thing, moduleData ) { - -} // end W3DTreeDraw - +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- W3DTreeDraw::~W3DTreeDraw( void ) { + addToTreeBuffer(); } //------------------------------------------------------------------------------------------------- -void W3DTreeDraw::reactToTransformChange( const Matrix3D *oldMtx, - const Coord3D *oldPos, - Real oldAngle ) +void W3DTreeDraw::addToTreeBuffer() { - Drawable *draw = getDrawable(); - if (m_treeAdded) { - return; - } - if (draw->getPosition()->x==0.0f && draw->getPosition()->y == 0.0f) { - return; - } - m_treeAdded = true; const W3DTreeDrawModuleData *moduleData = getW3DTreeDrawModuleData(); - if (!moduleData) { - return; - } + const Drawable *draw = getDrawable(); + + DEBUG_ASSERTCRASH(draw->isPositioned(), ("W3DTreeDraw::addToTreeBuffer - This tree was not positioned!")); + Real scale = draw->getScale(); Real scaleRandomness = draw->getTemplate()->getInstanceScaleFuzziness(); scaleRandomness = 0.0f; // We use the scale fuzziness inside WB to generate random scales, so they don't change at load time. jba. [4/22/2003] - TheTerrainRenderObject->addTree(draw->getID(), *draw->getPosition(), - scale, draw->getOrientation(), scaleRandomness, moduleData); - -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -void W3DTreeDraw::doDrawModule(const Matrix3D* transformMtx) -{ - - return; - + TheTerrainRenderObject->addTree(draw->getID(), *draw->getPosition(), scale, draw->getOrientation(), scaleRandomness, moduleData); } // ------------------------------------------------------------------------------------------------ @@ -165,7 +143,7 @@ void W3DTreeDraw::crc( Xfer *xfer ) // extend base class DrawModule::crc( xfer ); -} // end crc +} // ------------------------------------------------------------------------------------------------ /** Xfer method @@ -185,7 +163,7 @@ void W3DTreeDraw::xfer( Xfer *xfer ) // no data to save here, nobody will ever notice -} // end xfer +} // ------------------------------------------------------------------------------------------------ /** Load post process */ @@ -196,5 +174,5 @@ void W3DTreeDraw::loadPostProcess( void ) // extend base class DrawModule::loadPostProcess(); -} // end loadPostProcess +} diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp similarity index 98% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp index a500eecf31..7f4ebc785e 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp @@ -47,9 +47,7 @@ //----------------------------------------------------------------------------- #include "W3DDevice/GameClient/FlatHeightMap.h" -#include #include -#include #include #include #include @@ -89,7 +87,6 @@ #include "W3DDevice/GameClient/W3DPoly.h" #include "W3DDevice/GameClient/W3DCustomScene.h" -#include "Common/PerfTimer.h" #include "Common/UnitTimings.h" //Contains the DO_UNIT_TIMINGS define jba. @@ -275,10 +272,9 @@ void FlatHeightMapRenderObjClass::doPartialUpdate(const IRegion2D &partialRange, //============================================================================= void FlatHeightMapRenderObjClass::releaseTiles(void) { - if (m_tiles) { - delete [] m_tiles; - m_tiles = NULL; - } + delete [] m_tiles; + m_tiles = NULL; + m_tilesWidth = 0; m_tilesHeight = 0; m_numTiles = 0; @@ -460,7 +456,14 @@ void FlatHeightMapRenderObjClass::Render(RenderInfoClass & rinfo) Int devicePasses; W3DShaderManager::ShaderTypes st; - Bool doCloud = TheGlobalData->m_useCloudMap; + const Bool doCloud = useCloud(); + + if (doCloud) + { + // TheSuperHackers @tweak Updates the cloud movement before applying it to the world. + // Is now decoupled from logic step. + W3DShaderManager::updateCloud(); + } Matrix3D tm(Transform); // If there are trees, tell them to draw at the transparent time to draw. @@ -495,10 +498,6 @@ void FlatHeightMapRenderObjClass::Render(RenderInfoClass & rinfo) DX8Wrapper::Set_Material(m_vertexMaterialClass); DX8Wrapper::Set_Shader(m_shaderClass); - if (TheGlobalData->m_timeOfDay == TIME_OF_DAY_NIGHT) { - doCloud = false; - } - st=W3DShaderManager::ST_FLAT_TERRAIN_BASE; //set default shader //set correct shader based on current settings diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp similarity index 99% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp index b86f7f0c23..55f228a81d 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp @@ -45,15 +45,11 @@ //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- - - #include "W3DDevice/GameClient/HeightMap.h" #ifndef USE_FLAT_HEIGHT_MAP // Flat height map uses flattened textures. jba. [3/20/2003] -#include #include -#include #include #include #include @@ -93,7 +89,6 @@ #include "W3DDevice/GameClient/W3DPoly.h" #include "W3DDevice/GameClient/W3DCustomScene.h" -#include "Common/PerfTimer.h" #include "Common/UnitTimings.h" //Contains the DO_UNIT_TIMINGS define jba. @@ -1074,10 +1069,9 @@ Int HeightMapRenderObjClass::updateBlock(Int x0, Int y0, Int x1, Int y1, WorldH HeightMapRenderObjClass::~HeightMapRenderObjClass(void) { freeMapResources(); - if (m_extraBlendTilePositions) { - delete [] m_extraBlendTilePositions; - m_extraBlendTilePositions = NULL; - } + + delete [] m_extraBlendTilePositions; + m_extraBlendTilePositions = NULL; } //============================================================================= @@ -1913,7 +1907,14 @@ void HeightMapRenderObjClass::Render(RenderInfoClass & rinfo) Int i,j,devicePasses; W3DShaderManager::ShaderTypes st; - Bool doCloud = TheGlobalData->m_useCloudMap; + const Bool doCloud = useCloud(); + + if (doCloud) + { + // TheSuperHackers @tweak Updates the cloud movement before applying it to the world. + // Is now decoupled from logic step. + W3DShaderManager::updateCloud(); + } Matrix3D tm(Transform); #if 0 // There is some weirdness sometimes with the dx8 static buffers. @@ -2004,10 +2005,6 @@ void HeightMapRenderObjClass::Render(RenderInfoClass & rinfo) DX8Wrapper::Set_Material(m_vertexMaterialClass); DX8Wrapper::Set_Shader(m_shaderClass); - if (TheGlobalData->m_timeOfDay == TIME_OF_DAY_NIGHT) { - doCloud = false; - } - st=W3DShaderManager::ST_TERRAIN_BASE; //set default shader //set correct shader based on current settings @@ -2377,9 +2374,9 @@ void HeightMapRenderObjClass::renderExtraBlendTiles(void) ib += 6; vertexCount +=4; indexCount +=6; - }//tile has 3rd blend layer and is visible - } //for all extre blend tiles - }//unlock vertex buffer + } + } + } if (vertexCount) { @@ -2416,10 +2413,7 @@ void HeightMapRenderObjClass::renderExtraBlendTiles(void) W3DShaderManager::ShaderTypes st = W3DShaderManager::ST_ROAD_BASE; - Bool doCloud = TheGlobalData->m_useCloudMap; - if (TheGlobalData->m_timeOfDay == TIME_OF_DAY_NIGHT) { - doCloud = false; - } + const Bool doCloud = useCloud(); if (TheGlobalData->m_useLightMap && doCloud) { diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp similarity index 99% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp index 61b9492190..9e923b1d6d 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/TerrainTex.cpp @@ -103,6 +103,7 @@ int TerrainTextureClass::update(WorldHeightMap *htMap) DX8_ErrorCode(Peek_D3D_Texture()->GetSurfaceLevel(0, &surface_level)); DX8_ErrorCode(surface_level->GetDesc(&surface_desc)); if (surface_desc.Width < TEXTURE_WIDTH) { + surface_level->Release(); return 0; } @@ -195,8 +196,8 @@ int TerrainTextureClass::update(WorldHeightMap *htMap) surface_level->UnlockRect(); surface_level->Release(); DX8_ErrorCode(D3DXFilterTexture(Peek_D3D_Texture(), NULL, 0, D3DX_FILTER_BOX)); - if (TheWritableGlobalData->m_textureReductionFactor) { - Peek_D3D_Texture()->SetLOD(TheWritableGlobalData->m_textureReductionFactor); + if (WW3D::Get_Texture_Reduction()) { + Peek_D3D_Texture()->SetLOD(WW3D::Get_Texture_Reduction()); } return(surface_desc.Height); } @@ -944,7 +945,6 @@ void CloudMapTerrainTextureClass::Apply(unsigned int stage) // Do the base apply. TextureClass::Apply(stage); - return; #if 0 // obsolete /* previous setup */ if (TheGlobalData && TheGlobalData->m_trilinearTerrainTex) { diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/TileData.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/TileData.cpp similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/TileData.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/TileData.cpp diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp similarity index 98% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp index 30c9f6296f..fe936811b8 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp @@ -47,9 +47,8 @@ //----------------------------------------------------------------------------- #include "W3DDevice/GameClient/W3DPropBuffer.h" -#include -#include #include +#include "Common/GameUtility.h" #include "Common/Geometry.h" #include "Common/PerfTimer.h" #include "Common/Player.h" @@ -364,7 +363,7 @@ void W3DPropBuffer::drawProps(RenderInfoClass &rinfo) m_props[i].ss = OBJECTSHROUD_CLEAR; } if (m_props[i].ss == OBJECTSHROUD_INVALID) { - Int localPlayerIndex = ThePlayerList ? ThePlayerList->getLocalPlayer()->getPlayerIndex() : 0; + const Int localPlayerIndex = rts::getObservedOrLocalPlayerIndex_Safe(); m_props[i].ss = ThePartitionManager->getPropShroudStatusForPlayer(localPlayerIndex, &m_props[i].location); } if (m_props[i].ss >= OBJECTSHROUD_SHROUDED) { @@ -392,7 +391,7 @@ void W3DPropBuffer::drawProps(RenderInfoClass &rinfo) void W3DPropBuffer::crc( Xfer *xfer ) { // empty. jba [8/11/2003] -} // end CRC +} // ------------------------------------------------------------------------------------------------ /** Xfer @@ -408,7 +407,7 @@ void W3DPropBuffer::xfer( Xfer *xfer ) xfer->xferVersion( &version, currentVersion ); -} // end xfer +} // ------------------------------------------------------------------------------------------------ /** Load post process */ @@ -416,5 +415,5 @@ void W3DPropBuffer::xfer( Xfer *xfer ) void W3DPropBuffer::loadPostProcess( void ) { // empty. jba [8/11/2003] -} // end loadPostProcess +} diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp similarity index 99% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp index 24a64db0f0..6ae6394e28 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp @@ -1482,12 +1482,14 @@ class TerrainShader2Stage : public W3DShaderInterface public: float m_xSlidePerSecond ; ///< How far the clouds move per second. float m_ySlidePerSecond ; ///< How far the clouds move per second. - int m_curTick; float m_xOffset; float m_yOffset; + virtual Int set(Int pass); /// 1) m_xOffset -= 1; - while (m_yOffset > 1) m_yOffset -= 1; - while (m_xOffset < -1) m_xOffset += 1; - while (m_yOffset < -1) m_yOffset += 1; - D3DXMatrixTranslation(&offset, m_xOffset, m_yOffset,0); *destMatrix *= offset; } @@ -1756,7 +1747,7 @@ Int TerrainShader2Stage::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); - } //ST_TERRAIN_BASE_NOISE12 + } else { //only 1 noise or cloud texture // Now setup the texture pipeline. @@ -2476,7 +2467,7 @@ Int RoadShader2Stage::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); } - } //pass 0 + } else { //pass 1, apply additional noise pass Matrix4x4 curView; @@ -2535,7 +2526,6 @@ void RoadShader2Stage::reset(void) { ShaderClass::Invalidate(); - //Free references to textures DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU|0); @@ -2701,7 +2691,12 @@ void W3DShaderManager::shutdown(void) W3DFilters[i]->shutdown(); } } +} +//============================================================================= +void W3DShaderManager::updateCloud() +{ + terrainShader2Stage.updateCloud(); } // W3DShaderManager::getShaderPasses ======================================================= @@ -2993,7 +2988,7 @@ ChipsetType W3DShaderManager::getChipset( void ) if (maxTextures >= 8 && pixelShaderVersion >= 2.0f) chip=DC_GENERIC_PIXEL_SHADER_2_0; } - } //D3D8 interface and device exist. + } return chip; } @@ -3128,7 +3123,7 @@ StaticGameLODLevel W3DShaderManager::getGPUPerformanceIndex(void) if (chipType >= DC_GEFORCE2) detailSetting=STATIC_GAME_LOD_LOW; //these cards need multiple terrain passes. if (chipType >= DC_GENERIC_PIXEL_SHADER_1_1) //these cards can do terrain in single pass. - detailSetting=STATIC_GAME_LOD_HIGH; + detailSetting=STATIC_GAME_LOD_VERY_HIGH; } return detailSetting; @@ -3432,7 +3427,7 @@ Int FlatTerrainShader2Stage::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, W3DShaderManager::getShaderTexture(3)->Peek_D3D_Texture()); - } //ST_TERRAIN_BASE_NOISE12 + } else { //only 1 noise or cloud texture // Now setup the texture pipeline. diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp similarity index 99% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp index 3342bbf0a7..d11d305123 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp @@ -236,7 +236,7 @@ Bool W3DSmudgeManager::testHardwareSupport(void) //bottom right v[0].p = Vector4( BLOCK_SIZE-0.5f, BLOCK_SIZE-0.5f, 0.0f, 1.0f ); - v[0].u = BLOCK_SIZE/(Real)TheDisplay->getWidth(); v[0].v = BLOCK_SIZE/(Real)TheDisplay->getHeight();; + v[0].u = BLOCK_SIZE/(Real)TheDisplay->getWidth(); v[0].v = BLOCK_SIZE/(Real)TheDisplay->getHeight(); //top right v[1].p = Vector4( BLOCK_SIZE-0.5f, 0-0.5f, 0.0f, 1.0f ); v[1].u = BLOCK_SIZE/(Real)TheDisplay->getWidth(); v[1].v = 0; diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DSnow.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSnow.cpp similarity index 99% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DSnow.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSnow.cpp index cf40de7c79..bed66d1c65 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DSnow.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSnow.cpp @@ -156,8 +156,8 @@ void W3DSnowManager::reset( void ) void W3DSnowManager::update(void) { - - m_time += WW3D::Get_Frame_Time() / 1000.0f; + // TheSuperHackers @tweak The snow render update is now decoupled from the logic step. + m_time += WW3D::Get_Logic_Frame_Time_Seconds(); //find current time offset, adjusting for overflow m_time=fmod(m_time,m_fullTimePeriod); diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainBackground.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainBackground.cpp similarity index 99% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainBackground.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainBackground.cpp index e4f8492b8e..d7691c6316 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainBackground.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainBackground.cpp @@ -47,8 +47,6 @@ //----------------------------------------------------------------------------- #include "W3DDevice/GameClient/W3DTerrainBackground.h" -#include -#include #include #include #include "Common/GlobalData.h" diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp similarity index 99% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp index 56e4bdf9b5..83a391b5d7 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp @@ -491,11 +491,11 @@ TerrainTracksRenderObjClass *TerrainTracksRenderObjClassSystem::bindTrack( Rende mod->init(computeTrackSpacing(renderObject),length,texturename); mod->m_bound=true; m_TerrainTracksScene->Add_Render_Object( mod); - } // end if + } return mod; -} //end bindTrack +} //============================================================================= //TerrainTracksRenderObjClassSystem::unbindTrack @@ -658,7 +658,7 @@ void TerrainTracksRenderObjClassSystem::init( SceneClass *TerrainTracksScene ) assert( 0 ); return; - } // end if + } // allocate our modules for this system for( i = 0; i < numModules; i++ ) @@ -673,7 +673,7 @@ void TerrainTracksRenderObjClassSystem::init( SceneClass *TerrainTracksScene ) assert( 0 ); return; - } // end if + } mod->m_prevSystem = NULL; mod->m_nextSystem = m_freeModules; @@ -681,9 +681,9 @@ void TerrainTracksRenderObjClassSystem::init( SceneClass *TerrainTracksScene ) m_freeModules->m_prevSystem = mod; m_freeModules = mod; - } // end for i + } -} // end init +} //============================================================================= // TerrainTracksRenderObjClassSystem::shutdown @@ -705,7 +705,7 @@ void TerrainTracksRenderObjClassSystem::shutdown( void ) releaseTrack(mod); mod = nextMod; - } // end while + } // free all attached things and used modules @@ -719,13 +719,13 @@ void TerrainTracksRenderObjClassSystem::shutdown( void ) REF_PTR_RELEASE (m_freeModules); m_freeModules = nextMod; - } // end while + } REF_PTR_RELEASE(m_indexBuffer); REF_PTR_RELEASE(m_vertexMaterialClass); REF_PTR_RELEASE(m_vertexBuffer); -} // end shutdown +} //============================================================================= // TerrainTracksRenderObjClassSystem::update @@ -778,7 +778,7 @@ void TerrainTracksRenderObjClassSystem::update() releaseTrack(mod); } mod = nextMod; - } // end while + } } @@ -878,11 +878,11 @@ Try improving the fit to vertical surfaces like cliffs. verts->diffuse=diffuseLight | ( REAL_TO_INT(distanceFade*255.0f) <<24); verts++; - }//for - }// mod has edges to render + } + } mod = mod->m_nextSystem; - } //while (mod) - }//edges to flush + } + } //draw the filled vertex buffers if (m_edgesToFlush >= 2) @@ -909,7 +909,7 @@ Try improving the fit to vertical surfaces like cliffs. } mod=mod->m_nextSystem; } - } //there are some edges to render in pool. + } m_edgesToFlush=0; //reset count for next flush } @@ -926,7 +926,7 @@ void TerrainTracksRenderObjClassSystem::Reset(void) releaseTrack(mod); mod = nextMod; - } // end while + } // free all attached things and used modules @@ -950,7 +950,7 @@ void TerrainTracksRenderObjClassSystem::clearTracks(void) mod->m_totalEdgesAdded=0; mod = mod->m_nextSystem; - } // end while + } m_edgesToFlush=0; } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp similarity index 97% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp index d9162e42e4..77935049c5 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp @@ -27,7 +27,6 @@ // Author: Colin Day, April 2001 /////////////////////////////////////////////////////////////////////////////////////////////////// -#include #include #include @@ -170,17 +169,7 @@ W3DTerrainVisual::W3DTerrainVisual() m_clientHeightMap = NULL; #endif - - - - - - - - - - -} // end W3DTerrainVisual +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -191,23 +180,14 @@ W3DTerrainVisual::~W3DTerrainVisual() TheTerrainRenderObject = NULL; } - if (TheTerrainTracksRenderObjClassSystem) - { - delete TheTerrainTracksRenderObjClassSystem; - TheTerrainTracksRenderObjClassSystem=NULL; - } + delete TheTerrainTracksRenderObjClassSystem; + TheTerrainTracksRenderObjClassSystem=NULL; - if (TheW3DShadowManager) - { - delete TheW3DShadowManager; - TheW3DShadowManager=NULL; - } + delete TheW3DShadowManager; + TheW3DShadowManager=NULL; - if (TheSmudgeManager) - { - delete TheSmudgeManager; - TheSmudgeManager=NULL; - } + delete TheSmudgeManager; + TheSmudgeManager=NULL; REF_PTR_RELEASE( m_waterRenderObject ); TheWaterRenderObj=NULL; @@ -217,7 +197,7 @@ W3DTerrainVisual::~W3DTerrainVisual() #ifdef DO_SEISMIC_SIMULATIONS REF_PTR_RELEASE( m_clientHeightMap ); #endif -} // end ~W3DTerrainVisual +} //------------------------------------------------------------------------------------------------- /** init */ @@ -294,7 +274,7 @@ void W3DTerrainVisual::init( void ) m_seismicSimulationList.clear(); #endif -} // end init +} //------------------------------------------------------------------------------------------------- /** reset */ @@ -336,7 +316,7 @@ void W3DTerrainVisual::reset( void ) m_seismicSimulationList.clear(); #endif -} // end reset +} //------------------------------------------------------------------------------------------------- /** update */ @@ -354,8 +334,7 @@ void W3DTerrainVisual::update( void ) if( m_waterRenderObject ) m_waterRenderObject->update(); - -} // end update +} #ifdef DO_SEISMIC_SIMULATIONS @@ -458,10 +437,6 @@ void W3DTerrainVisual::handleSeismicSimulations( void ) } } - - - - } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -571,7 +546,7 @@ Bool W3DTerrainVisual::load( AsciiString filename ) REF_PTR_RELEASE( m_terrainRenderObject ); return FALSE; - } // end if + } if( m_terrainRenderObject == NULL ) return FALSE; @@ -583,9 +558,6 @@ Bool W3DTerrainVisual::load( AsciiString filename ) REF_PTR_RELEASE( m_logicHeightMap ); m_logicHeightMap = NEW WorldHeightMap(pStrm); - - - #ifdef DO_SEISMIC_SIMULATIONS fileStrm.close(); @@ -597,13 +569,6 @@ Bool W3DTerrainVisual::load( AsciiString filename ) #endif - - - - - - - // Add any lights loaded by map. MapObject *pMapObj = MapObject::getFirstMapObject(); while (pMapObj) @@ -666,7 +631,7 @@ Bool W3DTerrainVisual::load( AsciiString filename ) if (W3DDisplay::m_3DScene != NULL) { W3DDebugIcons *icons = NEW W3DDebugIcons; - W3DDisplay::m_3DScene->Add_Render_Object( icons ); + W3DDisplay::m_3DScene->Add_Render_Object( icons ); icons->Release_Ref(); // belongs to scene. } #endif @@ -704,7 +669,7 @@ Bool W3DTerrainVisual::load( AsciiString filename ) return TRUE; // success -} // end load +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -718,7 +683,7 @@ void W3DTerrainVisual::enableWaterGrid( Bool enable ) if( m_waterRenderObject ) m_waterRenderObject->enableWaterGrid( enable ); -} // end enableWaterGrid +} //------------------------------------------------------------------------------------------------- /** intersect the ray with the terrain, if a hit occurs TRUE is returned @@ -750,14 +715,14 @@ Bool W3DTerrainVisual::intersectTerrain( Coord3D *rayStart, result->y = point.Y; result->z = point.Z; - } // end if + } - } // end if + } // return hit result return hit; -} // end intersectTerrain +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -772,7 +737,7 @@ void W3DTerrainVisual::getTerrainColorAt( Real x, Real y, RGBColor *pColor ) m_logicHeightMap->getTerrainColorAt( x, y, pColor ); #endif -} // end getTerrainColorAt +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -780,27 +745,22 @@ TerrainType *W3DTerrainVisual::getTerrainTile( Real x, Real y ) { TerrainType *tile = NULL; - #ifdef DO_SEISMIC_SIMULATIONS if( m_clientHeightMap ) { AsciiString tileName = m_clientHeightMap->getTerrainNameAt( x, y ); tile = TheTerrainTypes->findTerrain( tileName ); - } // end if + } #else if( m_logicHeightMap ) { AsciiString tileName = m_logicHeightMap->getTerrainNameAt( x, y ); tile = TheTerrainTypes->findTerrain( tileName ); - } // end if + } #endif - - - return tile; - -} // end getTerrainTile +} // ------------------------------------------------------------------------------------------------ /** set min/max height values allowed in water grid pointed to by waterTable */ @@ -812,7 +772,7 @@ void W3DTerrainVisual::setWaterGridHeightClamps( const WaterHandle *waterTable, if( m_waterRenderObject ) m_waterRenderObject->setGridHeightClamps( minZ, maxZ ); -} // end setWaterGridHeightClamps +} // ------------------------------------------------------------------------------------------------ /** adjust fallof parameters for grid change method */ @@ -824,7 +784,7 @@ void W3DTerrainVisual::setWaterAttenuationFactors( const WaterHandle *waterTable if( m_waterRenderObject ) m_waterRenderObject->setGridChangeAttenuationFactors( a, b, c, range ); -} // end setWaterAttenuationFactors +} // ------------------------------------------------------------------------------------------------ /** set the water table position and orientation in world space */ @@ -836,7 +796,7 @@ void W3DTerrainVisual::setWaterTransform( const WaterHandle *waterTable, if( m_waterRenderObject ) m_waterRenderObject->setGridTransform( angle, x, y, z ); -} // end setWaterTransform +} // ------------------------------------------------------------------------------------------------ /** set water table transform by matrix */ @@ -847,7 +807,7 @@ void W3DTerrainVisual::setWaterTransform( const Matrix3D *transform ) if( m_waterRenderObject ) m_waterRenderObject->setGridTransform( transform ); -} // end setWaterTransform +} // ------------------------------------------------------------------------------------------------ /** get the water transform matrix */ @@ -858,7 +818,7 @@ void W3DTerrainVisual::getWaterTransform( const WaterHandle *waterTable, Matrix3 if( m_waterRenderObject ) m_waterRenderObject->getGridTransform( transform ); -} // end getWaterTransform +} // ------------------------------------------------------------------------------------------------ /** water grid resolution spacing */ @@ -870,7 +830,7 @@ void W3DTerrainVisual::setWaterGridResolution( const WaterHandle *waterTable, if( m_waterRenderObject ) m_waterRenderObject->setGridResolution( gridCellsX, gridCellsY, cellSize ); -} // end setWaterGridResolution +} // ------------------------------------------------------------------------------------------------ /** get water grid resolution spacing */ @@ -882,7 +842,7 @@ void W3DTerrainVisual::getWaterGridResolution( const WaterHandle *waterTable, if( m_waterRenderObject ) m_waterRenderObject->getGridResolution( gridCellsX, gridCellsY, cellSize ); -} // end getWaterGridResolution +} // ------------------------------------------------------------------------------------------------ /** adjust the water grid in world coords by the delta */ @@ -893,7 +853,7 @@ void W3DTerrainVisual::changeWaterHeight( Real x, Real y, Real delta ) if( m_waterRenderObject ) m_waterRenderObject->changeGridHeight( x, y, delta ); -} // end changeWaterHeight +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -904,7 +864,7 @@ void W3DTerrainVisual::addWaterVelocity( Real worldX, Real worldY, if( m_waterRenderObject ) m_waterRenderObject->addVelocity( worldX, worldY, velocity, preferredHeight ); -} // end addWaterVelocity +} // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ @@ -1178,21 +1138,25 @@ void W3DTerrainVisual::crc( Xfer *xfer ) // extend base class TerrainVisual::crc( xfer ); -} // end CRC +} // ------------------------------------------------------------------------------------------------ /** Xfer * Version Info: * 1: Initial version * 2: Add height map heights. - * 3: Add client side trees & props. jba. + * 3: Add client side trees & props. jba. (Added for Zero Hour) */ // ------------------------------------------------------------------------------------------------ void W3DTerrainVisual::xfer( Xfer *xfer ) { // version +#if RTS_GENERALS && RETAIL_COMPATIBLE_XFER_SAVE + XferVersion currentVersion = 2; +#else XferVersion currentVersion = 3; +#endif XferVersion version = currentVersion; xfer->xferVersion( &version, currentVersion ); @@ -1208,7 +1172,7 @@ void W3DTerrainVisual::xfer( Xfer *xfer ) DEBUG_CRASH(( "W3DTerrainVisual::xfer - m_isWaterGridRenderingEnabled mismatch" )); throw SC_INVALID_DATA; - } // end if + } // xfer grid data if enabled if( gridEnabled ) @@ -1229,7 +1193,7 @@ void W3DTerrainVisual::xfer( Xfer *xfer ) width, getGridWidth() )); throw SC_INVALID_DATA; - } // end if + } if( height != getGridHeight() ) { @@ -1237,11 +1201,11 @@ void W3DTerrainVisual::xfer( Xfer *xfer ) height, getGridHeight() )); throw SC_INVALID_DATA; - } // end if + } // write data for each grid - } // end if + } */ // Write out the terrain height data. @@ -1268,8 +1232,6 @@ void W3DTerrainVisual::xfer( Xfer *xfer ) xfer->xferSnapshot(m_terrainRenderObject); } - - // XFER // // X R // // X R // @@ -1284,11 +1246,7 @@ void W3DTerrainVisual::xfer( Xfer *xfer ) // X R // // XFER // - - - - -} // end xfer +} // ------------------------------------------------------------------------------------------------ /** Load post process */ @@ -1299,5 +1257,5 @@ void W3DTerrainVisual::loadPostProcess( void ) // extend base class TerrainVisual::loadPostProcess(); -} // end loadPostProcess +} diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp similarity index 96% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp index b7959b7763..1b5ba20336 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp @@ -56,10 +56,10 @@ enum //----------------------------------------------------------------------------- #include "W3DDevice/GameClient/W3DTreeBuffer.h" -#include -#include #include #include +#include "Common/FramePacer.h" +#include "Common/GameUtility.h" #include "Common/MapReaderWriterInfo.h" #include "Common/FileSystem.h" #include "Common/file.h" @@ -189,8 +189,8 @@ int W3DTreeBuffer::W3DTreeTextureClass::update(W3DTreeBuffer *buffer) DX8_ErrorCode(surface_level->UnlockRect()); surface_level->Release(); DX8_ErrorCode(D3DXFilterTexture(Peek_D3D_Texture(), NULL, (UINT)0, D3DX_FILTER_BOX)); - if (TheWritableGlobalData->m_textureReductionFactor) { - DX8_ErrorCode(Peek_D3D_Texture()->SetLOD((DWORD)TheWritableGlobalData->m_textureReductionFactor)); + if (WW3D::Get_Texture_Reduction()) { + DX8_ErrorCode(Peek_D3D_Texture()->SetLOD((DWORD)WW3D::Get_Texture_Reduction())); } return(surface_desc.Height); } @@ -344,10 +344,7 @@ Int W3DTreeBuffer::getPartitionBucket(const Coord3D &pos) const } //============================================================================= -// W3DTreeBuffer::cull -//============================================================================= -/** Culls the trees, marking the visible flag. If a tree becomes visible, it sets -it's sortKey */ +// W3DTreeBuffer::updateSway //============================================================================= void W3DTreeBuffer::updateSway(const BreezeInfo& info) { @@ -362,10 +359,8 @@ void W3DTreeBuffer::updateSway(const BreezeInfo& info) m_swayOffsets[i].Z = C - 1.0f; } - Real delta = info.m_randomness * 0.5f; - for (i=0; igetBreezeInfo(); - Bool pause = TheScriptEngine->isTimeFrozenScript() || TheScriptEngine->isTimeFrozenDebug(); - if (TheGameLogic && TheGameLogic->isGamePaused()) { - pause = true; - } - - // TheSuperHackers @bugfix Mauller 04/07/2025 decouple the tree sway position updates from the client fps - if (TheGameLogic) { - UnsignedInt currentFrame = TheGameLogic->getFrame(); - if (m_lastLogicFrame == currentFrame) { - pause = true; - } - m_lastLogicFrame = currentFrame; + if (info.m_breezeVersion != m_curSwayVersion) + { + updateSway(info); } - Int i; - if (!pause) { - if (info.m_breezeVersion != m_curSwayVersion) - { - updateSway(info); - } - } + // TheSuperHackers @tweak The tree sway, topple and sink time steps are now decoupled from the render update. + const Real timeScale = TheFramePacer->getActualLogicTimeScaleOverFpsRatio(); Vector3 swayFactor[MAX_SWAY_TYPES]; - for (i=0; i NUM_SWAY_ENTRIES-1) { - m_curSwayOffset[i] -= NUM_SWAY_ENTRIES-1; - } + Int i; + for (i=0; i NUM_SWAY_ENTRIES-1) { + m_curSwayOffset[i] -= NUM_SWAY_ENTRIES-1; } Int minOffset = REAL_TO_INT_FLOOR(m_curSwayOffset[i]); if (minOffset>=0 && minOffset+1setSize(m_treeTypes[type].m_shadowSize, -m_treeTypes[type].m_shadowSize*factor); + m_shadow->setSize(m_treeTypes[type].m_shadowSize, m_treeTypes[type].m_shadowSize); m_shadow->setPosition(m_trees[curTree].location.X, m_trees[curTree].location.Y, m_trees[curTree].location.Z); TheW3DProjectedShadowManager->queueDecal(m_shadow); } @@ -1619,30 +1597,29 @@ void W3DTreeBuffer::drawTrees(CameraClass * camera, RefRenderObjListIterator *pD // Update pushed aside and toppling trees. for (curTree=0; curTreem_killWhenToppled) { - if (m_trees[curTree].m_sinkFramesLeft==0) { + if (moduleData->m_killWhenToppled) { + if (m_trees[curTree].m_sinkFramesLeft <= 0.0f) { m_trees[curTree].treeType = DELETED_TREE_TYPE; // delete it. [7/11/2003] m_anythingChanged = true; // need to regenerate trees. [7/11/2003] } - m_trees[curTree].m_sinkFramesLeft--; - m_trees[curTree].location.Z -= m_treeTypes[type].m_data->m_sinkDistance/m_treeTypes[type].m_data->m_sinkFrames; + const Real sinkDistancePerFrame = moduleData->m_sinkDistance / moduleData->m_sinkFrames; + m_trees[curTree].m_sinkFramesLeft -= timeScale; + m_trees[curTree].location.Z -= sinkDistancePerFrame * timeScale; m_trees[curTree].m_mtx.Set_Translation(m_trees[curTree].location); } } else if (m_trees[curTree].pushAsideDelta!=0.0f) { m_trees[curTree].pushAside += m_trees[curTree].pushAsideDelta; if (m_trees[curTree].pushAside>=1.0f) { - m_trees[curTree].pushAsideDelta = -1.0/(Real)m_treeTypes[type].m_data->m_framesToMoveInward; + m_trees[curTree].pushAsideDelta = -1.0f/(Real)moduleData->m_framesToMoveInward; } else if (m_trees[curTree].pushAside<=0.0f) { m_trees[curTree].pushAsideDelta = 0.0f; m_trees[curTree].pushAside = 0.0f; @@ -1862,7 +1839,7 @@ static const Real ANGULAR_LIMIT = PI/2 - PI/64; //------------------------------------------------------------------------------------------------- ///< Keep track of rotational fall distance, bounce and/or stop when needed. //------------------------------------------------------------------------------------------------- -void W3DTreeBuffer::updateTopplingTree(TTree *tree) +void W3DTreeBuffer::updateTopplingTree(TTree *tree, Real timeScale) { //DLOG(Debug::Format("updating W3DTreeBuffer %08lx\n",this)); DEBUG_ASSERTCRASH(tree->m_toppleState != TOPPLE_UPRIGHT, ("hmm, we should be sleeping here")); @@ -1870,7 +1847,7 @@ void W3DTreeBuffer::updateTopplingTree(TTree *tree) return; const W3DTreeDrawModuleData* d = m_treeTypes[tree->treeType].m_data; - Int localPlayerIndex = ThePlayerList ? ThePlayerList->getLocalPlayer()->getPlayerIndex() : 0; + const Int localPlayerIndex = rts::getObservedOrLocalPlayerIndex_Safe(); Coord3D pos; pos.set(tree->location.X, tree->location.Y, tree->location.Z); ObjectShroudStatus ss = ThePartitionManager->getPropShroudStatusForPlayer(localPlayerIndex, &pos); @@ -1886,21 +1863,20 @@ void W3DTreeBuffer::updateTopplingTree(TTree *tree) tree->m_mtx.In_Place_Pre_Rotate_Y(ANGULAR_LIMIT * tree->m_toppleDirection.x); if (d->m_killWhenToppled) { // If got killed in the fog, just remove. jba [8/11/2003] - tree->m_sinkFramesLeft = 0; + tree->m_sinkFramesLeft = 0.0f; } return; } const Real VELOCITY_BOUNCE_LIMIT = 0.01f; // if the velocity after a bounce will be this or lower, just stop at zero const Real VELOCITY_BOUNCE_SOUND_LIMIT = 0.03f; // and if this low, then skip the bounce sound - Real curVelToUse = tree->m_angularVelocity; + Real curVelToUse = tree->m_angularVelocity * timeScale; if (tree->m_angularAccumulation + curVelToUse > ANGULAR_LIMIT) curVelToUse = ANGULAR_LIMIT - tree->m_angularAccumulation; tree->m_mtx.In_Place_Pre_Rotate_X(-curVelToUse * tree->m_toppleDirection.y); tree->m_mtx.In_Place_Pre_Rotate_Y(curVelToUse * tree->m_toppleDirection.x); - tree->m_angularAccumulation += curVelToUse; if ((tree->m_angularAccumulation >= ANGULAR_LIMIT) && (tree->m_angularVelocity > 0)) { @@ -1932,7 +1908,7 @@ void W3DTreeBuffer::updateTopplingTree(TTree *tree) } else { - tree->m_angularVelocity += tree->m_angularAcceleration; + tree->m_angularVelocity += tree->m_angularAcceleration * timeScale; } } @@ -1943,7 +1919,7 @@ void W3DTreeBuffer::updateTopplingTree(TTree *tree) void W3DTreeBuffer::crc( Xfer *xfer ) { // empty. jba [8/11/2003] -} // end CRC +} // ------------------------------------------------------------------------------------------------ /** Xfer @@ -1954,7 +1930,11 @@ void W3DTreeBuffer::xfer( Xfer *xfer ) { // version +#if RETAIL_COMPATIBLE_XFER_SAVE XferVersion currentVersion = 1; +#else + XferVersion currentVersion = 2; +#endif XferVersion version = currentVersion; xfer->xferVersion( &version, currentVersion ); @@ -2014,7 +1994,17 @@ void W3DTreeBuffer::xfer( Xfer *xfer ) xfer->xferReal(&tree.m_angularAccumulation); ///< How much have I rotated so I know when to bounce. xfer->xferUnsignedInt(&tree.m_options); ///< topple options xfer->xferMatrix3D(&tree.m_mtx); - xfer->xferUnsignedInt(&tree.m_sinkFramesLeft); ///< Toppled trees sink into the terrain & disappear, how many frames left. + + if (version <= 1) + { + UnsignedInt sinkFramesLeft = (UnsignedInt)tree.m_sinkFramesLeft; + xfer->xferUnsignedInt(&sinkFramesLeft); ///< Toppled trees sink into the terrain & disappear, how many frames left. + tree.m_sinkFramesLeft = (Real)sinkFramesLeft; + } + else + { + xfer->xferReal(&tree.m_sinkFramesLeft); ///< Toppled trees sink into the terrain & disappear, how many frames left. + } if (xfer->getXferMode() == XFER_LOAD && treeType != DELETED_TREE_TYPE && treeType < m_numTreeTypes) { Coord3D pos; @@ -2034,7 +2024,7 @@ void W3DTreeBuffer::xfer( Xfer *xfer ) } } -} // end xfer +} // ------------------------------------------------------------------------------------------------ /** Load post process */ @@ -2042,7 +2032,7 @@ void W3DTreeBuffer::xfer( Xfer *xfer ) void W3DTreeBuffer::loadPostProcess( void ) { // empty. jba [8/11/2003] -} // end loadPostProcess +} diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DVideoBuffer.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DVideoBuffer.cpp index e69a99e6b3..6f190d0063 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DVideoBuffer.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DVideoBuffer.cpp @@ -120,8 +120,8 @@ Bool W3DVideoBuffer::allocate( UnsignedInt width, UnsignedInt height ) m_width = width; m_height = height; - m_textureWidth = width;; - m_textureHeight = height;; + m_textureWidth = width; + m_textureHeight = height; unsigned int temp_depth=1; TextureLoader::Validate_Texture_Size( m_textureWidth, m_textureHeight, temp_depth); diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp similarity index 96% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp index ae9ab7f442..704f000e25 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp @@ -38,6 +38,8 @@ // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// #include "Common/BuildAssistant.h" +#include "Common/FramePacer.h" +#include "Common/GameUtility.h" #include "Common/GlobalData.h" #include "Common/Module.h" #include "Common/RandomValue.h" @@ -91,7 +93,7 @@ #include "WW3D2/predlod.h" #include "WW3D2/ww3d.h" -#include "W3DDevice/GameClient/camerashakesystem.h" +#include "W3DDevice/GameClient/CameraShakeSystem.h" #include "WinMain.h" /** @todo Remove this, it's only here because we are using timeGetTime, but we can remove that @@ -100,7 +102,7 @@ // 30 fps -Int TheW3DFrameLengthInMsec = 1000/LOGICFRAMES_PER_SECOND; // default is 33msec/frame == 30fps. but we may change it depending on sys config. +Real TheW3DFrameLengthInMsec = MSEC_PER_LOGICFRAME_REAL; // default is 33msec/frame == 30fps. but we may change it depending on sys config. static const Int MAX_REQUEST_CACHE_SIZE = 40; // Any size larger than 10, or examine code below for changes. jkmcd. static const Real DRAWABLE_OVERSCAN = 75.0f; ///< 3D world coords of how much to overscan in the 3D screen region @@ -118,18 +120,7 @@ inline Real maxf(Real a, Real b) { if (a > b) return a; else return b; } //------------------------------------------------------------------------------------------------- static void normAngle(Real &angle) { - if (angle < -10*PI) { - angle = 0; - } - if (angle > 10*PI) { - angle = 0; - } - while (angle < -PI) { - angle += 2*PI; - } - while (angle > PI) { - angle -= 2*PI; - } + angle = WWMath::Normalize_Angle(angle); } #define TERRAIN_SAMPLE_SIZE 40.0f @@ -181,7 +172,7 @@ W3DView::W3DView() m_shakerAngles.Y =0.0f; m_shakerAngles.Z =0.0f; -} // end W3DView +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -191,7 +182,7 @@ W3DView::~W3DView() REF_PTR_RELEASE( m_2DCamera ); REF_PTR_RELEASE( m_3DCamera ); -} // end ~W3DView +} //------------------------------------------------------------------------------------------------- /** Sets the height of the viewport, while maintaining original camera perspective. */ @@ -386,6 +377,14 @@ void W3DView::buildCameraTransform( Matrix3D *transform ) } else { + // TheSuperHackers @todo Investigate whether the non Generals code is correct for Zero Hour. + // It certainly is incorrect for Generals when m_FXPitch goes above 1: + // Seen in USA mission 1 second cut scene with SCUD Storm. +#if RTS_GENERALS + Real height = sourcePos.Z - targetPos.Z; + height *= m_FXPitch; + targetPos.Z = sourcePos.Z - height; +#else if (m_FXPitch <= 1.0f) { Real height = sourcePos.Z - targetPos.Z; @@ -397,6 +396,7 @@ void W3DView::buildCameraTransform( Matrix3D *transform ) sourcePos.X = targetPos.X + ((sourcePos.X - targetPos.X) / m_FXPitch); sourcePos.Y = targetPos.Y + ((sourcePos.Y - targetPos.Y) / m_FXPitch); } +#endif } //m_3DCamera->Set_View_Plane(DEG_TO_RADF(50.0f)); @@ -408,7 +408,8 @@ void W3DView::buildCameraTransform( Matrix3D *transform ) transform->Look_At( sourcePos, targetPos, 0 ); //WST 11/12/2002 New camera shaker system - CameraShakerSystem.Timestep(1.0f/30.0f); + // TheSuperHackers @tweak The camera shaker is now decoupled from the render update. + CameraShakerSystem.Timestep(TheFramePacer->getLogicTimeStepMilliseconds()); CameraShakerSystem.Update_Camera_Shaker(sourcePos, &m_shakerAngles); transform->Rotate_X(m_shakerAngles.X); transform->Rotate_Y(m_shakerAngles.Y); @@ -443,13 +444,9 @@ void W3DView::buildCameraTransform( Matrix3D *transform ) // WST 10.22.2002. Update the Listener positions used by audio system //-------------------------------------------------------------------- Vector3 position = transform->Get_Translation(); - m_pos.x = position.X; - m_pos.y = position.Y; - m_pos.z = position.Z; - - - //DEBUG_LOG(("mpos x%f, y%f, z%f", m_pos.x, m_pos.y, m_pos.z )); - + Coord3D coord; + coord.set(position.X, position.Y, position.Z); + View::setPosition(&coord); break; } } @@ -557,6 +554,10 @@ void W3DView::setCameraTransform( void ) { if (TheGlobalData->m_headless) return; + + if (m_viewLockedUntilFrame > TheGameClient->getFrame()) + return; + m_cameraHasMovedSinceRequest = true; Matrix3D cameraTransform( 1 ); @@ -661,7 +662,7 @@ void W3DView::init( void ) m_scrollAmountCutoff = TheGlobalData->m_scrollAmountCutoff; -} // end init +} //------------------------------------------------------------------------------------------------- const Coord3D& W3DView::get3DCameraPosition() const @@ -698,9 +699,9 @@ void W3DView::reset( void ) static void drawDrawable( Drawable *draw, void *userData ) { - draw->draw( (View *)userData ); + draw->draw(); -} // end drawDrawable +} // ------------------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------------------- @@ -766,7 +767,7 @@ static void drawContainedDrawable( Object *obj, void *userData ) if( draw ) drawDrawableExtents( draw, userData ); -} // end drawContainedDrawable +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -816,11 +817,11 @@ static void drawDrawableExtents( Drawable *draw, void *userData ) z += draw->getDrawableGeometryInfo().getMaxHeightAbovePosition(); - } // end for i + } break; - } // end case box + } //--------------------------------------------------------------------------------------------- case GEOMETRY_SPHERE: // not quite right, but close enough @@ -836,7 +837,7 @@ static void drawDrawableExtents( Drawable *draw, void *userData ) // next time 'round, draw the top of the cylinder center.z += draw->getDrawableGeometryInfo().getMaxHeightAbovePosition(); - } // end for i + } // draw centerline ICoord2D start, end; @@ -848,9 +849,9 @@ static void drawDrawableExtents( Drawable *draw, void *userData ) break; - } // case CYLINDER + } - } // end switch + } // draw any extents for things that are contained by this Object *obj = draw->getObject(); @@ -861,9 +862,9 @@ static void drawDrawableExtents( Drawable *draw, void *userData ) if( contain ) contain->iterateContained( drawContainedDrawable, userData, FALSE ); - } // end if + } -} // end drawDrawableExtents +} void drawAudioLocations( Drawable *draw, void *userData ); @@ -877,7 +878,7 @@ static void drawContainedAudioLocations( Object *obj, void *userData ) if( draw ) drawAudioLocations( draw, userData ); -} // end drawContainedAudio +} //------------------------------------------------------------------------------------------------- @@ -894,7 +895,7 @@ static void drawAudioLocations( Drawable *draw, void *userData ) if( contain ) contain->iterateContained( drawContainedAudioLocations, userData, FALSE ); - } // end if + } const ThingTemplate * thingTemplate = draw->getTemplate(); @@ -988,7 +989,7 @@ static void drawablePostDraw( Drawable *draw, void *userData ) return; Object* obj = draw->getObject(); - Int localPlayerIndex = ThePlayerList ? ThePlayerList->getLocalPlayer()->getPlayerIndex() : 0; + const Int localPlayerIndex = rts::getObservedOrLocalPlayerIndex_Safe(); #if ENABLE_CONFIGURABLE_SHROUD ObjectShroudStatus ss = (!obj || !TheGlobalData->m_shroudOn) ? OBJECTSHROUD_CLEAR : obj->getShroudedStatus(localPlayerIndex); #else @@ -1022,7 +1023,7 @@ static void drawablePostDraw( Drawable *draw, void *userData ) TheGameClient->incrementRenderedObjectCount(); -} // end drawablePostDraw +} //------------------------------------------------------------------------------------------------- // Display AI debug visuals @@ -1053,7 +1054,9 @@ Bool W3DView::updateCameraMovements() didUpdate = true; } else if (m_doingMoveCameraOnWaypointPath) { m_previousLookAtPosition = *getPosition(); - moveAlongWaypointPath(TheW3DFrameLengthInMsec); + // TheSuperHackers @tweak The scripted camera movement is now decoupled from the render update. + // The scripted camera will still move when the time is frozen, but not when the game is halted. + moveAlongWaypointPath(TheFramePacer->getLogicTimeStepMilliseconds(FramePacer::IgnoreFrozenTime)); didUpdate = true; } if (m_doingScriptedCameraLock) @@ -1077,6 +1080,35 @@ void W3DView::updateView(void) UPDATE(); } +// TheSuperHackers @tweak xezon 12/08/2025 The camera shaker is no longer tied to the render +// update. The shake does sharp shakes on every fixed time step, and is not intended to have +// linear interpolation during the render update. +void W3DView::stepView() +{ + // + // Process camera shake + // + if (m_shakeIntensity > 0.01f) + { + m_shakeOffset.x = m_shakeIntensity * m_shakeAngleCos; + m_shakeOffset.y = m_shakeIntensity * m_shakeAngleSin; + + // fake a stiff spring/damper + const Real dampingCoeff = 0.75f; + m_shakeIntensity *= dampingCoeff; + + // spring is so "stiff", it pulls 180 degrees opposite each frame + m_shakeAngleCos = -m_shakeAngleCos; + m_shakeAngleSin = -m_shakeAngleSin; + } + else + { + m_shakeIntensity = 0.0f; + m_shakeOffset.x = 0.0f; + m_shakeOffset.y = 0.0f; + } +} + //DECLARE_PERF_TIMER(W3DView_updateView) void W3DView::update(void) { @@ -1289,29 +1321,11 @@ void W3DView::update(void) } // // Process camera shake - /// @todo Make this framerate-independent // if (m_shakeIntensity > 0.01f) { - m_shakeOffset.x = m_shakeIntensity * m_shakeAngleCos; - m_shakeOffset.y = m_shakeIntensity * m_shakeAngleSin; - - // fake a stiff spring/damper - const Real dampingCoeff = 0.75f; - m_shakeIntensity *= dampingCoeff; - - // spring is so "stiff", it pulls 180 degrees opposite each frame - m_shakeAngleCos = -m_shakeAngleCos; - m_shakeAngleSin = -m_shakeAngleSin; - recalcCamera = true; } - else - { - m_shakeIntensity = 0.0f; - m_shakeOffset.x = 0.0f; - m_shakeOffset.y = 0.0f; - } //Process New C3 Camera Shaker system if (CameraShakerSystem.IsCameraShaking()) @@ -1327,40 +1341,46 @@ void W3DView::update(void) * scrolling), the zoom will move toward matching the desired height. */ // TheSuperHackers @tweak Can now also zoom when the game is paused. + // TheSuperHackers @tweak The camera zoom speed is now decoupled from the render update. + // TheSuperHackers @bugfix The camera terrain height adjustment now also works in replay playback. + m_terrainHeightUnderCamera = getHeightAroundPos(m_pos.x, m_pos.y); m_currentHeightAboveGround = m_cameraOffset.z * m_zoom - m_terrainHeightUnderCamera; + if (TheTerrainLogic && TheGlobalData && TheInGameUI && m_okToAdjustHeight) { Real desiredHeight = (m_terrainHeightUnderCamera + m_heightAboveGround); Real desiredZoom = desiredHeight / m_cameraOffset.z; - if (didScriptedMovement || (TheGameLogic->isInReplayGame() && TheGlobalData->m_useCameraInReplay)) + + if (didScriptedMovement) { // if we are in a scripted camera movement, take its height above ground as our desired height. m_heightAboveGround = m_currentHeightAboveGround; //DEBUG_LOG(("Frame %d: height above ground: %g %g %g %g", TheGameLogic->getFrame(), m_heightAboveGround, // m_cameraOffset.z, m_zoom, m_terrainHeightUnderCamera)); } + if (TheInGameUI->isScrolling()) { // if scrolling, only adjust if we're too close or too far if (m_scrollAmount.length() < m_scrollAmountCutoff || (m_currentHeightAboveGround < m_minHeightAboveGround) || (TheGlobalData->m_enforceMaxCameraHeight && m_currentHeightAboveGround > m_maxHeightAboveGround)) { - Real zoomAdj = (desiredZoom - m_zoom)*TheGlobalData->m_cameraAdjustSpeed; - if (fabs(zoomAdj) >= 0.0001) // only do positive + const Real fpsRatio = TheFramePacer->getBaseOverUpdateFpsRatio(); + const Real zoomAdj = (desiredZoom - m_zoom) * TheGlobalData->m_cameraAdjustSpeed * fpsRatio; + if (fabs(zoomAdj) >= 0.0001f) // only do positive { m_zoom += zoomAdj; recalcCamera = true; } } } - else + else if (!didScriptedMovement) { // we're not scrolling; settle toward desired height above ground - Real zoomAdj = (m_zoom - desiredZoom)*TheGlobalData->m_cameraAdjustSpeed; - Real zoomAdjAbs = fabs(zoomAdj); - if (zoomAdjAbs >= 0.0001 && !didScriptedMovement) + const Real fpsRatio = TheFramePacer->getBaseOverUpdateFpsRatio(); + const Real zoomAdj = (m_zoom - desiredZoom) * TheGlobalData->m_cameraAdjustSpeed * fpsRatio; + if (fabs(zoomAdj) >= 0.0001f) { - //DEBUG_LOG(("W3DView::update() - m_zoom=%g, desiredHeight=%g", m_zoom, desiredZoom)); m_zoom -= zoomAdj; recalcCamera = true; } @@ -1377,7 +1397,7 @@ void W3DView::update(void) #ifdef DO_SEISMIC_SIMULATIONS - // Give the terrain a chance to refresh animaing (Seismic) regions, if any. + // Give the terrain a chance to refresh animating (Seismic) regions, if any. TheTerrainVisual->updateSeismicSimulations(); #endif @@ -1386,8 +1406,7 @@ void W3DView::update(void) // render all of the visible Drawables /// @todo this needs to use a real region partition or something - if (WW3D::Get_Frame_Time()) //make sure some time actually elapsed - TheGameClient->iterateDrawablesInRegion( &axisAlignedRegion, drawDrawable, this ); + TheGameClient->iterateDrawablesInRegion( &axisAlignedRegion, drawDrawable, NULL ); } //------------------------------------------------------------------------------------------------- @@ -1420,7 +1439,7 @@ void W3DView::getAxisAlignedViewRegion(Region3D &axisAlignedRegion) if( box[ i ].y > axisAlignedRegion.hi.y ) axisAlignedRegion.hi.y = box[ i ].y; - } // end for i + } // low and high regions will be based of the extent of the map Region3D mapExtent; @@ -1683,7 +1702,7 @@ void W3DView::draw( void ) } } - } // end if, show debug AI + } #if defined(RTS_DEBUG) if( TheGlobalData->m_debugCamera ) @@ -1795,32 +1814,36 @@ void W3DView::setSnapMode( CameraLockType lockType, Real lockDist ) } //------------------------------------------------------------------------------------------------- -/** Scroll the view by the given delta in SCREEN COORDINATES, this interface - * assumes we will be scrolling along the X,Y plane */ +// Scroll the view by the given delta in SCREEN COORDINATES, this interface +// assumes we will be scrolling along the X,Y plane +// +// TheSuperHackers @bugfix Now rotates the view plane on the Z axis only to properly discard the +// camera pitch. The aspect ratio also no longer modifies the vertical scroll speed. //------------------------------------------------------------------------------------------------- void W3DView::scrollBy( Coord2D *delta ) { // if we haven't moved, ignore if( delta && (delta->x != 0 || delta->y != 0) ) { - const Real SCROLL_RESOLUTION = 250.0f; + constexpr const Real SCROLL_RESOLUTION = 250.0f; Vector3 world, worldStart, worldEnd; - Vector2 screen, start, end; + Vector2 start, end; m_scrollAmount = *delta; - screen.X = delta->x; - screen.Y = delta->y; - start.X = getWidth(); start.Y = getHeight(); - Real aspect = getHeight() == 0 ? 1 : getWidth()/getHeight(); + end.X = start.X + delta->x * SCROLL_RESOLUTION; - end.Y = start.Y + delta->y * SCROLL_RESOLUTION*aspect; + end.Y = start.Y + delta->y * SCROLL_RESOLUTION; + + m_3DCamera->Device_To_View_Space( start, &worldStart ); + m_3DCamera->Device_To_View_Space( end, &worldEnd ); - m_3DCamera->Device_To_World_Space( start, &worldStart ); - m_3DCamera->Device_To_World_Space( end, &worldEnd ); + const Real zRotation = m_3DCamera->Get_Transform().Get_Z_Rotation(); + worldStart.Rotate_Z(zRotation); + worldEnd.Rotate_Z(zRotation); world.X = worldEnd.X - worldStart.X; world.Y = worldEnd.Y - worldStart.Y; @@ -1840,9 +1863,9 @@ void W3DView::scrollBy( Coord2D *delta ) // set new camera position setCameraTransform(); - } // end if + } -} // end scrollBy +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -1901,7 +1924,7 @@ void W3DView::setAngleAndPitchToDefault( void ) // call our base class, we are adding functionality View::setAngleAndPitchToDefault(); - this->m_FXPitch = 1.0; + m_FXPitch = 1.0; // set the camera setCameraTransform(); @@ -1923,19 +1946,7 @@ void W3DView::setDefaultView(Real pitch, Real angle, Real maxHeight) //------------------------------------------------------------------------------------------------- void W3DView::setHeightAboveGround(Real z) { - m_heightAboveGround = z; - - // if our zoom is limited, we will stay within a predefined distance from the terrain - if( m_zoomLimited ) - { - - if (m_heightAboveGround < m_minHeightAboveGround) - m_heightAboveGround = m_minHeightAboveGround; - - if (m_heightAboveGround > m_maxHeightAboveGround) - m_heightAboveGround = m_maxHeightAboveGround; - - } // end if + View::setHeightAboveGround(z); m_doingMoveCameraOnWaypointPath = false; m_CameraArrivedAtWaypointOnPathFlag = false; @@ -1949,15 +1960,13 @@ void W3DView::setHeightAboveGround(Real z) //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- +// TheSuperHackers @bugfix xezon 18/09/2025 setZoom is no longer clamped by a min and max zoom. +// Instead the min and max camera height will be clamped elsewhere. Clamping the zoom would cause +// issues with camera playback in replay playback where changes in terrain elevation would not raise +// the camera height. void W3DView::setZoom(Real z) { - m_zoom = z; - - if (m_zoom < m_minZoom) - m_zoom = m_minZoom; - - if (m_zoom > m_maxZoom) - m_zoom = m_maxZoom; + View::setZoom(z); m_doingMoveCameraOnWaypointPath = false; m_CameraArrivedAtWaypointOnPathFlag = false; @@ -2058,10 +2067,10 @@ View::WorldToScreenReturn W3DView::worldToScreenTriReturn( const Coord3D *w, ICo return WTS_INSIDE_FRUSTUM; - } // end if + } return WTS_INVALID; -} // end worldToScreenTriReturn +} //------------------------------------------------------------------------------------------------- /** Using the W3D camera translate the screen coord to world coord */ @@ -2076,9 +2085,9 @@ void W3DView::screenToWorld( const ICoord2D *s, Coord3D *w ) if( m_3DCamera ) { DEBUG_CRASH(("implement me")); - } // end if + } -} // end screenToWorld +} //------------------------------------------------------------------------------------------------- /** all the drawables in the view, that fall within the 2D screen region @@ -2122,7 +2131,7 @@ Int W3DView::iterateDrawablesInRegion( IRegion2D *screenRegion, normalizedRegion.hi.x = ((Real)(screenRegion->hi.x - m_originX) / (Real)getWidth()) * 2.0f - 1.0f; normalizedRegion.hi.y = -(((Real)(screenRegion->lo.y - m_originY) / (Real)getHeight()) * 2.0f - 1.0f); - } // end if + } Drawable *onlyDrawableToTest = NULL; @@ -2173,10 +2182,10 @@ Int W3DView::iterateDrawablesInRegion( IRegion2D *screenRegion, inside = TRUE; - } // end if + } } - } //end else + } // if inside do the callback and count up if( inside ) @@ -2185,17 +2194,17 @@ Int W3DView::iterateDrawablesInRegion( IRegion2D *screenRegion, if( callback( draw, userData ) ) ++count; - } // end if + } // If onlyDrawableToTest, then we should bail out now. if (onlyDrawableToTest != NULL) break; - } // end for draw + } return count; -} // end iterateDrawablesInRegion +} //------------------------------------------------------------------------------------------------- /** cast a ray from the screen coords into the scene and return a drawable @@ -2254,7 +2263,7 @@ Drawable *W3DView::pickDrawable( const ICoord2D *screen, Bool forceAttack, PickT return draw; -} // end pickDrawable +} //------------------------------------------------------------------------------------------------- /** convert a pixel (x,y) to a location in the world on the terrain. @@ -2301,7 +2310,7 @@ void W3DView::screenToTerrain( const ICoord2D *screen, Coord3D *world ) // get the point of intersection according to W3D intersection = result.ContactPoint; - } // end if + } // Pick bridges. Vector3 bridgePt; @@ -2319,7 +2328,7 @@ void W3DView::screenToTerrain( const ICoord2D *screen, Coord3D *world ) req.second = (*world); m_locationRequests.push_back(req); // Insert this request at the end, requires no extra copies -} // end screenToTerrain +} //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -2358,7 +2367,7 @@ void W3DView::lookAt( const Coord3D *o ) pos.x = result.ContactPoint.X; pos.y = result.ContactPoint.Y; - } // end if + } } pos.z = 0; setPosition(&pos); @@ -2512,7 +2521,13 @@ void W3DView::rotateCameraTowardPosition(const Coord3D *pLoc, Int milliseconds, m_rcInfo.curFrame = 0; m_doingRotateCamera = true; m_rcInfo.angle.startAngle = m_angle; + // TheSuperHackers @todo Investigate if the non Generals code is correct for Zero Hour. + // It certainly is incorrect for Generals: Seen in GLA mission 1 opening cut scene. +#if RTS_GENERALS + m_rcInfo.angle.endAngle = m_angle + angle; +#else m_rcInfo.angle.endAngle = angle; +#endif m_rcInfo.startTimeMultiplier = m_timeMultiplier; m_rcInfo.endTimeMultiplier = m_timeMultiplier; m_rcInfo.ease.setEaseTimes(easeIn/milliseconds, easeOut/milliseconds); @@ -3092,7 +3107,7 @@ void W3DView::pitchCameraOneFrame(void) // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ -void W3DView::moveAlongWaypointPath(Int milliseconds) +void W3DView::moveAlongWaypointPath(Real milliseconds) { m_mcwpInfo.elapsedTimeMilliseconds += milliseconds; if (TheGlobalData->m_disableCameraMovement) { @@ -3130,8 +3145,14 @@ void W3DView::moveAlongWaypointPath(Int milliseconds) const Real deltaTime = m_mcwpInfo.ease(m_mcwpInfo.elapsedTimeMilliseconds/totalTime) - m_mcwpInfo.ease((m_mcwpInfo.elapsedTimeMilliseconds - milliseconds)/totalTime); m_mcwpInfo.curSegDistance += deltaTime*m_mcwpInfo.totalDistance; - while (m_mcwpInfo.curSegDistance >= m_mcwpInfo.waySegLength[m_mcwpInfo.curSegment]) { - + // TheSuperHacker @todo Investigate which one is really correct. + // The non Generals condition causes camera bug in Generals Shell Map. +#if RTS_GENERALS + while (m_mcwpInfo.curSegDistance > m_mcwpInfo.waySegLength[m_mcwpInfo.curSegment]) +#else + while (m_mcwpInfo.curSegDistance >= m_mcwpInfo.waySegLength[m_mcwpInfo.curSegment]) +#endif + { if ( m_doingMoveCameraOnWaypointPath ) { //WWDEBUG_SAY(( "MBL TEST: Camera waypoint along path reached!" )); @@ -3315,7 +3336,7 @@ void W3DView::screenToWorldAtZ( const ICoord2D *s, Coord3D *w, Real z ) w->y = Vector3::Find_Y_At_Z( z, rayStart, rayEnd ); w->z = z; -} // end screenToWorldAtZ +} void W3DView::cameraEnableSlaveMode(const AsciiString & objectName, const AsciiString & boneName) { diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp similarity index 98% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp index 2567cffcb4..2addc0e8ba 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp @@ -31,7 +31,6 @@ #define SCROLL_UV // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "stdio.h" #include "W3DDevice/GameClient/W3DWater.h" #include "W3DDevice/GameClient/HeightMap.h" #include "W3DDevice/GameClient/W3DShroud.h" @@ -49,6 +48,7 @@ #include "mesh.h" #include "matinfo.h" +#include "Common/FramePacer.h" #include "Common/GameState.h" #include "Common/GlobalData.h" #include "Common/PerfTimer.h" @@ -299,8 +299,7 @@ WaterRenderObjClass::~WaterRenderObjClass(void) SAFE_RELEASE( m_pBumpTexture2[i]); } - if (m_meshData) - delete [] m_meshData; + delete [] m_meshData; m_meshData = NULL; m_meshDataSize = 0; @@ -313,8 +312,7 @@ WaterRenderObjClass::~WaterRenderObjClass(void) TheWaterTransparency = NULL; ReleaseResources(); - if (m_waterTrackSystem) - delete m_waterTrackSystem; + delete m_waterTrackSystem; } //------------------------------------------------------------------------------------------------- @@ -527,7 +525,7 @@ HRESULT WaterRenderObjClass::initBumpMap(LPDIRECT3DTEXTURE8 *pTex, TextureClass pTex[0]->UnlockRect(level); surf->Unlock(); REF_PTR_RELEASE (surf); - }//for each level + } #else surf=pBumpSource->Get_Surface_Level(); @@ -621,8 +619,8 @@ HRESULT WaterRenderObjClass::generateVertexBuffer( Int sizeX, Int sizeY, Int ver { m_numVertices=sizeX*sizeY; //Assuming dynamic vertex buffer, allocate maximum multiple of required size to allow rendering from - //different parts of the buffer. 5-15-03: Disabled this since we use DISCARD mode instead to avoid Nvidia Runtime bug. -MW - //m_numVertices=(65536 / (sizeX*sizeY))*sizeX*sizeY; + //different parts of the buffer. 5-15-03: Disabled this since we use DISCARD mode instead to avoid Nvidia Runtime bug. -MW + //m_numVertices=(65536 / (sizeX*sizeY))*sizeX*sizeY; SEA_PATCH_VERTEX* pVertices; @@ -986,7 +984,7 @@ void WaterRenderObjClass::load(void) Int WaterRenderObjClass::init(Real waterLevel, Real dx, Real dy, SceneClass *parentScene, WaterType type) { - m_iBumpFrame=0; + m_fBumpFrame=0; m_fBumpScale=SEA_BUMP_SCALE; m_dx=dx; @@ -1164,14 +1162,14 @@ void WaterRenderObjClass::reset( void ) // on to the next one pData++; - } // end for i + } - } // end for j + } // mesh data is no longer in motion m_meshInMotion = FALSE; - } // end if, water type 3 + } if (m_waterTrackSystem) m_waterTrackSystem->reset(); @@ -1206,38 +1204,33 @@ void WaterRenderObjClass::enableWaterGrid(Bool state) } // ------------------------------------------------------------------------------------------------ -/** Update phase for water if we need it. This called once per client frame reguardless - * of how fast the logic framerate is running */ +/** Update phase for water if we need it. */ // ------------------------------------------------------------------------------------------------ void WaterRenderObjClass::update( void ) { - static UnsignedInt lastLogicFrame = 0; - UnsignedInt currLogicFrame = 0; + // TheSuperHackers @tweak The water movement time step is now decoupled from the render update. + const Real timeScale = TheFramePacer->getActualLogicTimeScaleOverFpsRatio(); - if( TheGameLogic ) - currLogicFrame = TheGameLogic->getFrame(); - - // we only process things if the logic frame has changed - if( lastLogicFrame != currLogicFrame ) { + constexpr const Real MagicOffset = 0.0125f * 33 / 5000; ///< the work of top Munkees; do not question it - m_riverVOrigin += 0.002f; - m_riverXOffset += (Real)(0.0125*33/5000); - m_riverYOffset += (Real)(2*0.0125*33/5000); - if (m_riverXOffset > 1) m_riverXOffset -= 1; - if (m_riverYOffset > 1) m_riverYOffset -= 1; - if (m_riverXOffset < -1) m_riverXOffset += 1; - if (m_riverYOffset < -1) m_riverYOffset += 1; - m_iBumpFrame++; - if (m_iBumpFrame >= NUM_BUMP_FRAMES) { - m_iBumpFrame = 0; - } + m_riverVOrigin += 0.002f * timeScale; + m_riverXOffset += (Real)(MagicOffset * timeScale); + m_riverYOffset += (Real)(2 * MagicOffset * timeScale); + + // This moves offsets towards zero when smaller -1.0 or larger 1.0 + m_riverXOffset -= (Int)m_riverXOffset; + m_riverYOffset -= (Int)m_riverYOffset; + + m_fBumpFrame += timeScale; + if (m_fBumpFrame >= NUM_BUMP_FRAMES) + m_fBumpFrame = 0.0f; // for vertex animated water we need to update the vector field if( m_doWaterGrid && m_meshInMotion == TRUE ) { const Real PREFERRED_HEIGHT_FUDGE = 1.0f; ///< this is close enough to at rest - const Real AT_REST_VELOCITY_FUDGE = 1.0f; ///< when we're close enought to at rest height and velocity we will stop + const Real AT_REST_VELOCITY_FUDGE = 1.0f; ///< when we're close enough to at rest height and velocity we will stop const Real WATER_DAMPENING = 0.93f; ///< use with up force of 15.0 Int i, j; Int mx = m_gridCellsX+1; @@ -1285,32 +1278,29 @@ void WaterRenderObjClass::update( void ) pData->height = pData->preferredHeight; pData->velocity = 0.0f; - } // end if + } else { // there is still motion in the mesh, we need to process next frame m_meshInMotion = TRUE; - } // end else + } - } // end if + } // on to the next one pData++; - } // end for i - - } // end for j + } - } // end if + } - // mark the last logic frame we processed on - lastLogicFrame = currLogicFrame; + } - } // end if, a logic frame has passed + } -} // end update +} //------------------------------------------------------------------------------------------------- @@ -1710,12 +1700,12 @@ void WaterRenderObjClass::Render(RenderInfoClass & rinfo) ShaderClass::Invalidate(); //reset shading system so it forces full state set. renderWater(); - } //WATER_TYPE_1 + } break; default: break; - }//switch + } if (TheGlobalData && TheGlobalData->m_drawSkyBox) { //center skybox around camera @@ -1848,7 +1838,7 @@ void WaterRenderObjClass::drawSea(RenderInfoClass & rinfo) m_pDev->SetTextureStageState(1, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP); m_pDev->SetTextureStageState(1, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP); - m_pDev->SetTexture( 0, m_pBumpTexture[m_iBumpFrame]); + m_pDev->SetTexture( 0, m_pBumpTexture[(Int)m_fBumpFrame]); #ifdef MIPMAP_BUMP_TEXTURE m_pDev->SetTextureStageState( 0, D3DTSS_MIPFILTER, D3DTEXF_POINT ); m_pDev->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); @@ -2239,9 +2229,9 @@ void WaterRenderObjClass::renderWaterMesh(void) if (!m_doWaterGrid) return; //the water grid is disabled. - //According to Nvidia there's a D3D bug that happens if you don't start with a - //new dynamic VB each frame - so we force a DISCARD by overflowing the counter. - m_vertexBufferD3DOffset = 0xffff; + //According to Nvidia there's a D3D bug that happens if you don't start with a + //new dynamic VB each frame - so we force a DISCARD by overflowing the counter. + m_vertexBufferD3DOffset = 0xffff; Setting *setting=&m_settings[m_tod]; @@ -2529,7 +2519,7 @@ void WaterRenderObjClass::addVelocity( Real worldX, Real worldY, } - } // end if, water type is 3 + } } @@ -2691,11 +2681,11 @@ Real WaterRenderObjClass::getWaterHeight(Real x, Real y) waterZ = pTrig->getPoint( 0 )->z; waterHandle = pTrig->getWaterHandle(); - } // end if + } - } // end if + } - } // end for + } if (waterHandle) return waterHandle->m_polygon->getPoint( 0 )->z; @@ -3431,7 +3421,7 @@ void WaterRenderObjClass::renderSkyBody(Matrix3D *mat) void WaterRenderObjClass::crc( Xfer *xfer ) { -} // end crc +} // ------------------------------------------------------------------------------------------------ /** Xfer @@ -3455,7 +3445,7 @@ void WaterRenderObjClass::xfer( Xfer *xfer ) DEBUG_CRASH(( "WaterRenderObjClass::xfer - cells X mismatch" )); throw SC_INVALID_DATA; - } // end if + } // grid cells Y Int cellsY = m_gridCellsY; @@ -3466,7 +3456,7 @@ void WaterRenderObjClass::xfer( Xfer *xfer ) DEBUG_CRASH(( "WaterRenderObjClass::xfer - cells Y mismatch" )); throw SC_INVALID_DATA; - } // end if + } // xfer each of the mesh data points for( UnsignedInt i = 0; i < m_meshDataSize; ++i ) @@ -3484,9 +3474,9 @@ void WaterRenderObjClass::xfer( Xfer *xfer ) // preferred height xfer->xferUnsignedByte( &m_meshData[ i ].preferredHeight ); - } // end for, i + } -} // end xfer +} // ------------------------------------------------------------------------------------------------ /** Load post process */ @@ -3494,6 +3484,6 @@ void WaterRenderObjClass::xfer( Xfer *xfer ) void WaterRenderObjClass::loadPostProcess( void ) { -} // end loadPostProcess +} diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp similarity index 97% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp index aa755f5936..afc6ed9013 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp @@ -50,6 +50,7 @@ #include "GameClient/InGameUI.h" #include "GameClient/Water.h" #include "GameLogic/TerrainLogic.h" +#include "Common/FramePacer.h" #include "Common/GlobalData.h" #include "Common/UnicodeString.h" #include "Common/file.h" @@ -62,10 +63,6 @@ #include "assetmgr.h" #include "WW3D2/dx8wrapper.h" -//#pragma optimize("", off) - -//#define ALLOW_WATER_TRACK_EDIT - //number of vertex pages allocated - allows double buffering of vertex updates. //while one is being rendered, another is being updated. Improves HW parallelism. #define WATER_VB_PAGES 1000 @@ -283,18 +280,6 @@ void WaterTracksObj::init( Real width, const Vector2 &start, const Vector2 &end, //============================================================================= Int WaterTracksObj::update(Int msElapsed) { -#ifdef ALLOW_WATER_TRACK_EDIT -// if (pauseWaves) -// m_elapsedMs = m_timeToReachBeach+m_timeToStop; -// else -#endif - - //nothing to do here...most of the work is done on render. - m_elapsedMs += msElapsed; //advance time for this update - - ///@todo: Should check in here if we are done with this object are return FALSE to free it. - // return FALSE; - return TRUE; //assume we had an update } @@ -310,6 +295,9 @@ Int WaterTracksObj::update(Int msElapsed) Int WaterTracksObj::render(DX8VertexBufferClass *vertexBuffer, Int batchStart) { + // TheSuperHackers @tweak The wave movement time step is now decoupled from the render update. + m_elapsedMs += TheFramePacer->getLogicTimeStepMilliseconds(); + VertexFormatXYZDUV1 *vb; Vector2 waveTailOrigin,waveFrontOrigin; Real ooWaveDirLen=1.0f/m_waveDir.Length(); //one over length @@ -544,7 +532,7 @@ WaterTracksObj *WaterTracksRenderSystem::bindTrack(waveType type) } mod->m_bound=true; - } // end if + } #ifdef SYNC_WAVES nextmod=m_usedModules; @@ -553,11 +541,11 @@ WaterTracksObj *WaterTracksRenderSystem::bindTrack(waveType type) { nextmod->m_elapsedMs=nextmod->m_initTimeOffset; nextmod=nextmod->m_nextSystem; - } // end while + } #endif return mod; -} //end bindTrack +} //============================================================================= //WaterTracksRenderSystem::unbindTrack @@ -731,7 +719,7 @@ void WaterTracksRenderSystem::init(void) assert( 0 ); return; - } // end if + } // allocate our modules for this system for( i = 0; i < numModules; i++ ) @@ -746,7 +734,7 @@ void WaterTracksRenderSystem::init(void) assert( 0 ); return; - } // end if + } mod->m_prevSystem = NULL; mod->m_nextSystem = m_freeModules; @@ -754,9 +742,9 @@ void WaterTracksRenderSystem::init(void) m_freeModules->m_prevSystem = mod; m_freeModules = mod; - } // end for i + } -} // end init +} void WaterTracksRenderSystem::reset(void) { @@ -772,7 +760,7 @@ void WaterTracksRenderSystem::reset(void) releaseTrack(mod); mod = nextMod; - } // end while + } // free all attached things and used modules @@ -799,7 +787,7 @@ void WaterTracksRenderSystem::shutdown( void ) releaseTrack(mod); mod = nextMod; - } // end while + } // free all attached things and used modules @@ -813,13 +801,13 @@ void WaterTracksRenderSystem::shutdown( void ) delete m_freeModules; m_freeModules = nextMod; - } // end while + } REF_PTR_RELEASE(m_indexBuffer); REF_PTR_RELEASE(m_vertexMaterialClass); REF_PTR_RELEASE(m_vertexBuffer); -} // end shutdown +} //============================================================================= // WaterTracksRenderSystem::update @@ -846,7 +834,7 @@ void WaterTracksRenderSystem::update() } mod = nextMod; - } // end while + } } @@ -879,9 +867,9 @@ Try improving the fit to vertical surfaces like cliffs. if (!m_usedModules || ShaderClass::Is_Backface_Culling_Inverted()) return; //don't render track marks in reflections. - //According to Nvidia there's a D3D bug that happens if you don't start with a - //new dynamic VB each frame - so we force a DISCARD by overflowing the counter. - m_batchStart = 0xffff; + //According to Nvidia there's a D3D bug that happens if you don't start with a + //new dynamic VB each frame - so we force a DISCARD by overflowing the counter. + m_batchStart = 0xffff; // adjust shading for time of day. Real shadeR, shadeG, shadeB; @@ -938,7 +926,7 @@ Try improving the fit to vertical surfaces like cliffs. m_batchStart = vertsRendered; //advance past vertices already in buffer mod = mod->m_nextSystem; - } //while (mod) + } DX8Wrapper::Set_DX8_Render_State(D3DRS_ZBIAS,0); @@ -960,7 +948,7 @@ WaterTracksObj *WaterTracksRenderSystem::findTrack(Vector2 &start, Vector2 &end, mod->m_type == type) return mod; mod = mod->m_nextSystem; - } //while (mod) + } return NULL; } void WaterTracksRenderSystem::saveTracks(void) @@ -972,10 +960,8 @@ void WaterTracksRenderSystem::saveTracks(void) AsciiString fileName=TheTerrainLogic->getSourceFilename(); char path[256]; - strcpy(path,fileName.str()); - Int len=strlen(path); - - strcpy(path+len-4,".wak"); + strlcpy(path, fileName.str(), ARRAY_SIZE(path)); + strlcat(path, ".wak", ARRAY_SIZE(path)); WaterTracksObj *umod; Int trackCount=0; @@ -995,7 +981,7 @@ void WaterTracksRenderSystem::saveTracks(void) trackCount++; } umod=umod->m_nextSystem; - } // end while + } fwrite(&trackCount,sizeof(trackCount),1,fp); fclose(fp); } @@ -1010,10 +996,8 @@ void WaterTracksRenderSystem::loadTracks(void) AsciiString fileName=TheTerrainLogic->getSourceFilename(); char path[256]; - strcpy(path,fileName.str()); - Int len=strlen(path); - - strcpy(path+len-4,".wak"); + strlcpy(path, fileName.str(), ARRAY_SIZE(path)); + strlcat(path, ".wak", ARRAY_SIZE(path)); File *file = TheFileSystem->openFile(path, File::READ | File::BINARY); WaterTracksObj *umod; diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/wave.nvp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/wave.nvp similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/wave.nvp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/wave.nvp diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/wave.nvv b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/wave.nvv similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Water/wave.nvv rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/wave.nvv diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp similarity index 97% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp index 10914d02bd..52384dfed5 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp @@ -30,7 +30,6 @@ #include "windows.h" #include "stdlib.h" -#include #include "Common/STLTypedefs.h" #include "Common/DataChunk.h" @@ -374,42 +373,33 @@ TileData *WorldHeightMap::m_alphaTiles[NUM_ALPHA_TILES]={0,0,0,0,0,0,0,0,0,0,0,0 // WorldHeightMap::~WorldHeightMap(void) { - if (m_data) { - delete[](m_data); - m_data = NULL; - } - if (m_tileNdxes) { - delete[](m_tileNdxes); - m_tileNdxes = NULL; - } - if (m_blendTileNdxes) { - delete[](m_blendTileNdxes); - m_blendTileNdxes = NULL; - } - if (m_extraBlendTileNdxes) { - delete[](m_extraBlendTileNdxes); - m_extraBlendTileNdxes = NULL; - } - if (m_cliffInfoNdxes) { - delete[](m_cliffInfoNdxes); - m_cliffInfoNdxes = NULL; - } - if (m_cellFlipState) - { delete[](m_cellFlipState); - m_cellFlipState = NULL; - } - if (m_seismicUpdateFlag) - { delete[](m_seismicUpdateFlag); - m_seismicUpdateFlag = NULL; - } - if (m_seismicZVelocities) - { delete[](m_seismicZVelocities); - m_seismicZVelocities = NULL; - } - if (m_cellCliffState) - { delete[](m_cellCliffState); - m_cellCliffState = NULL; - } + delete[](m_data); + m_data = NULL; + + delete[](m_tileNdxes); + m_tileNdxes = NULL; + + delete[](m_blendTileNdxes); + m_blendTileNdxes = NULL; + + delete[](m_extraBlendTileNdxes); + m_extraBlendTileNdxes = NULL; + + delete[](m_cliffInfoNdxes); + m_cliffInfoNdxes = NULL; + + delete[](m_cellFlipState); + m_cellFlipState = NULL; + + delete[](m_seismicUpdateFlag); + m_seismicUpdateFlag = NULL; + + delete[](m_seismicZVelocities); + m_seismicZVelocities = NULL; + + delete[](m_cellCliffState); + m_cellCliffState = NULL; + int i; for (i=0; iemptySides(); - file.registerParser(AsciiString("SidesList"), AsciiString::TheEmptyString, SidesList::ParseSidesDataChunk ); + file.registerParser("SidesList", AsciiString::TheEmptyString, SidesList::ParseSidesDataChunk ); } else { - file.registerParser( AsciiString("HeightMapData"), AsciiString::TheEmptyString, ParseHeightMapDataChunk ); - file.registerParser( AsciiString("BlendTileData"), AsciiString::TheEmptyString, ParseBlendTileDataChunk ); + file.registerParser( "HeightMapData", AsciiString::TheEmptyString, ParseHeightMapDataChunk ); + file.registerParser( "BlendTileData", AsciiString::TheEmptyString, ParseBlendTileDataChunk ); #ifdef EVAL_TILING_MODES - file.registerParser( AsciiString("FUNKY_TILING"), AsciiString::TheEmptyString, ParseFunkyTilingDataChunk ); + file.registerParser( "FUNKY_TILING", AsciiString::TheEmptyString, ParseFunkyTilingDataChunk ); #endif - file.registerParser( AsciiString("GlobalLighting"), AsciiString::TheEmptyString, ParseLightingDataChunk ); + file.registerParser( "GlobalLighting", AsciiString::TheEmptyString, ParseLightingDataChunk ); } if (!file.parse(this)) { @@ -590,9 +580,6 @@ void WorldHeightMap::clearFlipStates(void) { } } - - - //////////////////////////////////////////////////////////////////////////////m_SeismicUpdateFlag Bool WorldHeightMap::getSeismicUpdateFlag(Int xIndex, Int yIndex) const { @@ -708,21 +695,6 @@ Real WorldHeightMap::getBilinearSampleSeismicZVelocity( Int x, Int y) } - - - - - - - - - - - - - - - /** Get whether the cell is a cliff cell (impassable to ground vehicles). */ Bool WorldHeightMap::getCliffState(Int xIndex, Int yIndex) const @@ -858,7 +830,7 @@ Bool WorldHeightMap::ParseLightingDataChunk(DataChunkInput &file, DataChunkInfo Bool WorldHeightMap::ParseObjectsDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData) { file.m_currentObject = NULL; - file.registerParser( AsciiString("Object"), info->label, ParseObjectDataChunk ); + file.registerParser( "Object", info->label, ParseObjectDataChunk ); return (file.parse(userData)); } @@ -2223,8 +2195,8 @@ TextureClass *WorldHeightMap::getEdgeTerrainTexture(void) TerrainTextureClass *WorldHeightMap::getFlatTexture(Int xCell, Int yCell, Int cellWidth, Int pixelsPerCell) { - if (TheWritableGlobalData->m_textureReductionFactor) { - if (TheWritableGlobalData->m_textureReductionFactor>1) { + if (WW3D::Get_Texture_Reduction()) { + if (WW3D::Get_Texture_Reduction()>1) { pixelsPerCell /= 4; } else { pixelsPerCell /= 2; @@ -2492,7 +2464,7 @@ void WorldHeightMap::setupAlphaTiles(void) case K_RDIAG : blendInfo.rightDiagonal = true; break; case K_LLDIAG : blendInfo.leftDiagonal = true; blendInfo.longDiagonal = true; break; case K_LRDIAG : blendInfo.rightDiagonal = true; blendInfo.longDiagonal = true; break; - } // end of case. + } m_alphaTiles[k] = new TileData; TileData *pTile = m_alphaTiles[k]; diff --git a/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFile.cpp b/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFile.cpp index 540bd4ad48..9379f1042a 100644 --- a/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFile.cpp +++ b/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFile.cpp @@ -38,7 +38,9 @@ // Win32BIGFile::Win32BIGFile //============================================================================ -Win32BIGFile::Win32BIGFile() +Win32BIGFile::Win32BIGFile(AsciiString name, AsciiString path) + : m_name(name) + , m_path(path) { } @@ -86,7 +88,7 @@ File* Win32BIGFile::openFile( const Char *filename, Int access ) // whoever is opening this file wants write access, so copy the file to the local disk // and return that file pointer. - CONSTEXPR size_t bufferSize = 0; + constexpr size_t bufferSize = 0; File *localFile = TheLocalFileSystem->openFile(filename, access, bufferSize); if (localFile != NULL) { ramFile->copyDataToFile(localFile); diff --git a/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp b/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp index f0a07b912f..5aaedc2f1b 100644 --- a/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp +++ b/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp @@ -64,8 +64,8 @@ void Win32BIGFileSystem::init() { AsciiString installPath; GetStringFromGeneralsRegistry("", "InstallPath", installPath ); //@todo this will need to be ramped up to a crash for release - DEBUG_ASSERTCRASH(installPath != "", ("Be 1337! Go install Generals!")); - if (installPath!="") + DEBUG_ASSERTCRASH(!installPath.isEmpty(), ("Be 1337! Go install Generals!")); + if (!installPath.isEmpty()) loadBigFilesFromDirectory(installPath, "*.big"); #endif } @@ -129,7 +129,7 @@ ArchiveFile * Win32BIGFileSystem::openArchiveFile(const Char *filename) { // 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; + ArchiveFile *archiveFile = NEW Win32BIGFile(filename, AsciiString::TheEmptyString); for (Int i = 0; i < numLittleFiles; ++i) { Int filesize = 0; @@ -211,16 +211,26 @@ void Win32BIGFileSystem::closeAllFiles() { Bool Win32BIGFileSystem::loadBigFilesFromDirectory(AsciiString dir, AsciiString fileMask, Bool overwrite) { FilenameList filenameList; - TheLocalFileSystem->getFileListInDirectory(dir, AsciiString(""), fileMask, filenameList, TRUE); + TheLocalFileSystem->getFileListInDirectory(dir, "", fileMask, filenameList, TRUE); Bool actuallyAdded = FALSE; FilenameListIter it = filenameList.begin(); while (it != filenameList.end()) { +#if RTS_ZEROHOUR + // TheSuperHackers @bugfix bobtista 18/11/2025 Skip duplicate INIZH.big in Data\INI to prevent CRC mismatches. + // English, Chinese, and Korean SKUs shipped with two INIZH.big files (one in Run directory, one in Run\Data\INI). + // The DeleteFile cleanup doesn't work on EA App/Origin installs because the folder is not writable, so we skip loading it instead. + if (it->endsWithNoCase("Data\\INI\\INIZH.big") || it->endsWithNoCase("Data/INI/INIZH.big")) { + it++; + continue; + } +#endif + ArchiveFile *archiveFile = openArchiveFile((*it).str()); if (archiveFile != NULL) { DEBUG_LOG(("Win32BIGFileSystem::loadBigFilesFromDirectory - loading %s into the directory tree.", (*it).str())); - loadIntoDirectoryTree(archiveFile, *it, overwrite); + loadIntoDirectoryTree(archiveFile, overwrite); m_archiveFileMap[(*it)] = archiveFile; DEBUG_LOG(("Win32BIGFileSystem::loadBigFilesFromDirectory - %s inserted into the archive file map.", (*it).str())); actuallyAdded = TRUE; diff --git a/Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp b/Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp index 49e8b8de1a..84236de436 100644 --- a/Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp +++ b/Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp @@ -127,21 +127,19 @@ void Win32LocalFileSystem::getFileListInDirectory(const AsciiString& currentDire 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); + fileHandle = FindFirstFile(asciisearch.str(), &findData); done = (fileHandle == INVALID_HANDLE_VALUE); while (!done) { if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - (strcmp(findData.cFileName, ".") && strcmp(findData.cFileName, ".."))) { + (strcmp(findData.cFileName, ".") != 0 && strcmp(findData.cFileName, "..") != 0)) { // if we haven't already, add this filename to the list. // a stl set should only allow one copy of each filename AsciiString newFilename; @@ -167,7 +165,7 @@ void Win32LocalFileSystem::getFileListInDirectory(const AsciiString& currentDire while (!done) { if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - (strcmp(findData.cFileName, ".") && strcmp(findData.cFileName, ".."))) { + (strcmp(findData.cFileName, ".") != 0 && strcmp(findData.cFileName, "..") != 0)) { AsciiString tempsearchstr; tempsearchstr.concat(currentDirectory); diff --git a/Core/Libraries/Include/Lib/BaseTypeCore.h b/Core/Libraries/Include/Lib/BaseTypeCore.h index 6f824f21da..550bdd5adf 100644 --- a/Core/Libraries/Include/Lib/BaseTypeCore.h +++ b/Core/Libraries/Include/Lib/BaseTypeCore.h @@ -26,11 +26,8 @@ /////////////////////////////////////////////////////////////////////////////// // tell the compiler to only load this file once -#pragma once - -#ifndef _BASE_TYPE_CORE_H_ -#define _BASE_TYPE_CORE_H_ +#pragma once #include #include @@ -117,11 +114,6 @@ #define FALSE false #endif -// Elements in an array -#ifndef ELEMENTS_OF -#define ELEMENTS_OF( x ) ( sizeof( x ) / sizeof( x[0] ) ) -#endif - //-------------------------------------------------------------------- // Fundamental type definitions //-------------------------------------------------------------------- @@ -137,5 +129,3 @@ typedef bool Bool; // // note, the types below should use "long long", but MSVC doesn't support it yet typedef int64_t Int64; // 8 bytes typedef uint64_t UnsignedInt64; // 8 bytes - -#endif // _BASE_TYPE_CORE_H_ diff --git a/Core/Libraries/Include/rts/debug.h b/Core/Libraries/Include/rts/debug.h index cfe69a3bb8..d758693cbc 100644 --- a/Core/Libraries/Include/rts/debug.h +++ b/Core/Libraries/Include/rts/debug.h @@ -26,12 +26,7 @@ // // Proxy header for debug module ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef PROXY_DEBUG_H // Include guard -#define PROXY_DEBUG_H -#include "../../Source/debug/debug.h" +#pragma once -#endif // PROXY_DEBUG_H +#include "../../Source/debug/debug.h" diff --git a/Core/Libraries/Include/rts/profile.h b/Core/Libraries/Include/rts/profile.h index 34cf2d4d46..06faf42d04 100644 --- a/Core/Libraries/Include/rts/profile.h +++ b/Core/Libraries/Include/rts/profile.h @@ -26,12 +26,7 @@ // // Proxy header for profile module ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER + # pragma once -#endif -#ifndef PROXY_PROFILE_H // Include guard -#define PROXY_PROFILE_H #include "../../Source/profile/profile.h" - -#endif // PROXY_PROFILE_H diff --git a/Core/Libraries/Source/Compression/Compression.h b/Core/Libraries/Source/Compression/Compression.h index bea68a6b40..d93ac23226 100644 --- a/Core/Libraries/Source/Compression/Compression.h +++ b/Core/Libraries/Source/Compression/Compression.h @@ -22,9 +22,6 @@ #pragma once -#ifndef __COMPRESSION_H__ -#define __COMPRESSION_H__ - #include "Lib/BaseTypeCore.h" enum CompressionType @@ -67,5 +64,3 @@ class CompressionManager static CompressionType getPreferredCompression( void ); }; - -#endif // __COMPRESSION_H__ diff --git a/Core/Libraries/Source/Compression/EAC/btreecodex.h b/Core/Libraries/Source/Compression/EAC/btreecodex.h index cf28f5bea6..ed72b83597 100644 --- a/Core/Libraries/Source/Compression/EAC/btreecodex.h +++ b/Core/Libraries/Source/Compression/EAC/btreecodex.h @@ -18,16 +18,12 @@ /* Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. */ -#ifndef __BTRCODEX -#define __BTRCODEX 1 #ifdef __cplusplus extern "C" { #endif -#ifndef __CODEX_H -#error "Include codex.h before btreecodex.h" -#endif +#include "codex.h" /****************************************************************/ /* BTR Codex */ @@ -58,5 +54,4 @@ int GCALL BTREE_encode(void *compresseddata, const void *source, int sour #ifdef __cplusplus } #endif -#endif diff --git a/Core/Libraries/Source/Compression/EAC/btreeencode.cpp b/Core/Libraries/Source/Compression/EAC/btreeencode.cpp index 0ffbe0bae1..0afc2cfa57 100644 --- a/Core/Libraries/Source/Compression/EAC/btreeencode.cpp +++ b/Core/Libraries/Source/Compression/EAC/btreeencode.cpp @@ -367,11 +367,18 @@ static void BTREE_treepack(struct BTreeEncodeContext *EC, EC->buf1 = (unsigned char *) galloc(buf1size); if (!EC->buf1) - return; /* failure Insufficient memory for work buffer */ + { + gfree(treebuf); + return; /* failure Insufficient memory for work buffer */ + } EC->buf2 = (unsigned char *) galloc(buf2size); if (!EC->buf2) - return; /* failure Insufficient memory for work buffer */ + { + gfree(treebuf); + gfree(EC->buf1); + return; /* failure Insufficient memory for work buffer */ + } memcpy(EC->buf1, EC->buffer, EC->ulen); /* copy to scratch buffer */ diff --git a/Core/Libraries/Source/Compression/EAC/codex.h b/Core/Libraries/Source/Compression/EAC/codex.h index f4d3441e55..2b80d2171f 100644 --- a/Core/Libraries/Source/Compression/EAC/codex.h +++ b/Core/Libraries/Source/Compression/EAC/codex.h @@ -37,12 +37,7 @@ /* */ /*------------------------------------------------------------------*/ -#ifndef __CODEX_H -#define __CODEX_H 1 - -#if defined(_MSC_VER) #pragma once -#endif #ifdef __cplusplus extern "C" { @@ -119,5 +114,4 @@ int GCALL CODEX_encode(void *dest, const void *source, int sourcesize, int *opts #ifdef __cplusplus } #endif -#endif diff --git a/Core/Libraries/Source/Compression/EAC/gimex.h b/Core/Libraries/Source/Compression/EAC/gimex.h index 51260341f5..c1cc3325e1 100644 --- a/Core/Libraries/Source/Compression/EAC/gimex.h +++ b/Core/Libraries/Source/Compression/EAC/gimex.h @@ -63,11 +63,9 @@ gimex.h - Primary header file for the GIMEX API. /* */ /*------------------------------------------------------------------*/ -#ifndef __GIMEX_H -#define __GIMEX_H 1 +#pragma once #if defined(_MSC_VER) -#pragma once #pragma warning(disable : 4100) /* warning C4100: unreferenced parameter */ #endif @@ -492,6 +490,4 @@ static __inline void gputi(void *dst, unsigned int data, int bytes) } } -#endif /* __GIMEX_H */ - /* END ABSTRACT */ diff --git a/Core/Libraries/Source/Compression/EAC/huffcodex.h b/Core/Libraries/Source/Compression/EAC/huffcodex.h index af1d756d4b..027a4f38b0 100644 --- a/Core/Libraries/Source/Compression/EAC/huffcodex.h +++ b/Core/Libraries/Source/Compression/EAC/huffcodex.h @@ -18,16 +18,12 @@ /* Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. */ -#ifndef __HUFCODEX -#define __HUFCODEX 1 #ifdef __cplusplus extern "C" { #endif -#ifndef __CODEX_H -#error "Include codex.h before huffcodex.h" -#endif +#include "codex.h" /****************************************************************/ /* HUF Codex */ @@ -70,5 +66,4 @@ int GCALL HUFF_encode(void *compresseddata, const void *source, int sourc #ifdef __cplusplus } #endif -#endif diff --git a/Core/Libraries/Source/Compression/EAC/refcodex.h b/Core/Libraries/Source/Compression/EAC/refcodex.h index 80fdb92c20..ca92f004b3 100644 --- a/Core/Libraries/Source/Compression/EAC/refcodex.h +++ b/Core/Libraries/Source/Compression/EAC/refcodex.h @@ -18,16 +18,12 @@ /* Copyright (C) Electronic Arts Canada Inc. 1995-2002. All rights reserved. */ -#ifndef __REFCODEX -#define __REFCODEX 1 #ifdef __cplusplus extern "C" { #endif -#ifndef __CODEX_H -#error "Include codex.h before refcodex.h" -#endif +#include "codex.h" /****************************************************************/ /* REF Codex */ @@ -70,5 +66,4 @@ int GCALL REF_encode(void *compresseddata, const void *source, int source #ifdef __cplusplus } #endif -#endif diff --git a/Core/Libraries/Source/Compression/EAC/refencode.cpp b/Core/Libraries/Source/Compression/EAC/refencode.cpp index f88414d789..2f12606d5c 100644 --- a/Core/Libraries/Source/Compression/EAC/refencode.cpp +++ b/Core/Libraries/Source/Compression/EAC/refencode.cpp @@ -79,7 +79,10 @@ static int refcompress(unsigned char *from, int len, unsigned char *dest, int ma return(0); link = (int *) galloc(131072L*sizeof(int)); if (!link) - return(0); + { + gfree(hashtbl); + return(0); + } memset(hashtbl,-1,65536L*sizeof(int)); diff --git a/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp b/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp index 771000eecf..224084152a 100644 --- a/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp +++ b/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp @@ -20,7 +20,6 @@ // Compress interface for packets and files // Author: Jeff Brown, January 1999 -#include #include #include "Lib/BaseTypeCore.h" #include "NoxCompress.h" @@ -69,7 +68,11 @@ Bool DecompressFile (char *infile, char *outfile) outBlock= (char *) DbgMalloc( rawSize ); if (( inBlock == NULL ) || ( outBlock == NULL )) + { + if (inBlock) DbgFree(inBlock); + if (outBlock) DbgFree(outBlock); return FALSE; + } // Read in a big chunk o file NoxRead(inBlock, 1, compressedSize, inFilePtr); @@ -97,22 +100,20 @@ Bool DecompressFile (char *infile, char *outfile) DEBUG_LOG(("Decompressed %s to %s, output size = %d", infile, outfile, rawSize)); + Bool success = FALSE; LZHLDestroyDecompressor(decompress); outFilePtr = fopen(outfile, "wb"); if (outFilePtr) { fwrite (outBlock, rawSize, 1, outFilePtr); fclose(outFilePtr); + success = TRUE; } - else - return FALSE; - // Clean up this mess DbgFree(inBlock); DbgFree(outBlock); - return TRUE; - - } // End of if fileptr + return success; + } return FALSE; } @@ -148,7 +149,11 @@ Bool CompressFile (char *infile, char *outfile) outBlock= (char *) DbgMalloc( LZHLCompressorCalcMaxBuf( rawSize )); if (( inBlock == NULL ) || ( outBlock == NULL )) + { + DbgFree(inBlock); + DbgFree(outBlock); return FALSE; + } // Read in a big chunk o file NoxRead(inBlock, 1, rawSize, inFilePtr); @@ -164,8 +169,8 @@ Bool CompressFile (char *infile, char *outfile) compressedSize += compressed; } + Bool success = FALSE; LZHLDestroyCompressor(compressor); - outFilePtr = fopen(outfile, "wb"); if (outFilePtr) { @@ -173,14 +178,12 @@ Bool CompressFile (char *infile, char *outfile) fwrite(&rawSize, sizeof(UnsignedInt), 1, outFilePtr); fwrite(outBlock, compressedSize, 1, outFilePtr); fclose(outFilePtr); + success = TRUE; } - else - return FALSE; - // Clean up DbgFree(inBlock); DbgFree(outBlock); - return TRUE; + return success; } return FALSE; diff --git a/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.h b/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.h index 48afbcb4ec..0a14bd00af 100644 --- a/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.h +++ b/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.h @@ -20,9 +20,7 @@ // Compress/Decompression header. // Author: Jeff Brown, January 1999 - -#ifndef __compress_h -#define __compress_h +#pragma once #define MAP_EXTENSION ".map" #define LZH_EXTENSION ".nxz" @@ -36,5 +34,3 @@ UnsignedInt CalcNewSize (UnsignedInt rawSize); Bool DecompressMemory (void *inBufferVoid, Int inSize, void *outBufferVoid, Int& outSize); Bool CompressMemory (void *inBufferVoid, Int inSize, void *outBufferVoid, Int& outSize); - -#endif // __compress_h diff --git a/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt b/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt index 628746e29f..35c7ff4bd6 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt @@ -15,8 +15,8 @@ set(WW3D2_SRC assetstatus.h bitmaphandler.cpp bitmaphandler.h - #bmp2d.cpp - #bmp2d.h + bmp2d.cpp + bmp2d.h #boxrobj.cpp #boxrobj.h bwrender.cpp @@ -56,8 +56,8 @@ set(WW3D2_SRC #dx8renderer.h #dx8rendererdebugger.cpp #dx8rendererdebugger.h - #dx8texman.cpp - #dx8texman.h + dx8texman.cpp + dx8texman.h #dx8vertexbuffer.cpp #dx8vertexbuffer.h dx8webbrowser.cpp @@ -81,7 +81,7 @@ set(WW3D2_SRC #hlod.cpp #hlod.h hmdldef.cpp - hmdldef.H + hmdldef.h #hmorphanim.cpp #hmorphanim.h #hrawanim.cpp @@ -108,8 +108,8 @@ set(WW3D2_SRC #mapper.h matinfo.cpp matinfo.h - #matpass.cpp - #matpass.h + matpass.cpp + matpass.h #matrixmapper.cpp #matrixmapper.h #mesh.cpp @@ -200,18 +200,18 @@ set(WW3D2_SRC stripoptimizer.h surfaceclass.cpp surfaceclass.h - #texproject.cpp - #texproject.h + texproject.cpp + texproject.h #textdraw.cpp # unused textdraw.h - #texture.cpp - #texture.h - #texturefilter.cpp - #texturefilter.h - #textureloader.cpp - #textureloader.h - #texturethumbnail.cpp - #texturethumbnail.h + texture.cpp + texture.h + texturefilter.cpp + texturefilter.h + textureloader.cpp + textureloader.h + texturethumbnail.cpp + texturethumbnail.h #vertmaterial.cpp #vertmaterial.h visrasterizer.cpp diff --git a/Core/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp b/Core/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp index 612d9fb5be..0fb36d93ac 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp @@ -21,7 +21,6 @@ ////////////////////////////////////////////////////////////////////// #include "framgrab.h" -#include #include //#include diff --git a/Core/Libraries/Source/WWVegas/WW3D2/aabtree.cpp b/Core/Libraries/Source/WWVegas/WW3D2/aabtree.cpp index d353ea9a74..0dc4fb8cc2 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/aabtree.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/aabtree.cpp @@ -211,18 +211,14 @@ AABTreeClass & AABTreeClass::operator = (const AABTreeClass & that) void AABTreeClass::Reset(void) { NodeCount = 0; - if (Nodes) { - delete[] Nodes; - Nodes = NULL; - } + delete[] Nodes; + Nodes = NULL; + PolyCount = 0; - if (PolyIndices) { - delete[] PolyIndices; - PolyIndices = NULL; - } - if (Mesh) { - Mesh = NULL; - } + delete[] PolyIndices; + PolyIndices = NULL; + + Mesh = NULL; } /*********************************************************************************************** @@ -728,10 +724,6 @@ bool AABTreeClass::Intersect_OBBox_Recursive(AABTreeClass::CullNodeStruct * node return res; } -#ifdef RTS_DEBUG -#pragma optimize("", off) // We get an odd error when using optimized in the debug. -// All optimized seems to work. jba. -#endif /*********************************************************************************************** * AABTreeClass::Cast_Ray_To_Polys -- cast the ray to polys in the given node * * * @@ -791,10 +783,6 @@ bool AABTreeClass::Cast_Ray_To_Polys(CullNodeStruct * node,RayCollisionTestClass } return false; } -#ifdef RTS_DEBUG -#pragma optimize("", on) -#endif - /*********************************************************************************************** * AABTreeClass::Cast_Semi_Infinite_Axis_Aligned_Ray_To_Polys -- cast ray to polys in the node * diff --git a/Core/Libraries/Source/WWVegas/WW3D2/aabtree.h b/Core/Libraries/Source/WWVegas/WW3D2/aabtree.h index 270fb46569..d38dc9d6d0 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/aabtree.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/aabtree.h @@ -37,15 +37,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef AABTREE_H -#define AABTREE_H #include "always.h" -#include "refcount.h" #include "simplevec.h" #include "vector3.h" #include "Vector3i.h" @@ -350,5 +344,3 @@ inline void AABTreeClass::CullNodeStruct::Set_Poly_Count(uint32 count) WWASSERT(count < 0x7FFFFFFF); BackOrPolyCount = count; } - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/agg_def.cpp b/Core/Libraries/Source/WWVegas/WW3D2/agg_def.cpp index 1ebbfcf202..9353b28978 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/agg_def.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/agg_def.cpp @@ -182,9 +182,7 @@ AggregateDefClass::Free_Subobject_List (void) // Delete all the stucture pointers contained in the subobject list for (int index = 0; index < m_SubobjectList.Count (); index ++) { W3dAggregateSubobjectStruct *pinfo = m_SubobjectList[index]; - if (pinfo) { - delete pinfo; - } + delete pinfo; } // Reset the lists contents @@ -883,7 +881,7 @@ AggregateLoaderClass::Load_W3D (ChunkLoadClass &chunk_load) // Error! Free the definition delete pdefinition; - pdefinition = NULL; + } else { // Success! Create a prototype from the definition diff --git a/Core/Libraries/Source/WWVegas/WW3D2/agg_def.h b/Core/Libraries/Source/WWVegas/WW3D2/agg_def.h index 3e8055c370..be2d636e0c 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/agg_def.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/agg_def.h @@ -32,21 +32,14 @@ * * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef AGGREGATE_DEF_H -#define AGGREGATE_DEF_H #include "proto.h" #include "rendobj.h" #include "w3d_file.h" #include "w3derr.h" -#include "Vector.H" +#include "Vector.h" #include "bittype.h" -#include #ifdef _UNIX #include "osdep.h" @@ -254,6 +247,3 @@ class AggregateLoaderClass : public PrototypeLoaderClass // Global variables // extern AggregateLoaderClass _AggregateLoader; - - -#endif //__AGGREGATE_DEF_H diff --git a/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp b/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp index 5a046060e5..8202d5ce2f 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp @@ -37,13 +37,11 @@ // MBL Update for CNC3 INCURSION - 10.23.2002 - Expanded param handling, Added STOP command // -#include // stricmp() #include "animatedsoundmgr.h" -#include "INI.H" +#include "INI.h" #include "inisup.h" #include "ffactory.h" -#include "WWFILE.H" -#include +#include "WWFILE.h" #include "definition.h" #include "definitionmgr.h" #include "definitionclassids.h" diff --git a/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h b/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h index 25a0c2f27c..980e259591 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h @@ -37,15 +37,10 @@ // MBL Update for CNC3 INCURSION - 10.23.2002 - Expanded param handling, Added STOP command // -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __ANIMATEDSOUNDMGR_H -#define __ANIMATEDSOUNDMGR_H #include "simplevec.h" -#include "Vector.H" +#include "Vector.h" #include "hashtemplate.h" @@ -131,6 +126,3 @@ class AnimatedSoundMgrClass /////////////////////////////////////////////////////////////////// static ANIM_SOUND_LIST * Find_Sound_List (HAnimClass *anim); }; - - -#endif //__ANIMATEDSOUNDMGR_H diff --git a/Core/Libraries/Source/WWVegas/WW3D2/assetstatus.cpp b/Core/Libraries/Source/WWVegas/WW3D2/assetstatus.cpp index 78fa70cf9a..22d67d5c71 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/assetstatus.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/assetstatus.cpp @@ -19,7 +19,7 @@ #include "assetstatus.h" #include "hashtemplate.h" #include "wwstring.h" -#include "RAWFILE.H" +#include "RAWFILE.h" AssetStatusClass AssetStatusClass::Instance; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/assetstatus.h b/Core/Libraries/Source/WWVegas/WW3D2/assetstatus.h index 019ad0c72d..bb25aa729c 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/assetstatus.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/assetstatus.h @@ -16,12 +16,7 @@ ** along with this program. If not, see . */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef WW3D_ASSET_STATUS_H -#define WW3D_ASSET_STATUS_H #include "always.h" #include "hashtemplate.h" @@ -64,5 +59,3 @@ class AssetStatusClass void Add_To_Report(int index, const char* name); }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/bitmaphandler.h b/Core/Libraries/Source/WWVegas/WW3D2/bitmaphandler.h index e13fdc1f42..d12ceb63c5 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/bitmaphandler.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/bitmaphandler.h @@ -16,12 +16,7 @@ ** along with this program. If not, see . */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef BITMAPHANDLER_H -#define BITMAPHANDLER_H #include "always.h" #include "ww3dformat.h" @@ -479,6 +474,3 @@ WWINLINE unsigned BitmapHandlerClass::Combine_A8R8G8B8( bgra1+=bgra3; return bgra1; } - - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/bmp2d.cpp b/Core/Libraries/Source/WWVegas/WW3D2/bmp2d.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/bmp2d.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/bmp2d.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/bmp2d.h b/Core/Libraries/Source/WWVegas/WW3D2/bmp2d.h similarity index 97% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/bmp2d.h rename to Core/Libraries/Source/WWVegas/WW3D2/bmp2d.h index 863589825a..abf993dd32 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/bmp2d.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/bmp2d.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef BMP2D_H -#define BMP2D_H #include "dynamesh.h" @@ -55,5 +50,3 @@ class Bitmap2DObjClass : public DynamicScreenMeshClass virtual RenderObjClass * Clone(void) const; virtual int Class_ID(void) const { return CLASSID_BITMAP2D; } }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/bwrender.cpp b/Core/Libraries/Source/WWVegas/WW3D2/bwrender.cpp index a922e26346..9f8f9dbfca 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/bwrender.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/bwrender.cpp @@ -39,7 +39,6 @@ #include "bwrender.h" #include "vp.h" -#include BWRenderClass::Buffer::Buffer(unsigned char* buffer_, int scale_) diff --git a/Core/Libraries/Source/WWVegas/WW3D2/bwrender.h b/Core/Libraries/Source/WWVegas/WW3D2/bwrender.h index 887fec5d50..0c6db33b9d 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/bwrender.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/bwrender.h @@ -36,13 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef BWRENDER_H -#define BWRENDER_H - #include "always.h" #include "vector2.h" @@ -74,7 +68,7 @@ class BWRenderClass void Set_H_Line(int start_x, int end_x, int y); void Fill(unsigned char c); - inline int Scale() const { return scale; } + int Scale() const { return scale; } } pixel_buffer; Vector2* vertices; @@ -90,7 +84,3 @@ class BWRenderClass void Render_Triangles(const unsigned long* indices,int index_count); void Render_Triangle_Strip(const unsigned long* indices,int index_count); }; - - -#endif //BWRENDER_H - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/classid.h b/Core/Libraries/Source/WWVegas/WW3D2/classid.h index 4607fe766d..a734133cfb 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/classid.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/classid.h @@ -32,13 +32,7 @@ * * *-------------------------------------------------------------------------*/ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef CLASSID_H -#define CLASSID_H #include "always.h" @@ -60,6 +54,3 @@ enum ID_STREAMING_TEXTURE_CLASS, // StreamingTextureClass "texture.h" ID_STREAMING_TEXTURE_INSTANCE_CLASS, // StreamingTextureInstanceClass "texture.h" }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/collect.cpp b/Core/Libraries/Source/WWVegas/WW3D2/collect.cpp index ea9985d225..43717fe6ae 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/collect.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/collect.cpp @@ -968,6 +968,7 @@ void CollectionDefClass::Free(void) for (int i=0; i= ARRAY_SIZE(header.Name), "Incorrect array size"); + strcpy(Name,header.Name); ObjectNames.Resize(header.RenderObjectCount); while (cload.Open_Chunk()) { diff --git a/Core/Libraries/Source/WWVegas/WW3D2/collect.h b/Core/Libraries/Source/WWVegas/WW3D2/collect.h index 3f10ce3ff7..7341f9cbdb 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/collect.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/collect.h @@ -34,16 +34,11 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef COLLECT_H -#define COLLECT_H #include "rendobj.h" #include "composite.h" -#include "Vector.H" +#include "Vector.h" #include "proto.h" #include "w3d_file.h" #include "wwstring.h" @@ -145,5 +140,3 @@ class CollectionLoaderClass : public PrototypeLoaderClass }; extern CollectionLoaderClass _CollectionLoader; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/colorspace.h b/Core/Libraries/Source/WWVegas/WW3D2/colorspace.h index 306e879ee2..e4974a0054 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/colorspace.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/colorspace.h @@ -36,12 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef COLORSPACE_H -#define COLORSPACE_H #include "dx8wrapper.h" #include @@ -155,7 +150,3 @@ inline void Recolor(unsigned& rgba, const Vector3 &hsv_shift) Recolor((Vector3&)rgba_v, hsv_shift); rgba = DX8Wrapper::Convert_Color(rgba_v); } - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/coltest.cpp b/Core/Libraries/Source/WWVegas/WW3D2/coltest.cpp index 87b0e13b84..5639973d50 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/coltest.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/coltest.cpp @@ -99,7 +99,7 @@ bool AABoxCollisionTestClass::Cull(const AABoxClass & box) void AABoxCollisionTestClass::Rotate(ROTATION_TYPE rotation) { -#ifndef NDEBUG +#ifdef RTS_DEBUG int i; Matrix3D tm(1); @@ -156,9 +156,7 @@ void AABoxCollisionTestClass::Rotate(ROTATION_TYPE rotation) if (realmax.Z <= pts[i].Z) realmax.Z = pts[i].Z; } - -#endif - +#endif // RTS_DEBUG // rotate the test by the desired rotation about the Z axis, special cased for // 90 degree rotations about Z. arbitrary rotations cause the axis aligned @@ -216,13 +214,13 @@ void AABoxCollisionTestClass::Rotate(ROTATION_TYPE rotation) break; } -#ifndef NDEBUG +#ifdef RTS_DEBUG assert((Box.Center - realcenter).Length() < 0.001f); assert((SweepMin - realmin).Length() < 0.001f); assert((SweepMax - realmax).Length() < 0.001f); -#endif +#endif // RTS_DEBUG } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/coltest.h b/Core/Libraries/Source/WWVegas/WW3D2/coltest.h index c0ad19d495..0601a81947 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/coltest.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/coltest.h @@ -37,13 +37,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef COLTEST_H -#define COLTEST_H #include "always.h" #include "castres.h" @@ -312,6 +306,3 @@ inline bool OBBoxCollisionTestClass::Cast_To_Triangle(const TriClass & tri) { return CollisionMath::Collide(Box,Move,tri,Vector3(0,0,0),Result); } - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/coltype.h b/Core/Libraries/Source/WWVegas/WW3D2/coltype.h index 7e79dba122..b0f10f2cc4 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/coltype.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/coltype.h @@ -37,15 +37,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - -#ifndef COLTYPE_H -#define COLTYPE_H - ///////////////////////////////////////////////////////////////////////////////////////////////////////////// // @@ -87,8 +79,3 @@ enum COLL_TYPE_CAMERA = COLL_TYPE_3, // camera collision (99% should match physical setting) COLL_TYPE_VEHICLE = COLL_TYPE_4, // vehicles will collide with physical and this. }; - - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/composite.cpp b/Core/Libraries/Source/WWVegas/WW3D2/composite.cpp index 2717d96b0d..5924b3d815 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/composite.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/composite.cpp @@ -58,7 +58,6 @@ #include "composite.h" #include "wwdebug.h" #include -#include /*********************************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WW3D2/composite.h b/Core/Libraries/Source/WWVegas/WW3D2/composite.h index 8ae912f3af..74bd0e26cb 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/composite.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/composite.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef COMPOSITE_H -#define COMPOSITE_H #include "rendobj.h" #include "wwstring.h" @@ -93,7 +87,3 @@ class CompositeRenderObjClass : public RenderObjClass SphereClass ObjSphere; // object-space bounding sphere AABoxClass ObjBox; // object-space bounding box }; - - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/decalsys.cpp b/Core/Libraries/Source/WWVegas/WW3D2/decalsys.cpp index f6d8c2b40b..6ea694d29d 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/decalsys.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/decalsys.cpp @@ -329,10 +329,8 @@ MultiFixedPoolDecalSystemClass::MultiFixedPoolDecalSystemClass(const MultiFixedP MultiFixedPoolDecalSystemClass::~MultiFixedPoolDecalSystemClass(void) { - if (Pools) { - delete [] Pools; - Pools = 0; - } + delete [] Pools; + Pools = NULL; } // This clears the slot in addition to locking the generator, thus preventing any decal id @@ -463,25 +461,21 @@ void MultiFixedPoolDecalSystemClass::LogicalDecalClass::Clear(uint32 decal_id) */ MultiFixedPoolDecalSystemClass::LogicalDecalPoolClass::LogicalDecalPoolClass(void) : - Array(0), + Array(NULL), Size(0) { } MultiFixedPoolDecalSystemClass::LogicalDecalPoolClass::~LogicalDecalPoolClass(void) { - if (Array) { - delete [] Array; - Array = 0; - } + delete [] Array; + Array = NULL; } void MultiFixedPoolDecalSystemClass::LogicalDecalPoolClass::Initialize(uint32 size) { - if (Array) { - delete [] Array; - Array = 0; - } + delete [] Array; + Array = NULL; Size = size; assert(Size); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/decalsys.h b/Core/Libraries/Source/WWVegas/WW3D2/decalsys.h index 7214c65cee..6d7cbc1aa6 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/decalsys.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/decalsys.h @@ -36,12 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef DECALSYS_H -#define DECALSYS_H #include "always.h" #include "matrix3d.h" @@ -300,9 +295,3 @@ class MultiFixedPoolDecalSystemClass : public DecalSystemClass uint32 PoolCount; }; - - - - -#endif //DECALSYS_H - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/distlod.cpp b/Core/Libraries/Source/WWVegas/WW3D2/distlod.cpp index 420ed825fa..d64078d3f8 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/distlod.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/distlod.cpp @@ -242,15 +242,12 @@ DistLODDefClass::~DistLODDefClass(void) *=============================================================================================*/ void DistLODDefClass::Free(void) { - if (Name != NULL) { - delete[] Name; - Name = NULL; - } + delete[] Name; + Name = NULL; + if (Lods != NULL) { for (int i=0; i class DLNodeClass; @@ -207,5 +201,3 @@ inline void DLListClass::Remove_Tail() else tail->succ=0; n->Remove(); } - -#endif //DLLIST_H diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dx8list.h b/Core/Libraries/Source/WWVegas/WW3D2/dx8list.h index f759fe09bb..38facb816f 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dx8list.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/dx8list.h @@ -37,13 +37,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef DX8LIST_H -#define DX8LIST_H #include "always.h" #include "multilist.h" @@ -68,7 +62,3 @@ typedef MultiListIterator DX8PolygonRendererListIterat class TextureTrackerClass; typedef MultiListClass TextureTrackerList; typedef MultiListIterator TextureTrackerListIterator; - - -#endif //DX8LIST_H - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h b/Core/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h index 6bc97905d2..f864f725fb 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/dx8polygonrenderer.h @@ -36,14 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef DX8_POLYGON_RENDERER_H -#define DX8_POLYGON_RENDERER_H - #include "always.h" #include "meshmdl.h" @@ -91,7 +84,7 @@ class DX8PolygonRendererClass : public MultiListObjectClass unsigned Get_Vertex_Offset(void) { return vertex_offset; } unsigned Get_Index_Offset(void) { return index_offset; } - inline unsigned Get_Pass(void) { return pass; } + unsigned Get_Pass(void) { return pass; } MeshModelClass* Get_Mesh_Model_Class() { return mmc; } DX8TextureCategoryClass* Get_Texture_Category() { return texture_category; } @@ -157,5 +150,3 @@ inline void DX8PolygonRendererClass::Render_Sorted(/*const Matrix3D & tm,*/int b vertex_index_range); } - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8texman.cpp b/Core/Libraries/Source/WWVegas/WW3D2/dx8texman.cpp similarity index 99% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8texman.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/dx8texman.cpp index 92c6a635c6..d92e5b9f71 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8texman.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/dx8texman.cpp @@ -77,7 +77,6 @@ void DX8TextureManagerClass::Shutdown() { TextureTrackerClass *track=Managed_Textures.Remove_Head(); delete track; - track=NULL; } } diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8texman.h b/Core/Libraries/Source/WWVegas/WW3D2/dx8texman.h similarity index 97% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8texman.h rename to Core/Libraries/Source/WWVegas/WW3D2/dx8texman.h index 16ba1835ce..378fdad9c2 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/dx8texman.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/dx8texman.h @@ -37,19 +37,13 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef DX8TEXTUREMANAGER_H -#define DX8TEXTUREMANAGER_H #include "always.h" #include "texture.h" #include "dx8wrapper.h" #include "ww3dformat.h" #include "dx8list.h" -#include "ww3dformat.h" #include "multilist.h" class DX8TextureManagerClass; @@ -175,5 +169,3 @@ class DX8TextureManagerClass private: static TextureTrackerList Managed_Textures; }; - -#endif // ifdef TEXTUREMANAGER diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h b/Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h index eeb5881d9a..ad470a6df3 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.h @@ -30,8 +30,7 @@ // $Header: $ //****************************************************************************************** -#ifndef DX8_WEBBROWSER_H -#define DX8_WEBBROWSER_H +#pragma once #include #include "d3d8.h" @@ -89,5 +88,3 @@ class DX8WebBrowser }; #endif - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp b/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp index 888c05d0af..38d7c9a678 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp @@ -104,10 +104,9 @@ DynamicMeshModel::DynamicMeshModel(const DynamicMeshModel &src) : DynamicMeshModel::~DynamicMeshModel(void) { - if (MatDesc) { - delete MatDesc; - MatDesc = NULL; - } + delete MatDesc; + MatDesc = NULL; + REF_PTR_RELEASE(MatInfo); } @@ -225,7 +224,7 @@ void DynamicMeshModel::Render(RenderInfoClass & rinfo) vertices += fvf_info.Get_FVF_Size(); } - } // end scope for lock + } /* ** Write index data to index buffers @@ -244,7 +243,7 @@ void DynamicMeshModel::Render(RenderInfoClass & rinfo) indices[i*3 + 2] = (unsigned short)tris[i][2]; } - } // end scope for lock + } /* ** Set vertex and index buffers @@ -390,9 +389,9 @@ void DynamicMeshModel::Render(RenderInfoClass & rinfo) cur_tri_idx = next_tri_idx; - } // while (!done) + } - } // for (pass) + } } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.h b/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.h index 72edf68285..814c3aec38 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.h @@ -32,13 +32,7 @@ * * *-------------------------------------------------------------------------*/ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef DYNAMESH_H -#define DYNAMESH_H #include "meshgeometry.h" #include "meshmatdesc.h" @@ -578,5 +572,3 @@ class DynamicScreenMeshClass : public DynamicMeshClass { // tells when the triangle needs to be back flipped virtual bool Flip_Face( void) { return !DynamicMeshClass::Flip_Face(); } }; - -#endif // DYNAMESH diff --git a/Core/Libraries/Source/WWVegas/WW3D2/font3d.cpp b/Core/Libraries/Source/WWVegas/WW3D2/font3d.cpp index 59f3039bef..cc78b9ba33 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/font3d.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/font3d.cpp @@ -71,10 +71,8 @@ Font3DDataClass::Font3DDataClass( const char *filename ) ***********************************************************************************************/ Font3DDataClass::~Font3DDataClass(void) { - if (Name != NULL) { - free(Name); - Name = NULL; - } + free(Name); + Name = NULL; REF_PTR_RELEASE(Texture); } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/font3d.h b/Core/Libraries/Source/WWVegas/WW3D2/font3d.h index 61d9b609b1..cbaf28a386 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/font3d.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/font3d.h @@ -32,16 +32,9 @@ * * *---------------------------------------------------------------------------------------------*/ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef FONT3D_H -#define FONT3D_H #include "always.h" -#include "refcount.h" #include "vector4.h" #include "widestring.h" #include "rect.h" @@ -93,10 +86,10 @@ class Font3DDataClass : public RefCountClass { unsigned char Char_Height( WCHAR /*ch = 'H'*/ ) { return CharHeight; } // u and v are in normalized texture space - inline float Char_U_Offset( WCHAR ch = (WCHAR)'H') { return UOffsetTable[ch&0xFF]; }// & 0xFF]; } - inline float Char_V_Offset( WCHAR ch = (WCHAR)'H') { return VOffsetTable[ch&0xFF]; }// & 0xFF]; } - inline float Char_U_Width( WCHAR ch = (WCHAR)'H' ) { return UWidthTable[ch&0xFF]; }// & 0xFF]; } - inline float Char_V_Height( WCHAR /*ch = 'H'*/) { return VHeight; } + float Char_U_Offset( WCHAR ch = (WCHAR)'H') { return UOffsetTable[ch&0xFF]; }// & 0xFF]; } + float Char_V_Offset( WCHAR ch = (WCHAR)'H') { return VOffsetTable[ch&0xFF]; }// & 0xFF]; } + float Char_U_Width( WCHAR ch = (WCHAR)'H' ) { return UWidthTable[ch&0xFF]; }// & 0xFF]; } + float Char_V_Height( WCHAR /*ch = 'H'*/) { return VHeight; } // get all four UV values as one vector4 Vector4 Char_UV_Corners( WCHAR ch = (WCHAR)'H' ) @@ -218,6 +211,3 @@ class Font3DInstanceClass : public RefCountClass { void Build_Cached_Tables(); }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/formconv.h b/Core/Libraries/Source/WWVegas/WW3D2/formconv.h index 1073baabf0..55fbd18974 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/formconv.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/formconv.h @@ -37,12 +37,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef FORMCONV_H -#define FORMCONV_H #include "ww3dformat.h" #include @@ -58,5 +53,3 @@ D3DFORMAT WW3DZFormat_To_D3DFormat(WW3DZFormat ww3d_zformat); WW3DZFormat D3DFormat_To_WW3DZFormat(D3DFORMAT d3d_format); void Init_D3D_To_WW3_Conversion(); - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/framgrab.h b/Core/Libraries/Source/WWVegas/WW3D2/framgrab.h index d6905b8a26..4ad91b0bb7 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/framgrab.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/framgrab.h @@ -34,33 +34,17 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef FRAMEGRAB_H -#define FRAMEGRAB_H -#ifndef ALWAYS_H #include "always.h" -#endif #if defined (_MSC_VER) #pragma warning (push, 3) // (gth) system headers complain at warning level 4... #endif -#ifndef _WINDOWS_ #include "windows.h" -#endif - -#ifndef _INC_WINDOWSX #include "windowsx.h" -#endif - -#ifndef _INC_VFW #include "vfw.h" -#endif #if defined (_MSC_VER) #pragma warning (pop) @@ -113,5 +97,3 @@ class FrameGrabClass void ConvertFrame(void *BitmapPointer); }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/hanim.cpp b/Core/Libraries/Source/WWVegas/WW3D2/hanim.cpp index 80c22c30aa..479b6d764a 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/hanim.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/hanim.cpp @@ -43,7 +43,6 @@ #include "chunkio.h" #include "w3d_file.h" #include "wwdebug.h" -#include #include @@ -62,8 +61,8 @@ NamedPivotMapClass::~NamedPivotMapClass(void) NamedPivotMapClass::WeightInfoStruct & NamedPivotMapClass::WeightInfoStruct::operator = (WeightInfoStruct const &that) { - if(Name) delete [] Name; - assert(that.Name != 0); + delete [] Name; + assert(that.Name != NULL); Name = nstrdup(that.Name); Weight = that.Weight; return *this; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/hanim.h b/Core/Libraries/Source/WWVegas/WW3D2/hanim.h index ae5f429978..a01069917c 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/hanim.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/hanim.h @@ -35,23 +35,15 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef HANIM_H -#define HANIM_H #include "always.h" #include "quat.h" -#include "refcount.h" #include "w3d_file.h" #include "hash.h" #include "mempool.h" -#include -#include -#include +#include +#include struct NodeMotionStruct; class MotionChannelClass; @@ -95,11 +87,7 @@ class HAnimClass : public RefCountClass, public HashableClass virtual float Get_Frame_Rate() = 0; virtual float Get_Total_Time() = 0; -// virtual Vector3 Get_Translation(int pividx,float frame) = 0; -// virtual Quaternion Get_Orientation(int pividx,float frame) = 0; // Jani: Changed to pass in reference of destination to avoid copying - virtual void Get_Translation(int pividx,float frame) {} // todo: remove - virtual void Get_Orientation(int pividx,float frame) {} // todo: remove virtual void Get_Translation(Vector3& translation, int pividx,float frame) const = 0; virtual void Get_Orientation(Quaternion& orientation, int pividx,float frame) const = 0; virtual void Get_Transform(Matrix3D&, int pividx, float frame) const = 0; @@ -161,8 +149,8 @@ class NamedPivotMapClass : public PivotMapClass // This info is packaged into a struct to minimize DynamicVectorClass overhead struct WeightInfoStruct { - WeightInfoStruct() : Name(0) {} - ~WeightInfoStruct() { if(Name) delete [] Name; } + WeightInfoStruct() : Name(NULL) {} + ~WeightInfoStruct() { delete [] Name; } char *Name; float Weight; @@ -269,5 +257,3 @@ class HAnimComboClass { DynamicVectorClass HAnimComboData; }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp b/Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp index 890a7bf789..6813ca0785 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp @@ -56,7 +56,6 @@ #include "chunkio.h" #include "w3d_file.h" #include "wwdebug.h" -#include #include @@ -137,25 +136,25 @@ NodeCompressedMotionStruct::~NodeCompressedMotionStruct() switch (Flavor) { case ANIM_FLAVOR_TIMECODED: - if (tc.X) delete tc.X; - if (tc.Y) delete tc.Y; - if (tc.Z) delete tc.Z; - if (tc.Q) delete tc.Q; + delete tc.X; + delete tc.Y; + delete tc.Z; + delete tc.Q; break; case ANIM_FLAVOR_ADAPTIVE_DELTA: - if (ad.X) delete ad.X; - if (ad.Y) delete ad.Y; - if (ad.Z) delete ad.Z; - if (ad.Q) delete ad.Q; + delete ad.X; + delete ad.Y; + delete ad.Z; + delete ad.Q; break; default: WWASSERT(0); // unknown flavor break; } - if (Vis) delete Vis; + delete Vis; -} // ~NodeCompressedMotionStruct +} /*********************************************************************************************** @@ -214,9 +213,8 @@ HCompressedAnimClass::~HCompressedAnimClass(void) *=============================================================================================*/ void HCompressedAnimClass::Free(void) { - if (NodeMotion != NULL) { - delete[] NodeMotion; - } + delete[] NodeMotion; + NodeMotion = NULL; } @@ -257,15 +255,17 @@ int HCompressedAnimClass::Load_W3D(ChunkLoadClass & cload) cload.Close_Chunk(); - strcpy(Name,aheader.HierarchyName); - strcat(Name,"."); - strcat(Name,aheader.Name); + static_assert(ARRAY_SIZE(Name) >= ARRAY_SIZE(aheader.HierarchyName), "Incorrect array size"); + strcpy(Name, aheader.HierarchyName); + strlcat(Name, ".", ARRAY_SIZE(Name)); + strlcat(Name, aheader.Name, ARRAY_SIZE(Name)); // TSS chasing crash bug 05/26/99 WWASSERT(HierarchyName != NULL); WWASSERT(aheader.HierarchyName != NULL); WWASSERT(sizeof(HierarchyName) >= W3D_NAME_LEN); - strncpy(HierarchyName,aheader.HierarchyName,W3D_NAME_LEN); + static_assert(ARRAY_SIZE(HierarchyName) >= ARRAY_SIZE(aheader.HierarchyName), "Incorrect array size"); + strcpy(HierarchyName, aheader.HierarchyName); HTreeClass * base_pose = WW3DAssetManager::Get_Instance()->Get_HTree(HierarchyName); if (base_pose == NULL) { @@ -371,7 +371,7 @@ int HCompressedAnimClass::Load_W3D(ChunkLoadClass & cload) Free(); return LOAD_ERROR; -} // Load_W3D +} /*********************************************************************************************** * HCompressedAnimClass::read_channel -- Reads in a single channel of motion * @@ -392,7 +392,7 @@ bool HCompressedAnimClass::read_channel(ChunkLoadClass & cload,TimeCodedMotionCh return result; -} // read_channel +} bool HCompressedAnimClass::read_channel(ChunkLoadClass & cload,AdaptiveDeltaMotionChannelClass * * newchan) { @@ -401,7 +401,7 @@ bool HCompressedAnimClass::read_channel(ChunkLoadClass & cload,AdaptiveDeltaMoti return result; -} // read_channel +} /*********************************************************************************************** @@ -439,7 +439,7 @@ void HCompressedAnimClass::add_channel(TimeCodedMotionChannelClass * newchan) break; } -} // add_channel +} void HCompressedAnimClass::add_channel(AdaptiveDeltaMotionChannelClass * newchan) { @@ -464,7 +464,7 @@ void HCompressedAnimClass::add_channel(AdaptiveDeltaMotionChannelClass * newchan break; } -} // add_channel +} @@ -488,7 +488,7 @@ bool HCompressedAnimClass::read_bit_channel(ChunkLoadClass & cload,TimeCodedBitC return result; -} // read_bit_channel +} /*********************************************************************************************** @@ -577,7 +577,7 @@ void HCompressedAnimClass::Get_Orientation(Quaternion& q, int pividx,float frame WWASSERT(0); // unknown flavor break; } -} // Get_Orientation +} /*********************************************************************************************** * HCompressedAnimClass::Get_Transform -- returns the transform matrix for the given frame * diff --git a/Core/Libraries/Source/WWVegas/WW3D2/hcanim.h b/Core/Libraries/Source/WWVegas/WW3D2/hcanim.h index fe21ef1787..ad8cb6a4f4 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/hcanim.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/hcanim.h @@ -35,20 +35,13 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef HCANIM_H -#define HCANIM_H #include "always.h" #include "quat.h" -#include "refcount.h" #include "w3d_file.h" -#include "SLIST.H" -#include "Vector.H" +#include "SLIST.h" +#include "Vector.h" #include "hanim.h" struct NodeCompressedMotionStruct; @@ -93,8 +86,6 @@ class HCompressedAnimClass : public HAnimClass float Get_Total_Time() { return (float)NumFrames / FrameRate; } int Get_Flavor() { return Flavor; } -// Vector3 Get_Translation(int pividx,float frame); -// Quaternion Get_Orientation(int pividx,float frame); void Get_Translation(Vector3& translation, int pividx,float frame) const; void Get_Orientation(Quaternion& orientation, int pividx,float frame) const; void Get_Transform(Matrix3D& transform, int pividx,float frame) const; @@ -133,7 +124,3 @@ class HCompressedAnimClass : public HAnimClass void add_bit_channel(TimeCodedBitChannelClass * newchan); }; - - -#endif // hcanim.h - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp b/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp index 7eef124bbd..0a344c8e12 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp @@ -36,9 +36,8 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#include "hmdldef.H" +#include "hmdldef.h" #include -#include #include "w3d_file.h" #include "chunkio.h" #include "snapPts.h" @@ -95,10 +94,8 @@ HModelDefClass::~HModelDefClass(void) *=============================================================================================*/ void HModelDefClass::Free(void) { - if (SubObjects != NULL) { - delete[] SubObjects; - SubObjects = NULL; - } + delete[] SubObjects; + SubObjects = NULL; SubObjectCount = 0; if (SnapPoints != NULL) { @@ -151,11 +148,12 @@ int HModelDefClass::Load_W3D(ChunkLoadClass & cload) /* ** process the header info */ - strncpy(ModelName,header.Name,W3D_NAME_LEN); - ModelName[W3D_NAME_LEN - 1] = 0; - strncpy(BasePoseName,header.HierarchyName,W3D_NAME_LEN); - BasePoseName[W3D_NAME_LEN-1] = 0; - strcpy(Name,ModelName); + static_assert(ARRAY_SIZE(ModelName) >= ARRAY_SIZE(header.Name), "Incorrect array size"); + static_assert(ARRAY_SIZE(BasePoseName) >= ARRAY_SIZE(header.HierarchyName), "Incorrect array size"); + static_assert(ARRAY_SIZE(Name) >= ARRAY_SIZE(ModelName), "Incorrect array size"); + strcpy(ModelName, header.Name); + strcpy(BasePoseName, header.HierarchyName); + strcpy(Name, ModelName); /* ** Just allocate a node for the number of sub objects we're expecting @@ -237,9 +235,10 @@ bool HModelDefClass::read_connection(ChunkLoadClass & cload,HmdlNodeDefStruct * return false; } - strcpy(node->RenderObjName,ModelName); - strcat(node->RenderObjName,"."); - strcat(node->RenderObjName,con.RenderObjName); + static_assert(ARRAY_SIZE(node->RenderObjName) >= ARRAY_SIZE(ModelName), "Incorrect array size"); + strcpy(node->RenderObjName, ModelName); + strlcat(node->RenderObjName, ".", ARRAY_SIZE(node->RenderObjName)); + strlcat(node->RenderObjName, con.RenderObjName, ARRAY_SIZE(node->RenderObjName)); if (pre30) { if (con.PivotIdx == 65535) { diff --git a/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.H b/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.h similarity index 98% rename from Core/Libraries/Source/WWVegas/WW3D2/hmdldef.H rename to Core/Libraries/Source/WWVegas/WW3D2/hmdldef.h index 4092300d0e..a14060eabf 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.H +++ b/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef HMDLDEF_H -#define HMDLDEF_H #include "always.h" #include "w3d_file.h" @@ -108,5 +102,3 @@ class HModelDefClass friend class HModelClass; friend class HLodClass; }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/htree.cpp b/Core/Libraries/Source/WWVegas/WW3D2/htree.cpp index df05d7502a..63bc8f9acd 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/htree.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/htree.cpp @@ -54,7 +54,6 @@ #include "htree.h" #include "hanim.h" #include "hcanim.h" -#include #include #include "wwmath.h" #include "chunkio.h" @@ -62,6 +61,7 @@ #include "wwmemlog.h" #include "hrawanim.h" #include "motchan.h" +#include "ww3d.h" /*********************************************************************************************** * HTreeClass::HTreeClass -- constructor * @@ -357,10 +357,8 @@ bool HTreeClass::read_pivots(ChunkLoadClass & cload,bool pre30) *=============================================================================================*/ void HTreeClass::Free(void) { - if (Pivot != NULL) { - delete[] Pivot; - Pivot = NULL; - } + delete[] Pivot; + Pivot = NULL; NumPivots = 0; // Also clean up other members: @@ -608,8 +606,16 @@ void HTreeClass::Anim_Update(const Matrix3D & root,HAnimClass * motion,float fra /*Customized version of the above which excludes interpolation and assumes HRawAnimClass For use by 'Generals' -MW*/ -void HTreeClass::Anim_Update(const Matrix3D & root,HRawAnimClass * motion,float frame) +void HTreeClass::Anim_Update_Without_Interpolation(const Matrix3D & root,HRawAnimClass * motion,float frame) { + if (WW3D::Get_Sync_Frame_Time() == 0 && (int)motion->Get_Frame_Rate() == WWSyncPerSecond) + { + // TheSuperHackers @tweak Keep the animation frame step in sync with the ww3d frame step if they can align. + // @todo This needs improving if the WWSyncPerSecond is changed or the animation frame rates can be larger. + static_assert(WWSyncPerSecond == 30, "This is currently catered to a 30 fps sync"); + return; + } + PivotClass *pivot,*endpivot,*lastAnimPivot; Pivot[0].Transform = root; @@ -1018,11 +1024,8 @@ void HTreeClass::Release_Bone(int boneindex) assert(boneindex >= 0); assert(boneindex < NumPivots); #ifdef LAZY_CAP_MTX_ALLOC - if (Pivot[boneindex].CapTransformPtr) - { - delete Pivot[boneindex].CapTransformPtr; - Pivot[boneindex].CapTransformPtr = NULL; - } + delete Pivot[boneindex].CapTransformPtr; + Pivot[boneindex].CapTransformPtr = NULL; #else Pivot[boneindex].IsCaptured = false; #endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/htree.h b/Core/Libraries/Source/WWVegas/WW3D2/htree.h index f0fe2c563c..a3a2e42b71 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/htree.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/htree.h @@ -35,12 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef HTREE_H -#define HTREE_H #include "always.h" #include "pivot.h" @@ -100,7 +95,7 @@ class HTreeClass : public W3DMPO void Anim_Update( const Matrix3D & root, HAnimClass * motion, float frame); - void Anim_Update(const Matrix3D & root,HRawAnimClass * motion,float frame); + void Anim_Update_Without_Interpolation(const Matrix3D & root,HRawAnimClass * motion,float frame); void Blend_Update( const Matrix3D & root, HAnimClass * motion0, @@ -206,7 +201,3 @@ WWINLINE const Matrix3D & HTreeClass::Get_Transform(int pivot) const return Pivot[pivot].Transform; } - - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/intersec.cpp b/Core/Libraries/Source/WWVegas/WW3D2/intersec.cpp index 7aba004b13..38fe2c904d 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/intersec.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/intersec.cpp @@ -40,7 +40,6 @@ #include "camera.h" #include "scene.h" #include "intersec.inl" -#include "Utility/CppMacros.h" ////////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WW3D2/intersec.h b/Core/Libraries/Source/WWVegas/WW3D2/intersec.h index 4387699ee0..75b49640bd 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/intersec.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/intersec.h @@ -47,12 +47,7 @@ */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef INTERSEC_H -#define INTERSEC_H #include "always.h" #include "matrix3d.h" @@ -137,7 +132,7 @@ class IntersectionClass // // configures the member data to use the passed pointers - inline void Set(Vector3 *location, Vector3 *direction, Vector3 *intersection_normal, bool interpolate_normal, float max_distance, bool convex_test = false) + void Set(Vector3 *location, Vector3 *direction, Vector3 *intersection_normal, bool interpolate_normal, float max_distance, bool convex_test = false) { RayLocation = location; RayDirection = direction; @@ -152,7 +147,7 @@ class IntersectionClass // this constructor uses static variables for the location/direction/normal variables // so can be only used one thread at a time unless the Set() function is used to // set them to private vector3's - inline IntersectionClass() + IntersectionClass() : ConvexTest(false) { RayLocation = &_RayLocation; @@ -163,7 +158,7 @@ class IntersectionClass // This will be the most commonly used constructor - inline IntersectionClass(Vector3 *location, Vector3 *direction, Vector3 *intersection_normal, bool interpolate_normal = false, float max_distance = WWMATH_FLOAT_MAX, bool convex_test = false) + IntersectionClass(Vector3 *location, Vector3 *direction, Vector3 *intersection_normal, bool interpolate_normal = false, float max_distance = WWMATH_FLOAT_MAX, bool convex_test = false) { Set(location, direction, intersection_normal, interpolate_normal, max_distance, convex_test); } @@ -173,7 +168,7 @@ class IntersectionClass // this copy routine is used when the model coords are needed to be copied along with the other information. - inline void Copy_Results(IntersectionResultClass *Destination, IntersectionResultClass *Source) { + void Copy_Results(IntersectionResultClass *Destination, IntersectionResultClass *Source) { Destination->ModelMatrix = Source->ModelMatrix; Destination->ModelLocation = Source->ModelLocation; Copy_Partial_Results(Destination, Source); @@ -181,7 +176,7 @@ class IntersectionClass } - inline void Copy_Results(IntersectionResultClass *Source) { + void Copy_Results(IntersectionResultClass *Source) { Copy_Results(&Result, Source); } @@ -190,7 +185,7 @@ class IntersectionClass // otherwise the results are copied into the request structure. // This does not copy the matrix or location members; it is intended to be used during poly testing // where these values are identical between results, or as a completion function for Copy_Results() - inline void Copy_Partial_Results(IntersectionResultClass *Destination, IntersectionResultClass *Source) + void Copy_Partial_Results(IntersectionResultClass *Destination, IntersectionResultClass *Source) { Destination->IntersectedPolygon = Source->IntersectedPolygon; Destination->Intersection = Source->Intersection; @@ -203,13 +198,13 @@ class IntersectionClass // used for creating temporary copies - inline IntersectionClass(IntersectionClass *source) + IntersectionClass(IntersectionClass *source) { *this = source; } - inline IntersectionClass *operator =(IntersectionClass *source) + IntersectionClass *operator =(IntersectionClass *source) { Set(source->RayLocation, source->RayDirection, source->IntersectionNormal, source->InterpolateNormal, source->MaxDistance, source->ConvexTest); Copy_Results(&source->Result); @@ -225,7 +220,7 @@ class IntersectionClass // this will only set the result's range if intersection occurs; it is intended to be used as a first pass intersection test // before intersecting the mesh polygons itself. // Note: Does NOT do Max_Distance testing - inline bool Intersect_Sphere_Quick(SphereClass &Sphere, IntersectionResultClass *FinalResult) + bool Intersect_Sphere_Quick(SphereClass &Sphere, IntersectionResultClass *FinalResult) { // make a unit vector from the ray origin to the sphere center Vector3 sphere_vector(Sphere.Center - *RayLocation); @@ -243,7 +238,7 @@ class IntersectionClass // this will find the intersection with the sphere and the intersection normal if needed. - inline bool Intersect_Sphere(SphereClass &Sphere, IntersectionResultClass *FinalResult) + bool Intersect_Sphere(SphereClass &Sphere, IntersectionResultClass *FinalResult) { if(!Intersect_Sphere_Quick(Sphere, FinalResult)) return false; @@ -399,6 +394,3 @@ class IntersectionClass static Vector3 _RayLocation, _RayDirection, _IntersectionNormal; }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/intersec.inl b/Core/Libraries/Source/WWVegas/WW3D2/intersec.inl index e6882ac982..db4027ba45 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/intersec.inl +++ b/Core/Libraries/Source/WWVegas/WW3D2/intersec.inl @@ -17,9 +17,7 @@ */ -#if defined(_MSC_VER) #pragma once -#endif #ifndef INTERSEC_INL #define INTERSEC_INL diff --git a/Core/Libraries/Source/WWVegas/WW3D2/inttest.h b/Core/Libraries/Source/WWVegas/WW3D2/inttest.h index 655dde53cf..720d0a007e 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/inttest.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/inttest.h @@ -36,12 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef INTTEST_H -#define INTTEST_H #include "always.h" #include "aabox.h" @@ -250,7 +245,3 @@ inline void OBBoxIntersectionTestClass::update_bounding_box(void) BoundingBox.Center = Box.Center; Box.Basis.Rotate_AABox_Extent(Box.Extent,&BoundingBox.Extent); } - - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/layer.h b/Core/Libraries/Source/WWVegas/WW3D2/layer.h index 0840877e6f..4039719823 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/layer.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/layer.h @@ -34,16 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef LAYER_H -#define LAYER_H #include "always.h" -#include "LISTNODE.H" +#include "LISTNODE.h" #include "vector3.h" class SceneClass; @@ -93,8 +87,3 @@ class LayerClass : public LayerNodeClass }; typedef List LayerListClass; - - -#endif //LAYER_H - - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/line3d.h b/Core/Libraries/Source/WWVegas/WW3D2/line3d.h index 3b7cd46a04..9c7ae3c9ee 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/line3d.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/line3d.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef LINE3D_H -#define LINE3D_H #include "always.h" #include "rendobj.h" @@ -120,5 +115,3 @@ class Line3DClass : public W3DMPO, public RenderObjClass Vector4 Color; char SortLevel; }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/matinfo.cpp b/Core/Libraries/Source/WWVegas/WW3D2/matinfo.cpp index 599d065685..7a413efd89 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/matinfo.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/matinfo.cpp @@ -175,12 +175,8 @@ MaterialRemapperClass::~MaterialRemapperClass(void) SrcMatInfo->Release_Ref(); DestMatInfo->Release_Ref(); - if (TextureRemaps) { - delete[] TextureRemaps; - } - if (VertexMaterialRemaps) { - delete[] VertexMaterialRemaps; - } + delete[] TextureRemaps; + delete[] VertexMaterialRemaps; } TextureClass * MaterialRemapperClass::Remap_Texture(TextureClass * src) diff --git a/Core/Libraries/Source/WWVegas/WW3D2/matinfo.h b/Core/Libraries/Source/WWVegas/WW3D2/matinfo.h index 0ee00cd762..2c2dca540b 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/matinfo.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/matinfo.h @@ -34,17 +34,11 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef MATINFO_H -#define MATINFO_H #include "always.h" #include "wwdebug.h" -#include "Vector.H" +#include "Vector.h" #include "vertmaterial.h" #include "texture.h" #include "shader.h" @@ -331,5 +325,3 @@ inline void MaterialInfoClass::Replace_Texture(int index, TextureClass *newTextu { REF_PTR_SET(Textures[index],newTexture); } - -#endif // MATINFO_H diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/matpass.cpp b/Core/Libraries/Source/WWVegas/WW3D2/matpass.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/matpass.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/matpass.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/matpass.h b/Core/Libraries/Source/WWVegas/WW3D2/matpass.h similarity index 95% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/matpass.h rename to Core/Libraries/Source/WWVegas/WW3D2/matpass.h index 7fa40dd172..3dad1fc9df 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/matpass.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/matpass.h @@ -37,25 +37,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif -#ifndef MATPASS_H -#define MATPASS_H - -#ifndef REFCOUNT_H -#include "refcount.h" -#endif - -#ifndef SHADER_H +#include "always.h" #include "shader.h" -#endif - -#ifndef WWDEBUG_H -#include "wwdebug.h" -#endif - class TextureClass; class VertexMaterialClass; @@ -127,6 +112,3 @@ inline TextureClass * MaterialPassClass::Peek_Texture(int stage) const WWASSERT(stage < MAX_TEX_STAGES); return Texture[stage]; } - - -#endif // MATPASS_H diff --git a/Core/Libraries/Source/WWVegas/WW3D2/meshdam.cpp b/Core/Libraries/Source/WWVegas/WW3D2/meshdam.cpp index ff12300c09..410ea5f39d 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/meshdam.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/meshdam.cpp @@ -82,15 +82,11 @@ DamageClass::DamageClass(void): *=============================================================================================*/ DamageClass::~DamageClass(void) { - if (Verts != NULL) { - delete [] Verts; - Verts = NULL; - } + delete [] Verts; + Verts = NULL; - if (Colors != NULL) { - delete[] Colors; - Colors = NULL; - } + delete[] Colors; + Colors = NULL; } /*********************************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WW3D2/meshdam.h b/Core/Libraries/Source/WWVegas/WW3D2/meshdam.h index 8000505957..498ddb96b8 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/meshdam.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/meshdam.h @@ -36,12 +36,7 @@ #if 0 -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef MESHDAM_H -#define MESHDAM_H #include "always.h" #include "vector3.h" @@ -102,7 +97,5 @@ class DamageClass }; -#endif - #endif //0 diff --git a/Core/Libraries/Source/WWVegas/WW3D2/metalmap.cpp b/Core/Libraries/Source/WWVegas/WW3D2/metalmap.cpp index 0d95448d3f..ead093ca60 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/metalmap.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/metalmap.cpp @@ -51,9 +51,8 @@ #include "ww3dformat.h" #include "ww3d.h" #include -#include +#include #include -#include #include #include #include @@ -175,12 +174,11 @@ MetalMapManagerClass::~MetalMapManagerClass(void) REF_PTR_RELEASE(Textures[i]); } delete [] Textures; - Textures = 0; - } - if (MetalParameters) { - delete [] MetalParameters; - MetalParameters = 0; + Textures = NULL; } + + delete [] MetalParameters; + MetalParameters = NULL; } @@ -342,7 +340,7 @@ void MetalMapManagerClass::Update_Textures(void) } metal_map_surface->Unlock(); REF_PTR_RELEASE(metal_map_surface); - } // for i + } } /*********************************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WW3D2/metalmap.h b/Core/Libraries/Source/WWVegas/WW3D2/metalmap.h index 657c0b300b..0618719438 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/metalmap.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/metalmap.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef METALMAP_H -#define METALMAP_H #include @@ -117,5 +112,3 @@ class MetalMapManagerClass { // Use 16-bit metal maps or not bool Use16Bit; }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/missingtexture.h b/Core/Libraries/Source/WWVegas/WW3D2/missingtexture.h index db3af94fc1..106ca11512 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/missingtexture.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/missingtexture.h @@ -16,12 +16,7 @@ ** along with this program. If not, see . */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef DX8_MISSING_TEXTURE_H -#define DX8_MISSING_TEXTURE_H #include "always.h" @@ -37,6 +32,3 @@ class MissingTexture static IDirect3DTexture8* _Get_Missing_Texture(); // Return a reference to missing texture static IDirect3DSurface8* _Create_Missing_Surface(); // Create new surface which contain missing texture image }; - - -#endif // DX8_MISSING_TEXTURE diff --git a/Core/Libraries/Source/WWVegas/WW3D2/pivot.cpp b/Core/Libraries/Source/WWVegas/WW3D2/pivot.cpp index f3519a367d..b7f1c700e6 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/pivot.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/pivot.cpp @@ -40,7 +40,6 @@ #include "pivot.h" #include "wwmath.h" -#include /*********************************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WW3D2/pivot.h b/Core/Libraries/Source/WWVegas/WW3D2/pivot.h index 1c87c8df95..f8ab446df9 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/pivot.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/pivot.h @@ -35,12 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef PIVOT_H -#define PIVOT_H #include "always.h" #include "vector3.h" @@ -71,8 +66,7 @@ struct PivotClass ~PivotClass(void) { #ifdef LAZY_CAP_MTX_ALLOC - if (CapTransformPtr) - delete CapTransformPtr; + delete CapTransformPtr; #endif } @@ -108,7 +102,3 @@ struct PivotClass #endif }; - - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp b/Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp index ee381be2a5..34efa1c77d 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp @@ -77,7 +77,7 @@ #include "statistics.h" #include "simplevec.h" #include "texture.h" -#include "Vector.H" +#include "Vector.h" #include "vp.h" #include "matrix4.h" #include "dx8wrapper.h" @@ -907,7 +907,7 @@ void PointGroupClass::Render(RenderInfoClass &rinfo) transformed_loc[i].Z=result.Z; } current_loc = &transformed_loc[0]; - } // if transform + } // Update the arrays with the offsets. int vnum, pnum; @@ -973,7 +973,7 @@ void PointGroupClass::Render(RenderInfoClass &rinfo) *(Vector2*)(vb+fvfinfo.Get_Tex_Offset(0))=VertexUV[i]; vb+=fvfinfo.Get_FVF_Size(); } - } // copy + } DX8Wrapper::Set_Index_Buffer (indexbuffer, 0); DX8Wrapper::Set_Vertex_Buffer (PointVerts); @@ -988,7 +988,7 @@ void PointGroupClass::Render(RenderInfoClass &rinfo) } current+=delta; - } // loop while (currentRelease_Ref(); // todo : update for refcounted shaders - if(Shader) - delete Shader; + delete Shader; } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/polyinfo.h b/Core/Libraries/Source/WWVegas/WW3D2/polyinfo.h index 5e94983f2e..8eab24e855 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/polyinfo.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/polyinfo.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef POLYINFO_H -#define POLYINFO_H - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 class TextureClass; class VertexMaterialClass; @@ -89,6 +83,3 @@ class PolygonInfoClass VertexMaterialClass *VertexMaterial; ShaderClass *Shader; }; - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/predlod.cpp b/Core/Libraries/Source/WWVegas/WW3D2/predlod.cpp index aceaf7e1b8..dfe2a89962 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/predlod.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/predlod.cpp @@ -381,14 +381,12 @@ void PredictiveLODOptimizerClass::Free(void) { Clear(); - if (ObjectArray) { - delete [] ObjectArray; - ObjectArray = NULL; - ArraySize = 0; - } + delete [] ObjectArray; + ObjectArray = NULL; + ArraySize = 0; // Only the array number one has been allocated... - if (VisibleObjArray1) delete[] VisibleObjArray1; + delete[] VisibleObjArray1; VisibleObjArray1=NULL; VisibleObjArray2=NULL; VisibleObjArraySize = 0; @@ -398,7 +396,7 @@ void PredictiveLODOptimizerClass::AllocVisibleObjArrays(int num_objects) { if (VisibleObjArraySize::Evaluate (float time) return value; } - -#endif //__PRIM_ANIM_H diff --git a/Core/Libraries/Source/WWVegas/WW3D2/projector.cpp b/Core/Libraries/Source/WWVegas/WW3D2/projector.cpp index c1eda99ceb..1ce6e7bdf2 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/projector.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/projector.cpp @@ -46,7 +46,6 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "projector.h" -#include "refcount.h" #include "matrixmapper.h" diff --git a/Core/Libraries/Source/WWVegas/WW3D2/projector.h b/Core/Libraries/Source/WWVegas/WW3D2/projector.h index 9e13bd86e9..24b8632af4 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/projector.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/projector.h @@ -37,8 +37,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef PROJECTOR_H -#define PROJECTOR_H +#pragma once #include "always.h" #include "matrix3d.h" @@ -85,8 +84,3 @@ class ProjectorClass MatrixMapperClass * Mapper; }; - - -#endif - - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/proto.cpp b/Core/Libraries/Source/WWVegas/WW3D2/proto.cpp index 1072eb5eea..c19af3b205 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/proto.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/proto.cpp @@ -42,7 +42,7 @@ #include "proto.h" #include "mesh.h" -#include "hmdldef.H" +#include "hmdldef.h" #include "hlod.h" #include "w3derr.h" @@ -100,7 +100,7 @@ class HModelPrototypeClass : public W3DMPO, public PrototypeClass HModelDefClass * HModelDef; protected: - virtual ~HModelPrototypeClass(void) { if (HModelDef) delete HModelDef; } + virtual ~HModelPrototypeClass(void) { delete HModelDef; } }; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/proto.h b/Core/Libraries/Source/WWVegas/WW3D2/proto.h index 41b261138d..eb375602e2 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/proto.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/proto.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef PROTO_H -#define PROTO_H #include "always.h" #include @@ -94,8 +88,8 @@ class PrototypeClass virtual RenderObjClass * Create(void) = 0; virtual void DeleteSelf() = 0; - inline void friend_setNextHash(PrototypeClass* n) { NextHash = n; } - inline PrototypeClass* friend_getNextHash() { return NextHash; } + void friend_setNextHash(PrototypeClass* n) { NextHash = n; } + PrototypeClass* friend_getNextHash() { return NextHash; } protected: virtual ~PrototypeClass(void) {}; @@ -177,7 +171,3 @@ class HModelLoaderClass : public PrototypeLoaderClass */ extern MeshLoaderClass _MeshLoader; extern HModelLoaderClass _HModelLoader; - - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/proxy.h b/Core/Libraries/Source/WWVegas/WW3D2/proxy.h index 2cbb1d81d4..faf45a367e 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/proxy.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/proxy.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __PROXY_H -#define __PROXY_H #include "wwstring.h" #include "matrix3d.h" @@ -109,7 +104,3 @@ ProxyClass::operator!= (const ProxyClass &src) { return ((Name != src.Name) || (Transform != src.Transform)); } - - -#endif //__PROXY_H - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/rddesc.h b/Core/Libraries/Source/WWVegas/WW3D2/rddesc.h index 14729463e1..06fcbd4b51 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/rddesc.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/rddesc.h @@ -34,15 +34,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef RDDESC_H -#define RDDESC_H -#include "Vector.H" +#include "Vector.h" #include "wwstring.h" #include #include @@ -166,7 +160,3 @@ inline void RenderDeviceDescClass::add_resolution(int w,int h,int bits) ResArray.Add(ResolutionDescClass(w,h,bits)); } } - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp b/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp index e8d0b90921..e307f2e41f 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp @@ -785,7 +785,6 @@ void Render2DSentenceClass::Build_Sentence_Centered (const WCHAR *text, int *hkX if( ParseHotKey && (*word == L'&') && (*word+1 != 0) && (*word+1 > L' ') && (*word+1 != L'\n')) { int offset = 0; - //Added By Saad if (word_width != 0 ) { const WCHAR *word_back = word; @@ -796,7 +795,6 @@ void Render2DSentenceClass::Build_Sentence_Centered (const WCHAR *text, int *hkX offset =-1; } } - // *word++; calcHotKeyX = true; } @@ -853,7 +851,6 @@ void Render2DSentenceClass::Build_Sentence_Centered (const WCHAR *text, int *hkX // word_width = Font->Get_Char_Spacing (*word++); wordCount = 0; - //Added By Saad line_width += word_width; } // @@ -1170,6 +1167,8 @@ Render2DSentenceClass::Build_Sentence (const WCHAR *text, int *hkX, int *hkY) return ; } + if (Font == NULL) + return; if(Centered && (WrapWidth > 0 || wcschr(text,L'\n'))) Build_Sentence_Centered(text, hkX, hkY); @@ -1504,7 +1503,7 @@ FontCharsClass::Update_Current_Buffer (int char_width) // Create_GDI_Font // //////////////////////////////////////////////////////////////////////////////////// -void +bool FontCharsClass::Create_GDI_Font (const char *font_name) { HDC screen_dc = ::GetDC ((HWND)WW3D::Get_Window()); @@ -1598,6 +1597,8 @@ FontCharsClass::Create_GDI_Font (const char *font_name) if (doingGenerals) { CharOverhang = 0; } + + return GDIFont != NULL && GDIBitmap != NULL; } @@ -1646,7 +1647,7 @@ FontCharsClass::Free_GDI_Font (void) // Initialize_GDI_Font // //////////////////////////////////////////////////////////////////////////////////// -void +bool FontCharsClass::Initialize_GDI_Font (const char *font_name, int point_size, bool is_bold) { // @@ -1664,8 +1665,7 @@ FontCharsClass::Initialize_GDI_Font (const char *font_name, int point_size, bool // // Create the actual font object // - Create_GDI_Font (font_name); - return ; + return Create_GDI_Font (font_name); } @@ -1763,10 +1763,8 @@ FontCharsClass::Free_Character_Arrays (void) // Delete each member of the unicode array // for (int index = 0; index < count; index ++) { - if ( UnicodeCharArray[index] != NULL ) { - delete UnicodeCharArray[index]; - UnicodeCharArray[index] = NULL; - } + delete UnicodeCharArray[index]; + UnicodeCharArray[index] = NULL; } // @@ -1780,10 +1778,8 @@ FontCharsClass::Free_Character_Arrays (void) // Delete each member of the ascii character array // for (int index = 0; index < 256; index ++) { - if ( ASCIICharArray[index] != NULL ) { - delete ASCIICharArray[index]; - ASCIICharArray[index] = NULL; - } + delete ASCIICharArray[index]; + ASCIICharArray[index] = NULL; } return ; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.h b/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.h index ccab34025f..db8771a66a 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.h @@ -34,16 +34,11 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef RENDER2DSENTENCE_H -#define RENDER2DSENTENCE_H +#include "always.h" #include "render2d.h" -#include "refcount.h" -#include "Vector.H" +#include "Vector.h" #include "vector2i.h" #include "wwstring.h" #include "win.h" @@ -87,7 +82,7 @@ class FontCharsClass : public W3DMPO, public RefCountClass FontCharsClass *AlternateUnicodeFont; - void Initialize_GDI_Font( const char *font_name, int point_size, bool is_bold ); + bool Initialize_GDI_Font( const char *font_name, int point_size, bool is_bold ); bool Is_Font( const char *font_name, int point_size, bool is_bold ); const char * Get_Name( void ) { return Name; } @@ -104,7 +99,7 @@ class FontCharsClass : public W3DMPO, public RefCountClass // // Private methods // - void Create_GDI_Font( const char *font_name ); + bool Create_GDI_Font( const char *font_name ); void Free_GDI_Font( void ); const FontCharsClassCharDataStruct * Store_GDI_Char( WCHAR ch ); void Update_Current_Buffer( int char_width ); @@ -272,5 +267,3 @@ class Render2DSentenceClass { TextureClass * CurTexture; ShaderClass Shader; }; - -#endif // RENDER2DSENTENCE_H diff --git a/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp b/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp index 8762d85798..f6d787fc13 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp @@ -42,7 +42,6 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "renderobjectrecycler.h" -#include #include "rendobj.h" #include "assetmgr.h" #include "part_emt.h" diff --git a/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.h b/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.h index 4519c13530..aabc0c4c79 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.h @@ -36,9 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef RENDEROBJECTRECYCLER_H -#define RENDEROBJECTRECYCLER_H +#pragma once #include "always.h" #include "robjlist.h" @@ -77,8 +75,3 @@ class RenderObjectRecyclerClass RefRenderObjListClass InactiveModels; }; - - - - -#endif //RENDEROBJECTRECYCLER_H diff --git a/Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp index b7f3299361..b5d0671fc1 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp @@ -807,7 +807,7 @@ void RenderObjClass::Add(SceneClass * scene) * 11/04/1997 GH : Created. * * 2/25/99 GTH : moved to the base RenderObjClass * *=============================================================================================*/ -void RenderObjClass::Remove(void) +bool RenderObjClass::Remove(void) { // All render objects have their scene pointers set. To check if this is a "top level" // object, (i.e. directly in the scene) you see if its Container pointer is NULL. @@ -815,16 +815,19 @@ void RenderObjClass::Remove(void) if (Container == NULL) { if (Scene != NULL) { Scene->Remove_Render_Object(this); - return; + return true; } + return false; } else { Container->Remove_Sub_Object(this); - return; + return true; } #else - if (!Scene) return; + if (!Scene) + return false; Scene->Remove_Render_Object(this); Scene = NULL; + return true; #endif } @@ -1243,7 +1246,7 @@ PersistClass * RenderObjPersistFactoryClass::Load(ChunkLoadClass & cload) const // if the object we saved didn't have a name, replace it with null if (strlen(name) == 0) { static int count = 0; - if ( ++count < 10 ) { + if ( count++ < 10 ) { WWDEBUG_SAY(("RenderObjPersistFactory attempted to load an un-named render object!")); WWDEBUG_SAY(("Replacing it with a NULL render object!")); } @@ -1254,7 +1257,7 @@ PersistClass * RenderObjPersistFactoryClass::Load(ChunkLoadClass & cload) const if (new_obj == NULL) { static int count = 0; - if ( ++count < 10 ) { + if ( count++ < 10 ) { WWDEBUG_SAY(("RenderObjPersistFactory failed to create object: %s!!",name)); WWDEBUG_SAY(("Either the asset for this object is gone or you tried to save a procedural object.")); WWDEBUG_SAY(("Replacing it with a NULL render object!")); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/rendobj.h b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.h index 4b758e8ca3..fe1005ff48 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/rendobj.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.h @@ -38,16 +38,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef RENDOBJ_H -#define RENDOBJ_H #include "always.h" -#include "refcount.h" #include "sphere.h" #include "coltype.h" #include "aabox.h" @@ -85,20 +78,6 @@ template class DynamicVectorClass; // "unreferenced formal parameter" #pragma warning(disable : 4100) -#ifdef DEFINE_W3DANIMMODE_NAMES -static const char* TheAnimModeNames[] = -{ - "MANUAL", - "LOOP", - "ONCE", - "LOOP_PINGPONG", - "LOOP_BACKWARDS", - "ONCE_BACKWARDS", - NULL -}; -#endif - - ////////////////////////////////////////////////////////////////////////////////// // RenderObjClass // This is the interface for all objects that get rendered by WW3D. @@ -279,7 +258,7 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL // as small as possible /////////////////////////////////////////////////////////////////////////////////////////////////////////////// virtual void Add(SceneClass * scene); - virtual void Remove(void); + virtual bool Remove(void); virtual SceneClass * Get_Scene(void); virtual SceneClass * Peek_Scene(void) { return Scene; } virtual void Set_Container(RenderObjClass * con); @@ -288,7 +267,7 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL #define GET_CONTAINER_INLINE #ifdef GET_CONTAINER_INLINE // srj sez: this is called a ton and never overridden, so inline it - inline RenderObjClass * Get_Container(void) const { return Container; } + RenderObjClass * Get_Container(void) const { return Container; } #else virtual RenderObjClass * Get_Container(void) const; #endif @@ -336,6 +315,8 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL ANIM_MODE_LOOP_PINGPONG, ANIM_MODE_LOOP_BACKWARDS, //make sure only backwards playing animations after this one ANIM_MODE_ONCE_BACKWARDS, + + ANIM_MODE_COUNT }; virtual void Set_Animation( void ) { } @@ -653,6 +634,16 @@ WWINLINE bool RenderObjClass::Is_Transform_Identity_No_Validity_Check() const } - - +#ifdef DEFINE_W3DANIMMODE_NAMES +static const char* const TheAnimModeNames[] = +{ + "MANUAL", + "LOOP", + "ONCE", + "LOOP_PINGPONG", + "LOOP_BACKWARDS", + "ONCE_BACKWARDS", + NULL +}; +static_assert(ARRAY_SIZE(TheAnimModeNames) == RenderObjClass::ANIM_MODE_COUNT + 1, "Incorrect array size"); #endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/ringobj.cpp b/Core/Libraries/Source/WWVegas/WW3D2/ringobj.cpp index 7f1dc94b32..5108aa7152 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/ringobj.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/ringobj.cpp @@ -306,7 +306,7 @@ RingRenderObjClass::~RingRenderObjClass() { REF_PTR_RELEASE(RingMaterial); REF_PTR_RELEASE(RingTexture); -} // destructor +} /*********************************************************************************************** @@ -430,7 +430,7 @@ void RingRenderObjClass::Init_Material (void) // Texturing, zbuffer, primary gradient, alpha blending RingShader = ShaderClass::_PresetAlphaShader; -} // Init_Material +} @@ -502,8 +502,8 @@ const char * RingRenderObjClass::Get_Name(void) const void RingRenderObjClass::Set_Name(const char * name) { WWASSERT(name != NULL); - WWASSERT(strlen(name) < 2*W3D_NAME_LEN); - strcpy(Name,name); + const size_t nameLen = strlcpy(Name, name, ARRAY_SIZE(Name)); + (void)nameLen; WWASSERT(nameLen < ARRAY_SIZE(Name)); } /*********************************************************************************************** @@ -597,7 +597,7 @@ void RingRenderObjClass::render_ring(RenderInfoClass & rinfo,const Vector3 & cen DX8Wrapper::Draw_Triangles(0, ring.face_ct, 0, ring.Vertex_ct); } -} // render_ring +} /*********************************************************************************************** @@ -617,7 +617,7 @@ void RingRenderObjClass::render_ring(RenderInfoClass & rinfo,const Vector3 & cen void RingRenderObjClass::vis_render_ring(SpecialRenderInfoClass & rinfo,const Vector3 & center,const Vector3 & extent) { WWASSERT(0); -} // vis_render_ring +} /*********************************************************************************************** @@ -734,7 +734,7 @@ void RingRenderObjClass::Render(RenderInfoClass & rinfo) // render_ring (rinfo, ObjSpaceCenter, ObjSpaceExtent); } -} // Render +} /*********************************************************************************************** @@ -1146,13 +1146,9 @@ void RingRenderObjClass::animate() InnerScaleChannel.Get_Key_Count () > 0 || OuterScaleChannel.Get_Key_Count () > 0) { - // - // Convert from milliseconds to seconds and normalize the time - // if (AnimDuration > 0) { - float frametime = WW3D::Get_Frame_Time(); - frametime = (frametime * 0.001F) / AnimDuration; - anim_time += frametime; + float frametime = WW3D::Get_Logic_Frame_Time_Seconds(); + anim_time += frametime / AnimDuration; } else { anim_time = 1.0F; } @@ -1185,7 +1181,7 @@ void RingRenderObjClass::animate() } return ; -} // animate +} /* @@ -1210,7 +1206,7 @@ RingPrototypeClass::RingPrototypeClass (void) RingPrototypeClass::RingPrototypeClass(RingRenderObjClass *ring) { ::memset (&Definition, 0, sizeof (Definition)); - ::strcpy (Definition.Name, ring->Get_Name ()); + strlcpy(Definition.Name, ring->Get_Name(), ARRAY_SIZE(Definition.Name)); Definition.AnimDuration = ring->AnimDuration; Definition.Attributes = ring->Get_Flags (); @@ -1241,7 +1237,7 @@ RingPrototypeClass::RingPrototypeClass(RingRenderObjClass *ring) filename = name; } - ::strcpy (Definition.TextureName, filename); + strlcpy(Definition.TextureName, filename, ARRAY_SIZE(Definition.TextureName)); } // @@ -1451,7 +1447,7 @@ TileCount (5), InnerScale (1.0F, 1.0F), OuterScale (1.0F, 1.0F) { -} // empty ringmesh Constructor +} void RingMeshClass::Set_Tiling (int count) @@ -1633,11 +1629,11 @@ RingMeshClass::~RingMeshClass(void) void RingMeshClass::Free(void) { - if (vtx) delete vtx; - if (orig_vtx) delete orig_vtx; - if (vtx_normal) delete vtx_normal; - if (vtx_uv) delete vtx_uv; - if (tri_poly) delete tri_poly; + delete vtx; + delete orig_vtx; + delete vtx_normal; + delete vtx_uv; + delete tri_poly; vtx = NULL; orig_vtx = NULL; @@ -1645,6 +1641,6 @@ void RingMeshClass::Free(void) vtx_uv = NULL; tri_poly = NULL; -} // Free +} // EOF - ringobj.cpp diff --git a/Core/Libraries/Source/WWVegas/WW3D2/ringobj.h b/Core/Libraries/Source/WWVegas/WW3D2/ringobj.h index 06460014fa..b4ab20f494 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/ringobj.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/ringobj.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef RINGOBJ_H -#define RINGOBJ_H #include "always.h" #include "rendobj.h" @@ -363,8 +358,4 @@ class RingPrototypeClass : public W3DMPO, public PrototypeClass extern RingLoaderClass _RingLoader; -#endif // RINGOBJ_H - // EOF - ringobj,h - - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/robjlist.h b/Core/Libraries/Source/WWVegas/WW3D2/robjlist.h index 4f3ca52bd6..fc24a6ad78 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/robjlist.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/robjlist.h @@ -34,25 +34,11 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef ROBJLIST_H -#define ROBJLIST_H -#ifndef ALWAYS_H #include "always.h" -#endif - -#ifndef MULTILIST_H #include "multilist.h" -#endif - -#ifndef WWDEBUG_H #include "wwdebug.h" -#endif class RenderObjClass; @@ -61,7 +47,3 @@ typedef RefMultiListIterator RefRenderObjListIterator; typedef MultiListClass NonRefRenderObjListClass; typedef MultiListIterator NonRefRenderObjListIterator; - -#endif - - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/segline.h b/Core/Libraries/Source/WWVegas/WW3D2/segline.h index 8b11c779f9..362df753dd 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/segline.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/segline.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef SEGLINE_H -#define SEGLINE_H #include "rendobj.h" #include "shader.h" @@ -181,5 +176,3 @@ class SegmentedLineClass : public RenderObjClass // LineRenderer, contains most of the line settings. SegLineRendererClass LineRenderer; }; - -#endif // SEGLINE_H diff --git a/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp index c767677f8a..afeaffbe64 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp @@ -44,7 +44,7 @@ #include "sortingrenderer.h" #include "vp.h" #include "Vector3i.h" -#include "RANDOM.H" +#include "RANDOM.h" #include "v3_rnd.h" #include "meshgeometry.h" @@ -78,7 +78,7 @@ SegLineRendererClass::SegLineRendererClass(void) : NoiseAmplitude(0.0f), MergeAbortFactor(1.5f), TextureTileFactor(1.0f), - LastUsedSyncTime(WW3D::Get_Sync_Time()), + LastUsedSyncTime(WW3D::Get_Logic_Time_Milliseconds()), CurrentUVOffset(0.0f,0.0f), UScale(1.0f), UVOffsetDeltaPerMS(0.0f, 0.0f), @@ -209,7 +209,7 @@ void SegLineRendererClass::Set_Texture_Tile_Factor(float factor) void SegLineRendererClass::Reset_Line(void) { - LastUsedSyncTime = WW3D::Get_Sync_Time(); + LastUsedSyncTime = WW3D::Get_Logic_Time_Milliseconds(); CurrentUVOffset.Set(0.0f,0.0f); } @@ -235,9 +235,9 @@ void SegLineRendererClass::Render /* ** Handle texture UV offset animation (done once for entire line). */ - unsigned int delta = WW3D::Get_Sync_Time() - LastUsedSyncTime; - float del = (float)delta; - Vector2 uv_offset = CurrentUVOffset + UVOffsetDeltaPerMS * del; + // TheSuperHackers @tweak The render update is now decoupled from the logic step. + const unsigned int delta = WW3D::Get_Logic_Time_Milliseconds() - LastUsedSyncTime; + Vector2 uv_offset = CurrentUVOffset + UVOffsetDeltaPerMS * (float)delta; // ensure offsets are in [0, 1] range: uv_offset.X = uv_offset.X - floorf(uv_offset.X); @@ -245,7 +245,7 @@ void SegLineRendererClass::Render // Update state CurrentUVOffset = uv_offset; - LastUsedSyncTime = WW3D::Get_Sync_Time(); + LastUsedSyncTime = WW3D::Get_Logic_Time_Milliseconds(); // Used later TextureMapMode map_mode = Get_Texture_Mapping_Mode(); @@ -731,7 +731,7 @@ void SegLineRendererClass::Render segment[iidx].StartPlane = -start_pl; } - } // for iidx + } /* @@ -892,7 +892,7 @@ void SegLineRendererClass::Render next_int = &(intersection[iidx_r + 1][edge]); next_seg = &(segment[next_int->NextSegmentID]); - } // while + } // Copy from "read index" to "write index" write_int->PointCount = curr_int->PointCount; @@ -903,7 +903,7 @@ void SegLineRendererClass::Render write_int->Direction = curr_int->Direction; write_int->Fold = curr_int->Fold; - } // for iidx + } // If iidx_r is exactly equal to num_isects (rather than being larger by one) at this // point, this means that the last intersection was not merged with the previous one. In @@ -929,9 +929,9 @@ void SegLineRendererClass::Render assert(total_cnt == point_cnt); #endif - } // for edge - } // while (merged) - } // if (Is_Merge_Intersections()) + } + } + } /* ** Find vertex positions, generate vertices and triangles: @@ -1175,7 +1175,7 @@ void SegLineRendererClass::Render texture->V = vArray[i].v1; vb += vbSize; } - } // copy + } DynamicIBAccessClass ib_access((sorting?BUFFER_TYPE_DYNAMIC_SORTING:BUFFER_TYPE_DYNAMIC_DX8),tidx*3); { @@ -1205,7 +1205,7 @@ void SegLineRendererClass::Render REF_PTR_RELEASE(mat); - } // Chunking loop + } DX8Wrapper::Set_Transform(D3DTS_VIEW,view); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.h b/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.h index eb3f1f0918..eca151b7a0 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.h @@ -36,8 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef SEGLINERENDERER_H -#define SEGLINERENDERER_H +#pragma once #include "always.h" #include "shader.h" @@ -211,7 +210,3 @@ inline void SegLineRendererClass::Set_UV_Offset_Rate(const Vector2 &rate) { UVOffsetDeltaPerMS = rate * 0.001f; } - - -#endif //SEGLINERENDERER_H - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp b/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp index e4c15b3b4e..6a42f6586a 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp @@ -728,12 +728,8 @@ BSPClass::BSPClass(HTreeClass * tree,int bone_index,int & leaf_index) : BSPClass::~BSPClass(void) { - if (Front != NULL) { - delete Front; - } - if (Back != NULL) { - delete Back; - } + delete Front; + delete Back; Front = Back = NULL; } @@ -847,7 +843,6 @@ void ShatterSystem::Shutdown(void) */ for (int i=0; i, public RefCountClass ~SnapPointsClass(void) {} }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/soundlibrarybridge.h b/Core/Libraries/Source/WWVegas/WW3D2/soundlibrarybridge.h index e74644ca07..367fcc4573 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/soundlibrarybridge.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/soundlibrarybridge.h @@ -33,8 +33,8 @@ *--------------------------------------------------------------------------------------------- * Functions: * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef SOUNDLIBRARYBRIDGE_H -#define SOUNDLIBRARYBRIDGE_H + +#pragma once // Forward declarations. class Matrix3D; @@ -45,5 +45,3 @@ class SoundLibraryBridgeClass { virtual void Play_2D_Audio(const char * name) = 0; virtual void Stop_Playing_Audio(const char * name) = 0; }; - -#endif //SOUNDLIBRARYBRIDGE_H diff --git a/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp index ecbdbcfaf6..4bd67a6eda 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp @@ -42,7 +42,7 @@ #include "Sound3D.h" #include "WWAudio.h" #include "ffactory.h" -#include "WWFILE.H" +#include "WWFILE.h" #include "chunkio.h" #include "scene.h" diff --git a/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h index 3aa3a236df..c5ce0b6815 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SOUNDROBJ_H -#define __SOUNDROBJ_H // TheSuperHackers @build xezon 05/04/2025 Compile in WWAUDIO for Renegade's w3dview tool. #define noWWAUDIO 1 @@ -280,6 +275,3 @@ class SoundRenderObjLoaderClass : public PrototypeLoaderClass extern SoundRenderObjLoaderClass _SoundRenderObjLoader; #endif //noWWAUDIO (gth) removing dependency on wwaudio - -#endif //__SOUNDROBJ_H - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp b/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp index 24ade71dd7..3b24f5e09d 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp @@ -236,7 +236,7 @@ SphereRenderObjClass::SphereRenderObjClass(const SphereRenderObjClass & src) SphereRenderObjClass::~SphereRenderObjClass() { REF_PTR_RELEASE(SphereMaterial); -} // destructor +} /*********************************************************************************************** * SphereRenderObjClass::operator -- assignment operator * @@ -365,7 +365,7 @@ void SphereRenderObjClass::Init_Material (void) // is to turn off backface culling... ug... SphereShader.Set_Cull_Mode(ShaderClass::CULL_MODE_DISABLE); -} // Init_Material +} /*********************************************************************************************** @@ -437,8 +437,8 @@ const char * SphereRenderObjClass::Get_Name(void) const void SphereRenderObjClass::Set_Name(const char * name) { WWASSERT(name != NULL); - WWASSERT(strlen(name) < 2*W3D_NAME_LEN); - strcpy(Name,name); + const size_t nameLen = strlcpy(Name, name, ARRAY_SIZE(Name)); + (void)nameLen; WWASSERT(nameLen < ARRAY_SIZE(Name)); } @@ -528,7 +528,7 @@ void SphereRenderObjClass::render_sphere() DX8Wrapper::Draw_Triangles(0,mesh.face_ct,0,mesh.Vertex_ct); } -} // render_sphere +} /*********************************************************************************************** @@ -547,7 +547,7 @@ void SphereRenderObjClass::render_sphere() *=============================================================================================*/ void SphereRenderObjClass::vis_render_sphere(SpecialRenderInfoClass & rinfo,const Vector3 & center,const Vector3 & extent) { -} // vis_render_sphere +} /*********************************************************************************************** @@ -1104,13 +1104,9 @@ void SphereRenderObjClass::animate (void) ScaleChannel.Get_Key_Count () > 0 || VectorChannel.Get_Key_Count () > 0) { - // - // Convert from milliseconds to seconds and normalize the time - // if (AnimDuration > 0) { - float frametime = WW3D::Get_Frame_Time(); - frametime = (frametime * 0.001F) / AnimDuration; - anim_time += frametime; + float frametime = WW3D::Get_Logic_Frame_Time_Seconds(); + anim_time += frametime / AnimDuration; } else { anim_time = 1.0F; } @@ -1141,7 +1137,7 @@ void SphereRenderObjClass::animate (void) return ; -} // animate +} /* @@ -1166,7 +1162,7 @@ SpherePrototypeClass::SpherePrototypeClass (void) SpherePrototypeClass::SpherePrototypeClass(SphereRenderObjClass *sphere) { ::memset (&Definition, 0, sizeof (Definition)); - ::strcpy (Definition.Name, sphere->Get_Name ()); + strlcpy(Definition.Name, sphere->Get_Name(), ARRAY_SIZE(Definition.Name)); Definition.DefaultAlpha = sphere->Get_Default_Alpha (); Definition.AnimDuration = sphere->AnimDuration; @@ -1194,7 +1190,7 @@ SpherePrototypeClass::SpherePrototypeClass(SphereRenderObjClass *sphere) filename = name; } - ::strcpy (Definition.TextureName, filename); + strlcpy(Definition.TextureName, filename, ARRAY_SIZE(Definition.TextureName)); } @@ -1382,7 +1378,7 @@ inverse_alpha(false) Generate(radius, slices, stacks); -} // SphereMesh Constructor +} /*********************************************************************************************** * SphereMeshClass::SphereMeshClass -- Constructor for SphereMesh Geometry * @@ -1415,7 +1411,7 @@ tri_poly(NULL), inverse_alpha(false) { -} // Empty SphereMesh Constructor +} @@ -1484,7 +1480,7 @@ void SphereMeshClass::Set_Alpha_Vector (const AlphaVectorStruct &v, bool inverse } return ; -} // Set_Alpha_Vector +} /*********************************************************************************************** @@ -1563,8 +1559,8 @@ void SphereMeshClass::Generate(float radius, int slices, int stacks) uv->V = stackstep; uv++; - } // for slices - } // for stacks + } + } // Assign vertex for south pole; *veclist = -1.0f * vec; @@ -1698,7 +1694,7 @@ void SphereMeshClass::Generate(float radius, int slices, int stacks) Set_Alpha_Vector (alpha_vector, inverse_alpha, IsAdditive, true); return ; -} // Generate +} @@ -1715,7 +1711,7 @@ SphereMeshClass::~SphereMeshClass(void) Free(); -} // Destructor +} /*********************************************************************************************** @@ -1732,13 +1728,13 @@ SphereMeshClass::~SphereMeshClass(void) *=============================================================================================*/ void SphereMeshClass::Free(void) { - if (vtx) delete [] vtx; - if (vtx_normal) delete [] vtx_normal; - if (vtx_uv) delete [] vtx_uv; - if (dcg) delete [] dcg; - if (strips) delete [] strips; - if (fans) delete [] fans; - if (tri_poly) delete [] tri_poly; + delete [] vtx; + delete [] vtx_normal; + delete [] vtx_uv; + delete [] dcg; + delete [] strips; + delete [] fans; + delete [] tri_poly; vtx = NULL; vtx_normal = NULL; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.h b/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.h index fa5c42f598..5b854cf4fb 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef SPHEREOBJ_H -#define SPHEREOBJ_H #include "always.h" #include "rendobj.h" @@ -472,8 +467,4 @@ class SpherePrototypeClass : public W3DMPO, public PrototypeClass */ extern SphereLoaderClass _SphereLoader; -#endif // SPHEREOBJ_H - // EOF - sphereobj,h - - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/static_sort_list.h b/Core/Libraries/Source/WWVegas/WW3D2/static_sort_list.h index 5492e7b50e..d5e81a52fe 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/static_sort_list.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/static_sort_list.h @@ -35,12 +35,8 @@ *---------------------------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) -#pragma once -#endif -#ifndef STATIC_SORT_LIST_H -#define STATIC_SORT_LIST_H +#pragma once #include "robjlist.h" #include "w3d_file.h" @@ -59,7 +55,7 @@ class StaticSortListClass virtual void Add_To_List(RenderObjClass * robj, unsigned int sort_level) = 0; virtual void Render_And_Clear(RenderInfoClass & rinfo) = 0; -}; // end StaticSortListClass +}; // The actual implementation for the standard ww3d StaticSortList. class DefaultStaticSortListClass : public StaticSortListClass @@ -90,10 +86,4 @@ class DefaultStaticSortListClass : public StaticSortListClass // An array of lists - each object in a given list has same SortLevel. RefRenderObjListClass SortLists[MAX_SORT_LEVEL + 1]; -}; // end StaticSortListClass - - - - -#endif //STATIC_SORT_LIST_H - +}; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/statistics.cpp b/Core/Libraries/Source/WWVegas/WW3D2/statistics.cpp index ba506020c8..09b0ce0fe0 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/statistics.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/statistics.cpp @@ -24,7 +24,6 @@ #include "dx8caps.h" #include "textureloader.h" #include "texture.h" -#include #include #ifdef _UNIX diff --git a/Core/Libraries/Source/WWVegas/WW3D2/statistics.h b/Core/Libraries/Source/WWVegas/WW3D2/statistics.h index 408952f290..1b89610cbc 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/statistics.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/statistics.h @@ -16,12 +16,7 @@ ** along with this program. If not, see . */ -#ifndef WW3D_STATISTICS_H -#define WW3D_STATISTICS_H - -#if defined(_MSC_VER) #pragma once -#endif #include "always.h" //#include "wwstring.h" @@ -76,5 +71,3 @@ namespace Debug_Statistics #define DX8_RECORD_RENDER(polys,verts,shader) Debug_Statistics::Record_DX8_Polys_And_Vertices(polys,verts,shader) #define DX8_RECORD_SORTING_RENDER(polys,verts) Debug_Statistics::Record_Sorting_Polys_And_Vertices(polys,verts) #define DX8_RECORD_SKIN_RENDER(polys,verts) Debug_Statistics::Record_DX8_Skin_Polys_And_Vertices(polys,verts) - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/streak.h b/Core/Libraries/Source/WWVegas/WW3D2/streak.h index 7eba9a2349..f0eb918425 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/streak.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/streak.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef STREAK_H -#define STREAK_H #include "rendobj.h" #include "shader.h" @@ -208,13 +203,3 @@ class StreakLineClass : public RenderObjClass SegLineRendererClass LineRenderer; StreakRendererClass StreakRenderer;//special, per-point alpha/color/size }; - - - - - - - - - -#endif // SEGLINE_H diff --git a/Core/Libraries/Source/WWVegas/WW3D2/streakRender.cpp b/Core/Libraries/Source/WWVegas/WW3D2/streakRender.cpp index 3c0f8c9f51..2fe4daf94b 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/streakRender.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/streakRender.cpp @@ -32,7 +32,7 @@ #include "sortingrenderer.h" #include "vp.h" #include "Vector3i.h" -#include "RANDOM.H" +#include "RANDOM.h" #include "v3_rnd.h" @@ -863,7 +863,7 @@ void StreakRendererClass::RenderStreak segment[intersectionIndex].StartPlane = -start_pl; } - } // for intersectionIndex + } /* @@ -1038,7 +1038,7 @@ void StreakRendererClass::RenderStreak next_int = &(intersection[intersectionIndex_r + 1][edge]); next_seg = &(segment[next_int->NextSegmentID]); - } // while + } // Copy from "read index" to "write index" write_int->PointCount = curr_int->PointCount; @@ -1048,7 +1048,7 @@ void StreakRendererClass::RenderStreak write_int->Direction = curr_int->Direction; write_int->Fold = curr_int->Fold; - } // for intersectionIndex + } // If intersectionIndex_r is exactly equal to num_isects (rather than being larger by one) at this // point, this means that the last intersection was not merged with the previous one. In @@ -1075,9 +1075,9 @@ void StreakRendererClass::RenderStreak assert(total_cnt == point_cnt); #endif - } // for edge - } // while (merged) - } // if (Is_Merge_Intersections()) + } + } + } /* ** Find vertex positions, generate vertices and triangles: @@ -1356,7 +1356,7 @@ void StreakRendererClass::RenderStreak texture->V = vertexArray[i].v1; vb += vbSize; } - } // copy + } DynamicIBAccessClass ib_access((sorting?BUFFER_TYPE_DYNAMIC_SORTING:BUFFER_TYPE_DYNAMIC_DX8),triangleIndex*3); { @@ -1387,7 +1387,7 @@ void StreakRendererClass::RenderStreak DX8Wrapper::Draw_Triangles(0,triangleIndex,0,vnum); } - } // Chunking loop + } DX8Wrapper::Set_Transform(D3DTS_VIEW,view); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/streakRender.h b/Core/Libraries/Source/WWVegas/WW3D2/streakRender.h index fc4e0ac5f0..a51033d565 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/streakRender.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/streakRender.h @@ -36,8 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef STREAKRENDER_H -#define STREAKRENDER_H +#pragma once #include "always.h" #include "shader.h" @@ -222,6 +221,3 @@ inline void StreakRendererClass::Reset_Line(void) { // Empty } - -#endif //STREAKRENDER_H - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp index 640f9f312e..fdec676476 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp @@ -481,7 +481,7 @@ class Stripify }; int Stripify::s_mod[6] = {0,1,2,0,1,2}; -} // Strip +} template <> inline unsigned int HashTemplateKeyClass::Get_Hash_Value(const Strip::Edge& s) @@ -1009,7 +1009,7 @@ int* Stripify::stripify (const Vector3i* inTris, int N) return rOut; } -} // Strip +} int* StripOptimizerClass::Stripify(const int* tris, int N) { return Strip::Stripify::stripify((const Strip::Vector3i*)tris,N); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.h b/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.h index 5ae9a8cd9f..001840bb37 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.h @@ -16,12 +16,7 @@ ** along with this program. If not, see . */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef WW3D2_STRIP_OPTIMIZER_H__ -#define WW3D2_STRIP_OPTIMIZER_H__ #include "always.h" @@ -44,5 +39,3 @@ class StripOptimizerClass static int Get_Strip_Index_Count(const int* strips, int strips_count); }; - -#endif // WW3D2_STRIP_OPTIMIZER_H__ diff --git a/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.h b/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.h index de3b700057..947199f2cd 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.h @@ -36,15 +36,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef SURFACECLASS_H -#define SURFACECLASS_H +#include "always.h" #include "ww3dformat.h" -#include "refcount.h" struct IDirect3DSurface8; class Vector2i; @@ -148,7 +143,3 @@ class SurfaceClass : public W3DMPO, public RefCountClass WW3DFormat SurfaceFormat; friend class TextureClass; }; - -#endif - - diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texproject.cpp b/Core/Libraries/Source/WWVegas/WW3D2/texproject.cpp similarity index 99% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texproject.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/texproject.cpp index 5cb239e276..38b5ceee3e 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texproject.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/texproject.cpp @@ -88,7 +88,7 @@ // DEBUG DEBUG -#include "MPU.H" +#include "MPU.h" #define DEBUG_SHADOW_RENDERING 0 //#define DEFAULT_TEXTURE_SIZE 64 @@ -1317,9 +1317,8 @@ void TexProjectClass::Pre_Render_Update(const Matrix3D & camera) /* ** update the current intensity by iterating it towards the desired intensity */ - float frame_time = (float)WW3D::Get_Frame_Time() / 1000.0f; float intensity_delta = DesiredIntensity - Intensity; - float max_intensity_delta = INTENSITY_RATE_OF_CHANGE * frame_time; + float max_intensity_delta = INTENSITY_RATE_OF_CHANGE * WW3D::Get_Logic_Frame_Time_Seconds(); if (intensity_delta > max_intensity_delta) { Intensity += max_intensity_delta; diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texproject.h b/Core/Libraries/Source/WWVegas/WW3D2/texproject.h similarity index 99% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texproject.h rename to Core/Libraries/Source/WWVegas/WW3D2/texproject.h index a6b20d216b..0489220f64 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texproject.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/texproject.h @@ -37,12 +37,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef TEXPROJECT_H -#define TEXPROJECT_H #include "always.h" #include "matrix3d.h" @@ -242,7 +237,3 @@ class TexProjectClass : public ProjectorClass, public CullableClass, public Mult */ typedef RefMultiListClass TexProjListClass; typedef RefMultiListIterator TexProjListIterator; - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/textdraw.h b/Core/Libraries/Source/WWVegas/WW3D2/textdraw.h index 305f0983f5..668ace7d1a 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/textdraw.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/textdraw.h @@ -32,13 +32,7 @@ * * *-------------------------------------------------------------------------*/ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef TEXTDRAW_H -#define TEXTDRAW_H #include "always.h" #include "dynamesh.h" @@ -116,5 +110,3 @@ class TextDrawClass : public DynamicMeshClass Vector2 TranslateOffset; Vector2 PixelSize; }; - -#endif // TEXTDRAW_H diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.cpp b/Core/Libraries/Source/WWVegas/WW3D2/texture.cpp similarity index 99% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/texture.cpp index a3dd2c564a..a87382f647 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/texture.cpp @@ -42,10 +42,9 @@ #include "texture.h" #include -#include #include #include "dx8wrapper.h" -#include "TARGA.H" +#include "TARGA.h" #include #include "w3d_file.h" #include "assetmgr.h" @@ -59,9 +58,6 @@ #include "texturethumbnail.h" #include "wwprofile.h" -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") - const unsigned DEFAULT_INACTIVATION_TIME=20000; /* diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.h b/Core/Libraries/Source/WWVegas/WW3D2/texture.h similarity index 99% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.h rename to Core/Libraries/Source/WWVegas/WW3D2/texture.h index 5f05eba8ac..06e623fb6b 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texture.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/texture.h @@ -39,16 +39,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef TEXTURE_H -#define TEXTURE_H #include "always.h" -#include "refcount.h" #include "chunkio.h" #include "surfaceclass.h" #include "ww3dformat.h" @@ -480,5 +473,3 @@ class VolumeTextureClass : public TextureClass // Utility functions for loading and saving texture descriptions from/to W3D files TextureClass *Load_Texture(ChunkLoadClass & cload); void Save_Texture(TextureClass * texture, ChunkSaveClass & csave); - -#endif //TEXTURE_H diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturefilter.cpp b/Core/Libraries/Source/WWVegas/WW3D2/texturefilter.cpp similarity index 100% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturefilter.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/texturefilter.cpp diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturefilter.h b/Core/Libraries/Source/WWVegas/WW3D2/texturefilter.h similarity index 98% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturefilter.h rename to Core/Libraries/Source/WWVegas/WW3D2/texturefilter.h index 8db3f5c73d..3571471e4e 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturefilter.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/texturefilter.h @@ -37,8 +37,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef TEXTUREFILTER_H -#define TEXTUREFILTER_H +#pragma once #ifndef DX8_WRAPPER_H //#include "dx8wrapper.h" @@ -129,5 +128,3 @@ class TextureFilterClass TxtAddrMode UAddressMode; TxtAddrMode VAddressMode; }; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp b/Core/Libraries/Source/WWVegas/WW3D2/textureloader.cpp similarity index 99% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/textureloader.cpp index bda829eb7f..3b1fcfa61d 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/textureloader.cpp @@ -51,20 +51,15 @@ #include "dx8wrapper.h" #include "dx8caps.h" #include "missingtexture.h" -#include "TARGA.H" +#include "TARGA.h" #include -#include #include "wwmemlog.h" -#include "texture.h" #include "formconv.h" #include "texturethumbnail.h" #include "ddsfile.h" #include "bitmaphandler.h" #include "wwprofile.h" -//#pragma optimize("", off) -//#pragma MESSAGE("************************************** WARNING, optimization disabled for debugging purposes") - bool TextureLoader::TextureLoadSuspended; int TextureLoader::TextureInactiveOverrideTime = 0; @@ -625,7 +620,7 @@ IDirect3DSurface8* TextureLoader::Load_Surface_Immediate( DX8_ErrorCode(d3d_surface->UnlockRect()); - if (converted_surface) delete[] converted_surface; + delete[] converted_surface; return d3d_surface; } @@ -1100,7 +1095,7 @@ void TextureLoadTaskClass::Init(TextureBaseClass* tc, TaskType type, PriorityTyp REF_PTR_SET(Texture, tc); // Make sure texture has a filename. - WWASSERT(Texture->Get_Full_Path() != ""); + WWASSERT(!Texture->Get_Full_Path().Is_Empty()); Type = type; Priority = priority; @@ -2003,9 +1998,7 @@ bool TextureLoadTaskClass::Load_Uncompressed_Mipmap(void) } } - if (converted_surface) { - delete[] converted_surface; - } + delete[] converted_surface; return true; } @@ -2072,7 +2065,7 @@ void CubeTextureLoadTaskClass::Init(TextureBaseClass* tc, TaskType type, Priorit REF_PTR_SET(Texture, tc); // Make sure texture has a filename. - WWASSERT(Texture->Get_Full_Path() != ""); + WWASSERT(!Texture->Get_Full_Path().Is_Empty()); Type = type; Priority = priority; @@ -2483,7 +2476,7 @@ void VolumeTextureLoadTaskClass::Init(TextureBaseClass* tc, TaskType type, Prior REF_PTR_SET(Texture, tc); // Make sure texture has a filename. - WWASSERT(Texture->Get_Full_Path() != ""); + WWASSERT(!Texture->Get_Full_Path().Is_Empty()); Type = type; Priority = priority; diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.h b/Core/Libraries/Source/WWVegas/WW3D2/textureloader.h similarity index 99% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.h rename to Core/Libraries/Source/WWVegas/WW3D2/textureloader.h index 91375804a6..38104d6495 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/textureloader.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/textureloader.h @@ -37,13 +37,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef TEXTURELOADER_H -#define TEXTURELOADER_H - -#if defined(_MSC_VER) #pragma once -#endif #include "always.h" #include "texture.h" @@ -330,5 +324,3 @@ class VolumeTextureLoadTaskClass : public TextureLoadTaskClass unsigned int Depth; }; - -#endif diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp b/Core/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp similarity index 97% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp rename to Core/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp index c7bdb228b2..03c803491a 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp @@ -19,13 +19,13 @@ #include "texturethumbnail.h" #include "hashtemplate.h" #include "missingtexture.h" -#include "TARGA.H" +#include "TARGA.h" #include "ww3dformat.h" #include "ddsfile.h" #include "textureloader.h" #include "bitmaphandler.h" #include "ffactory.h" -#include "RAWFILE.H" +#include "RAWFILE.h" #include "wwprofile.h" #include @@ -37,7 +37,7 @@ static void Create_Hash_Name(StringClass& name, const StringClass& thumb_name) { name=thumb_name; int len=name.Get_Length(); - WWASSERT(!stricmp(&name[len-4],".tga") || !stricmp(&name[len-4],".dds")); + WWASSERT(stricmp(&name[len-4],".tga") == 0 || stricmp(&name[len-4],".dds") == 0); name[len-4]='\0'; _strlwr(name.Peek_Buffer()); } @@ -278,7 +278,7 @@ ThumbnailManagerClass::~ThumbnailManagerClass() ite.First(); } - if (ThumbnailMemory) delete[] ThumbnailMemory; + delete[] ThumbnailMemory; ThumbnailMemory=NULL; } @@ -404,8 +404,7 @@ void ThumbnailManagerClass::Deinit() while (ThumbnailManagerClass* man=ThumbnailManagerList.Head()) { delete man; } - if (GlobalThumbnailManager) { - delete GlobalThumbnailManager; - GlobalThumbnailManager=NULL; - } + + delete GlobalThumbnailManager; + GlobalThumbnailManager=NULL; } diff --git a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturethumbnail.h b/Core/Libraries/Source/WWVegas/WW3D2/texturethumbnail.h similarity index 97% rename from GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturethumbnail.h rename to Core/Libraries/Source/WWVegas/WW3D2/texturethumbnail.h index f343591bef..465bcc367e 100644 --- a/GeneralsMD/Code/Libraries/Source/WWVegas/WW3D2/texturethumbnail.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/texturethumbnail.h @@ -17,12 +17,8 @@ */ // 08/07/02 KM Texture class redesign (revisited) -#ifndef TEXTURETHUMBNAIL_H -#define TEXTURETHUMBNAIL_H -#if defined(_MSC_VER) #pragma once -#endif #include "always.h" #include "wwstring.h" @@ -126,5 +122,3 @@ class ThumbnailManagerClass : public DLNodeClass }; // ---------------------------------------------------------------------------- - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp index 994654e198..5c4bf51f9e 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp @@ -405,14 +405,12 @@ void IDBufferClass::Get_Resolution(int * get_w,int * get_h) void IDBufferClass::Reset(void) { - if (IDBuffer!=NULL) { - delete[] IDBuffer; - IDBuffer = NULL; - } - if (ZBuffer != NULL) { - delete[] ZBuffer; - ZBuffer = NULL; - } + delete[] IDBuffer; + IDBuffer = NULL; + + delete[] ZBuffer; + ZBuffer = NULL; + PixelCounter = 0; } @@ -493,7 +491,7 @@ struct EdgeStruct OOZStep = XStep * grad.DOOZ_DX + grad.DOOZ_DY; } - inline int Step(void) + int Step(void) { X+=XStep; Y++; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.h b/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.h index 554d007d41..193358f152 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.h @@ -36,12 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef VISRASTERIZER_H -#define VISRASTERIZER_H #include "always.h" #include "matrix3d.h" @@ -208,6 +203,3 @@ class VisRasterizerClass SimpleVecClass TempVertexBuffer; }; - -#endif //VISRASTERIZER_H - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp b/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp index 49279e03ce..415b9fb8c5 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp @@ -83,7 +83,7 @@ static void Scan_Emitter (ChunkLoadClass &cload, StringList &files, const char * static void Scan_Aggregate (ChunkLoadClass &cload, StringList &files, const char *w3d_name); static void Scan_HLOD (ChunkLoadClass &cload, StringList &files, const char *w3d_name); -static void Get_W3D_Name (const char *filename, char *w3d_name); +static void Get_W3D_Name (const char *filename, char *w3d_name, size_t w3d_name_size); static const char * Make_W3D_Filename (const char *w3d_name); @@ -118,7 +118,7 @@ bool Get_W3D_Dependencies (const char *w3d_filename, StringList &files) // Get the W3D name from the filename. char w3d_name[W3D_NAME_LEN]; - Get_W3D_Name(w3d_filename, w3d_name); + Get_W3D_Name(w3d_filename, w3d_name, ARRAY_SIZE(w3d_name)); // Create a chunk loader for this file, and scan the file. ChunkLoadClass cload(file); @@ -511,7 +511,7 @@ static void Scan_HLOD (ChunkLoadClass &cload, StringList &files, const char *w3d * HISTORY: * * 4/3/00 AJA : Created. * *=============================================================================================*/ -static void Get_W3D_Name (const char *filename, char *w3d_name) +static void Get_W3D_Name(const char* filename, char* w3d_name, size_t w3d_name_size) { assert(filename); assert(w3d_name); @@ -532,9 +532,9 @@ static void Get_W3D_Name (const char *filename, char *w3d_name) // Copy all characters from start to end (excluding 'end') // into the w3d_name buffer. Then capitalize the string. - memset(w3d_name, 0, W3D_NAME_LEN); // blank out the buffer - int num_chars = end - start; - strncpy(w3d_name, start, num_chars < W3D_NAME_LEN ? num_chars : W3D_NAME_LEN-1); + size_t num_chars = end - start; + WWASSERT(num_chars < w3d_name_size); + strlcpy(w3d_name, start, min(w3d_name_size, num_chars)); strupr(w3d_name); } @@ -554,7 +554,6 @@ static void Get_W3D_Name (const char *filename, char *w3d_name) static const char * Make_W3D_Filename (const char *w3d_name) { assert(w3d_name); - assert(strlen(w3d_name) < W3D_NAME_LEN); // Copy the w3d name into a static buffer, turn it into lowercase // letters, and append a ".w3d" file extension. That's the filename. @@ -565,11 +564,12 @@ static const char * Make_W3D_Filename (const char *w3d_name) buffer[0] = 0; return buffer; } - strcpy(buffer, w3d_name); + const size_t bufferLen = strlcpy(buffer, w3d_name, ARRAY_SIZE(buffer)); + (void)bufferLen; WWASSERT(bufferLen < W3D_NAME_LEN); char *dot = strchr(buffer, '.'); if (dot) *dot = 0; strlwr(buffer); - strcat(buffer, ".w3d"); + strlcat(buffer, ".w3d", ARRAY_SIZE(buffer)); return buffer; } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.h b/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.h index 3e02cae30d..363883df04 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.h @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef W3D_DEP_H -#define W3D_DEP_H +#pragma once #pragma warning (push, 3) #pragma warning (disable: 4018 4284 4786 4788) @@ -50,5 +49,3 @@ typedef std::list StringList; bool Get_W3D_Dependencies (const char *w3d_filename, StringList &files); - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h b/Core/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h index ba9f2a69ec..eb9a537f99 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h @@ -34,14 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef W3D_OBSOLETE_H -#define W3D_OBSOLETE_H - ///////////////////////////////////////////////////////////////////////////////////////////// // Obsolete chunk id's @@ -328,6 +321,3 @@ struct W3dHModelAuxDataStruct float32 LODMax; uint32 FutureUse[32]; }; - - -#endif // W3D_OBSOLETE_H diff --git a/Core/Libraries/Source/WWVegas/WW3D2/w3d_util.h b/Core/Libraries/Source/WWVegas/WW3D2/w3d_util.h index 99c97ee465..90b3da3e16 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/w3d_util.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/w3d_util.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef W3D_UTIL_H -#define W3D_UTIL_H #include "always.h" #include "w3d_file.h" @@ -74,7 +68,3 @@ class W3dUtilityClass static void Convert_Shader(const ShaderClass & shader,W3dShaderStruct * set); }; - -#endif - - diff --git a/Core/Libraries/Source/WWVegas/WW3D2/w3derr.h b/Core/Libraries/Source/WWVegas/WW3D2/w3derr.h index 4411dd2fe4..c600f8ca70 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/w3derr.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/w3derr.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef W3DERR_H -#define W3DERR_H #include "always.h" @@ -56,5 +50,3 @@ enum WW3DErrorType WW3D_ERROR_WINDOW_NOT_OPEN, WW3D_ERROR_INITIALIZATION_FAILED, }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.h b/Core/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.h index 9614682647..de01b0a939 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.h @@ -35,15 +35,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef W3DEXCLUSIONLIST_H -#define W3DEXCLUSIONLIST_H #include "always.h" -#include "Vector.H" +#include "Vector.h" #include "wwstring.h" #include "hashtemplate.h" @@ -78,7 +73,3 @@ class W3DExclusionListClass const DynamicVectorClass & Names; HashTemplateClass NameHash; }; - - - -#endif //EXCLUSIONLIST_H diff --git a/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp b/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp index 3e718ba0b5..b5d6de1a73 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp @@ -40,7 +40,7 @@ #include "ww3dformat.h" #include "vector4.h" #include "wwdebug.h" -#include "TARGA.H" +#include "TARGA.h" #include "dx8wrapper.h" #include "dx8caps.h" #include diff --git a/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.h b/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.h index 0724c8c834..e9f9d89874 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.h @@ -39,12 +39,7 @@ * Color_to_Vector4 - converts a color in the format described in format to a Vector4 * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef WW3DFORMAT_H -#define WW3DFORMAT_H #include "always.h" #include "wwstring.h" @@ -205,5 +200,3 @@ void Get_WW3D_ZFormat_Name(WW3DZFormat format, StringClass& name); unsigned Get_Num_Depth_Bits(WW3DZFormat zformat); unsigned Get_Num_Stencil_Bits(WW3DZFormat zformat); - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/ww3dids.h b/Core/Libraries/Source/WWVegas/WW3D2/ww3dids.h index de4827224d..d308fcab62 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/ww3dids.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/ww3dids.h @@ -34,14 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - -#ifndef WW3DIDS_H -#define WW3DIDS_H #include "saveloadids.h" @@ -73,5 +66,3 @@ enum WW3D_PERSIST_CHUNKID_LIGHT, WW3D_PERSIST_CHUNKID_DAZZLE, }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h b/Core/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h index 2d17edac82..2720d320ca 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/ww3dtrig.h @@ -34,14 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef WW3DTRIG_H -#define WW3DTRIG_H - /* ** The WW3D Library will check for debugging triggers using the following ID's @@ -57,5 +50,3 @@ enum WW3D_TRIGGER_SURFACE_CACHE_STATS = 0x101, // display surface cache info in the debug window WW3D_TRIGGER_PROCESS_STATS = 0x102 // render stats for last frame only }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AABTreeSoundCullClass.h b/Core/Libraries/Source/WWVegas/WWAudio/AABTreeSoundCullClass.h index 1e37e6c11f..e5e4182652 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/AABTreeSoundCullClass.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/AABTreeSoundCullClass.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __AABTREESOUNDCULLCLASS_H -#define __AABTREESOUNDCULLCLASS_H #include "aabtreecull.h" @@ -78,6 +72,3 @@ class AABTreeSoundCullClass : public AABTreeCullClass virtual void Save_Node_Contents (AABTreeNodeClass * node,ChunkSaveClass & csave) { }; }; - -#endif //__AABTREESOUNDCULLCLASS_H - diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.cpp b/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.cpp index eb343cf1a1..370b4537f0 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.cpp @@ -637,7 +637,7 @@ AudibleSoundClass::Initialize_Miles_Handle (void) // // Associate this object instance with the handle // - m_SoundHandle->Set_Sample_User_Data (INFO_OBJECT_PTR, (S32)this); + m_SoundHandle->Set_Sample_User_Data (INFO_OBJECT_PTR, (void *)this); } return ; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.h b/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.h index 1ccdf6b47c..bec8f15b5a 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.h @@ -34,24 +34,19 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SOUNDOBJ_H -#define __SOUNDOBJ_H #pragma warning (push, 3) #include "mss.h" #pragma warning (pop) //#include +#include "always.h" #include "vector3.h" #include "matrix3d.h" -#include "refcount.h" -#include "RAWFILE.H" +#include "RAWFILE.h" #include "SoundSceneObj.h" -#include "Vector.H" +#include "Vector.h" #include "wwstring.h" #include "definition.h" @@ -459,6 +454,3 @@ class AudibleSoundDefinitionClass : public DefinitionClass // Misc UI info Vector3 m_AttenuationSphereColor; }; - - -#endif //__SOUNDOBJ_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AudioEvents.h b/Core/Libraries/Source/WWVegas/WWAudio/AudioEvents.h index e8244fe5da..0a268f93f4 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/AudioEvents.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/AudioEvents.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __AUDIO_EVENTS_H -#define __AUDIO_EVENTS_H #include "simplevec.h" #include "bittype.h" @@ -209,7 +204,3 @@ AudioCallbackListClass::Remove_Callback (T pointer) return ; } - - -#endif //__AUDIO_EVENTS_H - diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.h b/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.h index ff3e13e2b5..bccf64bc29 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.h @@ -34,16 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __AUDIO_SAVE_LOAD_H -#define __AUDIO_SAVE_LOAD_H #include "saveloadsubsystem.h" -#include "Vector.H" +#include "Vector.h" #include "bittype.h" @@ -121,8 +115,3 @@ class DynamicAudioSaveLoadClass : public SaveLoadSubSystemClass //bool Save_Micro_Chunks (ChunkSaveClass &csave); //bool Load_Micro_Chunks (ChunkLoadClass &cload); }; - - -#endif //__AUDIO_SAVE_LOAD_H - - diff --git a/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.cpp b/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.cpp index cd0093940c..4228bb65b0 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.cpp @@ -57,7 +57,7 @@ SimplePersistFactoryClass _FilteredS // ///////////////////////////////////////////////////////////////////////////////// FilteredSoundClass::FilteredSoundClass (void) - : m_hFilter (INVALID_MILES_HANDLE) + : m_hFilter ((HPROVIDER)INVALID_MILES_HANDLE) { return ; } @@ -69,7 +69,7 @@ FilteredSoundClass::FilteredSoundClass (void) // //////////////////////////////////////////////////////////////////////////////////////////////// FilteredSoundClass::FilteredSoundClass (const FilteredSoundClass &src) - : m_hFilter (INVALID_MILES_HANDLE), + : m_hFilter ((HPROVIDER)INVALID_MILES_HANDLE), SoundPseudo3DClass (src) { (*this) = src; @@ -113,7 +113,7 @@ FilteredSoundClass::Initialize_Miles_Handle (void) SoundPseudo3DClass::Initialize_Miles_Handle (); m_hFilter = WWAudioClass::Get_Instance ()->Get_Reverb_Filter (); if ((m_SoundHandle != NULL) && - (m_hFilter != INVALID_MILES_HANDLE)) { + (m_hFilter != (HPROVIDER)INVALID_MILES_HANDLE)) { // // Pass the filter onto the sample diff --git a/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.h b/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.h index ebfdaf7216..c200a290f5 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __FILTERED_SOUND_H -#define __FILTERED_SOUND_H - #include "SoundPseudo3D.h" @@ -100,7 +94,3 @@ class FilteredSoundClass : public SoundPseudo3DClass ////////////////////////////////////////////////////////////////////// HPROVIDER m_hFilter; }; - - -#endif //__FILTERED_SOUND_H - diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Listener.cpp b/Core/Libraries/Source/WWVegas/WWAudio/Listener.cpp index 3d76e2f9fe..9797e5e898 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Listener.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/Listener.cpp @@ -84,7 +84,7 @@ Listener3DClass::Initialize_Miles_Handle (void) // Associate this object instance with the handle - m_SoundHandle->Set_Sample_User_Data (INFO_OBJECT_PTR, (S32)this); + m_SoundHandle->Set_Sample_User_Data (INFO_OBJECT_PTR, (void *)this); } return ; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Listener.h b/Core/Libraries/Source/WWVegas/WWAudio/Listener.h index 48aaee65aa..8ecfdac993 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Listener.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/Listener.h @@ -34,14 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __LISTENER_H -#define __LISTENER_H - #include "Sound3D.h" @@ -142,6 +135,3 @@ class Listener3DClass : public Sound3DClass // Private member data ////////////////////////////////////////////////////////////////////// }; - - -#endif //__LISTENER_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.h b/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.h index 69ef161f05..780e40816d 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.h @@ -30,12 +30,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __LOGICAL_LISTENER_H -#define __LOGICAL_LISTENER_H #include "SoundSceneObj.h" #include "bittype.h" @@ -147,7 +142,3 @@ class LogicalListenerClass : public SoundSceneObjClass static uint32 m_OldestTimestamp; static uint32 m_NewestTimestamp; }; - - -#endif //__LOGICAL_LISTENER_H - diff --git a/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.cpp b/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.cpp index 927e92146b..593e407de8 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.cpp @@ -171,7 +171,7 @@ LogicalSoundClass::On_Frame_Update (unsigned int milliseconds) // Update the sound's position if its linked to a render object // Apply_Auto_Position (); - return SoundSceneObjClass::On_Frame_Update (milliseconds);; + return SoundSceneObjClass::On_Frame_Update (milliseconds); } diff --git a/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.h b/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.h index 4eb86a3ce0..fc25c02062 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.h @@ -30,12 +30,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __LOGICAL_SOUND_H -#define __LOGICAL_SOUND_H #include "SoundSceneObj.h" #include "bittype.h" @@ -147,7 +142,3 @@ class LogicalSoundClass : public SoundSceneObjClass uint32 m_NotifyDelayInMS; uint32 m_LastNotification; }; - - -#endif //__LOGICAL_SOUND_H - diff --git a/Core/Libraries/Source/WWVegas/WWAudio/PriorityVector.h b/Core/Libraries/Source/WWVegas/WWAudio/PriorityVector.h index 231beb2eb5..a7e4fa54e3 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/PriorityVector.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/PriorityVector.h @@ -30,14 +30,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif -#ifndef __PRIORITY_VECTOR_H -#define __PRIORITY_VECTOR_H - -#include "Vector.H" +#include "Vector.h" //////////////////////////////////////////////////////////////////// // @@ -115,6 +110,3 @@ __inline bool PriorityVectorClass::Add_High (T const &object) { return DynamicVectorClass::Add_Head (object); } - -#endif //__PRIORITY_VECTOR_H - diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.cpp b/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.cpp index bfeb51ef94..d887071808 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.cpp @@ -532,7 +532,7 @@ Sound3DClass::Initialize_Miles_Handle (void) Seek (m_CurrentPosition); // Associate this object instance with the handle - m_SoundHandle->Set_Sample_User_Data (INFO_OBJECT_PTR, (S32)this); + m_SoundHandle->Set_Sample_User_Data (INFO_OBJECT_PTR, (void *)this); } return ; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.h b/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.h index 436ed482aa..f3c036f5fc 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SOUND3DOBJ_H -#define __SOUND3DOBJ_H #include "AudibleSound.h" #include "mempool.h" @@ -196,6 +191,3 @@ class Sound3DClass : public AudibleSoundClass bool m_IsStatic; unsigned int m_LastUpdate; }; - - -#endif //__SOUND3DOBJ_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundBuffer.cpp b/Core/Libraries/Source/WWVegas/WWAudio/SoundBuffer.cpp index 5484b6ff69..3896d68c5a 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundBuffer.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundBuffer.cpp @@ -36,7 +36,7 @@ #include "SoundBuffer.h" -#include "RAWFILE.H" +#include "RAWFILE.h" #include "wwdebug.h" #include "Utils.h" #include "ffactory.h" @@ -100,10 +100,8 @@ void SoundBufferClass::Free_Buffer (void) { // Free the buffer's memory - if (m_Buffer != NULL) { - delete [] m_Buffer; - m_Buffer = NULL; - } + delete [] m_Buffer; + m_Buffer = NULL; // Make sure we reset the length m_Length = 0L; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundBuffer.h b/Core/Libraries/Source/WWVegas/WWAudio/SoundBuffer.h index 1b0a5d68ea..45c48ad00f 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundBuffer.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundBuffer.h @@ -34,19 +34,13 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SOUNDBUFFER_H -#define __SOUNDBUFFER_H #pragma warning (push, 3) #include "mss.h" #pragma warning (pop) -#include "refcount.h" +#include "always.h" // Forward declarations @@ -175,6 +169,3 @@ class StreamSoundBufferClass : public SoundBufferClass // Protected member data ////////////////////////////////////////////////////////////////////// }; - - -#endif //__SOUNDBUFFER_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundChunkIDs.h b/Core/Libraries/Source/WWVegas/WWAudio/SoundChunkIDs.h index 98e54ab7ab..1d21530414 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundChunkIDs.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundChunkIDs.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SOUND_CHUNK_IDS_H -#define __SOUND_CHUNK_IDS_H #include "saveloadids.h" #include "definitionclassids.h" @@ -77,6 +71,3 @@ enum { CLASSID_SOUND_DEF = CLASSID_SOUND, }; - - -#endif //__SOUND_CHUNK_IDS_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundCullObj.h b/Core/Libraries/Source/WWVegas/WWAudio/SoundCullObj.h index bd0b5edfa2..299a37aac9 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundCullObj.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundCullObj.h @@ -34,17 +34,11 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SOUNDCULLOBJ_H -#define __SOUNDCULLOBJ_H +#include "always.h" #include "SoundSceneObj.h" #include "cullsys.h" -#include "refcount.h" #include "mempool.h" #include "multilist.h" @@ -169,5 +163,3 @@ SoundCullObjClass::Get_Bounding_Box (void) const m_AABox.Center = m_Transform.Get_Translation (); return m_AABox; } - -#endif //__SOUNDCULLOBJ_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.h b/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.h index 8bd6b2548e..cd9e78e403 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SOUND_PSEUDO_3DOBJ_H -#define __SOUND_PSEUDO_3DOBJ_H - #include "Sound3D.h" @@ -158,6 +152,3 @@ class SoundPseudo3DClass : public Sound3DClass // Private member data ////////////////////////////////////////////////////////////////////// }; - - -#endif //__SOUND_PSEUDO_3DOBJ_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.h b/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.h index 3896fc9554..ef2620e4da 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.h @@ -34,18 +34,12 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SOUNDSCENE_H -#define __SOUNDSCENE_H #include "aabtreecull.h" #include "gridcull.h" #include "Listener.h" -#include "Vector.H" +#include "Vector.h" #include "PriorityVector.h" #include "SoundCullObj.h" #include "LogicalListener.h" @@ -224,6 +218,3 @@ class SoundSceneClass bool m_IsBatchMode; }; - - -#endif //__SOUNDSCENE_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.h b/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.h index 39a5faf7f4..f0580edfb6 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.h @@ -32,14 +32,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif -#ifndef __SOUND_SCENE_OBJ_H -#define __SOUND_SCENE_OBJ_H - -#include "refcount.h" +#include "always.h" #include "WWAudio.h" #include "bittype.h" #include "persist.h" @@ -272,8 +267,3 @@ SoundSceneObjClass::Register_Callback m_pCallback = callback; return ; } - - - -#endif //__SOUND_SCENE_OBJ_H - diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Threads.cpp b/Core/Libraries/Source/WWVegas/WWAudio/Threads.cpp index 007ae7f4b4..65d62e83a8 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Threads.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/Threads.cpp @@ -30,12 +30,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - +#include "always.h" #include "Threads.h" -#include "refcount.h" #include "Utils.h" #include -#include "wwdebug.h" /////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Threads.h b/Core/Libraries/Source/WWVegas/WWAudio/Threads.h index de7cf80fb7..17af4841b5 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Threads.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/Threads.h @@ -30,15 +30,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __WWAUDIO_THREADS_H -#define __WWAUDIO_THREADS_H #include "windows.h" -#include "Vector.H" +#include "Vector.h" #include "mutex.h" // Forward declarations @@ -107,6 +102,3 @@ class WWAudioThreadsClass static CriticalSectionClass m_ListMutex; static bool m_IsShuttingDown; }; - -#endif //__WWAUDIO_THREADS_H - diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Utils.h b/Core/Libraries/Source/WWVegas/WWAudio/Utils.h index 37b60b5a10..ffff71bff5 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Utils.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/Utils.h @@ -34,9 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef __UTILS_H -#define __UTILS_H +#pragma once #pragma warning (push, 3) #include "mss.h" @@ -46,23 +44,11 @@ // // Macros // -#define SAFE_DELETE(pobject) \ - if (pobject) { \ - delete pobject; \ - pobject = NULL; \ - } \ +#define SAFE_DELETE(pobject) { delete pobject; pobject = NULL; } -#define SAFE_DELETE_ARRAY(pobject) \ - if (pobject) { \ - delete [] pobject; \ - pobject = NULL; \ - } \ +#define SAFE_DELETE_ARRAY(pobject) { delete [] pobject; pobject = NULL; } -#define SAFE_FREE(pobject) \ - if (pobject) { \ - ::free (pobject); \ - pobject = NULL; \ - } \ +#define SAFE_FREE(pobject) { ::free (pobject); pobject = NULL; } ///////////////////////////////////////////////////////////////////////////// @@ -100,6 +86,3 @@ Get_Filename_From_Path (LPCTSTR path) // Return the filename part of the path return filename; } - - -#endif //__UTILS_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp b/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp index 230eff7324..6590cbe88c 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp @@ -44,7 +44,7 @@ #include "SoundBuffer.h" #include "AudibleSound.h" #include "Sound3D.h" -#include "RAWFILE.H" +#include "RAWFILE.h" #include "SoundScene.h" #include "SoundPseudo3D.h" #include "ffactory.h" @@ -109,7 +109,7 @@ WWAudioClass::WWAudioClass (void) m_PlaybackRate (44100), m_PlaybackBits (16), m_PlaybackStereo (true), - m_ReverbFilter (INVALID_MILES_HANDLE), + m_ReverbFilter ((HPROVIDER)INVALID_MILES_HANDLE), m_UpdateTimer (-1), m_Driver3DPseudo (NULL), m_MusicVolume (DEF_MUSIC_VOL), @@ -372,7 +372,7 @@ WWAudioClass::Get_Sound_Buffer (const char *filename, bool is_3d) buffer = Create_Sound_Buffer (*file, filename, is_3d); } else { static int count = 0; - if ( ++count < 10 ) { + if ( count++ < 10 ) { WWDEBUG_SAY(( "Sound \"%s\" not found", filename )); } } @@ -807,7 +807,7 @@ WWAudioClass::Create_3D_Sound sound_obj->Set_Buffer (buffer); } else { static int count = 0; - if ( ++count < 10 ) { + if ( count++ < 10 ) { WWDEBUG_SAY(( "Sound File not Found \"%s\"", filename )); } } @@ -2104,7 +2104,7 @@ WWAudioClass::Initialize (const char *registry_subkey_name) HPROENUM next = HPROENUM_FIRST; char *name = NULL; if (::AIL_enumerate_filters (&next, &m_ReverbFilter, &name) == 0) { - m_ReverbFilter = INVALID_MILES_HANDLE; + m_ReverbFilter = (HPROVIDER)INVALID_MILES_HANDLE; } } @@ -2143,7 +2143,7 @@ WWAudioClass::Initialize HPROENUM next = HPROENUM_FIRST; char *name = NULL; if (::AIL_enumerate_filters (&next, &m_ReverbFilter, &name) == 0) { - m_ReverbFilter = INVALID_MILES_HANDLE; + m_ReverbFilter = (HPROVIDER)INVALID_MILES_HANDLE; } } @@ -2740,7 +2740,7 @@ WWAudioClass::Save_To_Registry // //////////////////////////////////////////////////////////////////////////////////////////// U32 AILCALLBACK -WWAudioClass::File_Open_Callback (char const *filename, U32 *file_handle) +WWAudioClass::File_Open_Callback (char const *filename, void **file_handle) { U32 retval = false; @@ -2751,7 +2751,7 @@ WWAudioClass::File_Open_Callback (char const *filename, U32 *file_handle) // FileClass *file = Get_Instance ()->Get_File (filename); if (file != NULL && file->Open ()) { - (*file_handle) = (U32)file; + (*file_handle) = (void *)file; retval = true; } } @@ -2766,7 +2766,7 @@ WWAudioClass::File_Open_Callback (char const *filename, U32 *file_handle) // //////////////////////////////////////////////////////////////////////////////////////////// void AILCALLBACK -WWAudioClass::File_Close_Callback (U32 file_handle) +WWAudioClass::File_Close_Callback (void *file_handle) { if (Get_Instance () != NULL) { @@ -2789,7 +2789,7 @@ WWAudioClass::File_Close_Callback (U32 file_handle) // //////////////////////////////////////////////////////////////////////////////////////////// S32 AILCALLBACK -WWAudioClass::File_Seek_Callback (U32 file_handle, S32 offset, U32 type) +WWAudioClass::File_Seek_Callback (void *file_handle, S32 offset, U32 type) { S32 retval = 0; @@ -2834,7 +2834,7 @@ WWAudioClass::File_Seek_Callback (U32 file_handle, S32 offset, U32 type) // //////////////////////////////////////////////////////////////////////////////////////////// U32 AILCALLBACK -WWAudioClass::File_Read_Callback (U32 file_handle, void *buffer, U32 bytes) +WWAudioClass::File_Read_Callback (void *file_handle, void *buffer, U32 bytes) { U32 retval = 0; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.h b/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.h index f9aaf54400..cc2f6a0c9e 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.h @@ -34,19 +34,14 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __WWAUDIO_H -#define __WWAUDIO_H #include "always.h" #pragma warning (push, 3) #include "mss.h" #pragma warning (pop) -#include "Vector.H" +#include "Vector.h" #include "SoundBuffer.h" #include "AudioEvents.h" #include "wwstring.h" @@ -258,7 +253,7 @@ class WWAudioClass // float Get_Effects_Level (void) { return m_EffectsLevel; } - // See ENVIRONMENT_ defines in MSS.H for a list of possible values. + // See ENVIRONMENT_ defines in MSS.h for a list of possible values. int Get_Reverb_Room_Type (void) { return m_ReverbRoomType; } void Set_Reverb_Room_Type (int type); @@ -485,10 +480,10 @@ class WWAudioClass ////////////////////////////////////////////////////////////////////// // Miles File Callbacks ////////////////////////////////////////////////////////////////////// - static U32 AILCALLBACK File_Open_Callback (char const *filename, U32 *file_handle); - static void AILCALLBACK File_Close_Callback (U32 file_handle); - static S32 AILCALLBACK File_Seek_Callback (U32 file_handle, S32 offset, U32 type); - static U32 AILCALLBACK File_Read_Callback (U32 file_handle, void *buffer, U32 bytes); + static U32 AILCALLBACK File_Open_Callback (char const *filename, void **file_handle); + static void AILCALLBACK File_Close_Callback (void *file_handle); + static S32 AILCALLBACK File_Seek_Callback (void *file_handle, S32 offset, U32 type); + static U32 AILCALLBACK File_Read_Callback (void *file_handle, void *buffer, U32 bytes); private: @@ -581,6 +576,3 @@ class WWAudioClass float m_EffectsLevel; int m_ReverbRoomType; }; - - -#endif //__WWAUDIO_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/listenerhandle.h b/Core/Libraries/Source/WWVegas/WWAudio/listenerhandle.h index 634954d8c5..1524b235f3 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/listenerhandle.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/listenerhandle.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __LISTENERHANDLE_H -#define __LISTENERHANDLE_H #include "sound3dhandle.h" @@ -97,6 +92,3 @@ class ListenerHandleClass : public Sound3DHandleClass // Protected member data /////////////////////////////////////////////////////////////////// }; - - -#endif //__LISTENERHANDLE_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/sound2dhandle.cpp b/Core/Libraries/Source/WWVegas/WWAudio/sound2dhandle.cpp index b615a54ee7..9ff5f7ecbb 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/sound2dhandle.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/sound2dhandle.cpp @@ -310,7 +310,7 @@ Sound2DHandleClass::Get_Sample_MS_Position (S32 *len, S32 *pos) // ////////////////////////////////////////////////////////////////////// void -Sound2DHandleClass::Set_Sample_User_Data (S32 i, U32 val) +Sound2DHandleClass::Set_Sample_User_Data (S32 i, void *val) { if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) { ::AIL_set_sample_user_data (SampleHandle, i, val); @@ -325,10 +325,10 @@ Sound2DHandleClass::Set_Sample_User_Data (S32 i, U32 val) // Get_Sample_User_Data // ////////////////////////////////////////////////////////////////////// -U32 +void * Sound2DHandleClass::Get_Sample_User_Data (S32 i) { - U32 retval = 0; + void *retval = NULL; if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) { retval = ::AIL_sample_user_data (SampleHandle, i); diff --git a/Core/Libraries/Source/WWVegas/WWAudio/sound2dhandle.h b/Core/Libraries/Source/WWVegas/WWAudio/sound2dhandle.h index cc6272f678..f76b8100b9 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/sound2dhandle.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/sound2dhandle.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SOUND2DHANDLE_H -#define __SOUND2DHANDLE_H #include "soundhandle.h" @@ -90,8 +85,8 @@ class Sound2DHandleClass : public SoundHandleClass U32 Get_Sample_Loop_Count (void); void Set_Sample_MS_Position (U32 ms); void Get_Sample_MS_Position (S32 *len, S32 *pos); - void Set_Sample_User_Data (S32 i, U32 val); - U32 Get_Sample_User_Data (S32 i); + void Set_Sample_User_Data (S32 i, void *val); + void * Get_Sample_User_Data (S32 i); S32 Get_Sample_Playback_Rate (void); void Set_Sample_Playback_Rate (S32 rate); @@ -102,6 +97,3 @@ class Sound2DHandleClass : public SoundHandleClass /////////////////////////////////////////////////////////////////// HSAMPLE SampleHandle; }; - - -#endif //__SOUND2DHANDLE_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/sound3dhandle.cpp b/Core/Libraries/Source/WWVegas/WWAudio/sound3dhandle.cpp index ee13e10bdc..2e28131523 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/sound3dhandle.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/sound3dhandle.cpp @@ -307,7 +307,7 @@ Sound3DHandleClass::Get_Sample_MS_Position (S32 *len, S32 *pos) // ////////////////////////////////////////////////////////////////////// void -Sound3DHandleClass::Set_Sample_User_Data (S32 i, U32 val) +Sound3DHandleClass::Set_Sample_User_Data (S32 i, void *val) { if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) { ::AIL_set_3D_object_user_data (SampleHandle, i, val); @@ -321,10 +321,10 @@ Sound3DHandleClass::Set_Sample_User_Data (S32 i, U32 val) // Get_Sample_User_Data // ////////////////////////////////////////////////////////////////////// -U32 +void * Sound3DHandleClass::Get_Sample_User_Data (S32 i) { - U32 retval = 0; + void *retval = NULL; if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) { retval = AIL_3D_object_user_data (SampleHandle, i); diff --git a/Core/Libraries/Source/WWVegas/WWAudio/sound3dhandle.h b/Core/Libraries/Source/WWVegas/WWAudio/sound3dhandle.h index b57a3141c2..2040057aa5 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/sound3dhandle.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/sound3dhandle.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SOUND3DHANDLE_H -#define __SOUND3DHANDLE_H #include "soundhandle.h" @@ -91,8 +86,8 @@ class Sound3DHandleClass : public SoundHandleClass U32 Get_Sample_Loop_Count (void); void Set_Sample_MS_Position (U32 ms); void Get_Sample_MS_Position (S32 *len, S32 *pos); - void Set_Sample_User_Data (S32 i, U32 val); - U32 Get_Sample_User_Data (S32 i); + void Set_Sample_User_Data (S32 i, void *val); + void * Get_Sample_User_Data (S32 i); S32 Get_Sample_Playback_Rate (void); void Set_Sample_Playback_Rate (S32 rate); @@ -107,6 +102,3 @@ class Sound3DHandleClass : public SoundHandleClass /////////////////////////////////////////////////////////////////// H3DSAMPLE SampleHandle; }; - - -#endif //__SOUND3DHANDLE_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/soundhandle.h b/Core/Libraries/Source/WWVegas/WWAudio/soundhandle.h index e1a61a2f38..297a9ba2a3 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/soundhandle.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/soundhandle.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SOUNDHANDLE_H -#define __SOUNDHANDLE_H #include "WWAudio.h" @@ -108,8 +103,8 @@ class SoundHandleClass virtual U32 Get_Sample_Loop_Count (void) = 0; virtual void Set_Sample_MS_Position (U32 ms) = 0; virtual void Get_Sample_MS_Position (S32 *len, S32 *pos) = 0; - virtual void Set_Sample_User_Data (S32 i, U32 val) = 0; - virtual U32 Get_Sample_User_Data (S32 i) = 0; + virtual void Set_Sample_User_Data (S32 i, void *val) = 0; + virtual void * Get_Sample_User_Data (S32 i) = 0; virtual S32 Get_Sample_Playback_Rate (void) = 0; virtual void Set_Sample_Playback_Rate (S32 rate) = 0; @@ -124,6 +119,3 @@ class SoundHandleClass /////////////////////////////////////////////////////////////////// SoundBufferClass * Buffer; }; - - -#endif //__SOUNDHANDLE_H diff --git a/Core/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.cpp b/Core/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.cpp index 5fbcb5d558..5bc7ed4e86 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.cpp @@ -305,7 +305,7 @@ SoundStreamHandleClass::Get_Sample_MS_Position (S32 *len, S32 *pos) // ////////////////////////////////////////////////////////////////////// void -SoundStreamHandleClass::Set_Sample_User_Data (S32 i, U32 val) +SoundStreamHandleClass::Set_Sample_User_Data (S32 i, void *val) { if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) { ::AIL_set_sample_user_data (SampleHandle, i, val); @@ -320,10 +320,10 @@ SoundStreamHandleClass::Set_Sample_User_Data (S32 i, U32 val) // Get_Sample_User_Data // ////////////////////////////////////////////////////////////////////// -U32 +void * SoundStreamHandleClass::Get_Sample_User_Data (S32 i) { - U32 retval = 0; + void *retval = NULL; if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) { retval = ::AIL_sample_user_data (SampleHandle, i); diff --git a/Core/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.h b/Core/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.h index c59b5439c3..ee4699df02 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SOUNDSTREAMHANDLE_H -#define __SOUNDSTREAMHANDLE_H - #include "soundhandle.h" @@ -92,8 +86,8 @@ class SoundStreamHandleClass : public SoundHandleClass U32 Get_Sample_Loop_Count (void); void Set_Sample_MS_Position (U32 ms); void Get_Sample_MS_Position (S32 *len, S32 *pos); - void Set_Sample_User_Data (S32 i, U32 val); - U32 Get_Sample_User_Data (S32 i); + void Set_Sample_User_Data (S32 i, void *val); + void * Get_Sample_User_Data (S32 i); S32 Get_Sample_Playback_Rate (void); void Set_Sample_Playback_Rate (S32 rate); @@ -109,6 +103,3 @@ class SoundStreamHandleClass : public SoundHandleClass HSAMPLE SampleHandle; HSTREAM StreamHandle; }; - - -#endif //__SOUNDSTREAMHANDLE_H diff --git a/Core/Libraries/Source/WWVegas/WWDebug/wwdebug.cpp b/Core/Libraries/Source/WWVegas/WWDebug/wwdebug.cpp index 8991b8fc75..e072d8a011 100644 --- a/Core/Libraries/Source/WWVegas/WWDebug/wwdebug.cpp +++ b/Core/Libraries/Source/WWVegas/WWDebug/wwdebug.cpp @@ -46,9 +46,8 @@ //#include "win.h" can use this if allowed to see wwlib #include #include -#include +#include #include -#include #include #include "Except.h" diff --git a/Core/Libraries/Source/WWVegas/WWDebug/wwdebug.h b/Core/Libraries/Source/WWVegas/WWDebug/wwdebug.h index c3a4f51dcd..2db3048d26 100644 --- a/Core/Libraries/Source/WWVegas/WWDebug/wwdebug.h +++ b/Core/Libraries/Source/WWVegas/WWDebug/wwdebug.h @@ -34,26 +34,23 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 - -#ifndef WWDEBUG_H -#define WWDEBUG_H // TheSuperHackers @todo Recover WWDEBUG? #ifdef WWDEBUG #include #endif +#include "../../../../../Core/GameEngine/Include/Common/Debug.h" + // The macro MESSAGE allows user to put: // #pragma MESSAGE("Hello world") // anywhere in a source file. The message: // sourcefname.cpp (123) : Hello world // would be printed if put in sourcefname.cpp on line 123 in compile window like an error. // You can then use next/prev error hot keys to see where comment is. It is not an error and -// will be printed everytime it is compiled. Very useful to put comments in code that cannot -// be forgoten. +// will be printed every time it is compiled. Very useful to put comments in code that cannot +// be forgotten. #define STRING_IT(a) #a #define TOKEN_IT(a) STRING_IT(,##a) #define MESSAGE(a) message (__FILE__ "(" TOKEN_IT(__LINE__) ") : " a) @@ -110,8 +107,6 @@ void WWDebug_DBWin32_Message_Handler( const char * message); ** WWDEBUG_SAY(("dir = %f",dir)); */ -#include "../../../../../Core/GameEngine/Include/Common/Debug.h" - #ifdef DEBUG_LOGGING #define WWDEBUG_SAY(x) DEBUG_LOG(x) #define WWDEBUG_WARNING(x) DEBUG_LOG(x) @@ -177,5 +172,3 @@ void WWDebug_DBWin32_Message_Handler( const char * message); #define WWDEBUG_PROFILE_START(x) #define WWDEBUG_PROFILE_STOP(x) #endif - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWDebug/wwhack.h b/Core/Libraries/Source/WWVegas/WWDebug/wwhack.h index 040d342ebe..97d0b7e695 100644 --- a/Core/Libraries/Source/WWVegas/WWDebug/wwhack.h +++ b/Core/Libraries/Source/WWVegas/WWDebug/wwhack.h @@ -34,17 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 - -#ifndef WWHACK_H -#define WWHACK_H /* ** FORCE_LINK is a hack to force a module in a lib to be linked into the EXE. */ #define FORCE_LINK( module ) void _Force_Link_ ## module( void ); _Force_Link_ ## module() #define DECLARE_FORCE_LINK( module ) void _Force_Link_ ## module( void ) {} - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp b/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp index 684b63eb51..31bd9b3cf5 100644 --- a/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp +++ b/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp @@ -41,7 +41,7 @@ #include "always.h" #include "wwmemlog.h" #include "wwdebug.h" -#include "Vector.H" +#include "Vector.h" #include "FastAllocator.h" #define USE_FAST_ALLOCATOR @@ -95,7 +95,7 @@ static unsigned FreeCount; ** Name for each memory category. I'm padding the array with some "undefined" strings in case ** someone forgets to set the name when adding a new category. */ -static const char * _MemoryCategoryNames[] = +static const char *const _MemoryCategoryNames[] = { "UNKNOWN", "Geometry", @@ -531,6 +531,7 @@ void WWMemoryLogClass::Register_Memory_Released(int category,int size) static void _MemLogCleanup(void) { delete _TheMemLog; + _TheMemLog = NULL; } @@ -578,10 +579,9 @@ MemLogClass * WWMemoryLogClass::Get_Log(void) void WWMemoryLogClass::Release_Log(void) { MemLogMutexLockClass lock; - if (_TheMemLog) { - delete _TheMemLog; - _TheMemLog = NULL; - } + + delete _TheMemLog; + _TheMemLog = NULL; } diff --git a/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.h b/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.h index 18f77b69f6..b994bbe16b 100644 --- a/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.h +++ b/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.h @@ -36,13 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if _MSC_VER >= 1000 #pragma once -#endif - -#ifndef WWMEMLOG_H -#define WWMEMLOG_H #define LOG_MEMORY // Comment this out to disable memlog compiling in @@ -182,10 +176,3 @@ class WWMemorySampleClass #else #define WWMEMLOG( category ) #endif - - - - - - -#endif //WWMEMLOG_H diff --git a/Core/Libraries/Source/WWVegas/WWDebug/wwprofile.cpp b/Core/Libraries/Source/WWVegas/WWDebug/wwprofile.cpp index 839bdb1f22..c02c4e5dd5 100644 --- a/Core/Libraries/Source/WWVegas/WWDebug/wwprofile.cpp +++ b/Core/Libraries/Source/WWVegas/WWDebug/wwprofile.cpp @@ -55,12 +55,11 @@ #include "wwdebug.h" //#include "systimer.h" #include "systimer.h" -#include "RAWFILE.H" +#include "RAWFILE.h" #include "ffactory.h" #include "simplevec.h" #include "cpudetect.h" #include "hashtemplate.h" -#include #include static SimpleDynVecClass ProfileCollectVector; @@ -615,7 +614,6 @@ void WWProfileManager::End_Collecting(const char* filename) for (i=0;i= 1000 #pragma once -#endif // _MSC_VER >= 1000 //#define ENABLE_TIME_AND_MEMORY_LOG - -#ifndef WWPROFILE_H -#define WWPROFILE_H - #include "wwstring.h" #ifdef _UNIX @@ -338,5 +332,3 @@ struct WWMemoryAndTimeLog ~WWMemoryAndTimeLog(); void Log_Intermediate(const char* text); }; - -#endif // WWPROFILE_H diff --git a/Core/Libraries/Source/WWVegas/WWDownload/CMakeLists.txt b/Core/Libraries/Source/WWVegas/WWDownload/CMakeLists.txt index 467d1febf5..ee2966bc91 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/WWDownload/CMakeLists.txt @@ -3,7 +3,7 @@ set(WWDOWNLOAD_SRC Download.h DownloadDebug.h downloaddefs.h - FTP.CPP + FTP.cpp ftp.h ftpdefs.h registry.cpp diff --git a/Core/Libraries/Source/WWVegas/WWDownload/Download.cpp b/Core/Libraries/Source/WWVegas/WWDownload/Download.cpp index 05e5dbb3ed..8f8ab20e21 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/Download.cpp +++ b/Core/Libraries/Source/WWVegas/WWDownload/Download.cpp @@ -19,11 +19,11 @@ // Download.cpp : Implementation of CDownload #include "DownloadDebug.h" #include "Download.h" +#include "stringex.h" #include #include #include #include -#include #include ///////////////////////////////////////////////////////////////////////////// @@ -47,7 +47,7 @@ HRESULT CDownload::DownloadFile(LPCSTR server, LPCSTR username, LPCSTR password, // If we're still connected, make sure we're on the right server if (m_Status == DOWNLOADSTATUS_FINDINGFILE) { - if ((strcmp(m_Server, server)) || (strcmp(m_Login, username))) + if ((strcmp(m_Server, server) != 0) || (strcmp(m_Login, username) != 0)) { // Damn, a server switch. Close conn & fix state m_Ftp->DisconnectFromServer(); @@ -69,15 +69,15 @@ HRESULT CDownload::DownloadFile(LPCSTR server, LPCSTR username, LPCSTR password, _mkdir("download"); // Copy parameters to member variables. - strncpy( m_Server, server, sizeof( m_Server ) ); - strncpy( m_Login, username, sizeof( m_Login ) ); - strncpy( m_Password, password, sizeof( m_Password ) ); - strncpy( m_File, file, sizeof( m_File ) ); - strncpy( m_LocalFile, localfile, sizeof( m_LocalFile ) ); + strlcpy( m_Server, server, sizeof( m_Server ) ); + strlcpy( m_Login, username, sizeof( m_Login ) ); + strlcpy( m_Password, password, sizeof( m_Password ) ); + strlcpy( m_File, file, sizeof( m_File ) ); + strlcpy( m_LocalFile, localfile, sizeof( m_LocalFile ) ); - strncpy( m_LastLocalFile, localfile, sizeof( m_LastLocalFile ) ); + strlcpy( m_LastLocalFile, localfile, sizeof( m_LastLocalFile ) ); - strncpy( m_RegKey, regkey, sizeof( m_RegKey ) ); + strlcpy( m_RegKey, regkey, sizeof( m_RegKey ) ); m_TryResume = tryresume; m_StartPosition=0; @@ -113,8 +113,7 @@ HRESULT CDownload::GetLastLocalFile(char *local_file, int maxlen) { if (local_file==0) return(E_FAIL); - strncpy(local_file, m_LastLocalFile, maxlen); - local_file[maxlen-1]=0; + strlcpy(local_file, m_LastLocalFile, maxlen); return(S_OK); } diff --git a/Core/Libraries/Source/WWVegas/WWDownload/Download.h b/Core/Libraries/Source/WWVegas/WWDownload/Download.h index 389a4abe33..bed1916507 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/Download.h +++ b/Core/Libraries/Source/WWVegas/WWDownload/Download.h @@ -18,8 +18,7 @@ // Download.h : Declaration of the CDownload -#ifndef __DOWNLOAD_H_ -#define __DOWNLOAD_H_ +#pragma once //#include "../resource.h" // main symbols #include "WWDownload/ftp.h" @@ -95,5 +94,3 @@ class CDownload Cftp *m_Ftp; IDownload *Listener; }; - -#endif //__DOWNLOAD_H_ diff --git a/Core/Libraries/Source/WWVegas/WWDownload/DownloadDebug.h b/Core/Libraries/Source/WWVegas/WWDownload/DownloadDebug.h index 7a4d7872fa..4948c19cc6 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/DownloadDebug.h +++ b/Core/Libraries/Source/WWVegas/WWDownload/DownloadDebug.h @@ -18,9 +18,6 @@ // DownloadDebug.h -#ifndef __DOWNLOADDEBUG_H_ -#define __DOWNLOADDEBUG_H_ +#pragma once #include "Common/Debug.h" - -#endif //__DOWNLOADDEBUG_H_ diff --git a/Core/Libraries/Source/WWVegas/WWDownload/FTP.CPP b/Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp similarity index 98% rename from Core/Libraries/Source/WWVegas/WWDownload/FTP.CPP rename to Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp index f4e807c5bd..01e67957ea 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/FTP.CPP +++ b/Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp @@ -23,7 +23,6 @@ /*************************************************************************/ -#include #include #include #include @@ -36,6 +35,7 @@ #include #include #include +#include //#include "wlib/wstring.h" #include "DownloadDebug.h" @@ -140,7 +140,7 @@ static bool Use_Non_Blocking_Mode(void) if ((regRetval!=ERROR_SUCCESS) || (type != REG_DWORD)) return(TRUE); - return(bool(value)); + return bool(value); } @@ -324,7 +324,7 @@ HRESULT Cftp::ConnectToServer(LPCSTR szServerName) char buffer[ 256 ]; int iReply, error; - strncpy( m_szServerName, szServerName, 128 ); + strlcpy( m_szServerName, szServerName, sizeof(m_szServerName)); if( m_iStatus == FTPSTAT_INIT ) { @@ -487,8 +487,8 @@ HRESULT Cftp::LoginToServer( LPCSTR szUserName, LPCSTR szPassword ) char command[ 256 ]; int iReply; - strncpy( m_szUserName, szUserName, 128 ); - strncpy( m_szPassword, szPassword, 128 ); + strlcpy( m_szUserName, szUserName, sizeof(m_szUserName)); + strlcpy( m_szPassword, szPassword, sizeof(m_szPassword)); memset( command, 0, 256 ); @@ -678,7 +678,7 @@ HRESULT Cftp::FindFile( LPCSTR szRemoteFileName, int * piSize ) _splitpath( szRemoteFileName, NULL, m_szRemoteFilePath+strlen(m_szRemoteFilePath), m_szRemoteFileName, ext ); - strcat( m_szRemoteFileName, ext ); + strlcat(m_szRemoteFileName, ext, ARRAY_SIZE(m_szRemoteFileName)); for( i = 0; i < (int)strlen( m_szRemoteFilePath ); i++ ) { @@ -1396,7 +1396,7 @@ HRESULT Cftp::GetNextFileBlock( LPCSTR szLocalFileName, int * piTotalRead ) //char str[ 256 ]; - strncpy( m_szLocalFileName, szLocalFileName, 256 ); + strlcpy( m_szLocalFileName, szLocalFileName, sizeof(m_szLocalFileName)); // Open local file @@ -1719,14 +1719,14 @@ HRESULT Cftp::FileRecoveryPosition( LPCSTR szLocalFileName, LPCSTR szRegistryRo // Concatenate the registry key together - strcpy( regkey, szRegistryRoot ); + strlcpy(regkey, szRegistryRoot, ARRAY_SIZE(regkey)); if( regkey[ strlen( regkey ) - 1 ] != '\\' ) { - strcat( regkey, "\\Download" ); + strlcat(regkey, "\\Download", ARRAY_SIZE(regkey)); } else { - strcat( regkey, "Download" ); + strlcat(regkey, "Download", ARRAY_SIZE(regkey)); } if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, (LPCTSTR)regkey, @@ -1830,8 +1830,7 @@ bool Prepare_Directories(const char *rootdir, const char *filename) const char *cptr=filename; while(cptr=strchr(cptr,'\\')) { - memset(tempstr,0,256); - strncpy(tempstr,filename,cptr-filename); + strlcpy(tempstr,filename,cptr-filename + 1); sprintf(newdir,"%s\\%s",rootdir, tempstr); if (!CreateDirectory(newdir, NULL)) return false; diff --git a/Core/Libraries/Source/WWVegas/WWDownload/Registry.h b/Core/Libraries/Source/WWVegas/WWDownload/Registry.h index 846fad6912..527e9adfde 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/Registry.h +++ b/Core/Libraries/Source/WWVegas/WWDownload/Registry.h @@ -22,9 +22,6 @@ #pragma once -#ifndef __WWDOWNLOAD_REGISTRY_H__ -#define __WWDOWNLOAD_REGISTRY_H__ - #include /** @@ -46,5 +43,3 @@ bool SetStringInRegistry(std::string path, std::string key, std::string val); * Store an unsigned int in the registry - returns true on success */ bool SetUnsignedIntInRegistry(std::string path, std::string key, unsigned int val); - -#endif // __WWDOWNLOAD_REGISTRY_H__ diff --git a/Core/Libraries/Source/WWVegas/WWDownload/downloaddefs.h b/Core/Libraries/Source/WWVegas/WWDownload/downloaddefs.h index b7fbb15daf..d8d94d308a 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/downloaddefs.h +++ b/Core/Libraries/Source/WWVegas/WWDownload/downloaddefs.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef _DOWNLOADDEFS_H -#define _DOWNLOADDEFS_H +#pragma once // CDownload statuses @@ -57,5 +56,3 @@ #define DOWNLOADEVENT_LOCALFILEOPENFAILED 5 #define DOWNLOADEVENT_TCPERROR 6 #define DOWNLOADEVENT_DISCONNECTERROR 7 - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWDownload/ftp.h b/Core/Libraries/Source/WWVegas/WWDownload/ftp.h index e12a1934b1..08c5918ab4 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/ftp.h +++ b/Core/Libraries/Source/WWVegas/WWDownload/ftp.h @@ -18,14 +18,12 @@ // ftp.h : Declaration of the Cftp -#ifndef __FTP_H_ -#define __FTP_H_ - +#pragma once //#include "../resource.h" // main symbols #include "winsock.h" -#include "stdio.h" +#include #include "WWDownload/ftpdefs.h" @@ -113,5 +111,3 @@ class Cftp HRESULT SendCommand( LPCSTR pCommand, int iSize ); }; - -#endif //__FTP_H_ diff --git a/Core/Libraries/Source/WWVegas/WWDownload/ftpdefs.h b/Core/Libraries/Source/WWVegas/WWDownload/ftpdefs.h index 35fa5b6a87..1306a38ecb 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/ftpdefs.h +++ b/Core/Libraries/Source/WWVegas/WWDownload/ftpdefs.h @@ -16,15 +16,10 @@ ** along with this program. If not, see . */ -#ifndef __FTPDEFS_H_INCLUDED__ -#define __FTPDEFS_H_INCLUDED__ - +#pragma once // CFtp return codes. #define FTP_SUCCEEDED S_OK #define FTP_FAILED MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 1 ) #define FTP_TRYING MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 2 ) - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWDownload/urlBuilder.h b/Core/Libraries/Source/WWVegas/WWDownload/urlBuilder.h index e802713f64..2d5ae532dd 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/urlBuilder.h +++ b/Core/Libraries/Source/WWVegas/WWDownload/urlBuilder.h @@ -16,9 +16,7 @@ ** along with this program. If not, see . */ -#ifndef _URLBUILDER_H_ -#define _URLBUILDER_H_ +#pragma once + void FormatURLFromRegistry( std::string& gamePatchURL, std::string& mapPatchURL, std::string& configURL, std::string& motdURL ); - -#endif // _URLBUILDER_H_ diff --git a/Core/Libraries/Source/WWVegas/WWLib/BSEARCH.H b/Core/Libraries/Source/WWVegas/WWLib/BSEARCH.h similarity index 95% rename from Core/Libraries/Source/WWVegas/WWLib/BSEARCH.H rename to Core/Libraries/Source/WWVegas/WWLib/BSEARCH.h index cb92bde071..aed9a03a44 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/BSEARCH.H +++ b/Core/Libraries/Source/WWVegas/WWLib/BSEARCH.h @@ -16,14 +16,7 @@ ** along with this program. If not, see . */ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 - -#ifndef BSEARCH_H -#define BSEARCH_H - /* ** Binary searching template. It can be faster than the built in C library @@ -73,6 +66,3 @@ T * Binary_Search(T * A, int n, T const & target) } return (NULL); } - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/BUFF.H b/Core/Libraries/Source/WWVegas/WWLib/BUFF.h similarity index 95% rename from Core/Libraries/Source/WWVegas/WWLib/BUFF.H rename to Core/Libraries/Source/WWVegas/WWLib/BUFF.h index 6c67388093..ad8bb6c5ec 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/BUFF.H +++ b/Core/Libraries/Source/WWVegas/WWLib/BUFF.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /G/wwlib/BUFF.H $* + * $Archive:: /G/wwlib/BUFF.h $* * * * $Author:: Eric_c $* * * @@ -33,13 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef CCBUFF_H -#define CCBUFF_H +#pragma once /* ** The "bool" integral type was defined by the C++ committee in @@ -90,6 +85,3 @@ class Buffer { */ bool IsAllocated; }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt b/Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt index 4198e37e32..997a6c0242 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt @@ -13,9 +13,9 @@ set(WWLIB_SRC binheap.h bittype.h bound.h - BSEARCH.H + BSEARCH.h buff.cpp - BUFF.H + BUFF.h bufffile.cpp bufffile.h CallbackHook.h @@ -25,13 +25,18 @@ set(WWLIB_SRC cpudetect.h #crandom.h crc.cpp - CRC.H + CRC.h #crcpipe.cpp #crcpipe.h #crcstraw.cpp #crcstraw.h cstraw.cpp cstraw.h + DbgHelpGuard.cpp + DbgHelpGuard.h + DbgHelpLoader.cpp + DbgHelpLoader.h + DbgHelpLoader_minidump.h Except.cpp Except.h FastAllocator.cpp @@ -44,17 +49,17 @@ set(WWLIB_SRC hash.cpp hash.h hashcalc.h - HASHLIST.H + HASHLIST.h #hashtab.h hashtemplate.h #incdec.h - INDEX.H + INDEX.h ini.cpp - INI.H + INI.h inisup.h iostruct.h jshell.cpp - LISTNODE.H + LISTNODE.h #lzo.cpp #lzo.h #lzo1x.h @@ -80,14 +85,14 @@ set(WWLIB_SRC nstrdup.h ntree.h pipe.cpp - PIPE.H + PIPE.h Point.h ramfile.cpp - RAMFILE.H + RAMFILE.h random.cpp - RANDOM.H + RANDOM.h rawfile.cpp - RAWFILE.H + RAWFILE.h readline.cpp readline.h realcrc.cpp @@ -101,20 +106,23 @@ set(WWLIB_SRC sharebuf.h Signaler.h simplevec.h - SLIST.H + SLIST.h slnode.cpp - SLNODE.H + SLNODE.h stimer.cpp stimer.h + STLUtils.h straw.cpp - STRAW.H + STRAW.h + stringex.h strtok_r.cpp strtok_r.h #swap.h + SystemAllocator.h systimer.cpp systimer.h - TARGA.CPP - TARGA.H + TARGA.cpp + TARGA.h textfile.cpp textfile.h tgatodxt.cpp @@ -126,26 +134,27 @@ set(WWLIB_SRC trim.h uarray.h vector.cpp - Vector.H + Vector.h visualc.h widestring.cpp widestring.h win.h WWCommon.h + WWDefines.h wwfile.cpp - WWFILE.H + WWFILE.h wwstring.cpp wwstring.h xpipe.cpp - XPIPE.H + XPIPE.h xstraw.cpp - XSTRAW.H + XSTRAW.h ) if(WIN32) list(APPEND WWLIB_SRC mpu.cpp - MPU.H + MPU.h rcfile.cpp rcfile.h registry.cpp @@ -166,6 +175,15 @@ target_include_directories(core_wwlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ) +target_precompile_headers(core_wwlib PRIVATE + always.h + STLUtils.h + win.h + WWCommon.h + wwstring.h + +) + target_link_libraries(core_wwlib PRIVATE core_wwcommon corei_always diff --git a/Core/Libraries/Source/WWVegas/WWLib/CRC.H b/Core/Libraries/Source/WWVegas/WWLib/CRC.h similarity index 98% rename from Core/Libraries/Source/WWVegas/WWLib/CRC.H rename to Core/Libraries/Source/WWVegas/WWLib/CRC.h index b0fe478714..e042b3d1e9 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/CRC.H +++ b/Core/Libraries/Source/WWVegas/WWLib/CRC.h @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef CRC_H -#define CRC_H +#pragma once #include @@ -129,6 +125,3 @@ class CRC { // get the CRC of a null-terminated string static unsigned long String( const char *string, unsigned long crc = 0 ); }; - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWLib/CallbackHook.h b/Core/Libraries/Source/WWVegas/WWLib/CallbackHook.h index 45edb97b2e..23a26db662 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/CallbackHook.h +++ b/Core/Libraries/Source/WWVegas/WWLib/CallbackHook.h @@ -33,8 +33,7 @@ * ******************************************************************************/ -#ifndef __CALLBACKHOOK_H__ -#define __CALLBACKHOOK_H__ +#pragma once class CallbackHook { @@ -80,5 +79,3 @@ template class Callback : bool (*mCallback)(T); T mUserData; }; - -#endif // __CALLBACKHOOK_H__ diff --git a/Core/Libraries/Source/WWVegas/WWLib/DbgHelpGuard.cpp b/Core/Libraries/Source/WWVegas/WWLib/DbgHelpGuard.cpp new file mode 100644 index 0000000000..2742a5cf5f --- /dev/null +++ b/Core/Libraries/Source/WWVegas/WWLib/DbgHelpGuard.cpp @@ -0,0 +1,49 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#include "DbgHelpGuard.h" + +#include "DbgHelpLoader.h" + + +DbgHelpGuard::DbgHelpGuard() + : m_needsUnload(false) +{ + activate(); +} + +DbgHelpGuard::~DbgHelpGuard() +{ + deactivate(); +} + +void DbgHelpGuard::activate() +{ + // Front load the DLL now to prevent other code from loading the potentially wrong DLL. + DbgHelpLoader::load(); + m_needsUnload = true; +} + +void DbgHelpGuard::deactivate() +{ + if (m_needsUnload) + { + DbgHelpLoader::unload(); + m_needsUnload = false; + } +} diff --git a/Core/Libraries/Source/WWVegas/WWLib/DbgHelpGuard.h b/Core/Libraries/Source/WWVegas/WWLib/DbgHelpGuard.h new file mode 100644 index 0000000000..c4ff06b280 --- /dev/null +++ b/Core/Libraries/Source/WWVegas/WWLib/DbgHelpGuard.h @@ -0,0 +1,44 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#pragma once + +#include "always.h" + + +// This class temporarily loads and unloads dbghelp.dll from the desired location to prevent +// other code from potentially loading it from an undesired location. +// This helps avoid crashing on boot using recent AMD/ATI drivers, which attempt to load and use +// dbghelp.dll from the game install directory but are unable to do so without crashing because +// the dbghelp.dll that ships with the game is very old and the AMD/ATI code does not handle +// that correctly. + +class DbgHelpGuard +{ +public: + + DbgHelpGuard(); + ~DbgHelpGuard(); + + void activate(); + void deactivate(); + +private: + + bool m_needsUnload; +}; diff --git a/Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.cpp b/Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.cpp new file mode 100644 index 0000000000..368bcd03ca --- /dev/null +++ b/Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.cpp @@ -0,0 +1,362 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#include "DbgHelpLoader.h" + + +DbgHelpLoader* DbgHelpLoader::Inst = NULL; +CriticalSectionClass DbgHelpLoader::CriticalSection; + +DbgHelpLoader::DbgHelpLoader() + : m_symInitialize(NULL) + , m_symCleanup(NULL) + , m_symLoadModule(NULL) + , m_symUnloadModule(NULL) + , m_symGetModuleBase(NULL) + , m_symGetSymFromAddr(NULL) + , m_symGetLineFromAddr(NULL) + , m_symSetOptions(NULL) + , m_symFunctionTableAccess(NULL) + , m_stackWalk(NULL) +#ifdef RTS_ENABLE_CRASHDUMP + , m_miniDumpWriteDump(NULL) +#endif + , m_dllModule(HMODULE(0)) + , m_referenceCount(0) + , m_failed(false) + , m_loadedFromSystem(false) +{ +} + +DbgHelpLoader::~DbgHelpLoader() +{ +} + +bool DbgHelpLoader::isLoaded() +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + return Inst != NULL && Inst->m_dllModule != HMODULE(0); +} + +bool DbgHelpLoader::isLoadedFromSystem() +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + return isLoaded() && Inst->m_loadedFromSystem; +} + +bool DbgHelpLoader::isFailed() +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + return Inst != NULL && Inst->m_failed; +} + +bool DbgHelpLoader::load() +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + if (Inst == NULL) + { + // Cannot use new/delete here when this is loaded during game memory initialization. + void* p = GlobalAlloc(GMEM_FIXED, sizeof(DbgHelpLoader)); + Inst = new (p) DbgHelpLoader(); + } + + // Always increment the reference count. + ++Inst->m_referenceCount; + + // Optimization: return early if it failed before. + if (Inst->m_failed) + return false; + + // Return early if someone else already loaded it. + if (Inst->m_referenceCount > 1) + return true; + + // Try load dbghelp.dll from the system directory first. + char dllFilename[MAX_PATH]; + ::GetSystemDirectoryA(dllFilename, ARRAY_SIZE(dllFilename)); + strlcat(dllFilename, "\\dbghelp.dll", ARRAY_SIZE(dllFilename)); + + Inst->m_dllModule = ::LoadLibraryA(dllFilename); + if (Inst->m_dllModule == HMODULE(0)) + { + // Not found. Try load dbghelp.dll from the work directory. + Inst->m_dllModule = ::LoadLibraryA("dbghelp.dll"); + if (Inst->m_dllModule == HMODULE(0)) + { + Inst->m_failed = true; + return false; + } + } + else + { + Inst->m_loadedFromSystem = true; + } + + Inst->m_symInitialize = reinterpret_cast(::GetProcAddress(Inst->m_dllModule, "SymInitialize")); + Inst->m_symCleanup = reinterpret_cast(::GetProcAddress(Inst->m_dllModule, "SymCleanup")); + Inst->m_symLoadModule = reinterpret_cast(::GetProcAddress(Inst->m_dllModule, "SymLoadModule")); + Inst->m_symUnloadModule = reinterpret_cast(::GetProcAddress(Inst->m_dllModule, "SymUnloadModule")); + Inst->m_symGetModuleBase = reinterpret_cast(::GetProcAddress(Inst->m_dllModule, "SymGetModuleBase")); + Inst->m_symGetSymFromAddr = reinterpret_cast(::GetProcAddress(Inst->m_dllModule, "SymGetSymFromAddr")); + Inst->m_symGetLineFromAddr = reinterpret_cast(::GetProcAddress(Inst->m_dllModule, "SymGetLineFromAddr")); + Inst->m_symSetOptions = reinterpret_cast(::GetProcAddress(Inst->m_dllModule, "SymSetOptions")); + Inst->m_symFunctionTableAccess = reinterpret_cast(::GetProcAddress(Inst->m_dllModule, "SymFunctionTableAccess")); + Inst->m_stackWalk = reinterpret_cast(::GetProcAddress(Inst->m_dllModule, "StackWalk")); +#ifdef RTS_ENABLE_CRASHDUMP + Inst->m_miniDumpWriteDump = reinterpret_cast(::GetProcAddress(Inst->m_dllModule, "MiniDumpWriteDump")); +#endif + + if (Inst->m_symInitialize == NULL || Inst->m_symCleanup == NULL) + { + freeResources(); + Inst->m_failed = true; + return false; + } + + return true; +} + +void DbgHelpLoader::unload() +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + if (Inst == NULL) + return; + + if (--Inst->m_referenceCount != 0) + return; + + freeResources(); + + Inst->~DbgHelpLoader(); + GlobalFree(Inst); + Inst = NULL; +} + +void DbgHelpLoader::freeResources() +{ + // Is private. Needs no locking. + + while (!Inst->m_initializedProcesses.empty()) + { + symCleanup(*Inst->m_initializedProcesses.begin()); + } + + if (Inst->m_dllModule != HMODULE(0)) + { + ::FreeLibrary(Inst->m_dllModule); + Inst->m_dllModule = HMODULE(0); + } + + Inst->m_symInitialize = NULL; + Inst->m_symCleanup = NULL; + Inst->m_symLoadModule = NULL; + Inst->m_symUnloadModule = NULL; + Inst->m_symGetModuleBase = NULL; + Inst->m_symGetSymFromAddr = NULL; + Inst->m_symGetLineFromAddr = NULL; + Inst->m_symSetOptions = NULL; + Inst->m_symFunctionTableAccess = NULL; + Inst->m_stackWalk = NULL; +#ifdef RTS_ENABLE_CRASHDUMP + Inst->m_miniDumpWriteDump = NULL; +#endif + + Inst->m_loadedFromSystem = false; +} + +BOOL DbgHelpLoader::symInitialize( + HANDLE hProcess, + LPSTR UserSearchPath, + BOOL fInvadeProcess) +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + if (Inst == NULL) + return FALSE; + + if (Inst->m_initializedProcesses.find(hProcess) != Inst->m_initializedProcesses.end()) + { + // Was already initialized. + return TRUE; + } + + if (Inst->m_symInitialize) + { + if (Inst->m_symInitialize(hProcess, UserSearchPath, fInvadeProcess) != FALSE) + { + // Is now initialized. + Inst->m_initializedProcesses.insert(hProcess); + return TRUE; + } + } + + return FALSE; +} + +BOOL DbgHelpLoader::symCleanup( + HANDLE hProcess) +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + if (Inst == NULL) + return FALSE; + + if (stl::find_and_erase(Inst->m_initializedProcesses, hProcess)) + { + if (Inst->m_symCleanup) + { + return Inst->m_symCleanup(hProcess); + } + } + + return FALSE; +} + +BOOL DbgHelpLoader::symLoadModule( + HANDLE hProcess, + HANDLE hFile, + LPSTR ImageName, + LPSTR ModuleName, + DWORD BaseOfDll, + DWORD SizeOfDll) +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + if (Inst != NULL && Inst->m_symLoadModule) + return Inst->m_symLoadModule(hProcess, hFile, ImageName, ModuleName, BaseOfDll, SizeOfDll); + + return FALSE; +} + +DWORD DbgHelpLoader::symGetModuleBase( + HANDLE hProcess, + DWORD dwAddr) +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + if (Inst != NULL && Inst->m_symGetModuleBase) + return Inst->m_symGetModuleBase(hProcess, dwAddr); + + return 0u; +} + +BOOL DbgHelpLoader::symUnloadModule( + HANDLE hProcess, + DWORD BaseOfDll) +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + if (Inst != NULL && Inst->m_symUnloadModule) + return Inst->m_symUnloadModule(hProcess, BaseOfDll); + + return FALSE; +} + +BOOL DbgHelpLoader::symGetSymFromAddr( + HANDLE hProcess, + DWORD Address, + LPDWORD Displacement, + PIMAGEHLP_SYMBOL Symbol) +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + if (Inst != NULL && Inst->m_symGetSymFromAddr) + return Inst->m_symGetSymFromAddr(hProcess, Address, Displacement, Symbol); + + return FALSE; +} + +BOOL DbgHelpLoader::symGetLineFromAddr( + HANDLE hProcess, + DWORD dwAddr, + PDWORD pdwDisplacement, + PIMAGEHLP_LINE Line) +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + if (Inst != NULL && Inst->m_symGetLineFromAddr) + return Inst->m_symGetLineFromAddr(hProcess, dwAddr, pdwDisplacement, Line); + + return FALSE; +} + +DWORD DbgHelpLoader::symSetOptions( + DWORD SymOptions) +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + if (Inst != NULL && Inst->m_symSetOptions) + return Inst->m_symSetOptions(SymOptions); + + return 0u; +} + +LPVOID DbgHelpLoader::symFunctionTableAccess( + HANDLE hProcess, + DWORD AddrBase) +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + if (Inst != NULL && Inst->m_symFunctionTableAccess) + return Inst->m_symFunctionTableAccess(hProcess, AddrBase); + + return NULL; +} + +BOOL DbgHelpLoader::stackWalk( + DWORD MachineType, + HANDLE hProcess, + HANDLE hThread, + LPSTACKFRAME StackFrame, + LPVOID ContextRecord, + PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine, + PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine, + PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine, + PTRANSLATE_ADDRESS_ROUTINE TranslateAddress) +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + if (Inst != NULL && Inst->m_stackWalk) + return Inst->m_stackWalk(MachineType, hProcess, hThread, StackFrame, ContextRecord, ReadMemoryRoutine, FunctionTableAccessRoutine, GetModuleBaseRoutine, TranslateAddress); + + return FALSE; +} + +#ifdef RTS_ENABLE_CRASHDUMP +BOOL DbgHelpLoader::miniDumpWriteDump( + HANDLE hProcess, + DWORD ProcessId, + HANDLE hFile, + MINIDUMP_TYPE DumpType, + PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, + PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, + PMINIDUMP_CALLBACK_INFORMATION CallbackParam) +{ + CriticalSectionClass::LockClass lock(CriticalSection); + + if (Inst != NULL && Inst->m_miniDumpWriteDump) + return Inst->m_miniDumpWriteDump(hProcess, ProcessId, hFile, DumpType, ExceptionParam, UserStreamParam, CallbackParam); + + return FALSE; +} +#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.h b/Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.h new file mode 100644 index 0000000000..3dda58f206 --- /dev/null +++ b/Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.h @@ -0,0 +1,216 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#pragma once + +#include "always.h" + +#include +#include // Must be included after Windows.h +#include +#ifdef RTS_ENABLE_CRASHDUMP +#include +#endif + +#include "mutex.h" +#include "SystemAllocator.h" + +// This static class can load, unload and use dbghelp.dll. Is thread-safe. +// Internally it must not use new and delete because it can be created during game memory initialization. + +class DbgHelpLoader +{ +private: + + static DbgHelpLoader* Inst; // Is singleton class + static CriticalSectionClass CriticalSection; // Required because dbg help is not thread safe for the most part + + DbgHelpLoader(); + ~DbgHelpLoader(); + +public: + + // Returns whether dbghelp.dll is loaded + static bool isLoaded(); + + // Returns whether dbghelp.dll is loaded from the system directory + static bool isLoadedFromSystem(); + + // Returns whether dbghelp.dll was attempted to be loaded but failed + static bool isFailed(); + + // Every call to load needs a paired call to unload, no matter if the load was successful + static bool load(); + static void unload(); + + static BOOL WINAPI symInitialize( + HANDLE hProcess, + LPSTR UserSearchPath, + BOOL fInvadeProcess); + + static BOOL WINAPI symCleanup( + HANDLE hProcess); + + static BOOL WINAPI symLoadModule( + HANDLE hProcess, + HANDLE hFile, + LPSTR ImageName, + LPSTR ModuleName, + DWORD BaseOfDll, + DWORD SizeOfDll); + + static DWORD WINAPI symGetModuleBase( + HANDLE hProcess, + DWORD dwAddr); + + static BOOL WINAPI symUnloadModule( + HANDLE hProcess, + DWORD BaseOfDll); + + static BOOL WINAPI symGetSymFromAddr( + HANDLE hProcess, + DWORD Address, + LPDWORD Displacement, + PIMAGEHLP_SYMBOL Symbol); + + static BOOL WINAPI symGetLineFromAddr( + HANDLE hProcess, + DWORD dwAddr, + PDWORD pdwDisplacement, + PIMAGEHLP_LINE Line); + + static DWORD WINAPI symSetOptions( + DWORD SymOptions); + + static LPVOID WINAPI symFunctionTableAccess( + HANDLE hProcess, + DWORD AddrBase); + + static BOOL WINAPI stackWalk( + DWORD MachineType, + HANDLE hProcess, + HANDLE hThread, + LPSTACKFRAME StackFrame, + LPVOID ContextRecord, + PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine, + PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine, + PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine, + PTRANSLATE_ADDRESS_ROUTINE TranslateAddress); + +#ifdef RTS_ENABLE_CRASHDUMP + static BOOL WINAPI miniDumpWriteDump( + HANDLE hProcess, + DWORD ProcessId, + HANDLE hFile, + MINIDUMP_TYPE DumpType, + PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, + PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, + PMINIDUMP_CALLBACK_INFORMATION CallbackParam); +#endif + +private: + + static void freeResources(); + + typedef BOOL (WINAPI *SymInitialize_t) ( + HANDLE hProcess, + LPSTR UserSearchPath, + BOOL fInvadeProcess); + + typedef BOOL (WINAPI *SymCleanup_t) ( + HANDLE hProcess); + + typedef BOOL (WINAPI *SymLoadModule_t) ( + HANDLE hProcess, + HANDLE hFile, + LPSTR ImageName, + LPSTR ModuleName, + DWORD BaseOfDll, + DWORD SizeOfDll); + + typedef DWORD (WINAPI *SymGetModuleBase_t) ( + HANDLE hProcess, + DWORD dwAddr); + + typedef BOOL (WINAPI *SymUnloadModule_t) ( + HANDLE hProcess, + DWORD BaseOfDll); + + typedef BOOL (WINAPI *SymGetSymFromAddr_t) ( + HANDLE hProcess, + DWORD Address, + LPDWORD Displacement, + PIMAGEHLP_SYMBOL Symbol); + + typedef BOOL (WINAPI* SymGetLineFromAddr_t) ( + HANDLE hProcess, + DWORD dwAddr, + PDWORD pdwDisplacement, + PIMAGEHLP_LINE Line); + + typedef DWORD (WINAPI *SymSetOptions_t) ( + DWORD SymOptions); + + typedef LPVOID (WINAPI *SymFunctionTableAccess_t) ( + HANDLE hProcess, + DWORD AddrBase); + + typedef BOOL (WINAPI *StackWalk_t) ( + DWORD MachineType, + HANDLE hProcess, + HANDLE hThread, + LPSTACKFRAME StackFrame, + LPVOID ContextRecord, + PREAD_PROCESS_MEMORY_ROUTINE ReadMemoryRoutine, + PFUNCTION_TABLE_ACCESS_ROUTINE FunctionTableAccessRoutine, + PGET_MODULE_BASE_ROUTINE GetModuleBaseRoutine, + PTRANSLATE_ADDRESS_ROUTINE TranslateAddress); + +#ifdef RTS_ENABLE_CRASHDUMP + typedef BOOL(WINAPI* MiniDumpWriteDump_t)( + HANDLE hProcess, + DWORD ProcessId, + HANDLE hFile, + MINIDUMP_TYPE DumpType, + PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, + PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, + PMINIDUMP_CALLBACK_INFORMATION CallbackParam); +#endif + + SymInitialize_t m_symInitialize; + SymCleanup_t m_symCleanup; + SymLoadModule_t m_symLoadModule; + SymUnloadModule_t m_symUnloadModule; + SymGetModuleBase_t m_symGetModuleBase; + SymGetSymFromAddr_t m_symGetSymFromAddr; + SymGetLineFromAddr_t m_symGetLineFromAddr; + SymSetOptions_t m_symSetOptions; + SymFunctionTableAccess_t m_symFunctionTableAccess; + StackWalk_t m_stackWalk; +#ifdef RTS_ENABLE_CRASHDUMP + MiniDumpWriteDump_t m_miniDumpWriteDump; +#endif + + typedef std::set, stl::system_allocator > Processes; + + Processes m_initializedProcesses; + HMODULE m_dllModule; + int m_referenceCount; + bool m_failed; + bool m_loadedFromSystem; +}; diff --git a/Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader_minidump.h b/Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader_minidump.h new file mode 100644 index 0000000000..272fa832f5 --- /dev/null +++ b/Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader_minidump.h @@ -0,0 +1,265 @@ +#pragma once + +#ifdef RTS_ENABLE_CRASHDUMP + +// Backported defines from minidumpapiset.h for VC6. +// minidumpapiset.h is Copyright (C) Microsoft Corporation. All rights reserved. + +#if defined(_MSC_VER) && _MSC_VER < 1300 +#include + +typedef enum _MINIDUMP_CALLBACK_TYPE { + ModuleCallback, + ThreadCallback, + ThreadExCallback, + IncludeThreadCallback, + IncludeModuleCallback, + MemoryCallback, + CancelCallback, + WriteKernelMinidumpCallback, + KernelMinidumpStatusCallback, + RemoveMemoryCallback, + IncludeVmRegionCallback, + IoStartCallback, + IoWriteAllCallback, + IoFinishCallback, + ReadMemoryFailureCallback, + SecondaryFlagsCallback, + IsProcessSnapshotCallback, + VmStartCallback, + VmQueryCallback, + VmPreReadCallback, + VmPostReadCallback +} MINIDUMP_CALLBACK_TYPE; + +typedef struct _MINIDUMP_THREAD_CALLBACK { + ULONG ThreadId; + HANDLE ThreadHandle; +#if defined(_ARM64_) + ULONG Pad; +#endif + CONTEXT Context; + ULONG SizeOfContext; + ULONG64 StackBase; + ULONG64 StackEnd; +} MINIDUMP_THREAD_CALLBACK, * PMINIDUMP_THREAD_CALLBACK; + +typedef struct _MINIDUMP_THREAD_EX_CALLBACK { + ULONG ThreadId; + HANDLE ThreadHandle; +#if defined(_ARM64_) + ULONG Pad; +#endif + CONTEXT Context; + ULONG SizeOfContext; + ULONG64 StackBase; + ULONG64 StackEnd; + ULONG64 BackingStoreBase; + ULONG64 BackingStoreEnd; +} MINIDUMP_THREAD_EX_CALLBACK, * PMINIDUMP_THREAD_EX_CALLBACK; + +typedef struct _MINIDUMP_MODULE_CALLBACK { + PWCHAR FullPath; + ULONG64 BaseOfImage; + ULONG SizeOfImage; + ULONG CheckSum; + ULONG TimeDateStamp; + VS_FIXEDFILEINFO VersionInfo; + PVOID CvRecord; + ULONG SizeOfCvRecord; + PVOID MiscRecord; + ULONG SizeOfMiscRecord; +} MINIDUMP_MODULE_CALLBACK, * PMINIDUMP_MODULE_CALLBACK; + +typedef struct _MINIDUMP_INCLUDE_THREAD_CALLBACK { + ULONG ThreadId; +} MINIDUMP_INCLUDE_THREAD_CALLBACK, * PMINIDUMP_INCLUDE_THREAD_CALLBACK; + +typedef enum _THREAD_WRITE_FLAGS { + ThreadWriteThread = 0x0001, + ThreadWriteStack = 0x0002, + ThreadWriteContext = 0x0004, + ThreadWriteBackingStore = 0x0008, + ThreadWriteInstructionWindow = 0x0010, + ThreadWriteThreadData = 0x0020, + ThreadWriteThreadInfo = 0x0040, +} THREAD_WRITE_FLAGS; + +typedef struct _MINIDUMP_INCLUDE_MODULE_CALLBACK { + ULONG64 BaseOfImage; +} MINIDUMP_INCLUDE_MODULE_CALLBACK, * PMINIDUMP_INCLUDE_MODULE_CALLBACK; + +typedef struct _MINIDUMP_IO_CALLBACK { + HANDLE Handle; + ULONG64 Offset; + PVOID Buffer; + ULONG BufferBytes; +} MINIDUMP_IO_CALLBACK, * PMINIDUMP_IO_CALLBACK; + +typedef struct _MINIDUMP_READ_MEMORY_FAILURE_CALLBACK +{ + ULONG64 Offset; + ULONG Bytes; + HRESULT FailureStatus; +} MINIDUMP_READ_MEMORY_FAILURE_CALLBACK, +* PMINIDUMP_READ_MEMORY_FAILURE_CALLBACK; + +typedef struct _MINIDUMP_VM_QUERY_CALLBACK +{ + ULONG64 Offset; +} MINIDUMP_VM_QUERY_CALLBACK, * PMINIDUMP_VM_QUERY_CALLBACK; + +typedef struct _MINIDUMP_VM_PRE_READ_CALLBACK +{ + ULONG64 Offset; + PVOID Buffer; + ULONG Size; +} MINIDUMP_VM_PRE_READ_CALLBACK, * PMINIDUMP_VM_PRE_READ_CALLBACK; + +typedef struct _MINIDUMP_VM_POST_READ_CALLBACK +{ + ULONG64 Offset; + PVOID Buffer; + ULONG Size; + ULONG Completed; + HRESULT Status; +} MINIDUMP_VM_POST_READ_CALLBACK, * PMINIDUMP_VM_POST_READ_CALLBACK; + +typedef struct _MINIDUMP_MEMORY_INFO { + ULONG64 BaseAddress; + ULONG64 AllocationBase; + ULONG32 AllocationProtect; + ULONG32 __alignment1; + ULONG64 RegionSize; + ULONG32 State; + ULONG32 Protect; + ULONG32 Type; + ULONG32 __alignment2; +} MINIDUMP_MEMORY_INFO, * PMINIDUMP_MEMORY_INFO; + +typedef struct _MINIDUMP_CALLBACK_INPUT { + ULONG ProcessId; + HANDLE ProcessHandle; + ULONG CallbackType; + union { + HRESULT Status; + MINIDUMP_THREAD_CALLBACK Thread; + MINIDUMP_THREAD_EX_CALLBACK ThreadEx; + MINIDUMP_MODULE_CALLBACK Module; + MINIDUMP_INCLUDE_THREAD_CALLBACK IncludeThread; + MINIDUMP_INCLUDE_MODULE_CALLBACK IncludeModule; + MINIDUMP_IO_CALLBACK Io; + MINIDUMP_READ_MEMORY_FAILURE_CALLBACK ReadMemoryFailure; + ULONG SecondaryFlags; + MINIDUMP_VM_QUERY_CALLBACK VmQuery; + MINIDUMP_VM_PRE_READ_CALLBACK VmPreRead; + MINIDUMP_VM_POST_READ_CALLBACK VmPostRead; + }; +} MINIDUMP_CALLBACK_INPUT, * PMINIDUMP_CALLBACK_INPUT; + +typedef struct _MINIDUMP_CALLBACK_OUTPUT { + union { + ULONG ModuleWriteFlags; + ULONG ThreadWriteFlags; + ULONG SecondaryFlags; + struct { + ULONG64 MemoryBase; + ULONG MemorySize; + }; + struct { + BOOL CheckCancel; + BOOL Cancel; + }; + HANDLE Handle; + struct { + MINIDUMP_MEMORY_INFO VmRegion; + BOOL Continue; + }; + struct { + HRESULT VmQueryStatus; + MINIDUMP_MEMORY_INFO VmQueryResult; + }; + struct { + HRESULT VmReadStatus; + ULONG VmReadBytesCompleted; + }; + HRESULT Status; + }; +} MINIDUMP_CALLBACK_OUTPUT, * PMINIDUMP_CALLBACK_OUTPUT; + +typedef struct _MINIDUMP_EXCEPTION_INFORMATION { + DWORD ThreadId; + PEXCEPTION_POINTERS ExceptionPointers; + BOOL ClientPointers; +} MINIDUMP_EXCEPTION_INFORMATION, * PMINIDUMP_EXCEPTION_INFORMATION; + +typedef struct _MINIDUMP_USER_STREAM { + ULONG32 Type; + ULONG BufferSize; + PVOID Buffer; + +} MINIDUMP_USER_STREAM, * PMINIDUMP_USER_STREAM; + +typedef struct _MINIDUMP_USER_STREAM_INFORMATION { + ULONG UserStreamCount; + PMINIDUMP_USER_STREAM UserStreamArray; +} MINIDUMP_USER_STREAM_INFORMATION, * PMINIDUMP_USER_STREAM_INFORMATION; + +typedef +BOOL +(WINAPI* MINIDUMP_CALLBACK_ROUTINE) ( + PVOID CallbackParam, + PMINIDUMP_CALLBACK_INPUT CallbackInput, + PMINIDUMP_CALLBACK_OUTPUT CallbackOutput + ); + +typedef struct _MINIDUMP_CALLBACK_INFORMATION { + MINIDUMP_CALLBACK_ROUTINE CallbackRoutine; + PVOID CallbackParam; +} MINIDUMP_CALLBACK_INFORMATION, * PMINIDUMP_CALLBACK_INFORMATION; + +typedef enum _MINIDUMP_TYPE { + MiniDumpNormal = 0x00000000, + MiniDumpWithDataSegs = 0x00000001, + MiniDumpWithFullMemory = 0x00000002, + MiniDumpWithHandleData = 0x00000004, + MiniDumpFilterMemory = 0x00000008, + MiniDumpScanMemory = 0x00000010, + MiniDumpWithUnloadedModules = 0x00000020, + MiniDumpWithIndirectlyReferencedMemory = 0x00000040, + MiniDumpFilterModulePaths = 0x00000080, + MiniDumpWithProcessThreadData = 0x00000100, + MiniDumpWithPrivateReadWriteMemory = 0x00000200, + MiniDumpWithoutOptionalData = 0x00000400, + MiniDumpWithFullMemoryInfo = 0x00000800, + MiniDumpWithThreadInfo = 0x00001000, + MiniDumpWithCodeSegs = 0x00002000, + MiniDumpWithoutAuxiliaryState = 0x00004000, + MiniDumpWithFullAuxiliaryState = 0x00008000, + MiniDumpWithPrivateWriteCopyMemory = 0x00010000, + MiniDumpIgnoreInaccessibleMemory = 0x00020000, + MiniDumpWithTokenInformation = 0x00040000, + MiniDumpWithModuleHeaders = 0x00080000, + MiniDumpFilterTriage = 0x00100000, + MiniDumpWithAvxXStateContext = 0x00200000, + MiniDumpWithIptTrace = 0x00400000, + MiniDumpScanInaccessiblePartialPages = 0x00800000, + MiniDumpFilterWriteCombinedMemory = 0x01000000, + MiniDumpValidTypeFlags = 0x01ffffff, + MiniDumpNoIgnoreInaccessibleMemory = 0x02000000, + MiniDumpValidTypeFlagsEx = 0x03ffffff, +} MINIDUMP_TYPE; + +typedef enum _MODULE_WRITE_FLAGS { + ModuleWriteModule = 0x0001, + ModuleWriteDataSeg = 0x0002, + ModuleWriteMiscRecord = 0x0004, + ModuleWriteCvRecord = 0x0008, + ModuleReferencedByMemory = 0x0010, + ModuleWriteTlsData = 0x0020, + ModuleWriteCodeSegs = 0x0040, +} MODULE_WRITE_FLAGS; + +#include +#endif +#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/Except.cpp b/Core/Libraries/Source/WWVegas/WWLib/Except.cpp index fe1d939101..e49d6ffb0e 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/Except.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/Except.cpp @@ -55,7 +55,7 @@ #include "cpudetect.h" #include "Except.h" //#include "debug.h" -#include "MPU.H" +#include "MPU.h" //#include "commando\nat.h" #include "thread.h" #include "wwdebug.h" @@ -64,7 +64,6 @@ #include #include #include -#include #ifdef WWDEBUG #define DebugString WWDebug_Printf @@ -138,7 +137,7 @@ static StackWalkType _StackWalk = NULL; static SymFunctionTableAccessType _SymFunctionTableAccess = NULL; static SymGetModuleBaseType _SymGetModuleBase = NULL; -static char const *ImagehelpFunctionNames[] = +static char const *const ImagehelpFunctionNames[] = { "SymCleanup", "SymGetSymFromAddr", @@ -224,7 +223,7 @@ char const * Last_Error_Text(void) *=============================================================================================*/ static void Add_Txt (char const *txt) { - if (strlen(ExceptionText) + strlen(txt) < 65535) { + if (strlen(ExceptionText) + strlen(txt) < ARRAY_SIZE(ExceptionText) - 1) { strcat(ExceptionText, txt); } #if (0) @@ -653,15 +652,15 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) for (int c = 0 ; c < 32 ; c++) { if (IsBadReadPtr(eip_ptr, 1)) { - strcat(scrap, "?? "); + strlcat(scrap, "?? ", ARRAY_SIZE(scrap)); } else { sprintf(bytestr, "%02X ", *eip_ptr); - strcat(scrap, bytestr); + strlcat(scrap, bytestr, ARRAY_SIZE(scrap)); } eip_ptr++; } - strcat(scrap, "\r\n\r\n"); + strlcat(scrap, "\r\n\r\n", ARRAY_SIZE(scrap)); Add_Txt(scrap); /* @@ -677,14 +676,14 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) ** The stack contents cannot be read so just print up question marks. */ sprintf(scrap, "%p: ", static_cast(stackptr)); - strcat(scrap, "????????\r\n"); + strlcat(scrap, "????????\r\n", ARRAY_SIZE(scrap)); } else { /* ** If this stack address is in our memory space then try to match it with a code symbol. */ if (IsBadCodePtr((FARPROC)*stackptr)) { sprintf(scrap, "%p: %08lX ", static_cast(stackptr), *stackptr); - strcat(scrap, "DATA_PTR\r\n"); + strlcat(scrap, "DATA_PTR\r\n", ARRAY_SIZE(scrap)); } else { sprintf(scrap, "%p: %08lX", static_cast(stackptr), *stackptr); @@ -697,12 +696,12 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) if (_SymGetSymFromAddr != NULL && _SymGetSymFromAddr (GetCurrentProcess(), *stackptr, &displacement, symptr)) { char symbuf[256]; sprintf(symbuf, " - %s + %08X", symptr->Name, displacement); - strcat(scrap, symbuf); + strlcat(scrap, symbuf, ARRAY_SIZE(scrap)); } } else { - strcat (scrap, " *"); + strlcat(scrap, " *", ARRAY_SIZE(scrap)); } - strcat (scrap, "\r\n"); + strlcat(scrap, "\r\n", ARRAY_SIZE(scrap)); } } Add_Txt(scrap); @@ -904,7 +903,7 @@ void Register_Thread_ID(unsigned long thread_id, char *thread_name, bool main_th ThreadInfoType *thread = new ThreadInfoType; thread->ThreadID = thread_id; - strcpy(thread->ThreadName, thread_name); + strlcpy(thread->ThreadName, thread_name, ARRAY_SIZE(thread->ThreadName)); thread->Main = main_thread; thread->ThreadHandle = INVALID_HANDLE_VALUE; ThreadList.Add(thread); diff --git a/Core/Libraries/Source/WWVegas/WWLib/Except.h b/Core/Libraries/Source/WWVegas/WWLib/Except.h index a425735b93..e67a4b1f64 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/Except.h +++ b/Core/Libraries/Source/WWVegas/WWLib/Except.h @@ -36,9 +36,6 @@ #pragma once -#ifndef EXCEPT_H -#define EXCEPT_H - #ifdef _MSC_VER #include "win.h" @@ -84,5 +81,3 @@ typedef struct tThreadInfoType { #endif //_MSC_VER - -#endif //EXCEPT_H diff --git a/Core/Libraries/Source/WWVegas/WWLib/FastAllocator.h b/Core/Libraries/Source/WWVegas/WWLib/FastAllocator.h index 61ec4bdc0b..bf45cf9bc5 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/FastAllocator.h +++ b/Core/Libraries/Source/WWVegas/WWLib/FastAllocator.h @@ -27,13 +27,7 @@ // /////////////////////////////////////////////////////////////////////////////// - -#ifndef FASTALLOCATOR_H -#define FASTALLOCATOR_H - -#if defined(_MSC_VER) #pragma once -#endif //#define MEMORY_OVERWRITE_TEST @@ -47,7 +41,6 @@ #include "mutex.h" #include #include //size_t & ptrdiff_t definition -#include /////////////////////////////////////////////////////////////////////////////// // Forward Declarations @@ -163,14 +156,20 @@ class StackAllocator{ T* pTArray = (T*)mTArray; const T* const pTArrayEnd = pTArray + nCount; while(pTArray < pTArrayEnd){ - new(pTArray)T; //Use the placement operator new. This simply calls the constructor - ++pTArray; //of T with 'this' set to the input address. Note that we don't put - } //a '()' after the T this is because () causes trivial types like int - } //and class* to be assigned zero/NULL. We don't want that. + //Use the placement operator new. This simply calls the constructor + //of T with 'this' set to the input address. Note that we don't put + //a '()' after the T this is because () causes trivial types like int + //and class* to be assigned zero/NULL. We don't want that. + new(pTArray)T; + ++pTArray; + } + } return (T*)mTArray; - } //Else the request is too big. So let's use (the slower) operator new. + } + //Else the request is too big. So let's use (the slower) operator new. return (mpTHeap = new T[nCount]); //The compiler will call the constructors here. - } //Else we are being used. Let's be nice and allocate something anyway. + } + //Else we are being used. Let's be nice and allocate something anyway. return new T[nCount]; } @@ -720,16 +719,3 @@ void main(){ getchar(); } */ - - - -#endif //sentry - - - - - - - - - diff --git a/Core/Libraries/Source/WWVegas/WWLib/HASHLIST.H b/Core/Libraries/Source/WWVegas/WWLib/HASHLIST.h similarity index 99% rename from Core/Libraries/Source/WWVegas/WWLib/HASHLIST.H rename to Core/Libraries/Source/WWVegas/WWLib/HASHLIST.h index 443debfa35..f0758d7227 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/HASHLIST.H +++ b/Core/Libraries/Source/WWVegas/WWLib/HASHLIST.h @@ -42,17 +42,12 @@ * HashListClass::Move_To -- Move nodes from one list to another. * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef HASHLIST_H -#define HASHLIST_H #pragma warning (push) #pragma warning (disable: 4786) -#include "LISTNODE.H" +#include "LISTNODE.h" #include #ifndef NULL @@ -630,23 +625,3 @@ void HashListClass::Move_To(HashListClass *newlist) } #pragma warning (pop) - -#endif // HASHLIST_H - - - - - - - - - - - - - - - - - - diff --git a/Core/Libraries/Source/WWVegas/WWLib/INDEX.H b/Core/Libraries/Source/WWVegas/WWLib/INDEX.h similarity index 99% rename from Core/Libraries/Source/WWVegas/WWLib/INDEX.H rename to Core/Libraries/Source/WWVegas/WWLib/INDEX.h index 401f653584..8356c1762b 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/INDEX.H +++ b/Core/Libraries/Source/WWVegas/WWLib/INDEX.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /G/wwlib/INDEX.H $* + * $Archive:: /G/wwlib/INDEX.h $* * * * $Author:: Eric_c $* * * @@ -48,14 +48,10 @@ * IndexClass::~IndexClass -- Destructor for index handler object. * * compfunc -- Support function for bsearch and bsort. * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef INDEX_H -#define INDEX_H +#pragma once -#include "BSEARCH.H" +#include "BSEARCH.h" #if !defined(__BORLANDC__) || !defined(_USERENTRY) #define _USERENTRY @@ -723,8 +719,3 @@ typename IndexClass::NodeElement const * IndexClass::Search_ return(Binary_Search(IndexTable, IndexCount, node)); // return((NodeElement const *)bsearch(&node, &IndexTable[0], IndexCount, sizeof(IndexTable[0]), search_compfunc)); } - - -#endif - - diff --git a/Core/Libraries/Source/WWVegas/WWLib/INI.H b/Core/Libraries/Source/WWVegas/WWLib/INI.h similarity index 99% rename from Core/Libraries/Source/WWVegas/WWLib/INI.H rename to Core/Libraries/Source/WWVegas/WWLib/INI.h index a59f1d32a1..dcfa6a631c 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/INI.H +++ b/Core/Libraries/Source/WWVegas/WWLib/INI.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 - -#ifndef INI_H -#define INI_H #include @@ -242,5 +237,3 @@ class INIClass { */ static bool KeepBlankEntries; }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/LISTNODE.H b/Core/Libraries/Source/WWVegas/WWLib/LISTNODE.h similarity index 99% rename from Core/Libraries/Source/WWVegas/WWLib/LISTNODE.H rename to Core/Libraries/Source/WWVegas/WWLib/LISTNODE.h index 6835766d70..159552c1e1 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/LISTNODE.H +++ b/Core/Libraries/Source/WWVegas/WWLib/LISTNODE.h @@ -33,13 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef LISTNODE_H -#define LISTNODE_H +#pragma once /* ** Includes @@ -321,6 +316,3 @@ class DoubleNode { SECONDARY Get_Secondary() { return SecondaryValue; }; void Unlink() { Primary.Unlink(); Secondary.Unlink(); }; }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/MPU.H b/Core/Libraries/Source/WWVegas/WWLib/MPU.h similarity index 98% rename from Core/Libraries/Source/WWVegas/WWLib/MPU.H rename to Core/Libraries/Source/WWVegas/WWLib/MPU.h index 70ffd0bb8b..2321fdcff4 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/MPU.H +++ b/Core/Libraries/Source/WWVegas/WWLib/MPU.h @@ -33,14 +33,10 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#pragma once -#ifndef MPU_H -#define MPU_H +#pragma once unsigned long Get_CPU_Clock(unsigned long & high); unsigned long Get_CPU_Rate(unsigned long & high); int Get_RDTSC_CPU_Speed(void); - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/PIPE.H b/Core/Libraries/Source/WWVegas/WWLib/PIPE.h similarity index 95% rename from Core/Libraries/Source/WWVegas/WWLib/PIPE.H rename to Core/Libraries/Source/WWVegas/WWLib/PIPE.h index 521baaabd1..afa979b48a 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/PIPE.H +++ b/Core/Libraries/Source/WWVegas/WWLib/PIPE.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /G/wwlib/PIPE.H $* + * $Archive:: /G/wwlib/PIPE.h $* * * * $Author:: Eric_c $* * * @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef PIPE_H -#define PIPE_H +#pragma once /* ** A "push through" pipe interface abstract class used for such purposes as compression @@ -73,5 +69,3 @@ class Pipe Pipe(Pipe & rvalue); Pipe & operator = (Pipe const & pipe); }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/Point.h b/Core/Libraries/Source/WWVegas/WWLib/Point.h index 25175784e9..888f15fdef 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/Point.h +++ b/Core/Libraries/Source/WWVegas/WWLib/Point.h @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef POINT_H -#define POINT_H +#pragma once template class TRect; @@ -201,6 +197,3 @@ TPoint3D const operator * (T lvalue, TPoint3D const & rvalue) ** integer 3D points. */ typedef TPoint3D Point3D; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/RAMFILE.H b/Core/Libraries/Source/WWVegas/WWLib/RAMFILE.h similarity index 98% rename from Core/Libraries/Source/WWVegas/WWLib/RAMFILE.H rename to Core/Libraries/Source/WWVegas/WWLib/RAMFILE.h index 54cfbc3e17..969c5c7bfe 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/RAMFILE.H +++ b/Core/Libraries/Source/WWVegas/WWLib/RAMFILE.h @@ -34,10 +34,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef RAMFILE_H -#define RAMFILE_H +#pragma once -#include "WWFILE.H" +#include "WWFILE.h" class RAMFileClass : public FileClass @@ -104,8 +103,3 @@ class RAMFileClass : public FileClass */ bool IsAllocated; }; - - - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/RANDOM.H b/Core/Libraries/Source/WWVegas/WWLib/RANDOM.h similarity index 99% rename from Core/Libraries/Source/WWVegas/WWLib/RANDOM.H rename to Core/Libraries/Source/WWVegas/WWLib/RANDOM.h index b856baab22..2f677888bf 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/RANDOM.H +++ b/Core/Libraries/Source/WWVegas/WWLib/RANDOM.h @@ -34,12 +34,8 @@ * Functions: * * Pick_Random_Number -- Picks a random number between two values (inclusive). * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef RANDOM_H -#define RANDOM_H +#pragma once // "unreferenced inline function has been removed" Yea, so what? #pragma warning(disable : 4514) @@ -266,5 +262,3 @@ int Pick_Random_Number(T & generator, int minval, int maxval) */ return(pick + minval); } - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/RAWFILE.H b/Core/Libraries/Source/WWVegas/WWLib/RAWFILE.h similarity index 97% rename from Core/Libraries/Source/WWVegas/WWLib/RAWFILE.H rename to Core/Libraries/Source/WWVegas/WWLib/RAWFILE.h index 28cd66c6a3..a770ca7cee 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/RAWFILE.H +++ b/Core/Libraries/Source/WWVegas/WWLib/RAWFILE.h @@ -37,21 +37,16 @@ * RawFileClass::~RawFileClass -- Default deconstructor for a file object. * * RawFileClass::Is_Open -- Checks to see if the file is open or not. * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef RAWFILE_Hx -#define RAWFILE_Hx +#pragma once //#include // #include "win.h" -#include #define NULL_HANDLE NULL #define HANDLE_TYPE FILE* -#include "WWFILE.H" +#include "WWFILE.h" #include "wwstring.h" @@ -152,5 +147,3 @@ class RawFileClass : public FileClass unsigned short Date; unsigned short Time; }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/SLIST.H b/Core/Libraries/Source/WWVegas/WWLib/SLIST.h similarity index 99% rename from Core/Libraries/Source/WWVegas/WWLib/SLIST.H rename to Core/Libraries/Source/WWVegas/WWLib/SLIST.h index 78b339d701..f93695811a 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/SLIST.H +++ b/Core/Libraries/Source/WWVegas/WWLib/SLIST.h @@ -20,7 +20,7 @@ * * * Project Name : G * * * - * File Name : SLIST.H * + * File Name : SLIST.h * * * * Programmer : Philip W. Gorrow * * * @@ -50,14 +50,10 @@ * SList::Add_Tail -- Adds a list to the tail of the list * * *SList::Find_Node -- returns first node in list matching the input * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef __SLIST_H__ -#define __SLIST_H__ +#pragma once -#include "SLNODE.H" +#include "SLNODE.h" #ifndef NULL #define NULL 0L @@ -541,5 +537,3 @@ inline SLNode *SList::Find_Node(T * data) const return cur; } - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/SLNODE.H b/Core/Libraries/Source/WWVegas/WWLib/SLNODE.h similarity index 95% rename from Core/Libraries/Source/WWVegas/WWLib/SLNODE.H rename to Core/Libraries/Source/WWVegas/WWLib/SLNODE.h index e17f056953..c49ce72101 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/SLNODE.H +++ b/Core/Libraries/Source/WWVegas/WWLib/SLNODE.h @@ -20,7 +20,7 @@ * * * Project Name : G * * * - * File Name : SLNODE.H * + * File Name : SLNODE.h * * * * Programmer : Philip W. Gorrow * * * @@ -31,17 +31,10 @@ *-------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef __SLNODE_H__ -#define __SLNODE_H__ +#pragma once -#ifndef ALWAYS_H #include "always.h" -#endif - #include "mempool.h" #ifndef NULL @@ -117,5 +110,3 @@ class SLNode : public GenericSLNode private: SLNode(void) {}; }; - -#endif diff --git a/Core/GameEngine/Include/Common/STLUtils.h b/Core/Libraries/Source/WWVegas/WWLib/STLUtils.h similarity index 53% rename from Core/GameEngine/Include/Common/STLUtils.h rename to Core/Libraries/Source/WWVegas/WWLib/STLUtils.h index 4fae9beef3..ca92bf76c6 100644 --- a/Core/GameEngine/Include/Common/STLUtils.h +++ b/Core/Libraries/Source/WWVegas/WWLib/STLUtils.h @@ -18,13 +18,48 @@ #pragma once -#include -#include #include +#include +#include +#include +#include namespace stl { +// Convenience struct to avoid the std::pair +template +struct range +{ + typedef typename Container::iterator iterator; + + range(iterator b, iterator e) : begin(b), end(e) {} + + iterator get() const { return begin; } + bool valid() const { return begin != end; } + ptrdiff_t distance() const { return std::distance(begin, end); } + + iterator begin; + iterator end; +}; + +template +struct const_range +{ + typedef typename Container::const_iterator iterator; + + const_range(iterator b, iterator e) : begin(b), end(e) {} + const_range(const range& other) : begin(other.begin), end(other.end) {} + + iterator get() const { return begin; } + bool valid() const { return begin != end; } + ptrdiff_t distance() const { return std::distance(begin, end); } + + iterator begin; + iterator end; +}; + + // Finds first matching element in vector-like container and erases it. template bool find_and_erase(Container& container, const typename Container::value_type& value) @@ -73,4 +108,38 @@ bool push_back_unique(Container& container, const typename Container::value_type return false; } + +template +Iter advance_in_range(Iter first, Iter last, ptrdiff_t n) +{ + if (n <= 0) + return first; + + const ptrdiff_t count = std::distance(first, last); + + if (n >= count) + return last; + + std::advance(first, n); + return first; +} + +template +range > get_range(std::multimap& mm, const Key& key, ptrdiff_t n = 0) +{ + typedef typename std::multimap::iterator Iter; + const std::pair pair = mm.equal_range(key); + const Iter it = advance_in_range(pair.first, pair.second, n); + return range >(it, pair.second); +} + +template +const_range > get_range(const std::multimap& mm, const Key& key, ptrdiff_t n = 0) +{ + typedef typename std::multimap::const_iterator Iter; + const std::pair pair = mm.equal_range(key); + const Iter it = advance_in_range(pair.first, pair.second, n); + return const_range >(it, pair.second); +} + } // namespace stl diff --git a/Core/Libraries/Source/WWVegas/WWLib/STRAW.H b/Core/Libraries/Source/WWVegas/WWLib/STRAW.h similarity index 95% rename from Core/Libraries/Source/WWVegas/WWLib/STRAW.H rename to Core/Libraries/Source/WWVegas/WWLib/STRAW.h index 00d7164b94..c099486577 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/STRAW.H +++ b/Core/Libraries/Source/WWVegas/WWLib/STRAW.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /G/wwlib/STRAW.H $* + * $Archive:: /G/wwlib/STRAW.h $* * * * $Author:: Eric_c $* * * @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef STRAW_H -#define STRAW_H +#pragma once /* ** This is a demand driven data carrier. It will retrieve the byte request by passing @@ -71,6 +67,3 @@ class Straw Straw(Straw & rvalue); Straw & operator = (Straw const & pipe); }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/Signaler.h b/Core/Libraries/Source/WWVegas/WWLib/Signaler.h index 6f05802614..073d032498 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/Signaler.h +++ b/Core/Libraries/Source/WWVegas/WWLib/Signaler.h @@ -37,8 +37,7 @@ * ******************************************************************************/ -#ifndef __SIGNALER_H__ -#define __SIGNALER_H__ +#pragma once template class Signaler { @@ -79,7 +78,3 @@ template class Signaler private: Signaler* mConnection; }; - -#endif // __SIGNALER_H__ - - diff --git a/Core/Libraries/Source/WWVegas/WWLib/SystemAllocator.h b/Core/Libraries/Source/WWVegas/WWLib/SystemAllocator.h new file mode 100644 index 0000000000..00f65a7912 --- /dev/null +++ b/Core/Libraries/Source/WWVegas/WWLib/SystemAllocator.h @@ -0,0 +1,128 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#pragma once + +#include // std::size_t, std::ptrdiff_t +#include // std::bad_alloc + + +namespace stl +{ + +// STL allocator that uses the Operating System allocator functions. Useful if allocations are meant to bypass new and delete, malloc and free. + +template +class system_allocator +{ +public: + + typedef T value_type; + typedef T* pointer; + typedef const T* const_pointer; + typedef T& reference; + typedef const T& const_reference; + typedef std::size_t size_type; + typedef std::ptrdiff_t difference_type; + + template + struct rebind + { + typedef system_allocator other; + }; + + system_allocator() throw() {} + +#if !(defined(_MSC_VER) && _MSC_VER < 1300) + system_allocator(const system_allocator&) throw() {} +#endif + + template + system_allocator(const system_allocator&) throw() {} + + ~system_allocator() throw() {} + + pointer address(reference x) const { return &x; } + const_pointer address(const_reference x) const { return &x; } + + pointer allocate(size_type n, const void* = 0) + { + if (n > max_size()) + throw std::bad_alloc(); + + void* p = GlobalAlloc(GMEM_FIXED, n * sizeof(T)); + if (!p) + throw std::bad_alloc(); + return static_cast(p); + } + + void deallocate(pointer p, size_type) + { + GlobalFree(p); + } + + void construct(pointer p, const T& val) + { + new (static_cast(p)) T(val); + } + + void destroy(pointer p) + { + p->~T(); + } + + size_type max_size() const throw() + { + return ~size_type(0) / sizeof(T); + } +}; + +// Allocators of same type are always equal +template +bool operator==(const system_allocator&, const system_allocator&) throw() { + return true; +} + +template +bool operator!=(const system_allocator&, const system_allocator&) throw() { + return false; +} + +} // namespace stl + + +#if defined(USING_STLPORT) + +// This tells STLport how to rebind system_allocator +namespace std +{ + template + struct __stl_alloc_rebind_helper; + + template + inline stl::system_allocator& __stl_alloc_rebind(stl::system_allocator& a, const Tp2*) { + return *reinterpret_cast*>(&a); + } + + template + inline const stl::system_allocator& __stl_alloc_rebind(const stl::system_allocator& a, const Tp2*) { + return *reinterpret_cast*>(&a); + } +} + +#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/TARGA.CPP b/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp similarity index 99% rename from Core/Libraries/Source/WWVegas/WWLib/TARGA.CPP rename to Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp index c4a027ed8f..de3d8773d1 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/TARGA.CPP +++ b/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp @@ -60,15 +60,15 @@ * ****************************************************************************/ -#include "TARGA.H" +#include "TARGA.h" #ifndef TGA_USES_WWLIB_FILE_CLASSES -#include +#include "WWDebug/wwdebug.h" #endif #include #include -#include +#include "stringex.h" #ifdef TGA_USES_WWLIB_FILE_CLASSES -#include "WWFILE.H" +#include "WWFILE.h" #include "ffactory.h" #else #include @@ -713,7 +713,7 @@ long Targa::Save(const char* name, long flags, bool addextension) if (!error) { mExtension.ExtSize = 495; - strncpy(mExtension.SoftID, "Denzil's Targa Code", 41); + strcpy(mExtension.SoftID, "Denzil's Targa Code"); mExtension.SoftVer.Number = (1 * 100); mExtension.SoftVer.Letter = 0; @@ -735,7 +735,7 @@ long Targa::Save(const char* name, long flags, bool addextension) if (!error) { footer.Developer = 0; - strncpy(footer.Signature, TGA2_SIGNATURE, 16); + strlcpy(footer.Signature, TGA2_SIGNATURE, sizeof(footer.Signature)); footer.RsvdChar = '.'; footer.BZST = 0; diff --git a/Core/Libraries/Source/WWVegas/WWLib/TARGA.H b/Core/Libraries/Source/WWVegas/WWLib/TARGA.h similarity index 99% rename from Core/Libraries/Source/WWVegas/WWLib/TARGA.H rename to Core/Libraries/Source/WWVegas/WWLib/TARGA.h index c4bf9f10b4..f0e082a3f2 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/TARGA.H +++ b/Core/Libraries/Source/WWVegas/WWLib/TARGA.h @@ -16,8 +16,8 @@ ** along with this program. If not, see . */ -#ifndef _TARGA_H_ -#define _TARGA_H_ +#pragma once + /**************************************************************************** * * C O N F I D E N T I A L --- W E S T W O O D S T U D I O S @@ -315,6 +315,3 @@ class Targa int File_Read(void *buffer, int size); int File_Write(void *buffer, int size); }; - -#endif /* _TARGA_H_ */ - diff --git a/Core/Libraries/Source/WWVegas/WWLib/Vector.H b/Core/Libraries/Source/WWVegas/WWLib/Vector.h similarity index 99% rename from Core/Libraries/Source/WWVegas/WWLib/Vector.H rename to Core/Libraries/Source/WWVegas/WWLib/Vector.h index bf7268fc99..09c4b8b1c3 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/Vector.H +++ b/Core/Libraries/Source/WWVegas/WWLib/Vector.h @@ -50,17 +50,12 @@ * DynamicVectorClass::Uninitialized_Add -- Add an empty place to the vector. * * DynamicVectorClass::Insert -- insert an object at the desired index * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef VECTOR_H -#define VECTOR_H +#pragma once #include "always.h" #include #include -#include #include #ifdef _MSC_VER @@ -370,7 +365,7 @@ int VectorClass::ID(T const & object) template void VectorClass::Clear(void) { - if (Vector && IsAllocated) { + if (IsAllocated) { delete[] Vector; Vector = 0; } @@ -1120,5 +1115,3 @@ bool Pointer_Vector_Remove(T const * ptr, VectorClass & vec) #ifdef _MSC_VER #pragma warning (default : 4702) // unreachable code, happens with some uses of these templates #endif - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/WWCOMUtil.h b/Core/Libraries/Source/WWVegas/WWLib/WWCOMUtil.h index af4019e05c..079d3a40f3 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/WWCOMUtil.h +++ b/Core/Libraries/Source/WWVegas/WWLib/WWCOMUtil.h @@ -34,8 +34,7 @@ * ******************************************************************************/ -#ifndef __WWCOMUTIL_H__ -#define __WWCOMUTIL_H__ +#pragma once #include @@ -56,5 +55,3 @@ bool RegisterCOMServer(const char* dllName); //! Unregister COM in-process DLL server bool UnregisterCOMServer(const char* dllName); - -#endif // __WWCOMUTIL_H__ diff --git a/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h b/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h index a4ed490128..d36f6df963 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h +++ b/Core/Libraries/Source/WWVegas/WWLib/WWCommon.h @@ -18,8 +18,34 @@ #pragma once +#include "refcount.h" +#include "STLUtils.h" +#include "stringex.h" +#include + + +// This macro serves as a general way to determine the number of elements within an array. +#ifndef ARRAY_SIZE +#if defined(_MSC_VER) && _MSC_VER < 1300 +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) +#else +template char (*ArraySizeHelper(Type(&)[Size]))[Size]; +#define ARRAY_SIZE(arr) sizeof(*ArraySizeHelper(arr)) +#endif +#endif // ARRAY_SIZE + +enum +{ + // TheSuperHackers @info The original WWSync was 33 ms, ~30 fps, integer. + // Changing this will require tweaking all Drawable code that concerns the ww3d time step, including locomotion physics. + WWSyncPerSecond = 30, + WWSyncMilliseconds = 1000 / WWSyncPerSecond, +}; + #if defined(_MSC_VER) && _MSC_VER < 1300 typedef unsigned MemValueType; +typedef long Interlocked32; // To use with Interlocked functions #else typedef unsigned long long MemValueType; +typedef volatile long Interlocked32; // To use with Interlocked functions #endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/WWDefines.h b/Core/Libraries/Source/WWVegas/WWLib/WWDefines.h new file mode 100644 index 0000000000..eb25d597db --- /dev/null +++ b/Core/Libraries/Source/WWVegas/WWLib/WWDefines.h @@ -0,0 +1,28 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#pragma once + +// Enable translation and rotation interpolation for raw animation (HRawAnimClass) updates. +// This was intentionally disabled in the retail version, but likely not fully thought through. +// Interpolation is certainly desired for animations that move and rotate meshes, but may not be +// desired for animations that teleport meshes from one location to another, such as blinking lights. +// @todo Implement a new flag per animation file to opt-out of interpolation. +#ifndef WW3D_ENABLE_RAW_ANIM_INTERPOLATION +#define WW3D_ENABLE_RAW_ANIM_INTERPOLATION (1) +#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/WWFILE.H b/Core/Libraries/Source/WWVegas/WWLib/WWFILE.h similarity index 97% rename from Core/Libraries/Source/WWVegas/WWLib/WWFILE.H rename to Core/Libraries/Source/WWVegas/WWLib/WWFILE.h index f1b8480e60..16b1bbfa0a 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/WWFILE.H +++ b/Core/Libraries/Source/WWVegas/WWLib/WWFILE.h @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef WWFILE_Hx -#define WWFILE_Hx +#pragma once #define YEAR(dt) (((dt & 0xFE000000) >> (9 + 16)) + 1980) #define MONTH(dt) ((dt & 0x01E00000) >> (5 + 16)) @@ -105,5 +101,3 @@ class FileClass int Printf_Indented(unsigned depth, char *str, ...); }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/XPIPE.H b/Core/Libraries/Source/WWVegas/WWLib/XPIPE.h similarity index 94% rename from Core/Libraries/Source/WWVegas/WWLib/XPIPE.H rename to Core/Libraries/Source/WWVegas/WWLib/XPIPE.h index d84af6f1cd..2e68e3c044 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/XPIPE.H +++ b/Core/Libraries/Source/WWVegas/WWLib/XPIPE.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /G/wwlib/XPIPE.H $* + * $Archive:: /G/wwlib/XPIPE.h $* * * * $Author:: Eric_c $* * * @@ -33,16 +33,12 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef XPIPE_H -#define XPIPE_H +#pragma once -#include "BUFF.H" -#include "PIPE.H" -#include "WWFILE.H" +#include "BUFF.h" +#include "PIPE.h" +#include "WWFILE.h" /* ** This is a simple store-into-buffer pipe terminator. Use it as the final link in a pipe process @@ -90,5 +86,3 @@ class FilePipe : public Pipe FilePipe & operator = (FilePipe const & pipe); }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/XSTRAW.H b/Core/Libraries/Source/WWVegas/WWLib/XSTRAW.h similarity index 94% rename from Core/Libraries/Source/WWVegas/WWLib/XSTRAW.H rename to Core/Libraries/Source/WWVegas/WWLib/XSTRAW.h index 4d115b1a87..f21e78f275 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/XSTRAW.H +++ b/Core/Libraries/Source/WWVegas/WWLib/XSTRAW.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /G/wwlib/XSTRAW.H $* + * $Archive:: /G/wwlib/XSTRAW.h $* * * * $Author:: Eric_c $* * * @@ -33,16 +33,12 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef XSTRAW_H -#define XSTRAW_H +#pragma once -#include "BUFF.H" -#include "STRAW.H" -#include "WWFILE.H" +#include "BUFF.h" +#include "STRAW.h" +#include "WWFILE.h" #include /* @@ -87,6 +83,3 @@ class FileStraw : public Straw FileStraw(FileStraw & rvalue); FileStraw & operator = (FileStraw const & pipe); }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/always.h b/Core/Libraries/Source/WWVegas/WWLib/always.h index 3ce54d3d9f..c58e6dd8e4 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/always.h +++ b/Core/Libraries/Source/WWVegas/WWLib/always.h @@ -33,14 +33,11 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef ALWAYS_H -#define ALWAYS_H +#pragma once #include "WWCommon.h" +#include "WWDefines.h" #include #include @@ -48,7 +45,6 @@ // TheSuperHackers @build feliwir 17/04/2025 include utility macros for cross-platform compatibility #include #include -#include // Disable warning about exception handling not being enabled. It's used as part of STL - in a part of STL we don't use. #pragma warning(disable : 4530) @@ -113,13 +109,20 @@ #define MSGW3DNEWARRAY(MSG) new( MSG, 0 ) #define W3DNEW new("W3D_" __FILE__, 0) #define W3DNEWARRAY new("W3A_" __FILE__, 0) + + #define NEW_REF( C, P ) ( (C*)RefCountClass::Set_Ref_Owner( W3DNEW C P, __FILE__, __LINE__ ) ) + #define SET_REF_OWNER( P ) ( RefCountClass::Set_Ref_Owner( P, __FILE__, __LINE__ ) ) #else #define MSGW3DNEW(MSG) new #define MSGW3DNEWARRAY(MSG) new #define W3DNEW new #define W3DNEWARRAY new + + #define NEW_REF( C, P ) ( W3DNEW C P ) + #define SET_REF_OWNER( P ) P #endif + // ---------------------------------------------------------------------------- extern void* createW3DMemPool(const char *poolName, int allocationSize); extern void* allocateFromW3DMemPool(void* p, int allocationSize); @@ -141,7 +144,7 @@ private: \ return The##ARGCLASS##Pool; \ } \ protected: \ - virtual int glueEnforcer() const { return sizeof(this); } \ + virtual void glueEnforcer() const { } \ public: \ inline void* operator new(size_t s) { return allocateFromW3DMemPool(getClassMemoryPool(), s); } \ inline void operator delete(void *p) { freeFromW3DMemPool(getClassMemoryPool(), p); } \ @@ -159,7 +162,7 @@ class W3DMPO } protected: // we never call this; it is present to cause compile errors in descendent classes - virtual int glueEnforcer() const = 0; + virtual void glueEnforcer() const = 0; public: virtual ~W3DMPO() { /* nothing */ } }; @@ -172,6 +175,9 @@ class W3DMPO #define W3DNEW new #define W3DNEWARRAY new + #define NEW_REF( C, P ) ( W3DNEW C P ) + #define SET_REF_OWNER( P ) P + #define W3DMPO_GLUE(ARGCLASS) class W3DMPO { }; @@ -191,7 +197,7 @@ class W3DMPO ** Define the MIN and MAX macros. ** NOTE: Joe used to #include in the various compiler header files. This ** header defines 'min' and 'max' macros which conflict with the surrender code so -** I'm relpacing all occurances of 'min' and 'max with 'MIN' and 'MAX'. For code which +** I'm replacing all occurrences of 'min' and 'max with 'MIN' and 'MAX'. For code which ** is out of our domain (e.g. Max sdk) I'm declaring template functions for 'min' and 'max' */ #define NOMINMAX @@ -245,7 +251,7 @@ template T max(T a,T b) #endif #if defined(__WATCOMC__) -#include "WATCOM.H" +#include "watcom.h" #endif @@ -253,17 +259,7 @@ template T max(T a,T b) #define NULL 0 #endif -/********************************************************************** -** This macro serves as a general way to determine the number of elements -** within an array. -*/ -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) int(sizeof(x)/sizeof(x[0])) -#endif #ifndef size_of #define size_of(typ,id) sizeof(((typ*)0)->id) #endif - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/argv.cpp b/Core/Libraries/Source/WWVegas/WWLib/argv.cpp index 1b5ae3c669..28958b3fbb 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/argv.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/argv.cpp @@ -43,11 +43,9 @@ #include #include -#include #include -#include #include "ffactory.h" -#include "RAWFILE.H" +#include "RAWFILE.h" int ArgvClass::Argc = 0; char *ArgvClass::Argv[MAX_ARGC]; @@ -105,7 +103,7 @@ const char *ArgvClass::Find_Again(const char *arg) if (Is_Exact_Size()) { // Case Sensitive, Exact Size. for (; CurrentPos < Argc; CurrentPos++) { - if (!strcmp(arg, Argv[CurrentPos])) { + if (strcmp(arg, Argv[CurrentPos]) == 0) { return Argv[CurrentPos]; } } @@ -113,7 +111,7 @@ const char *ArgvClass::Find_Again(const char *arg) // Case Sensitive, Match first strlen(arg). int len = strlen(arg); for (; CurrentPos < Argc; CurrentPos++) { - if (!strncmp(arg, Argv[CurrentPos], len)) { + if (strncmp(arg, Argv[CurrentPos], len) == 0) { return Argv[CurrentPos]; } } @@ -122,7 +120,7 @@ const char *ArgvClass::Find_Again(const char *arg) if (Is_Exact_Size()) { // Note case sensitive, Exact Size. for (; CurrentPos < Argc; CurrentPos++) { - if (!stricmp(arg, Argv[CurrentPos])) { + if (stricmp(arg, Argv[CurrentPos]) == 0) { return Argv[CurrentPos]; } } @@ -130,7 +128,7 @@ const char *ArgvClass::Find_Again(const char *arg) // Note case sensitive, Match first strlen(arg). int len = strlen(arg); for (; CurrentPos < Argc; CurrentPos++) { - if (!strnicmp(arg, Argv[CurrentPos], len)) { + if (strnicmp(arg, Argv[CurrentPos], len) == 0) { return Argv[CurrentPos]; } } @@ -203,7 +201,7 @@ int ArgvClass::Init(char *lpCmdLine, const char *fileprefix) bool was_file = false; // See if we are to load a file with parameters in it. - if (fp_cmp_len && !strncmp(fileprefix, ptr, fp_cmp_len)) { + if (fp_cmp_len && strncmp(fileprefix, ptr, fp_cmp_len) == 0) { ptr += fp_cmp_len; if (*ptr) { was_file = Load_File(ptr); diff --git a/Core/Libraries/Source/WWVegas/WWLib/argv.h b/Core/Libraries/Source/WWVegas/WWLib/argv.h index e561481044..a512b61861 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/argv.h +++ b/Core/Libraries/Source/WWVegas/WWLib/argv.h @@ -35,17 +35,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef ARGV_H -#define ARGV_H - -#ifndef ALWAYS_H #include "always.h" -#endif // Used to parse command line that is passed into WinMain. // It also has the ability to load a file with values to append to the command line. @@ -157,6 +149,3 @@ class ArgvClass enum {MAX_ARGC = 256}; static char *Argv[MAX_ARGC]; }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/b64pipe.cpp b/Core/Libraries/Source/WWVegas/WWLib/b64pipe.cpp index 9f1640b32f..fe6c313ec5 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/b64pipe.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/b64pipe.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/B64PIPE.CPP $* + * $Archive:: /Commando/Library/B64PIPE.cpp $* * * * $Author:: Greg_h $* * * @@ -39,7 +39,6 @@ #include "always.h" #include "b64pipe.h" #include "base64.h" -#include /*********************************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WWLib/b64pipe.h b/Core/Libraries/Source/WWVegas/WWLib/b64pipe.h index b1840dc5b3..19a1995136 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/b64pipe.h +++ b/Core/Libraries/Source/WWVegas/WWLib/b64pipe.h @@ -33,14 +33,10 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef B64PIPE_H -#define B64PIPE_H +#pragma once -#include "PIPE.H" +#include "PIPE.h" /* ** This class performs Base64 encoding/decoding to the data that is piped through. Note that @@ -89,5 +85,3 @@ class Base64Pipe : public Pipe Base64Pipe(Base64Pipe & rvalue); Base64Pipe & operator = (Base64Pipe const & pipe); }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/b64straw.cpp b/Core/Libraries/Source/WWVegas/WWLib/b64straw.cpp index 26081566d5..fde1aaadff 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/b64straw.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/b64straw.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/B64STRAW.CPP $* + * $Archive:: /Commando/Library/B64STRAW.cpp $* * * * $Author:: Greg_h $* * * @@ -38,7 +38,6 @@ #include "always.h" #include "b64straw.h" #include "base64.h" -#include /*********************************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WWLib/b64straw.h b/Core/Libraries/Source/WWVegas/WWLib/b64straw.h index 20b6b97cf8..fe24b32323 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/b64straw.h +++ b/Core/Libraries/Source/WWVegas/WWLib/b64straw.h @@ -33,14 +33,10 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef B64STRAW_H -#define B64STRAW_H +#pragma once -#include "STRAW.H" +#include "STRAW.h" /* ** Performs Base 64 encoding/decoding on the data that is drawn through the straw. Note that @@ -87,6 +83,3 @@ class Base64Straw : public Straw Base64Straw(Base64Straw & rvalue); Base64Straw & operator = (Base64Straw const & pipe); }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/base64.h b/Core/Libraries/Source/WWVegas/WWLib/base64.h index 75ee7fb656..301249cd19 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/base64.h +++ b/Core/Libraries/Source/WWVegas/WWLib/base64.h @@ -33,9 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 + #pragma once -#endif // _MSC_VER >= 1000 int Base64_Encode(void const * source, int slen, void * dest, int dlen); int Base64_Decode(void const * source, int slen, void * dest, int dlen); diff --git a/Core/Libraries/Source/WWVegas/WWLib/bfiofile.cpp b/Core/Libraries/Source/WWVegas/WWLib/bfiofile.cpp index 123434d3ca..b6fef3951d 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/bfiofile.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/bfiofile.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/BFIOFILE.CPP $* + * $Archive:: /Commando/Library/BFIOFILE.cpp $* * * * $Author:: Greg_h $* * * diff --git a/Core/Libraries/Source/WWVegas/WWLib/bfiofile.h b/Core/Libraries/Source/WWVegas/WWLib/bfiofile.h index 2955e054b7..8b144568ea 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/bfiofile.h +++ b/Core/Libraries/Source/WWVegas/WWLib/bfiofile.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/BFIOFILE.H $* + * $Archive:: /Commando/Library/BFIOFILE.h $* * * * $Author:: Greg_h $* * * @@ -34,10 +34,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef BFIOFILE_H -#define BFIOFILE_H +#pragma once -#include "RAWFILE.H" +#include "RAWFILE.h" /* ** This derivation of the raw file class handles buffering the input/output in order to @@ -92,5 +91,3 @@ class BufferIOFileClass : public RawFileClass long FilePos; long TrueFileStart; }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/binheap.h b/Core/Libraries/Source/WWVegas/WWLib/binheap.h index 31eafc978e..fa4aa9447a 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/binheap.h +++ b/Core/Libraries/Source/WWVegas/WWLib/binheap.h @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef BINARY_HEAP_CLASS_H -#define BINARY_HEAP_CLASS_H +#pragma once /*=============================================================================================*/ // Includes. @@ -314,6 +313,3 @@ class BinaryHeapClass // binary tree. bool Own_Array; }; - - -#endif //BINARY_HEAP_CLASS_H diff --git a/Core/Libraries/Source/WWVegas/WWLib/bittype.h b/Core/Libraries/Source/WWVegas/WWLib/bittype.h index 4a6d73cfd3..7b40a59c2e 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/bittype.h +++ b/Core/Libraries/Source/WWVegas/WWLib/bittype.h @@ -23,7 +23,7 @@ * * * Project Name : Voxel Technology * * * - * File Name : BITTYPE.H * + * File Name : BITTYPE.h * * * * Programmer : Greg Hjelstrom * * * @@ -34,12 +34,8 @@ *-------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef BITTYPE_H -#define BITTYPE_H +#pragma once typedef unsigned char uint8; typedef unsigned short uint16; @@ -63,4 +59,9 @@ typedef const char * LPCSTR; typedef unsigned int UINT; typedef unsigned long ULONG; -#endif //BITTYPE_H +#if defined(_MSC_VER) && _MSC_VER < 1300 +#ifndef _WCHAR_T_DEFINED +typedef unsigned short wchar_t; +#define _WCHAR_T_DEFINED +#endif +#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/bound.h b/Core/Libraries/Source/WWVegas/WWLib/bound.h index ee3d9945a3..8f526382a5 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/bound.h +++ b/Core/Libraries/Source/WWVegas/WWLib/bound.h @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef BOUND_H -#define BOUND_H +#pragma once template inline T Bound(T original, T minval, T maxval) @@ -55,7 +51,3 @@ T Bound(T original, T minval, T maxval) //float Bound(float, float, float); //double Bound(double, double, double); #endif - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWLib/buff.cpp b/Core/Libraries/Source/WWVegas/WWLib/buff.cpp index f460495452..ae14b73bc0 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/buff.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/buff.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /G/wwlib/BUFF.CPP $* + * $Archive:: /G/wwlib/BUFF.cpp $* * * * $Author:: Eric_c $* * * @@ -41,7 +41,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" -#include "BUFF.H" +#include "BUFF.h" //#include diff --git a/Core/Libraries/Source/WWVegas/WWLib/bufffile.cpp b/Core/Libraries/Source/WWVegas/WWLib/bufffile.cpp index de68c393e3..6c16b1d31c 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/bufffile.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/bufffile.cpp @@ -37,7 +37,6 @@ #include "always.h" #include "bufffile.h" #include "wwdebug.h" -#include int BufferedFileClass::_DesiredBufferSize = 1024*16; @@ -242,11 +241,9 @@ int BufferedFileClass::Seek(int pos, int dir) */ void BufferedFileClass::Reset_Buffer( void ) { - if ( Buffer != NULL ) { - delete [] Buffer; - Buffer = NULL; - BufferSize = 0; - BufferAvailable = 0; - BufferOffset = 0; - } + delete [] Buffer; + Buffer = NULL; + BufferSize = 0; + BufferAvailable = 0; + BufferOffset = 0; } diff --git a/Core/Libraries/Source/WWVegas/WWLib/bufffile.h b/Core/Libraries/Source/WWVegas/WWLib/bufffile.h index 4a22b91cc0..8153794c76 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/bufffile.h +++ b/Core/Libraries/Source/WWVegas/WWLib/bufffile.h @@ -38,14 +38,9 @@ * RawFileClass::Is_Open -- Checks to see if the file is open or not. * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 -#ifndef BUFFFILE_H -#define BUFFFILE_H - -#include "RAWFILE.H" +#include "RAWFILE.h" /* @@ -81,5 +76,3 @@ class BufferedFileClass : public RawFileClass int BufferOffset; // The data already given out static int _DesiredBufferSize; }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/chunkio.cpp b/Core/Libraries/Source/WWVegas/WWLib/chunkio.cpp index 0a34f07526..6c8bbbdbc8 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/chunkio.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/chunkio.cpp @@ -63,7 +63,6 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "chunkio.h" -#include #include diff --git a/Core/Libraries/Source/WWVegas/WWLib/chunkio.h b/Core/Libraries/Source/WWVegas/WWLib/chunkio.h index 7d2d00adab..59b0d4c10e 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/chunkio.h +++ b/Core/Libraries/Source/WWVegas/WWLib/chunkio.h @@ -34,29 +34,13 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef CHUNKIO_H -#define CHUNKIO_H +#pragma once -#ifndef ALWAYS_H #include "always.h" -#endif - -#ifndef BITTYPE_H #include "bittype.h" -#endif - -#ifndef WWFILE_H -#include "WWFILE.H" -#endif - -#ifndef IOSTRUCT_H +#include "WWFILE.h" #include "iostruct.h" -#endif - /************************************************************************************ @@ -374,7 +358,3 @@ class ChunkLoadClass */ #define OBSOLETE_MICRO_CHUNK(id) \ case (id): break; - - - -#endif // CHUNKIO_H diff --git a/Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp b/Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp index 686af13be3..622753fa1a 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp @@ -120,7 +120,7 @@ char CPUDetectClass::ProcessorString[48]; const char* CPUDetectClass::Get_Processor_Manufacturer_Name() { - static const char* ManufacturerNames[] = { + static const char* const ManufacturerNames[] = { "", "Intel", "UMC", @@ -131,6 +131,7 @@ const char* CPUDetectClass::Get_Processor_Manufacturer_Name() "Rise", "Transmeta" }; + static_assert(ARRAY_SIZE(ManufacturerNames) == MANUFACTURER_COUNT, "Incorrect array size"); return ManufacturerNames[ProcessorManufacturer]; } @@ -801,7 +802,7 @@ void CPUDetectClass::Init_Processor_String() case INTEL_PROCESSOR_PENTIUM4: str+="Pentium4"; break; } } - strncpy(ProcessorString,str.str(),sizeof(ProcessorString)); + strlcpy(ProcessorString,str.str(),sizeof(ProcessorString)); } } @@ -1112,7 +1113,7 @@ void CPUDetectClass::Init_Compact_Log() Get_OS_Info(os_info,OSVersionPlatformId,OSVersionNumberMajor,OSVersionNumberMinor,OSVersionBuildNumber); COMPACTLOG(("%s\t",os_info.Code)); - if (!stricmp(os_info.SubCode,"UNKNOWN")) { + if (stricmp(os_info.SubCode,"UNKNOWN") == 0) { COMPACTLOG(("%d\t",OSVersionBuildNumber&0xffff)); } else { diff --git a/Core/Libraries/Source/WWVegas/WWLib/cpudetect.h b/Core/Libraries/Source/WWVegas/WWLib/cpudetect.h index 23318f6507..4cba11de11 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/cpudetect.h +++ b/Core/Libraries/Source/WWVegas/WWLib/cpudetect.h @@ -36,12 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef WWLIB_CPU_DETECT_H__ -#define WWLIB_CPU_DETECT_H__ #include "always.h" #include "wwstring.h" @@ -67,7 +62,9 @@ class CPUDetectClass MANUFACTURER_NEXTGEN, MANUFACTURER_VIA, MANUFACTURER_RISE, - MANUFACTURER_TRANSMETA + MANUFACTURER_TRANSMETA, + + MANUFACTURER_COUNT } ProcessorManufacturerType; typedef enum @@ -146,30 +143,30 @@ class CPUDetectClass RISE_PROCESSOR_DRAGON2_018 } RiseProcessorType; - inline static ProcessorManufacturerType Get_Processor_Manufacturer() {return ProcessorManufacturer;} + static ProcessorManufacturerType Get_Processor_Manufacturer() {return ProcessorManufacturer;} static const char* Get_Processor_Manufacturer_Name(); - inline static bool Has_CPUID_Instruction() { return HasCPUIDInstruction; } - inline static bool Has_RDTSC_Instruction() { return HasRDTSCInstruction; } - inline static bool Has_CMOV_Instruction() { return HasCMOVSupport; } - inline static bool Has_MMX_Instruction_Set() { return HasMMXSupport; } - inline static bool Has_SSE_Instruction_Set() { return HasSSESupport; } - inline static bool Has_SSE2_Instruction_Set() { return HasSSE2Support; } - inline static bool Has_3DNow_Instruction_Set() { return Has3DNowSupport; } - inline static bool Has_Extended_3DNow_Instruction_Set() { return HasExtended3DNowSupport; } + static bool Has_CPUID_Instruction() { return HasCPUIDInstruction; } + static bool Has_RDTSC_Instruction() { return HasRDTSCInstruction; } + static bool Has_CMOV_Instruction() { return HasCMOVSupport; } + static bool Has_MMX_Instruction_Set() { return HasMMXSupport; } + static bool Has_SSE_Instruction_Set() { return HasSSESupport; } + static bool Has_SSE2_Instruction_Set() { return HasSSE2Support; } + static bool Has_3DNow_Instruction_Set() { return Has3DNowSupport; } + static bool Has_Extended_3DNow_Instruction_Set() { return HasExtended3DNowSupport; } // Call these functions after determining the manufacturer to find out which of the manufacturers processors // the system has. - inline static IntelProcessorType Get_Intel_Processor() { return IntelProcessor; } - inline static AMDProcessorType Get_AMD_Processor() { return AMDProcessor; } - inline static VIAProcessorType Get_VIA_Processor() { return VIAProcessor; } - inline static RiseProcessorType Get_Rise_Processor() { return RiseProcessor; } + static IntelProcessorType Get_Intel_Processor() { return IntelProcessor; } + static AMDProcessorType Get_AMD_Processor() { return AMDProcessor; } + static VIAProcessorType Get_VIA_Processor() { return VIAProcessor; } + static RiseProcessorType Get_Rise_Processor() { return RiseProcessor; } // Note that processor speed is only calculated at start and could change during execution, so // this number is not to be relied on! - inline static int Get_Processor_Speed() { return ProcessorSpeed; } - inline static sint64 Get_Processor_Ticks_Per_Second() { return ProcessorTicksPerSecond; } // Ticks per second - inline static double Get_Inv_Processor_Ticks_Per_Second() { return InvProcessorTicksPerSecond; } // 1.0 / Ticks per second + static int Get_Processor_Speed() { return ProcessorSpeed; } + static sint64 Get_Processor_Ticks_Per_Second() { return ProcessorTicksPerSecond; } // Ticks per second + static double Get_Inv_Processor_Ticks_Per_Second() { return InvProcessorTicksPerSecond; } // 1.0 / Ticks per second static unsigned Get_Feature_Bits() { return FeatureBits; } static unsigned Get_Extended_Feature_Bits() { return ExtendedFeatureBits; } @@ -203,9 +200,9 @@ class CPUDetectClass static unsigned Get_Processor_Type() { return ProcessorType; } - inline static const char* Get_Processor_String() { return ProcessorString; } - inline static const StringClass& Get_Processor_Log() { return ProcessorLog; } - inline static const StringClass& Get_Compact_Log() { return CompactLog; } + static const char* Get_Processor_String() { return ProcessorString; } + static const StringClass& Get_Processor_Log() { return ProcessorLog; } + static const StringClass& Get_Compact_Log() { return CompactLog; } static bool CPUID( unsigned& u_eax_, @@ -320,6 +317,3 @@ struct CPUIDStruct CPUDetectClass::CPUID(Eax,Ebx,Ecx,Edx,cpuid_type); } }; - - -#endif // WWLIB_CPU_DETECT_H__ diff --git a/Core/Libraries/Source/WWVegas/WWLib/crandom.h b/Core/Libraries/Source/WWVegas/WWLib/crandom.h index 02667d8121..29a8616a06 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/crandom.h +++ b/Core/Libraries/Source/WWVegas/WWLib/crandom.h @@ -34,15 +34,14 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef CRANDOM_H -#define CRANDOM_H +#pragma once #ifndef ALWAYS_H #include "always.h" #endif #ifndef RANDOM_H - #include "RANDOM.H" + #include "RANDOM.h" #endif #ifndef WWDEBUG_H @@ -119,5 +118,3 @@ inline float CRandom::Get_Float( float min, float max ) ** be synced between other computers. Good for simple visual and sound effects. */ extern CRandom FreeRandom; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/crc.cpp b/Core/Libraries/Source/WWVegas/WWLib/crc.cpp index 0faf61b858..455af0d083 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/crc.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/crc.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Code/wwlib/CRC.CPP $* + * $Archive:: /Commando/Code/wwlib/CRC.cpp $* * * * $Author:: Eric_c $* * * @@ -37,7 +37,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" -#include "CRC.H" +#include "CRC.h" /*********************************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WWLib/crcpipe.cpp b/Core/Libraries/Source/WWVegas/WWLib/crcpipe.cpp index 37086c01a7..c7397dd04f 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/crcpipe.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/crcpipe.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/CRCPIPE.CPP $* + * $Archive:: /Commando/Library/CRCPIPE.cpp $* * * * $Author:: Greg_h $* * * diff --git a/Core/Libraries/Source/WWVegas/WWLib/crcpipe.h b/Core/Libraries/Source/WWVegas/WWLib/crcpipe.h index d709ae0bb0..5a6f3af7c0 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/crcpipe.h +++ b/Core/Libraries/Source/WWVegas/WWLib/crcpipe.h @@ -34,11 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef CRCPIPE_H -#define CRCPIPE_H +#pragma once -#include "CRC.H" -#include "PIPE.H" +#include "CRC.h" +#include "PIPE.h" /* ** This class doesn't modify the data being piped through, but it does examine it and build @@ -60,5 +59,3 @@ class CRCPipe : public Pipe CRCPipe(CRCPipe & rvalue); CRCPipe & operator = (CRCPipe const & pipe); }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/crcstraw.cpp b/Core/Libraries/Source/WWVegas/WWLib/crcstraw.cpp index cb6898624d..ba173de5f5 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/crcstraw.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/crcstraw.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/CRCSTRAW.CPP $* + * $Archive:: /Commando/Library/CRCSTRAW.cpp $* * * * $Author:: Greg_h $* * * diff --git a/Core/Libraries/Source/WWVegas/WWLib/crcstraw.h b/Core/Libraries/Source/WWVegas/WWLib/crcstraw.h index 6e0fa59678..3d72841bbc 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/crcstraw.h +++ b/Core/Libraries/Source/WWVegas/WWLib/crcstraw.h @@ -34,11 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef CRCSTRAW_H -#define CRCSTRAW_H +#pragma once -#include "CRC.H" -#include "STRAW.H" +#include "CRC.h" +#include "STRAW.h" /* ** This class will build a CRC value from the data stream that is drawn through this class. @@ -60,6 +59,3 @@ class CRCStraw : public Straw CRCStraw(CRCStraw & rvalue); CRCStraw & operator = (CRCStraw const & pipe); }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/cstraw.cpp b/Core/Libraries/Source/WWVegas/WWLib/cstraw.cpp index c26d49ffd2..c65cd46c26 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/cstraw.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/cstraw.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/CSTRAW.CPP $* + * $Archive:: /Commando/Library/CSTRAW.cpp $* * * * $Author:: Greg_h $* * * @@ -37,7 +37,6 @@ #include "always.h" #include "cstraw.h" -#include /*********************************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WWLib/cstraw.h b/Core/Libraries/Source/WWVegas/WWLib/cstraw.h index 6ae663cf54..ffdfab40df 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/cstraw.h +++ b/Core/Libraries/Source/WWVegas/WWLib/cstraw.h @@ -33,15 +33,11 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef CSTRAW_H -#define CSTRAW_H +#pragma once -#include "BUFF.H" -#include "STRAW.H" +#include "BUFF.h" +#include "STRAW.h" /* ** This class handles transfer of data by perform regulated requests for data from the next @@ -65,8 +61,3 @@ class CacheStraw : public Straw CacheStraw(CacheStraw & rvalue); CacheStraw & operator = (CacheStraw const & pipe); }; - - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp b/Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp index 186d286927..02ea652aea 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp @@ -34,13 +34,11 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "ffactory.h" -#include "RAWFILE.H" +#include "RAWFILE.h" #include "bufffile.h" #include "realcrc.h" -#include #include #include -#include /* ** Statics @@ -148,7 +146,7 @@ void SimpleFileFactoryClass::Prepend_Sub_Directory( const char * sub_directory ) // Ensure sub_directory ends with a slash, and append a semicolon char temp_sub_dir[1024]; - strcpy(temp_sub_dir, sub_directory); + strlcpy(temp_sub_dir, sub_directory, ARRAY_SIZE(temp_sub_dir)); if (temp_sub_dir[sub_len - 1] != '\\') { temp_sub_dir[sub_len] = '\\'; temp_sub_dir[sub_len + 1] = 0; @@ -183,7 +181,7 @@ void SimpleFileFactoryClass::Append_Sub_Directory( const char * sub_directory ) // Ensure sub_directory ends with a slash char temp_sub_dir[1024]; - strcpy(temp_sub_dir, sub_directory); + strlcpy(temp_sub_dir, sub_directory, ARRAY_SIZE(temp_sub_dir)); if (temp_sub_dir[sub_len - 1] != '\\') { temp_sub_dir[sub_len] = '\\'; temp_sub_dir[sub_len + 1] = 0; diff --git a/Core/Libraries/Source/WWVegas/WWLib/ffactory.h b/Core/Libraries/Source/WWVegas/WWLib/ffactory.h index 0eaf79fd62..cb7acc11c1 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ffactory.h +++ b/Core/Libraries/Source/WWVegas/WWLib/ffactory.h @@ -34,25 +34,17 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 -#ifndef FFACTORY_H -#define FFACTORY_H - -#ifndef ALWAYS_H #include "always.h" -#endif - #include "mutex.h" -#include "Vector.H" +#include "Vector.h" #include "wwstring.h" /* ** */ -#include "RAWFILE.H" +#include "RAWFILE.h" class FileClass; /* @@ -159,5 +151,3 @@ extern RawFileFactoryClass * _TheWritingFileFactory; // No simple file factory. jba. // (gth) re-enabling this because w3d view uses it extern SimpleFileFactoryClass * _TheSimpleFileFactory; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/gcd_lcm.h b/Core/Libraries/Source/WWVegas/WWLib/gcd_lcm.h index 5c1349ffc2..e5ce3b0225 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/gcd_lcm.h +++ b/Core/Libraries/Source/WWVegas/WWLib/gcd_lcm.h @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef GCD_LCM_H -#define GCD_LCM_H +#pragma once #include "always.h" @@ -49,5 +45,3 @@ unsigned int Greatest_Common_Divisor(unsigned int a, unsigned int b); // The least common multiple (LCM) is the least integer of which given // positive integers are divisors. unsigned int Least_Common_Multiple(unsigned int a, unsigned int b); - -#endif // GCD_LCM_H diff --git a/Core/Libraries/Source/WWVegas/WWLib/global.h b/Core/Libraries/Source/WWVegas/WWLib/global.h index 81f9c1b3e2..47109607d8 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/global.h +++ b/Core/Libraries/Source/WWVegas/WWLib/global.h @@ -16,7 +16,7 @@ ** along with this program. If not, see . */ -/* GLOBAL.H - RSAREF types and constants +/* GLOBAL.h - RSAREF types and constants */ /* PROTOTYPES should be set to one if and only if the compiler supports diff --git a/Core/Libraries/Source/WWVegas/WWLib/hash.cpp b/Core/Libraries/Source/WWVegas/WWLib/hash.cpp index d819952acf..441fe6bfe7 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/hash.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/hash.cpp @@ -39,8 +39,6 @@ #include "wwdebug.h" #include "realcrc.h" -#include - /* ** HashTableClass */ @@ -58,10 +56,8 @@ HashTableClass::HashTableClass( int size ) : HashTableClass::~HashTableClass( void ) { // If we need to, free the hash table - if ( HashTable != NULL) { - delete [] HashTable; - HashTable = NULL; - } + delete [] HashTable; + HashTable = NULL; } void HashTableClass::Reset( void ) diff --git a/Core/Libraries/Source/WWVegas/WWLib/hash.h b/Core/Libraries/Source/WWVegas/WWLib/hash.h index 8324485815..c91e48c511 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/hash.h +++ b/Core/Libraries/Source/WWVegas/WWLib/hash.h @@ -35,13 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef HASH_H -#define HASH_H #include "always.h" @@ -115,6 +109,3 @@ class HashTableIteratorClass void Advance_Next( void ); }; - - -#endif // HASH_H diff --git a/Core/Libraries/Source/WWVegas/WWLib/hashcalc.h b/Core/Libraries/Source/WWVegas/WWLib/hashcalc.h index c6a63933f8..a01fbf08ff 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/hashcalc.h +++ b/Core/Libraries/Source/WWVegas/WWLib/hashcalc.h @@ -33,14 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - - -#ifndef HASHCALC_H -#define HASHCALC_H +#pragma once /* ** HashCalculatorClass @@ -68,7 +62,3 @@ template class HashCalculatorClass virtual int Num_Hash_Values(void) = 0; virtual int Get_Hash_Value(int index = 0) = 0; }; - - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/hashtab.h b/Core/Libraries/Source/WWVegas/WWLib/hashtab.h index ced524f0bb..7a66ce6bbc 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/hashtab.h +++ b/Core/Libraries/Source/WWVegas/WWLib/hashtab.h @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef HASHTAB_H -#define HASHTAB_H +#pragma once #if 0 @@ -121,7 +120,3 @@ Object * HashTableClass::Find(Key * key) const } #endif - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWLib/hashtemplate.h b/Core/Libraries/Source/WWVegas/WWLib/hashtemplate.h index 80d640915e..79de6a2cad 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/hashtemplate.h +++ b/Core/Libraries/Source/WWVegas/WWLib/hashtemplate.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef HASH_TEMPLATE_H -#define HASH_TEMPLATE_H #include "always.h" #include "wwstring.h" @@ -402,10 +396,8 @@ template inline HashTemplateClass inline HashTemplateClass::~HashTemplateClass() { - if (Hash) - delete[] Hash; - if (Table) - delete[] Table; + delete[] Hash; + delete[] Table; } // Get_Hash_Value specialization for StringClass. This is intended to be used @@ -427,7 +419,3 @@ template <> inline unsigned int HashTemplateKeyClass::Get_Hash_Valu hval = hval + (hval>>5) + (hval>>10) + (hval >> 20); return hval; } - - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/incdec.h b/Core/Libraries/Source/WWVegas/WWLib/incdec.h index 8ce539067b..e8e8ae76ed 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/incdec.h +++ b/Core/Libraries/Source/WWVegas/WWLib/incdec.h @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef INCDEC_H -#define INCDEC_H +#pragma once /* ** These templates allow enumeration types to have simple bitwise @@ -64,5 +63,3 @@ template inline T operator --(T & a, int) a = (T)((int)a - (int)1); return(aa); } - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/ini.cpp b/Core/Libraries/Source/WWVegas/WWLib/ini.cpp index 82b0f0b549..9a1f3c09fe 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ini.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/ini.cpp @@ -88,25 +88,24 @@ #include "b64pipe.h" #include "b64straw.h" #include "cstraw.h" -#include "INI.H" +#include "INI.h" #include "readline.h" #include "trim.h" #include "win.h" -#include "XPIPE.H" -#include "XSTRAW.H" -#include +#include "XPIPE.h" +#include "XSTRAW.h" #include #ifdef _UNIX #include #endif -#include "RAWFILE.H" +#include "RAWFILE.h" #include "ffactory.h" // recently transferred from ini.h #include "inisup.h" #include "trect.h" -#include "WWFILE.H" -#include "PIPE.H" +#include "WWFILE.h" +#include "PIPE.h" #include "wwstring.h" #include "widestring.h" #include "nstrdup.h" @@ -431,7 +430,7 @@ int INIClass::Load(Straw & ffile) if (ptr != NULL) *ptr = '\0'; strtrim(buffer); char section[64]; - strcpy(section, buffer); + strlcpy(section, buffer, ARRAY_SIZE(section)); /* ** Read in the entries of this section. @@ -1150,8 +1149,7 @@ bool INIClass::Put_TextBlock(char const * section, char const * text) char buffer[128]; - strncpy(buffer, text, 75); - buffer[75] = '\0'; + strlcpy(buffer, text, 76); char b[32]; sprintf(b, "%d", index); @@ -1639,7 +1637,7 @@ bool INIClass::Put_String(char const * section, char const * entry, char const * */ INIEntry * entryptr = secptr->Find_Entry(entry); if (entryptr != NULL) { - if (strcmp(entryptr->Entry, entry)) { + if (strcmp(entryptr->Entry, entry) != 0) { DuplicateCRCError("INIClass::Put_String", section, entry); } else { #if 0 @@ -1724,8 +1722,7 @@ int INIClass::Get_String(char const * section, char const * entry, char const * buffer[0] = '\0'; return(0); } else { - strncpy(buffer, defvalue, size); - buffer[size-1] = '\0'; + strlcpy(buffer, defvalue, size); strtrim(buffer); return(strlen(buffer)); } @@ -2287,8 +2284,8 @@ void INIClass::DuplicateCRCError(const char *message, const char *section, const OutputDebugString(buffer); assert(0); -#ifdef NDEBUG -#ifdef _WINDOWS +#ifdef RTS_RELEASE +#ifdef _WIN32 MessageBox(0, buffer, "Duplicate CRC in INI file.", MB_ICONSTOP | MB_OK); #endif #endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/inisup.h b/Core/Libraries/Source/WWVegas/WWLib/inisup.h index b6286eab11..1ed5b8477d 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/inisup.h +++ b/Core/Libraries/Source/WWVegas/WWLib/inisup.h @@ -33,10 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 +#pragma once /* ** This header defines generally unused member structures used by the INI class. @@ -44,9 +42,9 @@ ** to help reduce header dependancies. -ehc */ -#include "LISTNODE.H" -#include "INDEX.H" -#include "CRC.H" +#include "LISTNODE.h" +#include "INDEX.h" +#include "CRC.h" /* diff --git a/Core/Libraries/Source/WWVegas/WWLib/iostruct.h b/Core/Libraries/Source/WWVegas/WWLib/iostruct.h index 3d6a00594b..ada2fc3395 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/iostruct.h +++ b/Core/Libraries/Source/WWVegas/WWLib/iostruct.h @@ -33,21 +33,10 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#if defined(_MSC_VER) #pragma once -#endif -#ifndef IOSTRUCT_H -#define IOSTRUCT_H - -#ifndef BITTYPE_H #include "bittype.h" -#endif /* ** Some useful structures for writing/writing (safe from changes). @@ -78,8 +67,3 @@ struct IOQuaternionStruct { float32 Q[4]; }; - - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzo.h b/Core/Libraries/Source/WWVegas/WWLib/lzo.h index 8c47381a58..afecc22791 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzo.h +++ b/Core/Libraries/Source/WWVegas/WWLib/lzo.h @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef _LZO_H -#define _LZO_H +#pragma once #include "lzoconf.h" #include "lzo1x.h" @@ -100,7 +99,3 @@ class LZOCompressor static lzo_byte WorkBuffer[LZO1X_MEM_COMPRESS + 1]; static lzo_byte * EOWorkBuffer; }; - - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzo1x.h b/Core/Libraries/Source/WWVegas/WWLib/lzo1x.h index 2e7507c4bf..cae5f0e368 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzo1x.h +++ b/Core/Libraries/Source/WWVegas/WWLib/lzo1x.h @@ -59,9 +59,7 @@ markus.oberhumer@jk.uni-linz.ac.at */ - -#ifndef __LZO1X_H -#define __LZO1X_H +#pragma once #include "lzoconf.h" @@ -121,8 +119,6 @@ lzo1x_999_compress ( const lzo_byte *src, lzo_uint src_len, //} /* extern "C" */ //#endif -#endif /* already included */ - /* vi:ts=4 */ diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzo1x_d.cpp b/Core/Libraries/Source/WWVegas/WWLib/lzo1x_d.cpp index 4e02b39b33..40a3d374a9 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzo1x_d.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/lzo1x_d.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/LZO1X_D.CPP $* + * $Archive:: /Commando/Library/LZO1X_D.cpp $* * * * $Author:: Greg_h $* * * @@ -34,7 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -/* $Header: /Commando/Library/LZO1X_D.CPP 1 7/22/97 12:00p Greg_h $ */ +/* $Header: /Commando/Library/LZO1X_D.cpp 1 7/22/97 12:00p Greg_h $ */ /* lzo1x_d.c -- standalone LZO1X decompressor This file is part of the LZO real-time data compression library. diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzo_conf.h b/Core/Libraries/Source/WWVegas/WWLib/lzo_conf.h index b6be1cfb92..d1e3e2b84f 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzo_conf.h +++ b/Core/Libraries/Source/WWVegas/WWLib/lzo_conf.h @@ -65,9 +65,7 @@ to change. */ - -#ifndef __LZO_CONF_H -#define __LZO_CONF_H +#pragma once #ifndef __LZOCONF_H # include "lzoconf.h" @@ -202,7 +200,7 @@ /* Help the optimizer with register allocation. * Don't activate this macro for a fair comparision with other algorithms. */ -#if 1 && defined(NDEBUG) && !defined(__BOUNDS_CHECKING_ON) +#if 1 && defined(RTS_RELEASE) && !defined(__BOUNDS_CHECKING_ON) # if defined(__GNUC__) && defined(__i386__) # if !defined(LZO_OPTIMIZE_GNUC_i386_IS_BUGGY) # define LZO_OPTIMIZE_GNUC_i386 @@ -296,9 +294,6 @@ -#endif /* already included */ - /* vi:ts=4 */ - diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzoconf.h b/Core/Libraries/Source/WWVegas/WWLib/lzoconf.h index 60abbe6a52..b3bf5e85e9 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzoconf.h +++ b/Core/Libraries/Source/WWVegas/WWLib/lzoconf.h @@ -59,9 +59,7 @@ markus.oberhumer@jk.uni-linz.ac.at */ - -#ifndef __LZOCONF_H -#define __LZOCONF_H +#pragma once #define LZO_VERSION 0x0200 #define LZO_VERSION_STRING "0.20" @@ -228,8 +226,6 @@ LZO_EXTERN(int) _lzo_config_check(void); //} /* extern "C" */ //#endif -#endif /* already included */ - /* vi:ts=4 */ diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzopipe.cpp b/Core/Libraries/Source/WWVegas/WWLib/lzopipe.cpp index 73595f8f62..543aa56e25 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzopipe.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/lzopipe.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/LZOPIPE.CPP $* + * $Archive:: /Commando/Library/LZOPIPE.cpp $* * * * $Author:: Greg_h $* * * @@ -40,7 +40,7 @@ #include "always.h" -#include "BUFF.H" +#include "BUFF.h" #include "lzo.h" #include "lzopipe.h" #include diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzopipe.h b/Core/Libraries/Source/WWVegas/WWLib/lzopipe.h index 7422c66d1d..6faabfe1a9 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzopipe.h +++ b/Core/Libraries/Source/WWVegas/WWLib/lzopipe.h @@ -34,10 +34,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef LZOPIPE_H -#define LZOPIPE_H +#pragma once -#include "PIPE.H" +#include "PIPE.h" /* @@ -97,6 +96,3 @@ class LZOPipe : public Pipe LZOPipe(LZOPipe & rvalue); LZOPipe & operator = (LZOPipe const & pipe); }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzostraw.cpp b/Core/Libraries/Source/WWVegas/WWLib/lzostraw.cpp index bfeca0a533..f618454749 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzostraw.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/lzostraw.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/LZOSTRAW.CPP $* + * $Archive:: /Commando/Library/LZOSTRAW.cpp $* * * * $Author:: Greg_h $* * * diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzostraw.h b/Core/Libraries/Source/WWVegas/WWLib/lzostraw.h index 9e9c4e17cd..862cf4d73e 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzostraw.h +++ b/Core/Libraries/Source/WWVegas/WWLib/lzostraw.h @@ -34,11 +34,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef LZOSTRAW_H -#define LZOSTRAW_H +#pragma once - -#include "STRAW.H" +#include "STRAW.h" /* ** This class handles LZO compression/decompression to the data stream that is drawn through @@ -98,6 +96,3 @@ class LZOStraw : public Straw LZOStraw(LZOStraw & rvalue); LZOStraw & operator = (LZOStraw const & pipe); }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/md5.h b/Core/Libraries/Source/WWVegas/WWLib/md5.h index 2174d60661..7f41840f42 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/md5.h +++ b/Core/Libraries/Source/WWVegas/WWLib/md5.h @@ -16,7 +16,7 @@ ** along with this program. If not, see . */ -/* MD5.H - header file for MD5C.C +/* MD5.h - header file for MD5C.C */ /* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All diff --git a/Core/Libraries/Source/WWVegas/WWLib/mempool.h b/Core/Libraries/Source/WWVegas/WWLib/mempool.h index 0504439c2d..3eae0cf003 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/mempool.h +++ b/Core/Libraries/Source/WWVegas/WWLib/mempool.h @@ -42,13 +42,7 @@ * AutoPoolClass::operator delete -- overriden delete which calls the internal ObjectPool * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef MEMPOOL_H -#define MEMPOOL_H #include "bittype.h" #include "wwdebug.h" @@ -373,7 +367,3 @@ void AutoPoolClass::operator delete( void * memory ) if ( memory == 0 ) return; Allocator.Free_Object_Memory((T*)memory); } - - - -#endif // MEMPOOL_H diff --git a/Core/Libraries/Source/WWVegas/WWLib/mmsys.h b/Core/Libraries/Source/WWVegas/WWLib/mmsys.h index 2298e005f4..caf5335dc0 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/mmsys.h +++ b/Core/Libraries/Source/WWVegas/WWLib/mmsys.h @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef MMSYS_H -#define MMSYS_H +#pragma once /* ** This header just includes mmsystem.h with warning 4201 disabled @@ -47,5 +43,3 @@ #pragma warning(disable:4201) #include #pragma warning(default:4201) - -#endif // MMSYS_H diff --git a/Core/Libraries/Source/WWVegas/WWLib/mpu.cpp b/Core/Libraries/Source/WWVegas/WWLib/mpu.cpp index 5bbc1ac50d..f6da2de667 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/mpu.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/mpu.cpp @@ -37,7 +37,7 @@ #include "always.h" #include "win.h" -#include "MPU.H" +#include "MPU.h" #include "math.h" #include #include diff --git a/Core/Libraries/Source/WWVegas/WWLib/multilist.h b/Core/Libraries/Source/WWVegas/WWLib/multilist.h index 0ab054e1d5..f99c5613e5 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/multilist.h +++ b/Core/Libraries/Source/WWVegas/WWLib/multilist.h @@ -36,13 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef MULTILIST_H -#define MULTILIST_H #include "always.h" #include "mempool.h" @@ -530,7 +524,3 @@ class PriorityMultiListIterator : public MultiListIterator MultiListNodeClass * OriginalHead; }; - - -#endif //LIST_CLASS_H - diff --git a/Core/Libraries/Source/WWVegas/WWLib/mutex.h b/Core/Libraries/Source/WWVegas/WWLib/mutex.h index 06f2a6d310..cce5055f47 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/mutex.h +++ b/Core/Libraries/Source/WWVegas/WWLib/mutex.h @@ -16,12 +16,7 @@ ** along with this program. If not, see . */ -#ifndef MUTEX_H -#define MUTEX_H - -#if defined(_MSC_VER) #pragma once -#endif #include "always.h" #include "thread.h" @@ -205,5 +200,3 @@ class FastCriticalSectionClass friend class LockClass; }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/noinit.h b/Core/Libraries/Source/WWVegas/WWLib/noinit.h index efa714de2c..dfbe3b1573 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/noinit.h +++ b/Core/Libraries/Source/WWVegas/WWLib/noinit.h @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef NOINIT_H -#define NOINIT_H +#pragma once /********************************************************************** ** This class is solely used as a parameter to a constructor that does @@ -52,6 +51,3 @@ class NoInitClass { void operator () (void) const {}; }; #endif - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/notifier.h b/Core/Libraries/Source/WWVegas/WWLib/notifier.h index 696224bcd2..97aaca0831 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/notifier.h +++ b/Core/Libraries/Source/WWVegas/WWLib/notifier.h @@ -35,8 +35,7 @@ * 06/28/02 KM Notify name change to avoid MAX conflicts * ******************************************************************************/ -#ifndef __NOTIFY_H__ -#define __NOTIFY_H__ +#pragma once // Reduce warning level for STL #if defined(_MSC_VER) @@ -89,7 +88,7 @@ template class Observer //! Stop observing event void StopObserving() { - while (mNotifiers.size() > 0) + while (!mNotifiers.empty()) { Notifier* notifier = mNotifiers.back(); assert(notifier && "ERROR: NULL pointer in collection."); @@ -272,5 +271,3 @@ class TypedEventPair A mItemA; B mItemB; }; - -#endif // __NOTIFY_H__ diff --git a/Core/Libraries/Source/WWVegas/WWLib/nstrdup.cpp b/Core/Libraries/Source/WWVegas/WWLib/nstrdup.cpp index 685106a3e2..82aee8ade4 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/nstrdup.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/nstrdup.cpp @@ -37,7 +37,6 @@ #include "always.h" -#include "string.h" #include "nstrdup.h" //#include "../app/main/gnew.h" diff --git a/Core/Libraries/Source/WWVegas/WWLib/nstrdup.h b/Core/Libraries/Source/WWVegas/WWLib/nstrdup.h index 5c8c5dc850..5419dc2177 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/nstrdup.h +++ b/Core/Libraries/Source/WWVegas/WWLib/nstrdup.h @@ -33,17 +33,7 @@ *-------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __NSTRDUP_H__ -#define __NSTRDUP_H__ char * nstrdup(const char *str); - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/ntree.h b/Core/Libraries/Source/WWVegas/WWLib/ntree.h index 2d9d796216..075bfd9e0b 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ntree.h +++ b/Core/Libraries/Source/WWVegas/WWLib/ntree.h @@ -34,16 +34,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __NTREE_H -#define __NTREE_H - -#include "refcount.h" +#include "always.h" #include "wwstring.h" @@ -564,5 +557,3 @@ void SortedNTreeLeafClass::Insertion_Sort (SortedNTreeLeafClass *start, So return ; } - -#endif //__NTREE_H diff --git a/Core/Libraries/Source/WWVegas/WWLib/pipe.cpp b/Core/Libraries/Source/WWVegas/WWLib/pipe.cpp index 520bf267c3..cbd752ee09 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/pipe.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/pipe.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /G/wwlib/PIPE.CPP $* + * $Archive:: /G/wwlib/PIPE.cpp $* * * * $Author:: Eric_c $* * * @@ -40,9 +40,8 @@ #include "always.h" -#include "PIPE.H" +#include "PIPE.h" #include -//#include /*********************************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WWLib/ramfile.cpp b/Core/Libraries/Source/WWVegas/WWLib/ramfile.cpp index affb1eb81c..98de513cf4 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ramfile.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/ramfile.cpp @@ -48,8 +48,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" -#include "RAMFILE.H" -#include +#include "RAMFILE.h" /*********************************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WWLib/random.cpp b/Core/Libraries/Source/WWVegas/WWLib/random.cpp index 7166a4bdbb..3ebbd227e8 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/random.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/random.cpp @@ -44,7 +44,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" -#include "RANDOM.H" +#include "RANDOM.h" // Timing tests for random these random number generators in seconds for // 10000000 iterations. Testing done by Hector Yee, 6/20/01 diff --git a/Core/Libraries/Source/WWVegas/WWLib/rawfile.cpp b/Core/Libraries/Source/WWVegas/WWLib/rawfile.cpp index 15412e42ba..f282d3ee30 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/rawfile.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/rawfile.cpp @@ -53,11 +53,9 @@ // TheSuperHackers @build feliwir 11/04/2025 We removed Win32 API here and use plain C #include "always.h" -#include "RAWFILE.H" +#include "RAWFILE.h" #include -#include #include -#include #include #include #include @@ -69,7 +67,7 @@ ** This is a duplicate of the error numbers. The error handler for the RawFileClass handles ** these errors. If the error routine is overridden and additional errors are defined, then ** use numbers starting with 100. Note that these errors here are listed in numerical order. - ** These errors are defined in the standard header file "ERRNO.H". + ** These errors are defined in the standard header file "ERRNO.h". */ EZERO, // Non-error. EINVFNC, // Invalid function number. @@ -179,7 +177,7 @@ bool RawFileClass::Is_Open(void) const * Display an error message as indicated. If it is allowed to retry, then pressing a key * * will return from this function. Otherwise, it will exit the program with "exit()". * * * - * INPUT: error -- The error number (same as the DOSERR.H error numbers). * + * INPUT: error -- The error number (same as the DOSERR.h error numbers). * * * * canretry -- Can this routine exit normally so that retrying can occur? If this is * * false, then the program WILL exit in this routine. * diff --git a/Core/Libraries/Source/WWVegas/WWLib/rcfile.cpp b/Core/Libraries/Source/WWVegas/WWLib/rcfile.cpp index 2f8b0cb458..5462b80398 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/rcfile.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/rcfile.cpp @@ -65,16 +65,14 @@ ResourceFileClass::ResourceFileClass(HMODULE hmodule, char const *filename) : ResourceFileClass::~ResourceFileClass(void) { - if (ResourceName) - free(ResourceName); + free(ResourceName); } char const * ResourceFileClass::Set_Name(char const *filename) { - if (ResourceName) { - free(ResourceName); - ResourceName = NULL; - } + free(ResourceName); + ResourceName = NULL; + if (filename) { ResourceName = strdup(filename); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/rcfile.h b/Core/Libraries/Source/WWVegas/WWLib/rcfile.h index 5fc6289eb4..6217f09062 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/rcfile.h +++ b/Core/Libraries/Source/WWVegas/WWLib/rcfile.h @@ -34,15 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef RCFILE_H -#define RCFILE_H #include "always.h" -#include "WWFILE.H" +#include "WWFILE.h" #include "win.h" /* @@ -91,6 +86,3 @@ class ResourceFileClass : public FileClass unsigned char * EndOfFile; }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/readline.cpp b/Core/Libraries/Source/WWVegas/WWLib/readline.cpp index 4ae761237a..25112a4745 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/readline.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/readline.cpp @@ -40,10 +40,8 @@ #include "always.h" #include "readline.h" #include "trim.h" -#include "WWFILE.H" -#include "XSTRAW.H" -//#include -#include +#include "WWFILE.h" +#include "XSTRAW.h" #if !defined(__BORLANDC__) && !defined(_MSC_VER) diff --git a/Core/Libraries/Source/WWVegas/WWLib/readline.h b/Core/Libraries/Source/WWVegas/WWLib/readline.h index c0d8790c4c..1a9f019cc5 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/readline.h +++ b/Core/Libraries/Source/WWVegas/WWLib/readline.h @@ -33,19 +33,13 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef READLINE_H -#define READLINE_H +#pragma once -#include "STRAW.H" -#include "WWFILE.H" +#include "STRAW.h" +#include "WWFILE.h" #include int Read_Line(FileClass & file, char * buffer, int len, bool & eof); int Read_Line(Straw & file, char * buffer, int len, bool & eof); int Read_Line(Straw & file, wchar_t * buffer, int len, bool & eof); - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/realcrc.h b/Core/Libraries/Source/WWVegas/WWLib/realcrc.h index 347d962c00..c858e5f583 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/realcrc.h +++ b/Core/Libraries/Source/WWVegas/WWLib/realcrc.h @@ -33,17 +33,9 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef REALCRC_H -#define REALCRC_H +#pragma once unsigned long CRC_Memory( const unsigned char *data, unsigned long length, unsigned long crc = 0 ); unsigned long CRC_String( const char *string, unsigned long crc = 0 ); unsigned long CRC_Stringi( const char *string, unsigned long crc = 0 ); - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/ref_ptr.h b/Core/Libraries/Source/WWVegas/WWLib/ref_ptr.h index aa2495ac1e..b7063138d0 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ref_ptr.h +++ b/Core/Libraries/Source/WWVegas/WWLib/ref_ptr.h @@ -34,18 +34,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif -#ifndef REF_PTR_H -#define REF_PTR_H - -#ifndef ALWAYS_H #include "always.h" -#endif - #include "wwdebug.h" /* @@ -452,5 +443,3 @@ RefCountPtr Static_Cast(const RefCountPtr & base) { return RefCountPtr::Create_AddRef((Derived *)base.Peek()); } - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/refcount.cpp b/Core/Libraries/Source/WWVegas/WWLib/refcount.cpp index 39d746f15e..01f16cc45c 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/refcount.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/refcount.cpp @@ -44,7 +44,7 @@ // TheSuperHackers @build feliwir 17/04/2025 include __debugbreak macros #include -#ifndef NDEBUG +#ifdef RTS_DEBUG // #define PARANOID_REFCOUNTS @@ -161,14 +161,12 @@ void RefCountClass::Inc_Total_Refs(const RefCountClass * obj) assert(Validate_Active_Ref(obj)); #endif TotalRefs++; - } // SKB 7/21/99 Set BreakOnRefernce to a pointer and it will break when called. // This is used for debugging, please do not deleted. RefCountClass* BreakOnReference = 0; -#ifndef NDEBUG void RefCountClass::Add_Ref(void) const { NumRefs++; @@ -179,7 +177,6 @@ void RefCountClass::Add_Ref(void) const } Inc_Total_Refs(this); } -#endif /*********************************************************************************************** * RefCountClass::Validate_Active_Ref -- decrements the total reference count * @@ -206,8 +203,4 @@ void RefCountClass::Dec_Total_Refs(const RefCountClass * obj) } } - - -#endif - - +#endif // RTS_DEBUG diff --git a/Core/Libraries/Source/WWVegas/WWLib/refcount.h b/Core/Libraries/Source/WWVegas/WWLib/refcount.h index ef3f3753dd..9e39b9ba02 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/refcount.h +++ b/Core/Libraries/Source/WWVegas/WWLib/refcount.h @@ -33,27 +33,17 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef REFCOUNT_H -#define REFCOUNT_H -#ifndef ALWAYS_H -#include "always.h" -#endif +#pragma once -#ifndef LISTNODE_H -#include "LISTNODE.H" -#endif +#include "LISTNODE.h" +#include "WWDebug/wwdebug.h" -#include "wwdebug.h" class RefCountClass; -#ifndef NDEBUG +#ifdef RTS_DEBUG struct ActiveRefStruct { @@ -61,15 +51,7 @@ struct ActiveRefStruct int Line; }; -#define NEW_REF( C, P ) ( (C*)RefCountClass::Set_Ref_Owner( W3DNEW C P, __FILE__, __LINE__ ) ) -#define SET_REF_OWNER( P ) ( RefCountClass::Set_Ref_Owner( P, __FILE__, __LINE__ ) ) - -#else - -#define NEW_REF( C, P ) ( W3DNEW C P ) -#define SET_REF_OWNER( P ) P - -#endif +#endif // RTS_DEBUG /* @@ -79,7 +61,7 @@ struct ActiveRefStruct ** point it at the new object, and add-ref the new object (if its not null...) */ #define REF_PTR_SET(dst,src) { if (src) (src)->Add_Ref(); if (dst) (dst)->Release_Ref(); (dst) = (src); } -#define REF_PTR_RELEASE(x) { if (x) x->Release_Ref(); x = NULL; } +#define REF_PTR_RELEASE(x) { if (x) x->Release_Ref(); x = nullptr; } /* @@ -111,31 +93,31 @@ class RefCountClass { public: - RefCountClass(void) : - NumRefs(1) - #ifndef NDEBUG - ,ActiveRefNode(this) - #endif + RefCountClass(void) + : NumRefs(1) +#ifdef RTS_DEBUG + , ActiveRefNode(this) +#endif { - #ifndef NDEBUG +#ifdef RTS_DEBUG Add_Active_Ref(this); Inc_Total_Refs(this); - #endif +#endif } /* ** The reference counter value cannot be copied. */ - RefCountClass(const RefCountClass & ) : - NumRefs(1) - #ifndef NDEBUG - ,ActiveRefNode(this) - #endif + RefCountClass(const RefCountClass & ) + : NumRefs(1) +#ifdef RTS_DEBUG + , ActiveRefNode(this) +#endif { - #ifndef NDEBUG +#ifdef RTS_DEBUG Add_Active_Ref(this); Inc_Total_Refs(this); - #endif +#endif } RefCountClass& operator=(const RefCountClass&) { return *this; } @@ -144,24 +126,26 @@ class RefCountClass ** Add_Ref, call this function if you are going to keep a pointer ** to this object. */ -#ifdef NDEBUG - WWINLINE void Add_Ref(void) const { NumRefs++; } -#else +#ifdef RTS_DEBUG void Add_Ref(void) const; +#else + void Add_Ref(void) const { NumRefs++; } #endif /* ** Release_Ref, call this function when you no longer need the pointer ** to this object. */ - WWINLINE void Release_Ref(void) const { - #ifndef NDEBUG - Dec_Total_Refs(this); - #endif - NumRefs--; - WWASSERT(NumRefs >= 0); - if (NumRefs == 0) const_cast(this)->Delete_This(); - } + void Release_Ref(void) const + { +#ifdef RTS_DEBUG + Dec_Total_Refs(this); +#endif + NumRefs--; + WWASSERT(NumRefs >= 0); + if (NumRefs == 0) + const_cast(this)->Delete_This(); + } /* @@ -190,9 +174,9 @@ class RefCountClass */ virtual ~RefCountClass(void) { - #ifndef NDEBUG +#ifdef RTS_DEBUG Remove_Active_Ref(this); - #endif +#endif WWASSERT(NumRefs == 0); } @@ -221,7 +205,7 @@ class RefCountClass public: -#ifndef NDEBUG // Debugging stuff +#ifdef RTS_DEBUG // Debugging stuff /* ** Node in the Active Refs List @@ -258,7 +242,7 @@ class RefCountClass */ static bool Validate_Active_Ref(RefCountClass * obj); -#endif // NDEBUG +#endif // RTS_DEBUG }; @@ -329,6 +313,3 @@ class RefCountValue mutable IntegerType NumRefs; }; - - -#endif // REFCOUNT_H diff --git a/Core/Libraries/Source/WWVegas/WWLib/regexpr.h b/Core/Libraries/Source/WWVegas/WWLib/regexpr.h index 85dba66f7b..307ae03974 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/regexpr.h +++ b/Core/Libraries/Source/WWVegas/WWLib/regexpr.h @@ -18,13 +18,7 @@ // regexpr.h -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef REGEXPR_H -#define REGEXPR_H - /* ** RegularExpressionClass - This class encapsulates regular expression @@ -76,7 +70,3 @@ class RegularExpressionClass struct DataStruct; DataStruct *Data; }; - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWLib/registry.cpp b/Core/Libraries/Source/WWVegas/WWLib/registry.cpp index cabbd36243..15ec71602f 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/registry.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/registry.cpp @@ -34,8 +34,8 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "registry.h" -#include "RAWFILE.H" -#include "INI.H" +#include "RAWFILE.h" +#include "INI.h" #include "inisup.h" #include #include @@ -386,7 +386,7 @@ void RegistryClass::Save_Registry_Values(HKEY key, char *path, INIClass *ini) */ case REG_DWORD: strcpy(save_name, "DWORD_"); - strcat(save_name, value_name); + strlcat(save_name, value_name, ARRAY_SIZE(save_name)); ini->Put_Int(path, save_name, *((unsigned long*)data)); break; @@ -395,7 +395,7 @@ void RegistryClass::Save_Registry_Values(HKEY key, char *path, INIClass *ini) */ case REG_SZ: strcpy(save_name, "STRING_"); - strcat(save_name, value_name); + strlcat(save_name, value_name, ARRAY_SIZE(save_name)); ini->Put_String(path, save_name, (char*)data); break; @@ -404,7 +404,7 @@ void RegistryClass::Save_Registry_Values(HKEY key, char *path, INIClass *ini) */ case REG_BINARY: strcpy(save_name, "BIN_"); - strcat(save_name, value_name); + strlcat(save_name, value_name, ARRAY_SIZE(save_name)); ini->Put_UUBlock(path, save_name, (char*)data, data_size); break; @@ -470,9 +470,9 @@ void RegistryClass::Save_Registry_Tree(char *path, INIClass *ini) ** See if there are sub keys. */ char new_key_path[512]; - strcpy(new_key_path, path); - strcat(new_key_path, "\\"); - strcat(new_key_path, name); + strlcpy(new_key_path, path, ARRAY_SIZE(new_key_path)); + strlcat(new_key_path, "\\", ARRAY_SIZE(new_key_path)); + strlcat(new_key_path, name, ARRAY_SIZE(new_key_path)); unsigned long num_subs = 0; unsigned long num_values = 0; @@ -564,10 +564,10 @@ void RegistryClass::Load_Registry(const char *filename, char *old_path, char *ne ** Build the new path to use in the registry. */ char *section_name = section->Section; - strcpy(path, new_path); + strlcpy(path, new_path, ARRAY_SIZE(path)); char *cut = strstr(section_name, old_path); if (cut) { - strcat(path, cut + old_path_len); + strlcat(path, cut + old_path_len, ARRAY_SIZE(path)); } /* @@ -693,9 +693,9 @@ void RegistryClass::Delete_Registry_Tree(char *path) ** See if there are sub keys. */ char new_key_path[512]; - strcpy(new_key_path, path); - strcat(new_key_path, "\\"); - strcat(new_key_path, name); + strlcpy(new_key_path, path, ARRAY_SIZE(new_key_path)); + strlcat(new_key_path, "\\", ARRAY_SIZE(new_key_path)); + strlcat(new_key_path, name, ARRAY_SIZE(new_key_path)); unsigned long num_subs = 0; unsigned long num_values = 0; diff --git a/Core/Libraries/Source/WWVegas/WWLib/registry.h b/Core/Libraries/Source/WWVegas/WWLib/registry.h index ce257aca8b..0e83f40f89 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/registry.h +++ b/Core/Libraries/Source/WWVegas/WWLib/registry.h @@ -33,18 +33,10 @@ *---------------------------------------------------------------------------------------------* * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 -#ifndef REGISTRY_H -#define REGISTRY_H - -#ifndef ALWAYS_H #include "always.h" -#endif - -#include "Vector.H" +#include "Vector.h" #include "wwstring.h" #include "widestring.h" @@ -123,5 +115,3 @@ class RegistryClass { // static bool IsLocked; }; - -#endif // REGISTRY_H diff --git a/Core/Libraries/Source/WWVegas/WWLib/search.h b/Core/Libraries/Source/WWVegas/WWLib/search.h index c2c4beb189..35a7d9032e 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/search.h +++ b/Core/Libraries/Source/WWVegas/WWLib/search.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/SEARCH.H $* + * $Archive:: /Commando/Library/SEARCH.h $* * * * $Author:: Greg_h $* * * @@ -49,8 +49,7 @@ * compfunc -- Support function for bsearch and bsort. * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef SEARCH_H -#define SEARCH_H +#pragma once /* ** The "bool" integral type was defined by the C++ comittee in @@ -692,8 +691,3 @@ IndexClass::NodeElement const * IndexClass::Search_For_Node(int id) const node.ID = id; return((NodeElement const *)bsearch(&node, &IndexTable[0], IndexCount, sizeof(IndexTable[0]), search_compfunc)); } - - -#endif - - diff --git a/Core/Libraries/Source/WWVegas/WWLib/sharebuf.h b/Core/Libraries/Source/WWVegas/WWLib/sharebuf.h index 61950b1d1b..05f75027b6 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/sharebuf.h +++ b/Core/Libraries/Source/WWVegas/WWLib/sharebuf.h @@ -33,13 +33,10 @@ *-------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 + #pragma once -#endif // _MSC_VER >= 1000 -#ifndef SHAREBUF_H -#define SHAREBUF_H -#include "refcount.h" +#include "always.h" /* @@ -115,10 +112,8 @@ ShareBufferClass::ShareBufferClass(const ShareBufferClass & that) : template ShareBufferClass::~ShareBufferClass(void) { - if (Array) { - delete[] Array; - Array = NULL; - } + delete[] Array; + Array = NULL; } template @@ -146,6 +141,3 @@ void ShareBufferClass::Clear(void) { memset(Array,0,Count * sizeof(T)); } - - -#endif // SHAREBUF_H diff --git a/Core/Libraries/Source/WWVegas/WWLib/simplevec.h b/Core/Libraries/Source/WWVegas/WWLib/simplevec.h index 0448523205..ae2c6bc5a7 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/simplevec.h +++ b/Core/Libraries/Source/WWVegas/WWLib/simplevec.h @@ -47,16 +47,10 @@ * SimpleDynVecClass::Delete_All -- delete all items from the array * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef SIMPLEVEC_H -#define SIMPLEVEC_H #include "always.h" #include -#include // for memmove #if (_MSC_VER >= 1200) @@ -130,11 +124,9 @@ inline SimpleVecClass::SimpleVecClass(int size) : template inline SimpleVecClass::~SimpleVecClass(void) { - if (Vector != NULL) { - delete[] Vector; - Vector = NULL; - VectorMax = 0; - } + delete[] Vector; + Vector = NULL; + VectorMax = 0; } /*********************************************************************************************** @@ -194,11 +186,9 @@ inline bool SimpleVecClass::Resize(int newsize) /* ** Delete entire vector and reset counts */ + delete[] Vector; + Vector = NULL; VectorMax = 0; - if (Vector != NULL) { - delete[] Vector; - Vector = NULL; - } } return true; } @@ -330,10 +320,8 @@ inline SimpleDynVecClass::SimpleDynVecClass(int size) : template inline SimpleDynVecClass::~SimpleDynVecClass(void) { - if (Vector != NULL) { - delete[] Vector; - Vector = NULL; - } + delete[] Vector; + Vector = NULL; } /*********************************************************************************************** @@ -645,6 +633,3 @@ inline int SimpleDynVecClass::Find_Index(T const & object) #if (_MSC_VER >= 1200) #pragma warning (pop) #endif - -#endif // SIMPLEVEC_H - diff --git a/Core/Libraries/Source/WWVegas/WWLib/slnode.cpp b/Core/Libraries/Source/WWVegas/WWLib/slnode.cpp index 32ea009d52..51240412d1 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/slnode.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/slnode.cpp @@ -34,7 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#include "SLNODE.H" +#include "SLNODE.h" diff --git a/Core/Libraries/Source/WWVegas/WWLib/stimer.h b/Core/Libraries/Source/WWVegas/WWLib/stimer.h index 00d79ae882..5fb4e28c51 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/stimer.h +++ b/Core/Libraries/Source/WWVegas/WWLib/stimer.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/STIMER.H $* + * $Archive:: /Commando/Library/STIMER.h $* * * * $Author:: Greg_h $* * * @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef STIMER_H -#define STIMER_H +#pragma once /**************************************************************************** ** Timer constants. These are used when setting the countdown timer. @@ -61,5 +60,3 @@ class SystemTimerClass long operator () (void) const; operator long (void) const; }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/straw.cpp b/Core/Libraries/Source/WWVegas/WWLib/straw.cpp index a767d77656..a18068ad8e 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/straw.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/straw.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /G/wwlib/STRAW.CPP $* + * $Archive:: /G/wwlib/STRAW.cpp $* * * * $Author:: Eric_c $* * * @@ -38,9 +38,8 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" -#include "STRAW.H" +#include "STRAW.h" #include -//#include /*********************************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WWLib/stringex.h b/Core/Libraries/Source/WWVegas/WWLib/stringex.h new file mode 100644 index 0000000000..8e23b0227a --- /dev/null +++ b/Core/Libraries/Source/WWVegas/WWLib/stringex.h @@ -0,0 +1,302 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2025 TheSuperHackers +** +** 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 . +*/ + +#pragma once + +#include "bittype.h" +#include +#include + + +// Declaration + +template size_t strlen_t(const T *str); +template size_t strnlen_t(const T *str, size_t maxlen); + +#if defined(_MSC_VER) && _MSC_VER < 1300 +size_t strnlen(const char *str, size_t maxlen); +size_t wcsnlen(const wchar_t *str, size_t maxlen); +#endif + +template size_t strlcpy_t(T *dst, const T *src, size_t dstsize); +template size_t strlcat_t(T *dst, const T *src, size_t dstsize); + +size_t strlcpy(char *dst, const char *src, size_t dstsize); +size_t strlcat(char *dst, const char *src, size_t dstsize); +size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t dstsize); +size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t dstsize); + +template size_t strlmove_t(T *dst, const T *src, size_t dstsize); +template size_t strlmcat_t(T *dst, const T *src, size_t dstsize); + +size_t strlmove(char *dst, const char *src, size_t dstsize); +size_t strlmcat(char *dst, const char *src, size_t dstsize); +size_t wcslmove(wchar_t *dst, const wchar_t *src, size_t dstsize); +size_t wcslmcat(wchar_t *dst, const wchar_t *src, size_t dstsize); + +#if !(defined(_MSC_VER) && _MSC_VER < 1300) +template size_t strlcpy_t(char (&dst)[Size], const char *src); +template size_t strlcat_t(char (&dst)[Size], const char *src); +template size_t strlmove_t(char (&dst)[Size], const char *src); +template size_t strlmcat_t(char (&dst)[Size], const char *src); +#endif + +template int strncmp_t(const T *str1, const T *str2, size_t maxcount); +template int strnicmp_t(const T* str1, const T* str2, size_t maxcount); + +template bool startsWith(const T *str, const T *prefix); +template bool startsWithNoCase(const T *str, const T *prefix); +template bool endsWithNoCase(const T *str, const T *suffix); +template bool endsWithNoCase(const T *str, const T *suffix); + + +// Implementation + +// Templated strlen. +// Returns the number of characters until the first zero character. +template size_t strlen_t(const T *str) +{ + const T* begin = str; + while (*str) + ++str; + return static_cast(str - begin); +} + +// Templated strlen. +// Returns the number of characters until the first zero character or when maxlen is reached. +template size_t strnlen_t(const T *str, size_t maxlen) +{ + const T* begin = str; + const T* end = str + maxlen; + while (str < end && *str) + ++str; + return static_cast(str - begin); +} + +#if defined(_MSC_VER) && _MSC_VER < 1300 +inline size_t strnlen(const char *str, size_t maxlen) { return strnlen_t(str, maxlen); } +inline size_t wcsnlen(const wchar_t *str, size_t maxlen) { return strnlen_t(str, maxlen); } +#endif + +// Templated strlcpy. Prefer using this over strncpy. +// Copies src into dst until dstsize minus one. Always null terminates. +// Returns the length of src, excluding the null terminator. +template size_t strlcpy_t(T *dst, const T *src, size_t dstsize) +{ + const size_t srclen = strlen_t(src); + if (dstsize != 0) + { + size_t copylen = (srclen >= dstsize) ? dstsize - 1 : srclen; + memcpy(dst, src, copylen * sizeof(T)); + dst[copylen] = T(0); + } + return srclen; // length tried to create +} + +// Templated strlcat. Prefer using this over strncpy. +// Appends src into dst until dstsize minus one. Always null terminates. +// Returns the length of dst + src, excluding the null terminator. +template size_t strlcat_t(T *dst, const T *src, size_t dstsize) +{ + const size_t dstlen = strnlen_t(dst, dstsize); + const size_t srclen = strlen_t(src); + if (dstlen == dstsize) + { + return dstsize + srclen; // no space to append + } + size_t copylen = dstsize - dstlen - 1; + if (copylen > srclen) + { + copylen = srclen; + } + if (copylen > 0) + { + memcpy(dst + dstlen, src, copylen * sizeof(T)); + dst[dstlen + copylen] = T(0); + } + return dstlen + srclen; // length tried to create +} + +#ifndef HAVE_STRLCPY +inline size_t strlcpy(char *dst, const char *src, size_t dstsize) { return strlcpy_t(dst, src, dstsize); } +#endif +#ifndef HAVE_STRLCAT +inline size_t strlcat(char *dst, const char *src, size_t dstsize) { return strlcat_t(dst, src, dstsize); } +#endif +inline size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t dstsize) { return strlcpy_t(dst, src, dstsize); } +inline size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t dstsize) { return strlcat_t(dst, src, dstsize); } + +// Templated strlmove. Prefer using this over strlcpy if dst and src overlap. +// Moves src into dst until dstsize minus one. Always null terminates. +// Returns the length of src, excluding the null terminator. +template size_t strlmove_t(T *dst, const T *src, size_t dstsize) +{ + const size_t srclen = strlen_t(src); + if (dstsize > 0) + { + size_t copylen = (srclen >= dstsize) ? dstsize - 1 : srclen; + memmove(dst, src, copylen * sizeof(T)); + dst[copylen] = T(0); + } + return srclen; // length tried to create +} + +// Templated strlmcat. Prefer using this over strlcat if dst and src overlap. +// Appends src into dst until dstsize minus one. Always null terminates. +// Returns the length of dst + src, excluding the null terminator. +template size_t strlmcat_t(T *dst, const T *src, size_t dstsize) +{ + const size_t dstlen = strnlen_t(dst, dstsize); + const size_t srclen = strlen_t(src); + if (dstlen == dstsize) + { + return dstsize + srclen; // no space to append + } + size_t copylen = dstsize - dstlen - 1; + if (copylen > srclen) + { + copylen = srclen; + } + if (copylen > 0) + { + memmove(dst + dstlen, src, copylen * sizeof(T)); + dst[dstlen + copylen] = T(0); + } + return dstlen + srclen; // length tried to create +} + +inline size_t strlmove(char *dst, const char *src, size_t dstsize) { return strlmove_t(dst, src, dstsize); } +inline size_t strlmcat(char *dst, const char *src, size_t dstsize) { return strlmcat_t(dst, src, dstsize); } +inline size_t wcslmove(wchar_t *dst, const wchar_t *src, size_t dstsize) { return strlmove_t(dst, src, dstsize); } +inline size_t wcslmcat(wchar_t *dst, const wchar_t *src, size_t dstsize) { return strlmcat_t(dst, src, dstsize); } + +#if !(defined(_MSC_VER) && _MSC_VER < 1300) +template size_t strlcpy_t(char (&dst)[Size], const char *src) { return strlcpy_t(dst, src, Size); } +template size_t strlcat_t(char (&dst)[Size], const char *src) { return strlcat_t(dst, src, Size); } +template size_t strlmove_t(char (&dst)[Size], const char *src) { return strlmove_t(dst, src, Size); } +template size_t strlmcat_t(char (&dst)[Size], const char *src) { return strlmcat_t(dst, src, Size); } +#endif + +// Templated strncmp. +// Compares up to maxcount chars or a null byte is encountered, whichever comes first. +// Returns < 0 if str1 is less than str2, 0 is str1 and str2 are equal and > 0 if str2 is greater than str1. +template int strncmp_t(const T *str1, const T *str2, const size_t maxcount) +{ + for (size_t i = 0; i < maxcount; ++i) + { + const T c1 = str1[i]; + const T c2 = str2[i]; + const int diff = (int)c1 - (int)c2; + if (diff != 0) + { + return diff; + } + if (c1 == T(0)) // both c1 and c2 are null terminators + { + return 0; + } + } + return 0; +} + +// Lower case conversion helpers +inline char tolower_t(char c) +{ + // cast to unsigned char for correct behavior of tolower() + return (char)tolower((unsigned char)c); +} + +inline wchar_t tolower_t(wchar_t c) +{ + return (wchar_t)towlower(c); +} + +// Templated strnicmp. +// Case insensitively compares up to maxcount chars or a null byte is encountered, whichever comes first. +// Returns < 0 if str1 is less than str2, 0 is str1 and str2 are equal and > 0 if str2 is greater than str1. +template int strnicmp_t(const T *str1, const T *str2, const size_t maxcount) +{ + for (size_t i = 0; i < maxcount; ++i) + { + const T c1 = tolower_t(str1[i]); + const T c2 = tolower_t(str2[i]); + const int diff = (int)c1 - (int)c2; + if (diff != 0) + { + return diff; + } + if (c1 == T(0)) // both c1 and c2 are null terminators + { + return 0; + } + } + return 0; +} + +template inline bool startsWith(const T *str, const T *prefix) +{ + if (*prefix == T(0)) + return true; // everything starts with the empty string + + const size_t strlen = strlen_t(str); + const size_t prefixlen = strlen_t(prefix); + if (strlen < prefixlen) + return false; // prefix must be as long or shorter than str + + return strncmp_t(str, prefix, prefixlen) == 0; +} + +template inline bool startsWithNoCase(const T *str, const T *prefix) +{ + if (*prefix == T(0)) + return true; // everything starts with the empty string + + const size_t strlen = strlen_t(str); + const size_t prefixlen = strlen_t(prefix); + if (strlen < prefixlen) + return false; // prefix must be as long or shorter than str + + return strnicmp_t(str, prefix, prefixlen) == 0; +} + +template inline bool endsWith(const T *str, const T *suffix) +{ + if (*suffix == T(0)) + return true; // everything ends with the empty string + + const size_t strlen = strlen_t(str); + const size_t suffixlen = strlen_t(suffix); + if (strlen < suffixlen) + return false; // suffix must be as long or shorter than str + + return strncmp_t(str + strlen - suffixlen, suffix, suffixlen) == 0; +} + +template inline bool endsWithNoCase(const T *str, const T *suffix) +{ + if (*suffix == T(0)) + return true; // everything ends with the empty string + + const size_t strlen = strlen_t(str); + const size_t suffixlen = strlen_t(suffix); + if (strlen < suffixlen) + return false; // suffix must be as long or shorter than str + + return strnicmp_t(str + strlen - suffixlen, suffix, suffixlen) == 0; +} + diff --git a/Core/Libraries/Source/WWVegas/WWLib/strtok_r.cpp b/Core/Libraries/Source/WWVegas/WWLib/strtok_r.cpp index db0ba5b4a2..e9c9faec05 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/strtok_r.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/strtok_r.cpp @@ -36,8 +36,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "strtok_r.h" -#include -#include +#include "stringex.h" // // Replacement for strtok() that doesn't use a static to diff --git a/Core/Libraries/Source/WWVegas/WWLib/strtok_r.h b/Core/Libraries/Source/WWVegas/WWLib/strtok_r.h index 8a75c28c91..0d0d22d691 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/strtok_r.h +++ b/Core/Libraries/Source/WWVegas/WWLib/strtok_r.h @@ -33,19 +33,9 @@ *-------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __STRTOK_R_H__ -#define __STRTOK_R_H__ #ifndef _UNIX char *strtok_r(char *strptr, const char *delimiters, char **lasts); #endif - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/swap.h b/Core/Libraries/Source/WWVegas/WWLib/swap.h index 23587a32cf..b0a61e46c9 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/swap.h +++ b/Core/Libraries/Source/WWVegas/WWLib/swap.h @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef SWAP_H -#define SWAP_H +#pragma once /********************************************************************** ** Swaps two objects. @@ -48,5 +47,3 @@ void swap(T & left, T & right) left = right; right = temp; } - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/systimer.h b/Core/Libraries/Source/WWVegas/WWLib/systimer.h index 64b690fb9c..56db4c64b2 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/systimer.h +++ b/Core/Libraries/Source/WWVegas/WWLib/systimer.h @@ -35,6 +35,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #pragma once + #ifndef _SYSTIMER_H #include "always.h" diff --git a/Core/Libraries/Source/WWVegas/WWLib/textfile.h b/Core/Libraries/Source/WWVegas/WWLib/textfile.h index 5fa6c20935..3bb7076640 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/textfile.h +++ b/Core/Libraries/Source/WWVegas/WWLib/textfile.h @@ -32,15 +32,9 @@ * * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 -#ifndef __TEXT_FILE_H -#define __TEXT_FILE_H - - -#include "RAWFILE.H" +#include "RAWFILE.h" /////////////////////////////////////////////////////////////////////////////// // Forward declarations @@ -79,7 +73,3 @@ class TextFileClass : public RawFileClass bool Read_Line (StringClass &string); bool Write_Line (const StringClass &string); }; - - -#endif //__TEXT_FILE_H - diff --git a/Core/Libraries/Source/WWVegas/WWLib/tgatodxt.cpp b/Core/Libraries/Source/WWVegas/WWLib/tgatodxt.cpp index 08b32557ab..d1db1743cf 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/tgatodxt.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/tgatodxt.cpp @@ -39,7 +39,7 @@ #include "always.h" #include "nvdxtlib.h" -#include "TARGA.H" +#include "TARGA.h" #include "tgatodxt.h" #include "wwdebug.h" #include @@ -191,7 +191,7 @@ TGAToDXTClass::ErrorCode TGAToDXTClass::Convert (const char *inputpathname, cons if (!validsize) error_code = INVALID_SIZE; if (!validaspect) error_code = INVALID_ASPECT_RATIO; } - } // error == 0 + } return error_code; } diff --git a/Core/Libraries/Source/WWVegas/WWLib/tgatodxt.h b/Core/Libraries/Source/WWVegas/WWLib/tgatodxt.h index 140db5f9ab..778b5934a3 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/tgatodxt.h +++ b/Core/Libraries/Source/WWVegas/WWLib/tgatodxt.h @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef TGATODXT_H -#define TGATODXT_H +#pragma once #pragma message ("(gth) disabling TGAtoDXTClass temporarily so I can test the WW libs merge...") #if 0 @@ -81,5 +80,3 @@ class TGAToDXTClass extern TGAToDXTClass _TGAToDXTConverter; #endif //0 - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/thread.cpp b/Core/Libraries/Source/WWVegas/WWLib/thread.cpp index d6cefc030b..aaad589d7f 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/thread.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/thread.cpp @@ -34,10 +34,10 @@ ThreadClass::ThreadClass(const char *thread_name, ExceptionHandlerType exception_handler) : handle(0), running(false), thread_priority(0) { if (thread_name) { - assert(strlen(thread_name) < sizeof(ThreadName) - 1); - strcpy(ThreadName, thread_name); + size_t nameLen = strlcpy(ThreadName, thread_name, ARRAY_SIZE(ThreadName)); + (void)nameLen; assert(nameLen < ARRAY_SIZE(ThreadName)); } else { - strcpy(ThreadName, "No name");; + strcpy(ThreadName, "No name"); } ExceptionHandler = exception_handler; diff --git a/Core/Libraries/Source/WWVegas/WWLib/thread.h b/Core/Libraries/Source/WWVegas/WWLib/thread.h index cd7377e3e0..0f526274c6 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/thread.h +++ b/Core/Libraries/Source/WWVegas/WWLib/thread.h @@ -16,15 +16,10 @@ ** along with this program. If not, see . */ -#ifndef THREAD_H -#define THREAD_H - -#if defined(_MSC_VER) #pragma once -#endif #include "always.h" -#include "Vector.H" +#include "Vector.h" struct _EXCEPTION_POINTERS; @@ -99,5 +94,3 @@ class ThreadClass volatile unsigned long handle; int thread_priority; }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/trect.h b/Core/Libraries/Source/WWVegas/WWLib/trect.h index 3604a5b862..b302888f5f 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/trect.h +++ b/Core/Libraries/Source/WWVegas/WWLib/trect.h @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef TRECT_H -#define TRECT_H +#pragma once #include "Point.h" @@ -219,7 +215,3 @@ TPoint2D const TPoint2D::Bias_To(TRect const & rect) const ** is composed of integers. */ typedef TRect Rect; - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWLib/trim.cpp b/Core/Libraries/Source/WWVegas/WWLib/trim.cpp index 1c8b9db83e..36a39d0211 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/trim.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/trim.cpp @@ -36,7 +36,6 @@ #include "always.h" #include "trim.h" -#include #ifdef _UNIX #include diff --git a/Core/Libraries/Source/WWVegas/WWLib/trim.h b/Core/Libraries/Source/WWVegas/WWLib/trim.h index a2f8fc3100..cdb550eaa9 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/trim.h +++ b/Core/Libraries/Source/WWVegas/WWLib/trim.h @@ -33,16 +33,10 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef TRIM_H -#define TRIM_H +#pragma once #include char * strtrim(char * buffer); wchar_t * wcstrim(wchar_t * buffer); - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/uarray.h b/Core/Libraries/Source/WWVegas/WWLib/uarray.h index d76d526509..ba63093824 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/uarray.h +++ b/Core/Libraries/Source/WWVegas/WWLib/uarray.h @@ -36,21 +36,11 @@ * UniqueArrayClass::~UniqueArrayClass -- destructor * * UniqueArrayClass::Add -- Add an item to the array * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef UARRAY_H -#define UARRAY_H +#pragma once -#ifndef HASHCALC_H #include "hashcalc.h" -#endif - -#ifndef VECTOR_H -#include "Vector.H" -#endif - +#include "Vector.h" /* ** UniqueArrayClass @@ -155,10 +145,8 @@ UniqueArrayClass::UniqueArrayClass(int initial_size,int growth_rate,HashCalcu template UniqueArrayClass::~UniqueArrayClass(void) { - if (HashTable != NULL) { - delete[] HashTable; - HashTable = NULL; - } + delete[] HashTable; + HashTable = NULL; } @@ -222,7 +210,3 @@ inline int UniqueArrayClass::Add(const T & new_item) return index; } - - -#endif // UARRAY_H - diff --git a/Core/Libraries/Source/WWVegas/WWLib/vector.cpp b/Core/Libraries/Source/WWVegas/WWLib/vector.cpp index 801e64928e..f9333e0677 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/vector.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/vector.cpp @@ -53,8 +53,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" -#include "Vector.H" -#include +#include "Vector.h" /* ** The following template function can be located here ONLY if all the instantiations are diff --git a/Core/Libraries/Source/WWVegas/WWLib/verchk.cpp b/Core/Libraries/Source/WWVegas/WWLib/verchk.cpp index e6969e7664..6aa6cc4af8 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/verchk.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/verchk.cpp @@ -38,7 +38,7 @@ #include "verchk.h" #include #include -#include "RAWFILE.H" +#include "RAWFILE.h" #include "ffactory.h" diff --git a/Core/Libraries/Source/WWVegas/WWLib/verchk.h b/Core/Libraries/Source/WWVegas/WWLib/verchk.h index b5040cddff..2dbebead96 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/verchk.h +++ b/Core/Libraries/Source/WWVegas/WWLib/verchk.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __VERCHK_H -#define __VERCHK_H #include @@ -63,7 +57,3 @@ bool GetFileCreationTime(char* filename, FILETIME* createTime); // //////////////////////////////////////////////////////////////////////// int Compare_EXE_Version (int app_instance, const char *filename); - - -#endif //__VERCHK_H - diff --git a/Core/Libraries/Source/WWVegas/WWLib/visualc.h b/Core/Libraries/Source/WWVegas/WWLib/visualc.h index 1b325f0c01..a400314d91 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/visualc.h +++ b/Core/Libraries/Source/WWVegas/WWLib/visualc.h @@ -33,9 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 + #pragma once -#endif // _MSC_VER >= 1000 #if defined(_MSC_VER) diff --git a/Core/Libraries/Source/WWVegas/WWLib/widestring.cpp b/Core/Libraries/Source/WWVegas/WWLib/widestring.cpp index 69b1724e45..41cbb495ea 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/widestring.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/widestring.cpp @@ -38,7 +38,6 @@ #include "widestring.h" #include "win.h" -#include /////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWLib/widestring.h b/Core/Libraries/Source/WWVegas/WWLib/widestring.h index ef8c1fa983..3f08f9c356 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/widestring.h +++ b/Core/Libraries/Source/WWVegas/WWLib/widestring.h @@ -34,14 +34,8 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif -#ifndef __WIDESTRING_H -#define __WIDESTRING_H - -#include #include #include "always.h" #include "wwdebug.h" @@ -778,6 +772,3 @@ WideStringClass::Convert_To (StringClass &string) const { return (string.Copy_Wide (m_Buffer)); } - -#endif //__WIDESTRING_H - diff --git a/Core/Libraries/Source/WWVegas/WWLib/win.h b/Core/Libraries/Source/WWVegas/WWLib/win.h index 4b36eb64f6..70ef32dc39 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/win.h +++ b/Core/Libraries/Source/WWVegas/WWLib/win.h @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef WIN_H -#define WIN_H +#pragma once /* ** This header file includes the Windows headers. If there are any special pragmas that need @@ -88,5 +84,3 @@ void __cdecl Print_Win32Error(unsigned long win32Error); #else // _WIN32 //#include // file does not exist #endif // _WIN32 - -#endif // WIN_H diff --git a/Core/Libraries/Source/WWVegas/WWLib/wwfile.cpp b/Core/Libraries/Source/WWVegas/WWLib/wwfile.cpp index 3e1cbb7afc..c59d2af124 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/wwfile.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/wwfile.cpp @@ -37,7 +37,7 @@ #include #include #include -#include "WWFILE.H" +#include "WWFILE.h" #pragma warning(disable : 4514) diff --git a/Core/Libraries/Source/WWVegas/WWLib/wwstring.cpp b/Core/Libraries/Source/WWVegas/WWLib/wwstring.cpp index 54143fd640..f4da1100c4 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/wwstring.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/wwstring.cpp @@ -37,7 +37,6 @@ #include "wwstring.h" #include "wwmemlog.h" #include "mutex.h" -#include /////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWLib/wwstring.h b/Core/Libraries/Source/WWVegas/WWLib/wwstring.h index 113b7072a6..3a5745163b 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/wwstring.h +++ b/Core/Libraries/Source/WWVegas/WWLib/wwstring.h @@ -34,17 +34,11 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __WWSTRING_H -#define __WWSTRING_H #include "always.h" #include "mutex.h" #include "win.h" -#include #include #include "trim.h" #include "wwdebug.h" @@ -778,6 +772,3 @@ StringClass::Store_Length (int length) return ; } - -#endif //__WWSTRING_H - diff --git a/Core/Libraries/Source/WWVegas/WWLib/xpipe.cpp b/Core/Libraries/Source/WWVegas/WWLib/xpipe.cpp index b3fc9acc4a..15e310c9e6 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/xpipe.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/xpipe.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Code/Library/XPIPE.CPP $* + * $Archive:: /Commando/Code/Library/XPIPE.cpp $* * * * $Author:: Greg_h $* * * @@ -39,9 +39,8 @@ #include "always.h" -#include "XPIPE.H" +#include "XPIPE.h" #include -#include //--------------------------------------------------------------------------------------------------------- diff --git a/Core/Libraries/Source/WWVegas/WWLib/xstraw.cpp b/Core/Libraries/Source/WWVegas/WWLib/xstraw.cpp index f82fb99479..d567c0421c 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/xstraw.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/xstraw.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Code/Library/XSTRAW.CPP $* + * $Archive:: /Commando/Code/Library/XSTRAW.cpp $* * * * $Author:: Greg_h $* * * @@ -38,9 +38,8 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" -#include "XSTRAW.H" +#include "XSTRAW.h" #include -#include //--------------------------------------------------------------------------------------------------------- // BufferStraw diff --git a/Core/Libraries/Source/WWVegas/WWMath/Vector3i.h b/Core/Libraries/Source/WWVegas/WWMath/Vector3i.h index 970ab28881..d91f87b6c4 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/Vector3i.h +++ b/Core/Libraries/Source/WWVegas/WWMath/Vector3i.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef VECTOR3I_H -#define VECTOR3I_H #include "always.h" @@ -139,5 +133,3 @@ WWINLINE unsigned short & Vector3i16::operator[] (int n) { return ((unsigned short *)this)[n]; } - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/aabox.h b/Core/Libraries/Source/WWVegas/WWMath/aabox.h index 8741c5844a..eb0b29669f 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/aabox.h +++ b/Core/Libraries/Source/WWVegas/WWMath/aabox.h @@ -52,12 +52,7 @@ * AABoxClass::Init -- Init from a line segment * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef AABOX_H -#define AABOX_H #include "always.h" #include "matrix3d.h" @@ -674,6 +669,3 @@ WWINLINE void MinMaxAABoxClass::Translate(const Vector3 & pos) MinCorner+=pos; MaxCorner+=pos; } - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.cpp b/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.cpp index 9b38d85301..d4f12ff585 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.cpp @@ -38,7 +38,6 @@ #include "aabtreecull.h" #include "chunkio.h" #include "iostruct.h" -#include #include "sphere.h" #include "colmath.h" #include "colmathinlines.h" @@ -133,10 +132,8 @@ AABTreeCullSystemClass::~AABTreeCullSystemClass(void) delete RootNode; // Delete indexed node pointer array - if (IndexedNodes) { - delete[] IndexedNodes; - IndexedNodes = NULL; - } + delete[] IndexedNodes; + IndexedNodes = NULL; } @@ -884,10 +881,9 @@ void AABTreeCullSystemClass::Save_Object_Linkage(ChunkSaveClass & csave,Cullable void AABTreeCullSystemClass::Re_Index_Nodes(void) { - if (IndexedNodes != NULL) { - delete[] IndexedNodes; - IndexedNodes = NULL; - } + delete[] IndexedNodes; + IndexedNodes = NULL; + NodeCount = Partition_Node_Count(); WWASSERT(NodeCount > 0); IndexedNodes = new AABTreeNodeClass *[NodeCount]; @@ -936,14 +932,11 @@ AABTreeNodeClass::~AABTreeNodeClass(void) WWASSERT(Object == NULL); // delete our children - if (Front) { - delete Front; - Front = NULL; - } - if (Back) { - delete Back; - Back = NULL; - } + delete Front; + Front = NULL; + + delete Back; + Back = NULL; } void AABTreeNodeClass::Compute_Bounding_Box(void) diff --git a/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.h b/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.h index fcf45de025..7d0928bc5a 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.h +++ b/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef AABTREECULL_H -#define AABTREECULL_H #include "cullsys.h" #include "aaplane.h" @@ -337,8 +331,3 @@ class AABTreeLinkClass : public CullLinkClass, public AutoPoolClassSet(0,0,0); (*normal)[Normal] = 1.0f; } - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/cardinalspline.h b/Core/Libraries/Source/WWVegas/WWMath/cardinalspline.h index 2e9024fa98..504429dc53 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/cardinalspline.h +++ b/Core/Libraries/Source/WWVegas/WWMath/cardinalspline.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef CARDINALSPLINE_H -#define CARDINALSPLINE_H #include "hermitespline.h" @@ -98,7 +92,3 @@ class CardinalSpline1DClass : public HermiteSpline1DClass DynamicVectorClass Tightness; }; - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWMath/castres.h b/Core/Libraries/Source/WWVegas/WWMath/castres.h index ad1af135d7..69a577df6f 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/castres.h +++ b/Core/Libraries/Source/WWVegas/WWMath/castres.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef CASTRES_H -#define CASTRES_H #include "always.h" #include "vector3.h" @@ -70,6 +65,3 @@ struct CastResultStruct Vector3 ContactPoint; // This will be set to the point of collision if ComputeContactPoint is true }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/catmullromspline.h b/Core/Libraries/Source/WWVegas/WWMath/catmullromspline.h index 3d09bac894..e970ece445 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/catmullromspline.h +++ b/Core/Libraries/Source/WWVegas/WWMath/catmullromspline.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef CATMULLROMSPLINE_H -#define CATMULLROMSPLINE_H #include "hermitespline.h" @@ -74,5 +68,3 @@ class CatmullRomSpline1DClass : public HermiteSpline1DClass virtual bool Save(ChunkSaveClass &csave); virtual bool Load(ChunkLoadClass &cload); }; - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/colmath.h b/Core/Libraries/Source/WWVegas/WWMath/colmath.h index fac07df980..e1fb596810 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/colmath.h +++ b/Core/Libraries/Source/WWVegas/WWMath/colmath.h @@ -34,24 +34,11 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef COLMATH_H -#define COLMATH_H -#ifndef ALWAYS_H #include "always.h" -#endif - -#ifndef VECTOR3_H #include "vector3.h" -#endif - -#ifndef CASTRES_H #include "castres.h" -#endif class AAPlaneClass; class PlaneClass; @@ -308,5 +295,3 @@ inline CollisionMath::OverlapType CollisionMath::eval_overlap_collision(const Ca #define TRACK_COLLISION_OBBOX_OBBOX #define TRACK_COLLISION_OBBOX_OBBOX_HIT #endif - -#endif // COLMATH_H diff --git a/Core/Libraries/Source/WWVegas/WWMath/colmathaabox.h b/Core/Libraries/Source/WWVegas/WWMath/colmathaabox.h index 44deb7589a..70b8c50c0b 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/colmathaabox.h +++ b/Core/Libraries/Source/WWVegas/WWMath/colmathaabox.h @@ -38,12 +38,7 @@ * CollisionMath::Overlap_Test -- Tests overlap between two AABoxes * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef COLMATHAABOX_H -#define COLMATHAABOX_H #include "always.h" #include "aabox.h" @@ -105,6 +100,3 @@ WWINLINE CollisionMath::OverlapType CollisionMath::Overlap_Test(const AABoxClass return BOTH; } - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWMath/colmathfrustum.h b/Core/Libraries/Source/WWVegas/WWMath/colmathfrustum.h index 9ee3c141df..528ac9b688 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/colmathfrustum.h +++ b/Core/Libraries/Source/WWVegas/WWMath/colmathfrustum.h @@ -37,12 +37,7 @@ * CollisionMath::Overlap_Test -- test a frustum and an AABox for overlap * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef COLMATHFRUSTUM_H -#define COLMATHFRUSTUM_H #include "always.h" #include "aabox.h" @@ -101,5 +96,3 @@ CollisionMath::Overlap_Test(const FrustumClass & frustum,const AABoxClass & box, } return OVERLAPPED; } - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/colmathinlines.h b/Core/Libraries/Source/WWVegas/WWMath/colmathinlines.h index 15c80b5235..d06e715bea 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/colmathinlines.h +++ b/Core/Libraries/Source/WWVegas/WWMath/colmathinlines.h @@ -36,18 +36,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef COLMATHINLINES_H -#define COLMATHINLINES_H #include "colmathaabox.h" #include "colmathfrustum.h" #include "colmathline.h" #include "colmathplane.h" - -#endif - - diff --git a/Core/Libraries/Source/WWVegas/WWMath/colmathline.h b/Core/Libraries/Source/WWVegas/WWMath/colmathline.h index d2a890de2b..3dd52c2ebb 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/colmathline.h +++ b/Core/Libraries/Source/WWVegas/WWMath/colmathline.h @@ -36,8 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef COLMATHLINE_H -#define COLMATHLINE_H +#pragma once /* ** Inline collision functions dealing with line segments @@ -55,10 +54,3 @@ inline CollisionMath::OverlapType CollisionMath::Overlap_Test box.Init_Min_Max(min,max); return CollisionMath::Overlap_Test(box,line); } - - - - -#endif - - diff --git a/Core/Libraries/Source/WWVegas/WWMath/colmathplane.h b/Core/Libraries/Source/WWVegas/WWMath/colmathplane.h index 28d1e78c7c..930af32178 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/colmathplane.h +++ b/Core/Libraries/Source/WWVegas/WWMath/colmathplane.h @@ -39,9 +39,7 @@ * CollisionMath::Overlap_Test -- Tests overlap between a plane and an AABox * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef COLMATHPLANE_H -#define COLMATHPLANE_H +#pragma once #include "always.h" #include "plane.h" @@ -49,7 +47,7 @@ /* ** Inline collision functions dealing with planes -** This module is meant to be included only in .CPP files after you include colmath.h +** This module is meant to be included only in .cpp files after you include colmath.h ** It is not automatically included in order to reduce file dependencies... */ @@ -148,7 +146,3 @@ CollisionMath::Overlap_Test(const PlaneClass & plane,const AABoxClass & box) } return BOTH; } - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWMath/cullsys.h b/Core/Libraries/Source/WWVegas/WWMath/cullsys.h index 04f98681af..38a201d8ba 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/cullsys.h +++ b/Core/Libraries/Source/WWVegas/WWMath/cullsys.h @@ -34,17 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef CULLSYS_H -#define CULLSYS_H -#include "wwdebug.h" +#include "always.h" #include "stdlib.h" -#include "refcount.h" #include "aabox.h" class CullableClass; @@ -196,6 +189,3 @@ class CullSystemClass friend class CullableClass; }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/culltype.h b/Core/Libraries/Source/WWVegas/WWMath/culltype.h index 46cc4d6753..83ebc08b3a 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/culltype.h +++ b/Core/Libraries/Source/WWVegas/WWMath/culltype.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef CULLTYPE_H -#define CULLTYPE_H #include "always.h" @@ -57,6 +51,3 @@ typedef enum CULLTYPE CULL_INTERSECTING, // the object intersects an edge of the culling volume CULL_INSIDE // the object is completely inside the culling volume }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/curve.h b/Core/Libraries/Source/WWVegas/WWMath/curve.h index 8debabbdf5..6fdad67be3 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/curve.h +++ b/Core/Libraries/Source/WWVegas/WWMath/curve.h @@ -34,29 +34,12 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef CURVE_H -#define CURVE_H -#ifndef ALWAYS_H #include "always.h" -#endif - -#ifndef VECTOR_H -#include "Vector.H" -#endif - -#ifndef VECTOR3_H +#include "Vector.h" #include "vector3.h" -#endif - -#ifndef PERSIST_H #include "persist.h" -#endif class ChunkLoadClass; class ChunkSaveClass; @@ -174,6 +157,3 @@ class LinearCurve1DClass : public Curve1DClass virtual bool Save(ChunkSaveClass &csave); virtual bool Load(ChunkLoadClass &cload); }; - - -#endif //CURVE_H diff --git a/Core/Libraries/Source/WWVegas/WWMath/euler.h b/Core/Libraries/Source/WWVegas/WWMath/euler.h index 9c73d8bf4c..70dc0521cd 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/euler.h +++ b/Core/Libraries/Source/WWVegas/WWMath/euler.h @@ -35,13 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef EULER_H -#define EULER_H #include "always.h" #include "matrix3d.h" @@ -122,6 +116,3 @@ class EulerAnglesClass int Order; }; - - -#endif /*EULER_H*/ diff --git a/Core/Libraries/Source/WWVegas/WWMath/frustum.h b/Core/Libraries/Source/WWVegas/WWMath/frustum.h index b2af8fa475..0d46f6a692 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/frustum.h +++ b/Core/Libraries/Source/WWVegas/WWMath/frustum.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef FRUSTUM_H -#define FRUSTUM_H #include "vector3.h" #include "plane.h" @@ -66,8 +60,3 @@ class FrustumClass Vector3 BoundMin; Vector3 BoundMax; }; - - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWMath/gridcull.cpp b/Core/Libraries/Source/WWVegas/WWMath/gridcull.cpp index 33b9138f4b..b4289656c6 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/gridcull.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/gridcull.cpp @@ -178,10 +178,8 @@ GridCullSystemClass::GridCullSystemClass(void) : *=============================================================================================*/ GridCullSystemClass::~GridCullSystemClass(void) { - if (Cells != NULL) { - delete Cells; - Cells = NULL; - } + delete Cells; + Cells = NULL; } @@ -470,9 +468,7 @@ void GridCullSystemClass::Re_Partition(const Vector3 & input_min,const Vector3 & OOCellDim.Y = 1.0f / CellDim.Y; OOCellDim.Z = 1.0f / CellDim.Z; - if (Cells != NULL) { - delete[] Cells; - } + delete[] Cells; Cells = W3DNEWARRAY CullableClass * [total_cell_count()]; memset(&(Cells[0]),0,total_cell_count() * sizeof(CullableClass *)); @@ -634,11 +630,7 @@ void GridCullSystemClass::Load(ChunkLoadClass & cload) OOCellDim.Y = 1.0f / CellDim.Y; OOCellDim.Z = 1.0f / CellDim.Z; - if (Cells != NULL) { - delete [] Cells; - Cells = NULL; - } - + delete [] Cells; Cells = W3DNEWARRAY CullableClass * [total_cell_count()]; memset(&(Cells[0]),0,total_cell_count() * sizeof(CullableClass *)); diff --git a/Core/Libraries/Source/WWVegas/WWMath/gridcull.h b/Core/Libraries/Source/WWVegas/WWMath/gridcull.h index 802d23e9c8..18d9d9f886 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/gridcull.h +++ b/Core/Libraries/Source/WWVegas/WWMath/gridcull.h @@ -51,9 +51,7 @@ * GridCullSystemClass::VolumeStruct::Split -- split this volume * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif #include "cullsys.h" #include "mempool.h" @@ -61,7 +59,6 @@ #include "aabox.h" #include "lineseg.h" #include "obbox.h" -#include class ChunkLoadClass; class ChunkSaveClass; diff --git a/Core/Libraries/Source/WWVegas/WWMath/hermitespline.h b/Core/Libraries/Source/WWVegas/WWMath/hermitespline.h index 1f5db94c98..70d3f83bea 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/hermitespline.h +++ b/Core/Libraries/Source/WWVegas/WWMath/hermitespline.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef HERMITE_H -#define HERMITE_H #include "curve.h" @@ -138,6 +132,3 @@ class HermiteSpline1DClass : public Curve1DClass bool TangentsDirty; DynamicVectorClass Tangents; }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/lineseg.h b/Core/Libraries/Source/WWVegas/WWMath/lineseg.h index 95c940020f..3e0f90a0f1 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/lineseg.h +++ b/Core/Libraries/Source/WWVegas/WWMath/lineseg.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef LINESEG_H -#define LINESEG_H #include "always.h" #include "vector3.h" @@ -88,6 +82,3 @@ class LineSegClass Vector3 Dir; // normalized direction. float Length; // length of the segment }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/lookuptable.cpp b/Core/Libraries/Source/WWVegas/WWMath/lookuptable.cpp index 98edfd143c..139c782cfd 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/lookuptable.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/lookuptable.cpp @@ -38,7 +38,7 @@ #include "lookuptable.h" #include "curve.h" -#include "WWFILE.H" +#include "WWFILE.h" #include "ffactory.h" #include "chunkio.h" #include "persistfactory.h" diff --git a/Core/Libraries/Source/WWVegas/WWMath/lookuptable.h b/Core/Libraries/Source/WWVegas/WWMath/lookuptable.h index 7658f87ec1..c37923f4d7 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/lookuptable.h +++ b/Core/Libraries/Source/WWVegas/WWMath/lookuptable.h @@ -36,14 +36,11 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef LOOKUPTABLE_H -#define LOOKUPTABLE_H +#pragma once #include "always.h" #include "simplevec.h" #include "wwstring.h" -#include "refcount.h" #include "multilist.h" #include "wwmath.h" @@ -156,6 +153,3 @@ class LookupTableMgrClass static RefMultiListClass Tables; }; - - -#endif // LOOKUPTABLE_H diff --git a/Core/Libraries/Source/WWVegas/WWMath/matrix3.h b/Core/Libraries/Source/WWVegas/WWMath/matrix3.h index 1355694077..60c7413902 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/matrix3.h +++ b/Core/Libraries/Source/WWVegas/WWMath/matrix3.h @@ -23,7 +23,7 @@ * * * Project Name : WW3D * * * - * File Name : MATRIX3.H * + * File Name : MATRIX3.h * * * * Org Programmer : Greg Hjelstrom * * * @@ -56,13 +56,7 @@ * Matrix3x3::Rotate_Z -- Post-multiplies the matrix with a rotation about Z * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef Matrix3_H -#define Matrix3_H #include "always.h" #include "vector3.h" @@ -1028,5 +1022,3 @@ WWINLINE void Matrix3x3::Rotate_AABox_Extent(const Vector3 & extent,Vector3 * se } } } - -#endif /*Matrix3_H*/ diff --git a/Core/Libraries/Source/WWVegas/WWMath/matrix3d.cpp b/Core/Libraries/Source/WWVegas/WWMath/matrix3d.cpp index a7f2a105ac..e3c3c46c10 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/matrix3d.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/matrix3d.cpp @@ -23,7 +23,7 @@ * * * Project Name : Voxel Technology * * * - * File Name : MATRIX3D.CPP * + * File Name : MATRIX3D.cpp * * * * Org Programmer : Greg Hjelstrom * * * @@ -60,7 +60,6 @@ #include #include #include -//#include #include "vector3.h" #include "matrix3.h" #include "matrix4.h" diff --git a/Core/Libraries/Source/WWVegas/WWMath/matrix3d.h b/Core/Libraries/Source/WWVegas/WWMath/matrix3d.h index 904298e469..c849c8dab5 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/matrix3d.h +++ b/Core/Libraries/Source/WWVegas/WWMath/matrix3d.h @@ -23,7 +23,7 @@ * * * Project Name : Voxel Technology * * * - * File Name : MATRIX3D.H * + * File Name : MATRIX3D.h * * * * Org Programmer : Greg Hjelstrom * * * @@ -78,12 +78,7 @@ #define NO_ALLOW_TEMPORARIES -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef MATRIX3D_H -#define MATRIX3D_H #ifdef _UNIX #include "osdep.h" @@ -1815,4 +1810,3 @@ class DynamicMatrix3D : public W3DMPO public: Matrix3D Mat; }; -#endif /* MATRIX3D_H */ diff --git a/Core/Libraries/Source/WWVegas/WWMath/matrix4.h b/Core/Libraries/Source/WWVegas/WWMath/matrix4.h index 55b62e7782..81211850c7 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/matrix4.h +++ b/Core/Libraries/Source/WWVegas/WWMath/matrix4.h @@ -23,7 +23,7 @@ * * * Project Name : WW3D * * * - * File Name : MATRIX4.H * + * File Name : MATRIX4.h * * * * Org Programmer : Greg Hjelstrom * * * @@ -56,14 +56,7 @@ * Matrix4x4::operator /= -- "divide equals" operator * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - -#ifndef MATRIX4_H -#define MATRIX4_H #include "always.h" #include "vector4.h" @@ -843,6 +836,3 @@ WWINLINE void Matrix4x4::Transform_Vector(const Matrix4x4 & A,const Vector4 & in out->Z = (A[2][0] * v->X + A[2][1] * v->Y + A[2][2] * v->Z + A[2][3] * v->W); out->W = (A[3][0] * v->X + A[3][1] * v->Y + A[3][2] * v->Z + A[3][3] * v->W); } - - -#endif /*MATRIX4_H*/ diff --git a/Core/Libraries/Source/WWVegas/WWMath/normalcone.h b/Core/Libraries/Source/WWVegas/WWMath/normalcone.h index e6ad9608aa..d4cd659e52 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/normalcone.h +++ b/Core/Libraries/Source/WWVegas/WWMath/normalcone.h @@ -43,8 +43,7 @@ ** -ehc */ -#ifndef NORMALCONE_H -#define NORMALCONE_H +#pragma once #include "vector3.h" #include "matrix3.h" @@ -239,5 +238,3 @@ inline float NormalCone::Smallest_Dot_Product(const Vector3 & Input) return dot1; return dot2; } - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/obbox.cpp b/Core/Libraries/Source/WWVegas/WWMath/obbox.cpp index 0dd789bca6..e92787a274 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/obbox.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/obbox.cpp @@ -79,7 +79,7 @@ OBBoxClass::OBBoxClass(const Vector3 * /*points*/, int /*n*/) int i; // compute mean and covariances of points - float xsum = 0.0f, ysum = 0.0f, zsum = 0.0f;; + float xsum = 0.0f, ysum = 0.0f, zsum = 0.0f; float xxsum = 0.0f, xysum = 0.0f, xzsum = 0.0f; float yysum = 0.0f, yzsum = 0.0f, zzsum = 0.0f; diff --git a/Core/Libraries/Source/WWVegas/WWMath/obbox.h b/Core/Libraries/Source/WWVegas/WWMath/obbox.h index eb18e7f44d..4e3f7f141c 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/obbox.h +++ b/Core/Libraries/Source/WWVegas/WWMath/obbox.h @@ -41,12 +41,7 @@ * OBBoxClass::Compute_Axis_Aligned_Extent -- computes extent of an AABox enclosing this box * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef OBBOX_H -#define OBBOX_H #include "always.h" #include "vector3.h" @@ -267,5 +262,3 @@ inline bool OBBoxClass::operator!= (const OBBoxClass &src) { return (Center != src.Center) || (Extent != src.Extent) || (Basis != src.Basis); } - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/ode.cpp b/Core/Libraries/Source/WWVegas/WWMath/ode.cpp index 817c484f41..4889b11c55 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/ode.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/ode.cpp @@ -16,14 +16,14 @@ ** along with this program. If not, see . */ -/* $Header: /Commando/Code/wwmath/ODE.CPP 8 7/02/99 10:32a Greg_h $ */ +/* $Header: /Commando/Code/wwmath/ODE.cpp 8 7/02/99 10:32a Greg_h $ */ /*********************************************************************************************** *** Confidential - Westwood Studios *** *********************************************************************************************** * * * Project Name : Commando * * * - * $Archive:: /Commando/Code/wwmath/ODE.CPP $* + * $Archive:: /Commando/Code/wwmath/ODE.cpp $* * * * Author:: Greg_h * * * diff --git a/Core/Libraries/Source/WWVegas/WWMath/ode.h b/Core/Libraries/Source/WWVegas/WWMath/ode.h index 674b81c844..0d59713619 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/ode.h +++ b/Core/Libraries/Source/WWVegas/WWMath/ode.h @@ -35,16 +35,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef ODE_H -#define ODE_H #include "always.h" -#include "Vector.H" +#include "Vector.h" #include "wwdebug.h" @@ -129,6 +123,3 @@ class IntegrationSystem static void Runge_Kutta5_Integrate(ODESystemClass * odesys,float dt); }; - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWMath/plane.h b/Core/Libraries/Source/WWVegas/WWMath/plane.h index fb9d406c93..c0cfbfe281 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/plane.h +++ b/Core/Libraries/Source/WWVegas/WWMath/plane.h @@ -23,7 +23,7 @@ * * * Project Name : Voxel Technology * * * - * File Name : PLANE.H * + * File Name : PLANE.h * * * * Programmer : Greg Hjelstrom * * * @@ -35,12 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef PLANE_H -#define PLANE_H #include "always.h" #include "vector3.h" @@ -246,5 +241,3 @@ inline void PlaneClass::Intersect_Planes(const PlaneClass & a, const PlaneClass // find the point). line_dir->Normalize(); } - -#endif /*PLANE_H*/ diff --git a/Core/Libraries/Source/WWVegas/WWMath/pot.cpp b/Core/Libraries/Source/WWVegas/WWMath/pot.cpp index d25081db02..8ea327efdf 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/pot.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/pot.cpp @@ -22,7 +22,7 @@ * * * Project Name : G * * * - * $Archive:: /G/ww3d/POT.CPP $* + * $Archive:: /G/ww3d/POT.cpp $* * * * $Author:: Naty_h $* * * diff --git a/Core/Libraries/Source/WWVegas/WWMath/pot.h b/Core/Libraries/Source/WWVegas/WWMath/pot.h index b46d7d5aa3..3981fa3700 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/pot.h +++ b/Core/Libraries/Source/WWVegas/WWMath/pot.h @@ -22,7 +22,7 @@ * * * Project Name : G * * * - * $Archive:: /G/ww3d/POT.H $* + * $Archive:: /G/ww3d/POT.h $* * * * $Author:: Naty_h $* * * @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif -#ifndef __POT_H__ -#define __POT_H__ int Find_POT(int val); unsigned int Find_POT_Log2(unsigned int val); -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/quat.cpp b/Core/Libraries/Source/WWVegas/WWMath/quat.cpp index ae9386120c..b0bf14d9a9 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/quat.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/quat.cpp @@ -23,7 +23,7 @@ * * * Project Name : Voxel Technology * * * - * File Name : QUAT.CPP * + * File Name : QUAT.cpp * * * * Programmer : Greg Hjelstrom * * * @@ -54,7 +54,6 @@ #include "matrix4.h" #include "wwmath.h" -#include #include #include #include diff --git a/Core/Libraries/Source/WWVegas/WWMath/quat.h b/Core/Libraries/Source/WWVegas/WWMath/quat.h index deecf38bd1..7a7f28e9d1 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/quat.h +++ b/Core/Libraries/Source/WWVegas/WWMath/quat.h @@ -23,7 +23,7 @@ * * * Project Name : Voxel Technology * * * - * File Name : QUAT.H * + * File Name : QUAT.h * * * * Programmer : Greg Hjelstrom * * * @@ -35,12 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef QUAT_H -#define QUAT_H #include "always.h" #include "wwmath.h" @@ -309,9 +304,3 @@ WWINLINE Quaternion & Quaternion::operator = (const Quaternion & source) return *this; } - - -#endif /* QUAT_H */ - - - diff --git a/Core/Libraries/Source/WWVegas/WWMath/rect.h b/Core/Libraries/Source/WWVegas/WWMath/rect.h index 376e1fb0c6..b99fd42c8a 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/rect.h +++ b/Core/Libraries/Source/WWVegas/WWMath/rect.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef RECT_H -#define RECT_H #include "vector2.h" @@ -103,6 +97,3 @@ class RectClass void Snap_To_Units( const Vector2 & u ) { Left = (int)(Left / u.X + 0.5f) * u.X; Right = (int)(Right / u.X + 0.5f) * u.X; Top = (int)(Top / u.Y + 0.5f) * u.Y; Bottom = (int)(Bottom / u.Y + 0.5f) * u.Y; } }; - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWMath/sphere.h b/Core/Libraries/Source/WWVegas/WWMath/sphere.h index abdf695ad0..de098d5145 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/sphere.h +++ b/Core/Libraries/Source/WWVegas/WWMath/sphere.h @@ -48,13 +48,7 @@ * operator * -- Transform a sphere * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef SPHERE_H -#define SPHERE_H #include "always.h" #include "vector3.h" @@ -71,9 +65,9 @@ class SphereClass { public: - inline SphereClass(void) { }; - inline SphereClass(const Vector3 & center,float radius) { Init(center,radius); } - inline SphereClass(const Matrix3D& mtx,const Vector3 & center,float radius) { Init(mtx,center,radius); } + SphereClass(void) { }; + SphereClass(const Vector3 & center,float radius) { Init(center,radius); } + SphereClass(const Matrix3D& mtx,const Vector3 & center,float radius) { Init(mtx,center,radius); } inline SphereClass(const Vector3 & center,const SphereClass & s0); inline SphereClass(const Vector3 *Position, const int VertCount); @@ -545,8 +539,3 @@ inline SphereClass operator * (const Matrix3D & m, const SphereClass & s) { return Transform_Sphere(m,s); } - - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWMath/tcbspline.h b/Core/Libraries/Source/WWVegas/WWMath/tcbspline.h index b850af609c..23ec6b7e45 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/tcbspline.h +++ b/Core/Libraries/Source/WWVegas/WWMath/tcbspline.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef TCBSPLINE_H -#define TCBSPLINE_H #include "hermitespline.h" @@ -80,7 +74,3 @@ class TCBSpline3DClass : public HermiteSpline3DClass DynamicVectorClass Params; }; - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWMath/tri.h b/Core/Libraries/Source/WWVegas/WWMath/tri.h index 5a7cd512b7..77c9889e0b 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/tri.h +++ b/Core/Libraries/Source/WWVegas/WWMath/tri.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef TRI_H -#define TRI_H #include "always.h" #include "vector4.h" @@ -296,11 +290,9 @@ inline bool Cast_Semi_Infinite_Axis_Aligned_Ray_To_Triangle(const Vector3 &tri_p flags |= TRI_RAYCAST_FLAG_START_IN_TRI; } } - } // if (result == 0.0f) - } // else (result < 0.0f) - } // if Point_In_Triangle_2D() + } + } + } return retval; } - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/v3_rnd.h b/Core/Libraries/Source/WWVegas/WWMath/v3_rnd.h index f79ed64de3..defa05e721 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/v3_rnd.h +++ b/Core/Libraries/Source/WWVegas/WWMath/v3_rnd.h @@ -33,16 +33,12 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) -#pragma once -#endif -#ifndef V3_RND_H -#define V3_RND_H +#pragma once #include "always.h" #include "vector3.h" -#include "RANDOM.H" +#include "RANDOM.h" #include /* @@ -228,8 +224,3 @@ class Vector3SolidCylinderRandomizer : public Vector3Randomizer { float Extent; float Radius; }; - - -#endif - - diff --git a/Core/Libraries/Source/WWVegas/WWMath/vector2.h b/Core/Libraries/Source/WWVegas/WWMath/vector2.h index 2da94029ef..9ba45fe4d4 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/vector2.h +++ b/Core/Libraries/Source/WWVegas/WWMath/vector2.h @@ -23,7 +23,7 @@ * * * Project Name : Westwood 3D * * * - * File Name : VECTOR2.H * + * File Name : VECTOR2.h * * * * Programmer : Greg Hjelstrom * * * @@ -49,12 +49,7 @@ * Vector2::Lerp -- linearly interpolates two Vector2's * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef VECTOR2_H -#define VECTOR2_H #include "always.h" #include "wwmath.h" @@ -665,7 +660,3 @@ WWINLINE void Vector2::Lerp(const Vector2 & a,const Vector2 & b,float t,Vector2 set_result->X = (a.X + (b.X - a.X)*t); set_result->Y = (a.Y + (b.Y - a.Y)*t); } - - -#endif /* VECTOR2_H */ - diff --git a/Core/Libraries/Source/WWVegas/WWMath/vector2i.h b/Core/Libraries/Source/WWVegas/WWMath/vector2i.h index 3682d984f1..0645d090a0 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/vector2i.h +++ b/Core/Libraries/Source/WWVegas/WWMath/vector2i.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef VECTOR2I_H -#define VECTOR2I_H #include "always.h" @@ -108,6 +102,3 @@ WWINLINE void Vector2i::Swap(Vector2i & other) other.J ^= J; J ^= other.J; } - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWMath/vector3.h b/Core/Libraries/Source/WWVegas/WWMath/vector3.h index 611b69107d..efd75af2fd 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/vector3.h +++ b/Core/Libraries/Source/WWVegas/WWMath/vector3.h @@ -23,7 +23,7 @@ * * * Project Name : Westwood 3D * * * - * File Name : VECTOR3.H * + * File Name : VECTOR3.h * * * * Programmer : Greg Hjelstrom * * * @@ -63,12 +63,7 @@ * Vector3::Is_Valid -- Verifies that each component of this vector is a valid float * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef VECTOR3_H -#define VECTOR3_H #include "always.h" #include "wwmath.h" @@ -934,6 +929,3 @@ WWINLINE unsigned long Vector3::Convert_To_ARGB( float alpha ) const (unsigned(Y*255.0f)<<8) | (unsigned(Z*255.0f)); } - -#endif /* Vector3_H */ - diff --git a/Core/Libraries/Source/WWVegas/WWMath/vector4.h b/Core/Libraries/Source/WWVegas/WWMath/vector4.h index 6b1e350a50..a512aaad30 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/vector4.h +++ b/Core/Libraries/Source/WWVegas/WWMath/vector4.h @@ -23,7 +23,7 @@ * * * Project Name : Westwood 3D * * * - * File Name : VECTOR4.H * + * File Name : VECTOR4.h * * * * Programmer : Greg Hjelstrom * * * @@ -44,12 +44,7 @@ * Vector4::Is_Valid -- Vector4::Is_Valid * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef VECTOR4_H -#define VECTOR4_H #include "always.h" #include "wwmath.h" @@ -406,7 +401,3 @@ WWINLINE bool Vector4::Is_Valid(void) const { return (WWMath::Is_Valid_Float(X) && WWMath::Is_Valid_Float(Y) && WWMath::Is_Valid_Float(Z) && WWMath::Is_Valid_Float(W)); } - - -#endif /* VECTOR4_H */ - diff --git a/Core/Libraries/Source/WWVegas/WWMath/vehiclecurve.h b/Core/Libraries/Source/WWVegas/WWMath/vehiclecurve.h index 8833c1e341..46a9764705 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/vehiclecurve.h +++ b/Core/Libraries/Source/WWVegas/WWMath/vehiclecurve.h @@ -34,16 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __VEHICLE_CURVE_H -#define __VEHICLE_CURVE_H #include "curve.h" -#include "Vector.H" +#include "Vector.h" //////////////////////////////////////////////////////////////////////////////////////////// @@ -204,7 +198,3 @@ VehicleCurveClass::Clear_Keys (void) Curve3DClass::Clear_Keys (); return ; } - - -#endif //__VEHICLE_CURVE_H - diff --git a/Core/Libraries/Source/WWVegas/WWMath/vp.h b/Core/Libraries/Source/WWVegas/WWMath/vp.h index 19630d0c5a..937188093f 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/vp.h +++ b/Core/Libraries/Source/WWVegas/WWMath/vp.h @@ -45,12 +45,7 @@ *----------------------------------------------------------------------------------------------* */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef VECTORPROCESSOR_H -#define VECTORPROCESSOR_H class Vector2; class Vector3; @@ -89,5 +84,3 @@ class VectorProcessorClass static void ClampMin(float *dst, float *src, const float min, const int count); static void Power(float *dst, float *src, const float pow, const int count); }; - -#endif // VECTORPROCESSOR_H diff --git a/Core/Libraries/Source/WWVegas/WWMath/wwmath.h b/Core/Libraries/Source/WWVegas/WWMath/wwmath.h index bd90746b89..35372397a9 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/wwmath.h +++ b/Core/Libraries/Source/WWVegas/WWMath/wwmath.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef WWMATH_H -#define WWMATH_H #include "always.h" #include @@ -52,7 +46,8 @@ */ #define WWMATH_EPSILON 0.0001f #define WWMATH_EPSILON2 WWMATH_EPSILON * WWMATH_EPSILON -#define WWMATH_PI 3.141592654f +#define WWMATH_PI 3.141592654f +#define WWMATH_TWO_PI 6.283185308f #define WWMATH_FLOAT_MAX (FLT_MAX) #define WWMATH_FLOAT_MIN (FLT_MIN) #define WWMATH_SQRT2 1.414213562f @@ -143,6 +138,7 @@ static WWINLINE float Atan2(float y,float x) { return static_cast(atan2( static WWINLINE float Sign(float val); static WWINLINE float Ceil(float val) { return ceilf(val); } static WWINLINE float Floor(float val) { return floorf(val); } +static WWINLINE float Round(float val) { return floorf(val + 0.5f); } static WWINLINE bool Fast_Is_Float_Positive(const float & val); static WWINLINE bool Is_Power_Of_2(const unsigned int val); @@ -170,6 +166,8 @@ static WWINLINE float Byte_To_Unit_Float(unsigned char byte) { return ((float) static WWINLINE bool Is_Valid_Float(float x); static WWINLINE bool Is_Valid_Double(double x); +static WWINLINE float Normalize_Angle(float angle); // Normalizes the angle to the range -PI..PI + }; WWINLINE float WWMath::Sign(float val) @@ -652,5 +650,7 @@ WWINLINE float WWMath::Inv_Sqrt(float val) } #endif - -#endif +WWINLINE float WWMath::Normalize_Angle(float angle) +{ + return angle - (WWMATH_TWO_PI * Floor((angle + WWMATH_PI) / WWMATH_TWO_PI)); +} diff --git a/Core/Libraries/Source/WWVegas/WWMath/wwmathids.h b/Core/Libraries/Source/WWVegas/WWMath/wwmathids.h index d6f8d76695..786757d843 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/wwmathids.h +++ b/Core/Libraries/Source/WWVegas/WWMath/wwmathids.h @@ -36,8 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef WWMATHIDS_H -#define WWMATHIDS_H +#pragma once #include "saveloadids.h" @@ -59,8 +58,3 @@ enum WWMATH_CHUNKID_TCBSPLINE3D, WWMATH_CHUNKID_VEHICLECURVE }; - - - -#endif //WWMATHIDS_H - diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definition.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/definition.h index 9506a54b89..471c39ceac 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definition.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/definition.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __DEFINITION_H -#define __DEFINITION_H #include "always.h" // SKB Remove because of G conflicts with CLASSID_?? @@ -189,6 +184,3 @@ DefinitionClass::Is_Valid_Config (StringClass &message) { return true; } - - -#endif //__DEFINITION_H diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionclassids.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionclassids.h index 140b4454a5..8d74a2d5a0 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionclassids.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionclassids.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __DEFINITION_CLASS_ID_H -#define __DEFINITION_CLASS_ID_H #include "always.h" #include "bittype.h" @@ -102,7 +96,3 @@ SuperClassID_From_ClassID (uint32 class_id) return DEF_CLASSID_START + (num_ranges * DEF_CLASSID_RANGE); } - - -#endif //__DEFINITION_CLASS_ID_H - diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.h index 9ac92ac64b..a7230b95d4 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __DEFINITION_FACTORY_H -#define __DEFINITION_FACTORY_H #include "always.h" #include "bittype.h" @@ -88,6 +83,3 @@ class DefinitionFactoryClass ////////////////////////////////////////////////////////////// friend class DefinitionFactoryMgrClass; }; - - -#endif //__DEFINITION_FACTORY_H diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.cpp index 5c82277805..bf883471fc 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.cpp +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.cpp @@ -37,7 +37,7 @@ #include "definitionfactorymgr.h" #include "definitionfactory.h" #include "wwdebug.h" -#include + #ifdef _UNIX #include "osdep.h" #endif diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.h index 5eec552480..dd317f0759 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __DEFINITION_FACTORY_MGR_H -#define __DEFINITION_FACTORY_MGR_H #include "always.h" #include "bittype.h" @@ -85,6 +80,3 @@ class DefinitionFactoryMgrClass ///////////////////////////////////////////////////////////////////// static DefinitionFactoryClass * _FactoryListHead; }; - - -#endif //__DEFINITION_FACTORY_MGR_H diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.cpp index cdd4ea4696..056180c003 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.cpp +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.cpp @@ -44,7 +44,6 @@ #include "wwdebug.h" #include "wwmemlog.h" #include "twiddler.h" -#include #include "wwprofile.h" @@ -479,27 +478,21 @@ DefinitionMgrClass::Free_Definitions (void) DefinitionHash=NULL; } - // - // Free each of the definition objects - // - for (int index = 0; index < _DefinitionCount; index ++) { - DefinitionClass *definition = _SortedDefinitionArray[index]; - if (definition != NULL) { - delete definition; - } - } - // // Free the definition array // if (_SortedDefinitionArray != NULL) { + // + // Free each of the definition objects + // + for (int index = 0; index < _DefinitionCount; index ++) { + delete _SortedDefinitionArray[index]; + } delete [] _SortedDefinitionArray; + _SortedDefinitionArray = NULL; + _MaxDefinitionCount = 0; + _DefinitionCount = 0; } - - _SortedDefinitionArray = NULL; - _MaxDefinitionCount = 0; - _DefinitionCount = 0; - return ; } @@ -527,9 +520,7 @@ DefinitionMgrClass::Prepare_Definition_Array (void) // // Free the old array and start using the new array // - if (_SortedDefinitionArray != NULL) { - delete [] _SortedDefinitionArray; - } + delete [] _SortedDefinitionArray; _SortedDefinitionArray = new_array; _MaxDefinitionCount = new_size; } diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.h index e99e397864..ade932edbd 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.h @@ -34,14 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - -#ifndef __DEFINITION_MGR_H -#define __DEFINITION_MGR_H #include "always.h" #include "saveload.h" @@ -50,7 +43,7 @@ #include "wwdebug.h" #include "wwstring.h" #include "hashtemplate.h" -#include "Vector.H" +#include "Vector.h" // Forward declarations @@ -182,6 +175,3 @@ DefinitionMgrClass::Get_First (void) return definition; } - - -#endif //__DEFINITION_MGR_H diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/editable.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/editable.h index 17bd8078b2..059b5dcf9a 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/editable.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/editable.h @@ -41,15 +41,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - -#ifndef __EDITABLE_H -#define __EDITABLE_H - #include "always.h" #include "persist.h" @@ -331,9 +323,3 @@ EditableClass::Unlock_Parameter (int i) #define GENERIC_DEFID_PARAM(_class, data, root_class_id) #endif //PARAM_EDITING_ON - - -#endif //__EDITABLE_H - - - diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.h index 0bdc72c149..686bf88c29 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.h @@ -36,19 +36,12 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __PARAMETER_H -#define __PARAMETER_H #include "always.h" -#include #include #include "parametertypes.h" -#include "Vector.H" +#include "Vector.h" #include "wwstring.h" #include "bittype.h" #include "obbox.h" @@ -1155,7 +1148,3 @@ class SeparatorParameterClass : public ParameterClass // Copy methods virtual void Copy_Value (const ParameterClass &src); }; - - -#endif //__PARAMETER_H - diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameterlist.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/parameterlist.h index 24daa98d2b..80ba4a737f 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameterlist.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/parameterlist.h @@ -34,19 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - - - -#ifndef __PARAMETER_LIST_H -#define __PARAMETER_LIST_H #include "always.h" -#include "Vector.H" +#include "Vector.h" #include "parameter.h" #include "wwdebug.h" @@ -148,16 +139,10 @@ ParameterListClass::Free_Parameters (void) // // Free the parameter object // - if (param != NULL) { - delete param; - } + delete param; } Delete_All(); // m_Parameters.Delete_All (); return ; } - - -#endif //__PARAMETER_LIST_H - diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/parametertypes.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/parametertypes.h index b8be2d3061..8964521f6f 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/parametertypes.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/parametertypes.h @@ -34,15 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - - -#ifndef __PARAMETER_TYPES_H -#define __PARAMETER_TYPES_H #include "always.h" @@ -63,7 +55,3 @@ TYPE_MODELFILENAME } ParameterType;*/ - - -#endif //__PARAMETER_TYPES_H - diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/persist.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/persist.h index 515658c7df..ce46315ce9 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/persist.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/persist.h @@ -34,16 +34,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef PERSIST_H -#define PERSIST_H #include "always.h" -#include "refcount.h" #include "postloadable.h" class PersistFactoryClass; @@ -71,7 +64,3 @@ class PersistClass : public PostLoadableClass virtual bool Load (ChunkLoadClass &cload) { return true; } }; - - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.h index b1cae3468e..0599936a17 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.h @@ -34,16 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - - - -#ifndef PERSISTFACTORY_H -#define PERSISTFACTORY_H #include "always.h" #include "bittype.h" @@ -138,6 +129,3 @@ SimplePersistFactoryClass::Save(ChunkSaveClass & csave,PersistClass * obj->Save(csave); csave.End_Chunk(); } - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.cpp index f83f0673e5..21dc60f1bf 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.cpp +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.cpp @@ -36,7 +36,6 @@ #include "pointerremap.h" -#include "refcount.h" #include "wwdebug.h" diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.h index 3e77213228..5c54558355 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.h @@ -34,21 +34,14 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - -#ifndef POINTERREMAP_H -#define POINTERREMAP_H #ifdef _UNIX #include "osdep/osdep.h" #endif #include "always.h" -#include "Vector.H" +#include "Vector.h" class RefCountClass; @@ -110,6 +103,3 @@ class PointerRemapClass DynamicVectorClass PointerRequestTable; DynamicVectorClass RefCountRequestTable; }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/postloadable.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/postloadable.h index f574daef44..d6c0e555f2 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/postloadable.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/postloadable.h @@ -36,9 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef POSTLOADABLE_H -#define POSTLOADABLE_H - +#pragma once ////////////////////////////////////////////////////////////////////////////////// // @@ -64,8 +62,3 @@ class PostLoadableClass bool IsPostLoadRegistered; }; - - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.h index 7331fa5afa..05ac8b6e08 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.h @@ -34,19 +34,12 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - -#ifndef SAVELOAD_H -#define SAVELOAD_H #include "always.h" #include "pointerremap.h" #include "bittype.h" -#include "SLIST.H" +#include "SLIST.h" class RefCountClass; class SaveLoadSubSystemClass; @@ -217,7 +210,3 @@ class SaveLoadSystemClass #define REQUEST_POINTER_REMAP(pp) SaveLoadSystemClass::Request_Pointer_Remap(pp) #define REQUEST_REF_COUNTED_POINTER_REMAP(pp) SaveLoadSystemClass::Request_Ref_Counted_Pointer_Remap(pp) #endif - - -#endif //SAVELOAD_H - diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadids.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadids.h index 707d573e1c..ee8e111ce1 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadids.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadids.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef SAVELOADIDS_H -#define SAVELOADIDS_H ////////////////////////////////////////////////////////////////////////////////// // @@ -66,6 +60,3 @@ enum CHUNKID_WWMATH_BEGIN = 0x00080000, CHUNKID_WWTRANSLATEDB_BEGIN = 0x00090000 }; - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadstatus.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadstatus.h index cd414e7da9..776dbae40f 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadstatus.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadstatus.h @@ -16,12 +16,7 @@ ** along with this program. If not, see . */ -#ifndef WWSAVELOADSTATUS_H -#define WWSAVELOADSTATUS_H - -#if defined(_MSC_VER) #pragma once -#endif #include "always.h" #include "wwstring.h" @@ -38,5 +33,3 @@ namespace SaveLoadStatus #define INIT_STATUS(t) SaveLoadStatus::Set_Status_Text(t,0) #define INIT_SUB_STATUS(t) SaveLoadStatus::Set_Status_Text(t,1) - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.h index 7394f7a381..46c7d98da2 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.h @@ -34,15 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - -#ifndef SAVELOADSUBSYSTEM_H -#define SAVELOADSUBSYSTEM_H - #include "always.h" #include "bittype.h" @@ -89,7 +81,3 @@ class SaveLoadSubSystemClass : public PostLoadableClass friend class SaveLoadSystemClass; }; - - - -#endif diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/simpledefinitionfactory.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/simpledefinitionfactory.h index c18d86e051..b90eb038f9 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/simpledefinitionfactory.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/simpledefinitionfactory.h @@ -16,10 +16,7 @@ ** along with this program. If not, see . */ - - -#ifndef __SIMPLE_DEFINITION_FACTORY_H -#define __SIMPLE_DEFINITION_FACTORY_H +#pragma once #include "definitionfactory.h" @@ -80,7 +77,4 @@ SimpleDefinitionFactoryClass::Get_Class_ID (void) const #define DECLARE_DEFINITION_FACTORY(_class, _id, _name) \ char _class ## Name[] = _name; \ -SimpleDefinitionFactoryClass<_class, _id, _class ## Name> \ - -#endif //__SIMPLE_DEFINITION_FACTORY_H - +SimpleDefinitionFactoryClass<_class, _id, _class ## Name> diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/simpleparameter.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/simpleparameter.h index 65c428cb4a..af9f6dbd24 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/simpleparameter.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/simpleparameter.h @@ -34,16 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - - - -#ifndef __SIMPLE_PARAMETER_H -#define __SIMPLE_PARAMETER_H #include "always.h" #include "parameter.h" @@ -242,6 +233,3 @@ class AngleParameterClass : public RangedParameterClass (data, name) { Set_Range (0.0F, 6.283185307F); } }; - -#endif //__SIMPLE_PARAMETER_H - diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.cpp index 85dae162d9..8e782eb186 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.cpp +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.cpp @@ -36,7 +36,7 @@ #include "twiddler.h" -#include "RANDOM.H" +#include "RANDOM.h" #include "saveloadids.h" #include "simpledefinitionfactory.h" #include "persistfactory.h" diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.h index 873d11509f..7c45af94f6 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __TWIDDLER_H -#define __TWIDDLER_H #include "definition.h" #include "definitionclassids.h" @@ -124,7 +119,3 @@ TwiddlerClass::Set_Indirect_Class_ID (uint32 class_id) m_IndirectClassID = class_id; return ; } - - -#endif //__TWIDDLER_H - diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/wwsaveload.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/wwsaveload.h index 7a48106a90..8863266b1b 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/wwsaveload.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/wwsaveload.h @@ -36,12 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef WWSAVELOAD_H -#define WWSAVELOAD_H /** ** WWSaveLoad @@ -54,7 +49,3 @@ class WWSaveLoad static void Init(void); static void Shutdown(void); }; - - -#endif - diff --git a/Core/Libraries/Source/WWVegas/WWStub/wwdebugstub.cpp b/Core/Libraries/Source/WWVegas/WWStub/wwdebugstub.cpp index 48bd79cd78..3103aff21c 100644 --- a/Core/Libraries/Source/WWVegas/WWStub/wwdebugstub.cpp +++ b/Core/Libraries/Source/WWVegas/WWStub/wwdebugstub.cpp @@ -20,7 +20,7 @@ #include "wwdebug.h" #include #include -#include +#include char* TheCurrentIgnoreCrashPtr = NULL; diff --git a/Core/Libraries/Source/debug/CMakeLists.txt b/Core/Libraries/Source/debug/CMakeLists.txt index f81690ac1c..2489074944 100644 --- a/Core/Libraries/Source/debug/CMakeLists.txt +++ b/Core/Libraries/Source/debug/CMakeLists.txt @@ -1,6 +1,4 @@ set(DEBUG_SRC - "_pch.cpp" - "_pch.h" "debug_cmd.cpp" "debug_cmd.h" "debug_debug.cpp" @@ -17,7 +15,6 @@ set(DEBUG_SRC "debug_macro.h" "debug_stack.cpp" "debug_stack.h" - "debug.cpp" "debug.h" "internal_except.h" "internal_io.h" @@ -32,7 +29,16 @@ target_include_directories(core_debug INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ) +target_precompile_headers(core_debug PRIVATE + "debug.h" + "internal.h" + "internal_except.h" + "internal_io.h" + +) + target_link_libraries(core_debug PRIVATE core_config + core_wwcommon corei_always ) diff --git a/Core/Libraries/Source/debug/_pch.cpp b/Core/Libraries/Source/debug/_pch.cpp deleted file mode 100644 index d2e00b00bd..0000000000 --- a/Core/Libraries/Source/debug/_pch.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/debug/_pch.cpp $ -// $Author: mhoffe $ -// $Revision: #1 $ -// $DateTime: 2003/07/03 11:55:26 $ -// -// (c) 2003 Electronic Arts -// -// Precompiled header (module internal) -////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" diff --git a/Core/Libraries/Source/debug/_pch.h b/Core/Libraries/Source/debug/_pch.h deleted file mode 100644 index 203e146495..0000000000 --- a/Core/Libraries/Source/debug/_pch.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/debug/_pch.h $ -// $Author: mhoffe $ -// $Revision: #1 $ -// $DateTime: 2003/07/03 11:55:26 $ -// -// (c) 2003 Electronic Arts -// -// Precompiled header (module internal) -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef _PCH_H // Include guard -#define _PCH_H - -#include "debug.h" - -// we need windows.h at too many places... -#define STRICT -#define WIN32_LEAN_AND_MEAN -#include - -#include "internal.h" -#include "internal_io.h" -#include "internal_except.h" - -#endif // _PCH_H diff --git a/Core/Libraries/Source/debug/debug.h b/Core/Libraries/Source/debug/debug.h index 26d25dfb4c..11b75830a1 100644 --- a/Core/Libraries/Source/debug/debug.h +++ b/Core/Libraries/Source/debug/debug.h @@ -26,11 +26,8 @@ // // Debugging module ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef DEBUG_H // Include guard -#define DEBUG_H + +#pragma once /** \page lib_var Library variants @@ -104,5 +101,3 @@ #include "debug_cmd.h" #include "debug_stack.h" #include "debug_debug.h" - -#endif // DEBUG_H diff --git a/Core/Libraries/Source/debug/debug_cmd.cpp b/Core/Libraries/Source/debug/debug_cmd.cpp index 6b632d415c..019e2e3f7d 100644 --- a/Core/Libraries/Source/debug/debug_cmd.cpp +++ b/Core/Libraries/Source/debug/debug_cmd.cpp @@ -26,7 +26,10 @@ // // Debug command group 'debug' ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#include "debug.h" +#include "debug_cmd.h" +#include "internal.h" +#include #include bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, @@ -36,7 +39,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, // just for convenience... bool normalMode=cmdmode==CommandMode::Normal; - if (!strcmp(cmd,"help")) + if (strcmp(cmd,"help") == 0) { if (!normalMode) return true; @@ -47,7 +50,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, " list, io, alwaysflush, timestamp, exit, clear, add, view\n"; return true; } - else if (!strcmp(argv[0],"list")) + else if (strcmp(argv[0],"list") == 0) { dbg << "list (g|l|d|a|c) [ ]\n" "\n" @@ -69,7 +72,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, "e.g. debug.cpp(13).\n"; return true; } - else if (!strcmp(argv[0],"io")) + else if (strcmp(argv[0],"io") == 0) { dbg << "io { }]\n" "\n" @@ -88,33 +91,33 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, "a list of possible I/O classes.\n"; return true; } - else if (!strcmp(argv[0],"alwaysflush")) + else if (strcmp(argv[0],"alwaysflush") == 0) { dbg << "alwaysflush [ (+|-) ]\n\n" "Enables/disables flushing after each new entry in\n" "the log file (default: off).\n"; return true; } - else if (!strcmp(argv[0],"timestamp")) + else if (strcmp(argv[0],"timestamp") == 0) { dbg << "timestamp [ (+|-) ]\n\n" "Enables/disables timestamping each log entry\n" "(default: off).\n"; return true; } - else if (!strcmp(argv[0],"exit")) + else if (strcmp(argv[0],"exit") == 0) { dbg << "exit\n\nExits program immediately.\n"; return true; } - else if (!strcmp(argv[0],"clear")) + else if (strcmp(argv[0],"clear") == 0) { dbg << "clear (l|a|c)\n\n" "Clears the given inclusion/exclusion list\n" "(l=logs, a=asserts/crashes, c=checks).\n"; return true; } - else if (!strcmp(argv[0],"add")) + else if (strcmp(argv[0],"add") == 0) { dbg << "add (l|a|c) (+|-) \n" "\n" @@ -129,7 +132,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, "the last match."; return true; } - else if (!strcmp(argv[0],"view")) + else if (strcmp(argv[0],"view") == 0) { dbg << "view [ (l|a|c) ]\n\n" "Shows the active pattern for the given list\n" @@ -138,7 +141,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, } return false; } - if (!strcmp(cmd,"list")) + if (strcmp(cmd,"list") == 0) { const char *pattern=argn>=2?argv[1]:"*"; @@ -201,10 +204,10 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, return true; } - if (!strcmp(cmd,"io")) + if (strcmp(cmd,"io") == 0) { // cmd: io - if (!argn||!strcmp(argv[0],"?")) + if (!argn||strcmp(argv[0],"?") == 0) { // show active/all I/O classes if (normalMode) @@ -229,7 +232,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, // find I/O class Debug::IOFactoryListEntry *cur=dbg.firstIOFactory; for (;cur;cur=cur->next) - if (!strcmp(argv[0],cur->ioID)) + if (strcmp(argv[0],cur->ioID) == 0) break; if (!cur) { @@ -240,7 +243,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, if (argn>1) { // 'add' command? - if (!strcmp(argv[1],"add")) + if (strcmp(argv[1],"add") == 0) { if (cur->io) { @@ -255,7 +258,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, } } // 'remove' command? - if (!strcmp(argv[1],"remove")) + if (strcmp(argv[1],"remove") == 0) { if (cur->io) { @@ -277,7 +280,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, } return true; } - if (!strcmp(cmd,"alwaysflush")) + if (strcmp(cmd,"alwaysflush") == 0) { if (argn) { @@ -293,7 +296,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, return true; } - if (!strcmp(cmd,"timestamp")) + if (strcmp(cmd,"timestamp") == 0) { if (argn) { @@ -309,14 +312,14 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, return true; } - if (!strcmp(cmd,"exit")) + if (strcmp(cmd,"exit") == 0) { exit(1); return true; } - if (!strcmp(cmd,"clear")|| - !strcmp(cmd,"add")|| - !strcmp(cmd,"view")) + if (strcmp(cmd,"clear") == 0|| + strcmp(cmd,"add") == 0|| + strcmp(cmd,"view") == 0) { unsigned mask=0; if (argn) @@ -335,7 +338,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, mask=0xffffffff; bool modified=false; - if (!strcmp(cmd,"clear")) + if (strcmp(cmd,"clear") == 0) { // remove some (or all) pattern const char *pattern=argn<2?"*":argv[1]; @@ -365,7 +368,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, else dbg.lastPatternEntry=NULL; } - if (!strcmp(cmd,"add")) + if (strcmp(cmd,"add") == 0) { // add a pattern if (argn<3) @@ -376,7 +379,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, modified=true; } } - if (!strcmp(cmd,"view")) + if (strcmp(cmd,"view") == 0) { // show list of defined patterns for (Debug::PatternListEntry *cur=dbg.firstPatternEntry;cur;cur=cur->next) diff --git a/Core/Libraries/Source/debug/debug_cmd.h b/Core/Libraries/Source/debug/debug_cmd.h index f5c3974655..3e7f0bc45c 100644 --- a/Core/Libraries/Source/debug/debug_cmd.h +++ b/Core/Libraries/Source/debug/debug_cmd.h @@ -26,11 +26,8 @@ // // Debug command interface ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef DEBUG_CMD_H // Include guard -#define DEBUG_CMD_H + +#pragma once /** \interface DebugCmdInterface debug.h @@ -127,5 +124,3 @@ class DebugCmdInterface #endif ///@} - -#endif // DEBUG_CMD_H diff --git a/Core/Libraries/Source/debug/debug_debug.cpp b/Core/Libraries/Source/debug/debug_debug.cpp index e35f9006ee..7704975032 100644 --- a/Core/Libraries/Source/debug/debug_debug.cpp +++ b/Core/Libraries/Source/debug/debug_debug.cpp @@ -26,10 +26,13 @@ // // Debug class implementation ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#include "debug.h" +#include "internal.h" +#include "internal_except.h" +#include "internal_io.h" #include -#include -#include +#include +#include #include // needed for placement new prototype // a little dummy variable that makes the linker actually include @@ -346,7 +349,7 @@ bool Debug::AssertDone(void) "time being (stops logging this assertion as well)."; char *help=(char *)DebugAllocMemory(ioBuffer[curType].used+strlen(addInfo)+1); strcpy(help,ioBuffer[curType].buffer+82); - strcat(help,addInfo); + strcat(help, addInfo); // First hit? Then do a stack trace if (curFrameEntry->hits==1) @@ -523,7 +526,7 @@ Debug& Debug::LogBegin(const char *fileOrGroup) // we're doing all this extra work so that DLOGs can be spread across // multiple calls if (Instance.curType==DebugIOInterface::StringType::Log&& - strcmp(Instance.curSource,Instance.curFrameEntry->fileOrGroup)) + strcmp(Instance.curSource,Instance.curFrameEntry->fileOrGroup) != 0) Instance.FlushOutput(); if (Instance.curType!=DebugIOInterface::StringType::Log) @@ -610,7 +613,7 @@ bool Debug::CrashDone(bool die) #endif char *help=(char *)DebugAllocMemory(ioBuffer[curType].used+strlen(addInfo)+1); strcpy(help,ioBuffer[curType].buffer+82); - strcat(help,addInfo); + strcat(help, addInfo); // First hit? Then do a stack trace if (curFrameEntry->hits==1) @@ -729,8 +732,7 @@ Debug& Debug::operator<<(const char *str) void Debug::SetPrefixAndRadix(const char *prefix, int radix) { - strncpy(m_prefix,prefix?prefix:"",sizeof(m_prefix)-1); - m_prefix[sizeof(m_prefix)-1]=0; + strlcpy(m_prefix,prefix?prefix:"",sizeof(m_prefix)); m_radix=radix; } @@ -1186,7 +1188,7 @@ void Debug::UpdateFrameStatus(FrameHashEntry &entry) entry.frameType==FrameTypeCheck) wsprintf(help,"%s(%i)",entry.fileOrGroup,entry.line); else - strcpy(help,entry.fileOrGroup); + strlcpy(help, entry.fileOrGroup, ARRAY_SIZE(help)); // update frame status bool active=entry.frameType!=FrameTypeLog; @@ -1225,7 +1227,7 @@ const char *Debug::AddLogGroup(const char *fileOrGroup, const char *descr) KnownLogGroupList *cur=firstLogGroup; for (;cur;cur=cur->next) { - if (!strcmp(cur->nameGroup,fileOrGroup)) + if (strcmp(cur->nameGroup,fileOrGroup) == 0) { // yes, return translated name return cur->nameGroup; @@ -1423,11 +1425,11 @@ void Debug::SetBuildInfo(const char *version, const char *buildDate) { if (version) - strncpy(Instance.m_version,version,sizeof(Instance.m_version)-1); + strlcpy(Instance.m_version,version,sizeof(Instance.m_version)); if (internalVersion) - strncpy(Instance.m_intVersion,internalVersion,sizeof(Instance.m_intVersion)-1); + strlcpy(Instance.m_intVersion,internalVersion,sizeof(Instance.m_intVersion)); if (buildDate) - strncpy(Instance.m_buildDate,buildDate,sizeof(Instance.m_buildDate)-1); + strlcpy(Instance.m_buildDate,buildDate,sizeof(Instance.m_buildDate)); } void Debug::WriteBuildInfo(void) @@ -1545,7 +1547,7 @@ void Debug::ExecCommand(const char *cmdstart, const char *cmdend) // command group known? for (CmdInterfaceListEntry *cur=firstCmdGroup;cur;cur=cur->next) - if (!strcmp(curCommandGroup,cur->group)) + if (strcmp(curCommandGroup,cur->group) == 0) break; if (!cur) { @@ -1561,18 +1563,18 @@ void Debug::ExecCommand(const char *cmdstart, const char *cmdend) // search for a matching command handler for (CmdInterfaceListEntry *cur=firstCmdGroup;cur;cur=cur->next) { - if (strcmp(curCommandGroup,cur->group)) + if (strcmp(curCommandGroup,cur->group) != 0) continue; bool doneCommand=cur->cmdif->Execute(*this,p,mode,numParts-1,parts+1); - if (doneCommand&&(strcmp(p,"help")||numParts>1)) + if (doneCommand&&(strcmp(p,"help") != 0||numParts>1)) break; } // display error message if command not found, break away if (!cur&&mode==DebugCmdInterface::CommandMode::Normal) { - if (strcmp(p,"help")) + if (strcmp(p,"help") != 0) operator<<("Unknown command"); else if (numParts>1) operator<<("Unknown command, help not available"); diff --git a/Core/Libraries/Source/debug/debug_debug.h b/Core/Libraries/Source/debug/debug_debug.h index bf062ad3b8..956fa6f229 100644 --- a/Core/Libraries/Source/debug/debug_debug.h +++ b/Core/Libraries/Source/debug/debug_debug.h @@ -26,11 +26,8 @@ // // main Debug object (singleton) ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef DEBUG_DEBUG_H // Include guard -#define DEBUG_DEBUG_H + +#pragma once /** \class Debug debug.h @@ -1228,5 +1225,3 @@ DLOG( "My HResult is: " << Debug::HResult(SomeHRESULTValue) << "\n" ); const char *DebugGetDefaultCommands(void); ///@} end of debug_fn group - -#endif // DEBUG_DEBUG_H diff --git a/Core/Libraries/Source/debug/debug_doc.h b/Core/Libraries/Source/debug/debug_doc.h index 792f8dcf23..364da4d85a 100644 --- a/Core/Libraries/Source/debug/debug_doc.h +++ b/Core/Libraries/Source/debug/debug_doc.h @@ -26,11 +26,8 @@ // // additional Doxygen module documentation ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef DEBUG_DOC_H // Include guard -#define DEBUG_DOC_H + +#pragma once // This generates a small main page for Doxygen if a module only // documentation is built. @@ -705,5 +702,3 @@ void test(const Point2D &val) */ - -#endif // DEBUG_DOC_H diff --git a/Core/Libraries/Source/debug/debug_except.cpp b/Core/Libraries/Source/debug/debug_except.cpp index 27b17abc40..098e1b9bf8 100644 --- a/Core/Libraries/Source/debug/debug_except.cpp +++ b/Core/Libraries/Source/debug/debug_except.cpp @@ -26,7 +26,9 @@ // // Unhandled exception handler ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#include "debug.h" +#include "internal_except.h" +#include #include DebugExceptionhandler::DebugExceptionhandler(void) @@ -342,8 +344,6 @@ static BOOL CALLBACK ExceptionDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA return TRUE; } -#include - LONG __stdcall DebugExceptionhandler::ExceptionFilter(struct _EXCEPTION_POINTERS* pExPtrs) { // we should not be calling ourselves! diff --git a/Core/Libraries/Source/debug/debug_getdefaultcommands.cpp b/Core/Libraries/Source/debug/debug_getdefaultcommands.cpp index 1705216d21..a77b9721bd 100644 --- a/Core/Libraries/Source/debug/debug_getdefaultcommands.cpp +++ b/Core/Libraries/Source/debug/debug_getdefaultcommands.cpp @@ -26,7 +26,6 @@ // // DebugGetDefaultCommands function ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" // this function has its own file so that it can be 'overridden' // by another program using the Debug module diff --git a/Core/Libraries/Source/debug/debug_internal.cpp b/Core/Libraries/Source/debug/debug_internal.cpp index ec55eb49aa..0f61056232 100644 --- a/Core/Libraries/Source/debug/debug_internal.cpp +++ b/Core/Libraries/Source/debug/debug_internal.cpp @@ -26,7 +26,8 @@ // // Implementation of internal code ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#include "debug.h" +#include void DebugInternalAssert(const char *file, int line, const char *expr) { diff --git a/Core/Libraries/Source/debug/debug_io.h b/Core/Libraries/Source/debug/debug_io.h index 18292607f2..f1d14a7ec5 100644 --- a/Core/Libraries/Source/debug/debug_io.h +++ b/Core/Libraries/Source/debug/debug_io.h @@ -26,11 +26,8 @@ // // Debug I/O interface ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef DEBUG_IO_H // Include guard -#define DEBUG_IO_H + +#pragma once /** \interface DebugIOInterface debug.h @@ -198,5 +195,3 @@ class DebugIOInterface #endif ///@} - -#endif // DEBUG_IO_H diff --git a/Core/Libraries/Source/debug/debug_io_con.cpp b/Core/Libraries/Source/debug/debug_io_con.cpp index 440e46f73d..0b9c2d605e 100644 --- a/Core/Libraries/Source/debug/debug_io_con.cpp +++ b/Core/Libraries/Source/debug/debug_io_con.cpp @@ -26,7 +26,9 @@ // // Debug I/O class con (console window) ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#include "debug.h" +#include "internal.h" +#include "internal_io.h" #include #include // needed for placement new prototype @@ -192,13 +194,13 @@ void DebugIOCon::Write(StringType type, const char *src, const char *str) void DebugIOCon::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, unsigned argn, const char * const * argv) { - if (!cmd||!strcmp(cmd,"help")) + if (!cmd||strcmp(cmd,"help") == 0) { dbg << "con I/O help:\n" " add [ [ ] ]\n" " create con I/O (optionally specifying the window size)\n"; } - else if (!strcmp(cmd,"add")) + else if (strcmp(cmd,"add") == 0) { if (argn>0&&m_allocatedConsole) { diff --git a/Core/Libraries/Source/debug/debug_io_flat.cpp b/Core/Libraries/Source/debug/debug_io_flat.cpp index 1f1bc85d1a..7e7d00ca63 100644 --- a/Core/Libraries/Source/debug/debug_io_flat.cpp +++ b/Core/Libraries/Source/debug/debug_io_flat.cpp @@ -26,8 +26,13 @@ // // Debug I/O class flat (flat or split log file) ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#include "debug.h" +#include "debug_io.h" +#include "internal.h" +#include "internal_io.h" #include +#include +#include #include // needed for placement new prototype DebugIOFlat::OutputStream::OutputStream(const char *filename, unsigned maxSize): @@ -78,22 +83,20 @@ void DebugIOFlat::OutputStream::Delete(const char *path) char help[512]; if (path[0]&&(path[1]==':'||(path[0]=='\\'&&path[1]=='\\'))) { - strcpy(help,path); - strcpy(help+pathLen,fileNameOnly); - help[ext-fileNameOnly+pathLen]=0; + strlcpy(help, path, ARRAY_SIZE(help)); + strlcat(help, fileNameOnly, ARRAY_SIZE(help)); } else { // no, relative path given - strcpy(help,m_fileName); - strcpy(help+(fileNameOnly-m_fileName),path); - strcpy(help+(fileNameOnly-m_fileName)+pathLen,fileNameOnly); - help[ext-fileNameOnly+pathLen+(fileNameOnly-m_fileName)]=0; + strlcpy(help, m_fileName, ARRAY_SIZE(help)); + strlcat(help, path, ARRAY_SIZE(help)); + strlcat(help, fileNameOnly, ARRAY_SIZE(help)); } if (++run) wsprintf(help+strlen(help),"(%i)%s",run,ext); else - strcat(help,ext); + strlcat(help, ext, ARRAY_SIZE(help)); if (CopyFile(m_fileName,help,TRUE)) break; if (GetLastError()!=ERROR_FILE_EXISTS) @@ -263,7 +266,7 @@ void DebugIOFlat::ExpandMagic(const char *src, const char *splitName, char *buf) case 'n': case 'N': if (splitName&&strlen(splitName)<250) - strcpy(help,splitName); + strlcpy(help, splitName, ARRAY_SIZE(help)); break; default: *dst++=src[-1]; @@ -272,7 +275,7 @@ void DebugIOFlat::ExpandMagic(const char *src, const char *splitName, char *buf) unsigned len=strlen(help); if (dst-buf+len>250) break; - strcpy(dst,help); + strcpy(dst, help); dst+=len; } strcpy(dst,".log"); @@ -329,14 +332,14 @@ void DebugIOFlat::EmergencyFlush(void) void DebugIOFlat::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, unsigned argn, const char * const * argv) { - if (!cmd||!strcmp(cmd,"help")) + if (!cmd||strcmp(cmd,"help") == 0) { if (!argn) dbg << "flat I/O help:\n" "The following I/O commands are defined:\n" " add, copy, splitadd, splitview, splitremove\n" "Type in debug.io flat help for a detailed command help.\n"; - else if (!strcmp(argv[0],"add")) + else if (strcmp(argv[0],"add") == 0) dbg << "add [ [ ] ]\n\n" "Create flat file I/O (optionally specifying file name and file size).\n" @@ -360,13 +363,13 @@ void DebugIOFlat::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, "size memory based ring buffer. This data is flushed out once the \n" "program exits. If no size is given then the size of the log file is not \n" "limited and any log data is written out immediately.\n"; - else if (!strcmp(argv[0],"copy")) + else if (strcmp(argv[0],"copy") == 0) dbg << "copy \n\n" "Copies generated log file(s) into the given directory if the program\n" "exists or crashes. If there is already a log file with the same\n" "name a unique number is appended to the current log files' name.\n"; - else if (!strcmp(argv[0],"splitadd")) + else if (strcmp(argv[0],"splitadd") == 0) dbg << "splitadd [ ]\n\n" "Splits off part of the log data. Multiple splits can be defined. They \n" @@ -399,21 +402,21 @@ void DebugIOFlat::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, "\n" "If no size is given then the size of the log file is not limited and \n" "any log data is written out immediately.\n"; - else if (!strcmp(argv[0],"splitview")) + else if (strcmp(argv[0],"splitview") == 0) dbg << "splitview\n\n" "Shows all existing splits in the order they are evaluated."; - else if (!strcmp(argv[0],"splitremove")) + else if (strcmp(argv[0],"splitremove") == 0) dbg << "splitremove \n\n" "Removes all active splits matching the given name pattern."; else dbg << "Unknown flat I/O command"; } - else if (!strcmp(cmd,"add")) + else if (strcmp(cmd,"add") == 0) { // add [ [ ] ] __ASSERT(m_firstStream==NULL); - strcpy(m_baseFilename,argn?argv[0]:"*eMN"); + strlcpy(m_baseFilename, argn?argv[0]:"*eMN", ARRAY_SIZE(m_baseFilename)); char fn[256]; ExpandMagic(m_baseFilename,NULL,fn); @@ -423,16 +426,15 @@ void DebugIOFlat::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, m_firstStream->stream=OutputStream::Create(fn,argn>1?atoi(argv[1])*1024:0); m_lastStreamPtr=&m_firstStream->next; } - else if (!strcmp(cmd,"copy")) + else if (strcmp(cmd,"copy") == 0) { // copy if (argn) { - strncpy(m_copyDir,argv[0],sizeof(m_copyDir)-1); - m_copyDir[sizeof(m_copyDir)-1]=0; + strlcpy(m_copyDir,argv[0],sizeof(m_copyDir)); } } - else if (!strcmp(cmd,"splitadd")) + else if (strcmp(cmd,"splitadd") == 0) { // splitadd [ ] if (argn>=3) @@ -460,18 +462,15 @@ void DebugIOFlat::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, if (!cur->stringTypes) cur->stringTypes=0xffffffff; - strncpy(cur->items,argv[1],sizeof(cur->items)-1); - cur->items[sizeof(cur->items)-1]=0; - - strncpy(cur->name,argv[2],sizeof(cur->name)-1); - cur->name[sizeof(cur->name)-1]=0; + strlcpy(cur->items,argv[1],sizeof(cur->items)); + strlcpy(cur->name,argv[2],sizeof(cur->name)); // create our filename, search for stream with same filename char fn[256]; ExpandMagic(m_baseFilename,cur->name,fn); StreamListEntry *stream=m_firstStream; for (;stream;stream=stream->next) - if (!strcmp(stream->stream->GetFilename(),fn)) + if (strcmp(stream->stream->GetFilename(),fn) == 0) break; if (!stream) { @@ -485,7 +484,7 @@ void DebugIOFlat::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, cur->stream=stream->stream; } } - else if (!strcmp(cmd,"splitview")) + else if (strcmp(cmd,"splitview") == 0) { // splitview for (SplitListEntry *cur=m_firstSplit;cur;cur=cur->next) @@ -508,7 +507,7 @@ void DebugIOFlat::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, dbg << " " << cur->items << " " << cur->name << "\n"; } } - else if (!strcmp(cmd,"splitremove")) + else if (strcmp(cmd,"splitremove") == 0) { // splitremove const char *pattern=argn<1?"*":argv[0]; diff --git a/Core/Libraries/Source/debug/debug_io_net.cpp b/Core/Libraries/Source/debug/debug_io_net.cpp index f34c753633..52e3166102 100644 --- a/Core/Libraries/Source/debug/debug_io_net.cpp +++ b/Core/Libraries/Source/debug/debug_io_net.cpp @@ -26,7 +26,10 @@ // // Debug I/O class net (Network destination via named pipe) ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#include "debug.h" +#include "internal.h" +#include "internal_io.h" +#include #include // needed for placement new prototype DebugIONet::DebugIONet(void) @@ -83,13 +86,13 @@ void DebugIONet::EmergencyFlush(void) void DebugIONet::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, unsigned argn, const char * const * argv) { - if (!cmd||!strcmp(cmd,"help")) + if (!cmd||strcmp(cmd,"help") == 0) { dbg << "net I/O help:\n" " add [ ]\n" " create net I/O (optionally specifying the machine to connect to)\n"; } - else if (!strcmp(cmd,"add")) + else if (strcmp(cmd,"add") == 0) { const char *machine=argn?argv[0]:"."; diff --git a/Core/Libraries/Source/debug/debug_io_ods.cpp b/Core/Libraries/Source/debug/debug_io_ods.cpp index 2d574142a4..4e5ac90364 100644 --- a/Core/Libraries/Source/debug/debug_io_ods.cpp +++ b/Core/Libraries/Source/debug/debug_io_ods.cpp @@ -26,7 +26,9 @@ // // Debug I/O class ods (OutputDebugString, for use in debugger) ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#include "debug.h" +#include "internal.h" +#include "internal_io.h" #include // needed for placement new prototype void DebugIOOds::Write(StringType type, const char *src, const char *str) diff --git a/Core/Libraries/Source/debug/debug_macro.h b/Core/Libraries/Source/debug/debug_macro.h index cf50b27016..b4b0f07400 100644 --- a/Core/Libraries/Source/debug/debug_macro.h +++ b/Core/Libraries/Source/debug/debug_macro.h @@ -26,11 +26,8 @@ // // Debugging macros ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef DEBUG_MACRO_H // Include guard -#define DEBUG_MACRO_H + +#pragma once // I'm putting the documentation for the following macros // here because Doxygen otherwise includes the values of each macro @@ -390,5 +387,3 @@ sourcefname.cpp (123) : Hello world be forgotten. */ #define MESSAGE(a) message (__FILE__ "(" TOKEN_IT(__LINE__) ") : " a) - -#endif // DEBUG_MACRO_H diff --git a/Core/Libraries/Source/debug/debug_stack.cpp b/Core/Libraries/Source/debug/debug_stack.cpp index 60a5aae4fd..5864566133 100644 --- a/Core/Libraries/Source/debug/debug_stack.cpp +++ b/Core/Libraries/Source/debug/debug_stack.cpp @@ -26,7 +26,10 @@ // // Stack walker ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#include "debug.h" +#include "debug_stack.h" +#include +#include "stringex.h" #include // Definitions to allow run-time linking to the dbghelp.dll functions. @@ -47,7 +50,7 @@ static union #undef DBGHELP #define DBGHELP(name,ret,par) #name, -static char const *DebughelpFunctionNames[] = +static char const *const DebughelpFunctionNames[] = { #include "debug_stack.inl" NULL @@ -250,8 +253,7 @@ void DebugStackwalk::Signature::GetSymbol(unsigned addr, char *p=strrchr(symbolBuffer,'\\'); // use filename only, strip off path p=p?p+1:symbolBuffer; - strncpy(bufMod,p,sizeMod); - bufMod[sizeMod-1]=0; + strlcpy(bufMod,p,sizeMod); } if (relMod) *relMod=addr-modBase; @@ -266,8 +268,7 @@ void DebugStackwalk::Signature::GetSymbol(unsigned addr, DWORD displacement; if (gDbg._SymGetSymFromAddr((HANDLE)GetCurrentProcessId(),addr,&displacement,symPtr)) { - strncpy(bufSym,symPtr->Name,sizeSym); - bufSym[sizeSym-1]=0; + strlcpy(bufSym,symPtr->Name,sizeSym); if (relSym) *relSym=displacement; } @@ -288,8 +289,7 @@ void DebugStackwalk::Signature::GetSymbol(unsigned addr, { char *p=strrchr(line.FileName,'\\'); // use filename only, strip off path p=p?p+1:line.FileName; - strncpy(bufFile,p,sizeFile); - bufFile[sizeFile-1]=0; + strlcpy(bufFile,p,sizeFile); if (linePtr) *linePtr=line.LineNumber; if (relLine) diff --git a/Core/Libraries/Source/debug/debug_stack.h b/Core/Libraries/Source/debug/debug_stack.h index 977d0d1a11..fdb6677f8f 100644 --- a/Core/Libraries/Source/debug/debug_stack.h +++ b/Core/Libraries/Source/debug/debug_stack.h @@ -26,11 +26,8 @@ // // Stack walker ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef DEBUG_STACK_H // Include guard -#define DEBUG_STACK_H + +#pragma once /// \brief stack walker class (singleton) class DebugStackwalk @@ -168,5 +165,3 @@ class DebugStackwalk \return debug instance */ Debug& operator<<(Debug &dbg, const DebugStackwalk::Signature &sig); - -#endif // DEBUG_STACK_H diff --git a/Core/Libraries/Source/debug/internal.h b/Core/Libraries/Source/debug/internal.h index 3735764b25..775bcc8445 100644 --- a/Core/Libraries/Source/debug/internal.h +++ b/Core/Libraries/Source/debug/internal.h @@ -26,11 +26,8 @@ // // Internal header ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef INTERNAL_H // Include guard -#define INTERNAL_H + +#pragma once // make sure we're not omitting the frame pointer #pragma optimize("y",off) @@ -97,5 +94,3 @@ class DebugCmdInterfaceDebug: public DebugCmdInterface DebugFreeMemory(this); } }; - -#endif // INTERNAL_H diff --git a/Core/Libraries/Source/debug/internal_except.h b/Core/Libraries/Source/debug/internal_except.h index 3fc963601f..2e17cd0f03 100644 --- a/Core/Libraries/Source/debug/internal_except.h +++ b/Core/Libraries/Source/debug/internal_except.h @@ -26,11 +26,8 @@ // // Unhandled exception handler ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef INTERNAL_EXCEPT_H // Include guard -#define INTERNAL_EXCEPT_H + +#pragma once /// \internal exception handler class DebugExceptionhandler @@ -86,5 +83,3 @@ class DebugExceptionhandler */ static long __stdcall ExceptionFilter(struct _EXCEPTION_POINTERS* pExPtrs); }; - -#endif // INTERNAL_EXCEPT_H diff --git a/Core/Libraries/Source/debug/internal_io.h b/Core/Libraries/Source/debug/internal_io.h index 372275182c..ddb0b18693 100644 --- a/Core/Libraries/Source/debug/internal_io.h +++ b/Core/Libraries/Source/debug/internal_io.h @@ -26,11 +26,10 @@ // // Internal header: I/O classes ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef INTERNAL_IO_H // Include guard -#define INTERNAL_IO_H + +#pragma once + +#include /// \internal \brief con debug I/O class class DebugIOCon: public DebugIOInterface @@ -252,5 +251,3 @@ class DebugIOOds: public DebugIOInterface static DebugIOInterface *Create(void); virtual void Delete(void); }; - -#endif // INTERNAL_IO_H diff --git a/Core/Libraries/Source/debug/netserv/netserv.cpp b/Core/Libraries/Source/debug/netserv/netserv.cpp index 63c1d806f4..45abd3717c 100644 --- a/Core/Libraries/Source/debug/netserv/netserv.cpp +++ b/Core/Libraries/Source/debug/netserv/netserv.cpp @@ -297,7 +297,7 @@ int CALLBACK WinMain(HINSTANCE,HINSTANCE,LPSTR,int) char *input=InputConsole(); if (input) { - if (!strcmp(input,"quit")) + if (strcmp(input,"quit") == 0) break; } diff --git a/Core/Libraries/Source/debug/test2/StdAfx.cpp b/Core/Libraries/Source/debug/test2/StdAfx.cpp index 728477e7ca..3b7245248e 100644 --- a/Core/Libraries/Source/debug/test2/StdAfx.cpp +++ b/Core/Libraries/Source/debug/test2/StdAfx.cpp @@ -22,5 +22,5 @@ #include "StdAfx.h" -// TODO: reference any additional headers you need in STDAFX.H +// TODO: reference any additional headers you need in STDAFX.h // and not in this file diff --git a/Core/Libraries/Source/debug/test2/StdAfx.h b/Core/Libraries/Source/debug/test2/StdAfx.h index 89be871b3e..a435c4af8d 100644 --- a/Core/Libraries/Source/debug/test2/StdAfx.h +++ b/Core/Libraries/Source/debug/test2/StdAfx.h @@ -21,12 +21,7 @@ // are changed infrequently // -#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) -#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers @@ -46,5 +41,3 @@ //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) diff --git a/Core/Libraries/Source/debug/test2/test2.cpp b/Core/Libraries/Source/debug/test2/test2.cpp index b8352794da..0980746ec0 100644 --- a/Core/Libraries/Source/debug/test2/test2.cpp +++ b/Core/Libraries/Source/debug/test2/test2.cpp @@ -51,7 +51,7 @@ class TestCmdInterface: public DebugCmdInterface virtual bool Execute(class Debug& dbg, const char *cmd, CommandMode cmdmode, unsigned argn, const char * const * argv) { - if (strcmp(cmd,"box")) + if (strcmp(cmd,"box") != 0) return false; MessageBox(NULL,"Hello world!","Command",MB_OK); diff --git a/Core/Libraries/Source/debug/test3/test3.cpp b/Core/Libraries/Source/debug/test3/test3.cpp index 4298a6d883..bd16f76ba5 100644 --- a/Core/Libraries/Source/debug/test3/test3.cpp +++ b/Core/Libraries/Source/debug/test3/test3.cpp @@ -26,7 +26,7 @@ // // Debug module - Test 3 (Checking FLAT I/O, logging) ////////////////////////////////////////////////////////////////////////////// -#ifdef NDEBUG + #include "../debug.h" unsigned divByNull; diff --git a/Core/Libraries/Source/profile/CMakeLists.txt b/Core/Libraries/Source/profile/CMakeLists.txt index bad4e7f94c..e2457d8038 100644 --- a/Core/Libraries/Source/profile/CMakeLists.txt +++ b/Core/Libraries/Source/profile/CMakeLists.txt @@ -1,6 +1,4 @@ set(PROFILE_SRC - "_pch.cpp" - "_pch.h" "internal_cmd.h" "internal_funclevel.h" "internal_highlevel.h" @@ -26,7 +24,14 @@ target_include_directories(core_profile INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ) +target_precompile_headers(core_profile PRIVATE + "profile.h" + "internal.h" + +) + target_link_libraries(core_profile PRIVATE core_config + core_wwcommon corei_always ) diff --git a/Core/Libraries/Source/profile/_pch.cpp b/Core/Libraries/Source/profile/_pch.cpp deleted file mode 100644 index b3ad7391e6..0000000000 --- a/Core/Libraries/Source/profile/_pch.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/_pch.cpp $ -// $Author: mhoffe $ -// $Revision: #1 $ -// $DateTime: 2003/07/03 11:55:26 $ -// -// (c) 2003 Electronic Arts -// -// Precompiled header (module internal) -////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" diff --git a/Core/Libraries/Source/profile/_pch.h b/Core/Libraries/Source/profile/_pch.h deleted file mode 100644 index 13d2bfaa8f..0000000000 --- a/Core/Libraries/Source/profile/_pch.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -** Command & Conquer Generals Zero Hour(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 . -*/ - -/////////////////////////////////////////////////////////////////////////EA-V1 -// $File: //depot/GeneralsMD/Staging/code/Libraries/Source/profile/_pch.h $ -// $Author: mhoffe $ -// $Revision: #1 $ -// $DateTime: 2003/07/03 11:55:26 $ -// -// (c) 2003 Electronic Arts -// -// Precompiled header (module internal) -////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef _PCH_H // Include guard -#define _PCH_H - -#define WIN32_LEAN_AND_MEAN -#define STRICT -#include - -#include "profile.h" -#include "internal.h" - -#endif // _PCH_H diff --git a/Core/Libraries/Source/profile/internal.h b/Core/Libraries/Source/profile/internal.h index 3337436d20..b80d223baa 100644 --- a/Core/Libraries/Source/profile/internal.h +++ b/Core/Libraries/Source/profile/internal.h @@ -26,11 +26,8 @@ // // Internal header ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef INTERNAL_H // Include guard -#define INTERNAL_H + +#pragma once #include "../debug/debug.h" #include "internal_funclevel.h" @@ -38,6 +35,7 @@ #include "internal_cmd.h" #include "internal_result.h" #include "Utility/CppMacros.h" +#include #if !(defined(_MSC_VER) && _MSC_VER < 1300) #include @@ -154,5 +152,3 @@ __forceinline void ProfileGetTime(__int64 &t) t = static_cast<__int64>(_rdtsc()); #endif } - -#endif // INTERNAL_H diff --git a/Core/Libraries/Source/profile/internal_cmd.h b/Core/Libraries/Source/profile/internal_cmd.h index bb2ee94725..b46cb1e17c 100644 --- a/Core/Libraries/Source/profile/internal_cmd.h +++ b/Core/Libraries/Source/profile/internal_cmd.h @@ -26,11 +26,8 @@ // // Profile module command interface ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef INTERNAL_CMD_H // Include guard -#define INTERNAL_CMD_H + +#pragma once class ProfileCmdInterface: public DebugCmdInterface { @@ -57,5 +54,3 @@ class ProfileCmdInterface: public DebugCmdInterface unsigned argn, const char * const * argv); virtual void Delete(void) {} }; - -#endif // INTERNAL_CMD_H diff --git a/Core/Libraries/Source/profile/internal_funclevel.h b/Core/Libraries/Source/profile/internal_funclevel.h index cc8a854b8c..e9229dbf22 100644 --- a/Core/Libraries/Source/profile/internal_funclevel.h +++ b/Core/Libraries/Source/profile/internal_funclevel.h @@ -26,11 +26,10 @@ // // Function level profiling (internal header) ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef INTERNAL_FUNCLEVEL_H // Include guard -#define INTERNAL_FUNCLEVEL_H + +#pragma once + +#include class ProfileFuncLevelTracer { @@ -358,5 +357,3 @@ inline ProfileFuncLevelTracer::Function *ProfileFuncLevelTracer::FunctionMap::Fi return e->funcPtr; return NULL; } - -#endif // INTERNAL_FUNCLEVEL_H diff --git a/Core/Libraries/Source/profile/internal_highlevel.h b/Core/Libraries/Source/profile/internal_highlevel.h index 8c8b0765e7..2d9c572755 100644 --- a/Core/Libraries/Source/profile/internal_highlevel.h +++ b/Core/Libraries/Source/profile/internal_highlevel.h @@ -26,11 +26,8 @@ // // High level profiling (internal header) ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef INTERNAL_HIGHLEVEL_H // Include guard -#define INTERNAL_HIGHLEVEL_H + +#pragma once /// an internal high level profile ID class ProfileId @@ -243,5 +240,3 @@ class ProfileId /// next unused char in string buffer static unsigned stringBufUnused; }; - -#endif // INTERNAL_HIGHLEVEL_H diff --git a/Core/Libraries/Source/profile/internal_result.h b/Core/Libraries/Source/profile/internal_result.h index a36399907e..a62f082a39 100644 --- a/Core/Libraries/Source/profile/internal_result.h +++ b/Core/Libraries/Source/profile/internal_result.h @@ -26,11 +26,8 @@ // // Internal result functions ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef INTERNAL_RESULT_H // Include guard -#define INTERNAL_RESULT_H + +#pragma once /// \brief Simple CSV format flat file result function, for all threads. class ProfileResultFileCSV: public ProfileResultInterface @@ -98,5 +95,3 @@ class ProfileResultFileDOT: public ProfileResultInterface char *m_frameName; int m_foldThreshold; }; - -#endif // INTERNAL_RESULT_H diff --git a/Core/Libraries/Source/profile/profile.cpp b/Core/Libraries/Source/profile/profile.cpp index 3685f7395a..66981103b7 100644 --- a/Core/Libraries/Source/profile/profile.cpp +++ b/Core/Libraries/Source/profile/profile.cpp @@ -26,7 +26,8 @@ // // Profile module main code ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#include "profile.h" +#include "internal.h" #include #include "mmsystem.h" @@ -165,7 +166,7 @@ void Profile::StartRange(const char *range) // known name? unsigned k=0; for (;k\n" "\n" @@ -111,7 +112,7 @@ bool ProfileCmdInterface::Execute(class Debug& dbg, const char *cmd, CommandMode "- for inactive). The final state is always the last match."; return true; } - else if (!strcmp(argv[0],"view")) + else if (strcmp(argv[0],"view") == 0) { dbg << "view\n\n" "Shows the active pattern list.\n"; @@ -121,7 +122,7 @@ bool ProfileCmdInterface::Execute(class Debug& dbg, const char *cmd, CommandMode } // command: result - if (!strcmp(cmd,"result")) + if (strcmp(cmd,"result") == 0) { if (!argn) { @@ -138,7 +139,7 @@ bool ProfileCmdInterface::Execute(class Debug& dbg, const char *cmd, CommandMode { unsigned k=0; for (;knext) diff --git a/Core/Libraries/Source/profile/profile_doc.h b/Core/Libraries/Source/profile/profile_doc.h index c025c4a85e..7fb82b37ab 100644 --- a/Core/Libraries/Source/profile/profile_doc.h +++ b/Core/Libraries/Source/profile/profile_doc.h @@ -26,11 +26,8 @@ // // additional Doxygen module documentation ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef PROFILE_DOC_H // Include guard -#define PROFILE_DOC_H + +#pragma once // This generates a small main page for Doxygen if a module only // documentation is built. @@ -192,5 +189,3 @@ */ - -#endif // PROFILE_DOC_H diff --git a/Core/Libraries/Source/profile/profile_funclevel.cpp b/Core/Libraries/Source/profile/profile_funclevel.cpp index 941de59c95..3c7110ca2f 100644 --- a/Core/Libraries/Source/profile/profile_funclevel.cpp +++ b/Core/Libraries/Source/profile/profile_funclevel.cpp @@ -26,7 +26,8 @@ // // Function level profiling ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#include "profile.h" +#include "internal.h" #include "../debug/debug.h" #include diff --git a/Core/Libraries/Source/profile/profile_funclevel.h b/Core/Libraries/Source/profile/profile_funclevel.h index d0c61432e4..afe2227b0f 100644 --- a/Core/Libraries/Source/profile/profile_funclevel.h +++ b/Core/Libraries/Source/profile/profile_funclevel.h @@ -26,11 +26,8 @@ // // Function level profiling ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef PROFILE_FUNCLEVEL_H // Include guard -#define PROFILE_FUNCLEVEL_H + +#pragma once /** \brief The function level profiler. @@ -219,5 +216,3 @@ class ProfileFuncLevel */ static ProfileFuncLevel Instance; }; - -#endif // PROFILE_FUNCLEVEL_H diff --git a/Core/Libraries/Source/profile/profile_highlevel.cpp b/Core/Libraries/Source/profile/profile_highlevel.cpp index 06cc22aca6..fa55293e93 100644 --- a/Core/Libraries/Source/profile/profile_highlevel.cpp +++ b/Core/Libraries/Source/profile/profile_highlevel.cpp @@ -26,9 +26,10 @@ // // High level profiling ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#include "profile.h" +#include "internal.h" #include -#include +#include // our own fast critical section static ProfileFastCS cs; @@ -91,9 +92,8 @@ ProfileHighLevel::Block::Block(const char *name) m_idTime=AddProfile(name,NULL,"msec",6,-4); char help[256]; - strncpy(help,name,sizeof(help)); - help[sizeof(help)-1-2]=0; - strcat(help,".c"); + strlcpy(help, name, sizeof(help) - 2); + strlcat(help, ".c", sizeof(help)); AddProfile(help,NULL,"calls",6,0).Increment(); ProfileGetTime(m_start); @@ -324,7 +324,7 @@ bool ProfileHighLevel::FindProfile(const char *name, Id &id) ProfileFastCS::Lock lock(cs); for (ProfileId *cur=ProfileId::GetFirst();cur;cur=cur->GetNext()) - if (!strcmp(name,cur->GetName())) + if (strcmp(name,cur->GetName()) == 0) { id.m_idPtr=cur; return true; diff --git a/Core/Libraries/Source/profile/profile_highlevel.h b/Core/Libraries/Source/profile/profile_highlevel.h index 323b85fc33..dea386181b 100644 --- a/Core/Libraries/Source/profile/profile_highlevel.h +++ b/Core/Libraries/Source/profile/profile_highlevel.h @@ -26,11 +26,8 @@ // // High level profiling ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef PROFILE_HIGHLEVEL_H // Include guard -#define PROFILE_HIGHLEVEL_H + +#pragma once /// \internal internal Id representation class ProfileId; @@ -237,5 +234,3 @@ class ProfileHighLevel */ static ProfileHighLevel Instance; }; - -#endif // PROFILE_HIGHLEVEL_H diff --git a/Core/Libraries/Source/profile/profile_result.cpp b/Core/Libraries/Source/profile/profile_result.cpp index c0eff27de1..13d55a679b 100644 --- a/Core/Libraries/Source/profile/profile_result.cpp +++ b/Core/Libraries/Source/profile/profile_result.cpp @@ -26,10 +26,11 @@ // // Result function interface and result functions ////////////////////////////////////////////////////////////////////////////// -#include "_pch.h" +#include "profile.h" +#include "internal.h" #include -#include #include +#include ////////////////////////////////////////////////////////////////////////////// // ProfileResultFileCSV @@ -195,7 +196,7 @@ void ProfileResultFileDOT::WriteResults(void) if (m_frameName) { for (unsigned k=0;knext) - if (!strcmp(source,cur->source)) + if (strcmp(source,cur->source) == 0) { if (cur->numIdid[cur->numId++]=id; @@ -263,7 +264,7 @@ void ProfileResultFileDOT::WriteResults(void) { const char *s=caller.GetSource(); for (FoldHelper *cur2=fold;cur2;cur2=cur2->next) - if (!strcmp(cur2->source,s)) + if (strcmp(cur2->source,s) == 0) break; if (!cur2||cur2->mark) continue; diff --git a/Core/Libraries/Source/profile/profile_result.h b/Core/Libraries/Source/profile/profile_result.h index bc7fcf67c6..64a619ebfd 100644 --- a/Core/Libraries/Source/profile/profile_result.h +++ b/Core/Libraries/Source/profile/profile_result.h @@ -26,11 +26,8 @@ // // Result function interface and result functions ////////////////////////////////////////////////////////////////////////////// -#ifdef _MSC_VER -# pragma once -#endif -#ifndef PROFILE_RESULT_H // Include guard -#define PROFILE_RESULT_H + +#pragma once /** \brief Result function class. @@ -62,5 +59,3 @@ class ProfileResultInterface protected: ProfileResultInterface(void) {} }; - -#endif // PROFILE_RESULT_H diff --git a/Core/Tools/Autorun/ARGS.CPP b/Core/Tools/Autorun/ARGS.cpp similarity index 99% rename from Core/Tools/Autorun/ARGS.CPP rename to Core/Tools/Autorun/ARGS.cpp index dab619779e..ce3ec5c4ee 100644 --- a/Core/Tools/Autorun/ARGS.CPP +++ b/Core/Tools/Autorun/ARGS.cpp @@ -40,7 +40,7 @@ #include #include -#include "ARGS.H" +#include "ARGS.h" //----------------------------------------------------------------------------- // GLOBALS diff --git a/Core/Tools/Autorun/ARGS.H b/Core/Tools/Autorun/ARGS.h similarity index 97% rename from Core/Tools/Autorun/ARGS.H rename to Core/Tools/Autorun/ARGS.h index b4374361e1..fad81dea36 100644 --- a/Core/Tools/Autorun/ARGS.H +++ b/Core/Tools/Autorun/ARGS.h @@ -30,8 +30,7 @@ // //================================================================================================ -#ifndef ARGS_H -#define ARGS_H +#pragma once //---------------------------------------------------------------------------- // INCLUDES @@ -66,5 +65,3 @@ class Command_Line_Arguments }; extern Command_Line_Arguments *Args; - -#endif // ARGC_ARGV_H diff --git a/Core/Tools/Autorun/CDCNTRL.CPP b/Core/Tools/Autorun/CDCNTRL.cpp similarity index 99% rename from Core/Tools/Autorun/CDCNTRL.CPP rename to Core/Tools/Autorun/CDCNTRL.cpp index cd01b894f7..7d9f981a97 100644 --- a/Core/Tools/Autorun/CDCNTRL.CPP +++ b/Core/Tools/Autorun/CDCNTRL.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Renegade Setup/Autorun/CDCNTRL.CPP $* + * $Archive:: /Renegade Setup/Autorun/CDCNTRL.cpp $* * * * $Author:: Maria_l $* * * @@ -61,8 +61,8 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "assert.h" -#include "CDCNTRL.H" -#include "WinFix.H" +#include "CDCNTRL.h" +#include "WinFix.h" #include "Wnd_File.h" #pragma warning(disable : 4201) #include diff --git a/Core/Tools/Autorun/CDCNTRL.H b/Core/Tools/Autorun/CDCNTRL.h similarity index 98% rename from Core/Tools/Autorun/CDCNTRL.H rename to Core/Tools/Autorun/CDCNTRL.h index a63785e11b..7759d49a2d 100644 --- a/Core/Tools/Autorun/CDCNTRL.H +++ b/Core/Tools/Autorun/CDCNTRL.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Renegade Setup/Autorun/CDCNTRL.H $* + * $Archive:: /Renegade Setup/Autorun/CDCNTRL.h $* * * * $Author:: Maria_l $* * * @@ -36,11 +36,6 @@ #pragma once - -#ifndef _CDCNTRL -#define _CDCNTRL - - //#include "always.h" //#include #define STRICT @@ -149,8 +144,3 @@ typedef struct _PARAMBLOCK { } PARAMBLOCK, *PPARAMBLOCK; #pragma pack() - - - -#endif //_CDCNTRL - diff --git a/Core/Tools/Autorun/CMakeLists.txt b/Core/Tools/Autorun/CMakeLists.txt index bf3dddcfb0..ad06ebd5f9 100644 --- a/Core/Tools/Autorun/CMakeLists.txt +++ b/Core/Tools/Autorun/CMakeLists.txt @@ -1,23 +1,23 @@ set(AUTORUN_SRC - "ARGS.CPP" - "ARGS.H" + "ARGS.cpp" + "ARGS.h" "autorun.cpp" "autorun.h" "CallbackHook.h" - "CDCNTRL.CPP" - "CDCNTRL.H" + "CDCNTRL.cpp" + "CDCNTRL.h" "DrawButton.cpp" "DrawButton.h" "EZGIMEX.cpp" "GameText.cpp" "GameText.h" - "GETCD.CPP" + "GETCD.cpp" "GetCD.h" "gimex.h" "IGR.cpp" "IGR.h" "Jsupport.cpp" - "JSUPPORT.H" + "JSUPPORT.h" "leanAndMeanAutorun.h" "Locale_API.cpp" "Locale_API.h" @@ -32,8 +32,8 @@ set(AUTORUN_SRC "Utils.h" "ViewHTML.cpp" "ViewHTML.h" - "WinFix.CPP" - "WinFix.H" + "WinFix.cpp" + "WinFix.h" "Wnd_file.cpp" "Wnd_File.h" "WSYS_File.cpp" diff --git a/Core/Tools/Autorun/CallbackHook.h b/Core/Tools/Autorun/CallbackHook.h index 6864412d26..1bbaac4a92 100644 --- a/Core/Tools/Autorun/CallbackHook.h +++ b/Core/Tools/Autorun/CallbackHook.h @@ -33,8 +33,7 @@ * ******************************************************************************/ -#ifndef CALLBACKHOOK_H -#define CALLBACKHOOK_H +#pragma once class CallbackHook { @@ -81,5 +80,3 @@ template class Callback : public CallbackHook bool (*mCallback)(T); T mUserData; }; - -#endif // CALLBACKHOOK_H diff --git a/Core/Tools/Autorun/DrawButton.cpp b/Core/Tools/Autorun/DrawButton.cpp index 8d9bed99e0..edd7009682 100644 --- a/Core/Tools/Autorun/DrawButton.cpp +++ b/Core/Tools/Autorun/DrawButton.cpp @@ -22,7 +22,7 @@ * * * Project Name : Autorun * * * - * File Name : AUTORUN.CPP * + * File Name : AUTORUN.cpp * * * * Programmers: Maria del Mar McCready Legg * * * diff --git a/Core/Tools/Autorun/DrawButton.h b/Core/Tools/Autorun/DrawButton.h index 3748e133b9..582b4917a4 100644 --- a/Core/Tools/Autorun/DrawButton.h +++ b/Core/Tools/Autorun/DrawButton.h @@ -22,7 +22,7 @@ * * * Project Name : DrawButton * * * - * File Name : DRAWBUTTON.H * + * File Name : DRAWBUTTON.h * * * * Programmer : Maria del Mar McCready Legg * * * @@ -31,8 +31,7 @@ * Last Update : October 5, 2000 [MML] * *----------------------------------------------------------------------*/ -#ifndef DRAWBUTTONS_H -#define DRAWBUTTONS_H +#pragma once #include #include @@ -99,10 +98,3 @@ class DrawButton char PressedBitmap[ _MAX_FNAME ]; char FocusBitmap [ _MAX_FNAME ]; }; - - - - - - -#endif diff --git a/Core/Tools/Autorun/GETCD.CPP b/Core/Tools/Autorun/GETCD.cpp similarity index 98% rename from Core/Tools/Autorun/GETCD.CPP rename to Core/Tools/Autorun/GETCD.cpp index d23924dc94..fa8df05e26 100644 --- a/Core/Tools/Autorun/GETCD.CPP +++ b/Core/Tools/Autorun/GETCD.cpp @@ -20,7 +20,7 @@ ***** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***** **************************************************************************** * Project Name:: Command & Conquer * - * $Archive:: /Renegade Setup/Autorun/GETCD.CPP $Author:: Steve_t * + * $Archive:: /Renegade Setup/Autorun/GETCD.cpp $Author:: Steve_t * * $Modtime:: 1/28/02 10:54a $Revision:: 20 * *--------------------------------------------------------------------------* * Functions: * @@ -37,7 +37,7 @@ //#include "timer.h" #include "Wnd_File.h" //#include "missiondisk.h" -#include "WinFix.H" +#include "WinFix.h" #ifndef ROR_NOT_READY #define ROR_NOT_READY 21 @@ -200,7 +200,7 @@ int GetCDClass::Get_CD_Drive_For_This_Volume ( const char *volume_label ) volume_name[11] = '\0'; } - if ( !_stricmp( volume_label, volume_name )) { + if ( _stricmp( volume_label, volume_name ) == 0) { return( cd_drive ); } @@ -385,7 +385,7 @@ bool CD_Volume_Verification ( int cd_drive, char *volume_label, char *volume_to_ strncpy( volume_label, volume_name, 128 ); } - if ( !_stricmp( volume_to_find, volume_name )) { + if ( _stricmp( volume_to_find, volume_name ) == 0) { return TRUE; } diff --git a/Core/Tools/Autorun/GameText.cpp b/Core/Tools/Autorun/GameText.cpp index 9332136456..c2f990fc4e 100644 --- a/Core/Tools/Autorun/GameText.cpp +++ b/Core/Tools/Autorun/GameText.cpp @@ -227,7 +227,7 @@ GameTextManager::GameTextManager() m_munkee(FALSE), m_noStringList(NULL), m_useStringFile(TRUE), - m_failed(L"***FATAL*** String Manager failed to initilaized properly") + m_failed(L"***FATAL*** String Manager failed to initialized properly") { } @@ -340,18 +340,11 @@ void GameTextManager::init( void ) void GameTextManager::deinit( void ) { + delete [] m_stringInfo; + m_stringInfo = NULL; - if( m_stringInfo != NULL ) - { - delete [] m_stringInfo; - m_stringInfo = NULL; - } - - if( m_stringLUT != NULL ) - { - delete [] m_stringLUT; - m_stringLUT = NULL; - } + delete [] m_stringLUT; + m_stringLUT = NULL; m_textCount = 0; @@ -448,7 +441,7 @@ void GameTextManager::removeLeadingAndTrailing ( Char *buffer ) while ( (*ptr++ = *first++) != 0 ); - ptr -= 2;; + ptr -= 2; while ( (ptr > buffer) && (ch = *ptr) != 0 && iswspace ( ch ) ) { @@ -785,7 +778,7 @@ Bool GameTextManager::getStringCount( char *filename ) m_buffer[ len+1] = 0; readToEndOfQuote( &file, &m_buffer[1], m_buffer2, m_buffer3, MAX_UITEXT_LENGTH ); } - else if( !stricmp( m_buffer, "END") ) + else if( stricmp( m_buffer, "END") == 0 ) { m_textCount++; } @@ -981,7 +974,7 @@ Bool GameTextManager::parseStringFile( char *filename ) for ( Int i = 0; i < listCount; i++ ) { - if ( !stricmp ( m_stringInfo[i].label.c_str(), m_buffer )) + if ( stricmp ( m_stringInfo[i].label.c_str(), m_buffer ) == 0 ) { DEBUG_ASSERTCRASH ( FALSE, ("String label '%s' multiply defined!", m_buffer )); } @@ -1032,7 +1025,7 @@ Bool GameTextManager::parseStringFile( char *filename ) readString = TRUE; } } - else if ( !stricmp ( m_buffer, "END" )) + else if ( stricmp ( m_buffer, "END" ) == 0 ) { break; } diff --git a/Core/Tools/Autorun/GameText.h b/Core/Tools/Autorun/GameText.h index 581e55d2f8..df51f3810a 100644 --- a/Core/Tools/Autorun/GameText.h +++ b/Core/Tools/Autorun/GameText.h @@ -35,10 +35,6 @@ #pragma once -#ifndef __GAMECLIENT_GAMETEXT_H_ -#define __GAMECLIENT_GAMETEXT_H_ - - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -77,6 +73,3 @@ extern GameTextInterface* CreateGameTextInterface( void ); //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- - - -#endif // __GAMECLIENT_GAMETEXT_H_ diff --git a/Core/Tools/Autorun/GetCD.h b/Core/Tools/Autorun/GetCD.h index e92efc7f88..8f33d0a54e 100644 --- a/Core/Tools/Autorun/GetCD.h +++ b/Core/Tools/Autorun/GetCD.h @@ -31,10 +31,6 @@ #pragma once -#ifndef GETCD_H -#define GETCD_H - - extern const char * _CD_Volume_Label[]; extern int _Num_Volumes; @@ -318,6 +314,3 @@ extern GetCDClass CDList; // Functions //----------------------------------------------------------------------------- bool CD_Volume_Verification ( int cd_drive, char *volume_label, char *volume_to_find ); - - -#endif // PLAYCD_H diff --git a/Core/Tools/Autorun/JSUPPORT.H b/Core/Tools/Autorun/JSUPPORT.h similarity index 98% rename from Core/Tools/Autorun/JSUPPORT.H rename to Core/Tools/Autorun/JSUPPORT.h index 3138a1fd1f..a83751fb89 100644 --- a/Core/Tools/Autorun/JSUPPORT.H +++ b/Core/Tools/Autorun/JSUPPORT.h @@ -16,6 +16,6 @@ ** along with this program. If not, see . */ -// JSUPPORT.H +// JSUPPORT.h // DBCS Support Header extern int nGetWord( char *,int ); diff --git a/Core/Tools/Autorun/Jsupport.cpp b/Core/Tools/Autorun/Jsupport.cpp index b160e8fbf2..acfbeceef2 100644 --- a/Core/Tools/Autorun/Jsupport.cpp +++ b/Core/Tools/Autorun/Jsupport.cpp @@ -16,11 +16,11 @@ ** along with this program. If not, see . */ -// JSUPPORT.CPP +// JSUPPORT.cpp // DBCS Support Codes #include -#include "JSUPPORT.H" +#include "JSUPPORT.h" // ‘O’u‹Ö‘¥•¶Žš // Can't set these characters on top of line diff --git a/Core/Tools/Autorun/Locale_API.cpp b/Core/Tools/Autorun/Locale_API.cpp index 046c877a7a..73aa3aafbf 100644 --- a/Core/Tools/Autorun/Locale_API.cpp +++ b/Core/Tools/Autorun/Locale_API.cpp @@ -290,20 +290,15 @@ int Locale_Init ( int language, char *file ) void Locale_Restore ( void ) { - if (TheGameText) - { - delete TheGameText; - TheGameText = NULL; - } + delete TheGameText; + TheGameText = NULL; #if( USE_MULTI_FILE_FORMAT ) LOCALE_freetable(); LOCALE_restore(); #else - if( LocaleFile ) { - free( LocaleFile ); - LocaleFile = NULL; - } + free( LocaleFile ); + LocaleFile = NULL; #endif } diff --git a/Core/Tools/Autorun/Locale_API.h b/Core/Tools/Autorun/Locale_API.h index 169acc7624..73cd605453 100644 --- a/Core/Tools/Autorun/Locale_API.h +++ b/Core/Tools/Autorun/Locale_API.h @@ -36,9 +36,6 @@ #pragma once -#ifndef LOCALE_API_H -#define LOCALE_API_H - #include /****************************************************************************/ @@ -63,5 +60,3 @@ const wchar_t* Locale_GetString ( int StringID, wchar_t *String=NULL ); */ bool Locale_Use_Multi_Language_Files ( void ); //int Locale_Get_Language_ID ( void ) { return LanguageID; }; - -#endif diff --git a/Core/Tools/Autorun/POINT.h b/Core/Tools/Autorun/POINT.h index 60b0347ffc..5c2df4f84b 100644 --- a/Core/Tools/Autorun/POINT.h +++ b/Core/Tools/Autorun/POINT.h @@ -33,10 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#pragma once -#ifndef POINT_H -#define POINT_H +#pragma once #include //#include "always.h" @@ -237,6 +235,3 @@ TPoint3D const Cross_Product(TPoint3D const & lvalue, TPoint3D const & { return(lvalue.Cross_Product(rvalue)); } - - -#endif diff --git a/Core/Tools/Autorun/RECT.h b/Core/Tools/Autorun/RECT.h index 16cd920f10..0bd028d7cb 100644 --- a/Core/Tools/Autorun/RECT.h +++ b/Core/Tools/Autorun/RECT.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * Archive : /Sun/RECT.H * + * Archive : /Sun/RECT.h * * * * Author : Joe_b * * * @@ -36,10 +36,8 @@ * Intersect -- Find the intersection between two rectangles. * * Intersect -- Simple intersect between two rectangles. * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#pragma once -#ifndef RECT_H -#define RECT_H +#pragma once #include #include "POINT.h" @@ -303,6 +301,3 @@ TRect const Intersect(TRect const & rect1, TRect const & rect2) typedef TRect Rect; const Rect RECT_NONE(0,0,0,0); - -#endif - diff --git a/Core/Tools/Autorun/TTFont.cpp b/Core/Tools/Autorun/TTFont.cpp index 344811c5f5..0c3652ec9a 100644 --- a/Core/Tools/Autorun/TTFont.cpp +++ b/Core/Tools/Autorun/TTFont.cpp @@ -52,12 +52,12 @@ #include #include #include -#include "ARGS.H" +#include "ARGS.h" #include "autorun.h" #include "RECT.h" #include "Wnd_File.h" #include "TTFont.h" -#include "JSUPPORT.H" // [OYO] +#include "JSUPPORT.h" // [OYO] #include "Locale_API.h" @@ -662,7 +662,7 @@ int TTFontClass::Set_YSpacing( int y ) * 06/20/1887 BNA : Modified to handle new fonts. * *=============================================================================================*/ -#if(NDEBUG) +#ifdef RTS_RELEASE Point2D TTFontClass::Print( HDC hdc, @@ -772,7 +772,7 @@ Point2D TTFontClass::Print( return( point ); } -#endif +#endif // RTS_RELEASE /*********************************************************************************************** * TTFontClass::Print -- Print text to the surface specified. CHAR version. * @@ -1148,7 +1148,7 @@ int TTFontClass::Find_Text_VLength( HDC hdc, char *str, int width ) //-------------------------------------------------------------- wspc += Char_Pixel_Width( localDC, ' ' ); } - } // end-of-for + } //-------------------------------------------------------------------- // @@ -1173,7 +1173,7 @@ int TTFontClass::Find_Text_VLength( HDC hdc, char *str, int width ) } letter += n; - } // end-of-while + } //----------------------------------------------------------------------- // Left over, add a line. @@ -1398,14 +1398,11 @@ FontManagerClass::FontManagerClass ( HDC hdc ) *=============================================================================================*/ FontManagerClass::~FontManagerClass ( void ) { - if ( TTButtonFontPtr != NULL ) { - delete TTButtonFontPtr; - TTButtonFontPtr = NULL; - } - if ( TTTextFontPtr != NULL ) { - delete TTTextFontPtr; - TTTextFontPtr = NULL; - } + delete TTButtonFontPtr; + TTButtonFontPtr = NULL; + + delete TTTextFontPtr; + TTTextFontPtr = NULL; } diff --git a/Core/Tools/Autorun/TTFont.h b/Core/Tools/Autorun/TTFont.h index 375194db20..56138857bf 100644 --- a/Core/Tools/Autorun/TTFont.h +++ b/Core/Tools/Autorun/TTFont.h @@ -35,10 +35,8 @@ *----------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ -#pragma once -#ifndef TTFONT_H -#define TTFONT_H +#pragma once #include #include "POINT.h" @@ -299,6 +297,3 @@ extern TTFontClass *TTTextFontPtr; extern TTFontClass *TTTextFontPtr640; extern TTFontClass *TTTextFontPtr800; extern TTFontClass *TTLicenseFontPtr; - - -#endif diff --git a/Core/Tools/Autorun/Utils.cpp b/Core/Tools/Autorun/Utils.cpp index e9b371bd1c..e40fb229d7 100644 --- a/Core/Tools/Autorun/Utils.cpp +++ b/Core/Tools/Autorun/Utils.cpp @@ -69,12 +69,12 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ #include -#include "ARGS.H" +#include "ARGS.h" #include "assert.h" #include "Locale_API.h" #include "resource.h" #include "Utils.h" -#include "WinFix.H" +#include "WinFix.h" #include "Wnd_File.h" #include #include diff --git a/Core/Tools/Autorun/Utils.h b/Core/Tools/Autorun/Utils.h index ad97b6bb4c..894a7e4360 100644 --- a/Core/Tools/Autorun/Utils.h +++ b/Core/Tools/Autorun/Utils.h @@ -22,7 +22,7 @@ * * * Project Name : Setup * * * - * File Name : UTILS.H * + * File Name : UTILS.h * * * * Programmers: Maria del Mar McCready Legg * * * @@ -33,10 +33,8 @@ *-------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#pragma once -#ifndef UTILS_H -#define UTILS_H +#pragma once #include @@ -70,6 +68,3 @@ wchar_t * Path_Remove_Back_Slash ( wchar_t *path ); void PlugInProductName ( char *szString, int nName ); void PlugInProductName ( char *szString, char *szName ); void PlugInProductName ( wchar_t *szString, const wchar_t *szName ); - - -#endif diff --git a/Core/Tools/Autorun/ViewHTML.h b/Core/Tools/Autorun/ViewHTML.h index 4a81337f53..9279465937 100644 --- a/Core/Tools/Autorun/ViewHTML.h +++ b/Core/Tools/Autorun/ViewHTML.h @@ -32,11 +32,8 @@ * ******************************************************************************/ -#ifndef VIEWHTML_H -#define VIEWHTML_H +#pragma once #include "CallbackHook.h" bool ViewHTML(const char* url, bool wait = false, const CallbackHook& callback = CallbackHook()); - -#endif // VIEWHTML_H diff --git a/Core/Tools/Autorun/WSYS_FileSystem.h b/Core/Tools/Autorun/WSYS_FileSystem.h index 6eb78c7b83..7906b70da7 100644 --- a/Core/Tools/Autorun/WSYS_FileSystem.h +++ b/Core/Tools/Autorun/WSYS_FileSystem.h @@ -37,11 +37,6 @@ #pragma once -#ifndef __WSYS_FILESYSTEM_H -#define __WSYS_FILESYSTEM_H - - - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -90,7 +85,3 @@ extern FileSystem* TheFileSystem; //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- - - - -#endif // __WSYS_FILESYSTEM_H diff --git a/Core/Tools/Autorun/WSYS_RAMFile.cpp b/Core/Tools/Autorun/WSYS_RAMFile.cpp index 79d10c2886..804fafc41b 100644 --- a/Core/Tools/Autorun/WSYS_RAMFile.cpp +++ b/Core/Tools/Autorun/WSYS_RAMFile.cpp @@ -198,11 +198,8 @@ Bool RAMFile::open( File *file ) void RAMFile::close( void ) { - if ( m_data ) - { - delete [] m_data; - m_data = NULL; - } + delete [] m_data; + m_data = NULL; File::close(); } diff --git a/Core/Tools/Autorun/WSYS_RAMFile.h b/Core/Tools/Autorun/WSYS_RAMFile.h index 9529520a14..f890ee7f43 100644 --- a/Core/Tools/Autorun/WSYS_RAMFile.h +++ b/Core/Tools/Autorun/WSYS_RAMFile.h @@ -37,11 +37,6 @@ #pragma once -#ifndef __WSYS_RAMFILE_H -#define __WSYS_RAMFILE_H - - - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -95,6 +90,3 @@ class RAMFile : public File //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- - - -#endif // __WSYS_RAMFILE_H diff --git a/Core/Tools/Autorun/WSYS_StdFile.h b/Core/Tools/Autorun/WSYS_StdFile.h index f79b3b383a..867c71e5c3 100644 --- a/Core/Tools/Autorun/WSYS_StdFile.h +++ b/Core/Tools/Autorun/WSYS_StdFile.h @@ -37,11 +37,6 @@ #pragma once -#ifndef __WSYS_STDFILE_H -#define __WSYS_STDFILE_H - - - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -92,6 +87,3 @@ class StdFile : public File //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- - - -#endif // __WSYS_STDFILE_H diff --git a/Core/Tools/Autorun/WSYS_StdFileSystem.h b/Core/Tools/Autorun/WSYS_StdFileSystem.h index 3f278a4ec6..62a0ab21e2 100644 --- a/Core/Tools/Autorun/WSYS_StdFileSystem.h +++ b/Core/Tools/Autorun/WSYS_StdFileSystem.h @@ -37,11 +37,6 @@ #pragma once -#ifndef __WSYS_STDFILESYSTEM_H -#define __WSYS_STDFILESYSTEM_H - - - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -86,7 +81,3 @@ class StdFileSystem : public FileSystem //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- - - - -#endif // __WSYS_STDFILESYSTEM_H diff --git a/Core/Tools/Autorun/WSYS_file.h b/Core/Tools/Autorun/WSYS_file.h index fa18771d28..34cd965d82 100644 --- a/Core/Tools/Autorun/WSYS_file.h +++ b/Core/Tools/Autorun/WSYS_file.h @@ -37,11 +37,6 @@ #pragma once -#ifndef __WSYS_FILE_H -#define __WSYS_FILE_H - - - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -162,6 +157,3 @@ inline void File::deleteOnClose( void ) { m_deleteOnClose = TRUE;}; // include FileSystem.h as it will be used alot with File.h //#include "wsys/FileSystem.h" - - -#endif // __WSYS_FILE_H diff --git a/Core/Tools/Autorun/WinFix.CPP b/Core/Tools/Autorun/WinFix.cpp similarity index 99% rename from Core/Tools/Autorun/WinFix.CPP rename to Core/Tools/Autorun/WinFix.cpp index a1ca92155e..85e093aaa0 100644 --- a/Core/Tools/Autorun/WinFix.CPP +++ b/Core/Tools/Autorun/WinFix.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Renegade Setup/Autorun/WinFix.CPP $* + * $Archive:: /Renegade Setup/Autorun/WinFix.cpp $* * * * $Author:: Maria_l $* * * @@ -45,7 +45,7 @@ //#include #include #include -#include "WinFix.H" +#include "WinFix.h" #include "Wnd_File.h" /*************************************************************************** diff --git a/Core/Tools/Autorun/WinFix.H b/Core/Tools/Autorun/WinFix.h similarity index 98% rename from Core/Tools/Autorun/WinFix.H rename to Core/Tools/Autorun/WinFix.h index bbd4fb91fb..7d38f1ee42 100644 --- a/Core/Tools/Autorun/WinFix.H +++ b/Core/Tools/Autorun/WinFix.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Renegade Setup/Autorun/WinFix.H $* + * $Archive:: /Renegade Setup/Autorun/WinFix.h $* * * * $Author:: Maria_l $* * * @@ -47,10 +47,6 @@ #pragma once -#ifndef WINFIX_H -#define WINFIX_H - - /*----------------------------------------------------------------------------- ** Windows Version Information class. This is a global object that is used to ** store information about the specific OS that we are running under. This can @@ -145,5 +141,3 @@ class WindowsVersionInfo }; extern WindowsVersionInfo WinVersion; - -#endif diff --git a/Core/Tools/Autorun/Wnd_File.h b/Core/Tools/Autorun/Wnd_File.h index 40ac403c70..27e343372a 100644 --- a/Core/Tools/Autorun/Wnd_File.h +++ b/Core/Tools/Autorun/Wnd_File.h @@ -22,9 +22,9 @@ // // Project name: Blade Runner CD-ROM Windows 95 // -// File name: WND_FILE.H +// File name: WND_FILE.h // -// Source code: WND_FILE.CPP +// Source code: WND_FILE.cpp // // Compatibility: Microsoft Visual C++ 4.0 // Borland C++ 5.0 @@ -38,10 +38,8 @@ // James McNeill // //**************************************************************************** -#pragma once -#ifndef WND_FILE_H -#define WND_FILE_H +#pragma once //------------------------------------------------------------------------------ // include files... @@ -148,7 +146,7 @@ class StandardFileClass #if( SUPPORT_STREAMS ) //-------------------------------------------------------------------- - // The _stat structure, defined in SYS\STAT.H, includes these fields. + // The _stat structure, defined in SYS\STAT.h, includes these fields. // st_atime Time of last access of file ( time_t ). // st_ctime Time of creation of file ( time_t ). // st_dev Drive number of the disk containing the file (same as st_rdev). @@ -212,5 +210,3 @@ class StandardFileClass bool CD_File_Exists( char const *file_name ); // bool Find_File( char const *file_name ); #endif - -#endif // WND_FILE_H diff --git a/Core/Tools/Autorun/Wnd_file.cpp b/Core/Tools/Autorun/Wnd_file.cpp index d47003c65a..0db0ade184 100644 --- a/Core/Tools/Autorun/Wnd_file.cpp +++ b/Core/Tools/Autorun/Wnd_file.cpp @@ -22,9 +22,9 @@ // // Project name: Blade Runner CD-ROM Windows 95 // -// File name: WND_FILE.CPP +// File name: WND_FILE.cpp // -// Functions: WND_FILE.H +// Functions: WND_FILE.h // // Compatibility: Microsoft Visual C++ 4.0 // Borland C++ 5.0 @@ -45,7 +45,7 @@ #include #include #include "Wnd_File.h" -#include "WinFix.H" +#include "WinFix.h" //#include "autorun.h" diff --git a/Core/Tools/Autorun/autorun.cpp b/Core/Tools/Autorun/autorun.cpp index b63fe32881..fefdd6ed6e 100644 --- a/Core/Tools/Autorun/autorun.cpp +++ b/Core/Tools/Autorun/autorun.cpp @@ -22,7 +22,7 @@ * * * Project Name : Autorun * * * - * File Name : AUTORUN.CPP * + * File Name : AUTORUN.cpp * * * * Programmers: Maria del Mar McCready Legg * * * @@ -90,14 +90,14 @@ #include #include #include -#include "ARGS.H" +#include "ARGS.h" #include "autorun.h" #include "DrawButton.h" #include "resource.h" #include "Wnd_File.h" //#include "visualc.h" -#include "WinFix.H" -#include "CDCNTRL.H" +#include "WinFix.h" +#include "CDCNTRL.h" #include "IGR.h" #include "ViewHTML.h" @@ -252,7 +252,7 @@ enum IDS_MAIN_WINDOW, - IDS_COUNT // keep this last + IDS_COUNT }; */ @@ -1138,10 +1138,9 @@ LRESULT MainWindow::Window_Proc( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM decision = DialogBox( Main::hInstance, _TEXT( "BitmapDialog" ), hWnd, Dialog_Box_Proc ); - if ( Args ) { - delete( Args ); - Args = NULL; - } + delete( Args ); + Args = NULL; + Stop_Sound_Playing(); MoveWindow( hWnd, 0, 0, 0, 0, TRUE ); @@ -1760,7 +1759,7 @@ unsigned int MainWindow::Run_OpenFile(int cd_drive, const char *filename, bool w TranslateMessage( &msg ); DispatchMessage( &msg ); - } // end while + } DWORD exitCode; GetExitCodeProcess(hProcess, &exitCode); @@ -2216,11 +2215,7 @@ void MainWindow::Create_Buttons( HWND hWnd, RECT *dlg_rect ) for ( i = 0; i < NUM_BUTTONS; i++ ) { - if ( ButtonList[i] ) - { - delete( ButtonList[i] ); - } - + delete( ButtonList[i] ); ButtonList[i] = NULL; ButtonSizes[i].left = x_pos; // X position. ButtonSizes[i].top = y_pos; // Y position. @@ -2281,7 +2276,7 @@ void MainWindow::Create_Buttons( HWND hWnd, RECT *dlg_rect ) #ifdef LEAN_AND_MEAN Locale_GetString( "Autorun:Install" ), #else - AsciiString("Autorun:Install"), + "Autorun:Install", #endif TTButtonFontPtr ); @@ -2300,7 +2295,7 @@ void MainWindow::Create_Buttons( HWND hWnd, RECT *dlg_rect ) #ifdef LEAN_AND_MEAN Locale_GetString( "Autorun:Play" ), #else - AsciiString("Autorun:Play"), + "Autorun:Play", #endif TTButtonFontPtr ); /* @@ -2319,7 +2314,7 @@ void MainWindow::Create_Buttons( HWND hWnd, RECT *dlg_rect ) #ifdef LEAN_AND_MEAN Locale_GetString( "Autorun:Worldbuilder" ), #else - AsciiString("Autorun:Worldbuilder"), + "Autorun:Worldbuilder", #endif TTButtonFontPtr ); */ @@ -2338,7 +2333,7 @@ void MainWindow::Create_Buttons( HWND hWnd, RECT *dlg_rect ) #ifdef LEAN_AND_MEAN Locale_GetString( "Autorun:CheckForUpdates" ), #else - AsciiString("Autorun:CheckForUpdates"), + "Autorun:CheckForUpdates", #endif TTButtonFontPtr ); } @@ -2356,7 +2351,7 @@ void MainWindow::Create_Buttons( HWND hWnd, RECT *dlg_rect ) #ifdef LEAN_AND_MEAN Locale_GetString( "Autorun:ExploreCD" ), #else - AsciiString("Autorun:ExploreCD"), + "Autorun:ExploreCD", #endif TTButtonFontPtr ); // strcpy( next_button_name, ButtonImages[button_index] ); @@ -2377,7 +2372,7 @@ void MainWindow::Create_Buttons( HWND hWnd, RECT *dlg_rect ) #ifdef LEAN_AND_MEAN Locale_GetString( "Autorun:Website" ), #else - AsciiString("Autorun:Website"), + "Autorun:Website", #endif TTButtonFontPtr ); @@ -2400,7 +2395,7 @@ void MainWindow::Create_Buttons( HWND hWnd, RECT *dlg_rect ) #ifdef LEAN_AND_MEAN Locale_GetString( "Autorun:Uninstall" ), #else - AsciiString("Autorun:Uninstall"), + "Autorun:Uninstall", #endif TTButtonFontPtr ); @@ -2422,7 +2417,7 @@ void MainWindow::Create_Buttons( HWND hWnd, RECT *dlg_rect ) #ifdef LEAN_AND_MEAN Locale_GetString( "Autorun:Previews" ), #else - AsciiString("Autorun:Previews"), + "Autorun:Previews", #endif TTButtonFontPtr ); @@ -2439,7 +2434,7 @@ void MainWindow::Create_Buttons( HWND hWnd, RECT *dlg_rect ) #ifdef LEAN_AND_MEAN Locale_GetString( "Autorun:Help" ), #else - AsciiString("Autorun:Help"), + "Autorun:Help", #endif TTButtonFontPtr ); @@ -2456,7 +2451,7 @@ void MainWindow::Create_Buttons( HWND hWnd, RECT *dlg_rect ) #ifdef LEAN_AND_MEAN Locale_GetString( "Autorun:Cancel" ), #else - AsciiString("Autorun:Cancel"), + "Autorun:Cancel", #endif TTButtonFontPtr ); @@ -3410,7 +3405,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param hButtonBitmap = 0; } - } // END OF DRAW BITMAPS + } #if(0) TTFontClass *fontptr = ButtonList[i]->Return_Font_Ptr(); @@ -3495,9 +3490,9 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param - } // end of if button + } - } // For each button... + } //--------------------------------------------------------------- // Used in debugging -- draw rect around where buttons are. @@ -3553,7 +3548,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param DeleteDC( buttonDC ); DeleteDC( licenseDC ); - } // end of bitmaps + } //=================================================================== // Draw a solid colored background. @@ -3861,7 +3856,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param Reformat_Volume_Name( PRODUCT_VOLUME_CD2, volume_to_match ); // result = Prompt_For_CD( window_handle, volume_to_match, IDS_INSERT_CDROM_WITH_VOLUME2, IDS_EXIT_MESSAGE2, &cd_drive ); - result = Prompt_For_CD( window_handle, volume_to_match, AsciiString("Autorun:InsertCDROMWithVolume2"), AsciiString("Autorun:ExitMessage2"), &cd_drive ); + result = Prompt_For_CD( window_handle, volume_to_match, "Autorun:InsertCDROMWithVolume2", "Autorun:ExitMessage2", &cd_drive ); } if ( result ) { @@ -3888,7 +3883,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param } else { - Error_Message( Main::hInstance, AsciiString("Autorun:Generals"), AsciiString("Autorun:CantFindExplorer"), GAME_WEBSITE ); + Error_Message( Main::hInstance, "Autorun:Generals", "Autorun:CantFindExplorer", GAME_WEBSITE ); } break; #endif @@ -3976,10 +3971,8 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param if( end_dialog ) { for ( i = 0; i < NUM_BUTTONS; i++ ) { - if ( ButtonList[i] ) { - delete( ButtonList[i] ); - ButtonList[i] = NULL; - } + delete( ButtonList[i] ); + ButtonList[i] = NULL; } if ( hpal ) { DeleteObject( hpal ); @@ -4018,10 +4011,8 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param #if(BACKGROUND_BITMAP) for ( i = 0; i < NUM_BUTTONS; i++ ) { - if ( ButtonList[i] ) { - delete( ButtonList[i] ); - ButtonList[i] = NULL; - } + delete( ButtonList[i] ); + ButtonList[i] = NULL; } if ( hpal ) { DeleteObject( hpal ); @@ -4049,10 +4040,9 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param //----------------------------------------------------------------------- // Delete the arguments. //----------------------------------------------------------------------- - if ( Args ) { - delete( Args ); - Args = NULL; - } + delete( Args ); + Args = NULL; + KillTimer( window_handle, timer_id ); EndDialog( window_handle, w_param ); } @@ -4360,7 +4350,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param ButtonList[i]->Set_State( DrawButton::FOCUS_STATE ); // Msg( __LINE__, TEXT(__FILE__), TEXT("WM_MOUSEMOVE -- %s[FOCUS_STATE]."), ButtonList[i]->Return_Normal_Bitmap()); } - } // end of if + } //----------------------------------------------------------- // Get the area of the button, and post it for updating. @@ -4380,10 +4370,10 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param done = 1; } - } // end of if + } i++; - } // end of for + } #if( USE_MOUSE_MOVES ) diff --git a/Core/Tools/Autorun/autorun.h b/Core/Tools/Autorun/autorun.h index 5a068c055c..65a10e1124 100644 --- a/Core/Tools/Autorun/autorun.h +++ b/Core/Tools/Autorun/autorun.h @@ -34,9 +34,7 @@ * *************************************************************************************************/ - -#ifndef AUTORUN_H -#define AUTORUN_H +#pragma once #include #include @@ -250,7 +248,3 @@ class MainWindow : public Window unsigned int Run_OpenFile (int cd_drive, const char *filename, bool wait = false); LRESULT Window_Proc ( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam ); }; - - -#endif - diff --git a/Core/Tools/Autorun/gimex.h b/Core/Tools/Autorun/gimex.h index 291a495ae8..b1dd321c79 100644 --- a/Core/Tools/Autorun/gimex.h +++ b/Core/Tools/Autorun/gimex.h @@ -22,8 +22,7 @@ gimex.h - Graphics IMport EXport (GIMEX) v2.26 @ */ -#ifndef __GIMEX_H -#define __GIMEX_H 1 +#pragma once #ifdef __cplusplus extern "C" { @@ -299,9 +298,4 @@ unsigned long bswap(unsigned long val); #ifdef __cplusplus } #endif - -#endif /* __GIMEX_H */ /* END ABSTRACT */ - - - diff --git a/Core/Tools/Autorun/leanAndMeanAutorun.h b/Core/Tools/Autorun/leanAndMeanAutorun.h index 37c5b0d93e..5713622d7f 100644 --- a/Core/Tools/Autorun/leanAndMeanAutorun.h +++ b/Core/Tools/Autorun/leanAndMeanAutorun.h @@ -20,12 +20,7 @@ // Author: Mark Lorenzen, January 2003! // Description: Classes extracted from GameEngine for use in autorun without having to link the game to autorun /////////////////////////////////////////////////////////////////////////////////////////////////// -#pragma once - -#ifndef __LEANANDMEANAUTORUN_H_ -#define __LEANANDMEANAUTORUN_H_ +#pragma once #define LEAN_AND_MEAN - -#endif //__LEANANDMEANAUTORUN_H_ diff --git a/Core/Tools/Autorun/locale.h b/Core/Tools/Autorun/locale.h index d9c0f3aa96..f4a5fb07ed 100644 --- a/Core/Tools/Autorun/locale.h +++ b/Core/Tools/Autorun/locale.h @@ -22,8 +22,7 @@ locale.h - REAL fonts @ */ -#ifndef __LOCALE_H -#define __LOCALE_H 1 +#pragma once //#ifdef __cplusplus //extern "C" { @@ -66,7 +65,4 @@ const char * LOCALE_getstring( int stringid ); /* use values in the .h fil //#ifdef __cplusplus //} //#endif - -#endif /* __LOCALE_H */ /* END ABSTRACT */ - diff --git a/Core/Tools/Babylon/Babylon.cpp b/Core/Tools/Babylon/Babylon.cpp index fede71fa44..7354eefcb9 100644 --- a/Core/Tools/Babylon/Babylon.cpp +++ b/Core/Tools/Babylon/Babylon.cpp @@ -220,7 +220,7 @@ BOOL CALLBACK EnumAllWindowsProcExact(HWND hWnd, LPARAM lParam) GetWindowText(hWnd, szText, sizeof(szText)); - if ( !strncmp (szText, szSearchTitle, strlen ( szSearchTitle))) + if ( strncmp (szText, szSearchTitle, strlen ( szSearchTitle)) == 0) { * (BOOL *) lParam = TRUE; FoundWindow = hWnd; diff --git a/Core/Tools/Babylon/Babylon.h b/Core/Tools/Babylon/Babylon.h index 8655bde4e1..22b3020573 100644 --- a/Core/Tools/Babylon/Babylon.h +++ b/Core/Tools/Babylon/Babylon.h @@ -19,12 +19,7 @@ // Babylon.h : main header file for the BABYLON application // -#if !defined(AFX_BABYLON_H__2BF3124B_3BA1_11D3_B9DA_006097B90D93__INCLUDED_) -#define AFX_BABYLON_H__2BF3124B_3BA1_11D3_B9DA_006097B90D93__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #ifndef __AFXWIN_H__ #error include 'stdafx.h' before including this file for PCH @@ -70,5 +65,3 @@ extern LangID CurrentLanguage; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_BABYLON_H__2BF3124B_3BA1_11D3_B9DA_006097B90D93__INCLUDED_) diff --git a/Core/Tools/Babylon/BabylonDlg.cpp b/Core/Tools/Babylon/BabylonDlg.cpp index 8ecb19c6ad..27706df01f 100644 --- a/Core/Tools/Babylon/BabylonDlg.cpp +++ b/Core/Tools/Babylon/BabylonDlg.cpp @@ -133,7 +133,7 @@ static void removeLeadingAndTrailing ( char *buffer ) while ( *ptr++ = *first++ ); - ptr -= 2;; + ptr -= 2; while ( (ptr > buffer) && (ch = *ptr) && iswspace ( ch ) ) { @@ -330,7 +330,7 @@ BOOL CBabylonDlg::OnInitDialog() #endif - Ready();; + Ready(); PostMessage ( WM_COMMAND, MAKEWPARAM ( IDC_RELOAD, BN_CLICKED )); @@ -980,27 +980,27 @@ static int parseComment ( FILE *file, char *buffer, INFO *info ) return new_lines; } - if ( !stricmp ( token, "COMMENT" ) ) + if ( stricmp ( token, "COMMENT" ) == 0 ) { new_lines += getString ( file, buffer, info->comment ); } - else if ( !stricmp ( token, "CONTEXT" ) ) + else if ( stricmp ( token, "CONTEXT" ) == 0 ) { new_lines += getString ( file, buffer, info->context ); } - else if ( !stricmp ( token, "SPEAKER" ) ) + else if ( stricmp ( token, "SPEAKER" ) == 0 ) { new_lines += getString ( file, buffer, info->speaker ); } - else if ( !stricmp ( token, "LISTENER" ) ) + else if ( stricmp ( token, "LISTENER" ) == 0 ) { new_lines += getString ( file, buffer, info->listener ); } - else if ( !stricmp ( token, "MAXLEN" ) ) + else if ( stricmp ( token, "MAXLEN" ) == 0 ) { info->maxlen = atoi ( buffer ); } - else if ( !stricmp ( token, "WAVE" ) ) + else if ( stricmp ( token, "WAVE" ) == 0 ) { new_lines += getString ( file, buffer, info->wave ); } @@ -1024,7 +1024,7 @@ static int getLabelCount( char *filename ) if( fscanf( fp, "%s", buffer ) == EOF ) break; - if ( !stricmp( buffer, "END" ) ) + if ( stricmp( buffer, "END" ) == 0 ) { count++; } @@ -1083,7 +1083,7 @@ int CBabylonDlg::LoadStrFile ( TransDB *db, const char *filename, void (*cb) ( v line_number++; removeLeadingAndTrailing ( buffer ); - if ( !stricmp ( buffer, "END" ) ) + if ( stricmp ( buffer, "END" ) == 0 ) { break; } @@ -1138,10 +1138,7 @@ int CBabylonDlg::LoadStrFile ( TransDB *db, const char *filename, void (*cb) ( v db->ClearChanges (); - if ( label ) - { - delete label; - } + delete label; if ( file ) { @@ -1610,7 +1607,7 @@ int CBabylonDlg::UpdateLabel( BabylonLabel *source, BabylonLabel *destination, U if ( (stext = (BabylonText *) dtext->Matched ()) ) { // stext is the newer version; - if ( wcscmp ( dtext->Get (), stext->Get ())) + if ( wcscmp ( dtext->Get (), stext->Get ()) != 0) { if ( update ) { @@ -1620,7 +1617,7 @@ int CBabylonDlg::UpdateLabel( BabylonLabel *source, BabylonLabel *destination, U label_modified = TRUE; info.changes ++; } - if ( wcsicmp ( dtext->Wave (), stext->Wave ())) + if ( wcsicmp ( dtext->Wave (), stext->Wave ()) != 0) { if ( update ) { @@ -1982,7 +1979,7 @@ int CBabylonDlg::UpdateDB(TransDB *source, TransDB *destination, int update ) source->ClearChanges (); } } - } // update + } Ready (); diff --git a/Core/Tools/Babylon/BabylonDlg.h b/Core/Tools/Babylon/BabylonDlg.h index 02ccf55438..677e782611 100644 --- a/Core/Tools/Babylon/BabylonDlg.h +++ b/Core/Tools/Babylon/BabylonDlg.h @@ -19,12 +19,7 @@ // BabylonDlg.h : header file // -#if !defined(AFX_BABYLONDLG_H__2BF3124D_3BA1_11D3_B9DA_006097B90D93__INCLUDED_) -#define AFX_BABYLONDLG_H__2BF3124D_3BA1_11D3_B9DA_006097B90D93__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #include "resource.h" #include "TransDB.h" @@ -152,5 +147,3 @@ extern CBabylonDlg *MainDLG; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_BABYLONDLG_H__2BF3124D_3BA1_11D3_B9DA_006097B90D93__INCLUDED_) diff --git a/Core/Tools/Babylon/DlgProxy.h b/Core/Tools/Babylon/DlgProxy.h index 6d73d2fae6..2473539fb3 100644 --- a/Core/Tools/Babylon/DlgProxy.h +++ b/Core/Tools/Babylon/DlgProxy.h @@ -19,12 +19,7 @@ // DlgProxy.h : header file // -#if !defined(AFX_DLGPROXY_H__2BF3124F_3BA1_11D3_B9DA_006097B90D93__INCLUDED_) -#define AFX_DLGPROXY_H__2BF3124F_3BA1_11D3_B9DA_006097B90D93__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 class CBabylonDlg; @@ -75,5 +70,3 @@ class CBabylonDlgAutoProxy : public CCmdTarget //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DLGPROXY_H__2BF3124F_3BA1_11D3_B9DA_006097B90D93__INCLUDED_) diff --git a/Core/Tools/Babylon/ExportDlg.h b/Core/Tools/Babylon/ExportDlg.h index c98f9cd652..af799753f6 100644 --- a/Core/Tools/Babylon/ExportDlg.h +++ b/Core/Tools/Babylon/ExportDlg.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_EXPORTDLG_H__DDA81307_4F1A_11D3_B9DA_006097B90D93__INCLUDED_) -#define AFX_EXPORTDLG_H__DDA81307_4F1A_11D3_B9DA_006097B90D93__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // ExportDlg.h : header file // @@ -77,5 +73,3 @@ class CExportDlg : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EXPORTDLG_H__DDA81307_4F1A_11D3_B9DA_006097B90D93__INCLUDED_) diff --git a/Core/Tools/Babylon/GenerateDlg.h b/Core/Tools/Babylon/GenerateDlg.h index 881ddd3f10..1be84d2b50 100644 --- a/Core/Tools/Babylon/GenerateDlg.h +++ b/Core/Tools/Babylon/GenerateDlg.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_GENERATEDLG_H__959D0D41_50A5_11D3_B9DA_006097B90D93__INCLUDED_) -#define AFX_GENERATEDLG_H__959D0D41_50A5_11D3_B9DA_006097B90D93__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // GenerateDlg.h : header file // @@ -88,5 +84,3 @@ class CGenerateDlg : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_GENERATEDLG_H__959D0D41_50A5_11D3_B9DA_006097B90D93__INCLUDED_) diff --git a/Core/Tools/Babylon/MatchDlg.h b/Core/Tools/Babylon/MatchDlg.h index 619051f521..56fa8dacc0 100644 --- a/Core/Tools/Babylon/MatchDlg.h +++ b/Core/Tools/Babylon/MatchDlg.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_MATCHDLG_H__FA868061_4EA7_11D3_B9DA_006097B90D93__INCLUDED_) -#define AFX_MATCHDLG_H__FA868061_4EA7_11D3_B9DA_006097B90D93__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // MatchDlg.h : header file // @@ -72,5 +68,3 @@ extern BabylonLabel *MatchLabel; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_MATCHDLG_H__FA868061_4EA7_11D3_B9DA_006097B90D93__INCLUDED_) diff --git a/Core/Tools/Babylon/ProceedDlg.h b/Core/Tools/Babylon/ProceedDlg.h index e1c9f03738..ee42c7809b 100644 --- a/Core/Tools/Babylon/ProceedDlg.h +++ b/Core/Tools/Babylon/ProceedDlg.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_PROCEEDDLG_H__35C33E24_5AD8_11D3_B9DA_006097B90D93__INCLUDED_) -#define AFX_PROCEEDDLG_H__35C33E24_5AD8_11D3_B9DA_006097B90D93__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // ProceedDlg.h : header file // #define IDALWAYS 101 @@ -66,5 +62,3 @@ class ProceedDlg : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PROCEEDDLG_H__35C33E24_5AD8_11D3_B9DA_006097B90D93__INCLUDED_) diff --git a/Core/Tools/Babylon/Report.h b/Core/Tools/Babylon/Report.h index ef8145a7ad..93a66d12cd 100644 --- a/Core/Tools/Babylon/Report.h +++ b/Core/Tools/Babylon/Report.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_REPORT_H__47F98BA1_70E3_11D3_B9DA_006097B90D93__INCLUDED_) -#define AFX_REPORT_H__47F98BA1_70E3_11D3_B9DA_006097B90D93__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // Report.h : header file // @@ -85,5 +81,3 @@ class CReport : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_REPORT_H__47F98BA1_70E3_11D3_B9DA_006097B90D93__INCLUDED_) diff --git a/Core/Tools/Babylon/RetranslateDlg.h b/Core/Tools/Babylon/RetranslateDlg.h index 86bbdcb4cc..4c7354ff65 100644 --- a/Core/Tools/Babylon/RetranslateDlg.h +++ b/Core/Tools/Babylon/RetranslateDlg.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_RETRANSLATEDLG_H__19E25401_0ECB_11D4_B9DB_006097B90D93__INCLUDED_) -#define AFX_RETRANSLATEDLG_H__19E25401_0ECB_11D4_B9DB_006097B90D93__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // RetranslateDlg.h : header file // @@ -71,5 +67,3 @@ class RetranslateDlg : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_RETRANSLATEDLG_H__19E25401_0ECB_11D4_B9DB_006097B90D93__INCLUDED_) diff --git a/Core/Tools/Babylon/StdAfx.h b/Core/Tools/Babylon/StdAfx.h index 8039355681..14880ad8a4 100644 --- a/Core/Tools/Babylon/StdAfx.h +++ b/Core/Tools/Babylon/StdAfx.h @@ -21,12 +21,7 @@ // are changed infrequently // -#if !defined(AFX_STDAFX_H__2BF31252_3BA1_11D3_B9DA_006097B90D93__INCLUDED_) -#define AFX_STDAFX_H__2BF31252_3BA1_11D3_B9DA_006097B90D93__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers @@ -60,4 +55,3 @@ extern char AppTitle[]; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. -#endif // !defined(AFX_STDAFX_H__2BF31252_3BA1_11D3_B9DA_006097B90D93__INCLUDED_) diff --git a/Core/Tools/Babylon/TransDB.cpp b/Core/Tools/Babylon/TransDB.cpp index ac462c927c..5ef14300b9 100644 --- a/Core/Tools/Babylon/TransDB.cpp +++ b/Core/Tools/Babylon/TransDB.cpp @@ -96,7 +96,7 @@ LANGINFO *GetLangInfo ( char *language ) while ( item->langid != LANGID_UNKNOWN ) { - if ( !stricmp ( language, item->name ) ) + if ( stricmp ( language, item->name ) == 0 ) { return item; } @@ -330,7 +330,7 @@ BabylonText* TransDB::FindSubText ( OLECHAR *pattern, int item ) while ( text ) { - if ( !wcsnicmp ( text->Get (), pattern, 15 )) + if ( wcsnicmp ( text->Get (), pattern, 15 ) == 0) { if ( !item ) { @@ -692,7 +692,7 @@ BabylonText* BabylonLabel::FindText ( OLECHAR *find_text ) while ( txt ) { - if ( !wcscmp ( txt->Get(), find_text )) + if ( wcscmp ( txt->Get(), find_text ) == 0) { return txt; } @@ -836,25 +836,25 @@ void BabylonLabel::AddToTree ( CTreeCtrl *tc, HTREEITEM parent, int changes txt = NextText ( sh ); } - if ( strcmp ( CommentSB(), "" ) ) + if ( strcmp ( CommentSB(), "" ) != 0 ) { sprintf ( buffer, "COMMENT : %s", CommentSB() ); tc->InsertItem ( buffer, litem ); } - if ( strcmp ( ContextSB(), "" ) ) + if ( strcmp ( ContextSB(), "" ) != 0 ) { sprintf ( buffer, "CONTEXT : %s", ContextSB() ); tc->InsertItem ( buffer, litem ); } - if ( strcmp ( SpeakerSB(), "" ) ) + if ( strcmp ( SpeakerSB(), "" ) != 0 ) { sprintf ( buffer, "SPEAKER : %s", SpeakerSB() ); tc->InsertItem ( buffer, litem ); } - if ( strcmp ( ListenerSB(), "" ) ) + if ( strcmp ( ListenerSB(), "" ) != 0 ) { sprintf ( buffer, "LISTENER: %s", ListenerSB() ); tc->InsertItem ( buffer, litem ); @@ -1341,7 +1341,7 @@ void BabylonText::AddToTree ( CTreeCtrl *tc, HTREEITEM parent, int changes tc->InsertItem ( buffer, item ); } - if ( strcmp ( WaveSB(), "" ) ) + if ( strcmp ( WaveSB(), "" ) != 0 ) { sprintf ( buffer, "WAVE : %s", WaveSB() ); tc->InsertItem ( buffer, item ); @@ -1411,7 +1411,7 @@ void Translation::AddToTree ( CTreeCtrl *tc, HTREEITEM parent, int changes item = tc->InsertItem ( buffer, parent ); - if ( strcmp ( CommentSB(), "" ) ) + if ( strcmp ( CommentSB(), "" ) != 0 ) { sprintf ( buffer, "COMMENT: %s", CommentSB() ); tc->InsertItem ( buffer, item ); diff --git a/Core/Tools/Babylon/TransDB.h b/Core/Tools/Babylon/TransDB.h index f10bcf61be..fd508f9e18 100644 --- a/Core/Tools/Babylon/TransDB.h +++ b/Core/Tools/Babylon/TransDB.h @@ -21,8 +21,7 @@ // // -#ifndef __TRANSDB_H -#define __TRANSDB_H +#pragma once #include "olestring.h" #include "list.h" @@ -424,7 +423,3 @@ class DupNode : public ListNode extern TransDB* FirstTransDB ( void ); - - - -#endif // __TRANSDB_H diff --git a/Core/Tools/Babylon/VIEWDBSII.h b/Core/Tools/Babylon/VIEWDBSII.h index a2499d1e93..a9ea386653 100644 --- a/Core/Tools/Babylon/VIEWDBSII.h +++ b/Core/Tools/Babylon/VIEWDBSII.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_VIEWDBSII_H__AC697EE4_6D37_4F29_ACC7_8B260A33DA2E__INCLUDED_) -#define AFX_VIEWDBSII_H__AC697EE4_6D37_4F29_ACC7_8B260A33DA2E__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // VIEWDBSII.h : header file // @@ -66,5 +62,3 @@ class VIEWDBSII : public CDialog extern int ViewChanges; //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_VIEWDBSII_H__AC697EE4_6D37_4F29_ACC7_8B260A33DA2E__INCLUDED_) diff --git a/Core/Tools/Babylon/VerifyDlg.h b/Core/Tools/Babylon/VerifyDlg.h index 1b8151a9af..04964b6f3f 100644 --- a/Core/Tools/Babylon/VerifyDlg.h +++ b/Core/Tools/Babylon/VerifyDlg.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_VERIFYDLG_H__88E9C121_599B_11D3_B9DA_006097B90D93__INCLUDED_) -#define AFX_VERIFYDLG_H__88E9C121_599B_11D3_B9DA_006097B90D93__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // VerifyDlg.h : header file // @@ -81,5 +77,3 @@ class VerifyDlg : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_VERIFYDLG_H__88E9C121_599B_11D3_B9DA_006097B90D93__INCLUDED_) diff --git a/Core/Tools/Babylon/VerifyTextDlg.h b/Core/Tools/Babylon/VerifyTextDlg.h index 15bbdca8e6..fca1dda0fd 100644 --- a/Core/Tools/Babylon/VerifyTextDlg.h +++ b/Core/Tools/Babylon/VerifyTextDlg.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_VERIFYTEXTDLG_H__39DB1C81_6B90_11D3_B9DA_006097B90D93__INCLUDED_) -#define AFX_VERIFYTEXTDLG_H__39DB1C81_6B90_11D3_B9DA_006097B90D93__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // VerifyTextDlg.h : header file // @@ -64,5 +60,3 @@ class CVerifyTextDlg : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_VERIFYTEXTDLG_H__39DB1C81_6B90_11D3_B9DA_006097B90D93__INCLUDED_) diff --git a/Core/Tools/Babylon/XLStuff.cpp b/Core/Tools/Babylon/XLStuff.cpp index de276277cd..59be38979c 100644 --- a/Core/Tools/Babylon/XLStuff.cpp +++ b/Core/Tools/Babylon/XLStuff.cpp @@ -223,15 +223,8 @@ int PutSeparator ( int row ) range->ReleaseDispatch ( ); - if ( borders ) - { - delete borders ; - } - - if ( border ) - { - delete border ; - } + delete borders; + delete border; VariantClear ( &cell1 ); VariantClear ( &cell2 ); @@ -364,15 +357,8 @@ int PutSection ( int row, OLECHAR *title ) range->ReleaseDispatch ( ); - if ( borders ) - { - delete borders ; - } - - if ( border ) - { - delete border ; - } + delete borders; + delete border; VariantClear ( &cell1 ); VariantClear ( &cell2 ); @@ -475,17 +461,11 @@ void CloseExcel ( void ) { CloseWorkBook (); - if ( range ) - { - delete range; - range = NULL; - } + delete range; + range = NULL; - if ( ws ) - { - delete ws; - ws = NULL; - } + delete ws; + ws = NULL; if ( wbs ) { diff --git a/Core/Tools/Babylon/XLStuff.h b/Core/Tools/Babylon/XLStuff.h index e1849185da..90361bab44 100644 --- a/Core/Tools/Babylon/XLStuff.h +++ b/Core/Tools/Babylon/XLStuff.h @@ -21,8 +21,7 @@ // // -#ifndef XLSTUFF_H -#define XLSTUFF_H +#pragma once #include "BabylonDlg.h" typedef enum { @@ -256,7 +255,3 @@ int PutSection ( int row, const OLECHAR *title ); void SelectActiveSheet ( void ); int GetInt ( int row, int cell ); int GetString ( int row, int cell, OLECHAR *buffer ); - - - -#endif // XLSTUFF_H diff --git a/Core/Tools/Babylon/bin.h b/Core/Tools/Babylon/bin.h index a4915ea223..f928b15033 100644 --- a/Core/Tools/Babylon/bin.h +++ b/Core/Tools/Babylon/bin.h @@ -20,9 +20,7 @@ // Bin.h // - -#ifndef __BIN_H -#define __BIN_H +#pragma once #include "list.h" #include "olestring.h" @@ -103,6 +101,3 @@ class BinID }; - - -#endif // __BIN_H diff --git a/Core/Tools/Babylon/expimp.h b/Core/Tools/Babylon/expimp.h index adf558bd01..b15d0252dc 100644 --- a/Core/Tools/Babylon/expimp.h +++ b/Core/Tools/Babylon/expimp.h @@ -20,8 +20,7 @@ // expimp.h // -#ifndef __EXPIMP_H -#define __EXPIMP_H +#pragma once #include "TransDB.h" #include "BabylonDlg.h" @@ -107,4 +106,3 @@ int UpdateSentTranslations ( TransDB *db, const char *filename, CBabylonDlg *dlg int GenerateGameFiles ( TransDB *db, const char *filename, GNOPTIONS *option, LangID *languages, CBabylonDlg *dlg = NULL ); int GenerateReport ( TransDB *db, const char *filename, RPOPTIONS *options, LangID *languages, CBabylonDlg *dlg = NULL ); void ProcessWaves ( TransDB *db, const char *filename, CBabylonDlg *dlg ); -#endif diff --git a/Core/Tools/Babylon/fileops.h b/Core/Tools/Babylon/fileops.h index 174835192e..11a6bc0947 100644 --- a/Core/Tools/Babylon/fileops.h +++ b/Core/Tools/Babylon/fileops.h @@ -20,8 +20,7 @@ // File IO support // -#ifndef __FILEOPS_H -#define __FILEOPS_H +#pragma once static const int FA_NOFILE = 0; static const int FA_READONLY = 0x00000001; @@ -33,6 +32,3 @@ int FileExists ( const char *filename ); int FileAttribs ( const char *filename ); void MakeBackupFile ( const char *filename ); void RestoreBackupFile ( const char *filename ); - - -#endif // __FILEIO_H diff --git a/Core/Tools/Babylon/iff.h b/Core/Tools/Babylon/iff.h index c79d500fd1..7d1860032d 100644 --- a/Core/Tools/Babylon/iff.h +++ b/Core/Tools/Babylon/iff.h @@ -16,9 +16,7 @@ ** along with this program. If not, see . */ - -#ifndef __IFF_H -#define __IFF_H +#pragma once #define MakeID(a,b,c,d) ( (int) ( ( (int) (a) ) << 24 | ( (int) (b) ) << 16 | \ ( (int) (c) ) << 8 | ( (int) (d) ) ) ) @@ -122,6 +120,3 @@ int IFF_CloseChunk ( IFF_FILE * ); #define LtEn16(L) (L) #endif - - -#endif /* __IFF_H */ diff --git a/Core/Tools/Babylon/list.h b/Core/Tools/Babylon/list.h index 4de146bda4..944ae2b74b 100644 --- a/Core/Tools/Babylon/list.h +++ b/Core/Tools/Babylon/list.h @@ -16,10 +16,7 @@ ** along with this program. If not, see . */ - -#ifndef __LIST_H -#define __LIST_H - +#pragma once const int LOWEST_PRIORITY = (int ) 0x80000000; const int HIGHEST_PRIORITY = (int) 0x7fffffff; @@ -90,6 +87,3 @@ class ListSearch ListNode* LastNode ( List *new_head) { node = head = new_head; return Prev (); }; }; - - -#endif // __LIST_H diff --git a/Core/Tools/Babylon/loadsave.cpp b/Core/Tools/Babylon/loadsave.cpp index 0f9c89a8af..e3a7c30ebb 100644 --- a/Core/Tools/Babylon/loadsave.cpp +++ b/Core/Tools/Babylon/loadsave.cpp @@ -583,20 +583,9 @@ int LoadMainDB(TransDB *db, const char *filename, void (*cb) (void) ) error: - if ( label ) - { - delete label; - } - - if ( text ) - { - delete text; - } - - if ( trans ) - { - delete trans; - } + delete label; + delete text; + delete trans; if ( iff ) { diff --git a/Core/Tools/Babylon/loadsave.h b/Core/Tools/Babylon/loadsave.h index 977507a3f3..cde180af92 100644 --- a/Core/Tools/Babylon/loadsave.h +++ b/Core/Tools/Babylon/loadsave.h @@ -20,12 +20,8 @@ // loadsave.h // -#ifndef __LOADSAVE_H -#define __LOADSAVE_H +#pragma once int WriteMainDB(TransDB *db, const char *filename, CBabylonDlg *dlg ); int LoadMainDB(TransDB *db, const char *filename, void (*cb) (void ) = NULL ); int GetLabelCountDB ( char *filename ); - - -#endif diff --git a/Core/Tools/Babylon/olestring.h b/Core/Tools/Babylon/olestring.h index 577c86e800..1e3dd2908d 100644 --- a/Core/Tools/Babylon/olestring.h +++ b/Core/Tools/Babylon/olestring.h @@ -20,8 +20,7 @@ // OLEString // -#ifndef __OLESTRING_H -#define __OLESTRING_H +#pragma once const unsigned int OLESTRING_DEFAULT_SIZE = 256; @@ -55,7 +54,3 @@ template int SameFormat ( text *string1, text *string2 ); template void EncodeFormat ( text *string ); template void DecodeFormat ( text *string ); template int IsFormatTypeChar( text string1 ); - - - -#endif // __OLESTRING_H diff --git a/Core/Tools/Babylon/transcs.h b/Core/Tools/Babylon/transcs.h index f0a6c5de3f..559fa4f7eb 100644 --- a/Core/Tools/Babylon/transcs.h +++ b/Core/Tools/Babylon/transcs.h @@ -20,10 +20,6 @@ // transcs.h Translate char set // -#ifndef _TRANSCS_H -#define _TRANSCS_H - +#pragma once void CreateTranslationTable ( void ); - -#endif // _TRANSCS_H diff --git a/Core/Tools/CRCDiff/KVPair.cpp b/Core/Tools/CRCDiff/KVPair.cpp index 4aa7c4a968..bd7b396195 100644 --- a/Core/Tools/CRCDiff/KVPair.cpp +++ b/Core/Tools/CRCDiff/KVPair.cpp @@ -31,7 +31,7 @@ std::string intToString(int val) { - std::string s = ""; + std::string s; bool neg = (val < 0); if (val < 0) { @@ -134,7 +134,7 @@ void KVPairClass::readFromFile( const std::string& in, const std::string& delim FILE *fp = fopen(in.c_str(), "rb"); if (fp) { - std::string s = ""; + std::string s; fseek(fp, 0, SEEK_END); int len = ftell(fp); fseek(fp, 0, SEEK_SET); diff --git a/Core/Tools/CRCDiff/KVPair.h b/Core/Tools/CRCDiff/KVPair.h index a701b3a2a9..6ef7043b3a 100644 --- a/Core/Tools/CRCDiff/KVPair.h +++ b/Core/Tools/CRCDiff/KVPair.h @@ -23,8 +23,7 @@ // Description: Key/Value Pair class // --------------------------------------------------------------------------- -#ifndef __KVPAIR_H__ -#define __KVPAIR_H__ +#pragma once #include #include @@ -48,6 +47,3 @@ class KVPairClass protected: KeyValueMap m_map; }; - -#endif // __KVPAIR_H__ - diff --git a/Core/Tools/CRCDiff/debug.h b/Core/Tools/CRCDiff/debug.h index 8f1473ee9f..1945b6ef99 100644 --- a/Core/Tools/CRCDiff/debug.h +++ b/Core/Tools/CRCDiff/debug.h @@ -20,8 +20,7 @@ // Minimal debug info // Author: Matthew D. Campbell, Sept 2002 -#ifndef __DEBUG_H__ -#define __DEBUG_H__ +#pragma once #ifdef DEBUG @@ -35,6 +34,3 @@ void DebugLog( const char *fmt, ... ); #define DEBUG_LOG(x) {} #endif // DEBUG - -#endif // __DEBUG_H__ - diff --git a/Core/Tools/CRCDiff/expander.cpp b/Core/Tools/CRCDiff/expander.cpp index 9e7961d5d0..f1d4d07c78 100644 --- a/Core/Tools/CRCDiff/expander.cpp +++ b/Core/Tools/CRCDiff/expander.cpp @@ -99,7 +99,7 @@ void Expander::expand( const std::string& input, else { std::string toExpand = it->second; - std::string expanded = ""; + std::string expanded; //DEBUG_LOG(("###### expanding '%s'", toExpand.c_str())); expand(toExpand, expanded, stripUnknown); //DEBUG_LOG(("###### expanded '%s'", expanded.c_str())); diff --git a/Core/Tools/CRCDiff/expander.h b/Core/Tools/CRCDiff/expander.h index 8dcbe5873b..4373e87208 100644 --- a/Core/Tools/CRCDiff/expander.h +++ b/Core/Tools/CRCDiff/expander.h @@ -23,8 +23,7 @@ // Description: Key/value pair template expansion class // --------------------------------------------------------------------------- -#ifndef __EXPANDER_H__ -#define __EXPANDER_H__ +#pragma once #include #include @@ -49,6 +48,3 @@ class Expander std::string m_left; std::string m_right; }; - -#endif // __EXPANDER_H__ - diff --git a/Core/Tools/CRCDiff/misc.h b/Core/Tools/CRCDiff/misc.h index 6f394ff3c5..54bc699580 100644 --- a/Core/Tools/CRCDiff/misc.h +++ b/Core/Tools/CRCDiff/misc.h @@ -23,12 +23,8 @@ // Description: misc utils // --------------------------------------------------------------------------- -#ifndef __MISC_H__ -#define __MISC_H__ +#pragma once #include std::string intToString(int val); - -#endif // __MISC_H__ - diff --git a/Core/Tools/Compress/Compress.cpp b/Core/Tools/Compress/Compress.cpp index a9119e7b25..66466171cc 100644 --- a/Core/Tools/Compress/Compress.cpp +++ b/Core/Tools/Compress/Compress.cpp @@ -52,19 +52,19 @@ void dumpHelp(const char *exe) int main(int argc, char **argv) { - std::string inFile = ""; - std::string outFile = ""; + std::string inFile; + std::string outFile; CompressionType compressType = CompressionManager::getPreferredCompression(); for (int i=1; i 1000 #pragma once -#endif // _MSC_VER > 1000 #ifndef __AFXWIN_H__ #error include 'stdafx.h' before including this file for PCH @@ -68,5 +63,3 @@ class CDebugWindowApp : public CWinApp //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DEBUGWINDOW_H__018E1800_6E59_4527_BA0C_8731EBF22953__INCLUDED_) diff --git a/Core/Tools/DebugWindow/StdAfx.h b/Core/Tools/DebugWindow/StdAfx.h index 69b33dd61f..93949ef824 100644 --- a/Core/Tools/DebugWindow/StdAfx.h +++ b/Core/Tools/DebugWindow/StdAfx.h @@ -21,12 +21,7 @@ // are changed infrequently // -#if !defined(AFX_STDAFX_H__FB15454D_21B4_4F33_A593_C13A58B86008__INCLUDED_) -#define AFX_STDAFX_H__FB15454D_21B4_4F33_A593_C13A58B86008__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers @@ -61,5 +56,3 @@ //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__FB15454D_21B4_4F33_A593_C13A58B86008__INCLUDED_) diff --git a/Core/Tools/ImagePacker/CMakeLists.txt b/Core/Tools/ImagePacker/CMakeLists.txt index eb944eda28..db8aaf2d15 100644 --- a/Core/Tools/ImagePacker/CMakeLists.txt +++ b/Core/Tools/ImagePacker/CMakeLists.txt @@ -29,7 +29,7 @@ target_link_libraries(corei_imagepacker INTERFACE comctl32 core_debug core_profile - dbghelplib + core_wwcommon imm32 vfw32 winmm diff --git a/Core/Tools/ImagePacker/Include/ImageDirectory.h b/Core/Tools/ImagePacker/Include/ImageDirectory.h index ae2984c556..d2b64c33ef 100644 --- a/Core/Tools/ImagePacker/Include/ImageDirectory.h +++ b/Core/Tools/ImagePacker/Include/ImageDirectory.h @@ -40,9 +40,6 @@ #pragma once -#ifndef __IMAGEDIRECTORY_H_ -#define __IMAGEDIRECTORY_H_ - // SYSTEM INCLUDES //////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////// @@ -82,6 +79,3 @@ inline ImageDirectory::ImageDirectory( void ) } // EXTERNALS ////////////////////////////////////////////////////////////////// - -#endif // __IMAGEDIRECTORY_H_ - diff --git a/Core/Tools/ImagePacker/Include/ImageInfo.h b/Core/Tools/ImagePacker/Include/ImageInfo.h index a5c8927c9e..3dce43dfc0 100644 --- a/Core/Tools/ImagePacker/Include/ImageInfo.h +++ b/Core/Tools/ImagePacker/Include/ImageInfo.h @@ -39,9 +39,6 @@ #pragma once -#ifndef __IMAGEINFO_H_ -#define __IMAGEINFO_H_ - // SYSTEM INCLUDES //////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////// @@ -111,6 +108,3 @@ class ImageInfo // INLINING /////////////////////////////////////////////////////////////////// // EXTERNALS ////////////////////////////////////////////////////////////////// - -#endif // __IMAGEINFO_H_ - diff --git a/Core/Tools/ImagePacker/Include/ImagePacker.h b/Core/Tools/ImagePacker/Include/ImagePacker.h index 35a08b0066..c989a2fd9f 100644 --- a/Core/Tools/ImagePacker/Include/ImagePacker.h +++ b/Core/Tools/ImagePacker/Include/ImagePacker.h @@ -39,15 +39,12 @@ #pragma once -#ifndef __IMAGEPACKER_H_ -#define __IMAGEPACKER_H_ - // SYSTEM INCLUDES //////////////////////////////////////////////////////////// #include // USER INCLUDES ////////////////////////////////////////////////////////////// #include "Lib/BaseType.h" -#include "WWLib/TARGA.H" +#include "WWLib/TARGA.h" #include "ImageDirectory.h" #include "ImageInfo.h" #include "TexturePage.h" @@ -212,6 +209,3 @@ inline UnsignedInt ImagePacker::getGapMethod( void ) { return m_gapMethod; } // EXTERNALS ////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// extern ImagePacker *TheImagePacker; - -#endif // __IMAGEPACKER_H_ - diff --git a/Core/Tools/ImagePacker/Include/TexturePage.h b/Core/Tools/ImagePacker/Include/TexturePage.h index 93a9a4a462..ab0cd5142b 100644 --- a/Core/Tools/ImagePacker/Include/TexturePage.h +++ b/Core/Tools/ImagePacker/Include/TexturePage.h @@ -40,16 +40,13 @@ #pragma once -#ifndef __TEXTUREPAGE_H_ -#define __TEXTUREPAGE_H_ - // SYSTEM INCLUDES //////////////////////////////////////////////////////////// #include /////////////////////////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -#include "WWLib/TARGA.H" +#include "WWLib/TARGA.h" #include "Lib/BaseType.h" #include "ImageInfo.h" @@ -167,6 +164,3 @@ inline Int TexturePage::getWidth( void ) { return m_size.x; } inline Int TexturePage::getHeight( void ) { return m_size.y; } // EXTERNALS ////////////////////////////////////////////////////////////////// - -#endif // __TEXTUREPAGE_H_ - diff --git a/Core/Tools/ImagePacker/Include/WinMain.h b/Core/Tools/ImagePacker/Include/WinMain.h index dc2cffc033..c5ebe3b4af 100644 --- a/Core/Tools/ImagePacker/Include/WinMain.h +++ b/Core/Tools/ImagePacker/Include/WinMain.h @@ -39,9 +39,6 @@ #pragma once -#ifndef __WINMAIN_H_ -#define __WINMAIN_H_ - // SYSTEM INCLUDES //////////////////////////////////////////////////////////// #include @@ -57,6 +54,3 @@ // EXTERNALS ////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// extern HINSTANCE ApplicationHInstance; - -#endif // __WINMAIN_H_ - diff --git a/Core/Tools/ImagePacker/Include/WindowProc.h b/Core/Tools/ImagePacker/Include/WindowProc.h index 6d99831943..57886fd6c3 100644 --- a/Core/Tools/ImagePacker/Include/WindowProc.h +++ b/Core/Tools/ImagePacker/Include/WindowProc.h @@ -39,9 +39,6 @@ #pragma once -#ifndef __WINDOWPROC_H_ -#define __WINDOWPROC_H_ - // SYSTEM INCLUDES //////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////// @@ -69,6 +66,3 @@ extern BOOL CALLBACK PageErrorProc( HWND hWndDialog, UINT message, extern BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, WPARAM wParam, LPARAM lParam ); - -#endif // __WINDOWPROC_H_ - diff --git a/Core/Tools/ImagePacker/Source/ImageInfo.cpp b/Core/Tools/ImagePacker/Source/ImageInfo.cpp index 24b8776abf..46d483ac0c 100644 --- a/Core/Tools/ImagePacker/Source/ImageInfo.cpp +++ b/Core/Tools/ImagePacker/Source/ImageInfo.cpp @@ -86,7 +86,7 @@ ImageInfo::ImageInfo( void ) m_gutterUsed.x = 0; m_gutterUsed.y = 0; -} // end ImageInfo +} // ImageInfo::~ImageInfo ====================================================== /** */ @@ -94,14 +94,8 @@ ImageInfo::ImageInfo( void ) ImageInfo::~ImageInfo( void ) { - // delete path name - if( m_path ) - delete [] m_path; + delete [] m_path; + delete [] m_filenameOnly; + delete [] m_filenameOnlyNoExt; - if( m_filenameOnly ) - delete [] m_filenameOnly; - - if( m_filenameOnlyNoExt ) - delete [] m_filenameOnlyNoExt; - -} // end ~ImageInfo +} diff --git a/Core/Tools/ImagePacker/Source/ImagePacker.cpp b/Core/Tools/ImagePacker/Source/ImagePacker.cpp index 9d8847f5da..a113f4d7ea 100644 --- a/Core/Tools/ImagePacker/Source/ImagePacker.cpp +++ b/Core/Tools/ImagePacker/Source/ImagePacker.cpp @@ -41,13 +41,13 @@ /////////////////////////////////////////////////////////////////////////////// // SYSTEM INCLUDES //////////////////////////////////////////////////////////// -#include #include #include +#include // USER INCLUDES ////////////////////////////////////////////////////////////// #include "Common/Debug.h" -#include "WWLib/TARGA.H" +#include "WWLib/TARGA.h" #include "Resource.h" #include "ImagePacker.h" #include "WinMain.h" @@ -86,7 +86,7 @@ TexturePage *ImagePacker::createNewTexturePage( void ) DEBUG_ASSERTCRASH( page, ("Unable to allocate new texture page.") ); return NULL; - } // end if + } // link page to list page->m_prev = NULL; @@ -107,7 +107,7 @@ TexturePage *ImagePacker::createNewTexturePage( void ) return page; -} // end createNewTexturePage +} // ImagePacker::validateImages ================================================ /** Check all the images in the image list, if any of them cannot be @@ -140,7 +140,7 @@ Bool ImagePacker::validateImages( void ) DEBUG_ASSERTCRASH( image, ("Image in imagelist is NULL") ); continue; // should never happen - } // end if + } // // if this image is too big to fit in the target page size as a whole @@ -154,7 +154,7 @@ Bool ImagePacker::validateImages( void ) BitSet( image->m_status, ImageInfo::TOOBIG ); BitSet( image->m_status, ImageInfo::CANTPROCESS ); - } // end if + } // // if this image is not the right format we can't process it, at @@ -167,9 +167,9 @@ Bool ImagePacker::validateImages( void ) BitSet( image->m_status, ImageInfo::INVALIDCOLORDEPTH ); BitSet( image->m_status, ImageInfo::CANTPROCESS ); - } // end if + } - } // end for i + } // // if we have errors, build a list and show them to the user @@ -182,11 +182,11 @@ Bool ImagePacker::validateImages( void ) TheImagePacker->getWindowHandle(), (DLGPROC)ImageErrorProc ); - } // end if + } return proceed; -} // end validateImages +} // ImagePacker::packImages ==================================================== /** Pack all the images in the image list, starting from the top and @@ -211,7 +211,7 @@ Bool ImagePacker::packImages( void ) statusMessage( "Build Cancelled By User." ); return FALSE; - } // end if + } // loop through all images for( i = 0; i < m_imageCount; i++ ) @@ -235,7 +235,7 @@ Bool ImagePacker::packImages( void ) if( page->addImage( image ) == TRUE ) break; // page added, stop trying to add into pages - } // end for page + } // if image was not able to go on any existing page create a new page for it if( page == NULL ) @@ -255,15 +255,15 @@ Bool ImagePacker::packImages( void ) MessageBox( NULL, buffer, "Internal Error", MB_OK | MB_ICONERROR ); return FALSE; - } // end if + } - } // end if + } - } // end for i + } return TRUE; // success -} // end packImages +} // ImagePacker::writeFinalTextures ============================================ /** Generate and write the final textures to the output directory @@ -295,7 +295,7 @@ void ImagePacker::writeFinalTextures( void ) errors = TRUE; continue; // could not generate this page, but try to continue - } // end if + } // // write this page out to a file using the filename given by @@ -307,9 +307,9 @@ void ImagePacker::writeFinalTextures( void ) errors = TRUE; continue; // could not write page, but try to go on - } // end if + } - } // end for page + } // check for any errors and notify the user if( errors == TRUE ) @@ -320,9 +320,9 @@ void ImagePacker::writeFinalTextures( void ) TheImagePacker->getWindowHandle(), (DLGPROC)PageErrorProc ); - } // end if + } -} // end writeFinalTextures +} // sortImageCompare =========================================================== /** Compare function for qsort @@ -343,7 +343,7 @@ static Int sortImageCompare( const void *aa, const void *bb ) else return 0; -} // end sortImageCompare +} // ImagePacker::sortImageList ================================================= /** Sort the image list */ @@ -354,7 +354,7 @@ void ImagePacker::sortImageList( void ) // sort all images so that largest area ones are first qsort( (void *)m_imageList, m_imageCount, sizeof( ImageInfo *), sortImageCompare ); -} // end sortImageList +} // ImagePacker::addImagesInDirectory ========================================== /** Add all the images in the specified directory */ @@ -385,8 +385,8 @@ void ImagePacker::addImagesInDirectory( char *dir ) // if this is a file count it if( !(item.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - strcmp( item.cFileName, "." ) && - strcmp( item.cFileName, ".." ) ) + strcmp( item.cFileName, "." ) != 0 && + strcmp( item.cFileName, ".." ) != 0 ) { len = strlen( item.cFileName ); @@ -400,9 +400,9 @@ void ImagePacker::addImagesInDirectory( char *dir ) sprintf( filePath, "%s%s", dir, item.cFileName ); addImage( filePath ); - } // end if + } - } // end if + } // find the rest of the files while( FindNextFile( hFile, &item ) != 0 ) @@ -410,8 +410,8 @@ void ImagePacker::addImagesInDirectory( char *dir ) // if this is a file count it if( !(item.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - strcmp( item.cFileName, "." ) && - strcmp( item.cFileName, ".." ) ) + strcmp( item.cFileName, "." ) != 0 && + strcmp( item.cFileName, ".." ) != 0 ) { len = strlen( item.cFileName ); @@ -425,21 +425,21 @@ void ImagePacker::addImagesInDirectory( char *dir ) sprintf( filePath, "%s%s", dir, item.cFileName ); addImage( filePath ); - } // end if + } - } // end if + } - } // end while + } // close search FindClose( hFile ); - } //end if, items found + } // restore our current directory SetCurrentDirectory( currDir ); -} // end addImagesInDirectory +} // ImagePacker::checkOutputDirectory ========================================== /** Verify that there are no files in the output directory ... if there @@ -473,8 +473,8 @@ Bool ImagePacker::checkOutputDirectory( void ) // if this is a file count it if( !(item.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - strcmp( item.cFileName, "." ) && - strcmp( item.cFileName, ".." ) ) + strcmp( item.cFileName, "." ) != 0 && + strcmp( item.cFileName, ".." ) != 0 ) fileCount++; // find the rest of the files @@ -483,16 +483,16 @@ Bool ImagePacker::checkOutputDirectory( void ) // if this is a file count it if( !(item.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - strcmp( item.cFileName, "." ) && - strcmp( item.cFileName, ".." ) ) + strcmp( item.cFileName, "." ) != 0 && + strcmp( item.cFileName, ".." ) != 0 ) fileCount++; - } // end while + } // close search FindClose( hFile ); - } //end if, items found + } // switch back to the current directory SetCurrentDirectory( currDir ); @@ -526,8 +526,8 @@ Bool ImagePacker::checkOutputDirectory( void ) // if this is a file count it if( !(item.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - strcmp( item.cFileName, "." ) && - strcmp( item.cFileName, ".." ) ) + strcmp( item.cFileName, "." ) != 0 && + strcmp( item.cFileName, ".." ) != 0 ) DeleteFile( item.cFileName ); // find the rest of the files @@ -536,25 +536,25 @@ Bool ImagePacker::checkOutputDirectory( void ) // if this is a file count it if( !(item.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - strcmp( item.cFileName, "." ) && - strcmp( item.cFileName, ".." ) ) + strcmp( item.cFileName, "." ) != 0 && + strcmp( item.cFileName, ".." ) != 0 ) DeleteFile( item.cFileName ); - } // end while + } // close search FindClose( hFile ); - } //end if, items found + } // switch back to the current directory SetCurrentDirectory( currDir ); - } // end if + } return TRUE; // proceed -} // end checkOutputDirectory +} // ImagePacker::resetPageList ================================================= /** Clear the page list */ @@ -570,13 +570,13 @@ void ImagePacker::resetPageList( void ) delete m_pageList; m_pageList = next; - } // end while + } m_pageTail = NULL; m_pageCount = 0; m_targetPreviewPage = 1; -} // end resetPageList +} // ImagePacker::resetImageDirectoryList ======================================= /** Clear the image directory list */ @@ -592,12 +592,12 @@ void ImagePacker::resetImageDirectoryList( void ) delete m_dirList; m_dirList = next; - } // end while + } m_dirCount = 0; m_imagesInDirs = 0; -} // end resetImageDirectoryList +} // ImagePacker::resetImageList ================================================ /** Clear the image list */ @@ -605,12 +605,11 @@ void ImagePacker::resetImageDirectoryList( void ) void ImagePacker::resetImageList( void ) { - if( m_imageList ) - delete [] m_imageList; + delete [] m_imageList; m_imageList = NULL; m_imageCount = 0; -} // end resetImageList +} // ImagePacker::addDirectory ================================================== /** Add the directory to the directory list, do not add it if it is already @@ -651,7 +650,7 @@ void ImagePacker::addDirectory( char *path, Bool subDirs ) MB_OK | MB_ICONERROR ); return; - } // end if + } // allocate space for the path Int len = strlen( path ); @@ -665,7 +664,7 @@ void ImagePacker::addDirectory( char *path, Bool subDirs ) delete dir; return; - } // end if + } // tie to list dir->m_prev = NULL; @@ -688,8 +687,8 @@ void ImagePacker::addDirectory( char *path, Bool subDirs ) // if this is a file count it if( !(item.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - strcmp( item.cFileName, "." ) && - strcmp( item.cFileName, ".." ) ) + strcmp( item.cFileName, "." ) != 0 && + strcmp( item.cFileName, ".." ) != 0 ) { len = strlen( item.cFileName ); @@ -700,7 +699,7 @@ void ImagePacker::addDirectory( char *path, Bool subDirs ) (item.cFileName[ len - 1 ] == 'a' || item.cFileName[ len - 1 ] == 'A') ) dir->m_imageCount++; - } // end if + } // find the rest of the files while( FindNextFile( hFile, &item ) != 0 ) @@ -708,8 +707,8 @@ void ImagePacker::addDirectory( char *path, Bool subDirs ) // if this is a file count it if( !(item.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - strcmp( item.cFileName, "." ) && - strcmp( item.cFileName, ".." ) ) + strcmp( item.cFileName, "." ) != 0 && + strcmp( item.cFileName, ".." ) != 0 ) { len = strlen( item.cFileName ); @@ -720,14 +719,14 @@ void ImagePacker::addDirectory( char *path, Bool subDirs ) (item.cFileName[ len - 1 ] == 'a' || item.cFileName[ len - 1 ] == 'A') ) dir->m_imageCount++; - } // end if + } - } // end while + } // close search FindClose( hFile ); - } //end if, items found + } // add the image count of this directory to the total image count m_imagesInDirs += dir->m_imageCount; @@ -744,14 +743,14 @@ void ImagePacker::addDirectory( char *path, Bool subDirs ) // if this is a file count it if( (item.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - strcmp( item.cFileName, "." ) && - strcmp( item.cFileName, ".." ) ) + strcmp( item.cFileName, "." ) != 0 && + strcmp( item.cFileName, ".." ) != 0 ) { sprintf( subDir, "%s%s\\", path, item.cFileName ); addDirectory( subDir, subDirs ); - } // end if + } // find the rest of the files while( FindNextFile( hFile, &item ) != 0 ) @@ -759,28 +758,28 @@ void ImagePacker::addDirectory( char *path, Bool subDirs ) // if this is a file count it if( (item.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && - strcmp( item.cFileName, "." ) && - strcmp( item.cFileName, ".." ) ) + strcmp( item.cFileName, "." ) != 0 && + strcmp( item.cFileName, ".." ) != 0 ) { sprintf( subDir, "%s%s\\", path, item.cFileName ); addDirectory( subDir, subDirs ); - } // end if + } - } // end while + } // close search FindClose( hFile ); - } //end if, items found + } - } // end if + } // restore our current directory SetCurrentDirectory( currDir ); -} // end addDirectory +} // ImagePacker::addImage ====================================================== /** Add the image to the image list */ @@ -801,7 +800,7 @@ void ImagePacker::addImage( char *path ) MB_OK | MB_ICONERROR ); return; - } // end if + } // allocate space for the path Int len = strlen( path ); @@ -815,7 +814,7 @@ void ImagePacker::addImage( char *path ) delete info; return; - } // end if + } // load just the header information from the targa m_targa->Load( info->m_path, 0, TRUE ); @@ -838,15 +837,14 @@ void ImagePacker::addImage( char *path ) break; } - } // end for i + } Int nameLen = strlen( c ); info->m_filenameOnly = new char[ nameLen + 1 ]; strcpy( info->m_filenameOnly, c ); info->m_filenameOnlyNoExt = new char[ nameLen - 4 + 1 ]; - strncpy( info->m_filenameOnlyNoExt, c, nameLen - 4 ); - info->m_filenameOnlyNoExt[ nameLen - 4 ] = '\0'; + strlcpy( info->m_filenameOnlyNoExt, c, nameLen - 4 + 1 ); // assign to array m_imageList[ m_imageCount++ ] = info; @@ -856,7 +854,7 @@ void ImagePacker::addImage( char *path ) m_imageCount, m_imagesInDirs ); statusMessage( m_statusBuffer ); -} // end addImage +} // ImagePacker::generateINIFile =============================================== /** Generate the INI image file definition for the final packed images */ @@ -879,7 +877,7 @@ Bool ImagePacker::generateINIFile( void ) MessageBox( NULL, buffer, "Error Opening File", MB_OK | MB_ICONERROR ); return FALSE; - } // end if + } // print header for file fprintf( fp, "; ------------------------------------------------------------\n" ); @@ -926,16 +924,16 @@ Bool ImagePacker::generateINIFile( void ) "ROTATED_90_CLOCKWISE" : "NONE" ); fprintf( fp, "End\n\n" ); - } // end for image + } - } // end for page + } // close the file fclose( fp ); return TRUE; // success -} // end generateINIFile +} /////////////////////////////////////////////////////////////////////////////// // PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// @@ -975,12 +973,12 @@ Bool ImagePacker::getSettingsFromDialog( HWND dialog ) "Must Be Power Of 2", MB_OK | MB_ICONERROR ); return FALSE; - } // end if + } // set the size for the image packer setTargetSize( size, size ); - } // end if + } else if( IsDlgButtonChecked( dialog, RADIO_128X128 ) ) setTargetSize( 128, 128 ); else if( IsDlgButtonChecked( dialog, RADIO_256X256 ) ) @@ -994,7 +992,7 @@ Bool ImagePacker::getSettingsFromDialog( HWND dialog ) "Error", MB_OK | MB_ICONERROR ); return FALSE; - } // end else + } // get alpha option Bool outputAlpha = FALSE; @@ -1056,11 +1054,11 @@ Bool ImagePacker::getSettingsFromDialog( HWND dialog ) MessageBox( NULL, buffer, "Illegal Filename", MB_OK | MB_ICONERROR ); return FALSE; - } // end if + } - } // end for j + } - } // end for i + } // get the work on sub-folders option m_useSubFolders = IsDlgButtonChecked( dialog, CHECK_USE_SUB_FOLDERS ); @@ -1084,12 +1082,12 @@ Bool ImagePacker::getSettingsFromDialog( HWND dialog ) // add the directory addDirectory( buffer, m_useSubFolders ); - } // end for i + } // all done return TRUE; -} // end getSettingsFromDialog +} // ImagePacker::ImagePacker =================================================== /** */ @@ -1124,7 +1122,7 @@ ImagePacker::ImagePacker( void ) m_targa = NULL; m_compressTextures = FALSE; -} // end ImagePacker +} // ImagePacker::~ImagePacker ================================================== /** */ @@ -1138,10 +1136,9 @@ ImagePacker::~ImagePacker( void ) resetPageList(); // delete our targa header loader - if( m_targa ) - delete m_targa; + delete m_targa; -} // end ~ImagePacker +} // ImagePacker::init ========================================================== /** Initialize the image packer system */ @@ -1159,11 +1156,11 @@ Bool ImagePacker::init( void ) "Internal Error", MB_OK | MB_ICONERROR ); return FALSE; - } // end if + } return TRUE; -} // end init +} // ImagePacker::statusMessage ================================================= /** Status message for the program */ @@ -1173,7 +1170,7 @@ void ImagePacker::statusMessage( const char *message ) SetDlgItemText( getWindowHandle(), STATIC_STATUS, message ); -} // end statusMessage +} // ImagePacker::process ======================================================= /** Run the packing process */ @@ -1188,8 +1185,8 @@ Bool ImagePacker::process( void ) CreateDirectory( m_outputDirectory, NULL ); // subdir of output directory based on output image name - strcat( m_outputDirectory, m_outputFile ); - strcat( m_outputDirectory, "\\" ); + strlcat(m_outputDirectory, m_outputFile, ARRAY_SIZE(m_outputDirectory)); + strlcat(m_outputDirectory, "\\", ARRAY_SIZE(m_outputDirectory)); // // check for existing images in the output directory ... if we have @@ -1202,7 +1199,7 @@ Bool ImagePacker::process( void ) statusMessage( "Build Process Cancelled." ); return FALSE; - } // end if + } // reset the contents of our image list and existing textures resetImageList(); @@ -1241,9 +1238,9 @@ Bool ImagePacker::process( void ) m_pageCount, m_imageCount, m_dirCount ); statusMessage( m_statusBuffer ); - } // end if + } return TRUE; -} // end process +} diff --git a/Core/Tools/ImagePacker/Source/TexturePage.cpp b/Core/Tools/ImagePacker/Source/TexturePage.cpp index 837c2db767..e463a558f4 100644 --- a/Core/Tools/ImagePacker/Source/TexturePage.cpp +++ b/Core/Tools/ImagePacker/Source/TexturePage.cpp @@ -40,7 +40,7 @@ // SYSTEM INCLUDES //////////////////////////////////////////////////////////// #include -#include +#include // USER INCLUDES ////////////////////////////////////////////////////////////// #include "Common/Debug.h" @@ -100,7 +100,7 @@ void TexturePage::extendToRowIfOpen( char *src, row = src + (buffWidth * buffBPP); - } // end if + } else if( srcY >= imageHeight / 2 && (srcY != imageHeight - 1 || BitIsSet( fitBits, ImageInfo::FIT_YBORDER_BOTTOM )) ) @@ -109,7 +109,7 @@ void TexturePage::extendToRowIfOpen( char *src, // try to extend pixel "down" if that pixel is "open" row = src - (buffWidth * buffBPP); - } // end else + } // // if a 'row' is available, try to extend the current pixel @@ -127,7 +127,7 @@ void TexturePage::extendToRowIfOpen( char *src, otherColor[ 1 ] = row[ 2 ]; otherColor[ 2 ] = row[ 3 ]; - } // end if + } else { @@ -135,7 +135,7 @@ void TexturePage::extendToRowIfOpen( char *src, otherColor[ 1 ] = row[ 1 ]; otherColor[ 2 ] = row[ 2 ]; - } // end else + } // // see if this pixel is "open", again we prefer to check the @@ -148,7 +148,7 @@ void TexturePage::extendToRowIfOpen( char *src, if( otherAlpha == 0 ) otherOpen = TRUE; - } // end if + } else { @@ -157,7 +157,7 @@ void TexturePage::extendToRowIfOpen( char *src, otherColor[ 2 ] == 0 ) otherOpen = TRUE; - } // end else + } // copy pixel data from 'src' to 'row' if 'row' is "open" if( otherOpen == TRUE ) @@ -174,7 +174,7 @@ void TexturePage::extendToRowIfOpen( char *src, color[ 1 ] = src[ 2 ]; color[ 2 ] = src[ 3 ]; - } // end if + } else { @@ -182,7 +182,7 @@ void TexturePage::extendToRowIfOpen( char *src, color[ 1 ] = src[ 1 ]; color[ 2 ] = src[ 2 ]; - } // end else + } // copy the pixel to 'row' if( buffBPP == 4 ) @@ -194,7 +194,7 @@ void TexturePage::extendToRowIfOpen( char *src, row[ 2 ] = color[ 1 ]; row[ 3 ] = color[ 2 ]; - } // end if + } else { @@ -202,13 +202,13 @@ void TexturePage::extendToRowIfOpen( char *src, row[ 1 ] = color[ 1 ]; row[ 2 ] = color[ 2 ]; - } // end else + } - } // end if, other spot is open, copy it + } - } // end if, row + } -} // end extendToRowIfOpen +} // TexturePage::extendImageEdges ============================================== /** We want to extend the image data in destBuffer at the location region @@ -244,14 +244,14 @@ void TexturePage::extendImageEdges( Byte *destBuffer, imageWidth = image->m_size.y; imageHeight = image->m_size.x; - } // end if + } else { imageWidth = image->m_size.x; imageHeight = image->m_size.y; - } // end else + } Int x, y; char *ptr; @@ -279,7 +279,7 @@ void TexturePage::extendImageEdges( Byte *destBuffer, color[ 1 ] = ptr[ 2 ]; color[ 2 ] = ptr[ 3 ]; - } // end if + } else { @@ -287,7 +287,7 @@ void TexturePage::extendImageEdges( Byte *destBuffer, color[ 1 ] = ptr[ 1 ]; color[ 2 ] = ptr[ 2 ]; - } // end else + } // // see wheter or not we have data at this pixel, if we have alpha @@ -301,7 +301,7 @@ void TexturePage::extendImageEdges( Byte *destBuffer, if( alpha != 0 ) currPixel = TRUE; - } // end if + } else { @@ -310,7 +310,7 @@ void TexturePage::extendImageEdges( Byte *destBuffer, color[ 2 ] != 0 ) currPixel = TRUE; - } // end else + } // // if we're at the right edge we will extend this pixel off the @@ -335,7 +335,7 @@ void TexturePage::extendImageEdges( Byte *destBuffer, *(ptr + 6) = color[ 1 ]; *(ptr + 7) = color[ 2 ]; - } // end if + } else { @@ -343,9 +343,9 @@ void TexturePage::extendImageEdges( Byte *destBuffer, *(ptr + 4) = color[ 1 ]; *(ptr + 5) = color[ 2 ]; - } // end else + } - } // end if + } // // if we have a pixel here, attempt to extend it to the above @@ -377,9 +377,9 @@ void TexturePage::extendImageEdges( Byte *destBuffer, *(ptr - 2) = color[ 1 ]; *(ptr - 1) = color[ 2 ]; - } // end if + } - } // end if + } else if( prevPixel == TRUE && currPixel == FALSE ) { @@ -405,7 +405,7 @@ void TexturePage::extendImageEdges( Byte *destBuffer, ptr[ 2 ] = *(ptr - 2); ptr[ 3 ] = *(ptr - 1); - } // end if + } else { @@ -413,9 +413,9 @@ void TexturePage::extendImageEdges( Byte *destBuffer, ptr[ 1 ] = *(ptr - 2); ptr[ 2 ] = *(ptr - 1); - } // end else + } - } // end else if + } // // one more time now for a special case in the corners of the extended @@ -465,7 +465,7 @@ void TexturePage::extendImageEdges( Byte *destBuffer, dst[ 2 ] = color[ 1 ]; dst[ 3 ] = color[ 2 ]; - } // end if + } else { @@ -473,11 +473,11 @@ void TexturePage::extendImageEdges( Byte *destBuffer, dst[ 1 ] = color[ 1 ]; dst[ 2 ] = color[ 2 ]; - } // end else + } - } // end if dst + } - } // end if + } // move to the next pixel ptr += destBPP; @@ -488,11 +488,11 @@ void TexturePage::extendImageEdges( Byte *destBuffer, // prevPixel = currPixel; - } // end for x + } - } // end for y + } -} // end extendImageEdges +} // TexturePage::addImageData ================================================== /** Add the actual image data from 'image' to the destination buffer @@ -528,7 +528,7 @@ Bool TexturePage::addImageData( Byte *destBuffer, MessageBox( NULL, buffer, "Cannot Load Source File", MB_OK | MB_ICONERROR ); return FALSE; - } // end if + } // get the source image buffer char *sourceBuffer = source.GetImage(); @@ -585,7 +585,7 @@ Bool TexturePage::addImageData( Byte *destBuffer, else dest[ 0 ] = (char)0xFF; // solid alpha - } // end if + } else { @@ -594,17 +594,17 @@ Bool TexturePage::addImageData( Byte *destBuffer, dest[ 1 ] = src[ 1 ]; dest[ 0 ] = src[ 2 ]; - } // end else + } // skip past all these pixels dest += destBPP; src += sourceBPP; - } // end for x + } - } // end for y + } - } // end if, not rotated + } else { @@ -643,7 +643,7 @@ Bool TexturePage::addImageData( Byte *destBuffer, else dest[ 0 ] = (char)0xFF; // solid alpha - } // end if + } else { @@ -652,17 +652,17 @@ Bool TexturePage::addImageData( Byte *destBuffer, dest[ 1 ] = src[ 1 ]; dest[ 0 ] = src[ 2 ]; - } // end else + } // skip past all these pixels dest += destBPP; src += sourceBPP; - } // end for x + } - } // end for y + } - } // end else + } // // if we have the option to extend the RGB edges on we now need to process @@ -680,7 +680,7 @@ Bool TexturePage::addImageData( Byte *destBuffer, return TRUE; // all done -} // end addImageData +} // TexturePage::spotUsed ====================================================== /** Is this spot in the texture page open? */ @@ -690,7 +690,7 @@ Bool TexturePage::spotUsed( Int x, Int y ) return m_canvas[ y * m_size.y + x ]; -} // end spotUsed +} // TexturePage::lineUsed ====================================================== /** Is there ANY spot in the line specified that is used */ @@ -711,11 +711,11 @@ Bool TexturePage::lineUsed( Int sx, Int sy, Int ex, Int ey ) if( *ptr == USED ) return USED; - } // end for y + } return FALSE; // it's open! -} // end lineUsed +} // TexturePage::markRegionUsed ================================================ /** Mark this region as used */ @@ -737,9 +737,9 @@ void TexturePage::markRegionUsed( IRegion2D *region ) count = (region->hi.x - region->lo.x) + 1; memset( ptr, USED, count ); - } // end for + } -} // end markRegionUsed +} // TexturePage::buildFitRegion ================================================ /** Build an image region to try to fit into the page based on the location @@ -775,7 +775,7 @@ UnsignedInt TexturePage::buildFitRegion( IRegion2D *region, xBorder = 2; yBorder = 2; - } // end if + } // // when the image size exactly matches the target size of the texture @@ -788,14 +788,14 @@ UnsignedInt TexturePage::buildFitRegion( IRegion2D *region, *xGutter = 0; xBorder = 0; - } // end if + } if( imageHeight == m_size.y ) { *yGutter = 0; yBorder = 0; - } // end if + } // // when an image is 1 pixel smaller than the destination texture @@ -839,7 +839,7 @@ UnsignedInt TexturePage::buildFitRegion( IRegion2D *region, return fitBits; -} // end buildFitRegion +} /////////////////////////////////////////////////////////////////////////////// // PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// @@ -866,7 +866,7 @@ TexturePage::TexturePage( Int width, Int height ) DEBUG_ASSERTCRASH( m_canvas, ("Cannot allocate canvas for texture page") ); memset( m_canvas, FREE, sizeof( UnsignedByte ) * canvasSize ); -} // end TexturePage +} // TexturePage::~TexturePage ================================================== /** */ @@ -875,18 +875,15 @@ TexturePage::~TexturePage( void ) { // delete the canvas - if( m_canvas ) - delete [] m_canvas; + delete [] m_canvas; // delete targa if present, this will NOT delete a user assigned image buffer - if( m_targa ) - delete m_targa; + delete m_targa; // delete the final image buffer if present - if( m_packedImage ) - delete [] m_packedImage; + delete [] m_packedImage; -} // end ~TexturePage +} // TexturePage::addImage ====================================================== /** If this image will fit on this page, add it */ @@ -902,7 +899,7 @@ Bool TexturePage::addImage( ImageInfo *image ) DEBUG_ASSERTCRASH( image, ("TexturePage::addImage: NULL image!") ); return TRUE; // say it was added - } // end if + } // get our options for fitting Bool useGutter, useRGBExtend; @@ -945,14 +942,14 @@ Bool TexturePage::addImage( ImageInfo *image ) xGutter = TheImagePacker->getGutter(); yGutter = TheImagePacker->getGutter(); - } // end if + } else { xGutter = 0; yGutter = 0; - } // end else + } // // compute the region of the image at this location, the region that will @@ -969,7 +966,7 @@ Bool TexturePage::addImage( ImageInfo *image ) imageWidth = image->m_size.x; imageHeight = image->m_size.y; - } // end if + } else { @@ -994,7 +991,7 @@ Bool TexturePage::addImage( ImageInfo *image ) imageWidth = image->m_size.y; imageHeight = image->m_size.x; - } // end else + } // build the region fitBits = buildFitRegion( ®ion, x, y, @@ -1028,7 +1025,7 @@ Bool TexturePage::addImage( ImageInfo *image ) useRGBExtend ); - } // end if + } if( region.hi.y >= m_size.y ) { @@ -1045,7 +1042,7 @@ Bool TexturePage::addImage( ImageInfo *image ) &xGutter, &yGutter, useRGBExtend ); - } // end if + } // reject this location if the hi region goes off the texture page if( region.hi.y >= m_size.y ) @@ -1054,14 +1051,14 @@ Bool TexturePage::addImage( ImageInfo *image ) y = m_size.y; // skip to end, this isn't gonna work continue; - } // end if + } if( region.hi.x >= m_size.x ) { x = m_size.x; // skip to end of row to try next row continue; - } // end if + } // // reject this location if any of the corners are in used spots, @@ -1081,7 +1078,7 @@ Bool TexturePage::addImage( ImageInfo *image ) x = region.hi.x; // next anchor spot will be to the right of here continue; - } // end if + } // upper left and lower left if( spotUsed( region.lo.x, region.lo.y ) || // upper left @@ -1158,16 +1155,16 @@ Bool TexturePage::addImage( ImageInfo *image ) return TRUE; // success - } // end for x + } - } // end for y + } - } // end while, triesLeft + } // no space return FALSE; -} // end addImage +} // TexturePage::generateTexture =============================================== /** Generate the final packed texture given all the images that have @@ -1195,7 +1192,7 @@ Bool TexturePage::generateTexture( void ) MessageBox( NULL, buffer, "Internal Error", MB_OK | MB_ICONERROR ); return FALSE; - } // end if + } Bool outputAlpha = TheImagePacker->getOutputAlpha(); Int depth, bpp; @@ -1226,7 +1223,7 @@ Bool TexturePage::generateTexture( void ) BitSet( m_status, CANT_ALLOCATE_PACKED_IMAGE ); return FALSE; - } // end if + } // zero the packed image to all zero memset( m_packedImage, 0, sizeof( Byte ) * bufferSize ); @@ -1250,16 +1247,16 @@ Bool TexturePage::generateTexture( void ) BitSet( m_status, CANT_ADD_IMAGE_DATA ); return FALSE; - } // end if + } - } // end for image + } // set this data into the targa structure m_targa->SetImage( m_packedImage ); return TRUE; // success -} // end generateTexture +} // TexturePage::writeFile ===================================================== /** Write the texture data that has already been generated to a file @@ -1277,7 +1274,7 @@ Bool TexturePage::writeFile( char *baseFilename ) BitSet( m_status, NO_TEXTURE_DATA ); return FALSE; - } // end if + } // construct filename char filePath[ _MAX_PATH ]; @@ -1298,12 +1295,12 @@ Bool TexturePage::writeFile( char *baseFilename ) BitSet( m_status, PAGE_ERROR ); BitSet( m_status, ERROR_DURING_SAVE ); - } // end if + } // return success or not return !error; -} // end writeFile +} // TexturePage::getPixel ====================================================== /** Get the RGB pixel stored at location (x,y) (where (0,0) is the upper @@ -1336,7 +1333,7 @@ void TexturePage::getPixel( Int x, Int y, Byte *r, Byte *g, Byte *b, Byte *a ) *g = buf[ 2 ]; *b = buf[ 3 ]; - } // end if + } else { @@ -1347,6 +1344,6 @@ void TexturePage::getPixel( Int x, Int y, Byte *r, Byte *g, Byte *b, Byte *a ) *g = buf[ 1 ]; *b = buf[ 2 ]; - } // end else + } -} // end getPixel +} diff --git a/Core/Tools/ImagePacker/Source/WinMain.cpp b/Core/Tools/ImagePacker/Source/WinMain.cpp index bd116f022b..e31f28f457 100644 --- a/Core/Tools/ImagePacker/Source/WinMain.cpp +++ b/Core/Tools/ImagePacker/Source/WinMain.cpp @@ -103,7 +103,7 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, TheImagePacker = NULL; return 0; - } // end if + } // load the dialog box DialogBox( hInstance, (LPCTSTR)IMAGE_PACKER_DIALOG, @@ -118,4 +118,4 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, // all done return 0; -} // end WinMain +} diff --git a/Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp b/Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp index 391917057f..190f3fd8a3 100644 --- a/Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp +++ b/Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp @@ -39,7 +39,7 @@ // SYSTEM INCLUDES //////////////////////////////////////////////////////////// #include -#include +#include // USER INCLUDES ////////////////////////////////////////////////////////////// #include "ImagePacker.h" @@ -90,7 +90,7 @@ static void selectDrive( HWND dialog ) if( index != CB_ERR ) SendDlgItemMessage( dialog, COMBO_DRIVE, CB_SETCURSEL, index, 0 ); -} // end selectDrive +} /////////////////////////////////////////////////////////////////////////////// // PUBLIC FUNCTIONS /////////////////////////////////////////////////////////// @@ -127,7 +127,7 @@ BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, // set the current directory in the top label GetCurrentDirectory( _MAX_PATH, buffer ); if( buffer[ strlen( buffer ) - 1 ] != '\\' ) - strcat( buffer, "\\" ); + strlcat(buffer, "\\", ARRAY_SIZE(buffer)); SetDlgItemText( hWndDialog, STATIC_CURRENT_DIR, buffer ); // load the drive box @@ -141,7 +141,7 @@ BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, return TRUE; - } // end init + } // ------------------------------------------------------------------------ case WM_COMMAND: @@ -203,22 +203,22 @@ BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, MB_OK | MB_ICONINFORMATION ); continue; - } // end if + } // add path to the listbox SendDlgItemMessage( TheImagePacker->getWindowHandle(), LIST_FOLDERS, LB_INSERTSTRING, -1, (LPARAM)toAdd ); - } // end if + } - } // end if + } SetCurrentDirectory( startDir ); EndDialog( hWndDialog, TRUE ); break; - } // end proceed + } // -------------------------------------------------------------------- case BUTTON_CANCEL: @@ -228,7 +228,7 @@ BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, EndDialog( hWndDialog, FALSE ); break; - } // end cancel + } // -------------------------------------------------------------------- case COMBO_DRIVE: @@ -262,7 +262,7 @@ BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, // construct new direcotry name and update status text GetCurrentDirectory( _MAX_PATH, buffer ); if( buffer[ strlen( buffer ) - 1 ] != '\\' ) - strcat( buffer, "\\" ); + strlcat(buffer, "\\", ARRAY_SIZE(buffer)); SetDlgItemText( hWndDialog, STATIC_CURRENT_DIR, buffer ); EnableWindow( GetDlgItem( hWndDialog, BUTTON_ADD ), FALSE ); @@ -275,13 +275,13 @@ BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, (LPARAM)"*.*" ); - } // end if + } - } // end if + } break; - } // end drive + } // -------------------------------------------------------------------- case LIST_DIR: @@ -318,16 +318,16 @@ BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, if( strcmp( text, "[..]" ) == 0 ) enable = FALSE; - } // end if + } - } // end if + } else enable = FALSE; // do the enable EnableWindow( GetDlgItem( hWndDialog, BUTTON_ADD ), enable ); - } // end if + } if( notifyCode == LBN_DBLCLK ) { Int selected; @@ -353,7 +353,7 @@ BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, // construct new direcotry name and update status text GetCurrentDirectory( _MAX_PATH, buffer ); if( buffer[ strlen( buffer ) - 1 ] != '\\' ) - strcat( buffer, "\\" ); + strlcat(buffer, "\\", ARRAY_SIZE(buffer)); SetDlgItemText( hWndDialog, STATIC_CURRENT_DIR, buffer ); EnableWindow( GetDlgItem( hWndDialog, BUTTON_ADD ), FALSE ); @@ -365,23 +365,23 @@ BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, DDL_DIRECTORY | DDL_EXCLUSIVE, (LPARAM)"*.*" ); - } // end if + } break; - } // end list command + } - } // end switch + } break; - } // end command + } - } // end switch message + } return 0; -} // end DirectorySelectProc +} diff --git a/Core/Tools/ImagePacker/Source/WindowProcedures/ImageErrorProc.cpp b/Core/Tools/ImagePacker/Source/WindowProcedures/ImageErrorProc.cpp index 90e50ef226..93b08ff214 100644 --- a/Core/Tools/ImagePacker/Source/WindowProcedures/ImageErrorProc.cpp +++ b/Core/Tools/ImagePacker/Source/WindowProcedures/ImageErrorProc.cpp @@ -41,7 +41,7 @@ // SYSTEM INCLUDES //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// #include -#include +#include // USER INCLUDES ////////////////////////////////////////////////////////////// #include "ImagePacker.h" @@ -121,16 +121,16 @@ BOOL CALLBACK ImageErrorProc( HWND hWndDialog, UINT message, SendMessage( list, LB_INSERTSTRING, -1, (LPARAM)buffer ); - } // end if + } - } // end for i + } // set the extents for the horizontal scroll bar in the listbox SendMessage( list, LB_SETHORIZONTALEXTENT, 1280, 0 ); return TRUE; - } // end init + } // ------------------------------------------------------------------------ case WM_COMMAND: @@ -149,7 +149,7 @@ BOOL CALLBACK ImageErrorProc( HWND hWndDialog, UINT message, EndDialog( hWndDialog, TRUE ); break; - } // end proceed + } // -------------------------------------------------------------------- case BUTTON_CANCEL: @@ -158,18 +158,18 @@ BOOL CALLBACK ImageErrorProc( HWND hWndDialog, UINT message, EndDialog( hWndDialog, FALSE ); break; - } // end cancel + } - } // end switch + } break; - } // end command + } - } // end switch message + } return 0; -} // end ImageErrorProc +} diff --git a/Core/Tools/ImagePacker/Source/WindowProcedures/ImagePackerProc.cpp b/Core/Tools/ImagePacker/Source/WindowProcedures/ImagePackerProc.cpp index c1e6bab14c..333f4e11c3 100644 --- a/Core/Tools/ImagePacker/Source/WindowProcedures/ImagePackerProc.cpp +++ b/Core/Tools/ImagePacker/Source/WindowProcedures/ImagePackerProc.cpp @@ -85,7 +85,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, "Internal Error", MB_OK ); EndDialog( hWndDialog, FALSE ); - } // end if + } // save our window handlw TheImagePacker->setWindowHandle( hWndDialog ); @@ -154,7 +154,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, return TRUE; - } // end init dialog + } // ------------------------------------------------------------------------ case WM_COMMAND: @@ -179,11 +179,11 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, TheImagePacker->setTargetPreviewPage( page ); UpdatePreviewWindow(); - } // end if + } break; - } // end previous + } // -------------------------------------------------------------------- case BUTTON_NEXT: @@ -197,11 +197,11 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, TheImagePacker->setTargetPreviewPage( page ); UpdatePreviewWindow(); - } // end if + } break; - } // end next + } // -------------------------------------------------------------------- case CHECK_BITMAP_PREVIEW: @@ -218,7 +218,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, break; - } // end preview using image + } // -------------------------------------------------------------------- case CHECK_GAP_GUTTER: @@ -233,7 +233,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, break; - } // end transparent gutter + } // -------------------------------------------------------------------- case BUTTON_PREVIEW: @@ -248,7 +248,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, TheImagePacker->setPreviewWindow( NULL ); SetDlgItemText( hWndDialog, BUTTON_PREVIEW, "Open Preview" ); - } // end if + } else { HWND preview = MakePreviewDisplay(); @@ -260,13 +260,13 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, UpdatePreviewWindow(); SetDlgItemText( hWndDialog, BUTTON_PREVIEW, "Close Preview" ); - } // end if + } - } // end else + } break; - } // end test + } // -------------------------------------------------------------------- case BUTTON_ADD_FOLDER: @@ -279,7 +279,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, (DLGPROC)DirectorySelectProc ); break; - } // end add folder + } // -------------------------------------------------------------------- case BUTTON_REMOVE_FOLDER: @@ -289,7 +289,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, // get the directory listbox folderList = GetDlgItem( hWndDialog, LIST_FOLDERS ); if( folderList == NULL ) - break;; + break; // get the selected item in the folder listbox Int selCount; @@ -301,7 +301,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, "Select Folder First", MB_OK | MB_ICONINFORMATION ); break; - } // end if + } // // start at the end of the listbox, delete any items that @@ -314,7 +314,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, break; - } // end remove folder + } // -------------------------------------------------------------------- case RADIO_128X128: @@ -334,7 +334,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, break; - } // end target image size radio buttons + } // -------------------------------------------------------------------- case EDIT_WIDTH: @@ -358,13 +358,13 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, break; - } // end update + } - } // end switch + } break; - } // end user defined width + } // -------------------------------------------------------------------- case BUTTON_START: @@ -380,7 +380,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, break; - } // end execute + } // -------------------------------------------------------------------- case BUTTON_EXIT: @@ -390,18 +390,18 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, EndDialog( hWndDialog, TRUE ); break; - } // end exit + } - } // end switch + } return 0; - } // end command + } - } // end switch + } return 0; -} // end ImagePackerProc +} diff --git a/Core/Tools/ImagePacker/Source/WindowProcedures/PageErrorProc.cpp b/Core/Tools/ImagePacker/Source/WindowProcedures/PageErrorProc.cpp index f01b886dfa..e96cd278ec 100644 --- a/Core/Tools/ImagePacker/Source/WindowProcedures/PageErrorProc.cpp +++ b/Core/Tools/ImagePacker/Source/WindowProcedures/PageErrorProc.cpp @@ -41,7 +41,7 @@ // SYSTEM INCLUDES //////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// #include -#include +#include // USER INCLUDES ////////////////////////////////////////////////////////////// #include "ImagePacker.h" @@ -118,16 +118,16 @@ BOOL CALLBACK PageErrorProc( HWND hWndDialog, UINT message, SendMessage( list, LB_INSERTSTRING, -1, (LPARAM)buffer ); - } // end if + } - } // end for i + } // set the extents for the horizontal scroll bar in the listbox SendMessage( list, LB_SETHORIZONTALEXTENT, 1280, 0 ); return TRUE; - } // end init + } // ------------------------------------------------------------------------ case WM_COMMAND: @@ -146,18 +146,18 @@ BOOL CALLBACK PageErrorProc( HWND hWndDialog, UINT message, EndDialog( hWndDialog, TRUE ); break; - } // end proceed + } - } // end switch + } break; - } // end command + } - } // end switch message + } return 0; -} // end PageErrorProc +} diff --git a/Core/Tools/ImagePacker/Source/WindowProcedures/PreviewProc.cpp b/Core/Tools/ImagePacker/Source/WindowProcedures/PreviewProc.cpp index 804af6c0fc..24729b0f5e 100644 --- a/Core/Tools/ImagePacker/Source/WindowProcedures/PreviewProc.cpp +++ b/Core/Tools/ImagePacker/Source/WindowProcedures/PreviewProc.cpp @@ -39,7 +39,7 @@ // SYSTEM INCLUDES //////////////////////////////////////////////////////////// #include -#include +#include // USER INCLUDES ////////////////////////////////////////////////////////////// #include "ImagePacker.h" @@ -127,11 +127,11 @@ LRESULT CALLBACK PreviewProc( HWND hWnd, UINT message, // delete the created pen DeleteObject( pen ); - } // end for x + } - } // end for y + } - } // end if + } else { @@ -149,22 +149,22 @@ LRESULT CALLBACK PreviewProc( HWND hWnd, UINT message, rect.bottom = image->m_pagePos.hi.y + 1; // FillRect not inclusive FillRect( hdc, &rect, whiteBrush ); - } // end for image + } - } // end else + } - } // end for page + } EndPaint( hWnd, &ps ); break; - } // end paint + } - } // end switch + } return DefWindowProc( hWnd, message, wParam, lParam ); -} // end PreviewProc +} // MakePreviewDisplay ========================================================= /** */ @@ -213,7 +213,7 @@ HWND MakePreviewDisplay( void ) return hWnd; -} // end MakePreviewDisplay +} // UpdatePreviewWindow ======================================================== /** Update the preview window, if present */ @@ -264,4 +264,4 @@ void UpdatePreviewWindow( void ) // invalidate the client area for redraw InvalidateRect( preview, NULL, TRUE ); -} // end UpdatePreviewWindow +} diff --git a/Core/Tools/Launcher/BFISH.CPP b/Core/Tools/Launcher/BFISH.cpp similarity index 99% rename from Core/Tools/Launcher/BFISH.CPP rename to Core/Tools/Launcher/BFISH.cpp index 57d6fac377..a1cea42277 100644 --- a/Core/Tools/Launcher/BFISH.CPP +++ b/Core/Tools/Launcher/BFISH.cpp @@ -41,7 +41,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #pragma warning(disable : 4514) -#include "BFISH.H" +#include "BFISH.h" #include #include diff --git a/Core/Tools/Launcher/BFISH.H b/Core/Tools/Launcher/BFISH.h similarity index 99% rename from Core/Tools/Launcher/BFISH.H rename to Core/Tools/Launcher/BFISH.h index 5d206620d0..5290954ee7 100644 --- a/Core/Tools/Launcher/BFISH.H +++ b/Core/Tools/Launcher/BFISH.h @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef BFISH_H -#define BFISH_H +#pragma once #include @@ -100,6 +99,3 @@ class BlowfishEngine { */ unsigned long bf_S[4][UCHAR_MAX+1]; }; - -#endif - diff --git a/Core/Tools/Launcher/CMakeLists.txt b/Core/Tools/Launcher/CMakeLists.txt index 62670cbc22..09b938a60e 100644 --- a/Core/Tools/Launcher/CMakeLists.txt +++ b/Core/Tools/Launcher/CMakeLists.txt @@ -1,8 +1,8 @@ add_subdirectory(DatGen) set(LAUNCHER_SRC - "BFISH.CPP" - "BFISH.H" + "BFISH.cpp" + "BFISH.h" "configfile.cpp" "configfile.h" "dialog.cpp" diff --git a/Core/Tools/Launcher/DatGen/CMakeLists.txt b/Core/Tools/Launcher/DatGen/CMakeLists.txt index 5ebfe95aaa..4d38fbcfaf 100644 --- a/Core/Tools/Launcher/DatGen/CMakeLists.txt +++ b/Core/Tools/Launcher/DatGen/CMakeLists.txt @@ -1,7 +1,7 @@ set(DATGEN_SRC "DatGen.cpp" - "../BFISH.CPP" - "../BFISH.H" + "../BFISH.cpp" + "../BFISH.h" "../Toolkit/Debug/DebugPrint.cpp" "../Toolkit/Debug/DebugPrint.h" ) diff --git a/Core/Tools/Launcher/DatGen/DatGen.cpp b/Core/Tools/Launcher/DatGen/DatGen.cpp index e70bef7770..f584e9468c 100644 --- a/Core/Tools/Launcher/DatGen/DatGen.cpp +++ b/Core/Tools/Launcher/DatGen/DatGen.cpp @@ -23,7 +23,7 @@ #include #include #include -#include "BFISH.H" +#include "BFISH.h" #include void __cdecl doIt(void); diff --git a/Core/Tools/Launcher/Toolkit/Debug/DebugPrint.h b/Core/Tools/Launcher/Toolkit/Debug/DebugPrint.h index dd1f4723bf..976219ce74 100644 --- a/Core/Tools/Launcher/Toolkit/Debug/DebugPrint.h +++ b/Core/Tools/Launcher/Toolkit/Debug/DebugPrint.h @@ -34,8 +34,7 @@ * ******************************************************************************/ -#ifndef _DEBUGPRINT_H_ -#define _DEBUGPRINT_H_ +#pragma once #ifdef RTS_DEBUG @@ -61,5 +60,3 @@ extern char debugLogName[]; #define PrintWin32Error #endif // RTS_DEBUG - -#endif // _DEBUGPRINT_H_ diff --git a/Core/Tools/Launcher/Toolkit/Storage/File.h b/Core/Tools/Launcher/Toolkit/Storage/File.h index 6c629ffcb0..245c93f5a0 100644 --- a/Core/Tools/Launcher/Toolkit/Storage/File.h +++ b/Core/Tools/Launcher/Toolkit/Storage/File.h @@ -34,8 +34,7 @@ * ****************************************************************************/ -#ifndef FILE_H -#define FILE_H +#pragma once #include #include "Stream.h" @@ -149,5 +148,3 @@ class File : public Stream HANDLE mHandle; static const HANDLE INVALID_HANDLE; }; - -#endif // FILE_H diff --git a/Core/Tools/Launcher/Toolkit/Storage/Rights.h b/Core/Tools/Launcher/Toolkit/Storage/Rights.h index 6be60c6aa0..5414573fd8 100644 --- a/Core/Tools/Launcher/Toolkit/Storage/Rights.h +++ b/Core/Tools/Launcher/Toolkit/Storage/Rights.h @@ -34,8 +34,7 @@ * ****************************************************************************/ -#ifndef RIGHTS_H -#define RIGHTS_H +#pragma once // Access rights typedef enum @@ -44,5 +43,3 @@ typedef enum Rights_WriteOnly, Rights_ReadWrite, } ERights; - -#endif // RIGHTS_H diff --git a/Core/Tools/Launcher/Toolkit/Storage/Stream.h b/Core/Tools/Launcher/Toolkit/Storage/Stream.h index 8fc7b24f17..1803bd64d8 100644 --- a/Core/Tools/Launcher/Toolkit/Storage/Stream.h +++ b/Core/Tools/Launcher/Toolkit/Storage/Stream.h @@ -34,8 +34,7 @@ * ****************************************************************************/ -#ifndef STREAM_H -#define STREAM_H +#pragma once #include @@ -77,5 +76,3 @@ class Stream //! Flush the stream virtual void Flush(void) = 0; }; - -#endif // STREAM_H diff --git a/Core/Tools/Launcher/Toolkit/Support/RefCounted.h b/Core/Tools/Launcher/Toolkit/Support/RefCounted.h index b04986fa9b..314c71003d 100644 --- a/Core/Tools/Launcher/Toolkit/Support/RefCounted.h +++ b/Core/Tools/Launcher/Toolkit/Support/RefCounted.h @@ -37,8 +37,7 @@ * ******************************************************************************/ -#ifndef REFCOUNTED_H -#define REFCOUNTED_H +#pragma once #include @@ -82,5 +81,3 @@ class RefCounted unsigned int mRefCount; }; - -#endif // REFCOUNTED_H diff --git a/Core/Tools/Launcher/Toolkit/Support/RefPtr.h b/Core/Tools/Launcher/Toolkit/Support/RefPtr.h index a82bab8867..0e4e5c255d 100644 --- a/Core/Tools/Launcher/Toolkit/Support/RefPtr.h +++ b/Core/Tools/Launcher/Toolkit/Support/RefPtr.h @@ -65,8 +65,7 @@ * ******************************************************************************/ -#ifndef REFPTR_H -#define REFPTR_H +#pragma once #include "Visualc.h" #include "RefCounted.h" @@ -357,5 +356,3 @@ RefPtr Const_Cast(RefPtrConst& rhs) object.Attach(rhs.ReferencedObject()); return object; } - -#endif // RC_PTR_H diff --git a/Core/Tools/Launcher/Toolkit/Support/StringConvert.h b/Core/Tools/Launcher/Toolkit/Support/StringConvert.h index 5eb3ab587c..c7a1515f33 100644 --- a/Core/Tools/Launcher/Toolkit/Support/StringConvert.h +++ b/Core/Tools/Launcher/Toolkit/Support/StringConvert.h @@ -34,8 +34,7 @@ * ******************************************************************************/ -#ifndef STRINGCONVERT_H -#define STRINGCONVERT_H +#pragma once #include "UTypes.h" @@ -43,5 +42,3 @@ class UString; Char* UStringToANSI(const UString& string, Char* buffer, UInt bufferLength); Char* UnicodeToANSI(const WChar* string, Char* buffer, UInt bufferLength); - -#endif // STRINGCONVERT_H diff --git a/Core/Tools/Launcher/Toolkit/Support/UString.cpp b/Core/Tools/Launcher/Toolkit/Support/UString.cpp index c8c09a0b7e..12ccb8237f 100644 --- a/Core/Tools/Launcher/Toolkit/Support/UString.cpp +++ b/Core/Tools/Launcher/Toolkit/Support/UString.cpp @@ -266,10 +266,7 @@ UString::UString(const UString& s) UString::~UString() { - if (mData != NULL) - { - delete mData; - } + delete mData; } @@ -1323,11 +1320,7 @@ bool UString::AllocString(UInt size) data[0] = 0; - if (mData != NULL) - { - delete mData; - } - + delete mData; mData = data; mCapacity = size; diff --git a/Core/Tools/Launcher/Toolkit/Support/UString.h b/Core/Tools/Launcher/Toolkit/Support/UString.h index 6168d87305..a9b23e20f8 100644 --- a/Core/Tools/Launcher/Toolkit/Support/UString.h +++ b/Core/Tools/Launcher/Toolkit/Support/UString.h @@ -34,8 +34,7 @@ * ******************************************************************************/ -#ifndef USTRING_H -#define USTRING_H +#pragma once #include "UTypes.h" #include "RefCounted.h" @@ -235,5 +234,3 @@ class UString WChar* mData; UInt mCapacity; }; - -#endif // USTRING_H diff --git a/Core/Tools/Launcher/Toolkit/Support/UTypes.h b/Core/Tools/Launcher/Toolkit/Support/UTypes.h index d5219a5096..77e5eaa8ba 100644 --- a/Core/Tools/Launcher/Toolkit/Support/UTypes.h +++ b/Core/Tools/Launcher/Toolkit/Support/UTypes.h @@ -34,8 +34,7 @@ * ******************************************************************************/ -#ifndef UTYPES_H -#define UTYPES_H +#pragma once //! Signed integer value typedef int Int; @@ -90,5 +89,3 @@ typedef enum {OFF = false, ON = true, PENDING = -1} TriState; #ifndef NULL #define NULL (0L) #endif - -#endif // UTYPES_H diff --git a/Core/Tools/Launcher/Toolkit/Support/Visualc.h b/Core/Tools/Launcher/Toolkit/Support/Visualc.h index f18fe1613e..e8bd635539 100644 --- a/Core/Tools/Launcher/Toolkit/Support/Visualc.h +++ b/Core/Tools/Launcher/Toolkit/Support/Visualc.h @@ -33,10 +33,8 @@ * $Revision: $ * ******************************************************************************/ -#pragma once -#ifndef _VISUALC_H_ -#define _VISUALC_H_ +#pragma once #if defined(_MSC_VER) @@ -87,4 +85,3 @@ #pragma warning(disable:4786) #endif // _MSC_VER -#endif // _VISUALC_H_ diff --git a/Core/Tools/Launcher/configfile.h b/Core/Tools/Launcher/configfile.h index c99d4897fb..19354c6009 100644 --- a/Core/Tools/Launcher/configfile.h +++ b/Core/Tools/Launcher/configfile.h @@ -26,8 +26,7 @@ Start Date : June 9, 1997 Last Update : June 17, 1997 \***************************************************************************/ -#ifndef CONFIGFILE_HEADER -#define CONFIGFILE_HEADER +#pragma once #include "dictionary.h" #include "wstring.h" @@ -51,5 +50,3 @@ class ConfigFile Dictionary dictionary; // stores the mappings from keys // to value strings }; - -#endif diff --git a/Core/Tools/Launcher/dialog.h b/Core/Tools/Launcher/dialog.h index c293e315bf..101db772c8 100644 --- a/Core/Tools/Launcher/dialog.h +++ b/Core/Tools/Launcher/dialog.h @@ -16,13 +16,10 @@ ** along with this program. If not, see . */ -#ifndef DIALOG_HEADER -#define DIALOG_HEADER +#pragma once #include"winblows.h" #include HWND Create_Patch_Dialog(void); extern HWND PatchDialog; - -#endif diff --git a/Core/Tools/Launcher/dictionary.h b/Core/Tools/Launcher/dictionary.h index 01a0386a01..640190a5b5 100644 --- a/Core/Tools/Launcher/dictionary.h +++ b/Core/Tools/Launcher/dictionary.h @@ -35,8 +35,7 @@ is working well, this is much faster than a linked list, but only if your hashing function is good. \****************************************************************************/ -#ifndef DICTIONARY_HEADER -#define DICTIONARY_HEADER +#pragma once #include #include @@ -582,5 +581,3 @@ void Dictionary::expand(void) } delete[](oldtable); } - -#endif diff --git a/Core/Tools/Launcher/filed.h b/Core/Tools/Launcher/filed.h index cbbacf79a9..f490b05d1c 100644 --- a/Core/Tools/Launcher/filed.h +++ b/Core/Tools/Launcher/filed.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef FILED_HEADER -#define FILED_HEADER +#pragma once #include "odevice.h" @@ -52,5 +51,3 @@ class FileD : public OutputDevice FILE *out; bool m_outputDebug; }; - -#endif diff --git a/Core/Tools/Launcher/findpatch.cpp b/Core/Tools/Launcher/findpatch.cpp index f1556c2fb6..01715600af 100644 --- a/Core/Tools/Launcher/findpatch.cpp +++ b/Core/Tools/Launcher/findpatch.cpp @@ -206,8 +206,8 @@ void Delete_Patches(ConfigFile &config) DBGMSG("UNLINK: "<. */ -#ifndef FINDPATCH_HEADER -#define FINDPATCH_HEADER +#pragma once #include #include @@ -29,5 +28,3 @@ int Find_Patch(OUT char *file,int maxlen, ConfigFile &config); bit8 Get_App_Dir(OUT char *file,int maxlen, ConfigFile &config, int index); void Delete_Patches(ConfigFile &config); - -#endif diff --git a/Core/Tools/Launcher/loadbmp.h b/Core/Tools/Launcher/loadbmp.h index df825349f1..e2614fbe6c 100644 --- a/Core/Tools/Launcher/loadbmp.h +++ b/Core/Tools/Launcher/loadbmp.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef LOADBMP_HEADER -#define LOADBMP_HEADER +#pragma once #include #include @@ -41,6 +40,3 @@ class LoadBmp HPALETTE PalHandle_; HWND WindowHandle_; }; - - -#endif diff --git a/Core/Tools/Launcher/monod.h b/Core/Tools/Launcher/monod.h index 494674c974..4f94fd065e 100644 --- a/Core/Tools/Launcher/monod.h +++ b/Core/Tools/Launcher/monod.h @@ -16,9 +16,7 @@ ** along with this program. If not, see . */ -#ifndef MONOD_HEADER -#define MONOD_HEADER - +#pragma once #include #include @@ -70,5 +68,3 @@ class MonoD : public OutputDevice HANDLE handle; #endif }; - -#endif diff --git a/Core/Tools/Launcher/odevice.h b/Core/Tools/Launcher/odevice.h index ccd45e01a8..8cb924ea42 100644 --- a/Core/Tools/Launcher/odevice.h +++ b/Core/Tools/Launcher/odevice.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef ODEVICE_HEADER -#define ODEVICE_HEADER +#pragma once // This virtual base class provides an interface for output devices // that can be used for the debugging package. @@ -28,5 +27,3 @@ class OutputDevice virtual ~OutputDevice() {}; virtual int print(const char *s,int len)=0; }; - -#endif diff --git a/Core/Tools/Launcher/patch.h b/Core/Tools/Launcher/patch.h index fcb6db3745..b724c59ff9 100644 --- a/Core/Tools/Launcher/patch.h +++ b/Core/Tools/Launcher/patch.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef PATCH_HEADER -#define PATCH_HEADER +#pragma once #include "winblows.h" #include "dialog.h" @@ -26,5 +25,3 @@ #include "process.h" void Apply_Patch(char *patchfile,ConfigFile &config,int skuIndex); - -#endif diff --git a/Core/Tools/Launcher/process.h b/Core/Tools/Launcher/process.h index b123b37399..d3f2625bee 100644 --- a/Core/Tools/Launcher/process.h +++ b/Core/Tools/Launcher/process.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef PROCESS_HEADER -#define PROCESS_HEADER +#pragma once #include #include "wstypes.h" @@ -41,6 +40,3 @@ class Process bit8 Read_Process_Info(ConfigFile &config,OUT Process &info, IN const char *key = NULL); bit8 Create_Process(Process &process); bit8 Wait_Process(Process &process, DWORD *exit_code=NULL); - - -#endif diff --git a/Core/Tools/Launcher/streamer.cpp b/Core/Tools/Launcher/streamer.cpp index 24a316123c..061baad77d 100644 --- a/Core/Tools/Launcher/streamer.cpp +++ b/Core/Tools/Launcher/streamer.cpp @@ -43,8 +43,8 @@ Streamer::~Streamer() ///////// calling sync seems to cause crashes here on Win32 //sync(); ///////// - if (Buf) - delete[] Buf; + + delete[] Buf; } int Streamer::setOutputDevice(OutputDevice *device) diff --git a/Core/Tools/Launcher/streamer.h b/Core/Tools/Launcher/streamer.h index 41a83a30cc..ec79562070 100644 --- a/Core/Tools/Launcher/streamer.h +++ b/Core/Tools/Launcher/streamer.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef STREAMER_HEADER -#define STREAMER_HEADER +#pragma once #include #include @@ -57,5 +56,3 @@ class Streamer : public streambuf OutputDevice *Output_Device; char *Buf; }; - -#endif diff --git a/Core/Tools/Launcher/wdebug.h b/Core/Tools/Launcher/wdebug.h index 816fa743b7..72f732b648 100644 --- a/Core/Tools/Launcher/wdebug.h +++ b/Core/Tools/Launcher/wdebug.h @@ -50,8 +50,7 @@ will you be ready to leave grasshopper. \*****************************************************************************/ -#ifndef WDEBUG_HEADER -#define WDEBUG_HEADER +#pragma once #include #include "odevice.h" @@ -189,5 +188,3 @@ class MsgManager static ostream *warnStream(void); static ostream *errorStream(void); }; - -#endif diff --git a/Core/Tools/Launcher/winblows.h b/Core/Tools/Launcher/winblows.h index 3d43acc06a..9e6d14ef1f 100644 --- a/Core/Tools/Launcher/winblows.h +++ b/Core/Tools/Launcher/winblows.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef WINBLOWS_HEADER -#define WINBLOWS_HEADER +#pragma once #define WIN32_LEAN_AND_MEAN #include @@ -33,5 +32,3 @@ extern int main(int argc, char *argv[]); int Print_WM(UINT wm,char *out); - -#endif diff --git a/Core/Tools/Launcher/wstring.cpp b/Core/Tools/Launcher/wstring.cpp index 0cf92d9449..cec002a6b6 100644 --- a/Core/Tools/Launcher/wstring.cpp +++ b/Core/Tools/Launcher/wstring.cpp @@ -151,9 +151,7 @@ bit8 Wstring::cat(const char *s) strcat(str, s); - // delete the old string. - if(oldStr) - delete[](oldStr); + delete[](oldStr); return(TRUE); } @@ -188,9 +186,7 @@ bit8 Wstring::cat(uint32 size, const char *s) strncat(str, s, size); - // delete the old string. - if(oldStr) - delete[](oldStr); + delete[](oldStr); return(TRUE); } @@ -309,8 +305,7 @@ void Wstring::removeSpaces(void) void Wstring::clear(void) { - if(str) - delete[](str); + delete[](str); str=NULL; } diff --git a/Core/Tools/Launcher/wstring.h b/Core/Tools/Launcher/wstring.h index 94ddf203e0..00f39c2ffc 100644 --- a/Core/Tools/Launcher/wstring.h +++ b/Core/Tools/Launcher/wstring.h @@ -26,8 +26,7 @@ Start Date : June 1, 1997 Last Update : June 17, 1997 \****************************************************************************/ -#ifndef WSTRING_HEADER -#define WSTRING_HEADER +#pragma once #include #include @@ -83,5 +82,3 @@ class Wstring private: char *str; // Pointer to allocated string. }; - -#endif diff --git a/Core/Tools/Launcher/wstypes.h b/Core/Tools/Launcher/wstypes.h index 7bc8c565ca..d521a5872a 100644 --- a/Core/Tools/Launcher/wstypes.h +++ b/Core/Tools/Launcher/wstypes.h @@ -28,8 +28,7 @@ Last Update : June 17, 1997 Standard type definitions for the sake of portability and readability. \***************************************************************************/ -#ifndef WTYPES_HEADER -#define WTYPES_HEADER +#pragma once #ifndef TRUE #define TRUE 1 @@ -78,5 +77,3 @@ typedef unsigned int uint32; #define strncasecmp _strnicmp #define strcasecmp _stricmp #endif - -#endif diff --git a/Core/Tools/MapCacheBuilder/CMakeLists.txt b/Core/Tools/MapCacheBuilder/CMakeLists.txt index 5d390853a8..bdb38951a5 100644 --- a/Core/Tools/MapCacheBuilder/CMakeLists.txt +++ b/Core/Tools/MapCacheBuilder/CMakeLists.txt @@ -17,7 +17,6 @@ target_link_libraries(corei_mapcachebuilder INTERFACE comctl32 core_debug core_profile - dbghelplib imm32 vfw32 winmm diff --git a/Core/Tools/MapCacheBuilder/Include/WinMain.h b/Core/Tools/MapCacheBuilder/Include/WinMain.h index dc2cffc033..c5ebe3b4af 100644 --- a/Core/Tools/MapCacheBuilder/Include/WinMain.h +++ b/Core/Tools/MapCacheBuilder/Include/WinMain.h @@ -39,9 +39,6 @@ #pragma once -#ifndef __WINMAIN_H_ -#define __WINMAIN_H_ - // SYSTEM INCLUDES //////////////////////////////////////////////////////////// #include @@ -57,6 +54,3 @@ // EXTERNALS ////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// extern HINSTANCE ApplicationHInstance; - -#endif // __WINMAIN_H_ - diff --git a/Core/Tools/MapCacheBuilder/Source/WinMain.cpp b/Core/Tools/MapCacheBuilder/Source/WinMain.cpp index b052612a94..9a2d0adca3 100644 --- a/Core/Tools/MapCacheBuilder/Source/WinMain.cpp +++ b/Core/Tools/MapCacheBuilder/Source/WinMain.cpp @@ -40,7 +40,6 @@ // SYSTEM INCLUDES //////////////////////////////////////////////////////////// #include #include -#include // USER INCLUDES ////////////////////////////////////////////////////////////// #include "Lib/BaseType.h" @@ -116,10 +115,10 @@ static SubsystemInterfaceList _TheSubsystemList; template -void initSubsystem(SUBSYSTEM*& sysref, SUBSYSTEM* sys, const char* path1 = NULL, const char* path2 = NULL, const char* dirpath = NULL) +void initSubsystem(SUBSYSTEM*& sysref, SUBSYSTEM* sys, const char* path1 = NULL, const char* path2 = NULL) { sysref = sys; - _TheSubsystemList.initSubsystem(sys, path1, path2, dirpath, NULL); + _TheSubsystemList.initSubsystem(sys, path1, path2, NULL); } /////////////////////////////////////////////////////////////////////////////// @@ -225,13 +224,8 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, // Set the current directory to the app directory. char buf[_MAX_PATH]; GetModuleFileName(NULL, buf, sizeof(buf)); - char *pEnd = buf + strlen(buf); - while (pEnd != buf) { - if (*pEnd == '\\') { - *pEnd = 0; - break; - } - pEnd--; + if (char *pEnd = strrchr(buf, '\\')) { + *pEnd = 0; } ::SetCurrentDirectory(buf); @@ -257,31 +251,31 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, initSubsystem(TheLocalFileSystem, (LocalFileSystem*)new Win32LocalFileSystem); initSubsystem(TheArchiveFileSystem, (ArchiveFileSystem*)new Win32BIGFileSystem); INI ini; - initSubsystem(TheWritableGlobalData, new GlobalData(), "Data\\INI\\Default\\GameData.ini", "Data\\INI\\GameData.ini"); + initSubsystem(TheWritableGlobalData, new GlobalData(), "Data\\INI\\Default\\GameData", "Data\\INI\\GameData"); initSubsystem(TheGameText, CreateGameTextInterface()); - initSubsystem(TheScienceStore, new ScienceStore(), "Data\\INI\\Default\\Science.ini", "Data\\INI\\Science.ini"); - initSubsystem(TheMultiplayerSettings, new MultiplayerSettings(), "Data\\INI\\Default\\Multiplayer.ini", "Data\\INI\\Multiplayer.ini"); - initSubsystem(TheTerrainTypes, new TerrainTypeCollection(), "Data\\INI\\Default\\Terrain.ini", "Data\\INI\\Terrain.ini"); - initSubsystem(TheTerrainRoads, new TerrainRoadCollection(), "Data\\INI\\Default\\Roads.ini", "Data\\INI\\Roads.ini"); + initSubsystem(TheScienceStore, new ScienceStore(), "Data\\INI\\Default\\Science", "Data\\INI\\Science"); + initSubsystem(TheMultiplayerSettings, new MultiplayerSettings(), "Data\\INI\\Default\\Multiplayer", "Data\\INI\\Multiplayer"); + initSubsystem(TheTerrainTypes, new TerrainTypeCollection(), "Data\\INI\\Default\\Terrain", "Data\\INI\\Terrain"); + initSubsystem(TheTerrainRoads, new TerrainRoadCollection(), "Data\\INI\\Default\\Roads", "Data\\INI\\Roads"); initSubsystem(TheScriptEngine, (ScriptEngine*)(new ScriptEngine())); initSubsystem(TheAudio, (AudioManager*)new MilesAudioManager()); initSubsystem(TheVideoPlayer, (VideoPlayerInterface*)(new VideoPlayer())); initSubsystem(TheModuleFactory, (ModuleFactory*)(new W3DModuleFactory())); initSubsystem(TheSidesList, new SidesList()); initSubsystem(TheCaveSystem, new CaveSystem()); - initSubsystem(TheRankInfoStore, new RankInfoStore(), NULL, "Data\\INI\\Rank.ini"); - initSubsystem(ThePlayerTemplateStore, new PlayerTemplateStore(), "Data\\INI\\Default\\PlayerTemplate.ini", "Data\\INI\\PlayerTemplate.ini"); - initSubsystem(TheSpecialPowerStore, new SpecialPowerStore(), "Data\\INI\\Default\\SpecialPower.ini", "Data\\INI\\SpecialPower.ini" ); + initSubsystem(TheRankInfoStore, new RankInfoStore(), NULL, "Data\\INI\\Rank"); + initSubsystem(ThePlayerTemplateStore, new PlayerTemplateStore(), "Data\\INI\\Default\\PlayerTemplate", "Data\\INI\\PlayerTemplate"); + initSubsystem(TheSpecialPowerStore, new SpecialPowerStore(), "Data\\INI\\Default\\SpecialPower", "Data\\INI\\SpecialPower" ); initSubsystem(TheParticleSystemManager, (ParticleSystemManager*)(new W3DParticleSystemManager())); - initSubsystem(TheFXListStore, new FXListStore(), "Data\\INI\\Default\\FXList.ini", "Data\\INI\\FXList.ini"); - initSubsystem(TheWeaponStore, new WeaponStore(), NULL, "Data\\INI\\Weapon.ini"); - initSubsystem(TheObjectCreationListStore, new ObjectCreationListStore(), "Data\\INI\\Default\\ObjectCreationList.ini", "Data\\INI\\ObjectCreationList.ini"); - initSubsystem(TheLocomotorStore, new LocomotorStore(), NULL, "Data\\INI\\Locomotor.ini"); - initSubsystem(TheDamageFXStore, new DamageFXStore(), NULL, "Data\\INI\\DamageFX.ini"); - initSubsystem(TheArmorStore, new ArmorStore(), NULL, "Data\\INI\\Armor.ini"); - initSubsystem(TheThingFactory, new ThingFactory(), "Data\\INI\\Default\\Object.ini", NULL, "Data\\INI\\Object"); - initSubsystem(TheCrateSystem, new CrateSystem(), "Data\\INI\\Default\\Crate.ini", "Data\\INI\\Crate.ini"); - initSubsystem(TheUpgradeCenter, new UpgradeCenter, "Data\\INI\\Default\\Upgrade.ini", "Data\\INI\\Upgrade.ini"); + initSubsystem(TheFXListStore, new FXListStore(), "Data\\INI\\Default\\FXList", "Data\\INI\\FXList"); + initSubsystem(TheWeaponStore, new WeaponStore(), NULL, "Data\\INI\\Weapon"); + initSubsystem(TheObjectCreationListStore, new ObjectCreationListStore(), "Data\\INI\\Default\\ObjectCreationList", "Data\\INI\\ObjectCreationList"); + initSubsystem(TheLocomotorStore, new LocomotorStore(), NULL, "Data\\INI\\Locomotor"); + initSubsystem(TheDamageFXStore, new DamageFXStore(), NULL, "Data\\INI\\DamageFX"); + initSubsystem(TheArmorStore, new ArmorStore(), NULL, "Data\\INI\\Armor"); + initSubsystem(TheThingFactory, new ThingFactory(), "Data\\INI\\Default\\Object", "Data\\INI\\Object"); + initSubsystem(TheCrateSystem, new CrateSystem(), "Data\\INI\\Default\\Crate", "Data\\INI\\Crate"); + initSubsystem(TheUpgradeCenter, new UpgradeCenter, "Data\\INI\\Default\\Upgrade", "Data\\INI\\Upgrade"); initSubsystem(TheAnim2DCollection, new Anim2DCollection ); //Init's itself. _TheSubsystemList.postProcessLoadAll(); @@ -329,4 +323,4 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, // all done return 0; -} // end WinMain +} diff --git a/Core/Tools/PATCHGET/CHATAPI.CPP b/Core/Tools/PATCHGET/CHATAPI.cpp similarity index 99% rename from Core/Tools/PATCHGET/CHATAPI.CPP rename to Core/Tools/PATCHGET/CHATAPI.cpp index 07cb28a9fb..bba0c3902d 100644 --- a/Core/Tools/PATCHGET/CHATAPI.CPP +++ b/Core/Tools/PATCHGET/CHATAPI.cpp @@ -24,7 +24,7 @@ #include "gamespy/ghttp/ghttp.h" #include "DownloadManager.h" -#include "CHATAPI.H" +#include "CHATAPI.h" //#include "api/wolapi_i.c" // This should only be in one .cpp file #include @@ -34,8 +34,8 @@ #if defined(_MSC_VER) && _MSC_VER < 1300 #include #endif -#include "RESOURCE.H" -#include "WINBLOWS.H" +#include "RESOURCE.h" +#include "WINBLOWS.h" #include #include "process.h" #include "WWDownload/Registry.h" @@ -49,7 +49,8 @@ enum EVENT_TYPES { NOUPDATE_EVENT=0, // don't need to update ABORT_EVENT, - NUM_EVENTS // keep last + + NUM_EVENTS }; #if RTS_GENERALS @@ -358,7 +359,7 @@ static void queuePatch(bool mandatory, std::string downloadURL) std::string fileStr = filePath; unsigned int slashPos = filePath.find_last_of('/'); std::string fileDir = "patches\\"; - std::string fileName = ""; + std::string fileName; if (slashPos == filePath.npos) { fileName = filePath; @@ -815,7 +816,7 @@ char const * Fetch_String(int id) /* ** Determine if the string ID requested is valid. If not then return an empty string pointer. */ - if (id == -1 || id == TXT_NONE) return(""); + if (id == -1 || id == TXT_NONE) return ""; /* ** Adjust the 'time stamp' tracking value. This is an artificial value used merely to track @@ -858,7 +859,7 @@ char const * Fetch_String(int id) if (LoadString(Global_instance, id, stringptr, sizeof(_buffers[oldest].String)) == 0) { - return(""); + return ""; } /****** diff --git a/Core/Tools/PATCHGET/CHATAPI.H b/Core/Tools/PATCHGET/CHATAPI.h similarity index 94% rename from Core/Tools/PATCHGET/CHATAPI.H rename to Core/Tools/PATCHGET/CHATAPI.h index bcb549fe6c..7bc95bcc80 100644 --- a/Core/Tools/PATCHGET/CHATAPI.H +++ b/Core/Tools/PATCHGET/CHATAPI.h @@ -16,10 +16,9 @@ ** along with this program. If not, see . */ -#ifndef CHATAPI_HEADER -#define CHATAPI_HEADER +#pragma once -#include "COMINIT.H" +#include "COMINIT.h" #include #include #include @@ -46,5 +45,3 @@ void Update_If_Required(void); char const * Fetch_String(int id); } // namespace patchget - -#endif diff --git a/Core/Tools/PATCHGET/CMakeLists.txt b/Core/Tools/PATCHGET/CMakeLists.txt index 265a74c785..bd271598c5 100644 --- a/Core/Tools/PATCHGET/CMakeLists.txt +++ b/Core/Tools/PATCHGET/CMakeLists.txt @@ -1,20 +1,20 @@ set(PATCHGET_SRC - "CHATAPI.CPP" - "CHATAPI.H" - "COMINIT.CPP" - "COMINIT.H" + "CHATAPI.cpp" + "CHATAPI.h" + "COMINIT.cpp" + "COMINIT.h" "debug.cpp" "debug.h" "DownloadManager.cpp" "DownloadManager.h" - "PROCESS.CPP" - "PROCESS.H" + "PROCESS.cpp" + "PROCESS.h" "registry.cpp" "Registry.h" - "RESOURCE.H" - "WINBLOWS.CPP" - "WINBLOWS.H" - "WSTYPES.H" + "RESOURCE.h" + "WINBLOWS.cpp" + "WINBLOWS.h" + "WSTYPES.h" ) add_library(corei_patchgrabber INTERFACE) @@ -25,7 +25,6 @@ target_link_libraries(corei_patchgrabber INTERFACE comctl32 core_debug core_profile - dbghelplib gamespy::gamespy imm32 vfw32 diff --git a/Core/Tools/PATCHGET/COMINIT.CPP b/Core/Tools/PATCHGET/COMINIT.cpp similarity index 98% rename from Core/Tools/PATCHGET/COMINIT.CPP rename to Core/Tools/PATCHGET/COMINIT.cpp index 37e5c26be8..73efff26d9 100644 --- a/Core/Tools/PATCHGET/COMINIT.CPP +++ b/Core/Tools/PATCHGET/COMINIT.cpp @@ -19,7 +19,7 @@ // // If you link with this it will automatically call the COM initialization stuff // -#include "COMINIT.H" +#include "COMINIT.h" #include #include #include diff --git a/Core/Tools/PATCHGET/COMINIT.H b/Core/Tools/PATCHGET/COMINIT.h similarity index 94% rename from Core/Tools/PATCHGET/COMINIT.H rename to Core/Tools/PATCHGET/COMINIT.h index 2836f791c3..c35f69a2de 100644 --- a/Core/Tools/PATCHGET/COMINIT.H +++ b/Core/Tools/PATCHGET/COMINIT.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef COMINIT_HEADER -#define COMINIT_HEADER +#pragma once namespace patchget { @@ -35,5 +34,3 @@ class ComInit }; } // namespace patchget - -#endif diff --git a/Core/Tools/PATCHGET/DownloadManager.cpp b/Core/Tools/PATCHGET/DownloadManager.cpp index fd5112385f..c22268b622 100644 --- a/Core/Tools/PATCHGET/DownloadManager.cpp +++ b/Core/Tools/PATCHGET/DownloadManager.cpp @@ -21,9 +21,9 @@ // Author: Matthew D. Campbell, July 2002 #include "debug.h" -#include "CHATAPI.H" +#include "CHATAPI.h" #include "DownloadManager.h" -#include "RESOURCE.H" +#include "RESOURCE.h" namespace patchget { diff --git a/Core/Tools/PATCHGET/DownloadManager.h b/Core/Tools/PATCHGET/DownloadManager.h index 8b4a207757..443156920c 100644 --- a/Core/Tools/PATCHGET/DownloadManager.h +++ b/Core/Tools/PATCHGET/DownloadManager.h @@ -22,9 +22,6 @@ #pragma once -#ifndef __DOWNLOADMANAGER_H__ -#define __DOWNLOADMANAGER_H__ - #include "WWDownload/downloaddefs.h" #include "WWDownload/Download.h" #include @@ -96,5 +93,3 @@ class DownloadManager : public IDownload extern DownloadManager *TheDownloadManager; } // namespace patchget - -#endif // __DOWNLOADMANAGER_H__ diff --git a/Core/Tools/PATCHGET/PROCESS.CPP b/Core/Tools/PATCHGET/PROCESS.cpp similarity index 100% rename from Core/Tools/PATCHGET/PROCESS.CPP rename to Core/Tools/PATCHGET/PROCESS.cpp diff --git a/Core/Tools/PATCHGET/PROCESS.H b/Core/Tools/PATCHGET/PROCESS.h similarity index 93% rename from Core/Tools/PATCHGET/PROCESS.H rename to Core/Tools/PATCHGET/PROCESS.h index a1c9b61d87..26ccf044c8 100644 --- a/Core/Tools/PATCHGET/PROCESS.H +++ b/Core/Tools/PATCHGET/PROCESS.h @@ -16,11 +16,10 @@ ** along with this program. If not, see . */ -#ifndef PROCESS_HEADER -#define PROCESS_HEADER +#pragma once #include -#include "WSTYPES.H" +#include "WSTYPES.h" namespace patchget { @@ -42,5 +41,3 @@ bit8 Create_Process(Process &process); bit8 Wait_Process(Process &process, DWORD *exit_code=NULL); } // namespace patchget - -#endif diff --git a/Core/Tools/PATCHGET/RESOURCE.H b/Core/Tools/PATCHGET/RESOURCE.h similarity index 100% rename from Core/Tools/PATCHGET/RESOURCE.H rename to Core/Tools/PATCHGET/RESOURCE.h diff --git a/Core/Tools/PATCHGET/Registry.h b/Core/Tools/PATCHGET/Registry.h index 3600d0fefb..644dbdcf2b 100644 --- a/Core/Tools/PATCHGET/Registry.h +++ b/Core/Tools/PATCHGET/Registry.h @@ -22,9 +22,6 @@ #pragma once -#ifndef __REGISTRY_H__ -#define __REGISTRY_H__ - #include namespace patchget @@ -51,5 +48,3 @@ bool SetStringInRegistry(std::string path, std::string key, std::string val); bool SetUnsignedIntInRegistry(std::string path, std::string key, unsigned int val); } // namespace patchget - -#endif // __REGISTRY_H__ diff --git a/Core/Tools/PATCHGET/WINBLOWS.CPP b/Core/Tools/PATCHGET/WINBLOWS.cpp similarity index 99% rename from Core/Tools/PATCHGET/WINBLOWS.CPP rename to Core/Tools/PATCHGET/WINBLOWS.cpp index 7ff9cfd6f4..0e79559180 100644 --- a/Core/Tools/PATCHGET/WINBLOWS.CPP +++ b/Core/Tools/PATCHGET/WINBLOWS.cpp @@ -23,8 +23,8 @@ #include #include -#include "WINBLOWS.H" -#include "CHATAPI.H" +#include "WINBLOWS.h" +#include "CHATAPI.h" // TheSuperHackers @fix xezon 13/03/2025 Fix debug linker errors by diff --git a/Core/Tools/PATCHGET/WINBLOWS.H b/Core/Tools/PATCHGET/WINBLOWS.h similarity index 93% rename from Core/Tools/PATCHGET/WINBLOWS.H rename to Core/Tools/PATCHGET/WINBLOWS.h index be4f13f034..9a70a828ce 100644 --- a/Core/Tools/PATCHGET/WINBLOWS.H +++ b/Core/Tools/PATCHGET/WINBLOWS.h @@ -16,15 +16,14 @@ ** along with this program. If not, see . */ -#ifndef WINBLOWS_HEADER -#define WINBLOWS_HEADER +#pragma once #define WIN32_LEAN_AND_MEAN #include #include #include -#include"WSTYPES.H" +#include"WSTYPES.h" extern HINSTANCE Global_instance; extern LPSTR Global_commandline; @@ -33,5 +32,3 @@ extern int main(int argc, char *argv[]); int Print_WM(UINT wm,char *out); - -#endif diff --git a/Core/Tools/PATCHGET/WSTYPES.H b/Core/Tools/PATCHGET/WSTYPES.h similarity index 97% rename from Core/Tools/PATCHGET/WSTYPES.H rename to Core/Tools/PATCHGET/WSTYPES.h index fc8b255ec3..df4ee9b894 100644 --- a/Core/Tools/PATCHGET/WSTYPES.H +++ b/Core/Tools/PATCHGET/WSTYPES.h @@ -28,8 +28,7 @@ Last Update : June 17, 1997 Standard type definitions for the sake of portability and readability. \***************************************************************************/ -#ifndef WTYPES_HEADER -#define WTYPES_HEADER +#pragma once #ifndef TRUE #define TRUE 1 @@ -70,5 +69,3 @@ typedef unsigned int uint32; #define strncasecmp _strnicmp #define strcasecmp _stricmp #endif - -#endif diff --git a/Core/Tools/PATCHGET/debug.h b/Core/Tools/PATCHGET/debug.h index 4a6a3a31dd..e61a99033a 100644 --- a/Core/Tools/PATCHGET/debug.h +++ b/Core/Tools/PATCHGET/debug.h @@ -20,8 +20,7 @@ // Minimal debug info // Author: Matthew D. Campbell, Sept 2002 -#ifndef __DEBUG_H__ -#define __DEBUG_H__ +#pragma once namespace patchget { @@ -71,6 +70,3 @@ void DebugLog( const char *fmt, ... ); #endif } // namespace patchget - -#endif // __DEBUG_H__ - diff --git a/Core/Tools/W3DView/AddToLineupDialog.h b/Core/Tools/W3DView/AddToLineupDialog.h index 67a7342d98..5c331479da 100644 --- a/Core/Tools/W3DView/AddToLineupDialog.h +++ b/Core/Tools/W3DView/AddToLineupDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_ADDTOLINEUPDIALOG_H__AD8B92C5_25CB_11D4_8A1D_0090272E6F90__INCLUDED_) -#define AFX_ADDTOLINEUPDIALOG_H__AD8B92C5_25CB_11D4_8A1D_0090272E6F90__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // AddToLineupDialog.h : header file // @@ -65,5 +61,3 @@ class CAddToLineupDialog : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_ADDTOLINEUPDIALOG_H__AD8B92C5_25CB_11D4_8A1D_0090272E6F90__INCLUDED_) diff --git a/Core/Tools/W3DView/AdvancedAnimSheet.cpp b/Core/Tools/W3DView/AdvancedAnimSheet.cpp index 5da4fb8e96..4c57a38b2d 100644 --- a/Core/Tools/W3DView/AdvancedAnimSheet.cpp +++ b/Core/Tools/W3DView/AdvancedAnimSheet.cpp @@ -77,7 +77,7 @@ CAdvancedAnimSheet::~CAdvancedAnimSheet() { for (int i = 0; i < AnimCount; i++) { - MEMBER_RELEASE(Anims[i]); + REF_PTR_RELEASE(Anims[i]); } AnimsValid = false; AnimCount = 0; @@ -162,7 +162,7 @@ void CAdvancedAnimSheet::LoadAnims (void) // Add this Anims pointer to the array. if (AnimCount < MAX_REPORT_ANIMS) { - MEMBER_ADD(Anims[AnimCount], pHierarchyAnim); + REF_PTR_SET(Anims[AnimCount], pHierarchyAnim); AnimCount++; } else @@ -176,7 +176,7 @@ void CAdvancedAnimSheet::LoadAnims (void) } // Release our hold on this animation. - MEMBER_RELEASE(pHierarchyAnim); + REF_PTR_RELEASE(pHierarchyAnim); } } diff --git a/Core/Tools/W3DView/AdvancedAnimSheet.h b/Core/Tools/W3DView/AdvancedAnimSheet.h index 44735a340a..691787da8d 100644 --- a/Core/Tools/W3DView/AdvancedAnimSheet.h +++ b/Core/Tools/W3DView/AdvancedAnimSheet.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_ADVANCEDANIMSHEET_H__67C01724_7C0D_11D3_9A3A_0090272E6F90__INCLUDED_) -#define AFX_ADVANCEDANIMSHEET_H__67C01724_7C0D_11D3_9A3A_0090272E6F90__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // AdvancedAnimSheet.h : header file // @@ -88,5 +84,3 @@ class CAdvancedAnimSheet : public CPropertySheet //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_ADVANCEDANIMSHEET_H__67C01724_7C0D_11D3_9A3A_0090272E6F90__INCLUDED_) diff --git a/Core/Tools/W3DView/AggregateNameDialog.h b/Core/Tools/W3DView/AggregateNameDialog.h index 99b2c8b042..2d71d778dc 100644 --- a/Core/Tools/W3DView/AggregateNameDialog.h +++ b/Core/Tools/W3DView/AggregateNameDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_AGGREGATENAMEDIALOG_H__3F618448_CDEA_11D2_9FFC_00104B791122__INCLUDED_) -#define AFX_AGGREGATENAMEDIALOG_H__3F618448_CDEA_11D2_9FFC_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // AggregateNameDialog.h : header file // @@ -79,5 +75,3 @@ class AggregateNameDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_AGGREGATENAMEDIALOG_H__3F618448_CDEA_11D2_9FFC_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/AmbientLightDialog.h b/Core/Tools/W3DView/AmbientLightDialog.h index a806e56309..1ffd5dca66 100644 --- a/Core/Tools/W3DView/AmbientLightDialog.h +++ b/Core/Tools/W3DView/AmbientLightDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_AMBIENTLIGHTDIALOG_H__D60CC3CE_5F94_11D2_9FC7_00104B791122__INCLUDED_) -#define AFX_AMBIENTLIGHTDIALOG_H__D60CC3CE_5F94_11D2_9FC7_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // AmbientLightDialog.h : header file // @@ -71,5 +67,3 @@ class CAmbientLightDialog : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_AMBIENTLIGHTDIALOG_H__D60CC3CE_5F94_11D2_9FC7_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/AnimMixingPage.h b/Core/Tools/W3DView/AnimMixingPage.h index 393cb6ed9c..50c6c369d0 100644 --- a/Core/Tools/W3DView/AnimMixingPage.h +++ b/Core/Tools/W3DView/AnimMixingPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_ANIMMIXINGPAGE_H__67C01722_7C0D_11D3_9A3A_0090272E6F90__INCLUDED_) -#define AFX_ANIMMIXINGPAGE_H__67C01722_7C0D_11D3_9A3A_0090272E6F90__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // AnimMixingPage.h : header file // @@ -73,5 +69,3 @@ class CAnimMixingPage : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_ANIMMIXINGPAGE_H__67C01722_7C0D_11D3_9A3A_0090272E6F90__INCLUDED_) diff --git a/Core/Tools/W3DView/AnimReportPage.cpp b/Core/Tools/W3DView/AnimReportPage.cpp index 5435dbfc42..1b5af2f3ce 100644 --- a/Core/Tools/W3DView/AnimReportPage.cpp +++ b/Core/Tools/W3DView/AnimReportPage.cpp @@ -187,7 +187,7 @@ int CAnimReportPage::FindItem (const char *item_name) return m_AnimReport.FindItem(&lvfi); } -void CAnimReportPage::MakeChannelStr (int bone_idx, HAnimClass *hanim, char *channels) +void CAnimReportPage::MakeChannelStr (int bone_idx, HAnimClass *hanim, char channels[6]) { if (hanim->Has_X_Translation(bone_idx)) strcat(channels, "X"); diff --git a/Core/Tools/W3DView/AnimReportPage.h b/Core/Tools/W3DView/AnimReportPage.h index 74f9b96df3..8f5caac740 100644 --- a/Core/Tools/W3DView/AnimReportPage.h +++ b/Core/Tools/W3DView/AnimReportPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_ANIMREPORTPAGE_H__67C01723_7C0D_11D3_9A3A_0090272E6F90__INCLUDED_) -#define AFX_ANIMREPORTPAGE_H__67C01723_7C0D_11D3_9A3A_0090272E6F90__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // AnimReportPage.h : header file // @@ -60,7 +56,7 @@ class CAnimReportPage : public CPropertyPage protected: void FillListControl (void); int FindItem (const char *item_name); - void MakeChannelStr (int bone_idx, HAnimClass *hanim, char *channels); + void MakeChannelStr(int bone_idx, HAnimClass* hanim, char channels[6]); CAdvancedAnimSheet *m_Sheet; @@ -74,5 +70,3 @@ class CAnimReportPage : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_ANIMREPORTPAGE_H__67C01723_7C0D_11D3_9A3A_0090272E6F90__INCLUDED_) diff --git a/Core/Tools/W3DView/AnimatedSoundOptionsDialog.cpp b/Core/Tools/W3DView/AnimatedSoundOptionsDialog.cpp index 151960f8a3..85584f0037 100644 --- a/Core/Tools/W3DView/AnimatedSoundOptionsDialog.cpp +++ b/Core/Tools/W3DView/AnimatedSoundOptionsDialog.cpp @@ -27,7 +27,7 @@ #include "animatedsoundmgr.h" #include "wwsaveload.h" #include "definitionmgr.h" -#include "WWFILE.H" +#include "WWFILE.h" #include "chunkio.h" #include "wwdebug.h" #include "RestrictedFileDialog.h" diff --git a/Core/Tools/W3DView/AnimatedSoundOptionsDialog.h b/Core/Tools/W3DView/AnimatedSoundOptionsDialog.h index 25d55cb373..9024d742c3 100644 --- a/Core/Tools/W3DView/AnimatedSoundOptionsDialog.h +++ b/Core/Tools/W3DView/AnimatedSoundOptionsDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_ANIMATEDSOUNDOPTIONSDIALOG_H__5FD0B3D4_3975_4315_B412_44586622684B__INCLUDED_) -#define AFX_ANIMATEDSOUNDOPTIONSDIALOG_H__5FD0B3D4_3975_4315_B412_44586622684B__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // AnimatedSoundOptionsDialog.h : header file // @@ -77,5 +73,3 @@ class AnimatedSoundOptionsDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_ANIMATEDSOUNDOPTIONSDIALOG_H__5FD0B3D4_3975_4315_B412_44586622684B__INCLUDED_) diff --git a/Core/Tools/W3DView/AnimationPropPage.h b/Core/Tools/W3DView/AnimationPropPage.h index 0fc010c3e7..0e035b0593 100644 --- a/Core/Tools/W3DView/AnimationPropPage.h +++ b/Core/Tools/W3DView/AnimationPropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_ANIMATIONPROPPAGE_H__9B07DA65_62B6_11D2_9FC7_00104B791122__INCLUDED_) -#define AFX_ANIMATIONPROPPAGE_H__9B07DA65_62B6_11D2_9FC7_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // AnimationPropPage.h : header file // @@ -64,5 +60,3 @@ class CAnimationPropPage : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_ANIMATIONPROPPAGE_H__9B07DA65_62B6_11D2_9FC7_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/AnimationSpeed.h b/Core/Tools/W3DView/AnimationSpeed.h index f4bdff7504..0cd1c8894b 100644 --- a/Core/Tools/W3DView/AnimationSpeed.h +++ b/Core/Tools/W3DView/AnimationSpeed.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_ANIMATIONSPEED_H__D60CC3CD_5F94_11D2_9FC7_00104B791122__INCLUDED_) -#define AFX_ANIMATIONSPEED_H__D60CC3CD_5F94_11D2_9FC7_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // AnimationSpeed.h : header file // @@ -69,5 +65,3 @@ class CAnimationSpeed : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_ANIMATIONSPEED_H__D60CC3CD_5F94_11D2_9FC7_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/AssetInfo.cpp b/Core/Tools/W3DView/AssetInfo.cpp index 8cc309bc14..3b7092dcc6 100644 --- a/Core/Tools/W3DView/AssetInfo.cpp +++ b/Core/Tools/W3DView/AssetInfo.cpp @@ -37,7 +37,7 @@ #include "StdAfx.h" #include "AssetInfo.h" -//#include "HModel.H" +//#include "HModel.h" #include "assetmgr.h" #include "htree.h" @@ -53,7 +53,8 @@ AssetInfoClass::Initialize (void) // Assume we are wrapping an instance as apposed to an asset 'name'. RenderObjClass *prender_obj = m_pRenderObj; - SAFE_ADD_REF (prender_obj); + if (prender_obj) + prender_obj->Add_Ref(); // If we are wrapping an asset name, then create an instance of it. if (prender_obj == NULL) { @@ -72,7 +73,7 @@ AssetInfoClass::Initialize (void) } // Release our hold on the temporary object - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); } return ; diff --git a/Core/Tools/W3DView/AssetInfo.h b/Core/Tools/W3DView/AssetInfo.h index 10325bee3e..1ba0adf5e0 100644 --- a/Core/Tools/W3DView/AssetInfo.h +++ b/Core/Tools/W3DView/AssetInfo.h @@ -34,14 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - -#ifndef __ASSET_INFO_H -#define __ASSET_INFO_H #include "rendobj.h" #include "Utils.h" @@ -72,9 +65,9 @@ class AssetInfoClass : m_Name (passet_name), m_AssetType (type), m_dwUserData (user_data), - m_pRenderObj (NULL) { MEMBER_ADD (m_pRenderObj, prender_obj); Initialize (); } + m_pRenderObj (NULL) { REF_PTR_SET (m_pRenderObj, prender_obj); Initialize (); } - virtual ~AssetInfoClass (void) { MEMBER_RELEASE (m_pRenderObj); } + virtual ~AssetInfoClass (void) { REF_PTR_RELEASE (m_pRenderObj); } ////////////////////////////////////////////////////////////// // @@ -90,14 +83,14 @@ class AssetInfoClass ASSET_TYPE Get_Type (void) const { return m_AssetType; } DWORD Get_User_Number (void) const { return m_dwUserData; } const CString & Get_User_String (void) const { return m_UserString; } - RenderObjClass * Get_Render_Obj (void) const { SAFE_ADD_REF (m_pRenderObj); return m_pRenderObj; } + RenderObjClass * Get_Render_Obj (void) const { if (m_pRenderObj) m_pRenderObj->Add_Ref(); return m_pRenderObj; } RenderObjClass * Peek_Render_Obj (void) const { return m_pRenderObj; } void Set_Name (LPCTSTR pname) { m_Name = pname; } void Set_Hierarchy_Name (LPCTSTR pname) { m_HierarchyName = pname; } void Set_Type (ASSET_TYPE type) { m_AssetType = type; } void Set_User_Number (DWORD user_data) { m_dwUserData = user_data; } void Set_User_String (LPCTSTR string) { m_UserString = string; } - void Set_Render_Obj (RenderObjClass *pobj) { MEMBER_ADD (m_pRenderObj, pobj); } + void Set_Render_Obj (RenderObjClass *pobj) { REF_PTR_SET (m_pRenderObj, pobj); } // // Information methods @@ -127,7 +120,3 @@ class AssetInfoClass DWORD m_dwUserData; RenderObjClass * m_pRenderObj; }; - - - -#endif //__ASSET_INFO_H diff --git a/Core/Tools/W3DView/AssetPropertySheet.h b/Core/Tools/W3DView/AssetPropertySheet.h index 03dacf70d3..cb9446b6d0 100644 --- a/Core/Tools/W3DView/AssetPropertySheet.h +++ b/Core/Tools/W3DView/AssetPropertySheet.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_ASSETPROPERTYSHEET_H__FB40246D_5DFB_11D2_9FC7_00104B791122__INCLUDED_) -#define AFX_ASSETPROPERTYSHEET_H__FB40246D_5DFB_11D2_9FC7_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // AssetPropertySheet.h : header file // @@ -70,5 +66,3 @@ class CAssetPropertySheet : public CPropertySheet //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_ASSETPROPERTYSHEET_H__FB40246D_5DFB_11D2_9FC7_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/AssetTypes.h b/Core/Tools/W3DView/AssetTypes.h index 143fdf7847..bb85e71c6d 100644 --- a/Core/Tools/W3DView/AssetTypes.h +++ b/Core/Tools/W3DView/AssetTypes.h @@ -34,14 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __ASSET_TYPES_H -#define __ASSET_TYPES_H - typedef enum { @@ -59,6 +52,3 @@ typedef enum TypeSound } ASSET_TYPE; - - -#endif //__ASSET_TYPES_H diff --git a/Core/Tools/W3DView/BackgroundBMPDialog.h b/Core/Tools/W3DView/BackgroundBMPDialog.h index 2df90afcca..71a86752a9 100644 --- a/Core/Tools/W3DView/BackgroundBMPDialog.h +++ b/Core/Tools/W3DView/BackgroundBMPDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_BACKGROUNDBMPDIALOG_H__5D8C201B_6380_11D2_9FC7_00104B791122__INCLUDED_) -#define AFX_BACKGROUNDBMPDIALOG_H__5D8C201B_6380_11D2_9FC7_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // BackgroundBMPDialog.h : header file // @@ -62,5 +58,3 @@ class CBackgroundBMPDialog : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_BACKGROUNDBMPDIALOG_H__5D8C201B_6380_11D2_9FC7_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/BackgroundColorDialog.h b/Core/Tools/W3DView/BackgroundColorDialog.h index 763f61ee99..5999e968f0 100644 --- a/Core/Tools/W3DView/BackgroundColorDialog.h +++ b/Core/Tools/W3DView/BackgroundColorDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_BACKGROUNDCOLORDIALOG_H__AF3CDE8C_61EC_11D2_9FC7_00104B791122__INCLUDED_) -#define AFX_BACKGROUNDCOLORDIALOG_H__AF3CDE8C_61EC_11D2_9FC7_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // BackgroundColorDialog.h : header file // @@ -71,5 +67,3 @@ class CBackgroundColorDialog : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_BACKGROUNDCOLORDIALOG_H__AF3CDE8C_61EC_11D2_9FC7_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/BackgroundObjectDialog.h b/Core/Tools/W3DView/BackgroundObjectDialog.h index a5dd237efa..0032e55126 100644 --- a/Core/Tools/W3DView/BackgroundObjectDialog.h +++ b/Core/Tools/W3DView/BackgroundObjectDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_BACKGROUNDOBJECTDIALOG_H__9B07DA63_62B6_11D2_9FC7_00104B791122__INCLUDED_) -#define AFX_BACKGROUNDOBJECTDIALOG_H__9B07DA63_62B6_11D2_9FC7_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // BackgroundObjectDialog.h : header file // @@ -63,5 +59,3 @@ class CBackgroundObjectDialog : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_BACKGROUNDOBJECTDIALOG_H__9B07DA63_62B6_11D2_9FC7_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/BoneMgrDialog.cpp b/Core/Tools/W3DView/BoneMgrDialog.cpp index 8559792b87..57ed30814e 100644 --- a/Core/Tools/W3DView/BoneMgrDialog.cpp +++ b/Core/Tools/W3DView/BoneMgrDialog.cpp @@ -28,7 +28,7 @@ #include "MainFrm.h" #include "W3DViewDoc.h" #include "DataTreeView.h" -//#include "HModel.H" +//#include "HModel.h" #ifdef RTS_DEBUG #define new DEBUG_NEW @@ -222,15 +222,15 @@ BoneMgrDialogClass::Fill_Bone_Item // Free our hold on the render objs in the original node list for (index = 0; index < orig_node_list.Count (); index ++) { - MEMBER_RELEASE (orig_node_list[index]); + REF_PTR_RELEASE (orig_node_list[index]); } // Free our hold on the render objs in the node list for (index = 0; index < node_list.Count (); index ++) { - MEMBER_RELEASE (node_list[index]); + REF_PTR_RELEASE (node_list[index]); } - MEMBER_RELEASE (porig_model); + REF_PTR_RELEASE (porig_model); return ; } @@ -405,7 +405,7 @@ void BoneMgrDialogClass::OnOK (void) { // Simply forget about the backup we made - MEMBER_RELEASE (m_pBackupModel); + REF_PTR_RELEASE (m_pBackupModel); // Update the hierarchy's cached information to reflect the new settings CW3DViewDoc *pdoc = (CW3DViewDoc *)((CMainFrame *)::AfxGetMainWnd())->GetActiveDocument (); @@ -459,7 +459,7 @@ BoneMgrDialogClass::OnAttachButton (void) if (prender_obj != NULL) { m_pBaseModel->Add_Sub_Object_To_Bone (prender_obj, m_BoneName); m_BoneTree.InsertItem (name, 1, 1, hbone_item); - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); } } else { @@ -481,7 +481,7 @@ BoneMgrDialogClass::OnAttachButton (void) } // Release our hold on this pointer - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } // Remove the object from our UI diff --git a/Core/Tools/W3DView/BoneMgrDialog.h b/Core/Tools/W3DView/BoneMgrDialog.h index b14d5bedd2..33da214143 100644 --- a/Core/Tools/W3DView/BoneMgrDialog.h +++ b/Core/Tools/W3DView/BoneMgrDialog.h @@ -16,17 +16,13 @@ ** along with this program. If not, see . */ -#if !defined(AFX_BONEMGRDIALOG_H__66DA0E58_BFCA_11D2_9FFA_00104B791122__INCLUDED_) -#define AFX_BONEMGRDIALOG_H__66DA0E58_BFCA_11D2_9FFA_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // BoneMgrDialog.h : header file // #include "resource.h" -#include "Vector.H" +#include "Vector.h" // Forward declarations class HModelClass; @@ -107,5 +103,3 @@ class BoneMgrDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_BONEMGRDIALOG_H__66DA0E58_BFCA_11D2_9FFA_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/CMakeLists.txt b/Core/Tools/W3DView/CMakeLists.txt index a39051ac73..f8a8b9604c 100644 --- a/Core/Tools/W3DView/CMakeLists.txt +++ b/Core/Tools/W3DView/CMakeLists.txt @@ -151,7 +151,7 @@ set(W3DVIEW_SRC "Utils.cpp" "Utils.h" "Vector3RndCombo.cpp" - "Vector3RndCombo.H" + "Vector3RndCombo.h" "ViewerAssetMgr.cpp" "ViewerAssetMgr.h" "ViewerScene.cpp" @@ -170,6 +170,13 @@ add_library(corei_w3dview INTERFACE) target_sources(corei_w3dview INTERFACE ${W3DVIEW_SRC}) +target_precompile_headers(corei_w3dview INTERFACE + "StdAfx.h" + [["always.h"]] + [["STLUtils.h"]] + [["WWCommon.h"]] +) + if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") target_sources(corei_w3dview INTERFACE W3DView.rc) endif() diff --git a/Core/Tools/W3DView/CameraDistanceDialog.h b/Core/Tools/W3DView/CameraDistanceDialog.h index 6db4b2f6e6..ffde9e0757 100644 --- a/Core/Tools/W3DView/CameraDistanceDialog.h +++ b/Core/Tools/W3DView/CameraDistanceDialog.h @@ -16,12 +16,7 @@ ** along with this program. If not, see . */ -#if !defined(AFX_CAMERADISTANCEDIALOG_H__548D3315_D582_4B97_8607_31B4659DF498__INCLUDED_) -#define AFX_CAMERADISTANCEDIALOG_H__548D3315_D582_4B97_8607_31B4659DF498__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #include "resource.h" @@ -64,5 +59,3 @@ class CameraDistanceDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_CAMERADISTANCEDIALOG_H__548D3315_D582_4B97_8607_31B4659DF498__INCLUDED_) diff --git a/Core/Tools/W3DView/CameraSettingsDialog.h b/Core/Tools/W3DView/CameraSettingsDialog.h index 7f62789bc2..bd94ce278f 100644 --- a/Core/Tools/W3DView/CameraSettingsDialog.h +++ b/Core/Tools/W3DView/CameraSettingsDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_CAMERASETTINGSDIALOG_H__7E43F424_8191_11D3_A064_00104B791122__INCLUDED_) -#define AFX_CAMERASETTINGSDIALOG_H__7E43F424_8191_11D3_A064_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // CameraSettingsDialog.h : header file // @@ -78,5 +74,3 @@ class CameraSettingsDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_CAMERASETTINGSDIALOG_H__7E43F424_8191_11D3_A064_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/ColorBar.h b/Core/Tools/W3DView/ColorBar.h index f98787f13c..a1efce422d 100644 --- a/Core/Tools/W3DView/ColorBar.h +++ b/Core/Tools/W3DView/ColorBar.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_COLORBAR_H__D1243F40_D4D2_11D2_8DDF_00104B6FD9E3__INCLUDED_) -#define AFX_COLORBAR_H__D1243F40_D4D2_11D2_8DDF_00104B6FD9E3__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // ColorBar.h : header file // @@ -248,5 +244,3 @@ class ColorBarClass : public CWnd //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_COLORBAR_H__D1243F40_D4D2_11D2_8DDF_00104B6FD9E3__INCLUDED_) diff --git a/Core/Tools/W3DView/ColorPicker.h b/Core/Tools/W3DView/ColorPicker.h index 92ef47dc8d..6d4941b0a1 100644 --- a/Core/Tools/W3DView/ColorPicker.h +++ b/Core/Tools/W3DView/ColorPicker.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_COLORPICKER_H__C943A7EC_CAA3_11D2_8DDF_00104B6FD9E3__INCLUDED_) -#define AFX_COLORPICKER_H__C943A7EC_CAA3_11D2_8DDF_00104B6FD9E3__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // ColorPicker.h : header file // @@ -157,5 +153,3 @@ class ColorPickerClass : public CWnd //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_COLORPICKER_H__C943A7EC_CAA3_11D2_8DDF_00104B6FD9E3__INCLUDED_) diff --git a/Core/Tools/W3DView/ColorPickerDialogClass.h b/Core/Tools/W3DView/ColorPickerDialogClass.h index 7542ad5de9..64f6ea6e97 100644 --- a/Core/Tools/W3DView/ColorPickerDialogClass.h +++ b/Core/Tools/W3DView/ColorPickerDialogClass.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_COLORPICKERDIALOGCLASS_H__C943A7F1_CAA3_11D2_8DDF_00104B6FD9E3__INCLUDED_) -#define AFX_COLORPICKERDIALOGCLASS_H__C943A7F1_CAA3_11D2_8DDF_00104B6FD9E3__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // ColorPickerDialogClass.h : header file // @@ -132,5 +128,3 @@ class ColorPickerDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_COLORPICKERDIALOGCLASS_H__C943A7F1_CAA3_11D2_8DDF_00104B6FD9E3__INCLUDED_) diff --git a/Core/Tools/W3DView/ColorSelectionDialog.h b/Core/Tools/W3DView/ColorSelectionDialog.h index 199d49adb8..3c42553ed3 100644 --- a/Core/Tools/W3DView/ColorSelectionDialog.h +++ b/Core/Tools/W3DView/ColorSelectionDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_OLORSELECTIONDIALOG_H__C0BCECAE_B6EA_11D2_9FF8_00104B791122__INCLUDED_) -#define AFX_OLORSELECTIONDIALOG_H__C0BCECAE_B6EA_11D2_9FF8_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // ColorSelectionDialog.h : header file // @@ -105,5 +101,3 @@ class ColorSelectionDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_OLORSELECTIONDIALOG_H__C0BCECAE_B6EA_11D2_9FF8_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/ColorUtils.h b/Core/Tools/W3DView/ColorUtils.h index 3b103b32f1..2a440aafe3 100644 --- a/Core/Tools/W3DView/ColorUtils.h +++ b/Core/Tools/W3DView/ColorUtils.h @@ -18,12 +18,11 @@ ////////////////////////////////////////////////////////////////////////////////////////// // -// ColorUtils.H +// ColorUtils.h // // -#ifndef __COLORUTILS_H -#define __COLORUTILS_H +#pragma once ///////////////////////////////////////////////////////////////////////////// // Callbacks @@ -46,6 +45,3 @@ BOOL Set_Form_Original_Color (HWND form_wnd, int red, int green, int blue); BOOL Set_Update_Callback (HWND form_wnd, WWCTRL_COLORCALLBACK callback, void *arg=NULL); void RegisterColorPicker (HINSTANCE hinst); void RegisterColorBar (HINSTANCE hinst); - - -#endif //__COLORUTILS_H diff --git a/Core/Tools/W3DView/DataTreeView.cpp b/Core/Tools/W3DView/DataTreeView.cpp index 368a5fc1d7..1b5a31d163 100644 --- a/Core/Tools/W3DView/DataTreeView.cpp +++ b/Core/Tools/W3DView/DataTreeView.cpp @@ -48,7 +48,7 @@ #include "hcanim.h" #include "AssetInfo.h" #include "Utils.h" -#include "Vector.H" +#include "Vector.h" #include "part_emt.h" #include "agg_def.h" #include "bmp2d.h" @@ -521,7 +521,7 @@ CDataTreeView::LoadAnimationsIntoTree (void) } // Release our hold on this animation... - MEMBER_RELEASE (pHierarchyAnim); + REF_PTR_RELEASE (pHierarchyAnim); } } @@ -583,7 +583,7 @@ CDataTreeView::LoadAnimationsIntoTree (HTREEITEM hItem) } // Release our hold on the animation object - MEMBER_RELEASE (pHierarchyAnim); + REF_PTR_RELEASE (pHierarchyAnim); } } @@ -1009,7 +1009,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item) RenderObjClass *prender_obj = Create_Render_Obj_To_Display (hParentItem); pdoc->PlayAnimation (prender_obj, asset_info->Get_Name ()); - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); } } break; @@ -1019,7 +1019,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item) // Ask the document to display this object ParticleEmitterClass *emitter = (ParticleEmitterClass *)Create_Render_Obj_To_Display (htree_item); pdoc->Display_Emitter (emitter); - MEMBER_RELEASE (emitter); + REF_PTR_RELEASE (emitter); } break; @@ -1035,7 +1035,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item) // Ask the document to display this object RenderObjClass *prender_obj = Create_Render_Obj_To_Display (htree_item); pdoc->DisplayObject (prender_obj); - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); } break; } @@ -1478,7 +1478,7 @@ Set_Highest_LOD (RenderObjClass *render_obj) if (sub_obj != NULL) { Set_Highest_LOD (sub_obj); } - MEMBER_RELEASE (sub_obj); + REF_PTR_RELEASE (sub_obj); } // diff --git a/Core/Tools/W3DView/DataTreeView.h b/Core/Tools/W3DView/DataTreeView.h index 5a48f76c79..2882cf719b 100644 --- a/Core/Tools/W3DView/DataTreeView.h +++ b/Core/Tools/W3DView/DataTreeView.h @@ -16,18 +16,14 @@ ** along with this program. If not, see . */ -#if !defined(AFX_DATATREEVIEW_H__2BB39E40_5D3A_11D2_9FC6_00104B791122__INCLUDED_) -#define AFX_DATATREEVIEW_H__2BB39E40_5D3A_11D2_9FC6_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // DataTreeView.h : header file // -#include "AfxCView.H" +#include "AfxCView.h" #include "AssetTypes.h" -#include "Vector.H" +#include "Vector.h" // Forward declarations class RenderObjClass; @@ -175,6 +171,3 @@ class CDataTreeView : public CTreeView //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DATATREEVIEW_H__2BB39E40_5D3A_11D2_9FC6_00104B791122__INCLUDED_) - diff --git a/Core/Tools/W3DView/DeviceSelectionDialog.h b/Core/Tools/W3DView/DeviceSelectionDialog.h index 93da3959e7..18d67c60ca 100644 --- a/Core/Tools/W3DView/DeviceSelectionDialog.h +++ b/Core/Tools/W3DView/DeviceSelectionDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_DEVICESELECTIONDIALOG_H__49E2DFF9_5D3F_11D2_9FC6_00104B791122__INCLUDED_) -#define AFX_DEVICESELECTIONDIALOG_H__49E2DFF9_5D3F_11D2_9FC6_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // DeviceSelectionDialog.h : header file // @@ -86,5 +82,3 @@ class CDeviceSelectionDialog : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_DEVICESELECTIONDIALOG_H__49E2DFF9_5D3F_11D2_9FC6_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/DialogToolbar.cpp b/Core/Tools/W3DView/DialogToolbar.cpp index e80fc6c9be..f3e94f2831 100644 --- a/Core/Tools/W3DView/DialogToolbar.cpp +++ b/Core/Tools/W3DView/DialogToolbar.cpp @@ -36,7 +36,7 @@ #include "StdAfx.h" #include "DialogToolbar.h" -#include "AfxPriv.H" +#include "AfxPriv.h" BEGIN_MESSAGE_MAP(DialogToolbarClass, CToolBar) diff --git a/Core/Tools/W3DView/DialogToolbar.h b/Core/Tools/W3DView/DialogToolbar.h index 35bc8f91ed..09b160b6ab 100644 --- a/Core/Tools/W3DView/DialogToolbar.h +++ b/Core/Tools/W3DView/DialogToolbar.h @@ -34,14 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - -#ifndef __DIALOGTOOLBAR_H -#define __DIALOGTOOLBAR_H #include "resource.h" @@ -99,7 +92,3 @@ class DialogToolbarClass : public CToolBar // void Enable_Button (int id, bool benable = true); }; - - -#endif //__DIALOGTOOLBAR_H - diff --git a/Core/Tools/W3DView/DirectoryDialog.h b/Core/Tools/W3DView/DirectoryDialog.h index 6e7cce1d54..b0395a5151 100644 --- a/Core/Tools/W3DView/DirectoryDialog.h +++ b/Core/Tools/W3DView/DirectoryDialog.h @@ -34,14 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __DIRECTORY_DIALOG_H -#define __DIRECTORY_DIALOG_H - ///////////////////////////////////////////////////////////////////////// // @@ -49,7 +42,3 @@ // ///////////////////////////////////////////////////////////////////////// bool Browse_For_Folder (HWND parent_wnd, LPCTSTR initial_path, CString &path); - - -#endif //__DIRECTORY_DIALOG_H - diff --git a/Core/Tools/W3DView/EditLODDialog.cpp b/Core/Tools/W3DView/EditLODDialog.cpp index bdd7bf2aac..f00c487d6f 100644 --- a/Core/Tools/W3DView/EditLODDialog.cpp +++ b/Core/Tools/W3DView/EditLODDialog.cpp @@ -119,7 +119,7 @@ CEditLODDialog::OnInitDialog (void) RenderObjClass *pfirst_subobj = pLOD->Get_Sub_Object (0); if (pfirst_subobj != NULL) { m_spinIncrement = pfirst_subobj->Get_Bounding_Sphere ().Radius / 5.0F; - MEMBER_RELEASE (pfirst_subobj); + REF_PTR_RELEASE (pfirst_subobj); } // Loop through all the subobjects @@ -142,7 +142,7 @@ CEditLODDialog::OnInitDialog (void) m_hierarchyListCtrl.SetItemText (iIndex, COL_SWITCH_DN, stringTemp); // Free this object - MEMBER_RELEASE (pCSubObject); + REF_PTR_RELEASE (pCSubObject); } } diff --git a/Core/Tools/W3DView/EditLODDialog.h b/Core/Tools/W3DView/EditLODDialog.h index addc9283ae..94187d1ea4 100644 --- a/Core/Tools/W3DView/EditLODDialog.h +++ b/Core/Tools/W3DView/EditLODDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_EDITLODDIALOG_H__AF3CDE8E_61EC_11D2_9FC7_00104B791122__INCLUDED_) -#define AFX_EDITLODDIALOG_H__AF3CDE8E_61EC_11D2_9FC7_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // EditLODDialog.h : header file // @@ -78,5 +74,3 @@ class CEditLODDialog : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EDITLODDIALOG_H__AF3CDE8E_61EC_11D2_9FC7_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/EmitterColorPropPage.h b/Core/Tools/W3DView/EmitterColorPropPage.h index 3670b48997..4c33199bbb 100644 --- a/Core/Tools/W3DView/EmitterColorPropPage.h +++ b/Core/Tools/W3DView/EmitterColorPropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_EMITTERCOLORPROPPAGE_H__83A8B83F_BA3B_11D2_9FFA_00104B791122__INCLUDED_) -#define AFX_EMITTERCOLORPROPPAGE_H__83A8B83F_BA3B_11D2_9FFA_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // EmitterColorPropPage.h : header file // @@ -130,5 +126,3 @@ class EmitterColorPropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EMITTERCOLORPROPPAGE_H__83A8B83F_BA3B_11D2_9FFA_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/EmitterFramePropPage.h b/Core/Tools/W3DView/EmitterFramePropPage.h index dde1f43d4b..7e7c7cbf64 100644 --- a/Core/Tools/W3DView/EmitterFramePropPage.h +++ b/Core/Tools/W3DView/EmitterFramePropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_EMITTERFRAMEPROPPAGE_H__6F068804_EAD5_4A19_BE03_C9C7B534E6E8__INCLUDED_) -#define AFX_EMITTERFRAMEPROPPAGE_H__6F068804_EAD5_4A19_BE03_C9C7B534E6E8__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // EmitterFramePropPage.h : header file // @@ -130,5 +126,3 @@ inline float EmitterFramePropPageClass::Denormalize_Frame(float normalized_val) //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EMITTERFRAMEPROPPAGE_H__6F068804_EAD5_4A19_BE03_C9C7B534E6E8__INCLUDED_) diff --git a/Core/Tools/W3DView/EmitterGeneralPropPage.h b/Core/Tools/W3DView/EmitterGeneralPropPage.h index cfae9bd511..bb81f4a261 100644 --- a/Core/Tools/W3DView/EmitterGeneralPropPage.h +++ b/Core/Tools/W3DView/EmitterGeneralPropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_EMITTERGENERALPROPPAGE_H__83A8B83C_BA3B_11D2_9FFA_00104B791122__INCLUDED_) -#define AFX_EMITTERGENERALPROPPAGE_H__83A8B83C_BA3B_11D2_9FFA_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // EmitterGeneralPropPage.h : header file // @@ -130,5 +126,3 @@ class EmitterGeneralPropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EMITTERGENERALPROPPAGE_H__83A8B83C_BA3B_11D2_9FFA_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/EmitterInstanceList.cpp b/Core/Tools/W3DView/EmitterInstanceList.cpp index d8d20d5f67..a4f66a0e97 100644 --- a/Core/Tools/W3DView/EmitterInstanceList.cpp +++ b/Core/Tools/W3DView/EmitterInstanceList.cpp @@ -59,7 +59,7 @@ EmitterInstanceListClass::Free_List (void) // Release our hold on each of the emitter pointers // for (int index = 0; index < m_List.Count (); index ++) { - MEMBER_RELEASE (m_List[index]); + REF_PTR_RELEASE (m_List[index]); } m_List.Delete_All (); @@ -93,7 +93,8 @@ EmitterInstanceListClass::Add_Emitter (ParticleEmitterClass *emitter) // // Add this emitter to the list and put a hold on its reference // - SAFE_ADD_REF (emitter); + if (emitter) + emitter->Add_Ref(); m_List.Add (emitter); } diff --git a/Core/Tools/W3DView/EmitterInstanceList.h b/Core/Tools/W3DView/EmitterInstanceList.h index 488ab2784b..88688ba59e 100644 --- a/Core/Tools/W3DView/EmitterInstanceList.h +++ b/Core/Tools/W3DView/EmitterInstanceList.h @@ -30,14 +30,9 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif -#ifndef __EMITTER_INSTANCE_LIST_H -#define __EMITTER_INSTANCE_LIST_H - -#include "Vector.H" +#include "Vector.h" #include "part_ldr.h" #include "part_emt.h" @@ -110,5 +105,3 @@ class EmitterInstanceListClass : public ParticleEmitterDefClass DynamicVectorClass m_List; }; - -#endif //__EMITTER_INSTANCE_LIST_H diff --git a/Core/Tools/W3DView/EmitterLineGroupPropPage.h b/Core/Tools/W3DView/EmitterLineGroupPropPage.h index 56c10a1eda..2a575eff3e 100644 --- a/Core/Tools/W3DView/EmitterLineGroupPropPage.h +++ b/Core/Tools/W3DView/EmitterLineGroupPropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_EMITTERLINEGROUPPROPPAGE_H__51E7B2D1_1943_454E_B188_5F7D508D7203__INCLUDED_) -#define AFX_EMITTERLINEGROUPPROPPAGE_H__51E7B2D1_1943_454E_B188_5F7D508D7203__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // EmitterLineGroupPropPage.h : header file // @@ -112,5 +108,3 @@ class EmitterLineGroupPropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EMITTERLINEGROUPPROPPAGE_H__51E7B2D1_1943_454E_B188_5F7D508D7203__INCLUDED_) diff --git a/Core/Tools/W3DView/EmitterLinePropPage.h b/Core/Tools/W3DView/EmitterLinePropPage.h index a8d1b59ff4..00f2c2feee 100644 --- a/Core/Tools/W3DView/EmitterLinePropPage.h +++ b/Core/Tools/W3DView/EmitterLinePropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_EMITTERLINEPROPPAGE_H__BBD9ED4C_E752_439A_81D5_A4FA9A6F6FC8__INCLUDED_) -#define AFX_EMITTERLINEPROPPAGE_H__BBD9ED4C_E752_439A_81D5_A4FA9A6F6FC8__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // EmitterLinePropPage.h : header file // @@ -131,5 +127,3 @@ class EmitterLinePropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EMITTERLINEPROPPAGE_H__BBD9ED4C_E752_439A_81D5_A4FA9A6F6FC8__INCLUDED_) diff --git a/Core/Tools/W3DView/EmitterParticlePropPage.cpp b/Core/Tools/W3DView/EmitterParticlePropPage.cpp index aa5b92065f..cff67fb241 100644 --- a/Core/Tools/W3DView/EmitterParticlePropPage.cpp +++ b/Core/Tools/W3DView/EmitterParticlePropPage.cpp @@ -24,7 +24,7 @@ #include "EmitterParticlePropPage.h" #include "part_emt.h" #include "Utils.h" -#include "Vector3RndCombo.H" +#include "Vector3RndCombo.h" #include "VolumeRandomDialog.h" #include "EmitterInstanceList.h" diff --git a/Core/Tools/W3DView/EmitterParticlePropPage.h b/Core/Tools/W3DView/EmitterParticlePropPage.h index 091e930e81..ae3702d755 100644 --- a/Core/Tools/W3DView/EmitterParticlePropPage.h +++ b/Core/Tools/W3DView/EmitterParticlePropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_EMITTERPARTICLEPROPPAGE_H__83A8B83D_BA3B_11D2_9FFA_00104B791122__INCLUDED_) -#define AFX_EMITTERPARTICLEPROPPAGE_H__83A8B83D_BA3B_11D2_9FFA_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // EmitterParticlePropPage.h : header file // @@ -119,6 +115,3 @@ class EmitterParticlePropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EMITTERPARTICLEPROPPAGE_H__83A8B83D_BA3B_11D2_9FFA_00104B791122__INCLUDED_) - diff --git a/Core/Tools/W3DView/EmitterPhysicsPropPage.h b/Core/Tools/W3DView/EmitterPhysicsPropPage.h index 0b5b718185..2b2c35cd60 100644 --- a/Core/Tools/W3DView/EmitterPhysicsPropPage.h +++ b/Core/Tools/W3DView/EmitterPhysicsPropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_EMITTERPHYSICSPROPPAGE_H__83A8B83E_BA3B_11D2_9FFA_00104B791122__INCLUDED_) -#define AFX_EMITTERPHYSICSPROPPAGE_H__83A8B83E_BA3B_11D2_9FFA_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // EmitterPhysicsPropPage.h : header file // @@ -125,5 +121,3 @@ class EmitterPhysicsPropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EMITTERPHYSICSPROPPAGE_H__83A8B83E_BA3B_11D2_9FFA_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/EmitterPropertySheet.cpp b/Core/Tools/W3DView/EmitterPropertySheet.cpp index 7dc9c5f0fd..0b3eed55b2 100644 --- a/Core/Tools/W3DView/EmitterPropertySheet.cpp +++ b/Core/Tools/W3DView/EmitterPropertySheet.cpp @@ -265,7 +265,7 @@ EmitterPropertySheetClass::Update_Emitter (void) // // Use this emitter as the edited emitter from here on out // - MEMBER_RELEASE (m_pEmitter); + REF_PTR_RELEASE (m_pEmitter); m_pEmitter = pemitter;*/ // Pass the emitter along to the pages @@ -501,7 +501,7 @@ EmitterPropertySheetClass::Create_New_Emitter (void) // Display the new emitter // ::GetCurrentDocument ()->Display_Emitter (emitter); - MEMBER_RELEASE (emitter); + REF_PTR_RELEASE (emitter); /*SAFE_DELETE_ARRAY (color.Values); SAFE_DELETE_ARRAY (color.KeyTimes); diff --git a/Core/Tools/W3DView/EmitterPropertySheet.h b/Core/Tools/W3DView/EmitterPropertySheet.h index d9a43eb057..f0861029c8 100644 --- a/Core/Tools/W3DView/EmitterPropertySheet.h +++ b/Core/Tools/W3DView/EmitterPropertySheet.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_EMITTERPROPERTYSHEET_H__83A8B844_BA3B_11D2_9FFA_00104B791122__INCLUDED_) -#define AFX_EMITTERPROPERTYSHEET_H__83A8B844_BA3B_11D2_9FFA_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // EmitterPropertySheet.h : header file // @@ -124,5 +120,3 @@ class EmitterPropertySheetClass : public CPropertySheet //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EMITTERPROPERTYSHEET_H__83A8B844_BA3B_11D2_9FFA_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/EmitterRotationPropPage.h b/Core/Tools/W3DView/EmitterRotationPropPage.h index 42dd67c82f..aba163b3c0 100644 --- a/Core/Tools/W3DView/EmitterRotationPropPage.h +++ b/Core/Tools/W3DView/EmitterRotationPropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_EMITTERROTATIONPROPPAGE_H__35F8A2F6_C91C_4750_BF06_100433C1ECBB__INCLUDED_) -#define AFX_EMITTERROTATIONPROPPAGE_H__35F8A2F6_C91C_4750_BF06_100433C1ECBB__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // EmitterRotationPropPage.h : header file // @@ -139,5 +135,3 @@ inline float EmitterRotationPropPageClass::Denormalize_Rotation(float normalized //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EMITTERROTATIONPROPPAGE_H__35F8A2F6_C91C_4750_BF06_100433C1ECBB__INCLUDED_) diff --git a/Core/Tools/W3DView/EmitterSizePropPage.h b/Core/Tools/W3DView/EmitterSizePropPage.h index d0f76734d1..14e4ca369b 100644 --- a/Core/Tools/W3DView/EmitterSizePropPage.h +++ b/Core/Tools/W3DView/EmitterSizePropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_EMITTERSIZEPROPPAGE_H__0CD2CBA3_1219_11D3_A034_00104B791122__INCLUDED_) -#define AFX_EMITTERSIZEPROPPAGE_H__0CD2CBA3_1219_11D3_A034_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // EmitterSizePropPage.h : header file // @@ -115,5 +111,3 @@ class EmitterSizePropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EMITTERSIZEPROPPAGE_H__0CD2CBA3_1219_11D3_A034_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/EmitterUserPropPage.h b/Core/Tools/W3DView/EmitterUserPropPage.h index f0ca8c0c19..514c98ab92 100644 --- a/Core/Tools/W3DView/EmitterUserPropPage.h +++ b/Core/Tools/W3DView/EmitterUserPropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_EMITTERUSERPROPPAGE_H__83A8B840_BA3B_11D2_9FFA_00104B791122__INCLUDED_) -#define AFX_EMITTERUSERPROPPAGE_H__83A8B840_BA3B_11D2_9FFA_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // EmitterUserPropPage.h : header file // @@ -111,5 +107,3 @@ class EmitterUserPropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_EMITTERUSERPROPPAGE_H__83A8B840_BA3B_11D2_9FFA_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/GammaDialog.h b/Core/Tools/W3DView/GammaDialog.h index 9e378c5bf3..43adf086f4 100644 --- a/Core/Tools/W3DView/GammaDialog.h +++ b/Core/Tools/W3DView/GammaDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_GAMMADIALOG_H__DA25161A_E783_44DE_8398_B311C20C3BE9__INCLUDED_) -#define AFX_GAMMADIALOG_H__DA25161A_E783_44DE_8398_B311C20C3BE9__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // GammaDialog.h : header file // @@ -63,5 +59,3 @@ class GammaDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_GAMMADIALOG_H__DA25161A_E783_44DE_8398_B311C20C3BE9__INCLUDED_) diff --git a/Core/Tools/W3DView/Globals.cpp b/Core/Tools/W3DView/Globals.cpp index 2d9341463c..45dfd6d7a3 100644 --- a/Core/Tools/W3DView/Globals.cpp +++ b/Core/Tools/W3DView/Globals.cpp @@ -18,7 +18,7 @@ ///////////////////////////////////////////////////////////////////// // -// Globals.CPP +// Globals.cpp // // Module containing global variable initialization. // diff --git a/Core/Tools/W3DView/Globals.h b/Core/Tools/W3DView/Globals.h index 15205954b1..b0da69bfdf 100644 --- a/Core/Tools/W3DView/Globals.h +++ b/Core/Tools/W3DView/Globals.h @@ -18,16 +18,14 @@ ///////////////////////////////////////////////////////////////////// // -// Globals.H +// Globals.h // // Module containing global variable definitions. // // ///////////////////////////////////////////////////////////////////// -#ifndef __GLOBALS_H -#define __GLOBALS_H - +#pragma once ////////////////////////////////////////////////////// // Externs @@ -45,6 +43,3 @@ extern int g_iHeight; ////////////////////////////////////////////////////// const int DEFAULT_DEVICEINDEX = 1; const int DEFAULT_BITSPERPIX = 16; - - -#endif //__GLOBALS_H diff --git a/Core/Tools/W3DView/GraphicView.cpp b/Core/Tools/W3DView/GraphicView.cpp index ccf5bbfca5..e32acee128 100644 --- a/Core/Tools/W3DView/GraphicView.cpp +++ b/Core/Tools/W3DView/GraphicView.cpp @@ -40,7 +40,7 @@ #include "ScreenCursor.h" #include "mesh.h" #include "coltest.h" -#include "MPU.H" +#include "MPU.h" #include "dazzle.h" #include "SoundScene.h" #include "WWAudio.h" @@ -329,8 +329,8 @@ CGraphicView::OnDestroy (void) // // Free the camera object // - MEMBER_RELEASE (m_pCamera); - MEMBER_RELEASE (m_pLightMesh); + REF_PTR_RELEASE (m_pCamera); + REF_PTR_RELEASE (m_pLightMesh); // Is there an update thread running? if (m_TimerID == 0) { @@ -388,7 +388,7 @@ Set_Lowest_LOD (RenderObjClass *render_obj) if (psub_obj != NULL) { Set_Lowest_LOD (psub_obj); } - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } // @@ -436,7 +436,8 @@ CGraphicView::RepaintView // Simple check to avoid re-entrance // static bool _already_painting = false; - if (_already_painting) return; + if (_already_painting) + return; _already_painting = true; // @@ -452,10 +453,15 @@ CGraphicView::RepaintView m_dwLastFrameUpdate = cur_ticks; // Update the W3D frame times according to our elapsed tick count - if (ticks_to_use == 0) { - WW3D::Sync (WW3D::Get_Sync_Time() + (ticks_elapsed * m_animationSpeed)); - } else { - WW3D::Sync (WW3D::Get_Sync_Time() + ticks_to_use); + if (ticks_to_use == 0) + { + WW3D::Update_Logic_Frame_Time(ticks_elapsed * m_animationSpeed); + WW3D::Sync(WW3D::Get_Fractional_Sync_Milliseconds() >= WWSyncMilliseconds); + } + else + { + WW3D::Update_Logic_Frame_Time(ticks_to_use); + WW3D::Sync(true); } // Do we need to update the current animation? @@ -546,7 +552,7 @@ CGraphicView::RepaintView // // Let the audio class think // - WWAudioClass::Get_Instance ()->On_Frame_Update (WW3D::Get_Frame_Time()); + WWAudioClass::Get_Instance ()->On_Frame_Update (WW3D::Get_Logic_Frame_Time_Milliseconds()); // // Update the count of particles and polys in the status bar @@ -1321,7 +1327,7 @@ CGraphicView::Load_Default_Dat (void) } // Concat the default.dat filename onto the path - ::strcat (filename, "\\default.dat"); + strlcat(filename, "\\default.dat", ARRAY_SIZE(filename)); // Does the file exist in the directory? if (::GetFileAttributes (filename) != 0xFFFFFFFF) { diff --git a/Core/Tools/W3DView/GraphicView.h b/Core/Tools/W3DView/GraphicView.h index 93c13fda5a..8a6faa8b5d 100644 --- a/Core/Tools/W3DView/GraphicView.h +++ b/Core/Tools/W3DView/GraphicView.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_GRAPHICVIEW_H__2BB39E41_5D3A_11D2_9FC6_00104B791122__INCLUDED_) -#define AFX_GRAPHICVIEW_H__2BB39E41_5D3A_11D2_9FC6_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // GraphicView.h : header file // @@ -259,5 +255,3 @@ class CGraphicView : public CView //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_GRAPHICVIEW_H__2BB39E41_5D3A_11D2_9FC6_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/HierarchyPropPage.h b/Core/Tools/W3DView/HierarchyPropPage.h index 6b622f4f75..bd70b4f939 100644 --- a/Core/Tools/W3DView/HierarchyPropPage.h +++ b/Core/Tools/W3DView/HierarchyPropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_HIERARCHYPROPPAGE_H__FB40246E_5DFB_11D2_9FC7_00104B791122__INCLUDED_) -#define AFX_HIERARCHYPROPPAGE_H__FB40246E_5DFB_11D2_9FC7_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // HierarchyPropPage.h : header file // @@ -70,5 +66,3 @@ class CHierarchyPropPage : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_HIERARCHYPROPPAGE_H__FB40246E_5DFB_11D2_9FC7_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/LODDefs.h b/Core/Tools/W3DView/LODDefs.h index 89df220e26..0d5602d521 100644 --- a/Core/Tools/W3DView/LODDefs.h +++ b/Core/Tools/W3DView/LODDefs.h @@ -34,10 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef __LODDEFS_H -#define __LODDEFS_H - +#pragma once //////////////////////////////////////////////////////////////////////////// // @@ -102,7 +99,3 @@ __inline bool Is_Model_Part_of_LOD (LPCTSTR name, LPCTSTR base, LOD_NAMING_TYPE // Return the true/false result ccde return retval; } - - -#endif //__LODDEFS_H - diff --git a/Core/Tools/W3DView/MainFrm.cpp b/Core/Tools/W3DView/MainFrm.cpp index ce8035a5a2..e27917e65f 100644 --- a/Core/Tools/W3DView/MainFrm.cpp +++ b/Core/Tools/W3DView/MainFrm.cpp @@ -687,7 +687,7 @@ CMainFrame::WindowProc // Concat the default.dat filename onto the path TCHAR full_path[MAX_PATH]; - ::strcat (filename, "\\settings"); + strlcat (filename, "\\settings", ARRAY_SIZE(filename)); ::wsprintf (full_path, "%s%d.dat", filename, (LOWORD(wParam) - IDM_SETTINGS1) + 1); // Does the file exist in the directory? diff --git a/Core/Tools/W3DView/MainFrm.h b/Core/Tools/W3DView/MainFrm.h index e3de025ae7..67652f0a10 100644 --- a/Core/Tools/W3DView/MainFrm.h +++ b/Core/Tools/W3DView/MainFrm.h @@ -20,12 +20,7 @@ // ///////////////////////////////////////////////////////////////////////////// -#if !defined(AFX_MAINFRM_H__2BB39E2F_5D3A_11D2_9FC6_00104B791122__INCLUDED_) -#define AFX_MAINFRM_H__2BB39E2F_5D3A_11D2_9FC6_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 #include "DataTreeView.h" #include "Toolbar.h" @@ -296,5 +291,3 @@ class CMainFrame : public CFrameWnd //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_MAINFRM_H__2BB39E2F_5D3A_11D2_9FC6_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/MeshPropPage.h b/Core/Tools/W3DView/MeshPropPage.h index aa7c5c7a38..4286b4ea33 100644 --- a/Core/Tools/W3DView/MeshPropPage.h +++ b/Core/Tools/W3DView/MeshPropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_MESHPROPPAGE_H__FB40246F_5DFB_11D2_9FC7_00104B791122__INCLUDED_) -#define AFX_MESHPROPPAGE_H__FB40246F_5DFB_11D2_9FC7_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // MeshPropPage.h : header file // @@ -70,5 +66,3 @@ class CMeshPropPage : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_MESHPROPPAGE_H__FB40246F_5DFB_11D2_9FC7_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/OpacitySettingsDialog.h b/Core/Tools/W3DView/OpacitySettingsDialog.h index bbd0c4c62a..f362a012e5 100644 --- a/Core/Tools/W3DView/OpacitySettingsDialog.h +++ b/Core/Tools/W3DView/OpacitySettingsDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_OPACITYSETTINGSDIALOG_H__52B0C804_0D48_11D3_A031_00104B791122__INCLUDED_) -#define AFX_OPACITYSETTINGSDIALOG_H__52B0C804_0D48_11D3_A031_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // OpacitySettingsDialog.h : header file // @@ -79,5 +75,3 @@ class OpacitySettingsDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_OPACITYSETTINGSDIALOG_H__52B0C804_0D48_11D3_A031_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/OpacityVectorDialog.h b/Core/Tools/W3DView/OpacityVectorDialog.h index c4963ff25c..d2cc35fd87 100644 --- a/Core/Tools/W3DView/OpacityVectorDialog.h +++ b/Core/Tools/W3DView/OpacityVectorDialog.h @@ -16,12 +16,7 @@ ** along with this program. If not, see . */ -#if !defined(AFX_OPACITYVECTORDIALOG_H__E86BBE8C_F527_11D3_A08F_00104B791122__INCLUDED_) -#define AFX_OPACITYVECTORDIALOG_H__E86BBE8C_F527_11D3_A08F_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #include "resource.h" #include "sphereobj.h" @@ -101,5 +96,3 @@ class OpacityVectorDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_OPACITYVECTORDIALOG_H__E86BBE8C_F527_11D3_A08F_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/ParticleBlurTimeKeyDialog.h b/Core/Tools/W3DView/ParticleBlurTimeKeyDialog.h index 3aedcec4bd..2339682a1e 100644 --- a/Core/Tools/W3DView/ParticleBlurTimeKeyDialog.h +++ b/Core/Tools/W3DView/ParticleBlurTimeKeyDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_PARTICLEBLURTIMEKEYDIALOG_H__FCCD7E5F_E09A_450E_A1A4_0E401CC00C3B__INCLUDED_) -#define AFX_PARTICLEBLURTIMEKEYDIALOG_H__FCCD7E5F_E09A_450E_A1A4_0E401CC00C3B__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // ParticleBlurTimeKeyDialog.h : header file // @@ -76,5 +72,3 @@ class ParticleBlurTimeKeyDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PARTICLEBLURTIMEKEYDIALOG_H__FCCD7E5F_E09A_450E_A1A4_0E401CC00C3B__INCLUDED_) diff --git a/Core/Tools/W3DView/ParticleFrameKeyDialog.h b/Core/Tools/W3DView/ParticleFrameKeyDialog.h index 4e4077dd1a..03f045ec1e 100644 --- a/Core/Tools/W3DView/ParticleFrameKeyDialog.h +++ b/Core/Tools/W3DView/ParticleFrameKeyDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_PARTICLEFRAMEKEYDIALOG_H__43470F6A_86E2_44CF_8ED9_EE9B74D35908__INCLUDED_) -#define AFX_PARTICLEFRAMEKEYDIALOG_H__43470F6A_86E2_44CF_8ED9_EE9B74D35908__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // ParticleFrameKeyDialog.h : header file // @@ -77,5 +73,3 @@ class ParticleFrameKeyDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PARTICLEFRAMEKEYDIALOG_H__43470F6A_86E2_44CF_8ED9_EE9B74D35908__INCLUDED_) diff --git a/Core/Tools/W3DView/ParticleRotationKeyDialog.h b/Core/Tools/W3DView/ParticleRotationKeyDialog.h index b28692aeb4..37df1e0f41 100644 --- a/Core/Tools/W3DView/ParticleRotationKeyDialog.h +++ b/Core/Tools/W3DView/ParticleRotationKeyDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_PARTICLEROTATIONKEYDIALOG_H__2B0B9CFD_19BC_4910_8AB2_813120740C69__INCLUDED_) -#define AFX_PARTICLEROTATIONKEYDIALOG_H__2B0B9CFD_19BC_4910_8AB2_813120740C69__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // ParticleRotationKeyDialog.h : header file // @@ -77,5 +73,3 @@ class ParticleRotationKeyDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PARTICLEROTATIONKEYDIALOG_H__2B0B9CFD_19BC_4910_8AB2_813120740C69__INCLUDED_) diff --git a/Core/Tools/W3DView/ParticleSizeDialog.h b/Core/Tools/W3DView/ParticleSizeDialog.h index d9bee76924..80bb2be66a 100644 --- a/Core/Tools/W3DView/ParticleSizeDialog.h +++ b/Core/Tools/W3DView/ParticleSizeDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_PARTICLESIZEDIALOG_H__0CD2CBA5_1219_11D3_A034_00104B791122__INCLUDED_) -#define AFX_PARTICLESIZEDIALOG_H__0CD2CBA5_1219_11D3_A034_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // ParticleSizeDialog.h : header file // @@ -76,5 +72,3 @@ class ParticleSizeDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PARTICLESIZEDIALOG_H__0CD2CBA5_1219_11D3_A034_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/PlaySoundDialog.cpp b/Core/Tools/W3DView/PlaySoundDialog.cpp index 78ec632014..a15b28e23a 100644 --- a/Core/Tools/W3DView/PlaySoundDialog.cpp +++ b/Core/Tools/W3DView/PlaySoundDialog.cpp @@ -100,7 +100,7 @@ void PlaySoundDialogClass::OnCancel (void) { SoundObj->Stop (); - MEMBER_RELEASE (SoundObj); + REF_PTR_RELEASE (SoundObj); CDialog::OnCancel (); return ; diff --git a/Core/Tools/W3DView/PlaySoundDialog.h b/Core/Tools/W3DView/PlaySoundDialog.h index a0f367cb38..eed77d841b 100644 --- a/Core/Tools/W3DView/PlaySoundDialog.h +++ b/Core/Tools/W3DView/PlaySoundDialog.h @@ -16,12 +16,7 @@ ** along with this program. If not, see . */ -#if !defined(AFX_PLAYSOUNDDIALOG_H__AD61372C_2DA3_11D3_A042_00104B791122__INCLUDED_) -#define AFX_PLAYSOUNDDIALOG_H__AD61372C_2DA3_11D3_A042_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #include "resource.h" #include "WWAudio.h" @@ -71,5 +66,3 @@ class PlaySoundDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_PLAYSOUNDDIALOG_H__AD61372C_2DA3_11D3_A042_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/ResolutionDialog.h b/Core/Tools/W3DView/ResolutionDialog.h index fb06eecfcf..b826814f73 100644 --- a/Core/Tools/W3DView/ResolutionDialog.h +++ b/Core/Tools/W3DView/ResolutionDialog.h @@ -16,12 +16,7 @@ ** along with this program. If not, see . */ -#if !defined(AFX_RESOLUTIONDIALOG_H__6DB2FE81_D8CD_11D3_A086_00104B791122__INCLUDED_) -#define AFX_RESOLUTIONDIALOG_H__6DB2FE81_D8CD_11D3_A086_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #include "resource.h" @@ -83,5 +78,3 @@ class ResolutionDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_RESOLUTIONDIALOG_H__6DB2FE81_D8CD_11D3_A086_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/RestrictedFileDialog.h b/Core/Tools/W3DView/RestrictedFileDialog.h index c83561c0c2..2c4e7640e5 100644 --- a/Core/Tools/W3DView/RestrictedFileDialog.h +++ b/Core/Tools/W3DView/RestrictedFileDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_RESTRICTEDFILEDIALOG_H__C461432A_D7EE_11D2_A00A_00104B791122__INCLUDED_) -#define AFX_RESTRICTEDFILEDIALOG_H__C461432A_D7EE_11D2_A00A_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // RestrictedFileDialog.h : header file // @@ -56,5 +52,3 @@ class RestrictedFileDialogClass : public CFileDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_RESTRICTEDFILEDIALOG_H__C461432A_D7EE_11D2_A00A_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/RingColorPropPage.h b/Core/Tools/W3DView/RingColorPropPage.h index c0a8976f2f..63bd6d40a6 100644 --- a/Core/Tools/W3DView/RingColorPropPage.h +++ b/Core/Tools/W3DView/RingColorPropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_RINGCOLORPROPPAGE_H__E86BBE86_F527_11D3_A08F_00104B791122__INCLUDED_) -#define AFX_RINGCOLORPROPPAGE_H__E86BBE86_F527_11D3_A08F_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // RingColorPropPage.h : header file // @@ -113,6 +109,3 @@ class RingColorPropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_RINGCOLORPROPPAGE_H__E86BBE86_F527_11D3_A08F_00104B791122__INCLUDED_) - diff --git a/Core/Tools/W3DView/RingGeneralPropPage.h b/Core/Tools/W3DView/RingGeneralPropPage.h index 42237a335c..c09517824a 100644 --- a/Core/Tools/W3DView/RingGeneralPropPage.h +++ b/Core/Tools/W3DView/RingGeneralPropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_RINGGENERALPROPPAGE_H__E86BBE83_F527_11D3_A08F_00104B791122__INCLUDED_) -#define AFX_RINGGENERALPROPPAGE_H__E86BBE83_F527_11D3_A08F_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // RingGeneralPropPage.h : header file // @@ -118,5 +114,3 @@ class RingGeneralPropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_RINGGENERALPROPPAGE_H__E86BBE83_F527_11D3_A08F_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/RingPropertySheet.cpp b/Core/Tools/W3DView/RingPropertySheet.cpp index d4e89914c9..51ca2e8a78 100644 --- a/Core/Tools/W3DView/RingPropertySheet.cpp +++ b/Core/Tools/W3DView/RingPropertySheet.cpp @@ -51,7 +51,7 @@ RingPropertySheetClass::RingPropertySheetClass : m_RenderObj (NULL), CPropertySheet(nIDCaption, pParentWnd, iSelectPage) { - MEMBER_ADD (m_RenderObj, ring); + REF_PTR_SET (m_RenderObj, ring); Initialize (); return ; } @@ -72,7 +72,7 @@ RingPropertySheetClass::RingPropertySheetClass : m_RenderObj (NULL), CPropertySheet(pszCaption, pParentWnd, iSelectPage) { - MEMBER_ADD (m_RenderObj, ring); + REF_PTR_SET (m_RenderObj, ring); Initialize (); return ; } @@ -85,7 +85,7 @@ RingPropertySheetClass::RingPropertySheetClass ///////////////////////////////////////////////////////////////////////////// RingPropertySheetClass::~RingPropertySheetClass (void) { - MEMBER_RELEASE (m_RenderObj); + REF_PTR_RELEASE (m_RenderObj); return ; } @@ -204,7 +204,7 @@ RingPropertySheetClass::Add_Object_To_Viewer (void) // doc->Reload_Displayed_Object (); m_LastSavedName = m_RenderObj->Get_Name (); - MEMBER_ADD (m_RenderObj, (RingRenderObjClass *)doc->GetDisplayedObject ()); + REF_PTR_SET (m_RenderObj, (RingRenderObjClass *)doc->GetDisplayedObject ()); // // Pass the object along to the pages diff --git a/Core/Tools/W3DView/RingPropertySheet.h b/Core/Tools/W3DView/RingPropertySheet.h index 02f0ab87d5..d221010715 100644 --- a/Core/Tools/W3DView/RingPropertySheet.h +++ b/Core/Tools/W3DView/RingPropertySheet.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __RING_PROPERTY_SHEET_H -#define __RING_PROPERTY_SHEET_H #include "RingColorPropPage.h" #include "RingGeneralPropPage.h" @@ -120,5 +114,3 @@ class RingPropertySheetClass : public CPropertySheet }; ///////////////////////////////////////////////////////////////////////////// - -#endif //__RING_PROPERTY_SHEET_H diff --git a/Core/Tools/W3DView/RingSizePropPage.h b/Core/Tools/W3DView/RingSizePropPage.h index 9666f1091c..22def9c8f5 100644 --- a/Core/Tools/W3DView/RingSizePropPage.h +++ b/Core/Tools/W3DView/RingSizePropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_RINGSIZEPROPPAGE_H__E86BBE8A_F527_11D3_A08F_00104B791122__INCLUDED_) -#define AFX_RINGSIZEPROPPAGE_H__E86BBE8A_F527_11D3_A08F_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // RingSizePropPage.h : header file // @@ -122,5 +118,3 @@ class RingSizePropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_RINGSIZEPROPPAGE_H__E86BBE8A_F527_11D3_A08F_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/SaveSettingsDialog.h b/Core/Tools/W3DView/SaveSettingsDialog.h index 3ac3d1dd5a..859caeda99 100644 --- a/Core/Tools/W3DView/SaveSettingsDialog.h +++ b/Core/Tools/W3DView/SaveSettingsDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_SAVESETTINGSDIALOG_H__AF3CDE8D_61EC_11D2_9FC7_00104B791122__INCLUDED_) -#define AFX_SAVESETTINGSDIALOG_H__AF3CDE8D_61EC_11D2_9FC7_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // SaveSettingsDialog.h : header file // @@ -67,5 +63,3 @@ class CSaveSettingsDialog : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SAVESETTINGSDIALOG_H__AF3CDE8D_61EC_11D2_9FC7_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/ScaleDialog.h b/Core/Tools/W3DView/ScaleDialog.h index 3e3fec2d4d..f01746b3c5 100644 --- a/Core/Tools/W3DView/ScaleDialog.h +++ b/Core/Tools/W3DView/ScaleDialog.h @@ -16,13 +16,7 @@ ** along with this program. If not, see . */ -#if !defined(AFX_SCALEDIALOG_H__E86BBE8B_F527_11D3_A08F_00104B791122__INCLUDED_) -#define AFX_SCALEDIALOG_H__E86BBE8B_F527_11D3_A08F_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 - #include "resource.h" @@ -81,5 +75,3 @@ class ScaleDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SCALEDIALOG_H__E86BBE8B_F527_11D3_A08F_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/SceneLightDialog.h b/Core/Tools/W3DView/SceneLightDialog.h index ceecbb7cc9..0dc4c05a1d 100644 --- a/Core/Tools/W3DView/SceneLightDialog.h +++ b/Core/Tools/W3DView/SceneLightDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_SCENELIGHTDIALOG_H__AF3CDE89_61EC_11D2_9FC7_00104B791122__INCLUDED_) -#define AFX_SCENELIGHTDIALOG_H__AF3CDE89_61EC_11D2_9FC7_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 + // SceneLightDialog.h : header file // @@ -122,5 +118,3 @@ class CSceneLightDialog : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SCENELIGHTDIALOG_H__AF3CDE89_61EC_11D2_9FC7_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/ScreenCursor.cpp b/Core/Tools/W3DView/ScreenCursor.cpp index 8b8d67f0a0..28917a34f4 100644 --- a/Core/Tools/W3DView/ScreenCursor.cpp +++ b/Core/Tools/W3DView/ScreenCursor.cpp @@ -153,7 +153,7 @@ ScreenCursorClass::Initialize (void) void ScreenCursorClass::Set_Texture (TextureClass *texture) { - MEMBER_ADD (m_pTexture, texture); + REF_PTR_SET (m_pTexture, texture); // Find the dimensions of the texture: if (m_pTexture != NULL) { diff --git a/Core/Tools/W3DView/ScreenCursor.h b/Core/Tools/W3DView/ScreenCursor.h index 2b62c92175..3227d2ddd9 100644 --- a/Core/Tools/W3DView/ScreenCursor.h +++ b/Core/Tools/W3DView/ScreenCursor.h @@ -30,14 +30,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - -#ifndef __SCREENCURSOR_H -#define __SCREENCURSOR_H #include "resource.h" #include "rendobj.h" @@ -111,6 +104,3 @@ class ScreenCursorClass : public RenderObjClass int m_Width; int m_Height; }; - - -#endif //__SCREENCURSOR_H diff --git a/Core/Tools/W3DView/SoundEditDialog.h b/Core/Tools/W3DView/SoundEditDialog.h index dc0b99a48c..6cf71c059f 100644 --- a/Core/Tools/W3DView/SoundEditDialog.h +++ b/Core/Tools/W3DView/SoundEditDialog.h @@ -16,13 +16,7 @@ ** along with this program. If not, see . */ -#if !defined(AFX_SOUNDEDITDIALOG_H__376FEA4C_0A53_44FB_A6B5_DF0E96CF1DEF__INCLUDED_) -#define AFX_SOUNDEDITDIALOG_H__376FEA4C_0A53_44FB_A6B5_DF0E96CF1DEF__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 - #include "wwstring.h" #include "resource.h" @@ -113,5 +107,3 @@ class SoundEditDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SOUNDEDITDIALOG_H__376FEA4C_0A53_44FB_A6B5_DF0E96CF1DEF__INCLUDED_) diff --git a/Core/Tools/W3DView/SphereColorPropPage.h b/Core/Tools/W3DView/SphereColorPropPage.h index 60e5ddf00c..a461d862c7 100644 --- a/Core/Tools/W3DView/SphereColorPropPage.h +++ b/Core/Tools/W3DView/SphereColorPropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_SPHERECOLORPROPPAGE_H__E86BBE86_F527_11D3_A08F_00104B791122__INCLUDED_) -#define AFX_SPHERECOLORPROPPAGE_H__E86BBE86_F527_11D3_A08F_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // SphereColorPropPage.h : header file // @@ -122,6 +118,3 @@ class SphereColorPropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SPHERECOLORPROPPAGE_H__E86BBE86_F527_11D3_A08F_00104B791122__INCLUDED_) - diff --git a/Core/Tools/W3DView/SphereGeneralPropPage.h b/Core/Tools/W3DView/SphereGeneralPropPage.h index 923fa2011d..f3e3c919ed 100644 --- a/Core/Tools/W3DView/SphereGeneralPropPage.h +++ b/Core/Tools/W3DView/SphereGeneralPropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_SPHEREGENERALPROPPAGE_H__E86BBE83_F527_11D3_A08F_00104B791122__INCLUDED_) -#define AFX_SPHEREGENERALPROPPAGE_H__E86BBE83_F527_11D3_A08F_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // SphereGeneralPropPage.h : header file // @@ -116,5 +112,3 @@ class SphereGeneralPropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SPHEREGENERALPROPPAGE_H__E86BBE83_F527_11D3_A08F_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/SpherePropertySheet.cpp b/Core/Tools/W3DView/SpherePropertySheet.cpp index cdeaa7de6f..400f73d631 100644 --- a/Core/Tools/W3DView/SpherePropertySheet.cpp +++ b/Core/Tools/W3DView/SpherePropertySheet.cpp @@ -51,7 +51,7 @@ SpherePropertySheetClass::SpherePropertySheetClass : m_RenderObj (NULL), CPropertySheet(nIDCaption, pParentWnd, iSelectPage) { - MEMBER_ADD (m_RenderObj, sphere); + REF_PTR_SET (m_RenderObj, sphere); Initialize (); return ; } @@ -72,7 +72,7 @@ SpherePropertySheetClass::SpherePropertySheetClass : m_RenderObj (NULL), CPropertySheet(pszCaption, pParentWnd, iSelectPage) { - MEMBER_ADD (m_RenderObj, sphere); + REF_PTR_SET (m_RenderObj, sphere); Initialize (); return ; } @@ -85,7 +85,7 @@ SpherePropertySheetClass::SpherePropertySheetClass ///////////////////////////////////////////////////////////////////////////// SpherePropertySheetClass::~SpherePropertySheetClass (void) { - MEMBER_RELEASE (m_RenderObj); + REF_PTR_RELEASE (m_RenderObj); return ; } @@ -204,7 +204,7 @@ SpherePropertySheetClass::Add_Object_To_Viewer (void) // doc->Reload_Displayed_Object (); m_LastSavedName = m_RenderObj->Get_Name (); - MEMBER_ADD (m_RenderObj, (SphereRenderObjClass *)doc->GetDisplayedObject ()); + REF_PTR_SET (m_RenderObj, (SphereRenderObjClass *)doc->GetDisplayedObject ()); // // Pass the object along to the pages diff --git a/Core/Tools/W3DView/SpherePropertySheet.h b/Core/Tools/W3DView/SpherePropertySheet.h index 416433d1e1..65b9a5777c 100644 --- a/Core/Tools/W3DView/SpherePropertySheet.h +++ b/Core/Tools/W3DView/SpherePropertySheet.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SPHERE_PROPERTY_SHEET_H -#define __SPHERE_PROPERTY_SHEET_H #include "SphereColorPropPage.h" #include "SphereGeneralPropPage.h" @@ -120,5 +114,3 @@ class SpherePropertySheetClass : public CPropertySheet }; ///////////////////////////////////////////////////////////////////////////// - -#endif //__SPHERE_PROPERTY_SHEET_H diff --git a/Core/Tools/W3DView/SphereSizePropPage.h b/Core/Tools/W3DView/SphereSizePropPage.h index c5d0ff9ad5..ac6657054e 100644 --- a/Core/Tools/W3DView/SphereSizePropPage.h +++ b/Core/Tools/W3DView/SphereSizePropPage.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_SPHERESIZEPROPPAGE_H__E86BBE8A_F527_11D3_A08F_00104B791122__INCLUDED_) -#define AFX_SPHERESIZEPROPPAGE_H__E86BBE8A_F527_11D3_A08F_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // SphereSizePropPage.h : header file // @@ -114,5 +110,3 @@ class SphereSizePropPageClass : public CPropertyPage //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_SPHERESIZEPROPPAGE_H__E86BBE8A_F527_11D3_A08F_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/SphereUtils.h b/Core/Tools/W3DView/SphereUtils.h index 3bb429786c..cb60d55545 100644 --- a/Core/Tools/W3DView/SphereUtils.h +++ b/Core/Tools/W3DView/SphereUtils.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __SPHERE_UTILS -#define __SPHERE_UTILS #include "sphereobj.h" @@ -91,7 +86,3 @@ class SphereKeysClass int m_KeyCount; int m_MaxKeys; }; - - -#endif //__SPHERE_UTILS - diff --git a/Core/Tools/W3DView/StdAfx.h b/Core/Tools/W3DView/StdAfx.h index 12e973759a..c95bcb3a63 100644 --- a/Core/Tools/W3DView/StdAfx.h +++ b/Core/Tools/W3DView/StdAfx.h @@ -21,12 +21,7 @@ // are changed infrequently // -#if !defined(AFX_STDAFX_H__2BB39E2D_5D3A_11D2_9FC6_00104B791122__INCLUDED_) -#define AFX_STDAFX_H__2BB39E2D_5D3A_11D2_9FC6_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers @@ -43,5 +38,3 @@ //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__2BB39E2D_5D3A_11D2_9FC6_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/TextureMgrDialog.cpp b/Core/Tools/W3DView/TextureMgrDialog.cpp index 8537be6741..a639372773 100644 --- a/Core/Tools/W3DView/TextureMgrDialog.cpp +++ b/Core/Tools/W3DView/TextureMgrDialog.cpp @@ -35,13 +35,13 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#include "StdAfx.H" -#include "W3DView.H" -#include "TextureMgrDialog.H" -#include "Mesh.H" -#include "MatInfo.H" -#include "TextureSettingsDialog.H" -#include "AssetMgr.H" +#include "StdAfx.h" +#include "W3DView.h" +#include "TextureMgrDialog.h" +#include "Mesh.h" +#include "MatInfo.h" +#include "TextureSettingsDialog.h" +#include "AssetMgr.h" #include "texture.h" @@ -283,7 +283,7 @@ TextureMgrDialogClass::Add_Subobjs_To_List (RenderObjClass *prender_obj) // Recursively add subobjs to the list Add_Subobjs_To_List (psubobj); - MEMBER_RELEASE (psubobj); + REF_PTR_RELEASE (psubobj); } } @@ -336,7 +336,7 @@ TextureMgrDialogClass::Add_Textures_To_Node } // Release our hold on this pointer - MEMBER_RELEASE (pmat_info); + REF_PTR_RELEASE (pmat_info); } return ; @@ -438,7 +438,7 @@ TextureMgrDialogClass::OnDblclkMeshTextureListCtrl SR_RELEASE (poriginal_texture); } - MEMBER_RELEASE (pmat_info); + REF_PTR_RELEASE (pmat_info); } } diff --git a/Core/Tools/W3DView/TextureMgrDialog.h b/Core/Tools/W3DView/TextureMgrDialog.h index 2fd56a7fd0..1e109aa479 100644 --- a/Core/Tools/W3DView/TextureMgrDialog.h +++ b/Core/Tools/W3DView/TextureMgrDialog.h @@ -34,18 +34,13 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if !defined(AFX_TEXTUREMGRDIALOG_H__3F61844D_CDEA_11D2_9FFC_00104B791122__INCLUDED_) -#define AFX_TEXTUREMGRDIALOG_H__3F61844D_CDEA_11D2_9FFC_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 -#include "Vector.H" -#include "RendObj.H" -#include "Utils.H" -#include "Resource.H" -#include "DialogToolbar.H" +#include "Vector.h" +#include "RendObj.h" +#include "Utils.h" +#include "Resource.h" +#include "DialogToolbar.h" #include "texture.h" // Forward declarations @@ -96,9 +91,9 @@ class TextureListNodeClass m_pParent (NULL), m_Name (name), m_TextureIndex (0), - m_IconIndex (ICON_DEF_TEXTURE) { MEMBER_ADD (m_pTexture, ptexture); } + m_IconIndex (ICON_DEF_TEXTURE) { REF_PTR_SET (m_pTexture, ptexture); } - ~TextureListNodeClass (void) { MEMBER_RELEASE (m_pTexture); Free_Subobj_List (); } + ~TextureListNodeClass (void) { REF_PTR_RELEASE (m_pTexture); Free_Subobj_List (); } //////////////////////////////////////////////////////////// @@ -112,7 +107,7 @@ class TextureListNodeClass void Set_Type (NODE_TYPE type) { m_Type = type; } TextureClass * Peek_Texture (void) const { return m_pTexture; } - void Set_Texture (TextureClass *ptex) { MEMBER_ADD (m_pTexture, ptex); } + void Set_Texture (TextureClass *ptex) { REF_PTR_SET (m_pTexture, ptex); } TEXTURE_NODE_LIST & Get_Subobj_List (void) { return m_SubObjectList; } @@ -251,5 +246,3 @@ class TextureMgrDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_TEXTUREMGRDIALOG_H__3F61844D_CDEA_11D2_9FFC_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/TexturePathDialog.h b/Core/Tools/W3DView/TexturePathDialog.h index b7a24d4a11..0d83bfe3df 100644 --- a/Core/Tools/W3DView/TexturePathDialog.h +++ b/Core/Tools/W3DView/TexturePathDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_TEXTUREPATHDIALOG_H__FD455E37_D28C_11D3_A085_00104B791122__INCLUDED_) -#define AFX_TEXTUREPATHDIALOG_H__FD455E37_D28C_11D3_A085_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // TexturePathDialog.h : header file // @@ -63,5 +59,3 @@ class TexturePathDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_TEXTUREPATHDIALOG_H__FD455E37_D28C_11D3_A085_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/TextureSettingsDialog.cpp b/Core/Tools/W3DView/TextureSettingsDialog.cpp index fd89eb9322..6413def588 100644 --- a/Core/Tools/W3DView/TextureSettingsDialog.cpp +++ b/Core/Tools/W3DView/TextureSettingsDialog.cpp @@ -31,12 +31,12 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#include "StdAfx.H" -#include "Texture.H" -#include "W3DView.H" -#include "TextureSettingsDialog.H" -#include "Utils.H" -#include "AssetMgr.H" +#include "StdAfx.h" +#include "Texture.h" +#include "W3DView.h" +#include "TextureSettingsDialog.h" +#include "Utils.h" +#include "AssetMgr.h" /*#ifdef RTS_DEBUG #define new DEBUG_NEW @@ -79,8 +79,8 @@ TextureSettingsDialogClass::TextureSettingsDialogClass { //{{AFX_DATA_INIT(TextureSettingsDialogClass) //}}AFX_DATA_INIT - MEMBER_ADD (m_pTexture, ptexture); - MEMBER_ADD (m_pOriginalTexture, poriginal_texture); + REF_PTR_SET (m_pTexture, ptexture); + REF_PTR_SET (m_pOriginalTexture, poriginal_texture); return ; } @@ -528,7 +528,7 @@ TextureSettingsDialogClass::OnRestore (void) // Get the original texture TextureClass *pnew_texture = m_pOriginalTexture->Get_Texture (); m_pTexture->Set_Texture (pnew_texture); - MEMBER_RELEASE (pnew_texture); + REF_PTR_RELEASE (pnew_texture); // Reload the dialog control settings Load_Texture_Settings (); diff --git a/Core/Tools/W3DView/TextureSettingsDialog.h b/Core/Tools/W3DView/TextureSettingsDialog.h index c507d71ba9..ba443b4b0c 100644 --- a/Core/Tools/W3DView/TextureSettingsDialog.h +++ b/Core/Tools/W3DView/TextureSettingsDialog.h @@ -30,19 +30,14 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if !defined(AFX_TEXTURESETTINGSDIALOG_H__362C7398_D199_11D2_9FFD_00104B791122__INCLUDED_) -#define AFX_TEXTURESETTINGSDIALOG_H__362C7398_D199_11D2_9FFD_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #ifdef WW3D_DX8 // Forward delcarations class TextureClass; -#include "Resource.H" +#include "Resource.h" ///////////////////////////////////////////////////////////////////////////// // @@ -125,5 +120,3 @@ class TextureSettingsDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_TEXTURESETTINGSDIALOG_H__362C7398_D199_11D2_9FFD_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/Toolbar.cpp b/Core/Tools/W3DView/Toolbar.cpp index e9682de79f..b252d74647 100644 --- a/Core/Tools/W3DView/Toolbar.cpp +++ b/Core/Tools/W3DView/Toolbar.cpp @@ -18,7 +18,7 @@ ////////////////////////////////////////////////////////////////////// // -// Toolbar.CPP +// Toolbar.cpp // // Implementation of a 'fancy' toolbar using hi-color buttons // diff --git a/Core/Tools/W3DView/Toolbar.h b/Core/Tools/W3DView/Toolbar.h index c574836c88..527c2a1537 100644 --- a/Core/Tools/W3DView/Toolbar.h +++ b/Core/Tools/W3DView/Toolbar.h @@ -18,14 +18,12 @@ ////////////////////////////////////////////////////////////////////// // -// Toolbar.H +// Toolbar.h // // Declaration of a 'fancy' toolbar using hi-color buttons // -#ifndef __FANCYTOOLBAR_H -#define __FANCYTOOLBAR_H - +#pragma once ////////////////////////////////////////////////////////////// // @@ -164,5 +162,3 @@ class CFancyToolbar : public CControlBar int m_iButtons; int m_iCurrentButton; }; - -#endif // __FANCYTOOLBAR_H diff --git a/Core/Tools/W3DView/Utils.cpp b/Core/Tools/W3DView/Utils.cpp index b5ec8953cd..95ed99ff0b 100644 --- a/Core/Tools/W3DView/Utils.cpp +++ b/Core/Tools/W3DView/Utils.cpp @@ -18,7 +18,7 @@ ///////////////////////////////////////////////////////////////////////////// // -// Utils.CPP +// Utils.cpp // // Module containing usefull misc. utility functions // @@ -33,7 +33,7 @@ #include "assetmgr.h" #include "agg_def.h" #include "hlod.h" -#include +#include #include "rcfile.h" @@ -559,7 +559,7 @@ Build_Emitter_List // Recursivly add emitters to the list Build_Emitter_List (*psub_obj, list); - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } } @@ -586,7 +586,7 @@ Is_Aggregate (const char *asset_name) } // Free our hold on the temporary render object - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); // Return the true/false result code return retval; @@ -649,7 +649,7 @@ Is_Real_LOD (const char *asset_name) } // Free our hold on the temporary render object - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); // Return the true/false result code return retval; diff --git a/Core/Tools/W3DView/Utils.h b/Core/Tools/W3DView/Utils.h index c8346d6fb7..afd07056a7 100644 --- a/Core/Tools/W3DView/Utils.h +++ b/Core/Tools/W3DView/Utils.h @@ -18,15 +18,14 @@ ///////////////////////////////////////////////////////////////////////////// // -// Utils.H +// Utils.h // // Module containing usefull misc. utility functions // -#ifndef __UTILS_H -#define __UTILS_H +#pragma once -#include "Vector.H" +#include "Vector.h" // Forward declarations class RenderObjClass; @@ -36,38 +35,8 @@ class RenderObjClass; // // Macros // -#define SAFE_DELETE(pobject) \ - if (pobject) { \ - delete pobject; \ - pobject = NULL; \ - } \ - -#define SAFE_DELETE_ARRAY(pobject) \ - if (pobject) { \ - delete [] pobject; \ - pobject = NULL; \ - } \ - -#define SAFE_ADD_REF(pobject) \ - if (pobject) { \ - pobject->Add_Ref (); \ - } \ - -#define SAFE_RELEASE_REF(pobject) \ - if (pobject) { \ - pobject->Release_Ref (); \ - } \ - -#define MEMBER_RELEASE(pmember) \ - SAFE_RELEASE_REF(pmember); \ - pmember = NULL; \ - - -#define MEMBER_ADD(pmember, pnew) \ - MEMBER_RELEASE (pmember); \ - pmember = pnew; \ - SAFE_ADD_REF (pmember); \ - +#define SAFE_DELETE(pobject) { delete pobject; pobject = NULL; } +#define SAFE_DELETE_ARRAY(pobject) { delete [] pobject; pobject = NULL; } #define COM_RELEASE(pobject) \ if (pobject) { \ @@ -167,5 +136,3 @@ bool Is_Real_LOD (const char *asset_name); // Prototype routines void Rename_Aggregate_Prototype (const char *old_name, const char *new_name); - -#endif //__UTILS_H diff --git a/Core/Tools/W3DView/Vector3RndCombo.cpp b/Core/Tools/W3DView/Vector3RndCombo.cpp index 658e61d1f9..5cc5ca992d 100644 --- a/Core/Tools/W3DView/Vector3RndCombo.cpp +++ b/Core/Tools/W3DView/Vector3RndCombo.cpp @@ -32,7 +32,7 @@ #include "StdAfx.h" -#include "Vector3RndCombo.H" +#include "Vector3RndCombo.h" #include "v3_rnd.h" const char * const RANDOMIZER_NAMES[Vector3Randomizer::CLASSID_MAXKNOWN] = diff --git a/Core/Tools/W3DView/Vector3RndCombo.H b/Core/Tools/W3DView/Vector3RndCombo.h similarity index 93% rename from Core/Tools/W3DView/Vector3RndCombo.H rename to Core/Tools/W3DView/Vector3RndCombo.h index 2162234b47..e2adc4bb63 100644 --- a/Core/Tools/W3DView/Vector3RndCombo.H +++ b/Core/Tools/W3DView/Vector3RndCombo.h @@ -22,7 +22,7 @@ * * * Project Name : WW3DView * * * - * $Archive:: /Commando/Code/Tools/W3DView/Vector3RndCombo.H $Modtime:: $* + * $Archive:: /Commando/Code/Tools/W3DView/Vector3RndCombo.h $Modtime:: $* * * * $Revision:: 2 $* * * @@ -30,13 +30,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __VECTOR3RND_COMBO_H -#define __VECTOR3RND_COMBO_H // Forward declarations class Vector3Randomizer; @@ -50,5 +44,3 @@ class Vector3; void Fill_Vector3_Rnd_Combo (HWND hcombobox); Vector3Randomizer * Vector3_Rnd_From_Combo_Index (int index, float value1, float value2 = 0, float value3 = 0); int Combo_Index_From_Vector3_Rnd (Vector3Randomizer *randomizer); - -#endif //__VECTOR3RND_COMBO_H diff --git a/Core/Tools/W3DView/ViewerAssetMgr.h b/Core/Tools/W3DView/ViewerAssetMgr.h index 34aa25bda0..3025ccbfbe 100644 --- a/Core/Tools/W3DView/ViewerAssetMgr.h +++ b/Core/Tools/W3DView/ViewerAssetMgr.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __VIEWER_ASSETMGR_H -#define __VIEWER_ASSETMGR_H #include "assetmgr.h" @@ -89,6 +84,3 @@ class ViewerAssetMgrClass : public WW3DAssetManager /////////////////////////////////////////////////// DynamicVectorClass m_MissingTextureList; }; - - -#endif //__VIEWER_ASSETMGR_H diff --git a/Core/Tools/W3DView/ViewerScene.h b/Core/Tools/W3DView/ViewerScene.h index 1ea535f590..aac9078201 100644 --- a/Core/Tools/W3DView/ViewerScene.h +++ b/Core/Tools/W3DView/ViewerScene.h @@ -34,14 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - - -#ifndef __VIEWER_SCENE_H -#define __VIEWER_SCENE_H #include "scene.h" #include "aabox.h" @@ -113,6 +106,3 @@ class ViewerSceneClass : public SimpleSceneClass RefRenderObjListClass LineUpList; RefRenderObjListClass LightList; }; - - -#endif //__VIEWER_SCENE_H diff --git a/Core/Tools/W3DView/VolumeRandomDialog.h b/Core/Tools/W3DView/VolumeRandomDialog.h index 9eaa20bb42..10956f3122 100644 --- a/Core/Tools/W3DView/VolumeRandomDialog.h +++ b/Core/Tools/W3DView/VolumeRandomDialog.h @@ -16,12 +16,8 @@ ** along with this program. If not, see . */ -#if !defined(AFX_VOLUMERANDOMDIALOG_H__F22DB07B_0EFF_11D3_A034_00104B791122__INCLUDED_) -#define AFX_VOLUMERANDOMDIALOG_H__F22DB07B_0EFF_11D3_A034_00104B791122__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 + // VolumeRandomDialog.h : header file // @@ -96,5 +92,3 @@ class VolumeRandomDialogClass : public CDialog //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_VOLUMERANDOMDIALOG_H__F22DB07B_0EFF_11D3_A034_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/W3DView.cpp b/Core/Tools/W3DView/W3DView.cpp index b47499162d..89205622fd 100644 --- a/Core/Tools/W3DView/W3DView.cpp +++ b/Core/Tools/W3DView/W3DView.cpp @@ -318,7 +318,7 @@ void CW3DViewApp::OnAppAbout() */ void Debug_Refs(void) { -#ifndef NDEBUG +#ifdef RTS_DEBUG TRACE("Detecting Active Refs...\r\n"); //ODS("At time %s", cMiscUtil::Get_Text_Time()); RefCountNodeClass * first = RefCountClass::ActiveRefList.First(); @@ -344,7 +344,7 @@ void Debug_Refs(void) ActiveRefStruct * search_ref = &(search_obj->ActiveRefInfo); if ( ref->File && search_ref->File && - !strcmp(search_ref->File, ref->File) && + strcmp(search_ref->File, ref->File) == 0 && (search_ref->Line == ref->Line) ) { count++; } else if ( (ref->File == NULL) && (search_ref->File == NULL) ) { @@ -368,7 +368,7 @@ void Debug_Refs(void) } TRACE("Done.\r\n"); //ODS("At time %s", cMiscUtil::Get_Text_Time()); -#endif +#endif // RTS_DEBUG } diff --git a/Core/Tools/W3DView/W3DView.h b/Core/Tools/W3DView/W3DView.h index dce9ed9226..e7e3f1bde3 100644 --- a/Core/Tools/W3DView/W3DView.h +++ b/Core/Tools/W3DView/W3DView.h @@ -19,12 +19,7 @@ // W3DView.h : main header file for the W3DVIEW application // -#if !defined(AFX_W3DVIEW_H__2BB39E2B_5D3A_11D2_9FC6_00104B791122__INCLUDED_) -#define AFX_W3DVIEW_H__2BB39E2B_5D3A_11D2_9FC6_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 #ifndef __AFXWIN_H__ #error include 'stdafx.h' before including this file for PCH @@ -68,5 +63,3 @@ class CW3DViewApp : public CWinApp //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_W3DVIEW_H__2BB39E2B_5D3A_11D2_9FC6_00104B791122__INCLUDED_) diff --git a/Core/Tools/W3DView/W3DViewDoc.cpp b/Core/Tools/W3DView/W3DViewDoc.cpp index 054008126e..1594b53859 100644 --- a/Core/Tools/W3DView/W3DViewDoc.cpp +++ b/Core/Tools/W3DView/W3DViewDoc.cpp @@ -35,7 +35,7 @@ #include "light.h" #include "camera.h" #include "w3d_file.h" -#include "WWFILE.H" +#include "WWFILE.h" #include "bmp2d.h" #include "part_emt.h" #include "part_ldr.h" @@ -48,7 +48,7 @@ #include "hlod.h" #include "RestrictedFileDialog.h" #include "ViewerScene.h" -#include "INI.H" +#include "INI.h" #include "ww3d.h" #include "EmitterInstanceList.h" #include "mesh.h" @@ -130,7 +130,7 @@ CW3DViewDoc::CW3DViewDoc (void) CW3DViewDoc::~CW3DViewDoc (void) { CleanupResources (); - MEMBER_RELEASE (m_pCursor); + REF_PTR_RELEASE (m_pCursor); return ; } @@ -172,7 +172,7 @@ CW3DViewDoc::CleanupResources (void) if (m_pCursor != NULL) { m_pCursor->Remove (); } - MEMBER_RELEASE (m_pCursorScene); + REF_PTR_RELEASE (m_pCursorScene); if (m_pCScene) { @@ -197,10 +197,8 @@ CW3DViewDoc::CleanupResources (void) } // Was there a dazzle layer? - if (m_pDazzleLayer) { - delete m_pDazzleLayer; - m_pDazzleLayer = NULL; - } + delete m_pDazzleLayer; + m_pDazzleLayer = NULL; // Was there a valid scene object? if (m_pCBackObjectScene) @@ -245,8 +243,8 @@ CW3DViewDoc::CleanupResources (void) { // Free the currently displayed object SAFE_DELETE (m_pCAnimCombo); - MEMBER_RELEASE (m_pCAnimation); - MEMBER_RELEASE (m_pCRenderObj); + REF_PTR_RELEASE (m_pCAnimation); + REF_PTR_RELEASE (m_pCRenderObj); } return ; @@ -286,8 +284,8 @@ CW3DViewDoc::OnNewDocument (void) { // Free the currently displayed object SAFE_DELETE (m_pCAnimCombo); - MEMBER_RELEASE (m_pCAnimation); - MEMBER_RELEASE (m_pCRenderObj); + REF_PTR_RELEASE (m_pCAnimation); + REF_PTR_RELEASE (m_pCRenderObj); } CDataTreeView *pCDataTreeView = GetDataTreeView (); @@ -612,7 +610,7 @@ CW3DViewDoc::Display_Emitter // Lose the animation SAFE_DELETE (m_pCAnimCombo); - MEMBER_RELEASE (m_pCAnimation); + REF_PTR_RELEASE (m_pCAnimation); if (m_pCRenderObj != NULL) { @@ -628,7 +626,7 @@ CW3DViewDoc::Display_Emitter // Add the emitter to the scene pemitter->Set_Transform (Matrix3D (1)); - MEMBER_ADD (m_pCRenderObj, pemitter); + REF_PTR_SET (m_pCRenderObj, pemitter); m_pCScene->Add_Render_Object (m_pCRenderObj); pemitter->Start (); @@ -671,7 +669,7 @@ CW3DViewDoc::DisplayObject { // Lose the animation SAFE_DELETE (m_pCAnimCombo); - MEMBER_RELEASE (m_pCAnimation); + REF_PTR_RELEASE (m_pCAnimation); // Do we have an old object to remove from the scene? if (add_ghost == false) { @@ -876,7 +874,7 @@ CW3DViewDoc::PlayAnimation // Get an instance of the animation object SAFE_DELETE (m_pCAnimCombo); - MEMBER_RELEASE (m_pCAnimation); + REF_PTR_RELEASE (m_pCAnimation); m_pCAnimation = WW3DAssetManager::Get_Instance()->Get_HAnim (pszAnimationName); ASSERT (m_pCAnimation); @@ -968,7 +966,7 @@ CW3DViewDoc::PlayAnimation // Get an instance of the animation object SAFE_DELETE (m_pCAnimCombo); - MEMBER_RELEASE (m_pCAnimation); + REF_PTR_RELEASE (m_pCAnimation); m_pCAnimCombo = pCAnimCombo; m_pCAnimation = m_pCAnimCombo->Get_Motion(0); // ref added by get_motion ASSERT (m_pCAnimation); @@ -1028,7 +1026,7 @@ Get_Camera_Transform (RenderObjClass *render_obj, Matrix3D &tm) if (psub_obj != NULL) { retval = Get_Camera_Transform (psub_obj, tm); } - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } if (!retval) { @@ -1250,11 +1248,11 @@ CW3DViewDoc::GenerateLOD HLodDefClass *pdefinition = new HLodDefClass (*pnew_lod); plod_prototype = new HLodPrototypeClass (pdefinition); - MEMBER_RELEASE (pnew_lod); + REF_PTR_RELEASE (pnew_lod); // Loop through all the LOD definitions and free their names for (lod_index = 0; lod_index < lod_count; lod_index ++) { - MEMBER_RELEASE (plod_array[lod_index]); + REF_PTR_RELEASE (plod_array[lod_index]); } // Free the LOD definition array @@ -1534,7 +1532,7 @@ CW3DViewDoc::SaveSettings if (szPath[::lstrlen (szPath)-1] != '\\') { // Ensure the path is directory delimited - ::strcat (szPath, "\\"); + strlcat(szPath, "\\", ARRAY_SIZE(szPath)); } // Prepend the filename with its new path @@ -1891,7 +1889,7 @@ CW3DViewDoc::Remove_Object_From_Scene (RenderObjClass *prender_obj) if (psub_obj != NULL) { Remove_Object_From_Scene (psub_obj); } - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } // If this is an emitter, then remove its buffer @@ -2256,7 +2254,7 @@ CW3DViewDoc::Auto_Assign_Bones (void) // Add this render object to the bone RenderObjClass *prender_obj = WW3DAssetManager::Get_Instance ()->Create_Render_Obj (pbone_name); m_pCRenderObj->Add_Sub_Object_To_Bone (prender_obj, index); - MEMBER_RELEASE (prender_obj); + REF_PTR_RELEASE (prender_obj); bupdate_prototype = true; } } @@ -2538,7 +2536,7 @@ CW3DViewDoc::Build_Emitter_List if (psub_obj != NULL) { Build_Emitter_List (emitter_list, emitter_name, psub_obj); } - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } // @@ -2641,7 +2639,7 @@ CW3DViewDoc::Count_Particles (RenderObjClass *render_obj) if (psub_obj != NULL) { count += Count_Particles (psub_obj); } - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } @@ -2701,7 +2699,7 @@ CW3DViewDoc::Switch_LOD (int increment, RenderObjClass *render_obj) if (psub_obj != NULL) { Switch_LOD (increment, psub_obj); } - MEMBER_RELEASE (psub_obj); + REF_PTR_RELEASE (psub_obj); } // @@ -2972,7 +2970,7 @@ CW3DViewDoc::Import_Facial_Animation (const CString &heirarchy_name, const CStri // Cleanup // anim_desc_file->Close (); - MEMBER_RELEASE (new_anim); + REF_PTR_RELEASE (new_anim); SAFE_DELETE (anim_desc_file); } diff --git a/Core/Tools/W3DView/W3DViewDoc.h b/Core/Tools/W3DView/W3DViewDoc.h index 387a7fec0b..cab9ffd9b1 100644 --- a/Core/Tools/W3DView/W3DViewDoc.h +++ b/Core/Tools/W3DView/W3DViewDoc.h @@ -20,12 +20,7 @@ // ///////////////////////////////////////////////////////////////////////////// -#if !defined(AFX_W3DVIEWDOC_H__2BB39E31_5D3A_11D2_9FC6_00104B791122__INCLUDED_) -#define AFX_W3DVIEWDOC_H__2BB39E31_5D3A_11D2_9FC6_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 #include "scene.h" #include "chunkio.h" @@ -337,7 +332,3 @@ class CW3DViewDoc : public CDocument //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_W3DVIEWDOC_H__2BB39E31_5D3A_11D2_9FC6_00104B791122__INCLUDED_) - - diff --git a/Core/Tools/W3DView/W3DViewView.h b/Core/Tools/W3DView/W3DViewView.h index 4f8ab9210d..024b2af2af 100644 --- a/Core/Tools/W3DView/W3DViewView.h +++ b/Core/Tools/W3DView/W3DViewView.h @@ -20,12 +20,7 @@ // ///////////////////////////////////////////////////////////////////////////// -#if !defined(AFX_W3DVIEWVIEW_H__2BB39E33_5D3A_11D2_9FC6_00104B791122__INCLUDED_) -#define AFX_W3DVIEWVIEW_H__2BB39E33_5D3A_11D2_9FC6_00104B791122__INCLUDED_ - -#if _MSC_VER >= 1000 #pragma once -#endif // _MSC_VER >= 1000 class CW3DViewView : public CView { @@ -75,5 +70,3 @@ inline CW3DViewDoc* CW3DViewView::GetDocument() //{{AFX_INSERT_LOCATION}} // Microsoft Developer Studio will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_W3DVIEWVIEW_H__2BB39E33_5D3A_11D2_9FC6_00104B791122__INCLUDED_) diff --git a/Core/Tools/WW3D/max2w3d/AlphaModifier.h b/Core/Tools/WW3D/max2w3d/AlphaModifier.h index 47bf775459..e698b0e20e 100644 --- a/Core/Tools/WW3D/max2w3d/AlphaModifier.h +++ b/Core/Tools/WW3D/max2w3d/AlphaModifier.h @@ -34,10 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef ALPHA_MODIFIER_H -#define ALPHA_MODIFIER_H - +#pragma once #include #include "iparamm2.h" @@ -146,9 +143,3 @@ class AlphaModDlgProc : public ParamMap2UserDlgProc void SetThing(ReferenceTarget *m) {AlphaModifier = (AlphaModifierClass*)m;} }; - - -#endif //ALPHA_MODIFIER_H - - - diff --git a/Core/Tools/WW3D/max2w3d/CMakeLists.txt b/Core/Tools/WW3D/max2w3d/CMakeLists.txt index 433365eb59..07eb6dbf32 100644 --- a/Core/Tools/WW3D/max2w3d/CMakeLists.txt +++ b/Core/Tools/WW3D/max2w3d/CMakeLists.txt @@ -117,8 +117,8 @@ set(MAX2W3D_SRC "skindata.h" "SnapPoints.cpp" "SnapPoints.h" - "TARGA.CPP" - "TARGA.H" + "TARGA.cpp" + "TARGA.h" "util.cpp" "util.h" "Utility.cpp" diff --git a/Core/Tools/WW3D/max2w3d/ExportAllDlg.h b/Core/Tools/WW3D/max2w3d/ExportAllDlg.h index fc85abd06f..536e822a13 100644 --- a/Core/Tools/WW3D/max2w3d/ExportAllDlg.h +++ b/Core/Tools/WW3D/max2w3d/ExportAllDlg.h @@ -34,9 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef EXPORTALLDLG_H -#define EXPORTALLDLG_H +#pragma once #include "dllmain.h" #include "resource.h" @@ -76,6 +74,3 @@ class ExportAllDlg void OnBrowse (void); BOOL OnOK (void); // TRUE if ok to close dialog }; - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/FormClass.h b/Core/Tools/WW3D/max2w3d/FormClass.h index 3035dfebe8..9f12c95df3 100644 --- a/Core/Tools/WW3D/max2w3d/FormClass.h +++ b/Core/Tools/WW3D/max2w3d/FormClass.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef __FORMCLASS_H -#define __FORMCLASS_H #include @@ -68,5 +62,3 @@ class FormClass : public ParamDlg HWND m_hWnd; RECT m_FormRect; }; - -#endif //__FORMCLASS_H diff --git a/Core/Tools/WW3D/max2w3d/GameMtl.cpp b/Core/Tools/WW3D/max2w3d/GameMtl.cpp index 6752c6328d..1010d91197 100644 --- a/Core/Tools/WW3D/max2w3d/GameMtl.cpp +++ b/Core/Tools/WW3D/max2w3d/GameMtl.cpp @@ -23,7 +23,7 @@ * * * Project Name : Commando / G 3D engine * * * - * File Name : GAMEMTL.CPP * + * File Name : GAMEMTL.cpp * * * * Programmer : Greg Hjelstrom * * * diff --git a/Core/Tools/WW3D/max2w3d/GameMtlDlg.h b/Core/Tools/WW3D/max2w3d/GameMtlDlg.h index e28a822969..e5fe6042b7 100644 --- a/Core/Tools/WW3D/max2w3d/GameMtlDlg.h +++ b/Core/Tools/WW3D/max2w3d/GameMtlDlg.h @@ -34,13 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - -#ifndef GAMEMTLDLG_H -#define GAMEMTLDLG_H +#pragma once class GameMtl; + class GameMtlPassDlg; @@ -114,6 +111,3 @@ class GameMtlDlg: public ParamDlg friend BOOL CALLBACK PassCountPanelDlgProc(HWND, UINT, WPARAM,LPARAM); friend class GameMtl; }; - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/GameMtlForm.h b/Core/Tools/WW3D/max2w3d/GameMtlForm.h index cf4033947f..6febb29d35 100644 --- a/Core/Tools/WW3D/max2w3d/GameMtlForm.h +++ b/Core/Tools/WW3D/max2w3d/GameMtlForm.h @@ -34,10 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef GAMEMTLFORM_H -#define GAMEMTLFORM_H +#pragma once #include "FormClass.h" @@ -60,5 +57,3 @@ class GameMtlFormClass : public FormClass GameMtl * TheMtl; // current mtl being edited. int PassIndex; // material pass that this form edits }; - -#endif diff --git a/Core/Tools/WW3D/max2w3d/GameMtlPassDlg.h b/Core/Tools/WW3D/max2w3d/GameMtlPassDlg.h index 0efa924bf5..27a47f9172 100644 --- a/Core/Tools/WW3D/max2w3d/GameMtlPassDlg.h +++ b/Core/Tools/WW3D/max2w3d/GameMtlPassDlg.h @@ -34,11 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - -#ifndef GAMEMTLPASSDLG_H -#define GAMEMTLPASSDLG_H +#pragma once #include @@ -93,5 +89,3 @@ class GameMtlPassDlg: public ParamDlg GameMtlFormClass* Page[PAGE_COUNT]; }; - -#endif diff --git a/Core/Tools/WW3D/max2w3d/GameMtlShaderDlg.h b/Core/Tools/WW3D/max2w3d/GameMtlShaderDlg.h index 7c623ca5ef..298cf9bd35 100644 --- a/Core/Tools/WW3D/max2w3d/GameMtlShaderDlg.h +++ b/Core/Tools/WW3D/max2w3d/GameMtlShaderDlg.h @@ -34,10 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef GAMEMTLSHADERDLG_H -#define GAMEMTLSHADERDLG_H +#pragma once #include #include "GameMtlForm.h" @@ -66,5 +63,3 @@ class GameMtlShaderDlg : public GameMtlFormClass bool CompareShaderToBlendPreset(const ShaderBlendSettingPreset &blend_preset); void Set_Advanced_Defaults(void); }; - -#endif diff --git a/Core/Tools/WW3D/max2w3d/GameMtlTextureDlg.h b/Core/Tools/WW3D/max2w3d/GameMtlTextureDlg.h index 567af7be08..6c7bcebc14 100644 --- a/Core/Tools/WW3D/max2w3d/GameMtlTextureDlg.h +++ b/Core/Tools/WW3D/max2w3d/GameMtlTextureDlg.h @@ -34,13 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - - -#ifndef GAMEMTLTEXTUREDLG_H -#define GAMEMTLTEXTUREDLG_H +#pragma once #include + #include "GameMtlForm.h" class GameMtl; @@ -81,10 +78,3 @@ class GameMtlTextureDlg : public GameMtlFormClass ICustButton * Stage0DisplayButton; ICustButton * Stage1DisplayButton; }; - - - - -#endif - - diff --git a/Core/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.h b/Core/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.h index c8b92a48b9..63b3caa9c7 100644 --- a/Core/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.h +++ b/Core/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.h @@ -34,10 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef GAMEMTLVERTEXMATERIALDLG_H -#define GAMEMTLVERTEXMATERIALDLG_H +#pragma once #include #include "GameMtlForm.h" @@ -71,6 +68,3 @@ class GameMtlVertexMaterialDlg : public GameMtlFormClass ISpinnerControl * ShininessSpin; ISpinnerControl * UVChannelSpin[MAX_STAGES]; }; - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/InputDlg.h b/Core/Tools/WW3D/max2w3d/InputDlg.h index 57a6420838..28beae3a67 100644 --- a/Core/Tools/WW3D/max2w3d/InputDlg.h +++ b/Core/Tools/WW3D/max2w3d/InputDlg.h @@ -34,10 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - - -#ifndef INPUTDLG_H -#define INPUTDLG_H +#pragma once #include "dllmain.h" #include "resource.h" @@ -81,6 +78,3 @@ class InputDlg LRESULT OnInitDialog (WPARAM wParam, LPARAM lParam); BOOL OnOK (void); }; - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/LightGlareSave.h b/Core/Tools/WW3D/max2w3d/LightGlareSave.h index a585103f35..23c9f4e036 100644 --- a/Core/Tools/WW3D/max2w3d/LightGlareSave.h +++ b/Core/Tools/WW3D/max2w3d/LightGlareSave.h @@ -36,17 +36,12 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef LIGHTGLARESAVE_H -#define LIGHTGLARESAVE_H #include #include "w3d_file.h" #include "chunkio.h" -#include "PROGRESS.H" +#include "PROGRESS.h" /******************************************************************************************* @@ -78,7 +73,3 @@ class LightGlareSaveClass W3dLightGlareStruct GlareData; }; - - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/MeshDeform.h b/Core/Tools/WW3D/max2w3d/MeshDeform.h index 7d80686f86..45ea857f2c 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeform.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeform.h @@ -23,7 +23,7 @@ * * * Project Name : Commando / G 3D engine * * * - * File Name : MeshDeform.H * + * File Name : MeshDeform.h * * * * Programmer : Patrick Smith * * * @@ -35,12 +35,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef __MESH_DEFORM_H -#define __MESH_DEFORM_H +#pragma once #include -#include "Vector.H" +#include "Vector.h" // Forward declarations class MeshDeformPanelClass; @@ -196,6 +194,3 @@ class MeshDeformClass : public OSModifier // Information CStr m_OperationName; }; - - -#endif //__MESH_DEFORM_H diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformData.h b/Core/Tools/WW3D/max2w3d/MeshDeformData.h index 43eaa9043b..7e7170fe53 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformData.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeformData.h @@ -34,11 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef __MESH_DEFORM_DATA_H -#define __MESH_DEFORM_DATA_H +#pragma once #include -#include "Vector.H" +#include "Vector.h" #include "MeshDeformSet.h" @@ -122,7 +121,3 @@ class MeshDeformModData : public LocalModData int m_CurrentSet; SETS_LIST m_SetsList; }; - - -#endif //__MESH_DEFORM_DATA_H - diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformDefs.h b/Core/Tools/WW3D/max2w3d/MeshDeformDefs.h index b5f770b8d6..51e130766f 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformDefs.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeformDefs.h @@ -34,11 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef __MESH_DEFORM_DEFS_H -#define __MESH_DEFORM_DEFS_H +#pragma once #include -#include "Vector.H" +#include "Vector.h" /////////////////////////////////////////////////////////////////////////// // @@ -94,7 +93,3 @@ typedef struct _VERT_INFO // /////////////////////////////////////////////////////////////////////////// typedef DynamicVectorClass DEFORM_LIST; - - -#endif //__MESH_DEFORM_DEFS_H - diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformPanel.h b/Core/Tools/WW3D/max2w3d/MeshDeformPanel.h index 8973d8bbc0..36322e413d 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformPanel.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeformPanel.h @@ -22,7 +22,7 @@ * * * Project Name : Commando / G 3D engine * * * - * File Name : MeshDeformPanel.H * + * File Name : MeshDeformPanel.h * * * * Programmer : Patrick Smith * * * @@ -34,9 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef __MESH_DEFORM_PANEL_H -#define __MESH_DEFORM_PANEL_H +#pragma once #include #include "resource.h" @@ -112,6 +110,3 @@ class MeshDeformPanelClass ICustButton * m_pLockSetsButton; MeshDeformClass * m_pMeshDeformer; }; - - -#endif //__MESH_DEFORM_PANEL_H diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformSave.cpp b/Core/Tools/WW3D/max2w3d/MeshDeformSave.cpp index aadc4fe914..20746a95e9 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformSave.cpp +++ b/Core/Tools/WW3D/max2w3d/MeshDeformSave.cpp @@ -23,7 +23,7 @@ * * * Project Name : Commando / G 3D engine * * * - * File Name : MeshDeformSafe.CPP + * File Name : MeshDeformSafe.cpp * * * Programmer : Patrick Smith * * * diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformSave.h b/Core/Tools/WW3D/max2w3d/MeshDeformSave.h index ccfa8c7578..e27ff6e08e 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformSave.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeformSave.h @@ -23,7 +23,7 @@ * * * Project Name : Commando / G 3D engine * * * - * File Name : MeshDeformSafe.H + * File Name : MeshDeformSafe.h * * * Programmer : Patrick Smith * * * @@ -35,11 +35,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef __MESH_DEFORM_SAVE_H -#define __MESH_DEFORM_SAVE_H +#pragma once #include -#include "Vector.H" +#include "Vector.h" // Forward declarations class ChunkSaveClass; @@ -106,5 +105,3 @@ class MeshDeformSaveClass DEFORM_SAVE_LIST m_DeformSets; unsigned int m_AlphaPasses; }; - -#endif //__MESH_DEFORM_SAVE_H diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformSaveDefs.h b/Core/Tools/WW3D/max2w3d/MeshDeformSaveDefs.h index 8f9acb8d14..2202b6b66b 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformSaveDefs.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeformSaveDefs.h @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef __MESH_DEFORM_SAVE_DEFS_H -#define __MESH_DEFORM_SAVE_DEFS_H +#pragma once #include @@ -109,6 +108,3 @@ struct DeformDataChunk Point3 Value; uint32 reserved[2]; }; - - -#endif //__MESH_DEFORM_SAVE_DEFS_H diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp b/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp index 2eff00eb2a..54f747c988 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp +++ b/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp @@ -23,7 +23,7 @@ * * * Project Name : Commando / G 3D engine * * * - * File Name : MeshDeformSaveSet.CPP + * File Name : MeshDeformSaveSet.cpp * * * Programmer : Patrick Smith * * * diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.h b/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.h index 2b26fa5555..13642bc8a0 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.h @@ -23,7 +23,7 @@ * * * Project Name : Commando / G 3D engine * * * - * File Name : MeshDeformSaveSet.H + * File Name : MeshDeformSaveSet.h * * * Programmer : Patrick Smith * * * @@ -35,11 +35,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef __MESH_DEFORM_SAVE_SET_H -#define __MESH_DEFORM_SAVE_SET_H +#pragma once #include -#include "Vector.H" +#include "Vector.h" // Forward declarations class ChunkSaveClass; @@ -134,5 +133,3 @@ class MeshDeformSaveSetClass KEYFRAME * m_CurrentKeyFrame; unsigned int m_Flags; }; - -#endif //__MESH_DEFORM_SAVE_SET_H diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformSet.h b/Core/Tools/WW3D/max2w3d/MeshDeformSet.h index ea662cd992..4451fb290a 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformSet.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeformSet.h @@ -34,12 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef __MESH_DEFORM_SET_H -#define __MESH_DEFORM_SET_H +#pragma once #include -#include "Vector.H" +#include "Vector.h" #include "MeshDeformDefs.h" @@ -179,7 +177,3 @@ class MeshDeformSetClass // List of key frames KEY_FRAME_LIST m_KeyFrames; }; - - -#endif //__MESH_DEFORM_DATA_H - diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformUndo.h b/Core/Tools/WW3D/max2w3d/MeshDeformUndo.h index 6394b43cb2..330c34389a 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformUndo.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeformUndo.h @@ -34,11 +34,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef __MESH_DEFORM_UNDO_H -#define __MESH_DEFORM_UNDO_H +#pragma once #include -#include "Vector.H" +#include "Vector.h" #include "MeshDeformDefs.h" // Forward declarations @@ -150,6 +149,3 @@ class VertexColorRestoreClass : public VertexRestoreClass virtual void Copy_Vertex_State (DEFORM_LIST &list); virtual void Apply_Vertex_Data (DEFORM_LIST &list); }; - - -#endif //__MESH_DEFORM_UNDO_H diff --git a/Core/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.h b/Core/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.h index 56f96ce9b3..5b0875507b 100644 --- a/Core/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.h +++ b/Core/Tools/WW3D/max2w3d/PS2GameMtlShaderDlg.h @@ -34,9 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef PS2GAMEMTLSHADERDLG_H -#define PS2GAMEMTLSHADERDLG_H +#pragma once #include #include "GameMtlForm.h" @@ -67,5 +65,3 @@ class PS2GameMtlShaderDlg : public GameMtlFormClass bool CompareShaderToBlendPreset(const PS2ShaderBlendSettingPreset &blend_preset); void Set_Advanced_Defaults(void); }; - -#endif diff --git a/Core/Tools/WW3D/max2w3d/SceneSetupDlg.h b/Core/Tools/WW3D/max2w3d/SceneSetupDlg.h index efd55afcea..ce1d5de584 100644 --- a/Core/Tools/WW3D/max2w3d/SceneSetupDlg.h +++ b/Core/Tools/WW3D/max2w3d/SceneSetupDlg.h @@ -34,9 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SCENESETUPDLG_H -#define SCENESETUPDLG_H +#pragma once // SceneSetupDlg.h : header file // @@ -91,5 +89,3 @@ class SceneSetupDlg // Protected Data Interface *m_MaxInterface; }; - -#endif diff --git a/Core/Tools/WW3D/max2w3d/SnapPoints.h b/Core/Tools/WW3D/max2w3d/SnapPoints.h index fb21678fa1..3ef1a76789 100644 --- a/Core/Tools/WW3D/max2w3d/SnapPoints.h +++ b/Core/Tools/WW3D/max2w3d/SnapPoints.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef SNAPPOINTS_H -#define SNAPPOINTS_H #include "max.h" @@ -57,5 +51,3 @@ class SnapPointsClass public: static void Export_Points(INode * scene_root,TimeValue time,ChunkSaveClass & csave); }; - -#endif diff --git a/Core/Tools/WW3D/max2w3d/TARGA.CPP b/Core/Tools/WW3D/max2w3d/TARGA.cpp similarity index 99% rename from Core/Tools/WW3D/max2w3d/TARGA.CPP rename to Core/Tools/WW3D/max2w3d/TARGA.cpp index 644b352076..8b0ffd2e41 100644 --- a/Core/Tools/WW3D/max2w3d/TARGA.CPP +++ b/Core/Tools/WW3D/max2w3d/TARGA.cpp @@ -60,7 +60,7 @@ * ****************************************************************************/ -#include "TARGA.H" +#include "TARGA.h" #ifndef TGA_USES_WWLIB_FILE_CLASSES #include #endif diff --git a/Core/Tools/WW3D/max2w3d/TARGA.H b/Core/Tools/WW3D/max2w3d/TARGA.h similarity index 99% rename from Core/Tools/WW3D/max2w3d/TARGA.H rename to Core/Tools/WW3D/max2w3d/TARGA.h index 05d9aa5c2b..02cf38aee4 100644 --- a/Core/Tools/WW3D/max2w3d/TARGA.H +++ b/Core/Tools/WW3D/max2w3d/TARGA.h @@ -16,8 +16,8 @@ ** along with this program. If not, see . */ -#ifndef _TARGA_H_ -#define _TARGA_H_ +#pragma once + /**************************************************************************** * * C O N F I D E N T I A L --- W E S T W O O D S T U D I O S @@ -315,6 +315,3 @@ class Targa int File_Read(void *buffer, int size); int File_Write(void *buffer, int size); }; - -#endif /* _TARGA_H_ */ - diff --git a/Core/Tools/WW3D/max2w3d/aabtreebuilder.h b/Core/Tools/WW3D/max2w3d/aabtreebuilder.h index b75d10d0a6..604d8130c1 100644 --- a/Core/Tools/WW3D/max2w3d/aabtreebuilder.h +++ b/Core/Tools/WW3D/max2w3d/aabtreebuilder.h @@ -36,19 +36,13 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef AABTREEBUILDER_H -#define AABTREEBUILDER_H #include "always.h" #include "vector3.h" #include "vector3i.h" #include "aaplane.h" -#include "BITTYPE.H" +#include "BITTYPE.h" #include class AABTreeClass; @@ -201,9 +195,3 @@ class AABTreeBuilderClass friend class AABTreeClass; }; - - - - -#endif //AABTREEBUILDER_H - diff --git a/Core/Tools/WW3D/max2w3d/animationcompressionsettings.h b/Core/Tools/WW3D/max2w3d/animationcompressionsettings.h index 112c94b518..921ad26d04 100644 --- a/Core/Tools/WW3D/max2w3d/animationcompressionsettings.h +++ b/Core/Tools/WW3D/max2w3d/animationcompressionsettings.h @@ -36,9 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef __ANIMATION_COMPRESSION_SETTINGS_H -#define __ANIMATION_COMPRESSION_SETTINGS_H +#pragma once #include #include @@ -90,7 +88,3 @@ class AnimationCompressionSettingsDialogClass HWND Wnd; HWND ParentWnd; }; - - -#endif //__ANIMATION_COMPRESSION_SETTINGS_H - diff --git a/Core/Tools/WW3D/max2w3d/bchannel.cpp b/Core/Tools/WW3D/max2w3d/bchannel.cpp index 41a745af60..335f5cca22 100644 --- a/Core/Tools/WW3D/max2w3d/bchannel.cpp +++ b/Core/Tools/WW3D/max2w3d/bchannel.cpp @@ -233,7 +233,7 @@ void BitChannelClass::compute_range(void) while ((End >= 0) && (is_default(Get_Bit(End)))) { End--; } -} // compute_range +} // @@ -258,12 +258,12 @@ uint32 BitChannelClass::find_useless_packet(W3dTimeCodedBitChannelStruct * c) return(try_idx + 1); } - } // for + } } return( PACKETS_ALL_USEFUL ); -} // find_useless_packet +} // @@ -293,7 +293,7 @@ void BitChannelClass::remove_packet(W3dTimeCodedBitChannelStruct * c, uint32 pac // Decrement Packet Count c->NumTimeCodes--; -} // remove_packet +} // // Take a non-compressed TimeCoded Bit Channel @@ -311,7 +311,7 @@ void BitChannelClass::compress(W3dTimeCodedBitChannelStruct * c) } -} // compress +} diff --git a/Core/Tools/WW3D/max2w3d/bchannel.h b/Core/Tools/WW3D/max2w3d/bchannel.h index 9507139d5f..67c3b71668 100644 --- a/Core/Tools/WW3D/max2w3d/bchannel.h +++ b/Core/Tools/WW3D/max2w3d/bchannel.h @@ -34,16 +34,14 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef BCHANNEL_H -#define BCHANNEL_H +#pragma once #ifndef ALWAYS_H #include "always.h" #endif #ifndef BITTYPE_H -#include "BITTYPE.H" +#include "BITTYPE.h" #endif #ifndef CHUNKIO_H @@ -51,7 +49,7 @@ #endif #ifndef VECTOR_H -#include "Vector.H" +#include "Vector.h" #endif #ifndef W3D_FILE_H @@ -98,6 +96,3 @@ class BitChannelClass }; - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/boneicon.h b/Core/Tools/WW3D/max2w3d/boneicon.h index f111bd30ae..a9ecbd4207 100644 --- a/Core/Tools/WW3D/max2w3d/boneicon.h +++ b/Core/Tools/WW3D/max2w3d/boneicon.h @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef BONEICON_H -#define BONEICON_H +#pragma once struct VertexStruct { @@ -53,5 +51,3 @@ extern const int NumBoneIconVerts; extern const int NumBoneIconFaces; extern VertexStruct BoneIconVerts[]; extern FaceStruct BoneIconFaces[]; - -#endif diff --git a/Core/Tools/WW3D/max2w3d/bpick.h b/Core/Tools/WW3D/max2w3d/bpick.h index 6d6297c5d1..bb21289021 100644 --- a/Core/Tools/WW3D/max2w3d/bpick.h +++ b/Core/Tools/WW3D/max2w3d/bpick.h @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef BPICK_H -#define BPICK_H +#pragma once #include "max.h" //#include "dllmain.h" @@ -124,6 +122,3 @@ class BonePickerClass : public PickNodeCallback, public PickModeCallback, public }; extern BonePickerClass TheBonePicker; - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/colboxsave.h b/Core/Tools/WW3D/max2w3d/colboxsave.h index 2f67ff22cb..76fa6a449e 100644 --- a/Core/Tools/WW3D/max2w3d/colboxsave.h +++ b/Core/Tools/WW3D/max2w3d/colboxsave.h @@ -34,18 +34,12 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef COLBOXSAVE_H -#define COLBOXSAVE_H #include #include "w3d_file.h" #include "chunkio.h" -#include "PROGRESS.H" +#include "PROGRESS.h" /******************************************************************************************* @@ -78,7 +72,3 @@ class CollisionBoxSaveClass W3dBoxStruct BoxData; // contains same information as the W3dOBBoxStruct }; - - - -#endif //COLBOXSAVE_H diff --git a/Core/Tools/WW3D/max2w3d/dazzlesave.h b/Core/Tools/WW3D/max2w3d/dazzlesave.h index 3562c87ad6..bb2a4f1b58 100644 --- a/Core/Tools/WW3D/max2w3d/dazzlesave.h +++ b/Core/Tools/WW3D/max2w3d/dazzlesave.h @@ -36,17 +36,12 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef DAZZLESAVE_H -#define DAZZLESAVE_H #include #include "w3d_file.h" #include "chunkio.h" -#include "PROGRESS.H" +#include "PROGRESS.h" /******************************************************************************************* @@ -79,12 +74,3 @@ class DazzleSaveClass char DazzleType[128]; }; - - - - - - - -#endif //DAZZLESAVE_H - diff --git a/Core/Tools/WW3D/max2w3d/dllmain.cpp b/Core/Tools/WW3D/max2w3d/dllmain.cpp index e03af53066..ce3727e08e 100644 --- a/Core/Tools/WW3D/max2w3d/dllmain.cpp +++ b/Core/Tools/WW3D/max2w3d/dllmain.cpp @@ -23,7 +23,7 @@ * * * Project Name : Commando / G * * * - * File Name : DLLMAIN.CPP * + * File Name : DLLMAIN.cpp * * * * Programmer : Greg Hjelstrom * * * diff --git a/Core/Tools/WW3D/max2w3d/dllmain.h b/Core/Tools/WW3D/max2w3d/dllmain.h index 93c6fb9486..fb921d7b5c 100644 --- a/Core/Tools/WW3D/max2w3d/dllmain.h +++ b/Core/Tools/WW3D/max2w3d/dllmain.h @@ -23,7 +23,7 @@ * * * Project Name : Commando / G * * * - * File Name : DLLMAIN.H * + * File Name : DLLMAIN.h * * * * Programmer : Greg Hjelstrom * * * @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef DLLMAIN_H -#define DLLMAIN_H +#pragma once #include @@ -47,5 +45,3 @@ extern HINSTANCE AppInstance; #define MAX_PATH_LENGTH _MAX_PATH TCHAR * Get_String(int id); - -#endif /*DLLMAIN_H*/ diff --git a/Core/Tools/WW3D/max2w3d/exportlog.h b/Core/Tools/WW3D/max2w3d/exportlog.h index 593bda0180..d9b4e58f23 100644 --- a/Core/Tools/WW3D/max2w3d/exportlog.h +++ b/Core/Tools/WW3D/max2w3d/exportlog.h @@ -36,9 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef EXPORTLOG_H -#define EXPORTLOG_H +#pragma once #include @@ -56,7 +54,3 @@ class ExportLog static void rprintf(const char *, ...); static void updatebar(float position, float total); }; - - -#endif //EXPORTLOG_H - diff --git a/Core/Tools/WW3D/max2w3d/floaterdialog.h b/Core/Tools/WW3D/max2w3d/floaterdialog.h index d4837cdc19..de6d7f0427 100644 --- a/Core/Tools/WW3D/max2w3d/floaterdialog.h +++ b/Core/Tools/WW3D/max2w3d/floaterdialog.h @@ -36,9 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef FLOATERDIALOG_H -#define FLOATERDIALOG_H +#pragma once #include @@ -68,8 +66,3 @@ class FloaterDialogClass DLGPROC ChildDialogProc; }; - - - -#endif //FLOATERDIALOG_H - diff --git a/Core/Tools/WW3D/max2w3d/gamemaps.cpp b/Core/Tools/WW3D/max2w3d/gamemaps.cpp index b22def8e3a..0be2207c5c 100644 --- a/Core/Tools/WW3D/max2w3d/gamemaps.cpp +++ b/Core/Tools/WW3D/max2w3d/gamemaps.cpp @@ -23,7 +23,7 @@ * * * Project Name : Commando / G 3D engine * * * - * File Name : GAMEMAPS.CPP * + * File Name : GAMEMAPS.cpp * * * * Programmer : Greg Hjelstrom * * * diff --git a/Core/Tools/WW3D/max2w3d/gamemaps.h b/Core/Tools/WW3D/max2w3d/gamemaps.h index d2098b2217..f94e728406 100644 --- a/Core/Tools/WW3D/max2w3d/gamemaps.h +++ b/Core/Tools/WW3D/max2w3d/gamemaps.h @@ -23,7 +23,7 @@ * * * Project Name : Commando / G 3D engine * * * - * File Name : GAMEMAPS.H * + * File Name : GAMEMAPS.h * * * * Programmer : Greg Hjelstrom * * * @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef GAMEMAPS_H -#define GAMEMAPS_H +#pragma once #include #include "stdmat.h" @@ -110,6 +108,3 @@ class GameMapsClass: public ReferenceTarget IOResult Save(ISave * isave); IOResult Load(ILoad * iload); }; - - -#endif /*GAMEMAPS_H*/ diff --git a/Core/Tools/WW3D/max2w3d/gamemtl.h b/Core/Tools/WW3D/max2w3d/gamemtl.h index 3b07db3ca5..1065b4464d 100644 --- a/Core/Tools/WW3D/max2w3d/gamemtl.h +++ b/Core/Tools/WW3D/max2w3d/gamemtl.h @@ -23,7 +23,7 @@ * * * Project Name : Commando / G 3D engine * * * - * File Name : GAMEMTL.H * + * File Name : GAMEMTL.h * * * * Programmer : Greg Hjelstrom * * * @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef GAMEMTL_H -#define GAMEMTL_H +#pragma once #include #include "w3dmtl.h" @@ -366,8 +364,3 @@ class GameMtl: public Mtl }; Mtl * CreateGameMtl(); - -#endif - - - diff --git a/Core/Tools/WW3D/max2w3d/genlodextensiondialog.h b/Core/Tools/WW3D/max2w3d/genlodextensiondialog.h index a7bbfab0eb..c028e8a6fb 100644 --- a/Core/Tools/WW3D/max2w3d/genlodextensiondialog.h +++ b/Core/Tools/WW3D/max2w3d/genlodextensiondialog.h @@ -36,8 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef GENLODEXTENSIONDIALOG_H -#define GENLODEXTENSIONDIALOG_H +#pragma once #include @@ -87,8 +86,3 @@ class GenLodExtensionDialogClass friend BOOL CALLBACK _gen_lod_ext_dialog_proc(HWND Hwnd,UINT message,WPARAM wParam,LPARAM lParam); }; - - - - -#endif //GENLODEXTENSIONDIALOG_H diff --git a/Core/Tools/WW3D/max2w3d/genmtlnamesdialog.h b/Core/Tools/WW3D/max2w3d/genmtlnamesdialog.h index 50f6ee44bd..fcb8ef9614 100644 --- a/Core/Tools/WW3D/max2w3d/genmtlnamesdialog.h +++ b/Core/Tools/WW3D/max2w3d/genmtlnamesdialog.h @@ -36,8 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef GENMTLNAMESDIALOG_H -#define GENMTLNAMESDIALOG_H +#pragma once #include @@ -95,8 +94,3 @@ class GenMtlNamesDialogClass friend BOOL CALLBACK _gen_mtl_names_dialog_proc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam); }; - - -#endif //GENMTLNAMESDIALOG_H - - diff --git a/Core/Tools/WW3D/max2w3d/geometryexportcontext.h b/Core/Tools/WW3D/max2w3d/geometryexportcontext.h index 679b15d38f..c1d83f18d8 100644 --- a/Core/Tools/WW3D/max2w3d/geometryexportcontext.h +++ b/Core/Tools/WW3D/max2w3d/geometryexportcontext.h @@ -36,9 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef GEOMETRYEXPORTCONTEXT_H -#define GEOMETRYEXPORTCONTEXT_H +#pragma once #include @@ -108,8 +106,3 @@ class GeometryExportContextClass int numHouseColors; ///MW: number of used house colors char * materialColorTexture; //MW: texture to hold material colors }; - - - -#endif //GEOMETRYEXPORTCONTEXT_H - diff --git a/Core/Tools/WW3D/max2w3d/geometryexporttask.h b/Core/Tools/WW3D/max2w3d/geometryexporttask.h index 5a0dbae27d..a3802a1cf5 100644 --- a/Core/Tools/WW3D/max2w3d/geometryexporttask.h +++ b/Core/Tools/WW3D/max2w3d/geometryexporttask.h @@ -36,13 +36,12 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef GEOMETRYEXPORTTASK_H -#define GEOMETRYEXPORTTASK_H +#pragma once #include #include #include "w3d_file.h" -#include "Vector.H" +#include "Vector.h" class GeometryExportContextClass; @@ -148,8 +147,3 @@ class GeometryExportTaskClass TimeValue CurTime; INode * Node; }; - - - -#endif //GEOMETRYEXPORTTASK_H - diff --git a/Core/Tools/WW3D/max2w3d/gmtldlg.cpp b/Core/Tools/WW3D/max2w3d/gmtldlg.cpp index 22c0fb3802..f2ebcba44a 100644 --- a/Core/Tools/WW3D/max2w3d/gmtldlg.cpp +++ b/Core/Tools/WW3D/max2w3d/gmtldlg.cpp @@ -23,7 +23,7 @@ * * * Project Name : Commando / G 3D engine * * * - * File Name : GMTLDLG.CPP * + * File Name : GMTLDLG.cpp * * * * Programmer : Greg Hjelstrom * * * diff --git a/Core/Tools/WW3D/max2w3d/gridsnapmodifier.h b/Core/Tools/WW3D/max2w3d/gridsnapmodifier.h index 280911b232..b921e787df 100644 --- a/Core/Tools/WW3D/max2w3d/gridsnapmodifier.h +++ b/Core/Tools/WW3D/max2w3d/gridsnapmodifier.h @@ -36,12 +36,8 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef GRIDSNAPMODIFIER_H -#define GRIDSNAPMODIFIER_H +#pragma once class ClassDesc; ClassDesc * Get_Grid_Snap_Modifier_Desc(void); - - -#endif //GRIDSNAPMODIFIER_H diff --git a/Core/Tools/WW3D/max2w3d/hiersave.cpp b/Core/Tools/WW3D/max2w3d/hiersave.cpp index d7a3a8609f..70066e54d3 100644 --- a/Core/Tools/WW3D/max2w3d/hiersave.cpp +++ b/Core/Tools/WW3D/max2w3d/hiersave.cpp @@ -62,7 +62,7 @@ #include "hiersave.h" #include "w3d_file.h" #include "nodefilt.h" -#include "EULER.H" +#include "EULER.h" #include "util.h" #include "w3dappdata.h" #include "errclass.h" diff --git a/Core/Tools/WW3D/max2w3d/hiersave.h b/Core/Tools/WW3D/max2w3d/hiersave.h index ad379a21aa..6771537f7c 100644 --- a/Core/Tools/WW3D/max2w3d/hiersave.h +++ b/Core/Tools/WW3D/max2w3d/hiersave.h @@ -35,8 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef HIERSAVE_H -#define HIERSAVE_H +#pragma once #include "always.h" @@ -48,7 +47,7 @@ #endif #ifndef PROGRESS_H -#include "PROGRESS.H" +#include "PROGRESS.h" #endif #ifndef CHUNKIO_H @@ -60,7 +59,7 @@ #endif #ifndef VECTOR_H -#include "Vector.H" +#include "Vector.h" #endif @@ -166,5 +165,3 @@ class HierarchySaveClass Matrix3 fixup_matrix(const Matrix3 & src) const; void Free(void); }; - -#endif /*HIERSAVE_H*/ diff --git a/Core/Tools/WW3D/max2w3d/hlodsave.h b/Core/Tools/WW3D/max2w3d/hlodsave.h index e24edb6df3..a0b91af6b9 100644 --- a/Core/Tools/WW3D/max2w3d/hlodsave.h +++ b/Core/Tools/WW3D/max2w3d/hlodsave.h @@ -34,9 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef HLODSAVE_H -#define HLODSAVE_H +#pragma once #include "always.h" @@ -44,7 +42,7 @@ #include #include "w3d_file.h" -#include "PROGRESS.H" +#include "PROGRESS.h" #include "chunkio.h" #include "meshcon.h" @@ -123,7 +121,3 @@ class HLodSaveClass HLodArrayEntry aggregate_array; HLodArrayEntry proxy_array; }; - - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/logdlg.cpp b/Core/Tools/WW3D/max2w3d/logdlg.cpp index 8ff8cc3762..aa693b8223 100644 --- a/Core/Tools/WW3D/max2w3d/logdlg.cpp +++ b/Core/Tools/WW3D/max2w3d/logdlg.cpp @@ -104,7 +104,7 @@ void LogDataDialogClass::printf(const char *text, ...) { va_list arguments; va_start(arguments, text); -} // printf +} void LogDataDialogClass::printf(const char * text, va_list args) { @@ -169,7 +169,7 @@ void LogDataDialogClass::rprintf(const char *text, va_list args) //SendMessage(GetDlgItem(Hwnd,IDC_ANIM_LOG_RICHEDIT), EM_SCROLLCARET, 0, 0); -} // rprintf +} /*********************************************************************************************** @@ -194,7 +194,7 @@ void LogDataDialogClass::updatebar(float position, float total) SendMessage(ctrlHwnd, PBM_SETPOS, pos, 0 ); -} // updatebar +} /*********************************************************************************************** @@ -218,7 +218,7 @@ void LogDataDialogClass::Wait_OK() // wait for the OK } -} // Wait_OK +} @@ -296,7 +296,7 @@ bool LogDataDialogClass::Dialog_Proc } return FALSE; -} // Dialog_Proc +} void LogDataDialogClass::Dialog_Init() { @@ -325,7 +325,7 @@ void LogDataDialogClass::Dialog_Init() status = 1; // signal init -} // Dialog_Init +} @@ -367,7 +367,7 @@ BOOL CALLBACK _logdata_dialog_proc return FALSE; } -} // _logdata_dialog_proc +} DWORD WINAPI _logdata_thread_function(LPVOID log_obj_ptr) diff --git a/Core/Tools/WW3D/max2w3d/logdlg.h b/Core/Tools/WW3D/max2w3d/logdlg.h index c902c564ba..9be2b8c7e6 100644 --- a/Core/Tools/WW3D/max2w3d/logdlg.h +++ b/Core/Tools/WW3D/max2w3d/logdlg.h @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef LOGDLG_H -#define LOGDLG_H +#pragma once #include @@ -82,6 +80,4 @@ volatile int status; }; -#endif - // EOF - logdlg.h diff --git a/Core/Tools/WW3D/max2w3d/maxworldinfo.h b/Core/Tools/WW3D/max2w3d/maxworldinfo.h index b1bebb58a7..d690edb50a 100644 --- a/Core/Tools/WW3D/max2w3d/maxworldinfo.h +++ b/Core/Tools/WW3D/max2w3d/maxworldinfo.h @@ -36,14 +36,12 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef MAXWORLDINFO_H -#define MAXWORLDINFO_H - +#pragma once #include #include "meshbuild.h" #include "nodelist.h" -#include "Vector.H" +#include "Vector.h" class GeometryExportTaskClass; @@ -87,7 +85,3 @@ class MaxWorldInfoClass : public WorldInfoClass Matrix3 ExportTrans; bool SmoothBetweenMeshes; }; - - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/meshbuild.h b/Core/Tools/WW3D/max2w3d/meshbuild.h index 4a0b09290b..bb48832aa6 100644 --- a/Core/Tools/WW3D/max2w3d/meshbuild.h +++ b/Core/Tools/WW3D/max2w3d/meshbuild.h @@ -34,17 +34,12 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef MESHBUILD_H -#define MESHBUILD_H #include "always.h" #include "vector2.h" #include "vector3.h" -#include "BITTYPE.H" +#include "BITTYPE.h" #include @@ -375,5 +370,3 @@ inline const MeshBuilderClass::MeshStatsStruct & MeshBuilderClass::Get_Mesh_Stat assert(State == STATE_MESH_PROCESSED); return Stats; } - -#endif diff --git a/Core/Tools/WW3D/max2w3d/meshcon.h b/Core/Tools/WW3D/max2w3d/meshcon.h index 792b59abee..cae17047f1 100644 --- a/Core/Tools/WW3D/max2w3d/meshcon.h +++ b/Core/Tools/WW3D/max2w3d/meshcon.h @@ -35,10 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef MESHCON_H -#define MESHCON_H - +#pragma once #ifndef ALWAYS_H #include "always.h" @@ -61,7 +58,7 @@ #endif #ifndef VECTOR_H -#include "Vector.H" +#include "Vector.h" #endif @@ -144,6 +141,3 @@ class MeshConnectionsClass }; - - -#endif /*MESHCON_H*/ diff --git a/Core/Tools/WW3D/max2w3d/meshsave.cpp b/Core/Tools/WW3D/max2w3d/meshsave.cpp index ed8de0e934..d1ff3513b1 100644 --- a/Core/Tools/WW3D/max2w3d/meshsave.cpp +++ b/Core/Tools/WW3D/max2w3d/meshsave.cpp @@ -23,7 +23,7 @@ * * * Project Name : Commando / G * * * - * File Name : MESHSAVE.CPP * + * File Name : MESHSAVE.cpp * * * * Programmer : Greg Hjelstrom * * * diff --git a/Core/Tools/WW3D/max2w3d/meshsave.h b/Core/Tools/WW3D/max2w3d/meshsave.h index 139f4b6751..db46e5549d 100644 --- a/Core/Tools/WW3D/max2w3d/meshsave.h +++ b/Core/Tools/WW3D/max2w3d/meshsave.h @@ -23,7 +23,7 @@ * * * Project Name : Commando / G * * * - * File Name : MESHSAVE.H * + * File Name : MESHSAVE.h * * * * Programmer : Greg Hjelstrom * * * @@ -35,19 +35,14 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef MESHSAVE_H -#define MESHSAVE_H #include "rawfile.h" // have to include this before Max.h #include -#include "BITTYPE.H" +#include "BITTYPE.h" #include "w3d_file.h" #include "chunkio.h" -#include "PROGRESS.H" +#include "PROGRESS.h" #include "nodelist.h" #include "util.h" #include "w3dmtl.h" @@ -218,9 +213,3 @@ class MeshSaveClass friend class DamageClass; }; - - - - - -#endif /*MESHSAVE_H*/ diff --git a/Core/Tools/WW3D/max2w3d/motion.cpp b/Core/Tools/WW3D/max2w3d/motion.cpp index 7889840118..c687772147 100644 --- a/Core/Tools/WW3D/max2w3d/motion.cpp +++ b/Core/Tools/WW3D/max2w3d/motion.cpp @@ -53,7 +53,7 @@ #include "w3d_file.h" #include "vchannel.h" #include "bchannel.h" -#include "EULER.H" +#include "EULER.h" #include "util.h" #include "errclass.h" #include "w3dutil.h" @@ -496,7 +496,7 @@ void MotionClass::compute_frame_motion(int frame) set_binary_movement(bindex, frame, binary_move); - } // if(bindex!=-1) + } } /* diff --git a/Core/Tools/WW3D/max2w3d/motion.h b/Core/Tools/WW3D/max2w3d/motion.h index 811d8f56de..071298737e 100644 --- a/Core/Tools/WW3D/max2w3d/motion.h +++ b/Core/Tools/WW3D/max2w3d/motion.h @@ -35,10 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef MOTION_H -#define MOTION_H - +#pragma once #ifndef ALWAYS_H #include "always.h" @@ -51,7 +48,7 @@ #endif #ifndef PROGRESS_H -#include "PROGRESS.H" +#include "PROGRESS.h" #endif #ifndef CHUNKIO_H @@ -59,7 +56,7 @@ #endif #ifndef VECTOR_H -#include "Vector.H" +#include "Vector.h" #endif #ifndef LOGDLG_H @@ -159,6 +156,3 @@ class MotionClass void init(void); }; - - -#endif /*MOTION_H*/ diff --git a/Core/Tools/WW3D/max2w3d/namedsel.h b/Core/Tools/WW3D/max2w3d/namedsel.h index 1c2c3722ff..28c7c71bec 100644 --- a/Core/Tools/WW3D/max2w3d/namedsel.h +++ b/Core/Tools/WW3D/max2w3d/namedsel.h @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef NAMEDSEL_H -#define NAMEDSEL_H - +#pragma once #include "max.h" @@ -78,6 +76,3 @@ class NamedSelSetList NAMED_SEL_NAME_CHUNK = 0x0023 }; }; - - -#endif /*NAMEDSEL_H*/ diff --git a/Core/Tools/WW3D/max2w3d/nullsave.h b/Core/Tools/WW3D/max2w3d/nullsave.h index 8703378710..8a433d9819 100644 --- a/Core/Tools/WW3D/max2w3d/nullsave.h +++ b/Core/Tools/WW3D/max2w3d/nullsave.h @@ -34,19 +34,12 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef NULLSAVE_H -#define NULLSAVE_H - #include #include "w3d_file.h" #include "chunkio.h" -#include "PROGRESS.H" +#include "PROGRESS.h" /******************************************************************************************* @@ -74,8 +67,3 @@ class NullSaveClass W3dNullObjectStruct NullData; }; - - - - -#endif //NULLSAVE_H diff --git a/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.h b/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.h index 0565e29e74..96fa0d295b 100644 --- a/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.h +++ b/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.h @@ -36,9 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef __PRESET_EXPORT_OPTIONS_DIALOG_H -#define __PRESET_EXPORT_OPTIONS_DIALOG_H +#pragma once #include #include @@ -118,7 +116,3 @@ class PresetExportOptionsDialogClass HWND PaneWnds[PANE_MAX]; int CurrentPane; }; - - -#endif //__PRESET_EXPORT_OPTIONS_DIALOG_H - diff --git a/Core/Tools/WW3D/max2w3d/rcmenu.h b/Core/Tools/WW3D/max2w3d/rcmenu.h index 71ba817199..27a782c6d4 100644 --- a/Core/Tools/WW3D/max2w3d/rcmenu.h +++ b/Core/Tools/WW3D/max2w3d/rcmenu.h @@ -35,8 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef RCMENU_H -#define RCMENU_H +#pragma once #include "max.h" #include "dllmain.h" @@ -85,5 +84,3 @@ class RCMenuClass : public RightClickMenu }; extern RCMenuClass TheRCMenu; - -#endif diff --git a/Core/Tools/WW3D/max2w3d/simpdib.h b/Core/Tools/WW3D/max2w3d/simpdib.h index 8c066624f5..535446c851 100644 --- a/Core/Tools/WW3D/max2w3d/simpdib.h +++ b/Core/Tools/WW3D/max2w3d/simpdib.h @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef SIMPDIB_H -#define SIMPDIB_H +#pragma once #ifndef ALWAYS_H #include "always.h" @@ -77,6 +76,3 @@ class SimpleDIBClass int Pitch; // offset from DIBPixelBase to next row (can be negative for bottom-up DIBS) }; - - -#endif /*SIMPDIB_H*/ diff --git a/Core/Tools/WW3D/max2w3d/skin.h b/Core/Tools/WW3D/max2w3d/skin.h index f42f9a0ecd..ff5f7baf2a 100644 --- a/Core/Tools/WW3D/max2w3d/skin.h +++ b/Core/Tools/WW3D/max2w3d/skin.h @@ -34,9 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SKIN_H -#define SKIN_H +#pragma once #include #include "simpmod.h" @@ -397,9 +395,3 @@ class SkinModifierClass : public Modifier, BonePickerUserClass */ friend BOOL CALLBACK _bone_influence_dialog_thunk(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam); }; - - - - -#endif - diff --git a/Core/Tools/WW3D/max2w3d/skindata.h b/Core/Tools/WW3D/max2w3d/skindata.h index 0aa3d681bc..6726465dc8 100644 --- a/Core/Tools/WW3D/max2w3d/skindata.h +++ b/Core/Tools/WW3D/max2w3d/skindata.h @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef SKINDATA_H -#define SKINDATA_H +#pragma once #include "max.h" #include "namedsel.h" @@ -157,6 +155,3 @@ class SkinDataClass : public LocalModData }; }; - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/util.h b/Core/Tools/WW3D/max2w3d/util.h index 44af73865e..96eb55e03f 100644 --- a/Core/Tools/WW3D/max2w3d/util.h +++ b/Core/Tools/WW3D/max2w3d/util.h @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef UTIL_H -#define UTIL_H +#pragma once #ifndef ALWAYS_H #include "always.h" @@ -112,6 +110,3 @@ INode *Find_Named_Node (char *nodename, INode *root); delete [] pobject; \ pobject = NULL; \ } \ - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/vchannel.cpp b/Core/Tools/WW3D/max2w3d/vchannel.cpp index f5853db406..8392aaded4 100644 --- a/Core/Tools/WW3D/max2w3d/vchannel.cpp +++ b/Core/Tools/WW3D/max2w3d/vchannel.cpp @@ -250,7 +250,7 @@ bool VectorChannelClass::SaveTimeCoded(ChunkSaveClass & csave, BitChannelClass * return true; -} // SaveTimeCoded +} /* @@ -349,7 +349,7 @@ float VectorChannelClass::test_compress(int filter_index, float scale, float val return( sqrt(error) ); -} // test_compress +} // // compress Adaptive Delta packet @@ -425,7 +425,7 @@ float VectorChannelClass::compress(int filter_index, float scale, float value1, return( error ); -} // compress +} bool VectorChannelClass::SaveAdaptiveDelta(ChunkSaveClass & csave, BitChannelClass *binmov) @@ -504,7 +504,7 @@ bool VectorChannelClass::SaveAdaptiveDelta(ChunkSaveClass & csave, BitChannelCla temp_frame++; - } // for gi + } // Brute Force Filter @@ -541,9 +541,9 @@ bool VectorChannelClass::SaveAdaptiveDelta(ChunkSaveClass & csave, BitChannelCla // update work[vi]; work[vi] = decompressed_packet[15]; - } // for vi + } frame+=16; - } // for numpackets + } // print how big we are vs non-compressed @@ -573,7 +573,7 @@ bool VectorChannelClass::SaveAdaptiveDelta(ChunkSaveClass & csave, BitChannelCla return true; -} // SaveAdaptiveDelta +} bool VectorChannelClass::Save(ChunkSaveClass & csave, BitChannelClass *binmov) @@ -675,7 +675,7 @@ void VectorChannelClass::SetSaveOptions(bool compress, int flavor, float Terr, f CompressAnimationTranslationError = Terr; CompressAnimationRotationError = DEG_TO_RAD(Rerr); -} // SetSaveOptions +} // // Set data in motion channel to identity vector @@ -706,7 +706,7 @@ void VectorChannelClass::ClearInvisibleData(BitChannelClass *vis) Set_Vector( idx, tvec ); } } -} // ClearInvisibleData +} void VectorChannelClass::set_value(int framenum,int vindex,float32 val) @@ -757,7 +757,7 @@ void VectorChannelClass::compute_range(void) while ((End >= 0) && (is_identity(Get_Vector(End)))) { End--; } -} // compute_range +} // @@ -787,7 +787,7 @@ void VectorChannelClass::remove_packet(W3dTimeCodedAnimChannelStruct * c, uint32 // Decrement Packet Count c->NumTimeCodes--; -} // remove_packet +} // // Take a non-compressed TimeCoded Motion Channel @@ -923,11 +923,11 @@ void VectorChannelClass::compress(W3dTimeCodedAnimChannelStruct * c) assert(0); break; } - } // if ReducePercent + } - } // if Reduce + } -} // compress +} @@ -1022,7 +1022,7 @@ static float32 tempvec[MAX_VECTOR_SIZE]; // else continue - } // for + } } else { @@ -1058,7 +1058,7 @@ static float32 tempvec[MAX_VECTOR_SIZE]; return( PACKETS_ALL_USEFUL ); -} // find_useless_packet +} // @@ -1137,7 +1137,7 @@ uint32 VectorChannelClass::find_useless_packetQ(W3dTimeCodedAnimChannelStruct * // else continue - } // for + } } @@ -1171,7 +1171,7 @@ uint32 VectorChannelClass::find_useless_packetQ(W3dTimeCodedAnimChannelStruct * return( PACKETS_ALL_USEFUL ); -} // find_useless_packetQ +} // @@ -1268,7 +1268,7 @@ static float32 tempvec[MAX_VECTOR_SIZE]; // else continue - } // for + } return( ret_idx ); @@ -1285,7 +1285,7 @@ static float32 tempvec[MAX_VECTOR_SIZE]; return( PACKETS_ALL_USEFUL ); -} // Find Least useful packet +} // @@ -1370,7 +1370,7 @@ uint32 VectorChannelClass::find_least_useful_packetQ(W3dTimeCodedAnimChannelStru // else continue - } // for + } return( ret_idx ); @@ -1390,7 +1390,7 @@ uint32 VectorChannelClass::find_least_useful_packetQ(W3dTimeCodedAnimChannelStru return( PACKETS_ALL_USEFUL ); -} // find_least_useful_packetQ +} // EOF - vchannel.cpp diff --git a/Core/Tools/WW3D/max2w3d/vchannel.h b/Core/Tools/WW3D/max2w3d/vchannel.h index 9d28860db1..e26d75c3ad 100644 --- a/Core/Tools/WW3D/max2w3d/vchannel.h +++ b/Core/Tools/WW3D/max2w3d/vchannel.h @@ -35,16 +35,14 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef VCHANNEL_H -#define VCHANNEL_H +#pragma once #ifndef ALWAYS_H #include "always.h" #endif #ifndef BITTYPE_H -#include "BITTYPE.H" +#include "BITTYPE.h" #endif #ifndef CHUNKIO_H @@ -136,5 +134,3 @@ class VectorChannelClass bool SaveAdaptiveDelta(ChunkSaveClass & csave, BitChannelClass *binmov); }; - -#endif /*VCHANNEL_H*/ diff --git a/Core/Tools/WW3D/max2w3d/vxl.cpp b/Core/Tools/WW3D/max2w3d/vxl.cpp index 203be02d05..969095a7b2 100644 --- a/Core/Tools/WW3D/max2w3d/vxl.cpp +++ b/Core/Tools/WW3D/max2w3d/vxl.cpp @@ -416,7 +416,7 @@ void VoxelClass::Compute_Visiblity meter.Add_Increment(); if (meter.Cancelled()) throw ErrorClass("Export Cancelled"); - } // done with the X-Y layers + } ///////////////////////////////////////////////////////////// @@ -443,7 +443,7 @@ void VoxelClass::Compute_Visiblity meter.Add_Increment(); if (meter.Cancelled()) throw ErrorClass("Export Cancelled"); - } // done with the X-Z layers + } /////////////////////////////////////////////////////////// diff --git a/Core/Tools/WW3D/max2w3d/vxl.h b/Core/Tools/WW3D/max2w3d/vxl.h index 56554989f2..0d3b688d2d 100644 --- a/Core/Tools/WW3D/max2w3d/vxl.h +++ b/Core/Tools/WW3D/max2w3d/vxl.h @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef VXL_H -#define VXL_H +#pragma once #ifndef ALWAYS_H #include "always.h" @@ -54,7 +52,7 @@ #endif #ifndef PROGRESS_H -#include "PROGRESS.H" +#include "PROGRESS.h" #endif @@ -139,6 +137,3 @@ class VoxelClass // returns the position of the center of voxel(i,j,k) Point3 Voxel_Position(int i,int j,int k); }; - - -#endif /*VXL_H*/ diff --git a/Core/Tools/WW3D/max2w3d/vxldbg.h b/Core/Tools/WW3D/max2w3d/vxldbg.h index ec3663a8d8..8a734b8a74 100644 --- a/Core/Tools/WW3D/max2w3d/vxldbg.h +++ b/Core/Tools/WW3D/max2w3d/vxldbg.h @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef VXLDBG_H -#define VXLDBG_H +#pragma once #ifndef ALWAYS_H #include "always.h" @@ -76,7 +74,3 @@ class VoxelDebugWindowClass void update_display(void); }; - - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/vxllayer.cpp b/Core/Tools/WW3D/max2w3d/vxllayer.cpp index 7ba84c77b4..3a23cfa19c 100644 --- a/Core/Tools/WW3D/max2w3d/vxllayer.cpp +++ b/Core/Tools/WW3D/max2w3d/vxllayer.cpp @@ -23,7 +23,7 @@ * * * Project Name : Commando / G * * * - * File Name : VXLLAYER.CPP * + * File Name : VXLLAYER.cpp * * * * Programmer : Greg Hjelstrom * * * diff --git a/Core/Tools/WW3D/max2w3d/vxllayer.h b/Core/Tools/WW3D/max2w3d/vxllayer.h index e1dcdf2487..d70dc849ba 100644 --- a/Core/Tools/WW3D/max2w3d/vxllayer.h +++ b/Core/Tools/WW3D/max2w3d/vxllayer.h @@ -35,15 +35,13 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef VXLLAYER_H -#define VXLLAYER_H +#pragma once #include #ifndef BITTYPE_H -#include "BITTYPE.H" +#include "BITTYPE.h" #endif #ifndef NODELIST_H @@ -144,6 +142,3 @@ class VoxelLayerClass int bitmap_width; int bitmap_height; }; - - -#endif /*VXLLAYER_H*/ diff --git a/Core/Tools/WW3D/max2w3d/w3d_file.h b/Core/Tools/WW3D/max2w3d/w3d_file.h index 3dd3463c75..06e474e83a 100644 --- a/Core/Tools/WW3D/max2w3d/w3d_file.h +++ b/Core/Tools/WW3D/max2w3d/w3d_file.h @@ -35,16 +35,10 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef W3D_FILE_H -#define W3D_FILE_H #include "always.h" -#include "BITTYPE.H" +#include "BITTYPE.h" #include "iostruct.h" #include @@ -2076,6 +2070,3 @@ struct W3dSoundRObjHeaderStruct ** Include the obsolete structures and chunk ID's */ #include "w3d_obsolete.h" - - -#endif // W3D_FILE_H diff --git a/Core/Tools/WW3D/max2w3d/w3d_obsolete.h b/Core/Tools/WW3D/max2w3d/w3d_obsolete.h index 8ab37f9189..6d36fd2ac2 100644 --- a/Core/Tools/WW3D/max2w3d/w3d_obsolete.h +++ b/Core/Tools/WW3D/max2w3d/w3d_obsolete.h @@ -34,14 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef W3D_OBSOLETE_H -#define W3D_OBSOLETE_H - ///////////////////////////////////////////////////////////////////////////////////////////// // Obsolete chunk id's @@ -328,6 +321,3 @@ struct W3dHModelAuxDataStruct float32 LODMax; uint32 FutureUse[32]; }; - - -#endif // W3D_OBSOLETE_H diff --git a/Core/Tools/WW3D/max2w3d/w3dappdata.h b/Core/Tools/WW3D/max2w3d/w3dappdata.h index 833a9dc418..a79acf429a 100644 --- a/Core/Tools/WW3D/max2w3d/w3dappdata.h +++ b/Core/Tools/WW3D/max2w3d/w3dappdata.h @@ -36,8 +36,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef W3DAPPDATA_H -#define W3DAPPDATA_H +#pragma once #include @@ -409,7 +408,3 @@ struct W3DDazzleAppDataStruct unsigned int UnUsed[4]; char DazzleType[128]; }; - - -#endif - diff --git a/Core/Tools/WW3D/max2w3d/w3ddesc.h b/Core/Tools/WW3D/max2w3d/w3ddesc.h index bd843dfe65..2eb3ce2d8a 100644 --- a/Core/Tools/WW3D/max2w3d/w3ddesc.h +++ b/Core/Tools/WW3D/max2w3d/w3ddesc.h @@ -35,8 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef W3DDESC_H -#define W3DDESC_H +#pragma once #include "always.h" #include @@ -59,6 +58,3 @@ class W3dClassDesc : public ClassDesc Class_ID ClassID(); const TCHAR * Category(); }; - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/w3ddlg.h b/Core/Tools/WW3D/max2w3d/w3ddlg.h index a04cf54a26..49801726ba 100644 --- a/Core/Tools/WW3D/max2w3d/w3ddlg.h +++ b/Core/Tools/WW3D/max2w3d/w3ddlg.h @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef W3DDLG_H -#define W3DDLG_H +#pragma once #include "always.h" #include @@ -102,6 +100,3 @@ class W3dOptionsDialogClass int UnitsType; float UnitsScale; }; - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/w3dexp.cpp b/Core/Tools/WW3D/max2w3d/w3dexp.cpp index bd75384880..b1ade39381 100644 --- a/Core/Tools/WW3D/max2w3d/w3dexp.cpp +++ b/Core/Tools/WW3D/max2w3d/w3dexp.cpp @@ -60,7 +60,7 @@ #include "meshcon.h" #include "SnapPoints.h" #include "w3ddlg.h" -#include "PROGRESS.H" +#include "PROGRESS.h" #include "errclass.h" #include "motion.h" #include "util.h" @@ -75,7 +75,7 @@ #include "geometryexportcontext.h" #include -#include "TARGA.H" +#include "TARGA.h" // Used to communicate from the exporter to the dialog. char W3dExportClass::CurrentExportPath[_MAX_DRIVE + _MAX_DIR + 1] = { '\000' }; diff --git a/Core/Tools/WW3D/max2w3d/w3dexp.h b/Core/Tools/WW3D/max2w3d/w3dexp.h index 3ad3aab222..df69186b38 100644 --- a/Core/Tools/WW3D/max2w3d/w3dexp.h +++ b/Core/Tools/WW3D/max2w3d/w3dexp.h @@ -35,8 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef W3DEXP_H -#define W3DEXP_H +#pragma once #include "always.h" #include @@ -117,6 +116,3 @@ class W3dExportClass : public SceneExport void End_Progress_Bar(void); }; - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/w3dmtl.h b/Core/Tools/WW3D/max2w3d/w3dmtl.h index 913707de11..54fb2bd9a1 100644 --- a/Core/Tools/WW3D/max2w3d/w3dmtl.h +++ b/Core/Tools/WW3D/max2w3d/w3dmtl.h @@ -34,16 +34,11 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef W3DMTL_H -#define W3DMTL_H #include "always.h" #include "w3d_file.h" -#include "Vector.H" +#include "Vector.h" class GameMtl; class Mtl; @@ -307,7 +302,3 @@ class W3dMaterialDescClass DynamicVectorClass < TexClass > Textures; }; - - - -#endif diff --git a/Core/Tools/WW3D/max2w3d/w3dutil.h b/Core/Tools/WW3D/max2w3d/w3dutil.h index 3bb2f62277..ad1e6a4e57 100644 --- a/Core/Tools/WW3D/max2w3d/w3dutil.h +++ b/Core/Tools/WW3D/max2w3d/w3dutil.h @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef W3DUTIL_H -#define W3DUTIL_H +#pragma once #include #include "utilapi.h" @@ -126,5 +124,3 @@ W3DAppData0Struct * GetW3DAppData0 (INode *node); W3DAppData1Struct * GetW3DAppData1 (INode *node); W3DAppData2Struct * GetW3DAppData2 (INode *node); W3DDazzleAppDataStruct * GetW3DDazzleAppData(INode *node); - -#endif diff --git a/Core/Tools/WW3D/pluglib/BITTYPE.H b/Core/Tools/WW3D/pluglib/BITTYPE.h similarity index 95% rename from Core/Tools/WW3D/pluglib/BITTYPE.H rename to Core/Tools/WW3D/pluglib/BITTYPE.h index ccd0ebe22a..803142c16f 100644 --- a/Core/Tools/WW3D/pluglib/BITTYPE.H +++ b/Core/Tools/WW3D/pluglib/BITTYPE.h @@ -28,8 +28,7 @@ * *****************************************************************/ -#ifndef BITTYPE_H -#define BITTYPE_H +#pragma once typedef unsigned char uint8; typedef unsigned short uint16; @@ -41,6 +40,3 @@ typedef signed long sint32; typedef float float32; typedef double float64; - - -#endif //BITTYPE_H diff --git a/Core/Tools/WW3D/pluglib/CMakeLists.txt b/Core/Tools/WW3D/pluglib/CMakeLists.txt index de04ff9e63..e329dd35b9 100644 --- a/Core/Tools/WW3D/pluglib/CMakeLists.txt +++ b/Core/Tools/WW3D/pluglib/CMakeLists.txt @@ -1,14 +1,14 @@ set(PLUGLIB_SRC "aaplane.h" "always.h" - "BITTYPE.H" + "BITTYPE.h" "bool.h" "borlandc.h" "chunkio.cpp" "chunkio.h" "errclass.h" - "EULER.CPP" - "EULER.H" + "EULER.cpp" + "EULER.h" "hashcalc.h" "hsv.cpp" "hsv.h" @@ -26,7 +26,7 @@ set(PLUGLIB_SRC "palette.cpp" "palette.h" "plane.h" - "PROGRESS.H" + "PROGRESS.h" "rawfile.cpp" "rawfile.h" "realcrc.cpp" @@ -34,8 +34,8 @@ set(PLUGLIB_SRC "rgb.cpp" "rgb.h" "uarray.h" - "Vector.CPP" - "Vector.H" + "Vector.cpp" + "Vector.h" "vector2.h" "vector3.h" "vector3i.h" diff --git a/Core/Tools/WW3D/pluglib/EULER.CPP b/Core/Tools/WW3D/pluglib/EULER.cpp similarity index 98% rename from Core/Tools/WW3D/pluglib/EULER.CPP rename to Core/Tools/WW3D/pluglib/EULER.cpp index b997b1d1e9..517e51ab07 100644 --- a/Core/Tools/WW3D/pluglib/EULER.CPP +++ b/Core/Tools/WW3D/pluglib/EULER.cpp @@ -16,14 +16,14 @@ ** along with this program. If not, see . */ -/* $Header: /Commando/Code/Tools/max2w3d/EULER.CPP 5 12/02/97 10:14p Greg_h $ */ +/* $Header: /Commando/Code/Tools/max2w3d/EULER.cpp 5 12/02/97 10:14p Greg_h $ */ /*********************************************************************************************** *** Confidential - Westwood Studios *** *********************************************************************************************** * * * Project Name : Commando / G 3D Engine * * * - * $Archive:: /Commando/Code/Tools/max2w3d/EULER.CPP $* + * $Archive:: /Commando/Code/Tools/max2w3d/EULER.cpp $* * * * $Author:: Greg_h $* * * @@ -36,7 +36,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#include "EULER.H" +#include "EULER.h" #include diff --git a/Core/Tools/WW3D/pluglib/EULER.H b/Core/Tools/WW3D/pluglib/EULER.h similarity index 96% rename from Core/Tools/WW3D/pluglib/EULER.H rename to Core/Tools/WW3D/pluglib/EULER.h index 76f28c018a..189c82dd55 100644 --- a/Core/Tools/WW3D/pluglib/EULER.H +++ b/Core/Tools/WW3D/pluglib/EULER.h @@ -16,14 +16,14 @@ ** along with this program. If not, see . */ -/* $Header: /Commando/Code/Tools/max2w3d/EULER.H 3 10/28/97 6:08p Greg_h $ */ +/* $Header: /Commando/Code/Tools/max2w3d/EULER.h 3 10/28/97 6:08p Greg_h $ */ /*********************************************************************************************** *** Confidential - Westwood Studios *** *********************************************************************************************** * * * Project Name : Commando / G 3D Engine * * * - * $Archive:: /Commando/Code/Tools/max2w3d/EULER.H $* + * $Archive:: /Commando/Code/Tools/max2w3d/EULER.h $* * * * $Author:: Greg_h $* * * @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef EULER_H -#define EULER_H +#pragma once #include @@ -114,6 +112,3 @@ class EulerAnglesClass int Order; }; - - -#endif /*EULER_H*/ diff --git a/Core/Tools/WW3D/pluglib/PROGRESS.H b/Core/Tools/WW3D/pluglib/PROGRESS.h similarity index 95% rename from Core/Tools/WW3D/pluglib/PROGRESS.H rename to Core/Tools/WW3D/pluglib/PROGRESS.h index c32b4f4eab..4b7dfc888d 100644 --- a/Core/Tools/WW3D/pluglib/PROGRESS.H +++ b/Core/Tools/WW3D/pluglib/PROGRESS.h @@ -16,14 +16,14 @@ ** along with this program. If not, see . */ -/* $Header: /Commando/Code/Tools/max2w3d/PROGRESS.H 5 10/28/97 6:08p Greg_h $ */ +/* $Header: /Commando/Code/Tools/max2w3d/PROGRESS.h 5 10/28/97 6:08p Greg_h $ */ /*********************************************************************************************** *** Confidential - Westwood Studios *** *********************************************************************************************** * * * Project Name : Commando / G 3D engine * * * - * File Name : PROGRESS.H * + * File Name : PROGRESS.h * * * * Programmer : James McNeil * * * @@ -35,8 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef PROGRESS_H -#define PROGRESS_H +#pragma once #include "always.h" @@ -121,5 +120,3 @@ class Progress_Meter_Class BOOL Cancel_Requested; }; - -#endif /* PROGRESS_H */ diff --git a/Core/Tools/WW3D/pluglib/Vector.CPP b/Core/Tools/WW3D/pluglib/Vector.cpp similarity index 99% rename from Core/Tools/WW3D/pluglib/Vector.CPP rename to Core/Tools/WW3D/pluglib/Vector.cpp index e5006a44e0..328add8e5d 100644 --- a/Core/Tools/WW3D/pluglib/Vector.CPP +++ b/Core/Tools/WW3D/pluglib/Vector.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Code/Tools/pluglib/Vector.CPP $* + * $Archive:: /Commando/Code/Tools/pluglib/Vector.cpp $* * * * $Author:: Greg_h $* * * @@ -53,7 +53,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include "always.h" -#include "Vector.H" +#include "Vector.h" #include /* diff --git a/Core/Tools/WW3D/pluglib/Vector.H b/Core/Tools/WW3D/pluglib/Vector.h similarity index 99% rename from Core/Tools/WW3D/pluglib/Vector.H rename to Core/Tools/WW3D/pluglib/Vector.h index e19e8bedce..aa2ce7b26f 100644 --- a/Core/Tools/WW3D/pluglib/Vector.H +++ b/Core/Tools/WW3D/pluglib/Vector.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Code/Library/Vector.H $* + * $Archive:: /Commando/Code/Library/Vector.h $* * * * $Author:: Byon_g $* * * @@ -50,8 +50,7 @@ * DynamicVectorClass::Uninitialized_Add -- Add an empty place to the vector. * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef VECTOR_H -#define VECTOR_H +#pragma once #include "noinit.h" #include @@ -1001,7 +1000,3 @@ bool Pointer_Vector_Remove(T const * ptr, VectorClass & vec) } return(false); } - - -#endif - diff --git a/Core/Tools/WW3D/pluglib/WWmatrix3.h b/Core/Tools/WW3D/pluglib/WWmatrix3.h index 3b398e68c5..acb168f1e6 100644 --- a/Core/Tools/WW3D/pluglib/WWmatrix3.h +++ b/Core/Tools/WW3D/pluglib/WWmatrix3.h @@ -23,7 +23,7 @@ * * * Project Name : WW3D * * * - * File Name : MATRIX3.H * + * File Name : MATRIX3.h * * * * Programmer : Greg Hjelstrom * * * @@ -53,13 +53,7 @@ * Matrix3::Rotate_Z -- Post-multiplies the matrix with a rotation about Z * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef Matrix3_H -#define Matrix3_H #include "always.h" #include "vector3.h" @@ -1007,5 +1001,3 @@ inline void Matrix3::Transpose_Rotate_Vector(const Matrix3 & A,const Vector3 & i out->Y = (A[0][1] * v->X + A[1][1] * v->Y + A[2][1] * v->Z); out->Z = (A[0][2] * v->X + A[1][2] * v->Y + A[2][2] * v->Z); } - -#endif /*Matrix3_H*/ diff --git a/Core/Tools/WW3D/pluglib/aaplane.h b/Core/Tools/WW3D/pluglib/aaplane.h index 06bac66db5..0e7cb97e02 100644 --- a/Core/Tools/WW3D/pluglib/aaplane.h +++ b/Core/Tools/WW3D/pluglib/aaplane.h @@ -34,12 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef AAPLANE_H -#define AAPLANE_H #include "always.h" #include "vector3.h" @@ -79,5 +74,3 @@ inline void AAPlaneClass::Get_Normal(Vector3 * normal) const normal->Set(0,0,0); (*normal)[Normal] = 1.0f; } - -#endif diff --git a/Core/Tools/WW3D/pluglib/always.h b/Core/Tools/WW3D/pluglib/always.h index 720a457211..79a856d238 100644 --- a/Core/Tools/WW3D/pluglib/always.h +++ b/Core/Tools/WW3D/pluglib/always.h @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef ALWAYS_H -#define ALWAYS_H +#pragma once // Disable warning about exception handling not being enabled. It's used as part of STL - in a part of STL we don't use. #pragma warning(disable : 4530) @@ -165,6 +161,3 @@ template T max(T a,T b) #ifndef size_of #define size_of(typ,id) sizeof(((typ*)0)->id) #endif - - -#endif diff --git a/Core/Tools/WW3D/pluglib/bool.h b/Core/Tools/WW3D/pluglib/bool.h index 2c70667974..323d7c747b 100644 --- a/Core/Tools/WW3D/pluglib/bool.h +++ b/Core/Tools/WW3D/pluglib/bool.h @@ -33,9 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 + #pragma once -#endif // _MSC_VER >= 1000 #if !defined(TRUE_FALSE_DEFINED) && !defined(__BORLANDC__) && (_MSC_VER < 1100) && !defined(__WATCOMC__) #define TRUE_FALSE_DEFINED diff --git a/Core/Tools/WW3D/pluglib/borlandc.h b/Core/Tools/WW3D/pluglib/borlandc.h index 194faf5877..61b945dd0a 100644 --- a/Core/Tools/WW3D/pluglib/borlandc.h +++ b/Core/Tools/WW3D/pluglib/borlandc.h @@ -33,9 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 + #pragma once -#endif // _MSC_VER >= 1000 #if !defined(BORLANDC_H) && defined(__BORLANDC__) #define BORLANDC_H diff --git a/Core/Tools/WW3D/pluglib/chunkio.h b/Core/Tools/WW3D/pluglib/chunkio.h index 4768dd8752..2c38fc42b7 100644 --- a/Core/Tools/WW3D/pluglib/chunkio.h +++ b/Core/Tools/WW3D/pluglib/chunkio.h @@ -34,19 +34,15 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef CHUNKIO_H -#define CHUNKIO_H +#pragma once #ifndef ALWAYS_H #include "always.h" #endif #ifndef BITTYPE_H -#include "BITTYPE.H" +#include "BITTYPE.h" #endif #ifndef WWFILE_H @@ -374,7 +370,3 @@ class ChunkLoadClass */ #define OBSOLETE_MICRO_CHUNK(id) \ case (id): break; - - - -#endif // CHUNKIO_H diff --git a/Core/Tools/WW3D/pluglib/errclass.h b/Core/Tools/WW3D/pluglib/errclass.h index 67d699bcdd..60c26fa0cf 100644 --- a/Core/Tools/WW3D/pluglib/errclass.h +++ b/Core/Tools/WW3D/pluglib/errclass.h @@ -35,8 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef ERRCLASS_H -#define ERRCLASS_H +#pragma once #include @@ -83,6 +82,3 @@ inline ErrorClass & ErrorClass::operator = (const ErrorClass & that) return *this; } - - -#endif //ERRCLASS_H diff --git a/Core/Tools/WW3D/pluglib/hashcalc.h b/Core/Tools/WW3D/pluglib/hashcalc.h index c6a63933f8..a01fbf08ff 100644 --- a/Core/Tools/WW3D/pluglib/hashcalc.h +++ b/Core/Tools/WW3D/pluglib/hashcalc.h @@ -33,14 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - - -#ifndef HASHCALC_H -#define HASHCALC_H +#pragma once /* ** HashCalculatorClass @@ -68,7 +62,3 @@ template class HashCalculatorClass virtual int Num_Hash_Values(void) = 0; virtual int Get_Hash_Value(int index = 0) = 0; }; - - - -#endif diff --git a/Core/Tools/WW3D/pluglib/hsv.cpp b/Core/Tools/WW3D/pluglib/hsv.cpp index 2fd723c583..f9932e2d9a 100644 --- a/Core/Tools/WW3D/pluglib/hsv.cpp +++ b/Core/Tools/WW3D/pluglib/hsv.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/HSV.CPP $* + * $Archive:: /Commando/Library/HSV.cpp $* * * * $Author:: Greg_h $* * * diff --git a/Core/Tools/WW3D/pluglib/hsv.h b/Core/Tools/WW3D/pluglib/hsv.h index 277cc9f35e..e3f2cc2221 100644 --- a/Core/Tools/WW3D/pluglib/hsv.h +++ b/Core/Tools/WW3D/pluglib/hsv.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/HSV.H $* + * $Archive:: /Commando/Library/HSV.h $* * * * $Author:: Greg_h $* * * @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef HSV_H -#define HSV_H +#pragma once class RGBClass; class HSVClass; @@ -77,5 +76,3 @@ class HSVClass unsigned char Saturation; unsigned char Value; }; - -#endif diff --git a/Core/Tools/WW3D/pluglib/iostruct.h b/Core/Tools/WW3D/pluglib/iostruct.h index 88a933d7c8..7b0bc9116e 100644 --- a/Core/Tools/WW3D/pluglib/iostruct.h +++ b/Core/Tools/WW3D/pluglib/iostruct.h @@ -33,20 +33,14 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#if defined(_MSC_VER) #pragma once -#endif -#ifndef IOSTRUCT_H -#define IOSTRUCT_H +#pragma once #ifndef BITTYPE_H -#include "BITTYPE.H" + +#include "BITTYPE.h" #endif /* @@ -78,8 +72,3 @@ struct IOQuaternionStruct { float32 Q[4]; }; - - - -#endif - diff --git a/Core/Tools/WW3D/pluglib/matrix3d.cpp b/Core/Tools/WW3D/pluglib/matrix3d.cpp index fffed34adf..0b9afa7fcc 100644 --- a/Core/Tools/WW3D/pluglib/matrix3d.cpp +++ b/Core/Tools/WW3D/pluglib/matrix3d.cpp @@ -23,7 +23,7 @@ * * * Project Name : Voxel Technology * * * - * File Name : MATRIX3D.CPP * + * File Name : MATRIX3D.cpp * * * * Programmer : Greg Hjelstrom * * * diff --git a/Core/Tools/WW3D/pluglib/matrix3d.h b/Core/Tools/WW3D/pluglib/matrix3d.h index 66109b8d17..d8d5111d28 100644 --- a/Core/Tools/WW3D/pluglib/matrix3d.h +++ b/Core/Tools/WW3D/pluglib/matrix3d.h @@ -23,7 +23,7 @@ * * * Project Name : Voxel Technology * * * - * File Name : MATRIX3D.H * + * File Name : MATRIX3D.h * * * * Programmer : Greg Hjelstrom * * * @@ -70,12 +70,7 @@ * operator != -- Matrix inequality operator * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef MATRIX3D_H -#define MATRIX3D_H #ifdef _UNIX #include "osdep.h" @@ -1512,5 +1507,3 @@ inline void Matrix3D::Inverse_Rotate_Vector(const Matrix3D & A,const Vector3 & i out->Y = (A[0][1] * v->X + A[1][1] * v->Y + A[2][1] * v->Z); out->Z = (A[0][2] * v->X + A[1][2] * v->Y + A[2][2] * v->Z); } - -#endif /* MATRIX3D_H */ diff --git a/Core/Tools/WW3D/pluglib/matrix4.h b/Core/Tools/WW3D/pluglib/matrix4.h index 2f3038a9d2..8e9298d93f 100644 --- a/Core/Tools/WW3D/pluglib/matrix4.h +++ b/Core/Tools/WW3D/pluglib/matrix4.h @@ -23,7 +23,7 @@ * * * Project Name : WW3D * * * - * File Name : MATRIX4.H * + * File Name : MATRIX4.h * * * * Programmer : Greg Hjelstrom * * * @@ -52,13 +52,7 @@ * Matrix4::operator /= -- "divide equals" operator * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef MATRIX4_H -#define MATRIX4_H #include "always.h" #include "vector4.h" @@ -712,5 +706,3 @@ inline void Matrix4::Transform_Vector(const Matrix4 & A,const Vector3 & in,Vecto out->Y = (A[1][0] * v->X + A[1][1] * v->Y + A[1][2] * v->Z + A[1][3]); out->Z = (A[2][0] * v->X + A[2][1] * v->Y + A[2][2] * v->Z + A[2][3]); } - -#endif /*MATRIX4_H*/ diff --git a/Core/Tools/WW3D/pluglib/nodefilt.cpp b/Core/Tools/WW3D/pluglib/nodefilt.cpp index f393e1d763..be1d3886fa 100644 --- a/Core/Tools/WW3D/pluglib/nodefilt.cpp +++ b/Core/Tools/WW3D/pluglib/nodefilt.cpp @@ -23,7 +23,7 @@ * * * Project Name : Commando / G * * * - * File Name : NODEFILT.CPP * + * File Name : NODEFILT.cpp * * * * Programmer : Greg Hjelstrom * * * diff --git a/Core/Tools/WW3D/pluglib/nodefilt.h b/Core/Tools/WW3D/pluglib/nodefilt.h index 92e07d26a3..999fd897a4 100644 --- a/Core/Tools/WW3D/pluglib/nodefilt.h +++ b/Core/Tools/WW3D/pluglib/nodefilt.h @@ -23,7 +23,7 @@ * * * Project Name : Commando / G * * * - * File Name : NODEFILT.H * + * File Name : NODEFILT.h * * * * Programmer : Greg Hjelstrom * * * @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef NODEFILT_H -#define NODEFILT_H +#pragma once #include "always.h" #include @@ -172,7 +170,3 @@ class VisibleSelectedINodeFilter : public INodeFilterClass public: virtual BOOL Accept_Node(INode * node, TimeValue time); }; - - - -#endif /*NODEFILT_H*/ diff --git a/Core/Tools/WW3D/pluglib/nodelist.cpp b/Core/Tools/WW3D/pluglib/nodelist.cpp index ff5b804dd4..ef13af11c7 100644 --- a/Core/Tools/WW3D/pluglib/nodelist.cpp +++ b/Core/Tools/WW3D/pluglib/nodelist.cpp @@ -23,7 +23,7 @@ * * * Project Name : Commando / G * * * - * File Name : NODELIST.CPP * + * File Name : NODELIST.cpp * * * * Programmer : Greg Hjelstrom * * * diff --git a/Core/Tools/WW3D/pluglib/nodelist.h b/Core/Tools/WW3D/pluglib/nodelist.h index 4dfc702cc2..e7adc255e3 100644 --- a/Core/Tools/WW3D/pluglib/nodelist.h +++ b/Core/Tools/WW3D/pluglib/nodelist.h @@ -23,7 +23,7 @@ * * * Project Name : Commando / G * * * - * File Name : NODELIST.H * + * File Name : NODELIST.h * * * * Programmer : Greg Hjelstrom * * * @@ -35,9 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef NODELIST_H -#define NODELIST_H +#pragma once #include "always.h" #include @@ -97,6 +95,3 @@ class INodeCompareClass // returns >0 if nodea > node b. virtual int operator() (INode * nodea,INode * nodeb) const = 0; }; - - -#endif /*NODELIST_H*/ diff --git a/Core/Tools/WW3D/pluglib/noinit.h b/Core/Tools/WW3D/pluglib/noinit.h index efa714de2c..dfbe3b1573 100644 --- a/Core/Tools/WW3D/pluglib/noinit.h +++ b/Core/Tools/WW3D/pluglib/noinit.h @@ -34,8 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef NOINIT_H -#define NOINIT_H +#pragma once /********************************************************************** ** This class is solely used as a parameter to a constructor that does @@ -52,6 +51,3 @@ class NoInitClass { void operator () (void) const {}; }; #endif - - -#endif diff --git a/Core/Tools/WW3D/pluglib/palette.cpp b/Core/Tools/WW3D/pluglib/palette.cpp index 55e0c7330d..f270eb8faf 100644 --- a/Core/Tools/WW3D/pluglib/palette.cpp +++ b/Core/Tools/WW3D/pluglib/palette.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/PALETTE.CPP $* + * $Archive:: /Commando/Library/PALETTE.cpp $* * * * $Author:: Greg_h $* * * diff --git a/Core/Tools/WW3D/pluglib/palette.h b/Core/Tools/WW3D/pluglib/palette.h index eb89c3d2f9..211e950715 100644 --- a/Core/Tools/WW3D/pluglib/palette.h +++ b/Core/Tools/WW3D/pluglib/palette.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /G/wwlib/PALETTE.H $* + * $Archive:: /G/wwlib/PALETTE.h $* * * * $Author:: Eric_c $* * * @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef PALETTE_H -#define PALETTE_H +#pragma once #include "rgb.h" @@ -76,6 +72,3 @@ class PaletteClass protected: RGBClass Palette[COLOR_COUNT]; }; - - -#endif diff --git a/Core/Tools/WW3D/pluglib/plane.h b/Core/Tools/WW3D/pluglib/plane.h index 62f2740485..ed7b8bb253 100644 --- a/Core/Tools/WW3D/pluglib/plane.h +++ b/Core/Tools/WW3D/pluglib/plane.h @@ -23,7 +23,7 @@ * * * Project Name : Voxel Technology * * * - * File Name : PLANE.H * + * File Name : PLANE.h * * * * Programmer : Greg Hjelstrom * * * @@ -35,8 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifndef PLANE_H -#define PLANE_H +#pragma once #ifndef VECTOR3_H #include "vector3.h" @@ -93,7 +92,3 @@ inline bool In_Front(const Vector3 & point,const PlaneClass & plane) double dist = point * plane.N; return (dist > plane.D); } - - - -#endif /*PLANE_H*/ diff --git a/Core/Tools/WW3D/pluglib/rawfile.cpp b/Core/Tools/WW3D/pluglib/rawfile.cpp index ef0c63735a..996312b9f9 100644 --- a/Core/Tools/WW3D/pluglib/rawfile.cpp +++ b/Core/Tools/WW3D/pluglib/rawfile.cpp @@ -74,7 +74,7 @@ ** This is a duplicate of the error numbers. The error handler for the RawFileClass handles ** these errors. If the error routine is overridden and additional errors are defined, then ** use numbers starting with 100. Note that these errors here are listed in numerical order. - ** These errors are defined in the standard header file "ERRNO.H". + ** These errors are defined in the standard header file "ERRNO.h". */ EZERO, // Non-error. EINVFNC, // Invalid function number. @@ -185,7 +185,7 @@ bool RawFileClass::Is_Open(void) const * Display an error message as indicated. If it is allowed to retry, then pressing a key * * will return from this function. Otherwise, it will exit the program with "exit()". * * * - * INPUT: error -- The error number (same as the DOSERR.H error numbers). * + * INPUT: error -- The error number (same as the DOSERR.h error numbers). * * * * canretry -- Can this routine exit normally so that retrying can occur? If this is * * false, then the program WILL exit in this routine. * diff --git a/Core/Tools/WW3D/pluglib/rawfile.h b/Core/Tools/WW3D/pluglib/rawfile.h index 1ab2c41b39..40d81d696a 100644 --- a/Core/Tools/WW3D/pluglib/rawfile.h +++ b/Core/Tools/WW3D/pluglib/rawfile.h @@ -37,12 +37,8 @@ * RawFileClass::~RawFileClass -- Default deconstructor for a file object. * * RawFileClass::Is_Open -- Checks to see if the file is open or not. * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef RAWFILE_Hx -#define RAWFILE_Hx +#pragma once //#include @@ -199,7 +195,3 @@ inline char const * RawFileClass::File_Name(void) const { return(Filename); } - - - -#endif diff --git a/Core/Tools/WW3D/pluglib/realcrc.h b/Core/Tools/WW3D/pluglib/realcrc.h index 347d962c00..c858e5f583 100644 --- a/Core/Tools/WW3D/pluglib/realcrc.h +++ b/Core/Tools/WW3D/pluglib/realcrc.h @@ -33,17 +33,9 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 - -#ifndef REALCRC_H -#define REALCRC_H +#pragma once unsigned long CRC_Memory( const unsigned char *data, unsigned long length, unsigned long crc = 0 ); unsigned long CRC_String( const char *string, unsigned long crc = 0 ); unsigned long CRC_Stringi( const char *string, unsigned long crc = 0 ); - - -#endif diff --git a/Core/Tools/WW3D/pluglib/rgb.cpp b/Core/Tools/WW3D/pluglib/rgb.cpp index 9b2bb10188..1bfcc0dbb2 100644 --- a/Core/Tools/WW3D/pluglib/rgb.cpp +++ b/Core/Tools/WW3D/pluglib/rgb.cpp @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /Commando/Library/RGB.CPP $* + * $Archive:: /Commando/Library/RGB.cpp $* * * * $Author:: Greg_h $* * * diff --git a/Core/Tools/WW3D/pluglib/rgb.h b/Core/Tools/WW3D/pluglib/rgb.h index 0209e8d21a..20b76bd4a6 100644 --- a/Core/Tools/WW3D/pluglib/rgb.h +++ b/Core/Tools/WW3D/pluglib/rgb.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /G/wwlib/RGB.H $* + * $Archive:: /G/wwlib/RGB.h $* * * * $Author:: Eric_c $* * * @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef RGB_H -#define RGB_H +#pragma once class PaletteClass; class HSVClass; @@ -91,5 +87,3 @@ class RGBClass }; extern RGBClass const BlackColor; - -#endif diff --git a/Core/Tools/WW3D/pluglib/uarray.h b/Core/Tools/WW3D/pluglib/uarray.h index a754009304..1b89db61b3 100644 --- a/Core/Tools/WW3D/pluglib/uarray.h +++ b/Core/Tools/WW3D/pluglib/uarray.h @@ -36,19 +36,15 @@ * UniqueArrayClass::~UniqueArrayClass -- destructor * * UniqueArrayClass::Add -- Add an item to the array * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef UARRAY_H -#define UARRAY_H +#pragma once #ifndef HASHCALC_H #include "hashcalc.h" #endif #ifndef VECTOR_H -#include "Vector.H" +#include "Vector.h" #endif @@ -222,7 +218,3 @@ inline int UniqueArrayClass::Add(const T & new_item) return index; } - - -#endif // UARRAY_H - diff --git a/Core/Tools/WW3D/pluglib/vector2.h b/Core/Tools/WW3D/pluglib/vector2.h index b12c89cae7..91ff7d7e93 100644 --- a/Core/Tools/WW3D/pluglib/vector2.h +++ b/Core/Tools/WW3D/pluglib/vector2.h @@ -23,7 +23,7 @@ * * * Project Name : Westwood 3D * * * - * File Name : VECTOR2.H * + * File Name : VECTOR2.h * * * * Programmer : Greg Hjelstrom * * * @@ -49,12 +49,7 @@ * Vector2::Lerp -- linearly interpolates two Vector2's * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef VECTOR2_H -#define VECTOR2_H #include "always.h" #include "wwmath.h" @@ -634,7 +629,3 @@ inline void Vector2::Lerp(const Vector2 & a,const Vector2 & b,float t,Vector2 * set_result->X = (a.X + (b.X - a.X)*t); set_result->Y = (a.Y + (b.Y - a.Y)*t); } - - -#endif /* VECTOR2_H */ - diff --git a/Core/Tools/WW3D/pluglib/vector3.h b/Core/Tools/WW3D/pluglib/vector3.h index e3e5ce75dd..9249b8a5c1 100644 --- a/Core/Tools/WW3D/pluglib/vector3.h +++ b/Core/Tools/WW3D/pluglib/vector3.h @@ -23,7 +23,7 @@ * * * Project Name : Westwood 3D * * * - * File Name : VECTOR3.H * + * File Name : VECTOR3.h * * * * Programmer : Greg Hjelstrom * * * @@ -63,12 +63,7 @@ * Vector3::Is_Valid -- Verifies that each component of this vector is a valid float * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef VECTOR3_H -#define VECTOR3_H #include "always.h" #include "wwmath.h" @@ -925,6 +920,3 @@ WWINLINE unsigned long Vector3::Convert_To_ARGB( void ) const (unsigned(Y*255.0f)<<8) | (unsigned(Z*255.0f)); } - -#endif /* Vector3_H */ - diff --git a/Core/Tools/WW3D/pluglib/vector3i.h b/Core/Tools/WW3D/pluglib/vector3i.h index e7e7955f9c..4f65ee531c 100644 --- a/Core/Tools/WW3D/pluglib/vector3i.h +++ b/Core/Tools/WW3D/pluglib/vector3i.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef VECTOR3I_H -#define VECTOR3I_H #include "always.h" @@ -90,5 +84,3 @@ WWINLINE int& Vector3i::operator[] (int n) { return ((int*)this)[n]; } - -#endif diff --git a/Core/Tools/WW3D/pluglib/vector4.h b/Core/Tools/WW3D/pluglib/vector4.h index 76325fdd5b..620664a313 100644 --- a/Core/Tools/WW3D/pluglib/vector4.h +++ b/Core/Tools/WW3D/pluglib/vector4.h @@ -23,7 +23,7 @@ * * * Project Name : Westwood 3D * * * - * File Name : VECTOR4.H * + * File Name : VECTOR4.h * * * * Programmer : Greg Hjelstrom * * * @@ -44,12 +44,7 @@ * Vector4::Is_Valid -- Vector4::Is_Valid * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef VECTOR4_H -#define VECTOR4_H #include "always.h" #include "wwmath.h" @@ -384,7 +379,3 @@ inline bool Vector4::Is_Valid(void) const { return (WWMath::Is_Valid_Float(X) && WWMath::Is_Valid_Float(Y) && WWMath::Is_Valid_Float(Z) && WWMath::Is_Valid_Float(W)); } - - -#endif /* VECTOR4_H */ - diff --git a/Core/Tools/WW3D/pluglib/visualc.h b/Core/Tools/WW3D/pluglib/visualc.h index 3835ce3df8..2d23ad8d83 100644 --- a/Core/Tools/WW3D/pluglib/visualc.h +++ b/Core/Tools/WW3D/pluglib/visualc.h @@ -33,9 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 + #pragma once -#endif // _MSC_VER >= 1000 #if defined(_MSC_VER) diff --git a/Core/Tools/WW3D/pluglib/w3d_file.h b/Core/Tools/WW3D/pluglib/w3d_file.h index b29a6780c2..98f09b88e0 100644 --- a/Core/Tools/WW3D/pluglib/w3d_file.h +++ b/Core/Tools/WW3D/pluglib/w3d_file.h @@ -35,14 +35,12 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#ifndef W3D_FILE_H -#define W3D_FILE_H +#pragma once #include "always.h" #ifndef BITTYPE_H -#include "BITTYPE.H" +#include "BITTYPE.h" #endif @@ -883,7 +881,3 @@ struct W3dTileMapPartitionStruct W3dVectorStruct Min; // min corner of the bounding box W3dVectorStruct Max; // max corner of the bounding box }; - - - -#endif diff --git a/Core/Tools/WW3D/pluglib/w3dquat.cpp b/Core/Tools/WW3D/pluglib/w3dquat.cpp index 3212406c78..f50922fbe5 100644 --- a/Core/Tools/WW3D/pluglib/w3dquat.cpp +++ b/Core/Tools/WW3D/pluglib/w3dquat.cpp @@ -23,7 +23,7 @@ * * * Project Name : Voxel Technology * * * - * File Name : QUAT.CPP * + * File Name : QUAT.cpp * * * * Programmer : Greg Hjelstrom * * * diff --git a/Core/Tools/WW3D/pluglib/w3dquat.h b/Core/Tools/WW3D/pluglib/w3dquat.h index b2694e308c..b0ddb01e27 100644 --- a/Core/Tools/WW3D/pluglib/w3dquat.h +++ b/Core/Tools/WW3D/pluglib/w3dquat.h @@ -23,7 +23,7 @@ * * * Project Name : Voxel Technology * * * - * File Name : QUAT.H * + * File Name : QUAT.h * * * * Programmer : Greg Hjelstrom * * * @@ -35,12 +35,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef QUAT_H -#define QUAT_H #include "always.h" #include "wwmath.h" @@ -255,8 +250,3 @@ inline bool Quaternion::Is_Valid(void) const WWMath::Is_Valid_Float(Z) && WWMath::Is_Valid_Float(W) ); } - -#endif /* QUAT_H */ - - - diff --git a/Core/Tools/WW3D/pluglib/watcom.h b/Core/Tools/WW3D/pluglib/watcom.h index 31170d9c1f..9acc099e26 100644 --- a/Core/Tools/WW3D/pluglib/watcom.h +++ b/Core/Tools/WW3D/pluglib/watcom.h @@ -22,7 +22,7 @@ * * * Project Name : Command & Conquer * * * - * $Archive:: /G/wwlib/WATCOM.H $* + * $Archive:: /G/wwlib/WATCOM.h $* * * * $Author:: Eric_c $* * * @@ -33,9 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 + #pragma once -#endif // _MSC_VER >= 1000 #if !defined(WATCOM_H) && defined(__WATCOMC__) #define WATCOM_H diff --git a/Core/Tools/WW3D/pluglib/win.h b/Core/Tools/WW3D/pluglib/win.h index 83fee6bdd1..ecd1c7a64d 100644 --- a/Core/Tools/WW3D/pluglib/win.h +++ b/Core/Tools/WW3D/pluglib/win.h @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef WIN_H -#define WIN_H +#pragma once /* ** This header file includes the Windows headers. If there are any special pragmas that need @@ -69,7 +65,7 @@ #pragma warning(pop) #endif -#ifdef _WINDOWS +#ifdef _WIN32 extern HINSTANCE ProgramInstance; extern HWND MainWindow; extern bool GameInFocus; @@ -84,8 +80,6 @@ void __cdecl Print_Win32Error(unsigned long win32Error); #endif // RTS_DEBUG -#else // _WINDOWS +#else // _WIN32 #include -#endif // _WINDOWS - -#endif // WIN_H +#endif // _WIN32 diff --git a/Core/Tools/WW3D/pluglib/wwfile.h b/Core/Tools/WW3D/pluglib/wwfile.h index acf778bfd3..1ae0e39403 100644 --- a/Core/Tools/WW3D/pluglib/wwfile.h +++ b/Core/Tools/WW3D/pluglib/wwfile.h @@ -33,12 +33,8 @@ *---------------------------------------------------------------------------------------------* * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#if _MSC_VER >= 1000 -#pragma once -#endif // _MSC_VER >= 1000 -#ifndef WWFILE_Hx -#define WWFILE_Hx +#pragma once #ifdef _UNIX #include "osdep.h" @@ -108,5 +104,3 @@ class FileClass int Printf_Indented(unsigned depth, char *str, ...); }; - -#endif diff --git a/Core/Tools/WW3D/pluglib/wwmath.h b/Core/Tools/WW3D/pluglib/wwmath.h index 25264d389e..9bb2cc9bcc 100644 --- a/Core/Tools/WW3D/pluglib/wwmath.h +++ b/Core/Tools/WW3D/pluglib/wwmath.h @@ -34,13 +34,7 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ - -#if defined(_MSC_VER) #pragma once -#endif - -#ifndef WWMATH_H -#define WWMATH_H #include "always.h" #include @@ -253,5 +247,3 @@ inline bool WWMath::Is_Valid_Double(double x) } return true; } - -#endif diff --git a/Core/Tools/assetcull/assetcull.cpp b/Core/Tools/assetcull/assetcull.cpp index dc55dcdd36..4535a6f9c3 100644 --- a/Core/Tools/assetcull/assetcull.cpp +++ b/Core/Tools/assetcull/assetcull.cpp @@ -69,7 +69,7 @@ static bool filesEqual(const char *fn1, const char *fn2) if (fread(buf1,cur,1,f1)!=1|| fread(buf2,cur,1,f2)!=1) break; - if (memcmp(buf1,buf2,cur)) + if (memcmp(buf1,buf2,cur) != 0) break; k+=cur; } @@ -105,7 +105,7 @@ static int recursiveCull(FILE *batchFile, { if (fd.attrib&_A_SUBDIR) { - if (strcmp(fd.name,".")&& + if (strcmp(fd.name,".") != 0&& strcmp(fd.name,"..")) subdir.push_back(fd.name); } diff --git a/Core/Tools/buildVersionUpdate/buildVersionUpdate.cpp b/Core/Tools/buildVersionUpdate/buildVersionUpdate.cpp index d4105726d2..18de6bd75b 100644 --- a/Core/Tools/buildVersionUpdate/buildVersionUpdate.cpp +++ b/Core/Tools/buildVersionUpdate/buildVersionUpdate.cpp @@ -141,9 +141,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, { printf ("Build 0. Oops, didn't find a string of the format: '#define VERSION \"x.y.z\"'"); } - } // End if if (strstr - } // End of while - } // End of if filePtr + } + } + } else { // Didn't find the file, write a new one diff --git a/Core/Tools/mangler/crc.cpp b/Core/Tools/mangler/crc.cpp index 1a447ba5e2..c5e03e9115 100644 --- a/Core/Tools/mangler/crc.cpp +++ b/Core/Tools/mangler/crc.cpp @@ -18,7 +18,7 @@ #include -#ifdef _WINDOWS +#ifdef _WIN32 #include // *MUST* be included before ANY Wnet/Wlib headers if _REENTRANT is defined #endif diff --git a/Core/Tools/mangler/crc.h b/Core/Tools/mangler/crc.h index fbd057f424..0ff76e0ce9 100644 --- a/Core/Tools/mangler/crc.h +++ b/Core/Tools/mangler/crc.h @@ -16,11 +16,8 @@ ** along with this program. If not, see . */ -#ifndef __CRC_H__ -#define __CRC_H__ +#pragma once void Build_Packet_CRC(unsigned char *buf, int len); // len includes 4-byte CRC at head bool Passes_CRC_Check(unsigned char *buf, int len); // len includes 4-byte CRC at head void Add_CRC(unsigned long *crc, unsigned long val); - -#endif // __CRC_H__ diff --git a/Core/Tools/mangler/endian.h b/Core/Tools/mangler/endian.h index 9c31d5e428..9cf4efffa3 100644 --- a/Core/Tools/mangler/endian.h +++ b/Core/Tools/mangler/endian.h @@ -16,10 +16,7 @@ ** along with this program. If not, see . */ -#ifndef __ENDIAN_H__ -#define __ENDIAN_H__ - - +#pragma once /* ** Network order is big-endian. @@ -59,7 +56,3 @@ template inline T Endian(T val) return (retval); } - - -#endif //__ENDIAN_H__ - diff --git a/Core/Tools/mangler/mangler.cpp b/Core/Tools/mangler/mangler.cpp index 13efa1998e..5f758520f2 100644 --- a/Core/Tools/mangler/mangler.cpp +++ b/Core/Tools/mangler/mangler.cpp @@ -20,7 +20,7 @@ #include #include -#ifdef _WINDOWS +#ifdef _WIN32 #include // *MUST* be included before ANY Wnet/Wlib headers if _REENTRANT is defined #endif @@ -97,7 +97,7 @@ int main(int argc, char **argv) // ----- Initialize Winsock ----- -#ifdef _WINDOWS +#ifdef _WIN32 WORD verReq = MAKEWORD(2, 2); WSADATA wsadata; diff --git a/Core/Tools/mangler/mangler.h b/Core/Tools/mangler/mangler.h index c9cb28ed87..4368290acd 100644 --- a/Core/Tools/mangler/mangler.h +++ b/Core/Tools/mangler/mangler.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef __MANGLER_H__ -#define __MANGLER_H__ +#pragma once // Packet should consist of a GlobalHeaderType followed by a GlobalPacketType with the fields set as // indicated. @@ -75,5 +74,3 @@ struct ManglerData { #if !defined(__GNUC__) #pragma pack(pop) #endif - -#endif // __MANGLER_H__ diff --git a/Core/Tools/mangler/manglertest.cpp b/Core/Tools/mangler/manglertest.cpp index 49eb731686..033359a3d1 100644 --- a/Core/Tools/mangler/manglertest.cpp +++ b/Core/Tools/mangler/manglertest.cpp @@ -20,7 +20,7 @@ #include #include -#ifdef _WINDOWS +#ifdef _WIN32 #include // *MUST* be included before ANY Wnet/Wlib headers if _REENTRANT is defined #endif @@ -128,7 +128,7 @@ int main(int argc, char **argv) // ----- Initialize Winsock ----- -#ifdef _WINDOWS +#ifdef _WIN32 WORD verReq = MAKEWORD(2, 2); WSADATA wsadata; diff --git a/Core/Tools/mangler/wlib/arraylist.h b/Core/Tools/mangler/wlib/arraylist.h index b7d23d6df1..58c8481842 100644 --- a/Core/Tools/mangler/wlib/arraylist.h +++ b/Core/Tools/mangler/wlib/arraylist.h @@ -44,8 +44,7 @@ that don't belong to them, etc... \****************************************************************************/ -#ifndef ARRAYLIST_HEADER -#define ARRAYLIST_HEADER +#pragma once #include #include @@ -704,6 +703,3 @@ bit8 ArrayList::shrinkVector(void) return(TRUE); } - - -#endif diff --git a/Core/Tools/mangler/wlib/configfile.cpp b/Core/Tools/mangler/wlib/configfile.cpp index bed6c86446..b8d465b750 100644 --- a/Core/Tools/mangler/wlib/configfile.cpp +++ b/Core/Tools/mangler/wlib/configfile.cpp @@ -340,7 +340,7 @@ bit8 ConfigFile::setString(IN Wstring &_key, IN Wstring &value, IN char *section for (i=0; i. */ -#ifndef CRITSEC_HEADER -#define CRITSEC_HEADER +#pragma once #include "wstypes.h" #ifdef _WIN32 @@ -58,5 +57,3 @@ class CritSec mutable int RefCount_; // Reference count #endif }; - -#endif diff --git a/Core/Tools/mangler/wlib/dictionary.h b/Core/Tools/mangler/wlib/dictionary.h index 52839bcf13..2a21b5273b 100644 --- a/Core/Tools/mangler/wlib/dictionary.h +++ b/Core/Tools/mangler/wlib/dictionary.h @@ -35,10 +35,7 @@ is working well, this is much faster than a linked list, but only if your hashing function is good. \****************************************************************************/ - -#ifndef DICTIONARY_HEADER -#define DICTIONARY_HEADER - +#pragma once #include #include @@ -675,7 +672,3 @@ void Dictionary::expand(void) } delete[](oldtable); } - - -#endif - diff --git a/Core/Tools/mangler/wlib/filed.h b/Core/Tools/mangler/wlib/filed.h index eee97e1cf2..2d00ab1afa 100644 --- a/Core/Tools/mangler/wlib/filed.h +++ b/Core/Tools/mangler/wlib/filed.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef FILED_HEADER -#define FILED_HEADER +#pragma once #include "odevice.h" @@ -47,5 +46,3 @@ class FileD : public OutputDevice FILE *out; }; - -#endif diff --git a/Core/Tools/mangler/wlib/linkedlist.h b/Core/Tools/mangler/wlib/linkedlist.h index ead1736ad6..8589c3c45c 100644 --- a/Core/Tools/mangler/wlib/linkedlist.h +++ b/Core/Tools/mangler/wlib/linkedlist.h @@ -33,8 +33,7 @@ Copies of the data are stored instead of a pointer to the original. If you want to store pointers then the template should be of a pointer type. \****************************************************************************/ -#ifndef LINKEDLIST_HEADER -#define LINKEDLIST_HEADER +#pragma once #include #include @@ -491,5 +490,3 @@ template sint32 LinkedList::length(void) { return(Entries); } - -#endif diff --git a/Core/Tools/mangler/wlib/mboxd.h b/Core/Tools/mangler/wlib/mboxd.h index 3c4d0f5dde..a45eff3700 100644 --- a/Core/Tools/mangler/wlib/mboxd.h +++ b/Core/Tools/mangler/wlib/mboxd.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef MBOXD_HEADER -#define MBOXD_HEADER +#pragma once #include "odevice.h" @@ -36,5 +35,3 @@ class MboxD : public OutputDevice } }; - -#endif diff --git a/Core/Tools/mangler/wlib/monod.h b/Core/Tools/mangler/wlib/monod.h index 494674c974..4f94fd065e 100644 --- a/Core/Tools/mangler/wlib/monod.h +++ b/Core/Tools/mangler/wlib/monod.h @@ -16,9 +16,7 @@ ** along with this program. If not, see . */ -#ifndef MONOD_HEADER -#define MONOD_HEADER - +#pragma once #include #include @@ -70,5 +68,3 @@ class MonoD : public OutputDevice HANDLE handle; #endif }; - -#endif diff --git a/Core/Tools/mangler/wlib/odevice.h b/Core/Tools/mangler/wlib/odevice.h index ccd45e01a8..8cb924ea42 100644 --- a/Core/Tools/mangler/wlib/odevice.h +++ b/Core/Tools/mangler/wlib/odevice.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef ODEVICE_HEADER -#define ODEVICE_HEADER +#pragma once // This virtual base class provides an interface for output devices // that can be used for the debugging package. @@ -28,5 +27,3 @@ class OutputDevice virtual ~OutputDevice() {}; virtual int print(const char *s,int len)=0; }; - -#endif diff --git a/Core/Tools/mangler/wlib/sem4.cpp b/Core/Tools/mangler/wlib/sem4.cpp index 1f954cb7d0..e11b95a362 100644 --- a/Core/Tools/mangler/wlib/sem4.cpp +++ b/Core/Tools/mangler/wlib/sem4.cpp @@ -31,7 +31,7 @@ This is useful because the constructor will automatically call sem_init Sem4::Sem4() { -#ifndef _WINDOWS +#ifndef _WIN32 sem_init(&sem,1,1); #else sem = CreateSemaphore(NULL, 1, 1, NULL); @@ -40,7 +40,7 @@ Sem4::Sem4() Sem4::Sem4(uint32 value) { -#ifndef _WINDOWS +#ifndef _WIN32 sem_init(&sem,1,value); #else sem = CreateSemaphore(NULL, value, value, NULL); @@ -49,7 +49,7 @@ Sem4::Sem4(uint32 value) Sem4::~Sem4() { -#ifndef _WINDOWS +#ifndef _WIN32 sem_destroy(&sem); #else if (sem) CloseHandle(sem); @@ -58,7 +58,7 @@ Sem4::~Sem4() sint32 Sem4::Wait(void) const { -#ifndef _WINDOWS +#ifndef _WIN32 return(sem_wait((sem_t *)&sem)); #else if (!sem) @@ -79,7 +79,7 @@ sint32 Sem4::Wait(void) const sint32 Sem4::Post(void) const { -#ifndef _WINDOWS +#ifndef _WIN32 return(sem_post((sem_t *)&sem)); #else if (!sem) @@ -92,7 +92,7 @@ sint32 Sem4::Post(void) const sint32 Sem4::TryWait(void) const { -#ifndef _WINDOWS +#ifndef _WIN32 return(sem_trywait((sem_t *)&sem)); #else if (!sem) @@ -112,7 +112,7 @@ sint32 Sem4::TryWait(void) const sint32 Sem4::GetValue(int *sval) const { -#ifndef _WINDOWS +#ifndef _WIN32 return(sem_getvalue((sem_t *)&sem,sval)); #else if (!sem) @@ -128,7 +128,7 @@ sint32 Sem4::GetValue(int *sval) const sint32 Sem4::Destroy(void) { -#ifndef _WINDOWS +#ifndef _WIN32 return(sem_destroy(&sem)); #else return CloseHandle(sem); diff --git a/Core/Tools/mangler/wlib/sem4.h b/Core/Tools/mangler/wlib/sem4.h index 1ffe33f6a8..303fb1e238 100644 --- a/Core/Tools/mangler/wlib/sem4.h +++ b/Core/Tools/mangler/wlib/sem4.h @@ -16,21 +16,20 @@ ** along with this program. If not, see . */ -#ifndef SEM4_HEADER -#define SEM4_HEADER +#pragma once #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #endif #include "wstypes.h" #ifdef _REENTRANT -#ifndef _WINDOWS +#ifndef _WIN32 #include #else #include -#endif // _WINDOWS +#endif // _WIN32 #endif // _REENTRANT // Windows headers have a tendency to redefine IN @@ -43,7 +42,7 @@ class Sem4 { private: #ifdef _REENTRANT -#ifndef _WINDOWS +#ifndef _WIN32 sem_t sem; #else HANDLE sem; @@ -60,5 +59,3 @@ class Sem4 sint32 GetValue(int *sval) const; sint32 Destroy(void); }; - -#endif diff --git a/Core/Tools/mangler/wlib/stderrd.h b/Core/Tools/mangler/wlib/stderrd.h index abc8b5e0ec..3af596103e 100644 --- a/Core/Tools/mangler/wlib/stderrd.h +++ b/Core/Tools/mangler/wlib/stderrd.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef STDERRD_HEADER -#define STDERRD_HEADER +#pragma once #include "odevice.h" @@ -35,5 +34,3 @@ class StderrD : public OutputDevice return(len); } }; - -#endif diff --git a/Core/Tools/mangler/wlib/stdoutd.h b/Core/Tools/mangler/wlib/stdoutd.h index 5170fc1f5c..a7f51a76da 100644 --- a/Core/Tools/mangler/wlib/stdoutd.h +++ b/Core/Tools/mangler/wlib/stdoutd.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef STDOUTD_HEADER -#define STDOUTD_HEADER +#pragma once #include "odevice.h" @@ -36,5 +35,3 @@ class StdoutD : public OutputDevice return(len); } }; - -#endif diff --git a/Core/Tools/mangler/wlib/streamer.cpp b/Core/Tools/mangler/wlib/streamer.cpp index 24a316123c..061baad77d 100644 --- a/Core/Tools/mangler/wlib/streamer.cpp +++ b/Core/Tools/mangler/wlib/streamer.cpp @@ -43,8 +43,8 @@ Streamer::~Streamer() ///////// calling sync seems to cause crashes here on Win32 //sync(); ///////// - if (Buf) - delete[] Buf; + + delete[] Buf; } int Streamer::setOutputDevice(OutputDevice *device) diff --git a/Core/Tools/mangler/wlib/streamer.h b/Core/Tools/mangler/wlib/streamer.h index ce94139cd0..d0121a89be 100644 --- a/Core/Tools/mangler/wlib/streamer.h +++ b/Core/Tools/mangler/wlib/streamer.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef STREAMER_HEADER -#define STREAMER_HEADER +#pragma once #include #include @@ -63,5 +62,3 @@ class Streamer : public streambuf OutputDevice *Output_Device; char* Buf; }; - -#endif diff --git a/Core/Tools/mangler/wlib/syslogd.cpp b/Core/Tools/mangler/wlib/syslogd.cpp index aca18655b2..4107335c7e 100644 --- a/Core/Tools/mangler/wlib/syslogd.cpp +++ b/Core/Tools/mangler/wlib/syslogd.cpp @@ -20,7 +20,7 @@ SyslogD::SyslogD(char *ident,int logopt,int facility,int _priority) { -#ifndef _WINDOWS +#ifndef _WIN32 openlog(ident,logopt,facility); priority=_priority; #endif @@ -28,7 +28,7 @@ SyslogD::SyslogD(char *ident,int logopt,int facility,int _priority) int SyslogD::print(const char *str, int len) { -#ifndef _WINDOWS +#ifndef _WIN32 char *temp_str=new char[len+1]; memset(temp_str,0,len+1); strncpy(temp_str,str,len); diff --git a/Core/Tools/mangler/wlib/syslogd.h b/Core/Tools/mangler/wlib/syslogd.h index ee427b6418..74b25d313f 100644 --- a/Core/Tools/mangler/wlib/syslogd.h +++ b/Core/Tools/mangler/wlib/syslogd.h @@ -16,12 +16,11 @@ ** along with this program. If not, see . */ -#ifndef SYSLOGD_HEADER -#define SYSLOGD_HEADER +#pragma once #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #endif #include @@ -44,5 +43,3 @@ class SyslogD : public OutputDevice private: int priority; }; - -#endif diff --git a/Core/Tools/mangler/wlib/threadfac.h b/Core/Tools/mangler/wlib/threadfac.h index 3441735005..027de9be53 100644 --- a/Core/Tools/mangler/wlib/threadfac.h +++ b/Core/Tools/mangler/wlib/threadfac.h @@ -20,8 +20,7 @@ // Platform independent thread creation (Win32 & POSIX) // -#ifndef THREADFAC_HEADER -#define THREADFAC_HEADER +#pragma once #ifdef _WIN32 #include @@ -120,5 +119,3 @@ class Runnable static int ThreadCount_; static CritSec CritSec_; // to protect ThreadCount_ }; - -#endif diff --git a/Core/Tools/mangler/wlib/threadsafe.h b/Core/Tools/mangler/wlib/threadsafe.h index 551ffe837b..bc5492885d 100644 --- a/Core/Tools/mangler/wlib/threadsafe.h +++ b/Core/Tools/mangler/wlib/threadsafe.h @@ -31,8 +31,7 @@ #ifdef _REENTRANT -#ifndef THREADSAFE_HEADER -#define THREADSAFE_HEADER +#pragma once #define strtok ("strtok() is not MT-SAFE!") #define ascctime ("asctime() is not MT-SAFE!") @@ -57,6 +56,4 @@ #define pclose ("pclose() is not MT-SAFE!") #define ctermid ("ctermid() is not MT-SAFE!") #define getlogin ("getlogin() is not MT-SAFE!"); - -#endif // THREADSAFE_HEADER #endif // _REENTRANT diff --git a/Core/Tools/mangler/wlib/timezone.cpp b/Core/Tools/mangler/wlib/timezone.cpp index 34f558b072..b43235f475 100644 --- a/Core/Tools/mangler/wlib/timezone.cpp +++ b/Core/Tools/mangler/wlib/timezone.cpp @@ -22,7 +22,7 @@ void GetTimezoneInfo(const char * &timezone_str, int &timezone_offset) { timezone_str = "Unknown Timezone"; timezone_offset = 0; -#ifdef _WINDOWS +#ifdef _WIN32 struct _timeb wintime; _ftime(&wintime); @@ -37,7 +37,7 @@ void GetTimezoneInfo(const char * &timezone_str, int &timezone_offset) { timezone_offset = wintime.timezone * 60; // its in minutes... #endif -#ifndef _WINDOWS +#ifndef _WIN32 struct timeval unixtime; struct timezone unixtzone; gettimeofday(&unixtime,&unixtzone); diff --git a/Core/Tools/mangler/wlib/timezone.h b/Core/Tools/mangler/wlib/timezone.h index b7fe3ec5f1..3849cad000 100644 --- a/Core/Tools/mangler/wlib/timezone.h +++ b/Core/Tools/mangler/wlib/timezone.h @@ -25,8 +25,7 @@ only tells you info about what the daylight savings info is now, not 5 minutes from now, not 2 hours ago. Oh well. \****************************************************************************/ -#ifndef _TIMEZONE_H_ -#define _TIMEZONE_H_ +#pragma once // Just fill in both the timezone description and its offset from GMT void GetTimezoneInfo(const char * &timezone_str, int &timezone_offset); @@ -36,6 +35,3 @@ const char * TimezoneString(void); // Returns the offset from GMT of the current timezone int TimezoneOffset(void); - -#endif // _TIMEZONE_H_ - diff --git a/Core/Tools/mangler/wlib/ustring.h b/Core/Tools/mangler/wlib/ustring.h index 7796dfb3dd..c06e0d0674 100644 --- a/Core/Tools/mangler/wlib/ustring.h +++ b/Core/Tools/mangler/wlib/ustring.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef USTRING_HEADER -#define USTRING_HEADER +#pragma once #include #include @@ -57,5 +56,3 @@ class UstringT : public basic_string > }; typedef UstringT Ustring; - -#endif diff --git a/Core/Tools/mangler/wlib/wdebug.h b/Core/Tools/mangler/wlib/wdebug.h index 493a0ae90b..e16319f4da 100644 --- a/Core/Tools/mangler/wlib/wdebug.h +++ b/Core/Tools/mangler/wlib/wdebug.h @@ -50,8 +50,7 @@ will you be ready to leave grasshopper. \*****************************************************************************/ -#ifndef WDEBUG_HEADER -#define WDEBUG_HEADER +#pragma once #define USE_DEBUG_SEM @@ -60,7 +59,7 @@ will you be ready to leave grasshopper. #include #include -#if !defined(_WINDOWS) +#if !defined(_WIN32) // Windows headers have a tendency to redefine IN #ifdef IN #undef IN @@ -184,7 +183,7 @@ extern CritSec DebugLibSemaphore; #define DBG(X) X // In Windows, send a copy to the debugger window -#ifdef _WINDOWS +#ifdef _WIN32 // Print a variable #define PVAR(v) \ @@ -240,7 +239,7 @@ extern CritSec DebugLibSemaphore; DEBUGUNLOCK; \ } -#else // _WINDOWS +#else // _WIN32 // Print a variable #define PVAR(v) \ @@ -280,7 +279,7 @@ extern CritSec DebugLibSemaphore; "]: " << ##X << endl; X \ DEBUGUNLOCK; \ } -#endif // _WINDOWS +#endif // _WIN32 #endif // DEBUG @@ -310,5 +309,3 @@ class MsgManager static ostream *warnStream(void); static ostream *errorStream(void); }; - -#endif diff --git a/Core/Tools/mangler/wlib/wstring.cpp b/Core/Tools/mangler/wlib/wstring.cpp index 94e9f30de9..a19c9aaa00 100644 --- a/Core/Tools/mangler/wlib/wstring.cpp +++ b/Core/Tools/mangler/wlib/wstring.cpp @@ -265,8 +265,7 @@ void Wstring::removeSpaces(void) void Wstring::clear(void) { - if(str) - delete[](str); + delete[](str); strsize=0; str=NULL; } diff --git a/Core/Tools/mangler/wlib/wstring.h b/Core/Tools/mangler/wlib/wstring.h index 8b58b0e676..dc3cf29dd7 100644 --- a/Core/Tools/mangler/wlib/wstring.h +++ b/Core/Tools/mangler/wlib/wstring.h @@ -26,8 +26,7 @@ Start Date : June 1, 1997 Last Update : June 17, 1997 \****************************************************************************/ -#ifndef WSTRING_HEADER -#define WSTRING_HEADER +#pragma once #include #include @@ -89,5 +88,3 @@ class Wstring char *str; // Pointer to allocated string. int strsize; // allocated data length }; - -#endif diff --git a/Core/Tools/mangler/wlib/wstypes.h b/Core/Tools/mangler/wlib/wstypes.h index baa5d72884..c13ef1fa3c 100644 --- a/Core/Tools/mangler/wlib/wstypes.h +++ b/Core/Tools/mangler/wlib/wstypes.h @@ -28,15 +28,14 @@ Last Update : June 17, 1997 Standard type definitions for the sake of portability and readability. \***************************************************************************/ -#ifndef WSTYPES_HEADER -#define WSTYPES_HEADER +#pragma once #ifdef _REENTRANT // reentrant = threaded // Headers with non threadsafe libs need to come before my hacky // threadsafe.h otherwise they won't compile #include -#ifndef _WINDOWS +#ifndef _WIN32 #define _POSIX_C_SOURCE 199506L #define _POSIX_PTHREAD_SEMANTICS #define __EXTENSIONS__ @@ -44,7 +43,7 @@ Standard type definitions for the sake of portability and readability. #include #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #include #include @@ -110,9 +109,7 @@ typedef double float64; #define MAX_SINT16 0x7FFF #define MAX_SINT8 0x7F -#ifdef _WINDOWS +#ifdef _WIN32 #define strncasecmp _strnicmp #define strcasecmp _stricmp #endif - -#endif diff --git a/Core/Tools/mangler/wlib/wtime.cpp b/Core/Tools/mangler/wlib/wtime.cpp index 9351d3c0cf..3a3e84ea2f 100644 --- a/Core/Tools/mangler/wlib/wtime.cpp +++ b/Core/Tools/mangler/wlib/wtime.cpp @@ -35,7 +35,7 @@ static const char *FULLMONTHS[]={"January","February","March","April","May","Jun "July","August","September","October","November","December"}; // MDC: Windows doesn't provide a localtime_r, so make our own... -#ifdef _WINDOWS +#ifdef _WIN32 #ifdef _REENTRANT #include "critsec.h" static CritSec localtime_critsec; @@ -54,7 +54,7 @@ static struct tm *localtime_r(const time_t *clockval, struct tm *res) { #endif return res; } -#endif // _WINDOWS +#endif // _WIN32 Wtime::Wtime(void) { @@ -82,13 +82,13 @@ Wtime::~Wtime() void Wtime::Update(void) { sign=POSITIVE; - #ifdef _WINDOWS + #ifdef _WIN32 struct _timeb wintime; _ftime(&wintime); sec=wintime.time; usec=(wintime.millitm)*1000; #endif - #ifndef _WINDOWS + #ifndef _WIN32 struct timeval unixtime; struct timezone unixtzone; gettimeofday(&unixtime,&unixtzone); diff --git a/Core/Tools/mangler/wlib/wtime.h b/Core/Tools/mangler/wlib/wtime.h index be8adb38c5..e969217da0 100644 --- a/Core/Tools/mangler/wlib/wtime.h +++ b/Core/Tools/mangler/wlib/wtime.h @@ -20,16 +20,15 @@ wtime Neal Kettler \****************************************************************************/ -#ifndef WTIME_HEADER -#define WTIME_HEADER +#pragma once #include #include #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #include #include @@ -124,5 +123,3 @@ class Wtime uint32 usec; // microseconds (millionths of a second) bit8 sign; // for time differences 0 = pos 1 = neg }; - -#endif diff --git a/Core/Tools/mangler/wlib/xtime.cpp b/Core/Tools/mangler/wlib/xtime.cpp index 00bc596899..d36a7ec187 100644 --- a/Core/Tools/mangler/wlib/xtime.cpp +++ b/Core/Tools/mangler/wlib/xtime.cpp @@ -29,7 +29,7 @@ long long after you'll be dead. #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #endif #include "xtime.h" @@ -88,7 +88,7 @@ static sint32 Get_Day(int month, int day, int year) static bit8 Get_Date_From_Day(sint32 days, OUT sint32 &year, OUT sint32 &yday) { //register long int rem; - register long int y; + long int y; //register const unsigned short int *ip; if (days <= 365) @@ -286,13 +286,13 @@ void Xtime::update(void) day_=719528; // day_s from year 0 to Jan1, 1970 msec_=0; - #ifdef _WINDOWS + #ifdef _WIN32 struct _timeb wintime; _ftime(&wintime); addSeconds(wintime.time); msec_+=wintime.millitm; #endif - #ifndef _WINDOWS + #ifndef _WIN32 struct timeval unixtime; struct timezone unixtzone; gettimeofday(&unixtime,&unixtzone); diff --git a/Core/Tools/mangler/wlib/xtime.h b/Core/Tools/mangler/wlib/xtime.h index 0492095a00..c79e4c9f43 100644 --- a/Core/Tools/mangler/wlib/xtime.h +++ b/Core/Tools/mangler/wlib/xtime.h @@ -29,16 +29,14 @@ Hopefully by then somebody will replace the lame time() function :-) \****************************************************************************/ -#ifndef XTIME_HEADER -#define XTIME_HEADER - +#pragma once #include #include #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #include #include @@ -142,5 +140,3 @@ class Xtime sint32 day_; // days since Jan 1, 0 sint32 msec_; // milliseconds (thousandths of a sec) }; - -#endif diff --git a/Core/Tools/mangler/wnet/field.cpp b/Core/Tools/mangler/wnet/field.cpp index 4cd9043477..699b52507c 100644 --- a/Core/Tools/mangler/wnet/field.cpp +++ b/Core/Tools/mangler/wnet/field.cpp @@ -20,7 +20,7 @@ * * * Project Name : Westwood Auto Registration App * * * - * File Name : FIELD.CPP * + * File Name : FIELD.cpp * * * * Programmer : Philip W. Gorrow * * * @@ -34,7 +34,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #else #define Win32_Winsock diff --git a/Core/Tools/mangler/wnet/field.h b/Core/Tools/mangler/wnet/field.h index b321989913..de573ddbee 100644 --- a/Core/Tools/mangler/wnet/field.h +++ b/Core/Tools/mangler/wnet/field.h @@ -20,7 +20,7 @@ * * * Project Name : Westwood Auto Registration App * * * - * File Name : FIELD.H * + * File Name : FIELD.h * * * * Programmer : Philip W. Gorrow * * * diff --git a/Core/Tools/mangler/wnet/packet.cpp b/Core/Tools/mangler/wnet/packet.cpp index cbc52c7845..8cda4f64b0 100644 --- a/Core/Tools/mangler/wnet/packet.cpp +++ b/Core/Tools/mangler/wnet/packet.cpp @@ -20,7 +20,7 @@ * * * Project Name : Westwood Auto Registration App * * * - * File Name : PACKET.CPP * + * File Name : PACKET.cpp * * * * Programmer : Philip W. Gorrow * * * @@ -39,7 +39,7 @@ #include #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #else #define Win32_Winsock diff --git a/Core/Tools/mangler/wnet/packet.h b/Core/Tools/mangler/wnet/packet.h index ecf68ad2f4..d61870cb9d 100644 --- a/Core/Tools/mangler/wnet/packet.h +++ b/Core/Tools/mangler/wnet/packet.h @@ -20,7 +20,7 @@ * * * Project Name : Westwood Auto Registration App * * * - * File Name : PACKET.H * + * File Name : PACKET.h * * * * Programmer : Philip W. Gorrow * * * diff --git a/Core/Tools/mangler/wnet/tcp.cpp b/Core/Tools/mangler/wnet/tcp.cpp index 9dd0b93bd9..66ea079c7a 100644 --- a/Core/Tools/mangler/wnet/tcp.cpp +++ b/Core/Tools/mangler/wnet/tcp.cpp @@ -99,7 +99,7 @@ while (1) #include "tcp.h" #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #define closesocket close #endif @@ -170,7 +170,7 @@ sint32 TCP::SetBlocking(bit8 block,sint32 whichFD) if (whichFD==0) whichFD=fd; - #ifdef _WINDOWS + #ifdef _WIN32 unsigned long flag=1; if (block) flag=0; @@ -219,7 +219,7 @@ sint32 TCP::Write(const uint8 *msg,uint32 len,sint32 whichFD) } SetBlocking(TRUE,whichFD); retval=send(whichFD,(const char *)msg,len,0); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -241,7 +241,7 @@ sint32 TCP::WriteNB(uint8 *msg,uint32 len,sint32 whichFD) whichFD=fd; } retval=send(whichFD,(const char *)msg,len,0); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -942,7 +942,7 @@ bit8 TCP::Bind(uint32 IP,uint16 Port,bit8 reuseAddr) } retval=bind(fd,(struct sockaddr *)&addr,sizeof(addr)); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -1013,7 +1013,7 @@ bit8 TCP::Connect(uint32 IP,uint16 Port) result = connect(fd,(struct sockaddr *)&serverAddr, sizeof(serverAddr)); status=GetStatus(); - #ifdef _WINDOWS + #ifdef _WIN32 if (result==SOCKET_ERROR) result=-1; #endif @@ -1107,7 +1107,7 @@ bit8 TCP::ConnectAsync(uint32 IP,uint16 Port) connectErrno=errno; status=GetStatus(); - #ifdef _WINDOWS + #ifdef _WIN32 if (result==SOCKET_ERROR) { DBGMSG("Socket error 1 " << status); @@ -1124,7 +1124,7 @@ bit8 TCP::ConnectAsync(uint32 IP,uint16 Port) ClearStatus(); result = connect(fd,(struct sockaddr *)&serverAddr, sizeof(serverAddr)); status=GetStatus(); - #ifdef _WINDOWS + #ifdef _WIN32 if (result==SOCKET_ERROR) { DBGMSG("Socket error 2 " << status); @@ -1159,14 +1159,14 @@ bit8 TCP::ConnectAsync(uint32 IP,uint16 Port) void TCP::ClearStatus(void) { - #ifndef _WINDOWS + #ifndef _WIN32 errno=0; #endif } int TCP::GetStatus(void) { - #ifdef _WINDOWS + #ifdef _WIN32 int status=WSAGetLastError(); if (status==0) return(OK); else if (status==WSAEINTR) return(INTR); diff --git a/Core/Tools/mangler/wnet/tcp.h b/Core/Tools/mangler/wnet/tcp.h index 9bfd465d71..3e76c99ead 100644 --- a/Core/Tools/mangler/wnet/tcp.h +++ b/Core/Tools/mangler/wnet/tcp.h @@ -21,8 +21,7 @@ TCP Neal Kettler neal@westwood.com \****************************************************************************/ -#ifndef TCP_HEADER -#define TCP_HEADER +#pragma once #include #include @@ -31,7 +30,7 @@ TCP Neal Kettler neal@westwood.com #include #include -#ifdef _WINDOWS +#ifdef _WIN32 #include #include @@ -195,5 +194,3 @@ class TCP bit8 SetOutputDelay(sint32 delay) { outputDelay=delay; return(TRUE); }; }; - -#endif diff --git a/Core/Tools/mangler/wnet/udp.cpp b/Core/Tools/mangler/wnet/udp.cpp index d15cc98823..bba9479b65 100644 --- a/Core/Tools/mangler/wnet/udp.cpp +++ b/Core/Tools/mangler/wnet/udp.cpp @@ -60,7 +60,7 @@ sint32 UDP::Bind(uint32 IP,uint16 Port) addr.sin_port=Port; addr.sin_addr.s_addr=IP; fd=socket(AF_INET,SOCK_DGRAM,DEFAULT_PROTOCOL); - #ifdef _WINDOWS + #ifdef _WIN32 if (fd==SOCKET_ERROR) fd=-1; #endif @@ -69,7 +69,7 @@ sint32 UDP::Bind(uint32 IP,uint16 Port) retval=bind(fd,(struct sockaddr *)&addr,sizeof(addr)); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -104,7 +104,7 @@ bit8 UDP::getLocalAddr(uint32 &ip, uint16 &port) // private function sint32 UDP::SetBlocking(bit8 block) { - #ifdef _WINDOWS + #ifdef _WIN32 unsigned long flag=1; if (block) flag=0; @@ -145,7 +145,7 @@ sint32 UDP::Write(uint8 *msg,uint32 len,uint32 IP,uint16 port) ClearStatus(); retval=sendto(fd,(char *)msg,len,0,(struct sockaddr *)&to,sizeof(to)); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -161,7 +161,7 @@ sint32 UDP::Read(uint8 *msg,uint32 len,sockaddr_in *from) if (from!=NULL) { retval=recvfrom(fd,(char *)msg,len,0,(struct sockaddr *)from,&alen); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -169,7 +169,7 @@ sint32 UDP::Read(uint8 *msg,uint32 len,sockaddr_in *from) else { retval=recvfrom(fd,(char *)msg,len,0,NULL,NULL); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -180,14 +180,14 @@ sint32 UDP::Read(uint8 *msg,uint32 len,sockaddr_in *from) void UDP::ClearStatus(void) { - #ifndef _WINDOWS + #ifndef _WIN32 errno=0; #endif } UDP::sockStat UDP::GetStatus(void) { - #ifdef _WINDOWS + #ifdef _WIN32 int status=WSAGetLastError(); if (status==0) return(OK); else if (status==WSAEINTR) return(INTR); @@ -310,7 +310,7 @@ int UDP::Wait(sint32 sec,sint32 usec,fd_set &givenSet,fd_set &returnSet) bit8 UDP::SetInputBuffer(uint32 bytes) { - #ifndef _WINDOWS + #ifndef _WIN32 int retval,arg=bytes; retval=setsockopt(fd,SOL_SOCKET,SO_RCVBUF, @@ -328,7 +328,7 @@ bit8 UDP::SetInputBuffer(uint32 bytes) bit8 UDP::SetOutputBuffer(uint32 bytes) { - #ifndef _WINDOWS + #ifndef _WIN32 int retval,arg=bytes; retval=setsockopt(fd,SOL_SOCKET,SO_SNDBUF, @@ -346,7 +346,7 @@ bit8 UDP::SetOutputBuffer(uint32 bytes) int UDP::GetInputBuffer(void) { - #ifndef _WINDOWS + #ifndef _WIN32 int retval,arg=0,len=sizeof(int); retval=getsockopt(fd,SOL_SOCKET,SO_RCVBUF, @@ -360,7 +360,7 @@ int UDP::GetInputBuffer(void) int UDP::GetOutputBuffer(void) { - #ifndef _WINDOWS + #ifndef _WIN32 int retval,arg=0,len=sizeof(int); retval=getsockopt(fd,SOL_SOCKET,SO_SNDBUF, diff --git a/Core/Tools/mangler/wnet/udp.h b/Core/Tools/mangler/wnet/udp.h index 118eb100ad..7f40086058 100644 --- a/Core/Tools/mangler/wnet/udp.h +++ b/Core/Tools/mangler/wnet/udp.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef UDP_HEADER -#define UDP_HEADER +#pragma once #include #include @@ -25,7 +24,7 @@ #include #include -#ifdef _WINDOWS +#ifdef _WIN32 #include #include #define close _close @@ -110,5 +109,3 @@ class UDP int GetInputBuffer(void); int GetOutputBuffer(void); }; - -#endif diff --git a/Core/Tools/matchbot/debug.cpp b/Core/Tools/matchbot/debug.cpp index fa10a02bd0..2da4663134 100644 --- a/Core/Tools/matchbot/debug.cpp +++ b/Core/Tools/matchbot/debug.cpp @@ -30,7 +30,7 @@ extern "C" { #endif -#ifdef _WINDOWS +#ifdef _WIN32 #include void DebugCrash( const char *fmt, ... ) {} diff --git a/Core/Tools/matchbot/debug.h b/Core/Tools/matchbot/debug.h index a9ac87b270..1df2a06947 100644 --- a/Core/Tools/matchbot/debug.h +++ b/Core/Tools/matchbot/debug.h @@ -20,8 +20,7 @@ // Minimal debug info // Author: Matthew D. Campbell, Sept 2002 -#ifndef __DEBUG_H__ -#define __DEBUG_H__ +#pragma once #ifdef DEBUG @@ -41,6 +40,3 @@ void DebugLog( const char *fmt, ... ); #define DEBUG_LOG(x) {} #endif // DEBUG - -#endif // __DEBUG_H__ - diff --git a/Core/Tools/matchbot/encrypt.h b/Core/Tools/matchbot/encrypt.h index af2091e534..f4c204a647 100644 --- a/Core/Tools/matchbot/encrypt.h +++ b/Core/Tools/matchbot/encrypt.h @@ -16,13 +16,8 @@ ** along with this program. If not, see . */ -#ifndef ENCRYPT_HEADER -#define ENCRYPT_HEADER +#pragma once #define MAX_ENCRYPTED_STRING 8 //char *do_encrypt(char *, char *); char *do_encrypt(char *); - -#endif - - diff --git a/Core/Tools/matchbot/generals.cpp b/Core/Tools/matchbot/generals.cpp index 4b9af37dd3..8c6837a879 100644 --- a/Core/Tools/matchbot/generals.cpp +++ b/Core/Tools/matchbot/generals.cpp @@ -737,7 +737,7 @@ void GeneralsMatcher::checkMatchesInUserMap(UserMap& userMap, int ladderID, int } } } - } // for i2 + } if (bestUser && numPlayers == 2) { @@ -752,7 +752,7 @@ void GeneralsMatcher::checkMatchesInUserMap(UserMap& userMap, int ladderID, int u1, bestUser, NULL, NULL, NULL, NULL, NULL, NULL, 2, ladderID); break; } - } // for i1 + } dumpUsers(); } diff --git a/Core/Tools/matchbot/generals.h b/Core/Tools/matchbot/generals.h index 0cdd581ec9..a00619d704 100644 --- a/Core/Tools/matchbot/generals.h +++ b/Core/Tools/matchbot/generals.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef __GENERALS_H__ -#define __GENERALS_H__ +#pragma once #ifdef _WIN32 #include @@ -189,6 +188,3 @@ class GeneralsClientMatcher : public MatcherClass private: } ; - -#endif /* __GENERALS_H__ */ - diff --git a/Core/Tools/matchbot/global.h b/Core/Tools/matchbot/global.h index adb3cd0da0..577df4b2c2 100644 --- a/Core/Tools/matchbot/global.h +++ b/Core/Tools/matchbot/global.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef __GLOBAL_H__ -#define __GLOBAL_H__ +#pragma once #ifdef _WIN32 #include @@ -52,6 +51,3 @@ extern GlobalClass Global; // Log rotation functions void rotateOutput(void); void rotateParanoid(void); - -#endif - diff --git a/Core/Tools/matchbot/main.cpp b/Core/Tools/matchbot/main.cpp index fcbaa3f470..8b0a78fb57 100644 --- a/Core/Tools/matchbot/main.cpp +++ b/Core/Tools/matchbot/main.cpp @@ -183,7 +183,7 @@ int main(int argc, char ** argv) Setup_Signals(); -#ifdef _WINDOWS +#ifdef _WIN32 // ----- Initialize Winsock ----- WORD verReq = MAKEWORD(2, 2); WSADATA wsadata; @@ -240,10 +240,11 @@ int main(int argc, char ** argv) exit( -1); } - if (s_generalsMatcher) - delete s_generalsMatcher; - if (s_generalsClientMatcher) - delete s_generalsClientMatcher; + delete s_generalsMatcher; + s_generalsMatcher = NULL; + + delete s_generalsClientMatcher; + s_generalsClientMatcher = NULL; return 0; } @@ -319,7 +320,7 @@ void rotateOutput(void) sprintf(filenamebuf, "%s/%02d%02d%04d_%02d%02d%02d_log", logpath.get(), xtime.getMonth(), xtime.getMDay(), xtime.getYear(), xtime.getHour(), xtime.getMinute(), xtime.getSecond()); -#ifdef _WINDOWS +#ifdef _WIN32 mkdir(logpath.get()); #else mkdir(logpath.get(), 00666); @@ -395,7 +396,7 @@ void rotateParanoid(void) sprintf(filenamebuf, "%s/%02d%02d%04d_%02d%02d%02d_log", logpath.get(), xtime.getMonth(), xtime.getMDay(), xtime.getYear(), xtime.getHour(), xtime.getMinute(), xtime.getSecond()); -#ifdef _WINDOWS +#ifdef _WIN32 mkdir(logpath.get()); #else mkdir(logpath.get(), 00666); diff --git a/Core/Tools/matchbot/matcher.cpp b/Core/Tools/matchbot/matcher.cpp index a6426d6282..53f4c95a56 100644 --- a/Core/Tools/matchbot/matcher.cpp +++ b/Core/Tools/matchbot/matcher.cpp @@ -22,7 +22,7 @@ #include "timezone.h" #include "debug.h" -#ifdef _WINDOWS +#ifdef _WIN32 #define usleep(x) Sleep((x)/100000) #endif diff --git a/Core/Tools/matchbot/matcher.h b/Core/Tools/matchbot/matcher.h index c143966387..2d35c8e32f 100644 --- a/Core/Tools/matchbot/matcher.h +++ b/Core/Tools/matchbot/matcher.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef __MATCHER_H__ -#define __MATCHER_H__ +#pragma once #ifdef _WIN32 #include @@ -88,6 +87,3 @@ class MatcherClass time_t m_lastRotation; }; - -#endif /* __MATCHER_H__ */ - diff --git a/Core/Tools/matchbot/mydebug.cpp b/Core/Tools/matchbot/mydebug.cpp index 7a4da3ab8f..3ad1e156e4 100644 --- a/Core/Tools/matchbot/mydebug.cpp +++ b/Core/Tools/matchbot/mydebug.cpp @@ -80,12 +80,7 @@ int MyMsgManager::ReplaceAllStreams(FileD * output_device, const char *device_fi MYDEBUGLOCK; delete(paranoid_ostream); - - if (output_device != NULL) - { - delete(output_device); - output_device = NULL; - } + delete(output_device); rename(device_filename, copy_filename); diff --git a/Core/Tools/matchbot/mydebug.h b/Core/Tools/matchbot/mydebug.h index 77af17fea2..91227b3cfa 100644 --- a/Core/Tools/matchbot/mydebug.h +++ b/Core/Tools/matchbot/mydebug.h @@ -50,8 +50,7 @@ will you be ready to leave grasshopper. \*****************************************************************************/ -#ifndef MYDEBUG_HEADER -#define MYDEBUG_HEADER +#pragma once #define USE_SEM @@ -130,5 +129,3 @@ class MyMsgManager static ostream *paranoidStream(void); }; - -#endif diff --git a/Core/Tools/matchbot/rand.h b/Core/Tools/matchbot/rand.h index 59eadee1e8..73ae3ec9be 100644 --- a/Core/Tools/matchbot/rand.h +++ b/Core/Tools/matchbot/rand.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef __RAND_H__ -#define __RAND_H__ +#pragma once #include @@ -40,6 +39,3 @@ class RandClass unsigned int seed[6]; }; - -#endif /* __RAND_H__ */ - diff --git a/Core/Tools/matchbot/wlib/arraylist.h b/Core/Tools/matchbot/wlib/arraylist.h index b7d23d6df1..58c8481842 100644 --- a/Core/Tools/matchbot/wlib/arraylist.h +++ b/Core/Tools/matchbot/wlib/arraylist.h @@ -44,8 +44,7 @@ that don't belong to them, etc... \****************************************************************************/ -#ifndef ARRAYLIST_HEADER -#define ARRAYLIST_HEADER +#pragma once #include #include @@ -704,6 +703,3 @@ bit8 ArrayList::shrinkVector(void) return(TRUE); } - - -#endif diff --git a/Core/Tools/matchbot/wlib/configfile.cpp b/Core/Tools/matchbot/wlib/configfile.cpp index bed6c86446..b8d465b750 100644 --- a/Core/Tools/matchbot/wlib/configfile.cpp +++ b/Core/Tools/matchbot/wlib/configfile.cpp @@ -340,7 +340,7 @@ bit8 ConfigFile::setString(IN Wstring &_key, IN Wstring &value, IN char *section for (i=0; i. */ -#ifndef CRITSEC_HEADER -#define CRITSEC_HEADER +#pragma once #include "wstypes.h" #ifdef _WIN32 @@ -58,5 +57,3 @@ class CritSec mutable int RefCount_; // Reference count #endif }; - -#endif diff --git a/Core/Tools/matchbot/wlib/dictionary.h b/Core/Tools/matchbot/wlib/dictionary.h index 52839bcf13..2a21b5273b 100644 --- a/Core/Tools/matchbot/wlib/dictionary.h +++ b/Core/Tools/matchbot/wlib/dictionary.h @@ -35,10 +35,7 @@ is working well, this is much faster than a linked list, but only if your hashing function is good. \****************************************************************************/ - -#ifndef DICTIONARY_HEADER -#define DICTIONARY_HEADER - +#pragma once #include #include @@ -675,7 +672,3 @@ void Dictionary::expand(void) } delete[](oldtable); } - - -#endif - diff --git a/Core/Tools/matchbot/wlib/filed.h b/Core/Tools/matchbot/wlib/filed.h index eee97e1cf2..2d00ab1afa 100644 --- a/Core/Tools/matchbot/wlib/filed.h +++ b/Core/Tools/matchbot/wlib/filed.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef FILED_HEADER -#define FILED_HEADER +#pragma once #include "odevice.h" @@ -47,5 +46,3 @@ class FileD : public OutputDevice FILE *out; }; - -#endif diff --git a/Core/Tools/matchbot/wlib/linkedlist.h b/Core/Tools/matchbot/wlib/linkedlist.h index ead1736ad6..8589c3c45c 100644 --- a/Core/Tools/matchbot/wlib/linkedlist.h +++ b/Core/Tools/matchbot/wlib/linkedlist.h @@ -33,8 +33,7 @@ Copies of the data are stored instead of a pointer to the original. If you want to store pointers then the template should be of a pointer type. \****************************************************************************/ -#ifndef LINKEDLIST_HEADER -#define LINKEDLIST_HEADER +#pragma once #include #include @@ -491,5 +490,3 @@ template sint32 LinkedList::length(void) { return(Entries); } - -#endif diff --git a/Core/Tools/matchbot/wlib/mboxd.h b/Core/Tools/matchbot/wlib/mboxd.h index 3c4d0f5dde..a45eff3700 100644 --- a/Core/Tools/matchbot/wlib/mboxd.h +++ b/Core/Tools/matchbot/wlib/mboxd.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef MBOXD_HEADER -#define MBOXD_HEADER +#pragma once #include "odevice.h" @@ -36,5 +35,3 @@ class MboxD : public OutputDevice } }; - -#endif diff --git a/Core/Tools/matchbot/wlib/monod.h b/Core/Tools/matchbot/wlib/monod.h index 494674c974..4f94fd065e 100644 --- a/Core/Tools/matchbot/wlib/monod.h +++ b/Core/Tools/matchbot/wlib/monod.h @@ -16,9 +16,7 @@ ** along with this program. If not, see . */ -#ifndef MONOD_HEADER -#define MONOD_HEADER - +#pragma once #include #include @@ -70,5 +68,3 @@ class MonoD : public OutputDevice HANDLE handle; #endif }; - -#endif diff --git a/Core/Tools/matchbot/wlib/odevice.h b/Core/Tools/matchbot/wlib/odevice.h index ccd45e01a8..8cb924ea42 100644 --- a/Core/Tools/matchbot/wlib/odevice.h +++ b/Core/Tools/matchbot/wlib/odevice.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef ODEVICE_HEADER -#define ODEVICE_HEADER +#pragma once // This virtual base class provides an interface for output devices // that can be used for the debugging package. @@ -28,5 +27,3 @@ class OutputDevice virtual ~OutputDevice() {}; virtual int print(const char *s,int len)=0; }; - -#endif diff --git a/Core/Tools/matchbot/wlib/sem4.cpp b/Core/Tools/matchbot/wlib/sem4.cpp index 1f954cb7d0..e11b95a362 100644 --- a/Core/Tools/matchbot/wlib/sem4.cpp +++ b/Core/Tools/matchbot/wlib/sem4.cpp @@ -31,7 +31,7 @@ This is useful because the constructor will automatically call sem_init Sem4::Sem4() { -#ifndef _WINDOWS +#ifndef _WIN32 sem_init(&sem,1,1); #else sem = CreateSemaphore(NULL, 1, 1, NULL); @@ -40,7 +40,7 @@ Sem4::Sem4() Sem4::Sem4(uint32 value) { -#ifndef _WINDOWS +#ifndef _WIN32 sem_init(&sem,1,value); #else sem = CreateSemaphore(NULL, value, value, NULL); @@ -49,7 +49,7 @@ Sem4::Sem4(uint32 value) Sem4::~Sem4() { -#ifndef _WINDOWS +#ifndef _WIN32 sem_destroy(&sem); #else if (sem) CloseHandle(sem); @@ -58,7 +58,7 @@ Sem4::~Sem4() sint32 Sem4::Wait(void) const { -#ifndef _WINDOWS +#ifndef _WIN32 return(sem_wait((sem_t *)&sem)); #else if (!sem) @@ -79,7 +79,7 @@ sint32 Sem4::Wait(void) const sint32 Sem4::Post(void) const { -#ifndef _WINDOWS +#ifndef _WIN32 return(sem_post((sem_t *)&sem)); #else if (!sem) @@ -92,7 +92,7 @@ sint32 Sem4::Post(void) const sint32 Sem4::TryWait(void) const { -#ifndef _WINDOWS +#ifndef _WIN32 return(sem_trywait((sem_t *)&sem)); #else if (!sem) @@ -112,7 +112,7 @@ sint32 Sem4::TryWait(void) const sint32 Sem4::GetValue(int *sval) const { -#ifndef _WINDOWS +#ifndef _WIN32 return(sem_getvalue((sem_t *)&sem,sval)); #else if (!sem) @@ -128,7 +128,7 @@ sint32 Sem4::GetValue(int *sval) const sint32 Sem4::Destroy(void) { -#ifndef _WINDOWS +#ifndef _WIN32 return(sem_destroy(&sem)); #else return CloseHandle(sem); diff --git a/Core/Tools/matchbot/wlib/sem4.h b/Core/Tools/matchbot/wlib/sem4.h index 1ffe33f6a8..303fb1e238 100644 --- a/Core/Tools/matchbot/wlib/sem4.h +++ b/Core/Tools/matchbot/wlib/sem4.h @@ -16,21 +16,20 @@ ** along with this program. If not, see . */ -#ifndef SEM4_HEADER -#define SEM4_HEADER +#pragma once #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #endif #include "wstypes.h" #ifdef _REENTRANT -#ifndef _WINDOWS +#ifndef _WIN32 #include #else #include -#endif // _WINDOWS +#endif // _WIN32 #endif // _REENTRANT // Windows headers have a tendency to redefine IN @@ -43,7 +42,7 @@ class Sem4 { private: #ifdef _REENTRANT -#ifndef _WINDOWS +#ifndef _WIN32 sem_t sem; #else HANDLE sem; @@ -60,5 +59,3 @@ class Sem4 sint32 GetValue(int *sval) const; sint32 Destroy(void); }; - -#endif diff --git a/Core/Tools/matchbot/wlib/stderrd.h b/Core/Tools/matchbot/wlib/stderrd.h index abc8b5e0ec..3af596103e 100644 --- a/Core/Tools/matchbot/wlib/stderrd.h +++ b/Core/Tools/matchbot/wlib/stderrd.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef STDERRD_HEADER -#define STDERRD_HEADER +#pragma once #include "odevice.h" @@ -35,5 +34,3 @@ class StderrD : public OutputDevice return(len); } }; - -#endif diff --git a/Core/Tools/matchbot/wlib/stdoutd.h b/Core/Tools/matchbot/wlib/stdoutd.h index 5170fc1f5c..a7f51a76da 100644 --- a/Core/Tools/matchbot/wlib/stdoutd.h +++ b/Core/Tools/matchbot/wlib/stdoutd.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef STDOUTD_HEADER -#define STDOUTD_HEADER +#pragma once #include "odevice.h" @@ -36,5 +35,3 @@ class StdoutD : public OutputDevice return(len); } }; - -#endif diff --git a/Core/Tools/matchbot/wlib/streamer.cpp b/Core/Tools/matchbot/wlib/streamer.cpp index 24a316123c..061baad77d 100644 --- a/Core/Tools/matchbot/wlib/streamer.cpp +++ b/Core/Tools/matchbot/wlib/streamer.cpp @@ -43,8 +43,8 @@ Streamer::~Streamer() ///////// calling sync seems to cause crashes here on Win32 //sync(); ///////// - if (Buf) - delete[] Buf; + + delete[] Buf; } int Streamer::setOutputDevice(OutputDevice *device) diff --git a/Core/Tools/matchbot/wlib/streamer.h b/Core/Tools/matchbot/wlib/streamer.h index ce94139cd0..d0121a89be 100644 --- a/Core/Tools/matchbot/wlib/streamer.h +++ b/Core/Tools/matchbot/wlib/streamer.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef STREAMER_HEADER -#define STREAMER_HEADER +#pragma once #include #include @@ -63,5 +62,3 @@ class Streamer : public streambuf OutputDevice *Output_Device; char* Buf; }; - -#endif diff --git a/Core/Tools/matchbot/wlib/syslogd.cpp b/Core/Tools/matchbot/wlib/syslogd.cpp index aca18655b2..4107335c7e 100644 --- a/Core/Tools/matchbot/wlib/syslogd.cpp +++ b/Core/Tools/matchbot/wlib/syslogd.cpp @@ -20,7 +20,7 @@ SyslogD::SyslogD(char *ident,int logopt,int facility,int _priority) { -#ifndef _WINDOWS +#ifndef _WIN32 openlog(ident,logopt,facility); priority=_priority; #endif @@ -28,7 +28,7 @@ SyslogD::SyslogD(char *ident,int logopt,int facility,int _priority) int SyslogD::print(const char *str, int len) { -#ifndef _WINDOWS +#ifndef _WIN32 char *temp_str=new char[len+1]; memset(temp_str,0,len+1); strncpy(temp_str,str,len); diff --git a/Core/Tools/matchbot/wlib/syslogd.h b/Core/Tools/matchbot/wlib/syslogd.h index ee427b6418..74b25d313f 100644 --- a/Core/Tools/matchbot/wlib/syslogd.h +++ b/Core/Tools/matchbot/wlib/syslogd.h @@ -16,12 +16,11 @@ ** along with this program. If not, see . */ -#ifndef SYSLOGD_HEADER -#define SYSLOGD_HEADER +#pragma once #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #endif #include @@ -44,5 +43,3 @@ class SyslogD : public OutputDevice private: int priority; }; - -#endif diff --git a/Core/Tools/matchbot/wlib/threadfac.h b/Core/Tools/matchbot/wlib/threadfac.h index 3441735005..027de9be53 100644 --- a/Core/Tools/matchbot/wlib/threadfac.h +++ b/Core/Tools/matchbot/wlib/threadfac.h @@ -20,8 +20,7 @@ // Platform independent thread creation (Win32 & POSIX) // -#ifndef THREADFAC_HEADER -#define THREADFAC_HEADER +#pragma once #ifdef _WIN32 #include @@ -120,5 +119,3 @@ class Runnable static int ThreadCount_; static CritSec CritSec_; // to protect ThreadCount_ }; - -#endif diff --git a/Core/Tools/matchbot/wlib/threadsafe.h b/Core/Tools/matchbot/wlib/threadsafe.h index 551ffe837b..bc5492885d 100644 --- a/Core/Tools/matchbot/wlib/threadsafe.h +++ b/Core/Tools/matchbot/wlib/threadsafe.h @@ -31,8 +31,7 @@ #ifdef _REENTRANT -#ifndef THREADSAFE_HEADER -#define THREADSAFE_HEADER +#pragma once #define strtok ("strtok() is not MT-SAFE!") #define ascctime ("asctime() is not MT-SAFE!") @@ -57,6 +56,4 @@ #define pclose ("pclose() is not MT-SAFE!") #define ctermid ("ctermid() is not MT-SAFE!") #define getlogin ("getlogin() is not MT-SAFE!"); - -#endif // THREADSAFE_HEADER #endif // _REENTRANT diff --git a/Core/Tools/matchbot/wlib/timezone.cpp b/Core/Tools/matchbot/wlib/timezone.cpp index 34f558b072..b43235f475 100644 --- a/Core/Tools/matchbot/wlib/timezone.cpp +++ b/Core/Tools/matchbot/wlib/timezone.cpp @@ -22,7 +22,7 @@ void GetTimezoneInfo(const char * &timezone_str, int &timezone_offset) { timezone_str = "Unknown Timezone"; timezone_offset = 0; -#ifdef _WINDOWS +#ifdef _WIN32 struct _timeb wintime; _ftime(&wintime); @@ -37,7 +37,7 @@ void GetTimezoneInfo(const char * &timezone_str, int &timezone_offset) { timezone_offset = wintime.timezone * 60; // its in minutes... #endif -#ifndef _WINDOWS +#ifndef _WIN32 struct timeval unixtime; struct timezone unixtzone; gettimeofday(&unixtime,&unixtzone); diff --git a/Core/Tools/matchbot/wlib/timezone.h b/Core/Tools/matchbot/wlib/timezone.h index b7fe3ec5f1..3849cad000 100644 --- a/Core/Tools/matchbot/wlib/timezone.h +++ b/Core/Tools/matchbot/wlib/timezone.h @@ -25,8 +25,7 @@ only tells you info about what the daylight savings info is now, not 5 minutes from now, not 2 hours ago. Oh well. \****************************************************************************/ -#ifndef _TIMEZONE_H_ -#define _TIMEZONE_H_ +#pragma once // Just fill in both the timezone description and its offset from GMT void GetTimezoneInfo(const char * &timezone_str, int &timezone_offset); @@ -36,6 +35,3 @@ const char * TimezoneString(void); // Returns the offset from GMT of the current timezone int TimezoneOffset(void); - -#endif // _TIMEZONE_H_ - diff --git a/Core/Tools/matchbot/wlib/ustring.h b/Core/Tools/matchbot/wlib/ustring.h index 7796dfb3dd..c06e0d0674 100644 --- a/Core/Tools/matchbot/wlib/ustring.h +++ b/Core/Tools/matchbot/wlib/ustring.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef USTRING_HEADER -#define USTRING_HEADER +#pragma once #include #include @@ -57,5 +56,3 @@ class UstringT : public basic_string > }; typedef UstringT Ustring; - -#endif diff --git a/Core/Tools/matchbot/wlib/wdebug.cpp b/Core/Tools/matchbot/wlib/wdebug.cpp index a7490a1bbb..8dd5005ecb 100644 --- a/Core/Tools/matchbot/wlib/wdebug.cpp +++ b/Core/Tools/matchbot/wlib/wdebug.cpp @@ -85,12 +85,7 @@ int MsgManager::ReplaceAllStreams(FileD * output_device, IN char *device_filenam delete(info_ostream); delete(warn_ostream); delete(error_ostream); - - if (output_device != NULL) - { - delete(output_device); - output_device = NULL; - } + delete(output_device); rename(device_filename, copy_filename); diff --git a/Core/Tools/matchbot/wlib/wdebug.h b/Core/Tools/matchbot/wlib/wdebug.h index 07ab528543..4b5a8568d1 100644 --- a/Core/Tools/matchbot/wlib/wdebug.h +++ b/Core/Tools/matchbot/wlib/wdebug.h @@ -50,8 +50,7 @@ will you be ready to leave grasshopper. \*****************************************************************************/ -#ifndef WDEBUG_HEADER -#define WDEBUG_HEADER +#pragma once #define USE_DEBUG_SEM @@ -60,7 +59,7 @@ will you be ready to leave grasshopper. #include #include -#if !defined(_WINDOWS) +#if !defined(_WIN32) // Windows headers have a tendency to redefine IN #ifdef IN #undef IN @@ -184,7 +183,7 @@ extern CritSec DebugLibSemaphore; #define DBG(X) X // In Windows, send a copy to the debugger window -#ifdef _WINDOWS +#ifdef _WIN32 // Print a variable #define PVAR(v) \ @@ -244,7 +243,7 @@ extern CritSec DebugLibSemaphore; DEBUGUNLOCK; \ } -#else // _WINDOWS +#else // _WIN32 // Print a variable #define PVAR(v) \ @@ -284,7 +283,7 @@ extern CritSec DebugLibSemaphore; "]: " << ##X << endl; X \ DEBUGUNLOCK; \ } -#endif // _WINDOWS +#endif // _WIN32 #endif // DEBUG @@ -314,5 +313,3 @@ class MsgManager static ostream *warnStream(void); static ostream *errorStream(void); }; - -#endif diff --git a/Core/Tools/matchbot/wlib/wstring.cpp b/Core/Tools/matchbot/wlib/wstring.cpp index 94e9f30de9..a19c9aaa00 100644 --- a/Core/Tools/matchbot/wlib/wstring.cpp +++ b/Core/Tools/matchbot/wlib/wstring.cpp @@ -265,8 +265,7 @@ void Wstring::removeSpaces(void) void Wstring::clear(void) { - if(str) - delete[](str); + delete[](str); strsize=0; str=NULL; } diff --git a/Core/Tools/matchbot/wlib/wstring.h b/Core/Tools/matchbot/wlib/wstring.h index 8b58b0e676..dc3cf29dd7 100644 --- a/Core/Tools/matchbot/wlib/wstring.h +++ b/Core/Tools/matchbot/wlib/wstring.h @@ -26,8 +26,7 @@ Start Date : June 1, 1997 Last Update : June 17, 1997 \****************************************************************************/ -#ifndef WSTRING_HEADER -#define WSTRING_HEADER +#pragma once #include #include @@ -89,5 +88,3 @@ class Wstring char *str; // Pointer to allocated string. int strsize; // allocated data length }; - -#endif diff --git a/Core/Tools/matchbot/wlib/wstypes.h b/Core/Tools/matchbot/wlib/wstypes.h index baa5d72884..c13ef1fa3c 100644 --- a/Core/Tools/matchbot/wlib/wstypes.h +++ b/Core/Tools/matchbot/wlib/wstypes.h @@ -28,15 +28,14 @@ Last Update : June 17, 1997 Standard type definitions for the sake of portability and readability. \***************************************************************************/ -#ifndef WSTYPES_HEADER -#define WSTYPES_HEADER +#pragma once #ifdef _REENTRANT // reentrant = threaded // Headers with non threadsafe libs need to come before my hacky // threadsafe.h otherwise they won't compile #include -#ifndef _WINDOWS +#ifndef _WIN32 #define _POSIX_C_SOURCE 199506L #define _POSIX_PTHREAD_SEMANTICS #define __EXTENSIONS__ @@ -44,7 +43,7 @@ Standard type definitions for the sake of portability and readability. #include #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #include #include @@ -110,9 +109,7 @@ typedef double float64; #define MAX_SINT16 0x7FFF #define MAX_SINT8 0x7F -#ifdef _WINDOWS +#ifdef _WIN32 #define strncasecmp _strnicmp #define strcasecmp _stricmp #endif - -#endif diff --git a/Core/Tools/matchbot/wlib/wtime.cpp b/Core/Tools/matchbot/wlib/wtime.cpp index 4e7fe87df0..6ff6a0ce37 100644 --- a/Core/Tools/matchbot/wlib/wtime.cpp +++ b/Core/Tools/matchbot/wlib/wtime.cpp @@ -35,7 +35,7 @@ static const char *FULLMONTHS[]={"January","February","March","April","May","Jun "July","August","September","October","November","December"}; // MDC: Windows doesn't provide a localtime_r, so make our own... -#ifdef _WINDOWS +#ifdef _WIN32 #ifdef _REENTRANT #include "critsec.h" static CritSec localtime_critsec; @@ -54,7 +54,7 @@ static struct tm *localtime_r(const time_t *clockval, struct tm *res) { #endif return res; } -#endif // _WINDOWS +#endif // _WIN32 Wtime::Wtime(void) { @@ -82,13 +82,13 @@ Wtime::~Wtime() void Wtime::Update(void) { sign=POSITIVE; - #ifdef _WINDOWS + #ifdef _WIN32 struct _timeb wintime; _ftime(&wintime); sec=wintime.time; usec=(wintime.millitm)*1000; #endif - #ifndef _WINDOWS + #ifndef _WIN32 struct timeval unixtime; struct timezone unixtzone; gettimeofday(&unixtime,&unixtzone); diff --git a/Core/Tools/matchbot/wlib/wtime.h b/Core/Tools/matchbot/wlib/wtime.h index be8adb38c5..e969217da0 100644 --- a/Core/Tools/matchbot/wlib/wtime.h +++ b/Core/Tools/matchbot/wlib/wtime.h @@ -20,16 +20,15 @@ wtime Neal Kettler \****************************************************************************/ -#ifndef WTIME_HEADER -#define WTIME_HEADER +#pragma once #include #include #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #include #include @@ -124,5 +123,3 @@ class Wtime uint32 usec; // microseconds (millionths of a second) bit8 sign; // for time differences 0 = pos 1 = neg }; - -#endif diff --git a/Core/Tools/matchbot/wlib/xtime.cpp b/Core/Tools/matchbot/wlib/xtime.cpp index 00bc596899..d36a7ec187 100644 --- a/Core/Tools/matchbot/wlib/xtime.cpp +++ b/Core/Tools/matchbot/wlib/xtime.cpp @@ -29,7 +29,7 @@ long long after you'll be dead. #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #endif #include "xtime.h" @@ -88,7 +88,7 @@ static sint32 Get_Day(int month, int day, int year) static bit8 Get_Date_From_Day(sint32 days, OUT sint32 &year, OUT sint32 &yday) { //register long int rem; - register long int y; + long int y; //register const unsigned short int *ip; if (days <= 365) @@ -286,13 +286,13 @@ void Xtime::update(void) day_=719528; // day_s from year 0 to Jan1, 1970 msec_=0; - #ifdef _WINDOWS + #ifdef _WIN32 struct _timeb wintime; _ftime(&wintime); addSeconds(wintime.time); msec_+=wintime.millitm; #endif - #ifndef _WINDOWS + #ifndef _WIN32 struct timeval unixtime; struct timezone unixtzone; gettimeofday(&unixtime,&unixtzone); diff --git a/Core/Tools/matchbot/wlib/xtime.h b/Core/Tools/matchbot/wlib/xtime.h index 0492095a00..c79e4c9f43 100644 --- a/Core/Tools/matchbot/wlib/xtime.h +++ b/Core/Tools/matchbot/wlib/xtime.h @@ -29,16 +29,14 @@ Hopefully by then somebody will replace the lame time() function :-) \****************************************************************************/ -#ifndef XTIME_HEADER -#define XTIME_HEADER - +#pragma once #include #include #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #include #include @@ -142,5 +140,3 @@ class Xtime sint32 day_; // days since Jan 1, 0 sint32 msec_; // milliseconds (thousandths of a sec) }; - -#endif diff --git a/Core/Tools/matchbot/wnet/field.cpp b/Core/Tools/matchbot/wnet/field.cpp index 4cd9043477..699b52507c 100644 --- a/Core/Tools/matchbot/wnet/field.cpp +++ b/Core/Tools/matchbot/wnet/field.cpp @@ -20,7 +20,7 @@ * * * Project Name : Westwood Auto Registration App * * * - * File Name : FIELD.CPP * + * File Name : FIELD.cpp * * * * Programmer : Philip W. Gorrow * * * @@ -34,7 +34,7 @@ * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #else #define Win32_Winsock diff --git a/Core/Tools/matchbot/wnet/field.h b/Core/Tools/matchbot/wnet/field.h index b321989913..de573ddbee 100644 --- a/Core/Tools/matchbot/wnet/field.h +++ b/Core/Tools/matchbot/wnet/field.h @@ -20,7 +20,7 @@ * * * Project Name : Westwood Auto Registration App * * * - * File Name : FIELD.H * + * File Name : FIELD.h * * * * Programmer : Philip W. Gorrow * * * diff --git a/Core/Tools/matchbot/wnet/packet.cpp b/Core/Tools/matchbot/wnet/packet.cpp index cbc52c7845..8cda4f64b0 100644 --- a/Core/Tools/matchbot/wnet/packet.cpp +++ b/Core/Tools/matchbot/wnet/packet.cpp @@ -20,7 +20,7 @@ * * * Project Name : Westwood Auto Registration App * * * - * File Name : PACKET.CPP * + * File Name : PACKET.cpp * * * * Programmer : Philip W. Gorrow * * * @@ -39,7 +39,7 @@ #include #include #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #else #define Win32_Winsock diff --git a/Core/Tools/matchbot/wnet/packet.h b/Core/Tools/matchbot/wnet/packet.h index ecf68ad2f4..d61870cb9d 100644 --- a/Core/Tools/matchbot/wnet/packet.h +++ b/Core/Tools/matchbot/wnet/packet.h @@ -20,7 +20,7 @@ * * * Project Name : Westwood Auto Registration App * * * - * File Name : PACKET.H * + * File Name : PACKET.h * * * * Programmer : Philip W. Gorrow * * * diff --git a/Core/Tools/matchbot/wnet/tcp.cpp b/Core/Tools/matchbot/wnet/tcp.cpp index 9dd0b93bd9..66ea079c7a 100644 --- a/Core/Tools/matchbot/wnet/tcp.cpp +++ b/Core/Tools/matchbot/wnet/tcp.cpp @@ -99,7 +99,7 @@ while (1) #include "tcp.h" #include -#ifndef _WINDOWS +#ifndef _WIN32 #include #define closesocket close #endif @@ -170,7 +170,7 @@ sint32 TCP::SetBlocking(bit8 block,sint32 whichFD) if (whichFD==0) whichFD=fd; - #ifdef _WINDOWS + #ifdef _WIN32 unsigned long flag=1; if (block) flag=0; @@ -219,7 +219,7 @@ sint32 TCP::Write(const uint8 *msg,uint32 len,sint32 whichFD) } SetBlocking(TRUE,whichFD); retval=send(whichFD,(const char *)msg,len,0); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -241,7 +241,7 @@ sint32 TCP::WriteNB(uint8 *msg,uint32 len,sint32 whichFD) whichFD=fd; } retval=send(whichFD,(const char *)msg,len,0); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -942,7 +942,7 @@ bit8 TCP::Bind(uint32 IP,uint16 Port,bit8 reuseAddr) } retval=bind(fd,(struct sockaddr *)&addr,sizeof(addr)); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -1013,7 +1013,7 @@ bit8 TCP::Connect(uint32 IP,uint16 Port) result = connect(fd,(struct sockaddr *)&serverAddr, sizeof(serverAddr)); status=GetStatus(); - #ifdef _WINDOWS + #ifdef _WIN32 if (result==SOCKET_ERROR) result=-1; #endif @@ -1107,7 +1107,7 @@ bit8 TCP::ConnectAsync(uint32 IP,uint16 Port) connectErrno=errno; status=GetStatus(); - #ifdef _WINDOWS + #ifdef _WIN32 if (result==SOCKET_ERROR) { DBGMSG("Socket error 1 " << status); @@ -1124,7 +1124,7 @@ bit8 TCP::ConnectAsync(uint32 IP,uint16 Port) ClearStatus(); result = connect(fd,(struct sockaddr *)&serverAddr, sizeof(serverAddr)); status=GetStatus(); - #ifdef _WINDOWS + #ifdef _WIN32 if (result==SOCKET_ERROR) { DBGMSG("Socket error 2 " << status); @@ -1159,14 +1159,14 @@ bit8 TCP::ConnectAsync(uint32 IP,uint16 Port) void TCP::ClearStatus(void) { - #ifndef _WINDOWS + #ifndef _WIN32 errno=0; #endif } int TCP::GetStatus(void) { - #ifdef _WINDOWS + #ifdef _WIN32 int status=WSAGetLastError(); if (status==0) return(OK); else if (status==WSAEINTR) return(INTR); diff --git a/Core/Tools/matchbot/wnet/tcp.h b/Core/Tools/matchbot/wnet/tcp.h index 9bfd465d71..3e76c99ead 100644 --- a/Core/Tools/matchbot/wnet/tcp.h +++ b/Core/Tools/matchbot/wnet/tcp.h @@ -21,8 +21,7 @@ TCP Neal Kettler neal@westwood.com \****************************************************************************/ -#ifndef TCP_HEADER -#define TCP_HEADER +#pragma once #include #include @@ -31,7 +30,7 @@ TCP Neal Kettler neal@westwood.com #include #include -#ifdef _WINDOWS +#ifdef _WIN32 #include #include @@ -195,5 +194,3 @@ class TCP bit8 SetOutputDelay(sint32 delay) { outputDelay=delay; return(TRUE); }; }; - -#endif diff --git a/Core/Tools/matchbot/wnet/udp.cpp b/Core/Tools/matchbot/wnet/udp.cpp index d15cc98823..bba9479b65 100644 --- a/Core/Tools/matchbot/wnet/udp.cpp +++ b/Core/Tools/matchbot/wnet/udp.cpp @@ -60,7 +60,7 @@ sint32 UDP::Bind(uint32 IP,uint16 Port) addr.sin_port=Port; addr.sin_addr.s_addr=IP; fd=socket(AF_INET,SOCK_DGRAM,DEFAULT_PROTOCOL); - #ifdef _WINDOWS + #ifdef _WIN32 if (fd==SOCKET_ERROR) fd=-1; #endif @@ -69,7 +69,7 @@ sint32 UDP::Bind(uint32 IP,uint16 Port) retval=bind(fd,(struct sockaddr *)&addr,sizeof(addr)); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -104,7 +104,7 @@ bit8 UDP::getLocalAddr(uint32 &ip, uint16 &port) // private function sint32 UDP::SetBlocking(bit8 block) { - #ifdef _WINDOWS + #ifdef _WIN32 unsigned long flag=1; if (block) flag=0; @@ -145,7 +145,7 @@ sint32 UDP::Write(uint8 *msg,uint32 len,uint32 IP,uint16 port) ClearStatus(); retval=sendto(fd,(char *)msg,len,0,(struct sockaddr *)&to,sizeof(to)); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -161,7 +161,7 @@ sint32 UDP::Read(uint8 *msg,uint32 len,sockaddr_in *from) if (from!=NULL) { retval=recvfrom(fd,(char *)msg,len,0,(struct sockaddr *)from,&alen); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -169,7 +169,7 @@ sint32 UDP::Read(uint8 *msg,uint32 len,sockaddr_in *from) else { retval=recvfrom(fd,(char *)msg,len,0,NULL,NULL); - #ifdef _WINDOWS + #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; #endif @@ -180,14 +180,14 @@ sint32 UDP::Read(uint8 *msg,uint32 len,sockaddr_in *from) void UDP::ClearStatus(void) { - #ifndef _WINDOWS + #ifndef _WIN32 errno=0; #endif } UDP::sockStat UDP::GetStatus(void) { - #ifdef _WINDOWS + #ifdef _WIN32 int status=WSAGetLastError(); if (status==0) return(OK); else if (status==WSAEINTR) return(INTR); @@ -310,7 +310,7 @@ int UDP::Wait(sint32 sec,sint32 usec,fd_set &givenSet,fd_set &returnSet) bit8 UDP::SetInputBuffer(uint32 bytes) { - #ifndef _WINDOWS + #ifndef _WIN32 int retval,arg=bytes; retval=setsockopt(fd,SOL_SOCKET,SO_RCVBUF, @@ -328,7 +328,7 @@ bit8 UDP::SetInputBuffer(uint32 bytes) bit8 UDP::SetOutputBuffer(uint32 bytes) { - #ifndef _WINDOWS + #ifndef _WIN32 int retval,arg=bytes; retval=setsockopt(fd,SOL_SOCKET,SO_SNDBUF, @@ -346,7 +346,7 @@ bit8 UDP::SetOutputBuffer(uint32 bytes) int UDP::GetInputBuffer(void) { - #ifndef _WINDOWS + #ifndef _WIN32 int retval,arg=0,len=sizeof(int); retval=getsockopt(fd,SOL_SOCKET,SO_RCVBUF, @@ -360,7 +360,7 @@ int UDP::GetInputBuffer(void) int UDP::GetOutputBuffer(void) { - #ifndef _WINDOWS + #ifndef _WIN32 int retval,arg=0,len=sizeof(int); retval=getsockopt(fd,SOL_SOCKET,SO_SNDBUF, diff --git a/Core/Tools/matchbot/wnet/udp.h b/Core/Tools/matchbot/wnet/udp.h index 118eb100ad..7f40086058 100644 --- a/Core/Tools/matchbot/wnet/udp.h +++ b/Core/Tools/matchbot/wnet/udp.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef UDP_HEADER -#define UDP_HEADER +#pragma once #include #include @@ -25,7 +24,7 @@ #include #include -#ifdef _WINDOWS +#ifdef _WIN32 #include #include #define close _close @@ -110,5 +109,3 @@ class UDP int GetInputBuffer(void); int GetOutputBuffer(void); }; - -#endif diff --git a/Core/Tools/textureCompress/textureCompress.cpp b/Core/Tools/textureCompress/textureCompress.cpp index 1728b27e91..0eefe77166 100644 --- a/Core/Tools/textureCompress/textureCompress.cpp +++ b/Core/Tools/textureCompress/textureCompress.cpp @@ -64,7 +64,7 @@ static void logStuff(const char *fmt, ...) ::MessageBox(NULL, buffer, "textureCompress", MB_OK); } -#ifndef NDEBUG +#ifdef RTS_DEBUG class DebugMunkee { @@ -96,7 +96,7 @@ static void debugLog(const char *fmt, ...) #define DEBUG_LOG(x) {} -#endif // NDEBUG +#endif // RTS_DEBUG static void usage(const char *progname) @@ -231,7 +231,7 @@ Directory::Directory( const std::string& dirPath ) : m_dirPath(dirPath) // if this is a subdirectory keep the name around till the end if( item.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) { - if ( strcmp( item.cFileName, "." ) && strcmp( item.cFileName, ".." ) ) + if ( strcmp( item.cFileName, "." ) != 0 && strcmp( item.cFileName, ".." ) ) { info.set(item); m_subdirs.insert( info ); @@ -619,7 +619,7 @@ int main(int argc, const char **argv) const char *targetDir = argv[2]; const char *cacheDir = argv[3]; -#ifndef NDEBUG +#ifdef RTS_DEBUG theDebugMunkee = new DebugMunkee(argv[4]); #endif @@ -631,7 +631,7 @@ int main(int argc, const char **argv) //printSet( hasAlpha, "Using Alpha Channel" ); //tearDownLoadWindow(); -#ifndef NDEBUG +#ifdef RTS_DEBUG delete theDebugMunkee; theDebugMunkee = NULL; #endif diff --git a/Core/Tools/timingTest/StdAfx.cpp b/Core/Tools/timingTest/StdAfx.cpp index be97e1b641..a881c7bb19 100644 --- a/Core/Tools/timingTest/StdAfx.cpp +++ b/Core/Tools/timingTest/StdAfx.cpp @@ -22,5 +22,5 @@ #include "StdAfx.h" -// TODO: reference any additional headers you need in STDAFX.H +// TODO: reference any additional headers you need in STDAFX.h // and not in this file diff --git a/Core/Tools/timingTest/StdAfx.h b/Core/Tools/timingTest/StdAfx.h index c55d514831..fd99f02206 100644 --- a/Core/Tools/timingTest/StdAfx.h +++ b/Core/Tools/timingTest/StdAfx.h @@ -21,12 +21,7 @@ // are changed infrequently // -#if !defined(AFX_STDAFX_H__2E1EE76B_62B6_41EC_9B2E_E7B1677E0D6E__INCLUDED_) -#define AFX_STDAFX_H__2E1EE76B_62B6_41EC_9B2E_E7B1677E0D6E__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers @@ -36,5 +31,3 @@ //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__2E1EE76B_62B6_41EC_9B2E_E7B1677E0D6E__INCLUDED_) diff --git a/Core/Tools/versionUpdate/versionUpdate.cpp b/Core/Tools/versionUpdate/versionUpdate.cpp index 23c505ab6f..e8c1a90929 100644 --- a/Core/Tools/versionUpdate/versionUpdate.cpp +++ b/Core/Tools/versionUpdate/versionUpdate.cpp @@ -152,9 +152,9 @@ int APIENTRY WinMain(HINSTANCE hInstance, { printf ("Local build is 0. Oops, didn't find a string of the format: '#define VERSION \"x.y.z\"'"); } - } // End if if (strstr - } // End of while - } // End of if filePtr + } + } + } else { // Didn't find the file, write a new one diff --git a/Core/Tools/wolSetup/StdAfx.cpp b/Core/Tools/wolSetup/StdAfx.cpp index cc06faa54c..a666396e62 100644 --- a/Core/Tools/wolSetup/StdAfx.cpp +++ b/Core/Tools/wolSetup/StdAfx.cpp @@ -22,5 +22,5 @@ #include "StdAfx.h" -// TODO: reference any additional headers you need in STDAFX.H +// TODO: reference any additional headers you need in STDAFX.h // and not in this file diff --git a/Core/Tools/wolSetup/StdAfx.h b/Core/Tools/wolSetup/StdAfx.h index e2b01528de..9c16d70d2f 100644 --- a/Core/Tools/wolSetup/StdAfx.h +++ b/Core/Tools/wolSetup/StdAfx.h @@ -21,12 +21,7 @@ // are changed infrequently // -#if !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) -#define AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_ - -#if _MSC_VER > 1000 #pragma once -#endif // _MSC_VER > 1000 #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers @@ -37,5 +32,3 @@ //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. - -#endif // !defined(AFX_STDAFX_H__A9DB83DB_A9FD_11D0_BFD1_444553540000__INCLUDED_) diff --git a/Core/Tools/wolSetup/WOLAPI/chatdefs.h b/Core/Tools/wolSetup/WOLAPI/chatdefs.h index bcd83f50b0..e0175d7574 100644 --- a/Core/Tools/wolSetup/WOLAPI/chatdefs.h +++ b/Core/Tools/wolSetup/WOLAPI/chatdefs.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef CHATDEFS_HEADER -#define CHATDEFS_HEADER +#pragma once // gks 11/3/1999: version numbers for SetClientVersion // GMU 01/12/01 : bumped CHAT_VERSION_MINOR to 15 @@ -168,6 +167,3 @@ #define CHAN_MODE_KEY 0x0100 #define CHAN_MODE_BAN 0x0200 #define CHAN_MODE_LIMIT 0x0400 - - -#endif diff --git a/Core/Tools/wolSetup/WOLAPI/downloaddefs.h b/Core/Tools/wolSetup/WOLAPI/downloaddefs.h index a5a3bf4ceb..cd78d834a1 100644 --- a/Core/Tools/wolSetup/WOLAPI/downloaddefs.h +++ b/Core/Tools/wolSetup/WOLAPI/downloaddefs.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef _DOWNLOADDEFS_H -#define _DOWNLOADDEFS_H +#pragma once // CDownload statuses @@ -56,5 +55,3 @@ #define DOWNLOADEVENT_LOCALFILEOPENFAILED 5 #define DOWNLOADEVENT_TCPERROR 6 #define DOWNLOADEVENT_DISCONNECTERROR 7 - -#endif diff --git a/Core/Tools/wolSetup/WOLAPI/ftpdefs.h b/Core/Tools/wolSetup/WOLAPI/ftpdefs.h index 35fa5b6a87..1306a38ecb 100644 --- a/Core/Tools/wolSetup/WOLAPI/ftpdefs.h +++ b/Core/Tools/wolSetup/WOLAPI/ftpdefs.h @@ -16,15 +16,10 @@ ** along with this program. If not, see . */ -#ifndef __FTPDEFS_H_INCLUDED__ -#define __FTPDEFS_H_INCLUDED__ - +#pragma once // CFtp return codes. #define FTP_SUCCEEDED S_OK #define FTP_FAILED MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 1 ) #define FTP_TRYING MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 2 ) - - -#endif diff --git a/Core/Tools/wolSetup/WOLAPI/netutildefs.h b/Core/Tools/wolSetup/WOLAPI/netutildefs.h index 5f3840c10e..926bc1f2fa 100644 --- a/Core/Tools/wolSetup/WOLAPI/netutildefs.h +++ b/Core/Tools/wolSetup/WOLAPI/netutildefs.h @@ -16,9 +16,7 @@ ** along with this program. If not, see . */ -#ifndef NETUTILDEFS_HEADER -#define NETUTILDEFS_HEADER - +#pragma once #define NETUTIL_E_ERROR MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 100) #define NETUTIL_E_BUSY MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 101) @@ -28,5 +26,3 @@ #define NETUTIL_E_CANTVERIFY MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 257) #define NETUTIL_S_FINISHED MAKE_HRESULT( SEVERITY_SUCCESS, FACILITY_ITF, 500) - -#endif diff --git a/Core/Tools/wolSetup/verchk.h b/Core/Tools/wolSetup/verchk.h index d83f7cf5ba..4584bc1632 100644 --- a/Core/Tools/wolSetup/verchk.h +++ b/Core/Tools/wolSetup/verchk.h @@ -16,8 +16,7 @@ ** along with this program. If not, see . */ -#ifndef __VERCHK_H__ -#define __VERCHK_H__ +#pragma once #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN @@ -27,6 +26,3 @@ // Obtain version information from the specified file. bool GetVersionInfo(char* filename, VS_FIXEDFILEINFO* fileInfo); bool loadWolapi( char *filename ); - -#endif // __VERCHK_H__ - diff --git a/Core/Tools/wolSetup/wolSetup.h b/Core/Tools/wolSetup/wolSetup.h index 1241952d56..80350df119 100644 --- a/Core/Tools/wolSetup/wolSetup.h +++ b/Core/Tools/wolSetup/wolSetup.h @@ -19,8 +19,7 @@ // FILE: wolSetup.h ////////////////////////////////////////////////////// // Author: Matthew D. Campbell, December 2001 -#ifndef __WOLSETUP_H__ -#define __WOLSETUP_H__ +#pragma once #ifndef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN @@ -42,5 +41,3 @@ extern char g_generalsSerial[]; // TheSuperHackers @todo Check if this should be returning unsigned long. static int MAJOR(unsigned long x) { return (((x) & 0xffff0000) >> 16); } static int MINOR(unsigned long x) { return ((x) & 0xffff); } - -#endif // __WOLSETUP_H__ diff --git a/Dependencies/Utility/Utility/CppMacros.h b/Dependencies/Utility/Utility/CppMacros.h index 59a5ae09af..8bfb0297f2 100644 --- a/Dependencies/Utility/Utility/CppMacros.h +++ b/Dependencies/Utility/Utility/CppMacros.h @@ -37,13 +37,10 @@ #endif #if __cplusplus >= 201103L - #define CPP_11(code) code - #define CONSTEXPR constexpr +#define CPP_11(code) code #else - #define CPP_11(code) - #define CONSTEXPR -#endif - -#if __cplusplus < 201103L +#define CPP_11(code) #define static_assert(expr, msg) +#define constexpr +#define nullptr 0 #endif diff --git a/Dependencies/Utility/Utility/compat.h b/Dependencies/Utility/Utility/compat.h index 7af2c302c2..32d00018aa 100644 --- a/Dependencies/Utility/Utility/compat.h +++ b/Dependencies/Utility/Utility/compat.h @@ -71,4 +71,5 @@ #include "time_compat.h" #include "thread_compat.h" -#endif \ No newline at end of file +#endif + diff --git a/Dependencies/Utility/Utility/endian_compat.h b/Dependencies/Utility/Utility/endian_compat.h index 56b35c33be..08c6fdb16f 100644 --- a/Dependencies/Utility/Utility/endian_compat.h +++ b/Dependencies/Utility/Utility/endian_compat.h @@ -19,7 +19,6 @@ // This file contains macros to help with endian conversions between different endian systems. #pragma once -// VC6 does not support pragma once #ifndef ENDIAN_COMPAT_H #define ENDIAN_COMPAT_H @@ -195,30 +194,30 @@ template struct betohHelper; template struct letohHelper; // 2 byte integer, enum -template struct htobeHelper { static inline Type swap(Type value) { return static_cast(htobe16(static_cast(value))); } }; -template struct htoleHelper { static inline Type swap(Type value) { return static_cast(htole16(static_cast(value))); } }; -template struct betohHelper { static inline Type swap(Type value) { return static_cast(be16toh(static_cast(value))); } }; -template struct letohHelper { static inline Type swap(Type value) { return static_cast(le16toh(static_cast(value))); } }; +template struct htobeHelper { static Type swap(Type value) { return static_cast(htobe16(static_cast(value))); } }; +template struct htoleHelper { static Type swap(Type value) { return static_cast(htole16(static_cast(value))); } }; +template struct betohHelper { static Type swap(Type value) { return static_cast(be16toh(static_cast(value))); } }; +template struct letohHelper { static Type swap(Type value) { return static_cast(le16toh(static_cast(value))); } }; // 4 byte integer, enum -template struct htobeHelper { static inline Type swap(Type value) { return static_cast(htobe32(static_cast(value))); } }; -template struct htoleHelper { static inline Type swap(Type value) { return static_cast(htole32(static_cast(value))); } }; -template struct betohHelper { static inline Type swap(Type value) { return static_cast(be32toh(static_cast(value))); } }; -template struct letohHelper { static inline Type swap(Type value) { return static_cast(le16toh(static_cast(value))); } }; +template struct htobeHelper { static Type swap(Type value) { return static_cast(htobe32(static_cast(value))); } }; +template struct htoleHelper { static Type swap(Type value) { return static_cast(htole32(static_cast(value))); } }; +template struct betohHelper { static Type swap(Type value) { return static_cast(be32toh(static_cast(value))); } }; +template struct letohHelper { static Type swap(Type value) { return static_cast(le16toh(static_cast(value))); } }; // 8 byte integer, enum -template struct htobeHelper { static inline Type swap(Type value) { return static_cast(htobe64(static_cast(value))); } }; -template struct htoleHelper { static inline Type swap(Type value) { return static_cast(htole64(static_cast(value))); } }; -template struct betohHelper { static inline Type swap(Type value) { return static_cast(be64toh(static_cast(value))); } }; -template struct letohHelper { static inline Type swap(Type value) { return static_cast(le16toh(static_cast(value))); } }; +template struct htobeHelper { static Type swap(Type value) { return static_cast(htobe64(static_cast(value))); } }; +template struct htoleHelper { static Type swap(Type value) { return static_cast(htole64(static_cast(value))); } }; +template struct betohHelper { static Type swap(Type value) { return static_cast(be64toh(static_cast(value))); } }; +template struct letohHelper { static Type swap(Type value) { return static_cast(le16toh(static_cast(value))); } }; // float -template <> struct htobeHelper { static inline float swap(float value) { SwapType32 v = htobe32(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; -template <> struct htoleHelper { static inline float swap(float value) { SwapType32 v = htole32(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; -template <> struct betohHelper { static inline float swap(float value) { SwapType32 v = be32toh(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; -template <> struct letohHelper { static inline float swap(float value) { SwapType32 v = le16toh(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; +template <> struct htobeHelper { static float swap(float value) { SwapType32 v = htobe32(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; +template <> struct htoleHelper { static float swap(float value) { SwapType32 v = htole32(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; +template <> struct betohHelper { static float swap(float value) { SwapType32 v = be32toh(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; +template <> struct letohHelper { static float swap(float value) { SwapType32 v = le16toh(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; // double -template <> struct htobeHelper { static inline double swap(double value) { SwapType64 v = htobe64(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; -template <> struct htoleHelper { static inline double swap(double value) { SwapType64 v = htole64(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; -template <> struct betohHelper { static inline double swap(double value) { SwapType64 v = be64toh(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; -template <> struct letohHelper { static inline double swap(double value) { SwapType64 v = le16toh(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; +template <> struct htobeHelper { static double swap(double value) { SwapType64 v = htobe64(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; +template <> struct htoleHelper { static double swap(double value) { SwapType64 v = htole64(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; +template <> struct betohHelper { static double swap(double value) { SwapType64 v = be64toh(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; +template <> struct letohHelper { static double swap(double value) { SwapType64 v = le16toh(*reinterpret_cast(&value)); return *reinterpret_cast(&v); } }; } // namespace Endian // c++ template functions, takes any 2, 4, 8 bytes, including float, double, enum @@ -243,4 +242,5 @@ template inline void letoh_ref(Type &value) { value = Endian::let #endif // _MSC_VER < 1300 -#endif // ENDIAN_COMPAT_H \ No newline at end of file +#endif // ENDIAN_COMPAT_H + diff --git a/Dependencies/Utility/Utility/intrin_compat.h b/Dependencies/Utility/Utility/intrin_compat.h index c02913e432..efea3e62c7 100644 --- a/Dependencies/Utility/Utility/intrin_compat.h +++ b/Dependencies/Utility/Utility/intrin_compat.h @@ -103,7 +103,7 @@ static inline uint64_t _rdtsc() #endif } #endif // _rdtsc - + #ifdef _WIN32 #include #pragma intrinsic(_ReturnAddress) @@ -120,7 +120,7 @@ static inline uint64_t _rdtsc() #error "No implementation for _ReturnAddress" #endif -#if defined(__has_builtin) +#if defined(__has_builtin) #if __has_builtin(__builtin_debugtrap) #define __debugbreak() __builtin_debugtrap() #elif __has_builtin(__builtin_trap) diff --git a/Dependencies/Utility/Utility/mem_compat.h b/Dependencies/Utility/Utility/mem_compat.h index 189e1d058f..42a5e8f0bf 100644 --- a/Dependencies/Utility/Utility/mem_compat.h +++ b/Dependencies/Utility/Utility/mem_compat.h @@ -20,4 +20,5 @@ #pragma once #include -#define _alloca alloca \ No newline at end of file +#define _alloca alloca + diff --git a/Dependencies/Utility/Utility/stdint_adapter.h b/Dependencies/Utility/Utility/stdint_adapter.h index b73de83603..241b7cdb65 100644 --- a/Dependencies/Utility/Utility/stdint_adapter.h +++ b/Dependencies/Utility/Utility/stdint_adapter.h @@ -26,7 +26,7 @@ #else typedef int intptr_t; typedef unsigned int uintptr_t; -#endif +#endif /* 7.18.1.1 Exact-width integer types */ typedef signed char int8_t; diff --git a/Dependencies/Utility/Utility/string_compat.h b/Dependencies/Utility/Utility/string_compat.h index 0e26f3267e..ff88aaa7a4 100644 --- a/Dependencies/Utility/Utility/string_compat.h +++ b/Dependencies/Utility/Utility/string_compat.h @@ -34,4 +34,5 @@ inline char *_strlwr(char *str) { #define strlwr _strlwr #define stricmp strcasecmp #define strnicmp strncasecmp -#define strcmpi strcasecmp \ No newline at end of file +#define strcmpi strcasecmp + diff --git a/Dependencies/Utility/Utility/tchar_compat.h b/Dependencies/Utility/Utility/tchar_compat.h index f5a470fbef..69c8512409 100644 --- a/Dependencies/Utility/Utility/tchar_compat.h +++ b/Dependencies/Utility/Utility/tchar_compat.h @@ -27,4 +27,5 @@ typedef TCHAR* LPTSTR; #define _tcscmp strcmp #define _tcsicmp strcasecmp #define _tcsclen strlen -#define _tcscpy strcpy \ No newline at end of file +#define _tcscpy strcpy + diff --git a/Dependencies/Utility/Utility/thread_compat.h b/Dependencies/Utility/Utility/thread_compat.h index 9345944e7f..bd13a42f5a 100644 --- a/Dependencies/Utility/Utility/thread_compat.h +++ b/Dependencies/Utility/Utility/thread_compat.h @@ -29,4 +29,5 @@ inline int GetCurrentThreadId() inline void Sleep(int ms) { usleep(ms * 1000); -} \ No newline at end of file +} + diff --git a/Dependencies/Utility/Utility/time_compat.h b/Dependencies/Utility/Utility/time_compat.h index 1dd9582079..82449ee9ae 100644 --- a/Dependencies/Utility/Utility/time_compat.h +++ b/Dependencies/Utility/Utility/time_compat.h @@ -37,4 +37,5 @@ inline unsigned int GetTickCount() clock_gettime(CLOCK_MONOTONIC, &ts); // Return ms since boot return ts.tv_sec * 1000 + ts.tv_nsec / 1000000; -} \ No newline at end of file +} + diff --git a/Dependencies/Utility/Utility/wchar_compat.h b/Dependencies/Utility/Utility/wchar_compat.h index e43fa7a703..a6761905a7 100644 --- a/Dependencies/Utility/Utility/wchar_compat.h +++ b/Dependencies/Utility/Utility/wchar_compat.h @@ -30,4 +30,5 @@ typedef WCHAR* LPWSTR; // MultiByteToWideChar #define CP_ACP 0 #define MultiByteToWideChar(cp, flags, mbstr, cb, wcstr, cch) mbstowcs(wcstr, mbstr, cch) -#define WideCharToMultiByte(cp, flags, wcstr, cch, mbstr, cb, defchar, used) wcstombs(mbstr, wcstr, cb) \ No newline at end of file +#define WideCharToMultiByte(cp, flags, wcstr, cch, mbstr, cb, defchar, used) wcstombs(mbstr, wcstr, cb) + diff --git a/Generals/CMakeLists.txt b/Generals/CMakeLists.txt index 7953714f5a..78f920244e 100644 --- a/Generals/CMakeLists.txt +++ b/Generals/CMakeLists.txt @@ -15,23 +15,31 @@ add_subdirectory(Code) # If we are building on windows for windows, try and get the game install path from the registry. if("${CMAKE_HOST_SYSTEM}" MATCHES "Windows" AND "${CMAKE_SYSTEM}" MATCHES "Windows") - # Check the CD registry path - if(NOT RTS_INSTALL_PREFIX_GENERALS) - get_filename_component(RTS_INSTALL_PREFIX_GENERALS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Electronic Arts\\EA Games\\Generals;InstallPath]" ABSOLUTE CACHE) - endif() + include(${CMAKE_SOURCE_DIR}/cmake/registry.cmake) + + # Check the EA App/CD registry path + fetch_registry_value( + "HKEY_LOCAL_MACHINE/SOFTWARE/Electronic Arts/EA Games/Generals" + "InstallPath" + RTS_INSTALL_PREFIX_GENERALS + "Generals install path from registry") # Check the "First Decade" registry path - if(NOT RTS_INSTALL_PREFIX_GENERALS OR "${RTS_INSTALL_PREFIX_GENERALS}" STREQUAL "/registry") - get_filename_component(RTS_INSTALL_PREFIX_GENERALS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Electronic Arts\\EA Games\\Command and Conquer The First Decade;gr_folder]" ABSOLUTE CACHE) - endif() + fetch_registry_value( + "HKEY_LOCAL_MACHINE/SOFTWARE/Electronic Arts/EA Games/Command and Conquer The First Decade" + "gr_folder" + RTS_INSTALL_PREFIX_GENERALS + "Generals install path from registry") # Check the Steam registry path - if(NOT RTS_INSTALL_PREFIX_GENERALS OR "${RTS_INSTALL_PREFIX_GENERALS}" STREQUAL "/registry") - get_filename_component(RTS_INSTALL_PREFIX_GENERALS "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Electronic Arts\\EA Games\\Generals;installPath]" ABSOLUTE CACHE) - endif() + fetch_registry_value( + "HKEY_LOCAL_MACHINE/SOFTWARE/Electronic Arts/EA Games/Generals" + "installPath" + RTS_INSTALL_PREFIX_GENERALS + "Generals install path from registry") endif() -if(RTS_INSTALL_PREFIX_GENERALS AND NOT "${RTS_INSTALL_PREFIX_GENERALS}" STREQUAL "/registry") +if(RTS_INSTALL_PREFIX_GENERALS) install(TARGETS g_generals RUNTIME DESTINATION "${RTS_INSTALL_PREFIX_GENERALS}") install(FILES $ DESTINATION "${RTS_INSTALL_PREFIX_GENERALS}" OPTIONAL) @@ -69,4 +77,8 @@ if(RTS_INSTALL_PREFIX_GENERALS AND NOT "${RTS_INSTALL_PREFIX_GENERALS}" STREQUAL install(TARGETS g_w3dview RUNTIME DESTINATION "${RTS_INSTALL_PREFIX_GENERALS}") install(FILES $ DESTINATION "${RTS_INSTALL_PREFIX_GENERALS}" OPTIONAL) endif() +else() + message(STATUS "Generals install path not found. Registry keys for 'Generals' not found. " + "Generals targets will be built, but not installed. " + "You can specify the path manually by setting RTS_INSTALL_PREFIX_GENERALS.") endif() diff --git a/Generals/Code/GameEngine/CMakeLists.txt b/Generals/Code/GameEngine/CMakeLists.txt index 64236aa60d..9553884b67 100644 --- a/Generals/Code/GameEngine/CMakeLists.txt +++ b/Generals/Code/GameEngine/CMakeLists.txt @@ -62,7 +62,7 @@ set(GAMEENGINE_SRC Include/Common/List.h # Include/Common/LocalFile.h # Include/Common/LocalFileSystem.h - Include/Common/MapObject.h +# Include/Common/MapObject.h Include/Common/MapReaderWriterInfo.h Include/Common/MessageStream.h Include/Common/MiniLog.h @@ -74,7 +74,7 @@ set(GAMEENGINE_SRC Include/Common/Money.h Include/Common/MultiplayerSettings.h Include/Common/NameKeyGenerator.h - Include/Common/ObjectStatusTypes.h +# Include/Common/ObjectStatusTypes.h Include/Common/OSDisplay.h Include/Common/Overridable.h Include/Common/Override.h @@ -87,7 +87,7 @@ set(GAMEENGINE_SRC Include/Common/ProductionPrerequisite.h Include/Common/QuickmatchPreferences.h Include/Common/QuotedPrintable.h - Include/Common/Radar.h +# Include/Common/Radar.h # Include/Common/RAMFile.h # Include/Common/RandomValue.h Include/Common/Recorder.h @@ -192,7 +192,7 @@ set(GAMEENGINE_SRC Include/GameClient/Line2D.h Include/GameClient/LoadScreen.h Include/GameClient/LookAtXlat.h - Include/GameClient/MapUtil.h +# Include/GameClient/MapUtil.h Include/GameClient/MessageBox.h Include/GameClient/MetaEvent.h Include/GameClient/Module/AnimatedParticleSysBoneClientUpdate.h @@ -211,11 +211,11 @@ set(GAMEENGINE_SRC Include/GameClient/ShellHooks.h Include/GameClient/ShellMenuScheme.h Include/GameClient/Statistics.h - Include/GameClient/TerrainRoads.h - Include/GameClient/TerrainVisual.h +# Include/GameClient/TerrainRoads.h +# Include/GameClient/TerrainVisual.h # Include/GameClient/VideoPlayer.h - Include/GameClient/View.h - Include/GameClient/Water.h +# Include/GameClient/View.h +# Include/GameClient/Water.h Include/GameClient/WindowLayout.h # Include/GameClient/WindowVideoManager.h Include/GameClient/WindowXlat.h @@ -457,60 +457,60 @@ set(GAMEENGINE_SRC Include/GameLogic/WeaponSetFlags.h Include/GameLogic/WeaponSetType.h Include/GameLogic/WeaponStatus.h - Include/GameNetwork/Connection.h - Include/GameNetwork/ConnectionManager.h - Include/GameNetwork/DisconnectManager.h - Include/GameNetwork/DownloadManager.h - Include/GameNetwork/FileTransfer.h - Include/GameNetwork/FirewallHelper.h - Include/GameNetwork/FrameData.h - Include/GameNetwork/FrameDataManager.h - Include/GameNetwork/FrameMetrics.h - Include/GameNetwork/GameInfo.h - Include/GameNetwork/GameMessageParser.h +# Include/GameNetwork/Connection.h +# Include/GameNetwork/ConnectionManager.h +# Include/GameNetwork/DisconnectManager.h +# Include/GameNetwork/DownloadManager.h +# Include/GameNetwork/FileTransfer.h +# Include/GameNetwork/FirewallHelper.h +# Include/GameNetwork/FrameData.h +# Include/GameNetwork/FrameDataManager.h +# Include/GameNetwork/FrameMetrics.h +# Include/GameNetwork/GameInfo.h +# Include/GameNetwork/GameMessageParser.h Include/GameNetwork/GameSpy.h - Include/GameNetwork/GameSpy/BuddyDefs.h - Include/GameNetwork/GameSpy/BuddyThread.h - Include/GameNetwork/GameSpy/GameResultsThread.h - Include/GameNetwork/GameSpy/GSConfig.h - Include/GameNetwork/GameSpy/LadderDefs.h - Include/GameNetwork/GameSpy/LobbyUtils.h - Include/GameNetwork/GameSpy/MainMenuUtils.h - Include/GameNetwork/GameSpy/PeerDefs.h - Include/GameNetwork/GameSpy/PeerDefsImplementation.h - Include/GameNetwork/GameSpy/PeerThread.h - Include/GameNetwork/GameSpy/PersistentStorageDefs.h - Include/GameNetwork/GameSpy/PersistentStorageThread.h - Include/GameNetwork/GameSpy/PingThread.h - Include/GameNetwork/GameSpy/StagingRoomGameInfo.h - Include/GameNetwork/GameSpy/ThreadUtils.h +# Include/GameNetwork/GameSpy/BuddyDefs.h +# Include/GameNetwork/GameSpy/BuddyThread.h +# Include/GameNetwork/GameSpy/GameResultsThread.h +# Include/GameNetwork/GameSpy/GSConfig.h +# Include/GameNetwork/GameSpy/LadderDefs.h +# Include/GameNetwork/GameSpy/LobbyUtils.h +# Include/GameNetwork/GameSpy/MainMenuUtils.h +# Include/GameNetwork/GameSpy/PeerDefs.h +# Include/GameNetwork/GameSpy/PeerDefsImplementation.h +# Include/GameNetwork/GameSpy/PeerThread.h +# Include/GameNetwork/GameSpy/PersistentStorageDefs.h +# Include/GameNetwork/GameSpy/PersistentStorageThread.h +# Include/GameNetwork/GameSpy/PingThread.h +# Include/GameNetwork/GameSpy/StagingRoomGameInfo.h +# Include/GameNetwork/GameSpy/ThreadUtils.h Include/GameNetwork/GameSpyChat.h Include/GameNetwork/GameSpyGameInfo.h Include/GameNetwork/GameSpyGP.h - Include/GameNetwork/GameSpyOverlay.h +# Include/GameNetwork/GameSpyOverlay.h Include/GameNetwork/GameSpyPersistentStorage.h - Include/GameNetwork/GameSpyThread.h +# Include/GameNetwork/GameSpyThread.h Include/GameNetwork/GUIUtil.h - Include/GameNetwork/IPEnumeration.h - Include/GameNetwork/LANAPI.h - Include/GameNetwork/LANAPICallbacks.h - Include/GameNetwork/LANGameInfo.h - Include/GameNetwork/LANPlayer.h - Include/GameNetwork/NAT.h - Include/GameNetwork/NetCommandList.h - Include/GameNetwork/NetCommandMsg.h - Include/GameNetwork/NetCommandRef.h - Include/GameNetwork/NetCommandWrapperList.h - Include/GameNetwork/NetPacket.h - Include/GameNetwork/NetworkDefs.h - Include/GameNetwork/NetworkInterface.h - Include/GameNetwork/networkutil.h - Include/GameNetwork/RankPointValue.h - Include/GameNetwork/Transport.h - Include/GameNetwork/udp.h - Include/GameNetwork/User.h - Include/GameNetwork/WOLBrowser/FEBDispatch.h - Include/GameNetwork/WOLBrowser/WebBrowser.h +# Include/GameNetwork/IPEnumeration.h +# Include/GameNetwork/LANAPI.h +# Include/GameNetwork/LANAPICallbacks.h +# Include/GameNetwork/LANGameInfo.h +# Include/GameNetwork/LANPlayer.h +# Include/GameNetwork/NAT.h +# Include/GameNetwork/NetCommandList.h +# Include/GameNetwork/NetCommandMsg.h +# Include/GameNetwork/NetCommandRef.h +# Include/GameNetwork/NetCommandWrapperList.h +# Include/GameNetwork/NetPacket.h +# Include/GameNetwork/NetworkDefs.h +# Include/GameNetwork/NetworkInterface.h +# Include/GameNetwork/networkutil.h +# Include/GameNetwork/RankPointValue.h +# Include/GameNetwork/Transport.h +# Include/GameNetwork/udp.h +# Include/GameNetwork/User.h +# Include/GameNetwork/WOLBrowser/FEBDispatch.h +# Include/GameNetwork/WOLBrowser/WebBrowser.h Include/Precompiled/PreRTS.h # Source/Common/Audio/AudioEventRTS.cpp # Source/Common/Audio/AudioRequest.cpp @@ -610,9 +610,9 @@ set(GAMEENGINE_SRC # Source/Common/System/LocalFile.cpp # Source/Common/System/LocalFileSystem.cpp #Source/Common/System/MemoryInit.cpp - Source/Common/System/ObjectStatusTypes.cpp +# Source/Common/System/ObjectStatusTypes.cpp Source/Common/System/QuotedPrintable.cpp - Source/Common/System/Radar.cpp +# Source/Common/System/Radar.cpp # Source/Common/System/RAMFile.cpp Source/Common/System/registry.cpp Source/Common/System/SaveGame/GameState.cpp @@ -753,7 +753,7 @@ set(GAMEENGINE_SRC Source/GameClient/Input/Mouse.cpp Source/GameClient/LanguageFilter.cpp Source/GameClient/Line2D.cpp - Source/GameClient/MapUtil.cpp +# Source/GameClient/MapUtil.cpp Source/GameClient/MessageStream/CommandXlat.cpp Source/GameClient/MessageStream/GUICommandTranslator.cpp Source/GameClient/MessageStream/HintSpy.cpp @@ -773,11 +773,11 @@ set(GAMEENGINE_SRC Source/GameClient/System/Image.cpp Source/GameClient/System/ParticleSys.cpp Source/GameClient/System/RayEffect.cpp - Source/GameClient/Terrain/TerrainRoads.cpp - Source/GameClient/Terrain/TerrainVisual.cpp +# Source/GameClient/Terrain/TerrainRoads.cpp +# Source/GameClient/Terrain/TerrainVisual.cpp # Source/GameClient/VideoPlayer.cpp - Source/GameClient/View.cpp - Source/GameClient/Water.cpp +# Source/GameClient/View.cpp +# Source/GameClient/Water.cpp Source/GameLogic/AI/AI.cpp Source/GameLogic/AI/AIDock.cpp Source/GameLogic/AI/AIGroup.cpp @@ -1005,55 +1005,55 @@ set(GAMEENGINE_SRC Source/GameLogic/System/GameLogic.cpp Source/GameLogic/System/GameLogicDispatch.cpp Source/GameLogic/System/RankInfo.cpp - Source/GameNetwork/Connection.cpp - Source/GameNetwork/ConnectionManager.cpp - Source/GameNetwork/DisconnectManager.cpp - Source/GameNetwork/DownloadManager.cpp - Source/GameNetwork/FileTransfer.cpp - Source/GameNetwork/FirewallHelper.cpp - Source/GameNetwork/FrameData.cpp - Source/GameNetwork/FrameDataManager.cpp - Source/GameNetwork/FrameMetrics.cpp - Source/GameNetwork/GameInfo.cpp - Source/GameNetwork/GameMessageParser.cpp +# Source/GameNetwork/Connection.cpp +# Source/GameNetwork/ConnectionManager.cpp +# Source/GameNetwork/DisconnectManager.cpp +# Source/GameNetwork/DownloadManager.cpp +# Source/GameNetwork/FileTransfer.cpp +# Source/GameNetwork/FirewallHelper.cpp +# Source/GameNetwork/FrameData.cpp +# Source/GameNetwork/FrameDataManager.cpp +# Source/GameNetwork/FrameMetrics.cpp +# Source/GameNetwork/GameInfo.cpp +# Source/GameNetwork/GameMessageParser.cpp #Source/GameNetwork/GameSpy.cpp #Source/GameNetwork/GameSpyChat.cpp #Source/GameNetwork/GameSpyGameInfo.cpp #Source/GameNetwork/GameSpyGP.cpp #Source/GameNetwork/GameSpyPersistentStorage.cpp - Source/GameNetwork/GameSpy/Chat.cpp - Source/GameNetwork/GameSpy/GSConfig.cpp - Source/GameNetwork/GameSpy/LadderDefs.cpp - Source/GameNetwork/GameSpy/LobbyUtils.cpp - Source/GameNetwork/GameSpy/MainMenuUtils.cpp - Source/GameNetwork/GameSpy/PeerDefs.cpp - Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp - Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp - Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp - Source/GameNetwork/GameSpy/Thread/PeerThread.cpp - Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp - Source/GameNetwork/GameSpy/Thread/PingThread.cpp - Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp - Source/GameNetwork/GameSpyOverlay.cpp +# Source/GameNetwork/GameSpy/Chat.cpp +# Source/GameNetwork/GameSpy/GSConfig.cpp +# Source/GameNetwork/GameSpy/LadderDefs.cpp +# Source/GameNetwork/GameSpy/LobbyUtils.cpp +# Source/GameNetwork/GameSpy/MainMenuUtils.cpp +# Source/GameNetwork/GameSpy/PeerDefs.cpp +# Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp +# Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp +# Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp +# Source/GameNetwork/GameSpy/Thread/PeerThread.cpp +# Source/GameNetwork/GameSpy/Thread/PersistentStorageThread.cpp +# Source/GameNetwork/GameSpy/Thread/PingThread.cpp +# Source/GameNetwork/GameSpy/Thread/ThreadUtils.cpp +# Source/GameNetwork/GameSpyOverlay.cpp Source/GameNetwork/GUIUtil.cpp - Source/GameNetwork/IPEnumeration.cpp - Source/GameNetwork/LANAPI.cpp - Source/GameNetwork/LANAPICallbacks.cpp - Source/GameNetwork/LANAPIhandlers.cpp - Source/GameNetwork/LANGameInfo.cpp - Source/GameNetwork/NAT.cpp - Source/GameNetwork/NetCommandList.cpp - Source/GameNetwork/NetCommandMsg.cpp - Source/GameNetwork/NetCommandRef.cpp - Source/GameNetwork/NetCommandWrapperList.cpp - Source/GameNetwork/NetMessageStream.cpp - Source/GameNetwork/NetPacket.cpp - Source/GameNetwork/Network.cpp - Source/GameNetwork/NetworkUtil.cpp - Source/GameNetwork/Transport.cpp - Source/GameNetwork/udp.cpp - Source/GameNetwork/User.cpp - Source/GameNetwork/WOLBrowser/WebBrowser.cpp +# Source/GameNetwork/IPEnumeration.cpp +# Source/GameNetwork/LANAPI.cpp +# Source/GameNetwork/LANAPICallbacks.cpp +# Source/GameNetwork/LANAPIhandlers.cpp +# Source/GameNetwork/LANGameInfo.cpp +# Source/GameNetwork/NAT.cpp +# Source/GameNetwork/NetCommandList.cpp +# Source/GameNetwork/NetCommandMsg.cpp +# Source/GameNetwork/NetCommandRef.cpp +# Source/GameNetwork/NetCommandWrapperList.cpp +# Source/GameNetwork/NetMessageStream.cpp +# Source/GameNetwork/NetPacket.cpp +# Source/GameNetwork/Network.cpp +# Source/GameNetwork/NetworkUtil.cpp +# Source/GameNetwork/Transport.cpp +# Source/GameNetwork/udp.cpp +# Source/GameNetwork/User.cpp +# Source/GameNetwork/WOLBrowser/WebBrowser.cpp Source/Precompiled/PreRTS.cpp ) diff --git a/Generals/Code/GameEngine/Include/Common/ActionManager.h b/Generals/Code/GameEngine/Include/Common/ActionManager.h index 2a66e6dfec..54e982788e 100644 --- a/Generals/Code/GameEngine/Include/Common/ActionManager.h +++ b/Generals/Code/GameEngine/Include/Common/ActionManager.h @@ -34,9 +34,6 @@ #pragma once -#ifndef __ACTIONMANAGER_H_ -#define __ACTIONMANAGER_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Common/SubsystemInterface.h" @@ -110,5 +107,3 @@ class ActionManager : public SubsystemInterface // EXTERNALS ////////////////////////////////////////////////////////////////////////////////////// extern ActionManager *TheActionManager; - -#endif // end __ACTIONMANAGER_H_ diff --git a/Generals/Code/GameEngine/Include/Common/BattleHonors.h b/Generals/Code/GameEngine/Include/Common/BattleHonors.h index a7c94c9816..96ed04409f 100644 --- a/Generals/Code/GameEngine/Include/Common/BattleHonors.h +++ b/Generals/Code/GameEngine/Include/Common/BattleHonors.h @@ -45,9 +45,6 @@ #pragma once -#ifndef __BATTLE_HONORS_H_ -#define __BATTLE_HONORS_H_ - //----------------------------------------------------------------------------- // SYSTEM INCLUDES //////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -123,5 +120,3 @@ enum //----------------------------------------------------------------------------- // EXTERNALS ////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- - -#endif // __BATTLE_HONORS_H_ diff --git a/Generals/Code/GameEngine/Include/Common/BezierSegment.h b/Generals/Code/GameEngine/Include/Common/BezierSegment.h index e859d1460f..b16df7d8ce 100644 --- a/Generals/Code/GameEngine/Include/Common/BezierSegment.h +++ b/Generals/Code/GameEngine/Include/Common/BezierSegment.h @@ -28,8 +28,6 @@ // DO NOT DISTRIBUTE #pragma once -#ifndef __BEZIERSEGMENT_H__ -#define __BEZIERSEGMENT_H__ #include #include "Common/STLTypedefs.h" @@ -69,5 +67,3 @@ class BezierSegment public: // He get's friendly access. friend class BezFwdIterator; }; - -#endif /* __BEZIERSEGMENT_H__ */ diff --git a/Generals/Code/GameEngine/Include/Common/BitFlags.h b/Generals/Code/GameEngine/Include/Common/BitFlags.h index 33f7f792a2..2616939a11 100644 --- a/Generals/Code/GameEngine/Include/Common/BitFlags.h +++ b/Generals/Code/GameEngine/Include/Common/BitFlags.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __BitFlags_H_ -#define __BitFlags_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Common/STLTypedefs.h" @@ -53,9 +50,10 @@ class BitFlags { private: std::bitset m_bits; - static const char* s_bitNameList[]; public: + CPP_11(static constexpr size_t NumBits = NUMBITS); + static const char* const s_bitNameList[]; /* just a little syntactic sugar so that there is no "foo = 0" compatible constructor @@ -65,29 +63,29 @@ class BitFlags kInit = 0 }; - inline BitFlags() + BitFlags() { } - inline BitFlags(BogusInitType k, Int idx1) + BitFlags(BogusInitType k, Int idx1) { m_bits.set(idx1); } - inline BitFlags(BogusInitType k, Int idx1, Int idx2) + BitFlags(BogusInitType k, Int idx1, Int idx2) { m_bits.set(idx1); m_bits.set(idx2); } - inline BitFlags(BogusInitType k, Int idx1, Int idx2, Int idx3) + BitFlags(BogusInitType k, Int idx1, Int idx2, Int idx3) { m_bits.set(idx1); m_bits.set(idx2); m_bits.set(idx3); } - inline BitFlags(BogusInitType k, Int idx1, Int idx2, Int idx3, Int idx4) + BitFlags(BogusInitType k, Int idx1, Int idx2, Int idx3, Int idx4) { m_bits.set(idx1); m_bits.set(idx2); @@ -95,7 +93,7 @@ class BitFlags m_bits.set(idx4); } - inline BitFlags(BogusInitType k, Int idx1, Int idx2, Int idx3, Int idx4, Int idx5) + BitFlags(BogusInitType k, Int idx1, Int idx2, Int idx3, Int idx4, Int idx5) { m_bits.set(idx1); m_bits.set(idx2); @@ -104,7 +102,7 @@ class BitFlags m_bits.set(idx5); } - inline BitFlags(BogusInitType k, + BitFlags(BogusInitType k, Int idx1, Int idx2, Int idx3, @@ -133,28 +131,28 @@ class BitFlags m_bits.set(idx12); } - inline Bool operator==(const BitFlags& that) const + Bool operator==(const BitFlags& that) const { return this->m_bits == that.m_bits; } - inline Bool operator!=(const BitFlags& that) const + Bool operator!=(const BitFlags& that) const { return this->m_bits != that.m_bits; } - inline void set(Int i, Int val = 1) + void set(Int i, Int val = 1) { m_bits.set(i, val); } - inline Bool test(Int i) const + Bool test(Int i) const { return m_bits.test(i); } //Tests for any bits that are set in both. - inline Bool testForAny( const BitFlags& that ) const + Bool testForAny( const BitFlags& that ) const { BitFlags tmp = *this; tmp.m_bits &= that.m_bits; @@ -162,7 +160,7 @@ class BitFlags } //All argument bits must be set in our bits too in order to return TRUE - inline Bool testForAll( const BitFlags& that ) const + Bool testForAll( const BitFlags& that ) const { DEBUG_ASSERTCRASH( that.any(), ("BitFlags::testForAll is always true if you ask about zero flags. Did you mean that?") ); @@ -173,46 +171,46 @@ class BitFlags } //None of the argument bits must be set in our bits in order to return TRUE - inline Bool testForNone( const BitFlags& that ) const + Bool testForNone( const BitFlags& that ) const { BitFlags tmp = *this; tmp.m_bits &= that.m_bits; return !tmp.m_bits.any(); } - inline Int size() const + Int size() const { return m_bits.size(); } - inline Int count() const + Int count() const { return m_bits.count(); } - inline Bool any() const + Bool any() const { return m_bits.any(); } - inline void flip() + void flip() { m_bits.flip(); } - inline void clear() + void clear() { m_bits.reset(); } - inline Int countIntersection(const BitFlags& that) const + Int countIntersection(const BitFlags& that) const { BitFlags tmp = *this; tmp.m_bits &= that.m_bits; return tmp.m_bits.count(); } - inline Int countInverseIntersection(const BitFlags& that) const + Int countInverseIntersection(const BitFlags& that) const { BitFlags tmp = *this; tmp.m_bits.flip(); @@ -220,7 +218,7 @@ class BitFlags return tmp.m_bits.count(); } - inline Bool anyIntersectionWith(const BitFlags& that) const + Bool anyIntersectionWith(const BitFlags& that) const { /// @todo srj -- improve me. BitFlags tmp = that; @@ -228,23 +226,23 @@ class BitFlags return tmp.m_bits.any(); } - inline void clear(const BitFlags& clr) + void clear(const BitFlags& clr) { m_bits &= ~clr.m_bits; } - inline void set(const BitFlags& set) + void set(const BitFlags& set) { m_bits |= set.m_bits; } - inline void clearAndSet(const BitFlags& clr, const BitFlags& set) + void clearAndSet(const BitFlags& clr, const BitFlags& set) { m_bits &= ~clr.m_bits; m_bits |= set.m_bits; } - inline Bool testSetAndClear(const BitFlags& mustBeSet, const BitFlags& mustBeClear) const + Bool testSetAndClear(const BitFlags& mustBeSet, const BitFlags& mustBeClear) const { /// @todo srj -- improve me. BitFlags tmp = *this; @@ -261,7 +259,7 @@ class BitFlags return true; } - static const char** getBitNames() + static const char* const* getBitNames() { return s_bitNameList; } @@ -274,7 +272,7 @@ class BitFlags static Int getSingleBitFromName(const char* token) { Int i = 0; - for(const char** name = s_bitNameList; *name; ++name, ++i ) + for(const char* const* name = s_bitNameList; *name; ++name, ++i ) { if( stricmp( *name, token ) == 0 ) { @@ -328,6 +326,3 @@ class BitFlags }; - -#endif // __BitFlags_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/BitFlagsIO.h b/Generals/Code/GameEngine/Include/Common/BitFlagsIO.h index f372afb7fd..197c79f31f 100644 --- a/Generals/Code/GameEngine/Include/Common/BitFlagsIO.h +++ b/Generals/Code/GameEngine/Include/Common/BitFlagsIO.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __BitFlagsIO_H_ -#define __BitFlagsIO_H_ - #include "Common/BitFlags.h" #include "Common/INI.h" #include "Common/Xfer.h" @@ -182,9 +179,9 @@ void BitFlags::xfer(Xfer* xfer) AsciiString bitNameA = bitName; xfer->xferAsciiString( &bitNameA ); - } // end for i + } - } // end if, save + } else if( xfer->getXferMode() == XFER_LOAD ) { // clear the kind of mask data @@ -210,24 +207,26 @@ void BitFlags::xfer(Xfer* xfer) throw XFER_READ_ERROR; } - } // end for, i + } - } // end else if, load + } else if( xfer->getXferMode() == XFER_CRC ) { // just call the xfer implementation on the data values +#if RETAIL_COMPATIBLE_CRC xfer->xferUser( this, sizeof( this ) ); +#else + xfer->xferUser( this, sizeof( *this ) ); +#endif - } // end else if, crc + } else { DEBUG_CRASH(( "BitFlagsXfer - Unknown xfer mode '%d'", xfer->getXferMode() )); throw XFER_MODE_UNKNOWN; - } // end else - -} // end xfer + } -#endif +} diff --git a/Generals/Code/GameEngine/Include/Common/BorderColors.h b/Generals/Code/GameEngine/Include/Common/BorderColors.h index e88316df7e..d9395537cc 100644 --- a/Generals/Code/GameEngine/Include/Common/BorderColors.h +++ b/Generals/Code/GameEngine/Include/Common/BorderColors.h @@ -18,6 +18,7 @@ // jkmcd + #pragma once struct BorderColor diff --git a/Generals/Code/GameEngine/Include/Common/BuildAssistant.h b/Generals/Code/GameEngine/Include/Common/BuildAssistant.h index 62c6d6b740..84a2d20678 100644 --- a/Generals/Code/GameEngine/Include/Common/BuildAssistant.h +++ b/Generals/Code/GameEngine/Include/Common/BuildAssistant.h @@ -30,9 +30,6 @@ #pragma once -#ifndef __BUILDASSISTANT_H_ -#define __BUILDASSISTANT_H_ - // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// #include "Common/STLTypedefs.h" #include "Lib/BaseType.h" @@ -174,7 +171,7 @@ class BuildAssistant : public SubsystemInterface Object *builderObject ); /// return the "scratch pad" array that can be used to create a line of build locations - virtual inline Coord3D *getBuildLocations( void ) { return m_buildPositions; } + virtual Coord3D *getBuildLocations( void ) { return m_buildPositions; } /// is the template a line build object, like a wall virtual Bool isLineBuildTemplate( const ThingTemplate *tTemplate ); @@ -208,10 +205,7 @@ class BuildAssistant : public SubsystemInterface Int m_buildPositionSize; ///< number of elements in the build position array ObjectSellList m_sellList; ///< list of objects currently going through the "sell process" -}; // end BuildAssistant +}; // EXTERN ///////////////////////////////////////////////////////////////////////////////////////// extern BuildAssistant *TheBuildAssistant; - -#endif // __BUILDASSISTANT_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/CDManager.h b/Generals/Code/GameEngine/Include/Common/CDManager.h index df0b031115..2b5a60b157 100644 --- a/Generals/Code/GameEngine/Include/Common/CDManager.h +++ b/Generals/Code/GameEngine/Include/Common/CDManager.h @@ -43,10 +43,6 @@ #pragma once -#ifndef _COMMON_CDMANAGER_H_ -#define _COMMON_CDMANAGER_H_ - - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- @@ -187,5 +183,3 @@ class CDManager : public CDManagerInterface extern CDManagerInterface *TheCDManager; CDManagerInterface* CreateCDManager( void ); - -#endif // _COMMON_CDMANAGER_H_ diff --git a/Generals/Code/GameEngine/Include/Common/ClientUpdateModule.h b/Generals/Code/GameEngine/Include/Common/ClientUpdateModule.h index 04f6c510dc..c90e0adffa 100644 --- a/Generals/Code/GameEngine/Include/Common/ClientUpdateModule.h +++ b/Generals/Code/GameEngine/Include/Common/ClientUpdateModule.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __ClientUpdateModule_H_ -#define __ClientUpdateModule_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include @@ -63,7 +60,3 @@ class ClientUpdateModule : public DrawableModule inline ClientUpdateModule::ClientUpdateModule( Thing *thing, const ModuleData* moduleData ) : DrawableModule( thing, moduleData ) { } inline ClientUpdateModule::~ClientUpdateModule() { } //------------------------------------------------------------------------------------------------- - - -#endif // __ClientUpdateModule_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/CommandLine.h b/Generals/Code/GameEngine/Include/Common/CommandLine.h index fe458850ba..48e078dc3d 100644 --- a/Generals/Code/GameEngine/Include/Common/CommandLine.h +++ b/Generals/Code/GameEngine/Include/Common/CommandLine.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _COMMAND_LINE_H_ -#define _COMMAND_LINE_H_ - class CommandLine { public: @@ -38,5 +35,3 @@ class CommandLine static void parseCommandLineForStartup(); static void parseCommandLineForEngineInit(); }; - -#endif // _COMMAND_LINE_H_ diff --git a/Generals/Code/GameEngine/Include/Common/CriticalSection.h b/Generals/Code/GameEngine/Include/Common/CriticalSection.h index a20081eb3d..b44a88f2ff 100644 --- a/Generals/Code/GameEngine/Include/Common/CriticalSection.h +++ b/Generals/Code/GameEngine/Include/Common/CriticalSection.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __CRITICALSECTION_H__ -#define __CRITICALSECTION_H__ - #include "Common/PerfTimer.h" #ifdef PERF_TIMERS @@ -102,5 +99,3 @@ extern CriticalSection *TheUnicodeStringCriticalSection; extern CriticalSection *TheDmaCriticalSection; extern CriticalSection *TheMemoryPoolCriticalSection; extern CriticalSection *TheDebugLogCriticalSection; - -#endif /* __CRITICALSECTION_H__ */ diff --git a/Generals/Code/GameEngine/Include/Common/CustomMatchPreferences.h b/Generals/Code/GameEngine/Include/Common/CustomMatchPreferences.h index abf7971cc2..cc384c60a0 100644 --- a/Generals/Code/GameEngine/Include/Common/CustomMatchPreferences.h +++ b/Generals/Code/GameEngine/Include/Common/CustomMatchPreferences.h @@ -30,9 +30,6 @@ #pragma once -#ifndef __CUSTOMMATCHPREFERENCES_H__ -#define __CUSTOMMATCHPREFERENCES_H__ - //----------------------------------------------------------------------------- // USER INCLUDES ////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -78,6 +75,15 @@ class CustomMatchPreferences : public UserPreferences Bool getDisallowNonAsianText( void ); void setDisallowNonAsianText( Bool val ); -}; + Bool getSuperweaponRestricted(void) const; + void setSuperweaponRestricted( Bool superweaponRestricted); + + Money getStartingCash(void) const; + void setStartingCash( const Money &startingCash ); -#endif // __CUSTOMMATCHPREFERENCES_H__ + Bool getFactionsLimited(void) const; // Prefers to only use the original 3 sides, not USA Air Force General, GLA Toxin General, et al + void setFactionsLimited( Bool factionsLimited ); + + Bool getUseStats( void ) const; + void setUseStats( Bool useStats ); +}; diff --git a/Generals/Code/GameEngine/Include/Common/DamageFX.h b/Generals/Code/GameEngine/Include/Common/DamageFX.h index 586c78569b..710a76e55c 100644 --- a/Generals/Code/GameEngine/Include/Common/DamageFX.h +++ b/Generals/Code/GameEngine/Include/Common/DamageFX.h @@ -29,9 +29,6 @@ #pragma once -#ifndef _DamageFX_H_ -#define _DamageFX_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Common/GameCommon.h" #include "Common/NameKeyGenerator.h" @@ -150,7 +147,9 @@ class DamageFXStore : public SubsystemInterface /** Find the DamageFX with the given name. If no such DamageFX exists, return null. */ - const DamageFX *findDamageFX( AsciiString name ) const; + const DamageFX *findDamageFX( NameKeyType namekey ) const; + const DamageFX *findDamageFX( const AsciiString& name ) const; + const DamageFX *findDamageFX( const char* name ) const; static void parseDamageFXDefinition(INI* ini); @@ -164,6 +163,3 @@ class DamageFXStore : public SubsystemInterface // EXTERNALS ////////////////////////////////////////////////////////////////////////////////////// extern DamageFXStore *TheDamageFXStore; - -#endif // _DamageFX_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/DataChunk.h b/Generals/Code/GameEngine/Include/Common/DataChunk.h index 8a045d4e50..9c0e747d9c 100644 --- a/Generals/Code/GameEngine/Include/Common/DataChunk.h +++ b/Generals/Code/GameEngine/Include/Common/DataChunk.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _DATA_CHUNK_H_ -#define _DATA_CHUNK_H_ - #include "Common/GameMemory.h" #include "Common/Dict.h" #include "Common/MapReaderWriterInfo.h" @@ -232,7 +229,3 @@ class DataChunkInput NameKeyType readNameKey(void); }; - - - -#endif // _DATA_CHUNK_H_ diff --git a/Generals/Code/GameEngine/Include/Common/Dict.h b/Generals/Code/GameEngine/Include/Common/Dict.h index 8fed08c913..424fa3ae6b 100644 --- a/Generals/Code/GameEngine/Include/Common/Dict.h +++ b/Generals/Code/GameEngine/Include/Common/Dict.h @@ -45,9 +45,6 @@ #pragma once -#ifndef Dict_H -#define Dict_H - #include "Common/Errors.h" #include "Common/NameKeyGenerator.h" @@ -128,7 +125,7 @@ class Dict /** Return there is a pair with the given key and datatype, return true. */ - inline Bool known(NameKeyType key, DataType d) const + Bool known(NameKeyType key, DataType d) const { return getType(key) == d; } @@ -281,17 +278,17 @@ class Dict DictPairKeyType m_key; void* m_value; - inline static DictPairKeyType createKey(NameKeyType keyVal, DataType nt) + static DictPairKeyType createKey(NameKeyType keyVal, DataType nt) { return (DictPairKeyType)((((UnsignedInt)(keyVal)) << 8) | ((UnsignedInt)nt)); } - inline static DataType getTypeFromKey(DictPairKeyType nk) + static DataType getTypeFromKey(DictPairKeyType nk) { return (DataType)(((UnsignedInt)nk) & 0xff); } - inline static NameKeyType getNameFromKey(DictPairKeyType nk) + static NameKeyType getNameFromKey(DictPairKeyType nk) { return (NameKeyType)(((UnsignedInt)nk) >> 8); } @@ -301,13 +298,13 @@ class Dict void clear(); void copyFrom(DictPair* that); void setNameAndType(NameKeyType key, DataType type); - inline DataType getType() const { return getTypeFromKey(m_key); } - inline NameKeyType getName() const { return getNameFromKey(m_key); } - inline Bool* asBool() { return (Bool*)&m_value; } - inline Int* asInt() { return (Int*)&m_value; } - inline Real* asReal() { return (Real*)&m_value; } - inline AsciiString* asAsciiString() { return (AsciiString*)&m_value; } - inline UnicodeString* asUnicodeString() { return (UnicodeString*)&m_value; } + DataType getType() const { return getTypeFromKey(m_key); } + NameKeyType getName() const { return getNameFromKey(m_key); } + Bool* asBool() { return (Bool*)&m_value; } + Int* asInt() { return (Int*)&m_value; } + Real* asReal() { return (Real*)&m_value; } + AsciiString* asAsciiString() { return (AsciiString*)&m_value; } + UnicodeString* asUnicodeString() { return (UnicodeString*)&m_value; } }; struct DictPairData @@ -317,13 +314,13 @@ class Dict unsigned short m_numPairsUsed; // length of data allocated //DictPair m_pairs[]; - inline DictPair* peek() { return (DictPair*)(this+1); } + DictPair* peek() { return (DictPair*)(this+1); } }; #ifdef RTS_DEBUG void validate() const; #else - inline void validate() const { } + void validate() const { } #endif }; @@ -362,7 +359,3 @@ inline Dict::DataType Dict::getNthType(Int n) const return DICT_NONE; return m_data->peek()[n].getType(); } - -#endif // Dict_H - - diff --git a/Generals/Code/GameEngine/Include/Common/Directory.h b/Generals/Code/GameEngine/Include/Common/Directory.h index 744334b06e..7d1f0adf7e 100644 --- a/Generals/Code/GameEngine/Include/Common/Directory.h +++ b/Generals/Code/GameEngine/Include/Common/Directory.h @@ -27,10 +27,8 @@ // Desc: Directory info class /////////////////////////////////////////////////////////////////////////////////////////////////// #if (0) -#pragma once -#ifndef __DIRECTORY_H__ -#define __DIRECTORY_H__ +#pragma once // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Common/AsciiString.h" @@ -90,6 +88,4 @@ class Directory //------------------------------------------------------------------------------------------------- -#endif // __DIRECTORY_H__ - #endif diff --git a/Generals/Code/GameEngine/Include/Common/DisabledTypes.h b/Generals/Code/GameEngine/Include/Common/DisabledTypes.h index 526b609809..31fd14a0b7 100644 --- a/Generals/Code/GameEngine/Include/Common/DisabledTypes.h +++ b/Generals/Code/GameEngine/Include/Common/DisabledTypes.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __DISABLED_TYPES_H_ -#define __DISABLED_TYPES_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Lib/BaseType.h" #include "Common/BitFlags.h" @@ -109,6 +106,3 @@ extern const char *TheDisabledNames[]; extern DisabledMaskType DISABLEDMASK_NONE; // inits to all zeroes extern DisabledMaskType DISABLEDMASK_ALL; // inits to all bits set. void initDisabledMasks(); - -#endif // __DISABLED_TYPES_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/DiscreteCircle.h b/Generals/Code/GameEngine/Include/Common/DiscreteCircle.h index d9f17898bf..1ec8fcd5ab 100644 --- a/Generals/Code/GameEngine/Include/Common/DiscreteCircle.h +++ b/Generals/Code/GameEngine/Include/Common/DiscreteCircle.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __DISCRETECIRCLE_H__ -#define __DISCRETECIRCLE_H__ - //------------------------------------------------------------------------------------------------- /** One horizontal line of the circle we are going to generate, the points drawn should be from @@ -74,6 +71,3 @@ class DiscreteCircle void generateEdgePairs(Int xCenter, Int yCenter, Int radius); void removeDuplicates(); }; - -#endif /* __DISCRETECIRCLE_H__ */ - diff --git a/Generals/Code/GameEngine/Include/Common/DrawModule.h b/Generals/Code/GameEngine/Include/Common/DrawModule.h index 4da0325bff..e13310fa18 100644 --- a/Generals/Code/GameEngine/Include/Common/DrawModule.h +++ b/Generals/Code/GameEngine/Include/Common/DrawModule.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __DRAWMODULE_H_ -#define __DRAWMODULE_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Common/GameType.h" #include "Common/Module.h" @@ -41,6 +38,7 @@ // FORWARD REFERENCES ///////////////////////////////////////////////////////////////////////////// class Matrix3D; class RenderCost; +class OBBoxClass; // TYPES ////////////////////////////////////////////////////////////////////////////////////////// @@ -157,6 +155,10 @@ class ObjectDrawInterface // this method must ONLY be called from the client, NEVER From the logic, not even indirectly. virtual Bool clientOnly_getRenderObjInfo(Coord3D* pos, Real* boundingSphereRadius, Matrix3D* transform) const = 0; + + // (gth) C&C3 adding these accessors to render object properties + virtual Bool clientOnly_getRenderObjBoundBox(OBBoxClass * boundbox) const = 0; + virtual Bool clientOnly_getRenderObjBoneTransform(const AsciiString & boneName,Matrix3D * set_tm) const = 0; /** Find the bone(s) with the given name and return their positions and/or transforms in the given arrays. We look for a bone named "boneNamePrefixQQ", where QQ is 01, 02, 03, etc, starting at the @@ -248,7 +250,3 @@ class RenderCost int m_boneCount; int m_shadowDrawCount; }; - - -#endif // __DRAWMODULE_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/Energy.h b/Generals/Code/GameEngine/Include/Common/Energy.h index 70c5b6d64a..ecdda0f2f6 100644 --- a/Generals/Code/GameEngine/Include/Common/Energy.h +++ b/Generals/Code/GameEngine/Include/Common/Energy.h @@ -44,9 +44,6 @@ #pragma once -#ifndef _ENERGY_H_ -#define _ENERGY_H_ - // INLCUDES ///////////////////////////////////////////////////////////////////////////////////// #include "Common/Snapshot.h" @@ -118,6 +115,3 @@ class Energy : public Snapshot Int m_energyConsumption; ///< level of energy consumption, in kw Player *m_owner; ///< Tight pointer to the Player I am intrinsic to. }; - -#endif // _ENERGY_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/Errors.h b/Generals/Code/GameEngine/Include/Common/Errors.h index 380ffa5537..2c2cec27c6 100644 --- a/Generals/Code/GameEngine/Include/Common/Errors.h +++ b/Generals/Code/GameEngine/Include/Common/Errors.h @@ -45,9 +45,6 @@ #pragma once -#ifndef __ERRORS_H_ -#define __ERRORS_H_ - /** An ErrorCode is the repository for failure modes. In almost all situations, these values will be THROWN, not returned as error codes. Feel free @@ -68,5 +65,3 @@ enum ErrorCode CPP_11(: UnsignedInt) ERROR_LAST }; - -#endif // __ERRORS_H_ diff --git a/Generals/Code/GameEngine/Include/Common/FunctionLexicon.h b/Generals/Code/GameEngine/Include/Common/FunctionLexicon.h index 1c20e2653c..bdc82b65de 100644 --- a/Generals/Code/GameEngine/Include/Common/FunctionLexicon.h +++ b/Generals/Code/GameEngine/Include/Common/FunctionLexicon.h @@ -30,9 +30,6 @@ #pragma once -#ifndef __FUNCTIONLEXICON_H_ -#define __FUNCTIONLEXICON_H_ - #include "Common/SubsystemInterface.h" #include "Common/NameKeyGenerator.h" #include "Common/GameMemory.h" @@ -68,7 +65,7 @@ class FunctionLexicon : public SubsystemInterface TABLE_WIN_LAYOUT_UPDATE, TABLE_WIN_LAYOUT_SHUTDOWN, - MAX_FUNCTION_TABLES // keep this last + MAX_FUNCTION_TABLES }; public: @@ -125,7 +122,7 @@ class FunctionLexicon : public SubsystemInterface TableEntry *m_tables[ MAX_FUNCTION_TABLES ]; ///< the lookup tables -}; // end class FunctionLexicon +}; /////////////////////////////////////////////////////////////////////////////////////////////////// // INLINING @@ -149,6 +146,3 @@ inline WindowLayoutShutdownFunc FunctionLexicon::winLayoutShutdownFunc( NameKeyT // EXTERNALS /////////////////////////////////////////////////////////////////////////////////////////////////// extern FunctionLexicon *TheFunctionLexicon; ///< function dictionary external - -#endif // end __FUNCTIONLEXICON_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/GameCommon.h b/Generals/Code/GameEngine/Include/Common/GameCommon.h index 40b3677557..77d9eb99d8 100644 --- a/Generals/Code/GameEngine/Include/Common/GameCommon.h +++ b/Generals/Code/GameEngine/Include/Common/GameCommon.h @@ -47,9 +47,6 @@ #pragma once -#ifndef _GAMECOMMON_H_ -#define _GAMECOMMON_H_ - // ---------------------------------------------------------------------------------------------- #include "Lib/BaseType.h" #include "WWCommon.h" @@ -65,7 +62,8 @@ // ---------------------------------------------------------------------------------------------- enum { - LOGICFRAMES_PER_SECOND = 30, + BaseFps = 30, // The historic base frame rate for this game. This value must never change. + LOGICFRAMES_PER_SECOND = WWSyncPerSecond, MSEC_PER_SECOND = 1000 }; const Real LOGICFRAMES_PER_MSEC_REAL = (((Real)LOGICFRAMES_PER_SECOND) / ((Real)MSEC_PER_SECOND)); @@ -147,8 +145,6 @@ enum CellShroudStatus CPP_11(: Int) CELLSHROUD_CLEAR, CELLSHROUD_FOGGED, CELLSHROUD_SHROUDED, - - CELLSHROUD_COUNT }; //------------------------------------------------------------------------------------------------- @@ -161,8 +157,6 @@ enum ObjectShroudStatus CPP_11(: Int) OBJECTSHROUD_FOGGED, ///< object is completely fogged OBJECTSHROUD_SHROUDED, ///< object is completely shrouded OBJECTSHROUD_INVALID_BUT_PREVIOUS_VALID, ///< indeterminate state, will recompute, BUT previous status is valid, don't reset (used for save/load) - - OBJECTSHROUD_COUNT }; //------------------------------------------------------------------------------------------------- @@ -189,7 +183,7 @@ enum // NOTE NOTE NOTE: Keep TheVeterencyNames in sync with these. enum VeterancyLevel CPP_11(: Int) { - LEVEL_REGULAR = 0, + LEVEL_REGULAR, LEVEL_VETERAN, LEVEL_ELITE, LEVEL_HEROIC, @@ -197,12 +191,12 @@ enum VeterancyLevel CPP_11(: Int) LEVEL_COUNT, LEVEL_INVALID, - LEVEL_FIRST = LEVEL_REGULAR, + LEVEL_FIRST = 0, LEVEL_LAST = LEVEL_HEROIC }; // TheVeterancyNames is defined in GameCommon.cpp -extern const char *TheVeterancyNames[]; +extern const char *const TheVeterancyNames[]; //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -214,7 +208,8 @@ enum CommandSourceType CPP_11(: Int) CMD_FROM_AI, CMD_FROM_DOZER, // Special rare command when the dozer originates a command to attack a mine. Mines are not ai-attackable, and it seems deceitful for the dozer to generate a player or script command. jba. -}; ///< the source of a command + COMMAND_SOURCE_TYPE_COUNT +}; //------------------------------------------------------------------------------------------------- enum AbleToAttackType CPP_11(: Int) @@ -467,6 +462,7 @@ enum WhichTurretType CPP_11(: Int) // ------------------------------------------------------------------------ // this normalizes an angle to the range -PI...PI. +// TheSuperHackers @todo DO NOT USE THIS FUNCTION! Use WWMath::Normalize_Angle instead. Delete this. extern Real normalizeAngle(Real angle); // ------------------------------------------------------------------------ @@ -480,14 +476,13 @@ inline Real stdAngleDiff(Real a1, Real a2) // NOTE NOTE NOTE: Keep TheRelationShipNames in sync with this enum enum Relationship CPP_11(: Int) { - ENEMIES = 0, + ENEMIES, NEUTRAL, - ALLIES + ALLIES, + + RELATIONSHIP_COUNT }; // TheRelationShipNames is defined in Common/GameCommon.cpp -extern const char *TheRelationshipNames[]; - -#endif // _GAMECOMMON_H_ - +extern const char *const TheRelationshipNames[]; diff --git a/Generals/Code/GameEngine/Include/Common/GameEngine.h b/Generals/Code/GameEngine/Include/Common/GameEngine.h index 174274ecb3..0846229246 100644 --- a/Generals/Code/GameEngine/Include/Common/GameEngine.h +++ b/Generals/Code/GameEngine/Include/Common/GameEngine.h @@ -28,14 +28,9 @@ #pragma once -#ifndef _GAME_ENGINE_H_ -#define _GAME_ENGINE_H_ - #include "Common/SubsystemInterface.h" #include "Common/GameType.h" -#define DEFAULT_MAX_FPS 45 - // forward declarations class AudioManager; class GameLogic; @@ -55,12 +50,8 @@ class Radar; class WebBrowser; class ParticleSystemManager; -/** - * The implementation of the game engine - */ class GameEngine : public SubsystemInterface { - public: GameEngine( void ); @@ -72,8 +63,10 @@ class GameEngine : public SubsystemInterface virtual void execute( void ); /**< The "main loop" of the game engine. It will not return until the game exits. */ - virtual void setFramesPerSecondLimit( Int fps ); ///< Set the maximum rate engine updates are allowed to occur - virtual Int getFramesPerSecondLimit( void ); ///< Get maxFPS. Not inline since it is called from another lib. + + static Bool isTimeFrozen(); ///< Returns true if a script has frozen time. + static Bool isGameHalted(); ///< Returns true if the game is paused or the network is stalling. + virtual void setQuitting( Bool quitting ); ///< set quitting status virtual Bool getQuitting(void); ///< is app getting ready to quit. @@ -87,6 +80,10 @@ class GameEngine : public SubsystemInterface virtual void resetSubsystems( void ); + Bool canUpdateGameLogic(); + Bool canUpdateNetworkGameLogic(); + Bool canUpdateRegularGameLogic(); + virtual FileSystem *createFileSystem( void ); ///< Factory for FileSystem classes virtual LocalFileSystem *createLocalFileSystem( void ) = 0; ///< Factory for LocalFileSystem classes virtual ArchiveFileSystem *createArchiveFileSystem( void ) = 0; ///< Factory for ArchiveFileSystem classes @@ -101,11 +98,12 @@ class GameEngine : public SubsystemInterface virtual ParticleSystemManager* createParticleSystemManager( void ) = 0; virtual AudioManager *createAudioManager( void ) = 0; ///< Factory for Audio Manager - Int m_maxFPS; ///< Maximum frames per second allowed - Bool m_quitting; ///< true when we need to quit the game - Bool m_isActive; ///< app has OS focus. + Real m_logicTimeAccumulator; ///< Frame time accumulated towards submitting a new logic frame + Bool m_quitting; ///< true when we need to quit the game + Bool m_isActive; ///< app has OS focus. }; + inline void GameEngine::setQuitting( Bool quitting ) { m_quitting = quitting; } inline Bool GameEngine::getQuitting(void) { return m_quitting; } @@ -117,5 +115,3 @@ extern GameEngine *CreateGameEngine( void ); /// The entry point for the game system extern Int GameMain(); - -#endif // _GAME_ENGINE_H_ diff --git a/Generals/Code/GameEngine/Include/Common/GameLOD.h b/Generals/Code/GameEngine/Include/Common/GameLOD.h index 7eab7454f0..0e3390d77c 100644 --- a/Generals/Code/GameEngine/Include/Common/GameLOD.h +++ b/Generals/Code/GameEngine/Include/Common/GameLOD.h @@ -33,23 +33,26 @@ #pragma once -#ifndef _GAME_LOD_H_ -#define _GAME_LOD_H_ - enum ParticlePriorityType CPP_11(: Int); -#define MAX_LOD_PRESETS_PER_LEVEL 32 //number of hardware configs preset for each low,medium,high +#define MAX_LOD_PRESETS_PER_LEVEL 32 //number of hardware configs preset for each low,medium,high,veryhigh #define MAX_BENCH_PROFILES 16 //Make sure this enum stays in sync with GameLODNames[] enum StaticGameLODLevel CPP_11(: Int) { STATIC_GAME_LOD_UNKNOWN=-1, + STATIC_GAME_LOD_LOW, STATIC_GAME_LOD_MEDIUM, STATIC_GAME_LOD_HIGH, + STATIC_GAME_LOD_VERY_HIGH, + STATIC_GAME_LOD_CUSTOM, //make sure this remains last! - STATIC_GAME_LOD_COUNT + + STATIC_GAME_LOD_COUNT, + STATIC_GAME_LOD_FIRST = 0, + STATIC_GAME_LOD_LAST = STATIC_GAME_LOD_CUSTOM - 1, }; enum DynamicGameLODLevel CPP_11(: Int) @@ -69,6 +72,8 @@ enum CpuType CPP_11(: Int) P3, P4, K7, + + CPU_MAX }; //Keep this in sync with VideoNames in Gamelod.cpp @@ -161,15 +166,13 @@ class GameLODManager const char *getStaticGameLODLevelName(StaticGameLODLevel level); const char *getDynamicGameLODLevelName(DynamicGameLODLevel level); - StaticGameLODLevel findStaticLODLevel(void); ///< calculate the optimal static LOD level for this system. + StaticGameLODLevel getRecommendedStaticLODLevel(void); ///< calculate the optimal static LOD level for this system. Bool setStaticLODLevel(StaticGameLODLevel level); ///< set the current static LOD level. StaticGameLODLevel getStaticLODLevel(void) { return m_currentStaticLOD;} DynamicGameLODLevel findDynamicLODLevel(Real averageFPS); /// m_standardPublicBones; Real m_standardMinefieldDensity; Real m_standardMinefieldDistance; - Bool m_showMetrics; ///< whether or not to show the metrics. - Int m_defaultStartingCash; ///< The amount of cash a player starts with by default. + Bool m_showMetrics; ///< whether or not to show the metrics. + Money m_defaultStartingCash; ///< The amount of cash a player starts with by default. Bool m_debugShowGraphicalFramerate; ///< Whether or not to show the graphical framerate bar. @@ -574,5 +589,3 @@ inline const GlobalData* const& TheGlobalData = TheWritableGlobalData; #else #define TheGlobalData ((const GlobalData*)TheWritableGlobalData) #endif - -#endif diff --git a/Generals/Code/GameEngine/Include/Common/Handicap.h b/Generals/Code/GameEngine/Include/Common/Handicap.h index 6770f503fa..2ffabc9458 100644 --- a/Generals/Code/GameEngine/Include/Common/Handicap.h +++ b/Generals/Code/GameEngine/Include/Common/Handicap.h @@ -44,9 +44,6 @@ #pragma once -#ifndef _HANDICAP_H_ -#define _HANDICAP_H_ - #include "Lib/BaseType.h" // ---------------------------------------------------------------------------------------------- @@ -117,5 +114,3 @@ class Handicap static ThingType getBestThingType(const ThingTemplate *tmpl); }; - -#endif // _HANDICAP_H_ diff --git a/Generals/Code/GameEngine/Include/Common/INI.h b/Generals/Code/GameEngine/Include/Common/INI.h index ff2762c9ec..0e48452dc5 100644 --- a/Generals/Code/GameEngine/Include/Common/INI.h +++ b/Generals/Code/GameEngine/Include/Common/INI.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __INI_H_ -#define __INI_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include // for offsetof, which we don't use but everyone who includes us does #include "Common/STLTypedefs.h" @@ -91,14 +88,14 @@ enum /** Function typedef for parsing data block fields. * * buffer - the character buffer of the line from INI that we are reading and parsing - * instance - instance of what we're loading (for example a thingtemplate instance) + * instance - instance of what we're loading (for example a ThingTemplate instance) * store - where to store the data parsed, this is a field in the *instance* 'instance' */ //------------------------------------------------------------------------------------------------- typedef void (*INIFieldParseProc)( INI *ini, void *instance, void *store, const void* userData ); //------------------------------------------------------------------------------------------------- -typedef const char* ConstCharPtr; +typedef const char* const ConstCharPtr; typedef ConstCharPtr* ConstCharPtrArray; //------------------------------------------------------------------------------------------------- @@ -119,7 +116,7 @@ struct FieldParse const void* userData; ///< field-specific data Int offset; ///< offset to data field - inline void set(const char* t, INIFieldParseProc p, const void* u, Int o) + void set(const char* t, INIFieldParseProc p, const void* u, Int o) { token = t; parse = p; @@ -141,19 +138,15 @@ class MultiIniFieldParse public: MultiIniFieldParse() : m_count(0) { - //Added By Sadullah Nader - //Initializations missing and needed for(Int i = 0; i < MAX_MULTI_FIELDS; i++) m_extraOffset[i] = 0; - // - } void add(const FieldParse* f, UnsignedInt e = 0); - inline Int getCount() const { return m_count; } - inline const FieldParse* getNthFieldParse(Int i) const { return m_fieldParse[i]; } - inline UnsignedInt getNthExtraOffset(Int i) const { return m_extraOffset[i]; } + Int getCount() const { return m_count; } + const FieldParse* getNthFieldParse(Int i) const { return m_fieldParse[i]; } + UnsignedInt getNthExtraOffset(Int i) const { return m_extraOffset[i]; } }; //------------------------------------------------------------------------------------------------- @@ -173,8 +166,19 @@ class INI INI(); ~INI(); - void loadDirectory( AsciiString dirName, Bool subdirs, INILoadType loadType, Xfer *pXfer ); ///< load directory of INI files - void load( AsciiString filename, INILoadType loadType, Xfer *pXfer ); ///< load INI file + // TheSuperHackers @feature xezon 19/08/2025 + // Load a specific INI file by name and/or INI files from a directory (and its subdirectories). + // For example "Data\INI\Armor" loads "Data\INI\Armor.ini" and all *.ini files in "Data\INI\Armor". + // Throws if not a single INI file is found or one is not read correctly. + UnsignedInt loadFileDirectory( AsciiString fileDirName, INILoadType loadType, Xfer *pXfer, Bool subdirs = TRUE ); + + // Load INI files from a directory (and its subdirectories). + // Throws if one INI file is not read correctly. + UnsignedInt loadDirectory( AsciiString dirName, INILoadType loadType, Xfer *pXfer, Bool subdirs = TRUE ); + + // Load one specific INI file by name. + // Throws if the INI file is not found or is not read correctly. + UnsignedInt load( AsciiString filename, INILoadType loadType, Xfer *pXfer ); static Bool isDeclarationOfType( AsciiString blockType, AsciiString blockName, char *bufferToCheck ); static Bool isEndOfBlock( char *bufferToCheck ); @@ -200,6 +204,7 @@ class INI static void parseParticleSystemDefinition( INI *ini ); static void parseWaterSettingDefinition( INI *ini ); static void parseWaterTransparencyDefinition( INI *ini ); + static void parseWeatherDefinition( INI *ini ); static void parseMappedImageDefinition( INI *ini ); static void parseArmorDefinition( INI *ini ); static void parseDamageFXDefinition( INI *ini ); @@ -240,14 +245,14 @@ class INI static void parseWindowTransitions( INI* ini ); - inline AsciiString getFilename( void ) const { return m_filename; } - inline INILoadType getLoadType( void ) const { return m_loadType; } - inline UnsignedInt getLineNum( void ) const { return m_lineNum; } - inline const char *getSeps( void ) const { return m_seps; } - inline const char *getSepsPercent( void ) const { return m_sepsPercent; } - inline const char *getSepsColon( void ) const { return m_sepsColon; } - inline const char *getSepsQuote( void ) { return m_sepsQuote; } - inline Bool isEOF( void ) const { return m_endOfFile; } + AsciiString getFilename( void ) const { return m_filename; } + INILoadType getLoadType( void ) const { return m_loadType; } + UnsignedInt getLineNum( void ) const { return m_lineNum; } + const char *getSeps( void ) const { return m_seps; } + const char *getSepsPercent( void ) const { return m_sepsPercent; } + const char *getSepsColon( void ) const { return m_sepsColon; } + const char *getSepsQuote( void ) { return m_sepsQuote; } + Bool isEOF( void ) const { return m_endOfFile; } void initFromINI( void *what, const FieldParse* parseTable ); void initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList ); @@ -403,6 +408,3 @@ class INI char m_curBlockStart[ INI_MAX_CHARS_PER_LINE ]; ///< first line of cur block #endif }; - -#endif // __INI_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/INIException.h b/Generals/Code/GameEngine/Include/Common/INIException.h index afbbee3e82..5afca81bc1 100644 --- a/Generals/Code/GameEngine/Include/Common/INIException.h +++ b/Generals/Code/GameEngine/Include/Common/INIException.h @@ -45,8 +45,6 @@ class INIException ~INIException() { - if (mFailureMessage) { - delete [] mFailureMessage; - } + delete [] mFailureMessage; } }; diff --git a/Generals/Code/GameEngine/Include/Common/IgnorePreferences.h b/Generals/Code/GameEngine/Include/Common/IgnorePreferences.h index 38b4e89460..1801f0c519 100644 --- a/Generals/Code/GameEngine/Include/Common/IgnorePreferences.h +++ b/Generals/Code/GameEngine/Include/Common/IgnorePreferences.h @@ -45,9 +45,6 @@ #pragma once -#ifndef __IGNORE_PREFERENCES_H_ -#define __IGNORE_PREFERENCES_H_ - //----------------------------------------------------------------------------- // SYSTEM INCLUDES //////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -82,5 +79,3 @@ class IgnorePreferences : public UserPreferences //----------------------------------------------------------------------------- // EXTERNALS ////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- - -#endif // __IGNORE_PREFERENCES_H_ diff --git a/Generals/Code/GameEngine/Include/Common/KindOf.h b/Generals/Code/GameEngine/Include/Common/KindOf.h index 848ec363da..8dbec5da7c 100644 --- a/Generals/Code/GameEngine/Include/Common/KindOf.h +++ b/Generals/Code/GameEngine/Include/Common/KindOf.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __KINDOF_H_ -#define __KINDOF_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Lib/BaseType.h" #include "Common/BitFlags.h" @@ -43,8 +40,8 @@ enum KindOfType CPP_11(: Int) { KINDOF_INVALID = -1, - KINDOF_FIRST = 0, - KINDOF_OBSTACLE = KINDOF_FIRST, ///< an obstacle to land-based pathfinders + + KINDOF_OBSTACLE, ///< an obstacle to land-based pathfinders KINDOF_SELECTABLE, ///< Selectable KINDOF_IMMOBILE, ///< fixed in location KINDOF_CAN_ATTACK, ///< can attack @@ -143,8 +140,8 @@ enum KindOfType CPP_11(: Int) KINDOF_IGNORES_SELECT_ALL, ///< Too late to figure out intelligently if something should respond to a Select All command KINDOF_DONT_AUTO_CRUSH_INFANTRY, ///< These units don't try to crush the infantry if ai. - KINDOF_COUNT // total number of kindofs - + KINDOF_COUNT, // total number of kindofs + KINDOF_FIRST = 0, }; typedef BitFlags KindOfMaskType; @@ -189,6 +186,3 @@ inline void FLIP_KINDOFMASK(KindOfMaskType& m) // defined in Common/System/Kindof.cpp extern KindOfMaskType KINDOFMASK_NONE; // inits to all zeroes - -#endif // __KINDOF_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/LadderPreferences.h b/Generals/Code/GameEngine/Include/Common/LadderPreferences.h index b23f2ebb5d..e28d63721e 100644 --- a/Generals/Code/GameEngine/Include/Common/LadderPreferences.h +++ b/Generals/Code/GameEngine/Include/Common/LadderPreferences.h @@ -30,9 +30,6 @@ #pragma once -#ifndef __LADDERPREFERENCES_H__ -#define __LADDERPREFERENCES_H__ - //----------------------------------------------------------------------------- // USER INCLUDES ////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -76,5 +73,3 @@ class LadderPreferences : public UserPreferences private: LadderPrefMap m_ladders; }; - -#endif // __LADDERPREFERENCES_H__ diff --git a/Generals/Code/GameEngine/Include/Common/Language.h b/Generals/Code/GameEngine/Include/Common/Language.h index a2db8eafaf..1a25b2cef2 100644 --- a/Generals/Code/GameEngine/Include/Common/Language.h +++ b/Generals/Code/GameEngine/Include/Common/Language.h @@ -45,9 +45,6 @@ #pragma once -#ifndef __LANGUAGE_H_ -#define __LANGUAGE_H_ - // SYSTEM INCLUDES //////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////// @@ -75,34 +72,9 @@ typedef enum } LanguageID; -#define GameStrcpy wcscpy -#define GameStrncpy wcsncpy -#define GameStrlen wcslen -#define GameStrcat wcscat -#define GameStrcmp wcscmp -#define GameStrncmp wcsncmp -#define GameStricmp wcsicmp -#define GameStrnicmp wcsnicmp -#define GameStrtok wcstok -#define GameSprintf swprintf -#define GameVsprintf vswprintf -/// @todo -- add a non-malloc-based string dup func #define GameStrdup wcsdup -#define GameAtoi(S) wcstol( (S), NULL, 10) -#define GameAtod(S) wcstod( (S), NULL ) -#define GameItoa _itow -#define GameSscanf swscanf -#define GameStrstr wcsstr -#define GameStrchr wcschr -#define GameIsDigit iswdigit -#define GameIsAscii iswascii -#define GameIsAlNum iswalnum -#define GameIsAlpha iswalpha #define GameArrayEnd(array) (array)[(sizeof(array)/sizeof((array)[0]))-1] = 0 // INLINING /////////////////////////////////////////////////////////////////// // EXTERNALS ////////////////////////////////////////////////////////////////// extern LanguageID OurLanguage; ///< our current language definition - -#endif // __LANGUAGE_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/LatchRestore.h b/Generals/Code/GameEngine/Include/Common/LatchRestore.h index 5c3b1b2231..eb516c4b7e 100644 --- a/Generals/Code/GameEngine/Include/Common/LatchRestore.h +++ b/Generals/Code/GameEngine/Include/Common/LatchRestore.h @@ -30,9 +30,6 @@ #pragma once -#ifndef __LATCHRESTORE_H__ -#define __LATCHRESTORE_H__ - /* The purpose of the LatchRestore class is to allow you to override member variables for the scope of a function. Here's the code that this saves: @@ -111,7 +108,3 @@ class LatchRestore whereToRestore = valueToRestore; } }; - - -#endif /* __LATCHRESTORE_H__ */ - diff --git a/Generals/Code/GameEngine/Include/Common/List.h b/Generals/Code/GameEngine/Include/Common/List.h index a0156de3ef..ef47c1ee81 100644 --- a/Generals/Code/GameEngine/Include/Common/List.h +++ b/Generals/Code/GameEngine/Include/Common/List.h @@ -43,17 +43,11 @@ #pragma once - -#ifndef __WSYS_LIST_H -#define __WSYS_LIST_H - //---------------------------------------------------------------------------- // Includes //---------------------------------------------------------------------------- -#ifndef _BASE_TYPE_H_ #include -#endif //---------------------------------------------------------------------------- // Forward References @@ -177,5 +171,3 @@ inline LListNode* LList::lastNode( void ) { return m_head.prev();} ; inline void LList::setSortMode( SortMode new_mode ) { m_sortMode = new_mode; }; inline Bool LList::isEmpty( void ) { return !m_head.inList(); }; inline void LList::destroy( void ) { clear();}; - -#endif // __GDF_LIST_H_ diff --git a/Generals/Code/GameEngine/Include/Common/MapObject.h b/Generals/Code/GameEngine/Include/Common/MapObject.h deleted file mode 100644 index 84f1e7b16b..0000000000 --- a/Generals/Code/GameEngine/Include/Common/MapObject.h +++ /dev/null @@ -1,175 +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. // -// // -//////////////////////////////////////////////////////////////////////////////// - - -// MapObject.h -// Class to encapsulate height map. -// Author: John Ahlquist, April 2001 - -#pragma once - -#ifndef MapObject_H -#define MapObject_H - -#include "Common/Dict.h" -#include "Common/GameMemory.h" -#include "GameClient/TerrainRoads.h" - -/** MapObject class -Not ref counted. Do not store pointers to this class. */ -class WorldHeightMap; -class RenderObjClass; -class ThingTemplate; -class Shadow; -enum WaypointID CPP_11(: Int); - -#define MAP_XY_FACTOR (10.0f) //How wide and tall each height map square is in world space. -#define MAP_HEIGHT_SCALE (MAP_XY_FACTOR/16.0f) //divide all map heights by 8. - -// m_flags bit values. -enum { - FLAG_DRAWS_IN_MIRROR = 0x00000001, ///< If set, draws in water mirror. - FLAG_ROAD_POINT1 = 0x00000002, ///< If set, is the first point in a road segment. - FLAG_ROAD_POINT2 = 0x00000004, ///< If set, is the second point in a road segment. - FLAG_ROAD_FLAGS = (FLAG_ROAD_POINT1|FLAG_ROAD_POINT2), ///< If nonzero, object is a road piece. - FLAG_ROAD_CORNER_ANGLED = 0x00000008, ///< If set, the road corner is angled rather than curved. - FLAG_BRIDGE_POINT1 = 0x00000010, ///< If set, is the first point in a bridge. - FLAG_BRIDGE_POINT2 = 0x00000020, ///< If set, is the second point in a bridge. - FLAG_BRIDGE_FLAGS = (FLAG_BRIDGE_POINT1|FLAG_BRIDGE_POINT2), ///< If nonzero, object is a bridge piece. - FLAG_ROAD_CORNER_TIGHT = 0x00000040, - FLAG_ROAD_JOIN = 0x00000080, ///< If set, this road end does a generic alpha join. - FLAG_DONT_RENDER = 0x00000100 ///< If set, do not render this object. Only WB pays attention to this. (Right now, anyways) -}; - -class MapObject : public MemoryPoolObject -{ - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(MapObject, "MapObject") - -// friend doesn't play well with MPO -- srj -// friend class WorldHeightMap; -// friend class WorldHeightMapEdit; -// friend class AddObjectUndoable; -// friend class DeleteInfo; - - enum - { - MO_SELECTED = 0x01, - MO_LIGHT = 0x02, - MO_WAYPOINT = 0x04, - MO_SCORCH = 0x08 - }; - - // This data is currently written out into the map data file. - Coord3D m_location; ///< Location of the center of the object. - AsciiString m_objectName; ///< The object name. - const ThingTemplate* m_thingTemplate; ///< thing template for map object - Real m_angle; ///< positive x is 0 degrees, angle is counterclockwise in degrees. - MapObject* m_nextMapObject; ///< linked list. - Int m_flags; ///< Bit flags. - Dict m_properties; ///< general property sheet. - // This data is runtime data that is used by the worldbuider editor, but - // not saved in the map file. - Int m_color; ///< Display color. - RenderObjClass* m_renderObj; ///< object that renders in the 3d scene. - Shadow* m_shadowObj; ///< object that renders shadow in the 3d scene. - RenderObjClass* m_bridgeTowers[ BRIDGE_MAX_TOWERS ]; ///< for bridge towers - Int m_runtimeFlags; - -public: - static MapObject *TheMapObjectListPtr; - static Dict TheWorldDict; - -public: - MapObject(Coord3D loc, AsciiString name, Real angle, Int flags, const Dict* props, - const ThingTemplate *thingTemplate ); - //~MapObject(void); ///< Note that deleting the head of a list deletes all linked objects in the list. - -public: - - Dict *getProperties() { return &m_properties; } ///< return the object's property sheet. - - void setNextMap(MapObject *nextMap) {m_nextMapObject = nextMap;} ///< Link the next map object. - const Coord3D *getLocation(void) const {return &m_location;} ///< Get the center point. - Real getAngle(void) const {return m_angle;} ///< Get the angle. - Int getColor(void) const {return m_color;} ///< Gets whatever ui color we set. - void setColor(Int color) {m_color=color;} ///< Sets the ui color. - AsciiString getName(void) const {return m_objectName;} ///< Gets the object name - void setName(AsciiString name); ///< Sets the object name - void setThingTemplate( const ThingTemplate* thing ); ///< set template - const ThingTemplate *getThingTemplate( void ) const; - MapObject *getNext(void) const {return m_nextMapObject;} ///< Next map object in the list. Not a copy, don't delete it. - MapObject *duplicate(void); ///< Allocates a copy. Caller is responsible for delete-ing this when done with it. - - void setAngle(Real angle) {m_angle = normalizeAngle(angle);} - void setLocation(Coord3D *pLoc) {m_location = *pLoc;} - void setFlag(Int flag) {m_flags |= flag;} - void clearFlag(Int flag) {m_flags &= (~flag);} - Bool getFlag(Int flag) const {return (m_flags&flag)?true:false;} - Int getFlags(void) const {return (m_flags);} - - Bool isSelected(void) const {return (m_runtimeFlags & MO_SELECTED) != 0;} - void setSelected(Bool sel) { if (sel) m_runtimeFlags |= MO_SELECTED; else m_runtimeFlags &= ~MO_SELECTED; } - - Bool isLight(void) const {return (m_runtimeFlags & MO_LIGHT) != 0;} - Bool isWaypoint(void) const {return (m_runtimeFlags & MO_WAYPOINT) != 0;} - Bool isScorch(void) const {return (m_runtimeFlags & MO_SCORCH) != 0;} - - void setIsLight() {m_runtimeFlags |= MO_LIGHT;} - void setIsWaypoint() { m_runtimeFlags |= MO_WAYPOINT; } - void setIsScorch() { m_runtimeFlags |= MO_SCORCH; } - - void setRenderObj(RenderObjClass *pObj); - RenderObjClass *getRenderObj(void) const {return m_renderObj;} - void setShadowObj(Shadow *pObj) {m_shadowObj=pObj;} - Shadow *getShadowObj(void) const {return m_shadowObj;} - - RenderObjClass* getBridgeRenderObject( BridgeTowerType type ); - void setBridgeRenderObject( BridgeTowerType type, RenderObjClass* renderObj ); - - WaypointID getWaypointID(); - AsciiString getWaypointName(); - void setWaypointID(Int i); - void setWaypointName(AsciiString n); - - // calling validate will call verifyValidTeam and verifyValidUniqueID. - void validate(void); - - // verifyValidTeam will either place the map object on an approrpriate team, or leave the - // current team (if it is valid) - void verifyValidTeam(void); - - // verifyValidUniqueID will ensure that this unit isn't sharing a number with another unit. - void verifyValidUniqueID(void); - - // The fast version doesn't attempt to verify uniqueness. It goes - static void fastAssignAllUniqueIDs(void); - - - static MapObject *getFirstMapObject(void) { return TheMapObjectListPtr; } - static Dict* getWorldDict() { return &TheWorldDict; } - static Int countMapObjectsWithOwner(const AsciiString& n); -}; - -#endif - diff --git a/Generals/Code/GameEngine/Include/Common/MapReaderWriterInfo.h b/Generals/Code/GameEngine/Include/Common/MapReaderWriterInfo.h index b25483cea7..733d6d26c9 100644 --- a/Generals/Code/GameEngine/Include/Common/MapReaderWriterInfo.h +++ b/Generals/Code/GameEngine/Include/Common/MapReaderWriterInfo.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _MAP_READER_WRITER_INFO_H_ -#define _MAP_READER_WRITER_INFO_H_ - #define K_HEIGHT_MAP_VERSION_1 1 // Height map cell = 5.0 #define K_HEIGHT_MAP_VERSION_2 2 // Height map cell = 10.0 #define K_HEIGHT_MAP_VERSION_3 3 // Added m_borderSize @@ -117,8 +114,6 @@ class FileInputStream : public ChunkInputStream }; */ -#endif // _MAP_READER_WRITER_INFO_H_ - /* rev K_HEIGHT_MAP_VERSION_4 diff --git a/Generals/Code/GameEngine/Include/Common/MessageStream.h b/Generals/Code/GameEngine/Include/Common/MessageStream.h index c014895820..8c5e6c188e 100644 --- a/Generals/Code/GameEngine/Include/Common/MessageStream.h +++ b/Generals/Code/GameEngine/Include/Common/MessageStream.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _MESSAGE_STREAM_H_ -#define _MESSAGE_STREAM_H_ - #include "Common/GameCommon.h" // ensure we get DUMP_PERF_STATS, or not #include "Common/SubsystemInterface.h" #include "Lib/BaseType.h" @@ -241,8 +238,13 @@ class GameMessage : public MemoryPoolObject MSG_META_HELP, ///< bring up help screen #endif + MSG_META_INCREASE_MAX_RENDER_FPS, ///< TheSuperHackers @feature Increase the max render fps + MSG_META_DECREASE_MAX_RENDER_FPS, ///< TheSuperHackers @feature Decrease the max render fps + MSG_META_INCREASE_LOGIC_TIME_SCALE, ///< TheSuperHackers @feature Increase the logic time scale + MSG_META_DECREASE_LOGIC_TIME_SCALE, ///< TheSuperHackers @feature Decrease the logic time scale MSG_META_TOGGLE_LOWER_DETAILS, ///< toggles graphics options to crappy mode instantly MSG_META_TOGGLE_CONTROL_BAR, ///< show/hide controlbar + MSG_META_TOGGLE_PLAYER_OBSERVER, ///< TheSuperHackers @feature Toggle the player observer view in game MSG_META_BEGIN_PATH_BUILD, ///< enter path-building mode MSG_META_END_PATH_BUILD, ///< exit path-building mode @@ -261,16 +263,20 @@ class GameMessage : public MemoryPoolObject MSG_META_BEGIN_CAMERA_ROTATE_LEFT, MSG_META_END_CAMERA_ROTATE_LEFT, + MSG_META_ALT_CAMERA_ROTATE_LEFT, ///< TheSuperHackers @feature Rotate camera in 45 degree increments MSG_META_BEGIN_CAMERA_ROTATE_RIGHT, MSG_META_END_CAMERA_ROTATE_RIGHT, + MSG_META_ALT_CAMERA_ROTATE_RIGHT, ///< TheSuperHackers @feature Rotate camera in 45 degree increments MSG_META_BEGIN_CAMERA_ZOOM_IN, MSG_META_END_CAMERA_ZOOM_IN, MSG_META_BEGIN_CAMERA_ZOOM_OUT, MSG_META_END_CAMERA_ZOOM_OUT, MSG_META_CAMERA_RESET, MSG_META_TOGGLE_FAST_FORWARD_REPLAY, ///< Toggle the fast forward feature - MSG_META_TOGGLE_PAUSE, ///< TheSuperHackers @feature Toggle game pause (in replay playbacks) - MSG_META_STEP_FRAME, ///< TheSuperHackers @feature Step one frame (in replay playbacks) + MSG_META_TOGGLE_PAUSE, ///< TheSuperHackers @feature Toggle game pause + MSG_META_TOGGLE_PAUSE_ALT, ///< TheSuperHackers @feature Toggle game pause (alternative mapping) + MSG_META_STEP_FRAME, ///< TheSuperHackers @feature Step one frame + MSG_META_STEP_FRAME_ALT, ///< TheSuperHackers @feature Step one frame (alternative mapping) // META items that are really for debug/demo/development use only... @@ -800,5 +806,3 @@ extern CommandList *TheCommandList; * construct a valid 2D bounding region. */ extern void buildRegion( const ICoord2D *anchor, const ICoord2D *dest, IRegion2D *region ); - -#endif // _MESSAGE_STREAM_H_ diff --git a/Generals/Code/GameEngine/Include/Common/MissionStats.h b/Generals/Code/GameEngine/Include/Common/MissionStats.h index 01994f6aac..e57116f8c7 100644 --- a/Generals/Code/GameEngine/Include/Common/MissionStats.h +++ b/Generals/Code/GameEngine/Include/Common/MissionStats.h @@ -44,9 +44,6 @@ #pragma once -#ifndef _MISSIONSTATS_H_ -#define _MISSIONSTATS_H_ - #include "Lib/BaseType.h" #include "Common/GameCommon.h" #include "Common/Snapshot.h" @@ -85,6 +82,3 @@ class MissionStats : public Snapshot Int m_buildingsLost; ///< how many of our buildings were destroyed? //Int m_whoLastHurtMe; ///< last Player to destroy one of my units }; - -#endif // _MISSIONSTATS_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/ModelState.h b/Generals/Code/GameEngine/Include/Common/ModelState.h index b965cc1cc4..5997dd8e2e 100644 --- a/Generals/Code/GameEngine/Include/Common/ModelState.h +++ b/Generals/Code/GameEngine/Include/Common/ModelState.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _ModelState_H_ -#define _ModelState_H_ - #include "Lib/BaseType.h" #include "Common/INI.h" #include "Common/BitFlags.h" @@ -91,13 +88,11 @@ enum ModelConditionFlagType CPP_11(: Int) { MODELCONDITION_INVALID = -1, - MODELCONDITION_FIRST = 0, - // // Note: these values are saved in save files, so you MUST NOT REMOVE OR CHANGE // existing values! // - MODELCONDITION_TOPPLED = MODELCONDITION_FIRST, + MODELCONDITION_TOPPLED, MODELCONDITION_FRONTCRUSHED, MODELCONDITION_BACKCRUSHED, MODELCONDITION_DAMAGED, @@ -214,7 +209,8 @@ enum ModelConditionFlagType CPP_11(: Int) // existing values! // - MODELCONDITION_COUNT // keep last! + MODELCONDITION_COUNT, + MODELCONDITION_FIRST = 0, }; //------------------------------------------------------------------------------------------------- @@ -233,6 +229,3 @@ typedef BitFlags ModelConditionFlags; //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- - -#endif // _ModelState_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/Module.h b/Generals/Code/GameEngine/Include/Common/Module.h index 20c6d9d816..adc0e98e27 100644 --- a/Generals/Code/GameEngine/Include/Common/Module.h +++ b/Generals/Code/GameEngine/Include/Common/Module.h @@ -31,9 +31,6 @@ #pragma once -#ifndef __MODULE_H_ -#define __MODULE_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Common/INI.h" #include "Common/GameMemory.h" @@ -69,7 +66,7 @@ enum ModuleType CPP_11(: Int) MODULETYPE_CLIENT_UPDATE = 2, // put new drawable module types here - NUM_MODULE_TYPES, // keep this last! + NUM_MODULE_TYPES, FIRST_DRAWABLE_MODULE_TYPE = MODULETYPE_DRAW, LAST_DRAWABLE_MODULE_TYPE = MODULETYPE_CLIENT_UPDATE, @@ -192,7 +189,7 @@ class Module : public MemoryPoolObject, virtual NameKeyType getModuleNameKey() const = 0; - inline NameKeyType getModuleTagNameKey() const { return getModuleData()->getModuleTagNameKey(); } + NameKeyType getModuleTagNameKey() const { return getModuleData()->getModuleTagNameKey(); } /** this is called after all the Modules for a given Thing are created; it allows Modules to resolve any inter-Module dependencies. @@ -214,7 +211,7 @@ class Module : public MemoryPoolObject, protected: - inline const ModuleData* getModuleData() const { return m_moduleData; } + const ModuleData* getModuleData() const { return m_moduleData; } virtual void crc( Xfer *xfer ); virtual void xfer( Xfer *xfer ); @@ -223,7 +220,7 @@ class Module : public MemoryPoolObject, private: const ModuleData* m_moduleData; -}; // end Module +}; //------------------------------------------------------------------------------------------------- @@ -251,8 +248,8 @@ class ObjectModule : public Module protected: - inline Object *getObject() { return m_object; } - inline const Object *getObject() const { return m_object; } + Object *getObject() { return m_object; } + const Object *getObject() const { return m_object; } virtual void crc( Xfer *xfer ); virtual void xfer( Xfer *xfer ); @@ -294,8 +291,8 @@ class DrawableModule : public Module protected: - inline Drawable *getDrawable() { return m_drawable; } - inline const Drawable *getDrawable() const { return m_drawable; } + Drawable *getDrawable() { return m_drawable; } + const Drawable *getDrawable() const { return m_drawable; } virtual void crc( Xfer *xfer ); virtual void xfer( Xfer *xfer ); @@ -314,7 +311,3 @@ class DrawableModule : public Module //------------------------------------------------------------------------------------------------- /** VARIOUS MODULE INTERFACES */ //------------------------------------------------------------------------------------------------- - - -#endif // __MODULE_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/ModuleFactory.h b/Generals/Code/GameEngine/Include/Common/ModuleFactory.h index dd3ea4da64..f3f4182f90 100644 --- a/Generals/Code/GameEngine/Include/Common/ModuleFactory.h +++ b/Generals/Code/GameEngine/Include/Common/ModuleFactory.h @@ -36,9 +36,6 @@ #pragma once -#ifndef __MODULEFACTORY_H_ -#define __MODULEFACTORY_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include @@ -122,10 +119,7 @@ class ModuleFactory : public SubsystemInterface, public Snapshot ModuleTemplateMap m_moduleTemplateMap; ModuleDataList m_moduleDataList; -}; // end class ModuleFactory +}; // EXTERN ///////////////////////////////////////////////////////////////////////////////////////// extern ModuleFactory *TheModuleFactory; ///< singleton definition - -#endif // __MODULEFACTORY_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/Money.h b/Generals/Code/GameEngine/Include/Common/Money.h index bf3908a5be..2c4bbe3c6a 100644 --- a/Generals/Code/GameEngine/Include/Common/Money.h +++ b/Generals/Code/GameEngine/Include/Common/Money.h @@ -44,9 +44,6 @@ #pragma once -#ifndef _MONEY_H_ -#define _MONEY_H_ - #include "Lib/BaseType.h" #include "Common/Debug.h" #include "Common/Snapshot.h" @@ -64,23 +61,28 @@ class Money : public Snapshot public: - inline Money() : m_money(0), m_playerIndex(0) + Money() : m_playerIndex(0) { + init(); } void init() { - m_money = 0; + setStartingCash(0); } - inline UnsignedInt countMoney() const + UnsignedInt countMoney() const { return m_money; } /// returns the actual amount withdrawn, which may be less than you want. (sorry, can't go into debt...) UnsignedInt withdraw(UnsignedInt amountToWithdraw, Bool playSound = TRUE); - void deposit(UnsignedInt amountToDeposit, Bool playSound = TRUE); + void deposit(UnsignedInt amountToDeposit, Bool playSound = TRUE, Bool trackIncome = TRUE); + + void setStartingCash(UnsignedInt amount); + void updateIncomeBucket(); + UnsignedInt getCashPerMinute() const; void setPlayerIndex(Int ndx) { m_playerIndex = ndx; } @@ -105,7 +107,7 @@ class Money : public Snapshot UnsignedInt m_money; ///< amount of money Int m_playerIndex; ///< what is my player index? + UnsignedInt m_incomeBuckets[60]; ///< circular buffer of 60 seconds for income tracking + UnsignedInt m_currentBucket; + UnsignedInt m_cashPerMinute; }; - -#endif // _MONEY_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/MultiplayerSettings.h b/Generals/Code/GameEngine/Include/Common/MultiplayerSettings.h index a6e9c92f37..4ea47f91b6 100644 --- a/Generals/Code/GameEngine/Include/Common/MultiplayerSettings.h +++ b/Generals/Code/GameEngine/Include/Common/MultiplayerSettings.h @@ -29,10 +29,8 @@ #pragma once -#ifndef _MULTIPLAYERSETTINGS_H_ -#define _MULTIPLAYERSETTINGS_H_ - #include "GameClient/Color.h" +#include "Common/Money.h" // FORWARD DECLARATIONS /////////////////////////////////////////////////////////////////////////// struct FieldParse; @@ -48,11 +46,11 @@ class MultiplayerColorDefinition static const FieldParse m_colorFieldParseTable[]; ///< the parse table for INI definition const FieldParse *getFieldParse( void ) const { return m_colorFieldParseTable; } - inline AsciiString getTooltipName(void) const { return m_tooltipName; }; - inline RGBColor getRGBValue(void) const { return m_rgbValue; }; - inline RGBColor getRGBNightValue(void) const { return m_rgbValueNight; }; - inline Color getColor(void) const { return m_color; } - inline Color getNightColor(void) const { return m_colorNight; } + AsciiString getTooltipName(void) const { return m_tooltipName; }; + RGBColor getRGBValue(void) const { return m_rgbValue; }; + RGBColor getRGBNightValue(void) const { return m_rgbValueNight; }; + Color getColor(void) const { return m_color; } + Color getNightColor(void) const { return m_colorNight; } void setColor( RGBColor rgb ); void setNightColor( RGBColor rgb ); @@ -69,6 +67,9 @@ class MultiplayerColorDefinition typedef std::map MultiplayerColorList; typedef std::map::iterator MultiplayerColorIter; +// A list of values to display in the starting money dropdown +typedef std::vector< Money > MultiplayerStartingMoneyList; + //------------------------------------------------------------------------------------------------- /** Multiplayer Settings container class * Defines multiplayer settings */ @@ -91,16 +92,14 @@ class MultiplayerSettings : public SubsystemInterface MultiplayerColorDefinition * findMultiplayerColorDefinitionByName(AsciiString name); MultiplayerColorDefinition * newMultiplayerColorDefinition(AsciiString name); - inline Int getInitialCreditsMin( void ) { return m_initialCreditsMin; } - inline Int getInitialCreditsMax( void ) { return m_initialCreditsMax; } - inline Int getStartCountdownTimerSeconds( void ) { return m_startCountdownTimerSeconds; } - inline Int getMaxBeaconsPerPlayer( void ) { return m_maxBeaconsPerPlayer; } - inline Bool isShroudInMultiplayer( void ) { return m_isShroudInMultiplayer; } - inline Bool showRandomPlayerTemplate( void ) { return m_showRandomPlayerTemplate; } - inline Bool showRandomStartPos( void ) { return m_showRandomStartPos; } - inline Bool showRandomColor( void ) { return m_showRandomColor; } + Int getStartCountdownTimerSeconds( void ) { return m_startCountdownTimerSeconds; } + Int getMaxBeaconsPerPlayer( void ) { return m_maxBeaconsPerPlayer; } + Bool isShroudInMultiplayer( void ) { return m_isShroudInMultiplayer; } + Bool showRandomPlayerTemplate( void ) { return m_showRandomPlayerTemplate; } + Bool showRandomStartPos( void ) { return m_showRandomStartPos; } + Bool showRandomColor( void ) { return m_showRandomColor; } - inline Int getNumColors( void ) + Int getNumColors( void ) { if (m_numColors == 0) { m_numColors = m_colorList.size(); @@ -109,6 +108,17 @@ class MultiplayerSettings : public SubsystemInterface } MultiplayerColorDefinition * getColor(Int which); + + const Money & getDefaultStartingMoney() const + { + DEBUG_ASSERTCRASH( m_gotDefaultStartingMoney, ("You must specify a default starting money amount in multiplayer.ini") ); + return m_defaultStartingMoney; + } + + const MultiplayerStartingMoneyList & getStartingMoneyList() const { return m_startingMoneyList; } + + void addStartingMoneyChoice( const Money & money, Bool isDefault ); + private: Int m_initialCreditsMin; Int m_initialCreditsMax; @@ -123,9 +133,10 @@ class MultiplayerSettings : public SubsystemInterface Int m_numColors; MultiplayerColorDefinition m_observerColor; MultiplayerColorDefinition m_randomColor; + MultiplayerStartingMoneyList m_startingMoneyList; + Money m_defaultStartingMoney; + Bool m_gotDefaultStartingMoney; }; // singleton extern MultiplayerSettings *TheMultiplayerSettings; - -#endif diff --git a/Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h b/Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h index 7f2beb971a..2662543140 100644 --- a/Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h +++ b/Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h @@ -30,31 +30,26 @@ #pragma once -#ifndef __NAMEKEYGENERATOR_H_ -#define __NAMEKEYGENERATOR_H_ - #include "Lib/BaseType.h" #include "Common/SubsystemInterface.h" #include "Common/GameMemory.h" #include "Common/AsciiString.h" //------------------------------------------------------------------------------------------------- -/** - Note that NameKeyType isn't a "real" enum, but an enum type used to enforce the - fact that NameKeys are really magic cookies, and aren't really interchangeable - with ints. NAMEKEY_INVALID is always a legal value, but all other values are dynamically - determined at runtime. (The generated code is basically identical, of course.) -*/ +// Note that NameKeyType isn't a "real" enum, but an enum type used to enforce the +// fact that NameKeys are really magic cookies, and aren't really interchangeable +// with integers. NAMEKEY_INVALID is always a legal value, but all other values are dynamically +// determined at runtime. (The generated code is basically identical, of course.) //------------------------------------------------------------------------------------------------- enum NameKeyType CPP_11(: Int) { NAMEKEY_INVALID = 0, - NAMEKEY_MAX = 1<<23, // max ordinal value of a NameKey (some code relies on these fitting into 24 bits safely) - FORCE_NAMEKEYTYPE_LONG = 0x7fffffff // a trick to ensure the NameKeyType is a 32-bit int + NAMEKEY_MAX = 1<<23, // max ordinal value of a NameKey (some code relies on these fitting into 24 bits safely) + FORCE_NAMEKEYTYPE_LONG = 0x7fffffff, // a trick to ensure the NameKeyType is a 32-bit int }; //------------------------------------------------------------------------------------------------- -/** A bucket entry for the name key generator */ +// A bucket entry for the name key generator //------------------------------------------------------------------------------------------------- class Bucket : public MemoryPoolObject { @@ -75,12 +70,12 @@ inline Bucket::Bucket() : m_nextInSocket(NULL), m_key(NAMEKEY_INVALID) { } inline Bucket::~Bucket() { } //------------------------------------------------------------------------------------------------- -/** This class implements the conversion of an arbitrary string into a unique - * integer "key". Calling the nameToKey() method with the same string is - * guaranteed to return the same key. Also, all keys generated by an - * instance of this class are guaranteed to be unique with respect to that - * instance's catalog of names. Multiple instances of this class can be - * created to service multiple namespaces. */ +// This class implements the conversion of an arbitrary string into a unique +// integer "key". Calling the nameToKey() method with the same string is +// guaranteed to return the same key. Also, all keys generated by an +// instance of this class are guaranteed to be unique with respect to that +// instance's catalog of names. Multiple instances of this class can be +// created to service multiple namespaces. //------------------------------------------------------------------------------------------------- class NameKeyGenerator : public SubsystemInterface { @@ -95,23 +90,21 @@ class NameKeyGenerator : public SubsystemInterface virtual void update() { } /// Given a string, convert into a unique integer key. - NameKeyType nameToKey(const AsciiString& name) { return nameToKey(name.str()); } - NameKeyType nameToLowercaseKey(const AsciiString& name) { return nameToLowercaseKey(name.str()); } + NameKeyType nameToKey(const AsciiString& name); + NameKeyType nameToLowercaseKey(const AsciiString& name); /// Given a string, convert into a unique integer key. NameKeyType nameToKey(const char* name); NameKeyType nameToLowercaseKey(const char *name); - /** - given a key, return the name. this is almost never needed, - except for a few rare cases like object serialization. also - note that it's not particularly fast; it does a dumb linear - search for the key. - */ + // given a key, return the name. this is almost never needed, + // except for a few rare cases like object serialization. also + // note that it's not particularly fast; it does a dumb linear + // search for the key. AsciiString keyToName(NameKeyType key); - // Get a string out of the INI. Store it into a NameKeyType - static void parseStringAsNameKeyType( INI *ini, void *instance, void *store, const void* userData ); + // Get a string out of the INI. Store it into a NameKeyType + static void parseStringAsNameKeyType( INI *ini, void *instance, void *store, const void* userData ); private: @@ -123,12 +116,22 @@ class NameKeyGenerator : public SubsystemInterface SOCKET_COUNT = 6473 }; +#if RTS_ZEROHOUR && RETAIL_COMPATIBLE_CRC + Bool addReservedKey(); +#endif + + NameKeyType nameToKeyImpl(const AsciiString& name); + NameKeyType nameToLowercaseKeyImpl(const AsciiString& name); + NameKeyType nameToKeyImpl(const char* name); + NameKeyType nameToLowercaseKeyImpl(const char *name); + NameKeyType createNameKey(UnsignedInt hash, const AsciiString& name); + void freeSockets(); Bucket* m_sockets[SOCKET_COUNT]; ///< Catalog of all Buckets already generated UnsignedInt m_nextID; ///< Next available ID -}; // end class NameKeyGenerator +}; //------------------------------------------------------------------------------------------------- // Externals @@ -151,8 +154,5 @@ class StaticNameKey StaticNameKey(const char* p) : m_key(NAMEKEY_INVALID), m_name(p) {} NameKeyType key() const; // ugh, this is a little hokey, but lets us pretend that a StaticNameKey == NameKeyType - inline operator NameKeyType() const { return key(); } + operator NameKeyType() const { return key(); } }; - -#endif // __NAMEKEYGENERATOR_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/OSDisplay.h b/Generals/Code/GameEngine/Include/Common/OSDisplay.h index b7e9cd6839..1385a944b1 100644 --- a/Generals/Code/GameEngine/Include/Common/OSDisplay.h +++ b/Generals/Code/GameEngine/Include/Common/OSDisplay.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __OSDISPLAY_H__ -#define __OSDISPLAY_H__ - #include "Lib/BaseType.h" class AsciiString; @@ -63,4 +60,6 @@ enum OSDisplayOtherFlags CPP_11(: UnsignedInt) // This function will return the button pressed to close the dialog. OSDisplayButtonType OSDisplayWarningBox(AsciiString p, AsciiString m, UnsignedInt buttonFlags, UnsignedInt otherFlags); -#endif /* __OSDISPLAY_H__ */ +// TheSuperHackers @feature Tell the Operating System that the game is considered busy +// and we would not like the display screen and/or system to shut off. +void OSDisplaySetBusyState(Bool busyDisplay, Bool busySystem); diff --git a/Generals/Code/GameEngine/Include/Common/ObjectStatusTypes.h b/Generals/Code/GameEngine/Include/Common/ObjectStatusTypes.h deleted file mode 100644 index 200431fe62..0000000000 --- a/Generals/Code/GameEngine/Include/Common/ObjectStatusTypes.h +++ /dev/null @@ -1,129 +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. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: ObjectStatusTypes.h ///////////////////////////////////////////////////////////////////////// -// Author: Kris, May 2003 -// Desc: Object status types that are stackable using the BitSet system. Used to be ObjectStatusBits -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#ifndef __OBJECT_STATUS_TYPES_H -#define __OBJECT_STATUS_TYPES_H - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "Lib/BaseType.h" -#include "Common/BitFlags.h" -#include "Common/BitFlagsIO.h" - -//------------------------------------------------------------------------------------------------- -/** Object status types */ -//------------------------------------------------------------------------------------------------- -enum ObjectStatusTypes CPP_11(: Int) -{ - //These are saved. Do not insert or remove any! - - OBJECT_STATUS_NONE, ///< no status bit - OBJECT_STATUS_DESTROYED, ///< has been destroyed, pending delete - OBJECT_STATUS_CAN_ATTACK, ///< used by garrissoned buildings, is OR'ed with KINDOF_CAN_ATTACK in isAbleToAttack() - OBJECT_STATUS_UNDER_CONSTRUCTION, ///< object is being constructed and is not yet complete - OBJECT_STATUS_UNSELECTABLE, ///< This is a negative condition since these statuses are overrides. ie their presence forces the condition, but their absence means nothing - OBJECT_STATUS_NO_COLLISIONS, ///< object should be ignored for object-object collisions (but not object-ground); used for thing like collapsing parachutes that are intangible - OBJECT_STATUS_NO_ATTACK, ///< Absolute override to being able to attack - OBJECT_STATUS_AIRBORNE_TARGET, ///< InTheAir as far as AntiAir weapons are concerned only. - OBJECT_STATUS_PARACHUTING, ///< object is on a parachute - OBJECT_STATUS_REPULSOR, ///< object repulses "KINDOF_CAN_BE_REPULSED" objects. - OBJECT_STATUS_HIJACKED, ///< unit is in the possesion of an enemy criminal, call the authorities - OBJECT_STATUS_AFLAME, ///< This object is on fire. - OBJECT_STATUS_BURNED, ///< This object has already burned as much as it can. - OBJECT_STATUS_WET, ///< object has been soaked with water - OBJECT_STATUS_IS_FIRING_WEAPON, ///< Object is firing a weapon, now. Not true for special attacks. --Lorenzen - OBJECT_STATUS_BRAKING, ///< Object is braking, and subverts the physics. - OBJECT_STATUS_STEALTHED, ///< Object is currently "stealthed" - OBJECT_STATUS_DETECTED, ///< Object is in range of a stealth-detector unit (meaningless if STEALTHED not set) - OBJECT_STATUS_CAN_STEALTH, ///< Object has ability to stealth allowing the stealth update module to run. - OBJECT_STATUS_SOLD, ///< Object is being sold - OBJECT_STATUS_UNDERGOING_REPAIR, ///< Object is awaiting/undergoing a repair order that has been issued - OBJECT_STATUS_RECONSTRUCTING, ///< Reconstructing - OBJECT_STATUS_MASKED, ///< Masked objects are not selectable and targetable by players or AI - OBJECT_STATUS_IS_ATTACKING, ///< Object is in the general Attack state (incl. aim, approach, etc.). Note that IS_FIRING_WEAPON and IS_AIMING_WEAPON is a subset of this! - OBJECT_STATUS_IS_USING_ABILITY, ///< Object is in the process of preparing or firing a special ability. - OBJECT_STATUS_IS_AIMING_WEAPON, ///< Object is aiming a weapon, now. Not true for special attacks. - OBJECT_STATUS_NO_ATTACK_FROM_AI, ///< attacking this object may not be done from commandSource == CMD_FROM_AI - OBJECT_STATUS_IGNORING_STEALTH, ///< temporarily ignoring all stealth bits. (used only for some special-case mine clearing stuff.) - OBJECT_STATUS_IS_CARBOMB, ///< Object is now a carbomb. - // add more status types here and don't forget to add to the string table ObjectStatusMaskType::s_bitNameList[] - - OBJECT_STATUS_COUNT - -}; - -typedef BitFlags ObjectStatusMaskType; - -#define MAKE_OBJECT_STATUS_MASK(k) ObjectStatusMaskType(ObjectStatusMaskType::kInit, (k)) -#define MAKE_OBJECT_STATUS_MASK2(k,a) ObjectStatusMaskType(ObjectStatusMaskType::kInit, (k), (a)) -#define MAKE_OBJECT_STATUS_MASK3(k,a,b) ObjectStatusMaskType(ObjectStatusMaskType::kInit, (k), (a), (b)) -#define MAKE_OBJECT_STATUS_MASK4(k,a,b,c) ObjectStatusMaskType(ObjectStatusMaskType::kInit, (k), (a), (b), (c)) -#define MAKE_OBJECT_STATUS_MASK5(k,a,b,c,d) ObjectStatusMaskType(ObjectStatusMaskType::kInit, (k), (a), (b), (c), (d)) - -inline Bool TEST_OBJECT_STATUS_MASK( const ObjectStatusMaskType& m, ObjectStatusTypes t ) -{ - return m.test( t ); -} - -inline Bool TEST_OBJECT_STATUS_MASK_ANY( const ObjectStatusMaskType& m, const ObjectStatusMaskType& mask ) -{ - return m.anyIntersectionWith( mask ); -} - -inline Bool TEST_OBJECT_STATUS_MASK_MULTI( const ObjectStatusMaskType& m, const ObjectStatusMaskType& mustBeSet, const ObjectStatusMaskType& mustBeClear ) -{ - return m.testSetAndClear( mustBeSet, mustBeClear ); -} - -inline Bool OBJECT_STATUS_MASK_ANY_SET( const ObjectStatusMaskType& m) -{ - return m.any(); -} - -inline void CLEAR_OBJECT_STATUS_MASK( ObjectStatusMaskType& m ) -{ - m.clear(); -} - -inline void SET_ALL_OBJECT_STATUS_MASK_BITS( ObjectStatusMaskType& m ) -{ - m.clear( ); - m.flip( ); -} - -inline void FLIP_OBJECT_STATUS_MASK( ObjectStatusMaskType& m ) -{ - m.flip(); -} - -// defined in Common/System/ObjectStatusTypes.cpp -extern ObjectStatusMaskType OBJECT_STATUS_MASK_NONE; // inits to all zeroes - -#endif /* __OBJECT_STATUS_TYPES_H */ diff --git a/Generals/Code/GameEngine/Include/Common/Overridable.h b/Generals/Code/GameEngine/Include/Common/Overridable.h index 68c91bb38d..f395127884 100644 --- a/Generals/Code/GameEngine/Include/Common/Overridable.h +++ b/Generals/Code/GameEngine/Include/Common/Overridable.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _OVERRIDABLE_H_ -#define _OVERRIDABLE_H_ - #include "Common/GameMemory.h" /* @@ -122,9 +119,5 @@ class Overridable : public MemoryPoolObject // cleans up and dangling overrides. __inline Overridable::~Overridable() { - if (m_nextOverride) - deleteInstance(m_nextOverride); + deleteInstance(m_nextOverride); } - - -#endif /* _OVERRIDABLE_H_ */ diff --git a/Generals/Code/GameEngine/Include/Common/Override.h b/Generals/Code/GameEngine/Include/Common/Override.h index 3811bec8ec..d89ee69324 100644 --- a/Generals/Code/GameEngine/Include/Common/Override.h +++ b/Generals/Code/GameEngine/Include/Common/Override.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _OVERRIDE_H_ -#define _OVERRIDE_H_ - #include "Common/Overridable.h" /* @@ -136,6 +133,3 @@ OVERRIDE::operator const T*( ) const { return operator*(); } - -#endif /* _OVERRIDE_H_ */ - diff --git a/Generals/Code/GameEngine/Include/Common/PartitionSolver.h b/Generals/Code/GameEngine/Include/Common/PartitionSolver.h index 3bf3cc377c..6487bb7448 100644 --- a/Generals/Code/GameEngine/Include/Common/PartitionSolver.h +++ b/Generals/Code/GameEngine/Include/Common/PartitionSolver.h @@ -38,8 +38,6 @@ /*---------------------------------------------------------------------------*/ #pragma once -#ifndef _H_PARTITIONSOLVER_ -#define _H_PARTITIONSOLVER_ // INCLUDES /////////////////////////////////////////////////////////////////// @@ -83,5 +81,3 @@ class PartitionSolver void solve(void); const SolutionVec& getSolution( void ) const; }; - -#endif /* _H_PARTITIONSOLVER_ */ diff --git a/Generals/Code/GameEngine/Include/Common/PerfMetrics.h b/Generals/Code/GameEngine/Include/Common/PerfMetrics.h index 43a5dd0db6..f2d82d8615 100644 --- a/Generals/Code/GameEngine/Include/Common/PerfMetrics.h +++ b/Generals/Code/GameEngine/Include/Common/PerfMetrics.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __PERFMETRICS_H__ -#define __PERFMETRICS_H__ - // For load timings enum { PERFMETRICS_LOAD_STARTFRAME = 0 }; enum { PERFMETRICS_LOAD_STOPFRAME = 1 }; @@ -42,7 +39,3 @@ enum { PERFMETRICS_LOGIC_STOPFRAME = 1000 }; // For showing metrics enum { PERFMETRICS_BETWEEN_METRICS = 150 }; - -#endif /* __PERFMETRICS_H__ */ - - diff --git a/Generals/Code/GameEngine/Include/Common/PerfTimer.h b/Generals/Code/GameEngine/Include/Common/PerfTimer.h index 0ff80a461b..071b35b348 100644 --- a/Generals/Code/GameEngine/Include/Common/PerfTimer.h +++ b/Generals/Code/GameEngine/Include/Common/PerfTimer.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __PERFTIMER_H__ -#define __PERFTIMER_H__ - #include "Utility/intrin_compat.h" #if defined(RTS_DEBUG) @@ -315,5 +312,3 @@ extern void StatMetricsDisplay( DebugDisplayInterface *dd, void *, FILE *fp ); #define IGNORE_PERF_TIMER(id) #endif // PERF_TIMERS - -#endif /* __PERFTIMER_H__ */ diff --git a/Generals/Code/GameEngine/Include/Common/Player.h b/Generals/Code/GameEngine/Include/Common/Player.h index 5fc1b8e850..69327b447f 100644 --- a/Generals/Code/GameEngine/Include/Common/Player.h +++ b/Generals/Code/GameEngine/Include/Common/Player.h @@ -44,9 +44,6 @@ #pragma once -#ifndef _PLAYER_H_ -#define _PLAYER_H_ - #include "Common/Debug.h" #include "Common/Energy.h" #include "Common/GameType.h" @@ -61,7 +58,6 @@ #include "Common/STLTypedefs.h" #include "Common/ScoreKeeper.h" #include "Common/Team.h" -#include "Common/STLTypedefs.h" #include "Common/Upgrade.h" // ---------------------------------------------------------------------------------------------- @@ -101,13 +97,14 @@ enum ScienceAvailabilityType CPP_11(: Int) }; #ifdef DEFINE_SCIENCE_AVAILABILITY_NAMES -static const char *ScienceAvailabilityNames[] = +static const char *const ScienceAvailabilityNames[] = { "Available", "Disabled", "Hidden", NULL }; +static_assert(ARRAY_SIZE(ScienceAvailabilityNames) == SCIENCE_AVAILABILITY_COUNT + 1, "Incorrect array size"); #endif // end DEFINE_SCIENCE_AVAILABILITY_NAMES static const Int NUM_HOTKEY_SQUADS = 10; @@ -222,42 +219,42 @@ class Player : public Snapshot void deletePlayerAI(); - inline UnicodeString getPlayerDisplayName() { return m_playerDisplayName; } - inline NameKeyType getPlayerNameKey() const { return m_playerNameKey; } + UnicodeString getPlayerDisplayName() { return m_playerDisplayName; } + NameKeyType getPlayerNameKey() const { return m_playerNameKey; } - inline AsciiString getSide() const { return m_side; } + AsciiString getSide() const { return m_side; } - inline const PlayerTemplate* getPlayerTemplate() const { return m_playerTemplate; } + const PlayerTemplate* getPlayerTemplate() const { return m_playerTemplate; } /// return the Player's Handicap sub-object - inline const Handicap *getHandicap() const { return &m_handicap; } - inline Handicap *getHandicap() { return &m_handicap; } + const Handicap *getHandicap() const { return &m_handicap; } + Handicap *getHandicap() { return &m_handicap; } /// return the Player's Money sub-object - inline Money *getMoney() { return &m_money; } - inline const Money *getMoney() const { return &m_money; } + Money *getMoney() { return &m_money; } + const Money *getMoney() const { return &m_money; } UnsignedInt getSupplyBoxValue();///< Many things can affect the alue of a crate, but at heart it is a GlobalData ratio. - inline Energy *getEnergy() { return &m_energy; } - inline const Energy *getEnergy() const { return &m_energy; } + Energy *getEnergy() { return &m_energy; } + const Energy *getEnergy() const { return &m_energy; } // adds a power bonus to this player because of energy upgrade at his power plants - inline void addPowerBonus(Object *obj) { m_energy.addPowerBonus(obj); } - inline void removePowerBonus(Object *obj) { m_energy.removePowerBonus(obj); } + void addPowerBonus(Object *obj) { m_energy.addPowerBonus(obj); } + void removePowerBonus(Object *obj) { m_energy.removePowerBonus(obj); } - inline ResourceGatheringManager *getResourceGatheringManager(){ return m_resourceGatheringManager; } - inline TunnelTracker* getTunnelSystem(){ return m_tunnelSystem; } + ResourceGatheringManager *getResourceGatheringManager(){ return m_resourceGatheringManager; } + TunnelTracker* getTunnelSystem(){ return m_tunnelSystem; } - inline Color getPlayerColor() const { return m_color; } - inline Color getPlayerNightColor() const { return m_nightColor;} + Color getPlayerColor() const { return m_color; } + Color getPlayerNightColor() const { return m_nightColor;} /// return the type of controller - inline PlayerType getPlayerType() const { return m_playerType; } + PlayerType getPlayerType() const { return m_playerType; } void setPlayerType(PlayerType t, Bool skirmish); - inline PlayerIndex getPlayerIndex() const { return m_playerIndex; } + PlayerIndex getPlayerIndex() const { return m_playerIndex; } /// return a bitmask that is unique to this player. - inline PlayerMaskType getPlayerMask() const { return 1 << m_playerIndex; } + PlayerMaskType getPlayerMask() const { return 1 << m_playerIndex; } /// a convenience function to test the ThingTemplate against the players canBuild flags /// called by canBuild @@ -291,8 +288,8 @@ class Player : public Snapshot /// return t iff the player has all sciences that are prereqs for knowing the given science Bool hasPrereqsForScience(ScienceType t) const; - Bool hasUpgradeComplete( const UpgradeTemplate *upgradeTemplate ); ///< does player have totally done and produced upgrade - Bool hasUpgradeComplete( UpgradeMaskType testMask ); ///< does player have totally done and produced upgrade + Bool hasUpgradeComplete( const UpgradeTemplate *upgradeTemplate ) const; ///< does player have totally done and produced upgrade + Bool hasUpgradeComplete( UpgradeMaskType testMask ) const; ///< does player have totally done and produced upgrade UpgradeMaskType getCompletedUpgradeMask() const { return m_upgradesCompleted; } ///< get list of upgrades that are completed Bool hasUpgradeInProduction( const UpgradeTemplate *upgradeTemplate ); ///< does player have this upgrade in progress right now Upgrade *addUpgrade( const UpgradeTemplate *upgradeTemplate, @@ -531,9 +528,9 @@ class Player : public Snapshot void removeTeamFromList(TeamPrototype* team); typedef std::list PlayerTeamList; - inline const PlayerTeamList* getPlayerTeams() const { return &m_playerTeamPrototypes; } + const PlayerTeamList* getPlayerTeams() const { return &m_playerTeamPrototypes; } - inline Int getMpStartIndex(void) {return m_mpStartIndex;} + Int getMpStartIndex(void) {return m_mpStartIndex;} /// Set that all units should begin hunting. void setUnitsShouldHunt(Bool unitsShouldHunt, CommandSourceType source); @@ -593,9 +590,9 @@ class Player : public Snapshot Bool isPlayableSide( void ) const; - Bool isPlayerObserver( void ) const; // Favor !isActive() - this is used for Observer GUI mostly, not in-game stuff - Bool isPlayerDead(void) const; // Favor !isActive() - this is used so OCLs don't give us stuff after death. - Bool isPlayerActive(void) const; + Bool isPlayerObserver( void ) const; // Favor !isPlayerActive() - this is used for Observer GUI mostly, not in-game stuff + Bool isPlayerDead(void) const; // Favor !isPlayerActive() - this is used so OCLs don't give us stuff after death. + Bool isPlayerActive(void) const; // Player is alive and not observer. !isPlayerActive() is synonymous with observing. Bool didPlayerPreorder( void ) const { return m_isPreorder; } @@ -603,7 +600,7 @@ class Player : public Snapshot ScoreKeeper* getScoreKeeper( void ) { return &m_scoreKeeper; } /// time to create a hotkey team based on this GameMessage - void processCreateTeamGameMessage(Int hotkeyNum, GameMessage *msg); + void processCreateTeamGameMessage(Int hotkeyNum, const GameMessage *msg); /// time to select a hotkey team based on this GameMessage void processSelectTeamGameMessage(Int hotkeyNum, GameMessage *msg); @@ -792,5 +789,3 @@ class Player : public Snapshot Bool m_isPlayerDead; }; - -#endif // _PLAYER_H_ diff --git a/Generals/Code/GameEngine/Include/Common/PlayerList.h b/Generals/Code/GameEngine/Include/Common/PlayerList.h index 8dc008e9ae..2f0362b489 100644 --- a/Generals/Code/GameEngine/Include/Common/PlayerList.h +++ b/Generals/Code/GameEngine/Include/Common/PlayerList.h @@ -44,9 +44,6 @@ #pragma once -#ifndef _PLAYERLIST_H_ -#define _PLAYERLIST_H_ - #include "Common/SubsystemInterface.h" #include "Common/GameCommon.h" #include "Common/NameKeyGenerator.h" @@ -171,5 +168,3 @@ class PlayerList : public SubsystemInterface, // ---------------------------------------------------------------------------------------------- extern PlayerList *ThePlayerList; ///< singleton instance of PlayerList - -#endif // _PLAYERLIST_H_ diff --git a/Generals/Code/GameEngine/Include/Common/PlayerTemplate.h b/Generals/Code/GameEngine/Include/Common/PlayerTemplate.h index fe00b24358..1caf422167 100644 --- a/Generals/Code/GameEngine/Include/Common/PlayerTemplate.h +++ b/Generals/Code/GameEngine/Include/Common/PlayerTemplate.h @@ -44,9 +44,6 @@ #pragma once -#ifndef _PLAYERTEMPLATE_H_ -#define _PLAYERTEMPLATE_H_ - #include "Common/SubsystemInterface.h" #include "Common/GameMemory.h" #include "Common/Debug.h" @@ -77,35 +74,35 @@ class PlayerTemplate PlayerTemplate(); - inline void setNameKey(NameKeyType namekey) { m_nameKey = namekey; } + void setNameKey(NameKeyType namekey) { m_nameKey = namekey; } - inline NameKeyType getNameKey() const { DEBUG_ASSERTCRASH(m_nameKey != NAMEKEY_INVALID, ("bad namekey")); return m_nameKey; } - inline AsciiString getName() const { return KEYNAME(m_nameKey); } + NameKeyType getNameKey() const { DEBUG_ASSERTCRASH(m_nameKey != NAMEKEY_INVALID, ("bad namekey")); return m_nameKey; } + AsciiString getName() const { return KEYNAME(m_nameKey); } - inline UnicodeString getDisplayName() const { return m_displayName; } + UnicodeString getDisplayName() const { return m_displayName; } - inline AsciiString getSide() const { return m_side; } + AsciiString getSide() const { return m_side; } /// return the tech tree for the player. - inline const Handicap *getHandicap() const { return &m_handicap; } + const Handicap *getHandicap() const { return &m_handicap; } /// return the money for the player. - inline const Money *getMoney() const { return &m_money; } + const Money *getMoney() const { return &m_money; } - inline const RGBColor* getPreferredColor() const { return &m_preferredColor; } + const RGBColor* getPreferredColor() const { return &m_preferredColor; } - inline AsciiString getStartingBuilding( void ) const { return m_startingBuilding; } + AsciiString getStartingBuilding( void ) const { return m_startingBuilding; } AsciiString getStartingUnit( Int i ) const; - inline const ProductionChangeMap& getProductionCostChanges() const { return m_productionCostChanges; } - inline const ProductionChangeMap& getProductionTimeChanges() const { return m_productionTimeChanges; } - inline const ProductionVeterancyMap& getProductionVeterancyLevels() const { return m_productionVeterancyLevels; } - inline Bool isObserver() const { return m_observer; } - inline Bool isPlayableSide() const { return m_playableSide; } + const ProductionChangeMap& getProductionCostChanges() const { return m_productionCostChanges; } + const ProductionChangeMap& getProductionTimeChanges() const { return m_productionTimeChanges; } + const ProductionVeterancyMap& getProductionVeterancyLevels() const { return m_productionVeterancyLevels; } + Bool isObserver() const { return m_observer; } + Bool isPlayableSide() const { return m_playableSide; } - inline AsciiString getScoreScreen (void ) const { return m_scoreScreenImage; } - inline AsciiString getLoadScreen (void ) const { return m_loadScreenImage; } - inline AsciiString getBeaconTemplate( void ) const { return m_beaconTemplate; } + AsciiString getScoreScreen (void ) const { return m_scoreScreenImage; } + AsciiString getLoadScreen (void ) const { return m_loadScreenImage; } + AsciiString getBeaconTemplate( void ) const { return m_beaconTemplate; } const Image *getHeadWaterMarkImage( void ) const; const Image *getFlagWaterMarkImage( void ) const; @@ -114,6 +111,7 @@ class PlayerTemplate //const Image *getHiliteImage( void ) const; //const Image *getPushedImage( void ) const; const Image *getSideIconImage( void ) const; + const AsciiString getTooltip() const { return m_tooltip; } const ScienceVec& getIntrinsicSciences() const { return m_intrinsicSciences; } Int getIntrinsicSciencePurchasePoints() const { return m_intrinsicSPP; } @@ -161,6 +159,7 @@ class PlayerTemplate AsciiString m_specialPowerShortcutWinName; ///< The name of the window we'll be using for the shortcut bar Int m_specialPowerShortcutButtonCount; ///< The number of buttons located on the shortcut bar AsciiString m_loadScreenMusic; ///< the load screen music we want to play + AsciiString m_tooltip; ///< The tooltip describing this player template Bool m_observer; Bool m_playableSide; @@ -199,7 +198,7 @@ class PlayerTemplateStore : public SubsystemInterface const PlayerTemplate* getNthPlayerTemplate(Int i) const; const PlayerTemplate* findPlayerTemplate(NameKeyType namekey) const; - inline Int getPlayerTemplateCount() const { return m_playerTemplates.size(); } + Int getPlayerTemplateCount() const { return m_playerTemplates.size(); } // This function will fill outStringList with all the sides found in all the templates @@ -214,5 +213,3 @@ class PlayerTemplateStore : public SubsystemInterface // ---------------------------------------------------------------------------------------------- extern PlayerTemplateStore *ThePlayerTemplateStore; ///< singleton instance of PlayerTemplateStore - -#endif // _PLAYERTEMPLATE_H_ diff --git a/Generals/Code/GameEngine/Include/Common/ProductionPrerequisite.h b/Generals/Code/GameEngine/Include/Common/ProductionPrerequisite.h index c36323bb5e..a6f97ad35d 100644 --- a/Generals/Code/GameEngine/Include/Common/ProductionPrerequisite.h +++ b/Generals/Code/GameEngine/Include/Common/ProductionPrerequisite.h @@ -42,9 +42,6 @@ #pragma once -#ifndef __ProductionPrerequisite_H_ -#define __ProductionPrerequisite_H_ - //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- @@ -121,5 +118,3 @@ class ProductionPrerequisite }; //----------------------------------------------------------------------------- - -#endif diff --git a/Generals/Code/GameEngine/Include/Common/QuickmatchPreferences.h b/Generals/Code/GameEngine/Include/Common/QuickmatchPreferences.h index 38301af8b6..fdf0d8fe99 100644 --- a/Generals/Code/GameEngine/Include/Common/QuickmatchPreferences.h +++ b/Generals/Code/GameEngine/Include/Common/QuickmatchPreferences.h @@ -30,9 +30,6 @@ #pragma once -#ifndef __QUICKMATCHPREFERENCES_H__ -#define __QUICKMATCHPREFERENCES_H__ - //----------------------------------------------------------------------------- // USER INCLUDES ////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -78,5 +75,3 @@ class QuickMatchPreferences : public UserPreferences void setSide(Int val); Int getSide( void ); }; - -#endif // __QUICKMATCHPREFERENCES_H__ diff --git a/Generals/Code/GameEngine/Include/Common/QuotedPrintable.h b/Generals/Code/GameEngine/Include/Common/QuotedPrintable.h index d4b481a851..af373e9bb6 100644 --- a/Generals/Code/GameEngine/Include/Common/QuotedPrintable.h +++ b/Generals/Code/GameEngine/Include/Common/QuotedPrintable.h @@ -29,13 +29,8 @@ #pragma once -#ifndef __QUOTEDPRINTABLE_H__ -#define __QUOTEDPRINTABLE_H__ - UnicodeString QuotedPrintableToUnicodeString(AsciiString original); AsciiString UnicodeStringToQuotedPrintable(UnicodeString original); AsciiString QuotedPrintableToAsciiString(AsciiString original); AsciiString AsciiStringToQuotedPrintable(AsciiString original); - -#endif // __QUOTEDPRINTABLE_H__ diff --git a/Generals/Code/GameEngine/Include/Common/Radar.h b/Generals/Code/GameEngine/Include/Common/Radar.h deleted file mode 100644 index 5b3dbbdfb8..0000000000 --- a/Generals/Code/GameEngine/Include/Common/Radar.h +++ /dev/null @@ -1,314 +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. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: Radar.h ////////////////////////////////////////////////////////////////////////////////// -// Author: Colin Day, January 2002 -// Desc: Logical radar implementation -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#ifndef __RADAR_H_ -#define __RADAR_H_ - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include "Lib/BaseType.h" -#include "Common/SubsystemInterface.h" -#include "Common/GameMemory.h" -#include "GameClient/Display.h" // for ShroudLevel -#include "GameClient/Color.h" - -// FORWARD REFERENCES ///////////////////////////////////////////////////////////////////////////// -class GameWindow; -class Object; -class Player; -class TerrainLogic; - -// GLOBAL ///////////////////////////////////////////////////////////////////////////////////////// -// -// the following is used for the resolution of the radar "cells" ... this is how accurate -// the radar is and also reflects directly the size of the image we build ... which with -// WW3D must be a square power of two as well -// -enum -{ - RADAR_CELL_WIDTH = 128, // radar created at this horz resolution - RADAR_CELL_HEIGHT = 128 // radar created at this vert resolution -}; - -//------------------------------------------------------------------------------------------------- -/** These event types determine the colors radar events happen in to make it easier for us - * to play events with a consistent color scheme */ -//------------------------------------------------------------------------------------------------- -enum RadarEventType CPP_11(: Int) -{ - RADAR_EVENT_INVALID = 0, - RADAR_EVENT_CONSTRUCTION, - RADAR_EVENT_UPGRADE, - RADAR_EVENT_UNDER_ATTACK, - RADAR_EVENT_INFORMATION, - RADAR_EVENT_BEACON_PULSE, - RADAR_EVENT_INFILTRATION, //for defection, hijacking, hacking, carbombing, and other sneaks - RADAR_EVENT_BATTLE_PLAN, - RADAR_EVENT_STEALTH_DISCOVERED, // we discovered a stealth unit - RADAR_EVENT_STEALTH_NEUTRALIZED, // our stealth unit has been revealed - RADAR_EVENT_FAKE, //Internally creates a radar event, but doesn't notify the player (unit lost - //for example, so we can use the spacebar to jump to the event). - - RADAR_EVENT_NUM_EVENTS // keep this last - -}; - -enum RadarObjectType CPP_11(: Int) -{ - RadarObjectType_None = 0, - RadarObjectType_Regular, - RadarObjectType_Local, -}; - -// PROTOTYPES ///////////////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------------------------------- -/** Radar objects are objects that are on the radar, go figure :) */ -//------------------------------------------------------------------------------------------------- -class RadarObject : public MemoryPoolObject, - public Snapshot -{ - - MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE( RadarObject, "RadarObject" ) - -public: - - RadarObject( void ); - // destructor prototype defined by memory pool glue - - // color management - void setColor( Color c ) { m_color = c; } - inline Color getColor( void ) const { return m_color; } - - inline void friend_setObject( Object *obj ) { m_object = obj; } - inline Object *friend_getObject( void ) { return m_object; } - inline const Object *friend_getObject( void ) const { return m_object; } - - inline void friend_setNext( RadarObject *next ) { m_next = next; } - inline RadarObject *friend_getNext( void ) { return m_next; } - inline const RadarObject *friend_getNext( void ) const { return m_next; } - - Bool isTemporarilyHidden() const; - static Bool isTemporarilyHidden(const Object* obj); - -protected: - - // snapshot methods - virtual void crc( Xfer *xfer ); - virtual void xfer( Xfer *xfer ); - virtual void loadPostProcess( void ); - - Object *m_object; ///< the object - RadarObject *m_next; ///< next radar object - Color m_color; ///< color to draw for this object on the radar - -}; - -//------------------------------------------------------------------------------------------------- -/** Radar priorities. Keep this in sync with the priority names list below */ -//------------------------------------------------------------------------------------------------- -enum RadarPriorityType CPP_11(: Int) -{ - RADAR_PRIORITY_INVALID, // a priority that has not been set (in general it won't show up on the radar) - RADAR_PRIORITY_NOT_ON_RADAR, // object specifically forbidden from being on the radar - RADAR_PRIORITY_STRUCTURE, // structure level drawing priority - RADAR_PRIORITY_UNIT, // unit level drawing priority - RADAR_PRIORITY_LOCAL_UNIT_ONLY, // unit priority, but only on the radar if controlled by the local player - - RADAR_PRIORITY_NUM_PRIORITIES // keep this last -}; -#ifdef DEFINE_RADAR_PRIORITY_NAMES -static const char *RadarPriorityNames[] = -{ - "INVALID", // a priority that has not been set (in general it won't show up on the radar) - "NOT_ON_RADAR", // object specifically forbidden from being on the radar - "STRUCTURE", // structure level drawing priority - "UNIT", // unit level drawing priority - "LOCAL_UNIT_ONLY", // unit priority, but only on the radar if controlled by the local player - - NULL // keep this last -}; -#endif // DEFINE_RADAR_PRIOTITY_NAMES - -//------------------------------------------------------------------------------------------------- -/** Interface for the radar */ -//------------------------------------------------------------------------------------------------- -class Radar : public Snapshot, - public SubsystemInterface -{ - -public: - - Radar( void ); - virtual ~Radar( void ); - - virtual void init( void ) { } ///< subsystem initialization - virtual void reset( void ); ///< subsystem reset - virtual void update( void ); ///< subsystem per frame update - - // is the game window parameter the radar window - Bool isRadarWindow( GameWindow *window ) { return (m_radarWindow == window) && (m_radarWindow != NULL); } - - Bool radarToWorld( const ICoord2D *radar, Coord3D *world ); ///< radar point to world point on terrain - Bool radarToWorld2D( const ICoord2D *radar, Coord3D *world ); ///< radar point to world point (x,y only!) - Bool worldToRadar( const Coord3D *world, ICoord2D *radar ); ///< translate world point to radar (x,y) - Bool localPixelToRadar( const ICoord2D *pixel, ICoord2D *radar ); ///< translate pixel (with UL of radar being (0,0)) to logical radar coords - Bool screenPixelToWorld( const ICoord2D *pixel, Coord3D *world ); ///< translate pixel (with UL of the screen being (0,0)) to world position in the world - Object *objectUnderRadarPixel( const ICoord2D *pixel ); ///< return the object (if any) represented by the pixel coords passed in - void findDrawPositions( Int startX, Int startY, Int width, Int height, - ICoord2D *ul, ICoord2D *lr ); ///< make translation for screen area of radar square to scaled aspect ratio preserving points inside the radar area - - // priority inquiry - static Bool isPriorityVisible( RadarPriorityType priority ); ///< is the priority passed in a "visible" one on the radar - - // radar events - void createEvent( const Coord3D *world, RadarEventType type, Real secondsToLive = 4.0f ); ///< create radar event at location in world - void createPlayerEvent( Player *player, const Coord3D *world, RadarEventType type, Real secondsToLive = 4.0f ); ///< create radar event using player colors - - Bool getLastEventLoc( Coord3D *eventPos ); ///< get last event loc (if any) - void tryUnderAttackEvent( const Object *obj ); ///< try to make an "under attack" event if it's the proper time - void tryInfiltrationEvent( const Object *obj ); ///< try to make an "infiltration" event if it's the proper time - Bool tryEvent( RadarEventType event, const Coord3D *pos ); ///< try to make a "stealth" event - - // adding and removing objects from the radar - virtual RadarObjectType addObject( Object *obj ); ///< add object to radar - virtual RadarObjectType removeObject( Object *obj ); ///< remove object from radar - - // radar options - void hide( Bool hide ) { m_radarHidden = hide; } ///< hide/unhide the radar - Bool isRadarHidden( void ) { return m_radarHidden; } ///< is radar hidden - // other radar option methods here like the ability to show a certain - // team, show buildings, show units at all, etc - - // forcing the radar on/off regardless of player situation - void forceOn( Bool force ) { m_radarForceOn = force; } ///< force the radar to be on - Bool isRadarForced( void ) { return m_radarForceOn; } ///< is radar forced on? - - /// refresh the water values for the radar - virtual void refreshTerrain( TerrainLogic *terrain ); - - /// queue a refresh of the terran at the next available time - virtual void queueTerrainRefresh( void ); - - virtual void newMap( TerrainLogic *terrain ); ///< reset radar for new map - - virtual void draw( Int pixelX, Int pixelY, Int width, Int height ) = 0; ///< draw the radar - - /// empty the entire shroud - virtual void clearShroud() = 0; - - /// set the shroud level at shroud cell x,y - virtual void setShroudLevel( Int x, Int y, CellShroudStatus setting ) = 0; - -protected: - - // snapshot methods - virtual void crc( Xfer *xfer ); - virtual void xfer( Xfer *xfer ); - virtual void loadPostProcess( void ); - - /// internal method for creating a radar event with specific colors - void internalCreateEvent( const Coord3D *world, RadarEventType type, Real secondsToLive, - const RGBAColorInt *color1, const RGBAColorInt *color2 ); - - void deleteListResources( void ); ///< delete list radar resources used - Bool deleteFromList( Object *obj, RadarObject **list ); ///< try to remove object from specific list - - inline Real getTerrainAverageZ() const { return m_terrainAverageZ; } - inline Real getWaterAverageZ() const { return m_waterAverageZ; } - inline const RadarObject* getObjectList() const { return m_objectList; } - inline const RadarObject* getLocalObjectList() const { return m_localObjectList; } - - void clearAllEvents( void ); ///< remove all radar events in progress - - // search the object list for an object that maps to the given logical radar coords - Object *searchListForRadarLocationMatch( RadarObject *listHead, ICoord2D *radarMatch ); - - Bool m_radarHidden; ///< true when radar is not visible - Bool m_radarForceOn; ///< true when radar is forced to be on - RadarObject *m_objectList; ///< list of objects in the radar - RadarObject *m_localObjectList; /** list of objects for the local player, sorted - * in exactly the same priority as the regular - * object list for all other objects */ - - Real m_terrainAverageZ; ///< average Z for terrain samples - Real m_waterAverageZ; ///< average Z for water samples - - // - // when dealing with world sampling we will sample at these intervals so that - // the whole map can be accounted for within our RADAR_CELL_WIDTH and - // RADAR_CELL_HEIGHT resolutions - // - Real m_xSample; - Real m_ySample; - - enum { MAX_RADAR_EVENTS = 64 }; - struct RadarEvent - { - RadarEventType type; ///< type of this radar event - Bool active; ///< TRUE when event is "active", otherwise it's just historical information in the event array to look through - UnsignedInt createFrame; ///< frame event was created on - UnsignedInt dieFrame; ///< frame the event will go away on - UnsignedInt fadeFrame; ///< start fading out on this frame - RGBAColorInt color1; ///< color 1 for drawing - RGBAColorInt color2; ///< color 2 for drawing - Coord3D worldLoc; ///< location of event in the world - ICoord2D radarLoc; ///< 2D radar location of the event - Bool soundPlayed; ///< TRUE when we have played the radar sound for this - }; - RadarEvent m_event[ MAX_RADAR_EVENTS ];///< our radar events - Int m_nextFreeRadarEvent; ///< index into m_event for where to store the next event - Int m_lastRadarEvent; ///< index of the most recent radar event - - GameWindow *m_radarWindow; ///< window we display the radar in - - Region3D m_mapExtent; ///< extents of the current map - - UnsignedInt m_queueTerrainRefreshFrame; ///< frame we requested the last terrain refresh on - -}; - -// EXTERNALS ////////////////////////////////////////////////////////////////////////////////////// -extern Radar *TheRadar; ///< the radar singleton extern - -// TheSuperHackers @feature helmutbuhler 10/04/2025 -// Radar that does nothing. Used for Headless Mode. -class RadarDummy : public Radar -{ -public: - virtual void draw(Int pixelX, Int pixelY, Int width, Int height) { } - virtual void clearShroud() { } - virtual void setShroudLevel(Int x, Int y, CellShroudStatus setting) { } -}; - -#endif // __RADAR_H_ - - - diff --git a/Generals/Code/GameEngine/Include/Common/Recorder.h b/Generals/Code/GameEngine/Include/Common/Recorder.h index bbaa17a3f2..e1b98b6ae7 100644 --- a/Generals/Code/GameEngine/Include/Common/Recorder.h +++ b/Generals/Code/GameEngine/Include/Common/Recorder.h @@ -22,7 +22,6 @@ // // //////////////////////////////////////////////////////////////////////////////// - #pragma once #include "Common/MessageStream.h" @@ -118,9 +117,10 @@ class RecorderClass : public SubsystemInterface { Bool isPlaybackMode() const { return m_mode == RECORDERMODETYPE_PLAYBACK || m_mode == RECORDERMODETYPE_SIMULATION_PLAYBACK; } void initControls(); ///< Show or Hide the Replay controls - AsciiString getReplayDir(); ///< Returns the directory that holds the replay files. - static AsciiString getReplayExtention(); ///< Returns the file extention for replay files. - AsciiString getLastReplayFileName(); ///< Returns the filename used for the default replay. + static AsciiString getReplayDir(); ///< Returns the directory that holds the replay files. + static AsciiString getReplayArchiveDir(); ///< Returns the directory that holds the archived replay files. + static AsciiString getReplayExtention(); ///< Returns the file extention for replay files. + static AsciiString getLastReplayFileName(); ///< Returns the filename used for the default replay. GameInfo *getGameInfo( void ) { return &m_gameInfo; } ///< Returns the slot list for playback game start @@ -133,10 +133,12 @@ class RecorderClass : public SubsystemInterface { Bool sawCRCMismatch() const; void cleanUpReplayFile( void ); ///< after a crash, send replay/debug info to a central repository + void setArchiveEnabled(Bool enable) { m_archiveReplays = enable; } ///< Enable or disable replay archiving. void stopRecording(); ///< Stop recording and close m_file. protected: void startRecording(GameDifficulty diff, Int originalGameMode, Int rankPoints, Int maxFPS); ///< Start recording to m_file. void writeToFile(GameMessage *msg); ///< Write this GameMessage to m_file. + void archiveReplay(AsciiString fileName); ///< Move the specified replay file to the archive directory. void logGameStart(AsciiString options); void logGameEnd( void ); @@ -167,6 +169,7 @@ class RecorderClass : public SubsystemInterface { Bool m_wasDesync; Bool m_doingAnalysis; + Bool m_archiveReplays; ///< if true, each replay is archived to the replay archive folder after recording Int m_originalGameMode; // valid in replays diff --git a/Generals/Code/GameEngine/Include/Common/Registry.h b/Generals/Code/GameEngine/Include/Common/Registry.h index fff1c836aa..83ecb7dd24 100644 --- a/Generals/Code/GameEngine/Include/Common/Registry.h +++ b/Generals/Code/GameEngine/Include/Common/Registry.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __REGISTRY_H__ -#define __REGISTRY_H__ - #include /** @@ -47,5 +44,3 @@ AsciiString GetRegistryLanguage(void); // convenience function AsciiString GetRegistryGameName(void); // convenience function UnsignedInt GetRegistryVersion(void); // convenience function UnsignedInt GetRegistryMapPackVersion(void); // convenience function - -#endif // __REGISTRY_H__ diff --git a/Generals/Code/GameEngine/Include/Common/ResourceGatheringManager.h b/Generals/Code/GameEngine/Include/Common/ResourceGatheringManager.h index 0f9f052a6b..437f6d2fdd 100644 --- a/Generals/Code/GameEngine/Include/Common/ResourceGatheringManager.h +++ b/Generals/Code/GameEngine/Include/Common/ResourceGatheringManager.h @@ -30,9 +30,6 @@ #pragma once -#ifndef RESOURCE_GATHER_MANAGER_H -#define RESOURCE_GATHER_MANAGER_H - #include "Common/GameType.h" #include "Common/Snapshot.h" @@ -72,5 +69,3 @@ class ResourceGatheringManager : public MemoryPoolObject, objectIDList m_supplyCenters; }; - -#endif diff --git a/Generals/Code/GameEngine/Include/Common/STLTypedefs.h b/Generals/Code/GameEngine/Include/Common/STLTypedefs.h index 8c14a14973..484b3f33e8 100644 --- a/Generals/Code/GameEngine/Include/Common/STLTypedefs.h +++ b/Generals/Code/GameEngine/Include/Common/STLTypedefs.h @@ -44,9 +44,6 @@ #pragma once -#ifndef __STLTYPEDEFS_H__ -#define __STLTYPEDEFS_H__ - //----------------------------------------------------------------------------- // srj sez: this must come first, first, first. #define _STLP_USE_NEWALLOC 1 @@ -58,7 +55,6 @@ class STLSpecialAlloc; #include "Common/UnicodeString.h" #include "Common/GameCommon.h" #include "Common/GameMemory.h" -#include "Common/STLUtils.h" //----------------------------------------------------------------------------- @@ -74,6 +70,7 @@ enum DrawableID CPP_11(: Int); #include #include #include +#include #include #include #include @@ -177,10 +174,24 @@ namespace rts } }; + template<> struct hash + { + size_t operator()(const Char* s) const + { +#ifdef USING_STLPORT + std::hash hasher; + return hasher(s); +#else + std::hash hasher; + return hasher(s); +#endif + } + }; + // This is the equal_to overload for char* comparisons. We compare the // strings to determine whether they are equal or not. // Other overloads should go into specific header files, not here (unless - // they are ot be used in lots of places.) + // they are to be used in lots of places.) template<> struct equal_to { Bool operator()(const char* s1, const char* s2) const @@ -227,6 +238,60 @@ namespace rts return (__t1.compareNoCase(__t2) < 0); } }; -} -#endif /* __STLTYPEDEFS_H__ */ + // TheSuperHackers @info Structs to help create maps that can use C strings for + // lookups without the need to allocate a string. + template + struct string_key + { + typedef typename String::const_pointer const_pointer; + + static string_key temporary(const_pointer s) + { + string_key key; + key.cstr = s; + return key; + } + + string_key(const_pointer s) + : storage(s) + , cstr(storage.str()) + {} + + string_key(const String& s) + : storage(s) + , cstr(storage.str()) + {} + + const_pointer c_str() const + { + return cstr; + } + + private: + string_key() {} + + String storage; + const_pointer cstr; + }; + + template + struct string_key_hash + { + typedef typename String::const_pointer const_pointer; + size_t operator()(const string_key& key) const + { + return hash()(key.c_str()); + } + }; + + template + struct string_key_equal + { + bool operator()(const string_key& a, const string_key& b) const + { + return strcmp(a.c_str(), b.c_str()) == 0; + } + }; + +} // namespace rts diff --git a/Generals/Code/GameEngine/Include/Common/Science.h b/Generals/Code/GameEngine/Include/Common/Science.h index 235e3e279e..f7bfcd6ce0 100644 --- a/Generals/Code/GameEngine/Include/Common/Science.h +++ b/Generals/Code/GameEngine/Include/Common/Science.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __SCIENCE_H_ -#define __SCIENCE_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Common/Overridable.h" #include "Common/NameKeyGenerator.h" @@ -134,7 +131,3 @@ class ScienceStore : public SubsystemInterface }; extern ScienceStore* TheScienceStore; - - -#endif // __SCIENCE_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/ScopedMutex.h b/Generals/Code/GameEngine/Include/Common/ScopedMutex.h index fa898d94dc..aadd9531e2 100644 --- a/Generals/Code/GameEngine/Include/Common/ScopedMutex.h +++ b/Generals/Code/GameEngine/Include/Common/ScopedMutex.h @@ -23,9 +23,6 @@ #pragma once -#ifndef __SCOPEDMUTEX_H__ -#define __SCOPEDMUTEX_H__ - class ScopedMutex { private: @@ -42,5 +39,3 @@ class ScopedMutex ReleaseMutex(m_mutex); } }; - -#endif /* __SCOPEDMUTEX_H__ */ diff --git a/Generals/Code/GameEngine/Include/Common/ScoreKeeper.h b/Generals/Code/GameEngine/Include/Common/ScoreKeeper.h index f9d0be05b2..98bf12b894 100644 --- a/Generals/Code/GameEngine/Include/Common/ScoreKeeper.h +++ b/Generals/Code/GameEngine/Include/Common/ScoreKeeper.h @@ -45,9 +45,6 @@ #pragma once -#ifndef __SCOREKEEPER_H_ -#define __SCOREKEEPER_H_ - //----------------------------------------------------------------------------- // SYSTEM INCLUDES //////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -141,5 +138,3 @@ inline void ScoreKeeper::addMoneyEarned( Int money ) { m_totalMoneyEarned + //----------------------------------------------------------------------------- // EXTERNALS ////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- - -#endif // __SCOREKEEPER_H_ diff --git a/Generals/Code/GameEngine/Include/Common/SkirmishBattleHonors.h b/Generals/Code/GameEngine/Include/Common/SkirmishBattleHonors.h index 2e444e203b..ce1c68254d 100644 --- a/Generals/Code/GameEngine/Include/Common/SkirmishBattleHonors.h +++ b/Generals/Code/GameEngine/Include/Common/SkirmishBattleHonors.h @@ -30,9 +30,6 @@ #pragma once -#ifndef __SKIRMISHBATTLEHONORS_H__ -#define __SKIRMISHBATTLEHONORS_H__ - //----------------------------------------------------------------------------- // USER INCLUDES ////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -96,5 +93,3 @@ void InsertBattleHonor(GameWindow *list, const Image *image, Bool enabled, Int i void BattleHonorTooltip(GameWindow *window, WinInstanceData *instData, UnsignedInt mouse); - -#endif // __SKIRMISHBATTLEHONORS_H__ diff --git a/Generals/Code/GameEngine/Include/Common/SkirmishPreferences.h b/Generals/Code/GameEngine/Include/Common/SkirmishPreferences.h index d2b7f6a3e7..562b4720af 100644 --- a/Generals/Code/GameEngine/Include/Common/SkirmishPreferences.h +++ b/Generals/Code/GameEngine/Include/Common/SkirmishPreferences.h @@ -30,9 +30,6 @@ #pragma once -#ifndef __SKIRMISHPREFERENCES_H__ -#define __SKIRMISHPREFERENCES_H__ - //----------------------------------------------------------------------------- // USER INCLUDES ////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -57,6 +54,10 @@ class SkirmishPreferences : public UserPreferences Int getPreferredColor(void); // convenience function AsciiString getPreferredMap(void); // convenience function Bool usesSystemMapDir(void); // convenience function -}; -#endif // __SKIRMISHPREFERENCES_H__ + Bool getSuperweaponRestricted(void) const; + void setSuperweaponRestricted( Bool superweaponRestricted); + + Money getStartingCash(void) const; + void setStartingCash( const Money &startingCash ); +}; diff --git a/Generals/Code/GameEngine/Include/Common/Snapshot.h b/Generals/Code/GameEngine/Include/Common/Snapshot.h index 6922d9d0f7..e8a3ef7434 100644 --- a/Generals/Code/GameEngine/Include/Common/Snapshot.h +++ b/Generals/Code/GameEngine/Include/Common/Snapshot.h @@ -30,9 +30,6 @@ #pragma once -#ifndef __SNAPSHOT_H_ -#define __SNAPSHOT_H_ - // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// #include "Common/AsciiString.h" @@ -68,6 +65,3 @@ friend class XferCRC; virtual void loadPostProcess( void ) = 0; }; - -#endif // __SNAPSHOT_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/SparseMatchFinder.h b/Generals/Code/GameEngine/Include/Common/SparseMatchFinder.h index 68b845e99a..38e3bbed4d 100644 --- a/Generals/Code/GameEngine/Include/Common/SparseMatchFinder.h +++ b/Generals/Code/GameEngine/Include/Common/SparseMatchFinder.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __SparseMatchFinder_H_ -#define __SparseMatchFinder_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Common/BitFlags.h" #include "Common/STLTypedefs.h" @@ -112,13 +109,13 @@ class SparseMatchFinder //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- - inline static Int countConditionIntersection(const BITSET& a, const BITSET& b) + static Int countConditionIntersection(const BITSET& a, const BITSET& b) { return a.countIntersection(b); } //------------------------------------------------------------------------------------------------- - inline static Int countConditionInverseIntersection(const BITSET& a, const BITSET& b) + static Int countConditionInverseIntersection(const BITSET& a, const BITSET& b) { return a.countInverseIntersection(b); } @@ -169,9 +166,9 @@ class SparseMatchFinder curBestMatchStr = it->getDescription(); #endif } - } // end for i + } - } // end for it + } #ifdef SPARSEMATCH_DEBUG if (numDupMatches > 0) @@ -202,7 +199,7 @@ class SparseMatchFinder //------------------------------------------------------------------------------------------------- SparseMatchFinder& operator=(const SparseMatchFinder& other) { - if CONSTEXPR ((FLAGS & SparseMatchFinderFlags_NoCopy) == 0) + if constexpr ((FLAGS & SparseMatchFinderFlags_NoCopy) == 0) { if (this != &other) { @@ -243,6 +240,3 @@ class SparseMatchFinder } }; - -#endif // __SparseMatchFinder_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/SpecialPower.h b/Generals/Code/GameEngine/Include/Common/SpecialPower.h index 9d5f19c509..8317c3e104 100644 --- a/Generals/Code/GameEngine/Include/Common/SpecialPower.h +++ b/Generals/Code/GameEngine/Include/Common/SpecialPower.h @@ -30,9 +30,6 @@ #pragma once -#ifndef __SPECIALPOWER_H_ -#define __SPECIALPOWER_H_ - // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// #include "Common/AudioEventRTS.h" #include "Common/GameMemory.h" @@ -188,5 +185,3 @@ class SpecialPowerStore : public SubsystemInterface // EXTERNAL /////////////////////////////////////////////////////////////////////////////////////// extern SpecialPowerStore *TheSpecialPowerStore; - -#endif // end __SPECIALPOWER_H_ diff --git a/Generals/Code/GameEngine/Include/Common/SpecialPowerMaskType.h b/Generals/Code/GameEngine/Include/Common/SpecialPowerMaskType.h index ec9265d780..f72371b0e8 100644 --- a/Generals/Code/GameEngine/Include/Common/SpecialPowerMaskType.h +++ b/Generals/Code/GameEngine/Include/Common/SpecialPowerMaskType.h @@ -27,13 +27,9 @@ // JKMCD Aug 2002 #pragma once -#ifndef __SPECIALPOWERMASKTYPE_H__ -#define __SPECIALPOWERMASKTYPE_H__ #include "Common/BitFlags.h" #include "Common/BitFlagsIO.h" #include "Common/SpecialPowerType.h" typedef BitFlags SpecialPowerMaskType; - -#endif /* __SPECIALPOWERMASKTYPE_H__ */ diff --git a/Generals/Code/GameEngine/Include/Common/SpecialPowerType.h b/Generals/Code/GameEngine/Include/Common/SpecialPowerType.h index b967da9992..4fc2a6031d 100644 --- a/Generals/Code/GameEngine/Include/Common/SpecialPowerType.h +++ b/Generals/Code/GameEngine/Include/Common/SpecialPowerType.h @@ -27,8 +27,6 @@ // JKMCD Aug 2002 #pragma once -#ifndef __SPECIALPOWERTYPE_H__ -#define __SPECIALPOWERTYPE_H__ // ------------------------------------------------------------------------------------------------ // don't forget to add new strings to SpecialPowerMaskType::s_bitNameList[] @@ -97,5 +95,3 @@ enum SpecialPowerType CPP_11(: Int) }; // Definition of these names is located in SpecialPower.cpp - -#endif /* __SPECIALPOWERTYPE_H__ */ diff --git a/Generals/Code/GameEngine/Include/Common/StackDump.h b/Generals/Code/GameEngine/Include/Common/StackDump.h index c19680f461..9a0e836dcf 100644 --- a/Generals/Code/GameEngine/Include/Common/StackDump.h +++ b/Generals/Code/GameEngine/Include/Common/StackDump.h @@ -24,9 +24,6 @@ #pragma once -#ifndef __STACKDUMP_H_ -#define __STACKDUMP_H_ - #ifndef IG_DEGBUG_STACKTRACE #define IG_DEBUG_STACKTRACE 1 #endif @@ -70,6 +67,3 @@ __inline void DumpExceptionInfo( unsigned int u, EXCEPTION_POINTERS* e_info ) {} #endif extern AsciiString g_LastErrorDump; - - -#endif // __STACKDUMP_H_ diff --git a/Generals/Code/GameEngine/Include/Common/StateMachine.h b/Generals/Code/GameEngine/Include/Common/StateMachine.h index 39cbddce62..964612308b 100644 --- a/Generals/Code/GameEngine/Include/Common/StateMachine.h +++ b/Generals/Code/GameEngine/Include/Common/StateMachine.h @@ -28,17 +28,12 @@ #pragma once -#ifndef _STATE_MACHINE_H_ -#define _STATE_MACHINE_H_ - #include "Common/GameMemory.h" #include "Common/GameType.h" #include "Common/ModelState.h" #include "Common/Snapshot.h" #include "Common/Xfer.h" -#include "refcount.h" - //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -157,8 +152,8 @@ class State : public MemoryPoolObject, public Snapshot //Definition of busy -- when explicitly in the busy state. Moving or attacking is not considered busy! virtual Bool isBusy() const { return false; } - inline StateMachine* getMachine() { return m_machine; } ///< return the machine this state is part of - inline StateID getID() const { return m_ID; } ///< get this state's id + StateMachine* getMachine() { return m_machine; } ///< return the machine this state is part of + StateID getID() const { return m_ID; } ///< get this state's id Object* getMachineOwner(); const Object* getMachineOwner() const; @@ -172,7 +167,7 @@ class State : public MemoryPoolObject, public Snapshot #endif // for internal use by the StateMachine class --------------------------------------------------------- - inline void friend_setID( StateID id ) { m_ID = id; } ///< define this state's id (for use only by StateMachine class) + void friend_setID( StateID id ) { m_ID = id; } ///< define this state's id (for use only by StateMachine class) void friend_onSuccess( StateID toStateID ) { m_successStateID = toStateID; } ///< define which state to move to after successful completion void friend_onFailure( StateID toStateID ) { m_failureStateID = toStateID; } ///< define which state to move to after failure void friend_onCondition( StateTransFuncPtr test, StateID toStateID, void* userData, const char* description = NULL ); ///< define when to change state @@ -333,8 +328,8 @@ class StateMachine : public MemoryPoolObject, public Snapshot inline AsciiString getName() const {return m_name;} virtual AsciiString getCurrentStateName() const { return m_currentState ? m_currentState->getName() : AsciiString::TheEmptyString;} #else - inline Bool getWantsDebugOutput() const { return false; } - inline AsciiString getCurrentStateName() const { return AsciiString::TheEmptyString;} + Bool getWantsDebugOutput() const { return false; } + AsciiString getCurrentStateName() const { return AsciiString::TheEmptyString;} #endif protected: @@ -483,8 +478,6 @@ EMPTY_DTOR(SleepState) // @todo Replace calls to deleteInstance with RefCountPtr when so appropriate. inline void deleteInstance(StateMachine* machine) { - machine->Release_Ref(); + if (machine != NULL) + machine->Release_Ref(); } - - -#endif // _STATE_MACHINE_H_ diff --git a/Generals/Code/GameEngine/Include/Common/StatsCollector.h b/Generals/Code/GameEngine/Include/Common/StatsCollector.h index af78def921..9b67159c40 100644 --- a/Generals/Code/GameEngine/Include/Common/StatsCollector.h +++ b/Generals/Code/GameEngine/Include/Common/StatsCollector.h @@ -45,9 +45,6 @@ #pragma once -#ifndef __STATSCOLLECTOR_H_ -#define __STATSCOLLECTOR_H_ - //----------------------------------------------------------------------------- // SYSTEM INCLUDES //////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -119,5 +116,3 @@ class StatsCollector // EXTERNALS ////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- extern StatsCollector* TheStatsCollector; ///< we need a singleton - -#endif // __STATSCOLLECTOR_H_ diff --git a/Generals/Code/GameEngine/Include/Common/SubsystemInterface.h b/Generals/Code/GameEngine/Include/Common/SubsystemInterface.h index b996e7d46e..740accba46 100644 --- a/Generals/Code/GameEngine/Include/Common/SubsystemInterface.h +++ b/Generals/Code/GameEngine/Include/Common/SubsystemInterface.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __SUBSYSTEMINTERFACE_H_ -#define __SUBSYSTEMINTERFACE_H_ - #include "Common/INI.h" #include "Common/STLTypedefs.h" @@ -127,8 +124,8 @@ class SubsystemInterface Real m_startDrawTimeConsumed; Real m_curDrawTime; #else - inline void UPDATE(void) {update();} - inline void DRAW(void) {draw();} + void UPDATE(void) {update();} + void DRAW(void) {draw();} #endif protected: AsciiString m_name; @@ -136,7 +133,7 @@ class SubsystemInterface AsciiString getName(void) {return m_name;} void setName(AsciiString name) {m_name = name;} -}; // end SubsystemInterface +}; //------------------------------------------------------------------------------------------------- class SubsystemInterfaceList @@ -146,7 +143,7 @@ class SubsystemInterfaceList SubsystemInterfaceList(); ~SubsystemInterfaceList(); - void initSubsystem(SubsystemInterface* sys, const char* path1, const char* path2, const char* dirpath, Xfer *pXfer, AsciiString name=""); + void initSubsystem(SubsystemInterface* sys, const char* path1, const char* path2, Xfer *pXfer, AsciiString name=""); void addSubsystem(SubsystemInterface* sys); void removeSubsystem(SubsystemInterface* sys); void postProcessLoadAll(); @@ -165,6 +162,3 @@ class SubsystemInterfaceList }; extern SubsystemInterfaceList* TheSubsystemList; - -#endif // __SUBSYSTEMINTERFACE_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/SystemInfo.h b/Generals/Code/GameEngine/Include/Common/SystemInfo.h index aeacb184ed..8b08868eab 100644 --- a/Generals/Code/GameEngine/Include/Common/SystemInfo.h +++ b/Generals/Code/GameEngine/Include/Common/SystemInfo.h @@ -28,11 +28,4 @@ #pragma once -#ifndef __SYSTEMINFO_H__ -#define __SYSTEMINFO_H__ - extern const Bool TheSystemIsUnicode; - - - -#endif /* __SYSTEMINFO_H__ */ diff --git a/Generals/Code/GameEngine/Include/Common/Team.h b/Generals/Code/GameEngine/Include/Common/Team.h index 6db1a8da1d..d510d1cc5c 100644 --- a/Generals/Code/GameEngine/Include/Common/Team.h +++ b/Generals/Code/GameEngine/Include/Common/Team.h @@ -28,9 +28,6 @@ #pragma once -#ifndef _TEAM_H_ -#define _TEAM_H_ - #include "Common/GameType.h" #include "Common/Snapshot.h" #include "Common/Thing.h" @@ -528,10 +525,10 @@ class TeamPrototype : public MemoryPoolObject, TeamPrototypeID id ); // virtual destructor prototype provided by memory pool object - inline TeamPrototypeID getID() const { return m_id; } - inline const AsciiString& getName() const { return m_name; } - inline Bool getIsSingleton() const { return (m_flags & TEAM_SINGLETON) != 0; } - inline const TeamTemplateInfo *getTemplateInfo(void) const {return &m_teamTemplate;} + TeamPrototypeID getID() const { return m_id; } + const AsciiString& getName() const { return m_name; } + Bool getIsSingleton() const { return (m_flags & TEAM_SINGLETON) != 0; } + const TeamTemplateInfo *getTemplateInfo(void) const {return &m_teamTemplate;} /** return the team's owner (backtracking up if necessary) */ @@ -756,5 +753,3 @@ const AsciiString& Team::getName(void) const // ------------------------------------------------------------------------ - -#endif // _TEAM_H_ diff --git a/Generals/Code/GameEngine/Include/Common/Terrain.h b/Generals/Code/GameEngine/Include/Common/Terrain.h index 3d20810c15..dd6ea409a3 100644 --- a/Generals/Code/GameEngine/Include/Common/Terrain.h +++ b/Generals/Code/GameEngine/Include/Common/Terrain.h @@ -32,14 +32,9 @@ #pragma once -#ifndef __TERRAIN_H_ -#define __TERRAIN_H_ - // SYSTEM INCLUDES //////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////// // DEFINE ///////////////////////////////////////////////////////////////////// #define MAX_TERRAIN_NAME_LEN 64 ///< max size of map filename with extenstion - -#endif // end __TERRAIN_H_ diff --git a/Generals/Code/GameEngine/Include/Common/TerrainTypes.h b/Generals/Code/GameEngine/Include/Common/TerrainTypes.h index abd04b5b0e..b0b2e2013e 100644 --- a/Generals/Code/GameEngine/Include/Common/TerrainTypes.h +++ b/Generals/Code/GameEngine/Include/Common/TerrainTypes.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __TERRAINTYPE_H_ -#define __TERRAINTYPE_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Common/GameMemory.h" #include "Common/SubsystemInterface.h" @@ -70,11 +67,11 @@ typedef enum TERRAIN_WOOD, TERRAIN_BLEND_EDGES, - TERRAIN_NUM_CLASSES // keep this last + TERRAIN_NUM_CLASSES } TerrainClass; #ifdef DEFINE_TERRAIN_TYPE_NAMES -static const char *terrainTypeNames[] = +static const char *const terrainTypeNames[] = { "NONE", "DESERT_1", @@ -104,6 +101,7 @@ static const char *terrainTypeNames[] = NULL }; +static_assert(ARRAY_SIZE(terrainTypeNames) == TERRAIN_NUM_CLASSES + 1, "Incorrect array size"); #endif // end DEFINE_TERRAIN_TYPE_NAMES //------------------------------------------------------------------------------------------------- @@ -120,40 +118,40 @@ class TerrainType : public MemoryPoolObject // destructor prototype defined by memory pool glue /// get the name for this terrain - inline AsciiString getName( void ) { return m_name; } + AsciiString getName( void ) { return m_name; } /// get whether this terrain is blend edge terrain. - inline Bool isBlendEdge( void ) { return m_blendEdgeTexture; } + Bool isBlendEdge( void ) { return m_blendEdgeTexture; } /// get the type of this terrain - inline TerrainClass getClass( void ) { return m_class; } + TerrainClass getClass( void ) { return m_class; } /// get the construction restrictions - inline Bool getRestrictConstruction( void ) { return m_restrictConstruction; } + Bool getRestrictConstruction( void ) { return m_restrictConstruction; } /// get the texture file for this terrain - inline AsciiString getTexture( void ) { return m_texture; } + AsciiString getTexture( void ) { return m_texture; } /// get next terrain in list, only for use by the terrain collection - inline TerrainType *friend_getNext( void ) { return m_next; } + TerrainType *friend_getNext( void ) { return m_next; } /// set the name for this terrain, for use by terrain collection only - inline void friend_setName( AsciiString name ) { m_name = name; } + void friend_setName( AsciiString name ) { m_name = name; } /// set the next pointer for the terrain list, for use by terrain collection only - inline void friend_setNext( TerrainType *next ) { m_next = next; } + void friend_setNext( TerrainType *next ) { m_next = next; } /// set the texture, for use by terrain collection only - inline void friend_setTexture( AsciiString texture ) { m_texture = texture; } + void friend_setTexture( AsciiString texture ) { m_texture = texture; } /// set the class, for use by terrain collection only - inline void friend_setClass( TerrainClass terrainClass ) { m_class = terrainClass; } + void friend_setClass( TerrainClass terrainClass ) { m_class = terrainClass; } /// set the restrict construction flag, for use by terrain collection only - inline void friend_setRestrictConstruction( Bool restrict ) { m_restrictConstruction = restrict; } + void friend_setRestrictConstruction( Bool restrict ) { m_restrictConstruction = restrict; } /// set whether this terrain is blend edge terrain, for use by terrain collection only - inline void friend_setBlendEdge( Bool isBlend ) { m_blendEdgeTexture = isBlend; } + void friend_setBlendEdge( Bool isBlend ) { m_blendEdgeTexture = isBlend; } /// get the parsing table for INI const FieldParse *getFieldParse( void ) { return m_terrainTypeFieldParseTable; } @@ -204,6 +202,3 @@ class TerrainTypeCollection : public SubsystemInterface // EXTERNAL /////////////////////////////////////////////////////////////////////////////////////// extern TerrainTypeCollection *TheTerrainTypes; - -#endif // __TERRAINTYPE_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/Thing.h b/Generals/Code/GameEngine/Include/Common/Thing.h index b0c91c2a8a..838480831e 100644 --- a/Generals/Code/GameEngine/Include/Common/Thing.h +++ b/Generals/Code/GameEngine/Include/Common/Thing.h @@ -48,9 +48,6 @@ #pragma once -#ifndef __THING_H_ -#define __THING_H_ - //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- @@ -121,6 +118,9 @@ class Thing : public MemoryPoolObject inline const Coord3D *getPosition() const { return &m_cachedPos; } inline Real getOrientation() const { return m_cachedAngle; } + + Bool isPositioned() const; + const Coord3D *getUnitDirectionVector2D() const; void getUnitDirectionVector2D(Coord3D& dir) const; void getUnitDirectionVector3D(Coord3D& dir) const; @@ -194,6 +194,3 @@ class Thing : public MemoryPoolObject //----------------------------------------------------------------------------- // Externals //----------------------------------------------------------------------------- - -#endif // $label - diff --git a/Generals/Code/GameEngine/Include/Common/ThingFactory.h b/Generals/Code/GameEngine/Include/Common/ThingFactory.h index 69909b5713..c9469239c2 100644 --- a/Generals/Code/GameEngine/Include/Common/ThingFactory.h +++ b/Generals/Code/GameEngine/Include/Common/ThingFactory.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __THINGFACTORY_H_ -#define __THINGFACTORY_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Lib/BaseType.h" @@ -76,7 +73,7 @@ class ThingFactory : public SubsystemInterface get a template given template database name. return null if not found. note, this is now substantially faster (does a hash-table lookup) */ - const ThingTemplate *findTemplate( const AsciiString& name ) { return findTemplateInternal(name); } + const ThingTemplate *findTemplate( const AsciiString& name, Bool check = TRUE ) { return findTemplateInternal( name, check ); } /** get a template given ID. return null if not found. @@ -92,7 +89,7 @@ class ThingFactory : public SubsystemInterface /** request a new drawable using the given template. this will throw an exception on failure; it will never return null. */ - Drawable *newDrawable(const ThingTemplate *tmplate, DrawableStatus statusBits = DRAWABLE_STATUS_NONE ); + Drawable *newDrawable(const ThingTemplate *tmplate, DrawableStatusBits statusBits = DRAWABLE_STATUS_DEFAULT ); static void parseObjectDefinition( INI* ini, const AsciiString& name, const AsciiString& reskinFrom ); @@ -123,7 +120,7 @@ class ThingFactory : public SubsystemInterface NOTE: this is protected since it returns a NON-CONST template, and folks outside of the template system itself shouldn't get access... */ - ThingTemplate *findTemplateInternal( const AsciiString& name ); + ThingTemplate *findTemplateInternal( const AsciiString& name, Bool check = TRUE ); ThingTemplate *m_firstTemplate; ///< head of linked list UnsignedShort m_nextTemplateID; ///< next available ID for templates @@ -134,7 +131,3 @@ class ThingFactory : public SubsystemInterface // EXTERN ///////////////////////////////////////////////////////////////////////////////////////// extern ThingFactory *TheThingFactory; ///< the template singleton - - -#endif // __THINGFACTORY_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/ThingSort.h b/Generals/Code/GameEngine/Include/Common/ThingSort.h index b162c9288a..e35702922c 100644 --- a/Generals/Code/GameEngine/Include/Common/ThingSort.h +++ b/Generals/Code/GameEngine/Include/Common/ThingSort.h @@ -29,15 +29,12 @@ #pragma once -#ifndef __THINGSORT_H_ -#define __THINGSORT_H_ +#include "GameCommon.h" //------------------------------------------------------------------------------------------------- enum EditorSortingType CPP_11(: Int) { - ES_FIRST = 0, - - ES_NONE = ES_FIRST, + ES_NONE, ES_STRUCTURE, ES_INFANTRY, ES_VEHICLE, @@ -52,11 +49,12 @@ enum EditorSortingType CPP_11(: Int) ES_ROAD, // road objects...should never actually be in the object panel. ES_WAYPOINT, // waypoint objects...should never actually be in the object panel. - ES_NUM_SORTING_TYPES // keep this last - + ES_NUM_SORTING_TYPES, + ES_FIRST = 0, }; + #ifdef DEFINE_EDITOR_SORTING_NAMES -static const char *EditorSortingNames[] = +static const char *const EditorSortingNames[] = { "NONE", "STRUCTURE", @@ -75,7 +73,5 @@ static const char *EditorSortingNames[] = NULL }; +static_assert(ARRAY_SIZE(EditorSortingNames) == ES_NUM_SORTING_TYPES + 1, "Incorrect array size"); #endif - -#endif // __THINGSORT_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/ThingTemplate.h b/Generals/Code/GameEngine/Include/Common/ThingTemplate.h index 4637af55c7..f01dc7038e 100644 --- a/Generals/Code/GameEngine/Include/Common/ThingTemplate.h +++ b/Generals/Code/GameEngine/Include/Common/ThingTemplate.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __THINGTEMPLATE_H_ -#define __THINGTEMPLATE_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Lib/BaseType.h" @@ -82,7 +79,7 @@ typedef std::map PerUnitFXMap; // INV_IMAGE_HILITE, // INV_IMAGE_PUSHED, // -// INV_IMAGE_NUM_IMAGES // keep this last +// INV_IMAGE_NUM_IMAGES // //}; //------------------------------------------------------------------------------------------------- @@ -141,7 +138,7 @@ enum ThingTemplateAudioType CPP_11(: Int) TTAUDIO_voiceAttackAir, ///< Unit is ordered to attack an airborne unit TTAUDIO_voiceGuard, ///< Unit is ordered to guard an area - TTAUDIO_COUNT // keep last! + TTAUDIO_COUNT }; class AudioArray @@ -158,8 +155,7 @@ class AudioArray ~AudioArray() { for (Int i = 0; i < TTAUDIO_COUNT; ++i) - if (m_audio[i]) - deleteInstance(m_audio[i]); + deleteInstance(m_audio[i]); } AudioArray(const AudioArray& that) @@ -205,10 +201,10 @@ enum BuildCompletionType CPP_11(: Int) BC_APPEARS_AT_RALLY_POINT, ///< unit appears at rally point of its #1 prereq BC_PLACED_BY_PLAYER, ///< unit must be manually placed by player - BC_NUM_TYPES // leave this last + BC_NUM_TYPES }; #ifdef DEFINE_BUILD_COMPLETION_NAMES -static const char *BuildCompletionNames[] = +static const char *const BuildCompletionNames[] = { "INVALID", "APPEARS_AT_RALLY_POINT", @@ -216,6 +212,7 @@ static const char *BuildCompletionNames[] = NULL }; +static_assert(ARRAY_SIZE(BuildCompletionNames) == BC_NUM_TYPES + 1, "Incorrect array size"); #endif // end DEFINE_BUILD_COMPLETION_NAMES enum BuildableStatus CPP_11(: Int) @@ -226,11 +223,11 @@ enum BuildableStatus CPP_11(: Int) BSTATUS_NO, BSTATUS_ONLY_BY_AI, - BSTATUS_NUM_TYPES // leave this last + BSTATUS_NUM_TYPES }; #ifdef DEFINE_BUILDABLE_STATUS_NAMES -static const char *BuildableStatusNames[] = +static const char *const BuildableStatusNames[] = { "Yes", "Ignore_Prerequisites", @@ -238,6 +235,7 @@ static const char *BuildableStatusNames[] = "Only_By_AI", NULL }; +static_assert(ARRAY_SIZE(BuildableStatusNames) == BSTATUS_NUM_TYPES + 1, "Incorrect array size"); #endif // end DEFINE_BUILDABLE_STATUS_NAMES //------------------------------------------------------------------------------------------------- @@ -400,18 +398,18 @@ class ThingTemplate : public Overridable EditorSortingType getEditorSorting() const { return (EditorSortingType)m_editorSorting; } /// return true iff the template has the specified kindOf flag set. - inline Bool isKindOf(KindOfType t) const + Bool isKindOf(KindOfType t) const { return TEST_KINDOFMASK(m_kindof, t); } /// convenience for doing multiple kindof testing at once. - inline Bool isKindOfMulti(const KindOfMaskType& mustBeSet, const KindOfMaskType& mustBeClear) const + Bool isKindOfMulti(const KindOfMaskType& mustBeSet, const KindOfMaskType& mustBeClear) const { return TEST_KINDOFMASK_MULTI(m_kindof, mustBeSet, mustBeClear); } - inline Bool isAnyKindOf( const KindOfMaskType& anyKindOf ) const + Bool isAnyKindOf( const KindOfMaskType& anyKindOf ) const { return TEST_KINDOFMASK_ANY(m_kindof, anyKindOf); } @@ -429,6 +427,7 @@ class ThingTemplate : public Overridable Real getFenceXOffset() const { return m_fenceXOffset; } // return fence offset Bool isBridge() const { return m_isBridge; } // return fence offset + Bool isBridgeLike() const { return isBridge() || isKindOf(KINDOF_WALK_ON_TOP_OF_WALL); } // Only Object can ask this. Everyone else should ask the Object. In fact, you really should ask the Object everything. Real friend_getVisionRange() const { return m_visionRange; } ///< get vision range @@ -535,10 +534,10 @@ class ThingTemplate : public Overridable // these are intended ONLY for the private use of ThingFactory and do not use // the m_override pointer, it deals only with templates at the "top" level // - inline void friend_setTemplateName( const AsciiString& name ) { m_nameString = name; } - inline ThingTemplate *friend_getNextTemplate() const { return m_nextThingTemplate; } - inline void friend_setNextTemplate(ThingTemplate *tmplate) { m_nextThingTemplate = tmplate; } - inline void friend_setTemplateID(UnsignedShort id) { m_templateID = id; } + void friend_setTemplateName( const AsciiString& name ) { m_nameString = name; } + ThingTemplate *friend_getNextTemplate() const { return m_nextThingTemplate; } + void friend_setNextTemplate(ThingTemplate *tmplate) { m_nextThingTemplate = tmplate; } + void friend_setTemplateID(UnsignedShort id) { m_templateID = id; } Int getEnergyProduction() const { return m_energyProduction; } Int getEnergyBonus() const { return m_energyBonus; } @@ -763,6 +762,3 @@ class ThingTemplate : public Overridable //----------------------------------------------------------------------------- // Externals //----------------------------------------------------------------------------- - -#endif // __THINGTEMPLATE_H_ - diff --git a/Generals/Code/GameEngine/Include/Common/TunnelTracker.h b/Generals/Code/GameEngine/Include/Common/TunnelTracker.h index 4fe040954b..eddc5b3c10 100644 --- a/Generals/Code/GameEngine/Include/Common/TunnelTracker.h +++ b/Generals/Code/GameEngine/Include/Common/TunnelTracker.h @@ -29,9 +29,6 @@ #pragma once -#ifndef TUNNEL_TRACKER_H -#define TUNNEL_TRACKER_H - #include "Common/GameType.h" #include "Common/GameMemory.h" #include "Common/Snapshot.h" @@ -62,7 +59,11 @@ class TunnelTracker : public MemoryPoolObject, static void destroyObject( Object *obj, void *userData ); ///< Callback for Iterate Contained system static void healObject( Object *obj, void *frames ); ///< Callback for Iterate Contained system +#if PRESERVE_RETAIL_BEHAVIOR || RETAIL_COMPATIBLE_CRC void healObjects(Real frames); ///< heal all objects within the tunnel +#else + void healObjects(); ///< heal all objects within the tunnel +#endif UnsignedInt friend_getTunnelCount() const {return m_tunnelCount;}///< TunnelContains are allowed to ask if they are the last one ahead of deletion time @@ -78,15 +79,16 @@ class TunnelTracker : public MemoryPoolObject, virtual void loadPostProcess( void ); private: + void updateFullHealTime(); std::list< ObjectID > m_tunnelIDs; ///< I have to try to keep track of these because Caves need to iterate on them. ContainedItemsList m_containList; ///< the contained object pointers list std::list< ObjectID > m_xferContainList;///< for loading of m_containList during post processing Int m_containListSize; ///< size of the contain list UnsignedInt m_tunnelCount; ///< How many tunnels have registered so we know when we should kill our contain list + UnsignedInt m_framesForFullHeal; ///< How many frames it takes to fully heal a unit + Bool m_needsFullHealTimeUpdate; ///< Set to true when needing to recalc full heal time to batch the operation ObjectID m_curNemesisID; ///< If we have team(s) guarding a tunnel network system, this is one of the current targets. UnsignedInt m_nemesisTimestamp; ///< We only keep nemesis for a couple of seconds. }; - -#endif diff --git a/Generals/Code/GameEngine/Include/Common/UnitTimings.h b/Generals/Code/GameEngine/Include/Common/UnitTimings.h index 26b3ebb200..2aef897e2f 100644 --- a/Generals/Code/GameEngine/Include/Common/UnitTimings.h +++ b/Generals/Code/GameEngine/Include/Common/UnitTimings.h @@ -29,11 +29,4 @@ #pragma once -#ifndef __UNITTIMINGS_H_ -#define __UNITTIMINGS_H_ - - #define dontDO_UNIT_TIMINGS - -#endif - diff --git a/Generals/Code/GameEngine/Include/Common/Upgrade.h b/Generals/Code/GameEngine/Include/Common/Upgrade.h index c1282cf537..9f587e36bc 100644 --- a/Generals/Code/GameEngine/Include/Common/Upgrade.h +++ b/Generals/Code/GameEngine/Include/Common/Upgrade.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __UPGRADE_H_ -#define __UPGRADE_H_ - // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// #include "Common/AudioEventRTS.h" #include "Common/INI.h" @@ -149,9 +146,9 @@ enum UpgradeType CPP_11(: Int) UPGRADE_TYPE_PLAYER = 0, // upgrade applies to a player as a whole UPGRADE_TYPE_OBJECT, // upgrade applies to an object instance only - NUM_UPGRADE_TYPES, // keep this last + NUM_UPGRADE_TYPES }; -extern const char *TheUpgradeTypeNames[]; //Change above, change this! +extern const char *const TheUpgradeTypeNames[]; //Change above, change this! //------------------------------------------------------------------------------------------------- /** A single upgrade template definition */ @@ -235,10 +232,11 @@ class UpgradeCenter : public SubsystemInterface void reset( void ); ///< subsystem interface void update( void ) { } ///< subsystem interface - UpgradeTemplate *firstUpgradeTemplate( void ); ///< return the first upgrade template - const UpgradeTemplate *findUpgradeByKey( NameKeyType key ) const; ///< find upgrade by name key - const UpgradeTemplate *findUpgrade( const AsciiString& name ) const; ///< find and return upgrade by name - const UpgradeTemplate *findVeterancyUpgrade(VeterancyLevel level) const; ///< find and return upgrade by name + UpgradeTemplate *firstUpgradeTemplate( void ); ///< return the first upgrade template + const UpgradeTemplate *findUpgradeByKey( NameKeyType key ) const; ///< find upgrade by name key + const UpgradeTemplate *findUpgrade( const AsciiString& name ) const; ///< find and return upgrade by name + const UpgradeTemplate *findUpgrade( const char* name ) const; ///< find and return upgrade by name + const UpgradeTemplate *findVeterancyUpgrade(VeterancyLevel level) const; ///< find and return upgrade by veterancy level UpgradeTemplate *newUpgrade( const AsciiString& name ); ///< allocate, link, and return new upgrade @@ -263,5 +261,3 @@ class UpgradeCenter : public SubsystemInterface // EXTERNALS ////////////////////////////////////////////////////////////////////////////////////// extern UpgradeCenter *TheUpgradeCenter; - -#endif // end __UPGRADE_H_ diff --git a/Generals/Code/GameEngine/Include/Common/UserPreferences.h b/Generals/Code/GameEngine/Include/Common/UserPreferences.h index 85030853e0..aef49361d3 100644 --- a/Generals/Code/GameEngine/Include/Common/UserPreferences.h +++ b/Generals/Code/GameEngine/Include/Common/UserPreferences.h @@ -30,15 +30,14 @@ #pragma once -#ifndef __USERPREFERENCES_H__ -#define __USERPREFERENCES_H__ - //----------------------------------------------------------------------------- // USER INCLUDES ////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- #include "Common/STLTypedefs.h" -enum CursorCaptureMode CPP_11(: Int); +class Money; +typedef UnsignedInt CursorCaptureMode; +typedef UnsignedInt ScreenEdgeScrollMode; //----------------------------------------------------------------------------- // PUBLIC TYPES /////////////////////////////////////////////////////////////// @@ -90,9 +89,19 @@ class OptionPreferences : public UserPreferences void setOnlineIPAddress(AsciiString IP); // convenience function void setLANIPAddress(UnsignedInt IP); // convenience function void setOnlineIPAddress(UnsignedInt IP); // convenience function + Bool getArchiveReplaysEnabled() const; // convenience function Bool getAlternateMouseModeEnabled(void); // convenience function Real getScrollFactor(void); // convenience function + Bool getDrawScrollAnchor(void); + Bool getMoveScrollAnchor(void); + Bool getCursorCaptureEnabledInWindowedGame() const; + Bool getCursorCaptureEnabledInWindowedMenu() const; + Bool getCursorCaptureEnabledInFullscreenGame() const; + Bool getCursorCaptureEnabledInFullscreenMenu() const; CursorCaptureMode getCursorCaptureMode() const; + Bool getScreenEdgeScrollEnabledInWindowedApp() const; + Bool getScreenEdgeScrollEnabledInFullscreenApp() const; + ScreenEdgeScrollMode getScreenEdgeScrollMode() const; Bool getSendDelay(void); // convenience function Int getFirewallBehavior(void); // convenience function Short getFirewallPortAllocationDelta(void); // convenience function @@ -108,6 +117,7 @@ class OptionPreferences : public UserPreferences Real getMoneyTransactionVolume(void) const; Bool saveCameraInReplays(void); Bool useCameraInReplays(void); + Bool getPlayerObserverEnabled() const; Int getStaticGameDetail(void); // detail level selected by the user. Int getIdealStaticGameDetail(void); // detail level detected for user. Real getGammaValue(void); @@ -129,8 +139,14 @@ class OptionPreferences : public UserPreferences Int getCampaignDifficulty(void); void setCampaignDifficulty( Int diff ); + Int getNetworkLatencyFontSize(void); + Int getRenderFpsFontSize(void); Int getSystemTimeFontSize(void); Int getGameTimeFontSize(void); + + Real getResolutionFontAdjustment(void); + + Bool getShowMoneyPerMinute(void) const; }; //----------------------------------------------------------------------------- @@ -151,6 +167,9 @@ class LANPreferences : public UserPreferences Bool usesSystemMapDir(void); // convenience function Int getNumRemoteIPs(void); // convenience function UnicodeString getRemoteIPEntry(Int i); // convenience function -}; -#endif // __USERPREFERENCES_H__ + Bool getSuperweaponRestricted(void) const; + Money getStartingCash(void) const; + void setSuperweaponRestricted( Bool superweaponRestricted); + void setStartingCash( const Money & startingCash ); +}; diff --git a/Generals/Code/GameEngine/Include/Common/WellKnownKeys.h b/Generals/Code/GameEngine/Include/Common/WellKnownKeys.h index 0b22b74f45..67cacd62e2 100644 --- a/Generals/Code/GameEngine/Include/Common/WellKnownKeys.h +++ b/Generals/Code/GameEngine/Include/Common/WellKnownKeys.h @@ -45,9 +45,6 @@ #pragma once -#ifndef _H_WELLKNOWNKEYS -#define _H_WELLKNOWNKEYS - #include "Common/NameKeyGenerator.h" #ifdef INSTANTIATE_WELL_KNOWN_KEYS @@ -846,5 +843,3 @@ DEFINE_KEY(Player_7_Start) DEFINE_KEY(Player_8_Start) // --------------------------------------------------------------------------------------- - -#endif // _H_WELLKNOWNKEYS diff --git a/Generals/Code/GameEngine/Include/Common/encrypt.h b/Generals/Code/GameEngine/Include/Common/encrypt.h index d57d2ddb96..e441432f9e 100644 --- a/Generals/Code/GameEngine/Include/Common/encrypt.h +++ b/Generals/Code/GameEngine/Include/Common/encrypt.h @@ -28,16 +28,9 @@ #pragma once -#ifndef ENCRYPT_HEADER -#define ENCRYPT_HEADER - // This routine is non-reentrant, as it returns a static buffer!!! // Valid input is 4-8 characters, and can contain letters and numbers and '.' and '/' #define MAX_ENCRYPTED_STRING 8 const char *EncryptString(const char *); - -#endif - - diff --git a/Generals/Code/GameEngine/Include/Common/version.h b/Generals/Code/GameEngine/Include/Common/version.h index 9e1953a97a..088a0f7217 100644 --- a/Generals/Code/GameEngine/Include/Common/version.h +++ b/Generals/Code/GameEngine/Include/Common/version.h @@ -28,9 +28,6 @@ #pragma once -#ifndef __VERSION_H__ -#define __VERSION_H__ - #include /** @@ -120,5 +117,3 @@ class Version }; extern Version *TheVersion; - -#endif // __VERSION_H__ diff --git a/Generals/Code/GameEngine/Include/GameClient/Anim2D.h b/Generals/Code/GameEngine/Include/GameClient/Anim2D.h index 439d51a224..e3853a3710 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Anim2D.h +++ b/Generals/Code/GameEngine/Include/GameClient/Anim2D.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __ANIM_2D_H_ -#define __ANIM_2D_H_ - // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Common/Snapshot.h" @@ -52,11 +49,11 @@ enum Anim2DMode CPP_11(: Int) ANIM_2D_PING_PONG_BACKWARDS, // dont' forget to add new animation mode names to Anim2DModeNames[] below - ANIM_2D_NUM_MODES // keep this last please + ANIM_2D_NUM_MODES }; #ifdef DEFINE_ANIM_2D_MODE_NAMES -static const char *Anim2DModeNames[] = +static const char *const Anim2DModeNames[] = { "NONE", "ONCE", @@ -67,6 +64,7 @@ static const char *Anim2DModeNames[] = "PING_PONG_BACKWARDS", NULL }; +static_assert(ARRAY_SIZE(Anim2DModeNames) == ANIM_2D_NUM_MODES + 1, "Incorrect array size"); #endif // ------------------------------------------------------------------------------------------------ @@ -221,5 +219,3 @@ class Anim2DCollection : public SubsystemInterface // EXTERNALS ////////////////////////////////////////////////////////////////////////////////////// extern Anim2DCollection *TheAnim2DCollection; - -#endif // end __ANIM_2D_H_ diff --git a/Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h b/Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h index 85a5a1229e..523a4276f5 100644 --- a/Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h +++ b/Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h @@ -47,9 +47,6 @@ #pragma once -#ifndef __ANIMATEWINDOWMANAGER_H_ -#define __ANIMATEWINDOWMANAGER_H_ - //----------------------------------------------------------------------------- // SYSTEM INCLUDES //////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -232,9 +229,7 @@ namespace wnd inline Bool AnimateWindowManager::isFinished( void ) { return !m_needsUpdate; }; inline Bool AnimateWindowManager::isReversed( void ) { return m_reverse; }; - inline Bool AnimateWindowManager::isEmpty( void ){return (m_winList.size() == 0 && m_winMustFinishList.size() == 0); } + inline Bool AnimateWindowManager::isEmpty( void ){return (m_winList.empty() && m_winMustFinishList.empty()); } //----------------------------------------------------------------------------- // EXTERNALS ////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- - -#endif // __ANIMATEWINDOWMANAGER_H_ diff --git a/Generals/Code/GameEngine/Include/GameClient/CDCheck.h b/Generals/Code/GameEngine/Include/GameClient/CDCheck.h index bf1eddb3f6..e5e3a8921e 100644 --- a/Generals/Code/GameEngine/Include/GameClient/CDCheck.h +++ b/Generals/Code/GameEngine/Include/GameClient/CDCheck.h @@ -29,12 +29,7 @@ #pragma once -#ifndef __CDCHECK_H_ -#define __CDCHECK_H_ - typedef void (*gameStartCallback) (void); Bool IsFirstCDPresent(void); void CheckForCDAtGameStart( gameStartCallback callback ); - -#endif //__CDCHECK_H_ diff --git a/Generals/Code/GameEngine/Include/GameClient/CampaignManager.h b/Generals/Code/GameEngine/Include/GameClient/CampaignManager.h index e39c383962..2ea11594e4 100644 --- a/Generals/Code/GameEngine/Include/GameClient/CampaignManager.h +++ b/Generals/Code/GameEngine/Include/GameClient/CampaignManager.h @@ -45,9 +45,6 @@ #pragma once -#ifndef __CAMPAIGN_MANAGER_H_ -#define __CAMPAIGN_MANAGER_H_ - //----------------------------------------------------------------------------- // SYSTEM INCLUDES //////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- @@ -164,5 +161,3 @@ class CampaignManager : public Snapshot // EXTERNALS ////////////////////////////////////////////////////////////////// //----------------------------------------------------------------------------- extern CampaignManager *TheCampaignManager; - -#endif // __CAMPAIGN_MANAGER_H_ diff --git a/Generals/Code/GameEngine/Include/GameClient/Color.h b/Generals/Code/GameEngine/Include/GameClient/Color.h index 568c211f6a..87c497de18 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Color.h +++ b/Generals/Code/GameEngine/Include/GameClient/Color.h @@ -45,9 +45,6 @@ #pragma once -#ifndef __COLOR_H_ -#define __COLOR_H_ - // SYSTEM INCLUDES //////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////// @@ -88,6 +85,3 @@ extern void GameGetColorComponents( Color color, extern void GameGetColorComponentsReal( Color color, Real *red, Real *green, Real *blue, Real *alpha ); extern Color GameDarkenColor( Color color, Int percent = 10 ); - -#endif // __COLOR_H_ - diff --git a/Generals/Code/GameEngine/Include/GameClient/CommandXlat.h b/Generals/Code/GameEngine/Include/GameClient/CommandXlat.h index 4e74662202..aebea584fa 100644 --- a/Generals/Code/GameEngine/Include/GameClient/CommandXlat.h +++ b/Generals/Code/GameEngine/Include/GameClient/CommandXlat.h @@ -27,9 +27,6 @@ #pragma once -#ifndef _H_CommandXlat -#define _H_CommandXlat - #include "GameClient/InGameUI.h" enum GUICommandType CPP_11(: Int); @@ -79,6 +76,7 @@ enum FilterTypes CPP_11(: Int) FT_VIEW_BW_FILTER, //filter to apply a black & white filter to the screen. FT_VIEW_MOTION_BLUR_FILTER, //filter to apply motion blur filter to screen. FT_VIEW_CROSSFADE, /// +#include //---------------------------------------------------------------------------- @@ -83,7 +79,6 @@ class DebugDisplayInterface RED, GREEN, BLUE, - NUM_COLORS }; virtual ~DebugDisplayInterface() {}; @@ -150,7 +145,3 @@ extern void AudioDebugDisplay( DebugDisplayInterface *debugDisplay, void *userDa //---------------------------------------------------------------------------- // Inlining //---------------------------------------------------------------------------- - - - -#endif // __GAMECLIENT_DEBUGDISPLAY_H diff --git a/Generals/Code/GameEngine/Include/GameClient/Diplomacy.h b/Generals/Code/GameEngine/Include/GameClient/Diplomacy.h index 0011d93d7d..a26861cf43 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Diplomacy.h +++ b/Generals/Code/GameEngine/Include/GameClient/Diplomacy.h @@ -28,13 +28,8 @@ #pragma once -#ifndef __DIPLOMACY_H__ -#define __DIPLOMACY_H__ - void PopulateInGameDiplomacyPopup( void ); void UpdateDiplomacyBriefingText(AsciiString newText, Bool clear); typedef std::list BriefingList; BriefingList* GetBriefingTextList(void); - -#endif // #ifndef __DIPLOMACY_H__ diff --git a/Generals/Code/GameEngine/Include/GameClient/DisconnectMenu.h b/Generals/Code/GameEngine/Include/GameClient/DisconnectMenu.h index 7561cc3705..457c263feb 100644 --- a/Generals/Code/GameEngine/Include/GameClient/DisconnectMenu.h +++ b/Generals/Code/GameEngine/Include/GameClient/DisconnectMenu.h @@ -22,12 +22,8 @@ // // //////////////////////////////////////////////////////////////////////////////// - #pragma once -#ifndef __DISCONNECTDIALOG_H -#define __DISCONNECTDIALOG_H - #include "GameNetwork/DisconnectManager.h" enum DisconnectMenuStateType CPP_11(: Int) { @@ -69,15 +65,13 @@ class DisconnectMenu { DisconnectManager *m_disconnectManager; ///< For retrieving status updates from the disconnect manager. DisconnectMenuStateType m_menuState; ///< The current state of the menu screen. - static const char *m_playerNameTextControlNames[MAX_SLOTS]; ///< names of the player name controls in the window. - static const char *m_playerTimeoutTextControlNames[MAX_SLOTS]; ///< names of the timeout controls in the window. - static const char *m_playerVoteButtonControlNames[MAX_SLOTS]; ///< names of the vote button controls in the window. - static const char *m_playerVoteCountControlNames[MAX_SLOTS]; ///< names of the vote count static text controls in the window. - static const char *m_packetRouterTimeoutControlName; ///< name of the packet router timeout control window. - static const char *m_packetRouterTimeoutLabelControlName; ///< name of the packet router timeout label control window. - static const char *m_textDisplayControlName; ///< name of the text display listbox control window. + static const char *const m_playerNameTextControlNames[MAX_SLOTS]; ///< names of the player name controls in the window. + static const char *const m_playerTimeoutTextControlNames[MAX_SLOTS]; ///< names of the timeout controls in the window. + static const char *const m_playerVoteButtonControlNames[MAX_SLOTS]; ///< names of the vote button controls in the window. + static const char *const m_playerVoteCountControlNames[MAX_SLOTS]; ///< names of the vote count static text controls in the window. + static const char *const m_packetRouterTimeoutControlName; ///< name of the packet router timeout control window. + static const char *const m_packetRouterTimeoutLabelControlName; ///< name of the packet router timeout label control window. + static const char *const m_textDisplayControlName; ///< name of the text display listbox control window. }; extern DisconnectMenu *TheDisconnectMenu; - -#endif // #ifndef __DISCONNECTDIALOG_H diff --git a/Generals/Code/GameEngine/Include/GameClient/Display.h b/Generals/Code/GameEngine/Include/GameClient/Display.h index 93f82c4855..3d6a9d857c 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Display.h +++ b/Generals/Code/GameEngine/Include/GameClient/Display.h @@ -28,16 +28,10 @@ #pragma once -#ifndef _GAME_DISPLAY_H_ -#define _GAME_DISPLAY_H_ - -#include #include "Common/SubsystemInterface.h" -#include "View.h" #include "GameClient/Color.h" #include "GameClient/GameFont.h" - -class View; +#include "GameClient/View.h" struct ShroudLevel { @@ -109,6 +103,7 @@ class Display : public SubsystemInterface virtual void drawViews( void ); ///< Render all views of the world virtual void updateViews ( void ); ///< Updates state of world views + virtual void stepViews(); ///< Update views for every fixed time step virtual VideoBuffer* createVideoBuffer( void ) = 0; ///< Create a video buffer that can be used for this display @@ -118,6 +113,7 @@ class Display : public SubsystemInterface virtual Bool isClippingEnabled( void ) = 0; virtual void enableClipping( Bool onoff ) = 0; + virtual void step() {}; ///< Do one fixed time step virtual void draw( void ); ///< Redraw the entire display virtual void setTimeOfDay( TimeOfDay tod ) = 0; ///< Set the time of day for this display virtual void createLightPulse( const Coord3D *pos, const RGBColor *color, Real innerRadius,Real attenuationWidth, @@ -175,6 +171,7 @@ class Display : public SubsystemInterface virtual void toggleLetterBox(void) = 0; ///< enabled letter-boxed display virtual void enableLetterBox(Bool enable) = 0; ///< forces letter-boxed display on/off virtual Bool isLetterBoxFading( void ) { return FALSE; } ///< returns true while letterbox fades in/out + virtual Bool isLetterBoxed( void ) { return FALSE; } //WST 10/2/2002. Added query interface virtual void setCinematicText( AsciiString string ) { m_cinematicText = string; } virtual void setCinematicFont( GameFont *font ) { m_cinematicFont = font; } @@ -221,10 +218,8 @@ extern Display *TheDisplay; extern void StatDebugDisplay( DebugDisplayInterface *dd, void *, FILE *fp = NULL ); -//Added By Saad //Necessary for display resolution confirmation dialog box //Holds the previous and current display settings - typedef struct _DisplaySettings { Int xRes; //Resolution width @@ -232,6 +227,3 @@ typedef struct _DisplaySettings Int bitDepth; //Color Depth Bool windowed; //Window mode TRUE: we're windowed, FALSE: we're not windowed } DisplaySettings; - - -#endif // _GAME_DISPLAY_H_ diff --git a/Generals/Code/GameEngine/Include/GameClient/DisplayString.h b/Generals/Code/GameEngine/Include/GameClient/DisplayString.h index 4b586e76ca..164ad25bbb 100644 --- a/Generals/Code/GameEngine/Include/GameClient/DisplayString.h +++ b/Generals/Code/GameEngine/Include/GameClient/DisplayString.h @@ -46,9 +46,6 @@ #pragma once -#ifndef __DISPLAYSTRING_H_ -#define __DISPLAYSTRING_H_ - // SYSTEM INCLUDES //////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////// @@ -115,7 +112,7 @@ class DisplayString : public MemoryPoolObject DisplayString *m_next; ///< for the display string factory list ONLY DisplayString *m_prev; ///< for the display string factory list ONLY -}; // end DisplayString +}; /////////////////////////////////////////////////////////////////////////////// // INLINING /////////////////////////////////////////////////////////////////// @@ -129,6 +126,3 @@ inline void DisplayString::notifyTextChanged( void ) {} inline DisplayString *DisplayString::next( void ) { return m_next; } // EXTERNALS ////////////////////////////////////////////////////////////////// - -#endif // __DISPLAYSTRING_H_ - diff --git a/Generals/Code/GameEngine/Include/GameClient/DisplayStringManager.h b/Generals/Code/GameEngine/Include/GameClient/DisplayStringManager.h index 2fe0260011..6ce394d3fe 100644 --- a/Generals/Code/GameEngine/Include/GameClient/DisplayStringManager.h +++ b/Generals/Code/GameEngine/Include/GameClient/DisplayStringManager.h @@ -29,9 +29,6 @@ #pragma once -#ifndef __DISPLAYSTRINGMANAGER_H_ -#define __DISPLAYSTRINGMANAGER_H_ - #include "Common/SubsystemInterface.h" #include "GameClient/DisplayString.h" @@ -66,6 +63,3 @@ class DisplayStringManager : public SubsystemInterface // EXTERNALS ////////////////////////////////////////////////////////////////////////////////////// extern DisplayStringManager *TheDisplayStringManager; ///< singleton extern - -#endif // __DISPLAYSTRINGMANAGER_H_ - diff --git a/Generals/Code/GameEngine/Include/GameClient/DrawGroupInfo.h b/Generals/Code/GameEngine/Include/GameClient/DrawGroupInfo.h index d00e0a720b..0637bd8ec4 100644 --- a/Generals/Code/GameEngine/Include/GameClient/DrawGroupInfo.h +++ b/Generals/Code/GameEngine/Include/GameClient/DrawGroupInfo.h @@ -27,8 +27,6 @@ // Author: John K. McDonald, March 2002 #pragma once -#ifndef _H_DRAWGROUPINFO_ -#define _H_DRAWGROUPINFO_ struct DrawGroupInfo { @@ -64,5 +62,3 @@ struct DrawGroupInfo }; extern DrawGroupInfo *TheDrawGroupInfo; - -#endif /* _H_DRAWGROUPINFO */ diff --git a/Generals/Code/GameEngine/Include/GameClient/Drawable.h b/Generals/Code/GameEngine/Include/GameClient/Drawable.h index d9c52dd4d0..8d4c158d7c 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Drawable.h +++ b/Generals/Code/GameEngine/Include/GameClient/Drawable.h @@ -27,8 +27,6 @@ // Author: Michael S. Booth, March 2001 #pragma once -#ifndef _DRAWABLE_H_ -#define _DRAWABLE_H_ #include "Common/AudioEventRTS.h" #include "Common/GameType.h" @@ -81,9 +79,8 @@ enum DrawableIconType CPP_11(: Int) /** NOTE: This enum MUST appear in the same order as TheDrawableIconNames array to be * indexed correctly using that array */ ICON_INVALID = -1, - ICON_FIRST = 0, - ICON_DEFAULT_HEAL = ICON_FIRST, + ICON_DEFAULT_HEAL, ICON_STRUCTURE_HEAL, ICON_VEHICLE_HEAL, #ifdef ALLOW_DEMORALIZE @@ -102,7 +99,8 @@ enum DrawableIconType CPP_11(: Int) ICON_ENTHUSIASTIC_SUBLIMINAL, ICON_CARBOMB, - MAX_ICONS ///< keep this last + MAX_ICONS, + ICON_FIRST = 0, }; //----------------------------------------------------------------------------- @@ -168,7 +166,7 @@ class TintEnvelope : public MemoryPoolObject, public Snapshot TintEnvelope(void); void update(void); ///< does all the work void play(const RGBColor *peak, - UnsignedInt atackFrames = DEF_ATTACK_FRAMES, + UnsignedInt attackFrames = DEF_ATTACK_FRAMES, UnsignedInt decayFrames = DEF_DECAY_FRAMES, UnsignedInt sustainAtPeak = DEF_SUSTAIN_FRAMES ); // ask MLorenzen void sustain(void) { m_envState = ENVELOPE_STATE_SUSTAIN; } @@ -203,7 +201,7 @@ class TintEnvelope : public MemoryPoolObject, public Snapshot Vector3 m_decayRate; ///< step amount to make tint turn off slow or fast Vector3 m_peakColor; ///< um, the peak color, what color we are headed toward during attack Vector3 m_currentColor; ///< um, the current color, how we are colored, now - UnsignedInt m_sustainCounter; + Real m_sustainCounter; Byte m_envState; ///< a randomly switchable SUSTAIN state, release is compliment Bool m_affect; ///< set TRUE if this has any effect (has a non 0,0,0 color). }; @@ -225,14 +223,16 @@ enum StealthLookType CPP_11(: Int) // ------------------------------------------------------------------------------------------------ /** Drawable status bits */ // ------------------------------------------------------------------------------------------------ -enum DrawableStatus CPP_11(: Int) +typedef UnsignedInt DrawableStatusBits; +enum DrawableStatus CPP_11(: DrawableStatusBits) { DRAWABLE_STATUS_NONE = 0x00000000, ///< no status DRAWABLE_STATUS_DRAWS_IN_MIRROR = 0x00000001, ///< drawable can reflect DRAWABLE_STATUS_SHADOWS = 0x00000002, ///< use setShadowsEnabled() access method - DRAWABLE_STATUS_TINT_COLOR_LOCKED = 0x00000004, ///< drawable tint color is "locked" and won't fade to normal DRAWABLE_STATUS_NO_STATE_PARTICLES = 0x00000008, ///< do *not* auto-create particle systems based on model condition DRAWABLE_STATUS_NO_SAVE = 0x00000010, ///< do *not* save this drawable (UI fluff only). ignored (error, actually) if attached to an object + + DRAWABLE_STATUS_DEFAULT = DRAWABLE_STATUS_SHADOWS, }; enum TintStatus CPP_11(: Int) @@ -261,13 +261,24 @@ enum TerrainDecalType CPP_11(: Int) TERRAIN_DECAL_HORDE_VEHICLE, TERRAIN_DECAL_HORDE_WITH_NATIONALISM_UPGRADE_VEHICLE, TERRAIN_DECAL_CRATE, +#if RTS_GENERALS && RETAIL_COMPATIBLE_XFER_SAVE TERRAIN_DECAL_NONE, + TERRAIN_DECAL_HORDE_WITH_FANATICISM_UPGRADE, + TERRAIN_DECAL_CHEMSUIT, +#else + TERRAIN_DECAL_HORDE_WITH_FANATICISM_UPGRADE, + TERRAIN_DECAL_CHEMSUIT, + TERRAIN_DECAL_NONE, +#endif + TERRAIN_DECAL_SHADOW_TEXTURE, //use the shadow texture as the terrain decal. - TERRAIN_DECAL_MAX ///< keep this last + TERRAIN_DECAL_MAX }; //----------------------------------------------------------------------------- +constexpr const UnsignedInt InvalidShroudClearFrame = ~0u; + const Int DRAWABLE_FRAMES_PER_FLASH = LOGICFRAMES_PER_SECOND / 2; //----------------------------------------------------------------------------- @@ -283,7 +294,7 @@ class Drawable : public Thing, public: - Drawable( const ThingTemplate *thing, DrawableStatus statusBits = DRAWABLE_STATUS_NONE ); + Drawable( const ThingTemplate *thing, DrawableStatusBits statusBits = DRAWABLE_STATUS_DEFAULT ); void onDestroy( void ); ///< run from GameClient::destroyDrawable @@ -304,17 +315,17 @@ class Drawable : public Thing, void setTerrainDecalSize(Real x, Real y); void setTerrainDecalFadeTarget(Real target, Real rate = 0.1f); - inline Object *getObject( void ) { return m_object; } ///< return object ID bound to this drawble - inline const Object *getObject( void ) const { return m_object; } ///< return object ID bound to this drawble + Object *getObject( void ) { return m_object; } ///< return object ID bound to this drawble + const Object *getObject( void ) const { return m_object; } ///< return object ID bound to this drawble - inline DrawableInfo *getDrawableInfo(void) {return &m_drawableInfo;} + DrawableInfo *getDrawableInfo(void) {return &m_drawableInfo;} void setDrawableHidden( Bool hidden ); ///< hide or unhide drawable // // note that this is not necessarily the 'get' reflection of setDrawableHidden, since drawables // can spontaneously hide via stealth. (srj) // - inline Bool isDrawableEffectivelyHidden() const { return m_hidden || m_hiddenByStealth; } + Bool isDrawableEffectivelyHidden() const { return m_hidden || m_hiddenByStealth; } void setSelectable( Bool selectable ); ///< Changes the drawables selectability Bool isSelectable( void ) const; @@ -346,13 +357,14 @@ class Drawable : public Thing, ClientUpdateModule const** getClientUpdateModules() const { return (ClientUpdateModule const**)getModuleList(MODULETYPE_CLIENT_UPDATE); } ClientUpdateModule* findClientUpdateModule( NameKeyType key ); + // never returns null DrawModule** getDrawModules(); DrawModule const** getDrawModules() const; //--------------------------------------------------------------------------- void setDrawableStatus( DrawableStatus bit ) { BitSet( m_status, bit ); } void clearDrawableStatus( DrawableStatus bit ) { BitClear( m_status, bit ); } - inline Bool testDrawableStatus( DrawableStatus bit ) const { return (m_status & bit) != 0; } + Bool testDrawableStatus( DrawableStatus bit ) const { return (m_status & bit) != 0; } void setShroudClearFrame( UnsignedInt frame ) { m_shroudClearFrame = frame; } UnsignedInt getShroudClearFrame( void ) { return m_shroudClearFrame; } @@ -364,11 +376,11 @@ class Drawable : public Thing, void allocateShadows(void); ///< create shadow resources if not already present. Used by Options screen. void setFullyObscuredByShroud(Bool fullyObscured); - inline Bool getFullyObscuredByShroud(void) {return m_drawableFullyObscuredByShroud;} + Bool getFullyObscuredByShroud(void) {return m_drawableFullyObscuredByShroud;} Bool getDrawsInMirror() const { return BitIsSet(m_status, DRAWABLE_STATUS_DRAWS_IN_MIRROR) || isKindOf(KINDOF_CAN_CAST_REFLECTIONS); } - void colorFlash( const RGBColor *color, UnsignedInt decayFrames = DEF_DECAY_FRAMES, UnsignedInt attackFrames = 0, UnsignedInt sustainAtPeak = FALSE ); ///< flash a drawable in the color specified for a short time + void colorFlash( const RGBColor *color, UnsignedInt decayFrames = DEF_DECAY_FRAMES, UnsignedInt attackFrames = 0, UnsignedInt sustainAtPeak = 0 ); ///< flash a drawable in the color specified for a short time void colorTint( const RGBColor *color ); ///< tint this drawable the color specified void setTintEnvelope( const RGBColor *color, Real attack, Real decay ); ///< how to transition color void flashAsSelected( const RGBColor *color = NULL ); ///< drawable takes care of the details if you spec no color @@ -383,14 +395,14 @@ class Drawable : public Thing, // an "instance" matrix defines the local transform of the Drawable, and is concatenated with the global transform void setInstanceMatrix( const Matrix3D *instance ); ///< set the Drawable's instance transform const Matrix3D *getInstanceMatrix( void ) const { return &m_instance; } ///< get drawable instance transform - inline Bool isInstanceIdentity() const { return m_instanceIsIdentity; } + Bool isInstanceIdentity() const { return m_instanceIsIdentity; } - inline Real getInstanceScale( void ) const { return m_instanceScale; } ///< get scale that will be applied to instance matrix + Real getInstanceScale( void ) const { return m_instanceScale; } ///< get scale that will be applied to instance matrix void setInstanceScale(Real value) { m_instanceScale = value;} ///< set scale that will be applied to instance matrix before rendering. const Matrix3D *getTransformMatrix( void ) const; ///< return the world transform - void draw( View *view ); ///< render the drawable to the given view + void draw(); ///< render the drawable to the given view void updateDrawable(); ///< update the drawable void drawIconUI( void ); ///< draw "icon"(s) needed on drawable (health bars, veterency, etc) @@ -404,7 +416,7 @@ class Drawable : public Thing, void removeFromList(Drawable **pListHead); void setID( DrawableID id ); ///< set this drawable's unique ID - inline const ModelConditionFlags& getModelConditionFlags( void ) const { return m_conditionState; } + const ModelConditionFlags& getModelConditionFlags( void ) const { return m_conditionState; } // // NOTE: avoid repeated calls to the set and clear for the condition state as they @@ -504,16 +516,16 @@ class Drawable : public Thing, const Vector3 * getTintColor( void ) const; ///< get FX color value to add to ALL LIGHTS when drawing const Vector3 * getSelectionColor( void ) const; ///< get FX color value to add to ALL LIGHTS when drawing - inline TerrainDecalType getTerrainDecalType( void ) const { return m_terrainDecalType; } + TerrainDecalType getTerrainDecalType( void ) const { return m_terrainDecalType; } - inline void setDrawableOpacity( Real value ) { m_explicitOpacity = value; } ///< set alpha/opacity value used to override defaults when drawing. + void setDrawableOpacity( Real value ) { m_explicitOpacity = value; } ///< set alpha/opacity value used to override defaults when drawing. // note that this is not the 'get' inverse of setDrawableOpacity, since stealthing can also affect the effective opacity! - inline Real getEffectiveOpacity() const { return m_explicitOpacity * m_effectiveStealthOpacity; } ///< get alpha/opacity value used to override defaults when drawing. + Real getEffectiveOpacity() const { return m_explicitOpacity * m_effectiveStealthOpacity; } ///< get alpha/opacity value used to override defaults when drawing. void setEffectiveOpacity( Real pulseFactor, Real explicitOpacity = -1.0f ); // this is for the heatvision effect which operates completely independently of the stealth opacity effects. Draw() does the fading every frame. - inline Real getHeatVisionOpacity() const { return m_heatVisionOpacity; } ///< get alpha/opacity value used to render add'l heatvision rendering pass. + Real getHeatVisionOpacity() const { return m_heatVisionOpacity; } ///< get alpha/opacity value used to render add'l heatvision rendering pass. void setHeatVisionOpacity( Real op ) { m_heatVisionOpacity = op; }; ///< set alpha/opacity value used to render add'l heatvision rendering pass. // both of these assume that you are starting at one extreme 100% or 0% opacity and are trying to go to the other!! -- amit @@ -559,13 +571,13 @@ class Drawable : public Thing, Drawable *asDrawableMeth() { return this; } const Drawable *asDrawableMeth() const { return this; } - inline Module** getModuleList(ModuleType i) + Module** getModuleList(ModuleType i) { Module** m = m_modules[i - FIRST_DRAWABLE_MODULE_TYPE]; return m; } - inline Module* const* getModuleList(ModuleType i) const + Module* const* getModuleList(ModuleType i) const { Module** m = m_modules[i - FIRST_DRAWABLE_MODULE_TYPE]; return m; @@ -598,8 +610,12 @@ class Drawable : public Thing, virtual void reactToTransformChange(const Matrix3D* oldMtx, const Coord3D* oldPos, Real oldAngle); void updateHiddenStatus(); + void replaceModelConditionStateInDrawable(); + private: + const Locomotor* getLocomotor() const; + // note, these are lazily allocated! TintEnvelope* m_selectionFlashEnvelope; ///< used for selection flash, works WITH m_colorTintEnvelope TintEnvelope* m_colorTintEnvelope; ///< house color flashing, etc... works WITH m_selectionFlashEnvelope @@ -626,7 +642,7 @@ class Drawable : public Thing, Drawable *m_nextDrawable; Drawable *m_prevDrawable; ///< list links - UnsignedInt m_status; ///< status bits (see DrawableStatus enum) + DrawableStatusBits m_status; ///< status bits (see DrawableStatus enum) UnsignedInt m_tintStatus; ///< tint color status bits (see TintStatus enum) UnsignedInt m_prevTintStatus;///< for edge testing with m_tintStatus @@ -644,6 +660,8 @@ class Drawable : public Thing, DrawableLocoInfo* m_locoInfo; // lazily allocated + PhysicsXformInfo* m_physicsXform; + DynamicAudioEventRTS* m_ambientSound; ///< sound module for ambient sound (lazily allocated) Bool m_ambientSoundEnabled; @@ -677,7 +695,7 @@ class Drawable : public Thing, Bool m_instanceIsIdentity; ///< If true, instance matrix can be skipped Bool m_drawableFullyObscuredByShroud; ///