diff --git a/.github/workflows/build-historical.yml b/.github/workflows/build-historical.yml new file mode 100644 index 00000000000..46dd7daa7f3 --- /dev/null +++ b/.github/workflows/build-historical.yml @@ -0,0 +1,278 @@ +name: Build Historical + +permissions: + contents: write + +on: + workflow_dispatch: + inputs: + commit: + description: 'Commit SHA to build' + required: true + type: string + pull_requests: + description: 'PR numbers to cherry-pick (comma-separated, e.g., "545,876")' + required: false + default: '' + type: string + game: + description: 'Game to build' + required: true + default: 'GeneralsMD' + type: choice + options: + - 'Generals' + - 'GeneralsMD' + - 'Both' + create_release: + description: 'Create a GitHub release' + required: false + default: 'true' + type: choice + options: + - 'true' + - 'false' + +concurrency: + group: ${{ github.workflow }}-${{ github.event.inputs.commit }} + cancel-in-progress: false + +jobs: + prepare: + name: Prepare Build Info + runs-on: ubuntu-latest + outputs: + short_sha: ${{ steps.info.outputs.short_sha }} + commit_date: ${{ steps.info.outputs.commit_date }} + commit_subject: ${{ steps.info.outputs.commit_subject }} + release_tag: ${{ steps.info.outputs.release_tag }} + steps: + - name: Checkout Code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + - name: Gather Commit Info + id: info + run: | + COMMIT="${{ github.event.inputs.commit }}" + + if ! git cat-file -e "$COMMIT^{commit}" 2>/dev/null; then + echo "::error::Commit $COMMIT not found in repository" + exit 1 + fi + + SHORT_SHA=$(git rev-parse --short=7 "$COMMIT") + COMMIT_DATE=$(git show -s --format=%cs "$COMMIT") + COMMIT_SUBJECT=$(git show -s --format=%s "$COMMIT" | head -c 80) + + PR_SUFFIX="" + if [ -n "${{ github.event.inputs.pull_requests }}" ]; then + PR_SUFFIX="+pr${{ github.event.inputs.pull_requests }}" + fi + RELEASE_TAG="historical-${COMMIT_DATE}-${SHORT_SHA}${PR_SUFFIX}" + + echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT + echo "commit_date=$COMMIT_DATE" >> $GITHUB_OUTPUT + echo "commit_subject=$COMMIT_SUBJECT" >> $GITHUB_OUTPUT + echo "release_tag=$RELEASE_TAG" >> $GITHUB_OUTPUT + + echo "### Build Info" >> $GITHUB_STEP_SUMMARY + echo "- Commit: \`$COMMIT\` ($SHORT_SHA)" >> $GITHUB_STEP_SUMMARY + echo "- Date: $COMMIT_DATE" >> $GITHUB_STEP_SUMMARY + echo "- Subject: $COMMIT_SUBJECT" >> $GITHUB_STEP_SUMMARY + echo "- PRs to apply: ${{ github.event.inputs.pull_requests || 'none' }}" >> $GITHUB_STEP_SUMMARY + echo "- Release tag: $RELEASE_TAG" >> $GITHUB_STEP_SUMMARY + + build: + name: Build ${{ matrix.game }} vc6 + needs: prepare + runs-on: windows-2022 + timeout-minutes: 30 + strategy: + matrix: + game: ${{ github.event.inputs.game == 'Both' && fromJson('["Generals", "GeneralsMD"]') || fromJson(format('["{0}"]', github.event.inputs.game)) }} + fail-fast: false + + steps: + - name: Checkout Target Commit + uses: actions/checkout@v4 + with: + ref: ${{ github.event.inputs.commit }} + fetch-depth: 0 + + - name: Apply Pull Requests + if: ${{ github.event.inputs.pull_requests != '' }} + shell: bash + run: | + git config user.name "GitHub Actions" + git config user.email "actions@github.com" + + PR_LIST="${{ github.event.inputs.pull_requests }}" + IFS=',' read -ra PRS <<< "$PR_LIST" + + for PR in "${PRS[@]}"; do + PR=$(echo "$PR" | xargs) + echo "::group::Applying PR #$PR" + + git fetch origin "pull/$PR/head:pr-$PR" + + PR_BASE=$(git merge-base pr-$PR HEAD) + PR_COMMITS=$(git rev-list --reverse "$PR_BASE..pr-$PR") + + for COMMIT in $PR_COMMITS; do + echo "Cherry-picking $COMMIT" + if ! git cherry-pick --no-commit "$COMMIT"; then + echo "::error::Failed to cherry-pick commit $COMMIT from PR #$PR" + git cherry-pick --abort || true + exit 1 + fi + done + + git commit -m "Apply PR #$PR" || echo "No changes to commit for PR #$PR" + echo "::endgroup::" + done + + - name: Cache VC6 Installation + id: cache-vc6 + uses: actions/cache@v4 + with: + path: C:\VC6 + key: vc6-permanent-cache-v2 + + - name: Download VC6 Portable + if: ${{ steps.cache-vc6.outputs.cache-hit != 'true' }} + env: + EXPECTED_HASH: "D0EE1F6DCEF7DB3AD703120D9FB4FAD49EBCA28F44372E40550348B1C00CA583" + VC6_COMMIT: "001c4bafdcf2ef4b474d693acccd35a91e848f40" + shell: pwsh + run: | + Invoke-WebRequest -Uri https://github.com/itsmattkc/MSVC600/archive/$env:VC6_COMMIT.zip -OutFile VS6_VisualStudio6.zip + + $fileHash = (Get-FileHash -Path VS6_VisualStudio6.zip -Algorithm SHA256).Hash + if ($fileHash -ne $env:EXPECTED_HASH) { + Write-Error "Hash verification failed!" + exit 1 + } + + Expand-Archive -Path VS6_VisualStudio6.zip -DestinationPath C:\VC6 + Move-Item -Path C:\VC6\MSVC600-$env:VC6_COMMIT -Destination C:\VC6\VC6SP6 + Remove-Item VS6_VisualStudio6.zip + + - name: Set Up VC6 Environment + shell: pwsh + run: | + $VSCommonDir = "C:\VC6\VC6SP6\Common" + $MSDevDir = "C:\VC6\VC6SP6\Common\msdev98" + $MSVCDir = "C:\VC6\VC6SP6\VC98" + $VcOsDir = "WINNT" + + "VSCommonDir=$VSCommonDir" >> $env:GITHUB_ENV + "MSDevDir=$MSDevDir" >> $env:GITHUB_ENV + "MSVCDir=$MSVCDir" >> $env:GITHUB_ENV + "VcOsDir=$VcOsDir" >> $env:GITHUB_ENV + "PATH=$MSDevDir\BIN;$MSVCDir\BIN;$VSCommonDir\TOOLS\$VcOsDir;$VSCommonDir\TOOLS;$env:PATH" >> $env:GITHUB_ENV + "INCLUDE=$MSVCDir\ATL\INCLUDE;$MSVCDir\INCLUDE;$MSVCDir\MFC\INCLUDE;$env:INCLUDE" >> $env:GITHUB_ENV + "LIB=$MSVCDir\LIB;$MSVCDir\MFC\LIB;$env:LIB" >> $env:GITHUB_ENV + + - name: Configure with CMake + shell: pwsh + run: | + $buildFlags = @( + "-DRTS_BUILD_ZEROHOUR=${{ matrix.game == 'GeneralsMD' && 'ON' || 'OFF' }}", + "-DRTS_BUILD_GENERALS=${{ matrix.game == 'Generals' && 'ON' || 'OFF' }}", + "-DRTS_BUILD_CORE_TOOLS=ON", + "-DRTS_BUILD_${{ matrix.game == 'Generals' && 'GENERALS' || 'ZEROHOUR' }}_TOOLS=ON" + ) + cmake --preset vc6 $buildFlags + + - name: Build with CMake + shell: pwsh + run: | + cmake --build --preset vc6 + + - name: Collect Artifacts + shell: pwsh + run: | + $buildDir = "build\vc6" + $artifactsDir = New-Item -ItemType Directory -Force -Path "$buildDir\${{ matrix.game }}\artifacts" + + $files = Get-ChildItem -Path "$buildDir\Core","$buildDir\${{ matrix.game }}" -File | + Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } + + $files | Move-Item -Destination $artifactsDir -Force + + - name: Upload Artifact + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.game }}-vc6-${{ needs.prepare.outputs.short_sha }} + path: build\vc6\${{ matrix.game }}\artifacts + retention-days: 90 + + create-release: + name: Create Release + needs: [prepare, build] + if: ${{ github.event.inputs.create_release == 'true' }} + runs-on: ubuntu-latest + steps: + - name: Download Generals Artifact + if: ${{ github.event.inputs.game == 'Generals' || github.event.inputs.game == 'Both' }} + uses: actions/download-artifact@v4 + with: + name: Generals-vc6-${{ needs.prepare.outputs.short_sha }} + path: generals-artifacts + + - name: Download GeneralsMD Artifact + if: ${{ github.event.inputs.game == 'GeneralsMD' || github.event.inputs.game == 'Both' }} + uses: actions/download-artifact@v4 + with: + name: GeneralsMD-vc6-${{ needs.prepare.outputs.short_sha }} + path: generalsmd-artifacts + + - name: Prepare Release Archives + run: | + if [ -d "generals-artifacts" ]; then + zip -jr generals-${{ needs.prepare.outputs.release_tag }}.zip generals-artifacts/* + fi + if [ -d "generalsmd-artifacts" ]; then + zip -jr generalszh-${{ needs.prepare.outputs.release_tag }}.zip generalsmd-artifacts/* + fi + + - name: Generate Release Notes + id: notes + run: | + BODY="## Historical Build + + **Commit:** \`${{ github.event.inputs.commit }}\` + **Date:** ${{ needs.prepare.outputs.commit_date }} + **Subject:** ${{ needs.prepare.outputs.commit_subject }}" + + if [ -n "${{ github.event.inputs.pull_requests }}" ]; then + BODY="${BODY} + + **Applied PRs:** ${{ github.event.inputs.pull_requests }}" + fi + + BODY="${BODY} + + --- + *Built for replay compatibility testing.*" + + echo "body<> $GITHUB_OUTPUT + echo "$BODY" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ needs.prepare.outputs.release_tag }} + name: ${{ needs.prepare.outputs.release_tag }} + prerelease: true + body: ${{ steps.notes.outputs.body }} + files: | + generals-${{ needs.prepare.outputs.release_tag }}.zip + generalszh-${{ needs.prepare.outputs.release_tag }}.zip + fail_on_unmatched_files: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/build-toolchain.yml b/.github/workflows/build-toolchain.yml index 5999ee132b5..6dcad70e0de 100644 --- a/.github/workflows/build-toolchain.yml +++ b/.github/workflows/build-toolchain.yml @@ -31,23 +31,16 @@ jobs: name: ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} runs-on: windows-2022 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 @@ -112,15 +105,65 @@ jobs: with: arch: x86 + - name: Compute vcpkg cache key parts + if: startsWith(inputs.preset, 'win32') + id: vcpkg_key + shell: pwsh + run: | + $baseline = (Get-Content vcpkg.json | ConvertFrom-Json)."builtin-baseline" + + $msvc = $env:VCToolsVersion + if (-not $msvc) { $msvc = "unknown" } + + # Reduce churn: keep major.minor (e.g. 14.44) + $msvcMajorMinor = ($msvc -split '\.')[0..1] -join '.' + + $triplet = "x86-windows" + if ("${{ inputs.preset }}" -like "x64*") { $triplet = "x64-windows" } + + "baseline=$baseline" >> $env:GITHUB_OUTPUT + "msvc=$msvcMajorMinor" >> $env:GITHUB_OUTPUT + "triplet=$triplet" >> $env:GITHUB_OUTPUT + + Write-Host "vcpkg cache key parts: baseline=$baseline, msvc=$msvcMajorMinor, triplet=$triplet" + + - name: Restore vcpkg binary cache + if: startsWith(inputs.preset, 'win32') + id: vcpkg_cache + uses: actions/cache/restore@v4 + with: + path: ${{ github.workspace }}\vcpkg-bincache + key: vcpkg-bincache-v2-${{ runner.os }}-msvc${{ steps.vcpkg_key.outputs.msvc }}-baseline${{ steps.vcpkg_key.outputs.baseline }}-${{ steps.vcpkg_key.outputs.triplet }} + restore-keys: | + vcpkg-bincache-v2-${{ runner.os }}-msvc${{ steps.vcpkg_key.outputs.msvc }}-baseline${{ steps.vcpkg_key.outputs.baseline }}- + vcpkg-bincache-v2-${{ runner.os }}- + - name: Setup vcpkg uses: lukka/run-vcpkg@v11 + with: + runVcpkgInstall: false + doNotCache: true + + - name: Configure vcpkg to use cached directory + if: startsWith(inputs.preset, 'win32') + shell: pwsh + run: | + $cacheDir = "${{ github.workspace }}\vcpkg-bincache" + New-Item -ItemType Directory -Force -Path $cacheDir | Out-Null + + # lukka/run-vcpkg sets its own temp cache dir; override to force our cached dir + $env:VCPKG_DEFAULT_BINARY_CACHE = $cacheDir + $env:VCPKG_BINARY_SOURCES = "clear;files,$cacheDir,readwrite" + + "VCPKG_DEFAULT_BINARY_CACHE=$cacheDir" >> $env:GITHUB_ENV + "VCPKG_BINARY_SOURCES=$env:VCPKG_BINARY_SOURCES" >> $env:GITHUB_ENV - name: Configure ${{ inputs.game }} with CMake Using ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset shell: pwsh run: | $buildFlags = @( - "-DRTS_BUILD_ZEROHOUR=${{ inputs.game == 'GeneralsMD' && 'ON' || 'OFF' }}", - "-DRTS_BUILD_GENERALS=${{ inputs.game == 'Generals' && 'ON' || 'OFF' }}" + "-DRTS_BUILD_ZEROHOUR=${{ inputs.game == 'GeneralsMD' && 'ON' || 'OFF' }}", + "-DRTS_BUILD_GENERALS=${{ inputs.game == 'Generals' && 'ON' || 'OFF' }}" ) $gamePrefix = "${{ inputs.game == 'Generals' && 'GENERALS' || 'ZEROHOUR' }}" @@ -130,7 +173,6 @@ jobs: $buildFlags += "-DRTS_BUILD_${gamePrefix}_EXTRAS=${{ inputs.extras && 'ON' || 'OFF' }}" Write-Host "Build flags: $($buildFlags -join ' | ')" - cmake --preset ${{ inputs.preset }} $buildFlags - name: Build ${{ inputs.game }} with CMake Using ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Preset @@ -138,19 +180,29 @@ jobs: run: | cmake --build --preset ${{ inputs.preset }} + - name: Save vcpkg binary cache + # Only one job should save to avoid "Unable to reserve cache" conflicts. + if: ${{ startsWith(inputs.preset, 'win32') && steps.vcpkg_cache.outputs.cache-hit != 'true' && inputs.game == 'Generals' && inputs.preset == 'win32-vcpkg-debug' }} + uses: actions/cache/save@v4 + with: + path: ${{ github.workspace }}\vcpkg-bincache + key: vcpkg-bincache-v2-${{ runner.os }}-msvc${{ steps.vcpkg_key.outputs.msvc }}-baseline${{ steps.vcpkg_key.outputs.baseline }}-${{ steps.vcpkg_key.outputs.triplet }} + - name: Collect ${{ inputs.game }} ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact shell: pwsh run: | $buildDir = "build\${{ inputs.preset }}" $artifactsDir = New-Item -ItemType Directory -Force -Path "$buildDir\${{ inputs.game }}\artifacts" -Verbose - if ("${{ inputs.preset }}" -like "win32*") { - # For win32 preset, look in config-specific subdirectories + if ("${{ inputs.preset }}" -like "win32*") { $configToUse = if ("${{ inputs.preset }}" -match "debug") { "Debug" } else { "Release" } - $files = Get-ChildItem -Path "$buildDir\Core\$configToUse","$buildDir\${{ inputs.game }}\$configToUse" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose - } else { - $files = Get-ChildItem -Path "$buildDir\Core","$buildDir\${{ inputs.game }}" -File | Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose + $files = Get-ChildItem -Path "$buildDir\Core\$configToUse","$buildDir\${{ inputs.game }}\$configToUse" -File | + Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose + } else { + $files = Get-ChildItem -Path "$buildDir\Core","$buildDir\${{ inputs.game }}" -File | + Where-Object { $_.Extension -in @(".exe", ".dll", ".pdb") } -Verbose } + $files | Move-Item -Destination $artifactsDir -Verbose -Force - name: Upload ${{ inputs.game }} ${{ inputs.preset }}${{ inputs.tools && '+t' || '' }}${{ inputs.extras && '+e' || '' }} Artifact diff --git a/.gitignore b/.gitignore index 1c9c525ae12..c8d724bcaef 100644 --- a/.gitignore +++ b/.gitignore @@ -47,6 +47,11 @@ thumbs.db .clang-format /.vscode /Dependencies/MaxSDK/maxsdk +/tmp/ + +## AI assistant config (user-specific) +/.claude/ +/CLAUDE.md ## IntelliJ, CLion, etc. /.idea @@ -57,4 +62,8 @@ cmake-build-*/ ## Ninja .ninja_deps .ninja_log -build.ninja \ No newline at end of file +build.ninja + +## Python +__pycache__/ +*.pyc \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 4160c918c74..28ce09560e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,8 +36,18 @@ project(genzh LANGUAGES C CXX) # This file handles extra settings wanted/needed for different compilers. include(cmake/compilers.cmake) +# Debug symbol stripping for Release builds (MinGW) +include(cmake/debug_strip.cmake) + include(FetchContent) +# MinGW-w64 specific configuration +if(MINGW) + include(cmake/mingw.cmake) + include(cmake/reactos-atl.cmake) + include(cmake/widl.cmake) +endif() + # Find/Add build dependencies and stubs shared by all projects if((WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") AND ${CMAKE_SIZEOF_VOID_P} EQUAL 4) include(cmake/miles.cmake) @@ -62,6 +72,13 @@ if (IS_VS6_BUILD) add_subdirectory(Dependencies/MaxSDK) endif() add_subdirectory(Dependencies/Utility) + +# To be removed when abandoning VC6 +if (IS_VS6_BUILD) + include_directories(Dependencies/Utility) + add_compile_options(/FIUtility/CppMacros.h) +endif() + add_subdirectory(resources) add_subdirectory(Core) diff --git a/CMakePresets.json b/CMakePresets.json index 3c7b6908ce7..a0c04f661b3 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -163,6 +163,37 @@ "inherits": "default-vcpkg", "hidden": false, "displayName": "Unix 32bit VCPKG Release" + }, + { + "name": "mingw-w64-i686", + "displayName": "MinGW-w64 32-bit (i686) Release", + "generator": "Unix Makefiles", + "hidden": false, + "binaryDir": "${sourceDir}/build/${presetName}", + "toolchainFile": "${sourceDir}/cmake/toolchains/mingw-w64-i686.cmake", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON", + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "mingw-w64-i686-debug", + "displayName": "MinGW-w64 32-bit (i686) Debug", + "hidden": false, + "inherits": "mingw-w64-i686", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "RTS_BUILD_OPTION_DEBUG": "ON" + } + }, + { + "name": "mingw-w64-i686-profile", + "displayName": "MinGW-w64 32-bit (i686) Profile", + "hidden": false, + "inherits": "mingw-w64-i686", + "cacheVariables": { + "RTS_BUILD_OPTION_PROFILE": "ON" + } } ], "buildPresets": [ @@ -244,6 +275,24 @@ "displayName": "Build Unix 32bit VCPKG Release", "description": "Build Unix 32bit VCPKG Release", "configuration": "Release" + }, + { + "name": "mingw-w64-i686", + "configurePreset": "mingw-w64-i686", + "displayName": "Build MinGW-w64 32-bit (i686) Release", + "description": "Build MinGW-w64 32-bit (i686) Release" + }, + { + "name": "mingw-w64-i686-debug", + "configurePreset": "mingw-w64-i686-debug", + "displayName": "Build MinGW-w64 32-bit (i686) Debug", + "description": "Build MinGW-w64 32-bit (i686) Debug" + }, + { + "name": "mingw-w64-i686-profile", + "configurePreset": "mingw-w64-i686-profile", + "displayName": "Build MinGW-w64 32-bit (i686) Profile", + "description": "Build MinGW-w64 32-bit (i686) Profile" } ], "workflowPresets": [ @@ -402,6 +451,45 @@ "name": "unix" } ] + }, + { + "name": "mingw-w64-i686", + "steps": [ + { + "type": "configure", + "name": "mingw-w64-i686" + }, + { + "type": "build", + "name": "mingw-w64-i686" + } + ] + }, + { + "name": "mingw-w64-i686-debug", + "steps": [ + { + "type": "configure", + "name": "mingw-w64-i686-debug" + }, + { + "type": "build", + "name": "mingw-w64-i686-debug" + } + ] + }, + { + "name": "mingw-w64-i686-profile", + "steps": [ + { + "type": "configure", + "name": "mingw-w64-i686-profile" + }, + { + "type": "build", + "name": "mingw-w64-i686-profile" + } + ] } ] } \ No newline at end of file diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index 6f6f640b3a4..7c1269d1db9 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -5,6 +5,7 @@ add_library(corei_libraries_source_wwvegas INTERFACE) add_library(corei_libraries_source_wwvegas_wwlib INTERFACE) add_library(corei_main INTERFACE) add_library(corei_always INTERFACE) +add_library(corei_always_no_pch INTERFACE) # Use this for Shared Libs with MFC AFX target_include_directories(corei_gameengine_include INTERFACE "GameEngine/Include") target_include_directories(corei_libraries_include INTERFACE "Libraries/Include") @@ -12,11 +13,25 @@ target_include_directories(corei_libraries_source_wwvegas INTERFACE "Libraries/S target_include_directories(corei_libraries_source_wwvegas_wwlib INTERFACE "Libraries/Source/WWVegas/WWLib") target_include_directories(corei_main INTERFACE "Main") +target_sources(corei_libraries_include PRIVATE + Libraries/Include/Lib/BaseType.h + Libraries/Include/Lib/BaseTypeCore.h + Libraries/Include/Lib/trig.h + Libraries/Include/rts/debug.h + Libraries/Include/rts/profile.h +) target_link_libraries(corei_always INTERFACE + core_config core_utility corei_libraries_include resources ) +target_link_libraries(corei_always_no_pch INTERFACE + core_config + core_utility_no_pch + corei_libraries_include + resources +) # Set where the build results will end up set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) diff --git a/Core/GameEngine/CMakeLists.txt b/Core/GameEngine/CMakeLists.txt index a00502b598b..c2bd873cce6 100644 --- a/Core/GameEngine/CMakeLists.txt +++ b/Core/GameEngine/CMakeLists.txt @@ -19,7 +19,6 @@ set(GAMEENGINE_SRC # Include/Common/BitFlagsIO.h # Include/Common/BorderColors.h # Include/Common/BuildAssistant.h -# Include/Common/CDManager.h # Include/Common/ClientUpdateModule.h # Include/Common/CommandLine.h Include/Common/crc.h @@ -37,14 +36,14 @@ set(GAMEENGINE_SRC Include/Common/DynamicAudioEventInfo.h # Include/Common/encrypt.h # Include/Common/Energy.h -# Include/Common/Errors.h + 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 + Include/Common/GameCommon.h Include/Common/GameDefines.h # Include/Common/GameEngine.h # Include/Common/GameLOD.h @@ -54,13 +53,13 @@ set(GAMEENGINE_SRC # Include/Common/GameSpyMiscPreferences.h # Include/Common/GameState.h # Include/Common/GameStateMap.h -# Include/Common/GameType.h + Include/Common/GameType.h Include/Common/GameUtility.h # Include/Common/Geometry.h # Include/Common/GlobalData.h # Include/Common/Handicap.h # Include/Common/IgnorePreferences.h -# Include/Common/INI.h + Include/Common/INI.h # Include/Common/INIException.h # Include/Common/KindOf.h # Include/Common/LadderPreferences.h @@ -108,7 +107,7 @@ set(GAMEENGINE_SRC #Include/Common/simpleplayer.h # unused # Include/Common/SkirmishBattleHonors.h # Include/Common/SkirmishPreferences.h -# Include/Common/Snapshot.h + Include/Common/Snapshot.h # Include/Common/SparseMatchFinder.h # Include/Common/SpecialPower.h # Include/Common/SpecialPowerMaskType.h @@ -116,9 +115,9 @@ set(GAMEENGINE_SRC # Include/Common/StackDump.h # Include/Common/StateMachine.h # Include/Common/StatsCollector.h -# Include/Common/STLTypedefs.h + Include/Common/STLTypedefs.h Include/Common/StreamingArchiveFile.h -# Include/Common/SubsystemInterface.h + Include/Common/SubsystemInterface.h # Include/Common/SystemInfo.h # Include/Common/Team.h # Include/Common/Terrain.h @@ -132,7 +131,7 @@ set(GAMEENGINE_SRC # Include/Common/UnitTimings.h # Include/Common/Upgrade.h #Include/Common/urllaunch.h # unused -# Include/Common/UserPreferences.h + Include/Common/UserPreferences.h # Include/Common/version.h # Include/Common/WellKnownKeys.h Include/Common/WorkerProcess.h @@ -144,8 +143,7 @@ set(GAMEENGINE_SRC # Include/GameClient/Anim2D.h # Include/GameClient/AnimateWindowManager.h # Include/GameClient/CampaignManager.h -# Include/GameClient/CDCheck.h -# Include/GameClient/ChallengeGenerals.h + Include/GameClient/ChallengeGenerals.h # Include/GameClient/ClientInstance.h Include/GameClient/ClientRandomValue.h # Include/GameClient/Color.h @@ -212,7 +210,7 @@ set(GAMEENGINE_SRC # Include/GameClient/Module/SwayClientUpdate.h # Include/GameClient/Mouse.h Include/GameClient/ParabolicEase.h -# Include/GameClient/ParticleSys.h + Include/GameClient/ParticleSys.h # Include/GameClient/PlaceEventTranslator.h # Include/GameClient/ProcessAnimateWindow.h # Include/GameClient/RadiusDecal.h @@ -554,6 +552,7 @@ set(GAMEENGINE_SRC Include/GameNetwork/NetCommandRef.h Include/GameNetwork/NetCommandWrapperList.h Include/GameNetwork/NetPacket.h + Include/GameNetwork/NetPacketStructs.h Include/GameNetwork/NetworkDefs.h Include/GameNetwork/NetworkInterface.h Include/GameNetwork/networkutil.h @@ -589,7 +588,7 @@ set(GAMEENGINE_SRC # Source/Common/GameMain.cpp Source/Common/GameUtility.cpp # Source/Common/GlobalData.cpp -# Source/Common/INI/INI.cpp + Source/Common/INI/INI.cpp # Source/Common/INI/INIAiData.cpp # Source/Common/INI/INIAnimation.cpp Source/Common/INI/INIAudioEventInfo.cpp @@ -650,7 +649,6 @@ set(GAMEENGINE_SRC Source/Common/System/ArchiveFileSystem.cpp Source/Common/System/AsciiString.cpp # Source/Common/System/BuildAssistant.cpp -# Source/Common/System/CDManager.cpp # Source/Common/System/CriticalSection.cpp # Source/Common/System/DataChunk.cpp Source/Common/System/Debug.cpp @@ -660,10 +658,10 @@ set(GAMEENGINE_SRC Source/Common/System/File.cpp Source/Common/System/FileSystem.cpp # Source/Common/System/FunctionLexicon.cpp -# Source/Common/System/GameCommon.cpp + Source/Common/System/GameCommon.cpp #Source/Common/System/GameMemory.cpp # is conditionally appended #Source/Common/System/GameMemoryInit.cpp # is conditionally appended -# Source/Common/System/GameType.cpp + Source/Common/System/GameType.cpp # Source/Common/System/Geometry.cpp # Source/Common/System/KindOf.cpp # Source/Common/System/List.cpp @@ -677,10 +675,10 @@ set(GAMEENGINE_SRC # Source/Common/System/registry.cpp # Source/Common/System/SaveGame/GameState.cpp # Source/Common/System/SaveGame/GameStateMap.cpp -# Source/Common/System/Snapshot.cpp + Source/Common/System/Snapshot.cpp # Source/Common/System/StackDump.cpp Source/Common/System/StreamingArchiveFile.cpp -# Source/Common/System/SubsystemInterface.cpp + Source/Common/System/SubsystemInterface.cpp # Source/Common/System/Trig.cpp Source/Common/System/UnicodeString.cpp # Source/Common/System/Upgrade.cpp @@ -695,7 +693,7 @@ set(GAMEENGINE_SRC # Source/Common/Thing/Thing.cpp # Source/Common/Thing/ThingFactory.cpp # Source/Common/Thing/ThingTemplate.cpp -# Source/Common/UserPreferences.cpp + Source/Common/UserPreferences.cpp # Source/Common/version.cpp Source/Common/WorkerProcess.cpp # Source/GameClient/ClientInstance.cpp @@ -717,7 +715,7 @@ set(GAMEENGINE_SRC # Source/GameClient/GlobalLanguage.cpp # Source/GameClient/GraphDraw.cpp # Source/GameClient/GUI/AnimateWindowManager.cpp -# Source/GameClient/GUI/ChallengeGenerals.cpp + Source/GameClient/GUI/ChallengeGenerals.cpp # Source/GameClient/GUI/ControlBar/ControlBar.cpp # Source/GameClient/GUI/ControlBar/ControlBarBeacon.cpp # Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp @@ -835,7 +833,7 @@ set(GAMEENGINE_SRC Source/GameClient/System/Debug/AudioDebugDisplay.cpp # Source/GameClient/System/DebugDisplay.cpp # Source/GameClient/System/Image.cpp -# Source/GameClient/System/ParticleSys.cpp + Source/GameClient/System/ParticleSys.cpp # Source/GameClient/System/RayEffect.cpp Source/GameClient/System/Smudge.cpp Source/GameClient/Terrain/TerrainRoads.cpp @@ -1207,11 +1205,14 @@ target_include_directories(corei_gameengine_public INTERFACE target_link_libraries(corei_gameengine_public INTERFACE core_compression - core_config core_browserdispatch - core_utility #core_wwvegas d3d8lib gamespy::gamespy stlport ) + +# ReactOS ATL for MinGW-w64 only (MSVC uses native ATL) +if(MINGW) + target_link_libraries(corei_gameengine_public INTERFACE reactos_atl) +endif() diff --git a/Core/GameEngine/Include/Common/ArchiveFileSystem.h b/Core/GameEngine/Include/Common/ArchiveFileSystem.h index a482e593b99..f323b0f8295 100644 --- a/Core/GameEngine/Include/Common/ArchiveFileSystem.h +++ b/Core/GameEngine/Include/Common/ArchiveFileSystem.h @@ -156,8 +156,8 @@ class ArchiveFileSystem : public SubsystemInterface protected: struct ArchivedDirectoryInfoResult { - ArchivedDirectoryInfoResult() : dirInfo(NULL) {} - Bool valid() const { return dirInfo != NULL; } + ArchivedDirectoryInfoResult() : dirInfo(nullptr) {} + Bool valid() const { return dirInfo != nullptr; } ArchivedDirectoryInfo* dirInfo; AsciiString lastToken; ///< Synonymous for file name if the search directory was a file path diff --git a/Core/GameEngine/Include/Common/AsciiString.h b/Core/GameEngine/Include/Common/AsciiString.h index 5af9cbe130e..5259650dbef 100644 --- a/Core/GameEngine/Include/Common/AsciiString.h +++ b/Core/GameEngine/Include/Common/AsciiString.h @@ -252,7 +252,7 @@ class AsciiString void trimEnd(void); /** - Remove all consecutive occurances of c from the end of the string. + Remove all consecutive occurrences of c from the end of the string. */ void trimEnd(const char c); @@ -353,7 +353,7 @@ class AsciiString token was found. (note that this modifies 'this' as well, stripping the token off!) */ - Bool nextToken(AsciiString* token, const char* seps = NULL); + Bool nextToken(AsciiString* token, const char* seps = nullptr); /** return true iff the string is "NONE" (case-insensitive). @@ -420,7 +420,7 @@ inline int AsciiString::getByteCount() const inline Bool AsciiString::isEmpty() const { validate(); - return m_data == NULL || peek()[0] == 0; + return m_data == nullptr || peek()[0] == 0; } // ----------------------------------------------------- diff --git a/Core/GameEngine/Include/Common/AudioEventInfo.h b/Core/GameEngine/Include/Common/AudioEventInfo.h index dc4317204f6..2d149efc10b 100644 --- a/Core/GameEngine/Include/Common/AudioEventInfo.h +++ b/Core/GameEngine/Include/Common/AudioEventInfo.h @@ -124,10 +124,10 @@ struct AudioEventInfo : public MemoryPoolObject // DynamicAudioEventInfo interfacing functions virtual Bool isLevelSpecific() const { return false; } ///< If true, this sound is only defined on the current level and can be deleted when that level ends - virtual DynamicAudioEventInfo * getDynamicAudioEventInfo() { return NULL; } ///< If this object is REALLY a DynamicAudioEventInfo, return a pointer to the derived class - virtual const DynamicAudioEventInfo * getDynamicAudioEventInfo() const { return NULL; } ///< If this object is REALLY a DynamicAudioEventInfo, return a pointer to the derived class + virtual DynamicAudioEventInfo * getDynamicAudioEventInfo() { return nullptr; } ///< If this object is REALLY a DynamicAudioEventInfo, return a pointer to the derived class + virtual const DynamicAudioEventInfo * getDynamicAudioEventInfo() const { return nullptr; } ///< If this object is REALLY a DynamicAudioEventInfo, return a pointer to the derived class - /// Is this a permenant sound? That is, if I start this sound up, will it ever end + /// Is this a permanent sound? That is, if I start this sound up, will it ever end /// "on its own" or only if I explicitly kill it? Bool isPermanentSound() const { return BitIsSet( m_control, AC_LOOP ) && (m_loopCount == 0 ); } diff --git a/Core/GameEngine/Include/Common/AudioEventRTS.h b/Core/GameEngine/Include/Common/AudioEventRTS.h index 5a6f0f4510b..2dabfe8646d 100644 --- a/Core/GameEngine/Include/Common/AudioEventRTS.h +++ b/Core/GameEngine/Include/Common/AudioEventRTS.h @@ -99,7 +99,7 @@ class AudioEventRTS void decreaseLoopCount( void ); Bool hasMoreLoops( void ) const; - void setAudioEventInfo( const AudioEventInfo *eventInfo ) const; + void setAudioEventInfo( const AudioEventInfo *eventInfo ) const; // is mutable const AudioEventInfo *getAudioEventInfo( void ) const; void setPlayingHandle( AudioHandle handle ); // for ID of this audio piece. @@ -141,18 +141,18 @@ class AudioEventRTS Int getPlayerIndex( void ) const; void setPlayerIndex( Int playerNdx ); - Int getPlayingAudioIndex( void ) { return m_playingAudioIndex; }; - void setPlayingAudioIndex( Int pai ) { m_playingAudioIndex = pai; }; + Int getPlayingAudioIndex( void ) const { return m_playingAudioIndex; } + void setPlayingAudioIndex( Int pai ) const { m_playingAudioIndex = pai; } // is mutable - Bool getUninterruptable( ) const { return m_uninterruptable; } - void setUninterruptable( Bool uninterruptable ) { m_uninterruptable = uninterruptable; } + Bool getUninterruptible( ) const { return m_uninterruptible; } + void setUninterruptible( Bool uninterruptible ) { m_uninterruptible = uninterruptible; } // This will retrieve the appropriate position based on type. const Coord3D *getCurrentPosition( void ); // This will return the directory leading up to the appropriate type, including the trailing '\\' - // If localized is true, we'll append a language specifc directory to the end of the path. + // If localized is true, we'll append a language specific directory to the end of the path. AsciiString generateFilenamePrefix( AudioType audioTypeToPlay, Bool localized ); AsciiString generateFilenameExtension( AudioType audioTypeToPlay ); protected: @@ -170,8 +170,8 @@ class AudioEventRTS AsciiString m_attackName; ///< This is the filename that should be used during the attack. AsciiString m_decayName; ///< This is the filename that should be used during the decay. - AudioPriority m_priority; ///< This should be the priority as given by the event info, or the overrided priority. - Real m_volume; ///< This is the override for the volume. It will either be the normal + AudioPriority m_priority; ///< This should be the priority as given by the event info, or the overridden priority. + Real m_volume; ///< This is the override for the volume. It will either be the normal volume or an overridden value. TimeOfDay m_timeOfDay; ///< This should be the current Time Of Day. Coord3D m_positionOfAudio; ///< Position of the sound if no further positional updates are necessary @@ -184,14 +184,14 @@ class AudioEventRTS Bool m_shouldFade; ///< This should fade in or out (if it is starting or stopping) Bool m_isLogicalAudio; ///< Should probably only be true for scripted sounds - Bool m_uninterruptable; + Bool m_uninterruptible; // Playing attributes Real m_pitchShift; ///< Pitch shift that should occur on this piece of audio Real m_volumeShift; ///< Volume shift that should occur on this piece of audio Real m_delay; ///< Amount to delay before playing this sound Int m_loopCount; ///< The current loop count value. Only valid if this is a looping type event or the override has been set. - Int m_playingAudioIndex; ///< The sound index we are currently playing. In the case of non-random, we increment this to move to the next sound + mutable Int m_playingAudioIndex; ///< The sound index we are currently playing. In the case of non-random, we increment this to move to the next sound Int m_allCount; ///< If this sound is an ALL type, then this is how many sounds we have played so far. Int m_playerIndex; ///< The index of the player who owns this sound. Used for sounds that should have an owner, but don't have an object, etc. diff --git a/Core/GameEngine/Include/Common/Debug.h b/Core/GameEngine/Include/Common/Debug.h index 94b3a0c08d9..9f9fe1ab7f8 100644 --- a/Core/GameEngine/Include/Common/Debug.h +++ b/Core/GameEngine/Include/Common/Debug.h @@ -45,8 +45,6 @@ #pragma once -#include - class AsciiString; #define NO_RELEASE_DEBUG_LOGGING diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Errors.h b/Core/GameEngine/Include/Common/Errors.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/Errors.h rename to Core/GameEngine/Include/Common/Errors.h diff --git a/Core/GameEngine/Include/Common/FileSystem.h b/Core/GameEngine/Include/Common/FileSystem.h index 51bf9153caa..0449b8d6a74 100644 --- a/Core/GameEngine/Include/Common/FileSystem.h +++ b/Core/GameEngine/Include/Common/FileSystem.h @@ -155,10 +155,6 @@ class FileSystem : public SubsystemInterface Bool createDirectory(AsciiString directory); ///< create a directory of the given name. - Bool areMusicFilesOnCD(); - void loadMusicFilesFromCD(); - void unloadMusicFilesFromCD(); - 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. diff --git a/Core/GameEngine/Include/Common/GameAudio.h b/Core/GameEngine/Include/Common/GameAudio.h index 8a9d0093263..44a9efd3c0a 100644 --- a/Core/GameEngine/Include/Common/GameAudio.h +++ b/Core/GameEngine/Include/Common/GameAudio.h @@ -105,7 +105,7 @@ enum local player affiliation, etc. (The entire list of checks is contained in shouldPlayLocally()). In addition, the world and unit audio are never allowed to exceed their footprint, as specified - in the audio settings INI file. In order to accomodate this, the audio uses an audio cache. The + in the audio settings INI file. In order to accommodate this, the audio uses an audio cache. The audio cache will attempt to load a sample, assuming there is enough room. If there is not enough room, then it goes through and finds any samples that are lower priority, and kills them until enough room is present for the sample. If it cannot free enough room, nothing happens to the @@ -131,10 +131,21 @@ enum class AudioManager : public SubsystemInterface { public: + typedef UnsignedInt MuteAudioReasonInt; + + enum MuteAudioReason CPP_11(: UnsignedInt) + { + MuteAudioReason_WindowFocus, + + MuteAudioReason_Count + }; + + static const char *const MuteAudioReasonNames[]; + AudioManager(); virtual ~AudioManager(); #if defined(RTS_DEBUG) - virtual void audioDebugDisplay(DebugDisplayInterface *dd, void *userData, FILE *fp = NULL ) = 0; + virtual void audioDebugDisplay(DebugDisplayInterface *dd, void *userData, FILE *fp = nullptr ) = 0; #endif // From SubsystemInterface @@ -149,9 +160,8 @@ class AudioManager : public SubsystemInterface virtual void resumeAudio( AudioAffect which ) = 0; virtual void pauseAmbient( Bool shouldPause ) = 0; - // for focus issues - virtual void loseFocus( void ); - virtual void regainFocus( void ); + void muteAudio( MuteAudioReason reason ); + void unmuteAudio( MuteAudioReason reason ); // control for AudioEventsRTS virtual AudioHandle addAudioEvent( const AudioEventRTS *eventToAdd ); ///< Add an audio event (event must be declared in an INI file) @@ -190,7 +200,7 @@ class AudioManager : public SubsystemInterface virtual void closeDevice( void ) = 0; virtual void *getDevice( void ) = 0; - // Debice Dependent notification functions + // Device Dependent notification functions virtual void notifyOfAudioCompletion( UnsignedInt audioCompleted, UnsignedInt flags, bool isEarlyStop = false) = 0; // Device Dependent enumerate providers functions. It is okay for there to be only 1 provider (Miles provides a maximum of 64. @@ -287,7 +297,6 @@ class AudioManager : public SubsystemInterface virtual void closeAnySamplesUsingFile( const void *fileToClose ) = 0; virtual Bool isMusicAlreadyLoaded(void) const; - virtual Bool isMusicPlayingFromCD(void) const { return m_musicPlayingFromCD; } Bool getDisallowSpeech( void ) const { return m_disallowSpeech; } void setDisallowSpeech( Bool disallowSpeech ) { m_disallowSpeech = disallowSpeech; } @@ -361,6 +370,7 @@ class AudioManager : public SubsystemInterface NUM_VOLUME_TYPES }; Real *m_savedValues; + MuteAudioReasonInt m_muteReasonBits; // Group of 8 Bool m_speechOn : 1; @@ -370,9 +380,6 @@ class AudioManager : public SubsystemInterface Bool m_volumeHasChanged : 1; Bool m_hardwareAccel : 1; Bool m_surroundSpeakers : 1; - Bool m_musicPlayingFromCD : 1; - - // Next 8 Bool m_disallowSpeech : 1; }; @@ -395,7 +402,7 @@ class AudioManagerDummy : public AudioManager virtual AsciiString getMusicTrackName() const { return ""; } virtual void openDevice() {} virtual void closeDevice() {} - virtual void* getDevice() { return NULL; } + virtual void* getDevice() { return nullptr; } virtual void notifyOfAudioCompletion(UnsignedInt audioCompleted, UnsignedInt flags, bool isEarlyStop=false) {} virtual UnsignedInt getProviderCount(void) const { return 0; }; virtual AsciiString getProviderName(UnsignedInt providerNum) const { return ""; } @@ -416,7 +423,7 @@ class AudioManagerDummy : public AudioManager virtual void removePlayingAudio(AsciiString eventName) {} virtual void removeAllDisabledAudio() {} virtual Bool has3DSensitiveStreamsPlaying(void) const { return false; } - virtual void* getHandleForBink(void) { return NULL; } + virtual void* getHandleForBink(void) { return nullptr; } virtual void releaseHandleForBink(void) {} virtual void friend_forcePlayAudioEventRTS(const AudioEventRTS* eventToPlay) {} virtual void setPreferredProvider(AsciiString providerNdx) {} diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GameCommon.h b/Core/GameEngine/Include/Common/GameCommon.h similarity index 98% rename from GeneralsMD/Code/GameEngine/Include/Common/GameCommon.h rename to Core/GameEngine/Include/Common/GameCommon.h index 728c229c355..52a21083197 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/GameCommon.h +++ b/Core/GameEngine/Include/Common/GameCommon.h @@ -47,8 +47,6 @@ #pragma once -#define DONT_ALLOW_DEBUG_CHEATS_IN_RELEASE ///< Take of the DONT to get cheats back in to release - //#define _CAMPEA_DEMO // ---------------------------------------------------------------------------------------------- @@ -346,7 +344,7 @@ public: \ o->dlink_removeFrom_##LISTNAME(&m_dlinkhead_##LISTNAME.m_head); \ } \ typedef void (*RemoveAllProc_##LISTNAME)(OBJCLASS* o); \ - inline void removeAll_##LISTNAME(RemoveAllProc_##LISTNAME p = NULL) \ + inline void removeAll_##LISTNAME(RemoveAllProc_##LISTNAME p = nullptr) \ { \ while (m_dlinkhead_##LISTNAME.m_head) \ { \ @@ -359,7 +357,7 @@ public: \ inline void reverse_##LISTNAME() \ { \ OBJCLASS* cur = m_dlinkhead_##LISTNAME.m_head; \ - OBJCLASS* prev = NULL; \ + OBJCLASS* prev = nullptr; \ while (cur) \ { \ OBJCLASS* originalNext = cur->dlink_next_##LISTNAME(); \ @@ -463,7 +461,7 @@ class DLINK_ITERATOR Bool done() const { - return m_cur == NULL; + return m_cur == nullptr; } OBJCLASS* cur() const diff --git a/Core/GameEngine/Include/Common/GameDefines.h b/Core/GameEngine/Include/Common/GameDefines.h index 667ea8aa9ff..b562b51c40e 100644 --- a/Core/GameEngine/Include/Common/GameDefines.h +++ b/Core/GameEngine/Include/Common/GameDefines.h @@ -36,10 +36,18 @@ #endif // This is here to easily toggle between the retail compatible with fixed pathfinding fallback and pure fixed pathfinding mode -#if RETAIL_COMPATIBLE_CRC +#ifndef RETAIL_COMPATIBLE_PATHFINDING #define RETAIL_COMPATIBLE_PATHFINDING (1) -#else -#define RETAIL_COMPATIBLE_PATHFINDING (0) +#endif + +// This is here to easily toggle between the retail compatible pathfinding memory allocation and the new static allocated data mode +#ifndef RETAIL_COMPATIBLE_PATHFINDING_ALLOCATION +#define RETAIL_COMPATIBLE_PATHFINDING_ALLOCATION (1) +#endif + +// Disable non retail fixes in the networking, such as putting more data per UDP packet +#ifndef RETAIL_COMPATIBLE_NETWORKING +#define RETAIL_COMPATIBLE_NETWORKING (1) #endif // This is essentially synonymous for RETAIL_COMPATIBLE_CRC. There is a lot wrong with AIGroup, such as use-after-free, double-free, leaks, diff --git a/Core/GameEngine/Include/Common/GameMemory.h b/Core/GameEngine/Include/Common/GameMemory.h index 1ea96161cea..0e901b9d4af 100644 --- a/Core/GameEngine/Include/Common/GameMemory.h +++ b/Core/GameEngine/Include/Common/GameMemory.h @@ -321,7 +321,7 @@ class MemoryPool void addToList(MemoryPool **pHead); ///< add this pool to head of the linked list void removeFromList(MemoryPool **pHead); ///< remove this pool from the linked list #ifdef MEMORYPOOL_DEBUG - static void debugPoolInfoReport( MemoryPool *pool, FILE *fp = NULL ); ///< dump a report about this pool to the logfile + static void debugPoolInfoReport( MemoryPool *pool, FILE *fp = nullptr ); ///< dump a report about this pool to the logfile const char *debugGetBlockTagString(void *pBlock); ///< return the tagstring for the given block (assumed to belong to this pool) void debugMemoryVerifyPool(); ///< perform internal consistency check on this pool. Int debugPoolReportLeaks( const char* owner ); @@ -421,7 +421,7 @@ class DynamicMemoryAllocator Int debugCalcRawBlockBytes(Int *numBlocks); ///< calculate the number of bytes in "raw" (non-subpool) blocks void debugMemoryVerifyDma(); ///< perform internal consistency check const char *debugGetBlockTagString(void *pBlock); ///< return the tagstring for the given block (assumed to belong to this dma) - void debugDmaInfoReport( FILE *fp = NULL ); ///< dump a report about this pool to the logfile + void debugDmaInfoReport( FILE *fp = nullptr ); ///< dump a report about this pool to the logfile Int debugDmaReportLeaks(); #endif #ifdef MEMORYPOOL_CHECKPOINTING @@ -545,7 +545,7 @@ class MemoryPoolFactory /// destroy the contents of all pools and dmas. (the pools and dma's are not destroyed, just reset) void reset(); - void memoryPoolUsageReport( const char* filename, FILE *appendToFileInstead = NULL ); + void memoryPoolUsageReport( const char* filename, FILE *appendToFileInstead = nullptr ); #ifdef MEMORYPOOL_DEBUG @@ -559,7 +559,7 @@ class MemoryPoolFactory const char *debugGetBlockTagString(void *pBlock); /// dump a report with the given options to the logfile. - void debugMemoryReport(Int flags, Int startCheckpoint, Int endCheckpoint, FILE *fp = NULL ); + void debugMemoryReport(Int flags, Int startCheckpoint, Int endCheckpoint, FILE *fp = nullptr ); void debugSetInitFillerIndex(Int index); @@ -589,7 +589,7 @@ private: \ order-of-execution problem for static variables, ensuring this is not executed \ prior to the initialization of TheMemoryPoolFactory. \ */ \ - DEBUG_ASSERTCRASH(TheMemoryPoolFactory, ("TheMemoryPoolFactory is NULL")); \ + DEBUG_ASSERTCRASH(TheMemoryPoolFactory, ("TheMemoryPoolFactory is null")); \ static MemoryPool *The##ARGCLASS##Pool = TheMemoryPoolFactory->findMemoryPool(ARGPOOLNAME); \ DEBUG_ASSERTCRASH(The##ARGCLASS##Pool, ("Pool \"%s\" not found (did you set it up in initMemoryPools?)", ARGPOOLNAME)); \ DEBUG_ASSERTCRASH(The##ARGCLASS##Pool->getAllocationSize() >= sizeof(ARGCLASS), ("Pool \"%s\" is too small for this class (currently %d, need %d)", ARGPOOLNAME, The##ARGCLASS##Pool->getAllocationSize(), sizeof(ARGCLASS))); \ @@ -608,7 +608,7 @@ private: \ order-of-execution problem for static variables, ensuring this is not executed \ prior to the initialization of TheMemoryPoolFactory. \ */ \ - DEBUG_ASSERTCRASH(TheMemoryPoolFactory, ("TheMemoryPoolFactory is NULL")); \ + DEBUG_ASSERTCRASH(TheMemoryPoolFactory, ("TheMemoryPoolFactory is null")); \ static MemoryPool *The##ARGCLASS##Pool = TheMemoryPoolFactory->createMemoryPool(ARGPOOLNAME, sizeof(ARGCLASS), ARGINITIAL, ARGOVERFLOW); \ DEBUG_ASSERTCRASH(The##ARGCLASS##Pool, ("Pool \"%s\" not found (did you set it up in initMemoryPools?)", ARGPOOLNAME)); \ DEBUG_ASSERTCRASH(The##ARGCLASS##Pool->getAllocationSize() >= sizeof(ARGCLASS), ("Pool \"%s\" is too small for this class (currently %d, need %d)", ARGPOOLNAME, The##ARGCLASS##Pool->getAllocationSize(), sizeof(ARGCLASS))); \ @@ -902,9 +902,9 @@ class MemoryPoolObjectHolder private: MemoryPoolObject *m_mpo; public: - MemoryPoolObjectHolder(MemoryPoolObject *mpo = NULL) : m_mpo(mpo) { } + MemoryPoolObjectHolder(MemoryPoolObject *mpo = nullptr) : m_mpo(mpo) { } void hold(MemoryPoolObject *mpo) { DEBUG_ASSERTCRASH(!m_mpo, ("already holding")); m_mpo = mpo; } - void release() { m_mpo = NULL; } + void release() { m_mpo = nullptr; } ~MemoryPoolObjectHolder() { deleteInstance(m_mpo); } }; diff --git a/Core/GameEngine/Include/Common/GameMemoryNull.h b/Core/GameEngine/Include/Common/GameMemoryNull.h index 5babbf4553c..263f7a1dcb9 100644 --- a/Core/GameEngine/Include/Common/GameMemoryNull.h +++ b/Core/GameEngine/Include/Common/GameMemoryNull.h @@ -64,11 +64,11 @@ class MemoryPoolFactory { public: - void memoryPoolUsageReport( const char* filename, FILE *appendToFileInstead = NULL ); + void memoryPoolUsageReport( const char* filename, FILE *appendToFileInstead = nullptr ); #ifdef MEMORYPOOL_DEBUG - void debugMemoryReport(Int flags, Int startCheckpoint, Int endCheckpoint, FILE *fp = NULL ); + void debugMemoryReport(Int flags, Int startCheckpoint, Int endCheckpoint, FILE *fp = nullptr ); void debugSetInitFillerIndex(Int index); #endif diff --git a/GeneralsMD/Code/GameEngine/Include/Common/GameType.h b/Core/GameEngine/Include/Common/GameType.h similarity index 99% rename from GeneralsMD/Code/GameEngine/Include/Common/GameType.h rename to Core/GameEngine/Include/Common/GameType.h index 8167c5816b1..c8fbecf9f7f 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/GameType.h +++ b/Core/GameEngine/Include/Common/GameType.h @@ -187,7 +187,7 @@ enum WeaponSlotType CPP_11(: Int) // Layer 1 is the ground. // Layer 2 is the top layer - bridge if one is present, ground otherwise. // Layer 2 - LAYER_LAST -1 are bridges. -// Layer_WALL is a special "wall" layer for letting units run aroound on top of a wall +// Layer_WALL is a special "wall" layer for letting units run around on top of a wall // made of structures. // Note that the bridges just index in the pathfinder, so you don't actually // have a LAYER_BRIDGE_1 enum value. diff --git a/GeneralsMD/Code/GameEngine/Include/Common/INI.h b/Core/GameEngine/Include/Common/INI.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/Common/INI.h rename to Core/GameEngine/Include/Common/INI.h index b5d781d99fe..d5b1733248a 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/INI.h +++ b/Core/GameEngine/Include/Common/INI.h @@ -340,14 +340,14 @@ class INI this will *never* return null; if there are no more tokens, an exception will be thrown. */ - const char* getNextToken(const char* seps = NULL); + const char* getNextToken(const char* seps = nullptr); /** just like getNextToken(), except that null is returned if no more tokens are present (rather than throwing an exception). usually you should call getNextToken(), but for some cases this is handier (ie, parsing a variable-length number of tokens). */ - const char* getNextTokenOrNull(const char* seps = NULL); + const char* getNextTokenOrNull(const char* seps = nullptr); /** This is called when the next thing you expect is something like: @@ -408,15 +408,9 @@ class INI void readLine( void ); - File *m_file; ///< file pointer of file currently loading - - enum - { - INI_READ_BUFFER = 8192 ///< size of internal read buffer - }; - char m_readBuffer[INI_READ_BUFFER]; ///< internal read buffer - unsigned m_readBufferNext; ///< next char in read buffer - unsigned m_readBufferUsed; ///< number of bytes in read buffer + char* m_readBuffer; ///< internal read buffer + unsigned m_readBufferNext; ///< next char in read buffer + unsigned m_readBufferUsed; ///< number of bytes in read buffer AsciiString m_filename; ///< filename of file currently loading INILoadType m_loadType; ///< load time for current file diff --git a/Core/GameEngine/Include/Common/LocalFile.h b/Core/GameEngine/Include/Common/LocalFile.h index db9568ee0e7..ce6b12a1465 100644 --- a/Core/GameEngine/Include/Common/LocalFile.h +++ b/Core/GameEngine/Include/Common/LocalFile.h @@ -103,7 +103,7 @@ class LocalFile : public File virtual Int writeChar( const WideChar* character ); ///< Write a wide character to the file virtual Int seek( Int new_pos, seekMode mode = CURRENT ); ///< Set file position: See File::seek virtual Bool flush(); ///< flush data to disk - virtual void nextLine(Char *buf = NULL, Int bufSize = 0); ///< moves file position to after the next new-line + virtual void nextLine(Char *buf = nullptr, Int bufSize = 0); ///< moves file position to after the next new-line virtual Bool scanInt(Int &newInt); ///< return what gets read in as an integer at the current file position. virtual Bool scanReal(Real &newReal); ///< return what gets read in as a float at the current file position. virtual Bool scanString(AsciiString &newString); ///< return what gets read in as a string at the current file position. diff --git a/Core/GameEngine/Include/Common/RAMFile.h b/Core/GameEngine/Include/Common/RAMFile.h index 084aa8d857e..4e37b260cab 100644 --- a/Core/GameEngine/Include/Common/RAMFile.h +++ b/Core/GameEngine/Include/Common/RAMFile.h @@ -94,7 +94,7 @@ class RAMFile : public File virtual Int writeChar( const WideChar* character ); ///< Write a wide character to the file virtual Int seek( Int new_pos, seekMode mode = CURRENT ); ///< Set file position: See File::seek virtual Bool flush(); ///< flush data to disk - virtual void nextLine(Char *buf = NULL, Int bufSize = 0); ///< moves current position to after the next new-line + virtual void nextLine(Char *buf = nullptr, Int bufSize = 0); ///< moves current position to after the next new-line virtual Bool scanInt(Int &newInt); ///< return what gets read as an integer from the current memory position. virtual Bool scanReal(Real &newReal); ///< return what gets read as a float from the current memory position. diff --git a/Core/GameEngine/Include/Common/Radar.h b/Core/GameEngine/Include/Common/Radar.h index 431cfbf1668..ce9ed8042d4 100644 --- a/Core/GameEngine/Include/Common/Radar.h +++ b/Core/GameEngine/Include/Common/Radar.h @@ -143,7 +143,7 @@ static const char *const RadarPriorityNames[] = "UNIT", // unit level drawing priority "LOCAL_UNIT_ONLY", // unit priority, but only on the radar if controlled by the local player - NULL + nullptr }; static_assert(ARRAY_SIZE(RadarPriorityNames) == RADAR_PRIORITY_NUM_PRIORITIES + 1, "Incorrect array size"); #endif // DEFINE_RADAR_PRIOTITY_NAMES @@ -165,7 +165,7 @@ class Radar : public Snapshot, 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 isRadarWindow( GameWindow *window ) { return (m_radarWindow == window) && (m_radarWindow != nullptr); } 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!) @@ -218,8 +218,13 @@ class Radar : public Snapshot, /// 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; + /// TheSuperHackers @performance xezon 20/12/2025 Provides beginSetShroudLevel and endSetShroudLevel to improve performance. + /// Calling setShroudLevel many times is very expensive because it will lock a render resource on every call. + virtual void setShroudLevel( Int x, Int y, CellShroudStatus setting ) = 0; ///< set the shroud level at shroud cell x,y + virtual void beginSetShroudLevel() {} ///< call this once before multiple calls to setShroudLevel for better performance + virtual void endSetShroudLevel() {} ///< call this once after beginSetShroudLevel and setShroudLevel + + virtual void notifyViewChanged() {} ///< signals that the camera view has changed protected: diff --git a/GeneralsMD/Code/GameEngine/Include/Common/STLTypedefs.h b/Core/GameEngine/Include/Common/STLTypedefs.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/Common/STLTypedefs.h rename to Core/GameEngine/Include/Common/STLTypedefs.h index 2736316f560..0dc2ede1dc3 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/STLTypedefs.h +++ b/Core/GameEngine/Include/Common/STLTypedefs.h @@ -64,6 +64,7 @@ class Object; enum NameKeyType CPP_11(: Int); enum ObjectID CPP_11(: Int); enum DrawableID CPP_11(: Int); +enum ParticleSystemID CPP_11(: Int); #include #include @@ -147,6 +148,7 @@ namespace rts } }; +#ifdef USING_STLPORT template<> struct hash { size_t operator()(NameKeyType nkt) const @@ -174,6 +176,16 @@ namespace rts } }; + template<> struct hash + { + size_t operator()(ParticleSystemID nkt) const + { + std::hash tmp; + return tmp((UnsignedInt)nkt); + } + }; +#endif // USING_STLPORT + template<> struct hash { size_t operator()(const Char* s) const diff --git a/GeneralsMD/Code/GameEngine/Include/Common/Snapshot.h b/Core/GameEngine/Include/Common/Snapshot.h similarity index 100% rename from GeneralsMD/Code/GameEngine/Include/Common/Snapshot.h rename to Core/GameEngine/Include/Common/Snapshot.h diff --git a/Core/GameEngine/Include/Common/StreamingArchiveFile.h b/Core/GameEngine/Include/Common/StreamingArchiveFile.h index bf481b19784..270f94a4007 100644 --- a/Core/GameEngine/Include/Common/StreamingArchiveFile.h +++ b/Core/GameEngine/Include/Common/StreamingArchiveFile.h @@ -90,7 +90,7 @@ class StreamingArchiveFile : public RAMFile virtual Int seek( Int new_pos, seekMode mode = CURRENT ); ///< Set file position: See File::seek // Ini's should not be parsed with streaming files, that's just dumb. - virtual void nextLine(Char *buf = NULL, Int bufSize = 0) { DEBUG_CRASH(("Should not call nextLine on a streaming file.")); } + virtual void nextLine(Char *buf = nullptr, Int bufSize = 0) { DEBUG_CRASH(("Should not call nextLine on a streaming file.")); } virtual Bool scanInt(Int &newInt) { DEBUG_CRASH(("Should not call scanInt on a streaming file.")); return FALSE; } virtual Bool scanReal(Real &newReal) { DEBUG_CRASH(("Should not call scanReal on a streaming file.")); return FALSE; } virtual Bool scanString(AsciiString &newString) { DEBUG_CRASH(("Should not call scanString on a streaming file.")); return FALSE; } @@ -99,7 +99,7 @@ class StreamingArchiveFile : public RAMFile virtual Bool openFromArchive(File *archiveFile, const AsciiString& filename, Int offset, Int size); ///< copy file data from the given file at the given offset for the given size. virtual Bool copyDataToFile(File *localFile) { DEBUG_CRASH(("Are you sure you meant to copyDataToFile on a streaming file?")); return FALSE; } - virtual char* readEntireAndClose() { DEBUG_CRASH(("Are you sure you meant to readEntireAndClose on a streaming file?")); return NULL; } + virtual char* readEntireAndClose() { DEBUG_CRASH(("Are you sure you meant to readEntireAndClose on a streaming file?")); return nullptr; } virtual File* convertToRAMFile() { DEBUG_CRASH(("Are you sure you meant to readEntireAndClose on a streaming file?")); return this; } }; diff --git a/GeneralsMD/Code/GameEngine/Include/Common/SubsystemInterface.h b/Core/GameEngine/Include/Common/SubsystemInterface.h similarity index 97% rename from GeneralsMD/Code/GameEngine/Include/Common/SubsystemInterface.h rename to Core/GameEngine/Include/Common/SubsystemInterface.h index 50fd69520d0..35afc31ea2d 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/SubsystemInterface.h +++ b/Core/GameEngine/Include/Common/SubsystemInterface.h @@ -35,7 +35,7 @@ class Xfer; //------------------------------------------------------------------------------------------------- -/** This is the abstract base class from which all game engine subsytems should derive from. +/** This is the abstract base class from which all game engine subsystems should derive from. * In order to provide consistent behaviors across all these systems, any implementation * must obey the rules defined in here * @@ -52,7 +52,7 @@ class SubsystemInterface /** - Constructors should initialize any data to a valid state. That DOES NOT mean * the data has default values (something done in the init() method), only that * nothing is left pointing to garbage, un-initialized memory. In most cases - * this probably means just setting members to zero or NULL. + * this probably means just setting members to zero or nullptr. */ SubsystemInterface(); @@ -154,7 +154,7 @@ class SubsystemInterfaceList void resetAll(); void shutdownAll(); #ifdef DUMP_PERF_STATS - AsciiString dumpTimesForAll(); + AsciiString dumpTimesForAll(); #endif private: diff --git a/Core/GameEngine/Include/Common/UnicodeString.h b/Core/GameEngine/Include/Common/UnicodeString.h index ff66edfe478..ba49fbe05a1 100644 --- a/Core/GameEngine/Include/Common/UnicodeString.h +++ b/Core/GameEngine/Include/Common/UnicodeString.h @@ -252,7 +252,7 @@ class UnicodeString void trimEnd(void); /** - Remove all consecutive occurances of c from the end of the string. + Remove all consecutive occurrences of c from the end of the string. */ void trimEnd(const WideChar c); @@ -394,7 +394,7 @@ inline int UnicodeString::getByteCount() const inline Bool UnicodeString::isEmpty() const { validate(); - return m_data == NULL || peek()[0] == 0; + return m_data == nullptr || peek()[0] == 0; } // ----------------------------------------------------- diff --git a/GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h b/Core/GameEngine/Include/Common/UserPreferences.h similarity index 99% rename from GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h rename to Core/GameEngine/Include/Common/UserPreferences.h index 7936cfd8ee6..e3ec9b450ec 100644 --- a/GeneralsMD/Code/GameEngine/Include/Common/UserPreferences.h +++ b/Core/GameEngine/Include/Common/UserPreferences.h @@ -146,6 +146,7 @@ class OptionPreferences : public UserPreferences Int getRenderFpsFontSize(void); Int getSystemTimeFontSize(void); Int getGameTimeFontSize(void); + Int getPlayerInfoListFontSize(void); Real getResolutionFontAdjustment(void); diff --git a/Core/GameEngine/Include/Common/Xfer.h b/Core/GameEngine/Include/Common/Xfer.h index f9c82288007..db5b58a4073 100644 --- a/Core/GameEngine/Include/Common/Xfer.h +++ b/Core/GameEngine/Include/Common/Xfer.h @@ -180,7 +180,7 @@ class Xfer protected: - // this is the actual xfer impelmentation that each derived class should implement + // this is the actual xfer implementation that each derived class should implement virtual void xferImplementation( void *data, Int dataSize ) = 0; UnsignedInt m_options; ///< xfer options diff --git a/Core/GameEngine/Include/Common/file.h b/Core/GameEngine/Include/Common/file.h index 80e66445914..73ebe1417a3 100644 --- a/Core/GameEngine/Include/Common/file.h +++ b/Core/GameEngine/Include/Common/file.h @@ -183,13 +183,13 @@ class File : public MemoryPoolObject * END: means seek the specified number of bytes back from the end of the file */ virtual Bool flush() = 0; ///< flush data to disk - virtual void nextLine(Char *buf = NULL, Int bufSize = 0) = 0; ///< reads until it reaches a new-line character + virtual void nextLine(Char *buf = nullptr, Int bufSize = 0) = 0; ///< reads until it reaches a new-line character virtual Bool scanInt(Int &newInt) = 0; ///< read an integer from the current file position. virtual Bool scanReal(Real &newReal) = 0; ///< read a real number from the current file position. virtual Bool scanString(AsciiString &newString) = 0; ///< read a string from the current file position. - virtual Bool print ( const Char *format, ...); ///< Prints formated string to text file + virtual Bool print ( const Char *format, ...); ///< Prints formatted string to text file virtual Int size( void ); ///< Returns the size of the file virtual Int position( void ); ///< Returns the current read/write position diff --git a/GeneralsMD/Code/GameEngine/Include/GameClient/ChallengeGenerals.h b/Core/GameEngine/Include/GameClient/ChallengeGenerals.h similarity index 98% rename from GeneralsMD/Code/GameEngine/Include/GameClient/ChallengeGenerals.h rename to Core/GameEngine/Include/GameClient/ChallengeGenerals.h index fb8456685e4..351d57d6ae1 100644 --- a/GeneralsMD/Code/GameEngine/Include/GameClient/ChallengeGenerals.h +++ b/Core/GameEngine/Include/GameClient/ChallengeGenerals.h @@ -31,6 +31,7 @@ // INCLUDES ////////////////////////////////////////////////////////////////////////////////// #include "Common/GameType.h" +#include "Common/INI.h" #include "Common/Overridable.h" // DEFINES //////////////////////////////////////////////////////////////////////////////////////// @@ -38,7 +39,7 @@ #define NUM_GENERALS (12) // FORWARD REFERENCES ///////////////////////////////////////////////////////////////////////////// - +class Image; // CLASS DEFINITIONS ////////////////////////////////////////////////////////////////////////////// class GeneralPersona @@ -76,8 +77,8 @@ class GeneralPersona public: GeneralPersona( void ) : - m_imageBioPortraitSmall(NULL), - m_imageBioPortraitLarge(NULL) + m_imageBioPortraitSmall(nullptr), + m_imageBioPortraitLarge(nullptr) { } // ~GeneralPersona( void ); diff --git a/Generals/Code/GameEngine/Include/GameClient/ParticleSys.h b/Core/GameEngine/Include/GameClient/ParticleSys.h similarity index 92% rename from Generals/Code/GameEngine/Include/GameClient/ParticleSys.h rename to Core/GameEngine/Include/GameClient/ParticleSys.h index 8b2194f5332..f152fe86b6e 100644 --- a/Generals/Code/GameEngine/Include/GameClient/ParticleSys.h +++ b/Core/GameEngine/Include/GameClient/ParticleSys.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 @@ -61,6 +61,10 @@ enum ParticleSystemID CPP_11(: Int) #define DEFAULT_VOLUME_PARTICLE_DEPTH ( 0 )//The Default is not to do the volume thing! #define OPTIMUM_VOLUME_PARTICLE_DEPTH ( 6 ) +// TheSuperHackers @info The X and Y angles are not necessary for particles because there are only 2 placement modes: +// Billboard (always facing camera) and Ground Aligned, which overwrite any rotations on the X and Y axis by design. +// Therefore particles can only be rotated on the Z axis. Zero Hour never had X and Y angles, but Generals did. +#define PARTICLE_USE_XY_ROTATION (0) //-------------------------------------------------------------------------------------------------------------- @@ -122,11 +126,15 @@ class ParticleInfo : public Snapshot Coord3D m_emitterPos; ///< position of the emitter Real m_velDamping; ///< velocity damping coefficient +#if PARTICLE_USE_XY_ROTATION Real m_angleX; ///< initial angle around X axis Real m_angleY; ///< initial angle around Y axis +#endif Real m_angleZ; ///< initial angle around Z axis +#if PARTICLE_USE_XY_ROTATION Real m_angularRateX; ///< initial angle around X axis Real m_angularRateY; ///< initial angle around Y axis +#endif Real m_angularRateZ; ///< initial angle around Z axis Real m_angularDamping; ///< angular velocity damping coefficient @@ -174,7 +182,6 @@ class Particle : public MemoryPoolObject, void doWindMotion( void ); ///< do wind motion (if present) from particle system void applyForce( const Coord3D *force ); ///< add the given acceleration - void detachDrawable( void ) { m_drawable = NULL; } ///< detach the Drawable pointer from this particle const Coord3D *getPosition( void ) { return &m_pos; } Real getSize( void ) { return m_size; } @@ -188,7 +195,7 @@ class Particle : public MemoryPoolObject, void setIsCulled (Bool enable) { m_isCulled = enable;} ///< set particle to not visible because it's outside view frustum void controlParticleSystem( ParticleSystem *sys ) { m_systemUnderControl = sys; } - void detachControlledParticleSystem( void ) { m_systemUnderControl = NULL; } + void detachControlledParticleSystem( void ) { m_systemUnderControl = nullptr; } // get priority of this particle ... which is the priority of the system it belongs to ParticlePriorityType getPriority( void ); @@ -231,7 +238,6 @@ class Particle : public MemoryPoolObject, RGBColor m_colorRate; ///< current rate of color change Int m_colorTargetKey; ///< next index into key array - Drawable * m_drawable; ///< drawable associated with this particle Bool m_isCulled; ///< status of particle relative to screen bounds public: @@ -273,18 +279,22 @@ class ParticleSystemInfo : public Snapshot enum ParticleType { - INVALID_TYPE=0, PARTICLE, DRAWABLE, STREAK, VOLUME_PARTICLE, ///< is a particle a 2D-screen-facing particle, or a Drawable, or a Segment in a streak? + INVALID_TYPE=0, PARTICLE, DRAWABLE, STREAK, VOLUME_PARTICLE, SMUDGE, ///< is a particle a 2D-screen-facing particle, or a Drawable, or a Segment in a streak? PARTICLE_TYPE_COUNT } m_particleType; AsciiString m_particleTypeName; ///< if PARTICLE, texture filename, if DRAWABLE, Drawable name +#if PARTICLE_USE_XY_ROTATION GameClientRandomVariable m_angleX; ///< initial angle around X axis GameClientRandomVariable m_angleY; ///< initial angle around Y axis +#endif GameClientRandomVariable m_angleZ; ///< initial angle around Z axis +#if PARTICLE_USE_XY_ROTATION GameClientRandomVariable m_angularRateX; ///< initial angle around X axis GameClientRandomVariable m_angularRateY; ///< initial angle around Y axis +#endif GameClientRandomVariable m_angularRateZ; ///< initial angle around Z axis GameClientRandomVariable m_angularDamping; ///< angular velocity damping coefficient @@ -313,7 +323,8 @@ class ParticleSystemInfo : public Snapshot typedef Int Color; - void tintAllColors( Color tintColor ); + void tintAllColors( Color tintColor); + void tintColorsAllFrames( Color tintColor); GameClientRandomVariable m_colorScale; ///< color coefficient @@ -455,37 +466,37 @@ class ParticleSystemInfo : public Snapshot static const char *const ParticleShaderTypeNames[] = { - "NONE", "ADDITIVE", "ALPHA", "ALPHA_TEST", "MULTIPLY", NULL + "NONE", "ADDITIVE", "ALPHA", "ALPHA_TEST", "MULTIPLY", nullptr }; static_assert(ARRAY_SIZE(ParticleShaderTypeNames) == ParticleSystemInfo::PARTICLE_SHADER_TYPE_COUNT + 1, "Incorrect array size"); static const char *const ParticleTypeNames[] = { - "NONE", "PARTICLE", "DRAWABLE", "STREAK", "VOLUME_PARTICLE", NULL + "NONE", "PARTICLE", "DRAWABLE", "STREAK", "VOLUME_PARTICLE", "SMUDGE", nullptr }; static_assert(ARRAY_SIZE(ParticleTypeNames) == ParticleSystemInfo::PARTICLE_TYPE_COUNT + 1, "Incorrect array size"); static const char *const EmissionVelocityTypeNames[] = { - "NONE", "ORTHO", "SPHERICAL", "HEMISPHERICAL", "CYLINDRICAL", "OUTWARD", NULL + "NONE", "ORTHO", "SPHERICAL", "HEMISPHERICAL", "CYLINDRICAL", "OUTWARD", nullptr }; static_assert(ARRAY_SIZE(EmissionVelocityTypeNames) == ParticleSystemInfo::EMISSION_VELOCITY_TYPE_COUNT + 1, "Incorrect array size"); static const char *const EmissionVolumeTypeNames[] = { - "NONE", "POINT", "LINE", "BOX", "SPHERE", "CYLINDER", NULL + "NONE", "POINT", "LINE", "BOX", "SPHERE", "CYLINDER", nullptr }; static_assert(ARRAY_SIZE(EmissionVolumeTypeNames) == ParticleSystemInfo::EMISSION_VOLUME_TYPE_COUNT + 1, "Incorrect array size"); static const char *const ParticlePriorityNames[] = { - "NONE", "WEAPON_EXPLOSION","SCORCHMARK","DUST_TRAIL","BUILDUP","DEBRIS_TRAIL","UNIT_DAMAGE_FX","DEATH_EXPLOSION","SEMI_CONSTANT","CONSTANT","WEAPON_TRAIL","AREA_EFFECT","CRITICAL", "ALWAYS_RENDER", NULL + "NONE", "WEAPON_EXPLOSION","SCORCHMARK","DUST_TRAIL","BUILDUP","DEBRIS_TRAIL","UNIT_DAMAGE_FX","DEATH_EXPLOSION","SEMI_CONSTANT","CONSTANT","WEAPON_TRAIL","AREA_EFFECT","CRITICAL", "ALWAYS_RENDER", nullptr }; static_assert(ARRAY_SIZE(ParticlePriorityNames) == NUM_PARTICLE_PRIORITIES + 1, "Incorrect array size"); static const char *const WindMotionNames[] = { - "NONE", "Unused", "PingPong", "Circular", NULL + "NONE", "Unused", "PingPong", "Circular", nullptr }; static_assert(ARRAY_SIZE(WindMotionNames) == ParticleSystemInfo::WIND_MOTION_COUNT + 1, "Incorrect array size"); @@ -504,7 +515,7 @@ class ParticleSystemTemplate : public MemoryPoolObject, protected ParticleSystem AsciiString getName( void ) const { return m_name; } // This function was made const because of update modules' module data being all const. - ParticleSystem *createSlaveSystem( Bool createSlaves = TRUE ) const ; ///< if returns non-NULL, it is a slave system for use + ParticleSystem *createSlaveSystem( Bool createSlaves = TRUE ) const ; ///< if returns non-null, it is a slave system for use const FieldParse *getFieldParse( void ) const { return m_fieldParseTable; } ///< Parsing from INI access static void parseRGBColorKeyframe( INI* ini, void *instance, void *store, const void* /*userData*/ ); @@ -528,7 +539,7 @@ class ParticleSystemTemplate : public MemoryPoolObject, protected ParticleSystem AsciiString m_name; ///< the name of this template // This has to be mutable because of the delayed initialization thing in createSlaveSystem - mutable const ParticleSystemTemplate *m_slaveTemplate; ///< if non-NULL, use this to create a slave system + mutable const ParticleSystemTemplate *m_slaveTemplate; ///< if non-null, use this to create a slave system // template attribute data inherited from ParticleSystemInfo class }; @@ -559,6 +570,7 @@ class ParticleSystem : public MemoryPoolObject, void rotateLocalTransformX( Real x ); ///< rotate local transform matrix void rotateLocalTransformY( Real y ); ///< rotate local transform matrix void rotateLocalTransformZ( Real z ); ///< rotate local transform matrix + void setSkipParentXfrm(Bool enable) { m_skipParentXfrm = enable; } /// ParticleSystemList; - typedef std::list::iterator ParticleSystemListIt; + typedef ParticleSystemList::iterator ParticleSystemListIt; + typedef std::hash_map, rts::equal_to > ParticleSystemIDMap; typedef std::hash_map, rts::equal_to > TemplateMap; ParticleSystemManager( void ); @@ -791,7 +815,7 @@ class ParticleSystemManager : public SubsystemInterface, virtual void preloadAssets( TimeOfDay timeOfDay ); - // these are only for use by partcle systems to link and unlink themselves + // these are only for use by particle systems to link and unlink themselves void friend_addParticleSystem( ParticleSystem *particleSystemToAdd ); void friend_removeParticleSystem( ParticleSystem *particleSystemToRemove ); @@ -818,10 +842,11 @@ class ParticleSystemManager : public SubsystemInterface, private: TemplateMap m_templateMap; ///< a hash map of all particle system templates + ParticleSystemIDMap m_systemMap; ///< a hash map of all particle systems }; /// The particle system manager singleton extern ParticleSystemManager *TheParticleSystemManager; class DebugDisplayInterface; -extern void ParticleSystemDebugDisplay( DebugDisplayInterface *dd, void *, FILE *fp = NULL ); +extern void ParticleSystemDebugDisplay( DebugDisplayInterface *dd, void *, FILE *fp = nullptr ); diff --git a/Core/GameEngine/Include/GameClient/TerrainRoads.h b/Core/GameEngine/Include/GameClient/TerrainRoads.h index dd7669c9c1d..858a6e22b73 100644 --- a/Core/GameEngine/Include/GameClient/TerrainRoads.h +++ b/Core/GameEngine/Include/GameClient/TerrainRoads.h @@ -206,7 +206,7 @@ class TerrainRoadCollection : public SubsystemInterface void update() { } TerrainRoadType *findRoad( AsciiString name ); ///< find road with matching name - TerrainRoadType *newRoad( AsciiString name ); ///< allocate new road, assing name, and link to list + TerrainRoadType *newRoad( AsciiString name ); ///< allocate new road, assign name, and link to list TerrainRoadType *firstRoad( void ) { return m_roadList; } ///< return first road TerrainRoadType *nextRoad( TerrainRoadType *road ); ///< get next road diff --git a/Core/GameEngine/Include/GameClient/TerrainVisual.h b/Core/GameEngine/Include/GameClient/TerrainVisual.h index 8463ff83ab1..c1eaa434bd5 100644 --- a/Core/GameEngine/Include/GameClient/TerrainVisual.h +++ b/Core/GameEngine/Include/GameClient/TerrainVisual.h @@ -75,7 +75,7 @@ struct SeismicSimulationNode m_region.hi.x = 0; m_region.hi.y = 0; m_clean = FALSE; - callbackFilter = NULL; + callbackFilter = nullptr; m_life = 0; m_magnitude = DEFAULT_SEISMIC_SIMULATION_MAGNITUDE; @@ -95,7 +95,7 @@ struct SeismicSimulationNode m_magnitude = ssn.m_magnitude; } - SeismicSimulationNode( const Coord3D* ctr, Real rad, Real mag, SeismicSimulationFilterBase *cbf = NULL ) + SeismicSimulationNode( const Coord3D* ctr, Real rad, Real mag, SeismicSimulationFilterBase *cbf = nullptr ) { m_center.x = REAL_TO_INT_FLOOR(ctr->x/MAP_XY_FACTOR); m_center.y = REAL_TO_INT_FLOOR(ctr->y/MAP_XY_FACTOR); @@ -114,7 +114,7 @@ struct SeismicSimulationNode SeismicSimulationFilterBase::SeismicSimStatusCode handleFilterCallback( WorldHeightMapInterfaceClass *heightMap ) { - if ( callbackFilter == NULL ) + if ( callbackFilter == nullptr ) return SeismicSimulationFilterBase::SEISMIC_STATUS_INVALID; ++m_life; @@ -126,7 +126,7 @@ struct SeismicSimulationNode { DEBUG_ASSERTCRASH( callbackFilter, ("SeismicSimulationNode::applyGravity() has no callback filter!") ); - if ( callbackFilter == NULL ) + if ( callbackFilter == nullptr ) return velocityIn;//oops, we have no callback! return callbackFilter->applyGravityCallback( velocityIn ); @@ -186,7 +186,7 @@ static const char *const TerrainLODNames[] = "AUTOMATIC", "DISABLE", - NULL + nullptr }; static_assert(ARRAY_SIZE(TerrainLODNames) == TERRAIN_LOD_NUM_TYPES + 1, "Incorrect array size"); #endif // end DEFINE_TERRAIN_LOD_NAMES @@ -229,7 +229,7 @@ class TerrainVisual : public Snapshot, virtual void enableWaterGrid( Bool enable ) = 0; /// set min/max height values allowed in water grid pointed to by waterTable virtual void setWaterGridHeightClamps( const WaterHandle *waterTable, Real minZ, Real maxZ ) = 0; - /// adjust fallof parameters for grid change method + /// adjust falloff parameters for grid change method virtual void setWaterAttenuationFactors( const WaterHandle *waterTable, Real a, Real b, Real c, Real range ) = 0; /// set the water table position and orientation in world space virtual void setWaterTransform( const WaterHandle *waterTable, Real angle, Real x, Real y, Real z ) = 0; @@ -285,8 +285,8 @@ class TerrainVisual : public Snapshot, virtual void updateSeismicSimulations( void ) = 0; /// walk the SeismicSimulationList and, well, do it. virtual void addSeismicSimulation( const SeismicSimulationNode& sim ) = 0; #endif - virtual WorldHeightMap* getLogicHeightMap( void ) {return NULL;}; - virtual WorldHeightMap* getClientHeightMap( void ) {return NULL;}; + virtual WorldHeightMap* getLogicHeightMap( void ) {return nullptr;}; + virtual WorldHeightMap* getClientHeightMap( void ) {return nullptr;}; //////////////////////////////////////////////////// //////////////////////////////////////////////////// //////////////////////////////////////////////////// diff --git a/Core/GameEngine/Include/GameClient/View.h b/Core/GameEngine/Include/GameClient/View.h index 9d26976debb..cb64129d7d3 100644 --- a/Core/GameEngine/Include/GameClient/View.h +++ b/Core/GameEngine/Include/GameClient/View.h @@ -118,7 +118,7 @@ class View : public Snapshot /** project the 4 corners of this view into the world and return each point as a parameter, the world points are at the requested Z */ virtual void getScreenCornerWorldPointsAtZ( Coord3D *topLeft, Coord3D *topRight, - Coord3D *bottomLeft, Coord3D *bottomRight, + Coord3D *bottomRight, Coord3D *bottomLeft, Real z ); virtual void setWidth( Int width ) { m_width = width; } @@ -148,7 +148,7 @@ class View : public Snapshot virtual void cameraModFinalLookToward(Coord3D *pLoc){} ///< Sets a look at point during camera movement. virtual void cameraModFinalMoveTo(Coord3D *pLoc){ }; ///< Sets a final move to. - // (gth) C&C3 animation controled camera feature + // (gth) C&C3 animation controlled camera feature virtual void cameraEnableSlaveMode(const AsciiString & thingtemplateName, const AsciiString & boneName) {} virtual void cameraDisableSlaveMode(void) {} virtual void Add_Camera_Shake(const Coord3D & position,float radius, float duration, float power) {} @@ -168,15 +168,16 @@ class View : public Snapshot virtual Bool isTimeFrozen(void){ return false;} ///< Freezes time during the next camera movement. virtual Int getTimeMultiplier(void) {return 1;}; ///< Get the time multiplier. virtual void setTimeMultiplier(Int multiple) {}; ///< Set the time multiplier. - virtual void setDefaultView(Real pitch, Real angle, Real maxHeight) {}; + virtual void setDefaultView(Real pitch, Real angle, Real maxHeight) {}; // TheSuperHackers @todo Replace with setDefaultPitch(), setMaxHeightScale() virtual void zoomCamera( Real finalZoom, Int milliseconds, Real easeIn=0.0f, Real easeOut=0.0f ) {}; virtual void pitchCamera( Real finalPitch, Int milliseconds, Real easeIn=0.0f, Real easeOut=0.0f ) {}; - virtual void setAngle( Real angle ); ///< Rotate the view around the up axis to the given angle - virtual Real getAngle( void ) { return m_angle; } - virtual void setPitch( Real angle ); ///< Rotate the view around the horizontal axis to the given angle - virtual Real getPitch( void ) { return m_pitchAngle; } ///< Return current camera pitch - virtual void setAngleAndPitchToDefault( void ); ///< Set the view angle back to default + virtual void setAngle( Real radians ); ///< Rotate the view around the vertical axis to the given angle (yaw) + virtual Real getAngle( void ) { return m_angle; } ///< Return current camera angle + virtual void setPitch( Real radians ); ///< Rotate the view around the horizontal axis to the given angle (pitch) + virtual Real getPitch( void ) { return m_pitch; } ///< Return current camera pitch + virtual void setAngleToDefault( void ); ///< Set the view angle back to default + virtual void setPitchToDefault( void ); ///< Set the view pitch back to default virtual void getPosition(Coord3D *pos) { *pos=m_pos;} ///< Returns position camera is looking at (z will be zero) virtual const Coord3D& get3DCameraPosition() const = 0; ///< Returns the actual camera position @@ -190,17 +191,14 @@ class View : public Snapshot virtual void setOkToAdjustHeight( Bool val ) { m_okToAdjustHeight = val; } ///< Set this to adjust camera height // for debugging - virtual Real getTerrainHeightUnderCamera() { return m_terrainHeightUnderCamera; } - virtual void setTerrainHeightUnderCamera(Real z) { m_terrainHeightUnderCamera = z; } + virtual Real getTerrainHeightAtPivot() { return m_terrainHeightAtPivot; } virtual Real getCurrentHeightAboveGround() { return m_currentHeightAboveGround; } - virtual void setCurrentHeightAboveGround(Real z) { m_currentHeightAboveGround = z; } virtual void setFieldOfView( Real angle ) { m_FOV = angle; } ///< Set the horizontal field of view angle virtual Real getFieldOfView( void ) { return m_FOV; } ///< Get the horizontal field of view angle Bool worldToScreen( const Coord3D *w, ICoord2D *s ) { return worldToScreenTriReturn( w, s ) == WTS_INSIDE_FRUSTUM; } ///< Transform world coordinate "w" into screen coordinate "s" virtual WorldToScreenReturn worldToScreenTriReturn(const Coord3D *w, ICoord2D *s ) = 0; ///< Like worldToScreen(), but with a more informative return value - virtual void screenToWorld( const ICoord2D *s, Coord3D *w ) = 0; ///< Transform screen coordinate "s" into world coordinate "w" virtual void screenToTerrain( const ICoord2D *screen, Coord3D *world ) = 0; ///< transform screen coord to a point on the 3D terrain virtual void screenToWorldAtZ( const ICoord2D *s, Coord3D *w, Real z ) = 0; ///< transform screen point to world point at the specified world Z value @@ -231,7 +229,7 @@ class View : public Snapshot virtual void shake( const Coord3D *epicenter, CameraShakeType shakeType ) { }; virtual Real getFXPitch( void ) const { return 1.0f; } ///< returns the FX pitch angle - virtual void forceCameraConstraintRecalc(void) {} + virtual void forceCameraAreaConstraintRecalc(void) {} virtual void setGuardBandBias( const Coord2D *gb ) = 0; protected: @@ -254,27 +252,27 @@ class View : public Snapshot View *m_next; ///< List links used by the Display class - UnsignedInt m_id; ///< Rhe ID of this view + UnsignedInt m_id; ///< The ID of this view static UnsignedInt m_idNext; ///< Used for allocating view ID's for all views UnsignedInt m_viewLockedUntilFrame; - Coord3D m_pos; ///< Position of this view, in world coordinates + Coord3D m_pos; ///< Pivot of the camera, in world coordinates // TheSuperHackers @todo Make this Coord2D or use the Z component Int m_width, m_height; ///< Dimensions of the view Int m_originX, m_originY; ///< Location of top/left view corner - Real m_angle; ///< Angle at which view has been rotated about the Z axis - Real m_pitchAngle; ///< Rotation of view direction around horizontal (X) axis + Real m_angle; ///< Angle at which view has been rotated about the Z axis. Expected normalized + Real m_pitch; ///< Rotation of view direction around horizontal (X) axis. Expected normalized Real m_maxHeightAboveGround; ///< Highest camera above ground value Real m_minHeightAboveGround; ///< Lowest camera above ground value Real m_zoom; ///< Current zoom value - Real m_heightAboveGround; ///< User's desired height above ground + Real m_heightAboveGround; ///< User's desired camera height above ground Bool m_zoomLimited; ///< Camera restricted in zoom height - Real m_defaultAngle; - Real m_defaultPitchAngle; - Real m_currentHeightAboveGround; ///< Cached value for debugging - Real m_terrainHeightUnderCamera; ///< Cached value for debugging + Real m_defaultAngle; ///< Expected normalized + Real m_defaultPitch; ///< Expected normalized + Real m_currentHeightAboveGround; ///< Actual camera height above ground, or rather height above ground at default pitch + Real m_terrainHeightAtPivot; ///< Actual terrain height at camera pivot ObjectID m_cameraLock; ///< if nonzero, id of object that the camera should follow Drawable *m_cameraLockDrawable; ///< if nonzero, drawable of object that camera should follow. diff --git a/Core/GameEngine/Include/GameLogic/LogicRandomValue.h b/Core/GameEngine/Include/GameLogic/LogicRandomValue.h index 0bc26ef7d14..ee2c6b936ec 100644 --- a/Core/GameEngine/Include/GameLogic/LogicRandomValue.h +++ b/Core/GameEngine/Include/GameLogic/LogicRandomValue.h @@ -33,11 +33,15 @@ // do NOT use these functions directly, rather use the macros below extern Int GetGameLogicRandomValue( int lo, int hi, const char *file, int line ); +extern Int GetGameLogicRandomValueUnchanged(int lo, int hi, const char* file, int line); extern Real GetGameLogicRandomValueReal( Real lo, Real hi, const char *file, int line ); +extern Real GetGameLogicRandomValueRealUnchanged(Real lo, Real hi, const char* file, int line); // use these macros to access the random value functions #define GameLogicRandomValue( lo, hi ) GetGameLogicRandomValue( lo, hi, __FILE__, __LINE__ ) +#define GameLogicRandomValueUnchanged( lo, hi ) GetGameLogicRandomValueUnchanged( lo, hi, __FILE__, __LINE__ ) #define GameLogicRandomValueReal( lo, hi ) GetGameLogicRandomValueReal( lo, hi, __FILE__, __LINE__ ) +#define GameLogicRandomValueRealUnchanged( lo, hi ) GetGameLogicRandomValueRealUnchanged( lo, hi, __FILE__, __LINE__ ) //-------------------------------------------------------------------------------------------------------------- class CColorAlphaDialog; diff --git a/Core/GameEngine/Include/GameNetwork/Connection.h b/Core/GameEngine/Include/GameNetwork/Connection.h index 660a3dcfbb6..5324e29677a 100644 --- a/Core/GameEngine/Include/GameNetwork/Connection.h +++ b/Core/GameEngine/Include/GameNetwork/Connection.h @@ -18,7 +18,7 @@ /** * The Connection class handles queues for individual players, one connection per player. - * Connections are identified by their names (m_name). This should accomodate changing IPs + * Connections are identified by their names (m_name). This should accommodate changing IPs * in the face of modem disconnects, NAT irregularities, etc. * Messages can be guaranteed or non-guaranteed, sequenced or not. * diff --git a/Core/GameEngine/Include/GameNetwork/ConnectionManager.h b/Core/GameEngine/Include/GameNetwork/ConnectionManager.h index 98b98fe36ef..3bb96129831 100644 --- a/Core/GameEngine/Include/GameNetwork/ConnectionManager.h +++ b/Core/GameEngine/Include/GameNetwork/ConnectionManager.h @@ -144,7 +144,7 @@ class ConnectionManager // For disconnect blame assignment UnsignedInt getPingFrame(); Int getPingsSent(); - Int getPingsRecieved(); + Int getPingsReceived(); private: void doRelay(); @@ -171,13 +171,13 @@ class ConnectionManager // void doPerFrameMetrics(UnsignedInt frame); void getMinimumFps(Int &minFps, Int &minFpsPlayer); ///< Returns the smallest FPS in the m_fpsAverages list. - Real getMaximumLatency(); ///< Returns the highest average latency between players. + Real getMaximumLatency(); ///< Returns the average of the two highest average latencies between players. void requestFrameDataResend(Int playerID, UnsignedInt frame); ///< request of this player that he send the specified frame's data. // The connections are set up like the slot list. The connection corresponding to the local - // player's position in the slot list will be NULL. Connections corresponding to slots that - // do not have a player will also be NULL. + // player's position in the slot list will be null. Connections corresponding to slots that + // do not have a player will also be null. Connection *m_connections[MAX_SLOTS]; Transport *m_transport; diff --git a/Core/GameEngine/Include/GameNetwork/DisconnectManager.h b/Core/GameEngine/Include/GameNetwork/DisconnectManager.h index cfc1fb952e4..ccbb183881f 100644 --- a/Core/GameEngine/Include/GameNetwork/DisconnectManager.h +++ b/Core/GameEngine/Include/GameNetwork/DisconnectManager.h @@ -61,7 +61,7 @@ class DisconnectManager // For disconnect blame assignment UnsignedInt getPingFrame(); Int getPingsSent(); - Int getPingsRecieved(); + Int getPingsReceived(); protected: void sendKeepAlive(ConnectionManager *conMgr); @@ -120,6 +120,6 @@ class DisconnectManager time_t m_timeOfDisconnectScreenOn; Int m_pingsSent; - Int m_pingsRecieved; + Int m_pingsReceived; UnsignedInt m_pingFrame; }; diff --git a/Core/GameEngine/Include/GameNetwork/GameInfo.h b/Core/GameEngine/Include/GameNetwork/GameInfo.h index 79831cd16f6..b51b6ae7ff0 100644 --- a/Core/GameEngine/Include/GameNetwork/GameInfo.h +++ b/Core/GameEngine/Include/GameNetwork/GameInfo.h @@ -147,7 +147,7 @@ class GameSlot /** * GameInfo class - maintains information about the game setup and - * the contents of its slot list hroughout the game. + * the contents of its slot list throughout the game. */ class GameInfo { diff --git a/Core/GameEngine/Include/GameNetwork/GameSpy/PeerDefs.h b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerDefs.h index 41332be23a1..50325a5d03c 100644 --- a/Core/GameEngine/Include/GameNetwork/GameSpy/PeerDefs.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerDefs.h @@ -291,7 +291,7 @@ void GetAdditionalDisconnectsFromUserFile(PSPlayerStats *stats); extern Int GetAdditionalDisconnectsFromUserFile(Int playerID); //------------------------------------------------------------------------- -// These functions set up the globals and threads neccessary for our GameSpy impl. +// These functions set up the globals and threads necessary for our GameSpy impl. void SetUpGameSpy( const char *motdBuffer, const char *configBuffer ); void TearDownGameSpy( void ); diff --git a/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h index 5178e7d36bb..67744cf75c7 100644 --- a/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpy/PeerThread.h @@ -147,7 +147,7 @@ class PeerRequest UnsignedInt ladderPassCRC; Int maxPing; Int maxDiscons, discons; - char pings[17]; // 8 servers (0-ff), 1 NULL + char pings[17]; // 8 servers (0-ff), 1 null terminator Int numPlayers; Int botID; Int roomID; diff --git a/Core/GameEngine/Include/GameNetwork/GameSpyOverlay.h b/Core/GameEngine/Include/GameNetwork/GameSpyOverlay.h index b6dd9035949..26976e9833d 100644 --- a/Core/GameEngine/Include/GameNetwork/GameSpyOverlay.h +++ b/Core/GameEngine/Include/GameNetwork/GameSpyOverlay.h @@ -36,7 +36,7 @@ #include "GameClient/GameWindowManager.h" void ClearGSMessageBoxes( void ); ///< Tear down any GS message boxes (e.g. in case we have a new one to put up) -void GSMessageBoxOk(UnicodeString titleString,UnicodeString bodyString, GameWinMsgBoxFunc okFunc = NULL); ///< Display a Message box with Ok button and track it +void GSMessageBoxOk(UnicodeString titleString,UnicodeString bodyString, GameWinMsgBoxFunc okFunc = nullptr); ///< Display a Message box with Ok button and track it void GSMessageBoxOkCancel(UnicodeString title, UnicodeString message, GameWinMsgBoxFunc okFunc, GameWinMsgBoxFunc cancelFunc); ///< Display a Message box with Ok/Cancel buttons and track it void GSMessageBoxYesNo(UnicodeString title, UnicodeString message, GameWinMsgBoxFunc yesFunc, GameWinMsgBoxFunc noFunc); ///< Display a Message box with Yes/No buttons and track it void RaiseGSMessageBox( void ); ///< Bring GS message box to the foreground (if we transition screens while a message box is up) diff --git a/Core/GameEngine/Include/GameNetwork/IPEnumeration.h b/Core/GameEngine/Include/GameNetwork/IPEnumeration.h index 0b2651d2484..dea7352a587 100644 --- a/Core/GameEngine/Include/GameNetwork/IPEnumeration.h +++ b/Core/GameEngine/Include/GameNetwork/IPEnumeration.h @@ -37,7 +37,7 @@ class EnumeratedIP : public MemoryPoolObject { MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(EnumeratedIP, "EnumeratedIP") public: - EnumeratedIP() { m_IPstring = ""; m_next = NULL; m_IP = 0; } + EnumeratedIP() { m_IPstring = ""; m_next = nullptr; m_IP = 0; } // Access functions AsciiString getIPstring( void ) { return m_IPstring; } diff --git a/Core/GameEngine/Include/GameNetwork/LANAPI.h b/Core/GameEngine/Include/GameNetwork/LANAPI.h index eecd1eedbaf..511e18295af 100644 --- a/Core/GameEngine/Include/GameNetwork/LANAPI.h +++ b/Core/GameEngine/Include/GameNetwork/LANAPI.h @@ -44,7 +44,7 @@ static const Int g_lanHostNameLength = 1; static const Int g_lanGameNameLength = 16; // reduced length because of game option length static const Int g_lanGameNameReservedLength = 16; // save N wchars for ID info static const Int g_lanMaxChatLength = 100; -static const Int m_lanMaxOptionsLength = MAX_PACKET_SIZE - ( 8 + (g_lanGameNameLength+1)*2 + 4 + (g_lanPlayerNameLength+1)*2 +static const Int m_lanMaxOptionsLength = MAX_LANAPI_PACKET_SIZE - ( 8 + (g_lanGameNameLength+1)*2 + 4 + (g_lanPlayerNameLength+1)*2 + (g_lanLoginNameLength+1) + (g_lanHostNameLength+1) ); static const Int g_maxSerialLength = 23; // including the trailing '\0' @@ -130,6 +130,7 @@ class LANAPIInterface : public SubsystemInterface // Misc utility functions virtual LANGameInfo * LookupGame( UnicodeString gameName ) = 0; ///< return a pointer to a game we know about virtual LANGameInfo * LookupGameByListOffset( Int offset ) = 0; ///< return a pointer to a game we know about + virtual LANGameInfo * LookupGameByHost( UnsignedInt hostIP ) = 0; ///< return a pointer to the most recent game associated to the host IP address virtual Bool SetLocalIP( UnsignedInt localIP ) = 0; ///< For multiple NIC machines virtual void SetLocalIP( AsciiString localIP ) = 0; ///< For multiple NIC machines virtual Bool AmIHost( void ) = 0; ///< Am I hosting a game? @@ -140,6 +141,139 @@ class LANAPIInterface : public SubsystemInterface }; +/** + * LAN message class + */ +#pragma pack(push, 1) +struct LANMessage +{ + enum Type ///< What kind of message are we? + { + // Locating everybody + MSG_REQUEST_LOCATIONS, ///< Hey, where is everybody? + MSG_GAME_ANNOUNCE, ///< Here I am, and here's my game info! + MSG_LOBBY_ANNOUNCE, ///< Hey, I'm in the lobby! + + // Joining games + MSG_REQUEST_JOIN, ///< Let me in! Let me in! + MSG_JOIN_ACCEPT, ///< Okay, you can join. + MSG_JOIN_DENY, ///< Go away! We don't want any! + + // Leaving games + MSG_REQUEST_GAME_LEAVE, ///< I want to leave the game + MSG_REQUEST_LOBBY_LEAVE,///< I'm leaving the lobby + + // Game options, chat, etc + MSG_SET_ACCEPT, ///< I'm cool with everything as is. + MSG_MAP_AVAILABILITY, ///< I do (not) have the map. + MSG_CHAT, ///< Just spouting my mouth off. + MSG_GAME_START, ///< Hold on; we're starting! + MSG_GAME_START_TIMER, ///< The game will start in N seconds + MSG_GAME_OPTIONS, ///< Here's some info about the game. + 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 + } messageType; + + WideChar name[g_lanPlayerNameLength+1]; ///< My name, for convenience + char userName[g_lanLoginNameLength+1]; ///< login name, for convenience + char hostName[g_lanHostNameLength+1]; ///< machine name, for convenience + + // No additional data is required for REQUEST_LOCATIONS, LOBBY_ANNOUNCE, + // REQUEST_LOBBY_LEAVE, GAME_START. + union + { + // StartTimer is sent with GAME_START_TIMER + struct + { + Int seconds; + } StartTimer; + + // GameJoined is sent with REQUEST_GAME_LEAVE + struct + { + WideChar gameName[g_lanGameNameLength+1]; + } GameToLeave; + + // GameInfo if sent with GAME_ANNOUNCE + struct + { + WideChar gameName[g_lanGameNameLength+1]; + Bool inProgress; + char options[m_lanMaxOptionsLength+1]; + Bool isDirectConnect; + } GameInfo; + + // PlayerInfo is sent with REQUEST_GAME_INFO for direct connect games. + struct + { + UnsignedInt ip; + WideChar playerName[g_lanPlayerNameLength+1]; + } PlayerInfo; + + // GameToJoin is sent with REQUEST_JOIN + struct + { + UnsignedInt gameIP; + UnsignedInt exeCRC; + UnsignedInt iniCRC; + char serial[g_maxSerialLength]; + } GameToJoin; + + // GameJoined is sent with JOIN_ACCEPT + struct + { + WideChar gameName[g_lanGameNameLength+1]; + UnsignedInt gameIP; + UnsignedInt playerIP; + Int slotPosition; + } GameJoined; + + // GameNotJoined is sent with JOIN_DENY + struct + { + WideChar gameName[g_lanGameNameLength+1]; + UnsignedInt gameIP; + UnsignedInt playerIP; + LANAPIInterface::ReturnType reason; + } GameNotJoined; + + // Accept is sent with SET_ACCEPT + struct + { + WideChar gameName[g_lanGameNameLength+1]; + Bool isAccepted; + } Accept; + + // Accept is sent with MAP_AVAILABILITY + struct + { + WideChar gameName[g_lanGameNameLength+1]; + UnsignedInt mapCRC; // to make sure we're talking about the same map + Bool hasMap; + } MapStatus; + + // Chat is sent with CHAT + struct + { + WideChar gameName[g_lanGameNameLength+1]; + LANAPIInterface::ChatType chatType; + WideChar message[g_lanMaxChatLength+1]; + } Chat; + + // GameOptions is sent with GAME_OPTIONS + struct + { + char options[m_lanMaxOptionsLength+1]; + } GameOptions; + + }; +}; +#pragma pack(pop) + +static_assert(sizeof(LANMessage) <= MAX_LANAPI_PACKET_SIZE, "LANMessage struct cannot be larger than the max packet size"); + + /** * The LANAPI class is used to instantiate a singleton which * implements the interface to all LAN broadcast communications. @@ -198,6 +332,7 @@ class LANAPI : public LANAPIInterface // Misc utility functions virtual LANGameInfo * LookupGame( UnicodeString gameName ); ///< return a pointer to a game we know about virtual LANGameInfo * LookupGameByListOffset( Int offset ); ///< return a pointer to a game we know about + virtual LANGameInfo * LookupGameByHost( UnsignedInt hostIP ); ///< return a pointer to the most recent game associated to the host IP address virtual LANPlayer * LookupPlayer( UnsignedInt playerIP ); ///< return a pointer to a player we know about virtual Bool SetLocalIP( UnsignedInt localIP ); ///< For multiple NIC machines virtual void SetLocalIP( AsciiString localIP ); ///< For multiple NIC machines @@ -238,7 +373,7 @@ class LANAPI : public LANAPIInterface Bool m_isInLANMenu; ///< true while we are in a LAN menu (lobby, game options, direct connect) Bool m_inLobby; ///< Are we in the lobby (not in a game)? - LANGameInfo * m_currentGame; ///< Pointer to game (setup screen) we are currently in (NULL for lobby) + LANGameInfo * m_currentGame; ///< Pointer to game (setup screen) we are currently in (null for lobby) //LANGameInfo *m_currentGameInfo; ///< Pointer to game setup info we are currently in. UnsignedInt m_localIP; @@ -278,135 +413,3 @@ class LANAPI : public LANAPIInterface void handleInActive( LANMessage *msg, UnsignedInt senderIP ); }; - - - -/** - * LAN message class - */ -#pragma pack(push, 1) -struct LANMessage -{ - enum Type ///< What kind of message are we? - { - // Locating everybody - MSG_REQUEST_LOCATIONS, ///< Hey, where is everybody? - MSG_GAME_ANNOUNCE, ///< Here I am, and here's my game info! - MSG_LOBBY_ANNOUNCE, ///< Hey, I'm in the lobby! - - // Joining games - MSG_REQUEST_JOIN, ///< Let me in! Let me in! - MSG_JOIN_ACCEPT, ///< Okay, you can join. - MSG_JOIN_DENY, ///< Go away! We don't want any! - - // Leaving games - MSG_REQUEST_GAME_LEAVE, ///< I want to leave the game - MSG_REQUEST_LOBBY_LEAVE,///< I'm leaving the lobby - - // Game options, chat, etc - MSG_SET_ACCEPT, ///< I'm cool with everything as is. - MSG_MAP_AVAILABILITY, ///< I do (not) have the map. - MSG_CHAT, ///< Just spouting my mouth off. - MSG_GAME_START, ///< Hold on; we're starting! - MSG_GAME_START_TIMER, ///< The game will start in N seconds - MSG_GAME_OPTIONS, ///< Here's some info about the game. - 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 - } messageType; - - WideChar name[g_lanPlayerNameLength+1]; ///< My name, for convenience - char userName[g_lanLoginNameLength+1]; ///< login name, for convenience - char hostName[g_lanHostNameLength+1]; ///< machine name, for convenience - - // No additional data is required for REQUEST_LOCATIONS, LOBBY_ANNOUNCE, - // REQUEST_LOBBY_LEAVE, GAME_START. - union - { - // StartTimer is sent with GAME_START_TIMER - struct - { - Int seconds; - } StartTimer; - - // GameJoined is sent with REQUEST_GAME_LEAVE - struct - { - WideChar gameName[g_lanGameNameLength+1]; - } GameToLeave; - - // GameInfo if sent with GAME_ANNOUNCE - struct - { - WideChar gameName[g_lanGameNameLength+1]; - Bool inProgress; - char options[m_lanMaxOptionsLength+1]; - Bool isDirectConnect; - } GameInfo; - - // PlayerInfo is sent with REQUEST_GAME_INFO for direct connect games. - struct - { - UnsignedInt ip; - WideChar playerName[g_lanPlayerNameLength+1]; - } PlayerInfo; - - // GameToJoin is sent with REQUEST_JOIN - struct - { - UnsignedInt gameIP; - UnsignedInt exeCRC; - UnsignedInt iniCRC; - char serial[g_maxSerialLength]; - } GameToJoin; - - // GameJoined is sent with JOIN_ACCEPT - struct - { - WideChar gameName[g_lanGameNameLength+1]; - UnsignedInt gameIP; - UnsignedInt playerIP; - Int slotPosition; - } GameJoined; - - // GameNotJoined is sent with JOIN_DENY - struct - { - WideChar gameName[g_lanGameNameLength+1]; - UnsignedInt gameIP; - UnsignedInt playerIP; - LANAPIInterface::ReturnType reason; - } GameNotJoined; - - // Accept is sent with SET_ACCEPT - struct - { - WideChar gameName[g_lanGameNameLength+1]; - Bool isAccepted; - } Accept; - - // Accept is sent with MAP_AVAILABILITY - struct - { - WideChar gameName[g_lanGameNameLength+1]; - UnsignedInt mapCRC; // to make sure we're talking about the same map - Bool hasMap; - } MapStatus; - - // Chat is sent with CHAT - struct - { - WideChar gameName[g_lanGameNameLength+1]; - LANAPIInterface::ChatType chatType; - WideChar message[g_lanMaxChatLength+1]; - } Chat; - - // GameOptions is sent with GAME_OPTIONS - struct - { - char options[m_lanMaxOptionsLength+1]; - } GameOptions; - - }; -}; -#pragma pack(pop) diff --git a/Core/GameEngine/Include/GameNetwork/LANGameInfo.h b/Core/GameEngine/Include/GameNetwork/LANGameInfo.h index dbdeb0dfc69..c22696cf4c8 100644 --- a/Core/GameEngine/Include/GameNetwork/LANGameInfo.h +++ b/Core/GameEngine/Include/GameNetwork/LANGameInfo.h @@ -42,7 +42,7 @@ class LANGameSlot : public GameSlot public: LANGameSlot(); - LANPlayer *getUser( void ); ///< Get the User structure associated with the slot (NULL for non-humans) + LANPlayer *getUser( void ); ///< Get the User structure associated with the slot (null for non-humans) // Various tests Bool isUser( LANPlayer *user ); ///< Does this slot contain the given user? Based off user->name @@ -97,7 +97,7 @@ class LANGameInfo : public GameInfo 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 + // Convenience 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? diff --git a/Core/GameEngine/Include/GameNetwork/LANPlayer.h b/Core/GameEngine/Include/GameNetwork/LANPlayer.h index f71e7b18a73..e7c4e2f1e16 100644 --- a/Core/GameEngine/Include/GameNetwork/LANPlayer.h +++ b/Core/GameEngine/Include/GameNetwork/LANPlayer.h @@ -35,7 +35,7 @@ class LANPlayer { public: - LANPlayer() { m_name = m_login = m_host = L""; m_lastHeard = 0; m_next = NULL; m_IP = 0; } + LANPlayer() { m_name = m_login = m_host = L""; m_lastHeard = 0; m_next = nullptr; m_IP = 0; } // Access functions UnicodeString getName( void ) { return m_name; } diff --git a/Core/GameEngine/Include/GameNetwork/NetCommandList.h b/Core/GameEngine/Include/GameNetwork/NetCommandList.h index 21aa6ff733b..3e042d92123 100644 --- a/Core/GameEngine/Include/GameNetwork/NetCommandList.h +++ b/Core/GameEngine/Include/GameNetwork/NetCommandList.h @@ -35,7 +35,7 @@ * adding commands in order more efficiently since that is whats going to be * done most of the time. If the new message doesn't go after the last message * inserted, then the list will be traversed linearly until the proper spot is - * found. We can get away with this inefficient method since these occurances + * found. We can get away with this inefficient method since these occurrences * will be rare. Also, the list is not expected to ever have more than 30 or so * commands on it at a time. Five commands would probably be a normal amount. */ diff --git a/Core/GameEngine/Include/GameNetwork/NetCommandMsg.h b/Core/GameEngine/Include/GameNetwork/NetCommandMsg.h index 59b05f88e29..84eb1566689 100644 --- a/Core/GameEngine/Include/GameNetwork/NetCommandMsg.h +++ b/Core/GameEngine/Include/GameNetwork/NetCommandMsg.h @@ -44,12 +44,13 @@ class NetCommandMsg : public MemoryPoolObject 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; } + UnsignedInt getExecutionFrame() const { return m_executionFrame; } + UnsignedInt getPlayerID() const { return m_playerID; } + UnsignedShort getID() const { return m_id; } void setNetCommandType(NetCommandType type) { m_commandType = type; } NetCommandType getNetCommandType() { return m_commandType; } virtual Int getSortNumber(); + virtual size_t getPackedByteCount() const = 0; void attach(); void detach(); @@ -76,10 +77,12 @@ class NetGameCommandMsg : public NetCommandMsg NetGameCommandMsg(GameMessage *msg); //virtual ~NetGameCommandMsg(); - GameMessage *constructGameMessage(); + GameMessage *constructGameMessage() const; void addArgument(const GameMessageArgumentDataType type, GameMessageArgumentType arg); void setGameMessageType(GameMessage::Type type); + virtual size_t getPackedByteCount() const; + protected: Int m_numArgs; Int m_argSize; @@ -106,6 +109,8 @@ class NetAckBothCommandMsg : public NetCommandMsg void setOriginalPlayerID(UnsignedByte originalPlayerID); virtual Int getSortNumber(); + virtual size_t getPackedByteCount() const; + protected: UnsignedShort m_commandID; UnsignedByte m_originalPlayerID; @@ -130,6 +135,8 @@ class NetAckStage1CommandMsg : public NetCommandMsg void setOriginalPlayerID(UnsignedByte originalPlayerID); virtual Int getSortNumber(); + virtual size_t getPackedByteCount() const; + protected: UnsignedShort m_commandID; UnsignedByte m_originalPlayerID; @@ -154,6 +161,8 @@ class NetAckStage2CommandMsg : public NetCommandMsg void setOriginalPlayerID(UnsignedByte originalPlayerID); virtual Int getSortNumber(); + virtual size_t getPackedByteCount() const; + protected: UnsignedShort m_commandID; UnsignedByte m_originalPlayerID; @@ -170,6 +179,8 @@ class NetFrameCommandMsg : public NetCommandMsg void setCommandCount(UnsignedShort commandCount); UnsignedShort getCommandCount(); + virtual size_t getPackedByteCount() const; + protected: UnsignedShort m_commandCount; }; @@ -185,6 +196,8 @@ class NetPlayerLeaveCommandMsg : public NetCommandMsg UnsignedByte getLeavingPlayerID(); void setLeavingPlayerID(UnsignedByte id); + virtual size_t getPackedByteCount() const; + protected: UnsignedByte m_leavingPlayerID; }; @@ -202,6 +215,8 @@ class NetRunAheadMetricsCommandMsg : public NetCommandMsg Int getAverageFps(); void setAverageFps(Int fps); + virtual size_t getPackedByteCount() const; + protected: Real m_averageLatency; Int m_averageFps; @@ -221,6 +236,8 @@ class NetRunAheadCommandMsg : public NetCommandMsg UnsignedByte getFrameRate(); void setFrameRate(UnsignedByte frameRate); + virtual size_t getPackedByteCount() const; + protected: UnsignedShort m_runAhead; UnsignedByte m_frameRate; @@ -237,6 +254,8 @@ class NetDestroyPlayerCommandMsg : public NetCommandMsg UnsignedInt getPlayerIndex(); void setPlayerIndex(UnsignedInt playerIndex); + virtual size_t getPackedByteCount() const; + protected: UnsignedInt m_playerIndex; }; @@ -248,6 +267,8 @@ class NetKeepAliveCommandMsg : public NetCommandMsg public: NetKeepAliveCommandMsg(); //virtual ~NetKeepAliveCommandMsg(); + + virtual size_t getPackedByteCount() const; }; //----------------------------------------------------------------------------- @@ -257,6 +278,8 @@ class NetDisconnectKeepAliveCommandMsg : public NetCommandMsg public: NetDisconnectKeepAliveCommandMsg(); //virtual ~NetDisconnectKeepAliveCommandMsg(); + + virtual size_t getPackedByteCount() const; }; //----------------------------------------------------------------------------- @@ -273,6 +296,8 @@ class NetDisconnectPlayerCommandMsg : public NetCommandMsg UnsignedInt getDisconnectFrame(); void setDisconnectFrame(UnsignedInt frame); + virtual size_t getPackedByteCount() const; + protected: UnsignedByte m_disconnectSlot; UnsignedInt m_disconnectFrame; @@ -285,6 +310,8 @@ class NetPacketRouterQueryCommandMsg : public NetCommandMsg public: NetPacketRouterQueryCommandMsg(); //virtual ~NetPacketRouterQueryCommandMsg(); + + virtual size_t getPackedByteCount() const; }; //----------------------------------------------------------------------------- @@ -294,6 +321,8 @@ class NetPacketRouterAckCommandMsg : public NetCommandMsg public: NetPacketRouterAckCommandMsg(); //virtual ~NetPacketRouterAckCommandMsg(); + + virtual size_t getPackedByteCount() const; }; //----------------------------------------------------------------------------- @@ -307,6 +336,8 @@ class NetDisconnectChatCommandMsg : public NetCommandMsg UnicodeString getText(); void setText(UnicodeString text); + virtual size_t getPackedByteCount() const; + protected: UnicodeString m_text; }; @@ -325,6 +356,8 @@ class NetChatCommandMsg : public NetCommandMsg Int getPlayerMask( void ); void setPlayerMask( Int playerMask ); + virtual size_t getPackedByteCount() const; + protected: UnicodeString m_text; Int m_playerMask; @@ -344,6 +377,8 @@ class NetDisconnectVoteCommandMsg : public NetCommandMsg UnsignedInt getVoteFrame(); void setVoteFrame(UnsignedInt voteFrame); + virtual size_t getPackedByteCount() const; + protected: UnsignedByte m_slot; UnsignedInt m_voteFrame; @@ -359,6 +394,9 @@ class NetProgressCommandMsg: public NetCommandMsg UnsignedByte getPercentage(); void setPercentage( UnsignedByte percent ); + + virtual size_t getPackedByteCount() const; + protected: UnsignedByte m_percent; }; @@ -374,6 +412,8 @@ class NetWrapperCommandMsg : public NetCommandMsg UnsignedByte * getData(); void setData(UnsignedByte *data, UnsignedInt dataLength); + virtual size_t getPackedByteCount() const; + UnsignedInt getChunkNumber(); void setChunkNumber(UnsignedInt chunkNumber); @@ -421,6 +461,8 @@ class NetFileCommandMsg : public NetCommandMsg UnsignedByte * getFileData(); void setFileData(UnsignedByte *data, UnsignedInt dataLength); + virtual size_t getPackedByteCount() const; + protected: AsciiString m_portableFilename; @@ -448,6 +490,8 @@ class NetFileAnnounceCommandMsg : public NetCommandMsg UnsignedByte getPlayerMask(void); void setPlayerMask(UnsignedByte playerMask); + virtual size_t getPackedByteCount() const; + protected: AsciiString m_portableFilename; UnsignedShort m_fileID; @@ -468,6 +512,8 @@ class NetFileProgressCommandMsg : public NetCommandMsg Int getProgress(); void setProgress(Int val); + virtual size_t getPackedByteCount() const; + protected: UnsignedShort m_fileID; Int m_progress; @@ -483,6 +529,8 @@ class NetDisconnectFrameCommandMsg : public NetCommandMsg UnsignedInt getDisconnectFrame(); void setDisconnectFrame(UnsignedInt disconnectFrame); + virtual size_t getPackedByteCount() const; + protected: UnsignedInt m_disconnectFrame; }; @@ -497,6 +545,8 @@ class NetDisconnectScreenOffCommandMsg : public NetCommandMsg UnsignedInt getNewFrame(); void setNewFrame(UnsignedInt newFrame); + virtual size_t getPackedByteCount() const; + protected: UnsignedInt m_newFrame; }; @@ -511,6 +561,28 @@ class NetFrameResendRequestCommandMsg : public NetCommandMsg UnsignedInt getFrameToResend(); void setFrameToResend(UnsignedInt frame); + virtual size_t getPackedByteCount() const; + protected: UnsignedInt m_frameToResend; }; + +class NetLoadCompleteCommandMsg : public NetCommandMsg +{ + MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetLoadCompleteCommandMsg, "NetLoadCompleteCommandMsg") +public: + NetLoadCompleteCommandMsg(); + //virtual ~NetLoadCompleteCommandMsg(); + + virtual size_t getPackedByteCount() const; +}; + +class NetTimeOutGameStartCommandMsg : public NetCommandMsg +{ + MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE(NetTimeOutGameStartCommandMsg, "NetTimeOutGameStartCommandMsg") +public: + NetTimeOutGameStartCommandMsg(); + //virtual ~NetTimeOutGameStartCommandMsg(); + + virtual size_t getPackedByteCount() const; +}; diff --git a/Core/GameEngine/Include/GameNetwork/NetPacket.h b/Core/GameEngine/Include/GameNetwork/NetPacket.h index f117df083ab..d4980a9eef0 100644 --- a/Core/GameEngine/Include/GameNetwork/NetPacket.h +++ b/Core/GameEngine/Include/GameNetwork/NetPacket.h @@ -69,10 +69,11 @@ class NetPacket : public MemoryPoolObject UnsignedInt getAddr(); UnsignedShort getPort(); -protected: static UnsignedInt GetBufferSizeNeededForCommand(NetCommandMsg *msg); static void FillBufferWithCommand(UnsignedByte *buffer, NetCommandRef *msg); +protected: + // These functions return the size of the command without any compression, repetition, etc. // i.e. All of the required fields are taken into account when returning the size. static UnsignedInt GetGameCommandSize(NetCommandMsg *msg); diff --git a/Core/GameEngine/Include/GameNetwork/NetPacketStructs.h b/Core/GameEngine/Include/GameNetwork/NetPacketStructs.h new file mode 100644 index 00000000000..7f3dd418db2 --- /dev/null +++ b/Core/GameEngine/Include/GameNetwork/NetPacketStructs.h @@ -0,0 +1,324 @@ +/* +** 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 . +*/ + +// TheSuperHackers @refactor BobTista 07/10/2025 +// Packed struct definitions for network packet serialization. + +#pragma once + +#include "GameNetwork/NetworkDefs.h" + +// Ensure structs are packed to 1-byte alignment for network protocol compatibility +#pragma pack(push, 1) + +//////////////////////////////////////////////////////////////////////////////// +// Network packet field type definitions +//////////////////////////////////////////////////////////////////////////////// + +typedef UnsignedByte NetPacketFieldType; + +namespace NetPacketFieldTypes { + constexpr const NetPacketFieldType CommandType = 'T'; + constexpr const NetPacketFieldType Relay = 'R'; + constexpr const NetPacketFieldType Frame = 'F'; + constexpr const NetPacketFieldType PlayerId = 'P'; + constexpr const NetPacketFieldType CommandId = 'C'; + constexpr const NetPacketFieldType Data = 'D'; +} + +//////////////////////////////////////////////////////////////////////////////// +// Common packet field structures +//////////////////////////////////////////////////////////////////////////////// + +struct NetPacketCommandTypeField { + NetPacketCommandTypeField() : fieldType(NetPacketFieldTypes::CommandType) {} + char fieldType; + UnsignedByte commandType; +}; + +struct NetPacketRelayField { + NetPacketRelayField() : fieldType(NetPacketFieldTypes::Relay) {} + char fieldType; + UnsignedByte relay; +}; + +struct NetPacketFrameField { + NetPacketFrameField() : fieldType(NetPacketFieldTypes::Frame) {} + char fieldType; + UnsignedInt frame; +}; + +struct NetPacketPlayerIdField { + NetPacketPlayerIdField() : fieldType(NetPacketFieldTypes::PlayerId) {} + char fieldType; + UnsignedByte playerId; +}; + +struct NetPacketCommandIdField { + NetPacketCommandIdField() : fieldType(NetPacketFieldTypes::CommandId) {} + char fieldType; + UnsignedShort commandId; +}; + +struct NetPacketDataField { + NetPacketDataField() : fieldType(NetPacketFieldTypes::Data) {} + char fieldType; +}; + +//////////////////////////////////////////////////////////////////////////////// +// Packed Network structures +//////////////////////////////////////////////////////////////////////////////// + +struct NetPacketAckCommand { + NetPacketCommandTypeField commandType; + NetPacketPlayerIdField playerId; + NetPacketDataField dataHeader; + UnsignedShort commandId; // Command ID being acknowledged + UnsignedByte originalPlayerId; // Original player who sent the command +}; + +struct NetPacketFrameCommand { + NetPacketCommandTypeField commandType; + NetPacketFrameField frame; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + UnsignedShort commandCount; +}; + +struct NetPacketPlayerLeaveCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketFrameField frame; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + UnsignedByte leavingPlayerId; +}; + +struct NetPacketRunAheadMetricsCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + Real averageLatency; + UnsignedShort averageFps; +}; + +struct NetPacketRunAheadCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketFrameField frame; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + UnsignedShort runAhead; + UnsignedByte frameRate; +}; + +struct NetPacketDestroyPlayerCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketFrameField frame; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + UnsignedInt playerIndex; +}; + +struct NetPacketKeepAliveCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketDataField dataHeader; +}; + +struct NetPacketDisconnectKeepAliveCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketDataField dataHeader; +}; + +struct NetPacketDisconnectPlayerCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + UnsignedByte slot; + UnsignedInt disconnectFrame; +}; + +struct NetPacketRouterQueryCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketDataField dataHeader; +}; + +struct NetPacketRouterAckCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketDataField dataHeader; +}; + +struct NetPacketDisconnectVoteCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + UnsignedByte slot; + UnsignedInt voteFrame; +}; + +struct NetPacketChatCommand { + NetPacketCommandTypeField commandType; + NetPacketFrameField frame; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + UnsignedByte textLength; + // Variable fields: WideChar text[textLength] + Int playerMask + + enum { MaxTextLen = 255 }; + static Int getUsableTextLength(const UnicodeString& text) { return min(text.getLength(), (Int)MaxTextLen); } +}; + +struct NetPacketDisconnectChatCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketDataField dataHeader; + UnsignedByte textLength; + // Variable fields: WideChar text[textLength] + + enum { MaxTextLen = 255 }; + static Int getUsableTextLength(const UnicodeString& text) { return min(text.getLength(), (Int)MaxTextLen); } +}; + +struct NetPacketGameCommand { + NetPacketCommandTypeField commandType; + NetPacketFrameField frame; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + // Variable fields: GameMessage type + argument types + argument data +}; + +struct NetPacketWrapperCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + UnsignedShort wrappedCommandId; + UnsignedInt chunkNumber; + UnsignedInt numChunks; + UnsignedInt totalDataLength; + UnsignedInt dataLength; + UnsignedInt dataOffset; +}; + +struct NetPacketFileCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + // Variable fields: null-terminated filename + UnsignedInt fileDataLength + file data +}; + +struct NetPacketFileAnnounceCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + // Variable fields: null-terminated filename + UnsignedShort fileID + UnsignedByte playerMask +}; + +struct NetPacketFileProgressCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + UnsignedShort fileId; + Int progress; +}; + +struct NetPacketProgressCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketDataField dataHeader; + UnsignedByte percentage; +}; + +struct NetPacketLoadCompleteCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; +}; + +struct NetPacketTimeOutGameStartCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; +}; + +struct NetPacketDisconnectFrameCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + UnsignedInt disconnectFrame; +}; + +struct NetPacketDisconnectScreenOffCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + UnsignedInt newFrame; +}; + +struct NetPacketFrameResendRequestCommand { + NetPacketCommandTypeField commandType; + NetPacketRelayField relay; + NetPacketPlayerIdField playerId; + NetPacketCommandIdField commandId; + NetPacketDataField dataHeader; + UnsignedInt frameToResend; +}; + +// Restore normal struct packing +#pragma pack(pop) diff --git a/Core/GameEngine/Include/GameNetwork/NetworkDefs.h b/Core/GameEngine/Include/GameNetwork/NetworkDefs.h index 171f33df3d1..450bee52104 100644 --- a/Core/GameEngine/Include/GameNetwork/NetworkDefs.h +++ b/Core/GameEngine/Include/GameNetwork/NetworkDefs.h @@ -48,18 +48,35 @@ enum ConnectionNumbers CPP_11(: Int) NUM_CONNECTIONS }; -static const Int MAX_SLOTS = MAX_PLAYER+1; +static constexpr const Int MAX_SLOTS = MAX_PLAYER+1; +// TheSuperHackers @info As we are not detecting for network fragmentation and dynamically adjusting payload sizes, we set an 1100 bytes UDP payload as a safe upper limit for various networks +// We chose 1100 bytes as when taking mobile networks into account, maximum transmission unit sizes can vary from 1340 - 1500 bytes +// and when the packet headers for PPPOE, IPV6 and other virtual network encapsulation are considered, we need a lower safe UDP payload to prevent fragmentation. +static constexpr const Int MAX_UDP_PAYLOAD_SIZE = 1100; // UDP (8 bytes) + IP header (28 bytes) = 36 bytes total. We want a total packet size of 512, so 512 - 36 = 476 -static const Int MAX_PACKET_SIZE = 476; +static constexpr const Int RETAIL_GAME_PACKET_SIZE = 476; + +// TheSuperHackers @info The legacy lanapi cannot use a larger packet size without breaking the gameinfo command +static constexpr const Int MAX_LANAPI_PACKET_SIZE = RETAIL_GAME_PACKET_SIZE; + +// TheSuperHackers @bugfix Mauller 08/02/2026 Allow larger ethernet UDP payload to be used for game messages, this fixes connection issues and eliminates disconnection bugs +#if RETAIL_COMPATIBLE_NETWORKING +static constexpr const Int MAX_PACKET_SIZE = RETAIL_GAME_PACKET_SIZE; +static constexpr const Int MAX_NETWORK_MESSAGE_LEN = 1024; +#else +static constexpr const Int MAX_PACKET_SIZE = MAX_UDP_PAYLOAD_SIZE - sizeof(TransportMessageHeader); +static constexpr const Int MAX_NETWORK_MESSAGE_LEN = MAX_UDP_PAYLOAD_SIZE; +#endif + +// TheSuperHackers @bugfix Mauller 08/02/2026 Double send and receive buffer sizes to alleviate the occurance of disconnection issues in retail and non retail code. +static constexpr const Int MAX_MESSAGES = 256; /** * Command packet - contains frame #, total # of commands, and each command. This is what gets sent * to each player every frame */ -#define MAX_MESSAGE_LEN 1024 -#define MAX_MESSAGES 128 -static const Int numCommandsPerCommandPacket = (MAX_MESSAGE_LEN - sizeof(UnsignedInt) - sizeof(UnsignedShort))/sizeof(GameMessage); +static const Int numCommandsPerCommandPacket = (MAX_NETWORK_MESSAGE_LEN - sizeof(UnsignedInt) - sizeof(UnsignedShort))/sizeof(GameMessage); #pragma pack(push, 1) struct CommandPacket { @@ -89,7 +106,14 @@ struct TransportMessageHeader struct TransportMessage { TransportMessageHeader header; - UnsignedByte data[MAX_MESSAGE_LEN]; +#if RETAIL_COMPATIBLE_NETWORKING + // TheSuperHackers @info This value is not the correct one that should be used here, it should have been max packet size + // The non retail max network message len takes the extra bytes of the network message header into account when handling UDP payload data + // In retail this only works since no data larger than the retail game packet size is put into a network message + UnsignedByte data[MAX_NETWORK_MESSAGE_LEN]; +#else + UnsignedByte data[MAX_PACKET_SIZE]; +#endif Int length; UnsignedInt addr; UnsignedShort port; @@ -136,7 +160,7 @@ enum NetCommandType CPP_11(: Int) { NETCOMMANDTYPE_PROGRESS, NETCOMMANDTYPE_LOADCOMPLETE, NETCOMMANDTYPE_TIMEOUTSTART, - NETCOMMANDTYPE_WRAPPER, // A wrapper command that holds a command thats too big to fit in a single packet. + NETCOMMANDTYPE_WRAPPER, // A wrapper command that holds a command that's too big to fit in a single packet. NETCOMMANDTYPE_FILE, NETCOMMANDTYPE_FILEANNOUNCE, NETCOMMANDTYPE_FILEPROGRESS, @@ -196,7 +220,7 @@ static const UnsignedShort GENERALS_MAGIC_NUMBER = 0xF00D; //static const Int NETWORK_DISCONNECT_TIME = 5000; // The number of miliseconds between when a player's last disconnect keep alive command -// was recieved and when they are considered disconnected from the game. +// was received and when they are considered disconnected from the game. //static const Int NETWORK_PLAYER_TIMEOUT_TIME = 60000; // The base port number used for the transport socket. A players slot number is added to this diff --git a/Core/GameEngine/Include/GameNetwork/NetworkInterface.h b/Core/GameEngine/Include/GameNetwork/NetworkInterface.h index c0bf655eb64..3a577864f53 100644 --- a/Core/GameEngine/Include/GameNetwork/NetworkInterface.h +++ b/Core/GameEngine/Include/GameNetwork/NetworkInterface.h @@ -125,7 +125,7 @@ class NetworkInterface : public SubsystemInterface // For disconnect blame assignment virtual UnsignedInt getPingFrame() = 0; virtual Int getPingsSent() = 0; - virtual Int getPingsRecieved() = 0; + virtual Int getPingsReceived() = 0; }; diff --git a/Core/GameEngine/Include/GameNetwork/WOLBrowser/FEBDispatch.h b/Core/GameEngine/Include/GameNetwork/WOLBrowser/FEBDispatch.h index e87de2eb6c2..e7e0eb1135e 100644 --- a/Core/GameEngine/Include/GameNetwork/WOLBrowser/FEBDispatch.h +++ b/Core/GameEngine/Include/GameNetwork/WOLBrowser/FEBDispatch.h @@ -29,6 +29,11 @@ #pragma once +#if defined __MINGW32__ +#include "Utility/atl_compat.h" +#include "Utility/comsupp_compat.h" +#endif + #include extern CComModule _Module; #include @@ -51,15 +56,15 @@ public C FEBDispatch() { - m_ptinfo = NULL; - m_dispatch = NULL; + m_ptinfo = nullptr; + m_dispatch = nullptr; ITypeLib *ptlib; HRESULT hr; HRESULT TypeLibraryLoadResult; char filename[256]; - GetModuleFileName(NULL, filename, sizeof(filename)); + GetModuleFileName(nullptr, filename, sizeof(filename)); _bstr_t bstr(filename); TypeLibraryLoadResult = LoadTypeLib(bstr, &ptlib); @@ -81,7 +86,7 @@ public C } } - if ( m_dispatch == NULL ) + if ( m_dispatch == nullptr ) { DEBUG_LOG(("Error creating Dispatch for Web interface")); } diff --git a/Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp b/Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp index eda40c71c7e..367f894caef 100644 --- a/Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp +++ b/Core/GameEngine/Source/Common/Audio/AudioEventRTS.cpp @@ -68,7 +68,7 @@ AudioEventRTS::AudioEventRTS() m_shouldFade(false), m_isLogicalAudio(false), m_filenameToLoad(AsciiString::TheEmptyString), - m_eventInfo(NULL), + m_eventInfo(nullptr), m_playingHandle(0), m_killThisHandle(0), m_pitchShift(1.0), @@ -78,7 +78,7 @@ AudioEventRTS::AudioEventRTS() m_allCount(0), m_playerIndex(-1), m_delay(0.0f), - m_uninterruptable(FALSE) + m_uninterruptible(FALSE) { m_attackName.clear(); m_decayName.clear(); @@ -95,7 +95,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName ) m_shouldFade(false), m_isLogicalAudio(false), m_filenameToLoad(AsciiString::TheEmptyString), - m_eventInfo(NULL), + m_eventInfo(nullptr), m_playingHandle(0), m_killThisHandle(0), m_pitchShift(1.0), @@ -105,7 +105,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName ) m_allCount(0), m_playerIndex(-1), m_delay(0.0f), - m_uninterruptable(FALSE) + m_uninterruptible(FALSE) { m_attackName.clear(); m_decayName.clear(); @@ -123,7 +123,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName, ObjectID ownerID ) m_shouldFade(false), m_isLogicalAudio(false), m_filenameToLoad(AsciiString::TheEmptyString), - m_eventInfo(NULL), + m_eventInfo(nullptr), m_playingHandle(0), m_killThisHandle(0), m_pitchShift(1.0), @@ -133,7 +133,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName, ObjectID ownerID ) m_allCount(0), m_playerIndex(-1), m_delay(0.0f), - m_uninterruptable(FALSE) + m_uninterruptible(FALSE) { m_attackName.clear(); m_decayName.clear(); @@ -159,7 +159,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName, DrawableID drawableI m_shouldFade(false), m_isLogicalAudio(false), m_filenameToLoad(AsciiString::TheEmptyString), - m_eventInfo(NULL), + m_eventInfo(nullptr), m_playingHandle(0), m_killThisHandle(0), m_pitchShift(1.0), @@ -169,7 +169,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName, DrawableID drawableI m_allCount(0), m_playerIndex(-1), m_delay(0.0f), - m_uninterruptable(FALSE) + m_uninterruptible(FALSE) { m_attackName.clear(); m_decayName.clear(); @@ -194,7 +194,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName, const Coord3D *posit m_shouldFade(false), m_isLogicalAudio(false), m_filenameToLoad(AsciiString::TheEmptyString), - m_eventInfo(NULL), + m_eventInfo(nullptr), m_playingHandle(0), m_killThisHandle(0), m_pitchShift(1.0), @@ -204,7 +204,7 @@ AudioEventRTS::AudioEventRTS( const AsciiString& eventName, const Coord3D *posit m_allCount(0), m_playerIndex(-1), m_delay(0.0f), - m_uninterruptable(FALSE) + m_uninterruptible(FALSE) { m_positionOfAudio.set( positionOfAudio ); m_attackName.clear(); @@ -235,7 +235,7 @@ AudioEventRTS::AudioEventRTS( const AudioEventRTS& right ) m_attackName = right.m_attackName; m_decayName = right.m_decayName; m_portionToPlayNext = right.m_portionToPlayNext; - m_uninterruptable = right.m_uninterruptable; + m_uninterruptible = right.m_uninterruptible; if( m_ownerType == OT_Positional || m_ownerType == OT_Dead ) { @@ -276,7 +276,7 @@ AudioEventRTS& AudioEventRTS::operator=( const AudioEventRTS& right ) m_attackName = right.m_attackName; m_decayName = right.m_decayName; m_portionToPlayNext = right.m_portionToPlayNext; - m_uninterruptable = right.m_uninterruptable; + m_uninterruptible = right.m_uninterruptible; if( m_ownerType == OT_Positional || m_ownerType == OT_Dead ) { @@ -302,9 +302,9 @@ AudioEventRTS::~AudioEventRTS() //------------------------------------------------------------------------------------------------- void AudioEventRTS::setEventName( AsciiString name ) { - if ((name != m_eventName) && m_eventInfo != NULL) { + if ((name != m_eventName) && m_eventInfo != nullptr) { // Clear out the audio event info, cause its not valid for the new event. - m_eventInfo = NULL; + m_eventInfo = nullptr; } m_eventName = name; @@ -340,7 +340,7 @@ void AudioEventRTS::generateFilename( void ) { if (m_isLogicalAudio) { - which = GameLogicRandomValue(0, m_eventInfo->m_sounds.size() - 1); + which = GameLogicRandomValueUnchanged(0, m_eventInfo->m_sounds.size() - 1); } else { @@ -388,7 +388,7 @@ void AudioEventRTS::generatePlayInfo( void ) // needs to be logic because it needs to be the same on all systems. Int attackToPlay; if (m_isLogicalAudio) { - attackToPlay = GameLogicRandomValue(0, attackSize - 1); + attackToPlay = GameLogicRandomValueUnchanged(0, attackSize - 1); } else { attackToPlay = GameAudioRandomValue(0, attackSize - 1); } @@ -406,7 +406,7 @@ void AudioEventRTS::generatePlayInfo( void ) // needs to be logic because it needs to be the same on all systems. Int decayToPlay; if (m_isLogicalAudio) { - decayToPlay = GameLogicRandomValue(0, decaySize - 1); + decayToPlay = GameLogicRandomValueUnchanged(0, decaySize - 1); } else { decayToPlay = GameAudioRandomValue(0, decaySize - 1); } @@ -526,7 +526,7 @@ const AudioEventInfo *AudioEventRTS::getAudioEventInfo( void ) const if (m_eventInfo->m_audioName == m_eventName) { return m_eventInfo; } else { - m_eventInfo = NULL; + m_eventInfo = nullptr; } } @@ -568,7 +568,7 @@ const Coord3D* AudioEventRTS::getPosition( void ) return &m_positionOfAudio; } - return NULL; + return nullptr; } //------------------------------------------------------------------------------------------------- @@ -724,14 +724,13 @@ void AudioEventRTS::setVolume( Real vol ) //------------------------------------------------------------------------------------------------- const Coord3D *AudioEventRTS::getCurrentPosition( void ) { - if (m_ownerType == OT_Positional) + switch (m_ownerType) { + case OT_Positional: return &m_positionOfAudio; - } - else if (m_ownerType == OT_Object) - { - Object *obj = TheGameLogic->findObjectByID(m_objectID); - if (obj) + + case OT_Object: + if (Object *obj = TheGameLogic->findObjectByID(m_objectID)) { m_positionOfAudio.set( obj->getPosition() ); } @@ -740,11 +739,9 @@ const Coord3D *AudioEventRTS::getCurrentPosition( void ) m_ownerType = OT_Dead; } return &m_positionOfAudio; - } - else if (m_ownerType == OT_Drawable) - { - Drawable *draw = TheGameClient->findDrawableByID(m_drawableID); - if( draw ) + + case OT_Drawable: + if (Drawable *draw = TheGameClient->findDrawableByID(m_drawableID)) { m_positionOfAudio.set( draw->getPosition() ); } @@ -753,13 +750,12 @@ const Coord3D *AudioEventRTS::getCurrentPosition( void ) m_ownerType = OT_Dead; } return &m_positionOfAudio; - } - else if( m_ownerType == OT_Dead ) - { + + case OT_Dead: return &m_positionOfAudio; } - return NULL; + return nullptr; } //------------------------------------------------------------------------------------------------- diff --git a/Core/GameEngine/Source/Common/Audio/GameAudio.cpp b/Core/GameEngine/Source/Common/Audio/GameAudio.cpp index 9917266a64a..ea9a1956eed 100644 --- a/Core/GameEngine/Source/Common/Audio/GameAudio.cpp +++ b/Core/GameEngine/Source/Common/Audio/GameAudio.cpp @@ -80,7 +80,7 @@ static const char* TheSpeakerTypes[] = "4 Speaker", "5.1 Surround", "7.1 Surround", - NULL + nullptr }; static const Int TheSpeakerTypesCount = sizeof(TheSpeakerTypes) / sizeof(TheSpeakerTypes[0]); @@ -90,55 +90,59 @@ static void parseSpeakerType( INI *ini, void *instance, void *store, const void // Field Parse table for Audio Settings /////////////////////////////////////////////////////////// static const FieldParse audioSettingsFieldParseTable[] = { - { "AudioRoot", INI::parseAsciiString, NULL, offsetof( AudioSettings, m_audioRoot) }, - { "SoundsFolder", INI::parseAsciiString, NULL, offsetof( AudioSettings, m_soundsFolder) }, - { "MusicFolder", INI::parseAsciiString, NULL, offsetof( AudioSettings, m_musicFolder) }, - { "StreamingFolder", INI::parseAsciiString, NULL, offsetof( AudioSettings, m_streamingFolder) }, - { "SoundsExtension", INI::parseAsciiString, NULL, offsetof( AudioSettings, m_soundsExtension) }, - - { "UseDigital", INI::parseBool, NULL, offsetof( AudioSettings, m_useDigital) }, - { "UseMidi", INI::parseBool, NULL, offsetof( AudioSettings, m_useMidi) }, - { "OutputRate", INI::parseInt, NULL, offsetof( AudioSettings, m_outputRate) }, - { "OutputBits", INI::parseInt, NULL, offsetof( AudioSettings, m_outputBits) }, - { "OutputChannels", INI::parseInt, NULL, offsetof( AudioSettings, m_outputChannels) }, - { "SampleCount2D", INI::parseInt, NULL, offsetof( AudioSettings, m_sampleCount2D) }, - { "SampleCount3D", INI::parseInt, NULL, offsetof( AudioSettings, m_sampleCount3D) }, - { "StreamCount", INI::parseInt, NULL, offsetof( AudioSettings, m_streamCount) }, - - { "Preferred3DHW1", INI::parseAsciiString, NULL, offsetof( AudioSettings, m_preferred3DProvider[0]) }, - { "Preferred3DHW2", INI::parseAsciiString, NULL, offsetof( AudioSettings, m_preferred3DProvider[1]) }, - { "Preferred3DHW3", INI::parseAsciiString, NULL, offsetof( AudioSettings, m_preferred3DProvider[2]) }, - { "Preferred3DHW4", INI::parseAsciiString, NULL, offsetof( AudioSettings, m_preferred3DProvider[3]) }, - - { "Preferred3DSW", INI::parseAsciiString, NULL, offsetof( AudioSettings, m_preferred3DProvider[4]) }, - - { "Default2DSpeakerType", parseSpeakerType, NULL, offsetof( AudioSettings, m_defaultSpeakerType2D) }, - { "Default3DSpeakerType", parseSpeakerType, NULL, offsetof( AudioSettings, m_defaultSpeakerType3D) }, - - { "MinSampleVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_minVolume) }, - { "GlobalMinRange", INI::parseInt, NULL, offsetof( AudioSettings, m_globalMinRange) }, - { "GlobalMaxRange", INI::parseInt, NULL, offsetof( AudioSettings, m_globalMaxRange) }, - { "TimeBetweenDrawableSounds", INI::parseDurationUnsignedInt, NULL, offsetof( AudioSettings, m_drawableAmbientFrames) }, - { "TimeToFadeAudio", INI::parseDurationUnsignedInt, NULL, offsetof( AudioSettings, m_fadeAudioFrames) }, - { "AudioFootprintInBytes",INI::parseUnsignedInt, NULL, offsetof( AudioSettings, m_maxCacheSize) }, - { "Relative2DVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_relative2DVolume ) }, - { "DefaultSoundVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_defaultSoundVolume) }, - { "Default3DSoundVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_default3DSoundVolume) }, - { "DefaultSpeechVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_defaultSpeechVolume) }, - { "DefaultMusicVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_defaultMusicVolume) }, - { "DefaultMoneyTransactionVolume", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_defaultMoneyTransactionVolume) }, - { "MicrophoneDesiredHeightAboveTerrain", INI::parseReal, NULL, offsetof( AudioSettings, m_microphoneDesiredHeightAboveTerrain ) }, - { "MicrophoneMaxPercentageBetweenGroundAndCamera", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_microphoneMaxPercentageBetweenGroundAndCamera ) }, - { "ZoomMinDistance", INI::parseReal, NULL, offsetof( AudioSettings, m_zoomMinDistance ) }, - { "ZoomMaxDistance", INI::parseReal, NULL, offsetof( AudioSettings, m_zoomMaxDistance ) }, - { "ZoomSoundVolumePercentageAmount", INI::parsePercentToReal, NULL, offsetof( AudioSettings, m_zoomSoundVolumePercentageAmount ) }, - - { NULL, NULL, NULL, NULL } + { "AudioRoot", INI::parseAsciiString, nullptr, offsetof( AudioSettings, m_audioRoot) }, + { "SoundsFolder", INI::parseAsciiString, nullptr, offsetof( AudioSettings, m_soundsFolder) }, + { "MusicFolder", INI::parseAsciiString, nullptr, offsetof( AudioSettings, m_musicFolder) }, + { "StreamingFolder", INI::parseAsciiString, nullptr, offsetof( AudioSettings, m_streamingFolder) }, + { "SoundsExtension", INI::parseAsciiString, nullptr, offsetof( AudioSettings, m_soundsExtension) }, + + { "UseDigital", INI::parseBool, nullptr, offsetof( AudioSettings, m_useDigital) }, + { "UseMidi", INI::parseBool, nullptr, offsetof( AudioSettings, m_useMidi) }, + { "OutputRate", INI::parseInt, nullptr, offsetof( AudioSettings, m_outputRate) }, + { "OutputBits", INI::parseInt, nullptr, offsetof( AudioSettings, m_outputBits) }, + { "OutputChannels", INI::parseInt, nullptr, offsetof( AudioSettings, m_outputChannels) }, + { "SampleCount2D", INI::parseInt, nullptr, offsetof( AudioSettings, m_sampleCount2D) }, + { "SampleCount3D", INI::parseInt, nullptr, offsetof( AudioSettings, m_sampleCount3D) }, + { "StreamCount", INI::parseInt, nullptr, offsetof( AudioSettings, m_streamCount) }, + + { "Preferred3DHW1", INI::parseAsciiString, nullptr, offsetof( AudioSettings, m_preferred3DProvider[0]) }, + { "Preferred3DHW2", INI::parseAsciiString, nullptr, offsetof( AudioSettings, m_preferred3DProvider[1]) }, + { "Preferred3DHW3", INI::parseAsciiString, nullptr, offsetof( AudioSettings, m_preferred3DProvider[2]) }, + { "Preferred3DHW4", INI::parseAsciiString, nullptr, offsetof( AudioSettings, m_preferred3DProvider[3]) }, + + { "Preferred3DSW", INI::parseAsciiString, nullptr, offsetof( AudioSettings, m_preferred3DProvider[4]) }, + + { "Default2DSpeakerType", parseSpeakerType, nullptr, offsetof( AudioSettings, m_defaultSpeakerType2D) }, + { "Default3DSpeakerType", parseSpeakerType, nullptr, offsetof( AudioSettings, m_defaultSpeakerType3D) }, + + { "MinSampleVolume", INI::parsePercentToReal, nullptr, offsetof( AudioSettings, m_minVolume) }, + { "GlobalMinRange", INI::parseInt, nullptr, offsetof( AudioSettings, m_globalMinRange) }, + { "GlobalMaxRange", INI::parseInt, nullptr, offsetof( AudioSettings, m_globalMaxRange) }, + { "TimeBetweenDrawableSounds", INI::parseDurationUnsignedInt, nullptr, offsetof( AudioSettings, m_drawableAmbientFrames) }, + { "TimeToFadeAudio", INI::parseDurationUnsignedInt, nullptr, offsetof( AudioSettings, m_fadeAudioFrames) }, + { "AudioFootprintInBytes",INI::parseUnsignedInt, nullptr, offsetof( AudioSettings, m_maxCacheSize) }, + { "Relative2DVolume", INI::parsePercentToReal, nullptr, offsetof( AudioSettings, m_relative2DVolume ) }, + { "DefaultSoundVolume", INI::parsePercentToReal, nullptr, offsetof( AudioSettings, m_defaultSoundVolume) }, + { "Default3DSoundVolume", INI::parsePercentToReal, nullptr, offsetof( AudioSettings, m_default3DSoundVolume) }, + { "DefaultSpeechVolume", INI::parsePercentToReal, nullptr, offsetof( AudioSettings, m_defaultSpeechVolume) }, + { "DefaultMusicVolume", INI::parsePercentToReal, nullptr, offsetof( AudioSettings, m_defaultMusicVolume) }, + { "DefaultMoneyTransactionVolume", INI::parsePercentToReal, nullptr, offsetof( AudioSettings, m_defaultMoneyTransactionVolume) }, + { "MicrophoneDesiredHeightAboveTerrain", INI::parseReal, nullptr, offsetof( AudioSettings, m_microphoneDesiredHeightAboveTerrain ) }, + { "MicrophoneMaxPercentageBetweenGroundAndCamera", INI::parsePercentToReal, nullptr, offsetof( AudioSettings, m_microphoneMaxPercentageBetweenGroundAndCamera ) }, + { "ZoomMinDistance", INI::parseReal, nullptr, offsetof( AudioSettings, m_zoomMinDistance ) }, + { "ZoomMaxDistance", INI::parseReal, nullptr, offsetof( AudioSettings, m_zoomMaxDistance ) }, + { "ZoomSoundVolumePercentageAmount", INI::parsePercentToReal, nullptr, offsetof( AudioSettings, m_zoomSoundVolumePercentageAmount ) }, + + { nullptr, nullptr, nullptr, 0 } }; // Singleton TheAudio ///////////////////////////////////////////////////////////////////////////// -AudioManager *TheAudio = NULL; +AudioManager *TheAudio = nullptr; +const char *const AudioManager::MuteAudioReasonNames[] = +{ + "MuteAudioReason_WindowFocus", +}; // AudioManager Device Independent functions ////////////////////////////////////////////////////// AudioManager::AudioManager() : @@ -146,12 +150,13 @@ AudioManager::AudioManager() : m_sound3DOn(TRUE), m_musicOn(TRUE), m_speechOn(TRUE), - m_music(NULL), - m_sound(NULL), + m_music(nullptr), + m_sound(nullptr), m_surroundSpeakers(FALSE), - m_hardwareAccel(FALSE), - m_musicPlayingFromCD(FALSE) + m_hardwareAccel(FALSE) { + static_assert(ARRAY_SIZE(AudioManager::MuteAudioReasonNames) == MuteAudioReason_Count, "Incorrect array size"); + m_adjustedVolumes.clear(); m_audioRequests.clear(); m_listenerPosition.zero(); @@ -170,7 +175,8 @@ AudioManager::AudioManager() : m_audioSettings = NEW AudioSettings; m_miscAudio = NEW MiscAudio; m_silentAudioEvent = NEW AudioEventRTS; - m_savedValues = NULL; + m_savedValues = nullptr; + m_muteReasonBits = 0; m_disallowSpeech = FALSE; } @@ -186,19 +192,19 @@ AudioManager::~AudioManager() m_allAudioEventInfo.clear(); delete m_silentAudioEvent; - m_silentAudioEvent = NULL; + m_silentAudioEvent = nullptr; delete m_music; - m_music = NULL; + m_music = nullptr; delete m_sound; - m_sound = NULL; + m_sound = nullptr; delete m_miscAudio; - m_miscAudio = NULL; + m_miscAudio = nullptr; delete m_audioSettings; - m_audioSettings = NULL; + m_audioSettings = nullptr; delete [] m_savedValues; } @@ -207,51 +213,22 @@ AudioManager::~AudioManager() void AudioManager::init() { INI ini; - ini.loadFileDirectory( "Data\\INI\\AudioSettings", INI_LOAD_OVERWRITE, NULL); + ini.loadFileDirectory( "Data\\INI\\AudioSettings", INI_LOAD_OVERWRITE, nullptr); - ini.loadFileDirectory( "Data\\INI\\Default\\Music", INI_LOAD_OVERWRITE, NULL ); - ini.loadFileDirectory( "Data\\INI\\Music", INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Default\\Music", INI_LOAD_OVERWRITE, nullptr ); + ini.loadFileDirectory( "Data\\INI\\Music", INI_LOAD_OVERWRITE, nullptr ); - ini.loadFileDirectory( "Data\\INI\\Default\\SoundEffects", INI_LOAD_OVERWRITE, NULL ); - ini.loadFileDirectory( "Data\\INI\\SoundEffects", INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Default\\SoundEffects", INI_LOAD_OVERWRITE, nullptr ); + ini.loadFileDirectory( "Data\\INI\\SoundEffects", INI_LOAD_OVERWRITE, nullptr ); - ini.loadFileDirectory( "Data\\INI\\Default\\Speech", INI_LOAD_OVERWRITE, NULL ); - ini.loadFileDirectory( "Data\\INI\\Speech", INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Default\\Speech", INI_LOAD_OVERWRITE, nullptr ); + ini.loadFileDirectory( "Data\\INI\\Speech", INI_LOAD_OVERWRITE, nullptr ); - ini.loadFileDirectory( "Data\\INI\\Default\\Voice", INI_LOAD_OVERWRITE, NULL ); - ini.loadFileDirectory( "Data\\INI\\Voice", INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Default\\Voice", INI_LOAD_OVERWRITE, nullptr ); + ini.loadFileDirectory( "Data\\INI\\Voice", INI_LOAD_OVERWRITE, nullptr ); // 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. - if (!TheGlobalData->m_headless && !isMusicAlreadyLoaded()) - { - m_musicPlayingFromCD = TRUE; - while (TRUE) - { - // @todo Unload any files from CD first. - jkmcd - - TheFileSystem->loadMusicFilesFromCD(); - if (isMusicAlreadyLoaded()) - { - break; - } - // We loop infinitely on the splash screen if we don't allow breaking out of this loop. -//#if !defined( RTS_DEBUG ) - else - { - // Display the warning. - - if (OSDisplayWarningBox("GUI:InsertCDPrompt", "GUI:InsertCDMessage", OSDBT_OK | OSDBT_CANCEL, OSDOF_SYSTEMMODAL | OSDOF_EXCLAMATIONICON) == OSDBT_CANCEL) { - //TheGameEngine->setQuitting(TRUE); // Can't do this to WorldBuilder - break; - } - } -//#endif - } - } + ini.loadFileDirectory( "Data\\INI\\MiscAudio", INI_LOAD_OVERWRITE, nullptr); m_music = NEW MusicManager; m_sound = NEW SoundManager; @@ -419,7 +396,12 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd) } } - switch (eventToAdd->getAudioEventInfo()->m_soundType) + const AudioType soundType = eventToAdd->getAudioEventInfo()->m_soundType; + + // Check if audio type is on + // TheSuperHackers @info Zero audio volume is not a fail condition, because music, speech and sounds + // still need to be in flight in case the user raises the volume on runtime after the audio was already triggered. + switch (soundType) { case AT_Music: if (!isOn(AudioAffect_Music)) @@ -430,21 +412,33 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd) return AHSV_NoSound; break; case AT_Streaming: + // if we're currently playing uninterruptable speech, then disallow the addition of this sample + if (getDisallowSpeech()) + return AHSV_NoSound; if (!isOn(AudioAffect_Speech)) return AHSV_NoSound; break; } - // if we're currently playing uninterruptable speech, then disallow the addition of this sample - if (getDisallowSpeech() && eventToAdd->getAudioEventInfo()->m_soundType == AT_Streaming) { - return AHSV_NoSound; - } + // TheSuperHackers @info Scripted audio events are logical, i.e. synchronized across clients. + // In retail mode this early return cannot be taken for such audio events as it skips code that changes the logical game seed values. + // In non-retail mode logical audio events are decoupled from the CRC computation, so this early return is allowed. +#if RETAIL_COMPATIBLE_CRC + const Bool logicalAudio = eventToAdd->getIsLogicalAudio(); +#else + const Bool logicalAudio = FALSE; +#endif + const Bool notForLocal = !eventToAdd->getUninterruptible() && !shouldPlayLocally(eventToAdd); + if (!logicalAudio && notForLocal) + { + return AHSV_NotForLocal; + } AudioEventRTS *audioEvent = MSGNEW("AudioEventRTS") AudioEventRTS(*eventToAdd); // poolify audioEvent->setPlayingHandle( allocateNewHandle() ); audioEvent->generateFilename(); // which file are we actually going to play? - ((AudioEventRTS*)eventToAdd)->setPlayingAudioIndex( audioEvent->getPlayingAudioIndex() ); + eventToAdd->setPlayingAudioIndex( audioEvent->getPlayingAudioIndex() ); audioEvent->generatePlayInfo(); // generate pitch shift and volume shift now as well std::list >::iterator it; @@ -455,12 +449,13 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd) } } - if (!audioEvent->getUninterruptable()) { - if (!shouldPlayLocally(audioEvent)) { - releaseAudioEventRTS(audioEvent); - return AHSV_NotForLocal; - } +#if RETAIL_COMPATIBLE_CRC + if (notForLocal) + { + releaseAudioEventRTS(audioEvent); + return AHSV_NotForLocal; } +#endif // cull muted audio if (audioEvent->getVolume() < m_audioSettings->m_minVolume) { @@ -471,8 +466,7 @@ AudioHandle AudioManager::addAudioEvent(const AudioEventRTS *eventToAdd) return AHSV_Muted; } - AudioType type = eventToAdd->getAudioEventInfo()->m_soundType; - if (type == AT_Music) + if (soundType == AT_Music) { m_music->addAudioEvent(audioEvent); } @@ -498,7 +492,7 @@ Bool AudioManager::isValidAudioEvent(const AudioEventRTS *eventToCheck) const getInfoForAudioEvent(eventToCheck); - return (eventToCheck->getAudioEventInfo() != NULL); + return (eventToCheck->getAudioEventInfo() != nullptr); } //------------------------------------------------------------------------------------------------- @@ -864,7 +858,7 @@ AudioEventInfo *AudioManager::findAudioEventInfo( AsciiString eventName ) const AudioEventInfoHash::const_iterator it; it = m_allAudioEventInfo.find(eventName); if (it == m_allAudioEventInfo.end()) { - return NULL; + return nullptr; } return (*it).second; @@ -951,7 +945,7 @@ Real AudioManager::getAudioLengthMS( const AudioEventRTS *event ) //------------------------------------------------------------------------------------------------- Bool AudioManager::isMusicAlreadyLoaded(void) const { - const AudioEventInfo *musicToLoad = NULL; + const AudioEventInfo *musicToLoad = nullptr; AudioEventInfoHash::const_iterator it; for (it = m_allAudioEventInfo.begin(); it != m_allAudioEventInfo.end(); ++it) { if (it->second) { @@ -1012,7 +1006,7 @@ Bool AudioManager::shouldPlayLocally(const AudioEventRTS *audioEvent) if( !localPlayer->isPlayerActive() ) { //We are dead, thus are observing. Get the player we are observing. It's - //possible that we're not looking at any player, therefore it can be NULL. + //possible that we're not looking at any player, therefore it can be null. localPlayer = TheControlBar->getObserverLookAtPlayer(); } @@ -1034,12 +1028,12 @@ Bool AudioManager::shouldPlayLocally(const AudioEventRTS *audioEvent) Player *owningPlayer = ThePlayerList->getNthPlayer(audioEvent->getPlayerIndex()); - if (BitIsSet(ei->m_type, ST_PLAYER) && BitIsSet(ei->m_type, ST_UI) && owningPlayer == NULL) { + if (BitIsSet(ei->m_type, ST_PLAYER) && BitIsSet(ei->m_type, ST_UI) && owningPlayer == nullptr) { DEBUG_ASSERTCRASH(!TheGameLogic->isInGameLogicUpdate(), ("Playing %s sound -- player-based UI sound without specifying a player.", ei->m_audioName.str())); return TRUE; } - if (owningPlayer == NULL) { + if (owningPlayer == nullptr) { DEBUG_CRASH(("Sound '%s' expects an owning player, but the audio event that created it didn't specify one.", ei->m_audioName.str())); return FALSE; } @@ -1050,7 +1044,7 @@ Bool AudioManager::shouldPlayLocally(const AudioEventRTS *audioEvent) } const Team *localTeam = localPlayer->getDefaultTeam(); - if (localTeam == NULL) { + if (localTeam == nullptr) { return FALSE; } @@ -1082,16 +1076,21 @@ AudioHandle AudioManager::allocateNewHandle( void ) void AudioManager::releaseAudioEventRTS( AudioEventRTS *&eventToRelease ) { delete eventToRelease; - eventToRelease = NULL; + eventToRelease = nullptr; } //------------------------------------------------------------------------------------------------- -void AudioManager::loseFocus( void ) +void AudioManager::muteAudio( MuteAudioReason reason ) { - if (m_savedValues) + m_muteReasonBits |= 1u << reason; + + DEBUG_LOG(("AudioManager::muteAudio(%s): m_muteReason=%u muted=%d", + MuteAudioReasonNames[reason], m_muteReasonBits, (int)(m_muteReasonBits != 0))); + + if (m_muteReasonBits == 0 || m_savedValues) return; - // In this case, make all the audio go silent. + // Make all the audio go silent. m_savedValues = NEW Real[NUM_VOLUME_TYPES]; m_savedValues[VOLUME_TYPE_MUSIC] = m_systemMusicVolume; m_savedValues[VOLUME_TYPE_SOUND] = m_systemSoundVolume; @@ -1103,12 +1102,17 @@ void AudioManager::loseFocus( void ) } //------------------------------------------------------------------------------------------------- -void AudioManager::regainFocus( void ) +void AudioManager::unmuteAudio( MuteAudioReason reason ) { - if (!m_savedValues) + m_muteReasonBits &= ~(1u << reason); + + DEBUG_LOG(("AudioManager::unmuteAudio(%s): m_muteReason=%u muted=%d", + MuteAudioReasonNames[reason], m_muteReasonBits, (int)(m_muteReasonBits != 0))); + + if (m_muteReasonBits != 0 || !m_savedValues) return; - // We got focus back. Restore the previous audio values. + // Restore the previous audio values. setVolume(m_savedValues[VOLUME_TYPE_MUSIC], (AudioAffect) (AudioAffect_Music | AudioAffect_SystemSetting)); setVolume(m_savedValues[VOLUME_TYPE_SOUND], (AudioAffect) (AudioAffect_Sound | AudioAffect_SystemSetting)); setVolume(m_savedValues[VOLUME_TYPE_SOUND3D], (AudioAffect) (AudioAffect_Sound3D | AudioAffect_SystemSetting)); @@ -1116,7 +1120,7 @@ void AudioManager::regainFocus( void ) // Now, blow away the old volumes. delete [] m_savedValues; - m_savedValues = NULL; + m_savedValues = nullptr; } //------------------------------------------------------------------------------------------------- diff --git a/Core/GameEngine/Source/Common/Audio/GameMusic.cpp b/Core/GameEngine/Source/Common/Audio/GameMusic.cpp index 1f0bbe18c02..5e05c6ee4d3 100644 --- a/Core/GameEngine/Source/Common/Audio/GameMusic.cpp +++ b/Core/GameEngine/Source/Common/Audio/GameMusic.cpp @@ -75,10 +75,10 @@ const FieldParse MusicTrack::m_musicTrackFieldParseTable[] = { - { "Filename", INI::parseAsciiString, NULL, offsetof( MusicTrack, filename ) }, - { "Volume", INI::parsePercentToReal, NULL, offsetof( MusicTrack, volume ) }, - { "Ambient", INI::parseBool, NULL, offsetof( MusicTrack, ambient ) }, - { NULL, NULL, NULL, 0 }, + { "Filename", INI::parseAsciiString, nullptr, offsetof( MusicTrack, filename ) }, + { "Volume", INI::parsePercentToReal, nullptr, offsetof( MusicTrack, volume ) }, + { "Ambient", INI::parseBool, nullptr, offsetof( MusicTrack, ambient ) }, + { nullptr, nullptr, nullptr, 0 }, }; diff --git a/Core/GameEngine/Source/Common/Audio/GameSounds.cpp b/Core/GameEngine/Source/Common/Audio/GameSounds.cpp index f398941ab38..0bcc198b4b1 100644 --- a/Core/GameEngine/Source/Common/Audio/GameSounds.cpp +++ b/Core/GameEngine/Source/Common/Audio/GameSounds.cpp @@ -206,7 +206,7 @@ Bool SoundManager::canPlayNow( AudioEventRTS *event ) // 1) Are we muted because we're beyond our maximum distance? // 2) Are we shrouded and this is a shroud sound? // 3) Are we violating our voice count or are we playing above the limit? (If so, stop now) - // 4) is there an avaiable channel open? + // 4) is there an available channel open? // 5) if not, then determine if there is anything of lower priority that we can kill // 6) if not, are we an interrupt-sound type? // if so, are there any sounds of our type playing right now that we can interrupt? diff --git a/Core/GameEngine/Source/Common/Audio/simpleplayer.cpp b/Core/GameEngine/Source/Common/Audio/simpleplayer.cpp index 4af0d3a6a17..6357b7fbd0b 100644 --- a/Core/GameEngine/Source/Common/Audio/simpleplayer.cpp +++ b/Core/GameEngine/Source/Common/Audio/simpleplayer.cpp @@ -27,33 +27,33 @@ CSimplePlayer::CSimplePlayer( HRESULT* phr ) m_cRef = 1; m_cBuffersOutstanding = 0; - m_pReader = NULL; + m_pReader = nullptr; - m_pHeader = NULL; - m_hwo = NULL; + m_pHeader = nullptr; + m_hwo = nullptr; m_fEof = FALSE; - m_pszUrl = NULL; + m_pszUrl = nullptr; *phr = S_OK; - m_hOpenEvent = CreateEvent( NULL, FALSE, FALSE, SIMPLE_PLAYER_OPEN_EVENT ); - if ( NULL == m_hOpenEvent ) + m_hOpenEvent = CreateEvent( nullptr, FALSE, FALSE, SIMPLE_PLAYER_OPEN_EVENT ); + if ( nullptr == m_hOpenEvent ) { *phr = E_OUTOFMEMORY; } - m_hCloseEvent = CreateEvent( NULL, FALSE, FALSE, SIMPLE_PLAYER_CLOSE_EVENT ); - if ( NULL == m_hCloseEvent ) + m_hCloseEvent = CreateEvent( nullptr, FALSE, FALSE, SIMPLE_PLAYER_CLOSE_EVENT ); + if ( nullptr == m_hCloseEvent ) { *phr = E_OUTOFMEMORY; } m_hrOpen = S_OK; - m_hCompletionEvent = NULL; + m_hCompletionEvent = nullptr; InitializeCriticalSection( &m_CriSec ); - m_whdrHead = NULL; + m_whdrHead = nullptr; } @@ -70,19 +70,19 @@ CSimplePlayer::~CSimplePlayer() RemoveWaveHeaders(); DeleteCriticalSection( &m_CriSec ); - if( m_pHeader != NULL ) + if( m_pHeader != nullptr ) { m_pHeader->Release(); - m_pHeader = NULL; + m_pHeader = nullptr; } - if( m_pReader != NULL ) + if( m_pReader != nullptr ) { m_pReader->Release(); - m_pReader = NULL; + m_pReader = nullptr; } - if( m_hwo != NULL ) + if( m_hwo != nullptr ) { waveOutClose( m_hwo ); } @@ -164,7 +164,7 @@ HRESULT STDMETHODCALLTYPE CSimplePlayer::OnSample( LPWAVEHDR pwh = (LPWAVEHDR) new BYTE[ sizeof( WAVEHDR ) + cbData ]; - if( NULL == pwh ) + if( nullptr == pwh ) { DEBUG_LOG(( "OnSample OUT OF MEMORY! ")); @@ -233,7 +233,7 @@ HRESULT CSimplePlayer::Play( LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hComple // LPWSTR pszCheck = _wfullpath( wszFullUrl, pszUrl, MAX_PATH ); - if( NULL == pszCheck ) + if( nullptr == pszCheck ) { DEBUG_LOG(( "internal error %lu" , GetLastError() )); return E_UNEXPECTED ; @@ -249,7 +249,7 @@ HRESULT CSimplePlayer::Play( LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hComple m_pszUrl = new WCHAR[ wcslen( pszUrl ) + 1 ]; - if( NULL == m_pszUrl ) + if( nullptr == m_pszUrl ) { DEBUG_LOG(( "insufficient Memory" )) ; return( E_OUTOFMEMORY ); @@ -266,11 +266,11 @@ HRESULT CSimplePlayer::Play( LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hComple #ifdef SUPPORT_DRM - hr = WMCreateReader( NULL, WMT_RIGHT_PLAYBACK, &m_pReader ); + hr = WMCreateReader( nullptr, WMT_RIGHT_PLAYBACK, &m_pReader ); #else - hr = WMCreateReader( NULL, 0, &m_pReader ); + hr = WMCreateReader( nullptr, 0, &m_pReader ); #endif @@ -283,7 +283,7 @@ HRESULT CSimplePlayer::Play( LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hComple // // Open the file // - hr = m_pReader->Open( m_pszUrl, this, NULL ); + hr = m_pReader->Open( m_pszUrl, this, nullptr ); if ( SUCCEEDED( hr ) ) { WaitForSingleObject( m_hOpenEvent, INFINITE ); @@ -321,8 +321,8 @@ HRESULT CSimplePlayer::Play( LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hComple return( hr ); } - WCHAR *pwszName = NULL; - BYTE *pValue = NULL; + WCHAR *pwszName = nullptr; + BYTE *pValue = nullptr; for ( i = 0; i < wAttrCnt ; i++ ) { @@ -331,7 +331,7 @@ HRESULT CSimplePlayer::Play( LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hComple WMT_ATTR_DATATYPE type; WORD cbLength = 0; - hr = m_pHeader->GetAttributeByIndex( i, &wStream, NULL, &cchNamelen, &type, NULL, &cbLength ); + hr = m_pHeader->GetAttributeByIndex( i, &wStream, nullptr, &cchNamelen, &type, nullptr, &cbLength ); if ( FAILED( hr ) ) { DEBUG_LOG(( "GetAttributeByIndex Failed (hr=0x%08x)" , hr )); @@ -341,7 +341,7 @@ HRESULT CSimplePlayer::Play( LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hComple pwszName = new WCHAR[ cchNamelen ]; pValue = new BYTE[ cbLength ]; - if( NULL == pwszName || NULL == pValue ) + if( nullptr == pwszName || nullptr == pValue ) { hr = E_OUTOFMEMORY; break; @@ -383,17 +383,17 @@ HRESULT CSimplePlayer::Play( LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hComple } delete pwszName; - pwszName = NULL; + pwszName = nullptr; delete pValue; - pValue = NULL; + pValue = nullptr; } delete pwszName; - pwszName = NULL; + pwszName = nullptr; delete pValue; - pValue = NULL; + pValue = nullptr; if ( FAILED( hr ) ) { @@ -428,7 +428,7 @@ HRESULT CSimplePlayer::Play( LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hComple DWORD cbBuffer = 0; - hr = pProps->GetMediaType( NULL, &cbBuffer ); + hr = pProps->GetMediaType( nullptr, &cbBuffer ); if ( FAILED( hr ) ) { pProps->Release( ); @@ -462,7 +462,7 @@ HRESULT CSimplePlayer::Play( LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hComple memcpy( &m_wfx, pwfx, sizeof( WAVEFORMATEX ) + pwfx->cbSize ); delete[] (BYTE *)pMediaType ; - pMediaType = NULL ; + pMediaType = nullptr ; MMRESULT mmr; @@ -485,7 +485,7 @@ HRESULT CSimplePlayer::Play( LPCWSTR pszUrl, DWORD dwSecDuration, HANDLE hComple // Start reading the data (and rendering the audio) // QWORD cnsDuration = ( QWORD ) dwSecDuration * 10000000; - hr = m_pReader->Start( 0, cnsDuration, 1.0, NULL ); + hr = m_pReader->Start( 0, cnsDuration, 1.0, nullptr ); if( FAILED( hr ) ) { @@ -581,7 +581,7 @@ HRESULT STDMETHODCALLTYPE CSimplePlayer::OnStatus( case WMT_NO_RIGHTS: { - LPWSTR pwszEscapedURL = NULL; + LPWSTR pwszEscapedURL = nullptr; hr = MakeEscapedURL( m_pszUrl, &pwszEscapedURL ); @@ -599,7 +599,7 @@ HRESULT STDMETHODCALLTYPE CSimplePlayer::OnStatus( } delete [] pwszEscapedURL; - pwszEscapedURL = NULL ; + pwszEscapedURL = nullptr ; } } break; @@ -624,7 +624,7 @@ HRESULT CSimplePlayer::Close() { HRESULT hr = S_OK; - if( NULL != m_pReader ) + if( nullptr != m_pReader ) { hr = m_pReader->Close(); @@ -676,7 +676,7 @@ void CALLBACK CSimplePlayer::WaveProc( HRESULT CSimplePlayer::AddWaveHeader( LPWAVEHDR pwh ) { WAVEHDR_LIST *tmp = new WAVEHDR_LIST; - if( NULL == tmp ) + if( nullptr == tmp ) { return( E_OUTOFMEMORY ); } @@ -695,7 +695,7 @@ void CSimplePlayer::RemoveWaveHeaders( ) WAVEHDR_LIST *tmp; EnterCriticalSection( &m_CriSec ); - while( NULL != m_whdrHead ) + while( nullptr != m_whdrHead ) { tmp = m_whdrHead->next; DEBUG_ASSERTCRASH( m_whdrHead->pwh->dwFlags & WHDR_DONE, ("RemoveWaveHeaders!") ); diff --git a/Core/GameEngine/Source/Common/Audio/urllaunch.cpp b/Core/GameEngine/Source/Common/Audio/urllaunch.cpp index 6ac481a89c0..c66d21dfa47 100644 --- a/Core/GameEngine/Source/Common/Audio/urllaunch.cpp +++ b/Core/GameEngine/Source/Common/Audio/urllaunch.cpp @@ -25,7 +25,7 @@ /////////////////////////////////////////////////////////////////////////////// HRESULT MakeEscapedURL( LPWSTR pszInURL, LPWSTR *ppszOutURL ) { - if( ( NULL == pszInURL ) || ( NULL == ppszOutURL ) ) + if( ( nullptr == pszInURL ) || ( nullptr == ppszOutURL ) ) { return( E_INVALIDARG ); } @@ -45,7 +45,7 @@ HRESULT MakeEscapedURL( LPWSTR pszInURL, LPWSTR *ppszOutURL ) { LPWSTR pchToEscape = wcspbrk( pszTemp, L" #$%&\\+,;=@[]^{}" ); - if( NULL == pchToEscape ) + if( nullptr == pchToEscape ) { break; } @@ -67,7 +67,7 @@ HRESULT MakeEscapedURL( LPWSTR pszInURL, LPWSTR *ppszOutURL ) *ppszOutURL = new WCHAR[ cchNeeded ]; - if( NULL == *ppszOutURL ) + if( nullptr == *ppszOutURL ) { return( E_OUTOFMEMORY ); } @@ -89,7 +89,7 @@ HRESULT MakeEscapedURL( LPWSTR pszInURL, LPWSTR *ppszOutURL ) { LPWSTR pchToEscape = wcspbrk( pszTemp, L" #$%&\\+,;=@[]^{}" ); - if( NULL == pchToEscape ) + if( nullptr == pchToEscape ) { // // Copy the rest of the input string and get out @@ -127,8 +127,8 @@ HRESULT GetShellOpenCommand( LPTSTR ptszShellOpenCommand, DWORD cbShellOpenComma { LONG lResult; - HKEY hKey = NULL; - HKEY hFileKey = NULL; + HKEY hKey = nullptr; + HKEY hFileKey = nullptr; BOOL fFoundExtensionCommand = FALSE; @@ -148,7 +148,7 @@ HRESULT GetShellOpenCommand( LPTSTR ptszShellOpenCommand, DWORD cbShellOpenComma DWORD dwLength = sizeof( szFileType ); - lResult = RegQueryValueEx( hKey, NULL, 0, NULL, (BYTE *)szFileType, &dwLength ); + lResult = RegQueryValueEx( hKey, nullptr, 0, nullptr, (BYTE *)szFileType, &dwLength ); if( ERROR_SUCCESS != lResult ) { @@ -171,7 +171,7 @@ HRESULT GetShellOpenCommand( LPTSTR ptszShellOpenCommand, DWORD cbShellOpenComma dwLength = cbShellOpenCommand; - lResult = RegQueryValueEx( hFileKey, NULL, 0, NULL, (BYTE *)ptszShellOpenCommand, &dwLength ); + lResult = RegQueryValueEx( hFileKey, nullptr, 0, nullptr, (BYTE *)ptszShellOpenCommand, &dwLength ); if( 0 == lResult ) { @@ -186,7 +186,7 @@ HRESULT GetShellOpenCommand( LPTSTR ptszShellOpenCommand, DWORD cbShellOpenComma // if( !fFoundExtensionCommand ) { - if( NULL != hKey ) + if( nullptr != hKey ) { RegCloseKey( hKey ); } @@ -205,17 +205,17 @@ HRESULT GetShellOpenCommand( LPTSTR ptszShellOpenCommand, DWORD cbShellOpenComma DWORD dwLength = cbShellOpenCommand; - lResult = RegQueryValueEx( hKey, NULL, 0, NULL, (BYTE *)ptszShellOpenCommand, &dwLength ); + lResult = RegQueryValueEx( hKey, nullptr, 0, nullptr, (BYTE *)ptszShellOpenCommand, &dwLength ); } while( FALSE ); } - if( NULL != hKey ) + if( nullptr != hKey ) { RegCloseKey( hKey ); } - if( NULL != hFileKey ) + if( nullptr != hFileKey ) { RegCloseKey( hFileKey ); } @@ -248,12 +248,12 @@ HRESULT LaunchURL( LPCWSTR pszURL ) LPTSTR pszParam = _tcsstr( szShellOpenCommand, _T( "\"%1\"" ) ); - if( NULL == pszParam ) + if( nullptr == pszParam ) { pszParam = _tcsstr( szShellOpenCommand, _T( "\"%*\"" ) ); } - if( NULL != pszParam ) + if( nullptr != pszParam ) { *pszParam = _T( '\0' ) ; @@ -269,7 +269,7 @@ HRESULT LaunchURL( LPCWSTR pszURL ) // TCHAR szExe[ MAX_PATH * 2 ]; LPTSTR pchFirst = szShellOpenCommand; - LPTSTR pchNext = NULL; + LPTSTR pchNext = nullptr; while( _T( ' ' ) == *pchFirst ) { @@ -287,7 +287,7 @@ HRESULT LaunchURL( LPCWSTR pszURL ) pchNext = _tcschr( pchFirst + 1, _T( ' ' ) ); } - if( NULL == pchNext ) + if( nullptr == pchNext ) { pchNext = szShellOpenCommand + _tcslen( szShellOpenCommand ); } @@ -312,8 +312,8 @@ HRESULT LaunchURL( LPCWSTR pszURL ) StartUp.cb = sizeof(STARTUPINFO); - if( !CreateProcess( szExe, szLaunchCommand, NULL, NULL, - FALSE, 0, NULL, NULL, &StartUp, &ProcInfo) ) + if( !CreateProcess( szExe, szLaunchCommand, nullptr, nullptr, + FALSE, 0, nullptr, nullptr, &StartUp, &ProcInfo) ) { hr = HRESULT_FROM_WIN32( GetLastError() ); } @@ -323,12 +323,12 @@ HRESULT LaunchURL( LPCWSTR pszURL ) // CreateProcess succeeded and we do not need the handles to the thread // or the process, so close them now. // - if( NULL != ProcInfo.hThread ) + if( nullptr != ProcInfo.hThread ) { CloseHandle( ProcInfo.hThread ); } - if( NULL != ProcInfo.hProcess ) + if( nullptr != ProcInfo.hProcess ) { CloseHandle( ProcInfo.hProcess ); } diff --git a/Core/GameEngine/Source/Common/CRCDebug.cpp b/Core/GameEngine/Source/Common/CRCDebug.cpp index 6b46e248bbc..37ee13a87e6 100644 --- a/Core/GameEngine/Source/Common/CRCDebug.cpp +++ b/Core/GameEngine/Source/Common/CRCDebug.cpp @@ -120,7 +120,7 @@ void CRCDebugStartNewGame() if (g_saveDebugCRCPerFrame) { // Create folder for frame data, if it doesn't exist yet. - CreateDirectory(g_saveDebugCRCPerFrameDir.str(), NULL); + CreateDirectory(g_saveDebugCRCPerFrameDir.str(), nullptr); // Delete existing files FilenameList files; @@ -188,7 +188,7 @@ static AsciiString getFname(AsciiString path) static void addCRCDebugLineInternal(bool count, const char *fmt, va_list args) { - if (TheGameLogic == NULL || !(IS_FRAME_OK_TO_LOG)) + if (TheGameLogic == nullptr || !(IS_FRAME_OK_TO_LOG)) return; if (lastCRCDebugFrame != TheGameLogic->getFrame()) diff --git a/Core/GameEngine/Source/Common/FramePacer.cpp b/Core/GameEngine/Source/Common/FramePacer.cpp index d538af0677a..0ad42c944a3 100644 --- a/Core/GameEngine/Source/Common/FramePacer.cpp +++ b/Core/GameEngine/Source/Common/FramePacer.cpp @@ -28,7 +28,7 @@ #include "GameNetwork/NetworkInterface.h" -FramePacer* TheFramePacer = NULL; +FramePacer* TheFramePacer = nullptr; FramePacer::FramePacer() { @@ -83,12 +83,12 @@ Bool FramePacer::isActualFramesPerSecondLimitEnabled() const { Bool allowFpsLimit = true; - if (TheTacticalView != NULL) + if (TheTacticalView != nullptr) { allowFpsLimit &= TheTacticalView->getTimeMultiplier()<=1 && !TheScriptEngine->isTimeFast(); } - if (TheGameLogic != NULL) + if (TheGameLogic != nullptr) { #if defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE) allowFpsLimit &= !(!TheGameLogic->isGamePaused() && TheGlobalData->m_TiVOFastMode); @@ -177,7 +177,7 @@ Int FramePacer::getActualLogicTimeScaleFps(LogicTimeQueryFlags flags) const return 0; } - if (TheNetwork != NULL) + if (TheNetwork != nullptr) { return TheNetwork->getFrameRate(); } diff --git a/Core/GameEngine/Source/Common/GameUtility.cpp b/Core/GameEngine/Source/Common/GameUtility.cpp index 386fefdb3e0..cffb87f4842 100644 --- a/Core/GameEngine/Source/Common/GameUtility.cpp +++ b/Core/GameEngine/Source/Common/GameUtility.cpp @@ -67,11 +67,11 @@ bool localPlayerHasRadar() Player* getObservedOrLocalPlayer() { - DEBUG_ASSERTCRASH(TheControlBar != NULL, ("TheControlBar is NULL")); + DEBUG_ASSERTCRASH(TheControlBar != nullptr, ("TheControlBar is null")); Player* player = TheControlBar->getObservedPlayer(); - if (player == NULL) + if (player == nullptr) { - DEBUG_ASSERTCRASH(ThePlayerList != NULL, ("ThePlayerList is NULL")); + DEBUG_ASSERTCRASH(ThePlayerList != nullptr, ("ThePlayerList is null")); player = ThePlayerList->getLocalPlayer(); } return player; @@ -79,13 +79,13 @@ Player* getObservedOrLocalPlayer() Player* getObservedOrLocalPlayer_Safe() { - Player* player = NULL; + Player* player = nullptr; - if (TheControlBar != NULL) + if (TheControlBar != nullptr) player = TheControlBar->getObservedPlayer(); - if (player == NULL) - if (ThePlayerList != NULL) + if (player == nullptr) + if (ThePlayerList != nullptr) player = ThePlayerList->getLocalPlayer(); return player; @@ -101,11 +101,11 @@ PlayerIndex getObservedOrLocalPlayerIndex_Safe() void changeLocalPlayer(Player* player) { - DEBUG_ASSERTCRASH(player != NULL, ("Player is NULL")); + DEBUG_ASSERTCRASH(player != nullptr, ("Player is null")); ThePlayerList->setLocalPlayer(player); - TheControlBar->setObserverLookAtPlayer(NULL); - TheControlBar->setObservedPlayer(NULL); + TheControlBar->setObserverLookAtPlayer(nullptr); + TheControlBar->setObservedPlayer(nullptr); TheControlBar->setControlBarSchemeByPlayer(player); TheControlBar->initSpecialPowershortcutBar(player); @@ -117,14 +117,14 @@ void changeObservedPlayer(Player* player) TheControlBar->setObserverLookAtPlayer(player); const Bool canBeginObservePlayer = TheGlobalData->m_enablePlayerObserver && TheGhostObjectManager->trackAllPlayers(); - const Bool canEndObservePlayer = TheControlBar->getObservedPlayer() != NULL && TheControlBar->getObserverLookAtPlayer() == NULL; + const Bool canEndObservePlayer = TheControlBar->getObservedPlayer() != nullptr && TheControlBar->getObserverLookAtPlayer() == nullptr; if (canBeginObservePlayer || canEndObservePlayer) { TheControlBar->setObservedPlayer(player); Player *becomePlayer = player; - if (becomePlayer == NULL) + if (becomePlayer == nullptr) becomePlayer = ThePlayerList->findPlayerWithNameKey(TheNameKeyGenerator->nameToKey("ReplayObserver")); detail::changePlayerCommon(becomePlayer); } diff --git a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp b/Core/GameEngine/Source/Common/INI/INI.cpp similarity index 95% rename from GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp rename to Core/GameEngine/Source/Common/INI/INI.cpp index ab1a9119186..d1be02f84d9 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/INI/INI.cpp +++ b/Core/GameEngine/Source/Common/INI/INI.cpp @@ -67,7 +67,7 @@ // PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// -static Xfer *s_xfer = NULL; +static Xfer *s_xfer = nullptr; //------------------------------------------------------------------------------------------------- /** This is the table of data types we can have in INI files. To add a new data type @@ -149,7 +149,7 @@ static const BlockParse theTypeTable[] = { "ScriptAction", ScriptEngine::parseScriptAction }, { "ScriptCondition", ScriptEngine::parseScriptCondition }, - { NULL, NULL }, + { nullptr, nullptr }, }; @@ -158,7 +158,7 @@ static const BlockParse theTypeTable[] = /////////////////////////////////////////////////////////////////////////////////////////////////// Bool INI::isValidINIFilename( const char *filename ) { - if( filename == NULL ) + if( filename == nullptr ) return FALSE; Int len = strlen( filename ); @@ -187,8 +187,9 @@ Bool INI::isValidINIFilename( const char *filename ) INI::INI( void ) { - m_file = NULL; - m_readBufferNext=m_readBufferUsed=0; + m_readBuffer = nullptr; + m_readBufferNext = 0; + m_readBufferUsed = 0; m_filename = "None"; m_loadType = INI_LOAD_INVALID; m_lineNum = 0; @@ -275,7 +276,7 @@ UnsignedInt INI::loadDirectory( AsciiString dirName, INILoadType loadType, Xfer AsciiString tempname; tempname = (*it).str() + dirName.getLength(); - if ((tempname.find('\\') == NULL) && (tempname.find('/') == NULL)) { + if ((tempname.find('\\') == nullptr) && (tempname.find('/') == nullptr)) { // this file doesn't reside in a subdirectory, load it first. filesRead += load( *it, loadType, pXfer ); } @@ -288,7 +289,7 @@ UnsignedInt INI::loadDirectory( AsciiString dirName, INILoadType loadType, Xfer AsciiString tempname; tempname = (*it).str() + dirName.getLength(); - if ((tempname.find('\\') != NULL) || (tempname.find('/') != NULL)) { + if ((tempname.find('\\') != nullptr) || (tempname.find('/') != nullptr)) { filesRead += load( *it, loadType, pXfer ); } ++it; @@ -308,7 +309,7 @@ UnsignedInt INI::loadDirectory( AsciiString dirName, INILoadType loadType, Xfer void INI::prepFile( AsciiString filename, INILoadType loadType, Bool optional /*=FALSE*/) { // if we have a file open already -- we can't do another one - if( m_file != NULL ) + if( m_readBuffer != nullptr ) { DEBUG_CRASH(( "INI::load, cannot open file '%s', file already open", filename.str() )); @@ -317,8 +318,8 @@ void INI::prepFile( AsciiString filename, INILoadType loadType, Bool optional /* } // open the file - m_file = TheFileSystem->openFile(filename.str(), File::READ); - if( m_file == NULL ) + File* file = TheFileSystem->openFile(filename.str(), File::READ); + if( file == nullptr ) { if (optional) { DEBUG_LOG(("INI::load, cannot open file '%s'", filename.str())); @@ -329,7 +330,9 @@ void INI::prepFile( AsciiString filename, INILoadType loadType, Bool optional /* } - m_file = m_file->convertToRAMFile(); + m_readBufferNext = 0; + m_readBufferUsed = file->size(); + m_readBuffer = file->readEntireAndClose(); // save our filename m_filename = filename; @@ -342,15 +345,17 @@ void INI::prepFile( AsciiString filename, INILoadType loadType, Bool optional /* //------------------------------------------------------------------------------------------------- void INI::unPrepFile() { - // close the file - m_file->close(); - m_file = NULL; - m_readBufferUsed=m_readBufferNext=0; + // delete the buffer + delete[] m_readBuffer; + m_readBuffer = nullptr; + m_readBufferNext = 0; + m_readBufferUsed = 0; + m_filename = "None"; m_loadType = INI_LOAD_INVALID; m_lineNum = 0; m_endOfFile = FALSE; - s_xfer = NULL; + s_xfer = nullptr; } //------------------------------------------------------------------------------------------------- @@ -363,7 +368,7 @@ static INIBlockParse findBlockParse(const char* token) return parse->parse; } } - return NULL; + return nullptr; } //------------------------------------------------------------------------------------------------- @@ -388,7 +393,7 @@ static INIFieldParseProc findFieldParse(const FieldParse* parseTable, const char } else { - return NULL; + return nullptr; } } @@ -403,7 +408,7 @@ UnsignedInt INI::load( AsciiString filename, INILoadType loadType, Xfer *pXfer, s_xfer = pXfer; prepFile(filename, loadType, optional); - if (optional && m_file == NULL) { + if (optional && m_filename == "None") { // unPrepFile(); return 0; } @@ -441,7 +446,8 @@ UnsignedInt INI::load( AsciiString filename, INILoadType loadType, Xfer *pXfer, } catch (...) { DEBUG_CRASH(("Error parsing block '%s' in INI file '%s'", token, m_filename.str()) ); char buff[1024]; - sprintf(buff, "Error parsing INI file '%s' (Line: '%s')\n", m_filename.str(), currentLine.str()); + snprintf(buff, ARRAY_SIZE(buff), "Error parsing INI file '%s' (Line: '%s')\n", + m_filename.str(), currentLine.str()); throw INIException(buff); } @@ -473,55 +479,63 @@ UnsignedInt INI::load( AsciiString filename, INILoadType loadType, Xfer *pXfer, //------------------------------------------------------------------------------------------------- /** Read a line from the already open file. Any comments will be removed and - * therefore ignored from any given line */ + * therefore ignored from any given line + * + * TheSuperHackers @performance xezon 18/01/2026 The file contents are now read directly from a + * full File Ram buffer into the INI Line Buffer without a third buffer in between. + */ //------------------------------------------------------------------------------------------------- void INI::readLine( void ) { // sanity - DEBUG_ASSERTCRASH( m_file, ("readLine(), file pointer is NULL") ); - - if (m_endOfFile) - *m_buffer=0; - else - { - char *p=m_buffer; - while (p!=m_buffer+INI_MAX_CHARS_PER_LINE) - { - // get next character - if (m_readBufferNext==m_readBufferUsed) - { - // refill buffer - m_readBufferNext=0; - m_readBufferUsed=m_file->read(m_readBuffer,INI_READ_BUFFER); - - // EOF? - if (!m_readBufferUsed) - { - m_endOfFile=true; - *p=0; - break; - } - } - *p=m_readBuffer[m_readBufferNext++]; - - // CR? - if (*p=='\n') - { - *p=0; - break; - } - - DEBUG_ASSERTCRASH(*p != '\t', ("tab characters are not allowed in INI files (%s). please check your editor settings. Line Number %d",m_filename.str(), getLineNum())); - - // comment? - if (*p==';') - *p=0; - // whitespace? - else if (*p>0&&*p<32) - *p=' '; - p++; - } - *p=0; + DEBUG_ASSERTCRASH( m_readBuffer, ("readLine(), read buffer is null") ); + + if (m_endOfFile) + { + *m_buffer = 0; + } + else + { + // read up till the newline or semicolon character, or until out of space + char *p = m_buffer; + while (p != m_buffer+INI_MAX_CHARS_PER_LINE) + { + // test end of read buffer + if (m_readBufferNext==m_readBufferUsed) + { + m_endOfFile = true; + *p = 0; + break; + } + + // get next character + *p = m_readBuffer[m_readBufferNext++]; + + // check for new line + if (*p == '\n') + { + *p = 0; + break; + } + + DEBUG_ASSERTCRASH(*p != '\t', ("tab characters are not allowed in INI files (%s). please check your editor settings. Line Number %d", m_filename.str(), getLineNum())); + + // if this is a semicolon, that represents the start of a comment + if (*p == ';') + { + *p = 0; + } + + // make whitespace characters actual spaces + else if (*p > 0 && *p < 32) + { + *p = ' '; + } + + p++; + } + + *p = 0; // increase our line count m_lineNum++; @@ -529,18 +543,14 @@ void INI::readLine( void ) // check for at the max if ( p == m_buffer+INI_MAX_CHARS_PER_LINE ) { - - DEBUG_ASSERTCRASH( 0, ("Buffer too small (%d) and was truncated, increase INI_MAX_CHARS_PER_LINE", - INI_MAX_CHARS_PER_LINE) ); - + DEBUG_ASSERTCRASH( 0, ("Buffer too small (%d) and was truncated, increase INI_MAX_CHARS_PER_LINE", INI_MAX_CHARS_PER_LINE) ); } - } + } if (s_xfer) { s_xfer->xferUser( m_buffer, sizeof( char ) * strlen( m_buffer ) ); - //DEBUG_LOG(("Xfer val is now 0x%8.8X in %s, line %s", ((XferCRC *)s_xfer)->getCRC(), - //m_filename.str(), m_buffer)); + //DEBUG_LOG(("Xfer val is now 0x%8.8X in %s, line %s", ((XferCRC *)s_xfer)->getCRC(), m_filename.str(), m_buffer)); } } @@ -731,7 +741,7 @@ void INI::parseAsciiStringVector( INI* ini, void * /*instance*/, void *store, co { std::vector* asv = (std::vector*)store; asv->clear(); - for (const char *token = ini->getNextTokenOrNull(); token != NULL; token = ini->getNextTokenOrNull()) + for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull()) { asv->push_back(token); } @@ -744,7 +754,7 @@ void INI::parseAsciiStringVectorAppend( INI* ini, void * /*instance*/, void *sto std::vector* asv = (std::vector*)store; // nope, don't clear. duh. // asv->clear(); - for (const char *token = ini->getNextTokenOrNull(); token != NULL; token = ini->getNextTokenOrNull()) + for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull()) { asv->push_back(token); } @@ -756,7 +766,7 @@ void INI::parseAsciiStringVectorAppend( INI* ini, void * /*instance*/, void *sto { ScienceVec* asv = (ScienceVec*)store; asv->clear(); - for (const char *token = ini->getNextTokenOrNull(); token != NULL; token = ini->getNextTokenOrNull()) + for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull()) { if (stricmp(token, "None") == 0) { @@ -810,7 +820,7 @@ AsciiString INI::getNextQuotedAsciiString() buff[0] = '\0'; const char *token = getNextTokenOrNull(); // if null, just leave an empty string - if (token != NULL) + if (token != nullptr) { if (token[0] != '\"') { @@ -858,7 +868,7 @@ AsciiString INI::getNextAsciiString() AsciiString result; const char *token = getNextTokenOrNull(); // if null, just leave an empty string - if (token != NULL) + if (token != nullptr) { if (token[0] != '\"') { @@ -951,7 +961,7 @@ void INI::parseMappedImage( INI *ini, void * /*instance*/, void *store, const vo else { - DEBUG_CRASH(( "INI::parseAnim2DTemplate - TheAnim2DCollection is NULL" )); + DEBUG_CRASH(( "INI::parseAnim2DTemplate - TheAnim2DCollection is null" )); throw INI_UNKNOWN_ERROR; } @@ -978,7 +988,7 @@ void INI::parsePercentToReal( INI* ini, void * /*instance*/, void *store, const void INI::parseBitString8( INI* ini, void * /*instance*/, void *store, const void* userData ) { UnsignedInt tmp; - INI::parseBitString32(ini, NULL, &tmp, userData); + INI::parseBitString32(ini, nullptr, &tmp, userData); if (tmp & 0xffffff00) { DEBUG_CRASH(("Bad bitstring list INI::parseBitString8")); @@ -997,7 +1007,7 @@ void INI::parseBitString32( INI* ini, void * /*instance*/, void *store, const vo ConstCharPtrArray flagList = (ConstCharPtrArray)userData; UnsignedInt *bits = (UnsignedInt *)store; - if( flagList == NULL || flagList[ 0 ] == NULL) + if( flagList == nullptr || flagList[ 0 ] == nullptr) { DEBUG_ASSERTCRASH( flagList, ("INTERNAL ERROR! parseBitString32: No flag list provided!") ); throw INI_INVALID_NAME_LIST; @@ -1007,7 +1017,7 @@ void INI::parseBitString32( INI* ini, void * /*instance*/, void *store, const vo Bool foundAddOrSub = false; // loop through all tokens - for (const char *token = ini->getNextTokenOrNull(); token != NULL; token = ini->getNextTokenOrNull()) + for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull()) { if (stricmp(token, "NONE") == 0) { @@ -1130,7 +1140,7 @@ void INI::parseRGBAColorInt( INI* ini, void * /*instance*/, void *store, const v for( Int i = 0; i < 4; i++ ) { const char* token = ini->getNextTokenOrNull(ini->getSepsColon()); - if (token == NULL) + if (token == nullptr) { if (i < 3) { @@ -1182,7 +1192,7 @@ void INI::parseColorInt( INI* ini, void * /*instance*/, void *store, const void* for( Int i = 0; i < 4; i++ ) { const char* token = ini->getNextTokenOrNull(ini->getSepsColon()); - if (token == NULL) + if (token == nullptr) { if (i < 3) { @@ -1270,11 +1280,11 @@ void INI::parseDynamicAudioEventRTS( INI *ini, void * /*instance*/, void *store, if (stricmp(token, "NoSound") == 0) { deleteInstance(*theSound); - *theSound = NULL; + *theSound = nullptr; } else { - if (*theSound == NULL) + if (*theSound == nullptr) *theSound = newInstance(DynamicAudioEventRTS); (*theSound)->m_event.setEventName(AsciiString(token)); } @@ -1318,7 +1328,7 @@ void INI::parseThingTemplate( INI* ini, void * /*instance*/, void *store, const if (stricmp(token, "None") == 0) { - *theThingTemplate = NULL; + *theThingTemplate = nullptr; } else { @@ -1342,7 +1352,7 @@ void INI::parseArmorTemplate( INI* ini, void * /*instance*/, void *store, const if (stricmp(token, "None") == 0) { - *theArmorTemplate = NULL; + *theArmorTemplate = nullptr; } else { @@ -1382,7 +1392,7 @@ void INI::parseFXList( INI* ini, void * /*instance*/, void *store, const void* / ConstFXListPtr* theFXList = (ConstFXListPtr*)store; const FXList *fxl = TheFXListStore->findFXList(token); // could be null! - DEBUG_ASSERTCRASH(fxl != NULL || stricmp(token, "None") == 0, ("FXList %s not found!",token)); + DEBUG_ASSERTCRASH(fxl != nullptr || stricmp(token, "None") == 0, ("FXList %s not found!",token)); // assign it, even if null! *theFXList = fxl; @@ -1417,7 +1427,7 @@ void INI::parseDamageFX( INI* ini, void * /*instance*/, void *store, const void* if (stricmp(token, "None") == 0) { - *theDamageFX = NULL; + *theDamageFX = nullptr; } else { @@ -1627,7 +1637,7 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList { Bool done = FALSE; - if( what == NULL ) + if( what == nullptr ) { DEBUG_ASSERTCRASH( 0, ("INI::initFromINI - Invalid parameters supplied!") ); throw INI_INVALID_PARAMS; @@ -1655,7 +1665,7 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList for (int ptIdx = 0; ptIdx < parseTableList.getCount(); ++ptIdx) { int offset = 0; - const void* userData = 0; + const void* userData = nullptr; INIFieldParseProc parse = findFieldParse(parseTableList.getNthFieldParse(ptIdx), field, offset, userData); if (parse) { @@ -1670,7 +1680,8 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList char buff[1024]; - sprintf(buff, "[LINE: %d - FILE: '%s'] Error reading field '%s'\n", INI::getLineNum(), INI::getFilename().str(), field); + snprintf(buff, ARRAY_SIZE(buff), "[LINE: %d - FILE: '%s'] Error reading field '%s'\n", + INI::getLineNum(), INI::getFilename().str(), field); throw INIException(buff); } @@ -1709,7 +1720,7 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList /*static*/ const char* INI::getNextToken(const char* seps) { if (!seps) seps = getSeps(); - const char *token = ::strtok(NULL, seps); + const char *token = ::strtok(nullptr, seps); if (!token) throw INI_INVALID_DATA; return token; @@ -1719,7 +1730,7 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList /*static*/ const char* INI::getNextTokenOrNull(const char* seps) { if (!seps) seps = getSeps(); - const char *token = ::strtok(NULL, seps); + const char *token = ::strtok(nullptr, seps); return token; } @@ -1768,7 +1779,7 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList //------------------------------------------------------------------------------------------------- /*static*/ Int INI::scanIndexList(const char* token, ConstCharPtrArray nameList) { - if( nameList == NULL || nameList[ 0 ] == NULL ) + if( nameList == nullptr || nameList[ 0 ] == nullptr ) { DEBUG_ASSERTCRASH( 0, ("INTERNAL ERROR! scanIndexList, invalid name list") ); @@ -1794,7 +1805,7 @@ void INI::initFromINIMulti( void *what, const MultiIniFieldParse& parseTableList //------------------------------------------------------------------------------------------------- /*static*/ Int INI::scanLookupList(const char* token, ConstLookupListRecArray lookupList) { - if( lookupList == NULL || lookupList[ 0 ].name == NULL ) + if( lookupList == nullptr || lookupList[ 0 ].name == nullptr ) { DEBUG_ASSERTCRASH( 0, ("INTERNAL ERROR! scanLookupList, invalid name list") ); throw INI_INVALID_NAME_LIST; @@ -1953,15 +1964,13 @@ void INI::parseSoundsList( INI* ini, void *instance, void *store, const void* /* //------------------------------------------------------------------------------------------------- void INI::parseDamageTypeFlags(INI* ini, void* /*instance*/, void* store, const void* /*userData*/) { - DamageTypeFlags flags = DAMAGE_TYPE_FLAGS_NONE; - flags.flip(); + DamageTypeFlags flags = DAMAGE_TYPE_FLAGS_ALL; for (const char* token = ini->getNextToken(); token; token = ini->getNextTokenOrNull()) { if (stricmp(token, "ALL") == 0) { - flags = DAMAGE_TYPE_FLAGS_NONE; - flags.flip(); + flags = DAMAGE_TYPE_FLAGS_ALL; continue; } if (stricmp(token, "NONE") == 0) diff --git a/Core/GameEngine/Source/Common/INI/INIAudioEventInfo.cpp b/Core/GameEngine/Source/Common/INI/INIAudioEventInfo.cpp index 6404e247c0b..140126f7662 100644 --- a/Core/GameEngine/Source/Common/INI/INIAudioEventInfo.cpp +++ b/Core/GameEngine/Source/Common/INI/INIAudioEventInfo.cpp @@ -129,26 +129,26 @@ static void parsePitchShift( INI* ini, void *instance, void *store, const void* //------------------------------------------------------------------------------------------------- const FieldParse AudioEventInfo::m_audioEventInfo[] = { - { "Filename", INI::parseAsciiString, NULL, offsetof( AudioEventInfo, m_filename) }, - { "Volume", INI::parsePercentToReal, NULL, offsetof( AudioEventInfo, m_volume ) }, - { "VolumeShift", INI::parsePercentToReal, NULL, offsetof( AudioEventInfo, m_volumeShift ) }, - { "MinVolume", INI::parsePercentToReal, NULL, offsetof( AudioEventInfo, m_minVolume ) }, - { "PitchShift", parsePitchShift, NULL, 0 }, - { "Delay", parseDelay, NULL, 0 }, - { "Limit", INI::parseInt, NULL, offsetof( AudioEventInfo, m_limit ) }, - { "LoopCount", INI::parseInt, NULL, offsetof( AudioEventInfo, m_loopCount ) }, + { "Filename", INI::parseAsciiString, nullptr, offsetof( AudioEventInfo, m_filename) }, + { "Volume", INI::parsePercentToReal, nullptr, offsetof( AudioEventInfo, m_volume ) }, + { "VolumeShift", INI::parsePercentToReal, nullptr, offsetof( AudioEventInfo, m_volumeShift ) }, + { "MinVolume", INI::parsePercentToReal, nullptr, offsetof( AudioEventInfo, m_minVolume ) }, + { "PitchShift", parsePitchShift, nullptr, 0 }, + { "Delay", parseDelay, nullptr, 0 }, + { "Limit", INI::parseInt, nullptr, offsetof( AudioEventInfo, m_limit ) }, + { "LoopCount", INI::parseInt, nullptr, offsetof( AudioEventInfo, m_loopCount ) }, { "Priority", INI::parseIndexList, theAudioPriorityNames, offsetof( AudioEventInfo, m_priority ) }, { "Type", INI::parseBitString32, theSoundTypeNames, offsetof( AudioEventInfo, m_type ) }, { "Control", INI::parseBitString32, theAudioControlNames, offsetof( AudioEventInfo, m_control ) }, - { "Sounds", INI::parseSoundsList, NULL, offsetof( AudioEventInfo, m_sounds ) }, - { "SoundsNight", INI::parseSoundsList, NULL, offsetof( AudioEventInfo, m_soundsNight ) }, - { "SoundsEvening", INI::parseSoundsList, NULL, offsetof( AudioEventInfo, m_soundsEvening ) }, - { "SoundsMorning", INI::parseSoundsList, NULL, offsetof( AudioEventInfo, m_soundsMorning ) }, - { "Attack", INI::parseSoundsList, NULL, offsetof( AudioEventInfo, m_attackSounds ) }, - { "Decay", INI::parseSoundsList, NULL, offsetof( AudioEventInfo, m_decaySounds ) }, - { "MinRange", INI::parseReal, NULL, offsetof( AudioEventInfo, m_minDistance) }, - { "MaxRange", INI::parseReal, NULL, offsetof( AudioEventInfo, m_maxDistance) }, - { "LowPassCutoff", INI::parsePercentToReal, NULL, offsetof( AudioEventInfo, m_lowPassFreq) }, + { "Sounds", INI::parseSoundsList, nullptr, offsetof( AudioEventInfo, m_sounds ) }, + { "SoundsNight", INI::parseSoundsList, nullptr, offsetof( AudioEventInfo, m_soundsNight ) }, + { "SoundsEvening", INI::parseSoundsList, nullptr, offsetof( AudioEventInfo, m_soundsEvening ) }, + { "SoundsMorning", INI::parseSoundsList, nullptr, offsetof( AudioEventInfo, m_soundsMorning ) }, + { "Attack", INI::parseSoundsList, nullptr, offsetof( AudioEventInfo, m_attackSounds ) }, + { "Decay", INI::parseSoundsList, nullptr, offsetof( AudioEventInfo, m_decaySounds ) }, + { "MinRange", INI::parseReal, nullptr, offsetof( AudioEventInfo, m_minDistance) }, + { "MaxRange", INI::parseReal, nullptr, offsetof( AudioEventInfo, m_maxDistance) }, + { "LowPassCutoff", INI::parsePercentToReal, nullptr, offsetof( AudioEventInfo, m_lowPassFreq) }, }; //------------------------------------------------------------------------------------------------- @@ -186,7 +186,7 @@ const char *const theAudioPriorityNames[] = "NORMAL", "HIGH", "CRITICAL", - NULL + nullptr }; static_assert(ARRAY_SIZE(theAudioPriorityNames) == AP_COUNT + 1, "Incorrect array size"); @@ -201,7 +201,7 @@ const char *const theSoundTypeNames[] = "ALLIES", "ENEMIES", "EVERYONE", - NULL + nullptr }; const char *const theAudioControlNames[] = @@ -212,6 +212,6 @@ const char *const theAudioControlNames[] = "POSTDELAY", "INTERRUPT", "STOPEARLY", - NULL + nullptr }; diff --git a/Core/GameEngine/Source/Common/INI/INIMiscAudio.cpp b/Core/GameEngine/Source/Common/INI/INIMiscAudio.cpp index 5a552591c2a..83b71e071ee 100644 --- a/Core/GameEngine/Source/Common/INI/INIMiscAudio.cpp +++ b/Core/GameEngine/Source/Common/INI/INIMiscAudio.cpp @@ -30,45 +30,45 @@ const FieldParse MiscAudio::m_fieldParseTable[] = { - { "RadarNotifyUnitUnderAttackSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_radarUnitUnderAttackSound ) }, - { "RadarNotifyHarvesterUnderAttackSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_radarHarvesterUnderAttackSound ) }, - { "RadarNotifyStructureUnderAttackSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_radarStructureUnderAttackSound ) }, - { "RadarNotifyUnderAttackSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_radarUnderAttackSound ) }, - { "RadarNotifyInfiltrationSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_radarInfiltrationSound ) }, - { "RadarNotifyOnlineSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_radarOnlineSound ) }, - { "RadarNotifyOfflineSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_radarOfflineSound ) }, - { "DefectorTimerTickSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_defectorTimerTickSound ) }, - { "DefectorTimerDingSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_defectorTimerDingSound ) }, - { "LockonTickSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_lockonTickSound ) }, - { "AllCheerSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_allCheerSound ) }, - { "BattleCrySound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_battleCrySound ) }, - { "GUIClickSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_guiClickSound ) }, - { "NoCanDoSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_noCanDoSound ) }, - { "StealthDiscoveredSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_stealthDiscoveredSound ) }, - { "StealthNeutralizedSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_stealthNeutralizedSound ) }, - { "MoneyDepositSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_moneyDepositSound ) }, - { "MoneyWithdrawSound", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_moneyWithdrawSound ) }, - { "BuildingDisabled", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_buildingDisabled ) }, - { "BuildingReenabled", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_buildingReenabled ) }, - { "VehicleDisabled", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_vehicleDisabled ) }, - { "VehicleReenabled", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_vehicleReenabled ) }, - { "SplatterVehiclePilotsBrain", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_splatterVehiclePilotsBrain ) }, - { "TerroristInCarMoveVoice", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_terroristInCarMoveVoice ) }, - { "TerroristInCarAttackVoice", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_terroristInCarAttackVoice ) }, - { "TerroristInCarSelectVoice", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_terroristInCarSelectVoice ) }, - { "CrateHeal", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_crateHeal ) }, - { "CrateShroud", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_crateShroud ) }, - { "CrateSalvage", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_crateSalvage ) }, - { "CrateFreeUnit", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_crateFreeUnit ) }, - { "CrateMoney", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_crateMoney ) }, - { "UnitPromoted", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_unitPromoted ) }, - { "RepairSparks", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_repairSparks ) }, - { "SabotageShutDownBuilding", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_sabotageShutDownBuilding ) }, - { "SabotageResetTimeBuilding", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_sabotageResetTimerBuilding ) }, - { "AircraftWheelScreech", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_aircraftWheelScreech ) }, - { "ChronoDisabledSoundAmbient", INI::parseAudioEventRTS, NULL, offsetof( MiscAudio, m_chronoDisabledSoundLoop) }, + { "RadarNotifyUnitUnderAttackSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_radarUnitUnderAttackSound ) }, + { "RadarNotifyHarvesterUnderAttackSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_radarHarvesterUnderAttackSound ) }, + { "RadarNotifyStructureUnderAttackSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_radarStructureUnderAttackSound ) }, + { "RadarNotifyUnderAttackSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_radarUnderAttackSound ) }, + { "RadarNotifyInfiltrationSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_radarInfiltrationSound ) }, + { "RadarNotifyOnlineSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_radarOnlineSound ) }, + { "RadarNotifyOfflineSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_radarOfflineSound ) }, + { "DefectorTimerTickSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_defectorTimerTickSound ) }, + { "DefectorTimerDingSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_defectorTimerDingSound ) }, + { "LockonTickSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_lockonTickSound ) }, + { "AllCheerSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_allCheerSound ) }, + { "BattleCrySound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_battleCrySound ) }, + { "GUIClickSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_guiClickSound ) }, + { "NoCanDoSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_noCanDoSound ) }, + { "StealthDiscoveredSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_stealthDiscoveredSound ) }, + { "StealthNeutralizedSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_stealthNeutralizedSound ) }, + { "MoneyDepositSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_moneyDepositSound ) }, + { "MoneyWithdrawSound", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_moneyWithdrawSound ) }, + { "BuildingDisabled", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_buildingDisabled ) }, + { "BuildingReenabled", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_buildingReenabled ) }, + { "VehicleDisabled", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_vehicleDisabled ) }, + { "VehicleReenabled", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_vehicleReenabled ) }, + { "SplatterVehiclePilotsBrain", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_splatterVehiclePilotsBrain ) }, + { "TerroristInCarMoveVoice", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_terroristInCarMoveVoice ) }, + { "TerroristInCarAttackVoice", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_terroristInCarAttackVoice ) }, + { "TerroristInCarSelectVoice", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_terroristInCarSelectVoice ) }, + { "CrateHeal", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_crateHeal ) }, + { "CrateShroud", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_crateShroud ) }, + { "CrateSalvage", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_crateSalvage ) }, + { "CrateFreeUnit", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_crateFreeUnit ) }, + { "CrateMoney", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_crateMoney ) }, + { "UnitPromoted", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_unitPromoted ) }, + { "RepairSparks", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_repairSparks ) }, + { "SabotageShutDownBuilding", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_sabotageShutDownBuilding ) }, + { "SabotageResetTimeBuilding", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_sabotageResetTimerBuilding ) }, + { "AircraftWheelScreech", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_aircraftWheelScreech ) }, + { "ChronoDisabledSoundAmbient", INI::parseAudioEventRTS, nullptr, offsetof( MiscAudio, m_chronoDisabledSoundLoop) }, - { 0, 0, 0, 0 } + { nullptr, nullptr, nullptr, 0 } }; diff --git a/Core/GameEngine/Source/Common/RandomValue.cpp b/Core/GameEngine/Source/Common/RandomValue.cpp index f1c00982a86..0628c245eef 100644 --- a/Core/GameEngine/Source/Common/RandomValue.cpp +++ b/Core/GameEngine/Source/Common/RandomValue.cpp @@ -157,7 +157,7 @@ void InitRandom( void ) seedRandom(0, theGameLogicSeed); theGameLogicBaseSeed = 0; #else - time_t seconds = time( NULL ); + time_t seconds = time( nullptr ); seedRandom(seconds, theGameAudioSeed); seedRandom(seconds, theGameClientSeed); @@ -228,6 +228,37 @@ DEBUG_LOG(( "%d: GetGameLogicRandomValue = %d (%d - %d), %s line %d", return rval; } +// +// TheSuperHackers @info This function does not change the seed values with retail compatibility disabled. +// Consecutive calls always return the same value for the same combination of min / max values, assuming the seed values haven't changed in between. +// The intended use case for this function are randomized values that are desirable to be synchronized across clients, +// but should not result in a mismatch if they aren't synchronized; e.g. for scripted audio events. +// +Int GetGameLogicRandomValueUnchanged( int lo, int hi, const char *file, int line ) +{ +#if RETAIL_COMPATIBLE_CRC + return GetGameLogicRandomValue(lo, hi, file, line); +#endif + + const UnsignedInt delta = hi - lo + 1; + if (delta == 0) + return hi; + + UnsignedInt seed[ARRAY_SIZE(theGameLogicSeed)]; + memcpy(&seed[0], &theGameLogicSeed[0], sizeof(seed)); + + const Int rval = ((Int)(randomValue(seed) % delta)) + lo; + + DEBUG_ASSERTCRASH(rval >= lo && rval <= hi, ("Bad random val")); + +#ifdef DEBUG_RANDOM_LOGIC + DEBUG_LOG(( "%d: GetGameLogicRandomValueUnchanged = %d (%d - %d), %s line %d", + TheGameLogic->getFrame(), rval, lo, hi, file, line )); +#endif + + return rval; +} + // // Integer random value // @@ -298,6 +329,37 @@ DEBUG_LOG(( "%d: GetGameLogicRandomValueReal = %f, %s line %d", return rval; } +// +// TheSuperHackers @info This function does not change the seed values with retail compatibility disabled. +// Consecutive calls always return the same value for the same combination of min / max values, assuming the seed values haven't changed in between. +// The intended use case for this function are randomized values that are desirable to be synchronized across clients, +// but should not result in a mismatch if they aren't synchronized; e.g. for scripted audio events. +// +Real GetGameLogicRandomValueRealUnchanged( Real lo, Real hi, const char *file, int line ) +{ +#if RETAIL_COMPATIBLE_CRC + return GetGameLogicRandomValueReal(lo, hi, file, line); +#endif + + const Real delta = hi - lo; + if (delta <= 0.0f) + return hi; + + UnsignedInt seed[ARRAY_SIZE(theGameLogicSeed)]; + memcpy(&seed[0], &theGameLogicSeed[0], sizeof(seed)); + + const Real rval = ((Real)(randomValue(seed)) * theMultFactor) * delta + lo; + + DEBUG_ASSERTCRASH(rval >= lo && rval <= hi, ("Bad random val")); + +#ifdef DEBUG_RANDOM_LOGIC + DEBUG_LOG(( "%d: GetGameLogicRandomValueRealUnchanged = %f, %s line %d", + TheGameLogic->getFrame(), rval, file, line )); +#endif + + return rval; +} + // // Real valued random value // @@ -352,7 +414,7 @@ DEBUG_LOG(( "%d: GetGameAudioRandomValueReal = %f, %s line %d", const char *const GameClientRandomVariable::DistributionTypeNames[] = { - "CONSTANT", "UNIFORM", "GAUSSIAN", "TRIANGULAR", "LOW_BIAS", "HIGH_BIAS", NULL + "CONSTANT", "UNIFORM", "GAUSSIAN", "TRIANGULAR", "LOW_BIAS", "HIGH_BIAS", nullptr }; static_assert(ARRAY_SIZE(GameClientRandomVariable::DistributionTypeNames) == GameClientRandomVariable::DISTRIBUTION_COUNT + 1, "Incorrect array size"); @@ -398,7 +460,7 @@ Real GameClientRandomVariable::getValue( void ) const const char *const GameLogicRandomVariable::DistributionTypeNames[] = { - "CONSTANT", "UNIFORM", "GAUSSIAN", "TRIANGULAR", "LOW_BIAS", "HIGH_BIAS", NULL + "CONSTANT", "UNIFORM", "GAUSSIAN", "TRIANGULAR", "LOW_BIAS", "HIGH_BIAS", nullptr }; static_assert(ARRAY_SIZE(GameLogicRandomVariable::DistributionTypeNames) == GameLogicRandomVariable::DISTRIBUTION_COUNT + 1, "Incorrect array size"); diff --git a/Core/GameEngine/Source/Common/ReplaySimulation.cpp b/Core/GameEngine/Source/Common/ReplaySimulation.cpp index 354925c8fcd..7d18b5cb58f 100644 --- a/Core/GameEngine/Source/Common/ReplaySimulation.cpp +++ b/Core/GameEngine/Source/Common/ReplaySimulation.cpp @@ -134,7 +134,7 @@ int ReplaySimulation::simulateReplaysInWorkerProcesses(const std::vector processes; int filenamePositionStarted = 0; diff --git a/Core/GameEngine/Source/Common/System/ArchiveFile.cpp b/Core/GameEngine/Source/Common/System/ArchiveFile.cpp index c10b42754cf..1f982b65a1d 100644 --- a/Core/GameEngine/Source/Common/System/ArchiveFile.cpp +++ b/Core/GameEngine/Source/Common/System/ArchiveFile.cpp @@ -39,13 +39,13 @@ // and ? is used to denote a single wildcard character. static Bool SearchStringMatches(AsciiString str, AsciiString searchString) { - if (str.getLength() == 0) { - if (searchString.getLength() == 0) { + if (str.isEmpty()) { + if (searchString.isEmpty()) { return TRUE; } return FALSE; } - if (searchString.getLength() == 0) { + if (searchString.isEmpty()) { return FALSE; } @@ -83,14 +83,14 @@ static Bool SearchStringMatches(AsciiString str, AsciiString searchString) ArchiveFile::~ArchiveFile() { - if (m_file != NULL) { + if (m_file != nullptr) { m_file->close(); - m_file = NULL; + m_file = nullptr; } } ArchiveFile::ArchiveFile() - : m_file(NULL) + : m_file(nullptr) { } @@ -103,7 +103,7 @@ void ArchiveFile::addFile(const AsciiString& path, const ArchivedFileInfo *fileI tokenizer.toLower(); tokenizer.nextToken(&token, "\\/"); - while (token.getLength() > 0) + while (!token.isEmpty()) { DetailedArchivedDirectoryInfoMap::iterator tempiter = dirInfo->m_directories.find(token); if (tempiter == dirInfo->m_directories.end()) @@ -131,7 +131,7 @@ void ArchiveFile::getFileListInDirectory(const AsciiString& currentDirectory, co tokenizer.toLower(); tokenizer.nextToken(&token, "\\/"); - while (token.getLength() > 0) { + while (!token.isEmpty()) { DetailedArchivedDirectoryInfoMap::const_iterator it = dirInfo->m_directories.find(token); if (it != dirInfo->m_directories.end()) @@ -157,7 +157,7 @@ void ArchiveFile::getFileListInDirectory(const DetailedArchivedDirectoryInfo *di const DetailedArchivedDirectoryInfo *tempDirInfo = &(diriter->second); AsciiString tempdirname; tempdirname = currentDirectory; - if ((tempdirname.getLength() > 0) && (!tempdirname.endsWith("\\"))) { + if ((!tempdirname.isEmpty()) && (!tempdirname.endsWith("\\"))) { tempdirname.concat('\\'); } tempdirname.concat(tempDirInfo->m_directoryName); @@ -170,7 +170,7 @@ void ArchiveFile::getFileListInDirectory(const DetailedArchivedDirectoryInfo *di if (SearchStringMatches(fileiter->second.m_filename, searchName)) { AsciiString tempfilename; tempfilename = currentDirectory; - if ((tempfilename.getLength() > 0) && (!tempfilename.endsWith("\\"))) { + if ((!tempfilename.isEmpty()) && (!tempfilename.endsWith("\\"))) { tempfilename.concat('\\'); } tempfilename.concat(fileiter->second.m_filename); @@ -185,9 +185,9 @@ void ArchiveFile::getFileListInDirectory(const DetailedArchivedDirectoryInfo *di void ArchiveFile::attachFile(File *file) { - if (m_file != NULL) { + if (m_file != nullptr) { m_file->close(); - m_file = NULL; + m_file = nullptr; } m_file = file; } @@ -210,7 +210,7 @@ const ArchivedFileInfo * ArchiveFile::getArchivedFileInfo(const AsciiString& fil } else { - return NULL; + return nullptr; } tokenizer.nextToken(&token, "\\/"); @@ -223,7 +223,7 @@ const ArchivedFileInfo * ArchiveFile::getArchivedFileInfo(const AsciiString& fil } else { - return NULL; + return nullptr; } } diff --git a/Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp b/Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp index 1d8223a014c..77e9fde8df5 100644 --- a/Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp +++ b/Core/GameEngine/Source/Common/System/ArchiveFileSystem.cpp @@ -79,7 +79,7 @@ // Public Data //---------------------------------------------------------------------------- -ArchiveFileSystem *TheArchiveFileSystem = NULL; +ArchiveFileSystem *TheArchiveFileSystem = nullptr; //---------------------------------------------------------------------------- @@ -216,7 +216,7 @@ void ArchiveFileSystem::loadMods() { ArchiveFile *archiveFile = openArchiveFile(TheGlobalData->m_modBIG.str()); - if (archiveFile != NULL) { + if (archiveFile != nullptr) { DEBUG_LOG(("ArchiveFileSystem::loadMods - loading %s into the directory tree.", TheGlobalData->m_modBIG.str())); loadIntoDirectoryTree(archiveFile, TRUE); m_archiveFileMap[TheGlobalData->m_modBIG] = archiveFile; @@ -278,7 +278,7 @@ ArchiveFileSystem::ArchivedDirectoryInfoResult ArchiveFileSystem::getArchivedDir else { // the directory doesn't exist - result.dirInfo = NULL; + result.dirInfo = nullptr; result.lastToken = AsciiString::TheEmptyString; return result; } @@ -293,25 +293,25 @@ File * ArchiveFileSystem::openFile(const Char *filename, Int access, FileInstanc { ArchiveFile* archive = getArchiveFile(filename, instance); - if (archive == NULL) - return NULL; + if (archive == nullptr) + return nullptr; return archive->openFile(filename, access); } Bool ArchiveFileSystem::getFileInfo(const AsciiString& filename, FileInfo *fileInfo, FileInstance instance) const { - if (fileInfo == NULL) { + if (fileInfo == nullptr) { return FALSE; } - if (filename.getLength() <= 0) { + if (filename.isEmpty()) { return FALSE; } ArchiveFile* archive = getArchiveFile(filename, instance); - if (archive == NULL) + if (archive == nullptr) return FALSE; return archive->getFileInfo(filename, fileInfo); @@ -322,12 +322,12 @@ ArchiveFile* ArchiveFileSystem::getArchiveFile(const AsciiString& filename, File ArchivedDirectoryInfoResult result = const_cast(this)->getArchivedDirectoryInfo(filename.str()); if (!result.valid()) - return NULL; + return nullptr; stl::const_range range = stl::get_range(result.dirInfo->m_files, result.lastToken, instance); if (!range.valid()) - return NULL; + return nullptr; return range.get()->second; } diff --git a/Core/GameEngine/Source/Common/System/AsciiString.cpp b/Core/GameEngine/Source/Common/System/AsciiString.cpp index 31567ec5335..533ccd5ccf3 100644 --- a/Core/GameEngine/Source/Common/System/AsciiString.cpp +++ b/Core/GameEngine/Source/Common/System/AsciiString.cpp @@ -54,7 +54,7 @@ //----------------------------------------------------------------------------- inline char* skipSeps(char* p, const char* seps) { - while (*p && strchr(seps, *p) != NULL) + while (*p && strchr(seps, *p) != nullptr) ++p; return p; } @@ -62,7 +62,7 @@ inline char* skipSeps(char* p, const char* seps) //----------------------------------------------------------------------------- inline char* skipNonSeps(char* p, const char* seps) { - while (*p && strchr(seps, *p) == NULL) + while (*p && strchr(seps, *p) == nullptr) ++p; return p; } @@ -144,7 +144,7 @@ void AsciiString::ensureUniqueBufferOfSize(int numCharsNeeded, Bool preserveData return; } - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("Cannot use dynamic memory allocator before its initialization. Check static initialization order.")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("Cannot use dynamic memory allocator before its initialization. Check static initialization order.")); DEBUG_ASSERTCRASH(numCharsNeeded <= MAX_LEN, ("AsciiString::ensureUniqueBufferOfSize exceeds max string length %d with requested length %d", MAX_LEN, numCharsNeeded)); int minBytes = sizeof(AsciiStringData) + numCharsNeeded*sizeof(char); int actualBytes = TheDynamicMemoryAllocator->getActualAllocationSize(minBytes); @@ -190,29 +190,29 @@ void AsciiString::releaseBuffer() { TheDynamicMemoryAllocator->freeBytes(m_data); } - m_data = 0; + m_data = nullptr; } validate(); } // ----------------------------------------------------- -AsciiString::AsciiString(const char* s) : m_data(NULL) +AsciiString::AsciiString(const char* s) : m_data(nullptr) { //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 ? (int)strlen(s) : 0; if (len > 0) { - ensureUniqueBufferOfSize(len + 1, false, s, NULL); + ensureUniqueBufferOfSize(len + 1, false, s, nullptr); } validate(); } // ----------------------------------------------------- -AsciiString::AsciiString(const char* s, int len) : m_data(NULL) +AsciiString::AsciiString(const char* s, int len) : m_data(nullptr) { if (len > 0) { - ensureUniqueBufferOfSize(len + 1, false, s, NULL); + ensureUniqueBufferOfSize(len + 1, false, s, nullptr); } validate(); } @@ -248,7 +248,7 @@ void AsciiString::set(const char* s, int len) { if (len > 0) { - ensureUniqueBufferOfSize(len + 1, false, s, NULL); + ensureUniqueBufferOfSize(len + 1, false, s, nullptr); } else { @@ -263,7 +263,7 @@ char* AsciiString::getBufferForRead(Int len) { validate(); DEBUG_ASSERTCRASH(len>0, ("No need to allocate 0 len strings.")); - ensureUniqueBufferOfSize(len + 1, false, NULL, NULL); + ensureUniqueBufferOfSize(len + 1, false, nullptr, nullptr); validate(); return peek(); } @@ -290,7 +290,7 @@ void AsciiString::concat(const char* s) if (m_data) { - ensureUniqueBufferOfSize(getLength() + addlen + 1, true, NULL, s); + ensureUniqueBufferOfSize(getLength() + addlen + 1, true, nullptr, s); } else { @@ -350,7 +350,7 @@ void AsciiString::trimEnd(const char c) if (m_data) { - // Clip trailing consecutive occurances of c from the string. + // Clip trailing consecutive occurrences of c from the string. const int len = strlen(peek()); int index = len; while (index > 0 && getCharAt(index - 1) == c) @@ -401,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, nullptr, nullptr); size_t count = charCount; if (charCount > len) { @@ -422,7 +422,7 @@ void AsciiString::truncateTo(const Int maxLength) const size_t len = strlen(peek()); if (len > maxLength) { - ensureUniqueBufferOfSize(len + 1, true, NULL, NULL); + ensureUniqueBufferOfSize(len + 1, true, nullptr, nullptr); peek()[maxLength] = 0; } } @@ -510,7 +510,7 @@ Bool AsciiString::nextToken(AsciiString* tok, const char* seps) if (this->isEmpty() || tok == this) return false; - if (seps == NULL) + if (seps == nullptr) seps = " \n\r\t"; char* start = skipSeps(peek(), seps); diff --git a/Core/GameEngine/Source/Common/System/Debug.cpp b/Core/GameEngine/Source/Common/System/Debug.cpp index 33ddbff4606..a78085fcdaa 100644 --- a/Core/GameEngine/Source/Common/System/Debug.cpp +++ b/Core/GameEngine/Source/Common/System/Debug.cpp @@ -107,7 +107,7 @@ extern const char *gAppPrefix; /// So WB can have a different log file name. // TheSuperHackers @info Must not use static RAII types when set in DebugInit, // because DebugInit can be called during static module initialization before the main function is called. #ifdef DEBUG_LOGGING -static FILE *theLogFile = NULL; +static FILE *theLogFile = nullptr; static char theLogFileName[ _MAX_PATH ]; static char theLogFileNamePrev[ _MAX_PATH ]; #endif @@ -119,7 +119,7 @@ static DWORD theMainThreadID = 0; // PUBLIC DATA // ---------------------------------------------------------------------------- -char* TheCurrentIgnoreCrashPtr = NULL; +char* TheCurrentIgnoreCrashPtr = nullptr; #ifdef DEBUG_LOGGING UnsignedInt DebugLevelMask = 0; const char *TheDebugLevels[DEBUG_LEVEL_MAX] = { @@ -167,7 +167,7 @@ inline Bool ignoringAsserts() // ---------------------------------------------------------------------------- inline HWND getThreadHWND() { - return (theMainThreadID == GetCurrentThreadId())?ApplicationHWnd:NULL; + return (theMainThreadID == GetCurrentThreadId())?ApplicationHWnd:nullptr; } // ---------------------------------------------------------------------------- @@ -359,7 +359,7 @@ static void whackFunnyCharacters(char *buf) void DebugInit(int flags) { // if (theDebugFlags != 0) -// ::MessageBox(NULL, "Debug already inited", "", MB_OK|MB_APPLMODAL); +// ::MessageBox(nullptr, "Debug already inited", "", MB_OK|MB_APPLMODAL); // just quietly allow multiple calls to this, so that static ctors can call it. if (theDebugFlags == 0) @@ -378,7 +378,7 @@ void DebugInit(int flags) return; char dirbuf[ _MAX_PATH ]; - ::GetModuleFileName( NULL, dirbuf, sizeof( dirbuf ) ); + ::GetModuleFileName( nullptr, dirbuf, sizeof( dirbuf ) ); if (char *pEnd = strrchr(dirbuf, '\\')) { *(pEnd + 1) = 0; @@ -421,7 +421,7 @@ void DebugInit(int flags) } theLogFile = fopen(theLogFileName, "w"); - if (theLogFile != NULL) + if (theLogFile != nullptr) { DebugLog("Log %s opened: %s", theLogFileName, getCurrentTimeString()); } @@ -553,7 +553,7 @@ void DebugCrash(const char *format, ...) const int result = doCrashBox(theCrashBuffer, useLogging); - if (result == IDIGNORE && TheCurrentIgnoreCrashPtr != NULL) + if (result == IDIGNORE && TheCurrentIgnoreCrashPtr != nullptr) { int yn; if (!ignoringAsserts()) @@ -592,7 +592,7 @@ void DebugShutdown() DebugLog("Log closed: %s", getCurrentTimeString()); fclose(theLogFile); } - theLogFile = NULL; + theLogFile = nullptr; #endif theDebugFlags = 0; } @@ -719,7 +719,7 @@ double SimpleProfiler::getAverageTime() #define RELEASECRASH_FILE_NAME "ReleaseCrashInfo.txt" #define RELEASECRASH_FILE_NAME_PREV "ReleaseCrashInfoPrev.txt" - static FILE *theReleaseCrashLogFile = NULL; + static FILE *theReleaseCrashLogFile = nullptr; static void releaseCrashLogOutput(const char *buffer) { @@ -761,7 +761,7 @@ void ReleaseCrash(const char *reason) char prevbuf[ _MAX_PATH ]; char curbuf[ _MAX_PATH ]; - if (TheGlobalData==NULL) { + if (TheGlobalData==nullptr) { return; // We are shutting down, and TheGlobalData has been freed. jba. [4/15/2003] } @@ -797,7 +797,7 @@ void ReleaseCrash(const char *reason) fflush(theReleaseCrashLogFile); fclose(theReleaseCrashLogFile); - theReleaseCrashLogFile = NULL; + theReleaseCrashLogFile = nullptr; } if (!DX8Wrapper_IsWindowed) { @@ -809,14 +809,14 @@ void ReleaseCrash(const char *reason) #if defined(RTS_DEBUG) /* static */ char buff[8192]; // not so static so we can be threadsafe snprintf(buff, 8192, "Sorry, a serious error occurred. (%s)", reason); - ::MessageBox(NULL, buff, "Technical Difficulties...", MB_OK|MB_SYSTEMMODAL|MB_ICONERROR); + ::MessageBox(nullptr, buff, "Technical Difficulties...", MB_OK|MB_SYSTEMMODAL|MB_ICONERROR); #else // crash error messaged changed 3/6/03 BGC -// ::MessageBox(NULL, "Sorry, a serious error occurred.", "Technical Difficulties...", MB_OK|MB_TASKMODAL|MB_ICONERROR); -// ::MessageBox(NULL, "You have encountered a serious error. Serious errors can be caused by many things including viruses, overheated hardware and hardware that does not meet the minimum specifications for the game. Please visit the forums at www.generals.ea.com for suggested courses of action or consult your manual for Technical Support contact information.", "Technical Difficulties...", MB_OK|MB_TASKMODAL|MB_ICONERROR); +// ::MessageBox(nullptr, "Sorry, a serious error occurred.", "Technical Difficulties...", MB_OK|MB_TASKMODAL|MB_ICONERROR); +// ::MessageBox(nullptr, "You have encountered a serious error. Serious errors can be caused by many things including viruses, overheated hardware and hardware that does not meet the minimum specifications for the game. Please visit the forums at www.generals.ea.com for suggested courses of action or consult your manual for Technical Support contact information.", "Technical Difficulties...", MB_OK|MB_TASKMODAL|MB_ICONERROR); // crash error message changed again 8/22/03 M Lorenzen... made this message box modal to the system so it will appear on top of any task-modal windows, splash-screen, etc. - ::MessageBox(NULL, "You have encountered a serious error. Serious errors can be caused by many things including viruses, overheated hardware and hardware that does not meet the minimum specifications for the game. Please visit the forums at www.generals.ea.com for suggested courses of action or consult your manual for Technical Support contact information.", + ::MessageBox(nullptr, "You have encountered a serious error. Serious errors can be caused by many things including viruses, overheated hardware and hardware that does not meet the minimum specifications for the game. Please visit the forums at www.generals.ea.com for suggested courses of action or consult your manual for Technical Support contact information.", "Technical Difficulties...", MB_OK|MB_SYSTEMMODAL|MB_ICONERROR); @@ -850,7 +850,7 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m) if (TheSystemIsUnicode) { - ::MessageBoxW(NULL, mesg.str(), prompt.str(), MB_OK|MB_SYSTEMMODAL|MB_ICONERROR); + ::MessageBoxW(nullptr, mesg.str(), prompt.str(), MB_OK|MB_SYSTEMMODAL|MB_ICONERROR); } else { @@ -861,7 +861,7 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m) mesgA.translate(mesg); //Make sure main window is not TOP_MOST ::SetWindowPos(ApplicationHWnd, HWND_NOTOPMOST, 0, 0, 0, 0,SWP_NOSIZE |SWP_NOMOVE); - ::MessageBoxA(NULL, mesgA.str(), promptA.str(), MB_OK|MB_TASKMODAL|MB_ICONERROR); + ::MessageBoxA(nullptr, mesgA.str(), promptA.str(), MB_OK|MB_TASKMODAL|MB_ICONERROR); } char prevbuf[ _MAX_PATH ]; @@ -899,7 +899,7 @@ void ReleaseCrashLocalized(const AsciiString& p, const AsciiString& m) fflush(theReleaseCrashLogFile); fclose(theReleaseCrashLogFile); - theReleaseCrashLogFile = NULL; + theReleaseCrashLogFile = nullptr; } _exit(1); diff --git a/Core/GameEngine/Source/Common/System/FileSystem.cpp b/Core/GameEngine/Source/Common/System/FileSystem.cpp index 46d468d4a05..bcb4e5ce032 100644 --- a/Core/GameEngine/Source/Common/System/FileSystem.cpp +++ b/Core/GameEngine/Source/Common/System/FileSystem.cpp @@ -50,7 +50,6 @@ #include "Common/FileSystem.h" #include "Common/ArchiveFileSystem.h" -#include "Common/CDManager.h" #include "Common/GameAudio.h" #include "Common/LocalFileSystem.h" #include "Common/PerfTimer.h" @@ -101,7 +100,7 @@ DECLARE_PERF_TIMER(FileSystem) */ //=============================== -FileSystem *TheFileSystem = NULL; +FileSystem *TheFileSystem = nullptr; //---------------------------------------------------------------------------- // Private Prototypes @@ -174,9 +173,9 @@ void FileSystem::reset( void ) File* FileSystem::openFile( const Char *filename, Int access, size_t bufferSize, FileInstance instance ) { USE_PERF_TIMER(FileSystem) - File *file = NULL; + File *file = nullptr; - if ( TheLocalFileSystem != NULL ) + if ( TheLocalFileSystem != nullptr ) { if (instance != 0) { @@ -190,7 +189,7 @@ File* FileSystem::openFile( const Char *filename, Int access, size_t bufferSize file = TheLocalFileSystem->openFile( filename, access, bufferSize ); #if ENABLE_FILESYSTEM_EXISTENCE_CACHE - if (file != NULL && (file->getAccess() & File::CREATE)) + if (file != nullptr && (file->getAccess() & File::CREATE)) { FastCriticalSectionClass::LockClass lock(m_fileExistMutex); FileExistMap::iterator it = m_fileExist.find(FileExistMap::key_type::temporary(filename)); @@ -209,7 +208,7 @@ File* FileSystem::openFile( const Char *filename, Int access, size_t bufferSize } } - if ( (TheArchiveFileSystem != NULL) && (file == NULL) ) + if ( (TheArchiveFileSystem != nullptr) && (file == nullptr) ) { // TheSuperHackers @todo Pass 'access' here? file = TheArchiveFileSystem->openFile( filename, 0, instance ); @@ -298,7 +297,7 @@ Bool FileSystem::getFileInfo(const AsciiString& filename, FileInfo *fileInfo, Fi // TheSuperHackers @todo Add file info cache? - if (fileInfo == NULL) { + if (fileInfo == nullptr) { return FALSE; } memset(fileInfo, 0, sizeof(*fileInfo)); @@ -324,90 +323,12 @@ Bool FileSystem::getFileInfo(const AsciiString& filename, FileInfo *fileInfo, Fi Bool FileSystem::createDirectory(AsciiString directory) { USE_PERF_TIMER(FileSystem) - if (TheLocalFileSystem != NULL) { + if (TheLocalFileSystem != nullptr) { return TheLocalFileSystem->createDirectory(directory); } return FALSE; } -//============================================================================ -// FileSystem::areMusicFilesOnCD -//============================================================================ -Bool FileSystem::areMusicFilesOnCD() -{ -#if 1 - return TRUE; -#else - if (!TheCDManager) { - DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - No CD Manager; returning false")); - return FALSE; - } - - AsciiString cdRoot; - Int dc = TheCDManager->driveCount(); - for (Int i = 0; i < dc; ++i) { - DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - checking drive %d", i)); - CDDriveInterface *cdi = TheCDManager->getDrive(i); - if (!cdi) { - continue; - } - - cdRoot = cdi->getPath(); - if (!cdRoot.endsWith("\\")) - cdRoot.concat("\\"); -#if RTS_GENERALS - cdRoot.concat("gensec.big"); -#elif RTS_ZEROHOUR - cdRoot.concat("genseczh.big"); -#endif - DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - checking for %s", cdRoot.str())); - File *musicBig = TheLocalFileSystem->openFile(cdRoot.str()); - if (musicBig) - { - DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - found it!")); - musicBig->close(); - return TRUE; - } - } - return FALSE; -#endif -} -//============================================================================ -// FileSystem::loadMusicFilesFromCD -//============================================================================ -void FileSystem::loadMusicFilesFromCD() -{ - if (!TheCDManager) { - return; - } - - AsciiString cdRoot; - Int dc = TheCDManager->driveCount(); - for (Int i = 0; i < dc; ++i) { - CDDriveInterface *cdi = TheCDManager->getDrive(i); - if (!cdi) { - continue; - } - - cdRoot = cdi->getPath(); - if (TheArchiveFileSystem->loadBigFilesFromDirectory(cdRoot, MUSIC_BIG)) { - break; - } - } -} - -//============================================================================ -// FileSystem::unloadMusicFilesFromCD -//============================================================================ -void FileSystem::unloadMusicFilesFromCD() -{ - if (!(TheAudio && TheAudio->isMusicPlayingFromCD())) { - return; - } - - TheArchiveFileSystem->closeArchiveFile( MUSIC_BIG ); -} - //============================================================================ // FileSystem::normalizePath //============================================================================ diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/GameCommon.cpp b/Core/GameEngine/Source/Common/System/GameCommon.cpp similarity index 99% rename from GeneralsMD/Code/GameEngine/Source/Common/System/GameCommon.cpp rename to Core/GameEngine/Source/Common/System/GameCommon.cpp index 6d32e39f3e6..50a9066cdb6 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/GameCommon.cpp +++ b/Core/GameEngine/Source/Common/System/GameCommon.cpp @@ -36,7 +36,7 @@ const char *const TheVeterancyNames[] = "VETERAN", "ELITE", "HEROIC", - NULL + nullptr }; static_assert(ARRAY_SIZE(TheVeterancyNames) == LEVEL_COUNT + 1, "Incorrect array size"); @@ -45,7 +45,7 @@ const char *const TheRelationshipNames[] = "ENEMIES", "NEUTRAL", "ALLIES", - NULL + nullptr }; static_assert(ARRAY_SIZE(TheRelationshipNames) == RELATIONSHIP_COUNT + 1, "Incorrect array size"); diff --git a/Core/GameEngine/Source/Common/System/GameMemory.cpp b/Core/GameEngine/Source/Common/System/GameMemory.cpp index 2ede5c780b9..5c70904eb95 100644 --- a/Core/GameEngine/Source/Common/System/GameMemory.cpp +++ b/Core/GameEngine/Source/Common/System/GameMemory.cpp @@ -397,7 +397,7 @@ class MemoryPoolSingleBlock { private: - MemoryPoolBlob *m_owningBlob; ///< will be NULL if the single block was allocated via sysAllocate() + MemoryPoolBlob *m_owningBlob; ///< will be null if the single block was allocated via sysAllocate() MemoryPoolSingleBlock *m_nextBlock; ///< if m_owningBlob is nonnull, this points to next free (unallocated) block in the blob; if m_owningBlob is null, this points to the next used (allocated) raw block in the pool. #ifdef MPSB_DLINK MemoryPoolSingleBlock *m_prevBlock; ///< if m_owningBlob is nonnull, this points to prev free (unallocated) block in the blob; if m_owningBlob is null, this points to the prev used (allocated) raw block in the pool. @@ -508,8 +508,8 @@ class MemoryPoolBlob // PUBLIC DATA // ---------------------------------------------------------------------------- -MemoryPoolFactory *TheMemoryPoolFactory = NULL; -DynamicMemoryAllocator *TheDynamicMemoryAllocator = NULL; +MemoryPoolFactory *TheMemoryPoolFactory = nullptr; +DynamicMemoryAllocator *TheDynamicMemoryAllocator = nullptr; // ---------------------------------------------------------------------------- // INLINES @@ -578,7 +578,7 @@ inline MemoryPoolBlob *MemoryPoolSingleBlock::getOwningBlob() */ inline MemoryPoolSingleBlock *MemoryPoolSingleBlock::getNextFreeBlock() { - DEBUG_ASSERTCRASH(m_owningBlob != NULL, ("must be called on blob block")); + DEBUG_ASSERTCRASH(m_owningBlob != nullptr, ("must be called on blob block")); return m_nextBlock; } @@ -589,9 +589,9 @@ inline MemoryPoolSingleBlock *MemoryPoolSingleBlock::getNextFreeBlock() */ inline void MemoryPoolSingleBlock::setNextFreeBlock(MemoryPoolSingleBlock *b) { - //DEBUG_ASSERTCRASH(m_owningBlob != NULL && b->m_owningBlob != NULL, ("must be called on blob block")); + //DEBUG_ASSERTCRASH(m_owningBlob != nullptr && b->m_owningBlob != nullptr, ("must be called on blob block")); // don't check the 'b' block -- we need to call this before 'b' is fully initialized. - DEBUG_ASSERTCRASH(m_owningBlob != NULL, ("must be called on blob block")); + DEBUG_ASSERTCRASH(m_owningBlob != nullptr, ("must be called on blob block")); this->m_nextBlock = b; #ifdef MPSB_DLINK if (b) { @@ -606,7 +606,7 @@ inline void MemoryPoolSingleBlock::setNextFreeBlock(MemoryPoolSingleBlock *b) */ inline MemoryPoolSingleBlock *MemoryPoolSingleBlock::getNextRawBlock() { - DEBUG_ASSERTCRASH(m_owningBlob == NULL, ("must be called on raw block")); + DEBUG_ASSERTCRASH(m_owningBlob == nullptr, ("must be called on raw block")); return m_nextBlock; } @@ -616,7 +616,7 @@ inline MemoryPoolSingleBlock *MemoryPoolSingleBlock::getNextRawBlock() */ inline void MemoryPoolSingleBlock::setNextRawBlock(MemoryPoolSingleBlock *b) { - DEBUG_ASSERTCRASH(m_owningBlob == NULL && (!b || b->m_owningBlob == NULL), ("must be called on raw block")); + DEBUG_ASSERTCRASH(m_owningBlob == nullptr && (!b || b->m_owningBlob == nullptr), ("must be called on raw block")); m_nextBlock = b; #ifdef MPSB_DLINK if (b) @@ -686,7 +686,7 @@ inline BlockCheckpointInfo *MemoryPoolSingleBlock::debugGetCheckpointInfo() */ inline void MemoryPoolSingleBlock::debugSetCheckpointInfo(BlockCheckpointInfo *bi) { - DEBUG_ASSERTCRASH(m_checkpointInfo == NULL, ("should be null")); + DEBUG_ASSERTCRASH(m_checkpointInfo == nullptr, ("should be null")); m_checkpointInfo = bi; } #endif @@ -698,7 +698,7 @@ inline void MemoryPoolSingleBlock::debugSetCheckpointInfo(BlockCheckpointInfo *b */ inline void MemoryPoolSingleBlock::debugResetCheckpoint() { - m_checkpointInfo = NULL; + m_checkpointInfo = nullptr; } #endif @@ -706,7 +706,7 @@ inline void MemoryPoolSingleBlock::debugResetCheckpoint() /// accessor inline MemoryPoolBlob *MemoryPoolBlob::getNextInList() { return m_nextBlob; } /// accessor -inline Bool MemoryPoolBlob::hasAnyFreeBlocks() { return m_firstFreeBlock != NULL; } +inline Bool MemoryPoolBlob::hasAnyFreeBlocks() { return m_firstFreeBlock != nullptr; } /// accessor inline MemoryPool *MemoryPoolBlob::getOwningPool() { return m_owningPool; } /// accessor @@ -795,7 +795,7 @@ Bool BlockCheckpointInfo::shouldBeInReport(Int flags, Int startCheckpoint, Int e ::sysFree((void *)p); p = n; } - *pHead = NULL; + *pHead = nullptr; } #endif @@ -815,15 +815,15 @@ Bool BlockCheckpointInfo::shouldBeInReport(Int flags, Int startCheckpoint, Int e { DEBUG_ASSERTCRASH(debugLiteralTagString != FREE_SINGLEBLOCK_TAG_STRING, ("bad tag string")); - BlockCheckpointInfo *freed = NULL; + BlockCheckpointInfo *freed = nullptr; try { freed = (BlockCheckpointInfo *)::sysAllocateDoNotZero(sizeof(BlockCheckpointInfo)); } catch (...) { - freed = NULL; + freed = nullptr; } if (freed) { - DEBUG_ASSERTCRASH(debugLiteralTagString != NULL, ("null tagstrings are not allowed")); + DEBUG_ASSERTCRASH(debugLiteralTagString != nullptr, ("null tagstrings are not allowed")); freed->m_debugLiteralTagString = debugLiteralTagString; freed->m_allocCheckpoint = allocCheckpoint; freed->m_freeCheckpoint = -1; @@ -858,7 +858,7 @@ void MemoryPoolSingleBlock::initBlock(Int logicalSize, MemoryPoolBlob *owningBlo m_debugFlags = 0; if (!theMainInitFlag) debugIgnoreLeaksForThisBlock(); - DEBUG_ASSERTCRASH(debugLiteralTagString != NULL, ("null tagstrings are not allowed")); + DEBUG_ASSERTCRASH(debugLiteralTagString != nullptr, ("null tagstrings are not allowed")); m_debugLiteralTagString = debugLiteralTagString; m_logicalSize = logicalSize; m_wastedSize = 0; @@ -871,21 +871,21 @@ void MemoryPoolSingleBlock::initBlock(Int logicalSize, MemoryPoolBlob *owningBlo } else { - m_stacktrace[0] = NULL; + m_stacktrace[0] = nullptr; } #endif } #endif // MEMORYPOOL_DEBUG #ifdef MEMORYPOOL_CHECKPOINTING - m_checkpointInfo = NULL; + m_checkpointInfo = nullptr; #endif - m_nextBlock = NULL; + m_nextBlock = nullptr; #ifdef MPSB_DLINK - m_prevBlock = NULL; + m_prevBlock = nullptr; #endif - m_owningBlob = owningBlob; // could be NULL + m_owningBlob = owningBlob; // could be null #ifdef MEMORYPOOL_BOUNDINGWALL m_wallPattern = theBoundingWallPattern++; @@ -902,7 +902,7 @@ void MemoryPoolSingleBlock::initBlock(Int logicalSize, MemoryPoolBlob *owningBlo { DEBUG_ASSERTCRASH(pUserData, ("null pUserData")); if (!pUserData) - return NULL; + return nullptr; char* p = ((char*)pUserData) - sizeof(MemoryPoolSingleBlock); #ifdef MEMORYPOOL_BOUNDINGWALL p -= WALLSIZE; @@ -927,7 +927,7 @@ void MemoryPoolSingleBlock::initBlock(Int logicalSize, MemoryPoolBlob *owningBlo DECLARE_LITERALSTRING_ARG2) { MemoryPoolSingleBlock *block = (MemoryPoolSingleBlock *)::sysAllocateDoNotZero(calcRawBlockSize(logicalSize)); - block->initBlock(logicalSize, NULL, owningFactory PASS_LITERALSTRING_ARG2); + block->initBlock(logicalSize, nullptr, owningFactory PASS_LITERALSTRING_ARG2); block->setNextRawBlock(*pRawListHead); *pRawListHead = block; return block; @@ -940,12 +940,12 @@ void MemoryPoolSingleBlock::initBlock(Int logicalSize, MemoryPoolBlob *owningBlo */ void MemoryPoolSingleBlock::removeBlockFromList(MemoryPoolSingleBlock **pHead) { - DEBUG_ASSERTCRASH(this->m_owningBlob == NULL, ("this function should only be used on raw blocks")); + DEBUG_ASSERTCRASH(this->m_owningBlob == nullptr, ("this function should only be used on raw blocks")); #ifdef MPSB_DLINK - DEBUG_ASSERTCRASH(this->m_nextBlock == NULL || this->m_nextBlock->m_owningBlob == NULL, ("this function should only be used on raw blocks")); + DEBUG_ASSERTCRASH(this->m_nextBlock == nullptr || this->m_nextBlock->m_owningBlob == nullptr, ("this function should only be used on raw blocks")); if (this->m_prevBlock) { - DEBUG_ASSERTCRASH(this->m_prevBlock->m_owningBlob == NULL, ("this function should only be used on raw blocks")); + DEBUG_ASSERTCRASH(this->m_prevBlock->m_owningBlob == nullptr, ("this function should only be used on raw blocks")); DEBUG_ASSERTCRASH(*pHead != this, ("bad linkage")); this->m_prevBlock->m_nextBlock = this->m_nextBlock; } @@ -957,7 +957,7 @@ void MemoryPoolSingleBlock::removeBlockFromList(MemoryPoolSingleBlock **pHead) if (this->m_nextBlock) { - DEBUG_ASSERTCRASH(this->m_nextBlock->m_owningBlob == NULL, ("this function should only be used on raw blocks")); + DEBUG_ASSERTCRASH(this->m_nextBlock->m_owningBlob == nullptr, ("this function should only be used on raw blocks")); this->m_nextBlock->m_prevBlock = this->m_prevBlock; } #else @@ -965,10 +965,10 @@ void MemoryPoolSingleBlock::removeBlockFromList(MemoryPoolSingleBlock **pHead) // would require adding a back link, so I'd rather do some testing // first to see if it's really a speed issue in practice. (the only place // this is used is when freeing 'raw' blocks allocated via the DMA). - MemoryPoolSingleBlock *prev = NULL; + MemoryPoolSingleBlock *prev = nullptr; for (MemoryPoolSingleBlock *cur = *pHead; cur; cur = cur->m_nextBlock) { - DEBUG_ASSERTCRASH(cur->m_owningBlob == NULL, ("this function should only be used on raw blocks")); + DEBUG_ASSERTCRASH(cur->m_owningBlob == nullptr, ("this function should only be used on raw blocks")); if (cur == this) { if (prev) @@ -1005,7 +1005,7 @@ Int MemoryPoolSingleBlock::debugSingleBlockReportLeak(const char* owner) /** @todo srj -- we leak a bunch of these for some reason (probably due to leaking Win32LocalFile) so just ignore 'em for now... figure out later. */ } - else if (strstr(m_debugLiteralTagString, "Win32LocalFileSystem.cpp") != NULL) + else if (strstr(m_debugLiteralTagString, "Win32LocalFileSystem.cpp") != nullptr) { /** @todo srj -- we leak a bunch of these for some reason so just ignore 'em for now... figure out later. */ @@ -1035,14 +1035,14 @@ void MemoryPoolSingleBlock::debugVerifyBlock() DEBUG_ASSERTCRASH(this, ("null this")); DEBUG_ASSERTCRASH(m_magicCookie == SINGLEBLOCK_MAGIC_COOKIE, ("wrong cookie")); - DEBUG_ASSERTCRASH(m_debugLiteralTagString != NULL, ("bad tagstring")); + DEBUG_ASSERTCRASH(m_debugLiteralTagString != nullptr, ("bad tagstring")); /// @todo Put this check back in after the AI memory usage is under control (MSB) //DEBUG_ASSERTCRASH(m_logicalSize>0 && m_logicalSize < 0x00ffffff, ("unlikely value for m_logicalSize")); - DEBUG_ASSERTCRASH(m_nextBlock == NULL + DEBUG_ASSERTCRASH(m_nextBlock == nullptr || memcmp(&m_nextBlock->m_owningBlob, &s_initFillerValue, sizeof(s_initFillerValue)) == 0 || m_nextBlock->m_owningBlob == m_owningBlob, ("owning blob mismatch...")); #ifdef MPSB_DLINK - DEBUG_ASSERTCRASH(m_prevBlock == NULL + DEBUG_ASSERTCRASH(m_prevBlock == nullptr || memcmp(&m_prevBlock->m_owningBlob, &s_initFillerValue, sizeof(s_initFillerValue)) == 0 || m_prevBlock->m_owningBlob == m_owningBlob, ("owning blob mismatch...")); #endif @@ -1152,13 +1152,13 @@ void MemoryPoolSingleBlock::debugFillInWalls() fill in safe default values. */ MemoryPoolBlob::MemoryPoolBlob() : - m_owningPool(NULL), - m_nextBlob(NULL), - m_prevBlob(NULL), - m_firstFreeBlock(NULL), + m_owningPool(nullptr), + m_nextBlob(nullptr), + m_prevBlob(nullptr), + m_firstFreeBlock(nullptr), m_usedBlocksInBlob(0), m_totalBlocksInBlob(0), - m_blockData(NULL) + m_blockData(nullptr) { } @@ -1178,7 +1178,7 @@ MemoryPoolBlob::~MemoryPoolBlob() */ void MemoryPoolBlob::initBlob(MemoryPool *owningPool, Int allocationCount) { - DEBUG_ASSERTCRASH(m_blockData == NULL, ("unlikely init call")); + DEBUG_ASSERTCRASH(m_blockData == nullptr, ("unlikely init call")); m_owningPool = owningPool; m_totalBlocksInBlob = allocationCount; @@ -1198,7 +1198,7 @@ void MemoryPoolBlob::initBlob(MemoryPool *owningPool, Int allocationCount) #else block->initBlock(m_owningPool->getAllocationSize(), this, owningPool->getOwningFactory()); #endif - block->setNextFreeBlock((i > 0) ? next : NULL); + block->setNextFreeBlock((i > 0) ? next : nullptr); #ifdef MEMORYPOOL_DEBUG block->debugMarkBlockAsFree(); #endif @@ -1218,12 +1218,12 @@ void MemoryPoolBlob::initBlob(MemoryPool *owningPool, Int allocationCount) void MemoryPoolBlob::addBlobToList(MemoryPoolBlob **ppHead, MemoryPoolBlob **ppTail) { m_prevBlob = *ppTail; - m_nextBlob = NULL; + m_nextBlob = nullptr; - if (*ppTail != NULL) + if (*ppTail != nullptr) (*ppTail)->m_nextBlob = this; - if (*ppHead == NULL) + if (*ppHead == nullptr) *ppHead = this; *ppTail = this; @@ -1310,7 +1310,7 @@ void MemoryPoolBlob::debugMemoryVerifyBlob() { USE_PERF_TIMER(MemoryPoolDebugging) - DEBUG_ASSERTCRASH(m_owningPool != NULL, ("bad owner")); + DEBUG_ASSERTCRASH(m_owningPool != nullptr, ("bad owner")); DEBUG_ASSERTCRASH(m_usedBlocksInBlob >= 0 && m_usedBlocksInBlob <= m_totalBlocksInBlob, ("unlikely m_usedBlocksInBlob")); DEBUG_ASSERTCRASH(m_totalBlocksInBlob > 0, ("unlikely m_totalBlocksInBlob")); @@ -1392,7 +1392,7 @@ void MemoryPoolBlob::debugResetCheckpoints() init fields of Checkpointable to safe values. */ Checkpointable::Checkpointable() : - m_firstCheckpointInfo(NULL), + m_firstCheckpointInfo(nullptr), m_cpiEverFailed(false) { } @@ -1406,7 +1406,7 @@ Checkpointable::Checkpointable() : Checkpointable::~Checkpointable() { BlockCheckpointInfo::freeList(&m_firstCheckpointInfo); - m_firstCheckpointInfo = NULL; + m_firstCheckpointInfo = nullptr; m_cpiEverFailed = false; } #endif @@ -1439,7 +1439,7 @@ BlockCheckpointInfo *Checkpointable::debugAddCheckpointInfo( } else { - stacktrace[0] = NULL; + stacktrace[0] = nullptr; } #endif } @@ -1496,8 +1496,8 @@ void Checkpointable::debugResetCheckpoints() init to safe values. */ MemoryPool::MemoryPool() : - m_factory(NULL), - m_nextPoolInFactory(NULL), + m_factory(nullptr), + m_nextPoolInFactory(nullptr), m_poolName(""), m_allocationSize(0), m_initialAllocationCount(0), @@ -1505,9 +1505,9 @@ MemoryPool::MemoryPool() : m_usedBlocksInPool(0), m_totalBlocksInPool(0), m_peakUsedBlocksInPool(0), - m_firstBlob(NULL), - m_lastBlob(NULL), - m_firstBlobWithFreeBlocks(NULL) + m_firstBlob(nullptr), + m_lastBlob(nullptr), + m_firstBlobWithFreeBlocks(nullptr) { } @@ -1526,9 +1526,9 @@ void MemoryPool::init(MemoryPoolFactory *factory, const char *poolName, Int allo m_usedBlocksInPool = 0; m_totalBlocksInPool = 0; m_peakUsedBlocksInPool = 0; - m_firstBlob = NULL; - m_lastBlob = NULL; - m_firstBlobWithFreeBlocks = NULL; + m_firstBlob = nullptr; + m_lastBlob = nullptr; + m_firstBlobWithFreeBlocks = nullptr; // go ahead and init the initial block here (will throw on failure) createBlob(m_initialAllocationCount); @@ -1564,7 +1564,7 @@ MemoryPoolBlob* MemoryPool::createBlob(Int allocationCount) blob->addBlobToList(&m_firstBlob, &m_lastBlob); - DEBUG_ASSERTCRASH(m_firstBlobWithFreeBlocks == NULL, ("DO NOT IGNORE. Please call John McD - x36872 (m_firstBlobWithFreeBlocks != NULL)")); + DEBUG_ASSERTCRASH(m_firstBlobWithFreeBlocks == nullptr, ("DO NOT IGNORE. Please call John McD - x36872 (m_firstBlobWithFreeBlocks != nullptr)")); m_firstBlobWithFreeBlocks = blob; // bookkeeping @@ -1630,12 +1630,12 @@ void* MemoryPool::allocateBlockDoNotZeroImplementation(DECLARE_LITERALSTRING_ARG { ScopedCriticalSection scopedCriticalSection(TheMemoryPoolCriticalSection); - if (m_firstBlobWithFreeBlocks != NULL && !m_firstBlobWithFreeBlocks->hasAnyFreeBlocks()) + if (m_firstBlobWithFreeBlocks != nullptr && !m_firstBlobWithFreeBlocks->hasAnyFreeBlocks()) { // hmm... the current 'free' blob has nothing available. look and see if there // are any other existing blobs with freespace. MemoryPoolBlob *blob = m_firstBlob; - for (; blob != NULL; blob = blob->getNextInList()) + for (; blob != nullptr; blob = blob->getNextInList()) { if (blob->hasAnyFreeBlocks()) break; @@ -1648,7 +1648,7 @@ void* MemoryPool::allocateBlockDoNotZeroImplementation(DECLARE_LITERALSTRING_ARG // OK, if we are here then we have no blobs with freespace... darn. // allocate an overflow block. - if (m_firstBlobWithFreeBlocks == NULL) + if (m_firstBlobWithFreeBlocks == nullptr) { if (m_overflowAllocationCount == 0) { @@ -1801,9 +1801,9 @@ void MemoryPool::reset() { freeBlob(m_firstBlob); } - m_firstBlob = NULL; - m_lastBlob = NULL; - m_firstBlobWithFreeBlocks = NULL; + m_firstBlob = nullptr; + m_lastBlob = nullptr; + m_firstBlobWithFreeBlocks = nullptr; init(m_factory, m_poolName, m_allocationSize, m_initialAllocationCount, m_overflowAllocationCount); // will throw on failure @@ -1827,7 +1827,7 @@ void MemoryPool::removeFromList(MemoryPool **pHead) { // this isn't very efficient, but then, we rarely remove pools... // usually only at shutdown. so don't bother optimizing. - MemoryPool *prev = NULL; + MemoryPool *prev = nullptr; for (MemoryPool *cur = *pHead; cur; cur = cur->m_nextPoolInFactory) { if (cur == this) @@ -2002,14 +2002,14 @@ void MemoryPool::debugResetCheckpoints() init the DMA to safe values. */ DynamicMemoryAllocator::DynamicMemoryAllocator() : - m_factory(NULL), - m_nextDmaInFactory(NULL), + m_factory(nullptr), + m_nextDmaInFactory(nullptr), m_numPools(0), m_usedBlocksInDma(0), - m_rawBlocks(NULL) + m_rawBlocks(nullptr) { for (Int i = 0; i < MAX_DYNAMICMEMORYALLOCATOR_SUBPOOLS; i++) - m_pools[i] = 0; + m_pools[i] = nullptr; } //----------------------------------------------------------------------------- @@ -2029,7 +2029,7 @@ void DynamicMemoryAllocator::init(MemoryPoolFactory *factory, Int numSubPools, c { "dmaPool_1024", 1024, 64, 64 } }; - if (numSubPools == 0 || pParms == NULL) + if (numSubPools == 0 || pParms == nullptr) { // use the defaults... numSubPools = 7; @@ -2061,7 +2061,7 @@ DynamicMemoryAllocator::~DynamicMemoryAllocator() for (Int i = 0; i < m_numPools; i++) { m_factory->destroyMemoryPool(m_pools[i]); - m_pools[i] = NULL; + m_pools[i] = nullptr; } while (m_rawBlocks) @@ -2083,7 +2083,7 @@ MemoryPool *DynamicMemoryAllocator::findPoolForSize(Int allocSize) if (allocSize <= m_pools[i]->getAllocationSize()) return m_pools[i]; } - return NULL; + return nullptr; } //----------------------------------------------------------------------------- @@ -2104,7 +2104,7 @@ void DynamicMemoryAllocator::removeFromList(DynamicMemoryAllocator **pHead) { // this isn't very efficient, but then, we rarely remove these... // usually only at shutdown. so don't bother optimizing. - DynamicMemoryAllocator *prev = NULL; + DynamicMemoryAllocator *prev = nullptr; for (DynamicMemoryAllocator *cur = *pHead; cur; cur = cur->m_nextDmaInFactory) { if (cur == this) @@ -2163,15 +2163,15 @@ void *DynamicMemoryAllocator::allocateBytesDoNotZeroImplementation(Int numBytes { ScopedCriticalSection scopedCriticalSection(TheDmaCriticalSection); - void *result = NULL; + void *result = nullptr; #ifdef MEMORYPOOL_DEBUG - DEBUG_ASSERTCRASH(debugLiteralTagString != NULL, ("bad tagstring")); + DEBUG_ASSERTCRASH(debugLiteralTagString != nullptr, ("bad tagstring")); Int waste = 0; #endif MemoryPool *pool = findPoolForSize(numBytes); - if (pool != NULL) + if (pool != nullptr) { result = pool->allocateBlockDoNotZeroImplementation(PASS_LITERALSTRING_ARG1); #ifdef MEMORYPOOL_DEBUG @@ -2582,8 +2582,8 @@ void DynamicMemoryAllocator::debugDmaInfoReport( FILE *fp ) init the factory to safe values. */ MemoryPoolFactory::MemoryPoolFactory() : - m_firstPoolInFactory(NULL), - m_firstDmaInFactory(NULL) + m_firstPoolInFactory(nullptr), + m_firstDmaInFactory(nullptr) #ifdef MEMORYPOOL_CHECKPOINTING , m_curCheckpoint(0) #endif @@ -2687,7 +2687,7 @@ MemoryPool *MemoryPoolFactory::findMemoryPool(const char *poolName) return pool; } } - return NULL; + return nullptr; } //----------------------------------------------------------------------------- @@ -2791,7 +2791,7 @@ static const char* s_specialPrefixes[MAX_SPECIAL_USED] = "W3A_", "STL_", "STR_", - NULL + nullptr }; #endif @@ -2815,7 +2815,7 @@ void MemoryPoolFactory::adjustTotals(const char* tagString, Int usedDelta, Int p int found = 0; // if no matches found, goes into slot zero for (int i = 1; i < MAX_SPECIAL_USED; ++i) // start at 1, not zero { - if (s_specialPrefixes[i] == NULL) + if (s_specialPrefixes[i] == nullptr) break; if (strncmp(tagString, s_specialPrefixes[i], strlen(s_specialPrefixes[i])) == 0) @@ -2867,7 +2867,7 @@ void MemoryPoolFactory::debugMemoryVerify() for (DynamicMemoryAllocator *dma = m_firstDmaInFactory; dma; dma = dma->getNextDmaInList()) { dma->debugMemoryVerifyDma(); - Int tmp = dma->debugCalcRawBlockBytes(NULL); + Int tmp = dma->debugCalcRawBlockBytes(nullptr); used += tmp; phys += tmp; } @@ -2969,7 +2969,7 @@ void MemoryPoolFactory::memoryPoolUsageReport( const char* filename, FILE *appen #ifdef MEMORYPOOL_DEBUG //USE_PERF_TIMER(MemoryPoolDebugging) skip end-of-run reporting stuff - FILE* perfStatsFile = NULL; + FILE* perfStatsFile = nullptr; Int totalNamedPoolPeak = 0; if( !appendToFileInstead ) @@ -2984,7 +2984,7 @@ void MemoryPoolFactory::memoryPoolUsageReport( const char* filename, FILE *appen perfStatsFile = appendToFileInstead; } - if (perfStatsFile == NULL) + if (perfStatsFile == nullptr) { DEBUG_CRASH(("could not open/create perf file %s -- is it open in another app?",filename)); return; @@ -3036,7 +3036,7 @@ void MemoryPoolFactory::memoryPoolUsageReport( const char* filename, FILE *appen } #endif - if (lineIdx < MAX_SPECIAL_USED && s_specialPrefixes[lineIdx] != NULL) + if (lineIdx < MAX_SPECIAL_USED && s_specialPrefixes[lineIdx] != nullptr) { fprintf(perfStatsFile, ",,,%s,%d",s_specialPrefixes[lineIdx],m_usedBytesSpecialPeak[lineIdx]/1024); keepGoing = true; @@ -3118,7 +3118,7 @@ void MemoryPoolFactory::debugMemoryReport(Int flags, Int startCheckpoint, Int en fprintf( fp, "Begin Pool Info Report\n" ); fprintf( fp, "------------------------------------------\n" ); } - MemoryPool::debugPoolInfoReport( NULL, fp ); + MemoryPool::debugPoolInfoReport( nullptr, fp ); for (MemoryPool *pool = m_firstPoolInFactory; pool; pool = pool->getNextPoolInList()) { MemoryPool::debugPoolInfoReport( pool, fp ); @@ -3210,7 +3210,7 @@ void MemoryPoolFactory::debugMemoryReport(Int flags, Int startCheckpoint, Int en DEBUG_LOG(("Options: Between checkpoints %d and %d, report on (%s)",startCheckpoint,endCheckpoint,buf)); DEBUG_LOG(("------------------------------------------")); - BlockCheckpointInfo::doBlockCheckpointReport( NULL, "", 0, 0, 0 ); + BlockCheckpointInfo::doBlockCheckpointReport( nullptr, "", 0, 0, 0 ); for (MemoryPool *pool = m_firstPoolInFactory; pool; pool = pool->getNextPoolInList()) { pool->debugCheckpointReport(flags, startCheckpoint, endCheckpoint, pool->getPoolName()); @@ -3243,7 +3243,7 @@ void* STLSpecialAlloc::allocate(size_t __n) { ++theLinkTester; preMainInitMemoryManager(); - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("must init memory manager before calling global operator new")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("must init memory manager before calling global operator new")); return TheDynamicMemoryAllocator->allocateBytes(__n, "STL_"); } @@ -3252,7 +3252,7 @@ void STLSpecialAlloc::deallocate(void* __p, size_t) { ++theLinkTester; preMainInitMemoryManager(); - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("must init memory manager before calling global operator new")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("must init memory manager before calling global operator new")); TheDynamicMemoryAllocator->freeBytes(__p); } @@ -3264,7 +3264,7 @@ void *operator new(size_t size) { ++theLinkTester; preMainInitMemoryManager(); - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("must init memory manager before calling global operator new")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("must init memory manager before calling global operator new")); return TheDynamicMemoryAllocator->allocateBytes(size, "global operator new"); } @@ -3276,7 +3276,7 @@ void *operator new[](size_t size) { ++theLinkTester; preMainInitMemoryManager(); - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("must init memory manager before calling global operator new")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("must init memory manager before calling global operator new")); return TheDynamicMemoryAllocator->allocateBytes(size, "global operator new[]"); } @@ -3288,7 +3288,7 @@ void operator delete(void *p) { ++theLinkTester; preMainInitMemoryManager(); - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("must init memory manager before calling global operator delete")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("must init memory manager before calling global operator delete")); TheDynamicMemoryAllocator->freeBytes(p); } @@ -3300,7 +3300,7 @@ void operator delete[](void *p) { ++theLinkTester; preMainInitMemoryManager(); - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("must init memory manager before calling global operator delete")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("must init memory manager before calling global operator delete")); TheDynamicMemoryAllocator->freeBytes(p); } @@ -3312,7 +3312,7 @@ void* operator new(size_t size, const char * fname, int) { ++theLinkTester; preMainInitMemoryManager(); - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("must init memory manager before calling global operator new")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("must init memory manager before calling global operator new")); #ifdef MEMORYPOOL_DEBUG return TheDynamicMemoryAllocator->allocateBytesImplementation(size, fname); #else @@ -3328,7 +3328,7 @@ void operator delete(void * p, const char *, int) { ++theLinkTester; preMainInitMemoryManager(); - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("must init memory manager before calling global operator delete")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("must init memory manager before calling global operator delete")); TheDynamicMemoryAllocator->freeBytes(p); } @@ -3340,7 +3340,7 @@ void* operator new[](size_t size, const char * fname, int) { ++theLinkTester; preMainInitMemoryManager(); - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("must init memory manager before calling global operator new")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("must init memory manager before calling global operator new")); #ifdef MEMORYPOOL_DEBUG return TheDynamicMemoryAllocator->allocateBytesImplementation(size, fname); #else @@ -3356,7 +3356,7 @@ void operator delete[](void * p, const char *, int) { ++theLinkTester; preMainInitMemoryManager(); - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("must init memory manager before calling global operator delete")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("must init memory manager before calling global operator delete")); TheDynamicMemoryAllocator->freeBytes(p); } @@ -3366,7 +3366,7 @@ void *calloc(size_t a, size_t b) { ++theLinkTester; preMainInitMemoryManager(); - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("must init memory manager")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("must init memory manager")); return TheDynamicMemoryAllocator->allocateBytes(a * b, "calloc"); } #endif @@ -3377,7 +3377,7 @@ void free(void * p) { ++theLinkTester; preMainInitMemoryManager(); - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("must init memory manager")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("must init memory manager")); TheDynamicMemoryAllocator->freeBytes(p); } #endif @@ -3388,7 +3388,7 @@ void *malloc(size_t a) { ++theLinkTester; preMainInitMemoryManager(); - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("must init memory manager")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("must init memory manager")); return TheDynamicMemoryAllocator->allocateBytesDoNotZero(a, "malloc"); } #endif @@ -3408,7 +3408,7 @@ void *realloc(void *p, size_t s) */ void initMemoryManager() { - if (TheMemoryPoolFactory == NULL) + if (TheMemoryPoolFactory == nullptr) { Int numSubPools; const PoolInitRec *pParms; @@ -3482,7 +3482,7 @@ Bool isMemoryManagerOfficiallyInited() */ static void preMainInitMemoryManager() { - if (TheMemoryPoolFactory == NULL) + if (TheMemoryPoolFactory == nullptr) { Int numSubPools; @@ -3520,7 +3520,7 @@ void shutdownMemoryManager() DEBUG_ASSERTCRASH(TheMemoryPoolFactory, ("hmm, no factory")); if (TheMemoryPoolFactory) TheMemoryPoolFactory->destroyDynamicMemoryAllocator(TheDynamicMemoryAllocator); - TheDynamicMemoryAllocator = NULL; + TheDynamicMemoryAllocator = nullptr; } if (TheMemoryPoolFactory) @@ -3530,7 +3530,7 @@ void shutdownMemoryManager() // make an exception. TheMemoryPoolFactory->~MemoryPoolFactory(); ::sysFree((void *)TheMemoryPoolFactory); - TheMemoryPoolFactory = NULL; + TheMemoryPoolFactory = nullptr; } #ifdef MEMORYPOOL_DEBUG diff --git a/Core/GameEngine/Source/Common/System/GameMemoryInit.cpp b/Core/GameEngine/Source/Common/System/GameMemoryInit.cpp index d25872b98c6..6bdd7e65706 100644 --- a/Core/GameEngine/Source/Common/System/GameMemoryInit.cpp +++ b/Core/GameEngine/Source/Common/System/GameMemoryInit.cpp @@ -77,7 +77,7 @@ void userMemoryAdjustPoolSize(const char *poolName, Int& initialAllocationCount, if (initialAllocationCount > 0) return; - for (const PoolSizeRec* p = PoolSizes; p->name != NULL; ++p) + for (const PoolSizeRec* p = PoolSizes; p->name != nullptr; ++p) { if (strcmp(p->name, poolName) == 0) { @@ -112,7 +112,7 @@ void userMemoryManagerInitPools() // since we're called prior to main, the cur dir might not be what // we expect. so do it the hard way. char buf[_MAX_PATH]; - ::GetModuleFileName(NULL, buf, sizeof(buf)); + ::GetModuleFileName(nullptr, buf, sizeof(buf)); if (char* pEnd = strrchr(buf, '\\')) { *pEnd = 0; @@ -130,7 +130,7 @@ void userMemoryManagerInitPools() continue; if (sscanf(buf, "%s %d %d", poolName, &initial, &overflow ) == 3) { - for (PoolSizeRec* p = PoolSizes; p->name != NULL; ++p) + for (PoolSizeRec* p = PoolSizes; p->name != nullptr; ++p) { if (stricmp(p->name, poolName) == 0) { diff --git a/Core/GameEngine/Source/Common/System/GameMemoryInitPools_Generals.inl b/Core/GameEngine/Source/Common/System/GameMemoryInitPools_Generals.inl index 31b24b6551b..5f6f7ab9314 100644 --- a/Core/GameEngine/Source/Common/System/GameMemoryInitPools_Generals.inl +++ b/Core/GameEngine/Source/Common/System/GameMemoryInitPools_Generals.inl @@ -554,6 +554,8 @@ static PoolSizeRec PoolSizes[] = { "NetChatCommandMsg", 32, 32 }, { "NetDisconnectVoteCommandMsg", 32, 32 }, { "NetProgressCommandMsg", 32, 32 }, + { "NetLoadCompleteCommandMsg", 32, 32 }, + { "NetTimeOutGameStartCommandMsg", 32, 32 }, { "NetWrapperCommandMsg", 32, 32 }, { "NetFileCommandMsg", 32, 32 }, { "NetFileAnnounceCommandMsg", 32, 32 }, diff --git a/Core/GameEngine/Source/Common/System/GameMemoryInitPools_GeneralsMD.inl b/Core/GameEngine/Source/Common/System/GameMemoryInitPools_GeneralsMD.inl index 94187718a63..5fd11c54ba3 100644 --- a/Core/GameEngine/Source/Common/System/GameMemoryInitPools_GeneralsMD.inl +++ b/Core/GameEngine/Source/Common/System/GameMemoryInitPools_GeneralsMD.inl @@ -582,6 +582,8 @@ static PoolSizeRec PoolSizes[] = { "NetChatCommandMsg", 32, 32 }, { "NetDisconnectVoteCommandMsg", 32, 32 }, { "NetProgressCommandMsg", 32, 32 }, + { "NetLoadCompleteCommandMsg", 32, 32 }, + { "NetTimeOutGameStartCommandMsg", 32, 32 }, { "NetWrapperCommandMsg", 32, 32 }, { "NetFileCommandMsg", 32, 32 }, { "NetFileAnnounceCommandMsg", 32, 32 }, diff --git a/Core/GameEngine/Source/Common/System/GameMemoryNull.cpp b/Core/GameEngine/Source/Common/System/GameMemoryNull.cpp index 8520a77de9b..54f8fd770fe 100644 --- a/Core/GameEngine/Source/Common/System/GameMemoryNull.cpp +++ b/Core/GameEngine/Source/Common/System/GameMemoryNull.cpp @@ -28,8 +28,8 @@ static Bool theMainInitFlag = false; // PUBLIC DATA // ---------------------------------------------------------------------------- -MemoryPoolFactory *TheMemoryPoolFactory = NULL; -DynamicMemoryAllocator *TheDynamicMemoryAllocator = NULL; +MemoryPoolFactory *TheMemoryPoolFactory = nullptr; +DynamicMemoryAllocator *TheDynamicMemoryAllocator = nullptr; //----------------------------------------------------------------------------- // METHODS for DynamicMemoryAllocator @@ -45,7 +45,7 @@ DynamicMemoryAllocator *TheDynamicMemoryAllocator = NULL; void *DynamicMemoryAllocator::allocateBytesDoNotZeroImplementation(Int numBytes) { void *p = malloc(numBytes); - if (p == NULL) + if (p == nullptr) throw ERROR_OUT_OF_MEMORY; return p; } @@ -107,7 +107,7 @@ void MemoryPoolFactory::debugSetInitFillerIndex(Int index) */ void initMemoryManager() { - if (TheMemoryPoolFactory == NULL && TheDynamicMemoryAllocator == NULL) + if (TheMemoryPoolFactory == nullptr && TheDynamicMemoryAllocator == nullptr) { TheMemoryPoolFactory = new (malloc(sizeof MemoryPoolFactory)) MemoryPoolFactory; TheDynamicMemoryAllocator = new (malloc(sizeof DynamicMemoryAllocator)) DynamicMemoryAllocator; @@ -136,18 +136,18 @@ Bool isMemoryManagerOfficiallyInited() */ void shutdownMemoryManager() { - if (TheDynamicMemoryAllocator != NULL) + if (TheDynamicMemoryAllocator != nullptr) { TheDynamicMemoryAllocator->~DynamicMemoryAllocator(); free((void *)TheDynamicMemoryAllocator); - TheDynamicMemoryAllocator = NULL; + TheDynamicMemoryAllocator = nullptr; } - if (TheMemoryPoolFactory != NULL) + if (TheMemoryPoolFactory != nullptr) { TheMemoryPoolFactory->~MemoryPoolFactory(); free((void *)TheMemoryPoolFactory); - TheMemoryPoolFactory = NULL; + TheMemoryPoolFactory = nullptr; } theMainInitFlag = false; @@ -161,7 +161,7 @@ void shutdownMemoryManager() extern void * __cdecl operator new(size_t size) { void *p = malloc(size); - if (p == NULL) + if (p == nullptr) throw ERROR_OUT_OF_MEMORY; memset(p, 0, size); return p; @@ -175,7 +175,7 @@ extern void __cdecl operator delete(void *p) extern void * __cdecl operator new[](size_t size) { void *p = malloc(size); - if (p == NULL) + if (p == nullptr) throw ERROR_OUT_OF_MEMORY; memset(p, 0, size); return p; @@ -190,7 +190,7 @@ extern void __cdecl operator delete[](void *p) extern void* __cdecl operator new(size_t size, const char *, int) { void *p = malloc(size); - if (p == NULL) + if (p == nullptr) throw ERROR_OUT_OF_MEMORY; memset(p, 0, size); return p; @@ -204,7 +204,7 @@ extern void __cdecl operator delete(void *p, const char *, int) extern void* __cdecl operator new[](size_t size, const char *, int) { void *p = malloc(size); - if (p == NULL) + if (p == nullptr) throw ERROR_OUT_OF_MEMORY; memset(p, 0, size); return p; diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/GameType.cpp b/Core/GameEngine/Source/Common/System/GameType.cpp similarity index 98% rename from GeneralsMD/Code/GameEngine/Source/Common/System/GameType.cpp rename to Core/GameEngine/Source/Common/System/GameType.cpp index b4fbba3d5c3..5cd0d411220 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/System/GameType.cpp +++ b/Core/GameEngine/Source/Common/System/GameType.cpp @@ -34,7 +34,7 @@ const char *const TimeOfDayNames[] = "EVENING", "NIGHT", - NULL + nullptr }; static_assert(ARRAY_SIZE(TimeOfDayNames) == TIME_OF_DAY_COUNT + 1, "Incorrect array size"); @@ -43,6 +43,6 @@ const char *const WeatherNames[] = "NORMAL", "SNOWY", - NULL + nullptr }; static_assert(ARRAY_SIZE(WeatherNames) == WEATHER_COUNT + 1, "Incorrect array size"); diff --git a/Core/GameEngine/Source/Common/System/LocalFile.cpp b/Core/GameEngine/Source/Common/System/LocalFile.cpp index 7ac8cd7a20b..ffe95f0752c 100644 --- a/Core/GameEngine/Source/Common/System/LocalFile.cpp +++ b/Core/GameEngine/Source/Common/System/LocalFile.cpp @@ -106,7 +106,7 @@ static Int s_totalOpen = 0; LocalFile::LocalFile() #if USE_BUFFERED_IO - : m_file(NULL) + : m_file(nullptr) #else : m_handle(-1) #endif @@ -165,7 +165,7 @@ Bool LocalFile::open( const Char *filename, Int access, size_t bufferSize ) const Bool truncate = (m_access & TRUNCATE) != 0; const Bool binary = (m_access & BINARY) != 0; - const Char *mode = NULL; + const Char *mode = nullptr; // Mode string selection (mimics _open flag combinations) // TEXT is implicit for fopen if 'b' is not present @@ -191,7 +191,7 @@ Bool LocalFile::open( const Char *filename, Int access, size_t bufferSize ) } m_file = fopen(filename, mode); - if (m_file == NULL) + if (m_file == nullptr) { goto error; } @@ -201,7 +201,7 @@ Bool LocalFile::open( const Char *filename, Int access, size_t bufferSize ) if (bufferSize == 0) { - result = setvbuf(m_file, NULL, _IONBF, 0); // Uses no buffering + result = setvbuf(m_file, nullptr, _IONBF, 0); // Uses no buffering } else { @@ -210,7 +210,7 @@ Bool LocalFile::open( const Char *filename, Int access, size_t bufferSize ) : _IOFBF; // Uses full buffering // Buffer is expected to lazy allocate on first read or write later - result = setvbuf(m_file, NULL, bufferMode, bufferSize); + result = setvbuf(m_file, nullptr, bufferMode, bufferSize); } DEBUG_ASSERTCRASH(result == 0, ("LocalFile::open - setvbuf failed")); @@ -315,7 +315,7 @@ void LocalFile::closeFile() if (m_file) { fclose(m_file); - m_file = NULL; + m_file = nullptr; --s_totalOpen; } #else @@ -340,7 +340,7 @@ Int LocalFile::read( void *buffer, Int bytes ) return -1; } - if (buffer == NULL) + if (buffer == nullptr) { #if USE_BUFFERED_IO fseek(m_file, bytes, SEEK_CUR); @@ -669,7 +669,7 @@ void LocalFile::nextLine(Char *buf, Int bufSize) // seek to the next new-line. do { - if ((buf == NULL) || (i >= (bufSize-1))) { + if ((buf == nullptr) || (i >= (bufSize-1))) { #if USE_BUFFERED_IO val = fread(&c, 1, 1, m_file); #else @@ -686,7 +686,7 @@ void LocalFile::nextLine(Char *buf, Int bufSize) ++i; } while ((val != 0) && (c != '\n')); - if (buf != NULL) { + if (buf != nullptr) { if (i < bufSize) { buf[i] = 0; } else { diff --git a/Core/GameEngine/Source/Common/System/LocalFileSystem.cpp b/Core/GameEngine/Source/Common/System/LocalFileSystem.cpp index af6b19329b8..81373dc558f 100644 --- a/Core/GameEngine/Source/Common/System/LocalFileSystem.cpp +++ b/Core/GameEngine/Source/Common/System/LocalFileSystem.cpp @@ -75,7 +75,7 @@ // Public Data //---------------------------------------------------------------------------- -LocalFileSystem *TheLocalFileSystem = NULL; +LocalFileSystem *TheLocalFileSystem = nullptr; //---------------------------------------------------------------------------- // Private Prototypes diff --git a/Core/GameEngine/Source/Common/System/MiniDumper.cpp b/Core/GameEngine/Source/Common/System/MiniDumper.cpp index 21ab80e578a..b5fcf376c88 100644 --- a/Core/GameEngine/Source/Common/System/MiniDumper.cpp +++ b/Core/GameEngine/Source/Common/System/MiniDumper.cpp @@ -24,10 +24,10 @@ #include "gitinfo.h" // Globals for storing the pointer to the exception -_EXCEPTION_POINTERS* g_dumpException = NULL; +_EXCEPTION_POINTERS* g_dumpException = nullptr; DWORD g_dumpExceptionThreadId = 0; -MiniDumper* TheMiniDumper = NULL; +MiniDumper* TheMiniDumper = nullptr; // 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 @@ -39,7 +39,7 @@ constexpr const char* DumpFileNamePrefix = "Crash"; void MiniDumper::initMiniDumper(const AsciiString& userDirPath) { - DEBUG_ASSERTCRASH(TheMiniDumper == NULL, ("MiniDumper::initMiniDumper called on already created instance")); + DEBUG_ASSERTCRASH(TheMiniDumper == nullptr, ("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 @@ -53,8 +53,8 @@ void MiniDumper::shutdownMiniDumper() { TheMiniDumper->ShutDown(); TheMiniDumper->~MiniDumper(); - ::HeapFree(::GetProcessHeap(), NULL, TheMiniDumper); - TheMiniDumper = NULL; + ::HeapFree(::GetProcessHeap(), 0, TheMiniDumper); + TheMiniDumper = nullptr; } } @@ -63,10 +63,10 @@ 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_dumpRequested = nullptr; + m_dumpComplete = nullptr; + m_quitting = nullptr; + m_dumpThread = nullptr; m_dumpThreadId = 0; m_dumpDir[0] = 0; m_dumpFile[0] = 0; @@ -93,6 +93,8 @@ void MiniDumper::TriggerMiniDump(DumpType dumpType) return; } +#if defined(_MSC_VER) + // MSVC supports structured exception handling (__try/__except) __try { // Use DebugBreak to raise an exception that can be caught in the __except block @@ -102,6 +104,13 @@ void MiniDumper::TriggerMiniDump(DumpType dumpType) { TriggerMiniDumpForException(g_dumpException, dumpType); } +#elif defined(__GNUC__) && defined(_WIN32) + // GCC/MinGW-w64 doesn't support MSVC's __try/__except syntax + // Trigger dump directly without SEH support + DEBUG_LOG(("MiniDumper::TriggerMiniDump: SEH not supported on this compiler, skipping manual dump trigger.")); +#else + #error "MiniDumper::TriggerMiniDump: Unsupported compiler. This code requires MSVC or GCC/MinGW-w64 targeting Windows." +#endif } void MiniDumper::TriggerMiniDumpForException(_EXCEPTION_POINTERS* e_info, DumpType dumpType) @@ -145,7 +154,7 @@ void MiniDumper::Initialize(const AsciiString& userDirPath) return; } - DWORD executableSize = ::GetModuleFileNameW(NULL, m_executablePath, ARRAY_SIZE(m_executablePath)); + DWORD executableSize = ::GetModuleFileNameW(nullptr, 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)); @@ -158,18 +167,18 @@ void MiniDumper::Initialize(const AsciiString& userDirPath) return; } - m_dumpRequested = CreateEvent(NULL, TRUE, FALSE, NULL); - m_dumpComplete = CreateEvent(NULL, TRUE, FALSE, NULL); - m_quitting = CreateEvent(NULL, TRUE, FALSE, NULL); + m_dumpRequested = CreateEvent(nullptr, TRUE, FALSE, nullptr); + m_dumpComplete = CreateEvent(nullptr, TRUE, FALSE, nullptr); + m_quitting = CreateEvent(nullptr, TRUE, FALSE, nullptr); - if (m_dumpRequested == NULL || m_dumpComplete == NULL || m_quitting == NULL) + if (m_dumpRequested == nullptr || m_dumpComplete == nullptr || m_quitting == nullptr) { // 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); + m_dumpThread = ::CreateThread(nullptr, 0, MiniDumpThreadProc, this, CREATE_SUSPENDED, &m_dumpThreadId); if (!m_dumpThread) { DEBUG_LOG(("MiniDumper::Initialize: Unable to create thread: error=%u", ::GetLastError())); @@ -194,7 +203,7 @@ Bool MiniDumper::IsInitialized() const Bool MiniDumper::IsDumpThreadStillRunning() const { DWORD exitCode; - if (m_dumpThread != NULL && ::GetExitCodeThread(m_dumpThread, &exitCode) && exitCode == STILL_ACTIVE) + if (m_dumpThread != nullptr && ::GetExitCodeThread(m_dumpThread, &exitCode) && exitCode == STILL_ACTIVE) { return true; } @@ -211,7 +220,7 @@ Bool MiniDumper::InitializeDumpDirectory(const AsciiString& userDirPath) strlcat(m_dumpDir, "CrashDumps\\", ARRAY_SIZE(m_dumpDir)); if (::_access(m_dumpDir, 0) != 0) { - if (!::CreateDirectory(m_dumpDir, NULL)) + if (!::CreateDirectory(m_dumpDir, nullptr)) { DEBUG_LOG(("MiniDumper::Initialize: Unable to create path for crash dumps at '%s': error=%u", m_dumpDir, ::GetLastError())); return false; @@ -229,7 +238,7 @@ void MiniDumper::ShutdownDumpThread() { if (IsDumpThreadStillRunning()) { - DEBUG_ASSERTCRASH(m_quitting != NULL, ("MiniDumper::ShutdownDumpThread: Dump thread still running despite m_quitting being NULL")); + DEBUG_ASSERTCRASH(m_quitting != nullptr, ("MiniDumper::ShutdownDumpThread: Dump thread still running despite m_quitting being null")); ::SetEvent(m_quitting); DWORD waitRet = ::WaitForSingleObject(m_dumpThread, 3000); @@ -256,29 +265,29 @@ void MiniDumper::ShutDown() { ShutdownDumpThread(); - if (m_dumpThread != NULL) + if (m_dumpThread != nullptr) { DEBUG_ASSERTCRASH(!IsDumpThreadStillRunning(), ("MiniDumper::ShutDown: ShutdownDumpThread() was unable to stop Dump thread")); ::CloseHandle(m_dumpThread); - m_dumpThread = NULL; + m_dumpThread = nullptr; } - if (m_quitting != NULL) + if (m_quitting != nullptr) { ::CloseHandle(m_quitting); - m_quitting = NULL; + m_quitting = nullptr; } - if (m_dumpComplete != NULL) + if (m_dumpComplete != nullptr) { ::CloseHandle(m_dumpComplete); - m_dumpComplete = NULL; + m_dumpComplete = nullptr; } - if (m_dumpRequested != NULL) + if (m_dumpRequested != nullptr) { ::CloseHandle(m_dumpRequested); - m_dumpRequested = NULL; + m_dumpRequested = nullptr; } if (m_loadedDbgHelp) @@ -320,9 +329,9 @@ DWORD MiniDumper::ThreadProcInternal() DWORD WINAPI MiniDumper::MiniDumpThreadProc(LPVOID lpParam) { - if (lpParam == NULL) + if (lpParam == nullptr) { - DEBUG_LOG(("MiniDumper::MiniDumpThreadProc: The provided parameter was NULL, exiting thread.")); + DEBUG_LOG(("MiniDumper::MiniDumpThreadProc: The provided parameter was null, exiting thread.")); return MiniDumperExitCode_FailureParam; } @@ -350,16 +359,16 @@ void MiniDumper::CreateMiniDump(DumpType dumpType) 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) + HANDLE dumpFile = ::CreateFile(m_dumpFile, GENERIC_READ | GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); + if (dumpFile == nullptr || 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; + PMINIDUMP_EXCEPTION_INFORMATION exceptionInfoPtr = nullptr; MINIDUMP_EXCEPTION_INFORMATION exceptionInfo = { 0 }; - if (g_dumpException != NULL) + if (g_dumpException != nullptr) { exceptionInfo.ExceptionPointers = g_dumpException; exceptionInfo.ThreadId = g_dumpExceptionThreadId; @@ -386,8 +395,8 @@ void MiniDumper::CreateMiniDump(DumpType dumpType) dumpFile, miniDumpType, exceptionInfoPtr, - NULL, - NULL); + nullptr, + nullptr); if (!success) { diff --git a/Core/GameEngine/Source/Common/System/ObjectStatusTypes.cpp b/Core/GameEngine/Source/Common/System/ObjectStatusTypes.cpp index ab689ad343c..2a4f79b7da8 100644 --- a/Core/GameEngine/Source/Common/System/ObjectStatusTypes.cpp +++ b/Core/GameEngine/Source/Common/System/ObjectStatusTypes.cpp @@ -81,7 +81,7 @@ const char* const ObjectStatusMaskType::s_bitNameList[] = "IMMOBILE", "DISGUISED", "DEPLOYED", - NULL + nullptr }; static_assert(ARRAY_SIZE(ObjectStatusMaskType::s_bitNameList) == ObjectStatusMaskType::NumBits + 1, "Incorrect array size"); diff --git a/Core/GameEngine/Source/Common/System/RAMFile.cpp b/Core/GameEngine/Source/Common/System/RAMFile.cpp index 93d5994b451..7c909bee77c 100644 --- a/Core/GameEngine/Source/Common/System/RAMFile.cpp +++ b/Core/GameEngine/Source/Common/System/RAMFile.cpp @@ -103,7 +103,7 @@ RAMFile::RAMFile() : m_size(0), - m_data(NULL), + m_data(nullptr), m_pos(0) { @@ -143,7 +143,7 @@ Bool RAMFile::open( const Char *filename, Int access, size_t bufferSize ) File *file = TheFileSystem->openFile( filename, access, bufferSize ); - if ( file == NULL ) + if ( file == nullptr ) { return FALSE; } @@ -162,9 +162,9 @@ Bool RAMFile::open( const Char *filename, Int access, size_t bufferSize ) Bool RAMFile::open( File *file ) { //USE_PERF_TIMER(RAMFile) - if ( file == NULL ) + if ( file == nullptr ) { - return NULL; + return FALSE; } const Int access = file->getAccess(); @@ -178,7 +178,7 @@ Bool RAMFile::open( File *file ) m_size = file->size(); m_data = MSGNEW("RAMFILE") char [ m_size ]; // pool[]ify - if ( m_data == NULL ) + if ( m_data == nullptr ) { return FALSE; } @@ -188,7 +188,7 @@ Bool RAMFile::open( File *file ) if ( m_size < 0 ) { delete [] m_data; - m_data = NULL; + m_data = nullptr; return FALSE; } @@ -203,7 +203,7 @@ Bool RAMFile::open( File *file ) Bool RAMFile::openFromArchive(File *archiveFile, const AsciiString& filename, Int offset, Int size) { //USE_PERF_TIMER(RAMFile) - if (archiveFile == NULL) { + if (archiveFile == nullptr) { return FALSE; } @@ -246,7 +246,7 @@ void RAMFile::close( void ) void RAMFile::closeFile() { delete [] m_data; - m_data = NULL; + m_data = nullptr; } //================================================================= @@ -255,7 +255,7 @@ void RAMFile::closeFile() // if buffer is null, just advance the current position by 'bytes' Int RAMFile::read( void *buffer, Int bytes ) { - if( m_data == NULL ) + if( m_data == nullptr ) { return -1; } @@ -267,7 +267,7 @@ Int RAMFile::read( void *buffer, Int bytes ) bytes = bytesLeft; } - if (( bytes > 0 ) && ( buffer != NULL )) + if (( bytes > 0 ) && ( buffer != nullptr )) { memcpy ( buffer, &m_data[m_pos], bytes ); } @@ -485,7 +485,7 @@ void RAMFile::nextLine(Char *buf, Int bufSize) Int i = 0; // seek to the next new-line character while ((m_pos < m_size) && (m_data[m_pos] != '\n')) { - if ((buf != NULL) && (i < (bufSize-1))) { + if ((buf != nullptr) && (i < (bufSize-1))) { buf[i] = m_data[m_pos]; ++i; } @@ -494,13 +494,13 @@ void RAMFile::nextLine(Char *buf, Int bufSize) // we got to the new-line character, now go one past it. if (m_pos < m_size) { - if ((buf != NULL) && (i < bufSize)) { + if ((buf != nullptr) && (i < bufSize)) { buf[i] = m_data[m_pos]; ++i; } ++m_pos; } - if (buf != NULL) { + if (buf != nullptr) { if (i < bufSize) { buf[i] = 0; } else { @@ -517,7 +517,7 @@ void RAMFile::nextLine(Char *buf, Int bufSize) //================================================================= Bool RAMFile::copyDataToFile(File *localFile) { - if (localFile == NULL) { + if (localFile == nullptr) { return FALSE; } @@ -549,14 +549,14 @@ File* RAMFile::convertToRAMFile() char* RAMFile::readEntireAndClose() { - if (m_data == NULL) + if (m_data == nullptr) { - DEBUG_CRASH(("m_data is NULL in RAMFile::readEntireAndClose -- should not happen!")); + DEBUG_CRASH(("m_data is null in RAMFile::readEntireAndClose -- should not happen!")); return NEW char[1]; // just to avoid crashing... } char* tmp = m_data; - m_data = NULL; // will belong to our caller! + m_data = nullptr; // will belong to our caller! close(); diff --git a/Core/GameEngine/Source/Common/System/Radar.cpp b/Core/GameEngine/Source/Common/System/Radar.cpp index 86ac2046b84..4b482a2c188 100644 --- a/Core/GameEngine/Source/Common/System/Radar.cpp +++ b/Core/GameEngine/Source/Common/System/Radar.cpp @@ -56,7 +56,7 @@ // GLOBALS //////////////////////////////////////////////////////////////////////////////////////// -Radar *TheRadar = NULL; ///< the radar global singleton +Radar *TheRadar = nullptr; ///< the radar global singleton // PRIVATE //////////////////////////////////////////////////////////////////////////////////////// #define RADAR_QUEUE_TERRAIN_REFRESH_DELAY (LOGICFRAMES_PER_SECOND * 3.0f) @@ -68,7 +68,7 @@ void Radar::deleteList( RadarObject **list ) while( *list ) { RadarObject *nextObject = (*list)->friend_getNext(); - (*list)->friend_getObject()->friend_setRadarData( NULL ); + (*list)->friend_getObject()->friend_setRadarData( nullptr ); deleteInstance(*list); *list = nextObject; } @@ -86,7 +86,7 @@ void Radar::deleteListResources( void ) #ifdef DEBUG_CRASHING for( Object *obj = TheGameLogic->getFirstObject(); obj; obj = obj->getNextObject() ) { - DEBUG_ASSERTCRASH( obj->friend_getRadarData() == NULL, + DEBUG_ASSERTCRASH( obj->friend_getRadarData() == nullptr, ("Radar::deleteListResources: Unexpectedly an object still has radar data assigned") ); } #endif @@ -98,8 +98,8 @@ void Radar::deleteListResources( void ) RadarObject::RadarObject( void ) { - m_object = NULL; - m_next = NULL; + m_object = nullptr; + m_next = nullptr; m_color = GameMakeColor( 255, 255, 255, 255 ); } @@ -123,7 +123,7 @@ Bool RadarObject::isTemporarilyHidden() const Bool RadarObject::isTemporarilyHidden(const Object* obj) { Drawable* draw = obj->getDrawable(); - if (draw == NULL || draw->getStealthLook() == STEALTHLOOK_INVISIBLE || draw->isDrawableEffectivelyHidden()) + if (draw == nullptr || draw->getStealthLook() == STEALTHLOOK_INVISIBLE || draw->isDrawableEffectivelyHidden()) return true; return false; @@ -158,7 +158,7 @@ void RadarObject::xfer( Xfer *xfer ) // find the object and save m_object = TheGameLogic->findObjectByID( objectID ); - if( m_object == NULL ) + if( m_object == nullptr ) { DEBUG_CRASH(( "RadarObject::xfer - Unable to find object for radar data" )); @@ -189,10 +189,10 @@ void RadarObject::loadPostProcess( void ) Radar::Radar( void ) { - m_radarWindow = NULL; - m_objectList = NULL; - m_localObjectList = NULL; - m_localHeroObjectList = NULL; + m_radarWindow = nullptr; + m_objectList = nullptr; + m_localObjectList = nullptr; + m_localHeroObjectList = nullptr; 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; @@ -320,7 +320,7 @@ void Radar::newMap( TerrainLogic *terrain ) // keep a pointer for our radar window Int id = NAMEKEY( "ControlBar.wnd:LeftHUD" ); - m_radarWindow = TheWindowManager->winGetWindowFromId( NULL, id ); + m_radarWindow = TheWindowManager->winGetWindowFromId( nullptr, id ); DEBUG_ASSERTCRASH( m_radarWindow, ("Radar::newMap - Unable to find radar game window") ); // reset all the data in the radar @@ -394,8 +394,8 @@ Bool Radar::addObject( Object *obj ) RadarObject *newObj; // sanity - DEBUG_ASSERTCRASH( obj->friend_getRadarData() == NULL, - ("Radar: addObject - non NULL radar data for '%s'", + DEBUG_ASSERTCRASH( obj->friend_getRadarData() == nullptr, + ("Radar: addObject - non null radar data for '%s'", obj->getTemplate()->getName().str()) ); // allocate a new object @@ -437,7 +437,7 @@ Bool Radar::addObject( Object *obj ) //------------------------------------------------------------------------------------------------- Bool Radar::deleteFromList( Object *obj, RadarObject **list ) { - RadarObject *radarObject, *prevObject = NULL; + RadarObject *radarObject, *prevObject = nullptr; // find the object in list for( radarObject = *list; radarObject; radarObject = radarObject->friend_getNext() ) @@ -447,13 +447,13 @@ Bool Radar::deleteFromList( Object *obj, RadarObject **list ) { // unlink the object from list - if( prevObject == NULL ) + if( prevObject == nullptr ) *list = radarObject->friend_getNext(); // removing head of list else prevObject->friend_setNext( radarObject->friend_getNext() ); - // set the object radar data to NULL - obj->friend_setRadarData( NULL ); + // set the object radar data to null + obj->friend_setRadarData( nullptr ); // delete the object instance deleteInstance(radarObject); @@ -480,7 +480,7 @@ Bool Radar::removeObject( Object *obj ) { // sanity - if( obj->friend_getRadarData() == NULL ) + if( obj->friend_getRadarData() == nullptr ) return FALSE; if( deleteFromList( obj, &m_localHeroObjectList ) == TRUE ) @@ -509,7 +509,7 @@ Bool Radar::radarToWorld2D( const ICoord2D *radar, Coord3D *world ) Int x, y; // sanity - if( radar == NULL || world == NULL ) + if( radar == nullptr || world == nullptr ) return FALSE; // get the coords @@ -559,7 +559,7 @@ Bool Radar::worldToRadar( const Coord3D *world, ICoord2D *radar ) { // sanity - if( world == NULL || radar == NULL ) + if( world == nullptr || radar == nullptr ) return FALSE; // sanity check the world position @@ -600,7 +600,7 @@ Bool Radar::localPixelToRadar( const ICoord2D *pixel, ICoord2D *radar ) { // sanity - if( pixel == NULL || radar == NULL ) + if( pixel == nullptr || radar == nullptr ) return FALSE; // get window size of the radar @@ -670,11 +670,11 @@ Bool Radar::screenPixelToWorld( const ICoord2D *pixel, Coord3D *world ) { // sanity - if( pixel == NULL || world == NULL ) + if( pixel == nullptr || world == nullptr ) return FALSE; // if we have no radar window can't do the conversion - if( m_radarWindow == NULL ) + if( m_radarWindow == nullptr ) return FALSE; // translate pixel coords to local pixel coords relative to the radar window @@ -702,16 +702,16 @@ Object *Radar::objectUnderRadarPixel( const ICoord2D *pixel ) { // sanity - if( pixel == NULL ) - return NULL; + if( pixel == nullptr ) + return nullptr; // convert pixel location to radar logical radar location ICoord2D radar; if( localPixelToRadar( pixel, &radar ) == FALSE ) - return NULL; + return nullptr; // object we will return - Object *obj = NULL; + Object *obj = nullptr; // // scan the objects on the radar list and return any object that maps its world location @@ -722,11 +722,11 @@ Object *Radar::objectUnderRadarPixel( const ICoord2D *pixel ) obj = searchListForRadarLocationMatch( m_localHeroObjectList, &radar ); // search the local object list if not found - if( obj == NULL ) + if( obj == nullptr ) obj = searchListForRadarLocationMatch( m_localObjectList, &radar ); // search all other objects if still not found - if( obj == NULL ) + if( obj == nullptr ) obj = searchListForRadarLocationMatch( m_objectList, &radar ); // return the object found (if any) @@ -741,8 +741,8 @@ Object *Radar::searchListForRadarLocationMatch( RadarObject *listHead, ICoord2D { // sanity - if( listHead == NULL || radarMatch == NULL ) - return NULL; + if( listHead == nullptr || radarMatch == nullptr ) + return nullptr; // scan the list RadarObject *radarObject; @@ -754,10 +754,10 @@ Object *Radar::searchListForRadarLocationMatch( RadarObject *listHead, ICoord2D Object *obj = radarObject->friend_getObject(); // sanity - if( obj == NULL ) + if( obj == nullptr ) { - DEBUG_CRASH(( "Radar::searchListForRadarLocationMatch - NULL object encountered in list" )); + DEBUG_CRASH(( "Radar::searchListForRadarLocationMatch - null object encountered in list" )); continue; } @@ -775,7 +775,7 @@ Object *Radar::searchListForRadarLocationMatch( RadarObject *listHead, ICoord2D } // no match found - return NULL; + return nullptr; } @@ -907,7 +907,7 @@ void Radar::createEvent( const Coord3D *world, RadarEventType type, Real seconds { // sanity - if( world == NULL ) + if( world == nullptr ) return; // lookup the colors we are to used based on the event @@ -952,7 +952,7 @@ void Radar::createPlayerEvent( Player *player, const Coord3D *world, { // sanity - if( player == NULL || world == NULL ) + if( player == nullptr || world == nullptr ) return; // figure out the two colors we should use @@ -995,7 +995,7 @@ void Radar::internalCreateEvent( const Coord3D *world, RadarEventType type, Real static Real secondsBeforeDieToFade = 0.5f; ///< this many seconds before we hit the die frame we start to fade away // sanity - if( world == NULL || color1 == NULL || color2 == NULL ) + if( world == nullptr || color1 == nullptr || color2 == nullptr ) return; // translate the world coord to radar coords @@ -1060,7 +1060,7 @@ void Radar::tryUnderAttackEvent( const Object *obj ) { // sanity - if( obj == NULL ) + if( obj == nullptr ) return; // try to create the event @@ -1183,7 +1183,7 @@ Bool Radar::tryEvent( RadarEventType event, const Coord3D *pos ) { // sanity - if( event <= RADAR_EVENT_INVALID || event >= RADAR_EVENT_NUM_EVENTS || pos == NULL ) + if( event <= RADAR_EVENT_INVALID || event >= RADAR_EVENT_NUM_EVENTS || pos == nullptr ) return FALSE; // see if there was an event of this type within the given range within the given time @@ -1277,7 +1277,7 @@ static void xferRadarObjectList( Xfer *xfer, RadarObject **head ) RadarObject *radarObject; // sanity - DEBUG_ASSERTCRASH( head != NULL, ("xferRadarObjectList - Invalid parameters" )); + DEBUG_ASSERTCRASH( head != nullptr, ("xferRadarObjectList - Invalid parameters" )); // version XferVersion currentVersion = 1; @@ -1308,7 +1308,7 @@ static void xferRadarObjectList( Xfer *xfer, RadarObject **head ) { // the list should be empty at this point as we are loading it as a whole - if( *head != NULL ) + if( *head != nullptr ) { #if 1 // srj sez: yeah, it SHOULD be, but a few rogue things come into existence (via their ctor) preloaded @@ -1318,12 +1318,12 @@ static void xferRadarObjectList( Xfer *xfer, RadarObject **head ) { if (!radarObject->friend_getObject()->isDestroyed()) { - DEBUG_CRASH(( "xferRadarObjectList - List head should be NULL, or contain only destroyed objects" )); + DEBUG_CRASH(( "xferRadarObjectList - List head should be null, or contain only destroyed objects" )); throw SC_INVALID_DATA; } } #else - DEBUG_CRASH(( "xferRadarObjectList - List head should be NULL, but isn't" )); + DEBUG_CRASH(( "xferRadarObjectList - List head should be null, but isn't" )); throw SC_INVALID_DATA; #endif } @@ -1336,13 +1336,13 @@ static void xferRadarObjectList( Xfer *xfer, RadarObject **head ) radarObject = newInstance(RadarObject); // link to the end of the list - if( *head == NULL ) + if( *head == nullptr ) *head = radarObject; else { RadarObject *other; - for( other = *head; other->friend_getNext() != NULL; other = other->friend_getNext() ) + for( other = *head; other->friend_getNext() != nullptr; other = other->friend_getNext() ) { } @@ -1413,10 +1413,10 @@ void Radar::xfer( Xfer *xfer ) // Transfer all local hero objects to local object list. RadarObject **fromList = &m_localHeroObjectList; RadarObject **toList = &m_localObjectList; - while (*fromList != NULL) + while (*fromList != nullptr) { RadarObject* nextObject = (*fromList)->friend_getNext(); - (*fromList)->friend_setNext(NULL); + (*fromList)->friend_setNext(nullptr); linkRadarObject(*fromList, toList); *fromList = nextObject; } @@ -1443,13 +1443,13 @@ void Radar::xfer( Xfer *xfer ) RadarObject *currObject; RadarObject *prevObject; RadarObject *nextObject; - prevObject = NULL; - for (currObject = *fromList; currObject != NULL; currObject = nextObject) + prevObject = nullptr; + for (currObject = *fromList; currObject != nullptr; currObject = nextObject) { nextObject = currObject->friend_getNext(); if (currObject->friend_getObject()->isHero()) { - if (prevObject != NULL) + if (prevObject != nullptr) { prevObject->friend_setNext(nextObject); } @@ -1457,7 +1457,7 @@ void Radar::xfer( Xfer *xfer ) { *fromList = nextObject; } - currObject->friend_setNext(NULL); + currObject->friend_setNext(nullptr); linkRadarObject(currObject, toList); continue; } @@ -1472,7 +1472,7 @@ void Radar::xfer( Xfer *xfer ) if( eventCount != eventCountVerify ) { - DEBUG_CRASH(( "Radar::xfer - size of MAX_RADAR_EVENTS has changed, you must version this xfer method to accomodate the new array size. Was '%d' and is now '%d'", + DEBUG_CRASH(( "Radar::xfer - size of MAX_RADAR_EVENTS has changed, you must version this xfer method to accommodate the new array size. Was '%d' and is now '%d'", eventCount, eventCountVerify )); throw SC_INVALID_DATA; @@ -1540,7 +1540,7 @@ Bool Radar::isPriorityVisible( RadarPriorityType priority ) // ------------------------------------------------------------------------------------------------ void Radar::linkRadarObject( RadarObject *newObj, RadarObject **list ) { - if( *list == NULL ) + if( *list == nullptr ) { // trivial case, an empty list *list = newObj; @@ -1554,9 +1554,9 @@ void Radar::linkRadarObject( RadarObject *newObj, RadarObject **list ) RadarObject *prevObject; RadarObject *nextObject; - DEBUG_ASSERTCRASH(newObj->friend_getNext() == NULL, ("newObj->friend_getNext is not NULL")); + DEBUG_ASSERTCRASH(newObj->friend_getNext() == nullptr, ("newObj->friend_getNext is not null")); - prevObject = NULL; + prevObject = nullptr; prevPriority = RADAR_PRIORITY_INVALID; for( currObject = *list; currObject; currObject = nextObject ) { @@ -1571,7 +1571,7 @@ void Radar::linkRadarObject( RadarObject *newObj, RadarObject **list ) // 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) ) + if( (prevObject == nullptr || prevPriority < newPriority ) && (currPriority >= newPriority) ) { // insert into the list just ahead of currObject if( prevObject ) @@ -1592,7 +1592,7 @@ void Radar::linkRadarObject( RadarObject *newObj, RadarObject **list ) } break; } - else if( nextObject == NULL ) + else if( nextObject == nullptr ) { // at the end of the list, put object here currObject->friend_setNext( newObj ); @@ -1644,7 +1644,7 @@ void Radar::assignObjectColorToRadarObject( RadarObject *radarObj, Object *obj ) useIndicatorColor = false; } - if( useIndicatorColor || (player == NULL) ) + if( useIndicatorColor || (player == nullptr) ) { radarObj->setColor( obj->getIndicatorColor() ); } diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/Snapshot.cpp b/Core/GameEngine/Source/Common/System/Snapshot.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/System/Snapshot.cpp rename to Core/GameEngine/Source/Common/System/Snapshot.cpp diff --git a/Core/GameEngine/Source/Common/System/StreamingArchiveFile.cpp b/Core/GameEngine/Source/Common/System/StreamingArchiveFile.cpp index 1fc9f43b2ea..958ef2a3a2b 100644 --- a/Core/GameEngine/Source/Common/System/StreamingArchiveFile.cpp +++ b/Core/GameEngine/Source/Common/System/StreamingArchiveFile.cpp @@ -102,7 +102,7 @@ //================================================================= StreamingArchiveFile::StreamingArchiveFile() -: m_file(NULL), +: m_file(nullptr), m_startingPos(0), m_size(0), m_curPos(0) @@ -140,12 +140,12 @@ Bool StreamingArchiveFile::open( const Char *filename, Int access, size_t buffer //USE_PERF_TIMER(StreamingArchiveFile) File *file = TheFileSystem->openFile( filename, access, bufferSize ); - if ( file == NULL ) + if ( file == nullptr ) { return FALSE; } - return (open( file ) != NULL); + return open( file ); } //============================================================================ @@ -163,7 +163,7 @@ Bool StreamingArchiveFile::open( File *file ) Bool StreamingArchiveFile::openFromArchive(File *archiveFile, const AsciiString& filename, Int offset, Int size) { //USE_PERF_TIMER(StreamingArchiveFile) - if (archiveFile == NULL) { + if (archiveFile == nullptr) { return FALSE; } diff --git a/GeneralsMD/Code/GameEngine/Source/Common/System/SubsystemInterface.cpp b/Core/GameEngine/Source/Common/System/SubsystemInterface.cpp similarity index 100% rename from GeneralsMD/Code/GameEngine/Source/Common/System/SubsystemInterface.cpp rename to Core/GameEngine/Source/Common/System/SubsystemInterface.cpp diff --git a/Core/GameEngine/Source/Common/System/UnicodeString.cpp b/Core/GameEngine/Source/Common/System/UnicodeString.cpp index af1a6317e3f..386778d321b 100644 --- a/Core/GameEngine/Source/Common/System/UnicodeString.cpp +++ b/Core/GameEngine/Source/Common/System/UnicodeString.cpp @@ -95,7 +95,7 @@ void UnicodeString::ensureUniqueBufferOfSize(int numCharsNeeded, Bool preserveDa return; } - DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != NULL, ("Cannot use dynamic memory allocator before its initialization. Check static initialization order.")); + DEBUG_ASSERTCRASH(TheDynamicMemoryAllocator != nullptr, ("Cannot use dynamic memory allocator before its initialization. Check static initialization order.")); DEBUG_ASSERTCRASH(numCharsNeeded <= MAX_LEN, ("UnicodeString::ensureUniqueBufferOfSize exceeds max string length %d with requested length %d", MAX_LEN, numCharsNeeded)); int minBytes = sizeof(UnicodeStringData) + numCharsNeeded*sizeof(WideChar); int actualBytes = TheDynamicMemoryAllocator->getActualAllocationSize(minBytes); @@ -141,27 +141,27 @@ void UnicodeString::releaseBuffer() { TheDynamicMemoryAllocator->freeBytes(m_data); } - m_data = 0; + m_data = nullptr; } } // ----------------------------------------------------- -UnicodeString::UnicodeString(const WideChar* s) : m_data(NULL) +UnicodeString::UnicodeString(const WideChar* s) : m_data(nullptr) { int len = s ? (int)wcslen(s) : 0; if (len > 0) { - ensureUniqueBufferOfSize(len + 1, false, s, NULL); + ensureUniqueBufferOfSize(len + 1, false, s, nullptr); } validate(); } // ----------------------------------------------------- -UnicodeString::UnicodeString(const WideChar* s, int len) : m_data(NULL) +UnicodeString::UnicodeString(const WideChar* s, int len) : m_data(nullptr) { if (len > 0) { - ensureUniqueBufferOfSize(len + 1, false, s, NULL); + ensureUniqueBufferOfSize(len + 1, false, s, nullptr); } validate(); } @@ -197,7 +197,7 @@ void UnicodeString::set(const WideChar* s, int len) { if (len > 0) { - ensureUniqueBufferOfSize(len + 1, false, s, NULL); + ensureUniqueBufferOfSize(len + 1, false, s, nullptr); } else { @@ -212,7 +212,7 @@ WideChar* UnicodeString::getBufferForRead(Int len) { validate(); DEBUG_ASSERTCRASH(len>0, ("No need to allocate 0 len strings.")); - ensureUniqueBufferOfSize(len + 1, false, NULL, NULL); + ensureUniqueBufferOfSize(len + 1, false, nullptr, nullptr); validate(); return peek(); } @@ -239,7 +239,7 @@ void UnicodeString::concat(const WideChar* s) if (m_data) { - ensureUniqueBufferOfSize(getLength() + addlen + 1, true, NULL, s); + ensureUniqueBufferOfSize(getLength() + addlen + 1, true, nullptr, s); } else { @@ -302,7 +302,7 @@ void UnicodeString::trimEnd(const WideChar c) if (m_data) { - // Clip trailing consecutive occurances of c from the string. + // Clip trailing consecutive occurrences of c from the string. const int len = wcslen(peek()); int index = len; while (index > 0 && getCharAt(index - 1) == c) @@ -333,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, nullptr, nullptr); size_t count = charCount; if (charCount > len) { @@ -354,7 +354,7 @@ void UnicodeString::truncateTo(const Int maxLength) const size_t len = wcslen(peek()); if (len > maxLength) { - ensureUniqueBufferOfSize(len + 1, true, NULL, NULL); + ensureUniqueBufferOfSize(len + 1, true, nullptr, nullptr); peek()[maxLength] = 0; } } diff --git a/Core/GameEngine/Source/Common/System/Xfer.cpp b/Core/GameEngine/Source/Common/System/Xfer.cpp index 4427a7dd0a7..63e13bd5d63 100644 --- a/Core/GameEngine/Source/Common/System/Xfer.cpp +++ b/Core/GameEngine/Source/Common/System/Xfer.cpp @@ -496,7 +496,7 @@ void Xfer::xferSTLIntList( std::list< Int > *intListData ) { // sanity - if( intListData == NULL ) + if( intListData == nullptr ) return; // version @@ -562,7 +562,7 @@ void Xfer::xferScienceType( ScienceType *science ) { // sanity - DEBUG_ASSERTCRASH( science != NULL, ("xferScienceType - Invalid parameters") ); + DEBUG_ASSERTCRASH( science != nullptr, ("xferScienceType - Invalid parameters") ); AsciiString scienceName; @@ -611,7 +611,7 @@ void Xfer::xferScienceVec( ScienceVec *scienceVec ) { // sanity - DEBUG_ASSERTCRASH( scienceVec != NULL, ("xferScienceVec - Invalid parameters") ); + DEBUG_ASSERTCRASH( scienceVec != nullptr, ("xferScienceVec - Invalid parameters") ); // this deserves a version number const XferVersion currentVersion = 1; @@ -792,7 +792,7 @@ void Xfer::xferUpgradeMask( UpgradeMaskType *upgradeMaskData ) // find this upgrade template upgradeTemplate = TheUpgradeCenter->findUpgrade( upgradeName ); - if( upgradeTemplate == NULL ) + if( upgradeTemplate == nullptr ) { DEBUG_CRASH(( "Xfer::xferUpgradeMask - Unknown upgrade '%s'", upgradeName.str() )); @@ -810,7 +810,15 @@ void Xfer::xferUpgradeMask( UpgradeMaskType *upgradeMaskData ) { // just xfer implementation the data itself - xferImplementation( upgradeMaskData, sizeof( UpgradeMaskType ) ); +#if RETAIL_COMPATIBLE_CRC +#if RTS_GENERALS + xferImplementation(upgradeMaskData, 8); // The original upgrade mask was 8 bytes in Generals. +#else + xferImplementation(upgradeMaskData, 16); // The original upgrade mask was 16 bytes in Zero Hour. +#endif +#else + xferImplementation(upgradeMaskData, sizeof(UpgradeMaskType)); +#endif } else diff --git a/Core/GameEngine/Source/Common/System/XferCRC.cpp b/Core/GameEngine/Source/Common/System/XferCRC.cpp index 520cd2cc4fc..c5c3297fd5c 100644 --- a/Core/GameEngine/Source/Common/System/XferCRC.cpp +++ b/Core/GameEngine/Source/Common/System/XferCRC.cpp @@ -34,7 +34,7 @@ #include "Common/XferDeepCRC.h" #include "Common/crc.h" #include "Common/Snapshot.h" -#include "utility/endian_compat.h" +#include "Utility/endian_compat.h" //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- @@ -105,7 +105,7 @@ void XferCRC::addCRC( UnsignedInt val ) void XferCRC::xferSnapshot( Snapshot *snapshot ) { - if( snapshot == NULL ) + if( snapshot == nullptr ) { return; @@ -123,7 +123,7 @@ void XferCRC::xferSnapshot( Snapshot *snapshot ) void XferCRC::xferImplementation( void *data, Int dataSize ) { const UnsignedInt *uintPtr = (const UnsignedInt *) (data); - dataSize *= (data != NULL); + dataSize *= (data != nullptr); int dataBytes = (dataSize / 4); @@ -176,7 +176,7 @@ XferDeepCRC::XferDeepCRC( void ) { m_xferMode = XFER_SAVE; - m_fileFP = NULL; + m_fileFP = nullptr; } @@ -186,7 +186,7 @@ XferDeepCRC::~XferDeepCRC( void ) { // warn the user if a file was left open - if( m_fileFP != NULL ) + if( m_fileFP != nullptr ) { DEBUG_CRASH(( "Warning: Xfer file '%s' was left open", m_identifier.str() )); @@ -205,7 +205,7 @@ void XferDeepCRC::open( AsciiString identifier ) m_xferMode = XFER_SAVE; // sanity, check to see if we're already open - if( m_fileFP != NULL ) + if( m_fileFP != nullptr ) { DEBUG_CRASH(( "Cannot open file '%s' cause we've already got '%s' open", @@ -219,7 +219,7 @@ void XferDeepCRC::open( AsciiString identifier ) // open the file m_fileFP = fopen( identifier.str(), "w+b" ); - if( m_fileFP == NULL ) + if( m_fileFP == nullptr ) { DEBUG_CRASH(( "File '%s' not found", identifier.str() )); @@ -239,7 +239,7 @@ void XferDeepCRC::close( void ) { // sanity, if we don't have an open file we can do nothing - if( m_fileFP == NULL ) + if( m_fileFP == nullptr ) { DEBUG_CRASH(( "Xfer close called, but no file was open" )); @@ -249,7 +249,7 @@ void XferDeepCRC::close( void ) // close the file fclose( m_fileFP ); - m_fileFP = NULL; + m_fileFP = nullptr; // erase the filename m_identifier.clear(); @@ -268,7 +268,7 @@ void XferDeepCRC::xferImplementation( void *data, Int dataSize ) } // sanity - DEBUG_ASSERTCRASH( m_fileFP != NULL, ("XferSave - file pointer for '%s' is NULL", + DEBUG_ASSERTCRASH( m_fileFP != nullptr, ("XferSave - file pointer for '%s' is null", m_identifier.str()) ); // write data to file diff --git a/Core/GameEngine/Source/Common/System/XferLoad.cpp b/Core/GameEngine/Source/Common/System/XferLoad.cpp index 9b1f1981b3c..e8f8484f2a5 100644 --- a/Core/GameEngine/Source/Common/System/XferLoad.cpp +++ b/Core/GameEngine/Source/Common/System/XferLoad.cpp @@ -24,7 +24,7 @@ // FILE: XferLoad.cpp ///////////////////////////////////////////////////////////////////////////// // Author: Colin Day, February 2002 -// Desc: Xfer implemenation for loading from disk +// Desc: Xfer implementation for loading from disk /////////////////////////////////////////////////////////////////////////////////////////////////// // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// @@ -40,7 +40,7 @@ XferLoad::XferLoad( void ) { m_xferMode = XFER_LOAD; - m_fileFP = NULL; + m_fileFP = nullptr; } @@ -50,7 +50,7 @@ XferLoad::~XferLoad( void ) { // warn the user if a file was left open - if( m_fileFP != NULL ) + if( m_fileFP != nullptr ) { DEBUG_CRASH(( "Warning: Xfer file '%s' was left open", m_identifier.str() )); @@ -67,7 +67,7 @@ void XferLoad::open( AsciiString identifier ) { // sanity, check to see if we're already open - if( m_fileFP != NULL ) + if( m_fileFP != nullptr ) { DEBUG_CRASH(( "Cannot open file '%s' cause we've already got '%s' open", @@ -81,7 +81,7 @@ void XferLoad::open( AsciiString identifier ) // open the file m_fileFP = fopen( identifier.str(), "rb" ); - if( m_fileFP == NULL ) + if( m_fileFP == nullptr ) { DEBUG_CRASH(( "File '%s' not found", identifier.str() )); @@ -98,7 +98,7 @@ void XferLoad::close( void ) { // sanity, if we don't have an open file we can do nothing - if( m_fileFP == NULL ) + if( m_fileFP == nullptr ) { DEBUG_CRASH(( "Xfer close called, but no file was open" )); @@ -108,7 +108,7 @@ void XferLoad::close( void ) // close the file fclose( m_fileFP ); - m_fileFP = NULL; + m_fileFP = nullptr; // erase the filename m_identifier.clear(); @@ -122,7 +122,7 @@ Int XferLoad::beginBlock( void ) { // sanity - DEBUG_ASSERTCRASH( m_fileFP != NULL, ("Xfer begin block - file pointer for '%s' is NULL", + DEBUG_ASSERTCRASH( m_fileFP != nullptr, ("Xfer begin block - file pointer for '%s' is null", m_identifier.str()) ); // read block size @@ -155,7 +155,7 @@ void XferLoad::skip( Int dataSize ) { // sanity - DEBUG_ASSERTCRASH( m_fileFP != NULL, ("XferLoad::skip - file pointer for '%s' is NULL", + DEBUG_ASSERTCRASH( m_fileFP != nullptr, ("XferLoad::skip - file pointer for '%s' is null", m_identifier.str()) ); // sanity @@ -174,7 +174,7 @@ void XferLoad::skip( Int dataSize ) void XferLoad::xferSnapshot( Snapshot *snapshot ) { - if( snapshot == NULL ) + if( snapshot == nullptr ) { DEBUG_CRASH(( "XferLoad::xferSnapshot - Invalid parameters" )); @@ -244,7 +244,7 @@ void XferLoad::xferImplementation( void *data, Int dataSize ) { // sanity - DEBUG_ASSERTCRASH( m_fileFP != NULL, ("XferLoad - file pointer for '%s' is NULL", + DEBUG_ASSERTCRASH( m_fileFP != nullptr, ("XferLoad - file pointer for '%s' is null", m_identifier.str()) ); // read data from file diff --git a/Core/GameEngine/Source/Common/System/XferSave.cpp b/Core/GameEngine/Source/Common/System/XferSave.cpp index 292cb6c8838..cb87191ad96 100644 --- a/Core/GameEngine/Source/Common/System/XferSave.cpp +++ b/Core/GameEngine/Source/Common/System/XferSave.cpp @@ -56,8 +56,8 @@ XferSave::XferSave( void ) { m_xferMode = XFER_SAVE; - m_fileFP = NULL; - m_blockStack = NULL; + m_fileFP = nullptr; + m_blockStack = nullptr; } @@ -67,7 +67,7 @@ XferSave::~XferSave( void ) { // warn the user if a file was left open - if( m_fileFP != NULL ) + if( m_fileFP != nullptr ) { DEBUG_CRASH(( "Warning: Xfer file '%s' was left open", m_identifier.str() )); @@ -79,11 +79,11 @@ XferSave::~XferSave( void ) // the block stack should be empty, if it's not that means we started blocks but never // called enough matching end blocks // - if( m_blockStack != NULL ) + if( m_blockStack != nullptr ) { // tell the user there is an error - DEBUG_CRASH(( "Warning: XferSave::~XferSave - m_blockStack was not NULL!" )); + DEBUG_CRASH(( "Warning: XferSave::~XferSave - m_blockStack was not null!" )); // delete the block stack XferBlockData *next; @@ -107,7 +107,7 @@ void XferSave::open( AsciiString identifier ) { // sanity, check to see if we're already open - if( m_fileFP != NULL ) + if( m_fileFP != nullptr ) { DEBUG_CRASH(( "Cannot open file '%s' cause we've already got '%s' open", @@ -121,7 +121,7 @@ void XferSave::open( AsciiString identifier ) // open the file m_fileFP = fopen( identifier.str(), "w+b" ); - if( m_fileFP == NULL ) + if( m_fileFP == nullptr ) { DEBUG_CRASH(( "File '%s' not found", identifier.str() )); @@ -138,7 +138,7 @@ void XferSave::close( void ) { // sanity, if we don't have an open file we can do nothing - if( m_fileFP == NULL ) + if( m_fileFP == nullptr ) { DEBUG_CRASH(( "Xfer close called, but no file was open" )); @@ -148,7 +148,7 @@ void XferSave::close( void ) // close the file fclose( m_fileFP ); - m_fileFP = NULL; + m_fileFP = nullptr; // erase the filename m_identifier.clear(); @@ -166,7 +166,7 @@ Int XferSave::beginBlock( void ) { // sanity - DEBUG_ASSERTCRASH( m_fileFP != NULL, ("Xfer begin block - file pointer for '%s' is NULL", + DEBUG_ASSERTCRASH( m_fileFP != nullptr, ("Xfer begin block - file pointer for '%s' is null", m_identifier.str()) ); // get the current file position so we can back up here for the next end block call @@ -186,7 +186,7 @@ Int XferSave::beginBlock( void ) // save this block position on the top of the "stack" XferBlockData *top = newInstance(XferBlockData); // impossible -- exception will be thrown (srj) -// if( top == NULL ) +// if( top == nullptr ) // { // // DEBUG_CRASH(( "XferSave - Begin block, out of memory - can't save block stack data" )); @@ -211,11 +211,11 @@ void XferSave::endBlock( void ) { // sanity - DEBUG_ASSERTCRASH( m_fileFP != NULL, ("Xfer end block - file pointer for '%s' is NULL", + DEBUG_ASSERTCRASH( m_fileFP != nullptr, ("Xfer end block - file pointer for '%s' is null", m_identifier.str()) ); // sanity, make sure we have a block started - if( m_blockStack == NULL ) + if( m_blockStack == nullptr ) { DEBUG_CRASH(( "Xfer end block called, but no matching begin block was found" )); @@ -258,7 +258,7 @@ void XferSave::skip( Int dataSize ) { // sanity - DEBUG_ASSERTCRASH( m_fileFP != NULL, ("XferSave - file pointer for '%s' is NULL", + DEBUG_ASSERTCRASH( m_fileFP != nullptr, ("XferSave - file pointer for '%s' is null", m_identifier.str()) ); @@ -273,7 +273,7 @@ void XferSave::skip( Int dataSize ) void XferSave::xferSnapshot( Snapshot *snapshot ) { - if( snapshot == NULL ) + if( snapshot == nullptr ) { DEBUG_CRASH(( "XferSave::xferSnapshot - Invalid parameters" )); @@ -343,7 +343,7 @@ void XferSave::xferImplementation( void *data, Int dataSize ) { // sanity - DEBUG_ASSERTCRASH( m_fileFP != NULL, ("XferSave - file pointer for '%s' is NULL", + DEBUG_ASSERTCRASH( m_fileFP != nullptr, ("XferSave - file pointer for '%s' is null", m_identifier.str()) ); // write data to file diff --git a/GeneralsMD/Code/GameEngine/Source/Common/UserPreferences.cpp b/Core/GameEngine/Source/Common/UserPreferences.cpp similarity index 99% rename from GeneralsMD/Code/GameEngine/Source/Common/UserPreferences.cpp rename to Core/GameEngine/Source/Common/UserPreferences.cpp index 7fefc7d5d1f..f4680919d8e 100644 --- a/GeneralsMD/Code/GameEngine/Source/Common/UserPreferences.cpp +++ b/Core/GameEngine/Source/Common/UserPreferences.cpp @@ -127,7 +127,7 @@ Bool UserPreferences::load(AsciiString fname) if (fp) { char buf[LINE_LEN]; - while( fgets( buf, LINE_LEN, fp ) != NULL ) + while( fgets( buf, LINE_LEN, fp ) != nullptr ) { AsciiString line = buf; line.trim(); @@ -663,7 +663,7 @@ AsciiString CustomMatchPreferences::getPreferredMap(void) AsciiString ret; CustomMatchPreferences::const_iterator it = find("Map"); if (it == end()) - { //found find map, use default instead + { //map not found, use default instead ret = getDefaultOfficialMap(); return ret; } @@ -716,7 +716,7 @@ Money CustomMatchPreferences::getStartingCash(void) const } Money money; - money.deposit( strtoul( it->second.str(), NULL, 10 ), FALSE, FALSE ); + money.deposit( strtoul( it->second.str(), nullptr, 10 ), FALSE, FALSE ); return money; } @@ -814,6 +814,7 @@ Int GameSpyMiscPreferences::getMaxMessagesPerUpdate( void ) { return getInt("MaxMessagesPerUpdate", 100); } + //----------------------------------------------------------------------------- // IgnorePreferences base class //----------------------------------------------------------------------------- diff --git a/Core/GameEngine/Source/Common/WorkerProcess.cpp b/Core/GameEngine/Source/Common/WorkerProcess.cpp index 5970225a383..0aaae1842a7 100644 --- a/Core/GameEngine/Source/Common/WorkerProcess.cpp +++ b/Core/GameEngine/Source/Common/WorkerProcess.cpp @@ -67,9 +67,9 @@ static PFN_AssignProcessToJobObject AssignProcessToJobObject = (PFN_AssignProces WorkerProcess::WorkerProcess() { - m_processHandle = NULL; - m_readHandle = NULL; - m_jobHandle = NULL; + m_processHandle = nullptr; + m_readHandle = nullptr; + m_jobHandle = nullptr; m_exitcode = 0; m_isDone = false; } @@ -82,7 +82,7 @@ bool WorkerProcess::startProcess(UnicodeString command) // Create pipe for reading console output SECURITY_ATTRIBUTES saAttr = { sizeof(SECURITY_ATTRIBUTES) }; saAttr.bInheritHandle = TRUE; - HANDLE writeHandle = NULL; + HANDLE writeHandle = nullptr; if (!CreatePipe(&m_readHandle, &writeHandle, &saAttr, 0)) return false; SetHandleInformation(m_readHandle, HANDLE_FLAG_INHERIT, 0); @@ -93,15 +93,15 @@ bool WorkerProcess::startProcess(UnicodeString command) si.hStdError = writeHandle; si.hStdOutput = writeHandle; - PROCESS_INFORMATION pi = { 0 }; + PROCESS_INFORMATION pi = { nullptr }; - if (!CreateProcessW(NULL, (LPWSTR)command.str(), - NULL, NULL, /*bInheritHandles=*/TRUE, 0, - NULL, 0, &si, &pi)) + if (!CreateProcessW(nullptr, (LPWSTR)command.str(), + nullptr, nullptr, /*bInheritHandles=*/TRUE, 0, + nullptr, nullptr, &si, &pi)) { CloseHandle(writeHandle); CloseHandle(m_readHandle); - m_readHandle = NULL; + m_readHandle = nullptr; return false; } @@ -111,8 +111,8 @@ bool WorkerProcess::startProcess(UnicodeString command) // We want to make sure that when our process is killed, our workers automatically terminate as well. // In Windows, the way to do this is to attach the worker to a job we own. - m_jobHandle = CreateJobObjectW != NULL ? CreateJobObjectW(NULL, NULL) : NULL; - if (m_jobHandle != NULL) + m_jobHandle = CreateJobObjectW != nullptr ? CreateJobObjectW(nullptr, nullptr) : nullptr; + if (m_jobHandle != nullptr) { JOBOBJECT_EXTENDED_LIMIT_INFORMATION jobInfo = { 0 }; jobInfo.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE; @@ -125,7 +125,7 @@ bool WorkerProcess::startProcess(UnicodeString command) bool WorkerProcess::isRunning() const { - return m_processHandle != NULL; + return m_processHandle != nullptr; } bool WorkerProcess::isDone() const @@ -149,8 +149,8 @@ bool WorkerProcess::fetchStdOutput() { // Call PeekNamedPipe to make sure ReadFile won't block DWORD bytesAvailable = 0; - DEBUG_ASSERTCRASH(m_readHandle != NULL, ("Is not expected NULL")); - BOOL success = PeekNamedPipe(m_readHandle, NULL, 0, NULL, &bytesAvailable, NULL); + DEBUG_ASSERTCRASH(m_readHandle != nullptr, ("Is not expected null")); + BOOL success = PeekNamedPipe(m_readHandle, nullptr, 0, nullptr, &bytesAvailable, nullptr); if (!success) return true; if (bytesAvailable == 0) @@ -161,7 +161,7 @@ bool WorkerProcess::fetchStdOutput() DWORD readBytes = 0; char buffer[1024]; - success = ReadFile(m_readHandle, buffer, ARRAY_SIZE(buffer)-1, &readBytes, NULL); + success = ReadFile(m_readHandle, buffer, ARRAY_SIZE(buffer)-1, &readBytes, nullptr); if (!success) return true; DEBUG_ASSERTCRASH(readBytes != 0, ("expected readBytes to be non null")); @@ -190,13 +190,13 @@ void WorkerProcess::update() WaitForSingleObject(m_processHandle, INFINITE); GetExitCodeProcess(m_processHandle, &m_exitcode); CloseHandle(m_processHandle); - m_processHandle = NULL; + m_processHandle = nullptr; CloseHandle(m_readHandle); - m_readHandle = NULL; + m_readHandle = nullptr; CloseHandle(m_jobHandle); - m_jobHandle = NULL; + m_jobHandle = nullptr; m_isDone = true; } @@ -206,23 +206,23 @@ void WorkerProcess::kill() if (!isRunning()) return; - if (m_processHandle != NULL) + if (m_processHandle != nullptr) { TerminateProcess(m_processHandle, 1); CloseHandle(m_processHandle); - m_processHandle = NULL; + m_processHandle = nullptr; } - if (m_readHandle != NULL) + if (m_readHandle != nullptr) { CloseHandle(m_readHandle); - m_readHandle = NULL; + m_readHandle = nullptr; } - if (m_jobHandle != NULL) + if (m_jobHandle != nullptr) { CloseHandle(m_jobHandle); - m_jobHandle = NULL; + m_jobHandle = nullptr; } m_stdOutput.clear(); diff --git a/Core/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp b/Core/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp new file mode 100644 index 00000000000..eb5adf62d1b --- /dev/null +++ b/Core/GameEngine/Source/GameClient/GUI/ChallengeGenerals.cpp @@ -0,0 +1,160 @@ +/* +** 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 . +*/ + +//////////////////////////////////////////////////////////////////////////////// +// // +// (c) 2001-2003 Electronic Arts Inc. // +// // +//////////////////////////////////////////////////////////////////////////////// + +// FILE: ChallengeGenerals.h ////////////////////////////////////////////////////////////////////// +// Author: Steve Copeland, 6/24/2003 +// Desc: This is a manager for data pertaining to the Generals' Challenge personas and related GUI. +/////////////////////////////////////////////////////////////////////////////////////////////////// + +#include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine + +#include "GameClient/ChallengeGenerals.h" + + +ChallengeGenerals *TheChallengeGenerals = nullptr; + +ChallengeGenerals *createChallengeGenerals( void ) +{ + return MSGNEW("ChallengeGenerals") ChallengeGenerals; +} + + +ChallengeGenerals::ChallengeGenerals() +{ + //ctor +} + + +ChallengeGenerals::~ChallengeGenerals() +{ + //dtor +} + + +void ChallengeGenerals::init( void ) +{ + INI ini; + ini.loadFileDirectory( "Data\\INI\\ChallengeMode", INI_LOAD_OVERWRITE, nullptr ); +} + + +void ChallengeGenerals::parseGeneralPersona(INI *ini, void *instance, void *store, const void *userData) +{ + static const FieldParse dataFieldParse[] = + { + { "StartsEnabled", INI::parseBool, nullptr, offsetof( GeneralPersona, m_bStartsEnabled ) }, + { "BioNameString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioName ) }, + { "BioDOBString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioDOB ) }, + { "BioBirthplaceString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioBirthplace ) }, + { "BioStrategyString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioStrategy ) }, + { "BioRankString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioRank ) }, + { "BioBranchString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioBranch ) }, + { "BioClassNumberString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strBioClassNumber ) }, + { "BioPortraitSmall", INI::parseMappedImage, nullptr, offsetof( GeneralPersona, m_imageBioPortraitSmall ) }, + { "BioPortraitLarge", INI::parseMappedImage, nullptr, offsetof( GeneralPersona, m_imageBioPortraitLarge ) }, + { "Campaign", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strCampaign ) }, + { "PlayerTemplate", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strPlayerTemplateName ) }, + { "PortraitMovieLeftName", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strPortraitMovieLeftName ) }, + { "PortraitMovieRightName", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strPortraitMovieRightName ) }, + { "DefeatedImage", INI::parseMappedImage, nullptr, offsetof( GeneralPersona, m_imageDefeated ) }, + { "VictoriousImage", INI::parseMappedImage, nullptr, offsetof( GeneralPersona, m_imageVictorious ) }, + { "DefeatedString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strDefeated ) }, + { "VictoriousString", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strVictorious ) }, + { "SelectionSound", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strSelectionSound ) }, + { "TauntSound1", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strTauntSound1 ) }, + { "TauntSound2", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strTauntSound2 ) }, + { "TauntSound3", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strTauntSound3 ) }, + { "WinSound", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strWinSound ) }, + { "LossSound", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strLossSound ) }, + { "PreviewSound", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strPreviewSound ) }, + { "NameSound", INI::parseAsciiString, nullptr, offsetof( GeneralPersona, m_strNameSound ) }, + + { nullptr, nullptr, nullptr, 0 } + }; + ini->initFromINI(store, dataFieldParse); +} + + +const FieldParse ChallengeGenerals::s_fieldParseTable[] = +{ + { "GeneralPersona0", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[0] ) }, + { "GeneralPersona1", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[1] ) }, + { "GeneralPersona2", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[2] ) }, + { "GeneralPersona3", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[3] ) }, + { "GeneralPersona4", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[4] ) }, + { "GeneralPersona5", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[5] ) }, + { "GeneralPersona6", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[6] ) }, + { "GeneralPersona7", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[7] ) }, + { "GeneralPersona8", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[8] ) }, + { "GeneralPersona9", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[9] ) }, + { "GeneralPersona10", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[10] ) }, + { "GeneralPersona11", ChallengeGenerals::parseGeneralPersona, nullptr, offsetof( ChallengeGenerals, m_position[11] ) }, + { nullptr, nullptr, nullptr, 0 } +}; + + +//------------------------------------------------------------------------------------------------- +/** Parse Gen Challenge entries */ +//------------------------------------------------------------------------------------------------- +void INI::parseChallengeModeDefinition( INI* ini ) +{ + if( TheChallengeGenerals ) + { + ini->initFromINI( TheChallengeGenerals, TheChallengeGenerals->getFieldParse() ); + } +} + +const GeneralPersona* ChallengeGenerals::getPlayerGeneralByCampaignName( AsciiString name ) const +{ + for (Int i = 0; i < NUM_GENERALS; i++) + { + AsciiString campaignName = m_position[i].getCampaign(); + if (campaignName.compareNoCase( name.str() ) == 0) + return &m_position[i]; + } + DEBUG_CRASH(("Can't find General by Campaign Name")); + return nullptr; +} + +const GeneralPersona* ChallengeGenerals::getGeneralByGeneralName( AsciiString name ) const +{ + for (Int i = 0; i < NUM_GENERALS; i++) + { + AsciiString generalName = m_position[i].getBioName(); + if (generalName.compareNoCase( name.str() ) == 0) + return &m_position[i]; + } + return nullptr; +} + +const GeneralPersona* ChallengeGenerals::getGeneralByTemplateName( AsciiString name ) const +{ + for (Int i = 0; i < NUM_GENERALS; i++) + { + AsciiString templateName = m_position[i].getPlayerTemplateName(); + if (templateName.compareNoCase( name.str() ) == 0) + return &m_position[i]; + } + return nullptr; +} diff --git a/Core/GameEngine/Source/GameClient/GUI/WindowVideoManager.cpp b/Core/GameEngine/Source/GameClient/GUI/WindowVideoManager.cpp index 0bbbfde983e..d1578af7c7f 100644 --- a/Core/GameEngine/Source/GameClient/GUI/WindowVideoManager.cpp +++ b/Core/GameEngine/Source/GameClient/GUI/WindowVideoManager.cpp @@ -82,9 +82,9 @@ WindowVideo::WindowVideo( void ) { m_playType = WINDOW_PLAY_MOVIE_ONCE; - m_win = NULL; - m_videoBuffer = NULL; - m_videoStream = NULL; + m_win = nullptr; + m_videoBuffer = nullptr; + m_videoStream = nullptr; m_movieName.clear(); m_state = WINDOW_VIDEO_STATE_STOP; @@ -92,18 +92,18 @@ WindowVideo::WindowVideo( void ) WindowVideo::~WindowVideo( void ) { - // Don't Delete the window, only set it's video buffer to NULL + // Don't Delete the window, only set it's video buffer to null if(m_win) - m_win->winGetInstanceData()->setVideoBuffer( NULL ); - m_win = NULL; + m_win->winGetInstanceData()->setVideoBuffer( nullptr ); + m_win = nullptr; delete m_videoBuffer; - m_videoBuffer = NULL; + m_videoBuffer = nullptr; if ( m_videoStream ) { m_videoStream->close(); - m_videoStream = NULL; + m_videoStream = nullptr; } } @@ -126,7 +126,7 @@ void WindowVideo::setWindowState( WindowVideoStates state ) m_state = state; if(m_state == WINDOW_VIDEO_STATE_STOP && m_win) - m_win->winGetInstanceData()->setVideoBuffer( NULL ); + m_win->winGetInstanceData()->setVideoBuffer( nullptr ); if((m_state == WINDOW_VIDEO_STATE_PLAY || m_state == WINDOW_VIDEO_STATE_PAUSE )&& m_win) m_win->winGetInstanceData()->setVideoBuffer( m_videoBuffer ); @@ -258,26 +258,26 @@ void WindowVideoManager::playMovie( GameWindow *win, AsciiString movieName, Wind // create the new stream VideoStreamInterface *videoStream = TheVideoPlayer->open( movieName ); - if ( videoStream == NULL ) + if ( videoStream == nullptr ) { return; } // Create the new buffer VideoBuffer *videoBuffer = TheDisplay->createVideoBuffer(); - if ( videoBuffer == NULL || + if ( videoBuffer == nullptr || !videoBuffer->allocate( videoStream->width(), videoStream->height()) ) { // If we failed to create the buffer... delete videoBuffer; - videoBuffer = NULL; + videoBuffer = nullptr; if ( videoStream ) { videoStream->close(); - videoStream = NULL; + videoStream = nullptr; } return; diff --git a/Core/GameEngine/Source/GameClient/MapUtil.cpp b/Core/GameEngine/Source/GameClient/MapUtil.cpp index a99f1cdc36f..1a12c47e344 100644 --- a/Core/GameEngine/Source/GameClient/MapUtil.cpp +++ b/Core/GameEngine/Source/GameClient/MapUtil.cpp @@ -71,10 +71,10 @@ static Int m_height = 0; ///< Height map height (y size of array). static Int m_borderSize = 0; ///< Non-playable border area. static std::vector m_boundaries; ///< All the boundaries we use for the map static Int m_dataSize = 0; ///< size of m_data. -static UnsignedByte *m_data = 0; ///< array of z(height) values in the height map. +static UnsignedByte *m_data = nullptr; ///< array of z(height) values in the height map. static Dict worldDict = 0; -static WaypointMap *m_waypoints = 0; +static WaypointMap *m_waypoints = nullptr; static Coord3DList m_supplyPositions; static Coord3DList m_techPositions; @@ -101,7 +101,7 @@ static UnsignedInt calcCRC( AsciiString fname ) } fp->close(); - fp = NULL; + fp = nullptr; return theCRC.get(); } @@ -157,7 +157,7 @@ static Bool ParseObjectDataChunk(DataChunkInput &file, DataChunkInfo *info, void static Bool ParseObjectsDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData) { - file.m_currentObject = NULL; + file.m_currentObject = nullptr; file.registerParser( "Object", info->label, ParseObjectDataChunk ); return (file.parse(userData)); } @@ -233,7 +233,7 @@ static Bool loadMap( AsciiString filename ) file.registerParser( "HeightMapData", AsciiString::TheEmptyString, ParseSizeOnlyInChunk ); file.registerParser( "WorldInfo", AsciiString::TheEmptyString, ParseWorldDictDataChunk ); file.registerParser( "ObjectsList", AsciiString::TheEmptyString, ParseObjectsDataChunk ); - if (!file.parse(NULL)) { + if (!file.parse(nullptr)) { throw(ERROR_CORRUPT_FILE_FORMAT); } @@ -246,10 +246,10 @@ static Bool loadMap( AsciiString filename ) static void resetMap( void ) { delete[] m_data; - m_data = NULL; + m_data = nullptr; delete m_waypoints; - m_waypoints = NULL; + m_waypoints = nullptr; m_techPositions.clear(); m_supplyPositions.clear(); @@ -338,8 +338,8 @@ void MapCache::writeCacheINI( const AsciiString &mapDir ) filepath.concat(m_mapCacheName); FILE *fp = fopen(filepath.str(), "w"); - DEBUG_ASSERTCRASH(fp != NULL, ("Failed to create %s", filepath.str())); - if (fp == NULL) { + DEBUG_ASSERTCRASH(fp != nullptr, ("Failed to create %s", filepath.str())); + if (fp == nullptr) { return; } @@ -504,7 +504,7 @@ void MapCache::loadMapsFromMapCacheINI( const AsciiString &mapDir ) if (TheFileSystem->doesFileExist(fname.str())) { - ini.load( fname, INI_LOAD_OVERWRITE, NULL ); + ini.load( fname, INI_LOAD_OVERWRITE, nullptr ); } } @@ -712,7 +712,7 @@ Bool MapCache::addMap( return TRUE; } -MapCache *TheMapCache = NULL; +MapCache *TheMapCache = nullptr; // PUBLIC FUNCTIONS ////////////////////////////////////////////////////////////////////////////// @@ -744,17 +744,17 @@ static void buildMapListForNumPlayers(MapNameList &outMapNames, MapDisplayToFile struct MapListBoxData { MapListBoxData() - : listbox(NULL) + : listbox(nullptr) , numLength(0) , numColumns(0) , w(10) , h(10) , color(GameMakeColor(255, 255, 255, 255)) - , battleHonors(NULL) - , easyImage(NULL) - , mediumImage(NULL) - , brutalImage(NULL) - , maxBrutalImage(NULL) + , battleHonors(nullptr) + , easyImage(nullptr) + , mediumImage(nullptr) + , brutalImage(nullptr) + , maxBrutalImage(nullptr) , mapToSelect() , selectionIndex(0) // always select *something* , isMultiplayer(false) @@ -802,7 +802,7 @@ static Bool addMapToMapListbox( if (numBrutal) { const Int maxBrutalSlots = mapMetaData.m_numPlayers - 1; - if (lbData.maxBrutalImage != NULL && numBrutal == maxBrutalSlots) + if (lbData.maxBrutalImage != nullptr && numBrutal == maxBrutalSlots) { index = GadgetListBoxAddEntryImage( lbData.listbox, lbData.maxBrutalImage, index, 0, lbData.w, lbData.h, TRUE); imageItemData = 4; @@ -826,7 +826,7 @@ static Bool addMapToMapListbox( else { imageItemData = 0; - index = GadgetListBoxAddEntryImage( lbData.listbox, NULL, index, 0, lbData.w, lbData.h, TRUE); + index = GadgetListBoxAddEntryImage( lbData.listbox, nullptr, index, 0, lbData.w, lbData.h, TRUE); } } @@ -963,7 +963,7 @@ Int populateMapListboxNoReset( GameWindow *listbox, Bool useSystemMaps, Bool isM } delete lbData.battleHonors; - lbData.battleHonors = NULL; + lbData.battleHonors = nullptr; GadgetListBoxSetSelected(listbox, &lbData.selectionIndex, 1); @@ -1083,7 +1083,7 @@ const MapMetaData *MapCache::findMap(AsciiString mapName) mapName.toLower(); MapCache::iterator it = find(mapName); if (it == end()) - return NULL; + return nullptr; return &(it->second); } @@ -1095,7 +1095,7 @@ static void copyFromBigToDir( const AsciiString& infile, const AsciiString& outf // open the map file File *file = TheFileSystem->openFile( infile.str(), File::READ | File::BINARY ); - if( file == NULL ) + if( file == nullptr ) { DEBUG_CRASH(( "copyFromBigToDir - Error opening source file '%s'", infile.str() )); throw SC_INVALID_DATA; @@ -1110,7 +1110,7 @@ static void copyFromBigToDir( const AsciiString& infile, const AsciiString& outf // allocate buffer big enough to hold the entire map file char *buffer = NEW char[ fileSize ]; - if( buffer == NULL ) + if( buffer == nullptr ) { DEBUG_CRASH(( "copyFromBigToDir - Unable to allocate buffer for file '%s'", infile.str() )); throw SC_INVALID_DATA; @@ -1142,7 +1142,7 @@ static void copyFromBigToDir( const AsciiString& infile, const AsciiString& outf Image *getMapPreviewImage( AsciiString mapName ) { if(!TheGlobalData) - return NULL; + return nullptr; DEBUG_LOG(("%s Map Name", mapName.str())); AsciiString tgaName = mapName; AsciiString name; @@ -1174,7 +1174,7 @@ Image *getMapPreviewImage( AsciiString mapName ) { if(!TheFileSystem->doesFileExist(tgaName.str())) - return NULL; + return nullptr; AsciiString mapPreviewDir; mapPreviewDir.format(MAP_PREVIEW_DIR_PATH, TheGlobalData->getPath_UserData().str()); TheFileSystem->createDirectory(mapPreviewDir); @@ -1211,7 +1211,7 @@ Image *getMapPreviewImage( AsciiString mapName ) } else { - image = NULL; + image = nullptr; } } @@ -1222,7 +1222,7 @@ Image *getMapPreviewImage( AsciiString mapName ) /* // sanity if( mapName.isEmpty() ) - return NULL; + return nullptr; Region2D uv; mapPreviewImage = TheMappedImageCollection->findImageByName("MapPreview"); if(mapPreviewImage) @@ -1255,10 +1255,10 @@ Image *getMapPreviewImage( AsciiString mapName ) if (file.isValidFileType()) { // Backwards compatible files aren't valid data chunk files. // Read the waypoints. file.registerParser( "MapPreview", AsciiString::TheEmptyString, parseMapPreviewChunk ); - if (!file.parse(NULL)) { + if (!file.parse(nullptr)) { DEBUG_ASSERTCRASH(false,("Unable to read MapPreview info.")); deleteInstance(mapPreviewImage); - return NULL; + return nullptr; } } theInputStream.close(); @@ -1266,14 +1266,14 @@ Image *getMapPreviewImage( AsciiString mapName ) else { deleteInstance(mapPreviewImage); - return NULL; + return nullptr; } return mapPreviewImage; */ - return NULL; + return nullptr; } Bool parseMapPreviewChunk(DataChunkInput &file, DataChunkInfo *info, void *userData) @@ -1290,12 +1290,15 @@ Bool parseMapPreviewChunk(DataChunkInput &file, DataChunkInfo *info, void *userD //texture->Get_Surface_Level(); DEBUG_LOG(("BeginMapPreviewInfo")); + int pitch; + void *pBits = surface->Lock(&pitch); + const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel(); UnsignedInt *buffer = new UnsignedInt[size.x * size.y]; Int x,y; for (y=0; yDrawPixel( x, y, file.readInt() ); + surface->Draw_Pixel( x, y, file.readInt(), bytesPerPixel, pBits, pitch ); buffer[y + x] = file.readInt(); DEBUG_LOG(("x:%d, y:%d, %X", x, y, buffer[y + x])); } @@ -1303,6 +1306,7 @@ Bool parseMapPreviewChunk(DataChunkInput &file, DataChunkInfo *info, void *userD mapPreviewImage->setRawTextureData(buffer); DEBUG_ASSERTCRASH(file.atEndOfChunk(), ("Unexpected data left over.")); DEBUG_LOG(("EndMapPreviewInfo")); + surface->Unlock(); REF_PTR_RELEASE(surface); return true; */ diff --git a/Core/GameEngine/Source/GameClient/Snow.cpp b/Core/GameEngine/Source/GameClient/Snow.cpp index 46615690a76..737ac561334 100644 --- a/Core/GameEngine/Source/GameClient/Snow.cpp +++ b/Core/GameEngine/Source/GameClient/Snow.cpp @@ -32,7 +32,7 @@ #include "GameClient/View.h" -SnowManager *TheSnowManager=NULL; +SnowManager *TheSnowManager=nullptr; SnowManager::SnowManager() { @@ -93,38 +93,38 @@ void SnowManager::reset(void) SnowManager::~SnowManager() { delete [] m_startingHeights; - m_startingHeights=NULL; + m_startingHeights=nullptr; // TheSuperHackers @fix Mauller 13/04/2025 Delete the instance of the weather settings deleteInstance((WeatherSetting*)TheWeatherSetting.getNonOverloadedPointer()); - TheWeatherSetting=NULL; + TheWeatherSetting=nullptr; } -OVERRIDE TheWeatherSetting = NULL; +OVERRIDE TheWeatherSetting = nullptr; // PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// const FieldParse WeatherSetting::m_weatherSettingFieldParseTable[] = { - { "SnowTexture", INI::parseAsciiString,NULL, offsetof( WeatherSetting, m_snowTexture ) }, - { "SnowFrequencyScaleX", INI::parseReal,NULL, offsetof( WeatherSetting, m_snowFrequencyScaleX ) }, - { "SnowFrequencyScaleY", INI::parseReal,NULL, offsetof( WeatherSetting, m_snowFrequencyScaleY ) }, - { "SnowAmplitude", INI::parseReal,NULL, offsetof( WeatherSetting, m_snowAmplitude ) }, - { "SnowPointSize", INI::parseReal,NULL, offsetof( WeatherSetting, m_snowPointSize ) }, - { "SnowMaxPointSize", INI::parseReal,NULL, offsetof( WeatherSetting, m_snowMaxPointSize ) }, - { "SnowMinPointSize", INI::parseReal,NULL, offsetof( WeatherSetting, m_snowMinPointSize ) }, - { "SnowQuadSize", INI::parseReal,NULL, offsetof( WeatherSetting, m_snowQuadSize ) }, - { "SnowBoxDimensions", INI::parseReal,NULL, offsetof( WeatherSetting, m_snowBoxDimensions ) }, - { "SnowBoxDensity", INI::parseReal,NULL, offsetof( WeatherSetting, m_snowBoxDensity ) }, - { "SnowVelocity", INI::parseReal,NULL, offsetof( WeatherSetting, m_snowVelocity ) }, - { "SnowPointSprites", INI::parseBool,NULL, offsetof( WeatherSetting, m_usePointSprites ) }, - { "SnowEnabled", INI::parseBool,NULL, offsetof( WeatherSetting, m_snowEnabled ) }, - { 0, 0, 0, 0 }, + { "SnowTexture", INI::parseAsciiString,nullptr, offsetof( WeatherSetting, m_snowTexture ) }, + { "SnowFrequencyScaleX", INI::parseReal,nullptr, offsetof( WeatherSetting, m_snowFrequencyScaleX ) }, + { "SnowFrequencyScaleY", INI::parseReal,nullptr, offsetof( WeatherSetting, m_snowFrequencyScaleY ) }, + { "SnowAmplitude", INI::parseReal,nullptr, offsetof( WeatherSetting, m_snowAmplitude ) }, + { "SnowPointSize", INI::parseReal,nullptr, offsetof( WeatherSetting, m_snowPointSize ) }, + { "SnowMaxPointSize", INI::parseReal,nullptr, offsetof( WeatherSetting, m_snowMaxPointSize ) }, + { "SnowMinPointSize", INI::parseReal,nullptr, offsetof( WeatherSetting, m_snowMinPointSize ) }, + { "SnowQuadSize", INI::parseReal,nullptr, offsetof( WeatherSetting, m_snowQuadSize ) }, + { "SnowBoxDimensions", INI::parseReal,nullptr, offsetof( WeatherSetting, m_snowBoxDimensions ) }, + { "SnowBoxDensity", INI::parseReal,nullptr, offsetof( WeatherSetting, m_snowBoxDensity ) }, + { "SnowVelocity", INI::parseReal,nullptr, offsetof( WeatherSetting, m_snowVelocity ) }, + { "SnowPointSprites", INI::parseBool,nullptr, offsetof( WeatherSetting, m_usePointSprites ) }, + { "SnowEnabled", INI::parseBool,nullptr, offsetof( WeatherSetting, m_snowEnabled ) }, + { nullptr, nullptr, nullptr, 0 }, }; //------------------------------------------------------------------------------------------------- void INI::parseWeatherDefinition( INI *ini ) { - if (TheWeatherSetting == NULL) { + if (TheWeatherSetting == nullptr) { TheWeatherSetting = newInstance(WeatherSetting); } else if (ini->getLoadType() == INI_LOAD_CREATE_OVERRIDES) { WeatherSetting* ws = (WeatherSetting*) (TheWeatherSetting.getNonOverloadedPointer()); diff --git a/Core/GameEngine/Source/GameClient/System/Debug/AudioDebugDisplay.cpp b/Core/GameEngine/Source/GameClient/System/Debug/AudioDebugDisplay.cpp index 363cde812a7..9eefbefe9ae 100644 --- a/Core/GameEngine/Source/GameClient/System/Debug/AudioDebugDisplay.cpp +++ b/Core/GameEngine/Source/GameClient/System/Debug/AudioDebugDisplay.cpp @@ -106,9 +106,9 @@ static void printFunc( char *text ) //============================================================================ #if defined(RTS_DEBUG) -void AudioDebugDisplay ( DebugDisplayInterface *dd, void *, FILE *fp = NULL ) +void AudioDebugDisplay ( DebugDisplayInterface *dd, void *, FILE *fp = nullptr ) { - TheAudio->audioDebugDisplay( dd, NULL, fp ); + TheAudio->audioDebugDisplay( dd, nullptr, fp ); } #endif diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp similarity index 87% rename from GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp rename to Core/GameEngine/Source/GameClient/System/ParticleSys.cpp index aea2fa2b336..4e4e6d6970a 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/System/ParticleSys.cpp +++ b/Core/GameEngine/Source/GameClient/System/ParticleSys.cpp @@ -58,7 +58,7 @@ //------------------------------------------------------------------------------------------------- // the singleton -ParticleSystemManager *TheParticleSystemManager = NULL; +ParticleSystemManager *TheParticleSystemManager = nullptr; /////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////// @@ -68,9 +68,17 @@ ParticleSystemManager *TheParticleSystemManager = NULL; // ------------------------------------------------------------------------------------------------ ParticleInfo::ParticleInfo( void ) { +#if PARTICLE_USE_XY_ROTATION + m_angleX = 0.0f; + m_angleY = 0.0f; +#endif m_angleZ = 0.0f; - m_angularDamping = 0.0f; +#if PARTICLE_USE_XY_ROTATION + m_angularRateX = 0.0f; + m_angularRateY = 0.0f; +#endif m_angularRateZ = 0.0f; + m_angularDamping = 0.0f; m_colorScale =0.0f; m_size = 0.0f; m_sizeRate = 0.0f; @@ -122,14 +130,24 @@ void ParticleInfo::xfer( Xfer *xfer ) xfer->xferReal( &m_velDamping ); // angle +#if PARTICLE_USE_XY_ROTATION + xfer->xferReal( &m_angleX ); + xfer->xferReal( &m_angleY ); +#else Real tempAngle=0; //temporary value to save out for backwards compatibility when we supported x,y xfer->xferReal( &tempAngle ); xfer->xferReal( &tempAngle ); +#endif xfer->xferReal( &m_angleZ ); // angular rate +#if PARTICLE_USE_XY_ROTATION + xfer->xferReal( &m_angularRateX ); + xfer->xferReal( &m_angularRateY ); +#else xfer->xferReal( &tempAngle ); xfer->xferReal( &tempAngle ); +#endif xfer->xferReal( &m_angularRateZ ); // lifetime @@ -257,6 +275,10 @@ Particle::Particle( ParticleSystem *system, const ParticleInfo *info ) m_vel = info->m_vel; m_pos = info->m_pos; +#if PARTICLE_USE_XY_ROTATION + m_angleX = info->m_angleX; + m_angleY = info->m_angleY; +#endif m_angleZ = info->m_angleZ; m_lastPos.zero(); @@ -264,7 +286,10 @@ Particle::Particle( ParticleSystem *system, const ParticleInfo *info ) m_particleUpTowardsEmitter = info->m_particleUpTowardsEmitter; m_emitterPos = info->m_emitterPos; - +#if PARTICLE_USE_XY_ROTATION + m_angularRateX = info->m_angularRateX; + m_angularRateY = info->m_angularRateY; +#endif m_angularRateZ = info->m_angularRateZ; m_angularDamping = info->m_angularDamping; @@ -299,7 +324,7 @@ Particle::Particle( ParticleSystem *system, const ParticleInfo *info ) m_colorScale = info->m_colorScale; m_inSystemList = m_inOverallList = FALSE; - m_systemPrev = m_systemNext = m_overallPrev = m_overallNext = NULL; + m_systemPrev = m_systemNext = m_overallPrev = m_overallNext = nullptr; // add this particle to the global list, retaining particle creation order TheParticleSystemManager->addParticle(this, system->getPriority() ); @@ -324,7 +349,7 @@ Particle::~Particle() m_systemUnderControl->detachControlParticle( this ); m_systemUnderControl->destroy(); } - m_systemUnderControl = NULL; + m_systemUnderControl = nullptr; // remove from the global list TheParticleSystemManager->removeParticle(this); @@ -370,7 +395,15 @@ Bool Particle::update( void ) doWindMotion(); // update orientation +#if PARTICLE_USE_XY_ROTATION + m_angleX += m_angularRateX; + m_angleY += m_angularRateY; +#endif m_angleZ += m_angularRateZ; +#if PARTICLE_USE_XY_ROTATION + m_angularRateX *= m_angularDamping; + m_angularRateY *= m_angularDamping; +#endif m_angularRateZ *= m_angularDamping; if (m_particleUpTowardsEmitter) { @@ -380,8 +413,6 @@ Bool Particle::update( void ) emitterDir.x = m_pos.x - m_emitterPos.x; emitterDir.y = m_pos.y - m_emitterPos.y; m_angleZ = (angleBetween(&upVec, &emitterDir) + PI); - - } // update size @@ -461,7 +492,9 @@ Bool Particle::update( void ) // reset the acceleration for accumulation next frame - m_accel.z=m_accel.y=m_accel.x= 0.0f; + m_accel.x = 0.0f; + m_accel.y = 0.0f; + m_accel.z = 0.0f; // monitor lifetime if (m_lifetimeLeft && --m_lifetimeLeft == 0) @@ -549,7 +582,7 @@ void Particle::doWindMotion( void ) windForceStrength *= (1.0f - ((distFromWind - fullForceDistance) / (noForceDistance - fullForceDistance))); - // integate the wind motion into the position + // integrate the wind motion into the position m_pos.x += (Cos( windAngle ) * windForceStrength); m_pos.y += (Sin( windAngle ) * windForceStrength); @@ -578,14 +611,14 @@ Bool Particle::isInvisible( void ) // check that we're not in the process of going to another color if (m_colorKey[ m_colorTargetKey ].frame == 0) { - if ((m_color.red + m_color.green + m_color.blue) <= 0.06f) + if (m_color.red < 0.01f && m_color.green < 0.01f && m_color.blue < 0.01f) return true; } return false; case ParticleSystemInfo::ALPHA: // if alpha is zero, this particle is invisible - if (m_alpha < 0.02f) + if (m_alpha < 0.01f) return true; return false; @@ -599,7 +632,7 @@ Bool Particle::isInvisible( void ) // check that we're not in the process of going to another color if (m_colorKey[ m_colorTargetKey ].frame == 0) { - if ((m_color.red * m_color.green * m_color.blue) > 0.95f) + if (m_color.red > 0.99f && m_color.green > 0.99f && m_color.blue > 0.99f) return true; } return false; @@ -698,7 +731,7 @@ void Particle::loadPostProcess( void ) controlParticleSystem( system ); // sanity - if( m_systemUnderControlID == NULL ) + if( m_systemUnderControlID == INVALID_PARTICLE_SYSTEM_ID ) { DEBUG_CRASH(( "Particle::loadPostProcess - Unable to find system under control pointer" )); @@ -813,14 +846,24 @@ void ParticleSystemInfo::xfer( Xfer *xfer ) xfer->xferAsciiString( &m_particleTypeName ); // angles +#if PARTICLE_USE_XY_ROTATION + xfer->xferUser( &m_angleX, sizeof( GameClientRandomVariable ) ); + xfer->xferUser( &m_angleY, sizeof( GameClientRandomVariable ) ); +#else GameClientRandomVariable tempRandom; //for backwards compatibility when we supported x,y xfer->xferUser( &tempRandom, sizeof( GameClientRandomVariable ) ); xfer->xferUser( &tempRandom, sizeof( GameClientRandomVariable ) ); +#endif xfer->xferUser( &m_angleZ, sizeof( GameClientRandomVariable ) ); // angular rate +#if PARTICLE_USE_XY_ROTATION + xfer->xferUser( &m_angularRateX, sizeof( GameClientRandomVariable ) ); + xfer->xferUser( &m_angularRateY, sizeof( GameClientRandomVariable ) ); +#else xfer->xferUser( &tempRandom, sizeof( GameClientRandomVariable ) ); xfer->xferUser( &tempRandom, sizeof( GameClientRandomVariable ) ); +#endif xfer->xferUser( &m_angularRateZ, sizeof( GameClientRandomVariable ) ); // angular damping @@ -1038,7 +1081,7 @@ ParticleSystem::ParticleSystem( const ParticleSystemTemplate *sysTemplate, ParticleSystemID id, Bool createSlaves ) { - m_systemParticlesHead = m_systemParticlesTail = NULL; + m_systemParticlesHead = m_systemParticlesTail = nullptr; m_isFirstPos = true; m_template = sysTemplate; @@ -1056,7 +1099,7 @@ ParticleSystem::ParticleSystem( const ParticleSystemTemplate *sysTemplate, m_isIdentity = true; m_transform.Make_Identity(); - m_skipParentXfrm = false; + m_skipParentXfrm = false; m_isStopped = false; m_isDestroyed = false; @@ -1118,7 +1161,15 @@ ParticleSystem::ParticleSystem( const ParticleSystemTemplate *sysTemplate, m_velDamping = sysTemplate->m_velDamping; +#if PARTICLE_USE_XY_ROTATION + m_angleX = sysTemplate->m_angleX; + m_angleY = sysTemplate->m_angleY; +#endif m_angleZ = sysTemplate->m_angleZ; +#if PARTICLE_USE_XY_ROTATION + m_angularRateX = sysTemplate->m_angularRateX; + m_angularRateY = sysTemplate->m_angularRateY; +#endif m_angularRateZ = sysTemplate->m_angularRateZ; m_angularDamping = sysTemplate->m_angularDamping; @@ -1158,8 +1209,8 @@ ParticleSystem::ParticleSystem( const ParticleSystemTemplate *sysTemplate, // set up slave particle system, if any m_masterSystemID = INVALID_PARTICLE_SYSTEM_ID; m_slaveSystemID = INVALID_PARTICLE_SYSTEM_ID; - m_masterSystem = NULL; - m_slaveSystem = NULL; + m_masterSystem = nullptr; + m_slaveSystem = nullptr; if( createSlaves ) { ParticleSystem *slaveSystem = sysTemplate->createSlaveSystem(); @@ -1177,7 +1228,7 @@ ParticleSystem::ParticleSystem( const ParticleSystemTemplate *sysTemplate, m_attachedSystemName = sysTemplate->m_attachedSystemName; m_particleCount = 0; m_personalityStore = 0; - m_controlParticle = NULL; + m_controlParticle = nullptr; TheParticleSystemManager->friend_addParticleSystem(this); @@ -1195,8 +1246,8 @@ ParticleSystem::~ParticleSystem() { DEBUG_ASSERTCRASH( m_slaveSystem->getMaster() == this, ("~ParticleSystem: Our slave doesn't have us as a master!") ); - m_slaveSystem->setMaster( NULL ); - setSlave( NULL ); + m_slaveSystem->setMaster( nullptr ); + setSlave( nullptr ); } @@ -1205,8 +1256,8 @@ ParticleSystem::~ParticleSystem() { DEBUG_ASSERTCRASH( m_masterSystem->getSlave() == this, ("~ParticleSystem: Our master doesn't have us as a slave!") ); - m_masterSystem->setSlave( NULL ); - setMaster( NULL ); + m_masterSystem->setSlave( nullptr ); + setMaster( nullptr ); } @@ -1222,7 +1273,7 @@ ParticleSystem::~ParticleSystem() if (m_controlParticle) m_controlParticle->detachControlledParticleSystem(); - m_controlParticle = NULL; + m_controlParticle = nullptr; TheParticleSystemManager->friend_removeParticleSystem(this); //DEBUG_ASSERTLOG(!(m_totalParticleSystemCount % 10 == 0), ( "TotalParticleSystemCount = %d", m_totalParticleSystemCount )); @@ -1688,7 +1739,7 @@ Particle *ParticleSystem::createParticle( const ParticleInfo *info, { if (TheGlobalData->m_useFX == FALSE) - return NULL; + return nullptr; // // Enforce particle limit. @@ -1704,10 +1755,10 @@ Particle *ParticleSystem::createParticle( const ParticleInfo *info, if( priority < TheGameLODManager->getMinDynamicParticlePriority() || (priority < TheGameLODManager->getMinDynamicParticleSkipPriority() && TheGameLODManager->isParticleSkipped()) ) - return NULL; + return nullptr; if ( getParticleCount() > 0 && priority == AREA_EFFECT && m_isGroundAligned && TheParticleSystemManager->getFieldParticleCount() > (UnsignedInt)TheGlobalData->m_maxFieldParticleCount ) - return NULL; + return nullptr; // ALWAYS_RENDER particles are exempt from all count limits, and are always created, regardless of LOD issues. if (priority != ALWAYS_RENDER) @@ -1716,11 +1767,11 @@ Particle *ParticleSystem::createParticle( const ParticleInfo *info, if ( numInExcess > 0) { if( TheParticleSystemManager->removeOldestParticles((UnsignedInt) numInExcess, priority) != numInExcess ) - return NULL; // could not remove enough particles, don't create new stuff + return nullptr; // could not remove enough particles, don't create new stuff } if (TheGlobalData->m_maxParticleCount == 0) - return NULL; + return nullptr; } } @@ -1798,7 +1849,15 @@ const ParticleInfo *ParticleSystem::generateParticleInfo( Int particleNum, Int p info.m_velDamping = m_velDamping.getValue(); info.m_angularDamping = m_angularDamping.getValue(); +#if PARTICLE_USE_XY_ROTATION + info.m_angleX = m_angleX.getValue(); + info.m_angleY = m_angleY.getValue(); +#endif info.m_angleZ = m_angleZ.getValue(); +#if PARTICLE_USE_XY_ROTATION + info.m_angularRateX = m_angularRateX.getValue(); + info.m_angularRateY = m_angularRateY.getValue(); +#endif info.m_angularRateZ = m_angularRateZ.getValue(); info.m_lifetime = (UnsignedInt)m_lifetime.getValue(); @@ -1872,7 +1931,7 @@ Bool ParticleSystem::update( Int localPlayerIndex ) // matrix so generated particles' are relative to the parent Drawable's // position and orientation Bool transformSet = false; - const Matrix3D *parentXfrm = NULL; + const Matrix3D *parentXfrm = nullptr; Bool isShrouded = false; if (m_attachedToDrawableID) @@ -1885,7 +1944,6 @@ Bool ParticleSystem::update( Int localPlayerIndex ) isShrouded = true; parentXfrm = attachedTo->getTransformMatrix(); - m_lastPos = m_pos; m_pos = *attachedTo->getPosition(); } @@ -1907,14 +1965,11 @@ Bool ParticleSystem::update( Int localPlayerIndex ) if (!isShrouded) isShrouded = (objectAttachedTo->getShroudedStatus(localPlayerIndex) >= OBJECTSHROUD_FOGGED); - const Drawable * draw = objectAttachedTo->getDrawable(); - if ( draw ) - parentXfrm = draw->getTransformMatrix(); - else - parentXfrm = objectAttachedTo->getTransformMatrix(); - - - + const Drawable * draw = objectAttachedTo->getDrawable(); + if ( draw ) + parentXfrm = draw->getTransformMatrix(); + else + parentXfrm = objectAttachedTo->getTransformMatrix(); m_lastPos = m_pos; m_pos = *objectAttachedTo->getPosition(); @@ -1929,30 +1984,28 @@ Bool ParticleSystem::update( Int localPlayerIndex ) } } - - if (parentXfrm) { - if (m_skipParentXfrm) - { - //this particle system is already in world space so no need to apply parent xform. - m_transform = m_localTransform; - } - else - { - // if system has its own local transform, concatenate them - if (m_isLocalIdentity == false) - #ifdef ALLOW_TEMPORARIES - m_transform = (*parentXfrm) * m_localTransform; - #else - m_transform.mul(*parentXfrm, m_localTransform); - #endif - else - m_transform = *parentXfrm; - } - - m_isIdentity = false; - transformSet = true; + if (m_skipParentXfrm) + { + //this particle system is already in world space so no need to apply parent xform. + m_transform = m_localTransform; + } + else + { + // if system has its own local transform, concatenate them + if (m_isLocalIdentity == false) + #ifdef ALLOW_TEMPORARIES + m_transform = (*parentXfrm) * m_localTransform; + #else + m_transform.mul(*parentXfrm, m_localTransform); + #endif + else + m_transform = *parentXfrm; + } + + m_isIdentity = false; + transformSet = true; } @@ -1991,7 +2044,7 @@ Bool ParticleSystem::update( Int localPlayerIndex ) { if (m_isForever || (m_isForever == false && m_systemLifetimeLeft > 0)) { - if (!isShrouded && m_isStopped == false && m_masterSystem == NULL) + if (!isShrouded && m_isStopped == false && m_masterSystem == nullptr) { if (m_burstDelayLeft == 0) { @@ -2010,7 +2063,7 @@ Bool ParticleSystem::update( Int localPlayerIndex ) { // actually create a particle Particle *p = createParticle( info, priority ); - if (p == NULL) + if (p == nullptr) continue; if (m_attachedSystemName.isEmpty() == false) @@ -2209,7 +2262,7 @@ void ParticleSystem::updateWindMotion( void ) case ParticleSystemInfo::WIND_MOTION_CIRCULAR: { - // give us a wind angle change if one hasn't been specifed (this plays nice with the particle editor) + // give us a wind angle change if one hasn't been specified (this plays nice with the particle editor) if( m_windAngleChange == 0.0f ) m_windAngleChange = GameClientRandomValueReal( m_windAngleChangeMin, m_windAngleChangeMax ); @@ -2257,11 +2310,11 @@ void ParticleSystem::addParticle( Particle *particleToAdd ) } else { - particleToAdd->m_systemPrev = NULL; + particleToAdd->m_systemPrev = nullptr; } m_systemParticlesTail = particleToAdd; - particleToAdd->m_systemNext = NULL; + particleToAdd->m_systemNext = nullptr; particleToAdd->m_inSystemList = TRUE; ++m_particleCount; @@ -2284,13 +2337,13 @@ void ParticleSystem::removeParticle( Particle *particleToRemove ) if (particleToRemove->m_systemPrev) particleToRemove->m_systemPrev->m_systemNext = particleToRemove->m_systemNext; - // update head & tail if neccessary + // update head & tail if necessary if (particleToRemove == m_systemParticlesHead) m_systemParticlesHead = particleToRemove->m_systemNext; if (particleToRemove == m_systemParticlesTail) m_systemParticlesTail = particleToRemove->m_systemPrev; - particleToRemove->m_systemNext = particleToRemove->m_systemPrev = NULL; + particleToRemove->m_systemNext = particleToRemove->m_systemPrev = nullptr; particleToRemove->m_inSystemList = FALSE; --m_particleCount; } @@ -2300,7 +2353,7 @@ void ParticleSystem::removeParticle( Particle *particleToRemove ) ParticleInfo ParticleSystem::mergeRelatedParticleSystems( ParticleSystem *masterParticleSystem, ParticleSystem *slaveParticleSystem, Bool slaveNeedsFullPromotion) { if (!masterParticleSystem || !slaveParticleSystem) { - DEBUG_CRASH(("masterParticleSystem or slaveParticleSystem was NULL. Should not happen. JKMCD")); + DEBUG_CRASH(("masterParticleSystem or slaveParticleSystem was null. Should not happen. JKMCD")); ParticleInfo bogus; return bogus; } @@ -2319,7 +2372,15 @@ ParticleInfo ParticleSystem::mergeRelatedParticleSystems( ParticleSystem *master mergeInfo.m_sizeRate *= info->m_sizeRate; mergeInfo.m_sizeRateDamping *= info->m_sizeRateDamping; +#if PARTICLE_USE_XY_ROTATION + mergeInfo.m_angleX = info->m_angleX; + mergeInfo.m_angleY = info->m_angleY; +#endif mergeInfo.m_angleZ = info->m_angleZ; +#if PARTICLE_USE_XY_ROTATION + mergeInfo.m_angularRateX = info->m_angularRateX; + mergeInfo.m_angularRateY = info->m_angularRateY; +#endif mergeInfo.m_angularRateZ = info->m_angularRateZ; mergeInfo.m_angularDamping = info->m_angularDamping; @@ -2520,7 +2581,7 @@ void ParticleSystem::xfer( Xfer *xfer ) particle = createParticle( info, priority, TRUE ); // sanity - DEBUG_ASSERTCRASH( particle, ("ParticleSyste::xfer - Unable to create particle for loading") ); + DEBUG_ASSERTCRASH( particle, ("ParticleSystem::xfer - Unable to create particle for loading") ); // read in the particle data xfer->xferSnapshot( particle ); @@ -2545,10 +2606,10 @@ void ParticleSystem::loadPostProcess( void ) { // sanity - if( m_slaveSystem != NULL ) + if( m_slaveSystem != nullptr ) { - DEBUG_CRASH(( "ParticleSystem::loadPostProcess - m_slaveSystem is not NULL but should be" )); + DEBUG_CRASH(( "ParticleSystem::loadPostProcess - m_slaveSystem is not null but should be" )); throw SC_INVALID_DATA; } @@ -2557,10 +2618,10 @@ void ParticleSystem::loadPostProcess( void ) m_slaveSystem = TheParticleSystemManager->findParticleSystem( m_slaveSystemID ); // sanity - if( m_slaveSystem == NULL || m_slaveSystem->isDestroyed() == TRUE ) + if( m_slaveSystem == nullptr || m_slaveSystem->isDestroyed() == TRUE ) { - DEBUG_CRASH(( "ParticleSystem::loadPostProcess - m_slaveSystem is NULL or destroyed" )); + DEBUG_CRASH(( "ParticleSystem::loadPostProcess - m_slaveSystem is null or destroyed" )); throw SC_INVALID_DATA; } @@ -2572,10 +2633,10 @@ void ParticleSystem::loadPostProcess( void ) { // sanity - if( m_masterSystem != NULL ) + if( m_masterSystem != nullptr ) { - DEBUG_CRASH(( "ParticleSystem::loadPostProcess - m_masterSystem is not NULL but should be" )); + DEBUG_CRASH(( "ParticleSystem::loadPostProcess - m_masterSystem is not null but should be" )); throw SC_INVALID_DATA; } @@ -2584,10 +2645,10 @@ void ParticleSystem::loadPostProcess( void ) m_masterSystem = TheParticleSystemManager->findParticleSystem( m_masterSystemID ); // sanity - if( m_masterSystem == NULL || m_masterSystem->isDestroyed() == TRUE ) + if( m_masterSystem == nullptr || m_masterSystem->isDestroyed() == TRUE ) { - DEBUG_CRASH(( "ParticleSystem::loadPostProcess - m_masterSystem is NULL or destroyed" )); + DEBUG_CRASH(( "ParticleSystem::loadPostProcess - m_masterSystem is null or destroyed" )); throw SC_INVALID_DATA; } @@ -2606,98 +2667,106 @@ void ParticleSystem::loadPostProcess( void ) const FieldParse ParticleSystemTemplate::m_fieldParseTable[] = { { "Priority", INI::parseIndexList, ParticlePriorityNames, offsetof( ParticleSystemTemplate, m_priority ) }, - { "IsOneShot", INI::parseBool, NULL, offsetof( ParticleSystemTemplate, m_isOneShot ) }, + { "IsOneShot", INI::parseBool, nullptr, offsetof( ParticleSystemTemplate, m_isOneShot ) }, { "Shader", INI::parseIndexList, ParticleShaderTypeNames, offsetof( ParticleSystemTemplate, m_shaderType ) }, { "Type", INI::parseIndexList, ParticleTypeNames, offsetof( ParticleSystemTemplate, m_particleType ) }, - { "ParticleName", INI::parseAsciiString, NULL, offsetof( ParticleSystemTemplate, m_particleTypeName ) }, - { "AngleZ", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_angleZ ) }, - { "AngularRateZ", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_angularRateZ ) }, - { "AngularDamping", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_angularDamping ) }, - - { "VelocityDamping", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_velDamping ) }, - { "Gravity", INI::parseReal, NULL, offsetof( ParticleSystemTemplate, m_gravity ) }, - { "SlaveSystem", INI::parseAsciiString, NULL, offsetof( ParticleSystemTemplate, m_slaveSystemName ) }, - { "SlavePosOffset", INI::parseCoord3D, NULL, offsetof( ParticleSystemTemplate, m_slavePosOffset ) }, - { "PerParticleAttachedSystem", INI::parseAsciiString, NULL, offsetof( ParticleSystemTemplate, m_attachedSystemName ) }, - - { "Lifetime", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_lifetime ) }, - { "SystemLifetime", INI::parseUnsignedInt, NULL, offsetof( ParticleSystemTemplate, m_systemLifetime ) }, - - { "Size", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_startSize ) }, - { "StartSizeRate", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_startSizeRate ) }, - { "SizeRate", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_sizeRate ) }, - { "SizeRateDamping", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_sizeRateDamping ) }, - - { "Alpha1", ParticleSystemTemplate::parseRandomKeyframe, NULL, offsetof( ParticleSystemTemplate, m_alphaKey[0] ) }, - { "Alpha2", ParticleSystemTemplate::parseRandomKeyframe, NULL, offsetof( ParticleSystemTemplate, m_alphaKey[1] ) }, - { "Alpha3", ParticleSystemTemplate::parseRandomKeyframe, NULL, offsetof( ParticleSystemTemplate, m_alphaKey[2] ) }, - { "Alpha4", ParticleSystemTemplate::parseRandomKeyframe, NULL, offsetof( ParticleSystemTemplate, m_alphaKey[3] ) }, - { "Alpha5", ParticleSystemTemplate::parseRandomKeyframe, NULL, offsetof( ParticleSystemTemplate, m_alphaKey[4] ) }, - { "Alpha6", ParticleSystemTemplate::parseRandomKeyframe, NULL, offsetof( ParticleSystemTemplate, m_alphaKey[5] ) }, - { "Alpha7", ParticleSystemTemplate::parseRandomKeyframe, NULL, offsetof( ParticleSystemTemplate, m_alphaKey[6] ) }, - { "Alpha8", ParticleSystemTemplate::parseRandomKeyframe, NULL, offsetof( ParticleSystemTemplate, m_alphaKey[7] ) }, - - { "Color1", ParticleSystemTemplate::parseRGBColorKeyframe,NULL, offsetof( ParticleSystemTemplate, m_colorKey[0] ) }, - { "Color2", ParticleSystemTemplate::parseRGBColorKeyframe,NULL, offsetof( ParticleSystemTemplate, m_colorKey[1] ) }, - { "Color3", ParticleSystemTemplate::parseRGBColorKeyframe,NULL, offsetof( ParticleSystemTemplate, m_colorKey[2] ) }, - { "Color4", ParticleSystemTemplate::parseRGBColorKeyframe,NULL, offsetof( ParticleSystemTemplate, m_colorKey[3] ) }, - { "Color5", ParticleSystemTemplate::parseRGBColorKeyframe,NULL, offsetof( ParticleSystemTemplate, m_colorKey[4] ) }, - { "Color6", ParticleSystemTemplate::parseRGBColorKeyframe,NULL, offsetof( ParticleSystemTemplate, m_colorKey[5] ) }, - { "Color7", ParticleSystemTemplate::parseRGBColorKeyframe,NULL, offsetof( ParticleSystemTemplate, m_colorKey[6] ) }, - { "Color8", ParticleSystemTemplate::parseRGBColorKeyframe,NULL, offsetof( ParticleSystemTemplate, m_colorKey[7] ) }, - -// { "COLOR", ParticleSystemTemplate::parseRandomRGBColor, NULL, offsetof( ParticleSystemTemplate, m_color ) }, - { "ColorScale", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_colorScale ) }, - - { "BurstDelay", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_burstDelay ) }, - { "BurstCount", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_burstCount ) }, - - { "InitialDelay", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_initialDelay ) }, - - { "DriftVelocity", INI::parseCoord3D, NULL, offsetof( ParticleSystemTemplate, m_driftVelocity ) }, + { "ParticleName", INI::parseAsciiString, nullptr, offsetof( ParticleSystemTemplate, m_particleTypeName ) }, +#if PARTICLE_USE_XY_ROTATION + { "AngleX", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_angleX ) }, + { "AngleY", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_angleY ) }, +#endif + { "AngleZ", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_angleZ ) }, +#if PARTICLE_USE_XY_ROTATION + { "AngularRateX", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_angularRateX ) }, + { "AngularRateY", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_angularRateY ) }, +#endif + { "AngularRateZ", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_angularRateZ ) }, + { "AngularDamping", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_angularDamping ) }, + + { "VelocityDamping", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_velDamping ) }, + { "Gravity", INI::parseReal, nullptr, offsetof( ParticleSystemTemplate, m_gravity ) }, + { "SlaveSystem", INI::parseAsciiString, nullptr, offsetof( ParticleSystemTemplate, m_slaveSystemName ) }, + { "SlavePosOffset", INI::parseCoord3D, nullptr, offsetof( ParticleSystemTemplate, m_slavePosOffset ) }, + { "PerParticleAttachedSystem", INI::parseAsciiString, nullptr, offsetof( ParticleSystemTemplate, m_attachedSystemName ) }, + + { "Lifetime", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_lifetime ) }, + { "SystemLifetime", INI::parseUnsignedInt, nullptr, offsetof( ParticleSystemTemplate, m_systemLifetime ) }, + + { "Size", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_startSize ) }, + { "StartSizeRate", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_startSizeRate ) }, + { "SizeRate", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_sizeRate ) }, + { "SizeRateDamping", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_sizeRateDamping ) }, + + { "Alpha1", ParticleSystemTemplate::parseRandomKeyframe, nullptr, offsetof( ParticleSystemTemplate, m_alphaKey[0] ) }, + { "Alpha2", ParticleSystemTemplate::parseRandomKeyframe, nullptr, offsetof( ParticleSystemTemplate, m_alphaKey[1] ) }, + { "Alpha3", ParticleSystemTemplate::parseRandomKeyframe, nullptr, offsetof( ParticleSystemTemplate, m_alphaKey[2] ) }, + { "Alpha4", ParticleSystemTemplate::parseRandomKeyframe, nullptr, offsetof( ParticleSystemTemplate, m_alphaKey[3] ) }, + { "Alpha5", ParticleSystemTemplate::parseRandomKeyframe, nullptr, offsetof( ParticleSystemTemplate, m_alphaKey[4] ) }, + { "Alpha6", ParticleSystemTemplate::parseRandomKeyframe, nullptr, offsetof( ParticleSystemTemplate, m_alphaKey[5] ) }, + { "Alpha7", ParticleSystemTemplate::parseRandomKeyframe, nullptr, offsetof( ParticleSystemTemplate, m_alphaKey[6] ) }, + { "Alpha8", ParticleSystemTemplate::parseRandomKeyframe, nullptr, offsetof( ParticleSystemTemplate, m_alphaKey[7] ) }, + + { "Color1", ParticleSystemTemplate::parseRGBColorKeyframe,nullptr, offsetof( ParticleSystemTemplate, m_colorKey[0] ) }, + { "Color2", ParticleSystemTemplate::parseRGBColorKeyframe,nullptr, offsetof( ParticleSystemTemplate, m_colorKey[1] ) }, + { "Color3", ParticleSystemTemplate::parseRGBColorKeyframe,nullptr, offsetof( ParticleSystemTemplate, m_colorKey[2] ) }, + { "Color4", ParticleSystemTemplate::parseRGBColorKeyframe,nullptr, offsetof( ParticleSystemTemplate, m_colorKey[3] ) }, + { "Color5", ParticleSystemTemplate::parseRGBColorKeyframe,nullptr, offsetof( ParticleSystemTemplate, m_colorKey[4] ) }, + { "Color6", ParticleSystemTemplate::parseRGBColorKeyframe,nullptr, offsetof( ParticleSystemTemplate, m_colorKey[5] ) }, + { "Color7", ParticleSystemTemplate::parseRGBColorKeyframe,nullptr, offsetof( ParticleSystemTemplate, m_colorKey[6] ) }, + { "Color8", ParticleSystemTemplate::parseRGBColorKeyframe,nullptr, offsetof( ParticleSystemTemplate, m_colorKey[7] ) }, + +// { "COLOR", ParticleSystemTemplate::parseRandomRGBColor, nullptr, offsetof( ParticleSystemTemplate, m_color ) }, + { "ColorScale", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_colorScale ) }, + + { "BurstDelay", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_burstDelay ) }, + { "BurstCount", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_burstCount ) }, + + { "InitialDelay", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_initialDelay ) }, + + { "DriftVelocity", INI::parseCoord3D, nullptr, offsetof( ParticleSystemTemplate, m_driftVelocity ) }, { "VelocityType", INI::parseIndexList, EmissionVelocityTypeNames, offsetof( ParticleSystemTemplate, m_emissionVelocityType ) }, - { "VelOrthoX", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_emissionVelocity.ortho.x ) }, - { "VelOrthoY", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_emissionVelocity.ortho.y ) }, - { "VelOrthoZ", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_emissionVelocity.ortho.z ) }, + { "VelOrthoX", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_emissionVelocity.ortho.x ) }, + { "VelOrthoY", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_emissionVelocity.ortho.y ) }, + { "VelOrthoZ", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_emissionVelocity.ortho.z ) }, - { "VelSpherical", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_emissionVelocity.spherical.speed ) }, - { "VelHemispherical", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_emissionVelocity.hemispherical.speed ) }, + { "VelSpherical", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_emissionVelocity.spherical.speed ) }, + { "VelHemispherical", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_emissionVelocity.hemispherical.speed ) }, - { "VelCylindricalRadial", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_emissionVelocity.cylindrical.radial ) }, - { "VelCylindricalNormal", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_emissionVelocity.cylindrical.normal ) }, + { "VelCylindricalRadial", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_emissionVelocity.cylindrical.radial ) }, + { "VelCylindricalNormal", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_emissionVelocity.cylindrical.normal ) }, - { "VelOutward", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_emissionVelocity.outward.speed ) }, - { "VelOutwardOther", INI::parseGameClientRandomVariable, NULL, offsetof( ParticleSystemTemplate, m_emissionVelocity.outward.otherSpeed ) }, + { "VelOutward", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_emissionVelocity.outward.speed ) }, + { "VelOutwardOther", INI::parseGameClientRandomVariable, nullptr, offsetof( ParticleSystemTemplate, m_emissionVelocity.outward.otherSpeed ) }, { "VolumeType", INI::parseIndexList, EmissionVolumeTypeNames, offsetof( ParticleSystemTemplate, m_emissionVolumeType ) }, - { "VolLineStart", INI::parseCoord3D, NULL, offsetof( ParticleSystemTemplate, m_emissionVolume.line.start ) }, - { "VolLineEnd", INI::parseCoord3D, NULL, offsetof( ParticleSystemTemplate, m_emissionVolume.line.end ) }, + { "VolLineStart", INI::parseCoord3D, nullptr, offsetof( ParticleSystemTemplate, m_emissionVolume.line.start ) }, + { "VolLineEnd", INI::parseCoord3D, nullptr, offsetof( ParticleSystemTemplate, m_emissionVolume.line.end ) }, - { "VolBoxHalfSize", INI::parseCoord3D, NULL, offsetof( ParticleSystemTemplate, m_emissionVolume.box.halfSize ) }, + { "VolBoxHalfSize", INI::parseCoord3D, nullptr, offsetof( ParticleSystemTemplate, m_emissionVolume.box.halfSize ) }, - { "VolSphereRadius", INI::parseReal, NULL, offsetof( ParticleSystemTemplate, m_emissionVolume.sphere.radius ) }, + { "VolSphereRadius", INI::parseReal, nullptr, offsetof( ParticleSystemTemplate, m_emissionVolume.sphere.radius ) }, - { "VolCylinderRadius", INI::parseReal, NULL, offsetof( ParticleSystemTemplate, m_emissionVolume.cylinder.radius ) }, - { "VolCylinderLength", INI::parseReal, NULL, offsetof( ParticleSystemTemplate, m_emissionVolume.cylinder.length ) }, + { "VolCylinderRadius", INI::parseReal, nullptr, offsetof( ParticleSystemTemplate, m_emissionVolume.cylinder.radius ) }, + { "VolCylinderLength", INI::parseReal, nullptr, offsetof( ParticleSystemTemplate, m_emissionVolume.cylinder.length ) }, - { "IsHollow", INI::parseBool, NULL, offsetof( ParticleSystemTemplate, m_isEmissionVolumeHollow ) }, - { "IsGroundAligned", INI::parseBool, NULL, offsetof( ParticleSystemTemplate, m_isGroundAligned ) }, - { "IsEmitAboveGroundOnly", INI::parseBool, NULL, offsetof( ParticleSystemTemplate, m_isEmitAboveGroundOnly) }, - { "IsParticleUpTowardsEmitter", INI::parseBool, NULL, offsetof( ParticleSystemTemplate, m_isParticleUpTowardsEmitter) }, + { "IsHollow", INI::parseBool, nullptr, offsetof( ParticleSystemTemplate, m_isEmissionVolumeHollow ) }, + { "IsGroundAligned", INI::parseBool, nullptr, offsetof( ParticleSystemTemplate, m_isGroundAligned ) }, + { "IsEmitAboveGroundOnly", INI::parseBool, nullptr, offsetof( ParticleSystemTemplate, m_isEmitAboveGroundOnly) }, + { "IsParticleUpTowardsEmitter", INI::parseBool, nullptr, offsetof( ParticleSystemTemplate, m_isParticleUpTowardsEmitter) }, { "WindMotion", INI::parseIndexList, WindMotionNames, offsetof( ParticleSystemTemplate, m_windMotion ) }, - { "WindAngleChangeMin", INI::parseReal, NULL, offsetof( ParticleSystemTemplate, m_windAngleChangeMin ) }, - { "WindAngleChangeMax", INI::parseReal, NULL, offsetof( ParticleSystemTemplate, m_windAngleChangeMax ) }, + { "WindAngleChangeMin", INI::parseReal, nullptr, offsetof( ParticleSystemTemplate, m_windAngleChangeMin ) }, + { "WindAngleChangeMax", INI::parseReal, nullptr, offsetof( ParticleSystemTemplate, m_windAngleChangeMax ) }, - { "WindPingPongStartAngleMin", INI::parseReal, NULL, offsetof( ParticleSystemTemplate, m_windMotionStartAngleMin ) }, - { "WindPingPongStartAngleMax", INI::parseReal, NULL, offsetof( ParticleSystemTemplate, m_windMotionStartAngleMax ) }, + { "WindPingPongStartAngleMin", INI::parseReal, nullptr, offsetof( ParticleSystemTemplate, m_windMotionStartAngleMin ) }, + { "WindPingPongStartAngleMax", INI::parseReal, nullptr, offsetof( ParticleSystemTemplate, m_windMotionStartAngleMax ) }, - { "WindPingPongEndAngleMin", INI::parseReal, NULL, offsetof( ParticleSystemTemplate, m_windMotionEndAngleMin ) }, - { "WindPingPongEndAngleMax", INI::parseReal, NULL, offsetof( ParticleSystemTemplate, m_windMotionEndAngleMax ) }, + { "WindPingPongEndAngleMin", INI::parseReal, nullptr, offsetof( ParticleSystemTemplate, m_windMotionEndAngleMin ) }, + { "WindPingPongEndAngleMax", INI::parseReal, nullptr, offsetof( ParticleSystemTemplate, m_windMotionEndAngleMax ) }, - { NULL, NULL, NULL, 0 }, + { nullptr, nullptr, nullptr, 0 }, }; // ------------------------------------------------------------------------------------------------ @@ -2726,8 +2795,8 @@ void ParticleSystemTemplate::parseRGBColorKeyframe( INI* ini, void *instance, { RGBColorKeyframe *key = static_cast(store); - INI::parseRGBColor( ini, instance, &key->color, NULL ); - INI::parseUnsignedInt( ini, instance, &key->frame, NULL ); + INI::parseRGBColor( ini, instance, &key->color, nullptr ); + INI::parseUnsignedInt( ini, instance, &key->frame, nullptr ); } // ------------------------------------------------------------------------------------------------ @@ -2786,7 +2855,7 @@ void ParticleSystemTemplate::parseRandomRGBColor( INI* ini, void *instance, ParticleSystemTemplate::ParticleSystemTemplate( const AsciiString &name ) : m_name(name) { - m_slaveTemplate = NULL; + m_slaveTemplate = nullptr; } // ------------------------------------------------------------------------------------------------ @@ -2797,16 +2866,16 @@ ParticleSystemTemplate::~ParticleSystemTemplate() } // ------------------------------------------------------------------------------------------------ -/** If returns non-NULL, it is a slave system for use ... the create slaves parameter +/** If returns non-null, it is a slave system for use ... the create slaves parameter * tells *this* slave system whether or not it should create any slaves itself * automatically during its own constructor */ // ------------------------------------------------------------------------------------------------ ParticleSystem *ParticleSystemTemplate::createSlaveSystem( Bool createSlaves ) const { - if (m_slaveTemplate == NULL && m_slaveSystemName.isEmpty() == false) + if (m_slaveTemplate == nullptr && m_slaveSystemName.isEmpty() == false) m_slaveTemplate = TheParticleSystemManager->findTemplate( m_slaveSystemName ); - ParticleSystem *slave = NULL; + ParticleSystem *slave = nullptr; if (m_slaveTemplate) slave = TheParticleSystemManager->createParticleSystem( m_slaveTemplate, createSlaves ); @@ -2835,8 +2904,8 @@ ParticleSystemManager::ParticleSystemManager( void ) for( Int i = 0; i < NUM_PARTICLE_PRIORITIES; ++i ) { - m_allParticlesHead[ i ] = NULL; - m_allParticlesTail[ i ] = NULL; + m_allParticlesHead[ i ] = nullptr; + m_allParticlesTail[ i ] = nullptr; } @@ -2862,19 +2931,19 @@ void ParticleSystemManager::init( void ) { /// Read INI data and build templates INI ini; - ini.loadFileDirectory( "Data\\INI\\ParticleSystem", INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\ParticleSystem", INI_LOAD_OVERWRITE, nullptr ); // sanity, our lists must be empty!! for( Int i = 0; i < NUM_PARTICLE_PRIORITIES; ++i ) { // sanity - DEBUG_ASSERTCRASH( m_allParticlesHead[ i ] == NULL, ("INIT: ParticleSystem all particles head[%d] is not NULL!", i) ); - DEBUG_ASSERTCRASH( m_allParticlesTail[ i ] == NULL, ("INIT: ParticleSystem all particles tail[%d] is not NULL!", i) ); + DEBUG_ASSERTCRASH( m_allParticlesHead[ i ] == nullptr, ("INIT: ParticleSystem all particles head[%d] is not null!", i) ); + DEBUG_ASSERTCRASH( m_allParticlesTail[ i ] == nullptr, ("INIT: ParticleSystem all particles tail[%d] is not null!", i) ); - // just to be clean set them to NULL - m_allParticlesHead[ i ] = NULL; - m_allParticlesTail[ i ] = NULL; + // just to be clean set them to nullptr + m_allParticlesHead[ i ] = nullptr; + m_allParticlesTail[ i ] = nullptr; } @@ -2887,22 +2956,23 @@ void ParticleSystemManager::reset( void ) { while (!m_allParticleSystemList.empty()) { - DEBUG_ASSERTCRASH(m_allParticleSystemList.front() != NULL, ("ParticleSystemManager::reset: ParticleSystem is null")); + DEBUG_ASSERTCRASH(m_allParticleSystemList.front() != nullptr, ("ParticleSystemManager::reset: ParticleSystem is null")); deleteInstance(m_allParticleSystemList.front()); } DEBUG_ASSERTCRASH(m_particleSystemCount == 0, ("ParticleSystemManager::reset: m_particleSystemCount is %u, not 0", m_particleSystemCount)); + DEBUG_ASSERTCRASH(m_systemMap.size() == 0, ("ParticleSystemManager::reset: m_systemMap size is %zu, not 0", m_systemMap.size())); // sanity, our lists must be empty!! for( Int i = 0; i < NUM_PARTICLE_PRIORITIES; ++i ) { // sanity - DEBUG_ASSERTCRASH( m_allParticlesHead[ i ] == NULL, ("RESET: ParticleSystem all particles head[%d] is not NULL!", i) ); - DEBUG_ASSERTCRASH( m_allParticlesTail[ i ] == NULL, ("RESET: ParticleSystem all particles tail[%d] is not NULL!", i) ); + DEBUG_ASSERTCRASH( m_allParticlesHead[ i ] == nullptr, ("RESET: ParticleSystem all particles head[%d] is not null!", i) ); + DEBUG_ASSERTCRASH( m_allParticlesTail[ i ] == nullptr, ("RESET: ParticleSystem all particles tail[%d] is not null!", i) ); - // just to be clean set them to NULL - m_allParticlesHead[ i ] = NULL; - m_allParticlesTail[ i ] = NULL; + // just to be clean set them to nullptr + m_allParticlesHead[ i ] = nullptr; + m_allParticlesTail[ i ] = nullptr; } @@ -2935,7 +3005,7 @@ void ParticleSystemManager::update( void ) { // TheSuperHackers @info Must increment the list iterator before potential element erasure from the list. ParticleSystem* sys = *it++; - DEBUG_ASSERTCRASH(sys != NULL, ("ParticleSystemManager::update: ParticleSystem is null")); + DEBUG_ASSERTCRASH(sys != nullptr, ("ParticleSystemManager::update: ParticleSystem is null")); if (sys->update(m_localPlayerIndex) == false) { @@ -2958,8 +3028,8 @@ void ParticleSystemManager::setOnScreenParticleCount(int count) ParticleSystem *ParticleSystemManager::createParticleSystem( const ParticleSystemTemplate *sysTemplate, Bool createSlaves ) { // sanity - if (sysTemplate == NULL) - return NULL; + if (sysTemplate == nullptr) + return nullptr; m_uniqueSystemID = (ParticleSystemID)((UnsignedInt)m_uniqueSystemID + 1); ParticleSystem *sys = newInstance(ParticleSystem)( sysTemplate, m_uniqueSystemID, createSlaves ); @@ -2974,7 +3044,7 @@ ParticleSystemID ParticleSystemManager::createAttachedParticleSystemID( Object* attachTo, Bool createSlaves ) { - ParticleSystem* pSystem = TheParticleSystemManager->createParticleSystem(sysTemplate, createSlaves); + ParticleSystem* pSystem = createParticleSystem(sysTemplate, createSlaves); if (pSystem && attachTo) pSystem->attachToObject(attachTo); return pSystem ? pSystem->getSystemID() : INVALID_PARTICLE_SYSTEM_ID; @@ -2986,21 +3056,15 @@ ParticleSystemID ParticleSystemManager::createAttachedParticleSystemID( ParticleSystem *ParticleSystemManager::findParticleSystem( ParticleSystemID id ) { if (id == INVALID_PARTICLE_SYSTEM_ID) - return NULL; // my, that was easy - - ParticleSystem *system = NULL; + return nullptr; - for( ParticleSystemListIt it = m_allParticleSystemList.begin(); it != m_allParticleSystemList.end(); ++it ) { - system = *it; - DEBUG_ASSERTCRASH(system != NULL, ("ParticleSystemManager::findParticleSystem: ParticleSystem is null")); - - if( system->getSystemID() == id ) { - return system; - } + ParticleSystemIDMap::const_iterator it = m_systemMap.find(id); + if (it != m_systemMap.end()) + { + return it->second; } - return NULL; - + return nullptr; } // ------------------------------------------------------------------------------------------------ @@ -3018,7 +3082,7 @@ void ParticleSystemManager::destroyParticleSystemByID(ParticleSystemID id) // ------------------------------------------------------------------------------------------------ ParticleSystemTemplate *ParticleSystemManager::findTemplate( const AsciiString &name ) const { - ParticleSystemTemplate *sysTemplate = NULL; + ParticleSystemTemplate *sysTemplate = nullptr; TemplateMap::const_iterator find(m_templateMap.find(name)); if (find != m_templateMap.end()) { @@ -3034,12 +3098,12 @@ ParticleSystemTemplate *ParticleSystemManager::findTemplate( const AsciiString & ParticleSystemTemplate *ParticleSystemManager::newTemplate( const AsciiString &name ) { ParticleSystemTemplate *sysTemplate = findTemplate(name); - if (sysTemplate == NULL) { + if (sysTemplate == nullptr) { sysTemplate = newInstance(ParticleSystemTemplate)( name ); if (! m_templateMap.insert(std::make_pair(name, sysTemplate)).second) { deleteInstance(sysTemplate); - sysTemplate = NULL; + sysTemplate = nullptr; } } @@ -3052,7 +3116,7 @@ ParticleSystemTemplate *ParticleSystemManager::newTemplate( const AsciiString &n ParticleSystemTemplate *ParticleSystemManager::findParentTemplate( const AsciiString &name, Int parentNum ) const { if (name.isEmpty()) { - return NULL; + return nullptr; } TemplateMap::const_iterator begin(m_templateMap.begin()); @@ -3066,7 +3130,7 @@ ParticleSystemTemplate *ParticleSystemManager::findParentTemplate( const AsciiSt } } - return NULL; + return nullptr; } // ------------------------------------------------------------------------------------------------ @@ -3076,7 +3140,7 @@ void ParticleSystemManager::destroyAttachedSystems( Object *obj ) { // sanity - if( obj == NULL ) + if( obj == nullptr ) return; // iterate through all systems @@ -3086,7 +3150,7 @@ void ParticleSystemManager::destroyAttachedSystems( Object *obj ) { ParticleSystem *system = *it; - DEBUG_ASSERTCRASH(system != NULL, ("ParticleSystemManager::destroyAttachedSystems: ParticleSystem is null")); + DEBUG_ASSERTCRASH(system != nullptr, ("ParticleSystemManager::destroyAttachedSystems: ParticleSystem is null")); if( system->getAttachedObject() == obj->getID() ) system->destroy(); @@ -3115,11 +3179,11 @@ void ParticleSystemManager::addParticle( Particle *particleToAdd, ParticlePriori } else { - particleToAdd->m_overallPrev = NULL; + particleToAdd->m_overallPrev = nullptr; } m_allParticlesTail[ priority ] = particleToAdd; - particleToAdd->m_overallNext = NULL; + particleToAdd->m_overallNext = nullptr; particleToAdd->m_inOverallList = TRUE; ++m_particleCount; @@ -3144,13 +3208,13 @@ void ParticleSystemManager::removeParticle( Particle *particleToRemove) if (particleToRemove->m_overallPrev) particleToRemove->m_overallPrev->m_overallNext = particleToRemove->m_overallNext; - // update head & tail if neccessary + // update head & tail if necessary if (particleToRemove == m_allParticlesHead[ priority ]) m_allParticlesHead[ priority ] = particleToRemove->m_overallNext; if (particleToRemove == m_allParticlesTail[ priority ]) m_allParticlesTail[ priority ] = particleToRemove->m_overallPrev; - particleToRemove->m_overallNext = particleToRemove->m_overallPrev = NULL; + particleToRemove->m_overallNext = particleToRemove->m_overallPrev = nullptr; particleToRemove->m_inOverallList = FALSE; --m_particleCount; @@ -3162,8 +3226,9 @@ void ParticleSystemManager::removeParticle( Particle *particleToRemove) // ------------------------------------------------------------------------------------------------ void ParticleSystemManager::friend_addParticleSystem( ParticleSystem *particleSystemToAdd ) { - DEBUG_ASSERTCRASH(particleSystemToAdd != NULL, ("ParticleSystemManager::friend_addParticleSystem: ParticleSystem is null")); + DEBUG_ASSERTCRASH(particleSystemToAdd != nullptr, ("ParticleSystemManager::friend_addParticleSystem: ParticleSystem is null")); m_allParticleSystemList.push_back(particleSystemToAdd); + m_systemMap[particleSystemToAdd->getSystemID()] = particleSystemToAdd; ++m_particleSystemCount; } @@ -3174,6 +3239,7 @@ void ParticleSystemManager::friend_removeParticleSystem( ParticleSystem *particl { ParticleSystemListIt it = std::find(m_allParticleSystemList.begin(), m_allParticleSystemList.end(), particleSystemToRemove); if (it != m_allParticleSystemList.end()) { + m_systemMap.erase((*it)->getSystemID()); m_allParticleSystemList.erase(it); --m_particleSystemCount; } else { @@ -3303,7 +3369,7 @@ void ParticleSystemManager::xfer( Xfer *xfer ) systemTemplate = findTemplate( systemName ); // sanity - if( systemTemplate == NULL ) + if( systemTemplate == nullptr ) { DEBUG_CRASH(( "ParticleSystemManager::xfer - Unknown particle system template '%s'", @@ -3315,7 +3381,7 @@ void ParticleSystemManager::xfer( Xfer *xfer ) // create system system = createParticleSystem( systemTemplate, FALSE ); - if( system == NULL ) + if( system == nullptr ) { DEBUG_CRASH(( "ParticleSystemManager::xfer - Unable to allocate particle system '%s'", @@ -3400,16 +3466,17 @@ void ParticleSystemDebugDisplay( DebugDisplayInterface *dd, void *, FILE *fp ) // ------------------------------------------------------------------------------------------------ static Real angleBetween(const Coord2D *vecA, const Coord2D *vecB) { - if (!(vecA && vecA->length() && vecB && vecB->length())) { - return 0.0; + const Real lengthA = vecA->length(); + const Real lengthB = vecB->length(); + + if (!(lengthA && lengthB)) { + return 0.0f; } - Real lengthA = vecA->length(); - Real lengthB = vecB->length(); Real dotProduct = (vecA->x * vecB->x + vecA->y * vecB->y); Real cosTheta = dotProduct / (lengthA * lengthB); - // If the dotproduct is 0.0, then they are orthogonal + // If the dot product is 0.0, then they are orthogonal if (dotProduct == 0.0f) { if (vecB->x > 0) { return PI; diff --git a/Core/GameEngine/Source/GameClient/System/Smudge.cpp b/Core/GameEngine/Source/GameClient/System/Smudge.cpp index 62b40b491f8..5c6cfc05fbb 100644 --- a/Core/GameEngine/Source/GameClient/System/Smudge.cpp +++ b/Core/GameEngine/Source/GameClient/System/Smudge.cpp @@ -46,14 +46,14 @@ SmudgeManager::~SmudgeManager() SmudgeSet* head; //free memory used by smudge sets - while ((head = m_freeSmudgeSetList.Head ()) != NULL) { + while ((head = m_freeSmudgeSetList.Head ()) != nullptr) { m_freeSmudgeSetList.Remove_Head (); delete head; } Smudge* head2; //free memory used by smudges - while ((head2 = SmudgeSet::m_freeSmudgeList.Head ()) != NULL) { + while ((head2 = SmudgeSet::m_freeSmudgeList.Head ()) != nullptr) { m_freeSmudgeSetList.Remove_Head (); delete head2; } @@ -69,7 +69,7 @@ void SmudgeManager::reset(void) SmudgeSet* head; //Return all smudgeSets back to free pool. - while ((head = m_usedSmudgeSetList.Head ()) != NULL) { + while ((head = m_usedSmudgeSetList.Head ()) != nullptr) { m_usedSmudgeSetList.Remove_Head (); head->reset(); //free all smudges. m_freeSmudgeSetList.Add_Tail(head); @@ -109,7 +109,7 @@ void SmudgeSet::reset(void) { Smudge* head; - while ((head = m_usedSmudgeList.Head ()) != NULL) { + while ((head = m_usedSmudgeList.Head ()) != nullptr) { m_usedSmudgeList.Remove_Head (); m_freeSmudgeList.Add_Head(head); //add to free list } diff --git a/Core/GameEngine/Source/GameClient/Terrain/TerrainRoads.cpp b/Core/GameEngine/Source/GameClient/Terrain/TerrainRoads.cpp index ceae1abd30e..bcc12bc8c6e 100644 --- a/Core/GameEngine/Source/GameClient/Terrain/TerrainRoads.cpp +++ b/Core/GameEngine/Source/GameClient/Terrain/TerrainRoads.cpp @@ -35,7 +35,7 @@ #include "GameClient/TerrainRoads.h" // PUBLIC DATA //////////////////////////////////////////////////////////////////////////////////// -TerrainRoadCollection *TheTerrainRoads = NULL; +TerrainRoadCollection *TheTerrainRoads = nullptr; // PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// UnsignedInt TerrainRoadCollection::m_idCounter = 0; @@ -45,11 +45,11 @@ UnsignedInt TerrainRoadCollection::m_idCounter = 0; const FieldParse TerrainRoadType::m_terrainRoadFieldParseTable[] = { - { "Texture", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_texture ) }, - { "RoadWidth", INI::parseReal, NULL, offsetof( TerrainRoadType, m_roadWidth ) }, - { "RoadWidthInTexture", INI::parseReal, NULL, offsetof( TerrainRoadType, m_roadWidthInTexture ) }, + { "Texture", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_texture ) }, + { "RoadWidth", INI::parseReal, nullptr, offsetof( TerrainRoadType, m_roadWidth ) }, + { "RoadWidthInTexture", INI::parseReal, nullptr, offsetof( TerrainRoadType, m_roadWidthInTexture ) }, - { NULL, NULL, NULL, 0 }, + { nullptr, nullptr, nullptr, 0 }, }; @@ -58,35 +58,35 @@ const FieldParse TerrainRoadType::m_terrainRoadFieldParseTable[] = const FieldParse TerrainRoadType::m_terrainBridgeFieldParseTable[] = { - { "BridgeScale", INI::parseReal, NULL, offsetof( TerrainRoadType, m_bridgeScale ) }, - { "ScaffoldObjectName", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_scaffoldObjectName ) }, - { "ScaffoldSupportObjectName", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_scaffoldSupportObjectName ) }, - { "RadarColor", INI::parseRGBColor, NULL, offsetof( TerrainRoadType, m_radarColor ) }, + { "BridgeScale", INI::parseReal, nullptr, offsetof( TerrainRoadType, m_bridgeScale ) }, + { "ScaffoldObjectName", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_scaffoldObjectName ) }, + { "ScaffoldSupportObjectName", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_scaffoldSupportObjectName ) }, + { "RadarColor", INI::parseRGBColor, nullptr, offsetof( TerrainRoadType, m_radarColor ) }, - { "TransitionEffectsHeight", INI::parseReal, NULL, offsetof( TerrainRoadType, m_transitionEffectsHeight ) }, - { "NumFXPerType", INI::parseInt, NULL, offsetof( TerrainRoadType, m_numFXPerType ) }, + { "TransitionEffectsHeight", INI::parseReal, nullptr, offsetof( TerrainRoadType, m_transitionEffectsHeight ) }, + { "NumFXPerType", INI::parseInt, nullptr, offsetof( TerrainRoadType, m_numFXPerType ) }, - { "BridgeModelName", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_bridgeModelName ) }, - { "Texture", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_texture ) }, - { "BridgeModelNameDamaged", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_bridgeModelNameDamaged ) }, - { "TextureDamaged", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_textureDamaged ) }, - { "BridgeModelNameReallyDamaged", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_bridgeModelNameReallyDamaged ) }, - { "TextureReallyDamaged", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_textureReallyDamaged ) }, - { "BridgeModelNameBroken", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_bridgeModelNameBroken ) }, - { "TextureBroken", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_textureBroken ) }, + { "BridgeModelName", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_bridgeModelName ) }, + { "Texture", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_texture ) }, + { "BridgeModelNameDamaged", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_bridgeModelNameDamaged ) }, + { "TextureDamaged", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_textureDamaged ) }, + { "BridgeModelNameReallyDamaged", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_bridgeModelNameReallyDamaged ) }, + { "TextureReallyDamaged", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_textureReallyDamaged ) }, + { "BridgeModelNameBroken", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_bridgeModelNameBroken ) }, + { "TextureBroken", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_textureBroken ) }, - { "TowerObjectNameFromLeft", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_towerObjectName[ BRIDGE_TOWER_FROM_LEFT ] ) }, - { "TowerObjectNameFromRight", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_towerObjectName[ BRIDGE_TOWER_FROM_RIGHT ] ) }, - { "TowerObjectNameToLeft", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_towerObjectName[ BRIDGE_TOWER_TO_LEFT ] ) }, - { "TowerObjectNameToRight", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_towerObjectName[ BRIDGE_TOWER_TO_RIGHT ] ) }, + { "TowerObjectNameFromLeft", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_towerObjectName[ BRIDGE_TOWER_FROM_LEFT ] ) }, + { "TowerObjectNameFromRight", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_towerObjectName[ BRIDGE_TOWER_FROM_RIGHT ] ) }, + { "TowerObjectNameToLeft", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_towerObjectName[ BRIDGE_TOWER_TO_LEFT ] ) }, + { "TowerObjectNameToRight", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_towerObjectName[ BRIDGE_TOWER_TO_RIGHT ] ) }, - { "DamagedToSound", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_damageToSoundString[ BODY_DAMAGED ] ) }, - { "RepairedToSound", INI::parseAsciiString, NULL, offsetof( TerrainRoadType, m_repairedToSoundString[ BODY_DAMAGED ] ) }, - { "TransitionToOCL", parseTransitionToOCL, NULL, NULL }, - { "TransitionToFX", parseTransitionToFX, NULL, NULL }, + { "DamagedToSound", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_damageToSoundString[ BODY_DAMAGED ] ) }, + { "RepairedToSound", INI::parseAsciiString, nullptr, offsetof( TerrainRoadType, m_repairedToSoundString[ BODY_DAMAGED ] ) }, + { "TransitionToOCL", parseTransitionToOCL, nullptr, 0 }, + { "TransitionToFX", parseTransitionToFX, nullptr, 0 }, - { NULL, NULL, NULL, 0 }, + { nullptr, nullptr, nullptr, 0 }, }; @@ -209,7 +209,7 @@ TerrainRoadType::TerrainRoadType( void ) m_isBridge = FALSE; m_id = 0; - m_next = NULL; + m_next = nullptr; m_roadWidth = 0.0f; m_roadWidthInTexture = 0.0f; m_bridgeScale = 1.0f; @@ -237,8 +237,8 @@ TerrainRoadType::~TerrainRoadType( void ) TerrainRoadCollection::TerrainRoadCollection( void ) { - m_roadList = NULL; - m_bridgeList = NULL; + m_roadList = nullptr; + m_bridgeList = nullptr; m_idCounter = 1; ///< MUST start this at 1. @@ -298,7 +298,7 @@ TerrainRoadType *TerrainRoadCollection::findRoad( AsciiString name ) } // not found - return NULL; + return nullptr; } @@ -318,7 +318,7 @@ TerrainRoadType *TerrainRoadCollection::findBridge( AsciiString name ) } // not found - return NULL; + return nullptr; } diff --git a/Core/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp b/Core/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp index 7b200f35d8c..01966f9dd76 100644 --- a/Core/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp +++ b/Core/GameEngine/Source/GameClient/Terrain/TerrainVisual.cpp @@ -36,7 +36,7 @@ // GLOBALS //////////////////////////////////////////////////////////////////////////////////////// -TerrainVisual *TheTerrainVisual = NULL; +TerrainVisual *TheTerrainVisual = nullptr; /////////////////////////////////////////////////////////////////////////////////////////////////// // DEFINITIONS @@ -135,7 +135,7 @@ SeismicSimulationFilterBase::SeismicSimStatusCode DomeStyleSeismicFilter::filter Int life = node->m_life; - if ( heightMap == NULL ) + if ( heightMap == nullptr ) return SEISMIC_STATUS_INVALID; diff --git a/Core/GameEngine/Source/GameClient/VideoPlayer.cpp b/Core/GameEngine/Source/GameClient/VideoPlayer.cpp index a756d3c4562..4653cc4f951 100644 --- a/Core/GameEngine/Source/GameClient/VideoPlayer.cpp +++ b/Core/GameEngine/Source/GameClient/VideoPlayer.cpp @@ -78,7 +78,7 @@ // Public Data //---------------------------------------------------------------------------- -VideoPlayerInterface *TheVideoPlayer = NULL; +VideoPlayerInterface *TheVideoPlayer = nullptr; //---------------------------------------------------------------------------- // Private Prototypes @@ -155,7 +155,7 @@ void VideoBuffer::free( void ) //============================================================================ VideoPlayer::VideoPlayer() -: m_firstStream(NULL) +: m_firstStream(nullptr) { } @@ -169,7 +169,7 @@ VideoPlayer::~VideoPlayer() deinit(); // Set the video player to null if its us. (WB requires this.) if (this == TheVideoPlayer) { - TheVideoPlayer = NULL; + TheVideoPlayer = nullptr; } } @@ -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.loadFileDirectory( "Data\\INI\\Default\\Video", INI_LOAD_OVERWRITE, NULL ); - ini.loadFileDirectory( "Data\\INI\\Video", INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Default\\Video", INI_LOAD_OVERWRITE, nullptr ); + ini.loadFileDirectory( "Data\\INI\\Video", INI_LOAD_OVERWRITE, nullptr ); } //============================================================================ @@ -244,7 +244,7 @@ void VideoPlayer::regainFocus( void ) VideoStreamInterface* VideoPlayer::open( AsciiString movieTitle ) { - return NULL; + return nullptr; } //============================================================================ @@ -253,7 +253,7 @@ VideoStreamInterface* VideoPlayer::open( AsciiString movieTitle ) VideoStreamInterface* VideoPlayer::load( AsciiString movieTitle ) { - return NULL; + return nullptr; } //============================================================================ @@ -273,7 +273,7 @@ void VideoPlayer::closeAllStreams( void ) { VideoStreamInterface *stream ; - while ( (stream = firstStream()) != 0 ) + while ( (stream = firstStream()) != nullptr ) { stream->close(); } @@ -285,10 +285,10 @@ void VideoPlayer::closeAllStreams( void ) void VideoPlayer::remove( VideoStream *stream_to_remove ) { - VideoStream *last = NULL; + VideoStream *last = nullptr; VideoStream *stream = (VideoStream*) firstStream(); - while ( stream != NULL && stream != stream_to_remove ) + while ( stream != nullptr && stream != stream_to_remove ) { last = stream; stream = (VideoStream*) stream->next(); @@ -354,7 +354,7 @@ const Video* VideoPlayer::getVideo( AsciiString movieTitle ) return &(*it); } } - return NULL; + return nullptr; } //============================================================================ @@ -363,7 +363,7 @@ const Video* VideoPlayer::getVideo( AsciiString movieTitle ) const Video* VideoPlayer::getVideo( Int index ) { if (index < 0 || index >= mVideosAvailableForPlay.size()) { - return NULL; + return nullptr; } return &mVideosAvailableForPlay[index]; @@ -374,8 +374,8 @@ const Video* VideoPlayer::getVideo( Int index ) //============================================================================ VideoStream::VideoStream() -: m_next(NULL), - m_player(NULL) +: m_next(nullptr), + m_player(nullptr) { } @@ -390,7 +390,7 @@ VideoStream::~VideoStream() if ( m_player ) { m_player->remove( this ); - m_player = NULL; + m_player = nullptr; } } @@ -505,8 +505,8 @@ Int VideoStream::width( void ) const FieldParse VideoPlayer::m_videoFieldParseTable[] = { - { "Filename", INI::parseAsciiString, NULL, offsetof( Video, m_filename) }, - { "Comment", INI::parseAsciiString, NULL, offsetof( Video, m_commentForWB) }, - { NULL, NULL, NULL, 0 }, + { "Filename", INI::parseAsciiString, nullptr, offsetof( Video, m_filename) }, + { "Comment", INI::parseAsciiString, nullptr, offsetof( Video, m_commentForWB) }, + { nullptr, nullptr, nullptr, 0 }, }; diff --git a/Core/GameEngine/Source/GameClient/View.cpp b/Core/GameEngine/Source/GameClient/View.cpp index 97945602086..ba30809f3bb 100644 --- a/Core/GameEngine/Source/GameClient/View.cpp +++ b/Core/GameEngine/Source/GameClient/View.cpp @@ -36,7 +36,7 @@ UnsignedInt View::m_idNext = 1; // the tactical view singleton -View *TheTacticalView = NULL; +View *TheTacticalView = nullptr; View::View( void ) @@ -44,33 +44,33 @@ View::View( void ) m_viewLockedUntilFrame = 0u; m_currentHeightAboveGround = 0.0f; m_defaultAngle = 0.0f; - m_defaultPitchAngle = 0.0f; + m_defaultPitch = 0.0f; m_heightAboveGround = 0.0f; m_lockDist = 0.0f; m_maxHeightAboveGround = 0.0f; m_minHeightAboveGround = 0.0f; - m_next = NULL; + m_next = nullptr; m_okToAdjustHeight = TRUE; m_originX = 0; m_originY = 0; m_snapImmediate = FALSE; - m_terrainHeightUnderCamera = 0.0f; + m_terrainHeightAtPivot = 0.0f; m_zoom = 0.0f; m_pos.x = 0; m_pos.y = 0; m_width = 0; m_height = 0; m_angle = 0.0f; - m_pitchAngle = 0.0f; + m_pitch = 0.0f; m_cameraLock = INVALID_ID; - m_cameraLockDrawable = NULL; + m_cameraLockDrawable = nullptr; m_zoomLimited = TRUE; // create unique view ID m_id = m_idNext++; // default field of view - m_FOV = 50.0f * PI/180.0f; + m_FOV = DEG_TO_RADF(50.0f); m_mouseLocked = FALSE; @@ -92,7 +92,7 @@ void View::init( void ) m_pos.y = 0; m_angle = 0.0f; m_cameraLock = INVALID_ID; - m_cameraLockDrawable = NULL; + m_cameraLockDrawable = nullptr; m_zoomLimited = TRUE; m_zoom = 1.0f; @@ -101,7 +101,7 @@ void View::init( void ) m_okToAdjustHeight = FALSE; m_defaultAngle = 0.0f; - m_defaultPitchAngle = 0.0f; + m_defaultPitch = 0.0f; } void View::reset( void ) @@ -155,29 +155,36 @@ void View::scrollBy( Coord2D *delta ) } /** - * Rotate the view around the up axis by the given angle. + * Rotate the view around the vertical axis to the given angle. */ -void View::setAngle( Real angle ) +void View::setAngle( Real radians ) { - m_angle = angle; + m_angle = WWMath::Normalize_Angle(radians); } /** * Rotate the view around the horizontal (X) axis to the given angle. */ -void View::setPitch( Real angle ) +void View::setPitch( Real radians ) { constexpr Real limit = PI/5.0f; - m_pitchAngle = clamp(-limit, angle, limit); + m_pitch = clamp(-limit, radians, limit); } /** * Set the view angle back to default */ -void View::setAngleAndPitchToDefault( void ) +void View::setAngleToDefault( void ) { m_angle = m_defaultAngle; - m_pitchAngle = m_defaultPitchAngle; +} + +/** + * Set the view pitch back to default + */ +void View::setPitchToDefault( void ) +{ + m_pitch = m_defaultPitch; } void View::setHeightAboveGround(Real z) @@ -226,35 +233,38 @@ void View::setLocation( const ViewLocation *location ) the world points are at the requested Z */ //------------------------------------------------------------------------------------------------- void View::getScreenCornerWorldPointsAtZ( Coord3D *topLeft, Coord3D *topRight, - Coord3D *bottomLeft, Coord3D *bottomRight, + Coord3D *bottomRight, Coord3D *bottomLeft, Real z ) { - ICoord2D screenTopLeft, screenTopRight, screenBottomLeft, screenBottomRight; - ICoord2D origin; - Int viewWidth = getWidth(); - Int viewHeight = getHeight(); - // sanity - if( topLeft == NULL || topRight == NULL || bottomLeft == NULL || bottomRight == NULL ) + if( topLeft == nullptr || topRight == nullptr || bottomRight == nullptr || bottomLeft == nullptr) return; + ICoord2D screenTopLeft; + ICoord2D screenTopRight; + ICoord2D screenBottomRight; + ICoord2D screenBottomLeft; + ICoord2D origin; + const Int viewWidth = getWidth(); + const Int viewHeight = getHeight(); + // setup the screen coords for the 4 corners of the viewable display getOrigin( &origin.x, &origin.y ); - screenTopLeft.x = origin.x; // upper left - screenTopLeft.y = origin.y; // upper left - screenTopRight.x = origin.x + viewWidth; // upper right - screenTopRight.y = origin.y; // upper right - screenBottomLeft.x = origin.x + viewWidth; // lower right - screenBottomLeft.y = origin.y + viewHeight; // lower right - screenBottomRight.x = origin.x; // lower left - screenBottomRight.y = origin.y + viewHeight; // lower left + + screenTopLeft.x = origin.x; + screenTopLeft.y = origin.y; + screenTopRight.x = origin.x + viewWidth; + screenTopRight.y = origin.y; + screenBottomRight.x = origin.x + viewWidth; + screenBottomRight.y = origin.y + viewHeight; + screenBottomLeft.x = origin.x; + screenBottomLeft.y = origin.y + viewHeight; // project screenToWorldAtZ( &screenTopLeft, topLeft, z ); screenToWorldAtZ( &screenTopRight, topRight, z ); - screenToWorldAtZ( &screenBottomLeft, bottomLeft, z ); screenToWorldAtZ( &screenBottomRight, bottomRight, z ); - + screenToWorldAtZ( &screenBottomLeft, bottomLeft, z ); } // ------------------------------------------------------------------------------------------------ diff --git a/Core/GameEngine/Source/GameClient/Water.cpp b/Core/GameEngine/Source/GameClient/Water.cpp index ce17606d229..3382f11ce04 100644 --- a/Core/GameEngine/Source/GameClient/Water.cpp +++ b/Core/GameEngine/Source/GameClient/Water.cpp @@ -35,26 +35,26 @@ // GLOBALS //////////////////////////////////////////////////////////////////////////////////////// WaterSetting WaterSettings[ TIME_OF_DAY_COUNT ]; -OVERRIDE TheWaterTransparency = NULL; +OVERRIDE TheWaterTransparency = nullptr; // PRIVATE DATA /////////////////////////////////////////////////////////////////////////////////// const FieldParse WaterSetting::m_waterSettingFieldParseTable[] = { - { "SkyTexture", INI::parseAsciiString, NULL, offsetof( WaterSetting, m_skyTextureFile ) }, - { "WaterTexture", INI::parseAsciiString, NULL, offsetof( WaterSetting, m_waterTextureFile ) }, - { "Vertex00Color", INI::parseRGBAColorInt, NULL, offsetof( WaterSetting, m_vertex00Diffuse ) }, - { "Vertex10Color", INI::parseRGBAColorInt, NULL, offsetof( WaterSetting, m_vertex10Diffuse ) }, - { "Vertex01Color", INI::parseRGBAColorInt, NULL, offsetof( WaterSetting, m_vertex01Diffuse ) }, - { "Vertex11Color", INI::parseRGBAColorInt, NULL, offsetof( WaterSetting, m_vertex11Diffuse ) }, - { "DiffuseColor", INI::parseRGBAColorInt, NULL, offsetof( WaterSetting, m_waterDiffuseColor ) }, - { "TransparentDiffuseColor", INI::parseRGBAColorInt, NULL, offsetof( WaterSetting, m_transparentWaterDiffuse ) }, - { "UScrollPerMS", INI::parseReal, NULL, offsetof( WaterSetting, m_uScrollPerMs ) }, - { "VScrollPerMS", INI::parseReal, NULL, offsetof( WaterSetting, m_vScrollPerMs ) }, - { "SkyTexelsPerUnit", INI::parseReal, NULL, offsetof( WaterSetting, m_skyTexelsPerUnit ) }, - { "WaterRepeatCount", INI::parseInt, NULL, offsetof( WaterSetting, m_waterRepeatCount ) }, - - { NULL, NULL, NULL, 0 }, + { "SkyTexture", INI::parseAsciiString, nullptr, offsetof( WaterSetting, m_skyTextureFile ) }, + { "WaterTexture", INI::parseAsciiString, nullptr, offsetof( WaterSetting, m_waterTextureFile ) }, + { "Vertex00Color", INI::parseRGBAColorInt, nullptr, offsetof( WaterSetting, m_vertex00Diffuse ) }, + { "Vertex10Color", INI::parseRGBAColorInt, nullptr, offsetof( WaterSetting, m_vertex10Diffuse ) }, + { "Vertex01Color", INI::parseRGBAColorInt, nullptr, offsetof( WaterSetting, m_vertex01Diffuse ) }, + { "Vertex11Color", INI::parseRGBAColorInt, nullptr, offsetof( WaterSetting, m_vertex11Diffuse ) }, + { "DiffuseColor", INI::parseRGBAColorInt, nullptr, offsetof( WaterSetting, m_waterDiffuseColor ) }, + { "TransparentDiffuseColor", INI::parseRGBAColorInt, nullptr, offsetof( WaterSetting, m_transparentWaterDiffuse ) }, + { "UScrollPerMS", INI::parseReal, nullptr, offsetof( WaterSetting, m_uScrollPerMs ) }, + { "VScrollPerMS", INI::parseReal, nullptr, offsetof( WaterSetting, m_vScrollPerMs ) }, + { "SkyTexelsPerUnit", INI::parseReal, nullptr, offsetof( WaterSetting, m_skyTexelsPerUnit ) }, + { "WaterRepeatCount", INI::parseInt, nullptr, offsetof( WaterSetting, m_waterRepeatCount ) }, + + { nullptr, nullptr, nullptr, 0 }, }; @@ -62,20 +62,20 @@ const FieldParse WaterSetting::m_waterSettingFieldParseTable[] = const FieldParse WaterTransparencySetting::m_waterTransparencySettingFieldParseTable[] = { - { "TransparentWaterDepth", INI::parseReal, NULL, offsetof( WaterTransparencySetting, m_transparentWaterDepth ) }, - { "TransparentWaterMinOpacity", INI::parseReal, NULL, offsetof( WaterTransparencySetting, m_minWaterOpacity ) }, - { "StandingWaterColor", INI::parseRGBColor, NULL, offsetof( WaterTransparencySetting, m_standingWaterColor ) }, - { "StandingWaterTexture",INI::parseAsciiString, NULL, offsetof( WaterTransparencySetting, m_standingWaterTexture ) }, - { "AdditiveBlending", INI::parseBool, NULL, offsetof( WaterTransparencySetting, m_additiveBlend) }, - { "RadarWaterColor", INI::parseRGBColor, NULL, offsetof( WaterTransparencySetting, m_radarColor) }, - { "SkyboxTextureN", INI::parseAsciiString,NULL, offsetof( WaterTransparencySetting, m_skyboxTextureN ) }, - { "SkyboxTextureE", INI::parseAsciiString,NULL, offsetof( WaterTransparencySetting, m_skyboxTextureE ) }, - { "SkyboxTextureS", INI::parseAsciiString,NULL, offsetof( WaterTransparencySetting, m_skyboxTextureS ) }, - { "SkyboxTextureW", INI::parseAsciiString,NULL, offsetof( WaterTransparencySetting, m_skyboxTextureW ) }, - { "SkyboxTextureT", INI::parseAsciiString,NULL, offsetof( WaterTransparencySetting, m_skyboxTextureT ) }, + { "TransparentWaterDepth", INI::parseReal, nullptr, offsetof( WaterTransparencySetting, m_transparentWaterDepth ) }, + { "TransparentWaterMinOpacity", INI::parseReal, nullptr, offsetof( WaterTransparencySetting, m_minWaterOpacity ) }, + { "StandingWaterColor", INI::parseRGBColor, nullptr, offsetof( WaterTransparencySetting, m_standingWaterColor ) }, + { "StandingWaterTexture",INI::parseAsciiString, nullptr, offsetof( WaterTransparencySetting, m_standingWaterTexture ) }, + { "AdditiveBlending", INI::parseBool, nullptr, offsetof( WaterTransparencySetting, m_additiveBlend) }, + { "RadarWaterColor", INI::parseRGBColor, nullptr, offsetof( WaterTransparencySetting, m_radarColor) }, + { "SkyboxTextureN", INI::parseAsciiString,nullptr, offsetof( WaterTransparencySetting, m_skyboxTextureN ) }, + { "SkyboxTextureE", INI::parseAsciiString,nullptr, offsetof( WaterTransparencySetting, m_skyboxTextureE ) }, + { "SkyboxTextureS", INI::parseAsciiString,nullptr, offsetof( WaterTransparencySetting, m_skyboxTextureS ) }, + { "SkyboxTextureW", INI::parseAsciiString,nullptr, offsetof( WaterTransparencySetting, m_skyboxTextureW ) }, + { "SkyboxTextureT", INI::parseAsciiString,nullptr, offsetof( WaterTransparencySetting, m_skyboxTextureT ) }, - { 0, 0, 0, 0 }, + { nullptr, nullptr, nullptr, 0 }, }; diff --git a/Core/GameEngine/Source/GameNetwork/Connection.cpp b/Core/GameEngine/Source/GameNetwork/Connection.cpp index fe804e5ae86..eda39971126 100644 --- a/Core/GameEngine/Source/GameNetwork/Connection.cpp +++ b/Core/GameEngine/Source/GameNetwork/Connection.cpp @@ -35,9 +35,9 @@ enum { MaxQuitFlushTime = 30000 }; // wait this many milliseconds at most to ret * The constructor. */ Connection::Connection() { - m_transport = NULL; - m_user = NULL; - m_netCommandList = NULL; + m_transport = nullptr; + m_user = nullptr; + m_netCommandList = nullptr; m_retryTime = 2000; // set retry time to 2 seconds. m_lastTimeSent = 0; m_frameGrouping = 1; @@ -56,22 +56,22 @@ Connection::Connection() { */ Connection::~Connection() { deleteInstance(m_user); - m_user = NULL; + m_user = nullptr; deleteInstance(m_netCommandList); - m_netCommandList = NULL; + m_netCommandList = nullptr; } /** * Initialize the connection and any subsystems. */ void Connection::init() { - m_transport = NULL; + m_transport = nullptr; deleteInstance(m_user); - m_user = NULL; + m_user = nullptr; - if (m_netCommandList == NULL) { + if (m_netCommandList == nullptr) { m_netCommandList = newInstance(NetCommandList); m_netCommandList->init(); } @@ -131,10 +131,10 @@ User * Connection::getUser() { * The relay mostly has to do with the packet router. */ void Connection::sendNetCommandMsg(NetCommandMsg *msg, UnsignedByte relay) { - static NetPacket *packet = NULL; + static NetPacket *packet = nullptr; // this is done so we don't have to allocate and delete a packet every time we send a message. - if (packet == NULL) { + if (packet == nullptr) { packet = newInstance(NetPacket); } @@ -142,7 +142,7 @@ void Connection::sendNetCommandMsg(NetCommandMsg *msg, UnsignedByte relay) { if (m_isQuitting) return; - if (m_netCommandList != NULL) { + if (m_netCommandList != nullptr) { // check to see if this command will fit in a packet. If not, we need to split it up. // we are splitting up the command here so that the retry logic will not try to // resend the ENTIRE command (i.e. multiple packets work of data) and only do the retry @@ -153,7 +153,7 @@ void Connection::sendNetCommandMsg(NetCommandMsg *msg, UnsignedByte relay) { Bool msgFits = packet->addCommand(tempref); deleteInstance(tempref); // delete the temporary reference. - tempref = NULL; + tempref = nullptr; if (!msgFits) { NetCommandRef *origref = NEW_NETCOMMANDREF(msg); @@ -167,7 +167,7 @@ void Connection::sendNetCommandMsg(NetCommandMsg *msg, UnsignedByte relay) { NetCommandList *list = tempPacket->getCommandList(); NetCommandRef *ref1 = list->getFirstMessage(); - while (ref1 != NULL) { + while (ref1 != nullptr) { NetCommandRef *ref2 = m_netCommandList->addMessage(ref1->getCommand()); ref2->setRelay(relay); @@ -175,15 +175,15 @@ void Connection::sendNetCommandMsg(NetCommandMsg *msg, UnsignedByte relay) { } deleteInstance(tempPacket); - tempPacket = NULL; + tempPacket = nullptr; ++tempPacketPtr; deleteInstance(list); - list = NULL; + list = nullptr; } deleteInstance(origref); - origref = NULL; + origref = nullptr; return; } @@ -191,7 +191,7 @@ void Connection::sendNetCommandMsg(NetCommandMsg *msg, UnsignedByte relay) { // the message fits in a packet, add to the command list normally. NetCommandRef *ref = m_netCommandList->addMessage(msg); - if (ref != NULL) { + if (ref != nullptr) { /* #if defined(RTS_DEBUG) @@ -231,7 +231,7 @@ void Connection::clearCommandsExceptFrom( Int playerIndex ) } Bool Connection::isQueueEmpty() { - if (m_netCommandList->getFirstMessage() == NULL) { + if (m_netCommandList->getFirstMessage() == nullptr) { return TRUE; } return FALSE; @@ -269,7 +269,7 @@ UnsignedInt Connection::doSend() { // iterate through all the messages and put them into a packet(s). NetCommandRef *msg = m_netCommandList->getFirstMessage(); - while ((msg != NULL) && couldQueue) { + while ((msg != nullptr) && couldQueue) { NetPacket *packet = newInstance(NetPacket); packet->init(); packet->setAddress(m_user->GetIPAddr(), m_user->GetPort()); @@ -277,7 +277,7 @@ UnsignedInt Connection::doSend() { Bool notDone = TRUE; // add the command messages until either we run out of messages or the packet is full. - while ((msg != NULL) && notDone) { + while ((msg != nullptr) && notDone) { NetCommandRef *next = msg->getNext(); // Need this since msg could be deleted time_t timeLastSent = msg->getTimeLastSent(); @@ -301,7 +301,7 @@ UnsignedInt Connection::doSend() { msg = next; } - if (msg != NULL) { + if (msg != nullptr) { DEBUG_LOG(("didn't finish sending all commands in connection")); } @@ -340,7 +340,7 @@ NetCommandRef * Connection::processAck(NetCommandMsg *msg) { return processAck(ackmsg); } - return NULL; + return nullptr; } /** @@ -349,14 +349,14 @@ NetCommandRef * Connection::processAck(NetCommandMsg *msg) { */ NetCommandRef * Connection::processAck(UnsignedShort commandID, UnsignedByte originalPlayerID) { NetCommandRef *temp = m_netCommandList->getFirstMessage(); - while ((temp != NULL) && ((temp->getCommand()->getID() != commandID) || (temp->getCommand()->getPlayerID() != originalPlayerID))) { + while ((temp != nullptr) && ((temp->getCommand()->getID() != commandID) || (temp->getCommand()->getPlayerID() != originalPlayerID))) { // cycle through the commands till we find the one we need to remove. // Need to check for both the command ID and the player ID. temp = temp->getNext(); } - if (temp == NULL) { - return NULL; + if (temp == nullptr) { + return nullptr; } #if defined(RTS_DEBUG) @@ -402,7 +402,7 @@ void Connection::doRetryMetrics() { #if defined(RTS_DEBUG) void Connection::debugPrintCommands() { NetCommandRef *ref = m_netCommandList->getFirstMessage(); - while (ref != NULL) { + while (ref != nullptr) { DEBUG_LOG(("Connection::debugPrintCommands - ID: %d\tType: %s\tRelay: 0x%X for frame %d", ref->getCommand()->getID(), GetNetCommandTypeAsString(ref->getCommand()->getNetCommandType()), ref->getRelay(), ref->getCommand()->getExecutionFrame())); diff --git a/Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp b/Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp index 7b3450a960b..959c882d625 100644 --- a/Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp +++ b/Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp @@ -66,7 +66,7 @@ static Bool hasValidTransferFileExtension(const AsciiString& filePath) const char* fileExt = strrchr(filePath.str(), '.'); - if (fileExt == NULL || fileExt[1] == '\0') + if (fileExt == nullptr || fileExt[1] == '\0') { return false; } @@ -90,38 +90,38 @@ static Bool hasValidTransferFileExtension(const AsciiString& filePath) ConnectionManager::~ConnectionManager(void) { deleteInstance(m_localUser); - m_localUser = NULL; + m_localUser = nullptr; // Network will delete transports; we just forget them delete m_transport; - m_transport = NULL; + m_transport = nullptr; Int i = 0; for (; i < MAX_SLOTS; ++i) { deleteInstance(m_frameData[i]); - m_frameData[i] = NULL; + m_frameData[i] = nullptr; } for (i = 0; i < NUM_CONNECTIONS; ++i) { deleteInstance(m_connections[i]); - m_connections[i] = NULL; + m_connections[i] = nullptr; } // This is done here since TheDisconnectMenu should only be there if we are in a network game. delete TheDisconnectMenu; - TheDisconnectMenu = NULL; + TheDisconnectMenu = nullptr; delete m_disconnectManager; - m_disconnectManager = NULL; + m_disconnectManager = nullptr; deleteInstance(m_pendingCommands); - m_pendingCommands = NULL; + m_pendingCommands = nullptr; deleteInstance(m_relayedCommands); - m_relayedCommands = NULL; + m_relayedCommands = nullptr; deleteInstance(m_netCommandWrapperList); - m_netCommandWrapperList = NULL; + m_netCommandWrapperList = nullptr; s_fileCommandMap.clear(); s_fileRecipientMaskMap.clear(); @@ -136,16 +136,16 @@ ConnectionManager::~ConnectionManager(void) ConnectionManager::ConnectionManager(void) { for (Int i = 0; i < MAX_SLOTS; ++i) { - m_frameData[i] = NULL; + m_frameData[i] = nullptr; } - m_transport = NULL; - m_disconnectManager = NULL; - m_pendingCommands = NULL; - m_relayedCommands = NULL; + m_transport = nullptr; + m_disconnectManager = nullptr; + m_pendingCommands = nullptr; + m_relayedCommands = nullptr; m_localAddr = 0; m_localPort = 0; - m_netCommandWrapperList = NULL; - m_localUser = NULL; + m_netCommandWrapperList = nullptr; + m_localUser = nullptr; m_localUser = newInstance(User); } @@ -154,23 +154,23 @@ ConnectionManager::ConnectionManager(void) */ void ConnectionManager::init() { -// if (m_transport == NULL) { +// if (m_transport == nullptr) { // m_transport = new Transport; // } // m_transport->reset(); UnsignedInt i = 0; for (; i < NUM_CONNECTIONS; ++i) { - m_connections[i] = NULL; + m_connections[i] = nullptr; } - if (m_pendingCommands == NULL) { + if (m_pendingCommands == nullptr) { m_pendingCommands = newInstance(NetCommandList); m_pendingCommands->init(); } m_pendingCommands->reset(); - if (m_relayedCommands == NULL) { + if (m_relayedCommands == nullptr) { m_relayedCommands = newInstance(NetCommandList); m_relayedCommands->init(); } @@ -187,7 +187,7 @@ void ConnectionManager::init() for (i = 0; i < MAX_SLOTS; ++i) { deleteInstance(m_frameData[i]); - m_frameData[i] = NULL; + m_frameData[i] = nullptr; } // m_averageFps = 30; // since 30 fps is the desired rate, we'll start off at that. @@ -227,39 +227,39 @@ void ConnectionManager::init() */ void ConnectionManager::reset() { -// if (m_transport == NULL) { +// if (m_transport == nullptr) { // m_transport = new Transport; // } // m_transport->reset(); delete m_transport; - m_transport = NULL; + m_transport = nullptr; UnsignedInt i = 0; for (; i < (UnsignedInt)NUM_CONNECTIONS; ++i) { deleteInstance(m_connections[i]); - m_connections[i] = NULL; + m_connections[i] = nullptr; } for (i=0; i<(UnsignedInt)MAX_SLOTS; ++i) { deleteInstance(m_frameData[i]); - m_frameData[i] = NULL; + m_frameData[i] = nullptr; } - if (m_pendingCommands == NULL) { + if (m_pendingCommands == nullptr) { m_pendingCommands = newInstance(NetCommandList); m_pendingCommands->init(); } m_pendingCommands->reset(); - if (m_relayedCommands == NULL) { + if (m_relayedCommands == nullptr) { m_relayedCommands = newInstance(NetCommandList); m_relayedCommands->init(); } m_relayedCommands->reset(); - if (m_netCommandWrapperList == NULL) { + if (m_netCommandWrapperList == nullptr) { m_netCommandWrapperList = newInstance(NetCommandWrapperList); m_netCommandWrapperList->init(); } @@ -295,9 +295,9 @@ Int ConnectionManager::getPingsSent() return (m_disconnectManager)?m_disconnectManager->getPingsSent():0; } -Int ConnectionManager::getPingsRecieved() +Int ConnectionManager::getPingsReceived() { - return (m_disconnectManager)?m_disconnectManager->getPingsRecieved():0; + return (m_disconnectManager)?m_disconnectManager->getPingsReceived():0; } Bool ConnectionManager::isPlayerConnected( Int playerID ) @@ -316,7 +316,7 @@ void ConnectionManager::attachTransport(Transport *transport) { */ void ConnectionManager::zeroFrames(UnsignedInt startingFrame, UnsignedInt numFrames) { for (Int i = 0; i < MAX_SLOTS; ++i) { - if (m_frameData[i] != NULL) { + if (m_frameData[i] != nullptr) { // DEBUG_LOG(("Calling zeroFrames on player %d, starting frame %d, numFrames %d", i, startingFrame, numFrames)); m_frameData[i]->zeroFrames(startingFrame, numFrames); } @@ -331,7 +331,7 @@ void ConnectionManager::destroyGameMessages() { // Need to destroy these game messages because when the game ends, there are // still some game messages left over because of the run ahead aspect of // network play. - if (m_frameData[i] != NULL) { + if (m_frameData[i] != nullptr) { m_frameData[i]->destroyGameMessages(); } } @@ -347,7 +347,7 @@ void ConnectionManager::doRelay() { static Int numPackets = 0; static Int numCommands = 0; - NetPacket *packet = NULL; + NetPacket *packet = nullptr; for (Int i = 0; i < MAX_MESSAGES; ++i) { if (m_transport->m_inBuffer[i].length != 0) { @@ -364,7 +364,7 @@ void ConnectionManager::doRelay() { NetCommandRef *cmd = cmdList->getFirstMessage(); // Iterate through the commands in this packet and send them to the proper connections. - while (cmd != NULL) { + while (cmd != nullptr) { //DEBUG_LOG(("ConnectionManager::doRelay() - Looking at a command of type %s", //GetNetCommandTypeAsString(cmd->getCommand()->getNetCommandType()))); if (CommandRequiresAck(cmd->getCommand())) { @@ -381,10 +381,10 @@ void ConnectionManager::doRelay() { // Delete this packet since we won't be needing it anymore. deleteInstance(packet); - packet = NULL; + packet = nullptr; deleteInstance(cmdList); - cmdList = NULL; + cmdList = nullptr; // signal that this has been processed. m_transport->m_inBuffer[i].length = 0; @@ -393,7 +393,7 @@ void ConnectionManager::doRelay() { NetCommandList *cmdList = m_netCommandWrapperList->getReadyCommands(); NetCommandRef *cmd = cmdList->getFirstMessage(); - while (cmd != NULL) { + while (cmd != nullptr) { if (CommandRequiresAck(cmd->getCommand())) { ackCommand(cmd, m_localSlot); } @@ -408,10 +408,10 @@ void ConnectionManager::doRelay() { // Delete this packet since we won't be needing it anymore. deleteInstance(packet); - packet = NULL; + packet = nullptr; deleteInstance(cmdList); - cmdList = NULL; + cmdList = nullptr; } /** @@ -431,7 +431,7 @@ Bool ConnectionManager::processNetCommand(NetCommandRef *ref) { } // Early validation checks - if ((m_connections[msg->getPlayerID()] == NULL) && (msg->getPlayerID() != m_localSlot)) { + if ((m_connections[msg->getPlayerID()] == nullptr) && (msg->getPlayerID() != m_localSlot)) { // if this is from a player that is no longer in the game, then ignore them. return TRUE; } @@ -443,7 +443,7 @@ Bool ConnectionManager::processNetCommand(NetCommandRef *ref) { } if ((msg->getPlayerID() >= 0) && (msg->getPlayerID() < MAX_SLOTS) && (msg->getPlayerID() != m_localSlot)) { - if (m_connections[msg->getPlayerID()] == NULL) { + if (m_connections[msg->getPlayerID()] == nullptr) { return TRUE; } } @@ -542,7 +542,7 @@ void ConnectionManager::processFrameResendRequest(NetFrameResendRequestCommandMs } // make sure this player is still in our game. - if ((m_connections[playerID] == NULL) || (m_connections[playerID]->isQuitting() == TRUE)) { + if ((m_connections[playerID] == nullptr) || (m_connections[playerID]->isQuitting() == TRUE)) { return; } @@ -638,10 +638,10 @@ void ConnectionManager::processChat(NetChatCommandMsg *msg) //DEBUG_LOG(("processChat(): playerID = %d", playerID)); if (playerID == m_localSlot) { name = m_localUser->GetName(); - //DEBUG_LOG(("connection is NULL, using %ls", name.str())); - } else if (((m_connections[playerID] != NULL) && (m_connections[playerID]->isQuitting() == FALSE))) { + //DEBUG_LOG(("connection is null, using %ls", name.str())); + } else if (((m_connections[playerID] != nullptr) && (m_connections[playerID]->isQuitting() == FALSE))) { name = m_connections[playerID]->getUser()->GetName(); - //DEBUG_LOG(("connection is non-NULL, using %ls", name.str())); + //DEBUG_LOG(("connection is non-null, using %ls", name.str())); } unitext.format(L"[%ls] %ls", name.str(), msg->getText().str()); // DEBUG_LOG(("ConnectionManager::processChat - got message from player %d (mask %8.8X), message is %ls", playerID, msg->getPlayerMask(), unitext.str())); @@ -733,7 +733,7 @@ void ConnectionManager::processFile(NetFileCommandMsg *msg) { fp->write(buf, len); fp->close(); - fp = NULL; + fp = nullptr; DEBUG_LOG(("Wrote %d bytes to file %s!", len, realFileName.str())); } @@ -767,7 +767,7 @@ void ConnectionManager::processFile(NetFileCommandMsg *msg) if (deleteBuf) { delete[] buf; - buf = NULL; + buf = nullptr; } #endif // COMPRESS_TARGAS } @@ -823,7 +823,7 @@ void ConnectionManager::processFrameInfo(NetFrameCommandMsg *msg) { UnsignedInt playerID = msg->getPlayerID(); if ((playerID >= 0) && (playerID < MAX_SLOTS)) { - if (m_frameData[playerID] != NULL) { + if (m_frameData[playerID] != nullptr) { // DEBUG_LOG(("ConnectionManager::processFrameInfo - player %d, frame %d, command count %d, received on frame %d", playerID, msg->getExecutionFrame(), msg->getCommandCount(), TheGameLogic->getFrame())); m_frameData[playerID]->setFrameCommandCount(msg->getExecutionFrame(), msg->getCommandCount()); } @@ -840,7 +840,7 @@ void ConnectionManager::processAckStage1(NetCommandMsg *msg) { #endif UnsignedByte playerID = msg->getPlayerID(); - NetCommandRef *ref = NULL; + NetCommandRef *ref = nullptr; #if defined(RTS_DEBUG) if (doDebug == TRUE) { @@ -849,20 +849,20 @@ void ConnectionManager::processAckStage1(NetCommandMsg *msg) { #endif if ((playerID >= 0) && (playerID < NUM_CONNECTIONS)) { - if (m_connections[playerID] != NULL) { + if (m_connections[playerID] != nullptr) { ref = m_connections[playerID]->processAck(msg); } } else { DEBUG_ASSERTCRASH((playerID >= 0) && (playerID < NUM_CONNECTIONS), ("ConnectionManager::processAck - %d is an invalid player number", playerID)); } - if (ref != NULL) { + if (ref != nullptr) { if (ref->getCommand()->getNetCommandType() == NETCOMMANDTYPE_FRAMEINFO) { m_frameMetrics.processLatencyResponse(((NetFrameCommandMsg *)(ref->getCommand()))->getExecutionFrame()); } deleteInstance(ref); - ref = NULL; + ref = nullptr; } } @@ -884,18 +884,18 @@ void ConnectionManager::processAckStage2(NetCommandMsg *msg) { } NetCommandRef *ref = m_pendingCommands->findMessage(commandID, playerID); - if (ref != NULL) { + if (ref != nullptr) { //DEBUG_LOG(("ConnectionManager::processAckStage2 - removing command %d from the pending commands list.", commandID)); DEBUG_ASSERTCRASH((m_localSlot == playerID), ("Found a command in the pending commands list that wasn't originated by the local player")); m_pendingCommands->removeMessage(ref); deleteInstance(ref); - ref = NULL; + ref = nullptr; } else { //DEBUG_LOG(("ConnectionManager::processAckStage2 - Couldn't find command %d from player %d in the pending commands list.", commandID, playerID)); } ref = m_relayedCommands->findMessage(commandID, playerID); - if (ref != NULL) { + if (ref != nullptr) { //DEBUG_LOG(("ConnectionManager::processAckStage2 - found command ID %d from player %d in the relayed commands list.", commandID, playerID)); UnsignedByte prevRelay = ref->getRelay(); UnsignedByte relay = prevRelay & ~(1 << msg->getPlayerID()); @@ -906,10 +906,10 @@ void ConnectionManager::processAckStage2(NetCommandMsg *msg) { NetAckStage2CommandMsg *ackmsg = newInstance(NetAckStage2CommandMsg)(ref->getCommand()); sendLocalCommand(ackmsg, 1 << ackmsg->getOriginalPlayerID()); deleteInstance(ref); - ref = NULL; + ref = nullptr; ackmsg->detach(); - ackmsg = NULL; + ackmsg = nullptr; } else { ref->setRelay(relay); } @@ -940,12 +940,12 @@ void ConnectionManager::processAck(NetCommandMsg *msg) { */ PlayerLeaveCode ConnectionManager::processPlayerLeave(NetPlayerLeaveCommandMsg *msg) { UnsignedByte playerID = msg->getLeavingPlayerID(); - if ((playerID != m_localSlot) && (m_connections[playerID] != NULL)) { + if ((playerID != m_localSlot) && (m_connections[playerID] != nullptr)) { DEBUG_LOG(("ConnectionManager::processPlayerLeave() - setQuitting() on player %d on frame %d", playerID, TheGameLogic->getFrame())); m_connections[playerID]->setQuitting(); } DEBUG_ASSERTCRASH(m_frameData[playerID]->getIsQuitting() == FALSE, ("Player %d is already quitting", playerID)); - if ((playerID != m_localSlot) && (m_frameData[playerID] != NULL) && (m_frameData[playerID]->getIsQuitting() == FALSE)) { + if ((playerID != m_localSlot) && (m_frameData[playerID] != nullptr) && (m_frameData[playerID]->getIsQuitting() == FALSE)) { DEBUG_LOG(("ConnectionManager::processPlayerLeave - setQuitFrame on player %d for frame %d", playerID, TheGameLogic->getFrame()+1)); m_frameData[playerID]->setQuitFrame(TheGameLogic->getFrame() + FRAMES_TO_KEEP + 1); } @@ -986,7 +986,7 @@ UnsignedInt ConnectionManager::getPacketRouterSlot() { Bool ConnectionManager::areAllQueuesEmpty(void) { Bool retval = TRUE; for (Int i = 0; (i < MAX_SLOTS) && retval; ++i) { - if (m_connections[i] != NULL) { + if (m_connections[i] != nullptr) { if (m_connections[i]->isQueueEmpty() == FALSE) { //DEBUG_LOG(("ConnectionManager::areAllQueuesEmpty() - m_connections[%d] is not empty", i)); //m_connections[i]->debugPrintCommands(); @@ -1037,7 +1037,7 @@ void ConnectionManager::ackCommand(NetCommandRef *ref, UnsignedInt localSlot) { // Make send relay a bitmask for the connections that the relay will actually be sent to. This is // necessary to determine whether or not we have to wait to send a stage 2 ack. for (Int i = 0; i < MAX_SLOTS; ++i) { - if (((m_connections[i] != NULL) && (m_connections[i]->isQuitting() == FALSE))) { + if (((m_connections[i] != nullptr) && (m_connections[i]->isQuitting() == FALSE))) { sendRelay = sendRelay | (1 << i); } } @@ -1074,30 +1074,30 @@ void ConnectionManager::ackCommand(NetCommandRef *ref, UnsignedInt localSlot) { if (CommandRequiresDirectSend(msg) && CommandRequiresAck(msg)) { // Send this ack directly back to the sending player, don't go through the packet router. if ((msg->getPlayerID() >= 0) && (msg->getPlayerID() < MAX_SLOTS)) { - if (m_connections[msg->getPlayerID()] != NULL) { + if (m_connections[msg->getPlayerID()] != nullptr) { m_connections[msg->getPlayerID()]->sendNetCommandMsg(ackmsg, 1 << msg->getPlayerID()); } } } else { - // The local connection may be the packet router, in that case, the connection would be NULL. So do something about it! + // The local connection may be the packet router, in that case, the connection would be null. So do something about it! if ((m_packetRouterSlot >= 0) && (m_packetRouterSlot < MAX_SLOTS)) { - if (m_connections[m_packetRouterSlot] != NULL) { + if (m_connections[m_packetRouterSlot] != nullptr) { // DEBUG_LOG(("ConnectionManager::ackCommand - acking command %d from player %d to packet router.", commandID, m_packetRouterSlot)); m_connections[m_packetRouterSlot]->sendNetCommandMsg(ackmsg, 1 << m_packetRouterSlot); } else if (m_localSlot == m_packetRouterSlot) { // we are the packet router, send the ack to the player that sent the command. if ((msg->getPlayerID() >= 0) && (msg->getPlayerID() < MAX_SLOTS)) { - if (m_connections[msg->getPlayerID()] != NULL) { + if (m_connections[msg->getPlayerID()] != nullptr) { // DEBUG_LOG(("ConnectionManager::ackCommand - acking command %d from player %d directly to player.", commandID, msg->getPlayerID())); m_connections[msg->getPlayerID()]->sendNetCommandMsg(ackmsg, 1 << msg->getPlayerID()); } else { - // DEBUG_ASSERTCRASH(m_connections[msg->getPlayerID()] != NULL, ("Connection to player is NULL")); + // DEBUG_ASSERTCRASH(m_connections[msg->getPlayerID()] != nullptr, ("Connection to player is null")); } } else { DEBUG_ASSERTCRASH((msg->getPlayerID() >= 0) && (msg->getPlayerID() < MAX_SLOTS), ("Command sent by an invalid player ID.")); } } else { - DEBUG_ASSERTCRASH(m_connections[m_packetRouterSlot] != NULL, ("Connection to packet router is NULL")); + DEBUG_ASSERTCRASH(m_connections[m_packetRouterSlot] != nullptr, ("Connection to packet router is null")); } } else { DEBUG_ASSERTCRASH((m_packetRouterSlot >= 0) && (m_packetRouterSlot < MAX_SLOTS), ("I don't know who the packet router is.")); @@ -1113,7 +1113,7 @@ void ConnectionManager::ackCommand(NetCommandRef *ref, UnsignedInt localSlot) { */ void ConnectionManager::sendRemoteCommand(NetCommandRef *msg) { UnsignedByte actualRelay = 0; - if (msg->getCommand() == NULL) { + if (msg->getCommand() == nullptr) { return; } @@ -1121,7 +1121,7 @@ void ConnectionManager::sendRemoteCommand(NetCommandRef *msg) { msg->getCommand()->getID(), GetNetCommandTypeAsString(msg->getCommand()->getNetCommandType()), msg->getCommand()->getPlayerID(), msg->getRelay())); UnsignedByte relay = msg->getRelay(); - if ((relay & (1 << m_localSlot)) && (m_frameData[msg->getCommand()->getPlayerID()] != NULL)) { + if ((relay & (1 << m_localSlot)) && (m_frameData[msg->getCommand()->getPlayerID()] != nullptr)) { if (IsCommandSynchronized(msg->getCommand()->getNetCommandType())) { DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("ConnectionManager::sendRemoteCommand - adding net command of type %s to player %d for frame %d", GetNetCommandTypeAsString(msg->getCommand()->getNetCommandType()), msg->getCommand()->getPlayerID(), msg->getCommand()->getExecutionFrame())); m_frameData[msg->getCommand()->getPlayerID()]->addNetCommandMsg(msg->getCommand()); @@ -1129,7 +1129,7 @@ void ConnectionManager::sendRemoteCommand(NetCommandRef *msg) { } for (Int i = 0; i < MAX_SLOTS; ++i) { - if ((relay & (1 << i)) && ((m_connections[i] != NULL) && (m_connections[i]->isQuitting() == FALSE))) { + if ((relay & (1 << i)) && ((m_connections[i] != nullptr) && (m_connections[i]->isQuitting() == FALSE))) { DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("ConnectionManager::sendRemoteCommand - relaying command %d to player %d", msg->getCommand()->getID(), i)); m_connections[i]->sendNetCommandMsg(msg->getCommand(), 1 << i); actualRelay = actualRelay | (1 << i); @@ -1138,7 +1138,7 @@ void ConnectionManager::sendRemoteCommand(NetCommandRef *msg) { if ((actualRelay != 0) && (CommandRequiresAck(msg->getCommand()) == TRUE)) { NetCommandRef *ref = m_relayedCommands->addMessage(msg->getCommand()); - if (ref != NULL) { + if (ref != nullptr) { ref->setRelay(actualRelay); //DEBUG_LOG(("ConnectionManager::sendRemoteCommand - command %d added to relayed commands with relay %d", msg->getCommand()->getID(), ref->getRelay())); } @@ -1191,7 +1191,7 @@ void ConnectionManager::update(Bool isInGame) { doKeepAlive(); for (Int i = 0; i < NUM_CONNECTIONS; ++i) { - if (m_connections[i] != NULL) { + if (m_connections[i] != nullptr) { /* if (m_connections[i]->isQueueEmpty() == FALSE) { // DEBUG_LOG(("ConnectionManager::update - calling doSend on connection %d", i)); @@ -1204,15 +1204,15 @@ void ConnectionManager::update(Bool isInGame) { { DEBUG_LOG(("ConnectionManager::update - deleting connection for slot %d", i)); deleteInstance(m_connections[i]); - m_connections[i] = NULL; + m_connections[i] = nullptr; } } - if ((m_frameData[i] != NULL) && (m_frameData[i]->getIsQuitting() == TRUE)) { + if ((m_frameData[i] != nullptr) && (m_frameData[i]->getIsQuitting() == TRUE)) { if (m_frameData[i]->getQuitFrame() == TheGameLogic->getFrame()) { DEBUG_LOG(("ConnectionManager::update - deleting frame data for slot %d on quitting frame %d", i, m_frameData[i]->getQuitFrame())); deleteInstance(m_frameData[i]); - m_frameData[i] = NULL; + m_frameData[i] = nullptr; } } } @@ -1362,15 +1362,25 @@ void ConnectionManager::updateRunAhead(Int oldRunAhead, Int frameRate, Bool didS } Real ConnectionManager::getMaximumLatency() { - Real maxLatency = 0.0f; + + Real lat1 = 0.0f; + Real lat2 = 0.0f; for (Int i = 0; i < MAX_SLOTS; ++i) { - if (isPlayerConnected(i) && m_latencyAverages[i] > maxLatency) { - maxLatency = m_latencyAverages[i]; + if (isPlayerConnected(i)) { + if (m_latencyAverages[i] != 0.0f) { + if (m_latencyAverages[i] > lat1) { + lat2 = lat1; + lat1 = m_latencyAverages[i]; + } + else if (m_latencyAverages[i] > lat2) { + lat2 = m_latencyAverages[i]; + } + } } } - return maxLatency; + return (lat1 + lat2) / 2.0f; } void ConnectionManager::getMinimumFps(Int &minFps, Int &minFpsPlayer) { @@ -1378,7 +1388,7 @@ void ConnectionManager::getMinimumFps(Int &minFps, Int &minFpsPlayer) { minFpsPlayer = -1; // DEBUG_LOG_RAW(("ConnectionManager::getMinimumFps -")); for (Int i = 0; i < MAX_SLOTS; ++i) { - if ((m_connections[i] != NULL) || (i == m_localSlot)) { + if ((m_connections[i] != nullptr) || (i == m_localSlot)) { // DEBUG_LOG_RAW((" %d: %d,", i, m_fpsAverages[i])); if (m_fpsAverages[i] != -1) { if ((minFps == -1) || (m_fpsAverages[i] < minFps)) { @@ -1399,8 +1409,8 @@ UnsignedInt ConnectionManager::getMinimumCushion() { * The commands for the given frame are all ready, time to send out our command count for that frame. */ void ConnectionManager::processFrameTick(UnsignedInt frame) { - if ((m_frameData[m_localSlot] == NULL) || (m_frameData[m_localSlot]->getIsQuitting() == TRUE)) { - // if the local frame data stuff is NULL, we must be leaving the game. + if ((m_frameData[m_localSlot] == nullptr) || (m_frameData[m_localSlot]->getIsQuitting() == TRUE)) { + // if the local frame data stuff is null, we must be leaving the game. return; } UnsignedShort commandCount = m_frameData[m_localSlot]->getCommandCount(frame); @@ -1434,7 +1444,7 @@ void ConnectionManager::setLocalAddress(UnsignedInt ip, UnsignedInt port) { * Initialize the transport object */ void ConnectionManager::initTransport() { - DEBUG_ASSERTCRASH((m_transport == NULL), ("m_transport already exists when trying to init it.")); + DEBUG_ASSERTCRASH((m_transport == nullptr), ("m_transport already exists when trying to init it.")); DEBUG_LOG(("ConnectionManager::initTransport - Initializing Transport")); delete m_transport; @@ -1469,7 +1479,7 @@ void ConnectionManager::sendLocalGameMessage(GameMessage *msg, UnsignedInt frame * in the relay field. Commands sent in this way go through the packet router. */ void ConnectionManager::sendLocalCommand(NetCommandMsg *msg, UnsignedByte relay /* = 0xff by default*/) { - if (CommandRequiresDirectSend(msg) || (m_packetRouterSlot < 0) || (m_packetRouterSlot >= MAX_SLOTS) || (m_connections[m_packetRouterSlot] == NULL)) { + if (CommandRequiresDirectSend(msg) || (m_packetRouterSlot < 0) || (m_packetRouterSlot >= MAX_SLOTS) || (m_connections[m_packetRouterSlot] == nullptr)) { sendLocalCommandDirect(msg, relay); return; } @@ -1488,7 +1498,7 @@ void ConnectionManager::sendLocalCommand(NetCommandMsg *msg, UnsignedByte relay // I am the packet router, I need to send this packet to everyone individually. for (Int i = 0; i < MAX_SLOTS; ++i) { // Send it to all open connections. - if (((m_connections[i] != NULL) && (m_connections[i]->isQuitting() == FALSE)) && (relay & (1 << i))) { + if (((m_connections[i] != nullptr) && (m_connections[i]->isQuitting() == FALSE)) && (relay & (1 << i))) { // Set the relay mask to only go to this player so he knows not to relay it to anyone else. UnsignedByte temprelay = 1 << i; m_connections[i]->sendNetCommandMsg(msg, temprelay); // This will create a new copy of netmsg for this connection. @@ -1505,7 +1515,7 @@ void ConnectionManager::sendLocalCommand(NetCommandMsg *msg, UnsignedByte relay if (CommandRequiresAck(msg)) { NetCommandRef *ref = m_pendingCommands->addMessage(msg); //DEBUG_LOG(("ConnectionManager::sendLocalCommand - added command %d to pending commands list.", msg->getID())); - if (ref != NULL) { + if (ref != nullptr) { ref->setRelay(temprelay); } } @@ -1521,7 +1531,7 @@ void ConnectionManager::sendLocalCommand(NetCommandMsg *msg, UnsignedByte relay void ConnectionManager::sendLocalCommandDirect(NetCommandMsg *msg, UnsignedByte relay) { msg->attach(); - if (((relay & (1 << m_localSlot)) != 0) && (m_frameData[m_localSlot] != NULL)) { + if (((relay & (1 << m_localSlot)) != 0) && (m_frameData[m_localSlot] != nullptr)) { if (IsCommandSynchronized(msg->getNetCommandType()) == TRUE) { DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("ConnectionManager::sendLocalCommandDirect - adding net command of type %s to player %d for frame %d", GetNetCommandTypeAsString(msg->getNetCommandType()), msg->getPlayerID(), msg->getExecutionFrame())); m_frameData[m_localSlot]->addNetCommandMsg(msg); @@ -1530,7 +1540,7 @@ void ConnectionManager::sendLocalCommandDirect(NetCommandMsg *msg, UnsignedByte for (Int i = 0; i < MAX_SLOTS; ++i) { if ((relay & (1 << i)) != 0) { - if ((m_connections[i] != NULL) && (m_connections[i]->isQuitting() == FALSE)) { + if ((m_connections[i] != nullptr) && (m_connections[i]->isQuitting() == FALSE)) { UnsignedByte temprelay = 1 << i; m_connections[i]->sendNetCommandMsg(msg, temprelay); DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("ConnectionManager::sendLocalCommandDirect - Sending direct command %d of type %s to player %d", msg->getID(), GetNetCommandTypeAsString(msg->getNetCommandType()), i)); @@ -1552,7 +1562,7 @@ Bool ConnectionManager::allCommandsReady(UnsignedInt frame, Bool justTesting /* // retval = FALSE; // ****for testing purposes only!!!!!!**** Int i = 0; for (; (i < MAX_SLOTS) && retval; ++i) { - if ((m_frameData[i] != NULL) && (m_frameData[i]->getIsQuitting() == FALSE)) { + if ((m_frameData[i] != nullptr) && (m_frameData[i]->getIsQuitting() == FALSE)) { /* if (!(m_frameData[i]->allCommandsReady(frame, (frame != commandsReadyDebugSpewage) && (justTesting == FALSE)))) { if ((frame != commandsReadyDebugSpewage) && (justTesting == FALSE)) { @@ -1578,7 +1588,7 @@ Bool ConnectionManager::allCommandsReady(UnsignedInt frame, Bool justTesting /* if (frameRetVal == FRAMEDATA_RESEND) { // this frame's data is really screwed up, we need to clean it out so it can be resent to us. for (i = 0; i < MAX_SLOTS; ++i) { - if ((m_frameData[i] != NULL) && (i != m_localSlot)) { + if ((m_frameData[i] != nullptr) && (i != m_localSlot)) { m_frameData[i]->resetFrame(frame, FALSE); } } @@ -1614,7 +1624,7 @@ NetCommandList *ConnectionManager::getFrameCommandList(UnsignedInt frame) retlist->init(); for (Int i = 0; i < MAX_SLOTS; ++i) { - if (m_frameData[i] != NULL) { + if (m_frameData[i] != nullptr) { retlist->appendList(m_frameData[i]->getFrameCommandList(frame)); if (frame > FRAMES_TO_KEEP) { m_frameData[i]->resetFrame(frame - FRAMES_TO_KEEP); // After getting the commands for that frame from this @@ -1637,7 +1647,7 @@ void ConnectionManager::setFrameGrouping(time_t frameGrouping) { frameGrouping = frameGrouping / 2; } for (Int i = 0; i < MAX_SLOTS; ++i) { - if (m_connections[i] != NULL) { + if (m_connections[i] != nullptr) { m_connections[i]->setFrameGrouping(frameGrouping); } } @@ -1648,7 +1658,7 @@ void ConnectionManager::determineRouterFallbackPlan() { memset(m_packetRouterFallback, 0, sizeof(m_packetRouterFallback)); Int curnum = 1; for (Int i = 0; i < MAX_SLOTS; ++i) { - if (m_connections[i] != NULL) { + if (m_connections[i] != nullptr) { m_packetRouterFallback[i] = curnum; if (curnum == 1) { m_packetRouterSlot = i; @@ -1674,7 +1684,7 @@ void ConnectionManager::doKeepAlive() { while ((nextIndex <= numSeconds) && (nextIndex < MAX_SLOTS)) { // DEBUG_LOG(("ConnectionManager::doKeepAlive - trying to send keep alive message to player %d", nextIndex)); - if (m_connections[nextIndex] != NULL) { + if (m_connections[nextIndex] != nullptr) { NetKeepAliveCommandMsg *msg = newInstance(NetKeepAliveCommandMsg); msg->setPlayerID(m_localSlot); if (DoesCommandRequireACommandID(msg->getNetCommandType()) == TRUE) { @@ -1714,7 +1724,7 @@ PlayerLeaveCode ConnectionManager::disconnectPlayer(Int slot) { UnicodeString unicodeName; unicodeName = getPlayerName(slot); - if (unicodeName.getLength() > 0 && m_connections[slot]) { + if (!unicodeName.isEmpty() && m_connections[slot]) { TheInGameUI->message("Network:PlayerLeftGame", unicodeName.str()); // People are boneheads. Also play a sound @@ -1722,16 +1732,16 @@ PlayerLeaveCode ConnectionManager::disconnectPlayer(Int slot) { TheAudio->addAudioEvent(&leftGameSound); } - if ((m_frameData[slot] != NULL) && (m_frameData[slot]->getIsQuitting() == FALSE)) { + if ((m_frameData[slot] != nullptr) && (m_frameData[slot]->getIsQuitting() == FALSE)) { DEBUG_LOG(("ConnectionManager::disconnectPlayer - deleting player %d frame data", slot)); deleteInstance(m_frameData[slot]); - m_frameData[slot] = NULL; + m_frameData[slot] = nullptr; } - if (m_connections[slot] != NULL && !m_connections[slot]->isQuitting()) { + if (m_connections[slot] != nullptr && !m_connections[slot]->isQuitting()) { DEBUG_LOG(("ConnectionManager::disconnectPlayer - deleting player %d connection", slot)); deleteInstance(m_connections[slot]); - m_connections[slot] = NULL; + m_connections[slot] = nullptr; } // if (playerID == m_localSlot) { @@ -1771,6 +1781,7 @@ void ConnectionManager::quitGame() { // Need to do the NetDisconnectPlayerCommandMsg creation and sending here. NetDisconnectPlayerCommandMsg *disconnectMsg = newInstance(NetDisconnectPlayerCommandMsg); disconnectMsg->setDisconnectSlot(m_localSlot); + disconnectMsg->setDisconnectFrame(TheGameLogic->getFrame()); disconnectMsg->setPlayerID(m_localSlot); if (DoesCommandRequireACommandID(disconnectMsg->getNetCommandType())) { disconnectMsg->setID(GenerateNextCommandID()); @@ -1818,7 +1829,7 @@ void ConnectionManager::disconnectLocalPlayer() { */ void ConnectionManager::flushConnections() { for (Int i = 0; i < MAX_SLOTS; ++i) { - if (m_connections[i] != NULL) { + if (m_connections[i] != nullptr) { // DEBUG_LOG(("ConnectionManager::flushConnections - flushing connection to player %d", i)); /* if (m_connections[i]->isQueueEmpty()) { @@ -1829,19 +1840,19 @@ void ConnectionManager::flushConnections() { } } - if (m_transport != NULL) { + if (m_transport != nullptr) { m_transport->doSend(); } } void ConnectionManager::resendPendingCommands() { //DEBUG_LOG(("ConnectionManager::resendPendingCommands()")); - if (m_pendingCommands == NULL) { + if (m_pendingCommands == nullptr) { return; } NetCommandRef *ref = m_pendingCommands->getFirstMessage(); - while (ref != NULL) { + while (ref != nullptr) { //DEBUG_LOG(("ConnectionManager::resendPendingCommands - resending command %d", ref->getCommand()->getID())); sendLocalCommand(ref->getCommand(), ref->getRelay()); ref = ref->getNext(); @@ -1856,7 +1867,7 @@ UnicodeString ConnectionManager::getPlayerName(Int playerNum) { UnicodeString retval; if( playerNum == m_localSlot ) { retval = m_localUser->GetName(); - } else if (((m_connections[playerNum] != NULL) && (m_connections[playerNum]->isQuitting() == FALSE))) { + } else if (((m_connections[playerNum] != nullptr) && (m_connections[playerNum]->isQuitting() == FALSE))) { retval = m_connections[playerNum]->getUser()->GetName(); } return retval; @@ -1946,14 +1957,14 @@ void ConnectionManager::parseUserList(const GameInfo *game) m_localPort)); int numUsers = 0; - while ( (userStr=strtok_r(listPtr, ",", &listPos)) != NULL ) + while ( (userStr=strtok_r(listPtr, ",", &listPos)) != nullptr ) { - listPtr = NULL; - char *pos = NULL; + listPtr = nullptr; + char *pos = nullptr; nameStr = strtok_r(userStr, "@", &pos); - addrStr = strtok_r(NULL, "@:", &pos); - portStr = strtok_r(NULL, ": ", &pos); + addrStr = strtok_r(nullptr, "@:", &pos); + portStr = strtok_r(nullptr, ": ", &pos); if (!portStr || numUsers >= MAX_SLOTS) { @@ -1999,7 +2010,7 @@ void ConnectionManager::parseUserList(const GameInfo *game) } free(list); // from the strdup above. - list = NULL; + list = nullptr; */ } @@ -2167,7 +2178,7 @@ void ConnectionManager::sendFile(AsciiString path, UnsignedByte playerMask, Unsi // compress Targas #ifdef COMPRESS_TARGAS - char *compressedBuf = NULL; + char *compressedBuf = nullptr; Int compressedLen = path.endsWith(".tga")?CompressionManager::getMaxCompressedSize(len, CompressionManager::getPreferredCompression()):0; Int compressedSize = 0; if (compressedLen) @@ -2177,7 +2188,7 @@ void ConnectionManager::sendFile(AsciiString path, UnsignedByte playerMask, Unsi if (!compressedSize) { delete[] compressedBuf; - compressedBuf = NULL; + compressedBuf = nullptr; } #endif // COMPRESS_TARGAS @@ -2202,10 +2213,10 @@ void ConnectionManager::sendFile(AsciiString path, UnsignedByte playerMask, Unsi fileMsg->getID(), fileMsg->getRealFilename().str(), playerMask, fileMsg->getPlayerID(), fileMsg->getFileLength())); delete[] buf; - buf = NULL; + buf = nullptr; #ifdef COMPRESS_TARGAS delete[] compressedBuf; - compressedBuf = NULL; + compressedBuf = nullptr; #endif // COMPRESS_TARGAS DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("Sending file: '%s', len %d, to %X", path.str(), len, playerMask)); @@ -2235,7 +2246,7 @@ Int ConnectionManager::getFileTransferProgress(Int playerID, AsciiString path) void ConnectionManager::voteForPlayerDisconnect(Int slot) { - if (m_disconnectManager != NULL) { + if (m_disconnectManager != nullptr) { m_disconnectManager->voteForPlayerDisconnect(slot, this); } } @@ -2269,12 +2280,11 @@ void ConnectionManager::updateLoadProgress( Int progress ) void ConnectionManager::loadProgressComplete() { - NetCommandMsg *msg = newInstance(NetCommandMsg); + NetLoadCompleteCommandMsg *msg = newInstance(NetLoadCompleteCommandMsg); msg->setPlayerID( m_localSlot ); if (DoesCommandRequireACommandID(msg->getNetCommandType()) == TRUE) { msg->setID(GenerateNextCommandID()); } - msg->setNetCommandType(NETCOMMANDTYPE_LOADCOMPLETE); processLoadComplete(msg); sendLocalCommand(msg, 0xff ^ (1 << m_localSlot)); @@ -2283,9 +2293,8 @@ void ConnectionManager::loadProgressComplete() void ConnectionManager::sendTimeOutGameStart() { - NetCommandMsg *msg = newInstance(NetCommandMsg); + NetTimeOutGameStartCommandMsg *msg = newInstance(NetTimeOutGameStartCommandMsg); msg->setPlayerID( m_localSlot ); - msg->setNetCommandType(NETCOMMANDTYPE_TIMEOUTSTART); if (DoesCommandRequireACommandID(msg->getNetCommandType()) == TRUE) { msg->setID(GenerateNextCommandID()); } @@ -2321,7 +2330,7 @@ Int ConnectionManager::getSlotAverageFPS(Int slot) { void ConnectionManager::debugPrintConnectionCommands() { DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("ConnectionManager::debugPrintConnectionCommands - begin commands")); for (Int i = 0; i < MAX_SLOTS; ++i) { - if (m_connections[i] != NULL) { + if (m_connections[i] != nullptr) { DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("ConnectionManager::debugPrintConnectionCommands - commands for connection %d", i)); m_connections[i]->debugPrintCommands(); } @@ -2390,11 +2399,11 @@ void ConnectionManager::sendSingleFrameToPlayer(UnsignedInt playerID, UnsignedIn DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("ConnectionManager::sendFrameDataToPlayer - sending data for frame %d", frame)); for (Int i = 0; i < MAX_SLOTS; ++i) { - if ((m_frameData[i] != NULL) && (i != playerID)) { // no need to send his own commands to him. + if ((m_frameData[i] != nullptr) && (i != playerID)) { // no need to send his own commands to him. NetCommandList *list = m_frameData[i]->getFrameCommandList(frame); - if (list != NULL) { + if (list != nullptr) { NetCommandRef *ref = list->getFirstMessage(); - while (ref != NULL) { + while (ref != nullptr) { DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("ConnectionManager::sendFrameDataToPlayer - sending command %d from player %d to player %d using relay 0x%x", ref->getCommand()->getID(), i, playerID, relay)); sendLocalCommandDirect(ref->getCommand(), relay); ref = ref->getNext(); diff --git a/Core/GameEngine/Source/GameNetwork/DisconnectManager.cpp b/Core/GameEngine/Source/GameNetwork/DisconnectManager.cpp index 94beda05da6..6aec6e5868d 100644 --- a/Core/GameEngine/Source/GameNetwork/DisconnectManager.cpp +++ b/Core/GameEngine/Source/GameNetwork/DisconnectManager.cpp @@ -90,7 +90,7 @@ void DisconnectManager::init() { m_pingFrame = 0; m_pingsSent = 0; - m_pingsRecieved = 0; + m_pingsReceived = 0; } void DisconnectManager::update(ConnectionManager *conMgr) { @@ -124,7 +124,7 @@ void DisconnectManager::update(ConnectionManager *conMgr) { { m_pingFrame = TheGameLogic->getFrame(); m_pingsSent = 0; - m_pingsRecieved = 0; + m_pingsReceived = 0; // Send the pings if (ThePinger) @@ -173,7 +173,7 @@ void DisconnectManager::update(ConnectionManager *conMgr) { resp.avgPing, resp.hostname.c_str(), resp.repetitions)); if (resp.avgPing < 2000) { - m_pingsRecieved += resp.repetitions; + m_pingsReceived += resp.repetitions; } } } @@ -191,9 +191,9 @@ Int DisconnectManager::getPingsSent() return m_pingsSent; } -Int DisconnectManager::getPingsRecieved() +Int DisconnectManager::getPingsReceived() { - return m_pingsRecieved; + return m_pingsReceived; } diff --git a/Core/GameEngine/Source/GameNetwork/FileTransfer.cpp b/Core/GameEngine/Source/GameNetwork/FileTransfer.cpp index c64f3118adb..5d9cc7dfe64 100644 --- a/Core/GameEngine/Source/GameNetwork/FileTransfer.cpp +++ b/Core/GameEngine/Source/GameNetwork/FileTransfer.cpp @@ -276,7 +276,7 @@ Bool DoAnyMapTransfers(GameInfo *game) if (ok) ok = doFileTransfer(game->getMap(), ls, mask); delete ls; - ls = NULL; + ls = nullptr; if (!ok) TheShell->showShell(); return ok; diff --git a/Core/GameEngine/Source/GameNetwork/FirewallHelper.cpp b/Core/GameEngine/Source/GameNetwork/FirewallHelper.cpp index 320b672ee9f..e6619efd0c8 100644 --- a/Core/GameEngine/Source/GameNetwork/FirewallHelper.cpp +++ b/Core/GameEngine/Source/GameNetwork/FirewallHelper.cpp @@ -57,7 +57,7 @@ #include "GameNetwork/GameSpy/GSConfig.h" -FirewallHelperClass *TheFirewallHelper = NULL; +FirewallHelperClass *TheFirewallHelper = nullptr; FirewallHelperClass * createFirewallHelper() { @@ -360,8 +360,8 @@ Bool FirewallHelperClass::sendToManglerFromPort(UnsignedInt address, UnsignedSho // DEBUG_LOG(("PacketID = %u", packetID)); // DEBUG_LOG(("OriginalPortNumber = %u", port)); - if (spareSocket == NULL) { - DEBUG_ASSERTCRASH(spareSocket != NULL, ("Could not find spare socket for send.")); + if (spareSocket == nullptr) { + DEBUG_ASSERTCRASH(spareSocket != nullptr, ("Could not find spare socket for send.")); DEBUG_LOG(("FirewallHelperClass::sendToManglerFromPort - failed to find the spare socket for port %d", port)); return FALSE; } @@ -382,7 +382,7 @@ SpareSocketStruct * FirewallHelperClass::findSpareSocketByPort(UnsignedShort por } DEBUG_LOG(("FirewallHelperClass::findSpareSocketByPort - didn't find it")); - return NULL; + return nullptr; } ManglerMessage * FirewallHelperClass::findEmptyMessage() { @@ -391,7 +391,7 @@ ManglerMessage * FirewallHelperClass::findEmptyMessage() { return &(m_messages[i]); } } - return NULL; + return nullptr; } void FirewallHelperClass::byteAdjust(ManglerData *data) { @@ -422,17 +422,17 @@ void FirewallHelperClass::byteAdjust(ManglerData *data) { *=============================================================================================*/ UnsignedShort FirewallHelperClass::getManglerResponse(UnsignedShort packetID, Int time) { - ManglerMessage *msg = NULL; + ManglerMessage *msg = nullptr; -// SpareSocketStruct *spareSocket = NULL; +// SpareSocketStruct *spareSocket = nullptr; sockaddr_in addr; Int i = 0; for (; i < MAX_SPARE_SOCKETS; ++i) { - if (m_spareSockets[i].udp != NULL) { + if (m_spareSockets[i].udp != nullptr) { ManglerMessage *message = findEmptyMessage(); - if (message == NULL) { + if (message == nullptr) { break; } Int retval = m_spareSockets[i].udp->Read((unsigned char *)message, sizeof(ManglerData), &addr); @@ -462,7 +462,7 @@ UnsignedShort FirewallHelperClass::getManglerResponse(UnsignedShort packetID, In } // See if we have already received it and saved it. - if (msg == NULL) { + if (msg == nullptr) { for (i = 0; i < MAX_SPARE_SOCKETS; ++i) { if ((m_messages[i].length != 0) && (m_messages[i].data.PacketID == packetID)) { msg = &(m_messages[i]); @@ -471,7 +471,7 @@ UnsignedShort FirewallHelperClass::getManglerResponse(UnsignedShort packetID, In } } - if (msg == NULL) { + if (msg == nullptr) { return 0; } @@ -508,7 +508,7 @@ void FirewallHelperClass::writeFirewallBehavior(void) numstr = num; (pref)["FirewallBehavior"] = numstr; - TheWritableGlobalData->m_firewallPortAllocationDelta = TheFirewallHelper->getSourcePortAllocationDelta(); + TheWritableGlobalData->m_firewallPortAllocationDelta = getSourcePortAllocationDelta(); num[0] = 0; itoa(TheGlobalData->m_firewallPortAllocationDelta, num, 10); numstr = num; @@ -1027,7 +1027,7 @@ Bool FirewallHelperClass::detectionTest3WaitForResponsesUpdate() { return FALSE; } - DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForRepsonsesUpdate - starting 4th test")); + DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForResponsesUpdate - starting 4th test")); /* ** Fourth test. ** @@ -1037,7 +1037,7 @@ Bool FirewallHelperClass::detectionTest3WaitForResponsesUpdate() { if ((m_behavior & FIREWALL_TYPE_SIMPLE_PORT_ALLOCATION) != 0) { - DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForRepsonsesUpdate - simple port allocation, Testing to see if the NAT mangles differently per destination port at the same IP")); + DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForResponsesUpdate - simple port allocation, Testing to see if the NAT mangles differently per destination port at the same IP")); /* ** We need 2 source ports for this. @@ -1045,7 +1045,7 @@ Bool FirewallHelperClass::detectionTest3WaitForResponsesUpdate() { m_sparePorts[0] = getNextTemporarySourcePort(0); if (!openSpareSocket(m_sparePorts[0])) { m_currentState = DETECTIONSTATE_DONE; - DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForRepsonsesUpdate - Failed to open first spare port, bailing")); + DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForResponsesUpdate - Failed to open first spare port, bailing")); return TRUE; } @@ -1053,7 +1053,7 @@ Bool FirewallHelperClass::detectionTest3WaitForResponsesUpdate() { if (!openSpareSocket(m_sparePorts[1])) { closeSpareSocket(m_sparePorts[0]); m_currentState = DETECTIONSTATE_DONE; - DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForRepsonsesUpdate - Failed to open second spare port, bailing")); + DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForResponsesUpdate - Failed to open second spare port, bailing")); return TRUE; } @@ -1076,10 +1076,10 @@ Bool FirewallHelperClass::detectionTest3WaitForResponsesUpdate() { /* ** NAT32 uses different mangled source ports for different destination ports. */ - DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForRepsonsesUpdate - relative port allocation, NAT32 right?")); + DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForResponsesUpdate - relative port allocation, NAT32 right?")); UnsignedInt addbehavior = 0; addbehavior = (UnsignedInt)FIREWALL_TYPE_DESTINATION_PORT_DELTA; - DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForRepsonsesUpdate - adding DESTINATION PORT DELTA to behavior")); + DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForResponsesUpdate - adding DESTINATION PORT DELTA to behavior")); addbehavior |= (UnsignedInt)m_behavior; m_behavior = (FirewallBehaviorType) addbehavior; } @@ -1087,7 +1087,7 @@ Bool FirewallHelperClass::detectionTest3WaitForResponsesUpdate() { DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForResponsesUpdate - We don't have smart mangling, skipping test 4, entering test 5")); } - DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForRepsonsesUpdate - entering test 5")); + DEBUG_LOG(("FirewallHelperClass::detectionTest3WaitForResponsesUpdate - entering test 5")); m_currentState = DETECTIONSTATE_TEST5; return FALSE; @@ -1522,7 +1522,7 @@ Bool FirewallHelperClass::openSpareSocket(UnsignedShort port) { } m_spareSockets[i].udp = NEW UDP(); - if (m_spareSockets[i].udp == NULL) { + if (m_spareSockets[i].udp == nullptr) { DEBUG_LOG(("FirewallHelperClass::openSpareSocket - failed to create UDP object")); return FALSE; } @@ -1544,7 +1544,7 @@ void FirewallHelperClass::closeSpareSocket(UnsignedShort port) { for (Int i = 0; i < MAX_SPARE_SOCKETS; ++i) { if (m_spareSockets[i].port == port) { delete m_spareSockets[i].udp; - m_spareSockets[i].udp = NULL; + m_spareSockets[i].udp = nullptr; m_spareSockets[i].port = 0; break; } @@ -1557,7 +1557,7 @@ void FirewallHelperClass::closeSpareSocket(UnsignedShort port) { void FirewallHelperClass::closeAllSpareSockets() { for (Int i = 0; i < MAX_SPARE_SOCKETS; ++i) { delete (m_spareSockets[i].udp); - m_spareSockets[i].udp = NULL; + m_spareSockets[i].udp = nullptr; m_spareSockets[i].port = 0; } } diff --git a/Core/GameEngine/Source/GameNetwork/FrameData.cpp b/Core/GameEngine/Source/GameNetwork/FrameData.cpp index da5fef6e767..88b980f33f5 100644 --- a/Core/GameEngine/Source/GameNetwork/FrameData.cpp +++ b/Core/GameEngine/Source/GameNetwork/FrameData.cpp @@ -34,7 +34,7 @@ FrameData::FrameData() { m_frame = 0; - m_commandList = NULL; + m_commandList = nullptr; m_commandCount = 0; m_frameCommandCount = -1; m_lastFailedCC = 0; @@ -47,7 +47,7 @@ FrameData::FrameData() FrameData::~FrameData() { deleteInstance(m_commandList); - m_commandList = NULL; + m_commandList = nullptr; } /** @@ -56,7 +56,7 @@ FrameData::~FrameData() void FrameData::init() { m_frame = 0; - if (m_commandList == NULL) { + if (m_commandList == nullptr) { m_commandList = newInstance(NetCommandList); m_commandList->init(); } @@ -117,7 +117,7 @@ FrameDataReturnType FrameData::allCommandsReady(Bool debugSpewage) { if (m_commandCount > m_frameCommandCount) { DEBUG_LOG(("FrameData::allCommandsReady - There are more commands than there should be (%d, should be %d). Commands in command list are...", m_commandCount, m_frameCommandCount)); NetCommandRef *ref = m_commandList->getFirstMessage(); - while (ref != NULL) { + while (ref != nullptr) { DEBUG_LOG(("%s, frame = %d, id = %d", GetNetCommandTypeAsString(ref->getCommand()->getNetCommandType()), ref->getCommand()->getExecutionFrame(), ref->getCommand()->getID())); ref = ref->getNext(); } @@ -157,12 +157,12 @@ UnsignedInt FrameData::getCommandCount() { */ void FrameData::addCommand(NetCommandMsg *msg) { // need to add the message in order of command ID - if (m_commandList == NULL) { + if (m_commandList == nullptr) { init(); } // We don't need to worry about setting the relay since its not getting sent anywhere. - if (m_commandList->findMessage(msg) != NULL) { + if (m_commandList->findMessage(msg) != nullptr) { // We don't want to add the same command twice. return; } @@ -191,7 +191,7 @@ void FrameData::zeroFrame() { * destroy all the commands in this frame. */ void FrameData::destroyGameMessages() { - if (m_commandList == NULL) { + if (m_commandList == nullptr) { return; } diff --git a/Core/GameEngine/Source/GameNetwork/FrameDataManager.cpp b/Core/GameEngine/Source/GameNetwork/FrameDataManager.cpp index 0bc84f74bec..1dfc3349306 100644 --- a/Core/GameEngine/Source/GameNetwork/FrameDataManager.cpp +++ b/Core/GameEngine/Source/GameNetwork/FrameDataManager.cpp @@ -48,7 +48,7 @@ FrameDataManager::~FrameDataManager() { m_frameData[i].reset(); } delete[] m_frameData; - m_frameData = NULL; + m_frameData = nullptr; } /** diff --git a/Core/GameEngine/Source/GameNetwork/FrameMetrics.cpp b/Core/GameEngine/Source/GameNetwork/FrameMetrics.cpp index a9a9aca66e5..c571f0a4955 100644 --- a/Core/GameEngine/Source/GameNetwork/FrameMetrics.cpp +++ b/Core/GameEngine/Source/GameNetwork/FrameMetrics.cpp @@ -26,6 +26,8 @@ #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine +#include + #include "GameNetwork/FrameMetrics.h" #include "GameClient/Display.h" #include "GameNetwork/networkutil.h" @@ -48,13 +50,13 @@ FrameMetrics::FrameMetrics() FrameMetrics::~FrameMetrics() { delete m_fpsList; - m_fpsList = NULL; + m_fpsList = nullptr; delete m_latencyList; - m_latencyList = NULL; + m_latencyList = nullptr; delete[] m_pendingLatencies; - m_pendingLatencies = NULL; + m_pendingLatencies = nullptr; } void FrameMetrics::init() { @@ -105,9 +107,9 @@ void FrameMetrics::processLatencyResponse(UnsignedInt frame) { time_t timeDiff = curTime - m_pendingLatencies[pendingIndex]; Int latencyListIndex = frame % TheGlobalData->m_networkLatencyHistoryLength; - m_averageLatency -= m_latencyList[latencyListIndex] / TheGlobalData->m_networkLatencyHistoryLength; m_latencyList[latencyListIndex] = (Real)timeDiff / (Real)1000; // convert to seconds from milliseconds. - m_averageLatency += m_latencyList[latencyListIndex] / TheGlobalData->m_networkLatencyHistoryLength; + const Real latencySum = std::accumulate(m_latencyList, m_latencyList + TheGlobalData->m_networkLatencyHistoryLength, 0.0f); + m_averageLatency = latencySum / (Real)TheGlobalData->m_networkLatencyHistoryLength; if (frame % 16 == 0) { // DEBUG_LOG(("ConnectionManager::processFrameInfoAck - average latency = %f", m_averageLatency)); diff --git a/Core/GameEngine/Source/GameNetwork/GameInfo.cpp b/Core/GameEngine/Source/GameNetwork/GameInfo.cpp index 8551069daec..0b5370f0947 100644 --- a/Core/GameEngine/Source/GameNetwork/GameInfo.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameInfo.cpp @@ -47,7 +47,7 @@ -GameInfo *TheGameInfo = NULL; +GameInfo *TheGameInfo = nullptr; // GameSlot ---------------------------------------- @@ -285,7 +285,7 @@ GameInfo::GameInfo() { for (int i=0; i= MAX_SLOTS) return; - DEBUG_ASSERTCRASH( m_slot[slotNum], ("NULL slot pointer")); + DEBUG_ASSERTCRASH( m_slot[slotNum], ("null slot pointer")); if (!m_slot[slotNum]) return; @@ -443,9 +443,9 @@ GameSlot* GameInfo::getSlot( Int slotNum ) { DEBUG_ASSERTCRASH( slotNum >= 0 && slotNum < MAX_SLOTS, ("GameInfo::getSlot - Invalid slot number")); if (slotNum < 0 || slotNum >= MAX_SLOTS) - return NULL; + return nullptr; - DEBUG_ASSERTCRASH( m_slot[slotNum], ("NULL slot pointer") ); + DEBUG_ASSERTCRASH( m_slot[slotNum], ("null slot pointer") ); return m_slot[slotNum]; } @@ -453,9 +453,9 @@ const GameSlot* GameInfo::getConstSlot( Int slotNum ) const { DEBUG_ASSERTCRASH( slotNum >= 0 && slotNum < MAX_SLOTS, ("GameInfo::getSlot - Invalid slot number")); if (slotNum < 0 || slotNum >= MAX_SLOTS) - return NULL; + return nullptr; - DEBUG_ASSERTCRASH( m_slot[slotNum], ("NULL slot pointer") ); + DEBUG_ASSERTCRASH( m_slot[slotNum], ("null slot pointer") ); return m_slot[slotNum]; } @@ -468,7 +468,7 @@ Int GameInfo::getLocalSlotNum( void ) const for (Int i=0; iisPlayer(m_localIP)) @@ -521,11 +521,11 @@ void GameInfo::setMap( AsciiString mapName ) { m_mapMask |= 2; fp->close(); - fp = NULL; + fp = nullptr; } AsciiString newMapName; - if (mapName.getLength() > 0) + if (!mapName.isEmpty()) { AsciiString token; mapName.nextToken(&token, "\\/"); @@ -534,9 +534,9 @@ void GameInfo::setMap( AsciiString mapName ) // directory name, we can do this since the filename // is just the directory name with the file extention // added onto it. - while (mapName.find('\\') != NULL) + while (mapName.find('\\') != nullptr) { - if (newMapName.getLength() > 0) + if (!newMapName.isEmpty()) { newMapName.concat('/'); } @@ -551,7 +551,7 @@ void GameInfo::setMap( AsciiString mapName ) { m_mapMask |= 4; fp->close(); - fp = NULL; + fp = nullptr; } path = GetStrFileFromMap(m_mapName); @@ -561,7 +561,7 @@ void GameInfo::setMap( AsciiString mapName ) { m_mapMask |= 8; fp->close(); - fp = NULL; + fp = nullptr; } path = GetSoloINIFromMap(m_mapName); @@ -571,7 +571,7 @@ void GameInfo::setMap( AsciiString mapName ) { m_mapMask |= 16; fp->close(); - fp = NULL; + fp = nullptr; } path = GetAssetUsageFromMap(m_mapName); @@ -581,7 +581,7 @@ void GameInfo::setMap( AsciiString mapName ) { m_mapMask |= 32; fp->close(); - fp = NULL; + fp = nullptr; } path = GetReadmeFromMap(m_mapName); @@ -591,7 +591,7 @@ void GameInfo::setMap( AsciiString mapName ) { m_mapMask |= 64; fp->close(); - fp = NULL; + fp = nullptr; } } else @@ -737,11 +737,11 @@ void GameInfo::resetAccepted( void ) void GameInfo::resetStartSpots() { - GameSlot *slot = NULL; + GameSlot *slot = nullptr; for (Int i = 0; i < MAX_SLOTS; ++i) { slot = getSlot(i); - if (slot != NULL) + if (slot != nullptr) { slot->setStartPos(-1); } @@ -754,7 +754,7 @@ void GameInfo::resetStartSpots() void GameInfo::adjustSlotsForMap() { const MapMetaData *md = TheMapCache->findMap(m_mapName); - if (md != NULL) + if (md != nullptr) { // get the number of players allowed from the map. Int numPlayers = md->m_numPlayers; @@ -896,7 +896,7 @@ AsciiString GameInfoToAsciiString( const GameInfo *game ) AsciiString mapName = game->getMap(); mapName = TheGameState->realMapPathToPortableMapPath(mapName); AsciiString newMapName; - if (mapName.getLength() > 0) + if (!mapName.isEmpty()) { AsciiString token; mapName.nextToken(&token, "\\/"); @@ -905,9 +905,9 @@ AsciiString GameInfoToAsciiString( const GameInfo *game ) // directory name, we can do this since the filename // is just the directory name with the file extention // added onto it. - while (mapName.find('\\') != NULL) + while (mapName.find('\\') != nullptr) { - if (newMapName.getLength() > 0) + if (!newMapName.isEmpty()) { newMapName.concat('/'); } @@ -997,7 +997,7 @@ static Int grabHexInt(const char *s) char tmp[5] = "0xff"; tmp[2] = s[0]; tmp[3] = s[1]; - Int b = strtol(tmp, NULL, 16); + Int b = strtol(tmp, nullptr, 16); return b; } Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) @@ -1033,15 +1033,15 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) DEBUG_LOG(("ParseAsciiStringToGameInfo - parsing [%s]", options.str())); - while ( (keyValPair = strtok_r(bufPtr, ";", &strPos)) != NULL ) + while ( (keyValPair = strtok_r(bufPtr, ";", &strPos)) != nullptr ) { - bufPtr = NULL; // strtok within the same string + bufPtr = nullptr; // strtok within the same string AsciiString key, val; - char *pos = NULL; + char *pos = nullptr; char *keyPtr, *valPtr; keyPtr = (strtok_r(keyValPair, "=", &pos)); - valPtr = (strtok_r(NULL, "\n", &pos)); + valPtr = (strtok_r(nullptr, "\n", &pos)); if (keyPtr) key = keyPtr; if (valPtr) @@ -1073,7 +1073,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) AsciiString token; tempstr = val.str()+2; tempstr.nextToken(&token, "\\/"); - while (tempstr.getLength() > 0) + while (!tempstr.isEmpty()) { mapName.concat(token); mapName.concat('\\'); @@ -1127,7 +1127,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) } else if (key.compare("SC") == 0 ) { - UnsignedInt startingCashAmount = strtoul( val.str(), NULL, 10 ); + UnsignedInt startingCashAmount = strtoul( val.str(), nullptr, 10 ); startingCash.init(); startingCash.deposit( startingCashAmount, FALSE, FALSE ); sawStartingCash = TRUE; @@ -1142,7 +1142,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) sawSlotlist = true; /// @TODO: Need to read in all the slot info... big mess right now. char *rawSlotBuf = strdup(val.str()); - char *freeMe = NULL; + char *freeMe = nullptr; AsciiString rawSlot; // Bool slotsOk = true; //flag that lets us know whether or not the slot list is good. @@ -1152,13 +1152,13 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) rawSlot = strtok_r(rawSlotBuf,":",&pos); if( rawSlotBuf ) freeMe = rawSlotBuf; - rawSlotBuf = NULL; + rawSlotBuf = nullptr; switch (*rawSlot.str()) { case 'H': { // DEBUG_LOG(("ParseAsciiStringToGameInfo - Human player")); - char *slotPos = NULL; + char *slotPos = nullptr; //Parse out the Name AsciiString slotValue(strtok_r((char *)rawSlot.str(),",",&slotPos)); if(slotValue.isEmpty()) @@ -1173,7 +1173,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) //DEBUG_LOG(("ParseAsciiStringToGameInfo - name is %s", slotValue.str()+1)); //Parse out the IP - slotValue = strtok_r(NULL,",",&slotPos); + slotValue = strtok_r(nullptr,",",&slotPos); if(slotValue.isEmpty()) { optionsOk = false; @@ -1188,7 +1188,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) newSlot[i].setState(SLOT_PLAYER, name, playerIP); // parse out the port - slotValue = strtok_r(NULL, ",", &slotPos); + slotValue = strtok_r(nullptr, ",", &slotPos); if (slotValue.isEmpty()) { optionsOk = false; @@ -1201,7 +1201,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) DEBUG_LOG(("ParseAsciiStringToGameInfo - port is %d", playerPort)); //Read if it's accepted or not - slotValue = strtok_r(NULL,",",&slotPos); + slotValue = strtok_r(nullptr,",",&slotPos); if(slotValue.getLength() != 2) { optionsOk = false; @@ -1226,7 +1226,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) } //Read color index - slotValue = strtok_r(NULL,",",&slotPos); + slotValue = strtok_r(nullptr,",",&slotPos); if(slotValue.isEmpty()) { optionsOk = false; @@ -1244,7 +1244,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) //DEBUG_LOG(("ParseAsciiStringToGameInfo - player color set to %d", color)); //Read playerTemplate index - slotValue = strtok_r(NULL,",",&slotPos); + slotValue = strtok_r(nullptr,",",&slotPos); if(slotValue.isEmpty()) { optionsOk = false; @@ -1262,7 +1262,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) //DEBUG_LOG(("ParseAsciiStringToGameInfo - player template is %d", playerTemplate)); //Read start position index - slotValue = strtok_r(NULL,",",&slotPos); + slotValue = strtok_r(nullptr,",",&slotPos); if(slotValue.isEmpty()) { optionsOk = false; @@ -1280,7 +1280,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) //DEBUG_LOG(("ParseAsciiStringToGameInfo - player start position is %d", startPos)); //Read team index - slotValue = strtok_r(NULL,",",&slotPos); + slotValue = strtok_r(nullptr,",",&slotPos); if(slotValue.isEmpty()) { optionsOk = false; @@ -1298,7 +1298,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) //DEBUG_LOG(("ParseAsciiStringToGameInfo - team number is %d", team)); // Read the NAT behavior - slotValue = strtok_r(NULL, ",",&slotPos); + slotValue = strtok_r(nullptr, ",",&slotPos); if (slotValue.isEmpty()) { optionsOk = false; @@ -1319,7 +1319,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) case 'C': { DEBUG_LOG(("ParseAsciiStringToGameInfo - AI player")); - char *slotPos = NULL; + char *slotPos = nullptr; //Parse out the Name AsciiString slotValue(strtok_r((char *)rawSlot.str(),",",&slotPos)); if(slotValue.isEmpty()) @@ -1358,7 +1358,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) } //Read color index - slotValue = strtok_r(NULL,",",&slotPos); + slotValue = strtok_r(nullptr,",",&slotPos); if(slotValue.isEmpty()) { optionsOk = false; @@ -1376,7 +1376,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) //DEBUG_LOG(("ParseAsciiStringToGameInfo - player color set to %d", color)); //Read playerTemplate index - slotValue = strtok_r(NULL,",",&slotPos); + slotValue = strtok_r(nullptr,",",&slotPos); if(slotValue.isEmpty()) { optionsOk = false; @@ -1394,7 +1394,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) //DEBUG_LOG(("ParseAsciiStringToGameInfo - player template is %d", playerTemplate)); //Read start pos - slotValue = strtok_r(NULL,",",&slotPos); + slotValue = strtok_r(nullptr,",",&slotPos); if(slotValue.isEmpty()) { optionsOk = false; @@ -1424,7 +1424,7 @@ Bool ParseAsciiStringToGameInfo(GameInfo *game, AsciiString options) //DEBUG_LOG(("ParseAsciiStringToGameInfo - start spot is %d", startPos)); //Read team index - slotValue = strtok_r(NULL,",",&slotPos); + slotValue = strtok_r(nullptr,",",&slotPos); if(slotValue.isEmpty()) { optionsOk = false; diff --git a/Core/GameEngine/Source/GameNetwork/GameMessageParser.cpp b/Core/GameEngine/Source/GameNetwork/GameMessageParser.cpp index 9b289c450e5..3c7d4092425 100644 --- a/Core/GameEngine/Source/GameNetwork/GameMessageParser.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameMessageParser.cpp @@ -30,14 +30,14 @@ //---------------------------------------------------------------------------- GameMessageParser::GameMessageParser() { - m_first = NULL; + m_first = nullptr; m_argTypeCount = 0; } //---------------------------------------------------------------------------- GameMessageParser::GameMessageParser(GameMessage *msg) { - m_first = NULL; + m_first = nullptr; m_argTypeCount = 0; UnsignedByte argCount = msg->getArgumentCount(); @@ -65,8 +65,8 @@ GameMessageParser::GameMessageParser(GameMessage *msg) //---------------------------------------------------------------------------- GameMessageParser::~GameMessageParser() { - GameMessageParserArgumentType *temp = NULL; - while (m_first != NULL) { + GameMessageParserArgumentType *temp = nullptr; + while (m_first != nullptr) { temp = m_first->getNext(); deleteInstance(m_first); m_first = temp; @@ -76,7 +76,7 @@ GameMessageParser::~GameMessageParser() //---------------------------------------------------------------------------- void GameMessageParser::addArgType(GameMessageArgumentDataType type, Int argCount) { - if (m_first == NULL) { + if (m_first == nullptr) { m_first = newInstance(GameMessageParserArgumentType)(type, argCount); m_last = m_first; return; @@ -89,7 +89,7 @@ void GameMessageParser::addArgType(GameMessageArgumentDataType type, Int argCoun //---------------------------------------------------------------------------- GameMessageParserArgumentType::GameMessageParserArgumentType(GameMessageArgumentDataType type, Int argCount) { - m_next = NULL; + m_next = nullptr; m_type = type; m_argCount = argCount; } diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp index e3089d6fb6e..c9928461183 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Chat.cpp @@ -42,35 +42,35 @@ static const FieldParse GameSpyColorFieldParse[] = { - { "Default", INI::parseColorInt, NULL, OFFSET(GSCOLOR_DEFAULT) }, - { "CurrentRoom", INI::parseColorInt, NULL, OFFSET(GSCOLOR_CURRENTROOM) }, - { "ChatRoom", INI::parseColorInt, NULL, OFFSET(GSCOLOR_ROOM) }, - { "Game", INI::parseColorInt, NULL, OFFSET(GSCOLOR_GAME) }, - { "GameFull", INI::parseColorInt, NULL, OFFSET(GSCOLOR_GAME_FULL) }, - { "GameCRCMismatch", INI::parseColorInt, NULL, OFFSET(GSCOLOR_GAME_CRCMISMATCH) }, - { "PlayerNormal", INI::parseColorInt, NULL, OFFSET(GSCOLOR_PLAYER_NORMAL) }, - { "PlayerOwner", INI::parseColorInt, NULL, OFFSET(GSCOLOR_PLAYER_OWNER) }, - { "PlayerBuddy", INI::parseColorInt, NULL, OFFSET(GSCOLOR_PLAYER_BUDDY) }, - { "PlayerSelf", INI::parseColorInt, NULL, OFFSET(GSCOLOR_PLAYER_SELF) }, - { "PlayerIgnored", INI::parseColorInt, NULL, OFFSET(GSCOLOR_PLAYER_IGNORED) }, - { "ChatNormal", INI::parseColorInt, NULL, OFFSET(GSCOLOR_CHAT_NORMAL) }, - { "ChatEmote", INI::parseColorInt, NULL, OFFSET(GSCOLOR_CHAT_EMOTE) }, - { "ChatOwner", INI::parseColorInt, NULL, OFFSET(GSCOLOR_CHAT_OWNER) }, - { "ChatOwnerEmote", INI::parseColorInt, NULL, OFFSET(GSCOLOR_CHAT_OWNER_EMOTE) }, - { "ChatPriv", INI::parseColorInt, NULL, OFFSET(GSCOLOR_CHAT_PRIVATE) }, - { "ChatPrivEmote", INI::parseColorInt, NULL, OFFSET(GSCOLOR_CHAT_PRIVATE_EMOTE) }, - { "ChatPrivOwner", INI::parseColorInt, NULL, OFFSET(GSCOLOR_CHAT_PRIVATE_OWNER) }, - { "ChatPrivOwnerEmote", INI::parseColorInt, NULL, OFFSET(GSCOLOR_CHAT_PRIVATE_OWNER_EMOTE) }, - { "ChatBuddy", INI::parseColorInt, NULL, OFFSET(GSCOLOR_CHAT_BUDDY) }, - { "ChatSelf", INI::parseColorInt, NULL, OFFSET(GSCOLOR_CHAT_SELF) }, - { "AcceptTrue", INI::parseColorInt, NULL, OFFSET(GSCOLOR_ACCEPT_TRUE) }, - { "AcceptFalse", INI::parseColorInt, NULL, OFFSET(GSCOLOR_ACCEPT_FALSE) }, - { "MapSelected", INI::parseColorInt, NULL, OFFSET(GSCOLOR_MAP_SELECTED) }, - { "MapUnselected", INI::parseColorInt, NULL, OFFSET(GSCOLOR_MAP_UNSELECTED) }, - { "MOTD", INI::parseColorInt, NULL, OFFSET(GSCOLOR_MOTD) }, - { "MOTDHeading", INI::parseColorInt, NULL, OFFSET(GSCOLOR_MOTD_HEADING) }, - - { NULL, NULL, NULL, 0 } + { "Default", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_DEFAULT) }, + { "CurrentRoom", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_CURRENTROOM) }, + { "ChatRoom", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_ROOM) }, + { "Game", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_GAME) }, + { "GameFull", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_GAME_FULL) }, + { "GameCRCMismatch", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_GAME_CRCMISMATCH) }, + { "PlayerNormal", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_PLAYER_NORMAL) }, + { "PlayerOwner", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_PLAYER_OWNER) }, + { "PlayerBuddy", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_PLAYER_BUDDY) }, + { "PlayerSelf", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_PLAYER_SELF) }, + { "PlayerIgnored", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_PLAYER_IGNORED) }, + { "ChatNormal", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_CHAT_NORMAL) }, + { "ChatEmote", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_CHAT_EMOTE) }, + { "ChatOwner", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_CHAT_OWNER) }, + { "ChatOwnerEmote", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_CHAT_OWNER_EMOTE) }, + { "ChatPriv", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_CHAT_PRIVATE) }, + { "ChatPrivEmote", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_CHAT_PRIVATE_EMOTE) }, + { "ChatPrivOwner", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_CHAT_PRIVATE_OWNER) }, + { "ChatPrivOwnerEmote", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_CHAT_PRIVATE_OWNER_EMOTE) }, + { "ChatBuddy", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_CHAT_BUDDY) }, + { "ChatSelf", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_CHAT_SELF) }, + { "AcceptTrue", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_ACCEPT_TRUE) }, + { "AcceptFalse", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_ACCEPT_FALSE) }, + { "MapSelected", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_MAP_SELECTED) }, + { "MapUnselected", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_MAP_UNSELECTED) }, + { "MOTD", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_MOTD) }, + { "MOTDHeading", INI::parseColorInt, nullptr, OFFSET(GSCOLOR_MOTD_HEADING) }, + + { nullptr, nullptr, nullptr, 0 } }; diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp index bc2360883a2..c4d593bbe1a 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/GSConfig.cpp @@ -39,7 +39,7 @@ /////////////////////////////////////////////////////////////////////////////////////// -GameSpyConfigInterface *TheGameSpyConfig = NULL; +GameSpyConfigInterface *TheGameSpyConfig = nullptr; class GameSpyConfig : public GameSpyConfigInterface { diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/LadderDefs.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/LadderDefs.cpp index c59f0613a2f..7fad1cbb3d6 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/LadderDefs.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/LadderDefs.cpp @@ -40,7 +40,7 @@ #include "GameClient/MapUtil.h" -LadderList *TheLadderList = NULL; +LadderList *TheLadderList = nullptr; LadderInfo::LadderInfo() { @@ -59,7 +59,7 @@ LadderInfo::LadderInfo() static LadderInfo *parseLadder(AsciiString raw) { DEBUG_LOG(("Looking at ladder:\n%s", raw.str())); - LadderInfo *lad = NULL; + LadderInfo *lad = nullptr; AsciiString line; while (raw.nextToken(&line, "\n")) { @@ -212,8 +212,8 @@ static LadderInfo *parseLadder(AsciiString raw) { // no maps? don't play on it! delete lad; - lad = NULL; - return NULL; + lad = nullptr; + return nullptr; } } else if ( lad && line.startsWith("Map ") ) @@ -240,12 +240,12 @@ static LadderInfo *parseLadder(AsciiString raw) { // bad ladder - kill it delete lad; - lad = NULL; + lad = nullptr; } } delete lad; - return NULL; + return nullptr; } LadderList::LadderList() @@ -257,7 +257,7 @@ LadderList::LadderList() Bool inLadders = FALSE; Bool inSpecialLadders = FALSE; Bool inLadder = FALSE; - LadderInfo *lad = NULL; + LadderInfo *lad = nullptr; Int index = 1; AsciiString rawLadder; @@ -303,7 +303,7 @@ LadderList::LadderList() inLadder = FALSE; rawLadder.concat(line); rawLadder.concat('\n'); - if ((lad = parseLadder(rawLadder)) != NULL) + if ((lad = parseLadder(rawLadder)) != nullptr) { lad->index = index++; if (inLadders) @@ -384,13 +384,13 @@ const LadderInfo* LadderList::findLadder( const AsciiString& addr, UnsignedShort } } - return NULL; + return nullptr; } const LadderInfo* LadderList::findLadderByIndex( Int index ) { if (index == 0) - return NULL; + return nullptr; LadderInfoList::const_iterator cit; @@ -421,7 +421,7 @@ const LadderInfo* LadderList::findLadderByIndex( Int index ) } } - return NULL; + return nullptr; } const LadderInfoList* LadderList::getSpecialLadders( void ) @@ -475,7 +475,7 @@ void LadderList::checkLadder( AsciiString fname, Int index ) rawData.concat(buf); } fp->close(); - fp = NULL; + fp = nullptr; } DEBUG_LOG(("Read %d bytes from '%s'", rawData.getLength(), fname.str())); diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp index 7ac0d39b852..fa26e2e8c66 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/LobbyUtils.cpp @@ -85,12 +85,12 @@ static NameKeyType windowSortAlphaID = NAMEKEY_INVALID; static NameKeyType windowSortPingID = NAMEKEY_INVALID; static NameKeyType windowSortBuddiesID = NAMEKEY_INVALID; -static GameWindow *buttonSortAlpha = NULL; -static GameWindow *buttonSortPing = NULL; -static GameWindow *buttonSortBuddies = NULL; -static GameWindow *windowSortAlpha = NULL; -static GameWindow *windowSortPing = NULL; -static GameWindow *windowSortBuddies = NULL; +static GameWindow *buttonSortAlpha = nullptr; +static GameWindow *buttonSortPing = nullptr; +static GameWindow *buttonSortBuddies = nullptr; +static GameWindow *windowSortAlpha = nullptr; +static GameWindow *windowSortPing = nullptr; +static GameWindow *windowSortBuddies = nullptr; static GameSortType theGameSortType = GAMESORT_ALPHA_ASCENDING; static Bool sortBuddies = TRUE; @@ -184,14 +184,14 @@ static NameKeyType listboxLobbyGamesLargeID = NAMEKEY_INVALID; //static NameKeyType listboxLobbyGameInfoID = NAMEKEY_INVALID; // Window Pointers ------------------------------------------------------------------------ -static GameWindow *parent = NULL; -//static GameWindow *parentGameListSmall = NULL; -static GameWindow *parentGameListLarge = NULL; - //GameWindow *listboxLobbyGamesSmall = NULL; - GameWindow *listboxLobbyGamesLarge = NULL; - //GameWindow *listboxLobbyGameInfo = NULL; +static GameWindow *parent = nullptr; +//static GameWindow *parentGameListSmall = nullptr; +static GameWindow *parentGameListLarge = nullptr; + //GameWindow *listboxLobbyGamesSmall = nullptr; + GameWindow *listboxLobbyGamesLarge = nullptr; + //GameWindow *listboxLobbyGameInfo = nullptr; -static const Image *pingImages[3] = { NULL, NULL, NULL }; +static const Image *pingImages[3] = { nullptr, nullptr, nullptr }; static void gameTooltip(GameWindow *window, WinInstanceData *instData, @@ -225,15 +225,15 @@ static void gameTooltip(GameWindow *window, room->getPingAsInt(), TheGameSpyConfig->getPingCutoffGood(), TheGameSpyConfig->getPingCutoffBad(), TheGameSpyInfo->getPingString().str(), room->getPingString().str() ); - TheMouse->setCursorTooltip( s, 10, NULL, 2.0f ); // the text and width are the only params used. the others are the default values. + TheMouse->setCursorTooltip( s, 10, nullptr, 2.0f ); // the text and width are the only params used. the others are the default values. #else - TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:PingInfo"), 10, NULL, 2.0f ); // the text and width are the only params used. the others are the default values. + TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:PingInfo"), 10, nullptr, 2.0f ); // the text and width are the only params used. the others are the default values. #endif return; } if (col == COLUMN_NUMPLAYERS) { - TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:NumberOfPlayers"), 10, NULL, 2.0f ); // the text and width are the only params used. the others are the default values. + TheMouse->setCursorTooltip( TheGameText->fetch("TOOLTIP:NumberOfPlayers"), 10, nullptr, 2.0f ); // the text and width are the only params used. the others are the default values. return; } if (col == COLUMN_PASSWORD) @@ -243,7 +243,7 @@ static void gameTooltip(GameWindow *window, UnicodeString checkTooltip =TheGameText->fetch("TOOTIP:Password"); if(!checkTooltip.compare(L"Password required to joing game")) checkTooltip.set(L"Password required to join game"); - TheMouse->setCursorTooltip( checkTooltip, 10, NULL, 2.0f ); // the text and width are the only params used. the others are the default values. + TheMouse->setCursorTooltip( checkTooltip, 10, nullptr, 2.0f ); // the text and width are the only params used. the others are the default values. } else TheMouse->setCursorTooltip( UnicodeString::TheEmptyString ); @@ -342,7 +342,7 @@ static void gameTooltip(GameWindow *window, } DEBUG_ASSERTCRASH(numPlayers, ("Tooltipping a 0-player game!")); - TheMouse->setCursorTooltip( tooltip, 10, NULL, 2.0f ); // the text and width are the only params used. the others are the default values. + TheMouse->setCursorTooltip( tooltip, 10, nullptr, 2.0f ); // the text and width are the only params used. the others are the default values. } static Bool isSmall = TRUE; @@ -354,7 +354,7 @@ GameWindow *GetGameListBox( void ) GameWindow *GetGameInfoListBox( void ) { - return NULL; + return nullptr; } NameKeyType GetGameListBoxID( void ) @@ -371,7 +371,7 @@ void GrabWindowInfo( void ) { isSmall = TRUE; parentID = NAMEKEY( "WOLCustomLobby.wnd:WOLLobbyMenuParent" ); - parent = TheWindowManager->winGetWindowFromId(NULL, parentID); + parent = TheWindowManager->winGetWindowFromId(nullptr, parentID); pingImages[0] = TheMappedImageCollection->findImageByName("Ping03"); pingImages[1] = TheMappedImageCollection->findImageByName("Ping02"); @@ -381,21 +381,21 @@ void GrabWindowInfo( void ) DEBUG_ASSERTCRASH(pingImages[2], ("Can't find ping image!")); // parentGameListSmallID = NAMEKEY( "WOLCustomLobby.wnd:ParentGameListSmall" ); -// parentGameListSmall = TheWindowManager->winGetWindowFromId(NULL, parentGameListSmallID); +// parentGameListSmall = TheWindowManager->winGetWindowFromId(nullptr, parentGameListSmallID); parentGameListLargeID = NAMEKEY( "WOLCustomLobby.wnd:ParentGameListLarge" ); - parentGameListLarge = TheWindowManager->winGetWindowFromId(NULL, parentGameListLargeID); + parentGameListLarge = TheWindowManager->winGetWindowFromId(nullptr, parentGameListLargeID); listboxLobbyGamesSmallID = NAMEKEY( "WOLCustomLobby.wnd:ListboxGames" ); -// listboxLobbyGamesSmall = TheWindowManager->winGetWindowFromId(NULL, listboxLobbyGamesSmallID); +// listboxLobbyGamesSmall = TheWindowManager->winGetWindowFromId(nullptr, listboxLobbyGamesSmallID); // listboxLobbyGamesSmall->winSetTooltipFunc(gameTooltip); listboxLobbyGamesLargeID = NAMEKEY( "WOLCustomLobby.wnd:ListboxGamesLarge" ); - listboxLobbyGamesLarge = TheWindowManager->winGetWindowFromId(NULL, listboxLobbyGamesLargeID); + listboxLobbyGamesLarge = TheWindowManager->winGetWindowFromId(nullptr, listboxLobbyGamesLargeID); listboxLobbyGamesLarge->winSetTooltipFunc(gameTooltip); // // listboxLobbyGameInfoID = NAMEKEY( "WOLCustomLobby.wnd:ListboxGameInfo" ); -// listboxLobbyGameInfo = TheWindowManager->winGetWindowFromId(NULL, listboxLobbyGameInfoID); +// listboxLobbyGameInfo = TheWindowManager->winGetWindowFromId(nullptr, listboxLobbyGameInfoID); buttonSortAlphaID = NAMEKEY("WOLCustomLobby.wnd:ButtonSortAlpha"); buttonSortPingID = NAMEKEY("WOLCustomLobby.wnd:ButtonSortPing"); @@ -417,23 +417,23 @@ void GrabWindowInfo( void ) void ReleaseWindowInfo( void ) { isSmall = TRUE; - parent = NULL; -// parentGameListSmall = NULL; - parentGameListLarge = NULL; -// listboxLobbyGamesSmall = NULL; - listboxLobbyGamesLarge = NULL; -// listboxLobbyGameInfo = NULL; - - buttonSortAlpha = NULL; - buttonSortPing = NULL; - buttonSortBuddies = NULL; - windowSortAlpha = NULL; - windowSortPing = NULL; - windowSortBuddies = NULL; + parent = nullptr; +// parentGameListSmall = nullptr; + parentGameListLarge = nullptr; +// listboxLobbyGamesSmall = nullptr; + listboxLobbyGamesLarge = nullptr; +// listboxLobbyGameInfo = nullptr; + + buttonSortAlpha = nullptr; + buttonSortPing = nullptr; + buttonSortBuddies = nullptr; + windowSortAlpha = nullptr; + windowSortPing = nullptr; + windowSortBuddies = nullptr; } typedef std::set BuddyGameSet; -static BuddyGameSet *theBuddyGames = NULL; +static BuddyGameSet *theBuddyGames = nullptr; static void populateBuddyGames(void) { BuddyInfoMap *m = TheGameSpyInfo->getBuddyMap(); @@ -466,7 +466,7 @@ static void populateBuddyGames(void) static void clearBuddyGames(void) { delete theBuddyGames; - theBuddyGames = NULL; + theBuddyGames = nullptr; } struct GameSortStruct @@ -474,16 +474,16 @@ struct GameSortStruct bool operator()(GameSpyStagingRoom *g1, GameSpyStagingRoom *g2) const { // sort CRC mismatches to the bottom - Bool g1Good = (g1->getExeCRC() != TheGlobalData->m_exeCRC || g1->getIniCRC() != TheGlobalData->m_iniCRC); - Bool g2Good = (g1->getExeCRC() != TheGlobalData->m_exeCRC || g1->getIniCRC() != TheGlobalData->m_iniCRC); + Bool g1Good = (g1->getExeCRC() == TheGlobalData->m_exeCRC && g1->getIniCRC() == TheGlobalData->m_iniCRC); + Bool g2Good = (g2->getExeCRC() == TheGlobalData->m_exeCRC && g2->getIniCRC() == TheGlobalData->m_iniCRC); if ( g1Good ^ g2Good ) { return g1Good; } // sort games with private ladders to the bottom - Bool g1UnknownLadder = (g1->getLadderPort() && TheLadderList->findLadder(g1->getLadderIP(), g1->getLadderPort()) == NULL); - Bool g2UnknownLadder = (g2->getLadderPort() && TheLadderList->findLadder(g2->getLadderIP(), g2->getLadderPort()) == NULL); + Bool g1UnknownLadder = (g1->getLadderPort() && TheLadderList->findLadder(g1->getLadderIP(), g1->getLadderPort()) == nullptr); + Bool g2UnknownLadder = (g2->getLadderPort() && TheLadderList->findLadder(g2->getLadderIP(), g2->getLadderPort()) == nullptr); if ( g1UnknownLadder ^ g2UnknownLadder ) { return g2UnknownLadder; @@ -736,7 +736,7 @@ void RefreshGameListBox( GameWindow *win, Bool showMap ) if (indexToSelect < 0 && selectedID) { - TheWindowManager->winSetLoneWindow(NULL); + TheWindowManager->winSetLoneWindow(nullptr); } } @@ -856,7 +856,7 @@ void RefreshGameListBoxes( void ) GameWindow *main = GetGameListBox(); GameWindow *info = GetGameInfoListBox(); - RefreshGameListBox( main, (info == NULL) ); + RefreshGameListBox( main, (info == nullptr) ); if (info) { diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp index c6585cef93e..9cb427a9870 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/MainMenuUtils.cpp @@ -64,14 +64,14 @@ static Bool mustDownloadPatch = FALSE; static Bool cantConnectBeforeOnline = FALSE; static std::list queuedDownloads; -static char *MOTDBuffer = NULL; -static char *configBuffer = NULL; -GameWindow *onlineCancelWindow = NULL; +static char *MOTDBuffer = nullptr; +static char *configBuffer = nullptr; +GameWindow *onlineCancelWindow = nullptr; static Bool s_asyncDNSThreadDone = TRUE; static Bool s_asyncDNSThreadSucceeded = FALSE; static Bool s_asyncDNSLookupInProgress = FALSE; -static HANDLE s_asyncDNSThreadHandle = NULL; +static HANDLE s_asyncDNSThreadHandle = nullptr; enum { LOOKUP_INPROGRESS, LOOKUP_FAILED, @@ -181,7 +181,7 @@ static void startOnline( void ) if (onlineCancelWindow) { TheWindowManager->winDestroy(onlineCancelWindow); - onlineCancelWindow = NULL; + onlineCancelWindow = nullptr; } if (cantConnectBeforeOnline) @@ -222,10 +222,10 @@ static void startOnline( void ) SetUpGameSpy(MOTDBuffer, configBuffer); delete[] MOTDBuffer; - MOTDBuffer = NULL; + MOTDBuffer = nullptr; delete[] configBuffer; - configBuffer = NULL; + configBuffer = nullptr; #ifdef ALLOW_NON_PROFILED_LOGIN UserPreferences pref; @@ -326,7 +326,7 @@ static GHTTPBool motdCallback( GHTTPRequest request, GHTTPResult result, if (onlineCancelWindow && !checksLeftBeforeOnline) { TheWindowManager->winDestroy(onlineCancelWindow); - onlineCancelWindow = NULL; + onlineCancelWindow = nullptr; } DEBUG_LOG(("------- Got MOTD before going online -------")); @@ -352,7 +352,7 @@ static GHTTPBool configCallback( GHTTPRequest request, GHTTPResult result, } delete[] configBuffer; - configBuffer = NULL; + configBuffer = nullptr; if (result != GHTTPSuccess || bufferLen < 100) { @@ -362,7 +362,7 @@ static GHTTPBool configCallback( GHTTPRequest request, GHTTPResult result, if (onlineCancelWindow && !checksLeftBeforeOnline) { TheWindowManager->winDestroy(onlineCancelWindow); - onlineCancelWindow = NULL; + onlineCancelWindow = nullptr; } cantConnectBeforeOnline = TRUE; if (!checksLeftBeforeOnline) @@ -390,7 +390,7 @@ static GHTTPBool configCallback( GHTTPRequest request, GHTTPResult result, if (onlineCancelWindow && !checksLeftBeforeOnline) { TheWindowManager->winDestroy(onlineCancelWindow); - onlineCancelWindow = NULL; + onlineCancelWindow = nullptr; } DEBUG_LOG(("Got Config before going online")); @@ -449,11 +449,11 @@ static GHTTPBool configHeadCallback( GHTTPRequest request, GHTTPResult result, if (onlineCancelWindow && !checksLeftBeforeOnline) { TheWindowManager->winDestroy(onlineCancelWindow); - onlineCancelWindow = NULL; + onlineCancelWindow = nullptr; } delete[] configBuffer; - configBuffer = NULL; + configBuffer = nullptr; AsciiString fname; fname.format("%sGeneralsOnline\\Config.txt", TheGlobalData->getPath_UserData().str()); @@ -561,15 +561,15 @@ void CancelPatchCheckCallback( void ) if (onlineCancelWindow) { TheWindowManager->winDestroy(onlineCancelWindow); - onlineCancelWindow = NULL; + onlineCancelWindow = nullptr; } queuedDownloads.clear(); delete[] MOTDBuffer; - MOTDBuffer = NULL; + MOTDBuffer = nullptr; delete[] configBuffer; - configBuffer = NULL; + configBuffer = nullptr; } /////////////////////////////////////////////////////////////////////////////////////// @@ -588,7 +588,7 @@ static GHTTPBool overallStatsCallback( GHTTPRequest request, GHTTPResult result, Int state = STATS_MAX; // STATS_MAX == none AsciiString line; - OverallStats *stats = NULL; + OverallStats *stats = nullptr; while (message.nextToken(&line, "\n")) { line.trim(); @@ -646,7 +646,7 @@ static GHTTPBool overallStatsCallback( GHTTPRequest request, GHTTPResult result, stats->losses[state] = atoi(lossesLine.str()); } - stats = NULL; + stats = nullptr; } } @@ -694,7 +694,7 @@ void CheckOverallStats( void ) #elif RTS_ZEROHOUR const char *const url = "http://gamestats.gamespy.com/ccgenzh/display.html"; #endif - ghttpGet(url, GHTTPFalse, overallStatsCallback, NULL); + ghttpGet(url, GHTTPFalse, overallStatsCallback, nullptr); } /////////////////////////////////////////////////////////////////////////////////////// @@ -706,7 +706,7 @@ void CheckNumPlayersOnline( void ) #elif RTS_ZEROHOUR const char *const url = "http://launch.gamespyarcade.com/software/launch/arcadecount2.dll?svcname=ccgenzh"; #endif - ghttpGet(url, GHTTPFalse, numPlayersOnlineCallback, NULL); + ghttpGet(url, GHTTPFalse, numPlayersOnlineCallback, nullptr); } /////////////////////////////////////////////////////////////////////////////////////// @@ -739,9 +739,9 @@ int asyncGethostbyname(char * szName) { /* Kick off gethostname thread */ s_asyncDNSThreadDone = FALSE; - s_asyncDNSThreadHandle = CreateThread( NULL, 0, asyncGethostbynameThreadFunc, szName, 0, &threadid ); + s_asyncDNSThreadHandle = CreateThread( nullptr, 0, asyncGethostbynameThreadFunc, szName, 0, &threadid ); - if( s_asyncDNSThreadHandle == NULL ) + if( s_asyncDNSThreadHandle == nullptr ) { return( LOOKUP_FAILED ); } @@ -754,7 +754,7 @@ int asyncGethostbyname(char * szName) /* Thread finished */ stat = 0; s_asyncDNSLookupInProgress = FALSE; - s_asyncDNSThreadHandle = NULL; + s_asyncDNSThreadHandle = nullptr; return( (s_asyncDNSThreadSucceeded)?LOOKUP_SUCCEEDED:LOOKUP_FAILED ); } } @@ -814,7 +814,7 @@ void StopAsyncDNSCheck( void ) TerminateThread(s_asyncDNSThreadHandle,0); DEBUG_ASSERTCRASH(res, ("Could not terminate the Async DNS Lookup thread!")); // Thread still not killed! } - s_asyncDNSThreadHandle = NULL; + s_asyncDNSThreadHandle = nullptr; s_asyncDNSLookupInProgress = FALSE; } diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp index cd67390e83f..7a244e736f1 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp @@ -47,8 +47,8 @@ #include "GameLogic/GameLogic.h" -GameSpyInfoInterface *TheGameSpyInfo = NULL; -extern GameSpyStagingRoom *TheGameSpyGame = NULL; +GameSpyInfoInterface *TheGameSpyInfo = nullptr; +extern GameSpyStagingRoom *TheGameSpyGame = nullptr; void deleteNotificationBox( void ); bool AsciiComparator::operator()(AsciiString s1, AsciiString s2) const @@ -65,7 +65,7 @@ GameSpyInfo::GameSpyInfo() GameSpyInfo::~GameSpyInfo() { - TheGameSpyGame = NULL; + TheGameSpyGame = nullptr; reset(); } @@ -157,7 +157,7 @@ GameSpyStagingRoom* GameSpyInfo::getCurrentStagingRoom( void ) if (it != m_stagingRooms.end()) return it->second; - return NULL; + return nullptr; } void GameSpyInfo::setGameOptions( void ) @@ -408,12 +408,12 @@ void GameSpyInfo::joinBestGroupRoom( void ) } else { - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSGroupRoomJoinFail"), NULL); + GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSGroupRoomJoinFail"), nullptr); } } else { - GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSGroupRoomJoinFail"), NULL); + GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:GSGroupRoomJoinFail"), nullptr); } } @@ -498,7 +498,7 @@ GameSpyStagingRoom* GameSpyInfo::findStagingRoomByID( Int id ) if (it != m_stagingRooms.end()) return it->second; - return NULL; + return nullptr; } void GameSpyInfo::leaveStagingRoom( void ) @@ -605,11 +605,11 @@ void SetUpGameSpy( const char *motdBuffer, const char *configBuffer ) TearDownGameSpy(); AsciiString dir = TheGlobalData->getPath_UserData(); - CreateDirectory(dir.str(), NULL); + CreateDirectory(dir.str(), nullptr); dir.format("%sGeneralsOnline", TheGlobalData->getPath_UserData().str()); - CreateDirectory(dir.str(), NULL); + CreateDirectory(dir.str(), nullptr); dir.format("%sGeneralsOnline\\Ladders", TheGlobalData->getPath_UserData().str()); - CreateDirectory(dir.str(), NULL); + CreateDirectory(dir.str(), nullptr); TheGameSpyBuddyMessageQueue = GameSpyBuddyMessageQueueInterface::createNewMessageQueue(); TheGameSpyBuddyMessageQueue->startThread(); @@ -671,16 +671,16 @@ void TearDownGameSpy( void ) ThePinger->endThreads(); delete TheRankPointValues; - TheRankPointValues = NULL; + TheRankPointValues = nullptr; delete TheGameSpyPSMessageQueue; - TheGameSpyPSMessageQueue = NULL; + TheGameSpyPSMessageQueue = nullptr; delete TheGameSpyBuddyMessageQueue; - TheGameSpyBuddyMessageQueue = NULL; + TheGameSpyBuddyMessageQueue = nullptr; delete TheGameSpyPeerMessageQueue; - TheGameSpyPeerMessageQueue = NULL; + TheGameSpyPeerMessageQueue = nullptr; if (TheGameSpyInfo) { @@ -690,17 +690,17 @@ void TearDownGameSpy( void ) SignalUIInteraction(SHELL_SCRIPT_HOOK_GENERALS_ONLINE_LOGOUT); } delete TheGameSpyInfo; - TheGameSpyInfo = NULL; + TheGameSpyInfo = nullptr; } delete ThePinger; - ThePinger = NULL; + ThePinger = nullptr; delete TheLadderList; - TheLadderList = NULL; + TheLadderList = nullptr; delete TheGameSpyConfig; - TheGameSpyConfig = NULL; + TheGameSpyConfig = nullptr; // make sure the notification box doesn't exist deleteNotificationBox(); @@ -758,7 +758,7 @@ static Int grabHexInt(const char *s) char tmp[5] = "0xff"; tmp[2] = s[0]; tmp[3] = s[1]; - Int b = strtol(tmp, NULL, 16); + Int b = strtol(tmp, nullptr, 16); return b; } diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp index dc0aea8b3f3..dc24d0cca6f 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/StagingRoomGameInfo.cpp @@ -191,7 +191,7 @@ Bool GetLocalChatConnectionAddress(AsciiString serverName, UnsignedShort serverP DEBUG_LOG(("About to load INETMIB1.DLL")); HINSTANCE mib_ii_dll = LoadLibrary("inetmib1.dll"); - if (mib_ii_dll == NULL) { + if (mib_ii_dll == nullptr) { DEBUG_LOG(("Failed to load INETMIB1.DLL")); return(false); } @@ -199,7 +199,7 @@ Bool GetLocalChatConnectionAddress(AsciiString serverName, UnsignedShort serverP DEBUG_LOG(("About to load SNMPAPI.DLL")); HINSTANCE snmpapi_dll = LoadLibrary("snmpapi.dll"); - if (snmpapi_dll == NULL) { + if (snmpapi_dll == nullptr) { DEBUG_LOG(("Failed to load SNMPAPI.DLL")); FreeLibrary(mib_ii_dll); return(false); @@ -212,7 +212,7 @@ Bool GetLocalChatConnectionAddress(AsciiString serverName, UnsignedShort serverP SnmpExtensionQueryPtr = (int (__stdcall *)(unsigned char,SnmpVarBindList *,long *,long *)) GetProcAddress(mib_ii_dll, "SnmpExtensionQuery"); SnmpUtilMemAllocPtr = (void *(__stdcall *)(unsigned long)) GetProcAddress(snmpapi_dll, "SnmpUtilMemAlloc"); SnmpUtilMemFreePtr = (void (__stdcall *)(void *)) GetProcAddress(snmpapi_dll, "SnmpUtilMemFree"); - if (SnmpExtensionInitPtr == NULL || SnmpExtensionQueryPtr == NULL || SnmpUtilMemAllocPtr == NULL || SnmpUtilMemFreePtr == NULL) { + if (SnmpExtensionInitPtr == nullptr || SnmpExtensionQueryPtr == nullptr || SnmpUtilMemAllocPtr == nullptr || SnmpUtilMemFreePtr == nullptr) { DEBUG_LOG(("Failed to get proc addresses for linked functions")); FreeLibrary(snmpapi_dll); FreeLibrary(mib_ii_dll); @@ -448,7 +448,7 @@ GameSpyStagingRoom::GameSpyStagingRoom() cleanUpSlotPointers(); setLocalIP(0); - m_transport = NULL; + m_transport = nullptr; m_localName = "localhost"; @@ -514,7 +514,7 @@ Int GameSpyStagingRoom::getLocalSlotNum( void ) const for (Int i=0; iisPlayer(localName)) @@ -527,14 +527,14 @@ void GameSpyStagingRoom::startGame(Int gameID) { DEBUG_ASSERTCRASH(m_inGame, ("Starting a game while not in game")); DEBUG_LOG(("GameSpyStagingRoom::startGame - game id = %d", gameID)); - DEBUG_ASSERTCRASH(m_transport == NULL, ("m_transport is not NULL when it should be")); - DEBUG_ASSERTCRASH(TheNAT == NULL, ("TheNAT is not NULL when it should be")); + DEBUG_ASSERTCRASH(m_transport == nullptr, ("m_transport is not null when it should be")); + DEBUG_ASSERTCRASH(TheNAT == nullptr, ("TheNAT is not null when it should be")); UnsignedInt localIP = TheGameSpyInfo->getInternalIP(); setLocalIP(localIP); delete TheNAT; - TheNAT = NULL; + TheNAT = nullptr; // fill in GS-specific info Int numHumans = 0; @@ -800,10 +800,10 @@ void GameSpyStagingRoom::launchGame( void ) // Set up the game network AsciiString user; AsciiString userList; - DEBUG_ASSERTCRASH(TheNetwork == NULL, ("For some reason TheNetwork isn't NULL at the start of this game. Better look into that.")); + DEBUG_ASSERTCRASH(TheNetwork == nullptr, ("For some reason TheNetwork isn't null at the start of this game. Better look into that.")); delete TheNetwork; - TheNetwork = NULL; + TheNetwork = nullptr; // Time to initialize TheNetwork for this game. TheNetwork = NetworkInterface::createNetwork(); @@ -826,12 +826,12 @@ void GameSpyStagingRoom::launchGame( void ) // see if we really have the map. if not, back out. TheMapCache->updateCache(); - if (!filesOk || TheMapCache->findMap(getMap()) == NULL) + if (!filesOk || TheMapCache->findMap(getMap()) == nullptr) { DEBUG_LOG(("After transfer, we didn't really have the map. Bailing...")); delete TheNetwork; - TheNetwork = NULL; + TheNetwork = nullptr; GSMessageBoxOk(TheGameText->fetch("GUI:Error"), TheGameText->fetch("GUI:CouldNotTransferMap")); @@ -844,7 +844,7 @@ void GameSpyStagingRoom::launchGame( void ) // shutdown the top, but do not pop it off the stack // TheShell->hideShell(); // setup the Global Data with the Map and Seed - TheWritableGlobalData->m_pendingFile = TheGameSpyGame->getMap(); + TheWritableGlobalData->m_pendingFile = getMap(); // send a message to the logic for a new game GameMessage *msg = TheMessageStream->appendMessage( GameMessage::MSG_NEW_GAME ); @@ -861,11 +861,12 @@ void GameSpyStagingRoom::launchGame( void ) req.buddyRequestType = BuddyRequest::BUDDYREQUEST_SETSTATUS; req.arg.status.status = GP_PLAYING; strcpy(req.arg.status.statusString, "Loading"); - sprintf(req.arg.status.locationString, "%s", WideCharStringToMultiByte(TheGameSpyGame->getGameName().str()).c_str()); + strlcpy(req.arg.status.locationString, WideCharStringToMultiByte(getGameName().str()).c_str(), + ARRAY_SIZE(req.arg.status.locationString)); TheGameSpyBuddyMessageQueue->addRequest(req); delete TheNAT; - TheNAT = NULL; + TheNAT = nullptr; } void GameSpyStagingRoom::reset(void) diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp index da36009076c..50e2180d83d 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/BuddyThread.cpp @@ -126,7 +126,7 @@ enum CallbackType void callbackWrapper( GPConnection *con, void *arg, void *param ) { CallbackType info = (CallbackType)(Int)param; - BuddyThreadClass *thread = MESSAGE_QUEUE->getThread() ? MESSAGE_QUEUE->getThread() : NULL /*(TheGameSpyBuddyMessageQueue)?TheGameSpyBuddyMessageQueue->getThread():NULL*/; + BuddyThreadClass *thread = MESSAGE_QUEUE->getThread() ? MESSAGE_QUEUE->getThread() : nullptr /*(TheGameSpyBuddyMessageQueue)?TheGameSpyBuddyMessageQueue->getThread():nullptr*/; if (!thread) return; @@ -154,7 +154,7 @@ void callbackWrapper( GPConnection *con, void *arg, void *param ) GameSpyBuddyMessageQueue::GameSpyBuddyMessageQueue() { - m_thread = NULL; + m_thread = nullptr; } GameSpyBuddyMessageQueue::~GameSpyBuddyMessageQueue() @@ -181,7 +181,7 @@ void GameSpyBuddyMessageQueue::startThread( void ) void GameSpyBuddyMessageQueue::endThread( void ) { delete m_thread; - m_thread = NULL; + m_thread = nullptr; } Bool GameSpyBuddyMessageQueue::isThreadRunning( void ) diff --git a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp index 6d8cc679b22..6c13e2561bc 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpy/Thread/GameResultsThread.cpp @@ -105,7 +105,7 @@ GameResultsQueue::GameResultsQueue() : m_requestCount(0), m_responseCount(0) { for (Int i=0; ikeyvals) { DEBUG_CRASH(("Referencing a missing server!")); - return 0; + return nullptr; } return it->second; } - return 0; + return nullptr; } Int PeerThreadClass::findServer( SBServer server ) @@ -457,7 +457,7 @@ Int PeerThreadClass::findServer( SBServer server ) UnsignedShort newPrivatePort = SBServerGetPrivateQueryPort(server); UnsignedInt newPublicIP = SBServerGetPublicInetAddress(server); - SBServer serverToRemove = NULL; + SBServer serverToRemove = nullptr; for (std::map::iterator it = m_stagingServers.begin(); it != m_stagingServers.end(); ++it) { @@ -511,7 +511,7 @@ void connectCallbackWrapper( PEER peer, PEERBool success, int failureReason, voi DEBUG_LOG(("In connectCallbackWrapper()")); CheckServers(peer); #endif // SERVER_DEBUGGING - if (param != NULL) + if (param != nullptr) { ((PeerThreadClass *)param)->connectCallback( peer, success ); } @@ -519,7 +519,7 @@ void connectCallbackWrapper( PEER peer, PEERBool success, int failureReason, voi void nickErrorCallbackWrapper( PEER peer, Int type, const char *nick, int numSuggestedNicks, const gsi_char** suggestedNicks, void *param ) { - if (param != NULL) + if (param != nullptr) { ((PeerThreadClass *)param)->nickErrorCallback( peer, type, nick ); } @@ -531,7 +531,7 @@ static void joinRoomCallback(PEER peer, PEERBool success, PEERJoinResult result, GameSpyPeerMessageQueue::GameSpyPeerMessageQueue() { - m_thread = NULL; + m_thread = nullptr; m_serialAuth = SERIAL_OK; } @@ -559,7 +559,7 @@ void GameSpyPeerMessageQueue::startThread( void ) void GameSpyPeerMessageQueue::endThread( void ) { delete m_thread; - m_thread = NULL; + m_thread = nullptr; } Bool GameSpyPeerMessageQueue::isThreadRunning( void ) @@ -670,22 +670,22 @@ static void updateBuddyStatus( GameSpyBuddyStatus status, Int groupRoom = 0, std case BUDDY_LOBBY: req.arg.status.status = GP_CHATTING; strcpy(req.arg.status.statusString, "Chatting"); - sprintf(req.arg.status.locationString, "%d", groupRoom); + snprintf(req.arg.status.locationString, ARRAY_SIZE(req.arg.status.locationString), "%d", groupRoom); break; case BUDDY_STAGING: req.arg.status.status = GP_STAGING; strcpy(req.arg.status.statusString, "Staging"); - sprintf(req.arg.status.locationString, "%s", gameName.c_str()); + strlcpy(req.arg.status.locationString, gameName.c_str(), ARRAY_SIZE(req.arg.status.locationString)); break; case BUDDY_LOADING: req.arg.status.status = GP_PLAYING; strcpy(req.arg.status.statusString, "Loading"); - sprintf(req.arg.status.locationString, "%s", gameName.c_str()); + strlcpy(req.arg.status.locationString, gameName.c_str(), ARRAY_SIZE(req.arg.status.locationString)); break; case BUDDY_PLAYING: req.arg.status.status = GP_PLAYING; strcpy(req.arg.status.statusString, "Playing"); - sprintf(req.arg.status.locationString, "%s", gameName.c_str()); + strlcpy(req.arg.status.locationString, gameName.c_str(), ARRAY_SIZE(req.arg.status.locationString)); break; case BUDDY_MATCHING: req.arg.status.status = GP_ONLINE; @@ -1135,7 +1135,7 @@ void checkQR2Queries( PEER peer, SOCKET sock ) while (1) { - error = select(FD_SETSIZE, &set, NULL, NULL, &timeout); + error = select(FD_SETSIZE, &set, nullptr, nullptr, &timeout); if (SOCKET_ERROR == error || 0 == error) return; //else we have data @@ -1191,7 +1191,7 @@ void PeerThreadClass::Thread_Function() m_qmGroupRoom = 0; peer = peerInitialize( &callbacks ); - DEBUG_ASSERTCRASH( peer != NULL, ("NULL peer!") ); + DEBUG_ASSERTCRASH( peer != nullptr, ("null peer!") ); m_isConnected = m_isConnecting = false; qr2_register_key(EXECRC_KEY, EXECRC_STR); @@ -1322,7 +1322,7 @@ void PeerThreadClass::Thread_Function() { DEBUG_CRASH(("Error setting title")); peerShutdown( peer ); - peer = NULL; + peer = nullptr; return; } @@ -1406,8 +1406,8 @@ void PeerThreadClass::Thread_Function() s_lastStateChangedHeartbeat = 0; s_wantStateChangedHeartbeat = FALSE; peerStopGame( peer ); - peerLeaveRoom( peer, GroupRoom, NULL ); - peerLeaveRoom( peer, StagingRoom, NULL ); + peerLeaveRoom( peer, GroupRoom, nullptr ); + peerLeaveRoom( peer, StagingRoom, nullptr ); if (qr2Sock != INVALID_SOCKET) { closesocket(qr2Sock); @@ -1422,16 +1422,16 @@ void PeerThreadClass::Thread_Function() case PeerRequest::PEERREQUEST_LEAVEGROUPROOM: m_groupRoomID = 0; updateBuddyStatus( BUDDY_ONLINE ); - peerLeaveRoom( peer, GroupRoom, NULL ); - peerLeaveRoom( peer, StagingRoom, NULL ); m_isHosting = false; + peerLeaveRoom( peer, GroupRoom, nullptr ); + peerLeaveRoom( peer, StagingRoom, nullptr ); m_isHosting = false; break; case PeerRequest::PEERREQUEST_JOINSTAGINGROOM: { m_groupRoomID = 0; updateBuddyStatus( BUDDY_ONLINE ); - peerLeaveRoom( peer, GroupRoom, NULL ); - peerLeaveRoom( peer, StagingRoom, NULL ); m_isHosting = false; + peerLeaveRoom( peer, GroupRoom, nullptr ); + peerLeaveRoom( peer, StagingRoom, nullptr ); m_isHosting = false; SBServer server = findServerByID(incomingRequest.stagingRoom.id); m_localStagingServerName = incomingRequest.text; DEBUG_LOG(("Setting m_localStagingServerName to [%ls]", m_localStagingServerName.c_str())); @@ -1456,8 +1456,8 @@ void PeerThreadClass::Thread_Function() case PeerRequest::PEERREQUEST_LEAVESTAGINGROOM: m_groupRoomID = 0; updateBuddyStatus( BUDDY_ONLINE ); - peerLeaveRoom( peer, GroupRoom, NULL ); - peerLeaveRoom( peer, StagingRoom, NULL ); + peerLeaveRoom( peer, GroupRoom, nullptr ); + peerLeaveRoom( peer, StagingRoom, nullptr ); isThreadHosting = 0; // debugging s_lastStateChangedHeartbeat = 0; s_wantStateChangedHeartbeat = FALSE; @@ -1513,8 +1513,8 @@ void PeerThreadClass::Thread_Function() snprintf(values[4], 20, "%d", incomingRequest.statsToPush.side); snprintf(values[5], 20, "%d", incomingRequest.statsToPush.preorder); peerSetGlobalKeys(peer, 6, (const char **)keys, (const char **)values); - peerSetGlobalWatchKeys(peer, GroupRoom, 0, NULL, PEERFalse); - peerSetGlobalWatchKeys(peer, StagingRoom, 0, NULL, PEERFalse); + peerSetGlobalWatchKeys(peer, GroupRoom, 0, nullptr, PEERFalse); + peerSetGlobalWatchKeys(peer, StagingRoom, 0, nullptr, PEERFalse); peerSetGlobalWatchKeys(peer, GroupRoom, 6, keys, PEERTrue); peerSetGlobalWatchKeys(peer, StagingRoom, 6, keys, PEERTrue); #endif @@ -1578,8 +1578,8 @@ void PeerThreadClass::Thread_Function() updateBuddyStatus( BUDDY_ONLINE ); if (!incomingRequest.stagingRoomCreation.restrictGameList) { - peerLeaveRoom( peer, GroupRoom, NULL ); - peerLeaveRoom( peer, StagingRoom, NULL ); + peerLeaveRoom( peer, GroupRoom, nullptr ); + peerLeaveRoom( peer, StagingRoom, nullptr ); } m_isHosting = TRUE; @@ -1631,7 +1631,7 @@ void PeerThreadClass::Thread_Function() DEBUG_LOG(("Requesting to join room %d", m_localRoomID)); if (incomingRequest.stagingRoomCreation.restrictGameList) { - peerLeaveRoom( peer, StagingRoom, NULL ); + peerLeaveRoom( peer, StagingRoom, nullptr ); } else { @@ -1645,7 +1645,7 @@ void PeerThreadClass::Thread_Function() { if (incomingRequest.stagingRoomCreation.restrictGameList) { - peerLeaveRoom( peer, GroupRoom, NULL ); + peerLeaveRoom( peer, GroupRoom, nullptr ); } isThreadHosting = 1; // debugging s_lastStateChangedHeartbeat = timeGetTime(); // wait the full interval before updating state @@ -1696,7 +1696,7 @@ void PeerThreadClass::Thread_Function() resp.stagingRoom.percentComplete = 0; clearServers(); TheGameSpyPeerMessageQueue->addResponse(resp); - peerStartListingGames( peer, allKeysArray, NumKeys, (incomingRequest.gameList.restrictGameList?"~":NULL), listingGamesCallback, this ); + peerStartListingGames( peer, allKeysArray, NumKeys, (incomingRequest.gameList.restrictGameList?"~":nullptr), listingGamesCallback, this ); } break; @@ -1708,7 +1708,7 @@ void PeerThreadClass::Thread_Function() case PeerRequest::PEERREQUEST_STARTGAME: { - peerStartGame( peer, NULL, PEER_STOP_REPORTING); + peerStartGame( peer, nullptr, PEER_STOP_REPORTING); } break; @@ -1804,7 +1804,7 @@ static Int matchbotProfileID = 0; void quickmatchEnumPlayersCallback( PEER peer, PEERBool success, RoomType roomType, int index, const char * nick, int flags, void * param ) { PeerThreadClass *t = (PeerThreadClass *)param; - if (!t || !success || nick == NULL || nick[0] == '\0') + if (!t || !success || nick == nullptr || nick[0] == '\0') { t->sawEndOfEnumPlayers(); return; @@ -1958,8 +1958,8 @@ void PeerThreadClass::doQuickMatch( PEER peer ) TheGameSpyPeerMessageQueue->addResponse(resp); m_groupRoomID = m_qmGroupRoom; - peerLeaveRoom( peer, GroupRoom, NULL ); - peerLeaveRoom( peer, StagingRoom, NULL ); m_isHosting = false; + peerLeaveRoom( peer, GroupRoom, nullptr ); + peerLeaveRoom( peer, StagingRoom, nullptr ); m_isHosting = false; m_localRoomID = m_groupRoomID; m_roomJoined = false; DEBUG_LOG(("Requesting to join room %d in thread %X", m_localRoomID, this)); @@ -2064,8 +2064,8 @@ void PeerThreadClass::doQuickMatch( PEER peer ) case QM_MATCHED: { // leave QM channel, and clean up. Our work here is done. - peerLeaveRoom( peer, GroupRoom, NULL ); - peerLeaveRoom( peer, StagingRoom, NULL ); m_isHosting = false; + peerLeaveRoom( peer, GroupRoom, nullptr ); + peerLeaveRoom( peer, StagingRoom, nullptr ); m_isHosting = false; m_qmStatus = QM_STOPPED; peerLeaveRoom(peer, GroupRoom, ""); @@ -2101,7 +2101,7 @@ void PeerThreadClass::doQuickMatch( PEER peer ) static void getPlayerProfileIDCallback(PEER peer, PEERBool success, const char * nick, int profileID, void * param) { - if (success && param != NULL) + if (success && param != nullptr) { *((Int *)param) = profileID; } @@ -2204,7 +2204,7 @@ static void joinRoomCallback(PEER peer, PEERBool success, PEERJoinResult result, // Gets called once for each group room when listing group rooms. // After this has been called for each group room, it will be -// called one more time with groupID==0 and name==NULL. +// called one more time with groupID==0 and name==nullptr. ///////////////////////////////////////////////////////////////// static void listGroupRoomsCallback(PEER peer, PEERBool success, int groupID, SBServer server, @@ -2287,7 +2287,7 @@ void PeerThreadClass::connectCallback( PEER peer, PEERBool success ) DEBUG_LOG(("Before peerListGroupRooms()")); CheckServers(peer); #endif // SERVER_DEBUGGING - peerListGroupRooms( peer, NULL, listGroupRoomsCallback, this, PEERTrue ); + peerListGroupRooms( peer, nullptr, listGroupRoomsCallback, this, PEERTrue ); #ifdef SERVER_DEBUGGING DEBUG_LOG(("After peerListGroupRooms()")); CheckServers(peer); @@ -2329,7 +2329,7 @@ void PeerThreadClass::nickErrorCallback( PEER peer, Int type, const char *nick ) TheGameSpyPeerMessageQueue->addResponse(resp); // Cancel the connect. - peerRetryWithNick(peer, NULL); + peerRetryWithNick(peer, nullptr); } } else @@ -2340,7 +2340,7 @@ void PeerThreadClass::nickErrorCallback( PEER peer, Int type, const char *nick ) TheGameSpyPeerMessageQueue->addResponse(resp); // Cancel the connect. - peerRetryWithNick(peer, NULL); + peerRetryWithNick(peer, nullptr); } } @@ -2391,7 +2391,7 @@ void roomMessageCallback(PEER peer, RoomType roomType, const char * nick, const { if (resp.message.profileID == matchbotProfileID) { - char *lastStr = NULL; + char *lastStr = nullptr; char *cmd = strtok_r((char *)message, " ", &lastStr); if ( cmd && strcmp(cmd, "MBOT:POOLSIZE") == 0 ) { @@ -2399,8 +2399,8 @@ void roomMessageCallback(PEER peer, RoomType roomType, const char * nick, const while (1) { - char *poolStr = strtok_r(NULL, " ", &lastStr); - char *sizeStr = strtok_r(NULL, " ", &lastStr); + char *poolStr = strtok_r(nullptr, " ", &lastStr); + char *sizeStr = strtok_r(nullptr, " ", &lastStr); if (poolStr && sizeStr) { Int pool = atoi(poolStr); @@ -2451,12 +2451,12 @@ void playerMessageCallback(PEER peer, const char * nick, const char * message, M { if (resp.message.isPrivate && resp.message.profileID == matchbotProfileID) { - char *lastStr = NULL; + char *lastStr = nullptr; char *cmd = strtok_r((char *)message, " ", &lastStr); if ( cmd && strcmp(cmd, "MBOT:MATCHED") == 0 ) { - char *mapNumStr = strtok_r(NULL, " ", &lastStr); - char *seedStr = strtok_r(NULL, " ", &lastStr); + char *mapNumStr = strtok_r(nullptr, " ", &lastStr); + char *seedStr = strtok_r(nullptr, " ", &lastStr); char *playerStr[MAX_SLOTS]; char *playerIPStr[MAX_SLOTS]; char *playerSideStr[MAX_SLOTS]; @@ -2465,22 +2465,22 @@ void playerMessageCallback(PEER peer, const char * nick, const char * message, M Int numPlayers = 0; for (Int i=0; i 0) { char *dest = NEW char[len]; - WideCharToMultiByte( CP_UTF8, 0, orig, -1, dest, len, NULL, NULL ); + WideCharToMultiByte( CP_UTF8, 0, orig, -1, dest, len, nullptr, nullptr ); dest[len-1] = 0; ret = dest; delete[] dest; diff --git a/Core/GameEngine/Source/GameNetwork/GameSpyOverlay.cpp b/Core/GameEngine/Source/GameNetwork/GameSpyOverlay.cpp index 10af680e1b0..209e1d3bed8 100644 --- a/Core/GameEngine/Source/GameNetwork/GameSpyOverlay.cpp +++ b/Core/GameEngine/Source/GameNetwork/GameSpyOverlay.cpp @@ -44,9 +44,9 @@ void deleteNotificationBox( void ); static void raiseOverlays( void ); // Message boxes ------------------------------------- -static GameWindow *messageBoxWindow = NULL; -static GameWinMsgBoxFunc okFunc = NULL; -static GameWinMsgBoxFunc cancelFunc = NULL; +static GameWindow *messageBoxWindow = nullptr; +static GameWinMsgBoxFunc okFunc = nullptr; +static GameWinMsgBoxFunc cancelFunc = nullptr; static Bool reOpenPlayerInfoFlag = FALSE; /** * messageBoxOK is called when a message box is destroyed @@ -55,11 +55,11 @@ static Bool reOpenPlayerInfoFlag = FALSE; static void messageBoxOK( void ) { DEBUG_ASSERTCRASH(messageBoxWindow, ("Message box window went away without being there in the first place!")); - messageBoxWindow = NULL; + messageBoxWindow = nullptr; if (okFunc) { okFunc(); - okFunc = NULL; + okFunc = nullptr; } } @@ -70,11 +70,11 @@ static void messageBoxOK( void ) static void messageBoxCancel( void ) { DEBUG_ASSERTCRASH(messageBoxWindow, ("Message box window went away without being there in the first place!")); - messageBoxWindow = NULL; + messageBoxWindow = nullptr; if (cancelFunc) { cancelFunc(); - cancelFunc = NULL; + cancelFunc = nullptr; } } @@ -88,17 +88,17 @@ void ClearGSMessageBoxes( void ) if (messageBoxWindow) { TheWindowManager->winDestroy(messageBoxWindow); - messageBoxWindow = NULL; + messageBoxWindow = nullptr; } if (okFunc) { - okFunc = NULL; + okFunc = nullptr; } if (cancelFunc) { - cancelFunc = NULL; + cancelFunc = nullptr; } } @@ -172,15 +172,15 @@ static const char * gsOverlays[GSOVERLAY_MAX] = static WindowLayout *overlayLayouts[GSOVERLAY_MAX] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, }; static void buddyTryReconnect( void ) @@ -200,12 +200,12 @@ void GameSpyOpenOverlay( GSOverlayType overlay ) if (TheGameSpyBuddyMessageQueue->getLocalProfileID()) { // used to be connected - GSMessageBoxYesNo(TheGameText->fetch("GUI:GPErrorTitle"), TheGameText->fetch("GUI:GPDisconnected"), buddyTryReconnect, NULL); + GSMessageBoxYesNo(TheGameText->fetch("GUI:GPErrorTitle"), TheGameText->fetch("GUI:GPDisconnected"), buddyTryReconnect, nullptr); } else { // no profile - GSMessageBoxOk(TheGameText->fetch("GUI:GPErrorTitle"), TheGameText->fetch("GUI:GPNoProfile"), NULL); + GSMessageBoxOk(TheGameText->fetch("GUI:GPErrorTitle"), TheGameText->fetch("GUI:GPNoProfile"), nullptr); } return; } @@ -268,13 +268,13 @@ void GameSpyCloseOverlay( GSOverlayType overlay ) overlayLayouts[overlay]->runShutdown(); overlayLayouts[overlay]->destroyWindows(); deleteInstance(overlayLayouts[overlay]); - overlayLayouts[overlay] = NULL; + overlayLayouts[overlay] = nullptr; } } Bool GameSpyIsOverlayOpen( GSOverlayType overlay ) { - return (overlayLayouts[overlay] != NULL); + return (overlayLayouts[overlay] != nullptr); } void GameSpyToggleOverlay( GSOverlayType overlay ) diff --git a/Core/GameEngine/Source/GameNetwork/IPEnumeration.cpp b/Core/GameEngine/Source/GameNetwork/IPEnumeration.cpp index 9336b820640..4bc28109463 100644 --- a/Core/GameEngine/Source/GameNetwork/IPEnumeration.cpp +++ b/Core/GameEngine/Source/GameNetwork/IPEnumeration.cpp @@ -30,7 +30,7 @@ IPEnumeration::IPEnumeration( void ) { - m_IPlist = NULL; + m_IPlist = nullptr; m_isWinsockInitialized = false; } @@ -63,12 +63,12 @@ EnumeratedIP * IPEnumeration::getAddresses( void ) int err = WSAStartup(verReq, &wsadata); if (err != 0) { - return NULL; + return nullptr; } if ((LOBYTE(wsadata.wVersion) != 2) || (HIBYTE(wsadata.wVersion) !=2)) { WSACleanup(); - return NULL; + return nullptr; } m_isWinsockInitialized = true; } @@ -78,23 +78,23 @@ EnumeratedIP * IPEnumeration::getAddresses( void ) if (gethostname(hostname, sizeof(hostname))) { DEBUG_LOG(("Failed call to gethostname; WSAGetLastError returned %d", WSAGetLastError())); - return NULL; + return nullptr; } DEBUG_LOG(("Hostname is '%s'", hostname)); // get host information from the host name HOSTENT* hostEnt = gethostbyname(hostname); - if (hostEnt == NULL) + if (hostEnt == nullptr) { DEBUG_LOG(("Failed call to gethostbyname; WSAGetLastError returned %d", WSAGetLastError())); - return NULL; + return nullptr; } // sanity-check the length of the IP adress if (hostEnt->h_length != 4) { DEBUG_LOG(("gethostbyname returns oddly-sized IP addresses!")); - return NULL; + return nullptr; } // TheSuperHackers @feature Add one unique local host IP address for each multi client instance. @@ -111,7 +111,7 @@ EnumeratedIP * IPEnumeration::getAddresses( void ) // construct a list of addresses int numAddresses = 0; char *entry; - while ( (entry = hostEnt->h_addr_list[numAddresses++]) != 0 ) + while ( (entry = hostEnt->h_addr_list[numAddresses++]) != nullptr ) { addNewIP( (UnsignedByte)entry[0], @@ -141,7 +141,7 @@ void IPEnumeration::addNewIP( UnsignedByte a, UnsignedByte b, UnsignedByte c, Un if (!m_IPlist) { m_IPlist = newIP; - newIP->setNext(NULL); + newIP->setNext(nullptr); } else { diff --git a/Core/GameEngine/Source/GameNetwork/LANAPI.cpp b/Core/GameEngine/Source/GameNetwork/LANAPI.cpp index 86db49cbc7d..c7671fdc5c5 100644 --- a/Core/GameEngine/Source/GameNetwork/LANAPI.cpp +++ b/Core/GameEngine/Source/GameNetwork/LANAPI.cpp @@ -58,29 +58,29 @@ LANGame::LANGame( void ) } m_lastHeard = 0; m_inProgress = false; - m_next = NULL; + m_next = nullptr; } */ -LANAPI::LANAPI( void ) : m_transport(NULL) +LANAPI::LANAPI( void ) : m_transport(nullptr) { - DEBUG_LOG(("LANAPI::LANAPI() - max game option size is %d, sizeof(LANMessage)=%d, MAX_PACKET_SIZE=%d", - m_lanMaxOptionsLength, sizeof(LANMessage), MAX_PACKET_SIZE)); + DEBUG_LOG(("LANAPI::LANAPI() - max game option size is %d, sizeof(LANMessage)=%d, MAX_LANAPI_PACKET_SIZE=%d", + m_lanMaxOptionsLength, sizeof(LANMessage), MAX_LANAPI_PACKET_SIZE)); m_lastResendTime = 0; // - m_lobbyPlayers = NULL; - m_games = NULL; + m_lobbyPlayers = nullptr; + m_games = nullptr; m_name = L""; // safe default? m_pendingAction = ACT_NONE; m_expiration = 0; m_localIP = 0; m_inLobby = true; m_isInLANMenu = TRUE; - m_currentGame = NULL; + m_currentGame = nullptr; m_broadcastAddr = INADDR_BROADCAST; m_directConnectRemoteIP = 0; m_actionTimeout = 5000; // ms @@ -107,7 +107,7 @@ void LANAPI::init( void ) m_expiration = 0; m_inLobby = true; m_isInLANMenu = TRUE; - m_currentGame = NULL; + m_currentGame = nullptr; m_directConnectRemoteIP = 0; m_lastGameopt = ""; @@ -149,7 +149,7 @@ void LANAPI::reset( void ) m_transport->update(); LANGameInfo *theGame = m_games; - LANGameInfo *deletableGame = NULL; + LANGameInfo *deletableGame = nullptr; while (theGame) { @@ -159,7 +159,7 @@ void LANAPI::reset( void ) } LANPlayer *thePlayer = m_lobbyPlayers; - LANPlayer *deletablePlayer = NULL; + LANPlayer *deletablePlayer = nullptr; while (thePlayer) { @@ -168,14 +168,14 @@ void LANAPI::reset( void ) delete deletablePlayer; } - m_games = NULL; - m_lobbyPlayers = NULL; + m_games = nullptr; + m_lobbyPlayers = nullptr; m_directConnectRemoteIP = 0; m_pendingAction = ACT_NONE; m_expiration = 0; m_inLobby = true; m_isInLANMenu = TRUE; - m_currentGame = NULL; + m_currentGame = nullptr; } @@ -185,14 +185,14 @@ void LANAPI::sendMessage(LANMessage *msg, UnsignedInt ip /* = 0 */) { m_transport->queueSend(ip, lobbyPort, (unsigned char *)msg, sizeof(LANMessage) /*, 0, 0 */); } - else if ((m_currentGame != NULL) && (m_currentGame->getIsDirectConnect())) + else if ((m_currentGame != nullptr) && (m_currentGame->getIsDirectConnect())) { Int localSlot = m_currentGame->getLocalSlotNum(); for (Int i = 0; i < MAX_SLOTS; ++i) { if (i != localSlot) { GameSlot *slot = m_currentGame->getSlot(i); - if ((slot != NULL) && (slot->isHuman())) { + if ((slot != nullptr) && (slot->isHuman())) { m_transport->queueSend(slot->getIP(), lobbyPort, (unsigned char *)msg, sizeof(LANMessage) /*, 0, 0 */); } } @@ -561,21 +561,21 @@ void LANAPI::update( void ) switch (m_pendingAction) { case ACT_JOIN: - OnGameJoin(RET_TIMEOUT, NULL); + OnGameJoin(RET_TIMEOUT, nullptr); m_pendingAction = ACT_NONE; - m_currentGame = NULL; + m_currentGame = nullptr; m_inLobby = true; break; case ACT_LEAVE: OnPlayerLeave(m_name); m_pendingAction = ACT_NONE; - m_currentGame = NULL; + m_currentGame = nullptr; m_inLobby = true; break; case ACT_JOINDIRECTCONNECT: - OnGameJoin(RET_TIMEOUT, NULL); + OnGameJoin(RET_TIMEOUT, nullptr); m_pendingAction = ACT_NONE; - m_currentGame = NULL; + m_currentGame = nullptr; m_inLobby = true; break; default: @@ -621,13 +621,13 @@ void LANAPI::RequestGameJoin( LANGameInfo *game, UnsignedInt ip /* = 0 */ ) { if ((m_pendingAction != ACT_NONE) && (m_pendingAction != ACT_JOINDIRECTCONNECT)) { - OnGameJoin( RET_BUSY, NULL ); + OnGameJoin( RET_BUSY, nullptr ); return; } if (!game) { - OnGameJoin( RET_GAME_GONE, NULL ); + OnGameJoin( RET_GAME_GONE, nullptr ); return; } @@ -652,13 +652,13 @@ void LANAPI::RequestGameJoinDirectConnect(UnsignedInt ipaddress) { if (m_pendingAction != ACT_NONE) { - OnGameJoin( RET_BUSY, NULL ); + OnGameJoin( RET_BUSY, nullptr ); return; } if (ipaddress == 0) { - OnGameJoin( RET_GAME_GONE, NULL ); + OnGameJoin( RET_GAME_GONE, nullptr ); return; } @@ -690,7 +690,7 @@ void LANAPI::RequestGameLeave( void ) // Exit out immediately if we're hosting OnPlayerLeave(m_name); removeGame(m_currentGame); - m_currentGame = NULL; + m_currentGame = nullptr; m_inLobby = true; } else @@ -907,7 +907,7 @@ void LANAPI::RequestGameCreate( UnicodeString gameName, Bool isDirectConnect ) newSlot.setHost(m_hostName); myGame->setSlot(0,newSlot); - myGame->setNext(NULL); + myGame->setNext(nullptr); LANPreferences pref; AsciiString mapName = pref.getPreferredMap(); @@ -1094,7 +1094,7 @@ LANGameInfo * LANAPI::LookupGame( UnicodeString gameName ) theGame = theGame->getNext(); } - return theGame; // NULL means we didn't find anything. + return theGame; // null means we didn't find anything. } LANGameInfo * LANAPI::LookupGameByListOffset( Int offset ) @@ -1102,14 +1102,31 @@ LANGameInfo * LANAPI::LookupGameByListOffset( Int offset ) LANGameInfo *theGame = m_games; if (offset < 0) - return NULL; + return nullptr; while (offset-- && theGame) { theGame = theGame->getNext(); } - return theGame; // NULL means we didn't find anything. + return theGame; // null means we didn't find anything. +} + +LANGameInfo* LANAPI::LookupGameByHost(UnsignedInt hostIP) +{ + LANGameInfo* lastGame = nullptr; + UnsignedInt lastHeard = 0; + + for (LANGameInfo* game = m_games; game; game = game->getNext()) + { + if (game->getHostIP() == hostIP && game->getLastHeard() >= lastHeard) + { + lastGame = game; + lastHeard = game->getLastHeard(); + } + } + + return lastGame; } void LANAPI::removeGame( LANGameInfo *game ) @@ -1150,7 +1167,7 @@ LANPlayer * LANAPI::LookupPlayer( UnsignedInt playerIP ) thePlayer = thePlayer->getNext(); } - return thePlayer; // NULL means we didn't find anything. + return thePlayer; // null means we didn't find anything. } void LANAPI::removePlayer( LANPlayer *player ) @@ -1187,7 +1204,7 @@ void LANAPI::addGame( LANGameInfo *game ) if (!m_games) { m_games = game; - game->setNext(NULL); + game->setNext(nullptr); return; } else @@ -1217,7 +1234,7 @@ void LANAPI::addPlayer( LANPlayer *player ) if (!m_lobbyPlayers) { m_lobbyPlayers = player; - player->setNext(NULL); + player->setNext(nullptr); return; } else @@ -1270,7 +1287,7 @@ void LANAPI::setIsActive(Bool isActive) { if (isActive != m_isActive) { DEBUG_LOG(("LANAPI::setIsActive - m_isActive changed to %s", isActive ? "TRUE" : "FALSE")); if (isActive == FALSE) { - if ((m_inLobby == FALSE) && (m_currentGame != NULL)) { + if ((m_inLobby == FALSE) && (m_currentGame != nullptr)) { LANMessage msg; fillInLANMessage( &msg ); msg.messageType = LANMessage::MSG_INACTIVE; diff --git a/Core/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp b/Core/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp index ee3c87e3bf6..2c344553f76 100644 --- a/Core/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp +++ b/Core/GameEngine/Source/GameNetwork/LANAPICallbacks.cpp @@ -47,7 +47,7 @@ #include "GameNetwork/LANAPICallbacks.h" #include "GameNetwork/networkutil.h" -LANAPI *TheLAN = NULL; +LANAPI *TheLAN = nullptr; extern Bool LANbuttonPushed; @@ -208,10 +208,10 @@ void LANAPI::OnGameStart( void ) //m_currentGame->startGame(0); // 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.")); + DEBUG_ASSERTCRASH(TheNetwork == nullptr, ("For some reason TheNetwork isn't null at the start of this game. Better look into that.")); delete TheNetwork; - TheNetwork = NULL; + TheNetwork = nullptr; // Time to initialize TheNetwork for this game. TheNetwork = NetworkInterface::createNetwork(); @@ -228,16 +228,16 @@ void LANAPI::OnGameStart( void ) // see if we really have the map. if not, back out. TheMapCache->updateCache(); - if (!filesOk || TheMapCache->findMap(m_currentGame->getMap()) == NULL) + if (!filesOk || TheMapCache->findMap(m_currentGame->getMap()) == nullptr) { DEBUG_LOG(("After transfer, we didn't really have the map. Bailing...")); OnPlayerLeave(m_name); removeGame(m_currentGame); - m_currentGame = NULL; + m_currentGame = nullptr; m_inLobby = TRUE; delete TheNetwork; - TheNetwork = NULL; + TheNetwork = nullptr; OnChat(UnicodeString::TheEmptyString, 0, TheGameText->fetch("GUI:CouldNotTransferMap"), LANCHAT_SYSTEM); return; @@ -528,7 +528,7 @@ void LANAPI::OnGameJoin( ReturnType ret, LANGameInfo *theGame ) UnicodeString title, body; title = TheGameText->fetch("LAN:JoinFailed"); body = getErrorStringFromReturnType(ret); - MessageBoxOk(title, body, NULL); + MessageBoxOk(title, body, nullptr); } } @@ -665,7 +665,7 @@ void LANAPI::OnInActive(UnsignedInt IP) { void LANAPI::OnChat( UnicodeString player, UnsignedInt ip, UnicodeString message, ChatType format ) { - GameWindow *chatWindow = NULL; + GameWindow *chatWindow = nullptr; if (m_inLobby) { @@ -679,7 +679,7 @@ void LANAPI::OnChat( UnicodeString player, UnsignedInt ip, UnicodeString message { chatWindow = listboxChatWindowLanGame; } - if (chatWindow == NULL) + if (chatWindow == nullptr) return; Int index = -1; UnicodeString unicodeChat; diff --git a/Core/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp b/Core/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp index d6dbba08238..0f44f1d681d 100644 --- a/Core/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp +++ b/Core/GameEngine/Source/GameNetwork/LANAPIhandlers.cpp @@ -109,7 +109,7 @@ void LANAPI::handleGameAnnounce( LANMessage *msg, UnsignedInt senderIP ) else if (senderIP == m_directConnectRemoteIP) { - if (m_currentGame == NULL) + if (m_currentGame == nullptr) { LANGameInfo *game = LookupGame(UnicodeString(msg->GameInfo.gameName)); if (!game) @@ -150,7 +150,7 @@ void LANAPI::handleGameAnnounce( LANMessage *msg, UnsignedInt senderIP ) // remove from list removeGame(game); delete game; - game = NULL; + game = nullptr; } OnGameList( m_games ); @@ -226,7 +226,7 @@ static Bool IsSpaceCharacter(const WideChar c) static Bool ContainsInvalidChars(const WideChar* playerName) { - DEBUG_ASSERTCRASH(playerName != NULL, ("playerName is NULL")); + DEBUG_ASSERTCRASH(playerName != nullptr, ("playerName is null")); while (*playerName) { if (IsInvalidCharForPlayerName(*playerName++)) @@ -238,7 +238,7 @@ static Bool ContainsInvalidChars(const WideChar* playerName) static Bool ContainsAnyReadableChars(const WideChar* playerName) { - DEBUG_ASSERTCRASH(playerName != NULL, ("playerName is NULL")); + DEBUG_ASSERTCRASH(playerName != nullptr, ("playerName is null")); while (*playerName) { if (!IsSpaceCharacter(*playerName++)) @@ -433,7 +433,7 @@ void LANAPI::handleJoinAccept( LANMessage *msg, UnsignedInt senderIP ) if (!m_currentGame) { DEBUG_ASSERTCRASH(false, ("Could not find game to join!")); - OnGameJoin(RET_UNKNOWN, NULL); + OnGameJoin(RET_UNKNOWN, nullptr); } else { @@ -499,7 +499,7 @@ void LANAPI::handleRequestGameLeave( LANMessage *msg, UnsignedInt senderIP ) OnHostLeave(); removeGame(m_currentGame); delete m_currentGame; - m_currentGame = NULL; + m_currentGame = nullptr; /// @todo re-add myself to lobby? Or just keep me there all the time? If we send a LOBBY_ANNOUNCE things'll work out... LANPlayer *lanPlayer = LookupPlayer(m_localIP); @@ -621,7 +621,7 @@ void LANAPI::handleChat( LANMessage *msg, UnsignedInt senderIP ) if (m_inLobby) { LANPlayer *player; - if((player=LookupPlayer(senderIP)) != 0) + if((player=LookupPlayer(senderIP)) != nullptr) { OnChat(UnicodeString(player->getName()), player->getIP(), UnicodeString(msg->Chat.message), msg->Chat.chatType); player->setLastHeard(timeGetTime()); @@ -684,7 +684,7 @@ void LANAPI::handleGameOptions( LANMessage *msg, UnsignedInt senderIP ) } void LANAPI::handleInActive(LANMessage *msg, UnsignedInt senderIP) { - if (m_inLobby || (m_currentGame == NULL) || (m_currentGame->isGameInProgress())) { + if (m_inLobby || (m_currentGame == nullptr) || (m_currentGame->isGameInProgress())) { return; } @@ -700,7 +700,7 @@ void LANAPI::handleInActive(LANMessage *msg, UnsignedInt senderIP) { if (slotNum < 0) return; GameSlot *slot = m_currentGame->getSlot(slotNum); - if (slot == NULL) { + if (slot == nullptr) { return; } @@ -709,7 +709,7 @@ void LANAPI::handleInActive(LANMessage *msg, UnsignedInt senderIP) { } // don't want to unaccept the host, that's silly. They can't hit start alt-tabbed anyways. - if (senderIP == TheLAN->GetLocalIP()) { + if (senderIP == GetLocalIP()) { return; } diff --git a/Core/GameEngine/Source/GameNetwork/LANGameInfo.cpp b/Core/GameEngine/Source/GameNetwork/LANGameInfo.cpp index a34b6ea0e74..638681e4420 100644 --- a/Core/GameEngine/Source/GameNetwork/LANGameInfo.cpp +++ b/Core/GameEngine/Source/GameNetwork/LANGameInfo.cpp @@ -45,7 +45,7 @@ // Singleton ------------------------------------------ -LANGameInfo *TheLANGameInfo = NULL; +LANGameInfo *TheLANGameInfo = nullptr; // LANGameSlot ---------------------------------------- @@ -62,10 +62,10 @@ LANPlayer * LANGameSlot::getUser( void ) m_user.setIP(getIP()); m_user.setLastHeard(getLastHeard()); m_user.setName(getName()); - m_user.setNext(NULL); + m_user.setNext(nullptr); return &m_user; } - return NULL; + return nullptr; } // Various tests @@ -89,7 +89,7 @@ Bool LANGameSlot::isLocalPlayer( void ) const LANGameInfo::LANGameInfo() { m_lastHeard = 0; - m_next = NULL; + m_next = nullptr; m_isDirectConnect = false; // for (Int i = 0; i< MAX_SLOTS; ++i) @@ -117,7 +117,7 @@ LANGameSlot* LANGameInfo::getLANSlot( Int slotNum ) { DEBUG_ASSERTCRASH( slotNum >= 0 && slotNum < MAX_SLOTS, ("LANGameInfo::getLANSlot - Invalid slot number")); if (slotNum < 0 || slotNum >= MAX_SLOTS) - return NULL; + return nullptr; return &m_LANSlot[slotNum]; } @@ -126,7 +126,7 @@ const LANGameSlot* LANGameInfo::getConstLANSlot( Int slotNum ) const { DEBUG_ASSERTCRASH( slotNum >= 0 && slotNum < MAX_SLOTS, ("LANGameInfo::getConstLANSlot - Invalid slot number")); if (slotNum < 0 || slotNum >= MAX_SLOTS) - return NULL; + return nullptr; return &m_LANSlot[slotNum]; } @@ -198,7 +198,7 @@ void LANGameInfo::resetAccepted( void ) void LANDisplayGameList( GameWindow *gameListbox, LANGameInfo *gameList ) { - LANGameInfo *selectedPtr = NULL; + LANGameInfo *selectedPtr = nullptr; Int selectedIndex = -1; Int indexToSelect = -1; if (gameListbox) diff --git a/Core/GameEngine/Source/GameNetwork/NAT.cpp b/Core/GameEngine/Source/GameNetwork/NAT.cpp index 03e58556756..159d8532cfa 100644 --- a/Core/GameEngine/Source/GameNetwork/NAT.cpp +++ b/Core/GameEngine/Source/GameNetwork/NAT.cpp @@ -140,7 +140,7 @@ /* static */ time_t NAT::m_timeToWaitForPort = 15000; // wait for 15 seconds for the other player's port number. /* static */ time_t NAT::m_timeForRoundTimeout = 15000; // wait for at most 15 seconds for each connection round to finish. -NAT *TheNAT = NULL; +NAT *TheNAT = nullptr; NAT::NAT() { @@ -159,8 +159,8 @@ NAT::NAT() m_spareSocketPort = 0; m_startingPortNumber = 0; m_targetNodeNumber = 0; - m_transport = NULL; - m_slotList = NULL; + m_transport = nullptr; + m_slotList = nullptr; m_roundTimeout = 0; m_maxNumRetriesAllowed = 10; m_packetID = 0x7f00; @@ -212,7 +212,7 @@ NATStateType NAT::update() { TheEstablishConnectionsMenu->endMenu(); delete TheFirewallHelper; - TheFirewallHelper = NULL; + TheFirewallHelper = nullptr; } } else if (m_NATState == NATSTATE_DOCONNECTIONPATHS) { if (allConnectionsDoneThisRound() == TRUE) { @@ -238,7 +238,7 @@ NATStateType NAT::update() { TheEstablishConnectionsMenu->endMenu(); delete TheFirewallHelper; - TheFirewallHelper = NULL; + TheFirewallHelper = nullptr; */ } else { doThisConnectionRound(); @@ -256,7 +256,7 @@ NATStateType NAT::update() { // if we fail m_NATState = NATSTATE_FAILED; TheEstablishConnectionsMenu->endMenu(); - if (TheFirewallHelper != NULL) { + if (TheFirewallHelper != nullptr) { // we failed NAT negotiation, perhaps we need to redetect our firewall settings. // We don't trust the user to do it for themselves so we force them to do it next time // the log in. @@ -268,11 +268,11 @@ NATStateType NAT::update() { // TheFirewallHelper->writeFirewallBehavior(); delete TheFirewallHelper; - TheFirewallHelper = NULL; + TheFirewallHelper = nullptr; } // we failed to connect, so we don't have to pass on the transport to the network. delete m_transport; - m_transport = NULL; + m_transport = nullptr; } } return m_NATState; @@ -286,7 +286,7 @@ NATStateType NAT::update() { // if we didn't get a response, check to see if its time to send another packet to it NATConnectionState NAT::connectionUpdate() { - GameSlot *targetSlot = NULL; + GameSlot *targetSlot = nullptr; if (m_targetNodeNumber >= 0) { targetSlot = m_slotList[m_connectionNodes[m_targetNodeNumber].m_slotIndex]; } else { @@ -309,8 +309,8 @@ NATConnectionState NAT::connectionUpdate() { // we've made this connection, send a keepalive. Int slotIndex = m_connectionNodes[node].m_slotIndex; GameSlot *slot = m_slotList[slotIndex]; - DEBUG_ASSERTCRASH(slot != NULL, ("Trying to send keepalive to a NULL slot")); - if (slot != NULL) { + DEBUG_ASSERTCRASH(slot != nullptr, ("Trying to send keepalive to a null slot")); + if (slot != nullptr) { UnsignedInt ip = slot->getIP(); DEBUG_LOG(("NAT::connectionUpdate - sending keep alive to node %d at %d.%d.%d.%d:%d", node, PRINTF_IP_AS_4_INTS(ip), slot->getPort())); @@ -346,7 +346,7 @@ NATConnectionState NAT::connectionUpdate() { #ifdef DEBUG_LOGGING UnsignedInt slotIP = targetSlot->getIP(); #endif - DEBUG_LOG(("NAT::connectionUpdate - incomming packet has different from address than we expected, incoming: %d.%d.%d.%d expected: %d.%d.%d.%d", + DEBUG_LOG(("NAT::connectionUpdate - incoming packet has different from address than we expected, incoming: %d.%d.%d.%d expected: %d.%d.%d.%d", PRINTF_IP_AS_4_INTS(fromIP), PRINTF_IP_AS_4_INTS(slotIP))); targetSlot->setIP(fromIP); @@ -398,7 +398,7 @@ NATConnectionState NAT::connectionUpdate() { // we are waiting for a response from the mangler to tell us what port we're using. if (m_connectionStates[m_localNodeNumber] == NATCONNECTIONSTATE_WAITINGFORMANGLERRESPONSE) { UnsignedShort mangledPort = 0; - if (TheFirewallHelper != NULL) { + if (TheFirewallHelper != nullptr) { mangledPort = TheFirewallHelper->getManglerResponse(m_packetID); } if (mangledPort != 0) { @@ -420,7 +420,7 @@ NATConnectionState NAT::connectionUpdate() { m_sourcePorts[m_targetNodeNumber] = getSlotPort(m_connectionNodes[m_localNodeNumber].m_slotIndex); setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_WAITINGFORRESPONSE); } else { - if (TheFirewallHelper != NULL) { + if (TheFirewallHelper != nullptr) { DEBUG_LOG(("NAT::connectionUpdate - trying to send to the mangler again. mangler address: %d.%d.%d.%d, from port: %d, packet ID:%d", PRINTF_IP_AS_4_INTS(m_manglerAddress), m_spareSocketPort, m_packetID)); TheFirewallHelper->sendToManglerFromPort(m_manglerAddress, m_spareSocketPort, m_packetID); @@ -445,23 +445,23 @@ NATConnectionState NAT::connectionUpdate() { } // this is the function that starts the NAT/firewall negotiation process. -// after calling this, you should call the update function untill it returns +// after calling this, you should call the update function until it returns // NATSTATE_DONE. void NAT::establishConnectionPaths() { DEBUG_LOG(("NAT::establishConnectionPaths - entering")); m_NATState = NATSTATE_DOCONNECTIONPATHS; DEBUG_LOG(("NAT::establishConnectionPaths - using %d as our starting port number", m_startingPortNumber)); - if (TheEstablishConnectionsMenu == NULL) { + if (TheEstablishConnectionsMenu == nullptr) { TheEstablishConnectionsMenu = NEW EstablishConnectionsMenu; } TheEstablishConnectionsMenu->initMenu(); - if (TheFirewallHelper == NULL) { + if (TheFirewallHelper == nullptr) { TheFirewallHelper = createFirewallHelper(); } - DEBUG_ASSERTCRASH(m_slotList != NULL, ("NAT::establishConnectionPaths - don't have a slot list")); - if (m_slotList == NULL) { + DEBUG_ASSERTCRASH(m_slotList != nullptr, ("NAT::establishConnectionPaths - don't have a slot list")); + if (m_slotList == nullptr) { return; } @@ -469,7 +469,7 @@ void NAT::establishConnectionPaths() { m_numNodes = 0; Int i = 0; for (; i < MAX_SLOTS; ++i) { - if (m_slotList[i] != NULL) { + if (m_slotList[i] != nullptr) { if (m_slotList[i]->isHuman()) { DEBUG_LOG(("NAT::establishConnectionPaths - slot %d is %ls", i, m_slotList[i]->getName().str())); ++m_numNodes; @@ -509,7 +509,7 @@ void NAT::establishConnectionPaths() { DEBUG_LOG(("NAT::establishConnectionPaths - doing the netgear stuff")); UnsignedInt otherNetgearNum = -1; for (i = 0; i < MAX_SLOTS; ++i) { - if ((m_slotList != NULL) && (m_slotList[i] != NULL)) { + if ((m_slotList != nullptr) && (m_slotList[i] != nullptr)) { if ((m_slotList[i]->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) != 0) { if (otherNetgearNum == -1) { // this is the start of a new pair, put it in as the first non -1 node connection pair thing. @@ -545,7 +545,7 @@ void NAT::establishConnectionPaths() { if (connectionAssigned[i] == TRUE) { continue; } - if (m_slotList[i] == NULL) { + if (m_slotList[i] == nullptr) { continue; } if (!(m_slotList[i]->isHuman())) { @@ -581,7 +581,7 @@ void NAT::establishConnectionPaths() { // set up the names in the connection window. Int playerNum = 0; for (i = 0; i < MAX_SLOTS; ++i) { - while ((i < MAX_SLOTS) && (m_slotList[i] != NULL) && !(m_slotList[i]->isHuman())) { + while ((i < MAX_SLOTS) && (m_slotList[i] != nullptr) && !(m_slotList[i]->isHuman())) { ++i; } if (i >= MAX_SLOTS) { @@ -606,7 +606,7 @@ void NAT::attachSlotList(GameSlot *slotList[], Int localSlot, UnsignedInt localI m_slotList = slotList; m_localIP = localIP; m_transport = new Transport; - DEBUG_LOG(("NAT::attachSlotList - initting the transport socket with address %d.%d.%d.%d:%d", + DEBUG_LOG(("NAT::attachSlotList - initializing the transport socket with address %d.%d.%d.%d:%d", PRINTF_IP_AS_4_INTS(m_localIP), getSlotPort(localSlot))); m_startingPortNumber = NETWORK_BASE_PORT_NUMBER + ((timeGetTime() / 1000) % 20000); @@ -617,7 +617,7 @@ void NAT::attachSlotList(GameSlot *slotList[], Int localSlot, UnsignedInt localI Int NAT::getSlotPort(Int slot) { // return (slot + m_startingPortNumber); - if (m_slotList[slot] != NULL) { + if (m_slotList[slot] != nullptr) { return m_slotList[slot]->getPort(); } return 0; @@ -625,7 +625,7 @@ Int NAT::getSlotPort(Int slot) { void NAT::generatePortNumbers(GameSlot *slotList[], Int localSlot) { for (UnsignedInt i = 0; i < (UnsignedInt)MAX_SLOTS; ++i) { - if (slotList[i] != NULL) { + if (slotList[i] != nullptr) { if ((i == localSlot) && (TheWritableGlobalData->m_firewallPortOverride != 0)) { slotList[i]->setPort(TheWritableGlobalData->m_firewallPortOverride); } else { @@ -666,8 +666,8 @@ void NAT::doThisConnectionRound() { GameSlot *targetSlot = m_slotList[targetSlotIndex]; GameSlot *localSlot = m_slotList[m_connectionNodes[m_localNodeNumber].m_slotIndex]; - DEBUG_ASSERTCRASH(localSlot != NULL, ("local slot is NULL")); - DEBUG_ASSERTCRASH(targetSlot != NULL, ("trying to negotiate with a NULL target slot, slot is %d", m_connectionPairs[m_connectionPairIndex][m_connectionRound][i])); + DEBUG_ASSERTCRASH(localSlot != nullptr, ("local slot is null")); + DEBUG_ASSERTCRASH(targetSlot != nullptr, ("trying to negotiate with a null target slot, slot is %d", m_connectionPairs[m_connectionPairIndex][m_connectionRound][i])); DEBUG_LOG(("NAT::doThisConnectionRound - Target slot index = %d (%ls)", targetSlotIndex, m_slotList[targetSlotIndex]->getName().str())); DEBUG_LOG(("NAT::doThisConnectionRound - Target slot has NAT behavior 0x%8X, local slot has NAT behavior 0x%8X", targetSlot->getNATBehavior(), localSlot->getNATBehavior())); @@ -729,17 +729,17 @@ void NAT::sendMangledSourcePort() { FirewallHelperClass::tFirewallBehaviorType fwType = m_slotList[m_connectionNodes[m_localNodeNumber].m_slotIndex]->getNATBehavior(); GameSlot *targetSlot = m_slotList[m_connectionNodes[m_targetNodeNumber].m_slotIndex]; - DEBUG_ASSERTCRASH(targetSlot != NULL, ("NAT::sendMangledSourcePort - targetSlot is NULL")); - if (targetSlot == NULL) { - DEBUG_LOG(("NAT::sendMangledSourcePort - targetSlot is NULL, failed this connection")); + DEBUG_ASSERTCRASH(targetSlot != nullptr, ("NAT::sendMangledSourcePort - targetSlot is null")); + if (targetSlot == nullptr) { + DEBUG_LOG(("NAT::sendMangledSourcePort - targetSlot is null, failed this connection")); setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_FAILED); return; } GameSlot *localSlot = m_slotList[m_connectionNodes[m_localNodeNumber].m_slotIndex]; - DEBUG_ASSERTCRASH(localSlot != NULL, ("NAT::sendMangledSourcePort - localSlot is NULL, WTF?")); - if (localSlot == NULL) { - DEBUG_LOG(("NAT::sendMangledSourcePort - localSlot is NULL, failed this connection")); + DEBUG_ASSERTCRASH(localSlot != nullptr, ("NAT::sendMangledSourcePort - localSlot is null, WTF?")); + if (localSlot == nullptr) { + DEBUG_LOG(("NAT::sendMangledSourcePort - localSlot is null, failed this connection")); setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_FAILED); return; } @@ -803,7 +803,7 @@ void NAT::sendMangledSourcePort() { DEBUG_LOG(("NAT::sendMangledSourcePort - about to call gethostbyname for mangler at %s", manglerName)); struct hostent *hostInfo = gethostbyname(manglerName); - if (hostInfo == NULL) { + if (hostInfo == nullptr) { DEBUG_LOG(("NAT::sendMangledSourcePort - gethostbyname failed for mangler address %s", manglerName)); // can't find the mangler, we're screwed so just send the source port. sendMangledPortNumberToTarget(sourcePort, targetSlot); @@ -823,7 +823,7 @@ void NAT::sendMangledSourcePort() { m_manglerRetryTime = m_manglerRetryTimeInterval + timeGetTime(); m_manglerRetries = 0; - if (TheFirewallHelper != NULL) { + if (TheFirewallHelper != nullptr) { m_spareSocketPort = TheFirewallHelper->getNextTemporarySourcePort(0); TheFirewallHelper->openSpareSocket(m_spareSocketPort); TheFirewallHelper->sendToManglerFromPort(m_manglerAddress, m_spareSocketPort, m_packetID); @@ -838,9 +838,9 @@ void NAT::processManglerResponse(UnsignedShort mangledPort) { DEBUG_LOG(("NAT::processManglerResponse - Work out what my NAT'd port will be")); GameSlot *targetSlot = m_slotList[m_connectionNodes[m_targetNodeNumber].m_slotIndex]; - DEBUG_ASSERTCRASH(targetSlot != NULL, ("NAT::processManglerResponse - targetSlot is NULL")); - if (targetSlot == NULL) { - DEBUG_LOG(("NAT::processManglerResponse - targetSlot is NULL, failed this connection")); + DEBUG_ASSERTCRASH(targetSlot != nullptr, ("NAT::processManglerResponse - targetSlot is null")); + if (targetSlot == nullptr) { + DEBUG_LOG(("NAT::processManglerResponse - targetSlot is null, failed this connection")); setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_FAILED); return; } @@ -931,9 +931,9 @@ void NAT::connectionFailed(Int slotIndex) { // I have been probed by the target. void NAT::probed(Int nodeNumber) { GameSlot *localSlot = m_slotList[m_connectionNodes[m_localNodeNumber].m_slotIndex]; - DEBUG_ASSERTCRASH(localSlot != NULL, ("NAT::probed - localSlot is NULL, WTF?")); - if (localSlot == NULL) { - DEBUG_LOG(("NAT::probed - localSlot is NULL, failed this connection")); + DEBUG_ASSERTCRASH(localSlot != nullptr, ("NAT::probed - localSlot is null, WTF?")); + if (localSlot == nullptr) { + DEBUG_LOG(("NAT::probed - localSlot is null, failed this connection")); setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_FAILED); return; } @@ -944,9 +944,9 @@ void NAT::probed(Int nodeNumber) { if ((localSlot->getNATBehavior() & FirewallHelperClass::FIREWALL_TYPE_NETGEAR_BUG) != 0) { DEBUG_LOG(("NAT::probed - we have a NETGEAR and we were just probed for the first time")); GameSlot *targetSlot = m_slotList[m_connectionNodes[m_targetNodeNumber].m_slotIndex]; - DEBUG_ASSERTCRASH(targetSlot != NULL, ("NAT::probed - targetSlot is NULL")); - if (targetSlot == NULL) { - DEBUG_LOG(("NAT::probed - targetSlot is NULL, failed this connection")); + DEBUG_ASSERTCRASH(targetSlot != nullptr, ("NAT::probed - targetSlot is null")); + if (targetSlot == nullptr) { + DEBUG_LOG(("NAT::probed - targetSlot is null, failed this connection")); setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_FAILED); return; } @@ -974,17 +974,17 @@ void NAT::gotMangledPort(Int nodeNumber, UnsignedShort mangledPort) { } GameSlot *targetSlot = m_slotList[m_connectionNodes[m_targetNodeNumber].m_slotIndex]; - DEBUG_ASSERTCRASH(targetSlot != NULL, ("NAT::gotMangledPort - targetSlot is NULL")); - if (targetSlot == NULL) { - DEBUG_LOG(("NAT::gotMangledPort - targetSlot is NULL, failed this connection")); + DEBUG_ASSERTCRASH(targetSlot != nullptr, ("NAT::gotMangledPort - targetSlot is null")); + if (targetSlot == nullptr) { + DEBUG_LOG(("NAT::gotMangledPort - targetSlot is null, failed this connection")); setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_FAILED); return; } GameSlot *localSlot = m_slotList[m_connectionNodes[m_localNodeNumber].m_slotIndex]; - DEBUG_ASSERTCRASH(localSlot != NULL, ("NAT::gotMangledPort - localSlot is NULL, WTF?")); - if (localSlot == NULL) { - DEBUG_LOG(("NAT::gotMangledPort - localSlot is NULL, failed this connection")); + DEBUG_ASSERTCRASH(localSlot != nullptr, ("NAT::gotMangledPort - localSlot is null, WTF?")); + if (localSlot == nullptr) { + DEBUG_LOG(("NAT::gotMangledPort - localSlot is null, failed this connection")); setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_FAILED); return; } @@ -1014,14 +1014,14 @@ void NAT::gotMangledPort(Int nodeNumber, UnsignedShort mangledPort) { void NAT::gotInternalAddress(Int nodeNumber, UnsignedInt address) { GameSlot *targetSlot = m_slotList[m_connectionNodes[nodeNumber].m_slotIndex]; - DEBUG_ASSERTCRASH(targetSlot != NULL, ("NAT::gotInternalAddress - targetSlot is NULL")); - if (targetSlot == NULL) { + DEBUG_ASSERTCRASH(targetSlot != nullptr, ("NAT::gotInternalAddress - targetSlot is null")); + if (targetSlot == nullptr) { return; } GameSlot *localSlot = m_slotList[m_connectionNodes[m_localNodeNumber].m_slotIndex]; - DEBUG_ASSERTCRASH(localSlot != NULL, ("NAT::gotInternalAddress - localSlot is NULL, WTF?")); - if (localSlot == NULL) { + DEBUG_ASSERTCRASH(localSlot != nullptr, ("NAT::gotInternalAddress - localSlot is null, WTF?")); + if (localSlot == nullptr) { return; } @@ -1055,9 +1055,9 @@ void NAT::notifyTargetOfProbe(GameSlot *targetSlot) { void NAT::notifyUsersOfConnectionDone(Int nodeIndex) { GameSlot *localSlot = m_slotList[m_connectionNodes[m_localNodeNumber].m_slotIndex]; - DEBUG_ASSERTCRASH(localSlot != NULL, ("NAT::notifyUsersOfConnectionDone - localSlot is NULL, WTF?")); - if (localSlot == NULL) { - DEBUG_LOG(("NAT::notifyUsersOfConnectionDone - localSlot is NULL, failed this connection")); + DEBUG_ASSERTCRASH(localSlot != nullptr, ("NAT::notifyUsersOfConnectionDone - localSlot is null, WTF?")); + if (localSlot == nullptr) { + DEBUG_LOG(("NAT::notifyUsersOfConnectionDone - localSlot is null, failed this connection")); setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_FAILED); return; } @@ -1076,7 +1076,7 @@ void NAT::notifyUsersOfConnectionDone(Int nodeIndex) { continue; } - if ((m_slotList[i] == NULL) || (m_slotList[i]->isHuman() == FALSE)) { + if ((m_slotList[i] == nullptr) || (m_slotList[i]->isHuman() == FALSE)) { continue; } @@ -1097,9 +1097,9 @@ void NAT::notifyUsersOfConnectionDone(Int nodeIndex) { void NAT::notifyUsersOfConnectionFailed(Int nodeIndex) { GameSlot *localSlot = m_slotList[m_connectionNodes[m_localNodeNumber].m_slotIndex]; - DEBUG_ASSERTCRASH(localSlot != NULL, ("NAT::notifyUsersOfConnectionFailed - localSlot is NULL, WTF?")); - if (localSlot == NULL) { - DEBUG_LOG(("NAT::notifyUsersOfConnectionFailed - localSlot is NULL, failed this connection")); + DEBUG_ASSERTCRASH(localSlot != nullptr, ("NAT::notifyUsersOfConnectionFailed - localSlot is null, WTF?")); + if (localSlot == nullptr) { + DEBUG_LOG(("NAT::notifyUsersOfConnectionFailed - localSlot is null, failed this connection")); setConnectionState(m_localNodeNumber, NATCONNECTIONSTATE_FAILED); return; } @@ -1126,7 +1126,7 @@ void NAT::notifyUsersOfConnectionFailed(Int nodeIndex) { continue; } - if ((m_slotList[i] == NULL) || (m_slotList[i]->isHuman() == FALSE)) { + if ((m_slotList[i] == nullptr) || (m_slotList[i]->isHuman() == FALSE)) { continue; } @@ -1271,7 +1271,7 @@ void NAT::setConnectionState(Int nodeNumber, NATConnectionState state) { Int slot = 0; Int i = 0; for (; i < MAX_SLOTS; ++i) { - if (m_slotList[i] != NULL) { + if (m_slotList[i] != nullptr) { if (m_slotList[i]->isHuman()) { if (i != m_connectionNodes[m_localNodeNumber].m_slotIndex) { if (i == slotIndex) { diff --git a/Core/GameEngine/Source/GameNetwork/NetCommandList.cpp b/Core/GameEngine/Source/GameNetwork/NetCommandList.cpp index 9df51d77e99..b6a834c987b 100644 --- a/Core/GameEngine/Source/GameNetwork/NetCommandList.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetCommandList.cpp @@ -32,9 +32,9 @@ * Constructor. */ NetCommandList::NetCommandList() { - m_first = NULL; - m_last = NULL; - m_lastMessageInserted = NULL; + m_first = nullptr; + m_last = nullptr; + m_lastMessageInserted = nullptr; } /** @@ -48,17 +48,17 @@ NetCommandList::~NetCommandList() { * Append the given list of commands to this list. */ void NetCommandList::appendList(NetCommandList *list) { - if (list == NULL) { + if (list == nullptr) { return; } // Need to do it this way because of the reference counting that needs to happen in appendMessage. NetCommandRef *msg = list->getFirstMessage(); - NetCommandRef *next = NULL; - while (msg != NULL) { + NetCommandRef *next = nullptr; + while (msg != nullptr) { next = msg->getNext(); NetCommandRef *temp = addMessage(msg->getCommand()); - if (temp != NULL) { + if (temp != nullptr) { temp->setRelay(msg->getRelay()); } @@ -81,10 +81,10 @@ void NetCommandList::removeMessage(NetCommandRef *msg) { m_lastMessageInserted = msg->getNext(); } - if (msg->getPrev() != NULL) { + if (msg->getPrev() != nullptr) { msg->getPrev()->setNext(msg->getNext()); } - if (msg->getNext() != NULL) { + if (msg->getNext() != nullptr) { msg->getNext()->setPrev(msg->getPrev()); } @@ -95,8 +95,8 @@ void NetCommandList::removeMessage(NetCommandRef *msg) { m_last = msg->getPrev(); } - msg->setNext(NULL); - msg->setPrev(NULL); + msg->setNext(nullptr); + msg->setPrev(nullptr); } /** @@ -111,15 +111,15 @@ void NetCommandList::init() { */ void NetCommandList::reset() { NetCommandRef *temp = m_first; - while (m_first != NULL) { + while (m_first != nullptr) { temp = m_first->getNext(); - m_first->setNext(NULL); - m_first->setPrev(NULL); + m_first->setNext(nullptr); + m_first->setPrev(nullptr); deleteInstance(m_first); m_first = temp; } - m_last = NULL; - m_lastMessageInserted = NULL; + m_last = nullptr; + m_lastMessageInserted = nullptr; } /** @@ -127,16 +127,16 @@ void NetCommandList::reset() { * The message is sorted in based first on command type, then player id, and then command id. */ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) { - if (cmdMsg == NULL) { - DEBUG_ASSERTCRASH(cmdMsg != NULL, ("NetCommandList::addMessage - command message was NULL")); - return NULL; + if (cmdMsg == nullptr) { + DEBUG_ASSERTCRASH(cmdMsg != nullptr, ("NetCommandList::addMessage - command message was null")); + return nullptr; } // UnsignedInt id = cmdMsg->getID(); NetCommandRef *msg = NEW_NETCOMMANDREF(cmdMsg); - if (m_first == NULL) { + if (m_first == nullptr) { // this is the first node, so we don't have to worry about ordering it. m_first = msg; m_last = msg; @@ -144,7 +144,7 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) { return msg; } - if (m_lastMessageInserted != NULL) { + if (m_lastMessageInserted != nullptr) { // Messages that are inserted in order should just be put in one right after the other. // So saving the placement of the last message inserted can give us a huge boost in // efficiency. @@ -152,7 +152,7 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) { if ((m_lastMessageInserted->getCommand()->getNetCommandType() == msg->getCommand()->getNetCommandType()) && (m_lastMessageInserted->getCommand()->getPlayerID() == msg->getCommand()->getPlayerID()) && (m_lastMessageInserted->getCommand()->getID() < msg->getCommand()->getID()) && - ((theNext == NULL) || ((theNext->getCommand()->getNetCommandType() > msg->getCommand()->getNetCommandType()) || + ((theNext == nullptr) || ((theNext->getCommand()->getNetCommandType() > msg->getCommand()->getNetCommandType()) || (theNext->getCommand()->getPlayerID() > msg->getCommand()->getPlayerID()) || (theNext->getCommand()->getID() > msg->getCommand()->getID())))) { @@ -161,11 +161,11 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) { // This command is already in the list, don't duplicate it. deleteInstance(msg); - msg = NULL; - return NULL; + msg = nullptr; + return nullptr; } - if (theNext == NULL) { + if (theNext == nullptr) { // this means that m_lastMessageInserted == m_last, so m_last should point to the msg that is being inserted. msg->setNext(m_lastMessageInserted->getNext()); msg->setPrev(m_lastMessageInserted); @@ -192,12 +192,12 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) { // This command is already in the list, don't duplicate it. deleteInstance(msg); - msg = NULL; - return NULL; + msg = nullptr; + return nullptr; } msg->setPrev(m_last); - msg->setNext(NULL); + msg->setNext(nullptr); m_last->setNext(msg); m_last = msg; m_lastMessageInserted = msg; @@ -210,13 +210,13 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) { // This command is already in the list, don't duplicate it. deleteInstance(msg); - msg = NULL; - return NULL; + msg = nullptr; + return nullptr; } // The command goes at the head of the list. msg->setNext(m_first); - msg->setPrev(NULL); + msg->setPrev(nullptr); m_first->setPrev(msg); m_first = msg; m_lastMessageInserted = msg; @@ -226,23 +226,23 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) { // Find the start of the command type we're looking for. NetCommandRef *tempmsg = m_first; - while ((tempmsg != NULL) && (msg->getCommand()->getNetCommandType() > tempmsg->getCommand()->getNetCommandType())) { + while ((tempmsg != nullptr) && (msg->getCommand()->getNetCommandType() > tempmsg->getCommand()->getNetCommandType())) { tempmsg = tempmsg->getNext(); } - if (tempmsg == NULL) { + if (tempmsg == nullptr) { // Make sure this command isn't already in the list. if (isEqualCommandMsg(m_last->getCommand(), msg->getCommand())) { // This command is already in the list, don't duplicate it. deleteInstance(msg); - msg = NULL; - return NULL; + msg = nullptr; + return nullptr; } // message goes at the end of the list. msg->setPrev(m_last); - msg->setNext(NULL); + msg->setNext(nullptr); m_last->setNext(msg); m_last = msg; m_lastMessageInserted = msg; @@ -250,23 +250,23 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) { } // Now find the player position. munkee. - while ((tempmsg != NULL) && (msg->getCommand()->getNetCommandType() == tempmsg->getCommand()->getNetCommandType()) && (msg->getCommand()->getPlayerID() > tempmsg->getCommand()->getPlayerID())) { + while ((tempmsg != nullptr) && (msg->getCommand()->getNetCommandType() == tempmsg->getCommand()->getNetCommandType()) && (msg->getCommand()->getPlayerID() > tempmsg->getCommand()->getPlayerID())) { tempmsg = tempmsg->getNext(); } - if (tempmsg == NULL) { + if (tempmsg == nullptr) { // Make sure this command isn't already in the list. if (isEqualCommandMsg(m_last->getCommand(), msg->getCommand())) { // This command is already in the list, don't duplicate it. deleteInstance(msg); - msg = NULL; - return NULL; + msg = nullptr; + return nullptr; } // message goes at the end of the list. msg->setPrev(m_last); - msg->setNext(NULL); + msg->setNext(nullptr); m_last->setNext(msg); m_last = msg; m_lastMessageInserted = msg; @@ -275,23 +275,23 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) { // Find the position within the player's section based on the command ID. // If the command type doesn't require a command ID, sort by whatever it should be sorted by. - while ((tempmsg != NULL) && (msg->getCommand()->getNetCommandType() == tempmsg->getCommand()->getNetCommandType()) && (msg->getCommand()->getPlayerID() == tempmsg->getCommand()->getPlayerID()) && (msg->getCommand()->getSortNumber() > tempmsg->getCommand()->getSortNumber())) { + while ((tempmsg != nullptr) && (msg->getCommand()->getNetCommandType() == tempmsg->getCommand()->getNetCommandType()) && (msg->getCommand()->getPlayerID() == tempmsg->getCommand()->getPlayerID()) && (msg->getCommand()->getSortNumber() > tempmsg->getCommand()->getSortNumber())) { tempmsg = tempmsg->getNext(); } - if (tempmsg == NULL) { + if (tempmsg == nullptr) { // Make sure this command isn't already in the list. if (isEqualCommandMsg(m_last->getCommand(), msg->getCommand())) { // This command is already in the list, don't duplicate it. deleteInstance(msg); - msg = NULL; - return NULL; + msg = nullptr; + return nullptr; } // This message goes at the end of the list. msg->setPrev(m_last); - msg->setNext(NULL); + msg->setNext(nullptr); m_last->setNext(msg); m_last = msg; m_lastMessageInserted = msg; @@ -304,12 +304,12 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) { // This command is already in the list, don't duplicate it. deleteInstance(msg); - return NULL; + return nullptr; } // This message goes at the head of the list. msg->setNext(m_first); - msg->setPrev(NULL); + msg->setPrev(nullptr); m_first->setPrev(msg); m_first = msg; m_lastMessageInserted = msg; @@ -321,8 +321,8 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) { // This command is already in the list, don't duplicate it. deleteInstance(msg); - msg = NULL; - return NULL; + msg = nullptr; + return nullptr; } // Insert message before tempmsg. @@ -338,7 +338,7 @@ NetCommandRef * NetCommandList::addMessage(NetCommandMsg *cmdMsg) { Int NetCommandList::length() { Int retval = 0; NetCommandRef *temp = m_first; - while (temp != NULL) { + while (temp != nullptr) { ++retval; temp = temp->getNext(); } @@ -351,7 +351,7 @@ Int NetCommandList::length() { */ NetCommandRef * NetCommandList::findMessage(NetCommandMsg *msg) { NetCommandRef *retval = m_first; - while ((retval != NULL) && (isEqualCommandMsg(retval->getCommand(), msg) == FALSE)) { + while ((retval != nullptr) && (isEqualCommandMsg(retval->getCommand(), msg) == FALSE)) { retval = retval->getNext(); } return retval; @@ -359,7 +359,7 @@ NetCommandRef * NetCommandList::findMessage(NetCommandMsg *msg) { NetCommandRef * NetCommandList::findMessage(UnsignedShort commandID, UnsignedByte playerID) { NetCommandRef *retval = m_first; - while (retval != NULL) { + while (retval != nullptr) { if (DoesCommandRequireACommandID(retval->getCommand()->getNetCommandType())) { if ((retval->getCommand()->getID() == commandID) && (retval->getCommand()->getPlayerID() == playerID)) { return retval; diff --git a/Core/GameEngine/Source/GameNetwork/NetCommandMsg.cpp b/Core/GameEngine/Source/GameNetwork/NetCommandMsg.cpp index ea6d56b7285..6748e094f46 100644 --- a/Core/GameEngine/Source/GameNetwork/NetCommandMsg.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetCommandMsg.cpp @@ -26,6 +26,8 @@ #include "PreRTS.h" // This must go first in EVERY cpp file in the GameEngine #include "GameNetwork/NetCommandMsg.h" +#include "GameNetwork/NetPacketStructs.h" +#include "GameNetwork/GameMessageParser.h" #include "Common/GameState.h" #include "Common/PlayerList.h" #include "Common/Player.h" @@ -90,8 +92,8 @@ NetGameCommandMsg::NetGameCommandMsg() : NetCommandMsg() { m_numArgs = 0; m_type = (GameMessage::Type)0; m_commandType = NETCOMMANDTYPE_GAMECOMMAND; - m_argList = NULL; - m_argTail = NULL; + m_argList = nullptr; + m_argTail = nullptr; } /** @@ -113,7 +115,7 @@ NetGameCommandMsg::NetGameCommandMsg(GameMessage *msg) : NetCommandMsg() { */ NetGameCommandMsg::~NetGameCommandMsg() { GameMessageArgument *arg = m_argList; - while (arg != NULL) { + while (arg != nullptr) { m_argList = m_argList->m_next; deleteInstance(arg); arg = m_argList; @@ -125,19 +127,19 @@ NetGameCommandMsg::~NetGameCommandMsg() { */ void NetGameCommandMsg::addArgument(const GameMessageArgumentDataType type, GameMessageArgumentType arg) { - if (m_argTail == NULL) { + if (m_argTail == nullptr) { m_argList = newInstance(GameMessageArgument); m_argTail = m_argList; m_argList->m_data = arg; m_argList->m_type = type; - m_argList->m_next = NULL; + m_argList->m_next = nullptr; return; } GameMessageArgument *newArg = newInstance(GameMessageArgument); newArg->m_data = arg; newArg->m_type = type; - newArg->m_next = NULL; + newArg->m_next = nullptr; m_argTail->m_next = newArg; m_argTail = newArg; } @@ -145,7 +147,7 @@ void NetGameCommandMsg::addArgument(const GameMessageArgumentDataType type, Game // here's where we figure out which slot corresponds to which player static Int indexFromMask(UnsignedInt mask) { - Player *player = NULL; + Player *player = nullptr; Int i; for( i = 0; i < MAX_PLAYER_COUNT; i++ ) @@ -161,7 +163,7 @@ static Int indexFromMask(UnsignedInt mask) /** * Construct a new GameMessage object from the data in this object. */ -GameMessage *NetGameCommandMsg::constructGameMessage() +GameMessage *NetGameCommandMsg::constructGameMessage() const { GameMessage *retval = newInstance(GameMessage)(m_type); @@ -170,7 +172,7 @@ GameMessage *NetGameCommandMsg::constructGameMessage() retval->friend_setPlayerIndex( ThePlayerList->findPlayerWithNameKey(TheNameKeyGenerator->nameToKey(name))->getPlayerIndex()); GameMessageArgument *arg = m_argList; - while (arg != NULL) { + while (arg != nullptr) { switch (arg->m_type) { @@ -222,6 +224,72 @@ void NetGameCommandMsg::setGameMessageType(GameMessage::Type type) { m_type = type; } +size_t NetGameCommandMsg::getPackedByteCount() const { + UnsignedShort msglen = sizeof(NetPacketGameCommand); + + // Variable data portion + GameMessage *gmsg = constructGameMessage(); + GameMessageParser *parser = newInstance(GameMessageParser)(gmsg); + + msglen += sizeof(GameMessage::Type); + msglen += sizeof(UnsignedByte); + + GameMessageParserArgumentType *arg = parser->getFirstArgumentType(); + while (arg != nullptr) { + msglen += sizeof(UnsignedByte); // argument type + msglen += sizeof(UnsignedByte); // argument count + GameMessageArgumentDataType type = arg->getType(); + + switch (type) { + + case ARGUMENTDATATYPE_INTEGER: + msglen += arg->getArgCount() * sizeof(Int); + break; + case ARGUMENTDATATYPE_REAL: + msglen += arg->getArgCount() * sizeof(Real); + break; + case ARGUMENTDATATYPE_BOOLEAN: + msglen += arg->getArgCount() * sizeof(Bool); + break; + case ARGUMENTDATATYPE_OBJECTID: + msglen += arg->getArgCount() * sizeof(ObjectID); + break; + case ARGUMENTDATATYPE_DRAWABLEID: + msglen += arg->getArgCount() * sizeof(DrawableID); + break; + case ARGUMENTDATATYPE_TEAMID: + msglen += arg->getArgCount() * sizeof(UnsignedInt); + break; + case ARGUMENTDATATYPE_LOCATION: + msglen += arg->getArgCount() * sizeof(Coord3D); + break; + case ARGUMENTDATATYPE_PIXEL: + msglen += arg->getArgCount() * sizeof(ICoord2D); + break; + case ARGUMENTDATATYPE_PIXELREGION: + msglen += arg->getArgCount() * sizeof(IRegion2D); + break; + case ARGUMENTDATATYPE_TIMESTAMP: + msglen += arg->getArgCount() * sizeof(UnsignedInt); + break; + case ARGUMENTDATATYPE_WIDECHAR: + msglen += arg->getArgCount() * sizeof(WideChar); + break; + + } + + arg = arg->getNext(); + } + + deleteInstance(parser); + parser = nullptr; + + deleteInstance(gmsg); + gmsg = nullptr; + + return msglen; +} + //------------------------- // NetAckBothCommandMsg //------------------------- @@ -279,6 +347,10 @@ Int NetAckBothCommandMsg::getSortNumber() { return m_commandID; } +size_t NetAckBothCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketAckCommand); +} + //------------------------- // NetAckStage1CommandMsg //------------------------- @@ -336,6 +408,10 @@ Int NetAckStage1CommandMsg::getSortNumber() { return m_commandID; } +size_t NetAckStage1CommandMsg::getPackedByteCount() const { + return sizeof(NetPacketAckCommand); +} + //------------------------- // NetAckStage2CommandMsg //------------------------- @@ -393,6 +469,10 @@ Int NetAckStage2CommandMsg::getSortNumber() { return m_commandID; } +size_t NetAckStage2CommandMsg::getPackedByteCount() const { + return sizeof(NetPacketAckCommand); +} + //------------------------- // NetFrameCommandMsg //------------------------- @@ -424,6 +504,10 @@ UnsignedShort NetFrameCommandMsg::getCommandCount() { return m_commandCount; } +size_t NetFrameCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketFrameCommand); +} + //------------------------- // NetPlayerLeaveCommandMsg //------------------------- @@ -455,6 +539,10 @@ void NetPlayerLeaveCommandMsg::setLeavingPlayerID(UnsignedByte id) { m_leavingPlayerID = id; } +size_t NetPlayerLeaveCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketPlayerLeaveCommand); +} + //------------------------- // NetRunAheadMetricsCommandMsg //------------------------- @@ -501,6 +589,10 @@ Int NetRunAheadMetricsCommandMsg::getAverageFps() { return m_averageFps; } +size_t NetRunAheadMetricsCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketRunAheadMetricsCommand); +} + //------------------------- // NetRunAheadCommandMsg //------------------------- @@ -529,6 +621,10 @@ void NetRunAheadCommandMsg::setFrameRate(UnsignedByte frameRate) { m_frameRate = frameRate; } +size_t NetRunAheadCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketRunAheadCommand); +} + //------------------------- // NetDestroyPlayerCommandMsg //------------------------- @@ -564,6 +660,10 @@ UnsignedInt NetDestroyPlayerCommandMsg::getPlayerIndex( void ) return m_playerIndex; } +size_t NetDestroyPlayerCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketDestroyPlayerCommand); +} + //------------------------- // NetKeepAliveCommandMsg //------------------------- @@ -577,6 +677,10 @@ NetKeepAliveCommandMsg::NetKeepAliveCommandMsg() : NetCommandMsg() { NetKeepAliveCommandMsg::~NetKeepAliveCommandMsg() { } +size_t NetKeepAliveCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketKeepAliveCommand); +} + //------------------------- // NetDisconnectKeepAliveCommandMsg //------------------------- @@ -590,6 +694,10 @@ NetDisconnectKeepAliveCommandMsg::NetDisconnectKeepAliveCommandMsg() : NetComman NetDisconnectKeepAliveCommandMsg::~NetDisconnectKeepAliveCommandMsg() { } +size_t NetDisconnectKeepAliveCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketDisconnectKeepAliveCommand); +} + //------------------------- // NetDisconnectPlayerCommandMsg //------------------------- @@ -635,6 +743,10 @@ UnsignedInt NetDisconnectPlayerCommandMsg::getDisconnectFrame() { return m_disconnectFrame; } +size_t NetDisconnectPlayerCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketDisconnectPlayerCommand); +} + //------------------------- // NetPacketRouterQueryCommandMsg //------------------------- @@ -651,6 +763,10 @@ NetPacketRouterQueryCommandMsg::NetPacketRouterQueryCommandMsg() : NetCommandMsg NetPacketRouterQueryCommandMsg::~NetPacketRouterQueryCommandMsg() { } +size_t NetPacketRouterQueryCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketRouterQueryCommand); +} + //------------------------- // NetPacketRouterAckCommandMsg //------------------------- @@ -667,6 +783,10 @@ NetPacketRouterAckCommandMsg::NetPacketRouterAckCommandMsg() : NetCommandMsg() { NetPacketRouterAckCommandMsg::~NetPacketRouterAckCommandMsg() { } +size_t NetPacketRouterAckCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketRouterAckCommand); +} + //------------------------- // NetDisconnectChatCommandMsg //------------------------- @@ -748,6 +868,22 @@ void NetChatCommandMsg::setPlayerMask( Int playerMask ) m_playerMask = playerMask; } +size_t NetChatCommandMsg::getPackedByteCount() const +{ + return sizeof(NetPacketChatCommand) + + m_text.getByteCount() + + sizeof(m_playerMask); +} + +//------------------------- +// NetDisconnectChatCommandMsg +//------------------------- +size_t NetDisconnectChatCommandMsg::getPackedByteCount() const +{ + return sizeof(NetPacketDisconnectChatCommand) + + m_text.getByteCount(); +} + //------------------------- // NetDisconnectVoteCommandMsg //------------------------- @@ -793,6 +929,10 @@ void NetDisconnectVoteCommandMsg::setVoteFrame(UnsignedInt voteFrame) { m_voteFrame = voteFrame; } +size_t NetDisconnectVoteCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketDisconnectVoteCommand); +} + //------------------------- // NetProgressCommandMsg //------------------------- @@ -814,13 +954,17 @@ void NetProgressCommandMsg::setPercentage( UnsignedByte percent ) m_percent = percent; } +size_t NetProgressCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketProgressCommand); +} + //------------------------- // NetWrapperCommandMsg //------------------------- NetWrapperCommandMsg::NetWrapperCommandMsg() : NetCommandMsg() { m_commandType = NETCOMMANDTYPE_WRAPPER; m_numChunks = 0; - m_data = NULL; + m_data = nullptr; m_totalDataLength = 0; m_chunkNumber = 0; m_dataLength = 0; @@ -829,8 +973,8 @@ NetWrapperCommandMsg::NetWrapperCommandMsg() : NetCommandMsg() { } NetWrapperCommandMsg::~NetWrapperCommandMsg() { - delete m_data; - m_data = NULL; + delete[] m_data; + m_data = nullptr; } UnsignedByte * NetWrapperCommandMsg::getData() { @@ -839,7 +983,7 @@ UnsignedByte * NetWrapperCommandMsg::getData() { void NetWrapperCommandMsg::setData(UnsignedByte *data, UnsignedInt dataLength) { - delete m_data; + delete[] m_data; m_data = NEW UnsignedByte[dataLength]; // pool[]ify memcpy(m_data, data, dataLength); m_dataLength = dataLength; @@ -889,19 +1033,23 @@ void NetWrapperCommandMsg::setWrappedCommandID(UnsignedShort wrappedCommandID) { m_wrappedCommandID = wrappedCommandID; } +size_t NetWrapperCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketWrapperCommand) + m_dataLength; +} + //------------------------- // NetFileCommandMsg //------------------------- NetFileCommandMsg::NetFileCommandMsg() : NetCommandMsg() { m_commandType = NETCOMMANDTYPE_FILE; - m_data = NULL; + m_data = nullptr; m_portableFilename.clear(); m_dataLength = 0; } NetFileCommandMsg::~NetFileCommandMsg() { delete[] m_data; - m_data = NULL; + m_data = nullptr; } AsciiString NetFileCommandMsg::getRealFilename() @@ -929,6 +1077,14 @@ void NetFileCommandMsg::setFileData(UnsignedByte *data, UnsignedInt dataLength) memcpy(m_data, data, dataLength); } +size_t NetFileCommandMsg::getPackedByteCount() const +{ + return sizeof(NetPacketFileCommand) + + m_portableFilename.getLength() + 1 + + sizeof(m_dataLength) + + m_dataLength; +} + //------------------------- // NetFileAnnounceCommandMsg //------------------------- @@ -968,6 +1124,13 @@ void NetFileAnnounceCommandMsg::setPlayerMask(UnsignedByte playerMask) { m_playerMask = playerMask; } +size_t NetFileAnnounceCommandMsg::getPackedByteCount() const +{ + return sizeof(NetPacketFileAnnounceCommand) + + m_portableFilename.getLength() + 1 + + sizeof(m_fileID) + + sizeof(m_playerMask); +} //------------------------- // NetFileProgressCommandMsg @@ -997,6 +1160,10 @@ void NetFileProgressCommandMsg::setProgress(Int val) { m_progress = val; } +size_t NetFileProgressCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketFileProgressCommand); +} + //------------------------- // NetDisconnectFrameCommandMsg //------------------------- @@ -1016,6 +1183,10 @@ void NetDisconnectFrameCommandMsg::setDisconnectFrame(UnsignedInt disconnectFram m_disconnectFrame = disconnectFrame; } +size_t NetDisconnectFrameCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketDisconnectFrameCommand); +} + //------------------------- // NetDisconnectScreenOffCommandMsg //------------------------- @@ -1035,6 +1206,10 @@ void NetDisconnectScreenOffCommandMsg::setNewFrame(UnsignedInt newFrame) { m_newFrame = newFrame; } +size_t NetDisconnectScreenOffCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketDisconnectScreenOffCommand); +} + //------------------------- // NetFrameResendRequestCommandMsg //------------------------- @@ -1053,3 +1228,35 @@ UnsignedInt NetFrameResendRequestCommandMsg::getFrameToResend() { void NetFrameResendRequestCommandMsg::setFrameToResend(UnsignedInt frame) { m_frameToResend = frame; } + +size_t NetFrameResendRequestCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketFrameResendRequestCommand); +} + +//------------------------- +// NetLoadCompleteCommandMsg +//------------------------- +NetLoadCompleteCommandMsg::NetLoadCompleteCommandMsg() : NetCommandMsg() { + m_commandType = NETCOMMANDTYPE_LOADCOMPLETE; +} + +NetLoadCompleteCommandMsg::~NetLoadCompleteCommandMsg() { +} + +size_t NetLoadCompleteCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketLoadCompleteCommand); +} + +//------------------------- +// NetTimeOutGameStartCommandMsg +//------------------------- +NetTimeOutGameStartCommandMsg::NetTimeOutGameStartCommandMsg() : NetCommandMsg() { + m_commandType = NETCOMMANDTYPE_TIMEOUTSTART; +} + +NetTimeOutGameStartCommandMsg::~NetTimeOutGameStartCommandMsg() { +} + +size_t NetTimeOutGameStartCommandMsg::getPackedByteCount() const { + return sizeof(NetPacketTimeOutGameStartCommand); +} diff --git a/Core/GameEngine/Source/GameNetwork/NetCommandRef.cpp b/Core/GameEngine/Source/GameNetwork/NetCommandRef.cpp index 6e767e961ae..470a387ff77 100644 --- a/Core/GameEngine/Source/GameNetwork/NetCommandRef.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetCommandRef.cpp @@ -41,8 +41,8 @@ NetCommandRef::NetCommandRef(NetCommandMsg *msg) #endif { m_msg = msg; - m_next = NULL; - m_prev = NULL; + m_next = nullptr; + m_prev = nullptr; m_msg->attach(); m_timeLastSent = -1; @@ -57,12 +57,12 @@ NetCommandRef::NetCommandRef(NetCommandMsg *msg) */ NetCommandRef::~NetCommandRef() { - if (m_msg != NULL) + if (m_msg != nullptr) { m_msg->detach(); } - DEBUG_ASSERTCRASH(m_next == NULL, ("NetCommandRef::~NetCommandRef - m_next != NULL")); - DEBUG_ASSERTCRASH(m_prev == NULL, ("NetCommandRef::~NetCommandRef - m_prev != NULL")); + DEBUG_ASSERTCRASH(m_next == nullptr, ("NetCommandRef::~NetCommandRef - m_next != nullptr")); + DEBUG_ASSERTCRASH(m_prev == nullptr, ("NetCommandRef::~NetCommandRef - m_prev != nullptr")); #ifdef DEBUG_NETCOMMANDREF DEBUG_LOG(("NetCommandRef %d deleted", m_id)); diff --git a/Core/GameEngine/Source/GameNetwork/NetCommandWrapperList.cpp b/Core/GameEngine/Source/GameNetwork/NetCommandWrapperList.cpp index 86333e90168..6ff3e142c2e 100644 --- a/Core/GameEngine/Source/GameNetwork/NetCommandWrapperList.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetCommandWrapperList.cpp @@ -36,7 +36,7 @@ NetCommandWrapperListNode::NetCommandWrapperListNode(NetWrapperCommandMsg *msg) { - m_next = NULL; + m_next = nullptr; m_numChunks = msg->getNumChunks(); m_chunksPresent = NEW Bool[m_numChunks]; // pool[]ify m_numChunksPresent = 0; @@ -53,10 +53,10 @@ NetCommandWrapperListNode::NetCommandWrapperListNode(NetWrapperCommandMsg *msg) NetCommandWrapperListNode::~NetCommandWrapperListNode() { delete[] m_chunksPresent; - m_chunksPresent = NULL; + m_chunksPresent = nullptr; delete[] m_data; - m_data = NULL; + m_data = nullptr; } Bool NetCommandWrapperListNode::isComplete() { @@ -79,7 +79,7 @@ UnsignedInt NetCommandWrapperListNode::getRawDataLength() { } void NetCommandWrapperListNode::copyChunkData(NetWrapperCommandMsg *msg) { - if (msg == NULL) { + if (msg == nullptr) { DEBUG_CRASH(("Trying to copy data from a non-existent wrapper command message")); return; } @@ -132,12 +132,12 @@ UnsignedByte * NetCommandWrapperListNode::getRawData() { //////////////////////////////////////////////////////////////////////////////////////////////////// NetCommandWrapperList::NetCommandWrapperList() { - m_list = NULL; + m_list = nullptr; } NetCommandWrapperList::~NetCommandWrapperList() { NetCommandWrapperListNode *temp; - while (m_list != NULL) { + while (m_list != nullptr) { temp = m_list->m_next; deleteInstance(m_list); m_list = temp; @@ -145,12 +145,12 @@ NetCommandWrapperList::~NetCommandWrapperList() { } void NetCommandWrapperList::init() { - m_list = NULL; + m_list = nullptr; } void NetCommandWrapperList::reset() { NetCommandWrapperListNode *temp; - while (m_list != NULL) { + while (m_list != nullptr) { temp = m_list->m_next; deleteInstance(m_list); m_list = temp; @@ -161,7 +161,7 @@ Int NetCommandWrapperList::getPercentComplete(UnsignedShort wrappedCommandID) { NetCommandWrapperListNode *temp = m_list; - while ((temp != NULL) && (temp->getCommandID() != wrappedCommandID)) { + while ((temp != nullptr) && (temp->getCommandID() != wrappedCommandID)) { temp = temp->m_next; } @@ -175,11 +175,11 @@ void NetCommandWrapperList::processWrapper(NetCommandRef *ref) { NetCommandWrapperListNode *temp = m_list; NetWrapperCommandMsg *msg = (NetWrapperCommandMsg *)(ref->getCommand()); - while ((temp != NULL) && (temp->getCommandID() != msg->getWrappedCommandID())) { + while ((temp != nullptr) && (temp->getCommandID() != msg->getWrappedCommandID())) { temp = temp->m_next; } - if (temp == NULL) { + if (temp == nullptr) { temp = newInstance(NetCommandWrapperListNode)(msg); temp->m_next = m_list; m_list = temp; @@ -194,9 +194,9 @@ NetCommandList * NetCommandWrapperList::getReadyCommands() retlist->init(); NetCommandWrapperListNode *temp = m_list; - NetCommandWrapperListNode *next = NULL; + NetCommandWrapperListNode *next = nullptr; - while (temp != NULL) { + while (temp != nullptr) { next = temp->m_next; if (temp->isComplete()) { NetCommandRef *msg = NetPacket::ConstructNetCommandMsgFromRawData(temp->getRawData(), temp->getRawDataLength()); @@ -204,10 +204,10 @@ NetCommandList * NetCommandWrapperList::getReadyCommands() ret->setRelay(msg->getRelay()); deleteInstance(msg); - msg = NULL; + msg = nullptr; removeFromList(temp); - temp = NULL; + temp = nullptr; } temp = next; } @@ -216,29 +216,29 @@ NetCommandList * NetCommandWrapperList::getReadyCommands() } void NetCommandWrapperList::removeFromList(NetCommandWrapperListNode *node) { - if (node == NULL) { + if (node == nullptr) { return; } NetCommandWrapperListNode *temp = m_list; - NetCommandWrapperListNode *prev = NULL; + NetCommandWrapperListNode *prev = nullptr; - while ((temp != NULL) && (temp->getCommandID() != node->getCommandID())) { + while ((temp != nullptr) && (temp->getCommandID() != node->getCommandID())) { prev = temp; temp = temp->m_next; } - if (temp == NULL) { + if (temp == nullptr) { return; } - if (prev == NULL) { + if (prev == nullptr) { m_list = temp->m_next; deleteInstance(temp); - temp = NULL; + temp = nullptr; } else { prev->m_next = temp->m_next; deleteInstance(temp); - temp = NULL; + temp = nullptr; } } diff --git a/Core/GameEngine/Source/GameNetwork/NetMessageStream.cpp b/Core/GameEngine/Source/GameNetwork/NetMessageStream.cpp index 43f5cd6da28..c2855eca5ce 100644 --- a/Core/GameEngine/Source/GameNetwork/NetMessageStream.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetMessageStream.cpp @@ -43,24 +43,24 @@ // The per-player pointers for the list of commands static CommandMsg *CommandHead[MAX_SLOTS] = { /// @todo: remove static initialization - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr }; static CommandMsg *CommandTail[MAX_SLOTS] = { - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr }; /** @@ -75,7 +75,7 @@ static Bool AddToNetCommandList(GameMessage *msg, UnsignedInt timestamp, Command return false; } - if (CommandTail == NULL) + if (CommandTail == nullptr) { CommandHead = cmdMsg; CommandTail = cmdMsg; @@ -91,7 +91,7 @@ static Bool AddToNetCommandList(GameMessage *msg, UnsignedInt timestamp, Command } /** - * AddToRemoteNetCommandList is used by TheNetwork to queue up commands recieved from other players. + * AddToRemoteNetCommandList is used by TheNetwork to queue up commands received from other players. * Bool AddToNetCommandList(Int playerNum, GameMessage *msg, UnsignedInt timestamp) { @@ -104,32 +104,32 @@ Bool AddToNetCommandList(Int playerNum, GameMessage *msg, UnsignedInt timestamp) /** * GetCommandMsg returns a GameMessage (deleting its CommandMsg wrapper) that is valid - * for the current frame, or NULL. + * for the current frame, or nullptr. * static GameMessage * GetCommandMsg(UnsignedInt timestamp, CommandMsg *& CommandHead, CommandMsg *& CommandTail) { if (!CommandHead) - return NULL; + return nullptr; if (CommandHead->GetTimestamp() < timestamp) { DEBUG_LOG(("Time is %d, yet message timestamp is %d!", timestamp, CommandHead->GetTimestamp())); - return NULL; + return nullptr; } if (CommandHead->GetTimestamp() != timestamp) - return NULL; + return nullptr; CommandMsg *theMsg = CommandHead; if (CommandHead->GetNextCommandMsg()) { - CommandHead->GetNextCommandMsg()->SetPrevCommandMsg(NULL); + CommandHead->GetNextCommandMsg()->SetPrevCommandMsg(nullptr); CommandHead = CommandHead->GetNextCommandMsg(); } else { - CommandHead = CommandTail = NULL; + CommandHead = CommandTail = nullptr; } GameMessage *msg = theMsg->GetGameMessage(); @@ -143,7 +143,7 @@ static GameMessage * GetCommandMsg(UnsignedInt timestamp, CommandMsg *& CommandH GameMessage * GetCommandMsg(UnsignedInt timestamp, Int playerNum) { if (playerNum < 0 || playerNum >= MAX_SLOTS) - return NULL; + return nullptr; //DEBUG_LOG(("Adding msg to NetCommandList %d", playerNum)); return GetCommandMsg(timestamp, CommandHead[playerNum], CommandTail[playerNum]); diff --git a/Core/GameEngine/Source/GameNetwork/NetPacket.cpp b/Core/GameEngine/Source/GameNetwork/NetPacket.cpp index be74404bae5..66546da7190 100644 --- a/Core/GameEngine/Source/GameNetwork/NetPacket.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetPacket.cpp @@ -31,18 +31,9 @@ #include "GameNetwork/NetworkDefs.h" #include "GameNetwork/networkutil.h" #include "GameNetwork/GameMessageParser.h" +#include "GameNetwork/NetPacketStructs.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 -} +// TheSuperHackers @refactor BobTista 31/12/2025 Use packed structs for FillBufferWithXXX serialization // This function assumes that all of the fields are either of default value or are // present in the raw data. @@ -54,8 +45,8 @@ NetCommandRef * NetPacket::ConstructNetCommandMsgFromRawData(UnsignedByte *data, UnsignedByte relay = 0; Int offset = 0; - NetCommandRef *ref = NULL; - NetCommandMsg *msg = NULL; + NetCommandRef *ref = nullptr; + NetCommandMsg *msg = nullptr; while (offset < (Int)dataLength) { @@ -190,7 +181,7 @@ NetCommandRef * NetPacket::ConstructNetCommandMsgFromRawData(UnsignedByte *data, ref->setRelay(relay); msg->detach(); - msg = NULL; + msg = nullptr; return ref; @@ -213,7 +204,7 @@ NetPacketList NetPacket::ConstructBigCommandPacketList(NetCommandRef *ref) { } UnsignedInt bufferSize = GetBufferSizeNeededForCommand(msg); // need to implement. I have a drinking problem. - UnsignedByte *bigPacketData = NULL; + UnsignedByte *bigPacketData = nullptr; NetPacketList packetList; @@ -268,15 +259,15 @@ NetPacketList NetPacket::ConstructBigCommandPacketList(NetCommandRef *ref) { packetList.push_back(packet); deleteInstance(ref); - ref = NULL; + ref = nullptr; ++currentChunk; } wrapperMsg->detach(); - wrapperMsg = NULL; + wrapperMsg = nullptr; delete[] bigPacketData; - bigPacketData = NULL; + bigPacketData = nullptr; return packetList; } @@ -284,523 +275,14 @@ NetPacketList NetPacket::ConstructBigCommandPacketList(NetCommandRef *ref) { UnsignedInt NetPacket::GetBufferSizeNeededForCommand(NetCommandMsg *msg) { // This is where the fun begins... - if (msg == NULL) { + if (msg == nullptr) { return TRUE; // There was nothing to add, so it was successful. } - - switch(msg->getNetCommandType()) - { - case NETCOMMANDTYPE_GAMECOMMAND: - return GetGameCommandSize(msg); - case NETCOMMANDTYPE_ACKSTAGE1: - case NETCOMMANDTYPE_ACKSTAGE2: - case NETCOMMANDTYPE_ACKBOTH: - return GetAckCommandSize(msg); - case NETCOMMANDTYPE_FRAMEINFO: - return GetFrameCommandSize(msg); - case NETCOMMANDTYPE_PLAYERLEAVE: - return GetPlayerLeaveCommandSize(msg); - case NETCOMMANDTYPE_RUNAHEADMETRICS: - return GetRunAheadMetricsCommandSize(msg); - case NETCOMMANDTYPE_RUNAHEAD: - return GetRunAheadCommandSize(msg); - case NETCOMMANDTYPE_DESTROYPLAYER: - return GetDestroyPlayerCommandSize(msg); - case NETCOMMANDTYPE_KEEPALIVE: - return GetKeepAliveCommandSize(msg); - case NETCOMMANDTYPE_DISCONNECTKEEPALIVE: - return GetDisconnectKeepAliveCommandSize(msg); - case NETCOMMANDTYPE_DISCONNECTPLAYER: - return GetDisconnectPlayerCommandSize(msg); - case NETCOMMANDTYPE_PACKETROUTERQUERY: - return GetPacketRouterQueryCommandSize(msg); - case NETCOMMANDTYPE_PACKETROUTERACK: - return GetPacketRouterAckCommandSize(msg); - case NETCOMMANDTYPE_DISCONNECTCHAT: - return GetDisconnectChatCommandSize(msg); - case NETCOMMANDTYPE_DISCONNECTVOTE: - return GetDisconnectVoteCommandSize(msg); - case NETCOMMANDTYPE_CHAT: - return GetChatCommandSize(msg); - case NETCOMMANDTYPE_PROGRESS: - return GetProgressMessageSize(msg); - case NETCOMMANDTYPE_LOADCOMPLETE: - return GetLoadCompleteMessageSize(msg); - case NETCOMMANDTYPE_TIMEOUTSTART: - return GetTimeOutGameStartMessageSize(msg); - case NETCOMMANDTYPE_WRAPPER: - return GetWrapperCommandSize(msg); - case NETCOMMANDTYPE_FILE: - return GetFileCommandSize(msg); - case NETCOMMANDTYPE_FILEANNOUNCE: - return GetFileAnnounceCommandSize(msg); - case NETCOMMANDTYPE_FILEPROGRESS: - return GetFileProgressCommandSize(msg); - case NETCOMMANDTYPE_DISCONNECTFRAME: - return GetDisconnectFrameCommandSize(msg); - case NETCOMMANDTYPE_DISCONNECTSCREENOFF: - return GetDisconnectScreenOffCommandSize(msg); - case NETCOMMANDTYPE_FRAMERESENDREQUEST: - return GetFrameResendRequestCommandSize(msg); - default: - DEBUG_CRASH(("Unknown NETCOMMANDTYPE %d", msg->getNetCommandType())); - break; - } - - return 0; -} - -UnsignedInt NetPacket::GetGameCommandSize(NetCommandMsg *msg) { - NetGameCommandMsg *cmdMsg = (NetGameCommandMsg *)msg; - - UnsignedShort msglen = 0; - msglen += sizeof(UnsignedInt) + sizeof(UnsignedByte); // frame number - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // player ID - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // relay - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); // command type - msglen += sizeof(UnsignedShort) + sizeof(UnsignedByte); // command ID - msglen += sizeof(UnsignedByte); // the NetPacketFieldTypes::Data for the data section. - - GameMessage *gmsg = cmdMsg->constructGameMessage(); - GameMessageParser *parser = newInstance(GameMessageParser)(gmsg); - - msglen += sizeof(GameMessage::Type); - msglen += sizeof(UnsignedByte); -// Int numTypes = parser->getNumTypes(); - GameMessageParserArgumentType *arg = parser->getFirstArgumentType(); - while (arg != NULL) { - msglen += 2 * sizeof(UnsignedByte); // for the type and number of args of that type declaration. - GameMessageArgumentDataType type = arg->getType(); - - switch (type) { - - case ARGUMENTDATATYPE_INTEGER: - msglen += arg->getArgCount() * sizeof(Int); - break; - case ARGUMENTDATATYPE_REAL: - msglen += arg->getArgCount() * sizeof(Real); - break; - case ARGUMENTDATATYPE_BOOLEAN: - msglen += arg->getArgCount() * sizeof(Bool); - break; - case ARGUMENTDATATYPE_OBJECTID: - msglen += arg->getArgCount() * sizeof(ObjectID); - break; - case ARGUMENTDATATYPE_DRAWABLEID: - msglen += arg->getArgCount() * sizeof(DrawableID); - break; - case ARGUMENTDATATYPE_TEAMID: - msglen += arg->getArgCount() * sizeof(UnsignedInt); - break; - case ARGUMENTDATATYPE_LOCATION: - msglen += arg->getArgCount() * sizeof(Coord3D); - break; - case ARGUMENTDATATYPE_PIXEL: - msglen += arg->getArgCount() * sizeof(ICoord2D); - break; - case ARGUMENTDATATYPE_PIXELREGION: - msglen += arg->getArgCount() * sizeof(IRegion2D); - break; - case ARGUMENTDATATYPE_TIMESTAMP: - msglen += arg->getArgCount() * sizeof(UnsignedInt); - break; - case ARGUMENTDATATYPE_WIDECHAR: - msglen += arg->getArgCount() * sizeof(WideChar); - break; - - } - - arg = arg->getNext(); - } - - deleteInstance(parser); - parser = NULL; - - deleteInstance(gmsg); - gmsg = NULL; - - return msglen; -} - -UnsignedInt NetPacket::GetAckCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - ++msglen; - msglen += sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - - ++msglen; - msglen += sizeof(UnsignedShort); - msglen += sizeof(UnsignedByte); - - return msglen; -} - -UnsignedInt NetPacket::GetFrameCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedInt) + sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedShort) + sizeof(UnsignedByte); - - ++msglen; - msglen += sizeof(UnsignedShort); - - return msglen; -} - -UnsignedInt NetPacket::GetPlayerLeaveCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - msglen += sizeof(UnsignedInt) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedShort) + sizeof(UnsignedByte); - - ++msglen; - msglen += sizeof(UnsignedByte); - - return msglen; -} - -UnsignedInt NetPacket::GetRunAheadMetricsCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedShort) + sizeof(UnsignedByte); - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(Real); - - return msglen; -} - -UnsignedInt NetPacket::GetRunAheadCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - msglen += sizeof(UnsignedInt) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedShort) + sizeof(UnsignedByte); - - ++msglen; - msglen += sizeof(UnsignedShort); - msglen += sizeof(UnsignedByte); - - return msglen; -} - -UnsignedInt NetPacket::GetDestroyPlayerCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - msglen += sizeof(UnsignedInt) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedShort) + sizeof(UnsignedByte); - - ++msglen; - msglen += sizeof(UnsignedInt); - - return msglen; -} - -UnsignedInt NetPacket::GetKeepAliveCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - - ++msglen; // For the NetPacketFieldTypes::Data - - return msglen; -} - -UnsignedInt NetPacket::GetDisconnectKeepAliveCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - - ++msglen; // For the NetPacketFieldTypes::Data - - return msglen; + // Use the virtual function for all command message types + return msg->getPackedByteCount(); } -UnsignedInt NetPacket::GetDisconnectPlayerCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedShort) + sizeof(UnsignedByte); - - ++msglen; // the NetPacketFieldTypes::Data - msglen += sizeof(UnsignedByte); // slot number - msglen += sizeof(UnsignedInt); // disconnect frame - - return msglen; -} - -UnsignedInt NetPacket::GetPacketRouterQueryCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - - ++msglen; // the NetPacketFieldTypes::Data - - return msglen; -} - -UnsignedInt NetPacket::GetPacketRouterAckCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - - ++msglen; // the NetPacketFieldTypes::Data - - return msglen; -} - -UnsignedInt NetPacket::GetDisconnectChatCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - NetDisconnectChatCommandMsg *cmdMsg = (NetDisconnectChatCommandMsg *)(msg); - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - - ++msglen; // the NetPacketFieldTypes::Data - msglen += sizeof(UnsignedByte); // string msglength - UnsignedByte textmsglen = cmdMsg->getText().getLength(); - msglen += textmsglen * sizeof(UnsignedShort); - - return msglen; -} - -UnsignedInt NetPacket::GetDisconnectVoteCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedShort) + sizeof(UnsignedByte); - - ++msglen; // the NetPacketFieldTypes::Data - msglen += sizeof(UnsignedByte); // slot number - msglen += sizeof(UnsignedInt); // vote frame. - - return msglen; -} - -UnsignedInt NetPacket::GetChatCommandSize(NetCommandMsg *msg) { - Int msglen = 0; - NetChatCommandMsg *cmdMsg = (NetChatCommandMsg *)(msg); - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedInt) + sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedShort) + sizeof(UnsignedByte); - - ++msglen; // the NetPacketFieldTypes::Data - msglen += sizeof(UnsignedByte); // string msglength - UnsignedByte textmsglen = cmdMsg->getText().getLength(); - msglen += textmsglen * sizeof(UnsignedShort); - msglen += sizeof(Int); // playerMask - - return msglen; -} - -UnsignedInt NetPacket::GetProgressMessageSize(NetCommandMsg *msg) { - Int msglen = 0; - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - - ++msglen; // For the NetPacketFieldTypes::Data - ++msglen; // percentage - - return msglen; -} - -UnsignedInt NetPacket::GetLoadCompleteMessageSize(NetCommandMsg *msg) { - Int msglen = 0; - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - - ++msglen; // For the NetPacketFieldTypes::Data - - return msglen; -} - -UnsignedInt NetPacket::GetTimeOutGameStartMessageSize(NetCommandMsg *msg) { - Int msglen = 0; - - ++msglen; - msglen += sizeof(UnsignedByte); - msglen += sizeof(UnsignedByte) + sizeof(UnsignedByte); - ++msglen; - msglen += sizeof(UnsignedByte); - - ++msglen; // For the NetPacketFieldTypes::Data - - return msglen; -} - -// type, player, ID, relay, Data -UnsignedInt NetPacket::GetWrapperCommandSize(NetCommandMsg *msg) { - UnsignedInt msglen = 0; - - ++msglen; // NetPacketFieldTypes::CommandType - msglen += sizeof(UnsignedByte); // 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; // NetPacketFieldTypes::Data - - msglen += sizeof(UnsignedShort); // m_wrappedCommandID - msglen += sizeof(UnsignedInt); // m_chunkNumber - msglen += sizeof(UnsignedInt); // m_numChunks - msglen += sizeof(UnsignedInt); // m_totalDataLength - msglen += sizeof(UnsignedInt); // m_dataLength - msglen += sizeof(UnsignedInt); // m_dataOffset - - return msglen; -} - -UnsignedInt NetPacket::GetFileCommandSize(NetCommandMsg *msg) { - NetFileCommandMsg *filemsg = (NetFileCommandMsg *)msg; - UnsignedInt msglen = 0; - 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; // NetPacketFieldTypes::Data - - msglen += filemsg->getPortableFilename().getLength() + 1; // PORTABLE filename and the terminating 0 - msglen += sizeof(UnsignedInt); // file data length - msglen += filemsg->getFileLength(); // the file data - - return msglen; -} -UnsignedInt NetPacket::GetFileAnnounceCommandSize(NetCommandMsg *msg) { - NetFileAnnounceCommandMsg *filemsg = (NetFileAnnounceCommandMsg *)msg; - UnsignedInt msglen = 0; - 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; // NetPacketFieldTypes::Data - - msglen += filemsg->getPortableFilename().getLength() + 1; // PORTABLE filename and the terminating 0 - msglen += sizeof(UnsignedShort); // m_fileID - msglen += sizeof(UnsignedByte); // m_playerMask - - return msglen; -} - -UnsignedInt NetPacket::GetFileProgressCommandSize(NetCommandMsg *msg) { - UnsignedInt msglen = 0; - 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; // NetPacketFieldTypes::Data - - msglen += sizeof(UnsignedShort); // m_fileID - msglen += sizeof(Int); // m_progress - - return msglen; -} - -UnsignedInt NetPacket::GetDisconnectFrameCommandSize(NetCommandMsg *msg) { - UnsignedInt msglen = 0; - 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; // NetPacketFieldTypes::Data - msglen += sizeof(UnsignedInt); // disconnect frame - - return msglen; -} - -UnsignedInt NetPacket::GetDisconnectScreenOffCommandSize(NetCommandMsg *msg) { - UnsignedInt msglen = 0; - 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; // NetPacketFieldTypes::Data - msglen += sizeof(UnsignedInt); // new frame - - return msglen; -} - -UnsignedInt NetPacket::GetFrameResendRequestCommandSize(NetCommandMsg *msg) { - UnsignedInt msglen = 0; - 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; // NetPacketFieldTypes::Data - msglen += sizeof(UnsignedInt); // frame to resend - - return msglen; -} // this function assumes that buffer is already the correct size. void NetPacket::FillBufferWithCommand(UnsignedByte *buffer, NetCommandRef *ref) { @@ -889,48 +371,23 @@ void NetPacket::FillBufferWithCommand(UnsignedByte *buffer, NetCommandRef *ref) } void NetPacket::FillBufferWithGameCommand(UnsignedByte *buffer, NetCommandRef *msg) { - NetGameCommandMsg *cmdMsg = (NetGameCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; + NetGameCommandMsg *cmdMsg = static_cast(msg->getCommand()); // get the game message from the NetCommandMsg GameMessage *gmsg = cmdMsg->constructGameMessage(); //DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::FillBufferWithGameCommand for command ID %d", cmdMsg->getID())); - // If necessary, put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - - // If necessary, put the execution frame into the packet. - 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] = NetPacketFieldTypes::Relay; - ++offset; - UnsignedByte newRelay = msg->getRelay(); - memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); - offset += sizeof(UnsignedByte); + NetPacketGameCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.frame.frame = cmdMsg->getExecutionFrame(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); - // If necessary, put the playerID into the packet. - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - - // If necessary, specify the command ID of this command. - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); + memcpy(buffer, &packet, sizeof(packet)); - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; + // Variable data portion + UnsignedShort offset = sizeof(NetPacketGameCommand); // Now copy the GameMessage type into the packet. GameMessage::Type newType = gmsg->getType(); @@ -944,7 +401,7 @@ void NetPacket::FillBufferWithGameCommand(UnsignedByte *buffer, NetCommandRef *m offset += sizeof(numTypes); GameMessageParserArgumentType *argType = parser->getFirstArgumentType(); - while (argType != NULL) { + while (argType != nullptr) { UnsignedByte type = (UnsignedByte)(argType->getType()); memcpy(buffer + offset, &type, sizeof(type)); offset += sizeof(type); @@ -1012,19 +469,18 @@ void NetPacket::FillBufferWithGameCommand(UnsignedByte *buffer, NetCommandRef *m } deleteInstance(parser); - parser = NULL; + parser = nullptr; // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addGameMessage - added game message, frame %d, player %d, command ID %d", m_lastFrame, m_lastPlayerID, m_lastCommandID)); deleteInstance(gmsg); - gmsg = NULL; + gmsg = nullptr; } void NetPacket::FillBufferWithAckCommand(UnsignedByte *buffer, NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::FillBufferWithAckCommand - adding ack for command %d for player %d", cmdMsg->getCommandID(), msg->getCommand()->getPlayerID())); NetCommandMsg *cmdMsg = msg->getCommand(); - UnsignedShort offset = 0; UnsignedShort commandID = 0; UnsignedByte originalPlayerID = 0; @@ -1054,717 +510,271 @@ void NetPacket::FillBufferWithAckCommand(UnsignedByte *buffer, NetCommandRef *ms break; } - } - - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = type; - offset += sizeof(UnsignedByte); - - 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] = NetPacketFieldTypes::Data; - ++offset; - memcpy(buffer + offset, &commandID, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); - memcpy(buffer + offset, &originalPlayerID, sizeof(UnsignedByte)); - offset += sizeof(UnsignedByte); - - // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("outgoing - added ACK, original player %d, command id %d", origPlayerID, cmdID)); -} - -void NetPacket::FillBufferWithFrameCommand(UnsignedByte *buffer, NetCommandRef *msg) { - NetFrameCommandMsg *cmdMsg = (NetFrameCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; - // 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] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - -// If necessary, put the execution frame into the packet. - 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] = 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] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); - -// If necessary, specify the command ID of this command. - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; - UnsignedShort cmdCount = cmdMsg->getCommandCount(); - memcpy(buffer + offset, &cmdCount, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); - - // 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())); -} - -void NetPacket::FillBufferWithPlayerLeaveCommand(UnsignedByte *buffer, NetCommandRef *msg) { - NetPlayerLeaveCommandMsg *cmdMsg = (NetPlayerLeaveCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; -// 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] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - -// If necessary, put the relay into the packet. - 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] = NetPacketFieldTypes::Frame; - ++offset; - UnsignedInt newframe = cmdMsg->getExecutionFrame(); - memcpy(buffer+offset, &newframe, sizeof(UnsignedInt)); - offset += sizeof(UnsignedInt); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); + } -// If necessary, specify the command ID of this command. - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); + NetPacketAckCommand packet; + packet.commandType.commandType = type; + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId = commandID; + packet.originalPlayerId = originalPlayerID; -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); + memcpy(buffer, &packet, sizeof(packet)); - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; - UnsignedByte leavingPlayerID = cmdMsg->getLeavingPlayerID(); - memcpy(buffer + offset, &leavingPlayerID, sizeof(UnsignedByte)); - offset += sizeof(UnsignedByte); + // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("outgoing - added ACK, original player %d, command id %d", origPlayerID, cmdID)); } -void NetPacket::FillBufferWithRunAheadMetricsCommand(UnsignedByte *buffer, NetCommandRef *msg) { - NetRunAheadMetricsCommandMsg *cmdMsg = (NetRunAheadMetricsCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; -// 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())); +void NetPacket::FillBufferWithFrameCommand(UnsignedByte *buffer, NetCommandRef *msg) { + NetFrameCommandMsg *cmdMsg = static_cast(msg->getCommand()); + // 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] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); + NetPacketFrameCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.frame.frame = cmdMsg->getExecutionFrame(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); + packet.commandCount = cmdMsg->getCommandCount(); -// If necessary, put the relay into the packet. - buffer[offset] = NetPacketFieldTypes::Relay; - ++offset; - UnsignedByte newRelay = msg->getRelay(); - memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); - offset += sizeof(UnsignedByte); + memcpy(buffer, &packet, sizeof(packet)); -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); + // 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())); +} - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); +void NetPacket::FillBufferWithPlayerLeaveCommand(UnsignedByte *buffer, NetCommandRef *msg) { + NetPlayerLeaveCommandMsg *cmdMsg = static_cast(msg->getCommand()); +// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addPlayerLeaveCommand - adding player leave command for player %d", cmdMsg->getLeavingPlayerID())); -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); + NetPacketPlayerLeaveCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.frame.frame = cmdMsg->getExecutionFrame(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); + packet.leavingPlayerId = cmdMsg->getLeavingPlayerID(); -// If necessary, specify the command ID of this command. - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); + memcpy(buffer, &packet, sizeof(packet)); +} -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); +void NetPacket::FillBufferWithRunAheadMetricsCommand(UnsignedByte *buffer, NetCommandRef *msg) { + NetRunAheadMetricsCommandMsg *cmdMsg = static_cast(msg->getCommand()); +// 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())); - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; - // write the average latency - Real averageLatency = cmdMsg->getAverageLatency(); - memcpy(buffer + offset, &averageLatency, sizeof(averageLatency)); - offset += sizeof(averageLatency); - // write the average fps - UnsignedShort averageFps = (UnsignedShort)(cmdMsg->getAverageFps()); - memcpy(buffer + offset, &averageFps, sizeof(averageFps)); - offset += sizeof(averageFps); + NetPacketRunAheadMetricsCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); + packet.averageLatency = cmdMsg->getAverageLatency(); + packet.averageFps = static_cast(cmdMsg->getAverageFps()); + + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithRunAheadCommand(UnsignedByte *buffer, NetCommandRef *msg) { - NetRunAheadCommandMsg *cmdMsg = (NetRunAheadCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; + NetRunAheadCommandMsg *cmdMsg = static_cast(msg->getCommand()); //DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::FillBufferWithRunAheadCommand - adding run ahead command")); - // If necessary, put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - - // If necessary, put the relay into the packet. - 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] = NetPacketFieldTypes::Frame; - ++offset; - UnsignedInt newframe = cmdMsg->getExecutionFrame(); - memcpy(buffer+offset, &newframe, sizeof(UnsignedInt)); - offset += sizeof(UnsignedInt); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); - - // If necessary, specify the command ID of this command. - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; - UnsignedShort newRunAhead = cmdMsg->getRunAhead(); - memcpy(buffer + offset, &newRunAhead, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); + NetPacketRunAheadCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.frame.frame = cmdMsg->getExecutionFrame(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); + packet.runAhead = cmdMsg->getRunAhead(); + packet.frameRate = cmdMsg->getFrameRate(); - UnsignedByte newFrameRate = cmdMsg->getFrameRate(); - memcpy(buffer + offset, &newFrameRate, sizeof(UnsignedByte)); - offset += sizeof(UnsignedByte); + memcpy(buffer, &packet, sizeof(packet)); // 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)); } void NetPacket::FillBufferWithDestroyPlayerCommand(UnsignedByte *buffer, NetCommandRef *msg) { - NetDestroyPlayerCommandMsg *cmdMsg = (NetDestroyPlayerCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; + NetDestroyPlayerCommandMsg *cmdMsg = static_cast(msg->getCommand()); // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addRunAheadCommand - adding run ahead command")); -// If necessary, put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - -// If necessary, put the relay into the packet. - 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] = NetPacketFieldTypes::Frame; - ++offset; - UnsignedInt newframe = cmdMsg->getExecutionFrame(); - memcpy(buffer+offset, &newframe, sizeof(UnsignedInt)); - offset += sizeof(UnsignedInt); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("relay = %d, ", m_lastRelay)); - - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); - -// If necessary, specify the command ID of this command. - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); + NetPacketDestroyPlayerCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.frame.frame = cmdMsg->getExecutionFrame(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); + packet.playerIndex = cmdMsg->getPlayerIndex(); - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; - UnsignedInt newVal = cmdMsg->getPlayerIndex(); - memcpy(buffer + offset, &newVal, sizeof(UnsignedInt)); - offset += sizeof(UnsignedInt); + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithKeepAliveCommand(UnsignedByte *buffer, NetCommandRef *msg) { - NetKeepAliveCommandMsg *cmdMsg = (NetKeepAliveCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; - - // If necessary, put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - -// If necessary, put the relay into the packet. - buffer[offset] = NetPacketFieldTypes::Relay; - ++offset; - UnsignedByte newRelay = msg->getRelay(); - memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); - offset += sizeof(UnsignedByte); + NetKeepAliveCommandMsg *cmdMsg = static_cast(msg->getCommand()); - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); + NetPacketKeepAliveCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithDisconnectKeepAliveCommand(UnsignedByte *buffer, NetCommandRef *msg) { - NetDisconnectKeepAliveCommandMsg *cmdMsg = (NetDisconnectKeepAliveCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; - - // Put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); + NetDisconnectKeepAliveCommandMsg *cmdMsg = static_cast(msg->getCommand()); - // Put the relay into the packet. - 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] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); + NetPacketDisconnectKeepAliveCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithDisconnectPlayerCommand(UnsignedByte *buffer, NetCommandRef *msg) { - NetDisconnectPlayerCommandMsg *cmdMsg = (NetDisconnectPlayerCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; + NetDisconnectPlayerCommandMsg *cmdMsg = static_cast(msg->getCommand()); // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectPlayerCommand - adding run ahead command")); - // If necessary, put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - -// If necessary, put the relay into the packet. - 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] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); - -// If necessary, specify the command ID of this command. - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); - - // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); + NetPacketDisconnectPlayerCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); + packet.slot = cmdMsg->getDisconnectSlot(); + packet.disconnectFrame = cmdMsg->getDisconnectFrame(); - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; - UnsignedByte slot = cmdMsg->getDisconnectSlot(); - memcpy(buffer + offset, &slot, sizeof(slot)); - offset += sizeof(slot); - - UnsignedInt disconnectFrame = cmdMsg->getDisconnectFrame(); - memcpy(buffer + offset, &disconnectFrame, sizeof(disconnectFrame)); - offset += sizeof(disconnectFrame); + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithPacketRouterQueryCommand(UnsignedByte *buffer, NetCommandRef *msg) { - NetPacketRouterQueryCommandMsg *cmdMsg = (NetPacketRouterQueryCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; + NetPacketRouterQueryCommandMsg *cmdMsg = static_cast(msg->getCommand()); // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addPacketRouterQueryCommand - adding packet router query command")); - // If necessary, put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - - // If necessary, put the relay into the packet. - 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] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); + NetPacketRouterQueryCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); - - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithPacketRouterAckCommand(UnsignedByte *buffer, NetCommandRef *msg) { NetPacketRouterAckCommandMsg *cmdMsg = (NetPacketRouterAckCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addPacketRouterAckCommand - adding packet router query command")); - // If necessary, put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - - // If necessary, put the relay into the packet. - 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] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); + NetPacketRouterAckCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithDisconnectChatCommand(UnsignedByte *buffer, NetCommandRef *msg) { NetDisconnectChatCommandMsg *cmdMsg = (NetDisconnectChatCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectChatCommand - adding run ahead command")); -// If necessary, put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - -// If necessary, put the relay into the packet. - 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] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); + UnicodeString unitext = cmdMsg->getText(); -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); + NetPacketDisconnectChatCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.textLength = NetPacketDisconnectChatCommand::getUsableTextLength(unitext); - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; - UnicodeString unitext = cmdMsg->getText(); - UnsignedByte length = unitext.getLength(); - memcpy(buffer + offset, &length, sizeof(UnsignedByte)); - offset += sizeof(UnsignedByte); + memcpy(buffer, &packet, sizeof(packet)); - memcpy(buffer + offset, unitext.str(), length * sizeof(UnsignedShort)); - offset += length * sizeof(UnsignedShort); + // Variable data portion + UnsignedShort offset = sizeof(NetPacketDisconnectChatCommand); + memcpy(buffer + offset, unitext.str(), packet.textLength * sizeof(UnsignedShort)); + offset += packet.textLength * sizeof(UnsignedShort); } void NetPacket::FillBufferWithDisconnectVoteCommand(UnsignedByte *buffer, NetCommandRef *msg) { NetDisconnectVoteCommandMsg *cmdMsg = (NetDisconnectVoteCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectVoteCommand - adding run ahead command")); -// If necessary, put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - -// If necessary, put the relay into the packet. - 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] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); - -// If necessary, specify the command ID of this command. - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); - -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); - - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; - UnsignedByte slot = cmdMsg->getSlot(); - memcpy(buffer + offset, &slot, sizeof(slot)); - offset += sizeof(slot); + NetPacketDisconnectVoteCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); + packet.slot = cmdMsg->getSlot(); + packet.voteFrame = cmdMsg->getVoteFrame(); - UnsignedInt voteFrame = cmdMsg->getVoteFrame(); - memcpy(buffer + offset, &voteFrame, sizeof(voteFrame)); - offset += sizeof(voteFrame); + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithChatCommand(UnsignedByte *buffer, NetCommandRef *msg) { - NetChatCommandMsg *cmdMsg = (NetChatCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; + NetChatCommandMsg *cmdMsg = static_cast(msg->getCommand()); // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectChatCommand - adding run ahead command")); -// If necessary, put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - -// If necessary, put the execution frame into the packet. - 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] = 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] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); + UnicodeString unitext = cmdMsg->getText(); -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("player = %d", m_lastPlayerID)); + NetPacketChatCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.frame.frame = cmdMsg->getExecutionFrame(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); + packet.textLength = NetPacketChatCommand::getUsableTextLength(unitext); -// If necessary, specify the command ID of this command. - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); + memcpy(buffer, &packet, sizeof(packet)); -// DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("command id = %d", m_lastCommandID)); + // Variable data portion + UnsignedShort offset = sizeof(NetPacketChatCommand); + memcpy(buffer + offset, unitext.str(), packet.textLength * sizeof(UnsignedShort)); + offset += packet.textLength * sizeof(UnsignedShort); - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; - UnicodeString unitext = cmdMsg->getText(); - UnsignedByte length = unitext.getLength(); Int playerMask = cmdMsg->getPlayerMask(); - memcpy(buffer + offset, &length, sizeof(UnsignedByte)); - offset += sizeof(UnsignedByte); - - memcpy(buffer + offset, unitext.str(), length * sizeof(UnsignedShort)); - offset += length * sizeof(UnsignedShort); - memcpy(buffer + offset, &playerMask, sizeof(Int)); offset += sizeof(Int); } void NetPacket::FillBufferWithProgressMessage(UnsignedByte *buffer, NetCommandRef *msg) { NetProgressCommandMsg *cmdMsg = (NetProgressCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; - -// If necessary, put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - -// If necessary, put the relay into the packet. - 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] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; + NetPacketProgressCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.percentage = cmdMsg->getPercentage(); - buffer[offset] = cmdMsg->getPercentage(); - ++offset; + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithLoadCompleteMessage(UnsignedByte *buffer, NetCommandRef *msg) { - NetCommandMsg *cmdMsg = (NetCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; - -// If necessary, put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - -// If necessary, put the relay into the packet. - buffer[offset] = NetPacketFieldTypes::Relay; - ++offset; - UnsignedByte newRelay = msg->getRelay(); - memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); - offset += sizeof(UnsignedByte); + NetCommandMsg *cmdMsg = static_cast(msg->getCommand()); - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - -// If necessary, specify the command ID of this command. - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); + NetPacketLoadCompleteCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithTimeOutGameStartMessage(UnsignedByte *buffer, NetCommandRef *msg) { - NetCommandMsg *cmdMsg = (NetCommandMsg *)(msg->getCommand()); - UnsignedShort offset = 0; - -// If necessary, put the NetCommandType into the packet. - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - -// If necessary, put the relay into the packet. - buffer[offset] = NetPacketFieldTypes::Relay; - ++offset; - UnsignedByte newRelay = msg->getRelay(); - memcpy(buffer+offset, &newRelay, sizeof(UnsignedByte)); - offset += sizeof(UnsignedByte); - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); + NetCommandMsg *cmdMsg = static_cast(msg->getCommand()); -// If necessary, specify the command ID of this command. - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(UnsignedShort)); - offset += sizeof(UnsignedShort); + NetPacketTimeOutGameStartCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithFileMessage(UnsignedByte *buffer, NetCommandRef *msg) { - NetFileCommandMsg *cmdMsg = (NetFileCommandMsg *)(msg->getCommand()); - UnsignedInt offset = 0; - - // command type - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - - // relay - buffer[offset] = NetPacketFieldTypes::Relay; - ++offset; - buffer[offset] = msg->getRelay(); - offset += sizeof(UnsignedByte); + NetFileCommandMsg *cmdMsg = static_cast(msg->getCommand()); - // player ID - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); + NetPacketFileCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); - // command ID - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(newID)); - offset += sizeof(newID); + memcpy(buffer, &packet, sizeof(packet)); - // data - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; + // Variable data portion + UnsignedInt offset = sizeof(NetPacketFileCommand); AsciiString filename = cmdMsg->getPortableFilename(); // PORTABLE for (Int i = 0; i < filename.getLength(); ++i) { @@ -1783,37 +793,18 @@ void NetPacket::FillBufferWithFileMessage(UnsignedByte *buffer, NetCommandRef *m } void NetPacket::FillBufferWithFileAnnounceMessage(UnsignedByte *buffer, NetCommandRef *msg) { - NetFileAnnounceCommandMsg *cmdMsg = (NetFileAnnounceCommandMsg *)(msg->getCommand()); - UnsignedInt offset = 0; - - // command type - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); + NetFileAnnounceCommandMsg *cmdMsg = static_cast(msg->getCommand()); - // relay - buffer[offset] = NetPacketFieldTypes::Relay; - ++offset; - buffer[offset] = msg->getRelay(); - offset += sizeof(UnsignedByte); - - // player ID - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); + NetPacketFileAnnounceCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); - // command ID - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(newID)); - offset += sizeof(newID); + memcpy(buffer, &packet, sizeof(packet)); - // data - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; + // Variable data portion + UnsignedInt offset = sizeof(NetPacketFileAnnounceCommand); AsciiString filename = cmdMsg->getPortableFilename(); // PORTABLE for (Int i = 0; i < filename.getLength(); ++i) { @@ -1834,158 +825,55 @@ void NetPacket::FillBufferWithFileAnnounceMessage(UnsignedByte *buffer, NetComma void NetPacket::FillBufferWithFileProgressMessage(UnsignedByte *buffer, NetCommandRef *msg) { NetFileProgressCommandMsg *cmdMsg = (NetFileProgressCommandMsg *)(msg->getCommand()); - UnsignedInt offset = 0; - - // command type - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - - // relay - buffer[offset] = NetPacketFieldTypes::Relay; - ++offset; - buffer[offset] = msg->getRelay(); - offset += sizeof(UnsignedByte); - - // player ID - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - - // command ID - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(newID)); - offset += sizeof(newID); - - // data - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; - UnsignedShort fileID = cmdMsg->getFileID(); - memcpy(buffer + offset, &fileID, sizeof(fileID)); - offset += sizeof(fileID); + NetPacketFileProgressCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); + packet.fileId = cmdMsg->getFileID(); + packet.progress = cmdMsg->getProgress(); - Int progress = cmdMsg->getProgress(); - memcpy(buffer + offset, &progress, sizeof(progress)); - offset += sizeof(progress); + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithDisconnectFrameMessage(UnsignedByte *buffer, NetCommandRef *msg) { NetDisconnectFrameCommandMsg *cmdMsg = (NetDisconnectFrameCommandMsg *)(msg->getCommand()); - UnsignedInt offset = 0; - - // command type - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - // relay - buffer[offset] = NetPacketFieldTypes::Relay; - ++offset; - buffer[offset] = msg->getRelay(); - offset += sizeof(UnsignedByte); - - // player ID - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - - // command ID - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(newID)); - offset += sizeof(newID); - - // data - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; + NetPacketDisconnectFrameCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); + packet.disconnectFrame = cmdMsg->getDisconnectFrame(); - UnsignedInt disconnectFrame = cmdMsg->getDisconnectFrame(); - memcpy(buffer + offset, &disconnectFrame, sizeof(disconnectFrame)); - offset += sizeof(disconnectFrame); + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithDisconnectScreenOffMessage(UnsignedByte *buffer, NetCommandRef *msg) { NetDisconnectScreenOffCommandMsg *cmdMsg = (NetDisconnectScreenOffCommandMsg *)(msg->getCommand()); - UnsignedInt offset = 0; - - // command type - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - - // relay - buffer[offset] = NetPacketFieldTypes::Relay; - ++offset; - buffer[offset] = msg->getRelay(); - offset += sizeof(UnsignedByte); - - // player ID - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - - // command ID - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(newID)); - offset += sizeof(newID); - // data - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; + NetPacketDisconnectScreenOffCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); + packet.newFrame = cmdMsg->getNewFrame(); - UnsignedInt newFrame = cmdMsg->getNewFrame(); - memcpy(buffer + offset, &newFrame, sizeof(newFrame)); - offset += sizeof(newFrame); + memcpy(buffer, &packet, sizeof(packet)); } void NetPacket::FillBufferWithFrameResendRequestMessage(UnsignedByte *buffer, NetCommandRef *msg) { NetFrameResendRequestCommandMsg *cmdMsg = (NetFrameResendRequestCommandMsg *)(msg->getCommand()); - UnsignedInt offset = 0; - - // command type - buffer[offset] = NetPacketFieldTypes::CommandType; - ++offset; - buffer[offset] = cmdMsg->getNetCommandType(); - offset += sizeof(UnsignedByte); - - // relay - buffer[offset] = NetPacketFieldTypes::Relay; - ++offset; - buffer[offset] = msg->getRelay(); - offset += sizeof(UnsignedByte); - - // player ID - buffer[offset] = NetPacketFieldTypes::PlayerId; - ++offset; - buffer[offset] = cmdMsg->getPlayerID(); - offset += sizeof(UnsignedByte); - - // command ID - buffer[offset] = NetPacketFieldTypes::CommandId; - ++offset; - UnsignedShort newID = cmdMsg->getID(); - memcpy(buffer + offset, &newID, sizeof(newID)); - offset += sizeof(newID); - // data - buffer[offset] = NetPacketFieldTypes::Data; - ++offset; + NetPacketFrameResendRequestCommand packet; + packet.commandType.commandType = cmdMsg->getNetCommandType(); + packet.relay.relay = msg->getRelay(); + packet.playerId.playerId = cmdMsg->getPlayerID(); + packet.commandId.commandId = cmdMsg->getID(); + packet.frameToResend = cmdMsg->getFrameToResend(); - UnsignedInt frameToResend = cmdMsg->getFrameToResend(); - memcpy(buffer + offset, &frameToResend, sizeof(frameToResend)); - offset += sizeof(frameToResend); + memcpy(buffer, &packet, sizeof(packet)); } @@ -2013,7 +901,7 @@ NetPacket::NetPacket(TransportMessage *msg) { */ NetPacket::~NetPacket() { deleteInstance(m_lastCommand); - m_lastCommand = NULL; + m_lastCommand = nullptr; } /** @@ -2032,12 +920,12 @@ void NetPacket::init() { m_lastCommandType = 0; m_lastRelay = 0; - m_lastCommand = NULL; + m_lastCommand = nullptr; } void NetPacket::reset() { deleteInstance(m_lastCommand); - m_lastCommand = NULL; + m_lastCommand = nullptr; init(); } @@ -2057,12 +945,12 @@ void NetPacket::setAddress(Int addr, Int port) { Bool NetPacket::addCommand(NetCommandRef *msg) { // This is where the fun begins... - NetCommandMsg *cmdMsg = msg->getCommand(); - - if (msg == NULL) { + if (msg == nullptr) { return TRUE; // There was nothing to add, so it was successful. } + NetCommandMsg *cmdMsg = msg->getCommand(); + switch(cmdMsg->getNetCommandType()) { case NETCOMMANDTYPE_GAMECOMMAND: @@ -2466,7 +1354,7 @@ Bool NetPacket::isRoomForDisconnectFrameMessage(NetCommandRef *msg) { Bool NetPacket::addFileCommand(NetCommandRef *msg) { Bool needNewCommandID = FALSE; if (isRoomForFileMessage(msg)) { - NetFileCommandMsg *cmdMsg = (NetFileCommandMsg *)(msg->getCommand()); + NetFileCommandMsg *cmdMsg = static_cast(msg->getCommand()); // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { @@ -2538,7 +1426,7 @@ Bool NetPacket::addFileCommand(NetCommandRef *msg) { Bool NetPacket::isRoomForFileMessage(NetCommandRef *msg) { Int len = 0; Bool needNewCommandID = FALSE; - NetFileCommandMsg *cmdMsg = (NetFileCommandMsg *)(msg->getCommand()); + NetFileCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { len += sizeof(UnsignedByte) + sizeof(UnsignedByte); } @@ -2553,7 +1441,7 @@ Bool NetPacket::isRoomForFileMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte) + sizeof(UnsignedShort); } - ++len; // NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data len += cmdMsg->getPortableFilename().getLength() + 1; // PORTABLE filename + the terminating 0 len += sizeof(UnsignedInt); // filedata length len += cmdMsg->getFileLength(); @@ -2568,7 +1456,7 @@ Bool NetPacket::isRoomForFileMessage(NetCommandRef *msg) { Bool NetPacket::addFileAnnounceCommand(NetCommandRef *msg) { Bool needNewCommandID = FALSE; if (isRoomForFileAnnounceMessage(msg)) { - NetFileAnnounceCommandMsg *cmdMsg = (NetFileAnnounceCommandMsg *)(msg->getCommand()); + NetFileAnnounceCommandMsg *cmdMsg = static_cast(msg->getCommand()); // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { @@ -2645,7 +1533,7 @@ Bool NetPacket::addFileAnnounceCommand(NetCommandRef *msg) { Bool NetPacket::isRoomForFileAnnounceMessage(NetCommandRef *msg) { Int len = 0; Bool needNewCommandID = FALSE; - NetFileAnnounceCommandMsg *cmdMsg = (NetFileAnnounceCommandMsg *)(msg->getCommand()); + NetFileAnnounceCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { len += sizeof(UnsignedByte) + sizeof(UnsignedByte); } @@ -2660,7 +1548,7 @@ Bool NetPacket::isRoomForFileAnnounceMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte) + sizeof(UnsignedShort); } - ++len; // NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data len += cmdMsg->getPortableFilename().getLength() + 1; // PORTABLE filename + the terminating 0 len += sizeof(UnsignedShort); // m_fileID len += sizeof(UnsignedByte); // m_playerMask @@ -2760,7 +1648,7 @@ Bool NetPacket::isRoomForFileProgressMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte) + sizeof(UnsignedShort); } - ++len; // NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedShort); // m_fileID len += sizeof(Int); // m_progress @@ -2890,7 +1778,7 @@ Bool NetPacket::isRoomForWrapperMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte) + sizeof(UnsignedShort); } - ++len; // NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedShort); // wrapped command ID len += sizeof(UnsignedInt); // chunk number len += sizeof(UnsignedInt); // number of chunks @@ -2911,8 +1799,8 @@ Bool NetPacket::isRoomForWrapperMessage(NetCommandRef *msg) { */ Bool NetPacket::addTimeOutGameStartMessage(NetCommandRef *msg) { Bool needNewCommandID = FALSE; - if (isRoomForLoadCompleteMessage(msg)) { - NetCommandMsg *cmdMsg = (NetCommandMsg *)(msg->getCommand()); + if (isRoomForTimeOutGameStartMessage(msg)) { + NetCommandMsg *cmdMsg = static_cast(msg->getCommand()); // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { @@ -2976,7 +1864,8 @@ Bool NetPacket::addTimeOutGameStartMessage(NetCommandRef *msg) { */ Bool NetPacket::isRoomForTimeOutGameStartMessage(NetCommandRef *msg) { Int len = 0; - NetCommandMsg *cmdMsg = (NetCommandMsg *)(msg->getCommand()); + Bool needNewCommandID = FALSE; + NetCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { ++len; len += sizeof(UnsignedByte); @@ -2987,9 +1876,13 @@ Bool NetPacket::isRoomForTimeOutGameStartMessage(NetCommandRef *msg) { if (m_lastPlayerID != cmdMsg->getPlayerID()) { ++len; len += sizeof(UnsignedByte); + needNewCommandID = TRUE; + } + if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { + len += sizeof(UnsignedByte) + sizeof(UnsignedShort); } - ++len; // For the NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; } @@ -3004,7 +1897,7 @@ Bool NetPacket::isRoomForTimeOutGameStartMessage(NetCommandRef *msg) { Bool NetPacket::addLoadCompleteMessage(NetCommandRef *msg) { Bool needNewCommandID = FALSE; if (isRoomForLoadCompleteMessage(msg)) { - NetCommandMsg *cmdMsg = (NetCommandMsg *)(msg->getCommand()); + NetCommandMsg *cmdMsg = static_cast(msg->getCommand()); // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { @@ -3068,7 +1961,8 @@ Bool NetPacket::addLoadCompleteMessage(NetCommandRef *msg) { */ Bool NetPacket::isRoomForLoadCompleteMessage(NetCommandRef *msg) { Int len = 0; - NetCommandMsg *cmdMsg = (NetCommandMsg *)(msg->getCommand()); + Bool needNewCommandID = FALSE; + NetCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { ++len; len += sizeof(UnsignedByte); @@ -3079,9 +1973,13 @@ Bool NetPacket::isRoomForLoadCompleteMessage(NetCommandRef *msg) { if (m_lastPlayerID != cmdMsg->getPlayerID()) { ++len; len += sizeof(UnsignedByte); + needNewCommandID = TRUE; + } + if (((m_lastCommandID + 1) != (UnsignedShort)(cmdMsg->getID())) || (needNewCommandID == TRUE)) { + len += sizeof(UnsignedByte) + sizeof(UnsignedShort); } - ++len; // For the NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; } @@ -3165,7 +2063,7 @@ Bool NetPacket::isRoomForProgressMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // For the NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data ++len; // percentage if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; @@ -3276,7 +2174,7 @@ Bool NetPacket::isRoomForDisconnectVoteMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // the NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedByte); // slot number len += sizeof(UnsignedInt); // vote frame @@ -3331,12 +2229,12 @@ Bool NetPacket::addDisconnectChatCommand(NetCommandRef *msg) { m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnicodeString unitext = cmdMsg->getText(); - UnsignedByte length = unitext.getLength(); - memcpy(m_packet + m_packetLen, &length, sizeof(UnsignedByte)); + UnsignedByte textLen = NetPacketDisconnectChatCommand::getUsableTextLength(unitext); + memcpy(m_packet + m_packetLen, &textLen, sizeof(UnsignedByte)); m_packetLen += sizeof(UnsignedByte); - memcpy(m_packet + m_packetLen, unitext.str(), length * sizeof(UnsignedShort)); - m_packetLen += length * sizeof(UnsignedShort); + memcpy(m_packet + m_packetLen, unitext.str(), textLen * sizeof(UnsignedShort)); + m_packetLen += textLen * sizeof(UnsignedShort); // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket - added disconnect chat command")); @@ -3365,9 +2263,9 @@ Bool NetPacket::isRoomForDisconnectChatMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // the NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedByte); // string length - UnsignedByte textLen = cmdMsg->getText().getLength(); + UnsignedByte textLen = NetPacketDisconnectChatCommand::getUsableTextLength(cmdMsg->getText()); len += textLen * sizeof(UnsignedShort); if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; @@ -3378,7 +2276,7 @@ Bool NetPacket::isRoomForDisconnectChatMessage(NetCommandRef *msg) { Bool NetPacket::addChatCommand(NetCommandRef *msg) { Bool needNewCommandID = FALSE; if (isRoomForChatMessage(msg)) { - NetChatCommandMsg *cmdMsg = (NetChatCommandMsg *)(msg->getCommand()); + NetChatCommandMsg *cmdMsg = static_cast(msg->getCommand()); // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectChatCommand - adding run ahead command")); // If necessary, put the NetCommandType into the packet. @@ -3442,13 +2340,13 @@ Bool NetPacket::addChatCommand(NetCommandRef *msg) { m_packet[m_packetLen] = NetPacketFieldTypes::Data; ++m_packetLen; UnicodeString unitext = cmdMsg->getText(); - UnsignedByte length = unitext.getLength(); + UnsignedByte textLen = NetPacketChatCommand::getUsableTextLength(unitext); Int playerMask = cmdMsg->getPlayerMask(); - memcpy(m_packet + m_packetLen, &length, sizeof(UnsignedByte)); + memcpy(m_packet + m_packetLen, &textLen, sizeof(UnsignedByte)); m_packetLen += sizeof(UnsignedByte); - memcpy(m_packet + m_packetLen, unitext.str(), length * sizeof(UnsignedShort)); - m_packetLen += length * sizeof(UnsignedShort); + memcpy(m_packet + m_packetLen, unitext.str(), textLen * sizeof(UnsignedShort)); + m_packetLen += textLen * sizeof(UnsignedShort); memcpy(m_packet + m_packetLen, &playerMask, sizeof(Int)); m_packetLen += sizeof(Int); @@ -3468,7 +2366,7 @@ Bool NetPacket::addChatCommand(NetCommandRef *msg) { Bool NetPacket::isRoomForChatMessage(NetCommandRef *msg) { Bool needNewCommandID = FALSE; Int len = 0; - NetChatCommandMsg *cmdMsg = (NetChatCommandMsg *)(msg->getCommand()); + NetChatCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { ++len; len += sizeof(UnsignedByte); @@ -3488,9 +2386,9 @@ Bool NetPacket::isRoomForChatMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // the NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedByte); // string length - UnsignedByte textLen = cmdMsg->getText().getLength(); + UnsignedByte textLen = NetPacketChatCommand::getUsableTextLength(cmdMsg->getText()); len += textLen * sizeof(UnsignedShort); len += sizeof(Int); // playerMask if ((len + m_packetLen) > MAX_PACKET_SIZE) { @@ -3572,7 +2470,7 @@ Bool NetPacket::isRoomForPacketRouterAckMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // the NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; } @@ -3582,7 +2480,7 @@ Bool NetPacket::isRoomForPacketRouterAckMessage(NetCommandRef *msg) { Bool NetPacket::addPacketRouterQueryCommand(NetCommandRef *msg) { // need type, player id, relay, command id, slot number if (isRoomForPacketRouterQueryMessage(msg)) { - NetPacketRouterQueryCommandMsg *cmdMsg = (NetPacketRouterQueryCommandMsg *)(msg->getCommand()); + NetPacketRouterQueryCommandMsg *cmdMsg = static_cast(msg->getCommand()); // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addPacketRouterQueryCommand - adding packet router query command")); // If necessary, put the NetCommandType into the packet. @@ -3639,7 +2537,7 @@ Bool NetPacket::addPacketRouterQueryCommand(NetCommandRef *msg) { */ Bool NetPacket::isRoomForPacketRouterQueryMessage(NetCommandRef *msg) { Int len = 0; - NetPacketRouterQueryCommandMsg *cmdMsg = (NetPacketRouterQueryCommandMsg *)(msg->getCommand()); + NetPacketRouterQueryCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { ++len; len += sizeof(UnsignedByte); @@ -3652,7 +2550,7 @@ Bool NetPacket::isRoomForPacketRouterQueryMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // the NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; } @@ -3665,7 +2563,7 @@ Bool NetPacket::addDisconnectPlayerCommand(NetCommandRef *msg) { // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectPlayerCommand - entering...")); // need type, player id, relay, command id, slot number if (isRoomForDisconnectPlayerMessage(msg)) { - NetDisconnectPlayerCommandMsg *cmdMsg = (NetDisconnectPlayerCommandMsg *)(msg->getCommand()); + NetDisconnectPlayerCommandMsg *cmdMsg = static_cast(msg->getCommand()); // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addDisconnectPlayerCommand - adding run ahead command")); // If necessary, put the NetCommandType into the packet. @@ -3743,7 +2641,7 @@ Bool NetPacket::addDisconnectPlayerCommand(NetCommandRef *msg) { Bool NetPacket::isRoomForDisconnectPlayerMessage(NetCommandRef *msg) { Int len = 0; Bool needNewCommandID = FALSE; - NetDisconnectPlayerCommandMsg *cmdMsg = (NetDisconnectPlayerCommandMsg *)(msg->getCommand()); + NetDisconnectPlayerCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { ++len; len += sizeof(UnsignedByte); @@ -3760,7 +2658,7 @@ Bool NetPacket::isRoomForDisconnectPlayerMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // the NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedByte); // slot number len += sizeof(UnsignedInt); // disconnectFrame if ((len + m_packetLen) > MAX_PACKET_SIZE) { @@ -3775,7 +2673,7 @@ Bool NetPacket::isRoomForDisconnectPlayerMessage(NetCommandRef *msg) { */ Bool NetPacket::addDisconnectKeepAliveCommand(NetCommandRef *msg) { if (isRoomForDisconnectKeepAliveMessage(msg)) { - NetDisconnectKeepAliveCommandMsg *cmdMsg = (NetDisconnectKeepAliveCommandMsg *)(msg->getCommand()); + NetDisconnectKeepAliveCommandMsg *cmdMsg = static_cast(msg->getCommand()); // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { @@ -3828,7 +2726,7 @@ Bool NetPacket::addDisconnectKeepAliveCommand(NetCommandRef *msg) { */ Bool NetPacket::isRoomForDisconnectKeepAliveMessage(NetCommandRef *msg) { Int len = 0; - NetDisconnectKeepAliveCommandMsg *cmdMsg = (NetDisconnectKeepAliveCommandMsg *)(msg->getCommand()); + NetDisconnectKeepAliveCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { ++len; len += sizeof(UnsignedByte); @@ -3841,7 +2739,7 @@ Bool NetPacket::isRoomForDisconnectKeepAliveMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // For the NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; } @@ -3853,7 +2751,7 @@ Bool NetPacket::isRoomForDisconnectKeepAliveMessage(NetCommandRef *msg) { */ Bool NetPacket::addKeepAliveCommand(NetCommandRef *msg) { if (isRoomForKeepAliveMessage(msg)) { - NetKeepAliveCommandMsg *cmdMsg = (NetKeepAliveCommandMsg *)(msg->getCommand()); + NetKeepAliveCommandMsg *cmdMsg = static_cast(msg->getCommand()); // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { @@ -3906,7 +2804,7 @@ Bool NetPacket::addKeepAliveCommand(NetCommandRef *msg) { */ Bool NetPacket::isRoomForKeepAliveMessage(NetCommandRef *msg) { Int len = 0; - NetKeepAliveCommandMsg *cmdMsg = (NetKeepAliveCommandMsg *)(msg->getCommand()); + NetKeepAliveCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { ++len; len += sizeof(UnsignedByte); @@ -3919,7 +2817,7 @@ Bool NetPacket::isRoomForKeepAliveMessage(NetCommandRef *msg) { len += sizeof(UnsignedByte); } - ++len; // For the NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data if ((len + m_packetLen) > MAX_PACKET_SIZE) { return FALSE; } @@ -3932,7 +2830,7 @@ Bool NetPacket::isRoomForKeepAliveMessage(NetCommandRef *msg) { Bool NetPacket::addRunAheadCommand(NetCommandRef *msg) { Bool needNewCommandID = FALSE; if (isRoomForRunAheadMessage(msg)) { - NetRunAheadCommandMsg *cmdMsg = (NetRunAheadCommandMsg *)(msg->getCommand()); + NetRunAheadCommandMsg *cmdMsg = static_cast(msg->getCommand()); //DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addRunAheadCommand - adding run ahead command")); // If necessary, put the NetCommandType into the packet. @@ -4021,7 +2919,7 @@ Bool NetPacket::addRunAheadCommand(NetCommandRef *msg) { Bool NetPacket::isRoomForRunAheadMessage(NetCommandRef *msg) { Int len = 0; Bool needNewCommandID = FALSE; - NetRunAheadCommandMsg *cmdMsg = (NetRunAheadCommandMsg *)(msg->getCommand()); + NetRunAheadCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { ++len; len += sizeof(UnsignedByte); @@ -4056,7 +2954,7 @@ Bool NetPacket::isRoomForRunAheadMessage(NetCommandRef *msg) { Bool NetPacket::addDestroyPlayerCommand(NetCommandRef *msg) { Bool needNewCommandID = FALSE; if (isRoomForDestroyPlayerMessage(msg)) { - NetDestroyPlayerCommandMsg *cmdMsg = (NetDestroyPlayerCommandMsg *)(msg->getCommand()); + NetDestroyPlayerCommandMsg *cmdMsg = static_cast(msg->getCommand()); // If necessary, put the NetCommandType into the packet. if (m_lastCommandType != cmdMsg->getNetCommandType()) { @@ -4140,7 +3038,7 @@ Bool NetPacket::addDestroyPlayerCommand(NetCommandRef *msg) { Bool NetPacket::isRoomForDestroyPlayerMessage(NetCommandRef *msg) { Int len = 0; Bool needNewCommandID = FALSE; - NetDestroyPlayerCommandMsg *cmdMsg = (NetDestroyPlayerCommandMsg *)(msg->getCommand()); + NetDestroyPlayerCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { ++len; len += sizeof(UnsignedByte); @@ -4174,7 +3072,7 @@ Bool NetPacket::isRoomForDestroyPlayerMessage(NetCommandRef *msg) { Bool NetPacket::addRunAheadMetricsCommand(NetCommandRef *msg) { Bool needNewCommandID = FALSE; if (isRoomForRunAheadMetricsMessage(msg)) { - NetRunAheadMetricsCommandMsg *cmdMsg = (NetRunAheadMetricsCommandMsg *)(msg->getCommand()); + NetRunAheadMetricsCommandMsg *cmdMsg = static_cast(msg->getCommand()); // 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. @@ -4251,7 +3149,7 @@ Bool NetPacket::addRunAheadMetricsCommand(NetCommandRef *msg) { Bool NetPacket::isRoomForRunAheadMetricsMessage(NetCommandRef *msg) { Int len = 0; Bool needNewCommandID = FALSE; - NetRunAheadMetricsCommandMsg *cmdMsg = (NetRunAheadMetricsCommandMsg *)(msg->getCommand()); + NetRunAheadMetricsCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { ++len; len += sizeof(UnsignedByte); @@ -4268,7 +3166,7 @@ Bool NetPacket::isRoomForRunAheadMetricsMessage(NetCommandRef *msg) { len += sizeof(UnsignedShort) + sizeof(UnsignedByte); } - ++len; // NetPacketFieldTypes::Data + ++len; // for NetPacketFieldTypes::Data len += sizeof(UnsignedShort); len += sizeof(Real); if ((len + m_packetLen) > MAX_PACKET_SIZE) { @@ -4284,7 +3182,7 @@ Bool NetPacket::isRoomForRunAheadMetricsMessage(NetCommandRef *msg) { Bool NetPacket::addPlayerLeaveCommand(NetCommandRef *msg) { Bool needNewCommandID = FALSE; if (isRoomForPlayerLeaveMessage(msg)) { - NetPlayerLeaveCommandMsg *cmdMsg = (NetPlayerLeaveCommandMsg *)(msg->getCommand()); + NetPlayerLeaveCommandMsg *cmdMsg = static_cast(msg->getCommand()); // 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. @@ -4367,7 +3265,7 @@ Bool NetPacket::addPlayerLeaveCommand(NetCommandRef *msg) { Bool NetPacket::isRoomForPlayerLeaveMessage(NetCommandRef *msg) { Int len = 0; Bool needNewCommandID = FALSE; - NetPlayerLeaveCommandMsg *cmdMsg = (NetPlayerLeaveCommandMsg *)(msg->getCommand()); + NetPlayerLeaveCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { ++len; len += sizeof(UnsignedByte); @@ -4417,7 +3315,7 @@ Bool NetPacket::addFrameCommand(NetCommandRef *msg) { return TRUE; } if (isRoomForFrameMessage(msg)) { - NetFrameCommandMsg *cmdMsg = (NetFrameCommandMsg *)(msg->getCommand()); + NetFrameCommandMsg *cmdMsg = static_cast(msg->getCommand()); // 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. @@ -4503,7 +3401,7 @@ Bool NetPacket::addFrameCommand(NetCommandRef *msg) { Bool NetPacket::isRoomForFrameMessage(NetCommandRef *msg) { Int len = 0; Bool needNewCommandID = FALSE; - NetFrameCommandMsg *cmdMsg = (NetFrameCommandMsg *)(msg->getCommand()); + NetFrameCommandMsg *cmdMsg = static_cast(msg->getCommand()); if (m_lastCommandType != cmdMsg->getNetCommandType()) { ++len; len += sizeof(UnsignedByte); @@ -4532,7 +3430,7 @@ Bool NetPacket::isRoomForFrameMessage(NetCommandRef *msg) { } Bool NetPacket::isFrameRepeat(NetCommandRef *msg) { - if (m_lastCommand == NULL) { + if (m_lastCommand == nullptr) { return FALSE; } if (m_lastCommand->getCommand()->getNetCommandType() != NETCOMMANDTYPE_FRAMEINFO) { @@ -4662,7 +3560,7 @@ Bool NetPacket::isRoomForAckMessage(NetCommandRef *msg) { } Bool NetPacket::isAckRepeat(NetCommandRef *msg) { - if (m_lastCommand == NULL) { + if (m_lastCommand == nullptr) { return FALSE; } if (m_lastCommand->getCommand()->getNetCommandType() != msg->getCommand()->getNetCommandType()) { @@ -4810,7 +3708,7 @@ Bool NetPacket::addGameCommand(NetCommandRef *msg) { m_packetLen += sizeof(numTypes); GameMessageParserArgumentType *argType = parser->getFirstArgumentType(); - while (argType != NULL) { + while (argType != nullptr) { UnsignedByte type = (UnsignedByte)(argType->getType()); memcpy(m_packet + m_packetLen, &type, sizeof(type)); m_packetLen += sizeof(type); @@ -4830,7 +3728,7 @@ Bool NetPacket::addGameCommand(NetCommandRef *msg) { } deleteInstance(parser); - parser = NULL; + parser = nullptr; // DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::addGameMessage - added game message, frame %d, player %d, command ID %d", m_lastFrame, m_lastPlayerID, m_lastCommandID)); @@ -4844,7 +3742,7 @@ Bool NetPacket::addGameCommand(NetCommandRef *msg) { } deleteInstance(gmsg); - gmsg = NULL; + gmsg = nullptr; return retval; } @@ -4936,8 +3834,9 @@ Bool NetPacket::isRoomForGameMessage(NetCommandRef *msg, GameMessage *gmsg) { msglen += sizeof(UnsignedByte); // Int numTypes = parser->getNumTypes(); GameMessageParserArgumentType *arg = parser->getFirstArgumentType(); - while (arg != NULL) { - msglen += 2 * sizeof(UnsignedByte); // for the type and number of args of that type declaration. + while (arg != nullptr) { + msglen += sizeof(UnsignedByte); // argument type + msglen += sizeof(UnsignedByte); // argument count GameMessageArgumentDataType type = arg->getType(); switch (type) { @@ -4983,7 +3882,7 @@ Bool NetPacket::isRoomForGameMessage(NetCommandRef *msg, GameMessage *gmsg) { } deleteInstance(parser); - parser = NULL; + parser = nullptr; // Is there enough room in the packet for this message? if (msglen > (MAX_PACKET_SIZE - m_packetLen)) { @@ -5006,7 +3905,7 @@ NetCommandList * NetPacket::getCommandList() { UnsignedShort commandID = 1; // The first command is going to be UnsignedByte commandType = 0; UnsignedByte relay = 0; - NetCommandRef *lastCommand = NULL; + NetCommandRef *lastCommand = nullptr; Int i = 0; while (i < m_packetLen) { @@ -5041,7 +3940,7 @@ NetCommandList * NetPacket::getCommandList() { case NetPacketFieldTypes::Data: { ++i; - NetCommandMsg *msg = NULL; + NetCommandMsg *msg = nullptr; //DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::getCommandList() - command of type %d(%s)", commandType, GetNetCommandTypeAsString((NetCommandType)commandType))); @@ -5156,7 +4055,7 @@ NetCommandList * NetPacket::getCommandList() { break; } - if (msg == NULL) { + if (msg == nullptr) { DEBUG_CRASH(("Didn't read a message from the packet. Things are about to go wrong.")); continue; } @@ -5176,7 +4075,7 @@ NetCommandList * NetPacket::getCommandList() { // add the message to the list. NetCommandRef *ref = retval->addMessage(msg); - if (ref != NULL) { + if (ref != nullptr) { ref->setRelay(relay); } else { DEBUG_LOG_LEVEL(DEBUG_LEVEL_NET, ("NetPacket::getCommandList - failed to set relay for message %d", msg->getID())); @@ -5187,8 +4086,8 @@ NetCommandList * NetPacket::getCommandList() { msg->detach(); // Need to detach from new NetCommandMsg created by the "readXMessage" above. - // since the message is part of the list now, we don't have to keep track of it. So we'll just set it to NULL. - msg = NULL; + // since the message is part of the list now, we don't have to keep track of it. So we'll just set it to null. + msg = nullptr; break; } @@ -5196,11 +4095,11 @@ NetCommandList * NetPacket::getCommandList() { ++i; // Repeat the last command, doing some funky cool byte-saving stuff - if (lastCommand == NULL) { + if (lastCommand == nullptr) { DEBUG_CRASH(("Got a repeat command with no command to repeat.")); } - NetCommandMsg *msg = NULL; + NetCommandMsg *msg = nullptr; switch(commandType) { @@ -5252,7 +4151,7 @@ NetCommandList * NetPacket::getCommandList() { // add the message to the list. NetCommandRef *ref = retval->addMessage(msg); - if (ref != NULL) { + if (ref != nullptr) { ref->setRelay(relay); } @@ -5262,8 +4161,8 @@ NetCommandList * NetPacket::getCommandList() { msg->detach(); // Need to detach from new NetCommandMsg created by the "readXMessage" above. - // since the message is part of the list now, we don't have to keep track of it. So we'll just set it to NULL. - msg = NULL; + // since the message is part of the list now, we don't have to keep track of it. So we'll just set it to null. + msg = nullptr; break; } @@ -5280,7 +4179,7 @@ NetCommandList * NetPacket::getCommandList() { } deleteInstance(lastCommand); - lastCommand = NULL; + lastCommand = nullptr; return retval; } @@ -5325,7 +4224,7 @@ NetCommandMsg * NetPacket::readGameMessage(UnsignedByte *data, Int &i) GameMessageParserArgumentType *parserArgType = parser->getFirstArgumentType(); GameMessageArgumentDataType lasttype = ARGUMENTDATATYPE_UNKNOWN; Int argsLeftForType = 0; - if (parserArgType != NULL) { + if (parserArgType != nullptr) { lasttype = parserArgType->getType(); argsLeftForType = parserArgType->getArgCount(); } @@ -5334,14 +4233,14 @@ NetCommandMsg * NetPacket::readGameMessage(UnsignedByte *data, Int &i) --argsLeftForType; if (argsLeftForType == 0) { - DEBUG_ASSERTCRASH(parserArgType != NULL, ("parserArgType was NULL when it shouldn't have been.")); - if (parserArgType == NULL) { - return NULL; + DEBUG_ASSERTCRASH(parserArgType != nullptr, ("parserArgType was null when it shouldn't have been.")); + if (parserArgType == nullptr) { + return nullptr; } parserArgType = parserArgType->getNext(); - // parserArgType is allowed to be NULL here - if (parserArgType != NULL) { + // parserArgType is allowed to be null here + if (parserArgType != nullptr) { argsLeftForType = parserArgType->getArgCount(); lasttype = parserArgType->getType(); } @@ -5349,7 +4248,7 @@ NetCommandMsg * NetPacket::readGameMessage(UnsignedByte *data, Int &i) } deleteInstance(parser); - parser = NULL; + parser = nullptr; return (NetCommandMsg *)msg; } @@ -5746,12 +4645,12 @@ NetCommandMsg * NetPacket::readProgressMessage(UnsignedByte *data, Int &i) { } NetCommandMsg * NetPacket::readLoadCompleteMessage(UnsignedByte *data, Int &i) { - NetCommandMsg *msg = newInstance(NetCommandMsg); + NetLoadCompleteCommandMsg *msg = newInstance(NetLoadCompleteCommandMsg); return msg; } NetCommandMsg * NetPacket::readTimeOutGameStartMessage(UnsignedByte *data, Int &i) { - NetCommandMsg *msg = newInstance(NetCommandMsg); + NetTimeOutGameStartCommandMsg *msg = newInstance(NetTimeOutGameStartCommandMsg); return msg; } diff --git a/Core/GameEngine/Source/GameNetwork/Network.cpp b/Core/GameEngine/Source/GameNetwork/Network.cpp index 71d672cfed3..b24873dfd53 100644 --- a/Core/GameEngine/Source/GameNetwork/Network.cpp +++ b/Core/GameEngine/Source/GameNetwork/Network.cpp @@ -74,7 +74,7 @@ struct ConnectionMessage { Int id; NetMessageFlags flags; - UnsignedByte data[MAX_MESSAGE_LEN]; + UnsignedByte data[MAX_NETWORK_MESSAGE_LEN]; time_t lastSendTime; Int retries; Int length; @@ -90,7 +90,7 @@ static const int CmdMsgLen = 6; //< Minimum size of a command packet (Int + Unsi // PUBLIC DATA //////////////////////////////////////////////////////////////// /// The Network singleton instance -NetworkInterface *TheNetwork = NULL; +NetworkInterface *TheNetwork = nullptr; // PRIVATE PROTOTYPES ///////////////////////////////////////////////////////// @@ -176,7 +176,7 @@ class Network : public NetworkInterface // For disconnect blame assignment UnsignedInt getPingFrame(); Int getPingsSent(); - Int getPingsRecieved(); + Int getPingsReceived(); protected: void GetCommandsFromCommandList(); ///< Remove commands from TheCommandList and put them on the Network command list. @@ -231,9 +231,9 @@ Int Network::getPingsSent() return (m_conMgr)?m_conMgr->getPingsSent():0; } -Int Network::getPingsRecieved() +Int Network::getPingsReceived() { - return (m_conMgr)?m_conMgr->getPingsRecieved():0; + return (m_conMgr)?m_conMgr->getPingsReceived():0; } Bool Network::isPlayerConnected( Int playerID ) { @@ -270,8 +270,8 @@ Network::Network() m_frameDataReady = FALSE; m_isStalling = FALSE; m_sawCRCMismatch = FALSE; - m_conMgr = NULL; - m_messageWindow = NULL; + m_conMgr = nullptr; + m_messageWindow = nullptr; #if defined(RTS_DEBUG) m_networkOn = TRUE; @@ -295,11 +295,11 @@ Bool Network::deinit( void ) { m_conMgr->destroyGameMessages(); delete m_conMgr; - m_conMgr = NULL; + m_conMgr = nullptr; } if (m_messageWindow) { TheWindowManager->winDestroy(m_messageWindow); - m_messageWindow = NULL; + m_messageWindow = nullptr; } return true; @@ -403,7 +403,7 @@ void Network::parseUserList( const GameInfo *game ) { if (!game) { - DEBUG_LOG(("FAILED parseUserList with a NULL game")); + DEBUG_LOG(("FAILED parseUserList with a null game")); return; } @@ -425,8 +425,8 @@ void Network::startGame() { * it explicitly, but regardless, this is the one we're going to use. */ void Network::setLocalAddress(UnsignedInt ip, UnsignedInt port) { - DEBUG_ASSERTCRASH(m_conMgr != NULL, ("Connection manager does not exist.")); - if (m_conMgr != NULL) { + DEBUG_ASSERTCRASH(m_conMgr != nullptr, ("Connection manager does not exist.")); + if (m_conMgr != nullptr) { m_conMgr->setLocalAddress(ip, port); } } @@ -435,15 +435,15 @@ void Network::setLocalAddress(UnsignedInt ip, UnsignedInt port) { * Tell the network to initialize the transport object */ void Network::initTransport() { - DEBUG_ASSERTCRASH(m_conMgr != NULL, ("Connection manager does not exist.")); - if (m_conMgr != NULL) { + DEBUG_ASSERTCRASH(m_conMgr != nullptr, ("Connection manager does not exist.")); + if (m_conMgr != nullptr) { m_conMgr->initTransport(); } } void Network::attachTransport(Transport *transport) { - DEBUG_ASSERTCRASH(m_conMgr != NULL, ("Connection manager does not exist.")); - if (m_conMgr != NULL) { + DEBUG_ASSERTCRASH(m_conMgr != nullptr, ("Connection manager does not exist.")); + if (m_conMgr != nullptr) { m_conMgr->attachTransport(transport); } } @@ -452,7 +452,7 @@ void Network::attachTransport(Transport *transport) { * Does this command need to be transfered to the other game clients? */ Bool Network::isTransferCommand(GameMessage *msg) { - if ((msg != NULL) && ((msg->getType() > GameMessage::MSG_BEGIN_NETWORK_MESSAGES) && (msg->getType() < GameMessage::MSG_END_NETWORK_MESSAGES))) { + if ((msg != nullptr) && ((msg->getType() > GameMessage::MSG_BEGIN_NETWORK_MESSAGES) && (msg->getType() < GameMessage::MSG_END_NETWORK_MESSAGES))) { return TRUE; } return FALSE; @@ -463,8 +463,8 @@ Bool Network::isTransferCommand(GameMessage *msg) { */ void Network::GetCommandsFromCommandList() { GameMessage *msg = TheCommandList->getFirstMessage(); - GameMessage *next = NULL; - while (msg != NULL) { + GameMessage *next = nullptr; + while (msg != nullptr) { next = msg->next(); if (isTransferCommand(msg)) { // Is this something we should be sending to the other players? if (m_localStatus == NETLOCALSTATUS_INGAME) { @@ -559,7 +559,7 @@ Bool Network::processCommand(GameMessage *msg) * returns true if all the commands are ready for the given frame. */ Bool Network::AllCommandsReady(UnsignedInt frame) { - if (m_conMgr == NULL) { + if (m_conMgr == nullptr) { return TRUE; } @@ -579,13 +579,13 @@ Bool Network::AllCommandsReady(UnsignedInt frame) { * The commands need to be put on in the same order across all clients. */ void Network::RelayCommandsToCommandList(UnsignedInt frame) { - if ((m_conMgr == NULL) || (m_localStatus == NETLOCALSTATUS_PREGAME)) { + if ((m_conMgr == nullptr) || (m_localStatus == NETLOCALSTATUS_PREGAME)) { return; } m_checkCRCsThisFrame = FALSE; NetCommandList *netcmdlist = m_conMgr->getFrameCommandList(frame); NetCommandRef *msg = netcmdlist->getFirstMessage(); - while (msg != NULL) { + while (msg != nullptr) { NetCommandType cmdType = msg->getCommand()->getNetCommandType(); if (cmdType == NETCOMMANDTYPE_GAMECOMMAND) { //DEBUG_LOG(("Network::RelayCommandsToCommandList - appending command %d of type %s to command list on frame %d", msg->getCommand()->getID(), ((NetGameCommandMsg *)msg->getCommand())->constructGameMessage()->getCommandAsString(), TheGameLogic->getFrame())); @@ -700,7 +700,7 @@ void Network::update( void ) #endif GetCommandsFromCommandList(); // Remove commands from TheCommandList and send them to the connection manager. - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { if (m_localStatus == NETLOCALSTATUS_INGAME) { m_conMgr->updateRunAhead(m_runAhead, m_frameRate, m_didSelfSlug, getExecutionFrame()); m_didSelfSlug = FALSE; @@ -738,7 +738,7 @@ void Network::liteupdate() { } #endif - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { if (m_localStatus == NETLOCALSTATUS_PREGAME) { m_conMgr->update(FALSE); } else { @@ -748,7 +748,7 @@ void Network::liteupdate() { } void Network::endOfGameCheck() { - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { if (m_conMgr->canILeave()) { m_conMgr->disconnectLocalPlayer(); TheGameLogic->exitGame(); @@ -774,7 +774,7 @@ Bool Network::timeForNewFrame() { * to avoid being frozen by spikes in network lag. This will happen if another user's computer is * running too far behind us, so we need to slow down to let them catch up. */ - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { Real cushion = m_conMgr->getMinimumCushion(); Real runAheadPercentage = m_runAhead * (TheGlobalData->m_networkRunAheadSlack / (Real)100.0); // If we are at least 50% into our slack, we need to slow down. if (cushion < runAheadPercentage) { @@ -938,7 +938,7 @@ Bool Network::areAllQueuesEmpty(void) * Quit the game now. This should only be called from the disconnect screen. */ void Network::quitGame() { - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { m_conMgr->quitGame(); } @@ -968,28 +968,28 @@ Bool Network::isPacketRouter( void ) * Register a vote towards a player being disconnected. */ void Network::voteForPlayerDisconnect(Int slot) { - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { m_conMgr->voteForPlayerDisconnect(slot); } } void Network::updateLoadProgress( Int percent ) { - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { m_conMgr->updateLoadProgress( percent ); } } void Network::loadProgressComplete( void ) { - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { m_conMgr->loadProgressComplete(); } } void Network::sendTimeOutGameStart( void ) { - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { m_conMgr->sendTimeOutGameStart(); } } @@ -997,7 +997,7 @@ void Network::sendTimeOutGameStart( void ) UnsignedInt Network::getLocalPlayerID() { -if (m_conMgr != NULL) { +if (m_conMgr != nullptr) { return m_conMgr->getLocalPlayerID(); } return 49; @@ -1009,21 +1009,21 @@ UnicodeString Network::getPlayerName(Int playerNum) return UnicodeString::TheEmptyString; } } - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { return m_conMgr->getPlayerName( playerNum ); } return UnicodeString::TheEmptyString; } Int Network::getNumPlayers() { - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { return m_conMgr->getNumPlayers(); } return -1; } Int Network::getSlotAverageFPS(Int slot) { - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { return m_conMgr->getSlotAverageFPS(slot); } return -1; @@ -1040,13 +1040,13 @@ void Network::toggleNetworkOn() { #endif void Network::notifyOthersOfCurrentFrame() { - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { m_conMgr->notifyOthersOfCurrentFrame(TheGameLogic->getFrame()); } } void Network::notifyOthersOfNewFrame(UnsignedInt frame) { - if (m_conMgr != NULL) { + if (m_conMgr != nullptr) { m_conMgr->notifyOthersOfNewFrame(frame); } } diff --git a/Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp b/Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp index 4d04807d28c..174599cc97c 100644 --- a/Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp +++ b/Core/GameEngine/Source/GameNetwork/NetworkUtil.cpp @@ -84,9 +84,9 @@ UnsignedInt ResolveIP(AsciiString host) struct hostent *hostStruct; struct in_addr *hostNode; - if (host.getLength() == 0) + if (host.isEmpty()) { - DEBUG_LOG(("ResolveIP(): Can't resolve NULL")); + DEBUG_LOG(("ResolveIP(): Can't resolve null")); return 0; } @@ -98,7 +98,7 @@ UnsignedInt ResolveIP(AsciiString host) // String such as "localhost" hostStruct = gethostbyname(host.str()); - if (hostStruct == NULL) + if (hostStruct == nullptr) { DEBUG_LOG(("ResolveIP(): Can't resolve %s", host.str())); return 0; diff --git a/Core/GameEngine/Source/GameNetwork/Transport.cpp b/Core/GameEngine/Source/GameNetwork/Transport.cpp index 26c459f161b..9fe2c9305b1 100644 --- a/Core/GameEngine/Source/GameNetwork/Transport.cpp +++ b/Core/GameEngine/Source/GameNetwork/Transport.cpp @@ -70,7 +70,7 @@ static inline void decryptBuf( unsigned char *buf, Int len ) Transport::Transport(void) { m_winsockInit = false; - m_udpsock = NULL; + m_udpsock = nullptr; } Transport::~Transport(void) @@ -120,7 +120,7 @@ Bool Transport::init( UnsignedInt ip, UnsignedShort port ) DEBUG_CRASH(("Could not bind to 0x%8.8X:%d", ip, port)); DEBUG_LOG(("Transport::init - Failure to bind socket with error code %x", retval)); delete m_udpsock; - m_udpsock = NULL; + m_udpsock = nullptr; return false; } @@ -162,7 +162,7 @@ Bool Transport::init( UnsignedInt ip, UnsignedShort port ) void Transport::reset( void ) { delete m_udpsock; - m_udpsock = NULL; + m_udpsock = nullptr; if (m_winsockInit) { @@ -190,7 +190,7 @@ Bool Transport::update( void ) Bool Transport::doSend() { if (!m_udpsock) { - DEBUG_LOG(("Transport::doSend() - m_udpSock is NULL!")); + DEBUG_LOG(("Transport::doSend() - m_udpSock is null!")); return FALSE; } @@ -217,6 +217,10 @@ Bool Transport::doSend() { if (m_outBuffer[i].length != 0) { int bytesSent = 0; + // TheSuperHackers @info The handling of data sizing of the payload within a UDP packet is confusing due to the current networking implementation + // The max game packet size needs to be smaller than max udp payload by sizeof(TransportMessageHeader) + // But the max network message size needs to include the bytes of the transport message header and equal the max udp payload + // Therefore, transmitted data needs to add the extra bytes of the network header to the payloads length int bytesToSend = m_outBuffer[i].length + sizeof(TransportMessageHeader); // Send this message if ((bytesSent = m_udpsock->Write((unsigned char *)(&m_outBuffer[i]), bytesToSend, m_outBuffer[i].addr, m_outBuffer[i].port)) > 0) @@ -270,7 +274,7 @@ Bool Transport::doRecv() { if (!m_udpsock) { - DEBUG_LOG(("Transport::doRecv() - m_udpSock is NULL!")); + DEBUG_LOG(("Transport::doRecv() - m_udpSock is null!")); return FALSE; } @@ -281,12 +285,15 @@ Bool Transport::doRecv() #if defined(RTS_DEBUG) UnsignedInt now = timeGetTime(); #endif - + // TheSuperHackers @info The handling of data sizing of the payload within a UDP packet is confusing due to the current networking implementation + // The max game packet size needs to be smaller than max udp payload by sizeof(TransportMessageHeader) + // But the max network message size needs to include the bytes of the transport message header and equal the max udp payload + // Therefore, when receiving data we use the max udp payload size to receive the game packet payload and network header TransportMessage incomingMessage; unsigned char *buf = (unsigned char *)&incomingMessage; - int len = MAX_MESSAGE_LEN; + int len = MAX_NETWORK_MESSAGE_LEN; // DEBUG_LOG(("Transport::doRecv - checking")); - while ( (len=m_udpsock->Read(buf, MAX_MESSAGE_LEN, &from)) > 0 ) + while ( (len=m_udpsock->Read(buf, MAX_NETWORK_MESSAGE_LEN, &from)) > 0 ) { #if defined(RTS_DEBUG) // Packet loss simulation @@ -417,7 +424,7 @@ Bool Transport::isGeneralsPacket( TransportMessage *msg ) if (!msg) return false; - if (msg->length < 0 || msg->length > MAX_MESSAGE_LEN) + if (msg->length < 0 || msg->length > MAX_NETWORK_MESSAGE_LEN) return false; CRC crc; diff --git a/Core/GameEngine/Source/GameNetwork/WOLBrowser/WebBrowser.cpp b/Core/GameEngine/Source/GameNetwork/WOLBrowser/WebBrowser.cpp index d644725d483..ca18a2de9ef 100644 --- a/Core/GameEngine/Source/GameNetwork/WOLBrowser/WebBrowser.cpp +++ b/Core/GameEngine/Source/GameNetwork/WOLBrowser/WebBrowser.cpp @@ -57,7 +57,7 @@ class OLEInitializer OLEInitializer() { // Initialize this instance - OleInitialize(NULL); + OleInitialize(nullptr); } ~OLEInitializer() { @@ -67,7 +67,7 @@ class OLEInitializer OLEInitializer g_OLEInitializer; CComModule _Module; -CComObject * TheWebBrowser = NULL; +CComObject * TheWebBrowser = nullptr; /****************************************************************************** @@ -90,7 +90,7 @@ WebBrowser::WebBrowser() : mRefCount(1) { DEBUG_LOG(("Instantiating embedded WebBrowser")); - m_urlList = NULL; + m_urlList = nullptr; } @@ -114,15 +114,15 @@ WebBrowser::~WebBrowser() { DEBUG_LOG(("Destructing embedded WebBrowser")); if (this == TheWebBrowser) { - DEBUG_LOG(("WebBrowser::~WebBrowser - setting TheWebBrowser to NULL")); - TheWebBrowser = NULL; + DEBUG_LOG(("WebBrowser::~WebBrowser - setting TheWebBrowser to null")); + TheWebBrowser = nullptr; } WebBrowserURL *url = m_urlList; - while (url != NULL) { + while (url != nullptr) { WebBrowserURL *temp = url; url = url->m_next; deleteInstance(temp); - temp = NULL; + temp = nullptr; } } @@ -132,14 +132,14 @@ WebBrowser::~WebBrowser() const FieldParse WebBrowserURL::m_URLFieldParseTable[] = { - { "URL", INI::parseAsciiString, NULL, offsetof( WebBrowserURL, m_url ) }, - { NULL, NULL, NULL, 0 }, + { "URL", INI::parseAsciiString, nullptr, offsetof( WebBrowserURL, m_url ) }, + { nullptr, nullptr, nullptr, 0 }, }; WebBrowserURL::WebBrowserURL() { - m_next = NULL; + m_next = nullptr; m_tag.clear(); m_url.clear(); } @@ -165,9 +165,9 @@ WebBrowserURL::~WebBrowserURL() void WebBrowser::init() { - m_urlList = NULL; + m_urlList = nullptr; INI ini; - ini.loadFileDirectory( "Data\\INI\\Webpages", INI_LOAD_OVERWRITE, NULL ); + ini.loadFileDirectory( "Data\\INI\\Webpages", INI_LOAD_OVERWRITE, nullptr ); } /****************************************************************************** @@ -198,7 +198,7 @@ WebBrowserURL * WebBrowser::findURL(AsciiString tag) { WebBrowserURL *retval = m_urlList; - while ((retval != NULL) && tag.compareNoCase(retval->m_tag.str())) + while ((retval != nullptr) && tag.compareNoCase(retval->m_tag.str())) { retval = retval->m_next; } @@ -234,7 +234,7 @@ WebBrowserURL * WebBrowser::makeNewURL(AsciiString tag) STDMETHODIMP WebBrowser::QueryInterface(REFIID iid, void** ppv) IUNKNOWN_NOEXCEPT { - *ppv = NULL; + *ppv = nullptr; if ((iid == IID_IUnknown) || (iid == IID_IBrowserDispatch)) { @@ -294,7 +294,7 @@ ULONG STDMETHODCALLTYPE WebBrowser::Release(void) IUNKNOWN_NOEXCEPT { DEBUG_LOG(("WebBrowser::Release - all references released, deleting the object.")); if (this == TheWebBrowser) { - TheWebBrowser = NULL; + TheWebBrowser = nullptr; } delete this; return 0; diff --git a/Core/GameEngine/Source/GameNetwork/udp.cpp b/Core/GameEngine/Source/GameNetwork/udp.cpp index fd21c6e066a..cc4c087d0b4 100644 --- a/Core/GameEngine/Source/GameNetwork/udp.cpp +++ b/Core/GameEngine/Source/GameNetwork/udp.cpp @@ -134,7 +134,7 @@ Int UDP::Bind(const char *Host,UnsignedShort port) return ( Bind( ntohl(inet_addr(Host)), port) ); hostStruct = gethostbyname(Host); - if (hostStruct == NULL) + if (hostStruct == nullptr) return (0); hostNode = (struct in_addr *) hostStruct->h_addr; return ( Bind(ntohl(hostNode->s_addr),port) ); @@ -264,7 +264,7 @@ Int UDP::Read(unsigned char *msg,UnsignedInt len,sockaddr_in *from) Int retval; int alen=sizeof(sockaddr_in); - if (from!=NULL) + if (from!=nullptr) { retval=recvfrom(fd,(char *)msg,len,0,(struct sockaddr *)from,&alen); #ifdef _WIN32 @@ -287,7 +287,7 @@ Int UDP::Read(unsigned char *msg,UnsignedInt len,sockaddr_in *from) } else { - retval=recvfrom(fd,(char *)msg,len,0,NULL,NULL); + retval=recvfrom(fd,(char *)msg,len,0,nullptr,nullptr); #ifdef _WIN32 if (retval==SOCKET_ERROR) { @@ -434,7 +434,7 @@ int UDP::Wait(Int sec,Int usec,fd_set &givenSet,fd_set &returnSet) while( ! done) { if (noTimeout) - retval=select(givenMax+1,&returnSet,0,0,NULL); + retval=select(givenMax+1,&returnSet,0,0,nullptr); else { timeout.GetTimevalMT(tv); diff --git a/Core/GameEngineDevice/CMakeLists.txt b/Core/GameEngineDevice/CMakeLists.txt index 7ebd9b02944..93184aa47b1 100644 --- a/Core/GameEngineDevice/CMakeLists.txt +++ b/Core/GameEngineDevice/CMakeLists.txt @@ -10,25 +10,26 @@ set(GAMEENGINEDEVICE_SRC # Include/W3DDevice/GameClient/camerashakesystem.h Include/W3DDevice/GameClient/FlatHeightMap.h Include/W3DDevice/GameClient/HeightMap.h -# Include/W3DDevice/GameClient/Module/W3DDebrisDraw.h -# Include/W3DDevice/GameClient/Module/W3DDefaultDraw.h -# Include/W3DDevice/GameClient/Module/W3DDependencyModelDraw.h + Include/W3DDevice/GameClient/Module/W3DDebrisDraw.h + Include/W3DDevice/GameClient/Module/W3DDefaultDraw.h + Include/W3DDevice/GameClient/Module/W3DDependencyModelDraw.h Include/W3DDevice/GameClient/Module/W3DLaserDraw.h -# Include/W3DDevice/GameClient/Module/W3DModelDraw.h -# Include/W3DDevice/GameClient/Module/W3DOverlordAircraftDraw.h -# Include/W3DDevice/GameClient/Module/W3DOverlordTankDraw.h -# Include/W3DDevice/GameClient/Module/W3DOverlordTruckDraw.h -# Include/W3DDevice/GameClient/Module/W3DPoliceCarDraw.h -# Include/W3DDevice/GameClient/Module/W3DProjectileStreamDraw.h + Include/W3DDevice/GameClient/Module/W3DModelDraw.h + Include/W3DDevice/GameClient/Module/W3DOverlordAircraftDraw.h + Include/W3DDevice/GameClient/Module/W3DOverlordTankDraw.h + Include/W3DDevice/GameClient/Module/W3DOverlordTruckDraw.h + Include/W3DDevice/GameClient/Module/W3DPoliceCarDraw.h + Include/W3DDevice/GameClient/Module/W3DProjectileStreamDraw.h Include/W3DDevice/GameClient/Module/W3DPropDraw.h -# Include/W3DDevice/GameClient/Module/W3DRopeDraw.h -# Include/W3DDevice/GameClient/Module/W3DScienceModelDraw.h -# Include/W3DDevice/GameClient/Module/W3DSupplyDraw.h -# Include/W3DDevice/GameClient/Module/W3DTankDraw.h -# Include/W3DDevice/GameClient/Module/W3DTankTruckDraw.h -# Include/W3DDevice/GameClient/Module/W3DTracerDraw.h + Include/W3DDevice/GameClient/Module/W3DRopeDraw.h + Include/W3DDevice/GameClient/Module/W3DScienceModelDraw.h + Include/W3DDevice/GameClient/Module/W3DSupplyDraw.h + Include/W3DDevice/GameClient/Module/W3DTankDraw.h + Include/W3DDevice/GameClient/Module/W3DTankTruckDraw.h + Include/W3DDevice/GameClient/Module/W3DTracerDraw.h Include/W3DDevice/GameClient/Module/W3DTreeDraw.h -# Include/W3DDevice/GameClient/Module/W3DTruckDraw.h + Include/W3DDevice/GameClient/Module/W3DTruckDraw.h + Include/W3DDevice/GameClient/Module/W3DDependencyCarrierDraw.h Include/W3DDevice/GameClient/TerrainTex.h Include/W3DDevice/GameClient/TileData.h # Include/W3DDevice/GameClient/W3DAssetManager.h @@ -83,7 +84,6 @@ set(GAMEENGINEDEVICE_SRC # Include/W3DDevice/GameLogic/W3DTerrainLogic.h Include/Win32Device/Common/Win32BIGFile.h Include/Win32Device/Common/Win32BIGFileSystem.h -# Include/Win32Device/Common/Win32CDManager.h # Include/Win32Device/Common/Win32GameEngine.h Include/Win32Device/Common/Win32LocalFile.h Include/Win32Device/Common/Win32LocalFileSystem.h @@ -99,25 +99,26 @@ set(GAMEENGINEDEVICE_SRC # Source/W3DDevice/Common/W3DConvert.cpp Source/W3DDevice/GameClient/BaseHeightMap.cpp Source/W3DDevice/GameClient/CameraShakeSystem.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DProjectileStreamDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DProjectileStreamDraw.cpp Source/W3DDevice/GameClient/Drawable/Draw/W3DPropDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DRopeDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DScienceModelDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DSupplyDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DTracerDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DRopeDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DScienceModelDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DSupplyDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DTracerDraw.cpp Source/W3DDevice/GameClient/Drawable/Draw/W3DTreeDraw.cpp -# Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp + Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyCarrierDraw.cpp Source/W3DDevice/GameClient/FlatHeightMap.cpp # Source/W3DDevice/GameClient/GUI/Gadget/W3DCheckBox.cpp # Source/W3DDevice/GameClient/GUI/Gadget/W3DComboBox.cpp @@ -184,7 +185,6 @@ set(GAMEENGINEDEVICE_SRC # Source/W3DDevice/GameLogic/W3DTerrainLogic.cpp Source/Win32Device/Common/Win32BIGFile.cpp Source/Win32Device/Common/Win32BIGFileSystem.cpp -# Source/Win32Device/Common/Win32CDManager.cpp # Source/Win32Device/Common/Win32GameEngine.cpp Source/Win32Device/Common/Win32LocalFile.cpp Source/Win32Device/Common/Win32LocalFileSystem.cpp diff --git a/Core/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h b/Core/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h index 932747f1d1e..567f58acda6 100644 --- a/Core/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h +++ b/Core/GameEngineDevice/Include/MilesAudioDevice/MilesAudioManager.h @@ -70,10 +70,10 @@ struct PlayingAudio PlayingAudio() : m_type(PAT_INVALID), - m_audioEventRTS(NULL), + m_audioEventRTS(nullptr), m_requestStop(false), m_cleanupAudioEventRTS(true), - m_sample(NULL), + m_sample(nullptr), m_framesFaded(0) { } }; @@ -137,7 +137,7 @@ class MilesAudioManager : public AudioManager public: #if defined(RTS_DEBUG) - virtual void audioDebugDisplay(DebugDisplayInterface *dd, void *, FILE *fp = NULL ); + virtual void audioDebugDisplay(DebugDisplayInterface *dd, void *, FILE *fp = nullptr ); virtual AudioHandle addAudioEvent( const AudioEventRTS *eventToAdd ); ///< Add an audio event (event must be declared in an INI file) #endif @@ -273,8 +273,8 @@ class MilesAudioManager : public AudioManager void stopAllSpeech( void ); protected: - void initFilters( HSAMPLE sample, const AudioEventRTS *eventInfo ); - void initFilters3D( H3DSAMPLE sample, const AudioEventRTS *eventInfo, const Coord3D *pos ); + void initFilters( HSAMPLE sample, AudioEventRTS *eventInfo ); + void initFilters3D( H3DSAMPLE sample, AudioEventRTS *eventInfo, const Coord3D *pos ); void handleLoopStopEarly(PlayingAudio* audio); diff --git a/Core/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h b/Core/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h index 528ddb52a92..9dffa0ab60f 100644 --- a/Core/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h +++ b/Core/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h @@ -37,6 +37,7 @@ // FORWARD REFERENCES ///////////////////////////////////////////////////////////////////////////// class TextureClass; +class SurfaceClass; class TerrainLogic; // PROTOTYPES ///////////////////////////////////////////////////////////////////////////////////// @@ -63,11 +64,15 @@ class W3DRadar : public Radar virtual void draw( Int pixelX, Int pixelY, Int width, Int height ); ///< draw the radar virtual void clearShroud(); - virtual void setShroudLevel(Int x, Int y, CellShroudStatus setting); + virtual void setShroudLevel(Int x, Int y, CellShroudStatus setting); ///< set the shroud level at shroud cell x,y + virtual void beginSetShroudLevel(); ///< call this once before multiple calls to setShroudLevel for better performance + virtual void endSetShroudLevel(); ///< call this once after beginSetShroudLevel and setShroudLevel virtual void refreshTerrain( TerrainLogic *terrain ); virtual void refreshObjects(); + virtual void notifyViewChanged(); ///< signals that the camera view has changed + protected: void drawSingleBeaconEvent( Int pixelX, Int pixelY, Int width, Int height, Int index ); @@ -104,19 +109,21 @@ class W3DRadar : public Radar WW3DFormat m_shroudTextureFormat; ///< format to use for shroud texture Image *m_shroudImage; ///< shroud image abstraction for drawing TextureClass *m_shroudTexture; ///< shroud texture + SurfaceClass *m_shroudSurface; ///< surface to shroud texture + void *m_shroudSurfaceBits; ///< shroud surface bits + int m_shroudSurfacePitch; ///< shroud surface pitch + WW3DFormat m_shroudSurfaceFormat; ///< shroud surface format + UnsignedInt m_shroudSurfacePixelSize; ///< shroud surface pixel size Int m_textureWidth; ///< width for all radar textures Int m_textureHeight; ///< height for all radar textures // - // we want to keep a flag that tells us when to reconstruct the view box, we want - // to reconstruct the box on map change, and when the camera changes height - // or orientation. We want to avoid making the view box every frame because - // the 4 points visible on the edge of the screen will "jitter" unevenly as we - // translate real world coords to integer radar spots + // We want to keep a flag that tells us when to reconstruct the view box. + // We want to avoid making the view box every frame because the 4 points + // visible on the edge of the screen will "jitter" unevenly as we translate + // real world coordinates to integer radar positions. // Bool m_reconstructViewBox; ///< true when we need to reconstruct the box - Real m_viewAngle; ///< camera angle used for the view box we have - Real m_viewZoom; ///< camera zoom used for the view box we have ICoord2D m_viewBox[ 4 ]; ///< radar cell points for the 4 corners of view box }; diff --git a/Core/GameEngineDevice/Include/W3DDevice/GameClient/HeightMap.h b/Core/GameEngineDevice/Include/W3DDevice/GameClient/HeightMap.h index 4e35b067290..6352058dcf1 100644 --- a/Core/GameEngineDevice/Include/W3DDevice/GameClient/HeightMap.h +++ b/Core/GameEngineDevice/Include/W3DDevice/GameClient/HeightMap.h @@ -37,7 +37,6 @@ #include "W3DDevice/GameClient/WorldHeightMap.h" #include "W3DDevice/GameClient/BaseHeightMap.h" -#define VERTEX_BUFFER_TILE_LENGTH 32 //tiles of side length 32 (grid of 33x33 vertices). // Adjust the triangles to make cliff sides most attractive. jba. #define FLIP_TRIANGLES 1 @@ -48,10 +47,10 @@ Custom W3D render object that's used to process the terrain. It handles virtually everything to do with the terrain, including: drawing, lighting, scorchmarks and intersection tests. -*/ - - +TheSuperHackers @performance xezon 13/01/2026 +Class now stores the vertex buffer backup as one big array for optimal data locality. +*/ class HeightMapRenderObjClass : public BaseHeightMapRenderObjClass { @@ -89,9 +88,9 @@ class HeightMapRenderObjClass : public BaseHeightMapRenderObjClass Int *m_extraBlendTilePositions; ///x; m_guardBandBias.y = gb->y; } - private: CameraClass *m_3DCamera; ///< camera representation for 3D scene @@ -276,12 +275,14 @@ class W3DView : public View, public SubsystemInterface Real m_groundLevel; ///< height of ground. - Region2D m_cameraConstraint; ///< m_pos should be constrained to be within this area - Bool m_cameraConstraintValid; ///< if f, recalc cam constraints + Region2D m_cameraAreaConstraints; ///< Camera should be constrained to be within this area + Bool m_cameraAreaConstraintsValid; ///< If false, recalculates the camera area constraints in the next render update + Bool m_recalcCamera; ///< Recalculates the camera transform in the next render update - void setCameraTransform( void ); ///< set the transform matrix of m_3DCamera, based on m_pos & m_angle - void buildCameraTransform( Matrix3D *transform ) ; ///< calculate (but do not set) the transform matrix of m_3DCamera, based on m_pos & m_angle - void calcCameraConstraints() ; ///< recalc m_cameraConstraint + void setCameraTransform(void); ///< set the transform matrix of m_3DCamera, based on m_pos & m_angle + void buildCameraTransform(Matrix3D *transform); ///< calculate (but do not set) the transform matrix of m_3DCamera, based on m_pos & m_angle + void calcCameraAreaConstraints(); ///< Recalculates the camera area constraints + Bool isWithinCameraHeightConstraints() const; void moveAlongWaypointPath(Real milliseconds); ///< Move camera along path. void getPickRay(const ICoord2D *screen, Vector3 *rayStart, Vector3 *rayEnd); ///m_audioEventRTS); dd->printf("%2d: %-20s - (%s) Volume: %d (2D)\n", i, playing->m_audioEventRTS->getEventName().str(), filenameNoSlashes.str(), REAL_TO_INT(volume)); - playingArray[i] = NULL; + playingArray[i] = nullptr; } } if( fp ) @@ -348,7 +348,7 @@ void MilesAudioManager::audioDebugDisplay(DebugDisplayInterface *dd, void *, FIL dd->printf("%2d: %-20s - (%s) Volume: %d, Dist: %s, %s\n", i, playing->m_audioEventRTS->getEventName().str(), filenameNoSlashes.str(), REAL_TO_INT(volume), distStr, str ); - playingArray[i] = NULL; + playingArray[i] = nullptr; } } if( fp ) @@ -499,12 +499,12 @@ void MilesAudioManager::stopAudio( AudioAffect which ) std::list::iterator it; - PlayingAudio *playing = NULL; + PlayingAudio *playing = nullptr; if (BitIsSet(which, AudioAffect_Sound)) { for (it = m_playingSounds.begin(); it != m_playingSounds.end(); ++it) { playing = *it; if (playing) { - AIL_register_EOS_callback(playing->m_sample, NULL); + AIL_register_EOS_callback(playing->m_sample, nullptr); AIL_stop_sample(playing->m_sample); playing->m_status = PS_Stopped; } @@ -515,7 +515,7 @@ void MilesAudioManager::stopAudio( AudioAffect which ) for (it = m_playing3DSounds.begin(); it != m_playing3DSounds.end(); ++it) { playing = *it; if (playing) { - AIL_register_3D_EOS_callback(playing->m_3DSample, NULL); + AIL_register_3D_EOS_callback(playing->m_3DSample, nullptr); AIL_stop_3D_sample(playing->m_3DSample); playing->m_status = PS_Stopped; } @@ -535,7 +535,7 @@ void MilesAudioManager::stopAudio( AudioAffect which ) continue; } } - AIL_register_stream_callback(playing->m_stream, NULL); + AIL_register_stream_callback(playing->m_stream, nullptr); AIL_pause_stream(playing->m_stream, 1); playing->m_status = PS_Stopped; } @@ -548,7 +548,7 @@ void MilesAudioManager::pauseAudio( AudioAffect which ) { std::list::iterator it; - PlayingAudio *playing = NULL; + PlayingAudio *playing = nullptr; if (BitIsSet(which, AudioAffect_Sound)) { for (it = m_playingSounds.begin(); it != m_playingSounds.end(); ++it) { playing = *it; @@ -609,7 +609,7 @@ void MilesAudioManager::resumeAudio( AudioAffect which ) { std::list::iterator it; - PlayingAudio *playing = NULL; + PlayingAudio *playing = nullptr; if (BitIsSet(which, AudioAffect_Sound)) { for (it = m_playingSounds.begin(); it != m_playingSounds.end(); ++it) { playing = *it; @@ -665,7 +665,7 @@ void MilesAudioManager::playAudioEvent( AudioEventRTS *event ) } std::list::iterator it; - PlayingAudio *playing = NULL; + PlayingAudio *playing = nullptr; AudioHandle handleToKill = event->getHandleToKill(); @@ -680,18 +680,10 @@ void MilesAudioManager::playAudioEvent( AudioEventRTS *event ) DEBUG_LOG(("- Stream")); #endif - if ((info->m_soundType == AT_Streaming) && event->getUninterruptable()) { + if ((info->m_soundType == AT_Streaming) && event->getUninterruptible()) { stopAllSpeech(); } - Real curVolume = 1.0; - if (info->m_soundType == AT_Music) { - curVolume = m_musicVolume; - } else { - curVolume = m_speechVolume; - } - curVolume *= event->getVolume(); - Bool foundSoundToReplace = false; if (handleToKill) { for (it = m_playingStreams.begin(); it != m_playingStreams.end(); ++it) { @@ -715,7 +707,7 @@ void MilesAudioManager::playAudioEvent( AudioEventRTS *event ) if (!handleToKill || foundSoundToReplace) { stream = AIL_open_stream(m_digitalHandle, fileToPlay.str(), 0); } else { - stream = NULL; + stream = nullptr; } // Put this on here, so that the audio event RTS will be cleaned up regardless. @@ -724,13 +716,13 @@ void MilesAudioManager::playAudioEvent( AudioEventRTS *event ) audio->m_type = PAT_Stream; if (stream) { - if ((info->m_soundType == AT_Streaming) && event->getUninterruptable()) { + if ((info->m_soundType == AT_Streaming) && event->getUninterruptible()) { setDisallowSpeech(TRUE); } - AIL_set_stream_volume_pan(stream, curVolume, 0.5f); + AIL_set_stream_volume_pan(stream, getEffectiveVolume(event), 0.5f); playStream(event, stream); m_playingStreams.push_back(audio); - audio = NULL; + audio = nullptr; } break; } @@ -785,12 +777,12 @@ void MilesAudioManager::playAudioEvent( AudioEventRTS *event ) } else { - sample3D = NULL; + sample3D = nullptr; } // Push it onto the list of playing things audio->m_audioEventRTS = event; audio->m_3DSample = sample3D; - audio->m_file = NULL; + audio->m_file = nullptr; audio->m_type = PAT_3DSample; m_playing3DSounds.push_back(audio); @@ -808,7 +800,7 @@ void MilesAudioManager::playAudioEvent( AudioEventRTS *event ) } else { - audio = NULL; + audio = nullptr; #ifdef INTENSIVE_AUDIO_DEBUG DEBUG_LOG((" Playing.")); #endif @@ -855,13 +847,13 @@ void MilesAudioManager::playAudioEvent( AudioEventRTS *event ) } else { - sample = NULL; + sample = nullptr; } // Push it onto the list of playing things audio->m_audioEventRTS = event; audio->m_sample = sample; - audio->m_file = NULL; + audio->m_file = nullptr; audio->m_type = PAT_Sample; m_playingSounds.push_back(audio); @@ -876,7 +868,7 @@ void MilesAudioManager::playAudioEvent( AudioEventRTS *event ) #endif m_playingSounds.pop_back(); } else { - audio = NULL; + audio = nullptr; } #ifdef INTENSIVE_AUDIO_DEBUG @@ -887,8 +879,8 @@ void MilesAudioManager::playAudioEvent( AudioEventRTS *event ) } } - // If we were able to successfully play audio, then we set it to NULL above. (And it will be freed - // later. However, if audio is non-NULL at this point, then it must be freed. + // If we were able to successfully play audio, then we set it to null above. (And it will be freed + // later. However, if audio is non-null at this point, then it must be freed. if (audio) { releasePlayingAudio(audio); } @@ -1151,7 +1143,7 @@ void MilesAudioManager::releaseMilesHandles( PlayingAudio *release ) case PAT_Sample: { if (release->m_sample) { - AIL_register_EOS_callback(release->m_sample, NULL); + AIL_register_EOS_callback(release->m_sample, nullptr); AIL_stop_sample(release->m_sample); m_availableSamples.push_back(release->m_sample); } @@ -1160,7 +1152,7 @@ void MilesAudioManager::releaseMilesHandles( PlayingAudio *release ) case PAT_3DSample: { if (release->m_3DSample) { - AIL_register_3D_EOS_callback(release->m_3DSample, NULL); + AIL_register_3D_EOS_callback(release->m_3DSample, nullptr); AIL_stop_3D_sample(release->m_3DSample); m_available3DSamples.push_back(release->m_3DSample); } @@ -1169,7 +1161,7 @@ void MilesAudioManager::releaseMilesHandles( PlayingAudio *release ) case PAT_Stream: { if (release->m_stream) { - AIL_register_stream_callback(release->m_stream, NULL); + AIL_register_stream_callback(release->m_stream, nullptr); AIL_close_stream(release->m_stream); } break; @@ -1198,7 +1190,7 @@ void MilesAudioManager::releasePlayingAudio( PlayingAudio *release ) releaseAudioEventRTS(release->m_audioEventRTS); } delete release; - release = NULL; + release = nullptr; } //------------------------------------------------------------------------------------------------- @@ -1294,7 +1286,7 @@ HSAMPLE MilesAudioManager::getFirst2DSample( AudioEventRTS *event ) // Find the first sample of lower priority than my augmented priority that is interruptable and take its handle - return NULL; + return nullptr; } //------------------------------------------------------------------------------------------------- @@ -1307,28 +1299,27 @@ H3DSAMPLE MilesAudioManager::getFirst3DSample( AudioEventRTS *event ) } // Find the first sample of lower priority than my augmented priority that is interruptable and take its handle - return NULL; + return nullptr; } //------------------------------------------------------------------------------------------------- void MilesAudioManager::adjustPlayingVolume( PlayingAudio *audio ) { - Real desiredVolume = audio->m_audioEventRTS->getVolume() * audio->m_audioEventRTS->getVolumeShift(); Real pan; if (audio->m_type == PAT_Sample) { - AIL_sample_volume_pan(audio->m_sample, NULL, &pan); - AIL_set_sample_volume_pan(audio->m_sample, m_soundVolume * desiredVolume, pan); + AIL_sample_volume_pan(audio->m_sample, nullptr, &pan); + AIL_set_sample_volume_pan(audio->m_sample, getEffectiveVolume(audio->m_audioEventRTS), pan); } else if (audio->m_type == PAT_3DSample) { - AIL_set_3D_sample_volume(audio->m_3DSample, m_sound3DVolume * desiredVolume); + AIL_set_3D_sample_volume(audio->m_3DSample, getEffectiveVolume(audio->m_audioEventRTS)); } else if (audio->m_type == PAT_Stream) { - AIL_stream_volume_pan(audio->m_stream, NULL, &pan); + AIL_stream_volume_pan(audio->m_stream, nullptr, &pan); if (audio->m_audioEventRTS->getAudioEventInfo()->m_soundType == AT_Music ) { - AIL_set_stream_volume_pan(audio->m_stream, m_musicVolume * desiredVolume, pan); + AIL_set_stream_volume_pan(audio->m_stream, getEffectiveVolume(audio->m_audioEventRTS), pan); } else { - AIL_set_stream_volume_pan(audio->m_stream, m_speechVolume * desiredVolume, pan); + AIL_set_stream_volume_pan(audio->m_stream, getEffectiveVolume(audio->m_audioEventRTS), pan); } } @@ -1356,11 +1347,10 @@ void MilesAudioManager::stopAllSpeech( void ) } //------------------------------------------------------------------------------------------------- -void MilesAudioManager::initFilters( HSAMPLE sample, const AudioEventRTS *event ) +void MilesAudioManager::initFilters( HSAMPLE sample, AudioEventRTS *event ) { // set the sample volume - Real volume = event->getVolume() * event->getVolumeShift() * m_soundVolume; - AIL_set_sample_volume_pan(sample, volume, 0.5f); + AIL_set_sample_volume_pan(sample, getEffectiveVolume(event), 0.5f); // pitch shift Real pitchShift = event->getPitchShift(); @@ -1384,11 +1374,10 @@ void MilesAudioManager::initFilters( HSAMPLE sample, const AudioEventRTS *event } //------------------------------------------------------------------------------------------------- -void MilesAudioManager::initFilters3D( H3DSAMPLE sample, const AudioEventRTS *event, const Coord3D *pos ) +void MilesAudioManager::initFilters3D( H3DSAMPLE sample, AudioEventRTS *event, const Coord3D *pos ) { // set the sample volume - Real volume = event->getVolume() * event->getVolumeShift() * m_sound3DVolume; - AIL_set_3D_sample_volume(sample, volume); + AIL_set_3D_sample_volume(sample, getEffectiveVolume(event)); // pitch shift Real pitchShift = event->getPitchShift(); @@ -1529,7 +1518,7 @@ void MilesAudioManager::openDevice( void ) retval = AIL_quick_startup(audioSettings->m_useDigital, audioSettings->m_useMidi, audioSettings->m_outputRate, audioSettings->m_outputBits, audioSettings->m_outputChannels); // Quick handles tells us where to store the various devices. For now, we're only interested in the digital handle. - AIL_quick_handles(&m_digitalHandle, NULL, NULL); + AIL_quick_handles(&m_digitalHandle, nullptr, nullptr); if (retval) { buildProviderList(); @@ -1587,7 +1576,7 @@ Bool MilesAudioManager::isCurrentlyPlaying( AudioHandle handle ) // if something is requested, it is also considered playing std::list::iterator ait; - AudioRequest *req = NULL; + AudioRequest *req = nullptr; for (ait = m_audioRequests.begin(); ait != m_audioRequests.end(); ++ait) { req = *ait; if (req && req->m_usePendingEvent && req->m_pendingEvent->getPlayingHandle() == handle) { @@ -1730,7 +1719,7 @@ PlayingAudio *MilesAudioManager::findPlayingAudioFrom( UnsignedInt audioComplete } } - return NULL; + return nullptr; } @@ -1782,7 +1771,7 @@ void MilesAudioManager::selectProvider( UnsignedInt providerNdx ) } LPDIRECTSOUND lpDirectSoundInfo; - AIL_get_DirectSound_info( NULL, (void**)&lpDirectSoundInfo, NULL ); + AIL_get_DirectSound_info( nullptr, (void**)&lpDirectSoundInfo, nullptr ); Bool useDolby = FALSE; if( lpDirectSoundInfo ) { @@ -1874,7 +1863,7 @@ void MilesAudioManager::unselectProvider( void ) TheVideoPlayer->notifyVideoPlayerOfNewProvider(FALSE); } AIL_close_3D_listener(m_listener); - m_listener = NULL; + m_listener = nullptr; AIL_close_3D_provider(m_provider3D[m_selectedProvider].id); m_lastProvider = m_selectedProvider; @@ -1967,7 +1956,7 @@ Bool MilesAudioManager::doesViolateLimit( AudioEventRTS *event ) const std::list::const_iterator arIt; for (arIt = m_audioRequests.begin(); arIt != m_audioRequests.end(); ++arIt) { AudioRequest *req = (*arIt); - if (req == NULL) { + if (req == nullptr) { continue; } if( req->m_usePendingEvent ) @@ -2067,9 +2056,9 @@ AudioEventRTS* MilesAudioManager::findLowestPrioritySound( AudioEventRTS *event { //If the event we pass in is the lowest priority, don't bother checking because //there is nothing lower priority than lowest. - return NULL; + return nullptr; } - AudioEventRTS *lowestPriorityEvent = NULL; + AudioEventRTS *lowestPriorityEvent = nullptr; AudioPriority lowestPriority; std::list::const_iterator it; @@ -2210,15 +2199,14 @@ void MilesAudioManager::adjustVolumeOfPlayingAudio(AsciiString eventName, Real n Real pan; std::list::iterator it; - PlayingAudio *playing = NULL; + PlayingAudio *playing = nullptr; for (it = m_playingSounds.begin(); it != m_playingSounds.end(); ++it) { playing = *it; if (playing && playing->m_audioEventRTS->getEventName() == eventName) { // Adjust it playing->m_audioEventRTS->setVolume(newVolume); - Real desiredVolume = playing->m_audioEventRTS->getVolume() * playing->m_audioEventRTS->getVolumeShift(); - AIL_sample_volume_pan(playing->m_sample, NULL, &pan); - AIL_set_sample_volume_pan(playing->m_sample, desiredVolume, pan); + AIL_sample_volume_pan(playing->m_sample, nullptr, &pan); + AIL_set_sample_volume_pan(playing->m_sample, getEffectiveVolume(playing->m_audioEventRTS), pan); } } @@ -2227,8 +2215,7 @@ void MilesAudioManager::adjustVolumeOfPlayingAudio(AsciiString eventName, Real n if (playing && playing->m_audioEventRTS->getEventName() == eventName) { // Adjust it playing->m_audioEventRTS->setVolume(newVolume); - Real desiredVolume = playing->m_audioEventRTS->getVolume() * playing->m_audioEventRTS->getVolumeShift(); - AIL_set_3D_sample_volume(playing->m_3DSample, desiredVolume); + AIL_set_3D_sample_volume(playing->m_3DSample, getEffectiveVolume(playing->m_audioEventRTS)); } } @@ -2237,9 +2224,8 @@ void MilesAudioManager::adjustVolumeOfPlayingAudio(AsciiString eventName, Real n if (playing && playing->m_audioEventRTS->getEventName() == eventName) { // Adjust it playing->m_audioEventRTS->setVolume(newVolume); - Real desiredVolume = playing->m_audioEventRTS->getVolume() * playing->m_audioEventRTS->getVolumeShift(); - AIL_stream_volume_pan(playing->m_stream, NULL, &pan); - AIL_set_stream_volume_pan(playing->m_stream, desiredVolume, pan); + AIL_stream_volume_pan(playing->m_stream, nullptr, &pan); + AIL_set_stream_volume_pan(playing->m_stream, getEffectiveVolume(playing->m_audioEventRTS), pan); } } } @@ -2250,7 +2236,7 @@ void MilesAudioManager::removePlayingAudio( AsciiString eventName ) { std::list::iterator it; - PlayingAudio *playing = NULL; + PlayingAudio *playing = nullptr; for( it = m_playingSounds.begin(); it != m_playingSounds.end(); ) { playing = *it; @@ -2299,7 +2285,7 @@ void MilesAudioManager::removeAllDisabledAudio() { std::list::iterator it; - PlayingAudio *playing = NULL; + PlayingAudio *playing = nullptr; for( it = m_playingSounds.begin(); it != m_playingSounds.end(); ) { playing = *it; @@ -2349,7 +2335,7 @@ void MilesAudioManager::processRequestList( void ) std::list::iterator it; for (it = m_audioRequests.begin(); it != m_audioRequests.end(); /* empty */) { AudioRequest *req = (*it); - if (req == NULL) { + if (req == nullptr) { continue; } @@ -2439,7 +2425,7 @@ void MilesAudioManager::processPlayingList( void ) if( volForConsideration < m_audioSettings->m_minVolume && !playAnyways ) { // don't want to get an additional callback for this sample - AIL_register_3D_EOS_callback(playing->m_3DSample, NULL); + AIL_register_3D_EOS_callback(playing->m_3DSample, nullptr); //m_stoppedAudio.push_back(playing); releasePlayingAudio( playing ); it = m_playing3DSounds.erase(it); @@ -2456,7 +2442,7 @@ void MilesAudioManager::processPlayingList( void ) } else { - AIL_register_3D_EOS_callback(playing->m_3DSample, NULL); + AIL_register_3D_EOS_callback(playing->m_3DSample, nullptr); //m_stoppedAudio.push_back(playing); releasePlayingAudio( playing ); it = m_playing3DSounds.erase(it); @@ -2634,7 +2620,7 @@ Bool MilesAudioManager::checkForSample( AudioRequest *req ) return true; } - if ( req->m_pendingEvent->getAudioEventInfo() == NULL ) + if ( req->m_pendingEvent->getAudioEventInfo() == nullptr ) { // Fill in event info getInfoForAudioEvent( req->m_pendingEvent ); @@ -2710,7 +2696,7 @@ Real MilesAudioManager::getFileLengthMS( AsciiString strToLoad ) const } long retVal; - AIL_stream_ms_position(stream, &retVal, NULL); + AIL_stream_ms_position(stream, &retVal, nullptr); // Now close the stream AIL_close_stream(stream); @@ -2769,7 +2755,7 @@ void MilesAudioManager::setDeviceListenerPosition( void ) const Coord3D *MilesAudioManager::getCurrentPositionFromEvent( AudioEventRTS *event ) { if (!event->isPositionalAudio()) { - return NULL; + return nullptr; } return event->getCurrentPosition(); @@ -2786,25 +2772,29 @@ Bool MilesAudioManager::isOnScreen( const Coord3D *pos ) const //------------------------------------------------------------------------------------------------- Real MilesAudioManager::getEffectiveVolume(AudioEventRTS *event) const { - Real volume = 1.0f; - volume *= (event->getVolume() * event->getVolumeShift()); - if (event->getAudioEventInfo()->m_soundType == AT_Music) + Real volume = event->getVolume() * event->getVolumeShift(); + + switch (event->getAudioEventInfo()->m_soundType) + { + case AT_Music: { volume *= m_musicVolume; + break; } - else if (event->getAudioEventInfo()->m_soundType == AT_Streaming) + case AT_Streaming: { volume *= m_speechVolume; + break; } - else + case AT_SoundEffect: { if (event->isPositionalAudio()) { volume *= m_sound3DVolume; - Coord3D distance = m_listenerPosition; const Coord3D *pos = event->getCurrentPosition(); if (pos) { + Coord3D distance = m_listenerPosition; distance.sub(pos); Real objMinDistance; Real objMaxDistance; @@ -2839,6 +2829,8 @@ Real MilesAudioManager::getEffectiveVolume(AudioEventRTS *event) const { volume *= m_soundVolume; } + break; + } } return volume; @@ -2848,7 +2840,7 @@ Real MilesAudioManager::getEffectiveVolume(AudioEventRTS *event) const Bool MilesAudioManager::startNextLoop( PlayingAudio *looping ) { closeFile(looping->m_file); - looping->m_file = NULL; + looping->m_file = nullptr; if (looping->m_requestStop) { return false; @@ -2879,7 +2871,7 @@ Bool MilesAudioManager::startNextLoop( PlayingAudio *looping ) looping->m_file = playSample(looping->m_audioEventRTS, looping->m_sample); } - return looping->m_file != NULL; + return looping->m_file != nullptr; } return false; } @@ -2909,7 +2901,7 @@ void *MilesAudioManager::playSample( AudioEventRTS *event, HSAMPLE sample ) initFilters(sample, event); // Load the file in - void *fileBuffer = NULL; + void *fileBuffer = nullptr; fileBuffer = loadFileForRead(event); if (fileBuffer) { AIL_set_sample_file(sample, fileBuffer, 0); @@ -2954,7 +2946,7 @@ void *MilesAudioManager::playSample3D( AudioEventRTS *event, H3DSAMPLE sample3D return fileBuffer; } - return NULL; + return nullptr; } //------------------------------------------------------------------------------------------------- @@ -2986,7 +2978,7 @@ void MilesAudioManager::createListener( void ) //------------------------------------------------------------------------------------------------- void MilesAudioManager::initDelayFilter( void ) { - if (m_delayFilter != NULL) { + if (m_delayFilter != nullptr) { return; } @@ -3067,7 +3059,7 @@ void MilesAudioManager::processRequest( AudioRequest *req ) //------------------------------------------------------------------------------------------------- void *MilesAudioManager::getHandleForBink( void ) { - if (m_binkHandle == NULL) { + if (m_binkHandle == nullptr) { PlayingAudio *aud = allocatePlayingAudio(); aud->m_audioEventRTS = NEW AudioEventRTS("BinkHandle"); // poolify getInfoForAudioEvent(aud->m_audioEventRTS); @@ -3076,14 +3068,14 @@ void *MilesAudioManager::getHandleForBink( void ) if (!aud->m_sample) { releasePlayingAudio(aud); - return NULL; + return nullptr; } m_binkHandle = aud; } AILLPDIRECTSOUND lpDS; - AIL_get_DirectSound_info(m_binkHandle->m_sample, &lpDS, NULL); + AIL_get_DirectSound_info(m_binkHandle->m_sample, &lpDS, nullptr); return lpDS; } @@ -3092,7 +3084,7 @@ void MilesAudioManager::releaseHandleForBink( void ) { if (m_binkHandle) { releasePlayingAudio(m_binkHandle); - m_binkHandle = NULL; + m_binkHandle = nullptr; } } @@ -3176,7 +3168,7 @@ U32 AILCALLBACK streamingFileOpen(char const *fileName, void **file_handle) #endif (*file_handle) = (void *) TheFileSystem->openFile(fileName, File::READ | File::STREAMING); - return ((*file_handle) != 0); + return ((*file_handle) != nullptr); } //------------------------------------------------------------------------------------------------- @@ -3202,7 +3194,7 @@ U32 AILCALLBACK streamingFileRead(void *file_handle, void *buffer, U32 bytes) //------------------------------------------------------------------------------------------------- AudioFileCache::AudioFileCache() : m_maxSize(0), m_currentlyUsedSize(0), m_mutexName("AudioFileCacheMutex") { - m_mutex = CreateMutex(NULL, FALSE, m_mutexName); + m_mutex = CreateMutex(nullptr, FALSE, m_mutexName); } //------------------------------------------------------------------------------------------------- @@ -3246,7 +3238,7 @@ void *AudioFileCache::openFile( AudioEventRTS *eventToOpenFrom ) strToFind = eventToOpenFrom->getDecayFilename(); break; case PP_Done: - return NULL; + return nullptr; } OpenFilesHash::iterator it; @@ -3261,7 +3253,7 @@ void *AudioFileCache::openFile( AudioEventRTS *eventToOpenFrom ) File *file = TheFileSystem->openFile(strToFind.str()); if (!file) { DEBUG_ASSERTLOG(strToFind.isEmpty(), ("Missing Audio File: '%s'", strToFind.str())); - return NULL; + return nullptr; } UnsignedInt fileSize = file->size(); @@ -3277,7 +3269,7 @@ void *AudioFileCache::openFile( AudioEventRTS *eventToOpenFrom ) if (soundInfo.channels > 1) { DEBUG_CRASH(("Requested Positional Play of audio '%s', but it is in stereo.", strToFind.str())); delete [] buffer; - return NULL; + return nullptr; } } @@ -3300,7 +3292,7 @@ void *AudioFileCache::openFile( AudioEventRTS *eventToOpenFrom ) DEBUG_CRASH(("Unexpected compression type in '%s'", strToFind.str())); // prevent leaks delete [] buffer; - return NULL; + return nullptr; } openedAudioFile.m_fileSize = fileSize; @@ -3310,7 +3302,7 @@ void *AudioFileCache::openFile( AudioEventRTS *eventToOpenFrom ) if (!freeEnoughSpaceForSample(openedAudioFile)) { m_currentlyUsedSize -= openedAudioFile.m_fileSize; releaseOpenAudioFile(&openedAudioFile); - return NULL; + return nullptr; } } @@ -3362,8 +3354,8 @@ void AudioFileCache::releaseOpenAudioFile( OpenAudioFile *fileToRelease ) // Otherwise, we read it, we own it, blow it away. delete [] fileToRelease->m_file; } - fileToRelease->m_file = NULL; - fileToRelease->m_eventInfo = NULL; + fileToRelease->m_file = nullptr; + fileToRelease->m_eventInfo = nullptr; } } @@ -3490,6 +3482,6 @@ void MilesAudioManager::dumpAllAssetsUsed() } fprintf(logfile, "\nAudio Asset Report - END\n"); fclose(logfile); - logfile = NULL; + logfile = nullptr; } #endif diff --git a/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFile.cpp b/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFile.cpp index 1c988d12987..1f4148a251e 100644 --- a/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFile.cpp +++ b/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFile.cpp @@ -62,11 +62,11 @@ File* StdBIGFile::openFile( const Char *filename, Int access ) { const ArchivedFileInfo *fileInfo = getArchivedFileInfo(AsciiString(filename)); - if (fileInfo == NULL) { - return NULL; + if (fileInfo == nullptr) { + return nullptr; } - RAMFile *ramFile = NULL; + RAMFile *ramFile = nullptr; if (BitIsSet(access, File::STREAMING)) ramFile = newInstance( StreamingArchiveFile ); @@ -76,8 +76,8 @@ File* StdBIGFile::openFile( const Char *filename, Int access ) ramFile->deleteOnClose(); if (ramFile->openFromArchive(m_file, fileInfo->m_filename, fileInfo->m_offset, fileInfo->m_size) == FALSE) { ramFile->close(); - ramFile = NULL; - return NULL; + ramFile = nullptr; + return nullptr; } if ((access & File::WRITE) == 0) { @@ -90,12 +90,12 @@ File* StdBIGFile::openFile( const Char *filename, Int access ) constexpr size_t bufferSize = 0; File *localFile = TheLocalFileSystem->openFile(filename, access, bufferSize); - if (localFile != NULL) { + if (localFile != nullptr) { ramFile->copyDataToFile(localFile); } ramFile->close(); - ramFile = NULL; + ramFile = nullptr; return localFile; } @@ -153,7 +153,7 @@ Bool StdBIGFile::getFileInfo(const AsciiString& filename, FileInfo *fileInfo) co { const ArchivedFileInfo *tempFileInfo = getArchivedFileInfo(filename); - if (tempFileInfo == NULL) { + if (tempFileInfo == nullptr) { return FALSE; } diff --git a/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp b/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp index 13f7045bb86..ffd0150f4c5 100644 --- a/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp +++ b/Core/GameEngineDevice/Source/StdDevice/Common/StdBIGFileSystem.cpp @@ -51,8 +51,8 @@ StdBIGFileSystem::~StdBIGFileSystem() { } void StdBIGFileSystem::init() { - DEBUG_ASSERTCRASH(TheLocalFileSystem != NULL, ("TheLocalFileSystem must be initialized before TheArchiveFileSystem.")); - if (TheLocalFileSystem == NULL) { + DEBUG_ASSERTCRASH(TheLocalFileSystem != nullptr, ("TheLocalFileSystem must be initialized before TheArchiveFileSystem.")); + if (TheLocalFileSystem == nullptr) { return; } @@ -90,9 +90,9 @@ ArchiveFile * StdBIGFileSystem::openArchiveFile(const Char *filename) { DEBUG_LOG(("StdBIGFileSystem::openArchiveFile - opening BIG file %s", filename)); - if (fp == NULL) { + if (fp == nullptr) { DEBUG_CRASH(("Could not open archive file %s for parsing", filename)); - return NULL; + return nullptr; } AsciiString asciibuf; @@ -102,8 +102,8 @@ ArchiveFile * StdBIGFileSystem::openArchiveFile(const Char *filename) { if (strcmp(buffer, BIGFileIdentifier) != 0) { DEBUG_CRASH(("Error reading BIG file identifier in file %s", filename)); fp->close(); - fp = NULL; - return NULL; + fp = nullptr; + return nullptr; } // read in the file size. @@ -173,7 +173,7 @@ ArchiveFile * StdBIGFileSystem::openArchiveFile(const Char *filename) { archiveFile->attachFile(fp); delete fileInfo; - fileInfo = NULL; + fileInfo = nullptr; // leave fp open as the archive file will be using it. @@ -227,7 +227,7 @@ Bool StdBIGFileSystem::loadBigFilesFromDirectory(AsciiString dir, AsciiString fi ArchiveFile *archiveFile = openArchiveFile((*it).str()); - if (archiveFile != NULL) { + if (archiveFile != nullptr) { DEBUG_LOG(("StdBIGFileSystem::loadBigFilesFromDirectory - loading %s into the directory tree.", (*it).str())); loadIntoDirectoryTree(archiveFile, overwrite); m_archiveFileMap[(*it)] = archiveFile; diff --git a/Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp b/Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp index 119cd94a353..d47e473f4d2 100644 --- a/Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp +++ b/Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp @@ -131,13 +131,13 @@ File * StdLocalFileSystem::openFile(const Char *filename, Int access, size_t buf // sanity check if (strlen(filename) <= 0) { - return NULL; + return nullptr; } std::filesystem::path path = fixFilenameFromWindowsPath(filename, access); if (path.empty()) { - return NULL; + return nullptr; } if (access & File::WRITE) { @@ -148,7 +148,7 @@ File * StdLocalFileSystem::openFile(const Char *filename, Int access, size_t buf if (!std::filesystem::exists(dir, ec) || ec) { if(!std::filesystem::create_directories(dir, ec) || ec) { DEBUG_LOG(("StdLocalFileSystem::openFile - Error creating directory %s", dir.string().c_str())); - return NULL; + return nullptr; } } } @@ -157,7 +157,7 @@ File * StdLocalFileSystem::openFile(const Char *filename, Int access, size_t buf if (file->open(path.string().c_str(), access, bufferSize) == FALSE) { deleteInstance(file); - file = NULL; + file = nullptr; } else { file->deleteOnClose(); } diff --git a/Core/GameEngineDevice/Source/VideoDevice/Bink/BinkVideoPlayer.cpp b/Core/GameEngineDevice/Source/VideoDevice/Bink/BinkVideoPlayer.cpp index 09e9c85f229..34391190d43 100644 --- a/Core/GameEngineDevice/Source/VideoDevice/Bink/BinkVideoPlayer.cpp +++ b/Core/GameEngineDevice/Source/VideoDevice/Bink/BinkVideoPlayer.cpp @@ -187,9 +187,9 @@ void BinkVideoPlayer::regainFocus( void ) VideoStreamInterface* BinkVideoPlayer::createStream( HBINK handle ) { - if ( handle == NULL ) + if ( handle == nullptr ) { - return NULL; + return nullptr; } BinkVideoStream *stream = NEW BinkVideoStream; @@ -220,7 +220,7 @@ VideoStreamInterface* BinkVideoPlayer::createStream( HBINK handle ) VideoStreamInterface* BinkVideoPlayer::open( AsciiString movieTitle ) { - VideoStreamInterface* stream = NULL; + VideoStreamInterface* stream = nullptr; const Video* pVideo = getVideo(movieTitle); if (pVideo) { @@ -229,7 +229,7 @@ VideoStreamInterface* BinkVideoPlayer::open( AsciiString movieTitle ) if (TheGlobalData->m_modDir.isNotEmpty()) { char filePath[ _MAX_PATH ]; - sprintf( filePath, "%s%s\\%s.%s", TheGlobalData->m_modDir.str(), VIDEO_PATH, pVideo->m_filename.str(), VIDEO_EXT ); + snprintf( filePath, ARRAY_SIZE(filePath), "%s%s\\%s.%s", TheGlobalData->m_modDir.str(), VIDEO_PATH, pVideo->m_filename.str(), VIDEO_EXT ); HBINK handle = BinkOpen(filePath , BINKPRELOADALL ); DEBUG_ASSERTLOG(!handle, ("opened bink file %s", filePath)); if (handle) @@ -239,13 +239,13 @@ VideoStreamInterface* BinkVideoPlayer::open( AsciiString movieTitle ) } char localizedFilePath[ _MAX_PATH ]; - sprintf( localizedFilePath, VIDEO_LANG_PATH_FORMAT, GetRegistryLanguage().str(), pVideo->m_filename.str(), VIDEO_EXT ); + snprintf( localizedFilePath, ARRAY_SIZE(localizedFilePath), VIDEO_LANG_PATH_FORMAT, GetRegistryLanguage().str(), pVideo->m_filename.str(), VIDEO_EXT ); HBINK handle = BinkOpen(localizedFilePath , BINKPRELOADALL ); DEBUG_ASSERTLOG(!handle, ("opened localized bink file %s", localizedFilePath)); if (!handle) { char filePath[ _MAX_PATH ]; - sprintf( filePath, "%s\\%s.%s", VIDEO_PATH, pVideo->m_filename.str(), VIDEO_EXT ); + snprintf( filePath, ARRAY_SIZE(filePath), "%s\\%s.%s", VIDEO_PATH, pVideo->m_filename.str(), VIDEO_EXT ); handle = BinkOpen(filePath , BINKPRELOADALL ); DEBUG_ASSERTLOG(!handle, ("opened bink file %s", localizedFilePath)); } @@ -272,7 +272,7 @@ void BinkVideoPlayer::notifyVideoPlayerOfNewProvider( Bool nowHasValid ) { if (!nowHasValid) { TheAudio->releaseHandleForBink(); - BinkSetSoundTrack(0, 0); + BinkSetSoundTrack(0, nullptr); } else { initializeBinkWithMiles(); } @@ -291,7 +291,7 @@ void BinkVideoPlayer::initializeBinkWithMiles() } if( !driver || retVal == 0) { - BinkSetSoundTrack ( 0,0 ); + BinkSetSoundTrack ( 0,nullptr ); } } @@ -300,7 +300,7 @@ void BinkVideoPlayer::initializeBinkWithMiles() //============================================================================ BinkVideoStream::BinkVideoStream() -: m_handle(NULL) +: m_handle(nullptr) { } @@ -311,10 +311,10 @@ BinkVideoStream::BinkVideoStream() BinkVideoStream::~BinkVideoStream() { - if ( m_handle != NULL ) + if ( m_handle != nullptr ) { BinkClose( m_handle ); - m_handle = NULL; + m_handle = nullptr; } } @@ -379,7 +379,7 @@ void BinkVideoStream::frameRender( VideoBuffer *buffer ) return; } - if ( mem != NULL ) + if ( mem != nullptr ) { BinkCopyToBuffer ( m_handle, mem, buffer->pitch(), buffer->height(), @@ -423,7 +423,7 @@ Int BinkVideoStream::frameCount( void ) void BinkVideoStream::frameGoto( Int index ) { - BinkGoto(m_handle, index, NULL ); + BinkGoto(m_handle, index, 0 ); } //============================================================================ diff --git a/Core/GameEngineDevice/Source/VideoDevice/FFmpeg/FFmpegVideoPlayer.cpp b/Core/GameEngineDevice/Source/VideoDevice/FFmpeg/FFmpegVideoPlayer.cpp index 04baffcfeef..25118cb27c6 100644 --- a/Core/GameEngineDevice/Source/VideoDevice/FFmpeg/FFmpegVideoPlayer.cpp +++ b/Core/GameEngineDevice/Source/VideoDevice/FFmpeg/FFmpegVideoPlayer.cpp @@ -235,7 +235,7 @@ VideoStreamInterface* FFmpegVideoPlayer::open( AsciiString movieTitle ) if (TheGlobalData->m_modDir.isNotEmpty()) { char filePath[ _MAX_PATH ]; - sprintf( filePath, "%s%s\\%s.%s", TheGlobalData->m_modDir.str(), VIDEO_PATH, pVideo->m_filename.str(), VIDEO_EXT ); + snprintf( filePath, ARRAY_SIZE(filePath), "%s%s\\%s.%s", TheGlobalData->m_modDir.str(), VIDEO_PATH, pVideo->m_filename.str(), VIDEO_EXT ); File* file = TheFileSystem->openFile(filePath); DEBUG_ASSERTLOG(!file, ("opened bink file %s", filePath)); if (file) @@ -245,13 +245,13 @@ VideoStreamInterface* FFmpegVideoPlayer::open( AsciiString movieTitle ) } char localizedFilePath[ _MAX_PATH ]; - sprintf( localizedFilePath, VIDEO_LANG_PATH_FORMAT, GetRegistryLanguage().str(), pVideo->m_filename.str(), VIDEO_EXT ); + snprintf( localizedFilePath, ARRAY_SIZE(localizedFilePath), VIDEO_LANG_PATH_FORMAT, GetRegistryLanguage().str(), pVideo->m_filename.str(), VIDEO_EXT ); File* file = TheFileSystem->openFile(localizedFilePath); DEBUG_ASSERTLOG(!file, ("opened localized bink file %s", localizedFilePath)); if (!file) { char filePath[ _MAX_PATH ]; - sprintf( filePath, "%s\\%s.%s", VIDEO_PATH, pVideo->m_filename.str(), VIDEO_EXT ); + snprintf( filePath, ARRAY_SIZE(filePath), "%s\\%s.%s", VIDEO_PATH, pVideo->m_filename.str(), VIDEO_EXT ); file = TheFileSystem->openFile(filePath); DEBUG_ASSERTLOG(!file, ("opened bink file %s", filePath)); } diff --git a/Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp b/Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp index 21aea05038e..4535e76f05a 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp @@ -54,6 +54,7 @@ #include "W3DDevice/GameClient/W3DShroud.h" #include "WW3D2/texture.h" #include "WW3D2/dx8caps.h" +#include "WWMath/vector2i.h" @@ -132,7 +133,7 @@ void W3DRadar::initializeTextureFormats( void ) } //------------------------------------------------------------------------------------------------- -/** Delete resources used specifically in this W3D radar implemetation */ +/** Delete resources used specifically in this W3D radar implementation */ //------------------------------------------------------------------------------------------------- void W3DRadar::deleteResources( void ) { @@ -142,30 +143,33 @@ void W3DRadar::deleteResources( void ) // if( m_terrainTexture ) m_terrainTexture->Release_Ref(); - m_terrainTexture = NULL; + m_terrainTexture = nullptr; deleteInstance(m_terrainImage); - m_terrainImage = NULL; + m_terrainImage = nullptr; // // delete overlay resources used // if( m_overlayTexture ) m_overlayTexture->Release_Ref(); - m_overlayTexture = NULL; + m_overlayTexture = nullptr; deleteInstance(m_overlayImage); - m_overlayImage = NULL; + m_overlayImage = nullptr; // // delete shroud resources used // if( m_shroudTexture ) m_shroudTexture->Release_Ref(); - m_shroudTexture = NULL; + m_shroudTexture = nullptr; deleteInstance(m_shroudImage); - m_shroudImage = NULL; + m_shroudImage = nullptr; + + DEBUG_ASSERTCRASH(m_shroudSurface == nullptr, ("W3DRadar::deleteResources: m_shroudSurface is expected null")); + DEBUG_ASSERTCRASH(m_shroudSurfaceBits == nullptr, ("W3DRadar::deleteResources: m_shroudSurfaceBits is expected null")); } @@ -179,6 +183,9 @@ void W3DRadar::reconstructViewBox( void ) Int i; // get the 4 points of the view corners in the 3D world at the average Z height in the map + // 1-------2 + // \ / + // 4---3 TheTacticalView->getScreenCornerWorldPointsAtZ( &world[ 0 ], &world[ 1 ], &world[ 2 ], @@ -214,14 +221,6 @@ void W3DRadar::reconstructViewBox( void ) } - // - // save the camera settings for this view box, we will need to make it again only - // if some of these change - // - m_viewAngle = TheTacticalView->getAngle(); - Coord3D pos; - TheTacticalView->getPosition( &pos ); - m_viewZoom = TheTacticalView->getZoom(); m_reconstructViewBox = FALSE; } @@ -235,7 +234,7 @@ void W3DRadar::radarToPixel( const ICoord2D *radar, ICoord2D *pixel, { // sanity - if( radar == NULL || pixel == NULL ) + if( radar == nullptr || pixel == nullptr ) return; pixel->x = (radar->x * radarWidth / RADAR_CELL_WIDTH) + radarUpperLeftX; @@ -252,7 +251,7 @@ void W3DRadar::drawHeroIcon( Int pixelX, Int pixelY, Int width, Int height, cons { // get the hero icon image static const Image *image = (Image *)TheMappedImageCollection->findImageByName("HeroReticle"); - if (image != NULL) + if (image != nullptr) { // convert world to radar coords ICoord2D ulRadar; @@ -682,7 +681,7 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text { // sanity - if( listHead == NULL || texture == NULL ) + if( listHead == nullptr || texture == nullptr ) return; // get surface for texture to render into @@ -693,6 +692,12 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text Player *player = rts::getObservedOrLocalPlayer(); + SurfaceClass::SurfaceDescription surfaceDesc; + surface->Get_Description(surfaceDesc); + int pitch; + void *pBits = surface->Lock(&pitch); + const unsigned int bytesPerPixel = Get_Bytes_Per_Pixel(surfaceDesc.Format); + for( const RadarObject *rObj = listHead; rObj; rObj = rObj->friend_getNext() ) { if (!canRenderObject(rObj, player)) @@ -707,7 +712,7 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text radarPoint.y = pos->y / (m_mapExtent.height() / RADAR_CELL_HEIGHT); // get the color we're going to draw in - Color c = rObj->getColor(); + Color argbColor = 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 ) @@ -716,7 +721,7 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text if( obj->testStatus( OBJECT_STATUS_STEALTHED ) ) { UnsignedByte r, g, b, a; - GameGetColorComponents( c, &r, &g, &b, &a ); + GameGetColorComponents( argbColor, &r, &g, &b, &a ); const UnsignedInt framesForTransition = LOGICFRAMES_PER_SECOND; const UnsignedByte minAlpha = 32; @@ -726,27 +731,31 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text a = REAL_TO_UNSIGNEDBYTE( ((alphaScale - 1.0f) * (255.0f - minAlpha)) + minAlpha ); else a = REAL_TO_UNSIGNEDBYTE( (alphaScale * (255.0f - minAlpha)) + minAlpha ); - c = GameMakeColor( r, g, b, a ); + argbColor = GameMakeColor( r, g, b, a ); } + const unsigned int pixelColor = ARGB_Color_To_WW3D_Color(surfaceDesc.Format, argbColor); + // draw the blip, but make sure the points are legal if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) - surface->DrawPixel( radarPoint.x, radarPoint.y, c ); + surface->Draw_Pixel( radarPoint.x, radarPoint.y, pixelColor, bytesPerPixel, pBits, pitch ); radarPoint.y++; if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) - surface->DrawPixel( radarPoint.x, radarPoint.y, c ); + surface->Draw_Pixel( radarPoint.x, radarPoint.y, pixelColor, bytesPerPixel, pBits, pitch ); radarPoint.x++; if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) - surface->DrawPixel( radarPoint.x, radarPoint.y, c ); + surface->Draw_Pixel( radarPoint.x, radarPoint.y, pixelColor, bytesPerPixel, pBits, pitch ); radarPoint.y--; if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) - surface->DrawPixel( radarPoint.x, radarPoint.y, c ); + surface->Draw_Pixel( radarPoint.x, radarPoint.y, pixelColor, bytesPerPixel, pBits, pitch ); } + + surface->Unlock(); REF_PTR_RELEASE(surface); } @@ -834,23 +843,27 @@ W3DRadar::W3DRadar( void ) { m_terrainTextureFormat = WW3D_FORMAT_UNKNOWN; - m_terrainImage = NULL; - m_terrainTexture = NULL; + m_terrainImage = nullptr; + m_terrainTexture = nullptr; m_overlayTextureFormat = WW3D_FORMAT_UNKNOWN; - m_overlayImage = NULL; - m_overlayTexture = NULL; + m_overlayImage = nullptr; + m_overlayTexture = nullptr; m_shroudTextureFormat = WW3D_FORMAT_UNKNOWN; - m_shroudImage = NULL; - m_shroudTexture = NULL; + m_shroudImage = nullptr; + m_shroudTexture = nullptr; + m_shroudSurface = nullptr; + m_shroudSurfaceBits = nullptr; + m_shroudSurfacePitch = 0; + m_shroudSurfaceFormat = WW3D_FORMAT_UNKNOWN; + m_shroudSurfacePixelSize = 0; m_textureWidth = RADAR_CELL_WIDTH; m_textureHeight = RADAR_CELL_HEIGHT; m_reconstructViewBox = TRUE; - m_viewAngle = 0.0f; - m_viewZoom = 0.0f; + for( Int i = 0; i < 4; i++ ) { @@ -1025,7 +1038,7 @@ void W3DRadar::newMap( TerrainLogic *terrain ) Radar::newMap( terrain ); // sanity - if( terrain == NULL ) + if( terrain == nullptr ) return; // build terrain texture @@ -1060,6 +1073,13 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain ) ICoord2D radarPoint; Coord3D worldPoint; Bridge *bridge; + + SurfaceClass::SurfaceDescription surfaceDesc; + surface->Get_Description(surfaceDesc); + int pitch; + void *pBits = surface->Lock(&pitch); + const unsigned int bytesPerPixel = Get_Bytes_Per_Pixel(surfaceDesc.Format); + for( y = 0; y < m_textureHeight; y++ ) { @@ -1074,7 +1094,7 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain ) // check to see if this point is part of a working bridge Bool workingBridge = FALSE; bridge = TheTerrainLogic->findBridgeAt( &worldPoint ); - if( bridge != NULL ) + if( bridge != nullptr ) { Object *obj = TheGameLogic->findObjectByID( bridge->peekBridgeInfo()->bridgeObjectID ); @@ -1118,7 +1138,7 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain ) // get color for this Z and add to our sample color Real underwaterZ; - if( terrain->isUnderwater( worldPoint.x, worldPoint.y, NULL, &underwaterZ ) ) + if( terrain->isUnderwater( worldPoint.x, worldPoint.y, nullptr, &underwaterZ ) ) { // this is our "color" for water color = waterColor; @@ -1245,25 +1265,18 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain ) } - // // draw the pixel for the terrain at this point, note that because of the orientation // of our world we draw it with positive y in the "up" direction - // - // FYI: I tried making this faster by pulling out all the code inside DrawPixel - // and locking only once ... but it made absolutely *no* performance difference, - // the sampling and interpolation algorithm for generating pretty looking terrain - // and water for the radar is just, well, expensive. - // - surface->DrawPixel( x, y, GameMakeColor( color.red * 255, - color.green * 255, - color.blue * 255, - 255 ) ); + const Color argbColor = GameMakeColor( color.red * 255, color.green * 255, color.blue * 255, 255 ); + const unsigned int pixelColor = ARGB_Color_To_WW3D_Color(surfaceDesc.Format, argbColor); + surface->Draw_Pixel( x, y, pixelColor, bytesPerPixel, pBits, pitch ); } } // all done with the surface + surface->Unlock(); REF_PTR_RELEASE(surface); } @@ -1280,11 +1293,18 @@ void W3DRadar::clearShroud() SurfaceClass *surface = m_shroudTexture->Get_Surface_Level(); // fill to clear, shroud will make black. Don't want to make something black that logic can't clear - unsigned int color = GameMakeColor( 0, 0, 0, 0 ); + + int pitch; + void *pBits = surface->Lock(&pitch); + const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel(); + const Color color = GameMakeColor( 0, 0, 0, 0 ); + for( Int y = 0; y < m_textureHeight; y++ ) { - surface->DrawHLine(y, 0, m_textureWidth-1, color); + surface->Draw_H_Line(y, 0, m_textureWidth-1, color, bytesPerPixel, pBits, pitch); } + + surface->Unlock(); REF_PTR_RELEASE(surface); } @@ -1297,13 +1317,10 @@ void W3DRadar::setShroudLevel(Int shroudX, Int shroudY, CellShroudStatus setting return; #endif - W3DShroud* shroud = TheTerrainRenderObject ? TheTerrainRenderObject->getShroud() : NULL; + W3DShroud* shroud = TheTerrainRenderObject ? TheTerrainRenderObject->getShroud() : nullptr; if (!shroud) return; - SurfaceClass* surface = m_shroudTexture->Get_Surface_Level(); - DEBUG_ASSERTCRASH( surface, ("W3DRadar: Can't get surface for Shroud texture") ); - Int mapMinX = shroudX * shroud->getCellWidth(); Int mapMinY = shroudY * shroud->getCellHeight(); Int mapMaxX = (shroudX+1) * shroud->getCellWidth(); @@ -1315,21 +1332,19 @@ void W3DRadar::setShroudLevel(Int shroudX, Int shroudY, CellShroudStatus setting worldPoint.x = mapMinX; worldPoint.y = mapMinY; worldToRadar( &worldPoint, &radarPoint ); - Int radarMinX = radarPoint.x; - Int radarMinY = radarPoint.y; + const Int radarMinX = radarPoint.x; + const Int radarMinY = radarPoint.y; worldPoint.x = mapMaxX; worldPoint.y = mapMaxY; worldToRadar( &worldPoint, &radarPoint ); - Int radarMaxX = radarPoint.x; - Int radarMaxY = radarPoint.y; + const Int radarMaxX = radarPoint.x; + const Int radarMaxY = radarPoint.y; -/* - Int radarMinX = REAL_TO_INT_FLOOR(mapMinX / getXSample()); - Int radarMinY = REAL_TO_INT_FLOOR(mapMinY / getYSample()); - Int radarMaxX = REAL_TO_INT_CEIL(mapMaxX / getXSample()); - Int radarMaxY = REAL_TO_INT_CEIL(mapMaxY / getYSample()); -*/ + // Int radarMinX = REAL_TO_INT_FLOOR(mapMinX / getXSample()); + // Int radarMinY = REAL_TO_INT_FLOOR(mapMinY / getYSample()); + // Int radarMaxX = REAL_TO_INT_CEIL(mapMaxX / getXSample()); + // Int radarMaxY = REAL_TO_INT_CEIL(mapMaxY / getYSample()); /// @todo srj -- this really needs to smooth the display! @@ -1343,15 +1358,74 @@ void W3DRadar::setShroudLevel(Int shroudX, Int shroudY, CellShroudStatus setting else alpha = 0; - for( Int y = radarMinY; y <= radarMaxY; y++ ) + if (m_shroudSurface == nullptr) { - for( Int x = radarMinX; x <= radarMaxX; x++ ) + // This is expensive. + SurfaceClass* surface = m_shroudTexture->Get_Surface_Level(); + DEBUG_ASSERTCRASH( surface, ("W3DRadar: Can't get surface for Shroud texture") ); + SurfaceClass::SurfaceDescription surfaceDesc; + surface->Get_Description(surfaceDesc); + int pitch; + void *pBits = surface->Lock(&pitch); + const unsigned int bytesPerPixel = Get_Bytes_Per_Pixel(surfaceDesc.Format); + const Color argbColor = GameMakeColor( 0, 0, 0, alpha ); + const unsigned int pixelColor = ARGB_Color_To_WW3D_Color(surfaceDesc.Format, argbColor); + + for( Int y = radarMinY; y <= radarMaxY; ++y ) { - if( legalRadarPoint( x, y ) ) - surface->DrawPixel( x, y, GameMakeColor( 0, 0, 0, alpha ) ); + for( Int x = radarMinX; x <= radarMaxX; ++x ) + { + surface->Draw_Pixel( x, y, pixelColor, bytesPerPixel, pBits, pitch ); + } } + + surface->Unlock(); + REF_PTR_RELEASE(surface); } - REF_PTR_RELEASE(surface); + else + { + // This is cheap. + DEBUG_ASSERTCRASH(m_shroudSurfaceBits != nullptr, ("W3DRadar::setShroudLevel: m_shroudSurfaceBits is not expected null")); + DEBUG_ASSERTCRASH(m_shroudSurfaceFormat != WW3D_FORMAT_UNKNOWN, ("W3DRadar::setShroudLevel: m_shroudSurfaceFormat is not expected UNKNOWN")); + DEBUG_ASSERTCRASH(m_shroudSurfacePixelSize != 0, ("W3DRadar::setShroudLevel: m_shroudSurfacePixelSize is not expected 0")); + const Color argbColor = GameMakeColor( 0, 0, 0, alpha ); + const unsigned int pixelColor = ARGB_Color_To_WW3D_Color(m_shroudSurfaceFormat, argbColor); + + for( Int y = radarMinY; y <= radarMaxY; ++y ) + { + for( Int x = radarMinX; x <= radarMaxX; ++x ) + { + m_shroudSurface->Draw_Pixel( x, y, pixelColor, m_shroudSurfacePixelSize, m_shroudSurfaceBits, m_shroudSurfacePitch ); + } + } + } +} + +void W3DRadar::beginSetShroudLevel() +{ + DEBUG_ASSERTCRASH( m_shroudSurface == nullptr, ("W3DRadar::beginSetShroudLevel: m_shroudSurface is expected null") ); + m_shroudSurface = m_shroudTexture->Get_Surface_Level(); + DEBUG_ASSERTCRASH( m_shroudSurface != nullptr, ("W3DRadar::beginSetShroudLevel: Can't get surface for Shroud texture") ); + + SurfaceClass::SurfaceDescription surfaceDesc; + m_shroudSurface->Get_Description(surfaceDesc); + m_shroudSurfaceBits = m_shroudSurface->Lock(&m_shroudSurfacePitch); + m_shroudSurfaceFormat = surfaceDesc.Format; + m_shroudSurfacePixelSize = Get_Bytes_Per_Pixel(surfaceDesc.Format); +} + +void W3DRadar::endSetShroudLevel() +{ + DEBUG_ASSERTCRASH( m_shroudSurface != nullptr, ("W3DRadar::endSetShroudLevel: m_shroudSurface is not expected null") ); + if (m_shroudSurfaceBits != nullptr) + { + m_shroudSurface->Unlock(); + m_shroudSurfaceBits = nullptr; + m_shroudSurfacePitch = 0; + m_shroudSurfaceFormat = WW3D_FORMAT_UNKNOWN; + m_shroudSurfacePixelSize = 0; + } + REF_PTR_RELEASE(m_shroudSurface); } //------------------------------------------------------------------------------------------------- @@ -1433,14 +1507,10 @@ void W3DRadar::draw( Int pixelX, Int pixelY, Int width, Int height ) // draw any radar events drawEvents( ul.x, ul.y, scaledWidth, scaledHeight ); - // see if we need to reconstruct the view box - if( TheTacticalView->getZoom() != m_viewZoom ) - m_reconstructViewBox = TRUE; - if( TheTacticalView->getAngle() != m_viewAngle ) - m_reconstructViewBox = TRUE; - - if( m_reconstructViewBox == TRUE ) + if( m_reconstructViewBox ) + { reconstructViewBox(); + } // draw the view region on top of the radar reconstructing if necessary drawViewBox( ul.x, ul.y, scaledWidth, scaledHeight ); @@ -1466,13 +1536,19 @@ void W3DRadar::refreshObjects() { if constexpr (OVERLAY_REFRESH_RATE > 1) { - if (m_overlayTexture != NULL) + if (m_overlayTexture != nullptr) { updateObjectTexture(m_overlayTexture); } } } +// ------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------ +void W3DRadar::notifyViewChanged() +{ + m_reconstructViewBox = TRUE; +} ///The following is an "archive" of an attempt to foil the mapshroud hack... saved for later, since it is too close to release to try it @@ -1484,7 +1560,7 @@ void W3DRadar::refreshObjects() { // sanity - if( listHead == NULL || texture == NULL ) + if( listHead == nullptr || texture == nullptr ) return; // get surface for texture to render into @@ -1498,6 +1574,10 @@ void W3DRadar::refreshObjects() UnsignedByte minAlpha = 8; + int pitch; + void *pBits = surface->Lock(&pitch); + const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel(); + for( const RadarObject *rObj = listHead; rObj; rObj = rObj->friend_getNext() ) { UnsignedByte h = (UnsignedByte)(rObj->isTemporarilyHidden()); @@ -1582,24 +1662,26 @@ void W3DRadar::refreshObjects() // draw the blip, but make sure the points are legal if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) - surface->DrawPixel( radarPoint.x, radarPoint.y, c ); + surface->Draw_Pixel( radarPoint.x, radarPoint.y, c, bytesPerPixel, pBits, pitch ); radarPoint.x++; if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) - surface->DrawPixel( radarPoint.x, radarPoint.y, c ); + surface->Draw_Pixel( radarPoint.x, radarPoint.y, c, bytesPerPixel, pBits, pitch ); radarPoint.y++; if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) - surface->DrawPixel( radarPoint.x, radarPoint.y, c ); + surface->Draw_Pixel( radarPoint.x, radarPoint.y, c, bytesPerPixel, pBits, pitch ); radarPoint.x--; if( legalRadarPoint( radarPoint.x, radarPoint.y ) ) - surface->DrawPixel( radarPoint.x, radarPoint.y, c ); + surface->Draw_Pixel( radarPoint.x, radarPoint.y, c, bytesPerPixel, pBits, pitch ); } + + surface->Unlock(); REF_PTR_RELEASE(surface); } diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp index fd385940e3a..3027403ad7d 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/BaseHeightMap.cpp @@ -55,6 +55,7 @@ #include #include #include + #include "Common/GlobalData.h" #include "Common/PerfTimer.h" #include "Common/Xfer.h" @@ -112,7 +113,7 @@ static ShaderClass detailOpaqueShader(SC_DETAIL_BLEND); // Global Functions & Data //----------------------------------------------------------------------------- /// The one-of for the terrain rendering object. -BaseHeightMapRenderObjClass *TheTerrainRenderObject=NULL; +BaseHeightMapRenderObjClass *TheTerrainRenderObject=nullptr; /** Entry point so that trees can be drawn at the appropriate point in the rendering pipe for transparent objects. */ @@ -201,33 +202,33 @@ BaseHeightMapRenderObjClass::~BaseHeightMapRenderObjClass(void) freeMapResources(); delete m_treeBuffer; - m_treeBuffer = NULL; + m_treeBuffer = nullptr; delete m_propBuffer; - m_propBuffer = NULL; + m_propBuffer = nullptr; delete m_bibBuffer; - m_bibBuffer = NULL; + m_bibBuffer = nullptr; #ifdef DO_ROADS delete m_roadBuffer; - m_roadBuffer = NULL; + m_roadBuffer = nullptr; #endif delete m_bridgeBuffer; - m_bridgeBuffer = NULL; + m_bridgeBuffer = nullptr; delete m_waypointBuffer; - m_waypointBuffer = NULL; + m_waypointBuffer = nullptr; delete m_shroud; - m_shroud = NULL; + m_shroud = nullptr; delete [] m_shoreLineTilePositions; - m_shoreLineTilePositions = NULL; + m_shoreLineTilePositions = nullptr; delete [] m_shoreLineSortInfos; - m_shoreLineSortInfos = NULL; + m_shoreLineSortInfos = nullptr; } //============================================================================= @@ -246,9 +247,9 @@ BaseHeightMapRenderObjClass::BaseHeightMapRenderObjClass(void) //We should refine this with actual value. m_maxHeight=(pow(256.0, sizeof(HeightSampleType))-1.0)*MAP_HEIGHT_SCALE; m_minHeight=0; - m_shoreLineTilePositions=NULL; + m_shoreLineTilePositions=nullptr; m_numShoreLineTiles=0; - m_shoreLineSortInfos=NULL; + m_shoreLineSortInfos=nullptr; m_shoreLineSortInfosSize=0; m_shoreLineSortInfosXMajor=TRUE; m_shoreLineTileSortMaxCoordinate=0; @@ -257,13 +258,13 @@ BaseHeightMapRenderObjClass::BaseHeightMapRenderObjClass(void) m_shoreLineTilePositionsSize=0; m_currentMinWaterOpacity = -1.0f; - m_vertexMaterialClass=NULL; - m_stageZeroTexture=NULL; - m_stageOneTexture=NULL; - m_stageTwoTexture=NULL; - m_stageThreeTexture=NULL; - m_destAlphaTexture=NULL; - m_map=NULL; + m_vertexMaterialClass=nullptr; + m_stageZeroTexture=nullptr; + m_stageOneTexture=nullptr; + m_stageTwoTexture=nullptr; + m_stageThreeTexture=nullptr; + m_destAlphaTexture=nullptr; + m_map=nullptr; m_depthFade.X = 0.0f; m_depthFade.Y = 0.0f; m_depthFade.Z = 0.0f; @@ -271,20 +272,20 @@ BaseHeightMapRenderObjClass::BaseHeightMapRenderObjClass(void) m_disableTextures = false; TheTerrainRenderObject = this; - m_treeBuffer = NULL; - m_propBuffer = NULL; - m_bibBuffer = NULL; - m_bridgeBuffer = NULL; - m_waypointBuffer = NULL; + m_treeBuffer = nullptr; + m_propBuffer = nullptr; + m_bibBuffer = nullptr; + m_bridgeBuffer = nullptr; + m_waypointBuffer = nullptr; #ifdef DO_ROADS - m_roadBuffer = NULL; + m_roadBuffer = nullptr; #endif #ifdef DO_SCORCH - m_vertexScorch = NULL; - m_indexScorch = NULL; - m_scorchTexture = NULL; + m_vertexScorch = nullptr; + m_indexScorch = nullptr; + m_scorchTexture = nullptr; clearAllScorches(); - m_shroud = NULL; + m_shroud = nullptr; #endif m_bridgeBuffer = NEW W3DBridgeBuffer; @@ -334,24 +335,24 @@ void BaseHeightMapRenderObjClass::adjustTerrainLOD(Int adj) TheWritableGlobalData->m_terrainLOD=TERRAIN_LOD_MAX; } - if (m_map==NULL) return; + if (m_map==nullptr) return; if (m_shroud) m_shroud->reset(); //need reset here since initHeightData will load new shroud. - BaseHeightMapRenderObjClass *newROBJ = NULL; + BaseHeightMapRenderObjClass *newROBJ = nullptr; if (TheGlobalData->m_terrainLOD==7) { newROBJ = TheHeightMap; - if (newROBJ==NULL) { + if (newROBJ==nullptr) { newROBJ = NEW_REF( HeightMapRenderObjClass, () ); } } else { newROBJ = TheFlatHeightMap; - if (newROBJ==NULL) { + if (newROBJ==nullptr) { newROBJ = NEW_REF( FlatHeightMapRenderObjClass, () ); } } if (TheGlobalData->m_terrainLOD == 5) - newROBJ = NULL; + newROBJ = nullptr; RTS3DScene *pMyScene = (RTS3DScene *)Scene; if (pMyScene) { pMyScene->Remove_Render_Object(this); @@ -368,7 +369,7 @@ void BaseHeightMapRenderObjClass::adjustTerrainLOD(Int adj) newROBJ->initHeightData( m_map->getDrawWidth(), m_map->getDrawHeight(), m_map, - NULL); + nullptr); TheTerrainRenderObject = newROBJ; newROBJ->staticLightingChanged(); newROBJ->m_roadBuffer->loadRoads(); @@ -401,7 +402,7 @@ void BaseHeightMapRenderObjClass::ReleaseResources(void) m_waypointBuffer->freeWaypointBuffers(); } // We need to save the map. - WorldHeightMap *pMap=NULL; + WorldHeightMap *pMap=nullptr; REF_PTR_SET(pMap, m_map); freeMapResources(); m_map = pMap; // ref_ptr_set has already incremented the ref count. @@ -453,7 +454,7 @@ void BaseHeightMapRenderObjClass::ReAcquireResources(void) if (m_map) { - this->initHeightData(m_x,m_y,m_map, NULL); + this->initHeightData(m_x,m_y,m_map, nullptr); // Tell lights to update next time through. m_needFullUpdate = true; } @@ -769,9 +770,9 @@ relative to the ray so we can early exit as soon as we have a hit. /** Return intersection of a ray with the heightmap mesh. This is a quick version that just checks every polygon inside a 2D bounding rectangle of the ray projected onto the heightfield plane. -For most of our view-picking cases the ray in almost perpendicular to the +For most of our view-picking cases the ray is almost perpendicular to the map plane so this is very quick (small bounding box). But it can become slow -for arbitrary rays such as those used in AI visbility checks.(2 units on +for arbitrary rays such as those used in AI visibility checks(2 units on opposite corners of the map would check every polygon in the map). */ //============================================================================= @@ -793,7 +794,7 @@ bool BaseHeightMapRenderObjClass::Cast_Ray(RayCollisionTestClass & raytest) Int EndCellX = 0; Int StartCellY = 0; Int EndCellY = 0; - const Int overhang = 2*32+m_map->getBorderSizeInline(); // Allow picking past the edge for scrolling & objects. + const Int overhang = 2*VERTEX_BUFFER_TILE_LENGTH + m_map->getBorderSizeInline(); // Allow picking past the edge for scrolling & objects. Vector3 minPt(MAP_XY_FACTOR*(-overhang), MAP_XY_FACTOR*(-overhang), -MAP_XY_FACTOR); Vector3 maxPt(MAP_XY_FACTOR*(m_map->getXExtent()+overhang), MAP_XY_FACTOR*(m_map->getYExtent()+overhang), MAP_HEIGHT_SCALE*m_map->getMaxHeightValue()+MAP_XY_FACTOR); @@ -1097,7 +1098,7 @@ Real BaseHeightMapRenderObjClass::getHeightMapHeight(Real x, Real y, Coord3D* no //============================================================================= Bool BaseHeightMapRenderObjClass::isClearLineOfSight(const Coord3D& pos, const Coord3D& posOther) const { - if (m_map == NULL) + if (m_map == nullptr) return false; // doh. should not happen. WorldHeightMap *logicHeightMap = TheTerrainVisual?TheTerrainVisual->getLogicHeightMap():m_map; @@ -1256,7 +1257,7 @@ Bool BaseHeightMapRenderObjClass::isClearLineOfSight(const Coord3D& pos, const C Real fzinc = fdz * fnsInv; while (numSteps--) { - Real terrainHeight = getHeightMapHeight( fx, fy, NULL ); + Real terrainHeight = getHeightMapHeight( fx, fy, nullptr ); // if terrainHeight > fz, we can't see, so punt. // add a little fudge to account for slop. @@ -1300,7 +1301,7 @@ Real BaseHeightMapRenderObjClass::getMaxCellHeight(Real x, Real y) const // 0-----1 //Find surrounding grid points - if (m_map == NULL) + if (m_map == nullptr) { //sample point is not on the heightmap return 0.0f; //return default height } @@ -1343,7 +1344,7 @@ Real BaseHeightMapRenderObjClass::getMaxCellHeight(Real x, Real y) const Bool BaseHeightMapRenderObjClass::isCliffCell(Real x, Real y) { - if (m_map == NULL) + if (m_map == nullptr) { //sample point is not on the heightmap return false; } @@ -1369,7 +1370,7 @@ Bool BaseHeightMapRenderObjClass::isCliffCell(Real x, Real y) //============================================================================= Bool BaseHeightMapRenderObjClass::showAsVisibleCliff(Int xIndex, Int yIndex) const { - if (m_map == NULL) + if (m_map == nullptr) { return false; } @@ -1528,7 +1529,7 @@ Int BaseHeightMapRenderObjClass::Class_ID(void) const RenderObjClass * BaseHeightMapRenderObjClass::Clone(void) const { assert(false); - return NULL; + return nullptr; } //============================================================================= @@ -1880,7 +1881,7 @@ Int BaseHeightMapRenderObjClass::initHeightData(Int x, Int y, WorldHeightMap *pM if (m_roadBuffer) m_roadBuffer->setMap(m_map); #endif - HeightSampleType *data = NULL; + HeightSampleType *data = nullptr; if (pMap) { data = pMap->getDataPtr(); } @@ -1933,7 +1934,7 @@ Int BaseHeightMapRenderObjClass::initHeightData(Int x, Int y, WorldHeightMap *pM m_curNumScorchIndices=0; // If the textures aren't allocated (usually because of a hardware reset) need to allocate. Bool needToAllocate = false; - if (m_stageTwoTexture == NULL && m_treeBuffer) { + if (m_stageTwoTexture == nullptr && m_treeBuffer) { needToAllocate = true; } if (data && needToAllocate) @@ -2091,7 +2092,7 @@ void BaseHeightMapRenderObjClass::updateScorches(void) #if 0 UnsignedByte alpha[4]; float UA[4], VA[4]; - m_map->getAlphaUVData(xNdx, yNdx, UA, VA, alpha, &flipForBlend, false); + m_map->getAlphaUVData(xNdx, yNdx, UA, VA, alpha, &flipForBlend); #endif if (flipForBlend) { *curIb++ = startVertex + j*yOffset + i+1; @@ -2183,13 +2184,13 @@ Int BaseHeightMapRenderObjClass::getStaticDiffuse(Int x, Int y) if (y >= m_map->getYExtent()) y=m_map->getYExtent()-1; - if (m_map == NULL) { + if (m_map == nullptr) { return(0); } Vector3 l2r,n2f,normalAtTexel; Int vn0,un0,vp1,up1; - const Int cellOffset = 1; + constexpr const Int cellOffset = 1; vn0 = y-cellOffset; vp1 = y+cellOffset; @@ -2234,10 +2235,10 @@ Int BaseHeightMapRenderObjClass::getStaticDiffuse(Int x, Int y) doTheLight(&vertex, lightRay, &normalAtTexel, it, 1.0f); if (it) { pMyScene->destroyLightsIterator(it); - it = NULL; + it = nullptr; } } else { - doTheLight(&vertex, lightRay, &normalAtTexel, NULL, 1.0f); + doTheLight(&vertex, lightRay, &normalAtTexel, nullptr, 1.0f); } return vertex.diffuse; } @@ -2499,7 +2500,7 @@ is rendered. */ //============================================================================= void BaseHeightMapRenderObjClass::updateCenter(CameraClass *camera , RefRenderObjListIterator *pLightsIterator) { - if (m_map==NULL) { + if (m_map==nullptr) { return; } if (m_updating) { @@ -2578,7 +2579,7 @@ void BaseHeightMapRenderObjClass::renderShoreLines(CameraClass *pCamera) DX8Wrapper::Set_Material(vmat); REF_PTR_RELEASE(vmat); DX8Wrapper::Set_Texture(0,m_destAlphaTexture); - DX8Wrapper::Set_Transform(D3DTS_WORLD,Matrix3D(1)); + DX8Wrapper::Set_Transform(D3DTS_WORLD,Matrix3D(true)); //Enabled writes to destination alpha only DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_ALPHA); DX8Wrapper::Set_DX8_Texture_Stage_State(0, D3DTSS_TEXCOORDINDEX, 0); @@ -2762,7 +2763,7 @@ void BaseHeightMapRenderObjClass::renderShoreLinesSorted(CameraClass *pCamera) DX8Wrapper::Set_Material(vmat); REF_PTR_RELEASE(vmat); DX8Wrapper::Set_Texture(0,m_destAlphaTexture); - DX8Wrapper::Set_Transform(D3DTS_WORLD,Matrix3D(1)); + DX8Wrapper::Set_Transform(D3DTS_WORLD,Matrix3D(true)); //Enabled writes to destination alpha only DX8Wrapper::Set_DX8_Render_State(D3DRS_COLORWRITEENABLE,D3DCOLORWRITEENABLE_ALPHA); DX8Wrapper::Set_DX8_Texture_Stage_State(0, D3DTSS_TEXCOORDINDEX, 0); @@ -3060,11 +3061,10 @@ void BaseHeightMapRenderObjClass::renderTrees(CameraClass * camera) return; } #endif - if (m_map==NULL) return; - if (Scene==NULL) return; + if (m_map==nullptr) return; + if (Scene==nullptr) return; if (m_treeBuffer) { - Matrix3D tm(Transform); - DX8Wrapper::Set_Transform(D3DTS_WORLD,tm); + DX8Wrapper::Set_Transform(D3DTS_WORLD,Transform); DX8Wrapper::Set_Material(m_vertexMaterialClass); RTS3DScene *pMyScene = (RTS3DScene *)Scene; RefRenderObjListIterator pDynamicLightsIterator(pMyScene->getDynamicLights()); diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/CameraShakeSystem.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/CameraShakeSystem.cpp index 71d7124a479..140e83450f4 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/CameraShakeSystem.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/CameraShakeSystem.cpp @@ -135,7 +135,7 @@ CameraShakeSystemClass::CameraShakerClass::~CameraShakerClass(void) void CameraShakeSystemClass::CameraShakerClass::Compute_Rotations(const Vector3 & camera_position, Vector3 * set_angles) { - WWASSERT(set_angles != NULL); + WWASSERT(set_angles != nullptr); /* ** We want several different sinusiods, each with a different phase shift and diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp similarity index 90% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp index dc32633ad00..9396241c850 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDebrisDraw.cpp @@ -52,13 +52,13 @@ //------------------------------------------------------------------------------------------------- W3DDebrisDraw::W3DDebrisDraw(Thing *thing, const ModuleData* moduleData) : DrawModule(thing, moduleData) { - m_renderObject = NULL; + m_renderObject = nullptr; for (int i = 0; i < STATECOUNT; ++i) - m_anims[i] = NULL; - m_fxFinal = NULL; + m_anims[i] = nullptr; + m_fxFinal = nullptr; m_state = INITIAL; m_frames = 0; - m_shadow = NULL; + m_shadow = nullptr; m_finalStop = false; } @@ -69,19 +69,19 @@ W3DDebrisDraw::~W3DDebrisDraw(void) if (TheW3DShadowManager && m_shadow) { TheW3DShadowManager->removeShadow(m_shadow); - m_shadow = NULL; + m_shadow = nullptr; } if (m_renderObject) { - if (W3DDisplay::m_3DScene != NULL) + if (W3DDisplay::m_3DScene != nullptr) W3DDisplay::m_3DScene->Remove_Render_Object(m_renderObject); REF_PTR_RELEASE(m_renderObject); - m_renderObject = NULL; + m_renderObject = nullptr; } for (int i = 0; i < STATECOUNT; ++i) { REF_PTR_RELEASE(m_anims[i]); - m_anims[i] = NULL; + m_anims[i] = nullptr; } } @@ -103,7 +103,7 @@ void W3DDebrisDraw::setFullyObscuredByShroud(Bool fullyObscured) //------------------------------------------------------------------------------------------------- void W3DDebrisDraw::setModelName(AsciiString name, Color color, ShadowType t) { - if (m_renderObject == NULL && !name.isEmpty()) + if (m_renderObject == nullptr && !name.isEmpty()) { Int hexColor = 0; if (color != 0) @@ -112,7 +112,7 @@ void W3DDebrisDraw::setModelName(AsciiString name, Color color, ShadowType t) DEBUG_ASSERTCRASH(m_renderObject, ("Debris model %s not found!",name.str())); if (m_renderObject) { - if (W3DDisplay::m_3DScene != NULL) + if (W3DDisplay::m_3DScene != nullptr) W3DDisplay::m_3DScene->Add_Render_Object(m_renderObject); m_renderObject->Set_User_Data(getDrawable()->getDrawableInfo()); @@ -129,8 +129,6 @@ void W3DDebrisDraw::setModelName(AsciiString name, Color color, ShadowType t) { Shadow::ShadowTypeInfo shadowInfo; shadowInfo.m_type = t; - shadowInfo.m_sizeX=0; - shadowInfo.m_sizeY=0; m_shadow = TheW3DShadowManager->addShadow(m_renderObject, &shadowInfo); } else @@ -138,7 +136,7 @@ void W3DDebrisDraw::setModelName(AsciiString name, Color color, ShadowType t) if (TheW3DShadowManager && m_shadow) { TheW3DShadowManager->removeShadow(m_shadow); - m_shadow = NULL; + m_shadow = nullptr; } } @@ -156,11 +154,11 @@ void W3DDebrisDraw::setAnimNames(AsciiString initial, AsciiString flying, AsciiS for (i = 0; i < STATECOUNT; ++i) { REF_PTR_RELEASE(m_anims[i]); - m_anims[i] = NULL; + m_anims[i] = nullptr; } - m_anims[INITIAL] = initial.isEmpty() ? NULL : W3DDisplay::m_assetManager->Get_HAnim(initial.str()); - m_anims[FLYING] = flying.isEmpty() ? NULL : W3DDisplay::m_assetManager->Get_HAnim(flying.str()); + m_anims[INITIAL] = initial.isEmpty() ? nullptr : W3DDisplay::m_assetManager->Get_HAnim(initial.str()); + m_anims[FLYING] = flying.isEmpty() ? nullptr : W3DDisplay::m_assetManager->Get_HAnim(flying.str()); if (stricmp(final.str(), "STOP") == 0) { m_finalStop = true; @@ -170,7 +168,7 @@ void W3DDebrisDraw::setAnimNames(AsciiString initial, AsciiString flying, AsciiS { m_finalStop = false; } - m_anims[FINAL] = final.isEmpty() ? NULL : W3DDisplay::m_assetManager->Get_HAnim(final.str()); + m_anims[FINAL] = final.isEmpty() ? nullptr : W3DDisplay::m_assetManager->Get_HAnim(final.str()); m_state = 0; m_frames = 0; m_fxFinal = finalFX; @@ -237,7 +235,7 @@ void W3DDebrisDraw::doDrawModule(const Matrix3D* transformMtx) Int oldState = m_state; Object* obj = getDrawable()->getObject(); const Int MIN_FINAL_FRAMES = 3; - if (m_state != FINAL && obj != NULL && !obj->isAboveTerrain() && m_frames > MIN_FINAL_FRAMES) + if (m_state != FINAL && obj != nullptr && !obj->isAboveTerrain() && m_frames > MIN_FINAL_FRAMES) { m_state = FINAL; } @@ -246,12 +244,12 @@ void W3DDebrisDraw::doDrawModule(const Matrix3D* transformMtx) ++m_state; } HAnimClass* hanim = m_anims[m_state]; - if (hanim != NULL && (hanim != m_renderObject->Peek_Animation() || oldState != m_state)) + if (hanim != nullptr && (hanim != m_renderObject->Peek_Animation() || oldState != m_state)) { RenderObjClass::AnimMode m = TheAnimModes[m_state]; if (m_state == FINAL) { - FXList::doFXPos(m_fxFinal, getDrawable()->getPosition(), getDrawable()->getTransformMatrix(), 0, NULL, 0.0f); + FXList::doFXPos(m_fxFinal, getDrawable()->getPosition(), getDrawable()->getTransformMatrix(), 0, nullptr, 0.0f); if (m_finalStop) m = RenderObjClass::ANIM_MODE_MANUAL; } @@ -309,7 +307,7 @@ void W3DDebrisDraw::xfer( Xfer *xfer ) // when loading, set the animations if( xfer->getXferMode() == XFER_LOAD ) - setAnimNames( m_animInitial, m_animFlying, m_animFinal, NULL ); + setAnimNames( m_animInitial, m_animFlying, m_animFinal, nullptr ); // state xfer->xferInt( &m_state ); diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp similarity index 97% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp index 6c456effe61..993317edae7 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDefaultDraw.cpp @@ -54,18 +54,14 @@ W3DDefaultDraw::W3DDefaultDraw(Thing *thing, const ModuleData* moduleData) : DrawModule(thing, moduleData) { #ifdef LOAD_TEST_ASSETS - m_renderObject = NULL; - m_shadow = NULL; + m_renderObject = nullptr; + m_shadow = nullptr; if (!getDrawable()->getTemplate()->getLTAName().isEmpty()) { m_renderObject = W3DDisplay::m_assetManager->Create_Render_Obj(getDrawable()->getTemplate()->getLTAName().str(), getDrawable()->getScale(), 0); Shadow::ShadowTypeInfo shadowInfo; shadowInfo.m_type=(ShadowType)SHADOW_VOLUME; - shadowInfo.m_sizeX=0; //use defaults - shadowInfo.m_sizeY=0; - shadowInfo.m_offsetX=0; - shadowInfo.m_offsetY=0; DEBUG_LOG(("W3DDefaultDraw::W3DDefaultDraw - addShadow\n")); @@ -111,13 +107,13 @@ W3DDefaultDraw::~W3DDefaultDraw(void) if (TheW3DShadowManager && m_shadow) { TheW3DShadowManager->removeShadow(m_shadow); - m_shadow = NULL; + m_shadow = nullptr; } if (m_renderObject) { W3DDisplay::m_3DScene->Remove_Render_Object(m_renderObject); REF_PTR_RELEASE(m_renderObject); - m_renderObject = NULL; + m_renderObject = nullptr; } #endif } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyCarrierDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyCarrierDraw.cpp similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyCarrierDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyCarrierDraw.cpp diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp similarity index 97% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp index 5eb53a80542..c57af8b9d1f 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DDependencyModelDraw.cpp @@ -59,9 +59,9 @@ void W3DDependencyModelDrawModuleData::buildFieldParse(MultiIniFieldParse& p) static const FieldParse dataFieldParse[] = { - { "AttachToBoneInContainer", INI::parseAsciiString, NULL, offsetof(W3DDependencyModelDrawModuleData, m_attachToDrawableBoneInContainer) }, + { "AttachToBoneInContainer", INI::parseAsciiString, nullptr, offsetof(W3DDependencyModelDrawModuleData, m_attachToDrawableBoneInContainer) }, - { 0, 0, 0, 0 } + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); } @@ -98,7 +98,7 @@ void W3DDependencyModelDraw::doDrawModule(const Matrix3D* transformMtx) if ( ! me ) return; - Drawable *theirDrawable = NULL; + Drawable *theirDrawable = nullptr; if( me->getContainedBy() && !me->getContainedBy()->getContain()->isEnclosingContainerFor(me) ) theirDrawable = me->getContainedBy()->getDrawable(); diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp index 9efb0e4040d..62b3e8669ea 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DLaserDraw.cpp @@ -91,25 +91,25 @@ void W3DLaserDrawModuleData::buildFieldParse(MultiIniFieldParse& p) static const FieldParse dataFieldParse[] = { - { "NumBeams", INI::parseUnsignedInt, NULL, offsetof( W3DLaserDrawModuleData, m_numBeams ) }, - { "InnerBeamWidth", INI::parseReal, NULL, offsetof( W3DLaserDrawModuleData, m_innerBeamWidth ) }, - { "OuterBeamWidth", INI::parseReal, NULL, offsetof( W3DLaserDrawModuleData, m_outerBeamWidth ) }, - { "InnerColor", INI::parseColorInt, NULL, offsetof( W3DLaserDrawModuleData, m_innerColor ) }, - { "OuterColor", INI::parseColorInt, NULL, offsetof( W3DLaserDrawModuleData, m_outerColor ) }, - { "MaxIntensityLifetime", INI::parseDurationUnsignedInt, NULL, offsetof( W3DLaserDrawModuleData, m_maxIntensityFrames ) }, - { "FadeLifetime", INI::parseDurationUnsignedInt, NULL, offsetof( W3DLaserDrawModuleData, m_fadeFrames ) }, - { "Texture", INI::parseAsciiString, NULL, offsetof( W3DLaserDrawModuleData, m_textureName ) }, - { "ScrollRate", INI::parseReal, NULL, offsetof( W3DLaserDrawModuleData, m_scrollRate ) }, - { "Tile", INI::parseBool, NULL, offsetof( W3DLaserDrawModuleData, m_tile ) }, - { "Segments", INI::parseUnsignedInt, NULL, offsetof( W3DLaserDrawModuleData, m_segments ) }, - { "ArcHeight", INI::parseReal, NULL, offsetof( W3DLaserDrawModuleData, m_arcHeight ) }, - { "SegmentOverlapRatio", INI::parseReal, NULL, offsetof( W3DLaserDrawModuleData, m_segmentOverlapRatio ) }, - { "TilingScalar", INI::parseReal, NULL, offsetof( W3DLaserDrawModuleData, m_tilingScalar ) }, + { "NumBeams", INI::parseUnsignedInt, nullptr, offsetof( W3DLaserDrawModuleData, m_numBeams ) }, + { "InnerBeamWidth", INI::parseReal, nullptr, offsetof( W3DLaserDrawModuleData, m_innerBeamWidth ) }, + { "OuterBeamWidth", INI::parseReal, nullptr, offsetof( W3DLaserDrawModuleData, m_outerBeamWidth ) }, + { "InnerColor", INI::parseColorInt, nullptr, offsetof( W3DLaserDrawModuleData, m_innerColor ) }, + { "OuterColor", INI::parseColorInt, nullptr, offsetof( W3DLaserDrawModuleData, m_outerColor ) }, + { "MaxIntensityLifetime", INI::parseDurationUnsignedInt, nullptr, offsetof( W3DLaserDrawModuleData, m_maxIntensityFrames ) }, + { "FadeLifetime", INI::parseDurationUnsignedInt, nullptr, offsetof( W3DLaserDrawModuleData, m_fadeFrames ) }, + { "Texture", INI::parseAsciiString, nullptr, offsetof( W3DLaserDrawModuleData, m_textureName ) }, + { "ScrollRate", INI::parseReal, nullptr, offsetof( W3DLaserDrawModuleData, m_scrollRate ) }, + { "Tile", INI::parseBool, nullptr, offsetof( W3DLaserDrawModuleData, m_tile ) }, + { "Segments", INI::parseUnsignedInt, nullptr, offsetof( W3DLaserDrawModuleData, m_segments ) }, + { "ArcHeight", INI::parseReal, nullptr, offsetof( W3DLaserDrawModuleData, m_arcHeight ) }, + { "SegmentOverlapRatio", INI::parseReal, nullptr, offsetof( W3DLaserDrawModuleData, m_segmentOverlapRatio ) }, + { "TilingScalar", INI::parseReal, nullptr, offsetof( W3DLaserDrawModuleData, m_tilingScalar ) }, { "TextureGridTotalColumns", INI::parseUnsignedInt, NULL, offsetof(W3DLaserDrawModuleData, m_gridColumnsTotal) }, { "TextureGridColumns", INI::parseUnsignedInt, NULL, offsetof(W3DLaserDrawModuleData, m_gridColumns) }, { "UseHouseColorOuter", INI::parseBool, NULL, offsetof(W3DLaserDrawModuleData, m_useHouseColorOuter) }, { "UseHouseColorInner", INI::parseBool, NULL, offsetof(W3DLaserDrawModuleData, m_useHouseColorInner) }, - { 0, 0, 0, 0 } + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); } @@ -119,8 +119,8 @@ void W3DLaserDrawModuleData::buildFieldParse(MultiIniFieldParse& p) //------------------------------------------------------------------------------------------------- W3DLaserDraw::W3DLaserDraw( Thing *thing, const ModuleData* moduleData ) : DrawModule( thing, moduleData ), - m_line3D(NULL), - m_texture(NULL), + m_line3D(nullptr), + m_texture(nullptr), m_textureAspectRatio(1.0f), m_selfDirty(TRUE), m_hexColor(0) @@ -245,7 +245,7 @@ W3DLaserDraw::W3DLaserDraw( Thing *thing, const ModuleData* moduleData ) : } // add to scene - if (W3DDisplay::m_3DScene != NULL) + if (W3DDisplay::m_3DScene != nullptr) W3DDisplay::m_3DScene->Add_Render_Object( line ); //add it to our scene so it gets rendered with other objects. // hide the render object until the first time we come to draw it and @@ -270,7 +270,7 @@ W3DLaserDraw::~W3DLaserDraw( void ) { // remove line from scene - if (W3DDisplay::m_3DScene != NULL) + if (W3DDisplay::m_3DScene != nullptr) W3DDisplay::m_3DScene->Remove_Render_Object( m_line3D[ i ] ); // delete line diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp similarity index 91% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp index 2f2bd7f7674..893735fea30 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DModelDraw.cpp @@ -102,7 +102,7 @@ class LogClass LogClass::LogClass(const char *fname) { char buffer[ _MAX_PATH ]; - GetModuleFileName( NULL, buffer, sizeof( buffer ) ); + GetModuleFileName( nullptr, buffer, sizeof( buffer ) ); if (char *pEnd = strrchr(buffer, '\\')) { *pEnd = 0; @@ -242,7 +242,7 @@ static const char *const ACBitsNames[] = "MAINTAIN_FRAME_ACROSS_STATES3", "MAINTAIN_FRAME_ACROSS_STATES4", - NULL + nullptr }; static_assert(ARRAY_SIZE(ACBitsNames) == AC_BITS_COUNT + 1, "Incorrect array size"); @@ -299,7 +299,7 @@ const UnsignedInt NO_NEXT_DURATION = 0xffffffff; //------------------------------------------------------------------------------------------------- W3DAnimationInfo::W3DAnimationInfo(const AsciiString& name, Bool isIdle, Real distanceCovered) : #ifdef RETAIN_ANIM_HANDLES - m_handle(NULL), + m_handle(nullptr), m_naturalDurationInMsec(0), #else m_naturalDurationInMsec(-1), @@ -350,7 +350,7 @@ W3DAnimationInfo& W3DAnimationInfo::operator=(const W3DAnimationInfo &r) HAnimClass* W3DAnimationInfo::getAnimHandle() const { #ifdef RETAIN_ANIM_HANDLES - if (m_handle == NULL) + if (m_handle == nullptr) { // Get_HAnim addrefs it, so we'll have to release it in our dtor. m_handle = W3DDisplay::m_assetManager->Get_HAnim(m_name.str()); @@ -367,7 +367,7 @@ HAnimClass* W3DAnimationInfo::getAnimHandle() const #else HAnimClass* handle = W3DDisplay::m_assetManager->Get_HAnim(m_name.str()); DEBUG_ASSERTCRASH(handle, ("*** ASSET ERROR: animation %s not found",m_name.str())); - if (handle != NULL && m_naturalDurationInMsec < 0) + if (handle != nullptr && m_naturalDurationInMsec < 0) { m_naturalDurationInMsec = handle->Get_Num_Frames() * 1000.0f / handle->Get_Frame_Rate(); } @@ -383,7 +383,7 @@ W3DAnimationInfo::~W3DAnimationInfo() { #ifdef RETAIN_ANIM_HANDLES REF_PTR_RELEASE(m_handle); - m_handle = NULL; + m_handle = nullptr; #endif } @@ -397,8 +397,8 @@ void ModelConditionInfo::preloadAssets( TimeOfDay timeOfDay, Real scale ) } // this can be called from the client, which is problematic -// validateStuff(NULL, getDrawable()->getScale()); - //validateCachedBones(NULL, scale); +// validateStuff(nullptr, getDrawable()->getScale()); + //validateCachedBones(nullptr, scale); //validateTurretInfo(); //validateWeaponBarrelInfo(); } @@ -480,7 +480,7 @@ static Bool findSingleSubObj(RenderObjClass* robj, const AsciiString& boneName, #if defined(RTS_DEBUG) test->Release_Ref(); test = robj->Get_Sub_Object_On_Bone(0, boneIndex); - DEBUG_ASSERTCRASH(test != NULL && test == childObject, ("*** ASSET ERROR: Hmm, bone problem")); + DEBUG_ASSERTCRASH(test != nullptr && test == childObject, ("*** ASSET ERROR: Hmm, bone problem")); #endif } if (test) test->Release_Ref(); @@ -616,7 +616,7 @@ void ModelConditionInfo::validateCachedBones(RenderObjClass* robj, Real scale) c m_validStuff |= PRISTINE_BONES_VALID; Bool tossRobj = false; - if (robj == NULL) + if (robj == nullptr) { if (m_modelName.isEmpty()) { @@ -635,8 +635,8 @@ void ModelConditionInfo::validateCachedBones(RenderObjClass* robj, Real scale) c } Matrix3D originalTransform = robj->Get_Transform(); // save the transform - HLodClass* hlod = NULL; - HAnimClass* curAnim = NULL; + HLodClass* hlod = nullptr; + HAnimClass* curAnim = nullptr; int numFrames = 0; float frame = 0.0f; int mode = 0; @@ -661,14 +661,14 @@ void ModelConditionInfo::validateCachedBones(RenderObjClass* robj, Real scale) c if (animToUse) animToUse->Add_Ref(); } - if (animToUse != NULL) + if (animToUse != nullptr) { // make sure we're in frame zero. Int whichFrame = testFlagBit(m_flags, PRISTINE_BONE_POS_IN_FINAL_FRAME) ? animToUse->Get_Num_Frames()-1 : 0; robj->Set_Animation(animToUse, whichFrame, RenderObjClass::ANIM_MODE_MANUAL); // must balance the addref, above REF_PTR_RELEASE(animToUse); - animToUse = NULL; + animToUse = nullptr; } Matrix3D tmp(true); @@ -704,7 +704,7 @@ void ModelConditionInfo::validateCachedBones(RenderObjClass* robj, Real scale) c } robj->Set_Transform(originalTransform); // restore previous transform - if (curAnim != NULL) + if (curAnim != nullptr) { robj->Set_Animation(curAnim, frame, mode); hlod->Set_Animation_Frame_Rate_Multiplier(mult); @@ -767,12 +767,12 @@ void ModelConditionInfo::validateWeaponBarrelInfo() const if (!recoilBoneName.isEmpty()) { - sprintf(buffer, "%s%02d", recoilBoneName.str(), i); + snprintf(buffer, ARRAY_SIZE(buffer), "%s%02d", recoilBoneName.str(), i); findPristineBone(NAMEKEY(buffer), &info.m_recoilBone); } if (!mfName.isEmpty()) { - sprintf(buffer, "%s%02d", mfName.str(), i); + snprintf(buffer, ARRAY_SIZE(buffer), "%s%02d", mfName.str(), i); findPristineBone(NAMEKEY(buffer), &info.m_muzzleFlashBone); #if defined(RTS_DEBUG) || defined(DEBUG_CRASHING) if (info.m_muzzleFlashBone) @@ -781,7 +781,7 @@ void ModelConditionInfo::validateWeaponBarrelInfo() const } if (!fxBoneName.isEmpty()) { - sprintf(buffer, "%s%02d", fxBoneName.str(), i); + snprintf(buffer, ARRAY_SIZE(buffer), "%s%02d", fxBoneName.str(), i); findPristineBone(NAMEKEY(buffer), &info.m_fxBone); // special case: if we have multiple muzzleflashes, but only one fxbone, use that fxbone for everything. if (info.m_fxBone == 0 && info.m_muzzleFlashBone != 0) @@ -791,9 +791,9 @@ void ModelConditionInfo::validateWeaponBarrelInfo() const Int plbBoneIndex = 0; if (!plbName.isEmpty()) { - sprintf(buffer, "%s%02d", plbName.str(), i); + snprintf(buffer, ARRAY_SIZE(buffer), "%s%02d", plbName.str(), i); const Matrix3D* mtx = findPristineBone(NAMEKEY(buffer), &plbBoneIndex); - if (mtx != NULL) + if (mtx != nullptr) info.m_projectileOffsetMtx = *mtx; } @@ -827,8 +827,8 @@ void ModelConditionInfo::validateWeaponBarrelInfo() const info.m_muzzleFlashBoneName = mfName; #endif - const Matrix3D* plbMtx = plbName.isEmpty() ? NULL : findPristineBone(NAMEKEY(plbName), NULL); - if (plbMtx != NULL) + const Matrix3D* plbMtx = plbName.isEmpty() ? nullptr : findPristineBone(NAMEKEY(plbName), nullptr); + if (plbMtx != nullptr) info.m_projectileOffsetMtx = *plbMtx; else info.m_projectileOffsetMtx.Make_Identity(); @@ -836,7 +836,7 @@ void ModelConditionInfo::validateWeaponBarrelInfo() const if (!fxBoneName.isEmpty()) findPristineBone(NAMEKEY(fxBoneName), &info.m_fxBone); - if (info.m_fxBone != 0 || info.m_recoilBone != 0 || info.m_muzzleFlashBone != 0 || plbMtx != NULL) + if (info.m_fxBone != 0 || info.m_recoilBone != 0 || info.m_muzzleFlashBone != 0 || plbMtx != nullptr) { CRCDEBUG_LOG(("validateWeaponBarrelInfo() - model name %s (unadorned) wslot %d", m_modelName.str(), wslot)); DUMPMATRIX3D(&(info.m_projectileOffsetMtx)); @@ -880,7 +880,7 @@ void ModelConditionInfo::validateTurretInfo() const if (tur.m_turretAngleNameKey != NAMEKEY_INVALID) { - if (findPristineBone(tur.m_turretAngleNameKey, &tur.m_turretAngleBone) == NULL) + if (findPristineBone(tur.m_turretAngleNameKey, &tur.m_turretAngleBone) == nullptr) { //DEBUG_CRASH(("*** ASSET ERROR: TurretBone %s not found! (%s)",KEYNAME(tur.m_turretAngleNameKey).str(),m_modelName.str())); DEBUG_LOG(("*** ASSET ERROR: TurretBone %s not found! (%s)",KEYNAME(tur.m_turretAngleNameKey).str(),m_modelName.str())); @@ -894,7 +894,7 @@ void ModelConditionInfo::validateTurretInfo() const if (tur.m_turretPitchNameKey != NAMEKEY_INVALID) { - if (findPristineBone(tur.m_turretPitchNameKey, &tur.m_turretPitchBone) == NULL) + if (findPristineBone(tur.m_turretPitchNameKey, &tur.m_turretPitchBone) == nullptr) { //DEBUG_CRASH(("*** ASSET ERROR: TurretBone %s not found! (%s)",KEYNAME(tur.m_turretPitchNameKey).str(),m_modelName.str())); DEBUG_LOG(("*** ASSET ERROR: TurretBone %s not found! (%s)",KEYNAME(tur.m_turretPitchNameKey).str(),m_modelName.str())); @@ -923,7 +923,7 @@ const Matrix3D* ModelConditionInfo::findPristineBone(NameKeyType boneName, Int* // set it to zero, some callers rely on this if (boneIndex) *boneIndex = 0; - return NULL; + return nullptr; } if (boneName == NAMEKEY_INVALID) @@ -931,7 +931,7 @@ const Matrix3D* ModelConditionInfo::findPristineBone(NameKeyType boneName, Int* // set it to zero, some callers rely on this if (boneIndex) *boneIndex = 0; - return NULL; + return nullptr; } PristineBoneInfoMap::const_iterator it = m_pristineBones.find(boneName); @@ -946,14 +946,14 @@ const Matrix3D* ModelConditionInfo::findPristineBone(NameKeyType boneName, Int* // set it to zero -- some callers rely on this! if (boneIndex) *boneIndex = 0; - return NULL; + return nullptr; } } //------------------------------------------------------------------------------------------------- Bool ModelConditionInfo::findPristineBonePos(NameKeyType boneName, Coord3D& pos) const { - const Matrix3D* mtx = findPristineBone(boneName, NULL); + const Matrix3D* mtx = findPristineBone(boneName, nullptr); if (mtx) { Vector3 v = mtx->Get_Translation(); @@ -977,7 +977,7 @@ void ModelConditionInfo::loadAnimations() const { HAnimClass* h = it2->getAnimHandle(); // just force it to get loaded REF_PTR_RELEASE(h); - h = NULL; + h = nullptr; } #else // srj sez: I think there is no real reason to preload these all anymore. things that need the anims @@ -1087,7 +1087,7 @@ void W3DModelDrawModuleData::validateStuffForTimeAndWeather(const Drawable* draw if (!c_it->matchesMode(false, false) && !c_it->matchesMode(night, snowy)) continue; - c_it->validateStuff(NULL, draw->getScale(), m_extraPublicBones); + c_it->validateStuff(nullptr, draw->getScale(), m_extraPublicBones); } for (TransitionMap::iterator t_it = m_transitionMap.begin(); t_it != m_transitionMap.end(); ++t_it) @@ -1116,7 +1116,7 @@ void W3DModelDrawModuleData::validateStuffForTimeAndWeather(const Drawable* draw //it->addPublicBone(m_extraPublicBones); // srj sez: hm, this doesn't make sense; I think we really do need to validate transition states. - t_it->second.validateStuff(NULL, draw->getScale(), m_extraPublicBones); + t_it->second.validateStuff(nullptr, draw->getScale(), m_extraPublicBones); } } } @@ -1157,7 +1157,7 @@ const Vector3* W3DModelDrawModuleData::getAttachToDrawableBoneOffset(const Drawa { if (m_attachToDrawableBone.isEmpty()) { - return NULL; + return nullptr; } else { @@ -1165,7 +1165,7 @@ const Vector3* W3DModelDrawModuleData::getAttachToDrawableBoneOffset(const Drawa { // must use pristine bone here since the result is used by logic Matrix3D boneMtx; - if (draw->getPristineBonePositions(m_attachToDrawableBone.str(), 0, NULL, &boneMtx, 1) == 1) + if (draw->getPristineBonePositions(m_attachToDrawableBone.str(), 0, nullptr, &boneMtx, 1) == 1) { m_attachToDrawableBoneOffset = boneMtx.Get_Translation(); } @@ -1206,29 +1206,29 @@ void W3DModelDrawModuleData::buildFieldParse(MultiIniFieldParse& p) static const FieldParse dataFieldParse[] = { - { "InitialRecoilSpeed", INI::parseVelocityReal, NULL, offsetof(W3DModelDrawModuleData, m_initialRecoil) }, - { "MaxRecoilDistance", INI::parseReal, NULL, offsetof(W3DModelDrawModuleData, m_maxRecoil) }, - { "RecoilDamping", INI::parseReal, NULL, offsetof(W3DModelDrawModuleData, m_recoilDamping) }, - { "RecoilSettleSpeed", INI::parseVelocityReal, NULL, offsetof(W3DModelDrawModuleData, m_recoilSettle) }, - { "OkToChangeModelColor", INI::parseBool, NULL, offsetof(W3DModelDrawModuleData, m_okToChangeModelColor) }, - { "AnimationsRequirePower", INI::parseBool, NULL, offsetof(W3DModelDrawModuleData, m_animationsRequirePower) }, - { "ParticlesAttachedToAnimatedBones", INI::parseBool, NULL, offsetof(W3DModelDrawModuleData, m_particlesAttachedToAnimatedBones) }, - { "MinLODRequired", INI::parseStaticGameLODLevel, NULL, offsetof(W3DModelDrawModuleData, m_minLODRequired) }, + { "InitialRecoilSpeed", INI::parseVelocityReal, nullptr, offsetof(W3DModelDrawModuleData, m_initialRecoil) }, + { "MaxRecoilDistance", INI::parseReal, nullptr, offsetof(W3DModelDrawModuleData, m_maxRecoil) }, + { "RecoilDamping", INI::parseReal, nullptr, offsetof(W3DModelDrawModuleData, m_recoilDamping) }, + { "RecoilSettleSpeed", INI::parseVelocityReal, nullptr, offsetof(W3DModelDrawModuleData, m_recoilSettle) }, + { "OkToChangeModelColor", INI::parseBool, nullptr, offsetof(W3DModelDrawModuleData, m_okToChangeModelColor) }, + { "AnimationsRequirePower", INI::parseBool, nullptr, offsetof(W3DModelDrawModuleData, m_animationsRequirePower) }, + { "ParticlesAttachedToAnimatedBones", INI::parseBool, nullptr, offsetof(W3DModelDrawModuleData, m_particlesAttachedToAnimatedBones) }, + { "MinLODRequired", INI::parseStaticGameLODLevel, nullptr, offsetof(W3DModelDrawModuleData, m_minLODRequired) }, { "ProjectileBoneFeedbackEnabledSlots", INI::parseBitString32, TheWeaponSlotTypeNames, offsetof(W3DModelDrawModuleData, m_projectileBoneFeedbackEnabledSlots) }, { "DefaultConditionState", W3DModelDrawModuleData::parseConditionState, (void*)PARSE_DEFAULT, 0 }, { "ConditionState", W3DModelDrawModuleData::parseConditionState, (void*)PARSE_NORMAL, 0 }, { "AliasConditionState", W3DModelDrawModuleData::parseConditionState, (void*)PARSE_ALIAS, 0 }, { "TransitionState", W3DModelDrawModuleData::parseConditionState, (void*)PARSE_TRANSITION, 0 }, - { "TrackMarks", parseAsciiStringLC, NULL, offsetof(W3DModelDrawModuleData, m_trackFile) }, - { "ExtraPublicBone", INI::parseAsciiStringVectorAppend, NULL, offsetof(W3DModelDrawModuleData, m_extraPublicBones) }, - { "AttachToBoneInAnotherModule", parseAsciiStringLC, NULL, offsetof(W3DModelDrawModuleData, m_attachToDrawableBone) }, - { "IgnoreConditionStates", ModelConditionFlags::parseFromINI, NULL, offsetof(W3DModelDrawModuleData, m_ignoreConditionStates) }, - { "ReceivesDynamicLights", INI::parseBool, NULL, offsetof(W3DModelDrawModuleData, m_receivesDynamicLights) }, + { "TrackMarks", parseAsciiStringLC, nullptr, offsetof(W3DModelDrawModuleData, m_trackFile) }, + { "ExtraPublicBone", INI::parseAsciiStringVectorAppend, nullptr, offsetof(W3DModelDrawModuleData, m_extraPublicBones) }, + { "AttachToBoneInAnotherModule", parseAsciiStringLC, nullptr, offsetof(W3DModelDrawModuleData, m_attachToDrawableBone) }, + { "IgnoreConditionStates", ModelConditionFlags::parseFromINI, nullptr, offsetof(W3DModelDrawModuleData, m_ignoreConditionStates) }, + { "ReceivesDynamicLights", INI::parseBool, nullptr, offsetof(W3DModelDrawModuleData, m_receivesDynamicLights) }, { "IgnoreAnimationSpeedScaling", INI::parseBool, NULL, offsetof(W3DModelDrawModuleData, m_ignoreAnimScaling) }, { "IgnoreRotation", INI::parseBool, NULL, offsetof(W3DModelDrawModuleData, m_ignoreRotation) }, { "OnlyVisibleToOwningPlayer", INI::parseBool, NULL, offsetof(W3DModelDrawModuleData, m_showForOwnerOnly) }, //{ "DisableMovementEffectsOverWater", INI::parseBool, NULL, offsetof(W3DModelDrawModuleData, m_disableMoveEffectsOverWater) }, - { 0, 0, 0, 0 } + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); @@ -1299,7 +1299,7 @@ static void parseShowHideSubObject(INI* ini, void *instance, void *store, const { if (stricmp(it->subObjName.str(), subObjName.str()) == 0) { - it->hide = (userData != NULL); + it->hide = (userData != nullptr); found = true; } } @@ -1308,7 +1308,7 @@ static void parseShowHideSubObject(INI* ini, void *instance, void *store, const { ModelConditionInfo::HideShowSubObjInfo info; info.subObjName = subObjName; - info.hide = (userData != NULL); + info.hide = (userData != nullptr); vec->push_back(info); } subObjName = ini->getNextAsciiString(); @@ -1365,7 +1365,7 @@ static void parseParticleSysBone(INI* ini, void *instance, void * store, const v ParticleSysBoneInfo info; info.boneName = ini->getNextAsciiString(); info.boneName.toLower(); - ini->parseParticleSystemTemplate(ini, instance, &(info.particleSystemTemplate), NULL); + ini->parseParticleSystemTemplate(ini, instance, &(info.particleSystemTemplate), nullptr); ModelConditionInfo *self = (ModelConditionInfo *)instance; self->m_particleSysBones.push_back(info); } @@ -1429,63 +1429,63 @@ void W3DModelDrawModuleData::parseConditionState(INI* ini, void *instance, void { static const FieldParse myFieldParse[] = { - { "Model", parseAsciiStringLC, NULL, offsetof(ModelConditionInfo, m_modelName) }, - { "Turret", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[0].m_turretAngleNameKey) }, - { "TurretArtAngle", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[0].m_turretArtAngle) }, - { "TurretPitch", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[0].m_turretPitchNameKey) }, - { "TurretArtPitch", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[0].m_turretArtPitch) }, - { "AltTurret", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[1].m_turretAngleNameKey) }, - { "AltTurretArtAngle", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[1].m_turretArtAngle) }, - { "AltTurretPitch", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[1].m_turretPitchNameKey) }, - { "AltTurretArtPitch", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[1].m_turretArtPitch) }, - { "Turret1", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[0].m_turretAngleNameKey) }, - { "Turret1ArtAngle", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[0].m_turretArtAngle) }, - { "Turret1Pitch", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[0].m_turretPitchNameKey) }, - { "Turret1ArtPitch", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[0].m_turretArtPitch) }, - { "Turret2", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[1].m_turretAngleNameKey) }, - { "Turret2ArtAngle", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[1].m_turretArtAngle) }, - { "Turret2Pitch", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[1].m_turretPitchNameKey) }, - { "Turret2ArtPitch", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[1].m_turretArtPitch) }, - { "Turret3", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[2].m_turretAngleNameKey) }, - { "Turret3ArtAngle", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[2].m_turretArtAngle) }, - { "Turret3Pitch", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[2].m_turretPitchNameKey) }, - { "Turret3ArtPitch", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[2].m_turretArtPitch) }, - { "Turret4", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[3].m_turretAngleNameKey) }, - { "Turret4ArtAngle", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[3].m_turretArtAngle) }, - { "Turret4Pitch", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[3].m_turretPitchNameKey) }, - { "Turret4ArtPitch", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[3].m_turretArtPitch) }, - { "Turret5", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[4].m_turretAngleNameKey) }, - { "Turret5ArtAngle", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[4].m_turretArtAngle) }, - { "Turret5Pitch", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[4].m_turretPitchNameKey) }, - { "Turret5ArtPitch", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[4].m_turretArtPitch) }, - { "Turret6", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[5].m_turretAngleNameKey) }, - { "Turret6ArtAngle", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[5].m_turretArtAngle) }, - { "Turret6Pitch", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[5].m_turretPitchNameKey) }, - { "Turret6ArtPitch", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[5].m_turretArtPitch) }, - { "Turret7", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[6].m_turretAngleNameKey) }, - { "Turret7ArtAngle", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[6].m_turretArtAngle) }, - { "Turret7Pitch", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[6].m_turretPitchNameKey) }, - { "Turret7ArtPitch", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[6].m_turretArtPitch) }, - { "Turret8", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[7].m_turretAngleNameKey) }, - { "Turret8ArtAngle", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[7].m_turretArtAngle) }, - { "Turret8Pitch", parseBoneNameKey, NULL, offsetof(ModelConditionInfo, m_turrets[7].m_turretPitchNameKey) }, - { "Turret8ArtPitch", INI::parseAngleReal, NULL, offsetof(ModelConditionInfo, m_turrets[7].m_turretArtPitch) }, + { "Model", parseAsciiStringLC, nullptr, offsetof(ModelConditionInfo, m_modelName) }, + { "Turret", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[0].m_turretAngleNameKey) }, + { "TurretArtAngle", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[0].m_turretArtAngle) }, + { "TurretPitch", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[0].m_turretPitchNameKey) }, + { "TurretArtPitch", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[0].m_turretArtPitch) }, + { "AltTurret", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[1].m_turretAngleNameKey) }, + { "AltTurretArtAngle", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[1].m_turretArtAngle) }, + { "AltTurretPitch", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[1].m_turretPitchNameKey) }, + { "AltTurretArtPitch", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[1].m_turretArtPitch) }, + { "ShowSubObject", parseShowHideSubObject, (void*)nullptr, offsetof(ModelConditionInfo, m_hideShowVec) }, + { "Turret1ArtAngle", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[0].m_turretArtAngle) }, + { "Turret1Pitch", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[0].m_turretPitchNameKey) }, + { "Turret1ArtPitch", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[0].m_turretArtPitch) }, + { "Turret2", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[1].m_turretAngleNameKey) }, + { "Turret2ArtAngle", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[1].m_turretArtAngle) }, + { "Turret2Pitch", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[1].m_turretPitchNameKey) }, + { "Turret2ArtPitch", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[1].m_turretArtPitch) }, + { "Turret3", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[2].m_turretAngleNameKey) }, + { "Turret3ArtAngle", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[2].m_turretArtAngle) }, + { "Turret3Pitch", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[2].m_turretPitchNameKey) }, + { "Turret3ArtPitch", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[2].m_turretArtPitch) }, + { "Turret4", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[3].m_turretAngleNameKey) }, + { "Turret4ArtAngle", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[3].m_turretArtAngle) }, + { "Turret4Pitch", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[3].m_turretPitchNameKey) }, + { "Turret4ArtPitch", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[3].m_turretArtPitch) }, + { "Turret5", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[4].m_turretAngleNameKey) }, + { "Turret5ArtAngle", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[4].m_turretArtAngle) }, + { "Turret5Pitch", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[4].m_turretPitchNameKey) }, + { "Turret5ArtPitch", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[4].m_turretArtPitch) }, + { "Turret6", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[5].m_turretAngleNameKey) }, + { "Turret6ArtAngle", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[5].m_turretArtAngle) }, + { "Turret6Pitch", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[5].m_turretPitchNameKey) }, + { "Turret6ArtPitch", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[5].m_turretArtPitch) }, + { "Turret7", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[6].m_turretAngleNameKey) }, + { "Turret7ArtAngle", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[6].m_turretArtAngle) }, + { "Turret7Pitch", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[6].m_turretPitchNameKey) }, + { "Turret7ArtPitch", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[6].m_turretArtPitch) }, + { "Turret8", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[7].m_turretAngleNameKey) }, + { "Turret8ArtAngle", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[7].m_turretArtAngle) }, + { "Turret8Pitch", parseBoneNameKey, nullptr, offsetof(ModelConditionInfo, m_turrets[7].m_turretPitchNameKey) }, + { "Turret8ArtPitch", INI::parseAngleReal, nullptr, offsetof(ModelConditionInfo, m_turrets[7].m_turretArtPitch) }, { "ShowSubObject", parseShowHideSubObject, (void*)0, offsetof(ModelConditionInfo, m_hideShowVec) }, { "HideSubObject", parseShowHideSubObject, (void*)1, offsetof(ModelConditionInfo, m_hideShowVec) }, - { "WeaponFireFXBone", parseWeaponBoneName, NULL, offsetof(ModelConditionInfo, m_weaponFireFXBoneName[0]) }, - { "WeaponRecoilBone", parseWeaponBoneName, NULL, offsetof(ModelConditionInfo, m_weaponRecoilBoneName[0]) }, - { "WeaponMuzzleFlash", parseWeaponBoneName, NULL, offsetof(ModelConditionInfo, m_weaponMuzzleFlashName[0]) }, - { "WeaponLaunchBone", parseWeaponBoneName, NULL, offsetof(ModelConditionInfo, m_weaponProjectileLaunchBoneName[0]) }, - { "WeaponHideShowBone", parseWeaponBoneName, NULL, offsetof(ModelConditionInfo, m_weaponProjectileHideShowName[0]) }, + { "WeaponFireFXBone", parseWeaponBoneName, nullptr, offsetof(ModelConditionInfo, m_weaponFireFXBoneName[0]) }, + { "WeaponRecoilBone", parseWeaponBoneName, nullptr, offsetof(ModelConditionInfo, m_weaponRecoilBoneName[0]) }, + { "WeaponMuzzleFlash", parseWeaponBoneName, nullptr, offsetof(ModelConditionInfo, m_weaponMuzzleFlashName[0]) }, + { "WeaponLaunchBone", parseWeaponBoneName, nullptr, offsetof(ModelConditionInfo, m_weaponProjectileLaunchBoneName[0]) }, + { "WeaponHideShowBone", parseWeaponBoneName, nullptr, offsetof(ModelConditionInfo, m_weaponProjectileHideShowName[0]) }, { "Animation", parseAnimation, (void*)ANIM_NORMAL, offsetof(ModelConditionInfo, m_animations) }, { "IdleAnimation", parseAnimation, (void*)ANIM_IDLE, offsetof(ModelConditionInfo, m_animations) }, { "AnimationMode", INI::parseIndexList, TheAnimModeNames, offsetof(ModelConditionInfo, m_mode) }, - { "TransitionKey", parseLowercaseNameKey, NULL, offsetof(ModelConditionInfo, m_transitionKey) }, - { "WaitForStateToFinishIfPossible", parseLowercaseNameKey, NULL, offsetof(ModelConditionInfo, m_allowToFinishKey) }, + { "TransitionKey", parseLowercaseNameKey, nullptr, offsetof(ModelConditionInfo, m_transitionKey) }, + { "WaitForStateToFinishIfPossible", parseLowercaseNameKey, nullptr, offsetof(ModelConditionInfo, m_allowToFinishKey) }, { "Flags", INI::parseBitString32, ACBitsNames, offsetof(ModelConditionInfo, m_flags) }, - { "ParticleSysBone", parseParticleSysBone, NULL, 0 }, - { "AnimationSpeedFactorRange", parseRealRange, NULL, 0 }, - { 0, 0, 0, 0 } + { "ParticleSysBone", parseParticleSysBone, nullptr, 0 }, + { "AnimationSpeedFactorRange", parseRealRange, nullptr, 0 }, + { nullptr, nullptr, nullptr, 0 } }; ModelConditionInfo info; @@ -1586,7 +1586,7 @@ void W3DModelDrawModuleData::parseConditionState(INI* ini, void *instance, void prevState.m_description.concat("\nAKA: "); prevState.m_description.concat(description); #else - conditionsYes.parse(ini, NULL); + conditionsYes.parse(ini, nullptr); #endif if (conditionsYes.anyIntersectionWith(self->m_ignoreConditionStates)) @@ -1640,7 +1640,7 @@ void W3DModelDrawModuleData::parseConditionState(INI* ini, void *instance, void info.m_description.concat("\n "); info.m_description.concat(description); #else - conditionsYes.parse(ini, NULL); + conditionsYes.parse(ini, nullptr); #endif if (conditionsYes.anyIntersectionWith(self->m_ignoreConditionStates)) @@ -1769,16 +1769,16 @@ W3DModelDraw::W3DModelDraw(Thing *thing, const ModuleData* moduleData) : DrawMod m_animationMode = RenderObjClass::ANIM_MODE_LOOP; m_hideHeadlights = true; m_pauseAnimation = false; - m_curState = NULL; + m_curState = nullptr; m_hexColor = 0; - m_renderObject = NULL; - m_shadow = NULL; + m_renderObject = nullptr; + m_shadow = nullptr; m_shadowEnabled = TRUE; - m_terrainDecal = NULL; - m_trackRenderObject = NULL; + m_terrainDecal = nullptr; + m_trackRenderObject = nullptr; m_isFirstDrawModule = FALSE; m_whichAnimInCurState = -1; - m_nextState = NULL; + m_nextState = nullptr; m_nextStateAnimLoopDuration = NO_NEXT_DURATION; for (i = 0; i < WEAPONSLOT_COUNT; ++i) { @@ -1846,10 +1846,10 @@ W3DModelDraw::~W3DModelDraw(void) if (m_trackRenderObject && TheTerrainTracksRenderObjClassSystem) { TheTerrainTracksRenderObjClassSystem->unbindTrack(m_trackRenderObject); - m_trackRenderObject = NULL; + m_trackRenderObject = nullptr; } - nukeCurrentRender(NULL); + nukeCurrentRender(nullptr); } //------------------------------------------------------------------------------------------------- @@ -1861,8 +1861,8 @@ void W3DModelDraw::doStartOrStopParticleSys() //for (std::vector::const_iterator it = m_particleSystemIDs.begin(); it != m_particleSystemIDs.end(); ++it) { ParticleSystem *sys = TheParticleSystemManager->findParticleSystem((*it).id); - if (sys != NULL) { - // this can be NULL + if (sys != nullptr) { + // this can be null if (hidden) { sys->stop(); } else { @@ -1899,7 +1899,7 @@ void W3DModelDraw::releaseShadows(void) ///< frees all shadow resources used by { if (m_shadow) m_shadow->release(); - m_shadow = NULL; + m_shadow = nullptr; } /** Create shadow resources if not already present. This is used to dynamically enable/disable shadows by the options screen*/ @@ -1909,7 +1909,7 @@ void W3DModelDraw::allocateShadows(void) //Check if we don't already have a shadow but need one for this type of model. ShadowType type = tmplate->getShadowType(); - if (m_shadow == NULL && m_renderObject && TheW3DShadowManager && type != SHADOW_NONE + if (m_shadow == nullptr && m_renderObject && TheW3DShadowManager && type != SHADOW_NONE && (m_isFirstDrawModule || !(type == SHADOW_DECAL || type == SHADOW_ALPHA_DECAL || type == SHADOW_ADDITIVE_DECAL))) { Shadow::ShadowTypeInfo shadowInfo; @@ -1956,7 +1956,7 @@ void W3DModelDraw::getRenderCost(RenderCost & rc) const #if defined(RTS_DEBUG) void W3DModelDraw::getRenderCostRecursive(RenderCost & rc,RenderObjClass * robj) const { - if (robj == NULL) return; + if (robj == nullptr) return; // recurse through sub-objects for (int i=0; iGet_Num_Sub_Objects(); i++) { @@ -1973,7 +1973,7 @@ void W3DModelDraw::getRenderCostRecursive(RenderCost & rc,RenderObjClass * robj) if (robj->Class_ID() == RenderObjClass::CLASSID_MESH) { MeshClass * mesh = (MeshClass*)robj; MeshModelClass * model = mesh->Peek_Model(); - if (model != NULL) + if (model != nullptr) { if (model->Get_Flag(MeshGeometryClass::SORT)) rc.addSortedMeshes(1); if (model->Get_Flag(MeshGeometryClass::SKIN)) @@ -1985,7 +1985,7 @@ void W3DModelDraw::getRenderCostRecursive(RenderCost & rc,RenderObjClass * robj) // collect bone stats. const HTreeClass * htree = robj->Get_HTree(); - if (htree != NULL) { + if (htree != nullptr) { rc.addBones(htree->Num_Pivots()); } } @@ -2128,12 +2128,12 @@ void W3DModelDraw::doDrawModule(const Matrix3D* transformMtx) if (isAnimationComplete(m_renderObject)) { - if (m_curState != NULL && m_nextState != NULL) + if (m_curState != nullptr && m_nextState != nullptr) { //DEBUG_LOG(("transition %s is complete",m_curState->m_description.str())); const ModelConditionInfo* nextState = m_nextState; UnsignedInt nextDuration = m_nextStateAnimLoopDuration; - m_nextState = NULL; + m_nextState = nullptr; m_nextStateAnimLoopDuration = NO_NEXT_DURATION; setModelState(nextState); if (nextDuration != NO_NEXT_DURATION) @@ -2144,7 +2144,7 @@ void W3DModelDraw::doDrawModule(const Matrix3D* transformMtx) } if (m_renderObject && - m_curState != NULL && + m_curState != nullptr && m_whichAnimInCurState != -1) { if (m_curState->m_animations[m_whichAnimInCurState].isIdleAnim()) @@ -2193,15 +2193,15 @@ const ModelConditionInfo* W3DModelDraw::findTransitionForSig(TransitionSig sig) { return &(*it).second; } - return NULL; + return nullptr; } //------------------------------------------------------------------------------------------------- Real W3DModelDraw::getCurrentAnimFraction() const { - if (m_curState != NULL + if (m_curState != nullptr && isAnyMaintainFrameFlagSet(m_curState->m_flags) - && m_renderObject != NULL + && m_renderObject != nullptr && m_renderObject->Class_ID() == RenderObjClass::CLASSID_HLOD) { float framenum, dummy; @@ -2285,7 +2285,7 @@ void W3DModelDraw::adjustAnimation(const ModelConditionInfo* prevState, Real pre m_renderObject->Set_Animation(animHandle, startFrame, m_curState->m_mode); REF_PTR_RELEASE(animHandle); - animHandle = NULL; + animHandle = nullptr; if (m_renderObject->Class_ID() == RenderObjClass::CLASSID_HLOD) { @@ -2328,7 +2328,7 @@ Bool W3DModelDraw::setCurAnimDurationInMsec(Real desiredDurationInMsec) //------------------------------------------------------------------------------------------------- Real W3DModelDraw::getCurAnimDistanceCovered() const { - if (m_curState != NULL && m_whichAnimInCurState >= 0) + if (m_curState != nullptr && m_whichAnimInCurState >= 0) { const W3DAnimationInfo& animInfo = m_curState->m_animations[m_whichAnimInCurState]; #if defined(RTS_DEBUG) @@ -2424,7 +2424,7 @@ void W3DModelDraw::doHideShowSubObjs(const std::vectorGet_Sub_Object_By_Name(it->subObjName.str(), &objIndex)) != NULL) + if ((subObj = m_renderObject->Get_Sub_Object_By_Name(it->subObjName.str(), &objIndex)) != nullptr) { subObj->Set_Hidden(it->hide); @@ -2461,9 +2461,9 @@ void W3DModelDraw::stopClientParticleSystems() //for (std::vector::const_iterator it = m_particleSystemIDs.begin(); it != m_particleSystemIDs.end(); ++it) { ParticleSystem *sys = TheParticleSystemManager->findParticleSystem((*it).id); - if (sys != NULL) + if (sys != nullptr) { - // this can be NULL + // this can be null sys->destroy(); } } @@ -2665,15 +2665,15 @@ void W3DModelDraw::recalcBonesForClientParticleSystems() if (m_needRecalcBoneParticleSystems) { const Drawable* drawable = getDrawable(); - if (drawable != NULL ) + if (drawable != nullptr ) { - if( m_curState != NULL && drawable->testDrawableStatus( DRAWABLE_STATUS_NO_STATE_PARTICLES ) == FALSE ) + if( m_curState != nullptr && drawable->testDrawableStatus( DRAWABLE_STATUS_NO_STATE_PARTICLES ) == FALSE ) { for (std::vector::const_iterator it = m_curState->m_particleSysBones.begin(); it != m_curState->m_particleSysBones.end(); ++it) { ParticleSystem *sys = TheParticleSystemManager->createParticleSystem(it->particleSystemTemplate); - if (sys != NULL) + if (sys != nullptr) { Coord3D pos; pos.zero(); @@ -2705,7 +2705,7 @@ void W3DModelDraw::recalcBonesForClientParticleSystems() // and the direction, so that the system is oriented like the bone is sys->rotateLocalTransformZ(rotation); - // Attatch it to the object... + // Attach it to the object... sys->attachToDrawable(drawable); // important: mark it as do-not-save, since we'll just re-create it when we reload. @@ -2751,23 +2751,13 @@ void W3DModelDraw::recalcBonesForClientParticleSystems() Bool W3DModelDraw::updateBonesForClientParticleSystems() { const Drawable* drawable = getDrawable(); - if (drawable != NULL && m_curState != NULL && m_renderObject != NULL ) + if (drawable != nullptr && m_curState != nullptr && m_renderObject != nullptr ) { - -// Matrix3D originalTransform = m_renderObject->Get_Transform(); -// Matrix3D tmp = originalTransform; - // Vector3 zeroTranslation(0,0,0); - // tmp.Set_Translation( zeroTranslation ); - // tmp.Scale(drawable->getScale()); -// m_renderObject->Set_Transform(tmp); - - - for (std::vector::const_iterator it = m_particleSystemIDs.begin(); it != m_particleSystemIDs.end(); ++it) { ParticleSystem *sys = TheParticleSystemManager->findParticleSystem((*it).id); Int boneIndex = (*it).boneIndex; - if ( (sys != NULL) && (boneIndex != 0) ) + if ( (sys != nullptr) && (boneIndex != 0) ) { const Matrix3D boneTransform = m_renderObject->Get_Bone_Transform(boneIndex);// just a little worried about state changes @@ -2789,9 +2779,6 @@ Bool W3DModelDraw::updateBonesForClientParticleSystems() } } - -// m_renderObject->Set_Transform(originalTransform); - } return TRUE; @@ -2809,7 +2796,7 @@ void W3DModelDraw::setTerrainDecal(TerrainDecalType type) if (m_terrainDecal) m_terrainDecal->release(); - m_terrainDecal = NULL; + m_terrainDecal = nullptr; if (type == TERRAIN_DECAL_NONE || type >= TERRAIN_DECAL_MAX) //turning off decals on this object. (or bad value.) @@ -2868,11 +2855,11 @@ void W3DModelDraw::nukeCurrentRender(Matrix3D* xform) // changing geometry, so we need to remove shadow if present if (m_shadow) m_shadow->release(); - m_shadow = NULL; + m_shadow = nullptr; if(m_terrainDecal) m_terrainDecal->release(); - m_terrainDecal = NULL; + m_terrainDecal = nullptr; // remove existing render object from the scene if (m_renderObject) @@ -2880,10 +2867,10 @@ void W3DModelDraw::nukeCurrentRender(Matrix3D* xform) // save the transform for the new model if (xform) *xform = m_renderObject->Get_Transform(); - if (W3DDisplay::m_3DScene != NULL) + if (W3DDisplay::m_3DScene != nullptr) W3DDisplay::m_3DScene->Remove_Render_Object(m_renderObject); REF_PTR_RELEASE(m_renderObject); - m_renderObject = NULL; + m_renderObject = nullptr; } else { @@ -2904,7 +2891,7 @@ void W3DModelDraw::hideGarrisonFlags(Bool hide) Int objIndex; RenderObjClass* subObj; - if ((subObj = m_renderObject->Get_Sub_Object_By_Name("POLE", &objIndex)) != NULL) + if ((subObj = m_renderObject->Get_Sub_Object_By_Name("POLE", &objIndex)) != nullptr) { subObj->Set_Hidden(hide); @@ -2995,8 +2982,8 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState) DEBUG_LOG(("REQUEST switching to state %s for obj %s %d",newState->m_description.str(),getDrawable()->getObject()->getTemplate()->getName().str(),getDrawable()->getObject()->getID())); } #endif - const ModelConditionInfo* nextState = NULL; - if (m_curState != NULL && newState != NULL) + const ModelConditionInfo* nextState = nullptr; + if (m_curState != nullptr && newState != nullptr) { // if the requested state is the current state (and nothing is pending), // or if the requested state is pending, just punt. @@ -3017,8 +3004,8 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState) // -- curState is a real state, nextState is a real state without a wait-to-finish clause // -- should be impossible! - if ((m_curState == newState && m_nextState == NULL) || - (m_curState != NULL && m_nextState == newState)) + if ((m_curState == newState && m_nextState == nullptr) || + (m_curState != nullptr && m_nextState == newState)) { #ifdef DEBUG_OBJECT_ID_EXISTS if (getDrawable() && getDrawable()->getObject() && getDrawable()->getObject()->getID() == TheObjectIDToDebug) @@ -3054,7 +3041,7 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState) { TransitionSig sig = buildTransitionSig(m_curState->m_transitionKey, newState->m_transitionKey); const ModelConditionInfo* transState = findTransitionForSig(sig); - if (transState != NULL) + if (transState != nullptr) { #ifdef DEBUG_OBJECT_ID_EXISTS if (getDrawable() && getDrawable()->getObject() && getDrawable()->getObject()->getID() == TheObjectIDToDebug) @@ -3088,7 +3075,7 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState) // note that different states might use the same model; for these, don't go thru the // expense of creating a new render-object. (exception: if color is changing, or subobjs are changing, // or a few other things...) - if (m_curState == NULL || + if (m_curState == nullptr || newState->m_modelName != m_curState->m_modelName || turretNamesDiffer(newState, m_curState) // srj sez: I'm not sure why we want to do the "hard stuff" if we have projectile bones; I think @@ -3104,7 +3091,7 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState) // create a new render object and set into drawable if (newState->m_modelName.isEmpty()) { - m_renderObject = NULL; + m_renderObject = nullptr; } else { @@ -3132,7 +3119,7 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState) if (m_renderObject && TheGlobalData->m_makeTrackMarks && !m_trackRenderObject && - TheTerrainTracksRenderObjClassSystem != NULL && + TheTerrainTracksRenderObjClassSystem != nullptr && !getW3DModelDrawModuleData()->m_trackFile.isEmpty()) { m_trackRenderObject = TheTerrainTracksRenderObjClassSystem->bindTrack(m_renderObject, 1.0f*MAP_XY_FACTOR, getW3DModelDrawModuleData()->m_trackFile.str()); @@ -3158,8 +3145,8 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState) shadowInfo.m_hasDynamicLength = tmplate->hasDynamicShadowLength(); //DEBUG_LOG((">>> W3DModelDraw::allocateShadows, shadowInfo.m_hasDynamicLength = %d", shadowInfo.m_hasDynamicLength)); - DEBUG_ASSERTCRASH(m_shadow == NULL, ("m_shadow is not NULL")); - m_shadow = TheW3DShadowManager->addShadow(m_renderObject, &shadowInfo, draw); + DEBUG_ASSERTCRASH(m_shadow == nullptr, ("m_shadow is not null")); + m_shadow = TheW3DShadowManager->addShadow(m_renderObject, &shadowInfo, draw); if (m_shadow) { m_shadow->enableShadowInvisible(m_fullyObscuredByShroud); m_shadow->enableShadowRender(m_shadowEnabled); @@ -3214,7 +3201,7 @@ void W3DModelDraw::setModelState(const ModelConditionInfo* newState) } // add render object to our scene - if (W3DDisplay::m_3DScene != NULL) + if (W3DDisplay::m_3DScene != nullptr) W3DDisplay::m_3DScene->Add_Render_Object(m_renderObject); // tie in our drawable as the user data pointer in the render object @@ -3303,10 +3290,10 @@ void W3DModelDraw::replaceIndicatorColor(Color color) { m_hexColor = newColor; - // set these to NULL to force a regen of everything in setModelState. + // set these to nullptr to force a regen of everything in setModelState. const ModelConditionInfo* tmp = m_curState; - m_curState = NULL; - m_nextState = NULL; + m_curState = nullptr; + m_nextState = nullptr; m_nextStateAnimLoopDuration = NO_NEXT_DURATION; setModelState(tmp); } @@ -3378,7 +3365,7 @@ Bool W3DModelDraw::getProjectileLaunchOffset( //DUMPREAL(getDrawable()->getScale()); //BONEPOS_LOG(("validateStuffs() from within W3DModelDraw::getProjectileLaunchOffset()")); //BONEPOS_DUMPREAL(getDrawable()->getScale()); - stateToUse->validateStuff(NULL, getDrawable()->getScale(), d->m_extraPublicBones); + stateToUse->validateStuff(nullptr, getDrawable()->getScale(), d->m_extraPublicBones); DEBUG_ASSERTCRASH(stateToUse->m_transitionSig == NO_TRANSITION, ("It is never legal to getProjectileLaunchOffset from a Transition state (they vary on a per-client basis)... however, we can fix this (see srj)\n")); @@ -3392,7 +3379,7 @@ Bool W3DModelDraw::getProjectileLaunchOffset( // must use pristine bone here since the result is used by logic Matrix3D pivot; if (d->m_attachToDrawableBone.isNotEmpty() && - getDrawable()->getPristineBonePositions( d->m_attachToDrawableBone.str(), 0, NULL, &pivot, 1 ) == 1) + getDrawable()->getPristineBonePositions( d->m_attachToDrawableBone.str(), 0, nullptr, &pivot, 1 ) == 1) { pivot.Pre_Rotate_Z(getDrawable()->getOrientation()); techOffset.x = pivot.Get_X_Translation(); @@ -3408,7 +3395,7 @@ Bool W3DModelDraw::getProjectileLaunchOffset( // Can't find the launch pos, but they might still want the other info they asked for CRCDEBUG_LOG(("empty wbvec")); //BONEPOS_LOG(("empty wbvec")); - launchPos = NULL; + launchPos = nullptr; } else { @@ -3478,7 +3465,7 @@ Bool W3DModelDraw::getProjectileLaunchOffset( #endif } } - return launchPos != NULL;// return if LaunchPos is valid or not + return launchPos != nullptr;// return if LaunchPos is valid or not } //------------------------------------------------------------------------------------------------- @@ -3505,7 +3492,7 @@ Int W3DModelDraw::getPristineBonePositionsForConditionState( // { // CRCDEBUG_LOG(("W3DModelDraw::getPristineBonePositionsForConditionState() - state = '%s'", // stateToUse->getDescription().str())); -// //CRCDEBUG_LOG(("renderObject == NULL: %d", (stateToUse==m_curState)?(m_renderObject == NULL):1)); +// //CRCDEBUG_LOG(("renderObject == nullptr: %d", (stateToUse==m_curState)?(m_renderObject == nullptr):1)); // } //BONEPOS_LOG(("validateStuff() from within W3DModelDraw::getPristineBonePositionsForConditionState()")); @@ -3514,7 +3501,7 @@ Int W3DModelDraw::getPristineBonePositionsForConditionState( stateToUse->validateStuff( // if the state is the current state, pass in the current render object // so that we don't have to re-create it! - stateToUse == m_curState ? m_renderObject : NULL, + stateToUse == m_curState ? m_renderObject : nullptr, getDrawable()->getScale(), getW3DModelDrawModuleData()->m_extraPublicBones); @@ -3524,7 +3511,7 @@ Int W3DModelDraw::getPristineBonePositionsForConditionState( if (maxBones > MAX_BONE_GET) maxBones = MAX_BONE_GET; - if (transforms == NULL) + if (transforms == nullptr) transforms = tmpMtx; Int posCount = 0; @@ -3536,7 +3523,7 @@ Int W3DModelDraw::getPristineBonePositionsForConditionState( if (i == 0) strlcpy(buffer, boneNamePrefix, ARRAY_SIZE(buffer)); else - sprintf(buffer, "%s%02d", boneNamePrefix, i); + snprintf(buffer, ARRAY_SIZE(buffer), "%s%02d", boneNamePrefix, i); for (char *c = buffer; c && *c; ++c) { @@ -3544,7 +3531,7 @@ Int W3DModelDraw::getPristineBonePositionsForConditionState( *c = tolower(*c); } - const Matrix3D* mtx = stateToUse->findPristineBone(NAMEKEY(buffer), NULL); + const Matrix3D* mtx = stateToUse->findPristineBone(NAMEKEY(buffer), nullptr); if (mtx) { transforms[posCount] = *mtx; @@ -3663,7 +3650,7 @@ Int W3DModelDraw::getCurrentBonePositions( if (maxBones > MAX_BONE_GET) maxBones = MAX_BONE_GET; - if (transforms == NULL) + if (transforms == nullptr) transforms = tmpMtx; if( !m_renderObject ) @@ -3693,7 +3680,7 @@ Int W3DModelDraw::getCurrentBonePositions( if (i == 0) strlcpy(buffer, boneNamePrefix, ARRAY_SIZE(buffer)); else - sprintf(buffer, "%s%02d", boneNamePrefix, i); + snprintf(buffer, ARRAY_SIZE(buffer), "%s%02d", boneNamePrefix, i); Int boneIndex = m_renderObject->Get_Bone_Index(buffer); if (boneIndex == 0) @@ -3805,7 +3792,7 @@ Bool W3DModelDraw::handleWeaponFireFX(WeaponSlotType wslot, Int specificBarrelTo if (info.m_fxBone && m_renderObject) { const Object *logicObject = getDrawable()->getObject();// This is slow, so store it - if( ! m_renderObject->Is_Hidden() || (logicObject == NULL) ) + if( ! m_renderObject->Is_Hidden() || (logicObject == nullptr) ) { // I can ask the drawable's bone position if I am not hidden (if I have no object I have no choice) Matrix3D mtx = m_renderObject->Get_Bone_Transform(info.m_fxBone); @@ -3923,8 +3910,8 @@ void W3DModelDraw::setAnimationLoopDuration(UnsignedInt numFrames) { // this is never defined -- srj #ifdef NO_DURATIONS_ON_TRANSITIONS - if (m_curState != NULL && m_curState->m_transition != NO_TRANSITION && - m_nextState != NULL && m_nextState->m_transition == NO_TRANSITION) + if (m_curState != nullptr && m_curState->m_transition != NO_TRANSITION && + m_nextState != nullptr && m_nextState->m_transition == NO_TRANSITION) { DEBUG_LOG(("deferring pending duration of %d frames",numFrames)); m_nextStateAnimLoopDuration = numFrames; @@ -3932,7 +3919,7 @@ void W3DModelDraw::setAnimationLoopDuration(UnsignedInt numFrames) } m_nextStateAnimLoopDuration = NO_NEXT_DURATION; - DEBUG_ASSERTCRASH(m_curState != NULL && m_curState->m_transition == NO_TRANSITION, ("Hmm, setAnimationLoopDuration on a transition state is probably not right... see srj")); + DEBUG_ASSERTCRASH(m_curState != nullptr && m_curState->m_transition == NO_TRANSITION, ("Hmm, setAnimationLoopDuration on a transition state is probably not right... see srj")); #else m_nextStateAnimLoopDuration = NO_NEXT_DURATION; #endif @@ -3944,12 +3931,12 @@ void W3DModelDraw::setAnimationLoopDuration(UnsignedInt numFrames) /** similar to the above, but assumes that the current state is a "ONCE", and is smart about transition states... if there is a transition state - "inbetween", it is included in the completion time. + "in between", it is included in the completion time. */ void W3DModelDraw::setAnimationCompletionTime(UnsignedInt numFrames) { - if (m_curState != NULL && m_curState->m_transitionSig != NO_TRANSITION && !m_curState->m_animations.empty() && - m_nextState != NULL && m_nextState->m_transitionSig == NO_TRANSITION && !m_nextState->m_animations.empty()) + if (m_curState != nullptr && m_curState->m_transitionSig != NO_TRANSITION && m_curState->m_animations.size() > 0 && + m_nextState != nullptr && m_nextState->m_transitionSig == NO_TRANSITION && m_nextState->m_animations.size() > 0) { // we have a transition; split up the time suitably. // note that this is just a guess, and assumes that the states @@ -4025,7 +4012,7 @@ void W3DModelDraw::rebuildWeaponRecoilInfo(const ModelConditionInfo* state) { Int wslot; - if (state == NULL) + if (state == nullptr) { for (wslot = 0; wslot < WEAPONSLOT_COUNT; ++wslot) { @@ -4109,7 +4096,7 @@ void W3DModelDraw::doHideShowProjectileObjects( UnsignedInt showCount, UnsignedI for( UnsignedInt projectileIndex = 0; projectileIndex < maxCount; projectileIndex++ ) { oneEntry.subObjName.format("%s%02d", m_curState->m_weaponProjectileLaunchBoneName[slot].str(), (projectileIndex + 1)); - oneEntry.hide = ((projectileIndex + 1) <= hideCount); + oneEntry.hide = (projectileIndex < hideCount); showHideVector.push_back( oneEntry ); } } @@ -4137,7 +4124,7 @@ void W3DModelDraw::updateSubObjects() Int objIndex; RenderObjClass* subObj; - if ((subObj = m_renderObject->Get_Sub_Object_By_Name(it->subObjName.str(), &objIndex)) != NULL) + if ((subObj = m_renderObject->Get_Sub_Object_By_Name(it->subObjName.str(), &objIndex)) != nullptr) { subObj->Set_Hidden(it->hide); @@ -4272,7 +4259,7 @@ void W3DModelDraw::xfer( Xfer *xfer ) else { - // the vector must be emtpy + // the vector must be empty m_subObjectVec.clear(); // read each data item @@ -4387,7 +4374,7 @@ void W3DModelDraw::xfer( Xfer *xfer ) int curMode, dummy3; hlod->Peek_Animation_And_Info(dummy1, dummy3, curMode, dummy2); - // srj sez: do not change the animation mode. it's too risky, since if you change (say) a nonlooping + // srj sez: do not change the animation mode. it's too risky, since if you change (say) a non-looping // to a looping, something might break since it could rely on that anim terminating. // set animation data diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp similarity index 97% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp index e8b0f68b6bd..1a13c3189ca 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordAircraftDraw.cpp @@ -26,7 +26,7 @@ // // FILE: W3DOverlordAircraftDraw.h // Author: Mark Lorenzen, April 2003 -// Desc: Units that recieve portable structure upgrades (like the OverlordTnk) have a super specific special need. +// Desc: Units that receive portable structure upgrades (like the OverlordTnk) have a super specific special need. // He needs his rider to draw explicitly after him, // and he needs direct access to get that rider when everyone else can't see it because of the OverlordContain. // In the case of aircraft (Helix, SpectreGunship, etc.) we need this draw module which mimics the OverlordTnkDraw @@ -35,6 +35,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// + #include "Common/Xfer.h" #include "GameClient/Drawable.h" #include "GameLogic/Object.h" @@ -61,8 +62,8 @@ void W3DOverlordAircraftDrawModuleData::buildFieldParse(MultiIniFieldParse& p) static const FieldParse dataFieldParse[] = { - {"HasMultiAddOns", INI::parseBool, NULL, offsetof(W3DOverlordAircraftDrawModuleData, m_hasMultiAddOns)}, - { 0, 0, 0, 0 } + {"HasMultiAddOns", INI::parseBool, nullptr, offsetof(W3DOverlordAircraftDrawModuleData, m_hasMultiAddOns)}, + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp similarity index 96% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp index 89ac11a12a4..2f8baa873b6 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTankDraw.cpp @@ -22,13 +22,14 @@ // // //////////////////////////////////////////////////////////////////////////////// -// FIEL: W3DOverlordTankDraw.cpp //////////////////////////////////////////////////////////////////////////// +// FILE: W3DOverlordTankDraw.cpp //////////////////////////////////////////////////////////////////////////// // Author: Graham Smallwood, October 2002 // Desc: The Overlord has a super specific special need. He needs his rider to draw explicitly after him, // and he needs direct access to get that rider when everyone else can't see it because of the OverlordContain. /////////////////////////////////////////////////////////////////////////////////////////////////// // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// + #include "Common/Xfer.h" #include "GameClient/Drawable.h" #include "GameLogic/Object.h" @@ -52,8 +53,8 @@ void W3DOverlordTankDrawModuleData::buildFieldParse(MultiIniFieldParse& p) static const FieldParse dataFieldParse[] = { - {"HasMultiAddOns", INI::parseBool, NULL, offsetof(W3DOverlordTankDrawModuleData, m_hasMultiAddOns)}, - { 0, 0, 0, 0 } + {"HasMultiAddOns", INI::parseBool, nullptr, offsetof(W3DOverlordTankDrawModuleData, m_hasMultiAddOns)}, + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp similarity index 96% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp index bb01f1f2e02..62c53111ac8 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DOverlordTruckDraw.cpp @@ -22,13 +22,14 @@ // // //////////////////////////////////////////////////////////////////////////////// -// FIEL: W3DOverlordTruckDraw.cpp //////////////////////////////////////////////////////////////////////////// +// FILE: W3DOverlordTruckDraw.cpp //////////////////////////////////////////////////////////////////////////// // Author: Graham Smallwood, October 2002 // Desc: The Overlord has a super specific special need. He needs his rider to draw explicitly after him, // and he needs direct access to get that rider when everyone else can't see it because of the OverlordContain. /////////////////////////////////////////////////////////////////////////////////////////////////// // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// + #include "Common/Xfer.h" #include "GameClient/Drawable.h" #include "GameLogic/Object.h" @@ -52,8 +53,8 @@ void W3DOverlordTruckDrawModuleData::buildFieldParse(MultiIniFieldParse& p) static const FieldParse dataFieldParse[] = { - {"HasMultiAddOns", INI::parseBool, NULL, offsetof(W3DOverlordTruckDrawModuleData, m_hasMultiAddOns)}, - { 0, 0, 0, 0 } + {"HasMultiAddOns", INI::parseBool, nullptr, offsetof(W3DOverlordTruckDrawModuleData, m_hasMultiAddOns)}, + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cpp similarity index 97% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cpp index 5dd2dcf89e8..c80cb4aa7d4 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPoliceCarDraw.cpp @@ -29,6 +29,7 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include + #include "Common/STLTypedefs.h" #include "Common/Thing.h" #include "Common/Xfer.h" @@ -46,7 +47,7 @@ //------------------------------------------------------------------------------------------------- W3DDynamicLight *W3DPoliceCarDraw::createDynamicLight( void ) { - W3DDynamicLight *light = NULL; + W3DDynamicLight *light = nullptr; // get me a dynamic light from the scene light = W3DDisplay::m_3DScene->getADynamicLight(); @@ -74,7 +75,7 @@ W3DDynamicLight *W3DPoliceCarDraw::createDynamicLight( void ) //------------------------------------------------------------------------------------------------- W3DPoliceCarDraw::W3DPoliceCarDraw( Thing *thing, const ModuleData* moduleData ) : W3DTruckDraw( thing, moduleData ) { - m_light = NULL; + m_light = nullptr; m_curFrame = GameClientRandomValueReal(0, 10 ); } @@ -91,7 +92,7 @@ W3DPoliceCarDraw::~W3DPoliceCarDraw( void ) m_light->setFrameFade(0, 5); m_light->setDecayRange(); m_light->setDecayColor(); - m_light = NULL; + m_light = nullptr; } } @@ -105,7 +106,7 @@ void W3DPoliceCarDraw::doDrawModule(const Matrix3D* transformMtx) // get pointers to our render objects that we'll need RenderObjClass* policeCarRenderObj = getRenderObject(); - if( policeCarRenderObj == NULL ) + if( policeCarRenderObj == nullptr ) return; HAnimClass *anim = policeCarRenderObj->Peek_Animation(); @@ -139,7 +140,7 @@ void W3DPoliceCarDraw::doDrawModule(const Matrix3D* transformMtx) } // make us a light if we don't already have one - if( m_light == NULL ) + if( m_light == nullptr ) m_light = createDynamicLight(); diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DProjectileStreamDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DProjectileStreamDraw.cpp similarity index 93% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DProjectileStreamDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DProjectileStreamDraw.cpp index 6aa69be1c09..67394ae6e81 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DProjectileStreamDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DProjectileStreamDraw.cpp @@ -59,12 +59,12 @@ void W3DProjectileStreamDrawModuleData::buildFieldParse(MultiIniFieldParse& p) static const FieldParse dataFieldParse[] = { - { "Texture", INI::parseAsciiString, NULL, offsetof(W3DProjectileStreamDrawModuleData, m_textureName) }, - { "Width", INI::parseReal, NULL, offsetof(W3DProjectileStreamDrawModuleData, m_width) }, - { "TileFactor", INI::parseReal, NULL, offsetof(W3DProjectileStreamDrawModuleData, m_tileFactor) }, - { "ScrollRate", INI::parseReal, NULL, offsetof(W3DProjectileStreamDrawModuleData, m_scrollRate) }, - { "MaxSegments", INI::parseInt, NULL, offsetof(W3DProjectileStreamDrawModuleData, m_maxSegments) }, - { 0, 0, 0, 0 } + { "Texture", INI::parseAsciiString, nullptr, offsetof(W3DProjectileStreamDrawModuleData, m_textureName) }, + { "Width", INI::parseReal, nullptr, offsetof(W3DProjectileStreamDrawModuleData, m_width) }, + { "TileFactor", INI::parseReal, nullptr, offsetof(W3DProjectileStreamDrawModuleData, m_tileFactor) }, + { "ScrollRate", INI::parseReal, nullptr, offsetof(W3DProjectileStreamDrawModuleData, m_scrollRate) }, + { "MaxSegments", INI::parseInt, nullptr, offsetof(W3DProjectileStreamDrawModuleData, m_maxSegments) }, + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); } @@ -93,7 +93,7 @@ W3DProjectileStreamDraw::W3DProjectileStreamDraw( Thing *thing, const ModuleData const W3DProjectileStreamDrawModuleData* d = getW3DProjectileStreamDrawModuleData(); m_texture = WW3DAssetManager::Get_Instance()->Get_Texture( d->m_textureName.str() ); for( Int index = 0; index < MAX_PROJECTILE_STREAM; index++ ) - m_allLines[index] = NULL; + m_allLines[index] = nullptr; m_linesValid = 0; } @@ -126,7 +126,7 @@ void W3DProjectileStreamDraw::doDrawModule(const Matrix3D* ) { // get object from logic Object *me = getDrawable()->getObject(); - if (me == NULL) + if (me == nullptr) return; static NameKeyType key_ProjectileStreamUpdate = NAMEKEY("ProjectileStreamUpdate"); @@ -186,7 +186,7 @@ void W3DProjectileStreamDraw::doDrawModule(const Matrix3D* ) W3DDisplay::m_3DScene->Remove_Render_Object( deadLine ); REF_PTR_RELEASE( deadLine ); - m_allLines[lineIndex] = NULL; + m_allLines[lineIndex] = nullptr; m_linesValid--; } } @@ -195,7 +195,7 @@ void W3DProjectileStreamDraw::makeOrUpdateLine( Vector3 *points, UnsignedInt poi { Bool newLine = FALSE; - if( m_allLines[lineIndex] == NULL ) + if( m_allLines[lineIndex] == nullptr ) { //Need a new one if this is blank, otherwise I'll reset the existing one m_allLines[lineIndex] = NEW SegmentedLineClass; diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPropDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPropDraw.cpp index 1347418903d..d26b5e9b1fa 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPropDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DPropDraw.cpp @@ -55,9 +55,9 @@ void W3DPropDrawModuleData::buildFieldParse(MultiIniFieldParse& p) ModuleData::buildFieldParse(p); static const FieldParse dataFieldParse[] = { - { "ModelName", INI::parseAsciiString, NULL, offsetof(W3DPropDrawModuleData, m_modelName) }, + { "ModelName", INI::parseAsciiString, nullptr, offsetof(W3DPropDrawModuleData, m_modelName) }, - { 0, 0, 0, 0 } + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DRopeDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DRopeDraw.cpp similarity index 100% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DRopeDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DRopeDraw.cpp diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DScienceModelDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DScienceModelDraw.cpp similarity index 96% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DScienceModelDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DScienceModelDraw.cpp index d94d3ced65f..61afe059376 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DScienceModelDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DScienceModelDraw.cpp @@ -53,9 +53,9 @@ void W3DScienceModelDrawModuleData::buildFieldParse(MultiIniFieldParse& p) static const FieldParse dataFieldParse[] = { - { "RequiredScience", INI::parseScience, NULL, offsetof(W3DScienceModelDrawModuleData, m_requiredScience) }, + { "RequiredScience", INI::parseScience, nullptr, offsetof(W3DScienceModelDrawModuleData, m_requiredScience) }, - { 0, 0, 0, 0 } + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DSupplyDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DSupplyDraw.cpp similarity index 93% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DSupplyDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DSupplyDraw.cpp index bde8a4caddc..6fb67ea879d 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DSupplyDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DSupplyDraw.cpp @@ -48,9 +48,9 @@ void W3DSupplyDrawModuleData::buildFieldParse(MultiIniFieldParse& p) static const FieldParse dataFieldParse[] = { - { "SupplyBonePrefix", INI::parseAsciiString, NULL, offsetof(W3DSupplyDrawModuleData, m_supplyBonePrefix) }, + { "SupplyBonePrefix", INI::parseAsciiString, nullptr, offsetof(W3DSupplyDrawModuleData, m_supplyBonePrefix) }, - { 0, 0, 0, 0 } + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); } @@ -75,7 +75,7 @@ void W3DSupplyDraw::updateDrawModuleSupplyStatus( Int maxSupply, Int currentSupp AsciiString boneName = getW3DSupplyDrawModuleData()->m_supplyBonePrefix; if( m_totalBones == -1 ) { - m_totalBones = getDrawable()->getPristineBonePositions( boneName.str(), 1, NULL, NULL, INT_MAX );// The last arg is to guard the size of the arrays. I am not passing any in, I am just counting bones. + m_totalBones = getDrawable()->getPristineBonePositions( boneName.str(), 1, nullptr, nullptr, INT_MAX );// The last arg is to guard the size of the arrays. I am not passing any in, I am just counting bones. m_lastNumberShown = m_totalBones; } @@ -96,7 +96,7 @@ void W3DSupplyDraw::updateDrawModuleSupplyStatus( Int maxSupply, Int currentSupp while( currentIndex <= highIndex ) { char buffer[16]; - sprintf( buffer, "%s%02d", boneName.str(), currentIndex ); + snprintf( buffer, ARRAY_SIZE(buffer), "%s%02d", boneName.str(), currentIndex ); ModelConditionInfo::HideShowSubObjInfo info; info.hide = hide; info.subObjName = buffer; diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp similarity index 76% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp index cadf714315a..a5d2202c8ec 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankDraw.cpp @@ -30,6 +30,7 @@ // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include #include + #include "Common/Thing.h" #include "Common/ThingFactory.h" #include "Common/GameAudio.h" @@ -50,14 +51,20 @@ class Matrix3D; +// TheSuperHackers @info Is enabled by default and therefore compatible with the Retail INI setups. +#define SHOW_DEFAULT_TANK_DEBRIS (1) + //------------------------------------------------------------------------------------------------- -W3DTankDrawModuleData::W3DTankDrawModuleData() : - m_treadDebrisNameLeft("TrackDebrisDirtLeft"), - m_treadDebrisNameRight("TrackDebrisDirtRight"), - m_treadAnimationRate(0.0f), - m_treadPivotSpeedFraction(0.6f), - m_treadDriveSpeedFraction(0.3f) +W3DTankDrawModuleData::W3DTankDrawModuleData() + : m_treadAnimationRate(0.0f) + , m_treadPivotSpeedFraction(0.6f) + , m_treadDriveSpeedFraction(0.3f) { + if constexpr (SHOW_DEFAULT_TANK_DEBRIS) + { + m_treadDebrisNameLeft = "TrackDebrisDirtLeft"; // TheSuperHackers @todo Remove data particle names from code + m_treadDebrisNameRight = "TrackDebrisDirtRight"; + } } //------------------------------------------------------------------------------------------------- @@ -72,12 +79,12 @@ void W3DTankDrawModuleData::buildFieldParse(MultiIniFieldParse& p) static const FieldParse dataFieldParse[] = { - { "TreadDebrisLeft", INI::parseAsciiString, NULL, offsetof(W3DTankDrawModuleData, m_treadDebrisNameLeft) }, - { "TreadDebrisRight", INI::parseAsciiString, NULL, offsetof(W3DTankDrawModuleData, m_treadDebrisNameRight) }, - { "TreadAnimationRate", INI::parseVelocityReal, NULL, offsetof(W3DTankDrawModuleData, m_treadAnimationRate) }, - { "TreadPivotSpeedFraction", INI::parseReal, NULL, offsetof(W3DTankDrawModuleData, m_treadPivotSpeedFraction) }, - { "TreadDriveSpeedFraction", INI::parseReal, NULL, offsetof(W3DTankDrawModuleData, m_treadDriveSpeedFraction) }, - { 0, 0, 0, 0 } + { "TreadDebrisLeft", INI::parseAsciiString, nullptr, offsetof(W3DTankDrawModuleData, m_treadDebrisNameLeft) }, + { "TreadDebrisRight", INI::parseAsciiString, nullptr, offsetof(W3DTankDrawModuleData, m_treadDebrisNameRight) }, + { "TreadAnimationRate", INI::parseVelocityReal, nullptr, offsetof(W3DTankDrawModuleData, m_treadAnimationRate) }, + { "TreadPivotSpeedFraction", INI::parseReal, nullptr, offsetof(W3DTankDrawModuleData, m_treadPivotSpeedFraction) }, + { "TreadDriveSpeedFraction", INI::parseReal, nullptr, offsetof(W3DTankDrawModuleData, m_treadDriveSpeedFraction) }, + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); } @@ -85,13 +92,13 @@ void W3DTankDrawModuleData::buildFieldParse(MultiIniFieldParse& p) //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- W3DTankDraw::W3DTankDraw( Thing *thing, const ModuleData* moduleData ) -: W3DModelDraw( thing, moduleData ),m_prevRenderObj(NULL), m_treadDebrisLeft(NULL), m_treadDebrisRight(NULL) +: W3DModelDraw( thing, moduleData ) +, m_prevRenderObj(nullptr) { - m_treadDebrisLeft = NULL; - m_treadDebrisRight = NULL; + std::fill(m_treadDebrisIDs, m_treadDebrisIDs + ARRAY_SIZE(m_treadDebrisIDs), INVALID_PARTICLE_SYSTEM_ID); for (Int i=0; iattachToObject(NULL); - m_treadDebrisLeft->destroy(); - m_treadDebrisLeft = NULL; - } - if (m_treadDebrisRight) - { - m_treadDebrisRight->attachToObject(NULL); - m_treadDebrisRight->destroy(); - m_treadDebrisRight = NULL; + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_treadDebrisIDs[i])) + { + particleSys->attachToObject(nullptr); + particleSys->destroy(); + } + m_treadDebrisIDs[i] = INVALID_PARTICLE_SYSTEM_ID; } } //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- -void W3DTankDraw::createEmitters( void ) +void W3DTankDraw::createTreadEmitters( void ) { - if (!m_treadDebrisLeft) - { - const ParticleSystemTemplate *sysTemplate; - sysTemplate = TheParticleSystemManager->findTemplate(getW3DTankDrawModuleData()->m_treadDebrisNameLeft); - if (sysTemplate) - { - m_treadDebrisLeft = TheParticleSystemManager->createParticleSystem( sysTemplate ); - m_treadDebrisLeft->attachToDrawable(getDrawable()); - // important: mark it as do-not-save, since we'll just re-create it when we reload. - m_treadDebrisLeft->setSaveable(FALSE); - // they come into being stopped. - m_treadDebrisLeft->stop(); - } - } - if (!m_treadDebrisRight) + const AsciiString *treadDebrisNames[2]; + static_assert(ARRAY_SIZE(treadDebrisNames) == ARRAY_SIZE(m_treadDebrisIDs), "Array size must match"); + treadDebrisNames[0] = &getW3DTankDrawModuleData()->m_treadDebrisNameLeft; + treadDebrisNames[1] = &getW3DTankDrawModuleData()->m_treadDebrisNameRight; + + for (size_t i = 0; i < ARRAY_SIZE(m_treadDebrisIDs); ++i) { - const ParticleSystemTemplate *sysTemplate; - sysTemplate = TheParticleSystemManager->findTemplate(getW3DTankDrawModuleData()->m_treadDebrisNameRight); - if (sysTemplate) + if (m_treadDebrisIDs[i] == INVALID_PARTICLE_SYSTEM_ID) { - m_treadDebrisRight = TheParticleSystemManager->createParticleSystem( sysTemplate ); - m_treadDebrisRight->attachToDrawable(getDrawable()); - // important: mark it as do-not-save, since we'll just re-create it when we reload. - m_treadDebrisRight->setSaveable(FALSE); - // they come into being stopped. - m_treadDebrisRight->stop(); + if (const ParticleSystemTemplate *sysTemplate = TheParticleSystemManager->findTemplate(*treadDebrisNames[i])) + { + ParticleSystem *particleSys = TheParticleSystemManager->createParticleSystem( sysTemplate ); + particleSys->attachToDrawable(getDrawable()); + // important: mark it as do-not-save, since we'll just re-create it when we reload. + particleSys->setSaveable(FALSE); + // they come into being stopped. + particleSys->stop(); + m_treadDebrisIDs[i] = particleSys->getSystemID(); + } } } } @@ -159,7 +156,7 @@ void W3DTankDraw::createEmitters( void ) W3DTankDraw::~W3DTankDraw() { // TheSuperHackers @fix Mauller 16/04/2025 Delete particle systems - tossEmitters(); + tossTreadEmitters(); for (Int i=0; iisDrawableEffectivelyHidden()) - return; - if (m_treadDebrisLeft) - m_treadDebrisLeft->start(); - if (m_treadDebrisRight) - m_treadDebrisRight->start(); -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -/** - * Stop creating debris from the tank treads - */ void W3DTankDraw::stopMoveDebris( void ) { - if (m_treadDebrisLeft) - m_treadDebrisLeft->stop(); - if (m_treadDebrisRight) - m_treadDebrisRight->stop(); + for (size_t i = 0; i < ARRAY_SIZE(m_treadDebrisIDs); ++i) + { + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_treadDebrisIDs[i])) + { + particleSys->stop(); + } + } } //------------------------------------------------------------------------------------------------- @@ -261,7 +242,7 @@ void W3DTankDraw::updateTreadObjects(void) const char *meshName; //Check if subobject name starts with "TREADS". if (subObj && subObj->Class_ID() == RenderObjClass::CLASSID_MESH && subObj->Get_Name() - && ( (meshName=strchr(subObj->Get_Name(),'.') ) != 0 && *(meshName++)) + && ( (meshName=strchr(subObj->Get_Name(),'.') ) != nullptr && *(meshName++)) &&_strnicmp(meshName,"TREADS", 6) == 0) { //check if sub-object has the correct material to do texture scrolling. MaterialInfoClass *mat=subObj->Get_Material_Info(); @@ -319,19 +300,19 @@ void W3DTankDraw::doDrawModule(const Matrix3D* transformMtx) const Real DEBRIS_THRESHOLD = 0.00001f; - if (getRenderObject()==NULL) return; + if (getRenderObject()==nullptr) return; if (getRenderObject() != m_prevRenderObj) { updateTreadObjects(); } // get object from logic Object *obj = getDrawable()->getObject(); - if (obj == NULL) + if (obj == nullptr) return; // get object physics state PhysicsBehavior *physics = obj->getPhysics(); - if (physics == NULL) + if (physics == nullptr) return; const Coord3D *vel = physics->getVelocity(); @@ -339,10 +320,7 @@ void W3DTankDraw::doDrawModule(const Matrix3D* transformMtx) // if tank is moving, kick up dust and debris Real velMag = vel->x*vel->x + vel->y*vel->y; // only care about moving on the ground - if (velMag > DEBRIS_THRESHOLD && !getDrawable()->isDrawableEffectivelyHidden() && !getFullyObscuredByShroud()) - startMoveDebris(); - else - stopMoveDebris(); + const Bool doStartMoveDebris = velMag > DEBRIS_THRESHOLD && !getDrawable()->isDrawableEffectivelyHidden() && !getFullyObscuredByShroud(); // kick debris higher the faster we move Coord3D velMult; @@ -358,11 +336,19 @@ void W3DTankDraw::doDrawModule(const Matrix3D* transformMtx) if (velMult.z > 1.0f) velMult.z = 1.0f; - m_treadDebrisLeft->setVelocityMultiplier( &velMult ); - m_treadDebrisRight->setVelocityMultiplier( &velMult ); + for (size_t i = 0; i < ARRAY_SIZE(m_treadDebrisIDs); ++i) + { + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_treadDebrisIDs[i])) + { + if (doStartMoveDebris) + particleSys->start(); + else + particleSys->stop(); - m_treadDebrisLeft->setBurstCountMultiplier( velMult.z ); - m_treadDebrisRight->setBurstCountMultiplier( velMult.z ); + particleSys->setVelocityMultiplier( &velMult ); + particleSys->setBurstCountMultiplier( velMult.z ); + } + } //Update movement of treads if (m_treadCount && !(obj->isKindOf(KINDOF_NO_MOVE_EFFECTS_ON_WATER) && obj->isOverWater())) @@ -449,8 +435,8 @@ void W3DTankDraw::loadPostProcess( void ) // extend base class W3DModelDraw::loadPostProcess(); - // toss any existing ones and re-create 'em (since this module expects 'em to always be around) - tossEmitters(); - createEmitters(); + // toss any existing tread emitters and re-create 'em (since this module expects 'em to always be around) + tossTreadEmitters(); + createTreadEmitters(); } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp similarity index 71% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp index d2eca14b9d9..0571d312198 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTankTruckDraw.cpp @@ -47,15 +47,20 @@ #include "W3DDevice/GameClient/Module/W3DTankTruckDraw.h" #include "WW3D2/matinfo.h" -//#define SHOW_TANK_DEBRIS +// TheSuperHackers @info Is disabled by default and therefore compatible with the Retail INI setups. +#define SHOW_DEFAULT_TANK_DEBRIS (0) + //------------------------------------------------------------------------------------------------- -W3DTankTruckDrawModuleData::W3DTankTruckDrawModuleData(): - m_treadDebrisNameLeft("TrackDebrisDirtLeft"), - m_treadDebrisNameRight("TrackDebrisDirtRight"), - m_treadAnimationRate(0.0f), - m_treadPivotSpeedFraction(0.6f), - m_treadDriveSpeedFraction(0.3f) +W3DTankTruckDrawModuleData::W3DTankTruckDrawModuleData() + : m_treadAnimationRate(0.0f) + , m_treadPivotSpeedFraction(0.6f) + , m_treadDriveSpeedFraction(0.3f) { + if constexpr (SHOW_DEFAULT_TANK_DEBRIS) + { + m_treadDebrisNameLeft = "TrackDebrisDirtLeft"; // TheSuperHackers @todo Remove data particle names from code + m_treadDebrisNameRight = "TrackDebrisDirtRight"; + } } //------------------------------------------------------------------------------------------------- @@ -70,25 +75,25 @@ void W3DTankTruckDrawModuleData::buildFieldParse(MultiIniFieldParse& p) static const FieldParse dataFieldParse[] = { - { "Dust", INI::parseAsciiString, NULL, offsetof(W3DTankTruckDrawModuleData, m_dustEffectName) }, - { "DirtSpray", INI::parseAsciiString, NULL, offsetof(W3DTankTruckDrawModuleData, m_dirtEffectName) }, - { "PowerslideSpray", INI::parseAsciiString, NULL, offsetof(W3DTankTruckDrawModuleData, m_powerslideEffectName) }, - { "LeftFrontTireBone", INI::parseAsciiString, NULL, offsetof(W3DTankTruckDrawModuleData, m_frontLeftTireBoneName) }, - { "RightFrontTireBone", INI::parseAsciiString, NULL, offsetof(W3DTankTruckDrawModuleData, m_frontRightTireBoneName) }, - { "LeftRearTireBone", INI::parseAsciiString, NULL, offsetof(W3DTankTruckDrawModuleData, m_rearLeftTireBoneName) }, - { "RightRearTireBone", INI::parseAsciiString, NULL, offsetof(W3DTankTruckDrawModuleData, m_rearRightTireBoneName) }, - { "MidLeftFrontTireBone", INI::parseAsciiString, NULL, offsetof(W3DTankTruckDrawModuleData, m_midFrontLeftTireBoneName) }, - { "MidRightFrontTireBone", INI::parseAsciiString, NULL, offsetof(W3DTankTruckDrawModuleData, m_midFrontRightTireBoneName) }, - { "MidLeftRearTireBone", INI::parseAsciiString, NULL, offsetof(W3DTankTruckDrawModuleData, m_midRearLeftTireBoneName) }, - { "MidRightRearTireBone", INI::parseAsciiString, NULL, offsetof(W3DTankTruckDrawModuleData, m_midRearRightTireBoneName) }, - { "TireRotationMultiplier", INI::parseReal, NULL, offsetof(W3DTankTruckDrawModuleData, m_rotationSpeedMultiplier) }, - { "PowerslideRotationAddition", INI::parseReal, NULL, offsetof(W3DTankTruckDrawModuleData, m_powerslideRotationAddition) }, - { "TreadDebrisLeft", INI::parseAsciiString, NULL, offsetof(W3DTankTruckDrawModuleData, m_treadDebrisNameLeft) }, - { "TreadDebrisRight", INI::parseAsciiString, NULL, offsetof(W3DTankTruckDrawModuleData, m_treadDebrisNameRight) }, - { "TreadAnimationRate", INI::parseVelocityReal, NULL, offsetof(W3DTankTruckDrawModuleData, m_treadAnimationRate) }, - { "TreadPivotSpeedFraction", INI::parseReal, NULL, offsetof(W3DTankTruckDrawModuleData, m_treadPivotSpeedFraction) }, - { "TreadDriveSpeedFraction", INI::parseReal, NULL, offsetof(W3DTankTruckDrawModuleData, m_treadDriveSpeedFraction) }, - { 0, 0, 0, 0 } + { "Dust", INI::parseAsciiString, nullptr, offsetof(W3DTankTruckDrawModuleData, m_dustEffectName) }, + { "DirtSpray", INI::parseAsciiString, nullptr, offsetof(W3DTankTruckDrawModuleData, m_dirtEffectName) }, + { "PowerslideSpray", INI::parseAsciiString, nullptr, offsetof(W3DTankTruckDrawModuleData, m_powerslideEffectName) }, + { "LeftFrontTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTankTruckDrawModuleData, m_frontLeftTireBoneName) }, + { "RightFrontTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTankTruckDrawModuleData, m_frontRightTireBoneName) }, + { "LeftRearTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTankTruckDrawModuleData, m_rearLeftTireBoneName) }, + { "RightRearTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTankTruckDrawModuleData, m_rearRightTireBoneName) }, + { "MidLeftFrontTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTankTruckDrawModuleData, m_midFrontLeftTireBoneName) }, + { "MidRightFrontTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTankTruckDrawModuleData, m_midFrontRightTireBoneName) }, + { "MidLeftRearTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTankTruckDrawModuleData, m_midRearLeftTireBoneName) }, + { "MidRightRearTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTankTruckDrawModuleData, m_midRearRightTireBoneName) }, + { "TireRotationMultiplier", INI::parseReal, nullptr, offsetof(W3DTankTruckDrawModuleData, m_rotationSpeedMultiplier) }, + { "PowerslideRotationAddition", INI::parseReal, nullptr, offsetof(W3DTankTruckDrawModuleData, m_powerslideRotationAddition) }, + { "TreadDebrisLeft", INI::parseAsciiString, nullptr, offsetof(W3DTankTruckDrawModuleData, m_treadDebrisNameLeft) }, + { "TreadDebrisRight", INI::parseAsciiString, nullptr, offsetof(W3DTankTruckDrawModuleData, m_treadDebrisNameRight) }, + { "TreadAnimationRate", INI::parseVelocityReal, nullptr, offsetof(W3DTankTruckDrawModuleData, m_treadAnimationRate) }, + { "TreadPivotSpeedFraction", INI::parseReal, nullptr, offsetof(W3DTankTruckDrawModuleData, m_treadPivotSpeedFraction) }, + { "TreadDriveSpeedFraction", INI::parseReal, nullptr, offsetof(W3DTankTruckDrawModuleData, m_treadDriveSpeedFraction) }, + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); } @@ -96,57 +101,33 @@ void W3DTankTruckDrawModuleData::buildFieldParse(MultiIniFieldParse& p) //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- W3DTankTruckDraw::W3DTankTruckDraw( Thing *thing, const ModuleData* moduleData ) : W3DModelDraw( thing, moduleData ), -m_dirtEffect(NULL), m_dustEffect(NULL), m_powerslideEffect(NULL), m_effectsInitialized(false), -m_wasAirborne(false), m_isPowersliding(false), m_frontWheelRotation(0), m_rearWheelRotation(0), +m_effectsInitialized(false), m_wasAirborne(false), m_isPowersliding(false), m_frontWheelRotation(0), m_rearWheelRotation(0), m_frontRightTireBone(0), m_frontLeftTireBone(0), m_rearLeftTireBone(0),m_rearRightTireBone(0), -m_prevRenderObj(NULL) +m_prevRenderObj(nullptr) { //Truck Data + std::fill(m_truckEffectIDs, m_truckEffectIDs + ARRAY_SIZE(m_truckEffectIDs), INVALID_PARTICLE_SYSTEM_ID); + m_landingSound = *(thing->getTemplate()->getPerUnitSound("TruckLandingSound")); m_powerslideSound = *(thing->getTemplate()->getPerUnitSound("TruckPowerslideSound")); //Tank data - m_treadDebrisLeft = NULL; - m_treadDebrisRight = NULL; + std::fill(m_treadDebrisIDs, m_treadDebrisIDs + ARRAY_SIZE(m_treadDebrisIDs), INVALID_PARTICLE_SYSTEM_ID); for (Int i=0; ifindTemplate(getW3DTankTruckDrawModuleData()->m_treadDebrisNameLeft); - if (sysTemplate) - { - m_treadDebrisLeft = TheParticleSystemManager->createParticleSystem( sysTemplate ); - m_treadDebrisLeft->attachToDrawable(getDrawable()); -DEBUG_CRASH(("test me, may not work (srj)")); - // important: mark it as do-not-save, since we'll just re-create it when we reload. - m_treadDebrisLeft->setSaveable(FALSE); - } - - sysTemplate = TheParticleSystemManager->findTemplate(getW3DTankTruckDrawModuleData()->m_treadDebrisNameRight); - if (sysTemplate) - { - m_treadDebrisRight = TheParticleSystemManager->createParticleSystem( sysTemplate ); - m_treadDebrisRight->attachToDrawable(getDrawable()); -DEBUG_CRASH(("test me, may not work (srj)")); - // important: mark it as do-not-save, since we'll just re-create it when we reload. - m_treadDebrisRight->setSaveable(FALSE); - } - } -#endif + createTreadEmitters(); } //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- W3DTankTruckDraw::~W3DTankTruckDraw() { - tossEmitters(); + tossWheelEmitters(); + tossTreadEmitters(); for (Int i=0; iisDrawableEffectivelyHidden()) - return; - if (m_treadDebrisLeft) - m_treadDebrisLeft->start(); - if (m_treadDebrisRight) - m_treadDebrisRight->start(); -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -/** - * Stop creating debris from the tank treads - */ void W3DTankTruckDraw::stopMoveDebris( void ) { - if (m_treadDebrisLeft) - m_treadDebrisLeft->stop(); - if (m_treadDebrisRight) - m_treadDebrisRight->stop(); + for (size_t i = 0; i < ARRAY_SIZE(m_treadDebrisIDs); ++i) + { + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_treadDebrisIDs[i])) + { + particleSys->stop(); + } + } } //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- -void W3DTankTruckDraw::tossEmitters() +void W3DTankTruckDraw::tossWheelEmitters() { - if (m_dustEffect) - { - m_dustEffect->attachToObject(NULL); - m_dustEffect->destroy(); - m_dustEffect = NULL; - } - if (m_dirtEffect) - { - m_dirtEffect->attachToObject(NULL); - m_dirtEffect->destroy(); - m_dirtEffect = NULL; - } - if (m_powerslideEffect) + for (size_t i = 0; i < ARRAY_SIZE(m_truckEffectIDs); ++i) { - m_powerslideEffect->attachToObject(NULL); - m_powerslideEffect->destroy(); - m_powerslideEffect = NULL; + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[i])) + { + particleSys->attachToObject(nullptr); + particleSys->destroy(); + } + m_truckEffectIDs[i] = INVALID_PARTICLE_SYSTEM_ID; } } @@ -212,110 +168,133 @@ void W3DTankTruckDraw::setFullyObscuredByShroud(Bool fullyObscured) if (fullyObscured != getFullyObscuredByShroud()) { if (fullyObscured) - tossEmitters(); + { + tossWheelEmitters(); + stopMoveDebris(); + } else - createEmitters(); + { + createWheelEmitters(); + } } W3DModelDraw::setFullyObscuredByShroud(fullyObscured); } //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- -/** - - * Start creating debris from the tank treads - */ -void W3DTankTruckDraw::createEmitters( void ) +void W3DTankTruckDraw::createTreadEmitters( void ) { - if (getDrawable()->isDrawableEffectivelyHidden()) - return; if (getW3DTankTruckDrawModuleData()) { - const ParticleSystemTemplate *sysTemplate; - - if (!m_dustEffect) { + const AsciiString *treadDebrisNames[2]; + static_assert(ARRAY_SIZE(treadDebrisNames) == ARRAY_SIZE(m_treadDebrisIDs), "Array size must match"); + treadDebrisNames[0] = &getW3DTankTruckDrawModuleData()->m_treadDebrisNameLeft; + treadDebrisNames[1] = &getW3DTankTruckDrawModuleData()->m_treadDebrisNameRight; - sysTemplate = TheParticleSystemManager->findTemplate(getW3DTankTruckDrawModuleData()->m_dustEffectName); - if (sysTemplate) + for (size_t i = 0; i < ARRAY_SIZE(m_treadDebrisIDs); ++i) + { + if (m_treadDebrisIDs[i] == INVALID_PARTICLE_SYSTEM_ID) { - m_dustEffect = TheParticleSystemManager->createParticleSystem( sysTemplate ); - m_dustEffect->attachToObject(getDrawable()->getObject()); - // important: mark it as do-not-save, since we'll just re-create it when we reload. - m_dustEffect->setSaveable(FALSE); - } else { - if (!getW3DTankTruckDrawModuleData()->m_dustEffectName.isEmpty()) { - DEBUG_LOG(("*** ERROR - Missing particle system '%s' in thing '%s'", - getW3DTankTruckDrawModuleData()->m_dustEffectName.str(), getDrawable()->getObject()->getTemplate()->getName().str())); + if (const ParticleSystemTemplate *sysTemplate = TheParticleSystemManager->findTemplate(*treadDebrisNames[i])) + { + ParticleSystem *particleSys = TheParticleSystemManager->createParticleSystem( sysTemplate ); + particleSys->attachToDrawable(getDrawable()); + // important: mark it as do-not-save, since we'll just re-create it when we reload. + particleSys->setSaveable(FALSE); + // they come into being stopped. + particleSys->stop(); + m_treadDebrisIDs[i] = particleSys->getSystemID(); } } + } + } +} +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +void W3DTankTruckDraw::tossTreadEmitters( void ) +{ + for (size_t i = 0; i < ARRAY_SIZE(m_treadDebrisIDs); ++i) + { + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_treadDebrisIDs[i])) + { + particleSys->attachToObject(nullptr); + particleSys->destroy(); } - if (!m_dirtEffect) { - sysTemplate = TheParticleSystemManager->findTemplate(getW3DTankTruckDrawModuleData()->m_dirtEffectName); - if (sysTemplate) + m_treadDebrisIDs[i] = INVALID_PARTICLE_SYSTEM_ID; + } +} + +//------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------------- +void W3DTankTruckDraw::createWheelEmitters( void ) +{ + if (getDrawable()->isDrawableEffectivelyHidden()) + return; + if (getW3DTankTruckDrawModuleData()) + { + const AsciiString *effectNames[3]; + static_assert(ARRAY_SIZE(effectNames) == ARRAY_SIZE(m_truckEffectIDs), "Array size must match"); + effectNames[0] = &getW3DTankTruckDrawModuleData()->m_dustEffectName; + effectNames[1] = &getW3DTankTruckDrawModuleData()->m_dirtEffectName; + effectNames[2] = &getW3DTankTruckDrawModuleData()->m_powerslideEffectName; + + for (size_t i = 0; i < ARRAY_SIZE(m_truckEffectIDs); ++i) + { + if (m_truckEffectIDs[i] == INVALID_PARTICLE_SYSTEM_ID) { - m_dirtEffect = TheParticleSystemManager->createParticleSystem( sysTemplate ); - m_dirtEffect->attachToObject(getDrawable()->getObject()); - // important: mark it as do-not-save, since we'll just re-create it when we reload. - m_dirtEffect->setSaveable(FALSE); - } else { - if (!getW3DTankTruckDrawModuleData()->m_dirtEffectName.isEmpty()) { - DEBUG_LOG(("*** ERROR - Missing particle system '%s' in thing '%s'", - getW3DTankTruckDrawModuleData()->m_dirtEffectName.str(), getDrawable()->getObject()->getTemplate()->getName().str())); + if (const ParticleSystemTemplate *sysTemplate = TheParticleSystemManager->findTemplate(*effectNames[i])) + { + ParticleSystem *particleSys = TheParticleSystemManager->createParticleSystem( sysTemplate ); + particleSys->attachToObject(getDrawable()->getObject()); + // important: mark it as do-not-save, since we'll just re-create it when we reload. + particleSys->setSaveable(FALSE); + m_truckEffectIDs[i] = particleSys->getSystemID(); } - } - } - if (!m_powerslideEffect) { - sysTemplate = TheParticleSystemManager->findTemplate(getW3DTankTruckDrawModuleData()->m_powerslideEffectName); - if (sysTemplate) - { - m_powerslideEffect = TheParticleSystemManager->createParticleSystem( sysTemplate ); - m_powerslideEffect->attachToObject(getDrawable()->getObject()); - // important: mark it as do-not-save, since we'll just re-create it when we reload. - m_powerslideEffect->setSaveable(FALSE); - } else { - if (!getW3DTankTruckDrawModuleData()->m_powerslideEffectName.isEmpty()) { - DEBUG_LOG(("*** ERROR - Missing particle system '%s' in thing '%s'", - getW3DTankTruckDrawModuleData()->m_powerslideEffectName.str(), getDrawable()->getObject()->getTemplate()->getName().str())); + else + { + if (!effectNames[i]->isEmpty()) { + DEBUG_LOG(("*** ERROR - Missing particle system '%s' in thing '%s'", + effectNames[i]->str(), getDrawable()->getObject()->getTemplate()->getName().str())); + } } } } } - } //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- -/** - * Stop creating debris from the tank treads - */ -void W3DTankTruckDraw::enableEmitters( Bool enable ) +void W3DTankTruckDraw::enableWheelEmitters( Bool enable ) { // don't check... if we are hidden the first time thru, then we'll never create the emitters. // eg, if we are loading a game and the unit is in a tunnel, he'll never get emitteres even when he exits. //if (!m_effectsInitialized) { - createEmitters(); + createWheelEmitters(); m_effectsInitialized=true; } - if (m_dustEffect) + + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[DustEffect])) { if (enable) - m_dustEffect->start(); + particleSys->start(); else - m_dustEffect->stop(); + particleSys->stop(); } - if (m_dirtEffect) + + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[DirtEffect])) { if (enable) - m_dirtEffect->start(); + particleSys->start(); else - m_dirtEffect->stop(); + particleSys->stop(); } - if (m_powerslideEffect) + + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[PowerslideEffect])) { if (!enable) - m_powerslideEffect->stop(); + particleSys->stop(); } } //------------------------------------------------------------------------------------------------- @@ -391,10 +370,8 @@ void W3DTankTruckDraw::setHidden(Bool h) W3DModelDraw::setHidden(h); if (h) { - enableEmitters(false); -#ifdef SHOW_TANK_DEBRIS + enableWheelEmitters(false); stopMoveDebris(); -#endif } } @@ -446,7 +423,7 @@ void W3DTankTruckDraw::updateTreadObjects(void) const char *meshName; //Check if subobject name starts with "TREADS". if (subObj && subObj->Class_ID() == RenderObjClass::CLASSID_MESH && subObj->Get_Name() - && ( (meshName=strchr(subObj->Get_Name(),'.') ) != 0 && *(meshName++)) + && ( (meshName=strchr(subObj->Get_Name(),'.') ) != nullptr && *(meshName++)) &&_strnicmp(meshName,"TREADS", 6) == 0) { //check if sub-object has the correct material to do texture scrolling. MaterialInfoClass *mat=subObj->Get_Material_Info(); @@ -491,7 +468,7 @@ void W3DTankTruckDraw::onRenderObjRecreated(void) //DEBUG_LOG(("Old obj %x, newObj %x, new bones %d, old bones %d", // m_prevRenderObj, getRenderObject(), getRenderObject()->Get_Num_Bones(), // m_prevNumBones)); - m_prevRenderObj = NULL; + m_prevRenderObj = nullptr; m_frontLeftTireBone = 0; m_frontRightTireBone = 0; m_rearLeftTireBone = 0; @@ -524,17 +501,17 @@ void W3DTankTruckDraw::doDrawModule(const Matrix3D* transformMtx) const Real SIZE_CAP = 2.0f; // get object from logic Object *obj = getDrawable()->getObject(); - if (obj == NULL) + if (obj == nullptr) return; - if (getRenderObject()==NULL) return; + if (getRenderObject()==nullptr) return; if (getRenderObject() != m_prevRenderObj) { updateBones(); updateTreadObjects(); } // get object physics state PhysicsBehavior *physics = obj->getPhysics(); - if (physics == NULL) + if (physics == nullptr) return; // skip wheel animations - if over water @@ -629,7 +606,7 @@ void W3DTankTruckDraw::doDrawModule(const Matrix3D* transformMtx) Bool wasPowersliding = m_isPowersliding; m_isPowersliding = false; if (physics->isMotive() && !obj->isSignificantlyAboveTerrain()) { - enableEmitters(true); + enableWheelEmitters(true); Coord3D accel = *physics->getAcceleration(); accel.z = 0; // ignore gravitational force. Bool accelerating = accel.length()>ACCEL_THRESHOLD; @@ -640,43 +617,38 @@ void W3DTankTruckDraw::doDrawModule(const Matrix3D* transformMtx) accelerating = false; // decelerating, actually. } } - if (m_dustEffect) { + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[DustEffect])) { // Need more dust the faster we go. if (speed>SIZE_CAP) { speed = SIZE_CAP; } - m_dustEffect->setSizeMultiplier(speed); - } - if (m_dirtEffect) { if (wheelInfo && wheelInfo->m_framesAirborne>3) { Real factor = 1 + wheelInfo->m_framesAirborne/16; if (factor>2.0) factor = 2.0; - m_dustEffect->setSizeMultiplier(factor*SIZE_CAP); - m_dustEffect->trigger(); + particleSys->setSizeMultiplier(factor*SIZE_CAP); + particleSys->trigger(); m_landingSound.setPosition(obj->getPosition()); TheAudio->addAudioEvent(&m_landingSound); } else { - if (!accelerating || speed>2.0f) { - m_dirtEffect->stop(); - } + particleSys->setSizeMultiplier(speed); } } - if (m_powerslideEffect) { + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[PowerslideEffect])) { if (physics->getTurning() == TURN_NONE) { - m_powerslideEffect->stop(); + particleSys->stop(); } else { m_isPowersliding = true; - m_powerslideEffect->start(); + particleSys->start(); } } - if (m_dirtEffect) { - if (!accelerating || speed>2.0f) { - m_dirtEffect->stop(); + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[DirtEffect])) { + if (!accelerating) { + particleSys->stop(); } } } else - enableEmitters(false); + enableWheelEmitters(false); m_wasAirborne = obj->isSignificantlyAboveTerrain(); @@ -689,16 +661,12 @@ void W3DTankTruckDraw::doDrawModule(const Matrix3D* transformMtx) } //Tank update -#ifdef SHOW_TANK_DEBRIS const Real DEBRIS_THRESHOLD = 0.00001f; // if tank is moving, kick up dust and debris Real velMag = vel->x*vel->x + vel->y*vel->y; // only care about moving on the ground - if (velMag > DEBRIS_THRESHOLD && !getDrawable()->isDrawableEffectivelyHidden() && !getFullyObscuredByShroud()) - startMoveDebris(); - else - stopMoveDebris(); + const Bool doStartMoveDebris = velMag > DEBRIS_THRESHOLD && !getDrawable()->isDrawableEffectivelyHidden() && !getFullyObscuredByShroud(); // kick debris higher the faster we move Coord3D velMult; @@ -714,12 +682,20 @@ void W3DTankTruckDraw::doDrawModule(const Matrix3D* transformMtx) if (velMult.z > 1.0f) velMult.z = 1.0f; - m_treadDebrisLeft->setVelocityMultiplier( &velMult ); - m_treadDebrisRight->setVelocityMultiplier( &velMult ); + for (size_t i = 0; i < ARRAY_SIZE(m_treadDebrisIDs); ++i) + { + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_treadDebrisIDs[i])) + { + if (doStartMoveDebris) + particleSys->start(); + else + particleSys->stop(); + + particleSys->setVelocityMultiplier( &velMult ); + particleSys->setBurstCountMultiplier( velMult.z ); + } + } - m_treadDebrisLeft->setBurstCountMultiplier( velMult.z ); - m_treadDebrisRight->setBurstCountMultiplier( velMult.z ); -#endif //Update movement of treads if (m_treadCount && !(obj->isKindOf(KINDOF_NO_MOVE_EFFECTS_ON_WATER) && obj->isOverWater())) { @@ -796,7 +772,11 @@ void W3DTankTruckDraw::loadPostProcess( void ) // extend base class W3DModelDraw::loadPostProcess(); - // toss any existing ones (no need to re-create; we'll do that on demand) - tossEmitters(); + // toss any existing wheel emitters (no need to re-create; we'll do that on demand) + tossWheelEmitters(); + + // toss any existing tread emitters and re-create 'em (since this module expects 'em to always be around) + tossTreadEmitters(); + createTreadEmitters(); } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTracerDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTracerDraw.cpp similarity index 99% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTracerDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTracerDraw.cpp index 8398f8c0ece..15554b3a5b3 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTracerDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTracerDraw.cpp @@ -59,7 +59,7 @@ W3DTracerDraw::W3DTracerDraw( Thing *thing, const ModuleData* moduleData ) : Dra m_color.green = 0.8f; m_color.blue = 0.7f; m_speedInDistPerFrame = 1.0f; - m_theTracer = NULL; + m_theTracer = nullptr; } @@ -111,7 +111,7 @@ void W3DTracerDraw::doDrawModule(const Matrix3D* transformMtx) { // create tracer - if( m_theTracer == NULL ) + if( m_theTracer == nullptr ) { Vector3 start( 0.0f, 0.0f, 0.0f ); diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTreeDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTreeDraw.cpp index 81fff438779..7978ec8d17b 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTreeDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTreeDraw.cpp @@ -52,8 +52,8 @@ m_maxOutwardMovement(1.0f) const Real START_ACCEL_PERCENT = 0.01f; const Real VELOCITY_BOUNCE_PERCENT = 0.3f; // multiply the velocity by this when you bounce const Real MINIMUM_TOPPLE_SPEED = 0.5f; // Won't let trees fall slower than this - m_toppleFX = NULL; - m_bounceFX = NULL; + m_toppleFX = nullptr; + m_bounceFX = nullptr; m_stumpName.clear(); m_killWhenToppled = true; m_doTopple = false; @@ -78,27 +78,27 @@ void W3DTreeDrawModuleData::buildFieldParse(MultiIniFieldParse& p) ModuleData::buildFieldParse(p); static const FieldParse dataFieldParse[] = { - { "ModelName", INI::parseAsciiString, NULL, offsetof(W3DTreeDrawModuleData, m_modelName) }, - { "TextureName", INI::parseAsciiString, NULL, offsetof(W3DTreeDrawModuleData, m_textureName) }, - { "MoveOutwardTime", INI::parseDurationUnsignedInt, NULL, offsetof(W3DTreeDrawModuleData, m_framesToMoveOutward) }, - { "MoveInwardTime", INI::parseDurationUnsignedInt, NULL, offsetof(W3DTreeDrawModuleData, m_framesToMoveInward) }, - { "MoveOutwardDistanceFactor", INI::parseReal, NULL, offsetof(W3DTreeDrawModuleData, m_maxOutwardMovement) }, - { "DarkeningFactor", INI::parseReal, NULL, offsetof(W3DTreeDrawModuleData, m_darkening) }, + { "ModelName", INI::parseAsciiString, nullptr, offsetof(W3DTreeDrawModuleData, m_modelName) }, + { "TextureName", INI::parseAsciiString, nullptr, offsetof(W3DTreeDrawModuleData, m_textureName) }, + { "MoveOutwardTime", INI::parseDurationUnsignedInt, nullptr, offsetof(W3DTreeDrawModuleData, m_framesToMoveOutward) }, + { "MoveInwardTime", INI::parseDurationUnsignedInt, nullptr, offsetof(W3DTreeDrawModuleData, m_framesToMoveInward) }, + { "MoveOutwardDistanceFactor", INI::parseReal, nullptr, offsetof(W3DTreeDrawModuleData, m_maxOutwardMovement) }, + { "DarkeningFactor", INI::parseReal, nullptr, offsetof(W3DTreeDrawModuleData, m_darkening) }, // Topple parameters [7/7/2003] - { "ToppleFX", INI::parseFXList, NULL, offsetof( W3DTreeDrawModuleData, m_toppleFX ) }, - { "BounceFX", INI::parseFXList, NULL, offsetof( W3DTreeDrawModuleData, m_bounceFX ) }, - { "StumpName", INI::parseAsciiString, NULL, offsetof( W3DTreeDrawModuleData, m_stumpName ) }, - { "KillWhenFinishedToppling", INI::parseBool, NULL, offsetof( W3DTreeDrawModuleData, m_killWhenToppled ) }, - { "DoTopple", INI::parseBool, NULL, offsetof( W3DTreeDrawModuleData, m_doTopple ) }, - { "InitialVelocityPercent", INI::parsePercentToReal, NULL, offsetof( W3DTreeDrawModuleData, m_initialVelocityPercent ) }, - { "InitialAccelPercent", INI::parsePercentToReal, NULL, offsetof( W3DTreeDrawModuleData, m_initialAccelPercent ) }, - { "BounceVelocityPercent", INI::parsePercentToReal, NULL, offsetof( W3DTreeDrawModuleData, m_bounceVelocityPercent ) }, - { "MinimumToppleSpeed", INI::parsePositiveNonZeroReal, NULL, offsetof( W3DTreeDrawModuleData, m_minimumToppleSpeed ) }, - { "SinkDistance", INI::parsePositiveNonZeroReal, NULL, offsetof( W3DTreeDrawModuleData, m_sinkDistance ) }, - { "SinkTime", INI::parseDurationUnsignedInt, NULL, offsetof(W3DTreeDrawModuleData, m_sinkFrames) }, - { "DoShadow", INI::parseBool, NULL, offsetof( W3DTreeDrawModuleData, m_doShadow ) }, - { 0, 0, 0, 0 } + { "ToppleFX", INI::parseFXList, nullptr, offsetof( W3DTreeDrawModuleData, m_toppleFX ) }, + { "BounceFX", INI::parseFXList, nullptr, offsetof( W3DTreeDrawModuleData, m_bounceFX ) }, + { "StumpName", INI::parseAsciiString, nullptr, offsetof( W3DTreeDrawModuleData, m_stumpName ) }, + { "KillWhenFinishedToppling", INI::parseBool, nullptr, offsetof( W3DTreeDrawModuleData, m_killWhenToppled ) }, + { "DoTopple", INI::parseBool, nullptr, offsetof( W3DTreeDrawModuleData, m_doTopple ) }, + { "InitialVelocityPercent", INI::parsePercentToReal, nullptr, offsetof( W3DTreeDrawModuleData, m_initialVelocityPercent ) }, + { "InitialAccelPercent", INI::parsePercentToReal, nullptr, offsetof( W3DTreeDrawModuleData, m_initialAccelPercent ) }, + { "BounceVelocityPercent", INI::parsePercentToReal, nullptr, offsetof( W3DTreeDrawModuleData, m_bounceVelocityPercent ) }, + { "MinimumToppleSpeed", INI::parsePositiveNonZeroReal, nullptr, offsetof( W3DTreeDrawModuleData, m_minimumToppleSpeed ) }, + { "SinkDistance", INI::parsePositiveNonZeroReal, nullptr, offsetof( W3DTreeDrawModuleData, m_sinkDistance ) }, + { "SinkTime", INI::parseDurationUnsignedInt, nullptr, offsetof(W3DTreeDrawModuleData, m_sinkFrames) }, + { "DoShadow", INI::parseBool, nullptr, offsetof( W3DTreeDrawModuleData, m_doShadow ) }, + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); } diff --git a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp similarity index 76% rename from GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp rename to Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp index c7a4f583aa8..8e4d860d31d 100644 --- a/GeneralsMD/Code/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Drawable/Draw/W3DTruckDraw.cpp @@ -67,30 +67,30 @@ void W3DTruckDrawModuleData::buildFieldParse(MultiIniFieldParse& p) static const FieldParse dataFieldParse[] = { - { "Dust", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_dustEffectName) }, - { "DirtSpray", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_dirtEffectName) }, - { "PowerslideSpray", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_powerslideEffectName) }, - - { "LeftFrontTireBone", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_frontLeftTireBoneName) }, - { "RightFrontTireBone", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_frontRightTireBoneName) }, - { "LeftRearTireBone", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_rearLeftTireBoneName) }, - { "RightRearTireBone", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_rearRightTireBoneName) }, - { "MidLeftFrontTireBone", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_midFrontLeftTireBoneName) }, - { "MidRightFrontTireBone", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_midFrontRightTireBoneName) }, - { "MidLeftRearTireBone", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_midRearLeftTireBoneName) }, - { "MidRightRearTireBone", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_midRearRightTireBoneName) }, - { "MidLeftMidTireBone", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_midMidLeftTireBoneName) }, - { "MidRightMidTireBone", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_midMidRightTireBoneName) }, - - { "TireRotationMultiplier", INI::parseReal, NULL, offsetof(W3DTruckDrawModuleData, m_rotationSpeedMultiplier) }, - { "PowerslideRotationAddition", INI::parseReal, NULL, offsetof(W3DTruckDrawModuleData, m_powerslideRotationAddition) }, - { "CabBone", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_cabBoneName) }, - { "TrailerBone", INI::parseAsciiString, NULL, offsetof(W3DTruckDrawModuleData, m_trailerBoneName) }, - { "CabRotationMultiplier", INI::parseReal, NULL, offsetof(W3DTruckDrawModuleData, m_cabRotationFactor) }, - { "TrailerRotationMultiplier", INI::parseReal, NULL, offsetof(W3DTruckDrawModuleData, m_trailerRotationFactor) }, - { "RotationDamping", INI::parseReal, NULL, offsetof(W3DTruckDrawModuleData, m_rotationDampingFactor) }, - - { 0, 0, 0, 0 } + { "Dust", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_dustEffectName) }, + { "DirtSpray", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_dirtEffectName) }, + { "PowerslideSpray", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_powerslideEffectName) }, + + { "LeftFrontTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_frontLeftTireBoneName) }, + { "RightFrontTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_frontRightTireBoneName) }, + { "LeftRearTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_rearLeftTireBoneName) }, + { "RightRearTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_rearRightTireBoneName) }, + { "MidLeftFrontTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_midFrontLeftTireBoneName) }, + { "MidRightFrontTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_midFrontRightTireBoneName) }, + { "MidLeftRearTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_midRearLeftTireBoneName) }, + { "MidRightRearTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_midRearRightTireBoneName) }, + { "MidLeftMidTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_midMidLeftTireBoneName) }, + { "MidRightMidTireBone", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_midMidRightTireBoneName) }, + + { "TireRotationMultiplier", INI::parseReal, nullptr, offsetof(W3DTruckDrawModuleData, m_rotationSpeedMultiplier) }, + { "PowerslideRotationAddition", INI::parseReal, nullptr, offsetof(W3DTruckDrawModuleData, m_powerslideRotationAddition) }, + { "CabBone", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_cabBoneName) }, + { "TrailerBone", INI::parseAsciiString, nullptr, offsetof(W3DTruckDrawModuleData, m_trailerBoneName) }, + { "CabRotationMultiplier", INI::parseReal, nullptr, offsetof(W3DTruckDrawModuleData, m_cabRotationFactor) }, + { "TrailerRotationMultiplier", INI::parseReal, nullptr, offsetof(W3DTruckDrawModuleData, m_trailerRotationFactor) }, + { "RotationDamping", INI::parseReal, nullptr, offsetof(W3DTruckDrawModuleData, m_rotationDampingFactor) }, + + { nullptr, nullptr, nullptr, 0 } }; p.add(dataFieldParse); } @@ -98,13 +98,14 @@ void W3DTruckDrawModuleData::buildFieldParse(MultiIniFieldParse& p) //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- W3DTruckDraw::W3DTruckDraw( Thing *thing, const ModuleData* moduleData ) : W3DModelDraw( thing, moduleData ), -m_dirtEffect(NULL), m_dustEffect(NULL), m_powerslideEffect(NULL), m_effectsInitialized(false), -m_wasAirborne(false), m_isPowersliding(false), +m_effectsInitialized(false), m_wasAirborne(false), m_isPowersliding(false), m_frontWheelRotation(0), m_rearWheelRotation(0), m_midFrontWheelRotation(0), m_midRearWheelRotation(0), m_frontRightTireBone(0), m_frontLeftTireBone(0), m_rearLeftTireBone(0),m_rearRightTireBone(0), m_midFrontRightTireBone(0), m_midFrontLeftTireBone(0), m_midRearLeftTireBone(0),m_midRearRightTireBone(0), -m_midMidRightTireBone(0), m_midMidLeftTireBone(0), m_prevRenderObj(NULL) +m_midMidRightTireBone(0), m_midMidLeftTireBone(0), m_prevRenderObj(nullptr) { + std::fill(m_truckEffectIDs, m_truckEffectIDs + ARRAY_SIZE(m_truckEffectIDs), INVALID_PARTICLE_SYSTEM_ID); + const AudioEventRTS * event; event = thing->getTemplate()->getPerUnitSound("TruckLandingSound"); if (event) { @@ -120,30 +121,21 @@ m_midMidRightTireBone(0), m_midMidLeftTireBone(0), m_prevRenderObj(NULL) //------------------------------------------------------------------------------------------------- W3DTruckDraw::~W3DTruckDraw() { - tossEmitters(); + tossWheelEmitters(); } //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- -void W3DTruckDraw::tossEmitters() +void W3DTruckDraw::tossWheelEmitters() { - if (m_dustEffect) - { - m_dustEffect->attachToObject(NULL); - m_dustEffect->destroy(); - m_dustEffect = NULL; - } - if (m_dirtEffect) + for (size_t i = 0; i < ARRAY_SIZE(m_truckEffectIDs); ++i) { - m_dirtEffect->attachToObject(NULL); - m_dirtEffect->destroy(); - m_dirtEffect = NULL; - } - if (m_powerslideEffect) - { - m_powerslideEffect->attachToObject(NULL); - m_powerslideEffect->destroy(); - m_powerslideEffect = NULL; + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[i])) + { + particleSys->attachToObject(nullptr); + particleSys->destroy(); + } + m_truckEffectIDs[i] = INVALID_PARTICLE_SYSTEM_ID; } } @@ -153,110 +145,83 @@ void W3DTruckDraw::setFullyObscuredByShroud(Bool fullyObscured) if (fullyObscured != getFullyObscuredByShroud()) { if (fullyObscured) - tossEmitters(); + tossWheelEmitters(); else - createEmitters(); + createWheelEmitters(); } W3DModelDraw::setFullyObscuredByShroud(fullyObscured); } //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- -/** - - * Start creating debris from the tank treads - */ -void W3DTruckDraw::createEmitters( void ) +void W3DTruckDraw::createWheelEmitters( void ) { if (getDrawable()->isDrawableEffectivelyHidden()) return; if (getW3DTruckDrawModuleData()) { - const ParticleSystemTemplate *sysTemplate; - - if (!m_dustEffect) { - - sysTemplate = TheParticleSystemManager->findTemplate(getW3DTruckDrawModuleData()->m_dustEffectName); - if (sysTemplate) - { - m_dustEffect = TheParticleSystemManager->createParticleSystem( sysTemplate ); - m_dustEffect->attachToObject(getDrawable()->getObject()); - // important: mark it as do-not-save, since we'll just re-create it when we reload. - m_dustEffect->setSaveable(FALSE); - } else { - if (!getW3DTruckDrawModuleData()->m_dustEffectName.isEmpty()) { - DEBUG_LOG(("*** ERROR - Missing particle system '%s' in thing '%s'", - getW3DTruckDrawModuleData()->m_dustEffectName.str(), getDrawable()->getObject()->getTemplate()->getName().str())); - } - } + const AsciiString *effectNames[3]; + static_assert(ARRAY_SIZE(effectNames) == ARRAY_SIZE(m_truckEffectIDs), "Array size must match"); + effectNames[0] = &getW3DTruckDrawModuleData()->m_dustEffectName; + effectNames[1] = &getW3DTruckDrawModuleData()->m_dirtEffectName; + effectNames[2] = &getW3DTruckDrawModuleData()->m_powerslideEffectName; - } - if (!m_dirtEffect) { - sysTemplate = TheParticleSystemManager->findTemplate(getW3DTruckDrawModuleData()->m_dirtEffectName); - if (sysTemplate) + for (size_t i = 0; i < ARRAY_SIZE(m_truckEffectIDs); ++i) + { + if (m_truckEffectIDs[i] == INVALID_PARTICLE_SYSTEM_ID) { - m_dirtEffect = TheParticleSystemManager->createParticleSystem( sysTemplate ); - m_dirtEffect->attachToObject(getDrawable()->getObject()); - // important: mark it as do-not-save, since we'll just re-create it when we reload. - m_dirtEffect->setSaveable(FALSE); - } else { - if (!getW3DTruckDrawModuleData()->m_dirtEffectName.isEmpty()) { - DEBUG_LOG(("*** ERROR - Missing particle system '%s' in thing '%s'", - getW3DTruckDrawModuleData()->m_dirtEffectName.str(), getDrawable()->getObject()->getTemplate()->getName().str())); + if (const ParticleSystemTemplate *sysTemplate = TheParticleSystemManager->findTemplate(*effectNames[i])) + { + ParticleSystem *particleSys = TheParticleSystemManager->createParticleSystem( sysTemplate ); + particleSys->attachToObject(getDrawable()->getObject()); + // important: mark it as do-not-save, since we'll just re-create it when we reload. + particleSys->setSaveable(FALSE); + m_truckEffectIDs[i] = particleSys->getSystemID(); } - } - } - if (!m_powerslideEffect) { - sysTemplate = TheParticleSystemManager->findTemplate(getW3DTruckDrawModuleData()->m_powerslideEffectName); - if (sysTemplate) - { - m_powerslideEffect = TheParticleSystemManager->createParticleSystem( sysTemplate ); - m_powerslideEffect->attachToObject(getDrawable()->getObject()); - // important: mark it as do-not-save, since we'll just re-create it when we reload. - m_powerslideEffect->setSaveable(FALSE); - } else { - if (!getW3DTruckDrawModuleData()->m_powerslideEffectName.isEmpty()) { - DEBUG_LOG(("*** ERROR - Missing particle system '%s' in thing '%s'", - getW3DTruckDrawModuleData()->m_powerslideEffectName.str(), getDrawable()->getObject()->getTemplate()->getName().str())); + else + { + if (!effectNames[i]->isEmpty()) { + DEBUG_LOG(("*** ERROR - Missing particle system '%s' in thing '%s'", + effectNames[i]->str(), getDrawable()->getObject()->getTemplate()->getName().str())); + } } } } } - } //------------------------------------------------------------------------------------------------- //------------------------------------------------------------------------------------------------- -/** - * Stop creating debris from the tank treads - */ -void W3DTruckDraw::enableEmitters( Bool enable ) +void W3DTruckDraw::enableWheelEmitters( Bool enable ) { // don't check... if we are hidden the first time thru, then we'll never create the emitters. // eg, if we are loading a game and the unit is in a tunnel, he'll never get emitteres even when he exits. //if (!m_effectsInitialized) { - createEmitters(); + createWheelEmitters(); m_effectsInitialized=true; } - if (m_dustEffect) + + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[DustEffect])) { if (enable) - m_dustEffect->start(); + particleSys->start(); else - m_dustEffect->stop(); + particleSys->stop(); } - if (m_dirtEffect) + + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[DirtEffect])) { if (enable) - m_dirtEffect->start(); + particleSys->start(); else - m_dirtEffect->stop(); + particleSys->stop(); } - if (m_powerslideEffect) + + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[PowerslideEffect])) { if (!enable) - m_powerslideEffect->stop(); + particleSys->stop(); } } //------------------------------------------------------------------------------------------------- @@ -354,7 +319,7 @@ void W3DTruckDraw::setHidden(Bool h) W3DModelDraw::setHidden(h); if (h) { - enableEmitters(false); + enableWheelEmitters(false); } } @@ -364,7 +329,7 @@ void W3DTruckDraw::onRenderObjRecreated(void) //DEBUG_LOG(("Old obj %x, newObj %x, new bones %d, old bones %d", // m_prevRenderObj, getRenderObject(), getRenderObject()->Get_Num_Bones(), // m_prevNumBones)); - m_prevRenderObj = NULL; + m_prevRenderObj = nullptr; m_frontLeftTireBone = 0; m_frontRightTireBone = 0; m_rearLeftTireBone = 0; @@ -390,7 +355,7 @@ void W3DTruckDraw::doDrawModule(const Matrix3D* transformMtx) return; const W3DTruckDrawModuleData *moduleData = getW3DTruckDrawModuleData(); - if (moduleData==NULL) + if (moduleData==nullptr) return; // shouldn't ever happen. // TheSuperHackers @tweak Update the draw on every WW Sync only. @@ -402,10 +367,10 @@ void W3DTruckDraw::doDrawModule(const Matrix3D* transformMtx) const Real SIZE_CAP = 2.0f; // get object from logic Object *obj = getDrawable()->getObject(); - if (obj == NULL) + if (obj == nullptr) return; - if (getRenderObject()==NULL) return; + if (getRenderObject()==nullptr) return; if (getRenderObject() != m_prevRenderObj) { DEBUG_LOG(("W3DTruckDraw::doDrawModule - shouldn't update bones. jba")); updateBones(); @@ -413,7 +378,7 @@ void W3DTruckDraw::doDrawModule(const Matrix3D* transformMtx) // get object physics state PhysicsBehavior *physics = obj->getPhysics(); - if (physics == NULL) + if (physics == nullptr) return; // skip wheel animations - if over water @@ -584,7 +549,7 @@ void W3DTruckDraw::doDrawModule(const Matrix3D* transformMtx) Bool wasPowersliding = m_isPowersliding; m_isPowersliding = false; if (physics->isMotive() && !obj->isSignificantlyAboveTerrain()) { - enableEmitters(true); + enableWheelEmitters(true); Coord3D accel = *physics->getAcceleration(); accel.z = 0; // ignore gravitational force. Bool accelerating = accel.length()>ACCEL_THRESHOLD; @@ -595,43 +560,38 @@ void W3DTruckDraw::doDrawModule(const Matrix3D* transformMtx) accelerating = false; // decelerating, actually. } } - if (m_dustEffect) { + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[DustEffect])) { // Need more dust the faster we go. if (speed>SIZE_CAP) { speed = SIZE_CAP; } - m_dustEffect->setSizeMultiplier(speed); - } - if (m_dirtEffect) { if (wheelInfo && wheelInfo->m_framesAirborne>3) { Real factor = 1 + wheelInfo->m_framesAirborne/16; if (factor>2.0) factor = 2.0; - m_dustEffect->setSizeMultiplier(factor*SIZE_CAP); - m_dustEffect->trigger(); + particleSys->setSizeMultiplier(factor*SIZE_CAP); + particleSys->trigger(); m_landingSound.setObjectID(obj->getID()); TheAudio->addAudioEvent(&m_landingSound); } else { - if (!accelerating || speed>2.0f) { - m_dirtEffect->stop(); - } + particleSys->setSizeMultiplier(speed); } } - if (m_powerslideEffect) { + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[PowerslideEffect])) { if (physics->getTurning() == TURN_NONE) { - m_powerslideEffect->stop(); + particleSys->stop(); } else { m_isPowersliding = true; - m_powerslideEffect->start(); + particleSys->start(); } } - if (m_dirtEffect) { - if (!accelerating || speed>2.0f) { - m_dirtEffect->stop(); + if (ParticleSystem *particleSys = TheParticleSystemManager->findParticleSystem(m_truckEffectIDs[DirtEffect])) { + if (!accelerating) { + particleSys->stop(); } } } else - enableEmitters(false); + enableWheelEmitters(false); m_wasAirborne = obj->isSignificantlyAboveTerrain(); @@ -685,7 +645,7 @@ void W3DTruckDraw::loadPostProcess( void ) // extend base class W3DModelDraw::loadPostProcess(); - // toss any existing ones (no need to re-create; we'll do that on demand) - tossEmitters(); + // toss any existing wheel emitters (no need to re-create; we'll do that on demand) + tossWheelEmitters(); } diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp index 7f4ebc785ea..e3f3902c59b 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/FlatHeightMap.cpp @@ -45,6 +45,7 @@ //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- + #include "W3DDevice/GameClient/FlatHeightMap.h" #include @@ -90,7 +91,7 @@ #include "Common/UnitTimings.h" //Contains the DO_UNIT_TIMINGS define jba. -FlatHeightMapRenderObjClass *TheFlatHeightMap = NULL; +FlatHeightMapRenderObjClass *TheFlatHeightMap = nullptr; //----------------------------------------------------------------------------- // Private Data @@ -142,7 +143,7 @@ Int FlatHeightMapRenderObjClass::freeMapResources(void) FlatHeightMapRenderObjClass::~FlatHeightMapRenderObjClass(void) { releaseTiles(); - TheFlatHeightMap = NULL; + TheFlatHeightMap = nullptr; } //============================================================================= @@ -151,7 +152,7 @@ FlatHeightMapRenderObjClass::~FlatHeightMapRenderObjClass(void) /** Constructor. Mostly nulls out the member variables. */ //============================================================================= FlatHeightMapRenderObjClass::FlatHeightMapRenderObjClass(void): -m_tiles(NULL), +m_tiles(nullptr), m_tilesWidth(0), m_tilesHeight(0), m_numTiles(0), @@ -273,7 +274,7 @@ void FlatHeightMapRenderObjClass::doPartialUpdate(const IRegion2D &partialRange, void FlatHeightMapRenderObjClass::releaseTiles(void) { delete [] m_tiles; - m_tiles = NULL; + m_tiles = nullptr; m_tilesWidth = 0; m_tilesHeight = 0; @@ -377,7 +378,7 @@ void FlatHeightMapRenderObjClass::On_Frame_Update(void) void FlatHeightMapRenderObjClass::staticLightingChanged( void ) { BaseHeightMapRenderObjClass::staticLightingChanged(); - if (m_map==NULL) { + if (m_map==nullptr) { return; } Int i, j; @@ -487,8 +488,8 @@ void FlatHeightMapRenderObjClass::Render(RenderInfoClass & rinfo) // Force shaders to update. m_stageTwoTexture->restore(); - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); ShaderClass::Invalidate(); // tm.Scale(ObjSpaceExtent); @@ -530,7 +531,7 @@ void FlatHeightMapRenderObjClass::Render(RenderInfoClass & rinfo) W3DShaderManager::setTexture(0,TheTerrainRenderObject->getShroud()->getShroudTexture()); } - W3DShaderManager::setTexture(1,NULL); // Set by the tile later. [3/31/2003] + W3DShaderManager::setTexture(1,nullptr); // Set by the tile later. [3/31/2003] W3DShaderManager::setTexture(2,m_stageTwoTexture); //cloud W3DShaderManager::setTexture(3,m_stageThreeTexture);//noise //Disable writes to destination alpha channel (if there is one) @@ -547,7 +548,7 @@ void FlatHeightMapRenderObjClass::Render(RenderInfoClass & rinfo) Bool disableTex = m_disableTextures; if (m_disableTextures ) { DX8Wrapper::Set_Shader(ShaderClass::_PresetOpaque2DShader); - DX8Wrapper::Set_Texture(0,NULL); + DX8Wrapper::Set_Texture(0,nullptr); } else { W3DShaderManager::setShader(st, pass); } @@ -586,8 +587,8 @@ void FlatHeightMapRenderObjClass::Render(RenderInfoClass & rinfo) renderShoreLines(&rinfo.Camera); #ifdef DO_ROADS - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); m_stageTwoTexture->restore(); ShaderClass::Invalidate(); @@ -596,15 +597,15 @@ void FlatHeightMapRenderObjClass::Render(RenderInfoClass & rinfo) if (Scene) { RTS3DScene *pMyScene = (RTS3DScene *)Scene; RefRenderObjListIterator pDynamicLightsIterator(pMyScene->getDynamicLights()); - m_roadBuffer->drawRoads(&rinfo.Camera, doCloud?m_stageTwoTexture:NULL, TheGlobalData->m_useLightMap?m_stageThreeTexture:NULL, + m_roadBuffer->drawRoads(&rinfo.Camera, doCloud?m_stageTwoTexture:nullptr, TheGlobalData->m_useLightMap?m_stageThreeTexture:nullptr, m_disableTextures,xCoordMin-m_map->getBorderSizeInline(), xCoordMax-m_map->getBorderSizeInline(), yCoordMin-m_map->getBorderSizeInline(), yCoordMax-m_map->getBorderSizeInline(), &pDynamicLightsIterator); } } #endif #ifdef DO_SCORCH - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); m_stageTwoTexture->restore(); ShaderClass::Invalidate(); @@ -612,8 +613,8 @@ void FlatHeightMapRenderObjClass::Render(RenderInfoClass & rinfo) drawScorches(); } #endif - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); m_stageTwoTexture->restore(); ShaderClass::Invalidate(); DX8Wrapper::Apply_Render_State_Changes(); @@ -631,11 +632,11 @@ void FlatHeightMapRenderObjClass::Render(RenderInfoClass & rinfo) m_bibBuffer->renderBibs(); #endif // We do some custom blending, so tell the shader class to reset everything. - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); m_stageTwoTexture->restore(); ShaderClass::Invalidate(); - DX8Wrapper::Set_Material(NULL); + DX8Wrapper::Set_Material(nullptr); } diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp index 62cb4accf1c..3c709138360 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/HeightMap.cpp @@ -95,9 +95,7 @@ #define no_OPTIMIZED_HEIGHTMAP_LIGHTING 01 // Doesn't work well. jba. -const Bool HALF_RES_MESH = false; - -HeightMapRenderObjClass *TheHeightMap = NULL; +HeightMapRenderObjClass *TheHeightMap = nullptr; //----------------------------------------------------------------------------- // Private Data //----------------------------------------------------------------------------- @@ -127,20 +125,18 @@ inline Int IABS(Int x) { if (x>=0) return x; return -x;}; void HeightMapRenderObjClass::freeIndexVertexBuffers(void) { REF_PTR_RELEASE(m_indexBuffer); + if (m_vertexBufferTiles) { for (int i=0; i= m_x-1) x-=m_x-1; -#ifdef RTS_DEBUG - DEBUG_ASSERTCRASH (x>=0, ("X out of range.")); - DEBUG_ASSERTCRASH (x= m_x-1) x=m_x-1; + if (x < 0) x += xMax; + if (x >= xMax) x -= xMax; + if (x < 0) { DEBUG_CRASH(("X out of range.")); x = 0; } + if (x >= xMax) { DEBUG_CRASH(("X out of range.")); x = xMax; } return x; } @@ -280,15 +285,12 @@ is confusing, but it makes sliding the map 10x faster. */ //============================================================================= Int HeightMapRenderObjClass::getYWithOrigin(Int y) { + const Int yMax = m_y-1; y -= m_originY; - if (y<0) y+= m_y-1; - if (y>= m_y-1) y-=m_y-1; -#ifdef RTS_DEBUG - DEBUG_ASSERTCRASH (y>=0, ("Y out of range.")); - DEBUG_ASSERTCRASH (y= m_y-1) y=m_y-1; + if (y < 0) y += yMax; + if (y >= yMax) y -= yMax; + if (y < 0) { DEBUG_CRASH(("Y out of range.")); y = 0; } + if (y >= yMax) { DEBUG_CRASH(("Y out of range.")); y = yMax; } return y; } @@ -300,7 +302,7 @@ data is expected to be an array same dimensions as current heightmap mapped into this VB. */ //============================================================================= -Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, WorldHeightMap *pMap, RefRenderObjListIterator *pLightsIterator) +Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, VERTEX_FORMAT *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, WorldHeightMap *pMap, RefRenderObjListIterator *pLightsIterator) { Int i,j; Vector3 lightRay[MAX_GLOBAL_LIGHTS]; @@ -308,12 +310,8 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int Int xCoord, yCoord; Int vn0,un0,vp1,up1; Vector3 l2r,n2f,normalAtTexel; - Int vertsPerRow=(VERTEX_BUFFER_TILE_LENGTH)*4; //vertices per row of VB - - Int cellOffset = 1; - if (HALF_RES_MESH) { - cellOffset = 2; - } + constexpr const Int vertsPerRow=(VERTEX_BUFFER_TILE_LENGTH)*4; //vertices per row of VB + constexpr const Int cellOffset = 1; REF_PTR_SET(m_map, pMap); //update our heightmap pointer in case it changed since last call. if (m_vertexBufferTiles && pMap) @@ -324,7 +322,7 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int DX8VertexBufferClass::WriteLockClass lockVtxBuffer(pVB); VERTEX_FORMAT *vbHardware = (VERTEX_FORMAT*)lockVtxBuffer.Get_Vertex_Array(); - VERTEX_FORMAT *vBase = (VERTEX_FORMAT*)data; + VERTEX_FORMAT *vBase = data; // Note that we are building the vertex buffer data in the memory buffer, data. // At the bottom, we will copy the final vertex data for one cell into the // hardware vertex buffer. @@ -332,34 +330,28 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int for (j=y0; jgetDrawOrgY()) vn0=-pMap->getDrawOrgY(); vp1 = getYWithOrigin(j+cellOffset)+cellOffset; if (vp1 >= pMap->getYExtent()-pMap->getDrawOrgY()) vp1=pMap->getYExtent()-pMap->getDrawOrgY()-1; - yCoord = getYWithOrigin(j)+pMap->getDrawOrgY(); + yCoord = mapY+pMap->getDrawOrgY(); for (i=x0; igetDrawOrgX()) un0=-pMap->getDrawOrgX(); up1 = getXWithOrigin(i+cellOffset)+cellOffset; if (up1 >= pMap->getXExtent()-pMap->getDrawOrgX()) up1=pMap->getXExtent()-pMap->getDrawOrgX()-1; - xCoord = getXWithOrigin(i)+pMap->getDrawOrgX(); + xCoord = mapX+pMap->getDrawOrgX(); //update the 4 vertices in this block float U[4], V[4]; @@ -367,11 +359,8 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int float UA[4], VA[4]; Bool flipForBlend = false; // True if the blend needs the triangles flipped. - if (pMap) { - pMap->getUVData(getXWithOrigin(i),getYWithOrigin(j),U, V, HALF_RES_MESH); - pMap->getAlphaUVData(getXWithOrigin(i),getYWithOrigin(j), UA, VA, alpha, &flipForBlend, HALF_RES_MESH); - } - + pMap->getUVData(mapX, mapY, U, V); + pMap->getAlphaUVData(mapX, mapY, UA, VA, alpha, &flipForBlend); for (Int lightIndex=0; lightIndex < TheGlobalData->m_numGlobalLights; lightIndex++) { @@ -380,8 +369,8 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int } //top-left sample - l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(getXWithOrigin(i)+cellOffset, getYWithOrigin(j)) - pMap->getDisplayHeight(un0, getYWithOrigin(j)))); - n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(getXWithOrigin(i), (getYWithOrigin(j)+cellOffset)) - pMap->getDisplayHeight(getXWithOrigin(i), vn0))); + l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(mapX+cellOffset, mapY) - pMap->getDisplayHeight(un0, mapY))); + n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(mapX, (mapY+cellOffset)) - pMap->getDisplayHeight(mapX, vn0))); #ifdef ALLOW_TEMPORARIES normalAtTexel= Normalize(Vector3::Cross_Product(l2r,n2f)); @@ -391,7 +380,7 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int vb->x=xCoord; vb->y=yCoord; - vb->z= ((float)pMap->getDisplayHeight(getXWithOrigin(i), getYWithOrigin(j)))*MAP_HEIGHT_SCALE; + vb->z= ((float)pMap->getDisplayHeight(mapX, mapY))*MAP_HEIGHT_SCALE; vb->x = ADJUST_FROM_INDEX_TO_REAL(vb->x); vb->y = ADJUST_FROM_INDEX_TO_REAL(vb->y); vb->u1=U[0]; @@ -402,8 +391,8 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int vb++; //top-right sample - l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(up1 , getYWithOrigin(j) ) - pMap->getDisplayHeight(getXWithOrigin(i) , getYWithOrigin(j) ))); - n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(getXWithOrigin(i)+cellOffset , (getYWithOrigin(j)+cellOffset) ) - pMap->getDisplayHeight(getXWithOrigin(i)+cellOffset , vn0 ))); + l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(up1 , mapY ) - pMap->getDisplayHeight(mapX , mapY ))); + n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(mapX+cellOffset , (mapY+cellOffset) ) - pMap->getDisplayHeight(mapX+cellOffset , vn0 ))); #ifdef ALLOW_TEMPORARIES normalAtTexel= Normalize(Vector3::Cross_Product(l2r,n2f)); @@ -413,7 +402,7 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int vb->x=xCoord+cellOffset; vb->y=yCoord; - vb->z= ((float)pMap->getDisplayHeight(getXWithOrigin(i)+cellOffset, getYWithOrigin(j)))*MAP_HEIGHT_SCALE; + vb->z= ((float)pMap->getDisplayHeight(mapX+cellOffset, mapY))*MAP_HEIGHT_SCALE; vb->x = ADJUST_FROM_INDEX_TO_REAL(vb->x); vb->y = ADJUST_FROM_INDEX_TO_REAL(vb->y); vb->u1=U[1]; @@ -424,8 +413,8 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int vb++; //bottom-right sample - l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(up1 , (getYWithOrigin(j)+cellOffset) ) - pMap->getDisplayHeight(getXWithOrigin(i) , (getYWithOrigin(j)+cellOffset) ))); - n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(getXWithOrigin(i)+cellOffset , vp1 ) - pMap->getDisplayHeight(getXWithOrigin(i)+cellOffset , getYWithOrigin(j) ))); + l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(up1 , (mapY+cellOffset) ) - pMap->getDisplayHeight(mapX , (mapY+cellOffset) ))); + n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(mapX+cellOffset , vp1 ) - pMap->getDisplayHeight(mapX+cellOffset , mapY ))); #ifdef ALLOW_TEMPORARIES normalAtTexel= Normalize(Vector3::Cross_Product(l2r,n2f)); @@ -439,7 +428,7 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int } else { vb->y=yCoord+cellOffset; } - vb->z= ((float)pMap->getDisplayHeight(getXWithOrigin(i)+cellOffset, getYWithOrigin(j)+cellOffset))*MAP_HEIGHT_SCALE; + vb->z= ((float)pMap->getDisplayHeight(mapX+cellOffset, mapY+cellOffset))*MAP_HEIGHT_SCALE; vb->x = ADJUST_FROM_INDEX_TO_REAL(vb->x); vb->y = ADJUST_FROM_INDEX_TO_REAL(vb->y); vb->u1=U[2]; @@ -450,8 +439,8 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int vb++; //bottom-left sample - l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(getXWithOrigin(i)+cellOffset , (getYWithOrigin(j)+cellOffset) ) - pMap->getDisplayHeight(un0 , (getYWithOrigin(j)+cellOffset) ))); - n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(getXWithOrigin(i) , vp1 ) - pMap->getDisplayHeight(getXWithOrigin(i) , getYWithOrigin(j) ))); + l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(mapX+cellOffset , (mapY+cellOffset) ) - pMap->getDisplayHeight(un0 , (mapY+cellOffset) ))); + n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(pMap->getDisplayHeight(mapX , vp1 ) - pMap->getDisplayHeight(mapX , mapY ))); #ifdef ALLOW_TEMPORARIES normalAtTexel= Normalize(Vector3::Cross_Product(l2r,n2f)); @@ -470,7 +459,7 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int } else { vb->y=yCoord+cellOffset; } - vb->z= ((float)pMap->getDisplayHeight(getXWithOrigin(i), getYWithOrigin(j)+cellOffset))*MAP_HEIGHT_SCALE; + vb->z= ((float)pMap->getDisplayHeight(mapX, mapY+cellOffset))*MAP_HEIGHT_SCALE; vb->x = ADJUST_FROM_INDEX_TO_REAL(vb->x); vb->y = ADJUST_FROM_INDEX_TO_REAL(vb->y); vb->u1=U[3]; @@ -498,15 +487,14 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int Real borderHiX = (pMap->getXExtent()-2*pMap->getBorderSizeInline())*MAP_XY_FACTOR; Real borderHiY = (pMap->getYExtent()-2*pMap->getBorderSizeInline())*MAP_XY_FACTOR; Bool border = pCurVertices[0].x == -MAP_XY_FACTOR || pCurVertices[0].y == -MAP_XY_FACTOR; - Bool cliffMapped = pMap->isCliffMappedTexture(getXWithOrigin(i), getYWithOrigin(j)); + Bool cliffMapped = pMap->isCliffMappedTexture(mapX, mapY); if (pCurVertices[0].x == borderHiX) { border = true; } if (pCurVertices[0].y == borderHiY) { border = true; } - Bool isCliff = pMap->getCliffState(getXWithOrigin(i)+pMap->getDrawOrgX(), getYWithOrigin(j)+pMap->getDrawOrgY()) - || showAsVisibleCliff(getXWithOrigin(i) + pMap->getDrawOrgX(), getYWithOrigin(j)+pMap->getDrawOrgY()); + Bool isCliff = pMap->getCliffState(xCoord, yCoord) || showAsVisibleCliff(xCoord, yCoord); if ( isCliff || border || cliffMapped) { Int cellX, cellY; @@ -559,7 +547,7 @@ Int HeightMapRenderObjClass::updateVB(DX8VertexBufferClass *pVB, char *data, Int /** Update the dynamic lighting values only in a rectangular block of the given Vertex Buffer. The vertex locations and texture coords are unchanged. */ -Int HeightMapRenderObjClass::updateVBForLight(DX8VertexBufferClass *pVB, char *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, W3DDynamicLight *pLights[], Int numLights) +Int HeightMapRenderObjClass::updateVBForLight(DX8VertexBufferClass *pVB, VERTEX_FORMAT *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, W3DDynamicLight *pLights[], Int numLights) { #if (OPTIMIZED_HEIGHTMAP_LIGHTING) // (gth) if optimizations are enabled, jump over to the "optimized" version of this function. @@ -569,7 +557,7 @@ Int HeightMapRenderObjClass::updateVBForLight(DX8VertexBufferClass *pVB, char *d Int i,j,k; Int vn0,un0,vp1,up1; Vector3 l2r,n2f,normalAtTexel; - Int vertsPerRow=(VERTEX_BUFFER_TILE_LENGTH)*4; //vertices per row of VB + constexpr const Int vertsPerRow=(VERTEX_BUFFER_TILE_LENGTH)*4; //vertices per row of VB if (m_vertexBufferTiles && m_map) { @@ -583,10 +571,8 @@ Int HeightMapRenderObjClass::updateVBForLight(DX8VertexBufferClass *pVB, char *d for (j=y0; jgetDrawOrgY()-m_map->getBorderSizeInline(); + const Int mapY = getYWithOrigin(j); + const Int yCoord = mapY+m_map->getDrawOrgY()-m_map->getBorderSizeInline(); Bool intersect = false; for (k=0; km_minY <= yCoord+1 && @@ -601,7 +587,7 @@ Int HeightMapRenderObjClass::updateVBForLight(DX8VertexBufferClass *pVB, char *d if (!intersect) { continue; } - vn0 = getYWithOrigin(j)-1; + vn0 = mapY-1; if (vn0 < -m_map->getDrawOrgY()) vn0=-m_map->getDrawOrgY(); vp1 = getYWithOrigin(j+1)+1; @@ -610,10 +596,8 @@ Int HeightMapRenderObjClass::updateVBForLight(DX8VertexBufferClass *pVB, char *d for (i=x0; igetDrawOrgX()-m_map->getBorderSizeInline(); + const Int mapX = getXWithOrigin(i); + const Int xCoord = mapX+m_map->getDrawOrgX()-m_map->getBorderSizeInline(); Bool intersect = false; for (k=0; km_minX <= xCoord+1 && @@ -634,16 +618,13 @@ Int HeightMapRenderObjClass::updateVBForLight(DX8VertexBufferClass *pVB, char *d } // vb is the pointer to the vertex in the hardware dx8 vertex buffer. Int offset = (j-originY)*vertsPerRow+4*(i-originX); - if (HALF_RES_MESH) { - offset = (j-originY)*vertsPerRow/4+2*(i-originX); - } vb = vBase + offset; //skip to correct row in vertex buffer // vbMirror is the pointer to the vertex in our memory based copy. // The important point is that we can read out of our copy to get the original // diffuse color, and xyz location. It is VERY SLOW to read out of the // hardware vertex buffer, possibly worse... jba. - VERTEX_FORMAT *vbMirror = ((VERTEX_FORMAT*)data) + offset; - un0 = getXWithOrigin(i)-1; + VERTEX_FORMAT *vbMirror = data + offset; + un0 = mapX-1; if (un0 < -m_map->getDrawOrgX()) un0=-m_map->getDrawOrgX(); up1 = getXWithOrigin(i+1)+1; @@ -653,8 +634,8 @@ Int HeightMapRenderObjClass::updateVBForLight(DX8VertexBufferClass *pVB, char *d Vector3 lightRay(0,0,0); //top-left sample - l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(getXWithOrigin(i)+1, getYWithOrigin(j)) - m_map->getDisplayHeight(un0, getYWithOrigin(j)))); - n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(getXWithOrigin(i), (getYWithOrigin(j)+1)) - m_map->getDisplayHeight(getXWithOrigin(i), vn0))); + l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(mapX+1, mapY) - m_map->getDisplayHeight(un0, mapY))); + n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(mapX, (mapY+1)) - m_map->getDisplayHeight(mapX, vn0))); #ifdef ALLOW_TEMPORARIES normalAtTexel= Normalize(Vector3::Cross_Product(l2r,n2f)); @@ -666,8 +647,8 @@ Int HeightMapRenderObjClass::updateVBForLight(DX8VertexBufferClass *pVB, char *d vb++; vbMirror++; //top-right sample - l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(up1 , getYWithOrigin(j) ) - m_map->getDisplayHeight(getXWithOrigin(i) , getYWithOrigin(j) ))); - n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(getXWithOrigin(i)+1 , (getYWithOrigin(j)+1) ) - m_map->getDisplayHeight(getXWithOrigin(i)+1 , vn0 ))); + l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(up1 , mapY ) - m_map->getDisplayHeight(mapX , mapY ))); + n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(mapX+1 , (mapY+1) ) - m_map->getDisplayHeight(mapX+1 , vn0 ))); #ifdef ALLOW_TEMPORARIES normalAtTexel= Normalize(Vector3::Cross_Product(l2r,n2f)); @@ -679,8 +660,8 @@ Int HeightMapRenderObjClass::updateVBForLight(DX8VertexBufferClass *pVB, char *d vb++; vbMirror++; //bottom-right sample - l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(up1 , (getYWithOrigin(j)+1) ) - m_map->getDisplayHeight(getXWithOrigin(i) , (getYWithOrigin(j)+1) ))); - n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(getXWithOrigin(i)+1 , vp1 ) - m_map->getDisplayHeight(getXWithOrigin(i)+1 , getYWithOrigin(j) ))); + l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(up1 , (mapY+1) ) - m_map->getDisplayHeight(mapX , (mapY+1) ))); + n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(mapX+1 , vp1 ) - m_map->getDisplayHeight(mapX+1 , mapY ))); #ifdef ALLOW_TEMPORARIES normalAtTexel= Normalize(Vector3::Cross_Product(l2r,n2f)); @@ -692,8 +673,8 @@ Int HeightMapRenderObjClass::updateVBForLight(DX8VertexBufferClass *pVB, char *d vb++; vbMirror++; //bottom-left sample - l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(getXWithOrigin(i)+1 , (getYWithOrigin(j)+1) ) - m_map->getDisplayHeight(un0 , (getYWithOrigin(j)+1) ))); - n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(getXWithOrigin(i) , vp1 ) - m_map->getDisplayHeight(getXWithOrigin(i) , getYWithOrigin(j) ))); + l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(mapX+1 , (mapY+1) ) - m_map->getDisplayHeight(un0 , (mapY+1) ))); + n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(mapX , vp1 ) - m_map->getDisplayHeight(mapX , mapY ))); #ifdef ALLOW_TEMPORARIES normalAtTexel= Normalize(Vector3::Cross_Product(l2r,n2f)); @@ -711,12 +692,12 @@ Int HeightMapRenderObjClass::updateVBForLight(DX8VertexBufferClass *pVB, char *d } -Int HeightMapRenderObjClass::updateVBForLightOptimized(DX8VertexBufferClass *pVB, char *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, W3DDynamicLight *pLights[], Int numLights) +Int HeightMapRenderObjClass::updateVBForLightOptimized(DX8VertexBufferClass *pVB, VERTEX_FORMAT *data, Int x0, Int y0, Int x1, Int y1, Int originX, Int originY, W3DDynamicLight *pLights[], Int numLights) { Int i,j,k; Int vn0,un0,vp1,up1; Vector3 l2r,n2f,normalAtTexel; - Int vertsPerRow=(VERTEX_BUFFER_TILE_LENGTH)*4; //vertices per row of VB + constexpr const Int vertsPerRow=(VERTEX_BUFFER_TILE_LENGTH)*4; //vertices per row of VB if (m_vertexBufferTiles && m_map) { @@ -735,22 +716,9 @@ Int HeightMapRenderObjClass::updateVBForLightOptimized(DX8VertexBufferClass *pVB // the formula's that Generals is using but in the case of the "half-res-mesh" I'm not // sure things are correct... // - Int quad_right_offset; - Int quad_below_offset; - Int quad_below_right_offset; - - if (HALF_RES_MESH == false) { - // offset = (j-originY)*vertsPerRow+4*(i-originX); - quad_right_offset = 4; - quad_below_offset = vertsPerRow; - quad_below_right_offset = vertsPerRow + 4; - - } else { - // offset = (j-originY)*vertsPerRow/4+2*(i-originX); - quad_right_offset = 2; - quad_below_offset = vertsPerRow/4; - quad_below_right_offset = vertsPerRow/4 + 2; - } + constexpr const Int quad_right_offset = 4; + constexpr const Int quad_below_offset = vertsPerRow; + //constexpr const Int quad_below_right_offset = vertsPerRow + 4; // // i,j loop over the quads affected by the light. Each quad has its *own* 4 vertices. This @@ -758,10 +726,8 @@ Int HeightMapRenderObjClass::updateVBForLightOptimized(DX8VertexBufferClass *pVB // for (j=y0; jgetDrawOrgY()-m_map->getBorderSizeInline(); + const Int mapY = getYWithOrigin(j); + const Int yCoord = mapY+m_map->getDrawOrgY()-m_map->getBorderSizeInline(); Bool intersect = false; for (k=0; km_minY <= yCoord+1 && @@ -776,7 +742,7 @@ Int HeightMapRenderObjClass::updateVBForLightOptimized(DX8VertexBufferClass *pVB if (!intersect) { continue; } - vn0 = getYWithOrigin(j)-1; + vn0 = mapY-1; if (vn0 < -m_map->getDrawOrgY()) vn0=-m_map->getDrawOrgY(); vp1 = getYWithOrigin(j+1)+1; @@ -785,10 +751,8 @@ Int HeightMapRenderObjClass::updateVBForLightOptimized(DX8VertexBufferClass *pVB for (i=x0; igetDrawOrgX()-m_map->getBorderSizeInline(); + const Int mapX = getXWithOrigin(i); + const Int xCoord = mapX+m_map->getDrawOrgX()-m_map->getBorderSizeInline(); Bool intersect = false; for (k=0; km_minX <= xCoord+1 && @@ -809,17 +773,14 @@ Int HeightMapRenderObjClass::updateVBForLightOptimized(DX8VertexBufferClass *pVB } // vb is the pointer to the vertex in the hardware dx8 vertex buffer. Int offset = (j-originY)*vertsPerRow+4*(i-originX); - if (HALF_RES_MESH) { - offset = (j-originY)*vertsPerRow/4+2*(i-originX); - } vb = vBase + offset; //skip to correct row in vertex buffer // vbMirror is the pointer to the vertex in our memory based copy. // The important point is that we can read out of our copy to get the original // diffuse color, and xyz location. It is VERY SLOW to read out of the // hardware vertex buffer, possibly worse... jba. - VERTEX_FORMAT *vbMirror = ((VERTEX_FORMAT*)data) + offset; - VERTEX_FORMAT *vbaseMirror = ((VERTEX_FORMAT*)data); - un0 = getXWithOrigin(i)-1; + VERTEX_FORMAT *vbMirror = data + offset; + VERTEX_FORMAT *vbaseMirror = data; + un0 = mapX-1; if (un0 < -m_map->getDrawOrgX()) un0=-m_map->getDrawOrgX(); up1 = getXWithOrigin(i+1)+1; @@ -839,8 +800,8 @@ Int HeightMapRenderObjClass::updateVBForLightOptimized(DX8VertexBufferClass *pVB // top-left sample -> only compute when i==0 and j==0 if ((i==x0) && (j==y0)) { - l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(getXWithOrigin(i)+1, getYWithOrigin(j)) - m_map->getDisplayHeight(un0, getYWithOrigin(j)))); - n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(getXWithOrigin(i), (getYWithOrigin(j)+1)) - m_map->getDisplayHeight(getXWithOrigin(i), vn0))); + l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(mapX+1, mapY) - m_map->getDisplayHeight(un0, mapY))); + n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(mapX, (mapY+1)) - m_map->getDisplayHeight(mapX, vn0))); Vector3::Normalized_Cross_Product(l2r, n2f, &normalAtTexel); doTheDynamicLight(vb, vbMirror, &lightRay, &normalAtTexel, pLights, numLights); } @@ -848,8 +809,8 @@ Int HeightMapRenderObjClass::updateVBForLightOptimized(DX8VertexBufferClass *pVB //top-right sample -> compute when j==0, then copy to (right,0) if (j==y0) { - l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(up1 , getYWithOrigin(j) ) - m_map->getDisplayHeight(getXWithOrigin(i) , getYWithOrigin(j) ))); - n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(getXWithOrigin(i)+1 , (getYWithOrigin(j)+1) ) - m_map->getDisplayHeight(getXWithOrigin(i)+1 , vn0 ))); + l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(up1 , mapY ) - m_map->getDisplayHeight(mapX , mapY ))); + n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(mapX+1 , (mapY+1) ) - m_map->getDisplayHeight(mapX+1 , vn0 ))); Vector3::Normalized_Cross_Product(l2r, n2f, &normalAtTexel); light_copy = doTheDynamicLight(vb, vbMirror, &lightRay, &normalAtTexel, pLights, numLights); @@ -861,8 +822,8 @@ Int HeightMapRenderObjClass::updateVBForLightOptimized(DX8VertexBufferClass *pVB vb++; vbMirror++; //bottom-right sample -> always compute, then copy to (right,3), (down,1), (down+right,0) - l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(up1 , (getYWithOrigin(j)+1) ) - m_map->getDisplayHeight(getXWithOrigin(i) , (getYWithOrigin(j)+1) ))); - n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(getXWithOrigin(i)+1 , vp1 ) - m_map->getDisplayHeight(getXWithOrigin(i)+1 , getYWithOrigin(j) ))); + l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(up1 , (mapY+1) ) - m_map->getDisplayHeight(mapX , (mapY+1) ))); + n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(mapX+1 , vp1 ) - m_map->getDisplayHeight(mapX+1 , mapY ))); Vector3::Normalized_Cross_Product(l2r, n2f, &normalAtTexel); light_copy = doTheDynamicLight(vb, vbMirror, &lightRay, &normalAtTexel, pLights, numLights); @@ -885,8 +846,8 @@ Int HeightMapRenderObjClass::updateVBForLightOptimized(DX8VertexBufferClass *pVB //bottom-left sample -> compute when i==0, otherwise copy from (left,2) if (i==x0) { - l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(getXWithOrigin(i)+1 , (getYWithOrigin(j)+1) ) - m_map->getDisplayHeight(un0 , (getYWithOrigin(j)+1) ))); - n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(getXWithOrigin(i) , vp1 ) - m_map->getDisplayHeight(getXWithOrigin(i) , getYWithOrigin(j) ))); + l2r.Set(2*MAP_XY_FACTOR,0,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(mapX+1 , (mapY+1) ) - m_map->getDisplayHeight(un0 , (mapY+1) ))); + n2f.Set(0,2*MAP_XY_FACTOR,MAP_HEIGHT_SCALE*(m_map->getDisplayHeight(mapX , vp1 ) - m_map->getDisplayHeight(mapX , mapY ))); Vector3::Normalized_Cross_Product(l2r, n2f, &normalAtTexel); light_copy = doTheDynamicLight(vb, vbMirror, &lightRay, &normalAtTexel, pLights, numLights); @@ -1016,13 +977,12 @@ Int HeightMapRenderObjClass::updateBlock(Int x0, Int y0, Int x1, Int y1, WorldH DEBUG_ASSERTCRASH(y0<=y1, ("HeightMapRenderObjClass::UpdateBlock parameters have inside-out rectangle (on Y).")); #endif Invalidate_Cached_Bounding_Volumes(); - if (pMap && m_treeBuffer != NULL) { + if (pMap && m_treeBuffer != nullptr) { REF_PTR_SET(m_stageZeroTexture, pMap->getTerrainTexture()); REF_PTR_SET(m_stageOneTexture, pMap->getAlphaTerrainTexture()); } Int i,j; - DX8VertexBufferClass **pVB; Int originX,originY; //step through each vertex buffer that needs updating for (j=0; j= xMax) { continue; } - pVB=m_vertexBufferTiles+j*m_numVBTilesX+i; //point to correct row/column of vertex buffers - char **pData = m_vertexBufferBackup+j*m_numVBTilesX+i; - updateVB(*pVB, *pData, xMin, yMin, xMax, yMax, originX, originY, pMap, pLightsIterator); + DX8VertexBufferClass *pVB = getVertexBufferTile(i, j); + VERTEX_FORMAT *pData = getVertexBufferBackup(i, j); + updateVB(pVB, pData, xMin, yMin, xMax, yMax, originX, originY, pMap, pLightsIterator); } } @@ -1071,7 +1031,7 @@ HeightMapRenderObjClass::~HeightMapRenderObjClass(void) freeMapResources(); delete [] m_extraBlendTilePositions; - m_extraBlendTilePositions = NULL; + m_extraBlendTilePositions = nullptr; } //============================================================================= @@ -1080,15 +1040,15 @@ HeightMapRenderObjClass::~HeightMapRenderObjClass(void) /** Constructor. Mostly nulls out the member variables. */ //============================================================================= HeightMapRenderObjClass::HeightMapRenderObjClass(void): -m_extraBlendTilePositions(NULL), +m_extraBlendTilePositions(nullptr), m_numExtraBlendTiles(0), m_numVisibleExtraBlendTiles(0), m_extraBlendTilePositionsSize(0), -m_vertexBufferTiles(NULL), -m_vertexBufferBackup(NULL), +m_vertexBufferTiles(nullptr), +m_vertexBufferBackup(nullptr), m_originX(0), m_originY(0), -m_indexBuffer(NULL), +m_indexBuffer(nullptr), m_numVBTilesX(0), m_numVBTilesY(0), m_numVertexBufferTiles(0), @@ -1160,12 +1120,12 @@ void HeightMapRenderObjClass::adjustTerrainLOD(Int adj) TheWritableGlobalData->m_useHalfHeightMap = false; break; } - if (m_map==NULL) return; + if (m_map==nullptr) return; m_map->setDrawOrg(m_map->getDrawOrgX(), m_map->getDrawOrgX()); if (m_shroud) m_shroud->reset(); //need reset here since initHeightData will load new shroud. this->initHeightData(m_map->getDrawWidth(), - m_map->getDrawHeight(), m_map, NULL); + m_map->getDrawHeight(), m_map, nullptr); staticLightingChanged(); if (TheTacticalView) { TheTacticalView->setAngle(TheTacticalView->getAngle() + 1); @@ -1215,8 +1175,8 @@ void HeightMapRenderObjClass::oversizeTerrain(Int tilesToOversize) Int height = WorldHeightMap::NORMAL_DRAW_HEIGHT; if (tilesToOversize>0 && tilesToOversize<5) { - width += 32*tilesToOversize; - height += 32*tilesToOversize; + width += VERTEX_BUFFER_TILE_LENGTH * tilesToOversize; + height += VERTEX_BUFFER_TILE_LENGTH * tilesToOversize; if (width>m_map->getXExtent()) width = m_map->getXExtent(); if (height>m_map->getYExtent()) @@ -1238,8 +1198,8 @@ void HeightMapRenderObjClass::oversizeTerrain(Int tilesToOversize) if (m_shroud) m_shroud->reset(); //delete m_shroud; - //m_shroud = NULL; - initHeightData(m_map->getDrawWidth(), m_map->getDrawHeight(), m_map, NULL, FALSE); + //m_shroud = nullptr; + initHeightData(m_map->getDrawWidth(), m_map->getDrawHeight(), m_map, nullptr, FALSE); m_needFullUpdate = true; } @@ -1260,7 +1220,7 @@ Int HeightMapRenderObjClass::initHeightData(Int x, Int y, WorldHeightMap *pMap, // Int vertsPerRow=x*2-2; // Int vertsPerColumn=y*2-2; - HeightSampleType *data = NULL; + HeightSampleType *data = nullptr; if (pMap) { data = pMap->getDataPtr(); } @@ -1312,10 +1272,10 @@ Int HeightMapRenderObjClass::initHeightData(Int x, Int y, WorldHeightMap *pMap, // If the size changed, we need to allocate. Bool needToAllocate = (x != m_x || y != m_y); // If the textures aren't allocated (usually because of a hardware reset) need to allocate. - if (m_stageOneTexture == NULL) { + if (m_stageOneTexture == nullptr) { needToAllocate = true; } - if (data && needToAllocate && m_treeBuffer != NULL) + if (data && needToAllocate && m_treeBuffer != nullptr) { //requested heightmap different from old one. freeIndexVertexBuffers(); //Create static index buffers. These will index the vertex buffers holding the map. @@ -1342,8 +1302,7 @@ Int HeightMapRenderObjClass::initHeightData(Int x, Int y, WorldHeightMap *pMap, } //Get number of vertex buffers needed to hold current map - //First round dimensions to next multiple of VERTEX_BUFFER_TILE_LENGTH since that's our - //blocksize + //First round dimensions to next multiple of VERTEX_BUFFER_TILE_LENGTH since that's our block size m_numVBTilesX=1; for (i=VERTEX_BUFFER_TILE_LENGTH+1; igetDynamicLights()); - if (m_map == NULL) { + if (m_map == nullptr) { return; } @@ -1418,10 +1377,10 @@ void HeightMapRenderObjClass::On_Frame_Update(void) Int numDynaLights=0; W3DDynamicLight *enabledLights[MAX_ENABLED_DYNAMIC_LIGHTS]; - Int yCoordMin = m_map->getDrawOrgY(); - Int yCoordMax = m_y+m_map->getDrawOrgY(); - Int xCoordMin = m_map->getDrawOrgX(); - Int xCoordMax = m_x+m_map->getDrawOrgX(); + const Int xCoordMin = m_map->getDrawOrgX() - m_map->getBorderSizeInline(); + const Int yCoordMin = m_map->getDrawOrgY() - m_map->getBorderSizeInline(); + const Int xCoordMax = xCoordMin + m_map->getDrawWidth(); + const Int yCoordMax = yCoordMin + m_map->getDrawHeight(); for (pDynamicLightsIterator.First(); !pDynamicLightsIterator.Is_Done(); pDynamicLightsIterator.Next()) { @@ -1562,9 +1521,9 @@ void HeightMapRenderObjClass::On_Frame_Update(void) if (!intersect) { continue; } - pVB=m_vertexBufferTiles+j*m_numVBTilesX+i; //point to correct row/column of vertex buffers - char **pData = m_vertexBufferBackup+j*m_numVBTilesX+i; - updateVBForLight(*pVB, *pData, xMin, yMin, xMax, yMax, originX,originY, enabledLights, numDynaLights); + DX8VertexBufferClass *pVB = getVertexBufferTile(i, j); + VERTEX_FORMAT *pData = getVertexBufferBackup(i, j); + updateVBForLight(pVB, pData, xMin, yMin, xMax, yMax, originX,originY, enabledLights, numDynaLights); } } } @@ -1675,13 +1634,13 @@ is rendered. */ //============================================================================= void HeightMapRenderObjClass::updateCenter(CameraClass *camera , RefRenderObjListIterator *pLightsIterator) { - if (m_map==NULL) { + if (m_map==nullptr) { return; } if (m_updating) { return; } - if (m_vertexBufferTiles ==NULL) + if (m_vertexBufferTiles ==nullptr) return; //did not initialize resources yet. BaseHeightMapRenderObjClass::updateCenter(camera, pLightsIterator); @@ -1701,10 +1660,8 @@ void HeightMapRenderObjClass::updateCenter(CameraClass *camera , RefRenderObjLis return; // no need to center. } - Int cellOffset = 1; - if (HALF_RES_MESH) { - cellOffset = 2; - } + constexpr const Int cellOffset = 1; + // determine the ray corresponding to the camera and distance to projection plane Matrix3D camera_matrix = camera->Get_Transform(); @@ -1721,8 +1678,8 @@ void HeightMapRenderObjClass::updateCenter(CameraClass *camera , RefRenderObjLis Real intersectionZ; minHt = m_map->getMaxHeightValue(); - for (i=0; igetDisplayHeight(i,j); if (curgetDrawOrgX(); Int deltaY = newOrgY - m_map->getDrawOrgY(); if (IABS(deltaX) > m_x/2 || IABS(deltaY)>m_x/2) { @@ -1825,68 +1778,66 @@ void HeightMapRenderObjClass::updateCenter(CameraClass *camera , RefRenderObjLis return; } - if (abs(deltaX)>CENTER_LIMIT || abs(deltaY)>CENTER_LIMIT) { - if (abs(deltaY) >= CENTER_LIMIT) { - if (m_map->setDrawOrg(m_map->getDrawOrgX(), newOrgY)) { - Int minY = 0; - Int maxY = 0; - deltaY -= newOrgY - m_map->getDrawOrgY(); - m_originY += deltaY; - if (m_originY >= m_y-1) m_originY -= m_y-1; - if (deltaY<0) { - minY = m_originY; - maxY = m_originY-deltaY; - } else { - minY = m_originY - deltaY; - maxY = m_originY; - } - minY-=cellOffset; - if (m_originY < 0) m_originY += m_y-1; - if (minY<0) { - minY += m_y-1; - if (minY<0) minY = 0; - updateBlock(0, minY, m_x-1, m_y-1, m_map, pLightsIterator); - updateBlock(0, 0, m_x-1, maxY, m_map, pLightsIterator); - } else { - updateBlock(0, minY, m_x-1, maxY, m_map, pLightsIterator); - } + if (abs(deltaY) > CENTER_LIMIT) { + if (m_map->setDrawOrg(m_map->getDrawOrgX(), newOrgY)) { + Int minY = 0; + Int maxY = 0; + deltaY -= newOrgY - m_map->getDrawOrgY(); + m_originY += deltaY; + if (m_originY >= m_y-1) m_originY -= m_y-1; + if (deltaY<0) { + minY = m_originY; + maxY = m_originY-deltaY; + } else { + minY = m_originY - deltaY; + maxY = m_originY; } - // It is much more efficient to update a cople of columns one frame, and then - // a couple of rows. So if we aren't "jumping" to a new view, and have done X - // recently, return. - if (abs(deltaX) < BIG_JUMP && !m_doXNextTime) { - m_updating = false; - m_doXNextTime = true; - return; // Only do the y this frame. Do x next frame. jba. + minY-=cellOffset; + if (m_originY < 0) m_originY += m_y-1; + if (minY<0) { + minY += m_y-1; + if (minY<0) minY = 0; + updateBlock(0, minY, m_x-1, m_y-1, m_map, pLightsIterator); + updateBlock(0, 0, m_x-1, maxY, m_map, pLightsIterator); + } else { + updateBlock(0, minY, m_x-1, maxY, m_map, pLightsIterator); } } - if (abs(deltaX) > CENTER_LIMIT) { - m_doXNextTime = false; - newOrgX = m_map->getDrawOrgX() + deltaX; - if (m_map->setDrawOrg(newOrgX, m_map->getDrawOrgY())) { - Int minX = 0; - Int maxX = 0; - deltaX -= newOrgX - m_map->getDrawOrgX(); - m_originX += deltaX; - if (m_originX >= m_x-1) m_originX -= m_x-1; - if (deltaX<0) { - minX = m_originX; - maxX = m_originX-deltaX; - } else { - minX = m_originX - deltaX; - maxX = m_originX; - } - minX-=cellOffset; - maxX+=cellOffset; - if (m_originX < 0) m_originX += m_x-1; - if (minX<0) { - minX += m_x-1; - if (minX<0) minX = 0; - updateBlock(minX,0,m_x-1, m_y-1, m_map, pLightsIterator); - updateBlock(0,0,maxX, m_y-1, m_map, pLightsIterator); - } else { - updateBlock(minX,0,maxX, m_y-1, m_map, pLightsIterator); - } + // It is much more efficient to update a couple of columns one frame, and then + // a couple of rows. So if we aren't "jumping" to a new view, and have done X + // recently, return. + if (abs(deltaX) < BIG_JUMP && !m_doXNextTime) { + m_updating = false; + m_doXNextTime = true; + return; // Only do the y this frame. Do x next frame. jba. + } + } + if (abs(deltaX) > CENTER_LIMIT) { + m_doXNextTime = false; + newOrgX = m_map->getDrawOrgX() + deltaX; + if (m_map->setDrawOrg(newOrgX, m_map->getDrawOrgY())) { + Int minX = 0; + Int maxX = 0; + deltaX -= newOrgX - m_map->getDrawOrgX(); + m_originX += deltaX; + if (m_originX >= m_x-1) m_originX -= m_x-1; + if (deltaX<0) { + minX = m_originX; + maxX = m_originX-deltaX; + } else { + minX = m_originX - deltaX; + maxX = m_originX; + } + minX-=cellOffset; + maxX+=cellOffset; + if (m_originX < 0) m_originX += m_x-1; + if (minX<0) { + minX += m_x-1; + if (minX<0) minX = 0; + updateBlock(minX,0,m_x-1, m_y-1, m_map, pLightsIterator); + updateBlock(0,0,maxX, m_y-1, m_map, pLightsIterator); + } else { + updateBlock(minX,0,maxX, m_y-1, m_map, pLightsIterator); } } } @@ -1928,7 +1879,7 @@ void HeightMapRenderObjClass::Render(RenderInfoClass & rinfo) if (ndx>=m_numVertexBufferTiles) { ndx = 0; } - DX8VertexBufferClass::WriteLockClass lockVtxBuffer(m_vertexBufferTiles[ndx]); + DX8VertexBufferClass::WriteLockClass lockVtxBuffer(m_vertexBufferTiles + ndx); VERTEX_FORMAT *vb = (VERTEX_FORMAT*)lockVtxBuffer.Get_Vertex_Array(); vb = 0; } @@ -1954,8 +1905,8 @@ void HeightMapRenderObjClass::Render(RenderInfoClass & rinfo) // Force shaders to update. m_stageTwoTexture->restore(); - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); ShaderClass::Invalidate(); // tm.Scale(ObjSpaceExtent); @@ -2053,7 +2004,7 @@ void HeightMapRenderObjClass::Render(RenderInfoClass & rinfo) { if (m_disableTextures ) { DX8Wrapper::Set_Shader(ShaderClass::_PresetOpaque2DShader); - DX8Wrapper::Set_Texture(0,NULL); + DX8Wrapper::Set_Texture(0,nullptr); } else { W3DShaderManager::setShader(st, pass); } @@ -2062,15 +2013,7 @@ void HeightMapRenderObjClass::Render(RenderInfoClass & rinfo) for (j=0; jgetDrawOrgX()-1; #ifdef TEST_CUSTOM_EDGING // Draw edging just before last pass. - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); m_stageTwoTexture->restore(); m_customEdging->drawEdging(m_map, xCoordMin, xCoordMax, yCoordMin, yCoordMax, - m_stageZeroTexture, doCloud?m_stageTwoTexture:NULL, TheGlobalData->m_useLightMap?m_stageThreeTexture:NULL); + m_stageZeroTexture, doCloud?m_stageTwoTexture: nullptr, TheGlobalData->m_useLightMap?m_stageThreeTexture: nullptr); #endif #ifdef DO_ROADS - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); m_stageTwoTexture->restore(); ShaderClass::Invalidate(); @@ -2130,7 +2073,7 @@ void HeightMapRenderObjClass::Render(RenderInfoClass & rinfo) if (Scene) { RTS3DScene *pMyScene = (RTS3DScene *)Scene; RefRenderObjListIterator pDynamicLightsIterator(pMyScene->getDynamicLights()); - m_roadBuffer->drawRoads(&rinfo.Camera, doCloud?m_stageTwoTexture:NULL, TheGlobalData->m_useLightMap?m_stageThreeTexture:NULL, + m_roadBuffer->drawRoads(&rinfo.Camera, doCloud?m_stageTwoTexture:nullptr, TheGlobalData->m_useLightMap?m_stageThreeTexture:nullptr, m_disableTextures,xCoordMin-m_map->getBorderSizeInline(), xCoordMax-m_map->getBorderSizeInline(), yCoordMin-m_map->getBorderSizeInline(), yCoordMax-m_map->getBorderSizeInline(), &pDynamicLightsIterator); } } @@ -2139,8 +2082,8 @@ void HeightMapRenderObjClass::Render(RenderInfoClass & rinfo) m_propBuffer->drawProps(rinfo); } #ifdef DO_SCORCH - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); m_stageTwoTexture->restore(); ShaderClass::Invalidate(); @@ -2148,13 +2091,13 @@ void HeightMapRenderObjClass::Render(RenderInfoClass & rinfo) drawScorches(); } #endif - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); m_stageTwoTexture->restore(); ShaderClass::Invalidate(); DX8Wrapper::Apply_Render_State_Changes(); - m_bridgeBuffer->drawBridges(&rinfo.Camera, m_disableTextures, doCloud?m_stageTwoTexture:NULL); + m_bridgeBuffer->drawBridges(&rinfo.Camera, m_disableTextures, doCloud?m_stageTwoTexture:nullptr); if (TheTerrainTracksRenderObjClassSystem) TheTerrainTracksRenderObjClassSystem->flush(); @@ -2178,11 +2121,11 @@ void HeightMapRenderObjClass::Render(RenderInfoClass & rinfo) m_bibBuffer->renderBibs(); // We do some custom blending, so tell the shader class to reset everything. - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); m_stageTwoTexture->restore(); ShaderClass::Invalidate(); - DX8Wrapper::Set_Material(NULL); + DX8Wrapper::Set_Material(nullptr); } @@ -2191,7 +2134,7 @@ void HeightMapRenderObjClass::Render(RenderInfoClass & rinfo) ///Performs additional terrain rendering pass, blending in the black shroud texture. void HeightMapRenderObjClass::renderTerrainPass(CameraClass *pCamera) { - DX8Wrapper::Set_Transform(D3DTS_WORLD,Matrix3D(1)); + DX8Wrapper::Set_Transform(D3DTS_WORLD,Matrix3D(true)); //Apply the shader and material @@ -2200,15 +2143,7 @@ void HeightMapRenderObjClass::renderTerrainPass(CameraClass *pCamera) for (Int j=0; jLockRect(&locked_rect, NULL, 0)); + DX8_ErrorCode(surface_level->LockRect(&locked_rect, nullptr, 0)); Int tilePixelExtent = TILE_PIXEL_EXTENT; Int tilesPerRow = surface_desc.Width/(2*TILE_PIXEL_EXTENT+TILE_OFFSET); @@ -195,7 +195,7 @@ int TerrainTextureClass::update(WorldHeightMap *htMap) } surface_level->UnlockRect(); surface_level->Release(); - DX8_ErrorCode(D3DXFilterTexture(Peek_D3D_Texture(), NULL, 0, D3DX_FILTER_BOX)); + DX8_ErrorCode(D3DXFilterTexture(Peek_D3D_Texture(), nullptr, 0, D3DX_FILTER_BOX)); if (WW3D::Get_Texture_Reduction()) { Peek_D3D_Texture()->SetLOD(WW3D::Get_Texture_Reduction()); } @@ -227,7 +227,7 @@ int TerrainTextureClass::update(WorldHeightMap *htMap) return false; } - DX8_ErrorCode(surface_level->LockRect(&locked_rect, NULL, 0)); + DX8_ErrorCode(surface_level->LockRect(&locked_rect, nullptr, 0)); Int tilePixelExtent = TILE_PIXEL_EXTENT; Int tilesPerRow = surface_desc.Width/(2*TILE_PIXEL_EXTENT+TILE_OFFSET); @@ -352,7 +352,7 @@ int TerrainTextureClass::update(WorldHeightMap *htMap) } surface_level->UnlockRect(); surface_level->Release(); - DX8_ErrorCode(D3DXFilterTexture(D3DTexture, NULL, 0, D3DX_FILTER_BOX)); + DX8_ErrorCode(D3DXFilterTexture(D3DTexture, nullptr, 0, D3DX_FILTER_BOX)); return(surface_desc.Height); } #endif @@ -388,7 +388,7 @@ Bool TerrainTextureClass::updateFlat(WorldHeightMap *htMap, Int xCell, Int yCell return false; } - DX8_ErrorCode(surface_level->LockRect(&locked_rect, NULL, 0)); + DX8_ErrorCode(surface_level->LockRect(&locked_rect, nullptr, 0)); if (surface_desc.Format == D3DFMT_A1R5G5B5) { @@ -408,7 +408,7 @@ Bool TerrainTextureClass::updateFlat(WorldHeightMap *htMap, Int xCell, Int yCell for (cellY = 0; cellY < cellWidth; cellY++) { UnsignedByte *pBGRX_data = ((UnsignedByte*)locked_rect.pBits); UnsignedByte *pBGR = htMap->getPointerToTileData(xCell+cellX, yCell+cellY, pixelsPerCell); - if (pBGR == NULL) continue; // past end of defined terrain. [3/24/2003] + if (pBGR == nullptr) continue; // past end of defined terrain. [3/24/2003] Int k, l; for (k=pixelsPerCell-1; k>=0; k--) { UnsignedByte *pBGRX = pBGRX_data + (pixelsPerCell*(cellWidth-cellY-1)+k)*surface_desc.Width*pixelBytes + @@ -425,7 +425,7 @@ Bool TerrainTextureClass::updateFlat(WorldHeightMap *htMap, Int xCell, Int yCell surface_level->UnlockRect(); surface_level->Release(); - DX8_ErrorCode(D3DXFilterTexture(Peek_D3D_Texture(), NULL, 0, D3DX_FILTER_BOX)); + DX8_ErrorCode(D3DXFilterTexture(Peek_D3D_Texture(), nullptr, 0, D3DX_FILTER_BOX)); return(surface_desc.Height); } @@ -564,7 +564,7 @@ void AlphaTerrainTextureClass::Apply(unsigned int stage) DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ALPHAARG1, D3DTA_TFACTOR | D3DTA_COMPLEMENT); DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); - DX8Wrapper::Set_DX8_Texture(2, NULL); + DX8Wrapper::Set_DX8_Texture(2, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 2, D3DTSS_COLOROP, D3DTOP_MODULATE); DX8Wrapper::Set_DX8_Texture_Stage_State( 2, D3DTSS_TEXCOORDINDEX, 2); DX8Wrapper::Set_DX8_Texture_Stage_State( 2, D3DTSS_COLORARG1, D3DTA_TEXTURE); @@ -573,7 +573,7 @@ void AlphaTerrainTextureClass::Apply(unsigned int stage) DX8Wrapper::Set_DX8_Texture_Stage_State( 2, D3DTSS_ALPHAARG1, D3DTA_TFACTOR); DX8Wrapper::Set_DX8_Texture_Stage_State( 2, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); - DX8Wrapper::Set_DX8_Texture(3, NULL); + DX8Wrapper::Set_DX8_Texture(3, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 3, D3DTSS_COLOROP, D3DTOP_SELECTARG1); DX8Wrapper::Set_DX8_Texture_Stage_State( 3, D3DTSS_TEXCOORDINDEX, 3); DX8Wrapper::Set_DX8_Texture_Stage_State( 3, D3DTSS_COLORARG1, D3DTA_DIFFUSE | 0 | D3DTA_ALPHAREPLICATE); @@ -582,7 +582,7 @@ void AlphaTerrainTextureClass::Apply(unsigned int stage) DX8Wrapper::Set_DX8_Texture_Stage_State( 3, D3DTSS_ALPHAARG1, D3DTA_TFACTOR); DX8Wrapper::Set_DX8_Texture_Stage_State( 3, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); - DX8Wrapper::Set_DX8_Texture(4, NULL); + DX8Wrapper::Set_DX8_Texture(4, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 4, D3DTSS_COLOROP, D3DTOP_MODULATE); DX8Wrapper::Set_DX8_Texture_Stage_State( 4, D3DTSS_TEXCOORDINDEX, 4); DX8Wrapper::Set_DX8_Texture_Stage_State( 4, D3DTSS_COLORARG1, D3DTA_CURRENT); @@ -591,7 +591,7 @@ void AlphaTerrainTextureClass::Apply(unsigned int stage) DX8Wrapper::Set_DX8_Texture_Stage_State( 4, D3DTSS_ALPHAARG1, D3DTA_CURRENT); DX8Wrapper::Set_DX8_Texture_Stage_State( 4, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); - DX8Wrapper::Set_DX8_Texture(5, NULL); + DX8Wrapper::Set_DX8_Texture(5, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 5, D3DTSS_COLOROP, D3DTOP_ADD); DX8Wrapper::Set_DX8_Texture_Stage_State( 5, D3DTSS_TEXCOORDINDEX, 5); DX8Wrapper::Set_DX8_Texture_Stage_State( 5, D3DTSS_COLORARG1, D3DTA_DIFFUSE); @@ -600,7 +600,7 @@ void AlphaTerrainTextureClass::Apply(unsigned int stage) DX8Wrapper::Set_DX8_Texture_Stage_State( 5, D3DTSS_ALPHAARG1, D3DTA_TFACTOR | D3DTA_COMPLEMENT); DX8Wrapper::Set_DX8_Texture_Stage_State( 5, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); - DX8Wrapper::Set_DX8_Texture(6, NULL); + DX8Wrapper::Set_DX8_Texture(6, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 6, D3DTSS_COLOROP, D3DTOP_MODULATE); DX8Wrapper::Set_DX8_Texture_Stage_State( 6, D3DTSS_TEXCOORDINDEX, 6); DX8Wrapper::Set_DX8_Texture_Stage_State( 6, D3DTSS_COLORARG1, D3DTA_TFACTOR); @@ -609,7 +609,7 @@ void AlphaTerrainTextureClass::Apply(unsigned int stage) DX8Wrapper::Set_DX8_Texture_Stage_State( 6, D3DTSS_ALPHAARG1, D3DTA_TFACTOR); DX8Wrapper::Set_DX8_Texture_Stage_State( 6, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); - DX8Wrapper::Set_DX8_Texture(7, NULL); + DX8Wrapper::Set_DX8_Texture(7, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 7, D3DTSS_COLOROP, D3DTOP_SELECTARG1); DX8Wrapper::Set_DX8_Texture_Stage_State( 7, D3DTSS_TEXCOORDINDEX, 7); DX8Wrapper::Set_DX8_Texture_Stage_State( 7, D3DTSS_COLORARG1, D3DTA_TFACTOR); @@ -711,20 +711,20 @@ void LightMapTerrainTextureClass::Apply(unsigned int stage) DX8Wrapper::Set_DX8_Texture_Stage_State( stage, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); DX8Wrapper::Set_DX8_Texture_Stage_State( stage, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); - D3DXMATRIX inv; float det; - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMatrixInverse(&inv, &det, &curView); + D3DXMATRIX scale; D3DXMatrixScaling(&scale, STRETCH_FACTOR, STRETCH_FACTOR,1); inv *=scale; if (stage==0) { - DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, *((Matrix4x4*)&inv)); + DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, inv); } if (stage==1) { - DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, *((Matrix4x4*)&inv)); + DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, inv); } @@ -775,7 +775,7 @@ int AlphaEdgeTextureClass::update(WorldHeightMap *htMap) D3DSURFACE_DESC surface_desc; D3DLOCKED_RECT locked_rect; DX8_ErrorCode(Peek_D3D_Texture()->GetSurfaceLevel(0, &surface_level)); - DX8_ErrorCode(surface_level->LockRect(&locked_rect, NULL, 0)); + DX8_ErrorCode(surface_level->LockRect(&locked_rect, nullptr, 0)); DX8_ErrorCode(surface_level->GetDesc(&surface_desc)); Int tilePixelExtent = TILE_PIXEL_EXTENT; // blend tiles are 1/4 tiles. @@ -837,7 +837,7 @@ int AlphaEdgeTextureClass::update(WorldHeightMap *htMap) } surface_level->UnlockRect(); surface_level->Release(); - DX8_ErrorCode(D3DXFilterTexture(Peek_D3D_Texture(), NULL, 0, D3DX_FILTER_BOX)); + DX8_ErrorCode(D3DXFilterTexture(Peek_D3D_Texture(), nullptr, 0, D3DX_FILTER_BOX)); return(surface_desc.Height); } @@ -965,13 +965,13 @@ void CloudMapTerrainTextureClass::Apply(unsigned int stage) DX8Wrapper::Set_DX8_Texture_Stage_State( stage, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); DX8Wrapper::Set_DX8_Texture_Stage_State( stage, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); - D3DXMATRIX inv; float det; - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMatrixInverse(&inv, &det, &curView); + D3DXMATRIX scale; D3DXMatrixScaling(&scale, STRETCH_FACTOR, STRETCH_FACTOR,1); inv *=scale; @@ -999,7 +999,7 @@ void CloudMapTerrainTextureClass::Apply(unsigned int stage) DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG1 ); DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, *((Matrix4x4*)&inv)); + DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, inv); // Disable 3rd stage just in case. DX8Wrapper::Set_DX8_Texture_Stage_State( 2, D3DTSS_COLOROP, D3DTOP_DISABLE ); @@ -1018,7 +1018,7 @@ void CloudMapTerrainTextureClass::Apply(unsigned int stage) DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ALPHAARG1, D3DTA_CURRENT ); DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1 ); - DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, *((Matrix4x4*)&inv)); + DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, inv); } #endif } @@ -1070,7 +1070,7 @@ void CloudMapTerrainTextureClass::restore(void) DX8Wrapper::Set_DX8_Texture_Stage_State( i, D3DTSS_ALPHAARG1, D3DTA_TEXTURE); DX8Wrapper::Set_DX8_Texture_Stage_State( i, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); - DX8Wrapper::Set_DX8_Texture(i, NULL); + DX8Wrapper::Set_DX8_Texture(i, nullptr); } } } diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp index fe936811b86..1f607d54fdb 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DPropBuffer.cpp @@ -45,6 +45,7 @@ //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- + #include "W3DDevice/GameClient/W3DPropBuffer.h" #include @@ -157,7 +158,7 @@ Int W3DPropBuffer::addPropType(const AsciiString &modelName) } m_propTypes[m_numPropTypes].m_robj = WW3DAssetManager::Get_Instance()->Create_Render_Obj(modelName.str()); - if (m_propTypes[m_numPropTypes].m_robj==NULL) { + if (m_propTypes[m_numPropTypes].m_robj==nullptr) { DEBUG_CRASH(("Unable to find model for prop %s", modelName.str())); return -1; } @@ -277,7 +278,7 @@ void W3DPropBuffer::removePropsForConstruction(const Coord3D* pos, const Geometr // Just iterate all trees, as even non-collidable ones get removed. jba. [7/11/2003] Int i; for (i=0; iRender(rinfo); } } - rinfo.light_environment = NULL; + rinfo.light_environment = nullptr; } diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp index 6ae6394e28f..9cf5fa5b9aa 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DShaderManager.cpp @@ -88,8 +88,8 @@ class W3DShaderInterface ///do any custom resetting necessary to bring W3D in sync. virtual void reset(void) { ShaderClass::Invalidate(); - DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, NULL); - DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, NULL);}; + DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, nullptr); + DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, nullptr);}; virtual Int init(void) = 0; ///SetTexture(0,NULL); //previously rendered frame inside this texture + DX8Wrapper::_Get_D3D_Device8()->SetTexture(0,nullptr); //previously rendered frame inside this texture DX8Wrapper::Invalidate_Cached_Render_States(); } @@ -270,7 +270,7 @@ W3DFilterInterface *ScreenBWFilterList[]= { &screenBWFilter, &screenBWFilterDOT3, //slower version for older cards without pixel shaders. - NULL + nullptr }; Int ScreenBWFilter::init(void) @@ -278,7 +278,7 @@ Int ScreenBWFilter::init(void) Int res; HRESULT hr; - m_dwBWPixelShader = NULL; + m_dwBWPixelShader = 0; m_curFadeFrame = 0; if (!W3DShaderManager::canRenderToTexture()) { @@ -416,7 +416,7 @@ Int ScreenBWFilter::set(FilterModes mode) DX8Wrapper::Set_Material(vmat); REF_PTR_RELEASE(vmat); //no need to keep a reference since it's a preset. DX8Wrapper::Set_Shader(ShaderClass::_PresetOpaqueShader); - DX8Wrapper::Set_Texture(0,NULL); + DX8Wrapper::Set_Texture(0,nullptr); DX8Wrapper::Apply_Render_State_Changes(); //force update of view and projection matrices DX8Wrapper::Set_DX8_Render_State(D3DRS_ZFUNC,D3DCMP_ALWAYS); @@ -468,7 +468,7 @@ Int ScreenBWFilter::set(FilterModes mode) void ScreenBWFilter::reset(void) { - DX8Wrapper::_Get_D3D_Device8()->SetTexture(0,NULL); //previously rendered frame inside this texture + DX8Wrapper::_Get_D3D_Device8()->SetTexture(0,nullptr); //previously rendered frame inside this texture DX8Wrapper::_Get_D3D_Device8()->SetPixelShader(0); //turn off pixel shader DX8Wrapper::Invalidate_Cached_Render_States(); } @@ -478,7 +478,7 @@ Int ScreenBWFilter::shutdown(void) if (m_dwBWPixelShader) DX8Wrapper::_Get_D3D_Device8()->DeletePixelShader(m_dwBWPixelShader); - m_dwBWPixelShader=NULL; + m_dwBWPixelShader=0; return TRUE; } @@ -638,7 +638,7 @@ Int ScreenBWFilterDOT3::set(FilterModes mode) DX8Wrapper::Set_Material(vmat); REF_PTR_RELEASE(vmat); //no need to keep a reference since it's a preset. DX8Wrapper::Set_Shader(ShaderClass::_PresetOpaqueShader); - DX8Wrapper::Set_Texture(0,NULL); + DX8Wrapper::Set_Texture(0,nullptr); DX8Wrapper::Apply_Render_State_Changes(); //force update of view and projection matrices DX8Wrapper::Set_DX8_Render_State(D3DRS_ZFUNC,D3DCMP_ALWAYS); @@ -652,7 +652,7 @@ Int ScreenBWFilterDOT3::set(FilterModes mode) void ScreenBWFilterDOT3::reset(void) { - DX8Wrapper::_Get_D3D_Device8()->SetTexture(0,NULL); //previously rendered frame inside this texture + DX8Wrapper::_Get_D3D_Device8()->SetTexture(0,nullptr); //previously rendered frame inside this texture DX8Wrapper::Invalidate_Cached_Render_States(); } @@ -668,7 +668,7 @@ Int ScreenCrossFadeFilter::m_fadeFrames; Int ScreenCrossFadeFilter::m_curFadeFrame; Real ScreenCrossFadeFilter::m_curFadeValue; Int ScreenCrossFadeFilter::m_fadeDirection; -TextureClass *ScreenCrossFadeFilter::m_fadePatternTexture=NULL; +TextureClass *ScreenCrossFadeFilter::m_fadePatternTexture=nullptr; Bool ScreenCrossFadeFilter::m_skipRender = FALSE; ScreenCrossFadeFilter screenCrossFadeFilter; @@ -678,7 +678,7 @@ ScreenCrossFadeFilter screenCrossFadeFilter; W3DFilterInterface *ScreenCrossFadeFilterList[]= { &screenCrossFadeFilter, - NULL + nullptr }; Int ScreenCrossFadeFilter::init(void) @@ -858,8 +858,8 @@ Int ScreenCrossFadeFilter::set(FilterModes mode) DX8Wrapper::Set_Material(vmat); REF_PTR_RELEASE(vmat); //no need to keep a reference since it's a preset. DX8Wrapper::Set_Shader(ShaderClass::_PresetAlphaShader); - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); DX8Wrapper::Apply_Render_State_Changes(); //force update of view and projection matrices DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP); @@ -891,7 +891,7 @@ void ScreenCrossFadeFilter::reset(void) { DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - DX8Wrapper::_Get_D3D_Device8()->SetTexture(0,NULL); //previously rendered frame inside this texture + DX8Wrapper::_Get_D3D_Device8()->SetTexture(0,nullptr); //previously rendered frame inside this texture DX8Wrapper::Invalidate_Cached_Render_States(); } @@ -921,7 +921,7 @@ m_skipRender(false) W3DFilterInterface *ScreenMotionBlurFilterList[]= { &screenMotionBlurFilter, - NULL + nullptr }; Int ScreenMotionBlurFilter::init(void) @@ -1148,8 +1148,8 @@ Int ScreenMotionBlurFilter::set(FilterModes mode) DX8Wrapper::Set_Material(vmat); REF_PTR_RELEASE(vmat); //no need to keep a reference since it's a preset. DX8Wrapper::Set_Shader(ShaderClass::_PresetOpaqueShader); - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); DX8Wrapper::Apply_Render_State_Changes(); //force update of view and projection matrices DX8Wrapper::Set_DX8_Render_State(D3DRS_ZFUNC,D3DCMP_ALWAYS); @@ -1161,7 +1161,7 @@ Int ScreenMotionBlurFilter::set(FilterModes mode) void ScreenMotionBlurFilter::reset(void) { - DX8Wrapper::_Get_D3D_Device8()->SetTexture(0,NULL); //previously rendered frame inside this texture + DX8Wrapper::_Get_D3D_Device8()->SetTexture(0,nullptr); //previously rendered frame inside this texture DX8Wrapper::Invalidate_Cached_Render_States(); } @@ -1187,7 +1187,7 @@ class ShroudTextureShader : public W3DShaderInterface W3DShaderInterface *ShroudShaderList[]= { &shroudTextureShader, - NULL + nullptr }; //#define SHROUD_STRETCH_FACTOR (1.0f/MAP_XY_FACTOR) //1 texel per heightmap cell width @@ -1229,15 +1229,14 @@ Int ShroudTextureShader::set(Int stage) //We need to scale so shroud texel stretches over one full terrain cell. Each texel //is 1/128 the size of full texture. (assuming 128x128 vid-mem texture). W3DShroud *shroud; - if ((shroud=TheTerrainRenderObject->getShroud()) != 0) + if ((shroud=TheTerrainRenderObject->getShroud()) != nullptr) { ///@todo: All this code really only need to be done once per camera/view. Find a way to optimize it out. - D3DXMATRIX inv; - float det; - - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMATRIX inv; + float det; + D3DXMatrixInverse(&inv, &det, &curView); D3DXMATRIX scale,offset; @@ -1260,8 +1259,8 @@ Int ShroudTextureShader::set(Int stage) width = 1.0f/(width*shroud->getTextureWidth()); height = 1.0f/(height*shroud->getTextureHeight()); D3DXMatrixScaling(&scale, width, height, 1); - *((D3DXMATRIX *)&curView) = (inv * offset) * scale; - DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+stage), *((Matrix4x4*)&curView)); + curView = (inv * offset) * scale; + DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+stage), curView); } m_stageOfSet=stage; return TRUE; @@ -1269,7 +1268,7 @@ Int ShroudTextureShader::set(Int stage) void ShroudTextureShader::reset(void) { - DX8Wrapper::Set_Texture(m_stageOfSet,NULL); + DX8Wrapper::Set_Texture(m_stageOfSet,nullptr); DX8Wrapper::Set_DX8_Render_State(D3DRS_ZFUNC,D3DCMP_LESSEQUAL); DX8Wrapper::Set_DX8_Texture_Stage_State(m_stageOfSet, D3DTSS_TEXCOORDINDEX, m_stageOfSet); DX8Wrapper::Set_DX8_Texture_Stage_State(m_stageOfSet, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); @@ -1288,7 +1287,7 @@ class FlatShroudTextureShader : public W3DShaderInterface W3DShaderInterface *FlatShroudShaderList[]= { &flatShroudTextureShader, - NULL + nullptr }; //#define SHROUD_STRETCH_FACTOR (1.0f/MAP_XY_FACTOR) //1 texel per heightmap cell width @@ -1322,15 +1321,14 @@ Int FlatShroudTextureShader::set(Int stage) //We need to scale so shroud texel stretches over one full terrain cell. Each texel //is 1/128 the size of full texture. (assuming 128x128 vid-mem texture). W3DShroud *shroud; - if ((shroud=TheTerrainRenderObject->getShroud()) != 0) + if ((shroud=TheTerrainRenderObject->getShroud()) != nullptr) { ///@todo: All this code really only need to be done once per camera/view. Find a way to optimize it out. - D3DXMATRIX inv; - float det; - - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMATRIX inv; + float det; + D3DXMatrixInverse(&inv, &det, &curView); D3DXMATRIX scale,offset; @@ -1353,8 +1351,8 @@ Int FlatShroudTextureShader::set(Int stage) width = 1.0f/(width*shroud->getTextureWidth()); height = 1.0f/(height*shroud->getTextureHeight()); D3DXMatrixScaling(&scale, width, height, 1); - *((D3DXMATRIX *)&curView) = (inv * offset) * scale; - DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+stage), *((Matrix4x4*)&curView)); + curView = (inv * offset) * scale; + DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+stage), curView); } m_stageOfSet=stage; return TRUE; @@ -1363,7 +1361,7 @@ Int FlatShroudTextureShader::set(Int stage) void FlatShroudTextureShader::reset(void) { if (m_stageOfSet < MAX_TEXTURE_STAGES) - DX8Wrapper::Set_Texture(m_stageOfSet,NULL); + DX8Wrapper::Set_Texture(m_stageOfSet,nullptr); DX8Wrapper::Set_DX8_Render_State(D3DRS_ZFUNC,D3DCMP_LESSEQUAL); DX8Wrapper::Set_DX8_Texture_Stage_State(m_stageOfSet, D3DTSS_TEXCOORDINDEX, m_stageOfSet); DX8Wrapper::Set_DX8_Texture_Stage_State(m_stageOfSet, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); @@ -1381,7 +1379,7 @@ class MaskTextureShader : public W3DShaderInterface W3DShaderInterface *MaskShaderList[]= { &maskTextureShader, - NULL + nullptr }; Int MaskTextureShader::init(void) @@ -1413,7 +1411,8 @@ Int MaskTextureShader::set(Int pass) shader.Set_Primary_Gradient(ShaderClass::GRADIENT_DISABLE); DX8Wrapper::Set_Shader(shader); DX8Wrapper::Apply_Render_State_Changes(); - Matrix4x4 curView; + + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); DX8Wrapper::Set_DX8_Texture_Stage_State(0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION); @@ -1423,7 +1422,7 @@ Int MaskTextureShader::set(Int pass) float det; //Get inverse view matrix so we can transform camera space points back to world space - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMatrixInverse(&inv, &det, &curView); D3DXMATRIX scale,offset,offsetTextureCenter; Coord3D centerPos; @@ -1450,24 +1449,26 @@ Int MaskTextureShader::set(Int pass) ///@todo: Fix this to work with non 128x128 textures. if (worldTexelWidth != 0 && worldTexelHeight != 0) - { Real widthScale = 1.0f/(worldTexelWidth*128.0f); + { + Real widthScale = 1.0f/(worldTexelWidth*128.0f); Real heightScale = 1.0f/(worldTexelHeight*128.0f); D3DXMatrixScaling(&scale, widthScale, heightScale, 1); - *((D3DXMATRIX *)&curView) = ((inv * offset) * scale)*offsetTextureCenter; + curView = ((inv * offset) * scale)*offsetTextureCenter; } else - { D3DXMatrixScaling(&scale, 0, 0, 1); //scaling by 0 will set uv coordinates to 0,0 - *((D3DXMATRIX *)&curView) = ((inv * offset) * scale); + { + D3DXMatrixScaling(&scale, 0, 0, 1); //scaling by 0 will set uv coordinates to 0,0 + curView = ((inv * offset) * scale); } - DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, *((Matrix4x4*)&curView)); + DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, curView); return TRUE; } void MaskTextureShader::reset(void) { - DX8Wrapper::Set_Texture(0,NULL); + DX8Wrapper::Set_Texture(0,nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State(0, D3DTSS_TEXCOORDINDEX, 0); DX8Wrapper::Set_DX8_Texture_Stage_State(0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); } @@ -1547,7 +1548,7 @@ W3DShaderInterface *TerrainShaderList[]= &terrainShaderPixelShader, &terrainShader8Stage, &terrainShader2Stage, - NULL + nullptr }; ///List of different terrain shader implementations in order of preference @@ -1555,7 +1556,7 @@ W3DShaderInterface *FlatTerrainShaderList[]= { &flatTerrainShaderPixelShader, &flatTerrainShader2Stage, - NULL + nullptr }; Int TerrainShader2Stage::init( void ) @@ -1585,8 +1586,8 @@ void TerrainShader2Stage::reset(void) ShaderClass::Invalidate(); //Free references to textures - DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, NULL); - DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, NULL); + DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, nullptr); + DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU|0); @@ -1691,7 +1692,7 @@ Int TerrainShader2Stage::set(Int pass) break; case 2: // Noise/cloud pass - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); //these states apply to all noise/cloud combination passes @@ -1711,18 +1712,16 @@ Int TerrainShader2Stage::set(Int pass) DX8Wrapper::Set_DX8_Render_State(D3DRS_SRCBLEND,D3DBLEND_DESTCOLOR); DX8Wrapper::Set_DX8_Render_State(D3DRS_DESTBLEND,D3DBLEND_ZERO); - D3DXMATRIX inv; float det; - - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMatrixInverse(&inv, &det, &curView); if (W3DShaderManager::getCurrentShader() == W3DShaderManager::ST_TERRAIN_BASE_NOISE12) { //setup cloud pass DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, W3DShaderManager::getShaderTexture(2)->Peek_D3D_Texture()); - updateNoise1(((D3DXMATRIX*)&curView),&inv); //update curView with texture matrix + updateNoise1(&curView,&inv); //update curView with texture matrix DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, curView); //clouds always need bilinear filtering DX8Wrapper::Set_DX8_Texture_Stage_State(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR); @@ -1731,7 +1730,7 @@ Int TerrainShader2Stage::set(Int pass) //setup noise pass DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, W3DShaderManager::getShaderTexture(3)->Peek_D3D_Texture()); - updateNoise2(((D3DXMATRIX*)&curView),&inv); + updateNoise2(&curView,&inv); DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, curView); //noise always needs point/linear filtering. Why point!? DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MINFILTER, D3DTEXF_POINT); @@ -1754,7 +1753,7 @@ Int TerrainShader2Stage::set(Int pass) if (W3DShaderManager::getCurrentShader() == W3DShaderManager::ST_TERRAIN_BASE_NOISE1) { //setup cloud pass DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, W3DShaderManager::getShaderTexture(2)->Peek_D3D_Texture()); - updateNoise1(((D3DXMATRIX*)&curView),&inv); //update curView with texture matrix + updateNoise1(&curView,&inv); //update curView with texture matrix DX8Wrapper::Set_DX8_Texture_Stage_State(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR); DX8Wrapper::Set_DX8_Texture_Stage_State(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); } @@ -1762,14 +1761,14 @@ Int TerrainShader2Stage::set(Int pass) { //setup noise pass DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, W3DShaderManager::getShaderTexture(3)->Peek_D3D_Texture()); - updateNoise2(((D3DXMATRIX*)&curView),&inv); //update curView with texture matrix + updateNoise2(&curView,&inv); //update curView with texture matrix DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MINFILTER, D3DTEXF_POINT); DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); } DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, *((Matrix4x4*)&curView)); + DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, curView); } break; } @@ -1848,7 +1847,7 @@ Int TerrainShader8Stage::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ALPHAARG1, D3DTA_TFACTOR | D3DTA_COMPLEMENT); DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); - DX8Wrapper::Set_DX8_Texture(2, NULL); + DX8Wrapper::Set_DX8_Texture(2, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 2, D3DTSS_COLOROP, D3DTOP_MODULATE); DX8Wrapper::Set_DX8_Texture_Stage_State( 2, D3DTSS_TEXCOORDINDEX, 2); DX8Wrapper::Set_DX8_Texture_Stage_State( 2, D3DTSS_COLORARG1, D3DTA_TEXTURE); @@ -1857,7 +1856,7 @@ Int TerrainShader8Stage::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State( 2, D3DTSS_ALPHAARG1, D3DTA_TFACTOR); DX8Wrapper::Set_DX8_Texture_Stage_State( 2, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); - DX8Wrapper::Set_DX8_Texture(3, NULL); + DX8Wrapper::Set_DX8_Texture(3, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 3, D3DTSS_COLOROP, D3DTOP_SELECTARG1); DX8Wrapper::Set_DX8_Texture_Stage_State( 3, D3DTSS_TEXCOORDINDEX, 3); DX8Wrapper::Set_DX8_Texture_Stage_State( 3, D3DTSS_COLORARG1, D3DTA_DIFFUSE | 0 | D3DTA_ALPHAREPLICATE); @@ -1866,7 +1865,7 @@ Int TerrainShader8Stage::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State( 3, D3DTSS_ALPHAARG1, D3DTA_TFACTOR); DX8Wrapper::Set_DX8_Texture_Stage_State( 3, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); - DX8Wrapper::Set_DX8_Texture(4, NULL); + DX8Wrapper::Set_DX8_Texture(4, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 4, D3DTSS_COLOROP, D3DTOP_MODULATE); DX8Wrapper::Set_DX8_Texture_Stage_State( 4, D3DTSS_TEXCOORDINDEX, 4); DX8Wrapper::Set_DX8_Texture_Stage_State( 4, D3DTSS_COLORARG1, D3DTA_CURRENT); @@ -1875,7 +1874,7 @@ Int TerrainShader8Stage::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State( 4, D3DTSS_ALPHAARG1, D3DTA_CURRENT); DX8Wrapper::Set_DX8_Texture_Stage_State( 4, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE); - DX8Wrapper::Set_DX8_Texture(5, NULL); + DX8Wrapper::Set_DX8_Texture(5, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 5, D3DTSS_COLOROP, D3DTOP_ADD); DX8Wrapper::Set_DX8_Texture_Stage_State( 5, D3DTSS_TEXCOORDINDEX, 5); DX8Wrapper::Set_DX8_Texture_Stage_State( 5, D3DTSS_COLORARG1, D3DTA_DIFFUSE); @@ -1884,7 +1883,7 @@ Int TerrainShader8Stage::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State( 5, D3DTSS_ALPHAARG1, D3DTA_TFACTOR | D3DTA_COMPLEMENT); DX8Wrapper::Set_DX8_Texture_Stage_State( 5, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); - DX8Wrapper::Set_DX8_Texture(6, NULL); + DX8Wrapper::Set_DX8_Texture(6, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 6, D3DTSS_COLOROP, D3DTOP_MODULATE); DX8Wrapper::Set_DX8_Texture_Stage_State( 6, D3DTSS_TEXCOORDINDEX, 6); DX8Wrapper::Set_DX8_Texture_Stage_State( 6, D3DTSS_COLORARG1, D3DTA_TFACTOR); @@ -1893,7 +1892,7 @@ Int TerrainShader8Stage::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State( 6, D3DTSS_ALPHAARG1, D3DTA_TFACTOR); DX8Wrapper::Set_DX8_Texture_Stage_State( 6, D3DTSS_ALPHAARG2, D3DTA_TFACTOR); - DX8Wrapper::Set_DX8_Texture(7, NULL); + DX8Wrapper::Set_DX8_Texture(7, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 7, D3DTSS_COLOROP, D3DTOP_SELECTARG1); DX8Wrapper::Set_DX8_Texture_Stage_State( 7, D3DTSS_TEXCOORDINDEX, 7); DX8Wrapper::Set_DX8_Texture_Stage_State( 7, D3DTSS_COLORARG1, D3DTA_TFACTOR); @@ -1924,8 +1923,8 @@ void TerrainShader8Stage::reset(void) DX8Wrapper::Set_DX8_Texture_Stage_State( 4, D3DTSS_COLOROP, D3DTOP_DISABLE); DX8Wrapper::Set_DX8_Texture_Stage_State( 4, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, NULL); - DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, NULL); + DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, nullptr); + DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, nullptr); DX8Wrapper::Invalidate_Cached_Render_States(); } @@ -1940,9 +1939,9 @@ Int TerrainShaderPixelShader::shutdown(void) if (m_dwBaseNoise2PixelShader) DX8Wrapper::_Get_D3D_Device8()->DeletePixelShader(m_dwBaseNoise2PixelShader); - m_dwBasePixelShader=NULL; - m_dwBaseNoise1PixelShader=NULL; - m_dwBaseNoise2PixelShader=NULL; + m_dwBasePixelShader=0; + m_dwBaseNoise1PixelShader=0; + m_dwBaseNoise2PixelShader=0; return TRUE; } @@ -2038,12 +2037,12 @@ Int TerrainShaderPixelShader::set(Int pass) if (W3DShaderManager::getCurrentShader() >= W3DShaderManager::ST_TERRAIN_BASE_NOISE1) { - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); D3DXMATRIX inv; float det; - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMatrixInverse(&inv, &det, &curView); DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION); // Two output coordinates are used. @@ -2066,10 +2065,10 @@ Int TerrainShaderPixelShader::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State(3, D3DTSS_MINFILTER, D3DTEXF_POINT); DX8Wrapper::Set_DX8_Texture_Stage_State(3, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); - terrainShader2Stage.updateNoise1(((D3DXMATRIX*)&curView),&inv); //update curView with texture matrix + terrainShader2Stage.updateNoise1(&curView,&inv); //update curView with texture matrix DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE2, curView); - terrainShader2Stage.updateNoise2(((D3DXMATRIX*)&curView),&inv); //update curView with texture matrix + terrainShader2Stage.updateNoise2(&curView,&inv); //update curView with texture matrix DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE3, curView); DX8Wrapper::Set_DX8_Texture_Stage_State(3, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION); @@ -2083,14 +2082,14 @@ Int TerrainShaderPixelShader::set(Int pass) if (W3DShaderManager::getCurrentShader() == W3DShaderManager::ST_TERRAIN_BASE_NOISE1) { //cloud map DX8Wrapper::_Get_D3D_Device8()->SetTexture(2, W3DShaderManager::getShaderTexture(2)->Peek_D3D_Texture()); - terrainShader2Stage.updateNoise1(((D3DXMATRIX*)&curView),&inv); //update curView with texture matrix + terrainShader2Stage.updateNoise1(&curView,&inv); //update curView with texture matrix DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_MINFILTER, D3DTEXF_LINEAR); DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); } else { //light map DX8Wrapper::_Get_D3D_Device8()->SetTexture(2, W3DShaderManager::getShaderTexture(3)->Peek_D3D_Texture()); - terrainShader2Stage.updateNoise2(((D3DXMATRIX*)&curView),&inv); //update curView with texture matrix + terrainShader2Stage.updateNoise2(&curView,&inv); //update curView with texture matrix DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_MINFILTER, D3DTEXF_POINT); DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); } @@ -2107,13 +2106,13 @@ Int TerrainShaderPixelShader::set(Int pass) void TerrainShaderPixelShader::reset(void) { - DX8Wrapper::_Get_D3D_Device8()->SetTexture(2,NULL); //release reference to any texture - DX8Wrapper::_Get_D3D_Device8()->SetTexture(3,NULL); //release reference to any texture + DX8Wrapper::_Get_D3D_Device8()->SetTexture(2,nullptr); //release reference to any texture + DX8Wrapper::_Get_D3D_Device8()->SetTexture(3,nullptr); //release reference to any texture DX8Wrapper::_Get_D3D_Device8()->SetPixelShader(0); //turn off pixel shader - DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, NULL); - DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, NULL); + DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, nullptr); + DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU|0); @@ -2144,7 +2143,7 @@ class CloudTextureShader : public W3DShaderInterface W3DShaderInterface *CloudShaderList[]= { &cloudTextureShader, - NULL + nullptr }; Int CloudTextureShader::init(void) @@ -2158,16 +2157,16 @@ Int CloudTextureShader::init(void) /**Setup a certain texture stage to project our cloud texture*/ Int CloudTextureShader::set(Int stage) { - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); D3DXMATRIX inv; float det; - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMatrixInverse(&inv, &det, &curView); //Get a texture matrix that applies the current cloud position - terrainShader2Stage.updateNoise1(((D3DXMATRIX*)&curView),&inv,false); //update curView with texture matrix + terrainShader2Stage.updateNoise1(&curView,&inv,false); //update curView with texture matrix DX8Wrapper::Set_DX8_Texture_Stage_State(stage, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION); DX8Wrapper::Set_DX8_Texture_Stage_State(stage, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2); @@ -2193,7 +2192,7 @@ Int CloudTextureShader::set(Int stage) void CloudTextureShader::reset(void) { //Free reference to texture - DX8Wrapper::_Get_D3D_Device8()->SetTexture(m_stageOfSet, NULL); + DX8Wrapper::_Get_D3D_Device8()->SetTexture(m_stageOfSet, nullptr); //Turn off texture projection DX8Wrapper::Set_DX8_Texture_Stage_State( m_stageOfSet, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); DX8Wrapper::Set_DX8_Texture_Stage_State( m_stageOfSet, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU|m_stageOfSet); @@ -2228,7 +2227,7 @@ W3DShaderInterface *RoadShaderList[]= { &roadShaderPixelShader, &roadShader2Stage, - NULL + nullptr }; Int RoadShaderPixelShader::shutdown(void) @@ -2236,7 +2235,7 @@ Int RoadShaderPixelShader::shutdown(void) if (m_dwBaseNoise2PixelShader) DX8Wrapper::_Get_D3D_Device8()->DeletePixelShader(m_dwBaseNoise2PixelShader); - m_dwBaseNoise2PixelShader=NULL; + m_dwBaseNoise2PixelShader=0; return TRUE; } @@ -2251,7 +2250,7 @@ Int RoadShaderPixelShader::init( void ) if (res >= DC_GENERIC_PIXEL_SHADER_1_1) { //this shader needs some assets that need to be loaded - //shader decleration + //shader declaration DWORD Declaration[]= { (D3DVSD_STREAM(0)), @@ -2293,12 +2292,12 @@ Int RoadShaderPixelShader::set(Int pass) DX8Wrapper::Set_DX8_Render_State(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA); DX8Wrapper::Set_DX8_Render_State(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA); - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); D3DXMATRIX inv; float det; - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMatrixInverse(&inv, &det, &curView); if (TheGlobalData && TheGlobalData->m_trilinearTerrainTex) { DX8Wrapper::Set_DX8_Texture_Stage_State(0, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); @@ -2330,10 +2329,10 @@ Int RoadShaderPixelShader::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_MINFILTER, D3DTEXF_POINT); DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); - terrainShader2Stage.updateNoise1(((D3DXMATRIX*)&curView),&inv, false); //get texture projection matrix + terrainShader2Stage.updateNoise1(&curView,&inv, false); //get texture projection matrix DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, curView); - terrainShader2Stage.updateNoise2(((D3DXMATRIX*)&curView),&inv, false); //get texture projection matrix + terrainShader2Stage.updateNoise2(&curView,&inv, false); //get texture projection matrix DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE2, curView); DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION); @@ -2408,12 +2407,12 @@ Int RoadShader2Stage::set(Int pass) if (W3DShaderManager::getCurrentShader() >= W3DShaderManager::ST_ROAD_BASE_NOISE1) { //second texture unit will contain a noise pass - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); D3DXMATRIX inv; float det; - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMatrixInverse(&inv, &det, &curView); if (TheGlobalData && TheGlobalData->m_trilinearTerrainTex) DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); @@ -2440,7 +2439,7 @@ Int RoadShader2Stage::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MINFILTER, D3DTEXF_LINEAR); DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); - terrainShader2Stage.updateNoise1(((D3DXMATRIX*)&curView),&inv, false); //get texture projection matrix + terrainShader2Stage.updateNoise1(&curView, &inv, false); //get texture projection matrix DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, curView); } else @@ -2448,14 +2447,14 @@ Int RoadShader2Stage::set(Int pass) if (W3DShaderManager::getCurrentShader() == W3DShaderManager::ST_ROAD_BASE_NOISE1) { //cloud map DX8Wrapper::Set_Texture(1,W3DShaderManager::getShaderTexture(1)); - terrainShader2Stage.updateNoise1(((D3DXMATRIX*)&curView),&inv, false); //update curView with texture matrix + terrainShader2Stage.updateNoise1(&curView, &inv, false); //update curView with texture matrix DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MINFILTER, D3DTEXF_LINEAR); DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); } else { //light map DX8Wrapper::Set_Texture(1,W3DShaderManager::getShaderTexture(2)); - terrainShader2Stage.updateNoise2(((D3DXMATRIX*)&curView),&inv, false); //update curView with texture matrix + terrainShader2Stage.updateNoise2(&curView,&inv, false); //update curView with texture matrix DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MINFILTER, D3DTEXF_POINT); DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); } @@ -2470,12 +2469,12 @@ Int RoadShader2Stage::set(Int pass) } else { //pass 1, apply additional noise pass - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); D3DXMATRIX inv; float det; - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMatrixInverse(&inv, &det, &curView); if (TheGlobalData && TheGlobalData->m_trilinearTerrainTex) DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MIPFILTER, D3DTEXF_LINEAR); @@ -2484,7 +2483,7 @@ Int RoadShader2Stage::set(Int pass) DX8Wrapper::Set_Texture(1,W3DShaderManager::getShaderTexture(2)); - terrainShader2Stage.updateNoise2(((D3DXMATRIX*)&curView),&inv, false); //update curView with texture matrix + terrainShader2Stage.updateNoise2(&curView, &inv, false); //update curView with texture matrix DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MINFILTER, D3DTEXF_POINT); DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); @@ -2545,7 +2544,7 @@ W3DShaderInterface **MasterShaderList[]= MaskShaderList, CloudShaderList, FlatTerrainShaderList, - NULL + nullptr }; /** List of all custom filter lists - each list in this list contains variations of the same @@ -2557,7 +2556,7 @@ W3DFilterInterface **MasterFilterList[]= ScreenBWFilterList, ScreenMotionBlurFilterList, ScreenCrossFadeFilterList, - NULL + nullptr }; // W3DShaderManager::W3DShaderManager ========================================= @@ -2567,22 +2566,22 @@ W3DShaderManager::W3DShaderManager(void) { m_currentShader = ST_INVALID; m_currentFilter = FT_NULL_FILTER; - m_oldRenderSurface = NULL; - m_renderTexture = NULL; - m_newRenderSurface = NULL; - m_oldDepthSurface = NULL; + m_oldRenderSurface = nullptr; + m_renderTexture = nullptr; + m_newRenderSurface = nullptr; + m_oldDepthSurface = nullptr; m_renderingToTexture = false; Int i; for (i=0; iRelease(); - m_oldRenderSurface = NULL; - m_renderTexture = NULL; + m_oldRenderSurface = nullptr; + m_renderTexture = nullptr; } else { hr = m_renderTexture->GetSurfaceLevel(0, &m_newRenderSurface); if (hr != S_OK) { if (m_renderTexture) m_renderTexture->Release(); - m_renderTexture = NULL; - m_newRenderSurface = NULL; + m_renderTexture = nullptr; + m_newRenderSurface = nullptr; } else { hr = DX8Wrapper::_Get_D3D_Device8()->GetDepthStencilSurface(&m_oldDepthSurface); if (hr != S_OK) { if (m_newRenderSurface) m_newRenderSurface->Release(); if (m_renderTexture) m_renderTexture->Release(); - m_renderTexture = NULL; - m_newRenderSurface = NULL; - m_oldDepthSurface = NULL; + m_renderTexture = nullptr; + m_newRenderSurface = nullptr; + m_oldDepthSurface = nullptr; } } } @@ -2637,10 +2636,10 @@ void W3DShaderManager::init(void) W3DShaderInterface **shaders; - for (i=0; MasterShaderList[i] != NULL; i++) + for (i=0; MasterShaderList[i] != nullptr; i++) { shaders=MasterShaderList[i]; - for (j=0; shaders[j] != NULL; j++) + for (j=0; shaders[j] != nullptr; j++) { if (shaders[j]->init()) break; //found a working shader @@ -2648,10 +2647,10 @@ void W3DShaderManager::init(void) } W3DFilterInterface **filters; - for (i=0; MasterFilterList[i] != NULL; i++) + for (i=0; MasterFilterList[i] != nullptr; i++) { filters=MasterFilterList[i]; - for (j=0; filters[j] != NULL; j++) + for (j=0; filters[j] != nullptr; j++) { if (filters[j]->init()) break; //found a working shader @@ -2670,10 +2669,10 @@ void W3DShaderManager::shutdown(void) if (m_renderTexture) m_renderTexture->Release(); if (m_oldRenderSurface) m_oldRenderSurface->Release(); if (m_oldDepthSurface) m_oldDepthSurface->Release(); - m_renderTexture = NULL; - m_newRenderSurface = NULL; - m_oldDepthSurface = NULL; - m_oldRenderSurface = NULL; + m_renderTexture = nullptr; + m_newRenderSurface = nullptr; + m_oldDepthSurface = nullptr; + m_oldRenderSurface = nullptr; m_currentShader = ST_INVALID; m_currentFilter = FT_NULL_FILTER; //release any assets associated with a shader (vertex/pixel shaders, textures, etc.) @@ -2830,7 +2829,7 @@ void W3DShaderManager::startRenderToTexture(void) { DEBUG_ASSERTCRASH(!m_renderingToTexture, ("Already rendering to texture - cannot nest calls.")); - if (m_renderingToTexture || m_newRenderSurface==NULL || m_oldDepthSurface==NULL) return; + if (m_renderingToTexture || m_newRenderSurface==nullptr || m_oldDepthSurface==nullptr) return; HRESULT hr = DX8Wrapper::_Get_D3D_Device8()->SetRenderTarget(m_newRenderSurface,m_oldDepthSurface); DEBUG_ASSERTCRASH(hr==S_OK, ("Set target failed unexpectedly.")); if (hr != S_OK) @@ -2866,12 +2865,12 @@ void W3DShaderManager::startRenderToTexture(void) IDirect3DTexture8 *W3DShaderManager::endRenderToTexture(void) { DEBUG_ASSERTCRASH(m_renderingToTexture, ("Not rendering to texture.")); - if (!m_renderingToTexture) return NULL; + if (!m_renderingToTexture) return nullptr; HRESULT hr = DX8Wrapper::_Get_D3D_Device8()->SetRenderTarget(m_oldRenderSurface,m_oldDepthSurface); //restore original render target DEBUG_ASSERTCRASH(hr==S_OK, ("Set target failed unexpectedly.")); if (hr == S_OK) { - //assume render target texure will be in stage 0. Most hardware has "conditional" support for + //assume render target texture will be in stage 0. Most hardware has "conditional" support for //non-power-of-2 textures so we must force some required states: DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP); DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP); @@ -3005,11 +3004,11 @@ HRESULT W3DShaderManager::LoadAndCreateD3DShader(const char* strFilePath, const try { - File *file = NULL; + File *file = nullptr; HRESULT hr; file = TheFileSystem->openFile(strFilePath, File::READ | File::BINARY); - if (file == NULL) + if (file == nullptr) { OutputDebugString("Could not find file \n" ); return E_FAIL; @@ -3029,7 +3028,7 @@ HRESULT W3DShaderManager::LoadAndCreateD3DShader(const char* strFilePath, const file->read((void *)pShader, dwFileSize); file->close(); - file = NULL; + file = nullptr; if (ShaderType) // SHADERTYPE_VERTEX { @@ -3187,7 +3186,7 @@ Int W3DShaderManager::setShroudTex(Int stage) //We need to scale so shroud texel stretches over one full terrain cell. Each texel //is 1/128 the size of full texture. (assuming 128x128 vid-mem texture). W3DShroud *shroud; - if ((shroud=TheTerrainRenderObject->getShroud()) != 0) + if ((shroud=TheTerrainRenderObject->getShroud()) != nullptr) { DX8Wrapper::Set_Texture(stage, shroud->getShroudTexture()); @@ -3199,13 +3198,13 @@ Int W3DShaderManager::setShroudTex(Int stage) DX8Wrapper::Set_DX8_Texture_Stage_State( stage, D3DTSS_ALPHAARG2, D3DTA_CURRENT ); DX8Wrapper::Set_DX8_Texture_Stage_State( stage, D3DTSS_COLOROP, D3DTOP_MODULATE ); DX8Wrapper::Set_DX8_Texture_Stage_State( stage, D3DTSS_ALPHAOP, D3DTOP_SELECTARG2 ); - D3DXMATRIX inv; - float det; - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMATRIX inv; + float det; + D3DXMatrixInverse(&inv, &det, &curView); D3DXMATRIX scale,offset; @@ -3228,8 +3227,8 @@ Int W3DShaderManager::setShroudTex(Int stage) width = 1.0f/(width*shroud->getTextureWidth()); height = 1.0f/(height*shroud->getTextureHeight()); D3DXMatrixScaling(&scale, width, height, 1); - *((D3DXMATRIX *)&curView) = (inv * offset) * scale; - DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+stage), *((Matrix4x4*)&curView)); + curView = (inv * offset) * scale; + DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+stage), curView); return TRUE; } return FALSE; @@ -3258,8 +3257,8 @@ void FlatTerrainShader2Stage::reset(void) ShaderClass::Invalidate(); //Free references to textures - DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, NULL); - DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, NULL); + DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, nullptr); + DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU|0); @@ -3316,15 +3315,14 @@ Int FlatTerrainShader2Stage::set(Int pass) //We need to scale so shroud texel stretches over one full terrain cell. Each texel //is 1/128 the size of full texture. (assuming 128x128 vid-mem texture). W3DShroud *shroud; - if ((shroud=TheTerrainRenderObject->getShroud()) != 0) + if ((shroud=TheTerrainRenderObject->getShroud()) != nullptr) { - D3DXMATRIX inv; - float det; - - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMATRIX inv; + float det; + D3DXMatrixInverse(&inv, &det, &curView); D3DXMATRIX scale,offset; @@ -3347,8 +3345,8 @@ Int FlatTerrainShader2Stage::set(Int pass) width = 1.0f/(width*shroud->getTextureWidth()); height = 1.0f/(height*shroud->getTextureHeight()); D3DXMatrixScaling(&scale, width, height, 1); - *((D3DXMATRIX *)&curView) = (inv * offset) * scale; - DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0), *((Matrix4x4*)&curView)); + curView = (inv * offset) * scale; + DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0), curView); } } else { DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_COLOROP, D3DTOP_SELECTARG2 ); @@ -3371,7 +3369,7 @@ Int FlatTerrainShader2Stage::set(Int pass) break; case 1: // Noise/cloud pass - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); //these states apply to all noise/cloud combination passes @@ -3391,17 +3389,15 @@ Int FlatTerrainShader2Stage::set(Int pass) DX8Wrapper::Set_DX8_Render_State(D3DRS_SRCBLEND,D3DBLEND_DESTCOLOR); DX8Wrapper::Set_DX8_Render_State(D3DRS_DESTBLEND,D3DBLEND_ZERO); - D3DXMATRIX inv; float det; - - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMatrixInverse(&inv, &det, &curView); if (W3DShaderManager::getCurrentShader() == W3DShaderManager::ST_FLAT_TERRAIN_BASE_NOISE12) { //setup cloud pass - terrainShader2Stage.updateNoise1(((D3DXMATRIX*)&curView),&inv); //update curView with texture matrix + terrainShader2Stage.updateNoise1(&curView,&inv); //update curView with texture matrix DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, curView); //clouds always need bilinear filtering DX8Wrapper::Set_DX8_Texture_Stage_State(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR); @@ -3410,7 +3406,7 @@ Int FlatTerrainShader2Stage::set(Int pass) //setup noise pass - terrainShader2Stage.updateNoise2(((D3DXMATRIX*)&curView),&inv); + terrainShader2Stage.updateNoise2(&curView,&inv); DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, curView); //noise always needs point/linear filtering. Why point!? DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MINFILTER, D3DTEXF_POINT); @@ -3434,7 +3430,7 @@ Int FlatTerrainShader2Stage::set(Int pass) if (W3DShaderManager::getCurrentShader() == W3DShaderManager::ST_FLAT_TERRAIN_BASE_NOISE1) { //setup cloud pass DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, W3DShaderManager::getShaderTexture(2)->Peek_D3D_Texture()); - terrainShader2Stage.updateNoise1(((D3DXMATRIX*)&curView),&inv); //update curView with texture matrix + terrainShader2Stage.updateNoise1(&curView,&inv); //update curView with texture matrix DX8Wrapper::Set_DX8_Texture_Stage_State(0, D3DTSS_MINFILTER, D3DTEXF_LINEAR); DX8Wrapper::Set_DX8_Texture_Stage_State(0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); } @@ -3442,14 +3438,14 @@ Int FlatTerrainShader2Stage::set(Int pass) { //setup noise pass DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, W3DShaderManager::getShaderTexture(3)->Peek_D3D_Texture()); - terrainShader2Stage.updateNoise2(((D3DXMATRIX*)&curView),&inv); //update curView with texture matrix + terrainShader2Stage.updateNoise2(&curView,&inv); //update curView with texture matrix DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MINFILTER, D3DTEXF_POINT); DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); } DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_COLOROP, D3DTOP_DISABLE ); DX8Wrapper::Set_DX8_Texture_Stage_State( 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); - DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, *((Matrix4x4*)&curView)); + DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE0, curView); } break; } @@ -3476,10 +3472,10 @@ Int FlatTerrainShaderPixelShader::shutdown(void) if (m_dwBaseNoise2PixelShader) DX8Wrapper::_Get_D3D_Device8()->DeletePixelShader(m_dwBaseNoise2PixelShader); - m_dwBasePixelShader=NULL; - m_dwBase0PixelShader=NULL; - m_dwBaseNoise1PixelShader=NULL; - m_dwBaseNoise2PixelShader=NULL; + m_dwBasePixelShader=0; + m_dwBase0PixelShader=0; + m_dwBaseNoise1PixelShader=0; + m_dwBaseNoise2PixelShader=0; return TRUE; } @@ -3589,13 +3585,12 @@ Int FlatTerrainShaderPixelShader::set(Int pass) //We need to scale so shroud texel stretches over one full terrain cell. Each texel //is 1/128 the size of full texture. (assuming 128x128 vid-mem texture). { - D3DXMATRIX inv; - float det; - - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMATRIX inv; + float det; + D3DXMatrixInverse(&inv, &det, &curView); D3DXMATRIX scale,offset; @@ -3618,8 +3613,8 @@ Int FlatTerrainShaderPixelShader::set(Int pass) width = 1.0f/(width*shroud->getTextureWidth()); height = 1.0f/(height*shroud->getTextureHeight()); D3DXMatrixScaling(&scale, width, height, 1); - *((D3DXMATRIX *)&curView) = (inv * offset) * scale; - DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+curStage), *((Matrix4x4*)&curView)); + curView = (inv * offset) * scale; + DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+curStage), curView); } DX8Wrapper::Set_DX8_Texture_Stage_State( curStage, D3DTSS_ADDRESSU, D3DTADDRESS_CLAMP); DX8Wrapper::Set_DX8_Texture_Stage_State( curStage, D3DTSS_ADDRESSV, D3DTADDRESS_CLAMP); @@ -3633,12 +3628,12 @@ Int FlatTerrainShaderPixelShader::set(Int pass) Bool doNoise1 = (W3DShaderManager::getCurrentShader() == W3DShaderManager::ST_FLAT_TERRAIN_BASE_NOISE1 || W3DShaderManager::getCurrentShader() == W3DShaderManager::ST_FLAT_TERRAIN_BASE_NOISE12); if (doNoise1) { // Cloud pass. - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); D3DXMATRIX inv; float det; - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMatrixInverse(&inv, &det, &curView); DX8Wrapper::Set_DX8_Texture_Stage_State(curStage, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION); // Two output coordinates are used. @@ -3647,8 +3642,8 @@ Int FlatTerrainShaderPixelShader::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State(curStage, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); DX8Wrapper::Set_DX8_Texture_Stage_State(curStage, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); DX8Wrapper::_Get_D3D_Device8()->SetTexture(curStage, W3DShaderManager::getShaderTexture(2)->Peek_D3D_Texture()); - terrainShader2Stage.updateNoise1(((D3DXMATRIX*)&curView),&inv); //update curView with texture matrix - DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+curStage), *((Matrix4x4*)&curView)); + terrainShader2Stage.updateNoise1(&curView,&inv); //update curView with texture matrix + DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+curStage), curView); DX8Wrapper::Set_DX8_Texture_Stage_State(curStage, D3DTSS_MINFILTER, D3DTEXF_LINEAR); DX8Wrapper::Set_DX8_Texture_Stage_State(curStage, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); @@ -3660,12 +3655,12 @@ Int FlatTerrainShaderPixelShader::set(Int pass) W3DShaderManager::getCurrentShader() == W3DShaderManager::ST_FLAT_TERRAIN_BASE_NOISE12); if (doNoise2) { - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); D3DXMATRIX inv; float det; - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMatrixInverse(&inv, &det, &curView); DX8Wrapper::Set_DX8_Texture_Stage_State(curStage, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEPOSITION); // Two output coordinates are used. @@ -3674,8 +3669,8 @@ Int FlatTerrainShaderPixelShader::set(Int pass) DX8Wrapper::Set_DX8_Texture_Stage_State(curStage, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); DX8Wrapper::Set_DX8_Texture_Stage_State(curStage, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); DX8Wrapper::_Get_D3D_Device8()->SetTexture(curStage, W3DShaderManager::getShaderTexture(3)->Peek_D3D_Texture()); - terrainShader2Stage.updateNoise2(((D3DXMATRIX*)&curView),&inv); //update curView with texture matrix - DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+curStage), *((Matrix4x4*)&curView)); + terrainShader2Stage.updateNoise2(&curView,&inv); //update curView with texture matrix + DX8Wrapper::_Set_DX8_Transform((D3DTRANSFORMSTATETYPE )(D3DTS_TEXTURE0+curStage), curView); DX8Wrapper::Set_DX8_Texture_Stage_State(curStage, D3DTSS_MINFILTER, D3DTEXF_LINEAR); DX8Wrapper::Set_DX8_Texture_Stage_State(curStage, D3DTSS_MAGFILTER, D3DTEXF_LINEAR); @@ -3699,13 +3694,13 @@ Int FlatTerrainShaderPixelShader::set(Int pass) void FlatTerrainShaderPixelShader::reset(void) { - DX8Wrapper::_Get_D3D_Device8()->SetTexture(2,NULL); //release reference to any texture - DX8Wrapper::_Get_D3D_Device8()->SetTexture(3,NULL); //release reference to any texture + DX8Wrapper::_Get_D3D_Device8()->SetTexture(2,nullptr); //release reference to any texture + DX8Wrapper::_Get_D3D_Device8()->SetTexture(3,nullptr); //release reference to any texture DX8Wrapper::_Get_D3D_Device8()->SetPixelShader(0); //turn off pixel shader - DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, NULL); - DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, NULL); + DX8Wrapper::_Get_D3D_Device8()->SetTexture(0, nullptr); + DX8Wrapper::_Get_D3D_Device8()->SetTexture(1, nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); DX8Wrapper::Set_DX8_Texture_Stage_State( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU|0); diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp index d11d305123f..bc21f22e6d6 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp @@ -42,7 +42,7 @@ #include "WW3D2/sortingrenderer.h" -SmudgeManager *TheSmudgeManager=NULL; +SmudgeManager *TheSmudgeManager=nullptr; W3DSmudgeManager::W3DSmudgeManager(void) { @@ -133,8 +133,8 @@ void W3DSmudgeManager::ReAcquireResources(void) /*Copies a portion of the current render target into a specified buffer*/ Int copyRect(unsigned char *buf, Int bufSize, int oX, int oY, int width, int height) { - IDirect3DSurface8 *surface=NULL; ///LockRect(&lrect,NULL,D3DLOCK_READONLY); + hr=tempSurface->LockRect(&lrect,nullptr,D3DLOCK_READONLY); if (hr != S_OK) goto error; @@ -224,7 +224,7 @@ Bool W3DSmudgeManager::testHardwareSupport(void) shader.Set_Depth_Compare(ShaderClass::PASS_ALWAYS); shader.Set_Depth_Mask(ShaderClass::DEPTH_WRITE_DISABLE); DX8Wrapper::Set_Shader(shader); - DX8Wrapper::Set_Texture(0,NULL); + DX8Wrapper::Set_Texture(0,nullptr); DX8Wrapper::Apply_Render_State_Changes(); //force update of view and projection matrices struct _TRANS_LIT_TEX_VERTEX { diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSnow.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSnow.cpp index bed66d1c65d..370fac9d7c9 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSnow.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSnow.cpp @@ -39,9 +39,9 @@ struct POINTVERTEX W3DSnowManager::W3DSnowManager(void) { - m_indexBuffer=NULL; - m_snowTexture=NULL; - m_VertexBufferD3D=NULL; + m_indexBuffer=nullptr; + m_snowTexture=nullptr; + m_VertexBufferD3D=nullptr; } W3DSnowManager::~W3DSnowManager() @@ -63,7 +63,7 @@ void W3DSnowManager::ReleaseResources(void) if (m_VertexBufferD3D) m_VertexBufferD3D->Release(); - m_VertexBufferD3D=NULL; + m_VertexBufferD3D=nullptr; REF_PTR_RELEASE(m_indexBuffer); } @@ -80,9 +80,9 @@ Bool W3DSnowManager::ReAcquireResources(void) { LPDIRECT3DDEVICE8 m_pDev=DX8Wrapper::_Get_D3D_Device8(); - DEBUG_ASSERTCRASH(m_pDev, ("Trying to ReAquireResources on W3DSnowManager without device")); + DEBUG_ASSERTCRASH(m_pDev, ("Trying to ReAcquireResources on W3DSnowManager without device")); - if (m_VertexBufferD3D == NULL) + if (m_VertexBufferD3D == nullptr) { // Create vertex buffer if (FAILED(m_pDev->CreateVertexBuffer diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainBackground.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainBackground.cpp index d7691c63168..57413590474 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainBackground.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainBackground.cpp @@ -45,6 +45,7 @@ //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- + #include "W3DDevice/GameClient/W3DTerrainBackground.h" #include @@ -83,7 +84,7 @@ const Int PIXELS_PER_GRID = 8; // default tex resolution allocated for each tile //============================================================================= void W3DTerrainBackground::setFlip(WorldHeightMap *htMap) { - if (m_map==NULL) return; + if (m_map==nullptr) return; if (htMap) { REF_PTR_SET(m_map, htMap); } @@ -107,7 +108,7 @@ The vertex coordinates and texture coordinates, as well as static lighting are u */ void W3DTerrainBackground::doPartialUpdate(const IRegion2D &partialRange, WorldHeightMap *htMap, Bool doTextures ) { - if (m_map==NULL) return; + if (m_map==nullptr) return; if (htMap) { REF_PTR_SET(m_map, htMap); } @@ -120,7 +121,7 @@ void W3DTerrainBackground::doPartialUpdate(const IRegion2D &partialRange, WorldH return; Int requiredVertexSize = (m_width+1) * (m_width+1) + 6; - if (m_vertexTerrainSizegetFlatTexture(m_xOrigin, m_yOrigin, m_width, 4*PIXELS_PER_GRID); m_terrainTexture4X->Get_Filter().Set_U_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); m_terrainTexture4X->Get_Filter().Set_V_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); } } else if (m_texMultiplier == TEX2X) { REF_PTR_RELEASE(m_terrainTexture4X); - if (m_terrainTexture2X == NULL) { + if (m_terrainTexture2X == nullptr) { m_terrainTexture2X = m_map->getFlatTexture(m_xOrigin, m_yOrigin, m_width, 2*PIXELS_PER_GRID); m_terrainTexture2X->Get_Filter().Set_U_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); m_terrainTexture2X->Get_Filter().Set_V_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp index 83a391b5d78..d49ead1e582 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainTracks.cpp @@ -79,7 +79,7 @@ TerrainTracksRenderObjClass::~TerrainTracksRenderObjClass(void) //============================================================================= TerrainTracksRenderObjClass::TerrainTracksRenderObjClass(void) { - m_stageZeroTexture=NULL; + m_stageZeroTexture=nullptr; m_lastAnchor=Vector3(0,1,2.25); m_haveAnchor=false; m_haveCap=true; @@ -88,7 +88,7 @@ TerrainTracksRenderObjClass::TerrainTracksRenderObjClass(void) m_activeEdgeCount=0; m_totalEdgesAdded=0; m_bound=false; - m_ownerDrawable = NULL; + m_ownerDrawable = nullptr; } //============================================================================= @@ -129,7 +129,7 @@ Int TerrainTracksRenderObjClass::Class_ID(void) const RenderObjClass * TerrainTracksRenderObjClass::Clone(void) const { assert(false); - return NULL; + return nullptr; } //============================================================================= @@ -146,7 +146,7 @@ Int TerrainTracksRenderObjClass::freeTerrainTracksResources(void) m_bottomIndex=0; m_activeEdgeCount=0; m_totalEdgesAdded=0; - m_ownerDrawable = NULL; + m_ownerDrawable = nullptr; return 0; } @@ -455,7 +455,7 @@ static Real computeTrackSpacing(RenderObjClass *renderObj) //============================================================================= //TerrainTracksRenderObjClassSystem::bindTrack //============================================================================= -/** Grab a track from the free store. If no free tracks exist, return NULL. +/** Grab a track from the free store. If no free tracks exist, return null. As long as a track is bound to an object (like a tank) it is ready to accept updates with additional edges. Once it is unbound, it will expire and return to the free store once all tracks have faded out. @@ -482,7 +482,7 @@ TerrainTracksRenderObjClass *TerrainTracksRenderObjClassSystem::bindTrack( Rende m_freeModules = mod->m_nextSystem; // put module on the used list - mod->m_prevSystem = NULL; + mod->m_prevSystem = nullptr; mod->m_nextSystem = m_usedModules; if( m_usedModules ) m_usedModules->m_prevSystem = mod; @@ -510,7 +510,7 @@ void TerrainTracksRenderObjClassSystem::unbindTrack( TerrainTracksRenderObjClass //this object should return to free store as soon as there is nothing //left to render. mod->m_bound=false; - mod->m_ownerDrawable = NULL; + mod->m_ownerDrawable = nullptr; } //============================================================================= @@ -520,7 +520,7 @@ void TerrainTracksRenderObjClassSystem::unbindTrack( TerrainTracksRenderObjClass */ void TerrainTracksRenderObjClassSystem::releaseTrack( TerrainTracksRenderObjClass *mod ) { - if (mod==NULL) + if (mod==nullptr) return; DEBUG_ASSERTCRASH(mod->m_bound == false, ("mod is bound.")); @@ -534,7 +534,7 @@ void TerrainTracksRenderObjClassSystem::releaseTrack( TerrainTracksRenderObjClas m_usedModules = mod->m_nextSystem; // add module to free list - mod->m_prevSystem = NULL; + mod->m_prevSystem = nullptr; mod->m_nextSystem = m_freeModules; if( m_freeModules ) m_freeModules->m_prevSystem = mod; @@ -550,13 +550,13 @@ void TerrainTracksRenderObjClassSystem::releaseTrack( TerrainTracksRenderObjClas //============================================================================= TerrainTracksRenderObjClassSystem::TerrainTracksRenderObjClassSystem() { - m_usedModules = NULL; - m_freeModules = NULL; - m_TerrainTracksScene = NULL; + m_usedModules = nullptr; + m_freeModules = nullptr; + m_TerrainTracksScene = nullptr; m_edgesToFlush = 0; - m_indexBuffer = NULL; - m_vertexMaterialClass = NULL; - m_vertexBuffer = NULL; + m_indexBuffer = nullptr; + m_vertexMaterialClass = nullptr; + m_vertexBuffer = nullptr; m_maxTankTrackEdges=TheGlobalData->m_maxTankTrackEdges; m_maxTankTrackOpaqueEdges=TheGlobalData->m_maxTankTrackOpaqueEdges; @@ -574,8 +574,8 @@ TerrainTracksRenderObjClassSystem::~TerrainTracksRenderObjClassSystem( void ) // free all data shutdown(); - m_vertexMaterialClass=NULL; - m_TerrainTracksScene=NULL; + m_vertexMaterialClass=nullptr; + m_TerrainTracksScene=nullptr; } @@ -666,7 +666,7 @@ void TerrainTracksRenderObjClassSystem::init( SceneClass *TerrainTracksScene ) mod = NEW_REF( TerrainTracksRenderObjClass, () ); - if( mod == NULL ) + if( mod == nullptr ) { // unable to allocate modules needed @@ -675,7 +675,7 @@ void TerrainTracksRenderObjClassSystem::init( SceneClass *TerrainTracksScene ) } - mod->m_prevSystem = NULL; + mod->m_prevSystem = nullptr; mod->m_nextSystem = m_freeModules; if( m_freeModules ) m_freeModules->m_prevSystem = mod; @@ -709,7 +709,7 @@ void TerrainTracksRenderObjClassSystem::shutdown( void ) // free all attached things and used modules - assert( m_usedModules == NULL ); + assert( m_usedModules == nullptr ); // free all module storage while( m_freeModules ) @@ -895,8 +895,7 @@ Try improving the fit to vertical surfaces like cliffs. trackStartIndex=0; mod=m_usedModules; - Matrix3D tm(mod->Transform); - DX8Wrapper::Set_Transform(D3DTS_WORLD,tm); + DX8Wrapper::Set_Transform(D3DTS_WORLD,mod->Transform); while (mod) { if (mod->m_activeEdgeCount >= 2 && mod->Is_Really_Visible()) @@ -930,7 +929,7 @@ void TerrainTracksRenderObjClassSystem::Reset(void) // free all attached things and used modules - assert( m_usedModules == NULL ); + assert( m_usedModules == nullptr ); m_edgesToFlush=0; } @@ -971,4 +970,4 @@ void TerrainTracksRenderObjClassSystem::setDetail(void) ReAcquireResources(); }; -TerrainTracksRenderObjClassSystem *TheTerrainTracksRenderObjClassSystem=NULL; ///< singleton for track drawing system. +TerrainTracksRenderObjClassSystem *TheTerrainTracksRenderObjClassSystem=nullptr; ///< singleton for track drawing system. diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp index 770315f0f40..9c4c0c2dcd8 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTerrainVisual.cpp @@ -75,7 +75,7 @@ class TestSeismicFilter : public SeismicSimulationFilterBase Int life = node->m_life; - if ( heightMap == NULL ) + if ( heightMap == nullptr ) return SEISMIC_STATUS_INVALID; @@ -159,14 +159,14 @@ static TestSeismicFilter testSeismicFilter; W3DTerrainVisual::W3DTerrainVisual() { - m_terrainRenderObject = NULL; - m_waterRenderObject = NULL; - TheWaterRenderObj = NULL; + m_terrainRenderObject = nullptr; + m_waterRenderObject = nullptr; + TheWaterRenderObj = nullptr; - m_logicHeightMap = NULL; + m_logicHeightMap = nullptr; #ifdef DO_SEISMIC_SIMULATIONS - m_clientHeightMap = NULL; + m_clientHeightMap = nullptr; #endif } @@ -177,20 +177,20 @@ W3DTerrainVisual::~W3DTerrainVisual() { // release our render object if (TheTerrainRenderObject == m_terrainRenderObject) { - TheTerrainRenderObject = NULL; + TheTerrainRenderObject = nullptr; } delete TheTerrainTracksRenderObjClassSystem; - TheTerrainTracksRenderObjClassSystem=NULL; + TheTerrainTracksRenderObjClassSystem=nullptr; delete TheW3DShadowManager; - TheW3DShadowManager=NULL; + TheW3DShadowManager=nullptr; delete TheSmudgeManager; - TheSmudgeManager=NULL; + TheSmudgeManager=nullptr; REF_PTR_RELEASE( m_waterRenderObject ); - TheWaterRenderObj=NULL; + TheWaterRenderObj=nullptr; REF_PTR_RELEASE( m_terrainRenderObject ); REF_PTR_RELEASE( m_logicHeightMap ); @@ -251,19 +251,19 @@ void W3DTerrainVisual::init( void ) // set the vertex animated water properties Int waterSettingIndex = 0; // use index 0 settings by default - TheTerrainVisual->setWaterGridHeightClamps( NULL, + TheTerrainVisual->setWaterGridHeightClamps( nullptr, TheGlobalData->m_vertexWaterHeightClampLow[ waterSettingIndex ], TheGlobalData->m_vertexWaterHeightClampHi[ waterSettingIndex ] ); - TheTerrainVisual->setWaterTransform( NULL, + TheTerrainVisual->setWaterTransform( nullptr, TheGlobalData->m_vertexWaterAngle[ waterSettingIndex ], TheGlobalData->m_vertexWaterXPosition[ waterSettingIndex ], TheGlobalData->m_vertexWaterYPosition[ waterSettingIndex ], TheGlobalData->m_vertexWaterZPosition[ waterSettingIndex ] ); - TheTerrainVisual->setWaterGridResolution( NULL, + TheTerrainVisual->setWaterGridResolution( nullptr, TheGlobalData->m_vertexWaterXGridCells[ waterSettingIndex ], TheGlobalData->m_vertexWaterYGridCells[ waterSettingIndex ], TheGlobalData->m_vertexWaterGridSize[ waterSettingIndex ] ); - TheTerrainVisual->setWaterAttenuationFactors( NULL, + TheTerrainVisual->setWaterAttenuationFactors( nullptr, TheGlobalData->m_vertexWaterAttenuationA[ waterSettingIndex ], TheGlobalData->m_vertexWaterAttenuationB[ waterSettingIndex ], TheGlobalData->m_vertexWaterAttenuationC[ waterSettingIndex ], @@ -446,13 +446,13 @@ void W3DTerrainVisual::handleSeismicSimulations( void ) void W3DTerrainVisual::updateSeismicSimulations( void ) { - if (m_logicHeightMap==NULL) + if (m_logicHeightMap==nullptr) return; - if (m_clientHeightMap==NULL) + if (m_clientHeightMap==nullptr) return; - if (m_terrainRenderObject==NULL) + if (m_terrainRenderObject==nullptr) return; if ( ! m_seismicSimulationList.empty() ) @@ -548,7 +548,7 @@ Bool W3DTerrainVisual::load( AsciiString filename ) } - if( m_terrainRenderObject == NULL ) + if( m_terrainRenderObject == nullptr ) return FALSE; @@ -579,7 +579,7 @@ Bool W3DTerrainVisual::load( AsciiString filename ) Coord3D loc = *pMapObj->getLocation(); if (loc.z < 0) { Vector3 vec; - loc.z = m_terrainRenderObject->getHeightMapHeight(loc.x, loc.y, NULL); + loc.z = m_terrainRenderObject->getHeightMapHeight(loc.x, loc.y, nullptr); loc.z += d->getReal(TheKey_lightHeightAboveTerrain); } // It is a light, and handled at the device level. jba. @@ -602,7 +602,7 @@ Bool W3DTerrainVisual::load( AsciiString filename ) } - RefRenderObjListIterator *it = W3DDisplay::m_3DScene ? W3DDisplay::m_3DScene->createLightsIterator() : NULL; + RefRenderObjListIterator *it = W3DDisplay::m_3DScene ? W3DDisplay::m_3DScene->createLightsIterator() : nullptr; // apply the heightmap to the terrain render object #ifdef DO_SEISMIC_SIMULATIONS @@ -620,17 +620,17 @@ Bool W3DTerrainVisual::load( AsciiString filename ) if (it) { W3DDisplay::m_3DScene->destroyLightsIterator(it); - it = NULL; + it = nullptr; } // add our terrain render object to the scene - if (W3DDisplay::m_3DScene != NULL) + if (W3DDisplay::m_3DScene != nullptr) W3DDisplay::m_3DScene->Add_Render_Object( m_terrainRenderObject ); #if defined(RTS_DEBUG) // Icon drawing utility object for pathfinding. - if (W3DDisplay::m_3DScene != NULL) + if (W3DDisplay::m_3DScene != nullptr) { - W3DDebugIcons *icons = NEW W3DDebugIcons; + W3DDebugIcons *icons = NEW W3DDebugIcons(m_logicHeightMap->getXExtent(), m_logicHeightMap->getYExtent()); W3DDisplay::m_3DScene->Add_Render_Object( icons ); icons->Release_Ref(); // belongs to scene. } @@ -696,7 +696,7 @@ Bool W3DTerrainVisual::intersectTerrain( Coord3D *rayStart, Bool hit = FALSE; // sanity - if( rayStart == NULL || rayEnd == NULL ) + if( rayStart == nullptr || rayEnd == nullptr ) return hit; if( m_terrainRenderObject ) @@ -743,7 +743,7 @@ void W3DTerrainVisual::getTerrainColorAt( Real x, Real y, RGBColor *pColor ) //------------------------------------------------------------------------------------------------- TerrainType *W3DTerrainVisual::getTerrainTile( Real x, Real y ) { - TerrainType *tile = NULL; + TerrainType *tile = nullptr; #ifdef DO_SEISMIC_SIMULATIONS if( m_clientHeightMap ) @@ -905,7 +905,7 @@ void W3DTerrainVisual::setRawMapHeight(const ICoord2D *gridPos, Int height) if ( m_clientHeightMap ) { if ( height < m_clientHeightMap->getHeight( x,y ) ) - m_clientHeightMap->setRawHeight( x, y, height ); // if the client map is heigher than this height, it will fall down to it anyway! + m_clientHeightMap->setRawHeight( x, y, height ); // if the client map is higher than this height, it will fall down to it anyway! } #endif @@ -1079,7 +1079,7 @@ void W3DTerrainVisual::addProp(const ThingTemplate *tTemplate, const Coord3D *po if (mi.getCount() > 0) { const ModuleData* mdd = mi.getNthData(0); - const W3DModelDrawModuleData* md = mdd ? mdd->getAsW3DModelDrawModuleData() : NULL; + const W3DModelDrawModuleData* md = mdd ? mdd->getAsW3DModelDrawModuleData() : nullptr; if (md) { modelName = md->getBestModelNameForWB(state); @@ -1189,7 +1189,7 @@ void W3DTerrainVisual::xfer( Xfer *xfer ) if( width != getGridWidth() ) { - DEBUG_CRASH(( "W3DTerainVisual::xfer - grid width mismatch '%d' should be '%d'", + DEBUG_CRASH(( "W3DTerrainVisual::xfer - grid width mismatch '%d' should be '%d'", width, getGridWidth() )); throw SC_INVALID_DATA; @@ -1197,7 +1197,7 @@ void W3DTerrainVisual::xfer( Xfer *xfer ) if( height != getGridHeight() ) { - DEBUG_CRASH(( "W3DTerainVisual::xfer - grid height mismatch '%d' should be '%d'", + DEBUG_CRASH(( "W3DTerrainVisual::xfer - grid height mismatch '%d' should be '%d'", height, getGridHeight() )); throw SC_INVALID_DATA; diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp index 1b5ba203361..99e3588ff3a 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DTreeBuffer.cpp @@ -54,6 +54,7 @@ enum //----------------------------------------------------------------------------- // Includes //----------------------------------------------------------------------------- + #include "W3DDevice/GameClient/W3DTreeBuffer.h" #include @@ -137,7 +138,7 @@ int W3DTreeBuffer::W3DTreeTextureClass::update(W3DTreeBuffer *buffer) DX8_ErrorCode(Peek_D3D_Texture()->GetSurfaceLevel(0, &surface_level)); DX8_ErrorCode(surface_level->GetDesc(&surface_desc)); - DX8_ErrorCode(surface_level->LockRect(&locked_rect, NULL, 0)); + DX8_ErrorCode(surface_level->LockRect(&locked_rect, nullptr, 0)); Int tilePixelExtent = TILE_PIXEL_EXTENT; // Int numRows = surface_desc.Height/(tilePixelExtent+TILE_OFFSET); @@ -188,7 +189,7 @@ 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)); + DX8_ErrorCode(D3DXFilterTexture(Peek_D3D_Texture(), nullptr, (UINT)0, D3DX_FILTER_BOX)); if (WW3D::Get_Texture_Reduction()) { DX8_ErrorCode(Peek_D3D_Texture()->SetLOD((DWORD)WW3D::Get_Texture_Reduction())); } @@ -297,7 +298,7 @@ void W3DTreeBuffer::cull(const CameraClass * camera) { Int curTree; - // Calulate the vector direction that the camera is looking at. + // Calculate the vector direction that the camera is looking at. Matrix3D camera_matrix = camera->Get_Transform(); float zmod = -1; float x = zmod * camera_matrix[0][2] ; @@ -418,7 +419,7 @@ class GDIFileStream2 : public InputStream protected: File* m_file; public: - GDIFileStream2():m_file(NULL) {}; + GDIFileStream2():m_file(nullptr) {}; GDIFileStream2(File* pFile):m_file(pFile) {}; virtual Int read(void *pData, Int numBytes) { return(m_file?m_file->read(pData, numBytes):0); @@ -453,17 +454,17 @@ void W3DTreeBuffer::updateTexture(void) REF_PTR_RELEASE (m_sourceTiles[i]); } m_numTiles = 0; - File *theFile = NULL; + File *theFile = nullptr; for (i=0; im_textureName.str() ); + snprintf( texturePath, ARRAY_SIZE(texturePath), "%s%s", TERRAIN_TGA_DIR_PATH, m_treeTypes[i].m_data->m_textureName.str() ); theFile = TheFileSystem->openFile( texturePath, File::READ|File::BINARY); - if (theFile==NULL) { - sprintf( texturePath, "%s%s", TGA_DIR_PATH, m_treeTypes[i].m_data->m_textureName.str() ); + if (theFile==nullptr) { + snprintf( texturePath, ARRAY_SIZE(texturePath), "%s%s", TGA_DIR_PATH, m_treeTypes[i].m_data->m_textureName.str() ); theFile = TheFileSystem->openFile( texturePath, File::READ|File::BINARY); } - if (theFile != NULL) { + if (theFile != nullptr) { GDIFileStream2 theStream(theFile); InputStream *pStr = &theStream; Bool halfTile; @@ -521,7 +522,7 @@ void W3DTreeBuffer::updateTexture(void) if (m_textureWidth>MAX_TEX_WIDTH) { m_textureWidth = 64; m_textureHeight = 64; - if (m_treeTexture==NULL) { + if (m_treeTexture==nullptr) { m_treeTexture = new TextureClass("missing.tga"); } DEBUG_CRASH(("Too many trees in a scene.")); @@ -694,16 +695,13 @@ void W3DTreeBuffer::loadTreesInVertexAndIndexBuffers(RefRenderObjListIterator *p return; } - if (m_shadow == NULL && TheW3DProjectedShadowManager) { + if (m_shadow == nullptr && TheW3DProjectedShadowManager) { Shadow::ShadowTypeInfo shadowInfo; - shadowInfo.m_ShadowName[0] = 0; shadowInfo.allowUpdates=FALSE; //shadow image will never update shadowInfo.allowWorldAlign=TRUE; //shadow image will wrap around world objects shadowInfo.m_type = (ShadowType)SHADOW_DECAL; shadowInfo.m_sizeX=20; shadowInfo.m_sizeY=20; - shadowInfo.m_offsetX=0; - shadowInfo.m_offsetY=0; m_shadow = TheW3DProjectedShadowManager->createDecalShadow(&shadowInfo); } @@ -751,7 +749,7 @@ void W3DTreeBuffer::loadTreesInVertexAndIndexBuffers(RefRenderObjListIterator *p Vector3 loc = m_trees[curTree].location; Real theSin = m_trees[curTree].sin; Real theCos = m_trees[curTree].cos; - if (type<0 || m_treeTypes[type].m_mesh == 0) { + if (type<0 || m_treeTypes[type].m_mesh == nullptr) { continue; } @@ -806,7 +804,7 @@ void W3DTreeBuffer::loadTreesInVertexAndIndexBuffers(RefRenderObjListIterator *p const unsigned *vecDiffuse = m_treeTypes[type].m_mesh->Peek_Model()->Get_Color_Array(0, false); Int diffuse = 0; - if (normals == NULL) { + if (normals == nullptr) { doVertexLighting = false; Vector3 normal(0.0f,0.0f,1.0f); diffuse = doLighting(&normal, objectLighting, &emissive, 0xFFFFFFFF, 1.0f); @@ -824,7 +822,7 @@ void W3DTreeBuffer::loadTreesInVertexAndIndexBuffers(RefRenderObjListIterator *p } // panel start is index offset, there are 3 index per triangle. if (m_trees[curTree].panelStart/3 + 2 > numIndex) { - continue; // not enought polygons for the offset. jba. + continue; // not enough polygons for the offset. jba. } for (j=0; j<6; j++) { i = ((Int *)pPoly)[j+m_trees[curTree].panelStart]; @@ -1014,7 +1012,7 @@ void W3DTreeBuffer::updateVertexBuffer(void) Vector3 loc = m_trees[curTree].location; Real theSin = m_trees[curTree].sin; Real theCos = m_trees[curTree].cos; - if (type<0 || m_treeTypes[type].m_mesh == 0) { + if (type<0 || m_treeTypes[type].m_mesh == nullptr) { type = 0; } @@ -1078,7 +1076,7 @@ W3DTreeBuffer::~W3DTreeBuffer(void) } delete m_shadow; - m_shadow = NULL; + m_shadow = nullptr; } //============================================================================= @@ -1092,12 +1090,12 @@ W3DTreeBuffer::W3DTreeBuffer(void) m_initialized = false; Int i; for (i=0; iCreate_Render_Obj(data->m_modelName.str()); - if (robj==NULL) { + if (robj==nullptr) { DEBUG_CRASH(("Unable to find model for tree %s", data->m_modelName.str())); return 0; } @@ -1357,7 +1355,7 @@ Int W3DTreeBuffer::addTreeType(const W3DTreeDrawModuleData *data) if (robj->Class_ID() == RenderObjClass::CLASSID_MESH) m_treeTypes[m_numTreeTypes].m_mesh = (MeshClass*)robj; - if (m_treeTypes[m_numTreeTypes].m_mesh==NULL) { + if (m_treeTypes[m_numTreeTypes].m_mesh==nullptr) { DEBUG_CRASH(("Tree %s is not simple mesh. Tell artist to re-export. Don't Ignore!!!", data->m_modelName.str())); return 0; } @@ -1565,7 +1563,7 @@ void W3DTreeBuffer::drawTrees(CameraClass * camera, RefRenderObjListIterator *pD m_needToUpdateTexture = false; updateTexture(); } - if (m_treeTexture==NULL) { + if (m_treeTexture==nullptr) { return; } if (m_updateAllKeys) { @@ -1707,7 +1705,7 @@ void W3DTreeBuffer::drawTrees(CameraClass * camera, RefRenderObjListIterator *pD DX8Wrapper::Set_Shader(detailAlphaShader); DX8Wrapper::Set_Texture(0,m_treeTexture); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(1,nullptr); DX8Wrapper::Set_DX8_Texture_Stage_State(0, D3DTSS_TEXCOORDINDEX, 0); DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_TEXCOORDINDEX, 1); // Draw all the trees. @@ -1717,9 +1715,9 @@ void W3DTreeBuffer::drawTrees(CameraClass * camera, RefRenderObjListIterator *pD if (m_dwTreeVertexShader) { D3DXMATRIX matProj, matView, matWorld; - DX8Wrapper::_Get_DX8_Transform(D3DTS_WORLD, *(Matrix4x4*)&matWorld); - DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, *(Matrix4x4*)&matView); - DX8Wrapper::_Get_DX8_Transform(D3DTS_PROJECTION, *(Matrix4x4*)&matProj); + DX8Wrapper::_Get_DX8_Transform(D3DTS_WORLD, matWorld); + DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, matView); + DX8Wrapper::_Get_DX8_Transform(D3DTS_PROJECTION, matProj); D3DXMATRIX mat; D3DXMatrixMultiply( &mat, &matView, &matProj ); D3DXMatrixMultiply( &mat, &matWorld, &mat ); @@ -1737,7 +1735,7 @@ void W3DTreeBuffer::drawTrees(CameraClass * camera, RefRenderObjListIterator *pD } W3DShroud *shroud; - if ((shroud=TheTerrainRenderObject->getShroud()) != 0) { + if ((shroud=TheTerrainRenderObject->getShroud()) != nullptr) { // Setup shroud texture info [6/6/2003] float xoffset = 0; float yoffset = 0; @@ -1793,7 +1791,7 @@ void W3DTreeBuffer::drawTrees(CameraClass * camera, RefRenderObjListIterator *pD } DX8Wrapper::Set_Vertex_Shader(DX8_FVF_XYZNDUV1); - DX8Wrapper::Set_Pixel_Shader(NULL); + DX8Wrapper::Set_Pixel_Shader(0); DX8Wrapper::Invalidate_Cached_Render_States(); //code above mucks around with W3D states so make sure we reset } @@ -1924,7 +1922,9 @@ void W3DTreeBuffer::crc( Xfer *xfer ) // ------------------------------------------------------------------------------------------------ /** Xfer * Version Info: - * 1: Initial version */ + * 1: Initial version + * 2: TheSuperHackers @tweak Serialize sink frames as float instead of integer + */ // ------------------------------------------------------------------------------------------------ void W3DTreeBuffer::xfer( Xfer *xfer ) { diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DVideoBuffer.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DVideoBuffer.cpp index 6f190d0063f..7f41e93e62f 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DVideoBuffer.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DVideoBuffer.cpp @@ -103,8 +103,8 @@ W3DVideoBuffer::W3DVideoBuffer( VideoBuffer::Type format ) : VideoBuffer(format), - m_texture(NULL), - m_surface(NULL) + m_texture(nullptr), + m_surface(nullptr) { } @@ -129,17 +129,17 @@ Bool W3DVideoBuffer::allocate( UnsignedInt width, UnsignedInt height ) if ( w3dFormat == WW3D_FORMAT_UNKNOWN ) { - return NULL; + return FALSE; } m_texture = MSGNEW("TextureClass") TextureClass ( m_textureWidth, m_textureHeight, w3dFormat, MIP_LEVELS_1 ); - if ( m_texture == NULL ) + if ( m_texture == nullptr ) { return FALSE; } - if ( lock() == NULL ) + if ( lock() == nullptr ) { free(); return FALSE; @@ -166,9 +166,9 @@ W3DVideoBuffer::~W3DVideoBuffer() void* W3DVideoBuffer::lock( void ) { - void *mem = NULL; + void *mem = nullptr; - if ( m_surface != NULL ) + if ( m_surface != nullptr ) { unlock(); } @@ -189,11 +189,11 @@ void* W3DVideoBuffer::lock( void ) void W3DVideoBuffer::unlock( void ) { - if ( m_surface != NULL ) + if ( m_surface != nullptr ) { m_surface->Unlock(); m_surface->Release_Ref(); - m_surface = NULL; + m_surface = nullptr; } } @@ -203,7 +203,7 @@ void W3DVideoBuffer::unlock( void ) Bool W3DVideoBuffer::valid( void ) { - return m_texture != NULL; + return m_texture != nullptr; } //============================================================================ @@ -218,9 +218,9 @@ void W3DVideoBuffer::free( void ) { unlock(); m_texture->Release_Ref(); - m_texture = NULL; + m_texture = nullptr; } - m_surface = NULL; + m_surface = nullptr; VideoBuffer::free(); } diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp index 62a650b5934..2182a83163a 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DView.cpp @@ -37,11 +37,14 @@ #include // USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// +#include "Lib/BaseType.h" + #include "Common/BuildAssistant.h" #include "Common/FramePacer.h" #include "Common/GameUtility.h" #include "Common/GlobalData.h" #include "Common/Module.h" +#include "Common/Radar.h" #include "Common/RandomValue.h" #include "Common/ThingTemplate.h" #include "Common/ThingSort.h" @@ -95,21 +98,12 @@ #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 - when we have our own timer */ - - - // 30 fps 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 - - - - +constexpr const Real NearZ = MAP_XY_FACTOR; ///< Set the near to MAP_XY_FACTOR. Improves z buffer resolution. //================================================================================================= inline Real minf(Real a, Real b) { if (a < b) return a; else return b; } @@ -145,9 +139,9 @@ static Real getHeightAroundPos(Real x, Real y) W3DView::W3DView() { - m_3DCamera = NULL; - m_2DCamera = NULL; - m_groundLevel = 10.0; + m_3DCamera = nullptr; + m_2DCamera = nullptr; + m_groundLevel = 10.0f; m_cameraOffset.z = TheGlobalData->m_cameraHeight; m_cameraOffset.y = -(m_cameraOffset.z / tan(TheGlobalData->m_cameraPitch * (PI / 180.0))); m_cameraOffset.x = -(m_cameraOffset.y * tan(TheGlobalData->m_cameraYaw * (PI / 180.0))); @@ -162,7 +156,7 @@ W3DView::W3DView() m_freezeTimeForCameraMovement = false; m_cameraHasMovedSinceRequest = true; m_locationRequests.clear(); - m_locationRequests.reserve(MAX_REQUEST_CACHE_SIZE + 10); // This prevents the vector from ever re-allocing + m_locationRequests.reserve(MAX_REQUEST_CACHE_SIZE + 10); // This prevents the vector from ever re-allocating //Enhancements from CNC3 WST 4/15/2003. JSC Integrated 5/20/03. m_CameraArrivedAtWaypointOnPathFlag = false; // Scripts for polling camera reached targets @@ -172,6 +166,8 @@ W3DView::W3DView() m_shakerAngles.Y =0.0f; m_shakerAngles.Z =0.0f; + m_recalcCamera = false; + } //------------------------------------------------------------------------------------------------- @@ -197,6 +193,11 @@ void W3DView::setHeight(Int height) m_3DCamera->Get_Viewport(vMin,vMax); vMax.Y=(Real)(m_originY+height)/(Real)TheDisplay->getHeight(); m_3DCamera->Set_Viewport(vMin,vMax); + + // TheSuperHackers @bugfix Now recalculates the camera constraints because + // showing or hiding the control bar will change the viewable area. + m_cameraAreaConstraintsValid = false; + m_recalcCamera = true; } //------------------------------------------------------------------------------------------------- @@ -216,6 +217,9 @@ void W3DView::setWidth(Int width) //we want to maintain the same scale, so we'll need to adjust the fov. //default W3D fov for full-screen is 50 degrees. m_3DCamera->Set_View_Plane((Real)width/(Real)TheDisplay->getWidth()*DEG_TO_RADF(50.0f),-1); + + m_cameraAreaConstraintsValid = false; + m_recalcCamera = true; } //------------------------------------------------------------------------------------------------- @@ -257,68 +261,43 @@ void W3DView::buildCameraTransform( Matrix3D *transform ) pos.x += m_shakeOffset.x; pos.y += m_shakeOffset.y; - if (m_cameraConstraintValid) + if (m_cameraAreaConstraintsValid) { - pos.x = maxf(m_cameraConstraint.lo.x, pos.x); - pos.x = minf(m_cameraConstraint.hi.x, pos.x); - pos.y = maxf(m_cameraConstraint.lo.y, pos.y); - pos.y = minf(m_cameraConstraint.hi.y, pos.y); + pos.x = maxf(m_cameraAreaConstraints.lo.x, pos.x); + pos.x = minf(m_cameraAreaConstraints.hi.x, pos.x); + pos.y = maxf(m_cameraAreaConstraints.lo.y, pos.y); + pos.y = minf(m_cameraAreaConstraints.hi.y, pos.y); } + sourcePos.X = m_cameraOffset.x; + sourcePos.Y = m_cameraOffset.y; + sourcePos.Z = m_cameraOffset.z; + // set position of camera itself if (m_useRealZoomCam) //WST 10/10/2002 Real Zoom using FOV { - sourcePos.X = m_cameraOffset.x; - sourcePos.Y = m_cameraOffset.y; - sourcePos.Z = m_cameraOffset.z; - Real capped_zoom = zoom; - if (capped_zoom > 1.0f) - { - capped_zoom= 1.0f; - } - if (capped_zoom < MIN_CAPPED_ZOOM) - { - capped_zoom = MIN_CAPPED_ZOOM; - } - m_FOV = 50.0f * PI/180.0f * capped_zoom * capped_zoom; + Real cappedZoom = clamp(MIN_CAPPED_ZOOM, zoom, 1.0f); + m_FOV = DEG_TO_RADF(50.0f) * cappedZoom * cappedZoom; } else { - sourcePos.X = m_cameraOffset.x*zoom; - sourcePos.Y = m_cameraOffset.y*zoom; - sourcePos.Z = m_cameraOffset.z*zoom; - } - -#ifdef NOT_IN_USE - if (TheGlobalData->m_isOffsetCameraZ && TheTerrainLogic) - { - sourcePos.Z += TheTerrainLogic->getGroundHeight(pos.x, pos.y); - if (m_prevSourcePosZ != SOURCEPOS_INVALID) - { - const Real MAX_SPZ_VARIATION = 0.05f; - Real spzMin = m_prevSourcePosZ*(1.0-MAX_SPZ_VARIATION); - Real spzMax Coord3D center; - = m_prevSourcePosZ*(1.0+MAX_SPZ_VARIATION); - if (sourcePos.Z < spzMin) sourcePos.Z = spzMin; - if (sourcePos.Z > spzMax) sourcePos.Z = spzMax; - } - m_prevSourcePosZ = sourcePos.Z; + sourcePos.X *= zoom; + sourcePos.Y *= zoom; + sourcePos.Z *= zoom; } -#endif // camera looking at origin targetPos.X = 0; targetPos.Y = 0; targetPos.Z = 0; - - Real factor = 1.0 - (groundLevel/sourcePos.Z ); + const Real heightScale = 1.0f - (groundLevel / sourcePos.Z); // construct a matrix to rotate around the up vector by the given angle - Matrix3D angleTransform( Vector3( 0.0f, 0.0f, 1.0f ), angle ); + const Matrix3D angleTransform( Vector3( 0.0f, 0.0f, 1.0f ), angle ); // construct a matrix to rotate around the horizontal vector by the given angle - Matrix3D pitchTransform( Vector3( 1.0f, 0.0f, 0.0f ), pitch ); + const Matrix3D pitchTransform( Vector3( 1.0f, 0.0f, 0.0f ), pitch ); // rotate camera position (pitch, then angle) #ifdef ALLOW_TEMPORARIES @@ -328,50 +307,35 @@ void W3DView::buildCameraTransform( Matrix3D *transform ) pitchTransform.mulVector3(sourcePos); angleTransform.mulVector3(sourcePos); #endif - sourcePos *= factor; - // translate to current XY position - sourcePos.X += pos.x; - sourcePos.Y += pos.y; - sourcePos.Z += groundLevel; + sourcePos *= heightScale; + // set look at position targetPos.X += pos.x; targetPos.Y += pos.y; targetPos.Z += groundLevel; + // translate to world space + sourcePos += targetPos; + // do m_FXPitch adjustment. //WST Real height = sourcePos.Z - targetPos.Z; //WST height *= m_FXPitch; //WST targetPos.Z = sourcePos.Z - height; - // The following code moves camera down and pitch up when player zooms in. // Use scripts to switch to useRealZoomCam if (m_useRealZoomCam) { - Real pitch_adjust = 1.0f; + Real pitchAdjust = 1.0f; if (!TheDisplay->isLetterBoxed()) { - Real capped_zoom = zoom; - if (capped_zoom > 1.0f) - { - capped_zoom= 1.0f; - } - if (capped_zoom < MIN_CAPPED_ZOOM) - { - capped_zoom = MIN_CAPPED_ZOOM; - } - sourcePos.Z = sourcePos.Z * ( 0.5f + capped_zoom * 0.5f); // move camera down physically - pitch_adjust = capped_zoom; // adjust camera to pitch up + Real cappedZoom = clamp(MIN_CAPPED_ZOOM, zoom, 1.0f); + sourcePos.Z = sourcePos.Z * (0.5f + cappedZoom * 0.5f); // move camera down physically + pitchAdjust = cappedZoom; // adjust camera to pitch up } - m_FXPitch = 1.0f * (0.25f + pitch_adjust*0.75f); - } - - - // do fxPitch adjustment - if (m_useRealZoomCam) - { + m_FXPitch = 1.0f * (0.25f + pitchAdjust*0.75f); sourcePos.X = targetPos.X + ((sourcePos.X - targetPos.X) / m_FXPitch); sourcePos.Y = targetPos.Y + ((sourcePos.Y - targetPos.Y) / m_FXPitch); } @@ -387,9 +351,7 @@ void W3DView::buildCameraTransform( Matrix3D *transform ) #else if (m_FXPitch <= 1.0f) { - Real height = sourcePos.Z - targetPos.Z; - height *= m_FXPitch; - targetPos.Z = sourcePos.Z - height; + targetPos.Z = sourcePos.Z - ((sourcePos.Z - targetPos.Z) * m_FXPitch); } else { @@ -409,6 +371,7 @@ void W3DView::buildCameraTransform( Matrix3D *transform ) //WST 11/12/2002 New camera shaker system // TheSuperHackers @tweak The camera shaker is now decoupled from the render update. + // TheSuperHackers @todo Move Update_Camera_Shaker to the W3DView::update function. CameraShakerSystem.Timestep(TheFramePacer->getLogicTimeStepMilliseconds()); CameraShakerSystem.Update_Camera_Shaker(sourcePos, &m_shakerAngles); transform->Rotate_X(m_shakerAngles.X); @@ -425,10 +388,10 @@ void W3DView::buildCameraTransform( Matrix3D *transform ) // find object named m_cameraSlaveObjectName Object * obj = TheScriptEngine->getUnitNamed(m_cameraSlaveObjectName); - if (obj != NULL) { + if (obj != nullptr) { // dig out the drawable Drawable * draw = obj->getDrawable(); - if (draw != NULL) { + if (draw != nullptr) { // dig out the first draw module with an ObjectDrawInterface for (DrawModule ** dm = draw->getDrawModules(); *dm; ++dm) { @@ -461,8 +424,18 @@ void W3DView::buildCameraTransform( Matrix3D *transform ) } //------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -void W3DView::calcCameraConstraints() +/* +Note the following restrictions on camera constraints! + +-- they assume that all maps are height 'm_groundLevel' at the edges. + (since you need to add some "buffer" around the edges of your map + anyway, this shouldn't be an issue.) + +-- for angles/pitches other than zero, it may show boundaries. + since we currently plan the game to be restricted to this, + it shouldn't be an issue. +*/ +void W3DView::calcCameraAreaConstraints() { // const Matrix3D& cameraTransform = m_3DCamera->Get_Transform(); @@ -475,20 +448,7 @@ void W3DView::calcCameraConstraints() Region3D mapRegion; TheTerrainLogic->getExtent( &mapRegion ); - /* - Note the following restrictions on camera constraints! - - -- they assume that all maps are height 'm_groundLevel' at the edges. - (since you need to add some "buffer" around the edges of your map - anyway, this shouldn't be an issue.) - - -- for angles/pitches other than zero, it may show boundaries. - since we currently plan the game to be restricted to this, - it shouldn't be an issue. - - */ Real maxEdgeZ = m_groundLevel; -// const Real BORDER_FUDGE = MAP_XY_FACTOR * 1.414f; Coord3D center, bottom; ICoord2D screen; @@ -518,15 +478,23 @@ void W3DView::calcCameraConstraints() offset = -1000; // push out the constraints so we can look at staging areas. } - m_cameraConstraint.lo.x = mapRegion.lo.x + offset; - m_cameraConstraint.hi.x = mapRegion.hi.x - offset; - // this looks inverted, but is correct - m_cameraConstraint.lo.y = mapRegion.lo.y + offset; - m_cameraConstraint.hi.y = mapRegion.hi.y - offset; - m_cameraConstraintValid = true; + m_cameraAreaConstraints.lo.x = mapRegion.lo.x + offset; + m_cameraAreaConstraints.hi.x = mapRegion.hi.x - offset; + m_cameraAreaConstraints.lo.y = mapRegion.lo.y + offset; + m_cameraAreaConstraints.hi.y = mapRegion.hi.y - offset; + + m_cameraAreaConstraintsValid = true; } } +//------------------------------------------------------------------------------------------------- +Bool W3DView::isWithinCameraHeightConstraints() const +{ + const Bool isAboveMinHeight = m_currentHeightAboveGround >= m_minHeightAboveGround; + const Bool isBelowMaxHeight = m_currentHeightAboveGround <= m_maxHeightAboveGround; + return isAboveMinHeight && (isBelowMaxHeight || !TheGlobalData->m_enforceMaxCameraHeight); +} + //------------------------------------------------------------------------------------------------- /** Returns a world-space ray originating at a given screen pixel position and ending at the far clip plane for current camera. Screen coordinates @@ -534,10 +502,13 @@ void W3DView::calcCameraConstraints() //------------------------------------------------------------------------------------------------- void W3DView::getPickRay(const ICoord2D *screen, Vector3 *rayStart, Vector3 *rayEnd) { - Real logX,logY; + Real logX; + Real logY; + Real screenX = screen->x - m_originX; + Real screenY = screen->y - m_originY; //W3D Screen coordinates are -1 to 1, so we need to do some conversion: - PixelScreenToW3DLogicalScreen(screen->x - m_originX,screen->y - m_originY, &logX, &logY,getWidth(),getHeight()); + PixelScreenToW3DLogicalScreen(screenX, screenY, &logX, &logY, getWidth(), getHeight()); *rayStart = m_3DCamera->Get_Position(); //get camera location m_3DCamera->Un_Project(*rayEnd,Vector2(logX,logY)); //get world space point @@ -559,13 +530,9 @@ void W3DView::setCameraTransform( void ) return; m_cameraHasMovedSinceRequest = true; - Matrix3D cameraTransform( 1 ); + Matrix3D cameraTransform; - Real nearZ, farZ; - // m_3DCamera->Get_Clip_Planes(nearZ, farZ); - // Set the near to MAP_XY_FACTOR. Improves zbuffer resolution. - nearZ = MAP_XY_FACTOR; - farZ = 1200.0f; + Real farZ = 1200.0f; if (m_useRealZoomCam) //WST 10.19.2002 { @@ -576,36 +543,37 @@ void W3DView::setCameraTransform( void ) } else { - if ((TheGlobalData && TheGlobalData->m_drawEntireTerrain) || (m_FXPitch<0.95f || m_zoom>1.05)) + if ((TheGlobalData->m_drawEntireTerrain) || (m_FXPitch<0.95f || m_zoom>1.05)) { //need to extend far clip plane so entire terrain can be visible farZ *= MAP_XY_FACTOR; } } - m_3DCamera->Set_Clip_Planes(nearZ, farZ); #if defined(RTS_DEBUG) if (TheGlobalData->m_useCameraConstraints) #endif { - if (!m_cameraConstraintValid) + if (!m_cameraAreaConstraintsValid) { buildCameraTransform(&cameraTransform); m_3DCamera->Set_Transform( cameraTransform ); - calcCameraConstraints(); + calcCameraAreaConstraints(); } - DEBUG_ASSERTLOG(m_cameraConstraintValid,("*** cam constraints are not valid!!!")); + DEBUG_ASSERTLOG(m_cameraAreaConstraintsValid,("*** cam constraints are not valid!!!")); - if (m_cameraConstraintValid) + if (m_cameraAreaConstraintsValid) { Coord3D pos = *getPosition(); - pos.x = maxf(m_cameraConstraint.lo.x, pos.x); - pos.x = minf(m_cameraConstraint.hi.x, pos.x); - pos.y = maxf(m_cameraConstraint.lo.y, pos.y); - pos.y = minf(m_cameraConstraint.hi.y, pos.y); + pos.x = maxf(m_cameraAreaConstraints.lo.x, pos.x); + pos.x = minf(m_cameraAreaConstraints.hi.x, pos.x); + pos.y = maxf(m_cameraAreaConstraints.lo.y, pos.y); + pos.y = minf(m_cameraAreaConstraints.hi.y, pos.y); setPosition(&pos); } } + m_3DCamera->Set_Clip_Planes(NearZ, farZ); + #if defined(RTS_DEBUG) m_3DCamera->Set_View_Plane( m_FOV, -1 ); #endif @@ -616,13 +584,14 @@ void W3DView::setCameraTransform( void ) if (TheTerrainRenderObject) { - RefRenderObjListIterator *it = W3DDisplay::m_3DScene->createLightsIterator(); - TheTerrainRenderObject->updateCenter(m_3DCamera, it); - if (it) - { - W3DDisplay::m_3DScene->destroyLightsIterator(it); - it = NULL; - } + updateTerrain(); + } + + // TheSuperHackers @fix Notify the Radar about the changed view always. + // This way the radar view box should always be in sync with the camera view. + if (TheRadar) + { + TheRadar->notifyViewChanged(); } } @@ -633,7 +602,7 @@ void W3DView::init( void ) // extend View functionality View::init(); setName("W3DView"); - // set default camera "lookat" point + // set default camera "look at" point Coord3D pos; pos.x = 87.0f; pos.y = 77.0f; @@ -647,9 +616,6 @@ void W3DView::init( void ) // create our 3D camera m_3DCamera = NEW_REF( CameraClass, () ); - - setCameraTransform(); - // create our 2D camera for the GUI overlay m_2DCamera = NEW_REF( CameraClass, () ); m_2DCamera->Set_Position( Vector3( 0, 0, 1 ) ); @@ -658,10 +624,11 @@ void W3DView::init( void ) m_2DCamera->Set_View_Plane( min, max ); m_2DCamera->Set_Clip_Planes( 0.995f, 2.0f ); - m_cameraConstraintValid = false; + m_cameraAreaConstraintsValid = false; m_scrollAmountCutoff = TheGlobalData->m_scrollAmountCutoff; + m_recalcCamera = true; } //------------------------------------------------------------------------------------------------- @@ -757,7 +724,7 @@ void drawDebugCircle( const Coord3D & center, Real radius, Real width, Color col } } -void drawDrawableExtents( Drawable *draw, void *userData ); // FORWARD DECLARATION +static void drawDrawableExtents( Drawable *draw, void *userData ); // FORWARD DECLARATION // ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------ static void drawContainedDrawable( Object *obj, void *userData ) @@ -867,7 +834,7 @@ static void drawDrawableExtents( Drawable *draw, void *userData ) } -void drawAudioLocations( Drawable *draw, void *userData ); +static void drawAudioLocations( Drawable *draw, void *userData ); // ------------------------------------------------------------------------------------------------ // Helper for drawAudioLocations // ------------------------------------------------------------------------------------------------ @@ -899,13 +866,13 @@ static void drawAudioLocations( Drawable *draw, void *userData ) const ThingTemplate * thingTemplate = draw->getTemplate(); - if ( thingTemplate == NULL || thingTemplate->getEditorSorting() != ES_AUDIO ) + if ( thingTemplate == nullptr || thingTemplate->getEditorSorting() != ES_AUDIO ) { return; // All done } // Copied in hideously inappropriate code copying ways from DrawObject.cpp - // Should definately be a global, probably read in from an INI file + // Should definitely be a global, probably read in from an INI file static const Int poleHeight = 20; static const Int flagHeight = 10; static const Int flagWidth = 10; @@ -957,18 +924,18 @@ static void drawAudioRadii( const Drawable * drawable ) { const AudioEventInfo * ambientInfo = ambientSound->getAudioEventInfo(); - if ( ambientInfo == NULL ) + if ( ambientInfo == nullptr ) { // I don't think that's right... - OutputDebugString( ("Playing sound has NULL AudioEventInfo?\n" ) ); + OutputDebugString( ("Playing sound has null AudioEventInfo?\n" ) ); - if ( TheAudio != NULL ) + if ( TheAudio != nullptr ) { ambientInfo = TheAudio->findAudioEventInfo( ambientSound->getEventName() ); } } - if ( ambientInfo != NULL ) + if ( ambientInfo != nullptr ) { // Colors match those used in WorldBuilder drawDebugCircle( *drawable->getPosition(), ambientInfo->m_minDistance, 1.0f, GameMakeColor(0x00, 0x00, 0xFF, 0xFF) ); @@ -1113,7 +1080,6 @@ void W3DView::stepView() void W3DView::update(void) { //USE_PERF_TIMER(W3DView_updateView) - Bool recalcCamera = false; Bool didScriptedMovement = false; #ifdef LOG_FRAME_TIMES __int64 curTime64,freq64; @@ -1129,14 +1095,9 @@ void W3DView::update(void) // Int elapsedTimeMs = TheW3DFrameLengthInMsec; // Assume a constant time flow. It just works out better. jba. - if (TheTerrainRenderObject->doesNeedFullUpdate()) { - RefRenderObjListIterator *it = W3DDisplay::m_3DScene->createLightsIterator(); - TheTerrainRenderObject->updateCenter(m_3DCamera, it); - if (it) - { - W3DDisplay::m_3DScene->destroyLightsIterator(it); - it = NULL; - } + if (TheTerrainRenderObject && TheTerrainRenderObject->doesNeedFullUpdate()) + { + updateTerrain(); } static Real followFactor = -1; @@ -1154,7 +1115,7 @@ void W3DView::update(void) Bool loseLock = false; // check if object has been destroyed or is dead -> lose lock - if (cameraLockObj == NULL) + if (cameraLockObj == nullptr) { loseLock = true; } @@ -1171,7 +1132,7 @@ void W3DView::update(void) if (loseLock) { setCameraLock(INVALID_ID); - setCameraLockDrawable(NULL); + setCameraLockDrawable(nullptr); followFactor = -1; } else @@ -1182,13 +1143,13 @@ void W3DView::update(void) followFactor += 0.05f; if (followFactor>1.0f) followFactor = 1.0f; } - if (getCameraLockDrawable() != NULL) + if (getCameraLockDrawable() != nullptr) { Drawable* cameraLockDrawable = (Drawable *)getCameraLockDrawable(); if (!cameraLockDrawable) { - setCameraLockDrawable(NULL); + setCameraLockDrawable(nullptr); } else { @@ -1220,8 +1181,6 @@ void W3DView::update(void) Matrix3D camXForm; camXForm.Look_At(camtran,objPos,0); m_3DCamera->Set_Transform(camXForm); - - recalcCamera = false; //we already did it } } } @@ -1280,22 +1239,21 @@ void W3DView::update(void) if (cameraLockObj->isUsingAirborneLocomotor() && cameraLockObj->isAboveTerrainOrWater()) { Matrix3D camXForm; - Real oldZRot = m_angle; Real idealZRot = cameraLockObj->getOrientation() - M_PI_2; - normAngle(oldZRot); - normAngle(idealZRot); - Real diff = idealZRot - oldZRot; - normAngle(diff); if (m_snapImmediate) { - m_angle = idealZRot; + View::setAngle(idealZRot); } else { - m_angle += diff * 0.1f; + normAngle(idealZRot); + Real oldZRot = m_angle; + normAngle(oldZRot); + Real diffRot = idealZRot - oldZRot; + normAngle(diffRot); + View::setAngle(m_angle + diffRot * 0.1f); } - normAngle(m_angle); } } if (m_snapImmediate) @@ -1303,7 +1261,7 @@ void W3DView::update(void) m_groundLevel = objpos.z; didScriptedMovement = true; - recalcCamera = true; + m_recalcCamera = true; } } } @@ -1312,7 +1270,7 @@ void W3DView::update(void) // If we aren't frozen for debug, allow the camera to follow scripted movements. if (updateCameraMovements()) { didScriptedMovement = true; - recalcCamera = true; + m_recalcCamera = true; } } else { if (m_doingRotateCamera || m_doingMoveCameraOnWaypointPath || m_doingPitchCamera || m_doingZoomCamera || m_doingScriptedCameraLock) { @@ -1324,13 +1282,13 @@ void W3DView::update(void) // if (m_shakeIntensity > 0.01f) { - recalcCamera = true; + m_recalcCamera = true; } //Process New C3 Camera Shaker system if (CameraShakerSystem.IsCameraShaking()) { - recalcCamera = true; + m_recalcCamera = true; } /* @@ -1344,12 +1302,12 @@ void W3DView::update(void) // 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; + m_terrainHeightAtPivot = getHeightAroundPos(m_pos.x, m_pos.y); + m_currentHeightAboveGround = m_cameraOffset.z * m_zoom - m_terrainHeightAtPivot; - if (TheTerrainLogic && TheGlobalData && TheInGameUI && m_okToAdjustHeight) + if (m_okToAdjustHeight) { - Real desiredHeight = (m_terrainHeightUnderCamera + m_heightAboveGround); + Real desiredHeight = (m_terrainHeightAtPivot + m_heightAboveGround); Real desiredZoom = desiredHeight / m_cameraOffset.z; if (didScriptedMovement) @@ -1360,42 +1318,39 @@ void W3DView::update(void) // 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)) - { - 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 if (!didScriptedMovement) + const Bool isScrolling = TheInGameUI && TheInGameUI->isScrolling(); + const Bool isScrollingTooFast = m_scrollAmount.length() >= m_scrollAmountCutoff; + const Bool isWithinHeightConstraints = isWithinCameraHeightConstraints(); + + // if scrolling, only adjust if we're too close or too far + const Bool adjustZoomWhenScrolling = isScrolling && (!isScrollingTooFast || !isWithinHeightConstraints); + + // if not scrolling, settle toward desired height above ground + const Bool adjustZoomWhenNotScrolling = !isScrolling && !didScriptedMovement; + + if (adjustZoomWhenScrolling || adjustZoomWhenNotScrolling) { - // we're not scrolling; settle toward desired height above ground const Real fpsRatio = TheFramePacer->getBaseOverUpdateFpsRatio(); - const Real zoomAdj = (m_zoom - desiredZoom) * TheGlobalData->m_cameraAdjustSpeed * fpsRatio; + const Real zoomAdj = (desiredZoom - m_zoom) * TheGlobalData->m_cameraAdjustSpeed * fpsRatio; if (fabs(zoomAdj) >= 0.0001f) { - m_zoom -= zoomAdj; - recalcCamera = true; + m_zoom += zoomAdj; + m_recalcCamera = true; } } } + if (TheScriptEngine->isTimeFast()) { return; // don't draw - makes it faster :) jba. } // (gth) C&C3 if m_isCameraSlaved then force the camera to update each frame - if ((recalcCamera) || (m_isCameraSlaved)) { + if (m_recalcCamera || m_isCameraSlaved) + { setCameraTransform(); + m_recalcCamera = false; } - #ifdef DO_SEISMIC_SIMULATIONS // Give the terrain a chance to refresh animating (Seismic) regions, if any. TheTerrainVisual->updateSeismicSimulations(); @@ -1406,7 +1361,7 @@ void W3DView::update(void) // render all of the visible Drawables /// @todo this needs to use a real region partition or something - TheGameClient->iterateDrawablesInRegion( &axisAlignedRegion, drawDrawable, NULL ); + TheGameClient->iterateDrawablesInRegion( &axisAlignedRegion, drawDrawable, nullptr ); } //------------------------------------------------------------------------------------------------- @@ -1418,6 +1373,9 @@ void W3DView::getAxisAlignedViewRegion(Region3D &axisAlignedRegion) // get the 4 points in 3D space of the 4 corners of the view, we will use a z = 0.0f // value so that we can get everything ... even stuff below the terrain // + // 1-------2 + // \ / + // 4---3 Coord3D box[ 4 ]; getScreenCornerWorldPointsAtZ( &box[ 0 ], &box[ 1 ], &box[ 2 ], &box[ 3 ], 0.0f ); @@ -1425,21 +1383,7 @@ void W3DView::getAxisAlignedViewRegion(Region3D &axisAlignedRegion) // take those 4 corners projected into the world and create an axis aligned bounding // box, we will use this box to iterate the drawables in 3D space // - axisAlignedRegion.lo = box[ 0 ]; - axisAlignedRegion.hi = box[ 0 ]; - for( Int i = 0; i < 4; i++ ) - { - - if( box[ i ].x < axisAlignedRegion.lo.x ) - axisAlignedRegion.lo.x = box[ i ].x; - if( box[ i ].y < axisAlignedRegion.lo.y ) - axisAlignedRegion.lo.y = box[ i ].y; - if( box[ i ].x > axisAlignedRegion.hi.x ) - axisAlignedRegion.hi.x = box[ i ].x; - if( box[ i ].y > axisAlignedRegion.hi.y ) - axisAlignedRegion.hi.y = box[ i ].y; - - } + axisAlignedRegion.setFromPointsNoZ(box, ARRAY_SIZE(box)); // low and high regions will be based of the extent of the map Region3D mapExtent; @@ -1768,7 +1712,7 @@ void W3DView::draw( void ) // Draw audio radii for ALL drawables, not just those on screen const Drawable * drawable = TheGameClient->getDrawableList(); - while ( drawable != NULL ) + while ( drawable != nullptr ) { drawAudioRadii( drawable ); drawable = drawable->getNextDrawable(); @@ -1860,9 +1804,7 @@ void W3DView::scrollBy( Coord2D *delta ) //m_cameraConstraintValid = false; // pos change does NOT invalidate cam constraints m_doingRotateCamera = false; - // set new camera position - setCameraTransform(); - + m_recalcCamera = true; } } @@ -1871,21 +1813,16 @@ void W3DView::scrollBy( Coord2D *delta ) //------------------------------------------------------------------------------------------------- void W3DView::forceRedraw() { - - // set the camera - setCameraTransform(); + m_cameraAreaConstraintsValid = false; + m_recalcCamera = true; } //------------------------------------------------------------------------------------------------- /** Rotate the view around the up axis to the given angle. */ //------------------------------------------------------------------------------------------------- -void W3DView::setAngle( Real angle ) +void W3DView::setAngle( Real radians ) { - // Normalize to +-PI. - normAngle(angle); - // call our base class, we are adding functionality - View::setAngle( angle ); - + View::setAngle( radians ); m_doingMoveCameraOnWaypointPath = false; m_CameraArrivedAtWaypointOnPathFlag = false; @@ -1894,40 +1831,50 @@ void W3DView::setAngle( Real angle ) m_doingPitchCamera = false; m_doingZoomCamera = false; m_doingScriptedCameraLock = false; - // set the camera - setCameraTransform(); + m_recalcCamera = true; } //------------------------------------------------------------------------------------------------- /** Rotate the view around the horizontal (X) axis to the given angle. */ //------------------------------------------------------------------------------------------------- -void W3DView::setPitch( Real angle ) +void W3DView::setPitch( Real radians ) { - // call our base class, we are extending functionality - View::setPitch( angle ); - + View::setPitch( radians ); m_doingMoveCameraOnWaypointPath = false; m_doingRotateCamera = false; m_doingPitchCamera = false; m_doingZoomCamera = false; m_doingScriptedCameraLock = false; - // set the camera - setCameraTransform(); + // TheSuperHackers @fix Now recalculates the camera constraints because + // the camera pitch can change the camera distance towards the map border. + m_cameraAreaConstraintsValid = false; + m_recalcCamera = true; } //------------------------------------------------------------------------------------------------- -/** Set the view angle & pitch back to default */ +/** Set the view angle back to default */ //------------------------------------------------------------------------------------------------- -void W3DView::setAngleAndPitchToDefault( void ) +void W3DView::setAngleToDefault( void ) { - // call our base class, we are adding functionality - View::setAngleAndPitchToDefault(); + View::setAngleToDefault(); - m_FXPitch = 1.0; + m_recalcCamera = true; +} - // set the camera - setCameraTransform(); +//------------------------------------------------------------------------------------------------- +/** Set the view pitch back to default */ +//------------------------------------------------------------------------------------------------- +void W3DView::setPitchToDefault( void ) +{ + View::setPitchToDefault(); + + m_FXPitch = 1.0f; + + // TheSuperHackers @fix Now recalculates the camera constraints because + // the camera pitch can change the camera distance towards the map border. + m_cameraAreaConstraintsValid = false; + m_recalcCamera = true; } //------------------------------------------------------------------------------------------------- @@ -1936,7 +1883,7 @@ void W3DView::setDefaultView(Real pitch, Real angle, Real maxHeight) { // MDC - we no longer want to rotate maps (design made all of them right to begin with) // m_defaultAngle = angle * M_PI/180.0f; - m_defaultPitchAngle = pitch; + m_defaultPitch = pitch; m_maxHeightAboveGround = TheGlobalData->m_maxCameraHeight*maxHeight; if (m_minHeightAboveGround > m_maxHeightAboveGround) m_maxHeightAboveGround = m_minHeightAboveGround; @@ -1954,8 +1901,8 @@ void W3DView::setHeightAboveGround(Real z) m_doingPitchCamera = false; m_doingZoomCamera = false; m_doingScriptedCameraLock = false; - m_cameraConstraintValid = false; // recalc it. - setCameraTransform(); + m_cameraAreaConstraintsValid = false; + m_recalcCamera = true; } //------------------------------------------------------------------------------------------------- @@ -1974,8 +1921,8 @@ void W3DView::setZoom(Real z) m_doingPitchCamera = false; m_doingZoomCamera = false; m_doingScriptedCameraLock = false; - m_cameraConstraintValid = false; // recalc it. - setCameraTransform(); + m_cameraAreaConstraintsValid = false; + m_recalcCamera = true; } //------------------------------------------------------------------------------------------------- @@ -2002,8 +1949,8 @@ void W3DView::setZoomToDefault( void ) m_doingPitchCamera = false; m_doingZoomCamera = false; m_doingScriptedCameraLock = false; - m_cameraConstraintValid = false; // recalc it. - setCameraTransform(); + m_cameraAreaConstraintsValid = false; + m_recalcCamera = true; } //------------------------------------------------------------------------------------------------- @@ -2016,7 +1963,8 @@ void W3DView::setFieldOfView( Real angle ) #if defined(RTS_DEBUG) // this is only for testing, and recalculating the // camera every frame is wasteful - setCameraTransform(); + m_cameraAreaConstraintsValid = false; + m_recalcCamera = true; #endif } @@ -2028,7 +1976,7 @@ void W3DView::setFieldOfView( Real angle ) View::WorldToScreenReturn W3DView::worldToScreenTriReturn( const Coord3D *w, ICoord2D *s ) { // sanity - if( w == NULL || s == NULL ) + if( w == nullptr || s == nullptr ) return WTS_INVALID; if( m_3DCamera ) @@ -2072,23 +2020,6 @@ View::WorldToScreenReturn W3DView::worldToScreenTriReturn( const Coord3D *w, ICo return WTS_INVALID; } -//------------------------------------------------------------------------------------------------- -/** Using the W3D camera translate the screen coord to world coord */ -//------------------------------------------------------------------------------------------------- -void W3DView::screenToWorld( const ICoord2D *s, Coord3D *w ) -{ - - // sanity - if( s == NULL || w == NULL ) - return; - - if( m_3DCamera ) - { - DEBUG_CRASH(("implement me")); - } - -} - //------------------------------------------------------------------------------------------------- /** all the drawables in the view, that fall within the 2D screen region * will call the callback function. The number of drawables that passed @@ -2134,12 +2065,12 @@ Int W3DView::iterateDrawablesInRegion( IRegion2D *screenRegion, } - Drawable *onlyDrawableToTest = NULL; + Drawable *onlyDrawableToTest = nullptr; if (regionIsPoint) { // Allow all drawables to be picked. onlyDrawableToTest = pickDrawable(&screenRegion->lo, TRUE, (PickType) getPickTypesForContext(TheInGameUI->isInForceAttackMode())); - if (onlyDrawableToTest == NULL) { + if (onlyDrawableToTest == nullptr) { return 0; } } @@ -2160,7 +2091,7 @@ Int W3DView::iterateDrawablesInRegion( IRegion2D *screenRegion, inside = FALSE; // no screen region, means all drawbles - if( screenRegion == NULL ) + if( screenRegion == nullptr ) inside = TRUE; else { @@ -2197,7 +2128,7 @@ Int W3DView::iterateDrawablesInRegion( IRegion2D *screenRegion, } // If onlyDrawableToTest, then we should bail out now. - if (onlyDrawableToTest != NULL) + if (onlyDrawableToTest != nullptr) break; } @@ -2213,16 +2144,16 @@ Int W3DView::iterateDrawablesInRegion( IRegion2D *screenRegion, //------------------------------------------------------------------------------------------------- Drawable *W3DView::pickDrawable( const ICoord2D *screen, Bool forceAttack, PickType pickType ) { - RenderObjClass *renderObj = NULL; - Drawable *draw = NULL; - DrawableInfo *drawInfo = NULL; + RenderObjClass *renderObj = nullptr; + Drawable *draw = nullptr; + DrawableInfo *drawInfo = nullptr; // sanity - if( screen == NULL ) - return NULL; + if( screen == nullptr ) + return nullptr; // don't pick a drawable if there is a window under the cursor - GameWindow *window = NULL; + GameWindow *window = nullptr; if (TheWindowManager) window = TheWindowManager->getWindowUnderCursor(screen->x, screen->y); @@ -2230,7 +2161,7 @@ Drawable *W3DView::pickDrawable( const ICoord2D *screen, Bool forceAttack, PickT { // check to see if it or any of its parents are opaque. If so, we can't select anything. if (!BitIsSet( window->winGetStatus(), WIN_STATUS_SEE_THRU )) - return NULL; + return nullptr; window = window->winGetParent(); } @@ -2254,7 +2185,7 @@ Drawable *W3DView::pickDrawable( const ICoord2D *screen, Bool forceAttack, PickT // for right now there is no drawable data in a render object which is // if we've found a render object, return our drawable associated with it, - // the terrain, therefore the userdata is NULL + // the terrain, therefore the userdata is null /// @todo terrain and picking! if( renderObj ) drawInfo = (DrawableInfo *)renderObj->Get_User_Data(); @@ -2272,7 +2203,7 @@ Drawable *W3DView::pickDrawable( const ICoord2D *screen, Bool forceAttack, PickT void W3DView::screenToTerrain( const ICoord2D *screen, Coord3D *world ) { // sanity - if( screen == NULL || world == NULL || TheTerrainRenderObject == NULL ) + if( screen == nullptr || world == nullptr || TheTerrainRenderObject == nullptr ) return; if (m_cameraHasMovedSinceRequest) { @@ -2386,8 +2317,7 @@ void W3DView::lookAt( const Coord3D *o ) m_CameraArrivedAtWaypointOnPathFlag = false; m_doingScriptedCameraLock = false; - setCameraTransform(); - + m_recalcCamera = true; } //------------------------------------------------------------------------------------------------- @@ -2403,9 +2333,8 @@ void W3DView::initHeightForMap( void ) m_cameraOffset.z = m_groundLevel+TheGlobalData->m_cameraHeight; m_cameraOffset.y = -(m_cameraOffset.z / tan(TheGlobalData->m_cameraPitch * (PI / 180.0))); m_cameraOffset.x = -(m_cameraOffset.y * tan(TheGlobalData->m_cameraYaw * (PI / 180.0))); - m_cameraConstraintValid = false; // possible ground level change invalidates cam constraints - setCameraTransform(); - + m_cameraAreaConstraintsValid = false; // possible ground level change invalidates camera constraints + m_recalcCamera = true; } //------------------------------------------------------------------------------------------------- @@ -2812,23 +2741,19 @@ void W3DView::cameraModFinalPitch(Real finalPitch, Real easeIn, Real easeOut) { void W3DView::resetCamera(const Coord3D *location, Int milliseconds, Real easeIn, Real easeOut) { moveCameraTo(location, milliseconds, 0, false, easeIn, easeOut); - m_mcwpInfo.cameraAngle[2] = 0.0; // default angle. + m_mcwpInfo.cameraAngle[2] = 0.0f; // default angle. // m_mcwpInfo.cameraAngle[2] = m_defaultAngle; - m_angle = m_mcwpInfo.cameraAngle[0]; + View::setAngle(m_mcwpInfo.cameraAngle[0]); // terrain height + desired height offset == cameraOffset * actual zoom // find best approximation of max terrain height we can see - //Real terrainHeightMax = getHeightAroundPos(m_pos.x, m_pos.y); Real terrainHeightMax = getHeightAroundPos(location->x, location->y); Real desiredHeight = (terrainHeightMax + m_maxHeightAboveGround); Real desiredZoom = desiredHeight / m_cameraOffset.z; zoomCamera( desiredZoom, milliseconds, easeIn, easeOut ); // this isn't right... or is it? - pitchCamera( 1.0, milliseconds, easeIn, easeOut ); - // pitchCamera( m_defaultPitchAngle, milliseconds, easeIn, easeOut ); - //DEBUG_LOG(("W3DView::resetCamera() Current zoom: %g Desired zoom: %g Current pitch: %g Desired pitch: %g", - // m_zoom, desiredZoom, m_pitchAngle, m_defaultPitchAngle)); + pitchCamera( 1.0f, milliseconds, easeIn, easeOut ); } // ------------------------------------------------------------------------------------------------ @@ -2852,12 +2777,9 @@ Bool W3DView::isCameraMovementFinished(void) Bool W3DView::isCameraMovementAtWaypointAlongPath(void) { - // WWDEBUG_SAY((( "MBL: Polling W3DView::isCameraMovementAtWaypointAlongPath" ))); - - Bool return_value = m_CameraArrivedAtWaypointOnPathFlag; - #pragma message( "MBL: Clearing variable after polling - for scripting - see Adam.\n" ) + Bool returnValue = m_CameraArrivedAtWaypointOnPathFlag; m_CameraArrivedAtWaypointOnPathFlag = false; - return( return_value ); + return returnValue; } // ------------------------------------------------------------------------------------------------ @@ -2885,7 +2807,7 @@ void W3DView::moveCameraAlongWaypointPath(Waypoint *pWay, Int milliseconds, Int if (pWay->getNumLinks()>0) { pWay = pWay->getLink(0); } else { - pWay = NULL; + pWay = nullptr; } Vector2 dir(m_mcwpInfo.waypoints[m_mcwpInfo.numWaypoints].x-m_mcwpInfo.waypoints[m_mcwpInfo.numWaypoints-1].x, m_mcwpInfo.waypoints[m_mcwpInfo.numWaypoints].y-m_mcwpInfo.waypoints[m_mcwpInfo.numWaypoints-1].y); if (dir.Length()= 0.1f) { + angle = WWMath::Acos(dir.X/dirLength); if (dir.Y<0.0f) { angle = -angle; } - // Default camera is rotated 90 degrees, so match. angle -= PI/2; normAngle(angle); @@ -3035,13 +2957,12 @@ void W3DView::rotateCameraOneFrame(void) Real angleDiff = angle - m_angle; normAngle(angleDiff); angleDiff *= factor; - m_angle += angleDiff; - normAngle(m_angle); + View::setAngle(m_angle + angleDiff); m_timeMultiplier = m_rcInfo.startTimeMultiplier + REAL_TO_INT_FLOOR(0.5 + (m_rcInfo.endTimeMultiplier-m_rcInfo.startTimeMultiplier)*factor); } else { - m_angle = angle; + View::setAngle(angle); } } } @@ -3049,8 +2970,8 @@ void W3DView::rotateCameraOneFrame(void) else if (m_rcInfo.curFrame <= m_rcInfo.numFrames) { Real factor = m_rcInfo.ease(((Real)m_rcInfo.curFrame)/m_rcInfo.numFrames); - m_angle = WWMath::Lerp(m_rcInfo.angle.startAngle, m_rcInfo.angle.endAngle, factor); - normAngle(m_angle); + Real angle = WWMath::Lerp(m_rcInfo.angle.startAngle, m_rcInfo.angle.endAngle, factor); + View::setAngle(angle); m_timeMultiplier = m_rcInfo.startTimeMultiplier + REAL_TO_INT_FLOOR(0.5 + (m_rcInfo.endTimeMultiplier-m_rcInfo.startTimeMultiplier)*factor); } @@ -3060,7 +2981,7 @@ void W3DView::rotateCameraOneFrame(void) m_freezeTimeForCameraMovement = false; if (! m_rcInfo.trackObject) { - m_angle = m_rcInfo.angle.endAngle; + View::setAngle(m_rcInfo.angle.endAngle); } } } @@ -3132,7 +3053,7 @@ void W3DView::moveAlongWaypointPath(Real milliseconds) m_CameraArrivedAtWaypointOnPathFlag = false; m_freezeTimeForCameraMovement = false; - m_angle = m_mcwpInfo.cameraAngle[m_mcwpInfo.numWaypoints]; + View::setAngle(m_mcwpInfo.cameraAngle[m_mcwpInfo.numWaypoints]); m_groundLevel = m_mcwpInfo.groundHeight[m_mcwpInfo.numWaypoints]; /////////////////////m_cameraOffset.z = m_groundLevel+TheGlobalData->m_cameraHeight; @@ -3144,10 +3065,10 @@ void W3DView::moveAlongWaypointPath(Real milliseconds) setPosition(&pos); // Note - assuming that the scripter knows what he is doing, we adjust the constraints so that // the scripted action can occur. - m_cameraConstraint.lo.x = minf(m_cameraConstraint.lo.x, pos.x); - m_cameraConstraint.hi.x = maxf(m_cameraConstraint.hi.x, pos.x); - m_cameraConstraint.lo.y = minf(m_cameraConstraint.lo.y, pos.y); - m_cameraConstraint.hi.y = maxf(m_cameraConstraint.hi.y, pos.y); + m_cameraAreaConstraints.lo.x = minf(m_cameraAreaConstraints.lo.x, pos.x); + m_cameraAreaConstraints.hi.x = maxf(m_cameraAreaConstraints.hi.x, pos.x); + m_cameraAreaConstraints.lo.y = minf(m_cameraAreaConstraints.lo.y, pos.y); + m_cameraAreaConstraints.hi.y = maxf(m_cameraAreaConstraints.hi.y, pos.y); return; } @@ -3203,8 +3124,7 @@ void W3DView::moveAlongWaypointPath(Real milliseconds) if (fabs(deltaAngle) > PI/10) { DEBUG_LOG(("Huh.")); } - m_angle += avgFactor*(deltaAngle); - normAngle(m_angle); + View::setAngle(m_angle + (avgFactor*deltaAngle)); Real timeMultiplier = m_mcwpInfo.timeMultiplier[m_mcwpInfo.curSegment]*factor1 + m_mcwpInfo.timeMultiplier[m_mcwpInfo.curSegment+1]*factor2; @@ -3259,10 +3179,10 @@ void W3DView::moveAlongWaypointPath(Real milliseconds) setPosition(&result); // Note - assuming that the scripter knows what he is doing, we adjust the constraints so that // the scripted action can occur. - m_cameraConstraint.lo.x = minf(m_cameraConstraint.lo.x, result.x); - m_cameraConstraint.hi.x = maxf(m_cameraConstraint.hi.x, result.x); - m_cameraConstraint.lo.y = minf(m_cameraConstraint.lo.y, result.y); - m_cameraConstraint.hi.y = maxf(m_cameraConstraint.hi.y, result.y); + m_cameraAreaConstraints.lo.x = minf(m_cameraAreaConstraints.lo.x, result.x); + m_cameraAreaConstraints.hi.x = maxf(m_cameraAreaConstraints.hi.x, result.x); + m_cameraAreaConstraints.lo.y = minf(m_cameraAreaConstraints.lo.y, result.y); + m_cameraAreaConstraints.hi.y = maxf(m_cameraAreaConstraints.hi.y, result.y); } @@ -3334,8 +3254,7 @@ void W3DView::shake( const Coord3D *epicenter, CameraShakeType shakeType ) } //------------------------------------------------------------------------------------------------- -/** Transformt he screen pixel coord passed in, to a world coordinate at the specified - * z value */ +/** Transform the screen pixel coord passed in, to a world coordinate at the specified z value */ //------------------------------------------------------------------------------------------------- void W3DView::screenToWorldAtZ( const ICoord2D *s, Coord3D *w, Real z ) { @@ -3373,8 +3292,8 @@ void W3DView::cameraDisableRealZoomMode(void) //WST added 10/18/2002 m_useRealZoomCam = false; m_FXPitch = 1.0f; //Reset to default //m_zoom = 1.0f; - m_FOV = 50.0f * PI/180.0f; - setCameraTransform(); + m_FOV = DEG_TO_RADF(50.0f); + m_recalcCamera = true; updateView(); } @@ -3390,3 +3309,15 @@ void W3DView::Add_Camera_Shake (const Coord3D & position,float radius,float dura CameraShakerSystem.Add_Camera_Shake(vpos,radius,duration,power); } +void W3DView::updateTerrain() +{ + DEBUG_ASSERTCRASH(TheTerrainRenderObject != nullptr, ("TheTerrainRenderObject is null")); + + RefRenderObjListIterator *it = W3DDisplay::m_3DScene->createLightsIterator(); + TheTerrainRenderObject->updateCenter(m_3DCamera, it); + if (it) + { + W3DDisplay::m_3DScene->destroyLightsIterator(it); + it = nullptr; + } +} diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp index 2addc0e8ba6..32c1eee4741 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWater.cpp @@ -31,6 +31,7 @@ #define SCROLL_UV // INCLUDES /////////////////////////////////////////////////////////////////////////////////////// + #include "W3DDevice/GameClient/W3DWater.h" #include "W3DDevice/GameClient/HeightMap.h" #include "W3DDevice/GameClient/W3DShroud.h" @@ -162,9 +163,9 @@ static inline DWORD F2DW( FLOAT f ) { return *((DWORD*)&f); } static ShaderClass zFillAlphaShader(SC_ZFILL_BLEND3); static ShaderClass blendStagesShader(SC_DETAIL_BLEND); -WaterRenderObjClass *TheWaterRenderObj=NULL; ///Release(); (p)=NULL; } } +#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=nullptr; } } void doSkyBoxSet(Bool startDraw) { @@ -237,19 +238,18 @@ void WaterRenderObjClass::setupJbaWaterShader(void) DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2); DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); - D3DXMATRIX inv; - float det; - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMATRIX inv; + float det; + D3DXMatrixInverse(&inv, &det, &curView); D3DXMATRIX scale; - D3DXMatrixScaling(&scale, NOISE_REPEAT_FACTOR, NOISE_REPEAT_FACTOR,1); D3DXMATRIX destMatrix = inv * scale; D3DXMatrixTranslation(&scale, m_riverVOrigin, m_riverVOrigin,0); destMatrix = destMatrix*scale; - DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE2, *(Matrix4x4*)&destMatrix); + DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE2, destMatrix); } m_pDev->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); @@ -300,7 +300,7 @@ WaterRenderObjClass::~WaterRenderObjClass(void) } delete [] m_meshData; - m_meshData = NULL; + m_meshData = nullptr; m_meshDataSize = 0; //Release strings allocated inside global water settings. @@ -309,7 +309,7 @@ WaterRenderObjClass::~WaterRenderObjClass(void) WaterSettings[i].m_waterTextureFile.clear(); } deleteInstance((WaterTransparencySetting*)TheWaterTransparency.getNonOverloadedPointer()); - TheWaterTransparency = NULL; + TheWaterTransparency = nullptr; ReleaseResources(); delete m_waterTrackSystem; @@ -323,25 +323,25 @@ WaterRenderObjClass::WaterRenderObjClass(void) memset( &m_settings, 0, sizeof( m_settings ) ); m_dx=0; m_dy=0; - m_indexBuffer=NULL; - m_waterTrackSystem = NULL; + m_indexBuffer=nullptr; + m_waterTrackSystem = nullptr; m_doWaterGrid = FALSE; - m_meshVertexMaterialClass=NULL; - m_meshLight=NULL; - m_vertexMaterialClass=NULL; - m_alphaClippingTexture=NULL; + m_meshVertexMaterialClass=nullptr; + m_meshLight=nullptr; + m_vertexMaterialClass=nullptr; + m_alphaClippingTexture=nullptr; m_useCloudLayer=true; m_waterType = WATER_TYPE_0_TRANSLUCENT; m_tod=TIME_OF_DAY_AFTERNOON; - m_pReflectionTexture=NULL; - m_skyBox=NULL; - m_vertexBufferD3D=NULL; - m_indexBufferD3D=NULL; + m_pReflectionTexture=nullptr; + m_skyBox=nullptr; + m_vertexBufferD3D=nullptr; + m_indexBufferD3D=nullptr; m_vertexBufferD3DOffset=0; - m_dwWavePixelShader=NULL; - m_dwWaveVertexShader=NULL; - m_meshData=NULL; + m_dwWavePixelShader=0; + m_dwWaveVertexShader=0; + m_meshData=nullptr; m_meshDataSize = 0; m_meshInMotion = FALSE; m_gridOrigin=Vector2(0,0); @@ -356,17 +356,17 @@ WaterRenderObjClass::WaterRenderObjClass(void) Int i=NUM_BUMP_FRAMES; while (i--) - m_pBumpTexture[i]=NULL; + m_pBumpTexture[i]=nullptr; m_riverVOrigin=0; - m_riverTexture=NULL; - m_whiteTexture=NULL; - m_waterNoiseTexture=NULL; - m_riverAlphaEdge=NULL; + m_riverTexture=nullptr; + m_whiteTexture=nullptr; + m_waterNoiseTexture=nullptr; + m_riverAlphaEdge=nullptr; m_waterPixelShader=0; ///Get_Description(d3dsd); pSrc=(unsigned char *)surf->Lock((int *)&dwSrcPitch); - pTex[0]->LockRect( level, &d3dlr, 0, 0 ); + pTex[0]->LockRect( level, &d3dlr, nullptr, 0 ); DWORD dwDstPitch = (DWORD)d3dlr.Pitch; BYTE* pDst = (BYTE*)d3dlr.pBits; @@ -641,7 +641,7 @@ HRESULT WaterRenderObjClass::generateVertexBuffer( Int sizeX, Int sizeY, Int ver m_numVertices=sizeX*sizeY; } - if (m_vertexBufferD3D == NULL) + if (m_vertexBufferD3D == nullptr) { // Create vertex buffer if (FAILED(hr=m_pDev->CreateVertexBuffer @@ -916,7 +916,7 @@ void WaterRenderObjClass::ReAcquireResources(void) add r0.rgb, r0, t3\n\ +mul r0.a, r0, t3\n\ add r0.rgb, r0, r1\n"; - hr = D3DXAssembleShader( shader, strlen(shader), 0, NULL, &compiledShader, NULL); + hr = D3DXAssembleShader( shader, strlen(shader), 0, nullptr, &compiledShader, nullptr); if (hr==0) { hr = DX8Wrapper::_Get_D3D_Device8()->CreatePixelShader((DWORD*)compiledShader->GetBufferPointer(), &m_riverWaterPixelShader); compiledShader->Release(); @@ -929,7 +929,7 @@ void WaterRenderObjClass::ReAcquireResources(void) mul r0,v0,t0 ; blend vertex color into t0. \n\ mul r1.rgb,t2,c0 ; reduce t2 (environment mapped reflection) by constant\n\ add r0.rgb, r0, r1"; - hr = D3DXAssembleShader( shader, strlen(shader), 0, NULL, &compiledShader, NULL); + hr = D3DXAssembleShader( shader, strlen(shader), 0, nullptr, &compiledShader, nullptr); if (hr==0) { hr = DX8Wrapper::_Get_D3D_Device8()->CreatePixelShader((DWORD*)compiledShader->GetBufferPointer(), &m_waterPixelShader); compiledShader->Release(); @@ -944,7 +944,7 @@ void WaterRenderObjClass::ReAcquireResources(void) mad r0.rgb, t1, t2, r0 ; blend sparkles and noise \n\ mul r0.rgb, r0, t3 ; blend in black shroud \n\ ;\n"; - hr = D3DXAssembleShader( shader, strlen(shader), 0, NULL, &compiledShader, NULL); + hr = D3DXAssembleShader( shader, strlen(shader), 0, nullptr, &compiledShader, nullptr); if (hr==0) { hr = DX8Wrapper::_Get_D3D_Device8()->CreatePixelShader((DWORD*)compiledShader->GetBufferPointer(), &m_trapezoidWaterPixelShader); compiledShader->Release(); @@ -964,7 +964,11 @@ void WaterRenderObjClass::ReAcquireResources(void) if (m_whiteTexture && !m_whiteTexture->Is_Initialized()) { m_whiteTexture->Init(); SurfaceClass *surface=m_whiteTexture->Get_Surface_Level(); - surface->DrawPixel(0,0,0xffffffff); + int pitch; + void *pBits = surface->Lock(&pitch); + const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel(); + surface->Draw_Pixel(0, 0, 0xffffffff, bytesPerPixel, pBits, pitch); + surface->Unlock(); REF_PTR_RELEASE(surface); } } @@ -1107,10 +1111,14 @@ Int WaterRenderObjClass::init(Real waterLevel, Real dx, Real dy, SceneClass *par m_riverTexture=WW3DAssetManager::Get_Instance()->Get_Texture(TheWaterTransparency->m_standingWaterTexture.str()); - //For some reason setting a NULL texture does not result in 0xffffffff for pixel shaders so using explicit "white" texture. + //For some reason setting a null texture does not result in 0xffffffff for pixel shaders so using explicit "white" texture. m_whiteTexture=MSGNEW("TextureClass") TextureClass(1,1,WW3D_FORMAT_A4R4G4B4,MIP_LEVELS_1); SurfaceClass *surface=m_whiteTexture->Get_Surface_Level(); - surface->DrawPixel(0,0,0xffffffff); + int pitch; + void *pBits = surface->Lock(&pitch); + const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel(); + surface->Draw_Pixel(0, 0, 0xffffffff, bytesPerPixel, pBits, pitch); + surface->Unlock(); REF_PTR_RELEASE(surface); m_waterNoiseTexture=WW3DAssetManager::Get_Instance()->Get_Texture("Noise0000.tga"); @@ -1182,7 +1190,7 @@ void WaterRenderObjClass::enableWaterGrid(Bool state) m_drawingRiver = false; m_disableRiver = false; - if (state && m_meshData == NULL) + if (state && m_meshData == nullptr) { //water type has changed, must allocate necessary assets for new water. //contains the current deformed water surface z(height) values. With 1 vertex invisible border //around surface to speed up normal calculations. @@ -1348,7 +1356,7 @@ void WaterRenderObjClass::loadSetting( Setting *setting, TimeOfDay timeOfDay ) SurfaceClass::SurfaceDescription surfaceDesc; // sanity - DEBUG_ASSERTCRASH( setting, ("WaterRenderObjClass::loadSetting, NULL setting") ); + DEBUG_ASSERTCRASH( setting, ("WaterRenderObjClass::loadSetting, null setting") ); // textures setting->skyTexture = WW3DAssetManager::Get_Instance()->Get_Texture( WaterSettings[ timeOfDay ].m_skyTextureFile.str() ); @@ -1407,7 +1415,7 @@ void WaterRenderObjClass::loadSetting( Setting *setting, TimeOfDay timeOfDay ) //------------------------------------------------------------------------------------------------- void WaterRenderObjClass::updateRenderTargetTextures(CameraClass *cam) { - if (m_waterType == WATER_TYPE_2_PVSHADER && getClippedWaterPlane(cam, NULL) && + if (m_waterType == WATER_TYPE_2_PVSHADER && getClippedWaterPlane(cam, nullptr) && TheTerrainRenderObject && TheTerrainRenderObject->getMap()) renderMirror(cam); //generate texture containing reflected scene } @@ -1487,7 +1495,7 @@ void WaterRenderObjClass::renderMirror(CameraClass *cam) WW3D::End_Render(false); // Change the rendertarget back to the main backbuffer - DX8Wrapper::Set_Render_Target((IDirect3DSurface8 *)NULL); + DX8Wrapper::Set_Render_Target((IDirect3DSurface8 *)nullptr); } //------------------------------------------------------------------------------------------------- @@ -1593,18 +1601,17 @@ void WaterRenderObjClass::Render(RenderInfoClass & rinfo) // Alternate Clipping Method using alpha testing hack! /**************************************************************************************/ - D3DXMATRIX inv; - D3DXMATRIX clipMatrix; - Real det; - Matrix4x4 curView; - //get current view matrix + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); //get inverse of view matrix(= view to world matrix) - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMATRIX inv; + Real det; + D3DXMatrixInverse(&inv, &det, &curView); //create clipping matrix by inserting our plane equation into the 1st column + D3DXMATRIX clipMatrix; D3DXMatrixIdentity(&clipMatrix); clipMatrix(0,0)=WaterNormal.X; clipMatrix(1,0)=WaterNormal.Y; @@ -1622,7 +1629,7 @@ void WaterRenderObjClass::Render(RenderInfoClass & rinfo) DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2); // Set texture generation matrix for stage 1 - DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, *((Matrix4*)&inv)); + DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE1, inv); // Disable bilinear filtering DX8Wrapper::Set_DX8_Texture_Stage_State(1, D3DTSS_MINFILTER, D3DTEXF_POINT); @@ -1716,7 +1723,7 @@ void WaterRenderObjClass::Render(RenderInfoClass & rinfo) } //Clean up after any pixel shaders. - //Force render state apply so that the "NULL" texture gets applied to D3D, thus releasing shroud reference count. + //Force render state apply so that the null texture gets applied to D3D, thus releasing shroud reference count. DX8Wrapper::Apply_Render_State_Changes(); DX8Wrapper::Invalidate_Cached_Render_States(); @@ -1787,11 +1794,9 @@ void WaterRenderObjClass::drawSea(RenderInfoClass & rinfo) matWW3D._23=1.0f; matWW3D._44=1.0f; - Matrix3D tm(Transform); - - DX8Wrapper::Set_Transform(D3DTS_WORLD,tm); //position the water surface - DX8Wrapper::Set_Texture(0,NULL); //we'll be setting our own textures, so reset W3D - DX8Wrapper::Set_Texture(1,NULL); //we'll be setting our own textures, so reset W3D + DX8Wrapper::Set_Transform(D3DTS_WORLD,Transform); //position the water surface + DX8Wrapper::Set_Texture(0,nullptr); //we'll be setting our own textures, so reset W3D + DX8Wrapper::Set_Texture(1,nullptr); //we'll be setting our own textures, so reset W3D DX8Wrapper::Apply_Render_State_Changes(); //force update of view and projection matrices @@ -1800,8 +1805,8 @@ void WaterRenderObjClass::drawSea(RenderInfoClass & rinfo) rinfo.Camera.Get_Transform().Get_Translation(&camTran); - DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, *(Matrix4x4*)&matView); - DX8Wrapper::_Get_DX8_Transform(D3DTS_PROJECTION, *(Matrix4x4*)&matProj); + DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, matView); + DX8Wrapper::_Get_DX8_Transform(D3DTS_PROJECTION, matProj); //default setup from Kenny's demo m_pDev->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); @@ -1918,9 +1923,9 @@ void WaterRenderObjClass::drawSea(RenderInfoClass & rinfo) } // m_pDev->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID); m_pDev->SetRenderState(D3DRS_ALPHABLENDENABLE , FALSE); - m_pDev->SetTexture( 0, NULL); //release reference to bump texture - m_pDev->SetTexture( 1, NULL); //release reference to reflection texture - m_pDev->SetTexture( 2, NULL); //release reference to reflection texture + m_pDev->SetTexture( 0, nullptr); //release reference to bump texture + m_pDev->SetTexture( 1, nullptr); //release reference to reflection texture + m_pDev->SetTexture( 2, nullptr); //release reference to reflection texture m_pDev->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE); m_pDev->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU|0); @@ -1941,8 +1946,8 @@ void WaterRenderObjClass::drawSea(RenderInfoClass & rinfo) m_pDev->SetTextureStageState( 2, D3DTSS_ALPHAOP, D3DTOP_DISABLE ); //Restore old transforms - DX8Wrapper::_Set_DX8_Transform(D3DTS_VIEW, *(Matrix4x4*)&matView); - DX8Wrapper::_Set_DX8_Transform(D3DTS_PROJECTION, *(Matrix4x4*)&matProj); + DX8Wrapper::_Set_DX8_Transform(D3DTS_VIEW, matView); + DX8Wrapper::_Set_DX8_Transform(D3DTS_PROJECTION, matProj); m_pDev->SetPixelShader(0); //turn off pixel shader m_pDev->SetVertexShader(DX8_FVF_XYZDUV1); //turn off custom vertex shader @@ -1966,7 +1971,7 @@ void WaterRenderObjClass::drawSea(RenderInfoClass & rinfo) D3DXMatrixMultiply(&matTemp, &patchMatrix, &matWW3D); - DX8Wrapper::_Set_DX8_Transform(D3DTS_WORLD, *(Matrix4x4*)&matTemp); + DX8Wrapper::_Set_DX8_Transform(D3DTS_WORLD, matTemp); m_pDev->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP,0,m_numVertices,0,m_numIndices); } @@ -2358,9 +2363,7 @@ void WaterRenderObjClass::renderWaterMesh(void) m_vertexBufferD3D->Unlock(); - Matrix3D tm(Transform); - - DX8Wrapper::Set_Transform(D3DTS_WORLD,tm); //position the water surface + DX8Wrapper::Set_Transform(D3DTS_WORLD,Transform); //position the water surface DX8Wrapper::Set_Material(m_meshVertexMaterialClass); ShaderClass::CullModeType oldCullMode=m_shaderClass.Get_Cull_Mode(); @@ -2379,9 +2382,9 @@ void WaterRenderObjClass::renderWaterMesh(void) DX8Wrapper::Set_Texture(1,setting->waterTexture); DX8Wrapper::Set_Light(0,*m_meshLight); - DX8Wrapper::Set_Light(1,NULL); - DX8Wrapper::Set_Light(2,NULL); - DX8Wrapper::Set_Light(3,NULL); + DX8Wrapper::Set_Light(1,nullptr); + DX8Wrapper::Set_Light(2,nullptr); + DX8Wrapper::Set_Light(3,nullptr); /* DX8Wrapper::Set_DX8_Render_State(D3DRS_AMBIENT,0); //turn off scene ambient DX8Wrapper::Set_DX8_Render_State(D3DRS_SPECULARENABLE,TRUE); @@ -2425,12 +2428,12 @@ void WaterRenderObjClass::renderWaterMesh(void) // m_pDev->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID); - if (m_trapezoidWaterPixelShader) DX8Wrapper::_Get_D3D_Device8()->SetPixelShader(NULL); + if (m_trapezoidWaterPixelShader) DX8Wrapper::_Get_D3D_Device8()->SetPixelShader(0); m_vertexBufferD3DOffset += mx*my; //advance past vertices already in buffer - DX8Wrapper::Set_Texture(0,NULL); - DX8Wrapper::Set_Texture(1,NULL); + DX8Wrapper::Set_Texture(0,nullptr); + DX8Wrapper::Set_Texture(1,nullptr); ShaderClass::Invalidate(); m_shaderClass.Set_Cull_Mode(oldCullMode); //water should be visible from both sides @@ -2624,7 +2627,7 @@ void WaterRenderObjClass::setGridResolution(Real gridCellsX, Real gridCellsY, Re { delete [] m_meshData;//free previously allocated grid and allocate new size - m_meshData = NULL; // must set to NULL so that we properly re-allocate + m_meshData = nullptr; // must set to null so that we properly re-allocate m_meshDataSize = 0; Bool enable = m_doWaterGrid; @@ -2657,7 +2660,7 @@ static Real wobble(Real baseV, Real offset, Bool wobble) /**Utility function used to query water heights in a manner that works in both RTS and WB.*/ Real WaterRenderObjClass::getWaterHeight(Real x, Real y) { - const WaterHandle *waterHandle = NULL; + const WaterHandle *waterHandle = nullptr; Real waterZ = 0.0f; ICoord3D iLoc; @@ -2901,7 +2904,7 @@ void WaterRenderObjClass::drawRiverWater(PolygonTrigger *pTrig) DX8Wrapper::_Get_D3D_Device8()->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID); } - if (m_riverWaterPixelShader) DX8Wrapper::_Get_D3D_Device8()->SetPixelShader(NULL); + if (m_riverWaterPixelShader) DX8Wrapper::_Get_D3D_Device8()->SetPixelShader(0); //restore blend mode to what W3D expects. if (TheWaterTransparency->m_additiveBlend) @@ -2955,12 +2958,16 @@ void WaterRenderObjClass::setupFlatWaterShader(void) DX8Wrapper::_Get_D3D_Device8()->SetRenderState(D3DRS_ZFUNC, D3DCMP_LESSEQUAL); } else - { //Assume no shroud, so stage 3 will be "NULL" texture but using actual white because - //pixel shader on GF4 generates random colors with SetTexture(3,NULL). + { //Assume no shroud, so stage 3 will be null texture but using actual white because + //pixel shader on GF4 generates random colors with SetTexture(3,nullptr). if (!m_whiteTexture->Is_Initialized()) { m_whiteTexture->Init(); SurfaceClass *surface=m_whiteTexture->Get_Surface_Level(); - surface->DrawPixel(0,0,0xffffffff); + int pitch; + void *pBits = surface->Lock(&pitch); + const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel(); + surface->Draw_Pixel(0, 0, 0xffffffff, bytesPerPixel, pBits, pitch); + surface->Unlock(); REF_PTR_RELEASE(surface); } DX8Wrapper::_Get_D3D_Device8()->SetTexture(3,m_whiteTexture->Peek_D3D_Texture()); @@ -2993,19 +3000,18 @@ void WaterRenderObjClass::setupFlatWaterShader(void) DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT2); DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_ADDRESSU, D3DTADDRESS_WRAP); DX8Wrapper::Set_DX8_Texture_Stage_State(2, D3DTSS_ADDRESSV, D3DTADDRESS_WRAP); - D3DXMATRIX inv; - float det; - Matrix4x4 curView; + D3DXMATRIX curView; DX8Wrapper::_Get_DX8_Transform(D3DTS_VIEW, curView); - D3DXMatrixInverse(&inv, &det, (D3DXMATRIX*)&curView); + D3DXMATRIX inv; + float det; + D3DXMatrixInverse(&inv, &det, &curView); D3DXMATRIX scale; - D3DXMatrixScaling(&scale, NOISE_REPEAT_FACTOR, NOISE_REPEAT_FACTOR,1); D3DXMATRIX destMatrix = inv * scale; D3DXMatrixTranslation(&scale, m_riverVOrigin, m_riverVOrigin,0); destMatrix = destMatrix*scale; - DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE2, *(Matrix4x4*)&destMatrix); + DX8Wrapper::_Set_DX8_Transform(D3DTS_TEXTURE2, destMatrix); } m_pDev->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR ); @@ -3298,7 +3304,7 @@ void WaterRenderObjClass::drawTrapezoidWater(Vector3 points[4]) DX8Wrapper::_Get_D3D_Device8()->SetRenderState(D3DRS_FILLMODE,D3DFILL_SOLID); } - if (m_riverWaterPixelShader) DX8Wrapper::_Get_D3D_Device8()->SetPixelShader(NULL); + if (m_riverWaterPixelShader) DX8Wrapper::_Get_D3D_Device8()->SetPixelShader(0); //Restore alpha blend to default values since we may have changed them to feather edges. if (!TheWaterTransparency->m_additiveBlend) { DX8Wrapper::Set_DX8_Render_State(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA ); @@ -3315,7 +3321,7 @@ void WaterRenderObjClass::drawTrapezoidWater(Vector3 points[4]) if (m_trapezoidWaterPixelShader) { //shroud was applied in stage3 of main pass so just need to restore state here. W3DShaderManager::resetShader(W3DShaderManager::ST_SHROUD_TEXTURE); - DX8Wrapper::_Get_D3D_Device8()->SetTexture(3,NULL); //free possible reference to shroud texture + DX8Wrapper::_Get_D3D_Device8()->SetTexture(3,nullptr); //free possible reference to shroud texture DX8Wrapper::_Get_D3D_Device8()->SetRenderState(D3DRS_ZFUNC, D3DCMP_EQUAL); } else @@ -3407,7 +3413,7 @@ void WaterRenderObjClass::renderSkyBody(Matrix3D *mat) DX8Wrapper::Set_Vertex_Buffer(vb_access); Matrix3D tm(1); - //set postion of skybody in world + //set position of skybody in world // tm.Set_Translation(Vector3(40,0,0)); DX8Wrapper::Set_Transform(D3DTS_WORLD,tm); diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp index afc6ed90131..8fb9cae3199 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/Water/W3DWaterTracks.cpp @@ -73,7 +73,7 @@ //#define DEFAULT_FINAL_WAVE_HEIGHT 18.0f //#define DEFAULT_SECOND_WAVE_TIME_OFFSET 6267 //should always be half of totalMs -WaterTracksRenderSystem *TheWaterTracksRenderSystem=NULL; ///< singleton for track drawing system. +WaterTracksRenderSystem *TheWaterTracksRenderSystem=nullptr; ///< singleton for track drawing system. static Bool pauseWaves=FALSE; @@ -131,7 +131,7 @@ WaterTracksObj::~WaterTracksObj(void) //============================================================================= WaterTracksObj::WaterTracksObj(void) { - m_stageZeroTexture=NULL; + m_stageZeroTexture=nullptr; m_bound=false; m_initTimeOffset=0; } @@ -482,7 +482,7 @@ Int WaterTracksObj::render(DX8VertexBufferClass *vertexBuffer, Int batchStart) //============================================================================= //WaterTracksRenderSystem::bindTrack //============================================================================= -/** Grab a track from the free store. If no free tracks exist, return NULL. +/** Grab a track from the free store. If no free tracks exist, return null. As long as a track is bound to an object (like a tank) it is ready to accept updates with additional edges. Once it is unbound, it will expire and return to the free store once all tracks have faded out. @@ -506,7 +506,7 @@ WaterTracksObj *WaterTracksRenderSystem::bindTrack(waveType type) mod->m_type=type; // put module on the used list (sorted next to similar types) - nextmod=NULL,prevmod=NULL; + nextmod=nullptr,prevmod=nullptr; for( nextmod = m_usedModules; nextmod; prevmod=nextmod,nextmod = nextmod->m_nextSystem ) { if (nextmod->m_type==type) @@ -523,7 +523,7 @@ WaterTracksObj *WaterTracksRenderSystem::bindTrack(waveType type) } } - if (nextmod==NULL) + if (nextmod==nullptr) { //shadow with new texture. Add to top of list. mod->m_nextSystem = m_usedModules; if (m_usedModules) @@ -570,7 +570,7 @@ void WaterTracksRenderSystem::unbindTrack( WaterTracksObj *mod ) */ void WaterTracksRenderSystem::releaseTrack( WaterTracksObj *mod ) { - if (mod==NULL) + if (mod==nullptr) return; assert(mod->m_bound == false); @@ -584,7 +584,7 @@ void WaterTracksRenderSystem::releaseTrack( WaterTracksObj *mod ) m_usedModules = mod->m_nextSystem; // add module to free list - mod->m_prevSystem = NULL; + mod->m_prevSystem = nullptr; mod->m_nextSystem = m_freeModules; if( m_freeModules ) m_freeModules->m_prevSystem = mod; @@ -599,11 +599,11 @@ void WaterTracksRenderSystem::releaseTrack( WaterTracksObj *mod ) //============================================================================= WaterTracksRenderSystem::WaterTracksRenderSystem() { - m_usedModules = NULL; - m_freeModules = NULL; - m_indexBuffer = NULL; - m_vertexMaterialClass = NULL; - m_vertexBuffer = NULL; + m_usedModules = nullptr; + m_freeModules = nullptr; + m_indexBuffer = nullptr; + m_vertexMaterialClass = nullptr; + m_vertexBuffer = nullptr; m_stripSizeX=WATER_STRIP_X; m_stripSizeY=WATER_STRIP_Y; m_batchStart=0; @@ -621,7 +621,7 @@ WaterTracksRenderSystem::~WaterTracksRenderSystem( void ) // free all data shutdown(); - m_vertexMaterialClass=NULL; + m_vertexMaterialClass=nullptr; } @@ -727,7 +727,7 @@ void WaterTracksRenderSystem::init(void) mod = NEW WaterTracksObj; - if( mod == NULL ) + if( mod == nullptr ) { // unable to allocate modules needed @@ -736,7 +736,7 @@ void WaterTracksRenderSystem::init(void) } - mod->m_prevSystem = NULL; + mod->m_prevSystem = nullptr; mod->m_nextSystem = m_freeModules; if( m_freeModules ) m_freeModules->m_prevSystem = mod; @@ -764,7 +764,7 @@ void WaterTracksRenderSystem::reset(void) // free all attached things and used modules - assert( m_usedModules == NULL ); + assert( m_usedModules == nullptr ); } //============================================================================= @@ -791,7 +791,7 @@ void WaterTracksRenderSystem::shutdown( void ) // free all attached things and used modules - assert( m_usedModules == NULL ); + assert( m_usedModules == nullptr ); // free all module storage while( m_freeModules ) @@ -949,7 +949,7 @@ WaterTracksObj *WaterTracksRenderSystem::findTrack(Vector2 &start, Vector2 &end, return mod; mod = mod->m_nextSystem; } - return NULL; + return nullptr; } void WaterTracksRenderSystem::saveTracks(void) { @@ -1023,7 +1023,7 @@ void WaterTracksRenderSystem::loadTracks(void) goto tryagain; } - umod=TheWaterTracksRenderSystem->bindTrack(wtype); + umod=bindTrack(wtype); if (umod) { //umod->init(1.5f*MAP_XY_FACTOR,Vector2(0,0),Vector2(1,1),"wave256.tga"); flipU ^= 1; //toggle flip state @@ -1032,7 +1032,7 @@ void WaterTracksRenderSystem::loadTracks(void) if (waveTypeInfo[wtype].m_secondWaveTimeOffset) //check if we need a second wave to follow { - umod=TheWaterTracksRenderSystem->bindTrack(wtype); + umod=bindTrack(wtype); if (umod) { umod->init(waveTypeInfo[wtype].m_finalHeight,waveTypeInfo[wtype].m_finalWidth,startPos,endPos,waveTypeInfo[wtype].m_textureName,waveTypeInfo[wtype].m_secondWaveTimeOffset); @@ -1083,10 +1083,10 @@ extern HWND ApplicationHWnd; //TODO: Fix editor so it actually draws the wave segment instead of line while editing //Could freeze all the water while editing? Or keep setting elapsed time on current segment. //Have to make it so seamless merge of segments at final position. -static void TestWaterUpdate(void) +void TestWaterUpdate(void) { static Int doInit=1; - static WaterTracksObj *track=NULL,*track2=NULL; + static WaterTracksObj *track=nullptr,*track2=nullptr; static Int trackEditMode=0; static waveType currentWaveType = WaveTypeOcean; POINT screenPoint; @@ -1225,8 +1225,8 @@ static void TestWaterUpdate(void) TheWaterTracksRenderSystem->unbindTrack(track2); haveStart=0; //reset for next segment haveEnd=0; - track=NULL; - track2=NULL; + track=nullptr; + track2=nullptr; } } else @@ -1255,8 +1255,8 @@ static void TestWaterUpdate(void) TheWaterTracksRenderSystem->saveTracks(); haveStart=0; //reset for next segment haveEnd=0; - track=NULL; - track2=NULL; + track=nullptr; + track2=nullptr; UnicodeString string; string.format(L"Saved Tracks"); TheInGameUI->message(string); @@ -1273,8 +1273,8 @@ static void TestWaterUpdate(void) TheWaterTracksRenderSystem->loadTracks(); haveStart=0; //reset for next segment haveEnd=0; - track=NULL; - track2=NULL; + track=nullptr; + track2=nullptr; UnicodeString string; string.format(L"Loaded Tracks"); TheInGameUI->message(string); diff --git a/Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp b/Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp index 225c8da6126..666655a5fa3 100644 --- a/Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp +++ b/Core/GameEngineDevice/Source/W3DDevice/GameClient/WorldHeightMap.cpp @@ -81,7 +81,7 @@ class GDIFileStream : public InputStream /* ********* MapObject class ****************************/ -/*static*/ MapObject *MapObject::TheMapObjectListPtr = NULL; +/*static*/ MapObject *MapObject::TheMapObjectListPtr = nullptr; /*static*/ Dict MapObject::TheWorldDict; MapObject::MapObject(Coord3D loc, AsciiString name, Real angle, Int flags, const Dict* props, @@ -89,13 +89,13 @@ MapObject::MapObject(Coord3D loc, AsciiString name, Real angle, Int flags, const { m_objectName = validateName( name, flags ); m_thingTemplate = thingTemplate; - m_nextMapObject = NULL; + m_nextMapObject = nullptr; m_location = loc; m_angle = normalizeAngle(angle); m_color = (0xff)<<8; // Bright green. m_flags = flags; - m_renderObj = NULL; - m_shadowObj = NULL; + m_renderObj = nullptr; + m_shadowObj = nullptr; m_runtimeFlags = 0; // Note - do NOT set TheKey_objectSelectable on creation - allow it to follow the .ini value unless specified by user action. jba. [3/20/2003] if (props) @@ -114,27 +114,27 @@ MapObject::MapObject(Coord3D loc, AsciiString name, Real angle, Int flags, const } for( Int i = 0; i < BRIDGE_MAX_TOWERS; ++i ) - setBridgeRenderObject( (BridgeTowerType)i, NULL ); + setBridgeRenderObject( (BridgeTowerType)i, nullptr ); } MapObject::~MapObject(void) { - setRenderObj(NULL); - setShadowObj(NULL); + setRenderObj(nullptr); + setShadowObj(nullptr); if (m_nextMapObject) { MapObject *cur = m_nextMapObject; MapObject *next; while (cur) { next = cur->getNext(); - cur->setNextMap(NULL); // prevents recursion. + cur->setNextMap(nullptr); // prevents recursion. deleteInstance(cur); cur = next; } } for( Int i = 0; i < BRIDGE_MAX_TOWERS; ++i ) - setBridgeRenderObject( (BridgeTowerType)i, NULL ); + setBridgeRenderObject( (BridgeTowerType)i, nullptr ); } @@ -164,7 +164,7 @@ RenderObjClass* MapObject::getBridgeRenderObject( BridgeTowerType type ) if( type >= 0 && type < BRIDGE_MAX_TOWERS ) return m_bridgeTowers[ type ]; - return NULL; + return nullptr; } @@ -361,13 +361,13 @@ const ThingTemplate *MapObject::getThingTemplate( void ) const if (m_thingTemplate) return (const ThingTemplate*) m_thingTemplate->getFinalOverride(); - return NULL; + return nullptr; } /* ********* WorldHeightMap class ****************************/ -TileData *WorldHeightMap::m_alphaTiles[NUM_ALPHA_TILES]={0,0,0,0,0,0,0,0,0,0,0,0}; +TileData *WorldHeightMap::m_alphaTiles[NUM_ALPHA_TILES]={0}; // // WorldHeightMap destructor . @@ -375,31 +375,31 @@ TileData *WorldHeightMap::m_alphaTiles[NUM_ALPHA_TILES]={0,0,0,0,0,0,0,0,0,0,0,0 WorldHeightMap::~WorldHeightMap(void) { delete[](m_data); - m_data = NULL; + m_data = nullptr; delete[](m_tileNdxes); - m_tileNdxes = NULL; + m_tileNdxes = nullptr; delete[](m_blendTileNdxes); - m_blendTileNdxes = NULL; + m_blendTileNdxes = nullptr; delete[](m_extraBlendTileNdxes); - m_extraBlendTileNdxes = NULL; + m_extraBlendTileNdxes = nullptr; delete[](m_cliffInfoNdxes); - m_cliffInfoNdxes = NULL; + m_cliffInfoNdxes = nullptr; delete[](m_cellFlipState); - m_cellFlipState = NULL; + m_cellFlipState = nullptr; delete[](m_seismicUpdateFlag); - m_seismicUpdateFlag = NULL; + m_seismicUpdateFlag = nullptr; delete[](m_seismicZVelocities); - m_seismicZVelocities = NULL; + m_seismicZVelocities = nullptr; delete[](m_cellCliffState); - m_cellCliffState = NULL; + m_cellCliffState = nullptr; int i; for (i=0; iclear(); } @@ -431,22 +431,22 @@ void WorldHeightMap::freeListOfMapObjects(void) transparent tile for non-blended tiles. */ WorldHeightMap::WorldHeightMap(): - m_width(0), m_height(0), m_dataSize(0), m_data(NULL), m_cellFlipState(NULL), m_seismicUpdateFlag(NULL), m_seismicZVelocities(NULL), + m_width(0), m_height(0), m_dataSize(0), m_data(nullptr), m_cellFlipState(nullptr), m_seismicUpdateFlag(nullptr), m_seismicZVelocities(nullptr), m_drawOriginX(0), m_drawOriginY(0), m_numTextureClasses(0), m_drawWidthX(NORMAL_DRAW_WIDTH), m_drawHeightY(NORMAL_DRAW_HEIGHT), - m_tileNdxes(NULL), m_blendTileNdxes(NULL), m_extraBlendTileNdxes(NULL), m_cliffInfoNdxes(NULL), - m_terrainTexHeight(1), m_alphaTexHeight(1), m_cellCliffState(NULL), + m_tileNdxes(nullptr), m_blendTileNdxes(nullptr), m_extraBlendTileNdxes(nullptr), m_cliffInfoNdxes(nullptr), + m_terrainTexHeight(1), m_alphaTexHeight(1), m_cellCliffState(nullptr), #ifdef EVAL_TILING_MODES m_tileMode(TILE_4x4), #endif m_numCliffInfo(1), - m_terrainTex(NULL), m_alphaTerrainTex(NULL), m_numBitmapTiles(0), m_numBlendedTiles(1) + m_terrainTex(nullptr), m_alphaTerrainTex(nullptr), m_numBitmapTiles(0), m_numBlendedTiles(1) { Int i; for (i=0; ivalidateSides(); @@ -470,23 +470,23 @@ static Bool ParseFunkyTilingDataChunk(DataChunkInput &file, DataChunkInfo *info, * */ WorldHeightMap::WorldHeightMap(ChunkInputStream *pStrm, Bool logicalDataOnly): - m_width(0), m_height(0), m_dataSize(0), m_data(NULL), m_cellFlipState(NULL), m_seismicUpdateFlag(NULL), m_seismicZVelocities(NULL), - m_drawOriginX(0), m_cellCliffState(NULL), m_drawOriginY(0), + m_width(0), m_height(0), m_dataSize(0), m_data(nullptr), m_cellFlipState(nullptr), m_seismicUpdateFlag(nullptr), m_seismicZVelocities(nullptr), + m_drawOriginX(0), m_cellCliffState(nullptr), m_drawOriginY(0), m_numTextureClasses(0), m_drawWidthX(NORMAL_DRAW_WIDTH), m_drawHeightY(NORMAL_DRAW_HEIGHT), - m_tileNdxes(NULL), m_blendTileNdxes(NULL), m_extraBlendTileNdxes(NULL), m_cliffInfoNdxes(NULL), + m_tileNdxes(nullptr), m_blendTileNdxes(nullptr), m_extraBlendTileNdxes(nullptr), m_cliffInfoNdxes(nullptr), m_terrainTexHeight(1), m_alphaTexHeight(1), #ifdef EVAL_TILING_MODES m_tileMode(TILE_4x4), #endif m_numCliffInfo(1), - m_terrainTex(NULL), m_alphaTerrainTex(NULL), m_numBitmapTiles(0), m_numBlendedTiles(1) + m_terrainTex(nullptr), m_alphaTerrainTex(nullptr), m_numBitmapTiles(0), m_numBlendedTiles(1) { int i; for (i=0; im_stretchTerrain) { m_drawWidthX=STRETCH_DRAW_WIDTH; @@ -830,7 +830,7 @@ Bool WorldHeightMap::ParseLightingDataChunk(DataChunkInput &file, DataChunkInfo */ Bool WorldHeightMap::ParseObjectsDataChunk(DataChunkInput &file, DataChunkInfo *info, void *userData) { - file.m_currentObject = NULL; + file.m_currentObject = nullptr; file.registerParser( "Object", info->label, ParseObjectDataChunk ); return (file.parse(userData)); } @@ -1005,12 +1005,12 @@ void WorldHeightMap::readTexClass(TXTextureClass *texClass, TileData **tileData) { char path[_MAX_PATH]; path[0] = 0; - File *theFile = NULL; + File *theFile = nullptr; // get the file from the description in TheTerrainTypes TerrainType *terrain = TheTerrainTypes->findTerrain( texClass->name ); char texturePath[ _MAX_PATH ]; - if (terrain==NULL) + if (terrain==nullptr) { #ifdef LOAD_TEST_ASSETS theFile = TheFileSystem->openFile( texClass->name.str(), File::READ|File::BINARY); @@ -1018,11 +1018,11 @@ void WorldHeightMap::readTexClass(TXTextureClass *texClass, TileData **tileData) } else { - sprintf( texturePath, "%s%s", TERRAIN_TGA_DIR_PATH, terrain->getTexture().str() ); + snprintf( texturePath, ARRAY_SIZE(texturePath), "%s%s", TERRAIN_TGA_DIR_PATH, terrain->getTexture().str() ); theFile = TheFileSystem->openFile( texturePath, File::READ|File::BINARY); } - if (theFile != NULL) { + if (theFile != nullptr) { GDIFileStream theStream(theFile); InputStream *pStr = &theStream; Int numTiles = WorldHeightMap::countTiles(pStr); @@ -1278,10 +1278,10 @@ Bool WorldHeightMap::ParseObjectData(DataChunkInput &file, DataChunkInfo *info, if (pPrevious) { - DEBUG_ASSERTCRASH(MapObject::TheMapObjectListPtr != NULL && pPrevious->getNext() == NULL, ("Bad linkage.")); + DEBUG_ASSERTCRASH(MapObject::TheMapObjectListPtr != nullptr && pPrevious->getNext() == nullptr, ("Bad linkage.")); pPrevious->setNextMap(pThisOne); } else { - DEBUG_ASSERTCRASH(MapObject::TheMapObjectListPtr == NULL, ("Bad linkage.")); + DEBUG_ASSERTCRASH(MapObject::TheMapObjectListPtr == nullptr, ("Bad linkage.")); MapObject::TheMapObjectListPtr = pThisOne; } file.m_currentObject = pThisOne; @@ -1386,7 +1386,7 @@ Bool WorldHeightMap::readTiles(InputStream *pStr, TileData **tiles, Int numRows) if (bytesPerPixel > 4) return(false); int i; for (i=0; im_tileLocationInTexture.x = x; @@ -1576,7 +1576,7 @@ Int WorldHeightMap::updateTileTexturePositions(Int *edgeHeight) availableGrid[row+j][column+i] = false; Int baseNdx = m_edgeTextureClasses[texClass].firstTile + i + j*width; // In case we are just checking for room... - if (m_edgeTiles[baseNdx] == NULL) continue; + if (m_edgeTiles[baseNdx] == nullptr) continue; Int x = xOrigin + i*TILE_PIXEL_EXTENT; Int y = yOrigin + (width-j-1)*TILE_PIXEL_EXTENT; // Use negative offsets to differentiate between tiles & edges. @@ -1591,10 +1591,10 @@ Int WorldHeightMap::updateTileTexturePositions(Int *edgeHeight) /** getUVData - Gets the texture coordinates to use. See getTerrainTexture. */ -void WorldHeightMap::getUVForNdx(Int tileNdx, float *minU, float *minV, float *maxU, float*maxV, Bool fullTile) +void WorldHeightMap::getUVForNdx(Int tileNdx, float *minU, float *minV, float *maxU, float*maxV) { Short baseNdx = tileNdx>>2; - if (m_sourceTiles[baseNdx] == NULL) { + if (m_sourceTiles[baseNdx] == nullptr) { // Missing texture. *minU = *minV = *maxU = *maxV = 0.0f; return; @@ -1620,21 +1620,20 @@ void WorldHeightMap::getUVForNdx(Int tileNdx, float *minU, float *minV, float *m *minV/=m_terrainTexHeight; *maxU/=TEXTURE_WIDTH; *maxV/=m_terrainTexHeight; - if (!fullTile) { - // Tiles are 64x64 pixels, height grids map to 32x32. - // So get the proper quadrant of the tile. - Real midX = (*minU+*maxU)/2; - Real midY = (*minV+*maxV)/2; - if (tileNdx&2) { // y's are flipped. - *maxV = midY; - } else { - *minV = midY; - } - if (tileNdx&1) { - *minU = midX; - } else { - *maxU = midX; - } + + // Tiles are 64x64 pixels, height grids map to 32x32. + // So get the proper quadrant of the tile. + Real midX = (*minU+*maxU)/2; + Real midY = (*minV+*maxV)/2; + if (tileNdx&2) { // y's are flipped. + *maxV = midY; + } else { + *minV = midY; + } + if (tileNdx&1) { + *minU = midX; + } else { + *maxU = midX; } } @@ -1660,12 +1659,10 @@ Bool WorldHeightMap::isCliffMappedTexture(Int x, Int y) { }; /** getUVData - Gets the texture coordinates to use. See getTerrainTexture. - xIndex and yIndex are the integer coorddinates into the height map. - U and V are the texture coordiantes for the 4 corners of a height map cell. - fullTile is true if we are doing 1/2 resolution height map, and require a full - tile to texture a cell. Otherwise, we use quarter tiles per cell. + xIndex and yIndex are the integer coordinates into the height map. + U and V are the texture coordinates for the 4 corners of a height map cell. */ -Bool WorldHeightMap::getUVData(Int xIndex, Int yIndex, float U[4], float V[4], Bool fullTile) +Bool WorldHeightMap::getUVData(Int xIndex, Int yIndex, float U[4], float V[4]) { #define dont_SHOW_THE_TEXTURE_FOR_DEBUG 1 #if SHOW_THE_TEXTURE_FOR_DEBUG @@ -1692,7 +1689,7 @@ Bool WorldHeightMap::getUVData(Int xIndex, Int yIndex, float U[4], float V[4], B Int ndx = (yIndex*m_width)+xIndex; if ((ndxm_adjustCliffTextures) { @@ -1723,9 +1718,6 @@ Bool WorldHeightMap::getUVForTileIndex(Int ndx, Short tileNdx, float U[4], float if (nU==0.0) { return false; // missing texture. } - if (fullTile) { - return false; - } if (m_cliffInfoNdxes[ndx]) { TCliffInfo info = m_cliffInfo[m_cliffInfoNdxes[ndx]]; Bool tilesMatch = false; @@ -1756,7 +1748,11 @@ Bool WorldHeightMap::getUVForTileIndex(Int ndx, Short tileNdx, float U[4], float return info.flip; } } -#define DO_OLD_UV + +// TheSuperHackers @bugfix xezon 11/12/2025 Disables the old uv adjustment for cliffs, +// because it produces bad uv tiles on steep terrain and is also not helping performance. +// @todo Delete this code when we are certain we never need this again. +//#define DO_OLD_UV #ifdef DO_OLD_UV // old uv adjustment for cliffs static Real STRETCH_LIMIT = 1.5f; // If it is stretching less than this, don't adjust. @@ -1773,7 +1769,7 @@ Bool WorldHeightMap::getUVForTileIndex(Int ndx, Short tileNdx, float U[4], float tilesPerRow *= 4; - getUVForNdx(tileNdx, &nU, &nV, &xU, &xV, fullTile); + getUVForNdx(tileNdx, &nU, &nV, &xU, &xV); U[0] = nU; U[1] = xU; U[2] = xU; U[3] = nU; V[0] = xV; V[1] = xV; V[2] = nV; V[3] = nV; if (TheGlobalData && !TheGlobalData->m_adjustCliffTextures) { @@ -1782,9 +1778,6 @@ Bool WorldHeightMap::getUVForTileIndex(Int ndx, Short tileNdx, float U[4], float if (nU==0.0) { return false; // missing texture. } - if (fullTile) { - return false; - } // check for excessive heights. if (ndx < this->m_dataSize - m_width - 1) { Int h0 = m_data[ndx]; @@ -1901,7 +1894,7 @@ Bool WorldHeightMap::getUVForTileIndex(Int ndx, Short tileNdx, float U[4], float return; #endif Real dx = (h3-h2)*HEIGHT_SCALE; - dx = sqrt(1+dx*dx); // lenght of the bottom of the cell + dx = sqrt(1+dx*dx); // length of the bottom of the cell Real dy = (h3-h0)*HEIGHT_SCALE; dy = sqrt(1+dy*dy); // length of the left side. if (dx>3)] |= flipForBlend << (x & 0x7); DEBUG_ASSERTCRASH ((y*m_flipStateWidth+(x>>3)) < (m_flipStateWidth * m_height), ("Bad range")); @@ -2193,7 +2182,7 @@ TextureClass *WorldHeightMap::getTerrainTexture(void) TextureClass *WorldHeightMap::getAlphaTerrainTexture(void) { - if (m_alphaTerrainTex == NULL) { + if (m_alphaTerrainTex == nullptr) { getTerrainTexture(); } return m_alphaTerrainTex; @@ -2201,7 +2190,7 @@ TextureClass *WorldHeightMap::getAlphaTerrainTexture(void) TextureClass *WorldHeightMap::getEdgeTerrainTexture(void) { - if (m_alphaEdgeTex == NULL) { + if (m_alphaEdgeTex == nullptr) { getTerrainTexture(); } return m_alphaEdgeTex; @@ -2393,12 +2382,12 @@ UnsignedByte * WorldHeightMap::getPointerToTileData(Int xIndex, Int yIndex, Int { Int ndx = (yIndex*m_width)+xIndex; if (yIndex<0 || xIndex<0 || xIndex>=m_width || yIndex>=m_height) { - return NULL; + return nullptr; } if (ndx<0 || ndx>=m_dataSize) { - return NULL; + return nullptr; } - TBlendTileInfo *pBlend = NULL; + TBlendTileInfo *pBlend = nullptr; Short tileNdx = m_tileNdxes[ndx]; if (getRawTileData(tileNdx, width, s_buffer, DATA_LEN_BYTES)) { Short blendTileNdx = m_blendTileNdxes[ndx]; @@ -2427,7 +2416,7 @@ UnsignedByte * WorldHeightMap::getPointerToTileData(Int xIndex, Int yIndex, Int return(s_buffer); } - return(NULL); + return(nullptr); } #define K_HORIZ 0 @@ -2462,7 +2451,7 @@ UnsignedByte *WorldHeightMap::getRGBAlphaDataForWidth(Int width, TBlendTileInfo void WorldHeightMap::setupAlphaTiles(void) { TBlendTileInfo blendInfo; - if (m_alphaTiles[0] != NULL) return; + if (m_alphaTiles[0] != nullptr) return; Int k; for (k=0; kdeleteOnClose(); if (ramFile->openFromArchive(m_file, fileInfo->m_filename, fileInfo->m_offset, fileInfo->m_size) == FALSE) { ramFile->close(); - ramFile = NULL; - return NULL; + ramFile = nullptr; + return nullptr; } if ((access & File::WRITE) == 0) { @@ -90,12 +90,12 @@ File* Win32BIGFile::openFile( const Char *filename, Int access ) constexpr size_t bufferSize = 0; File *localFile = TheLocalFileSystem->openFile(filename, access, bufferSize); - if (localFile != NULL) { + if (localFile != nullptr) { ramFile->copyDataToFile(localFile); } ramFile->close(); - ramFile = NULL; + ramFile = nullptr; return localFile; } @@ -153,7 +153,7 @@ Bool Win32BIGFile::getFileInfo(const AsciiString& filename, FileInfo *fileInfo) { const ArchivedFileInfo *tempFileInfo = getArchivedFileInfo(filename); - if (tempFileInfo == NULL) { + if (tempFileInfo == nullptr) { return FALSE; } diff --git a/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp b/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp index 5aaedc2f1b8..64401c47eff 100644 --- a/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp +++ b/Core/GameEngineDevice/Source/Win32Device/Common/Win32BIGFileSystem.cpp @@ -52,8 +52,8 @@ Win32BIGFileSystem::~Win32BIGFileSystem() { } void Win32BIGFileSystem::init() { - DEBUG_ASSERTCRASH(TheLocalFileSystem != NULL, ("TheLocalFileSystem must be initialized before TheArchiveFileSystem.")); - if (TheLocalFileSystem == NULL) { + DEBUG_ASSERTCRASH(TheLocalFileSystem != nullptr, ("TheLocalFileSystem must be initialized before TheArchiveFileSystem.")); + if (TheLocalFileSystem == nullptr) { return; } @@ -89,9 +89,9 @@ ArchiveFile * Win32BIGFileSystem::openArchiveFile(const Char *filename) { DEBUG_LOG(("Win32BIGFileSystem::openArchiveFile - opening BIG file %s", filename)); - if (fp == NULL) { + if (fp == nullptr) { DEBUG_CRASH(("Could not open archive file %s for parsing", filename)); - return NULL; + return nullptr; } AsciiString asciibuf; @@ -101,8 +101,8 @@ ArchiveFile * Win32BIGFileSystem::openArchiveFile(const Char *filename) { if (strcmp(buffer, BIGFileIdentifier) != 0) { DEBUG_CRASH(("Error reading BIG file identifier in file %s", filename)); fp->close(); - fp = NULL; - return NULL; + fp = nullptr; + return nullptr; } // read in the file size. @@ -174,7 +174,7 @@ ArchiveFile * Win32BIGFileSystem::openArchiveFile(const Char *filename) { archiveFile->attachFile(fp); delete fileInfo; - fileInfo = NULL; + fileInfo = nullptr; // leave fp open as the archive file will be using it. @@ -228,7 +228,7 @@ Bool Win32BIGFileSystem::loadBigFilesFromDirectory(AsciiString dir, AsciiString ArchiveFile *archiveFile = openArchiveFile((*it).str()); - if (archiveFile != NULL) { + if (archiveFile != nullptr) { DEBUG_LOG(("Win32BIGFileSystem::loadBigFilesFromDirectory - loading %s into the directory tree.", (*it).str())); loadIntoDirectoryTree(archiveFile, overwrite); m_archiveFileMap[(*it)] = archiveFile; diff --git a/Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp b/Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp index 84236de436b..43a6ca5cbdd 100644 --- a/Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp +++ b/Core/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp @@ -48,7 +48,7 @@ File * Win32LocalFileSystem::openFile(const Char *filename, Int access, size_t b // sanity check if (strlen(filename) <= 0) { - return NULL; + return nullptr; } if (access & File::WRITE) { @@ -60,7 +60,7 @@ File * Win32LocalFileSystem::openFile(const Char *filename, Int access, size_t b AsciiString dirName; string.nextToken(&token, "\\/"); dirName = token; - while ((token.find('.') == NULL) || (string.find('.') != NULL)) { + while ((token.find('.') == nullptr) || (string.find('.') != nullptr)) { createDirectory(dirName); string.nextToken(&token, "\\/"); dirName.concat('\\'); @@ -73,7 +73,7 @@ File * Win32LocalFileSystem::openFile(const Char *filename, Int access, size_t b if (file->open(filename, access, bufferSize) == FALSE) { deleteInstance(file); - file = NULL; + file = nullptr; } else { file->deleteOnClose(); } @@ -124,7 +124,7 @@ Bool Win32LocalFileSystem::doesFileExist(const Char *filename) const void Win32LocalFileSystem::getFileListInDirectory(const AsciiString& currentDirectory, const AsciiString& originalDirectory, const AsciiString& searchName, FilenameList & filenameList, Bool searchSubdirectories) const { - HANDLE fileHandle = NULL; + HANDLE fileHandle = nullptr; WIN32_FIND_DATA findData; AsciiString asciisearch; @@ -187,7 +187,7 @@ void Win32LocalFileSystem::getFileListInDirectory(const AsciiString& currentDire Bool Win32LocalFileSystem::getFileInfo(const AsciiString& filename, FileInfo *fileInfo) const { WIN32_FIND_DATA findData; - HANDLE findHandle = NULL; + HANDLE findHandle = nullptr; findHandle = FindFirstFile(filename.str(), &findData); if (findHandle == INVALID_HANDLE_VALUE) { @@ -206,15 +206,15 @@ Bool Win32LocalFileSystem::getFileInfo(const AsciiString& filename, FileInfo *fi Bool Win32LocalFileSystem::createDirectory(AsciiString directory) { - if ((directory.getLength() > 0) && (directory.getLength() < _MAX_DIR)) { - return (CreateDirectory(directory.str(), NULL) != 0); + if ((!directory.isEmpty()) && (directory.getLength() < _MAX_DIR)) { + return (CreateDirectory(directory.str(), nullptr) != 0); } return FALSE; } AsciiString Win32LocalFileSystem::normalizePath(const AsciiString& filePath) const { - DWORD retval = GetFullPathNameA(filePath.str(), 0, NULL, NULL); + DWORD retval = GetFullPathNameA(filePath.str(), 0, nullptr, nullptr); if (retval == 0) { DEBUG_LOG(("Unable to determine buffer size for normalized file path. Error=(%u).", GetLastError())); @@ -222,7 +222,7 @@ AsciiString Win32LocalFileSystem::normalizePath(const AsciiString& filePath) con } AsciiString normalizedFilePath; - retval = GetFullPathNameA(filePath.str(), retval, normalizedFilePath.getBufferForRead(retval - 1), NULL); + retval = GetFullPathNameA(filePath.str(), retval, normalizedFilePath.getBufferForRead(retval - 1), nullptr); if (retval == 0) { DEBUG_LOG(("Unable to normalize file path '%s'. Error=(%u).", filePath.str(), GetLastError())); diff --git a/Generals/Code/Libraries/Include/Lib/BaseType.h b/Core/Libraries/Include/Lib/BaseType.h similarity index 78% rename from Generals/Code/Libraries/Include/Lib/BaseType.h rename to Core/Libraries/Include/Lib/BaseType.h index ea7efe1f5ba..e0bc1a3caa2 100644 --- a/Generals/Code/Libraries/Include/Lib/BaseType.h +++ b/Core/Libraries/Include/Lib/BaseType.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 @@ -58,6 +58,28 @@ inline int sign(NUM x) else return 0; } +// TheSuperHackers @refactor JohnsterID 24/01/2026 Add lowercase min/max templates for GameEngine layer. +// GameEngine code typically uses BaseType.h, but may include WWVegas headers (which define min/max in always.h). +// Header guard prevents duplicate definitions. VC6's lacks std::min/std::max. +#ifndef _MIN_MAX_TEMPLATES_DEFINED_ +#define _MIN_MAX_TEMPLATES_DEFINED_ + +#ifdef min +#undef min +#endif + +#ifdef max +#undef max +#endif + +template +inline T min(T a, T b) { return (a < b) ? a : b; } + +template +inline T max(T a, T b) { return (a > b) ? a : b; } + +#endif // _MIN_MAX_TEMPLATES_DEFINED_ + //----------------------------------------------------------------------------- inline Real rad2deg(Real rad) { return rad * (180/PI); } inline Real deg2rad(Real rad) { return rad * (PI/180); } @@ -65,7 +87,7 @@ inline Real deg2rad(Real rad) { return rad * (PI/180); } //----------------------------------------------------------------------------- // For twiddling bits //----------------------------------------------------------------------------- -// TheSuperHackers @build xezon 22/03/2025 Renames BitTest to BitIsSet to prevent conflict with BitTest macro from winnt.h +// TheSuperHackers @build xezon 17/03/2025 Renames BitTest to BitIsSet to prevent conflict with BitTest macro from winnt.h #define BitIsSet( x, i ) ( ( (x) & (i) ) != 0 ) #define BitSet( x, i ) ( (x) |= (i) ) #define BitClear( x, i ) ( (x ) &= ~(i) ) @@ -151,8 +173,13 @@ __forceinline float fast_float_ceil(float f) #define INT_TO_REAL(x) ((Real)(x)) // once we've ceiled/floored, trunc and round are identical, and currently, round is faster... (srj) +#if RTS_GENERALS /*&& RETAIL_COMPATIBLE_CRC*/ #define REAL_TO_INT_CEIL(x) (fast_float2long_round(ceilf(x))) #define REAL_TO_INT_FLOOR(x) (fast_float2long_round(floorf(x))) +#else +#define REAL_TO_INT_CEIL(x) (fast_float2long_round(fast_float_ceil(x))) +#define REAL_TO_INT_FLOOR(x) (fast_float2long_round(fast_float_floor(x))) +#endif #define FAST_REAL_TRUNC(x) fast_float_trunc(x) #define FAST_REAL_CEIL(x) fast_float_ceil(x) @@ -195,12 +222,14 @@ struct Coord2D } } - Real toAngle( void ); ///< turn 2D vector into angle (where angle 0 is down the +x axis) + Real toAngle( void ) const; ///< turn 2D vector into angle (where angle 0 is down the +x axis) + void rotateByAngle(Real angle); ///< rotate the vector by the given angle (radians) }; -inline Real Coord2D::toAngle( void ) +inline Real Coord2D::toAngle( void ) const { +#if RTS_GENERALS /*&& RETAIL_COMPATIBLE_CRC*/ Coord2D vector; vector.x = x; @@ -242,7 +271,32 @@ inline Real Coord2D::toAngle( void ) // S is sign of angle - MSB return value; +#else + const Real len = length(); + if (len == 0.0f) + return 0.0f; + + Real c = x/len; + // bound it in case of numerical error + if (c < -1.0f) + c = -1.0f; + else if (c > 1.0f) + c = 1.0f; + return y < 0.0f ? -ACos(c) : ACos(c); +#endif +} + +inline void Coord2D::rotateByAngle(Real angle) +{ + Real cs = Cos(angle); + Real sn = Sin(angle); + + Real px = x * cs - y * sn; + Real py = x * sn + y * cs; + + x = px; + y = py; } struct ICoord2D @@ -375,6 +429,47 @@ struct Region3D Real depth( void ) const { return hi.z - lo.z; } void zero() { lo.zero(); hi.zero(); } + + void setFromPointsNoZ(const Coord3D* points, Int count) + { + lo.x = points[0].x; + lo.y = points[0].y; + hi.x = points[0].x; + hi.y = points[0].y; + for (Int i = 1; i < count; ++i) + { + if (points[i].x < lo.x) + lo.x = points[i].x; + if (points[i].y < lo.y) + lo.y = points[i].y; + if (points[i].x > hi.x) + hi.x = points[i].x; + if (points[i].y > hi.y) + hi.y = points[i].y; + } + } + + void setFromPoints(const Coord3D* points, Int count) + { + lo = points[0]; + hi = points[0]; + for (Int i = 1; i < count; ++i) + { + if (points[i].x < lo.x) + lo.x = points[i].x; + if (points[i].y < lo.y) + lo.y = points[i].y; + if (points[i].z < lo.z) + lo.z = points[i].z; + if (points[i].x > hi.x) + hi.x = points[i].x; + if (points[i].y > hi.y) + hi.y = points[i].y; + if (points[i].z > hi.z) + hi.z = points[i].z; + } + } + Bool isInRegionNoZ( const Coord3D *query ) const { return (lo.x < query->x) && (query->x < hi.x) @@ -432,3 +527,8 @@ struct RGBAColorInt UnsignedInt red, green, blue, alpha; // range between 0 and 255 }; + +// Modulo function working with negative values, required for angles +inline Real nmod(Real x, Real y) { + return fmod(fmod(x, y) + y, y); +} diff --git a/Core/Libraries/Include/Lib/BaseTypeCore.h b/Core/Libraries/Include/Lib/BaseTypeCore.h index 550bdd5adf8..ab702efd496 100644 --- a/Core/Libraries/Include/Lib/BaseTypeCore.h +++ b/Core/Libraries/Include/Lib/BaseTypeCore.h @@ -33,7 +33,6 @@ #include // TheSuperHackers @build feliwir 07/04/2025 Adds utility macros for cross-platform compatibility #include -#include #include /* @@ -88,22 +87,17 @@ #define TWO_PI 6.28318530718f #endif -#ifndef NULL -//#define NULL ((void *)0) -#define NULL 0 // C++ doesn't like casting void *'s into other pointers -#endif - // MSVC math.h defines overloaded functions with this name... //#ifndef abs //#define abs(x) (((x) < 0) ? -(x) : (x)) //#endif -#ifndef min -#define min(x,y) (((x)<(y)) ? (x) : (y)) +#ifndef MIN +#define MIN(x,y) (((x)<(y)) ? (x) : (y)) #endif -#ifndef max -#define max(x,y) (((x)>(y)) ? (x) : (y)) +#ifndef MAX +#define MAX(x,y) (((x)>(y)) ? (x) : (y)) #endif #ifndef TRUE diff --git a/GeneralsMD/Code/Libraries/Include/Lib/trig.h b/Core/Libraries/Include/Lib/trig.h similarity index 100% rename from GeneralsMD/Code/Libraries/Include/Lib/trig.h rename to Core/Libraries/Include/Lib/trig.h diff --git a/Core/Libraries/Source/Compression/CMakeLists.txt b/Core/Libraries/Source/Compression/CMakeLists.txt index 0f168201697..5a5fbc8275a 100644 --- a/Core/Libraries/Source/Compression/CMakeLists.txt +++ b/Core/Libraries/Source/Compression/CMakeLists.txt @@ -29,9 +29,8 @@ target_include_directories(core_compression INTERFACE ) target_link_libraries(core_compression PRIVATE - core_config - core_utility corei_libraries_include + corei_always ) diff --git a/Core/Libraries/Source/Compression/CompressionManager.cpp b/Core/Libraries/Source/Compression/CompressionManager.cpp index 0853a26745c..ca3343d6927 100644 --- a/Core/Libraries/Source/Compression/CompressionManager.cpp +++ b/Core/Libraries/Source/Compression/CompressionManager.cpp @@ -435,7 +435,7 @@ void DoCompressTest( void ) } delete compressedBuf; - compressedBuf = NULL; + compressedBuf = nullptr; } DEBUG_LOG(("d = %d -> %d", d.origSize, d.compressedSize[i])); @@ -443,10 +443,10 @@ void DoCompressTest( void ) DEBUG_LOG(("s_sizes[%s] = %d -> %d", it->first.str(), s_sizes[it->first].origSize, s_sizes[it->first].compressedSize[i])); delete[] buf; - buf = NULL; + buf = nullptr; delete[] uncompressedBuf; - uncompressedBuf = NULL; + uncompressedBuf = nullptr; } ++it; @@ -486,10 +486,10 @@ void DoCompressTest( void ) for (i = 0; i < COMPRESSION_MAX+1; ++i) { delete s_compressGathers[i]; - s_compressGathers[i] = NULL; + s_compressGathers[i] = nullptr; delete s_decompressGathers[i]; - s_decompressGathers[i] = NULL; + s_decompressGathers[i] = nullptr; } } diff --git a/Core/Libraries/Source/Compression/EAC/codex.h b/Core/Libraries/Source/Compression/EAC/codex.h index 2b80d2171fe..a0caafe6781 100644 --- a/Core/Libraries/Source/Compression/EAC/codex.h +++ b/Core/Libraries/Source/Compression/EAC/codex.h @@ -30,7 +30,7 @@ /* */ /* Version Date SE History */ /* ------- ------ -- ------- */ -/* 1.00 990824 FB codex API seperated from huff tool */ +/* 1.00 990824 FB codex API separated from huff tool */ /* 1.01 010427 FB fb6 32 bit size header */ /* 1.02 011011 FB c++ defaults */ /* 2.00 011015 FB bool, dest/source, new about struct,no QPUBLIC */ diff --git a/Core/Libraries/Source/Compression/EAC/huffencode.cpp b/Core/Libraries/Source/Compression/EAC/huffencode.cpp index d01f8a99117..06f51b39831 100644 --- a/Core/Libraries/Source/Compression/EAC/huffencode.cpp +++ b/Core/Libraries/Source/Compression/EAC/huffencode.cpp @@ -718,7 +718,7 @@ static void HUFF_analysis(struct HuffEncodeContext *EC, /* - maintains perfect tree - find intest code - - find intest branch thats shorter than maximum bits + - find intest branch that's shorter than maximum bits - graft one branch to the shorter branch - shorten the other code by 1 */ @@ -1181,8 +1181,8 @@ int GCALL HUFF_encode(void *compresseddata, const void *source, int sourcesize, int plen=0; struct HUFFMemStruct infile; struct HUFFMemStruct outfile; - struct HuffEncodeContext *EC=0; - void *deltabuf=0; + struct HuffEncodeContext *EC=nullptr; + void *deltabuf=nullptr; int opt=0; if (opts) opt = opts[0]; diff --git a/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp b/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp index 224084152a1..25d454c0b87 100644 --- a/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp +++ b/Core/Libraries/Source/Compression/LZHCompress/NoxCompress.cpp @@ -35,17 +35,17 @@ Bool DecompressFile (char *infile, char *outfile) { UnsignedInt rawSize = 0, compressedSize = 0; - FILE *inFilePtr = NULL; - FILE *outFilePtr= NULL; - char *inBlock = NULL; - char *outBlock = NULL; + FILE *inFilePtr = nullptr; + FILE *outFilePtr= nullptr; + char *inBlock = nullptr; + char *outBlock = nullptr; LZHL_DHANDLE decompress; Int ok = 0; size_t srcSz, dstSz; // Parameter checking - if (( infile == NULL ) || ( outfile == NULL )) + if (( infile == nullptr ) || ( outfile == nullptr )) return FALSE; inFilePtr = fopen( infile, "rb" ); @@ -67,7 +67,7 @@ Bool DecompressFile (char *infile, char *outfile) inBlock = (char *) DbgMalloc( compressedSize ); outBlock= (char *) DbgMalloc( rawSize ); - if (( inBlock == NULL ) || ( outBlock == NULL )) + if (( inBlock == nullptr ) || ( outBlock == nullptr )) { if (inBlock) DbgFree(inBlock); if (outBlock) DbgFree(outBlock); @@ -123,16 +123,16 @@ Bool CompressFile (char *infile, char *outfile) { UnsignedInt rawSize = 0; UnsignedInt compressedSize = 0, compressed = 0, i = 0; - FILE *inFilePtr = NULL; - FILE *outFilePtr= NULL; - char *inBlock = NULL; - char *outBlock = NULL; + FILE *inFilePtr = nullptr; + FILE *outFilePtr= nullptr; + char *inBlock = nullptr; + char *outBlock = nullptr; LZHL_CHANDLE compressor; UnsignedInt blocklen; // Parameter checking - if (( infile == NULL ) || ( outfile == NULL )) + if (( infile == nullptr ) || ( outfile == nullptr )) return FALSE; // Allocate the appropriate amount of memory @@ -148,7 +148,7 @@ Bool CompressFile (char *infile, char *outfile) inBlock = (char *) DbgMalloc(rawSize); outBlock= (char *) DbgMalloc( LZHLCompressorCalcMaxBuf( rawSize )); - if (( inBlock == NULL ) || ( outBlock == NULL )) + if (( inBlock == nullptr ) || ( outBlock == nullptr )) { DbgFree(inBlock); DbgFree(outBlock); @@ -164,7 +164,7 @@ Bool CompressFile (char *infile, char *outfile) compressor = LZHLCreateCompressor(); for ( i = 0; i < rawSize; i += BLOCKSIZE ) { - blocklen = min((UnsignedInt)BLOCKSIZE, rawSize - i); + blocklen = MIN((UnsignedInt)BLOCKSIZE, rawSize - i); compressed = LZHLCompress(compressor, outBlock + compressedSize, inBlock + i, blocklen); compressedSize += compressed; } @@ -193,7 +193,7 @@ Bool CompressPacket (char *inPacket, char *outPacket) { // Parameter checking - if (( inPacket == NULL ) || ( outPacket == NULL )) + if (( inPacket == nullptr ) || ( outPacket == nullptr )) return FALSE; return TRUE; @@ -204,7 +204,7 @@ Bool DecompressPacket (char *inPacket, char *outPacket) { // Parameter checking - if (( inPacket == NULL ) || ( outPacket == NULL )) + if (( inPacket == nullptr ) || ( outPacket == nullptr )) return FALSE; return TRUE; } @@ -226,7 +226,7 @@ Bool DecompressMemory (void *inBufferVoid, Int inSize, void *outBufferVoid, Int // Parameter checking - if (( inBuffer == NULL ) || ( outBuffer == NULL ) || ( inSize < 4 ) || ( outSize == 0 )) + if (( inBuffer == nullptr ) || ( outBuffer == nullptr ) || ( inSize < 4 ) || ( outSize == 0 )) return FALSE; // Get compressed size of file. @@ -273,7 +273,7 @@ Bool CompressMemory (void *inBufferVoid, Int inSize, void *outBufferVoid, Int& // Parameter checking - if (( inBuffer == NULL ) || ( outBuffer == NULL ) || ( inSize < 4 ) || ( outSize == 0 )) + if (( inBuffer == nullptr ) || ( outBuffer == nullptr ) || ( inSize < 4 ) || ( outSize == 0 )) return FALSE; rawSize = inSize; @@ -282,7 +282,7 @@ Bool CompressMemory (void *inBufferVoid, Int inSize, void *outBufferVoid, Int& compressor = LZHLCreateCompressor(); for ( i = 0; i < rawSize; i += BLOCKSIZE ) { - blocklen = min((UnsignedInt)BLOCKSIZE, rawSize - i); + blocklen = MIN((UnsignedInt)BLOCKSIZE, rawSize - i); compressed = LZHLCompress(compressor, outBuffer + compressedSize, inBuffer + i, blocklen); compressedSize += compressed; } diff --git a/Core/Libraries/Source/EABrowserDispatch/CMakeLists.txt b/Core/Libraries/Source/EABrowserDispatch/CMakeLists.txt index 169ea2db465..baef7ddbca3 100644 --- a/Core/Libraries/Source/EABrowserDispatch/CMakeLists.txt +++ b/Core/Libraries/Source/EABrowserDispatch/CMakeLists.txt @@ -1,16 +1,32 @@ add_library(core_browserdispatch INTERFACE) if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") - add_custom_command( - OUTPUT BrowserDispatch_i.c BrowserDispatch.h - COMMAND midl.exe "${CMAKE_CURRENT_LIST_DIR}\\BrowserDispatch.idl" /header BrowserDispatch.h - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS "${CMAKE_CURRENT_LIST_DIR}/BrowserDispatch.idl" - VERBATIM - ) - add_library(core_browserdispatchwin STATIC BrowserDispatch_i.c) - set_target_properties(core_browserdispatchwin PROPERTIES OUTPUT_NAME browserdispatchwin) - target_link_libraries(core_browserdispatch INTERFACE core_browserdispatchwin) + if(MINGW AND IDL_COMPILER_FOUND) + # Use widl for MinGW builds + add_idl_file(browserdispatch_idl "${CMAKE_CURRENT_LIST_DIR}/BrowserDispatch.idl") + add_library(core_browserdispatchwin STATIC ${browserdispatch_idl_IID} ${browserdispatch_idl_HEADER}) + elseif(MSVC) + # Use midl for MSVC builds + add_custom_command( + OUTPUT BrowserDispatch_i.c BrowserDispatch.h + COMMAND midl.exe "${CMAKE_CURRENT_LIST_DIR}\\BrowserDispatch.idl" /header BrowserDispatch.h /iid BrowserDispatch_i.c + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS "${CMAKE_CURRENT_LIST_DIR}/BrowserDispatch.idl" + VERBATIM + ) + add_library(core_browserdispatchwin STATIC BrowserDispatch_i.c) + else() + message(FATAL_ERROR + "EABrowserDispatch requires an IDL compiler for Windows builds:\n" + " - For MinGW: Install widl (apt-get install wine-stable-dev)\n" + " - For MSVC: midl.exe should be in PATH\n" + " - For other compilers: Not currently supported") + endif() + + if(TARGET core_browserdispatchwin) + set_target_properties(core_browserdispatchwin PROPERTIES OUTPUT_NAME browserdispatchwin) + target_link_libraries(core_browserdispatch INTERFACE core_browserdispatchwin) + endif() endif() target_include_directories(core_browserdispatch INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/..) diff --git a/Core/Libraries/Source/EABrowserEngine/CMakeLists.txt b/Core/Libraries/Source/EABrowserEngine/CMakeLists.txt index 6df92e01f92..58a12bb9c16 100644 --- a/Core/Libraries/Source/EABrowserEngine/CMakeLists.txt +++ b/Core/Libraries/Source/EABrowserEngine/CMakeLists.txt @@ -1,16 +1,32 @@ add_library(core_browserengine INTERFACE) if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") - add_custom_command( - OUTPUT BrowserEngine_i.c BrowserEngine.h - COMMAND midl.exe "${CMAKE_CURRENT_LIST_DIR}\\BrowserEngine.idl" /header BrowserEngine.h - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - DEPENDS "${CMAKE_CURRENT_LIST_DIR}/BrowserEngine.idl" - VERBATIM - ) - add_library(core_browserenginewin STATIC BrowserEngine_i.c) - set_target_properties(core_browserenginewin PROPERTIES OUTPUT_NAME browserenginewin) - target_link_libraries(core_browserengine INTERFACE core_browserenginewin) + if(MINGW AND IDL_COMPILER_FOUND) + # Use widl for MinGW builds + add_idl_file(browserengine_idl "${CMAKE_CURRENT_LIST_DIR}/BrowserEngine.idl") + add_library(core_browserenginewin STATIC ${browserengine_idl_IID} ${browserengine_idl_HEADER}) + elseif(MSVC) + # Use midl for MSVC builds + add_custom_command( + OUTPUT BrowserEngine_i.c BrowserEngine.h + COMMAND midl.exe "${CMAKE_CURRENT_LIST_DIR}\\BrowserEngine.idl" /header BrowserEngine.h /iid BrowserEngine_i.c + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS "${CMAKE_CURRENT_LIST_DIR}/BrowserEngine.idl" + VERBATIM + ) + add_library(core_browserenginewin STATIC BrowserEngine_i.c) + else() + message(FATAL_ERROR + "EABrowserEngine requires an IDL compiler for Windows builds:\n" + " - For MinGW: Install widl (apt-get install wine-stable-dev)\n" + " - For MSVC: midl.exe should be in PATH\n" + " - For other compilers: Not currently supported") + endif() + + if(TARGET core_browserenginewin) + set_target_properties(core_browserenginewin PROPERTIES OUTPUT_NAME browserenginewin) + target_link_libraries(core_browserengine INTERFACE core_browserenginewin) + endif() endif() target_include_directories(core_browserengine INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/..) diff --git a/Core/Libraries/Source/WWVegas/CMakeLists.txt b/Core/Libraries/Source/WWVegas/CMakeLists.txt index 6c1a97bc6d9..70b13daf85c 100644 --- a/Core/Libraries/Source/WWVegas/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/CMakeLists.txt @@ -7,8 +7,6 @@ target_compile_definitions(core_wwcommon INTERFACE ) target_link_libraries(core_wwcommon INTERFACE - core_config - core_utility d3d8lib milesstub stlport diff --git a/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt b/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt index 35c7ff4bd6e..d8a1a275779 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/WW3D2/CMakeLists.txt @@ -237,7 +237,7 @@ add_library(corei_ww3d2 INTERFACE) target_sources(corei_ww3d2 INTERFACE ${WW3D2_SRC}) -if (NOT IS_VS6_BUILD) +if (MSVC AND NOT IS_VS6_BUILD) target_link_libraries(corei_ww3d2 INTERFACE comsuppw ) @@ -245,4 +245,6 @@ endif() target_link_libraries(corei_ww3d2 INTERFACE core_browserengine + core_wwlib + core_wwmath ) diff --git a/Core/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp b/Core/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp index 0fb36d93ac3..eb560e6e94c 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/FramGrab.cpp @@ -37,8 +37,8 @@ FrameGrabClass::FrameGrabClass(const char *filename, MODE mode, int width, int h FrameRate = framerate; Counter = 0; - Stream = 0; - AVIFile = 0; + Stream = nullptr; + AVIFile = nullptr; if(Mode != AVI) return; @@ -49,15 +49,15 @@ FrameGrabClass::FrameGrabClass(const char *filename, MODE mode, int width, int h int result; char file[256]; do { - sprintf(file, "%s%d.AVI", filename, counter++); + snprintf(file, ARRAY_SIZE(file), "%s%d.AVI", filename, counter++); result = _access(file, 0); } while(result != -1); // Create new AVI file using AVIFileOpen. - hr = AVIFileOpen(&AVIFile, file, OF_WRITE | OF_CREATE, NULL); + hr = AVIFileOpen(&AVIFile, file, OF_WRITE | OF_CREATE, nullptr); if (hr != 0) { char buf[256]; - sprintf(buf, "Unable to open %s\n", Filename); + snprintf(buf, ARRAY_SIZE(buf), "Unable to open %s\n", Filename); OutputDebugString(buf); CleanupAVI(); return; @@ -120,9 +120,9 @@ FrameGrabClass::~FrameGrabClass() } void FrameGrabClass::CleanupAVI() { - if(Bitmap != 0) { GlobalFreePtr(Bitmap); Bitmap = 0; } - if(Stream != 0) { AVIStreamRelease(Stream); Stream = 0; } - if(AVIFile != 0) { AVIFileRelease(AVIFile); AVIFile = 0; } + if(Bitmap != nullptr) { GlobalFreePtr(Bitmap); Bitmap = nullptr; } + if(Stream != nullptr) { AVIStreamRelease(Stream); Stream = nullptr; } + if(AVIFile != nullptr) { AVIFileRelease(AVIFile); AVIFile = nullptr; } AVIFileExit(); Mode = RAW; @@ -133,7 +133,7 @@ void FrameGrabClass::GrabAVI(void *BitmapPointer) // CompressDIB(&bi, lpOld, &biNew, lpNew); // Save the compressed data using AVIStreamWrite. - HRESULT hr = AVIStreamWrite(Stream, Counter++, 1, BitmapPointer, BitmapInfoHeader.biSizeImage, AVIIF_KEYFRAME, NULL, NULL); + HRESULT hr = AVIStreamWrite(Stream, Counter++, 1, BitmapPointer, BitmapInfoHeader.biSizeImage, AVIIF_KEYFRAME, nullptr, nullptr); if(hr != 0) { char buf[256]; sprintf(buf, "avi write error %x/%d\n", hr, hr); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/aabtree.cpp b/Core/Libraries/Source/WWVegas/WW3D2/aabtree.cpp index 0dc4fb8cc29..7710545b3a2 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/aabtree.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/aabtree.cpp @@ -88,10 +88,10 @@ *=============================================================================================*/ AABTreeClass::AABTreeClass(void) : NodeCount(0), - Nodes(NULL), + Nodes(nullptr), PolyCount(0), - PolyIndices(NULL), - Mesh(NULL) + PolyIndices(nullptr), + Mesh(nullptr) { } @@ -137,10 +137,10 @@ AABTreeClass::AABTreeClass(AABTreeBuilderClass * builder) *=============================================================================================*/ AABTreeClass::AABTreeClass(const AABTreeClass & that) : NodeCount(0), - Nodes(NULL), + Nodes(nullptr), PolyCount(0), - PolyIndices(0), - Mesh(NULL) + PolyIndices(nullptr), + Mesh(nullptr) { *this = that; } @@ -212,13 +212,13 @@ void AABTreeClass::Reset(void) { NodeCount = 0; delete[] Nodes; - Nodes = NULL; + Nodes = nullptr; PolyCount = 0; delete[] PolyIndices; - PolyIndices = NULL; + PolyIndices = nullptr; - Mesh = NULL; + Mesh = nullptr; } /*********************************************************************************************** @@ -267,9 +267,9 @@ void AABTreeClass::Build_Tree_Recursive(AABTreeBuilderClass::CullNodeStruct * no /* ** If this is a non-leaf node, set up the child indices, otherwise set up the polygon indices */ - if (node->Front != NULL) { + if (node->Front != nullptr) { - WWASSERT(node->Back != NULL); // if we have one child, we better have both! + WWASSERT(node->Back != nullptr); // if we have one child, we better have both! newnode->Set_Front_Child(node->Front->Index); newnode->Set_Back_Child(node->Back->Index); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/aabtree.h b/Core/Libraries/Source/WWVegas/WW3D2/aabtree.h index d38dc9d6d01..1e96e96cc1e 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/aabtree.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/aabtree.h @@ -224,7 +224,7 @@ inline int AABTreeClass::Compute_Ram_Size(void) inline bool AABTreeClass::Cast_Ray(RayCollisionTestClass & raytest) { - WWASSERT(Nodes != NULL); + WWASSERT(Nodes != nullptr); return Cast_Ray_Recursive(&(Nodes[0]),raytest); } @@ -241,7 +241,7 @@ inline int AABTreeClass::Cast_Semi_Infinite_Axis_Aligned_Ray(const Vector3 & sta static const int axis_1[6] = { 1, 1, 2, 2, 0, 0 }; static const int axis_2[6] = { 2, 2, 0, 0, 1, 1 }; static const int direction[6] = { 1, 0, 1, 0, 1, 0 }; - WWASSERT(Nodes != NULL); + WWASSERT(Nodes != nullptr); WWASSERT(axis_dir >= 0); WWASSERT(axis_dir < 6); @@ -255,25 +255,25 @@ inline int AABTreeClass::Cast_Semi_Infinite_Axis_Aligned_Ray(const Vector3 & sta inline bool AABTreeClass::Cast_AABox(AABoxCollisionTestClass & boxtest) { - WWASSERT(Nodes != NULL); + WWASSERT(Nodes != nullptr); return Cast_AABox_Recursive(&(Nodes[0]),boxtest); } inline bool AABTreeClass::Cast_OBBox(OBBoxCollisionTestClass & boxtest) { - WWASSERT(Nodes != NULL); + WWASSERT(Nodes != nullptr); return Cast_OBBox_Recursive(&(Nodes[0]),boxtest); } inline bool AABTreeClass::Intersect_OBBox(OBBoxIntersectionTestClass & boxtest) { - WWASSERT(Nodes != NULL); + WWASSERT(Nodes != nullptr); return Intersect_OBBox_Recursive(&(Nodes[0]),boxtest); } inline void AABTreeClass::Update_Bounding_Boxes(void) { - WWASSERT(Nodes != NULL); + WWASSERT(Nodes != nullptr); Update_Bounding_Boxes_Recursive(&(Nodes[0])); } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/agg_def.cpp b/Core/Libraries/Source/WWVegas/WW3D2/agg_def.cpp index 9353b289781..f65e97de9fb 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/agg_def.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/agg_def.cpp @@ -65,7 +65,7 @@ AggregateLoaderClass _AggregateLoader; // AggregateDefClass // AggregateDefClass::AggregateDefClass (void) - : m_pName (NULL) + : m_pName (nullptr) { // Set our member data to default settings ::memset (&m_Info, 0, sizeof (m_Info)); @@ -80,7 +80,7 @@ AggregateDefClass::AggregateDefClass (void) // AggregateDefClass // AggregateDefClass::AggregateDefClass (const AggregateDefClass &src) - : m_pName (NULL) + : m_pName (nullptr) { // Set our member data to default settings ::memset (&m_Info, 0, sizeof (m_Info)); @@ -98,7 +98,7 @@ AggregateDefClass::AggregateDefClass (const AggregateDefClass &src) // AggregateDefClass // AggregateDefClass::AggregateDefClass (RenderObjClass &base_model) - : m_pName (NULL) + : m_pName (nullptr) { // Set our member data to default settings ::memset (&m_Info, 0, sizeof (m_Info)); @@ -117,11 +117,11 @@ AggregateDefClass::AggregateDefClass (RenderObjClass &base_model) AggregateDefClass::~AggregateDefClass (void) { // Free the name buffer if necessary - if (m_pName != NULL) { + if (m_pName != nullptr) { // free() is used because the buffer was allocated with ::_strdup(). ::free (m_pName); - m_pName = NULL; + m_pName = nullptr; } Free_Subobject_List (); @@ -139,9 +139,9 @@ AggregateDefClass::operator= (const AggregateDefClass &src) int index; // Free the name buffer if necessary - if (m_pName != NULL) { + if (m_pName != nullptr) { ::free (m_pName); - m_pName = NULL; + m_pName = nullptr; } // Start with a fresh set of data @@ -156,7 +156,7 @@ AggregateDefClass::operator= (const AggregateDefClass &src) // Loop through all the entries in the src object's subobj list for (index = 0; index < src.m_SubobjectList.Count (); index ++) { W3dAggregateSubobjectStruct *pinfo = src.m_SubobjectList[index]; - if (pinfo != NULL) { + if (pinfo != nullptr) { // Copy the src object's info for this subobj W3dAggregateSubobjectStruct *new_info = W3DNEW W3dAggregateSubobjectStruct; @@ -200,7 +200,7 @@ AggregateDefClass::Create (void) { // Attempt to create an instance of the hierarchy RenderObjClass *pmodel = Create_Render_Object (m_Info.BaseModelName); - if (pmodel != NULL) { + if (pmodel != nullptr) { // Perform the aggregation Attach_Subobjects (*pmodel); @@ -237,11 +237,11 @@ AggregateDefClass::Find_Subobject // Loop through all the models in our "path" until we've either failed // or found the exact mesh we were looking for... for (int index = 1; - (mesh_path[index][0] != 0) && (parent_model != NULL); + (mesh_path[index][0] != 0) && (parent_model != nullptr); index ++) { // Look one level deeper into the subobject chain... - RenderObjClass *sub_obj = NULL; + RenderObjClass *sub_obj = nullptr; if (bone_path[index][0] == 0) { sub_obj = parent_model->Get_Sub_Object_By_Name (mesh_path[index]); } else { @@ -250,11 +250,11 @@ AggregateDefClass::Find_Subobject int subobj_count = parent_model->Get_Num_Sub_Objects_On_Bone (bone_index); // Loop through all the subobjects on this bone - for (int subobj_index = 0; (subobj_index < subobj_count) && (sub_obj == NULL); subobj_index ++) { + for (int subobj_index = 0; (subobj_index < subobj_count) && (sub_obj == nullptr); subobj_index ++) { // Is this the subobject we were looking for? RenderObjClass *ptemp_obj = parent_model->Get_Sub_Object_On_Bone (subobj_index, bone_index); - if (ptemp_obj == NULL) + if (ptemp_obj == nullptr) continue; if (::lstrcmpi (ptemp_obj->Get_Name (), mesh_path[index]) == 0) { @@ -286,11 +286,11 @@ AggregateDefClass::Attach_Subobjects (RenderObjClass &base_model) // Now loop through all the subobjects and attach them to the appropriate bone for (int index = 0; index < m_SubobjectList.Count (); index ++) { W3dAggregateSubobjectStruct *psubobj_info = m_SubobjectList[index]; - if (psubobj_info != NULL) { + if (psubobj_info != nullptr) { // Now create this subobject and attach it to its bone. RenderObjClass *prender_obj = Create_Render_Object (psubobj_info->SubobjectName); - if (prender_obj != NULL) { + if (prender_obj != nullptr) { // Attach this object to the requested bone if (base_model.Add_Sub_Object_To_Bone (prender_obj, psubobj_info->BoneName) == false) { @@ -317,14 +317,14 @@ RenderObjClass * AggregateDefClass::Create_Render_Object (const char *passet_name) { // Assume failure - RenderObjClass *prender_obj = NULL; + RenderObjClass *prender_obj = nullptr; // Attempt to get an instance of the render object from the asset manager prender_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj (passet_name); // If we couldn't find the render object in the asset manager, then attempt to // load it from file - if ((prender_obj == NULL) && + if ((prender_obj == nullptr) && Load_Assets (passet_name)) { // It should be in the asset manager now, so attempt to get it again. @@ -347,7 +347,7 @@ AggregateDefClass::Load_Assets (const char *passet_name) bool retval = false; // Param OK? - if (passet_name != NULL) { + if (passet_name != nullptr) { // Determine what the current working directory is char path[MAX_PATH]; @@ -385,7 +385,7 @@ AggregateDefClass::Initialize (RenderObjClass &base_model) // Determine what the render objects original name was. const char *orig_model_name = base_model.Get_Base_Model_Name (); - orig_model_name = (orig_model_name == NULL) ? base_model.Get_Name () : orig_model_name; + orig_model_name = (orig_model_name == nullptr) ? base_model.Get_Name () : orig_model_name; // Record information about this base model ::lstrcpy (m_Info.BaseModelName, orig_model_name); @@ -437,7 +437,7 @@ AggregateDefClass::Build_Subobject_List index < original_model.Get_Num_Sub_Objects_On_Bone (bone_index); index ++) { RenderObjClass *psubobj = original_model.Get_Sub_Object_On_Bone (index, bone_index); - if (psubobj != NULL) { + if (psubobj != nullptr) { orig_node_list.Add (psubobj); } } @@ -448,7 +448,7 @@ AggregateDefClass::Build_Subobject_List index < model.Get_Num_Sub_Objects_On_Bone (bone_index); index ++) { RenderObjClass *psubobj = model.Get_Sub_Object_On_Bone (index, bone_index); - if (psubobj != NULL) { + if (psubobj != nullptr) { node_list.Add (psubobj); } } @@ -460,11 +460,11 @@ AggregateDefClass::Build_Subobject_List W3dAggregateSubobjectStruct subobj_info = { 0 }; for (int node_index = 0; node_index < node_count; node_index ++) { RenderObjClass *psubobject = node_list[node_index]; - WWASSERT (psubobject != NULL); + WWASSERT (psubobject != nullptr); // Is this subobject new? (i.e. not in a 'vanilla' instance?) const char *prototype_name = psubobject->Get_Name (); - if (psubobject != NULL && + if (psubobject != nullptr && (Is_Object_In_List (prototype_name, orig_node_list) == false)) { // Add this subobject to our list @@ -519,7 +519,7 @@ AggregateDefClass::Is_Object_In_List RenderObjClass *prender_obj = node_list[node_index]; // Is this the render object we were looking for? - if (prender_obj != NULL && + if (prender_obj != nullptr && ::lstrcmpi (prender_obj->Get_Name (), passet_name) == 0) { retval = true; } @@ -870,11 +870,11 @@ PrototypeClass * AggregateLoaderClass::Load_W3D (ChunkLoadClass &chunk_load) { // Assume failure - AggregatePrototypeClass *pprototype = NULL; + AggregatePrototypeClass *pprototype = nullptr; // Create a definition object AggregateDefClass *pdefinition = W3DNEW AggregateDefClass; - if (pdefinition != NULL) { + if (pdefinition != nullptr) { // Ask the definition object to load the aggregate data if (pdefinition->Load_W3D (chunk_load) != WW3D_ERROR_OK) { diff --git a/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp b/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp index 8202d5ce2fb..dd5150377ad 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.cpp @@ -58,7 +58,7 @@ ////////////////////////////////////////////////////////////////////// HashTemplateClass AnimatedSoundMgrClass::AnimationNameHash; DynamicVectorClass AnimatedSoundMgrClass::AnimSoundLists; -SoundLibraryBridgeClass* AnimatedSoundMgrClass::SoundLibrary = NULL; +SoundLibraryBridgeClass* AnimatedSoundMgrClass::SoundLibrary = nullptr; ////////////////////////////////////////////////////////////////////// // Local inlines @@ -66,7 +66,7 @@ SoundLibraryBridgeClass* AnimatedSoundMgrClass::SoundLibrary = N static WWINLINE INIClass * Get_INI (const char *filename) { - INIClass *ini = NULL; + INIClass *ini = nullptr; // // Get the file from our filefactory @@ -100,12 +100,12 @@ Build_List_From_String { int count = 0; - WWASSERT (buffer != NULL); - WWASSERT (delimiter != NULL); - WWASSERT (string_list != NULL); - if ((buffer != NULL) && - (delimiter != NULL) && - (string_list != NULL)) + WWASSERT (buffer != nullptr); + WWASSERT (delimiter != nullptr); + WWASSERT (string_list != nullptr); + if ((buffer != nullptr) && + (delimiter != nullptr) && + (string_list != nullptr)) { int delim_len = ::strlen (delimiter); @@ -114,7 +114,7 @@ Build_List_From_String // const char *entry = buffer; for (; - (entry != NULL) && (entry[1] != 0); + (entry != nullptr) && (entry[1] != 0); entry = ::strstr (entry, delimiter)) { @@ -141,7 +141,7 @@ Build_List_From_String // count = 0; for (entry = buffer; - (entry != NULL) && (entry[1] != 0); + (entry != nullptr) && (entry[1] != 0); entry = ::strstr (entry, delimiter)) { @@ -157,14 +157,14 @@ Build_List_From_String // StringClass entry_string = entry; char *delim_start = ::strstr (entry_string.Peek_Buffer(), delimiter); - if (delim_start != NULL) { + if (delim_start != nullptr) { delim_start[0] = 0; } // // Add this entry to our list // - if ((entry_string.Get_Length () > 0) || (count == 0)) { + if ((!entry_string.Is_Empty()) || (count == 0)) { (*string_list)[count++] = entry_string; } } @@ -195,8 +195,8 @@ Is_In_Param_List // // Check incoming parameters // - WWASSERT( param_list != NULL ); - if ( param_list == NULL ) + WWASSERT( param_list != nullptr ); + if ( param_list == nullptr ) { return( false ); } @@ -205,8 +205,8 @@ Is_In_Param_List { return( false ); } - WWASSERT( param_to_check != NULL ); - if ( param_to_check == NULL ) + WWASSERT( param_to_check != nullptr ); + if ( param_to_check == nullptr ) { return( false ); } @@ -226,7 +226,7 @@ Is_In_Param_List // OutputDebugString( "\n" ); // if ( stricmp( string.Peek_Buffer(), param_to_check ) == 0 ) // Breaks with whitespaces - if ( strstr( string.str(), param_to_check ) != 0 ) + if ( strstr( string.str(), param_to_check ) != nullptr ) { return( true ); } @@ -257,7 +257,7 @@ AnimatedSoundMgrClass::Initialize (const char *ini_filename) // Determine which filename to use // const char *filename_to_use = ini_filename; - if (filename_to_use == NULL) { + if (filename_to_use == nullptr) { filename_to_use = DEFAULT_INI_FILENAME; } @@ -265,14 +265,14 @@ AnimatedSoundMgrClass::Initialize (const char *ini_filename) // Get the INI file which contains the data for this viewer // INIClass *ini_file = ::Get_INI (filename_to_use); - if (ini_file != NULL) { + if (ini_file != nullptr) { // // Loop over all the sections in the INI // List §ion_list = ini_file->Get_Section_List (); for ( INISection *section = section_list.First (); - section != NULL && section->Is_Valid (); + section != nullptr && section->Is_Valid (); section = section->Next_Valid ()) { // @@ -332,7 +332,7 @@ AnimatedSoundMgrClass::Initialize (const char *ini_filename) // // Separate the parameters into an easy-to-handle data structure // - StringClass *param_list = NULL; + StringClass *param_list = nullptr; int param_count = ::Build_List_From_String (value, ",", ¶m_list); // if ((param_count >= 2) && (param_count <= 3)) @@ -437,12 +437,12 @@ AnimatedSoundMgrClass::Shutdown (void) const char* AnimatedSoundMgrClass::Get_Embedded_Sound_Name (HAnimClass *anim) { - if (anim == NULL) { - return NULL; + if (anim == nullptr) { + return nullptr; } ANIM_SOUND_LIST* list = Find_Sound_List (anim); - if (list == NULL) { - return NULL; + if (list == nullptr) { + return nullptr; } return list->BoneName.str(); @@ -491,7 +491,7 @@ AnimatedSoundMgrClass::Trigger_Sound const Matrix3D & tm ) { - if ((SoundLibrary == NULL) || (anim == NULL)) { + if ((SoundLibrary == nullptr) || (anim == nullptr)) { return old_frame; } @@ -502,7 +502,7 @@ AnimatedSoundMgrClass::Trigger_Sound // Lookup the sound list for this animation // ANIM_SOUND_LIST *sound_list = Find_Sound_List (anim); - if (sound_list != NULL) { + if (sound_list != nullptr) { for (int index = 0; index < sound_list->List.Count (); index ++) { int frame = sound_list->List[index]->Frame; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h b/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h index 980e259591b..785cc7f32f5 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/animatedsoundmgr.h @@ -68,7 +68,7 @@ class AnimatedSoundMgrClass // // Initialization and shutdown // - static void Initialize (const char *ini_filename = NULL); + static void Initialize (const char *ini_filename = nullptr); static void Shutdown (void); // diff --git a/Core/Libraries/Source/WWVegas/WW3D2/bitmaphandler.cpp b/Core/Libraries/Source/WWVegas/WW3D2/bitmaphandler.cpp index 3b387a4a433..9bba18e5f34 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/bitmaphandler.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/bitmaphandler.cpp @@ -113,16 +113,16 @@ void BitmapHandlerClass::Copy_Image_Generate_Mipmap( unsigned b8g8r8a8_10; unsigned b8g8r8a8_11; for (unsigned x=0;xSet_Container(NULL); + SubObjects[i]->Set_Container(nullptr); SubObjects[i]->Release_Ref(); - SubObjects[i] = NULL; + SubObjects[i] = nullptr; } SubObjects.Delete_All(); ProxyList.Delete_All (); @@ -531,7 +531,7 @@ int CollectionClass::Add_Sub_Object(RenderObjClass * subobj) *=============================================================================================*/ int CollectionClass::Remove_Sub_Object(RenderObjClass * robj) { - if (robj == NULL) return 0; + if (robj == nullptr) return 0; int res = 0; @@ -543,7 +543,7 @@ int CollectionClass::Remove_Sub_Object(RenderObjClass * robj) if (Is_In_Scene()) { SubObjects[i]->Notify_Removed(Scene); } - SubObjects[i]->Set_Container(NULL); + SubObjects[i]->Set_Container(nullptr); SubObjects[i]->Set_Transform(tm); SubObjects[i]->Release_Ref(); res = SubObjects.Delete(i); @@ -744,7 +744,7 @@ int CollectionClass::Snap_Point_Count(void) *=============================================================================================*/ void CollectionClass::Get_Snap_Point(int index,Vector3 * set) { - WWASSERT(set != NULL); + WWASSERT(set != nullptr); if (SnapPoints) { *set = (*SnapPoints)[index]; } else { @@ -816,7 +816,7 @@ void CollectionClass::Update_Obj_Space_Bounding_Volumes(void) } Matrix3D tm = Get_Transform(); - Set_Transform(Matrix3D(1)); + Set_Transform(Matrix3D(true)); // loop through all sub-objects, combining their bounding spheres. BoundSphere = SubObjects[0]->Get_Bounding_Sphere(); @@ -929,7 +929,7 @@ int CollectionClass::Get_Proxy_Count (void) const *=============================================================================================*/ CollectionDefClass::CollectionDefClass(void) { - SnapPoints = NULL; + SnapPoints = nullptr; } @@ -1088,15 +1088,15 @@ PrototypeClass * CollectionLoaderClass::Load_W3D(ChunkLoadClass & cload) { CollectionDefClass * def = W3DNEW CollectionDefClass; - if (def == NULL) { - return NULL; + if (def == nullptr) { + return nullptr; } if (def->Load(cload) != WW3D_ERROR_OK) { // load failed, delete the model and return an error delete def; - return NULL; + return nullptr; } else { diff --git a/Core/Libraries/Source/WWVegas/WW3D2/coltest.h b/Core/Libraries/Source/WWVegas/WW3D2/coltest.h index 0601a819470..5d86e248b33 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/coltest.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/coltest.h @@ -98,7 +98,7 @@ class CollisionTestClass inline CollisionTestClass::CollisionTestClass(CastResultStruct * res,int collision_type) : Result(res), CollisionType(collision_type), - CollidedRenderObj(NULL) + CollidedRenderObj(nullptr) { } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/composite.cpp b/Core/Libraries/Source/WWVegas/WW3D2/composite.cpp index 5924b3d8151..76fd7d37f1e 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/composite.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/composite.cpp @@ -206,10 +206,10 @@ void CompositeRenderObjClass::Set_Name(const char * name) *=============================================================================================*/ void CompositeRenderObjClass::Set_Base_Model_Name(const char *name) { - // NULL is a legal value for BaseModelName. Unfortunately, + // null is a legal value for BaseModelName. Unfortunately, // StringClass::operator= does not modify the string when - // assigning NULL, so we explicitly handle that case here. - if (name != 0) { + // assigning null, so we explicitly handle that case here. + if (name != nullptr) { BaseModelName = name; } else { BaseModelName = ""; @@ -479,7 +479,7 @@ void CompositeRenderObjClass::Delete_Decal(uint32 decal_id) void CompositeRenderObjClass::Update_Obj_Space_Bounding_Volumes(void) { int i; - RenderObjClass * robj = NULL; + RenderObjClass * robj = nullptr; // if we don't have any sub objects, just set default bounds if (Get_Num_Sub_Objects() <= 0) { @@ -553,7 +553,7 @@ void CompositeRenderObjClass::Set_User_Data(void *value, bool recursive) const char * CompositeRenderObjClass::Get_Base_Model_Name (void) const { if (BaseModelName.Is_Empty()) { - return NULL; + return nullptr; } return BaseModelName; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/decalsys.cpp b/Core/Libraries/Source/WWVegas/WW3D2/decalsys.cpp index 6ea694d29d9..04a1835731c 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/decalsys.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/decalsys.cpp @@ -174,12 +174,12 @@ DecalGeneratorClass::DecalGeneratorClass(uint32 id,DecalSystemClass * system) : System(system), BackfaceVal(0.0f), ApplyToTranslucentMeshes(false), - Material(NULL) + Material(nullptr) { Material = NEW_REF(MaterialPassClass,()); - WWASSERT(System != NULL); - WWASSERT(Material != NULL); + WWASSERT(System != nullptr); + WWASSERT(Material != nullptr); } @@ -277,7 +277,7 @@ void DecalGeneratorClass::Set_Mesh_Transform(const Matrix3D & mesh_transform) if (WW3D::Is_Texturing_Enabled()) { float texsize = 64.0f; TextureClass * tex = Material->Peek_Texture(); - WWASSERT(tex != NULL); + WWASSERT(tex != nullptr); if (tex) { // SurfaceClass::SurfaceDescription surface_desc; // tex->Get_Level_Description(surface_desc); @@ -295,7 +295,7 @@ void DecalGeneratorClass::Set_Mesh_Transform(const Matrix3D & mesh_transform) */ MultiFixedPoolDecalSystemClass::MultiFixedPoolDecalSystemClass(uint32 num_pools, const uint32 *pool_sizes) : - Pools(0), + Pools(nullptr), PoolCount(num_pools), Generator_PoolID(0), Generator_SlotID(0) @@ -312,7 +312,7 @@ MultiFixedPoolDecalSystemClass::MultiFixedPoolDecalSystemClass(uint32 num_pools, } MultiFixedPoolDecalSystemClass::MultiFixedPoolDecalSystemClass(const MultiFixedPoolDecalSystemClass & that) : - Pools(0), + Pools(nullptr), PoolCount(that.PoolCount), Generator_PoolID(that.Generator_PoolID), Generator_SlotID(that.Generator_SlotID) @@ -330,7 +330,7 @@ MultiFixedPoolDecalSystemClass::MultiFixedPoolDecalSystemClass(const MultiFixedP MultiFixedPoolDecalSystemClass::~MultiFixedPoolDecalSystemClass(void) { delete [] Pools; - Pools = NULL; + Pools = nullptr; } // This clears the slot in addition to locking the generator, thus preventing any decal id @@ -461,7 +461,7 @@ void MultiFixedPoolDecalSystemClass::LogicalDecalClass::Clear(uint32 decal_id) */ MultiFixedPoolDecalSystemClass::LogicalDecalPoolClass::LogicalDecalPoolClass(void) : - Array(NULL), + Array(nullptr), Size(0) { } @@ -469,13 +469,13 @@ MultiFixedPoolDecalSystemClass::LogicalDecalPoolClass::LogicalDecalPoolClass(voi MultiFixedPoolDecalSystemClass::LogicalDecalPoolClass::~LogicalDecalPoolClass(void) { delete [] Array; - Array = NULL; + Array = nullptr; } void MultiFixedPoolDecalSystemClass::LogicalDecalPoolClass::Initialize(uint32 size) { delete [] Array; - Array = NULL; + Array = nullptr; Size = size; assert(Size); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/decalsys.h b/Core/Libraries/Source/WWVegas/WW3D2/decalsys.h index 6d7cbc1aa6c..f16dde43b15 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/decalsys.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/decalsys.h @@ -162,7 +162,7 @@ class DecalGeneratorClass : public ProjectorClass ** Material parameters: just grab a pointer the material pass and modify it. ** Remember to release your ref to it when you are done. */ - MaterialPassClass * Get_Material(void) { WWASSERT(Material != NULL); Material->Add_Ref(); return Material; } + MaterialPassClass * Get_Material(void) { WWASSERT(Material != nullptr); Material->Add_Ref(); return Material; } /* ** Decal generation support. Call Set_Mesh_Transform for the mesh you want to add diff --git a/Core/Libraries/Source/WWVegas/WW3D2/distlod.cpp b/Core/Libraries/Source/WWVegas/WW3D2/distlod.cpp index d64078d3f8f..c09dc6958a6 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/distlod.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/distlod.cpp @@ -104,7 +104,7 @@ RenderObjClass * DistLODPrototypeClass::Create(void) // and destroy the DistLOD so that the models are "containerless". Also // invert the order of the models in the DistLOD char * name = nstrdup(dist->Get_Name()); - WWASSERT(name != NULL); + WWASSERT(name != nullptr); int count = dist->Get_Num_Sub_Objects(); RenderObjClass ** robj = W3DNEWARRAY RenderObjClass * [count]; @@ -112,7 +112,7 @@ RenderObjClass * DistLODPrototypeClass::Create(void) for (; iGet_Sub_Object(i); - WWASSERT(robj[count - 1 - i] != NULL); + WWASSERT(robj[count - 1 - i] != nullptr); } dist->Release_Ref(); @@ -135,16 +135,16 @@ PrototypeClass *DistLODLoaderClass::Load_W3D( ChunkLoadClass &cload ) { DistLODDefClass * pCDistLODClass = W3DNEW DistLODDefClass; - if (pCDistLODClass == NULL) + if (pCDistLODClass == nullptr) { - return NULL; + return nullptr; } if (pCDistLODClass->Load_W3D(cload) != WW3D_ERROR_OK) { // load failed, delete the model and return an error delete pCDistLODClass; - return NULL; + return nullptr; } else { @@ -169,9 +169,9 @@ PrototypeClass *DistLODLoaderClass::Load_W3D( ChunkLoadClass &cload ) * HISTORY: * *=============================================================================================*/ DistLODDefClass::DistLODDefClass(void) : - Name(NULL), + Name(nullptr), LodCount(0), - Lods(NULL) + Lods(nullptr) { } @@ -193,11 +193,11 @@ DistLODDefClass::DistLODDefClass(void) : * 7/15/98 GTH : Created. * *=============================================================================================*/ DistLODDefClass::DistLODDefClass(const char * name,int lodcount,DistLODNodeDefStruct * modeldefs) : - Name(NULL), + Name(nullptr), LodCount(0), - Lods(NULL) + Lods(nullptr) { - assert(name != NULL); + assert(name != nullptr); Name = nstrdup(name); LodCount = lodcount; @@ -243,14 +243,14 @@ DistLODDefClass::~DistLODDefClass(void) void DistLODDefClass::Free(void) { delete[] Name; - Name = NULL; + Name = nullptr; - if (Lods != NULL) { + if (Lods != nullptr) { for (int i=0; iCreate_Render_Obj(def.Lods[i].Name); - assert(Lods[i].Model != NULL); + assert(Lods[i].Model != nullptr); Lods[i].Model->Set_Container(this); // copy the distances @@ -429,7 +429,7 @@ DistLODClass::DistLODClass(const DistLODClass & that) : for (int i=0; iClone(); - assert(Lods[i].Model != NULL); + assert(Lods[i].Model != nullptr); Lods[i].Model->Set_Container(this); // copy the distances @@ -472,16 +472,16 @@ DistLODClass::~DistLODClass(void) *=============================================================================================*/ void DistLODClass::Free(void) { - if (Lods != NULL) { + if (Lods != nullptr) { for (int i=0; iSet_Container(NULL); + if (Lods[i].Model != nullptr) { + Lods[i].Model->Set_Container(nullptr); Lods[i].Model->Release_Ref(); - Lods[i].Model = NULL; + Lods[i].Model = nullptr; } } delete[] Lods; - Lods = NULL; + Lods = nullptr; } CurLod = 0; LodCount = 0; @@ -584,8 +584,8 @@ RenderObjClass * DistLODClass::Get_Sub_Object(int index) const assert(index >= 0); assert(index < LodCount); - if (Lods[index].Model == NULL) { - return NULL; + if (Lods[index].Model == nullptr) { + return nullptr; } else { Lods[index].Model->Add_Ref(); return Lods[index].Model; @@ -626,7 +626,7 @@ void DistLODClass::Set_Transform(const Matrix3D &m) { RenderObjClass::Set_Transform(m); for (int i=0; iSet_Transform(m); } } @@ -650,7 +650,7 @@ void DistLODClass::Set_Position(const Vector3 &v) { RenderObjClass::Set_Position(v); for (int i=0; iSet_Position(v); } } @@ -671,7 +671,7 @@ void DistLODClass::Set_Position(const Vector3 &v) void DistLODClass::Set_Animation( void ) { for (int i=0; iSet_Animation(); } } @@ -692,7 +692,7 @@ void DistLODClass::Set_Animation( void ) void DistLODClass::Set_Animation( HAnimClass * motion,float frame,int mode) { for (int i=0; iSet_Animation(motion,frame,mode); } } @@ -713,7 +713,7 @@ void DistLODClass::Set_Animation( HAnimClass * motion,float frame,int mode) void DistLODClass::Set_Animation( HAnimClass * motion0,float frame0,HAnimClass * motion1,float frame1,float percentage) { for (int i=0; iSet_Animation(motion0,frame0,motion1,frame1,percentage); } } @@ -734,7 +734,7 @@ void DistLODClass::Set_Animation( HAnimClass * motion0,float frame0,HAnimClass * void DistLODClass::Set_Animation( HAnimComboClass * anim_combo) { for (int i=0; iSet_Animation( anim_combo); } } @@ -866,7 +866,7 @@ const Matrix3D & DistLODClass::Get_Bone_Transform(int boneindex) void DistLODClass::Capture_Bone(int bindex) { for (int i=0; iCapture_Bone(bindex); } } @@ -887,7 +887,7 @@ void DistLODClass::Capture_Bone(int bindex) void DistLODClass::Release_Bone(int bindex) { for (int i=0; iRelease_Bone(bindex); } } @@ -927,7 +927,7 @@ bool DistLODClass::Is_Bone_Captured(int bindex) const void DistLODClass::Control_Bone(int bindex,const Matrix3D & tm,bool world_space_translation) { for (int i=0; iControl_Bone(bindex,tm,world_space_translation); } } @@ -1053,7 +1053,7 @@ void DistLODClass::Get_Snap_Point(int index,Vector3 * set) void DistLODClass::Scale(float scale) { for (int i=0; iScale(scale); } } @@ -1074,7 +1074,7 @@ void DistLODClass::Scale(float scale) void DistLODClass::Scale(float scalex, float scaley, float scalez) { for (int i=0; iScale(scalex,scaley,scalez); } } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/distlod.h b/Core/Libraries/Source/WWVegas/WW3D2/distlod.h index 01e39339b17..9cbcd6b3c72 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/distlod.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/distlod.h @@ -173,7 +173,7 @@ class DistLODLoaderClass : public PrototypeLoaderClass */ struct DistLODNodeDefStruct { - DistLODNodeDefStruct(void) : Name(NULL),ResDownDist(0.0f),ResUpDist(0.0f) {} + DistLODNodeDefStruct(void) : Name(nullptr),ResDownDist(0.0f),ResUpDist(0.0f) {} char * Name; float ResDownDist; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dx8texman.h b/Core/Libraries/Source/WWVegas/WW3D2/dx8texman.h index 378fdad9c2e..67d5077e1b2 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dx8texman.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/dx8texman.h @@ -69,7 +69,7 @@ class TextureTrackerClass : public MultiListObjectClass void Release() { - Texture->Set_D3D_Base_Texture(NULL); + Texture->Set_D3D_Base_Texture(nullptr); } TextureBaseClass* Get_Texture() const { return Texture; } @@ -101,7 +101,7 @@ class DX8TextureTrackerClass : public TextureTrackerClass virtual void Recreate() const { - WWASSERT(Texture->Peek_D3D_Base_Texture()==NULL); + WWASSERT(Texture->Peek_D3D_Base_Texture()==nullptr); Texture->Poke_Texture ( DX8Wrapper::_Create_DX8_Texture @@ -138,7 +138,7 @@ class DX8ZTextureTrackerClass : public TextureTrackerClass virtual void Recreate() const { - WWASSERT(Texture->Peek_D3D_Base_Texture()==NULL); + WWASSERT(Texture->Peek_D3D_Base_Texture()==nullptr); Texture->Poke_Texture ( DX8Wrapper::_Create_DX8_ZTexture diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp b/Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp index b8bfc7fb6b5..75f014f3f56 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp @@ -46,6 +46,9 @@ #else +#ifdef __MINGW32__ +#include "Utility/comsupp_compat.h" // MinGW COM support compatibility +#endif #include #include @@ -57,7 +60,7 @@ typedef _com_ptr_t<_com_IIID> I static IFEBrowserEngine2Ptr pBrowser = 0; -HWND DX8WebBrowser::hWnd = 0; +HWND DX8WebBrowser::hWnd = nullptr; bool DX8WebBrowser::Initialize( const char* badpageurl, const char* loadingpageurl, @@ -67,7 +70,7 @@ bool DX8WebBrowser::Initialize( const char* badpageurl, if(pBrowser == 0) { // Initialize COM - CoInitialize(0); + CoInitialize(nullptr); // Create an instance of the browser control HRESULT hr = pBrowser.CreateInstance(__uuidof(FEBrowserEngine2)); @@ -126,7 +129,7 @@ void DX8WebBrowser::Shutdown() // Release the smart pointer. pBrowser = 0; - hWnd = 0; + hWnd = nullptr; // Shut down COM CoUninitialize(); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp b/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp index 38d7c9a6787..a100660b8de 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.cpp @@ -53,8 +53,8 @@ DynamicMeshModel::DynamicMeshModel(unsigned int max_polys, unsigned int max_vert MeshGeometryClass(), DynamicMeshPNum(0), DynamicMeshVNum(0), - MatDesc(NULL), - MatInfo(NULL) + MatDesc(nullptr), + MatInfo(nullptr) { MatInfo = NEW_REF(MaterialInfoClass, ()); @@ -69,8 +69,8 @@ DynamicMeshModel::DynamicMeshModel(unsigned int max_polys, unsigned int max_vert MeshGeometryClass(), DynamicMeshPNum(0), DynamicMeshVNum(0), - MatDesc(NULL), - MatInfo(NULL) + MatDesc(nullptr), + MatInfo(nullptr) { MatInfo = mat_info; MatInfo->Add_Ref(); @@ -86,8 +86,8 @@ DynamicMeshModel::DynamicMeshModel(const DynamicMeshModel &src) : MeshGeometryClass(src), DynamicMeshPNum(src.DynamicMeshPNum), DynamicMeshVNum(src.DynamicMeshVNum), - MatDesc(NULL), - MatInfo(NULL) + MatDesc(nullptr), + MatInfo(nullptr) { // Copy the material info structure. MatInfo = NEW_REF(MaterialInfoClass, (*(src.MatInfo))); @@ -105,7 +105,7 @@ DynamicMeshModel::DynamicMeshModel(const DynamicMeshModel &src) : DynamicMeshModel::~DynamicMeshModel(void) { delete MatDesc; - MatDesc = NULL; + MatDesc = nullptr; REF_PTR_RELEASE(MatInfo); } @@ -274,28 +274,28 @@ void DynamicMeshModel::Render(RenderInfoClass & rinfo) bool material_changed = false; bool shader_changed = false; - TextureClass **texture_array0 = NULL; + TextureClass **texture_array0 = nullptr; TexBufferClass * tex_buf = MatDesc->Get_Texture_Array(pass, 0, false); if (tex_buf) { texture_array0 = tex_buf->Get_Array(); } else { - texture_array0 = NULL; + texture_array0 = nullptr; } - TextureClass **texture_array1 = NULL; + TextureClass **texture_array1 = nullptr; TexBufferClass * tex_buf1 = MatDesc->Get_Texture_Array(pass, 1, false); if (tex_buf1) { texture_array1 = tex_buf1->Get_Array(); } else { - texture_array1 = NULL; + texture_array1 = nullptr; } - VertexMaterialClass **material_array = NULL; + VertexMaterialClass **material_array = nullptr; MatBufferClass * mat_buf = MatDesc->Get_Material_Array(pass, false); if (mat_buf) { material_array = mat_buf->Get_Array(); } else { - material_array = NULL; + material_array = nullptr; } ShaderClass *shader_array = MatDesc->Get_Shader_Array(pass, false); @@ -518,7 +518,7 @@ bool DynamicMeshClass::End_Vertex() ** *******************************************************************/ DynamicMeshClass::DynamicMeshClass(int max_poly, int max_vert) : - Model(NULL), + Model(nullptr), PolyCount(0), VertCount(0), TriVertexCount(0), @@ -544,7 +544,7 @@ DynamicMeshClass::DynamicMeshClass(int max_poly, int max_vert) : } DynamicMeshClass::DynamicMeshClass(int max_poly, int max_vert, MaterialInfoClass *mat_info) : - Model(NULL), + Model(nullptr), PolyCount(0), VertCount(0), TriVertexCount(0), @@ -571,7 +571,7 @@ DynamicMeshClass::DynamicMeshClass(int max_poly, int max_vert, MaterialInfoClass DynamicMeshClass::DynamicMeshClass(const DynamicMeshClass & src) : RenderObjClass(src), - Model(NULL), + Model(nullptr), PolyCount(src.PolyCount), VertCount(src.VertCount), TriVertexCount(src.TriVertexCount), @@ -765,7 +765,7 @@ int DynamicMeshClass::Set_Texture(TextureClass *texture, bool dont_search, int p Model->Initialize_Texture_Array(pass, 0, tex); tex->Release_Ref(); - // flag that we need to write the per polygon material overide array + // flag that we need to write the per polygon material override array MultiTexture[pass] = true; } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.h b/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.h index 814c3aec385..5282531f922 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/dynamesh.h @@ -90,8 +90,8 @@ class DynamicMeshModel : public MeshGeometryClass int Get_Pass_Count(void) const { return MatDesc->Get_Pass_Count(); } // Create the array (if it doesn't exist), fill it with the supplied value. - void Initialize_Texture_Array(int pass, int stage, TextureClass *texture = NULL); - void Initialize_Material_Array(int pass, VertexMaterialClass *vmat = NULL); + void Initialize_Texture_Array(int pass, int stage, TextureClass *texture = nullptr); + void Initialize_Material_Array(int pass, VertexMaterialClass *vmat = nullptr); // Accessors to material info: MaterialInfoClass *Peek_Material_Info(void) { return MatInfo; } @@ -456,7 +456,7 @@ inline TriIndex * DynamicMeshModel::Get_Non_Const_Polygon_Array(void) inline void DynamicMeshClass::Get_Obj_Space_Bounding_Sphere(SphereClass & sphere) const { if (!Bounding_Volumes_Valid()) { - Model->Compute_Bounds(NULL); + Model->Compute_Bounds(nullptr); } Model->Get_Bounding_Sphere(&sphere); } @@ -464,7 +464,7 @@ inline void DynamicMeshClass::Get_Obj_Space_Bounding_Sphere(SphereClass & sphere inline void DynamicMeshClass::Get_Obj_Space_Bounding_Box(AABoxClass & box) const { if (!Bounding_Volumes_Valid()) { - Model->Compute_Bounds(NULL); + Model->Compute_Bounds(nullptr); } Model->Get_Bounding_Box(&box); } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/font3d.cpp b/Core/Libraries/Source/WWVegas/WW3D2/font3d.cpp index cc78b9ba331..10524e509e6 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/font3d.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/font3d.cpp @@ -57,7 +57,7 @@ static SurfaceClass *_surface; ***********************************************************************************************/ Font3DDataClass::Font3DDataClass( const char *filename ) { - Texture = NULL; + Texture = nullptr; Load_Font_Image( filename); Name = strdup( filename); Name = strupr( Name); @@ -72,7 +72,7 @@ Font3DDataClass::Font3DDataClass( const char *filename ) Font3DDataClass::~Font3DDataClass(void) { free(Name); - Name = NULL; + Name = nullptr; REF_PTR_RELEASE(Texture); } @@ -232,7 +232,7 @@ SurfaceClass *Font3DDataClass::Make_Proportional( SurfaceClass *surface ) // now shink the image given the minimum char sizes // surface = Minimize_Font_Image( surface ); Minimize_Font_Image( _surface ); - return NULL; + return nullptr; } /*********************************************************************************************** @@ -302,7 +302,7 @@ bool Font3DDataClass::Load_Font_Image( const char *filename ) // convert the just created mon-spaced font to proportional (optional) // surface = Make_Proportional( surface ); _surface = surface; - surface = NULL; + surface = nullptr; Minimize_Font_Image( _surface ); } else { @@ -328,7 +328,7 @@ bool Font3DDataClass::Load_Font_Image( const char *filename ) // convert the just created mon-spaced font to proportional (optional) _surface = surface; - surface = NULL; + surface = nullptr; Make_Proportional( _surface ); } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/font3d.h b/Core/Libraries/Source/WWVegas/WW3D2/font3d.h index cbaf28a386d..1863fdaa0f6 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/font3d.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/font3d.h @@ -53,7 +53,7 @@ class SurfaceClass; ** 16-bit Targa files, then converted to proportional fonts by ** finding the minimum bounding box for each chacter. The font ** texture is then minimized to a 256x256 or 128x128 texture -** material by re-stacking chars by thier minimum bounding box. +** material by re-stacking chars by their minimum bounding box. ** ** During use, this class is really no more than a data table accessor ** Only during creation is any real code run. diff --git a/Core/Libraries/Source/WWVegas/WW3D2/hanim.cpp b/Core/Libraries/Source/WWVegas/WW3D2/hanim.cpp index 479b6d764af..7e4f41e5981 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/hanim.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/hanim.cpp @@ -62,7 +62,7 @@ NamedPivotMapClass::~NamedPivotMapClass(void) NamedPivotMapClass::WeightInfoStruct & NamedPivotMapClass::WeightInfoStruct::operator = (WeightInfoStruct const &that) { delete [] Name; - assert(that.Name != NULL); + assert(that.Name != nullptr); Name = nstrdup(that.Name); Weight = that.Weight; return *this; @@ -75,7 +75,7 @@ void NamedPivotMapClass::Add(const char *Name, float Weight) info.Name = (char *) Name; info.Weight = Weight; WeightInfo.Add(info); - info.Name = 0; + info.Name = nullptr; } // configure the base pivot map using the specified tree @@ -109,7 +109,7 @@ void NamedPivotMapClass::Update_Pivot_Map(const HTreeClass *Tree) DEFINE_AUTO_POOL(HAnimComboDataClass,256); HAnimComboDataClass::HAnimComboDataClass(bool shared) -: Shared(shared), HAnim(0), PivotMap(0), Frame(0), PrevFrame(0), Weight(1) +: Shared(shared), HAnim(nullptr), PivotMap(nullptr), Frame(0), PrevFrame(0), Weight(1) {} @@ -132,8 +132,8 @@ void HAnimComboDataClass::Copy(const HAnimComboDataClass *src) PrevFrame = src->Get_Prev_Frame(); Weight = src->Get_Weight(); } else { - HAnim = 0; - PivotMap = 0; + HAnim = nullptr; + PivotMap = nullptr; Frame = 0; PrevFrame = 0; Weight = 1; @@ -150,30 +150,30 @@ HAnimComboDataClass::~HAnimComboDataClass(void) void HAnimComboDataClass::Clear(void) { - if ( HAnim != NULL ) { + if ( HAnim != nullptr ) { HAnim->Release_Ref(); - HAnim = NULL; + HAnim = nullptr; } // not sure if the pivot map should be deleted or just have everything set to one. // removing it effectively sets it to one, so that's what I'm doing for now. if(PivotMap) { PivotMap->Release_Ref(); - PivotMap = NULL; + PivotMap = nullptr; } Frame = 0.0f; PrevFrame = 0.0f; Weight = 1.0; - PivotMap = NULL; + PivotMap = nullptr; } void HAnimComboDataClass::Set_HAnim(HAnimClass *motion) { - if ( motion != NULL ) { + if ( motion != nullptr ) { motion->Add_Ref(); } - if ( HAnim != NULL ) { + if ( HAnim != nullptr ) { HAnim->Release_Ref(); } HAnim = motion; @@ -182,10 +182,10 @@ void HAnimComboDataClass::Set_HAnim(HAnimClass *motion) void HAnimComboDataClass::Set_Pivot_Map(PivotMapClass *map) { - if ( map != NULL ) { + if ( map != nullptr ) { map->Add_Ref(); } - if ( PivotMap != NULL ) { + if ( PivotMap != nullptr ) { PivotMap->Release_Ref(); } PivotMap = map; @@ -197,11 +197,11 @@ void HAnimComboDataClass::Set_Pivot_Map(PivotMapClass *map) */ void HAnimComboDataClass::Build_Active_Pivot_Map(void) { - if ( PivotMap != NULL ) { + if ( PivotMap != nullptr ) { PivotMap->Release_Ref(); } - if(HAnim == NULL) { - PivotMap = 0; + if(HAnim == nullptr) { + PivotMap = nullptr; return; } @@ -284,7 +284,7 @@ bool HAnimComboClass::Normalize_Weights(void) int num_anim_pivots = 100000; for (anim_idx = 0; anim_idx < anim_count; anim_idx++ ) { num_anim_pivots = MIN(num_anim_pivots, Peek_Motion(anim_idx)->Get_Num_Pivots()); - bool has_pivot_map = Peek_Pivot_Weight_Map(anim_idx) != NULL; + bool has_pivot_map = Peek_Pivot_Weight_Map(anim_idx) != nullptr; all_pivot_maps &= has_pivot_map; none_pivot_maps &= !has_pivot_map; } @@ -297,7 +297,7 @@ bool HAnimComboClass::Normalize_Weights(void) // Calculate total weight of all active anims, ensure it is very close to 1. float weight_total = 0.0f; for (anim_idx = 0; anim_idx < anim_count; anim_idx++ ) { - if (Peek_Motion(anim_idx) != NULL ) { + if (Peek_Motion(anim_idx) != nullptr ) { float weight = Get_Weight(anim_idx); weight_total += weight; } @@ -307,7 +307,7 @@ bool HAnimComboClass::Normalize_Weights(void) if (weight_total != 0.0 && WWMath::Fabs( weight_total - 1.0 ) > WWMATH_EPSILON) { float oo_total = 1.0f / weight_total; for (anim_idx = 0; anim_idx < anim_count; anim_idx++ ) { - if (Peek_Motion(anim_idx) != NULL ) { + if (Peek_Motion(anim_idx) != nullptr ) { Set_Weight(anim_idx, Get_Weight(anim_idx) * oo_total); } } @@ -322,7 +322,7 @@ bool HAnimComboClass::Normalize_Weights(void) float weight_total = 0.0f; for (anim_idx = 0; anim_idx < anim_count; anim_idx++ ) { - if (Peek_Motion(anim_idx) != NULL ) { + if (Peek_Motion(anim_idx) != nullptr ) { float weight = Get_Weight(anim_idx) * (*Peek_Pivot_Weight_Map(anim_idx))[piv_idx]; weight_total += weight; } @@ -332,7 +332,7 @@ bool HAnimComboClass::Normalize_Weights(void) if (weight_total != 0.0 && WWMath::Fabs( weight_total - 1.0 ) > WWMATH_EPSILON) { float oo_total = 1.0f / weight_total; for (anim_idx = 0; anim_idx < anim_count; anim_idx++ ) { - if (Peek_Motion(anim_idx) != NULL ) { + if (Peek_Motion(anim_idx) != nullptr ) { PivotMapClass *pivot_map = Get_Pivot_Weight_Map(anim_idx); float new_weight = (*pivot_map)[piv_idx] * oo_total; (*pivot_map)[piv_idx] = new_weight; @@ -367,7 +367,7 @@ HAnimClass *HAnimComboClass::Get_Motion( int index ) HAnimClass *anim = data->Peek_HAnim(); - if ( anim != NULL ) { + if ( anim != nullptr ) { anim->Add_Ref(); } return anim; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/hanim.h b/Core/Libraries/Source/WWVegas/WW3D2/hanim.h index a01069917cc..ddb1a69bc33 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/hanim.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/hanim.h @@ -149,7 +149,7 @@ class NamedPivotMapClass : public PivotMapClass // This info is packaged into a struct to minimize DynamicVectorClass overhead struct WeightInfoStruct { - WeightInfoStruct() : Name(NULL) {} + WeightInfoStruct() : Name(nullptr) {} ~WeightInfoStruct() { delete [] Name; } char *Name; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp b/Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp index 6813ca07851..e6303a8fb42 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/hcanim.cpp @@ -108,12 +108,12 @@ struct NodeCompressedMotionStruct * HISTORY: * *=============================================================================================*/ NodeCompressedMotionStruct::NodeCompressedMotionStruct() : - Vis(NULL) + Vis(nullptr) { - vd.X = NULL; - vd.Y = NULL; - vd.Z = NULL; - vd.Q = NULL; + vd.X = nullptr; + vd.Y = nullptr; + vd.Z = nullptr; + vd.Q = nullptr; } @@ -174,7 +174,7 @@ HCompressedAnimClass::HCompressedAnimClass(void) : NumNodes(0), Flavor(0), FrameRate(0), - NodeMotion(NULL) + NodeMotion(nullptr) { memset(Name,0,W3D_NAME_LEN); memset(HierarchyName,0,W3D_NAME_LEN); @@ -214,7 +214,7 @@ HCompressedAnimClass::~HCompressedAnimClass(void) void HCompressedAnimClass::Free(void) { delete[] NodeMotion; - NodeMotion = NULL; + NodeMotion = nullptr; } @@ -261,14 +261,14 @@ int HCompressedAnimClass::Load_W3D(ChunkLoadClass & cload) strlcat(Name, aheader.Name, ARRAY_SIZE(Name)); // TSS chasing crash bug 05/26/99 - WWASSERT(HierarchyName != NULL); - WWASSERT(aheader.HierarchyName != NULL); + WWASSERT(HierarchyName != nullptr); + WWASSERT(aheader.HierarchyName != nullptr); WWASSERT(sizeof(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) { + if (base_pose == nullptr) { goto Error; } NumNodes = base_pose->Num_Pivots(); @@ -281,7 +281,7 @@ int HCompressedAnimClass::Load_W3D(ChunkLoadClass & cload) WWASSERT((Flavor == ANIM_FLAVOR_TIMECODED)||(Flavor == ANIM_FLAVOR_ADAPTIVE_DELTA)); NodeMotion = W3DNEWARRAY NodeCompressedMotionStruct[ NumNodes ]; - if (NodeMotion == NULL) { + if (NodeMotion == nullptr) { goto Error; } @@ -314,7 +314,7 @@ int HCompressedAnimClass::Load_W3D(ChunkLoadClass & cload) add_channel(tc_chan); } else { // PWG 12-14-98: we have only allocated space for NumNode pivots. - // If we have an index thats equal or higher than NumNode we are + // If we have an index that's equal or higher than NumNode we are // gonna trash memory. Boy will we trash memory. // GTH 09-25-2000: print a warning and survive this error delete tc_chan; @@ -331,7 +331,7 @@ int HCompressedAnimClass::Load_W3D(ChunkLoadClass & cload) add_channel(ad_chan); } else { // PWG 12-14-98: we have only allocated space for NumNode pivots. - // If we have an index thats equal or higher than NumNode we are + // If we have an index that's equal or higher than NumNode we are // gonna trash memory. Boy will we trash memory. // GTH 09-25-2000: print a warning and survive this error delete ad_chan; @@ -349,7 +349,7 @@ int HCompressedAnimClass::Load_W3D(ChunkLoadClass & cload) add_bit_channel(newbitchan); } else { // PWG 12-14-98: we have only allocated space for NumNode pivots. - // If we have an index thats equal or higher than NumNode we are + // If we have an index that's equal or higher than NumNode we are // gonna trash memory. Boy will we trash memory. // GTH 09-25-2000: print a warning and survive this error delete newbitchan; @@ -640,7 +640,7 @@ void HCompressedAnimClass::Get_Transform( Matrix3D& mtx, int pividx, float frame bool HCompressedAnimClass::Get_Visibility(int pividx,float frame) { - if (NodeMotion[pividx].Vis != NULL) { + if (NodeMotion[pividx].Vis != nullptr) { return (NodeMotion[pividx].Vis->Get_Bit((int)frame) == 1); } @@ -667,11 +667,11 @@ bool HCompressedAnimClass::Is_Node_Motion_Present(int pividx) { WWASSERT((pividx >= 0) && (pividx < NumNodes)); - if (NodeMotion[pividx].vd.X != NULL) return true; - if (NodeMotion[pividx].vd.Y != NULL) return true; - if (NodeMotion[pividx].vd.Z != NULL) return true; - if (NodeMotion[pividx].vd.Q != NULL) return true; - if (NodeMotion[pividx].Vis != NULL) return true; + if (NodeMotion[pividx].vd.X != nullptr) return true; + if (NodeMotion[pividx].vd.Y != nullptr) return true; + if (NodeMotion[pividx].vd.Z != nullptr) return true; + if (NodeMotion[pividx].vd.Q != nullptr) return true; + if (NodeMotion[pividx].Vis != nullptr) return true; return false; } @@ -679,31 +679,31 @@ bool HCompressedAnimClass::Is_Node_Motion_Present(int pividx) bool HCompressedAnimClass::Has_X_Translation (int pividx) { WWASSERT((pividx >= 0) && (pividx < NumNodes)); - return NodeMotion[pividx].vd.X != NULL; + return NodeMotion[pividx].vd.X != nullptr; } bool HCompressedAnimClass::Has_Y_Translation (int pividx) { WWASSERT((pividx >= 0) && (pividx < NumNodes)); - return NodeMotion[pividx].vd.Y != NULL; + return NodeMotion[pividx].vd.Y != nullptr; } bool HCompressedAnimClass::Has_Z_Translation (int pividx) { WWASSERT((pividx >= 0) && (pividx < NumNodes)); - return NodeMotion[pividx].vd.Z != NULL; + return NodeMotion[pividx].vd.Z != nullptr; } bool HCompressedAnimClass::Has_Rotation (int pividx) { WWASSERT((pividx >= 0) && (pividx < NumNodes)); - return NodeMotion[pividx].vd.Q != NULL; + return NodeMotion[pividx].vd.Q != nullptr; } bool HCompressedAnimClass::Has_Visibility (int pividx) { WWASSERT((pividx >= 0) && (pividx < NumNodes)); - return NodeMotion[pividx].Vis != NULL; + return NodeMotion[pividx].Vis != nullptr; } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp b/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp index 0a344c8e123..3d437456e19 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/hmdldef.cpp @@ -57,8 +57,8 @@ *=============================================================================================*/ HModelDefClass::HModelDefClass(void) : SubObjectCount(0), - SubObjects(NULL), - SnapPoints(NULL) + SubObjects(nullptr), + SnapPoints(nullptr) { } @@ -95,12 +95,12 @@ HModelDefClass::~HModelDefClass(void) void HModelDefClass::Free(void) { delete[] SubObjects; - SubObjects = NULL; + SubObjects = nullptr; SubObjectCount = 0; - if (SnapPoints != NULL) { + if (SnapPoints != nullptr) { SnapPoints->Release_Ref(); - SnapPoints = NULL; + SnapPoints = nullptr; } } @@ -160,7 +160,7 @@ int HModelDefClass::Load_W3D(ChunkLoadClass & cload) */ SubObjectCount = header.NumConnections; SubObjects = W3DNEWARRAY HmdlNodeDefStruct[SubObjectCount]; - if (SubObjects == NULL) { + if (SubObjects == nullptr) { goto Error; } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/htree.cpp b/Core/Libraries/Source/WWVegas/WW3D2/htree.cpp index 63bc8f9acd3..231d50ea97a 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/htree.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/htree.cpp @@ -77,7 +77,7 @@ *=============================================================================================*/ HTreeClass::HTreeClass(void) : NumPivots(0), - Pivot(NULL), + Pivot(nullptr), ScaleFactor(1.0f) { } @@ -90,7 +90,7 @@ void HTreeClass::Init_Default(void) Pivot = MSGW3DNEWARRAY("HTreeClass::Pivot") PivotClass[NumPivots]; Pivot[0].Index = 0; - Pivot[0].Parent = NULL; + Pivot[0].Parent = nullptr; Pivot[0].BaseTransform.Make_Identity(); Pivot[0].Transform.Make_Identity(); Pivot[0].IsVisible = true; @@ -138,7 +138,7 @@ HTreeClass::~HTreeClass(void) *=============================================================================================*/ HTreeClass::HTreeClass(const HTreeClass & src) : NumPivots(0), - Pivot(NULL), + Pivot(nullptr), ScaleFactor(1.0f) { memcpy(&Name,&src.Name,sizeof(Name)); @@ -151,10 +151,10 @@ HTreeClass::HTreeClass(const HTreeClass & src) : for (int pi = 0; pi < NumPivots; pi++) { Pivot[pi] = src.Pivot[pi]; - if (src.Pivot[pi].Parent != NULL) { + if (src.Pivot[pi].Parent != nullptr) { Pivot[pi].Parent = &(Pivot[src.Pivot[pi].Parent->Index]); } else { - Pivot[pi].Parent = NULL; + Pivot[pi].Parent = nullptr; } } @@ -269,7 +269,7 @@ bool HTreeClass::read_pivots(ChunkLoadClass & cload,bool pre30) */ if (pre30) { Pivot[0].Index = 0; - Pivot[0].Parent = NULL; + Pivot[0].Parent = nullptr; Pivot[0].BaseTransform.Make_Identity(); Pivot[0].Transform.Make_Identity(); Pivot[0].IsVisible = true; @@ -325,10 +325,10 @@ bool HTreeClass::read_pivots(ChunkLoadClass & cload,bool pre30) /* ** Set the parent pointer. The first pivot will have a parent index - ** of -1 (in post-3.0 files) so set its parent to NULL. + ** of -1 (in post-3.0 files) so set its parent to nullptr. */ if (piv.ParentIdx == -1) { - Pivot[pidx].Parent = NULL; + Pivot[pidx].Parent = nullptr; assert(pidx == 0); } else { Pivot[pidx].Parent = &(Pivot[piv.ParentIdx]); @@ -358,7 +358,7 @@ bool HTreeClass::read_pivots(ChunkLoadClass & cload,bool pre30) void HTreeClass::Free(void) { delete[] Pivot; - Pivot = NULL; + Pivot = nullptr; NumPivots = 0; // Also clean up other members: @@ -390,8 +390,8 @@ bool HTreeClass::Simple_Evaluate_Pivot bool retval = false; end_tm->Make_Identity (); - if ( motion != NULL && - end_tm != NULL && + if ( motion != nullptr && + end_tm != nullptr && pivot_index >= 0 && pivot_index < NumPivots) { @@ -400,7 +400,7 @@ bool HTreeClass::Simple_Evaluate_Pivot // attached to and transform each. // for ( PivotClass *pivot = &Pivot[pivot_index]; - pivot != NULL && pivot->Parent != NULL; + pivot != nullptr && pivot->Parent != nullptr; pivot = pivot->Parent) { // @@ -474,7 +474,7 @@ bool HTreeClass::Simple_Evaluate_Pivot bool retval = false; end_tm->Make_Identity (); - if ( end_tm != NULL && + if ( end_tm != nullptr && pivot_index >= 0 && pivot_index < NumPivots) { @@ -483,7 +483,7 @@ bool HTreeClass::Simple_Evaluate_Pivot // attached to and transform each. // for ( PivotClass *pivot = &Pivot[pivot_index]; - pivot != NULL && pivot->Parent != NULL; + pivot != nullptr && pivot->Parent != nullptr; pivot = pivot->Parent) { // @@ -537,7 +537,7 @@ void HTreeClass::Base_Update(const Matrix3D & root) pivot = &Pivot[piv_idx]; - assert(pivot->Parent != NULL); + assert(pivot->Parent != nullptr); Matrix3D::Multiply(pivot->Parent->Transform, pivot->BaseTransform, &(pivot->Transform)); pivot->IsVisible = 1; @@ -571,7 +571,7 @@ void HTreeClass::Anim_Update(const Matrix3D & root,HAnimClass * motion,float fra pivot = &Pivot[piv_idx]; // base pose - assert(pivot->Parent != NULL); + assert(pivot->Parent != nullptr); Matrix3D::Multiply(pivot->Parent->Transform, pivot->BaseTransform, &(pivot->Transform)); // Don't update this pivot if the HTree doesn't have animation data for it... @@ -642,7 +642,7 @@ void HTreeClass::Anim_Update_Without_Interpolation(const Matrix3D & root,HRawAni for (int piv_idx=1; pivot < endpivot; pivot++,nodeMotion++) { // base pose - assert(pivot->Parent != NULL); + assert(pivot->Parent != nullptr); Matrix3D::Multiply(pivot->Parent->Transform, pivot->BaseTransform, &(pivot->Transform)); // Don't update this pivot if the HTree doesn't have animation data for it... @@ -653,11 +653,11 @@ void HTreeClass::Anim_Update_Without_Interpolation(const Matrix3D & root,HRawAni trans.Set(0.0f,0.0f,0.0f); Matrix3D *xform=&pivot->Transform; - if (nodeMotion->X != NULL) + if (nodeMotion->X != nullptr) nodeMotion->X->Get_Vector(iframe,&(trans[0])); - if (nodeMotion->Y != NULL) + if (nodeMotion->Y != nullptr) nodeMotion->Y->Get_Vector(iframe,&(trans[1])); - if (nodeMotion->Z != NULL) + if (nodeMotion->Z != nullptr) nodeMotion->Z->Get_Vector(iframe,&(trans[2])); if (ScaleFactor == 1.0f) @@ -665,7 +665,7 @@ void HTreeClass::Anim_Update_Without_Interpolation(const Matrix3D & root,HRawAni else xform->Translate(trans*ScaleFactor); - if (nodeMotion->Q != NULL) + if (nodeMotion->Q != nullptr) { nodeMotion->Q->Get_Vector_As_Quat(iframe, q); #ifdef ALLOW_TEMPORARIES *xform = *xform * ::Build_Matrix3D(q,mtx); @@ -675,7 +675,7 @@ void HTreeClass::Anim_Update_Without_Interpolation(const Matrix3D & root,HRawAni } // visibility - if (nodeMotion->Vis != NULL) + if (nodeMotion->Vis != nullptr) pivot->IsVisible=(nodeMotion->Vis->Get_Bit(iframe) == 1); else pivot->IsVisible=1; @@ -724,7 +724,7 @@ void HTreeClass::Blend_Update pivot = &Pivot[piv_idx]; - assert(pivot->Parent != NULL); + assert(pivot->Parent != nullptr); Matrix3D::Multiply(pivot->Parent->Transform,pivot->BaseTransform,&(pivot->Transform)); if (piv_idx < num_anim_pivots) { @@ -797,7 +797,7 @@ void HTreeClass::Combo_Update for (int piv_idx=1; piv_idx < NumPivots; piv_idx++) { pivot = &Pivot[piv_idx]; - assert(pivot->Parent != NULL); + assert(pivot->Parent != nullptr); Matrix3D::Multiply(pivot->Parent->Transform,pivot->BaseTransform,&(pivot->Transform)); if (piv_idx < num_anim_pivots) { @@ -818,7 +818,7 @@ void HTreeClass::Combo_Update HAnimClass *motion = anim->Get_Motion( anim_num ); - if ( motion != NULL ) { + if ( motion != nullptr ) { float frame_num = anim->Get_Frame( anim_num ); @@ -828,7 +828,7 @@ void HTreeClass::Combo_Update float weight = anim->Get_Weight( anim_num ); - if ( pivot_map != NULL ) { + if ( pivot_map != nullptr ) { weight *= (*pivot_map)[piv_idx]; // GREG - Pivot maps are ref counted so shouldn't we // release the rivot map here? @@ -894,7 +894,7 @@ void HTreeClass::Combo_Update for ( anim_num = 0; (anim_num < anim->Get_Num_Anims()) && (!pivot->IsVisible); anim_num++ ) { HAnimClass *motion = anim->Get_Motion( anim_num ); - if ( motion != NULL ) { + if ( motion != nullptr ) { float frame_num = anim->Get_Frame( anim_num ); pivot->IsVisible |= motion->Get_Visibility(piv_idx,frame_num); @@ -976,7 +976,7 @@ int HTreeClass::Get_Parent_Index(int boneidx) const assert(boneidx >= 0); assert(boneidx < NumPivots); - if (Pivot[boneidx].Parent != NULL) { + if (Pivot[boneidx].Parent != nullptr) { return Pivot[boneidx].Parent->Index; } else { return 0; @@ -1009,7 +1009,7 @@ void HTreeClass::Capture_Bone(int boneindex) assert(boneindex >= 0); assert(boneindex < NumPivots); #ifdef LAZY_CAP_MTX_ALLOC - if (Pivot[boneindex].CapTransformPtr == NULL) + if (Pivot[boneindex].CapTransformPtr == nullptr) { Pivot[boneindex].CapTransformPtr = MSGW3DNEW("PivotClassCaptureBoneMtx") DynamicMatrix3D; Pivot[boneindex].CapTransformPtr->Mat.Make_Identity(); @@ -1025,7 +1025,7 @@ void HTreeClass::Release_Bone(int boneindex) assert(boneindex < NumPivots); #ifdef LAZY_CAP_MTX_ALLOC delete Pivot[boneindex].CapTransformPtr; - Pivot[boneindex].CapTransformPtr = NULL; + Pivot[boneindex].CapTransformPtr = nullptr; #else Pivot[boneindex].IsCaptured = false; #endif @@ -1045,7 +1045,7 @@ void HTreeClass::Control_Bone(int boneindex,const Matrix3D & relative_tm,bool wo assert(Pivot[boneindex].Is_Captured()); #ifdef LAZY_CAP_MTX_ALLOC - if (Pivot[boneindex].CapTransformPtr == NULL) + if (Pivot[boneindex].CapTransformPtr == nullptr) return; Pivot[boneindex].WorldSpaceTranslation = world_space_translation; Pivot[boneindex].CapTransformPtr->Mat = relative_tm; @@ -1080,7 +1080,7 @@ HTreeClass * HTreeClass::Alter_Avatar_HTree( const HTreeClass *tree, Vector3 &sc // being stretched out on the Y-axis instead of the Z-axis like the rest of the bodies. Hence, the list of pivots // below are ones that I will special case and scale them based on the Z-axis scaling factor instead of the Y-axis // scaling factor. - const char * flip_list[] = { " RIGHTFOREARM", " RIGHTHAND", " LEFTFOREARM", " LEFTHAND", "RIGHTINDEX", "RIGHTFINGERS", "RIGHTTHUMB", "LEFTINDEX", "LEFTFINGERS", "LEFTTHUMB", 0 }; + const char * flip_list[] = { " RIGHTFOREARM", " RIGHTHAND", " LEFTFOREARM", " LEFTHAND", "RIGHTINDEX", "RIGHTFINGERS", "RIGHTTHUMB", "LEFTINDEX", "LEFTFINGERS", "LEFTTHUMB", nullptr }; // Clone the new tree with the tree that is passed in HTreeClass * new_tree = new HTreeClass( *tree ); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/intersec.cpp b/Core/Libraries/Source/WWVegas/WW3D2/intersec.cpp index 38fe2c904de..1709f956bb0 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/intersec.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/intersec.cpp @@ -60,7 +60,7 @@ bool IntersectionClass::Intersect_Screen_Point_RenderObject(float screen_x, floa bool IntersectionClass::Intersect_RenderObject(RenderObjClass *RObj, IntersectionResultClass *FinalResult) { - if(FinalResult == 0) + if(FinalResult == nullptr) FinalResult = &Result; return RObj->Intersect(this, FinalResult); @@ -347,7 +347,7 @@ RenderObjClass *IntersectionClass::Intersect_Sub_Object(float screenx, float scr if (Intersect_Screen_Point_RenderObject(screenx, screeny, layer, robj, result)) { return robj; } - return NULL; + return nullptr; } // finds the intersection of the nearest object in the array. diff --git a/Core/Libraries/Source/WWVegas/WW3D2/intersec.inl b/Core/Libraries/Source/WWVegas/WW3D2/intersec.inl index db4027ba455..3fc05e586fb 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/intersec.inl +++ b/Core/Libraries/Source/WWVegas/WW3D2/intersec.inl @@ -150,7 +150,7 @@ inline bool IntersectionClass::_Point_In_Polygon_Z( Vector3 &Corner3 ) { -// these defines could be variables if support for other axis were neccessary +// these defines could be variables if support for other axis were necessary #define AXIS_1 0 #define AXIS_2 1 #define AXIS_3 2 diff --git a/Core/Libraries/Source/WWVegas/WW3D2/layer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/layer.cpp index 327075303c0..2f4c3e74cf5 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/layer.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/layer.cpp @@ -63,8 +63,8 @@ * 3/27/98 GTH : Created. * *=============================================================================================*/ LayerClass::LayerClass(void) : - Scene(NULL), - Camera(NULL), + Scene(nullptr), + Camera(nullptr), Clear(false), ClearZ(true), ClearColor(0,0,0) @@ -132,11 +132,11 @@ LayerClass::~LayerClass(void) { if (Scene) { Scene->Release_Ref(); - Scene=0; + Scene=nullptr; } if (Camera) { Camera->Release_Ref(); - Camera=0; + Camera=nullptr; } } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/line3d.cpp b/Core/Libraries/Source/WWVegas/WW3D2/line3d.cpp index d2ba6b4a041..e6ca062703b 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/line3d.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/line3d.cpp @@ -268,7 +268,7 @@ void Line3DClass::Render(RenderInfoClass & rinfo) } DX8Wrapper::Set_Shader(Shader); - DX8Wrapper::Set_Texture(0,NULL); + DX8Wrapper::Set_Texture(0,nullptr); VertexMaterialClass *vm=VertexMaterialClass::Get_Preset(VertexMaterialClass::PRELIT_DIFFUSE); DX8Wrapper::Set_Material(vm); REF_PTR_RELEASE(vm); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/matinfo.cpp b/Core/Libraries/Source/WWVegas/WW3D2/matinfo.cpp index 7a413efd890..d2fec946b20 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/matinfo.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/matinfo.cpp @@ -73,7 +73,7 @@ MaterialInfoClass * MaterialInfoClass::Clone(void) const int MaterialInfoClass::Add_Texture(TextureClass * tex) { - WWASSERT(tex != NULL); + WWASSERT(tex != nullptr); tex->Add_Ref(); int index = Textures.Count(); Textures.Add(tex); @@ -133,13 +133,13 @@ void MaterialInfoClass::Free(void) MaterialRemapperClass::MaterialRemapperClass(MaterialInfoClass * src,MaterialInfoClass * dest) : TextureCount(0), - TextureRemaps(NULL), + TextureRemaps(nullptr), VertexMaterialCount(0), - VertexMaterialRemaps(NULL), - LastSrcVmat(NULL), - LastDestVmat(NULL), - LastSrcTex(NULL), - LastDestTex(NULL) + VertexMaterialRemaps(nullptr), + LastSrcVmat(nullptr), + LastDestVmat(nullptr), + LastSrcTex(nullptr), + LastDestTex(nullptr) { WWASSERT(src); WWASSERT(dest); @@ -181,7 +181,7 @@ MaterialRemapperClass::~MaterialRemapperClass(void) TextureClass * MaterialRemapperClass::Remap_Texture(TextureClass * src) { - if (src == NULL) return src; + if (src == nullptr) return src; if (src == LastSrcTex) return LastDestTex; for (int i=0; iAdd_Ref(); } int index = VertexMaterials.Count(); @@ -251,7 +251,7 @@ inline VertexMaterialClass * MaterialInfoClass::Get_Vertex_Material(const char * { int index = Get_Vertex_Material_Index(name); if (index == -1) { - return NULL; + return nullptr; } else { return Get_Vertex_Material(index); } @@ -268,7 +268,7 @@ inline VertexMaterialClass * MaterialInfoClass::Peek_Vertex_Material(const char { int index = Get_Vertex_Material_Index(name); if (index == -1) { - return NULL; + return nullptr; } else { return Peek_Vertex_Material(index); } @@ -308,7 +308,7 @@ inline TextureClass * MaterialInfoClass::Get_Texture(const char * name) { int index = Get_Texture_Index(name); if (index == -1) { - return NULL; + return nullptr; } else { return Get_Texture(index); } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/matpass.cpp b/Core/Libraries/Source/WWVegas/WW3D2/matpass.cpp index f8cc3e348f4..3146a4152b2 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/matpass.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/matpass.cpp @@ -71,12 +71,12 @@ bool MaterialPassClass::EnablePerPolygonCulling = true; *=============================================================================================*/ MaterialPassClass::MaterialPassClass(void) : Shader(0), - Material(NULL), - CullVolume(NULL), + Material(nullptr), + CullVolume(nullptr), EnableOnTranslucentMeshes(true) { for (int i=0; i= MapCount) return 0; + if (id < 0 || id >= MapCount) return nullptr; Textures[id]->Add_Ref(); return Textures[id]; } @@ -284,7 +284,7 @@ void MetalMapManagerClass::Update_Textures(void) MetalParams &cur_params = MetalParameters[i]; // If shinyness > 1, apply it to specular value array - float *specular = 0; + float *specular = nullptr; float temp_specular[METALMAP_SIZE_2]; float shinyness = cur_params.Shininess; if (shinyness > 1.0f) { diff --git a/Core/Libraries/Source/WWVegas/WW3D2/missingtexture.cpp b/Core/Libraries/Source/WWVegas/WW3D2/missingtexture.cpp index d2bfe954fa4..0a2867b12b7 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/missingtexture.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/missingtexture.cpp @@ -29,7 +29,7 @@ static unsigned missing_image_depth=24; extern unsigned int missing_image_palette[]; extern unsigned int missing_image_pixels[]; -static IDirect3DTexture8 * _MissingTexture = NULL; +static IDirect3DTexture8 * _MissingTexture = nullptr; IDirect3DTexture8* MissingTexture::_Get_Missing_Texture() { @@ -40,19 +40,19 @@ IDirect3DTexture8* MissingTexture::_Get_Missing_Texture() IDirect3DSurface8* MissingTexture::_Create_Missing_Surface() { - IDirect3DSurface8 *texture_surface = NULL; + IDirect3DSurface8 *texture_surface = nullptr; DX8_ErrorCode(_MissingTexture->GetSurfaceLevel(0, &texture_surface)); D3DSURFACE_DESC texture_surface_desc; ::ZeroMemory(&texture_surface_desc, sizeof(D3DSURFACE_DESC)); DX8_ErrorCode(texture_surface->GetDesc(&texture_surface_desc)); - IDirect3DSurface8 *surface = NULL; + IDirect3DSurface8 *surface = nullptr; DX8CALL(CreateImageSurface( texture_surface_desc.Width, texture_surface_desc.Height, texture_surface_desc.Format, &surface)); - DX8CALL(CopyRects(texture_surface, NULL, 0, surface, NULL)); + DX8CALL(CopyRects(texture_surface, nullptr, 0, surface, nullptr)); texture_surface->Release(); return surface; } @@ -104,11 +104,11 @@ void MissingTexture::_Init() DX8_ErrorCode(D3DXLoadSurfaceFromSurface( dst, - NULL, // palette - NULL, // rect + nullptr, // palette + nullptr, // rect src, - NULL, // palette - NULL, // rect + nullptr, // palette + nullptr, // rect D3DX_FILTER_BOX, // box is good for 2:1 filtering 0)); @@ -159,10 +159,10 @@ void MissingTexture::_Init() void MissingTexture::_Deinit() { _MissingTexture->Release(); - _MissingTexture=0; + _MissingTexture=nullptr; } -static unsigned int missing_image_palette[]={ +unsigned int missing_image_palette[]={ 0x7F040204,0x7F048AC4,0x7F84829C,0x7FFC0204,0x7F0442AB,0x7FFCFE04,0x7F444244,0x7F0462FC, 0x7F84CEE4,0x7FC4C6CF,0x7F9CA6B2,0x7FC4E6F4,0x7F04FE04,0x7F4C82D4,0x7F2452A1,0x7F0442D4, 0x7F446AB0,0x7FA4A6B6,0x7F2C62C2,0x7FE4E6E9,0x7F646264,0x7F0402FC,0x7FC4D6E1,0x7F44B6DC, @@ -196,7 +196,7 @@ static unsigned int missing_image_palette[]={ 0x7FACDEEC,0x7F2CA6D4,0x7F0452E4,0x7FD4D6E4,0x7F849ED4,0x7FB4B6CC,0x7F4C7ACC,0x7FACC6FC, 0x7F9496B4,0x7F042AA4,0x7F1C62E4,0x7F74A6EC,0x7FE4EEFC,0x7F1C72FC,0x7FD4DEEC,0x7F2C5ABC}; -static unsigned int missing_image_pixels[]={ +unsigned int missing_image_pixels[]={ 0x03030303,0x03030303,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, 0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, 0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7,0xA7A7A7A7, diff --git a/Core/Libraries/Source/WWVegas/WW3D2/pivot.cpp b/Core/Libraries/Source/WWVegas/WW3D2/pivot.cpp index b7f1c700e66..11f53f27c9f 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/pivot.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/pivot.cpp @@ -55,11 +55,11 @@ * 07/24/1997 GH : Created. * *=============================================================================================*/ PivotClass::PivotClass(void) : - Parent(NULL), + Parent(nullptr), BaseTransform(1), Transform(1), #ifdef LAZY_CAP_MTX_ALLOC - CapTransformPtr(NULL), + CapTransformPtr(nullptr), Index(0), IsVisible(true), WorldSpaceTranslation(false) @@ -80,7 +80,7 @@ PivotClass::PivotClass(const PivotClass& that) : BaseTransform(that.BaseTransform), Transform(that.Transform), #ifdef LAZY_CAP_MTX_ALLOC - CapTransformPtr(NULL), + CapTransformPtr(nullptr), Index(that.Index), IsVisible(that.IsVisible), WorldSpaceTranslation(that.WorldSpaceTranslation) @@ -95,7 +95,7 @@ PivotClass::PivotClass(const PivotClass& that) : { memcpy(Name, that.Name, sizeof(Name)); #ifdef LAZY_CAP_MTX_ALLOC - if (that.CapTransformPtr != NULL) + if (that.CapTransformPtr != nullptr) { CapTransformPtr = MSGW3DNEW("PivotClassCaptureBoneMtx") DynamicMatrix3D; CapTransformPtr->Mat = that.CapTransformPtr->Mat; @@ -112,11 +112,11 @@ PivotClass& PivotClass::operator=(const PivotClass& that) BaseTransform = that.BaseTransform; Transform = that.Transform; #ifdef LAZY_CAP_MTX_ALLOC - CapTransformPtr = NULL; + CapTransformPtr = nullptr; Index = that.Index; IsVisible = that.IsVisible; WorldSpaceTranslation = that.WorldSpaceTranslation; - if (that.CapTransformPtr != NULL) + if (that.CapTransformPtr != nullptr) { CapTransformPtr = MSGW3DNEW("PivotClassCaptureBoneMtx") DynamicMatrix3D; CapTransformPtr->Mat = that.CapTransformPtr->Mat; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/pivot.h b/Core/Libraries/Source/WWVegas/WW3D2/pivot.h index f8ab446df9d..bf753574b5b 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/pivot.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/pivot.h @@ -74,7 +74,7 @@ struct PivotClass bool Is_Captured() const { #ifdef LAZY_CAP_MTX_ALLOC - return CapTransformPtr != NULL; + return CapTransformPtr != nullptr; #else return IsCaptured; #endif diff --git a/Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp b/Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp index 34efa1c77d9..17a7977c8b3 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/pointgr.cpp @@ -94,9 +94,9 @@ // static data members Vector3 PointGroupClass::_TriVertexLocationOrientationTable[256][3]; Vector3 PointGroupClass::_QuadVertexLocationOrientationTable[256][4]; -Vector2 *PointGroupClass::_TriVertexUVFrameTable[5] = { NULL, NULL, NULL, NULL, NULL}; -Vector2 *PointGroupClass::_QuadVertexUVFrameTable[5] = { NULL, NULL, NULL, NULL, NULL}; -VertexMaterialClass *PointGroupClass::PointMaterial=NULL; +Vector2 *PointGroupClass::_TriVertexUVFrameTable[5] = { nullptr, nullptr, nullptr, nullptr, nullptr}; +Vector2 *PointGroupClass::_QuadVertexUVFrameTable[5] = { nullptr, nullptr, nullptr, nullptr, nullptr}; +VertexMaterialClass *PointGroupClass::PointMaterial=nullptr; // Static arrays for intermediate calcs (never resized down, just up): VectorClass PointGroupClass::compressed_loc; // point locations 'compressed' by APT @@ -149,15 +149,15 @@ SortingIndexBufferClass *SortingTris, *SortingQuads; // Sorting index buffers. * 11/17/1998 NH : Created. * *========================================================================*/ PointGroupClass::PointGroupClass(void) : - PointLoc(NULL), - PointDiffuse(NULL), - APT(NULL), - PointSize(NULL), - PointOrientation(NULL), - PointFrame(NULL), + PointLoc(nullptr), + PointDiffuse(nullptr), + APT(nullptr), + PointSize(nullptr), + PointOrientation(nullptr), + PointFrame(nullptr), PointCount(0), FrameRowColumnCountLog2(0), - Texture(NULL), + Texture(nullptr), Flags(0), Shader(ShaderClass::_PresetAdditiveSpriteShader), PointMode(TRIS), @@ -189,31 +189,31 @@ PointGroupClass::~PointGroupClass(void) { if (PointLoc) { PointLoc->Release_Ref(); - PointLoc = NULL; + PointLoc = nullptr; } if (PointDiffuse) { PointDiffuse->Release_Ref(); - PointDiffuse=NULL; + PointDiffuse=nullptr; } if (APT) { APT->Release_Ref(); - APT = NULL; + APT = nullptr; } if (PointSize) { PointSize->Release_Ref(); - PointSize = NULL; + PointSize = nullptr; } if (PointOrientation) { PointOrientation->Release_Ref(); - PointOrientation = NULL; + PointOrientation = nullptr; } if (PointFrame) { PointFrame->Release_Ref(); - PointFrame = NULL; + PointFrame = nullptr; } if (Texture) { REF_PTR_RELEASE(Texture); - Texture = NULL; + Texture = nullptr; } } @@ -248,7 +248,7 @@ PointGroupClass & PointGroupClass::operator = (const PointGroupClass & that) * WARNINGS: * * * * NOTES: colors, alphas, APT, sizes, orientations and frames are * - * optional. active_point_count can also be used with a NULL apt.* + * optional. active_point_count can also be used with a nullptr apt.* * In this case active_point_count is ignored if it is -1 * * (default value) and otherwise it indicates the first N active * * points in the arrays. * @@ -626,7 +626,7 @@ TextureClass * PointGroupClass::Peek_Texture(void) * WARNINGS: the primary gradient will be set to MODULATE/DISABLE in * * the shader depending on whether a color or alpha array was * * passed in Set_Point_Arrays. also, texturing will be * - * enabled or disabled dependent on whether a non-NULL * + * enabled or disabled dependent on whether a non-null * * texture was set. * * these will override the primary gradient/texturing * * settings in the given shader. * @@ -788,11 +788,11 @@ void PointGroupClass::Render(RenderInfoClass &rinfo) // if (Texture) Texture->Process_Reduction(); // Pointers which point into existing buffers (member or static): - Vector3 *current_loc = NULL; - Vector4 *current_diffuse = NULL; - float *current_size = NULL; - unsigned char *current_orient = NULL; - unsigned char *current_frame = NULL; + Vector3 *current_loc = nullptr; + Vector4 *current_diffuse = nullptr; + float *current_size = nullptr; + unsigned char *current_orient = nullptr; + unsigned char *current_frame = nullptr; // If there is a color or alpha array enable gradient in shader - otherwise disable. float value_255 = 0.9961f; //254 / 255 @@ -809,7 +809,7 @@ void PointGroupClass::Render(RenderInfoClass &rinfo) Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_DISABLE); } - // If Texture is non-NULL enable texturing in shader - otherwise disable. + // If Texture is non-null enable texturing in shader - otherwise disable. if (Texture) { Shader.Set_Texturing(ShaderClass::TEXTURING_ENABLE); } else { @@ -1041,9 +1041,9 @@ void PointGroupClass::Update_Arrays( if (VertexLoc.Length() < total_vnum) { // Resize arrays (2x guardband to prevent frequent reallocations). - VertexLoc.Resize(total_vnum * 2, NULL); - VertexUV.Resize(total_vnum * 2, NULL); - VertexDiffuse.Resize(total_vnum * 2, NULL); + VertexLoc.Resize(total_vnum * 2, nullptr); + VertexUV.Resize(total_vnum * 2, nullptr); + VertexDiffuse.Resize(total_vnum * 2, nullptr); } int vert, i, j; @@ -1660,11 +1660,11 @@ void PointGroupClass::RenderVolumeParticle(RenderInfoClass &rinfo, unsigned int WWASSERT(PointLoc && PointLoc->Get_Array()); // Pointers which point into existing buffers (member or static): - Vector3 *current_loc = NULL; - Vector4 *current_diffuse = NULL; - float *current_size = NULL; - unsigned char *current_orient = NULL; - unsigned char *current_frame = NULL; + Vector3 *current_loc = nullptr; + Vector4 *current_diffuse = nullptr; + float *current_size = nullptr; + unsigned char *current_orient = nullptr; + unsigned char *current_frame = nullptr; // If there is a color or alpha array enable gradient in shader - otherwise disable. float value_255 = 0.9961f; //254 / 255 @@ -1681,7 +1681,7 @@ void PointGroupClass::RenderVolumeParticle(RenderInfoClass &rinfo, unsigned int Shader.Set_Primary_Gradient(ShaderClass::GRADIENT_DISABLE); } - // If Texture is non-NULL enable texturing in shader - otherwise disable. + // If Texture is non-null enable texturing in shader - otherwise disable. if (Texture) { Shader.Set_Texturing(ShaderClass::TEXTURING_ENABLE); } else { diff --git a/Core/Libraries/Source/WWVegas/WW3D2/pointgr.h b/Core/Libraries/Source/WWVegas/WW3D2/pointgr.h index 021c56e5493..e0cce7d05be 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/pointgr.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/pointgr.h @@ -78,11 +78,11 @@ class PointGroupClass // PointGroupClass interface: void Set_Arrays(ShareBufferClass *locs, - ShareBufferClass *diffuse = NULL, - ShareBufferClass *apt = NULL, - ShareBufferClass *sizes = NULL, - ShareBufferClass *orientations = NULL, - ShareBufferClass *frames = NULL, + ShareBufferClass *diffuse = nullptr, + ShareBufferClass *apt = nullptr, + ShareBufferClass *sizes = nullptr, + ShareBufferClass *orientations = nullptr, + ShareBufferClass *frames = nullptr, int active_point_count = -1, float vpxmin = 0.0f, float vpymin = 0.0f, float vpxmax = 0.0f, float vpymax = 0.0f); @@ -151,11 +151,11 @@ class PointGroupClass // number of possible frames must be a power of two - for this reason the number of frame rows // and columns, orientations, etc. are represented as the log base 2 of the actual number. ShareBufferClass * PointLoc; // World/cameraspace point locs - ShareBufferClass * PointDiffuse; // (NULL if not used) RGBA values - ShareBufferClass * APT; // (NULL if not used) active point table - ShareBufferClass * PointSize; // (NULL if not used) size override table - ShareBufferClass * PointOrientation; // (NULL if not used) orientation indices - ShareBufferClass * PointFrame; // (NULL if not used) frame indices + ShareBufferClass * PointDiffuse; // (null if not used) RGBA values + ShareBufferClass * APT; // (null if not used) active point table + ShareBufferClass * PointSize; // (null if not used) size override table + ShareBufferClass * PointOrientation; // (null if not used) orientation indices + ShareBufferClass * PointFrame; // (null if not used) frame indices int PointCount; // Active (if APT) or total point count // See comments for Get/Set_Frame_Row_Column_Count_Log2 above diff --git a/Core/Libraries/Source/WWVegas/WW3D2/predlod.cpp b/Core/Libraries/Source/WWVegas/WW3D2/predlod.cpp index dfe2a899629..d612bed5ab7 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/predlod.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/predlod.cpp @@ -57,8 +57,8 @@ class LODHeapNode { public: - LODHeapNode(void) { Item = NULL; } - LODHeapNode (float key) { Item = NULL; Key = key; } + LODHeapNode(void) { Item = nullptr; } + LODHeapNode (float key) { Item = nullptr; Key = key; } LODHeapNode (RenderObjClass * item, float key) { Item = item; Key = key; } ~LODHeapNode(void) { } @@ -173,7 +173,7 @@ class LODHeap { }; // Static PredictiveLODOptimizerClass data members: -RenderObjClass ** PredictiveLODOptimizerClass::ObjectArray = NULL; +RenderObjClass ** PredictiveLODOptimizerClass::ObjectArray = nullptr; int PredictiveLODOptimizerClass::ArraySize = 0; int PredictiveLODOptimizerClass::NumObjects = 0; float PredictiveLODOptimizerClass::TotalCost = 0.0f; @@ -201,7 +201,7 @@ void PredictiveLODOptimizerClass::Clear(void) for (int i = 0; i < NumObjects; i++) { if (ObjectArray[i]) { ObjectArray[i]->Release_Ref(); - ObjectArray[i] = NULL; + ObjectArray[i] = nullptr; } } } @@ -296,8 +296,8 @@ void PredictiveLODOptimizerClass::Optimize_LODs(float max_cost) LODHeap min_current_value_queue(NumObjects, VisibleObjArray1); LODHeap max_post_increment_value_queue(NumObjects, VisibleObjArray2); // These memory areas now are pointed to within the heaps: -// visible_obj_array1 = NULL; -// visible_obj_array2 = NULL; +// visible_obj_array1 = nullptr; +// visible_obj_array2 = nullptr; // Main loop: iteratively increment/decrement tuples. bool done = false; @@ -305,8 +305,8 @@ void PredictiveLODOptimizerClass::Optimize_LODs(float max_cost) while (!done) { // Initialize max_data and min_data so comparison at end of loop uses correct values. - max_data = NULL; - min_data = NULL; + max_data = nullptr; + min_data = nullptr; // Increment incrementable tuple with maximum next value. if (TotalCost <= max_cost) { @@ -382,13 +382,13 @@ void PredictiveLODOptimizerClass::Free(void) Clear(); delete [] ObjectArray; - ObjectArray = NULL; + ObjectArray = nullptr; ArraySize = 0; // Only the array number one has been allocated... delete[] VisibleObjArray1; - VisibleObjArray1=NULL; - VisibleObjArray2=NULL; + VisibleObjArray1=nullptr; + VisibleObjArray2=nullptr; VisibleObjArraySize = 0; } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/proto.cpp b/Core/Libraries/Source/WWVegas/WW3D2/proto.cpp index c19af3b2050..d899803ce62 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/proto.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/proto.cpp @@ -121,8 +121,8 @@ PrototypeClass * MeshLoaderClass::Load_W3D(ChunkLoadClass & cload) { MeshClass * mesh = NEW_REF( MeshClass, () ); - if (mesh == NULL) { - return NULL; + if (mesh == nullptr) { + return nullptr; } if (mesh->Load_W3D(cload) != WW3D_ERROR_OK) { @@ -130,7 +130,7 @@ PrototypeClass * MeshLoaderClass::Load_W3D(ChunkLoadClass & cload) // if the load failed, delete the mesh assert(mesh->Num_Refs() == 1); mesh->Release_Ref(); - return NULL; + return nullptr; } else { @@ -159,15 +159,15 @@ PrototypeClass * HModelLoaderClass::Load_W3D(ChunkLoadClass & cload) { HModelDefClass * hdef = W3DNEW HModelDefClass; - if (hdef == NULL) { - return NULL; + if (hdef == nullptr) { + return nullptr; } if (hdef->Load_W3D(cload) != HModelDefClass::OK) { // load failed, delete the model and return an error delete hdef; - return NULL; + return nullptr; } else { diff --git a/Core/Libraries/Source/WWVegas/WW3D2/proto.h b/Core/Libraries/Source/WWVegas/WW3D2/proto.h index eb375602e23..d8f91de126c 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/proto.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/proto.h @@ -81,7 +81,7 @@ class PrototypeClass public: - PrototypeClass(void) : NextHash(NULL) {} + PrototypeClass(void) : NextHash(nullptr) {} virtual const char * Get_Name(void) const = 0; virtual int Get_Class_ID(void) const = 0; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/rddesc.h b/Core/Libraries/Source/WWVegas/WW3D2/rddesc.h index 06fcbd4b510..ac305c9512f 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/rddesc.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/rddesc.h @@ -61,9 +61,9 @@ class RenderDeviceDescClass public: - RenderDeviceDescClass(void) : DeviceName(NULL), DeviceVendor(NULL), DevicePlatform(NULL), - DriverName(NULL), DriverVendor(NULL), DriverVersion(NULL), - HardwareName(NULL), HardwareVendor(NULL), HardwareChipset(NULL) + RenderDeviceDescClass(void) : DeviceName(), DeviceVendor(), DevicePlatform(), + DriverName(), DriverVendor(), DriverVersion(), + HardwareName(), HardwareVendor(), HardwareChipset() { } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp b/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp index e307f2e41f3..3b251ac3156 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/render2dsentence.cpp @@ -54,18 +54,18 @@ // //////////////////////////////////////////////////////////////////////////////////// Render2DSentenceClass::Render2DSentenceClass (void) : - Font (NULL), + Font (nullptr), Location (0.0F,0.0F), Cursor (0.0F,0.0F), TextureOffset (0, 0), TextureStartX (0), - CurSurface (NULL), + CurSurface (nullptr), CurrTextureSize (0), MonoSpaced (false), IsClippedEnabled (false), ClipRect (0, 0, 0, 0), BaseLocation (0, 0), - LockedPtr (NULL), + LockedPtr (nullptr), LockedStride (0), TextureSizeHint (0), WrapWidth (0), @@ -133,9 +133,9 @@ Render2DSentenceClass::Reset (void) // // Make sure we unlock the current surface (if necessary) // - if (LockedPtr != NULL) { + if (LockedPtr != nullptr) { CurSurface->Unlock (); - LockedPtr = NULL; + LockedPtr = nullptr; } // @@ -286,7 +286,7 @@ Render2DSentenceClass::Get_Text_Extents (const WCHAR *text) Vector2 Render2DSentenceClass::Get_Formatted_Text_Extents (const WCHAR *text) { - return Build_Sentence_Not_Centered(text, NULL, NULL, true); + return Build_Sentence_Not_Centered(text, nullptr, nullptr, true); } @@ -346,9 +346,9 @@ Render2DSentenceClass::Build_Textures (void) // // Make sure we unlock the current surface // - if (LockedPtr != NULL) { + if (LockedPtr != nullptr) { CurSurface->Unlock (); - LockedPtr = NULL; + LockedPtr = nullptr; } // @@ -386,7 +386,7 @@ Render2DSentenceClass::Build_Textures (void) // // Copy the contents of the texture from the surface // - DX8Wrapper::_Copy_DX8_Rects (curr_surface->Peek_D3D_Surface (), NULL, 0, texture_surface->Peek_D3D_Surface (), NULL); + DX8Wrapper::_Copy_DX8_Rects (curr_surface->Peek_D3D_Surface (), nullptr, 0, texture_surface->Peek_D3D_Surface (), nullptr); REF_PTR_RELEASE (texture_surface); // @@ -422,8 +422,8 @@ Render2DSentenceClass::Build_Textures (void) void Render2DSentenceClass::Draw_Sentence (uint32 color) { - Render2DClass *curr_renderer = NULL; - SurfaceClass *curr_surface = NULL; + Render2DClass *curr_renderer = nullptr; + SurfaceClass *curr_surface = nullptr; DrawExtents.Set (0, 0, 0, 0); @@ -631,9 +631,9 @@ Render2DSentenceClass::Allocate_New_Surface (const WCHAR *text, bool justCalcExt // // Unlock the last surface (if necessary) // - if (LockedPtr != NULL) { + if (LockedPtr != nullptr) { CurSurface->Unlock (); - LockedPtr = NULL; + LockedPtr = nullptr; } } @@ -697,7 +697,7 @@ Render2DSentenceClass::Allocate_New_Surface (const WCHAR *text, bool justCalcExt // Create the new surface // CurSurface = NEW_REF (SurfaceClass, (CurrTextureSize, CurrTextureSize, WW3D_FORMAT_A4R4G4B4)); - WWASSERT (CurSurface != NULL); + WWASSERT (CurSurface != nullptr); CurSurface->Add_Ref (); // @@ -743,7 +743,7 @@ void Render2DSentenceClass::Build_Sentence_Centered (const WCHAR *text, int *hkX // // Ensure we have a surface to start with // - if (CurSurface == NULL) { + if (CurSurface == nullptr) { Allocate_New_Surface (text); } @@ -926,9 +926,9 @@ void Render2DSentenceClass::Build_Sentence_Centered (const WCHAR *text, int *hkX // // Ensure the surface is locked // - if (LockedPtr == NULL) { + if (LockedPtr == nullptr) { LockedPtr = (uint16 *)CurSurface->Lock (&LockedStride); - WWASSERT (LockedPtr != NULL); + WWASSERT (LockedPtr != nullptr); } // @@ -998,7 +998,7 @@ Vector2 Render2DSentenceClass::Build_Sentence_Not_Centered (const WCHAR *text, i // // Ensure we have a surface to start with // - if (CurSurface == NULL) { + if (CurSurface == nullptr) { Allocate_New_Surface (text, justCalcExtents); } @@ -1010,7 +1010,7 @@ Vector2 Render2DSentenceClass::Build_Sentence_Not_Centered (const WCHAR *text, i // // Loop over all the characters in the string // - while (text != NULL) { + while (text != nullptr) { WCHAR ch = *text++; dontBlit = false; // @@ -1116,9 +1116,9 @@ Vector2 Render2DSentenceClass::Build_Sentence_Not_Centered (const WCHAR *text, i // if (!justCalcExtents) { - if (LockedPtr == NULL) { + if (LockedPtr == nullptr) { LockedPtr = (uint16 *)CurSurface->Lock (&LockedStride); - WWASSERT (LockedPtr != NULL); + WWASSERT (LockedPtr != nullptr); } } @@ -1163,11 +1163,11 @@ Vector2 Render2DSentenceClass::Build_Sentence_Not_Centered (const WCHAR *text, i void Render2DSentenceClass::Build_Sentence (const WCHAR *text, int *hkX, int *hkY) { - if (text == NULL) { + if (text == nullptr) { return ; } - if (Font == NULL) + if (Font == nullptr) return; if(Centered && (WrapWidth > 0 || wcschr(text,L'\n'))) @@ -1186,21 +1186,21 @@ Render2DSentenceClass::Build_Sentence (const WCHAR *text, int *hkX, int *hkY) // //////////////////////////////////////////////////////////////////////////////////// FontCharsClass::FontCharsClass (void) : - OldGDIFont( NULL ), - OldGDIBitmap( NULL ), - GDIFont( NULL ), - GDIBitmap( NULL ), - GDIBitmapBits ( NULL ), - MemDC( NULL ), + OldGDIFont( nullptr ), + OldGDIBitmap( nullptr ), + GDIFont( nullptr ), + GDIBitmap( nullptr ), + GDIBitmapBits ( nullptr ), + MemDC( nullptr ), CurrPixelOffset( 0 ), PointSize( 0 ), CharHeight( 0 ), - UnicodeCharArray( NULL ), + UnicodeCharArray( nullptr ), FirstUnicodeChar( 0xFFFF ), LastUnicodeChar( 0 ), IsBold (false) { - AlternateUnicodeFont = NULL; + AlternateUnicodeFont = nullptr; ::memset( ASCIICharArray, 0, sizeof (ASCIICharArray) ); return ; } @@ -1232,7 +1232,7 @@ FontCharsClass::~FontCharsClass (void) const FontCharsClassCharDataStruct * FontCharsClass::Get_Char_Data (WCHAR ch) { - const FontCharsClassCharDataStruct *retval = NULL; + const FontCharsClassCharDataStruct *retval = nullptr; if ( ch < 256 ) { @@ -1251,7 +1251,7 @@ FontCharsClass::Get_Char_Data (WCHAR ch) // // If the character wasn't found, then add it to our list // - if ( retval == NULL ) { + if ( retval == nullptr ) { retval = Store_GDI_Char( ch ); } @@ -1269,7 +1269,7 @@ int FontCharsClass::Get_Char_Width (WCHAR ch) { const FontCharsClassCharDataStruct * data = Get_Char_Data( ch ); - if ( data != NULL ) { + if ( data != nullptr ) { return data->Width; } @@ -1286,7 +1286,7 @@ int FontCharsClass::Get_Char_Spacing (WCHAR ch) { const FontCharsClassCharDataStruct * data = Get_Char_Data( ch ); - if ( data != NULL ) { + if ( data != nullptr ) { if ( data->Width != 0 ) { return data->Width - PixelOverlap - CharOverhang; } @@ -1305,7 +1305,7 @@ void FontCharsClass::Blit_Char (WCHAR ch, uint16 *dest_ptr, int dest_stride, int x, int y) { const FontCharsClassCharDataStruct * data = Get_Char_Data( ch ); - if ( data != NULL && data->Width != 0 ) { + if ( data != nullptr && data->Width != 0 ) { // // Setup the src and destination pointers @@ -1353,7 +1353,7 @@ FontCharsClass::Store_GDI_Char (WCHAR ch) if (ch == 'W') { xOrigin = 1; } - ::ExtTextOutW( MemDC, xOrigin, 0, ETO_OPAQUE, &rect, &ch, 1, NULL); + ::ExtTextOutW( MemDC, xOrigin, 0, ETO_OPAQUE, &rect, &ch, 1, nullptr); // // Get the size of the character we just drew @@ -1565,7 +1565,7 @@ FontCharsClass::Create_GDI_Font (const char *font_name) (const BITMAPINFO *)&bitmap_info, DIB_RGB_COLORS, (void **)&GDIBitmapBits, - NULL, + nullptr, 0L); // @@ -1598,7 +1598,7 @@ FontCharsClass::Create_GDI_Font (const char *font_name) CharOverhang = 0; } - return GDIFont != NULL && GDIBitmap != NULL; + return GDIFont != nullptr && GDIBitmap != nullptr; } @@ -1614,28 +1614,28 @@ FontCharsClass::Free_GDI_Font (void) // Select the old font back into the DC and delete // our font object // - if ( GDIFont != NULL ) { + if ( GDIFont != nullptr ) { ::SelectObject( MemDC, OldGDIFont ); ::DeleteObject( GDIFont ); - GDIFont = NULL; + GDIFont = nullptr; } // // Select the old bitmap back into the DC and delete // our bitmap object // - if ( GDIBitmap != NULL ) { + if ( GDIBitmap != nullptr ) { ::SelectObject( MemDC, OldGDIBitmap ); ::DeleteObject( GDIBitmap ); - GDIBitmap = NULL; + GDIBitmap = nullptr; } // // Delete our memory DC // - if ( MemDC != NULL ) { + if ( MemDC != nullptr ) { ::DeleteDC( MemDC ); - MemDC = NULL; + MemDC = nullptr; } return ; @@ -1728,7 +1728,7 @@ FontCharsClass::Grow_Unicode_Array (WCHAR ch) // // Copy the contents of the old array into the new array // - if ( UnicodeCharArray != NULL ) { + if ( UnicodeCharArray != nullptr ) { int start_offset = (FirstUnicodeChar - first_index); int old_count = (LastUnicodeChar - FirstUnicodeChar) + 1; ::memcpy (&new_array[start_offset], UnicodeCharArray, sizeof (FontCharsClassCharDataStruct *) * old_count); @@ -1737,7 +1737,7 @@ FontCharsClass::Grow_Unicode_Array (WCHAR ch) // Delete the old array // delete [] UnicodeCharArray; - UnicodeCharArray = NULL; + UnicodeCharArray = nullptr; } FirstUnicodeChar = first_index; @@ -1755,7 +1755,7 @@ FontCharsClass::Grow_Unicode_Array (WCHAR ch) void FontCharsClass::Free_Character_Arrays (void) { - if ( UnicodeCharArray != NULL ) { + if ( UnicodeCharArray != nullptr ) { int count = (LastUnicodeChar - FirstUnicodeChar) + 1; @@ -1764,14 +1764,14 @@ FontCharsClass::Free_Character_Arrays (void) // for (int index = 0; index < count; index ++) { delete UnicodeCharArray[index]; - UnicodeCharArray[index] = NULL; + UnicodeCharArray[index] = nullptr; } // // Delete the array itself // delete [] UnicodeCharArray; - UnicodeCharArray = NULL; + UnicodeCharArray = nullptr; } // @@ -1779,7 +1779,7 @@ FontCharsClass::Free_Character_Arrays (void) // for (int index = 0; index < 256; index ++) { delete ASCIICharArray[index]; - ASCIICharArray[index] = NULL; + ASCIICharArray[index] = nullptr; } return ; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp b/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp index f6d787fc139..f4eff41a166 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/renderobjectrecycler.cpp @@ -82,7 +82,7 @@ RenderObjClass * RenderObjectRecyclerClass::Get_Render_Object(const char * name, { RefRenderObjListIterator it(&InactiveModels); - RenderObjClass * found = NULL; + RenderObjClass * found = nullptr; while (!it.Is_Done()) { if (stricmp(it.Peek_Obj()->Get_Name(),name) == 0) { found = it.Peek_Obj(); @@ -91,7 +91,7 @@ RenderObjClass * RenderObjectRecyclerClass::Get_Render_Object(const char * name, it.Next(); } - if (found != NULL) { + if (found != nullptr) { found->Add_Ref(); InactiveModels.Remove(found); found->Set_Transform(tm); @@ -101,13 +101,13 @@ RenderObjClass * RenderObjectRecyclerClass::Get_Render_Object(const char * name, } else { RenderObjClass * new_model = WW3DAssetManager::Get_Instance()->Create_Render_Obj(name); - if (new_model != NULL) { + if (new_model != nullptr) { new_model->Set_Transform(tm); return new_model; } } - return NULL; + return nullptr; } @@ -143,7 +143,7 @@ void RenderObjectRecyclerClass::Return_Render_Object(RenderObjClass * obj) *=============================================================================================*/ void RenderObjectRecyclerClass::Insert_Inactive_Model(RenderObjClass * obj) { - WWASSERT(obj != NULL); + WWASSERT(obj != nullptr); InactiveModels.Add(obj); } @@ -181,7 +181,7 @@ void RenderObjectRecyclerClass::Reset_Model(RenderObjClass * model) /* ** animated models must have their animation reset (if present) */ - if (model->Peek_Animation() != NULL) { + if (model->Peek_Animation() != nullptr) { model->Set_Animation(model->Peek_Animation(),0.0f,RenderObjClass::ANIM_MODE_ONCE); } } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp index b5d0671fc17..46d037b9330 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.cpp @@ -103,7 +103,7 @@ StringClass Filename_From_Asset_Name (const char *asset_name) { StringClass filename; - if (asset_name != NULL) { + if (asset_name != nullptr) { // // Copy the model name into a new filename buffer @@ -114,7 +114,7 @@ Filename_From_Asset_Name (const char *asset_name) // Do we need to strip off the model's suffix? // char *suffix = ::strchr (filename.Peek_Buffer(), '.'); - if (suffix != NULL) { + if (suffix != nullptr) { suffix[0] = 0; } @@ -165,10 +165,10 @@ RenderObjClass::RenderObjClass(void) : Bits(DEFAULT_BITS), Transform(1), NativeScreenSize(WW3D::Get_Default_Native_Screen_Size()), - Scene(NULL), - Container(NULL), - User_Data(NULL), - RenderHook(NULL), + Scene(nullptr), + Container(nullptr), + User_Data(nullptr), + RenderHook(nullptr), ObjectScale(1.0), ObjectColor(0), CachedBoundingSphere(Vector3(0,0,0),1.0f), @@ -194,10 +194,10 @@ RenderObjClass::RenderObjClass(const RenderObjClass & src) : Bits(src.Bits), Transform(src.Transform), NativeScreenSize(src.NativeScreenSize), - Scene(NULL), - Container(NULL), - User_Data(NULL), - RenderHook(NULL), + Scene(nullptr), + Container(nullptr), + User_Data(nullptr), + RenderHook(nullptr), ObjectScale(1.0), ObjectColor(0), CachedBoundingSphere(src.CachedBoundingSphere), @@ -354,7 +354,7 @@ float RenderObjClass::Get_Screen_Size(CameraClass &camera) *=============================================================================================*/ SceneClass * RenderObjClass::Get_Scene(void) { - if (Scene != NULL) { + if (Scene != nullptr) { Scene->Add_Ref(); } return Scene; @@ -377,7 +377,7 @@ void RenderObjClass::Set_Container(RenderObjClass * con) { // Either we arent currently in a container or we are clearing our container, otherwise // Houston, there is a problem! - WWASSERT((con == NULL) || (Container == NULL)); + WWASSERT((con == nullptr) || (Container == nullptr)); Container = con; } @@ -463,11 +463,11 @@ void RenderObjClass::Validate_Transform(void) const */ RenderObjClass * con = Get_Container(); bool dirty = false; - if (con != NULL) + if (con != nullptr) { dirty = con->Are_Sub_Object_Transforms_Dirty(); - while (con->Get_Container() != NULL) + while (con->Get_Container() != nullptr) { dirty |= con->Are_Sub_Object_Transforms_Dirty(); con = con->Get_Container(); @@ -540,7 +540,7 @@ RenderObjClass * RenderObjClass::Get_Sub_Object_By_Name(const char * name, int * RenderObjClass * robj = Get_Sub_Object(i); if (robj) { const char * subobjname = strchr(robj->Get_Name(),'.'); - if (subobjname == NULL) { + if (subobjname == nullptr) { subobjname = robj->Get_Name(); } else { // skip past the period. @@ -556,7 +556,7 @@ RenderObjClass * RenderObjClass::Get_Sub_Object_By_Name(const char * name, int * } } - return NULL; + return nullptr; } @@ -789,7 +789,7 @@ void RenderObjClass::Update_Sub_Object_Transforms(void) void RenderObjClass::Add(SceneClass * scene) { WWASSERT(scene); - WWASSERT(Container == NULL); + WWASSERT(Container == nullptr); Scene = scene; Scene->Add_Render_Object(this); } @@ -810,10 +810,10 @@ void RenderObjClass::Add(SceneClass * scene) 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. + // object, (i.e. directly in the scene) you see if its Container pointer is null. #if 1 - if (Container == NULL) { - if (Scene != NULL) { + if (Container == nullptr) { + if (Scene != nullptr) { Scene->Remove_Render_Object(this); return true; } @@ -826,7 +826,7 @@ bool RenderObjClass::Remove(void) if (!Scene) return false; Scene->Remove_Render_Object(this); - Scene = NULL; + Scene = nullptr; return true; #endif } @@ -880,7 +880,7 @@ void RenderObjClass::Notify_Added(SceneClass * scene) *=============================================================================================*/ void RenderObjClass::Notify_Removed(SceneClass * scene) { - Scene = NULL; + Scene = nullptr; } @@ -1056,7 +1056,7 @@ bool RenderObjClass::Build_Dependency_List (DynamicVectorClass &fil // Ask this subobj to add all of its file dependencies to the list RenderObjClass *psub_obj = Get_Sub_Object (index); - if (psub_obj != NULL) { + if (psub_obj != nullptr) { psub_obj->Build_Dependency_List (file_list); psub_obj->Release_Ref (); } @@ -1101,7 +1101,7 @@ bool RenderObjClass::Build_Texture_List // Ask this subobj to add all of its texture file dependencies to the list // RenderObjClass *sub_obj = Get_Sub_Object (index); - if (sub_obj != NULL) { + if (sub_obj != nullptr) { sub_obj->Build_Texture_List (texture_file_list); sub_obj->Release_Ref (); } @@ -1150,7 +1150,7 @@ void RenderObjClass::Add_Dependencies_To_List // External hierarchy file // const HTreeClass *phtree = Get_HTree (); - if (phtree != NULL) { + if (phtree != nullptr) { const char *htree_name = phtree->Get_Name (); if (::lstrcmpi (htree_name, model_name) != 0) { @@ -1165,7 +1165,7 @@ void RenderObjClass::Add_Dependencies_To_List // Original W3D file (if an aggregate) // const char *base_model_name = Get_Base_Model_Name (); - if (base_model_name != NULL) { + if (base_model_name != nullptr) { // // Add this file to the list @@ -1182,7 +1182,7 @@ void RenderObjClass::Add_Dependencies_To_List /**************************************************************************************** - RenderObjClass - Persistant object support. + RenderObjClass - Persistent object support. NOTE: For now, the render obj PersistFactory is going to cheat by simply storing the name of the render object that was saved. At load time, it will ask the @@ -1216,7 +1216,7 @@ uint32 RenderObjPersistFactoryClass::Chunk_ID(void) const PersistClass * RenderObjPersistFactoryClass::Load(ChunkLoadClass & cload) const { - RenderObjClass * old_obj = NULL; + RenderObjClass * old_obj = nullptr; Matrix3D tm(1); char name[64]; name[0] = '\0'; @@ -1248,25 +1248,25 @@ PersistClass * RenderObjPersistFactoryClass::Load(ChunkLoadClass & cload) const static int count = 0; if ( count++ < 10 ) { WWDEBUG_SAY(("RenderObjPersistFactory attempted to load an un-named render object!")); - WWDEBUG_SAY(("Replacing it with a NULL render object!")); + WWDEBUG_SAY(("Replacing it with a null render object!")); } strcpy(name,"NULL"); } RenderObjClass * new_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj(name); - if (new_obj == NULL) { + if (new_obj == nullptr) { static int count = 0; 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!")); + WWDEBUG_SAY(("Replacing it with a null render object!")); } strcpy(name,"NULL"); new_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj(name); } - WWASSERT(new_obj != NULL); + WWASSERT(new_obj != nullptr); if (new_obj) { new_obj->Set_Transform(tm); } @@ -1301,7 +1301,7 @@ bool RenderObjClass::Save (ChunkSaveClass &csave) { // This should never hit with the persist factory we're using... // Yes this looks like a design flaw but the way we're saving render objects is - // a "shortcut". We specifically designed this capability into the persistant + // a "shortcut". We specifically designed this capability into the persistent // object system so that we could avoid making all render object's save and // load themselves if possible. WWASSERT(0); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/rendobj.h b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.h index fe1005ff48e..0b4861c00bd 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/rendobj.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/rendobj.h @@ -157,7 +157,7 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL //Added for 'Generals' - MW enum {USER_DATA_MATERIAL_OVERRIDE = 0x01234567}; - //This strucutre is used to pass custom rendering parameters into the W3D + //This structure is used to pass custom rendering parameters into the W3D //mesh renderer so it can override settings which are usually shared across //all instances of a model - typically material settings like alpha, texture //animation, texture uv scrolling, etc. Added for 'Generals' -MW @@ -228,7 +228,7 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL virtual int Class_ID(void) const { return CLASSID_UNKNOWN; } virtual const char * Get_Name(void) const { return "UNNAMED"; } virtual void Set_Name(const char * name) { } - virtual const char * Get_Base_Model_Name (void) const { return NULL; } + virtual const char * Get_Base_Model_Name (void) const { return nullptr; } virtual void Set_Base_Model_Name (const char *name) { } virtual int Get_Num_Polys(void) const { return 0; } @@ -253,7 +253,7 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Render Object Interface - "Scene Graph" // Some of the functions in this group are non-virtual as they are meant - // to be never overriden or are supposed to be implemented in terms of + // to be never overridden or are supposed to be implemented in terms of // the other virtual functions. We want to keep the virtual interface // as small as possible /////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -286,13 +286,13 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL virtual void Notify_Removed(SceneClass * scene); virtual int Get_Num_Sub_Objects(void) const { return 0; } - virtual RenderObjClass * Get_Sub_Object(int index) const { return NULL; } + virtual RenderObjClass * Get_Sub_Object(int index) const { return nullptr; } virtual int Add_Sub_Object(RenderObjClass * subobj) { return 0; } virtual int Remove_Sub_Object(RenderObjClass * robj) { return 0; } - virtual RenderObjClass * Get_Sub_Object_By_Name(const char * name, int *index=NULL) const; + virtual RenderObjClass * Get_Sub_Object_By_Name(const char * name, int *index=nullptr) const; virtual int Get_Num_Sub_Objects_On_Bone(int boneindex) const { return 0; } - virtual RenderObjClass * Get_Sub_Object_On_Bone(int index,int boneindex) const { return NULL; } + virtual RenderObjClass * Get_Sub_Object_On_Bone(int index,int boneindex) const { return nullptr; } virtual int Get_Sub_Object_Bone_Index(RenderObjClass * subobj) const { return 0; } virtual int Get_Sub_Object_Bone_Index(int LodIndex, int ModelIndex) const { return 0; } virtual int Add_Sub_Object_To_Bone(RenderObjClass * subobj,int bone_index) { return 0; } @@ -329,9 +329,9 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL float percentage) { } virtual void Set_Animation( HAnimComboClass * anim_combo) { } - virtual HAnimClass * Peek_Animation( void ) { return NULL; } + virtual HAnimClass * Peek_Animation( void ) { return nullptr; } virtual int Get_Num_Bones(void) { return 0; } - virtual const char * Get_Bone_Name(int bone_index) { return NULL; } + virtual const char * Get_Bone_Name(int bone_index) { return nullptr; } virtual int Get_Bone_Index(const char * bonename) { return 0; } virtual const Matrix3D & Get_Bone_Transform(const char * bonename) { return Get_Transform(); } virtual const Matrix3D & Get_Bone_Transform(int boneindex) { return Get_Transform(); } @@ -341,7 +341,7 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL virtual void Release_Bone(int bindex) { } virtual bool Is_Bone_Captured(int bindex) const { return false; } virtual void Control_Bone(int bindex,const Matrix3D & objtm,bool world_space_translation = false) { } - virtual const HTreeClass * Get_HTree(void) const { return NULL; } + virtual const HTreeClass * Get_HTree(void) const { return nullptr; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Render Object Interface - Collision Detection @@ -422,7 +422,7 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL /////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Render Object Interface - Attributes, Options, Properties, etc /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - virtual MaterialInfoClass * Get_Material_Info(void) { return NULL; } + virtual MaterialInfoClass * Get_Material_Info(void) { return nullptr; } virtual void Set_User_Data(void *value, bool recursive = false) { User_Data = value; }; virtual void * Get_User_Data() { return User_Data; }; virtual int Get_Num_Snap_Points(void) { return 0; } @@ -465,7 +465,7 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL virtual int Get_Collision_Type(void) const { return (Bits & COLL_TYPE_MASK); } virtual void Set_Collision_Type(int type) { Bits &= ~COLL_TYPE_MASK; Bits |= (type & COLL_TYPE_MASK) | COLL_TYPE_ALL; } virtual bool Is_Complete(void) { return false; } - virtual bool Is_In_Scene(void) { return Scene != NULL; } + virtual bool Is_In_Scene(void) { return Scene != nullptr; } virtual float Get_Native_Screen_Size(void) const { return NativeScreenSize; } virtual void Set_Native_Screen_Size(float screensize) { NativeScreenSize = screensize; } @@ -483,7 +483,7 @@ class RenderObjClass : public RefCountClass , public PersistClass, public MultiL int Is_Self_Shadowed() const { return (Bits&IS_SELF_SHADOWED); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - // Persistant object save-load interface + // Persistent object save-load interface /////////////////////////////////////////////////////////////////////////////////////////////////////////////// virtual const PersistFactoryClass & Get_Factory (void) const; virtual bool Save (ChunkSaveClass &csave); @@ -643,7 +643,7 @@ static const char* const TheAnimModeNames[] = "LOOP_PINGPONG", "LOOP_BACKWARDS", "ONCE_BACKWARDS", - NULL + nullptr }; 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 5108aa7152a..de5e0de92f9 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/ringobj.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/ringobj.cpp @@ -171,8 +171,8 @@ RingRenderObjClass::RingRenderObjClass(void) LODBias(1.0f), CurrentLOD(RING_NUM_LOD), // RING_NUM_LOD does not include the null LOD AnimDuration (0.0F), - RingMaterial (NULL), - RingTexture (NULL), + RingMaterial (nullptr), + RingTexture (nullptr), Color (0.75F,0.75F,0.75F), InnerScale (1, 1), OuterScale (1, 1), @@ -214,8 +214,8 @@ RingRenderObjClass::RingRenderObjClass(const W3dRingStruct & def) LODBias(1.0f), CurrentLOD(RING_NUM_LOD), // RING_NUM_LOD does not include the null LOD AnimDuration (0.0F), - RingMaterial (NULL), - RingTexture (NULL), + RingMaterial (nullptr), + RingTexture (nullptr), Color (0.75F,0.75F,0.75F), InnerScale (1, 1), OuterScale (1, 1), @@ -265,8 +265,8 @@ RingRenderObjClass::RingRenderObjClass(const RingRenderObjClass & src) LODBias(1.0f), CurrentLOD(RING_NUM_LOD), // RING_NUM_LOD does not include the null LOD AnimDuration (0.0F), - RingMaterial (NULL), - RingTexture (NULL), + RingMaterial (nullptr), + RingTexture (nullptr), Color (0.75F,0.75F,0.75F), InnerScale (1, 1), OuterScale (1, 1), @@ -373,7 +373,7 @@ void RingRenderObjClass::Generate_Shared_Mesh_Arrays (void) float step = (RING_HIGHEST_LOD - RING_LOWEST_LOD); step /= RING_NUM_LOD; - // For NULL LOD set Cost to a small nonzero amount to avoid divisions by zero. + // For null LOD set Cost to a small nonzero amount to avoid divisions by zero. RingLODCosts[0] = 0.000001f; for(int i=0; i < RING_NUM_LOD; i++) { @@ -501,7 +501,7 @@ const char * RingRenderObjClass::Get_Name(void) const *=============================================================================================*/ void RingRenderObjClass::Set_Name(const char * name) { - WWASSERT(name != NULL); + WWASSERT(name != nullptr); const size_t nameLen = strlcpy(Name, name, ARRAY_SIZE(Name)); (void)nameLen; WWASSERT(nameLen < ARRAY_SIZE(Name)); } @@ -520,7 +520,7 @@ void RingRenderObjClass::Set_Name(const char * name) *=============================================================================================*/ void RingRenderObjClass::render_ring(RenderInfoClass & rinfo,const Vector3 & center,const Vector3 & extent) { - // Should never get here with NULL LOD + // Should never get here with null LOD if (CurrentLOD == 0) { WWASSERT(0); return; @@ -670,7 +670,7 @@ int RingRenderObjClass::Class_ID(void) const *=============================================================================================*/ void RingRenderObjClass::Render(RenderInfoClass & rinfo) { - // NULL LOD + // null LOD if (CurrentLOD == 0) return; if (Is_Not_Hidden_At_All() == false) { @@ -707,7 +707,7 @@ void RingRenderObjClass::Render(RenderInfoClass & rinfo) // // Make sure this mesh uses the correct UV tiling // - if (RingTexture != NULL) { + if (RingTexture != nullptr) { RingMeshArray[CurrentLOD - 1].Set_Tiling (TextureTileCount); } @@ -859,7 +859,7 @@ void RingRenderObjClass::Special_Render(SpecialRenderInfoClass & rinfo) temp.Translate(Transform.Get_Translation()); if (rinfo.RenderType == SpecialRenderInfoClass::RENDER_VIS) { - WWASSERT(rinfo.VisRasterizer != NULL); + WWASSERT(rinfo.VisRasterizer != nullptr); rinfo.VisRasterizer->Set_Model_Transform(temp); vis_render_ring(rinfo,ObjSpaceCenter,ObjSpaceExtent); } @@ -1101,7 +1101,7 @@ void RingRenderObjClass::Scale(float scalex, float scaley, float scalez) /*********************************************************************************************** - * RingRenderObjClass::Update_On_Visibilty -- Either starts or stops the animation based on vis* + * RingRenderObjClass::Update_On_Visibility -- Either starts or stops the animation based on vis* * * * INPUT: * * * @@ -1112,7 +1112,7 @@ void RingRenderObjClass::Scale(float scalex, float scaley, float scalez) * HISTORY: * * 4/04/00 pds : Created. * *=============================================================================================*/ -void RingRenderObjClass::Update_On_Visibilty(void) +void RingRenderObjClass::Update_On_Visibility(void) { // Simply start or stop the animation based on // the visibility state of the primitive. @@ -1228,10 +1228,10 @@ RingPrototypeClass::RingPrototypeClass(RingRenderObjClass *ring) // // Determine the texture name for this ring // - if (ring->RingTexture != NULL) { + if (ring->RingTexture != nullptr) { StringClass name = ring->RingTexture->Get_Full_Path(); const char *filename = ::strrchr (name, '\\'); - if (filename != NULL) { + if (filename != nullptr) { filename ++; } else { filename = name; @@ -1408,12 +1408,12 @@ RingMeshClass::RingMeshClass(float radius, int slices): Radius(radius), Slices(slices), Vertex_ct(0), // 1 vertex minimum, for center -vtx(NULL), -orig_vtx(NULL), -vtx_normal(NULL), -vtx_uv(NULL), +vtx(nullptr), +orig_vtx(nullptr), +vtx_normal(nullptr), +vtx_uv(nullptr), face_ct(0), -tri_poly(NULL), +tri_poly(nullptr), TileCount (5), InnerScale (1.0F, 1.0F), OuterScale (1.0F, 1.0F) @@ -1437,12 +1437,12 @@ RingMeshClass::RingMeshClass(void): Radius(0.0f), Slices(0), Vertex_ct(0), // 1 vertex minimum, for center -vtx(NULL), -orig_vtx(NULL), -vtx_normal(NULL), -vtx_uv(NULL), +vtx(nullptr), +orig_vtx(nullptr), +vtx_normal(nullptr), +vtx_uv(nullptr), face_ct(0), -tri_poly(NULL), +tri_poly(nullptr), TileCount (5), InnerScale (1.0F, 1.0F), OuterScale (1.0F, 1.0F) @@ -1635,11 +1635,11 @@ void RingMeshClass::Free(void) delete vtx_uv; delete tri_poly; - vtx = NULL; - orig_vtx = NULL; - vtx_normal = NULL; - vtx_uv = NULL; - tri_poly = NULL; + vtx = nullptr; + orig_vtx = nullptr; + vtx_normal = nullptr; + vtx_uv = nullptr; + tri_poly = nullptr; } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/ringobj.h b/Core/Libraries/Source/WWVegas/WW3D2/ringobj.h index b4ab20f4944..fafdffe9e0f 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/ringobj.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/ringobj.h @@ -87,7 +87,7 @@ struct W3dRingStruct // variable set of keyframes for each channel }; -// Note: RING_NUM_LOD does not include the NULL LOD. +// Note: RING_NUM_LOD does not include the null LOD. #define RING_NUM_LOD (20) #define RING_LOWEST_LOD (10) #define RING_HIGHEST_LOD (50) @@ -140,10 +140,10 @@ class RingRenderObjClass : public RenderObjClass virtual void Scale(float scale); virtual void Scale(float scalex, float scaley, float scalez); - virtual void Set_Hidden(int onoff) { RenderObjClass::Set_Hidden (onoff); Update_On_Visibilty (); } - virtual void Set_Visible(int onoff) { RenderObjClass::Set_Visible (onoff); Update_On_Visibilty (); } - virtual void Set_Animation_Hidden(int onoff) { RenderObjClass::Set_Animation_Hidden (onoff); Update_On_Visibilty (); } - virtual void Set_Force_Visible(int onoff) { RenderObjClass::Set_Force_Visible (onoff); Update_On_Visibilty (); } + virtual void Set_Hidden(int onoff) { RenderObjClass::Set_Hidden (onoff); Update_On_Visibility (); } + virtual void Set_Visible(int onoff) { RenderObjClass::Set_Visible (onoff); Update_On_Visibility (); } + virtual void Set_Animation_Hidden(int onoff) { RenderObjClass::Set_Animation_Hidden (onoff); Update_On_Visibility (); } + virtual void Set_Force_Visible(int onoff) { RenderObjClass::Set_Force_Visible (onoff); Update_On_Visibility (); } const AABoxClass & Get_Box(void); @@ -220,7 +220,7 @@ class RingRenderObjClass : public RenderObjClass protected: virtual void update_cached_box(void); - void Update_On_Visibilty(void); + void Update_On_Visibility(void); // Initialization stuff void Init_Material (void); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/segline.cpp b/Core/Libraries/Source/WWVegas/WW3D2/segline.cpp index 9e7070837e9..9c951f65937 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/segline.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/segline.cpp @@ -576,7 +576,7 @@ bool SegmentedLineClass::Cast_Ray(RayCollisionTestClass & raytest) Vector3 p0; Vector3 p1; - if (raytest.Ray.Find_Intersection (line_seg, &p0, &fraction, &p1, NULL)) { + if (raytest.Ray.Find_Intersection (line_seg, &p0, &fraction, &p1, nullptr)) { // // Determine if the ray was close enough to this line to be diff --git a/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp index afeaffbe649..00c65a63ae3 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/seglinerenderer.cpp @@ -69,7 +69,7 @@ SegLineRendererClass::SegLineRendererClass(void) : - Texture(NULL), + Texture(nullptr), Shader(ShaderClass::_PresetAdditiveSpriteShader), Width(0.0f), Color(Vector3(1,1,1)), @@ -84,13 +84,13 @@ SegLineRendererClass::SegLineRendererClass(void) : UVOffsetDeltaPerMS(0.0f, 0.0f), Bits(DEFAULT_BITS), m_vertexBufferSize(0), - m_vertexBuffer(NULL) + m_vertexBuffer(nullptr) { // EMPTY } SegLineRendererClass::SegLineRendererClass(const SegLineRendererClass & that) : - Texture(NULL), + Texture(nullptr), Shader(ShaderClass::_PresetAdditiveSpriteShader), Width(0.0f), Color(Vector3(1,1,1)), @@ -105,7 +105,7 @@ SegLineRendererClass::SegLineRendererClass(const SegLineRendererClass & that) : UVOffsetDeltaPerMS(0.0f, 0.0f), Bits(DEFAULT_BITS), m_vertexBufferSize(0), - m_vertexBuffer(NULL) + m_vertexBuffer(nullptr) { *this = that; } @@ -176,7 +176,7 @@ void SegLineRendererClass::Set_Texture(TextureClass *texture) TextureClass * SegLineRendererClass::Get_Texture(void) const { - if (Texture != NULL) { + if (Texture != nullptr) { Texture->Add_Ref(); } return Texture; @@ -354,7 +354,7 @@ void SegLineRendererClass::Render Vector4 subdiv_rgbas[MAX_SEGLINE_POINT_BUFFER_SIZE]; unsigned int sub_point_cnt; - Vector4 *rgbasPointer = rgbas ? &rgbas[ chidx ] : NULL; + Vector4 *rgbasPointer = rgbas ? &rgbas[ chidx ] : nullptr; subdivision_util(point_cnt, xformed_pts, base_tex_v, &sub_point_cnt, xformed_subdiv_pts, subdiv_tex_v, rgbasPointer, subdiv_rgbas); @@ -1137,7 +1137,7 @@ void SegLineRendererClass::Render mat=VertexMaterialClass::Get_Preset(VertexMaterialClass::PRELIT_NODIFFUSE); } - // If Texture is non-NULL enable texturing in shader - otherwise disable. + // If Texture is non-null enable texturing in shader - otherwise disable. if (Texture) { shader.Set_Texturing(ShaderClass::TEXTURING_ENABLE); } else { diff --git a/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp b/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp index 6a42f6586a2..c0ebbcd78eb 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/shattersystem.cpp @@ -174,7 +174,7 @@ class PolygonClass ** plane. The plane is defined by the x-y plane of the coordinate system ** (i.e. z-axis is the normal of the plane, origin is a point on the plane). ** Leaf nodes of this tree will have two indices. These are indices into -** the MeshFragments array where they put the polygons in thier front and +** the MeshFragments array where they put the polygons in their front and ** back half-spaces. */ class BSPClass @@ -687,8 +687,8 @@ bool PolygonClass::Salvage_Degenerate(void) BSPClass::BSPClass(HTreeClass * tree,int bone_index,int & leaf_index) : Plane(0,0,1,0), - Front(NULL), - Back(NULL), + Front(nullptr), + Back(nullptr), FrontLeafIndex(-1), BackLeafIndex(-1) { @@ -730,7 +730,7 @@ BSPClass::~BSPClass(void) { delete Front; delete Back; - Front = Back = NULL; + Front = Back = nullptr; } void BSPClass::Set_Plane_From_Transform(const Matrix3D & tm) @@ -759,7 +759,7 @@ void BSPClass::Clip_Polygon(const PolygonClass & polygon) // Process the front halfspace: Recurse if we have a child clipping plane, // otherwise add our polygons to our assigned clipping pool - if (Front == NULL) { + if (Front == nullptr) { // We're a leaf node so put the polygons into the mesh fragment arrays if (front_poly.Get_Vertex_Count() >= 3) { ClipPools[FrontLeafIndex].Add(front_poly); @@ -772,7 +772,7 @@ void BSPClass::Clip_Polygon(const PolygonClass & polygon) } // Process the back halfspace: - if (Back==NULL) { + if (Back==nullptr) { if (back_poly.Get_Vertex_Count() >= 3) { ClipPools[BackLeafIndex].Add(back_poly); } @@ -809,17 +809,17 @@ void ShatterSystem::Init(void) StringClass htree_name; htree_name.Format(SHATTER_PATTERN_FORMAT,0); - if (WW3DAssetManager::Get_Instance()==NULL) + if (WW3DAssetManager::Get_Instance()==nullptr) return; // WorldBuilderTool doesn't initialize the asset manager. jba. #if 1 - HTreeClass *htree = NULL; + HTreeClass *htree = nullptr; #else HTreeClass * htree = WW3DAssetManager::Get_Instance()->Get_HTree(htree_name); #endif - while (htree != NULL) { + while (htree != nullptr) { if ((htree->Num_Pivots() > 1) && (htree->Num_Pivots() < MAX_MESH_FRAGMENTS)) { int leaf_counter = 0; - htree->Base_Update(Matrix3D(1)); + htree->Base_Update(Matrix3D(true)); ShatterPatterns.Add(W3DNEW BSPClass(htree,1,leaf_counter)); } @@ -995,24 +995,24 @@ void ShatterSystem::Shatter_Mesh(MeshClass * mesh,const Vector3 & point,const Ve SHATTER_DEBUG_SAY(("normal: %f %f %f",src_vnorms[vert_index].X,src_vnorms[vert_index].Y,src_vnorms[vert_index].Z)); for (ipass=0; ipassAdd_Ref(); } return MeshFragments[fragment_index]; @@ -1092,7 +1092,7 @@ void ShatterSystem::Process_Clip_Pools ** Grab the model */ MeshModelClass * model = mesh->Get_Model(); - WWASSERT(model != NULL); + WWASSERT(model != nullptr); /* ** Loop over all ClipPools and build a mesh for any that contain polygons @@ -1132,11 +1132,11 @@ void ShatterSystem::Process_Clip_Pools bool has_textures = false; for (ipass=0; ipassGet_Pass_Count(); ipass++) { - if (model->Peek_Single_Material(ipass) != NULL) { + if (model->Peek_Single_Material(ipass) != nullptr) { matinfo->Add_Vertex_Material(model->Peek_Single_Material(ipass)); } for (int istage=0; istagePeek_Single_Texture(ipass,istage) != NULL) { + if (model->Peek_Single_Texture(ipass,istage) != nullptr) { matinfo->Add_Texture(model->Peek_Single_Texture(ipass,istage)); has_textures = true; } @@ -1150,7 +1150,7 @@ void ShatterSystem::Process_Clip_Pools for (istage=0; istagePeek_Single_Texture(ipass,istage); - if (tex != NULL) { + if (tex != nullptr) { new_mesh->Peek_Model()->Set_Single_Texture(tex,ipass,istage); } } @@ -1180,7 +1180,7 @@ void ShatterSystem::Process_Clip_Pools SHATTER_DEBUG_SAY(("Begin Vertex:")); new_mesh->Begin_Vertex(); - SHATTER_DEBUG_SAY(("postion: %f %f %f",pos.X,pos.Y,pos.Z)); + SHATTER_DEBUG_SAY(("position: %f %f %f",pos.X,pos.Y,pos.Z)); new_mesh->Location_Inline(pos); new_mesh->Normal(norm); @@ -1192,7 +1192,7 @@ void ShatterSystem::Process_Clip_Pools ** If there were vertex colors for this pass in the original mesh, then ** copy the color out of the vertex into the new mesh. */ - if (mtl_params.DCG[ipass] != NULL) { + if (mtl_params.DCG[ipass] != nullptr) { SHATTER_DEBUG_SAY(("DCG: pass:%d: %f %f %f",ipass,vert.DCG[ipass].X,vert.DCG[ipass].Y,vert.DCG[ipass].Z)); /* OLD CODE new_mesh->DCG(Vector3(vert.DCG[ipass].X,vert.DCG[ipass].Y,vert.DCG[ipass].Z),ipass); @@ -1202,7 +1202,7 @@ void ShatterSystem::Process_Clip_Pools } // HY- Multiplying DIG with DCG as in meshmdlio - if (mtl_params.DIG[ipass] != NULL) { + if (mtl_params.DIG[ipass] != nullptr) { SHATTER_DEBUG_SAY(("DIG: pass:%d: %f %f %f",ipass,vert.DIG[ipass].X,vert.DIG[ipass].Y,vert.DIG[ipass].Z)); Vector4 mc=DX8Wrapper::Convert_Color(mycolor); Vector4 dc=DX8Wrapper::Convert_Color(vert.DIG[ipass]); @@ -1218,7 +1218,7 @@ void ShatterSystem::Process_Clip_Pools */ // #pragma MESSAGE("HY- Naty, will dynamesh support multiple stages of UV?") for (istage=0; istageUV(vert.TexCoord[ipass][istage],istage); } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp index 4bd67a6eda9..36434e71286 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.cpp @@ -60,7 +60,7 @@ SoundRenderObjLoaderClass _SoundRenderObjLoader; ////////////////////////////////////////////////////////////////////////////////// SoundRenderObjClass::SoundRenderObjClass (void) : Flags (FLAG_STOP_WHEN_HIDDEN), - Sound (NULL), + Sound (nullptr), IsInitialized (false) { return ; @@ -74,7 +74,7 @@ SoundRenderObjClass::SoundRenderObjClass (void) ////////////////////////////////////////////////////////////////////////////////// SoundRenderObjClass::SoundRenderObjClass (const SoundRenderObjClass &src) : Flags (FLAG_STOP_WHEN_HIDDEN), - Sound (NULL), + Sound (nullptr), IsInitialized (false) { (*this) = src; @@ -92,8 +92,8 @@ SoundRenderObjClass::~SoundRenderObjClass (void) // // Remove the old sound from the world (if necessary) // - if (Sound != NULL) { - Sound->Attach_To_Object (NULL); + if (Sound != nullptr) { + Sound->Attach_To_Object (nullptr); Sound->Remove_From_Scene (); REF_PTR_RELEASE (Sound); } @@ -140,7 +140,7 @@ SoundRenderObjClass::Set_Sound (AudibleSoundDefinitionClass *definition) // // Remove the old sound from the world (if necessary) // - if (Sound != NULL) { + if (Sound != nullptr) { Sound->Remove_From_Scene (); REF_PTR_RELEASE (Sound); } @@ -148,7 +148,7 @@ SoundRenderObjClass::Set_Sound (AudibleSoundDefinitionClass *definition) // // Create the sound object from its definition // - if (definition != NULL) { + if (definition != nullptr) { Sound = (AudibleSoundClass *)definition->Create (); } @@ -167,11 +167,11 @@ SoundRenderObjClass::On_Frame_Update (void) // // Stop the sound from playing (if necessary) // - if ( Sound != NULL && + if ( Sound != nullptr && Sound->Is_In_Scene () && Sound->Is_Playing () == false) { - Sound->Attach_To_Object (NULL); + Sound->Attach_To_Object (nullptr); Sound->Remove_From_Scene (); } @@ -195,7 +195,7 @@ SoundRenderObjClass::Set_Hidden (int onoff) // if (IsInitialized == false || Is_Not_Hidden_At_All () != before) { IsInitialized = true; - Update_On_Visibilty (); + Update_On_Visibility (); } return ; @@ -218,7 +218,7 @@ SoundRenderObjClass::Set_Visible (int onoff) // if (IsInitialized == false || Is_Not_Hidden_At_All () != before) { IsInitialized = true; - Update_On_Visibilty (); + Update_On_Visibility (); } return ; @@ -241,7 +241,7 @@ SoundRenderObjClass::Set_Animation_Hidden (int onoff) // if (IsInitialized == false || Is_Not_Hidden_At_All () != before) { IsInitialized = true; - Update_On_Visibilty (); + Update_On_Visibility (); } return ; @@ -264,7 +264,7 @@ SoundRenderObjClass::Set_Force_Visible (int onoff) // if (IsInitialized == false || Is_Not_Hidden_At_All () != before) { IsInitialized = true; - Update_On_Visibilty (); + Update_On_Visibility (); } return ; @@ -273,13 +273,13 @@ SoundRenderObjClass::Set_Force_Visible (int onoff) ////////////////////////////////////////////////////////////////////////////////// // -// Update_On_Visibilty +// Update_On_Visibility // ////////////////////////////////////////////////////////////////////////////////// void -SoundRenderObjClass::Update_On_Visibilty (void) +SoundRenderObjClass::Update_On_Visibility (void) { - if (Sound == NULL) { + if (Sound == nullptr) { return ; } @@ -295,7 +295,7 @@ SoundRenderObjClass::Update_On_Visibilty (void) // if ( Is_Not_Hidden_At_All () && Sound->Is_In_Scene () == false && - Peek_Scene () != NULL) + Peek_Scene () != nullptr) { // // Make sure the sound is properly attached to this render @@ -304,13 +304,13 @@ SoundRenderObjClass::Update_On_Visibilty (void) Sound->Attach_To_Object (this); Sound->Add_To_Scene (true); - } else if ((Is_Not_Hidden_At_All () == false) || (Peek_Scene () == NULL)) { + } else if ((Is_Not_Hidden_At_All () == false) || (Peek_Scene () == nullptr)) { // // Remove the sound from the scene (it will stop playing) // - if ((Flags & FLAG_STOP_WHEN_HIDDEN) != 0 || (Peek_Scene () == NULL)) { - Sound->Attach_To_Object (NULL); + if ((Flags & FLAG_STOP_WHEN_HIDDEN) != 0 || (Peek_Scene () == nullptr)) { + Sound->Attach_To_Object (nullptr); Sound->Remove_From_Scene (); } } @@ -327,7 +327,7 @@ SoundRenderObjClass::Update_On_Visibilty (void) AudibleSoundClass * SoundRenderObjClass::Get_Sound (void) const { - if (Sound != NULL) { + if (Sound != nullptr) { Sound->Add_Ref (); } @@ -363,7 +363,7 @@ SoundRenderObjClass::Notify_Added (SceneClass *scene) RenderObjClass::Notify_Added (scene); scene->Register (this, SceneClass::ON_FRAME_UPDATE); - Update_On_Visibilty (); + Update_On_Visibility (); return ; } @@ -379,7 +379,7 @@ SoundRenderObjClass::Notify_Removed (SceneClass *scene) scene->Unregister (this, SceneClass::ON_FRAME_UPDATE); RenderObjClass::Notify_Removed (scene); - Update_On_Visibilty (); + Update_On_Visibility (); return ; } @@ -396,7 +396,7 @@ SoundRenderObjClass::Set_Transform (const Matrix3D &tm) if (IsInitialized == false) { IsInitialized = true; - Update_On_Visibilty (); + Update_On_Visibility (); } return ; @@ -415,7 +415,7 @@ SoundRenderObjClass::Set_Position (const Vector3 &pos) if (IsInitialized == false) { IsInitialized = true; - Update_On_Visibilty (); + Update_On_Visibility (); } return ; @@ -742,13 +742,13 @@ SoundRenderObjDefClass::Write_Definition (ChunkSaveClass &csave) PrototypeClass * SoundRenderObjLoaderClass::Load_W3D (ChunkLoadClass &cload) { - SoundRenderObjPrototypeClass *prototype = NULL; + SoundRenderObjPrototypeClass *prototype = nullptr; // // Create a definition object // SoundRenderObjDefClass *definition = W3DNEW SoundRenderObjDefClass; - if (definition != NULL) { + if (definition != nullptr) { // // Ask the definition object to load the sound data diff --git a/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h index c5ce0b6815a..3624a6172c5 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/soundrobj.h @@ -136,7 +136,7 @@ class SoundRenderObjClass : public RenderObjClass /////////////////////////////////////////////////////////// // Protected methods /////////////////////////////////////////////////////////// - virtual void Update_On_Visibilty (void); + virtual void Update_On_Visibility (void); private: @@ -231,7 +231,7 @@ class SoundRenderObjPrototypeClass : public W3DMPO, public PrototypeClass // Public constructors/destructors /////////////////////////////////////////////////////////// SoundRenderObjPrototypeClass (SoundRenderObjDefClass *def) - : Definition (NULL) { Set_Definition (def); } + : Definition (nullptr) { Set_Definition (def); } /////////////////////////////////////////////////////////// // Public methods diff --git a/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp b/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp index 3b24f5e09d4..72e8e9eed1e 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.cpp @@ -119,8 +119,8 @@ SphereRenderObjClass::SphereRenderObjClass(void) LODBias(1.0f), CurrentLOD(SPHERE_NUM_LOD), // SPHERE_NUM_LOD does not include the null LOD AnimDuration (0.0F), - SphereMaterial (NULL), - SphereTexture (NULL), + SphereMaterial (nullptr), + SphereTexture (nullptr), CurrentColor(0.75f, 0.75f, 0.75F), CurrentAlpha(1.0f), CurrentScale(1.0f, 1.0f, 1.0f), @@ -161,8 +161,8 @@ SphereRenderObjClass::SphereRenderObjClass(const W3dSphereStruct & def) LODBias(1.0f), CurrentLOD(SPHERE_NUM_LOD), // SPHERE_NUM_LOD does not include the null LOD AnimDuration (0.0F), - SphereMaterial (NULL), - SphereTexture (NULL), + SphereMaterial (nullptr), + SphereTexture (nullptr), CurrentColor(0.75f, 0.75f, 0.75F), CurrentAlpha(1.0f), CurrentScale(1.0f, 1.0f, 1.0f), @@ -211,8 +211,8 @@ SphereRenderObjClass::SphereRenderObjClass(const SphereRenderObjClass & src) LODBias(1.0f), CurrentLOD(SPHERE_NUM_LOD), // SPHERE_NUM_LOD does not include the null LOD AnimDuration (0.0F), - SphereMaterial (NULL), - SphereTexture (NULL), + SphereMaterial (nullptr), + SphereTexture (nullptr), CurrentColor(0.75f, 0.75f, 0.75F), CurrentAlpha(1.0f), CurrentScale(1.0f, 1.0f, 1.0f), @@ -300,7 +300,7 @@ void SphereRenderObjClass::Generate_Shared_Mesh_Arrays (const AlphaVectorStruct float step = (SPHERE_HIGHEST_LOD - SPHERE_LOWEST_LOD); step /= SPHERE_NUM_LOD; - // For NULL LOD set Cost to a small nonzero amount to avoid divisions by zero. + // For null LOD set Cost to a small nonzero amount to avoid divisions by zero. SphereLODCosts[0] = 0.000001f; for(int i=0; i < SPHERE_NUM_LOD; i++) { @@ -436,7 +436,7 @@ const char * SphereRenderObjClass::Get_Name(void) const *=============================================================================================*/ void SphereRenderObjClass::Set_Name(const char * name) { - WWASSERT(name != NULL); + WWASSERT(name != nullptr); const size_t nameLen = strlcpy(Name, name, ARRAY_SIZE(Name)); (void)nameLen; WWASSERT(nameLen < ARRAY_SIZE(Name)); } @@ -457,7 +457,7 @@ void SphereRenderObjClass::Set_Name(const char * name) *=============================================================================================*/ void SphereRenderObjClass::render_sphere() { - // Should never get here with NULL LOD + // Should never get here with null LOD if (CurrentLOD == 0) { WWASSERT(0); return; @@ -600,7 +600,7 @@ int SphereRenderObjClass::Class_ID(void) const *=============================================================================================*/ void SphereRenderObjClass::Render(RenderInfoClass & rinfo) { - // NULL LOD + // null LOD if (CurrentLOD == 0) return; if (Is_Not_Hidden_At_All() == false) { @@ -702,7 +702,7 @@ void SphereRenderObjClass::Special_Render(SpecialRenderInfoClass & rinfo) temp.Translate(Transform.Get_Translation()); if (rinfo.RenderType == SpecialRenderInfoClass::RENDER_VIS) { - WWASSERT(rinfo.VisRasterizer != NULL); + WWASSERT(rinfo.VisRasterizer != nullptr); rinfo.VisRasterizer->Set_Model_Transform(temp); vis_render_sphere(rinfo,ObjSpaceCenter,ObjSpaceExtent); } @@ -1058,7 +1058,7 @@ AlphaVectorStruct SphereRenderObjClass::Get_Default_Vector(void) const /*********************************************************************************************** - * SphereRenderObjClass::Update_On_Visibilty -- Either starts or stops the animation based on visibility* + * SphereRenderObjClass::Update_On_Visibility -- Either starts or stops the animation based on visibility* * * * INPUT: * * * @@ -1069,7 +1069,7 @@ AlphaVectorStruct SphereRenderObjClass::Get_Default_Vector(void) const * HISTORY: * * 4/04/00 pds : Created. * *=============================================================================================*/ -void SphereRenderObjClass::Update_On_Visibilty(void) +void SphereRenderObjClass::Update_On_Visibility(void) { // Simply start or stop the animation based on // the visibility state of the primitive. @@ -1181,10 +1181,10 @@ SpherePrototypeClass::SpherePrototypeClass(SphereRenderObjClass *sphere) // // Determine the texture name for this sphere // - if (sphere->SphereTexture != NULL) { + if (sphere->SphereTexture != nullptr) { StringClass name = sphere->SphereTexture->Get_Full_Path(); const char *filename = ::strrchr (name, '\\'); - if (filename != NULL) { + if (filename != nullptr) { filename ++; } else { filename = name; @@ -1360,17 +1360,17 @@ Radius(radius), Slices(slices), Stacks(stacks), Vertex_ct(0), -vtx(NULL), -vtx_normal(NULL), -vtx_uv(NULL), +vtx(nullptr), +vtx_normal(nullptr), +vtx_uv(nullptr), strip_ct(0), strip_size(0), -strips(NULL), +strips(nullptr), fan_ct(0), fan_size(0), -fans(NULL), +fans(nullptr), face_ct(0), -tri_poly(NULL), +tri_poly(nullptr), inverse_alpha(false) { // compute # of vertices @@ -1397,17 +1397,17 @@ Radius(0.0f), Slices(0), Stacks(0), Vertex_ct(0), -vtx(NULL), -vtx_normal(NULL), -vtx_uv(NULL), +vtx(nullptr), +vtx_normal(nullptr), +vtx_uv(nullptr), strip_ct(0), strip_size(0), -strips(NULL), +strips(nullptr), fan_ct(0), fan_size(0), -fans(NULL), +fans(nullptr), face_ct(0), -tri_poly(NULL), +tri_poly(nullptr), inverse_alpha(false) { @@ -1736,13 +1736,13 @@ void SphereMeshClass::Free(void) delete [] fans; delete [] tri_poly; - vtx = NULL; - vtx_normal = NULL; - vtx_uv = NULL; - dcg = NULL; - strips = NULL; - fans = NULL; - tri_poly = NULL; + vtx = nullptr; + vtx_normal = nullptr; + vtx_uv = nullptr; + dcg = nullptr; + strips = nullptr; + fans = nullptr; + tri_poly = nullptr; } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.h b/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.h index 5b854cf4fb0..b681b91ed12 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/sphereobj.h @@ -212,7 +212,7 @@ SphereMeshClass::Set_DCG (bool is_additive, int index, float value) return ; } -// Note: SPHERE_NUM_LOD does not include the NULL LOD. +// Note: SPHERE_NUM_LOD does not include the null LOD. #define SPHERE_NUM_LOD (10) #define SPHERE_LOWEST_LOD (7) #define SPHERE_HIGHEST_LOD (17) @@ -266,10 +266,10 @@ class SphereRenderObjClass : public RenderObjClass virtual void Scale(float scale); virtual void Scale(float scalex, float scaley, float scalez); - virtual void Set_Hidden(int onoff) { RenderObjClass::Set_Hidden (onoff); Update_On_Visibilty (); } - virtual void Set_Visible(int onoff) { RenderObjClass::Set_Visible (onoff); Update_On_Visibilty (); } - virtual void Set_Animation_Hidden(int onoff) { RenderObjClass::Set_Animation_Hidden (onoff); Update_On_Visibilty (); } - virtual void Set_Force_Visible(int onoff) { RenderObjClass::Set_Force_Visible (onoff); Update_On_Visibilty (); } + virtual void Set_Hidden(int onoff) { RenderObjClass::Set_Hidden (onoff); Update_On_Visibility (); } + virtual void Set_Visible(int onoff) { RenderObjClass::Set_Visible (onoff); Update_On_Visibility (); } + virtual void Set_Animation_Hidden(int onoff) { RenderObjClass::Set_Animation_Hidden (onoff); Update_On_Visibility (); } + virtual void Set_Force_Visible(int onoff) { RenderObjClass::Set_Force_Visible (onoff); Update_On_Visibility (); } const AABoxClass & Get_Box(void); @@ -341,7 +341,7 @@ class SphereRenderObjClass : public RenderObjClass virtual void update_cached_box(void); virtual void Update_Cached_Bounding_Volumes(void) const; - void Update_On_Visibilty(void); + void Update_On_Visibility(void); // Initialization stuff void Init_Material (void); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/statistics.cpp b/Core/Libraries/Source/WWVegas/WW3D2/statistics.cpp index 09b0ce0fe03..e703c89e67b 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/statistics.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/statistics.cpp @@ -75,7 +75,7 @@ static void Record_Texture_Begin() procedural_texture_count=0; record_count=0; texture_change_count=0; - latest_texture=NULL; + latest_texture=nullptr; texture_statistics.Resize(0); } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/streak.cpp b/Core/Libraries/Source/WWVegas/WW3D2/streak.cpp index 2c045a083e2..3eb75ae29f7 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/streak.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/streak.cpp @@ -59,7 +59,7 @@ StreakLineClass::StreakLineClass(void) : MaxSubdivisionLevels(0), NormalizedScreenArea(0.0f) { - Personalities = NULL; + Personalities = nullptr; } @@ -715,7 +715,7 @@ bool StreakLineClass::Cast_Ray(RayCollisionTestClass & raytest) Vector3 p0; Vector3 p1; - if (raytest.Ray.Find_Intersection (line_seg, &p0, &fraction, &p1, NULL)) { + if (raytest.Ray.Find_Intersection (line_seg, &p0, &fraction, &p1, nullptr)) { // // Determine if the ray was close enough to this line to be diff --git a/Core/Libraries/Source/WWVegas/WW3D2/streak.h b/Core/Libraries/Source/WWVegas/WW3D2/streak.h index f0eb918425e..e6c4d2516ba 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/streak.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/streak.h @@ -163,9 +163,9 @@ class StreakLineClass : public RenderObjClass void Set_LocsWidthsColors( unsigned int num_points, Vector3 *locs, - float *widths = NULL, - Vector4 *colors = NULL, - unsigned int *personalities = NULL); + float *widths = nullptr, + Vector4 *colors = nullptr, + unsigned int *personalities = nullptr); protected: diff --git a/Core/Libraries/Source/WWVegas/WW3D2/streakRender.cpp b/Core/Libraries/Source/WWVegas/WW3D2/streakRender.cpp index 2fe4daf94bb..ed7eae37c18 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/streakRender.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/streakRender.cpp @@ -55,7 +55,7 @@ StreakRendererClass::StreakRendererClass(void) : - Texture(NULL), + Texture(nullptr), Shader(ShaderClass::_PresetAdditiveSpriteShader), Width(0.0f), Color(Vector3(1,1,1)), @@ -69,13 +69,13 @@ StreakRendererClass::StreakRendererClass(void) : // UVOffsetDeltaPerMS(0.0f, 0.0f), Bits(DEFAULT_BITS), m_vertexBufferSize(0), - m_vertexBuffer(NULL) + m_vertexBuffer(nullptr) { // EMPTY } StreakRendererClass::StreakRendererClass(const StreakRendererClass & that) : - Texture(NULL), + Texture(nullptr), Shader(ShaderClass::_PresetAdditiveSpriteShader), Width(0.0f), Color(Vector3(1,1,1)), @@ -89,7 +89,7 @@ StreakRendererClass::StreakRendererClass(const StreakRendererClass & that) : // UVOffsetDeltaPerMS(0.0f, 0.0f), Bits(DEFAULT_BITS), m_vertexBufferSize(0), - m_vertexBuffer(NULL) + m_vertexBuffer(nullptr) { *this = that; } @@ -159,7 +159,7 @@ void StreakRendererClass::Set_Texture(TextureClass *texture) TextureClass * StreakRendererClass::Get_Texture(void) const { - if (Texture != NULL) { + if (Texture != nullptr) { Texture->Add_Ref(); } return Texture; @@ -1307,7 +1307,7 @@ void StreakRendererClass::RenderStreak DX8Wrapper::Set_Material(mat); REF_PTR_RELEASE(mat); - // If Texture is non-NULL enable texturing in shader - otherwise disable. + // If Texture is non-null enable texturing in shader - otherwise disable. if (Texture) { shader.Set_Texturing(ShaderClass::TEXTURING_ENABLE); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp index fdec676476a..26536668494 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/stripoptimizer.cpp @@ -174,7 +174,7 @@ void StripOptimizerClass::Optimize_Strip_Order (int* strips, int strip_count) const int* prev = ss[0]; // previous strip o = Copy_Strip (o, ss[0]); // output first strip - ss[0] = 0; + ss[0] = nullptr; for (;;) { @@ -197,7 +197,7 @@ void StripOptimizerClass::Optimize_Strip_Order (int* strips, int strip_count) o = Copy_Strip(o, ss[bestIndex]); // copy the strip prev = ss[bestIndex]; // set to prev - ss[bestIndex] = NULL; // mark as selected + ss[bestIndex] = nullptr; // mark as selected } // WWASSERT((out+outSize)==o); // HUH? @@ -258,7 +258,7 @@ void StripOptimizerClass::Optimize_Triangle_Order (int *tris, int triangle_count Tri* prev = t[0]; *o++ = *prev; - t[0] = NULL; + t[0] = nullptr; for (;;) { @@ -284,7 +284,7 @@ void StripOptimizerClass::Optimize_Triangle_Order (int *tris, int triangle_count *o++ = *t[bestIndex]; prev = t[bestIndex]; - t[bestIndex] = NULL; + t[bestIndex] = nullptr; } @@ -407,14 +407,14 @@ struct Triangle { Triangle (void) { - m_neighbors[0] = 0; - m_neighbors[1] = 0; - m_neighbors[2] = 0; + m_neighbors[0] = nullptr; + m_neighbors[1] = nullptr; + m_neighbors[2] = nullptr; m_vertices[0] = 0; m_vertices[1] = 0; m_vertices[2] = 0; - m_prev = 0; - m_next = 0; + m_prev = nullptr; + m_next = nullptr; m_bin = -1; } @@ -497,7 +497,7 @@ namespace Strip * * Description: Returns pointer to triangle with smallest connectivity * - * Returns: pointer to triangle with smallest connectivity or NULL + * Returns: pointer to triangle with smallest connectivity or nullptr * if the queue is empty * *****************************************************************************/ @@ -507,7 +507,7 @@ inline Triangle* TriangleQueue::getTop (void) const for (int i = 0; i < 4; i++) if (m_bin[i]) return m_bin[i]; // return head - return 0; // end + return nullptr; // end } /***************************************************************************** @@ -548,7 +548,7 @@ inline TriangleQueue::~TriangleQueue () * Description: Internal function for recalculating a triangle's * connectivity * - * Parameters: t = pointer to triangle (non-NULL) + * Parameters: t = pointer to triangle (non-null) * *****************************************************************************/ @@ -570,7 +570,7 @@ inline void TriangleQueue::reinsert (Triangle* t) if (t->m_next) t->m_next->m_prev = t->m_prev; - t->m_prev = 0; + t->m_prev = nullptr; t->m_next = m_bin[w]; if (t->m_next) t->m_next->m_prev = t; @@ -585,7 +585,7 @@ inline void TriangleQueue::reinsert (Triangle* t) * * Description: Removes a triangle from the queue * - * Parameters: t = pointer to triangle (non-NULL) + * Parameters: t = pointer to triangle (non-null) * *****************************************************************************/ @@ -612,7 +612,7 @@ inline void TriangleQueue::removeTriangle (Triangle* t) for (i = 0; i < 3; i++) { - update[i] = 0; + update[i] = nullptr; if (t->m_neighbors[i]) { Triangle* n = t->m_neighbors[i]; @@ -621,8 +621,8 @@ inline void TriangleQueue::removeTriangle (Triangle* t) if (n->m_neighbors[k]==t) break; WWASSERT (k!=3); // WASS?? - n->m_neighbors[k] = 0; // reduce connection - t->m_neighbors[i] = 0; + n->m_neighbors[k] = nullptr; // reduce connection + t->m_neighbors[i] = nullptr; update[i] = n; } } @@ -656,7 +656,7 @@ inline TriangleQueue::TriangleQueue (Triangle* tris, int N) { int i; for (i = 0; i < 4; i++) - m_bin[i] = 0; // initialize to zero + m_bin[i] = nullptr; // initialize to zero int largestIndex = 0; @@ -680,7 +680,7 @@ inline TriangleQueue::TriangleQueue (Triangle* tris, int N) int w = t->getConnectivity(); WWASSERT(w>=0 && w <=3); WWASSERT(!t->m_prev && !t->m_next && t->m_bin==-1); // must not be in a bin - t->m_prev = 0; + t->m_prev = nullptr; t->m_next = m_bin[w]; if (t->m_next) t->m_next->m_prev = t; @@ -833,7 +833,7 @@ Triangle* Stripify::generateTriangleList (const Vector3i* inTris, int N) int* Stripify::stripify (const Vector3i* inTris, int N) { if (!inTris || N<=0) // boo! - return 0; + return nullptr; //-------------------------------------------------------------------- // Initial setup @@ -893,7 +893,7 @@ int* Stripify::stripify (const Vector3i* inTris, int N) for (;;) { - Triangle* next = 0; // find next triangle + Triangle* next = nullptr; // find next triangle int i; for (i = 0; i < 3; i++) diff --git a/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.cpp b/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.cpp index ae112b257bb..140c2cd0f65 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.cpp @@ -37,7 +37,6 @@ * SurfaceClass::Clear -- Clears a surface to 0 * * SurfaceClass::Copy -- Copies a region from one surface to another of the same format * * SurfaceClass::FindBBAlpha -- Finds the bounding box of non zero pixels in the region (x0, * - * PixelSize -- Helper Function to find the size in bytes of a pixel * * SurfaceClass::Is_Transparent_Column -- Tests to see if the column is transparent or not * * SurfaceClass::Copy -- Copies from a byte array to the surface * * SurfaceClass::CreateCopy -- Creates a byte array copy of the surface * @@ -56,57 +55,6 @@ #include "bound.h" #include -/*********************************************************************************************** - * PixelSize -- Helper Function to find the size in bytes of a pixel * - * * - * * - * * - * * - * INPUT: * - * * - * OUTPUT: * - * * - * WARNINGS: * - * * - * HISTORY: * - * 2/13/2001 hy : Created. * - *=============================================================================================*/ - -unsigned int PixelSize(const SurfaceClass::SurfaceDescription &sd) -{ - unsigned int size=0; - - switch (sd.Format) - { - case WW3D_FORMAT_A8R8G8B8: - case WW3D_FORMAT_X8R8G8B8: - size=4; - break; - case WW3D_FORMAT_R8G8B8: - size=3; - break; - case WW3D_FORMAT_R5G6B5: - case WW3D_FORMAT_X1R5G5B5: - case WW3D_FORMAT_A1R5G5B5: - case WW3D_FORMAT_A4R4G4B4: - case WW3D_FORMAT_A8R3G3B2: - case WW3D_FORMAT_X4R4G4B4: - case WW3D_FORMAT_A8P8: - case WW3D_FORMAT_A8L8: - size=2; - break; - case WW3D_FORMAT_R3G3B2: - case WW3D_FORMAT_A8: - case WW3D_FORMAT_P8: - case WW3D_FORMAT_L8: - case WW3D_FORMAT_A4L4: - size=1; - break; - } - - return size; -} - void Convert_Pixel(Vector3 &rgb, const SurfaceClass::SurfaceDescription &sd, const unsigned char * pixel) { const float scale=1/255.0f; @@ -213,7 +161,7 @@ void Convert_Pixel(unsigned char * pixel,const SurfaceClass::SurfaceDescription ** SurfaceClass *************************************************************************/ SurfaceClass::SurfaceClass(unsigned width, unsigned height, WW3DFormat format): - D3DSurface(NULL), + D3DSurface(nullptr), SurfaceFormat(format) { WWASSERT(width); @@ -222,7 +170,7 @@ SurfaceClass::SurfaceClass(unsigned width, unsigned height, WW3DFormat format): } SurfaceClass::SurfaceClass(const char *filename): - D3DSurface(NULL) + D3DSurface(nullptr) { D3DSurface = DX8Wrapper::_Create_DX8_Surface(filename); SurfaceDescription desc; @@ -231,7 +179,7 @@ SurfaceClass::SurfaceClass(const char *filename): } SurfaceClass::SurfaceClass(IDirect3DSurface8 *d3d_surface) : - D3DSurface (NULL) + D3DSurface (nullptr) { Attach (d3d_surface); SurfaceDescription desc; @@ -243,7 +191,7 @@ SurfaceClass::~SurfaceClass(void) { if (D3DSurface) { D3DSurface->Release(); - D3DSurface = NULL; + D3DSurface = nullptr; } } @@ -257,13 +205,36 @@ void SurfaceClass::Get_Description(SurfaceDescription &surface_desc) surface_desc.Width = d3d_desc.Width; } -void * SurfaceClass::Lock(int * pitch) +unsigned int SurfaceClass::Get_Bytes_Per_Pixel() +{ + SurfaceDescription surfaceDesc; + Get_Description(surfaceDesc); + return ::Get_Bytes_Per_Pixel(surfaceDesc.Format); +} + +SurfaceClass::LockedSurfacePtr SurfaceClass::Lock(int *pitch) { D3DLOCKED_RECT lock_rect; ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect, 0, 0)); + DX8_ErrorCode(D3DSurface->LockRect(&lock_rect, nullptr, 0)); + *pitch = lock_rect.Pitch; + return static_cast(lock_rect.pBits); +} + +SurfaceClass::LockedSurfacePtr SurfaceClass::Lock(int *pitch, const Vector2i &min, const Vector2i &max) +{ + D3DLOCKED_RECT lock_rect; + ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); + + RECT rect; + rect.left = min.I; + rect.top = min.J; + rect.right = max.I; + rect.bottom = max.J; + DX8_ErrorCode(D3DSurface->LockRect(&lock_rect, &rect, 0)); + *pitch = lock_rect.Pitch; - return (void *)lock_rect.pBits; + return static_cast(lock_rect.pBits); } void SurfaceClass::Unlock(void) @@ -292,11 +263,11 @@ void SurfaceClass::Clear() Get_Description(sd); // size of each pixel in bytes - unsigned int size=PixelSize(sd); + unsigned int size=::Get_Bytes_Per_Pixel(sd.Format); D3DLOCKED_RECT lock_rect; ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,0,0)); + DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,nullptr,0)); unsigned int i; unsigned char *mem=(unsigned char *) lock_rect.pBits; @@ -331,11 +302,11 @@ void SurfaceClass::Copy(const unsigned char *other) Get_Description(sd); // size of each pixel in bytes - unsigned int size=PixelSize(sd); + unsigned int size=::Get_Bytes_Per_Pixel(sd.Format); D3DLOCKED_RECT lock_rect; ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,0,0)); + DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,nullptr,0)); unsigned int i; unsigned char *mem=(unsigned char *) lock_rect.pBits; @@ -364,13 +335,13 @@ void SurfaceClass::Copy(const unsigned char *other) * HISTORY: * * 5/2/2001 hy : Created. * *=============================================================================================*/ -void SurfaceClass::Copy(Vector2i &min,Vector2i &max, const unsigned char *other) +void SurfaceClass::Copy(const Vector2i &min, const Vector2i &max, const unsigned char *other) { SurfaceDescription sd; Get_Description(sd); // size of each pixel in bytes - unsigned int size=PixelSize(sd); + unsigned int size=::Get_Bytes_Per_Pixel(sd.Format); D3DLOCKED_RECT lock_rect; ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); @@ -415,7 +386,7 @@ unsigned char *SurfaceClass::CreateCopy(int *width,int *height,int*size,bool fli Get_Description(sd); // size of each pixel in bytes - unsigned int mysize=PixelSize(sd); + unsigned int mysize=::Get_Bytes_Per_Pixel(sd.Format); *width=sd.Width; *height=sd.Height; @@ -425,7 +396,7 @@ unsigned char *SurfaceClass::CreateCopy(int *width,int *height,int*size,bool fli D3DLOCKED_RECT lock_rect; ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,0,D3DLOCK_READONLY)); + DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,nullptr,D3DLOCK_READONLY)); unsigned int i; unsigned char *mem=(unsigned char *) lock_rect.pBits; @@ -503,7 +474,7 @@ void SurfaceClass::Copy( if (dest.right>int(sd.Width)) dest.right=int(sd.Width); if (dest.bottom>int(sd.Height)) dest.bottom=int(sd.Height); - DX8_ErrorCode(D3DXLoadSurfaceFromSurface(D3DSurface,NULL,&dest,other->D3DSurface,NULL,&src,D3DX_FILTER_NONE,0)); + DX8_ErrorCode(D3DXLoadSurfaceFromSurface(D3DSurface,nullptr,&dest,other->D3DSurface,nullptr,&src,D3DX_FILTER_NONE,0)); } } @@ -545,7 +516,7 @@ void SurfaceClass::Stretch_Copy( dest.top=dsty; dest.bottom=dsty+dstheight; - DX8_ErrorCode(D3DXLoadSurfaceFromSurface(D3DSurface,NULL,&dest,other->D3DSurface,NULL,&src,D3DX_FILTER_TRIANGLE ,0)); + DX8_ErrorCode(D3DXLoadSurfaceFromSurface(D3DSurface,nullptr,&dest,other->D3DSurface,nullptr,&src,D3DX_FILTER_TRIANGLE ,0)); } /*********************************************************************************************** @@ -595,7 +566,7 @@ void SurfaceClass::FindBB(Vector2i *min,Vector2i*max) DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,&rect,D3DLOCK_READONLY)); int x,y; - unsigned int size=PixelSize(sd); + unsigned int size=::Get_Bytes_Per_Pixel(sd.Format); Vector2i realmin=*max; Vector2i realmax=*min; @@ -658,7 +629,7 @@ bool SurfaceClass::Is_Transparent_Column(unsigned int column) break; } - unsigned int size=PixelSize(sd); + unsigned int size=::Get_Bytes_Per_Pixel(sd.Format); D3DLOCKED_RECT lock_rect; ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); @@ -692,7 +663,7 @@ bool SurfaceClass::Is_Transparent_Column(unsigned int column) } /*********************************************************************************************** - * SurfaceClass::Get_Pixel -- Returns the pixel's RGB valus to the caller * + * SurfaceClass::Get_Pixel -- Returns the pixel's RGB valus to the caller * * * * * * * @@ -705,28 +676,16 @@ bool SurfaceClass::Is_Transparent_Column(unsigned int column) * * * HISTORY: * * 2/13/2001 hy : Created. * + * 1/10/2025 TheSuperHackers : Added bits and pitch to argument list for better performance * *=============================================================================================*/ -void SurfaceClass::Get_Pixel(Vector3 &rgb, int x,int y) +void SurfaceClass::Get_Pixel(Vector3 &rgb, int x, int y, LockedSurfacePtr pBits, int pitch) { SurfaceDescription sd; Get_Description(sd); - x = min(x,(int)sd.Width - 1); - y = min(y,(int)sd.Height - 1); - - D3DLOCKED_RECT lock_rect; - ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - RECT rect; - ::ZeroMemory(&rect, sizeof(RECT)); - - rect.bottom=y+1; - rect.top=y; - rect.left=x; - rect.right=x+1; - - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,&rect,D3DLOCK_READONLY)); - Convert_Pixel(rgb,sd,(unsigned char *) lock_rect.pBits); - DX8_ErrorCode(D3DSurface->UnlockRect()); + unsigned int bytesPerPixel = ::Get_Bytes_Per_Pixel(sd.Format); + unsigned char* dst = static_cast(pBits) + y * pitch + x * bytesPerPixel; + Convert_Pixel(rgb,sd,dst); } /*********************************************************************************************** @@ -752,7 +711,7 @@ void SurfaceClass::Attach (IDirect3DSurface8 *surface) // // Lock a reference onto the object // - if (D3DSurface != NULL) { + if (D3DSurface != nullptr) { D3DSurface->AddRef (); } @@ -780,11 +739,11 @@ void SurfaceClass::Detach (void) // // Release the hold we have on the D3D object // - if (D3DSurface != NULL) { + if (D3DSurface != nullptr) { D3DSurface->Release (); } - D3DSurface = NULL; + D3DSurface = nullptr; return ; } @@ -802,44 +761,16 @@ void SurfaceClass::Detach (void) * WARNINGS: * * * * HISTORY: * + * 1/10/2025 TheSuperHackers : Added bits and pitch to argument list for better performance * *=============================================================================================*/ -void SurfaceClass::DrawPixel(const unsigned int x,const unsigned int y, unsigned int color) +void SurfaceClass::Draw_Pixel(const unsigned int x, const unsigned int y, unsigned int color, + unsigned int bytesPerPixel, LockedSurfacePtr pBits, int pitch) { - SurfaceDescription sd; - Get_Description(sd); - - unsigned int size=PixelSize(sd); + unsigned char* dst = static_cast(pBits) + y * pitch + x * bytesPerPixel; + memcpy(dst, &color, bytesPerPixel); +} - D3DLOCKED_RECT lock_rect; - ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - RECT rect; - ::ZeroMemory(&rect, sizeof(RECT)); - rect.bottom=y+1; - rect.top=y; - rect.left=x; - rect.right=x+1; - - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,&rect,0)); - unsigned char *cptr=(unsigned char*)lock_rect.pBits; - unsigned short *sptr=(unsigned short*)lock_rect.pBits; - unsigned int *lptr=(unsigned int*)lock_rect.pBits; - - switch (size) - { - case 1: - *cptr=(unsigned char) (color & 0xFF); - break; - case 2: - *sptr=(unsigned short) (color & 0xFFFF); - break; - case 4: - *lptr=color; - break; - } - - DX8_ErrorCode(D3DSurface->UnlockRect()); -} /*********************************************************************************************** * SurfaceClass::DrawHLine -- draws a horizontal line * @@ -855,49 +786,18 @@ void SurfaceClass::DrawPixel(const unsigned int x,const unsigned int y, unsigned * * * HISTORY: * * 4/9/2001 hy : Created. * - * 4/9/2001 hy : Created. * + * 1/10/2025 TheSuperHackers : Added bits and pitch to argument list for better performance * *=============================================================================================*/ -void SurfaceClass::DrawHLine(const unsigned int y,const unsigned int x1, const unsigned int x2, unsigned int color) +void SurfaceClass::Draw_H_Line(const unsigned int y, const unsigned int x1, const unsigned int x2, + unsigned int color, unsigned int bytesPerPixel, LockedSurfacePtr pBits, int pitch) { - SurfaceDescription sd; - Get_Description(sd); - - unsigned int size=PixelSize(sd); - - D3DLOCKED_RECT lock_rect; - ::ZeroMemory(&lock_rect, sizeof(D3DLOCKED_RECT)); - RECT rect; - ::ZeroMemory(&rect, sizeof(RECT)); - - rect.bottom=y+1; - rect.top=y; - rect.left=x1; - rect.right=x2+1; - - DX8_ErrorCode(D3DSurface->LockRect(&lock_rect,&rect,0)); - unsigned char *cptr=(unsigned char*)lock_rect.pBits; - unsigned short *sptr=(unsigned short*)lock_rect.pBits; - unsigned int *lptr=(unsigned int*)lock_rect.pBits; + unsigned char* row = static_cast(pBits) + y * pitch; - unsigned int x; - // the assumption here is that whenever a pixel has alpha it's in the MSB - for (x=x1; x<=x2; x++) + for (unsigned int x = x1; x <= x2; ++x) { - switch (size) - { - case 1: - *cptr++=(unsigned char) (color & 0xFF); - break; - case 2: - *sptr++=(unsigned short) (color & 0xFFFF); - break; - case 4: - *lptr++=color; - break; - } + unsigned char* dst = row + x * bytesPerPixel; + memcpy(dst, &color, bytesPerPixel); } - - DX8_ErrorCode(D3DSurface->UnlockRect()); } @@ -963,7 +863,7 @@ bool SurfaceClass::Is_Monochrome(void) int pitch,size; - size=PixelSize(sd); + size=::Get_Bytes_Per_Pixel(sd.Format); unsigned char *bits=(unsigned char*) Lock(&pitch); Vector3 rgb; @@ -1013,7 +913,7 @@ void SurfaceClass::Hue_Shift(const Vector3 &hsv_shift) Get_Description(sd); int pitch,size; - size=PixelSize(sd); + size=::Get_Bytes_Per_Pixel(sd.Format); unsigned char *bits=(unsigned char*) Lock(&pitch); Vector3 rgb; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.h b/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.h index 947199f2cd1..fb1f5a12af7 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/surfaceclass.h @@ -57,6 +57,7 @@ class SurfaceClass : public W3DMPO, public RefCountClass { W3DMPO_GLUE(SurfaceClass) public: + typedef void *LockedSurfacePtr; struct SurfaceDescription { WW3DFormat Format; // Surface format @@ -76,10 +77,14 @@ class SurfaceClass : public W3DMPO, public RefCountClass ~SurfaceClass(void); // Get surface description - void Get_Description(SurfaceDescription &surface_desc); + void Get_Description(SurfaceDescription &surface_desc); + + // Get the bytes per pixel count + unsigned int Get_Bytes_Per_Pixel(); // Lock / unlock the surface - void * Lock(int * pitch); + LockedSurfacePtr Lock(int *pitch); + LockedSurfacePtr Lock(int *pitch, const Vector2i &min, const Vector2i &max); void Unlock(void); // HY -- The following functions are support functions for font3d @@ -97,11 +102,11 @@ class SurfaceClass : public W3DMPO, public RefCountClass void Copy(const unsigned char *other); // support for copying from a byte array - void Copy(Vector2i &min,Vector2i &max, const unsigned char *other); + void Copy(const Vector2i &min, const Vector2i &max, const unsigned char *other); // copies the contents of one surface to another, stretches void Stretch_Copy( - unsigned int dstx, unsigned int dsty,unsigned int dstwidth, unsigned int dstheight, + unsigned int dstx, unsigned int dsty, unsigned int dstwidth, unsigned int dstheight, unsigned int srcx, unsigned int srcy, unsigned int srcwidth, unsigned int srcheight, const SurfaceClass *source); @@ -122,12 +127,15 @@ class SurfaceClass : public W3DMPO, public RefCountClass void Detach (void); // draws a horizontal line - void DrawHLine(const unsigned int y,const unsigned int x1, const unsigned int x2, unsigned int color); + void Draw_H_Line(const unsigned int y, const unsigned int x1, const unsigned int x2, + unsigned int color, unsigned int bytesPerPixel, LockedSurfacePtr pBits, int pitch); - void DrawPixel(const unsigned int x,const unsigned int y, unsigned int color); + // draws a pixel + void Draw_Pixel(const unsigned int x, const unsigned int y, unsigned int color, + unsigned int bytesPerPixel, LockedSurfacePtr pBits, int pitch); - // get pixel function .. to be used infrequently - void Get_Pixel(Vector3 &rgb, int x,int y); + // get pixel function + void Get_Pixel(Vector3 &rgb, int x, int y, LockedSurfacePtr pBits, int pitch); void Hue_Shift(const Vector3 &hsv_shift); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/texproject.cpp b/Core/Libraries/Source/WWVegas/WW3D2/texproject.cpp index 38b5ceee3e2..9c2e4b694e4 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/texproject.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/texproject.cpp @@ -186,10 +186,10 @@ TexProjectClass::TexProjectClass(void) : DesiredIntensity(1.0f), Intensity(1.0f), Attenuation(1.0f), - MaterialPass(NULL), - Mapper1(NULL), - RenderTarget(NULL), - DepthStencilTarget(NULL), + MaterialPass(nullptr), + Mapper1(nullptr), + RenderTarget(nullptr), + DepthStencilTarget(nullptr), HFov(90.0f), VFov(90.0f), XMin(-10.0f), @@ -205,7 +205,7 @@ TexProjectClass::TexProjectClass(void) : // create a vertex material VertexMaterialClass * vmtl = NEW_REF(VertexMaterialClass,()); - WWASSERT(vmtl != NULL); + WWASSERT(vmtl != nullptr); // Plug our parent's mapper into our vertex material // the mapper for stage1 will be allocated as needed @@ -213,7 +213,7 @@ TexProjectClass::TexProjectClass(void) : MaterialPass->Set_Material(vmtl); vmtl->Release_Ref(); - vmtl = NULL; + vmtl = nullptr; // by default init our material pass to be multiplicative (shadow) Init_Multiplicative(); @@ -594,7 +594,7 @@ void TexProjectClass::Init_Multiplicative(void) /* ** remove the texture from the second stage */ - MaterialPass->Set_Texture(NULL,1); + MaterialPass->Set_Texture(nullptr,1); } #if (DEBUG_SHADOW_RENDERING) @@ -620,13 +620,13 @@ void TexProjectClass::Init_Multiplicative(void) ** Set up some mapper settings related to depth gradient */ if (Get_Flag(USE_DEPTH_GRADIENT)) { - if (Mapper1 == NULL) { + if (Mapper1 == nullptr) { Mapper1 = NEW_REF(MatrixMapperClass,(1)); } Mapper1->Set_Type(MatrixMapperClass::DEPTH_GRADIENT); vmtl->Set_Mapper(Mapper1,1); } else { - vmtl->Set_Mapper(NULL,1); + vmtl->Set_Mapper(nullptr,1); } } @@ -709,7 +709,7 @@ void TexProjectClass::Init_Additive(void) ** Set up some mapper settings related to depth gradient ** Additive texture projections always use the normal gradient */ - if (Mapper1 == NULL) { + if (Mapper1 == nullptr) { Mapper1 = NEW_REF(MatrixMapperClass,(1)); } Mapper1->Set_Type(MatrixMapperClass::NORMAL_GRADIENT); @@ -731,7 +731,7 @@ void TexProjectClass::Init_Additive(void) *=============================================================================================*/ void TexProjectClass::Set_Texture(TextureClass * texture) { - if (texture != NULL) + if (texture != nullptr) { texture->Get_Filter().Set_U_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); texture->Get_Filter().Set_V_Addr_Mode(TextureFilterClass::TEXTURE_ADDRESS_CLAMP); @@ -871,8 +871,8 @@ bool TexProjectClass::Compute_Perspective_Projection float zfar ) { - if (model == NULL) { - WWDEBUG_SAY(("Attempting to generate projection for a NULL model")); + if (model == nullptr) { + WWDEBUG_SAY(("Attempting to generate projection for a null model")); return false; } @@ -998,8 +998,8 @@ bool TexProjectClass::Compute_Ortho_Projection float zfar ) { - if (model == NULL) { - WWDEBUG_SAY(("Attempting to generate projection for a NULL model")); + if (model == nullptr) { + WWDEBUG_SAY(("Attempting to generate projection for a null model")); return false; } @@ -1118,19 +1118,19 @@ bool TexProjectClass::Compute_Texture SpecialRenderInfoClass * context ) { - if ((model == NULL) || (context == NULL)) + if ((model == nullptr) || (context == nullptr)) { return false; } /* ** Render to texture */ - TextureClass * rtarget=NULL; - ZTextureClass* ztarget=NULL; + TextureClass * rtarget=nullptr; + ZTextureClass* ztarget=nullptr; Peek_Render_Target(&rtarget,&ztarget); - if (rtarget != NULL) + if (rtarget != nullptr) { // set projector for render context KJM context->Texture_Projector=this; @@ -1153,7 +1153,7 @@ bool TexProjectClass::Compute_Texture color.Set(1.0f,1.0f,1.0f); } - bool zclear=ztarget!=NULL; + bool zclear=ztarget!=nullptr; bool snapshot=WW3D::Is_Snapshot_Activated(); SNAPSHOT_SAY(("TexProjectCLass::Begin_Render()")); @@ -1163,7 +1163,7 @@ bool TexProjectClass::Compute_Texture WW3D::End_Render(false); WW3D::Activate_Snapshot(snapshot); // End_Render() ends the shapsnot, so restore the state - DX8Wrapper::Set_Render_Target((IDirect3DSurface8 *)NULL); + DX8Wrapper::Set_Render_Target((IDirect3DSurface8 *)nullptr); } @@ -1176,7 +1176,7 @@ bool TexProjectClass::Compute_Texture bwr.Fill(0xff); context->BWRenderer = &bwr; model->Special_Render(*context); - context->BWRenderer = NULL; + context->BWRenderer = nullptr; #endif return true; } @@ -1243,12 +1243,12 @@ TextureClass* TexProjectClass::Peek_Render_Target ) { // some uses of this function just want to know if a render target exists - if (rtarget==NULL) return RenderTarget; + if (rtarget==nullptr) return RenderTarget; *rtarget=RenderTarget; // don't set if pointer isn't supplied - if (ztarget!=NULL) + if (ztarget!=nullptr) *ztarget=DepthStencilTarget; return RenderTarget; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/texproject.h b/Core/Libraries/Source/WWVegas/WW3D2/texproject.h index 0489220f649..bd3d5449cc0 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/texproject.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/texproject.h @@ -86,7 +86,7 @@ class ZTextureClass; ** bounding volume first, then defer computing the actual texture until it is ** determined that the volume falls into the frustum and is applied to at least one ** object. -** solution: Code the bounding volume/projection paramter generation separate from +** solution: Code the bounding volume/projection parameter generation separate from ** the texture generation code. A derived texture projection object. Let texture ** projectors know about the object they are projecting so that they can have that ** object rendered from the desired viewpoint. Need a 'Dirty' flag and a pointer to @@ -158,8 +158,8 @@ class TexProjectClass : public ProjectorClass, public CullableClass, public Mult bool Compute_Ortho_Projection(const AABoxClass & obj_box,const Matrix3D & tm,const Vector3 & lightdir,float znear=-1.0f,float zfar=-1.0f); bool Needs_Render_Target(void); - void Set_Render_Target(TextureClass* render_target, ZTextureClass* ztarget=NULL); - TextureClass* Peek_Render_Target(TextureClass** rtarget=NULL, ZTextureClass** ztarget=NULL); + void Set_Render_Target(TextureClass* render_target, ZTextureClass* ztarget=nullptr); + TextureClass* Peek_Render_Target(TextureClass** rtarget=nullptr, ZTextureClass** ztarget=nullptr); bool Compute_Texture(RenderObjClass * model,SpecialRenderInfoClass * context); @@ -170,12 +170,12 @@ class TexProjectClass : public ProjectorClass, public CullableClass, public Mult /* ** virtual interface for getting the pointer of the object that generated this shadow. - ** defaults to returning NULL. This is implemented by some derived classes and used by + ** defaults to returning nullptr. This is implemented by some derived classes and used by ** the system to prevent a projection from being applied to the object that generated ** the projection... ** (gth) feels kludgy, this got a little messy when I moved this code into WW3D from WWPhys */ - virtual void * Get_Projection_Object_ID(void) const { return NULL; } + virtual void * Get_Projection_Object_ID(void) const { return nullptr; } protected: diff --git a/Core/Libraries/Source/WWVegas/WW3D2/textdraw.cpp b/Core/Libraries/Source/WWVegas/WW3D2/textdraw.cpp index 281eac76ae5..eed9f5744dc 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/textdraw.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/textdraw.cpp @@ -267,7 +267,7 @@ float TextDrawClass::Print( Font3DInstanceClass *font, char ch, float screen_x, } /* - ** Get the font texture uv coordinate for teh upper right and lower left corners of the rect + ** Get the font texture uv coordinate for the upper right and lower left corners of the rect */ RectClass font_uv = font->Char_UV( ch ); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/texture.cpp b/Core/Libraries/Source/WWVegas/WW3D2/texture.cpp index a87382f6478..f923fbec419 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/texture.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/texture.cpp @@ -84,7 +84,7 @@ TextureBaseClass::TextureBaseClass bool reducible ) : MipLevelCount(mip_level_count), - D3DTexture(NULL), + D3DTexture(nullptr), Initialized(false), Name(""), FullPath(""), @@ -101,8 +101,8 @@ TextureBaseClass::TextureBaseClass Height(height), Pool(pool), Dirty(false), - TextureLoadTask(NULL), - ThumbnailLoadTask(NULL), + TextureLoadTask(nullptr), + ThumbnailLoadTask(nullptr), HSVShift(0.0f,0.0f,0.0f) { } @@ -115,14 +115,14 @@ TextureBaseClass::TextureBaseClass TextureBaseClass::~TextureBaseClass(void) { delete TextureLoadTask; - TextureLoadTask=NULL; + TextureLoadTask=nullptr; delete ThumbnailLoadTask; - ThumbnailLoadTask=NULL; + ThumbnailLoadTask=nullptr; if (D3DTexture) { D3DTexture->Release(); - D3DTexture = NULL; + D3DTexture = nullptr; } DX8TextureManagerClass::Remove(this); @@ -204,7 +204,7 @@ void TextureBaseClass::Invalidate() if (D3DTexture) { D3DTexture->Release(); - D3DTexture = NULL; + D3DTexture = nullptr; } Initialized=false; @@ -239,7 +239,7 @@ void TextureBaseClass::Invalidate() if (D3DTexture) { D3DTexture->Release(); - D3DTexture = NULL; + D3DTexture = nullptr; } Initialized=false; @@ -267,11 +267,11 @@ void TextureBaseClass::Set_D3D_Base_Texture(IDirect3DBaseTexture8* tex) // reset the access timer whenever someon messes with this pointer. LastAccessed=WW3D::Get_Sync_Time(); - if (D3DTexture != NULL) { + if (D3DTexture != nullptr) { D3DTexture->Release(); } D3DTexture = tex; - if (D3DTexture != NULL) { + if (D3DTexture != nullptr) { D3DTexture->AddRef(); } } @@ -285,7 +285,7 @@ void TextureBaseClass::Load_Locked_Surface() { WWPROFILE(("TextureClass::Load_Locked_Surface()")); if (D3DTexture) D3DTexture->Release(); - D3DTexture=0; + D3DTexture=nullptr; TextureLoader::Request_Thumbnail(this); Initialized=false; } @@ -332,7 +332,7 @@ unsigned int TextureBaseClass::Get_Priority(void) { if (!D3DTexture) { - WWASSERT_PRINT(0, "Get_Priority: D3DTexture is NULL!"); + WWASSERT_PRINT(0, "Get_Priority: D3DTexture is null!"); return 0; } @@ -352,7 +352,7 @@ unsigned int TextureBaseClass::Set_Priority(unsigned int priority) { if (!D3DTexture) { - WWASSERT_PRINT(0, "Set_Priority: D3DTexture is NULL!"); + WWASSERT_PRINT(0, "Set_Priority: D3DTexture is null!"); return 0; } @@ -390,13 +390,13 @@ unsigned TextureBaseClass::Get_Reduction() const //********************************************************************************************** -//! Apply NULL texture state +//! Apply null texture state /*! */ void TextureBaseClass::Apply_Null(unsigned int stage) { - // This function sets the render states for a "NULL" texture - DX8Wrapper::Set_DX8_Texture(stage, NULL); + // This function sets the render states for a "null" texture + DX8Wrapper::Set_DX8_Texture(stage, nullptr); } // ---------------------------------------------------------------------------- @@ -709,7 +709,7 @@ TextureClass::TextureClass default: break; } - WWASSERT_PRINT(name && name[0], "TextureClass CTor: NULL or empty texture name"); + WWASSERT_PRINT(name && name[0], "TextureClass CTor: null or empty texture name"); int len=strlen(name); for (int i=0;iGetSurfaceLevel(level, &d3d_surface)); SurfaceClass *surface = new SurfaceClass(d3d_surface); d3d_surface->Release(); @@ -1002,7 +1002,7 @@ SurfaceClass *TextureClass::Get_Surface_Level(unsigned int level) void TextureClass::Get_Level_Description( SurfaceClass::SurfaceDescription & desc, unsigned int level ) { SurfaceClass * surf = Get_Surface_Level(level); - if (surf != NULL) { + if (surf != nullptr) { surf->Get_Description(desc); } REF_PTR_RELEASE(surf); @@ -1016,11 +1016,11 @@ IDirect3DSurface8 *TextureClass::Get_D3D_Surface_Level(unsigned int level) { if (!Peek_D3D_Texture()) { - WWASSERT_PRINT(0, "Get_D3D_Surface_Level: D3DTexture is NULL!"); - return 0; + WWASSERT_PRINT(0, "Get_D3D_Surface_Level: D3DTexture is null!"); + return nullptr; } - IDirect3DSurface8 *d3d_surface = NULL; + IDirect3DSurface8 *d3d_surface = nullptr; DX8_ErrorCode(Peek_D3D_Texture()->GetSurfaceLevel(level, &d3d_surface)); return d3d_surface; } @@ -1047,7 +1047,7 @@ unsigned TextureClass::Get_Texture_Memory_Usage() const TextureClass* Load_Texture(ChunkLoadClass & cload) { // Assume failure - TextureClass *newtex = NULL; + TextureClass *newtex = nullptr; char name[256]; if (cload.Open_Chunk () && (cload.Cur_Chunk_ID () == W3D_CHUNK_TEXTURE)) @@ -1308,11 +1308,11 @@ IDirect3DSurface8* ZTextureClass::Get_D3D_Surface_Level(unsigned int level) { if (!Peek_D3D_Texture()) { - WWASSERT_PRINT(0, "Get_D3D_Surface_Level: D3DTexture is NULL!"); - return 0; + WWASSERT_PRINT(0, "Get_D3D_Surface_Level: D3DTexture is null!"); + return nullptr; } - IDirect3DSurface8 *d3d_surface = NULL; + IDirect3DSurface8 *d3d_surface = nullptr; DX8_ErrorCode(Peek_D3D_Texture()->GetSurfaceLevel(level, &d3d_surface)); return d3d_surface; } @@ -1454,7 +1454,7 @@ CubeTextureClass::CubeTextureClass default: break; } - WWASSERT_PRINT(name && name[0], "TextureClass CTor: NULL or empty texture name"); + WWASSERT_PRINT(name && name[0], "TextureClass CTor: null or empty texture name"); int len=strlen(name); for (int i=0;iNext == NULL && task->Prev == NULL); + WWASSERT(task != nullptr && task->Next == nullptr && task->Prev == nullptr); // update inserted task to point to list task->Next = Root.Next; @@ -95,7 +95,7 @@ void TextureLoadTaskListClass::Push_Front (TextureLoadTaskClass *task) void TextureLoadTaskListClass::Push_Back(TextureLoadTaskClass *task) { // task should be non-null and not on any list - WWASSERT(task != NULL && task->Next == NULL && task->Prev == NULL); + WWASSERT(task != nullptr && task->Next == nullptr && task->Prev == nullptr); // update inserted task to point to list task->Next = &Root; @@ -111,7 +111,7 @@ TextureLoadTaskClass *TextureLoadTaskListClass::Pop_Front(void) { // exit early if list is empty if (Is_Empty()) { - return 0; + return nullptr; } // otherwise, grab first task and remove it. @@ -125,7 +125,7 @@ TextureLoadTaskClass *TextureLoadTaskListClass::Pop_Back(void) { // exit early if list is empty if (Is_Empty()) { - return 0; + return nullptr; } // otherwise, grab last task and remove it. @@ -146,9 +146,9 @@ void TextureLoadTaskListClass::Remove(TextureLoadTaskClass *task) task->Next->Prev = task->Prev; // update task to no longer point at list - task->Prev = 0; - task->Next = 0; - task->List = 0; + task->Prev = nullptr; + task->Next = nullptr; + task->List = nullptr; } @@ -180,7 +180,7 @@ TextureLoadTaskClass *SynchronizedTextureLoadTaskListClass::Pop_Front(void) { // this duplicates code inside base class, but saves us an unnecessary lock. if (Is_Empty()) { - return 0; + return nullptr; } FastCriticalSectionClass::LockClass lock(CriticalSection); @@ -192,7 +192,7 @@ TextureLoadTaskClass *SynchronizedTextureLoadTaskListClass::Pop_Back(void) { // this duplicates code inside base class, but saves us an unnecessary lock. if (Is_Empty()) { - return 0; + return nullptr; } FastCriticalSectionClass::LockClass lock(CriticalSection); @@ -249,8 +249,8 @@ IDirect3DTexture8* Load_Compressed_Texture( // If DDS file isn't available, use TGA file to convert to DDS. DDSFileClass dds_file(filename,reduction_factor); - if (!dds_file.Is_Available()) return NULL; - if (!dds_file.Load()) return NULL; + if (!dds_file.Is_Available()) return nullptr; + if (!dds_file.Load()) return nullptr; unsigned width=dds_file.Get_Width(0); unsigned height=dds_file.Get_Height(0); @@ -269,7 +269,7 @@ IDirect3DTexture8* Load_Compressed_Texture( ); for (unsigned level=0;levelGetSurfaceLevel(level/*-reduction_factor*/,&d3d_surface)); dds_file.Copy_Level_To_Surface(level,d3d_surface); @@ -415,7 +415,7 @@ IDirect3DTexture8* TextureLoader::Load_Thumbnail(const StringClass& filename, co { WWASSERT(Is_DX8_Thread()); - ThumbnailClass* thumb=NULL; + ThumbnailClass* thumb=nullptr; thumb=ThumbnailManagerClass::Peek_Thumbnail_Instance_From_Any_Manager(filename); // If no thumb is found return a missing texture @@ -456,7 +456,7 @@ IDirect3DTexture8* TextureLoader::Load_Thumbnail(const StringClass& filename, co sysmem_texture->LockRect( level, &locked_rects[level], - NULL, + nullptr, 0)); } @@ -529,7 +529,7 @@ IDirect3DSurface8* TextureLoader::Load_Surface_Immediate( if (compressed) { IDirect3DTexture8* comp_tex=Load_Compressed_Texture(filename,0,MIP_LEVELS_1,WW3D_FORMAT_UNKNOWN); if (comp_tex) { - IDirect3DSurface8* d3d_surface=NULL; + IDirect3DSurface8* d3d_surface=nullptr; DX8_ErrorCode(comp_tex->GetSurfaceLevel(0,&d3d_surface)); comp_tex->Release(); return d3d_surface; @@ -566,7 +566,7 @@ IDirect3DSurface8* TextureLoader::Load_Surface_Immediate( unsigned char* src_surface=(unsigned char*)targa.GetImage(); // No paletted destination format allowed - unsigned char* converted_surface=NULL; + unsigned char* converted_surface=nullptr; if (src_format==WW3D_FORMAT_A1R5G5B5 || src_format==WW3D_FORMAT_R5G6B5 || src_format==WW3D_FORMAT_A4R4G4B4 || src_format==WW3D_FORMAT_P8 || src_format==WW3D_FORMAT_L8 || src_width!=width || src_height!=height) { converted_surface=W3DNEWARRAY unsigned char[width*height*4]; @@ -600,7 +600,7 @@ IDirect3DSurface8* TextureLoader::Load_Surface_Immediate( DX8_ErrorCode( d3d_surface->LockRect( &locked_rect, - NULL, + nullptr, 0)); BitmapHandlerClass::Copy_Image( @@ -963,7 +963,7 @@ void TextureLoader::Load_Thumbnail(TextureBaseClass *tc) // release our reference to thumbnail texture d3d_texture->Release(); - d3d_texture = 0; + d3d_texture = nullptr; } @@ -1003,8 +1003,8 @@ void LoaderThreadClass::Thread_Function(void) //////////////////////////////////////////////////////////////////////////////// TextureLoadTaskClass::TextureLoadTaskClass() -: Texture (0), - D3DTexture (0), +: Texture (nullptr), + D3DTexture (nullptr), Format (WW3D_FORMAT_UNKNOWN), Width (0), Height (0), @@ -1020,7 +1020,7 @@ TextureLoadTaskClass::TextureLoadTaskClass() // is done by Init() and Deinit(). for (int i = 0; i < MIP_LEVELS_MAX; ++i) { - LockedSurfacePtr[i] = NULL; + LockedSurfacePtr[i] = nullptr; LockedSurfacePitch[i] = 0; } } @@ -1038,7 +1038,7 @@ TextureLoadTaskClass *TextureLoadTaskClass::Create(TextureBaseClass *tc, TaskTyp // and priority, then associate the texture with the task. // pull a load task from front of free list - TextureLoadTaskClass *task = NULL; + TextureLoadTaskClass *task = nullptr; switch (tc->Get_Asset_Type()) { case TextureBaseClass::TEX_REGULAR : task=_TexLoadFreeList.Pop_Front(); break; @@ -1101,7 +1101,7 @@ void TextureLoadTaskClass::Init(TextureBaseClass* tc, TaskType type, PriorityTyp Priority = priority; State = STATE_NONE; - D3DTexture = 0; + D3DTexture = nullptr; TextureClass* tex=Texture->As_TextureClass(); @@ -1123,19 +1123,19 @@ void TextureLoadTaskClass::Init(TextureBaseClass* tc, TaskType type, PriorityTyp for (int i = 0; i < MIP_LEVELS_MAX; ++i) { - LockedSurfacePtr[i] = NULL; + LockedSurfacePtr[i] = nullptr; LockedSurfacePitch[i] = 0; } switch (Type) { case TASK_THUMBNAIL: - WWASSERT(Texture->ThumbnailLoadTask == NULL); + WWASSERT(Texture->ThumbnailLoadTask == nullptr); Texture->ThumbnailLoadTask = this; break; case TASK_LOAD: - WWASSERT(Texture->TextureLoadTask == NULL); + WWASSERT(Texture->TextureLoadTask == nullptr); Texture->TextureLoadTask = this; break; } @@ -1145,25 +1145,25 @@ void TextureLoadTaskClass::Init(TextureBaseClass* tc, TaskType type, PriorityTyp void TextureLoadTaskClass::Deinit() { // task should not be on any list when it is being detached from texture. - WWASSERT(Next == NULL); - WWASSERT(Prev == NULL); + WWASSERT(Next == nullptr); + WWASSERT(Prev == nullptr); - WWASSERT(D3DTexture == NULL); + WWASSERT(D3DTexture == nullptr); for (int i = 0; i < MIP_LEVELS_MAX; ++i) { - WWASSERT(LockedSurfacePtr[i] == NULL); + WWASSERT(LockedSurfacePtr[i] == nullptr); } if (Texture) { switch (Type) { case TASK_THUMBNAIL: WWASSERT(Texture->ThumbnailLoadTask == this); - Texture->ThumbnailLoadTask = NULL; + Texture->ThumbnailLoadTask = nullptr; break; case TASK_LOAD: WWASSERT(Texture->TextureLoadTask == this); - Texture->TextureLoadTask = NULL; + Texture->TextureLoadTask = nullptr; break; } @@ -1287,13 +1287,13 @@ void TextureLoadTaskClass::Apply(bool initialize) // Verify that none of the mip levels are locked for (unsigned i=0;iApply_New_Surface(D3DTexture, initialize); D3DTexture->Release(); - D3DTexture = NULL; + D3DTexture = nullptr; } static bool Get_Texture_Information @@ -1786,7 +1786,7 @@ void TextureLoadTaskClass::Lock_Surfaces(void) ( i, &locked_rect, - NULL, + nullptr, 0 ) ); @@ -1805,7 +1805,7 @@ void TextureLoadTaskClass::Unlock_Surfaces(void) WWASSERT(ThreadClass::_Get_Current_Thread_ID() == DX8Wrapper::_Get_Main_Thread_ID()); DX8_ErrorCode(Peek_D3D_Texture()->UnlockRect(i)); } - LockedSurfacePtr[i] = NULL; + LockedSurfacePtr[i] = nullptr; } #ifndef USE_MANAGED_TEXTURES @@ -1899,7 +1899,7 @@ bool TextureLoadTaskClass::Load_Uncompressed_Mipmap(void) } unsigned char * src_surface = (unsigned char*)targa.GetImage(); - unsigned char * converted_surface = NULL; + unsigned char * converted_surface = nullptr; // No paletted format allowed when generating mipmaps Vector3 hsv_shift=HSVShift; @@ -1956,7 +1956,7 @@ bool TextureLoadTaskClass::Load_Uncompressed_Mipmap(void) src_height, src_pitch, src_format, - NULL, + nullptr, 0, true, hsv_shift); @@ -1982,7 +1982,7 @@ bool TextureLoadTaskClass::Load_Uncompressed_Mipmap(void) src_height, src_pitch, src_format, - NULL, + nullptr, 0, true, hsv_shift); @@ -2042,7 +2042,7 @@ CubeTextureLoadTaskClass::CubeTextureLoadTaskClass() { for (int i = 0; i < MIP_LEVELS_MAX; ++i) { - LockedCubeSurfacePtr[f][i] = NULL; + LockedCubeSurfacePtr[f][i] = nullptr; LockedCubeSurfacePitch[f][i] = 0; } } @@ -2071,7 +2071,7 @@ void CubeTextureLoadTaskClass::Init(TextureBaseClass* tc, TaskType type, Priorit Priority = priority; State = STATE_NONE; - D3DTexture = 0; + D3DTexture = nullptr; CubeTextureClass* tex=Texture->As_CubeTextureClass(); @@ -2095,7 +2095,7 @@ void CubeTextureLoadTaskClass::Init(TextureBaseClass* tc, TaskType type, Priorit { for (int i = 0; i < MIP_LEVELS_MAX; ++i) { - LockedCubeSurfacePtr[f][i] = NULL; + LockedCubeSurfacePtr[f][i] = nullptr; LockedCubeSurfacePitch[f][i] = 0; } } @@ -2103,12 +2103,12 @@ void CubeTextureLoadTaskClass::Init(TextureBaseClass* tc, TaskType type, Priorit switch (Type) { case TASK_THUMBNAIL: - WWASSERT(Texture->ThumbnailLoadTask == NULL); + WWASSERT(Texture->ThumbnailLoadTask == nullptr); Texture->ThumbnailLoadTask = this; break; case TASK_LOAD: - WWASSERT(Texture->TextureLoadTask == NULL); + WWASSERT(Texture->TextureLoadTask == nullptr); Texture->TextureLoadTask = this; break; } @@ -2118,16 +2118,16 @@ void CubeTextureLoadTaskClass::Init(TextureBaseClass* tc, TaskType type, Priorit void CubeTextureLoadTaskClass::Deinit() { // task should not be on any list when it is being detached from texture. - WWASSERT(Next == NULL); - WWASSERT(Prev == NULL); + WWASSERT(Next == nullptr); + WWASSERT(Prev == nullptr); - WWASSERT(D3DTexture == NULL); + WWASSERT(D3DTexture == nullptr); for (int f=0; f<6; f++) { for (int i = 0; i < MIP_LEVELS_MAX; ++i) { - WWASSERT(LockedCubeSurfacePtr[f][i] == NULL); + WWASSERT(LockedCubeSurfacePtr[f][i] == nullptr); } } @@ -2137,12 +2137,12 @@ void CubeTextureLoadTaskClass::Deinit() { case TASK_THUMBNAIL: WWASSERT(Texture->ThumbnailLoadTask == this); - Texture->ThumbnailLoadTask = NULL; + Texture->ThumbnailLoadTask = nullptr; break; case TASK_LOAD: WWASSERT(Texture->TextureLoadTask == this); - Texture->TextureLoadTask = NULL; + Texture->TextureLoadTask = nullptr; break; } @@ -2166,7 +2166,7 @@ void CubeTextureLoadTaskClass::Lock_Surfaces(void) (D3DCUBEMAP_FACES)f, i, &locked_rect, - NULL, + nullptr, 0 ) ); @@ -2190,7 +2190,7 @@ void CubeTextureLoadTaskClass::Unlock_Surfaces(void) Peek_D3D_Cube_Texture()->UnlockRect((D3DCUBEMAP_FACES)f,i) ); } - LockedCubeSurfacePtr[f][i] = NULL; + LockedCubeSurfacePtr[f][i] = nullptr; } } @@ -2454,7 +2454,7 @@ VolumeTextureLoadTaskClass::VolumeTextureLoadTaskClass() for (int i = 0; i < MIP_LEVELS_MAX; ++i) { - LockedSurfacePtr[i] = NULL; + LockedSurfacePtr[i] = nullptr; LockedSurfacePitch[i] = 0; LockedSurfaceSlicePitch[i] = 0; } @@ -2482,7 +2482,7 @@ void VolumeTextureLoadTaskClass::Init(TextureBaseClass* tc, TaskType type, Prior Priority = priority; State = STATE_NONE; - D3DTexture = 0; + D3DTexture = nullptr; VolumeTextureClass* tex=Texture->As_VolumeTextureClass(); @@ -2505,7 +2505,7 @@ void VolumeTextureLoadTaskClass::Init(TextureBaseClass* tc, TaskType type, Prior for (int i = 0; i < MIP_LEVELS_MAX; ++i) { - LockedSurfacePtr[i] = NULL; + LockedSurfacePtr[i] = nullptr; LockedSurfacePitch[i] = 0; LockedSurfaceSlicePitch[i] = 0; } @@ -2513,12 +2513,12 @@ void VolumeTextureLoadTaskClass::Init(TextureBaseClass* tc, TaskType type, Prior switch (Type) { case TASK_THUMBNAIL: - WWASSERT(Texture->ThumbnailLoadTask == NULL); + WWASSERT(Texture->ThumbnailLoadTask == nullptr); Texture->ThumbnailLoadTask = this; break; case TASK_LOAD: - WWASSERT(Texture->TextureLoadTask == NULL); + WWASSERT(Texture->TextureLoadTask == nullptr); Texture->TextureLoadTask = this; break; } @@ -2535,7 +2535,7 @@ void VolumeTextureLoadTaskClass::Lock_Surfaces() ( i, &locked_box, - NULL, + nullptr, 0 ) ); @@ -2558,7 +2558,7 @@ void VolumeTextureLoadTaskClass::Unlock_Surfaces() Peek_D3D_Volume_Texture()->UnlockBox(i) ); } - LockedSurfacePtr[i] = NULL; + LockedSurfacePtr[i] = nullptr; } #ifndef USE_MANAGED_TEXTURES diff --git a/Core/Libraries/Source/WWVegas/WW3D2/textureloader.h b/Core/Libraries/Source/WWVegas/WW3D2/textureloader.h index 38104d6495a..af5b018cd84 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/textureloader.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/textureloader.h @@ -45,6 +45,7 @@ class StringClass; struct IDirect3DTexture8; class TextureLoadTaskClass; +class TextureLoadTaskListClass; class TextureLoader { @@ -78,7 +79,7 @@ class TextureLoader static void Request_Foreground_Loading(TextureBaseClass* tc); static void Flush_Pending_Load_Tasks(void); - static void Update(void(*network_callback)(void) = NULL); + static void Update(void(*network_callback)(void) = nullptr); // returns true if current thread of execution is allowed to make DX8 calls. static bool Is_DX8_Thread(void); @@ -134,10 +135,10 @@ class TextureLoadTaskListClass // Add a task to end of list void Push_Back (TextureLoadTaskClass *task); - // Remove and return a task from beginning of list, or NULL if list is empty. + // Remove and return a task from beginning of list, or null if list is empty. TextureLoadTaskClass * Pop_Front (void); - // Remove and return a task from end of list, or NULL if list is empty + // Remove and return a task from end of list, or null if list is empty TextureLoadTaskClass * Pop_Back (void); // Remove specified task from list, if present diff --git a/Core/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp b/Core/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp index 03c803491af..5d05da9d44b 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp @@ -102,7 +102,7 @@ ThumbnailClass::ThumbnailClass( ThumbnailClass::ThumbnailClass(ThumbnailManagerClass* manager, const StringClass& filename) : Manager(manager), - Bitmap(0), + Bitmap(nullptr), Name(filename), Allocated(false), Width(0), @@ -259,7 +259,7 @@ ThumbnailClass::~ThumbnailClass() // ---------------------------------------------------------------------------- ThumbnailManagerClass::ThumbnailManagerClass(const char* thumbnail_filename) : - ThumbnailMemory(NULL), + ThumbnailMemory(nullptr), ThumbnailFileName(thumbnail_filename), PerTextureTimeStampUsed(false), Changed(false), @@ -279,7 +279,7 @@ ThumbnailManagerClass::~ThumbnailManagerClass() } delete[] ThumbnailMemory; - ThumbnailMemory=NULL; + ThumbnailMemory=nullptr; } // ---------------------------------------------------------------------------- @@ -292,7 +292,7 @@ ThumbnailManagerClass* ThumbnailManagerClass::Peek_Thumbnail_Manager(const char* } if (GlobalThumbnailManager && GlobalThumbnailManager->ThumbnailFileName==thumbnail_filename) return GlobalThumbnailManager; - return NULL; + return nullptr; } // ---------------------------------------------------------------------------- @@ -326,7 +326,7 @@ void ThumbnailManagerClass::Remove_Thumbnail_Manager(const char* thumbnail_filen if (GlobalThumbnailManager && GlobalThumbnailManager->ThumbnailFileName==thumbnail_filename) { delete GlobalThumbnailManager; - GlobalThumbnailManager=NULL; + GlobalThumbnailManager=nullptr; } } // ---------------------------------------------------------------------------- @@ -359,13 +359,13 @@ ThumbnailClass* ThumbnailManagerClass::Peek_Thumbnail_Instance_From_Any_Manager( ThumbnailClass* thumb=new ThumbnailClass(GlobalThumbnailManager,filename); if (!thumb->Peek_Bitmap()) { delete thumb; - thumb=NULL; + thumb=nullptr; } return thumb; } } - return NULL; + return nullptr; } @@ -394,7 +394,7 @@ void ThumbnailManagerClass::Remove_From_Hash(ThumbnailClass* thumb) void ThumbnailManagerClass::Init() { - WWASSERT(GlobalThumbnailManager == NULL); + WWASSERT(GlobalThumbnailManager == nullptr); GlobalThumbnailManager=new ThumbnailManagerClass(GLOBAL_THUMBNAIL_MANAGER_FILENAME); GlobalThumbnailManager->Enable_Per_Texture_Time_Stamp(true); } @@ -406,5 +406,5 @@ void ThumbnailManagerClass::Deinit() } delete GlobalThumbnailManager; - GlobalThumbnailManager=NULL; + GlobalThumbnailManager=nullptr; } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp b/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp index 5c4bf51f9e9..413c0d0e253 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/visrasterizer.cpp @@ -145,7 +145,7 @@ static VisPolyClass _VisPoly1; VisRasterizerClass::VisRasterizerClass(void) : ModelTransform(1), - Camera(NULL), + Camera(nullptr), MVTransform(1) { } @@ -179,7 +179,7 @@ void VisRasterizerClass::Set_Camera(CameraClass * camera) CameraClass * VisRasterizerClass::Get_Camera(void) { - if (Camera != NULL) { + if (Camera != nullptr) { Camera->Add_Ref(); } return Camera; @@ -228,8 +228,8 @@ bool VisRasterizerClass::Render_Triangles AABoxClass & bounds ) { - WWASSERT(verts != NULL); - WWASSERT(tris != NULL); + WWASSERT(verts != nullptr); + WWASSERT(tris != nullptr); WWASSERT(vcount > 0); WWASSERT(tcount > 0); @@ -375,8 +375,8 @@ IDBufferClass::IDBufferClass(void) : PixelCounter(0), ResWidth(0), ResHeight(0), - IDBuffer(NULL), - ZBuffer(NULL) + IDBuffer(nullptr), + ZBuffer(nullptr) { } @@ -399,17 +399,17 @@ void IDBufferClass::Set_Resolution(int w,int h) void IDBufferClass::Get_Resolution(int * get_w,int * get_h) { - if (get_w != NULL) { *get_w = ResWidth; } - if (get_h != NULL) { *get_h = ResHeight; } + if (get_w != nullptr) { *get_w = ResWidth; } + if (get_h != nullptr) { *get_h = ResHeight; } } void IDBufferClass::Reset(void) { delete[] IDBuffer; - IDBuffer = NULL; + IDBuffer = nullptr; delete[] ZBuffer; - ZBuffer = NULL; + ZBuffer = nullptr; PixelCounter = 0; } @@ -431,8 +431,8 @@ void IDBufferClass::Clear(void) if ((ResWidth > 0) && (ResHeight > 0)) { int byte_count = ResWidth * ResWidth * sizeof(uint32); - WWASSERT(IDBuffer != NULL); - WWASSERT(ZBuffer != NULL); + WWASSERT(IDBuffer != nullptr); + WWASSERT(ZBuffer != nullptr); memset(IDBuffer,0,byte_count); memset(ZBuffer,0,byte_count); } @@ -511,7 +511,7 @@ struct EdgeStruct bool IDBufferClass::Render_Triangle(const Vector3 & p0,const Vector3 & p1,const Vector3 & p2) { - if ((ZBuffer == NULL) || (IDBuffer == NULL)) { + if ((ZBuffer == nullptr) || (IDBuffer == nullptr)) { return false; } @@ -593,8 +593,8 @@ bool IDBufferClass::Render_Triangle(const Vector3 & p0,const Vector3 & p1,const EdgeStruct top_to_middle_edge(grads,points,top,middle); EdgeStruct middle_to_bottom_edge(grads,points,middle,bottom); - EdgeStruct * left_edge = NULL; - EdgeStruct * right_edge = NULL; + EdgeStruct * left_edge = nullptr; + EdgeStruct * right_edge = nullptr; bool middle_is_left = false; if (bottom_for_compare > middle_for_compare) { diff --git a/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp b/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp index 415b9fb8c53..5999cef031e 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/w3d_dep.cpp @@ -109,7 +109,7 @@ bool Get_W3D_Dependencies (const char *w3d_filename, StringList &files) file->Open(); if ( ! file->Is_Open()) { _TheFileFactory->Return_File(file); - file=NULL; + file=nullptr; return false; } } else { @@ -131,7 +131,7 @@ bool Get_W3D_Dependencies (const char *w3d_filename, StringList &files) // Close the file. file->Close(); _TheFileFactory->Return_File(file); - file=NULL; + file=nullptr; // Sort the set of filenames, and remove any duplicates. files.sort(); @@ -275,7 +275,7 @@ static void Scan_Mesh_Textures (ChunkLoadClass &cload, StringList &files, const // We're interested in the TEXTURE_NAME sub-chunk. if (cload.Cur_Chunk_ID() == W3D_CHUNK_TEXTURE_NAME) { - // This chunk's data is a NULL-terminated string + // This chunk's data is a null-terminated string // which is the texture filename. Read it and // add it to the list of files referred to. char texture[_MAX_PATH]; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h b/Core/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h index eb9a537f99d..b6d268ad94b 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/w3d_obsolete.h @@ -80,9 +80,9 @@ enum ///////////////////////////////////////////////////////////////////////////////////////////// struct W3dMaterialStruct { - char MaterialName[W3D_NAME_LEN]; // name of the material (NULL terminated) - char PrimaryName[W3D_NAME_LEN]; // primary texture name (NULL terminated) - char SecondaryName[W3D_NAME_LEN]; // secondary texture name (NULL terminated) + char MaterialName[W3D_NAME_LEN]; // name of the material (null-terminated) + char PrimaryName[W3D_NAME_LEN]; // primary texture name (null-terminated) + char SecondaryName[W3D_NAME_LEN]; // secondary texture name (null-terminated) uint32 RenderFlags; // Rendering flags uint8 Red; // Rgb colors uint8 Green; @@ -94,9 +94,9 @@ struct W3dMaterialStruct ///////////////////////////////////////////////////////////////////////////////////////////// struct W3dMaterial2Struct { - char MaterialName[W3D_NAME_LEN]; // name of the material (NULL terminated) - char PrimaryName[W3D_NAME_LEN]; // primary texture name (NULL terminated) - char SecondaryName[W3D_NAME_LEN]; // secondary texture name (NULL terminated) + char MaterialName[W3D_NAME_LEN]; // name of the material (null-terminated) + char PrimaryName[W3D_NAME_LEN]; // primary texture name (null-terminated) + char SecondaryName[W3D_NAME_LEN]; // secondary texture name (null-terminated) uint32 RenderFlags; // Rendering flags uint8 Red; // Rgb colors uint8 Green; diff --git a/Core/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp b/Core/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp index 800158e9456..68da606cdcc 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/w3dexclusionlist.cpp @@ -61,13 +61,13 @@ bool W3DExclusionListClass::Is_Excluded(PrototypeClass * proto) const char * root_name = copy.Peek_Buffer(); // don't preserve munged prototypes - if (strchr(root_name,'#') != NULL) { + if (strchr(root_name,'#') != nullptr) { return false; } // chop off the sub-object name if present ( char * tmp = strchr(root_name,'.'); - if (tmp != NULL) { + if (tmp != nullptr) { *tmp = 0; } diff --git a/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp b/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp index b5d6de1a736..0c867868458 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp +++ b/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.cpp @@ -393,25 +393,131 @@ WW3DFormat Get_Valid_Texture_Format(WW3DFormat format, bool is_compression_allow unsigned Get_Bytes_Per_Pixel(WW3DFormat format) { switch (format) { + case WW3D_FORMAT_A8R8G8B8: case WW3D_FORMAT_X8R8G8B8: case WW3D_FORMAT_X8L8V8U8: - case WW3D_FORMAT_A8R8G8B8: return 4; - case WW3D_FORMAT_R8G8B8: return 3; + return 4; + case WW3D_FORMAT_R8G8B8: + return 3; + case WW3D_FORMAT_R5G6B5: + case WW3D_FORMAT_X1R5G5B5: case WW3D_FORMAT_A1R5G5B5: case WW3D_FORMAT_A4R4G4B4: + case WW3D_FORMAT_A8R3G3B2: + case WW3D_FORMAT_X4R4G4B4: + case WW3D_FORMAT_A8P8: + case WW3D_FORMAT_A8L8: case WW3D_FORMAT_U8V8: case WW3D_FORMAT_L6V5U5: - case WW3D_FORMAT_R5G6B5: return 2; + return 2; case WW3D_FORMAT_R3G3B2: - case WW3D_FORMAT_L8: case WW3D_FORMAT_A8: - case WW3D_FORMAT_P8: return 1; + case WW3D_FORMAT_P8: + case WW3D_FORMAT_L8: + case WW3D_FORMAT_A4L4: + return 1; default: WWASSERT(0); break; } return 0; } +unsigned ARGB_Color_To_WW3D_Color(WW3DFormat format, unsigned argb) +{ + unsigned a = (argb >> 24) & 0xFF; + unsigned r = (argb >> 16) & 0xFF; + unsigned g = (argb >> 8) & 0xFF; + unsigned b = (argb >> 0) & 0xFF; + + switch (format) + { + case WW3D_FORMAT_R8G8B8: + return (r << 16) | (g << 8) | b; + + case WW3D_FORMAT_A8R8G8B8: + return (a << 24) | (r << 16) | (g << 8) | b; + + case WW3D_FORMAT_X8R8G8B8: + return (0xFF << 24) | (r << 16) | (g << 8) | b; + + case WW3D_FORMAT_R5G6B5: + return ((r >> 3) << 11) | + ((g >> 2) << 5) | + ((b >> 3) << 0); + + case WW3D_FORMAT_X1R5G5B5: + return ( 1 << 15) | + ((r >> 3) << 10) | + ((g >> 3) << 5) | + ((b >> 3) << 0); + + case WW3D_FORMAT_A1R5G5B5: + return ((a >> 7) << 15) | + ((r >> 3) << 10) | + ((g >> 3) << 5) | + ((b >> 3) << 0); + + case WW3D_FORMAT_A4R4G4B4: + return ((a >> 4) << 12) | + ((r >> 4) << 8) | + ((g >> 4) << 4) | + ((b >> 4) << 0); + + case WW3D_FORMAT_R3G3B2: + return ((r >> 5) << 5) | + ((g >> 5) << 2) | + ((b >> 6) << 0); + + case WW3D_FORMAT_A8: + return a; + + case WW3D_FORMAT_A8R3G3B2: + return ( a << 8) | + ((r >> 5) << 5) | + ((g >> 5) << 2) | + ((b >> 6) << 0); + + case WW3D_FORMAT_X4R4G4B4: + return ( 0xF << 12) | + ((r >> 4) << 8) | + ((g >> 4) << 4) | + ((b >> 4) << 0); + + case WW3D_FORMAT_L8: + { + unsigned l = (r * 77 + g * 150 + b * 29) >> 8; + return l; + } + + case WW3D_FORMAT_A8L8: + { + unsigned l = (r * 77 + g * 150 + b * 29) >> 8; + return (a << 8) | l; + } + + case WW3D_FORMAT_A4L4: + { + unsigned l = (r * 77 + g * 150 + b * 29) >> 8; + return ((a >> 4) << 4) | (l >> 4); + } + + // Palettized, bump-map, and compressed formats + // cannot be represented by a single ARGB color + case WW3D_FORMAT_P8: + case WW3D_FORMAT_A8P8: + case WW3D_FORMAT_U8V8: + case WW3D_FORMAT_L6V5U5: + case WW3D_FORMAT_X8L8V8U8: + case WW3D_FORMAT_DXT1: + case WW3D_FORMAT_DXT2: + case WW3D_FORMAT_DXT3: + case WW3D_FORMAT_DXT4: + case WW3D_FORMAT_DXT5: + default: + return 0; + } +} + unsigned Get_Num_Depth_Bits(WW3DZFormat zformat) { switch (zformat) diff --git a/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.h b/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.h index e9f9d898742..ade7aa7cbc7 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/ww3dformat.h @@ -195,6 +195,8 @@ WW3DFormat Get_Valid_Texture_Format(WW3DFormat format,bool is_compression_allowe unsigned Get_Bytes_Per_Pixel(WW3DFormat format); +unsigned ARGB_Color_To_WW3D_Color(WW3DFormat format, unsigned argb); + void Get_WW3D_Format_Name(WW3DFormat format, StringClass& name); void Get_WW3D_ZFormat_Name(WW3DZFormat format, StringClass& name); diff --git a/Core/Libraries/Source/WWVegas/WW3D2/ww3dids.h b/Core/Libraries/Source/WWVegas/WW3D2/ww3dids.h index d308fcab62b..d6609919bfc 100644 --- a/Core/Libraries/Source/WWVegas/WW3D2/ww3dids.h +++ b/Core/Libraries/Source/WWVegas/WW3D2/ww3dids.h @@ -39,12 +39,12 @@ #include "saveloadids.h" /* -** These are the chunk-id's used by all persistant objects in WW3D. The persistant object +** These are the chunk-id's used by all persistent objects in WW3D. The persistent object ** framework is defined in the WWSaveLoad library. ** ** Sept 23, 1999 -** - Initial implementation of making the Commando engine persistant included making some -** of WW3D persistant. For this initial implementation, we're going to assume that we +** - Initial implementation of making the Commando engine persistent included making some +** of WW3D persistent. For this initial implementation, we're going to assume that we ** can re-create all of our game objects from the asset manager and patch up any state ** changes with custom game object code. Therefore, the base class RenderObjClass has ** a persist manager which simply saves the name of the render object and its transform diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AABTreeSoundCullClass.h b/Core/Libraries/Source/WWVegas/WWAudio/AABTreeSoundCullClass.h index e5e41826521..bd97c067b34 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/AABTreeSoundCullClass.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/AABTreeSoundCullClass.h @@ -53,7 +53,7 @@ class AABTreeSoundCullClass : public AABTreeCullClass // Public constructors/destructors ////////////////////////////////////////////////////////////////////// AABTreeSoundCullClass (void) - : AABTreeCullClass (NULL) { } + : AABTreeCullClass (nullptr) { } virtual ~AABTreeSoundCullClass (void) { } diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.cpp b/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.cpp index 370b4537f06..caff7eba3a8 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/AudibleSound.cpp @@ -138,12 +138,12 @@ namespace AUDIBLE_SOUND_DEF_SAVELOAD AudibleSoundClass::AudibleSoundClass (void) : m_Priority (0.5F), m_RuntimePriority (0), - m_SoundHandle (NULL), + m_SoundHandle (nullptr), m_Length (0), m_CurrentPosition (0), m_Timestamp (0), m_State (STATE_STOPPED), - m_Buffer (NULL), + m_Buffer (nullptr), m_Volume (1.0F), m_Pan (0.5F), m_LoopCount (1), @@ -152,12 +152,12 @@ AudibleSoundClass::AudibleSoundClass (void) m_bDirty (true), m_DropOffRadius (1), m_IsCulled (true), - m_pConvertedFormat (NULL), + m_pConvertedFormat (nullptr), m_PrevTransform (1), m_Transform (1), m_ListenerTransform (1), - m_Definition (NULL), - m_LogicalSound (NULL), + m_Definition (nullptr), + m_LogicalSound (nullptr), m_StartOffset (0), m_PitchFactor (1.0F) { @@ -173,12 +173,12 @@ AudibleSoundClass::AudibleSoundClass (void) AudibleSoundClass::AudibleSoundClass (const AudibleSoundClass &src) : m_Priority (0.5F), m_RuntimePriority (0), - m_SoundHandle (NULL), + m_SoundHandle (nullptr), m_Length (0), m_CurrentPosition (0), m_Timestamp (0), m_State (STATE_STOPPED), - m_Buffer (NULL), + m_Buffer (nullptr), m_Volume (1.0F), m_Pan (0.5F), m_LoopCount (1), @@ -187,11 +187,11 @@ AudibleSoundClass::AudibleSoundClass (const AudibleSoundClass &src) m_bDirty (true), m_DropOffRadius (1), m_IsCulled (true), - m_pConvertedFormat (NULL), + m_pConvertedFormat (nullptr), m_PrevTransform (1), m_Transform (1), - m_Definition (NULL), - m_LogicalSound (NULL), + m_Definition (nullptr), + m_LogicalSound (nullptr), m_StartOffset (0), m_PitchFactor (1.0F) { @@ -215,9 +215,9 @@ AudibleSoundClass::~AudibleSoundClass (void) // Delay the release of the buffer (fixes a sync bug // with Miles internals). // - if (m_Buffer != NULL) { + if (m_Buffer != nullptr) { WWAudioThreadsClass::Add_Delayed_Release_Object (m_Buffer); - m_Buffer = NULL; + m_Buffer = nullptr; } Free_Miles_Handle (); @@ -269,9 +269,9 @@ AudibleSoundClass::Set_Buffer (SoundBufferClass *buffer) // Delay the release of the buffer (fixes a sync bug // with Miles internals). // - if (m_Buffer != NULL) { + if (m_Buffer != nullptr) { WWAudioThreadsClass::Add_Delayed_Release_Object (m_Buffer); - m_Buffer = NULL; + m_Buffer = nullptr; } REF_PTR_SET (m_Buffer, buffer); @@ -282,7 +282,7 @@ AudibleSoundClass::Set_Buffer (SoundBufferClass *buffer) } // Get the time (in ms) that this buffer will play for... - if (m_Buffer != NULL) { + if (m_Buffer != nullptr) { m_Length = m_Buffer->Get_Duration (); } @@ -337,7 +337,7 @@ AudibleSoundClass::Play (bool alloc_handle) MMSLockClass lock; // If we don't have a valid handle already, try to get one from miles - if (alloc_handle && (m_pConvertedFormat == NULL)) { + if (alloc_handle && (m_pConvertedFormat == nullptr)) { Allocate_Miles_Handle (); } @@ -349,7 +349,7 @@ AudibleSoundClass::Play (bool alloc_handle) m_LoopsLeft = m_LoopCount; // If we have a valid handle, then start playing the sample - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { m_SoundHandle->Start_Sample (); } @@ -365,14 +365,14 @@ AudibleSoundClass::Play (bool alloc_handle) // // Create the associate logical sound (if necessary) // - if (m_LogicalSound == NULL && m_Definition != NULL) { + if (m_LogicalSound == nullptr && m_Definition != nullptr) { m_LogicalSound = m_Definition->Create_Logical (); } // // Add this logical sound to the scene // - if (m_LogicalSound != NULL) { + if (m_LogicalSound != nullptr) { m_LogicalSound->Set_User_Data (m_UserObj, m_UserData); m_LogicalSound->Set_Transform (m_Transform); m_LogicalSound->Add_To_Scene (); @@ -381,7 +381,7 @@ AudibleSoundClass::Play (bool alloc_handle) // // Should we send off the text notification? // - if (m_IsCulled == false && m_Definition != NULL) { + if (m_IsCulled == false && m_Definition != nullptr) { const StringClass &text = m_Definition->Get_Display_Text (); WWAudioClass::Get_Instance ()->Fire_Text_Callback (this, text); } @@ -407,7 +407,7 @@ AudibleSoundClass::Pause (void) if (m_State == STATE_PLAYING) { // Pass the pause request onto miles - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { m_SoundHandle->Stop_Sample (); } @@ -437,7 +437,7 @@ AudibleSoundClass::Resume (void) if (m_State == STATE_PAUSED) { // Pass the resume request onto miles - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { m_SoundHandle->Resume_Sample (); } @@ -468,7 +468,7 @@ AudibleSoundClass::Stop (bool remove_from_playlist) (m_State == STATE_PLAYING)) { // Actually stop the sample from playing - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { m_SoundHandle->Stop_Sample (); } @@ -488,7 +488,7 @@ AudibleSoundClass::Stop (bool remove_from_playlist) // // Stop the logical portion of the sound // - if (m_LogicalSound != NULL && m_LogicalSound->Is_Single_Shot () == false) { + if (m_LogicalSound != nullptr && m_LogicalSound->Is_Single_Shot () == false) { m_LogicalSound->Remove_From_Scene (); } } @@ -518,7 +518,7 @@ AudibleSoundClass::Seek (unsigned long milliseconds) } // Update the actual sound data if we are playing the sound - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { m_SoundHandle->Set_Sample_MS_Position (m_CurrentPosition); } } @@ -543,7 +543,7 @@ AudibleSoundClass::Set_Miles_Handle (MILES_HANDLE handle) // // Is our data valid? // - if (handle != INVALID_MILES_HANDLE && m_Buffer != NULL) { + if (handle != INVALID_MILES_HANDLE && m_Buffer != nullptr) { // // Determine which type of sound handle to create, streaming or standard 2D @@ -587,7 +587,7 @@ AudibleSoundClass::Initialize_Miles_Handle (void) } // Do we have a valid sample handle from miles? - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { // // Initialize the handle @@ -597,7 +597,7 @@ AudibleSoundClass::Initialize_Miles_Handle (void) // // Record the total length of the sample in milliseconds... // - m_SoundHandle->Get_Sample_MS_Position ((S32 *)&m_Length, NULL); + m_SoundHandle->Get_Sample_MS_Position ((S32 *)&m_Length, nullptr); // // Pass our cached settings onto miles @@ -655,24 +655,24 @@ AudibleSoundClass::Free_Miles_Handle (void) MMSLockClass lock; // Do we have a valid sample handle from miles? - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { // // Release our hold on this handle // - m_SoundHandle->Set_Sample_User_Data (INFO_OBJECT_PTR, NULL); + m_SoundHandle->Set_Sample_User_Data (INFO_OBJECT_PTR, nullptr); m_SoundHandle->End_Sample (); // // Remove the association between file handle and AudibleSoundClass object // - //m_SoundHandle->Set_Sample_User_Data (INFO_OBJECT_PTR, NULL); + //m_SoundHandle->Set_Sample_User_Data (INFO_OBJECT_PTR, nullptr); // // Free the sound handle object // delete m_SoundHandle; - m_SoundHandle = NULL; + m_SoundHandle = nullptr; } return ; @@ -692,7 +692,7 @@ AudibleSoundClass::Get_Pan (void) // // Do we have a valid sample handle from miles? // - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { m_Pan = ((float)m_SoundHandle->Get_Sample_Pan ()) / 127.0F; } @@ -719,7 +719,7 @@ AudibleSoundClass::Set_Pan (float pan) // // Do we have a valid sample handle from miles? // - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { m_SoundHandle->Set_Sample_Pan (int(m_Pan * 127.0F)); } @@ -742,9 +742,9 @@ AudibleSoundClass::Set_Pitch_Factor (float factor) // // Do we have a valid sample handle from miles? // - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { - if (m_Buffer != NULL) { + if (m_Buffer != nullptr) { // // Get the base rate of the sound and scale our playback rate @@ -772,7 +772,7 @@ AudibleSoundClass::Get_Playback_Rate (void) int retval = 0; // Do we have a valid sample handle from miles? - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { retval = m_SoundHandle->Get_Sample_Playback_Rate (); } @@ -791,7 +791,7 @@ AudibleSoundClass::Set_Playback_Rate (int rate_in_hz) MMSLockClass lock; // Do we have a valid sample handle from miles? - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { m_SoundHandle->Set_Sample_Playback_Rate (rate_in_hz); } @@ -810,7 +810,7 @@ AudibleSoundClass::Get_Volume (void) MMSLockClass lock; // Do we have a valid sample handle from miles? - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { m_Volume = ((float)m_SoundHandle->Get_Sample_Volume ()) / 127.0F; } @@ -834,7 +834,7 @@ AudibleSoundClass::Set_Volume (float volume) m_Volume = max (m_Volume, 0.0F); // Do we have a valid sample handle from miles? - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { // Calculate the 'real' volume to set based on the global volume and the sound // effect volume. @@ -872,7 +872,7 @@ AudibleSoundClass::Set_Loop_Count (int count) m_LoopCount = count; // Do we have a valid sample handle from miles? - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { m_SoundHandle->Set_Sample_Loop_Count (m_LoopCount); } @@ -915,14 +915,14 @@ AudibleSoundClass::On_Frame_Update (unsigned int milliseconds) Update_Play_Position (); } - if (m_pConvertedFormat != NULL) { + if (m_pConvertedFormat != nullptr) { m_pConvertedFormat->Re_Sync (*this); } // // Move the logical sound with the audible one... // - if (m_LogicalSound != NULL) { + if (m_LogicalSound != nullptr) { m_LogicalSound->Set_Transform (m_Transform); } @@ -973,7 +973,7 @@ AudibleSoundClass::Allocate_Miles_Handle (void) // // If we need to, get a play-handle from the audio system // - if (m_SoundHandle == NULL) { + if (m_SoundHandle == nullptr) { Set_Miles_Handle ((MILES_HANDLE)WWAudioClass::Get_Instance ()->Get_2D_Sample (*this)); } @@ -994,7 +994,7 @@ AudibleSoundClass::On_Loop_End (void) // Let the audio system know that we are done with this sound Stop (); - if (m_Scene != NULL) { + if (m_Scene != nullptr) { Remove_From_Scene (); } @@ -1039,8 +1039,8 @@ AudibleSoundClass::Determine_Real_Volume (void) const LPCTSTR AudibleSoundClass::Get_Filename (void) const { - LPCTSTR filename = NULL; - if (m_Buffer != NULL) { + LPCTSTR filename = nullptr; + if (m_Buffer != nullptr) { filename = m_Buffer->Get_Filename (); } @@ -1067,7 +1067,7 @@ AudibleSoundClass::Cull_Sound (bool culled) // Note: We also free the handle if a converted form // of the sound is currently playing. // - if (m_IsCulled || (m_pConvertedFormat != NULL)) { + if (m_IsCulled || (m_pConvertedFormat != nullptr)) { Free_Miles_Handle (); } else { Allocate_Miles_Handle (); @@ -1118,7 +1118,7 @@ void AudibleSoundClass::Add_To_Scene (bool start_playing) { SoundSceneClass *scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene (); - if ((scene != NULL) && (m_Scene == NULL)) { + if ((scene != nullptr) && (m_Scene == nullptr)) { // // Add this sound to the static culling system @@ -1139,14 +1139,14 @@ AudibleSoundClass::Add_To_Scene (bool start_playing) void AudibleSoundClass::Remove_From_Scene (void) { - if (m_Scene != NULL) { + if (m_Scene != nullptr) { // // Remove this sound from the static culling system // m_Scene->Remove_Static_Sound (this); - m_Scene = NULL; - m_PhysWrapper = NULL; + m_Scene = nullptr; + m_PhysWrapper = nullptr; } return ; @@ -1209,7 +1209,7 @@ AudibleSoundClass::Re_Sync (AudibleSoundClass &src) void AudibleSoundClass::Free_Conversion (void) { - if (m_pConvertedFormat != NULL) { + if (m_pConvertedFormat != nullptr) { m_pConvertedFormat->Stop (); REF_PTR_RELEASE (m_pConvertedFormat); } @@ -1233,7 +1233,7 @@ AudibleSoundClass::Free_Conversion (void) void AudibleSoundClass::Convert_To_Filtered (void) { - if (m_pConvertedFormat == NULL) { + if (m_pConvertedFormat == nullptr) { // // Make a copy of the sound in its new format @@ -1273,7 +1273,7 @@ AudibleSoundClass::Convert_To_Filtered (void) AudibleSoundClass * AudibleSoundClass::As_Converted_Format (void) { - if (m_pConvertedFormat == NULL) { + if (m_pConvertedFormat == nullptr) { Convert_To_Filtered (); } @@ -1382,7 +1382,7 @@ AudibleSoundDefinitionClass::Initialize_From_Sound (AudibleSoundClass *sound) // // Read the settings from the sound object // - if (sound != NULL) { + if (sound != nullptr) { Sound3DClass *sound_3d = sound->As_Sound3DClass (); // @@ -1402,14 +1402,14 @@ AudibleSoundDefinitionClass::Initialize_From_Sound (AudibleSoundClass *sound) m_Filename = sound->Get_Filename (); m_DropOffRadius = sound->Get_DropOff_Radius (); m_Priority = sound->Peek_Priority (); - m_Is3D = (sound_3d != NULL); + m_Is3D = (sound_3d != nullptr); m_Type = sound->Get_Type (); m_LoopCount = sound->Get_Loop_Count (); m_Volume = sound->Get_Volume (); m_StartOffset = sound->Get_Start_Offset (); m_PitchFactor = sound->Get_Pitch_Factor (); - if (sound_3d != NULL) { + if (sound_3d != nullptr) { m_MaxVolRadius = sound_3d->Get_Max_Vol_Radius (); } } @@ -1582,7 +1582,7 @@ AudibleSoundDefinitionClass::Create (void) const AudibleSoundClass * AudibleSoundDefinitionClass::Create_Sound (int classid_hint) const { - AudibleSoundClass *new_sound = NULL; + AudibleSoundClass *new_sound = nullptr; // // If this is a relative path, strip it off and assume @@ -1590,7 +1590,7 @@ AudibleSoundDefinitionClass::Create_Sound (int classid_hint) const // StringClass real_filename(m_Filename,true); const char *dir_delimiter = ::strrchr (m_Filename, '\\'); - if (dir_delimiter != NULL && m_Filename.Get_Length () > 2 && m_Filename[1] != ':') { + if (dir_delimiter != nullptr && m_Filename.Get_Length () > 2 && m_Filename[1] != ':') { real_filename = (dir_delimiter + 1); } @@ -1606,7 +1606,7 @@ AudibleSoundDefinitionClass::Create_Sound (int classid_hint) const // // Did we successfully create the sound? // - if (new_sound != NULL) { + if (new_sound != nullptr) { // // Configure the sound @@ -1637,7 +1637,7 @@ AudibleSoundDefinitionClass::Create_Sound (int classid_hint) const LogicalSoundClass * AudibleSoundDefinitionClass::Create_Logical (void) { - LogicalSoundClass *logical_sound = NULL; + LogicalSoundClass *logical_sound = nullptr; if (m_CreateLogical) { @@ -1699,7 +1699,7 @@ AudibleSoundClass::Save (ChunkSaveClass &csave) WRITE_MICRO_CHUNK (csave, VARID_PITCH_FACTOR, m_PitchFactor); WRITE_MICRO_CHUNK (csave, VARID_LISTENER_TRANSFORM, m_ListenerTransform); - if (m_Buffer != NULL) { + if (m_Buffer != nullptr) { WRITE_MICRO_CHUNK_STRING (csave, VARID_FILENAME, m_Buffer->Get_Filename ()); } @@ -1761,7 +1761,7 @@ AudibleSoundClass::Load (ChunkLoadClass &cload) case VARID_THIS_PTR: { - AudibleSoundClass *old_ptr = NULL; + AudibleSoundClass *old_ptr = nullptr; cload.Read(&old_ptr, sizeof (old_ptr)); SaveLoadSystemClass::Register_Pointer (old_ptr, this); } @@ -1780,8 +1780,8 @@ AudibleSoundClass::Load (ChunkLoadClass &cload) // // Reconstruct the sound buffer we had before we saved // - if (filename.Get_Length () > 0) { - bool is_3d = (As_Sound3DClass () != NULL); + if (!filename.Is_Empty()) { + bool is_3d = (As_Sound3DClass () != nullptr); SoundBufferClass *buffer = WWAudioClass::Get_Instance ()->Get_Sound_Buffer (filename, is_3d); Set_Buffer (buffer); REF_PTR_RELEASE (buffer); diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AudioEvents.h b/Core/Libraries/Source/WWVegas/WWAudio/AudioEvents.h index 0a268f93f4a..f3db72c15db 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/AudioEvents.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/AudioEvents.h @@ -60,10 +60,10 @@ class StringClass; // Callback declarations. These functions are called when a registered event occurs // in the sound library/ // -typedef void (_stdcall *LPFNSOSCALLBACK) (SoundSceneObjClass *sound_obj, uint32 user_param); -typedef void (_stdcall *LPFNEOSCALLBACK) (SoundSceneObjClass *sound_obj, uint32 user_param); -typedef void (_stdcall *LPFNHEARDCALLBACK) (LogicalListenerClass *listener, LogicalSoundClass *sound_obj, uint32 user_param); -typedef void (_stdcall *LPFNTEXTCALLBACK) (AudibleSoundClass *sound_obj, const StringClass &text, uint32 user_param); +typedef void (__stdcall *LPFNSOSCALLBACK) (SoundSceneObjClass *sound_obj, uint32 user_param); +typedef void (__stdcall *LPFNEOSCALLBACK) (SoundSceneObjClass *sound_obj, uint32 user_param); +typedef void (__stdcall *LPFNHEARDCALLBACK) (LogicalListenerClass *listener, LogicalSoundClass *sound_obj, uint32 user_param); +typedef void (__stdcall *LPFNTEXTCALLBACK) (AudibleSoundClass *sound_obj, const StringClass &text, uint32 user_param); ///////////////////////////////////////////////////////////////////////////////// @@ -129,7 +129,7 @@ struct AUDIO_CALLBACK_STRUCT uint32 user_data; AUDIO_CALLBACK_STRUCT (void) - : callback_ptr (NULL), user_data (0) {} + : callback_ptr (nullptr), user_data (0) {} AUDIO_CALLBACK_STRUCT (T _ptr, uint32 _data) : callback_ptr (_ptr), user_data (_data) {} @@ -182,7 +182,7 @@ AudioCallbackListClass::Add_Callback (T pointer, uint32 user_data) template T AudioCallbackListClass::Get_Callback (int index, uint32 *user_data) { - if (user_data != NULL) { + if (user_data != nullptr) { (*user_data) = Vector[index].user_data; } diff --git a/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.cpp b/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.cpp index 3915556f3c0..af93ac2c62a 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/AudioSaveLoad.cpp @@ -112,7 +112,7 @@ StaticAudioSaveLoadClass::Save (ChunkSaveClass &csave) // Save the static sounds // SoundSceneClass *scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene (); - if (scene != NULL) { + if (scene != nullptr) { csave.Begin_Chunk (CHUNKID_STATIC_SCENE); scene->Save_Static (csave); csave.End_Chunk (); @@ -142,7 +142,7 @@ StaticAudioSaveLoadClass::Load (ChunkLoadClass &cload) case CHUNKID_STATIC_SCENE: { SoundSceneClass *scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene (); - if (scene != NULL) { + if (scene != nullptr) { scene->Load_Static (cload); } } @@ -202,7 +202,7 @@ DynamicAudioSaveLoadClass::Save (ChunkSaveClass &csave) // Save the static sounds // SoundSceneClass *scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene (); - if (scene != NULL) { + if (scene != nullptr) { csave.Begin_Chunk (CHUNKID_DYNAMIC_VARIABLES); float global_scale = LogicalListenerClass::Get_Global_Scale (); @@ -261,7 +261,7 @@ DynamicAudioSaveLoadClass::Load (ChunkLoadClass &cload) case CHUNKID_DYNAMIC_SCENE: { SoundSceneClass *scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene (); - if (scene != NULL) { + if (scene != nullptr) { scene->Load_Dynamic (cload); } } diff --git a/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.cpp b/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.cpp index 4228bb65b09..12be84b2cfc 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/FilteredSound.cpp @@ -112,7 +112,7 @@ FilteredSoundClass::Initialize_Miles_Handle (void) { SoundPseudo3DClass::Initialize_Miles_Handle (); m_hFilter = WWAudioClass::Get_Instance ()->Get_Reverb_Filter (); - if ((m_SoundHandle != NULL) && + if ((m_SoundHandle != nullptr) && (m_hFilter != (HPROVIDER)INVALID_MILES_HANDLE)) { // @@ -152,12 +152,12 @@ FilteredSoundClass::Initialize_Miles_Handle (void) void FilteredSoundClass::Update_Volume (void) { - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { // Determine the listener's position and the sound's position SoundSceneClass *scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene (); Listener3DClass *listener = scene->Peek_2nd_Listener (); - if (listener != NULL) { + if (listener != nullptr) { Vector3 listener_pos = listener->Get_Position (); Vector3 sound_pos = m_Transform.Get_Translation (); diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Listener.cpp b/Core/Libraries/Source/WWVegas/WWAudio/Listener.cpp index 9797e5e8989..1a3cdf4a2e3 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Listener.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/Listener.cpp @@ -75,7 +75,7 @@ Listener3DClass::Initialize_Miles_Handle (void) MMSLockClass lock; // Do we have a valid sample handle from miles? - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { ::AIL_set_3D_position (m_SoundHandle->Get_H3DSAMPLE (), 0.0F, 0.0F, 0.0F); ::AIL_set_3D_orientation (m_SoundHandle->Get_H3DSAMPLE (), diff --git a/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.cpp b/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.cpp index d9227a7578b..8e2b3c15580 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/LogicalListener.cpp @@ -107,7 +107,7 @@ void LogicalListenerClass::Add_To_Scene (bool /*start_playing*/) { SoundSceneClass *scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene (); - if ((scene != NULL) && (m_Scene == NULL)) { + if ((scene != nullptr) && (m_Scene == nullptr)) { // // Add this listener to the culling system @@ -128,14 +128,14 @@ LogicalListenerClass::Add_To_Scene (bool /*start_playing*/) void LogicalListenerClass::Remove_From_Scene (void) { - if (m_Scene != NULL) { + if (m_Scene != nullptr) { // // Remove this listener from the culling system // m_Scene->Remove_Logical_Listener (this); - m_Scene = NULL; - m_PhysWrapper = NULL; + m_Scene = nullptr; + m_PhysWrapper = nullptr; } return ; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.cpp b/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.cpp index 593e407de80..55a7c18a2ae 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/LogicalSound.cpp @@ -104,7 +104,7 @@ void LogicalSoundClass::Add_To_Scene (bool /*start_playing*/) { SoundSceneClass *scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene (); - if ((scene != NULL) && (m_Scene == NULL)) { + if ((scene != nullptr) && (m_Scene == nullptr)) { // // Add this sound to the culling system @@ -125,14 +125,14 @@ LogicalSoundClass::Add_To_Scene (bool /*start_playing*/) void LogicalSoundClass::Remove_From_Scene (void) { - if (m_Scene != NULL) { + if (m_Scene != nullptr) { // // Remove this sound from the culling system // m_Scene->Remove_Logical_Sound (this, m_IsSingleShot); - m_Scene = NULL; - m_PhysWrapper = NULL; + m_Scene = nullptr; + m_PhysWrapper = nullptr; m_LastNotification = 0; } diff --git a/Core/Libraries/Source/WWVegas/WWAudio/PriorityVector.h b/Core/Libraries/Source/WWVegas/WWAudio/PriorityVector.h index a7e4fa54e39..0649522a9b1 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/PriorityVector.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/PriorityVector.h @@ -67,7 +67,7 @@ template __inline bool PriorityVectorClass::Process_Head (T &object) { bool retval = false; - if (Vector != NULL) { + if (Vector != nullptr) { // Pass the object back to the caller object = Vector[0]; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.cpp b/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.cpp index d8870718086..18be023ab38 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/Sound3D.cpp @@ -168,7 +168,7 @@ Sound3DClass::On_Frame_Update (unsigned int milliseconds) { Matrix3D prev_tm = m_PrevTransform; - if (m_bDirty && (m_PhysWrapper != NULL)) { + if (m_bDirty && (m_PhysWrapper != nullptr)) { m_Scene->Update_Sound (m_PhysWrapper); m_bDirty = false; } @@ -285,7 +285,7 @@ Sound3DClass::Update_Miles_Transform (void) // // Do we have a valid miles handle? // - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { // // Build a matrix to transform coordinates from world-space to listener-space @@ -356,7 +356,7 @@ Sound3DClass::Set_Position (const Vector3 &position) m_IsTransformInitted = true; } - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { // // Transform the sound's position into 'listener-space' @@ -393,7 +393,7 @@ Sound3DClass::Set_Velocity (const Vector3 &velocity) // // Pass the sound's velocity onto miles // - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { //WWDEBUG_SAY (("Current Velocity: %.2f %.2f %.2f", m_CurrentVelocity.X, m_CurrentVelocity.Y, m_CurrentVelocity.Z)); ::AIL_set_3D_velocity_vector (m_SoundHandle->Get_H3DSAMPLE (), @@ -420,7 +420,7 @@ Sound3DClass::Set_DropOff_Radius (float radius) Set_Dirty (); // Pass attenuation settings onto miles - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { ::AIL_set_3D_sample_distances ( m_SoundHandle->Get_H3DSAMPLE (), m_DropOffRadius, (m_MaxVolRadius > 1.0F) ? m_MaxVolRadius : 1.0F); @@ -442,7 +442,7 @@ Sound3DClass::Set_Max_Vol_Radius (float radius) Set_Dirty (); // Pass attenuation settings onto miles - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { ::AIL_set_3D_sample_distances ( m_SoundHandle->Get_H3DSAMPLE (), m_DropOffRadius, (m_MaxVolRadius > 1.0F) ? m_MaxVolRadius : 1.0F); @@ -470,7 +470,7 @@ Sound3DClass::Initialize_Miles_Handle (void) } // Do we have a valid sample handle from miles? - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { // // Pass the actual sound data onto the sample @@ -480,7 +480,7 @@ Sound3DClass::Initialize_Miles_Handle (void) // // Record the total length of the sample in milliseconds... // - m_SoundHandle->Get_Sample_MS_Position ((S32 *)&m_Length, NULL); + m_SoundHandle->Get_Sample_MS_Position ((S32 *)&m_Length, nullptr); // // Pass our cached settings onto miles @@ -552,7 +552,7 @@ Sound3DClass::Allocate_Miles_Handle (void) // // If we need to, get a play-handle from the audio system // - if (m_SoundHandle == NULL) { + if (m_SoundHandle == nullptr) { Set_Miles_Handle ((MILES_HANDLE)WWAudioClass::Get_Instance ()->Get_3D_Sample (*this)); } @@ -569,7 +569,7 @@ void Sound3DClass::Add_To_Scene (bool start_playing) { SoundSceneClass *scene = WWAudioClass::Get_Instance ()->Get_Sound_Scene (); - if ((scene != NULL) && (m_Scene == NULL)) { + if ((scene != nullptr) && (m_Scene == nullptr)) { // Determine what culling system this sound belongs to if (m_IsStatic) { @@ -592,7 +592,7 @@ Sound3DClass::Add_To_Scene (bool start_playing) void Sound3DClass::Remove_From_Scene (void) { - if (m_Scene != NULL) { + if (m_Scene != nullptr) { // Determine what culling system this sound belongs to if (m_IsStatic) { @@ -601,8 +601,8 @@ Sound3DClass::Remove_From_Scene (void) m_Scene->Remove_Sound (this); } - m_Scene = NULL; - m_PhysWrapper = NULL; + m_Scene = nullptr; + m_PhysWrapper = nullptr; } return ; @@ -718,7 +718,7 @@ Sound3DClass::Set_Miles_Handle (MILES_HANDLE handle) // // Is our data valid? // - if (handle != INVALID_MILES_HANDLE && m_Buffer != NULL) { + if (handle != INVALID_MILES_HANDLE && m_Buffer != nullptr) { // // Configure the sound handle diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundBuffer.cpp b/Core/Libraries/Source/WWVegas/WWAudio/SoundBuffer.cpp index 3896d68c5a4..95463cbdbbc 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundBuffer.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundBuffer.cpp @@ -67,9 +67,9 @@ static DynamicVectorClass MappingList; // SoundBufferClass // SoundBufferClass::SoundBufferClass (void) - : m_Buffer (NULL), + : m_Buffer (nullptr), m_Length (0), - m_Filename (NULL), + m_Filename (nullptr), m_Duration (0), m_Rate (0), m_Bits (0), @@ -101,7 +101,7 @@ SoundBufferClass::Free_Buffer (void) { // Free the buffer's memory delete [] m_Buffer; - m_Buffer = NULL; + m_Buffer = nullptr; // Make sure we reset the length m_Length = 0L; @@ -126,7 +126,7 @@ SoundBufferClass::Determine_Stats (unsigned char *buffer) // Attempt to get statistical information about this sound AILSOUNDINFO info = { 0 }; - if ((buffer != NULL) && (::AIL_WAV_info (buffer, &info) != 0)) { + if ((buffer != nullptr) && (::AIL_WAV_info (buffer, &info) != 0)) { // Cache this information m_Rate = info.rate; @@ -151,7 +151,7 @@ void SoundBufferClass::Set_Filename (const char *name) { SAFE_FREE (m_Filename); - if (name != NULL) { + if (name != nullptr) { m_Filename = ::strdup (name); } @@ -170,8 +170,8 @@ SoundBufferClass::Load_From_File (const char *filename) bool retval = false; // Param OK? - WWASSERT (filename != NULL); - if (filename != NULL) { + WWASSERT (filename != nullptr); + if (filename != nullptr) { // Create a file object and pass it onto the appropriate function FileClass *file=_TheFileFactory->Get_File(filename); @@ -179,7 +179,7 @@ SoundBufferClass::Load_From_File (const char *filename) retval = Load_From_File(*file); _TheFileFactory->Return_File(file); } - file=NULL; + file=nullptr; } // Return the true/false result code @@ -257,9 +257,9 @@ SoundBufferClass::Load_From_Memory Set_Filename ("unknown.wav"); // Params OK? - WWASSERT (mem_buffer != NULL); + WWASSERT (mem_buffer != nullptr); WWASSERT (size > 0L); - if ((mem_buffer != NULL) && (size > 0L)) { + if ((mem_buffer != nullptr) && (size > 0L)) { // Allocate a new buffer of the correct length and copy the contents // into the buffer diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundCullObj.h b/Core/Libraries/Source/WWVegas/WWAudio/SoundCullObj.h index 299a37aac94..2a463cdc7b9 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundCullObj.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundCullObj.h @@ -58,7 +58,7 @@ class SoundCullObjClass : public MultiListObjectClass, public CullableClass // Public constructors/destructors ////////////////////////////////////////////////////////////////////// SoundCullObjClass (void) - : m_SoundObj (NULL), + : m_SoundObj (nullptr), m_Transform (1) {} virtual ~SoundCullObjClass (void) { REF_PTR_RELEASE (m_SoundObj); } @@ -106,7 +106,7 @@ __inline const Matrix3D & SoundCullObjClass::Get_Transform (void) const { // Determine the transform to use - if (m_SoundObj != NULL) { + if (m_SoundObj != nullptr) { m_Transform = m_SoundObj->Get_Transform (); } @@ -121,7 +121,7 @@ SoundCullObjClass::Set_Transform (const Matrix3D &transform) m_Transform = transform; // Pass the tranform on - if (m_SoundObj != NULL) { + if (m_SoundObj != nullptr) { m_SoundObj->Set_Transform (m_Transform); Set_Cull_Box (Get_Bounding_Box ()); } @@ -136,7 +136,7 @@ SoundCullObjClass::Set_Sound_Obj (SoundSceneObjClass *sound_obj) // Start using this sound object REF_PTR_SET (m_SoundObj, sound_obj); //m_SoundObj = sound_obj; - if (m_SoundObj != NULL) { + if (m_SoundObj != nullptr) { m_Transform = m_SoundObj->Get_Transform (); Set_Cull_Box (Get_Bounding_Box ()); } @@ -149,7 +149,7 @@ __inline const AABoxClass & SoundCullObjClass::Get_Bounding_Box (void) const { // Get the 'real' values from the - if (m_SoundObj != NULL) { + if (m_SoundObj != nullptr) { m_Transform = m_SoundObj->Get_Transform (); m_AABox.Extent.X = m_SoundObj->Get_DropOff_Radius (); m_AABox.Extent.Y = m_SoundObj->Get_DropOff_Radius (); diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.cpp b/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.cpp index bbb8385f585..c9c602a6d1c 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundPseudo3D.cpp @@ -140,7 +140,7 @@ SoundPseudo3DClass::Update_Pseudo_Volume (float distance) // // Only do this if the sound is really playing // - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { float volume_mod = Determine_Real_Volume (); float max_distance = Get_DropOff_Radius (); @@ -179,7 +179,7 @@ SoundPseudo3DClass::Update_Pseudo_Volume (void) MMSLockClass lock; // Only do this if the sound is really playing - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { // // Find the difference in the sound position and its listener's position @@ -210,7 +210,7 @@ SoundPseudo3DClass::Update_Pseudo_Pan (void) // // Only do this if the sound is really playing // - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { // // Transform the sound's position into 'listener-space' @@ -272,7 +272,7 @@ SoundPseudo3DClass::On_Frame_Update (unsigned int milliseconds) { // If necessary, update the volume based on the distance // from the listener - if (m_SoundHandle != NULL) { + if (m_SoundHandle != nullptr) { Update_Pseudo_Volume (); Update_Pseudo_Pan (); } diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.cpp b/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.cpp index 9a8796b29d7..f343f101bb8 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.cpp @@ -78,8 +78,8 @@ enum // //////////////////////////////////////////////////////////////////////////////////////////////// SoundSceneClass::SoundSceneClass (void) - : m_Listener (NULL), - m_2ndListener (NULL), + : m_Listener (nullptr), + m_2ndListener (nullptr), m_MinExtents (-500, -500, -500), m_MaxExtents (500, 500, 500), m_IsBatchMode (false) @@ -152,7 +152,7 @@ SoundSceneClass::Collect_Logical_Sounds (unsigned int milliseconds, int listener } PriorityMultiListIterator priority_queue (&m_LogicalListeners); - LogicalListenerClass *listener = NULL; + LogicalListenerClass *listener = nullptr; // // Loop over as many of the listeners as we want to process this @@ -179,7 +179,7 @@ SoundSceneClass::Collect_Logical_Sounds (unsigned int milliseconds, int listener // SoundCullObjClass * cull_obj; for ( cull_obj = m_LogicalCullingSystem.Get_First_Collected_Object(); - cull_obj != NULL; + cull_obj != nullptr; cull_obj = m_LogicalCullingSystem.Get_Next_Collected_Object (cull_obj)) { // @@ -262,9 +262,9 @@ SoundSceneClass::Collect_Audible_Sounds // they are 'really' audible. The culling systems just check bounding boxes // but we need to be able to check attenuation spheres. // - SoundCullObjClass * cull_obj = NULL; + SoundCullObjClass * cull_obj = nullptr; for ( cull_obj = m_DynamicCullingSystem.Get_First_Collected_Object(); - cull_obj != NULL; + cull_obj != nullptr; cull_obj = m_DynamicCullingSystem.Get_Next_Collected_Object(cull_obj)) { // Get a pointer to the current 'cull-sound' object @@ -297,7 +297,7 @@ SoundSceneClass::Collect_Audible_Sounds // but we need to be able to check attenuation spheres. // for ( cull_obj = m_StaticCullingSystem.Get_First_Collected_Object(); - cull_obj != NULL; + cull_obj != nullptr; cull_obj = m_StaticCullingSystem.Get_Next_Collected_Object(cull_obj)) { AudibleSoundClass *sound_obj = (AudibleSoundClass *)cull_obj->Peek_Sound_Obj (); @@ -347,7 +347,7 @@ SoundSceneClass::On_Frame_Update (unsigned int milliseconds) // // First, collect any auxiliary sounds that are audible // - if (m_2ndListener != NULL) { + if (m_2ndListener != nullptr) { m_2ndListener->On_Frame_Update (milliseconds); Collect_Audible_Sounds (m_2ndListener, auxiliary_sounds); } @@ -436,7 +436,7 @@ SoundSceneClass::On_Frame_Update (unsigned int milliseconds) // /*aux_info.sound_obj->Convert_To_Filtered (); AudibleSoundClass *tinny_sound = aux_info.sound_obj->As_Converted_Format (); - if (tinny_sound != NULL) { + if (tinny_sound != nullptr) { audible_sounds.Add (tinny_sound); }*/ @@ -480,7 +480,7 @@ SoundSceneClass::On_Frame_Update (unsigned int milliseconds) // // Make sure we cull the sound // - WWASSERT(sound_obj != NULL); + WWASSERT(sound_obj != nullptr); sound_obj->Cull_Sound (true); sound_obj->Set_Runtime_Priority (0); } @@ -527,8 +527,8 @@ SoundSceneClass::Add_Sound WWPROFILE ("Add_Sound"); WWMEMLOG(MEM_SOUND); - WWASSERT (sound_obj != NULL); - if (sound_obj != NULL && sound_obj->Is_In_Scene () == false) { + WWASSERT (sound_obj != nullptr); + if (sound_obj != nullptr && sound_obj->Is_In_Scene () == false) { bool cull_sound = true; @@ -598,7 +598,7 @@ SoundSceneClass::Remove_Sound { WWPROFILE ("Remove_Sound"); - if (sound_obj == NULL) { + if (sound_obj == nullptr) { return ; } @@ -613,7 +613,7 @@ SoundSceneClass::Remove_Sound // Is this sound really in the scene? // SoundCullObjClass *cull_obj = sound_obj->Peek_Cullable_Wrapper (); - if (cull_obj != NULL && m_DynamicSounds.Is_In_List (cull_obj)) { + if (cull_obj != nullptr && m_DynamicSounds.Is_In_List (cull_obj)) { // // Stop playing the sound if necessary @@ -625,7 +625,7 @@ SoundSceneClass::Remove_Sound // // Flush the sound's cull-wrapper since we are removing it from the scene // - sound_obj->Set_Cullable_Wrapper (NULL); + sound_obj->Set_Cullable_Wrapper (nullptr); // // Remove this sound from the dynamic culling system @@ -657,14 +657,14 @@ SoundSceneClass::Add_Static_Sound { WWPROFILE ("Add_Static_Sound"); - WWASSERT (sound_obj != NULL); - if (sound_obj != NULL) { + WWASSERT (sound_obj != nullptr); + if (sound_obj != nullptr) { // // Check to see if this sound is already in the scene // SoundCullObjClass *cull_obj = sound_obj->Peek_Cullable_Wrapper (); - if (cull_obj == NULL) { + if (cull_obj == nullptr) { // // Create a wrapper object for the sound that we can use @@ -738,7 +738,7 @@ SoundSceneClass::Remove_Static_Sound { WWPROFILE ("Remove_Static_Sound"); - if (sound_obj == NULL) { + if (sound_obj == nullptr) { return ; } @@ -753,7 +753,7 @@ SoundSceneClass::Remove_Static_Sound // Is this sound really in the scene? // SoundCullObjClass *cull_obj = sound_obj->Peek_Cullable_Wrapper (); - if (cull_obj != NULL && m_StaticSounds.Is_In_List (cull_obj)) { + if (cull_obj != nullptr && m_StaticSounds.Is_In_List (cull_obj)) { // // Stop playing the sound if necessary @@ -765,7 +765,7 @@ SoundSceneClass::Remove_Static_Sound // // Flush the sound's cull-wrapper since we are removing it from the scene // - sound_obj->Set_Cullable_Wrapper (NULL); + sound_obj->Set_Cullable_Wrapper (nullptr); // // Remove this sound from the static culling system @@ -797,8 +797,8 @@ SoundSceneClass::Add_Logical_Sound { WWPROFILE ("Add_Logical_Sound"); - WWASSERT (sound_obj != NULL); - if (sound_obj != NULL) { + WWASSERT (sound_obj != nullptr); + if (sound_obj != nullptr) { // // Check to make sure we don't add this sound twice @@ -860,7 +860,7 @@ SoundSceneClass::Remove_Logical_Sound { WWPROFILE ("Remove_Logical_Sound"); - if (sound_obj == NULL) { + if (sound_obj == nullptr) { return ; } @@ -887,7 +887,7 @@ SoundSceneClass::Remove_Logical_Sound // // Remove this sound obj's wrapper // - sound_obj->Set_Cullable_Wrapper (NULL); + sound_obj->Set_Cullable_Wrapper (nullptr); WWAudioThreadsClass::Add_Delayed_Release_Object (cull_obj); // @@ -919,7 +919,7 @@ SoundSceneClass::Remove_Logical_Sound // // Remove this sound obj's wrapper // - sound_obj->Set_Cullable_Wrapper (NULL); + sound_obj->Set_Cullable_Wrapper (nullptr); WWAudioThreadsClass::Add_Delayed_Release_Object (cull_obj); // @@ -943,8 +943,8 @@ SoundSceneClass::Add_Logical_Listener (LogicalListenerClass *listener_obj) { WWPROFILE ("Add_Logical_Listener"); - WWASSERT (listener_obj != NULL); - if (listener_obj != NULL) { + WWASSERT (listener_obj != nullptr); + if (listener_obj != nullptr) { // // Add the listener to the 'scene' if its in our list @@ -970,8 +970,8 @@ SoundSceneClass::Remove_Logical_Listener (LogicalListenerClass *listener_obj) { WWPROFILE ("Remove_Logical_Listener"); - WWASSERT (listener_obj != NULL); - if (listener_obj != NULL) { + WWASSERT (listener_obj != nullptr); + if (listener_obj != nullptr) { // // Remove the listener from the 'scene' if its in our list @@ -994,7 +994,7 @@ SoundSceneClass::Remove_Logical_Listener (LogicalListenerClass *listener_obj) void SoundSceneClass::Update_Sound (SoundCullObjClass *sound_obj) { - if (sound_obj != NULL) { + if (sound_obj != nullptr) { sound_obj->Set_Cull_Box(sound_obj->Get_Bounding_Box()); } @@ -1031,7 +1031,7 @@ SoundSceneClass::Is_Sound_In_Scene (AudibleSoundClass *sound_obj, bool all) // lists. // SoundCullObjClass *cull_obj = sound_obj->Peek_Cullable_Wrapper (); - if (cull_obj != NULL) { + if (cull_obj != nullptr) { retval = (m_DynamicSounds.Is_In_List (cull_obj) || m_StaticSounds.Is_In_List (cull_obj)); } @@ -1112,7 +1112,7 @@ SoundSceneClass::Save_Static_Sounds (ChunkSaveClass &csave) // Get the sound from its cull object // AudibleSoundClass *sound_obj = (AudibleSoundClass *)cull_obj->Peek_Sound_Obj (); - if (sound_obj != NULL) { + if (sound_obj != nullptr) { // // Have the sound's factory save it @@ -1141,9 +1141,9 @@ SoundSceneClass::Load_Static_Sounds (ChunkLoadClass &cload) // Load this sound from the chunk (if possible) // PersistFactoryClass *factory = SaveLoadSystemClass::Find_Persist_Factory (cload.Cur_Chunk_ID ()); - if (factory != NULL) { + if (factory != nullptr) { AudibleSoundClass *sound_obj = (AudibleSoundClass *)factory->Load (cload); - if (sound_obj != NULL) { + if (sound_obj != nullptr) { sound_obj->Add_To_Scene (true); REF_PTR_RELEASE (sound_obj); } @@ -1258,7 +1258,7 @@ SoundSceneClass::Flush_Scene (void) SoundCullObjClass *cull_obj = temp_static_it.Peek_Obj (); AudibleSoundClass *sound_obj = (AudibleSoundClass *)cull_obj->Peek_Sound_Obj (); - if (sound_obj != NULL) { + if (sound_obj != nullptr) { Remove_Static_Sound (sound_obj); } } @@ -1271,7 +1271,7 @@ SoundSceneClass::Flush_Scene (void) SoundCullObjClass *cull_obj = temp_dynamic_it.Peek_Obj (); AudibleSoundClass *sound_obj = (AudibleSoundClass *)cull_obj->Peek_Sound_Obj (); - if (sound_obj != NULL) { + if (sound_obj != nullptr) { Remove_Sound (sound_obj); } } @@ -1288,11 +1288,11 @@ SoundSceneClass::Flush_Scene (void) void SoundSceneClass::Set_2nd_Listener (Listener3DClass *listener) { - if (m_2ndListener != NULL) { + if (m_2ndListener != nullptr) { m_2ndListener->On_Removed_From_Scene (); } - if (listener != NULL) { + if (listener != nullptr) { listener->On_Added_To_Scene (); } diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.h b/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.h index ef2620e4da7..cbb8f10f3c4 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundScene.h @@ -177,7 +177,7 @@ class SoundSceneClass { public: AudibleInfoClass (void) - : sound_obj (NULL), + : sound_obj (nullptr), distance2 (0) { } AudibleInfoClass (AudibleSoundClass *obj, float dist2) diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.cpp b/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.cpp index e9aceda67e5..a0efe123fdf 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.cpp @@ -69,13 +69,13 @@ CriticalSectionClass SoundSceneObjClass::m_IDListMutex; ////////////////////////////////////////////////////////////////////////////////// -// Mutex managment +// Mutex management ////////////////////////////////////////////////////////////////////////////////// /* class HandleMgrClass { public: - HandleMgrClass (void) { SoundSceneObjClass::m_IDListMutex = ::CreateMutex (NULL, FALSE, NULL); } + HandleMgrClass (void) { SoundSceneObjClass::m_IDListMutex = ::CreateMutex (nullptr, FALSE, nullptr); } ~HandleMgrClass (void) { ::CloseHandle (SoundSceneObjClass::m_IDListMutex); } }; @@ -89,12 +89,12 @@ HandleMgrClass _GlobalMutexHandleMgr; // //////////////////////////////////////////////////////////////////////////////////////////////// SoundSceneObjClass::SoundSceneObjClass (void) - : m_Scene (NULL), - m_PhysWrapper (NULL), - m_pCallback (NULL), - m_AttachedObject (NULL), + : m_Scene (nullptr), + m_PhysWrapper (nullptr), + m_pCallback (nullptr), + m_AttachedObject (nullptr), m_UserData (0), - m_UserObj (NULL), + m_UserObj (nullptr), m_ID (SOUND_OBJ_DEFAULT_ID), m_RegisteredEvents (AudioCallbackClass::EVENT_NONE) { @@ -111,12 +111,12 @@ SoundSceneObjClass::SoundSceneObjClass (void) // //////////////////////////////////////////////////////////////////////////////////////////////// SoundSceneObjClass::SoundSceneObjClass (const SoundSceneObjClass &src) - : m_Scene (NULL), - m_PhysWrapper (NULL), - m_pCallback (NULL), - m_AttachedObject (NULL), + : m_Scene (nullptr), + m_PhysWrapper (nullptr), + m_pCallback (nullptr), + m_AttachedObject (nullptr), m_UserData (0), - m_UserObj (NULL), + m_UserObj (nullptr), m_ID (SOUND_OBJ_DEFAULT_ID), m_RegisteredEvents (AudioCallbackClass::EVENT_NONE) { @@ -175,7 +175,7 @@ SoundSceneObjClass::Attach_To_Object { REF_PTR_SET (m_AttachedObject, render_obj); - if (m_AttachedObject != NULL && bone_name != NULL) { + if (m_AttachedObject != nullptr && bone_name != nullptr) { m_AttachedBone = m_AttachedObject->Get_Bone_Index (bone_name); } else { m_AttachedBone = -1; @@ -225,7 +225,7 @@ SoundSceneObjClass::Apply_Auto_Position (void) { // If the sound is attached to an object, then update its transform // based on this link. - if (m_AttachedObject != NULL) { + if (m_AttachedObject != nullptr) { // Determine which transform to use Matrix3D transform (1); @@ -336,7 +336,7 @@ SoundSceneObjClass::Load (ChunkLoadClass &cload) // We need to 'swizzle' the attached object pointer. We saved the pointer's // value, and need to map it (hopefully) to the new value. // - if (m_AttachedObject != NULL) { + if (m_AttachedObject != nullptr) { SaveLoadSystemClass::Request_Ref_Counted_Pointer_Remap ((RefCountClass **)&m_AttachedObject); } diff --git a/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.h b/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.h index f0580edfb6a..384d35cf81b 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/SoundSceneObj.h @@ -103,11 +103,11 @@ class SoundSceneObjClass : public MultiListObjectClass, public PersistClass, pub ////////////////////////////////////////////////////////////////////// // Conversion methods ////////////////////////////////////////////////////////////////////// - virtual Sound3DClass * As_Sound3DClass (void) { return NULL; } - virtual SoundPseudo3DClass * As_SoundPseudo3DClass (void) { return NULL; } - virtual FilteredSoundClass * As_FilteredSoundClass (void) { return NULL; } - virtual Listener3DClass * As_Listener3DClass (void) { return NULL; } - virtual AudibleSoundClass * As_AudibleSoundClass(void) { return NULL; } + virtual Sound3DClass * As_Sound3DClass (void) { return nullptr; } + virtual SoundPseudo3DClass * As_SoundPseudo3DClass (void) { return nullptr; } + virtual FilteredSoundClass * As_FilteredSoundClass (void) { return nullptr; } + virtual Listener3DClass * As_Listener3DClass (void) { return nullptr; } + virtual AudibleSoundClass * As_AudibleSoundClass(void) { return nullptr; } ////////////////////////////////////////////////////////////////////// // Identification methods @@ -145,7 +145,7 @@ class SoundSceneObjClass : public MultiListObjectClass, public PersistClass, pub ////////////////////////////////////////////////////////////////////// // User data methods ////////////////////////////////////////////////////////////////////// - virtual void Set_User_Data (RefCountClass *user_obj = NULL, uint32 user = 0) { REF_PTR_SET (m_UserObj, user_obj); m_UserData = user; } + virtual void Set_User_Data (RefCountClass *user_obj = nullptr, uint32 user = 0) { REF_PTR_SET (m_UserObj, user_obj); m_UserData = user; } virtual uint32 Get_User_Data (void) const { return m_UserData; } virtual RefCountClass *Peek_User_Obj (void) const { return m_UserObj; } @@ -163,7 +163,7 @@ class SoundSceneObjClass : public MultiListObjectClass, public PersistClass, pub ////////////////////////////////////////////////////////////////////// virtual void Add_To_Scene (bool start_playing = true) = 0; virtual void Remove_From_Scene (void) = 0; - virtual bool Is_In_Scene (void) const { return m_Scene != NULL; } + virtual bool Is_In_Scene (void) const { return m_Scene != nullptr; } ////////////////////////////////////////////////////////////////////// // Attenuation settings @@ -190,7 +190,7 @@ class SoundSceneObjClass : public MultiListObjectClass, public PersistClass, pub virtual void Set_Cullable_Wrapper (SoundCullObjClass *obj) { m_PhysWrapper = obj; } ////////////////////////////////////////////////////////////////////// - // Sound object managment + // Sound object management ////////////////////////////////////////////////////////////////////// static void Register_Sound_Object (SoundSceneObjClass *sound_obj); static void Unregister_Sound_Object (SoundSceneObjClass *sound_obj); @@ -229,7 +229,7 @@ SoundSceneObjClass::On_Event uint32 param2 ) { - if ((m_pCallback != NULL) && (m_RegisteredEvents & event)) { + if ((m_pCallback != nullptr) && (m_RegisteredEvents & event)) { switch (event) { diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Threads.cpp b/Core/Libraries/Source/WWVegas/WWAudio/Threads.cpp index 65d62e83a84..28996c7f799 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Threads.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/Threads.cpp @@ -39,7 +39,7 @@ /////////////////////////////////////////////////////////////////////////////////////////// // Static member initialization /////////////////////////////////////////////////////////////////////////////////////////// -WWAudioThreadsClass::DELAYED_RELEASE_INFO * WWAudioThreadsClass::m_ReleaseListHead = NULL; +WWAudioThreadsClass::DELAYED_RELEASE_INFO * WWAudioThreadsClass::m_ReleaseListHead = nullptr; CriticalSectionClass WWAudioThreadsClass::m_ListMutex; HANDLE WWAudioThreadsClass::m_hDelayedReleaseThread = (HANDLE)-1; HANDLE WWAudioThreadsClass::m_hDelayedReleaseEvent = (HANDLE)-1; @@ -79,7 +79,7 @@ WWAudioThreadsClass::Create_Delayed_Release_Thread (LPVOID param) // If the thread isn't already running, then // if (m_hDelayedReleaseThread == (HANDLE)-1) { - m_hDelayedReleaseEvent = ::CreateEvent (NULL, FALSE, FALSE, NULL); + m_hDelayedReleaseEvent = ::CreateEvent (nullptr, FALSE, FALSE, nullptr); m_hDelayedReleaseThread = (HANDLE)::_beginthread (Delayed_Release_Thread_Proc, 0, param); } @@ -174,9 +174,9 @@ WWAudioThreadsClass::Flush_Delayed_Release_Objects (void) // Loop through all the objects in our delay list, and // free them now. // - DELAYED_RELEASE_INFO *info = NULL; - DELAYED_RELEASE_INFO *next = NULL; - for (info = m_ReleaseListHead; info != NULL; info = next) { + DELAYED_RELEASE_INFO *info = nullptr; + DELAYED_RELEASE_INFO *next = nullptr; + for (info = m_ReleaseListHead; info != nullptr; info = next) { next = info->next; // @@ -186,7 +186,7 @@ WWAudioThreadsClass::Flush_Delayed_Release_Objects (void) SAFE_DELETE (info); } - m_ReleaseListHead = NULL; + m_ReleaseListHead = nullptr; return ; } @@ -215,10 +215,10 @@ WWAudioThreadsClass::Delayed_Release_Thread_Proc (LPVOID /*param*/) // free any that have expired. // DWORD current_time = ::GetTickCount (); - DELAYED_RELEASE_INFO *curr = NULL; - DELAYED_RELEASE_INFO *prev = NULL; - DELAYED_RELEASE_INFO *next = NULL; - for (curr = m_ReleaseListHead; curr != NULL; curr = next) { + DELAYED_RELEASE_INFO *curr = nullptr; + DELAYED_RELEASE_INFO *prev = nullptr; + DELAYED_RELEASE_INFO *next = nullptr; + for (curr = m_ReleaseListHead; curr != nullptr; curr = next) { next = curr->next; // @@ -229,7 +229,7 @@ WWAudioThreadsClass::Delayed_Release_Thread_Proc (LPVOID /*param*/) // // Unlink the object // - if (prev == NULL) { + if (prev == nullptr) { m_ReleaseListHead = next; } else { prev->next = next; @@ -271,7 +271,7 @@ WWAudioThreadsClass::Begin_Modify_List (void) // // Wait for up to one second to modify the list object // - if (m_ListMutex != NULL) { + if (m_ListMutex != nullptr) { retval = (::WaitForSingleObject (m_ListMutex, 1000) == WAIT_OBJECT_0); WWASSERT (retval); } @@ -291,7 +291,7 @@ WWAudioThreadsClass::End_Modify_List (void) // // Release this thread's hold on the mutex object. // - if (m_ListMutex != NULL) { + if (m_ListMutex != nullptr) { ::ReleaseMutex (m_ListMutex); } diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Threads.h b/Core/Libraries/Source/WWVegas/WWAudio/Threads.h index 17af4841b5e..c013bfdfb2c 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Threads.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/Threads.h @@ -65,7 +65,7 @@ class WWAudioThreadsClass // // Delayed release mechanism // - static HANDLE Create_Delayed_Release_Thread (LPVOID param = NULL); + static HANDLE Create_Delayed_Release_Thread (LPVOID param = nullptr); static void End_Delayed_Release_Thread (DWORD timeout = 20000); static void Add_Delayed_Release_Object (RefCountClass *object, DWORD delay = 2000); static void Flush_Delayed_Release_Objects (void); diff --git a/Core/Libraries/Source/WWVegas/WWAudio/Utils.h b/Core/Libraries/Source/WWVegas/WWAudio/Utils.h index ffff71bff50..49af4be2615 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/Utils.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/Utils.h @@ -44,11 +44,11 @@ // // Macros // -#define SAFE_DELETE(pobject) { delete pobject; pobject = NULL; } +#define SAFE_DELETE(pobject) { delete pobject; pobject = nullptr; } -#define SAFE_DELETE_ARRAY(pobject) { delete [] pobject; pobject = NULL; } +#define SAFE_DELETE_ARRAY(pobject) { delete [] pobject; pobject = nullptr; } -#define SAFE_FREE(pobject) { ::free (pobject); pobject = NULL; } +#define SAFE_FREE(pobject) { ::free (pobject); pobject = nullptr; } ///////////////////////////////////////////////////////////////////////////// @@ -74,9 +74,9 @@ class MMSLockClass __inline LPCTSTR Get_Filename_From_Path (LPCTSTR path) { - // Find the last occurance of the directory deliminator + // Find the last occurrence of the directory deliminator LPCTSTR filename = ::strrchr (path, '\\'); - if (filename != NULL) { + if (filename != nullptr) { // Increment past the directory deliminator filename ++; } else { diff --git a/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp b/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp index 6590cbe88c7..ca2a18ac0af 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.cpp @@ -65,8 +65,8 @@ //////////////////////////////////////////////////////////////////////////////////////////////// // Static member initialization //////////////////////////////////////////////////////////////////////////////////////////////// -WWAudioClass *WWAudioClass::_theInstance = NULL; -HANDLE WWAudioClass::_TimerSyncEvent = NULL; +WWAudioClass *WWAudioClass::_theInstance = nullptr; +HANDLE WWAudioClass::_TimerSyncEvent = nullptr; //////////////////////////////////////////////////////////////////////////////////////////////// @@ -104,14 +104,14 @@ WWAudioClass::Is_OK_To_Give_Handle (const AudibleSoundClass &sound_obj) // //////////////////////////////////////////////////////////////////////////////////////////////// WWAudioClass::WWAudioClass (void) - : m_Driver2D (NULL), - m_Driver3D (NULL), + : m_Driver2D (nullptr), + m_Driver3D (nullptr), m_PlaybackRate (44100), m_PlaybackBits (16), m_PlaybackStereo (true), m_ReverbFilter ((HPROVIDER)INVALID_MILES_HANDLE), m_UpdateTimer (-1), - m_Driver3DPseudo (NULL), + m_Driver3DPseudo (nullptr), m_MusicVolume (DEF_MUSIC_VOL), m_SoundVolume (DEF_SFX_VOL), m_MaxCacheSize (DEF_CACHE_SIZE * 1024), @@ -120,10 +120,10 @@ WWAudioClass::WWAudioClass (void) m_Max3DSamples (DEF_3D_SAMPLE_COUNT), m_Max2DBufferSize (DEF_MAX_2D_BUFFER_SIZE), m_Max3DBufferSize (DEF_MAX_3D_BUFFER_SIZE), - m_SoundScene (NULL), + m_SoundScene (nullptr), m_IsMusicEnabled (true), m_AreSoundEffectsEnabled (true), - m_FileFactory (NULL), + m_FileFactory (nullptr), m_EffectsLevel (0), m_ReverbRoomType (ENVIRONMENT_GENERIC) { @@ -134,7 +134,7 @@ WWAudioClass::WWAudioClass (void) // AIL_startup (); _theInstance = this; - _TimerSyncEvent = ::CreateEvent (NULL, TRUE, FALSE, "WWAUDIO_TIMER_SYNC"); + _TimerSyncEvent = ::CreateEvent (nullptr, TRUE, FALSE, "WWAUDIO_TIMER_SYNC"); // // Set some default values @@ -162,9 +162,9 @@ WWAudioClass::~WWAudioClass (void) WWAudioThreadsClass::End_Delayed_Release_Thread (); Shutdown (); - _theInstance = NULL; + _theInstance = nullptr; ::CloseHandle(_TimerSyncEvent); - _TimerSyncEvent = NULL; + _TimerSyncEvent = nullptr; ::DeleteCriticalSection (&MMSLockClass::_MSSLockCriticalSection); @@ -184,7 +184,7 @@ WWAudioClass::~WWAudioClass (void) void WWAudioClass::Flush_Cache (void) { - // Loop through all the hash indicies + // Loop through all the hash indices for (int hash_index = 0; hash_index < MAX_CACHE_HASH; hash_index ++) { // Loop through all the buffers at this hash index and free them all @@ -238,11 +238,11 @@ WWAudioClass::Open_2D_Device (LPWAVEFORMAT format) WWASSERT (success == AIL_NO_ERROR); // Open the driver - success = ::AIL_waveOutOpen (&m_Driver2D, NULL, 0, format); + success = ::AIL_waveOutOpen (&m_Driver2D, nullptr, 0, format); // Do we need to switch from direct sound to waveout? if ((success == AIL_NO_ERROR) && - (m_Driver2D != NULL) && + (m_Driver2D != nullptr) && (m_Driver2D->emulated_ds == TRUE)) { ::AIL_waveOutClose (m_Driver2D); success = 2; @@ -258,7 +258,7 @@ WWAudioClass::Open_2D_Device (LPWAVEFORMAT format) WWASSERT (success == AIL_NO_ERROR); // Open the driver - success = ::AIL_waveOutOpen (&m_Driver2D, NULL, 0, format); + success = ::AIL_waveOutOpen (&m_Driver2D, nullptr, 0, format); WWASSERT (success == AIL_NO_ERROR); type = (success == AIL_NO_ERROR) ? DRIVER2D_WAVEOUT : DRIVER2D_ERROR; } @@ -337,13 +337,13 @@ WWAudioClass::Close_2D_Device (void) // // Do we have an open driver handle to close? // - if (m_Driver2D != NULL) { + if (m_Driver2D != nullptr) { // // Close the driver // ::AIL_waveOutClose (m_Driver2D); - m_Driver2D = NULL; + m_Driver2D = nullptr; retval = true; } @@ -366,9 +366,9 @@ WWAudioClass::Get_Sound_Buffer (const char *filename, bool is_3d) // Try to find the buffer in our cache, otherwise create a new buffer. // SoundBufferClass *buffer = Find_Cached_Buffer (filename); - if (buffer == NULL) { + if (buffer == nullptr) { FileClass *file = Get_File (filename); - if (file != NULL && file->Is_Available ()) { + if (file != nullptr && file->Is_Available ()) { buffer = Create_Sound_Buffer (*file, filename, is_3d); } else { static int count = 0; @@ -397,7 +397,7 @@ WWAudioClass::Get_Sound_Buffer (FileClass &file, const char *string_id, bool is_ // Try to find the buffer in our cache, otherwise create a new buffer. // SoundBufferClass *buffer = Find_Cached_Buffer (string_id); - if (buffer == NULL) { + if (buffer == nullptr) { buffer = Create_Sound_Buffer (file, string_id, is_3d); } @@ -413,11 +413,11 @@ WWAudioClass::Get_Sound_Buffer (FileClass &file, const char *string_id, bool is_ SoundBufferClass * WWAudioClass::Find_Cached_Buffer (const char *string_id) { - SoundBufferClass *sound_buffer = NULL; + SoundBufferClass *sound_buffer = nullptr; // Param OK? - WWASSERT (string_id != NULL); - if (string_id != NULL) { + WWASSERT (string_id != nullptr); + if (string_id != nullptr) { // // Determine which index in our hash table to use @@ -459,7 +459,7 @@ WWAudioClass::Free_Cache_Space (int bytes) { int bytes_freed = 0; - // Loop through all the hash indicies + // Loop through all the hash indices for (int hash_index = 0; (hash_index < MAX_CACHE_HASH) && (bytes_freed < bytes); hash_index ++) { @@ -471,7 +471,7 @@ WWAudioClass::Free_Cache_Space (int bytes) // Can we free this cached buffer? CACHE_ENTRY_STRUCT &info = m_CachedBuffers[hash_index][index]; - if ((info.buffer != NULL) && (info.buffer->Num_Refs () == 1)) { + if ((info.buffer != nullptr) && (info.buffer->Num_Refs () == 1)) { // Add the size of this buffer to our count of bytes freed bytes_freed += info.buffer->Get_Raw_Length (); @@ -512,10 +512,10 @@ WWAudioClass::Cache_Buffer bool retval = false; // Params OK? - WWASSERT (buffer != NULL); - WWASSERT (string_id != NULL); - if ((buffer != NULL) && - (string_id != NULL) && + WWASSERT (buffer != nullptr); + WWASSERT (string_id != nullptr); + if ((buffer != nullptr) && + (string_id != nullptr) && (buffer->Get_Raw_Length () < (U32)(m_MaxCacheSize / 2))) { // Attempt to free space in the cache (if needed) @@ -565,7 +565,7 @@ WWAudioClass::Create_Sound_Buffer bool is_3d ) { - SoundBufferClass *sound_buffer = NULL; + SoundBufferClass *sound_buffer = nullptr; // // Determine how large this buffer can be @@ -591,8 +591,8 @@ WWAudioClass::Create_Sound_Buffer WWASSERT (success); // If we were successful in creating the sound buffer, then - // try to cache it as well, otherwise free the buffer and return NULL. - if (success && (string_id != NULL)) { + // try to cache it as well, otherwise free the buffer and return null. + if (success && (string_id != nullptr)) { Cache_Buffer (sound_buffer, string_id); } else if (success == false) { REF_PTR_RELEASE (sound_buffer); @@ -629,8 +629,8 @@ WWAudioClass::Create_Sound_Buffer WWASSERT (success); // If we were successful in creating the sound buffer, then - // try to cache it as well, otherwise free the buffer and return NULL. - if (success && (string_id != NULL)) { + // try to cache it as well, otherwise free the buffer and return null. + if (success && (string_id != nullptr)) { Cache_Buffer (sound_buffer, string_id); } else if (success == false) { REF_PTR_RELEASE (sound_buffer); @@ -675,12 +675,12 @@ AudibleSoundClass * WWAudioClass::Create_Sound_Effect (const char *filename) { // Assume failure - AudibleSoundClass *sound_obj = NULL; + AudibleSoundClass *sound_obj = nullptr; if (Is_Disabled () == false) { // Param OK? - WWASSERT (filename != NULL); - if (filename != NULL) { + WWASSERT (filename != nullptr); + if (filename != nullptr) { // Create a file object and pass it onto the appropriate function FileClass *file = Get_File (filename); @@ -718,7 +718,7 @@ WWAudioClass::Create_Sound_Effect // Try to find the buffer in our cache, otherwise create a new buffer. SoundBufferClass *buffer = Find_Cached_Buffer (string_id); - if (buffer == NULL) { + if (buffer == nullptr) { buffer = Create_Sound_Buffer (raw_wave_data, bytes, string_id, false); } @@ -740,7 +740,7 @@ WWAudioClass::Create_Sound_Effect Sound3DClass * WWAudioClass::Create_3D_Sound (FileClass &file, const char *string_id, int classid_hint) { - Sound3DClass *sound_obj = NULL; + Sound3DClass *sound_obj = nullptr; if (Is_Disabled () == false) { // Try to find the buffer in our cache, otherwise create a new buffer. @@ -755,7 +755,7 @@ WWAudioClass::Create_3D_Sound (FileClass &file, const char *string_id, int class { sound_obj = W3DNEW SoundPseudo3DClass; sound_obj->Set_Buffer (buffer); - } else if (buffer != NULL) { + } else if (buffer != nullptr) { sound_obj = W3DNEW Sound3DClass; sound_obj->Set_Buffer (buffer); } @@ -783,12 +783,12 @@ WWAudioClass::Create_3D_Sound WWMEMLOG(MEM_SOUND); // Assume failure - Sound3DClass *sound_obj = NULL; + Sound3DClass *sound_obj = nullptr; if (Is_Disabled () == false) { // Param OK? - WWASSERT (filename != NULL); - if (filename != NULL) { + WWASSERT (filename != nullptr); + if (filename != nullptr) { // Try to find the buffer in our cache, otherwise create a new buffer. SoundBufferClass *buffer = Get_Sound_Buffer (filename, true); @@ -802,7 +802,7 @@ WWAudioClass::Create_3D_Sound { sound_obj = W3DNEW SoundPseudo3DClass; sound_obj->Set_Buffer (buffer); - } else if (buffer != NULL) { + } else if (buffer != nullptr) { sound_obj = W3DNEW Sound3DClass; sound_obj->Set_Buffer (buffer); } else { @@ -835,14 +835,14 @@ WWAudioClass::Create_3D_Sound int classid_hint ) { - Sound3DClass *sound_obj = NULL; + Sound3DClass *sound_obj = nullptr; if (Is_Disabled () == false) { // // Try to find the buffer in our cache, otherwise create a new buffer. // SoundBufferClass *buffer = Find_Cached_Buffer (string_id); - if (buffer == NULL) { + if (buffer == nullptr) { buffer = Create_Sound_Buffer (raw_wave_data, bytes, string_id, true); } @@ -855,7 +855,7 @@ WWAudioClass::Create_3D_Sound { sound_obj = W3DNEW SoundPseudo3DClass; sound_obj->Set_Buffer (buffer); - } else if (buffer != NULL) { + } else if (buffer != nullptr) { sound_obj = W3DNEW Sound3DClass; sound_obj->Set_Buffer (buffer); } @@ -882,13 +882,13 @@ WWAudioClass::Create_Sound int classid_hint ) { - AudibleSoundClass *sound = NULL; + AudibleSoundClass *sound = nullptr; // // Find the definition // DefinitionClass *definition = DefinitionMgrClass::Find_Definition (definition_id); - if (definition != NULL ) { + if (definition != nullptr ) { // // Make sure this is really a sound definition @@ -901,7 +901,7 @@ WWAudioClass::Create_Sound // Create an instance of the sound // sound = sound_def->Create_Sound (classid_hint); - if (sound != NULL) { + if (sound != nullptr) { sound->Set_User_Data (user_obj, user_data); } } @@ -925,13 +925,13 @@ WWAudioClass::Create_Sound int classid_hint ) { - AudibleSoundClass *sound = NULL; + AudibleSoundClass *sound = nullptr; // // Find the definition // DefinitionClass *definition = DefinitionMgrClass::Find_Typed_Definition (def_name, CLASSID_SOUND, true); - if (definition != NULL ) { + if (definition != nullptr ) { // // Make sure this is really a sound definition @@ -944,7 +944,7 @@ WWAudioClass::Create_Sound // Create an instance of the sound // sound = sound_def->Create_Sound (classid_hint); - if (sound != NULL) { + if (sound != nullptr) { sound->Set_User_Data (user_obj, user_data); } } @@ -972,7 +972,7 @@ WWAudioClass::Create_Continuous_Sound // Create an instance of the sound and play it // AudibleSoundClass *sound = Create_Sound (definition_id, user_obj, user_data, classid_hint); - if (sound != NULL) { + if (sound != nullptr) { if (sound->Get_Loop_Count () != INFINITE_LOOPS) { WWDEBUG_SAY (("Audio Error: Creating a continuous sound with a finite loop count!")); @@ -1004,7 +1004,7 @@ WWAudioClass::Create_Instant_Sound // Create an instance of the sound and play it // AudibleSoundClass *sound = Create_Sound (definition_id, user_obj, user_data, classid_hint); - if (sound != NULL) { + if (sound != nullptr) { if (sound->Get_Loop_Count () == INFINITE_LOOPS) { WWDEBUG_SAY (("Audio Error: Creating an instant sound %s with an infinite loop count!",sound->Get_Definition()->Get_Name())); @@ -1038,7 +1038,7 @@ WWAudioClass::Create_Continuous_Sound // Create an instance of the sound and play it // AudibleSoundClass *sound = Create_Sound (def_name, user_obj, user_data, classid_hint); - if (sound != NULL) { + if (sound != nullptr) { if (sound->Get_Loop_Count () != INFINITE_LOOPS) { WWDEBUG_SAY (("Audio Error: Creating a continuous sound with a finite loop count!")); @@ -1071,7 +1071,7 @@ WWAudioClass::Create_Instant_Sound // Create an instance of the sound and play it // AudibleSoundClass *sound = Create_Sound (def_name, user_obj, user_data, classid_hint); - if (sound != NULL) { + if (sound != nullptr) { if (sound->Get_Loop_Count () == INFINITE_LOOPS) { WWDEBUG_SAY (("Audio Error: Creating an instant sound %s with an infinite loop count!",sound->Get_Definition()->Get_Name())); @@ -1124,7 +1124,7 @@ WWAudioClass::Free_Completed_Sounds (void) for (int index = 0; index < m_CompletedSounds.Count (); index ++) { AudibleSoundClass *sound_obj = m_CompletedSounds[index]; - WWASSERT(sound_obj != NULL); //TSS 05/24/99 + WWASSERT(sound_obj != nullptr); //TSS 05/24/99 // Remove this sound from the playlist bool found = false; @@ -1158,7 +1158,7 @@ WWAudioClass::Free_Completed_Sounds (void) AudibleSoundClass * WWAudioClass::Get_Playlist_Entry (int index) const { - AudibleSoundClass *sound_obj = NULL; + AudibleSoundClass *sound_obj = nullptr; // Params OK? WWASSERT (index >= 0 && index < m_Playlist.Count ()); @@ -1183,8 +1183,8 @@ WWAudioClass::Add_To_Playlist (AudibleSoundClass *sound) // Assume failure bool retval = false; - WWASSERT (sound != NULL); - if (sound != NULL) { + WWASSERT (sound != nullptr); + if (sound != nullptr) { // Loop through all the entries in the playlist bool already_added = false; @@ -1215,8 +1215,8 @@ WWAudioClass::Remove_From_Playlist (AudibleSoundClass *sound_obj) // Assume failure bool retval = false; - WWASSERT (sound_obj != NULL); - if (sound_obj != NULL) { + WWASSERT (sound_obj != nullptr); + if (sound_obj != nullptr) { // Loop through all the entries in the playlist int index = 0; @@ -1236,9 +1236,9 @@ WWAudioClass::Remove_From_Playlist (AudibleSoundClass *sound_obj) // if (sound_obj->Get_Loop_Count () != INFINITE_LOOPS) { for (index = 0; index < m_EOSCallbackList.Count (); index ++) { - uint32 user_data = NULL; + uint32 user_data = 0; LPFNEOSCALLBACK callback = m_EOSCallbackList.Get_Callback (index, &user_data); - if (callback != NULL) { + if (callback != nullptr) { (*callback) (sound_obj, user_data); } } @@ -1281,7 +1281,7 @@ WWAudioClass::Is_Sound_In_Playlist (AudibleSoundClass *sound_obj) void WWAudioClass::Reprioritize_Playlist (void) { - AudibleSoundClass *sound_to_get_handle = NULL; + AudibleSoundClass *sound_to_get_handle = nullptr; float hightest_priority = 0; // Loop through all the entries in the playlist @@ -1289,7 +1289,7 @@ WWAudioClass::Reprioritize_Playlist (void) // Is this the highest priority without a miles handle? AudibleSoundClass *sound_obj = m_Playlist[index]; - if ((sound_obj->Get_Miles_Handle () == NULL) && + if ((sound_obj->Get_Miles_Handle () == nullptr) && (sound_obj->Is_Sound_Culled () == false) && (sound_obj->Get_Priority () > hightest_priority)) { @@ -1301,7 +1301,7 @@ WWAudioClass::Reprioritize_Playlist (void) } // Get a new handle for this sound if necessary - if (sound_to_get_handle != NULL) { + if (sound_to_get_handle != nullptr) { sound_to_get_handle->Allocate_Miles_Handle (); } @@ -1322,7 +1322,7 @@ WWAudioClass::On_Frame_Update (unsigned int milliseconds) // Free_Completed_Sounds (); - if (m_SoundScene != NULL) { + if (m_SoundScene != nullptr) { m_SoundScene->On_Frame_Update (milliseconds); m_SoundScene->Collect_Logical_Sounds (milliseconds); } @@ -1356,7 +1356,7 @@ WWAudioClass::Release_2D_Handles (void) // Release our hold on all the samples we've allocated for (int index = 0; index < m_2DSampleHandles.Count (); index ++) { HSAMPLE sample = m_2DSampleHandles[index]; - if (sample != NULL) { + if (sample != nullptr) { ::AIL_release_sample_handle (sample); } } @@ -1379,13 +1379,13 @@ WWAudioClass::Allocate_2D_Handles (void) // Start fresh Release_2D_Handles (); - if (m_Driver2D != NULL) { + if (m_Driver2D != nullptr) { // Attempt to allocate our share of 2D sample handles for (int index = 0; index < m_Max2DSamples; index ++) { HSAMPLE sample = ::AIL_allocate_sample_handle (m_Driver2D); - if (sample != NULL) { - ::AIL_set_sample_user_data (sample, INFO_OBJECT_PTR, NULL); + if (sample != nullptr) { + ::AIL_set_sample_user_data (sample, INFO_OBJECT_PTR, nullptr); m_2DSampleHandles.Add (sample); } } @@ -1414,8 +1414,8 @@ WWAudioClass::Get_2D_Sample (const AudibleSoundClass &sound_obj) float lowest_priority = sound_obj.Get_Priority (); float lowest_runtime_priority = sound_obj.Get_Runtime_Priority (); - AudibleSoundClass *lowest_pri_sound = NULL; - HSAMPLE lowest_pri_sample = NULL; + AudibleSoundClass *lowest_pri_sound = nullptr; + HSAMPLE lowest_pri_sample = nullptr; HSAMPLE free_sample = (HSAMPLE)INVALID_MILES_HANDLE; // Loop through all the available sample handles and try to find @@ -1424,11 +1424,11 @@ WWAudioClass::Get_2D_Sample (const AudibleSoundClass &sound_obj) for (int index = 0; (index < m_2DSampleHandles.Count ()) && !found; index ++) { HSAMPLE sample = m_2DSampleHandles[index]; - if (sample != NULL) { + if (sample != nullptr) { // Get a pointer to the object that is currently using this sample AudibleSoundClass *sound_obj = (AudibleSoundClass *)::AIL_sample_user_data (sample, INFO_OBJECT_PTR); - if (sound_obj == NULL) { + if (sound_obj == nullptr) { // Return this sample handle to the caller free_sample = sample; @@ -1456,7 +1456,7 @@ WWAudioClass::Get_2D_Sample (const AudibleSoundClass &sound_obj) // Steal the sample handle from the lower priority // sound and return the handle to the caller. - if ((found == false) && (lowest_pri_sound != NULL)) { + if ((found == false) && (lowest_pri_sound != nullptr)) { lowest_pri_sound->Free_Miles_Handle (); free_sample = lowest_pri_sample; } @@ -1482,8 +1482,8 @@ WWAudioClass::Get_3D_Sample (const Sound3DClass &sound_obj) float lowest_priority = sound_obj.Get_Priority (); float lowest_runtime_priority = sound_obj.Get_Runtime_Priority (); - AudibleSoundClass *lowest_pri_sound = NULL; - H3DSAMPLE lowest_pri_sample = NULL; + AudibleSoundClass *lowest_pri_sound = nullptr; + H3DSAMPLE lowest_pri_sample = nullptr; H3DSAMPLE free_sample = (H3DSAMPLE)INVALID_MILES_HANDLE; @@ -1493,11 +1493,11 @@ WWAudioClass::Get_3D_Sample (const Sound3DClass &sound_obj) for (int index = 0; (index < m_3DSampleHandles.Count ()) && !found; index ++) { H3DSAMPLE sample = m_3DSampleHandles[index]; - if (sample != NULL) { + if (sample != nullptr) { // Get a pointer to the object that is currently using this sample AudibleSoundClass *sound_obj = (AudibleSoundClass *)::AIL_3D_object_user_data (sample, INFO_OBJECT_PTR); - if (sound_obj == NULL) { + if (sound_obj == nullptr) { // Return this sample handle to the caller free_sample = sample; @@ -1525,7 +1525,7 @@ WWAudioClass::Get_3D_Sample (const Sound3DClass &sound_obj) // Steal the sample handle from the lower priority // sound and return the handle to the caller. - if ((found == false) && (lowest_pri_sound != NULL)) { + if ((found == false) && (lowest_pri_sound != nullptr)) { lowest_pri_sound->Free_Miles_Handle (); free_sample = lowest_pri_sample; } @@ -1559,8 +1559,8 @@ WWAudioClass::Build_3D_Driver_List (void) MMSLockClass lock; HPROENUM next = HPROENUM_FIRST; - HPROVIDER provider = NULL; - char *name = NULL; + HPROVIDER provider = nullptr; + char *name = nullptr; while (::AIL_enumerate_3D_providers (&next, &provider, &name) > 0) { // Can we successfully open this provider? @@ -1616,21 +1616,21 @@ WWAudioClass::Free_3D_Driver_List (void) // for (int index = 0; index < m_Driver3DList.Count (); index ++) { DRIVER_INFO_STRUCT *info = m_Driver3DList[index]; - if (info != NULL) { + if (info != nullptr) { // // Free the information we have stored with this driver // - if (info->name != NULL) { + if (info->name != nullptr) { ::free (info->name); } delete info; } } - if (m_Driver3D != NULL) { + if (m_Driver3D != nullptr) { ::AIL_close_3D_provider (m_Driver3D); - m_Driver3D = NULL; + m_Driver3D = nullptr; } // @@ -1656,7 +1656,7 @@ WWAudioClass::Select_3D_Device (const char *device_name) // for (int index = 0; index < m_Driver3DList.Count (); index ++) { DRIVER_INFO_STRUCT *info = m_Driver3DList[index]; - if (info != NULL) { + if (info != nullptr) { // // Is this the device we were looking for? @@ -1681,7 +1681,7 @@ bool WWAudioClass::Select_3D_Device (const char *device_name, HPROVIDER provider) { bool retval = false; - if ((provider != NULL) && (provider != m_Driver3D)) { + if ((provider != nullptr) && (provider != m_Driver3D)) { // // Remove all the handles @@ -1692,9 +1692,9 @@ WWAudioClass::Select_3D_Device (const char *device_name, HPROVIDER provider) // // Close the previous driver if needs be // - if (m_Driver3D != NULL) { + if (m_Driver3D != nullptr) { ::AIL_close_3D_provider (m_Driver3D); - m_Driver3D = NULL; + m_Driver3D = nullptr; } // @@ -1711,7 +1711,7 @@ WWAudioClass::Select_3D_Device (const char *device_name, HPROVIDER provider) // StringClass lower_name = device_name; ::strlwr (lower_name.Peek_Buffer ()); - if (::strstr (device_name, "eax") != 0) { + if (::strstr (device_name, "eax") != nullptr) { m_EffectsLevel = 1.0F; } else { m_EffectsLevel = 0.0F; @@ -1802,10 +1802,10 @@ WWAudioClass::Find_3D_Device (DRIVER_TYPE_3D type) int driver_index = -1; for (int index = 0; (index < m_Driver3DList.Count ()) && (driver_index == -1); index ++) { DRIVER_INFO_STRUCT *info = m_Driver3DList[index]; - if ((info != NULL) && (info->name != NULL)) { + if ((info != nullptr) && (info->name != nullptr)) { // Is this the driver we were looking for? - if (::strstr (info->name, sub_string) != NULL) { + if (::strstr (info->name, sub_string) != nullptr) { driver_index = index; } } @@ -1829,13 +1829,13 @@ WWAudioClass::Allocate_3D_Handles (void) // Start fresh Release_3D_Handles (); - if (m_Driver3D != NULL) { + if (m_Driver3D != nullptr) { // Attempt to allocate our share of 3D sample handles for (int index = 0; index < m_Max3DSamples; index ++) { H3DSAMPLE sample = ::AIL_allocate_3D_sample_handle (m_Driver3D); - if (sample != NULL) { - ::AIL_set_3D_object_user_data (sample, INFO_OBJECT_PTR, NULL); + if (sample != nullptr) { + ::AIL_set_3D_object_user_data (sample, INFO_OBJECT_PTR, nullptr); m_3DSampleHandles.Add (sample); } } @@ -1860,7 +1860,7 @@ WWAudioClass::Release_3D_Handles (void) // for (int index = 0; index < m_3DSampleHandles.Count (); index ++) { H3DSAMPLE sample = m_3DSampleHandles[index]; - if (sample != NULL) { + if (sample != nullptr) { ::AIL_release_3D_sample_handle (sample); } } @@ -1883,7 +1883,7 @@ WWAudioClass::Validate_3D_Sound_Buffer (SoundBufferClass *buffer) // // 3D sound buffer MUST be uncompressed mono WAV data // - if ((buffer != NULL) && + if ((buffer != nullptr) && (buffer->Get_Channels () == 1) && (buffer->Get_Type () == WAVE_FORMAT_PCM) && (buffer->Is_Streaming () == false)) @@ -2102,7 +2102,7 @@ WWAudioClass::Initialize (const char *registry_subkey_name) // Grab the first (and only) filter for use with our 'tinny' effect. // HPROENUM next = HPROENUM_FIRST; - char *name = NULL; + char *name = nullptr; if (::AIL_enumerate_filters (&next, &m_ReverbFilter, &name) == 0) { m_ReverbFilter = (HPROVIDER)INVALID_MILES_HANDLE; } @@ -2141,7 +2141,7 @@ WWAudioClass::Initialize // Grab the first (and only) filter for use with our 'tinny' effect. // HPROENUM next = HPROENUM_FIRST; - char *name = NULL; + char *name = nullptr; if (::AIL_enumerate_filters (&next, &m_ReverbFilter, &name) == 0) { m_ReverbFilter = (HPROVIDER)INVALID_MILES_HANDLE; } @@ -2172,14 +2172,14 @@ WWAudioClass::Shutdown (void) // Wait for the timer callback function to end ::WaitForSingleObject (_TimerSyncEvent, 20000); ::CloseHandle (_TimerSyncEvent); - _TimerSyncEvent = NULL; + _TimerSyncEvent = nullptr; } // // Stop all sounds from playing // Flush_Playlist (); - if (m_SoundScene != NULL) { + if (m_SoundScene != nullptr) { m_SoundScene->Flush_Scene (); } @@ -2267,7 +2267,7 @@ WWAudioClass::UnRegister_Text_Callback (LPFNTEXTCALLBACK callback) void WWAudioClass::Fire_Text_Callback (AudibleSoundClass *sound_obj, const StringClass &text) { - if (text.Get_Length () > 0) { + if (!text.Is_Empty()) { // // Loop over all the text-callbacks that have been registered @@ -2275,7 +2275,7 @@ WWAudioClass::Fire_Text_Callback (AudibleSoundClass *sound_obj, const StringClas for (int index = 0; index < m_TextCallbackList.Count (); index ++) { uint32 user_data = 0L; LPFNTEXTCALLBACK callback = m_TextCallbackList.Get_Callback (index, &user_data); - if (callback != NULL) { + if (callback != nullptr) { // // Fire the notification @@ -2375,13 +2375,13 @@ WWAudioClass::Simple_Play_2D_Sound_Effect { bool retval = false; AudibleSoundClass *sound = Create_Sound_Effect (filename); - if (sound != NULL) { + if (sound != nullptr) { sound->Set_Priority (priority); sound->Set_Loop_Count (1); sound->Set_Volume(volume); sound->Play (); sound->Release_Ref (); - sound = NULL; + sound = nullptr; retval = true; } @@ -2404,13 +2404,13 @@ WWAudioClass::Simple_Play_2D_Sound_Effect { bool retval = false; AudibleSoundClass *sound = Create_Sound_Effect (file); - if (sound != NULL) { + if (sound != nullptr) { sound->Set_Priority (priority); sound->Set_Loop_Count (1); sound->Set_Volume(volume); sound->Play (); sound->Release_Ref (); - sound = NULL; + sound = nullptr; retval = true; } @@ -2426,8 +2426,8 @@ WWAudioClass::Simple_Play_2D_Sound_Effect FileClass * WWAudioClass::Get_File (LPCTSTR filename) { - FileClass *file = NULL; - if (m_FileFactory != NULL) { + FileClass *file = nullptr; + if (m_FileFactory != nullptr) { file = m_FileFactory->Get_File (filename); } else { file = _TheFileFactory->Get_File(filename); @@ -2446,7 +2446,7 @@ WWAudioClass::Get_File (LPCTSTR filename) void WWAudioClass::Return_File (FileClass *file) { - if (m_FileFactory != NULL) { + if (m_FileFactory != nullptr) { m_FileFactory->Return_File (file); } else { SAFE_DELETE (file); @@ -2534,7 +2534,7 @@ WWAudioClass::Get_Logical_Type (int index, StringClass &name) SoundSceneObjClass * WWAudioClass::Find_Sound_Object (uint32 sound_obj_id) { - SoundSceneObjClass *sound_obj = NULL; + SoundSceneObjClass *sound_obj = nullptr; // // Lookup the sound object and return it to the caller @@ -2673,7 +2673,7 @@ WWAudioClass::Save_To_Registry (const char *subkey_name) // // Is this the device we were looking for? // - if (info != NULL && info->driver == m_Driver3D) { + if (info != nullptr && info->driver == m_Driver3D) { device_name = info->name; break; } @@ -2744,13 +2744,13 @@ WWAudioClass::File_Open_Callback (char const *filename, void **file_handle) { U32 retval = false; - if (Get_Instance () != NULL) { + if (Get_Instance () != nullptr) { // // Open the file // FileClass *file = Get_Instance ()->Get_File (filename); - if (file != NULL && file->Open ()) { + if (file != nullptr && file->Open ()) { (*file_handle) = (void *)file; retval = true; } @@ -2768,13 +2768,13 @@ WWAudioClass::File_Open_Callback (char const *filename, void **file_handle) void AILCALLBACK WWAudioClass::File_Close_Callback (void *file_handle) { - if (Get_Instance () != NULL) { + if (Get_Instance () != nullptr) { // // Close the file (if necessary) // FileClass *file = reinterpret_cast (file_handle); - if (file != NULL) { + if (file != nullptr) { Get_Instance ()->Return_File (file); } } @@ -2797,7 +2797,7 @@ WWAudioClass::File_Seek_Callback (void *file_handle, S32 offset, U32 type) // Convert the handle to a file handle type // FileClass *file = reinterpret_cast (file_handle); - if (file != NULL) { + if (file != nullptr) { // // Convert the Miles seek type to one of our own @@ -2842,7 +2842,7 @@ WWAudioClass::File_Read_Callback (void *file_handle, void *buffer, U32 bytes) // Convert the handle to a file handle type // FileClass *file = reinterpret_cast (file_handle); - if (file != NULL) { + if (file != nullptr) { // // Read the bytes from the file diff --git a/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.h b/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.h index cc2f6a0c9ec..94c8e73b597 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/WWAudio.h @@ -174,7 +174,7 @@ class WWAudioClass // // Note: After call Initialize () you can begin using the library, you don't - // need to explicity call Open_2D_Device () or Select_3D_Device (). Those + // need to explicitly call Open_2D_Device () or Select_3D_Device (). Those // methods were provided as a means of opening devices other than the default. // // The Initialize () method defaults to a stereo, 16bit, 44100hz 2D DirectSound @@ -195,7 +195,7 @@ class WWAudioClass ////////////////////////////////////////////////////////////////////// // 2D Hardware/driver selection methods ////////////////////////////////////////////////////////////////////// - DRIVER_TYPE_2D Open_2D_Device (LPWAVEFORMAT format = NULL); + DRIVER_TYPE_2D Open_2D_Device (LPWAVEFORMAT format = nullptr); DRIVER_TYPE_2D Open_2D_Device (bool stereo, int bits, int hertz); bool Close_2D_Device (void); int Get_Playback_Rate (void) const { return m_PlaybackRate; } @@ -356,12 +356,12 @@ class WWAudioClass // // Sound creation methods // - int Create_Instant_Sound (int definition_id, const Matrix3D &tm, RefCountClass *user_obj = NULL, uint32 user_data = 0, int classid_hint = CLASSID_3D); - int Create_Instant_Sound (const char *def_name, const Matrix3D &tm, RefCountClass *user_obj = NULL, uint32 user_data = 0, int classid_hint = CLASSID_3D); - AudibleSoundClass * Create_Continuous_Sound (int definition_id, RefCountClass *user_obj = NULL, uint32 user_data = 0, int classid_hint = CLASSID_3D); - AudibleSoundClass * Create_Continuous_Sound (const char *def_name, RefCountClass *user_obj = NULL, uint32 user_data = 0, int classid_hint = CLASSID_3D); - AudibleSoundClass * Create_Sound (int definition_id, RefCountClass *user_obj = NULL, uint32 user_data = 0, int classid_hint = CLASSID_3D); - AudibleSoundClass * Create_Sound (const char *def_name, RefCountClass *user_obj = NULL, uint32 user_data = 0, int classid_hint = CLASSID_3D); + int Create_Instant_Sound (int definition_id, const Matrix3D &tm, RefCountClass *user_obj = nullptr, uint32 user_data = 0, int classid_hint = CLASSID_3D); + int Create_Instant_Sound (const char *def_name, const Matrix3D &tm, RefCountClass *user_obj = nullptr, uint32 user_data = 0, int classid_hint = CLASSID_3D); + AudibleSoundClass * Create_Continuous_Sound (int definition_id, RefCountClass *user_obj = nullptr, uint32 user_data = 0, int classid_hint = CLASSID_3D); + AudibleSoundClass * Create_Continuous_Sound (const char *def_name, RefCountClass *user_obj = nullptr, uint32 user_data = 0, int classid_hint = CLASSID_3D); + AudibleSoundClass * Create_Sound (int definition_id, RefCountClass *user_obj = nullptr, uint32 user_data = 0, int classid_hint = CLASSID_3D); + AudibleSoundClass * Create_Sound (const char *def_name, RefCountClass *user_obj = nullptr, uint32 user_data = 0, int classid_hint = CLASSID_3D); ////////////////////////////////////////////////////////////////////// // Sound object lookup @@ -502,7 +502,7 @@ class WWAudioClass SoundBufferClass * buffer; _CACHE_ENTRY_STRUCT (void) - : string_id (0), buffer (NULL) {} + : string_id (0), buffer (nullptr) {} _CACHE_ENTRY_STRUCT &operator= (const _CACHE_ENTRY_STRUCT &src) { string_id = ::strdup (src.string_id); REF_PTR_SET (buffer, src.buffer); return *this; } bool operator== (const _CACHE_ENTRY_STRUCT &src) { return false; } @@ -560,7 +560,7 @@ class WWAudioClass DynamicVectorClass m_2DSampleHandles; DynamicVectorClass m_3DSampleHandles; - // Playlist managment + // Playlist management DynamicVectorClass m_Playlist; DynamicVectorClass m_CompletedSounds; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/sound2dhandle.cpp b/Core/Libraries/Source/WWVegas/WWAudio/sound2dhandle.cpp index 9ff5f7ecbb5..169b73fdcb7 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/sound2dhandle.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/sound2dhandle.cpp @@ -81,7 +81,7 @@ Sound2DHandleClass::Initialize (SoundBufferClass *buffer) // // Pass the actual sound data onto the sample // - if (Buffer != NULL) { + if (Buffer != nullptr) { ::AIL_set_named_sample_file (SampleHandle, (char *)Buffer->Get_Filename (), Buffer->Get_Raw_Buffer (), Buffer->Get_Raw_Length (), 0); } @@ -167,7 +167,7 @@ Sound2DHandleClass::Set_Sample_Pan (S32 pan) // TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_set_sample_pan. // TheSuperHackers @todo Perhaps use float natively. float fVolume = 0.0F; - ::AIL_sample_volume_pan (SampleHandle, &fVolume, NULL); + ::AIL_sample_volume_pan (SampleHandle, &fVolume, nullptr); float fPan = pan / 127.0F; ::AIL_set_sample_volume_pan (SampleHandle, fVolume, fPan); } @@ -189,7 +189,7 @@ Sound2DHandleClass::Get_Sample_Pan (void) if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) { // TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_sample_pan. float fPan = 0.5F; - ::AIL_sample_volume_pan (SampleHandle, NULL, &fPan); + ::AIL_sample_volume_pan (SampleHandle, nullptr, &fPan); retval = fPan * 127; } @@ -209,7 +209,7 @@ Sound2DHandleClass::Set_Sample_Volume (S32 volume) // TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_set_sample_volume. // TheSuperHackers @todo Perhaps use float natively. float fPan = 0.5F; - ::AIL_sample_volume_pan (SampleHandle, NULL, &fPan); + ::AIL_sample_volume_pan (SampleHandle, nullptr, &fPan); float fVolume = volume / 127.0F; ::AIL_set_sample_volume_pan (SampleHandle, fVolume, fPan); } @@ -230,7 +230,7 @@ Sound2DHandleClass::Get_Sample_Volume (void) if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) { // TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_sample_volume. float fVolume = 0.0F; - ::AIL_sample_volume_pan (SampleHandle, &fVolume, NULL); + ::AIL_sample_volume_pan (SampleHandle, &fVolume, nullptr); retval = fVolume * 127; } @@ -328,7 +328,7 @@ Sound2DHandleClass::Set_Sample_User_Data (S32 i, void *val) void * Sound2DHandleClass::Get_Sample_User_Data (S32 i) { - void *retval = NULL; + void *retval = nullptr; if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) { retval = ::AIL_sample_user_data (SampleHandle, i); diff --git a/Core/Libraries/Source/WWVegas/WWAudio/sound3dhandle.cpp b/Core/Libraries/Source/WWVegas/WWAudio/sound3dhandle.cpp index 2e281315239..9ea5335c4f3 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/sound3dhandle.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/sound3dhandle.cpp @@ -71,7 +71,7 @@ Sound3DHandleClass::Initialize (SoundBufferClass *buffer) { SoundHandleClass::Initialize (buffer); - if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE && Buffer != NULL) { + if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE && Buffer != nullptr) { // // Configure the 3D sample @@ -260,7 +260,7 @@ Sound3DHandleClass::Set_Sample_MS_Position (U32 ms) { if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) { - WWASSERT (Buffer != NULL); + WWASSERT (Buffer != nullptr); U32 bytes_per_sec = (Buffer->Get_Rate () * Buffer->Get_Bits ()) >> 3; U32 bytes = (ms * bytes_per_sec) / 1000; bytes += (bytes & 1); @@ -281,15 +281,15 @@ Sound3DHandleClass::Get_Sample_MS_Position (S32 *len, S32 *pos) { if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) { - WWASSERT (Buffer != NULL); - if (pos != NULL) { + WWASSERT (Buffer != nullptr); + if (pos != nullptr) { U32 bytes = ::AIL_3D_sample_offset (SampleHandle); U32 bytes_per_sec = (Buffer->Get_Rate () * Buffer->Get_Bits ()) >> 3; U32 ms = (bytes * 1000) / bytes_per_sec; (*pos) = ms; } - if (len != NULL) { + if (len != nullptr) { U32 bytes = ::AIL_3D_sample_length (SampleHandle); U32 bytes_per_sec = (Buffer->Get_Rate () * Buffer->Get_Bits ()) >> 3; U32 ms = (bytes * 1000) / bytes_per_sec; @@ -324,7 +324,7 @@ Sound3DHandleClass::Set_Sample_User_Data (S32 i, void *val) void * Sound3DHandleClass::Get_Sample_User_Data (S32 i) { - void *retval = NULL; + void *retval = nullptr; if (SampleHandle != (H3DSAMPLE)INVALID_MILES_HANDLE) { retval = AIL_3D_object_user_data (SampleHandle, i); diff --git a/Core/Libraries/Source/WWVegas/WWAudio/soundhandle.cpp b/Core/Libraries/Source/WWVegas/WWAudio/soundhandle.cpp index 550d4445ded..15080f5d787 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/soundhandle.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/soundhandle.cpp @@ -44,7 +44,7 @@ // ////////////////////////////////////////////////////////////////////// SoundHandleClass::SoundHandleClass (void) : - Buffer (NULL) + Buffer (nullptr) { return ; } @@ -61,9 +61,9 @@ SoundHandleClass::~SoundHandleClass (void) // Delay the release of the buffer (fixes a sync bug // with Miles internals). // - if (Buffer != NULL) { + if (Buffer != nullptr) { WWAudioThreadsClass::Add_Delayed_Release_Object (Buffer); - Buffer = NULL; + Buffer = nullptr; } return ; diff --git a/Core/Libraries/Source/WWVegas/WWAudio/soundhandle.h b/Core/Libraries/Source/WWVegas/WWAudio/soundhandle.h index 297a9ba2a38..ea5bf8a8c9e 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/soundhandle.h +++ b/Core/Libraries/Source/WWVegas/WWAudio/soundhandle.h @@ -70,17 +70,17 @@ class SoundHandleClass // // RTTI // - virtual Sound3DHandleClass * As_Sound3DHandleClass (void) { return NULL; } - virtual Sound2DHandleClass * As_Sound2DHandleClass (void) { return NULL; } - virtual SoundStreamHandleClass * As_SoundStreamHandleClass (void) { return NULL; } - virtual ListenerHandleClass * As_ListenerHandleClass (void) { return NULL; } + virtual Sound3DHandleClass * As_Sound3DHandleClass (void) { return nullptr; } + virtual Sound2DHandleClass * As_Sound2DHandleClass (void) { return nullptr; } + virtual SoundStreamHandleClass * As_SoundStreamHandleClass (void) { return nullptr; } + virtual ListenerHandleClass * As_ListenerHandleClass (void) { return nullptr; } // // Handle access // - virtual H3DSAMPLE Get_H3DSAMPLE (void) { return NULL; } - virtual HSAMPLE Get_HSAMPLE (void) { return NULL; } - virtual HSTREAM Get_HSTREAM (void) { return NULL; } + virtual H3DSAMPLE Get_H3DSAMPLE (void) { return nullptr; } + virtual HSAMPLE Get_HSAMPLE (void) { return nullptr; } + virtual HSTREAM Get_HSTREAM (void) { return nullptr; } // // Initialization diff --git a/Core/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.cpp b/Core/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.cpp index 5bc7ed4e862..f66b9f1073f 100644 --- a/Core/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.cpp +++ b/Core/Libraries/Source/WWVegas/WWAudio/soundstreamhandle.cpp @@ -72,7 +72,7 @@ SoundStreamHandleClass::Initialize (SoundBufferClass *buffer) { SoundHandleClass::Initialize (buffer); - if (Buffer != NULL) { + if (Buffer != nullptr) { // // Create a stream @@ -164,7 +164,7 @@ SoundStreamHandleClass::Set_Sample_Pan (S32 pan) // TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_set_stream_pan. // TheSuperHackers @todo Perhaps use float natively. float fVolume = 0.0F; - ::AIL_stream_volume_pan (StreamHandle, &fVolume, NULL); + ::AIL_stream_volume_pan (StreamHandle, &fVolume, nullptr); float fPan = pan / 127.0F; ::AIL_set_stream_volume_pan (StreamHandle, fVolume, fPan); } @@ -185,7 +185,7 @@ SoundStreamHandleClass::Get_Sample_Pan (void) if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) { // TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_stream_pan. float fPan = 0.5F; - ::AIL_stream_volume_pan (StreamHandle, NULL, &fPan); + ::AIL_stream_volume_pan (StreamHandle, nullptr, &fPan); retval = fPan * 127; } @@ -205,7 +205,7 @@ SoundStreamHandleClass::Set_Sample_Volume (S32 volume) // TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_set_stream_volume. // TheSuperHackers @todo Perhaps use float natively. float fPan = 0.5F; - ::AIL_stream_volume_pan (StreamHandle, NULL, &fPan); + ::AIL_stream_volume_pan (StreamHandle, nullptr, &fPan); float fVolume = volume / 127.0F; ::AIL_set_stream_volume_pan (StreamHandle, fVolume, fPan); } @@ -226,7 +226,7 @@ SoundStreamHandleClass::Get_Sample_Volume (void) if (StreamHandle != (HSTREAM)INVALID_MILES_HANDLE) { // TheSuperHackers @fix xezon 05/04/2025 Upgrades miles call from legacy AIL_stream_volume. float fVolume = 0.0F; - ::AIL_stream_volume_pan (StreamHandle, &fVolume, NULL); + ::AIL_stream_volume_pan (StreamHandle, &fVolume, nullptr); retval = fVolume * 127; } @@ -323,7 +323,7 @@ SoundStreamHandleClass::Set_Sample_User_Data (S32 i, void *val) void * SoundStreamHandleClass::Get_Sample_User_Data (S32 i) { - void *retval = NULL; + void *retval = nullptr; if (SampleHandle != (HSAMPLE)INVALID_MILES_HANDLE) { retval = ::AIL_sample_user_data (SampleHandle, i); diff --git a/Core/Libraries/Source/WWVegas/WWDebug/wwdebug.cpp b/Core/Libraries/Source/WWVegas/WWDebug/wwdebug.cpp index e072d8a0115..6d46bb668f4 100644 --- a/Core/Libraries/Source/WWVegas/WWDebug/wwdebug.cpp +++ b/Core/Libraries/Source/WWVegas/WWDebug/wwdebug.cpp @@ -57,11 +57,11 @@ #include #endif -static PrintFunc _CurMessageHandler = NULL; -static AssertPrintFunc _CurAssertHandler = NULL; -static TriggerFunc _CurTriggerHandler = NULL; -static ProfileFunc _CurProfileStartHandler = NULL; -static ProfileFunc _CurProfileStopHandler = NULL; +static PrintFunc _CurMessageHandler = nullptr; +static AssertPrintFunc _CurAssertHandler = nullptr; +static TriggerFunc _CurTriggerHandler = nullptr; +static ProfileFunc _CurProfileStartHandler = nullptr; +static ProfileFunc _CurProfileStopHandler = nullptr; // Convert the latest system error into a string and return a pointer to // a static buffer containing the error string. @@ -71,12 +71,12 @@ void Convert_System_Error_To_String(int id, char* buffer, int buf_len) #ifndef _UNIX FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, - NULL, + nullptr, id, 0, buffer, buf_len, - NULL); + nullptr); #endif } @@ -204,7 +204,7 @@ ProfileFunc WWDebug_Install_Profile_Stop_Handler(ProfileFunc func) void WWDebug_Printf(const char * format,...) { - if (_CurMessageHandler != NULL) { + if (_CurMessageHandler != nullptr) { va_list va; char buffer[4096]; @@ -234,7 +234,7 @@ void WWDebug_Printf(const char * format,...) void WWDebug_Printf_Warning(const char * format,...) { - if (_CurMessageHandler != NULL) { + if (_CurMessageHandler != nullptr) { va_list va; char buffer[4096]; @@ -264,7 +264,7 @@ void WWDebug_Printf_Warning(const char * format,...) void WWDebug_Printf_Error(const char * format,...) { - if (_CurMessageHandler != NULL) { + if (_CurMessageHandler != nullptr) { va_list va; char buffer[4096]; @@ -294,7 +294,7 @@ void WWDebug_Printf_Error(const char * format,...) #ifdef WWDEBUG void WWDebug_Assert_Fail(const char * expr,const char * file, int line) { - if (_CurAssertHandler != NULL) { + if (_CurAssertHandler != nullptr) { char buffer[4096]; sprintf(buffer,"%s (%d) Assert: %s\n",file,line,expr); @@ -312,7 +312,7 @@ void WWDebug_Assert_Fail(const char * expr,const char * file, int line) char assertbuf[4096]; sprintf(assertbuf, "Assert failed\n\n. File %s Line %d", file, line); - int code = MessageBoxA(NULL, assertbuf, "WWDebug_Assert_Fail", MB_ABORTRETRYIGNORE|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL); + int code = MessageBoxA(nullptr, assertbuf, "WWDebug_Assert_Fail", MB_ABORTRETRYIGNORE|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL); if (code == IDABORT) { raise(SIGABRT); @@ -374,7 +374,7 @@ void __cdecl _assert(void *expr, void *filename, unsigned lineno) #ifdef WWDEBUG void WWDebug_Assert_Fail_Print(const char * expr,const char * file, int line,const char * string) { - if (_CurAssertHandler != NULL) { + if (_CurAssertHandler != nullptr) { char buffer[4096]; sprintf(buffer,"%s (%d) Assert: %s %s\n",file,line,expr, string); @@ -403,7 +403,7 @@ void WWDebug_Assert_Fail_Print(const char * expr,const char * file, int line,con *=============================================================================================*/ bool WWDebug_Check_Trigger(int trigger_num) { - if (_CurTriggerHandler != NULL) { + if (_CurTriggerHandler != nullptr) { return _CurTriggerHandler(trigger_num); } else { return false; @@ -425,7 +425,7 @@ bool WWDebug_Check_Trigger(int trigger_num) *=============================================================================================*/ void WWDebug_Profile_Start( const char * title) { - if (_CurProfileStartHandler != NULL) { + if (_CurProfileStartHandler != nullptr) { _CurProfileStartHandler( title ); } } @@ -445,7 +445,7 @@ void WWDebug_Profile_Start( const char * title) *=============================================================================================*/ void WWDebug_Profile_Stop( const char * title) { - if (_CurProfileStopHandler != NULL) { + if (_CurProfileStopHandler != nullptr) { _CurProfileStopHandler( title ); } } @@ -477,7 +477,7 @@ void WWDebug_DBWin32_Message_Handler( const char * str ) heventDBWIN = OpenEvent(EVENT_MODIFY_STATE, FALSE, "DBWIN_BUFFER_READY"); if ( !heventDBWIN ) { - //MessageBox(NULL, "DBWIN_BUFFER_READY nonexistent", NULL, MB_OK); + //MessageBox(nullptr, "DBWIN_BUFFER_READY nonexistent", nullptr, MB_OK); return; } @@ -485,15 +485,15 @@ void WWDebug_DBWin32_Message_Handler( const char * str ) heventData = OpenEvent(EVENT_MODIFY_STATE, FALSE, "DBWIN_DATA_READY"); if ( !heventData ) { - // MessageBox(NULL, "DBWIN_DATA_READY nonexistent", NULL, MB_OK); + // MessageBox(nullptr, "DBWIN_DATA_READY nonexistent", nullptr, MB_OK); CloseHandle(heventDBWIN); return; } - hSharedFile = CreateFileMapping((HANDLE)-1, NULL, PAGE_READWRITE, 0, 4096, "DBWIN_BUFFER"); + hSharedFile = CreateFileMapping((HANDLE)-1, nullptr, PAGE_READWRITE, 0, 4096, "DBWIN_BUFFER"); if (!hSharedFile) { - //MessageBox(NULL, "DebugTrace: Unable to create file mapping object DBWIN_BUFFER", "Error", MB_OK); + //MessageBox(nullptr, "DebugTrace: Unable to create file mapping object DBWIN_BUFFER", "Error", MB_OK); CloseHandle(heventDBWIN); CloseHandle(heventData); return; @@ -502,7 +502,7 @@ void WWDebug_DBWin32_Message_Handler( const char * str ) lpszSharedMem = (LPSTR)MapViewOfFile(hSharedFile, FILE_MAP_WRITE, 0, 0, 512); if (!lpszSharedMem) { - //MessageBox(NULL, "DebugTrace: Unable to map shared memory", "Error", MB_OK); + //MessageBox(nullptr, "DebugTrace: Unable to map shared memory", "Error", MB_OK); CloseHandle(heventDBWIN); CloseHandle(heventData); return; diff --git a/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp b/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp index 31bd9b3cf5e..067a8b6b716 100644 --- a/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp +++ b/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.cpp @@ -131,7 +131,7 @@ class MemoryCounterClass public: MemoryCounterClass(void) : CurrentAllocation(0), PeakAllocation(0) { } - void Memory_Allocated(int size) { CurrentAllocation+=size; PeakAllocation = max(PeakAllocation,CurrentAllocation); } + void Memory_Allocated(int size) { CurrentAllocation+=size; PeakAllocation = MAX(PeakAllocation,CurrentAllocation); } void Memory_Released(int size) { CurrentAllocation-=size; } int Get_Current_Allocated_Memory(void) { return CurrentAllocation; } @@ -248,11 +248,11 @@ class MemLogClass ** _MemLogMutex - handle to the mutex used to arbtirate access to the logging data structures ** _MemLogLockCounter - count of the active mutex locks. */ -static MemLogClass * _TheMemLog = NULL; +static MemLogClass * _TheMemLog = nullptr; static bool _MemLogAllocated = false; #if MEMLOG_USE_MUTEX -static void * _MemLogMutex = NULL; +static void * _MemLogMutex = nullptr; static int _MemLogLockCounter = 0; #endif @@ -272,8 +272,8 @@ WWINLINE void * Get_Mem_Log_Mutex(void) { #if MEMLOG_USE_MUTEX - if (_MemLogMutex == NULL) { - _MemLogMutex=CreateMutex(NULL,false,NULL); + if (_MemLogMutex == nullptr) { + _MemLogMutex=CreateMutex(nullptr,false,nullptr); WWASSERT(_MemLogMutex); } return _MemLogMutex; @@ -291,7 +291,7 @@ WWINLINE void * Get_Mem_Log_Mutex(void) #endif #if DISABLE_MEMLOG - return NULL; + return nullptr; #endif } @@ -531,7 +531,7 @@ void WWMemoryLogClass::Register_Memory_Released(int category,int size) static void _MemLogCleanup(void) { delete _TheMemLog; - _TheMemLog = NULL; + _TheMemLog = nullptr; } @@ -539,7 +539,7 @@ MemLogClass * WWMemoryLogClass::Get_Log(void) { MemLogMutexLockClass lock; - if (_TheMemLog == NULL) { + if (_TheMemLog == nullptr) { //assert(!_MemLogAllocated); _TheMemLog = W3DNEW MemLogClass; @@ -581,7 +581,7 @@ void WWMemoryLogClass::Release_Log(void) MemLogMutexLockClass lock; delete _TheMemLog; - _TheMemLog = NULL; + _TheMemLog = nullptr; } @@ -663,7 +663,7 @@ void * WWMemoryLogClass::Allocate_Memory(size_t size) */ void * ptr = ALLOC_MEMORY(size + sizeof(MemoryLogStruct)); - if (ptr != NULL) { + if (ptr != nullptr) { /* ** Record this allocation */ diff --git a/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.h b/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.h index b994bbe16bc..3a87b80d83b 100644 --- a/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.h +++ b/Core/Libraries/Source/WWVegas/WWDebug/wwmemlog.h @@ -38,6 +38,8 @@ #pragma once +#include + #define LOG_MEMORY // Comment this out to disable memlog compiling in class MemLogClass; diff --git a/Core/Libraries/Source/WWVegas/WWDebug/wwprofile.cpp b/Core/Libraries/Source/WWVegas/WWDebug/wwprofile.cpp index c02c4e5dd59..e6e4d0fb88c 100644 --- a/Core/Libraries/Source/WWVegas/WWDebug/wwprofile.cpp +++ b/Core/Libraries/Source/WWVegas/WWDebug/wwprofile.cpp @@ -32,12 +32,12 @@ * * *---------------------------------------------------------------------------------------------* * WWProfile_Get_Ticks -- Retrieves the cpu performance counter * - * WWProfileHierachyNodeClass::WWProfileHierachyNodeClass -- Constructor * - * WWProfileHierachyNodeClass::~WWProfileHierachyNodeClass -- Destructor * - * WWProfileHierachyNodeClass::Get_Sub_Node -- Searches for a child node by name (pointer) * - * WWProfileHierachyNodeClass::Reset -- Reset all profiling data in the tree * - * WWProfileHierachyNodeClass::Call -- Start timing * - * WWProfileHierachyNodeClass::Return -- Stop timing, record results * + * WWProfileHierarchyNodeClass::WWProfileHierarchyNodeClass -- Constructor * + * WWProfileHierarchyNodeClass::~WWProfileHierarchyNodeClass -- Destructor * + * WWProfileHierarchyNodeClass::Get_Sub_Node -- Searches for a child node by name (pointer) * + * WWProfileHierarchyNodeClass::Reset -- Reset all profiling data in the tree * + * WWProfileHierarchyNodeClass::Call -- Start timing * + * WWProfileHierarchyNodeClass::Return -- Stop timing, record results * * WWProfileManager::Start_Profile -- Begin a named profile * * WWProfileManager::Stop_Profile -- Stop timing and record the results. * * WWProfileManager::Reset -- Reset the contents of the profiling system * @@ -62,7 +62,7 @@ #include "hashtemplate.h" #include -static SimpleDynVecClass ProfileCollectVector; +static SimpleDynVecClass ProfileCollectVector; static double TotalFrameTimes; static bool ProfileCollecting; @@ -95,7 +95,7 @@ WWINLINE double WWProfile_Get_Inv_Processor_Ticks_Per_Second(void) * HISTORY: * * 9/24/2000 gth : Created. * *=============================================================================================*/ -inline void WWProfile_Get_Ticks(_int64 * ticks) +static inline void WWProfile_Get_Ticks(_int64 * ticks) { #ifdef _UNIX *ticks = TIMEGETTIME(); @@ -106,7 +106,7 @@ inline void WWProfile_Get_Ticks(_int64 * ticks) /*********************************************************************************************** - * WWProfileHierachyNodeClass::WWProfileHierachyNodeClass -- Constructor * + * WWProfileHierarchyNodeClass::WWProfileHierarchyNodeClass -- Constructor * * * * * * INPUT: * @@ -122,15 +122,15 @@ inline void WWProfile_Get_Ticks(_int64 * ticks) * HISTORY: * * 9/24/2000 gth : Created. * *=============================================================================================*/ -WWProfileHierachyNodeClass::WWProfileHierachyNodeClass( const char * name, WWProfileHierachyNodeClass * parent ) : +WWProfileHierarchyNodeClass::WWProfileHierarchyNodeClass( const char * name, WWProfileHierarchyNodeClass * parent ) : Name( name ), TotalCalls( 0 ), TotalTime( 0 ), StartTime( 0 ), RecursionCounter( 0 ), Parent( parent ), - Child( NULL ), - Sibling( NULL ) + Child( nullptr ), + Sibling( nullptr ) { Reset(); @@ -140,15 +140,15 @@ WWProfileHierachyNodeClass::WWProfileHierachyNodeClass( const char * name, WWPro } } -WWProfileHierachyNodeClass::WWProfileHierachyNodeClass( unsigned id, WWProfileHierachyNodeClass * parent ) : - Name( NULL ), +WWProfileHierarchyNodeClass::WWProfileHierarchyNodeClass( unsigned id, WWProfileHierarchyNodeClass * parent ) : + Name( nullptr ), TotalCalls( 0 ), TotalTime( 0 ), StartTime( 0 ), RecursionCounter( 0 ), Parent( parent ), - Child( NULL ), - Sibling( NULL ), + Child( nullptr ), + Sibling( nullptr ), ProfileStringID(id) { Reset(); @@ -156,7 +156,7 @@ WWProfileHierachyNodeClass::WWProfileHierachyNodeClass( unsigned id, WWProfileHi /*********************************************************************************************** - * WWProfileHierachyNodeClass::~WWProfileHierachyNodeClass -- Destructor * + * WWProfileHierarchyNodeClass::~WWProfileHierarchyNodeClass -- Destructor * * * * INPUT: * * * @@ -167,16 +167,16 @@ WWProfileHierachyNodeClass::WWProfileHierachyNodeClass( unsigned id, WWProfileHi * HISTORY: * * 9/24/2000 gth : Created. * *=============================================================================================*/ -WWProfileHierachyNodeClass::~WWProfileHierachyNodeClass( void ) +WWProfileHierarchyNodeClass::~WWProfileHierarchyNodeClass( void ) { delete Child; delete Sibling; } -WWProfileHierachyNodeClass* WWProfileHierachyNodeClass::Clone_Hierarchy(WWProfileHierachyNodeClass* parent) +WWProfileHierarchyNodeClass* WWProfileHierarchyNodeClass::Clone_Hierarchy(WWProfileHierarchyNodeClass* parent) { - WWProfileHierachyNodeClass* node=new WWProfileHierachyNodeClass(Name,parent); + WWProfileHierarchyNodeClass* node=new WWProfileHierarchyNodeClass(Name,parent); node->TotalCalls=TotalCalls; node->TotalTime=TotalTime; node->StartTime=StartTime; @@ -192,7 +192,7 @@ WWProfileHierachyNodeClass* WWProfileHierachyNodeClass::Clone_Hierarchy(WWProfil return node; } -void WWProfileHierachyNodeClass::Write_To_File(FileClass* file,int recursion) +void WWProfileHierarchyNodeClass::Write_To_File(FileClass* file,int recursion) { if (TotalTime!=0.0f) { int i; @@ -211,7 +211,7 @@ void WWProfileHierachyNodeClass::Write_To_File(FileClass* file,int recursion) } } -void WWProfileHierachyNodeClass::Add_To_String_Compact(StringClass& string,int recursion) +void WWProfileHierarchyNodeClass::Add_To_String_Compact(StringClass& string,int recursion) { if (TotalTime!=0.0f) { StringClass work; @@ -221,7 +221,7 @@ void WWProfileHierachyNodeClass::Add_To_String_Compact(StringClass& string,int r if (Child) { StringClass work; Child->Add_To_String_Compact(work,recursion+1); - if (work.Get_Length()!=0) { + if (!work.Is_Empty()) { string+="{"; string+=work; string+="}"; @@ -233,7 +233,7 @@ void WWProfileHierachyNodeClass::Add_To_String_Compact(StringClass& string,int r } /*********************************************************************************************** - * WWProfileHierachyNodeClass::Get_Sub_Node -- Searches for a child node by name (pointer) * + * WWProfileHierarchyNodeClass::Get_Sub_Node -- Searches for a child node by name (pointer) * * * * INPUT: * * name - static string pointer to the name of the node we are searching for * @@ -247,10 +247,10 @@ void WWProfileHierachyNodeClass::Add_To_String_Compact(StringClass& string,int r * HISTORY: * * 9/24/2000 gth : Created. * *=============================================================================================*/ -WWProfileHierachyNodeClass * WWProfileHierachyNodeClass::Get_Sub_Node( const char * name ) +WWProfileHierarchyNodeClass * WWProfileHierarchyNodeClass::Get_Sub_Node( const char * name ) { // Try to find this sub node - WWProfileHierachyNodeClass * child = Child; + WWProfileHierarchyNodeClass * child = Child; while ( child ) { if ( child->Name == name ) { return child; @@ -259,7 +259,7 @@ WWProfileHierachyNodeClass * WWProfileHierachyNodeClass::Get_Sub_Node( const cha } // We didn't find it, so add it - WWProfileHierachyNodeClass * node = W3DNEW WWProfileHierachyNodeClass( name, this ); + WWProfileHierarchyNodeClass * node = W3DNEW WWProfileHierarchyNodeClass( name, this ); node->Sibling = Child; Child = node; return node; @@ -267,7 +267,7 @@ WWProfileHierachyNodeClass * WWProfileHierachyNodeClass::Get_Sub_Node( const cha /*********************************************************************************************** - * WWProfileHierachyNodeClass::Reset -- Reset all profiling data in the tree * + * WWProfileHierarchyNodeClass::Reset -- Reset all profiling data in the tree * * * * INPUT: * * * @@ -278,7 +278,7 @@ WWProfileHierachyNodeClass * WWProfileHierachyNodeClass::Get_Sub_Node( const cha * HISTORY: * * 9/24/2000 gth : Created. * *=============================================================================================*/ -void WWProfileHierachyNodeClass::Reset( void ) +void WWProfileHierarchyNodeClass::Reset( void ) { TotalCalls = 0; TotalTime = 0.0f; @@ -293,7 +293,7 @@ void WWProfileHierachyNodeClass::Reset( void ) /*********************************************************************************************** - * WWProfileHierachyNodeClass::Call -- Start timing * + * WWProfileHierarchyNodeClass::Call -- Start timing * * * * INPUT: * * * @@ -304,7 +304,7 @@ void WWProfileHierachyNodeClass::Reset( void ) * HISTORY: * * 9/24/2000 gth : Created. * *=============================================================================================*/ -void WWProfileHierachyNodeClass::Call( void ) +void WWProfileHierarchyNodeClass::Call( void ) { TotalCalls++; if (RecursionCounter++ == 0) { @@ -314,7 +314,7 @@ void WWProfileHierachyNodeClass::Call( void ) /*********************************************************************************************** - * WWProfileHierachyNodeClass::Return -- Stop timing, record results * + * WWProfileHierarchyNodeClass::Return -- Stop timing, record results * * * * INPUT: * * * @@ -325,7 +325,7 @@ void WWProfileHierachyNodeClass::Call( void ) * HISTORY: * * 9/24/2000 gth : Created. * *=============================================================================================*/ -bool WWProfileHierachyNodeClass::Return( void ) +bool WWProfileHierarchyNodeClass::Return( void ) { if (--RecursionCounter == 0) { if ( TotalCalls != 0 ) { @@ -346,9 +346,9 @@ bool WWProfileHierachyNodeClass::Return( void ) ** ***************************************************************************************************/ bool WWProfileManager::IsProfileEnabled=false; -WWProfileHierachyNodeClass WWProfileManager::Root( "Root", NULL ); -WWProfileHierachyNodeClass * WWProfileManager::CurrentNode = &WWProfileManager::Root; -WWProfileHierachyNodeClass * WWProfileManager::CurrentRootNode = &WWProfileManager::Root; +WWProfileHierarchyNodeClass WWProfileManager::Root( "Root", nullptr ); +WWProfileHierarchyNodeClass * WWProfileManager::CurrentNode = &WWProfileManager::Root; +WWProfileHierarchyNodeClass * WWProfileManager::CurrentRootNode = &WWProfileManager::Root; int WWProfileManager::FrameCounter = 0; __int64 WWProfileManager::ResetTime = 0; @@ -482,7 +482,7 @@ void WWProfileManager::Increment_Frame_Counter( void ) if (ProfileCollecting) { float time=Get_Time_Since_Reset(); TotalFrameTimes+=time; - WWProfileHierachyNodeClass* new_root=Root.Clone_Hierarchy(NULL); + WWProfileHierarchyNodeClass* new_root=Root.Clone_Hierarchy(nullptr); new_root->Set_Total_Time(time); new_root->Set_Total_Calls(1); ProfileCollectVector.Add(new_root); @@ -564,7 +564,7 @@ void WWProfileManager::End_Collecting(const char* filename) int i; if (filename && ProfileCollectVector.Count()!=0) { FileClass * file= _TheWritingFileFactory->Get_File(filename); - if (file != NULL) { + if (file != nullptr) { // // Open or create the file // @@ -717,14 +717,14 @@ static unsigned Read_ID(char* memory,unsigned pos,unsigned maxpos,StringClass& s return Read_Line(memory,pos,maxpos); } -static unsigned Read_Frame(char* memory,unsigned pos,unsigned maxpos,WWProfileHierachyInfoClass*& root,HashTemplateClass& id_hash) +static unsigned Read_Frame(char* memory,unsigned pos,unsigned maxpos,WWProfileHierarchyInfoClass*& root,HashTemplateClass& id_hash) { char statusstring[256]; unsigned framenumber=0; float frametime; - root=NULL; - WWProfileHierachyInfoClass* parent=NULL; - WWProfileHierachyInfoClass* latest=NULL; + root=nullptr; + WWProfileHierarchyInfoClass* parent=nullptr; + WWProfileHierarchyInfoClass* latest=nullptr; pos+=7; // "FRAME: " @@ -757,7 +757,7 @@ static unsigned Read_Frame(char* memory,unsigned pos,unsigned maxpos,WWProfileHi StringClass name="Unknown"; id_hash.Get(id,name); - WWProfileHierachyInfoClass* new_node=new WWProfileHierachyInfoClass(name,parent); + WWProfileHierarchyInfoClass* new_node=new WWProfileHierarchyInfoClass(name,parent); if (parent) { new_node->Set_Sibling(parent->Get_Child()); parent->Set_Child(new_node); @@ -765,7 +765,7 @@ static unsigned Read_Frame(char* memory,unsigned pos,unsigned maxpos,WWProfileHi new_node->Set_Total_Time(time); new_node->Set_Total_Calls(count); latest=new_node; - if (root==NULL) root=new_node; + if (root==nullptr) root=new_node; } else if (memory[pos]=='{') { parent=latest; @@ -785,17 +785,17 @@ static unsigned Read_Frame(char* memory,unsigned pos,unsigned maxpos,WWProfileHi return Read_Line(memory,pos,maxpos); } -void WWProfileManager::Load_Profile_Log(const char* filename, WWProfileHierachyInfoClass**& array, unsigned& count) +void WWProfileManager::Load_Profile_Log(const char* filename, WWProfileHierarchyInfoClass**& array, unsigned& count) { - array=NULL; + array=nullptr; count=0; unsigned i; FileClass * file= _TheFileFactory->Get_File(filename); - if (file != NULL && file->Is_Available()) { + if (file != nullptr && file->Is_Available()) { HashTemplateClass string_hash; HashTemplateClass id_hash; - SimpleDynVecClass vec; + SimpleDynVecClass vec; // // Open or create the file @@ -819,7 +819,7 @@ void WWProfileManager::Load_Profile_Log(const char* filename, WWProfileHierachyI id_hash.Insert(id,string); } else if (tmp[0]=='F' && tmp[1]=='R' && tmp[2]=='A' && tmp[3]=='M' && tmp[4]=='E' && tmp[5]==':') { - WWProfileHierachyInfoClass* node=NULL; + WWProfileHierarchyInfoClass* node=nullptr; pos=Read_Frame(memory,pos,size,node,id_hash); if (node) { vec.Add(node); @@ -833,7 +833,7 @@ void WWProfileManager::Load_Profile_Log(const char* filename, WWProfileHierachyI if (vec.Count()) { count=vec.Count(); - array=new WWProfileHierachyInfoClass*[count]; + array=new WWProfileHierarchyInfoClass*[count]; for (i=0;iGet_Child(); @@ -902,7 +902,7 @@ void WWProfileIterator::Next(void) bool WWProfileIterator::Is_Done(void) { - return CurrentChild == NULL; + return CurrentChild == nullptr; } void WWProfileIterator::Enter_Child( void ) @@ -914,12 +914,12 @@ void WWProfileIterator::Enter_Child( void ) void WWProfileIterator::Enter_Child( int index ) { CurrentChild = CurrentParent->Get_Child(); - while ( (CurrentChild != NULL) && (index != 0) ) { + while ( (CurrentChild != nullptr) && (index != 0) ) { index--; CurrentChild = CurrentChild->Get_Sibling(); } - if ( CurrentChild != NULL ) { + if ( CurrentChild != nullptr ) { CurrentParent = CurrentChild; CurrentChild = CurrentParent->Get_Child(); } @@ -927,7 +927,7 @@ void WWProfileIterator::Enter_Child( int index ) void WWProfileIterator::Enter_Parent( void ) { - if ( CurrentParent->Get_Parent() != NULL ) { + if ( CurrentParent->Get_Parent() != nullptr ) { CurrentParent = CurrentParent->Get_Parent(); } CurrentChild = CurrentParent->Get_Child(); @@ -958,13 +958,13 @@ void WWProfileInOrderIterator::Next(void) } else { // if not, go to my parent's sibling, or his....... // Find a parent with a sibling.... bool done = false; - while ( CurrentNode != NULL && !done ) { + while ( CurrentNode != nullptr && !done ) { // go to my parent CurrentNode = CurrentNode->Get_Parent(); // If I have a sibling, go there - if ( CurrentNode != NULL && CurrentNode->Get_Sibling() != NULL ) { + if ( CurrentNode != nullptr && CurrentNode->Get_Sibling() != nullptr ) { CurrentNode = CurrentNode->Get_Sibling(); done = true; } @@ -974,7 +974,7 @@ void WWProfileInOrderIterator::Next(void) bool WWProfileInOrderIterator::Is_Done(void) { - return CurrentNode == NULL; + return CurrentNode == nullptr; } /* @@ -1003,7 +1003,7 @@ WWTimeItClass::~WWTimeItClass( void ) */ WWMeasureItClass::WWMeasureItClass( float * p_result ) { - WWASSERT(p_result != NULL); + WWASSERT(p_result != nullptr); PResult = p_result; WWProfile_Get_Ticks( &Time ); } @@ -1013,7 +1013,7 @@ WWMeasureItClass::~WWMeasureItClass( void ) __int64 End; WWProfile_Get_Ticks( &End ); End -= Time; - WWASSERT(PResult != NULL); + WWASSERT(PResult != nullptr); *PResult = End * WWProfile_Get_Inv_Processor_Ticks_Per_Second(); } @@ -1080,7 +1080,7 @@ void WWMemoryAndTimeLog::Log_Intermediate(const char* text) } /*********************************************************************************************** - * WWProfileHierachyInfoClass::WWProfileHierachyInfoClass -- Constructor * + * WWProfileHierarchyInfoClass::WWProfileHierarchyInfoClass -- Constructor * * * * * * INPUT: * @@ -1093,18 +1093,18 @@ void WWMemoryAndTimeLog::Log_Intermediate(const char* text) * * * HISTORY: * *=============================================================================================*/ -WWProfileHierachyInfoClass::WWProfileHierachyInfoClass( const char * name, WWProfileHierachyInfoClass * parent ) : +WWProfileHierarchyInfoClass::WWProfileHierarchyInfoClass( const char * name, WWProfileHierarchyInfoClass * parent ) : Name( name ), TotalCalls( 0 ), TotalTime( 0 ), Parent( parent ), - Child( NULL ), - Sibling( NULL ) + Child( nullptr ), + Sibling( nullptr ) { } /*********************************************************************************************** - * WWProfileHierachyNodeClass::~WWProfileHierachyNodeClass -- Destructor * + * WWProfileHierarchyNodeClass::~WWProfileHierarchyNodeClass -- Destructor * * * * INPUT: * * * @@ -1115,7 +1115,7 @@ WWProfileHierachyInfoClass::WWProfileHierachyInfoClass( const char * name, WWPro * HISTORY: * * 9/24/2000 gth : Created. * *=============================================================================================*/ -WWProfileHierachyInfoClass::~WWProfileHierachyInfoClass( void ) +WWProfileHierarchyInfoClass::~WWProfileHierarchyInfoClass( void ) { delete Child; delete Sibling; diff --git a/Core/Libraries/Source/WWVegas/WWDebug/wwprofile.h b/Core/Libraries/Source/WWVegas/WWDebug/wwprofile.h index ba76edea986..67bb3c832c7 100644 --- a/Core/Libraries/Source/WWVegas/WWDebug/wwprofile.h +++ b/Core/Libraries/Source/WWVegas/WWDebug/wwprofile.h @@ -55,22 +55,22 @@ class FileClass; /* ** A node in the WWProfile Hierarchy Tree */ -class WWProfileHierachyNodeClass { +class WWProfileHierarchyNodeClass { public: - WWProfileHierachyNodeClass( const char * name, WWProfileHierachyNodeClass * parent ); - WWProfileHierachyNodeClass( unsigned id, WWProfileHierachyNodeClass * parent ); - ~WWProfileHierachyNodeClass( void ); + WWProfileHierarchyNodeClass( const char * name, WWProfileHierarchyNodeClass * parent ); + WWProfileHierarchyNodeClass( unsigned id, WWProfileHierarchyNodeClass * parent ); + ~WWProfileHierarchyNodeClass( void ); - WWProfileHierachyNodeClass * Get_Sub_Node( const char * name ); + WWProfileHierarchyNodeClass * Get_Sub_Node( const char * name ); - WWProfileHierachyNodeClass * Get_Parent( void ) { return Parent; } - WWProfileHierachyNodeClass * Get_Sibling( void ) { return Sibling; } - WWProfileHierachyNodeClass * Get_Child( void ) { return Child; } + WWProfileHierarchyNodeClass * Get_Parent( void ) { return Parent; } + WWProfileHierarchyNodeClass * Get_Sibling( void ) { return Sibling; } + WWProfileHierarchyNodeClass * Get_Child( void ) { return Child; } - void Set_Parent( WWProfileHierachyNodeClass *node ) { Parent=node; } - void Set_Sibling( WWProfileHierachyNodeClass *node ) { Sibling=node; } - void Set_Child( WWProfileHierachyNodeClass *node ) { Child=node; } + void Set_Parent( WWProfileHierarchyNodeClass *node ) { Parent=node; } + void Set_Sibling( WWProfileHierarchyNodeClass *node ) { Sibling=node; } + void Set_Child( WWProfileHierarchyNodeClass *node ) { Child=node; } void Reset( void ); void Call( void ); @@ -82,7 +82,7 @@ class WWProfileHierachyNodeClass { void Set_Total_Calls(int calls) { TotalCalls=calls; } void Set_Total_Time(float time) { TotalTime=time; } - WWProfileHierachyNodeClass* Clone_Hierarchy(WWProfileHierachyNodeClass* parent); + WWProfileHierarchyNodeClass* Clone_Hierarchy(WWProfileHierarchyNodeClass* parent); void Write_To_File(FileClass* file,int recursion); void Add_To_String_Compact(StringClass& string,int recursion); @@ -96,23 +96,23 @@ class WWProfileHierachyNodeClass { int RecursionCounter; unsigned ProfileStringID; - WWProfileHierachyNodeClass * Parent; - WWProfileHierachyNodeClass * Child; - WWProfileHierachyNodeClass * Sibling; + WWProfileHierarchyNodeClass * Parent; + WWProfileHierarchyNodeClass * Child; + WWProfileHierarchyNodeClass * Sibling; }; -class WWProfileHierachyInfoClass { +class WWProfileHierarchyInfoClass { public: - WWProfileHierachyInfoClass( const char * name, WWProfileHierachyInfoClass * parent ); - ~WWProfileHierachyInfoClass( void ); + WWProfileHierarchyInfoClass( const char * name, WWProfileHierarchyInfoClass * parent ); + ~WWProfileHierarchyInfoClass( void ); - WWProfileHierachyInfoClass * Get_Parent( void ) { return Parent; } - WWProfileHierachyInfoClass * Get_Sibling( void ) { return Sibling; } - WWProfileHierachyInfoClass * Get_Child( void ) { return Child; } + WWProfileHierarchyInfoClass * Get_Parent( void ) { return Parent; } + WWProfileHierarchyInfoClass * Get_Sibling( void ) { return Sibling; } + WWProfileHierarchyInfoClass * Get_Child( void ) { return Child; } - void Set_Parent( WWProfileHierachyInfoClass *node ) { Parent=node; } - void Set_Sibling( WWProfileHierachyInfoClass *node ) { Sibling=node; } - void Set_Child( WWProfileHierachyInfoClass *node ) { Child=node; } + void Set_Parent( WWProfileHierarchyInfoClass *node ) { Parent=node; } + void Set_Sibling( WWProfileHierarchyInfoClass *node ) { Sibling=node; } + void Set_Child( WWProfileHierarchyInfoClass *node ) { Child=node; } const char * Get_Name( void ) { return Name; } void Set_Name( const char* name ) { Name=name; } @@ -127,9 +127,9 @@ class WWProfileHierachyInfoClass { int TotalCalls; float TotalTime; - WWProfileHierachyInfoClass * Parent; - WWProfileHierachyInfoClass * Child; - WWProfileHierachyInfoClass * Sibling; + WWProfileHierarchyInfoClass * Parent; + WWProfileHierarchyInfoClass * Child; + WWProfileHierarchyInfoClass * Sibling; }; /* @@ -158,10 +158,10 @@ class WWProfileIterator float Get_Current_Parent_Total_Time( void ) { return CurrentParent->Get_Total_Time(); } protected: - WWProfileHierachyNodeClass * CurrentParent; - WWProfileHierachyNodeClass * CurrentChild; + WWProfileHierarchyNodeClass * CurrentParent; + WWProfileHierarchyNodeClass * CurrentChild; - WWProfileIterator( WWProfileHierachyNodeClass * start ); + WWProfileIterator( WWProfileHierarchyNodeClass * start ); friend class WWProfileManager; }; @@ -182,7 +182,7 @@ class WWProfileInOrderIterator float Get_Current_Total_Time( void ) { return CurrentNode->Get_Total_Time(); } protected: - WWProfileHierachyNodeClass * CurrentNode; + WWProfileHierarchyNodeClass * CurrentNode; WWProfileInOrderIterator( void ); friend class WWProfileManager; @@ -213,17 +213,17 @@ class WWProfileManager { static WWProfileInOrderIterator * Get_In_Order_Iterator( void ); static void Release_In_Order_Iterator( WWProfileInOrderIterator * iterator ); - static WWProfileHierachyNodeClass * Get_Root( void ) { return &Root; } + static WWProfileHierarchyNodeClass * Get_Root( void ) { return &Root; } static void Begin_Collecting(); static void End_Collecting(const char* filename); - static void Load_Profile_Log(const char* filename, WWProfileHierachyInfoClass**& array, unsigned& count); + static void Load_Profile_Log(const char* filename, WWProfileHierarchyInfoClass**& array, unsigned& count); private: - static WWProfileHierachyNodeClass Root; - static WWProfileHierachyNodeClass * CurrentNode; - static WWProfileHierachyNodeClass * CurrentRootNode; + static WWProfileHierarchyNodeClass Root; + static WWProfileHierarchyNodeClass * CurrentNode; + static WWProfileHierarchyNodeClass * CurrentRootNode; static int FrameCounter; static __int64 ResetTime; static bool IsProfileEnabled; diff --git a/Core/Libraries/Source/WWVegas/WWDownload/Download.cpp b/Core/Libraries/Source/WWVegas/WWDownload/Download.cpp index 8f8ab20e218..10d874a324a 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/Download.cpp +++ b/Core/Libraries/Source/WWVegas/WWDownload/Download.cpp @@ -57,9 +57,9 @@ HRESULT CDownload::DownloadFile(LPCSTR server, LPCSTR username, LPCSTR password, // Check all parameters are non-null. - if( ( server == NULL ) || ( username == NULL ) || - ( password == NULL ) || ( file == NULL ) || - ( localfile == NULL ) || ( regkey == NULL ) ) + if( ( server == nullptr ) || ( username == nullptr ) || + ( password == nullptr ) || ( file == nullptr ) || + ( localfile == nullptr ) || ( regkey == nullptr ) ) { //////////DBGMSG("Download Paramerror"); return( DOWNLOAD_PARAMERROR ); @@ -110,7 +110,7 @@ HRESULT CDownload::DownloadFile(LPCSTR server, LPCSTR username, LPCSTR password, // Get the local filename of the last file we requested to download.... // HRESULT CDownload::GetLastLocalFile(char *local_file, int maxlen) { - if (local_file==0) + if (local_file==nullptr) return(E_FAIL); strlcpy(local_file, m_LastLocalFile, maxlen); diff --git a/Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp b/Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp index 01e67957ea2..a73e28ba216 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp +++ b/Core/Libraries/Source/WWVegas/WWDownload/FTP.cpp @@ -133,7 +133,7 @@ static bool Use_Non_Blocking_Mode(void) // Fetch the flag bufsiz=sizeof(value); type=REG_DWORD; - regRetval=RegQueryValueEx(regKey, "UseNonBlockingFTP", 0, &type, (BYTE*) &value, &bufsiz); + regRetval=RegQueryValueEx(regKey, "UseNonBlockingFTP", nullptr, &type, (BYTE*) &value, &bufsiz); RegCloseKey(regKey); @@ -198,7 +198,7 @@ Cftp::~Cftp() if (m_pfLocalFile) { fclose(m_pfLocalFile); - m_pfLocalFile = NULL; + m_pfLocalFile = nullptr; } } @@ -235,7 +235,7 @@ void Cftp::ZeroStuff(void) m_iFilePos = 0; m_iStatus = FTPSTAT_INIT; m_sendNewPortStatus = 0; - m_pfLocalFile = NULL; + m_pfLocalFile = nullptr; m_findStart = 0; memset(&m_CommandSockAddr, 0, sizeof(m_CommandSockAddr)); memset(&m_DataSockAddr, 0, sizeof(m_DataSockAddr)); @@ -269,7 +269,7 @@ int Cftp::AsyncGetHostByName(char * szName, struct sockaddr_in &address ) gThreadFlag = 0; memset(&gThreadAddress,0,sizeof(gThreadAddress)); - if( CreateThread( NULL, 0, gethostbynameA, szName, 0, &threadid ) == NULL ) + if( CreateThread( nullptr, 0, gethostbynameA, szName, 0, &threadid ) == nullptr ) { return( FTP_FAILED ); } @@ -300,7 +300,7 @@ int Cftp::AsyncGetHostByName(char * szName, struct sockaddr_in &address ) * HRESULT Cftp::ConnectToServer(LPCSTR szServerName) * * $_Description : -* Overloaded funciton that makes a connection to a server. Will probably +* Overloaded function that makes a connection to a server. Will probably * fail on (at least) the first call, as it may take a while for the server * to send it's "ready" reply. * @@ -426,7 +426,7 @@ HRESULT Cftp::ConnectToServer(LPCSTR szServerName) timeval tv; tv.tv_sec=0; tv.tv_usec=0; - int retval=select(m_iCommandSocket+1,0,&wset,&eset,&tv); + int retval=select(m_iCommandSocket+1,nullptr,&wset,&eset,&tv); if (retval == 0) // not ready yet.... return(FTP_TRYING); if (FD_ISSET(m_iCommandSocket, &eset)) { @@ -494,9 +494,9 @@ HRESULT Cftp::LoginToServer( LPCSTR szUserName, LPCSTR szPassword ) if( m_iStatus == FTPSTAT_CONNECTED ) { - sprintf( command, "USER %s\r\n", m_szUserName ); + snprintf( command, ARRAY_SIZE(command), "USER %s\r\n", m_szUserName ); - if( SendCommand( command, 7 + strlen( m_szUserName ) ) < 0 ) + if( SendCommand( command, (int)strlen( command ) ) < 0 ) { return( FTP_TRYING ); } @@ -517,9 +517,9 @@ HRESULT Cftp::LoginToServer( LPCSTR szUserName, LPCSTR szPassword ) if( m_iStatus == FTPSTAT_SENTUSER ) { - sprintf( command, "PASS %s\r\n", m_szPassword ); + snprintf( command, ARRAY_SIZE(command), "PASS %s\r\n", m_szPassword ); - if( SendCommand( command, 7 + strlen( m_szPassword ) ) < 0 ) + if( SendCommand( command, (int)strlen( command ) ) < 0 ) { return( FTP_TRYING ); } @@ -665,9 +665,9 @@ HRESULT Cftp::FindFile( LPCSTR szRemoteFileName, int * piSize ) char ext[ 10 ]; if (m_findStart==0) - m_findStart=time(NULL); + m_findStart=time(nullptr); - if((time(NULL)-m_findStart) > 30) // try for 30 seconds + if((time(nullptr)-m_findStart) > 30) // try for 30 seconds { /////////DBGMSG("FindFile: Tried for too long"); m_findStart=0; @@ -675,7 +675,7 @@ HRESULT Cftp::FindFile( LPCSTR szRemoteFileName, int * piSize ) } //strcpy(m_szRemoteFilePath, "/"); // start at home - _splitpath( szRemoteFileName, NULL, m_szRemoteFilePath+strlen(m_szRemoteFilePath), + _splitpath( szRemoteFileName, nullptr, m_szRemoteFilePath+strlen(m_szRemoteFilePath), m_szRemoteFileName, ext ); strlcat(m_szRemoteFileName, ext, ARRAY_SIZE(m_szRemoteFileName)); @@ -694,9 +694,9 @@ HRESULT Cftp::FindFile( LPCSTR szRemoteFileName, int * piSize ) if( ( m_iStatus == FTPSTAT_LOGGEDIN ) || ( m_iStatus == FTPSTAT_FILEFOUND ) ) { - sprintf( command, "CWD %s\r\n", m_szRemoteFilePath ); + snprintf( command, ARRAY_SIZE(command), "CWD %s\r\n", m_szRemoteFilePath ); - if( SendCommand( command, 6 + strlen( m_szRemoteFilePath ) ) < 0 ) + if( SendCommand( command, (int)strlen( command ) ) < 0 ) { return( FTP_TRYING ); } @@ -747,9 +747,9 @@ HRESULT Cftp::FindFile( LPCSTR szRemoteFileName, int * piSize ) if( m_iStatus == FTPSTAT_SENTPORT ) { - sprintf( command, "LIST %s\r\n", m_szRemoteFileName ); + snprintf( command, ARRAY_SIZE(command), "LIST %s\r\n", m_szRemoteFileName ); - if( SendCommand( command, 7 + strlen( m_szRemoteFileName ) ) < 0 ) + if( SendCommand( command, (int)strlen( command ) ) < 0 ) { return( FTP_TRYING ); } @@ -830,7 +830,7 @@ HRESULT Cftp::FindFile( LPCSTR szRemoteFileName, int * piSize ) if( sscanf( &listline[ 32 ], " %d ", &i ) == 1 ) { - if( piSize != NULL ) + if( piSize != nullptr ) { *piSize = i; m_iFileSize = i; @@ -949,7 +949,7 @@ HRESULT Cftp::RecvReply( LPCSTR pReplyBuffer, int iSize, int * piRetCode ) // Verify that this is a complete line, if not we will keep trying til // we have one. char *end=strstr(pc, "\r\n"); - if (end == 0) + if (end == nullptr) return(FTP_TRYING); // OK, we've got a line, pull it from the socket... @@ -1028,7 +1028,7 @@ unsigned long MyIPAddress( int sockfd ) pHE = gethostbyname( pBuffer ); - if( pHE == NULL ) + if( pHE == nullptr ) { return( FTP_FAILED ); } @@ -1039,7 +1039,7 @@ unsigned long MyIPAddress( int sockfd ) i = 0; - while( ( pAddr = pHE->h_addr_list[ i++ ] ) != NULL ) + while( ( pAddr = pHE->h_addr_list[ i++ ] ) != nullptr ) { ip = *((unsigned long *)pAddr ); @@ -1227,7 +1227,7 @@ int Cftp::OpenDataConnection() return( FTP_FAILED ); } - if( ( iNewSocket = accept( m_iDataSocket, NULL, 0 ) ) < 0 ) + if( ( iNewSocket = accept( m_iDataSocket, nullptr, nullptr ) ) < 0 ) { if( WSAGetLastError() != (WSAEWOULDBLOCK ) ) { @@ -1391,7 +1391,7 @@ HRESULT Cftp::GetNextFileBlock( LPCSTR szLocalFileName, int * piTotalRead ) int res, iReply; char downloadfilename[256]; - GetDownloadFilename(szLocalFileName, downloadfilename); + GetDownloadFilename(szLocalFileName, downloadfilename, ARRAY_SIZE(downloadfilename)); //char str[ 256 ]; @@ -1404,14 +1404,14 @@ HRESULT Cftp::GetNextFileBlock( LPCSTR szLocalFileName, int * piTotalRead ) { if( m_iFilePos == 0 ) { - if( ( m_pfLocalFile = fopen( downloadfilename, "wb" ) ) == NULL ) + if( ( m_pfLocalFile = fopen( downloadfilename, "wb" ) ) == nullptr ) { return( FTP_FAILED ); } } else { - if( ( m_pfLocalFile = fopen( downloadfilename, "ab" ) ) == NULL ) + if( ( m_pfLocalFile = fopen( downloadfilename, "ab" ) ) == nullptr ) { return( FTP_FAILED ); } @@ -1507,7 +1507,7 @@ HRESULT Cftp::GetNextFileBlock( LPCSTR szLocalFileName, int * piTotalRead ) if( m_iStatus == FTPSTAT_SENTREST ) { - sprintf( command, "RETR %s\r\n", m_szRemoteFileName ); + snprintf( command, ARRAY_SIZE(command), "RETR %s\r\n", m_szRemoteFileName ); if( SendCommand( command, strlen( command ) ) < 0 ) { @@ -1563,7 +1563,7 @@ HRESULT Cftp::GetNextFileBlock( LPCSTR szLocalFileName, int * piTotalRead ) m_iFilePos += totread; // update read position - if( piTotalRead != NULL ) + if( piTotalRead != nullptr ) *piTotalRead = m_iFilePos; @@ -1599,7 +1599,7 @@ HRESULT Cftp::GetNextFileBlock( LPCSTR szLocalFileName, int * piTotalRead ) if( m_iStatus == FTPSTAT_FILEDATACLOSED ) { CloseDataConnection(); fclose( m_pfLocalFile ); - m_pfLocalFile = NULL; + m_pfLocalFile = nullptr; /* * Move the file from the temporary download location to its @@ -1607,7 +1607,7 @@ HRESULT Cftp::GetNextFileBlock( LPCSTR szLocalFileName, int * piTotalRead ) */ char downloadfilename[256]; - GetDownloadFilename(m_szLocalFileName, downloadfilename); + GetDownloadFilename(m_szLocalFileName, downloadfilename, ARRAY_SIZE(downloadfilename)); // Make sure the path exists for the new file char curdir[256]; @@ -1688,10 +1688,10 @@ HRESULT Cftp::GetNextFileBlock( LPCSTR szLocalFileName, int * piTotalRead ) HRESULT Cftp::FileRecoveryPosition( LPCSTR szLocalFileName, LPCSTR szRegistryRoot ) { char downloadfilename[256]; - GetDownloadFilename(szLocalFileName, downloadfilename); + GetDownloadFilename(szLocalFileName, downloadfilename, ARRAY_SIZE(downloadfilename)); FILE *testfp = fopen( downloadfilename, "rb" ); - if( testfp == NULL ) + if( testfp == nullptr ) { m_iFilePos = 0; return 0; @@ -1711,7 +1711,7 @@ HRESULT Cftp::FileRecoveryPosition( LPCSTR szLocalFileName, LPCSTR szRegistryRo char regkey[ 512 ]; unsigned long t1, t2; - if( ( szRegistryRoot == NULL ) || ( szLocalFileName == NULL ) ) + if( ( szRegistryRoot == nullptr ) || ( szLocalFileName == nullptr ) ) { // Bail out return( 0 ); @@ -1760,7 +1760,7 @@ HRESULT Cftp::FileRecoveryPosition( LPCSTR szLocalFileName, LPCSTR szRegistryRo // File previously downloaded testfp = fopen( FTP_TEMPFILENAME, "rb" ); - if( testfp == NULL ) + if( testfp == nullptr ) { m_iFilePos = 0; RegCloseKey(hkey); @@ -1793,7 +1793,7 @@ HRESULT Cftp::FileRecoveryPosition( LPCSTR szLocalFileName, LPCSTR szRegistryRo // // convert a local name to a temp filename to use for downloading // -void Cftp::GetDownloadFilename(const char *localname, char *downloadname) +void Cftp::GetDownloadFilename(const char *localname, char *downloadname, size_t downloadname_size) { char *name = strdup(localname); char *s = name; @@ -1803,7 +1803,7 @@ void Cftp::GetDownloadFilename(const char *localname, char *downloadname) *s = '_'; ++s; } - sprintf(downloadname,"download\\%s_%d.tmp",name,m_iFileSize); + snprintf(downloadname, downloadname_size, "download\\%s_%d.tmp", name, m_iFileSize); free(name); /* Wstring name; @@ -1831,8 +1831,8 @@ bool Prepare_Directories(const char *rootdir, const char *filename) while(cptr=strchr(cptr,'\\')) { strlcpy(tempstr,filename,cptr-filename + 1); - sprintf(newdir,"%s\\%s",rootdir, tempstr); - if (!CreateDirectory(newdir, NULL)) + snprintf(newdir, ARRAY_SIZE(newdir), "%s\\%s", rootdir, tempstr); + if (!CreateDirectory(newdir, nullptr)) return false; //if ((_mkdir(newdir) == -1) && ((errno == ENOENT || errno==EACCES))) //return(false); diff --git a/Core/Libraries/Source/WWVegas/WWDownload/Registry.h b/Core/Libraries/Source/WWVegas/WWDownload/Registry.h index 527e9adfde1..c8f0b5cda64 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/Registry.h +++ b/Core/Libraries/Source/WWVegas/WWDownload/Registry.h @@ -17,7 +17,7 @@ */ // Registry.h -// Simple interface for storing/retreiving registry values +// Simple interface for storing/retrieving registry values // Author: Matthew D. Campbell, December 2001 #pragma once diff --git a/Core/Libraries/Source/WWVegas/WWDownload/ftp.h b/Core/Libraries/Source/WWVegas/WWDownload/ftp.h index 08c5918ab47..31d4d0e43d9 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/ftp.h +++ b/Core/Libraries/Source/WWVegas/WWDownload/ftp.h @@ -22,7 +22,8 @@ //#include "../resource.h" // main symbols -#include "winsock.h" +#include +#include #include #include "WWDownload/ftpdefs.h" @@ -83,7 +84,7 @@ class Cftp int AsyncGetHostByName( char * szName, struct sockaddr_in &address ); // Convert a local filename into a temp filename to download into - void GetDownloadFilename( const char* localname, char* downloadname); + void GetDownloadFilename( const char* localname, char* downloadname, size_t downloadname_size); void CloseSockets(void); void ZeroStuff(void); diff --git a/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp b/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp index 494e09ecb29..d31c4222fd9 100644 --- a/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp +++ b/Core/Libraries/Source/WWVegas/WWDownload/registry.cpp @@ -17,7 +17,7 @@ */ // Registry.cpp -// Simple interface for storing/retreiving registry values +// Simple interface for storing/retrieving registry values // Author: Matthew D. Campbell, December 2001 #include @@ -37,7 +37,7 @@ bool getStringFromRegistry(HKEY root, std::string path, std::string key, std::s if ((returnValue = RegOpenKeyEx( root, path.c_str(), 0, KEY_READ, &handle )) == ERROR_SUCCESS) { - returnValue = RegQueryValueEx(handle, key.c_str(), NULL, &type, (unsigned char *) &buffer, &size); + returnValue = RegQueryValueEx(handle, key.c_str(), nullptr, &type, (unsigned char *) &buffer, &size); RegCloseKey( handle ); } @@ -60,7 +60,7 @@ bool getUnsignedIntFromRegistry(HKEY root, std::string path, std::string key, un if ((returnValue = RegOpenKeyEx( root, path.c_str(), 0, KEY_READ, &handle )) == ERROR_SUCCESS) { - returnValue = RegQueryValueEx(handle, key.c_str(), NULL, &type, (unsigned char *) &buffer, &size); + returnValue = RegQueryValueEx(handle, key.c_str(), nullptr, &type, (unsigned char *) &buffer, &size); RegCloseKey( handle ); } @@ -81,7 +81,7 @@ bool setStringInRegistry( HKEY root, std::string path, std::string key, std::str int size; char lpClass[] = "REG_NONE"; - if ((returnValue = RegCreateKeyEx( root, path.c_str(), 0, lpClass, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &handle, NULL )) == ERROR_SUCCESS) + if ((returnValue = RegCreateKeyEx( root, path.c_str(), 0, lpClass, REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &handle, nullptr )) == ERROR_SUCCESS) { type = REG_SZ; size = val.length()+1; @@ -100,7 +100,7 @@ bool setUnsignedIntInRegistry( HKEY root, std::string path, std::string key, uns int size; char lpClass[] = "REG_NONE"; - if ((returnValue = RegCreateKeyEx( root, path.c_str(), 0, lpClass, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &handle, NULL )) == ERROR_SUCCESS) + if ((returnValue = RegCreateKeyEx( root, path.c_str(), 0, lpClass, REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &handle, nullptr )) == ERROR_SUCCESS) { type = REG_DWORD; size = 4; diff --git a/Core/Libraries/Source/WWVegas/WWLib/BSEARCH.h b/Core/Libraries/Source/WWVegas/WWLib/BSEARCH.h index aed9a03a444..88d6885ae85 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/BSEARCH.h +++ b/Core/Libraries/Source/WWVegas/WWLib/BSEARCH.h @@ -64,5 +64,5 @@ T * Binary_Search(T * A, int n, T const & target) stride -= pivot + 1; } } - return (NULL); + return (nullptr); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt b/Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt index 997a6c02420..228506fee0e 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/WWLib/CMakeLists.txt @@ -176,6 +176,7 @@ target_include_directories(core_wwlib PUBLIC ) target_precompile_headers(core_wwlib PRIVATE + [["Utility/CppMacros.h"]] # Must be first, to be removed when abandoning VC6 always.h STLUtils.h win.h diff --git a/Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.cpp b/Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.cpp index 368bcd03ca7..dab6686125c 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/DbgHelpLoader.cpp @@ -19,24 +19,24 @@ #include "DbgHelpLoader.h" -DbgHelpLoader* DbgHelpLoader::Inst = NULL; +DbgHelpLoader* DbgHelpLoader::Inst = nullptr; 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) + : m_symInitialize(nullptr) + , m_symCleanup(nullptr) + , m_symLoadModule(nullptr) + , m_symUnloadModule(nullptr) + , m_symGetModuleBase(nullptr) + , m_symGetSymFromAddr(nullptr) + , m_symGetLineFromAddr(nullptr) + , m_symSetOptions(nullptr) + , m_symFunctionTableAccess(nullptr) + , m_stackWalk(nullptr) #ifdef RTS_ENABLE_CRASHDUMP - , m_miniDumpWriteDump(NULL) + , m_miniDumpWriteDump(nullptr) #endif - , m_dllModule(HMODULE(0)) + , m_dllModule(HMODULE(nullptr)) , m_referenceCount(0) , m_failed(false) , m_loadedFromSystem(false) @@ -51,7 +51,7 @@ bool DbgHelpLoader::isLoaded() { CriticalSectionClass::LockClass lock(CriticalSection); - return Inst != NULL && Inst->m_dllModule != HMODULE(0); + return Inst != nullptr && Inst->m_dllModule != HMODULE(nullptr); } bool DbgHelpLoader::isLoadedFromSystem() @@ -65,14 +65,14 @@ bool DbgHelpLoader::isFailed() { CriticalSectionClass::LockClass lock(CriticalSection); - return Inst != NULL && Inst->m_failed; + return Inst != nullptr && Inst->m_failed; } bool DbgHelpLoader::load() { CriticalSectionClass::LockClass lock(CriticalSection); - if (Inst == NULL) + if (Inst == nullptr) { // Cannot use new/delete here when this is loaded during game memory initialization. void* p = GlobalAlloc(GMEM_FIXED, sizeof(DbgHelpLoader)); @@ -96,11 +96,11 @@ bool DbgHelpLoader::load() strlcat(dllFilename, "\\dbghelp.dll", ARRAY_SIZE(dllFilename)); Inst->m_dllModule = ::LoadLibraryA(dllFilename); - if (Inst->m_dllModule == HMODULE(0)) + if (Inst->m_dllModule == HMODULE(nullptr)) { // Not found. Try load dbghelp.dll from the work directory. Inst->m_dllModule = ::LoadLibraryA("dbghelp.dll"); - if (Inst->m_dllModule == HMODULE(0)) + if (Inst->m_dllModule == HMODULE(nullptr)) { Inst->m_failed = true; return false; @@ -125,7 +125,7 @@ bool DbgHelpLoader::load() Inst->m_miniDumpWriteDump = reinterpret_cast(::GetProcAddress(Inst->m_dllModule, "MiniDumpWriteDump")); #endif - if (Inst->m_symInitialize == NULL || Inst->m_symCleanup == NULL) + if (Inst->m_symInitialize == nullptr || Inst->m_symCleanup == nullptr) { freeResources(); Inst->m_failed = true; @@ -139,7 +139,7 @@ void DbgHelpLoader::unload() { CriticalSectionClass::LockClass lock(CriticalSection); - if (Inst == NULL) + if (Inst == nullptr) return; if (--Inst->m_referenceCount != 0) @@ -149,7 +149,7 @@ void DbgHelpLoader::unload() Inst->~DbgHelpLoader(); GlobalFree(Inst); - Inst = NULL; + Inst = nullptr; } void DbgHelpLoader::freeResources() @@ -161,24 +161,24 @@ void DbgHelpLoader::freeResources() symCleanup(*Inst->m_initializedProcesses.begin()); } - if (Inst->m_dllModule != HMODULE(0)) + if (Inst->m_dllModule != HMODULE(nullptr)) { ::FreeLibrary(Inst->m_dllModule); - Inst->m_dllModule = HMODULE(0); + Inst->m_dllModule = HMODULE(nullptr); } - 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; + Inst->m_symInitialize = nullptr; + Inst->m_symCleanup = nullptr; + Inst->m_symLoadModule = nullptr; + Inst->m_symUnloadModule = nullptr; + Inst->m_symGetModuleBase = nullptr; + Inst->m_symGetSymFromAddr = nullptr; + Inst->m_symGetLineFromAddr = nullptr; + Inst->m_symSetOptions = nullptr; + Inst->m_symFunctionTableAccess = nullptr; + Inst->m_stackWalk = nullptr; #ifdef RTS_ENABLE_CRASHDUMP - Inst->m_miniDumpWriteDump = NULL; + Inst->m_miniDumpWriteDump = nullptr; #endif Inst->m_loadedFromSystem = false; @@ -191,7 +191,7 @@ BOOL DbgHelpLoader::symInitialize( { CriticalSectionClass::LockClass lock(CriticalSection); - if (Inst == NULL) + if (Inst == nullptr) return FALSE; if (Inst->m_initializedProcesses.find(hProcess) != Inst->m_initializedProcesses.end()) @@ -218,7 +218,7 @@ BOOL DbgHelpLoader::symCleanup( { CriticalSectionClass::LockClass lock(CriticalSection); - if (Inst == NULL) + if (Inst == nullptr) return FALSE; if (stl::find_and_erase(Inst->m_initializedProcesses, hProcess)) @@ -242,7 +242,7 @@ BOOL DbgHelpLoader::symLoadModule( { CriticalSectionClass::LockClass lock(CriticalSection); - if (Inst != NULL && Inst->m_symLoadModule) + if (Inst != nullptr && Inst->m_symLoadModule) return Inst->m_symLoadModule(hProcess, hFile, ImageName, ModuleName, BaseOfDll, SizeOfDll); return FALSE; @@ -254,7 +254,7 @@ DWORD DbgHelpLoader::symGetModuleBase( { CriticalSectionClass::LockClass lock(CriticalSection); - if (Inst != NULL && Inst->m_symGetModuleBase) + if (Inst != nullptr && Inst->m_symGetModuleBase) return Inst->m_symGetModuleBase(hProcess, dwAddr); return 0u; @@ -266,7 +266,7 @@ BOOL DbgHelpLoader::symUnloadModule( { CriticalSectionClass::LockClass lock(CriticalSection); - if (Inst != NULL && Inst->m_symUnloadModule) + if (Inst != nullptr && Inst->m_symUnloadModule) return Inst->m_symUnloadModule(hProcess, BaseOfDll); return FALSE; @@ -280,7 +280,7 @@ BOOL DbgHelpLoader::symGetSymFromAddr( { CriticalSectionClass::LockClass lock(CriticalSection); - if (Inst != NULL && Inst->m_symGetSymFromAddr) + if (Inst != nullptr && Inst->m_symGetSymFromAddr) return Inst->m_symGetSymFromAddr(hProcess, Address, Displacement, Symbol); return FALSE; @@ -294,7 +294,7 @@ BOOL DbgHelpLoader::symGetLineFromAddr( { CriticalSectionClass::LockClass lock(CriticalSection); - if (Inst != NULL && Inst->m_symGetLineFromAddr) + if (Inst != nullptr && Inst->m_symGetLineFromAddr) return Inst->m_symGetLineFromAddr(hProcess, dwAddr, pdwDisplacement, Line); return FALSE; @@ -305,7 +305,7 @@ DWORD DbgHelpLoader::symSetOptions( { CriticalSectionClass::LockClass lock(CriticalSection); - if (Inst != NULL && Inst->m_symSetOptions) + if (Inst != nullptr && Inst->m_symSetOptions) return Inst->m_symSetOptions(SymOptions); return 0u; @@ -317,10 +317,10 @@ LPVOID DbgHelpLoader::symFunctionTableAccess( { CriticalSectionClass::LockClass lock(CriticalSection); - if (Inst != NULL && Inst->m_symFunctionTableAccess) + if (Inst != nullptr && Inst->m_symFunctionTableAccess) return Inst->m_symFunctionTableAccess(hProcess, AddrBase); - return NULL; + return nullptr; } BOOL DbgHelpLoader::stackWalk( @@ -336,7 +336,7 @@ BOOL DbgHelpLoader::stackWalk( { CriticalSectionClass::LockClass lock(CriticalSection); - if (Inst != NULL && Inst->m_stackWalk) + if (Inst != nullptr && Inst->m_stackWalk) return Inst->m_stackWalk(MachineType, hProcess, hThread, StackFrame, ContextRecord, ReadMemoryRoutine, FunctionTableAccessRoutine, GetModuleBaseRoutine, TranslateAddress); return FALSE; @@ -354,7 +354,7 @@ BOOL DbgHelpLoader::miniDumpWriteDump( { CriticalSectionClass::LockClass lock(CriticalSection); - if (Inst != NULL && Inst->m_miniDumpWriteDump) + if (Inst != nullptr && Inst->m_miniDumpWriteDump) return Inst->m_miniDumpWriteDump(hProcess, ProcessId, hFile, DumpType, ExceptionParam, UserStreamParam, CallbackParam); return FALSE; diff --git a/Core/Libraries/Source/WWVegas/WWLib/Except.cpp b/Core/Libraries/Source/WWVegas/WWLib/Except.cpp index e49d6ffb0eb..201829f2ff7 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/Except.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/Except.cpp @@ -47,7 +47,7 @@ * Exception_Handler -- Exception handler filter function * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ -#ifdef _MSC_VER + #if defined(_WIN32) #include "always.h" #include @@ -85,8 +85,8 @@ static char ExceptionText [65536]; bool SymbolsAvailable = false; HINSTANCE ImageHelp = (HINSTANCE) -1; -void (*AppCallback)(void) = NULL; -char *(*AppVersionCallback)(void) = NULL; +void (*AppCallback)(void) = nullptr; +char *(*AppVersionCallback)(void) = nullptr; /* ** Flag to indicate we should exit when an exception occurs. @@ -127,15 +127,15 @@ typedef LPVOID (WINAPI *SymFunctionTableAccessType) (HANDLE hProcess, DWORD Addr typedef DWORD (WINAPI *SymGetModuleBaseType) (HANDLE hProcess, DWORD dwAddr); -static SymCleanupType _SymCleanup = NULL; -static SymGetSymFromAddrType _SymGetSymFromAddr = NULL; -static SymInitializeType _SymInitialize = NULL; -static SymLoadModuleType _SymLoadModule = NULL; -static SymSetOptionsType _SymSetOptions = NULL; -static SymUnloadModuleType _SymUnloadModule = NULL; -static StackWalkType _StackWalk = NULL; -static SymFunctionTableAccessType _SymFunctionTableAccess = NULL; -static SymGetModuleBaseType _SymGetModuleBase = NULL; +static SymCleanupType _SymCleanup = nullptr; +static SymGetSymFromAddrType _SymGetSymFromAddr = nullptr; +static SymInitializeType _SymInitialize = nullptr; +static SymLoadModuleType _SymLoadModule = nullptr; +static SymSetOptionsType _SymSetOptions = nullptr; +static SymUnloadModuleType _SymUnloadModule = nullptr; +static StackWalkType _StackWalk = nullptr; +static SymFunctionTableAccessType _SymFunctionTableAccess = nullptr; +static SymGetModuleBaseType _SymGetModuleBase = nullptr; static char const *const ImagehelpFunctionNames[] = { @@ -148,7 +148,7 @@ static char const *const ImagehelpFunctionNames[] = "StackWalk", "SymFunctionTableAccess", "SymGetModuleBaseType", - NULL + nullptr }; @@ -201,7 +201,7 @@ int __cdecl _purecall(void) char const * Last_Error_Text(void) { static char message_buffer[256]; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &message_buffer[0], 256, NULL); + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &message_buffer[0], 256, nullptr); return (message_buffer); } @@ -352,9 +352,9 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) */ HINSTANCE imagehelp = LoadLibrary("IMAGEHLP.DLL"); - if (imagehelp != NULL) { + if (imagehelp != nullptr) { DebugString ("Exception Handler: Found IMAGEHLP.DLL - linking to required functions\n"); - char const *function_name = NULL; + char const *function_name = nullptr; unsigned long *fptr = (unsigned long*) &_SymCleanup; int count = 0; @@ -374,14 +374,14 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) /* ** Retrieve the programs symbols if they are available */ - if (_SymSetOptions != NULL) { + if (_SymSetOptions != nullptr) { _SymSetOptions(SYMOPT_DEFERRED_LOADS); } int symload = 0; int symbols_available = false; - if (_SymInitialize != NULL && _SymInitialize (GetCurrentProcess(), NULL, false)) { + if (_SymInitialize != nullptr && _SymInitialize (GetCurrentProcess(), nullptr, false)) { DebugString("Exception Handler: Symbols are available\r\n\n"); symbols_available = true; } @@ -389,19 +389,19 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) if (!symbols_available) { DebugString ("Exception Handler: SymInitialize failed with code %d - %s\n", GetLastError(), Last_Error_Text()); } else { - if (_SymSetOptions != NULL) { + if (_SymSetOptions != nullptr) { _SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME); } char module_name[_MAX_PATH]; - GetModuleFileName(NULL, module_name, sizeof(module_name)); + GetModuleFileName(nullptr, module_name, sizeof(module_name)); - if (_SymLoadModule != NULL) { - symload = _SymLoadModule(GetCurrentProcess(), NULL, module_name, NULL, 0, 0); + if (_SymLoadModule != nullptr) { + symload = _SymLoadModule(GetCurrentProcess(), nullptr, module_name, nullptr, 0, 0); } if (!symload) { - assert(_SymLoadModule != NULL); + assert(_SymLoadModule != nullptr); DebugString ("Exception Handler: SymLoad failed for module %s with code %d - %s\n", module_name, GetLastError(), Last_Error_Text()); } } @@ -468,11 +468,12 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) symptr->Address = context->Eip; if (!IsBadCodePtr((FARPROC)context->Eip)) { - if (_SymGetSymFromAddr != NULL && _SymGetSymFromAddr (GetCurrentProcess(), context->Eip, &displacement, symptr)) { - sprintf (scrap, "Exception occurred at %08X - %s + %08X\r\n", context->Eip, symptr->Name, displacement); + if (_SymGetSymFromAddr != nullptr && _SymGetSymFromAddr (GetCurrentProcess(), context->Eip, &displacement, symptr)) { + snprintf(scrap, ARRAY_SIZE(scrap), "Exception occurred at %08X - %s + %08X\r\n", + context->Eip, symptr->Name, displacement); } else { DebugString ("Exception Handler: Failed to get symbol for EIP\r\n"); - if (_SymGetSymFromAddr != NULL) { + if (_SymGetSymFromAddr != nullptr) { DebugString ("Exception Handler: SymGetSymFromAddr failed with code %d - %s\n", GetLastError(), Last_Error_Text()); } sprintf (scrap, "Exception occurred at %08X\r\n", context->Eip); @@ -507,9 +508,9 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) symptr->Size = 0; symptr->Address = temp_addr; - if (_SymGetSymFromAddr != NULL && _SymGetSymFromAddr (GetCurrentProcess(), temp_addr, &displacement, symptr)) { + if (_SymGetSymFromAddr != nullptr && _SymGetSymFromAddr (GetCurrentProcess(), temp_addr, &displacement, symptr)) { char symbuf[256]; - sprintf(symbuf, "%s + %08X\r\n", symptr->Name, displacement); + snprintf(symbuf, ARRAY_SIZE(symbuf), "%s + %08X\r\n", symptr->Name, displacement); Add_Txt(symbuf); } } else { @@ -546,7 +547,7 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) #endif //(0) if (AppVersionCallback) { - sprintf(scrap, "%s\r\n\r\n", AppVersionCallback()); + snprintf(scrap, ARRAY_SIZE(scrap), "%s\r\n\r\n", AppVersionCallback()); Add_Txt(scrap); } @@ -559,7 +560,8 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) ** Get the thread info from ThreadClass. */ for (int thread = 0 ; thread < ThreadList.Count() ; thread++) { - sprintf(scrap, " ID: %08X - %s", ThreadList[thread]->ThreadID, ThreadList[thread]->ThreadName); + snprintf(scrap, ARRAY_SIZE(scrap), " ID: %08X - %s", + ThreadList[thread]->ThreadID, ThreadList[thread]->ThreadName); Add_Txt(scrap); if (GetCurrentThreadId() == ThreadList[thread]->ThreadID) { Add_Txt(" ***CURRENT THREAD***"); @@ -570,7 +572,9 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) /* ** CPU type */ - sprintf(scrap, "\r\nCPU %s, %d Mhz, Vendor: %s\r\n", (char*)CPUDetectClass::Get_Processor_String(), Get_RDTSC_CPU_Speed(), (char*)CPUDetectClass::Get_Processor_Manufacturer_Name()); + snprintf(scrap, ARRAY_SIZE(scrap), "\r\nCPU %s, %d Mhz, Vendor: %s\r\n", + (char*)CPUDetectClass::Get_Processor_String(), Get_RDTSC_CPU_Speed(), + (char*)CPUDetectClass::Get_Processor_Manufacturer_Name()); Add_Txt(scrap); @@ -625,18 +629,13 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) } void *fp_data_ptr = (void*)(&context->FloatSave.RegisterArea[fp*10]); - double fp_value; + // TheSuperHackers @refactor Replaced MSVC inline assembly with portable C++ cast for MinGW compatibility /* ** Convert FP dump from temporary real value (10 bytes) to double (8 bytes). + ** On x86, long double is the 10-byte x87 format, so we can just cast. */ - _asm { - push eax - mov eax,fp_data_ptr - fld tbyte ptr [eax] - fstp qword ptr [fp_value] - pop eax - } + double fp_value = (double)(*(long double*)fp_data_ptr); sprintf(scrap, " %+#.17e\r\n", fp_value); Add_Txt(scrap); } @@ -693,9 +692,9 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) symptr->Size = 0; symptr->Address = *stackptr; - if (_SymGetSymFromAddr != NULL && _SymGetSymFromAddr (GetCurrentProcess(), *stackptr, &displacement, symptr)) { + if (_SymGetSymFromAddr != nullptr && _SymGetSymFromAddr (GetCurrentProcess(), *stackptr, &displacement, symptr)) { char symbuf[256]; - sprintf(symbuf, " - %s + %08X", symptr->Name, displacement); + snprintf(symbuf, ARRAY_SIZE(symbuf), " - %s + %08X", symptr->Name, displacement); strlcat(scrap, symbuf, ARRAY_SIZE(scrap)); } } else { @@ -712,13 +711,13 @@ void Dump_Exception_Info(EXCEPTION_POINTERS *e_info) ** Unload the symbols. */ if (symbols_available) { - if (_SymCleanup != NULL) { + if (_SymCleanup != nullptr) { _SymCleanup (GetCurrentProcess()); } if (symload) { - if (_SymUnloadModule != NULL) { - _SymUnloadModule(GetCurrentProcess(), NULL); + if (_SymUnloadModule != nullptr) { + _SymUnloadModule(GetCurrentProcess(), 0); } } @@ -810,9 +809,9 @@ int Exception_Handler(int exception_code, EXCEPTION_POINTERS *e_info) */ HANDLE debug_file; DWORD actual; - debug_file = CreateFile("_except.txt", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + debug_file = CreateFile("_except.txt", GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); if (debug_file != INVALID_HANDLE_VALUE){ - WriteFile(debug_file, ExceptionText, strlen(ExceptionText), &actual, NULL); + WriteFile(debug_file, ExceptionText, strlen(ExceptionText), &actual, nullptr); CloseHandle (debug_file); #if (0) @@ -1064,8 +1063,8 @@ void Load_Image_Helper(void) if (ImageHelp == (HINSTANCE)-1) { ImageHelp = LoadLibrary("IMAGEHLP.DLL"); - if (ImageHelp != NULL) { - char const *function_name = NULL; + if (ImageHelp != nullptr) { + char const *function_name = nullptr; unsigned long *fptr = (unsigned long *) &_SymCleanup; int count = 0; @@ -1083,29 +1082,29 @@ void Load_Image_Helper(void) /* ** Retrieve the programs symbols if they are available. This can be a .pdb or a .dbg file. */ - if (_SymSetOptions != NULL) { + if (_SymSetOptions != nullptr) { _SymSetOptions(SYMOPT_DEFERRED_LOADS); } int symload = 0; - if (_SymInitialize != NULL && _SymInitialize(GetCurrentProcess(), NULL, FALSE)) { + if (_SymInitialize != nullptr && _SymInitialize(GetCurrentProcess(), nullptr, FALSE)) { - if (_SymSetOptions != NULL) { + if (_SymSetOptions != nullptr) { _SymSetOptions(SYMOPT_DEFERRED_LOADS | SYMOPT_UNDNAME); } char exe_name[_MAX_PATH]; - GetModuleFileName(NULL, exe_name, sizeof(exe_name)); + GetModuleFileName(nullptr, exe_name, sizeof(exe_name)); - if (_SymLoadModule != NULL) { - symload = _SymLoadModule(GetCurrentProcess(), NULL, exe_name, NULL, 0, 0); + if (_SymLoadModule != nullptr) { + symload = _SymLoadModule(GetCurrentProcess(), nullptr, exe_name, nullptr, 0, 0); } if (symload) { SymbolsAvailable = true; } else { - //assert (_SymLoadModule != NULL); + //assert (_SymLoadModule != nullptr); //DebugString ("SymLoad failed for module %s with code %d - %s\n", szModuleName, GetLastError(), Last_Error_Text()); } } @@ -1151,7 +1150,7 @@ bool Lookup_Symbol(void *code_ptr, char *symbol, int &displacement) /* ** Make sure symbols are available. */ - if (!SymbolsAvailable || _SymGetSymFromAddr == NULL) { + if (!SymbolsAvailable || _SymGetSymFromAddr == nullptr) { return(false); } @@ -1196,7 +1195,7 @@ bool Lookup_Symbol(void *code_ptr, char *symbol, int &displacement) * * * INPUT: Ptr to return address list * * Number of return addresses to fetch * - * Ptr to optional context. NULL means use current * + * Ptr to optional context. null means use current * * * * OUTPUT: Number of return addresses found * * * @@ -1220,7 +1219,7 @@ int Stack_Walk(unsigned long *return_addresses, int num_addresses, CONTEXT *cont /* ** If there is no debug support .dll available then we can't walk the stack. */ - if (ImageHelp == NULL) { + if (ImageHelp == nullptr) { return(0); } @@ -1232,6 +1231,7 @@ int Stack_Walk(unsigned long *return_addresses, int num_addresses, CONTEXT *cont unsigned long reg_eip, reg_ebp, reg_esp; +#if defined(_MSC_VER) __asm { here: lea eax,here @@ -1239,6 +1239,17 @@ int Stack_Walk(unsigned long *return_addresses, int num_addresses, CONTEXT *cont mov reg_ebp,ebp mov reg_esp,esp } +#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(_M_IX86)) + __asm__ __volatile__ ( + "call 1f\n\t" + "1: pop %0\n\t" + "mov %%ebp, %1\n\t" + "mov %%esp, %2" + : "=r" (reg_eip), "=r" (reg_ebp), "=r" (reg_esp) + ); +#else +#error "Unsupported compiler or architecture for register capture" +#endif stack_frame.AddrPC.Mode = AddrModeFlat; stack_frame.AddrPC.Offset = reg_eip; @@ -1262,12 +1273,12 @@ int Stack_Walk(unsigned long *return_addresses, int num_addresses, CONTEXT *cont ** Walk the stack by the requested number of return address iterations. */ for (int i = 0; i < num_addresses + 1; i++) { - if (_StackWalk(IMAGE_FILE_MACHINE_I386, GetCurrentProcess(), GetCurrentThread(), &stack_frame, NULL, NULL, _SymFunctionTableAccess, _SymGetModuleBase, NULL)) { + if (_StackWalk(IMAGE_FILE_MACHINE_I386, GetCurrentProcess(), GetCurrentThread(), &stack_frame, nullptr, nullptr, _SymFunctionTableAccess, _SymGetModuleBase, nullptr)) { /* ** First result will always be the return address we were called from. */ - if (i==0 && context == NULL) { + if (i==0 && context == nullptr) { continue; } unsigned long return_address = stack_frame.AddrReturn.Offset; @@ -1307,7 +1318,7 @@ bool Is_Trying_To_Exit(void) -#endif //_MSC_VER +#endif //_WIN32 diff --git a/Core/Libraries/Source/WWVegas/WWLib/Except.h b/Core/Libraries/Source/WWVegas/WWLib/Except.h index e67a4b1f64e..6b9daaeadb8 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/Except.h +++ b/Core/Libraries/Source/WWVegas/WWLib/Except.h @@ -36,7 +36,7 @@ #pragma once -#ifdef _MSC_VER +#if defined(_WIN32) #include "win.h" /* @@ -46,7 +46,7 @@ typedef struct _EXCEPTION_POINTERS EXCEPTION_POINTERS; typedef struct _CONTEXT CONTEXT; int Exception_Handler(int exception_code, EXCEPTION_POINTERS *e_info); -int Stack_Walk(unsigned long *return_addresses, int num_addresses, CONTEXT *context = NULL); +int Stack_Walk(unsigned long *return_addresses, int num_addresses, CONTEXT *context = nullptr); bool Lookup_Symbol(void *code_ptr, char *symbol, int &displacement); void Load_Image_Helper(void); void Register_Thread_ID(unsigned long thread_id, char *thread_name, bool main = false); @@ -80,4 +80,4 @@ typedef struct tThreadInfoType { -#endif //_MSC_VER +#endif //_WIN32 diff --git a/Core/Libraries/Source/WWVegas/WWLib/FastAllocator.h b/Core/Libraries/Source/WWVegas/WWLib/FastAllocator.h index bf45cf9bc51..8a45d4dc7fa 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/FastAllocator.h +++ b/Core/Libraries/Source/WWVegas/WWLib/FastAllocator.h @@ -106,7 +106,7 @@ class FastAllocatorGeneral; //Allocates and deletes items of any size. Can use // StackAllocator stackAllocator; //Create an instance. We use the 'construct' hint feature here. // int** pArray = stackAllocator.New(nSize); //Allocate memory. // memset(pArray, 0, nSize*sizeof(int*)); //Do something with the memory. -// stackAllocator.Delete(pArray); //In this example, we explicity free the memory. +// stackAllocator.Delete(pArray); //In this example, we explicitly free the memory. // } // // void Example(int nSize){ @@ -129,7 +129,7 @@ class FastAllocatorGeneral; //Allocates and deletes items of any size. Can use template class StackAllocator{ public: - StackAllocator() : mnAllocCount(-1), mpTHeap(NULL){} + StackAllocator() : mnAllocCount(-1), mpTHeap(nullptr){} ~StackAllocator(){ if(mnAllocCount != -1){ //If there is anything to do... if(mpTHeap) @@ -159,7 +159,7 @@ class StackAllocator{ //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. + //and class* to be assigned zero/null. We don't want that. new(pTArray)T; ++pTArray; } @@ -187,7 +187,7 @@ class StackAllocator{ } else if(pT == mpTHeap){ //If the allocation came from our heap... delete[] mpTHeap; //The compiler will call the destructors here. - mpTHeap = NULL; //We clear these out so that we can possibly + mpTHeap = nullptr; //We clear these out so that we can possibly mnAllocCount = -1; // use the allocator again. } else //Else the allocation came from the external heap. @@ -196,7 +196,7 @@ class StackAllocator{ protected: int mnAllocCount; //Count of objects allocated. -1 means that nothing is allocated. We don't use zero because zero is a legal allocation count in C++. - T* mpTHeap; //This is normally NULL, but gets used of the allocation request is too high. + T* mpTHeap; //This is normally null, but gets used of the allocation request is too high. char mTArray[nStackCount*sizeof(T)]; //This is our stack memory. }; /////////////////////////////////////////////////////////////////////////////// @@ -492,8 +492,8 @@ WWINLINE void FastAllocatorGeneral::Free(void* pAlloc) } //ANSI C requires: -// (1) realloc(NULL, newsize) is equivalent to malloc(newsize). -// (2) realloc(pblock, 0) is equivalent to free(pblock) (except that NULL is returned). +// (1) realloc(nullptr, newsize) is equivalent to malloc(newsize). +// (2) realloc(pblock, 0) is equivalent to free(pblock) (except that nullptr is returned). // (3) if the realloc() fails, the object pointed to by pblock is left unchanged. // WWINLINE void* FastAllocatorGeneral::Realloc(void* pAlloc, unsigned int n){ @@ -507,7 +507,7 @@ WWINLINE void* FastAllocatorGeneral::Realloc(void* pAlloc, unsigned int n){ return pNewAlloc; } Free(pAlloc); - return NULL; + return nullptr; } @@ -544,7 +544,7 @@ WWINLINE void* FastAllocatorGeneral::Realloc(void* pAlloc, unsigned int n){ T* address(T& t) const { return (&t); } //These two are slightly strange but const T* address(const T& t) const { return (&t); } //required functions. Just do it. - static T* allocate(size_t n, const void* =NULL) { return (T*)FastAllocatorGeneral::Get_Allocator()->Alloc(n*sizeof(T)); } + static T* allocate(size_t n, const void* =nullptr) { return (T*)FastAllocatorGeneral::Get_Allocator()->Alloc(n*sizeof(T)); } static void construct(T* ptr, const T& value) { new(ptr) T(value); } static void deallocate(void* ptr, size_t /*n*/) { FastAllocatorGeneral::Get_Allocator()->Free(ptr); } static void destroy(T* ptr) { ptr->~T(); } @@ -586,7 +586,7 @@ WWINLINE void* FastAllocatorGeneral::Realloc(void* pAlloc, unsigned int n){ pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } - T* allocate(size_type n, const void* = NULL) { return n != 0 ? static_cast(FastAllocatorGeneral::Get_Allocator()->Alloc(n*sizeof(T))) : NULL; } + T* allocate(size_type n, const void* = nullptr) { return n != 0 ? static_cast(FastAllocatorGeneral::Get_Allocator()->Alloc(n*sizeof(T))) : nullptr; } void deallocate(pointer p, size_type n) { FastAllocatorGeneral::Get_Allocator()->Free(p); } size_type max_size() const { return size_t(-1) / sizeof(T); } void construct(pointer p, const T& val) { new(p) T(val); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/HASHLIST.h b/Core/Libraries/Source/WWVegas/WWLib/HASHLIST.h index f0758d72277..d916bc316fc 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/HASHLIST.h +++ b/Core/Libraries/Source/WWVegas/WWLib/HASHLIST.h @@ -50,10 +50,6 @@ #include "LISTNODE.h" #include -#ifndef NULL -#define NULL (0L) -#endif - #define A_LARGE_PRIME_NUMBER 257 // HashListClass<> and HashNodeClass<>: @@ -156,14 +152,14 @@ class HashNodeClass : public DataNode *>, public U if (next && next->Is_Valid()) { return(next); } - return(NULL); + return(nullptr); } HashNodeClass *Prev_Valid() { HashNodeClass *prev = Prev(); if (prev && prev->Is_Valid()) { return(prev); } - return(NULL); + return(nullptr); } // Get record that is in hash table. @@ -496,7 +492,7 @@ HashNodeClass *HashListClass::Find(unsigned key) assert(cur); assert(cur->Is_Valid()); } - return(NULL); + return(nullptr); } @@ -534,7 +530,7 @@ void HashListClass::Remove(HashNodeClass *node) if (Is_Last(node)) { // SKB: 2/20/01 - clear incase inserted in new list later. Clear_Last(node); - HashTable[hashidx] = NULL; + HashTable[hashidx] = nullptr; UsedValues--; } else { HashTable[hashidx] = node->Next_Valid(); diff --git a/Core/Libraries/Source/WWVegas/WWLib/INDEX.h b/Core/Libraries/Source/WWVegas/WWLib/INDEX.h index 8356c1762b5..f73d81c2f83 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/INDEX.h +++ b/Core/Libraries/Source/WWVegas/WWLib/INDEX.h @@ -40,7 +40,7 @@ * IndexClass::IndexClass -- Constructor for index handler. * * IndexClass::Invalidate_Archive -- Invalidate the archive pointer. * * IndexClass::Is_Archive_Same -- Checks to see if archive pointer is same as index. * - * IndexClass::Is_Present -- Checks for presense of index entry. * + * IndexClass::Is_Present -- Checks for presence of index entry. * * IndexClass::Remove_Index -- Find matching index and remove it from system. * * IndexClass::Search_For_Node -- Perform a search for the specified node ID * * IndexClass::Set_Archive -- Records the node pointer into the archive. * @@ -293,7 +293,7 @@ bool IndexClass::Increase_Table_Size(int amount) if (amount < 0) return(false); NodeElement * table = W3DNEWARRAY NodeElement[IndexSize + amount]; - if (table != NULL) { + if (table != nullptr) { /* ** Copy all valid nodes into the new table. @@ -327,12 +327,12 @@ bool IndexClass::Increase_Table_Size(int amount) /*********************************************************************************************** * IndexClass::Count -- Fetch the number of index entries recorded. * * * - * This will return the quantity of index entries that have been recored by this index * + * This will return the quantity of index entries that have been recorded by this index * * handler. * * * * INPUT: none * * * - * OUTPUT: Returns with number of recored indecies present. * + * OUTPUT: Returns with number of recorded indices present. * * * * WARNINGS: none * * * @@ -347,7 +347,7 @@ int IndexClass::Count(void) const /*********************************************************************************************** - * IndexClass::Is_Present -- Checks for presense of index entry. * + * IndexClass::Is_Present -- Checks for presence of index entry. * * * * This routine will scan for the specified index entry. If it was found, then 'true' is * * returned. * @@ -414,7 +414,7 @@ bool IndexClass::Is_Present(INDEX const & id) const * * * WARNINGS: This routine presumes that the index exists. If it doesn't exist, then the * * default constructed object "T" is returned instead. To avoid this problem, * - * always verfiy the existance of the index by calling Is_Present() first. * + * always verfiy the existence of the index by calling Is_Present() first. * * * * HISTORY: * * 11/02/1996 JLB : Created. * @@ -653,7 +653,7 @@ bool IndexClass::Remove_Index(INDEX const & id) * * * OUTPUT: Returns with the comparision value between the two nodes. * * * - * WARNINGS: This is highly dependant upon the layout of the NodeElement structure. * + * WARNINGS: This is highly dependent upon the layout of the NodeElement structure. * * * * HISTORY: * * 11/02/1996 JLB : Created. * @@ -680,7 +680,7 @@ int _USERENTRY IndexClass::search_compfunc(void const * ptr1, void con * INPUT: id -- The index ID to search for. * * * * OUTPUT: Returns with a pointer to the NodeElement that matches the index ID specified. If * - * no matching index could be found, then NULL is returned. * + * no matching index could be found, then nullptr is returned. * * * * WARNINGS: none * * * diff --git a/Core/Libraries/Source/WWVegas/WWLib/INI.h b/Core/Libraries/Source/WWVegas/WWLib/INI.h index dcfa6a631ce..9f3b2e3d9d8 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/INI.h +++ b/Core/Libraries/Source/WWVegas/WWLib/INI.h @@ -63,10 +63,6 @@ template class TRect; template class List; template class IndexClass; -#ifndef NULL -#define NULL 0L -#endif - /* ** This is an INI database handler class. It handles a database with a disk format identical ** to the INI files commonly used by Windows. @@ -107,19 +103,19 @@ class INIClass { /* ** Erase all data within this INI file manager. */ - bool Clear(char const * section = NULL, char const * entry = NULL); + bool Clear(char const * section = nullptr, char const * entry = nullptr); // int Line_Count(char const * section) const; bool Is_Loaded(void) const; int Size(void) const; - bool Is_Present(char const * section, char const * entry = NULL) const {if (entry == 0) return(Find_Section(section) != 0);return(Find_Entry(section, entry) != 0);} + bool Is_Present(char const * section, char const * entry = nullptr) const {if (entry == 0) return(Find_Section(section) != 0);return(Find_Entry(section, entry) != 0);} /* ** Fetch the number of sections in the INI file or verify if a specific ** section is present. */ int Section_Count(void) const; - bool Section_Present(char const * section) const {return(Find_Section(section) != NULL);} + bool Section_Present(char const * section) const {return(Find_Section(section) != nullptr);} /* ** Fetch the number of entries in a section or get a particular entry in a section. diff --git a/Core/Libraries/Source/WWVegas/WWLib/LISTNODE.h b/Core/Libraries/Source/WWVegas/WWLib/LISTNODE.h index 159552c1e1a..fc510a9420b 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/LISTNODE.h +++ b/Core/Libraries/Source/WWVegas/WWLib/LISTNODE.h @@ -55,7 +55,7 @@ class GenericList; class GenericNode { public: - GenericNode(void) : NextNode(0), PrevNode(0) {} + GenericNode(void) : NextNode(nullptr), PrevNode(nullptr) {} virtual ~GenericNode(void) {Unlink();} GenericNode(GenericNode & node) {node.Link(this);} GenericNode & operator = (GenericNode & node) { @@ -73,8 +73,8 @@ class GenericNode { if (Is_Valid()) { PrevNode->NextNode = NextNode; NextNode->PrevNode = PrevNode; - PrevNode = 0; - NextNode = 0; + PrevNode = nullptr; + NextNode = nullptr; } } @@ -96,13 +96,13 @@ class GenericNode { GenericNode * Next(void) const {return(NextNode);} GenericNode * Next_Valid(void) const { - return ((NextNode && NextNode->NextNode) ? NextNode : (GenericNode *)0); + return ((NextNode && NextNode->NextNode) ? NextNode : (GenericNode *)nullptr); } GenericNode * Prev(void) const {return(PrevNode);} GenericNode * Prev_Valid(void) const { - return ((PrevNode && PrevNode->PrevNode) ? PrevNode : (GenericNode *)0); + return ((PrevNode && PrevNode->PrevNode) ? PrevNode : (GenericNode *)nullptr); } - bool Is_Valid(void) const {return(this != (GenericNode *)0 && NextNode != (GenericNode *)0 && PrevNode != (GenericNode *)0);} + bool Is_Valid(void) const {return(this != (GenericNode *)nullptr && NextNode != (GenericNode *)nullptr && PrevNode != (GenericNode *)nullptr);} protected: GenericNode * NextNode; @@ -131,14 +131,14 @@ class GenericList { GenericNode * First_Valid(void) const { GenericNode *node = FirstNode.Next(); - return (node->Next() ? node : (GenericNode *)0); + return (node->Next() ? node : (GenericNode *)nullptr); } GenericNode * Last(void) const {return(LastNode.Prev());} GenericNode * Last_Valid(void) const { GenericNode *node = LastNode.Prev(); - return (node->Prev() ? node : (GenericNode *)0); + return (node->Prev() ? node : (GenericNode *)nullptr); } bool Is_Empty(void) const {return(!FirstNode.Next()->Is_Valid());} diff --git a/Core/Libraries/Source/WWVegas/WWLib/RAMFILE.h b/Core/Libraries/Source/WWVegas/WWLib/RAMFILE.h index 969c5c7bfe5..99792dceb2d 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/RAMFILE.h +++ b/Core/Libraries/Source/WWVegas/WWLib/RAMFILE.h @@ -60,7 +60,7 @@ class RAMFileClass : public FileClass virtual void Close(void); virtual unsigned long Get_Date_Time(void) {return(0);} virtual bool Set_Date_Time(unsigned long ) {return(true);} - virtual void Error(int , int = false, char const * =NULL) {} + virtual void Error(int , int = false, char const * =nullptr) {} virtual void Bias(int start, int length=-1); operator char const * () {return File_Name();} diff --git a/Core/Libraries/Source/WWVegas/WWLib/RAWFILE.h b/Core/Libraries/Source/WWVegas/WWLib/RAWFILE.h index a770ca7ceed..3d6c17be7b1 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/RAWFILE.h +++ b/Core/Libraries/Source/WWVegas/WWLib/RAWFILE.h @@ -44,7 +44,7 @@ // #include "win.h" -#define NULL_HANDLE NULL +#define NULL_HANDLE nullptr #define HANDLE_TYPE FILE* #include "WWFILE.h" #include "wwstring.h" @@ -98,7 +98,7 @@ class RawFileClass : public FileClass virtual void Close(void); virtual unsigned long Get_Date_Time(void); virtual bool Set_Date_Time(unsigned long datetime); - virtual void Error(int error, int canretry = false, char const * filename=NULL); + virtual void Error(int error, int canretry = false, char const * filename=nullptr); virtual void Bias(int start, int length=-1); virtual void * Get_File_Handle(void) { return Handle; } diff --git a/Core/Libraries/Source/WWVegas/WWLib/SLIST.h b/Core/Libraries/Source/WWVegas/WWLib/SLIST.h index f93695811a4..b27ca0d1025 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/SLIST.h +++ b/Core/Libraries/Source/WWVegas/WWLib/SLIST.h @@ -55,10 +55,6 @@ #include "SLNODE.h" -#ifndef NULL -#define NULL 0L -#endif - template class SList { private: @@ -73,8 +69,8 @@ class SList { // SList(void) { - HeadNode = NULL; - TailNode = NULL; + HeadNode = nullptr; + TailNode = nullptr; }; virtual ~SList(void) { Remove_All(); }; @@ -97,13 +93,13 @@ class SList { virtual bool Remove(T *element); // remove an individual element virtual void Remove_All(void); // Remove all nodes from list - // Insert before oldnode, if oldnode is NULL then before head node - virtual bool Insert_Before(T *newnode, T *oldnode = NULL); + // Insert before oldnode, if oldnode is null then before head node + virtual bool Insert_Before(T *newnode, T *oldnode = nullptr); // Could possibly implement an InsertBefore that operates on a whole list - // Insert after oldnode, if oldnode is NULL then insert at head - virtual bool Insert_After(T *newnode, T *oldnode = NULL); + // Insert after oldnode, if oldnode is null then insert at head + virtual bool Insert_After(T *newnode, T *oldnode = nullptr); // Could possibly implement an InsertAfter that operates on a whole list virtual bool Is_Empty(void) const; // True if list is empty @@ -131,11 +127,11 @@ template bool SList::Insert_Before(T *newnode, T *oldnode) { // if not adding anything then just skip the add. - if (newnode == NULL) + if (newnode == nullptr) return false; // if there is no head to the list then add it to head - if (oldnode == NULL || HeadNode == NULL || HeadNode->Data() == oldnode) { + if (oldnode == nullptr || HeadNode == nullptr || HeadNode->Data() == oldnode) { return(Add_Head(newnode)); } @@ -148,7 +144,7 @@ bool SList::Insert_Before(T *newnode, T *oldnode) // Verify that we found the entry as it might not have been in the list. // Note: Cur will be valid because it wont be assigned unless Next is // valid. - if (cur->Next() != NULL && cur->Next()->Data() == oldnode) { + if (cur->Next() != nullptr && cur->Next()->Data() == oldnode) { SLNode *temp = new SLNode (newnode); temp->Set_Next(cur->Next()); cur->Set_Next(temp); @@ -177,10 +173,10 @@ bool SList::Insert_Before(T *newnode, T *oldnode) template bool SList::Insert_After(T *newnode, T *oldnode) { - if (newnode == NULL) + if (newnode == nullptr) return false; - if (oldnode == NULL || HeadNode == NULL) { + if (oldnode == nullptr || HeadNode == nullptr) { return(Add_Head(newnode)); } @@ -189,7 +185,7 @@ bool SList::Insert_After(T *newnode, T *oldnode) for (cur = HeadNode; cur && cur->Data() != oldnode; cur = cur->Next()) {} // Did we find the data we want to insert after? - if (cur != NULL && cur->Data() == oldnode) { + if (cur != nullptr && cur->Data() == oldnode) { if (cur == TailNode) { // Inserting after tail return(Add_Tail(newnode)); } @@ -221,7 +217,7 @@ void SList::Remove_All(void) next = cur->Next(); delete cur; } - HeadNode = TailNode = NULL; + HeadNode = TailNode = nullptr; } /************************************************************************** @@ -240,12 +236,12 @@ template bool SList::Remove(T *element) { // if not adding anything then just skip the add. - if (element == NULL || HeadNode == NULL) + if (element == nullptr || HeadNode == nullptr) return false; // if the head is the element in question remove it if (HeadNode->Data() == element) { - return(Remove_Head() != NULL ? true : false); + return(Remove_Head() != nullptr ? true : false); } // now we need to walk the list in an attempt to add the @@ -257,7 +253,7 @@ bool SList::Remove(T *element) // Verify that we found the entry as it might not have been in the list. // Note: Cur will be valid because it wont be assigned unless Next is // valid. - if (cur->Next() != NULL && cur->Next()->Data() == element) { + if (cur->Next() != nullptr && cur->Next()->Data() == element) { SLNode *temp = cur->Next(); cur->Set_Next(temp->Next()); if (temp == TailNode) TailNode = cur; @@ -282,14 +278,14 @@ bool SList::Remove(T *element) template T *SList::Remove_Head(void) { - if (HeadNode == NULL) // Should make an assertion here instead! - return ((T* )NULL); + if (HeadNode == nullptr) // Should make an assertion here instead! + return ((T* )nullptr); SLNode *temp = HeadNode; HeadNode = HeadNode->Next(); - if (HeadNode == NULL) // Do we have empty list now? - TailNode = NULL; + if (HeadNode == nullptr) // Do we have empty list now? + TailNode = nullptr; T *data = temp->Data(); delete temp; @@ -320,11 +316,11 @@ T *SList::Remove_Head(void) template T *SList::Remove_Tail(void) { - if (HeadNode == NULL) // Should make an assertion here instead! - return ((T *)NULL); + if (HeadNode == nullptr) // Should make an assertion here instead! + return ((T *)nullptr); T* data = TailNode->Data(); - return (Remove(data) ? data : (T*)NULL); + return (Remove(data) ? data : (T*)nullptr); } @@ -401,7 +397,7 @@ inline SLNode *SList::Tail(void) const template inline bool SList::Is_Empty(void) const { - return( HeadNode == NULL ? true : false); + return( HeadNode == nullptr ? true : false); } @@ -446,10 +442,10 @@ bool SList::Add_Head(T *data) template bool SList::Add_Head(SList& list) { - if (list.HeadNode == NULL) return false; + if (list.HeadNode == nullptr) return false; // Save point for initial add of element. - SLNode *addpoint = NULL; + SLNode *addpoint = nullptr; // We traverse list backwards so nodes are added in right order. for (SLNode *cur = list.HeadNode; cur; cur = cur->Next()) @@ -480,11 +476,11 @@ bool SList::Add_Head(SList& list) template bool SList::Add_Tail(T *data) { - if (data == NULL) return false; + if (data == nullptr) return false; SLNode *temp = new SLNode (data); - if (HeadNode == NULL) { // empty list + if (HeadNode == nullptr) { // empty list HeadNode = TailNode = temp; } else { // non-empty list TailNode->Set_Next(temp); @@ -508,7 +504,7 @@ bool SList::Add_Tail(T *data) template bool SList::Add_Tail(SList& list) { - if (list.HeadNode == NULL) return false; + if (list.HeadNode == nullptr) return false; for (SLNode *cur = list.HeadNode; cur; cur = cur->Next()) Add_Tail(cur->Data()); diff --git a/Core/Libraries/Source/WWVegas/WWLib/SLNODE.h b/Core/Libraries/Source/WWVegas/WWLib/SLNODE.h index c49ce72101c..79255d0df1c 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/SLNODE.h +++ b/Core/Libraries/Source/WWVegas/WWLib/SLNODE.h @@ -37,10 +37,6 @@ #include "always.h" #include "mempool.h" -#ifndef NULL -#define NULL 0 -#endif - // Forward references for friend classes template class SList; @@ -64,7 +60,7 @@ class GenericSLNode : public AutoPoolClass // created from anything but a friend or parent class. // GenericSLNode(void *obj) - {NodeData = obj; NodeNext = 0; }; + {NodeData = obj; NodeNext = nullptr; }; // // You cannot declare a node class without giving it a data object. diff --git a/Core/Libraries/Source/WWVegas/WWLib/STLUtils.h b/Core/Libraries/Source/WWVegas/WWLib/STLUtils.h index ca92bf76c67..bb76c2f507f 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/STLUtils.h +++ b/Core/Libraries/Source/WWVegas/WWLib/STLUtils.h @@ -22,7 +22,6 @@ #include #include #include -#include namespace stl { diff --git a/Core/Libraries/Source/WWVegas/WWLib/Signaler.h b/Core/Libraries/Source/WWVegas/WWLib/Signaler.h index 073d032498e..3ec7b961a87 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/Signaler.h +++ b/Core/Libraries/Source/WWVegas/WWLib/Signaler.h @@ -55,11 +55,11 @@ template class Signaler {} virtual void SignalDropped(Signaler& signaler) - {mConnection = NULL;} + {mConnection = nullptr;} protected: Signaler() : - mConnection(NULL) + mConnection(nullptr) {} virtual ~Signaler() @@ -69,7 +69,7 @@ template class Signaler {mConnection = &source;} void Disconnect(void) - {if (mConnection) {mConnection->SignalDropped(*this);} mConnection = NULL;} + {if (mConnection) {mConnection->SignalDropped(*this);} mConnection = nullptr;} // Prevent copy and assignment Signaler(const Signaler&); diff --git a/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp b/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp index de3d8773d1b..640cc5067cc 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/TARGA.cpp @@ -102,8 +102,8 @@ Targa::Targa(void) { - mImage = NULL; - mPalette = NULL; + mImage = nullptr; + mPalette = nullptr; Clear_File(); mAccess = TGA_READMODE; mFlags = 0; @@ -138,11 +138,11 @@ Targa::~Targa(void) Close(); /* Free the palette buffer if we allocated it. */ - if ((mPalette != NULL) && (mFlags & TGAF_PAL)) + if ((mPalette != nullptr) && (mFlags & TGAF_PAL)) free(mPalette); /* Free the image buffer if we allocated it. */ - if ((mImage != NULL) && (mFlags & TGAF_IMAGE)) + if ((mImage != nullptr) && (mFlags & TGAF_IMAGE)) free(mImage); } @@ -317,7 +317,7 @@ void Targa::Close(void) if (TGAFile) { TGAFile->Close(); _TheFileFactory->Return_File(TGAFile); - TGAFile = NULL; + TGAFile = nullptr; } #else /* Close the file if it is open. */ @@ -341,7 +341,7 @@ void Targa::Close(void) * * FUNCTION * Open and load the Targa into the specified buffers. If either buffer -* pointer is NULL then that field will not be processed. +* pointer is nullptr then that field will not be processed. * * INPUTS * Name - Name of Targa image file to load. @@ -360,7 +360,7 @@ long Targa::Load(const char* name, char* palette, char* image,bool invert_image) long error = 0; /* Open the Targa */ - if (Open(name, TGA_READMODE) == NULL) { + if (Open(name, TGA_READMODE) == 0) { /* Process ColorMap (palette) */ if (Header.ColorMapType == 1) { @@ -371,7 +371,7 @@ long Targa::Load(const char* name, char* palette, char* image,bool invert_image) /* Load the palette from the TGA if a palette buffer is provided * otherwise we will skip it. */ - if ((palette != NULL) && (Header.CMapLength > 0)) { + if ((palette != nullptr) && (Header.CMapLength > 0)) { /* Adjust palette to the starting color entry. */ palette += (Header.CMapStart * depth); @@ -391,7 +391,7 @@ long Targa::Load(const char* name, char* palette, char* image,bool invert_image) /* Load the image data from the TGA if an image buffer is provided * otherwise we are done. */ - if (!error && (image != NULL)) { + if (!error && (image != nullptr)) { depth = TGA_BytesPerPixel(Header.PixelDepth); size = ((Header.Width * Header.Height) * depth); @@ -422,7 +422,7 @@ long Targa::Load(const char* name, char* palette, char* image,bool invert_image) break; case TGA_TRUECOLOR_ENCODED: - if ((error = DecodeImage()) == NULL) { + if ((error = DecodeImage()) == 0) { if (invert_image) InvertImage(); } break; @@ -499,21 +499,21 @@ long Targa::Load(const char* name, long flags, bool invert_image) if ((flags & TGAF_PAL) && (Header.ColorMapType == 1)) { /* Dispose of any previous palette. */ - if ((mPalette != NULL) && (mFlags & TGAF_PAL)) { + if ((mPalette != nullptr) && (mFlags & TGAF_PAL)) { free(mPalette); - mPalette = NULL; + mPalette = nullptr; mFlags &= ~TGAF_PAL; } /* Only allocate a palette if the client hasn't assigned one. */ - if ((mPalette == NULL) && !(mFlags & TGAF_PAL)) { + if ((mPalette == nullptr) && !(mFlags & TGAF_PAL)) { /* Compute the size of the palette from the targa header. */ size = (Header.CMapLength * (Header.CMapDepth >> 3)); if (size != 0) { /* Allocate memory for the palette. */ - if ((mPalette = (char *)malloc(size)) != NULL) { + if ((mPalette = (char *)malloc(size)) != nullptr) { mFlags |= TGAF_PAL; /* We allocated the palette. */ } else { error = TGAERR_NOMEM; @@ -526,20 +526,20 @@ long Targa::Load(const char* name, long flags, bool invert_image) if (!error && (flags & TGAF_IMAGE)) { /* Dispose of any previous image. */ - if ((mImage != NULL) && (mFlags & TGAF_IMAGE)) { + if ((mImage != nullptr) && (mFlags & TGAF_IMAGE)) { free(mImage); - mImage = NULL; + mImage = nullptr; mFlags &= ~TGAF_IMAGE; } /* Only allocate an image if the client hasn't assigned one. */ - if ((mImage == NULL) && !(mFlags & TGAF_IMAGE)) { + if ((mImage == nullptr) && !(mFlags & TGAF_IMAGE)) { /* Compute the size of the image data from the targa header. */ size = ((Header.Width * Header.Height) * TGA_BytesPerPixel(Header.PixelDepth)); if (size != 0) { /* Allocate memory for the image. */ - if ((mImage = (char *)malloc(size)) != NULL) { + if ((mImage = (char *)malloc(size)) != nullptr) { mFlags |= TGAF_IMAGE; /* We allocated the image. */ } else { error = TGAERR_NOMEM; @@ -598,7 +598,7 @@ long Targa::Save(const char* name, long flags, bool addextension) TGA2Footer footer; /* Open the Targa for write. */ - if (Open(name, TGA_WRITEMODE) == NULL) + if (Open(name, TGA_WRITEMODE) == 0) { Header.IDLength = 0; @@ -634,7 +634,7 @@ long Targa::Save(const char* name, long flags, bool addextension) /*----------------------------------------------------------------------- * WRITE THE COLORMAP (PALETTE) DATA SECTION *---------------------------------------------------------------------*/ - if (!error && (flags & TGAF_PAL) && (mPalette != NULL) + if (!error && (flags & TGAF_PAL) && (mPalette != nullptr) && (Header.CMapLength > 0)) { /* Adjust palette to the starting color entry. */ @@ -643,7 +643,7 @@ long Targa::Save(const char* name, long flags, bool addextension) size = (Header.CMapLength * depth); /* Allocate temporary buffer for palette manipulation. */ - if ((temppal = (char *)malloc(size)) != NULL) + if ((temppal = (char *)malloc(size)) != nullptr) { memcpy(temppal, palette, size); ptr = temppal; @@ -675,7 +675,7 @@ long Targa::Save(const char* name, long flags, bool addextension) /*----------------------------------------------------------------------- * WRITE THE IMAGE DATA SECTION *---------------------------------------------------------------------*/ - if (!error && (flags & TGAF_IMAGE) && (mImage != NULL)) + if (!error && (flags & TGAF_IMAGE) && (mImage != nullptr)) { bool imageinverted; @@ -935,18 +935,18 @@ void Targa::YFlip(void) char *Targa::SetImage(char *buffer) { - char *oldbuffer = NULL; + char *oldbuffer = nullptr; /* Free any image buffer before assigning another. */ - if ((mImage != NULL) && (mFlags & TGAF_IMAGE)) + if ((mImage != nullptr) && (mFlags & TGAF_IMAGE)) { free(mImage); - mImage = NULL; + mImage = nullptr; mFlags &= ~TGAF_IMAGE; } /* Get the old user buffer. */ - if (mImage != NULL) + if (mImage != nullptr) oldbuffer = mImage; /* Assign the new image buffer. */ @@ -978,18 +978,18 @@ char *Targa::SetImage(char *buffer) char *Targa::SetPalette(char *buffer) { - char *oldbuffer = NULL; + char *oldbuffer = nullptr; /* Free any image buffer before assigning another. */ - if ((mPalette != NULL) && (mFlags & TGAF_PAL)) + if ((mPalette != nullptr) && (mFlags & TGAF_PAL)) { free(mPalette); - mPalette = NULL; + mPalette = nullptr; mFlags &= ~TGAF_PAL; } /* Get the old user buffer. */ - if (mPalette != NULL) + if (mPalette != nullptr) oldbuffer = mPalette; /* Assign the new image buffer. */ @@ -1020,13 +1020,13 @@ bool Targa::IsCompressed(void) * * FUNCTION * Retrieve a pointer to the Targa 2.0 extension data area. If the file -* version is 1.0 OR there is no extensio area then a NULL will be returned. +* version is 1.0 OR there is no extensio area then a nullptr will be returned. * * INPUTS * NONE * * RESULT -* Ext - Pointer to Extension data, NULL if not available. +* Ext - Pointer to Extension data, nullptr if not available. * ****************************************************************************/ @@ -1035,7 +1035,7 @@ TGA2Extension *Targa::GetExtension(void) if (mFlags & TGAF_TGA2) return (&mExtension); - return (NULL); + return (nullptr); } @@ -1170,7 +1170,7 @@ long Targa::EncodeImage() depth = TGA_BytesPerPixel(Header.PixelDepth); /* Allocate packet buffer to hold maximum encoded data run. */ - if ((packet = (char *)malloc(128 * depth)) != NULL) + if ((packet = (char *)malloc(128 * depth)) != nullptr) { pixels = Header.Width * Header.Height; start = mImage; @@ -1339,7 +1339,7 @@ void Targa::InvertImage(void) void Targa::Clear_File(void) { #ifdef TGA_USES_WWLIB_FILE_CLASSES - TGAFile = NULL; + TGAFile = nullptr; #else mFH = -1; #endif @@ -1347,7 +1347,7 @@ void Targa::Clear_File(void) bool Targa::Is_File_Open(void) { #ifdef TGA_USES_WWLIB_FILE_CLASSES - return (TGAFile != NULL); + return (TGAFile != nullptr); #else return (mFH != -1); #endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/TARGA.h b/Core/Libraries/Source/WWVegas/WWLib/TARGA.h index f0e082a3f28..603087b52cd 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/TARGA.h +++ b/Core/Libraries/Source/WWVegas/WWLib/TARGA.h @@ -197,13 +197,13 @@ typedef struct _TGA2Ratio * TGA2Footer. * * ExtSize - Extension area size. (495 bytes for 2.0) - * AuthName - Name of the person who created image (NULL terminated ASCII) - * AuthComment - Comments of the author (NULL terminated ASCII) + * AuthName - Name of the person who created image (null-terminated ASCII) + * AuthComment - Comments of the author (null-terminated ASCII) * DateStamp - Date the file was created. (See TGA2DateStamp) * TimeStamp - Time the file was created. (See TGA2TimeStamp) - * JobName - Name of job image belongs to (NULL terminated ASCII) + * JobName - Name of job image belongs to (null-terminated ASCII) * JobTime - Elapsed time of the job. - * SoftID - ID of software used to create image (NULL terminated ASCII) + * SoftID - ID of software used to create image (null-terminated ASCII) * SoftVer - Version number of software used. * KeyColor - Tranparent color value. * Aspect - Pixel aspect ratio. diff --git a/Core/Libraries/Source/WWVegas/WWLib/Vector.h b/Core/Libraries/Source/WWVegas/WWLib/Vector.h index 09c4b8b1c35..3c2cae49cbf 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/Vector.h +++ b/Core/Libraries/Source/WWVegas/WWLib/Vector.h @@ -136,7 +136,7 @@ class VectorClass * * * This constructor for the vector class is passed the initial size of the vector and an * * optional pointer to a preallocated block of memory that the vector will be placed in. * - * If this optional pointer is NULL (or not provided), then the vector is allocated out * + * If this optional pointer is nullptr (or not provided), then the vector is allocated out * * of free store (with the "new" operator). * * * * INPUT: size -- The number of elements to initialize this vector to. * @@ -153,7 +153,7 @@ class VectorClass *=============================================================================================*/ template VectorClass::VectorClass(int size, T const * array) : - Vector(0), + Vector(nullptr), VectorMax(size), IsValid(true), IsAllocated(false) @@ -367,7 +367,7 @@ void VectorClass::Clear(void) { if (IsAllocated) { delete[] Vector; - Vector = 0; + Vector = nullptr; } IsAllocated = false; VectorMax = 0; @@ -426,7 +426,7 @@ bool VectorClass::Resize(int newsize, T const * array) ** If there is an old vector, then it must be copied (as much as is feasible) ** to the new vector. */ - if (Vector != NULL) { + if (Vector != nullptr) { /* ** Copy as much of the old vector into the new vector as possible. This @@ -446,7 +446,7 @@ bool VectorClass::Resize(int newsize, T const * array) */ if (IsAllocated) { delete[] Vector; - Vector = 0; + Vector = nullptr; } } @@ -489,14 +489,14 @@ class DynamicVectorClass : public VectorClass using VectorClass::Length; public: - DynamicVectorClass(unsigned size=0, T const * array=0); + DynamicVectorClass(unsigned size=0, T const * array=nullptr); // Stubbed equality operators so you can have dynamic vectors of dynamic vectors bool operator== (const DynamicVectorClass &src) { return false; } bool operator!= (const DynamicVectorClass &src) { return true; } // Change maximum size of vector. - virtual bool Resize(int newsize, T const * array=0); + virtual bool Resize(int newsize, T const * array=nullptr); // Resets and frees the vector array. virtual void Clear(void) {ActiveCount = 0;VectorClass::Clear();}; @@ -541,7 +541,7 @@ class DynamicVectorClass : public VectorClass // Uninitialized Add - does everything an Add does, except copying an // object into the 'new' spot in the array. It returns a pointer to - // the 'new' spot. (NULL if the Add failed). NOTE - you must then fill + // the 'new' spot. (null if the Add failed). NOTE - you must then fill // this memory area with a valid object (e.g. by using placement new), // or chaos will result! T * Uninitialized_Add(void); @@ -656,7 +656,7 @@ int DynamicVectorClass::ID(T const & object) * DynamicVectorClass::Add -- Add an element to the vector. * * * * Use this routine to add an element to the vector. The vector will automatically be * - * resized to accomodate the new element IF the vector was allocated previously and the * + * resized to accommodate the new element IF the vector was allocated previously and the * * growth rate is not zero. * * * * INPUT: object -- Reference to the object that will be added to the vector. * @@ -911,7 +911,7 @@ void DynamicVectorClass::Delete_All(void) * INPUT: none. * * * * OUTPUT: T *; Points to the empty space where the new object is to be created. (If the * - * space was not added successfully, returns NULL). * + * space was not added successfully, returns nullptr). * * * * WARNINGS: If memory area is left uninitialized, Very Bad Things will happen. * * * @@ -930,7 +930,7 @@ T * DynamicVectorClass::Uninitialized_Add(void) ** Failure to increase the size of the vector is an error condition. ** Return with the error value. */ - return(NULL); + return(nullptr); } } else { @@ -938,7 +938,7 @@ T * DynamicVectorClass::Uninitialized_Add(void) ** Increasing the size of this vector is not allowed! Bail this ** routine with the error value. */ - return(NULL); + return(nullptr); } } @@ -969,7 +969,7 @@ int First_False_Bit(void const * array); class BooleanVectorClass { public: - BooleanVectorClass(unsigned size=0, unsigned char * array=0); + BooleanVectorClass(unsigned size=0, unsigned char * array=nullptr); BooleanVectorClass(BooleanVectorClass const & vector); // Assignment operator. @@ -1083,7 +1083,7 @@ int Pointer_Vector_Add(T * ptr, VectorClass & vec) int id = 0; bool foundspot = false; for (int index = 0; index < vec.Length(); index++) { - if (vec[index] == NULL) { + if (vec[index] == nullptr) { id = index; foundspot = true; break; @@ -1093,7 +1093,7 @@ int Pointer_Vector_Add(T * ptr, VectorClass & vec) id = vec.Length(); vec.Resize((vec.Length()+1) * 2); for (int index = id; index < vec.Length(); index++) { - vec[index] = NULL; + vec[index] = nullptr; } } vec[id] = ptr; @@ -1106,7 +1106,7 @@ bool Pointer_Vector_Remove(T const * ptr, VectorClass & vec) { int id = vec.ID((T *)ptr); if (id != -1) { - vec[id] = NULL; + vec[id] = nullptr; return(true); } return(false); diff --git a/Core/Libraries/Source/WWVegas/WWLib/WWCOMUtil.cpp b/Core/Libraries/Source/WWVegas/WWLib/WWCOMUtil.cpp index dc94b82bc9c..acfbe0138a6 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/WWCOMUtil.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/WWCOMUtil.cpp @@ -67,10 +67,10 @@ STDMETHODIMP Dispatch_GetProperty(IDispatch* object, const OLECHAR* propName, if (SUCCEEDED(hr)) { // Get the property - DISPPARAMS params = {NULL, NULL, 0, 0}; + DISPPARAMS params = {nullptr, nullptr, 0, 0}; UINT argErr = 0; hr = object->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, - DISPATCH_PROPERTYGET, ¶ms, result, NULL, &argErr); + DISPATCH_PROPERTYGET, ¶ms, result, nullptr, &argErr); } return hr; @@ -107,7 +107,7 @@ STDMETHODIMP Dispatch_PutProperty(IDispatch* object, const OLECHAR* propName, if (SUCCEEDED(hr)) { // Get the property - DISPPARAMS params = {NULL, NULL, 0, 0}; + DISPPARAMS params = {nullptr, nullptr, 0, 0}; params.cArgs = 1; params.rgvarg = propValue; @@ -115,7 +115,7 @@ STDMETHODIMP Dispatch_PutProperty(IDispatch* object, const OLECHAR* propName, UINT argErr = 0; hr = object->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, - DISPATCH_PROPERTYPUT, ¶ms, &result, NULL, &argErr); + DISPATCH_PROPERTYPUT, ¶ms, &result, nullptr, &argErr); } return hr; @@ -153,7 +153,7 @@ STDMETHODIMP Dispatch_InvokeMethod(IDispatch* object, const OLECHAR* methodName, { UINT argErr = 0; hr = object->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT, - DISPATCH_METHOD, params, result, NULL, &argErr); + DISPATCH_METHOD, params, result, nullptr, &argErr); } return hr; @@ -182,11 +182,11 @@ bool RegisterCOMServer(const char* dllName) HINSTANCE hInst = LoadLibrary(dllName); - if (hInst != NULL) + if (hInst != nullptr) { FARPROC regServerProc = GetProcAddress(hInst, "DllRegisterServer"); - if (regServerProc != NULL) + if (regServerProc != nullptr) { HRESULT hr = regServerProc(); success = SUCCEEDED(hr); @@ -221,11 +221,11 @@ bool UnregisterCOMServer(const char* dllName) HINSTANCE hInst = LoadLibrary(dllName); - if (hInst != NULL) + if (hInst != nullptr) { FARPROC unregServerProc = GetProcAddress(hInst, "DllUnregisterServer"); - if (unregServerProc != NULL) + if (unregServerProc != nullptr) { HRESULT hr = unregServerProc(); success = SUCCEEDED(hr); diff --git a/Core/Libraries/Source/WWVegas/WWLib/WWFILE.h b/Core/Libraries/Source/WWVegas/WWLib/WWFILE.h index 16b1bbfa0ac..490cf43078f 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/WWFILE.h +++ b/Core/Libraries/Source/WWVegas/WWLib/WWFILE.h @@ -49,10 +49,6 @@ #define SEEK_END 2 // Seek from end of file. #endif -#ifndef NULL - #define NULL 0 -#endif - class FileClass { @@ -82,7 +78,7 @@ class FileClass virtual void Close(void) = 0; virtual unsigned long Get_Date_Time(void) {return(0);} virtual bool Set_Date_Time(unsigned long ) {return(false);} -// virtual void Error(int error, int canretry = false, char const * filename=NULL) = 0; +// virtual void Error(int error, int canretry = false, char const * filename=nullptr) = 0; virtual void * Get_File_Handle(void) { return reinterpret_cast(-1); } // virtual void Bias(int start, int length=-1) = 0; diff --git a/Core/Libraries/Source/WWVegas/WWLib/XPIPE.h b/Core/Libraries/Source/WWVegas/WWLib/XPIPE.h index 2e68e3c044f..17f66ca9384 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/XPIPE.h +++ b/Core/Libraries/Source/WWVegas/WWLib/XPIPE.h @@ -81,7 +81,7 @@ class FilePipe : public Pipe FileClass * File; bool HasOpened; - bool Valid_File(void) {return(File != NULL);} + bool Valid_File(void) {return(File != nullptr);} FilePipe(FilePipe & rvalue); FilePipe & operator = (FilePipe const & pipe); diff --git a/Core/Libraries/Source/WWVegas/WWLib/XSTRAW.h b/Core/Libraries/Source/WWVegas/WWLib/XSTRAW.h index f21e78f275b..d5aee44b866 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/XSTRAW.h +++ b/Core/Libraries/Source/WWVegas/WWLib/XSTRAW.h @@ -79,7 +79,7 @@ class FileStraw : public Straw FileClass * File; bool HasOpened; - bool Valid_File(void) {return(File != NULL);} + bool Valid_File(void) {return(File != nullptr);} FileStraw(FileStraw & rvalue); FileStraw & operator = (FileStraw const & pipe); }; diff --git a/Core/Libraries/Source/WWVegas/WWLib/always.h b/Core/Libraries/Source/WWVegas/WWLib/always.h index c58e6dd8e48..946f5dab695 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/always.h +++ b/Core/Libraries/Source/WWVegas/WWLib/always.h @@ -158,7 +158,7 @@ class W3DMPO static void* getClassMemoryPool() { assert(0); // must replace this via W3DMPO_GLUE - return 0; + return nullptr; } protected: // we never call this; it is present to cause compile errors in descendent classes @@ -200,7 +200,9 @@ class W3DMPO ** 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' */ +#ifndef NOMINMAX #define NOMINMAX +#endif #ifndef MAX #define MAX(a,b) (((a) > (b)) ? (a) : (b)) @@ -218,6 +220,17 @@ class W3DMPO #undef max #endif +// Provide min/max template functions for compatibility with legacy code +#ifndef _MIN_MAX_TEMPLATES_DEFINED_ +#define _MIN_MAX_TEMPLATES_DEFINED_ + +#if defined(__MINGW32__) || defined(__MINGW64__) +// For MinGW, use STL's min/max +#include +using std::min; +using std::max; +#else +// For MSVC, provide custom templates template T min(T a,T b) { if (a T max(T a,T b) return b; } } +#endif + +#endif // _MIN_MAX_TEMPLATES_DEFINED_ /* @@ -254,9 +270,8 @@ template T max(T a,T b) #include "watcom.h" #endif - -#ifndef NULL - #define NULL 0 +#if defined(__MINGW32__) || defined(__MINGW64__) +#include "mingw.h" #endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/argv.cpp b/Core/Libraries/Source/WWVegas/WWLib/argv.cpp index 28958b3fbb8..58f33c1ba7f 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/argv.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/argv.cpp @@ -54,7 +54,7 @@ char *ArgvClass::Argv[MAX_ARGC]; * * * INPUT: * * bool case_sensitive - Do you want to perform a case sensitive search (stricmp)? * - * bool exact_size - Do you want string of same lenght (strncmp) ? * + * bool exact_size - Do you want string of same length (strncmp) ? * * * * OUTPUT: * * * @@ -65,7 +65,7 @@ char *ArgvClass::Argv[MAX_ARGC]; *=============================================================================================*/ ArgvClass::ArgvClass(bool case_sensitive, bool exact_size): Flags(0), - LastArg(0), + LastArg(nullptr), CurrentPos(-1) { Case_Sensitive(case_sensitive); @@ -76,7 +76,7 @@ ArgvClass::ArgvClass(bool case_sensitive, bool exact_size): * *ArgvClass::Find_Again -- Search for a string given the flags. * * * * INPUT: * - * const char *arg - String to search for. If NULL, LastArg will be used. * + * const char *arg - String to search for. If nullptr, LastArg will be used. * * * * OUTPUT: * * const char *string found (null if not found) * @@ -135,14 +135,14 @@ const char *ArgvClass::Find_Again(const char *arg) } } } - return NULL; + return nullptr; } /*********************************************************************************************** * ArgvClass::Init -- Setup the command line. * * * * INPUT: * - * LPSTR lpCmdLine - A string of white space seperated strings. Quotes force spaces to * + * LPSTR lpCmdLine - A string of white space separated strings. Quotes force spaces to * * be ignored. * * char *fileprefix - A prefix on an arguement telling system to load postfix file name * * as command line params. * @@ -299,7 +299,7 @@ void ArgvClass::Free() { for (int lp = 0; lp < Argc; lp++) { free(Argv[lp]); - Argv[lp] = 0; + Argv[lp] = nullptr; } Argc = -1; } @@ -325,7 +325,7 @@ const char *ArgvClass::Find_Value(const char *arg) return(Get_Cur_Value(strlen(arg))); } } - return(NULL); + return(nullptr); } /*********************************************************************************************** @@ -345,12 +345,12 @@ const char *ArgvClass::Get_Cur_Value(unsigned prefixlen, bool * val_in_next) { if (val_in_next) *val_in_next = false; if (CurrentPos < 0) { - return NULL; + return nullptr; } char *ptr = Argv[CurrentPos]; if (strlen(ptr) < prefixlen) { - return(NULL); + return(nullptr); } ptr += prefixlen; @@ -366,7 +366,7 @@ const char *ArgvClass::Get_Cur_Value(unsigned prefixlen, bool * val_in_next) // Goto next line to handle '-P data' case on command line. ptr = Argv[CurrentPos + 1]; if (!ptr) { - return NULL; + return nullptr; } while (*ptr) { @@ -376,7 +376,7 @@ const char *ArgvClass::Get_Cur_Value(unsigned prefixlen, bool * val_in_next) } ptr++; } - return (NULL); + return (nullptr); } @@ -398,7 +398,7 @@ const char *ArgvClass::Get_Cur_Value(unsigned prefixlen, bool * val_in_next) *=============================================================================================*/ void ArgvClass::Update_Value(const char *attrib, const char *value) { - if ((Find_Value(attrib))!=NULL) + if ((Find_Value(attrib))!=nullptr) { if (((CurrentPos+1) < Argc) && (Argv[CurrentPos+1][0] != '-')) // update old value { @@ -470,7 +470,7 @@ bool ArgvClass::Remove_Value(const char *attrib) { int removeCount=1; - if ((Find_Value(attrib))!=NULL) + if ((Find_Value(attrib))!=nullptr) { free(Argv[CurrentPos]); if (((CurrentPos+1) < Argc)&&(Argv[CurrentPos+1][0]!='-')) // value for this arg diff --git a/Core/Libraries/Source/WWVegas/WWLib/argv.h b/Core/Libraries/Source/WWVegas/WWLib/argv.h index a512b618619..15cae760e18 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/argv.h +++ b/Core/Libraries/Source/WWVegas/WWLib/argv.h @@ -46,7 +46,7 @@ // If there is a arguement (for example @file.arg) then the fname is loaded up, // parsed, and put into the command line. The format of the parameter file is as follows: // 1. a semicolon (;) at the start of the line is a comment and will be ignored. -// 2. Each line is a seperate parameter. This enables white space to be embeded. +// 2. Each line is a separate parameter. This enables white space to be embeded. // In typical Argv implementation, the first argument is the name of the application. This // is not the case with this. class ArgvClass @@ -68,7 +68,7 @@ class ArgvClass CurrentPos = -1; return(Find_Again(arg)); } - // If NULL passed, original string will be used. + // If null passed, original string will be used. const char *Find_Again(const char *arg = 0L); // Return pointer to data after 'arg'. @@ -87,7 +87,7 @@ class ArgvClass void Update_Value(const char *attrib, const char *value); // Add a new attrib value pair (or just an option) - void Add_Value(const char *attrib, const char *value=NULL); + void Add_Value(const char *attrib, const char *value=nullptr); // Remove an option (and its value) bool Remove_Value(const char *attrib); diff --git a/Core/Libraries/Source/WWVegas/WWLib/b64pipe.cpp b/Core/Libraries/Source/WWVegas/WWLib/b64pipe.cpp index fe6c313ec5e..7381331796d 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/b64pipe.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/b64pipe.cpp @@ -62,7 +62,7 @@ *=============================================================================================*/ int Base64Pipe::Put(void const * source, int slen) { - if (source == NULL || slen < 1) { + if (source == nullptr || slen < 1) { return(Pipe::Put(source, slen)); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/base64.cpp b/Core/Libraries/Source/WWVegas/WWLib/base64.cpp index 09fc0ce0212..3cc8ae9d686 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/base64.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/base64.cpp @@ -144,7 +144,7 @@ int Base64_Encode(void const * source, int slen, void * dest, int dlen) /* ** Check the parameters for legality. */ - if (source == NULL || slen == 0 || dest == NULL || dlen == 0) { + if (source == nullptr || slen == 0 || dest == nullptr || dlen == 0) { return(0); } @@ -245,7 +245,7 @@ int Base64_Decode(void const * source, int slen, void * dest, int dlen) /* ** Check the parameters for legality. */ - if (source == NULL || slen == 0 || dest == NULL || dlen == 0) { + if (source == nullptr || slen == 0 || dest == nullptr || dlen == 0) { return(0); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/bfiofile.h b/Core/Libraries/Source/WWVegas/WWLib/bfiofile.h index 8b144568ea1..523d45d4943 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/bfiofile.h +++ b/Core/Libraries/Source/WWVegas/WWLib/bfiofile.h @@ -53,7 +53,7 @@ class BufferIOFileClass : public RawFileClass BufferIOFileClass(void); virtual ~BufferIOFileClass(void); - bool Cache( long size=0, void * ptr=NULL); + bool Cache( long size=0, void * ptr=nullptr); void Free( void); bool Commit( void); virtual char const * Set_Name(char const * filename); diff --git a/Core/Libraries/Source/WWVegas/WWLib/binheap.h b/Core/Libraries/Source/WWVegas/WWLib/binheap.h index fa4aa9447ab..ea2dec99532 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/binheap.h +++ b/Core/Libraries/Source/WWVegas/WWLib/binheap.h @@ -65,7 +65,7 @@ class HeapNodeClass }; // WARNING! -// To reduce the number of compares, element [0] is a sentinel. It's key value must be the smallest or NULL. +// To reduce the number of compares, element [0] is a sentinel. It's key value must be the smallest or null. // Keeps track of pointers to objects. template class BinaryHeapClass @@ -88,7 +88,7 @@ class BinaryHeapClass BinaryHeapClass(unsigned int max_number_of_elements) : Max_Number_Of_Elements (max_number_of_elements), Number_Of_Elements (0), - Elements (NULL), + Elements (nullptr), Own_Array (false) { Resize_Array (max_number_of_elements); @@ -100,10 +100,10 @@ class BinaryHeapClass Release_Array (); } - // Reset all entries in the array to NULL + // Reset all entries in the array to null void Flush_Array (void) { - ::memset (Elements, NULL, sizeof (HeapNodeClass *) * Max_Number_Of_Elements); + ::memset (Elements, nullptr, sizeof (HeapNodeClass *) * Max_Number_Of_Elements); Number_Of_Elements = 0; } @@ -119,8 +119,8 @@ class BinaryHeapClass Number_Of_Elements = 0; Own_Array = true; - // Initialize to NULL - ::memset (Elements, NULL, sizeof (HeapNodeClass *) * new_size); + // Initialize to null + ::memset (Elements, nullptr, sizeof (HeapNodeClass *) * new_size); return ; } @@ -128,7 +128,7 @@ class BinaryHeapClass { if (Own_Array) { delete [] Elements; - Elements = NULL; + Elements = nullptr; Number_Of_Elements = 0; Max_Number_Of_Elements = 0; } @@ -206,7 +206,7 @@ class BinaryHeapClass HeapNodeClass* min_element; if (Number_Of_Elements == 0) { - return NULL; + return nullptr; } assert(Number_Of_Elements > 0); @@ -214,7 +214,7 @@ class BinaryHeapClass // The smallest element is always at this position. min_element = Elements[1]; - if (min_element != NULL) { + if (min_element != nullptr) { min_element->Set_Heap_Location (0); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/buff.cpp b/Core/Libraries/Source/WWVegas/WWLib/buff.cpp index ae14b73bc06..071b8768ba1 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/buff.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/buff.cpp @@ -69,7 +69,7 @@ Buffer::Buffer(void * buffer, long size) : Size(size), IsAllocated(false) { - if (buffer == NULL && size > 0) { + if (buffer == nullptr && size > 0) { BufferPtr = W3DNEWARRAY char[size]; IsAllocated = true; } @@ -82,7 +82,7 @@ Buffer::Buffer(char * buffer, long size) : Size(size), IsAllocated(false) { - if (buffer == NULL && size > 0) { + if (buffer == nullptr && size > 0) { BufferPtr = W3DNEWARRAY char[size]; IsAllocated = true; } @@ -95,7 +95,7 @@ Buffer::Buffer(void const * buffer, long size) : Size(size), IsAllocated(false) { - if (buffer == NULL && size > 0) { + if (buffer == nullptr && size > 0) { BufferPtr = W3DNEWARRAY char[size]; IsAllocated = true; } @@ -114,13 +114,13 @@ Buffer::Buffer(void const * buffer, long size) : * OUTPUT: none * * * * WARNINGS: There is no way to tell if the allocation failed. To verify, call Get_Buffer * - * and compare with NULL. * + * and compare with nullptr. * * * * HISTORY: * * 07/29/1996 JLB : Created. * *=============================================================================================*/ Buffer::Buffer(long size) : - BufferPtr(NULL), + BufferPtr(nullptr), Size(size), IsAllocated(false) { @@ -225,7 +225,7 @@ void Buffer::Reset(void) if (IsAllocated) { delete [] BufferPtr; } - BufferPtr = NULL; + BufferPtr = nullptr; Size = 0; IsAllocated = false; } diff --git a/Core/Libraries/Source/WWVegas/WWLib/bufffile.cpp b/Core/Libraries/Source/WWVegas/WWLib/bufffile.cpp index 6c16b1d31ca..090639514d3 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/bufffile.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/bufffile.cpp @@ -45,7 +45,7 @@ int BufferedFileClass::_DesiredBufferSize = 1024*16; *=============================================================================================*/ BufferedFileClass::BufferedFileClass(void) : RawFileClass(), - Buffer( NULL ), + Buffer( nullptr ), BufferSize( 0 ), BufferAvailable( 0 ), BufferOffset( 0 ) @@ -57,7 +57,7 @@ BufferedFileClass::BufferedFileClass(void) : *=============================================================================================*/ BufferedFileClass::BufferedFileClass(char const * filename) : RawFileClass( filename ), - Buffer( NULL ), + Buffer( nullptr ), BufferSize( 0 ), BufferAvailable( 0 ), BufferOffset( 0 ) @@ -91,10 +91,10 @@ void BufferedFileClass::Close(void) * the file. This condition can result in fewer bytes being read than requested. Determine * * this by examining the return value. * * * - * INPUT: buffer -- Pointer to the buffer to read data into. If NULL is passed, no read * + * INPUT: buffer -- Pointer to the buffer to read data into. If nullptr is passed, no read * * is performed. * * * - * size -- The number of bytes to read. If NULL is passed, then no read is * + * size -- The number of bytes to read. If nullptr is passed, then no read is * * performed. * * * * OUTPUT: Returns with the number of bytes read into the buffer. If this number is less * @@ -242,7 +242,7 @@ int BufferedFileClass::Seek(int pos, int dir) void BufferedFileClass::Reset_Buffer( void ) { delete [] Buffer; - Buffer = NULL; + Buffer = nullptr; BufferSize = 0; BufferAvailable = 0; BufferOffset = 0; diff --git a/Core/Libraries/Source/WWVegas/WWLib/chunkio.cpp b/Core/Libraries/Source/WWVegas/WWLib/chunkio.cpp index 6c8bbbdbc8e..0c0f6f6b0e4 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/chunkio.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/chunkio.cpp @@ -732,7 +732,7 @@ uint32 ChunkLoadClass::Read(void * buf,uint32 nbytes) *=============================================================================================*/ uint32 ChunkLoadClass::Read(IOVector2Struct * v) { - assert(v != NULL); + assert(v != nullptr); return Read(v,sizeof(v)); } @@ -751,7 +751,7 @@ uint32 ChunkLoadClass::Read(IOVector2Struct * v) *=============================================================================================*/ uint32 ChunkLoadClass::Read(IOVector3Struct * v) { - assert(v != NULL); + assert(v != nullptr); return Read(v,sizeof(v)); } @@ -770,7 +770,7 @@ uint32 ChunkLoadClass::Read(IOVector3Struct * v) *=============================================================================================*/ uint32 ChunkLoadClass::Read(IOVector4Struct * v) { - assert(v != NULL); + assert(v != nullptr); return Read(v,sizeof(v)); } @@ -789,7 +789,7 @@ uint32 ChunkLoadClass::Read(IOVector4Struct * v) *=============================================================================================*/ uint32 ChunkLoadClass::Read(IOQuaternionStruct * q) { - assert(q != NULL); + assert(q != nullptr); return Read(q,sizeof(q)); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp b/Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp index 622753fa1a5..31d6c02d2ba 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp @@ -942,7 +942,7 @@ void CPUDetectClass::Init_OS() OSVersionExtraInfo = os.szCSDVersion; #else typedef LONG(WINAPI * RtlGetVersionPtr)(PRTL_OSVERSIONINFOW); - HMODULE ntdll = LoadLibraryExA("ntdll", NULL, 0); + HMODULE ntdll = LoadLibraryExA("ntdll", nullptr, 0); if (ntdll != nullptr) { RtlGetVersionPtr RtlGetVersion = (RtlGetVersionPtr)::GetProcAddress(ntdll, "RtlGetVersion"); @@ -1104,7 +1104,7 @@ void CPUDetectClass::Init_Compact_Log() GetTimeZoneInformation(&time_zone); COMPACTLOG(("%d\t", time_zone.Bias)); // get diff between local time and UTC #elif defined(_UNIX) - time_t t = time(NULL); + time_t t = time(nullptr); localtime(&t); COMPACTLOG(("%d\t", timezone)); #endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/crc.cpp b/Core/Libraries/Source/WWVegas/WWLib/crc.cpp index 455af0d0833..8577f284d01 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/crc.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/crc.cpp @@ -90,7 +90,7 @@ void CRCEngine::operator() (char datum) *=============================================================================================*/ long CRCEngine::operator() (void const * buffer, int length) { - if (buffer != NULL && length > 0) { + if (buffer != nullptr && length > 0) { char const * dataptr = (char const *)buffer; int bytes_left = length; diff --git a/Core/Libraries/Source/WWVegas/WWLib/crcstraw.cpp b/Core/Libraries/Source/WWVegas/WWLib/crcstraw.cpp index ba173de5f59..aeddbe9bf4a 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/crcstraw.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/crcstraw.cpp @@ -62,7 +62,7 @@ *=============================================================================================*/ int CRCStraw::Get(void * source, int slen) { - if (source == NULL || slen < 1) { + if (source == nullptr || slen < 1) { return(0); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/cstraw.cpp b/Core/Libraries/Source/WWVegas/WWLib/cstraw.cpp index c65cd46c269..af3b0417415 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/cstraw.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/cstraw.cpp @@ -64,7 +64,7 @@ int CacheStraw::Get(void * source, int slen) { int total = 0; - if (Is_Valid() && source != NULL && slen > 0) { + if (Is_Valid() && source != nullptr && slen > 0) { /* ** Keep processing the data request until there is no more data to supply or the request diff --git a/Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp b/Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp index 02ea652aea7..88b0003ac2b 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/ffactory.cpp @@ -43,7 +43,7 @@ /* ** Statics ** NOTE: If _TheFileFactory is ever changed to point to an object of a different class which does -** not derive from SimpleFileFactoryClass, _TheSimpleFileFactory should be set to NULL. +** not derive from SimpleFileFactoryClass, _TheSimpleFileFactory should be set to null. */ SimpleFileFactoryClass _DefaultFileFactory; FileFactoryClass * _TheFileFactory = &_DefaultFileFactory; @@ -56,11 +56,11 @@ RawFileFactoryClass * _TheWritingFileFactory = &_DefaultWritingFileFactory; ** */ file_auto_ptr::file_auto_ptr(FileFactoryClass *fac, const char *filename) : - _Ptr(NULL), _Fac(fac) + _Ptr(nullptr), _Fac(fac) { assert(_Fac); _Ptr=_Fac->Get_File(filename); - if ( _Ptr == NULL ) { + if ( _Ptr == nullptr ) { _Ptr = W3DNEW BufferedFileClass(); } } @@ -215,7 +215,7 @@ Is_Full_Path (const char *path) { bool retval = false; - if (path != NULL && path[0] != 0) { + if (path != nullptr && path[0] != 0) { // Check for drive designation retval = bool(path[1] == ':'); @@ -239,7 +239,7 @@ FileClass * SimpleFileFactoryClass::Get_File( char const *filename ) if (IsStripPath) { const char * ptr = ::strrchr( filename, '\\' ); - if (ptr != 0) { + if (ptr != nullptr) { ptr++; stripped_name = ptr; } else { @@ -270,7 +270,7 @@ FileClass * SimpleFileFactoryClass::Get_File( char const *filename ) if (!SubDirectory.Is_Empty()) { // - // SubDirectory may contain a semicolon seperated search path... + // SubDirectory may contain a semicolon separated search path... // If the file doesn't exist, we'll set the path to the last dir in // the search path. Therefore newly created files will always go in the // last dir in the search path. @@ -281,8 +281,8 @@ FileClass * SimpleFileFactoryClass::Get_File( char const *filename ) { char *tokstart=subdir.Peek_Buffer(); const char *tok; - while((tok=strtok(tokstart, ";")) != NULL) { - tokstart=NULL; + while((tok=strtok(tokstart, ";")) != nullptr) { + tokstart=nullptr; new_name.Format("%s%s",tok,stripped_name.str()); file->Set_Name( new_name ); // Call Set_Name to force an allocated name if (file->Open()) { diff --git a/Core/Libraries/Source/WWVegas/WWLib/ffactory.h b/Core/Libraries/Source/WWVegas/WWLib/ffactory.h index cb7acc11c16..77b70ab6e3d 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ffactory.h +++ b/Core/Libraries/Source/WWVegas/WWLib/ffactory.h @@ -126,7 +126,7 @@ class SimpleFileFactoryClass : public FileFactoryClass { virtual FileClass * Get_File( char const *filename ); virtual void Return_File( FileClass *file ); - // sub_directory may be a semicolon seperated search path. New files will always + // sub_directory may be a semicolon separated search path. New files will always // go in the last dir in the path. void Get_Sub_Directory( StringClass& new_dir ) const; void Set_Sub_Directory( const char * sub_directory ); diff --git a/Core/Libraries/Source/WWVegas/WWLib/hash.cpp b/Core/Libraries/Source/WWVegas/WWLib/hash.cpp index 441fe6bfe72..a5d8114ee32 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/hash.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/hash.cpp @@ -57,35 +57,35 @@ HashTableClass::~HashTableClass( void ) { // If we need to, free the hash table delete [] HashTable; - HashTable = NULL; + HashTable = nullptr; } void HashTableClass::Reset( void ) { for ( int i = 0; i < HashTableSize; i++ ) { - HashTable[i] = NULL; + HashTable[i] = nullptr; } } void HashTableClass::Add( HashableClass * entry ) { - WWASSERT( entry != NULL); + WWASSERT( entry != nullptr); int index = Hash( entry->Get_Key() ); - WWASSERT( entry->NextHash == NULL ); + WWASSERT( entry->NextHash == nullptr ); entry->NextHash = HashTable[ index ]; HashTable[ index ] = entry; } bool HashTableClass::Remove( HashableClass * entry ) { - WWASSERT(entry != NULL); + WWASSERT(entry != nullptr); // Find in the hash table. const char *key = entry->Get_Key(); int index = Hash( key ); - if ( HashTable[ index ] != NULL ) { + if ( HashTable[ index ] != nullptr ) { // Special check for first entry if ( HashTable[ index ] == entry ) { @@ -95,7 +95,7 @@ bool HashTableClass::Remove( HashableClass * entry ) // Search the list for the entry, and remove it HashableClass * node = HashTable[ index ]; - while ( node->NextHash != NULL ) { + while ( node->NextHash != nullptr ) { if ( node->NextHash == entry ) { node->NextHash = entry->NextHash; return true; @@ -111,12 +111,12 @@ HashableClass * HashTableClass::Find( const char * key ) { // Find in the hash table. int index = Hash( key ); - for ( HashableClass * node = HashTable[ index ]; node != NULL; node = node->NextHash ) { + for ( HashableClass * node = HashTable[ index ]; node != nullptr; node = node->NextHash ) { if ( ::stricmp( node->Get_Key(), key ) == 0 ) { return node; } } - return NULL; + return nullptr; } int HashTableClass::Hash( const char * key ) @@ -139,7 +139,7 @@ void HashTableIteratorClass::First(void) void HashTableIteratorClass::Next(void) { CurrentEntry = NextEntry; - if ( NextEntry != NULL ) { + if ( NextEntry != nullptr ) { NextEntry = NextEntry->NextHash; Advance_Next(); } @@ -147,7 +147,7 @@ void HashTableIteratorClass::Next(void) void HashTableIteratorClass::Advance_Next(void) { - while ( NextEntry == NULL ) { + while ( NextEntry == nullptr ) { Index++; if ( Index >= Table.HashTableSize ) { return; // Done! diff --git a/Core/Libraries/Source/WWVegas/WWLib/hash.h b/Core/Libraries/Source/WWVegas/WWLib/hash.h index c91e48c5116..2ba8aa0af36 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/hash.h +++ b/Core/Libraries/Source/WWVegas/WWLib/hash.h @@ -48,7 +48,7 @@ class HashTableIteratorClass; class HashableClass { public: - HashableClass( void ) : NextHash( NULL ) {} + HashableClass( void ) : NextHash( nullptr ) {} virtual ~HashableClass( void ) {} virtual const char * Get_Key( void ) = 0; @@ -98,7 +98,7 @@ class HashTableIteratorClass void First( void ); void Next( void ); - bool Is_Done( void ) { return CurrentEntry == NULL; } + bool Is_Done( void ) { return CurrentEntry == nullptr; } HashableClass * Get_Current( void ) { return CurrentEntry; } private: diff --git a/Core/Libraries/Source/WWVegas/WWLib/hashtab.h b/Core/Libraries/Source/WWVegas/WWLib/hashtab.h index 7a66ce6bbc8..c888725121e 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/hashtab.h +++ b/Core/Libraries/Source/WWVegas/WWLib/hashtab.h @@ -116,7 +116,7 @@ Object * HashTableClass::Find(Key * key) const } // couldn't find it - return NULL; + return nullptr; } #endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/hashtemplate.h b/Core/Libraries/Source/WWVegas/WWLib/hashtemplate.h index 79de6a2cad0..7f0bd96e644 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/hashtemplate.h +++ b/Core/Libraries/Source/WWVegas/WWLib/hashtemplate.h @@ -72,7 +72,7 @@ class HashTemplateClass enum { - NIL = -1 // internal enumeration for representing a NULL link + NIL = -1 // internal enumeration for representing a null link }; HashTemplateClass(void); diff --git a/Core/Libraries/Source/WWVegas/WWLib/ini.cpp b/Core/Libraries/Source/WWVegas/WWLib/ini.cpp index 9a1f3c09feb..42bf373abfd 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ini.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/ini.cpp @@ -124,15 +124,15 @@ const int INIClass::MAX_LINE_LENGTH = 4096; INIEntry::~INIEntry(void) { free(Entry); - Entry = NULL; + Entry = nullptr; free(Value); - Value = NULL; + Value = nullptr; } INISection::~INISection(void) { free(Section); - Section = 0; + Section = nullptr; EntryList.Delete(); } @@ -168,7 +168,7 @@ void INIClass::Shutdown(void) * HISTORY: * *=============================================================================================*/ INIClass::INIClass(void) -: Filename(0) +: Filename(nullptr) { Initialize(); } @@ -187,7 +187,7 @@ INIClass::INIClass(void) *=============================================================================================*/ INIClass::INIClass(FileClass & file) -: Filename(0) +: Filename(nullptr) { Initialize(); Load(file); @@ -209,7 +209,7 @@ INIClass::INIClass(FileClass & file) *=============================================================================================*/ INIClass::INIClass(const char *filename) -: Filename(0) +: Filename(nullptr) { Initialize(); FileClass *file=_TheFileFactory->Get_File(filename); @@ -250,7 +250,7 @@ INIClass::~INIClass(void) * then the entire INI data is cleared out. Optionally, this routine can be used to clear * * out just an individual entry in the specified section. * * * - * INPUT: section -- Pointer to the section to clear out [pass NULL to clear all]. * + * INPUT: section -- Pointer to the section to clear out [pass nullptr to clear all]. * * * * entry -- Pointer to optional entry specifier. If this parameter is specified, * * then only this specific entry (if found) will be cleared. Otherwise, * @@ -267,7 +267,7 @@ INIClass::~INIClass(void) *=============================================================================================*/ bool INIClass::Clear(char const * section, char const * entry) { - if (section == NULL) { + if (section == nullptr) { SectionList->Delete(); SectionIndex->Clear(); @@ -275,10 +275,10 @@ bool INIClass::Clear(char const * section, char const * entry) Filename = nstrdup(""); } else { INISection * secptr = Find_Section(section); - if (secptr != NULL) { - if (entry != NULL) { + if (secptr != nullptr) { + if (entry != nullptr) { INIEntry * entptr = secptr->Find_Entry(entry); - if (entptr != NULL) { + if (entptr != nullptr) { /* ** Remove the entry from the entry index list. */ @@ -386,7 +386,7 @@ int INIClass::Load(const char *filename) * 09/29/1997 JLB : Handles the merging case. * * 12/09/1997 EHC : Detects duplicate entry CRCs and fails in that case * * 03/22/2001 AJA : Treat "foobar=" as a valid entry with value " ". * - * 08/23/2001 AJA : Make the loading of "foobar=" dependant on the KeepBlankEntries flag. * + * 08/23/2001 AJA : Make the loading of "foobar=" dependent on the KeepBlankEntries flag. * *=============================================================================================*/ int INIClass::Load(Straw & ffile) { @@ -411,7 +411,7 @@ int INIClass::Load(Straw & ffile) while (!end_of_file) { Read_Line(file, buffer, sizeof(buffer), end_of_file); if (end_of_file) return(false); - if (buffer[0] == '[' && strchr(buffer, ']') != NULL) break; + if (buffer[0] == '[' && strchr(buffer, ']') != nullptr) break; } if (merge) { @@ -427,7 +427,7 @@ int INIClass::Load(Straw & ffile) */ buffer[0] = ' '; char * ptr = strchr(buffer, ']'); - if (ptr != NULL) *ptr = '\0'; + if (ptr != nullptr) *ptr = '\0'; strtrim(buffer); char section[64]; strlcpy(section, buffer, ARRAY_SIZE(section)); @@ -443,7 +443,7 @@ int INIClass::Load(Straw & ffile) ** care of it. */ int len = Read_Line(file, buffer, sizeof(buffer), end_of_file); - if (buffer[0] == '[' && strchr(buffer, ']') != NULL) break; + if (buffer[0] == '[' && strchr(buffer, ']') != nullptr) break; /* ** Determine if this line is a comment or blank line. Throw it out if it is. @@ -491,10 +491,10 @@ int INIClass::Load(Straw & ffile) buffer[0] = ' '; char * ptr = strchr(buffer, ']'); - if (ptr != NULL) *ptr = '\0'; + if (ptr != nullptr) *ptr = '\0'; strtrim(buffer); INISection * secptr = W3DNEW INISection(strdup(buffer)); - if (secptr == NULL) { + if (secptr == nullptr) { Clear(); return(false); } @@ -510,7 +510,7 @@ int INIClass::Load(Straw & ffile) ** care of it. */ int len = Read_Line(file, buffer, sizeof(buffer), end_of_file); - if (buffer[0] == '[' && strchr(buffer, ']') != NULL) break; + if (buffer[0] == '[' && strchr(buffer, ']') != nullptr) break; /* ** Determine if this line is a comment or blank line. Throw it out if it is. @@ -546,7 +546,7 @@ int INIClass::Load(Straw & ffile) INIEntry * entryptr = W3DNEW INIEntry(strdup(buffer), strdup(divider)); - if (entryptr == NULL) { + if (entryptr == nullptr) { delete secptr; Clear(); return(false); @@ -626,7 +626,7 @@ int INIClass::Save(const char *filename) const retval=Save(*file); _TheWritingFileFactory->Return_File(file); } - file=NULL; + file=nullptr; delete[] Filename; Filename = nstrdup(filename); @@ -708,7 +708,7 @@ int INIClass::Save(Pipe & pipe) const * brackets. Case is NOT sensitive in the search. * * * * OUTPUT: Returns with a pointer to the INI section control structure if the section was * - * found. Otherwise, NULL is returned. * + * found. Otherwise, nullptr is returned. * * * * WARNINGS: none * * * @@ -719,7 +719,7 @@ int INIClass::Save(Pipe & pipe) const *=============================================================================================*/ INISection * INIClass::Find_Section(char const * section) const { - if (section != NULL) { + if (section != nullptr) { // long crc = CRCEngine()(section, strlen(section)); long crc = CRC(section); @@ -727,7 +727,7 @@ INISection * INIClass::Find_Section(char const * section) const return((*SectionIndex)[crc]); } } - return(NULL); + return(nullptr); } @@ -772,7 +772,7 @@ int INIClass::Section_Count(void) const int INIClass::Entry_Count(char const * section) const { INISection * secptr = Find_Section(section); - if (secptr != NULL) { + if (secptr != nullptr) { return(secptr->EntryIndex.Count()); } return(0); @@ -790,7 +790,7 @@ int INIClass::Entry_Count(char const * section) const * entry -- Pointer to the entry name to search for. * * * * OUTPUT: If the entry was found, then a pointer to the entry control structure will be * - * returned. Otherwise, NULL will be returned. * + * returned. Otherwise, nullptr will be returned. * * * * WARNINGS: none * * * @@ -800,10 +800,10 @@ int INIClass::Entry_Count(char const * section) const INIEntry * INIClass::Find_Entry(char const * section, char const * entry) const { INISection * secptr = Find_Section(section); - if (secptr != NULL) { + if (secptr != nullptr) { return(secptr->Find_Entry(entry)); } - return(NULL); + return(nullptr); } @@ -829,16 +829,16 @@ char const * INIClass::Get_Entry(char const * section, int index) const { INISection * secptr = Find_Section(section); - if (secptr != NULL && index < secptr->EntryIndex.Count()) { + if (secptr != nullptr && index < secptr->EntryIndex.Count()) { INIEntry * entryptr = secptr->EntryList.First(); - while (entryptr != NULL && entryptr->Is_Valid()) { + while (entryptr != nullptr && entryptr->Is_Valid()) { if (index == 0) return(entryptr->Entry); index--; entryptr = entryptr->Next(); } } - return(NULL); + return(nullptr); } @@ -866,7 +866,7 @@ unsigned INIClass::Enumerate_Entries(const char *Section, const char * Entry_Pre char entry[256]; do { - sprintf(entry, "%s%d", Entry_Prefix, count); + snprintf(entry, ARRAY_SIZE(entry), "%s%d", Entry_Prefix, count); present = Is_Present(Section, entry); if(present) count++; @@ -900,7 +900,7 @@ unsigned INIClass::Enumerate_Entries(const char *Section, const char * Entry_Pre *=============================================================================================*/ bool INIClass::Put_UUBlock(char const * section, void const * block, int len) { - if (section == NULL || block == NULL || len < 1) return(false); + if (section == nullptr || block == nullptr || len < 1) return(false); Clear(section); @@ -952,7 +952,7 @@ bool INIClass::Put_UUBlock(char const * section, void const * block, int len) *=============================================================================================*/ int INIClass::Get_UUBlock(char const * section, void * block, int len) const { - if (section == NULL) return(0); + if (section == nullptr) return(0); Base64Pipe b64pipe(Base64Pipe::DECODE); BufferPipe bpipe(block, len); @@ -1034,7 +1034,7 @@ const WideStringClass& INIClass::Get_Wide_String(WideStringClass& new_string, ch *=============================================================================================*/ bool INIClass::Put_Wide_String(char const * section, char const * entry, wchar_t const * string) { - if (section == NULL || entry == NULL || string == NULL) { + if (section == nullptr || entry == nullptr || string == nullptr) { return(false); } @@ -1070,7 +1070,7 @@ bool INIClass::Put_Wide_String(char const * section, char const * entry, wchar_t bool INIClass::Put_UUBlock(char const * section, char const *entry, void const * block, int len) { - if (section == NULL || block == NULL || len < 1) return(false); + if (section == nullptr || block == nullptr || len < 1) return(false); BufferStraw straw(block, len); Base64Straw bstraw(Base64Straw::ENCODE); @@ -1092,8 +1092,8 @@ bool INIClass::Put_UUBlock(char const * section, char const *entry, void const * int INIClass::Get_UUBlock(char const * section, char const *entry, void * block, int len) const { - if (section == NULL) return(0); - if (entry == NULL) return(0); + if (section == nullptr) return(0); + if (entry == nullptr) return(0); Base64Pipe b64pipe(Base64Pipe::DECODE); BufferPipe bpipe(block, len); @@ -1140,12 +1140,12 @@ int INIClass::Get_UUBlock(char const * section, char const *entry, void * block, *=============================================================================================*/ bool INIClass::Put_TextBlock(char const * section, char const * text) { - if (section == NULL) return(false); + if (section == nullptr) return(false); Clear(section); int index = 1; - while (text != NULL && *text != 0) { + while (text != nullptr && *text != 0) { char buffer[128]; @@ -1316,10 +1316,10 @@ int INIClass::Get_Int(char const * section, char const * entry, int defvalue) co /* ** Verify that the parameters are nominally correct. */ - if (section == NULL || entry == NULL) return(defvalue); + if (section == nullptr || entry == nullptr) return(defvalue); INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr && entryptr->Value != NULL) { + if (entryptr && entryptr->Value != nullptr) { if (*entryptr->Value == '$') { sscanf(entryptr->Value, "$%x", &defvalue); @@ -1453,10 +1453,10 @@ int INIClass::Get_Hex(char const * section, char const * entry, int defvalue) co /* ** Verify that the parameters are nominally correct. */ - if (section == NULL || entry == NULL) return(defvalue); + if (section == nullptr || entry == nullptr) return(defvalue); INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr && entryptr->Value != NULL) { + if (entryptr && entryptr->Value != nullptr) { sscanf(entryptr->Value, "%x", &defvalue); } return(defvalue); @@ -1487,14 +1487,14 @@ float INIClass::Get_Float(char const * section, char const * entry, float defval /* ** Verify that the parameters are nominally correct. */ - if (section == NULL || entry == NULL) return(defvalue); + if (section == nullptr || entry == nullptr) return(defvalue); INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr != NULL && entryptr->Value != NULL) { + if (entryptr != nullptr && entryptr->Value != nullptr) { float val = defvalue; sscanf(entryptr->Value, "%f", &val); defvalue = val; - if (strchr(entryptr->Value, '%') != NULL) { + if (strchr(entryptr->Value, '%') != nullptr) { defvalue /= 100.0f; } } @@ -1554,14 +1554,14 @@ double INIClass::Get_Double(char const * section, char const * entry, double def /* ** Verify that the parameters are nominally correct. */ - if (section == NULL || entry == NULL) return(defvalue); + if (section == nullptr || entry == nullptr) return(defvalue); INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr != NULL && entryptr->Value != NULL) { + if (entryptr != nullptr && entryptr->Value != nullptr) { double val = defvalue; sscanf(entryptr->Value, "%lf", &val); defvalue = val; - if (strchr(entryptr->Value, '%') != NULL) { + if (strchr(entryptr->Value, '%') != nullptr) { defvalue /= 100.0f; } } @@ -1621,13 +1621,13 @@ bool INIClass::Put_Double(char const * section, char const * entry, double numbe *=============================================================================================*/ bool INIClass::Put_String(char const * section, char const * entry, char const * string) { - if (section == NULL || entry == NULL) return(false); + if (section == nullptr || entry == nullptr) return(false); INISection * secptr = Find_Section(section); - if (secptr == NULL) { + if (secptr == nullptr) { secptr = W3DNEW INISection(strdup(section)); - if (secptr == NULL) return(false); + if (secptr == nullptr) return(false); SectionList->Add_Tail(secptr); SectionIndex->Add_Index(secptr->Index_ID(), secptr); } @@ -1636,7 +1636,7 @@ bool INIClass::Put_String(char const * section, char const * entry, char const * ** Remove the old entry if found and print debug message */ INIEntry * entryptr = secptr->Find_Entry(entry); - if (entryptr != NULL) { + if (entryptr != nullptr) { if (strcmp(entryptr->Entry, entry) != 0) { DuplicateCRCError("INIClass::Put_String", section, entry); } else { @@ -1653,14 +1653,14 @@ bool INIClass::Put_String(char const * section, char const * entry, char const * /* ** Create and add the new entry. */ - if (string != NULL && strlen(string) > 0) { + if (string != nullptr && strlen(string) > 0) { entryptr = W3DNEW INIEntry(strdup(entry), strdup(string)); // If this assert fires, then the string will be truncated on load, because // there will not be enough room in the loading buffer! WWASSERT(strlen(string) < MAX_LINE_LENGTH); - if (entryptr == NULL) { + if (entryptr == nullptr) { return(false); } secptr->EntryList.Add_Tail(entryptr); @@ -1701,24 +1701,24 @@ int INIClass::Get_String(char const * section, char const * entry, char const * /* ** Verify that the parameters are nominally legal. */ -// if (buffer != NULL && size > 0) { +// if (buffer != nullptr && size > 0) { // buffer[0] = '\0'; // } - if (buffer == NULL || size < 2 || section == NULL || entry == NULL) return(0); + if (buffer == nullptr || size < 2 || section == nullptr || entry == nullptr) return(0); /* ** Fetch the entry string if it is present. If not, then the normal default ** value will be used as the entry value. */ INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr != NULL && entryptr->Value != NULL) { + if (entryptr != nullptr && entryptr->Value != nullptr) { defvalue = entryptr->Value; } /* ** Fill in the buffer with the entry value and return with the length of the string. */ - if (defvalue == NULL) { + if (defvalue == nullptr) { buffer[0] = '\0'; return(0); } else { @@ -1734,7 +1734,7 @@ int INIClass::Get_String(char const * section, char const * entry, char const * */ const StringClass& INIClass::Get_String(StringClass& new_string, char const * section, char const * entry, char const * defvalue) const { - if (section == NULL || entry == NULL) { + if (section == nullptr || entry == nullptr) { new_string=""; return new_string; } @@ -1744,11 +1744,11 @@ const StringClass& INIClass::Get_String(StringClass& new_string, char const * se ** value will be used as the entry value. */ INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr != NULL) { + if (entryptr != nullptr) { defvalue = entryptr->Value; } - if (defvalue == NULL) { + if (defvalue == nullptr) { new_string=""; return new_string; } @@ -1786,27 +1786,27 @@ const StringClass& INIClass::Get_String(StringClass& new_string, char const * se *=============================================================================================*/ char *INIClass::Get_Alloc_String(char const * section, char const * entry, char const * defvalue) const { - if (section == NULL || entry == NULL) return(NULL); + if (section == nullptr || entry == nullptr) return(nullptr); /* ** Fetch the entry string if it is present. If not, then the normal default ** value will be used as the entry value. */ INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr != NULL) { + if (entryptr != nullptr) { defvalue = entryptr->Value; } - if (defvalue == NULL) return NULL; + if (defvalue == nullptr) return nullptr; return(strdup(defvalue)); } int INIClass::Get_List_Index(char const * section, char const * entry, int const defvalue, char *list[]) { - if (section == NULL || entry == NULL) return(0); + if (section == nullptr || entry == nullptr) return(0); INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr == NULL || entryptr->Value == NULL) { + if (entryptr == nullptr || entryptr->Value == nullptr) { return defvalue; } @@ -1822,7 +1822,7 @@ int INIClass::Get_Int_Bitfield(char const * section, char const * entry, int def { // if we can't find the entry or the entry is null just return the default value INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr == NULL || entryptr->Value == NULL) { + if (entryptr == nullptr || entryptr->Value == nullptr) { return defvalue; } @@ -1833,7 +1833,7 @@ int INIClass::Get_Int_Bitfield(char const * section, char const * entry, int def char *str = strdup(entryptr->Value); int lp; - for (char *token = strtok(str, "|+"); token; token = strtok(NULL, "|+")) { + for (char *token = strtok(str, "|+"); token; token = strtok(nullptr, "|+")) { for (lp = 0; list[lp]; lp++) { // if this list entry matches our string token then we need // to set this bit. @@ -1844,7 +1844,7 @@ int INIClass::Get_Int_Bitfield(char const * section, char const * entry, int def } // if we reached the end of the list and found nothing then we need // to assert since we have an unidentified value - if (list[lp] == NULL) assert(lp < 1000); + if (list[lp] == nullptr) assert(lp < 1000); } free(str); return retval; @@ -1852,10 +1852,10 @@ int INIClass::Get_Int_Bitfield(char const * section, char const * entry, int def int * INIClass::Get_Alloc_Int_Array(char const * section, char const * entry, int listend) { - int *retval = NULL; + int *retval = nullptr; INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr == NULL || entryptr->Value == NULL) { + if (entryptr == nullptr || entryptr->Value == nullptr) { retval = W3DNEWARRAY int[1]; retval[0] = listend; @@ -1867,7 +1867,7 @@ int * INIClass::Get_Alloc_Int_Array(char const * section, char const * entry, in int count = 0; char *str = strdup(entryptr->Value); char *token; - for (token = strtok(str, " "); token; token = strtok(NULL, " ")) { + for (token = strtok(str, " "); token; token = strtok(nullptr, " ")) { count++; } free(str); @@ -1877,7 +1877,7 @@ int * INIClass::Get_Alloc_Int_Array(char const * section, char const * entry, in retval = W3DNEWARRAY int[count+1]; count = 0; str = strdup(entryptr->Value); - for (token = strtok(str, " "); token; token = strtok(NULL, " ")) { + for (token = strtok(str, " "); token; token = strtok(nullptr, " ")) { retval[count] = atoi(token); count++; } @@ -1948,10 +1948,10 @@ bool INIClass::Get_Bool(char const * section, char const * entry, bool defvalue) /* ** Verify that the parameters are nominally correct. */ - if (section == NULL || entry == NULL) return(defvalue); + if (section == nullptr || entry == nullptr) return(defvalue); INIEntry * entryptr = Find_Entry(section, entry); - if (entryptr && entryptr->Value != NULL) { + if (entryptr && entryptr->Value != nullptr) { switch (toupper(*entryptr->Value)) { case 'Y': case 'T': @@ -2188,7 +2188,7 @@ TPoint2D const INIClass::Get_Point(char const * section, char const * ent * INPUT: entry -- The entry to scan for. * * * * OUTPUT: Returns with a pointer to the entry control structure if the entry was found. * - * Otherwise it returns NULL. * + * Otherwise it returns nullptr. * * * * WARNINGS: none * * * @@ -2199,14 +2199,14 @@ TPoint2D const INIClass::Get_Point(char const * section, char const * ent *=============================================================================================*/ INIEntry * INISection::Find_Entry(char const * entry) const { - if (entry != NULL) { + if (entry != nullptr) { // int crc = CRCEngine()(entry, strlen(entry)); int crc = CRC::String(entry); if (EntryIndex.Is_Present(crc)) { return(EntryIndex[crc]); } } - return(NULL); + return(nullptr); } @@ -2227,7 +2227,7 @@ INIEntry * INISection::Find_Entry(char const * entry) const *=============================================================================================*/ void INIClass::Strip_Comments(char * buffer) { - if (buffer != NULL) { + if (buffer != nullptr) { char * comment = strchr(buffer, ';'); if (comment) { *comment = '\0'; @@ -2286,7 +2286,7 @@ void INIClass::DuplicateCRCError(const char *message, const char *section, const #ifdef RTS_RELEASE #ifdef _WIN32 - MessageBox(0, buffer, "Duplicate CRC in INI file.", MB_ICONSTOP | MB_OK); + MessageBox(nullptr, 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 1ed5b8477dc..e173b867f39 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/inisup.h +++ b/Core/Libraries/Source/WWVegas/WWLib/inisup.h @@ -52,9 +52,9 @@ ** The entry identifier and value string are combined into this object. */ struct INIEntry : public Node { - INIEntry(char * entry = NULL, char * value = NULL) : Entry(entry), Value(value) {} + INIEntry(char * entry = nullptr, char * value = nullptr) : Entry(entry), Value(value) {} ~INIEntry(void); -// ~INIEntry(void) {free(Entry);Entry = NULL;free(Value);Value = NULL;} +// ~INIEntry(void) {free(Entry);Entry = nullptr;free(Value);Value = nullptr;} // int Index_ID(void) const {return(CRCEngine()(Entry, strlen(Entry)));}; int Index_ID(void) const { return CRC::String(Entry);}; diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzo.cpp b/Core/Libraries/Source/WWVegas/WWLib/lzo.cpp index cca880a9f37..ba763b35e41 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzo.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/lzo.cpp @@ -111,5 +111,5 @@ int LZOCompressor::Decompress { CriticalSectionClass::LockClass m(mutex); - return lzo1x_decompress(in,in_len,out,out_len,NULL); + return lzo1x_decompress(in,in_len,out,out_len,nullptr); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzo1x.h b/Core/Libraries/Source/WWVegas/WWLib/lzo1x.h index cae5f0e368d..e880d47b73c 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzo1x.h +++ b/Core/Libraries/Source/WWVegas/WWLib/lzo1x.h @@ -73,7 +73,7 @@ ************************************************************************/ /* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. + * When the required size is 0, you can also pass a nullptr pointer. */ #define LZO1X_MEM_COMPRESS ((lzo_uint) (16384L * sizeof(lzo_byte *))) diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzo_conf.h b/Core/Libraries/Source/WWVegas/WWLib/lzo_conf.h index d1e3e2b84fa..597c4e2b50c 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzo_conf.h +++ b/Core/Libraries/Source/WWVegas/WWLib/lzo_conf.h @@ -280,7 +280,7 @@ #else /* This is the safe (but slower) version */ #define LZO_CHECK_MPOS_DET(m_pos,m_off,in,ip,max_offset) \ - (m_pos == NULL || (m_off = ip - m_pos) > max_offset) + (m_pos == nullptr || (m_off = ip - m_pos) > max_offset) #endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzopipe.cpp b/Core/Libraries/Source/WWVegas/WWLib/lzopipe.cpp index 543aa56e257..eb6e8b50961 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzopipe.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/lzopipe.cpp @@ -67,8 +67,8 @@ LZOPipe::LZOPipe(CompControl control, int blocksize) : Control(control), Counter(0), - Buffer(NULL), - Buffer2(NULL), + Buffer(nullptr), + Buffer2(nullptr), BlockSize(blocksize) { SafetyMargin = BlockSize; @@ -95,10 +95,10 @@ LZOPipe::LZOPipe(CompControl control, int blocksize) : LZOPipe::~LZOPipe(void) { delete [] Buffer; - Buffer = NULL; + Buffer = nullptr; delete [] Buffer2; - Buffer2 = NULL; + Buffer2 = nullptr; } @@ -123,11 +123,11 @@ LZOPipe::~LZOPipe(void) *=============================================================================================*/ int LZOPipe::Put(void const * source, int slen) { - if (source == NULL || slen < 1) { + if (source == nullptr || slen < 1) { return(Pipe::Put(source, slen)); } - assert(Buffer != NULL); + assert(Buffer != nullptr); int total = 0; @@ -177,7 +177,7 @@ int LZOPipe::Put(void const * source, int slen) */ if (Counter == BlockHeader.CompCount) { unsigned int length = sizeof (Buffer2); - lzo1x_decompress ((unsigned char*)Buffer, BlockHeader.CompCount, (unsigned char*)Buffer2, &length, NULL); + lzo1x_decompress ((unsigned char*)Buffer, BlockHeader.CompCount, (unsigned char*)Buffer2, &length, nullptr); total += Pipe::Put(Buffer2, BlockHeader.UncompCount); Counter = 0; BlockHeader.CompCount = 0xFFFF; @@ -264,7 +264,7 @@ int LZOPipe::Put(void const * source, int slen) *=============================================================================================*/ int LZOPipe::Flush(void) { - assert(Buffer != NULL); + assert(Buffer != nullptr); int total = 0; diff --git a/Core/Libraries/Source/WWVegas/WWLib/lzostraw.cpp b/Core/Libraries/Source/WWVegas/WWLib/lzostraw.cpp index f6184547498..3b892300ef1 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/lzostraw.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/lzostraw.cpp @@ -66,8 +66,8 @@ LZOStraw::LZOStraw(CompControl control, int blocksize) : Control(control), Counter(0), - Buffer(NULL), - Buffer2(NULL), + Buffer(nullptr), + Buffer2(nullptr), BlockSize(blocksize) { SafetyMargin = BlockSize; @@ -95,10 +95,10 @@ LZOStraw::LZOStraw(CompControl control, int blocksize) : LZOStraw::~LZOStraw(void) { delete [] Buffer; - Buffer = NULL; + Buffer = nullptr; delete [] Buffer2; - Buffer2 = NULL; + Buffer2 = nullptr; } @@ -125,14 +125,14 @@ LZOStraw::~LZOStraw(void) *=============================================================================================*/ int LZOStraw::Get(void * destbuf, int slen) { - assert(Buffer != NULL); + assert(Buffer != nullptr); int total = 0; /* ** Verify parameters for legality. */ - if (destbuf == NULL || slen < 1) { + if (destbuf == nullptr || slen < 1) { return(0); } @@ -164,7 +164,7 @@ int LZOStraw::Get(void * destbuf, int slen) incount = Straw::Get(staging_buffer, BlockHeader.CompCount); if (incount != BlockHeader.CompCount) break; unsigned int length = sizeof(Buffer); - lzo1x_decompress ((unsigned char*)staging_buffer, BlockHeader.CompCount, (unsigned char*)Buffer, &length, NULL); + lzo1x_decompress ((unsigned char*)staging_buffer, BlockHeader.CompCount, (unsigned char*)Buffer, &length, nullptr); delete [] staging_buffer; Counter = BlockHeader.UncompCount; } else { diff --git a/Core/Libraries/Source/WWVegas/WWLib/mempool.h b/Core/Libraries/Source/WWVegas/WWLib/mempool.h index 3eae0cf003a..df32692e96b 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/mempool.h +++ b/Core/Libraries/Source/WWVegas/WWLib/mempool.h @@ -38,8 +38,8 @@ * ObjectPoolClass::Free_Object -- releases obj back into the pool * * ObjectPoolClass::Allocate_Object_Memory -- internal function which returns memory for an * * ObjectPoolClass::Free_Object_Memory -- internal function, returns object's memory to the * - * AutoPoolClass::operator new -- overriden new which calls the internal ObjectPool * - * AutoPoolClass::operator delete -- overriden delete which calls the internal ObjectPool * + * AutoPoolClass::operator new -- overridden new which calls the internal ObjectPool * + * AutoPoolClass::operator delete -- overridden delete which calls the internal ObjectPool * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ #pragma once @@ -176,8 +176,8 @@ ObjectPoolClass AutoPoolClass::Allocator = {} *=============================================================================================*/ template ObjectPoolClass::ObjectPoolClass(void) : - FreeListHead(NULL), - BlockListHead(NULL), + FreeListHead(nullptr), + BlockListHead(nullptr), FreeObjectCount(0), TotalObjectCount(0) { @@ -204,7 +204,7 @@ ObjectPoolClass::~ObjectPoolClass(void) // delete all of the blocks we allocated int block_count = 0; - while (BlockListHead != NULL) { + while (BlockListHead != nullptr) { uint32 * next_block = *(uint32 **)BlockListHead; ::operator delete(BlockListHead); BlockListHead = next_block; @@ -278,7 +278,7 @@ T * ObjectPoolClass::Allocate_Object_Memory(void) { FastCriticalSectionClass::LockClass lock(ObjectPoolCS); - if ( FreeListHead == 0 ) { + if ( FreeListHead == nullptr ) { // No free objects, allocate another block uint32 * tmp_block_head = BlockListHead; @@ -291,7 +291,7 @@ T * ObjectPoolClass::Allocate_Object_Memory(void) for ( int i = 0; i < BLOCK_SIZE; i++ ) { *(T**)(&(FreeListHead[i])) = &(FreeListHead[i+1]); // link up the elements } - *(T**)(&(FreeListHead[BLOCK_SIZE-1])) = 0; // Mark the end + *(T**)(&(FreeListHead[BLOCK_SIZE-1])) = nullptr; // Mark the end FreeObjectCount += BLOCK_SIZE; TotalObjectCount += BLOCK_SIZE; @@ -322,7 +322,7 @@ void ObjectPoolClass::Free_Object_Memory(T * obj) { FastCriticalSectionClass::LockClass lock(ObjectPoolCS); - WWASSERT(obj != NULL); + WWASSERT(obj != nullptr); *(T**)(obj) = FreeListHead; // Link to the Head FreeListHead = obj; // Set the Head FreeObjectCount++; @@ -330,7 +330,7 @@ void ObjectPoolClass::Free_Object_Memory(T * obj) /*********************************************************************************************** - * AutoPoolClass::operator new -- overriden new which calls the internal ObjectPool * + * AutoPoolClass::operator new -- overridden new which calls the internal ObjectPool * * * * INPUT: * * * @@ -350,7 +350,7 @@ void * AutoPoolClass::operator new( size_t size ) /*********************************************************************************************** - * AutoPoolClass::operator delete -- overriden delete which calls the internal ObjectPool * + * AutoPoolClass::operator delete -- overridden delete which calls the internal ObjectPool * * * * INPUT: * * * @@ -364,6 +364,6 @@ void * AutoPoolClass::operator new( size_t size ) template void AutoPoolClass::operator delete( void * memory ) { - if ( memory == 0 ) return; + if ( memory == nullptr ) return; Allocator.Free_Object_Memory((T*)memory); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/mingw.h b/Core/Libraries/Source/WWVegas/WWLib/mingw.h new file mode 100644 index 00000000000..388093a2462 --- /dev/null +++ b/Core/Libraries/Source/WWVegas/WWLib/mingw.h @@ -0,0 +1,60 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2026 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 + +#if defined(__MINGW32__) || defined(__MINGW64__) + +/* +** MinGW-w64 provides most mathematical constants in when _USE_MATH_DEFINES is set +** (which is done globally in cmake/mingw.cmake). +** +** However, MinGW's is missing one constant (M_1_SQRTPI) and uses a different name +** for another (M_SQRT1_2 instead of M_SQRT_2). We define those here to match MSVC and Watcom. +** +** This brings MinGW in line with MSVC (visualc.h) and Watcom (watcom.h) +** which provide all 14 mathematical constants. +*/ + +#include + +/* +** M_1_SQRTPI is not defined by MinGW's math.h +** Define it to match visualc.h and watcom.h +*/ +#ifndef M_1_SQRTPI +#define M_1_SQRTPI 0.564189583547756286948 +#endif + +/* +** MinGW defines M_SQRT1_2 instead of M_SQRT_2 +** Both represent 1/sqrt(2), just different naming +** Create an alias for compatibility +*/ +#ifndef M_SQRT_2 +#define M_SQRT_2 M_SQRT1_2 +#endif + +/* +** At this point, all 14 mathematical constants are available: +** M_E, M_LOG2E, M_LOG10E, M_LN2, M_LN10, +** M_PI, M_PI_2, M_PI_4, M_1_PI, M_2_PI, +** M_1_SQRTPI, M_2_SQRTPI, M_SQRT2, M_SQRT_2 +*/ + +#endif diff --git a/Core/Libraries/Source/WWVegas/WWLib/multilist.cpp b/Core/Libraries/Source/WWVegas/WWLib/multilist.cpp index 8689e5bbca6..bc06cc6c0b3 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/multilist.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/multilist.cpp @@ -40,7 +40,7 @@ #include "wwmemlog.h" /* -** Delcare the pool for ListNodes +** Declare the pool for ListNodes */ DEFINE_AUTO_POOL(MultiListNodeClass, 256); @@ -168,7 +168,7 @@ bool GenericMultiListClass::Internal_Add_After(MultiListObjectClass * obj,const existing_node = existing_node->NextList; } - if (existing_node == NULL) { + if (existing_node == nullptr) { return false; // he's not in this list! } @@ -194,14 +194,14 @@ bool GenericMultiListClass::Internal_Remove(MultiListObjectClass *obj) { // find the list node in this object that belongs to this list MultiListNodeClass * lnode = obj->Get_List_Node(); - MultiListNodeClass * prevlnode = 0; + MultiListNodeClass * prevlnode = nullptr; while ((lnode) && (lnode->List != this)) { prevlnode = lnode; lnode = lnode->NextList; } - if (lnode == 0) { + if (lnode == nullptr) { return false; } @@ -227,7 +227,7 @@ bool GenericMultiListClass::Internal_Remove(MultiListObjectClass *obj) MultiListObjectClass * GenericMultiListClass::Internal_Remove_List_Head(void) { if (Head.Next == &Head) { - return 0; // no more objects + return nullptr; // no more objects } MultiListNodeClass * node = Head.Next; diff --git a/Core/Libraries/Source/WWVegas/WWLib/multilist.h b/Core/Libraries/Source/WWVegas/WWLib/multilist.h index f99c5613e5b..542c8ad6252 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/multilist.h +++ b/Core/Libraries/Source/WWVegas/WWLib/multilist.h @@ -72,7 +72,7 @@ class MultiListObjectClass { public: - MultiListObjectClass(void) : ListNode(NULL) { } + MultiListObjectClass(void) : ListNode(nullptr) { } virtual ~MultiListObjectClass(void); MultiListNodeClass * Get_List_Node() const { return ListNode; } @@ -262,7 +262,7 @@ class MultiListClass : public GenericMultiListClass void Reset_List() { - while (Get_Head() != NULL) { + while (Get_Head() != nullptr) { Remove_Head(); } } @@ -310,7 +310,7 @@ class MultiListIterator : public GenericMultiListIterator void Remove_Current_Object(void) { ObjectType * obj = Peek_Obj(); - if (obj != NULL) { + if (obj != nullptr) { Next(); ((MultiListClass *)List)->Remove(obj); } @@ -425,7 +425,7 @@ class RefMultiListClass : public GenericMultiListClass void Reset_List() { - while (Peek_Head() != NULL) { + while (Peek_Head() != nullptr) { Release_Head(); } } @@ -451,7 +451,7 @@ class RefMultiListIterator : public GenericMultiListIterator ObjectType * Get_Obj(void) { ObjectType * obj = (ObjectType*)Current_Object(); - if (obj != NULL) { + if (obj != nullptr) { obj->Add_Ref(); } return obj; @@ -465,7 +465,7 @@ class RefMultiListIterator : public GenericMultiListIterator void Remove_Current_Object(void) { ObjectType * obj = Peek_Obj(); - if (obj != NULL) { + if (obj != nullptr) { Next(); ((RefMultiListClass *)List)->Remove(obj); } @@ -494,7 +494,7 @@ class PriorityMultiListIterator : public MultiListIterator public: PriorityMultiListIterator(MultiListClass *list) - : OriginalHead (NULL), + : OriginalHead (nullptr), MultiListIterator(list) { First (); } bool @@ -504,8 +504,8 @@ class PriorityMultiListIterator : public MultiListIterator // Check to ensure we don't wrap around the list (stop after iterating // the list once). - if (CurNode != NULL && CurNode->Object != NULL && OriginalHead != CurNode) { - OriginalHead = (OriginalHead == NULL) ? CurNode : OriginalHead; + if (CurNode != nullptr && CurNode->Object != nullptr && OriginalHead != CurNode) { + OriginalHead = (OriginalHead == nullptr) ? CurNode : OriginalHead; (*object) = (ObjectType *)CurNode->Object; diff --git a/Core/Libraries/Source/WWVegas/WWLib/mutex.cpp b/Core/Libraries/Source/WWVegas/WWLib/mutex.cpp index 946090a282e..765b1857083 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/mutex.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/mutex.cpp @@ -24,12 +24,12 @@ // ---------------------------------------------------------------------------- -MutexClass::MutexClass(const char* name) : handle(NULL), locked(false) +MutexClass::MutexClass(const char* name) : handle(nullptr), locked(false) { #ifdef _UNIX //assert(0); #else - handle=CreateMutex(NULL,false,name); + handle=CreateMutex(nullptr,false,name); WWASSERT(handle); #endif } @@ -90,7 +90,7 @@ MutexClass::LockClass::~LockClass() // ---------------------------------------------------------------------------- -CriticalSectionClass::CriticalSectionClass() : handle(NULL), locked(false) +CriticalSectionClass::CriticalSectionClass() : handle(nullptr), locked(false) { #ifdef _UNIX //assert(0); diff --git a/Core/Libraries/Source/WWVegas/WWLib/mutex.h b/Core/Libraries/Source/WWVegas/WWLib/mutex.h index cce5055f478..a9c106ce196 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/mutex.h +++ b/Core/Libraries/Source/WWVegas/WWLib/mutex.h @@ -40,13 +40,13 @@ class MutexClass unsigned locked; // Lock and unlock are private so that you can't use them directly. Use LockClass as a sentry instead! - // Lock returns true if lock was succesful, false otherwise + // Lock returns true if lock was successful, false otherwise bool Lock(int time); void Unlock(); public: - // Name can (and usually should) be NULL. Use name only if you wish to create a globally unique mutex - MutexClass(const char* name = NULL); + // Name can (and usually should) be nullptr. Use name only if you wish to create a globally unique mutex + MutexClass(const char* name = nullptr); ~MutexClass(); enum { @@ -89,7 +89,7 @@ class CriticalSectionClass void Unlock(); public: - // Name can (and usually should) be NULL. Use name only if you wish to create a globally unique mutex + // Name can (and usually should) be nullptr. Use name only if you wish to create a globally unique mutex CriticalSectionClass(); ~CriticalSectionClass(); @@ -123,7 +123,7 @@ class FastCriticalSectionClass #endif public: - // Name can (and usually should) be NULL. Use name only if you wish to create a globally unique mutex + // Name can (and usually should) be nullptr. Use name only if you wish to create a globally unique mutex FastCriticalSectionClass() #if defined(_MSC_VER) && _MSC_VER < 1300 : Flag(0) diff --git a/Core/Libraries/Source/WWVegas/WWLib/notifier.h b/Core/Libraries/Source/WWVegas/WWLib/notifier.h index 97aaca08316..2f4bf286d73 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/notifier.h +++ b/Core/Libraries/Source/WWVegas/WWLib/notifier.h @@ -60,7 +60,7 @@ template class Observer typedef std::vector< Notifier* > NotifierColl; Observer() : - mNotifiers(NULL) + mNotifiers() {} virtual ~Observer() @@ -91,7 +91,7 @@ template class Observer while (!mNotifiers.empty()) { Notifier* notifier = mNotifiers.back(); - assert(notifier && "ERROR: NULL pointer in collection."); + assert(notifier && "ERROR: null pointer in collection."); notifier->RemoveObserver(*this); } } diff --git a/Core/Libraries/Source/WWVegas/WWLib/nstrdup.cpp b/Core/Libraries/Source/WWVegas/WWLib/nstrdup.cpp index 82aee8ade4d..81b1d29802c 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/nstrdup.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/nstrdup.cpp @@ -54,7 +54,7 @@ *========================================================================*/ char * nstrdup(const char *str) { - if(str == 0) return 0; + if(str == nullptr) return nullptr; // eventually should be replaced with NEW when we go to the wwnew stuff. char *retval = W3DNEWARRAY char [strlen(str) + 1]; diff --git a/Core/Libraries/Source/WWVegas/WWLib/ntree.h b/Core/Libraries/Source/WWVegas/WWLib/ntree.h index 075bfd9e0b8..7466d6712fe 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ntree.h +++ b/Core/Libraries/Source/WWVegas/WWLib/ntree.h @@ -61,7 +61,7 @@ class NTreeClass // Public constructors/destructors ////////////////////////////////////////////////////////////// NTreeClass (void) - : m_Root (NULL) { } + : m_Root (nullptr) { } virtual ~NTreeClass (void) { Reset (); } ////////////////////////////////////////////////////////////// @@ -92,9 +92,9 @@ class NTreeClass template NTreeLeafClass *NTreeClass::Add (const T &value) { - NTreeLeafClass *retval = NULL; + NTreeLeafClass *retval = nullptr; - if (m_Root == NULL) { + if (m_Root == nullptr) { // // Allocate a new root node @@ -121,13 +121,13 @@ NTreeLeafClass *NTreeClass::Add (const T &value) template void NTreeClass::Reset (void) { - if (m_Root != NULL) { + if (m_Root != nullptr) { // // Find the last leaf in the root // NTreeLeafClass *end_leaf = m_Root; - while (end_leaf->Peek_Next () != NULL) { + while (end_leaf->Peek_Next () != nullptr) { end_leaf = end_leaf->Peek_Next (); } @@ -137,7 +137,7 @@ void NTreeClass::Reset (void) // leaf along the way is guarenteed to have at least 1 // reference count on it. // - for (NTreeLeafClass *leaf = end_leaf; leaf != NULL; ) { + for (NTreeLeafClass *leaf = end_leaf; leaf != nullptr; ) { NTreeLeafClass *curr_leaf = leaf; leaf = leaf->Peek_Prev (); @@ -189,9 +189,9 @@ class SortedNTreeClass : public NTreeClass template SortedNTreeLeafClass *SortedNTreeClass::Add_Sorted (const T &value, const char *name) { - SortedNTreeLeafClass *retval = NULL; + SortedNTreeLeafClass *retval = nullptr; - if (m_Root == NULL) { + if (m_Root == nullptr) { // // Allocate a new root node @@ -213,7 +213,7 @@ SortedNTreeLeafClass *SortedNTreeClass::Add_Sorted (const T &value, const // Make sure our 'root' pointer is the first one in the list // NTreeLeafClass *prev = m_Root->Peek_Prev (); - if (prev != NULL) { + if (prev != nullptr) { REF_PTR_SET (m_Root, prev); } } @@ -236,10 +236,10 @@ class NTreeLeafClass : public RefCountClass // Public constructors/destructors ////////////////////////////////////////////////////////////// NTreeLeafClass (void) - : m_Parent (NULL), - m_Child (NULL), - m_PrevSibling (NULL), - m_NextSibling (NULL) { } + : m_Parent (nullptr), + m_Child (nullptr), + m_PrevSibling (nullptr), + m_NextSibling (nullptr) { } virtual ~NTreeLeafClass (void); @@ -319,7 +319,7 @@ NTreeLeafClass *NTreeLeafClass::Add_Child (const T &value) // // Link this new leaf into the hierarchy // - if (m_Child != NULL) { + if (m_Child != nullptr) { m_Child->Set_Prev (new_child); new_child->Set_Next (m_Child); } @@ -366,26 +366,26 @@ void NTreeLeafClass::Remove (void) // // Fixup the parent's child leaf object // - if (m_Parent != NULL && m_Parent->Peek_Child () == this) { + if (m_Parent != nullptr && m_Parent->Peek_Child () == this) { m_Parent->Set_Child (m_NextSibling); } // // Remove all our children // - while (m_Child != NULL) { + while (m_Child != nullptr) { m_Child->Remove (); } // // Unlink ourselves from our siblings // - if (m_NextSibling != NULL) { - m_NextSibling->Set_Prev (NULL); + if (m_NextSibling != nullptr) { + m_NextSibling->Set_Prev (nullptr); } - if (m_PrevSibling != NULL) { - m_PrevSibling->Set_Next (NULL); + if (m_PrevSibling != nullptr) { + m_PrevSibling->Set_Next (nullptr); } REF_PTR_RELEASE (m_Parent); @@ -454,7 +454,7 @@ SortedNTreeLeafClass *SortedNTreeLeafClass::Add_Sorted (const T &value, co // Find the first-most sibling // SortedNTreeLeafClass *start = this; - while (start->Peek_Prev () != NULL) { + while (start->Peek_Prev () != nullptr) { start = (SortedNTreeLeafClass *)start->Peek_Prev (); } @@ -484,7 +484,7 @@ SortedNTreeLeafClass *SortedNTreeLeafClass::Add_Child_Sorted (const T &val new_child->Set_Name (name); new_child->Set_Parent (this); - if (m_Child == NULL) { + if (m_Child == nullptr) { m_Child = new_child; } else { @@ -497,7 +497,7 @@ SortedNTreeLeafClass *SortedNTreeLeafClass::Add_Child_Sorted (const T &val // Make sure our 'child' pointer is the first one in the list // NTreeLeafClass *prev = m_Child->Peek_Prev (); - if (prev != NULL) { + if (prev != nullptr) { REF_PTR_SET (m_Child, prev); } @@ -523,7 +523,7 @@ void SortedNTreeLeafClass::Insertion_Sort (SortedNTreeLeafClass *start, So // bool inserted = false; for ( SortedNTreeLeafClass *leaf = start; - leaf != NULL && !inserted; + leaf != nullptr && !inserted; leaf = (SortedNTreeLeafClass *)leaf->Peek_Next ()) { // @@ -538,13 +538,13 @@ void SortedNTreeLeafClass::Insertion_Sort (SortedNTreeLeafClass *start, So new_sibling->Set_Prev (prev); new_sibling->Set_Next (leaf); leaf->Set_Prev (new_sibling); - if (prev != NULL) { + if (prev != nullptr) { prev->Set_Next (new_sibling); } inserted = true; - } else if (leaf->Peek_Next () == NULL) { + } else if (leaf->Peek_Next () == nullptr) { // // Put the new sibling on the end of the list diff --git a/Core/Libraries/Source/WWVegas/WWLib/pipe.cpp b/Core/Libraries/Source/WWVegas/WWLib/pipe.cpp index cbd752ee096..0a2845b756e 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/pipe.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/pipe.cpp @@ -61,15 +61,15 @@ *=============================================================================================*/ Pipe::~Pipe(void) { - if (ChainTo != NULL) { + if (ChainTo != nullptr) { ChainTo->ChainFrom = ChainFrom; } - if (ChainFrom != NULL) { + if (ChainFrom != nullptr) { ChainFrom->Put_To(ChainTo); } - ChainFrom = NULL; - ChainTo = NULL; + ChainFrom = nullptr; + ChainTo = nullptr; } @@ -91,18 +91,18 @@ Pipe::~Pipe(void) void Pipe::Put_To(Pipe * pipe) { if (ChainTo != pipe) { - if (pipe != NULL && pipe->ChainFrom != NULL) { - pipe->ChainFrom->Put_To(NULL); - pipe->ChainFrom = NULL; + if (pipe != nullptr && pipe->ChainFrom != nullptr) { + pipe->ChainFrom->Put_To(nullptr); + pipe->ChainFrom = nullptr; } - if (ChainTo != NULL) { - ChainTo->ChainFrom = NULL; + if (ChainTo != nullptr) { + ChainTo->ChainFrom = nullptr; ChainTo->Flush(); } ChainTo = pipe; - if (ChainTo != NULL) { + if (ChainTo != nullptr) { ChainTo->ChainFrom = this; } } @@ -129,7 +129,7 @@ void Pipe::Put_To(Pipe * pipe) *=============================================================================================*/ int Pipe::Put(void const * source, int length) { - if (ChainTo != NULL) { + if (ChainTo != nullptr) { return(ChainTo->Put(source, length)); } return(length); @@ -156,7 +156,7 @@ int Pipe::Put(void const * source, int length) *=============================================================================================*/ int Pipe::Flush(void) { - if (ChainTo != NULL) { + if (ChainTo != nullptr) { return(ChainTo->Flush()); } return(0); diff --git a/Core/Libraries/Source/WWVegas/WWLib/ramfile.cpp b/Core/Libraries/Source/WWVegas/WWLib/ramfile.cpp index 98de513cf4d..005830d1092 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ramfile.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/ramfile.cpp @@ -62,7 +62,7 @@ * * * INPUT: buffer -- Pointer to the buffer to use for this file. The buffer will already * * contain data if the file is opened for READ. It will be considered * - * a scratch buffer if opened for WRITE. If the buffer pointer is NULL * + * a scratch buffer if opened for WRITE. If the buffer pointer is nullptr * * but the length parameter is not, then a buffer will be allocated * * of the specified length. This case is only useful for opening the * * file for WRITE. * @@ -85,7 +85,7 @@ RAMFileClass::RAMFileClass(void * buffer, int len) : IsOpen(false), IsAllocated(false) { - if (buffer == NULL && len > 0) { + if (buffer == nullptr && len > 0) { Buffer = W3DNEWARRAY char[len]; IsAllocated = true; } @@ -111,7 +111,7 @@ RAMFileClass::~RAMFileClass(void) Close(); if (IsAllocated) { delete [] Buffer; - Buffer = NULL; + Buffer = nullptr; IsAllocated = false; } } @@ -250,7 +250,7 @@ int RAMFileClass::Open(char const *, int access) *=============================================================================================*/ int RAMFileClass::Open(int access) { - if (Buffer == NULL || Is_Open()) { + if (Buffer == nullptr || Is_Open()) { return(false); } @@ -297,7 +297,7 @@ int RAMFileClass::Open(int access) *=============================================================================================*/ int RAMFileClass::Read(void * buffer, int size) { - if (Buffer == NULL || buffer == NULL || size == 0) { + if (Buffer == nullptr || buffer == nullptr || size == 0) { return(0); } @@ -346,7 +346,7 @@ int RAMFileClass::Read(void * buffer, int size) *=============================================================================================*/ int RAMFileClass::Seek(int pos, int dir) { - if (Buffer == NULL || !Is_Open()) { + if (Buffer == nullptr || !Is_Open()) { return(Offset); } @@ -422,7 +422,7 @@ int RAMFileClass::Size(void) *=============================================================================================*/ int RAMFileClass::Write(void const * buffer, int size) { - if (Buffer == NULL || buffer == NULL || size == 0) { + if (Buffer == nullptr || buffer == nullptr || size == 0) { return(0); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/random.cpp b/Core/Libraries/Source/WWVegas/WWLib/random.cpp index 3ebbd227e83..a99576267f4 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/random.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/random.cpp @@ -56,7 +56,7 @@ Time for Random3=1.281000 Time for Random4=0.375000 Time for Built in Rand()=0.813000 Results from DIEHARD battery of tests -A p-value of 0.0 or 1.0 means it fails. Anything inbetween is ok. +A p-value of 0.0 or 1.0 means it fails. Anything in between is ok. R0 - FAILED almost all tests, didn't complete squeeze test R2 - Passed all tests, p-value 0.6 R3 - Failed 11 of 253 tests, p-value 1.0 @@ -211,7 +211,7 @@ int Random2Class::operator() (void) * This routine will generate a random number between the two values specified. It uses * * a method that will not bias the values in any way. * * * - * INPUT: minval -- The minium return value (inclusive). * + * INPUT: minval -- The minimum return value (inclusive). * * * * maxval -- The maximum return value (inclusive). * * * @@ -320,7 +320,7 @@ int Random3Class::operator() (void) * This routine will generate a random number between the two values specified. It uses * * a method that will not bias the values in any way. * * * - * INPUT: minval -- The minium return value (inclusive). * + * INPUT: minval -- The minimum return value (inclusive). * * * * maxval -- The maximum return value (inclusive). * * * diff --git a/Core/Libraries/Source/WWVegas/WWLib/rawfile.cpp b/Core/Libraries/Source/WWVegas/WWLib/rawfile.cpp index f282d3ee306..2f88162d4a2 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/rawfile.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/rawfile.cpp @@ -290,11 +290,11 @@ void RawFileClass::Reset(void) * RawFileClass::File_Name -- Returns with the filename associate with the file object. * * * * Use this routine to determine what filename is associated with this file object. If no * - * filename has yet been assigned, then this routing will return NULL. * + * filename has yet been assigned, then this routing will return null. * * * * INPUT: none * * * - * OUTPUT: Returns with a pointer to the file name associated with this file object or NULL * + * OUTPUT: Returns with a pointer to the file name associated with this file object or nullptr * * if one doesn't exist. * * * * WARNINGS: none * @@ -402,7 +402,7 @@ int RawFileClass::Open(int rights) ** Verify that there is a filename associated with this file object. If not, then this is a ** big error condition. */ - if (Filename.Get_Length()==0) { + if (Filename.Is_Empty()) { Error(ENOENT, false); } @@ -492,7 +492,7 @@ int RawFileClass::Open(int rights) *=============================================================================================*/ bool RawFileClass::Is_Available(int forced) { - if (Filename.Get_Length()==0) return(false); + if (Filename.Is_Empty()) return(false); /* ** If the file is already open, then is must have already passed the availability check. @@ -587,10 +587,10 @@ void RawFileClass::Close(void) * the file. This condition can result in fewer bytes being read than requested. Determine * * this by examining the return value. * * * - * INPUT: buffer -- Pointer to the buffer to read data into. If NULL is passed, no read * + * INPUT: buffer -- Pointer to the buffer to read data into. If nullptr is passed, no read * * is performed. * * * - * size -- The number of bytes to read. If NULL is passed, then no read is * + * size -- The number of bytes to read. If nullptr is passed, then no read is * * performed. * * * * OUTPUT: Returns with the number of bytes read into the buffer. If this number is less * @@ -755,7 +755,7 @@ int RawFileClass::Seek(int pos, int dir) /* ** A file that is biased will have a seek operation modified so that the file appears to ** exist only within the bias range. All bytes outside of this range appear to be - ** non-existant. + ** non-existent. */ if (BiasLength != -1) { switch (dir) { diff --git a/Core/Libraries/Source/WWVegas/WWLib/rcfile.cpp b/Core/Libraries/Source/WWVegas/WWLib/rcfile.cpp index 5462b803980..543dddfdfef 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/rcfile.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/rcfile.cpp @@ -42,11 +42,11 @@ const char * RESOURCE_FILE_TYPE_NAME = "File"; ResourceFileClass::ResourceFileClass(HMODULE hmodule, char const *filename) : - ResourceName(NULL), - hModule(NULL), - FileBytes(NULL), - FilePtr(NULL), - EndOfFile(NULL) + ResourceName(nullptr), + hModule(nullptr), + FileBytes(nullptr), + FilePtr(nullptr), + EndOfFile(nullptr) { Set_Name(filename); HRSRC hresource = FindResource(hmodule,ResourceName,RESOURCE_FILE_TYPE_NAME); @@ -71,7 +71,7 @@ ResourceFileClass::~ResourceFileClass(void) char const * ResourceFileClass::Set_Name(char const *filename) { free(ResourceName); - ResourceName = NULL; + ResourceName = nullptr; if (filename) { ResourceName = strdup(filename); diff --git a/Core/Libraries/Source/WWVegas/WWLib/rcfile.h b/Core/Libraries/Source/WWVegas/WWLib/rcfile.h index 6217f09062c..55740e7000a 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/rcfile.h +++ b/Core/Libraries/Source/WWVegas/WWLib/rcfile.h @@ -60,7 +60,7 @@ class ResourceFileClass : public FileClass virtual int Create(void) { return false; } virtual int Delete(void) { return false; } virtual bool Is_Available(int /*forced=false*/) { return Is_Open (); } - virtual bool Is_Open(void) const { return (FileBytes != NULL); } + virtual bool Is_Open(void) const { return (FileBytes != nullptr); } virtual int Open(char const * /*fname*/, int /*rights=READ*/) { return Is_Open(); } virtual int Open(int /*rights=READ*/) { return Is_Open(); } @@ -70,7 +70,7 @@ class ResourceFileClass : public FileClass virtual int Size(void); virtual int Write(void const * /*buffer*/, int /*size*/) { return 0; } virtual void Close(void) { } - virtual void Error(int error, int canretry = false, char const * filename=NULL); + virtual void Error(int error, int canretry = false, char const * filename=nullptr); virtual void Bias(int start, int length=-1) {} virtual unsigned char *Peek_Data(void) const { return FileBytes; } diff --git a/Core/Libraries/Source/WWVegas/WWLib/readline.cpp b/Core/Libraries/Source/WWVegas/WWLib/readline.cpp index 25112a4745c..199fe30bcde 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/readline.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/readline.cpp @@ -101,7 +101,7 @@ int Read_Line(FileClass & file, char * buffer, int len, bool & eof) *=============================================================================================*/ int Read_Line(Straw & file, char * buffer, int len, bool & eof) { - if (len == 0 || buffer == NULL) return(0); + if (len == 0 || buffer == nullptr) return(0); int count = 0; for (;;) { @@ -125,7 +125,7 @@ int Read_Line(Straw & file, char * buffer, int len, bool & eof) int Read_Line(Straw & file, wchar_t * buffer, int len, bool & eof) { - if (len == 0 || buffer == NULL) return(0); + if (len == 0 || buffer == nullptr) return(0); int count = 0; for (;;) { diff --git a/Core/Libraries/Source/WWVegas/WWLib/realcrc.cpp b/Core/Libraries/Source/WWVegas/WWLib/realcrc.cpp index 9e7708c3860..d4ff35607fa 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/realcrc.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/realcrc.cpp @@ -33,7 +33,7 @@ *---------------------------------------------------------------------------------------------* * Functions: * * CRC_Memory -- calculates a CRC for a block of memory * - * CRC_String -- Calculates a CRC for a NULL-terminated string * + * CRC_String -- Calculates a CRC for a null-terminated string * * CRC_Stringi -- Calculates a CRC for a string, case-insensitive * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ @@ -134,7 +134,7 @@ unsigned long CRC_Memory( const unsigned char *data, unsigned long length, unsig /*********************************************************************************************** - * CRC_String -- Calculates a CRC for a NULL-terminated string * + * CRC_String -- Calculates a CRC for a null-terminated string * * * * INPUT: * * * diff --git a/Core/Libraries/Source/WWVegas/WWLib/ref_ptr.h b/Core/Libraries/Source/WWVegas/WWLib/ref_ptr.h index b7063138d0c..6401e53af1b 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/ref_ptr.h +++ b/Core/Libraries/Source/WWVegas/WWLib/ref_ptr.h @@ -219,7 +219,7 @@ class RefCountPtr // Is generally used for objects returned by operator new and "Get" functions. static RefCountPtr Create_NoAddRef(T *t) { - WWASSERT(t == NULL || t->Num_Refs() >= 1); + WWASSERT(t == nullptr || t->Num_Refs() >= 1); return RefCountPtr(t, RefCountPtr::GET); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/refcount.cpp b/Core/Libraries/Source/WWVegas/WWLib/refcount.cpp index 01f16cc45c1..d9f1e0de0fe 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/refcount.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/refcount.cpp @@ -71,7 +71,7 @@ RefCountListClass RefCountClass::ActiveRefList; RefCountClass * RefCountClass::Add_Active_Ref(RefCountClass *obj) { ActiveRefList.Add_Head(&(obj->ActiveRefNode)); - obj->ActiveRefInfo.File = NULL; // default to no debug information added. + obj->ActiveRefInfo.File = nullptr; // default to no debug information added. obj->ActiveRefInfo.Line = 0; return obj; } diff --git a/Core/Libraries/Source/WWVegas/WWLib/registry.cpp b/Core/Libraries/Source/WWVegas/WWLib/registry.cpp index 15ec71602fc..90b8d4f0316 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/registry.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/registry.cpp @@ -71,8 +71,8 @@ RegistryClass::RegistryClass( const char * sub_key, bool create ) : if (create && !IsLocked) { DWORD disposition; - result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, sub_key, 0, NULL, 0, - KEY_ALL_ACCESS, NULL, &key, &disposition); + result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, sub_key, 0, nullptr, 0, + KEY_ALL_ACCESS, nullptr, &key, &disposition); } else { result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, sub_key, 0, IsLocked ? KEY_READ : KEY_ALL_ACCESS, &key); } @@ -96,7 +96,7 @@ int RegistryClass::Get_Int( const char * name, int def_value ) { assert( IsValid ); DWORD type, data = 0, data_len = sizeof( data ); - if (( ::RegQueryValueEx( (HKEY)Key, name, NULL, &type, (LPBYTE)&data, &data_len ) == + if (( ::RegQueryValueEx( (HKEY)Key, name, nullptr, &type, (LPBYTE)&data, &data_len ) == ERROR_SUCCESS ) && ( type == REG_DWORD )) { } else { data = def_value; @@ -132,7 +132,7 @@ float RegistryClass::Get_Float( const char * name, float def_value ) assert( IsValid ); float data = 0; DWORD type, data_len = sizeof( data ); - if (( ::RegQueryValueEx( (HKEY)Key, name, NULL, &type, (LPBYTE)&data, &data_len ) == + if (( ::RegQueryValueEx( (HKEY)Key, name, nullptr, &type, (LPBYTE)&data, &data_len ) == ERROR_SUCCESS ) && ( type == REG_DWORD )) { } else { data = def_value; @@ -156,7 +156,7 @@ int RegistryClass::Get_Bin_Size( const char * name ) assert( IsValid ); unsigned long size = 0; - ::RegQueryValueEx( (HKEY)Key, name, NULL, NULL, NULL, &size ); + ::RegQueryValueEx( (HKEY)Key, name, nullptr, nullptr, nullptr, &size ); return size; } @@ -164,18 +164,18 @@ int RegistryClass::Get_Bin_Size( const char * name ) void RegistryClass::Get_Bin( const char * name, void *buffer, int buffer_size ) { assert( IsValid ); - assert( buffer != NULL ); + assert( buffer != nullptr ); assert( buffer_size > 0 ); unsigned long size = buffer_size; - ::RegQueryValueEx( (HKEY)Key, name, NULL, NULL, (LPBYTE)buffer, &size ); + ::RegQueryValueEx( (HKEY)Key, name, nullptr, nullptr, (LPBYTE)buffer, &size ); return ; } void RegistryClass::Set_Bin( const char * name, const void *buffer, int buffer_size ) { assert( IsValid ); - assert( buffer != NULL ); + assert( buffer != nullptr ); assert( buffer_size > 0 ); if (IsLocked) { @@ -188,20 +188,20 @@ void RegistryClass::Set_Bin( const char * name, const void *buffer, int buffer_s void RegistryClass::Get_String( const char * name, StringClass &string, const char *default_string ) { assert( IsValid ); - string = (default_string == NULL) ? "" : default_string; + string = (default_string == nullptr) ? "" : default_string; // // Get the size of the entry // DWORD data_size = 0; DWORD type = 0; - LONG result = ::RegQueryValueEx ((HKEY)Key, name, NULL, &type, NULL, &data_size); + LONG result = ::RegQueryValueEx ((HKEY)Key, name, nullptr, &type, nullptr, &data_size); if (result == ERROR_SUCCESS && type == REG_SZ) { // // Read the entry from the registry // - ::RegQueryValueEx ((HKEY)Key, name, NULL, &type, + ::RegQueryValueEx ((HKEY)Key, name, nullptr, &type, (LPBYTE)string.Get_Buffer (data_size), &data_size); } @@ -214,12 +214,12 @@ char *RegistryClass::Get_String( const char * name, char *value, int value_size, { assert( IsValid ); DWORD type = 0; - if (( ::RegQueryValueEx( (HKEY)Key, name, NULL, &type, (LPBYTE)value, (DWORD*)&value_size ) == + if (( ::RegQueryValueEx( (HKEY)Key, name, nullptr, &type, (LPBYTE)value, (DWORD*)&value_size ) == ERROR_SUCCESS ) && ( type == REG_SZ )) { } else { //*value = 0; //value = (char *) default_string; - if (default_string == NULL) { + if (default_string == nullptr) { *value = 0; } else { assert(strlen(default_string) < (unsigned int) value_size); @@ -232,7 +232,7 @@ char *RegistryClass::Get_String( const char * name, char *value, int value_size, void RegistryClass::Set_String( const char * name, const char *value ) { assert( IsValid ); - int size = strlen( value ) + 1; // must include NULL + int size = strlen( value ) + 1; // must include null terminator if (IsLocked) { return; } @@ -251,7 +251,7 @@ void RegistryClass::Get_Value_List( DynamicVectorClass &list ) int index = 0; unsigned long sizeof_name = sizeof (value_name); while (::RegEnumValue ((HKEY)Key, index ++, - value_name, &sizeof_name, 0, NULL, NULL, NULL) == ERROR_SUCCESS) + value_name, &sizeof_name, nullptr, nullptr, nullptr, nullptr) == ERROR_SUCCESS) { sizeof_name = sizeof (value_name); @@ -298,20 +298,20 @@ void RegistryClass::Deleta_All_Values( void ) void RegistryClass::Get_String( const WCHAR * name, WideStringClass &string, const WCHAR *default_string ) { assert( IsValid ); - string = (default_string == NULL) ? L"" : default_string; + string = (default_string == nullptr) ? L"" : default_string; // // Get the size of the entry // DWORD data_size = 0; DWORD type = 0; - LONG result = ::RegQueryValueExW ((HKEY)Key, name, NULL, &type, NULL, &data_size); + LONG result = ::RegQueryValueExW ((HKEY)Key, name, nullptr, &type, nullptr, &data_size); if (result == ERROR_SUCCESS && type == REG_SZ) { // // Read the entry from the registry // - ::RegQueryValueExW ((HKEY)Key, name, NULL, &type, + ::RegQueryValueExW ((HKEY)Key, name, nullptr, &type, (LPBYTE)string.Get_Buffer ((data_size / 2) + 1), &data_size); } @@ -376,7 +376,7 @@ void RegistryClass::Save_Registry_Values(HKEY key, char *path, INIClass *ini) char value_name[256]; unsigned long value_name_size = sizeof(value_name); - result = RegEnumValue(key, index, value_name, &value_name_size, 0, &type, data, &data_size); + result = RegEnumValue(key, index, value_name, &value_name_size, nullptr, &type, data, &data_size); if (result == ERROR_SUCCESS) { switch (type) { @@ -463,7 +463,7 @@ void RegistryClass::Save_Registry_Tree(char *path, INIClass *ini) while (result == ERROR_SUCCESS) { class_name_size = sizeof(class_name); name_size = sizeof(name); - result = RegEnumKeyEx(base_key, index, name, &name_size, 0, class_name, &class_name_size, &file_time); + result = RegEnumKeyEx(base_key, index, name, &name_size, nullptr, class_name, &class_name_size, &file_time); if (result == ERROR_SUCCESS) { /* @@ -479,7 +479,7 @@ void RegistryClass::Save_Registry_Tree(char *path, INIClass *ini) long new_result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, new_key_path, 0, KEY_ALL_ACCESS, &sub_key); if (new_result == ERROR_SUCCESS) { - new_result = RegQueryInfoKey(sub_key, NULL, NULL, 0, &num_subs, NULL, NULL, &num_values, NULL, NULL, NULL, NULL); + new_result = RegQueryInfoKey(sub_key, nullptr, nullptr, nullptr, &num_subs, nullptr, nullptr, &num_values, nullptr, nullptr, nullptr, nullptr); /* ** If there are sun keys then enumerate those. @@ -558,7 +558,7 @@ void RegistryClass::Load_Registry(const char *filename, char *old_path, char *ne List §ion_list = ini.Get_Section_List(); - for (INISection *section = section_list.First() ; section != NULL ; section = section->Next_Valid()) { + for (INISection *section = section_list.First() ; section != nullptr ; section = section->Next_Valid()) { /* ** Build the new path to use in the registry. @@ -637,7 +637,7 @@ void RegistryClass::Delete_Registry_Values(HKEY key) char value_name[256]; unsigned long value_name_size = sizeof(value_name); - result = RegEnumValue(key, index, value_name, &value_name_size, 0, &type, data, &data_size); + result = RegEnumValue(key, index, value_name, &value_name_size, nullptr, &type, data, &data_size); if (result == ERROR_SUCCESS) { result = RegDeleteValue(key, value_name); @@ -686,7 +686,7 @@ void RegistryClass::Delete_Registry_Tree(char *path) while (result == ERROR_SUCCESS) { class_name_size = sizeof(class_name); name_size = sizeof(name); - result = RegEnumKeyEx(base_key, index, name, &name_size, 0, class_name, &class_name_size, &file_time); + result = RegEnumKeyEx(base_key, index, name, &name_size, nullptr, class_name, &class_name_size, &file_time); if (result == ERROR_SUCCESS) { /* @@ -702,7 +702,7 @@ void RegistryClass::Delete_Registry_Tree(char *path) long new_result = RegOpenKeyEx(HKEY_LOCAL_MACHINE, new_key_path, 0, KEY_ALL_ACCESS, &sub_key); if (new_result == ERROR_SUCCESS) { - new_result = RegQueryInfoKey(sub_key, NULL, NULL, 0, &num_subs, NULL, NULL, &num_values, NULL, NULL, NULL, NULL); + new_result = RegQueryInfoKey(sub_key, nullptr, nullptr, nullptr, &num_subs, nullptr, nullptr, &num_values, nullptr, nullptr, nullptr, nullptr); /* ** If there are sub keys then enumerate those. diff --git a/Core/Libraries/Source/WWVegas/WWLib/registry.h b/Core/Libraries/Source/WWVegas/WWLib/registry.h index 0e83f40f89c..75cefcf13d3 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/registry.h +++ b/Core/Libraries/Source/WWVegas/WWLib/registry.h @@ -69,12 +69,12 @@ class RegistryClass { // String data type access char *Get_String( const char * name, char *value, int value_size, - const char * default_string = NULL ); - void Get_String( const char * name, StringClass &string, const char *default_string = NULL); + const char * default_string = nullptr ); + void Get_String( const char * name, StringClass &string, const char *default_string = nullptr); void Set_String( const char * name, const char *value ); // Wide string data type access - void Get_String( const WCHAR * name, WideStringClass &string, const WCHAR *default_string = NULL); + void Get_String( const WCHAR * name, WideStringClass &string, const WCHAR *default_string = nullptr); void Set_String( const WCHAR * name, const WCHAR *value ); // Binary data type access diff --git a/Core/Libraries/Source/WWVegas/WWLib/search.h b/Core/Libraries/Source/WWVegas/WWLib/search.h index 35a7d9032e2..1c88c488adf 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/search.h +++ b/Core/Libraries/Source/WWVegas/WWLib/search.h @@ -40,7 +40,7 @@ * IndexClass::IndexClass -- Constructor for index handler. * * IndexClass::Invalidate_Archive -- Invalidate the archive pointer. * * IndexClass::Is_Archive_Same -- Checks to see if archive pointer is same as index. * - * IndexClass::Is_Present -- Checks for presense of index entry. * + * IndexClass::Is_Present -- Checks for presence of index entry. * * IndexClass::Remove_Index -- Find matching index and remove it from system. * * IndexClass::Search_For_Node -- Perform a search for the specified node ID * * IndexClass::Set_Archive -- Records the node pointer into the archive. * @@ -291,7 +291,7 @@ bool IndexClass::Increase_Table_Size(int amount) if (amount < 0) return(false); NodeElement * table = W3DNEWARRAY NodeElement[IndexSize + amount]; - if (table != NULL) { + if (table != nullptr) { /* ** Copy all valid nodes into the new table. @@ -325,12 +325,12 @@ bool IndexClass::Increase_Table_Size(int amount) /*********************************************************************************************** * IndexClass::Count -- Fetch the number of index entries recorded. * * * - * This will return the quantity of index entries that have been recored by this index * + * This will return the quantity of index entries that have been recorded by this index * * handler. * * * * INPUT: none * * * - * OUTPUT: Returns with number of recored indecies present. * + * OUTPUT: Returns with number of recorded indices present. * * * * WARNINGS: none * * * @@ -345,7 +345,7 @@ int IndexClass::Count(void) const /*********************************************************************************************** - * IndexClass::Is_Present -- Checks for presense of index entry. * + * IndexClass::Is_Present -- Checks for presence of index entry. * * * * This routine will scan for the specified index entry. If it was found, then 'true' is * * returned. * @@ -412,7 +412,7 @@ bool IndexClass::Is_Present(int id) const * * * WARNINGS: This routine presumes that the index exists. If it doesn't exist, then the * * default constructed object "T" is returned instead. To avoid this problem, * - * always verfiy the existance of the index by calling Is_Present() first. * + * always verfiy the existence of the index by calling Is_Present() first. * * * * HISTORY: * * 11/02/1996 JLB : Created. * @@ -626,7 +626,7 @@ bool IndexClass::Remove_Index(int id) * * * OUTPUT: Returns with the comparision value between the two nodes. * * * - * WARNINGS: This is highly dependant upon the layout of the NodeElement structure. * + * WARNINGS: This is highly dependent upon the layout of the NodeElement structure. * * * * HISTORY: * * 11/02/1996 JLB : Created. * @@ -653,7 +653,7 @@ int _USERENTRY IndexClass::search_compfunc(void const * ptr1, void const * pt * INPUT: id -- The index ID to search for. * * * * OUTPUT: Returns with a pointer to the NodeElement that matches the index ID specified. If * - * no matching index could be found, then NULL is returned. * + * no matching index could be found, then nullptr is returned. * * * * WARNINGS: none * * * diff --git a/Core/Libraries/Source/WWVegas/WWLib/sharebuf.h b/Core/Libraries/Source/WWVegas/WWLib/sharebuf.h index 05f75027b6c..e2d0291cc49 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/sharebuf.h +++ b/Core/Libraries/Source/WWVegas/WWLib/sharebuf.h @@ -113,7 +113,7 @@ template ShareBufferClass::~ShareBufferClass(void) { delete[] Array; - Array = NULL; + Array = nullptr; } template diff --git a/Core/Libraries/Source/WWVegas/WWLib/simplevec.h b/Core/Libraries/Source/WWVegas/WWLib/simplevec.h index ae2c6bc5a75..3ecbd8b180c 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/simplevec.h +++ b/Core/Libraries/Source/WWVegas/WWLib/simplevec.h @@ -77,7 +77,7 @@ template class SimpleVecClass int Length(void) const { return VectorMax; } virtual bool Resize(int newsize); virtual bool Uninitialised_Grow(int newsize); - void Zero_Memory(void) { if (Vector != NULL) { memset(Vector,0,VectorMax * sizeof(T)); } } + void Zero_Memory(void) { if (Vector != nullptr) { memset(Vector,0,VectorMax * sizeof(T)); } } protected: @@ -101,7 +101,7 @@ template class SimpleVecClass *=============================================================================================*/ template inline SimpleVecClass::SimpleVecClass(int size) : - Vector(NULL), + Vector(nullptr), VectorMax(0) { if (size > 0) { @@ -125,7 +125,7 @@ template inline SimpleVecClass::~SimpleVecClass(void) { delete[] Vector; - Vector = NULL; + Vector = nullptr; VectorMax = 0; } @@ -160,7 +160,7 @@ inline bool SimpleVecClass::Resize(int newsize) ** If there is an old vector, then it must be copied (as much as is feasible) ** to the new vector. */ - if (Vector != NULL) { + if (Vector != nullptr) { /* ** Mem copy as much of the old vector into the new vector as possible. @@ -172,7 +172,7 @@ inline bool SimpleVecClass::Resize(int newsize) ** Delete the old vector. */ delete[] Vector; - Vector = NULL; + Vector = nullptr; } /* @@ -187,7 +187,7 @@ inline bool SimpleVecClass::Resize(int newsize) ** Delete entire vector and reset counts */ delete[] Vector; - Vector = NULL; + Vector = nullptr; VectorMax = 0; } return true; @@ -321,7 +321,7 @@ template inline SimpleDynVecClass::~SimpleDynVecClass(void) { delete[] Vector; - Vector = NULL; + Vector = nullptr; } /*********************************************************************************************** diff --git a/Core/Libraries/Source/WWVegas/WWLib/straw.cpp b/Core/Libraries/Source/WWVegas/WWLib/straw.cpp index a18068ad8e1..84ed8bf9f23 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/straw.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/straw.cpp @@ -60,15 +60,15 @@ *=============================================================================================*/ Straw::~Straw(void) { - if (ChainTo != NULL) { + if (ChainTo != nullptr) { ChainTo->ChainFrom = ChainFrom; } - if (ChainFrom != NULL) { + if (ChainFrom != nullptr) { ChainFrom->Get_From(ChainTo); } - ChainFrom = NULL; - ChainTo = NULL; + ChainFrom = nullptr; + ChainTo = nullptr; } @@ -91,17 +91,17 @@ Straw::~Straw(void) void Straw::Get_From(Straw * straw) { if (ChainTo != straw) { - if (straw != NULL && straw->ChainFrom != NULL) { - straw->ChainFrom->Get_From(NULL); - straw->ChainFrom = NULL; + if (straw != nullptr && straw->ChainFrom != nullptr) { + straw->ChainFrom->Get_From(nullptr); + straw->ChainFrom = nullptr; } - if (ChainTo != NULL) { - ChainTo->ChainFrom = NULL; + if (ChainTo != nullptr) { + ChainTo->ChainFrom = nullptr; } ChainTo = straw; - if (ChainTo != NULL) { + if (ChainTo != nullptr) { ChainTo->ChainFrom = this; } } @@ -130,7 +130,7 @@ void Straw::Get_From(Straw * straw) *=============================================================================================*/ int Straw::Get(void * source, int slen) { - if (ChainTo != NULL) { + if (ChainTo != nullptr) { return(ChainTo->Get(source, slen)); } return(0); diff --git a/Core/Libraries/Source/WWVegas/WWLib/strtok_r.cpp b/Core/Libraries/Source/WWVegas/WWLib/strtok_r.cpp index e9c9faec05a..66d0a195753 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/strtok_r.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/strtok_r.cpp @@ -55,7 +55,7 @@ char *strtok_r(char *strptr, const char *delimiters, char **lasts) *lasts=strptr; if ((*lasts)[0]==0) // 0 length string? - return(NULL); + return(nullptr); // // Note: strcspn & strspn are both called, they're opposites @@ -68,7 +68,7 @@ char *strtok_r(char *strptr, const char *delimiters, char **lasts) *lasts+=dend; if ((*lasts)[0]==0) // 0 length string? - return(NULL); + return(nullptr); dstart=strcspn(*lasts, delimiters); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/systimer.h b/Core/Libraries/Source/WWVegas/WWLib/systimer.h index 56db4c64b22..89676f2965e 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/systimer.h +++ b/Core/Libraries/Source/WWVegas/WWLib/systimer.h @@ -51,7 +51,7 @@ inline unsigned long systimerGetMS(void) { struct timeval tv; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); return (tv.tv_sec * 1000) + (tv.tv_usec / 1000); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/textfile.cpp b/Core/Libraries/Source/WWVegas/WWLib/textfile.cpp index 52d33f6f7d1..bc36014894c 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/textfile.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/textfile.cpp @@ -130,7 +130,7 @@ TextFileClass::Read_Line (StringClass &string) } } - bool retval = (string.Get_Length () > 0); + bool retval = (!string.Is_Empty()); if (retval) { int len = string.Get_Length (); diff --git a/Core/Libraries/Source/WWVegas/WWLib/tgatodxt.cpp b/Core/Libraries/Source/WWVegas/WWLib/tgatodxt.cpp index d1db1743cf9..334fe55fc59 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/tgatodxt.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/tgatodxt.cpp @@ -55,12 +55,12 @@ TGAToDXTClass _TGAToDXTConverter; // /////////////////////////////////////////////////////////////////////////////// TGAToDXTClass::TGAToDXTClass() - : WriteTimePtr (NULL), + : WriteTimePtr (nullptr), BufferSize (1024), BufferCount (0) { Buffer = new unsigned char [BufferSize]; - WWASSERT (Buffer != NULL); + WWASSERT (Buffer != nullptr); } @@ -207,15 +207,15 @@ void TGAToDXTClass::Write (const char *outputpathname) HANDLE hfile; DWORD bytecountwritten; - hfile = ::CreateFile (outputpathname, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, 0L, NULL); + hfile = ::CreateFile (outputpathname, GENERIC_WRITE, FILE_SHARE_READ, nullptr, CREATE_ALWAYS, 0L, nullptr); if (hfile != INVALID_HANDLE_VALUE) { LockFile (hfile, 0, 0, BufferCount, 0); - WriteFile (hfile, Buffer, BufferCount, &bytecountwritten, NULL); + WriteFile (hfile, Buffer, BufferCount, &bytecountwritten, nullptr); UnlockFile (hfile, 0, 0, BufferCount, 0); // Stamp the write time (if one has been supplied). - if (WriteTimePtr != NULL) { - SetFileTime (hfile, NULL, NULL, WriteTimePtr); + if (WriteTimePtr != nullptr) { + SetFileTime (hfile, nullptr, nullptr, WriteTimePtr); } CloseHandle (hfile); @@ -253,7 +253,7 @@ void WriteDTXnFile (DWORD datacount, void *data) newbuffersize = MAX (_TGAToDXTConverter.BufferSize * 2, _TGAToDXTConverter.BufferCount + datacount); newbuffer = new unsigned char [newbuffersize]; - WWASSERT (newbuffer != NULL); + WWASSERT (newbuffer != nullptr); memcpy (newbuffer, _TGAToDXTConverter.Buffer, _TGAToDXTConverter.BufferCount); delete [] _TGAToDXTConverter.Buffer; _TGAToDXTConverter.Buffer = newbuffer; diff --git a/Core/Libraries/Source/WWVegas/WWLib/thread.cpp b/Core/Libraries/Source/WWVegas/WWLib/thread.cpp index aaad589d7f4..7b30487e27b 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/thread.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/thread.cpp @@ -57,13 +57,22 @@ void __cdecl ThreadClass::Internal_Thread_Function(void* params) #ifdef _WIN32 Register_Thread_ID(tc->ThreadID, tc->ThreadName); - if (tc->ExceptionHandler != NULL) { +#if defined(_MSC_VER) + // MSVC supports structured exception handling (__try/__except) + if (tc->ExceptionHandler != nullptr) { __try { tc->Thread_Function(); } __except(tc->ExceptionHandler(GetExceptionCode(), GetExceptionInformation())) {}; } else { tc->Thread_Function(); } +#elif defined(__GNUC__) && defined(_WIN32) + // GCC/MinGW-w64 doesn't support MSVC's __try/__except syntax + // Call Thread_Function directly without SEH support + tc->Thread_Function(); +#else + #error "ThreadClass::Internal_Thread_Function: Unsupported compiler. This code requires MSVC or GCC/MinGW-w64 targeting Windows." +#endif #else //_WIN32 tc->Thread_Function(); @@ -126,7 +135,7 @@ void ThreadClass::Sleep_Ms(unsigned ms) } #ifndef _UNIX -HANDLE test_event = ::CreateEvent (NULL, FALSE, FALSE, ""); +HANDLE test_event = ::CreateEvent (nullptr, FALSE, FALSE, ""); #endif void ThreadClass::Switch_Thread() diff --git a/Core/Libraries/Source/WWVegas/WWLib/thread.h b/Core/Libraries/Source/WWVegas/WWLib/thread.h index 0f526274c68..2aae9fb4fe8 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/thread.h +++ b/Core/Libraries/Source/WWVegas/WWLib/thread.h @@ -43,7 +43,7 @@ class ThreadClass public: typedef int (*ExceptionHandlerType)(int exception_code, struct _EXCEPTION_POINTERS *e_info); - ThreadClass(const char *name = NULL, ExceptionHandlerType exception_handler = NULL); + ThreadClass(const char *name = nullptr, ExceptionHandlerType exception_handler = nullptr); virtual ~ThreadClass(); // Execute Thread_Function(). Note that only one instance can be executed at a time. @@ -71,7 +71,7 @@ class ThreadClass const char *Get_Name(void) {return(ThreadName);}; // Get info about a registered thread by it's index. - static int Get_Thread_By_Index(int index, char *name_ptr = NULL); + static int Get_Thread_By_Index(int index, char *name_ptr = nullptr); protected: diff --git a/Core/Libraries/Source/WWVegas/WWLib/trect.h b/Core/Libraries/Source/WWVegas/WWLib/trect.h index b302888f5f6..0446753d2e5 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/trect.h +++ b/Core/Libraries/Source/WWVegas/WWLib/trect.h @@ -59,7 +59,7 @@ class TRect TRect const operator + (TPoint2D const & point) {return(TRect(X + point.X, Y + point.Y, Width, Height));} TRect const operator - (TPoint2D const & point) {return(TRect(X - point.X, Y - point.Y, Width, Height));} - TRect const Intersect(TRect const & rectangle, T * x=NULL, T * y=NULL) const; + TRect const Intersect(TRect const & rectangle, T * x=nullptr, T * y=nullptr) const; TRect const Union(TRect const & rect2) const; /* @@ -163,10 +163,10 @@ TRect const TRect::Intersect(TRect const & rectangle, T * x, T * y) con ** Adjust Height relative draw position according to Height new rectangle ** union. */ - if (x != NULL) { + if (x != nullptr) { *x -= (r.X-X); } - if (y != NULL) { + if (y != nullptr) { *y -= (r.Y-Y); } diff --git a/Core/Libraries/Source/WWVegas/WWLib/trim.cpp b/Core/Libraries/Source/WWVegas/WWLib/trim.cpp index 36a39d02114..ccc97c2ff88 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/trim.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/trim.cpp @@ -44,7 +44,7 @@ /*********************************************************************************************** * strtrim -- Trim leading and trailing white space off of string. * * * - * This routine will remove the leading and trailing whitespace from the string specifed. * + * This routine will remove the leading and trailing whitespace from the string specified. * * The string is modified in place. * * * * INPUT: buffer -- Pointer to the string to be trimmed. * diff --git a/Core/Libraries/Source/WWVegas/WWLib/uarray.h b/Core/Libraries/Source/WWVegas/WWLib/uarray.h index ba630938249..50b7061e94a 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/uarray.h +++ b/Core/Libraries/Source/WWVegas/WWLib/uarray.h @@ -146,7 +146,7 @@ template UniqueArrayClass::~UniqueArrayClass(void) { delete[] HashTable; - HashTable = NULL; + HashTable = nullptr; } diff --git a/Core/Libraries/Source/WWVegas/WWLib/vector.cpp b/Core/Libraries/Source/WWVegas/WWLib/vector.cpp index f9333e06773..0d6b4800bde 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/vector.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/vector.cpp @@ -85,7 +85,7 @@ BooleanVectorClass::BooleanVectorClass(unsigned size, unsigned char * array) : BitCount(size), Copy(false), LastIndex(-1), - BitArray(0, 0) + BitArray(0, nullptr) { BitArray.Resize(((size + (8-1)) / 8), array); // LastIndex = -1; diff --git a/Core/Libraries/Source/WWVegas/WWLib/verchk.cpp b/Core/Libraries/Source/WWVegas/WWLib/verchk.cpp index 6aa6cc4af80..b555c48bbcf 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/verchk.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/verchk.cpp @@ -61,7 +61,7 @@ bool GetVersionInfo(char* filename, VS_FIXEDFILEINFO* fileInfo) { - if (filename == NULL || fileInfo == NULL) + if (filename == nullptr || fileInfo == nullptr) { return false; } @@ -121,7 +121,7 @@ bool GetFileCreationTime(char* filename, FILETIME* createTime) if (handle != INVALID_HANDLE_VALUE) { - if (GetFileTime(handle, NULL, NULL, createTime)) + if (GetFileTime(handle, nullptr, nullptr, createTime)) { return true; } @@ -173,7 +173,7 @@ Get_Image_File_Header (const char *filename, IMAGE_FILE_HEADER *file_header) } _TheFileFactory->Return_File(file); - file=NULL; + file=nullptr; return retval; } @@ -193,7 +193,7 @@ Get_Image_File_Header (HINSTANCE app_instance, IMAGE_FILE_HEADER *file_header) // Read the dos header (all PE exectuable files begin with this) // IMAGE_DOS_HEADER *dos_header = (IMAGE_DOS_HEADER *)app_instance; - if (dos_header != NULL) { + if (dos_header != nullptr) { // // Determine the offset where the image header resides diff --git a/Core/Libraries/Source/WWVegas/WWLib/verchk.h b/Core/Libraries/Source/WWVegas/WWLib/verchk.h index 2dbebead96d..6f5d492c434 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/verchk.h +++ b/Core/Libraries/Source/WWVegas/WWLib/verchk.h @@ -41,7 +41,7 @@ // Obtain version information from the specified file. bool GetVersionInfo(char* filename, VS_FIXEDFILEINFO* fileInfo); -// Retreive creation time of specified file. +// Retrieve creation time of specified file. bool GetFileCreationTime(char* filename, FILETIME* createTime); //////////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWLib/widestring.cpp b/Core/Libraries/Source/WWVegas/WWLib/widestring.cpp index 41cbb495eaa..fa421229b2b 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/widestring.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/widestring.cpp @@ -67,10 +67,10 @@ WCHAR * WideStringClass::m_FreeTempPtr[MAX_TEMP_STRING] = { }; WCHAR * WideStringClass::m_ResTempPtr[MAX_TEMP_STRING] = { - NULL, - NULL, - NULL, - NULL + nullptr, + nullptr, + nullptr, + nullptr }; @@ -86,7 +86,7 @@ WideStringClass::Get_String (int length, bool is_temp) m_Buffer = m_EmptyString; } else { - WCHAR *string = NULL; + WCHAR *string = nullptr; // // Should we attempt to use a temp buffer for this string? @@ -103,14 +103,14 @@ WideStringClass::Get_String (int length, bool is_temp) // Try to find an available temporary buffer // for (int index = 0; index < MAX_TEMP_STRING; index ++) { - if (m_FreeTempPtr[index] != NULL) { + if (m_FreeTempPtr[index] != nullptr) { // // Grab this unused buffer for our string // string = m_FreeTempPtr[index]; m_ResTempPtr[index] = m_FreeTempPtr[index]; - m_FreeTempPtr[index] = NULL; + m_FreeTempPtr[index] = nullptr; Set_Buffer_And_Allocated_Length (string, MAX_TEMP_LEN); // @@ -122,7 +122,7 @@ WideStringClass::Get_String (int length, bool is_temp) } } - if (string == NULL) { + if (string == nullptr) { Set_Buffer_And_Allocated_Length (Allocate_Buffer (length), length); } } @@ -212,7 +212,7 @@ WideStringClass::Free_String (void) // m_Buffer[0] = 0; m_FreeTempPtr[index] = m_Buffer; - m_ResTempPtr[index] = 0; + m_ResTempPtr[index] = nullptr; m_UsedTempStringCount --; found = true; break; @@ -242,10 +242,10 @@ WideStringClass::Free_String (void) // Format // /////////////////////////////////////////////////////////////////// -int _cdecl +int __cdecl WideStringClass::Format_Args (const WCHAR *format, va_list arg_list ) { - if (format == NULL) { + if (format == nullptr) { return 0; } @@ -273,10 +273,10 @@ WideStringClass::Format_Args (const WCHAR *format, va_list arg_list ) // Format // /////////////////////////////////////////////////////////////////// -int _cdecl +int __cdecl WideStringClass::Format (const WCHAR *format, ...) { - if (format == NULL) { + if (format == nullptr) { return 0; } @@ -319,11 +319,11 @@ WideStringClass::Release_Resources (void) /////////////////////////////////////////////////////////////////// bool WideStringClass::Convert_From (const char *text) { - if (text != NULL) { + if (text != nullptr) { int length; - length = MultiByteToWideChar (CP_ACP, 0, text, -1, NULL, 0); + length = MultiByteToWideChar (CP_ACP, 0, text, -1, nullptr, 0); if (length > 0) { Uninitialised_Grow (length); diff --git a/Core/Libraries/Source/WWVegas/WWLib/widestring.h b/Core/Libraries/Source/WWVegas/WWLib/widestring.h index 3f08f9c3564..68421655bf5 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/widestring.h +++ b/Core/Libraries/Source/WWVegas/WWLib/widestring.h @@ -104,8 +104,8 @@ class WideStringClass bool Is_Empty (void) const; void Erase (int start_index, int char_count); - int _cdecl Format (const WCHAR *format, ...); - int _cdecl Format_Args (const WCHAR *format, va_list arg_list ); + int __cdecl Format (const WCHAR *format, ...); + int __cdecl Format_Args (const WCHAR *format, va_list arg_list ); bool Convert_From (const char *text); bool Convert_To (StringClass &string); bool Convert_To (StringClass &string) const; diff --git a/Core/Libraries/Source/WWVegas/WWLib/wwstring.cpp b/Core/Libraries/Source/WWVegas/WWLib/wwstring.cpp index f4da1100c4a..62c612d0856 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/wwstring.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/wwstring.cpp @@ -71,7 +71,7 @@ StringClass::Get_String (int length, bool is_temp) return; } - TCHAR *string = NULL; + TCHAR *string = nullptr; // // Should we attempt to use a temp buffer for this string? @@ -113,7 +113,7 @@ StringClass::Get_String (int length, bool is_temp) } } - if (string == NULL) { + if (string == nullptr) { // // Allocate a new string as necessary @@ -235,7 +235,7 @@ StringClass::Free_String (void) // Format // /////////////////////////////////////////////////////////////////// -int _cdecl +int __cdecl StringClass::Format_Args (const TCHAR *format, va_list arg_list ) { // @@ -267,7 +267,7 @@ StringClass::Format_Args (const TCHAR *format, va_list arg_list ) // Format // /////////////////////////////////////////////////////////////////// -int _cdecl +int __cdecl StringClass::Format (const TCHAR *format, ...) { va_list arg_list; @@ -316,16 +316,16 @@ StringClass::Release_Resources (void) /////////////////////////////////////////////////////////////////// bool StringClass::Copy_Wide (const WCHAR *source) { - if (source != NULL) { + if (source != nullptr) { int length; int unmapped; - length = WideCharToMultiByte (CP_ACP, 0 , source, -1, NULL, 0, NULL, &unmapped); + length = WideCharToMultiByte (CP_ACP, 0 , source, -1, nullptr, 0, nullptr, &unmapped); if (length > 0) { // Convert. - WideCharToMultiByte (CP_ACP, 0, source, -1, Get_Buffer (length), length, NULL, NULL); + WideCharToMultiByte (CP_ACP, 0, source, -1, Get_Buffer (length), length, nullptr, nullptr); // Update length. Store_Length (length - 1); diff --git a/Core/Libraries/Source/WWVegas/WWLib/wwstring.h b/Core/Libraries/Source/WWVegas/WWLib/wwstring.h index 3a5745163bd..6ae220b3787 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/wwstring.h +++ b/Core/Libraries/Source/WWVegas/WWLib/wwstring.h @@ -114,8 +114,8 @@ class StringClass bool Is_Empty (void) const; void Erase (int start_index, int char_count); - int _cdecl Format (const TCHAR *format, ...); - int _cdecl Format_Args (const TCHAR *format, va_list arg_list ); + int __cdecl Format (const TCHAR *format, ...); + int __cdecl Format_Args (const TCHAR *format, va_list arg_list ); // Trim leading and trailing whitespace characters (values <= 32) void Trim(void); @@ -497,7 +497,7 @@ inline void StringClass::Trim(void) inline const StringClass & StringClass::operator+= (const TCHAR *string) { - WWASSERT (string != NULL); + WWASSERT (string != nullptr); int cur_len = Get_Length (); int src_len = _tcslen (string); diff --git a/Core/Libraries/Source/WWVegas/WWLib/xpipe.cpp b/Core/Libraries/Source/WWVegas/WWLib/xpipe.cpp index 15e310c9e64..cceb4400f75 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/xpipe.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/xpipe.cpp @@ -70,7 +70,7 @@ int BufferPipe::Put(void const * source, int slen) { int total = 0; - if (Is_Valid() && source != NULL && slen > 0) { + if (Is_Valid() && source != nullptr && slen > 0) { int len = slen; if (BufferPtr.Get_Size() != 0) { int theoretical_max = BufferPtr.Get_Size() - Index; @@ -99,7 +99,7 @@ FilePipe::~FilePipe(void) if (Valid_File() && HasOpened) { HasOpened = false; File->Close(); - File = NULL; + File = nullptr; } } @@ -153,7 +153,7 @@ int FilePipe::End(void) *=============================================================================================*/ int FilePipe::Put(void const * source, int slen) { - if (Valid_File() && source != NULL && slen > 0) { + if (Valid_File() && source != nullptr && slen > 0) { if (!File->Is_Open()) { HasOpened = true; File->Open(FileClass::WRITE); diff --git a/Core/Libraries/Source/WWVegas/WWLib/xstraw.cpp b/Core/Libraries/Source/WWVegas/WWLib/xstraw.cpp index d567c0421ca..9e520096aca 100644 --- a/Core/Libraries/Source/WWVegas/WWLib/xstraw.cpp +++ b/Core/Libraries/Source/WWVegas/WWLib/xstraw.cpp @@ -68,7 +68,7 @@ int BufferStraw::Get(void * source, int slen) { int total = 0; - if (Is_Valid() && source != NULL && slen > 0) { + if (Is_Valid() && source != nullptr && slen > 0) { int len = slen; if (BufferPtr.Get_Size() != 0) { int theoretical_max = BufferPtr.Get_Size() - Index; @@ -113,7 +113,7 @@ int BufferStraw::Get(void * source, int slen) *=============================================================================================*/ int FileStraw::Get(void * source, int slen) { - if (Valid_File() && source != NULL && slen > 0) { + if (Valid_File() && source != nullptr && slen > 0) { if (!File->Is_Open()) { HasOpened = true; if (!File->Is_Available()) return(0); @@ -145,6 +145,6 @@ FileStraw::~FileStraw(void) if (Valid_File() && HasOpened) { File->Close(); HasOpened = false; - File = NULL; + File = nullptr; } } diff --git a/Core/Libraries/Source/WWVegas/WWMath/CMakeLists.txt b/Core/Libraries/Source/WWVegas/WWMath/CMakeLists.txt index d88eb09edb7..dca9eb68fef 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/WWMath/CMakeLists.txt @@ -87,6 +87,8 @@ target_sources(core_wwmath PRIVATE ${WWMATH_SRC}) target_link_libraries(core_wwmath PRIVATE core_wwcommon + corei_always + core_wwsaveload ) # @todo Test its impact and see what to do with the legacy functions. diff --git a/Core/Libraries/Source/WWVegas/WWMath/aabox.h b/Core/Libraries/Source/WWVegas/WWMath/aabox.h index eb0b29669fa..1ec34cc7afc 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/aabox.h +++ b/Core/Libraries/Source/WWVegas/WWMath/aabox.h @@ -518,7 +518,7 @@ WWINLINE bool AABoxClass::Contains(const Vector3 & point) const WWINLINE void MinMaxAABoxClass::Init(Vector3 * points,int num) { assert(num > 0); - assert(points != NULL); + assert(points != nullptr); MinCorner = points[0]; MaxCorner = points[0]; for (int i=0; iGet_Culling_System() == NULL), + (obj->Get_Culling_System() == nullptr), "AABTreeCullSystemClass::Add -- Object is already in another culling system!\n" ); @@ -172,9 +172,9 @@ void AABTreeCullSystemClass::Remove_Object_Internal(CullableClass * obj) WWASSERT(node); node->Remove_Object(obj); - link->Set_Culling_System(NULL); + link->Set_Culling_System(nullptr); delete link; - obj->Set_Cull_Link(NULL); + obj->Set_Cull_Link(nullptr); ObjectCount--; WWASSERT(ObjectCount >= 0); @@ -304,7 +304,7 @@ void AABTreeCullSystemClass::Add_Loaded_Object(AABTreeNodeClass * node,CullableC WWASSERT_PRINT ( - (obj->Get_Culling_System() == NULL), + (obj->Get_Culling_System() == nullptr), "AABTreeCullSystemClass::Add_Loaded_Object -- Object is already in another culling system!\n" ); @@ -381,7 +381,7 @@ void AABTreeCullSystemClass::Re_Partition(const AABoxClass & bounds,SimpleDynVec */ dummy_node->Box.Extent.Set(0,0,0); CullableClass * obj = get_first_object(dummy_node); - while (obj != NULL) { + while (obj != nullptr) { Update_Culling(obj); obj = get_first_object(dummy_node); } @@ -781,7 +781,7 @@ void AABTreeCullSystemClass::Load_Nodes(AABTreeNodeClass * node,ChunkLoadClass & // if we are supposed to have a front child, load it if (node_desc.Attributes & AABNODE_ATTRIBUTE_FRONT_CHILD) { - WWASSERT(node->Front == NULL); + WWASSERT(node->Front == nullptr); node->Front = new AABTreeNodeClass(); node->Front->Parent = node; Load_Nodes(node->Front,cload); @@ -789,7 +789,7 @@ void AABTreeCullSystemClass::Load_Nodes(AABTreeNodeClass * node,ChunkLoadClass & // if we have a back child, load it if (node_desc.Attributes & AABNODE_ATTRIBUTE_BACK_CHILD) { - WWASSERT(node->Back == NULL); + WWASSERT(node->Back == nullptr); node->Back = new AABTreeNodeClass(); node->Back->Parent = node; Load_Nodes(node->Back,cload); @@ -882,7 +882,7 @@ void AABTreeCullSystemClass::Save_Object_Linkage(ChunkSaveClass & csave,Cullable void AABTreeCullSystemClass::Re_Index_Nodes(void) { delete[] IndexedNodes; - IndexedNodes = NULL; + IndexedNodes = nullptr; NodeCount = Partition_Node_Count(); WWASSERT(NodeCount > 0); @@ -918,10 +918,10 @@ void AABTreeCullSystemClass::Re_Index_Nodes_Recursive(AABTreeNodeClass * node,in AABTreeNodeClass::AABTreeNodeClass(void) : Index(0), Box(Vector3(0,0,0),Vector3(0,0,0)), - Parent(NULL), - Front(NULL), - Back(NULL), - Object(NULL), + Parent(nullptr), + Front(nullptr), + Back(nullptr), + Object(nullptr), UserData(0) { } @@ -929,14 +929,14 @@ AABTreeNodeClass::AABTreeNodeClass(void) : AABTreeNodeClass::~AABTreeNodeClass(void) { // objects should be removed before deleting the partition tree - WWASSERT(Object == NULL); + WWASSERT(Object == nullptr); // delete our children delete Front; - Front = NULL; + Front = nullptr; delete Back; - Back = NULL; + Back = nullptr; } void AABTreeNodeClass::Compute_Bounding_Box(void) @@ -1000,7 +1000,7 @@ void AABTreeNodeClass::Add_Object(CullableClass * obj,bool update_bounds) if (update_bounds) { // if this is the only object and we have no children, just copy // the object's bounding box, otherwise, add it to what we have - if ((Object_Count() == 1) && (Front == NULL) && (Back == NULL)) { + if ((Object_Count() == 1) && (Front == nullptr) && (Back == nullptr)) { Box = obj->Get_Cull_Box(); } else { Box.Add_Box(obj->Get_Cull_Box()); @@ -1013,7 +1013,7 @@ void AABTreeNodeClass::Remove_Object(CullableClass * obj) WWASSERT(obj); // find the given object in our linked list - CullableClass * prevobj = NULL; + CullableClass * prevobj = nullptr; CullableClass * curobj = Object; while (curobj) { @@ -1029,8 +1029,8 @@ void AABTreeNodeClass::Remove_Object(CullableClass * obj) Object = link->NextObject; } - link->NextObject = NULL; - link->Node = NULL; + link->NextObject = nullptr; + link->Node = nullptr; return; } @@ -1076,7 +1076,7 @@ CullableClass * AABTreeNodeClass::Peek_Object(int index) { int count = 0; CullableClass * obj = Object; - WWASSERT(obj != NULL); + WWASSERT(obj != nullptr); while (obj && (count != index)) { count++; @@ -1107,7 +1107,7 @@ void AABTreeNodeClass::Partition(void) */ SimpleDynVecClass boxes(obj_count); CullableClass * obj = Object; - while (obj != NULL) { + while (obj != nullptr) { boxes.Add(obj->Get_Cull_Box()); obj = get_next_object(obj); } @@ -1144,7 +1144,7 @@ void AABTreeNodeClass::Partition(void) Front->Partition(); } else { delete front; - front = NULL; + front = nullptr; } /* @@ -1156,7 +1156,7 @@ void AABTreeNodeClass::Partition(void) Back->Partition(); } else { delete back; - back = NULL; + back = nullptr; } } @@ -1165,8 +1165,8 @@ void AABTreeNodeClass::Partition(void) void AABTreeNodeClass::Split_Objects(const AABTreeNodeClass::SplitChoiceStruct & sc,AABTreeNodeClass * front,AABTreeNodeClass * back) { // This function assumes that this node is a leaf - WWASSERT(Front == NULL); - WWASSERT(Back == NULL); + WWASSERT(Front == nullptr); + WWASSERT(Back == nullptr); WWASSERT(Object_Count() == sc.FrontCount + sc.BackCount); int fcount = 0; @@ -1255,7 +1255,7 @@ void AABTreeNodeClass::Partition(const AABoxClass & bounds,SimpleDynVecClassParent = this; Front->Partition(sc.FrontBox,frontboxes); } else { - Front = NULL; + Front = nullptr; } /* @@ -1266,7 +1266,7 @@ void AABTreeNodeClass::Partition(const AABoxClass & bounds,SimpleDynVecClassParent = this; Back->Partition(sc.BackBox,backboxes); } else { - Back = NULL; + Back = nullptr; } } @@ -1317,14 +1317,14 @@ void AABTreeNodeClass::Select_Splitting_Plane SimpleDynVecClass & boxes ) { - const int NUM_TRYS = 300; + const int NUM_TRIES = 300; /* ** Try putting axis-aligned planes through some random vertices */ int objcount = boxes.Count(); - int trys = 0; - for (trys = 0; trys < MIN(NUM_TRYS,objcount); trys++) { + int tries = 0; + for (tries = 0; tries < MIN(NUM_TRIES,objcount); tries++) { int obj_index; SplitChoiceStruct test; @@ -1361,7 +1361,7 @@ void AABTreeNodeClass::Select_Splitting_Plane /* ** Still haven't found a valid splitting plane, uh-oh. */ - if ((trys >= MIN(NUM_TRYS,objcount)) && (sc->Cost == FLT_MAX)) { + if ((tries >= MIN(NUM_TRIES,objcount)) && (sc->Cost == FLT_MAX)) { Select_Splitting_Plane_Brute_Force(sc,boxes); return; } @@ -1473,7 +1473,7 @@ AABTreeIterator::AABTreeIterator(AABTreeCullSystemClass * tree) : Tree(tree), CurNodeIndex(0) { - WWASSERT(Tree != NULL); + WWASSERT(Tree != nullptr); } void AABTreeIterator::Reset(void) @@ -1507,7 +1507,7 @@ bool AABTreeIterator::Enter_Sibling(void) /* ** if our parent doesn't have two children, we don't have a sibling */ - if ((parent_front == NULL) || (parent_back == NULL)) { + if ((parent_front == nullptr) || (parent_back == nullptr)) { return false; } @@ -1533,7 +1533,7 @@ bool AABTreeIterator::Enter_Sibling(void) bool AABTreeIterator::Has_Front_Child(void) { validate(); - return (Tree->IndexedNodes[CurNodeIndex]->Front != NULL); + return (Tree->IndexedNodes[CurNodeIndex]->Front != nullptr); } bool AABTreeIterator::Enter_Front_Child(void) @@ -1549,7 +1549,7 @@ bool AABTreeIterator::Enter_Front_Child(void) bool AABTreeIterator::Has_Back_Child(void) { validate(); - return (Tree->IndexedNodes[CurNodeIndex]->Back != NULL); + return (Tree->IndexedNodes[CurNodeIndex]->Back != nullptr); } bool AABTreeIterator::Enter_Back_Child(void) diff --git a/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.h b/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.h index 7d0928bc5a0..c0009909155 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.h +++ b/Core/Libraries/Source/WWVegas/WWMath/aabtreecull.h @@ -72,9 +72,9 @@ class AABTreeCullSystemClass : public CullSystemClass /* ** Update_Bounding_Boxes. This function causes all bounding boxes in the tree to update themselves. ** If any box is found to not bound the objects it is supposed to contain, the box is updated - ** Note that this is normally not necessary, the reason this function existsis due to the fact + ** Note that this is normally not necessary, the reason this function exists is due to the fact ** that the renegade level editor tries to do everything possible to not discard the precalculated - ** visibilty data for a level. In some cases, we want to load geometry that has been edited back + ** visibility data for a level. In some cases, we want to load geometry that has been edited back ** into the same AABTree without re-partitioning. */ void Update_Bounding_Boxes(void); @@ -326,7 +326,7 @@ class AABTreeNodeClass : public AutoPoolClass class AABTreeLinkClass : public CullLinkClass, public AutoPoolClass { public: - AABTreeLinkClass(AABTreeCullSystemClass * system) : CullLinkClass(system),Node(NULL), NextObject(NULL) { } + AABTreeLinkClass(AABTreeCullSystemClass * system) : CullLinkClass(system),Node(nullptr), NextObject(nullptr) { } AABTreeNodeClass * Node; // partition node containing this object CullableClass * NextObject; // next object in the node diff --git a/Core/Libraries/Source/WWVegas/WWMath/castres.h b/Core/Libraries/Source/WWVegas/WWMath/castres.h index 69a577df6fe..dc45230c745 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/castres.h +++ b/Core/Libraries/Source/WWVegas/WWMath/castres.h @@ -56,7 +56,7 @@ struct CastResultStruct CastResultStruct(void) { Reset(); } void Reset(void) { StartBad = false; Fraction = 1.0f; Normal.Set(0,0,0); SurfaceType = 0; ComputeContactPoint = false; ContactPoint.Set(0,0,0); } - bool StartBad; // was the inital configuration interpenetrating something? + bool StartBad; // was the initial configuration interpenetrating something? float Fraction; // fraction of the move up until collision Vector3 Normal; // surface normal at the collision point uint32 SurfaceType; // surface type of polygon at collision point (see W3D_SURFACE_TYPES in w3d_file.h) diff --git a/Core/Libraries/Source/WWVegas/WWMath/colmathaabox.cpp b/Core/Libraries/Source/WWVegas/WWMath/colmathaabox.cpp index 03c23aaca5b..decb97274f4 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/colmathaabox.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/colmathaabox.cpp @@ -449,7 +449,7 @@ struct AABCollisionStruct Vector3::Subtract(move1,move0,&M); // move vector relative to stationary box0 } - bool StartBad; // Inital configuration is intersecting? + bool StartBad; // Initial configuration is intersecting? float MaxFrac; // Longest move allowed so far int AxisId; // Last separating axis int Side; // which side of the interval diff --git a/Core/Libraries/Source/WWVegas/WWMath/colmathaabtri.cpp b/Core/Libraries/Source/WWVegas/WWMath/colmathaabtri.cpp index 66e63353cd9..639f4925dc6 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/colmathaabtri.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/colmathaabtri.cpp @@ -146,7 +146,7 @@ struct BTCollisionStruct Vector3::Cross_Product(E[0],E[1],&N); } - bool StartBad; // Inital configuration is intersecting? + bool StartBad; // Initial configuration is intersecting? float MaxFrac; // Longest move allowed so far int AxisId; // Last separating axis @@ -860,8 +860,8 @@ bool CollisionMath::Collide struct AABTIntersectStruct { AABTIntersectStruct(void) : - Box(NULL), - Tri(NULL) + Box(nullptr), + Tri(nullptr) { } diff --git a/Core/Libraries/Source/WWVegas/WWMath/colmathline.cpp b/Core/Libraries/Source/WWVegas/WWMath/colmathline.cpp index c7a0ec0bf3d..c55036b636d 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/colmathline.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/colmathline.cpp @@ -48,7 +48,7 @@ /* ** Structure used in the line->box test. There was a lot of common code between the axis- -** aligned and oriented box tests so I package all of the truely relevant information into +** aligned and oriented box tests so I package all of the truly relevant information into ** this struct and pass it into a function local to this module. In the case of oriented ** boxes, the ray must be transformed into the box's coordinate system prior to the call ** and the normal is calculated slightly differently. diff --git a/Core/Libraries/Source/WWVegas/WWMath/colmathobbobb.cpp b/Core/Libraries/Source/WWVegas/WWMath/colmathobbobb.cpp index be254af2655..9af3fd1e007 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/colmathobbobb.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/colmathobbobb.cpp @@ -536,7 +536,7 @@ struct ObbCollisionStruct B[2].Set(box1.Basis[0][2],box1.Basis[1][2],box1.Basis[2][2]); } - bool StartBad; // Inital configuration is intersecting? + bool StartBad; // Initial configuration is intersecting? float MaxFrac; // Longest move allowed so far int AxisId; // Last separating axis int Side; // which side of the interval @@ -1314,7 +1314,7 @@ bool collide_obb_obb /* ** If our fraction is smaller, override the previous - ** values because our collision occured first. + ** values because our collision occurred first. */ if (context.MaxFrac < result->Fraction) { diff --git a/Core/Libraries/Source/WWVegas/WWMath/colmathobbtri.cpp b/Core/Libraries/Source/WWVegas/WWMath/colmathobbtri.cpp index 858c2aee20d..0fb50cce896 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/colmathobbtri.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/colmathobbtri.cpp @@ -167,7 +167,7 @@ struct BTCollisionStruct Vector3::Cross_Product(E[0],E[1],&N); } - bool StartBad; // Inital configuration is intersecting? + bool StartBad; // Initial configuration is intersecting? float MaxFrac; // Longest move allowed so far int AxisId; // Last separating axis int Point; // Index of the "closest" triangle point (or one of them) diff --git a/Core/Libraries/Source/WWVegas/WWMath/colmathsphere.cpp b/Core/Libraries/Source/WWVegas/WWMath/colmathsphere.cpp index c951728306d..1485c2efc19 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/colmathsphere.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/colmathsphere.cpp @@ -54,7 +54,7 @@ #include "wwdebug.h" -// Sphere Intersection fucntions. Does the sphere intersect the passed in object +// Sphere Intersection functions. Does the sphere intersect the passed in object /*********************************************************************************************** * CollisionMath::Intersection_Test -- Sphere - AAbox intersection * * * diff --git a/Core/Libraries/Source/WWVegas/WWMath/cullsys.cpp b/Core/Libraries/Source/WWVegas/WWMath/cullsys.cpp index ad0a8354794..74287a28877 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/cullsys.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/cullsys.cpp @@ -45,8 +45,8 @@ ** *************************************************************************/ CullableClass::CullableClass(void) : - CullLink(NULL), - NextCollected(NULL) + CullLink(nullptr), + NextCollected(nullptr) { CullBox.Init(Vector3(0,0,0),Vector3(1,1,1)); } @@ -56,7 +56,7 @@ CullableClass::~CullableClass(void) // the cull system that contains us is responsible for any culling link // so we better be out of it and it should have cleared our pointer before // we are deleted. - WWASSERT(CullLink == NULL); + WWASSERT(CullLink == nullptr); } void CullableClass::Set_Cull_Box(const AABoxClass & box,bool just_loaded) @@ -70,7 +70,7 @@ void CullableClass::Set_Cull_Box(const AABoxClass & box,bool just_loaded) // so you know you're in the right node of the culling system... if (!just_loaded) { CullSystemClass * sys = Get_Culling_System(); - if (sys != NULL) { + if (sys != nullptr) { sys->Update_Culling(this); } } @@ -88,7 +88,7 @@ CullSystemClass * CullableClass::Get_Culling_System(void) const if (CullLink) { return CullLink->Get_Culling_System(); } - return NULL; + return nullptr; } @@ -101,7 +101,7 @@ CullSystemClass * CullableClass::Get_Culling_System(void) const ** *************************************************************************/ CullSystemClass::CullSystemClass(void) : - CollectionHead(NULL) + CollectionHead(nullptr) { } @@ -118,10 +118,10 @@ CullableClass * CullSystemClass::Get_First_Collected_Object_Internal(void) CullableClass * CullSystemClass::Get_Next_Collected_Object_Internal(CullableClass * obj) { - if (obj != NULL) { + if (obj != nullptr) { return obj->NextCollected; } - return NULL; + return nullptr; } CullableClass * CullSystemClass::Peek_First_Collected_Object_Internal(void) @@ -131,20 +131,20 @@ CullableClass * CullSystemClass::Peek_First_Collected_Object_Internal(void) CullableClass * CullSystemClass::Peek_Next_Collected_Object_Internal(CullableClass * obj) { - if (obj != NULL) { + if (obj != nullptr) { return obj->NextCollected; } - return NULL; + return nullptr; } void CullSystemClass::Reset_Collection(void) { - CollectionHead = NULL; + CollectionHead = nullptr; } void CullSystemClass::Add_To_Collection(CullableClass * obj) { - WWASSERT(obj != NULL); + WWASSERT(obj != nullptr); obj->NextCollected = CollectionHead; CollectionHead = obj; } diff --git a/Core/Libraries/Source/WWVegas/WWMath/cullsys.h b/Core/Libraries/Source/WWVegas/WWMath/cullsys.h index 38a201d8ba4..0593de20441 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/cullsys.h +++ b/Core/Libraries/Source/WWVegas/WWMath/cullsys.h @@ -55,7 +55,7 @@ class CullLinkClass { public: WWINLINE CullLinkClass(CullSystemClass * system) { System = system; WWASSERT(System); } - virtual ~CullLinkClass(void) { WWASSERT(System == NULL); } + virtual ~CullLinkClass(void) { WWASSERT(System == nullptr); } WWINLINE void Set_Culling_System(CullSystemClass * sys) { System = sys; } WWINLINE CullSystemClass * Get_Culling_System(void) { return System; } @@ -106,7 +106,7 @@ class CullableClass : public RefCountClass ** Each object can be linked into various types of culling systems. ** Each culling system can use its own linkage data structure (derived ** from CullLinkClass) to keep track of the object. The CullData pointer - ** will point to one of the culling link objects and NULL + ** will point to one of the culling link objects and nullptr ** if its not in any system. */ CullLinkClass * CullLink; diff --git a/Core/Libraries/Source/WWVegas/WWMath/curve.cpp b/Core/Libraries/Source/WWVegas/WWMath/curve.cpp index 353fa6d22fe..1ad94705ae0 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/curve.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/curve.cpp @@ -142,10 +142,10 @@ void Curve3DClass::Get_Key(int i,Vector3 * set_point,float * set_t) { assert(i >= 0); assert(i < Keys.Count()); - if (set_point != NULL) { + if (set_point != nullptr) { *set_point = Keys[i].Point; } - if (set_t != NULL) { + if (set_t != nullptr) { *set_t = Keys[i].Time; } } @@ -385,13 +385,13 @@ void Curve1DClass::Get_Key(int i,float * set_point,float * set_t,unsigned int * { assert(i >= 0); assert(i < Keys.Count()); - if (set_point != NULL) { + if (set_point != nullptr) { *set_point = Keys[i].Point; } - if (set_t != NULL) { + if (set_t != nullptr) { *set_t = Keys[i].Time; } - if (extra != NULL) { + if (extra != nullptr) { *extra = Keys[i].Extra; } } diff --git a/Core/Libraries/Source/WWVegas/WWMath/curve.h b/Core/Libraries/Source/WWVegas/WWMath/curve.h index 6fdad67be3b..26dab2eafc8 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/curve.h +++ b/Core/Libraries/Source/WWVegas/WWMath/curve.h @@ -66,7 +66,7 @@ class Curve3DClass : public PersistClass float Get_Start_Time(void); float Get_End_Time(void); - // persistant object support + // persistent object support virtual bool Save (ChunkSaveClass &csave); virtual bool Load (ChunkLoadClass &cload); @@ -93,7 +93,7 @@ class LinearCurve3DClass : public Curve3DClass public: virtual void Evaluate(float time,Vector3 * set_val); - // persistant object support + // persistent object support virtual const PersistFactoryClass & Get_Factory(void) const; virtual bool Save(ChunkSaveClass &csave); virtual bool Load(ChunkLoadClass &cload); @@ -116,7 +116,7 @@ class Curve1DClass : public PersistClass virtual bool Is_Looping(void); virtual void Set_Looping(bool onoff); virtual int Key_Count(void); - virtual void Get_Key(int i,float * set_point,float * set_t,unsigned int * extra=NULL); + virtual void Get_Key(int i,float * set_point,float * set_t,unsigned int * extra=nullptr); virtual void Set_Key(int i,float point,unsigned int extra=0); virtual int Add_Key(float point,float t,unsigned int extra=0); virtual void Remove_Key(int i); @@ -124,7 +124,7 @@ class Curve1DClass : public PersistClass float Get_Start_Time(void); float Get_End_Time(void); - // persistant object support + // persistent object support virtual bool Save (ChunkSaveClass &csave); virtual bool Load (ChunkLoadClass &cload); @@ -152,7 +152,7 @@ class LinearCurve1DClass : public Curve1DClass public: virtual void Evaluate(float time,float * set_val); - // persistant object support + // persistent object support virtual const PersistFactoryClass & Get_Factory(void) const; virtual bool Save(ChunkSaveClass &csave); virtual bool Load(ChunkLoadClass &cload); diff --git a/Core/Libraries/Source/WWVegas/WWMath/frustum.h b/Core/Libraries/Source/WWVegas/WWMath/frustum.h index 0d46f6a692d..685f79407e1 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/frustum.h +++ b/Core/Libraries/Source/WWVegas/WWMath/frustum.h @@ -55,7 +55,21 @@ class FrustumClass public: Matrix3D CameraTransform; + // Plane 0: NEAR + // Plane 1: bottom + // Plane 2: right + // Plane 3: top + // Plane 4: left + // Plane 5: FAR PlaneClass Planes[6]; + // Corner 0: NEAR upper left + // Corner 1: NEAR upper right + // Corner 2: NEAR lower left + // Corner 3: NEAR lower right + // Corner 4: FAR upper left + // Corner 5: FAR upper right + // Corner 6: FAR lower left + // Corner 7: FAR lower right Vector3 Corners[8]; Vector3 BoundMin; Vector3 BoundMax; diff --git a/Core/Libraries/Source/WWVegas/WWMath/gridcull.cpp b/Core/Libraries/Source/WWVegas/WWMath/gridcull.cpp index b4289656c6f..9f8cf831c87 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/gridcull.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/gridcull.cpp @@ -116,8 +116,8 @@ static inline CullableClass * get_next_object(CullableClass * obj) GridLinkClass::GridLinkClass(GridCullSystemClass * system) : CullLinkClass(system), GridAddress(-1), - Prev(NULL), - Next(NULL) + Prev(nullptr), + Next(nullptr) { } @@ -153,8 +153,8 @@ GridCullSystemClass::GridCullSystemClass(void) : MaxObjExtent(15), Origin(-100,-100,-100), CellDim(10,10,10), - Cells(NULL), - NoGridList(NULL), + Cells(nullptr), + NoGridList(nullptr), ObjCount(0), TerminationCellCount(TERMINATION_CELL_COUNT) { @@ -179,7 +179,7 @@ GridCullSystemClass::GridCullSystemClass(void) : GridCullSystemClass::~GridCullSystemClass(void) { delete Cells; - Cells = NULL; + Cells = nullptr; } @@ -477,7 +477,7 @@ void GridCullSystemClass::Re_Partition(const Vector3 & input_min,const Vector3 & */ CullableClass * obj; for ( obj = Get_First_Collected_Object_Internal(); - obj != NULL; + obj != nullptr; obj = Get_Next_Collected_Object_Internal(obj)) { link_object(obj); @@ -639,7 +639,7 @@ void GridCullSystemClass::Load(ChunkLoadClass & cload) */ CullableClass * obj; for ( obj = Get_First_Collected_Object_Internal(); - obj != NULL; + obj != nullptr; obj = Get_Next_Collected_Object_Internal(obj)) { link_object(obj); @@ -749,7 +749,7 @@ const GridCullSystemClass::StatsStruct & GridCullSystemClass::Get_Statistics(voi void GridCullSystemClass::Add_Object_Internal(CullableClass * obj) { WWASSERT(obj); - WWASSERT(obj->Get_Culling_System() == NULL); + WWASSERT(obj->Get_Culling_System() == nullptr); GridLinkClass * link = new GridLinkClass(this); obj->Set_Cull_Link(link); @@ -779,9 +779,9 @@ void GridCullSystemClass::Remove_Object_Internal(CullableClass * obj) GridLinkClass * link = (GridLinkClass *)obj->Get_Cull_Link(); unlink_object(obj); - link->Set_Culling_System(NULL); + link->Set_Culling_System(nullptr); delete link; - obj->Set_Cull_Link(NULL); + obj->Set_Cull_Link(nullptr); ObjCount--; obj->Release_Ref(); @@ -816,7 +816,7 @@ void GridCullSystemClass::link_object(CullableClass * obj,int address) WWASSERT(obj); WWASSERT(obj->Get_Culling_System() == this); GridLinkClass * link = (GridLinkClass *)obj->Get_Cull_Link(); - WWASSERT(link != NULL); + WWASSERT(link != nullptr); /* ** if obj cannot be inserted into the grid, add it to the NoGridList @@ -886,11 +886,11 @@ void GridCullSystemClass::link_object_to_list(CullableClass ** head,CullableClas ** Insert this object as the new head of the list. */ link->Next = *head; - link->Prev = NULL; + link->Prev = nullptr; - if (link->Next != NULL) { + if (link->Next != nullptr) { GridLinkClass * next_link = (GridLinkClass *)link->Next->Get_Cull_Link(); - WWASSERT(next_link != NULL); + WWASSERT(next_link != nullptr); next_link->Prev = obj; } @@ -952,8 +952,8 @@ void GridCullSystemClass::unlink_object_from_list(CullableClass ** head,Cullable next_link->Prev = link->Prev; } - link->Prev = NULL; - link->Next = NULL; + link->Prev = nullptr; + link->Next = nullptr; } @@ -965,7 +965,7 @@ void GridCullSystemClass::unlink_object_from_list(CullableClass ** head,Cullable *************************************************************************/ void GridCullSystemClass::collect_objects_in_leaf(const Vector3 & point,CullableClass * head) { - if (head != NULL) { + if (head != nullptr) { GridListIterator it(head); for (;!it.Is_Done(); it.Next()) { CullableClass * obj = it.Peek_Obj(); @@ -978,7 +978,7 @@ void GridCullSystemClass::collect_objects_in_leaf(const Vector3 & point,Cullable void GridCullSystemClass::collect_objects_in_leaf(const AABoxClass & box,CullableClass * head) { - if (head != NULL) { + if (head != nullptr) { GridListIterator it(head); for (;!it.Is_Done(); it.Next()) { CullableClass * obj = it.Peek_Obj(); @@ -991,7 +991,7 @@ void GridCullSystemClass::collect_objects_in_leaf(const AABoxClass & box,Cullabl void GridCullSystemClass::collect_objects_in_leaf(const OBBoxClass & obbox,CullableClass * head) { - if (head != NULL) { + if (head != nullptr) { GridListIterator it(head); for (;!it.Is_Done(); it.Next()) { CullableClass * obj = it.Peek_Obj(); @@ -1004,7 +1004,7 @@ void GridCullSystemClass::collect_objects_in_leaf(const OBBoxClass & obbox,Culla void GridCullSystemClass::collect_objects_in_leaf(const FrustumClass & frustum,CullableClass * head) { - if (head != NULL) { + if (head != nullptr) { GridListIterator it(head); for (;!it.Is_Done(); it.Next()) { CullableClass * obj = it.Peek_Obj(); diff --git a/Core/Libraries/Source/WWVegas/WWMath/gridcull.h b/Core/Libraries/Source/WWVegas/WWMath/gridcull.h index 18d9d9f8865..21f04907c12 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/gridcull.h +++ b/Core/Libraries/Source/WWVegas/WWMath/gridcull.h @@ -270,7 +270,7 @@ class GridListIterator void First(void) { CurObj = Head; } void Next(void) { if (CurObj) { CurObj = ((GridLinkClass *)CurObj->Get_Cull_Link())->Next; } } void Prev(void) { if (CurObj) { CurObj = ((GridLinkClass *)CurObj->Get_Cull_Link())->Prev; } } - bool Is_Done(void) { return (CurObj == NULL); } + bool Is_Done(void) { return (CurObj == nullptr); } CullableClass * Get_Obj(void) { if (CurObj) { CurObj->Add_Ref(); } return CurObj; } CullableClass * Peek_Obj(void) { return CurObj; } @@ -412,7 +412,7 @@ WWINLINE int GridCullSystemClass::total_cell_count(void) *=============================================================================================*/ WWINLINE void GridCullSystemClass::compute_box(int i,int j,int k,AABoxClass * set_box) { - WWASSERT(set_box != NULL); + WWASSERT(set_box != nullptr); WWASSERT((i >= 0) && (j >= 0) && (k >= 0)); WWASSERT((i < CellCount[0]) && (j < CellCount[1]) && (k < CellCount[2])); @@ -444,7 +444,7 @@ WWINLINE void GridCullSystemClass::compute_box(int i,int j,int k,AABoxClass * se *=============================================================================================*/ WWINLINE void GridCullSystemClass::compute_box(const GridCullSystemClass::VolumeStruct & vol, AABoxClass * set_box) { - WWASSERT(set_box != NULL); + WWASSERT(set_box != nullptr); WWASSERT((vol.Min[0] >= 0) && (vol.Min[1] >= 0) && (vol.Min[2] >= 0)); WWASSERT((vol.Max[0] <= CellCount[0]) && (vol.Max[1] <= CellCount[1]) && (vol.Max[2] <= CellCount[2])); diff --git a/Core/Libraries/Source/WWVegas/WWMath/lineseg.cpp b/Core/Libraries/Source/WWVegas/WWMath/lineseg.cpp index e5f4150d6ea..13ad6c35e17 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/lineseg.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/lineseg.cpp @@ -215,11 +215,11 @@ LineSegClass::Find_Intersection // // Return the fractions if they caller wants them // - if (fraction1 != NULL) { + if (fraction1 != nullptr) { (*fraction1) = length1 / Length; } - if (fraction2 != NULL) { + if (fraction2 != nullptr) { (*fraction2) = length2 / Length; } diff --git a/Core/Libraries/Source/WWVegas/WWMath/lookuptable.cpp b/Core/Libraries/Source/WWVegas/WWMath/lookuptable.cpp index 139c782cfd9..72eb2fa9891 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/lookuptable.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/lookuptable.cpp @@ -83,8 +83,8 @@ void LookupTableClass::Init(const char * name,Curve1DClass * curve) Name = name; // Store the min and max input values for the table - curve->Get_Key(0,NULL,&MinInputValue,NULL); - curve->Get_Key(curve->Key_Count()-1,NULL,&MaxInputValue,NULL); + curve->Get_Key(0,nullptr,&MinInputValue,nullptr); + curve->Get_Key(curve->Key_Count()-1,nullptr,&MaxInputValue,nullptr); OOMaxMinusMin = 1.0f / (MaxInputValue - MinInputValue); // Sample the curve and store the output values @@ -125,7 +125,7 @@ void LookupTableMgrClass::Shutdown(void) void LookupTableMgrClass::Reset(void) { - while (Tables.Peek_Head() != NULL) { + while (Tables.Peek_Head() != nullptr) { Tables.Release_Head(); } } @@ -151,7 +151,7 @@ LookupTableClass * LookupTableMgrClass::Get_Table(const char * name,bool try_to_ } // otherwise we can try to load it. - LookupTableClass * new_table = NULL; + LookupTableClass * new_table = nullptr; if (try_to_load) { FileClass * file = _TheFileFactory->Get_File(name); @@ -159,9 +159,9 @@ LookupTableClass * LookupTableMgrClass::Get_Table(const char * name,bool try_to_ ChunkLoadClass cload(file); - Curve1DClass * curve = NULL; + Curve1DClass * curve = nullptr; Load_Table_Desc(cload,&curve); - if (curve != NULL) { + if (curve != nullptr) { new_table = NEW_REF(LookupTableClass,()); new_table->Init(name,curve); Add_Table(new_table); @@ -206,7 +206,7 @@ void LookupTableMgrClass::Load_Table_Desc Vector2 * set_max_corner ) { - *curve_ptr = NULL; + *curve_ptr = nullptr; PersistFactoryClass * factory; float xmin,xmax; @@ -218,8 +218,8 @@ void LookupTableMgrClass::Load_Table_Desc case LOOKUPTABLE_CHUNK_CURVE: cload.Open_Chunk(); factory = SaveLoadSystemClass::Find_Persist_Factory(cload.Cur_Chunk_ID()); - WWASSERT(factory != NULL); - if (factory != NULL) { + WWASSERT(factory != nullptr); + if (factory != nullptr) { *curve_ptr = (Curve1DClass *)factory->Load(cload); } cload.Close_Chunk(); @@ -238,10 +238,10 @@ void LookupTableMgrClass::Load_Table_Desc cload.Close_Chunk(); } - if (set_min_corner != NULL) { + if (set_min_corner != nullptr) { set_min_corner->Set(xmin,ymin); } - if (set_max_corner != NULL) { + if (set_max_corner != nullptr) { set_max_corner->Set(xmax,ymax); } } diff --git a/Core/Libraries/Source/WWVegas/WWMath/lookuptable.h b/Core/Libraries/Source/WWVegas/WWMath/lookuptable.h index c37923f4d7e..650095aff4e 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/lookuptable.h +++ b/Core/Libraries/Source/WWVegas/WWMath/lookuptable.h @@ -143,8 +143,8 @@ class LookupTableMgrClass static void Load_Table_Desc( ChunkLoadClass & cload, Curve1DClass ** curve_ptr, - Vector2 * set_min = NULL, - Vector2 * set_max = NULL ); + Vector2 * set_min = nullptr, + Vector2 * set_max = nullptr ); static void Reset(void); diff --git a/Core/Libraries/Source/WWVegas/WWMath/matrix3.cpp b/Core/Libraries/Source/WWVegas/WWMath/matrix3.cpp index 26de94bb921..40a3ea4d14b 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/matrix3.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/matrix3.cpp @@ -290,7 +290,7 @@ void Matrix3x3::Symmetric_Eigen_Solve(void) void Matrix3x3::Multiply(const Matrix3x3 & A,const Matrix3x3 & B,Matrix3x3 * set_res) { Matrix3x3 tmp; - Matrix3x3 * Aptr; + const Matrix3x3 * Aptr; float tmp1,tmp2,tmp3; // Check for aliased parameters, copy the 'A' matrix into a temporary if the @@ -300,7 +300,7 @@ void Matrix3x3::Multiply(const Matrix3x3 & A,const Matrix3x3 & B,Matrix3x3 * set tmp = A; Aptr = &tmp; } else { - Aptr = (Matrix3x3 *)&A; + Aptr = &A; } tmp1 = B[0][0]; diff --git a/Core/Libraries/Source/WWVegas/WWMath/matrix3d.cpp b/Core/Libraries/Source/WWVegas/WWMath/matrix3d.cpp index e3c3c46c105..dd2009a659d 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/matrix3d.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/matrix3d.cpp @@ -64,7 +64,10 @@ #include "matrix3.h" #include "matrix4.h" #include "quat.h" -#include "d3dx8math.h" + +#include "WWLib/win.h" +#include +#include // some static matrices which are sometimes useful const Matrix3D Matrix3D::Identity @@ -509,32 +512,76 @@ void Matrix3D::Obj_Look_At(const Vector3 &p,const Vector3 &t,float roll) * * * HISTORY: * * 8/7/98 GTH : Created. * + * 01/03/2026 TheSuperHackers : Implemented. * *=============================================================================================*/ -void Matrix3D::Get_Inverse(Matrix3D & inv) const +Matrix3D * Matrix3D::Get_Inverse(Matrix3D * out, float * detOut, const Matrix3D * m) { - // TODO: Implement the general purpose inverse function here (once we need it :-) - //Get_Orthogonal_Inverse(inv); + // Read linear + translation elements + + const float m00 = m->Row[0][0], m01 = m->Row[1][0], m02 = m->Row[2][0]; + const float m10 = m->Row[0][1], m11 = m->Row[1][1], m12 = m->Row[2][1]; + const float m20 = m->Row[0][2], m21 = m->Row[1][2], m22 = m->Row[2][2]; + + const float tx = m->Row[0][3]; + const float ty = m->Row[1][3]; + const float tz = m->Row[2][3]; + + // Compute 2x2 sub-determinants (minors) for cofactor expansion + // These correspond to minors of the 4x4 extended matrix (with last row 0,0,0,1) + + const float s0 = m00 * m11 - m10 * m01; + const float s1 = m00 * m12 - m10 * m02; + const float s3 = m01 * m12 - m11 * m02; + + const float c5 = m22; + const float c4 = m21; + const float c2 = m20; + + const float c3 = m21 * tz - ty * m22; + const float c1 = m20 * tz - tx * m22; + const float c0 = m20 * ty - tx * m21; + + // Compute determinant (matches 4x4 extended determinant) + + const float det = s0 * c5 - s1 * c4 + s3 * c2; + + if (detOut) + *detOut = det; + + if (fabsf(det) < 1e-8f) + return NULL; + + const float invDet = 1.0f / det; + + // Compute inverse using adjugate / determinant + // Adjugate = transpose of cofactor matrix + // Multiplies each cofactor by 1/det to get the inverse + // Writes in column-major order to match engine conventions + + out->Row[0][0] = ( m11 * c5 - m12 * c4) * invDet; + out->Row[1][0] = (-m01 * c5 + m02 * c4) * invDet; + out->Row[2][0] = ( s3) * invDet; - Matrix4x4 mat4(*this); - Matrix4x4 mat4Inv; + out->Row[0][1] = (-m10 * c5 + m12 * c2) * invDet; + out->Row[1][1] = ( m00 * c5 - m02 * c2) * invDet; + out->Row[2][1] = ( -s1) * invDet; - float det; - D3DXMatrixInverse((D3DXMATRIX *)&mat4Inv, &det, (D3DXMATRIX*)&mat4); + out->Row[0][2] = ( m10 * c4 - m11 * c2) * invDet; + out->Row[1][2] = (-m00 * c4 + m01 * c2) * invDet; + out->Row[2][2] = ( s0) * invDet; - inv.Row[0][0]=mat4Inv[0][0]; - inv.Row[0][1]=mat4Inv[0][1]; - inv.Row[0][2]=mat4Inv[0][2]; - inv.Row[0][3]=mat4Inv[0][3]; + // Translation (still from 4x4 cofactors) - inv.Row[1][0]=mat4Inv[1][0]; - inv.Row[1][1]=mat4Inv[1][1]; - inv.Row[1][2]=mat4Inv[1][2]; - inv.Row[1][3]=mat4Inv[1][3]; + out->Row[0][3] = (-m10 * c3 + m11 * c1 - m12 * c0) * invDet; + out->Row[1][3] = ( m00 * c3 - m01 * c1 + m02 * c0) * invDet; + out->Row[2][3] = (-tx * s3 + ty * s1 - tz * s0) * invDet; - inv.Row[2][0]=mat4Inv[2][0]; - inv.Row[2][1]=mat4Inv[2][1]; - inv.Row[2][2]=mat4Inv[2][2]; - inv.Row[2][3]=mat4Inv[2][3]; + return out; +} + +void Matrix3D::Get_Inverse(Matrix3D & inv) const +{ + Get_Inverse(&inv, NULL, this); } /*********************************************************************************************** @@ -638,10 +685,10 @@ void Matrix3D::Copy_3x3_Matrix(float matrix[3][3]) void Matrix3D::Multiply(const Matrix3D & A,const Matrix3D & B,Matrix3D * set_res) { - assert(set_res != NULL); + assert(set_res != nullptr); Matrix3D tmp; - Matrix3D * Aptr; + const Matrix3D * Aptr; // Check for aliased parameters, copy the 'A' matrix into a temporary if the // result is going into 'A'. (in this case, this function is no better than @@ -650,7 +697,7 @@ void Matrix3D::Multiply(const Matrix3D & A,const Matrix3D & B,Matrix3D * set_res tmp = A; Aptr = &tmp; } else { - Aptr = (Matrix3D *)&A; + Aptr = &A; } #ifdef ALLOW_TEMPORARIES @@ -695,7 +742,7 @@ void Matrix3D::Multiply(const Matrix3D & A,const Matrix3D & B,Matrix3D * set_res #if 0 void Matrix3D::Multiply(const Matrix3D & A,const Matrix3D & B,Matrix3D * set_res) { - assert(set_res != NULL); + assert(set_res != nullptr); float tmp[12]; // Check for aliased parameters, copy the 'A' matrix into a temporary if the @@ -1239,3 +1286,41 @@ bool Matrix3D::Solve_Linear_System(Matrix3D & system) return true; } + + +void To_D3DMATRIX(_D3DMATRIX& dxm, const Matrix3D& m) +{ + dxm.m[0][0] = m[0][0]; + dxm.m[0][1] = m[1][0]; + dxm.m[0][2] = m[2][0]; + dxm.m[0][3] = 0.0f; + + dxm.m[1][0] = m[0][1]; + dxm.m[1][1] = m[1][1]; + dxm.m[1][2] = m[2][1]; + dxm.m[1][3] = 0.0f; + + dxm.m[2][0] = m[0][2]; + dxm.m[2][1] = m[1][2]; + dxm.m[2][2] = m[2][2]; + dxm.m[2][3] = 0.0f; + + dxm.m[3][0] = m[0][3]; + dxm.m[3][1] = m[1][3]; + dxm.m[3][2] = m[2][3]; + dxm.m[3][3] = 1.0f; +} + +_D3DMATRIX To_D3DMATRIX(const Matrix3D& m) +{ + _D3DMATRIX dxm; + To_D3DMATRIX(dxm, m); + return dxm; +} + +D3DXMATRIX To_D3DXMATRIX(const Matrix3D& m) +{ + D3DXMATRIX dxm; + To_D3DMATRIX(dxm, m); + return dxm; +} diff --git a/Core/Libraries/Source/WWVegas/WWMath/matrix3d.h b/Core/Libraries/Source/WWVegas/WWMath/matrix3d.h index c849c8dab5c..6aa42037091 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/matrix3d.h +++ b/Core/Libraries/Source/WWVegas/WWMath/matrix3d.h @@ -115,7 +115,7 @@ class Quaternion; I use column-vectors so normally transformations are post-multiplied and camera transformations should be pre-multiplied. The methods of this class called Translate, Rotate_X, etc. all perform post-multiplication - with the current matix. These methods (Translate, Rotate_X, etc) also + with the current matrix. These methods (Translate, Rotate_X, etc) also have been hand-coded to only perform the necessary arithmetic. The * operator can be used for general purpose matrix multiplication or to transform a vector by a matrix. @@ -231,7 +231,7 @@ class Matrix3D // These functions will give you the approximate amount that the // matrix has been rotated about a given axis. These functions - // cannot be used to re-build a matrx. Use the EulerAnglesClass + // cannot be used to re-build a matrix. Use the EulerAnglesClass // to convert a matrix into a set of three Euler angles. float Get_X_Rotation(void) const; float Get_Y_Rotation(void) const; @@ -306,12 +306,9 @@ class Matrix3D WWINLINE void Get_Z_Vector(Vector3 * set_z) const { set_z->Set(Row[0][2], Row[1][2], Row[2][2]); } // Get the inverse of the matrix. - // TODO: currently the "intended-to-be" general inverse function just calls - // the special case Orthogonal inverse functions. Also, when we implement - // general case, check where we were using Get_Inverse since usually it should - // be changed to Get_Orthogonal_Inverse... - void Get_Inverse(Matrix3D & set_inverse) const; - void Get_Orthogonal_Inverse(Matrix3D & set_inverse) const; + static Matrix3D * Get_Inverse(Matrix3D * out, float * detOut, const Matrix3D * m); + void Get_Inverse(Matrix3D & inv) const; + void Get_Orthogonal_Inverse(Matrix3D & inv) const; // used for importing SurRender matrices void Copy_3x3_Matrix(float matrix[3][3]); @@ -1810,3 +1807,15 @@ class DynamicMatrix3D : public W3DMPO public: Matrix3D Mat; }; + + +// TheSuperHackers @info Always convert Matrix3D to D3DMATRIX or vice versa with the conversion functions below. +// Reason being, D3DMATRIX is row-major, and Matrix3D is column-major and therefore copying one matrix to the +// other will always require a transpose. + +struct _D3DMATRIX; +struct D3DXMATRIX; + +extern void To_D3DMATRIX(_D3DMATRIX& dxm, const Matrix3D& m); +extern _D3DMATRIX To_D3DMATRIX(const Matrix3D& m); +extern D3DXMATRIX To_D3DXMATRIX(const Matrix3D& m); diff --git a/Core/Libraries/Source/WWVegas/WWMath/matrix4.cpp b/Core/Libraries/Source/WWVegas/WWMath/matrix4.cpp index 69a0206e51b..0b489a40c72 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/matrix4.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/matrix4.cpp @@ -43,6 +43,10 @@ #include "matrix4.h" #include +#include "WWLib/win.h" +#include +#include + /*********************************************************************************************** * Matrix4x4::Multiply -- Multiply two Matrix4x4's together * * * @@ -195,3 +199,70 @@ int operator != (const Matrix4x4 & a, const Matrix4x4 & b) return (!(a == b)); } + +void To_D3DMATRIX(_D3DMATRIX& dxm, const Matrix4x4& m) +{ + dxm.m[0][0] = m[0][0]; + dxm.m[0][1] = m[1][0]; + dxm.m[0][2] = m[2][0]; + dxm.m[0][3] = m[3][0]; + + dxm.m[1][0] = m[0][1]; + dxm.m[1][1] = m[1][1]; + dxm.m[1][2] = m[2][1]; + dxm.m[1][3] = m[3][1]; + + dxm.m[2][0] = m[0][2]; + dxm.m[2][1] = m[1][2]; + dxm.m[2][2] = m[2][2]; + dxm.m[2][3] = m[3][2]; + + dxm.m[3][0] = m[0][3]; + dxm.m[3][1] = m[1][3]; + dxm.m[3][2] = m[2][3]; + dxm.m[3][3] = m[3][3]; +} + +_D3DMATRIX To_D3DMATRIX(const Matrix4x4& m) +{ + _D3DMATRIX dxm; + To_D3DMATRIX(dxm, m); + return dxm; +} + +D3DXMATRIX To_D3DXMATRIX(const Matrix4x4& m) +{ + D3DXMATRIX dxm; + To_D3DMATRIX(dxm, m); + return dxm; +} + +void To_Matrix4x4(Matrix4x4& m, const _D3DMATRIX& dxm) +{ + m[0][0] = dxm.m[0][0]; + m[0][1] = dxm.m[1][0]; + m[0][2] = dxm.m[2][0]; + m[0][3] = dxm.m[3][0]; + + m[1][0] = dxm.m[0][1]; + m[1][1] = dxm.m[1][1]; + m[1][2] = dxm.m[2][1]; + m[1][3] = dxm.m[3][1]; + + m[2][0] = dxm.m[0][2]; + m[2][1] = dxm.m[1][2]; + m[2][2] = dxm.m[2][2]; + m[2][3] = dxm.m[3][2]; + + m[3][0] = dxm.m[0][3]; + m[3][1] = dxm.m[1][3]; + m[3][2] = dxm.m[2][3]; + m[3][3] = dxm.m[3][3]; +} + +Matrix4x4 To_Matrix4x4(const _D3DMATRIX& dxm) +{ + Matrix4x4 m; + To_Matrix4x4(m, dxm); + return m; +} diff --git a/Core/Libraries/Source/WWVegas/WWMath/matrix4.h b/Core/Libraries/Source/WWVegas/WWMath/matrix4.h index 81211850c79..33e151363a3 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/matrix4.h +++ b/Core/Libraries/Source/WWVegas/WWMath/matrix4.h @@ -110,6 +110,7 @@ class Matrix4x4 ** Transpose and Inverse */ WWINLINE Matrix4x4 Transpose(void) const; + static WWINLINE Matrix4x4* Inverse(Matrix4x4* out, float* detOut, const Matrix4x4* m); WWINLINE Matrix4x4 Inverse(void) const; /* @@ -520,7 +521,7 @@ WWINLINE Matrix4x4 Matrix4x4::Transpose() const } /*********************************************************************************************** - * Matrix4x4::Inverse -- returns the inverse of the matrix * + * Matrix4x4::Inverse -- returns the inverse of the matrix * * * * INPUT: * * * @@ -530,46 +531,87 @@ WWINLINE Matrix4x4 Matrix4x4::Transpose() const * * * HISTORY: * * 06/02/1997 GH : Created. * + * 01/03/2026 TheSuperHackers : Implemented. * *=============================================================================================*/ -WWINLINE Matrix4x4 Matrix4x4::Inverse() const // Gauss-Jordan elimination with partial pivoting -{ - WWASSERT_PRINT(0,"Matrix4x4::Inverse does not work, re-implement!"); - - Matrix4x4 a(*this); // As a evolves from original mat into identity - Matrix4x4 b(true); // b evolves from identity into inverse(a) - int i, j, i1; - - // Loop over cols of a from left to right, eliminating above and below diagonal - for (j=0; j<4; j++) { - - // Find largest pivot in column j among rows j..3 - i1 = j; - for (i=j+1; i<4; i++) { - if (WWMath::Fabs(a[i][j]) > WWMath::Fabs(a[i1][j])) { - i1 = i; - } - } - - // Swap rows i1 and j in a and b to put pivot on diagonal - Swap(a.Row[i1], a.Row[j]); - Swap(b.Row[i1], b.Row[j]); - - // Scale row j to have a unit diagonal - if (a[j][j]==0.) { - //ALGEBRA_ERROR("Matrix4x4::inverse: singular matrix; can't invert\n"); - } - b.Row[j] /= a.Row[j][j]; - a.Row[j] /= a.Row[j][j]; - - // Eliminate off-diagonal elems in col j of a, doing identical ops to b - for (i=0; i<4; i++) { - if (i != j) { - b.Row[i] -= a[i][j] * b.Row[j]; - a.Row[i] -= a[i][j] * a.Row[j]; - } - } - } - return b; +WWINLINE Matrix4x4* Matrix4x4::Inverse(Matrix4x4* out, float* detOut, const Matrix4x4* m) +{ + // Read matrix elements + // Uses a column-major, column-vector convention (matches D3DXMatrixInverse) + // Row[i][j] stores the element at row i, column j. + + const float m00 = m->Row[0][0], m01 = m->Row[1][0], m02 = m->Row[2][0], m03 = m->Row[3][0]; + const float m10 = m->Row[0][1], m11 = m->Row[1][1], m12 = m->Row[2][1], m13 = m->Row[3][1]; + const float m20 = m->Row[0][2], m21 = m->Row[1][2], m22 = m->Row[2][2], m23 = m->Row[3][2]; + const float m30 = m->Row[0][3], m31 = m->Row[1][3], m32 = m->Row[2][3], m33 = m->Row[3][3]; + + // Compute 2x2 determinants (minors) used for cofactors + // s0..s5: sub-determinants of the upper-left 2x2 blocks, used in cofactor expansion + + const float s0 = m00 * m11 - m10 * m01; + const float s1 = m00 * m12 - m10 * m02; + const float s2 = m00 * m13 - m10 * m03; + const float s3 = m01 * m12 - m11 * m02; + const float s4 = m01 * m13 - m11 * m03; + const float s5 = m02 * m13 - m12 * m03; + + // c0..c5: sub-determinants of the lower-right 2x2 blocks, used in cofactor expansion + + const float c5 = m22 * m33 - m32 * m23; + const float c4 = m21 * m33 - m31 * m23; + const float c3 = m21 * m32 - m31 * m22; + const float c2 = m20 * m33 - m30 * m23; + const float c1 = m20 * m32 - m30 * m22; + const float c0 = m20 * m31 - m30 * m21; + + // Compute determinant of 4x4 matrix + // Using cofactor expansion along the first row + // If det is near zero, the matrix is singular and cannot be inverted + + const float det = + s0 * c5 - s1 * c4 + s2 * c3 + + s3 * c2 - s4 * c1 + s5 * c0; + + if (detOut) + *detOut = det; + + if (fabsf(det) < 1e-8f) + return NULL; + + const float invDet = 1.0f / det; + + // Compute inverse matrix using adjugate / determinant + // The adjugate matrix is the transpose of the cofactor matrix + // Multiplies each cofactor by 1/det to get the inverse + // Writes in column-major order to match engine conventions + + out->Row[0][0] = ( m11 * c5 - m12 * c4 + m13 * c3) * invDet; + out->Row[1][0] = (-m01 * c5 + m02 * c4 - m03 * c3) * invDet; + out->Row[2][0] = ( m31 * s5 - m32 * s4 + m33 * s3) * invDet; + out->Row[3][0] = (-m21 * s5 + m22 * s4 - m23 * s3) * invDet; + + out->Row[0][1] = (-m10 * c5 + m12 * c2 - m13 * c1) * invDet; + out->Row[1][1] = ( m00 * c5 - m02 * c2 + m03 * c1) * invDet; + out->Row[2][1] = (-m30 * s5 + m32 * s2 - m33 * s1) * invDet; + out->Row[3][1] = ( m20 * s5 - m22 * s2 + m23 * s1) * invDet; + + out->Row[0][2] = ( m10 * c4 - m11 * c2 + m13 * c0) * invDet; + out->Row[1][2] = (-m00 * c4 + m01 * c2 - m03 * c0) * invDet; + out->Row[2][2] = ( m30 * s4 - m31 * s2 + m33 * s0) * invDet; + out->Row[3][2] = (-m20 * s4 + m21 * s2 - m23 * s0) * invDet; + + out->Row[0][3] = (-m10 * c3 + m11 * c1 - m12 * c0) * invDet; + out->Row[1][3] = ( m00 * c3 - m01 * c1 + m02 * c0) * invDet; + out->Row[2][3] = (-m30 * s3 + m31 * s1 - m32 * s0) * invDet; + out->Row[3][3] = ( m20 * s3 - m21 * s1 + m22 * s0) * invDet; + + return out; +} + +WWINLINE Matrix4x4 Matrix4x4::Inverse() const +{ + Matrix4x4 inv; + Inverse(&inv, NULL, this); + return inv; } /*********************************************************************************************** @@ -836,3 +878,18 @@ 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); } + + +// TheSuperHackers @info Always convert Matrix4x4 to D3DMATRIX or vice versa with the conversion functions below. +// Reason being, D3DMATRIX is row-major, and Matrix4x4 is column-major and therefore copying one matrix to the +// other will always require a transpose. + +struct _D3DMATRIX; +struct D3DXMATRIX; + +extern void To_D3DMATRIX(_D3DMATRIX& dxm, const Matrix4x4& m); +extern _D3DMATRIX To_D3DMATRIX(const Matrix4x4& m); +extern D3DXMATRIX To_D3DXMATRIX(const Matrix4x4& m); + +extern void To_Matrix4x4(Matrix4x4& m, const _D3DMATRIX& dxm); +extern Matrix4x4 To_Matrix4x4(const _D3DMATRIX& dxm); diff --git a/Core/Libraries/Source/WWVegas/WWMath/obbox.cpp b/Core/Libraries/Source/WWVegas/WWMath/obbox.cpp index e92787a274c..68aa7c48456 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/obbox.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/obbox.cpp @@ -37,7 +37,7 @@ * Functions: * * OBBoxClass::OBBoxClass -- Constructor that computes the box for a set of point * * OBBoxClass::Init_From_Box_Points -- Create an OBBox from 8 corners of a box * - * OBBoxClass::Init_Random -- initalize a random oriented box * + * OBBoxClass::Init_Random -- initialize a random oriented box * * Oriented_Boxes_Intersect_On_Axis -- test if two boxes intersect on given axis * * Oriented_Boxes_Intersect -- test if two oriented boxes intersect * * Oriented_Boxes_Collide_On_Axis -- test if two boxes collide on the given axis * @@ -277,7 +277,7 @@ void OBBoxClass::Init_From_Box_Points(Vector3 * points,int num) /*********************************************************************************************** - * OBBoxClass::Init_Random -- initalize a random oriented box * + * OBBoxClass::Init_Random -- initialize a random oriented box * * * * INPUT: * * * diff --git a/Core/Libraries/Source/WWVegas/WWMath/obbox.h b/Core/Libraries/Source/WWVegas/WWMath/obbox.h index 4e3f7f141ce..bd1c87a85d7 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/obbox.h +++ b/Core/Libraries/Source/WWVegas/WWMath/obbox.h @@ -211,7 +211,7 @@ inline void OBBoxClass::Compute_Point(float params[3],Vector3 * set_point) const *=============================================================================================*/ inline void OBBoxClass::Compute_Axis_Aligned_Extent(Vector3 * set_extent) const { - WWASSERT(set_extent != NULL); + WWASSERT(set_extent != nullptr); // x extent is the box projected onto the x axis set_extent->X = WWMath::Fabs(Extent[0] * Basis[0][0]) + diff --git a/Core/Libraries/Source/WWVegas/WWMath/ode.cpp b/Core/Libraries/Source/WWVegas/WWMath/ode.cpp index 4889b11c554..2d32f805c13 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/ode.cpp +++ b/Core/Libraries/Source/WWVegas/WWMath/ode.cpp @@ -71,7 +71,7 @@ static StateVectorClass _WorkVector7; *=============================================================================================*/ void IntegrationSystem::Euler_Integrate(ODESystemClass * sys, float dt) { - WWASSERT(sys != NULL); + WWASSERT(sys != nullptr); /* ** Get the current state @@ -90,7 +90,7 @@ void IntegrationSystem::Euler_Integrate(ODESystemClass * sys, float dt) ** Euler method, just evaluate the derivative, multiply ** by the time-step and add to the current state vector. */ - sys->Compute_Derivatives(0,NULL,&dydt); + sys->Compute_Derivatives(0,nullptr,&dydt); Y1.Resize(Y0.Count()); for (int i = 0; i < Y0.Count(); i++) { @@ -139,7 +139,7 @@ void IntegrationSystem::Midpoint_Integrate(ODESystemClass * sys,float dt) ** MidPoint method, first evaluate the derivitives of the ** state vector just like the Euler method. */ - sys->Compute_Derivatives(0.0f,NULL,&dydt); + sys->Compute_Derivatives(0.0f,nullptr,&dydt); /* ** Compute the midpoint between the Euler solution and @@ -208,7 +208,7 @@ void IntegrationSystem::Runge_Kutta_Integrate(ODESystemClass * sys,float dt) /* ** First Step */ - sys->Compute_Derivatives(0.0f,NULL,&dydt); + sys->Compute_Derivatives(0.0f,nullptr,&dydt); for (i=0; iCompute_Derivatives(0.0f,NULL,&dydt); + odesys->Compute_Derivatives(0.0f,nullptr,&dydt); for (i=0;iX = (a.X + (b.X - a.X)*t); set_result->Y = (a.Y + (b.Y - a.Y)*t); } diff --git a/Core/Libraries/Source/WWVegas/WWMath/vector3.h b/Core/Libraries/Source/WWVegas/WWMath/vector3.h index efd75af2fd3..595e42aa052 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/vector3.h +++ b/Core/Libraries/Source/WWVegas/WWMath/vector3.h @@ -36,7 +36,7 @@ * Scalar Division Operator -- Divide a vector by a scalar * * Scalar Multiply Operator -- Multiply a vector by a scalar * * Vector Addition Operator -- Add two vectors * - * Vector Subtraction Operator -- Subract two vectors * + * Vector Subtraction Operator -- Subtract two vectors * * Vector Inner Product Operator -- Compute the inner or dot product * * Vector Equality Operator -- Determine if two vectors are identical * * Vector Inequality Operator -- Determine if two vectors are identical * @@ -252,7 +252,7 @@ WWINLINE Vector3 operator + (const Vector3 &a,const Vector3 &b) } /************************************************************************** - * Vector Subtraction Operator -- Subract two vectors * + * Vector Subtraction Operator -- Subtract two vectors * * * * INPUT: * * * @@ -534,7 +534,7 @@ WWINLINE void Swap(Vector3 & a,Vector3 & b) *=============================================================================================*/ WWINLINE void Vector3::Lerp(const Vector3 & a, const Vector3 & b, float alpha,Vector3 * set_result) { - assert(set_result != NULL); + assert(set_result != nullptr); set_result->X = (a.X + (b.X - a.X)*alpha); set_result->Y = (a.Y + (b.Y - a.Y)*alpha); set_result->Z = (a.Z + (b.Z - a.Z)*alpha); @@ -564,7 +564,7 @@ WWINLINE Vector3 Vector3::Lerp(const Vector3 & a, const Vector3 & b, float alpha *=============================================================================================*/ WWINLINE void Vector3::Add(const Vector3 &a,const Vector3 &b,Vector3 * set_result) { - assert(set_result != NULL); + assert(set_result != nullptr); set_result->X = a.X + b.X; set_result->Y = a.Y + b.Y; set_result->Z = a.Z + b.Z; @@ -585,7 +585,7 @@ WWINLINE void Vector3::Add(const Vector3 &a,const Vector3 &b,Vector3 * set_resul *=============================================================================================*/ WWINLINE void Vector3::Subtract(const Vector3 &a,const Vector3 &b,Vector3 * set_result) { - assert(set_result != NULL); + assert(set_result != nullptr); set_result->X = a.X - b.X; set_result->Y = a.Y - b.Y; set_result->Z = a.Z - b.Z; diff --git a/Core/Libraries/Source/WWVegas/WWMath/vector4.h b/Core/Libraries/Source/WWVegas/WWMath/vector4.h index a512aaad300..0901e2b6c69 100644 --- a/Core/Libraries/Source/WWVegas/WWMath/vector4.h +++ b/Core/Libraries/Source/WWVegas/WWMath/vector4.h @@ -36,7 +36,7 @@ * Scalar Division Operator -- Divide a vector by a scalar * * Scalar Multiply Operator -- Multiply a vector by a scalar * * Vector Addition Operator -- Add two vectors * - * Vector Subtraction Operator -- Subract two vectors * + * Vector Subtraction Operator -- Subtract two vectors * * Vector Inner Product Operator -- Compute the inner or dot product * * Vector Equality Operator -- Detemine if two vectors are identical * * Vector Inequality Operator -- Detemine if two vectors are identical * @@ -179,7 +179,7 @@ WWINLINE Vector4 operator + (const Vector4 &a,const Vector4 &b) } /************************************************************************** - * Vector Subtraction Operator -- Subract two vectors * + * Vector Subtraction Operator -- Subtract two vectors * * * * INPUT: * * * diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/CMakeLists.txt b/Core/Libraries/Source/WWVegas/WWSaveLoad/CMakeLists.txt index bcb5af6819c..df618b0489a 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/CMakeLists.txt +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/CMakeLists.txt @@ -42,4 +42,5 @@ target_sources(core_wwsaveload PRIVATE ${WWSAVELOAD_SRC}) target_link_libraries(core_wwsaveload PRIVATE core_wwcommon + corei_always ) diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.cpp index eb0def89256..9d556877719 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.cpp +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactory.cpp @@ -44,8 +44,8 @@ // ///////////////////////////////////////////////////////// DefinitionFactoryClass::DefinitionFactoryClass (void) - : m_NextFactory (0), - m_PrevFactory (0) + : m_NextFactory (nullptr), + m_PrevFactory (nullptr) { DefinitionFactoryMgrClass::Register_Factory (this); return ; diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.cpp index bf883471fc5..8cc6313026a 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.cpp +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionfactorymgr.cpp @@ -45,7 +45,7 @@ //////////////////////////////////////////////////////////////////////////// // Static member initialization //////////////////////////////////////////////////////////////////////////// -DefinitionFactoryClass *DefinitionFactoryMgrClass::_FactoryListHead = 0; +DefinitionFactoryClass *DefinitionFactoryMgrClass::_FactoryListHead = nullptr; //////////////////////////////////////////////////////////////////////////// @@ -56,14 +56,14 @@ DefinitionFactoryClass *DefinitionFactoryMgrClass::_FactoryListHead = 0; DefinitionFactoryClass * DefinitionFactoryMgrClass::Find_Factory (uint32 class_id) { - DefinitionFactoryClass *factory = 0; + DefinitionFactoryClass *factory = nullptr; // // Loop through all the factories and see if we can // find the one who owns the corresponding class-id. // for ( DefinitionFactoryClass *curr_factory = _FactoryListHead; - (factory == 0) && (curr_factory != 0); + (factory == nullptr) && (curr_factory != nullptr); curr_factory = curr_factory->m_NextFactory) { // @@ -86,14 +86,14 @@ DefinitionFactoryMgrClass::Find_Factory (uint32 class_id) DefinitionFactoryClass * DefinitionFactoryMgrClass::Find_Factory (const char *name) { - DefinitionFactoryClass *factory = 0; + DefinitionFactoryClass *factory = nullptr; // // Loop through all the factories and see if we can // find the one who owns the corresponding class-id. // for ( DefinitionFactoryClass *curr_factory = _FactoryListHead; - (factory == 0) && (curr_factory != 0); + (factory == nullptr) && (curr_factory != nullptr); curr_factory = curr_factory->m_NextFactory) { // @@ -116,14 +116,14 @@ DefinitionFactoryMgrClass::Find_Factory (const char *name) DefinitionFactoryClass * DefinitionFactoryMgrClass::Get_First (uint32 superclass_id) { - DefinitionFactoryClass *factory = 0; + DefinitionFactoryClass *factory = nullptr; // // Loop through all the factories and see if we can // find the next one that belongs to the given superclass // for ( DefinitionFactoryClass *curr_factory = _FactoryListHead; - (factory == 0) && (curr_factory != 0); + (factory == nullptr) && (curr_factory != nullptr); curr_factory = curr_factory->m_NextFactory) { // @@ -150,13 +150,13 @@ DefinitionFactoryMgrClass::Get_Next uint32 superclass_id ) { - DefinitionFactoryClass *factory = 0; + DefinitionFactoryClass *factory = nullptr; // // Loop through all the factories and see if we can // find the next one that belongs to the given superclass // - while ((factory == NULL) && ((curr_factory = curr_factory->m_NextFactory) != NULL)) { + while ((factory == nullptr) && ((curr_factory = curr_factory->m_NextFactory) != nullptr)) { // // Is this the factory we were looking for? @@ -190,12 +190,12 @@ DefinitionFactoryMgrClass::Get_First (void) DefinitionFactoryClass * DefinitionFactoryMgrClass::Get_Next (DefinitionFactoryClass *curr_factory) { - DefinitionFactoryClass *factory = 0; + DefinitionFactoryClass *factory = nullptr; // // Simply return the next factory in the chain // - if (curr_factory != NULL) { + if (curr_factory != nullptr) { factory = curr_factory->m_NextFactory; } @@ -247,7 +247,7 @@ DefinitionFactoryMgrClass::Link_Factory (DefinitionFactoryClass *factory) factory->m_NextFactory = _FactoryListHead; // If the list wasn't empty, link the next factory back to this factory - if (factory->m_NextFactory != 0) { + if (factory->m_NextFactory != nullptr) { factory->m_NextFactory->m_PrevFactory = factory; } @@ -268,7 +268,7 @@ DefinitionFactoryMgrClass::Unlink_Factory (DefinitionFactoryClass *factory) WWASSERT(factory != 0); // Handle the factory's prev pointer: - if (factory->m_PrevFactory == 0) { + if (factory->m_PrevFactory == nullptr) { // this factory is the head WWASSERT (_FactoryListHead == factory); @@ -282,14 +282,14 @@ DefinitionFactoryMgrClass::Unlink_Factory (DefinitionFactoryClass *factory) } // Handle the factory's next pointer if its not at the end of the list: - if (factory->m_NextFactory != 0) { + if (factory->m_NextFactory != nullptr) { factory->m_NextFactory->m_PrevFactory = factory->m_PrevFactory; } // factory is now un-linked - factory->m_NextFactory = 0; - factory->m_PrevFactory = 0; + factory->m_NextFactory = nullptr; + factory->m_PrevFactory = nullptr; return ; } diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.cpp index 056180c0031..be38c957e50 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.cpp +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.cpp @@ -73,7 +73,7 @@ enum ////////////////////////////////////////////////////////////////////////////////// // Static member initialization ////////////////////////////////////////////////////////////////////////////////// -DefinitionClass ** DefinitionMgrClass::_SortedDefinitionArray = NULL; +DefinitionClass ** DefinitionMgrClass::_SortedDefinitionArray = nullptr; int DefinitionMgrClass::_DefinitionCount = 0; int DefinitionMgrClass::_MaxDefinitionCount = 0; HashTemplateClass*>* DefinitionMgrClass::DefinitionHash; @@ -108,7 +108,7 @@ DefinitionMgrClass::~DefinitionMgrClass (void) DefinitionClass * DefinitionMgrClass::Find_Definition (uint32 id, bool twiddle) { - DefinitionClass *definition = NULL; + DefinitionClass *definition = nullptr; int lower_index = 0; int upper_index = _DefinitionCount - 1; @@ -121,7 +121,7 @@ DefinitionMgrClass::Find_Definition (uint32 id, bool twiddle) while (keep_going) { DefinitionClass *curr_def = _SortedDefinitionArray[index]; - WWASSERT (curr_def != NULL); + WWASSERT (curr_def != nullptr); // // Is this the definition we are looking for? @@ -162,7 +162,7 @@ DefinitionMgrClass::Find_Definition (uint32 id, bool twiddle) // framework for definitions) // if ( twiddle && - definition != NULL && + definition != nullptr && definition->Get_Class_ID () == CLASSID_TWIDDLERS) { definition = ((TwiddlerClass *)definition)->Twiddle (); @@ -180,7 +180,7 @@ DefinitionMgrClass::Find_Definition (uint32 id, bool twiddle) DefinitionClass * DefinitionMgrClass::Find_Named_Definition (const char *name, bool twiddle) { - DefinitionClass *definition = NULL; + DefinitionClass *definition = nullptr; // // Loop through all the definitions and see if we can @@ -192,7 +192,7 @@ DefinitionMgrClass::Find_Named_Definition (const char *name, bool twiddle) // // Is this the definition we were looking for? // - if (curr_def != NULL && ::stricmp (curr_def->Get_Name (), name) == 0) { + if (curr_def != nullptr && ::stricmp (curr_def->Get_Name (), name) == 0) { definition = curr_def; break; } @@ -203,7 +203,7 @@ DefinitionMgrClass::Find_Named_Definition (const char *name, bool twiddle) // framework for definitions) // if ( twiddle && - definition != NULL && + definition != nullptr && definition->Get_Class_ID () == CLASSID_TWIDDLERS) { definition = ((TwiddlerClass *)definition)->Twiddle (); @@ -225,12 +225,12 @@ DefinitionMgrClass::Find_Typed_Definition (const char *name, uint32 class_id, bo // // Sanity check // - if (DefinitionHash == NULL) { - WWDEBUG_SAY (("DefinitionMgrClass::Find_Typed_Definition () failed due to a NULL DefinitionHash.")); - return NULL; + if (DefinitionHash == nullptr) { + WWDEBUG_SAY (("DefinitionMgrClass::Find_Typed_Definition () failed due to a null DefinitionHash.")); + return nullptr; } - DefinitionClass *definition = NULL; + DefinitionClass *definition = nullptr; // Check the hash table first. The hash table is built as we need the definitions, so if definition is not // in the table, it will be added there. @@ -238,7 +238,7 @@ DefinitionMgrClass::Find_Typed_Definition (const char *name, uint32 class_id, bo // // TSS null deref on this sucker 08/03/01 // - WWASSERT(DefinitionHash != NULL); + WWASSERT(DefinitionHash != nullptr); StringClass lower_case_name(name,true); _strlwr(lower_case_name.Peek_Buffer()); @@ -266,7 +266,7 @@ DefinitionMgrClass::Find_Typed_Definition (const char *name, uint32 class_id, bo if (!definition) { for (int index = 0; index < _DefinitionCount; index ++) { DefinitionClass *curr_def = _SortedDefinitionArray[index]; - if (curr_def != NULL) { + if (curr_def != nullptr) { // // Is this the correct class of definition? @@ -299,7 +299,7 @@ DefinitionMgrClass::Find_Typed_Definition (const char *name, uint32 class_id, bo // framework for definitions) // if ( twiddle && - definition != NULL && + definition != nullptr && definition->Get_Class_ID () == CLASSID_TWIDDLERS) { definition = ((TwiddlerClass *)definition)->Twiddle (); @@ -323,7 +323,7 @@ DefinitionMgrClass::List_Available_Definitions (void) WWDEBUG_SAY(("Available definitions:")); for (int index = 0; index < _DefinitionCount; index ++) { DefinitionClass *curr_def = _SortedDefinitionArray[index]; - if (curr_def != NULL) { + if (curr_def != nullptr) { WWDEBUG_SAY((" >%s<", curr_def->Get_Name ())); } } @@ -344,9 +344,9 @@ DefinitionMgrClass::List_Available_Definitions (int superclass_id) // Loop through all the definitions and print the definition name // WWDEBUG_SAY(("Available superclass definitions for 0x%8X:", superclass_id)); - DefinitionClass *definition = NULL; + DefinitionClass *definition = nullptr; for ( definition = Get_First (superclass_id, DefinitionMgrClass::ID_SUPERCLASS); - definition != NULL; + definition != nullptr; definition = Get_Next (definition, superclass_id, DefinitionMgrClass::ID_SUPERCLASS)) { WWDEBUG_SAY((" >%s<", definition->Get_Name ())); @@ -364,18 +364,18 @@ DefinitionMgrClass::List_Available_Definitions (int superclass_id) DefinitionClass * DefinitionMgrClass::Get_First (uint32 id, ID_TYPE type) { - DefinitionClass *definition = NULL; + DefinitionClass *definition = nullptr; // // Loop through all the definitions and find the first // one that belongs to the requested class // for ( int index = 0; - (definition == NULL) && (index < _DefinitionCount); + (definition == nullptr) && (index < _DefinitionCount); index ++) { DefinitionClass *curr_def = _SortedDefinitionArray[index]; - if (curr_def != NULL) { + if (curr_def != nullptr) { // // Is this the definition we were looking for? @@ -407,18 +407,18 @@ DefinitionMgrClass::Get_Next ID_TYPE type ) { - DefinitionClass *definition = NULL; + DefinitionClass *definition = nullptr; // // Loop through all the definitions and find the first // one that belongs to the requested class // for ( int index = curr_def->m_DefinitionMgrLink + 1; - (definition == NULL) && (index < _DefinitionCount); + (definition == nullptr) && (index < _DefinitionCount); index ++) { DefinitionClass *curr_def = _SortedDefinitionArray[index]; - if (curr_def != NULL) { + if (curr_def != nullptr) { // // Is this the definition we were looking for? @@ -445,8 +445,8 @@ DefinitionMgrClass::Get_Next DefinitionClass * DefinitionMgrClass::Get_Next (DefinitionClass *curr_def) { - WWASSERT (curr_def != NULL); - DefinitionClass *definition = NULL; + WWASSERT (curr_def != nullptr); + DefinitionClass *definition = nullptr; int index = curr_def->m_DefinitionMgrLink + 1; if (index < _DefinitionCount) { @@ -475,13 +475,13 @@ DefinitionMgrClass::Free_Definitions (void) } DefinitionHash->Remove_All(); delete DefinitionHash; - DefinitionHash=NULL; + DefinitionHash=nullptr; } // // Free the definition array // - if (_SortedDefinitionArray != NULL) { + if (_SortedDefinitionArray != nullptr) { // // Free each of the definition objects // @@ -489,7 +489,7 @@ DefinitionMgrClass::Free_Definitions (void) delete _SortedDefinitionArray[index]; } delete [] _SortedDefinitionArray; - _SortedDefinitionArray = NULL; + _SortedDefinitionArray = nullptr; _MaxDefinitionCount = 0; _DefinitionCount = 0; } @@ -538,8 +538,8 @@ DefinitionMgrClass::Prepare_Definition_Array (void) void DefinitionMgrClass::Register_Definition (DefinitionClass *definition) { - WWASSERT (definition != NULL); - if (definition != NULL && definition->m_DefinitionMgrLink == -1 && definition->Get_ID () != 0) { + WWASSERT (definition != nullptr); + if (definition != nullptr && definition->m_DefinitionMgrLink == -1 && definition->Get_ID () != 0) { // // Make sure the definition array is large enough // @@ -559,7 +559,7 @@ DefinitionMgrClass::Register_Definition (DefinitionClass *definition) while (keep_going) { DefinitionClass *curr_def = _SortedDefinitionArray[index]; - WWASSERT (curr_def != NULL); + WWASSERT (curr_def != nullptr); // // Check to make sure we aren't trying to register a definition @@ -634,7 +634,7 @@ DefinitionMgrClass::Unregister_Definition (DefinitionClass *definition) WWASSERT (definition != 0); //WWASSERT (definition->m_DefinitionMgrLink >= 0 && definition->m_DefinitionMgrLink < _DefinitionCount); - if (definition != NULL && definition->m_DefinitionMgrLink != -1) { + if (definition != nullptr && definition->m_DefinitionMgrLink != -1) { // // Re-index the definitions that come after this definition in the list @@ -644,7 +644,7 @@ DefinitionMgrClass::Unregister_Definition (DefinitionClass *definition) _SortedDefinitionArray[index]->m_DefinitionMgrLink = index; } - _SortedDefinitionArray[_DefinitionCount - 1] = NULL; + _SortedDefinitionArray[_DefinitionCount - 1] = nullptr; definition->m_DefinitionMgrLink = -1; _DefinitionCount --; } @@ -741,7 +741,7 @@ DefinitionMgrClass::Save_Objects // for (int index = 0; index < _DefinitionCount; index ++) { DefinitionClass *definition = _SortedDefinitionArray[index]; - if (definition != NULL && definition->Is_Save_Enabled ()) { + if (definition != nullptr && definition->Is_Save_Enabled ()) { // // Save this definition object @@ -789,10 +789,10 @@ DefinitionMgrClass::Load_Objects (ChunkLoadClass &cload) // Load this definition from the chunk (if possible) // PersistFactoryClass *factory = SaveLoadSystemClass::Find_Persist_Factory (cload.Cur_Chunk_ID ()); - if (factory != NULL) { + if (factory != nullptr) { DefinitionClass *definition = (DefinitionClass *)factory->Load (cload); - if (definition != NULL) { + if (definition != nullptr) { // // Add this definition to our array @@ -868,7 +868,7 @@ DefinitionMgrClass::Get_New_ID (uint32 class_id) // for (int index = 0; index < _DefinitionCount; index ++) { DefinitionClass *definition = _SortedDefinitionArray[index]; - if (definition != NULL) { + if (definition != nullptr) { // // Get this definition's ID @@ -888,7 +888,7 @@ DefinitionMgrClass::Get_New_ID (uint32 class_id) // ID range. // DefinitionClass *next_definition = _SortedDefinitionArray[index + 1]; - if (next_definition != NULL && next_definition->Get_ID () > (curr_id + 1)) { + if (next_definition != nullptr && next_definition->Get_ID () > (curr_id + 1)) { is_ok = true; } @@ -923,8 +923,8 @@ DefinitionMgrClass::fnCompareDefinitionsCallback const void *elem2 ) { - WWASSERT (elem1 != NULL); - WWASSERT (elem2 != NULL); + WWASSERT (elem1 != nullptr); + WWASSERT (elem2 != nullptr); DefinitionClass *definition1 = *((DefinitionClass **)elem1); DefinitionClass *definition2 = *((DefinitionClass **)elem2); diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.h index ade932edbd9..aad040c795f 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/definitionmgr.h @@ -168,7 +168,7 @@ DefinitionMgrClass::Contains_Data (void) const inline DefinitionClass * DefinitionMgrClass::Get_First (void) { - DefinitionClass *definition = NULL; + DefinitionClass *definition = nullptr; if (_DefinitionCount > 0) { definition = _SortedDefinitionArray[0]; } diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/editable.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/editable.h index 059b5dcf9ac..446d9ee4886 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/editable.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/editable.h @@ -87,7 +87,7 @@ inline ParameterClass * EditableClass::Lock_Parameter (int i) { WWASSERT (0); - return NULL; + return nullptr; } ///////////////////////////////////////////////////////////////////// diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.cpp index 534e0ada3bb..e8adf404bcf 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.cpp +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.cpp @@ -55,7 +55,7 @@ ParameterClass * ParameterClass::Construct (Type type, void *data, const char *name) { - ParameterClass *new_param = NULL; + ParameterClass *new_param = nullptr; switch (type) { case TYPE_INT: @@ -211,7 +211,7 @@ StringParameterClass::StringParameterClass (StringClass *string) // ///////////////////////////////////////////////////////////////////// StringParameterClass::StringParameterClass (const StringParameterClass &src) - : m_String (NULL) + : m_String (nullptr) { (*this) = src; return ; @@ -242,7 +242,7 @@ StringParameterClass::operator== (const StringParameterClass &src) { bool retval = false; - if (m_String != NULL && src.m_String != NULL && + if (m_String != nullptr && src.m_String != nullptr && (m_String->Compare (*(src.m_String)) == 0)) { retval = true; } @@ -294,8 +294,8 @@ StringParameterClass::Copy_Value (const ParameterClass &src) const char * StringParameterClass::Get_String (void) const { - const char * string = NULL; - if (m_String != NULL) { + const char * string = nullptr; + if (m_String != nullptr) { string = (*m_String); } return string; @@ -310,7 +310,7 @@ StringParameterClass::Get_String (void) const void StringParameterClass::Set_String (const char * string) { - if (m_String != NULL) { + if (m_String != nullptr) { Set_Modified (); (*m_String) = string; } @@ -536,7 +536,7 @@ EnumParameterClass::EnumParameterClass (int *value) // ///////////////////////////////////////////////////////////////////// EnumParameterClass::EnumParameterClass (const EnumParameterClass &src) - : m_Value (NULL) + : m_Value (nullptr) { (*this) = src; return ; @@ -570,7 +570,7 @@ EnumParameterClass::operator== (const EnumParameterClass &src) { bool retval = false; - if (m_Value != NULL && src.m_Value != NULL && + if (m_Value != nullptr && src.m_Value != nullptr && (*m_Value) == (*src.m_Value)) { retval = true; @@ -652,7 +652,7 @@ EnumParameterClass::Add_Values (const char *first_name, int first_value, ...) // Get the string param // const char *name = va_arg (arg_list, const char *); - if (name == NULL) { + if (name == nullptr) { more_params = false; } else { @@ -694,7 +694,7 @@ PhysDefParameterClass::PhysDefParameterClass (int *id) // ///////////////////////////////////////////////////////////////////// PhysDefParameterClass::PhysDefParameterClass (const PhysDefParameterClass &src) - : m_Value (NULL) + : m_Value (nullptr) { (*this) = src; return ; @@ -725,7 +725,7 @@ PhysDefParameterClass::operator== (const PhysDefParameterClass &src) { bool retval = false; - if (m_Value != NULL && src.m_Value != NULL && + if (m_Value != nullptr && src.m_Value != nullptr && (*m_Value) == (*src.m_Value)) { retval = true; @@ -792,7 +792,7 @@ ModelDefParameterClass::ModelDefParameterClass (int *id) // ///////////////////////////////////////////////////////////////////// ModelDefParameterClass::ModelDefParameterClass (const ModelDefParameterClass &src) - : m_Value (NULL) + : m_Value (nullptr) { (*this) = src; return ; @@ -823,7 +823,7 @@ ModelDefParameterClass::operator== (const ModelDefParameterClass &src) { bool retval = false; - if (m_Value != NULL && src.m_Value != NULL && + if (m_Value != nullptr && src.m_Value != nullptr && (*m_Value) == (*src.m_Value)) { retval = true; @@ -890,7 +890,7 @@ DefParameterClass::DefParameterClass (int *id) // ///////////////////////////////////////////////////////////////////// DefParameterClass::DefParameterClass (const DefParameterClass &src) - : m_Value (NULL) + : m_Value (nullptr) { (*this) = src; return ; @@ -921,7 +921,7 @@ DefParameterClass::operator== (const DefParameterClass &src) { bool retval = false; - if (m_Value != NULL && src.m_Value != NULL && + if (m_Value != nullptr && src.m_Value != nullptr && (*m_Value) == (*src.m_Value)) { retval = true; @@ -1024,7 +1024,7 @@ GenericDefParameterClass::operator== (const GenericDefParameterClass &src) { bool retval = false; - if (m_Value != NULL && src.m_Value != NULL && + if (m_Value != nullptr && src.m_Value != nullptr && (*m_Value) == (*src.m_Value)) { retval = true; @@ -1124,7 +1124,7 @@ GameObjDefParameterClass::operator== (const GameObjDefParameterClass &src) { bool retval = false; - if (m_Value != NULL && src.m_Value != NULL && + if (m_Value != nullptr && src.m_Value != nullptr && (*m_Value) == (*src.m_Value)) { retval = true; @@ -1194,7 +1194,7 @@ WeaponObjDefParameterClass::WeaponObjDefParameterClass (int *id) // ///////////////////////////////////////////////////////////////////// WeaponObjDefParameterClass::WeaponObjDefParameterClass (const WeaponObjDefParameterClass &src) - : GameObjDefParameterClass (NULL) + : GameObjDefParameterClass (nullptr) { (*this) = src; return ; @@ -1225,7 +1225,7 @@ WeaponObjDefParameterClass::operator== (const WeaponObjDefParameterClass &src) { bool retval = false; - if (m_Value != NULL && src.m_Value != NULL && + if (m_Value != nullptr && src.m_Value != nullptr && (*m_Value) == (*src.m_Value)) { retval = true; @@ -1295,7 +1295,7 @@ AmmoObjDefParameterClass::AmmoObjDefParameterClass (int *id) // ///////////////////////////////////////////////////////////////////// AmmoObjDefParameterClass::AmmoObjDefParameterClass (const AmmoObjDefParameterClass &src) - : GameObjDefParameterClass (NULL) + : GameObjDefParameterClass (nullptr) { (*this) = src; return ; @@ -1326,7 +1326,7 @@ AmmoObjDefParameterClass::operator== (const AmmoObjDefParameterClass &src) { bool retval = false; - if (m_Value != NULL && src.m_Value != NULL && + if (m_Value != nullptr && src.m_Value != nullptr && (*m_Value) == (*src.m_Value)) { retval = true; @@ -1396,7 +1396,7 @@ ExplosionObjDefParameterClass::ExplosionObjDefParameterClass (int *id) // ///////////////////////////////////////////////////////////////////// ExplosionObjDefParameterClass::ExplosionObjDefParameterClass (const ExplosionObjDefParameterClass &src) - : GameObjDefParameterClass (NULL) + : GameObjDefParameterClass (nullptr) { (*this) = src; return ; @@ -1427,7 +1427,7 @@ ExplosionObjDefParameterClass::operator== (const ExplosionObjDefParameterClass & { bool retval = false; - if (m_Value != NULL && src.m_Value != NULL && + if (m_Value != nullptr && src.m_Value != nullptr && (*m_Value) == (*src.m_Value)) { retval = true; @@ -1526,7 +1526,7 @@ SoundDefParameterClass::operator== (const SoundDefParameterClass &src) { bool retval = false; - if (m_Value != NULL && src.m_Value != NULL && + if (m_Value != nullptr && src.m_Value != nullptr && (*m_Value) == (*src.m_Value)) { retval = true; @@ -1579,8 +1579,8 @@ ScriptParameterClass::ScriptParameterClass (StringClass *name, StringClass *para // ///////////////////////////////////////////////////////////////////// ScriptParameterClass::ScriptParameterClass (const ScriptParameterClass &src) - : m_ScriptName (NULL), - m_ScriptParams (NULL) + : m_ScriptName (nullptr), + m_ScriptParams (nullptr) { (*this) = src; return ; @@ -1615,8 +1615,8 @@ ScriptParameterClass::operator== (const ScriptParameterClass &src) // // Data valid? // - if ( (m_ScriptName != NULL) && (src.m_ScriptName != NULL) && - (m_ScriptParams != NULL) && (src.m_ScriptParams != NULL)) + if ( (m_ScriptName != nullptr) && (src.m_ScriptName != nullptr) && + (m_ScriptParams != nullptr) && (src.m_ScriptParams != nullptr)) { // @@ -1684,7 +1684,7 @@ ScriptParameterClass::Copy_Value (const ParameterClass &src) DefIDListParameterClass::DefIDListParameterClass (DynamicVectorClass *list) : m_IDList (list), m_ClassID (0), - m_SelectedClassID (NULL) + m_SelectedClassID (nullptr) { return ; } @@ -1696,9 +1696,9 @@ DefIDListParameterClass::DefIDListParameterClass (DynamicVectorClass *list) // ///////////////////////////////////////////////////////////////////// DefIDListParameterClass::DefIDListParameterClass (const DefIDListParameterClass &src) - : m_IDList (NULL), + : m_IDList (nullptr), m_ClassID (0), - m_SelectedClassID (NULL) + m_SelectedClassID (nullptr) { (*this) = src; return ; @@ -1735,7 +1735,7 @@ DefIDListParameterClass::operator== (const DefIDListParameterClass &src) // // Data valid? // - if ((m_IDList != NULL) && (src.m_IDList != NULL)) + if ((m_IDList != nullptr) && (src.m_IDList != nullptr)) { // // Class IDs the same? @@ -1793,7 +1793,7 @@ DefIDListParameterClass::Copy_Value (const ParameterClass &src) m_ClassID = real_src.m_ClassID; (*m_IDList) = (*real_src.m_IDList); - if (m_SelectedClassID != NULL && real_src.m_SelectedClassID != NULL) { + if (m_SelectedClassID != nullptr && real_src.m_SelectedClassID != nullptr) { (*m_SelectedClassID) = (*real_src.m_SelectedClassID); } } @@ -1828,7 +1828,7 @@ ZoneParameterClass::ZoneParameterClass (OBBoxClass *box) // ///////////////////////////////////////////////////////////////////// ZoneParameterClass::ZoneParameterClass (const ZoneParameterClass &src) - : m_OBBox (NULL) + : m_OBBox (nullptr) { (*this) = src; return ; @@ -1863,7 +1863,7 @@ ZoneParameterClass::operator== (const ZoneParameterClass &src) // // Are the OBBoxes the same? // - if ((m_OBBox != NULL) && (src.m_OBBox != NULL)) { + if ((m_OBBox != nullptr) && (src.m_OBBox != nullptr)) { retval = (*m_OBBox) == (*src.m_OBBox); } @@ -1933,7 +1933,7 @@ FilenameListParameterClass::FilenameListParameterClass (DynamicVectorClassCount (); int count2 = src.m_FilenameList->Count (); @@ -2054,8 +2054,8 @@ ScriptListParameterClass::ScriptListParameterClass // ///////////////////////////////////////////////////////////////////// ScriptListParameterClass::ScriptListParameterClass (const ScriptListParameterClass &src) - : m_NameList (NULL), - m_ParamList (NULL) + : m_NameList (nullptr), + m_ParamList (nullptr) { (*this) = src; return ; @@ -2091,8 +2091,8 @@ ScriptListParameterClass::operator== (const ScriptListParameterClass &src) // // Data valid? // - if ( (m_NameList != NULL) && (src.m_NameList != NULL) && - (m_ParamList != NULL) && (src.m_ParamList != NULL)) + if ( (m_NameList != nullptr) && (src.m_NameList != nullptr) && + (m_ParamList != nullptr) && (src.m_ParamList != nullptr)) { retval = Are_Lists_Identical (*m_NameList, *(src.m_NameList)); retval &= Are_Lists_Identical (*m_ParamList, *(src.m_ParamList)); diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.h index 686bf88c292..ac2d337a127 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/parameter.h @@ -115,7 +115,7 @@ class ParameterClass ////////////////////////////////////////////////////////////////////////////// // RTTI - virtual DefParameterClass * As_DefParameterClass (void) { return NULL; } + virtual DefParameterClass * As_DefParameterClass (void) { return nullptr; } // Type identification (see paramtypes.h in wwsaveload) virtual Type Get_Type (void) const = 0; @@ -159,7 +159,7 @@ class ParameterClass ////////////////////////////////////////////////////////////////////////////////// inline ParameterClass::ParameterClass (void) - : m_Name (NULL), + : m_Name (nullptr), IsModified (false) { return ; @@ -170,7 +170,7 @@ ParameterClass::ParameterClass (void) ////////////////////////////////////////////////////////////////////////////////// inline ParameterClass::ParameterClass (const ParameterClass &src) - : m_Name (NULL), + : m_Name (nullptr), IsModified (false) { (*this) = src; @@ -183,7 +183,7 @@ ParameterClass::ParameterClass (const ParameterClass &src) inline ParameterClass::~ParameterClass (void) { - Set_Name (NULL); + Set_Name (nullptr); return ; } @@ -213,12 +213,12 @@ ParameterClass::Get_Name (void) const inline void ParameterClass::Set_Name (const char *new_name) { - if (m_Name != NULL) { + if (m_Name != nullptr) { ::free ((void *)m_Name); - m_Name = NULL; + m_Name = nullptr; } - if (new_name != NULL) { + if (new_name != nullptr) { m_Name = ::strdup (new_name); } @@ -468,7 +468,7 @@ class EnumParameterClass : public ParameterClass StringClass name; int value; - _ENUM_VALUE (const char *_name=NULL, int _value=0) : name (_name), value (_value) {} + _ENUM_VALUE (const char *_name=nullptr, int _value=0) : name (_name), value (_value) {} bool operator== (const _ENUM_VALUE &) { return false; } bool operator!= (const _ENUM_VALUE &) { return true; } } ENUM_VALUE; diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameterlist.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/parameterlist.h index 80ba4a737fb..10c6e130712 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/parameterlist.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/parameterlist.h @@ -101,10 +101,10 @@ ParameterListClass::Add (void *data, const char *param_name, ParameterClass::Typ ParameterClass *new_param = ParameterClass::Construct (type, data, param_name); // - // Add the new paramter object to our list + // Add the new parameter object to our list // - WWASSERT (new_param != NULL); - if (new_param != NULL) { + WWASSERT (new_param != nullptr); + if (new_param != nullptr) { DynamicVectorClass::Add (new_param); } @@ -118,9 +118,9 @@ inline void ParameterListClass::Add (ParameterClass *new_param) { // - // Add the new paramter object to our list + // Add the new parameter object to our list // - if (new_param != NULL) { + if (new_param != nullptr) { DynamicVectorClass::Add (new_param); } diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.cpp index ca81e905c5f..9dc1283f98f 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.cpp +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.cpp @@ -39,7 +39,7 @@ #include "saveload.h" PersistFactoryClass::PersistFactoryClass(void) : - NextFactory(NULL) + NextFactory(nullptr) { SaveLoadSystemClass::Register_Persist_Factory(this); } diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.h index 0599936a178..d45822f80d3 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/persistfactory.h @@ -100,7 +100,7 @@ template PersistClass * SimplePersistFactoryClass::Load(ChunkLoadClass & cload) const { T * new_obj = W3DNEW T; - T * old_obj = NULL; + T * old_obj = nullptr; cload.Open_Chunk(); WWASSERT(cload.Cur_Chunk_ID() == SIMPLEFACTORY_CHUNKID_OBJPOINTER); diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.cpp index 21dc60f1bf4..a8033d14e97 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.cpp +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/pointerremap.cpp @@ -111,10 +111,10 @@ void PointerRemapClass::Process_Request_Table(DynamicVectorClass } else { // Failed to re-map the pointer. - // warn the user, set pointer to NULL, reset index to the pre_search_index. + // warn the user, set pointer to null, reset index to the pre_search_index. // If this happens, things could be going very wrong. (find out why its happening!) pair_index = pre_search_index; - *request_table[pointer_index].PointerToRemap = NULL; + *request_table[pointer_index].PointerToRemap = nullptr; #ifdef WWDEBUG const char * file = request_table[pointer_index].File; int line = request_table[pointer_index].Line; diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.cpp index 004d09544cb..d2b8011e76d 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.cpp +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.cpp @@ -50,8 +50,8 @@ #include "systimer.h" -SaveLoadSubSystemClass * SaveLoadSystemClass::SubSystemListHead = NULL; -PersistFactoryClass * SaveLoadSystemClass::FactoryListHead = NULL; +SaveLoadSubSystemClass * SaveLoadSystemClass::SubSystemListHead = nullptr; +PersistFactoryClass * SaveLoadSystemClass::FactoryListHead = nullptr; SList SaveLoadSystemClass::PostLoadList; PointerRemapClass SaveLoadSystemClass::PointerRemapper; @@ -82,7 +82,7 @@ bool SaveLoadSystemClass::Load (ChunkLoadClass &cload,bool auto_post_load) SaveLoadStatus::Inc_Status_Count(); // Count the sub systems loaded SaveLoadSubSystemClass *sys = Find_Sub_System(cload.Cur_Chunk_ID ()); WWLOG_INTERMEDIATE("Find_Sub_System"); - if (sys != NULL) { + if (sys != nullptr) { //WWRELEASE_SAY((" Name: %s",sys->Name())); INIT_SUB_STATUS(sys->Name()); ok &= sys->Load(cload); @@ -99,7 +99,7 @@ bool SaveLoadSystemClass::Load (ChunkLoadClass &cload,bool auto_post_load) // Call PostLoad on each PersistClass that wanted post-load if (auto_post_load) { - Post_Load_Processing(NULL); + Post_Load_Processing(nullptr); } WWLOG_INTERMEDIATE("PostLoadProcessing"); @@ -134,14 +134,14 @@ bool SaveLoadSystemClass::Post_Load_Processing (void(*network_callback)(void)) void SaveLoadSystemClass::Register_Sub_System (SaveLoadSubSystemClass * sys) { - WWASSERT(sys != NULL); + WWASSERT(sys != nullptr); Link_Sub_System(sys); } void SaveLoadSystemClass::Unregister_Sub_System (SaveLoadSubSystemClass * sys) { - WWASSERT(sys != NULL); + WWASSERT(sys != nullptr); Unlink_Sub_System(sys); } @@ -150,7 +150,7 @@ SaveLoadSubSystemClass * SaveLoadSystemClass::Find_Sub_System (uint32 chunk_id) { // TODO: need a d-s that gives fast searching based on chunk_id!! SaveLoadSubSystemClass * sys; - for ( sys = SubSystemListHead; sys != NULL; sys = sys->NextSubSystem ) { + for ( sys = SubSystemListHead; sys != nullptr; sys = sys->NextSubSystem ) { if ( sys->Chunk_ID() == chunk_id ) { break; } @@ -160,13 +160,13 @@ SaveLoadSubSystemClass * SaveLoadSystemClass::Find_Sub_System (uint32 chunk_id) void SaveLoadSystemClass::Register_Persist_Factory(PersistFactoryClass * factory) { - WWASSERT(factory != NULL); + WWASSERT(factory != nullptr); Link_Factory(factory); } void SaveLoadSystemClass::Unregister_Persist_Factory(PersistFactoryClass * factory) { - WWASSERT(factory != NULL); + WWASSERT(factory != nullptr); Unlink_Factory(factory); } @@ -174,7 +174,7 @@ PersistFactoryClass * SaveLoadSystemClass::Find_Persist_Factory(uint32 chunk_id) { // TODO: need a d-s that gives fast searching based on chunk_id!! PersistFactoryClass * fact; - for ( fact = FactoryListHead; fact != NULL; fact = fact->NextFactory ) { + for ( fact = FactoryListHead; fact != nullptr; fact = fact->NextFactory ) { if ( fact->Chunk_ID() == chunk_id ) { break; } @@ -187,9 +187,9 @@ bool SaveLoadSystemClass::Is_Post_Load_Callback_Registered(PostLoadableClass * o // obsolete! bool retval = false; - SLNode *list_node = NULL; + SLNode *list_node = nullptr; for ( list_node = PostLoadList.Head(); - retval == false && list_node != NULL; + retval == false && list_node != nullptr; list_node = list_node->Next()) { retval = (list_node->Data() == obj); @@ -200,7 +200,7 @@ bool SaveLoadSystemClass::Is_Post_Load_Callback_Registered(PostLoadableClass * o void SaveLoadSystemClass::Register_Post_Load_Callback(PostLoadableClass * obj) { - WWASSERT(obj != NULL); + WWASSERT(obj != nullptr); if (!obj->Is_Post_Load_Registered()) { obj->Set_Post_Load_Registered(true); PostLoadList.Add_Head(obj); @@ -240,9 +240,9 @@ void SaveLoadSystemClass::Request_Ref_Counted_Pointer_Remap (RefCountClass **poi void SaveLoadSystemClass::Link_Sub_System(SaveLoadSubSystemClass * sys) { - WWASSERT(sys != NULL); - if (sys != NULL) { - WWASSERT(sys->NextSubSystem == NULL); // sys should never be registered twice! + WWASSERT(sys != nullptr); + if (sys != nullptr) { + WWASSERT(sys->NextSubSystem == nullptr); // sys should never be registered twice! sys->NextSubSystem = SubSystemListHead; SubSystemListHead = sys; } @@ -250,30 +250,30 @@ void SaveLoadSystemClass::Link_Sub_System(SaveLoadSubSystemClass * sys) void SaveLoadSystemClass::Unlink_Sub_System(SaveLoadSubSystemClass * sys) { - WWASSERT(sys != NULL); + WWASSERT(sys != nullptr); SaveLoadSubSystemClass * cursys = SubSystemListHead; - SaveLoadSubSystemClass * prev = NULL; + SaveLoadSubSystemClass * prev = nullptr; while (cursys != sys) { prev = cursys; cursys = cursys->NextSubSystem; } - if (prev == NULL) { + if (prev == nullptr) { SubSystemListHead = sys->NextSubSystem; } else { prev->NextSubSystem = sys->NextSubSystem; } - sys->NextSubSystem = NULL; + sys->NextSubSystem = nullptr; } void SaveLoadSystemClass::Link_Factory(PersistFactoryClass * fact) { - WWASSERT(fact != NULL); - if (fact != NULL) { - WWASSERT(fact->NextFactory == NULL); // factories should never be registered twice! + WWASSERT(fact != nullptr); + if (fact != nullptr) { + WWASSERT(fact->NextFactory == nullptr); // factories should never be registered twice! fact->NextFactory = FactoryListHead; FactoryListHead = fact; } @@ -281,23 +281,23 @@ void SaveLoadSystemClass::Link_Factory(PersistFactoryClass * fact) void SaveLoadSystemClass::Unlink_Factory(PersistFactoryClass * fact) { - WWASSERT(fact != NULL); + WWASSERT(fact != nullptr); PersistFactoryClass * curfact = FactoryListHead; - PersistFactoryClass * prev = NULL; + PersistFactoryClass * prev = nullptr; while (curfact != fact) { prev = curfact; curfact = curfact->NextFactory; } - if (prev == NULL) { + if (prev == nullptr) { FactoryListHead = fact->NextFactory; } else { prev->NextFactory = fact->NextFactory; } - fact->NextFactory = NULL; + fact->NextFactory = nullptr; } void Force_Link_WWSaveLoad (void) diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.h index 05ac8b6e08e..137818210a8 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveload.h @@ -70,7 +70,7 @@ class ChunkLoadClass; // // To achive this, we developed several core concepts: // -// - Persistant Objects: Most of the state of the game is contained in the objects +// - Persistent Objects: Most of the state of the game is contained in the objects // active at any given time. PersistClass is an abstract interface which will allow // objects to be used with the save-load system. It was also important to keep the // overhead caused by inheriting this class to an absolute minimum. @@ -90,7 +90,7 @@ class ChunkLoadClass; // (derived from SaveLoadSubSystemClass). The application in-effect creates file formats // by simply having the sub-systems that it wants write into a file. In this way you can // achieve things like saving only static data into one file and dynamic into another, etc. -// All persistant objects that get saved will be told to save by some sub-system. For +// All persistent objects that get saved will be told to save by some sub-system. For // example: in Commando, I have a PhysicsDynamicDataSubSystem which saves all of the // dynamic physics objects. In saving those objects I use the built-in PersistFactories // and am therefore completely safe from new object types being added to the system, it will just @@ -160,8 +160,8 @@ class SaveLoadSystemClass static void Register_Pointer (void *old_pointer, void *new_pointer); #ifdef WWDEBUG - static void Request_Pointer_Remap (void **pointer_to_convert,const char * file = NULL,int line = 0); - static void Request_Ref_Counted_Pointer_Remap (RefCountClass **pointer_to_convert,const char * file = NULL,int line = 0); + static void Request_Pointer_Remap (void **pointer_to_convert,const char * file = nullptr,int line = 0); + static void Request_Ref_Counted_Pointer_Remap (RefCountClass **pointer_to_convert,const char * file = nullptr,int line = 0); #else static void Request_Pointer_Remap (void **pointer_to_convert); static void Request_Ref_Counted_Pointer_Remap (RefCountClass **pointer_to_convert); diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.cpp index d45322be8a1..831ef841d70 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.cpp +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/saveloadsubsystem.cpp @@ -40,7 +40,7 @@ SaveLoadSubSystemClass::SaveLoadSubSystemClass(void) : - NextSubSystem(NULL) + NextSubSystem(nullptr) { // All Sub-Systems are automatically registered with the SaveLoadSystem SaveLoadSystemClass::Register_Sub_System (this); diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/simpleparameter.h b/Core/Libraries/Source/WWVegas/WWSaveLoad/simpleparameter.h index af9f6dbd249..cb39c6c68e1 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/simpleparameter.h +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/simpleparameter.h @@ -171,7 +171,7 @@ typedef SimpleParameterClass StringsDBE // // RangedParameterClass // -// Extends simple paramter types so they can have minimum/maximum values. +// Extends simple parameter types so they can have minimum/maximum values. // ////////////////////////////////////////////////////////////////////////////////// template diff --git a/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.cpp b/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.cpp index 8e782eb186a..87a5807cfe7 100644 --- a/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.cpp +++ b/Core/Libraries/Source/WWVegas/WWSaveLoad/twiddler.cpp @@ -105,7 +105,7 @@ TwiddlerClass::~TwiddlerClass (void) DefinitionClass * TwiddlerClass::Twiddle (void) const { - DefinitionClass *definition = NULL; + DefinitionClass *definition = nullptr; if (m_DefinitionList.Count () > 0) { @@ -134,13 +134,13 @@ TwiddlerClass::Twiddle (void) const PersistClass * TwiddlerClass::Create (void) const { - PersistClass *retval = NULL; + PersistClass *retval = nullptr; // // Pick a random definition // DefinitionClass *definition = Twiddle (); - if (definition != NULL) { + if (definition != nullptr) { // // Indirect the creation to the definition we randomly selected diff --git a/Core/Libraries/Source/WWVegas/WWStub/wwallocstub.cpp b/Core/Libraries/Source/WWVegas/WWStub/wwallocstub.cpp index d250ae52f1e..eb4ea7ec38d 100644 --- a/Core/Libraries/Source/WWVegas/WWStub/wwallocstub.cpp +++ b/Core/Libraries/Source/WWVegas/WWStub/wwallocstub.cpp @@ -17,6 +17,7 @@ */ // TheSuperHackers @build feliwir 15/04/2025 Simple allocator implementation useful for tools + #include "always.h" #include @@ -66,7 +67,7 @@ void operator delete[](void * p, const char *, int) void* createW3DMemPool(const char *poolName, int allocationSize) { - return NULL; + return nullptr; } void* allocateFromW3DMemPool(void* pool, int allocationSize) diff --git a/Core/Libraries/Source/WWVegas/WWStub/wwdebugstub.cpp b/Core/Libraries/Source/WWVegas/WWStub/wwdebugstub.cpp index 3103aff21c3..903b170c453 100644 --- a/Core/Libraries/Source/WWVegas/WWStub/wwdebugstub.cpp +++ b/Core/Libraries/Source/WWVegas/WWStub/wwdebugstub.cpp @@ -17,12 +17,13 @@ */ // TheSuperHackers @build feliwir 15/04/2025 Simple debug implementation useful for tools + #include "wwdebug.h" #include #include #include -char* TheCurrentIgnoreCrashPtr = NULL; +char* TheCurrentIgnoreCrashPtr = nullptr; #ifdef DEBUG_LOGGING diff --git a/Core/Libraries/Source/debug/CMakeLists.txt b/Core/Libraries/Source/debug/CMakeLists.txt index 24890749443..ddce3092d16 100644 --- a/Core/Libraries/Source/debug/CMakeLists.txt +++ b/Core/Libraries/Source/debug/CMakeLists.txt @@ -30,6 +30,7 @@ target_include_directories(core_debug INTERFACE ) target_precompile_headers(core_debug PRIVATE + [["Utility/CppMacros.h"]] # Must be first, to be removed when abandoning VC6 "debug.h" "internal.h" "internal_except.h" @@ -38,7 +39,6 @@ target_precompile_headers(core_debug PRIVATE ) target_link_libraries(core_debug PRIVATE - core_config core_wwcommon corei_always ) diff --git a/Core/Libraries/Source/debug/debug_cmd.cpp b/Core/Libraries/Source/debug/debug_cmd.cpp index 019e2e3f7d4..d6d2f8526c4 100644 --- a/Core/Libraries/Source/debug/debug_cmd.cpp +++ b/Core/Libraries/Source/debug/debug_cmd.cpp @@ -263,7 +263,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, if (cur->io) { cur->io->Delete(); - cur->io=NULL; + cur->io=nullptr; } return true; } @@ -276,7 +276,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, return true; } - cur->io->Execute(dbg,argn>1?argv[1]:NULL,!normalMode,argn>1?argn-2:0,argv+2); + cur->io->Execute(dbg,argn>1?argv[1]:nullptr,!normalMode,argn>1?argn-2:0,argv+2); } return true; } @@ -366,7 +366,7 @@ bool DebugCmdInterfaceDebug::Execute(class Debug& dbg, const char *cmd, dbg.lastPatternEntry=cur; } else - dbg.lastPatternEntry=NULL; + dbg.lastPatternEntry=nullptr; } if (strcmp(cmd,"add") == 0) { diff --git a/Core/Libraries/Source/debug/debug_cmd.h b/Core/Libraries/Source/debug/debug_cmd.h index 3e7f0bc45c6..d3cbec19222 100644 --- a/Core/Libraries/Source/debug/debug_cmd.h +++ b/Core/Libraries/Source/debug/debug_cmd.h @@ -38,7 +38,7 @@ command group and the commands implemented for this group. A Debug command group interface instance must register itself - using Debug::AddCommands. Ownership is then transfered to + using Debug::AddCommands. Ownership is then transferred to the Debug module unless the object is manually removed by calling Debug::RemoveCommands. diff --git a/Core/Libraries/Source/debug/debug_debug.cpp b/Core/Libraries/Source/debug/debug_debug.cpp index 77049750322..7e218e9ad1b 100644 --- a/Core/Libraries/Source/debug/debug_debug.cpp +++ b/Core/Libraries/Source/debug/debug_debug.cpp @@ -26,6 +26,7 @@ // // Debug class implementation ////////////////////////////////////////////////////////////////////////////// + #include "debug.h" #include "internal.h" #include "internal_except.h" @@ -46,11 +47,22 @@ bool __DebugIncludeInLink1; // .CRT$XCZ. We jam in our own two functions at the very beginning // and end of this list (B and Y respectively since the A and Z segments // contain list delimiters). +#if defined(_MSC_VER) #pragma data_seg(".CRT$XCB") void *Debug::PreStatic=&Debug::PreStaticInit; #pragma data_seg(".CRT$XCY") void *Debug::PostStatic=&Debug::PostStaticInit; #pragma data_seg() +#elif defined(__GNUC__) && defined(_WIN32) +// For GCC/MinGW-w64 targeting Windows, use constructor attributes +// Use priority 101 for PreStatic (very early) and 65434 for PostStatic (very late) +void __attribute__((constructor(101))) GccPreStaticInit() { Debug::PreStaticInit(); } +void __attribute__((constructor(65434))) GccPostStaticInit() { Debug::PostStaticInit(); } +void *Debug::PreStatic = nullptr; +void *Debug::PostStatic = nullptr; +#else +#error "Unsupported compiler or platform. This code requires MSVC or GCC/MinGW-w64 targeting Windows." +#endif Debug::LogDescription::LogDescription(const char *fileOrGroup, const char *description) { @@ -84,21 +96,21 @@ void Debug::PreStaticInit(void) atexit(StaticExit); // init vars - Instance.hrTranslators=NULL; + Instance.hrTranslators=nullptr; Instance.numHrTranslators=0; - Instance.firstIOFactory=NULL; - Instance.firstCmdGroup=NULL; + Instance.firstIOFactory=nullptr; + Instance.firstCmdGroup=nullptr; memset(Instance.frameHash,0,sizeof(Instance.frameHash)); - Instance.nextUnusedFrameHash=NULL; + Instance.nextUnusedFrameHash=nullptr; Instance.numAvailableFrameHash=0; - Instance.firstLogGroup=NULL; + Instance.firstLogGroup=nullptr; memset(Instance.ioBuffer,0,sizeof(Instance.ioBuffer)); Instance.curType=DebugIOInterface::StringType::MAX; *Instance.curSource=0; Instance.disableAssertsEtc=0; - Instance.curFrameEntry=NULL; - Instance.firstPatternEntry=NULL; - Instance.lastPatternEntry=NULL; + Instance.curFrameEntry=nullptr; + Instance.firstPatternEntry=nullptr; + Instance.lastPatternEntry=nullptr; *Instance.curCommandGroup=0; Instance.alwaysFlush=false; Instance.timeStamp=false; @@ -124,25 +136,25 @@ void Debug::PostStaticInit(void) /// exec dbgcmd file char ioBuffer[2048]; - GetModuleFileName(NULL,ioBuffer,sizeof(ioBuffer)); + GetModuleFileName(nullptr,ioBuffer,sizeof(ioBuffer)); char *q=strrchr(ioBuffer,'.'); if (q) strcpy(q,".dbgcmd"); - HANDLE h=CreateFile(ioBuffer,GENERIC_READ,0,NULL,OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL,NULL); + HANDLE h=CreateFile(ioBuffer,GENERIC_READ,0,nullptr,OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL,nullptr); if (h==INVALID_HANDLE_VALUE) - h=CreateFile("default.dbgcmd",GENERIC_READ,0,NULL,OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL,NULL); + h=CreateFile("default.dbgcmd",GENERIC_READ,0,nullptr,OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL,nullptr); if (h!=INVALID_HANDLE_VALUE) { char cmdBuffer[512]; unsigned long ioCur=0,ioUsed=0,cmdCur=0; - ReadFile(h,ioBuffer,sizeof(ioBuffer),&ioUsed,NULL); + ReadFile(h,ioBuffer,sizeof(ioBuffer),&ioUsed,nullptr); for (;;) { if (ioCur==ioUsed) { - ReadFile(h,ioBuffer,sizeof(ioBuffer),&ioUsed,NULL); + ReadFile(h,ioBuffer,sizeof(ioBuffer),&ioUsed,nullptr); ioCur=0; } if (ioCur==ioUsed||ioBuffer[ioCur]=='\n'||ioBuffer[ioCur]=='\r') @@ -177,7 +189,7 @@ void Debug::PostStaticInit(void) if (p!=q) { Instance.ExecCommand(p,q); - p=*q?q+1:NULL; + p=*q?q+1:nullptr; } } } @@ -213,7 +225,7 @@ void Debug::StaticExit(void) if (io->io) { io->io->Delete(); - io->io=NULL; + io->io=nullptr; } // and command group interfaces... @@ -221,7 +233,7 @@ void Debug::StaticExit(void) if (cmd->cmdif) { cmd->cmdif->Delete(); - cmd->cmdif=NULL; + cmd->cmdif=nullptr; } } @@ -252,15 +264,36 @@ Debug::~Debug() // again, do not put any code in here } +#if defined(_MSC_VER) +// MSVC: Use SE Translator static void LocalSETranslator(unsigned, struct _EXCEPTION_POINTERS *pExPtrs) { // simply call our regular exception handler DebugExceptionhandler::ExceptionFilter(pExPtrs); } +#elif defined(__GNUC__) && defined(_WIN32) +// MinGW-w64: Use Vectored Exception Handler (Windows-only) +// Note: VEH is process-wide (unlike MSVC's per-thread _set_se_translator), +// but this matches the existing process-wide SetUnhandledExceptionFilter architecture. +// Returns EXCEPTION_CONTINUE_SEARCH to avoid interfering with normal exception handling. +static LONG WINAPI LocalVectoredExceptionHandler(struct _EXCEPTION_POINTERS *pExPtrs) +{ + // Call our regular exception handler + DebugExceptionhandler::ExceptionFilter(pExPtrs); + return EXCEPTION_CONTINUE_SEARCH; +} +#endif void Debug::InstallExceptionHandler(void) { +#if defined(_MSC_VER) _set_se_translator(LocalSETranslator); +#elif defined(__GNUC__) && defined(_WIN32) + // MinGW-w64 doesn't support _set_se_translator, use Vectored Exception Handler + AddVectoredExceptionHandler(1, LocalVectoredExceptionHandler); +#else + #error "Unsupported compiler for exception handling" +#endif } bool Debug::SkipNext(void) @@ -273,11 +306,23 @@ bool Debug::SkipNext(void) // do not implement this function inline, we do need // a valid frame pointer here! unsigned help; +#if defined(_MSC_VER) _asm { mov eax,[ebp+4] // return address mov help,eax }; +#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(_M_IX86)) + // GCC/Clang inline assembly for x86-32 + __asm__ __volatile__( + "mov 4(%%ebp), %0" + : "=r"(help) + : + : "memory" + ); +#else + #error "Unsupported compiler or architecture for inline assembly" +#endif curStackFrame=help; // do we know if to skip the following code? @@ -290,7 +335,7 @@ bool Debug::SkipNext(void) if (e->status==Unknown) Instance.UpdateFrameStatus(*e); - // now we now wether to skip or not + // now we now whether to skip or not return e->status==Skip; } @@ -304,7 +349,7 @@ Debug& Debug::AssertBegin(const char *file, int line, const char *expr) Instance.FlushOutput(); // set new output - __ASSERT(Instance.curFrameEntry==NULL); + __ASSERT(Instance.curFrameEntry==nullptr); Instance.curFrameEntry=Instance.GetFrameEntry(curStackFrame,FrameTypeAssert,file,line); if (Instance.curFrameEntry->status==NoSkip) { @@ -332,7 +377,7 @@ bool Debug::AssertDone(void) // did we have an active assertion? if (curType==DebugIOInterface::StringType::Assert) { - __ASSERT(curFrameEntry!=NULL); + __ASSERT(curFrameEntry!=nullptr); // hit info? if (curFrameEntry->hits>1) @@ -369,12 +414,12 @@ bool Debug::AssertDone(void) /// @todo replace MessageBox with custom dialog w/ 4 options: abort, skip 1, skip all, break // now display message, wait for user input - int result=MessageBox(NULL,help,"Assertion failed", + int result=MessageBox(nullptr,help,"Assertion failed", MB_ABORTRETRYIGNORE|MB_ICONSTOP|MB_TASKMODAL|MB_SETFOREGROUND); switch(result) { case IDABORT: - curFrameEntry=NULL; + curFrameEntry=nullptr; exit(1); break; case IDIGNORE: @@ -389,7 +434,13 @@ bool Debug::AssertDone(void) } break; case IDRETRY: +#if defined(_MSC_VER) _asm int 0x03 +#elif defined(__GNUC__) + __builtin_trap(); +#else + #error "Unsupported compiler for breakpoint" +#endif break; default: ((void)0); @@ -419,7 +470,7 @@ bool Debug::AssertDone(void) } } - curFrameEntry=NULL; + curFrameEntry=nullptr; return false; } @@ -433,7 +484,7 @@ Debug& Debug::CheckBegin(const char *file, int line, const char *expr) Instance.FlushOutput(); // set new output - __ASSERT(Instance.curFrameEntry==NULL); + __ASSERT(Instance.curFrameEntry==nullptr); Instance.curFrameEntry=Instance.GetFrameEntry(curStackFrame,FrameTypeCheck,file,line); if (Instance.curFrameEntry->status==NoSkip) { @@ -461,7 +512,7 @@ bool Debug::CheckDone(void) // did we have an active check? if (curType==DebugIOInterface::StringType::Check) { - __ASSERT(curFrameEntry!=NULL); + __ASSERT(curFrameEntry!=nullptr); // hit info? if (curFrameEntry->hits>1) @@ -502,7 +553,7 @@ bool Debug::CheckDone(void) } } - curFrameEntry=NULL; + curFrameEntry=nullptr; return false; } @@ -517,7 +568,7 @@ Debug& Debug::LogBegin(const char *fileOrGroup) Instance.FlushOutput(); // set new output - __ASSERT(Instance.curFrameEntry==NULL); + __ASSERT(Instance.curFrameEntry==nullptr); Instance.curFrameEntry=Instance.GetFrameEntry(curStackFrame,FrameTypeLog,fileOrGroup,0); if (Instance.curFrameEntry->status==NoSkip) { @@ -545,7 +596,7 @@ bool Debug::LogDone(void) // we're not flushing here on intention! - curFrameEntry=NULL; + curFrameEntry=nullptr; return false; } @@ -559,7 +610,7 @@ Debug& Debug::CrashBegin(const char *file, int line) Instance.FlushOutput(); // set new output - __ASSERT(Instance.curFrameEntry==NULL); + __ASSERT(Instance.curFrameEntry==nullptr); Instance.curFrameEntry=Instance.GetFrameEntry(curStackFrame,FrameTypeAssert,file,line); if (Instance.curFrameEntry->status==NoSkip) { @@ -589,7 +640,7 @@ bool Debug::CrashDone(bool die) // did we have an active assertion? if (curType==DebugIOInterface::StringType::Crash) { - __ASSERT(curFrameEntry!=NULL); + __ASSERT(curFrameEntry!=nullptr); // hit info? if (curFrameEntry->hits>1) @@ -637,12 +688,12 @@ bool Debug::CrashDone(bool die) /// @todo replace MessageBox with custom dialog w/ 4 options: abort, skip 1, skip all, break // now display message, wait for user input - int result=MessageBox(NULL,help,"Crash hit", + int result=MessageBox(nullptr,help,"Crash hit", MB_ABORTRETRYIGNORE|MB_ICONSTOP|MB_TASKMODAL|MB_SETFOREGROUND); switch(result) { case IDABORT: - curFrameEntry=NULL; + curFrameEntry=nullptr; exit(1); break; case IDIGNORE: @@ -657,7 +708,13 @@ bool Debug::CrashDone(bool die) } break; case IDRETRY: +#if defined(_MSC_VER) _asm int 0x03 +#elif defined(__GNUC__) + __builtin_trap(); +#else + #error "Unsupported compiler for breakpoint" +#endif break; default: ((void)0); @@ -689,14 +746,14 @@ bool Debug::CrashDone(bool die) else #endif { - MessageBox(NULL,help,"Game crash", + MessageBox(nullptr,help,"Game crash", MB_OK|MB_ICONSTOP|MB_TASKMODAL|MB_SETFOREGROUND); - curFrameEntry=NULL; + curFrameEntry=nullptr; _exit(1); } } - curFrameEntry=NULL; + curFrameEntry=nullptr; return false; } @@ -709,7 +766,7 @@ Debug& Debug::operator<<(const char *str) // buffer large enough? if (!str) - str="[NULL]"; + str="[null]"; else if (!*str) return *this; @@ -846,7 +903,7 @@ Debug& Debug::operator<<(const void *ptr) (*this) << "0x" << _ultoa((unsigned long)ptr,help,16); } else - (*this) << "NULL"; + (*this) << "null"; return *this; } @@ -1024,8 +1081,8 @@ bool Debug::AddIOFactory(const char *io_id, const char *descr, DebugIOInterface* entry->ioID=io_id; entry->descr=descr; entry->factory=func; - entry->io=NULL; - entry->input=NULL; + entry->io=nullptr; + entry->input=nullptr; entry->inputAlloc=0; entry->inputUsed=0; @@ -1054,7 +1111,7 @@ bool Debug::AddCommands(const char *cmdgroup, DebugCmdInterface *cmdif) // allocate & init new list entry CmdInterfaceListEntry *entry=(CmdInterfaceListEntry *) DebugAllocMemory(sizeof(CmdInterfaceListEntry)); - entry->next=NULL; + entry->next=nullptr; entry->group=cmdgroup; entry->cmdif=cmdif; @@ -1141,7 +1198,7 @@ void Debug::Update(void) Debug::FrameHashEntry* Debug::AddFrameEntry(unsigned addr, unsigned type, const char *fileOrGroup, int line) { - __ASSERT(LookupFrame(addr)==NULL); + __ASSERT(LookupFrame(addr)==nullptr); // get new entry if (!numAvailableFrameHash) @@ -1166,12 +1223,12 @@ Debug::FrameHashEntry* Debug::AddFrameEntry(unsigned addr, unsigned type, { // must add to list of known logs, // store translated name - e->fileOrGroup=AddLogGroup(fileOrGroup,NULL); + e->fileOrGroup=AddLogGroup(fileOrGroup,nullptr); } else { // no, just add file name (without path though) - e->fileOrGroup=fileOrGroup?strrchr(fileOrGroup,'\\'):NULL; + e->fileOrGroup=fileOrGroup?strrchr(fileOrGroup,'\\'):nullptr; e->fileOrGroup=e->fileOrGroup?e->fileOrGroup+1:fileOrGroup; } @@ -1348,7 +1405,7 @@ void Debug::FlushOutput(bool defaultLog) cur->io->Write(curType,curSource,ioBuffer[curType].buffer); if (alwaysFlush) - cur->io->Write(curType,curSource,NULL); + cur->io->Write(curType,curSource,nullptr); } // written nowhere? @@ -1357,11 +1414,11 @@ void Debug::FlushOutput(bool defaultLog) #ifdef HAS_LOGS // then force output to a very simple default log file // (non-Release builds only) - HANDLE h=CreateFile("default.log",GENERIC_WRITE,0,NULL, - OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL); - SetFilePointer(h,0,NULL,FILE_END); + HANDLE h=CreateFile("default.log",GENERIC_WRITE,0,nullptr, + OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,nullptr); + SetFilePointer(h,0,nullptr,FILE_END); DWORD dwDummy; - WriteFile(h,ioBuffer[curType].buffer,strlen(ioBuffer[curType].buffer),&dwDummy,NULL); + WriteFile(h,ioBuffer[curType].buffer,strlen(ioBuffer[curType].buffer),&dwDummy,nullptr); CloseHandle(h); #endif } @@ -1382,7 +1439,7 @@ void Debug::AddPatternEntry(unsigned types, bool isActive, const char *pattern) DebugAllocMemory(sizeof(PatternListEntry)); // init - cur->next=NULL; + cur->next=nullptr; cur->frameTypes=types; cur->isActive=isActive; cur->pattern=(char *)DebugAllocMemory(strlen(pattern)+1); @@ -1464,7 +1521,7 @@ void Debug::ExecCommand(const char *cmdstart, const char *cmdend) // just dropping the excess arguments char *parts[100]; int numParts=0; - char *lastNonWhitespace=NULL; + char *lastNonWhitespace=nullptr; char *cur=strbuf; // regular reply or structured reply? @@ -1504,7 +1561,7 @@ void Debug::ExecCommand(const char *cmdstart, const char *cmdend) { if (numParts0; // find main app window - HWND appHWnd=NULL; + HWND appHWnd=nullptr; EnumThreadWindows(GetCurrentThreadId(),EnumThreadWndProc,(LPARAM)&appHWnd); if (!appHWnd) { diff --git a/Core/Libraries/Source/debug/debug_debug.h b/Core/Libraries/Source/debug/debug_debug.h index 956fa6f2299..f49104985e2 100644 --- a/Core/Libraries/Source/debug/debug_debug.h +++ b/Core/Libraries/Source/debug/debug_debug.h @@ -365,7 +365,7 @@ DLOG( "My HResult is: " << Debug::HResult(SomeHRESULTValue) << "\n" ); \param file file that contains DASSERT or DASSERT_MSG macro \param line line where assert macro can be found - \param expr expression that triggered the assertion, NULL for 'general failure' (\ref DFAIL) + \param expr expression that triggered the assertion, nullptr for 'general failure' (\ref DFAIL) \return reference to Debug instance */ static Debug &AssertBegin(const char *file, int line, const char *expr); @@ -439,7 +439,7 @@ DLOG( "My HResult is: " << Debug::HResult(SomeHRESULTValue) << "\n" ); Starts building the crash string which will then be send to the active output destinations. - \param file file that contains DCRASH or DCRASH_RELEASE macro, if NULL + \param file file that contains DCRASH or DCRASH_RELEASE macro, if nullptr then no file info is given (used by DCRASH_RELEASE in release builds) \param line line where crash macro can be found, 0 if no line info should @@ -731,6 +731,12 @@ DLOG( "My HResult is: " << Debug::HResult(SomeHRESULTValue) << "\n" ); void WriteBuildInfo(void); private: +#if defined(__GNUC__) && defined(_WIN32) + // For GCC/MinGW-w64 targeting Windows, allow constructor functions to call init methods + friend void GccPreStaticInit(); + friend void GccPostStaticInit(); +#endif + // no assignment, no copy constructor Debug(const Debug&); Debug& operator=(const Debug&); @@ -738,7 +744,7 @@ DLOG( "My HResult is: " << Debug::HResult(SomeHRESULTValue) << "\n" ); /** \internal Undocumented default constructor. Initializes debugging library. - We can make this private as well so nobody accidently tries to create + We can make this private as well so nobody accidentally tries to create a Debug instance. Actually this function does not do anything - initialization is rather performed by PreStaticInit() and PostStaticInit(). @@ -823,7 +829,7 @@ DLOG( "My HResult is: " << Debug::HResult(SomeHRESULTValue) << "\n" ); /// factory function DebugIOInterface* (*factory)(void); - /// I/O interface (may be NULL) + /// I/O interface (may be null) DebugIOInterface *io; /// input buffer @@ -1040,7 +1046,7 @@ DLOG( "My HResult is: " << Debug::HResult(SomeHRESULTValue) << "\n" ); Returns translated group name. \param fileOrGroup file or log group - \param descr description, may be NULL + \param descr description, may be nullptr \return translated log group name */ const char *AddLogGroup(const char *fileOrGroup, const char *descr); diff --git a/Core/Libraries/Source/debug/debug_dlg/debug_dlg.cpp b/Core/Libraries/Source/debug/debug_dlg/debug_dlg.cpp index c1e7c164570..2a0645f4592 100644 --- a/Core/Libraries/Source/debug/debug_dlg/debug_dlg.cpp +++ b/Core/Libraries/Source/debug/debug_dlg/debug_dlg.cpp @@ -138,7 +138,7 @@ BOOL CALLBACK DialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) hf=CreateFont(13,0,0,0,FW_NORMAL, FALSE,FALSE,FALSE,ANSI_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY,FIXED_PITCH|FF_MODERN,NULL); + DEFAULT_QUALITY,FIXED_PITCH|FF_MODERN,nullptr); SendDlgItemMessage(hWnd,105,WM_SETFONT,(WPARAM)hf,MAKELPARAM(TRUE,0)); SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"EAX:0x00000666 EBX:0x7ffdf000 ECX:0x00000000"); SendDlgItemMessage(hWnd,105,LB_ADDSTRING,0,(LPARAM)"EDX:0x00422208 ESI:0x02100210 EDI:0x0012fec4"); @@ -180,7 +180,7 @@ int CALLBACK WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, int) { // show dialog box first InitCommonControls(); - DialogBox(hInst,MAKEINTRESOURCE(100),NULL,DialogProc); + DialogBox(hInst,MAKEINTRESOURCE(100),nullptr,DialogProc); // write out resource data (if possible) FILE *f=fopen("..\\rc_exception.inl","wt"); diff --git a/Core/Libraries/Source/debug/debug_except.cpp b/Core/Libraries/Source/debug/debug_except.cpp index 098e1b9bf81..8a90948733f 100644 --- a/Core/Libraries/Source/debug/debug_except.cpp +++ b/Core/Libraries/Source/debug/debug_except.cpp @@ -172,17 +172,13 @@ void DebugExceptionhandler::LogFPURegisters(Debug &dbg, struct _EXCEPTION_POINTE for (unsigned i=0;i<10;i++) dbg << Debug::Width(2) << value[i]; - double fpVal; + // TheSuperHackers @refactor Replaced MSVC inline assembly with portable C++ cast for MinGW compatibility + // Convert from temporary real (10 byte) to double (8 bytes). + // On x86, long double is the 10-byte x87 format, so we can just cast. + double fpVal = (double)(*(long double*)value); + dbg << " " << fpVal; - // convert from temporary real (10 byte) to double - _asm - { - mov eax,value - fld tbyte ptr [eax] - fstp qword ptr [fpVal] - } - - dbg << " " << fpVal << "\n"; + dbg << "\n"; } dbg << Debug::FillChar() << Debug::Dec(); } @@ -235,7 +231,7 @@ static BOOL CALLBACK ExceptionDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA SendDlgItemMessage(hWnd,105,WM_SETFONT,(WPARAM)CreateFont(13,0,0,0,FW_NORMAL, FALSE,FALSE,FALSE,ANSI_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY,FIXED_PITCH|FF_MODERN,NULL),MAKELPARAM(TRUE,0)); + DEFAULT_QUALITY,FIXED_PITCH|FF_MODERN,nullptr),MAKELPARAM(TRUE,0)); // exception type SendDlgItemMessage(hWnd,100,WM_SETTEXT,0,(LPARAM) @@ -324,19 +320,19 @@ static BOOL CALLBACK ExceptionDlgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA ListView_SetItem(list,&item); item.iSubItem++; - item.pszText=strtok(NULL,","); + item.pszText=strtok(nullptr,","); ListView_SetItem(list,&item); item.iSubItem++; - item.pszText=strtok(NULL,","); + item.pszText=strtok(nullptr,","); ListView_SetItem(list,&item); item.iSubItem++; - item.pszText=strtok(NULL,":"); + item.pszText=strtok(nullptr,":"); ListView_SetItem(list,&item); item.iSubItem++; - item.pszText=strtok(NULL,""); + item.pszText=strtok(nullptr,""); ListView_SetItem(list,&item); } } @@ -350,7 +346,7 @@ LONG __stdcall DebugExceptionhandler::ExceptionFilter(struct _EXCEPTION_POINTERS static bool inExceptionFilter; if (inExceptionFilter) { - MessageBox(NULL,"Exception in exception handler","Fatal error",MB_OK); + MessageBox(nullptr,"Exception in exception handler","Fatal error",MB_OK); return EXCEPTION_CONTINUE_SEARCH; } inExceptionFilter=true; @@ -411,7 +407,7 @@ LONG __stdcall DebugExceptionhandler::ExceptionFilter(struct _EXCEPTION_POINTERS // Show a dialog box InitCommonControls(); exPtrs=pExPtrs; - DialogBoxIndirect(NULL,(LPDLGTEMPLATE)rcException,NULL,ExceptionDlgProc); + DialogBoxIndirect(NULL,(LPDLGTEMPLATE)rcException,nullptr,ExceptionDlgProc); // Now die return EXCEPTION_EXECUTE_HANDLER; diff --git a/Core/Libraries/Source/debug/debug_internal.cpp b/Core/Libraries/Source/debug/debug_internal.cpp index 0f610562327..91ce90f1429 100644 --- a/Core/Libraries/Source/debug/debug_internal.cpp +++ b/Core/Libraries/Source/debug/debug_internal.cpp @@ -26,6 +26,7 @@ // // Implementation of internal code ////////////////////////////////////////////////////////////////////////////// + #include "debug.h" #include @@ -35,7 +36,7 @@ void DebugInternalAssert(const char *file, int line, const char *expr) // module only we know how long stuff can get char buf[512]; wsprintf(buf,"File %s, line %i:\n%s",file,line,expr); - MessageBox(NULL,buf,"Internal assert failed", + MessageBox(nullptr,buf,"Internal assert failed", MB_OK|MB_ICONSTOP|MB_TASKMODAL|MB_SETFOREGROUND); // stop right now! @@ -52,15 +53,15 @@ void *DebugAllocMemory(unsigned numBytes) void *DebugReAllocMemory(void *oldPtr, unsigned newSize) { - // Windows doesn't like ReAlloc with NULL handle/ptr... + // Windows doesn't like ReAlloc with null handle/ptr... if (!oldPtr) - return newSize?DebugAllocMemory(newSize):0; + return newSize?DebugAllocMemory(newSize):nullptr; // Shrinking to 0 size is basically freeing memory if (!newSize) { GlobalFree((HGLOBAL)oldPtr); - return 0; + return nullptr; } // now try GlobalReAlloc first diff --git a/Core/Libraries/Source/debug/debug_io.h b/Core/Libraries/Source/debug/debug_io.h index f1d14a7ec5e..47a0681008f 100644 --- a/Core/Libraries/Source/debug/debug_io.h +++ b/Core/Libraries/Source/debug/debug_io.h @@ -106,19 +106,19 @@ class DebugIOInterface \brief Write out some characters differentiated by the log string type. \param type possible string type - \param src string source, may be NULL, content depends on type: + \param src string source, may be nullptr, content depends on type: - + - +
typesrc
Assertfile(line)
Checkfile(line)
Loglog group
Crashfile(line)
ExceptionNULL
Exceptionnullptr
CmdReplygroup.command
StructuredCmdReplygroup.command
OtherNULLOthernullptr
- \param str string to output, NUL delimited, if NULL then simply flush + \param str string to output, NUL delimited, if nullptr then simply flush output (if applicable) */ virtual void Write(StringType type, const char *src, const char *str)=0; diff --git a/Core/Libraries/Source/debug/debug_io_con.cpp b/Core/Libraries/Source/debug/debug_io_con.cpp index 0b9c2d605e7..bbd3d07974a 100644 --- a/Core/Libraries/Source/debug/debug_io_con.cpp +++ b/Core/Libraries/Source/debug/debug_io_con.cpp @@ -26,6 +26,7 @@ // // Debug I/O class con (console window) ////////////////////////////////////////////////////////////////////////////// + #include "debug.h" #include "internal.h" #include "internal_io.h" @@ -59,7 +60,7 @@ DebugIOCon::DebugIOCon(void): ci.bVisible=FALSE; SetConsoleCursorInfo(h,&ci); - Write(StringType::Other,NULL,"\n\nEA/Debug console open\n\n"); + Write(StringType::Other,nullptr,"\n\nEA/Debug console open\n\n"); } } @@ -188,7 +189,7 @@ void DebugIOCon::Write(StringType type, const char *src, const char *str) return; DWORD dwDummy; - WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),str,strlen(str),&dwDummy,NULL); + WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),str,strlen(str),&dwDummy,nullptr); } void DebugIOCon::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, diff --git a/Core/Libraries/Source/debug/debug_io_flat.cpp b/Core/Libraries/Source/debug/debug_io_flat.cpp index 7e7d00ca63c..35348073535 100644 --- a/Core/Libraries/Source/debug/debug_io_flat.cpp +++ b/Core/Libraries/Source/debug/debug_io_flat.cpp @@ -26,6 +26,7 @@ // // Debug I/O class flat (flat or split log file) ////////////////////////////////////////////////////////////////////////////// + #include "debug.h" #include "debug_io.h" #include "internal.h" @@ -46,9 +47,9 @@ DebugIOFlat::OutputStream::OutputStream(const char *filename, unsigned maxSize): m_buffer=(char *)DebugAllocMemory(m_bufferSize); if (!m_limitedFileSize) - m_fileHandle=CreateFile(m_fileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS, + m_fileHandle=CreateFile(m_fileName,GENERIC_WRITE,0,nullptr,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_WRITE_THROUGH, - NULL); + nullptr); } DebugIOFlat::OutputStream::~OutputStream() @@ -173,22 +174,22 @@ void DebugIOFlat::OutputStream::Flush(void) { // simple flush to file DWORD written; - WriteFile(m_fileHandle,m_buffer,m_bufferUsed,&written,NULL); + WriteFile(m_fileHandle,m_buffer,m_bufferUsed,&written,nullptr); m_bufferUsed=0; } else { // create file, write ring buffer - m_fileHandle=CreateFile(m_fileName,GENERIC_WRITE,0,NULL,CREATE_ALWAYS, + m_fileHandle=CreateFile(m_fileName,GENERIC_WRITE,0,nullptr,CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL|FILE_FLAG_WRITE_THROUGH, - NULL); + nullptr); DWORD written; if (m_bufferUsednext; DebugFreeMemory(kill); } - m_firstSplit=NULL; + m_firstSplit=nullptr; for (StreamListEntry *stream=m_firstStream;stream;) { @@ -414,15 +415,15 @@ void DebugIOFlat::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, else if (strcmp(cmd,"add") == 0) { // add [ [ ] ] - __ASSERT(m_firstStream==NULL); + __ASSERT(m_firstStream==nullptr); strlcpy(m_baseFilename, argn?argv[0]:"*eMN", ARRAY_SIZE(m_baseFilename)); char fn[256]; - ExpandMagic(m_baseFilename,NULL,fn); + ExpandMagic(m_baseFilename,nullptr,fn); m_firstStream=(StreamListEntry *)DebugAllocMemory(sizeof(StreamListEntry)); - m_firstStream->next=NULL; + m_firstStream->next=nullptr; m_firstStream->stream=OutputStream::Create(fn,argn>1?atoi(argv[1])*1024:0); m_lastStreamPtr=&m_firstStream->next; } @@ -476,7 +477,7 @@ void DebugIOFlat::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, { // must create new stream stream=(StreamListEntry *)DebugAllocMemory(sizeof(StreamListEntry)); - stream->next=NULL; + stream->next=nullptr; *m_lastStreamPtr=stream; m_lastStreamPtr=&stream->next; stream->stream=OutputStream::Create(fn,argn>3?atoi(argv[3])*1024:0); @@ -532,7 +533,7 @@ void DebugIOFlat::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, m_firstSplit=cur; } else - m_firstSplit=NULL; + m_firstSplit=nullptr; } } diff --git a/Core/Libraries/Source/debug/debug_io_net.cpp b/Core/Libraries/Source/debug/debug_io_net.cpp index 52e31661021..37ecc4c1669 100644 --- a/Core/Libraries/Source/debug/debug_io_net.cpp +++ b/Core/Libraries/Source/debug/debug_io_net.cpp @@ -26,6 +26,7 @@ // // Debug I/O class net (Network destination via named pipe) ////////////////////////////////////////////////////////////////////////////// + #include "debug.h" #include "internal.h" #include "internal_io.h" @@ -48,13 +49,13 @@ int DebugIONet::Read(char *buf, int maxchar) return 0; DWORD mode=PIPE_READMODE_MESSAGE|PIPE_NOWAIT; - SetNamedPipeHandleState(m_pipe,&mode,NULL,NULL); + SetNamedPipeHandleState(m_pipe,&mode,nullptr,nullptr); DWORD read; - if (!ReadFile(m_pipe,buf,maxchar-1,&read,NULL)) + if (!ReadFile(m_pipe,buf,maxchar-1,&read,nullptr)) read=0; mode=PIPE_READMODE_MESSAGE|PIPE_WAIT; - SetNamedPipeHandleState(m_pipe,&mode,NULL,NULL); + SetNamedPipeHandleState(m_pipe,&mode,nullptr,nullptr); return read; } @@ -65,18 +66,18 @@ void DebugIONet::Write(StringType type, const char *src, const char *str) return; DWORD dummy; - WriteFile(m_pipe,&type,1,&dummy,NULL); + WriteFile(m_pipe,&type,1,&dummy,nullptr); unsigned len; len=src?strlen(src):0; - WriteFile(m_pipe,&len,4,&dummy,NULL); + WriteFile(m_pipe,&len,4,&dummy,nullptr); if (len) - WriteFile(m_pipe,src,len,&dummy,NULL); + WriteFile(m_pipe,src,len,&dummy,nullptr); len=strlen(str); - WriteFile(m_pipe,&len,4,&dummy,NULL); + WriteFile(m_pipe,&len,4,&dummy,nullptr); if (len) - WriteFile(m_pipe,str,len,&dummy,NULL); + WriteFile(m_pipe,str,len,&dummy,nullptr); } void DebugIONet::EmergencyFlush(void) @@ -99,7 +100,7 @@ void DebugIONet::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, char buf[256]; wsprintf(buf,"\\\\%s\\pipe\\ea_debug_v1",machine); m_pipe=CreateFile(buf,GENERIC_READ|GENERIC_WRITE, - 0,NULL,OPEN_EXISTING,0,NULL); + 0,nullptr,OPEN_EXISTING,0,nullptr); if (m_pipe==INVALID_HANDLE_VALUE) { dbg << "Could not connect to given machine.\n"; @@ -108,14 +109,14 @@ void DebugIONet::Execute(class Debug& dbg, const char *cmd, bool structuredCmd, // we're reading messages DWORD mode=PIPE_READMODE_MESSAGE; - SetNamedPipeHandleState(m_pipe,&mode,NULL,NULL); + SetNamedPipeHandleState(m_pipe,&mode,nullptr,nullptr); // write welcome message char comp[128]; mode=sizeof(comp); GetComputerName(comp,&mode); wsprintf(buf,"Client at %s\n",comp); - Write(Other,NULL,buf); + Write(Other,nullptr,buf); } } diff --git a/Core/Libraries/Source/debug/debug_macro.h b/Core/Libraries/Source/debug/debug_macro.h index b4b0f074008..b24f9d3b40d 100644 --- a/Core/Libraries/Source/debug/debug_macro.h +++ b/Core/Libraries/Source/debug/debug_macro.h @@ -153,7 +153,7 @@ if (!DCHECK_MSG(!(cond),msg)) \endcode so it can be used e.g. like this: \code -DFAIL_IF_MSG(!ptrval,"pointer must not be NULL") return; +DFAIL_IF_MSG(!ptrval,"pointer must not be null") return; \endcode \param cond condition which is checked for failure @@ -188,7 +188,7 @@ DFAIL_IF_MSG(!ptrval,"pointer must not be NULL") return; Works just like \ref DLOG but instead of using the current file as a logging group the logging group is explicitly specified. - \note Specifiy the group directly without quotes, e.g. + \note Specify the group directly without quotes, e.g. \code DLOG_GROUP(my_log_group,"hello world") \endcode @@ -328,7 +328,7 @@ DFAIL_IF_MSG(!ptrval,"pointer must not be NULL") return; (Debug::SkipNext(),(Debug::CrashBegin(__FILE__,__LINE__) << msg).CrashDone(true)) #define DFAIL() \ - Debug::AssertBegin(__FILE__,__LINE__,NULL).AssertDone() + Debug::AssertBegin(__FILE__,__LINE__,nullptr).AssertDone() #define D_ISLOG() \ Debug::IsLogEnabled(__FILE__) @@ -349,7 +349,7 @@ DFAIL_IF_MSG(!ptrval,"pointer must not be NULL") return; #define DLOG_GROUP(group,what) ((void)0) #define DLOG_GROUP_DESCR(g,d) #define DCRASH(msg) ((void)0) - #define DCRASH_RELEASE(msg) (Debug::SkipNext(),(Debug::CrashBegin(NULL,0) << msg).CrashDone(true)) + #define DCRASH_RELEASE(msg) (Debug::SkipNext(),(Debug::CrashBegin(nullptr,0) << msg).CrashDone(true)) #define DFAIL() ((void)0) #define D_ISLOG() false #define D_ISLOG_GROUP(group) false diff --git a/Core/Libraries/Source/debug/debug_stack.cpp b/Core/Libraries/Source/debug/debug_stack.cpp index 58645661339..71d99058137 100644 --- a/Core/Libraries/Source/debug/debug_stack.cpp +++ b/Core/Libraries/Source/debug/debug_stack.cpp @@ -26,6 +26,7 @@ // // Stack walker ////////////////////////////////////////////////////////////////////////////// + #include "debug.h" #include "debug_stack.h" #include @@ -53,7 +54,7 @@ static union static char const *const DebughelpFunctionNames[] = { #include "debug_stack.inl" - NULL + nullptr }; #undef DBGHELP @@ -71,7 +72,7 @@ static void InitDbghelp(void) // firstly check for dbghelp.dll in the EXE directory char dbgHelpPath[256]; - if (GetModuleFileName(NULL,dbgHelpPath,sizeof(dbgHelpPath))) + if (GetModuleFileName(nullptr,dbgHelpPath,sizeof(dbgHelpPath))) { char *slash=strrchr(dbgHelpPath,'\\'); if (slash) @@ -100,7 +101,7 @@ static void InitDbghelp(void) { // not all functions found -> clear them all while (funcptr!=gDbg.funcPtr) - *--funcptr=NULL; + *--funcptr=0; } else { @@ -108,7 +109,7 @@ static void InitDbghelp(void) gDbg._SymSetOptions(gDbg._SymGetOptions()|SYMOPT_DEFERRED_LOADS|SYMOPT_LOAD_LINES); // Init module - gDbg._SymInitialize((HANDLE)GetCurrentProcessId(),NULL,TRUE); + gDbg._SymInitialize((HANDLE)GetCurrentProcessId(),nullptr,TRUE); // Check: are we using a newer version of dbghelp.dll? // (older versions have some serious issues.. err... bugs) @@ -363,6 +364,7 @@ int DebugStackwalk::StackWalk(Signature &sig, struct _CONTEXT *ctx) { // walk stack back using current call chain unsigned long reg_eip, reg_ebp, reg_esp; +#if defined(_MSC_VER) __asm { here: @@ -371,6 +373,17 @@ int DebugStackwalk::StackWalk(Signature &sig, struct _CONTEXT *ctx) mov reg_ebp,ebp mov reg_esp,esp }; +#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(_M_IX86)) + __asm__ __volatile__ ( + "call 1f\n\t" + "1: pop %0\n\t" + "mov %%ebp, %1\n\t" + "mov %%esp, %2" + : "=r" (reg_eip), "=r" (reg_ebp), "=r" (reg_esp) + ); +#else +#error "Unsupported compiler or architecture for register capture" +#endif stackFrame.AddrPC.Offset = reg_eip; stackFrame.AddrStack.Offset = reg_esp; stackFrame.AddrFrame.Offset = reg_ebp; @@ -380,7 +393,7 @@ int DebugStackwalk::StackWalk(Signature &sig, struct _CONTEXT *ctx) bool skipFirst=!ctx; while (sig.m_numAddr\n",11,&dwDummy,NULL); + WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),"\n\n",11,&dwDummy,nullptr); m_connected=true; m_state=0; } @@ -203,13 +203,13 @@ class Pipe void Write(char msg) { DWORD dummy; - if (!WriteFile(m_pipe,&msg,1,&dummy,NULL)||!dummy) + if (!WriteFile(m_pipe,&msg,1,&dummy,nullptr)||!dummy) { char sp[30]; wsprintf(sp,"%c:%i/%i\n",msg,dummy,GetLastError()); DWORD dwDummy; - WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),sp,strlen(sp),&dwDummy,NULL); + WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),sp,strlen(sp),&dwDummy,nullptr); } } @@ -219,14 +219,14 @@ class Pipe switch(m_state) { case 0: - if (!ReadFile(m_pipe,&m_stringType,1,&read,NULL)) + if (!ReadFile(m_pipe,&m_stringType,1,&read,nullptr)) break; if (read==1) m_state++; - return NULL; + return nullptr; case 1: case 3: - if (!ReadFile(m_pipe,&m_len,4,&read,NULL)) + if (!ReadFile(m_pipe,&m_len,4,&read,nullptr)) break; if (read==4) { @@ -236,18 +236,18 @@ class Pipe m_str=(char *)realloc(m_str,m_len+1); m_state++; } - return NULL; + return nullptr; case 2: - if (!ReadFile(m_pipe,m_src,m_len,&read,NULL)) + if (!ReadFile(m_pipe,m_src,m_len,&read,nullptr)) break; if (read==m_len) { m_src[m_len]=0; m_state++; } - return NULL; + return nullptr; case 4: - if (!ReadFile(m_pipe,m_str,m_len,&read,NULL)) + if (!ReadFile(m_pipe,m_str,m_len,&read,nullptr)) break; if (read==m_len) { @@ -255,7 +255,7 @@ class Pipe m_state=0; return m_str; } - return NULL; + return nullptr; } if (GetLastError()==ERROR_BROKEN_PIPE) @@ -263,11 +263,11 @@ class Pipe DisconnectNamedPipe(m_pipe); DWORD dwDummy; - WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),"\n\n",14,&dwDummy,NULL); + WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),"\n\n",14,&dwDummy,nullptr); m_connected=false; } - return NULL; + return nullptr; } }; @@ -280,7 +280,7 @@ int CALLBACK WinMain(HINSTANCE,HINSTANCE,LPSTR,int) GetComputerName(buf1,&dwDummy); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),buf2, wsprintf(buf2,"\n\nSimple debug.net Server ready. Enter 'quit' to exit.\n\nLocal machine: %s\n\n",buf1), - &dwDummy,NULL); + &dwDummy,nullptr); Pipe p[10]; for (int k=0;k<10;k++) @@ -288,7 +288,7 @@ int CALLBACK WinMain(HINSTANCE,HINSTANCE,LPSTR,int) { char msg[200]; wsprintf(msg,"Can't create named pipe (Code %i).",GetLastError()); - MessageBox(NULL,msg,"Error",MB_OK); + MessageBox(nullptr,msg,"Error",MB_OK); return 1; } @@ -310,7 +310,7 @@ int CALLBACK WinMain(HINSTANCE,HINSTANCE,LPSTR,int) if (msg) { DWORD dwDummy; - WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),msg,strlen(msg),&dwDummy,NULL); + WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),msg,strlen(msg),&dwDummy,nullptr); } if (input) diff --git a/Core/Libraries/Source/debug/test2/test2.cpp b/Core/Libraries/Source/debug/test2/test2.cpp index 0980746ec03..70756043f12 100644 --- a/Core/Libraries/Source/debug/test2/test2.cpp +++ b/Core/Libraries/Source/debug/test2/test2.cpp @@ -54,7 +54,7 @@ class TestCmdInterface: public DebugCmdInterface if (strcmp(cmd,"box") != 0) return false; - MessageBox(NULL,"Hello world!","Command",MB_OK); + MessageBox(nullptr,"Hello world!","Command",MB_OK); return true; } @@ -89,7 +89,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, Debug::Command("debug.io ; send via EXE, try test.box!"); // Main message loop: - while (GetMessage(&msg, NULL, 0, 0)) + while (GetMessage(&msg, nullptr, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { @@ -128,7 +128,7 @@ ATOM MyRegisterClass(HINSTANCE hInstance) wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_TEST2); - wcex.hCursor = LoadCursor(NULL, IDC_ARROW); + wcex.hCursor = LoadCursor(nullptr, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = (LPCSTR)IDC_TEST2; wcex.lpszClassName = szWindowClass; @@ -154,7 +154,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); + CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, nullptr, nullptr, hInstance, nullptr); if (!hWnd) { @@ -162,7 +162,7 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) } // create a timer for calling Debug::Update - SetTimer(hWnd,1,100,NULL); + SetTimer(hWnd,1,100,nullptr); ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); @@ -226,7 +226,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return 0; } -// Mesage handler for about box. +// Message handler for about box. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) diff --git a/Core/Libraries/Source/profile/CMakeLists.txt b/Core/Libraries/Source/profile/CMakeLists.txt index e2457d80389..5fee2d17b0e 100644 --- a/Core/Libraries/Source/profile/CMakeLists.txt +++ b/Core/Libraries/Source/profile/CMakeLists.txt @@ -25,13 +25,13 @@ target_include_directories(core_profile INTERFACE ) target_precompile_headers(core_profile PRIVATE + [["Utility/CppMacros.h"]] # Must be first, to be removed when abandoning VC6 "profile.h" "internal.h" ) target_link_libraries(core_profile PRIVATE - core_config core_wwcommon corei_always ) diff --git a/Core/Libraries/Source/profile/internal.h b/Core/Libraries/Source/profile/internal.h index b80d223baae..9d418018d85 100644 --- a/Core/Libraries/Source/profile/internal.h +++ b/Core/Libraries/Source/profile/internal.h @@ -34,7 +34,6 @@ #include "internal_highlevel.h" #include "internal_cmd.h" #include "internal_result.h" -#include "Utility/CppMacros.h" #include #if !(defined(_MSC_VER) && _MSC_VER < 1300) @@ -87,7 +86,7 @@ class ProfileFastCS } #else - volatile std::atomic_flag Flag{}; + std::atomic_flag Flag{}; void ThreadSafeSetFlag() { diff --git a/Core/Libraries/Source/profile/internal_funclevel.h b/Core/Libraries/Source/profile/internal_funclevel.h index e9229dbf22c..7d920f9832b 100644 --- a/Core/Libraries/Source/profile/internal_funclevel.h +++ b/Core/Libraries/Source/profile/internal_funclevel.h @@ -176,7 +176,7 @@ class ProfileFuncLevelTracer glob.tracer=tr; for (int k=0;knext) if (e->funcPtr->addr==addr) return e->funcPtr; - return NULL; + return nullptr; } diff --git a/Core/Libraries/Source/profile/internal_highlevel.h b/Core/Libraries/Source/profile/internal_highlevel.h index 2d9c572755e..f6f098ad147 100644 --- a/Core/Libraries/Source/profile/internal_highlevel.h +++ b/Core/Libraries/Source/profile/internal_highlevel.h @@ -57,7 +57,7 @@ class ProfileId /** Retrieves next profile ID. - \return next profile ID, NULL if none + \return next profile ID, nullptr if none */ ProfileId *GetNext(void) const { return m_next; } diff --git a/Core/Libraries/Source/profile/internal_result.h b/Core/Libraries/Source/profile/internal_result.h index a62f082a394..50ad507f8c3 100644 --- a/Core/Libraries/Source/profile/internal_result.h +++ b/Core/Libraries/Source/profile/internal_result.h @@ -66,7 +66,7 @@ class ProfileResultFileDOT: public ProfileResultInterface \brief Creates a class instance. \param fileName name of DOT file to generate (defaults to profile.dot) - \param frameName name of frame to use (NULL for global) + \param frameName name of frame to use (null for global) \param foldThreshold if the number of functions exceeds the given threshold then all functions belonging to the same source file will be folded into a single entry diff --git a/Core/Libraries/Source/profile/profile.cpp b/Core/Libraries/Source/profile/profile.cpp index 66981103b79..36a4ada2575 100644 --- a/Core/Libraries/Source/profile/profile.cpp +++ b/Core/Libraries/Source/profile/profile.cpp @@ -26,6 +26,7 @@ // // Profile module main code ////////////////////////////////////////////////////////////////////////////// + #include "profile.h" #include "internal.h" #include @@ -50,15 +51,15 @@ void *ProfileAllocMemory(unsigned numBytes) void *ProfileReAllocMemory(void *oldPtr, unsigned newSize) { - // Windows doesn't like ReAlloc with NULL handle/ptr... + // Windows doesn't like ReAlloc with null handle/ptr... if (!oldPtr) - return newSize?ProfileAllocMemory(newSize):0; + return newSize?ProfileAllocMemory(newSize):nullptr; // Shrinking to 0 size is basically freeing memory if (!newSize) { GlobalFree((HGLOBAL)oldPtr); - return 0; + return nullptr; } // now try GlobalReAlloc first @@ -323,7 +324,7 @@ unsigned Profile::GetFrameCount(void) const char *Profile::GetFrameName(unsigned frame) { - return frame>=m_rec?NULL:m_recNames[frame]; + return frame>=m_rec?nullptr:m_recNames[frame]; } void Profile::ClearTotals(void) diff --git a/Core/Libraries/Source/profile/profile.h b/Core/Libraries/Source/profile/profile.h index 92dde861b86..b087c8a6fa5 100644 --- a/Core/Libraries/Source/profile/profile.h +++ b/Core/Libraries/Source/profile/profile.h @@ -50,7 +50,7 @@ class Profile /** \brief Starts range recording. - \param range name of range to record, ==NULL for "frame" + \param range name of range to record, == nullptr for "frame" */ static void StartRange(const char *range=0); @@ -58,7 +58,7 @@ class Profile \brief Appends profile data to the last recorded frame of the given range. - \param range name of range to record, ==NULL for "frame" + \param range name of range to record, == nullptr for "frame" */ static void AppendRange(const char *range=0); @@ -68,7 +68,7 @@ class Profile \note After this call the recorded range data will be available as a new range frame. - \param range name of range to record, ==NULL for "frame" + \param range name of range to record, == nullptr for "frame" */ static void StopRange(const char *range=0); diff --git a/Core/Libraries/Source/profile/profile_cmd.cpp b/Core/Libraries/Source/profile/profile_cmd.cpp index 5eb0ef643f4..6fdeb4cf1e5 100644 --- a/Core/Libraries/Source/profile/profile_cmd.cpp +++ b/Core/Libraries/Source/profile/profile_cmd.cpp @@ -26,6 +26,7 @@ // // Profile module command interface ////////////////////////////////////////////////////////////////////////////// + #include "profile.h" #include "internal.h" @@ -211,7 +212,7 @@ bool ProfileCmdInterface::Execute(class Debug& dbg, const char *cmd, CommandMode Profile::lastPatternEntry=cur; } else - Profile::lastPatternEntry=NULL; + Profile::lastPatternEntry=nullptr; return true; } @@ -228,7 +229,7 @@ bool ProfileCmdInterface::Execute(class Debug& dbg, const char *cmd, CommandMode ProfileAllocMemory(sizeof(Profile::PatternListEntry)); // init - cur->next=NULL; + cur->next=nullptr; cur->isActive=*argv[0]=='+'; cur->pattern=(char *)ProfileAllocMemory(strlen(argv[1])+1); strcpy(cur->pattern,argv[1]); diff --git a/Core/Libraries/Source/profile/profile_funclevel.cpp b/Core/Libraries/Source/profile/profile_funclevel.cpp index 3c7110ca2ff..3e73367dec8 100644 --- a/Core/Libraries/Source/profile/profile_funclevel.cpp +++ b/Core/Libraries/Source/profile/profile_funclevel.cpp @@ -26,6 +26,7 @@ // // Function level profiling ////////////////////////////////////////////////////////////////////////////// + #include "profile.h" #include "internal.h" #include "../debug/debug.h" @@ -73,7 +74,7 @@ static void __declspec(naked) _pleave(void) } } -extern "C" void __declspec(naked) _cdecl _penter(void) +extern "C" void __declspec(naked) __cdecl _penter(void) { unsigned callerFunc,ESPonReturn,callerRet; ProfileFuncLevelTracer *p; @@ -127,14 +128,14 @@ extern "C" void __declspec(naked) _cdecl _penter(void) } } -ProfileFuncLevelTracer *ProfileFuncLevelTracer::head=NULL; +ProfileFuncLevelTracer *ProfileFuncLevelTracer::head=nullptr; bool ProfileFuncLevelTracer::shuttingDown=false; int ProfileFuncLevelTracer::curFrame=0; unsigned ProfileFuncLevelTracer::frameRecordMask; bool ProfileFuncLevelTracer::recordCaller=false; ProfileFuncLevelTracer::ProfileFuncLevelTracer(void): - stack(NULL), usedStack(0), totalStack(0), maxDepth(0) + stack(nullptr), usedStack(0), totalStack(0), maxDepth(0) { ProfileFastCS::Lock lock(cs); @@ -297,7 +298,7 @@ int ProfileFuncLevelTracer::FrameStart(void) for (ProfileFuncLevelTracer *p=head;p;p=p->next) { Function *f; - for (int k=0;(f=p->func.Enumerate(k))!=NULL;k++) + for (int k=0;(f=p->func.Enumerate(k))!=nullptr;k++) { Profile &p=f->cur[i]; p.caller.Clear(); @@ -326,7 +327,7 @@ void ProfileFuncLevelTracer::FrameEnd(int which, int mixIndex) for (ProfileFuncLevelTracer *p=head;p;p=p->next) { Function *f; - for (int k=0;(f=p->func.Enumerate(k))!=NULL;k++) + for (int k=0;(f=p->func.Enumerate(k))!=nullptr;k++) { Profile &p=f->cur[which]; if (p.callCount) @@ -349,7 +350,7 @@ void ProfileFuncLevelTracer::ClearTotals(void) for (ProfileFuncLevelTracer *p=head;p;p=p->next) { Function *f; - for (int k=0;(f=p->func.Enumerate(k))!=NULL;k++) + for (int k=0;(f=p->func.Enumerate(k))!=nullptr;k++) { f->glob.caller.Clear(); f->glob.callCount=0; @@ -360,7 +361,7 @@ void ProfileFuncLevelTracer::ClearTotals(void) } ProfileFuncLevelTracer::UnsignedMap::UnsignedMap(void): - e(NULL), alloc(0), used(0), writeLock(false) + e(nullptr), alloc(0), used(0), writeLock(false) { memset(hash,0,sizeof(hash)); } @@ -373,7 +374,7 @@ ProfileFuncLevelTracer::UnsignedMap::~UnsignedMap() void ProfileFuncLevelTracer::UnsignedMap::Clear(void) { ProfileFreeMemory(e); - e=NULL; + e=nullptr; alloc=used=0; memset(hash,0,sizeof(hash)); } @@ -443,7 +444,7 @@ void ProfileFuncLevelTracer::UnsignedMap::MixIn(const UnsignedMap &src) } ProfileFuncLevelTracer::ProfileMap::ProfileMap(void): - root(NULL), tail(&root) + root(nullptr), tail(&root) { } @@ -462,7 +463,7 @@ ProfileFuncLevelTracer::Profile *ProfileFuncLevelTracer::ProfileMap::Find(int fr { List *p=root; for (;p&&p->framenext); - return p&&p->frame==frame?&p->p:NULL; + return p&&p->frame==frame?&p->p: nullptr; } void ProfileFuncLevelTracer::ProfileMap::Append(int frame, const Profile &p) @@ -471,7 +472,7 @@ void ProfileFuncLevelTracer::ProfileMap::Append(int frame, const Profile &p) new (newEntry) List; newEntry->frame=frame; newEntry->p.Copy(p); - newEntry->next=NULL; + newEntry->next=nullptr; *tail=newEntry; tail=&newEntry->next; } @@ -490,7 +491,7 @@ void ProfileFuncLevelTracer::ProfileMap::MixIn(int frame, const Profile &p) } ProfileFuncLevelTracer::FunctionMap::FunctionMap(void): - e(NULL), alloc(0), used(0) + e(nullptr), alloc(0), used(0) { memset(hash,0,sizeof(hash)); } @@ -539,7 +540,7 @@ void ProfileFuncLevelTracer::FunctionMap::Insert(Function *funcPtr) ProfileFuncLevelTracer::Function *ProfileFuncLevelTracer::FunctionMap::Enumerate(int index) { if (index<0||index>=(int)used) - return NULL; + return nullptr; return e[index].funcPtr; } @@ -565,7 +566,7 @@ bool ProfileFuncLevel::IdList::Enum(unsigned index, Id &id, unsigned *countPtr) const char *ProfileFuncLevel::Id::GetSource(void) const { if (!m_funcPtr) - return NULL; + return nullptr; ProfileFuncLevelTracer::Function *func=(ProfileFuncLevelTracer::Function *)m_funcPtr; if (!func->funcSource) @@ -573,9 +574,9 @@ const char *ProfileFuncLevel::Id::GetSource(void) const char helpFunc[256],helpFile[256]; unsigned ofsFunc; DebugStackwalk::Signature::GetSymbol(func->addr, - NULL,0,NULL, + nullptr,0,nullptr, helpFunc,sizeof(helpFunc),&ofsFunc, - helpFile,sizeof(helpFile),&func->funcLine,NULL); + helpFile,sizeof(helpFile),&func->funcLine,nullptr); char help[300]; wsprintf(help,ofsFunc?"%s+0x%x":"%s",helpFunc,ofsFunc); @@ -591,7 +592,7 @@ const char *ProfileFuncLevel::Id::GetSource(void) const const char *ProfileFuncLevel::Id::GetFunction(void) const { if (!m_funcPtr) - return NULL; + return nullptr; ProfileFuncLevelTracer::Function *func=(ProfileFuncLevelTracer::Function *)m_funcPtr; if (!func->funcSource) GetSource(); @@ -609,7 +610,7 @@ unsigned ProfileFuncLevel::Id::GetAddress(void) const unsigned ProfileFuncLevel::Id::GetLine(void) const { if (!m_funcPtr) - return NULL; + return 0; ProfileFuncLevelTracer::Function *func=(ProfileFuncLevelTracer::Function *)m_funcPtr; if (!func->funcSource) GetSource(); @@ -736,12 +737,12 @@ bool ProfileFuncLevel::IdList::Enum(unsigned index, Id &id, unsigned *) const const char *ProfileFuncLevel::Id::GetSource(void) const { - return NULL; + return nullptr; } const char *ProfileFuncLevel::Id::GetFunction(void) const { - return NULL; + return nullptr; } unsigned ProfileFuncLevel::Id::GetAddress(void) const @@ -791,4 +792,4 @@ ProfileFuncLevel::ProfileFuncLevel(void) #endif // !defined HAS_PROFILE ProfileFuncLevel ProfileFuncLevel::Instance; -HANDLE ProfileFastCS::testEvent=::CreateEvent(NULL,FALSE,FALSE,""); +HANDLE ProfileFastCS::testEvent=::CreateEvent(nullptr,FALSE,FALSE,""); diff --git a/Core/Libraries/Source/profile/profile_funclevel.h b/Core/Libraries/Source/profile/profile_funclevel.h index afe2227b0f3..f4ae3d8d41f 100644 --- a/Core/Libraries/Source/profile/profile_funclevel.h +++ b/Core/Libraries/Source/profile/profile_funclevel.h @@ -93,14 +93,14 @@ class ProfileFuncLevel /** \brief Returns the source file this Id is in. - \return source file name, may be NULL + \return source file name, may be nullptr */ const char *GetSource(void) const; /** \brief Returns the function name for this Id. - \return function name, may be NULL + \return function name, may be nullptr */ const char *GetFunction(void) const; @@ -205,8 +205,8 @@ class ProfileFuncLevel /** \internal - Undocumented default constructor. Initializes function level profiler. - We can make this private as well so nobody accidently tries to create + Undocumented default constructor. Initializes function-level profiler. + We can make this private as well so nobody accidentally tries to create another instance. */ ProfileFuncLevel(void); diff --git a/Core/Libraries/Source/profile/profile_highlevel.cpp b/Core/Libraries/Source/profile/profile_highlevel.cpp index fa55293e935..a5524d83374 100644 --- a/Core/Libraries/Source/profile/profile_highlevel.cpp +++ b/Core/Libraries/Source/profile/profile_highlevel.cpp @@ -26,6 +26,7 @@ // // High level profiling ////////////////////////////////////////////////////////////////////////////// + #include "profile.h" #include "internal.h" #include @@ -51,35 +52,35 @@ void ProfileHighLevel::Id::SetMax(double max) const char *ProfileHighLevel::Id::GetName(void) const { - return m_idPtr?m_idPtr->GetName():NULL; + return m_idPtr?m_idPtr->GetName():nullptr; } const char *ProfileHighLevel::Id::GetDescr(void) const { - return m_idPtr?m_idPtr->GetDescr():NULL; + return m_idPtr?m_idPtr->GetDescr():nullptr; } const char *ProfileHighLevel::Id::GetUnit(void) const { - return m_idPtr?m_idPtr->GetUnit():NULL; + return m_idPtr?m_idPtr->GetUnit():nullptr; } const char *ProfileHighLevel::Id::GetCurrentValue(void) const { - return m_idPtr?m_idPtr->AsString(m_idPtr->GetCurrentValue()):NULL; + return m_idPtr?m_idPtr->AsString(m_idPtr->GetCurrentValue()):nullptr; } const char *ProfileHighLevel::Id::GetValue(unsigned frame) const { double v; if (!m_idPtr||!m_idPtr->GetFrameValue(frame,v)) - return NULL; + return nullptr; return m_idPtr->AsString(v); } const char *ProfileHighLevel::Id::GetTotalValue(void) const { - return m_idPtr?m_idPtr->AsString(m_idPtr->GetTotalValue()):NULL; + return m_idPtr?m_idPtr->AsString(m_idPtr->GetTotalValue()):nullptr; } ////////////////////////////////////////////////////////////////////////////// @@ -89,12 +90,12 @@ ProfileHighLevel::Block::Block(const char *name) { DFAIL_IF(!name) return; - m_idTime=AddProfile(name,NULL,"msec",6,-4); + m_idTime=AddProfile(name,nullptr,"msec",6,-4); char help[256]; strlcpy(help, name, sizeof(help) - 2); strlcat(help, ".c", sizeof(help)); - AddProfile(help,NULL,"calls",6,0).Increment(); + AddProfile(help,nullptr,"calls",6,0).Increment(); ProfileGetTime(m_start); } @@ -129,18 +130,18 @@ ProfileId::ProfileId(const char *name, const char *descr, const char *unit, int strcpy(m_descr,descr); } else - m_descr=NULL; + m_descr=nullptr; if (unit) { m_unit=(char *)ProfileAllocMemory(strlen(unit)+1); strcpy(m_unit,unit); } else - m_unit=NULL; + m_unit=nullptr; m_precision=precision; m_exp10=exp10; m_curVal=m_totalVal=0.; - m_recFrameVal=NULL; + m_recFrameVal=nullptr; m_firstFrame=curFrame; m_valueMode=Unknown; } @@ -315,7 +316,7 @@ bool ProfileHighLevel::EnumProfile(unsigned index, Id &id) ProfileId *cur=ProfileId::GetFirst(); for (;cur&&index--;cur=cur->GetNext()); id.m_idPtr=cur; - return cur!=NULL; + return cur!=nullptr; } bool ProfileHighLevel::FindProfile(const char *name, Id &id) @@ -330,7 +331,7 @@ bool ProfileHighLevel::FindProfile(const char *name, Id &id) return true; } - id.m_idPtr=NULL; + id.m_idPtr=nullptr; return false; } diff --git a/Core/Libraries/Source/profile/profile_highlevel.h b/Core/Libraries/Source/profile/profile_highlevel.h index dea386181b5..541892f0ff7 100644 --- a/Core/Libraries/Source/profile/profile_highlevel.h +++ b/Core/Libraries/Source/profile/profile_highlevel.h @@ -119,7 +119,7 @@ class ProfileHighLevel any consecutive call to any profile module function. \param frame number of recorded frame/range - \return value at given frame, NULL if frame not found + \return value at given frame, nullptr if frame not found */ const char *GetValue(unsigned frame) const; @@ -223,8 +223,8 @@ class ProfileHighLevel /** \internal - Undocumented default constructor. Initializes high level profiler. - We can make this private as well so nobody accidently tries to create + Undocumented default constructor. Initializes high-level profiler. + We can make this private as well so nobody accidentally tries to create another instance. */ ProfileHighLevel(void); diff --git a/Core/Libraries/Source/profile/profile_result.cpp b/Core/Libraries/Source/profile/profile_result.cpp index 13d55a679b9..a4b59fd3043 100644 --- a/Core/Libraries/Source/profile/profile_result.cpp +++ b/Core/Libraries/Source/profile/profile_result.cpp @@ -26,6 +26,7 @@ // // Result function interface and result functions ////////////////////////////////////////////////////////////////////////////// + #include "profile.h" #include "internal.h" #include @@ -145,9 +146,9 @@ void ProfileResultFileCSV::Delete(void) ProfileResultInterface *ProfileResultFileDOT::Create(int argn, const char * const *argv) { return new (ProfileAllocMemory(sizeof(ProfileResultFileDOT))) - ProfileResultFileDOT(argn>0?argv[0]:NULL, - argn>1?argv[1]:NULL, - argn>2?atoi(argv[2]):NULL); + ProfileResultFileDOT(argn>0?argv[0]:nullptr, + argn>1?argv[1]:nullptr, + argn>2?atoi(argv[2]): 0); } ProfileResultFileDOT::ProfileResultFileDOT(const char *fileName, const char *frameName, int foldThreshold) @@ -162,7 +163,7 @@ ProfileResultFileDOT::ProfileResultFileDOT(const char *fileName, const char *fra strcpy(m_frameName,frameName); } else - m_frameName=NULL; + m_frameName=nullptr; m_foldThreshold=foldThreshold; } @@ -226,7 +227,7 @@ void ProfileResultFileDOT::WriteResults(void) // folding version // build source code clusters first - FoldHelper *fold=NULL; + FoldHelper *fold=nullptr; for (k=0;tMax.EnumProfile(k,id);k++) { const char *source=id.GetSource(); diff --git a/Core/Tools/Autorun/ARGS.cpp b/Core/Tools/Autorun/ARGS.cpp index ce3ec5c4ee9..a9ece43f620 100644 --- a/Core/Tools/Autorun/ARGS.cpp +++ b/Core/Tools/Autorun/ARGS.cpp @@ -46,7 +46,7 @@ // GLOBALS //----------------------------------------------------------------------------- -Command_Line_Arguments *Args = NULL; +Command_Line_Arguments *Args = nullptr; //***************************************************************************** // COMMAND_LINE_ARGUMENTS::COMMAND_LINE_ARGUMENTS -- Constructor. @@ -69,7 +69,7 @@ Command_Line_Arguments::Command_Line_Arguments ( //-------------------------------------------------------------------------- // debug checks... //-------------------------------------------------------------------------- - assert( windows_command_line_string != NULL ); + assert( windows_command_line_string != nullptr ); //-------------------------------------------------------------------------- // reset all class data @@ -172,7 +172,7 @@ Command_Line_Arguments::Command_Line_Arguments ( HINSTANCE current_instance_hand //-------------------------------------------------------------------------- // debug checks... //-------------------------------------------------------------------------- - assert( windows_command_line_string != NULL ); + assert( windows_command_line_string != nullptr ); //-------------------------------------------------------------------------- // reset all class data @@ -329,7 +329,7 @@ const char *Command_Line_Arguments::Get_argv ( int argument_index ) void Command_Line_Arguments::Set_argv( int argument_index, char *arg ) { - if( arg == NULL || *arg == '\0' ) { + if( arg == nullptr || *arg == '\0' ) { return; } diff --git a/Core/Tools/Autorun/CDCNTRL.cpp b/Core/Tools/Autorun/CDCNTRL.cpp index 7d9f981a97b..5b00db5432c 100644 --- a/Core/Tools/Autorun/CDCNTRL.cpp +++ b/Core/Tools/Autorun/CDCNTRL.cpp @@ -220,7 +220,7 @@ HANDLE CDControlClass::Open_Removable_Volume( char drive ) ** Get a handle to the volume. */ _stprintf( volume_name, _TEXT( "\\\\.\\%c:" ), drive + 'A' ); - volume = CreateFile( volume_name, access_flags, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL ); + volume = CreateFile( volume_name, access_flags, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr ); // assert (volume != INVALID_HANDLE_VALUE); @@ -273,7 +273,7 @@ bool CDControlClass::Lock_Volume( HANDLE volume ) */ for ( int trycount = 0; trycount < LOCK_RETRIES; trycount++ ) { - if ( DeviceIoControl( volume, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &bytes_returned, NULL )) { + if ( DeviceIoControl( volume, FSCTL_LOCK_VOLUME, nullptr, 0, nullptr, 0, &bytes_returned, nullptr )) { return( true ); } // Msg( __LINE__, TEXT(__FILE__), TEXT("DeviceIoControl failed to lock volume. Error %d - %s"), GetLastError(), Last_Error_Text()); @@ -308,7 +308,7 @@ bool CDControlClass::Unlock_Volume(HANDLE volume) */ for ( int trycount = 0; trycount < LOCK_RETRIES; trycount++ ) { - if ( DeviceIoControl( volume, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, &bytes_returned, NULL )) return( true ); + if ( DeviceIoControl( volume, FSCTL_UNLOCK_VOLUME, nullptr, 0, nullptr, 0, &bytes_returned, nullptr )) return( true ); // DebugString ("DeviceIoControl failed to unlock volume. Error %d - %s\n", GetLastError(), Last_Error_Text()); // Msg( __LINE__, __FILE__, "DeviceIoControl failed to unlock volume. Error %d - %s", GetLastError(), Last_Error_Text()); Last_Error_Text( _TEXT( "DeviceIoControl failed to unlock volume." ), GetLastError()); @@ -335,7 +335,7 @@ bool CDControlClass::Dismount_Volume(HANDLE volume) assert( WinVersion.Is_WinNT()); unsigned long bytes_returned; - bool result = ((DeviceIoControl( volume, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &bytes_returned, NULL)) ? true : false ); + bool result = ((DeviceIoControl( volume, FSCTL_DISMOUNT_VOLUME, nullptr, 0, nullptr, 0, &bytes_returned, nullptr )) ? true : false ); if (result == false) { // DebugString ("DeviceIoControl failed to dismount volume. Error %d - %s\n", GetLastError(), Last_Error_Text()); @@ -367,7 +367,7 @@ bool CDControlClass::Prevent_Removal_Of_Volume( HANDLE volume, bool prevent ) pmrbuffer.PreventMediaRemoval = prevent; - bool result = ((DeviceIoControl( volume, IOCTL_STORAGE_MEDIA_REMOVAL, &pmrbuffer, sizeof(PREVENT_MEDIA_REMOVAL), NULL, 0, &bytes_returned, NULL)) ? true : false); + bool result = ((DeviceIoControl( volume, IOCTL_STORAGE_MEDIA_REMOVAL, &pmrbuffer, sizeof(PREVENT_MEDIA_REMOVAL), nullptr, 0, &bytes_returned, nullptr)) ? true : false); if (result == false) { // DebugString ("DeviceIoControl failed to prevent media removal. Error %d - %s\n", GetLastError(), Last_Error_Text()); @@ -382,7 +382,7 @@ bool CDControlClass::Prevent_Removal_Of_Volume( HANDLE volume, bool prevent ) * * * INPUT: HANDLE of volume to eject * * * - * OUTPUT: true if ejection occured * + * OUTPUT: true if ejection occurred * * * * WARNINGS: None * * * @@ -393,7 +393,7 @@ bool CDControlClass::Auto_Eject_Volume(HANDLE volume) { assert (WinVersion.Is_WinNT()); unsigned long bytes_returned; - bool result = ((DeviceIoControl( volume, IOCTL_STORAGE_EJECT_MEDIA, NULL, 0, NULL, 0, &bytes_returned, NULL)) ? true : false); + bool result = ((DeviceIoControl( volume, IOCTL_STORAGE_EJECT_MEDIA, nullptr, 0, nullptr, 0, &bytes_returned, nullptr )) ? true : false); if (result == false) { // DebugString ("DeviceIoControl failed to eject media. Error %d - %s\n", GetLastError(), Last_Error_Text()); @@ -911,7 +911,7 @@ bool CDControlClass::Auto_Eject_Volume_95 (HANDLE vwin32, char drive) HANDLE WINAPI CDControlClass::Open_VWin32 (void) { assert (WinVersion.Is_Win9x()); - HANDLE result = CreateFile ( TEXT("\\\\.\\vwin32"), 0, 0, NULL, 0, FILE_FLAG_DELETE_ON_CLOSE, NULL); + HANDLE result = CreateFile ( TEXT("\\\\.\\vwin32"), 0, 0, nullptr, 0, FILE_FLAG_DELETE_ON_CLOSE, nullptr); assert (result != INVALID_HANDLE_VALUE); return (result); } @@ -1086,7 +1086,7 @@ void Last_Error_Text ( LPCTSTR szPrefix, HRESULT hr ) if ( hr == S_OK ) { _stprintf( szDisplay, TEXT("%s"), szPrefix ); -// MessageBox( NULL, szDisplay, TEXT("Msg"),0 ); +// MessageBox( nullptr, szDisplay, TEXT("Msg"),0 ); return; } @@ -1095,17 +1095,17 @@ void Last_Error_Text ( LPCTSTR szPrefix, HRESULT hr ) } FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, + nullptr, hr, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), (LPTSTR)&szMessage, 0, - NULL ); + nullptr ); _stprintf( szDisplay, TEXT( "%s: %s(%lx)" ), szPrefix, szMessage, hr ); Msg( __LINE__, TEXT(__FILE__), TEXT("GetLastError: %s"), szDisplay ); -// MessageBox( NULL, szDisplay, TEXT( "GetLastError" ), MB_OK ); +// MessageBox( nullptr, szDisplay, TEXT( "GetLastError" ), MB_OK ); LocalFree( szMessage ); diff --git a/Core/Tools/Autorun/CMakeLists.txt b/Core/Tools/Autorun/CMakeLists.txt index ad06ebd5f99..52623b606bb 100644 --- a/Core/Tools/Autorun/CMakeLists.txt +++ b/Core/Tools/Autorun/CMakeLists.txt @@ -53,8 +53,6 @@ add_library(corei_autorun INTERFACE) target_sources(corei_autorun INTERFACE ${AUTORUN_SRC}) target_link_libraries(corei_autorun INTERFACE - core_config - core_utility winmm ) diff --git a/Core/Tools/Autorun/CallbackHook.h b/Core/Tools/Autorun/CallbackHook.h index 1bbaac4a920..324e3827bcd 100644 --- a/Core/Tools/Autorun/CallbackHook.h +++ b/Core/Tools/Autorun/CallbackHook.h @@ -68,7 +68,7 @@ template class Callback : public CallbackHook virtual bool DoCallback(void) const { - if (mCallback != NULL) + if (mCallback != nullptr) { return mCallback(mUserData); } diff --git a/Core/Tools/Autorun/DrawButton.cpp b/Core/Tools/Autorun/DrawButton.cpp index edd7009682f..34b35f94ce2 100644 --- a/Core/Tools/Autorun/DrawButton.cpp +++ b/Core/Tools/Autorun/DrawButton.cpp @@ -113,7 +113,7 @@ DrawButton::DrawButton ( int id, RECT button_rect, const char *normal, const cha // Set the string variables. //-------------------------------------------------------------------------- memset( String, '\0', MAX_PATH ); -// if ( string != NULL ) { +// if ( string != nullptr ) { // wcscpy( String, Locale_GetString( string_num, String )); @@ -127,9 +127,9 @@ DrawButton::DrawButton ( int id, RECT button_rect, const char *normal, const cha //-------------------------------------------------------------------------- // Set the font pointer. //-------------------------------------------------------------------------- - MyFontPtr = NULL; + MyFontPtr = nullptr; - if ( fontptr != NULL ) { + if ( fontptr != nullptr ) { MyFontPtr = fontptr; } @@ -182,16 +182,16 @@ DrawButton::DrawButton ( int id, RECT button_rect, const char *normal, const cha // Set the string variables. //-------------------------------------------------------------------------- memset( String, '\0', MAX_PATH ); - if ( string != NULL ) { + if ( string != nullptr ) { wcscpy( String, string ); } //-------------------------------------------------------------------------- // Set the font pointer. //-------------------------------------------------------------------------- - MyFontPtr = NULL; + MyFontPtr = nullptr; - if ( fontptr != NULL ) { + if ( fontptr != nullptr ) { MyFontPtr = fontptr; } @@ -233,7 +233,7 @@ void DrawButton::Draw_Text ( HDC hDC ) RECT outline_rect; Rect rect; - if( hDC == NULL ) { + if( hDC == nullptr ) { return; } @@ -289,7 +289,7 @@ void DrawButton::Draw_Text ( HDC hDC ) // OUTPUT: bool -- true of false. // // WARNINGS: No keyboard/mouse/paint handling built in. Do manually. -// Note: width is shortened below to accomodate actual bitmap area. +// Note: width is shortened below to accommodate actual bitmap area. // // HISTORY: // 07/15/1996 MML : Created. diff --git a/Core/Tools/Autorun/EZGIMEX.cpp b/Core/Tools/Autorun/EZGIMEX.cpp index 444b9ad9fd9..fd18ac35e94 100644 --- a/Core/Tools/Autorun/EZGIMEX.cpp +++ b/Core/Tools/Autorun/EZGIMEX.cpp @@ -49,7 +49,7 @@ /* And increase stream buffer */ /* - setvbuf(f, NULL, _IOFBF, FILE_BUFFER_SIZE); + setvbuf(f, nullptr, _IOFBF, FILE_BUFFER_SIZE); */ #define __NOINLINE__ 1 @@ -151,13 +151,13 @@ GSTREAM * GCALL gopen(const char *filename) handle = fopen( filename, "r+b" ); - Msg( __LINE__, __FILE__, "gopen:: handle = %d", (( handle != NULL )? 1 : 0 )); + Msg( __LINE__, __FILE__, "gopen:: handle = %d", (( handle != nullptr )? 1 : 0 )); if ( !handle ) { handle = fopen( filename, "rb" ); - Msg( __LINE__, __FILE__, "gopen:: handle = %d", (( handle != NULL )? 1 : 0 )); + Msg( __LINE__, __FILE__, "gopen:: handle = %d", (( handle != nullptr )? 1 : 0 )); } return((GSTREAM *) handle); } diff --git a/Core/Tools/Autorun/GETCD.cpp b/Core/Tools/Autorun/GETCD.cpp index fa8df05e26b..c033a23f674 100644 --- a/Core/Tools/Autorun/GETCD.cpp +++ b/Core/Tools/Autorun/GETCD.cpp @@ -184,10 +184,10 @@ int GetCDClass::Get_CD_Drive_For_This_Volume ( const char *volume_label ) (char const *)buffer, &volume_name[0], (unsigned long)sizeof(volume_name)-1, - (unsigned long *)NULL, + (unsigned long *)nullptr, (unsigned long *)&filename_length, (unsigned long *)&misc_dword, - (char *)NULL, + (char *)nullptr, (unsigned long)0 )) { //--------------------------------------------------------------------- @@ -212,12 +212,12 @@ int GetCDClass::Get_CD_Drive_For_This_Volume ( const char *volume_label ) FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, + nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, - NULL + nullptr ); Msg( __LINE__, __FILE__, (LPTSTR)lpMsgBuf ); LocalFree( lpMsgBuf ); @@ -270,8 +270,8 @@ const char *GetCDClass::Get_Volume_For_This_CD_Drive ( const char *path, char *v unsigned filename_length; static char volume_label[ MAX_PATH ] = ""; // [OYO] add static - if ( path == NULL || volume_name == NULL ) { - return( NULL ); + if ( path == nullptr || volume_name == nullptr ) { + return( nullptr ); } memset( volume_name, '\0', sizeof( volume_name )); @@ -281,10 +281,10 @@ const char *GetCDClass::Get_Volume_For_This_CD_Drive ( const char *path, char *v (char const *)buffer, &volume_label[0], (unsigned long)sizeof(volume_label)-1, - (unsigned long *)NULL, + (unsigned long *)nullptr, (unsigned long *)&filename_length, (unsigned long *)&misc_dword, - (char *)NULL, + (char *)nullptr, (unsigned long)0 )) { strcpy( volume_name, volume_label ); @@ -296,12 +296,12 @@ const char *GetCDClass::Get_Volume_For_This_CD_Drive ( const char *path, char *v FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, + nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, - NULL + nullptr ); Msg( __LINE__, __FILE__, (LPTSTR)lpMsgBuf ); LocalFree( lpMsgBuf ); @@ -361,10 +361,10 @@ bool CD_Volume_Verification ( int cd_drive, char *volume_label, char *volume_to_ (char const *)buffer, &volume_name[0], (unsigned long)sizeof(volume_name)-1, - (unsigned long *)NULL, + (unsigned long *)nullptr, (unsigned long *)&filename_length, (unsigned long *)&misc_dword, - (char *)NULL, + (char *)nullptr, (unsigned long)0 )) { /****************************************************************** @@ -381,7 +381,7 @@ bool CD_Volume_Verification ( int cd_drive, char *volume_label, char *volume_to_ volume_name[11] = '\0'; } - if ( volume_label != NULL ) { + if ( volume_label != nullptr ) { strncpy( volume_label, volume_name, 128 ); } diff --git a/Core/Tools/Autorun/GameText.cpp b/Core/Tools/Autorun/GameText.cpp index c2f990fc4eb..d318b87ca1d 100644 --- a/Core/Tools/Autorun/GameText.cpp +++ b/Core/Tools/Autorun/GameText.cpp @@ -174,7 +174,7 @@ class GameTextManager : public GameTextInterface Char readChar( File *file ); }; -static int _cdecl compareLUT ( const void *, const void*); +static int __cdecl compareLUT ( const void *, const void*); //---------------------------------------------------------------------------- // Private Data //---------------------------------------------------------------------------- @@ -185,7 +185,7 @@ static int _cdecl compareLUT ( const void *, const void*); // Public Data //---------------------------------------------------------------------------- -GameTextInterface *TheGameText = NULL; +GameTextInterface *TheGameText = nullptr; //---------------------------------------------------------------------------- // Private Prototypes @@ -220,12 +220,12 @@ GameTextInterface* CreateGameTextInterface( void ) GameTextManager::GameTextManager() : m_textCount(0), m_maxLabelLen(0), - m_stringInfo(NULL), - m_stringLUT(NULL), + m_stringInfo(nullptr), + m_stringLUT(nullptr), m_initialized(FALSE), m_jabberWockie(FALSE), m_munkee(FALSE), - m_noStringList(NULL), + m_noStringList(nullptr), m_useStringFile(TRUE), m_failed(L"***FATAL*** String Manager failed to initialized properly") { @@ -294,7 +294,7 @@ void GameTextManager::init( void ) m_stringInfo = new StringInfo[m_textCount]; - if( m_stringInfo == NULL ) + if( m_stringInfo == nullptr ) { deinit(); return; @@ -341,10 +341,10 @@ void GameTextManager::init( void ) void GameTextManager::deinit( void ) { delete [] m_stringInfo; - m_stringInfo = NULL; + m_stringInfo = nullptr; delete [] m_stringLUT; - m_stringLUT = NULL; + m_stringLUT = nullptr; m_textCount = 0; @@ -362,7 +362,7 @@ void GameTextManager::deinit( void ) DEBUG_LOG(("*** End missing strings ***")); DEBUG_LOG(("")); - m_noStringList = NULL; + m_noStringList = nullptr; m_initialized = FALSE; } @@ -474,7 +474,7 @@ void GameTextManager::readToEndOfQuote( File *file, Char *in, Char *out, Char *w { if ( (ch = *in++) == 0 ) { - in = NULL; // have exhausted the input m_buffer + in = nullptr; // have exhausted the input m_buffer ch = readChar ( file ); } } @@ -531,7 +531,7 @@ void GameTextManager::readToEndOfQuote( File *file, Char *in, Char *out, Char *w { if ( (ch = *in++) == 0 ) { - in = NULL; // have exhausted the input m_buffer + in = nullptr; // have exhausted the input m_buffer ch = readChar ( file ); } } @@ -634,7 +634,7 @@ void GameTextManager::translateCopy( WideChar *outbuf, Char *inbuf ) if ( m_jabberWockie ) { static Char buffer[MAX_UITEXT_LENGTH*2]; - Char *firstLetter = NULL, *lastLetter; + Char *firstLetter = nullptr, *lastLetter; Char *b = buffer; Int formatWord = FALSE; Char ch; @@ -650,7 +650,7 @@ void GameTextManager::translateCopy( WideChar *outbuf, Char *inbuf ) lastLetter = b-1; reverseWord ( firstLetter, lastLetter ); } - firstLetter = NULL; + firstLetter = nullptr; formatWord = FALSE; } *b++ = ch; @@ -1049,7 +1049,7 @@ const wchar_t * GameTextManager::fetch( const Char *label ) { DEBUG_ASSERTCRASH ( m_initialized, ("String Manager has not been m_initialized") ); - if( m_stringInfo == NULL ) + if( m_stringInfo == nullptr ) { return m_failed.c_str(); } @@ -1058,12 +1058,12 @@ const wchar_t * GameTextManager::fetch( const Char *label ) StringLookUp key; std::string lb; lb = label; - key.info = NULL; + key.info = nullptr; key.label = &lb; lookUp = (StringLookUp *) bsearch( &key, (void*) m_stringLUT, m_textCount, sizeof(StringLookUp), compareLUT ); - if( lookUp == NULL ) + if( lookUp == nullptr ) { // See if we already have the missing string wchar_t tmp[256]; diff --git a/Core/Tools/Autorun/IGR.cpp b/Core/Tools/Autorun/IGR.cpp index 7ea522b0541..662a0d2c46f 100644 --- a/Core/Tools/Autorun/IGR.cpp +++ b/Core/Tools/Autorun/IGR.cpp @@ -29,7 +29,7 @@ #include "IGR.h" -IGROptionsClass *OnlineOptions = NULL; +IGROptionsClass *OnlineOptions = nullptr; /********************************************************************************************* @@ -66,7 +66,7 @@ bool IGROptionsClass::Init( void ) // If successful, get the options IGROptionsType ReadOptions = 0; - returnValue = RegQueryValueEx(handle, WOLAPI_REG_KEY_OPTIONS, NULL, + returnValue = RegQueryValueEx(handle, WOLAPI_REG_KEY_OPTIONS, nullptr, (unsigned long *) &type, (unsigned char *) &ReadOptions, (unsigned long *)&size); if (returnValue == ERROR_SUCCESS) { @@ -161,8 +161,8 @@ bool IGROptionsClass::Set_Options( IGROptionsType options ) if( RegOpenKeyEx( HKEY_LOCAL_MACHINE, key, 0, KEY_ALL_ACCESS, &handle ) != ERROR_SUCCESS ) { // If not, make the WOLAPI key - if( RegCreateKeyEx( HKEY_LOCAL_MACHINE, key, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, - NULL, &handle, (unsigned long *)&disp ) != ERROR_SUCCESS ) + if( RegCreateKeyEx( HKEY_LOCAL_MACHINE, key, 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, + nullptr, &handle, (unsigned long *)&disp ) != ERROR_SUCCESS ) return false; } diff --git a/Core/Tools/Autorun/Jsupport.cpp b/Core/Tools/Autorun/Jsupport.cpp index acfbeceef2a..6dbd211a694 100644 --- a/Core/Tools/Autorun/Jsupport.cpp +++ b/Core/Tools/Autorun/Jsupport.cpp @@ -88,7 +88,7 @@ int nGetWord( char *string, int fdbcs ) // If no string was passed in, exit. //-------------------------------------------------------------------------- if( !p || !( c0 = *p++ )) { -// if(( p == NULL ) || ( *p == '\0' )) { +// if(( p == nullptr ) || ( *p == '\0' )) { return 0; } // c0 = *p; diff --git a/Core/Tools/Autorun/Locale_API.cpp b/Core/Tools/Autorun/Locale_API.cpp index 73aa3aafbfd..f706ae2080c 100644 --- a/Core/Tools/Autorun/Locale_API.cpp +++ b/Core/Tools/Autorun/Locale_API.cpp @@ -94,7 +94,7 @@ const wchar_t *localeStringsMissing[ MISSING_STRING_HINTS_MAX ] = /* GLOBAL VARIABLES */ /****************************************************************************/ char LanguageFile[ _MAX_PATH ]; -void * LocaleFile = NULL; +void * LocaleFile = nullptr; int CodePage = GetACP(); int LanguageID = 0; int PrimaryLanguage = LANG_NEUTRAL; @@ -144,7 +144,7 @@ int Locale_Init ( int language, char *file ) //------------------------------------------------------------------------- // Check for a file passed in. //------------------------------------------------------------------------- - if( file == NULL || file[0] == '/0' ) { + if( file == nullptr || file[0] == '/0' ) { return 0; } strcpy( LanguageFile, file ); @@ -176,7 +176,7 @@ int Locale_Init ( int language, char *file ) HRSRC hRsrc; HGLOBAL hGlobal; - HMODULE module = GetModuleHandle( NULL ); + HMODULE module = GetModuleHandle( nullptr ); //------------------------------------------------------------------------- // Find the string file in this program's resources. @@ -225,7 +225,7 @@ int Locale_Init ( int language, char *file ) } hRsrc = FindResourceEx( module, RT_RCDATA, "STRINGS", MAKELANGID( PrimaryLanguage, SubLanguage )); - if ( hRsrc == NULL ) { + if ( hRsrc == nullptr ) { hRsrc = FindResourceEx( module, RT_RCDATA, "STRINGS", MAKELANGID( LANG_ENGLISH, SUBLANG_ENGLISH_US )); } if ( hRsrc ) { @@ -247,11 +247,11 @@ int Locale_Init ( int language, char *file ) FreeResource( hGlobal ); } - if( LocaleFile == NULL ) { + if( LocaleFile == nullptr ) { LocaleFile = Load_File( LanguageFile, &filesize ); } - if( LocaleFile != NULL ) { + if( LocaleFile != nullptr ) { result = 1; } @@ -291,19 +291,19 @@ int Locale_Init ( int language, char *file ) void Locale_Restore ( void ) { delete TheGameText; - TheGameText = NULL; + TheGameText = nullptr; #if( USE_MULTI_FILE_FORMAT ) LOCALE_freetable(); LOCALE_restore(); #else free( LocaleFile ); - LocaleFile = NULL; + LocaleFile = nullptr; #endif } /****************************************************************************/ -/* retreiving strings */ +/* retrieving strings */ /****************************************************************************/ const char* Locale_GetString( int StringID, char *String ) @@ -321,9 +321,9 @@ const char* Locale_GetString( int StringID, char *String ) #endif Remove_Quotes_Around_String( wide_buffer ); - WideCharToMultiByte( CodePage, 0, wide_buffer, _MAX_PATH, buffer, _MAX_PATH, NULL, NULL ); + WideCharToMultiByte( CodePage, 0, wide_buffer, _MAX_PATH, buffer, _MAX_PATH, nullptr, nullptr ); - if( String != NULL ) { + if( String != nullptr ) { strncpy( String, buffer, _MAX_PATH ); } @@ -356,12 +356,12 @@ const wchar_t* Locale_GetString( int StringID, wchar_t *String ) wcscpy( wide_buffer, (wchar_t *)LOCALE_getstring( StringID )); #else - wchar_t *localeStr = NULL; + wchar_t *localeStr = nullptr; - if (TheGameText != NULL) + if (TheGameText != nullptr) localeStr = (wchar_t *)TheGameText->fetch( s_stringLabels[StringID] ); - if (localeStr == NULL) + if (localeStr == nullptr) { return localeStringsMissing[ min( MISSING_STRING_HINTS_MAX - 1, StringID ) ]; } @@ -373,7 +373,7 @@ const wchar_t* Locale_GetString( int StringID, wchar_t *String ) Remove_Quotes_Around_String( wide_buffer ); - if( String != NULL ) { + if( String != nullptr ) { wcsncpy( String, wide_buffer, _MAX_PATH ); } @@ -392,7 +392,7 @@ wchar_t *Remove_Quotes_Around_String ( wchar_t *old_string ) int length; //---------------------------------------------------------------------- - // If string is not NULL... + // If string is not null... //---------------------------------------------------------------------- if ( *letter == '"' ) { diff --git a/Core/Tools/Autorun/Locale_API.h b/Core/Tools/Autorun/Locale_API.h index 73cd605453e..2f8aa2c084b 100644 --- a/Core/Tools/Autorun/Locale_API.h +++ b/Core/Tools/Autorun/Locale_API.h @@ -53,10 +53,10 @@ extern int SubLanguage; /****************************************************************************/ int Locale_Init ( int language, char *file ); void Locale_Restore ( void ); -const wchar_t* Locale_GetString( const char *id, wchar_t *buffer = NULL, int size = _MAX_PATH ); +const wchar_t* Locale_GetString( const char *id, wchar_t *buffer = nullptr, int size = _MAX_PATH ); /* const char* Locale_GetString ( int StringID, char *String ); -const wchar_t* Locale_GetString ( int StringID, wchar_t *String=NULL ); +const wchar_t* Locale_GetString ( int StringID, wchar_t *String=nullptr ); */ bool Locale_Use_Multi_Language_Files ( void ); //int Locale_Get_Language_ID ( void ) { return LanguageID; }; diff --git a/Core/Tools/Autorun/RECT.h b/Core/Tools/Autorun/RECT.h index 0bd028d7cb2..02a010c38a2 100644 --- a/Core/Tools/Autorun/RECT.h +++ b/Core/Tools/Autorun/RECT.h @@ -257,10 +257,10 @@ TRect const Intersect(TRect const & bounding_rect, TRect const & draw_r ** Adjust Height relative draw position according to Height new draw_rect ** union. */ - if (x != NULL) { + if (x != nullptr) { *x -= T(new_draw_rect.X - draw_rect.X); } - if (y != NULL) { + if (y != nullptr) { *y -= T(new_draw_rect.Y - draw_rect.Y); } @@ -290,7 +290,7 @@ TRect const Intersect(TRect const & bounding_rect, TRect const & draw_r template TRect const Intersect(TRect const & rect1, TRect const & rect2) { - return(Intersect(rect1, rect2, (T*)NULL, (T*)NULL)); + return(Intersect(rect1, rect2, (T*)nullptr, (T*)nullptr)); } diff --git a/Core/Tools/Autorun/TTFont.cpp b/Core/Tools/Autorun/TTFont.cpp index 0c3652ec9a4..5dbf31207dc 100644 --- a/Core/Tools/Autorun/TTFont.cpp +++ b/Core/Tools/Autorun/TTFont.cpp @@ -68,14 +68,14 @@ //------------------------------------------------------------------------- // Text Fonts. //------------------------------------------------------------------------- -TTFontClass *TTButtonFontPtr = NULL; -TTFontClass *TTButtonFontPtrSmall = NULL; -TTFontClass *TTTextFontPtr = NULL; -TTFontClass *TTTextFontPtr640 = NULL; -TTFontClass *TTTextFontPtr800 = NULL; -TTFontClass *TTLicenseFontPtr = NULL; +TTFontClass *TTButtonFontPtr = nullptr; +TTFontClass *TTButtonFontPtrSmall = nullptr; +TTFontClass *TTTextFontPtr = nullptr; +TTFontClass *TTTextFontPtr640 = nullptr; +TTFontClass *TTTextFontPtr800 = nullptr; +TTFontClass *TTLicenseFontPtr = nullptr; -FontManagerClass * FontManager = NULL; +FontManagerClass * FontManager = nullptr; //unsigned long TEXT_COLOR = RGB( 247, 171, 11 ); //unsigned long SHADOW_COLOR = RGB( 40, 8, 8 ); @@ -142,7 +142,7 @@ TTFontClass::TTFontClass( //-------------------------------------------------------------------------- // Get or Set a Font filename. //-------------------------------------------------------------------------- - if (( filename == NULL ) || ( filename[0] == '\0' )) { + if (( filename == nullptr ) || ( filename[0] == '\0' )) { strcpy( szFilename, "Arial.ttf" ); } else { strcpy( szFilename, filename ); @@ -151,7 +151,7 @@ TTFontClass::TTFontClass( //-------------------------------------------------------------------------- // Get or Set a Font facename. //-------------------------------------------------------------------------- - if (( facename == NULL ) || ( facename[0] == '\0' )) { + if (( facename == nullptr ) || ( facename[0] == '\0' )) { strcpy( szFacename, "Arial" ); } else { strcpy( szFacename, facename ); @@ -180,7 +180,7 @@ TTFontClass::TTFontClass( pitchAndFamily, szFacename ); - if ( hdc && ( Font != NULL )) { + if ( hdc && ( Font != nullptr )) { //---------------------------------------------------------------------- // The GetTextFace function lets a program determine the face name of @@ -196,7 +196,7 @@ TTFontClass::TTFontClass( SelectObject( hdc, old_object ); DeleteObject( Font ); - Font = NULL; + Font = nullptr; Font = CreateFont( height, // height of font @@ -335,14 +335,14 @@ int TTFontClass::Char_Pixel_Width ( HDC hdc, char const * string, int *num_bytes //-------------------------------------------------------------------------- // These values must be passed in. //-------------------------------------------------------------------------- - if ( string == NULL || *string == '\0' || hdc == NULL ) { + if ( string == nullptr || *string == '\0' || hdc == nullptr ) { return( 0 ); } //-------------------------------------------------------------------------- // If this value is passed in, the set the default value (1=single). //-------------------------------------------------------------------------- - if ( num_bytes!= NULL ) { + if ( num_bytes!= nullptr ) { *num_bytes = 1; } @@ -378,7 +378,7 @@ int TTFontClass::Char_Pixel_Width ( HDC hdc, char const * string, int *num_bytes int TTFontClass::String_Pixel_Width( HDC hdc, char const * string ) const { - if ( string == NULL ) { + if ( string == nullptr ) { return(0); } @@ -392,7 +392,7 @@ int TTFontClass::String_Pixel_Width( HDC hdc, char const * string ) const size.cx = 0; - if ( localDC == NULL ) { + if ( localDC == nullptr ) { return( size.cx ); } @@ -432,11 +432,11 @@ void TTFontClass::String_Pixel_Bounds( HDC hdc, const char* string, Rect& bounds bounds.Width = 0; bounds.Height = 0; - if ( string == NULL ) { + if ( string == nullptr ) { return; } - if ( hdc == NULL ) { + if ( hdc == nullptr ) { return; } @@ -501,14 +501,14 @@ void TTFontClass::String_Pixel_Bounds( HDC hdc, const char* string, Rect& bounds // UINT TTFontClass::Get_Double_Byte_Char ( const char *string, int *num_bytes ) const { - if ( string == NULL || *string == '\0' ) { + if ( string == nullptr || *string == '\0' ) { return( 0 ); } const char *ptr = string; UINT c = *(BYTE *)ptr++; - if ( num_bytes != NULL ) { + if ( num_bytes != nullptr ) { *num_bytes = 1; } @@ -536,7 +536,7 @@ UINT TTFontClass::Get_Double_Byte_Char ( const char *string, int *num_bytes ) co //-------------------------------------------------------------------------- if( IsDBCSLeadByte( c )&& *ptr ) { // [OYO] c = ( c << 8 ) | *(BYTE *)ptr++; - if ( num_bytes != NULL ) { + if ( num_bytes != nullptr ) { *num_bytes = 2; } } @@ -677,7 +677,7 @@ Point2D TTFontClass::Print( int length = wcslen( string ); memset( buffer, '\0', _MAX_PATH ); - WideCharToMultiByte( CodePage, 0, string, length, buffer, _MAX_PATH, NULL, NULL ); + WideCharToMultiByte( CodePage, 0, string, length, buffer, _MAX_PATH, nullptr, nullptr ); return( Print( hdc, buffer, cliprect, forecolor, backcolor, flag, shadow )); } @@ -703,10 +703,10 @@ Point2D TTFontClass::Print( //-------------------------------------------------------------------------- // If no string, why continue? //-------------------------------------------------------------------------- - assert( string != NULL ); - assert( hdc != NULL ); + assert( string != nullptr ); + assert( hdc != nullptr ); - if (( string == NULL ) || ( string[0] == '\0' )) { + if (( string == nullptr ) || ( string[0] == '\0' )) { return( point ); } @@ -729,7 +729,7 @@ Point2D TTFontClass::Print( //-------------------------------------------------------------------------- if ( hdc ) { - assert( Font != NULL ); + assert( Font != nullptr ); old_object = SelectObject( hdc, Font ); @@ -747,7 +747,7 @@ Point2D TTFontClass::Print( // &rect, // optional dimensions // string, // string // length, // number of characters in string -// NULL // array of spacing values +// nullptr // array of spacing values // ); // result = TextOutW( @@ -817,10 +817,10 @@ Point2D TTFontClass::Print( //-------------------------------------------------------------------------- // If no string, why continue? //-------------------------------------------------------------------------- - assert( string != NULL ); - assert( hdc != NULL ); + assert( string != nullptr ); + assert( hdc != nullptr ); - if (( string == NULL ) || ( string[0] == '\0' )) { + if (( string == nullptr ) || ( string[0] == '\0' )) { return( point ); } @@ -848,7 +848,7 @@ Point2D TTFontClass::Print( //-------------------------------------------------------------------------- if ( hdc ) { - assert( Font != NULL ); + assert( Font != nullptr ); old_object = SelectObject( hdc, Font ); @@ -1047,14 +1047,14 @@ int TTFontClass::Find_Text_VLength( HDC hdc, char *str, int width ) bool make_dc = FALSE; HDC localDC = hdc; - if ( *str == '\0' || str == NULL ) { + if ( *str == '\0' || str == nullptr ) { return( 0 ); } //-------------------------------------------------------------------------- // If no DC was passed in, then we need to get one. //-------------------------------------------------------------------------- - if ( localDC == NULL ) { + if ( localDC == nullptr ) { return( 0 ); } @@ -1223,7 +1223,7 @@ FontManagerClass::FontManagerClass ( HDC hdc ) strcpy( szFacename, "Arial" ); strcpy( szPath, Args->Get_argv(0)); - _splitpath( szPath, drive, dir, NULL, NULL ); + _splitpath( szPath, drive, dir, nullptr, nullptr ); _makepath( szPath, drive, dir, "Setup\\Setup", ".ini" ); GetPrivateProfileString( "Fonts", "Font", "Arial.tff", szFile, MAX_PATH, szPath ); @@ -1351,37 +1351,37 @@ FontManagerClass::FontManagerClass ( HDC hdc ) //---------------------------------------------------------------------- // If we fell through... //---------------------------------------------------------------------- - if( TTButtonFontPtr == NULL || TTTextFontPtr == NULL ) { + if( TTButtonFontPtr == nullptr || TTTextFontPtr == nullptr ) { strcpy( szFile, "Arial.tff" ); strcpy( szFacename, "Arial" ); - if( TTButtonFontPtr == NULL ) { + if( TTButtonFontPtr == nullptr ) { TTButtonFontPtr = new TTFontClass( hdc, szFile, szFacename, 22, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE ); } - if( TTButtonFontPtrSmall == NULL ) { + if( TTButtonFontPtrSmall == nullptr ) { TTButtonFontPtrSmall= new TTFontClass( hdc, szFile, szFacename, 22, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE ); } - if( TTTextFontPtr == NULL ) { + if( TTTextFontPtr == nullptr ) { TTTextFontPtr = new TTFontClass( hdc, szFile, szFacename, 16, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE ); } - if( TTTextFontPtr640 == NULL ) { + if( TTTextFontPtr640 == nullptr ) { TTTextFontPtr640 = new TTFontClass( hdc, szFile, szFacename, 14, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE ); } - if( TTTextFontPtr800 == NULL ) { + if( TTTextFontPtr800 == nullptr ) { TTTextFontPtr800 = new TTFontClass( hdc, szFile, szFacename, 14, FW_SEMIBOLD, ANSI_CHARSET, 0, 0, 0, FALSE ); } - if( TTLicenseFontPtr == NULL ) { + if( TTLicenseFontPtr == nullptr ) { TTLicenseFontPtr = new TTFontClass( hdc, szFile, szFacename, 12, FW_MEDIUM, ANSI_CHARSET, 0, 0, 0, FALSE ); } } } - assert( TTTextFontPtr != NULL ); - assert( TTTextFontPtr640 != NULL ); - assert( TTTextFontPtr800 != NULL ); - assert( TTButtonFontPtr != NULL ); - assert( TTButtonFontPtrSmall != NULL ); - assert( TTLicenseFontPtr != NULL ); + assert( TTTextFontPtr != nullptr ); + assert( TTTextFontPtr640 != nullptr ); + assert( TTTextFontPtr800 != nullptr ); + assert( TTButtonFontPtr != nullptr ); + assert( TTButtonFontPtrSmall != nullptr ); + assert( TTLicenseFontPtr != nullptr ); } /*********************************************************************************************** @@ -1399,10 +1399,10 @@ FontManagerClass::FontManagerClass ( HDC hdc ) FontManagerClass::~FontManagerClass ( void ) { delete TTButtonFontPtr; - TTButtonFontPtr = NULL; + TTButtonFontPtr = nullptr; delete TTTextFontPtr; - TTTextFontPtr = NULL; + TTTextFontPtr = nullptr; } @@ -1423,7 +1423,7 @@ FontManagerClass::~FontManagerClass ( void ) *=============================================================================================*/ TTFontClass * Font_From_TPF ( TextPrintType flags ) { - TTFontClass *fontptr= NULL; + TTFontClass *fontptr= nullptr; switch (flags & 0x000F) { diff --git a/Core/Tools/Autorun/TTFont.h b/Core/Tools/Autorun/TTFont.h index 56138857bff..b81b38319ca 100644 --- a/Core/Tools/Autorun/TTFont.h +++ b/Core/Tools/Autorun/TTFont.h @@ -204,15 +204,15 @@ class TTFontClass virtual ~TTFontClass(void) { - if ( Font != NULL ) { + if ( Font != nullptr ) { DeleteObject( Font ); - Font = NULL; + Font = nullptr; } RemoveFontResource( szFilename ); }; virtual int Char_Pixel_Width ( HDC hdc, UINT c ) const; - virtual int Char_Pixel_Width ( HDC hdc, char const * string, int *num_bytes=NULL ) const; + virtual int Char_Pixel_Width ( HDC hdc, char const * string, int *num_bytes=nullptr ) const; virtual int String_Pixel_Width ( HDC hdc, char const * string ) const; virtual void String_Pixel_Bounds ( HDC hdc, const char * string, Rect& bounds ) const; virtual int Get_Width ( void ) const; @@ -222,7 +222,7 @@ class TTFontClass virtual int Find_Text_VLength ( HDC hdc, char *str, int width ); virtual HFONT Get_Font_Ptr ( void ) { return Font; }; virtual int IsFontDBCS ( void ) const { return ((CharSet==SHIFTJIS_CHARSET)||(CharSet==HANGEUL_CHARSET)||(CharSet==CHINESEBIG5_CHARSET)); }; // [OYO] - virtual UINT Get_Double_Byte_Char ( const char *string, int *num_bytes=NULL ) const; + virtual UINT Get_Double_Byte_Char ( const char *string, int *num_bytes=nullptr ) const; virtual Point2D Print( HDC hdc, @@ -272,7 +272,7 @@ bool Is_True_Type_Font ( TextPrintType flags ); // True Type??? //------------------------------------------------------------------------- // This class is a wrapper around all the fonts that we want to be available. -// The constructer will make them, and the destructor will remove them for us. +// The constructor will make them, and the destructor will remove them for us. //------------------------------------------------------------------------- class FontManagerClass { diff --git a/Core/Tools/Autorun/Utils.cpp b/Core/Tools/Autorun/Utils.cpp index e40fb229d74..565449b0f96 100644 --- a/Core/Tools/Autorun/Utils.cpp +++ b/Core/Tools/Autorun/Utils.cpp @@ -89,7 +89,7 @@ // Purpose: To replace each "&" with "&&" for display in a dialog. // Some dialogs mistake a single "&" for an accelerator key. // -// Input: pszString - any NULL terminated string. +// Input: pszString - any null-terminated string. // // Returns: VOID (returns nothing) // @@ -192,7 +192,7 @@ void Fix_Single_Ampersands ( wchar_t *pszString, bool upper_case ) // Purpose: To replace each "&&" with "&" for display in a dialog. // Some dialogs mistake a single "&" for an accelerator key. // -// Input: pszString - any NULL terminated string. +// Input: pszString - any null-terminated string. // // Returns: VOID (returns nothing) // @@ -254,7 +254,7 @@ void Fix_Double_Ampersands ( LPSTR pszString, bool upper_case ) void * Load_Alloc_Data( char *filename, long *filesize ) { int size, bytes_read; - void *ptr = NULL; + void *ptr = nullptr; StandardFileClass file; //------------------------------------------------------------------------- @@ -262,7 +262,7 @@ void * Load_Alloc_Data( char *filename, long *filesize ) //------------------------------------------------------------------------- file.Open( filename, MODE_READ_ONLY ); if ( !file.Query_Open()) { - return( NULL ); + return( nullptr ); } //------------------------------------------------------------------------- @@ -271,7 +271,7 @@ void * Load_Alloc_Data( char *filename, long *filesize ) size = file.Query_Size(); ptr = (void*)malloc(size + 1); if ( !ptr ) { - return( NULL ); + return( nullptr ); } //------------------------------------------------------------------------- @@ -287,10 +287,10 @@ void * Load_Alloc_Data( char *filename, long *filesize ) assert( bytes_read == size ); if ( bytes_read != size ) { free(ptr); - return( NULL ); + return( nullptr ); } - if ( filesize != NULL ) { + if ( filesize != nullptr ) { *filesize = (long)size; } return( ptr ); @@ -312,10 +312,10 @@ void * Load_Alloc_Data( char *filename, long *filesize ) void *Load_File ( char *filename, long *filesize ) { - void *ptr = NULL; + void *ptr = nullptr; - if ( filename == NULL || filename[0] == '\0' ) { - return( NULL ); + if ( filename == nullptr || filename[0] == '\0' ) { + return( nullptr ); } //------------------------------------------------------------------------- @@ -347,12 +347,12 @@ char *Make_Current_Path_To ( const char *filename, char *path ) char dir [ _MAX_DIR ]; strcpy( szPath, Args->Get_argv(0)); - _splitpath( szPath, drive, dir, NULL, NULL ); - _makepath( szPath, drive, dir, NULL, NULL ); + _splitpath( szPath, drive, dir, nullptr, nullptr ); + _makepath( szPath, drive, dir, nullptr, nullptr ); Path_Add_Back_Slash( szPath ); strcat( szPath, filename ); - if( path != NULL ) { + if( path != nullptr ) { strcpy( path, szPath ); } return( path ); @@ -365,12 +365,12 @@ wchar_t *Make_Current_Path_To ( const wchar_t *filename, wchar_t *path ) wchar_t dir [ _MAX_DIR ]; wcscpy( szPath, (wchar_t *)Args->Get_argv(0)); - _wsplitpath( szPath, drive, dir, NULL, NULL ); - _wmakepath( szPath, drive, dir, NULL, NULL ); + _wsplitpath( szPath, drive, dir, nullptr, nullptr ); + _wmakepath( szPath, drive, dir, nullptr, nullptr ); Path_Add_Back_Slash( szPath ); wcscat( szPath, filename ); - if( path != NULL ) { + if( path != nullptr ) { wcscpy( path, szPath ); } return( path ); @@ -392,7 +392,7 @@ wchar_t *Make_Current_Path_To ( const wchar_t *filename, wchar_t *path ) char *Path_Add_Back_Slash ( char *path ) { - if ( path != NULL && *path != '\0' ) { + if ( path != nullptr && *path != '\0' ) { if ( path[ strlen( path )-1 ] != '\\' ) { strcat( path, "\\" ); } @@ -402,7 +402,7 @@ char *Path_Add_Back_Slash ( char *path ) wchar_t *Path_Add_Back_Slash ( wchar_t *path ) { - if ( path != NULL && *path != '\0' ) { + if ( path != nullptr && *path != '\0' ) { if ( path[ wcslen( path )-1 ] != '\\' ) { wcscat( path, L"\\" ); } @@ -426,7 +426,7 @@ wchar_t *Path_Add_Back_Slash ( wchar_t *path ) char *Path_Remove_Back_Slash ( char *path ) { - if ( path != NULL && *path != '\0' ) { + if ( path != nullptr && *path != '\0' ) { if ( path[ strlen( path )-1 ] == '\\' ) { path[ strlen( path )-1 ] = '\0'; } @@ -436,7 +436,7 @@ char *Path_Remove_Back_Slash ( char *path ) wchar_t *Path_Remove_Back_Slash ( wchar_t *path ) { - if ( path != NULL && *path != '\0' ) { + if ( path != nullptr && *path != '\0' ) { if ( path[ wcslen( path )-1 ] == L'\\' ) { path[ wcslen( path )-1 ] = L'\0'; } @@ -460,10 +460,10 @@ void PlugInProductName ( char *szString, char *szName ) char szTextBuf[ MAX_PATH ]; char szOut[ MAX_PATH ]; char szProduct[ MAX_PATH ]; - char * temp = NULL; - char * next = NULL; + char * temp = nullptr; + char * next = nullptr; - if ( szName == NULL || szName[0] == '\0' ) { + if ( szName == nullptr || szName[0] == '\0' ) { return; } @@ -480,7 +480,7 @@ void PlugInProductName ( char *szString, char *szName ) // Substitute each "%P" with "%s". nStrReturn is the index // into the buffer where "%P" was found. //------------------------------------------------------------- - while ( temp != NULL && nCount < 6) { + while ( temp != nullptr && nCount < 6) { next = temp+1; nCount = nCount + 1; temp = strstr( next, "%s" ); @@ -533,8 +533,8 @@ void PlugInProductName( char *szString, int nName ) char szTextBuf[ MAX_PATH ]; char szOut[ MAX_PATH ]; char szProduct[ MAX_PATH ]; - char * temp = NULL; - char * next = NULL; + char * temp = nullptr; + char * next = nullptr; if ( nName <= STRNONE ) { nName = STRNONE; @@ -555,7 +555,7 @@ void PlugInProductName( char *szString, int nName ) // Substitute each "%P" with "%s". nStrReturn is the index // into the buffer where "%P" was found. //------------------------------------------------------------- - while ( temp != NULL && nCount < 6) { + while ( temp != nullptr && nCount < 6) { next = temp+1; nCount = nCount + 1; temp = strstr( next, "%s" ); @@ -608,10 +608,10 @@ void PlugInProductName ( wchar_t *szString, const wchar_t *szName ) wchar_t szTextBuf[ MAX_PATH ]; wchar_t szOut[ MAX_PATH ]; wchar_t szProduct[ MAX_PATH ]; - wchar_t *temp = NULL; - wchar_t *next = NULL; + wchar_t *temp = nullptr; + wchar_t *next = nullptr; - if ( szName == NULL || szName[0] == '\0' ) { + if ( szName == nullptr || szName[0] == '\0' ) { return; } @@ -628,7 +628,7 @@ void PlugInProductName ( wchar_t *szString, const wchar_t *szName ) // Substitute each "%P" with "%s". nStrReturn is the index // into the buffer where "%P" was found. //------------------------------------------------------------- - while ( temp != NULL && nCount < 6) { + while ( temp != nullptr && nCount < 6) { next = temp+1; nCount = nCount + 1; temp = wcsstr( next, L"%s" ); diff --git a/Core/Tools/Autorun/ViewHTML.cpp b/Core/Tools/Autorun/ViewHTML.cpp index dd0bc246c54..88794f35c84 100644 --- a/Core/Tools/Autorun/ViewHTML.cpp +++ b/Core/Tools/Autorun/ViewHTML.cpp @@ -53,7 +53,7 @@ * INPUTS * URL - Website address * Wait - Wait for user to close browser (default = false) -* Callback - User callback to invoke during wait (default = NULL callback) +* Callback - User callback to invoke during wait (default = nullptr callback) * * RESULT * Success - True if successful; otherwise false @@ -70,7 +70,7 @@ bool ViewHTML(const char* url, bool wait, const CallbackHook& callback) //-------------------------------------------------------------------------- // Just return if no URL specified //-------------------------------------------------------------------------- - if ((url == NULL) || (strlen(url) == 0)) + if ((url == nullptr) || (strlen(url) == 0)) { // DebugPrint("***** No URL specified.\n"); Msg( __LINE__, TEXT(__FILE__), TEXT("***** No URL specified." )); @@ -111,10 +111,10 @@ bool ViewHTML(const char* url, bool wait, const CallbackHook& callback) filename2, GENERIC_WRITE, 0, - NULL, + nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, - NULL); + nullptr); if (file == INVALID_HANDLE_VALUE) { @@ -126,12 +126,12 @@ bool ViewHTML(const char* url, bool wait, const CallbackHook& callback) // Write generic contents const char* contents = "ViewHTML"; DWORD written; - WriteFile(file, contents, strlen(contents), &written, NULL); + WriteFile(file, contents, strlen(contents), &written, nullptr); CloseHandle(file); // Find the executable that can launch this file char exeName[MAX_PATH]; - HINSTANCE hInst = FindExecutable(filename2, NULL, exeName); + HINSTANCE hInst = FindExecutable(filename2, nullptr, exeName); // Delete temporary file DeleteFile(filename2); @@ -157,12 +157,12 @@ bool ViewHTML(const char* url, bool wait, const CallbackHook& callback) BOOL createSuccess = CreateProcess( exeName, commandLine, - NULL, - NULL, + nullptr, + nullptr, FALSE, 0, - NULL, - NULL, + nullptr, + nullptr, &startupInfo, &processInfo); diff --git a/Core/Tools/Autorun/WSYS_FileSystem.cpp b/Core/Tools/Autorun/WSYS_FileSystem.cpp index d98795e10db..9f7c92c64f9 100644 --- a/Core/Tools/Autorun/WSYS_FileSystem.cpp +++ b/Core/Tools/Autorun/WSYS_FileSystem.cpp @@ -86,7 +86,7 @@ */ //=============================== -FileSystem *TheFileSystem = NULL; +FileSystem *TheFileSystem = nullptr; //---------------------------------------------------------------------------- // Private Prototypes diff --git a/Core/Tools/Autorun/WSYS_FileSystem.h b/Core/Tools/Autorun/WSYS_FileSystem.h index 7906b70da70..7d27b583b4c 100644 --- a/Core/Tools/Autorun/WSYS_FileSystem.h +++ b/Core/Tools/Autorun/WSYS_FileSystem.h @@ -73,7 +73,7 @@ class FileSystem public: virtual ~FileSystem() {}; - virtual File* open( const Char *filename, Int access = 0 ) = NULL ; ///< opens a File interface to the specified file + virtual File* open( const Char *filename, Int access = 0 ) = 0 ; ///< opens a File interface to the specified file }; diff --git a/Core/Tools/Autorun/WSYS_RAMFile.cpp b/Core/Tools/Autorun/WSYS_RAMFile.cpp index 804fafc41b5..e35cd4cbf25 100644 --- a/Core/Tools/Autorun/WSYS_RAMFile.cpp +++ b/Core/Tools/Autorun/WSYS_RAMFile.cpp @@ -95,7 +95,7 @@ RAMFile::RAMFile() : m_size(0), - m_data(NULL) + m_data(nullptr) { } @@ -132,7 +132,7 @@ Bool RAMFile::open( const Char *filename, Int access ) { File *file = TheFileSystem->open( filename, access ); - if ( file == NULL ) + if ( file == nullptr ) { return FALSE; } @@ -152,9 +152,9 @@ Bool RAMFile::open( const Char *filename, Int access ) Bool RAMFile::open( File *file ) { - if ( file == NULL ) + if ( file == nullptr ) { - return NULL; + return FALSE; } Int access = file->getAccess(); @@ -168,7 +168,7 @@ Bool RAMFile::open( File *file ) m_size = file->size(); m_data = new char [ m_size ]; - if ( m_data == NULL ) + if ( m_data == nullptr ) { return FALSE; } @@ -178,7 +178,7 @@ Bool RAMFile::open( File *file ) if ( m_size < 0 ) { delete [] m_data; - m_data = NULL; + m_data = nullptr; return FALSE; } @@ -199,7 +199,7 @@ Bool RAMFile::open( File *file ) void RAMFile::close( void ) { delete [] m_data; - m_data = NULL; + m_data = nullptr; File::close(); } @@ -210,7 +210,7 @@ void RAMFile::close( void ) Int RAMFile::read( void *buffer, Int bytes ) { - if( m_data == NULL ) + if( m_data == nullptr ) { return -1; } diff --git a/Core/Tools/Autorun/WSYS_StdFileSystem.cpp b/Core/Tools/Autorun/WSYS_StdFileSystem.cpp index 15698cd1c07..2f488696da1 100644 --- a/Core/Tools/Autorun/WSYS_StdFileSystem.cpp +++ b/Core/Tools/Autorun/WSYS_StdFileSystem.cpp @@ -115,7 +115,7 @@ File* StdFileSystem::open( const Char *filename, Int access ) else { delete file; - file = NULL; + file = nullptr; } return (File*) file; diff --git a/Core/Tools/Autorun/WSYS_file.h b/Core/Tools/Autorun/WSYS_file.h index 34cd965d822..0b54ea1493a 100644 --- a/Core/Tools/Autorun/WSYS_file.h +++ b/Core/Tools/Autorun/WSYS_file.h @@ -111,17 +111,17 @@ class File virtual Bool open( const Char *filename, Int access = 0 ); ///< Open a file for access virtual void close( void ); ///< Close the file !!! File object no longer valid after this call !!! - virtual Int read( void *buffer, Int bytes ) = NULL ; /**< Read the specified number of bytes from the file in to the + virtual Int read( void *buffer, Int bytes ) = 0 ; /**< Read the specified number of bytes from the file in to the * memory pointed at by buffer. Returns the number of bytes read. - * Returns -1 if an error occured. + * Returns -1 if an error occurred. */ - virtual Int write( void *buffer, Int bytes ) = NULL ; /**< Write the specified number of bytes from the + virtual Int write( void *buffer, Int bytes ) = 0 ; /**< Write the specified number of bytes from the * memory pointed at by buffer to the file. Returns the number of bytes written. - * Returns -1 if an error occured. + * Returns -1 if an error occurred. */ - virtual Int seek( Int bytes, seekMode mode = CURRENT ) = NULL; /**< Sets the file position of the next read/write operation. Returns the new file + virtual Int seek( Int bytes, seekMode mode = CURRENT ) = 0; /**< Sets the file position of the next read/write operation. Returns the new file * position as the number of bytes from the start of the file. - * Returns -1 if an error occured. + * Returns -1 if an error occurred. * * seekMode determines how the seek is done: * @@ -129,7 +129,7 @@ class File * CURRENT: means seek the specified the number of bytes from the current file position * END: means seek the specified number of bytes back from the end of the file */ - virtual Bool printf ( const Char *format, ...); ///< Prints formated string to text file + virtual Bool printf ( const Char *format, ...); ///< Prints formatted string to text file virtual Int size( void ); ///< Returns the size of the file virtual Int position( void ); ///< Returns the current read/write position diff --git a/Core/Tools/Autorun/WinFix.cpp b/Core/Tools/Autorun/WinFix.cpp index 85e093aaa0f..0a3003b0406 100644 --- a/Core/Tools/Autorun/WinFix.cpp +++ b/Core/Tools/Autorun/WinFix.cpp @@ -93,9 +93,9 @@ WindowsVersionInfo::WindowsVersionInfo(void) : // Start recording messages. //-------------------------------------------------------------------------- Delete_Msg_File(); - Msg( __LINE__, __FILE__, "----------------------------------------------", NULL ); - Msg( __LINE__, __FILE__, "------------------ Setup -----------------", NULL ); - Msg( __LINE__, __FILE__, "----------------------------------------------", NULL ); + Msg( __LINE__, __FILE__, "----------------------------------------------", nullptr ); + Msg( __LINE__, __FILE__, "------------------ Setup -----------------", nullptr ); + Msg( __LINE__, __FILE__, "----------------------------------------------", nullptr ); //-------------------------------------------------------------------------- // Get the version info from the OS. @@ -191,7 +191,7 @@ WindowsVersionInfo::WindowsVersionInfo(void) : DWORD dwBufLen; RegOpenKeyEx( HKEY_LOCAL_MACHINE, "SYSTEM\\CurrentControlSet\\Control\\ProductOptions", 0, KEY_QUERY_VALUE, &hKey ); - RegQueryValueEx( hKey, "ProductType", NULL, NULL, (LPBYTE) szProductType, &dwBufLen); + RegQueryValueEx( hKey, "ProductType", nullptr, nullptr, (LPBYTE) szProductType, &dwBufLen); RegCloseKey( hKey ); if ( lstrcmpi( "WINNT", szProductType) == 0 ) diff --git a/Core/Tools/Autorun/Wnd_file.cpp b/Core/Tools/Autorun/Wnd_file.cpp index 0db0ade1841..3bba17df3f0 100644 --- a/Core/Tools/Autorun/Wnd_file.cpp +++ b/Core/Tools/Autorun/Wnd_file.cpp @@ -132,7 +132,7 @@ void __cdecl Msg( int line, const char *filename, const char *fmt, ... ) // Make filename. //---------------------------------------------------------------------- const char *temp = strrchr( filename, '\\' ); - if ( temp != NULL || temp[0] != '\0' ) { + if ( temp != nullptr || temp[0] != '\0' ) { temp++; strcpy( szFile, temp ); } @@ -203,10 +203,10 @@ void __cdecl Msg( int line, const char *filename, const wchar_t *fmt, UINT codep memset( szBuffer1, '\0', MAX_PATH * 3 ); memset( szBuffer2, '\0', MAX_PATH * 2 ); - if ( DebugFile == NULL ) { + if ( DebugFile == nullptr ) { return; } - if ( filename == NULL ) { + if ( filename == nullptr ) { return; } @@ -214,7 +214,7 @@ void __cdecl Msg( int line, const char *filename, const wchar_t *fmt, UINT codep // Make filename. //---------------------------------------------------------------------- const char *temp = strrchr( filename, '\\' ); - if ( temp != NULL || temp[0] != '\0' ) { + if ( temp != nullptr || temp[0] != '\0' ) { temp++; length = strlen( temp ); mbstowcs( szFile, temp, length ); @@ -240,7 +240,7 @@ void __cdecl Msg( int line, const char *filename, const wchar_t *fmt, UINT codep // 950 Chinese (Taiwan; Hong Kong SAR, PRC) // 1252 Windows 3.1 Latin 1 (US, Western Europe) //--------------------------------------------------------------------- - WideCharToMultiByte( codepage, 0, szBuffer1, -1, szBuffer3, MAX_PATH*3, NULL, NULL ); + WideCharToMultiByte( codepage, 0, szBuffer1, -1, szBuffer3, MAX_PATH*3, nullptr, nullptr ); length = strlen( szBuffer3 ); nBytes = file.Write( szBuffer3, length ); @@ -306,9 +306,9 @@ void Delete_Msg_File ( void ) wsprintf( buff, "===========================================================\r\n" ); nBytes = file.Write( buff, strlen( buff )); - GetDateFormat( LOCALE_USER_DEFAULT, DATE_SHORTDATE, NULL, NULL, date, 50 ); -// GetTimeFormat( LOCALE_USER_DEFAULT, TIME_NOSECONDS, NULL, NULL, time, 30 ); - GetTimeFormat( LOCALE_USER_DEFAULT, NULL, NULL, "hh':'mm':'ss tt", time, 30 ); + GetDateFormat( LOCALE_USER_DEFAULT, DATE_SHORTDATE, nullptr, nullptr, date, 50 ); +// GetTimeFormat( LOCALE_USER_DEFAULT, TIME_NOSECONDS, nullptr, nullptr, time, 30 ); + GetTimeFormat( LOCALE_USER_DEFAULT, 0, nullptr, "hh':'mm':'ss tt", time, 30 ); wsprintf( buff, "SETUP: File: %s Date: %s Time: %s.\r\n", DebugFile, date, time ); nBytes = file.Write( buff, strlen( buff )); @@ -347,7 +347,7 @@ StandardFileClass::~StandardFileClass( void ) ASSERT( File_Handle == INVALID_FILE_HANDLE ); #endif #if( SUPPORT_STREAMS ) - ASSERT( File_Stream_Ptr == NULL ); + ASSERT( File_Stream_Ptr == nullptr ); #endif ASSERT( Currently_Open == FALSE ); @@ -370,7 +370,7 @@ bool StandardFileClass::Open( const char *no_path_file_name, int open_mode ) // // debug checks... // - ASSERT( no_path_file_name != NULL ); + ASSERT( no_path_file_name != nullptr ); ASSERT( Currently_Open == FALSE ); ASSERT( strlen( no_path_file_name ) < MAX_PATH ); ASSERT( open_mode == MODE_READ_ONLY || @@ -418,7 +418,7 @@ bool StandardFileClass::Open( const char *no_path_file_name, int open_mode ) #if( SUPPORT_STREAMS ) - ASSERT( File_Stream_Ptr == NULL ); + ASSERT( File_Stream_Ptr == nullptr ); // // "r" - open existing file for reading. @@ -475,7 +475,7 @@ bool StandardFileClass::Open( const char *no_path_file_name, int open_mode ) // // if not success with HD open, try CD // - if ( File_Stream_Ptr == NULL ) { + if ( File_Stream_Ptr == nullptr ) { // // try CD open @@ -488,7 +488,7 @@ bool StandardFileClass::Open( const char *no_path_file_name, int open_mode ) // // not successful? // - if ( File_Stream_Ptr == NULL ) { + if ( File_Stream_Ptr == nullptr ) { return( FALSE ); } @@ -569,12 +569,12 @@ bool StandardFileClass::Close( void ) #if( SUPPORT_STREAMS ) - ASSERT( File_Stream_Ptr != NULL ); + ASSERT( File_Stream_Ptr != nullptr ); // // error? // - if ( File_Stream_Ptr == NULL || Currently_Open == FALSE ) { + if ( File_Stream_Ptr == nullptr || Currently_Open == FALSE ) { // // no success // @@ -591,7 +591,7 @@ bool StandardFileClass::Close( void ) // // reset file data // - File_Stream_Ptr = NULL; + File_Stream_Ptr = nullptr; Currently_Open = FALSE; // @@ -619,7 +619,7 @@ int StandardFileClass::Read( void *buffer, unsigned long int bytes_to_read ) // // debug checks ( Fails if condition is FALSE ). // - ASSERT( buffer != NULL ); + ASSERT( buffer != nullptr ); ASSERT( bytes_to_read > 0 ); ASSERT( Currently_Open == TRUE ); @@ -644,11 +644,11 @@ int StandardFileClass::Read( void *buffer, unsigned long int bytes_to_read ) #if( SUPPORT_STREAMS ) - ASSERT( File_Stream_Ptr != NULL ); + ASSERT( File_Stream_Ptr != nullptr ); // // error? // - if ( File_Stream_Ptr == NULL || Currently_Open == FALSE ) { + if ( File_Stream_Ptr == nullptr || Currently_Open == FALSE ) { // // nothing read // @@ -690,11 +690,11 @@ int StandardFileClass::Write( void *buffer, unsigned long int bytes_to_write ) // // debug checks // - ASSERT( buffer != NULL ); + ASSERT( buffer != nullptr ); ASSERT( bytes_to_write > 0 ); ASSERT( Currently_Open == TRUE ); - if ( buffer == NULL ) { + if ( buffer == nullptr ) { return( 0 ); } if ( bytes_to_write < 1 ) { @@ -724,11 +724,11 @@ int StandardFileClass::Write( void *buffer, unsigned long int bytes_to_write ) #if( SUPPORT_STREAMS ) - ASSERT( File_Stream_Ptr != NULL ); + ASSERT( File_Stream_Ptr != nullptr ); // // error? // - if ( File_Stream_Ptr == NULL || Currently_Open == FALSE ) { + if ( File_Stream_Ptr == nullptr || Currently_Open == FALSE ) { // // nothing written // @@ -788,12 +788,12 @@ bool StandardFileClass::Seek( int distance, int seek_file_position ) #if( SUPPORT_STREAMS ) - ASSERT( File_Stream_Ptr != NULL ); + ASSERT( File_Stream_Ptr != nullptr ); // // error? // - if ( File_Stream_Ptr == NULL || Currently_Open == FALSE ) { + if ( File_Stream_Ptr == nullptr || Currently_Open == FALSE ) { // // error // @@ -853,11 +853,11 @@ int StandardFileClass::Tell( void ) #if( SUPPORT_STREAMS ) - ASSERT( File_Stream_Ptr != NULL ); + ASSERT( File_Stream_Ptr != nullptr ); // // error? // - if ( File_Stream_Ptr == NULL || Currently_Open == FALSE ) { + if ( File_Stream_Ptr == nullptr || Currently_Open == FALSE ) { // // error // @@ -906,11 +906,11 @@ int StandardFileClass::Query_Size( void ) #endif #if( SUPPORT_STREAMS ) - ASSERT( File_Stream_Ptr != NULL ); + ASSERT( File_Stream_Ptr != nullptr ); // // error? // - if ( File_Stream_Ptr == NULL || Currently_Open == FALSE ) { + if ( File_Stream_Ptr == nullptr || Currently_Open == FALSE ) { // // error // @@ -974,7 +974,7 @@ void StandardFileClass::Reset( void ) File_Handle = INVALID_FILE_HANDLE; #endif #if( SUPPORT_STREAMS ) - File_Stream_Ptr = NULL; + File_Stream_Ptr = nullptr; #endif Currently_Open = FALSE; File_Name[ 0 ] = '\0'; @@ -988,8 +988,8 @@ int StandardFileClass::End_Of_File ( void ) #endif #if( SUPPORT_STREAMS ) - ASSERT( File_Stream_Ptr != NULL ); - if ( File_Stream_Ptr == NULL || Currently_Open == FALSE ) { + ASSERT( File_Stream_Ptr != nullptr ); + if ( File_Stream_Ptr == nullptr || Currently_Open == FALSE ) { return( -1 ); } return( feof( File_Stream_Ptr )); @@ -999,8 +999,8 @@ int StandardFileClass::End_Of_File ( void ) int StandardFileClass::Flush ( void ) { #if( SUPPORT_STREAMS ) - ASSERT( File_Stream_Ptr != NULL ); - if ( File_Stream_Ptr == NULL || Currently_Open == FALSE ) { + ASSERT( File_Stream_Ptr != nullptr ); + if ( File_Stream_Ptr == nullptr || Currently_Open == FALSE ) { return( -1 ); } return( fflush( File_Stream_Ptr )); @@ -1031,7 +1031,7 @@ HANDLE Open_File( char const *file_name, int mode ) // // debug checks... // - ASSERT( file_name != NULL ); + ASSERT( file_name != nullptr ); // ASSERT( mode == READ || mode == WRITE ); ASSERT( mode == MODE_READ_ONLY || mode == MODE_WRITE_ONLY || @@ -1082,10 +1082,10 @@ HANDLE Open_File( char const *file_name, int mode ) windows_file_handle = CreateFile( file_name, access, share, - NULL, + nullptr, creation, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, - NULL ); + nullptr ); // // error? // @@ -1131,7 +1131,7 @@ bool Close_File( HANDLE handle ) // debug checks... // // ASSERT( handle > INVALID_FILE_HANDLE ); - // ASSERT( Windows_File_Handles[ handle ] != NULL ); + // ASSERT( Windows_File_Handles[ handle ] != nullptr ); ASSERT( handle != INVALID_FILE_HANDLE ); // @@ -1149,7 +1149,7 @@ bool Close_File( HANDLE handle ) // // free the entry // - // Windows_File_Handles[ handle ] = NULL; + // Windows_File_Handles[ handle ] = nullptr; // // return success or not @@ -1180,9 +1180,9 @@ int Read_File( HANDLE handle, void *buffer, unsigned long int bytes_to_read ) // debug checks... // ASSERT( handle > INVALID_FILE_HANDLE ); - ASSERT( buffer != NULL ); + ASSERT( buffer != nullptr ); // ASSERT( bytes_to_read > 0 ); - // ASSERT( Windows_File_Handles[ handle ] != NULL ); + // ASSERT( Windows_File_Handles[ handle ] != nullptr ); // Debug_Printf( "Reading file %d\r\n", handle ); @@ -1190,7 +1190,7 @@ int Read_File( HANDLE handle, void *buffer, unsigned long int bytes_to_read ) // (void *) buffer, // (DWORD) bytes_to_read, // (DWORD *) &bytes_actually_read, - // NULL ); + // nullptr ); // // &&& use real HANDLE @@ -1199,7 +1199,7 @@ int Read_File( HANDLE handle, void *buffer, unsigned long int bytes_to_read ) (void *) buffer, (DWORD) bytes_to_read, (DWORD *) &bytes_actually_read, - NULL ); + nullptr ); ASSERT( success == TRUE ); @@ -1226,9 +1226,9 @@ int Write_File( HANDLE handle, void const *buffer, unsigned long int bytes_to_wr // debug checks... // ASSERT( handle != INVALID_FILE_HANDLE ); - ASSERT( buffer != NULL ); + ASSERT( buffer != nullptr ); // ASSERT( bytes_to_write > 0 ); - // ASSERT( Windows_File_Handles[ handle ] != NULL ); + // ASSERT( Windows_File_Handles[ handle ] != nullptr ); // Debug_Printf( "Writing file %d\r\n", handle ); @@ -1236,7 +1236,7 @@ int Write_File( HANDLE handle, void const *buffer, unsigned long int bytes_to_wr // buffer, // (DWORD) bytes_to_write, // (DWORD *) &bytes_actually_written, - // NULL ); + // nullptr ); // // &&& make this a real handle @@ -1245,7 +1245,7 @@ int Write_File( HANDLE handle, void const *buffer, unsigned long int bytes_to_wr buffer, (DWORD) bytes_to_write, (DWORD *) &bytes_actually_written, - NULL ); + nullptr ); ASSERT( success == TRUE ); ASSERT( bytes_actually_written == bytes_to_write ); @@ -1277,7 +1277,7 @@ bool Seek_File( HANDLE handle, int distance, int seek_file_location ) ASSERT( seek_file_location == SEEK_SET || seek_file_location == SEEK_CUR || seek_file_location == SEEK_END ); - // ASSERT( Windows_File_Handles[ handle ] != NULL ); + // ASSERT( Windows_File_Handles[ handle ] != nullptr ); // // set the seek movement method @@ -1294,7 +1294,7 @@ bool Seek_File( HANDLE handle, int distance, int seek_file_location ) // success = SetFilePointer( Windows_File_Handles[ handle ], // distance, - // NULL, + // nullptr, // move_method ); // @@ -1302,7 +1302,7 @@ bool Seek_File( HANDLE handle, int distance, int seek_file_location ) // success = SetFilePointer( (HANDLE) handle, distance, - NULL, + nullptr, move_method ); if ( success == 0xFFFFFFFF ) { @@ -1324,7 +1324,7 @@ int Tell_File( HANDLE handle ) // debug checks... // ASSERT( handle != INVALID_FILE_HANDLE ); - // ASSERT( Windows_File_Handles[ handle ] != NULL ); + // ASSERT( Windows_File_Handles[ handle ] != nullptr ); // // set the seek movement method @@ -1336,7 +1336,7 @@ int Tell_File( HANDLE handle ) // pos = SetFilePointer( handle, 0, // distance to move - NULL, + nullptr, move_method ); if ( pos == 0xFFFFFFFF ) { @@ -1357,9 +1357,9 @@ int File_Size( HANDLE handle ) // debug checks... // ASSERT( handle != INVALID_FILE_HANDLE ); - // ASSERT( Windows_File_Handles[ handle ] != NULL ); + // ASSERT( Windows_File_Handles[ handle ] != nullptr ); - file_size = GetFileSize( handle, NULL ); + file_size = GetFileSize( handle, nullptr ); ASSERT( file_size != 0xFFFFFFFF ); // @@ -1386,7 +1386,7 @@ bool Full_Path_File_Exists( char const *file_name ) // // debug checks... // - ASSERT( file_name != NULL ); + ASSERT( file_name != nullptr ); // // if we can open the file for read, it exists... @@ -1424,7 +1424,7 @@ bool HD_File_Exists( char const *file_name ) // // debug checks... // - ASSERT( file_name != NULL ); + ASSERT( file_name != nullptr ); strcpy( full_path, HD_Path ); strcat( full_path, file_name ); @@ -1463,7 +1463,7 @@ bool CD_File_Exists( char const *file_name ) // // debug checks... // - ASSERT( file_name != NULL ); + ASSERT( file_name != nullptr ); strcpy( full_path, CD_Path ); strcat( full_path, file_name ); @@ -1517,7 +1517,7 @@ int Get_Internal_File_Handle( void ) // if ( ! _initialized ) { for ( i = 0; i < MAX_FILES_OPEN_AT_A_TIME; i ++ ) { - Windows_File_Handles[ i ] = NULL; + Windows_File_Handles[ i ] = nullptr; } _initialized = TRUE; } @@ -1526,7 +1526,7 @@ int Get_Internal_File_Handle( void ) // look for free slot // for ( i = 0; i < MAX_FILES_OPEN_AT_A_TIME; i ++ ) { - if ( Windows_File_Handles[ i ] == NULL ) { + if ( Windows_File_Handles[ i ] == nullptr ) { return( i ); } } @@ -1553,7 +1553,7 @@ bool Full_Path_File_Exists( char const *file_name ) FILE *file_stream_ptr; file_stream_ptr = fopen( file_name, "rb" ); - if ( file_stream_ptr != NULL ) { + if ( file_stream_ptr != nullptr ) { fclose( file_stream_ptr ); return( TRUE ); } @@ -1572,13 +1572,13 @@ bool HD_File_Exists( char const *file_name ) // // debug checks... // - ASSERT( file_name != NULL ); + ASSERT( file_name != nullptr ); strcpy( full_path, HD_Path ); strcat( full_path, file_name ); file_stream_ptr = fopen( full_path, "rb" ); - if ( file_stream_ptr != NULL ) { + if ( file_stream_ptr != nullptr ) { fclose( file_stream_ptr ); return( TRUE ); } @@ -1597,13 +1597,13 @@ bool CD_File_Exists( char const *file_name ) // // debug checks... // - ASSERT( file_name != NULL ); + ASSERT( file_name != nullptr ); strcpy( full_path, CD_Path ); strcat( full_path, file_name ); file_stream_ptr = fopen( full_path, "rb" ); - if ( file_stream_ptr != NULL ) { + if ( file_stream_ptr != nullptr ) { fclose( file_stream_ptr ); return( TRUE ); } diff --git a/Core/Tools/Autorun/autorun.cpp b/Core/Tools/Autorun/autorun.cpp index fefdd6ed6e4..2e5a428c2b3 100644 --- a/Core/Tools/Autorun/autorun.cpp +++ b/Core/Tools/Autorun/autorun.cpp @@ -182,7 +182,7 @@ // Global Variables //----------------------------------------------------------------------------- LaunchObjectClass LaunchObject; -MainWindow *GlobalMainWindow = NULL; +MainWindow *GlobalMainWindow = nullptr; int Language = 0; int LanguageToUse = 0; @@ -284,9 +284,9 @@ BOOL CDLocked = FALSE; int WindowsVersion = 0; int NumberArguments = 0; int SongNumber = 0; -HANDLE AppMutex = NULL; -HANDLE GameAppMutex = NULL; -HANDLE SetupAppMutex = NULL; +HANDLE AppMutex = nullptr; +HANDLE GameAppMutex = nullptr; +HANDLE SetupAppMutex = nullptr; @@ -304,7 +304,7 @@ extern ArchiveFileSystem *TheArchiveFileSystem; #endif // stuff needed to compile. -HWND ApplicationHWnd = NULL; +HWND ApplicationHWnd = nullptr; HINSTANCE ApplicationHInstance; ///< main application instance const char *g_strFile = "Autorun.str"; @@ -385,7 +385,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd ApplicationHInstance = hInstance; Main::hPrevInstance = hPrevInstance; Main::nCmdShow = nCmdShow; - Main::hModule = GetModuleHandle( NULL ); + Main::hModule = GetModuleHandle( nullptr ); memset( szSetupWindow, '\0', MAX_PATH ); memset( szGameWindow, '\0', MAX_PATH ); @@ -416,9 +416,9 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd // Init Args class. //------------------------------------------------------------------------- Args = new Command_Line_Arguments( hInstance, GetCommandLine()); - if ( Args == NULL ) { -// Error_Message( hInstance, IDS_ERROR, IDS_COMMAND_LINE_ERR, NULL ); - Error_Message( hInstance, "Autorun:Error", "Autorun:CommandLineError", NULL ); + if ( Args == nullptr ) { +// Error_Message( hInstance, IDS_ERROR, IDS_COMMAND_LINE_ERR, nullptr ); + Error_Message( hInstance, "Autorun:Error", "Autorun:CommandLineError", nullptr ); return( 0 ); } Msg( __LINE__, __FILE__, "Args Created." ); @@ -539,8 +539,8 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd // Save off the Current path for use by other stuff. //------------------------------------------------------------------------- _tcscpy( szArgvPath, Args->Get_argv(0)); - _tsplitpath( szArgvPath, drive, dir, NULL, NULL ); - _tmakepath ( szArgvPath, drive, dir, NULL, NULL ); + _tsplitpath( szArgvPath, drive, dir, nullptr, nullptr ); + _tmakepath ( szArgvPath, drive, dir, nullptr, nullptr ); Path_Add_Back_Slash( szArgvPath ); Msg( __LINE__, TEXT(__FILE__), TEXT("szArgvPath = %s."), szArgvPath ); @@ -558,7 +558,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd LoadString( Main::hInstance, IDS_CANT_FIND_FILE, szBuffer1, _MAX_PATH ); MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szPath, _MAX_PATH, szWideBuffer0, _MAX_PATH ); sprintf( szBuffer2, szBuffer1, szWideBuffer0 ); - MessageBox( NULL, szBuffer2, "Autorun", MB_APPLMODAL | MB_OK ); + MessageBox( nullptr, szBuffer2, "Autorun", MB_APPLMODAL | MB_OK ); return 0; } */ @@ -583,7 +583,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd //Fix_Single_Ampersands( &szProductName[0], false ); //Fix_Single_Ampersands( &szFullProductName[0], false ); Msg( __LINE__, __FILE__, "szProductName = %s.", szProductName ); - WideCharToMultiByte( CodePage, 0, szProductName, _MAX_PATH, szProduct_Name, _MAX_PATH, NULL, NULL ); + WideCharToMultiByte( CodePage, 0, szProductName, _MAX_PATH, szProduct_Name, _MAX_PATH, nullptr, nullptr ); #else @@ -593,7 +593,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd Msg( __LINE__, __FILE__, "Full Product Name = %ls.", fullProductName.str() ); Msg( __LINE__, __FILE__, "szRegistryKey = %s.", szRegistryKey ); Msg( __LINE__, __FILE__, "szGameWindow = %s.", szGameWindow ); - WideCharToMultiByte( CodePage, 0, productName.str(), productName.getLength()+1, szProduct_Name, _MAX_PATH, NULL, NULL ); + WideCharToMultiByte( CodePage, 0, productName.str(), productName.getLength()+1, szProduct_Name, _MAX_PATH, nullptr, nullptr ); #endif @@ -613,7 +613,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd // If the named mutex object existed before the function call, the function returns // a handle to the existing object and GetLastError returns ERROR_ALREADY_EXISTS. // Otherwise, the caller created the mutex. - // If the function fails, the return value is NULL. To get extended error + // If the function fails, the return value is null. To get extended error // information, call GetLastError. // // WARNING: DO NOT use this number for any other application except Autorun @@ -623,9 +623,9 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd } else { strcpy( szBuffer, AUTORUN_MUTEX_OBJECT ); } - AppMutex = CreateMutex( NULL, FALSE, szBuffer ); + AppMutex = CreateMutex( nullptr, FALSE, szBuffer ); - if ( AppMutex != NULL && ( GetLastError() == ERROR_ALREADY_EXISTS )) { + if ( AppMutex != nullptr && ( GetLastError() == ERROR_ALREADY_EXISTS )) { Msg( __LINE__, __FILE__, "AppMutex of %s already exists. Exit here.", szBuffer ); @@ -636,7 +636,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd //--------------------------------------------------------------------- // Check if Game/Setup is already running, and is looking for the CDRom. //--------------------------------------------------------------------- - HWND prev = FindWindow( szClassName, NULL ); + HWND prev = FindWindow( szClassName, nullptr ); if( prev ){ //if( IsIconic( prev )){ //ShowWindow( prev, SW_RESTORE ); @@ -648,9 +648,9 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd Msg( __LINE__, __FILE__, "AppMutex of %s created.", szBuffer ); //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - // if AppMutex was NULL, let through. Perhaps in future we want to trap it? + // if AppMutex was nullptr, let through. Perhaps in future we want to trap it? //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - if ( AppMutex == NULL ) { + if ( AppMutex == nullptr ) { } //========================================================================= @@ -659,7 +659,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd // // Return Values // If the function succeeds, the return value is a handle to the mutex object. - // If the function fails, the return value is NULL. To get extended error + // If the function fails, the return value is null. To get extended error // information, call GetLastError. // // WARNING: DO NOT use this number for any other application except Game/Setup. @@ -671,12 +671,12 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd } GameAppMutex = OpenMutex( MUTEX_ALL_ACCESS, FALSE, szBuffer ); - if ( GameAppMutex != NULL ) { + if ( GameAppMutex != nullptr ) { Msg( __LINE__, TEXT(__FILE__), TEXT("Mutex Object of game found.")); Msg( __LINE__, TEXT(__FILE__), TEXT("Looking for Game Window.")); - HWND ccwindow = FindWindow( szGameWindow, NULL ); + HWND ccwindow = FindWindow( szGameWindow, nullptr ); if ( ccwindow ) { Msg( __LINE__, TEXT(__FILE__), TEXT("Found Game Window.")); @@ -690,7 +690,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd Msg( __LINE__, TEXT(__FILE__), TEXT("Looking for Setup Window.")); - ccwindow = FindWindow( szSetupWindow, NULL ); + ccwindow = FindWindow( szSetupWindow, nullptr ); if ( ccwindow ) { Msg( __LINE__, TEXT(__FILE__), TEXT("Found Setup Window.")); @@ -713,11 +713,11 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd //--------------------------------------------------------------------- // Check if Game/Setup is already running, and is looking for the CDRom. //--------------------------------------------------------------------- - HWND prev = FindWindow( szClassName, NULL ); - if ( prev == NULL ) { - prev = FindWindow( szGameWindow, NULL ); - if ( prev == NULL ) { - prev = FindWindow( szSetupWindow, NULL ); + HWND prev = FindWindow( szClassName, nullptr ); + if ( prev == nullptr ) { + prev = FindWindow( szGameWindow, nullptr ); + if ( prev == nullptr ) { + prev = FindWindow( szSetupWindow, nullptr ); } } if( prev ){ @@ -735,7 +735,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd // because we ask the user to insert CD-1 again at the end of the install // to prevent a crash on Windows ME where it tries to access CD-1 again. //--------------------------------------------------------------------- - prev = FindWindow( NULL,"InstallShield Wizard"); + prev = FindWindow( nullptr,"InstallShield Wizard"); if( prev ){ return 0; } @@ -761,7 +761,7 @@ int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpszCmd Msg( __LINE__, __FILE__, "szWav[0] = %s.", szWavs[0] ); Msg( __LINE__, __FILE__, "szWav[1] = %s.", szWavs[1] ); - srand(( unsigned )time( NULL )); + srand(( unsigned )time( nullptr )); SongNumber = rand() & 1; // UseSounds = TRUE; @@ -874,32 +874,32 @@ void Prog_End ( void ) CDLocked = false; } - if( Args != NULL ) { + if( Args != nullptr ) { delete( Args ); - Args = NULL; + Args = nullptr; Msg( __LINE__, __FILE__, "Args deleted." ); } - if ( AppMutex != NULL ) { + if ( AppMutex != nullptr ) { CloseHandle( AppMutex ); - AppMutex = NULL; + AppMutex = nullptr; Msg( __LINE__, __FILE__, "AppMutex deleted." ); } - if ( GameAppMutex != NULL) { + if ( GameAppMutex != nullptr) { CloseHandle( GameAppMutex ); - GameAppMutex = NULL; + GameAppMutex = nullptr; } - if ( FontManager != NULL ) { + if ( FontManager != nullptr ) { delete( FontManager ); - FontManager = NULL; + FontManager = nullptr; Msg( __LINE__, __FILE__, "FontManager deleted." ); } - if ( OnlineOptions != NULL ) { + if ( OnlineOptions != nullptr ) { delete( OnlineOptions ); - OnlineOptions = NULL; + OnlineOptions = nullptr; Msg( __LINE__, __FILE__, "OnlineOptions deleted." ); } @@ -929,7 +929,7 @@ int Main::MessageLoop( void ) { MSG msg; - while( GetMessage( &msg, NULL, 0, 0 )) { + while( GetMessage( &msg, nullptr, 0, 0 )) { TranslateMessage( &msg ); DispatchMessage( &msg ); } @@ -998,7 +998,7 @@ void MainWindow::Register( void ) wndclass.hIcon = LoadIcon( Main::hInstance, MAKEINTRESOURCE(1)); // strcpy( szBuffer, "C&C2.ICO" ); -// wndclass.hIcon = (HICON)LoadImage( NULL, szBuffer, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE ); +// wndclass.hIcon = (HICON)LoadImage( nullptr, szBuffer, IMAGE_ICON, 0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE ); wndclass.hCursor = LoadCursor( Main::hInstance, MAKEINTRESOURCE(2) ); wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); @@ -1013,12 +1013,12 @@ void MainWindow::Register( void ) FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, - NULL, + nullptr, GetLastError(), MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), (LPTSTR)&szMessage, 0, - NULL ); + nullptr ); _stprintf( szBuffer, TEXT( "%s(%lx)" ), szMessage, GetLastError()); Msg( __LINE__, TEXT(__FILE__), TEXT("GetLastError: %s"), szBuffer ); @@ -1048,11 +1048,11 @@ MainWindow::MainWindow( void ) #ifdef LEAN_AND_MEAN - WideCharToMultiByte( CodePage, 0, szFullProductName, _MAX_PATH, szBuffer, _MAX_PATH, NULL, NULL ); + WideCharToMultiByte( CodePage, 0, szFullProductName, _MAX_PATH, szBuffer, _MAX_PATH, nullptr, nullptr ); #else - WideCharToMultiByte( CodePage, 0, fullProductName.str(), fullProductName.getLength()+1, szBuffer, _MAX_PATH, NULL, NULL ); + WideCharToMultiByte( CodePage, 0, fullProductName.str(), fullProductName.getLength()+1, szBuffer, _MAX_PATH, nullptr, nullptr ); #endif @@ -1072,8 +1072,8 @@ MainWindow::MainWindow( void ) 0, 640, 480, - NULL, - NULL, + nullptr, + nullptr, Main::hInstance, (LPTSTR) this ); @@ -1139,7 +1139,7 @@ LRESULT MainWindow::Window_Proc( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM decision = DialogBox( Main::hInstance, _TEXT( "BitmapDialog" ), hWnd, Dialog_Box_Proc ); delete( Args ); - Args = NULL; + Args = nullptr; Stop_Sound_Playing(); @@ -1271,7 +1271,7 @@ BOOL MainWindow::Is_Product_Registered( void ) // Get Full path\filename of product to execute ("Play"). //----------------------------------------------------------------------- Size = _MAX_PATH; - if ( RegQueryValueEx( phKey, INSTALL_PATH_KEY, NULL, &Type, (unsigned char *)szGamePath, &Size ) == ERROR_SUCCESS ) { + if ( RegQueryValueEx( phKey, INSTALL_PATH_KEY, nullptr, &Type, (unsigned char *)szGamePath, &Size ) == ERROR_SUCCESS ) { _tcscpy(szWorldbuilderPath, szGamePath); _tcscpy(szPatchgetPath, szGamePath); _tcscat(szGamePath, LAUNCHER_FILENAME); @@ -1302,20 +1302,20 @@ BOOL MainWindow::Is_Product_Registered( void ) if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, key, 0, KEY_ALL_ACCESS, &phKey ) == ERROR_SUCCESS ) { Size = _MAX_PATH; - if ( RegQueryValueEx( phKey, UNINSTALL_STRING_SUBKEY, NULL, &Type, (unsigned char *)aName, &Size ) == ERROR_SUCCESS ) + if ( RegQueryValueEx( phKey, UNINSTALL_STRING_SUBKEY, nullptr, &Type, (unsigned char *)aName, &Size ) == ERROR_SUCCESS ) { //------------------------------------------------------------------------------------------------------ // Look for the uninstall program. If found, set flag. // JFS... need to extract path and command line... 8/26/03 // JFS... further verify that we use a very limited uninstall based on the presence of "IDriver.exe" //------------------------------------------------------------------------------------------------------ - if(strstr(aName,UNINSTALL_EXECUTABLE) != NULL) + if(strstr(aName,UNINSTALL_EXECUTABLE) != nullptr) { char *sp; strcpy( szUninstallPath, aName ); sp = strchr(szUninstallPath,'/'); - if(*sp != NULL) + if(sp != nullptr && *sp != '\0') { strcpy( szUninstallCommandLine, sp ); strcpy( szUninstallPath, aName ); @@ -1368,7 +1368,7 @@ BOOL MainWindow::Is_Product_Registered( void ) // Get Full path\filename of product to execute ("Register.exe"). //----------------------------------------------------------------------- Size = _MAX_PATH; - if ( RegQueryValueEx( phKey, INSTALLPATH_SUBKEY, NULL, &Type, (unsigned char *)szRegisterPath, &Size ) == ERROR_SUCCESS ) { + if ( RegQueryValueEx( phKey, INSTALLPATH_SUBKEY, nullptr, &Type, (unsigned char *)szRegisterPath, &Size ) == ERROR_SUCCESS ) { //-------------------------------------------------------------------- // Check if this executable exists. @@ -1395,7 +1395,7 @@ BOOL MainWindow::Is_Product_Registered( void ) // Get Full path\filename of product to execute ("Register.exe"). //----------------------------------------------------------------------- Size = _MAX_PATH; - if ( RegQueryValueEx( phKey, INSTALLPATH_SUBKEY, NULL, &Type, (unsigned char *)szBuffer, &Size ) == ERROR_SUCCESS ) { + if ( RegQueryValueEx( phKey, INSTALLPATH_SUBKEY, nullptr, &Type, (unsigned char *)szBuffer, &Size ) == ERROR_SUCCESS ) { //-------------------------------------------------------------------- // Check if this executable exists. @@ -1458,8 +1458,8 @@ BOOL MainWindow::Run_Explorer( const char *szString, HWND hWnd, RECT *rect ) // Get current drive/directory from _argv[0]. //-------------------------------------------------------------------------- _tcscpy( szPath, szArgvPath ); - _tsplitpath( szPath, drive, dir, NULL, NULL ); - _tmakepath ( szPath, drive, dir, NULL, NULL ); + _tsplitpath( szPath, drive, dir, nullptr, nullptr ); + _tmakepath ( szPath, drive, dir, nullptr, nullptr ); //-------------------------------------------------------------------------- // Get Windows directory and build path to Explorer. Pas in szPath as @@ -1484,11 +1484,11 @@ BOOL MainWindow::Run_Explorer( const char *szString, HWND hWnd, RECT *rect ) result = CreateProcess( szWindowsPath, // address of module name lpszComLine, // address of command line - NULL, // address of process security attributes - NULL, // address of thread security attributes + nullptr, // address of process security attributes + nullptr, // address of thread security attributes FALSE, // new process inherits handles 0, // creation flags - NULL, // address of new environment block + nullptr, // address of new environment block szCurDir, // address of current directory name &startupinfo, // address of STARTUPINFO &processinfo ); // address of PROCESS_INFORMATION @@ -1539,7 +1539,7 @@ unsigned int MainWindow::Run_Game ( HWND hWnd, RECT *rect ) // Check if C&C is already running, and is looking for the CDRom. // The Autorun keeps asking to "Play" when this happens. //-------------------------------------------------------------------------- - HWND game_window = FindWindow ( szGameWindow, NULL ); + HWND game_window = FindWindow ( szGameWindow, nullptr ); if ( game_window ){ ShowWindow( game_window, SW_RESTORE ); SetForegroundWindow ( game_window ); @@ -1745,11 +1745,11 @@ unsigned int MainWindow::Run_OpenFile(int cd_drive, const char *filename, bool w while ((waiting == true) && (quit != true)) { Sleep(0); - while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) ) + while( PeekMessage( &msg, nullptr, 0, 0, PM_NOREMOVE ) ) { // get the message - returnValue = GetMessage( &msg, NULL, 0, 0 ); + returnValue = GetMessage( &msg, nullptr, 0, 0 ); // check for quitting if( returnValue == 0 ) @@ -2059,8 +2059,8 @@ unsigned int MainWindow::Run_Uninstall( HWND hWnd, RECT *rect ) FindClose( handle ); - _splitpath( szUninstallPath, drive, dir, NULL, NULL ); - _makepath ( szCurDir, drive, dir, NULL, NULL ); + _splitpath( szUninstallPath, drive, dir, nullptr, nullptr ); + _makepath ( szCurDir, drive, dir, nullptr, nullptr ); //======================================================================= // Setup the call @@ -2071,11 +2071,11 @@ unsigned int MainWindow::Run_Uninstall( HWND hWnd, RECT *rect ) result = CreateProcess( szUninstallPath, // address of module name szUninstallCommandLine, // address of command line - NULL, // address of process security attributes - NULL, // address of thread security attributes + nullptr, // address of process security attributes + nullptr, // address of thread security attributes 0, // new process inherits handles 0, - NULL, // address of new environment block + nullptr, // address of new environment block szCurDir, &startupinfo, // address of STARTUPINFO &processinfo ); // address of PROCESS_INFORMATION @@ -2085,8 +2085,8 @@ unsigned int MainWindow::Run_Uninstall( HWND hWnd, RECT *rect ) //-------------------------------------------------------------------------- if ( !result ) { - _tsplitpath( szUninstallPath, NULL, NULL, file, ext ); - _tmakepath ( szPath, NULL, NULL, file, ext ); + _tsplitpath( szUninstallPath, nullptr, nullptr, file, ext ); + _tmakepath ( szPath, nullptr, nullptr, file, ext ); Cant_Find_MessageBox ( Main::hInstance, szPath ); // #if(BACKGROUND_BITMAP) @@ -2117,7 +2117,7 @@ unsigned int MainWindow::Run_Uninstall( HWND hWnd, RECT *rect ) //----------------------------------------------------------------------- // Flush the Queue //----------------------------------------------------------------------- - while (PeekMessage( &msg, NULL, 0, 0, PM_REMOVE )) { + while (PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE )) { TranslateMessage( &msg ); // DispatchMessage( &msg ); } @@ -2216,7 +2216,7 @@ void MainWindow::Create_Buttons( HWND hWnd, RECT *dlg_rect ) for ( i = 0; i < NUM_BUTTONS; i++ ) { delete( ButtonList[i] ); - ButtonList[i] = NULL; + ButtonList[i] = nullptr; ButtonSizes[i].left = x_pos; // X position. ButtonSizes[i].top = y_pos; // Y position. ButtonSizes[i].right = width; // Button's width. @@ -2505,7 +2505,7 @@ LRESULT CALLBACK Wnd_Proc ( HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lPa // msg is called. Then we use the GlobalMainWindow's WindowProc to // process all the individual msgs sent. //-------------------------------------------------------------------------- - if ( GlobalMainWindow == NULL ) { + if ( GlobalMainWindow == nullptr ) { if ( iMessage == WM_CREATE ) { LPCREATESTRUCT lpcs; @@ -2556,7 +2556,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param HDC hDC, memDC, buttonDC, licenseDC; BITMAP bm, fm, lm; -// LOGPALETTE * plgpl = NULL; +// LOGPALETTE * plgpl = nullptr; PAINTSTRUCT ps; static int bits_pixel = 0; static int idCtl = 0; @@ -2657,7 +2657,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param wideBuffer = TheGameText->fetch("Autorun:Title"); wideBuffer2.format(wideBuffer, fullProductName.str()); - WideCharToMultiByte( CodePage, 0, wideBuffer2.str(), wideBuffer2.getLength()+1, szBuffer, _MAX_PATH, NULL, NULL ); + WideCharToMultiByte( CodePage, 0, wideBuffer2.str(), wideBuffer2.getLength()+1, szBuffer, _MAX_PATH, nullptr, nullptr ); #endif @@ -2689,7 +2689,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param HDC hdc = GetDC( window_handle ); FontManager = new FontManagerClass( hdc ); - assert( FontManager != NULL ); + assert( FontManager != nullptr ); ReleaseDC( window_handle, hdc ); //======================================================================= @@ -2870,7 +2870,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param //----------------------------------------------------------------------- i = 0; while ( i < NUM_BUTTONS ) { - if ( ButtonList[i] == NULL ) { + if ( ButtonList[i] == nullptr ) { i++; } else { break; @@ -2891,7 +2891,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param // Msg( __LINE__, TEXT(__FILE__), TEXT("buttons_rect = [%d,%d,%d,%d]"), buttons_rect.left, buttons_rect.top, buttons_rect.right, buttons_rect.bottom ); for( j = 0; j < NUM_BUTTONS; j++ ) { - if ( ButtonList[j] != NULL ) { + if ( ButtonList[j] != nullptr ) { buttons_rect.left = __min( ButtonSizes[j].left , buttons_rect.left ); buttons_rect.top = __min( ButtonSizes[j].top , buttons_rect.top ); buttons_rect.right = __max( ButtonSizes[j].left + ButtonSizes[j].right , buttons_rect.right ); @@ -2963,7 +2963,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param // Who is the first button? //----------------------------------------------------------------------- while ( i < NUM_BUTTONS ) { - if ( ButtonList[i] == NULL ) { + if ( ButtonList[i] == nullptr ) { i++; } else { break; @@ -2983,7 +2983,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param //------------------------------------------------------------------- // Make areas between the buttons. //------------------------------------------------------------------- - if ( ButtonList[index] != NULL && ButtonList[index+1] != NULL ) { + if ( ButtonList[index] != nullptr && ButtonList[index+1] != nullptr ) { // Area between buttons. BackgroundRect[j].top = ButtonList[index]->Return_Y_Pos() + ButtonList[index]->Return_Height(); @@ -2996,7 +2996,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param //------------------------------------------------------------------- // Now look for areas in front of and behind each button. //------------------------------------------------------------------- - if ( ButtonList[index] != NULL ) { + if ( ButtonList[index] != nullptr ) { // Area in front of buttons. BackgroundRect[j].top = ButtonList[index]->Return_Y_Pos(); @@ -3044,8 +3044,8 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param //======================================================================= // Set dialog's timer! 1000 = 1 second. //======================================================================= -// timer_id = SetTimer( window_handle, 1000, 250L, NULL ); - timer_id = SetTimer( window_handle, 1000, 500L, NULL ); +// timer_id = SetTimer( window_handle, 1000, 250L, nullptr ); + timer_id = SetTimer( window_handle, 1000, 500L, nullptr ); } return( TRUE ); @@ -3120,13 +3120,13 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param } GameAppMutex = OpenMutex( MUTEX_ALL_ACCESS, FALSE, szBuffer ); - if ( GameAppMutex != NULL ) { + if ( GameAppMutex != nullptr ) { //--------------------------------------------------------- // Handle(s) are closed in the ProgEnd(). //--------------------------------------------------------- - HWND ccwindow = FindWindow( szGameWindow, NULL ); + HWND ccwindow = FindWindow( szGameWindow, nullptr ); if ( ccwindow ) { if( IsIconic( ccwindow )){ ShowWindow( ccwindow, SW_RESTORE ); @@ -3135,7 +3135,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param } else { - ccwindow = FindWindow( szSetupWindow, NULL ); + ccwindow = FindWindow( szSetupWindow, nullptr ); if ( ccwindow ) { if( IsIconic( ccwindow )){ ShowWindow( ccwindow, SW_RESTORE ); @@ -3261,7 +3261,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param HGDIOBJ oldpen = SelectObject( hDC, pen ); SetBkMode( hDC, TRANSPARENT ); - MoveToEx( hDC, BackgroundRect[i].left+1, BackgroundRect[i].top+1, NULL ); + MoveToEx( hDC, BackgroundRect[i].left+1, BackgroundRect[i].top+1, nullptr ); LineTo( hDC, BackgroundRect[i].right-1, BackgroundRect[i].top+1 ); LineTo( hDC, BackgroundRect[i].right-1, BackgroundRect[i].bottom-1 ); LineTo( hDC, BackgroundRect[i].left+1, BackgroundRect[i].bottom-1 ); @@ -3337,7 +3337,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param HGDIOBJ oldpen = SelectObject( hDC, pen ); SetBkMode( hDC, TRANSPARENT ); - MoveToEx( hDC, flicker_rect.left+1, flicker_rect.top+1, NULL ); + MoveToEx( hDC, flicker_rect.left+1, flicker_rect.top+1, nullptr ); LineTo( hDC, flicker_rect.right-1, flicker_rect.top+1 ); LineTo( hDC, flicker_rect.right-1, flicker_rect.bottom-1 ); LineTo( hDC, flicker_rect.left+1, flicker_rect.bottom-1 ); @@ -3462,7 +3462,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param MoveToEx( hDC, // handle to device context outline_rect.left, // x-coordinate of new current position outline_rect.top, // y-coordinate of new current position - NULL ); // pointer to old current position + nullptr ); // pointer to old current position LineTo( hDC, // device context handle outline_rect.right, // x-coordinate of line's ending point @@ -3509,7 +3509,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param MoveToEx( hDC, ButtonList[i]->Return_X_Pos()-1, - ButtonList[i]->Return_Y_Pos()-1, NULL ); + ButtonList[i]->Return_Y_Pos()-1, nullptr ); LineTo( hDC, ButtonList[i]->Return_X_Pos() + ButtonList[i]->Return_Width() + 1, ButtonList[i]->Return_Y_Pos()-1 ); @@ -3560,7 +3560,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param // Print text at bottom of screen. //=================================================================== Rect text_rect; - TTFontClass *fontptr = NULL; + TTFontClass *fontptr = nullptr; if ( b640X480 ) { fontptr = TTTextFontPtr640; @@ -3674,7 +3674,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param //----------------------------------------------------------------------- if ( FirstTime ) { if( UseSounds ) { - PlaySound( szWavs[ SongNumber ], NULL, SND_ASYNC | SND_RESOURCE ); + PlaySound( szWavs[ SongNumber ], nullptr, SND_ASYNC | SND_RESOURCE ); } FirstTime = FALSE; } @@ -3736,10 +3736,10 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param std::wstring wideBuffer = TheGameText->fetch("Autorun:CantRunAVIs"); std::wstring wideBuffer2 = TheGameText->fetch("Autorun:Error"); int length = wideBuffer.length(); - WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, NULL, NULL ); + WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, nullptr, nullptr ); length = wideBuffer2.length(); - WideCharToMultiByte( CodePage, 0, wideBuffer2.c_str(), length+1, szBuffer2, _MAX_PATH, NULL, NULL ); - MessageBox( NULL, szBuffer, szBuffer2, MB_APPLMODAL | MB_OK ); + WideCharToMultiByte( CodePage, 0, wideBuffer2.c_str(), length+1, szBuffer2, _MAX_PATH, nullptr, nullptr ); + MessageBox( nullptr, szBuffer, szBuffer2, MB_APPLMODAL | MB_OK ); } */ } @@ -3781,10 +3781,10 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param std::wstring wideBuffer = TheGameText->fetch("Autorun:CantRunHelp"); std::wstring wideBuffer2 = TheGameText->fetch("Autorun:Error"); int length = wideBuffer.length(); - WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, NULL, NULL ); + WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, nullptr, nullptr ); length = wideBuffer2.length(); - WideCharToMultiByte( CodePage, 0, wideBuffer2.c_str(), length+1, szBuffer2, _MAX_PATH, NULL, NULL ); - MessageBox( NULL, szBuffer, szBuffer2, MB_APPLMODAL | MB_OK ); + WideCharToMultiByte( CodePage, 0, wideBuffer2.c_str(), length+1, szBuffer2, _MAX_PATH, nullptr, nullptr ); + MessageBox( nullptr, szBuffer, szBuffer2, MB_APPLMODAL | MB_OK ); } */ } @@ -3972,7 +3972,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param for ( i = 0; i < NUM_BUTTONS; i++ ) { delete( ButtonList[i] ); - ButtonList[i] = NULL; + ButtonList[i] = nullptr; } if ( hpal ) { DeleteObject( hpal ); @@ -4012,7 +4012,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param for ( i = 0; i < NUM_BUTTONS; i++ ) { delete( ButtonList[i] ); - ButtonList[i] = NULL; + ButtonList[i] = nullptr; } if ( hpal ) { DeleteObject( hpal ); @@ -4041,7 +4041,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param // Delete the arguments. //----------------------------------------------------------------------- delete( Args ); - Args = NULL; + Args = nullptr; KillTimer( window_handle, timer_id ); EndDialog( window_handle, w_param ); @@ -4092,7 +4092,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param UnrealizeObject( hStaticBrush ); // reset the origin of the brush next time used. point.x = point.y = 0; // create a point. ClientToScreen( window_handle, &point ); // translate into screen coordinates. - SetBrushOrgEx( (HDC)w_param, point.x, point.y, NULL ); // New Origin to use when next selected. + SetBrushOrgEx( (HDC)w_param, point.x, point.y, nullptr ); // New Origin to use when next selected. return((LRESULT) hStaticBrush ); } #endif @@ -4590,7 +4590,7 @@ BOOL CALLBACK Dialog_Box_Proc( HWND window_handle, UINT message, WPARAM w_param void Stop_Sound_Playing ( void ) { - PlaySound( NULL, NULL, SND_ASYNC | SND_FILENAME ); + PlaySound( nullptr, nullptr, SND_ASYNC | SND_FILENAME ); } //***************************************************************************** @@ -4650,7 +4650,7 @@ BOOL Options( Command_Line_Arguments *Orgs ) sprintf( szBuffer3, szBuffer, szVersion ); // strcpy( szBuffer, szRegistryKey ); - MessageBox( NULL, szBuffer3, "Autorun", MB_TASKMODAL | MB_OK ); + MessageBox( nullptr, szBuffer3, "Autorun", MB_TASKMODAL | MB_OK ); result = FALSE; } break; @@ -4807,10 +4807,10 @@ BOOL Valid_Environment ( void ) std::wstring wideBuffer = TheGameText->fetch("GUI:WindowsVersionText"); std::wstring wideBuffer2 = TheGameText->fetch("GUI:WindowsVersionTitle"); length = wideBuffer.length(); - WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, NULL, NULL ); + WideCharToMultiByte( CodePage, 0, wideBuffer.c_str(), length+1, szBuffer, _MAX_PATH, nullptr, nullptr ); length = wideBuffer2.length(); - WideCharToMultiByte( CodePage, 0, wideBuffer2.c_str(), length+1, szBuffer2, _MAX_PATH, NULL, NULL ); - MessageBox( NULL, szBuffer, szBuffer2, MB_APPLMODAL | MB_OK ); + WideCharToMultiByte( CodePage, 0, wideBuffer2.c_str(), length+1, szBuffer2, _MAX_PATH, nullptr, nullptr ); + MessageBox( nullptr, szBuffer, szBuffer2, MB_APPLMODAL | MB_OK ); } return( result ); @@ -4837,7 +4837,7 @@ HBITMAP LoadResourceBitmap( HINSTANCE hInstance, LPCTSTR lpString, HPALETTE FAR int iNumColors; HRSRC hRsrc; HGLOBAL hGlobal; - HBITMAP hBitmapFinal = NULL; + HBITMAP hBitmapFinal = nullptr; LPBITMAPINFOHEADER lpbi; hBitmapFinal = LoadBitmap( hInstance, lpString ); @@ -4901,7 +4901,7 @@ HPALETTE CreateDIBPalette ( LPBITMAPINFO lpbmi, LPINT lpiNumColors ) LPBITMAPINFOHEADER lpbi; LPLOGPALETTE lpPal; HANDLE hLogPal; - HPALETTE hPal = NULL; + HPALETTE hPal = nullptr; int i; lpbi = (LPBITMAPINFOHEADER) lpbmi; @@ -4976,7 +4976,7 @@ HBITMAP LoadResourceButton( HINSTANCE hInstance, LPCTSTR lpString, HPALETTE FAR int iNumColors; HRSRC hRsrc; HGLOBAL hGlobal; - HBITMAP hBitmapFinal = NULL; + HBITMAP hBitmapFinal = nullptr; LPBITMAPINFOHEADER lpbi; //-------------------------------------------------------------------------- @@ -4990,7 +4990,7 @@ HBITMAP LoadResourceButton( HINSTANCE hInstance, LPCTSTR lpString, HPALETTE FAR //----------------------------------------------------------------------- hGlobal = LoadResource( hInstance, hRsrc ); lpbi = (LPBITMAPINFOHEADER) LockResource( hGlobal ); - hdc = GetDC( NULL ); + hdc = GetDC( nullptr ); //-------------------------------------------------------------------------- // Set number of colors ( 2 to the nth ). @@ -5006,7 +5006,7 @@ HBITMAP LoadResourceButton( HINSTANCE hInstance, LPCTSTR lpString, HPALETTE FAR // Select to the DC and realize it in the System palette. //----------------------------------------------------------------------- // *lphPalette = CreateDIBPalette((LPBITMAPINFO) lpbi, &iNumColors ); - if ( lphPalette != NULL ) { + if ( lphPalette != nullptr ) { SelectPalette( hdc, lphPalette, FALSE ); RealizePalette( hdc ); } @@ -5025,7 +5025,7 @@ HBITMAP LoadResourceButton( HINSTANCE hInstance, LPCTSTR lpString, HPALETTE FAR //----------------------------------------------------------------------- // Free DS and memory used. //----------------------------------------------------------------------- - ReleaseDC( NULL, hdc ); + ReleaseDC( nullptr, hdc ); UnlockResource( hGlobal ); FreeResource( hGlobal ); } @@ -5063,7 +5063,7 @@ void Cant_Find_MessageBox ( HINSTANCE hInstance, const char *szPath ) MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, szPath, _MAX_PATH, szWideBuffer0, _MAX_PATH ); swprintf( szWideBuffer2, szWideBuffer, szWideBuffer0 ); - MessageBoxW( NULL, szWideBuffer2, szWideBuffer3, MB_APPLMODAL | MB_OK ); + MessageBoxW( nullptr, szWideBuffer2, szWideBuffer3, MB_APPLMODAL | MB_OK ); } #else @@ -5072,8 +5072,8 @@ void Cant_Find_MessageBox ( HINSTANCE hInstance, const char *szPath ) std::wstring wideBuffer2.format( wideBuffer.str(), productName.str() ); std::wstring wideBuffer3 = TheGameText->fetch("Autorun:CantFind"); - WideCharToMultiByte( CodePage, 0, wideBuffer3.str(), wideBuffer3.getLength()+1, szBuffer3, _MAX_PATH, NULL, NULL ); - WideCharToMultiByte( CodePage, 0, wideBuffer2.str(), wideBuffer2.getLength()+1, szBuffer2, _MAX_PATH, NULL, NULL ); + WideCharToMultiByte( CodePage, 0, wideBuffer3.str(), wideBuffer3.getLength()+1, szBuffer3, _MAX_PATH, nullptr, nullptr ); + WideCharToMultiByte( CodePage, 0, wideBuffer2.str(), wideBuffer2.getLength()+1, szBuffer2, _MAX_PATH, nullptr, nullptr ); sprintf( szBuffer1, szBuffer3, szPath ); @@ -5081,29 +5081,29 @@ void Cant_Find_MessageBox ( HINSTANCE hInstance, const char *szPath ) if ( strlen( szPath ) < 3 ) { - MessageBox( NULL, "The path specified in Cant_Find_MessageBox was blank", "Autorun", MB_APPLMODAL | MB_OK ); + MessageBox( nullptr, "The path specified in Cant_Find_MessageBox was blank", "Autorun", MB_APPLMODAL | MB_OK ); return; } if ( strlen( szBuffer1 ) < 3 && strlen( szBuffer3 ) < 3 ) { - MessageBox( NULL, "***MISSING MESSAGES***... IDS_AUTORUN_TITLE and IDS_CANT_FIND", "Autorun", MB_APPLMODAL | MB_OK ); + MessageBox( nullptr, "***MISSING MESSAGES***... IDS_AUTORUN_TITLE and IDS_CANT_FIND", "Autorun", MB_APPLMODAL | MB_OK ); return; } if ( strlen( szBuffer1 ) < 3 ) { - MessageBox( NULL, "***MISSING MESSAGE***... IDS_AUTORUN_TITLE", "Autorun", MB_APPLMODAL | MB_OK ); + MessageBox( nullptr, "***MISSING MESSAGE***... IDS_AUTORUN_TITLE", "Autorun", MB_APPLMODAL | MB_OK ); return; } if ( strlen( szBuffer3 ) < 3 ) { - MessageBox( NULL, "***MISSING MESSAGE***... IDS_CANT_FIND", "Autorun", MB_APPLMODAL | MB_OK ); + MessageBox( nullptr, "***MISSING MESSAGE***... IDS_CANT_FIND", "Autorun", MB_APPLMODAL | MB_OK ); return; } - MessageBox( NULL, szBuffer1, szBuffer2, MB_APPLMODAL | MB_OK ); + MessageBox( nullptr, szBuffer1, szBuffer2, MB_APPLMODAL | MB_OK ); #endif } @@ -5139,14 +5139,14 @@ void Error_Message ( HINSTANCE hInstance, const char * title, const char * strin wideBuffer3 = wideBuffer; // insert not provided } - WideCharToMultiByte( CodePage, 0, wideBuffer2.str(), wideBuffer2.getLength()+1, szBuffer2, _MAX_PATH, NULL, NULL ); - WideCharToMultiByte( CodePage, 0, wideBuffer3.str(), wideBuffer3.getLength()+1, szBuffer3, _MAX_PATH, NULL, NULL ); + WideCharToMultiByte( CodePage, 0, wideBuffer2.str(), wideBuffer2.getLength()+1, szBuffer2, _MAX_PATH, nullptr, nullptr ); + WideCharToMultiByte( CodePage, 0, wideBuffer3.str(), wideBuffer3.getLength()+1, szBuffer3, _MAX_PATH, nullptr, nullptr ); - MessageBox( NULL, szBuffer3, szBuffer2, MB_APPLMODAL | MB_OK ); + MessageBox( nullptr, szBuffer3, szBuffer2, MB_APPLMODAL | MB_OK ); #endif - MessageBox( NULL, "ERROR_UNDEFINED", "ERROR_UNDEFINED", MB_APPLMODAL | MB_OK ); + MessageBox( nullptr, "ERROR_UNDEFINED", "ERROR_UNDEFINED", MB_APPLMODAL | MB_OK ); } @@ -5161,17 +5161,17 @@ LaunchObjectClass::LaunchObjectClass ( char *path, char *args ) memset( szPath, '\0', _MAX_PATH ); memset( szArgs, '\0', _MAX_PATH ); - if( path != NULL && path[0] != '\0' ) { + if( path != nullptr && path[0] != '\0' ) { strcpy( szPath, path ); } - if( args != NULL && args[0] != '\0' ) { + if( args != nullptr && args[0] != '\0' ) { strcpy( szArgs, args ); } } void LaunchObjectClass::SetPath ( char *path ) { - if( path != NULL && path[0] != '\0' ) { + if( path != nullptr && path[0] != '\0' ) { memset( szPath, '\0', _MAX_PATH ); strcpy( szPath, path ); } @@ -5179,7 +5179,7 @@ void LaunchObjectClass::SetPath ( char *path ) void LaunchObjectClass::SetArgs ( char *args ) { - if( args != NULL && args[0] != '\0' ) { + if( args != nullptr && args[0] != '\0' ) { memset( szArgs, '\0', _MAX_PATH ); strcpy( szArgs, args ); } @@ -5214,7 +5214,7 @@ unsigned int LaunchObjectClass::Launch ( void ) // new working drive (1=A, 2=B, and so forth). This function changes only // the working drive; _chdir changes the working directory. //-------------------------------------------------------------------------- - _makepath( filepath, drive, dir, NULL, NULL ); + _makepath( filepath, drive, dir, nullptr, nullptr ); Path_Remove_Back_Slash( filepath ); abc = (unsigned)( toupper( filepath[0] ) - 'A' + 1 ); @@ -5250,12 +5250,12 @@ unsigned int LaunchObjectClass::Launch ( void ) result = CreateProcess( szPath, // address of module name lpszComLine, // address of command line - NULL, // address of process security attributes - NULL, // address of thread security attributes + nullptr, // address of process security attributes + nullptr, // address of thread security attributes FALSE, // new process inherits handles FALSE, - NULL, // address of new environment block - NULL, // address of current directory name + nullptr, // address of new environment block + nullptr, // address of current directory name &startupinfo, // address of STARTUPINFO &processinfo ); // address of PROCESS_INFORMATION @@ -5265,7 +5265,7 @@ unsigned int LaunchObjectClass::Launch ( void ) if ( !result ) { Msg( __LINE__, TEXT(__FILE__), TEXT("Launch of %s failed." ), lpszComLine ); - _makepath ( filepath, NULL, NULL, file, ext ); + _makepath ( filepath, nullptr, nullptr, file, ext ); Cant_Find_MessageBox ( Main::hInstance, filepath ); } Msg( __LINE__, TEXT(__FILE__), TEXT("Launch of %s succeeded." ), lpszComLine ); @@ -5428,7 +5428,7 @@ int Show_Message ( HWND window_handle, const char * message1, const char * messa wcscat( szString3, L" " ); wcscat( szString3, string2.str() ); - WideCharToMultiByte( CodePage, 0, szString3, _MAX_PATH, szBuffer, _MAX_PATH, NULL, NULL ); + WideCharToMultiByte( CodePage, 0, szString3, _MAX_PATH, szBuffer, _MAX_PATH, nullptr, nullptr ); result = MessageBox( window_handle, szBuffer, "Autorun", MB_RETRYCANCEL|MB_APPLMODAL|MB_SETFOREGROUND ); return( result ); @@ -5452,7 +5452,7 @@ void Reformat_Volume_Name ( const char *volume_name, char *new_volume_name ) temp_volume_name[11] = '\0'; } - if( new_volume_name != NULL ) { + if( new_volume_name != nullptr ) { strcpy( new_volume_name, temp_volume_name ); } } diff --git a/Core/Tools/Autorun/autorun.h b/Core/Tools/Autorun/autorun.h index 65a10e11240..6bc37e82884 100644 --- a/Core/Tools/Autorun/autorun.h +++ b/Core/Tools/Autorun/autorun.h @@ -165,7 +165,7 @@ typedef enum { class LaunchObjectClass { public: - LaunchObjectClass ( char *path=NULL, char *args=NULL ); + LaunchObjectClass ( char *path=nullptr, char *args=nullptr ); void SetPath ( char *path ); void SetArgs ( char *args ); @@ -228,7 +228,7 @@ class MainWindow : public Window static void Register ( void ); static void Reset_Class_Name ( char *string ) { - if ( string != NULL && string[0] != '\0' ) { + if ( string != nullptr && string[0] != '\0' ) { strcpy( szClassName, string ); } }; diff --git a/Core/Tools/Autorun/locale.cpp b/Core/Tools/Autorun/locale.cpp index 1abc9cf1035..fde9d77a78b 100644 --- a/Core/Tools/Autorun/locale.cpp +++ b/Core/Tools/Autorun/locale.cpp @@ -91,7 +91,7 @@ typedef struct INDEX* pIndex[LOCALE_BANK_COUNT]; /* array of string indices */ } LOCALE_INSTANCE; -static LOCALE_INSTANCE *lx = NULL; +static LOCALE_INSTANCE *lx = nullptr; /*************************************************************************/ /* initialization/restore */ @@ -100,10 +100,10 @@ static LOCALE_INSTANCE *lx = NULL; /* helper function to make assertions for initialization clearer */ int LOCALE_isinitialized( void ) { - if ( lx == NULL ) { + if ( lx == nullptr ) { // TRACE("LOCALE API is not initialized - call LOCALE_init before calling LOCALE functions\n"); } - return( lx != NULL ); + return( lx != nullptr ); } /* @@ -148,11 +148,11 @@ int LOCALE_init(void) int ok = 0; /* ensure locale module is NOT already initialized */ - ASSERT(lx == NULL); /* can only call LOCALE_init after a restore or once, cannot double init locale API */ + ASSERT(lx == nullptr); /* can only call LOCALE_init after a restore or once, cannot double init locale API */ /* allocate instance */ lx = (LOCALE_INSTANCE*)galloc(sizeof(LOCALE_INSTANCE)); - if (lx != NULL) { + if (lx != nullptr) { memset(lx, 0, sizeof(LOCALE_INSTANCE)); ok = 1; } @@ -198,10 +198,10 @@ void LOCALE_restore(void) { int i; - if( lx != NULL ) { + if( lx != nullptr ) { ASSERT(LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */ - ASSERT(lx != NULL); + ASSERT(lx != nullptr); /* free any language tables */ for (i = 0; i < LOCALE_BANK_COUNT; i++) { @@ -213,7 +213,7 @@ void LOCALE_restore(void) /* free instance */ gfree(lx); - lx = NULL; + lx = nullptr; } } @@ -415,7 +415,7 @@ int LOCALE_getbankstringcount(void) ; DESCRIPTION ; ; Loads the specified language from the string file into the -; current bank. Returns non zero if the operation was succesful. +; current bank. Returns non-zero if the operation was successful. ; The bank must be free before you can call LOCALE_loadtable. To ; free a bank use the LOCALE_freetable function. To determine ; if the bank is free use the LOCALE_getbankstringcount function. @@ -508,7 +508,7 @@ static int readheader( GSTREAM* g ) static int readstrings( GSTREAM* g, int LanguageID ) { - Msg( __LINE__, __FILE__, "readstrings:: g ok? %d.", ((g!= NULL)?1:0)); + Msg( __LINE__, __FILE__, "readstrings:: g ok? %d.", ((g!= nullptr)?1:0)); int ok = 0; @@ -567,11 +567,11 @@ int LOCALE_loadtable(const char* PathName, int LanguageID) GSTREAM* g; ASSERT(LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */ - ASSERT(lx->pBank[lx->BankIndex] == NULL); /* bank must be empty before loading a new table */ - ASSERT(lx->pIndex[lx->BankIndex] == NULL); /* bank must be empty before loading a new table */ + ASSERT(lx->pBank[lx->BankIndex] == nullptr); /* bank must be empty before loading a new table */ + ASSERT(lx->pIndex[lx->BankIndex] == nullptr); /* bank must be empty before loading a new table */ g = gopen( PathName ); - if( g != NULL ) { + if( g != nullptr ) { Msg( __LINE__, __FILE__, "LOCALE_loadtable-- file opened." ); @@ -637,19 +637,19 @@ int LOCALE_loadtable(const char* PathName, int LanguageID) void LOCALE_freetable(void) { - if( lx != NULL ) { + if( lx != nullptr ) { ASSERT(LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */ ASSERT(lx->pBank[lx->BankIndex]); /* table must be loaded before calling this function */ /* free string bank */ gfree(lx->pBank[lx->BankIndex]); - lx->pBank[lx->BankIndex] = NULL; + lx->pBank[lx->BankIndex] = nullptr; /* if the bank has an index loaded, free that as well */ if (lx->pIndex[lx->BankIndex]) { gfree(lx->pIndex[lx->BankIndex]); - lx->pIndex[lx->BankIndex] = NULL; + lx->pIndex[lx->BankIndex] = nullptr; } } } @@ -714,12 +714,12 @@ static int getstringbyindex( unsigned short key, const INDEX* pIndex ) unsigned char* base; /* pointer to base of string id table */ ASSERT(LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */ - ASSERT(pIndex != NULL); /* index not loaded - .loc file must have index created (use -i option) */ + ASSERT(pIndex != nullptr); /* index not loaded - .loc file must have index created (use -i option) */ base = ((unsigned char*)pIndex) + LOCALEFILE_INDEXCHUNK_STRINGID_OFFSET; result = (unsigned short*)bsearch((unsigned char *)&key, base, pIndex->StringCount, 4, compare); - if (result != NULL) { + if (result != nullptr) { /* index is the second unsigned short */ ++result; index = *result; @@ -731,14 +731,14 @@ static int getstringbyindex( unsigned short key, const INDEX* pIndex ) const char* LOCALE_getstring( int StringID ) { - const char* p; /* pointer to string, NULL if string cannot be found */ + const char* p; /* pointer to string, nullptr if string cannot be found */ Msg( __LINE__, __FILE__, "Locale_getstring::( %d ).", StringID ); ASSERT( LOCALE_isinitialized()); /* must call LOCALE_init before calling this function */ /* get string array index from the index if it exists */ - if ( lx->pIndex[ lx->BankIndex ] != NULL ) { + if ( lx->pIndex[ lx->BankIndex ] != nullptr ) { StringID = getstringbyindex((unsigned short)StringID, lx->pIndex[lx->BankIndex]); } @@ -766,7 +766,7 @@ const char* LOCALE_getstring( int StringID ) } else { - p = NULL; + p = nullptr; } Msg( __LINE__, __FILE__, L"%s", 1252, (wchar_t *)p ); @@ -823,12 +823,12 @@ int LOCALElanguageid = 0; const char* LOCALE_getstr( const void* pLocFile, int StringID ) { - const char* p; /* pointer to string, NULL if string cannot be found */ + const char* p; /* pointer to string, nullptr if string cannot be found */ HEADER* pHeader; BANK* pBank; - ASSERT(pLocFile != NULL); + ASSERT(pLocFile != nullptr); pHeader = (LOCALEFILE_HEADERCHUNK*)(pLocFile); ASSERT(pHeader->ChunkID == LOCALEFILE_HEADERCHUNKID); @@ -856,7 +856,7 @@ const char* LOCALE_getstr( const void* pLocFile, int StringID ) p += offset; } else { - p = NULL; + p = nullptr; } return p; diff --git a/Core/Tools/Babylon/Babylon.cpp b/Core/Tools/Babylon/Babylon.cpp index 7354eefcb9a..2974163c51d 100644 --- a/Core/Tools/Babylon/Babylon.cpp +++ b/Core/Tools/Babylon/Babylon.cpp @@ -35,11 +35,11 @@ static char THIS_FILE[] = __FILE__; #endif char AppTitle[200]; -CBabylonDlg *MainDLG = NULL; +CBabylonDlg *MainDLG = nullptr; static const char *AppName = "Babylon:"; static int AlreadyRunning( void ); -static HWND FoundWindow = NULL; +static HWND FoundWindow = nullptr; ///////////////////////////////////////////////////////////////////////////// // CBabylonApp @@ -62,8 +62,8 @@ CBabylonApp::CBabylonApp() // The one and only CBabylonApp object CBabylonApp theApp; -TransDB *BabylonstrDB = NULL; -TransDB *MainDB = NULL; +TransDB *BabylonstrDB = nullptr; +TransDB *MainDB = nullptr; char BabylonstrFilename[_MAX_PATH]; char MainXLSFilename[_MAX_PATH]; char DialogPath[_MAX_PATH]; @@ -208,7 +208,7 @@ BOOL CALLBACK EnumAllWindowsProc(HWND hWnd, LPARAM lParam) return FALSE; } - FoundWindow = NULL; + FoundWindow = nullptr; return TRUE; } @@ -227,7 +227,7 @@ BOOL CALLBACK EnumAllWindowsProcExact(HWND hWnd, LPARAM lParam) return FALSE; } - FoundWindow = NULL; + FoundWindow = nullptr; return TRUE; } diff --git a/Core/Tools/Babylon/BabylonDlg.cpp b/Core/Tools/Babylon/BabylonDlg.cpp index 27706df01f2..66911d9ede9 100644 --- a/Core/Tools/Babylon/BabylonDlg.cpp +++ b/Core/Tools/Babylon/BabylonDlg.cpp @@ -196,7 +196,7 @@ END_MESSAGE_MAP() IMPLEMENT_DYNAMIC(CBabylonDlg, CDialog); -CBabylonDlg::CBabylonDlg(CWnd* pParent /*=NULL*/) +CBabylonDlg::CBabylonDlg(CWnd* pParent /*=nullptr*/) : CDialog(CBabylonDlg::IDD, pParent) { //{{AFX_DATA_INIT(CBabylonDlg) @@ -204,16 +204,16 @@ CBabylonDlg::CBabylonDlg(CWnd* pParent /*=NULL*/) //}}AFX_DATA_INIT // Note that LoadIcon does not require a subsequent DestroyIcon in Win32 m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME); - m_pAutoProxy = NULL; + m_pAutoProxy = nullptr; } CBabylonDlg::~CBabylonDlg() { // If there is an automation proxy for this dialog, set - // its back pointer to this dialog to NULL, so it knows + // its back pointer to this dialog to nullptr, so it knows // the dialog has been deleted. - if (m_pAutoProxy != NULL) - m_pAutoProxy->m_pDialog = NULL; + if (m_pAutoProxy != nullptr) + m_pAutoProxy->m_pDialog = nullptr; } @@ -266,7 +266,7 @@ BOOL CBabylonDlg::OnInitDialog() ASSERT(IDM_ABOUTBOX < 0xF000); CMenu* pSysMenu = GetSystemMenu(FALSE); - if (pSysMenu != NULL) + if (pSysMenu != nullptr) { CString strAboutMenu; strAboutMenu.LoadString(IDS_ABOUTBOX); @@ -427,7 +427,7 @@ BOOL CBabylonDlg::CanExit() // If the proxy object is still around, then the automation // controller is still holding on to this application. Leave // the dialog around, but hide its UI. - if (m_pAutoProxy != NULL) + if (m_pAutoProxy != nullptr) { ShowWindow(SW_HIDE); return FALSE; @@ -451,7 +451,7 @@ BOOL CBabylonDlg::CanExit() //DEL } //DEL else //DEL { -//DEL SelectFile ( NULL ); +//DEL SelectFile ( nullptr ); //DEL } //DEL delete dlg; //DEL } @@ -684,7 +684,7 @@ void CBabylonDlg::Status( const char *string, int log ) int CBabylonDlg::SaveLog() { - FILE *log = NULL; + FILE *log = nullptr; EDITSTREAM es; CRichEditCtrl *rec = (CRichEditCtrl *) GetDlgItem ( IDC_LOG ); int ok = FALSE; @@ -759,7 +759,7 @@ static int readToEndOfQuote( FILE *file, char *in, char *out, char *wavefile, in { if ( !(ch = *in++)) { - in = NULL; // have exhausted the input buffer + in = nullptr; // have exhausted the input buffer ch = getc ( file ); } } @@ -835,7 +835,7 @@ static int readToEndOfQuote( FILE *file, char *in, char *out, char *wavefile, in { if ( !(ch = *in++)) { - in = NULL; // have exhausted the input buffer + in = nullptr; // have exhausted the input buffer ch = getc ( file ); } } @@ -1037,8 +1037,8 @@ static int getLabelCount( char *filename ) int CBabylonDlg::LoadStrFile ( TransDB *db, const char *filename, void (*cb) ( void ) ) { - FILE *file = NULL; - BabylonLabel *label = NULL; + FILE *file = nullptr; + BabylonLabel *label = nullptr; int status = FALSE; int line_number = 0; int label_count = 0; @@ -1128,7 +1128,7 @@ int CBabylonDlg::LoadStrFile ( TransDB *db, const char *filename, void (*cb) ( v { cb (); } - label = NULL; + label = nullptr; } status = TRUE; @@ -1538,7 +1538,7 @@ int CBabylonDlg::UpdateLabel( BabylonLabel *source, BabylonLabel *destination, U } - // ask the user to resolve remaing unmatched strings + // ask the user to resolve remaining unmatched strings { @@ -1555,7 +1555,7 @@ int CBabylonDlg::UpdateLabel( BabylonLabel *source, BabylonLabel *destination, U if ( !stext->Matched () ) { int result; - BabylonText *match = NULL; + BabylonText *match = nullptr; if ( update && !skip ) { @@ -2076,7 +2076,7 @@ int CBabylonDlg::MatchText ( BabylonText *text, BabylonLabel *label, BabylonText CMatchDlg dlg; int result; - *match = NULL; + *match = nullptr; sprintf ( buffer, "Text: %s\n\nLabel:%s\n", text->GetSB (), label->NameSB () ); // TODO: Add your control notification handler code here @@ -2128,7 +2128,7 @@ void CBabylonDlg::OnImport() { if ( CanOperate ()) { - CFileDialog fd ( TRUE , NULL, "*.xls", OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR ); + CFileDialog fd ( TRUE , nullptr, "*.xls", OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR ); if ( fd.DoModal () == IDOK ) { @@ -2159,7 +2159,7 @@ int CBabylonDlg::ValidateStrFile( const char *filename) PROCESS_INFORMATION ProcessInfo; const char *results = "strcheck.rst"; int errors = 0; - FILE *file = NULL; + FILE *file = nullptr; StartupInfo.cb = sizeof(STARTUPINFO); StartupInfo.dwFlags = STARTF_USESHOWWINDOW; @@ -2175,15 +2175,14 @@ int CBabylonDlg::ValidateStrFile( const char *filename) sprintf ( buffer, "strcheck %s %s", filename, results ); - if (!CreateProcess( - NULL, + if (!CreateProcess( nullptr, buffer, - NULL, - NULL, + nullptr, + nullptr, FALSE, 0, - NULL, - NULL, + nullptr, + nullptr, &StartupInfo, &ProcessInfo)) { @@ -2497,7 +2496,7 @@ void CBabylonDlg::OnTranslations() void CBabylonDlg::OnSelchangeCombolang() { - LANGINFO *info = NULL; + LANGINFO *info = nullptr; int index; index = combo->GetCurSel (); @@ -2557,7 +2556,7 @@ void CBabylonDlg::OnSent() // TODO: Add your control notification handler code here if ( CanOperate ()) { - CFileDialog fd ( TRUE , NULL, "*.xls", OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR ); + CFileDialog fd ( TRUE , nullptr, "*.xls", OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR ); if ( fd.DoModal () == IDOK ) { diff --git a/Core/Tools/Babylon/BabylonDlg.h b/Core/Tools/Babylon/BabylonDlg.h index 677e782611b..fbf9900e407 100644 --- a/Core/Tools/Babylon/BabylonDlg.h +++ b/Core/Tools/Babylon/BabylonDlg.h @@ -90,9 +90,9 @@ class CBabylonDlg : public CDialog int SaveLog ( void ); void Status ( const char *string, int log = TRUE); void Log ( const char *string, LogFormat format = NEW_LINE ); - CBabylonDlg(CWnd* pParent = NULL); // standard constructor + CBabylonDlg(CWnd* pParent = nullptr); // standard constructor virtual ~CBabylonDlg(); - int LoadStrFile ( TransDB *db, const char *fileaname, void (*cb ) (void ) = NULL ); + int LoadStrFile ( TransDB *db, const char *fileaname, void (*cb ) (void ) = nullptr ); void Ready ( void ) { Status ( "Ready", FALSE ); ProgressComplete(); }; // Dialog Data diff --git a/Core/Tools/Babylon/CMakeLists.txt b/Core/Tools/Babylon/CMakeLists.txt index a85ee41a72c..39dc7ca37fb 100644 --- a/Core/Tools/Babylon/CMakeLists.txt +++ b/Core/Tools/Babylon/CMakeLists.txt @@ -57,7 +57,7 @@ set_target_properties(core_babylon PROPERTIES OUTPUT_NAME babylon) target_sources(core_babylon PRIVATE ${BABYLON_SRC}) target_link_libraries(core_babylon PRIVATE - core_config + corei_always ) if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") diff --git a/Core/Tools/Babylon/DlgProxy.cpp b/Core/Tools/Babylon/DlgProxy.cpp index 6442aa5c774..86a51df1034 100644 --- a/Core/Tools/Babylon/DlgProxy.cpp +++ b/Core/Tools/Babylon/DlgProxy.cpp @@ -47,7 +47,7 @@ CBabylonDlgAutoProxy::CBabylonDlgAutoProxy() // main window pointer. Set the proxy's internal pointer // to point to the dialog, and set the dialog's back pointer to // this proxy. - ASSERT (AfxGetApp()->m_pMainWnd != NULL); + ASSERT (AfxGetApp()->m_pMainWnd != nullptr); ASSERT_VALID (AfxGetApp()->m_pMainWnd); ASSERT_KINDOF(CBabylonDlg, AfxGetApp()->m_pMainWnd); m_pDialog = (CBabylonDlg*) AfxGetApp()->m_pMainWnd; @@ -59,8 +59,8 @@ CBabylonDlgAutoProxy::~CBabylonDlgAutoProxy() // To terminate the application when all objects created with // with automation, the destructor calls AfxOleUnlockApp. // Among other things, this will destroy the main dialog - if (m_pDialog != NULL) - m_pDialog->m_pAutoProxy = NULL; + if (m_pDialog != nullptr) + m_pDialog->m_pAutoProxy = nullptr; AfxOleUnlockApp(); } diff --git a/Core/Tools/Babylon/ExportDlg.cpp b/Core/Tools/Babylon/ExportDlg.cpp index 991bc7a803f..4fd6a980879 100644 --- a/Core/Tools/Babylon/ExportDlg.cpp +++ b/Core/Tools/Babylon/ExportDlg.cpp @@ -36,7 +36,7 @@ static int max_index; // CExportDlg dialog -CExportDlg::CExportDlg(CWnd* pParent /*=NULL*/) +CExportDlg::CExportDlg(CWnd* pParent /*=nullptr*/) : CDialog(CExportDlg::IDD, pParent) { //{{AFX_DATA_INIT(CExportDlg) @@ -149,7 +149,7 @@ BOOL CExportDlg::OnInitDialog() // TODO: Add extra initialization here combo = (CComboBox *) GetDlgItem ( IDC_COMBOLANG ); - combo->SetItemDataPtr ( 0, NULL ); + combo->SetItemDataPtr ( 0, nullptr ); options.filter = TR_CHANGES; options.include_comments = FALSE; @@ -198,7 +198,7 @@ BOOL CExportDlg::OnInitDialog() void CExportDlg::OnSelchangeCombolang() { // TODO: Add your control notification handler code here - LANGINFO *info = NULL; + LANGINFO *info = nullptr; int index; CButton *export_button = (CButton *) GetDlgItem ( IDOK ); CComboBox *combo = (CComboBox *) GetDlgItem ( IDC_COMBOLANG ); diff --git a/Core/Tools/Babylon/ExportDlg.h b/Core/Tools/Babylon/ExportDlg.h index af799753f60..63a9c5b9478 100644 --- a/Core/Tools/Babylon/ExportDlg.h +++ b/Core/Tools/Babylon/ExportDlg.h @@ -40,7 +40,7 @@ class CExportDlg : public CDialog char* Filename ( void ) { return filename; }; TROPTIONS* Options ( void ) { return &options; }; - CExportDlg(CWnd* pParent = NULL); // standard constructor + CExportDlg(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CExportDlg) diff --git a/Core/Tools/Babylon/GenerateDlg.cpp b/Core/Tools/Babylon/GenerateDlg.cpp index aa7adfa2f4e..b54905f3cff 100644 --- a/Core/Tools/Babylon/GenerateDlg.cpp +++ b/Core/Tools/Babylon/GenerateDlg.cpp @@ -34,7 +34,7 @@ static char THIS_FILE[] = __FILE__; // CGenerateDlg dialog -CGenerateDlg::CGenerateDlg(CWnd* pParent /*=NULL*/) +CGenerateDlg::CGenerateDlg(CWnd* pParent /*=nullptr*/) : CDialog(CGenerateDlg::IDD, pParent) { options.format = GN_UNICODE; diff --git a/Core/Tools/Babylon/GenerateDlg.h b/Core/Tools/Babylon/GenerateDlg.h index 1be84d2b50b..8e5248b99d3 100644 --- a/Core/Tools/Babylon/GenerateDlg.h +++ b/Core/Tools/Babylon/GenerateDlg.h @@ -43,7 +43,7 @@ class CGenerateDlg : public CDialog // Construction public: - CGenerateDlg(CWnd* pParent = NULL); // standard constructor + CGenerateDlg(CWnd* pParent = nullptr); // standard constructor char* FilePrefix ( void ) { return filename; }; GNOPTIONS* Options ( void ) { return &options; }; diff --git a/Core/Tools/Babylon/MatchDlg.cpp b/Core/Tools/Babylon/MatchDlg.cpp index a01c513aeb0..a0a14e78765 100644 --- a/Core/Tools/Babylon/MatchDlg.cpp +++ b/Core/Tools/Babylon/MatchDlg.cpp @@ -29,18 +29,18 @@ static char THIS_FILE[] = __FILE__; #endif -BabylonText *MatchingBabylonText = NULL; +BabylonText *MatchingBabylonText = nullptr; BabylonText *MatchOriginalText; BabylonLabel *MatchLabel; #define MAX_MATCH 256 -static BabylonText *current_match = NULL; +static BabylonText *current_match = nullptr; ///////////////////////////////////////////////////////////////////////////// // CMatchDlg dialog -CMatchDlg::CMatchDlg(CWnd* pParent /*=NULL*/) +CMatchDlg::CMatchDlg(CWnd* pParent /*=nullptr*/) : CDialog(CMatchDlg::IDD, pParent) { //{{AFX_DATA_INIT(CMatchDlg) @@ -74,14 +74,14 @@ void CMatchDlg::OnCancel() { // TODO: Add extra cleanup here - MatchingBabylonText = NULL; + MatchingBabylonText = nullptr; CDialog::OnCancel(); } void CMatchDlg::OnNomatch() { // TODO: Add your control notification handler code here - MatchingBabylonText = NULL; + MatchingBabylonText = nullptr; CDialog::OnOK (); } @@ -112,7 +112,7 @@ BOOL CMatchDlg::OnInitDialog() SetWindowText ( buffer ); CDialog::OnInitDialog(); - current_match = NULL; + current_match = nullptr; newtext = (CStatic *) GetDlgItem ( IDC_NEWTEXT ); newtext->SetWindowText ( MatchOriginalText->GetSB()); @@ -149,7 +149,7 @@ BOOL CMatchDlg::OnInitDialog() combo->SetCurSel ( 0 ); OnSelchangeMatchcombo(); - MatchingBabylonText = NULL; + MatchingBabylonText = nullptr; // TODO: Add extra initialization here return TRUE; // return TRUE unless you set the focus to a control @@ -173,7 +173,7 @@ void CMatchDlg::OnSelchangeMatchcombo() } else { - current_match = NULL; + current_match = nullptr; } } diff --git a/Core/Tools/Babylon/MatchDlg.h b/Core/Tools/Babylon/MatchDlg.h index 56fa8dacc05..d6bcd7f247e 100644 --- a/Core/Tools/Babylon/MatchDlg.h +++ b/Core/Tools/Babylon/MatchDlg.h @@ -31,7 +31,7 @@ class CMatchDlg : public CDialog { // Construction public: - CMatchDlg(CWnd* pParent = NULL); // standard constructor + CMatchDlg(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CMatchDlg) diff --git a/Core/Tools/Babylon/ProceedDlg.cpp b/Core/Tools/Babylon/ProceedDlg.cpp index 46bf943fd74..30ceb05a443 100644 --- a/Core/Tools/Babylon/ProceedDlg.cpp +++ b/Core/Tools/Babylon/ProceedDlg.cpp @@ -33,7 +33,7 @@ static char THIS_FILE[] = __FILE__; // ProceedDlg dialog -ProceedDlg::ProceedDlg(const char *nmessage, CWnd* pParent /*=NULL*/) +ProceedDlg::ProceedDlg(const char *nmessage, CWnd* pParent /*=nullptr*/) : CDialog(ProceedDlg::IDD, pParent) { //{{AFX_DATA_INIT(ProceedDlg) diff --git a/Core/Tools/Babylon/ProceedDlg.h b/Core/Tools/Babylon/ProceedDlg.h index ee42c7809be..5584d4368f3 100644 --- a/Core/Tools/Babylon/ProceedDlg.h +++ b/Core/Tools/Babylon/ProceedDlg.h @@ -30,7 +30,7 @@ class ProceedDlg : public CDialog // Construction const char *message; public: - ProceedDlg(const char *message, CWnd* pParent = NULL); // standard constructor + ProceedDlg(const char *message, CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(ProceedDlg) diff --git a/Core/Tools/Babylon/Report.cpp b/Core/Tools/Babylon/Report.cpp index 5fe3a770479..ac345d828f8 100644 --- a/Core/Tools/Babylon/Report.cpp +++ b/Core/Tools/Babylon/Report.cpp @@ -34,7 +34,7 @@ static char THIS_FILE[] = __FILE__; // CReport dialog -CReport::CReport(CWnd* pParent /*=NULL*/) +CReport::CReport(CWnd* pParent /*=nullptr*/) : CDialog(CReport::IDD, pParent) { @@ -170,7 +170,7 @@ void CReport::OnOK() } // get the filename - CFileDialog fd ( FALSE , NULL, "*.txt", OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR ); + CFileDialog fd ( FALSE , nullptr, "*.txt", OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR ); if ( fd.DoModal () != IDOK ) { diff --git a/Core/Tools/Babylon/Report.h b/Core/Tools/Babylon/Report.h index 93a66d12cd9..f159ef82dbc 100644 --- a/Core/Tools/Babylon/Report.h +++ b/Core/Tools/Babylon/Report.h @@ -44,7 +44,7 @@ class CReport : public CDialog // Construction public: - CReport(CWnd* pParent = NULL); // standard constructor + CReport(CWnd* pParent = nullptr); // standard constructor char* Filename ( void ) { return filename; }; RPOPTIONS* Options ( void ) { return &options; }; diff --git a/Core/Tools/Babylon/RetranslateDlg.cpp b/Core/Tools/Babylon/RetranslateDlg.cpp index d586c668a83..5b1506e1eb7 100644 --- a/Core/Tools/Babylon/RetranslateDlg.cpp +++ b/Core/Tools/Babylon/RetranslateDlg.cpp @@ -33,7 +33,7 @@ static char THIS_FILE[] = __FILE__; // RetranslateDlg dialog -RetranslateDlg::RetranslateDlg(CWnd* pParent /*=NULL*/) +RetranslateDlg::RetranslateDlg(CWnd* pParent /*=nullptr*/) : CDialog(RetranslateDlg::IDD, pParent) { //{{AFX_DATA_INIT(RetranslateDlg) diff --git a/Core/Tools/Babylon/RetranslateDlg.h b/Core/Tools/Babylon/RetranslateDlg.h index 4c7354ff65e..d7e451044c8 100644 --- a/Core/Tools/Babylon/RetranslateDlg.h +++ b/Core/Tools/Babylon/RetranslateDlg.h @@ -34,7 +34,7 @@ class RetranslateDlg : public CDialog BabylonText *newtext; BabylonText *oldtext; - RetranslateDlg(CWnd* pParent = NULL); // standard constructor + RetranslateDlg(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(RetranslateDlg) diff --git a/Core/Tools/Babylon/TransDB.cpp b/Core/Tools/Babylon/TransDB.cpp index 5ef14300b94..1e1ae4d0de4 100644 --- a/Core/Tools/Babylon/TransDB.cpp +++ b/Core/Tools/Babylon/TransDB.cpp @@ -44,7 +44,7 @@ static LANGINFO langinfo[] = { LANGID_KOREAN, "Korean", "ko", "k" }, { LANGID_CHINESE, "Chinese", "ch", "c" }, { LANGID_JABBER, "Jabberwockie", "jb", "e" }, - { LANGID_UNKNOWN, "Unknown", NULL, NULL } + { LANGID_UNKNOWN, "Unknown", nullptr, nullptr } }; LANGINFO *GetLangInfo ( int index ) @@ -55,7 +55,7 @@ LANGINFO *GetLangInfo ( int index ) return &langinfo[index]; } - return NULL; + return nullptr; } LANGINFO *GetLangInfo ( LangID langid ) @@ -73,7 +73,7 @@ LANGINFO *GetLangInfo ( LangID langid ) item++; } - return NULL; + return nullptr; } const char *GetLangName ( LangID langid ) @@ -103,7 +103,7 @@ LANGINFO *GetLangInfo ( char *language ) item++; } - return NULL; + return nullptr; } TransDB* FirstTransDB ( void ) @@ -115,7 +115,7 @@ TransDB* FirstTransDB ( void ) { return (TransDB *) first->Item (); } - return NULL; + return nullptr; } TransDB::TransDB ( const char *cname ) @@ -199,7 +199,7 @@ void TransDB::RemoveLabel ( BabylonLabel *label ) if ( (node = labels.Find ( label )) ) { node->Remove (); - label->SetDB ( NULL ); + label->SetDB ( nullptr ); label_bin->Remove ( label ); delete node; Changed (); @@ -263,7 +263,7 @@ BabylonLabel* TransDB::FirstLabel ( ListSearch& sh ) return (BabylonLabel *) node->Item (); } - return NULL; + return nullptr; } BabylonLabel* TransDB::NextLabel ( ListSearch& sh) @@ -275,7 +275,7 @@ BabylonLabel* TransDB::NextLabel ( ListSearch& sh) return (BabylonLabel *) node->Item (); } - return NULL; + return nullptr; } BabylonText* TransDB::FirstObsolete ( ListSearch& sh ) @@ -287,7 +287,7 @@ BabylonText* TransDB::FirstObsolete ( ListSearch& sh ) return (BabylonText *) node->Item (); } - return NULL; + return nullptr; } BabylonText* TransDB::NextObsolete ( ListSearch& sh) @@ -299,7 +299,7 @@ BabylonText* TransDB::NextObsolete ( ListSearch& sh) return (BabylonText *) node->Item (); } - return NULL; + return nullptr; } BabylonLabel* TransDB::FindLabel ( OLECHAR *name ) @@ -346,7 +346,7 @@ BabylonText* TransDB::FindSubText ( OLECHAR *pattern, int item ) label = NextLabel ( sh ); } - return NULL; + return nullptr; } @@ -537,17 +537,17 @@ TransDB* TransDB::Next ( void ) return (TransDB *) next->Item (); } - return NULL; + return nullptr; } void BabylonLabel::init ( void ) { - db = NULL; - comment = NULL; + db = nullptr; + comment = nullptr; line_number = -1; max_len = 0; - name = NULL; + name = nullptr; } BabylonLabel::BabylonLabel ( void ) @@ -587,9 +587,9 @@ void BabylonLabel::RemoveText ( BabylonText *txt ) if ( (node = text.Find ( txt )) ) { node->Remove (); - txt->SetDB ( NULL ); - txt->SetLabel ( NULL ); - txt->SetParent ( NULL ); + txt->SetDB ( nullptr ); + txt->SetLabel ( nullptr ); + txt->SetParent ( nullptr ); delete node; Changed (); } @@ -667,7 +667,7 @@ BabylonText* BabylonLabel::FirstText ( ListSearch& sh ) return (BabylonText *) node->Item (); } - return NULL; + return nullptr; } BabylonText* BabylonLabel::NextText ( ListSearch& sh) @@ -679,7 +679,7 @@ BabylonText* BabylonLabel::NextText ( ListSearch& sh) return (BabylonText *) node->Item (); } - return NULL; + return nullptr; } @@ -699,7 +699,7 @@ BabylonText* BabylonLabel::FindText ( OLECHAR *find_text ) txt = NextText ( sh ); } - return NULL; + return nullptr; } @@ -876,12 +876,12 @@ void BabylonLabel::AddToTree ( CTreeCtrl *tc, HTREEITEM parent, int changes void BabylonText::init ( void ) { - db = NULL; - label = NULL; + db = nullptr; + label = nullptr; line_number = -1; revision = 1; - text = NULL; - wavefile = NULL; + text = nullptr; + wavefile = nullptr; id = -1; retranslate = FALSE; sent = FALSE; @@ -1087,7 +1087,7 @@ Translation* BabylonText::FirstTranslation ( ListSearch& sh ) return (Translation *) node->Item (); } - return NULL; + return nullptr; } Translation* BabylonText::NextTranslation ( ListSearch& sh) @@ -1099,7 +1099,7 @@ Translation* BabylonText::NextTranslation ( ListSearch& sh) return (Translation *) node->Item (); } - return NULL; + return nullptr; } Translation* BabylonText::GetTranslation ( LangID langid ) @@ -1471,7 +1471,7 @@ int TransDB::Warnings ( CBabylonDlg *dlg ) { if ( dlg ) { - sprintf ( buffer, "Warning:: text at line %5d is NULL", + sprintf ( buffer, "Warning:: text at line %5d is null", text->LineNumber()); dlg->Log ( buffer ); } diff --git a/Core/Tools/Babylon/TransDB.h b/Core/Tools/Babylon/TransDB.h index fd508f9e18c..813f2fafe2e 100644 --- a/Core/Tools/Babylon/TransDB.h +++ b/Core/Tools/Babylon/TransDB.h @@ -123,7 +123,7 @@ class DBAttribs public: - DBAttribs( void ) { parent = NULL; changed = FALSE; processed = FALSE; match = NULL; }; + DBAttribs( void ) { parent = nullptr; changed = FALSE; processed = FALSE; match = nullptr; }; void SetParent ( DBAttribs *new_parent ) { parent = new_parent; }; int IsChanged ( void ) { return changed; }; @@ -135,7 +135,7 @@ class DBAttribs void NotProcessed ( void ) { processed = FALSE; }; void* Matched ( void ) { return match; }; void Match ( void* new_match ) { match = new_match; }; - void NotMatched ( void ) { match = NULL; }; + void NotMatched ( void ) { match = nullptr; }; }; @@ -360,19 +360,19 @@ class TransDB : public DBAttribs ~TransDB ( ); void InvalidateDialog( LangID langid ); - void VerifyDialog( LangID langid, void (*cb) ( void ) = NULL ); - int ReportDialog( DLGREPORT *report, LangID langid, void (*print) ( const char *)= NULL, PMASK pmask= PMASK_ALL ); - int ReportTranslations( TRNREPORT *report, LangID langid, void (*print) ( const char *) = NULL, PMASK pmask = PMASK_ALL ); - void ReportDuplicates ( CBabylonDlg *dlg = NULL ); + void VerifyDialog( LangID langid, void (*cb) ( void ) = nullptr ); + int ReportDialog( DLGREPORT *report, LangID langid, void (*print) ( const char *)= nullptr, PMASK pmask= PMASK_ALL ); + int ReportTranslations( TRNREPORT *report, LangID langid, void (*print) ( const char *) = nullptr, PMASK pmask = PMASK_ALL ); + void ReportDuplicates ( CBabylonDlg *dlg = nullptr ); void AddLabel ( BabylonLabel *label ); void AddText ( BabylonText *text ); void AddObsolete ( BabylonText *text ); void RemoveLabel ( BabylonLabel *label ); void RemoveText ( BabylonText *text ); void RemoveObsolete ( BabylonText *text ); - int Errors ( CBabylonDlg *dlg = NULL ); + int Errors ( CBabylonDlg *dlg = nullptr ); int HasErrors ( void ) { return checked_for_errors ? last_error_count != 0 : FALSE; }; - int Warnings ( CBabylonDlg *dlg = NULL ); + int Warnings ( CBabylonDlg *dlg = nullptr ); int NumLabelsChanged ( void ); int NumLabels ( void ); int NumObsolete ( void ) { return num_obsolete; }; @@ -392,7 +392,7 @@ class TransDB : public DBAttribs void ClearProcessed ( void ); void ClearMatched ( void ); TransDB* Next ( void ); - void AddToTree ( CTreeCtrl *tc, HTREEITEM parent, int changes = FALSE, void (*cb) ( void ) = NULL ); + void AddToTree ( CTreeCtrl *tc, HTREEITEM parent, int changes = FALSE, void (*cb) ( void ) = nullptr ); char* Name ( void ) { return name;}; void EnableIDs ( void ) { next_string_id = START_STRING_ID; }; int NewID ( void ) { if ( next_string_id != -1) return next_string_id++; else return -1; }; diff --git a/Core/Tools/Babylon/VIEWDBSII.cpp b/Core/Tools/Babylon/VIEWDBSII.cpp index 98c051408de..bebb55de96a 100644 --- a/Core/Tools/Babylon/VIEWDBSII.cpp +++ b/Core/Tools/Babylon/VIEWDBSII.cpp @@ -33,7 +33,7 @@ static char THIS_FILE[] = __FILE__; // VIEWDBSII dialog -VIEWDBSII::VIEWDBSII(CWnd* pParent /*=NULL*/) +VIEWDBSII::VIEWDBSII(CWnd* pParent /*=nullptr*/) : CDialog(VIEWDBSII::IDD, pParent) { //{{AFX_DATA_INIT(VIEWDBSII) diff --git a/Core/Tools/Babylon/VIEWDBSII.h b/Core/Tools/Babylon/VIEWDBSII.h index a9ea386653b..0a1b31adc79 100644 --- a/Core/Tools/Babylon/VIEWDBSII.h +++ b/Core/Tools/Babylon/VIEWDBSII.h @@ -28,7 +28,7 @@ class VIEWDBSII : public CDialog { // Construction public: - VIEWDBSII(CWnd* pParent = NULL); // standard constructor + VIEWDBSII(CWnd* pParent = nullptr); // standard constructor void OnClose(); BOOL OnInitDialog(); diff --git a/Core/Tools/Babylon/VerifyDlg.cpp b/Core/Tools/Babylon/VerifyDlg.cpp index b339d9ce5dd..03ee23c5cb1 100644 --- a/Core/Tools/Babylon/VerifyDlg.cpp +++ b/Core/Tools/Babylon/VerifyDlg.cpp @@ -35,7 +35,7 @@ static char THIS_FILE[] = __FILE__; // VerifyDlg dialog -VerifyDlg::VerifyDlg( BabylonText *ntext, LangID langid, const char *path, CWnd* pParent /*=NULL*/) +VerifyDlg::VerifyDlg( BabylonText *ntext, LangID langid, const char *path, CWnd* pParent /*=nullptr*/) : CDialog(VerifyDlg::IDD, pParent) { //{{AFX_DATA_INIT(VerifyDlg) @@ -121,8 +121,8 @@ BOOL VerifyDlg::OnInitDialog() stream = AIL_open_stream ( dig, wavefile, 0 ); if ( stream ) { - timer = SetTimer( TIMERID, 300, NULL ); - AIL_stream_ms_position ( stream, &total, NULL ); + timer = SetTimer( TIMERID, 300, nullptr ); + AIL_stream_ms_position ( stream, &total, nullptr ); slider->SetRange ( 0, total ); } #endif @@ -211,7 +211,7 @@ void VerifyDlg::CloseAudio ( void ) if ( stream ) { AIL_close_stream ( stream ); - stream = NULL; + stream = nullptr; } #endif } @@ -225,7 +225,7 @@ void VerifyDlg::OnTimer(UINT nIDEvent) if ( stream ) { long current; - AIL_stream_ms_position ( stream, NULL, ¤t ); + AIL_stream_ms_position ( stream, nullptr, ¤t ); slider->SetPos ( current ); } #endif diff --git a/Core/Tools/Babylon/VerifyDlg.h b/Core/Tools/Babylon/VerifyDlg.h index 04964b6f3f4..0adb56bed2d 100644 --- a/Core/Tools/Babylon/VerifyDlg.h +++ b/Core/Tools/Babylon/VerifyDlg.h @@ -41,7 +41,7 @@ class VerifyDlg : public CDialog CSliderCtrl *slider; // Construction public: - VerifyDlg(BabylonText *ntext, LangID langid, const char *path, CWnd* pParent = NULL); // standard constructor + VerifyDlg(BabylonText *ntext, LangID langid, const char *path, CWnd* pParent = nullptr); // standard constructor void CloseAudio ( void ); // Dialog Data diff --git a/Core/Tools/Babylon/VerifyTextDlg.cpp b/Core/Tools/Babylon/VerifyTextDlg.cpp index 9725ad58ff1..3df24bf744c 100644 --- a/Core/Tools/Babylon/VerifyTextDlg.cpp +++ b/Core/Tools/Babylon/VerifyTextDlg.cpp @@ -33,7 +33,7 @@ static char THIS_FILE[] = __FILE__; // CVerifyTextDlg dialog -CVerifyTextDlg::CVerifyTextDlg( char *trans, char *orig, CWnd* pParent /*=NULL*/) +CVerifyTextDlg::CVerifyTextDlg( char *trans, char *orig, CWnd* pParent /*=nullptr*/) : CDialog(CVerifyTextDlg::IDD, pParent) { //{{AFX_DATA_INIT(CVerifyTextDlg) diff --git a/Core/Tools/Babylon/VerifyTextDlg.h b/Core/Tools/Babylon/VerifyTextDlg.h index fca1dda0fd1..27b28446d04 100644 --- a/Core/Tools/Babylon/VerifyTextDlg.h +++ b/Core/Tools/Babylon/VerifyTextDlg.h @@ -30,7 +30,7 @@ class CVerifyTextDlg : public CDialog char *m_trans; char *m_orig; public: - CVerifyTextDlg(char *trans, char *orig, CWnd* pParent = NULL); // standard constructor + CVerifyTextDlg(char *trans, char *orig, CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CVerifyTextDlg) diff --git a/Core/Tools/Babylon/ViewDBsDlg.cpp b/Core/Tools/Babylon/ViewDBsDlg.cpp index 2fd32722ccc..fdc7d614f16 100644 --- a/Core/Tools/Babylon/ViewDBsDlg.cpp +++ b/Core/Tools/Babylon/ViewDBsDlg.cpp @@ -37,7 +37,7 @@ int ViewChanges = FALSE; // CViewDBsDlg dialog -VIEWDBSII::VIEWDBSII(CWnd* pParent /*=NULL*/) +VIEWDBSII::VIEWDBSII(CWnd* pParent /*=nullptr*/) : CDialog(VIEWDBSII::IDD, pParent) { //{{AFX_DATA_INIT(CViewDBsDlg) diff --git a/Core/Tools/Babylon/XLStuff.cpp b/Core/Tools/Babylon/XLStuff.cpp index 59be38979c7..e914708cd91 100644 --- a/Core/Tools/Babylon/XLStuff.cpp +++ b/Core/Tools/Babylon/XLStuff.cpp @@ -32,11 +32,11 @@ static const int xlWorkbookNormal = -4143; static const int xlNoChange = 1; static const int xlLocalSessionChanges = 2; static const int xlWBATWorksheet = -4167; -static _Workbook *workbook = NULL; -static _Application *xl = NULL; -static Workbooks *wbs = NULL; -static Range *range = NULL; -static _Worksheet *ws = NULL; +static _Workbook *workbook = nullptr; +static _Application *xl = nullptr; +static Workbooks *wbs = nullptr; +static Range *range = nullptr; +static _Worksheet *ws = nullptr; static OLECHAR buffer[100*1024]; static VARIANT no, yes, dummy, dummy0, nullstring, empty; @@ -165,8 +165,8 @@ int PutSeparator ( int row ) // .ColorIndex = xlAutomatic // End With int ok = FALSE; - Border *border = NULL; - Borders *borders = NULL; + Border *border = nullptr; + Borders *borders = nullptr; LPDISPATCH dispatch; OLECHAR cellname1[20]; OLECHAR cellname2[20]; @@ -237,15 +237,15 @@ int PutSection ( int row, OLECHAR *title ) { int ok = FALSE; - Range *range = NULL; - Border *border = NULL; - Borders *borders = NULL; - Interior *interior = NULL; + Range *range = nullptr; + Border *border = nullptr; + Borders *borders = nullptr; + Interior *interior = nullptr; LPDISPATCH dispatch; OLECHAR cellname1[20]; OLECHAR cellname2[20]; VARIANT cell1,cell2; - _Worksheet *ws = NULL; + _Worksheet *ws = nullptr; if ( !ws ) { @@ -293,7 +293,7 @@ int PutSection ( int row, OLECHAR *title ) border->SetWeight ( thin ); delete border; - border = NULL; + border = nullptr; dispatch = borders->GetItem ( xlEdgeTop ); @@ -309,7 +309,7 @@ int PutSection ( int row, OLECHAR *title ) border->SetWeight ( medium ); delete border; - border = NULL; + border = nullptr; dispatch = borders->GetItem ( xlEdgeRight ); @@ -323,7 +323,7 @@ int PutSection ( int row, OLECHAR *title ) border->SetLineStyle ( none ); delete border; - border = NULL; + border = nullptr; dispatch = borders->GetItem ( xlEdgeLeft ); @@ -462,16 +462,16 @@ void CloseExcel ( void ) CloseWorkBook (); delete range; - range = NULL; + range = nullptr; delete ws; - ws = NULL; + ws = nullptr; if ( wbs ) { wbs->Close(); delete wbs; - wbs = NULL; + wbs = nullptr; } if ( xl ) @@ -479,7 +479,7 @@ void CloseExcel ( void ) xl->Quit(); xl->ReleaseDispatch (); delete xl; - xl = NULL; + xl = nullptr; } VariantClear ( &nullstring ); @@ -599,7 +599,7 @@ void CloseWorkBook ( void ) workbook->SetSaved ( TRUE ); workbook->Close ( no, nullstring, no ); delete workbook; - workbook = NULL; + workbook = nullptr; } } diff --git a/Core/Tools/Babylon/bin.cpp b/Core/Tools/Babylon/bin.cpp index 0116060b165..03af9d6910f 100644 --- a/Core/Tools/Babylon/bin.cpp +++ b/Core/Tools/Babylon/bin.cpp @@ -29,7 +29,7 @@ Bin::Bin ( int size ) { assert ( size > 0 ); num_buckets = size; - sh_item = NULL; + sh_item = nullptr; bucket = new List[size]; @@ -48,7 +48,7 @@ Bin::~Bin ( ) void Bin::Clear ( void ) { int count = num_buckets; - sh_item = NULL; + sh_item = nullptr; while ( count-- ) { List *head = &bucket[count]; @@ -71,7 +71,7 @@ void* Bin::Get ( OLECHAR *text1, OLECHAR *text2 ) return item->Item(); } - return NULL; + return nullptr; } void* Bin::GetNext ( void ) @@ -83,7 +83,7 @@ void* Bin::GetNext ( void ) return item->Item(); } - return NULL; + return nullptr; } void Bin::Add ( void *data, OLECHAR *text1, OLECHAR *text2 ) @@ -92,7 +92,7 @@ void Bin::Add ( void *data, OLECHAR *text1, OLECHAR *text2 ) List *list; int hash; - sh_item = NULL; + sh_item = nullptr; hash = calc_hash ( text1 ); item = new BinItem ( data, hash, text1, text2 ); @@ -149,7 +149,7 @@ BinItem* Bin::GetNextBinItem ( void ) BinItem* Bin::GetBinItem ( void *item ) { - BinItem *bitem = NULL; + BinItem *bitem = nullptr; int i; @@ -191,7 +191,7 @@ void Bin::Remove ( OLECHAR *text1, OLECHAR *text2 ) void Bin::Remove ( BinItem *item ) { - sh_item = NULL; + sh_item = nullptr; item->Remove (); delete item ; @@ -303,7 +303,7 @@ void* BinID::Get ( int id) return item->Item(); } - return NULL; + return nullptr; } void BinID::Add ( void *data, int id ) @@ -342,7 +342,7 @@ BinIDItem* BinID::GetBinIDItem ( int id ) BinIDItem* BinID::GetBinIDItem ( void *item ) { - BinIDItem *bitem = NULL; + BinIDItem *bitem = nullptr; int i; diff --git a/Core/Tools/Babylon/bin.h b/Core/Tools/Babylon/bin.h index f928b150337..728ae00ad6b 100644 --- a/Core/Tools/Babylon/bin.h +++ b/Core/Tools/Babylon/bin.h @@ -56,14 +56,14 @@ class Bin ~Bin (); void Clear ( void ); - void* Get ( OLECHAR *text1, OLECHAR *text2 = NULL ); + void* Get ( OLECHAR *text1, OLECHAR *text2 = nullptr ); void* GetNext ( void ); - void Add ( void *item, OLECHAR *text1, OLECHAR *text2 = NULL ); - BinItem* GetBinItem ( OLECHAR *text1, OLECHAR *text2 = NULL ); + void Add ( void *item, OLECHAR *text1, OLECHAR *text2 = nullptr ); + BinItem* GetBinItem ( OLECHAR *text1, OLECHAR *text2 = nullptr ); BinItem* GetBinItem ( void *item ); BinItem* GetNextBinItem ( void ); void Remove ( void *item ); - void Remove ( OLECHAR *text1, OLECHAR *text2 = NULL ); + void Remove ( OLECHAR *text1, OLECHAR *text2 = nullptr ); void Remove ( BinItem *item ); diff --git a/Core/Tools/Babylon/excel8.cpp b/Core/Tools/Babylon/excel8.cpp index 18bb32cb760..b3044ffde5c 100644 --- a/Core/Tools/Babylon/excel8.cpp +++ b/Core/Tools/Babylon/excel8.cpp @@ -37,21 +37,21 @@ static char THIS_FILE[] = __FILE__; LPDISPATCH Workbooks::GetApplication() { LPDISPATCH result; - InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long Workbooks::GetCreator() { long result; - InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } LPDISPATCH Workbooks::GetParent() { LPDISPATCH result; - InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -67,13 +67,13 @@ LPDISPATCH Workbooks::Add(const VARIANT& Template) void Workbooks::Close() { - InvokeHelper(0x115, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x115, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } long Workbooks::GetCount() { long result; - InvokeHelper(0x76, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x76, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -90,7 +90,7 @@ LPDISPATCH Workbooks::GetItem(const VARIANT& Index) LPUNKNOWN Workbooks::Get_NewEnum() { LPUNKNOWN result; - InvokeHelper(0xfffffffc, DISPATCH_PROPERTYGET, VT_UNKNOWN, (void*)&result, NULL); + InvokeHelper(0xfffffffc, DISPATCH_PROPERTYGET, VT_UNKNOWN, (void*)&result, nullptr); return result; } @@ -110,7 +110,7 @@ void Workbooks::OpenText(LPCTSTR Filename, const VARIANT& Origin, const VARIANT& { static BYTE parms[] = VTS_BSTR VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_I4 VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x2ab, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x2ab, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Filename, &Origin, &StartRow, &DataType, TextQualifier, &ConsecutiveDelimiter, &Tab, &Semicolon, &Comma, &Space, &Other, &OtherChar, &FieldInfo, &TextVisualLayout); } @@ -134,42 +134,42 @@ LPDISPATCH Workbooks::Get_Default(const VARIANT& Index) LPDISPATCH _Application::GetApplication() { LPDISPATCH result; - InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long _Application::GetCreator() { long result; - InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetParent() { LPDISPATCH result; - InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetActiveCell() { LPDISPATCH result; - InvokeHelper(0x131, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x131, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetActiveChart() { LPDISPATCH result; - InvokeHelper(0xb7, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0xb7, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } CString _Application::GetActivePrinter() { CString result; - InvokeHelper(0x132, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x132, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -177,82 +177,82 @@ void _Application::SetActivePrinter(LPCTSTR lpszNewValue) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x132, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x132, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, lpszNewValue); } LPDISPATCH _Application::GetActiveSheet() { LPDISPATCH result; - InvokeHelper(0x133, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x133, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetActiveWindow() { LPDISPATCH result; - InvokeHelper(0x2f7, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x2f7, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetActiveWorkbook() { LPDISPATCH result; - InvokeHelper(0x134, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x134, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetAddIns() { LPDISPATCH result; - InvokeHelper(0x225, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x225, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetAssistant() { LPDISPATCH result; - InvokeHelper(0x59e, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x59e, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } void _Application::Calculate() { - InvokeHelper(0x117, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x117, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } LPDISPATCH _Application::GetCells() { LPDISPATCH result; - InvokeHelper(0xee, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0xee, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetCharts() { LPDISPATCH result; - InvokeHelper(0x79, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x79, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetColumns() { LPDISPATCH result; - InvokeHelper(0xf1, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0xf1, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetCommandBars() { LPDISPATCH result; - InvokeHelper(0x59f, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x59f, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long _Application::GetDDEAppReturnCode() { long result; - InvokeHelper(0x14c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x14c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -260,7 +260,7 @@ void _Application::DDEExecute(long Channel, LPCTSTR String) { static BYTE parms[] = VTS_I4 VTS_BSTR; - InvokeHelper(0x14d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x14d, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Channel, String); } @@ -278,7 +278,7 @@ void _Application::DDEPoke(long Channel, const VARIANT& Item, const VARIANT& Dat { static BYTE parms[] = VTS_I4 VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x14f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x14f, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Channel, &Item, &Data); } @@ -296,7 +296,7 @@ void _Application::DDETerminate(long Channel) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x151, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x151, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Channel); } @@ -346,7 +346,7 @@ LPDISPATCH _Application::Intersect(LPDISPATCH Arg1, LPDISPATCH Arg2, const VARIA LPDISPATCH _Application::GetNames() { LPDISPATCH result; - InvokeHelper(0x1ba, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1ba, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -363,7 +363,7 @@ LPDISPATCH _Application::GetRange(const VARIANT& Cell1, const VARIANT& Cell2) LPDISPATCH _Application::GetRows() { LPDISPATCH result; - InvokeHelper(0x102, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x102, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -398,7 +398,7 @@ VARIANT _Application::_Run2(const VARIANT& Macro, const VARIANT& Arg1, const VAR LPDISPATCH _Application::GetSelection() { LPDISPATCH result; - InvokeHelper(0x93, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x93, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -406,21 +406,21 @@ void _Application::SendKeys(const VARIANT& Keys, const VARIANT& Wait) { static BYTE parms[] = VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x17f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x17f, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Keys, &Wait); } LPDISPATCH _Application::GetSheets() { LPDISPATCH result; - InvokeHelper(0x1e5, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1e5, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetThisWorkbook() { LPDISPATCH result; - InvokeHelper(0x30a, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x30a, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -440,42 +440,42 @@ LPDISPATCH _Application::Union(LPDISPATCH Arg1, LPDISPATCH Arg2, const VARIANT& LPDISPATCH _Application::GetWindows() { LPDISPATCH result; - InvokeHelper(0x1ae, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1ae, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetWorkbooks() { LPDISPATCH result; - InvokeHelper(0x23c, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x23c, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetWorksheetFunction() { LPDISPATCH result; - InvokeHelper(0x5a0, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x5a0, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetWorksheets() { LPDISPATCH result; - InvokeHelper(0x1ee, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1ee, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetExcel4IntlMacroSheets() { LPDISPATCH result; - InvokeHelper(0x245, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x245, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetExcel4MacroSheets() { LPDISPATCH result; - InvokeHelper(0x243, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x243, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -483,7 +483,7 @@ void _Application::ActivateMicrosoftApp(long Index) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x447, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x447, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Index); } @@ -491,7 +491,7 @@ void _Application::AddChartAutoFormat(const VARIANT& Chart, LPCTSTR Name, const { static BYTE parms[] = VTS_VARIANT VTS_BSTR VTS_VARIANT; - InvokeHelper(0xd8, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0xd8, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Chart, Name, &Description); } @@ -499,14 +499,14 @@ void _Application::AddCustomList(const VARIANT& ListArray, const VARIANT& ByRow) { static BYTE parms[] = VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x30c, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x30c, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &ListArray, &ByRow); } BOOL _Application::GetAlertBeforeOverwriting() { BOOL result; - InvokeHelper(0x3a2, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x3a2, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -514,14 +514,14 @@ void _Application::SetAlertBeforeOverwriting(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x3a2, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x3a2, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } CString _Application::GetAltStartupPath() { CString result; - InvokeHelper(0x139, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x139, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -529,14 +529,14 @@ void _Application::SetAltStartupPath(LPCTSTR lpszNewValue) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x139, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x139, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, lpszNewValue); } BOOL _Application::GetAskToUpdateLinks() { BOOL result; - InvokeHelper(0x3e0, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x3e0, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -544,14 +544,14 @@ void _Application::SetAskToUpdateLinks(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x3e0, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x3e0, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Application::GetEnableAnimations() { BOOL result; - InvokeHelper(0x49c, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x49c, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -559,28 +559,28 @@ void _Application::SetEnableAnimations(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x49c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x49c, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } LPDISPATCH _Application::GetAutoCorrect() { LPDISPATCH result; - InvokeHelper(0x479, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x479, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long _Application::GetBuild() { long result; - InvokeHelper(0x13a, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x13a, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } BOOL _Application::GetCalculateBeforeSave() { BOOL result; - InvokeHelper(0x13b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x13b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -588,14 +588,14 @@ void _Application::SetCalculateBeforeSave(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x13b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x13b, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } long _Application::GetCalculation() { long result; - InvokeHelper(0x13c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x13c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -603,7 +603,7 @@ void _Application::SetCalculation(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x13c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x13c, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } @@ -620,21 +620,21 @@ VARIANT _Application::GetCaller(const VARIANT& Index) BOOL _Application::GetCanPlaySounds() { BOOL result; - InvokeHelper(0x13e, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x13e, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } BOOL _Application::GetCanRecordSounds() { BOOL result; - InvokeHelper(0x13f, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x13f, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } CString _Application::GetCaption() { CString result; - InvokeHelper(0x8b, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x8b, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -642,14 +642,14 @@ void _Application::SetCaption(LPCTSTR lpszNewValue) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x8b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x8b, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, lpszNewValue); } BOOL _Application::GetCellDragAndDrop() { BOOL result; - InvokeHelper(0x140, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x140, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -657,7 +657,7 @@ void _Application::SetCellDragAndDrop(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x140, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x140, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -694,7 +694,7 @@ VARIANT _Application::GetClipboardFormats(const VARIANT& Index) BOOL _Application::GetDisplayClipboardWindow() { BOOL result; - InvokeHelper(0x142, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x142, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -702,14 +702,14 @@ void _Application::SetDisplayClipboardWindow(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x142, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x142, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } long _Application::GetCommandUnderlines() { long result; - InvokeHelper(0x143, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x143, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -717,14 +717,14 @@ void _Application::SetCommandUnderlines(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x143, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x143, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } BOOL _Application::GetConstrainNumeric() { BOOL result; - InvokeHelper(0x144, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x144, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -732,7 +732,7 @@ void _Application::SetConstrainNumeric(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x144, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x144, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -749,7 +749,7 @@ VARIANT _Application::ConvertFormula(const VARIANT& Formula, long FromReferenceS BOOL _Application::GetCopyObjectsWithCells() { BOOL result; - InvokeHelper(0x3df, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x3df, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -757,14 +757,14 @@ void _Application::SetCopyObjectsWithCells(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x3df, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x3df, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } long _Application::GetCursor() { long result; - InvokeHelper(0x489, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x489, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -772,21 +772,21 @@ void _Application::SetCursor(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x489, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x489, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } long _Application::GetCustomListCount() { long result; - InvokeHelper(0x313, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x313, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } long _Application::GetCutCopyMode() { long result; - InvokeHelper(0x14a, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x14a, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -794,14 +794,14 @@ void _Application::SetCutCopyMode(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x14a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x14a, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } long _Application::GetDataEntryMode() { long result; - InvokeHelper(0x14b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x14b, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -809,21 +809,21 @@ void _Application::SetDataEntryMode(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x14b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x14b, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } CString _Application::Get_Default() { CString result; - InvokeHelper(0x0, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x0, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } CString _Application::GetDefaultFilePath() { CString result; - InvokeHelper(0x40e, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x40e, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -831,7 +831,7 @@ void _Application::SetDefaultFilePath(LPCTSTR lpszNewValue) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x40e, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x40e, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, lpszNewValue); } @@ -839,7 +839,7 @@ void _Application::DeleteChartAutoFormat(LPCTSTR Name) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0xd9, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0xd9, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Name); } @@ -847,21 +847,21 @@ void _Application::DeleteCustomList(long ListNum) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x30f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x30f, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, ListNum); } LPDISPATCH _Application::GetDialogs() { LPDISPATCH result; - InvokeHelper(0x2f9, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x2f9, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } BOOL _Application::GetDisplayAlerts() { BOOL result; - InvokeHelper(0x157, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x157, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -869,14 +869,14 @@ void _Application::SetDisplayAlerts(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x157, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x157, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Application::GetDisplayFormulaBar() { BOOL result; - InvokeHelper(0x158, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x158, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -884,14 +884,14 @@ void _Application::SetDisplayFormulaBar(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x158, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x158, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Application::GetDisplayFullScreen() { BOOL result; - InvokeHelper(0x425, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x425, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -899,14 +899,14 @@ void _Application::SetDisplayFullScreen(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x425, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x425, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Application::GetDisplayNoteIndicator() { BOOL result; - InvokeHelper(0x159, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x159, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -914,14 +914,14 @@ void _Application::SetDisplayNoteIndicator(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x159, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x159, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } long _Application::GetDisplayCommentIndicator() { long result; - InvokeHelper(0x4ac, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x4ac, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -929,14 +929,14 @@ void _Application::SetDisplayCommentIndicator(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x4ac, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x4ac, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } BOOL _Application::GetDisplayExcel4Menus() { BOOL result; - InvokeHelper(0x39f, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x39f, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -944,14 +944,14 @@ void _Application::SetDisplayExcel4Menus(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x39f, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x39f, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Application::GetDisplayRecentFiles() { BOOL result; - InvokeHelper(0x39e, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x39e, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -959,14 +959,14 @@ void _Application::SetDisplayRecentFiles(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x39e, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x39e, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Application::GetDisplayScrollBars() { BOOL result; - InvokeHelper(0x15a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x15a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -974,14 +974,14 @@ void _Application::SetDisplayScrollBars(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x15a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x15a, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Application::GetDisplayStatusBar() { BOOL result; - InvokeHelper(0x15b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x15b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -989,19 +989,19 @@ void _Application::SetDisplayStatusBar(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x15b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x15b, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } void _Application::DoubleClick() { - InvokeHelper(0x15d, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x15d, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } BOOL _Application::GetEditDirectlyInCell() { BOOL result; - InvokeHelper(0x3a1, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x3a1, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1009,14 +1009,14 @@ void _Application::SetEditDirectlyInCell(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x3a1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x3a1, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Application::GetEnableAutoComplete() { BOOL result; - InvokeHelper(0x49b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x49b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1024,14 +1024,14 @@ void _Application::SetEnableAutoComplete(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x49b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x49b, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } long _Application::GetEnableCancelKey() { long result; - InvokeHelper(0x448, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x448, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -1039,14 +1039,14 @@ void _Application::SetEnableCancelKey(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x448, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x448, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } BOOL _Application::GetEnableSound() { BOOL result; - InvokeHelper(0x4ad, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x4ad, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1054,7 +1054,7 @@ void _Application::SetEnableSound(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x4ad, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x4ad, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -1071,26 +1071,26 @@ VARIANT _Application::GetFileConverters(const VARIANT& Index1, const VARIANT& In LPDISPATCH _Application::GetFileSearch() { LPDISPATCH result; - InvokeHelper(0x4b0, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x4b0, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetFileFind() { LPDISPATCH result; - InvokeHelper(0x4b1, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x4b1, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } void _Application::FindFile() { - InvokeHelper(0x42c, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x42c, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } BOOL _Application::GetFixedDecimal() { BOOL result; - InvokeHelper(0x15f, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x15f, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1098,14 +1098,14 @@ void _Application::SetFixedDecimal(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x15f, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x15f, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } long _Application::GetFixedDecimalPlaces() { long result; - InvokeHelper(0x160, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x160, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -1113,7 +1113,7 @@ void _Application::SetFixedDecimalPlaces(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x160, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x160, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } @@ -1161,14 +1161,14 @@ void _Application::Goto(const VARIANT& Reference, const VARIANT& Scroll) { static BYTE parms[] = VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x1db, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x1db, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Reference, &Scroll); } double _Application::GetHeight() { double result; - InvokeHelper(0x7b, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, NULL); + InvokeHelper(0x7b, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, nullptr); return result; } @@ -1176,7 +1176,7 @@ void _Application::SetHeight(double newValue) { static BYTE parms[] = VTS_R8; - InvokeHelper(0x7b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x7b, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, newValue); } @@ -1184,14 +1184,14 @@ void _Application::Help(const VARIANT& HelpFile, const VARIANT& HelpContextID) { static BYTE parms[] = VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x162, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x162, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &HelpFile, &HelpContextID); } BOOL _Application::GetIgnoreRemoteRequests() { BOOL result; - InvokeHelper(0x164, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x164, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1199,7 +1199,7 @@ void _Application::SetIgnoreRemoteRequests(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x164, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x164, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -1226,7 +1226,7 @@ VARIANT _Application::InputBox(LPCTSTR Prompt, const VARIANT& Title, const VARIA BOOL _Application::GetInteractive() { BOOL result; - InvokeHelper(0x169, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x169, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1234,7 +1234,7 @@ void _Application::SetInteractive(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x169, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x169, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -1251,7 +1251,7 @@ VARIANT _Application::GetInternational(const VARIANT& Index) BOOL _Application::GetIteration() { BOOL result; - InvokeHelper(0x16b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x16b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1259,14 +1259,14 @@ void _Application::SetIteration(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x16b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x16b, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } double _Application::GetLeft() { double result; - InvokeHelper(0x7f, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, NULL); + InvokeHelper(0x7f, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, nullptr); return result; } @@ -1274,14 +1274,14 @@ void _Application::SetLeft(double newValue) { static BYTE parms[] = VTS_R8; - InvokeHelper(0x7f, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x7f, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, newValue); } CString _Application::GetLibraryPath() { CString result; - InvokeHelper(0x16e, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x16e, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -1290,48 +1290,48 @@ void _Application::MacroOptions(const VARIANT& Macro, const VARIANT& Description { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x46f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x46f, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Macro, &Description, &HasMenu, &MenuText, &HasShortcutKey, &ShortcutKey, &Category, &StatusBar, &HelpContextID, &HelpFile); } void _Application::MailLogoff() { - InvokeHelper(0x3b1, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x3b1, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void _Application::MailLogon(const VARIANT& Name, const VARIANT& Password, const VARIANT& DownloadNewMail) { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x3af, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x3af, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Name, &Password, &DownloadNewMail); } VARIANT _Application::GetMailSession() { VARIANT result; - InvokeHelper(0x3ae, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x3ae, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } long _Application::GetMailSystem() { long result; - InvokeHelper(0x3cb, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x3cb, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } BOOL _Application::GetMathCoprocessorAvailable() { BOOL result; - InvokeHelper(0x16f, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x16f, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } double _Application::GetMaxChange() { double result; - InvokeHelper(0x170, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, NULL); + InvokeHelper(0x170, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, nullptr); return result; } @@ -1339,14 +1339,14 @@ void _Application::SetMaxChange(double newValue) { static BYTE parms[] = VTS_R8; - InvokeHelper(0x170, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x170, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, newValue); } long _Application::GetMaxIterations() { long result; - InvokeHelper(0x171, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x171, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -1354,42 +1354,42 @@ void _Application::SetMaxIterations(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x171, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x171, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } long _Application::GetMemoryFree() { long result; - InvokeHelper(0x172, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x172, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } long _Application::GetMemoryTotal() { long result; - InvokeHelper(0x173, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x173, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } long _Application::GetMemoryUsed() { long result; - InvokeHelper(0x174, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x174, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } BOOL _Application::GetMouseAvailable() { BOOL result; - InvokeHelper(0x175, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x175, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } BOOL _Application::GetMoveAfterReturn() { BOOL result; - InvokeHelper(0x176, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x176, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1397,14 +1397,14 @@ void _Application::SetMoveAfterReturn(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x176, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x176, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } long _Application::GetMoveAfterReturnDirection() { long result; - InvokeHelper(0x478, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x478, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -1412,49 +1412,49 @@ void _Application::SetMoveAfterReturnDirection(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x478, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x478, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } LPDISPATCH _Application::GetRecentFiles() { LPDISPATCH result; - InvokeHelper(0x4b2, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x4b2, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } CString _Application::GetName() { CString result; - InvokeHelper(0x6e, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x6e, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } LPDISPATCH _Application::NextLetter() { LPDISPATCH result; - InvokeHelper(0x3cc, DISPATCH_METHOD, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x3cc, DISPATCH_METHOD, VT_DISPATCH, (void*)&result, nullptr); return result; } CString _Application::GetNetworkTemplatesPath() { CString result; - InvokeHelper(0x184, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x184, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetODBCErrors() { LPDISPATCH result; - InvokeHelper(0x4b3, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x4b3, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long _Application::GetODBCTimeout() { long result; - InvokeHelper(0x4b4, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x4b4, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -1462,7 +1462,7 @@ void _Application::SetODBCTimeout(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x4b4, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x4b4, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } @@ -1470,7 +1470,7 @@ void _Application::OnKey(LPCTSTR Key, const VARIANT& Procedure) { static BYTE parms[] = VTS_BSTR VTS_VARIANT; - InvokeHelper(0x272, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x272, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Key, &Procedure); } @@ -1478,7 +1478,7 @@ void _Application::OnRepeat(LPCTSTR Text, LPCTSTR Procedure) { static BYTE parms[] = VTS_BSTR VTS_BSTR; - InvokeHelper(0x301, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x301, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Text, Procedure); } @@ -1486,7 +1486,7 @@ void _Application::OnTime(const VARIANT& EarliestTime, LPCTSTR Procedure, const { static BYTE parms[] = VTS_VARIANT VTS_BSTR VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x270, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x270, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &EarliestTime, Procedure, &LatestTime, &Schedule); } @@ -1494,14 +1494,14 @@ void _Application::OnUndo(LPCTSTR Text, LPCTSTR Procedure) { static BYTE parms[] = VTS_BSTR VTS_BSTR; - InvokeHelper(0x302, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x302, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Text, Procedure); } CString _Application::GetOnWindow() { CString result; - InvokeHelper(0x26f, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x26f, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -1509,35 +1509,35 @@ void _Application::SetOnWindow(LPCTSTR lpszNewValue) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x26f, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x26f, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, lpszNewValue); } CString _Application::GetOperatingSystem() { CString result; - InvokeHelper(0x177, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x177, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } CString _Application::GetOrganizationName() { CString result; - InvokeHelper(0x178, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x178, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } CString _Application::GetPath() { CString result; - InvokeHelper(0x123, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x123, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } CString _Application::GetPathSeparator() { CString result; - InvokeHelper(0x179, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x179, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -1554,7 +1554,7 @@ VARIANT _Application::GetPreviousSelections(const VARIANT& Index) BOOL _Application::GetPivotTableSelection() { BOOL result; - InvokeHelper(0x4b5, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x4b5, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1562,14 +1562,14 @@ void _Application::SetPivotTableSelection(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x4b5, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x4b5, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Application::GetPromptForSummaryInfo() { BOOL result; - InvokeHelper(0x426, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x426, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1577,34 +1577,34 @@ void _Application::SetPromptForSummaryInfo(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x426, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x426, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } void _Application::Quit() { - InvokeHelper(0x12e, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x12e, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void _Application::RecordMacro(const VARIANT& BasicCode, const VARIANT& XlmCode) { static BYTE parms[] = VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x305, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x305, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &BasicCode, &XlmCode); } BOOL _Application::GetRecordRelative() { BOOL result; - InvokeHelper(0x17b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x17b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } long _Application::GetReferenceStyle() { long result; - InvokeHelper(0x17c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x17c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -1612,7 +1612,7 @@ void _Application::SetReferenceStyle(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x17c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x17c, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } @@ -1638,13 +1638,13 @@ BOOL _Application::RegisterXLL(LPCTSTR Filename) void _Application::Repeat() { - InvokeHelper(0x12d, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x12d, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } BOOL _Application::GetRollZoom() { BOOL result; - InvokeHelper(0x4b6, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x4b6, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1652,7 +1652,7 @@ void _Application::SetRollZoom(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x4b6, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x4b6, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -1660,14 +1660,14 @@ void _Application::SaveWorkspace(const VARIANT& Filename) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0xd4, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0xd4, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Filename); } BOOL _Application::GetScreenUpdating() { BOOL result; - InvokeHelper(0x17e, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x17e, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1675,7 +1675,7 @@ void _Application::SetScreenUpdating(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x17e, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x17e, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -1683,14 +1683,14 @@ void _Application::SetDefaultChart(const VARIANT& FormatName, const VARIANT& Gal { static BYTE parms[] = VTS_VARIANT VTS_VARIANT; - InvokeHelper(0xdb, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0xdb, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &FormatName, &Gallery); } long _Application::GetSheetsInNewWorkbook() { long result; - InvokeHelper(0x3e1, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x3e1, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -1698,14 +1698,14 @@ void _Application::SetSheetsInNewWorkbook(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x3e1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x3e1, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } BOOL _Application::GetShowChartTipNames() { BOOL result; - InvokeHelper(0x4b7, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x4b7, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1713,14 +1713,14 @@ void _Application::SetShowChartTipNames(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x4b7, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x4b7, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Application::GetShowChartTipValues() { BOOL result; - InvokeHelper(0x4b8, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x4b8, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1728,14 +1728,14 @@ void _Application::SetShowChartTipValues(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x4b8, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x4b8, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } CString _Application::GetStandardFont() { CString result; - InvokeHelper(0x39c, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x39c, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -1743,14 +1743,14 @@ void _Application::SetStandardFont(LPCTSTR lpszNewValue) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x39c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x39c, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, lpszNewValue); } double _Application::GetStandardFontSize() { double result; - InvokeHelper(0x39d, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, NULL); + InvokeHelper(0x39d, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, nullptr); return result; } @@ -1758,21 +1758,21 @@ void _Application::SetStandardFontSize(double newValue) { static BYTE parms[] = VTS_R8; - InvokeHelper(0x39d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x39d, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, newValue); } CString _Application::GetStartupPath() { CString result; - InvokeHelper(0x181, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x181, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } VARIANT _Application::GetStatusBar() { VARIANT result; - InvokeHelper(0x182, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x182, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -1780,21 +1780,21 @@ void _Application::SetStatusBar(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x182, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x182, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } CString _Application::GetTemplatesPath() { CString result; - InvokeHelper(0x17d, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x17d, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } BOOL _Application::GetShowToolTips() { BOOL result; - InvokeHelper(0x183, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x183, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1802,14 +1802,14 @@ void _Application::SetShowToolTips(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x183, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x183, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } double _Application::GetTop() { double result; - InvokeHelper(0x7e, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, NULL); + InvokeHelper(0x7e, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, nullptr); return result; } @@ -1817,14 +1817,14 @@ void _Application::SetTop(double newValue) { static BYTE parms[] = VTS_R8; - InvokeHelper(0x7e, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x7e, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, newValue); } long _Application::GetDefaultSaveFormat() { long result; - InvokeHelper(0x4b9, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x4b9, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -1832,14 +1832,14 @@ void _Application::SetDefaultSaveFormat(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x4b9, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x4b9, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } CString _Application::GetTransitionMenuKey() { CString result; - InvokeHelper(0x136, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x136, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -1847,14 +1847,14 @@ void _Application::SetTransitionMenuKey(LPCTSTR lpszNewValue) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x136, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x136, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, lpszNewValue); } long _Application::GetTransitionMenuKeyAction() { long result; - InvokeHelper(0x137, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x137, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -1862,14 +1862,14 @@ void _Application::SetTransitionMenuKeyAction(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x137, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x137, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } BOOL _Application::GetTransitionNavigKeys() { BOOL result; - InvokeHelper(0x138, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x138, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1877,33 +1877,33 @@ void _Application::SetTransitionNavigKeys(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x138, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x138, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } void _Application::Undo() { - InvokeHelper(0x12f, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x12f, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } double _Application::GetUsableHeight() { double result; - InvokeHelper(0x185, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, NULL); + InvokeHelper(0x185, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, nullptr); return result; } double _Application::GetUsableWidth() { double result; - InvokeHelper(0x186, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, NULL); + InvokeHelper(0x186, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, nullptr); return result; } BOOL _Application::GetUserControl() { BOOL result; - InvokeHelper(0x4ba, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x4ba, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1911,14 +1911,14 @@ void _Application::SetUserControl(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x4ba, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x4ba, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } CString _Application::GetUserName_() { CString result; - InvokeHelper(0x187, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x187, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -1926,35 +1926,35 @@ void _Application::SetUserName(LPCTSTR lpszNewValue) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x187, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x187, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, lpszNewValue); } CString _Application::GetValue() { CString result; - InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } LPDISPATCH _Application::GetVbe() { LPDISPATCH result; - InvokeHelper(0x4bb, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x4bb, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } CString _Application::GetVersion() { CString result; - InvokeHelper(0x188, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x188, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } BOOL _Application::GetVisible() { BOOL result; - InvokeHelper(0x22e, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x22e, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -1962,7 +1962,7 @@ void _Application::SetVisible(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x22e, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x22e, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -1970,7 +1970,7 @@ void _Application::Volatile(const VARIANT& Volatile) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x314, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x314, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Volatile); } @@ -1978,14 +1978,14 @@ void _Application::Wait(const VARIANT& Time) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x189, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x189, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Time); } double _Application::GetWidth() { double result; - InvokeHelper(0x7a, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, NULL); + InvokeHelper(0x7a, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, nullptr); return result; } @@ -1993,21 +1993,21 @@ void _Application::SetWidth(double newValue) { static BYTE parms[] = VTS_R8; - InvokeHelper(0x7a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x7a, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, newValue); } BOOL _Application::GetWindowsForPens() { BOOL result; - InvokeHelper(0x18b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x18b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } long _Application::GetWindowState() { long result; - InvokeHelper(0x18c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x18c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -2015,14 +2015,14 @@ void _Application::SetWindowState(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x18c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x18c, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } long _Application::GetUILanguage() { long result; - InvokeHelper(0x2, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x2, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -2030,14 +2030,14 @@ void _Application::SetUILanguage(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x2, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x2, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } long _Application::GetDefaultSheetDirection() { long result; - InvokeHelper(0xe5, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0xe5, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -2045,14 +2045,14 @@ void _Application::SetDefaultSheetDirection(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0xe5, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0xe5, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } long _Application::GetCursorMovement() { long result; - InvokeHelper(0xe8, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0xe8, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -2060,14 +2060,14 @@ void _Application::SetCursorMovement(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0xe8, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0xe8, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } long _Application::GetControlCharacters() { long result; - InvokeHelper(0xe9, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0xe9, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -2075,14 +2075,14 @@ void _Application::SetControlCharacters(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0xe9, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0xe9, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } BOOL _Application::GetEnableEvents() { BOOL result; - InvokeHelper(0x4bc, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x4bc, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2090,7 +2090,7 @@ void _Application::SetEnableEvents(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x4bc, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x4bc, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -2104,28 +2104,28 @@ void _Application::SetEnableEvents(BOOL bNewValue) LPDISPATCH _Workbook::GetApplication() { LPDISPATCH result; - InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long _Workbook::GetCreator() { long result; - InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } LPDISPATCH _Workbook::GetParent() { LPDISPATCH result; - InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } BOOL _Workbook::GetAcceptLabelsInFormulas() { BOOL result; - InvokeHelper(0x5a1, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x5a1, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2133,33 +2133,33 @@ void _Workbook::SetAcceptLabelsInFormulas(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x5a1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x5a1, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } void _Workbook::Activate() { - InvokeHelper(0x130, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x130, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } LPDISPATCH _Workbook::GetActiveChart() { LPDISPATCH result; - InvokeHelper(0xb7, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0xb7, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Workbook::GetActiveSheet() { LPDISPATCH result; - InvokeHelper(0x133, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x133, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long _Workbook::GetAutoUpdateFrequency() { long result; - InvokeHelper(0x5a2, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x5a2, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -2167,14 +2167,14 @@ void _Workbook::SetAutoUpdateFrequency(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x5a2, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x5a2, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } BOOL _Workbook::GetAutoUpdateSaveChanges() { BOOL result; - InvokeHelper(0x5a3, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x5a3, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2182,14 +2182,14 @@ void _Workbook::SetAutoUpdateSaveChanges(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x5a3, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x5a3, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } long _Workbook::GetChangeHistoryDuration() { long result; - InvokeHelper(0x5a4, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x5a4, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -2197,14 +2197,14 @@ void _Workbook::SetChangeHistoryDuration(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x5a4, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x5a4, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } LPDISPATCH _Workbook::GetBuiltinDocumentProperties() { LPDISPATCH result; - InvokeHelper(0x498, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x498, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -2212,7 +2212,7 @@ void _Workbook::ChangeFileAccess(long Mode, const VARIANT& WritePassword, const { static BYTE parms[] = VTS_I4 VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x3dd, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x3dd, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Mode, &WritePassword, &Notify); } @@ -2220,14 +2220,14 @@ void _Workbook::ChangeLink(LPCTSTR Name, LPCTSTR NewName, long Type) { static BYTE parms[] = VTS_BSTR VTS_BSTR VTS_I4; - InvokeHelper(0x322, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x322, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Name, NewName, Type); } LPDISPATCH _Workbook::GetCharts() { LPDISPATCH result; - InvokeHelper(0x79, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x79, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -2235,21 +2235,21 @@ void _Workbook::Close(const VARIANT& SaveChanges, const VARIANT& Filename, const { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x115, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x115, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &SaveChanges, &Filename, &RouteWorkbook); } CString _Workbook::GetCodeName() { CString result; - InvokeHelper(0x55d, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x55d, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } CString _Workbook::Get_CodeName() { CString result; - InvokeHelper(0x80010000, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x80010000, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -2257,7 +2257,7 @@ void _Workbook::Set_CodeName(LPCTSTR lpszNewValue) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x80010000, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x80010000, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, lpszNewValue); } @@ -2275,21 +2275,21 @@ void _Workbook::SetColors(const VARIANT& Index, const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x11e, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x11e, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &Index, &newValue); } LPDISPATCH _Workbook::GetCommandBars() { LPDISPATCH result; - InvokeHelper(0x59f, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x59f, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long _Workbook::GetConflictResolution() { long result; - InvokeHelper(0x497, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x497, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -2297,35 +2297,35 @@ void _Workbook::SetConflictResolution(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x497, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x497, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } LPDISPATCH _Workbook::GetContainer() { LPDISPATCH result; - InvokeHelper(0x4a6, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x4a6, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } BOOL _Workbook::GetCreateBackup() { BOOL result; - InvokeHelper(0x11f, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x11f, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } LPDISPATCH _Workbook::GetCustomDocumentProperties() { LPDISPATCH result; - InvokeHelper(0x499, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x499, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } BOOL _Workbook::GetDate1904() { BOOL result; - InvokeHelper(0x193, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x193, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2333,7 +2333,7 @@ void _Workbook::SetDate1904(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x193, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x193, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -2341,14 +2341,14 @@ void _Workbook::DeleteNumberFormat(LPCTSTR NumberFormat) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x18d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x18d, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, NumberFormat); } long _Workbook::GetDisplayDrawingObjects() { long result; - InvokeHelper(0x194, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x194, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -2356,47 +2356,47 @@ void _Workbook::SetDisplayDrawingObjects(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x194, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x194, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } BOOL _Workbook::ExclusiveAccess() { BOOL result; - InvokeHelper(0x490, DISPATCH_METHOD, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x490, DISPATCH_METHOD, VT_BOOL, (void*)&result, nullptr); return result; } long _Workbook::GetFileFormat() { long result; - InvokeHelper(0x120, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x120, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } void _Workbook::ForwardMailer() { - InvokeHelper(0x3cd, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x3cd, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } CString _Workbook::GetFullName() { CString result; - InvokeHelper(0x121, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x121, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } BOOL _Workbook::GetHasPassword() { BOOL result; - InvokeHelper(0x122, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x122, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } BOOL _Workbook::GetHasRoutingSlip() { BOOL result; - InvokeHelper(0x3b6, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x3b6, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2404,14 +2404,14 @@ void _Workbook::SetHasRoutingSlip(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x3b6, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x3b6, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Workbook::GetIsAddin() { BOOL result; - InvokeHelper(0x5a5, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x5a5, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2419,7 +2419,7 @@ void _Workbook::SetIsAddin(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x5a5, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x5a5, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -2446,7 +2446,7 @@ VARIANT _Workbook::LinkSources(const VARIANT& Type) LPDISPATCH _Workbook::GetMailer() { LPDISPATCH result; - InvokeHelper(0x3d3, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x3d3, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -2454,35 +2454,35 @@ void _Workbook::MergeWorkbook(const VARIANT& Filename) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x5a6, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x5a6, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Filename); } BOOL _Workbook::GetMultiUserEditing() { BOOL result; - InvokeHelper(0x491, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x491, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } CString _Workbook::GetName() { CString result; - InvokeHelper(0x6e, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x6e, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } LPDISPATCH _Workbook::GetNames() { LPDISPATCH result; - InvokeHelper(0x1ba, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1ba, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Workbook::NewWindow() { LPDISPATCH result; - InvokeHelper(0x118, DISPATCH_METHOD, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x118, DISPATCH_METHOD, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -2490,21 +2490,21 @@ void _Workbook::OpenLinks(LPCTSTR Name, const VARIANT& ReadOnly, const VARIANT& { static BYTE parms[] = VTS_BSTR VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x323, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x323, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Name, &ReadOnly, &Type); } CString _Workbook::GetPath() { CString result; - InvokeHelper(0x123, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x123, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } BOOL _Workbook::GetPersonalViewListSettings() { BOOL result; - InvokeHelper(0x5a7, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x5a7, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2512,14 +2512,14 @@ void _Workbook::SetPersonalViewListSettings(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x5a7, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x5a7, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Workbook::GetPersonalViewPrintSettings() { BOOL result; - InvokeHelper(0x5a8, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x5a8, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2527,14 +2527,14 @@ void _Workbook::SetPersonalViewPrintSettings(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x5a8, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x5a8, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } LPDISPATCH _Workbook::PivotCaches() { LPDISPATCH result; - InvokeHelper(0x5a9, DISPATCH_METHOD, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x5a9, DISPATCH_METHOD, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -2542,14 +2542,14 @@ void _Workbook::Post(const VARIANT& DestName) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x48e, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x48e, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &DestName); } BOOL _Workbook::GetPrecisionAsDisplayed() { BOOL result; - InvokeHelper(0x195, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x195, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2557,7 +2557,7 @@ void _Workbook::SetPrecisionAsDisplayed(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x195, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x195, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -2565,7 +2565,7 @@ void _Workbook::PrintOut(const VARIANT& From, const VARIANT& To, const VARIANT& { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x389, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x389, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &From, &To, &Copies, &Preview, &ActivePrinter, &PrintToFile, &Collate); } @@ -2573,7 +2573,7 @@ void _Workbook::PrintPreview(const VARIANT& EnableChanges) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x119, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x119, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &EnableChanges); } @@ -2581,7 +2581,7 @@ void _Workbook::Protect(const VARIANT& Password, const VARIANT& Structure, const { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x11a, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x11a, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Password, &Structure, &Windows); } @@ -2589,84 +2589,84 @@ void _Workbook::ProtectSharing(const VARIANT& Filename, const VARIANT& Password, { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x5aa, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x5aa, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Filename, &Password, &WriteResPassword, &ReadOnlyRecommended, &CreateBackup, &SharingPassword); } BOOL _Workbook::GetProtectStructure() { BOOL result; - InvokeHelper(0x24c, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x24c, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } BOOL _Workbook::GetProtectWindows() { BOOL result; - InvokeHelper(0x127, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x127, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } BOOL _Workbook::GetReadOnly() { BOOL result; - InvokeHelper(0x128, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x128, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } BOOL _Workbook::GetReadOnlyRecommended() { BOOL result; - InvokeHelper(0x129, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x129, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } void _Workbook::RefreshAll() { - InvokeHelper(0x5ac, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x5ac, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void _Workbook::Reply() { - InvokeHelper(0x3d1, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x3d1, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void _Workbook::ReplyAll() { - InvokeHelper(0x3d2, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x3d2, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void _Workbook::RemoveUser(long Index) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x5ad, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x5ad, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Index); } long _Workbook::GetRevisionNumber() { long result; - InvokeHelper(0x494, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x494, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } void _Workbook::Route() { - InvokeHelper(0x3b2, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x3b2, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } BOOL _Workbook::GetRouted() { BOOL result; - InvokeHelper(0x3b7, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x3b7, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } LPDISPATCH _Workbook::GetRoutingSlip() { LPDISPATCH result; - InvokeHelper(0x3b5, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x3b5, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -2674,13 +2674,13 @@ void _Workbook::RunAutoMacros(long Which) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x27a, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x27a, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Which); } void _Workbook::Save() { - InvokeHelper(0x11b, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x11b, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void _Workbook::SaveAs(const VARIANT& Filename, const VARIANT& FileFormat, const VARIANT& Password, const VARIANT& WriteResPassword, const VARIANT& ReadOnlyRecommended, const VARIANT& CreateBackup, long AccessMode, const VARIANT& ConflictResolution, @@ -2688,7 +2688,7 @@ void _Workbook::SaveAs(const VARIANT& Filename, const VARIANT& FileFormat, const { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_I4 VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x11c, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x11c, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Filename, &FileFormat, &Password, &WriteResPassword, &ReadOnlyRecommended, &CreateBackup, AccessMode, &ConflictResolution, &AddToMru, &TextCodepage, &TextVisualLayout); } @@ -2696,14 +2696,14 @@ void _Workbook::SaveCopyAs(const VARIANT& Filename) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0xaf, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0xaf, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Filename); } BOOL _Workbook::GetSaved() { BOOL result; - InvokeHelper(0x12a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x12a, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2711,14 +2711,14 @@ void _Workbook::SetSaved(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x12a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x12a, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Workbook::GetSaveLinkValues() { BOOL result; - InvokeHelper(0x196, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x196, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2726,7 +2726,7 @@ void _Workbook::SetSaveLinkValues(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x196, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x196, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -2734,7 +2734,7 @@ void _Workbook::SendMail(const VARIANT& Recipients, const VARIANT& Subject, cons { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x3b3, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x3b3, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Recipients, &Subject, &ReturnReceipt); } @@ -2742,7 +2742,7 @@ void _Workbook::SendMailer(const VARIANT& FileFormat, long Priority) { static BYTE parms[] = VTS_VARIANT VTS_I4; - InvokeHelper(0x3d4, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x3d4, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &FileFormat, Priority); } @@ -2750,21 +2750,21 @@ void _Workbook::SetLinkOnData(LPCTSTR Name, const VARIANT& Procedure) { static BYTE parms[] = VTS_BSTR VTS_VARIANT; - InvokeHelper(0x329, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x329, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Name, &Procedure); } LPDISPATCH _Workbook::GetSheets() { LPDISPATCH result; - InvokeHelper(0x1e5, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1e5, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } BOOL _Workbook::GetShowConflictHistory() { BOOL result; - InvokeHelper(0x493, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x493, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2772,14 +2772,14 @@ void _Workbook::SetShowConflictHistory(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x493, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x493, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } LPDISPATCH _Workbook::GetStyles() { LPDISPATCH result; - InvokeHelper(0x1ed, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1ed, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -2787,7 +2787,7 @@ void _Workbook::Unprotect(const VARIANT& Password) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x11d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x11d, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Password); } @@ -2795,27 +2795,27 @@ void _Workbook::UnprotectSharing(const VARIANT& SharingPassword) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x5af, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x5af, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &SharingPassword); } void _Workbook::UpdateFromFile() { - InvokeHelper(0x3e3, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x3e3, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void _Workbook::UpdateLink(const VARIANT& Name, const VARIANT& Type) { static BYTE parms[] = VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x324, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x324, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Name, &Type); } BOOL _Workbook::GetUpdateRemoteReferences() { BOOL result; - InvokeHelper(0x19b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x19b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2823,70 +2823,70 @@ void _Workbook::SetUpdateRemoteReferences(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x19b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x19b, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } VARIANT _Workbook::GetUserStatus() { VARIANT result; - InvokeHelper(0x495, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x495, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } LPDISPATCH _Workbook::GetCustomViews() { LPDISPATCH result; - InvokeHelper(0x5b0, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x5b0, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Workbook::GetWindows() { LPDISPATCH result; - InvokeHelper(0x1ae, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1ae, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Workbook::GetWorksheets() { LPDISPATCH result; - InvokeHelper(0x1ee, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1ee, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } BOOL _Workbook::GetWriteReserved() { BOOL result; - InvokeHelper(0x12b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x12b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } CString _Workbook::GetWriteReservedBy() { CString result; - InvokeHelper(0x12c, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x12c, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } LPDISPATCH _Workbook::GetExcel4IntlMacroSheets() { LPDISPATCH result; - InvokeHelper(0x245, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x245, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Workbook::GetExcel4MacroSheets() { LPDISPATCH result; - InvokeHelper(0x243, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x243, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } BOOL _Workbook::GetTemplateRemoveExtData() { BOOL result; - InvokeHelper(0x5b1, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x5b1, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2894,7 +2894,7 @@ void _Workbook::SetTemplateRemoveExtData(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x5b1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x5b1, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -2902,14 +2902,14 @@ void _Workbook::HighlightChangesOptions(const VARIANT& When, const VARIANT& Who, { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x5b2, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x5b2, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &When, &Who, &Where); } BOOL _Workbook::GetHighlightChangesOnScreen() { BOOL result; - InvokeHelper(0x5b5, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x5b5, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2917,14 +2917,14 @@ void _Workbook::SetHighlightChangesOnScreen(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x5b5, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x5b5, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Workbook::GetKeepChangeHistory() { BOOL result; - InvokeHelper(0x5b6, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x5b6, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2932,14 +2932,14 @@ void _Workbook::SetKeepChangeHistory(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x5b6, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x5b6, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Workbook::GetListChangesOnNewSheet() { BOOL result; - InvokeHelper(0x5b7, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x5b7, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -2947,7 +2947,7 @@ void _Workbook::SetListChangesOnNewSheet(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x5b7, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x5b7, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -2955,7 +2955,7 @@ void _Workbook::PurgeChangeHistoryNow(long Days, const VARIANT& SharingPassword) { static BYTE parms[] = VTS_I4 VTS_VARIANT; - InvokeHelper(0x5b8, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x5b8, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Days, &SharingPassword); } @@ -2963,7 +2963,7 @@ void _Workbook::AcceptAllChanges(const VARIANT& When, const VARIANT& Who, const { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x5ba, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x5ba, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &When, &Who, &Where); } @@ -2971,19 +2971,19 @@ void _Workbook::RejectAllChanges(const VARIANT& When, const VARIANT& Who, const { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x5bb, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x5bb, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &When, &Who, &Where); } void _Workbook::ResetColors() { - InvokeHelper(0x5bc, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x5bc, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } LPDISPATCH _Workbook::GetVBProject() { LPDISPATCH result; - InvokeHelper(0x5bd, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x5bd, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -2991,19 +2991,19 @@ void _Workbook::FollowHyperlink(LPCTSTR Address, const VARIANT& SubAddress, cons { static BYTE parms[] = VTS_BSTR VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x5be, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x5be, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Address, &SubAddress, &NewWindow, &AddHistory, &ExtraInfo, &Method, &HeaderInfo); } void _Workbook::AddToFavorites() { - InvokeHelper(0x5c4, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x5c4, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } BOOL _Workbook::GetIsInplace() { BOOL result; - InvokeHelper(0x6f4, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x6f4, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -3017,53 +3017,53 @@ BOOL _Workbook::GetIsInplace() LPDISPATCH _Worksheet::GetApplication() { LPDISPATCH result; - InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long _Worksheet::GetCreator() { long result; - InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } LPDISPATCH _Worksheet::GetParent() { LPDISPATCH result; - InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } void _Worksheet::Activate() { - InvokeHelper(0x130, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x130, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void _Worksheet::Copy(const VARIANT& Before, const VARIANT& After) { static BYTE parms[] = VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x227, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x227, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Before, &After); } void _Worksheet::Delete() { - InvokeHelper(0x75, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x75, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } CString _Worksheet::GetCodeName() { CString result; - InvokeHelper(0x55d, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x55d, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } CString _Worksheet::Get_CodeName() { CString result; - InvokeHelper(0x80010000, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x80010000, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -3071,14 +3071,14 @@ void _Worksheet::Set_CodeName(LPCTSTR lpszNewValue) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x80010000, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x80010000, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, lpszNewValue); } long _Worksheet::GetIndex() { long result; - InvokeHelper(0x1e6, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x1e6, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -3086,14 +3086,14 @@ void _Worksheet::Move(const VARIANT& Before, const VARIANT& After) { static BYTE parms[] = VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x27d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x27d, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Before, &After); } CString _Worksheet::GetName() { CString result; - InvokeHelper(0x6e, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x6e, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -3101,28 +3101,28 @@ void _Worksheet::SetName(LPCTSTR lpszNewValue) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x6e, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x6e, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, lpszNewValue); } LPDISPATCH _Worksheet::GetNext() { LPDISPATCH result; - InvokeHelper(0x1f6, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1f6, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Worksheet::GetPageSetup() { LPDISPATCH result; - InvokeHelper(0x3e6, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x3e6, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Worksheet::GetPrevious() { LPDISPATCH result; - InvokeHelper(0x1f7, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1f7, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -3130,7 +3130,7 @@ void _Worksheet::PrintOut(const VARIANT& From, const VARIANT& To, const VARIANT& { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x389, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x389, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &From, &To, &Copies, &Preview, &ActivePrinter, &PrintToFile, &Collate); } @@ -3138,7 +3138,7 @@ void _Worksheet::PrintPreview(const VARIANT& EnableChanges) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x119, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x119, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &EnableChanges); } @@ -3146,35 +3146,35 @@ void _Worksheet::Protect(const VARIANT& Password, const VARIANT& DrawingObjects, { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x11a, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x11a, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Password, &DrawingObjects, &Contents, &Scenarios, &UserInterfaceOnly); } BOOL _Worksheet::GetProtectContents() { BOOL result; - InvokeHelper(0x124, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x124, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } BOOL _Worksheet::GetProtectDrawingObjects() { BOOL result; - InvokeHelper(0x125, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x125, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } BOOL _Worksheet::GetProtectionMode() { BOOL result; - InvokeHelper(0x487, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x487, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } BOOL _Worksheet::GetProtectScenarios() { BOOL result; - InvokeHelper(0x126, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x126, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -3183,7 +3183,7 @@ void _Worksheet::SaveAs(LPCTSTR Filename, const VARIANT& FileFormat, const VARIA { static BYTE parms[] = VTS_BSTR VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x11c, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x11c, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Filename, &FileFormat, &Password, &WriteResPassword, &ReadOnlyRecommended, &CreateBackup, &AddToMru, &TextCodepage, &TextVisualLayout); } @@ -3191,7 +3191,7 @@ void _Worksheet::Select(const VARIANT& Replace) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0xeb, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0xeb, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Replace); } @@ -3199,14 +3199,14 @@ void _Worksheet::Unprotect(const VARIANT& Password) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x11d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x11d, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Password); } long _Worksheet::GetVisible() { long result; - InvokeHelper(0x22e, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x22e, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -3214,21 +3214,21 @@ void _Worksheet::SetVisible(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x22e, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x22e, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } LPDISPATCH _Worksheet::GetShapes() { LPDISPATCH result; - InvokeHelper(0x561, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x561, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } BOOL _Worksheet::GetTransitionExpEval() { BOOL result; - InvokeHelper(0x191, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x191, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -3236,14 +3236,14 @@ void _Worksheet::SetTransitionExpEval(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x191, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x191, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Worksheet::GetAutoFilterMode() { BOOL result; - InvokeHelper(0x318, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x318, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -3251,7 +3251,7 @@ void _Worksheet::SetAutoFilterMode(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x318, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x318, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -3259,19 +3259,19 @@ void _Worksheet::SetBackgroundPicture(LPCTSTR Filename) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x4a4, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x4a4, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Filename); } void _Worksheet::Calculate() { - InvokeHelper(0x117, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x117, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } BOOL _Worksheet::GetEnableCalculation() { BOOL result; - InvokeHelper(0x590, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x590, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -3279,14 +3279,14 @@ void _Worksheet::SetEnableCalculation(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x590, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x590, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } LPDISPATCH _Worksheet::GetCells() { LPDISPATCH result; - InvokeHelper(0xee, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0xee, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -3304,54 +3304,54 @@ void _Worksheet::CheckSpelling(const VARIANT& CustomDictionary, const VARIANT& I { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x1f9, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x1f9, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &CustomDictionary, &IgnoreUppercase, &AlwaysSuggest, &IgnoreInitialAlefHamza, &IgnoreFinalYaa, &SpellScript); } LPDISPATCH _Worksheet::GetCircularReference() { LPDISPATCH result; - InvokeHelper(0x42d, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x42d, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } void _Worksheet::ClearArrows() { - InvokeHelper(0x3ca, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x3ca, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } LPDISPATCH _Worksheet::GetColumns() { LPDISPATCH result; - InvokeHelper(0xf1, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0xf1, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long _Worksheet::GetConsolidationFunction() { long result; - InvokeHelper(0x315, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x315, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } VARIANT _Worksheet::GetConsolidationOptions() { VARIANT result; - InvokeHelper(0x316, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x316, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } VARIANT _Worksheet::GetConsolidationSources() { VARIANT result; - InvokeHelper(0x317, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x317, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } BOOL _Worksheet::GetEnableAutoFilter() { BOOL result; - InvokeHelper(0x484, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x484, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -3359,14 +3359,14 @@ void _Worksheet::SetEnableAutoFilter(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x484, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x484, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } long _Worksheet::GetEnableSelection() { long result; - InvokeHelper(0x591, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x591, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -3374,14 +3374,14 @@ void _Worksheet::SetEnableSelection(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x591, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x591, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } BOOL _Worksheet::GetEnableOutlining() { BOOL result; - InvokeHelper(0x485, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x485, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -3389,14 +3389,14 @@ void _Worksheet::SetEnableOutlining(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x485, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x485, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } BOOL _Worksheet::GetEnablePivotTable() { BOOL result; - InvokeHelper(0x486, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x486, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -3404,7 +3404,7 @@ void _Worksheet::SetEnablePivotTable(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x486, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x486, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } @@ -3431,19 +3431,19 @@ VARIANT _Worksheet::_Evaluate(const VARIANT& Name) BOOL _Worksheet::GetFilterMode() { BOOL result; - InvokeHelper(0x320, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x320, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } void _Worksheet::ResetAllPageBreaks() { - InvokeHelper(0x592, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x592, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } LPDISPATCH _Worksheet::GetNames() { LPDISPATCH result; - InvokeHelper(0x1ba, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1ba, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -3460,7 +3460,7 @@ LPDISPATCH _Worksheet::OLEObjects(const VARIANT& Index) LPDISPATCH _Worksheet::GetOutline() { LPDISPATCH result; - InvokeHelper(0x66, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x66, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -3468,7 +3468,7 @@ void _Worksheet::Paste(const VARIANT& Destination, const VARIANT& Link) { static BYTE parms[] = VTS_VARIANT VTS_VARIANT; - InvokeHelper(0xd3, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0xd3, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Destination, &Link); } @@ -3476,7 +3476,7 @@ void _Worksheet::PasteSpecial(const VARIANT& Format, const VARIANT& Link, const { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x403, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x403, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Format, &Link, &DisplayAsIcon, &IconFileName, &IconIndex, &IconLabel); } @@ -3515,7 +3515,7 @@ LPDISPATCH _Worksheet::GetRange(const VARIANT& Cell1, const VARIANT& Cell2) LPDISPATCH _Worksheet::GetRows() { LPDISPATCH result; - InvokeHelper(0x102, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x102, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -3532,7 +3532,7 @@ LPDISPATCH _Worksheet::Scenarios(const VARIANT& Index) CString _Worksheet::GetScrollArea() { CString result; - InvokeHelper(0x599, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL); + InvokeHelper(0x599, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, nullptr); return result; } @@ -3540,31 +3540,31 @@ void _Worksheet::SetScrollArea(LPCTSTR lpszNewValue) { static BYTE parms[] = VTS_BSTR; - InvokeHelper(0x599, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x599, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, lpszNewValue); } void _Worksheet::ShowAllData() { - InvokeHelper(0x31a, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x31a, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void _Worksheet::ShowDataForm() { - InvokeHelper(0x199, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x199, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } double _Worksheet::GetStandardHeight() { double result; - InvokeHelper(0x197, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, NULL); + InvokeHelper(0x197, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, nullptr); return result; } double _Worksheet::GetStandardWidth() { double result; - InvokeHelper(0x198, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, NULL); + InvokeHelper(0x198, DISPATCH_PROPERTYGET, VT_R8, (void*)&result, nullptr); return result; } @@ -3572,14 +3572,14 @@ void _Worksheet::SetStandardWidth(double newValue) { static BYTE parms[] = VTS_R8; - InvokeHelper(0x198, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x198, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, newValue); } BOOL _Worksheet::GetTransitionFormEntry() { BOOL result; - InvokeHelper(0x192, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x192, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -3587,49 +3587,49 @@ void _Worksheet::SetTransitionFormEntry(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x192, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x192, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } long _Worksheet::GetType() { long result; - InvokeHelper(0x6c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x6c, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } LPDISPATCH _Worksheet::GetUsedRange() { LPDISPATCH result; - InvokeHelper(0x19c, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x19c, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Worksheet::GetHPageBreaks() { LPDISPATCH result; - InvokeHelper(0x58a, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x58a, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Worksheet::GetVPageBreaks() { LPDISPATCH result; - InvokeHelper(0x58b, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x58b, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Worksheet::GetQueryTables() { LPDISPATCH result; - InvokeHelper(0x59a, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x59a, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } BOOL _Worksheet::GetDisplayPageBreaks() { BOOL result; - InvokeHelper(0x59b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, NULL); + InvokeHelper(0x59b, DISPATCH_PROPERTYGET, VT_BOOL, (void*)&result, nullptr); return result; } @@ -3637,38 +3637,38 @@ void _Worksheet::SetDisplayPageBreaks(BOOL bNewValue) { static BYTE parms[] = VTS_BOOL; - InvokeHelper(0x59b, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x59b, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, bNewValue); } LPDISPATCH _Worksheet::GetComments() { LPDISPATCH result; - InvokeHelper(0x23f, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x23f, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH _Worksheet::GetHyperlinks() { LPDISPATCH result; - InvokeHelper(0x571, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x571, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } void _Worksheet::ClearCircles() { - InvokeHelper(0x59c, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x59c, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void _Worksheet::CircleInvalid() { - InvokeHelper(0x59d, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x59d, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } LPDISPATCH _Worksheet::GetAutoFilter() { LPDISPATCH result; - InvokeHelper(0x319, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x319, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -3682,33 +3682,33 @@ LPDISPATCH _Worksheet::GetAutoFilter() LPDISPATCH Range::GetApplication() { LPDISPATCH result; - InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long Range::GetCreator() { long result; - InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } LPDISPATCH Range::GetParent() { LPDISPATCH result; - InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } void Range::Activate() { - InvokeHelper(0x130, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x130, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } VARIANT Range::GetAddIndent() { VARIANT result; - InvokeHelper(0x427, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x427, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -3716,7 +3716,7 @@ void Range::SetAddIndent(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x427, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x427, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } @@ -3744,7 +3744,7 @@ void Range::AdvancedFilter(long Action, const VARIANT& CriteriaRange, const VARI { static BYTE parms[] = VTS_I4 VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x36c, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x36c, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Action, &CriteriaRange, &CopyToRange, &Unique); } @@ -3752,19 +3752,19 @@ void Range::ApplyNames(const VARIANT& Names, const VARIANT& IgnoreRelativeAbsolu { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_I4 VTS_VARIANT; - InvokeHelper(0x1b9, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x1b9, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Names, &IgnoreRelativeAbsolute, &UseRowColumnNames, &OmitColumn, &OmitRow, Order, &AppendLast); } void Range::ApplyOutlineStyles() { - InvokeHelper(0x1c0, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x1c0, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } LPDISPATCH Range::GetAreas() { LPDISPATCH result; - InvokeHelper(0x238, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x238, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -3782,7 +3782,7 @@ void Range::AutoFill(LPDISPATCH Destination, long Type) { static BYTE parms[] = VTS_DISPATCH VTS_I4; - InvokeHelper(0x1c1, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x1c1, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Destination, Type); } @@ -3790,52 +3790,52 @@ void Range::AutoFilter(const VARIANT& Field, const VARIANT& Criteria1, long Oper { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_I4 VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x319, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x319, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Field, &Criteria1, Operator, &Criteria2, &VisibleDropDown); } void Range::AutoFit() { - InvokeHelper(0xed, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0xed, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void Range::AutoFormat(long Format, const VARIANT& Number, const VARIANT& Font, const VARIANT& Alignment, const VARIANT& Border, const VARIANT& Pattern, const VARIANT& Width) { static BYTE parms[] = VTS_I4 VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x72, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x72, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Format, &Number, &Font, &Alignment, &Border, &Pattern, &Width); } void Range::AutoOutline() { - InvokeHelper(0x40c, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x40c, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void Range::BorderAround(const VARIANT& LineStyle, long Weight, long ColorIndex, const VARIANT& Color) { static BYTE parms[] = VTS_VARIANT VTS_I4 VTS_I4 VTS_VARIANT; - InvokeHelper(0x42b, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x42b, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &LineStyle, Weight, ColorIndex, &Color); } LPDISPATCH Range::GetBorders() { LPDISPATCH result; - InvokeHelper(0x1b3, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1b3, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } void Range::Calculate() { - InvokeHelper(0x117, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x117, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } LPDISPATCH Range::GetCells() { LPDISPATCH result; - InvokeHelper(0xee, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0xee, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -3853,39 +3853,39 @@ void Range::CheckSpelling(const VARIANT& CustomDictionary, const VARIANT& Ignore { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x1f9, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x1f9, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &CustomDictionary, &IgnoreUppercase, &AlwaysSuggest, &IgnoreInitialAlefHamza, &IgnoreFinalYaa, &SpellScript); } void Range::Clear() { - InvokeHelper(0x6f, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x6f, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void Range::ClearContents() { - InvokeHelper(0x71, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x71, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void Range::ClearFormats() { - InvokeHelper(0x70, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x70, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void Range::ClearNotes() { - InvokeHelper(0xef, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0xef, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void Range::ClearOutline() { - InvokeHelper(0x40d, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x40d, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } long Range::GetColumn() { long result; - InvokeHelper(0xf0, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0xf0, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -3902,14 +3902,14 @@ LPDISPATCH Range::ColumnDifferences(const VARIANT& Comparison) LPDISPATCH Range::GetColumns() { LPDISPATCH result; - InvokeHelper(0xf1, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0xf1, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } VARIANT Range::GetColumnWidth() { VARIANT result; - InvokeHelper(0xf2, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0xf2, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -3917,7 +3917,7 @@ void Range::SetColumnWidth(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0xf2, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0xf2, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } @@ -3925,7 +3925,7 @@ void Range::Consolidate(const VARIANT& Sources, const VARIANT& Function, const V { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x1e2, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x1e2, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Sources, &Function, &TopRow, &LeftColumn, &CreateLinks); } @@ -3933,7 +3933,7 @@ void Range::Copy(const VARIANT& Destination) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x227, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x227, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Destination); } @@ -3951,14 +3951,14 @@ void Range::CopyPicture(long Appearance, long Format) { static BYTE parms[] = VTS_I4 VTS_I4; - InvokeHelper(0xd5, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0xd5, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Appearance, Format); } long Range::GetCount() { long result; - InvokeHelper(0x76, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x76, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -3966,7 +3966,7 @@ void Range::CreateNames(const VARIANT& Top, const VARIANT& Left, const VARIANT& { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x1c9, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x1c9, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Top, &Left, &Bottom, &Right); } @@ -3974,21 +3974,21 @@ void Range::CreatePublisher(const VARIANT& Edition, long Appearance, const VARIA { static BYTE parms[] = VTS_VARIANT VTS_I4 VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x1ca, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x1ca, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Edition, Appearance, &ContainsPICT, &ContainsBIFF, &ContainsRTF, &ContainsVALU); } LPDISPATCH Range::GetCurrentArray() { LPDISPATCH result; - InvokeHelper(0x1f5, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1f5, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH Range::GetCurrentRegion() { LPDISPATCH result; - InvokeHelper(0xf3, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0xf3, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -3996,7 +3996,7 @@ void Range::Cut(const VARIANT& Destination) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x235, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x235, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Destination); } @@ -4004,7 +4004,7 @@ void Range::DataSeries(const VARIANT& Rowcol, long Type, long Date, const VARIAN { static BYTE parms[] = VTS_VARIANT VTS_I4 VTS_I4 VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x1d0, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x1d0, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Rowcol, Type, Date, &Step, &Stop, &Trend); } @@ -4022,7 +4022,7 @@ void Range::Set_Default(const VARIANT& RowIndex, const VARIANT& ColumnIndex, con { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x0, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x0, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &RowIndex, &ColumnIndex, &newValue); } @@ -4030,35 +4030,35 @@ void Range::Delete(const VARIANT& Shift) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x75, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x75, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Shift); } LPDISPATCH Range::GetDependents() { LPDISPATCH result; - InvokeHelper(0x21f, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x21f, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } VARIANT Range::DialogBox_() { VARIANT result; - InvokeHelper(0xf5, DISPATCH_METHOD, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0xf5, DISPATCH_METHOD, VT_VARIANT, (void*)&result, nullptr); return result; } LPDISPATCH Range::GetDirectDependents() { LPDISPATCH result; - InvokeHelper(0x221, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x221, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH Range::GetDirectPrecedents() { LPDISPATCH result; - InvokeHelper(0x222, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x222, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -4085,35 +4085,35 @@ LPDISPATCH Range::GetEnd(long Direction) LPDISPATCH Range::GetEntireColumn() { LPDISPATCH result; - InvokeHelper(0xf6, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0xf6, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH Range::GetEntireRow() { LPDISPATCH result; - InvokeHelper(0xf7, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0xf7, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } void Range::FillDown() { - InvokeHelper(0xf8, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0xf8, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void Range::FillLeft() { - InvokeHelper(0xf9, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0xf9, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void Range::FillRight() { - InvokeHelper(0xfa, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0xfa, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void Range::FillUp() { - InvokeHelper(0xfb, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0xfb, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } LPDISPATCH Range::Find(const VARIANT& What, const VARIANT& After, const VARIANT& LookIn, const VARIANT& LookAt, const VARIANT& SearchOrder, long SearchDirection, const VARIANT& MatchCase, const VARIANT& MatchByte, @@ -4150,14 +4150,14 @@ LPDISPATCH Range::FindPrevious(const VARIANT& After) LPDISPATCH Range::GetFont() { LPDISPATCH result; - InvokeHelper(0x92, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x92, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } VARIANT Range::GetFormula() { VARIANT result; - InvokeHelper(0x105, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x105, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4165,14 +4165,14 @@ void Range::SetFormula(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x105, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x105, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Range::GetFormulaArray() { VARIANT result; - InvokeHelper(0x24a, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x24a, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4180,14 +4180,14 @@ void Range::SetFormulaArray(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x24a, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x24a, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } long Range::GetFormulaLabel() { long result; - InvokeHelper(0x564, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x564, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -4195,14 +4195,14 @@ void Range::SetFormulaLabel(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x564, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x564, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } VARIANT Range::GetFormulaHidden() { VARIANT result; - InvokeHelper(0x106, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x106, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4210,14 +4210,14 @@ void Range::SetFormulaHidden(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x106, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x106, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Range::GetFormulaLocal() { VARIANT result; - InvokeHelper(0x107, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x107, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4225,14 +4225,14 @@ void Range::SetFormulaLocal(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x107, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x107, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Range::GetFormulaR1C1() { VARIANT result; - InvokeHelper(0x108, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x108, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4240,14 +4240,14 @@ void Range::SetFormulaR1C1(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x108, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x108, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Range::GetFormulaR1C1Local() { VARIANT result; - InvokeHelper(0x109, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x109, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4255,13 +4255,13 @@ void Range::SetFormulaR1C1Local(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x109, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x109, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } void Range::FunctionWizard() { - InvokeHelper(0x23b, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x23b, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } BOOL Range::GoalSeek(const VARIANT& Goal, LPDISPATCH ChangingCell) @@ -4287,28 +4287,28 @@ VARIANT Range::Group(const VARIANT& Start, const VARIANT& End, const VARIANT& By VARIANT Range::GetHasArray() { VARIANT result; - InvokeHelper(0x10a, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x10a, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } VARIANT Range::GetHasFormula() { VARIANT result; - InvokeHelper(0x10b, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x10b, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } VARIANT Range::GetHeight() { VARIANT result; - InvokeHelper(0x7b, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x7b, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } VARIANT Range::GetHidden() { VARIANT result; - InvokeHelper(0x10c, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x10c, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4316,14 +4316,14 @@ void Range::SetHidden(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x10c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x10c, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Range::GetHorizontalAlignment() { VARIANT result; - InvokeHelper(0x88, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x88, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4331,14 +4331,14 @@ void Range::SetHorizontalAlignment(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x88, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x88, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Range::GetIndentLevel() { VARIANT result; - InvokeHelper(0xc9, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0xc9, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4346,7 +4346,7 @@ void Range::SetIndentLevel(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0xc9, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0xc9, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } @@ -4354,7 +4354,7 @@ void Range::InsertIndent(long InsertAmount) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x565, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x565, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, InsertAmount); } @@ -4362,14 +4362,14 @@ void Range::Insert(const VARIANT& Shift) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0xfc, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0xfc, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Shift); } LPDISPATCH Range::GetInterior() { LPDISPATCH result; - InvokeHelper(0x81, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x81, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -4387,45 +4387,45 @@ void Range::SetItem(const VARIANT& RowIndex, const VARIANT& ColumnIndex, const V { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0xaa, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0xaa, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &RowIndex, &ColumnIndex, &newValue); } void Range::Justify() { - InvokeHelper(0x1ef, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x1ef, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } VARIANT Range::GetLeft() { VARIANT result; - InvokeHelper(0x7f, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x7f, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } long Range::GetListHeaderRows() { long result; - InvokeHelper(0x4a3, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x4a3, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } void Range::ListNames() { - InvokeHelper(0xfd, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0xfd, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } long Range::GetLocationInTable() { long result; - InvokeHelper(0x2b3, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x2b3, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } VARIANT Range::GetLocked() { VARIANT result; - InvokeHelper(0x10d, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x10d, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4433,7 +4433,7 @@ void Range::SetLocked(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x10d, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x10d, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } @@ -4441,26 +4441,26 @@ void Range::Merge(const VARIANT& Across) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x234, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x234, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Across); } void Range::UnMerge() { - InvokeHelper(0x568, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x568, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } LPDISPATCH Range::GetMergeArea() { LPDISPATCH result; - InvokeHelper(0x569, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x569, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } VARIANT Range::GetMergeCells() { VARIANT result; - InvokeHelper(0xd0, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0xd0, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4468,14 +4468,14 @@ void Range::SetMergeCells(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0xd0, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0xd0, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Range::GetName() { VARIANT result; - InvokeHelper(0x6e, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x6e, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4483,7 +4483,7 @@ void Range::SetName(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x6e, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x6e, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } @@ -4491,21 +4491,21 @@ void Range::NavigateArrow(const VARIANT& TowardPrecedent, const VARIANT& ArrowNu { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x408, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x408, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &TowardPrecedent, &ArrowNumber, &LinkNumber); } LPUNKNOWN Range::Get_NewEnum() { LPUNKNOWN result; - InvokeHelper(0xfffffffc, DISPATCH_PROPERTYGET, VT_UNKNOWN, (void*)&result, NULL); + InvokeHelper(0xfffffffc, DISPATCH_PROPERTYGET, VT_UNKNOWN, (void*)&result, nullptr); return result; } LPDISPATCH Range::GetNext() { LPDISPATCH result; - InvokeHelper(0x1f6, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1f6, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -4522,7 +4522,7 @@ CString Range::NoteText(const VARIANT& Text, const VARIANT& Start, const VARIANT VARIANT Range::GetNumberFormat() { VARIANT result; - InvokeHelper(0xc1, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0xc1, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4530,14 +4530,14 @@ void Range::SetNumberFormat(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0xc1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0xc1, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Range::GetNumberFormatLocal() { VARIANT result; - InvokeHelper(0x449, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x449, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4545,7 +4545,7 @@ void Range::SetNumberFormatLocal(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x449, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x449, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } @@ -4562,7 +4562,7 @@ LPDISPATCH Range::GetOffset(const VARIANT& RowOffset, const VARIANT& ColumnOffse VARIANT Range::GetOrientation() { VARIANT result; - InvokeHelper(0x86, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x86, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4570,14 +4570,14 @@ void Range::SetOrientation(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x86, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x86, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Range::GetOutlineLevel() { VARIANT result; - InvokeHelper(0x10f, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x10f, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4585,14 +4585,14 @@ void Range::SetOutlineLevel(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x10f, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x10f, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } long Range::GetPageBreak() { long result; - InvokeHelper(0xff, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0xff, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -4600,7 +4600,7 @@ void Range::SetPageBreak(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0xff, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0xff, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } @@ -4608,7 +4608,7 @@ void Range::Parse(const VARIANT& ParseLine, const VARIANT& Destination) { static BYTE parms[] = VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x1dd, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x1dd, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &ParseLine, &Destination); } @@ -4616,49 +4616,49 @@ void Range::PasteSpecial(long Paste, long Operation, const VARIANT& SkipBlanks, { static BYTE parms[] = VTS_I4 VTS_I4 VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x403, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x403, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Paste, Operation, &SkipBlanks, &Transpose); } LPDISPATCH Range::GetPivotField() { LPDISPATCH result; - InvokeHelper(0x2db, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x2db, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH Range::GetPivotItem() { LPDISPATCH result; - InvokeHelper(0x2e4, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x2e4, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH Range::GetPivotTable() { LPDISPATCH result; - InvokeHelper(0x2cc, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x2cc, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH Range::GetPrecedents() { LPDISPATCH result; - InvokeHelper(0x220, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x220, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } VARIANT Range::GetPrefixCharacter() { VARIANT result; - InvokeHelper(0x1f8, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x1f8, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } LPDISPATCH Range::GetPrevious() { LPDISPATCH result; - InvokeHelper(0x1f7, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x1f7, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -4666,7 +4666,7 @@ void Range::PrintOut(const VARIANT& From, const VARIANT& To, const VARIANT& Copi { static BYTE parms[] = VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x389, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x389, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &From, &To, &Copies, &Preview, &ActivePrinter, &PrintToFile, &Collate); } @@ -4674,14 +4674,14 @@ void Range::PrintPreview(const VARIANT& EnableChanges) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x119, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x119, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &EnableChanges); } LPDISPATCH Range::GetQueryTable() { LPDISPATCH result; - InvokeHelper(0x56a, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x56a, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -4697,7 +4697,7 @@ LPDISPATCH Range::GetRange(const VARIANT& Cell1, const VARIANT& Cell2) void Range::RemoveSubtotal() { - InvokeHelper(0x373, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x373, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } BOOL Range::Replace(const VARIANT& What, const VARIANT& Replacement, const VARIANT& LookAt, const VARIANT& SearchOrder, const VARIANT& MatchCase, const VARIANT& MatchByte, const VARIANT& MatchControlCharacters, const VARIANT& MatchDiacritics, @@ -4724,7 +4724,7 @@ LPDISPATCH Range::GetResize(const VARIANT& RowSize, const VARIANT& ColumnSize) long Range::GetRow() { long result; - InvokeHelper(0x101, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x101, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -4741,7 +4741,7 @@ LPDISPATCH Range::RowDifferences(const VARIANT& Comparison) VARIANT Range::GetRowHeight() { VARIANT result; - InvokeHelper(0x110, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x110, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4749,14 +4749,14 @@ void Range::SetRowHeight(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x110, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x110, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } LPDISPATCH Range::GetRows() { LPDISPATCH result; - InvokeHelper(0x102, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x102, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -4775,26 +4775,26 @@ VARIANT Range::Run(const VARIANT& Arg1, const VARIANT& Arg2, const VARIANT& Arg3 void Range::Select() { - InvokeHelper(0xeb, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0xeb, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void Range::Show() { - InvokeHelper(0x1f0, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x1f0, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void Range::ShowDependents(const VARIANT& Remove) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x36d, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x36d, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Remove); } VARIANT Range::GetShowDetail() { VARIANT result; - InvokeHelper(0x249, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x249, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4802,27 +4802,27 @@ void Range::SetShowDetail(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x249, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x249, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } void Range::ShowErrors() { - InvokeHelper(0x36e, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x36e, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } void Range::ShowPrecedents(const VARIANT& Remove) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x36f, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x36f, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Remove); } VARIANT Range::GetShrinkToFit() { VARIANT result; - InvokeHelper(0xd1, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0xd1, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4830,7 +4830,7 @@ void Range::SetShrinkToFit(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0xd1, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0xd1, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } @@ -4839,7 +4839,7 @@ void Range::Sort(const VARIANT& Key1, long Order1, const VARIANT& Key2, const VA { static BYTE parms[] = VTS_VARIANT VTS_I4 VTS_VARIANT VTS_VARIANT VTS_I4 VTS_VARIANT VTS_I4 VTS_I4 VTS_VARIANT VTS_VARIANT VTS_I4 VTS_I4 VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x370, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x370, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Key1, Order1, &Key2, &Type, Order2, &Key3, Order3, Header, &OrderCustom, &MatchCase, Orientation, SortMethod, &IgnoreControlCharacters, &IgnoreDiacritics, &IgnoreKashida); } @@ -4847,14 +4847,14 @@ void Range::SortSpecial(long SortMethod, const VARIANT& Key1, long Order1, const { static BYTE parms[] = VTS_I4 VTS_VARIANT VTS_I4 VTS_VARIANT VTS_VARIANT VTS_I4 VTS_VARIANT VTS_I4 VTS_I4 VTS_VARIANT VTS_VARIANT VTS_I4; - InvokeHelper(0x371, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x371, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, SortMethod, &Key1, Order1, &Type, &Key2, Order2, &Key3, Order3, Header, &OrderCustom, &MatchCase, Orientation); } LPDISPATCH Range::GetSoundNote() { LPDISPATCH result; - InvokeHelper(0x394, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x394, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -4871,7 +4871,7 @@ LPDISPATCH Range::SpecialCells(long Type, const VARIANT& Value) VARIANT Range::GetStyle() { VARIANT result; - InvokeHelper(0x104, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x104, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4879,7 +4879,7 @@ void Range::SetStyle(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x104, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x104, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } @@ -4887,7 +4887,7 @@ void Range::SubscribeTo(LPCTSTR Edition, long Format) { static BYTE parms[] = VTS_BSTR VTS_I4; - InvokeHelper(0x1e1, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x1e1, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, Edition, Format); } @@ -4895,14 +4895,14 @@ void Range::Subtotal(long GroupBy, long Function, const VARIANT& TotalList, cons { static BYTE parms[] = VTS_I4 VTS_I4 VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_I4; - InvokeHelper(0x372, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x372, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, GroupBy, Function, &TotalList, &Replace, &PageBreaks, SummaryBelowData); } VARIANT Range::GetSummary() { VARIANT result; - InvokeHelper(0x111, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x111, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4910,14 +4910,14 @@ void Range::Table(const VARIANT& RowInput, const VARIANT& ColumnInput) { static BYTE parms[] = VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x1f1, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x1f1, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &RowInput, &ColumnInput); } VARIANT Range::GetText() { VARIANT result; - InvokeHelper(0x8a, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x8a, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4926,26 +4926,26 @@ void Range::TextToColumns(const VARIANT& Destination, long DataType, long TextQu { static BYTE parms[] = VTS_VARIANT VTS_I4 VTS_I4 VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT VTS_VARIANT; - InvokeHelper(0x410, DISPATCH_METHOD, VT_EMPTY, NULL, parms, + InvokeHelper(0x410, DISPATCH_METHOD, VT_EMPTY, nullptr, parms, &Destination, DataType, TextQualifier, &ConsecutiveDelimiter, &Tab, &Semicolon, &Comma, &Space, &Other, &OtherChar, &FieldInfo); } VARIANT Range::GetTop() { VARIANT result; - InvokeHelper(0x7e, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x7e, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } void Range::Ungroup() { - InvokeHelper(0xf4, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0xf4, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } VARIANT Range::GetUseStandardHeight() { VARIANT result; - InvokeHelper(0x112, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x112, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4953,14 +4953,14 @@ void Range::SetUseStandardHeight(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x112, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x112, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Range::GetUseStandardWidth() { VARIANT result; - InvokeHelper(0x113, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x113, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4968,21 +4968,21 @@ void Range::SetUseStandardWidth(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x113, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x113, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } LPDISPATCH Range::GetValidation() { LPDISPATCH result; - InvokeHelper(0x56b, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x56b, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } VARIANT Range::GetValue() { VARIANT result; - InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -4990,14 +4990,14 @@ void Range::SetValue(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x6, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x6, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Range::GetValue2() { VARIANT result; - InvokeHelper(0x56c, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x56c, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5005,14 +5005,14 @@ void Range::SetValue2(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x56c, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x56c, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Range::GetVerticalAlignment() { VARIANT result; - InvokeHelper(0x89, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x89, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5020,28 +5020,28 @@ void Range::SetVerticalAlignment(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x89, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x89, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Range::GetWidth() { VARIANT result; - InvokeHelper(0x7a, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x7a, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } LPDISPATCH Range::GetWorksheet() { LPDISPATCH result; - InvokeHelper(0x15c, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x15c, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } VARIANT Range::GetWrapText() { VARIANT result; - InvokeHelper(0x114, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x114, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5049,7 +5049,7 @@ void Range::SetWrapText(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x114, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x114, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } @@ -5066,33 +5066,33 @@ LPDISPATCH Range::AddComment(const VARIANT& Text) LPDISPATCH Range::GetComment() { LPDISPATCH result; - InvokeHelper(0x38e, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x38e, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } void Range::ClearComments() { - InvokeHelper(0x56e, DISPATCH_METHOD, VT_EMPTY, NULL, NULL); + InvokeHelper(0x56e, DISPATCH_METHOD, VT_EMPTY, nullptr, nullptr); } LPDISPATCH Range::GetPhonetic() { LPDISPATCH result; - InvokeHelper(0x56f, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x56f, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } LPDISPATCH Range::GetFormatConditions() { LPDISPATCH result; - InvokeHelper(0x570, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x570, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long Range::GetReadingOrder() { long result; - InvokeHelper(0x3cf, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x3cf, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -5100,14 +5100,14 @@ void Range::SetReadingOrder(long nNewValue) { static BYTE parms[] = VTS_I4; - InvokeHelper(0x3cf, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x3cf, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, nNewValue); } LPDISPATCH Range::GetHyperlinks() { LPDISPATCH result; - InvokeHelper(0x571, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x571, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } @@ -5121,28 +5121,28 @@ LPDISPATCH Range::GetHyperlinks() LPDISPATCH Border::GetApplication() { LPDISPATCH result; - InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long Border::GetCreator() { long result; - InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } LPDISPATCH Border::GetParent() { LPDISPATCH result; - InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } VARIANT Border::GetColor() { VARIANT result; - InvokeHelper(0x63, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x63, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5150,14 +5150,14 @@ void Border::SetColor(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x63, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x63, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Border::GetColorIndex() { VARIANT result; - InvokeHelper(0x61, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x61, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5165,14 +5165,14 @@ void Border::SetColorIndex(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x61, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x61, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Border::GetLineStyle() { VARIANT result; - InvokeHelper(0x77, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x77, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5180,14 +5180,14 @@ void Border::SetLineStyle(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x77, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x77, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Border::GetWeight() { VARIANT result; - InvokeHelper(0x78, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x78, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5195,7 +5195,7 @@ void Border::SetWeight(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x78, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x78, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } @@ -5209,28 +5209,28 @@ void Border::SetWeight(const VARIANT& newValue) LPDISPATCH Borders::GetApplication() { LPDISPATCH result; - InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long Borders::GetCreator() { long result; - InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } LPDISPATCH Borders::GetParent() { LPDISPATCH result; - InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } VARIANT Borders::GetColor() { VARIANT result; - InvokeHelper(0x63, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x63, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5238,14 +5238,14 @@ void Borders::SetColor(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x63, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x63, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Borders::GetColorIndex() { VARIANT result; - InvokeHelper(0x61, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x61, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5253,14 +5253,14 @@ void Borders::SetColorIndex(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x61, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x61, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } long Borders::GetCount() { long result; - InvokeHelper(0x76, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x76, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } @@ -5277,7 +5277,7 @@ LPDISPATCH Borders::GetItem(long Index) VARIANT Borders::GetLineStyle() { VARIANT result; - InvokeHelper(0x77, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x77, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5285,21 +5285,21 @@ void Borders::SetLineStyle(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x77, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x77, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } LPUNKNOWN Borders::Get_NewEnum() { LPUNKNOWN result; - InvokeHelper(0xfffffffc, DISPATCH_PROPERTYGET, VT_UNKNOWN, (void*)&result, NULL); + InvokeHelper(0xfffffffc, DISPATCH_PROPERTYGET, VT_UNKNOWN, (void*)&result, nullptr); return result; } VARIANT Borders::GetValue() { VARIANT result; - InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x6, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5307,14 +5307,14 @@ void Borders::SetValue(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x6, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x6, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Borders::GetWeight() { VARIANT result; - InvokeHelper(0x78, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x78, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5322,7 +5322,7 @@ void Borders::SetWeight(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x78, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x78, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } @@ -5346,28 +5346,28 @@ LPDISPATCH Borders::Get_Default(long Index) LPDISPATCH Interior::GetApplication() { LPDISPATCH result; - InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x94, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } long Interior::GetCreator() { long result; - InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, NULL); + InvokeHelper(0x95, DISPATCH_PROPERTYGET, VT_I4, (void*)&result, nullptr); return result; } LPDISPATCH Interior::GetParent() { LPDISPATCH result; - InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, NULL); + InvokeHelper(0x96, DISPATCH_PROPERTYGET, VT_DISPATCH, (void*)&result, nullptr); return result; } VARIANT Interior::GetColor() { VARIANT result; - InvokeHelper(0x63, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x63, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5375,14 +5375,14 @@ void Interior::SetColor(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x63, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x63, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Interior::GetColorIndex() { VARIANT result; - InvokeHelper(0x61, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x61, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5390,14 +5390,14 @@ void Interior::SetColorIndex(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x61, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x61, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Interior::GetInvertIfNegative() { VARIANT result; - InvokeHelper(0x84, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x84, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5405,14 +5405,14 @@ void Interior::SetInvertIfNegative(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x84, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x84, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Interior::GetPattern() { VARIANT result; - InvokeHelper(0x5f, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x5f, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5420,14 +5420,14 @@ void Interior::SetPattern(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x5f, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x5f, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Interior::GetPatternColor() { VARIANT result; - InvokeHelper(0x64, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x64, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5435,14 +5435,14 @@ void Interior::SetPatternColor(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x64, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x64, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } VARIANT Interior::GetPatternColorIndex() { VARIANT result; - InvokeHelper(0x62, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, NULL); + InvokeHelper(0x62, DISPATCH_PROPERTYGET, VT_VARIANT, (void*)&result, nullptr); return result; } @@ -5450,6 +5450,6 @@ void Interior::SetPatternColorIndex(const VARIANT& newValue) { static BYTE parms[] = VTS_VARIANT; - InvokeHelper(0x62, DISPATCH_PROPERTYPUT, VT_EMPTY, NULL, parms, + InvokeHelper(0x62, DISPATCH_PROPERTYPUT, VT_EMPTY, nullptr, parms, &newValue); } diff --git a/Core/Tools/Babylon/expimp.cpp b/Core/Tools/Babylon/expimp.cpp index 1b933889d38..235651df502 100644 --- a/Core/Tools/Babylon/expimp.cpp +++ b/Core/Tools/Babylon/expimp.cpp @@ -102,7 +102,7 @@ static void translateCopy( OLECHAR *outbuf, OLECHAR *inbuf ) { static OLECHAR buffer[100*1024]; - OLECHAR *firstLetter = NULL, *lastLetter; + OLECHAR *firstLetter = nullptr, *lastLetter; OLECHAR *b = buffer; int formatWord = FALSE; OLECHAR ch; @@ -118,7 +118,7 @@ static void translateCopy( OLECHAR *outbuf, OLECHAR *inbuf ) lastLetter = b-1; reverseWord ( firstLetter, lastLetter ); } - firstLetter = NULL; + firstLetter = nullptr; formatWord = FALSE; } *b++ = ch; @@ -200,7 +200,7 @@ static void writeText ( BabylonText *text, int row ) wcscpy ( olebuf, text->Get()); EncodeFormat ( olebuf ); PutCell ( row, CELL_ENGLISH, olebuf , 0); - PutCell ( row, CELL_MAXLEN, NULL , maxlen ); + PutCell ( row, CELL_MAXLEN, nullptr , maxlen ); swprintf ( buffer, L"=LEN(%c%d)",'A' + CELL_LOCALIZED -1, row ); PutCell ( row, CELL_STRLEN, buffer , 0); @@ -394,8 +394,8 @@ static int export_trans ( TransDB *db, LangID langid, TROPTIONS *options, void ( if ( write ) { - PutCell ( row, CELL_STRINGID, NULL, -1 ); - PutCell ( ROW_COUNT, COLUMN_COUNT, NULL, count ); + PutCell ( row, CELL_STRINGID, nullptr, -1 ); + PutCell ( ROW_COUNT, COLUMN_COUNT, nullptr, count ); } return count; @@ -405,7 +405,7 @@ static int export_trans ( TransDB *db, LangID langid, TROPTIONS *options, void ( int ExportTranslations ( TransDB *db, const char *filename, LangID langid, TROPTIONS *options, CBabylonDlg *dlg ) { int exports ; - exports = export_trans ( db, langid, options, NULL, FALSE ); + exports = export_trans ( db, langid, options, nullptr, FALSE ); if ( !exports ) { @@ -563,7 +563,7 @@ static int import_trans ( TransDB *db, LangID langid, void (*cb) ( void ), CBaby BabylonText *text; - if ( (text = db->FindText ( id )) == NULL ) + if ( (text = db->FindText ( id )) == nullptr ) { // string is no longer in database stale_count++; @@ -757,7 +757,7 @@ static int update_sent_trans ( TransDB *db, LangID langid, void (*cb) ( void ), BabylonText *text; - if ( (text = db->FindText ( id )) == NULL ) + if ( (text = db->FindText ( id )) == nullptr ) { // string is no longer in database unmatched++; @@ -1408,7 +1408,7 @@ void ProcessWaves ( TransDB *db, const char *filename, CBabylonDlg *dlg ) int last_row = 1; int matches = 0; int unmatched = 0; - FILE *file = NULL; + FILE *file = nullptr; char *ptr; strcpy ( buffer, filename ); @@ -1483,7 +1483,7 @@ int GenerateReport ( TransDB *db, const char *filename, RPOPTIONS *options, Lang LangID langid; int count= 0 ; int num; - FILE *file = NULL; + FILE *file = nullptr; if ( dlg ) { diff --git a/Core/Tools/Babylon/expimp.h b/Core/Tools/Babylon/expimp.h index b15d0252dc9..78a94f44bb0 100644 --- a/Core/Tools/Babylon/expimp.h +++ b/Core/Tools/Babylon/expimp.h @@ -100,9 +100,9 @@ typedef struct } CSF_HEADER; -int ExportTranslations ( TransDB *db, const char *filename, LangID langid, TROPTIONS *options, CBabylonDlg *dlg = NULL ); -int ImportTranslations ( TransDB *db, const char *filename, CBabylonDlg *dlg = NULL ); -int UpdateSentTranslations ( TransDB *db, const char *filename, CBabylonDlg *dlg = NULL ); -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 ); +int ExportTranslations ( TransDB *db, const char *filename, LangID langid, TROPTIONS *options, CBabylonDlg *dlg = nullptr ); +int ImportTranslations ( TransDB *db, const char *filename, CBabylonDlg *dlg = nullptr ); +int UpdateSentTranslations ( TransDB *db, const char *filename, CBabylonDlg *dlg = nullptr ); +int GenerateGameFiles ( TransDB *db, const char *filename, GNOPTIONS *option, LangID *languages, CBabylonDlg *dlg = nullptr ); +int GenerateReport ( TransDB *db, const char *filename, RPOPTIONS *options, LangID *languages, CBabylonDlg *dlg = nullptr ); void ProcessWaves ( TransDB *db, const char *filename, CBabylonDlg *dlg ); diff --git a/Core/Tools/Babylon/iff.cpp b/Core/Tools/Babylon/iff.cpp index d8fc596717b..36b12d77c1b 100644 --- a/Core/Tools/Babylon/iff.cpp +++ b/Core/Tools/Babylon/iff.cpp @@ -92,7 +92,7 @@ int IFF_seek ( IFF_FILE *iff, int pos, int mode ) IFF_FILE *IFF_Open ( const char *name ) { - IFF_FILE *iff = NULL; + IFF_FILE *iff = nullptr; if ( ! (iff = (IFF_FILE *) malloc ( sizeof (IFF_FILE)))) @@ -118,7 +118,7 @@ IFF_FILE *IFF_Open ( const char *name ) IFF_Close ( iff ); } - return NULL; + return nullptr; } /******************************************************************/ @@ -128,7 +128,7 @@ IFF_FILE *IFF_Open ( const char *name ) IFF_FILE *IFF_Load ( const char *name ) { - IFF_FILE *iff = NULL; + IFF_FILE *iff = nullptr; if ( ! (iff = (IFF_FILE *) malloc ( sizeof (IFF_FILE)))) { @@ -164,7 +164,7 @@ IFF_FILE *IFF_Load ( const char *name ) IFF_Close ( iff ); } - return NULL; + return nullptr; } /******************************************************************/ @@ -359,7 +359,7 @@ int IFF_Read ( IFF_FILE *iff, void *buff, int size ) IFF_FILE *IFF_New ( const char *name ) { - IFF_FILE *iff = NULL; + IFF_FILE *iff = nullptr; if ( ! (iff = (IFF_FILE *) malloc ( sizeof (IFF_FILE)))) @@ -384,7 +384,7 @@ IFF_FILE *IFF_New ( const char *name ) IFF_Close ( iff ); } - return NULL; + return nullptr; } /******************************************************************/ diff --git a/Core/Tools/Babylon/list.cpp b/Core/Tools/Babylon/list.cpp index 738a78f3d4f..bf076b0d89c 100644 --- a/Core/Tools/Babylon/list.cpp +++ b/Core/Tools/Babylon/list.cpp @@ -29,7 +29,7 @@ ListNode::ListNode ( void ) { prev = next = this; pri = NORMAL_PRIORITY; - item = NULL; + item = nullptr; } void ListNode::Append ( ListNode *new_node ) @@ -71,7 +71,7 @@ ListNode* ListNode::Next ( void ) { if ( next->IsHead ( ) ) { - return NULL; + return nullptr; } return next; @@ -81,7 +81,7 @@ ListNode* ListNode::Prev ( void ) { if ( prev->IsHead () ) { - return NULL; + return nullptr; } return prev; @@ -97,7 +97,7 @@ ListNode* ListNode::NextLoop ( void ) next_node = next_node->next; if ( next_node->IsHead ( )) { - return NULL; /* it is an empty list */ + return nullptr; /* it is an empty list */ } } @@ -115,7 +115,7 @@ ListNode* ListNode::PrevLoop ( void ) prev_node = prev_node->prev; if ( prev_node->IsHead ( )) { - return NULL; /* it is an empty list */ + return nullptr; /* it is an empty list */ } } @@ -265,7 +265,7 @@ void* List::Item ( int list_index ) return node->Item(); } - return NULL; + return nullptr; } ListNode* List::FirstNode ( void ) @@ -312,5 +312,5 @@ ListNode* List::Find ( void *item ) node = node->Next (); } - return NULL; + return nullptr; } diff --git a/Core/Tools/Babylon/loadsave.cpp b/Core/Tools/Babylon/loadsave.cpp index e3a7c30ebbd..f1a0e88963f 100644 --- a/Core/Tools/Babylon/loadsave.cpp +++ b/Core/Tools/Babylon/loadsave.cpp @@ -216,7 +216,7 @@ int WriteMainDB(TransDB *db, const char *filename, CBabylonDlg *dlg ) ListSearch sh_label; ListSearch sh_text; int count = 0; - IFF_FILE *iff = NULL; + IFF_FILE *iff = nullptr; DBINFO dbinfo; int ok = FALSE; @@ -339,11 +339,11 @@ int WriteMainDB(TransDB *db, const char *filename, CBabylonDlg *dlg ) int LoadMainDB(TransDB *db, const char *filename, void (*cb) (void) ) { - BabylonLabel *label = NULL; - BabylonText *text = NULL; - Translation *trans = NULL; + BabylonLabel *label = nullptr; + BabylonText *text = nullptr; + Translation *trans = nullptr; int count = 0; - IFF_FILE *iff = NULL; + IFF_FILE *iff = nullptr; DBINFO dbinfo; int ok = FALSE; @@ -393,14 +393,14 @@ int LoadMainDB(TransDB *db, const char *filename, void (*cb) (void) ) db->AddObsolete ( text ); } - text = NULL; + text = nullptr; } if ( label ) { count++; db->AddLabel ( label ); - label = NULL; + label = nullptr; if ( cb ) { cb (); @@ -459,7 +459,7 @@ int LoadMainDB(TransDB *db, const char *filename, void (*cb) (void) ) db->AddObsolete ( text ); } - text = NULL; + text = nullptr; } if ( ! (text = new BabylonText ())) @@ -547,7 +547,7 @@ int LoadMainDB(TransDB *db, const char *filename, void (*cb) (void) ) { delete trans; } - trans = NULL; + trans = nullptr; break; } @@ -565,14 +565,14 @@ int LoadMainDB(TransDB *db, const char *filename, void (*cb) (void) ) db->AddObsolete ( text ); } - text = NULL; + text = nullptr; } if ( label ) { count++; db->AddLabel ( label ); - label = NULL; + label = nullptr; if ( cb ) { cb (); @@ -605,7 +605,7 @@ int LoadMainDB(TransDB *db, const char *filename, void (*cb) (void) ) int GetLabelCountDB ( char *filename ) { - IFF_FILE *iff = NULL; + IFF_FILE *iff = nullptr; DBINFO dbinfo; int count = 0; diff --git a/Core/Tools/Babylon/loadsave.h b/Core/Tools/Babylon/loadsave.h index cde180af921..c69a3769904 100644 --- a/Core/Tools/Babylon/loadsave.h +++ b/Core/Tools/Babylon/loadsave.h @@ -23,5 +23,5 @@ #pragma once int WriteMainDB(TransDB *db, const char *filename, CBabylonDlg *dlg ); -int LoadMainDB(TransDB *db, const char *filename, void (*cb) (void ) = NULL ); +int LoadMainDB(TransDB *db, const char *filename, void (*cb) (void ) = nullptr ); int GetLabelCountDB ( char *filename ); diff --git a/Core/Tools/Babylon/olestring.cpp b/Core/Tools/Babylon/olestring.cpp index 1d5cd26a75c..762e063d775 100644 --- a/Core/Tools/Babylon/olestring.cpp +++ b/Core/Tools/Babylon/olestring.cpp @@ -62,8 +62,8 @@ template int IsFormatTypeChar ( text ch ) OLEString::OLEString ( void ) { - ole = NULL; - sb = NULL; + ole = nullptr; + sb = nullptr; len = 0; Unlock (); @@ -75,8 +75,8 @@ OLEString::~OLEString ( ) { delete [] ole; delete [] sb; - ole = NULL; - sb = NULL; + ole = nullptr; + sb = nullptr; len = 0; } @@ -88,8 +88,8 @@ void OLEString::Set ( OLECHAR *new_ole ) { delete [] ole; delete [] sb; - ole = NULL; - sb = NULL; + ole = nullptr; + sb = nullptr; len = wcslen ( new_ole ); { @@ -109,8 +109,8 @@ void OLEString::Set ( const char *new_sb ) { delete [] ole; delete [] sb; - ole = NULL; - sb = NULL; + ole = nullptr; + sb = nullptr; len = strlen ( new_sb ); @@ -207,7 +207,7 @@ void OLEString::FormatMetaString ( void ) Set ( string ); delete [] string; - string = NULL; + string = nullptr; } template void StripSpaces ( text *string ) diff --git a/Core/Tools/CMakeLists.txt b/Core/Tools/CMakeLists.txt index f2e820ad74b..0175ddaf1c7 100644 --- a/Core/Tools/CMakeLists.txt +++ b/Core/Tools/CMakeLists.txt @@ -3,6 +3,7 @@ # Build useful tool binaries. if(RTS_BUILD_CORE_TOOLS) add_subdirectory(DebugWindow) + add_subdirectory(ParticleEditor) endif() # Build less useful tool/test binaries. diff --git a/Core/Tools/CRCDiff/CMakeLists.txt b/Core/Tools/CRCDiff/CMakeLists.txt index 4a01798a8e0..323d2cc99a6 100644 --- a/Core/Tools/CRCDiff/CMakeLists.txt +++ b/Core/Tools/CRCDiff/CMakeLists.txt @@ -15,8 +15,7 @@ set_target_properties(core_crcdiff PROPERTIES OUTPUT_NAME crcdiff) target_sources(core_crcdiff PRIVATE ${CRCDIFF_SRC}) target_link_libraries(core_crcdiff PRIVATE - core_config - core_utility + corei_always stlport ) diff --git a/Core/Tools/CRCDiff/CRCDiff.cpp b/Core/Tools/CRCDiff/CRCDiff.cpp index 62d57e993cb..36ed86871e6 100644 --- a/Core/Tools/CRCDiff/CRCDiff.cpp +++ b/Core/Tools/CRCDiff/CRCDiff.cpp @@ -45,7 +45,7 @@ static bool getNextLine(FILE *fp, char *line, int& frame, int& index) { return false; char buf[LINESIZE]; - while (fgets(buf, LINESIZE-1, fp) != NULL) + while (fgets(buf, LINESIZE-1, fp) != nullptr) { int len = strlen(buf); if (buf[len-1] == '\n') @@ -70,7 +70,7 @@ static std::string readInFile(const char *fname) { std::string ret; char buf[LINESIZE]; - while (fgets(buf, LINESIZE-1, fp) != NULL) + while (fgets(buf, LINESIZE-1, fp) != nullptr) { ret.append(buf); } @@ -81,7 +81,7 @@ static std::string readInFile(const char *fname) { //============================================================================= -static FILE *ofp = NULL; +static FILE *ofp = nullptr; void dumpQueued(void); @@ -190,7 +190,7 @@ int main(int argc, char *argv[]) atexit(exitWait); const char *inFname[2]; const char *outFname = "out.html"; - FILE *ifp[2] = {NULL, NULL}; + FILE *ifp[2] = { nullptr, nullptr}; std::string header, footer; if (argc != 7) @@ -264,7 +264,7 @@ int main(int argc, char *argv[]) if (seenRight && seenLeft) { outputLine(lastFrame[0], lastIndex[0], linkNum++, - "leftOnly", lastLine[0], NULL, NULL); + "leftOnly", lastLine[0], nullptr, nullptr); ++numDiffs; } lastFrame[0] = -1; @@ -278,7 +278,7 @@ int main(int argc, char *argv[]) if (seenRight && seenLeft) { outputLine(lastFrame[1], lastIndex[1], linkNum++, - NULL, NULL, "rightOnly", lastLine[1]); + nullptr, nullptr, "rightOnly", lastLine[1]); ++numDiffs; } lastFrame[1] = -1; @@ -329,7 +329,7 @@ int main(int argc, char *argv[]) if (seenRight && seenLeft) { outputLine(lastFrame[0], lastIndex[0], linkNum++, - "leftOnly", lastLine[0], NULL, NULL); + "leftOnly", lastLine[0], nullptr, nullptr); ++numDiffs; } lastFrame[0] = -1; @@ -342,7 +342,7 @@ int main(int argc, char *argv[]) if (seenRight && seenLeft) { outputLine(lastFrame[1], lastIndex[1], linkNum++, - NULL, NULL, "rightOnly", lastLine[1]); + nullptr, nullptr, "rightOnly", lastLine[1]); ++numDiffs; } lastFrame[1] = -1; diff --git a/Core/Tools/Compress/CMakeLists.txt b/Core/Tools/Compress/CMakeLists.txt index e83dba331c5..4678993e8d3 100644 --- a/Core/Tools/Compress/CMakeLists.txt +++ b/Core/Tools/Compress/CMakeLists.txt @@ -8,7 +8,6 @@ set_target_properties(core_compress PROPERTIES OUTPUT_NAME compress) target_sources(core_compress PRIVATE ${COMRPESS_SRC}) target_link_libraries(core_compress PRIVATE - core_config core_compression corei_always ) diff --git a/Core/Tools/DebugWindow/CMakeLists.txt b/Core/Tools/DebugWindow/CMakeLists.txt index d6514ca8ada..e3ee28abcf2 100644 --- a/Core/Tools/DebugWindow/CMakeLists.txt +++ b/Core/Tools/DebugWindow/CMakeLists.txt @@ -13,7 +13,7 @@ add_library(core_debugwindow SHARED) target_sources(core_debugwindow PRIVATE ${DEBUGWINDOW_SRC}) target_link_libraries(core_debugwindow PRIVATE - core_config + corei_always_no_pch ) if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") diff --git a/Core/Tools/DebugWindow/DebugWindow.cpp b/Core/Tools/DebugWindow/DebugWindow.cpp index bc15074c03e..c01d0418c00 100644 --- a/Core/Tools/DebugWindow/DebugWindow.cpp +++ b/Core/Tools/DebugWindow/DebugWindow.cpp @@ -73,7 +73,7 @@ CDebugWindowApp::CDebugWindowApp() { AfxInitialize(true); AFX_MANAGE_STATE(AfxGetStaticModuleState( )); - m_DialogWindow = NULL; + m_DialogWindow = nullptr; } DebugWindowDialog* CDebugWindowApp::GetDialogWindow(void) @@ -103,7 +103,7 @@ void __declspec(dllexport) CreateDebugDialog(void) DebugWindowDialog* tmpWnd; tmpWnd = new DebugWindowDialog; tmpWnd->Create(DebugWindowDialog::IDD); - tmpWnd->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER); + tmpWnd->SetWindowPos(nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER); tmpWnd->ShowWindow(SW_SHOW); if (tmpWnd->GetMainWndHWND()) { SetFocus(tmpWnd->GetMainWndHWND()); @@ -120,7 +120,7 @@ void __declspec(dllexport) DestroyDebugDialog(void) if (tmpWnd) { tmpWnd->DestroyWindow(); delete tmpWnd; - theApp.SetDialogWindow(NULL); + theApp.SetDialogWindow(nullptr); } } diff --git a/Core/Tools/DebugWindow/DebugWindowDialog.cpp b/Core/Tools/DebugWindow/DebugWindowDialog.cpp index 202f6e87584..91667ad4ac8 100644 --- a/Core/Tools/DebugWindow/DebugWindowDialog.cpp +++ b/Core/Tools/DebugWindow/DebugWindowDialog.cpp @@ -25,7 +25,7 @@ DebugWindowDialog::DebugWindowDialog(UINT nIDTemplate, CWnd* pParentWnd) : mStepping = false; mRunFast = false; mNumberOfStepsAllowed = -1; - mMainWndHWND = ::FindWindow(NULL, "Command & Conquer: Generals"); + mMainWndHWND = ::FindWindow(nullptr, "Command & Conquer: Generals"); } int DebugWindowDialog::OnCreate(LPCREATESTRUCT lpCreateStruct) diff --git a/Core/Tools/DebugWindow/DebugWindowDialog.h b/Core/Tools/DebugWindow/DebugWindowDialog.h index 5fb09d0c01d..6e1751f9a72 100644 --- a/Core/Tools/DebugWindow/DebugWindowDialog.h +++ b/Core/Tools/DebugWindow/DebugWindowDialog.h @@ -34,7 +34,7 @@ class DebugWindowDialog : public CDialog { public: enum {IDD = IDD_DebugWindow}; - DebugWindowDialog(UINT nIDTemplate = DebugWindowDialog::IDD, CWnd* pParentWnd = NULL); + DebugWindowDialog(UINT nIDTemplate = DebugWindowDialog::IDD, CWnd* pParentWnd = nullptr); bool CanProceed(void); bool RunAppFast(void); diff --git a/Core/Tools/DebugWindow/StdAfx.h b/Core/Tools/DebugWindow/StdAfx.h index 93949ef8247..a867c9d598c 100644 --- a/Core/Tools/DebugWindow/StdAfx.h +++ b/Core/Tools/DebugWindow/StdAfx.h @@ -56,3 +56,5 @@ //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#include diff --git a/Core/Tools/ImagePacker/Include/ImageDirectory.h b/Core/Tools/ImagePacker/Include/ImageDirectory.h index d2b64c33efe..2cece795979 100644 --- a/Core/Tools/ImagePacker/Include/ImageDirectory.h +++ b/Core/Tools/ImagePacker/Include/ImageDirectory.h @@ -72,9 +72,9 @@ class ImageDirectory inline ImageDirectory::~ImageDirectory( void ) { delete m_path; } inline ImageDirectory::ImageDirectory( void ) { - m_path = NULL; - m_next = NULL; - m_prev = NULL; + m_path = nullptr; + m_next = nullptr; + m_prev = nullptr; m_imageCount = 0; } diff --git a/Core/Tools/ImagePacker/Include/TexturePage.h b/Core/Tools/ImagePacker/Include/TexturePage.h index ab0cd5142b5..cc5e9d781a7 100644 --- a/Core/Tools/ImagePacker/Include/TexturePage.h +++ b/Core/Tools/ImagePacker/Include/TexturePage.h @@ -97,7 +97,7 @@ class TexturePage Int getHeight( void ); ///< get height of texture page // get rgb from final generated texture (putting this in for quick preview) - void getPixel( Int x, Int y, Byte *r, Byte *g, Byte *b, Byte *a = NULL ); + void getPixel( Int x, Int y, Byte *r, Byte *g, Byte *b, Byte *a = nullptr ); TexturePage *m_next; TexturePage *m_prev; diff --git a/Core/Tools/ImagePacker/Source/ImageInfo.cpp b/Core/Tools/ImagePacker/Source/ImageInfo.cpp index 46d483ac0cc..4a71bfe10ca 100644 --- a/Core/Tools/ImagePacker/Source/ImageInfo.cpp +++ b/Core/Tools/ImagePacker/Source/ImageInfo.cpp @@ -70,14 +70,14 @@ ImageInfo::ImageInfo( void ) m_colorDepth = 0; m_size.x = 0; m_size.y = 0; - m_path = NULL; - m_filenameOnly = NULL; - m_filenameOnlyNoExt = NULL; + m_path = nullptr; + m_filenameOnly = nullptr; + m_filenameOnlyNoExt = nullptr; m_status = UNPACKED; - m_page = NULL; - m_nextPageImage = NULL; - m_prevPageImage = NULL; + m_page = nullptr; + m_nextPageImage = nullptr; + m_prevPageImage = nullptr; m_pagePos.lo.x = 0; m_pagePos.lo.y = 0; m_pagePos.hi.x = 0; diff --git a/Core/Tools/ImagePacker/Source/ImagePacker.cpp b/Core/Tools/ImagePacker/Source/ImagePacker.cpp index a113f4d7eab..fb180b69806 100644 --- a/Core/Tools/ImagePacker/Source/ImagePacker.cpp +++ b/Core/Tools/ImagePacker/Source/ImagePacker.cpp @@ -61,7 +61,7 @@ const char *gAppPrefix = "ip_"; // So IP can have a different debug log file nam /////////////////////////////////////////////////////////////////////////////// // PRIVATE DATA /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -ImagePacker *TheImagePacker = NULL; +ImagePacker *TheImagePacker = nullptr; // PUBLIC DATA //////////////////////////////////////////////////////////////// @@ -80,23 +80,23 @@ TexturePage *ImagePacker::createNewTexturePage( void ) // allocate new page page = new TexturePage( getTargetWidth(), getTargetHeight() ); - if( page == NULL ) + if( page == nullptr ) { DEBUG_ASSERTCRASH( page, ("Unable to allocate new texture page.") ); - return NULL; + return nullptr; } // link page to list - page->m_prev = NULL; + page->m_prev = nullptr; page->m_next = m_pageList; if( m_pageList ) m_pageList->m_prev = page; m_pageList = page; // add the tail pointer if this is the first page - if( m_pageTail == NULL ) + if( m_pageTail == nullptr ) m_pageTail = page; // we got a new page now @@ -134,10 +134,10 @@ Bool ImagePacker::validateImages( void ) image = m_imageList[ i ]; // sanity - if( image == NULL ) + if( image == nullptr ) { - DEBUG_ASSERTCRASH( image, ("Image in imagelist is NULL") ); + DEBUG_ASSERTCRASH( image, ("Image in imagelist is null") ); continue; // should never happen } @@ -179,7 +179,7 @@ Bool ImagePacker::validateImages( void ) proceed = DialogBox( ApplicationHInstance, (LPCTSTR)IMAGE_ERRORS, - TheImagePacker->getWindowHandle(), + getWindowHandle(), (DLGPROC)ImageErrorProc ); } @@ -195,8 +195,8 @@ Bool ImagePacker::validateImages( void ) Bool ImagePacker::packImages( void ) { UnsignedInt i; - TexturePage *page = NULL; - ImageInfo *image = NULL; + TexturePage *page = nullptr; + ImageInfo *image = nullptr; // // first sanity check all images loaded, if there are images that cannot @@ -238,11 +238,11 @@ Bool ImagePacker::packImages( void ) } // if image was not able to go on any existing page create a new page for it - if( page == NULL ) + if( page == nullptr ) { page = createNewTexturePage(); - if( page == NULL ) + if( page == nullptr ) return FALSE; // try to add the image to this page @@ -252,7 +252,7 @@ Bool ImagePacker::packImages( void ) sprintf( buffer, "Unable to add image '%s' to a brand new page!\n", image->m_path ); DEBUG_ASSERTCRASH( 0, (buffer) ); - MessageBox( NULL, buffer, "Internal Error", MB_OK | MB_ICONERROR ); + MessageBox( nullptr, buffer, "Internal Error", MB_OK | MB_ICONERROR ); return FALSE; } @@ -317,7 +317,7 @@ void ImagePacker::writeFinalTextures( void ) DialogBox( ApplicationHInstance, (LPCTSTR)PAGE_ERRORS, - TheImagePacker->getWindowHandle(), + getWindowHandle(), (DLGPROC)PageErrorProc ); } @@ -363,7 +363,7 @@ void ImagePacker::addImagesInDirectory( char *dir ) { // sanity - if( dir == NULL ) + if( dir == nullptr ) return; char currDir[ _MAX_PATH ]; @@ -461,7 +461,7 @@ Bool ImagePacker::checkOutputDirectory( void ) GetCurrentDirectory( _MAX_PATH, currDir ); // create the output directory if it does not exist - CreateDirectory( m_outputDirectory, NULL ); + CreateDirectory( m_outputDirectory, nullptr ); // change into the output directory SetCurrentDirectory( m_outputDirectory ); @@ -504,7 +504,7 @@ Bool ImagePacker::checkOutputDirectory( void ) sprintf( buffer, "The output directory (%s) must be empty before proceeding. Delete '%d' files and continue with build process?", m_outputDirectory, fileCount ); - response = MessageBox( NULL, buffer, + response = MessageBox( nullptr, buffer, "Delete files to continue?", MB_YESNO | MB_ICONWARNING ); @@ -572,7 +572,7 @@ void ImagePacker::resetPageList( void ) } - m_pageTail = NULL; + m_pageTail = nullptr; m_pageCount = 0; m_targetPreviewPage = 1; @@ -606,7 +606,7 @@ void ImagePacker::resetImageList( void ) { delete [] m_imageList; - m_imageList = NULL; + m_imageList = nullptr; m_imageCount = 0; } @@ -625,7 +625,7 @@ void ImagePacker::addDirectory( char *path, Bool subDirs ) HANDLE hFile; // handle for search resources // santiy - if( path == NULL ) + if( path == nullptr ) return; // check to see if path is already in list @@ -643,10 +643,10 @@ void ImagePacker::addDirectory( char *path, Bool subDirs ) // image is not in list, make a new entry and link to the list dir = new ImageDirectory; - if( dir == NULL ) + if( dir == nullptr ) { - MessageBox( NULL, "Unable to allocate image directory", "Error", + MessageBox( nullptr, "Unable to allocate image directory", "Error", MB_OK | MB_ICONERROR ); return; @@ -656,10 +656,10 @@ void ImagePacker::addDirectory( char *path, Bool subDirs ) Int len = strlen( path ); dir->m_path = new char[ len + 1 ]; strcpy( dir->m_path, path ); - if( dir->m_path == NULL ) + if( dir->m_path == nullptr ) { - MessageBox( NULL, "Unable to allocate path for directory", "Error", + MessageBox( nullptr, "Unable to allocate path for directory", "Error", MB_OK | MB_ICONERROR ); delete dir; return; @@ -667,7 +667,7 @@ void ImagePacker::addDirectory( char *path, Bool subDirs ) } // tie to list - dir->m_prev = NULL; + dir->m_prev = nullptr; dir->m_next = m_dirList; if( m_dirList ) m_dirList->m_prev = dir; @@ -788,15 +788,15 @@ void ImagePacker::addImage( char *path ) { // sanity - if( path == NULL ) + if( path == nullptr ) return; // allocate a new entry ImageInfo *info = new ImageInfo; - if( info == NULL ) + if( info == nullptr ) { - MessageBox( NULL, "Unable to allocate image info", "Error", + MessageBox( nullptr, "Unable to allocate image info", "Error", MB_OK | MB_ICONERROR ); return; @@ -806,10 +806,10 @@ void ImagePacker::addImage( char *path ) Int len = strlen( path ); info->m_path = new char[ len + 1 ]; strcpy( info->m_path, path ); - if( info->m_path == NULL ) + if( info->m_path == nullptr ) { - MessageBox( NULL, "Unable to allcoate image path info", "Error", + MessageBox( nullptr, "Unable to allocate image path info", "Error", MB_OK | MB_ICONERROR ); delete info; return; @@ -869,12 +869,12 @@ Bool ImagePacker::generateINIFile( void ) // open the file fp = fopen( filename, "w" ); - if( fp == NULL ) + if( fp == nullptr ) { char buffer[ _MAX_PATH + 64 ]; sprintf( buffer, "Cannot open INI file '%s' for writing.", filename ); - MessageBox( NULL, buffer, "Error Opening File", MB_OK | MB_ICONERROR ); + MessageBox( nullptr, buffer, "Error Opening File", MB_OK | MB_ICONERROR ); return FALSE; } @@ -948,7 +948,7 @@ Bool ImagePacker::getSettingsFromDialog( HWND dialog ) Int i; // sanity - if( dialog == NULL ) + if( dialog == nullptr ) return FALSE; // if we are using a user target image size, it must be a power of 2 @@ -957,7 +957,7 @@ Bool ImagePacker::getSettingsFromDialog( HWND dialog ) UnsignedInt size, val; Int bitCount = 0; - size = GetDlgItemInt( dialog, EDIT_WIDTH, NULL, FALSE ); + size = GetDlgItemInt( dialog, EDIT_WIDTH, nullptr, FALSE ); for( val = size; val; val >>= 1 ) if( BitIsSet( val, 0x1 ) ) bitCount++; @@ -969,7 +969,7 @@ Bool ImagePacker::getSettingsFromDialog( HWND dialog ) if( bitCount != 1 ) { - MessageBox( NULL, "The target image size must be a power of 2.", + MessageBox( nullptr, "The target image size must be a power of 2.", "Must Be Power Of 2", MB_OK | MB_ICONERROR ); return FALSE; @@ -988,7 +988,7 @@ Bool ImagePacker::getSettingsFromDialog( HWND dialog ) else { - MessageBox( NULL, "Internal Error. Target Size Unknown.", + MessageBox( nullptr, "Internal Error. Target Size Unknown.", "Error", MB_OK | MB_ICONERROR ); return FALSE; @@ -998,36 +998,36 @@ Bool ImagePacker::getSettingsFromDialog( HWND dialog ) Bool outputAlpha = FALSE; if( IsDlgButtonChecked( dialog, CHECK_ALPHA ) == BST_CHECKED ) outputAlpha = TRUE; - TheImagePacker->setOutputAlpha( outputAlpha ); + setOutputAlpha( outputAlpha ); // get create INI option Bool createINI = FALSE; if( IsDlgButtonChecked( dialog, CHECK_INI ) == BST_CHECKED ) createINI = TRUE; - TheImagePacker->setINICreate( createINI ); + setINICreate( createINI ); // get preview with image option Bool useBitmap = FALSE; if( IsDlgButtonChecked( dialog, CHECK_BITMAP_PREVIEW ) == BST_CHECKED ) useBitmap = TRUE; - TheImagePacker->setUseTexturePreview( useBitmap ); + setUseTexturePreview( useBitmap ); // get option to compress final textures Bool compress = FALSE; if( IsDlgButtonChecked( dialog, CHECK_COMPRESS ) == BST_CHECKED ) compress = TRUE; - TheImagePacker->setCompressTextures( compress ); + setCompressTextures( compress ); // get options for the gap options - TheImagePacker->clearGapMethod( ImagePacker::GAP_METHOD_EXTEND_RGB ); + clearGapMethod( ImagePacker::GAP_METHOD_EXTEND_RGB ); if( IsDlgButtonChecked( dialog, CHECK_GAP_EXTEND_RGB ) == BST_CHECKED ) - TheImagePacker->setGapMethod( ImagePacker::GAP_METHOD_EXTEND_RGB ); - TheImagePacker->clearGapMethod( ImagePacker::GAP_METHOD_GUTTER ); + setGapMethod( ImagePacker::GAP_METHOD_EXTEND_RGB ); + clearGapMethod( ImagePacker::GAP_METHOD_GUTTER ); if( IsDlgButtonChecked( dialog, CHECK_GAP_GUTTER ) == BST_CHECKED ) - TheImagePacker->setGapMethod( ImagePacker::GAP_METHOD_GUTTER ); + setGapMethod( ImagePacker::GAP_METHOD_GUTTER ); // get gutter size whether we are using that option or not - Int gutter = GetDlgItemInt( dialog, EDIT_GUTTER, NULL, FALSE ); + Int gutter = GetDlgItemInt( dialog, EDIT_GUTTER, nullptr, FALSE ); if( gutter < 0 ) gutter = 0; setGutter( gutter ); @@ -1051,7 +1051,7 @@ Bool ImagePacker::getSettingsFromDialog( HWND dialog ) sprintf( buffer, "Output filename '%s' contains one or more of the following illegal characters:\n\n%s", m_outputFile, illegal ); - MessageBox( NULL, buffer, "Illegal Filename", MB_OK | MB_ICONERROR ); + MessageBox( nullptr, buffer, "Illegal Filename", MB_OK | MB_ICONERROR ); return FALSE; } @@ -1095,20 +1095,20 @@ Bool ImagePacker::getSettingsFromDialog( HWND dialog ) ImagePacker::ImagePacker( void ) { - m_hWnd = NULL; + m_hWnd = nullptr; m_targetSize.x = DEFAULT_TARGET_SIZE; m_targetSize.y = DEFAULT_TARGET_SIZE; m_useSubFolders = TRUE; strcpy( m_outputFile, "" ); strcpy( m_outputDirectory, "" ); - m_dirList = NULL; + m_dirList = nullptr; m_dirCount = 0; m_imagesInDirs = 0; - m_imageList = NULL; + m_imageList = nullptr; m_imageCount = 0; strcpy( m_statusBuffer, "" ); - m_pageList = NULL; - m_pageTail = NULL; + m_pageList = nullptr; + m_pageTail = nullptr; m_pageCount = 0; m_gapMethod = GAP_METHOD_EXTEND_RGB; m_gutterSize = 1; @@ -1116,10 +1116,10 @@ ImagePacker::ImagePacker( void ) m_createINI = TRUE; m_targetPreviewPage = 1; - m_hWndPreview = NULL; + m_hWndPreview = nullptr; m_showTextureInPreview = FALSE; - m_targa = NULL; + m_targa = nullptr; m_compressTextures = FALSE; } @@ -1148,11 +1148,11 @@ Bool ImagePacker::init( void ) // allocate a targa to read the headers for the images m_targa = new Targa; - if( m_targa == NULL ) + if( m_targa == nullptr ) { DEBUG_ASSERTCRASH( m_targa, ("Unable to allocate targa header during init") ); - MessageBox( NULL, "ImagePacker can't init, unable to create targa", + MessageBox( nullptr, "ImagePacker can't init, unable to create targa", "Internal Error", MB_OK | MB_ICONERROR ); return FALSE; @@ -1182,7 +1182,7 @@ Bool ImagePacker::process( void ) char currDir[ _MAX_PATH ]; GetCurrentDirectory( _MAX_PATH, currDir ); sprintf( m_outputDirectory, "%s\\ImagePackerOutput\\", currDir ); - CreateDirectory( m_outputDirectory, NULL ); + CreateDirectory( m_outputDirectory, nullptr ); // subdir of output directory based on output image name strlcat(m_outputDirectory, m_outputFile, ARRAY_SIZE(m_outputDirectory)); diff --git a/Core/Tools/ImagePacker/Source/TexturePage.cpp b/Core/Tools/ImagePacker/Source/TexturePage.cpp index e463a558f4b..a2520e4c92f 100644 --- a/Core/Tools/ImagePacker/Source/TexturePage.cpp +++ b/Core/Tools/ImagePacker/Source/TexturePage.cpp @@ -79,10 +79,10 @@ void TexturePage::extendToRowIfOpen( char *src, { char otherAlpha; char otherColor[ 3 ]; - char *row = NULL; + char *row = nullptr; // sanity - if( src == NULL ) + if( src == nullptr ) return; // @@ -229,7 +229,7 @@ void TexturePage::extendImageEdges( Byte *destBuffer, { // sanity - if( destBuffer == NULL || image == NULL ) + if( destBuffer == nullptr || image == nullptr ) return; // @@ -426,7 +426,7 @@ void TexturePage::extendImageEdges( Byte *destBuffer, // if( currPixel == TRUE ) { - char *dst = NULL; + char *dst = nullptr; // top left corner if( x == 0 && y == 0 && @@ -514,7 +514,7 @@ Bool TexturePage::addImageData( Byte *destBuffer, { // sanity - if( destBuffer == NULL || image == NULL ) + if( destBuffer == nullptr || image == nullptr ) return FALSE; // load the real image data for the source @@ -525,7 +525,7 @@ Bool TexturePage::addImageData( Byte *destBuffer, sprintf( buffer, "Error loading source file '%s'\n", image->m_path ); DEBUG_ASSERTCRASH( 0, (buffer) ); - MessageBox( NULL, buffer, "Cannot Load Source File", MB_OK | MB_ICONERROR ); + MessageBox( nullptr, buffer, "Cannot Load Source File", MB_OK | MB_ICONERROR ); return FALSE; } @@ -761,7 +761,7 @@ UnsignedInt TexturePage::buildFitRegion( IRegion2D *region, { // sanity - if( region == NULL || xGutter == NULL || yGutter == NULL ) + if( region == nullptr || xGutter == nullptr || yGutter == nullptr ) return 0; // @@ -853,12 +853,12 @@ TexturePage::TexturePage( Int width, Int height ) Int canvasSize; m_id = -1; - m_next = NULL; - m_prev = NULL; + m_next = nullptr; + m_prev = nullptr; m_size.x = width; m_size.y = height; - m_packedImage = NULL; - m_targa = NULL; + m_packedImage = nullptr; + m_targa = nullptr; // create a "canvas" to represent used and unused areas canvasSize = m_size.x * m_size.y; @@ -892,11 +892,11 @@ Bool TexturePage::addImage( ImageInfo *image ) { IRegion2D region; - // santiy - if( image == NULL ) + // sanity + if( image == nullptr ) { - DEBUG_ASSERTCRASH( image, ("TexturePage::addImage: NULL image!") ); + DEBUG_ASSERTCRASH( image, ("TexturePage::addImage: null image!") ); return TRUE; // say it was added } @@ -1147,7 +1147,7 @@ Bool TexturePage::addImage( ImageInfo *image ) image->m_pagePos.hi.y -= yGutter; // link this image to the texture page - image->m_prevPageImage = NULL; + image->m_prevPageImage = nullptr; image->m_nextPageImage = m_imageList; if( m_imageList ) m_imageList->m_prevPageImage = image; @@ -1174,22 +1174,22 @@ Bool TexturePage::generateTexture( void ) { // sanity - if( m_imageList == NULL ) + if( m_imageList == nullptr ) return FALSE; // sanity - DEBUG_ASSERTCRASH( m_packedImage == NULL, ("The packed image list must be NULL before generating texture") ); - DEBUG_ASSERTCRASH( m_targa == NULL, ("The targa must be NULL before generating a new texture") ); + DEBUG_ASSERTCRASH( m_packedImage == nullptr, ("The packed image list must be null before generating texture") ); + DEBUG_ASSERTCRASH( m_targa == nullptr, ("The targa must be null before generating a new texture") ); // allocate targa to help us generate the final texture m_targa = new Targa; - if( m_targa == NULL ) + if( m_targa == nullptr ) { char buffer[ 128 ]; sprintf( buffer, "Unable to allocate new targa to generate texture\n" ); DEBUG_ASSERTCRASH( m_targa, (buffer) ); - MessageBox( NULL, buffer, "Internal Error", MB_OK | MB_ICONERROR ); + MessageBox( nullptr, buffer, "Internal Error", MB_OK | MB_ICONERROR ); return FALSE; } @@ -1212,13 +1212,13 @@ Bool TexturePage::generateTexture( void ) // allocate a buffer for our final image Int bufferSize = m_size.x * m_size.y * bpp; m_packedImage = new Byte[ bufferSize ]; - if( m_packedImage == NULL ) + if( m_packedImage == nullptr ) { char buffer[ 128 ]; sprintf( buffer, "Unable to allocate final packed image buffer\n" ); DEBUG_ASSERTCRASH( m_packedImage, (buffer) ); - MessageBox( NULL, buffer, "Internal Error", MB_OK | MB_ICONERROR ); + MessageBox( nullptr, buffer, "Internal Error", MB_OK | MB_ICONERROR ); BitSet( m_status, PAGE_ERROR ); BitSet( m_status, CANT_ALLOCATE_PACKED_IMAGE ); return FALSE; @@ -1267,7 +1267,7 @@ Bool TexturePage::writeFile( char *baseFilename ) { // sanity - if( baseFilename == NULL || m_targa == NULL ) + if( baseFilename == nullptr || m_targa == nullptr ) { BitSet( m_status, PAGE_ERROR ); @@ -1311,7 +1311,7 @@ void TexturePage::getPixel( Int x, Int y, Byte *r, Byte *g, Byte *b, Byte *a ) { // do nothing if we have no image data - if( m_packedImage == NULL ) + if( m_packedImage == nullptr ) return; // how many bytes per pixel for the targa file format diff --git a/Core/Tools/ImagePacker/Source/WinMain.cpp b/Core/Tools/ImagePacker/Source/WinMain.cpp index e31f28f4573..5abd36edb0e 100644 --- a/Core/Tools/ImagePacker/Source/WinMain.cpp +++ b/Core/Tools/ImagePacker/Source/WinMain.cpp @@ -58,10 +58,10 @@ /////////////////////////////////////////////////////////////////////////////// // PUBLIC DATA //////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -HINSTANCE ApplicationHInstance = NULL; ///< our application instance +HINSTANCE ApplicationHInstance = nullptr; ///< our application instance /// just to satisfy the game libraries we link to -HWND ApplicationHWnd = NULL; +HWND ApplicationHWnd = nullptr; const Char *g_strFile = "data\\Generals.str"; const Char *g_csfFile = "data\\%s\\Generals.csf"; @@ -92,7 +92,7 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, // allocate a new image packer system TheImagePacker = new ImagePacker; - if( TheImagePacker == NULL ) + if( TheImagePacker == nullptr ) return 0; // initialize the system @@ -100,18 +100,18 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, { delete TheImagePacker; - TheImagePacker = NULL; + TheImagePacker = nullptr; return 0; } // load the dialog box DialogBox( hInstance, (LPCTSTR)IMAGE_PACKER_DIALOG, - NULL, (DLGPROC)ImagePackerProc ); + nullptr, (DLGPROC)ImagePackerProc ); // delete the image packer delete TheImagePacker; - TheImagePacker = NULL; + TheImagePacker = nullptr; shutdownMemoryManager(); diff --git a/Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp b/Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp index 190f3fd8a3e..2d299b44d1e 100644 --- a/Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp +++ b/Core/Tools/ImagePacker/Source/WindowProcedures/DirectorySelect.cpp @@ -199,7 +199,7 @@ BOOL CALLBACK DirectorySelectProc( HWND hWndDialog, UINT message, char message[ _MAX_PATH + 32 ]; sprintf( message, "Ignoring folder '%s', already in list.", toAdd ); - MessageBox( NULL, message, "Folder Already In List", + MessageBox( nullptr, message, "Folder Already In List", MB_OK | MB_ICONINFORMATION ); continue; diff --git a/Core/Tools/ImagePacker/Source/WindowProcedures/ImageErrorProc.cpp b/Core/Tools/ImagePacker/Source/WindowProcedures/ImageErrorProc.cpp index 93b08ff2143..94cf829e6b5 100644 --- a/Core/Tools/ImagePacker/Source/WindowProcedures/ImageErrorProc.cpp +++ b/Core/Tools/ImagePacker/Source/WindowProcedures/ImageErrorProc.cpp @@ -83,7 +83,7 @@ BOOL CALLBACK ImageErrorProc( HWND hWndDialog, UINT message, // // sanity - if( TheImagePacker == NULL ) + if( TheImagePacker == nullptr ) return TRUE; // go through all images @@ -101,7 +101,7 @@ BOOL CALLBACK ImageErrorProc( HWND hWndDialog, UINT message, image = TheImagePacker->getImage( i ); // sanity - if( image == NULL ) + if( image == nullptr ) continue; // if image can't be processed find out why diff --git a/Core/Tools/ImagePacker/Source/WindowProcedures/ImagePackerProc.cpp b/Core/Tools/ImagePacker/Source/WindowProcedures/ImagePackerProc.cpp index 333f4e11c30..f0cbddc6242 100644 --- a/Core/Tools/ImagePacker/Source/WindowProcedures/ImagePackerProc.cpp +++ b/Core/Tools/ImagePacker/Source/WindowProcedures/ImagePackerProc.cpp @@ -78,10 +78,10 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, { // we must have our program interface to continue - if( TheImagePacker == NULL ) + if( TheImagePacker == nullptr ) { - MessageBox( NULL, "Internal Error, 'TheImagePacker' not initialized", + MessageBox( nullptr, "Internal Error, 'TheImagePacker' not initialized", "Internal Error", MB_OK ); EndDialog( hWndDialog, FALSE ); @@ -245,7 +245,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, // delete test display window DestroyWindow( preview ); - TheImagePacker->setPreviewWindow( NULL ); + TheImagePacker->setPreviewWindow( nullptr ); SetDlgItemText( hWndDialog, BUTTON_PREVIEW, "Open Preview" ); } @@ -288,7 +288,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, // get the directory listbox folderList = GetDlgItem( hWndDialog, LIST_FOLDERS ); - if( folderList == NULL ) + if( folderList == nullptr ) break; // get the selected item in the folder listbox @@ -297,7 +297,7 @@ BOOL CALLBACK ImagePackerProc( HWND hWndDialog, UINT message, if( selCount == 0 ) { - MessageBox( NULL, "You must first select a folder to remove it", + MessageBox( nullptr, "You must first select a folder to remove it", "Select Folder First", MB_OK | MB_ICONINFORMATION ); break; diff --git a/Core/Tools/ImagePacker/Source/WindowProcedures/PageErrorProc.cpp b/Core/Tools/ImagePacker/Source/WindowProcedures/PageErrorProc.cpp index e96cd278ec9..b8301d23773 100644 --- a/Core/Tools/ImagePacker/Source/WindowProcedures/PageErrorProc.cpp +++ b/Core/Tools/ImagePacker/Source/WindowProcedures/PageErrorProc.cpp @@ -83,7 +83,7 @@ BOOL CALLBACK PageErrorProc( HWND hWndDialog, UINT message, // // sanity - if( TheImagePacker == NULL ) + if( TheImagePacker == nullptr ) return TRUE; // go through all pages diff --git a/Core/Tools/ImagePacker/Source/WindowProcedures/PreviewProc.cpp b/Core/Tools/ImagePacker/Source/WindowProcedures/PreviewProc.cpp index 24729b0f5e5..bd53e08d181 100644 --- a/Core/Tools/ImagePacker/Source/WindowProcedures/PreviewProc.cpp +++ b/Core/Tools/ImagePacker/Source/WindowProcedures/PreviewProc.cpp @@ -118,7 +118,7 @@ LRESULT CALLBACK PreviewProc( HWND hWnd, UINT message, prevPen = (HPEN)SelectObject( hdc, pen ); // draw ... what is the Win32 put pixel function??? - MoveToEx( hdc, x, y, NULL ); + MoveToEx( hdc, x, y, nullptr ); LineTo( hdc, x + 1, y ); // put the old pen back @@ -182,12 +182,12 @@ HWND MakePreviewDisplay( void ) wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = ApplicationHInstance; - wcex.hIcon = NULL; - wcex.hCursor = LoadCursor( NULL, IDC_ARROW ); + wcex.hIcon = nullptr; + wcex.hCursor = LoadCursor( nullptr, IDC_ARROW ); wcex.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH ); - wcex.lpszMenuName = NULL; + wcex.lpszMenuName = nullptr; wcex.lpszClassName = className; - wcex.hIconSm = NULL; + wcex.hIconSm = nullptr; RegisterClassEx( &wcex ); @@ -200,13 +200,13 @@ HWND MakePreviewDisplay( void ) 30, // y position TheImagePacker->getTargetWidth(), TheImagePacker->getTargetHeight(), - NULL, // parent - NULL, // menu + nullptr, // parent + nullptr, // menu ApplicationHInstance, // instance - NULL ); // creation data + nullptr ); // creation data - if( hWnd == NULL ) - return NULL; + if( hWnd == nullptr ) + return nullptr; // display the window ShowWindow( hWnd, SW_SHOW ); @@ -223,14 +223,14 @@ void UpdatePreviewWindow( void ) HWND preview; // sanity - if( TheImagePacker == NULL ) + if( TheImagePacker == nullptr ) return; // get preview window preview = TheImagePacker->getPreviewWindow(); // if window not here don't bother - if( preview == NULL ) + if( preview == nullptr ) return; // make the title @@ -262,6 +262,6 @@ void UpdatePreviewWindow( void ) TRUE ); // invalidate the client area for redraw - InvalidateRect( preview, NULL, TRUE ); + InvalidateRect( preview, nullptr, TRUE ); } diff --git a/Core/Tools/Launcher/BFISH.cpp b/Core/Tools/Launcher/BFISH.cpp index a1cea422770..2137ece9146 100644 --- a/Core/Tools/Launcher/BFISH.cpp +++ b/Core/Tools/Launcher/BFISH.cpp @@ -81,7 +81,7 @@ typedef union { BlowfishEngine::~BlowfishEngine(void) { if (IsKeyed) { - Submit_Key(NULL, 0); + Submit_Key(nullptr, 0); } } @@ -95,7 +95,7 @@ BlowfishEngine::~BlowfishEngine(void) * indefinitely. The key must be 56 bytes or less in length. This is necessary because * * any keys longer than that will not correctly affect the encryption process. * * * - * If the key pointer is NULL, then the S-Box tables are reset to identity. This will * + * If the key pointer is null, then the S-Box tables are reset to identity. This will * * mask the previous key setting. Use this method to clear the engine after processing in * * order to gain a measure of security. * * * diff --git a/Core/Tools/Launcher/CMakeLists.txt b/Core/Tools/Launcher/CMakeLists.txt index 09b938a60ea..34966a27bd5 100644 --- a/Core/Tools/Launcher/CMakeLists.txt +++ b/Core/Tools/Launcher/CMakeLists.txt @@ -62,8 +62,6 @@ target_compile_definitions(corei_launcher INTERFACE target_link_libraries(corei_launcher INTERFACE comctl32 - core_config - core_utility ) if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") diff --git a/Core/Tools/Launcher/DatGen/CMakeLists.txt b/Core/Tools/Launcher/DatGen/CMakeLists.txt index 4d38fbcfaf5..3816b6b4147 100644 --- a/Core/Tools/Launcher/DatGen/CMakeLists.txt +++ b/Core/Tools/Launcher/DatGen/CMakeLists.txt @@ -14,7 +14,6 @@ target_include_directories(corei_datgen INTERFACE ) target_link_libraries(corei_datgen INTERFACE - core_config ) target_sources(corei_datgen INTERFACE ${DATGEN_SRC}) diff --git a/Core/Tools/Launcher/DatGen/DatGen.cpp b/Core/Tools/Launcher/DatGen/DatGen.cpp index f584e9468cc..8745d77a805 100644 --- a/Core/Tools/Launcher/DatGen/DatGen.cpp +++ b/Core/Tools/Launcher/DatGen/DatGen.cpp @@ -61,7 +61,7 @@ static void doIt(void) // Retrieve install path DWORD type; DWORD sizeOfBuffer = sizeof(installPath); - result = RegQueryValueEx(hKey, "InstallPath", NULL, &type, installPath, &sizeOfBuffer); + result = RegQueryValueEx(hKey, "InstallPath", nullptr, &type, installPath, &sizeOfBuffer); assert((result == ERROR_SUCCESS) && "Failed to obtain game install path!"); assert((strlen((const char*)installPath) > 0) && "Game install path invalid!"); @@ -69,14 +69,14 @@ static void doIt(void) // Retrieve Hard drive S/N char drive[8]; - _splitpath((const char*)installPath, drive, NULL, NULL, NULL); + _splitpath((const char*)installPath, drive, nullptr, nullptr, nullptr); strcat(drive, "\\"); DWORD volumeSerialNumber = 0; DWORD maxComponentLength; DWORD fileSystemFlags; - BOOL volInfoSuccess = GetVolumeInformation((const char*)drive, NULL, 0, - &volumeSerialNumber, &maxComponentLength, &fileSystemFlags, NULL, 0); + BOOL volInfoSuccess = GetVolumeInformation((const char*)drive, nullptr, 0, + &volumeSerialNumber, &maxComponentLength, &fileSystemFlags, nullptr, 0); if (volInfoSuccess == FALSE) { @@ -113,7 +113,7 @@ static void doIt(void) if (result == ERROR_SUCCESS) { - result = RegQueryValueEx(hKey, "", NULL, &type, gameSerialNumber, &sizeOfBuffer); + result = RegQueryValueEx(hKey, "", nullptr, &type, gameSerialNumber, &sizeOfBuffer); assert((result == ERROR_SUCCESS) && "Failed to obtain game serial number!"); assert((strlen((const char*)gameSerialNumber) > 0) && "Game serial number invalid!"); } @@ -137,7 +137,7 @@ static void doIt(void) DWORD type; DWORD sizeOfBuffer = sizeof(winProductID); - result = RegQueryValueEx(hKey, "ProductID", NULL, &type, winProductID, &sizeOfBuffer); + result = RegQueryValueEx(hKey, "ProductID", nullptr, &type, winProductID, &sizeOfBuffer); assert((result == ERROR_SUCCESS) && "Failed to obtain windows product ID!"); assert((strlen((const char*)winProductID) > 0) && "Invalid windows product ID"); diff --git a/Core/Tools/Launcher/Toolkit/Debug/DebugPrint.cpp b/Core/Tools/Launcher/Toolkit/Debug/DebugPrint.cpp index ac0c17cd674..95b8562077f 100644 --- a/Core/Tools/Launcher/Toolkit/Debug/DebugPrint.cpp +++ b/Core/Tools/Launcher/Toolkit/Debug/DebugPrint.cpp @@ -50,7 +50,7 @@ char debugLogName[_MAX_PATH]; * DebugPrint(String, ArgList...) * * DESCRIPTION -* Ouput debug print messages to the debugger and log file. +* Output debug print messages to the debugger and log file. * * INPUTS * String - String to output. @@ -66,7 +66,7 @@ void __cdecl DebugPrint(const char* string, ...) static char _buffer[1024]; static char _filename[512] = ""; - if (string != NULL) + if (string != nullptr) { // Format string va_list va; @@ -83,21 +83,21 @@ void __cdecl DebugPrint(const char* string, ...) char drive[_MAX_DRIVE]; char dir[_MAX_DIR]; - GetModuleFileName(GetModuleHandle(NULL), &path[0], sizeof(path)); - _splitpath(path, drive, dir, NULL, NULL); + GetModuleFileName(GetModuleHandle(nullptr), &path[0], sizeof(path)); + _splitpath(path, drive, dir, nullptr, nullptr); _makepath(_filename, drive, dir, debugLogName, "txt"); OutputDebugString("Creating "); OutputDebugString(_filename); OutputDebugString("\n"); - file = CreateFile(_filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile(_filename, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, nullptr); } else { - file = CreateFile(_filename, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, - FILE_ATTRIBUTE_NORMAL, NULL); + file = CreateFile(_filename, GENERIC_WRITE, 0, nullptr, OPEN_ALWAYS, + FILE_ATTRIBUTE_NORMAL, nullptr); } // Send string to debugger @@ -131,10 +131,10 @@ void __cdecl DebugPrint(const char* string, ...) if (file != INVALID_HANDLE_VALUE) { - SetFilePointer(file, 0, NULL, FILE_END); + SetFilePointer(file, 0, nullptr, FILE_END); DWORD written; - WriteFile(file, &_buffer[0], strlen(_buffer), &written, NULL); + WriteFile(file, &_buffer[0], strlen(_buffer), &written, nullptr); CloseHandle(file); } @@ -162,7 +162,7 @@ void __cdecl PrintWin32Error(const char* string, ...) { static char _buffer[1024]; - if (string != NULL) + if (string != nullptr) { // Format string va_list va; @@ -172,8 +172,8 @@ void __cdecl PrintWin32Error(const char* string, ...) LPVOID lpMsgBuf; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, NULL); + FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, GetLastError(), + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0, nullptr); DebugPrint("***** Win32 Error: %s\n", _buffer); DebugPrint(" Reason: %s\n", (char*)lpMsgBuf); diff --git a/Core/Tools/Launcher/Toolkit/Debug/DebugPrint.h b/Core/Tools/Launcher/Toolkit/Debug/DebugPrint.h index 976219ce744..26e2d6c40f3 100644 --- a/Core/Tools/Launcher/Toolkit/Debug/DebugPrint.h +++ b/Core/Tools/Launcher/Toolkit/Debug/DebugPrint.h @@ -43,7 +43,7 @@ extern "C" { #endif -//! Ouput debug print messages to the debugger and log file. +//! Output debug print messages to the debugger and log file. void __cdecl DebugPrint(const char* string, ...); void __cdecl PrintWin32Error(const char* string, ...); diff --git a/Core/Tools/Launcher/Toolkit/Storage/File.cpp b/Core/Tools/Launcher/Toolkit/Storage/File.cpp index cc497bcc355..7b14540be72 100644 --- a/Core/Tools/Launcher/Toolkit/Storage/File.cpp +++ b/Core/Tools/Launcher/Toolkit/Storage/File.cpp @@ -272,7 +272,7 @@ bool File::IsAvailable(bool force) // Attempt to open the file mHandle = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); // If the open failed then the file is not available. if (mHandle == INVALID_HANDLE) @@ -351,19 +351,18 @@ File::EFileError File::Open(ERights rights) // Read only access case Rights_ReadOnly: mHandle = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); break; // Write only access case Rights_WriteOnly: - mHandle = CreateFile(name, GENERIC_WRITE, 0, - NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + mHandle = CreateFile(name, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); break; // Read and Write access case Rights_ReadWrite: mHandle = CreateFile(name, GENERIC_READ | GENERIC_WRITE, 0, - NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); break; // Unknown rights access violation @@ -549,7 +548,7 @@ File::EFileError File::Delete(void) File::EFileError File::Load(void*& outBuffer, UInt32& outSize) { - outBuffer = NULL; + outBuffer = nullptr; outSize = 0; // Enforce access control @@ -578,7 +577,7 @@ File::EFileError File::Load(void*& outBuffer, UInt32& outSize) } // Get the size of the file - UInt32 size = GetFileSize(mHandle, NULL); + UInt32 size = GetFileSize(mHandle, nullptr); if (size == 0xFFFFFFFF) { @@ -593,8 +592,8 @@ File::EFileError File::Load(void*& outBuffer, UInt32& outSize) outBuffer = malloc(size); outSize = size; - // If allocation succeded then load file data. - if (outBuffer != NULL) + // If allocation succeeded then load file data. + if (outBuffer != nullptr) { // Fill the buffer with the file contents while (size > 0) @@ -602,7 +601,7 @@ File::EFileError File::Load(void*& outBuffer, UInt32& outSize) unsigned long bytesRead = 0; // Read in some bytes. - if (ReadFile(mHandle, outBuffer, size, &bytesRead, NULL) == 0) + if (ReadFile(mHandle, outBuffer, size, &bytesRead, nullptr) == 0) { result = FileError_Read; @@ -686,7 +685,7 @@ File::EFileError File::Save(const void* buffer, UInt32 size) // Write the data to the file. unsigned long bytesWritten = 0; - if (WriteFile(mHandle, buffer, size, &bytesWritten, NULL) == 0) + if (WriteFile(mHandle, buffer, size, &bytesWritten, nullptr) == 0) { result = FileError_Write; OnFileError(result, false); @@ -780,7 +779,7 @@ UInt32 File::GetLength(void) openedHere = true; } - UInt32 length = GetFileSize(mHandle, NULL); + UInt32 length = GetFileSize(mHandle, nullptr); if (length == 0xFFFFFFFF) { @@ -816,15 +815,15 @@ UInt32 File::GetLength(void) void File::SetLength(UInt32 length) { // Get the current file position - UInt32 position = SetFilePointer(mHandle, 0, NULL, FILE_CURRENT); + UInt32 position = SetFilePointer(mHandle, 0, nullptr, FILE_CURRENT); // Extend the file size by positioning the Win32 file pointer to the // specified location then setting the end of file. - SetFilePointer(mHandle, length, NULL, FILE_BEGIN); + SetFilePointer(mHandle, length, nullptr, FILE_BEGIN); SetEndOfFile(mHandle); // Restore file position - SetFilePointer(mHandle, position, NULL, FILE_BEGIN); + SetFilePointer(mHandle, position, nullptr, FILE_BEGIN); } @@ -846,7 +845,7 @@ void File::SetLength(UInt32 length) UInt32 File::GetMarker(void) { - return SetFilePointer(mHandle, 0, NULL, FILE_CURRENT); + return SetFilePointer(mHandle, 0, nullptr, FILE_CURRENT); } @@ -894,7 +893,7 @@ void File::SetMarker(Int32 offset, EStreamFrom from) break; } - offset = SetFilePointer(mHandle, offset, NULL, dir); + offset = SetFilePointer(mHandle, offset, nullptr, dir); if (offset == 0xFFFFFFFF) { @@ -946,7 +945,7 @@ bool File::AtEnd(void) UInt32 File::GetBytes(void* ptr, UInt32 bytes) { // Parameter check; Null pointers are bad! - assert(ptr != NULL); + assert(ptr != nullptr); // Enforce rights control if (GetRights() == Rights_WriteOnly) @@ -972,7 +971,7 @@ UInt32 File::GetBytes(void* ptr, UInt32 bytes) { unsigned long read; - if (ReadFile(mHandle, ptr, bytesToRead, &read, NULL) == 0) + if (ReadFile(mHandle, ptr, bytesToRead, &read, nullptr) == 0) { if (OnFileError(FileError_Read, true) == false) { @@ -1015,7 +1014,7 @@ UInt32 File::GetBytes(void* ptr, UInt32 bytes) UInt32 File::PutBytes(const void* ptr, UInt32 bytes) { // Parameter check; Null pointers are bad! - assert(ptr != NULL); + assert(ptr != nullptr); // Enforce access control if (GetRights() == Rights_ReadOnly) @@ -1041,7 +1040,7 @@ UInt32 File::PutBytes(const void* ptr, UInt32 bytes) { unsigned long written; - if (WriteFile(mHandle, ptr, bytes, &written, NULL) == 0) + if (WriteFile(mHandle, ptr, bytes, &written, nullptr) == 0) { if (OnFileError(FileError_Write, true) == false) { @@ -1070,14 +1069,14 @@ UInt32 File::PutBytes(const void* ptr, UInt32 bytes) * Bytes - Number of bytes to retrieve * * RESULT -* Actual number of bytes transfered +* Actual number of bytes transferred * ******************************************************************************/ UInt32 File::PeekBytes(void* ptr, UInt32 bytes) { - // Parameter check; NULL pointers are bad! - assert(ptr != NULL); + // Parameter check; nullptr pointers are bad! + assert(ptr != nullptr); // Get current position UInt32 pos = GetMarker(); diff --git a/Core/Tools/Launcher/Toolkit/Support/RefPtr.h b/Core/Tools/Launcher/Toolkit/Support/RefPtr.h index 0e4e5c255d5..cfd0ba4aadf 100644 --- a/Core/Tools/Launcher/Toolkit/Support/RefPtr.h +++ b/Core/Tools/Launcher/Toolkit/Support/RefPtr.h @@ -34,9 +34,9 @@ * Reinterpret_Cast replaces reinterpret_cast and reinterpret_cast * Const_Cast replaces const_cast and const_cast * -* IsValid() replaces (x != NULL) +* IsValid() replaces (x != nullptr) * -* Member function Attach() or assigning RefPtr() will NULL a pointer. +* Member function Attach() or assigning RefPtr() will nullptr a pointer. * * Generally, RefPtr<> and RefPtrConst<> behave like their raw pointer * counterparts, except of course they are reference counted and will delete @@ -85,26 +85,26 @@ class RefPtrBase {return !operator==(rhs);} inline bool IsValid(void) const - {return (mRefObject != NULL);} + {return (mRefObject != nullptr);} inline void Detach(void) { if (IsValid()) { mRefObject->Release(); - mRefObject = NULL; + mRefObject = nullptr; } } protected: RefPtrBase() - : mRefObject(NULL) + : mRefObject(nullptr) {} RefPtrBase(RefCounted* object) : mRefObject(object) { - assert((mRefObject == NULL) || (mRefObject->mRefCount == 0)); + assert((mRefObject == nullptr) || (mRefObject->mRefCount == 0)); if (IsValid()) { @@ -140,7 +140,7 @@ class RefPtrBase if (object != mRefObject) { // Add reference to new object - if (object != NULL) + if (object != nullptr) { object->AddReference(); } diff --git a/Core/Tools/Launcher/Toolkit/Support/StringConvert.cpp b/Core/Tools/Launcher/Toolkit/Support/StringConvert.cpp index fecee38b55f..387dfadbb8e 100644 --- a/Core/Tools/Launcher/Toolkit/Support/StringConvert.cpp +++ b/Core/Tools/Launcher/Toolkit/Support/StringConvert.cpp @@ -84,16 +84,15 @@ Char* UStringToANSI(const UString& string, Char* buffer, UInt bufferLength) Char* UnicodeToANSI(const WChar* string, Char* buffer, UInt bufferLength) { - if ((string == NULL) || (buffer == NULL)) + if ((string == nullptr) || (buffer == nullptr)) { - return NULL; + return nullptr; } #ifdef RTS_DEBUG int result = #endif - WideCharToMultiByte(CP_ACP, 0, string, -1, buffer, bufferLength, - NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, string, -1, buffer, bufferLength, nullptr, nullptr); #ifdef RTS_DEBUG if (result == 0) diff --git a/Core/Tools/Launcher/Toolkit/Support/UString.cpp b/Core/Tools/Launcher/Toolkit/Support/UString.cpp index 12ccb8237f3..01a070850fc 100644 --- a/Core/Tools/Launcher/Toolkit/Support/UString.cpp +++ b/Core/Tools/Launcher/Toolkit/Support/UString.cpp @@ -67,7 +67,7 @@ template T CharToUpper(const T ch) // Check if character is one of the specified characters templatebool IsCharacter(WChar ch, const T* oneOf) { - assert(oneOf != NULL); + assert(oneOf != nullptr); int length = 0; @@ -146,7 +146,7 @@ template bool StripRight(WChar* string, const T* trimChars) ******************************************************************************/ UString::UString() - : mData(NULL), + : mData(nullptr), mCapacity(0) { } @@ -169,7 +169,7 @@ UString::UString() ******************************************************************************/ UString::UString(UInt capacity) - : mData(NULL), + : mData(nullptr), mCapacity(0) { AllocString(capacity); @@ -185,7 +185,7 @@ UString::UString(UInt capacity) * Create a new UString from an ANSI string literal * * INPUTS -* String - Pointer to a NULL terminated ANSI string +* String - Pointer to a null-terminated ANSI string * * RESULT * NONE @@ -193,7 +193,7 @@ UString::UString(UInt capacity) ******************************************************************************/ UString::UString(const Char* s) - : mData(NULL), + : mData(nullptr), mCapacity(0) { Copy(s); @@ -209,7 +209,7 @@ UString::UString(const Char* s) * Create a new UString from a UNICODE string literal * * INPUTS -* String - Pointer to a NULL terminated UNICODE string +* String - Pointer to a null-terminated UNICODE string * * RESULT * NONE @@ -217,7 +217,7 @@ UString::UString(const Char* s) ******************************************************************************/ UString::UString(const WChar* ws) - : mData(NULL), + : mData(nullptr), mCapacity(0) { Copy(ws); @@ -241,7 +241,7 @@ UString::UString(const WChar* ws) ******************************************************************************/ UString::UString(const UString& s) - : mData(NULL), + : mData(nullptr), mCapacity(0) { Copy(s); @@ -288,7 +288,7 @@ UString::~UString() UInt UString::Length(void) const { - if (mData == NULL) + if (mData == nullptr) { return 0; } @@ -315,7 +315,7 @@ UInt UString::Length(void) const void UString::Copy(const Char* s) { - assert(s != NULL); + assert(s != nullptr); UInt length = strlen(s); if (length == 0) @@ -360,7 +360,7 @@ void UString::Copy(const Char* s) void UString::Copy(const WChar* ws) { - assert(ws != NULL); + assert(ws != nullptr); UInt length = wcslen(ws); if (length == 0) @@ -419,7 +419,7 @@ void UString::Copy(const UString& s) void UString::Concat(const Char* s) { // Parameter check - assert(s != NULL); + assert(s != nullptr); UInt length = Length(); UInt additional = strlen(s); @@ -462,7 +462,7 @@ void UString::Concat(const Char* s) void UString::Concat(const WChar* ws) { - assert(ws != NULL); + assert(ws != nullptr); UInt length = (Length() + wcslen(ws)); if (Capacity() < length) @@ -516,11 +516,11 @@ void UString::Concat(const UString& s) Int UString::Compare(const Char* s) const { - // If comparing string is NULL and this string is NULL then strings are equal, + // If comparing string is nullptr and this string is nullptr then strings are equal, // otherwise comparing string is less than this string. - if (s == NULL) + if (s == nullptr) { - if (Get() == NULL) + if (Get() == nullptr) { return 0; } @@ -528,8 +528,8 @@ Int UString::Compare(const Char* s) const return -1; } - // If this string is NULL then comparing string is greater - if (Get() == NULL) + // If this string is nullptr then comparing string is greater + if (Get() == nullptr) { return 1; } @@ -632,11 +632,11 @@ Int UString::Compare(const UString& s) const Int UString::CompareNoCase(const Char* s) const { - // If comparing string is NULL and this string is NULL then strings are + // If comparing string is nullptr and this string is nullptr then strings are // equal, otherwise comparing string is less than this string. - if (s == NULL) + if (s == nullptr) { - if (Get() == NULL) + if (Get() == nullptr) { return 0; } @@ -644,8 +644,8 @@ Int UString::CompareNoCase(const Char* s) const return -1; } - // If this string is NULL then comparing string is greater. - if (Get() == NULL) + // If this string is nullptr then comparing string is greater. + if (Get() == nullptr) { return 1; } @@ -739,7 +739,7 @@ Int UString::CompareNoCase(const UString& s) const * UString::Find - ANSI character * * DESCRIPTION -* Find the first occurance of character +* Find the first occurrence of character * * INPUTS * Char - ANSI character to search for @@ -761,7 +761,7 @@ Int UString::Find(Char c) const * UString::Find - Unicode character * * DESCRIPTION -* Find the first occurance of character +* Find the first occurrence of character * * INPUTS * Char - Unicode character to search for. @@ -776,7 +776,7 @@ Int UString::Find(WChar c) const const WChar* ptr = wcschr(Get(), c); // Not found? - if (ptr == NULL) + if (ptr == nullptr) { return -1; } @@ -791,7 +791,7 @@ Int UString::Find(WChar c) const * UString::FindLast - ANSI character * * DESCRIPTION -* Find the last occurance of a character +* Find the last occurrence of a character * * INPUTS * Char - ANSI character @@ -813,7 +813,7 @@ Int UString::FindLast(Char c) const * UString::FindLast - Unicode character * * DESCRIPTION -* Find the last occurance of a character +* Find the last occurrence of a character * * INPUTS * Char - Unicode character @@ -825,11 +825,11 @@ Int UString::FindLast(Char c) const Int UString::FindLast(WChar c) const { - assert(mData != NULL); + assert(mData != nullptr); WChar* ptr = wcsrchr(mData, (WChar)c); // Not found? - if (ptr == NULL) + if (ptr == nullptr) { return -1; } @@ -857,7 +857,7 @@ Int UString::FindLast(WChar c) const UString UString::SubString(const Char* s) { assert(false); - assert(s != NULL); + assert(s != nullptr); return UString(""); } @@ -865,7 +865,7 @@ UString UString::SubString(const Char* s) UString UString::SubString(const WChar* ws) { assert(false); - assert(ws != NULL); + assert(ws != nullptr); return UString(""); } @@ -990,7 +990,7 @@ UString UString::Right(UInt count) void UString::ToUpper(void) { - if (mData != NULL) + if (mData != nullptr) { wcsupr(mData); } @@ -1015,7 +1015,7 @@ void UString::ToUpper(void) void UString::ToLower(void) { - if (mData != NULL) + if (mData != nullptr) { wcslwr(mData); } @@ -1040,7 +1040,7 @@ void UString::ToLower(void) void UString::Reverse(void) { - if (mData != NULL) + if (mData != nullptr) { wcsrev(mData); } @@ -1105,7 +1105,7 @@ bool UString::Trim(const UString& trimChars) bool UString::TrimLeft(const Char* trimChars) { - if ((trimChars == NULL) || (strlen(trimChars) == 0)) + if ((trimChars == nullptr) || (strlen(trimChars) == 0)) { return false; } @@ -1116,7 +1116,7 @@ bool UString::TrimLeft(const Char* trimChars) bool UString::TrimLeft(const WChar* trimChars) { - if ((trimChars == NULL) || (wcslen(trimChars) == 0)) + if ((trimChars == nullptr) || (wcslen(trimChars) == 0)) { return false; } @@ -1149,7 +1149,7 @@ bool UString::TrimLeft(const UString& trimChars) bool UString::TrimRight(const Char* trimChars) { - if ((trimChars == NULL) || (strlen(trimChars) == 0)) + if ((trimChars == nullptr) || (strlen(trimChars) == 0)) { return false; } @@ -1160,7 +1160,7 @@ bool UString::TrimRight(const Char* trimChars) bool UString::TrimRight(const WChar* trimChars) { - if ((trimChars == NULL) || (wcslen(trimChars) == 0)) + if ((trimChars == nullptr) || (wcslen(trimChars) == 0)) { return false; } @@ -1216,7 +1216,7 @@ void UString::ConvertToANSI(Char* buffer, UInt bufferLength) const UInt UString::Size(void) const { - if (mData == NULL) + if (mData == nullptr) { return 0; } @@ -1268,15 +1268,15 @@ bool UString::Resize(UInt size) // Allocate new storage assert(size > 0); WChar* data = new WChar[size + 1]; - assert(data != NULL); + assert(data != nullptr); - if (data == NULL) + if (data == nullptr) { return false; } // Copy existing string into new storage buffer - if (mData != NULL) + if (mData != nullptr) { UInt minSize = __min(Capacity(), size); wcsncpy(data, mData, minSize); @@ -1311,9 +1311,9 @@ bool UString::Resize(UInt size) bool UString::AllocString(UInt size) { WChar* data = new WChar[size + 1]; - assert(data != NULL); + assert(data != nullptr); - if (data == NULL) + if (data == nullptr) { return false; } diff --git a/Core/Tools/Launcher/Toolkit/Support/UString.h b/Core/Tools/Launcher/Toolkit/Support/UString.h index a9b23e20f87..85463994969 100644 --- a/Core/Tools/Launcher/Toolkit/Support/UString.h +++ b/Core/Tools/Launcher/Toolkit/Support/UString.h @@ -74,11 +74,11 @@ class UString Int CompareNoCase(const WChar* ws) const; Int CompareNoCase(const UString& s) const; - //! Find the first occurance of character + //! Find the first occurrence of character Int Find(Char c) const; Int Find(WChar wc) const; - //! Find the last occurance of a character + //! Find the last occurrence of a character Int FindLast(Char c) const; Int FindLast(WChar c) const; @@ -136,7 +136,7 @@ class UString bool Resize(UInt size); const WChar* Get(void) const - {return (mData != NULL) ? mData : L"";} + {return (mData != nullptr) ? mData : L"";} //! Assignment operator UString operator=(const Char* s) diff --git a/Core/Tools/Launcher/Toolkit/Support/UTypes.h b/Core/Tools/Launcher/Toolkit/Support/UTypes.h index 77e5eaa8bab..f0a727c84cd 100644 --- a/Core/Tools/Launcher/Toolkit/Support/UTypes.h +++ b/Core/Tools/Launcher/Toolkit/Support/UTypes.h @@ -85,7 +85,3 @@ typedef Float32 Float; //! TriState typedef enum {OFF = false, ON = true, PENDING = -1} TriState; -//! Empty pointer -#ifndef NULL -#define NULL (0L) -#endif diff --git a/Core/Tools/Launcher/configfile.cpp b/Core/Tools/Launcher/configfile.cpp index 7f2dc928e6c..81a9649063e 100644 --- a/Core/Tools/Launcher/configfile.cpp +++ b/Core/Tools/Launcher/configfile.cpp @@ -68,7 +68,7 @@ bit8 ConfigFile::readFile(FILE *in) cptr=Eat_Spaces(string); if ((*cptr==0)||(*cptr=='#')) // '#' signals a comment continue; - if (strchr(cptr,'=')==NULL) // All config entries must have a '=' + if (strchr(cptr,'=')==nullptr) // All config entries must have a '=' continue; key=cptr; key.truncate('='); diff --git a/Core/Tools/Launcher/dialog.cpp b/Core/Tools/Launcher/dialog.cpp index 7bd986abc3c..663a86d60b0 100644 --- a/Core/Tools/Launcher/dialog.cpp +++ b/Core/Tools/Launcher/dialog.cpp @@ -30,7 +30,7 @@ BOOL CALLBACK Patch_Window_Proc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lPar HWND Create_Patch_Dialog(void) { PatchDialog=CreateDialog(Global_instance, MAKEINTRESOURCE(IDD_PATCHPROGRESS), - NULL, (DLGPROC)Patch_Window_Proc); + nullptr, (DLGPROC)Patch_Window_Proc); ShowWindow(PatchDialog, SW_NORMAL); SetForegroundWindow(PatchDialog); diff --git a/Core/Tools/Launcher/dictionary.h b/Core/Tools/Launcher/dictionary.h index 640190a5b52..6fa576f1592 100644 --- a/Core/Tools/Launcher/dictionary.h +++ b/Core/Tools/Launcher/dictionary.h @@ -119,7 +119,7 @@ Dictionary::Dictionary(uint32 (* hashFn)(K &key)) : //Table is a pointer to a list of pointers (the hash table) table=(DNode **)new DNode* [size]; - assert(table!=NULL); + assert(table!=nullptr); memset((void *)table,0,size*sizeof(void *)); hashFunc=hashFn; @@ -143,13 +143,13 @@ void Dictionary::clear() for (i=0; ihashNext; delete(del); } - table[i]=NULL; + table[i]=nullptr; } entries=0; @@ -181,7 +181,7 @@ void Dictionary::print(IN FILE *out) const fprintf(out," |\n"); fprintf(out,"[ ]"); - while (temp!=NULL) + while (temp!=nullptr) { fprintf(out,"--[ ]"); temp=temp->hashNext; @@ -207,27 +207,27 @@ bit8 Dictionary::iterate(INOUT int &index,INOUT int &offset, return(FALSE); temp=table[index]; - while ((temp==NULL)&&((++index) < getSize())) + while ((temp==nullptr)&&((++index) < getSize())) { temp=table[index]; offset=0; } - if (temp==NULL) // no more slots with data + if (temp==nullptr) // no more slots with data return(FALSE); uint32 i=0; - while ((temp!=NULL) && (i < offset)) + while ((temp!=nullptr) && (i < offset)) { temp=temp->hashNext; i++; } - if (temp==NULL) // should never happen + if (temp==nullptr) // should never happen return(FALSE); value=temp->value; - if (temp->hashNext==NULL) + if (temp->hashNext==nullptr) { index++; offset=0; @@ -263,10 +263,10 @@ bit8 Dictionary::contains(IN K &key) node=table[offset]; - if (node==NULL) + if (node==nullptr) { return(FALSE); } // can't find it - while(node!=NULL) + while(node!=nullptr) { if ((node->key)==key) { return(TRUE); } @@ -300,7 +300,7 @@ bit8 Dictionary::add(IN K &key,IN V &value) float percent; item=(DNode *)new DNode; - assert(item!=NULL); + assert(item!=nullptr); #ifdef KEY_MEM_OPS memcpy(&(item->key),&key,sizeof(K)); @@ -314,7 +314,7 @@ bit8 Dictionary::add(IN K &key,IN V &value) item->value=value; #endif - item->hashNext=NULL; + item->hashNext=nullptr; //If key already exists, it will be overwritten remove(key); @@ -323,7 +323,7 @@ bit8 Dictionary::add(IN K &key,IN V &value) node=table[offset]; - if (node==NULL) + if (node==nullptr) { table[offset]=item; } else { @@ -358,7 +358,7 @@ bit8 Dictionary::remove(IN K &key,OUT V &value) node=table[offset]; last=node; - if (node==NULL) return(FALSE); + if (node==nullptr) return(FALSE); //special case table points to thing to delete @@ -384,7 +384,7 @@ bit8 Dictionary::remove(IN K &key,OUT V &value) node=node->hashNext; //Now the case if the thing to delete is not the first - while (node!=NULL) + while (node!=nullptr) { #ifdef KEY_MEM_OPS if (0==memcmp(&(node->key),&key,sizeof(K))) @@ -437,7 +437,7 @@ bit8 Dictionary::removeAny(OUT K &key,OUT V &value) int i; offset=-1; for (i=0; i<(int)getSize(); i++) - if (table[i]!=NULL) + if (table[i]!=nullptr) { offset=i; break; @@ -479,16 +479,16 @@ bit8 Dictionary::getValue(IN K &key,OUT V &value) node=table[offset]; - if (node==NULL) return(FALSE); + if (node==nullptr) return(FALSE); #ifdef KEY_MEM_OPS - while ((node!=NULL)&&(memcmp(&(node->key),&key,sizeof(K)))) + while ((node!=nullptr)&&(memcmp(&(node->key),&key,sizeof(K)))) #else - while ((node!=NULL)&&( ! ((node->key)==key)) ) // odd syntax so you don't + while ((node!=nullptr)&&( ! ((node->key)==key)) ) // odd syntax so you don't #endif // have to do oper != { node=node->hashNext; } - if (node==NULL) + if (node==nullptr) { return(FALSE); } #ifdef VALUE_MEM_OPS @@ -524,13 +524,13 @@ void Dictionary::shrink(void) tableBits--; table=(DNode **)new DNode*[size]; - assert(table!=NULL); + assert(table!=nullptr); memset((void *)table,0,size*sizeof(void *)); for (i=0; ikey); first=table[offset]; @@ -563,13 +563,13 @@ void Dictionary::expand(void) tableBits++; table=(DNode **)new DNode* [size]; - assert(table!=NULL); + assert(table!=nullptr); memset((void *)table,0,size*sizeof(void *)); for (i=0; ikey); first=table[offset]; diff --git a/Core/Tools/Launcher/filed.h b/Core/Tools/Launcher/filed.h index f490b05d1c3..bb3ffd7e757 100644 --- a/Core/Tools/Launcher/filed.h +++ b/Core/Tools/Launcher/filed.h @@ -26,7 +26,7 @@ class FileD : public OutputDevice FileD(char *filename, bool outputDebug) : m_outputDebug(outputDebug) { out=fopen(filename,"w"); - if (out==NULL) + if (out==nullptr) out=fopen("FileDev.out","w"); } diff --git a/Core/Tools/Launcher/findpatch.cpp b/Core/Tools/Launcher/findpatch.cpp index 01715600afd..ed5687e4f7c 100644 --- a/Core/Tools/Launcher/findpatch.cpp +++ b/Core/Tools/Launcher/findpatch.cpp @@ -35,7 +35,7 @@ int Find_Patch(OUT char *filename,int maxlen, ConfigFile &config) WIN32_FIND_DATA findData; char string[128]; HANDLE hFile; - const char *extensions[]={"web","exe","exn","rtp",NULL}; + const char *extensions[]={"web","exe","exn","rtp", nullptr}; int i; int skuIndex=0; Wstring key; @@ -131,7 +131,7 @@ bit8 Get_App_Dir(OUT char *filename,int maxlen, ConfigFile &config,int index) } DWORD type; DWORD length=MAX_PATH; - regRetval=RegQueryValueEx(regKey,"InstallPath",NULL,&type,(uint8 *)gamePath, + regRetval=RegQueryValueEx(regKey,"InstallPath",nullptr,&type,(uint8 *)gamePath, &length); DBGMSG("GAME PATH = "<bmiColors, ((1< cutoffTime) + if (time(nullptr) > cutoffTime) { // The future is now! Just run the game. RunGame(argv[0], config, proc); @@ -315,8 +315,8 @@ void CreatePrimaryWin(const char *prefix) wc.cbWndExtra = 0; // No extra win data wc.hInstance = Global_instance; wc.hIcon=LoadIcon(Global_instance, MAKEINTRESOURCE(IDI_GENERALS)); - wc.hCursor = NULL; /////////LoadCursor( NULL, IDC_ARROW ); - wc.hbrBackground = NULL; + wc.hCursor = nullptr; /////////LoadCursor( nullptr, IDC_ARROW ); + wc.hbrBackground = nullptr; wc.lpszMenuName = name; wc.lpszClassName = name; RegisterClass(&wc); @@ -326,7 +326,7 @@ void CreatePrimaryWin(const char *prefix) */ HWND hwnd = CreateWindowEx(WS_EX_TOPMOST, name, name, WS_POPUP, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), - NULL, NULL, Global_instance, NULL); + nullptr, nullptr, Global_instance, nullptr); if(!hwnd) { @@ -361,7 +361,7 @@ void myChdir(char *path) int abc; _splitpath( path, drive, dir, file, ext ); - _makepath ( filepath, drive, dir, NULL, NULL ); + _makepath ( filepath, drive, dir, nullptr, nullptr ); if ( filepath[ strlen( filepath ) - 1 ] == '\\' ) { diff --git a/Core/Tools/Launcher/monod.cpp b/Core/Tools/Launcher/monod.cpp index 8e05d8449d7..2ec8a047bec 100644 --- a/Core/Tools/Launcher/monod.cpp +++ b/Core/Tools/Launcher/monod.cpp @@ -22,12 +22,12 @@ MonoD::MonoD(void) { #ifdef _WIN32 unsigned long retval; - handle = CreateFile("\\\\.\\MONO", GENERIC_READ|GENERIC_WRITE, 0, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + handle = CreateFile("\\\\.\\MONO", GENERIC_READ|GENERIC_WRITE, 0, nullptr, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (handle != INVALID_HANDLE_VALUE) { - DeviceIoControl(handle, (DWORD)IOCTL_MONO_CLEAR_SCREEN, NULL, 0, NULL, 0, + DeviceIoControl(handle, (DWORD)IOCTL_MONO_CLEAR_SCREEN, nullptr, 0, nullptr, 0, &retval,0); } #endif @@ -37,7 +37,7 @@ MonoD::~MonoD() { #ifdef _WIN32 CloseHandle(handle); - handle=NULL; + handle = nullptr; #endif } @@ -45,8 +45,8 @@ int MonoD::print(const char *str, int len) { #ifdef _WIN32 unsigned long retval; - WriteFile(handle, str, len, &retval, NULL); - //DeviceIoControl(handle, (DWORD)IOCTL_MONO_PRINT_RAW, (void *)str, len, NULL, 0, + WriteFile(handle, str, len, &retval, nullptr); + //DeviceIoControl(handle, (DWORD)IOCTL_MONO_PRINT_RAW, (void *)str, len, nullptr, 0, // &retval,0); return(len); #else diff --git a/Core/Tools/Launcher/patch.cpp b/Core/Tools/Launcher/patch.cpp index 63c746aafbe..ef9e1bff7a9 100644 --- a/Core/Tools/Launcher/patch.cpp +++ b/Core/Tools/Launcher/patch.cpp @@ -49,7 +49,7 @@ BOOL CALLBACK Update_Info_Proc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lPara case WM_INITDIALOG: { FILE *in = fopen("launcher.txt","r"); - if (in==NULL) + if (in==nullptr) { EndDialog(hwnd,-1); return(1); @@ -57,7 +57,7 @@ BOOL CALLBACK Update_Info_Proc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lPara char line[270]; int lastsel=0; - char *cptr=NULL; + char *cptr=nullptr; while(fgets(line,255,in)) { //Get rid of any trailing junk @@ -76,7 +76,7 @@ BOOL CALLBACK Update_Info_Proc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lPara SendDlgItemMessage(hwnd, IDC_TEXT, EM_SETSEL, (WPARAM)lastsel, (LPARAM)lastsel ); SendDlgItemMessage(hwnd, IDC_TEXT, EM_REPLACESEL, 0, (LPARAM)(line) ); - SendDlgItemMessage(hwnd, IDC_TEXT, EM_GETSEL, (WPARAM)NULL, (LPARAM)&lastsel ); + SendDlgItemMessage(hwnd, IDC_TEXT, EM_GETSEL, (WPARAM)nullptr, (LPARAM)&lastsel ); } unselectText=1; fclose(in); @@ -158,7 +158,7 @@ void Apply_Patch(char *patchfile,ConfigFile &config,int skuIndex) lpClass, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, - NULL, + nullptr, ®Key, ®Previous); @@ -167,21 +167,21 @@ void Apply_Patch(char *patchfile,ConfigFile &config,int skuIndex) RegSetValueEx(regKey,"EXEPatch",0,REG_SZ,(const uint8*)patchfile,strlen(patchfile)+1); char message[256]; - LoadString(NULL,IDS_SYS_RESTART,message,256); + LoadString(nullptr,IDS_SYS_RESTART,message,256); char title[128]; - LoadString(NULL,IDS_SYS_RESTART_TITLE,title,128); + LoadString(nullptr,IDS_SYS_RESTART_TITLE,title,128); - MessageBox(NULL,message,title,MB_OK); + MessageBox(nullptr,message,title,MB_OK); Shutdown_Computer_Now(); } else { char message[256]; - LoadString(NULL,IDS_RUNONCE_ERR,message,256); + LoadString(nullptr,IDS_RUNONCE_ERR,message,256); char string[256]; sprintf(string,message,patchfile); - MessageBox(NULL,string,"ERROR",MB_OK); + MessageBox(nullptr,string,"ERROR",MB_OK); } } // @@ -191,21 +191,21 @@ void Apply_Patch(char *patchfile,ConfigFile &config,int skuIndex) { MSG msg; HWND dialog=Create_Patch_Dialog(); - while(PeekMessage(&msg,NULL,0,0, PM_REMOVE)) + while(PeekMessage(&msg,nullptr,0,0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); } HINSTANCE hInst=LoadLibrary("patchw32.dll"); - if (hInst==NULL) + if (hInst==nullptr) { char message[256]; - LoadString(NULL,IDS_ERR_MISSING_FILE,message,256); + LoadString(nullptr,IDS_ERR_MISSING_FILE,message,256); char string[256]; sprintf(string,message,"patchw32.dll"); char title[128]; - LoadString(NULL,IDS_ERROR,title,128); - MessageBox(NULL,string,title,MB_OK); + LoadString(nullptr,IDS_ERROR,title,128); + MessageBox(nullptr,string,title,MB_OK); exit(-1); return; } @@ -215,13 +215,13 @@ void Apply_Patch(char *patchfile,ConfigFile &config,int skuIndex) PATCHFUNC patchFunc; patchFunc=(PATCHFUNC)GetProcAddress(hInst,"RTPatchApply32@12"); - if (patchFunc==NULL) + if (patchFunc==nullptr) { char message[256]; - LoadString(NULL,IDS_BAD_LIBRARY,message,256); + LoadString(nullptr,IDS_BAD_LIBRARY,message,256); char title[128]; - LoadString(NULL,IDS_ERROR,title,128); - MessageBox(NULL,message,title,MB_OK); + LoadString(nullptr,IDS_ERROR,title,128); + MessageBox(nullptr,message,title,MB_OK); return; } @@ -248,7 +248,7 @@ void Apply_Patch(char *patchfile,ConfigFile &config,int skuIndex) char *cptr=patchfile; char *tempPtr; DWORD version; - while( (tempPtr=strchr(cptr,'\\')) !=NULL) + while( (tempPtr=strchr(cptr,'\\')) !=nullptr) cptr=tempPtr+1; if (cptr) version=atol(cptr); @@ -300,7 +300,7 @@ void Apply_Patch(char *patchfile,ConfigFile &config,int skuIndex) Wait_Process(notepad); } #else - DialogBox(Global_instance,MAKEINTRESOURCE(IDD_CHANGELOG),NULL,(DLGPROC)Update_Info_Proc); + DialogBox(Global_instance,MAKEINTRESOURCE(IDD_CHANGELOG),nullptr,(DLGPROC)Update_Info_Proc); #endif } // @@ -323,18 +323,18 @@ void Apply_Patch(char *patchfile,ConfigFile &config,int skuIndex) else if (strcasecmp(patchfile+strlen(patchfile)-strlen(".web"),".web")==0) { char message[256]; - LoadString(NULL,IDS_WEBPATCH,message,256); + LoadString(nullptr,IDS_WEBPATCH,message,256); char title[128]; - LoadString(NULL,IDS_WEBPATCH_TITLE,title,128); - MessageBox(NULL,message,title,MB_OK); + LoadString(nullptr,IDS_WEBPATCH_TITLE,title,128); + MessageBox(nullptr,message,title,MB_OK); FILE *in=fopen(patchfile,"r"); - if (in!=NULL) + if (in!=nullptr) { char URL[256]; fgets(URL,255,in); fclose(in); - ShellExecute(NULL,NULL,URL,NULL,".",SW_SHOW); + ShellExecute(nullptr,nullptr,URL,nullptr,".",SW_SHOW); _unlink(patchfile); //// This is somewhat skanky, but we can't wait //// for the viewer to exit (I tried). @@ -342,7 +342,7 @@ void Apply_Patch(char *patchfile,ConfigFile &config,int skuIndex) } else { - MessageBox(NULL,patchfile,"Patchfile vanished?",MB_OK); + MessageBox(nullptr,patchfile,"Patchfile vanished?",MB_OK); } } } @@ -362,15 +362,14 @@ void Shutdown_Computer_Now(void) } // Get the LUID for the shutdown privilege. - LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME, - &tkp.Privileges[0].Luid); + LookupPrivilegeValue(nullptr, SE_SHUTDOWN_NAME, &tkp.Privileges[0].Luid); tkp.PrivilegeCount = 1; // one privilege to set tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; // Get the shutdown privilege for this process. AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, - (PTOKEN_PRIVILEGES)NULL, 0); + (PTOKEN_PRIVILEGES)nullptr, 0); // Cannot test the return value of AdjustTokenPrivileges. if (GetLastError() != ERROR_SUCCESS) @@ -383,13 +382,13 @@ void Shutdown_Computer_Now(void) { // Should never happen char restart[128]; - LoadString(NULL,IDS_MUST_RESTART,restart,128); - MessageBox(NULL,restart,"OK",MB_OK); + LoadString(nullptr,IDS_MUST_RESTART,restart,128); + MessageBox(nullptr,restart,"OK",MB_OK); exit(0); } MSG msg; - while (GetMessage(&msg, NULL, 0, 0)) + while (GetMessage(&msg, nullptr, 0, 0)) { TranslateMessage( &msg ); DispatchMessage( &msg ); @@ -410,7 +409,7 @@ __declspec(dllexport) LPVOID CALLBACK PatchCallBack(UINT Id, LPVOID Param) // Make sure our windows get updated MSG msg; int counter=0; - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE )) + while (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE )) { TranslateMessage( &msg ); DispatchMessage( &msg ); @@ -445,11 +444,11 @@ __declspec(dllexport) LPVOID CALLBACK PatchCallBack(UINT Id, LPVOID Param) // Error message header/text ///////*g_LogFile << (char *)Parm << endl; char errmsg[256]; - LoadString(NULL,IDS_ERR_PATCH,errmsg,256); - MessageBox(NULL,(char *)Param,errmsg,MB_OK); + LoadString(nullptr,IDS_ERR_PATCH,errmsg,256); + MessageBox(nullptr,(char *)Param,errmsg,MB_OK); { FILE *out=fopen("patch.err","a"); - time_t timet=time(NULL); + time_t timet=time(nullptr); fprintf(out,"\n\nPatch Error: %s\n",ctime(&timet)); fprintf(out,"%s\n",(char *)Param); fclose(out); @@ -507,7 +506,7 @@ __declspec(dllexport) LPVOID CALLBACK PatchCallBack(UINT Id, LPVOID Param) currFile++; char xofy[64]; - LoadString(NULL,IDS_FILE_X_OF_Y,xofy,64); + LoadString(nullptr,IDS_FILE_X_OF_Y,xofy,64); sprintf(string,xofy,currFile,fileCount); SetWindowText(GetDlgItem(PatchDialog,IDC_CAPTION),string); @@ -575,7 +574,7 @@ __declspec(dllexport) LPVOID CALLBACK PatchCallBack(UINT Id, LPVOID Param) } if(Abort) - return (NULL); + return (nullptr); else return (RetVal); } diff --git a/Core/Tools/Launcher/process.cpp b/Core/Tools/Launcher/process.cpp index 335dbb0f225..3069824821f 100644 --- a/Core/Tools/Launcher/process.cpp +++ b/Core/Tools/Launcher/process.cpp @@ -23,8 +23,8 @@ Process::Process() directory[0]=0; command[0]=0; args[0]=0; - hProcess=NULL; - hThread=NULL; + hProcess=nullptr; + hThread=nullptr; } // Create a process @@ -43,7 +43,7 @@ bit8 Create_Process(Process &process) DBGMSG("PROCESS CMD="<strlen(str)) pos=strlen(str); @@ -443,7 +443,7 @@ bit8 Wstring::replace(const char *replaceThis, const char *withThis) if(!dest.cat(src)) return(FALSE); - src=NULL; + src=nullptr; } } return(set(dest.get())); @@ -493,7 +493,7 @@ char Wstring::set(uint32 size, const char *string) return(FALSE); } - // Copy the bytes in the string, and NULL-terminate it. + // Copy the bytes in the string, and null-terminate it. strncpy(str, string, size); str[size] = 0; @@ -545,18 +545,18 @@ bit8 Wstring::truncate(char c) { sint32 len; - if (str==NULL) + if (str==nullptr) return(FALSE); char *cptr=strchr(str,c); - if (cptr==NULL) + if (cptr==nullptr) return(FALSE); len=(sint32)(cptr-str); truncate((uint32)len); return(TRUE); } -// Get a token from this string that's seperated by one or more +// Get a token from this string that's separated by one or more // chars from the 'delim' string , start at offset & return offset sint32 Wstring::getToken(int offset,const char *delim,Wstring &out) { @@ -564,7 +564,7 @@ sint32 Wstring::getToken(int offset,const char *delim,Wstring &out) sint32 start; sint32 stop; for (i=offset; i<(int)length(); i++) { - if(strchr(delim,str[i])==NULL) + if(strchr(delim,str[i])==nullptr) break; } if (i>=(int)length()) @@ -572,7 +572,7 @@ sint32 Wstring::getToken(int offset,const char *delim,Wstring &out) start=i; for (; i<(int)length(); i++) { - if(strchr(delim,str[i])!=NULL) + if(strchr(delim,str[i])!=nullptr) break; } stop=i-1; @@ -593,7 +593,7 @@ sint32 Wstring::getLine(int offset, Wstring &out) return(-1); for (; i<(int)length(); i++) { - if(strchr("\r\n",str[i])!=NULL) + if(strchr("\r\n",str[i])!=nullptr) break; } stop=i; diff --git a/Core/Tools/Launcher/wstypes.h b/Core/Tools/Launcher/wstypes.h index d521a5872a0..e74cd7a43fe 100644 --- a/Core/Tools/Launcher/wstypes.h +++ b/Core/Tools/Launcher/wstypes.h @@ -46,10 +46,6 @@ Standard type definitions for the sake of portability and readability. #define MAX(x,y) (((x)>(y))?(x):(y)) #endif -#ifndef NULL -#define NULL 0 -#endif - //These are used for readability purposes mostly, when a method takes a // pointer or reference these help specify what will happen to the data // that is sent in. diff --git a/Core/Tools/MapCacheBuilder/Source/WinMain.cpp b/Core/Tools/MapCacheBuilder/Source/WinMain.cpp index 9a2d0adca3f..f26f8952ee2 100644 --- a/Core/Tools/MapCacheBuilder/Source/WinMain.cpp +++ b/Core/Tools/MapCacheBuilder/Source/WinMain.cpp @@ -115,19 +115,19 @@ static SubsystemInterfaceList _TheSubsystemList; template -void initSubsystem(SUBSYSTEM*& sysref, SUBSYSTEM* sys, const char* path1 = NULL, const char* path2 = NULL) +void initSubsystem(SUBSYSTEM*& sysref, SUBSYSTEM* sys, const char* path1 = nullptr, const char* path2 = nullptr) { sysref = sys; - _TheSubsystemList.initSubsystem(sys, path1, path2, NULL); + _TheSubsystemList.initSubsystem(sys, path1, path2, nullptr); } /////////////////////////////////////////////////////////////////////////////// // PUBLIC DATA //////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -HINSTANCE ApplicationHInstance = NULL; ///< our application instance +HINSTANCE ApplicationHInstance = nullptr; ///< our application instance /// just to satisfy the game libraries we link to -HWND ApplicationHWnd = NULL; +HWND ApplicationHWnd = nullptr; const char *gAppPrefix = "MC_"; @@ -143,14 +143,14 @@ const Char *g_csfFile = "data\\%s\\Generals.csf"; static char *nextParam(char *newSource, const char *seps) { - static char *source = NULL; + static char *source = nullptr; if (newSource) { source = newSource; } if (!source) { - return NULL; + return nullptr; } // find first separator @@ -186,15 +186,15 @@ static char *nextParam(char *newSource, const char *seps) *end = 0; if (!*source) - source = NULL; + source = nullptr; } else { - source = NULL; + source = nullptr; } if (first && !*first) - first = NULL; + first = nullptr; } return first; @@ -223,7 +223,7 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, // Set the current directory to the app directory. char buf[_MAX_PATH]; - GetModuleFileName(NULL, buf, sizeof(buf)); + GetModuleFileName(nullptr, buf, sizeof(buf)); if (char *pEnd = strrchr(buf, '\\')) { *pEnd = 0; } @@ -235,11 +235,11 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, std::list argvSet; char *token; token = nextParam(lpCmdLine, "\" "); - while (token != NULL) { + while (token != nullptr) { char * str = strtrim(token); argvSet.push_back(str); DEBUG_LOG(("Adding '%s'", str)); - token = nextParam(NULL, "\" "); + token = nextParam(nullptr, "\" "); } // not part of the subsystem list, because it should normally never be reset! @@ -263,16 +263,16 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, initSubsystem(TheModuleFactory, (ModuleFactory*)(new W3DModuleFactory())); initSubsystem(TheSidesList, new SidesList()); initSubsystem(TheCaveSystem, new CaveSystem()); - initSubsystem(TheRankInfoStore, new RankInfoStore(), NULL, "Data\\INI\\Rank"); + initSubsystem(TheRankInfoStore, new RankInfoStore(), nullptr, "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", "Data\\INI\\FXList"); - initSubsystem(TheWeaponStore, new WeaponStore(), NULL, "Data\\INI\\Weapon"); + initSubsystem(TheWeaponStore, new WeaponStore(), nullptr, "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(TheLocomotorStore, new LocomotorStore(), nullptr, "Data\\INI\\Locomotor"); + initSubsystem(TheDamageFXStore, new DamageFXStore(), nullptr, "Data\\INI\\DamageFX"); + initSubsystem(TheArmorStore, new ArmorStore(), nullptr, "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"); @@ -294,23 +294,23 @@ Int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, TheMapCache->updateCache(); delete TheMapCache; - TheMapCache = NULL; + TheMapCache = nullptr; // load the dialog box //DialogBox( hInstance, (LPCTSTR)IMAGE_PACKER_DIALOG, - // NULL, (DLGPROC)ImagePackerProc ); + // nullptr, (DLGPROC)ImagePackerProc ); // delete TheGlobalData //delete TheGlobalData; - //TheGlobalData = NULL; + //TheGlobalData = nullptr; _TheSubsystemList.shutdownAll(); delete TheFileSystem; - TheFileSystem = NULL; + TheFileSystem = nullptr; delete TheNameKeyGenerator; - TheNameKeyGenerator = NULL; + TheNameKeyGenerator = nullptr; } catch (...) diff --git a/Core/Tools/PATCHGET/CHATAPI.cpp b/Core/Tools/PATCHGET/CHATAPI.cpp index bba0c3902d3..7e1df70c117 100644 --- a/Core/Tools/PATCHGET/CHATAPI.cpp +++ b/Core/Tools/PATCHGET/CHATAPI.cpp @@ -176,16 +176,16 @@ static void startOnline( void ) // Close that contacting window DestroyWindow(g_ContactWindow); - g_ContactWindow=NULL; + g_ContactWindow=nullptr; if (cantConnect) { - MessageBox(NULL, "Can't Connect", GAME_NAME, MB_OK); + MessageBox(nullptr, "Can't Connect", GAME_NAME, MB_OK); exit(0); } else if (queuedDownloads.size()) { - if (MessageBox(NULL, "Patches Available. Download?", GAME_NAME, MB_YESNO) == IDYES) + if (MessageBox(nullptr, "Patches Available. Download?", GAME_NAME, MB_YESNO) == IDYES) { DEBUG_LOG(("Downloading patches")); while (queuedDownloads.size()) @@ -210,7 +210,7 @@ static void startOnline( void ) } */ delete TheDownloadManager; - TheDownloadManager = NULL; + TheDownloadManager = nullptr; if (g_Finished != 1) { @@ -229,7 +229,7 @@ static void startOnline( void ) } else { - MessageBox(NULL, "No Patches Available", GAME_NAME, MB_OK); + MessageBox(nullptr, "No Patches Available", GAME_NAME, MB_OK); exit(0); } } @@ -278,7 +278,7 @@ static std::string getNextLine(std::string in, std::string& remainder) //----------------------------------------------------------------------------- inline const char* skipSeps(const char* p, const char* seps) { - while (*p && strchr(seps, *p) != NULL) + while (*p && strchr(seps, *p) != nullptr) ++p; return p; } @@ -286,18 +286,18 @@ inline const char* skipSeps(const char* p, const char* seps) //----------------------------------------------------------------------------- inline const char* skipNonSeps(const char* p, const char* seps) { - while (*p && strchr(seps, *p) == NULL) + while (*p && strchr(seps, *p) == nullptr) ++p; return p; } //----------------------------------------------------------------------------- -bool nextToken(std::string& base, std::string& tok, const char* seps = NULL) +bool nextToken(std::string& base, std::string& tok, const char* seps = nullptr) { if (base.empty()) return false; - if (seps == NULL) + if (seps == nullptr) seps = " \n\r\t"; const char* start = skipSeps(base.c_str(), seps); @@ -463,8 +463,8 @@ static void StartPatchCheck( void ) // check for a patch first checksLeft = 2; cantConnect = false; - ghttpGet(gameURL.c_str(), GHTTPFalse, patchCheckCallback, NULL); - ghttpGet(mapURL.c_str(), GHTTPFalse, patchCheckCallback, NULL); + ghttpGet(gameURL.c_str(), GHTTPFalse, patchCheckCallback, nullptr); + ghttpGet(mapURL.c_str(), GHTTPFalse, patchCheckCallback, nullptr); DEBUG_LOG(("Started looking for patches at '%s' && '%s'", gameURL.c_str(), mapURL.c_str())); } @@ -526,7 +526,7 @@ BOOL CALLBACK downloadDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM //sprintf(localfile,"%s\\%s",g_Update->localpath,g_Update->patchfile); // Create the directory - //CreateDirectory((char *)g_Update->localpath, NULL ); + //CreateDirectory((char *)g_Update->localpath, nullptr ); TheDownloadManager->downloadFile(TheDownload.server, TheDownload.userName, TheDownload.password, TheDownload.file, TheDownload.localFile, TheDownload.regKey, TheDownload.tryResume); @@ -537,7 +537,7 @@ BOOL CALLBACK downloadDialogProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM */ g_DownloadWindow = hwndDlg; g_Finished = 0; - SetTimer( hwndDlg, 1, 200, NULL ); // was 50 + SetTimer( hwndDlg, 1, 200, nullptr ); // was 50 break; @@ -625,8 +625,8 @@ HWND CreatePrimaryWin(void) wc.cbWndExtra = 0; // No extra win data wc.hInstance = Global_instance; wc.hIcon=LoadIcon(Global_instance, MAKEINTRESOURCE(IDI_ICON1)); - wc.hCursor = NULL; /////////LoadCursor( NULL, IDC_ARROW ); - wc.hbrBackground = NULL; + wc.hCursor = nullptr; /////////LoadCursor( nullptr, IDC_ARROW ); + wc.hbrBackground = nullptr; wc.lpszMenuName = name; wc.lpszClassName = name; RegisterClass( &wc ); @@ -645,10 +645,10 @@ HWND CreatePrimaryWin(void) //GetSystemMetrics( SM_CYSCREEN ), 0,0, - NULL, - NULL, + nullptr, + nullptr, Global_instance, - NULL ); + nullptr ); SendMessage(hwnd,WM_SETICON,(WPARAM)ICON_SMALL, (LPARAM)LoadIcon(Global_instance, MAKEINTRESOURCE(IDI_ICON1))); @@ -667,7 +667,7 @@ void DispatchEvents(void) { MSG msg; int counter=0; - while(PeekMessage(&msg,NULL,0,0, PM_REMOVE)) + while(PeekMessage(&msg,nullptr,0,0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); @@ -696,7 +696,7 @@ int main(int argc, char *argv[]) { char username[64]; valuesize=sizeof(username); - if (RegQueryValueEx(rKey,"UserName",NULL,&type,(uint8 *)username,&valuesize)==ERROR_SUCCESS) + if (RegQueryValueEx(rKey,"UserName",nullptr,&type,(uint8 *)username,&valuesize)==ERROR_SUCCESS) have_registered=true; RegCloseKey(rKey); } @@ -711,7 +711,7 @@ int main(int argc, char *argv[]) if (!have_registered) { - if (MessageBox(NULL,Fetch_String(TXT_REGNOW),Fetch_String(TXT_TITLE),MB_YESNO)==IDNO) + if (MessageBox(nullptr,Fetch_String(TXT_REGNOW),Fetch_String(TXT_TITLE),MB_YESNO)==IDNO) have_registered=true; // pretend they've alredy registered } @@ -723,7 +723,7 @@ int main(int argc, char *argv[]) { char regapp[300]; valuesize=sizeof(regapp); - if ((RegQueryValueEx(rKey,"InstallPath",NULL,&type,(uint8 *)regapp,&valuesize)==ERROR_SUCCESS)&& + if ((RegQueryValueEx(rKey,"InstallPath",nullptr,&type,(uint8 *)regapp,&valuesize)==ERROR_SUCCESS)&& (strlen(regapp) > 8)) { // Launch the process @@ -732,9 +732,9 @@ int main(int argc, char *argv[]) info.cbSize=sizeof(info); info.fMask=SEE_MASK_NOCLOSEPROCESS; info.hwnd=g_PrimaryWindow; - info.lpVerb=NULL; + info.lpVerb=nullptr; info.lpFile=regapp; - info.lpParameters=NULL; + info.lpParameters=nullptr; info.lpDirectory="."; info.nShow=SW_SHOW; ShellExecuteEx(&info); @@ -865,15 +865,15 @@ char const * Fetch_String(int id) /****** char resname[32]; sprintf(resname,"#%d",id); - HMODULE hmod=GetModuleHandle(NULL); + HMODULE hmod=GetModuleHandle(nullptr); HRSRC hrsrc=FindResourceEx(hmod, RT_STRING, MAKEINTRESOURCE(id), LANGID); if (hrsrc==0) { char message_buffer[256]; - FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &message_buffer[0], 256, NULL ); + FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), &message_buffer[0], 256, nullptr ); } - HGLOBAL resdata=LoadResource(NULL,hrsrc); + HGLOBAL resdata=LoadResource(nullptr,hrsrc); LPVOID vdata=LockResource(resdata); strcpy(stringptr,(char *)vdata); *********/ @@ -903,13 +903,13 @@ void Startup_Chat(void) /* //////CComObject* g_pChatSink; HRESULT hRes; - g_pChatSink=NULL; + g_pChatSink=nullptr; - CoCreateInstance(CLSID_Chat, NULL, CLSCTX_INPROC_SERVER, + CoCreateInstance(CLSID_Chat, nullptr, CLSCTX_INPROC_SERVER, IID_IChat, (void**)&pChat); - if (pChat==NULL) + if (pChat==nullptr) { char error[128]; char apimissing[256]; @@ -922,8 +922,8 @@ void Startup_Chat(void) g_pChatSink=new CChatEventSink; // Get a connection point from the chat class - IConnectionPoint *pConnectionPoint=NULL; - IConnectionPointContainer *pContainer=NULL; + IConnectionPoint *pConnectionPoint=nullptr; + IConnectionPointContainer *pContainer=nullptr; dwChatAdvise=0; hRes=pChat->QueryInterface(IID_IConnectionPointContainer,(void**)&pContainer); @@ -945,8 +945,8 @@ void Shutdown_Chat(void) /* /////AtlUnadvise(pChat, IID_IChatEvent, dwChatAdvise); - IConnectionPoint *pConnectionPoint=NULL; - IConnectionPointContainer *pContainer=NULL; + IConnectionPoint *pConnectionPoint=nullptr; + IConnectionPointContainer *pContainer=nullptr; HRESULT hRes; hRes=pChat->QueryInterface(IID_IConnectionPointContainer,(void**)&pContainer); @@ -976,7 +976,7 @@ void Update_If_Required(void) int i; // Create the events for (i=0; iRequestServerList(1000,262364,"register","regpas98",15); @@ -1034,7 +1034,7 @@ void Update_If_Required(void) { pChat->PumpMessages(); MSG msg; - while(PeekMessage(&msg,NULL,0,0, PM_REMOVE)) + while(PeekMessage(&msg,nullptr,0,0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); @@ -1097,7 +1097,7 @@ CChatEventSink::QueryInterface(const IID& iid, void** ppv) } else { - *ppv = NULL; + *ppv = nullptr; return E_NOINTERFACE; } (reinterpret_cast(*ppv))->AddRef() ; @@ -1157,7 +1157,7 @@ CDownloadEventSink::QueryInterface(const IID& iid, void** ppv) } else { - *ppv = NULL; + *ppv = nullptr; return E_NOINTERFACE; } (reinterpret_cast(*ppv))->AddRef() ; @@ -1204,16 +1204,16 @@ void SetupDownload( void ) /* HRESULT hRes; - g_pDownloadSink=NULL; + g_pDownloadSink=nullptr; - CoCreateInstance(CLSID_Download, NULL, CLSCTX_INPROC_SERVER, + CoCreateInstance(CLSID_Download, nullptr, CLSCTX_INPROC_SERVER, IID_IDownload, (void**)&pDownload); _ASSERTE(pDownload); g_pDownloadSink=new CDownloadEventSink; // Get a connection point from the chat class - IConnectionPoint *pConnectionPoint=NULL; - IConnectionPointContainer *pContainer=NULL; + IConnectionPoint *pConnectionPoint=nullptr; + IConnectionPointContainer *pContainer=nullptr; dwDownloadAdvise = 0; hRes=pDownload->QueryInterface(IID_IConnectionPointContainer,(void**)&pContainer); @@ -1232,8 +1232,8 @@ void ClosedownDownload( void ) /* // AtlUnadvise(pDownload, IID_IDownloadEvent, dwDownloadAdvise); - IConnectionPoint *pConnectionPoint=NULL; - IConnectionPointContainer *pContainer=NULL; + IConnectionPoint *pConnectionPoint=nullptr; + IConnectionPointContainer *pContainer=nullptr; HRESULT hRes; hRes=pDownload->QueryInterface(IID_IConnectionPointContainer,(void**)&pContainer); @@ -1308,7 +1308,7 @@ BOOL CALLBACK Download_Dialog_Proc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR sprintf(localfile,"%s\\%s",g_Update->localpath,g_Update->patchfile); // Create the directory - CreateDirectory((char *)g_Update->localpath, NULL ); + CreateDirectory((char *)g_Update->localpath, nullptr ); res=pDownload->DownloadFile((char *)g_Update->server, (char *)g_Update->login, (char *)g_Update->password, fullpath, localfile, APP_REG_KEY); @@ -1316,7 +1316,7 @@ BOOL CALLBACK Download_Dialog_Proc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPAR */ g_DownloadWindow = hwndDlg; g_Finished = 0; - SetTimer( hwndDlg, 1, 200, NULL ); // was 50 + SetTimer( hwndDlg, 1, 200, nullptr ); // was 50 break; @@ -1474,7 +1474,7 @@ STDMETHODIMP CChatEventSink::OnServerList(HRESULT res, Server* servers) // If we get this, then we don't need to patch // Close that contacting window DestroyWindow(g_ContactWindow); - g_ContactWindow=NULL; + g_ContactWindow=nullptr; LogMsg("Server List"); @@ -1661,7 +1661,7 @@ STDMETHODIMP CChatEventSink::OnUpdateList(HRESULT r, Update * updates) // Close that contacting window DestroyWindow(g_ContactWindow); - g_ContactWindow=NULL; + g_ContactWindow=nullptr; if( FAILED(r) ) { @@ -1669,7 +1669,7 @@ STDMETHODIMP CChatEventSink::OnUpdateList(HRESULT r, Update * updates) SetEvent(Events[ABORT_EVENT]); // An error occurred, bail out } - if( updates == NULL ) // shouldn't happen + if( updates == nullptr ) // shouldn't happen return S_OK; @@ -1680,7 +1680,7 @@ STDMETHODIMP CChatEventSink::OnUpdateList(HRESULT r, Update * updates) // Count the updates; tmp = updates; - while( tmp != NULL ) + while( tmp != nullptr ) { tmp = tmp->next; numupdates++; @@ -1711,7 +1711,7 @@ STDMETHODIMP CChatEventSink::OnUpdateList(HRESULT r, Update * updates) } // Do the downloads - while( tmp != NULL ) + while( tmp != nullptr ) { g_Update = tmp; diff --git a/Core/Tools/PATCHGET/COMINIT.cpp b/Core/Tools/PATCHGET/COMINIT.cpp index 73efff26d9c..c592d606ac0 100644 --- a/Core/Tools/PATCHGET/COMINIT.cpp +++ b/Core/Tools/PATCHGET/COMINIT.cpp @@ -30,10 +30,10 @@ namespace patchget ComInit::ComInit() { - HRESULT hRes = CoInitialize(NULL); + HRESULT hRes = CoInitialize(nullptr); if (SUCCEEDED(hRes)==FALSE) { - MessageBox(NULL,"Can't initialize COM?!?!","Error:",MB_OK); + MessageBox(nullptr,"Can't initialize COM?!?!","Error:",MB_OK); exit(0); } } diff --git a/Core/Tools/PATCHGET/DownloadManager.cpp b/Core/Tools/PATCHGET/DownloadManager.cpp index c22268b6226..56d20eed39f 100644 --- a/Core/Tools/PATCHGET/DownloadManager.cpp +++ b/Core/Tools/PATCHGET/DownloadManager.cpp @@ -28,7 +28,7 @@ namespace patchget { -DownloadManager *TheDownloadManager = NULL; +DownloadManager *TheDownloadManager = nullptr; DownloadManager::DownloadManager() { diff --git a/Core/Tools/PATCHGET/PROCESS.cpp b/Core/Tools/PATCHGET/PROCESS.cpp index f59ad57a447..871073fcf95 100644 --- a/Core/Tools/PATCHGET/PROCESS.cpp +++ b/Core/Tools/PATCHGET/PROCESS.cpp @@ -26,8 +26,8 @@ Process::Process() directory[0]=0; command[0]=0; args[0]=0; - hProcess=NULL; - hThread=NULL; + hProcess=nullptr; + hThread=nullptr; } // Create a process @@ -44,7 +44,7 @@ bit8 Create_Process(Process &process) strcpy(cmdargs,process.command); strcat(cmdargs,process.args); - retval=CreateProcess(NULL,cmdargs,NULL,NULL,FALSE, 0 ,NULL, NULL/*process.directory*/,&si,&piProcess); + retval=CreateProcess(nullptr,cmdargs,nullptr,nullptr,FALSE, 0 ,nullptr, nullptr/*process.directory*/,&si,&piProcess); process.hProcess=piProcess.hProcess; process.hThread=piProcess.hThread; @@ -58,11 +58,11 @@ bit8 Wait_Process(Process &process, DWORD *exit_code) { DWORD retval; retval=WaitForSingleObject(process.hProcess,INFINITE); - if (exit_code != NULL) + if (exit_code != nullptr) *exit_code=-1; if (retval==WAIT_OBJECT_0) // process exited { - if (exit_code != NULL) + if (exit_code != nullptr) GetExitCodeProcess(process.hProcess,exit_code); return(TRUE); } diff --git a/Core/Tools/PATCHGET/PROCESS.h b/Core/Tools/PATCHGET/PROCESS.h index 26ccf044c82..57ce353c6fd 100644 --- a/Core/Tools/PATCHGET/PROCESS.h +++ b/Core/Tools/PATCHGET/PROCESS.h @@ -38,6 +38,6 @@ class Process //bit8 Read_Process_Info(ConfigFile &config,OUT Process &info); bit8 Create_Process(Process &process); -bit8 Wait_Process(Process &process, DWORD *exit_code=NULL); +bit8 Wait_Process(Process &process, DWORD *exit_code=nullptr); } // namespace patchget diff --git a/Core/Tools/PATCHGET/Registry.h b/Core/Tools/PATCHGET/Registry.h index 644dbdcf2b7..1e06e549af0 100644 --- a/Core/Tools/PATCHGET/Registry.h +++ b/Core/Tools/PATCHGET/Registry.h @@ -17,7 +17,7 @@ */ // Registry.h -// Simple interface for storing/retreiving registry values +// Simple interface for storing/retrieving registry values // Author: Matthew D. Campbell, December 2001 #pragma once diff --git a/Core/Tools/PATCHGET/WINBLOWS.cpp b/Core/Tools/PATCHGET/WINBLOWS.cpp index 0e79559180b..fd99da0bcc1 100644 --- a/Core/Tools/PATCHGET/WINBLOWS.cpp +++ b/Core/Tools/PATCHGET/WINBLOWS.cpp @@ -30,8 +30,8 @@ // TheSuperHackers @fix xezon 13/03/2025 Fix debug linker errors by // adding "patchget" namespaces and these globals here. // just to satisfy the game libraries we link to -HINSTANCE ApplicationHInstance = NULL; ///< our application instance -HWND ApplicationHWnd = NULL; +HINSTANCE ApplicationHInstance = nullptr; ///< our application instance +HWND ApplicationHWnd = nullptr; const char *g_strFile = "data\\Generals.str"; const char *g_csfFile = "data\\%s\\Generals.csf"; const char *gAppPrefix = "patchget_"; // prefix to the debug log. diff --git a/Core/Tools/PATCHGET/debug.cpp b/Core/Tools/PATCHGET/debug.cpp index d0809df4648..e6a4d04a280 100644 --- a/Core/Tools/PATCHGET/debug.cpp +++ b/Core/Tools/PATCHGET/debug.cpp @@ -37,7 +37,7 @@ static int doCrashBox(const char *buffer, bool logResult) { int result; - result = ::MessageBox(NULL, buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_APPLMODAL|MB_ICONWARNING); + result = ::MessageBox(nullptr, buffer, "Assertion Failure", MB_ABORTRETRYIGNORE|MB_APPLMODAL|MB_ICONWARNING); switch(result) { @@ -96,7 +96,7 @@ void DebugCrash(const char *format, ...) va_end(arg); if (strlen(theBuffer) >= sizeof(theBuffer)) - ::MessageBox(NULL, "String too long for debug buffers", "", MB_OK|MB_APPLMODAL); + ::MessageBox(nullptr, "String too long for debug buffers", "", MB_OK|MB_APPLMODAL); OutputDebugString(theBuffer); OutputDebugString("\n"); @@ -106,10 +106,10 @@ void DebugCrash(const char *format, ...) int result = doCrashBox(theBuffer, true); - if (result == IDIGNORE && TheCurrentIgnoreCrashPtr != NULL) + if (result == IDIGNORE && TheCurrentIgnoreCrashPtr != nullptr) { int yn; - yn = ::MessageBox(NULL, "Ignore this crash from now on?", "", MB_YESNO|MB_APPLMODAL); + yn = ::MessageBox(nullptr, "Ignore this crash from now on?", "", MB_YESNO|MB_APPLMODAL); if (yn == IDYES) *TheCurrentIgnoreCrashPtr = 1; } diff --git a/Core/Tools/PATCHGET/debug.h b/Core/Tools/PATCHGET/debug.h index e61a99033aa..90eb764def5 100644 --- a/Core/Tools/PATCHGET/debug.h +++ b/Core/Tools/PATCHGET/debug.h @@ -55,7 +55,7 @@ void DebugLog( const char *fmt, ... ); if (!ignoreCrash) { \ TheCurrentIgnoreCrashPtr = &ignoreCrash; \ DebugCrash m ; \ - TheCurrentIgnoreCrashPtr = NULL; \ + TheCurrentIgnoreCrashPtr = nullptr; \ } \ } \ } while (0) diff --git a/Core/Tools/PATCHGET/registry.cpp b/Core/Tools/PATCHGET/registry.cpp index 0640c0a9112..fdc412010fa 100644 --- a/Core/Tools/PATCHGET/registry.cpp +++ b/Core/Tools/PATCHGET/registry.cpp @@ -17,7 +17,7 @@ */ // Registry.cpp -// Simple interface for storing/retreiving registry values +// Simple interface for storing/retrieving registry values // Author: Matthew D. Campbell, December 2001 #include @@ -40,7 +40,7 @@ bool getStringFromRegistry(HKEY root, std::string path, std::string key, std::s if ((returnValue = RegOpenKeyEx( root, path.c_str(), 0, KEY_ALL_ACCESS, &handle )) == ERROR_SUCCESS) { - returnValue = RegQueryValueEx(handle, key.c_str(), NULL, &type, (unsigned char *) &buffer, &size); + returnValue = RegQueryValueEx(handle, key.c_str(), nullptr, &type, (unsigned char *) &buffer, &size); RegCloseKey( handle ); } @@ -63,7 +63,7 @@ bool getUnsignedIntFromRegistry(HKEY root, std::string path, std::string key, un if ((returnValue = RegOpenKeyEx( root, path.c_str(), 0, KEY_ALL_ACCESS, &handle )) == ERROR_SUCCESS) { - returnValue = RegQueryValueEx(handle, key.c_str(), NULL, &type, (unsigned char *) &buffer, &size); + returnValue = RegQueryValueEx(handle, key.c_str(), nullptr, &type, (unsigned char *) &buffer, &size); RegCloseKey( handle ); } @@ -84,7 +84,7 @@ bool setStringInRegistry( HKEY root, std::string path, std::string key, std::str int size; char lpClass[] = "REG_NONE"; - if ((returnValue = RegCreateKeyEx( root, path.c_str(), 0, lpClass, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &handle, NULL )) == ERROR_SUCCESS) + if ((returnValue = RegCreateKeyEx( root, path.c_str(), 0, lpClass, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr, &handle, nullptr )) == ERROR_SUCCESS) { type = REG_SZ; size = val.length()+1; @@ -103,7 +103,7 @@ bool setUnsignedIntInRegistry( HKEY root, std::string path, std::string key, uns int size; char lpClass[] = "REG_NONE"; - if ((returnValue = RegCreateKeyEx( root, path.c_str(), 0, lpClass, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &handle, NULL )) == ERROR_SUCCESS) + if ((returnValue = RegCreateKeyEx( root, path.c_str(), 0, lpClass, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr, &handle, nullptr )) == ERROR_SUCCESS) { type = REG_DWORD; size = 4; diff --git a/GeneralsMD/Code/Tools/ParticleEditor/CButtonShowColor.cpp b/Core/Tools/ParticleEditor/CButtonShowColor.cpp similarity index 100% rename from GeneralsMD/Code/Tools/ParticleEditor/CButtonShowColor.cpp rename to Core/Tools/ParticleEditor/CButtonShowColor.cpp diff --git a/GeneralsMD/Code/Tools/ParticleEditor/CButtonShowColor.h b/Core/Tools/ParticleEditor/CButtonShowColor.h similarity index 100% rename from GeneralsMD/Code/Tools/ParticleEditor/CButtonShowColor.h rename to Core/Tools/ParticleEditor/CButtonShowColor.h diff --git a/GeneralsMD/Code/Tools/ParticleEditor/CColorAlphaDialog.cpp b/Core/Tools/ParticleEditor/CColorAlphaDialog.cpp similarity index 100% rename from GeneralsMD/Code/Tools/ParticleEditor/CColorAlphaDialog.cpp rename to Core/Tools/ParticleEditor/CColorAlphaDialog.cpp diff --git a/GeneralsMD/Code/Tools/ParticleEditor/CColorAlphaDialog.h b/Core/Tools/ParticleEditor/CColorAlphaDialog.h similarity index 98% rename from GeneralsMD/Code/Tools/ParticleEditor/CColorAlphaDialog.h rename to Core/Tools/ParticleEditor/CColorAlphaDialog.h index 1c8801e14ba..4d4ef457970 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/CColorAlphaDialog.h +++ b/Core/Tools/ParticleEditor/CColorAlphaDialog.h @@ -30,7 +30,7 @@ class CColorAlphaDialog : public CDialog void onColorPress( Int colorPressed ); public: enum {IDD = IDD_PSEd_EditColorAndAlpha}; - CColorAlphaDialog(UINT nIDTemplate = CColorAlphaDialog::IDD, CWnd* pParentWnd = NULL); + CColorAlphaDialog(UINT nIDTemplate = CColorAlphaDialog::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); diff --git a/GeneralsMD/Code/Tools/ParticleEditor/CMakeLists.txt b/Core/Tools/ParticleEditor/CMakeLists.txt similarity index 52% rename from GeneralsMD/Code/Tools/ParticleEditor/CMakeLists.txt rename to Core/Tools/ParticleEditor/CMakeLists.txt index 4d09c98ec22..61c879d51ff 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/CMakeLists.txt +++ b/Core/Tools/ParticleEditor/CMakeLists.txt @@ -26,37 +26,31 @@ set(PARTICLEED_SRC "VelocityTypePanels.h" ) -add_library(z_particleeditor SHARED) -set_target_properties(z_particleeditor PROPERTIES OUTPUT_NAME particleeditor PREFIX "") +add_library(core_particleeditor SHARED) +set_target_properties(core_particleeditor PROPERTIES OUTPUT_NAME particleeditor PREFIX "") -target_sources(z_particleeditor PRIVATE ${PARTICLEED_SRC}) +target_sources(core_particleeditor PRIVATE ${PARTICLEED_SRC}) -target_include_directories(z_particleeditor PRIVATE +target_include_directories(core_particleeditor PRIVATE include res ) -target_link_libraries(z_particleeditor PRIVATE +target_link_libraries(core_particleeditor PRIVATE core_debug core_profile + corei_always_no_pch + corei_gameengine_include corei_libraries_source_wwvegas corei_libraries_source_wwvegas_wwlib - d3d8lib - imm32 - core_config stlport - vfw32 - winmm - zi_gameengine_include - zi_always - zi_libraries_source_wwvegas ) if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") - target_link_options(z_particleeditor PRIVATE /NODEFAULTLIB:libci.lib /NODEFAULTLIB:libc.lib) - target_compile_definitions(z_particleeditor PRIVATE _AFXDLL) - target_sources(z_particleeditor PRIVATE ParticleEditor.rc) - set_target_properties(z_particleeditor PROPERTIES OUTPUT_NAME ParticleEditor) + target_link_options(core_particleeditor PRIVATE /NODEFAULTLIB:libci.lib /NODEFAULTLIB:libc.lib) + target_compile_definitions(core_particleeditor PRIVATE _AFXDLL) + target_sources(core_particleeditor PRIVATE ParticleEditor.rc) + set_target_properties(core_particleeditor PROPERTIES OUTPUT_NAME ParticleEditor) else() - set_target_properties(z_particleeditor PROPERTIES OUTPUT_NAME particleeditor) + set_target_properties(core_particleeditor PROPERTIES OUTPUT_NAME particleeditor) endif() diff --git a/GeneralsMD/Code/Tools/ParticleEditor/CParticleEditorPage.h b/Core/Tools/ParticleEditor/CParticleEditorPage.h similarity index 92% rename from GeneralsMD/Code/Tools/ParticleEditor/CParticleEditorPage.h rename to Core/Tools/ParticleEditor/CParticleEditorPage.h index bc932935799..b6365147eb5 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/CParticleEditorPage.h +++ b/Core/Tools/ParticleEditor/CParticleEditorPage.h @@ -22,7 +22,7 @@ struct CParticleEditorPage : public CDialog { UINT m_templateID; public: - CParticleEditorPage(UINT nIDTemplate = 0, CWnd* pParentWnd = NULL); + CParticleEditorPage(UINT nIDTemplate = 0, CWnd* pParentWnd = nullptr); void InitPanel( int templateID ); diff --git a/GeneralsMD/Code/Tools/ParticleEditor/CSwitchesDialog.cpp b/Core/Tools/ParticleEditor/CSwitchesDialog.cpp similarity index 100% rename from GeneralsMD/Code/Tools/ParticleEditor/CSwitchesDialog.cpp rename to Core/Tools/ParticleEditor/CSwitchesDialog.cpp diff --git a/GeneralsMD/Code/Tools/ParticleEditor/CSwitchesDialog.h b/Core/Tools/ParticleEditor/CSwitchesDialog.h similarity index 98% rename from GeneralsMD/Code/Tools/ParticleEditor/CSwitchesDialog.h rename to Core/Tools/ParticleEditor/CSwitchesDialog.h index 5b467b0c2b4..35adbf77c27 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/CSwitchesDialog.h +++ b/Core/Tools/ParticleEditor/CSwitchesDialog.h @@ -26,7 +26,7 @@ class CSwitchesDialog : public CDialog { public: enum {IDD = IDD_PSEd_EditSwitchesDialog}; - CSwitchesDialog(UINT nIDTemplate = CSwitchesDialog::IDD, CWnd* pParentWnd = NULL); + CSwitchesDialog(UINT nIDTemplate = CSwitchesDialog::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); diff --git a/GeneralsMD/Code/Tools/ParticleEditor/EmissionTypePanels.cpp b/Core/Tools/ParticleEditor/EmissionTypePanels.cpp similarity index 100% rename from GeneralsMD/Code/Tools/ParticleEditor/EmissionTypePanels.cpp rename to Core/Tools/ParticleEditor/EmissionTypePanels.cpp diff --git a/GeneralsMD/Code/Tools/ParticleEditor/EmissionTypePanels.h b/Core/Tools/ParticleEditor/EmissionTypePanels.h similarity index 97% rename from GeneralsMD/Code/Tools/ParticleEditor/EmissionTypePanels.h rename to Core/Tools/ParticleEditor/EmissionTypePanels.h index 347c65f152d..300973ed21a 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/EmissionTypePanels.h +++ b/Core/Tools/ParticleEditor/EmissionTypePanels.h @@ -49,7 +49,7 @@ class EmissionPanelPoint : public ISwapablePanel public: enum {IDD = IDD_PSEd_EmissionPanelPoint}; virtual DWORD GetIDD( void ) { return IDD; } - EmissionPanelPoint(UINT nIDTemplate = EmissionPanelPoint::IDD, CWnd* pParentWnd = NULL); + EmissionPanelPoint(UINT nIDTemplate = EmissionPanelPoint::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); @@ -67,7 +67,7 @@ class EmissionPanelLine : public ISwapablePanel public: enum {IDD = IDD_PSEd_EmissionPanelLine}; virtual DWORD GetIDD( void ) { return IDD; } - EmissionPanelLine(UINT nIDTemplate = EmissionPanelLine::IDD, CWnd* pParentWnd = NULL); + EmissionPanelLine(UINT nIDTemplate = EmissionPanelLine::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); @@ -85,7 +85,7 @@ class EmissionPanelBox : public ISwapablePanel public: enum {IDD = IDD_PSEd_EmissionPanelBox}; virtual DWORD GetIDD( void ) { return IDD; } - EmissionPanelBox(UINT nIDTemplate = EmissionPanelBox::IDD, CWnd* pParentWnd = NULL); + EmissionPanelBox(UINT nIDTemplate = EmissionPanelBox::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); @@ -103,7 +103,7 @@ class EmissionPanelSphere : public ISwapablePanel public: enum {IDD = IDD_PSEd_EmissionPanelSphere}; virtual DWORD GetIDD( void ) { return IDD; } - EmissionPanelSphere(UINT nIDTemplate = EmissionPanelSphere::IDD, CWnd* pParentWnd = NULL); + EmissionPanelSphere(UINT nIDTemplate = EmissionPanelSphere::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); @@ -121,7 +121,7 @@ class EmissionPanelCylinder : public ISwapablePanel public: enum {IDD = IDD_PSEd_EmissionPanelCylinder}; virtual DWORD GetIDD( void ) { return IDD; } - EmissionPanelCylinder(UINT nIDTemplate = EmissionPanelCylinder::IDD, CWnd* pParentWnd = NULL); + EmissionPanelCylinder(UINT nIDTemplate = EmissionPanelCylinder::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); diff --git a/GeneralsMD/Code/Tools/ParticleEditor/ISwapablePanel.h b/Core/Tools/ParticleEditor/ISwapablePanel.h similarity index 95% rename from GeneralsMD/Code/Tools/ParticleEditor/ISwapablePanel.h rename to Core/Tools/ParticleEditor/ISwapablePanel.h index 96b12558989..2461474bcc1 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/ISwapablePanel.h +++ b/Core/Tools/ParticleEditor/ISwapablePanel.h @@ -43,7 +43,7 @@ interface ISwapablePanel : public CDialog { - ISwapablePanel(UINT nIDTemplate = 0, CWnd* pParentWnd = NULL) : CDialog(nIDTemplate, pParentWnd) {} + ISwapablePanel(UINT nIDTemplate = 0, CWnd* pParentWnd = nullptr) : CDialog(nIDTemplate, pParentWnd) {} virtual DWORD GetIDD( void ) = 0; virtual void performUpdate( IN Bool toUI ) = 0; virtual void InitPanel( void ) = 0; diff --git a/GeneralsMD/Code/Tools/ParticleEditor/MoreParmsDialog.cpp b/Core/Tools/ParticleEditor/MoreParmsDialog.cpp similarity index 100% rename from GeneralsMD/Code/Tools/ParticleEditor/MoreParmsDialog.cpp rename to Core/Tools/ParticleEditor/MoreParmsDialog.cpp diff --git a/GeneralsMD/Code/Tools/ParticleEditor/MoreParmsDialog.h b/Core/Tools/ParticleEditor/MoreParmsDialog.h similarity index 99% rename from GeneralsMD/Code/Tools/ParticleEditor/MoreParmsDialog.h rename to Core/Tools/ParticleEditor/MoreParmsDialog.h index a8be3b1cd48..06555e88b8a 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/MoreParmsDialog.h +++ b/Core/Tools/ParticleEditor/MoreParmsDialog.h @@ -45,7 +45,7 @@ class MoreParmsDialog : public CDialog { public: enum { IDD = IDD_PSEd_EditMoreParms }; - MoreParmsDialog(UINT nIDTemplate = MoreParmsDialog::IDD, CWnd* pParentWnd = NULL); + MoreParmsDialog(UINT nIDTemplate = MoreParmsDialog::IDD, CWnd* pParentWnd = nullptr); virtual ~MoreParmsDialog(); void InitPanel( void ); diff --git a/GeneralsMD/Code/Tools/ParticleEditor/ParticleEditor.cpp b/Core/Tools/ParticleEditor/ParticleEditor.cpp similarity index 98% rename from GeneralsMD/Code/Tools/ParticleEditor/ParticleEditor.cpp rename to Core/Tools/ParticleEditor/ParticleEditor.cpp index 00e8a591c92..781b4f66a6d 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/ParticleEditor.cpp +++ b/Core/Tools/ParticleEditor/ParticleEditor.cpp @@ -73,7 +73,7 @@ CDebugWindowApp::CDebugWindowApp() { AfxInitialize(true); AFX_MANAGE_STATE(AfxGetStaticModuleState( )); - m_DialogWindow = NULL; + m_DialogWindow = nullptr; } @@ -104,9 +104,9 @@ void __declspec(dllexport) CreateParticleSystemDialog(void) DebugWindowDialog* tmpWnd; tmpWnd = new DebugWindowDialog; - tmpWnd->Create(DebugWindowDialog::IDD, NULL); + tmpWnd->Create(DebugWindowDialog::IDD, nullptr); - tmpWnd->SetWindowPos(NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER); + tmpWnd->SetWindowPos(nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOZORDER); tmpWnd->InitPanel(); tmpWnd->ShowWindow(SW_SHOW); if (tmpWnd->GetMainWndHWND()) { @@ -126,7 +126,7 @@ void __declspec(dllexport) DestroyParticleSystemDialog(void) if (tmpWnd) { tmpWnd->DestroyWindow(); delete tmpWnd; - theApp.SetDialogWindow(NULL); + theApp.SetDialogWindow(nullptr); } } catch (...) { } } diff --git a/Generals/Code/Tools/ParticleEditor/ParticleEditor.def b/Core/Tools/ParticleEditor/ParticleEditor.def similarity index 100% rename from Generals/Code/Tools/ParticleEditor/ParticleEditor.def rename to Core/Tools/ParticleEditor/ParticleEditor.def diff --git a/GeneralsMD/Code/Tools/ParticleEditor/ParticleEditor.h b/Core/Tools/ParticleEditor/ParticleEditor.h similarity index 100% rename from GeneralsMD/Code/Tools/ParticleEditor/ParticleEditor.h rename to Core/Tools/ParticleEditor/ParticleEditor.h diff --git a/Generals/Code/Tools/ParticleEditor/ParticleEditor.rc b/Core/Tools/ParticleEditor/ParticleEditor.rc similarity index 100% rename from Generals/Code/Tools/ParticleEditor/ParticleEditor.rc rename to Core/Tools/ParticleEditor/ParticleEditor.rc diff --git a/Generals/Code/Tools/ParticleEditor/ParticleEditorDialog.cpp b/Core/Tools/ParticleEditor/ParticleEditorDialog.cpp similarity index 97% rename from Generals/Code/Tools/ParticleEditor/ParticleEditorDialog.cpp rename to Core/Tools/ParticleEditor/ParticleEditorDialog.cpp index 670b92543b1..ace9b9650fc 100644 --- a/Generals/Code/Tools/ParticleEditor/ParticleEditorDialog.cpp +++ b/Core/Tools/ParticleEditor/ParticleEditorDialog.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 @@ -35,11 +35,11 @@ m_colorAlphaDialog(CColorAlphaDialog::IDD, this), m_switchesDialog(CSwitchesDialog::IDD, this), m_moreParmsDialog(MoreParmsDialog::IDD, this) { - mMainWndHWND = ::FindWindow(NULL, "Command & Conquer: Generals"); + mMainWndHWND = ::FindWindow(nullptr, "Command & Conquer: Generals"); m_activeEmissionPage = 0; m_activeVelocityPage = 0; m_activeParticlePage = 0; - m_particleSystem = NULL; + m_particleSystem = nullptr; m_changeHasOcurred = false; @@ -157,7 +157,7 @@ void DebugWindowDialog::InitPanel( void ) m_emissionTypePanels[j]->Create(m_emissionTypePanels[j]->GetIDD(), this); m_emissionTypePanels[j]->InitPanel(); m_emissionTypePanels[j]->ShowWindow(SW_HIDE); - m_emissionTypePanels[j]->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER); + m_emissionTypePanels[j]->SetWindowPos(nullptr, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER); } pWnd->ShowWindow(SW_HIDE); m_emissionTypePanels[0]->ShowWindow(SW_SHOW); @@ -172,7 +172,7 @@ void DebugWindowDialog::InitPanel( void ) m_velocityTypePanels[j]->Create(m_velocityTypePanels[j]->GetIDD(), this); m_velocityTypePanels[j]->InitPanel(); m_velocityTypePanels[j]->ShowWindow(SW_HIDE); - m_velocityTypePanels[j]->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER); + m_velocityTypePanels[j]->SetWindowPos(nullptr, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER); } pWnd->ShowWindow(SW_HIDE); m_velocityTypePanels[0]->ShowWindow(SW_SHOW); @@ -187,7 +187,7 @@ void DebugWindowDialog::InitPanel( void ) m_particleTypePanels[j]->Create(m_particleTypePanels[j]->GetIDD(), this); m_particleTypePanels[j]->InitPanel(); m_particleTypePanels[j]->ShowWindow(SW_HIDE); - m_particleTypePanels[j]->SetWindowPos(NULL, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER); + m_particleTypePanels[j]->SetWindowPos(nullptr, rect.left, rect.top, rect.Width(), rect.Height(), SWP_NOZORDER); } pWnd->ShowWindow(SW_HIDE); m_particleTypePanels[0]->ShowWindow(SW_SHOW); @@ -1342,22 +1342,34 @@ void DebugWindowDialog::performUpdate( IN Bool toUI ) pWnd = GetDlgItem(IDC_PSEd_AngleXMin); if (pWnd) { if (toUI) { +#if PARTICLE_USE_XY_ROTATION sprintf(buff, FORMAT_STRING, m_particleSystem->m_angleX.getMinimumValue()); +#else + sprintf(buff, FORMAT_STRING, 0.0f); +#endif pWnd->SetWindowText(buff); } else { +#if PARTICLE_USE_XY_ROTATION pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); m_particleSystem->m_angleX.m_low = atof(buff); +#endif } } pWnd = GetDlgItem(IDC_PSEd_AngleYMin); if (pWnd) { if (toUI) { +#if PARTICLE_USE_XY_ROTATION sprintf(buff, FORMAT_STRING, m_particleSystem->m_angleY.getMinimumValue()); +#else + sprintf(buff, FORMAT_STRING, 0.0f); +#endif pWnd->SetWindowText(buff); } else { +#if PARTICLE_USE_XY_ROTATION pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); m_particleSystem->m_angleY.m_low = atof(buff); +#endif } } @@ -1375,22 +1387,34 @@ void DebugWindowDialog::performUpdate( IN Bool toUI ) pWnd = GetDlgItem(IDC_PSEd_AngleXMax); if (pWnd) { if (toUI) { +#if PARTICLE_USE_XY_ROTATION sprintf(buff, FORMAT_STRING, m_particleSystem->m_angleX.getMaximumValue()); +#else + sprintf(buff, FORMAT_STRING, 0.0f); +#endif pWnd->SetWindowText(buff); } else { +#if PARTICLE_USE_XY_ROTATION pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); m_particleSystem->m_angleX.m_high = atof(buff); +#endif } } pWnd = GetDlgItem(IDC_PSEd_AngleYMax); if (pWnd) { if (toUI) { +#if PARTICLE_USE_XY_ROTATION sprintf(buff, FORMAT_STRING, m_particleSystem->m_angleY.getMaximumValue()); +#else + sprintf(buff, FORMAT_STRING, 0.0f); +#endif pWnd->SetWindowText(buff); } else { +#if PARTICLE_USE_XY_ROTATION pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); m_particleSystem->m_angleY.m_high = atof(buff); +#endif } } @@ -1408,22 +1432,34 @@ void DebugWindowDialog::performUpdate( IN Bool toUI ) pWnd = GetDlgItem(IDC_PSEd_AngularRateXMin); if (pWnd) { if (toUI) { +#if PARTICLE_USE_XY_ROTATION sprintf(buff, FORMAT_STRING, m_particleSystem->m_angularRateX.getMinimumValue()); +#else + sprintf(buff, FORMAT_STRING, 0.0f); +#endif pWnd->SetWindowText(buff); } else { +#if PARTICLE_USE_XY_ROTATION pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); m_particleSystem->m_angularRateX.m_low = atof(buff); +#endif } } pWnd = GetDlgItem(IDC_PSEd_AngularRateYMin); if (pWnd) { if (toUI) { +#if PARTICLE_USE_XY_ROTATION sprintf(buff, FORMAT_STRING, m_particleSystem->m_angularRateY.getMinimumValue()); +#else + sprintf(buff, FORMAT_STRING, 0.0f); +#endif pWnd->SetWindowText(buff); } else { +#if PARTICLE_USE_XY_ROTATION pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); m_particleSystem->m_angularRateY.m_low = atof(buff); +#endif } } @@ -1441,22 +1477,34 @@ void DebugWindowDialog::performUpdate( IN Bool toUI ) pWnd = GetDlgItem(IDC_PSEd_AngularRateXMax); if (pWnd) { if (toUI) { +#if PARTICLE_USE_XY_ROTATION sprintf(buff, FORMAT_STRING, m_particleSystem->m_angularRateX.getMaximumValue()); +#else + sprintf(buff, FORMAT_STRING, 0.0f); +#endif pWnd->SetWindowText(buff); } else { +#if PARTICLE_USE_XY_ROTATION pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); m_particleSystem->m_angularRateX.m_high = atof(buff); +#endif } } pWnd = GetDlgItem(IDC_PSEd_AngularRateYMax); if (pWnd) { if (toUI) { +#if PARTICLE_USE_XY_ROTATION sprintf(buff, FORMAT_STRING, m_particleSystem->m_angularRateY.getMaximumValue()); +#else + sprintf(buff, FORMAT_STRING, 0.0f); +#endif pWnd->SetWindowText(buff); } else { +#if PARTICLE_USE_XY_ROTATION pWnd->GetWindowText(buff, ARBITRARY_BUFF_SIZE - 1); m_particleSystem->m_angularRateY.m_high = atof(buff); +#endif } } diff --git a/GeneralsMD/Code/Tools/ParticleEditor/ParticleEditorDialog.h b/Core/Tools/ParticleEditor/ParticleEditorDialog.h similarity index 99% rename from GeneralsMD/Code/Tools/ParticleEditor/ParticleEditorDialog.h rename to Core/Tools/ParticleEditor/ParticleEditorDialog.h index b38afd9d18f..52a5783c4e0 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/ParticleEditorDialog.h +++ b/Core/Tools/ParticleEditor/ParticleEditorDialog.h @@ -54,7 +54,7 @@ class DebugWindowDialog : public CDialog { public: enum {IDD = IDD_PSEd}; - DebugWindowDialog(UINT nIDTemplate = DebugWindowDialog::IDD, CWnd* pParentWnd = NULL); + DebugWindowDialog(UINT nIDTemplate = DebugWindowDialog::IDD, CWnd* pParentWnd = nullptr); virtual ~DebugWindowDialog(); void InitPanel( void ); diff --git a/GeneralsMD/Code/Tools/ParticleEditor/ParticleEditorExport.h b/Core/Tools/ParticleEditor/ParticleEditorExport.h similarity index 100% rename from GeneralsMD/Code/Tools/ParticleEditor/ParticleEditorExport.h rename to Core/Tools/ParticleEditor/ParticleEditorExport.h diff --git a/GeneralsMD/Code/Tools/ParticleEditor/ParticleTypePanels.cpp b/Core/Tools/ParticleEditor/ParticleTypePanels.cpp similarity index 100% rename from GeneralsMD/Code/Tools/ParticleEditor/ParticleTypePanels.cpp rename to Core/Tools/ParticleEditor/ParticleTypePanels.cpp diff --git a/GeneralsMD/Code/Tools/ParticleEditor/ParticleTypePanels.h b/Core/Tools/ParticleEditor/ParticleTypePanels.h similarity index 97% rename from GeneralsMD/Code/Tools/ParticleEditor/ParticleTypePanels.h rename to Core/Tools/ParticleEditor/ParticleTypePanels.h index 3858e1256a5..a11b9966488 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/ParticleTypePanels.h +++ b/Core/Tools/ParticleEditor/ParticleTypePanels.h @@ -48,7 +48,7 @@ class ParticlePanelParticle : public ISwapablePanel public: enum {IDD = IDD_PSEd_ParticlePanelParticle}; virtual DWORD GetIDD( void ) { return IDD; } - ParticlePanelParticle(UINT nIDTemplate = ParticlePanelParticle::IDD, CWnd* pParentWnd = NULL); + ParticlePanelParticle(UINT nIDTemplate = ParticlePanelParticle::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); @@ -66,7 +66,7 @@ class ParticlePanelDrawable : public ISwapablePanel public: enum {IDD = IDD_PSEd_ParticlePanelDrawable}; virtual DWORD GetIDD( void ) { return IDD; } - ParticlePanelDrawable(UINT nIDTemplate = ParticlePanelDrawable::IDD, CWnd* pParentWnd = NULL); + ParticlePanelDrawable(UINT nIDTemplate = ParticlePanelDrawable::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); void clearAllThingTemplates( void ); @@ -85,7 +85,7 @@ class ParticlePanelStreak : public ParticlePanelParticle public: enum {IDD = IDD_PSEd_ParticlePanelStreak}; virtual DWORD GetIDD( void ) { return IDD; } - ParticlePanelStreak(UINT nIDTemplate = ParticlePanelStreak::IDD, CWnd* pParentWnd = NULL); + ParticlePanelStreak(UINT nIDTemplate = ParticlePanelStreak::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); diff --git a/GeneralsMD/Code/Tools/ParticleEditor/Resource.h b/Core/Tools/ParticleEditor/Resource.h similarity index 100% rename from GeneralsMD/Code/Tools/ParticleEditor/Resource.h rename to Core/Tools/ParticleEditor/Resource.h diff --git a/GeneralsMD/Code/Tools/ParticleEditor/ShaderTypePanels.cpp b/Core/Tools/ParticleEditor/ShaderTypePanels.cpp similarity index 100% rename from GeneralsMD/Code/Tools/ParticleEditor/ShaderTypePanels.cpp rename to Core/Tools/ParticleEditor/ShaderTypePanels.cpp diff --git a/GeneralsMD/Code/Tools/ParticleEditor/ShaderTypePanels.h b/Core/Tools/ParticleEditor/ShaderTypePanels.h similarity index 100% rename from GeneralsMD/Code/Tools/ParticleEditor/ShaderTypePanels.h rename to Core/Tools/ParticleEditor/ShaderTypePanels.h diff --git a/GeneralsMD/Code/Tools/ParticleEditor/StdAfx.cpp b/Core/Tools/ParticleEditor/StdAfx.cpp similarity index 100% rename from GeneralsMD/Code/Tools/ParticleEditor/StdAfx.cpp rename to Core/Tools/ParticleEditor/StdAfx.cpp diff --git a/GeneralsMD/Code/Tools/ParticleEditor/StdAfx.h b/Core/Tools/ParticleEditor/StdAfx.h similarity index 96% rename from GeneralsMD/Code/Tools/ParticleEditor/StdAfx.h rename to Core/Tools/ParticleEditor/StdAfx.h index a5879cdae31..bd5d8643fe4 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/StdAfx.h +++ b/Core/Tools/ParticleEditor/StdAfx.h @@ -54,7 +54,7 @@ // I don't care that debug symbols are longer than 255, I won't read them anyways. #pragma warning (disable : 4786) -// Define IN and OUT. Use them for sementic emphasis. +// Define IN and OUT. Use them for semantic emphasis. #ifndef IN # define IN #endif @@ -70,3 +70,5 @@ //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. + +#include diff --git a/GeneralsMD/Code/Tools/ParticleEditor/VelocityTypePanels.cpp b/Core/Tools/ParticleEditor/VelocityTypePanels.cpp similarity index 99% rename from GeneralsMD/Code/Tools/ParticleEditor/VelocityTypePanels.cpp rename to Core/Tools/ParticleEditor/VelocityTypePanels.cpp index b1dbfaa6df7..72da56265b8 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/VelocityTypePanels.cpp +++ b/Core/Tools/ParticleEditor/VelocityTypePanels.cpp @@ -16,7 +16,6 @@ ** along with this program. If not, see . */ - // FILE: VelocityTypePanels.cpp /*---------------------------------------------------------------------------*/ /* EA Pacific */ diff --git a/GeneralsMD/Code/Tools/ParticleEditor/VelocityTypePanels.h b/Core/Tools/ParticleEditor/VelocityTypePanels.h similarity index 96% rename from GeneralsMD/Code/Tools/ParticleEditor/VelocityTypePanels.h rename to Core/Tools/ParticleEditor/VelocityTypePanels.h index ecc4ac07382..9a1c0207aff 100644 --- a/GeneralsMD/Code/Tools/ParticleEditor/VelocityTypePanels.h +++ b/Core/Tools/ParticleEditor/VelocityTypePanels.h @@ -49,7 +49,7 @@ class VelocityPanelOrtho : public ISwapablePanel public: enum {IDD = IDD_PSEd_VelocityPanelOrtho}; virtual DWORD GetIDD( void ) { return IDD; } - VelocityPanelOrtho(UINT nIDTemplate = VelocityPanelOrtho::IDD, CWnd* pParentWnd = NULL); + VelocityPanelOrtho(UINT nIDTemplate = VelocityPanelOrtho::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); @@ -67,7 +67,7 @@ class VelocityPanelSphere : public ISwapablePanel public: enum {IDD = IDD_PSEd_VelocityPanelSphere}; virtual DWORD GetIDD( void ) { return IDD; } - VelocityPanelSphere(UINT nIDTemplate = VelocityPanelSphere::IDD, CWnd* pParentWnd = NULL); + VelocityPanelSphere(UINT nIDTemplate = VelocityPanelSphere::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); @@ -85,7 +85,7 @@ class VelocityPanelHemisphere : public ISwapablePanel public: enum {IDD = IDD_PSEd_VelocityPanelHemisphere}; virtual DWORD GetIDD( void ) { return IDD; } - VelocityPanelHemisphere(UINT nIDTemplate = VelocityPanelHemisphere::IDD, CWnd* pParentWnd = NULL); + VelocityPanelHemisphere(UINT nIDTemplate = VelocityPanelHemisphere::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); @@ -103,7 +103,7 @@ class VelocityPanelCylinder : public ISwapablePanel public: enum {IDD = IDD_PSEd_VelocityPanelCylinder}; virtual DWORD GetIDD( void ) { return IDD; } - VelocityPanelCylinder(UINT nIDTemplate = VelocityPanelCylinder::IDD, CWnd* pParentWnd = NULL); + VelocityPanelCylinder(UINT nIDTemplate = VelocityPanelCylinder::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); @@ -121,7 +121,7 @@ class VelocityPanelOutward : public ISwapablePanel public: enum {IDD = IDD_PSEd_VelocityPanelOutward}; virtual DWORD GetIDD( void ) { return IDD; } - VelocityPanelOutward(UINT nIDTemplate = VelocityPanelOutward::IDD, CWnd* pParentWnd = NULL); + VelocityPanelOutward(UINT nIDTemplate = VelocityPanelOutward::IDD, CWnd* pParentWnd = nullptr); void InitPanel( void ); diff --git a/Generals/Code/Tools/ParticleEditor/post-build-Release.bat b/Core/Tools/ParticleEditor/post-build-Release.bat similarity index 100% rename from Generals/Code/Tools/ParticleEditor/post-build-Release.bat rename to Core/Tools/ParticleEditor/post-build-Release.bat diff --git a/Generals/Code/Tools/ParticleEditor/post-build.bat b/Core/Tools/ParticleEditor/post-build.bat similarity index 100% rename from Generals/Code/Tools/ParticleEditor/post-build.bat rename to Core/Tools/ParticleEditor/post-build.bat diff --git a/Generals/Code/Tools/ParticleEditor/res/ParticleEditor.rc2 b/Core/Tools/ParticleEditor/res/ParticleEditor.rc2 similarity index 100% rename from Generals/Code/Tools/ParticleEditor/res/ParticleEditor.rc2 rename to Core/Tools/ParticleEditor/res/ParticleEditor.rc2 diff --git a/Core/Tools/W3DView/AddToLineupDialog.cpp b/Core/Tools/W3DView/AddToLineupDialog.cpp index 94dc34e0414..06feb6e3616 100644 --- a/Core/Tools/W3DView/AddToLineupDialog.cpp +++ b/Core/Tools/W3DView/AddToLineupDialog.cpp @@ -38,7 +38,7 @@ static char THIS_FILE[] = __FILE__; // CAddToLineupDialog dialog -CAddToLineupDialog::CAddToLineupDialog(ViewerSceneClass *scene, CWnd* pParent /*=NULL*/) +CAddToLineupDialog::CAddToLineupDialog(ViewerSceneClass *scene, CWnd* pParent /*=nullptr*/) : CDialog(CAddToLineupDialog::IDD, pParent), m_pCScene(scene) { @@ -79,9 +79,9 @@ BOOL CAddToLineupDialog::OnInitDialog() // Populate the combo box with the names of the objects that // can be added to the lineup. WW3DAssetManager *assets = WW3DAssetManager::Get_Instance(); - ASSERT(assets != NULL); + ASSERT(assets != nullptr); RenderObjIterator *it = assets->Create_Render_Obj_Iterator(); - ASSERT(it != NULL); + ASSERT(it != nullptr); for (; !it->Is_Done(); it->Next()) { if (m_pCScene->Can_Line_Up(it->Current_Item_Class_ID())) diff --git a/Core/Tools/W3DView/AddToLineupDialog.h b/Core/Tools/W3DView/AddToLineupDialog.h index 5c331479da1..37c17c1f2db 100644 --- a/Core/Tools/W3DView/AddToLineupDialog.h +++ b/Core/Tools/W3DView/AddToLineupDialog.h @@ -30,7 +30,7 @@ class CAddToLineupDialog : public CDialog { // Construction public: - CAddToLineupDialog(ViewerSceneClass *scene, CWnd* pParent = NULL); // standard constructor + CAddToLineupDialog(ViewerSceneClass *scene, CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CAddToLineupDialog) diff --git a/Core/Tools/W3DView/AdvancedAnimSheet.cpp b/Core/Tools/W3DView/AdvancedAnimSheet.cpp index 4c57a38b2d4..72b1ba5c7c1 100644 --- a/Core/Tools/W3DView/AdvancedAnimSheet.cpp +++ b/Core/Tools/W3DView/AdvancedAnimSheet.cpp @@ -42,8 +42,8 @@ static char THIS_FILE[] = __FILE__; // Will compare their names. static int anim_name_compare (const void *arg1, const void *arg2) { - ASSERT(arg1 != NULL); - ASSERT(arg2 != NULL); + ASSERT(arg1 != nullptr); + ASSERT(arg2 != nullptr); HAnimClass *a1 = *(HAnimClass**)arg1; HAnimClass *a2 = *(HAnimClass**)arg2; return _stricmp( a1->Get_Name(), a2->Get_Name() ); @@ -117,7 +117,7 @@ HAnimClass ** CAdvancedAnimSheet::GetAnims (void) LoadAnims(); // Return the array regardless of validity. If the entries are - // invalid, they'll all be NULL, but the array itself is cool. + // invalid, they'll all be nullptr, but the array itself is cool. return Anims; } @@ -127,10 +127,10 @@ void CAdvancedAnimSheet::LoadAnims (void) // Get the current render object and it's HTree. If it doesn't have // an HTree, then it's not animating and we're not interested. RenderObjClass *robj = ::GetCurrentDocument()->GetDisplayedObject(); - if (robj == NULL) + if (robj == nullptr) return; const HTreeClass *htree = robj->Get_HTree(); - if (htree == NULL) + if (htree == nullptr) return; const char *htree_name = htree->Get_Name(); @@ -142,7 +142,7 @@ void CAdvancedAnimSheet::LoadAnims (void) // Get an iterator from the asset manager that we can // use to enumerate the currently loaded assets AssetIterator *pAnimEnum = WW3DAssetManager::Get_Instance()->Create_HAnim_Iterator(); - ASSERT(pAnimEnum != NULL); + ASSERT(pAnimEnum != nullptr); if (pAnimEnum) { // Loop through all the animations in the manager @@ -153,7 +153,7 @@ void CAdvancedAnimSheet::LoadAnims (void) // Get an instance of the animation object HAnimClass *pHierarchyAnim = WW3DAssetManager::Get_Instance()->Get_HAnim(pszAnimName); - ASSERT(pHierarchyAnim != NULL); + ASSERT(pHierarchyAnim != nullptr); if (pHierarchyAnim) { // Does this animation apply to the current model's HTree? @@ -182,7 +182,7 @@ void CAdvancedAnimSheet::LoadAnims (void) // Free the object delete pAnimEnum; - pAnimEnum = NULL; + pAnimEnum = nullptr; } /* diff --git a/Core/Tools/W3DView/AdvancedAnimSheet.h b/Core/Tools/W3DView/AdvancedAnimSheet.h index 691787da8d1..fd2bf23f419 100644 --- a/Core/Tools/W3DView/AdvancedAnimSheet.h +++ b/Core/Tools/W3DView/AdvancedAnimSheet.h @@ -37,7 +37,7 @@ class CAdvancedAnimSheet : public CPropertySheet // Construction public: - CAdvancedAnimSheet(CWnd *pParentWnd = NULL, UINT iSelectPage = 0); + CAdvancedAnimSheet(CWnd *pParentWnd = nullptr, UINT iSelectPage = 0); // Attributes public: @@ -46,7 +46,7 @@ class CAdvancedAnimSheet : public CPropertySheet CAnimMixingPage m_MixingPage; CAnimReportPage m_ReportPage; - // Indeces of animations selected in the mixing page. + // Indices of animations selected in the mixing page. DynamicVectorClass m_SelectedAnims; // Operations diff --git a/Core/Tools/W3DView/AggregateNameDialog.cpp b/Core/Tools/W3DView/AggregateNameDialog.cpp index a8f1f1e8d4b..37b1a88093b 100644 --- a/Core/Tools/W3DView/AggregateNameDialog.cpp +++ b/Core/Tools/W3DView/AggregateNameDialog.cpp @@ -48,7 +48,7 @@ static char THIS_FILE[] = __FILE__; // // AggregateNameDialogClass // -AggregateNameDialogClass::AggregateNameDialogClass (CWnd* pParent /*=NULL*/) +AggregateNameDialogClass::AggregateNameDialogClass (CWnd* pParent /*=nullptr*/) : CDialog(AggregateNameDialogClass::IDD, pParent) { //{{AFX_DATA_INIT(AggregateNameDialogClass) diff --git a/Core/Tools/W3DView/AggregateNameDialog.h b/Core/Tools/W3DView/AggregateNameDialog.h index 2d71d778dc0..ec9c700bb15 100644 --- a/Core/Tools/W3DView/AggregateNameDialog.h +++ b/Core/Tools/W3DView/AggregateNameDialog.h @@ -28,8 +28,8 @@ class AggregateNameDialogClass : public CDialog { // Construction public: - AggregateNameDialogClass(CWnd* pParent = NULL); - AggregateNameDialogClass(UINT resource_id, const CString &def_name, CWnd* pParent = NULL); + AggregateNameDialogClass(CWnd* pParent = nullptr); + AggregateNameDialogClass(UINT resource_id, const CString &def_name, CWnd* pParent = nullptr); // Dialog Data //{{AFX_DATA(AggregateNameDialogClass) diff --git a/Core/Tools/W3DView/AmbientLightDialog.cpp b/Core/Tools/W3DView/AmbientLightDialog.cpp index d5e1abc29dd..708d9cbe64a 100644 --- a/Core/Tools/W3DView/AmbientLightDialog.cpp +++ b/Core/Tools/W3DView/AmbientLightDialog.cpp @@ -39,7 +39,7 @@ static char THIS_FILE[] = __FILE__; // CAmbientLightDialog dialog -CAmbientLightDialog::CAmbientLightDialog(CWnd* pParent /*=NULL*/) +CAmbientLightDialog::CAmbientLightDialog(CWnd* pParent /*=nullptr*/) : CDialog(CAmbientLightDialog::IDD, pParent) { //{{AFX_DATA_INIT(CAmbientLightDialog) diff --git a/Core/Tools/W3DView/AmbientLightDialog.h b/Core/Tools/W3DView/AmbientLightDialog.h index 1ffd5dca663..7e6ae32f590 100644 --- a/Core/Tools/W3DView/AmbientLightDialog.h +++ b/Core/Tools/W3DView/AmbientLightDialog.h @@ -28,7 +28,7 @@ class CAmbientLightDialog : public CDialog { // Construction public: - CAmbientLightDialog(CWnd* pParent = NULL); // standard constructor + CAmbientLightDialog(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CAmbientLightDialog) diff --git a/Core/Tools/W3DView/AnimMixingPage.cpp b/Core/Tools/W3DView/AnimMixingPage.cpp index 34ed1675f53..59e45261146 100644 --- a/Core/Tools/W3DView/AnimMixingPage.cpp +++ b/Core/Tools/W3DView/AnimMixingPage.cpp @@ -76,7 +76,7 @@ BOOL CAnimMixingPage::OnInitDialog() { CPropertyPage::OnInitDialog(); - ASSERT(m_Sheet != NULL); + ASSERT(m_Sheet != nullptr); FillListCtrl(); return TRUE; // return TRUE unless you set the focus to a control @@ -89,10 +89,10 @@ void CAnimMixingPage::FillListCtrl (void) // Get the current render object and it's HTree. If it doesn't have // an HTree, then it's not animating and we're not interested. RenderObjClass *robj = ::GetCurrentDocument()->GetDisplayedObject(); - if (robj == NULL) + if (robj == nullptr) return; const HTreeClass *htree = robj->Get_HTree(); - if (htree == NULL) + if (htree == nullptr) return; // Get a sorted array of animations that affect the currently active object. @@ -114,12 +114,12 @@ void CAnimMixingPage::OnOK() RenderObjClass *current_obj = ::GetCurrentDocument()->GetDisplayedObject(); const char *obj_name = current_obj->Get_Name(); RenderObjClass *robj = WW3DAssetManager::Get_Instance()->Create_Render_Obj(obj_name); - if (num_selected > 0 && robj != NULL) + if (num_selected > 0 && robj != nullptr) { HAnimClass **anim = m_Sheet->GetAnims(); HAnimComboClass *combo = new HAnimComboClass(num_selected); - ASSERT(combo != NULL); + ASSERT(combo != nullptr); POSITION pos = m_AnimList.GetFirstSelectedItemPosition(); int array_idx, idx = 0; diff --git a/Core/Tools/W3DView/AnimMixingPage.h b/Core/Tools/W3DView/AnimMixingPage.h index 50c6c369d0b..77c1df481d2 100644 --- a/Core/Tools/W3DView/AnimMixingPage.h +++ b/Core/Tools/W3DView/AnimMixingPage.h @@ -32,7 +32,7 @@ class CAnimMixingPage : public CPropertyPage // Construction public: - CAnimMixingPage(CAdvancedAnimSheet *sheet = NULL); + CAnimMixingPage(CAdvancedAnimSheet *sheet = nullptr); ~CAnimMixingPage(); // Dialog Data diff --git a/Core/Tools/W3DView/AnimReportPage.cpp b/Core/Tools/W3DView/AnimReportPage.cpp index 1b5af2f3ce8..17286668dae 100644 --- a/Core/Tools/W3DView/AnimReportPage.cpp +++ b/Core/Tools/W3DView/AnimReportPage.cpp @@ -91,10 +91,10 @@ void CAnimReportPage::FillListControl() // Get the current render object and it's HTree. If it doesn't have // an HTree, then it's not animating and we're not interested. RenderObjClass *robj = ::GetCurrentDocument()->GetDisplayedObject(); - if (robj == NULL) + if (robj == nullptr) return; const HTreeClass *htree = robj->Get_HTree(); - if (htree == NULL) + if (htree == nullptr) return; // Get a sorted array of animations that affect the currently active object. diff --git a/Core/Tools/W3DView/AnimReportPage.h b/Core/Tools/W3DView/AnimReportPage.h index 8f5caac7406..d4933140e04 100644 --- a/Core/Tools/W3DView/AnimReportPage.h +++ b/Core/Tools/W3DView/AnimReportPage.h @@ -33,7 +33,7 @@ class CAnimReportPage : public CPropertyPage // Construction public: - CAnimReportPage(CAdvancedAnimSheet *sheet = NULL); + CAnimReportPage(CAdvancedAnimSheet *sheet = nullptr); ~CAnimReportPage(); // Dialog Data diff --git a/Core/Tools/W3DView/AnimatedSoundOptionsDialog.cpp b/Core/Tools/W3DView/AnimatedSoundOptionsDialog.cpp index 85584f00373..dea88570eca 100644 --- a/Core/Tools/W3DView/AnimatedSoundOptionsDialog.cpp +++ b/Core/Tools/W3DView/AnimatedSoundOptionsDialog.cpp @@ -44,7 +44,7 @@ static char THIS_FILE[] = __FILE__; // AnimatedSoundOptionsDialogClass dialog -AnimatedSoundOptionsDialogClass::AnimatedSoundOptionsDialogClass(CWnd* pParent /*=NULL*/) +AnimatedSoundOptionsDialogClass::AnimatedSoundOptionsDialogClass(CWnd* pParent /*=nullptr*/) : CDialog(AnimatedSoundOptionsDialogClass::IDD, pParent) { //{{AFX_DATA_INIT(AnimatedSoundOptionsDialogClass) @@ -204,7 +204,7 @@ AnimatedSoundOptionsDialogClass::Load_Animated_Sound_Settings (void) // Try to load the definitions into the definition mgr // FileClass *file = _TheFileFactory->Get_File (sound_def_lib_path); - if (file != NULL) { + if (file != nullptr) { file->Open (FileClass::READ); ChunkLoadClass cload (file); SaveLoadSystemClass::Load (cload); diff --git a/Core/Tools/W3DView/AnimatedSoundOptionsDialog.h b/Core/Tools/W3DView/AnimatedSoundOptionsDialog.h index 9024d742c38..b2afc10a5d1 100644 --- a/Core/Tools/W3DView/AnimatedSoundOptionsDialog.h +++ b/Core/Tools/W3DView/AnimatedSoundOptionsDialog.h @@ -28,7 +28,7 @@ class AnimatedSoundOptionsDialogClass : public CDialog { // Construction public: - AnimatedSoundOptionsDialogClass(CWnd* pParent = NULL); // standard constructor + AnimatedSoundOptionsDialogClass(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(AnimatedSoundOptionsDialogClass) diff --git a/Core/Tools/W3DView/AnimationSpeed.h b/Core/Tools/W3DView/AnimationSpeed.h index 0cd1c8894b0..e0626c745ea 100644 --- a/Core/Tools/W3DView/AnimationSpeed.h +++ b/Core/Tools/W3DView/AnimationSpeed.h @@ -28,7 +28,7 @@ class CAnimationSpeed : public CDialog { // Construction public: - CAnimationSpeed(CWnd* pParent = NULL); // standard constructor + CAnimationSpeed(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CAnimationSpeed) diff --git a/Core/Tools/W3DView/AssetInfo.cpp b/Core/Tools/W3DView/AssetInfo.cpp index 3b7092dcc62..0abd6dc3688 100644 --- a/Core/Tools/W3DView/AssetInfo.cpp +++ b/Core/Tools/W3DView/AssetInfo.cpp @@ -57,11 +57,11 @@ AssetInfoClass::Initialize (void) prender_obj->Add_Ref(); // If we are wrapping an asset name, then create an instance of it. - if (prender_obj == NULL) { + if (prender_obj == nullptr) { prender_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj (m_Name); } - if (prender_obj != NULL) { + if (prender_obj != nullptr) { // Get the hierarchy tree for this object (if one exists) const HTreeClass *phtree = prender_obj->Get_HTree (); diff --git a/Core/Tools/W3DView/AssetInfo.h b/Core/Tools/W3DView/AssetInfo.h index 1ba0adf5e0c..8655a3363b8 100644 --- a/Core/Tools/W3DView/AssetInfo.h +++ b/Core/Tools/W3DView/AssetInfo.h @@ -59,13 +59,13 @@ class AssetInfoClass AssetInfoClass (void) : m_AssetType (TypeUnknown), m_dwUserData (0L), - m_pRenderObj (NULL) { Initialize (); } + m_pRenderObj (nullptr) { Initialize (); } - AssetInfoClass (LPCTSTR passet_name, ASSET_TYPE type, RenderObjClass *prender_obj = NULL, DWORD user_data = 0L) + AssetInfoClass (LPCTSTR passet_name, ASSET_TYPE type, RenderObjClass *prender_obj = nullptr, DWORD user_data = 0L) : m_Name (passet_name), m_AssetType (type), m_dwUserData (user_data), - m_pRenderObj (NULL) { REF_PTR_SET (m_pRenderObj, prender_obj); Initialize (); } + m_pRenderObj (nullptr) { REF_PTR_SET (m_pRenderObj, prender_obj); Initialize (); } virtual ~AssetInfoClass (void) { REF_PTR_RELEASE (m_pRenderObj); } diff --git a/Core/Tools/W3DView/AssetPropertySheet.h b/Core/Tools/W3DView/AssetPropertySheet.h index cb9446b6d08..c770b2f5752 100644 --- a/Core/Tools/W3DView/AssetPropertySheet.h +++ b/Core/Tools/W3DView/AssetPropertySheet.h @@ -30,7 +30,7 @@ class CAssetPropertySheet : public CPropertySheet // Construction public: - CAssetPropertySheet (int iCaptionID, CPropertyPage *pCPropertyPage, CWnd *pCParentWnd = NULL); + CAssetPropertySheet (int iCaptionID, CPropertyPage *pCPropertyPage, CWnd *pCParentWnd = nullptr); // Attributes public: @@ -56,8 +56,8 @@ class CAssetPropertySheet : public CPropertySheet private: // Private constructors (shouldn't be called) - CAssetPropertySheet(UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0) {} - CAssetPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0) {} + CAssetPropertySheet(UINT nIDCaption, CWnd* pParentWnd = nullptr, UINT iSelectPage = 0) {} + CAssetPropertySheet(LPCTSTR pszCaption, CWnd* pParentWnd = nullptr, UINT iSelectPage = 0) {} CPropertyPage *m_pCPropertyPage; }; diff --git a/Core/Tools/W3DView/BackgroundBMPDialog.cpp b/Core/Tools/W3DView/BackgroundBMPDialog.cpp index 6de5f2c192e..7fd50ca25db 100644 --- a/Core/Tools/W3DView/BackgroundBMPDialog.cpp +++ b/Core/Tools/W3DView/BackgroundBMPDialog.cpp @@ -39,7 +39,7 @@ static char THIS_FILE[] = __FILE__; // // CBackgroundBMPDialog // -CBackgroundBMPDialog::CBackgroundBMPDialog (CWnd* pParent /*=NULL*/) +CBackgroundBMPDialog::CBackgroundBMPDialog (CWnd* pParent /*=nullptr*/) : CDialog(CBackgroundBMPDialog::IDD, pParent) { //{{AFX_DATA_INIT(CBackgroundBMPDialog) @@ -121,7 +121,7 @@ CBackgroundBMPDialog::OnOK (void) else { // Ask the doc to clear any existing background BMP - pCDoc->SetBackgroundBMP (NULL); + pCDoc->SetBackgroundBMP (nullptr); } } diff --git a/Core/Tools/W3DView/BackgroundBMPDialog.h b/Core/Tools/W3DView/BackgroundBMPDialog.h index 71a86752a91..569995bb45f 100644 --- a/Core/Tools/W3DView/BackgroundBMPDialog.h +++ b/Core/Tools/W3DView/BackgroundBMPDialog.h @@ -28,7 +28,7 @@ class CBackgroundBMPDialog : public CDialog { // Construction public: - CBackgroundBMPDialog(CWnd* pParent = NULL); // standard constructor + CBackgroundBMPDialog(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CBackgroundBMPDialog) diff --git a/Core/Tools/W3DView/BackgroundColorDialog.cpp b/Core/Tools/W3DView/BackgroundColorDialog.cpp index 45f066b5491..e8d2a71d3d1 100644 --- a/Core/Tools/W3DView/BackgroundColorDialog.cpp +++ b/Core/Tools/W3DView/BackgroundColorDialog.cpp @@ -37,7 +37,7 @@ static char THIS_FILE[] = __FILE__; // CBackgroundColorDialog dialog -CBackgroundColorDialog::CBackgroundColorDialog(CWnd* pParent /*=NULL*/) +CBackgroundColorDialog::CBackgroundColorDialog(CWnd* pParent /*=nullptr*/) : CDialog(CBackgroundColorDialog::IDD, pParent) { //{{AFX_DATA_INIT(CBackgroundColorDialog) diff --git a/Core/Tools/W3DView/BackgroundColorDialog.h b/Core/Tools/W3DView/BackgroundColorDialog.h index 5999e968f07..4b6a1f31a97 100644 --- a/Core/Tools/W3DView/BackgroundColorDialog.h +++ b/Core/Tools/W3DView/BackgroundColorDialog.h @@ -28,7 +28,7 @@ class CBackgroundColorDialog : public CDialog { // Construction public: - CBackgroundColorDialog(CWnd* pParent = NULL); // standard constructor + CBackgroundColorDialog(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CBackgroundColorDialog) diff --git a/Core/Tools/W3DView/BackgroundObjectDialog.cpp b/Core/Tools/W3DView/BackgroundObjectDialog.cpp index dc4c28a0a8c..2117ce60470 100644 --- a/Core/Tools/W3DView/BackgroundObjectDialog.cpp +++ b/Core/Tools/W3DView/BackgroundObjectDialog.cpp @@ -38,7 +38,7 @@ static char THIS_FILE[] = __FILE__; // // CBackgroundObjectDialog // -CBackgroundObjectDialog::CBackgroundObjectDialog (CWnd* pParent /*=NULL*/) +CBackgroundObjectDialog::CBackgroundObjectDialog (CWnd* pParent /*=nullptr*/) : CDialog(CBackgroundObjectDialog::IDD, pParent) { //{{AFX_DATA_INIT(CBackgroundObjectDialog) @@ -114,7 +114,7 @@ CBackgroundObjectDialog::OnInitDialog (void) // Free the enumerator object we created earlier delete pObjEnum; - pObjEnum = NULL; + pObjEnum = nullptr; } // Get a pointer to the doc @@ -174,7 +174,7 @@ CBackgroundObjectDialog::OnOK (void) else { // Ask the doc to clear the background object - pCDoc->SetBackgroundObject (NULL); + pCDoc->SetBackgroundObject (nullptr); } // Allow the base class to process this message diff --git a/Core/Tools/W3DView/BackgroundObjectDialog.h b/Core/Tools/W3DView/BackgroundObjectDialog.h index 0032e55126e..2b8963d7fe9 100644 --- a/Core/Tools/W3DView/BackgroundObjectDialog.h +++ b/Core/Tools/W3DView/BackgroundObjectDialog.h @@ -28,7 +28,7 @@ class CBackgroundObjectDialog : public CDialog { // Construction public: - CBackgroundObjectDialog(CWnd* pParent = NULL); // standard constructor + CBackgroundObjectDialog(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CBackgroundObjectDialog) diff --git a/Core/Tools/W3DView/BoneMgrDialog.cpp b/Core/Tools/W3DView/BoneMgrDialog.cpp index 57ed30814e9..d9eacf4f18f 100644 --- a/Core/Tools/W3DView/BoneMgrDialog.cpp +++ b/Core/Tools/W3DView/BoneMgrDialog.cpp @@ -47,7 +47,7 @@ BoneMgrDialogClass::BoneMgrDialogClass CWnd *pparent ) : m_pBaseModel (prender_obj), - m_pBackupModel (NULL), + m_pBackupModel (nullptr), m_bAttach (true), CDialog (BoneMgrDialogClass::IDD, pparent) { @@ -120,7 +120,7 @@ BoneMgrDialogClass::OnInitDialog (void) // Get the hierarchy tree for this model so we can enumerate bone's // and subobjects. - HTREEITEM hfirst_item = NULL; + HTREEITEM hfirst_item = nullptr; // Loop through all the bones in this model int bone_count = m_pBaseModel->Get_Num_Bones (); @@ -133,7 +133,7 @@ BoneMgrDialogClass::OnInitDialog (void) Fill_Bone_Item (hbone_item, index); // Is this the first item we've added to the tree? - if (hfirst_item == NULL) { + if (hfirst_item == nullptr) { hfirst_item = hbone_item; } } @@ -179,7 +179,7 @@ BoneMgrDialogClass::Fill_Bone_Item // to compare with the supplied hmodel and determine // which 'bones-models' are new. const char *orig_model_name = m_pBaseModel->Get_Base_Model_Name (); - orig_model_name = (orig_model_name == NULL) ? m_pBaseModel->Get_Name () : orig_model_name; + orig_model_name = (orig_model_name == nullptr) ? m_pBaseModel->Get_Name () : orig_model_name; RenderObjClass *porig_model = WW3DAssetManager::Get_Instance()->Create_Render_Obj (orig_model_name); // Build a list of nodes that are contained in the vanilla model @@ -189,7 +189,7 @@ BoneMgrDialogClass::Fill_Bone_Item index < porig_model->Get_Num_Sub_Objects_On_Bone (bone_index); index ++) { RenderObjClass *psubobj = porig_model->Get_Sub_Object_On_Bone (index, bone_index); - if (psubobj != NULL) { + if (psubobj != nullptr) { orig_node_list.Add (psubobj); } } @@ -200,7 +200,7 @@ BoneMgrDialogClass::Fill_Bone_Item index < m_pBaseModel->Get_Num_Sub_Objects_On_Bone (bone_index); index ++) { RenderObjClass *psubobj = m_pBaseModel->Get_Sub_Object_On_Bone (index, bone_index); - if (psubobj != NULL) { + if (psubobj != nullptr) { node_list.Add (psubobj); } } @@ -210,10 +210,10 @@ BoneMgrDialogClass::Fill_Bone_Item // Add the subobjects to the tree control for (int node_index = 0; node_index < node_list.Count (); node_index ++) { RenderObjClass *psubobject = node_list[node_index]; - ASSERT (psubobject != NULL); + ASSERT (psubobject != nullptr); // Is this subobject new? (i.e. not in a 'vanilla' instance?) - if (psubobject != NULL && + if (psubobject != nullptr && (Is_Object_In_List (psubobject->Get_Name (), orig_node_list) == false)) { m_BoneTree.InsertItem (psubobject->Get_Name (), 1, 1, hbone_item); } @@ -255,7 +255,7 @@ BoneMgrDialogClass::Is_Object_In_List RenderObjClass *prender_obj = node_list[node_index]; // Is this the render object we were looking for? - if (prender_obj != NULL && + if (prender_obj != nullptr && ::lstrcmpi (prender_obj->Get_Name (), passet_name) == 0) { retval = true; } @@ -324,12 +324,12 @@ BoneMgrDialogClass::Is_Render_Obj_Already_Attached (const CString &name) HTREEITEM htree_item = m_BoneTree.GetSelectedItem (); HTREEITEM hparent_item = m_BoneTree.GetParentItem (htree_item); - htree_item = (hparent_item != NULL) ? hparent_item : htree_item; - if (htree_item != NULL) { + htree_item = (hparent_item != nullptr) ? hparent_item : htree_item; + if (htree_item != nullptr) { // Loop through all the children of this bone for (HTREEITEM hchild_item = m_BoneTree.GetChildItem (htree_item); - (hchild_item != NULL) && (retval == false); + (hchild_item != nullptr) && (retval == false); hchild_item = m_BoneTree.GetNextSiblingItem (hchild_item)) { // Is this the render object we were looking for? @@ -354,7 +354,7 @@ BoneMgrDialogClass::Update_Controls (HTREEITEM selected_item) { // Get the name of the currently selected item CString name = m_BoneTree.GetItemText (selected_item); - bool bis_bone = (m_BoneTree.GetParentItem (selected_item) == NULL); + bool bis_bone = (m_BoneTree.GetParentItem (selected_item) == nullptr); // Did the user select a bone name? if (bis_bone) { @@ -388,7 +388,7 @@ BoneMgrDialogClass::OnDestroy (void) { // Free the state image list we associated with the control CImageList *pimagelist = m_BoneTree.GetImageList (TVSIL_NORMAL); - m_BoneTree.SetImageList (NULL, TVSIL_NORMAL); + m_BoneTree.SetImageList (nullptr, TVSIL_NORMAL); SAFE_DELETE (pimagelist); // Allow the base class to process this message @@ -456,7 +456,7 @@ BoneMgrDialogClass::OnAttachButton (void) // Create an instance of the render object and attach it to the bone RenderObjClass *prender_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj (name); - if (prender_obj != NULL) { + if (prender_obj != nullptr) { m_pBaseModel->Add_Sub_Object_To_Bone (prender_obj, m_BoneName); m_BoneTree.InsertItem (name, 1, 1, hbone_item); REF_PTR_RELEASE (prender_obj); @@ -472,7 +472,7 @@ BoneMgrDialogClass::OnAttachButton (void) // Is this the subobject we were looking for? RenderObjClass *psub_obj = m_pBaseModel->Get_Sub_Object_On_Bone (index, bone_index); - if ((psub_obj != NULL) && + if ((psub_obj != nullptr) && (::lstrcmpi (psub_obj->Get_Name (), name) == 0)) { // Remove this subobject from the bone @@ -489,7 +489,7 @@ BoneMgrDialogClass::OnAttachButton (void) } // Refresh the UI state - m_BoneTree.InvalidateRect (NULL, TRUE); + m_BoneTree.InvalidateRect (nullptr, TRUE); m_BoneTree.UpdateWindow (); Update_Controls (hbone_item); return ; @@ -508,7 +508,7 @@ BoneMgrDialogClass::Get_Current_Bone_Item (void) HTREEITEM hparent_item = m_BoneTree.GetParentItem (htree_item); // Return the bone item - return (hparent_item != NULL) ? hparent_item : htree_item; + return (hparent_item != nullptr) ? hparent_item : htree_item; } @@ -525,7 +525,7 @@ BoneMgrDialogClass::Remove_Object_From_Bone { // Loop through all the children of this bone for (HTREEITEM hchild_item = m_BoneTree.GetChildItem (bone_item); - (hchild_item != NULL); + (hchild_item != nullptr); hchild_item = m_BoneTree.GetNextSiblingItem (hchild_item)) { // Is this the render object we were looking for? diff --git a/Core/Tools/W3DView/BoneMgrDialog.h b/Core/Tools/W3DView/BoneMgrDialog.h index 33da2141434..b5b6adafaae 100644 --- a/Core/Tools/W3DView/BoneMgrDialog.h +++ b/Core/Tools/W3DView/BoneMgrDialog.h @@ -37,7 +37,7 @@ class BoneMgrDialogClass : public CDialog { // Construction public: - BoneMgrDialogClass (RenderObjClass *prender_obj, CWnd* pParent = NULL); + BoneMgrDialogClass (RenderObjClass *prender_obj, CWnd* pParent = nullptr); // Dialog Data //{{AFX_DATA(BoneMgrDialogClass) diff --git a/Core/Tools/W3DView/CMakeLists.txt b/Core/Tools/W3DView/CMakeLists.txt index f8a8b9604c0..d835feaa6e3 100644 --- a/Core/Tools/W3DView/CMakeLists.txt +++ b/Core/Tools/W3DView/CMakeLists.txt @@ -171,6 +171,7 @@ add_library(corei_w3dview INTERFACE) target_sources(corei_w3dview INTERFACE ${W3DVIEW_SRC}) target_precompile_headers(corei_w3dview INTERFACE + [["Utility/CppMacros.h"]] # Must be first, to be removed when abandoning VC6 "StdAfx.h" [["always.h"]] [["STLUtils.h"]] diff --git a/Core/Tools/W3DView/CameraDistanceDialog.cpp b/Core/Tools/W3DView/CameraDistanceDialog.cpp index 7064f0f35be..1c8b6b3a510 100644 --- a/Core/Tools/W3DView/CameraDistanceDialog.cpp +++ b/Core/Tools/W3DView/CameraDistanceDialog.cpp @@ -38,7 +38,7 @@ static char THIS_FILE[] = __FILE__; // CameraDistanceDialogClass // ///////////////////////////////////////////////////////////////////////////// -CameraDistanceDialogClass::CameraDistanceDialogClass(CWnd* pParent /*=NULL*/) +CameraDistanceDialogClass::CameraDistanceDialogClass(CWnd* pParent /*=nullptr*/) : CDialog(CameraDistanceDialogClass::IDD, pParent) { //{{AFX_DATA_INIT(CameraDistanceDialogClass) @@ -122,7 +122,7 @@ CameraDistanceDialogClass::OnNotify // Update the spinner control if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); } diff --git a/Core/Tools/W3DView/CameraDistanceDialog.h b/Core/Tools/W3DView/CameraDistanceDialog.h index ffde9e0757a..9fb2f377479 100644 --- a/Core/Tools/W3DView/CameraDistanceDialog.h +++ b/Core/Tools/W3DView/CameraDistanceDialog.h @@ -29,7 +29,7 @@ class CameraDistanceDialogClass : public CDialog { // Construction public: - CameraDistanceDialogClass(CWnd* pParent = NULL); // standard constructor + CameraDistanceDialogClass(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CameraDistanceDialogClass) diff --git a/Core/Tools/W3DView/CameraSettingsDialog.cpp b/Core/Tools/W3DView/CameraSettingsDialog.cpp index 31c2a6b50a0..401cdd10c5e 100644 --- a/Core/Tools/W3DView/CameraSettingsDialog.cpp +++ b/Core/Tools/W3DView/CameraSettingsDialog.cpp @@ -41,7 +41,7 @@ static char THIS_FILE[] = __FILE__; // CameraSettingsDialogClass // ///////////////////////////////////////////////////////////////////////////// -CameraSettingsDialogClass::CameraSettingsDialogClass(CWnd* pParent /*=NULL*/) +CameraSettingsDialogClass::CameraSettingsDialogClass(CWnd* pParent /*=nullptr*/) : CDialog(CameraSettingsDialogClass::IDD, pParent) { //{{AFX_DATA_INIT(CameraSettingsDialogClass) @@ -168,7 +168,7 @@ CameraSettingsDialogClass::OnOK (void) // // Update the fog settings. The fog near clip plane should always be equal // to the camera near clip plane, but the fog far clip plane is scene - // dependant. We will be sure to modify only the near clip plane here. + // dependent. We will be sure to modify only the near clip plane here. // float fog_near, fog_far; doc->GetScene()->Get_Fog_Range(&fog_near, &fog_far); @@ -179,7 +179,7 @@ CameraSettingsDialogClass::OnOK (void) // Refresh the camera settings // RenderObjClass *render_obj = doc->GetDisplayedObject (); - if (render_obj != NULL) { + if (render_obj != nullptr) { graphic_view->Reset_Camera_To_Display_Object (*render_obj); } @@ -241,7 +241,7 @@ CameraSettingsDialogClass::OnReset (void) graphic_view->Reset_FOV (); RenderObjClass *render_obj = doc->GetDisplayedObject (); - if (render_obj != NULL) { + if (render_obj != nullptr) { graphic_view->Reset_Camera_To_Display_Object (*render_obj); } @@ -289,7 +289,7 @@ CameraSettingsDialogClass::OnNotify // Update the spinner control if necessary // NMHDR *header = (NMHDR *)lParam; - if ((header != NULL) && (header->code == UDN_DELTAPOS)) { + if ((header != nullptr) && (header->code == UDN_DELTAPOS)) { LPNMUPDOWN updown_info = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (header->hwndFrom, updown_info->iDelta); diff --git a/Core/Tools/W3DView/CameraSettingsDialog.h b/Core/Tools/W3DView/CameraSettingsDialog.h index bd94ce278fc..15d96dae8ba 100644 --- a/Core/Tools/W3DView/CameraSettingsDialog.h +++ b/Core/Tools/W3DView/CameraSettingsDialog.h @@ -28,7 +28,7 @@ class CameraSettingsDialogClass : public CDialog { // Construction public: - CameraSettingsDialogClass(CWnd* pParent = NULL); // standard constructor + CameraSettingsDialogClass(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CameraSettingsDialogClass) diff --git a/Core/Tools/W3DView/ColorBar.cpp b/Core/Tools/W3DView/ColorBar.cpp index 38ec40b1bd1..f77b56415b1 100644 --- a/Core/Tools/W3DView/ColorBar.cpp +++ b/Core/Tools/W3DView/ColorBar.cpp @@ -43,16 +43,16 @@ static char THIS_FILE[] = __FILE__; // ColorBarClass // ColorBarClass::ColorBarClass (void) - : m_hBitmap (NULL), + : m_hBitmap (nullptr), m_iBMPWidth (0), m_iBMPHeight (0), - m_pBits (NULL), - m_hMemDC (NULL), + m_pBits (nullptr), + m_hMemDC (nullptr), m_iColorPoints (0), m_iMarkerWidth (0), m_iMarkerHeight (0), - m_KeyFrameDIB (NULL), - m_pKeyFrameBits (NULL), + m_KeyFrameDIB (nullptr), + m_pKeyFrameBits (nullptr), m_iCurrentKey (0), m_MinPos (0), m_MaxPos (1), @@ -124,9 +124,9 @@ ColorBarClass::ColorBarClass (void) // ColorBarClass::~ColorBarClass (void) { - if (m_hMemDC != NULL) { + if (m_hMemDC != nullptr) { ::DeleteObject (m_hMemDC); - m_hMemDC = NULL; + m_hMemDC = nullptr; } Free_Marker_Bitmap (); @@ -170,7 +170,7 @@ RegisterColorBar (HINSTANCE hinst) wndclass.lpfnWndProc = fnColorBarProc; wndclass.hInstance = hinst; wndclass.hbrBackground = (HBRUSH)(COLOR_3DFACE + 1); - wndclass.hCursor = ::LoadCursor (NULL, IDC_ARROW); + wndclass.hCursor = ::LoadCursor (nullptr, IDC_ARROW); wndclass.lpszClassName = "WWCOLORBAR"; // Let the windows manager know about this global class @@ -199,12 +199,12 @@ fnColorBarProc case WM_CREATE: { LPCREATESTRUCT pcreate_info = (LPCREATESTRUCT)lparam; - if (pcreate_info != NULL) { + if (pcreate_info != nullptr) { // Should we create a new class manager for this window? ColorBarClass *pwnd = (ColorBarClass *)pcreate_info->lpCreateParams; BOOL created = FALSE; - if (pwnd == NULL) { + if (pwnd == nullptr) { pwnd = new ColorBarClass; created = TRUE; } @@ -218,7 +218,7 @@ fnColorBarProc WNDPROC *pOldWndProc = pwnd->GetSuperWndProcAddr (); if (pOldWndProc) { WNDPROC pold_proc = (WNDPROC)::SetWindowLong (hwnd, GWL_WNDPROC, (DWORD)::AfxGetAfxWndProc ()); - ASSERT (pold_proc != NULL); + ASSERT (pold_proc != nullptr); (*pOldWndProc) = pold_proc; } @@ -235,18 +235,18 @@ fnColorBarProc ColorBarClass *pwnd = (ColorBarClass *)::GetProp (hwnd, "CLASSPOINTER"); BOOL created = (BOOL)::GetProp (hwnd, "CREATED"); - if (pwnd != NULL) { + if (pwnd != nullptr) { pwnd->Detach (); WNDPROC *pOldWndProc = pwnd->GetSuperWndProcAddr (); if (pOldWndProc) { ::SetWindowLong (hwnd, GWL_WNDPROC, (DWORD)(*pOldWndProc)); - (*pOldWndProc) = NULL; + (*pOldWndProc) = nullptr; } if (created) { delete pwnd; - pwnd = NULL; + pwnd = nullptr; } } } @@ -268,7 +268,7 @@ ColorBarClass::OnCreate (LPCREATESTRUCT lpCreateStruct) if (CWnd::OnCreate (lpCreateStruct) == -1) return -1; - m_hMemDC = ::CreateCompatibleDC (NULL); + m_hMemDC = ::CreateCompatibleDC (nullptr); Create_Bitmap (); return 0; } @@ -291,7 +291,7 @@ ColorBarClass::Create ) { // Create the window (it will force the message map and everthing) - HWND hparent_wnd = (pparent_wnd != NULL) ? pparent_wnd->m_hWnd : NULL; + HWND hparent_wnd = (pparent_wnd != nullptr) ? pparent_wnd->m_hWnd : nullptr; HWND hwnd = ::CreateWindow ("WWCOLORBAR", lpszWindowName, dwStyle, @@ -305,7 +305,7 @@ ColorBarClass::Create this); // Return the true/false result code - return (hwnd != NULL); + return (hwnd != nullptr); } @@ -377,18 +377,18 @@ ColorBarClass::Create_Bitmap (void) bitmap_info.biClrImportant = 0; // Get a temporary screen DC - HDC hscreen_dc = ::GetDC (NULL); + HDC hscreen_dc = ::GetDC (nullptr); // Create a bitmap that we can access the bits directly of m_hBitmap = ::CreateDIBSection (hscreen_dc, (const BITMAPINFO *)&bitmap_info, DIB_RGB_COLORS, (void **)&m_pBits, - NULL, + nullptr, 0L); // Release our temporary screen DC - ::ReleaseDC (NULL, hscreen_dc); + ::ReleaseDC (nullptr, hscreen_dc); // Window's bitmaps are DWORD aligned, so make sure // we take that into account. @@ -409,10 +409,10 @@ ColorBarClass::Create_Bitmap (void) void ColorBarClass::Free_Bitmap (void) { - if (m_hBitmap != NULL) { + if (m_hBitmap != nullptr) { ::DeleteObject (m_hBitmap); - m_hBitmap = NULL; - m_pBits = NULL; + m_hBitmap = nullptr; + m_pBits = nullptr; } m_iBMPWidth = 0; @@ -675,7 +675,7 @@ ColorBarClass::Paint_DIB (void) // int x_pos = 0; int y_pos = 0; - int *position = NULL; + int *position = nullptr; int offset = 0; if (style & CBRS_HORZ) { @@ -736,7 +736,7 @@ ColorBarClass::OnPaint (void) void ColorBarClass::Paint_Screen (HDC hwnd_dc) { - if (m_hMemDC != NULL) { + if (m_hMemDC != nullptr) { // // Blit the actual color bar to the screen @@ -808,22 +808,22 @@ ColorBarClass::Get_Point if ((index >= 0) && (index < m_iColorPoints)) { // Return the position to the caller if requested - if (position != NULL) { + if (position != nullptr) { (*position) = m_MinPos + (m_ColorPoints[index].PosPercent * (m_MaxPos - m_MinPos)); } // Return the red value to the caller if requested - if (red != NULL) { + if (red != nullptr) { (*red) = m_ColorPoints[index].StartRed; } // Return the green value to the caller if requested - if (green != NULL) { + if (green != nullptr) { (*green) = m_ColorPoints[index].StartGreen; } // Return the blue value to the caller if requested - if (blue != NULL) { + if (blue != nullptr) { (*blue) = m_ColorPoints[index].StartBlue; } } @@ -1141,10 +1141,10 @@ ColorBarClass::Update_Point_Info (void) void ColorBarClass::Free_Marker_Bitmap (void) { - if (m_KeyFrameDIB != NULL) { + if (m_KeyFrameDIB != nullptr) { ::DeleteObject (m_KeyFrameDIB); - m_KeyFrameDIB = NULL; - m_pKeyFrameBits = NULL; + m_KeyFrameDIB = nullptr; + m_pKeyFrameBits = nullptr; } return ; @@ -1164,7 +1164,7 @@ ColorBarClass::Load_Key_Frame_BMP (void) // Load the appropriate BMP based on the barstyle // LONG style = ::GetWindowLong (m_hWnd, GWL_STYLE); - HBITMAP hbmp = NULL; + HBITMAP hbmp = nullptr; if (style & CBRS_HORZ) { hbmp = ::LoadBitmap (::AfxGetResourceHandle (), MAKEINTRESOURCE (IDB_KEYFRAME_V)); } else { @@ -1195,21 +1195,21 @@ ColorBarClass::Load_Key_Frame_BMP (void) bitmap_info.biClrImportant = 0; // Get a temporary screen DC - HDC hscreen_dc = ::GetDC (NULL); + HDC hscreen_dc = ::GetDC (nullptr); // Create a bitmap that we can access the bits directly of m_KeyFrameDIB = ::CreateDIBSection (hscreen_dc, (const BITMAPINFO *)&bitmap_info, DIB_RGB_COLORS, (void **)&m_pKeyFrameBits, - NULL, + nullptr, 0L); // Release our temporary screen DC - ::ReleaseDC (NULL, hscreen_dc); + ::ReleaseDC (nullptr, hscreen_dc); // Initialize 2 temp DCs so we can copy from the BMP to the DIB section - HDC htemp_dc = ::CreateCompatibleDC (NULL); + HDC htemp_dc = ::CreateCompatibleDC (nullptr); HBITMAP hold_bmp1 = (HBITMAP)::SelectObject (m_hMemDC, m_KeyFrameDIB); HBITMAP hold_bmp2 = (HBITMAP)::SelectObject (htemp_dc, hbmp); @@ -1239,7 +1239,7 @@ ColorBarClass::Paint_Key_Frame (int x_pos, int y_pos) int marker_scanline = (m_iMarkerWidth * 3) + alignment_offset; int width_in_bytes = m_iMarkerWidth * 3; - if ((m_pBits != NULL) && (m_pKeyFrameBits != NULL)) { + if ((m_pBits != nullptr) && (m_pKeyFrameBits != nullptr)) { int dest_index = (m_iScanlineSize * y_pos) + (x_pos * 3); int src_index = 0; @@ -1507,7 +1507,7 @@ ColorBarClass::Send_Notification (int code, int key) // Fill in the nofitication structure // LONG id = ::GetWindowLong (m_hWnd, GWL_ID); - CBR_NMHDR notify_hdr = { 0 }; + CBR_NMHDR notify_hdr = { nullptr }; notify_hdr.hdr.hwndFrom = m_hWnd; notify_hdr.hdr.idFrom = id; notify_hdr.hdr.code = code; @@ -1707,7 +1707,7 @@ ColorBarClass::Move_Selection (float new_pos, bool send_notify) // if (send_notify) { LONG id = ::GetWindowLong (m_hWnd, GWL_ID); - CBR_NMHDR notify_hdr = { 0 }; + CBR_NMHDR notify_hdr = { nullptr }; notify_hdr.hdr.hwndFrom = m_hWnd; notify_hdr.hdr.idFrom = id; notify_hdr.hdr.code = CBRN_SEL_CHANGED; @@ -1926,7 +1926,7 @@ ColorBarClass::Set_Redraw (bool redraw) void ColorBarClass::Repaint (void) { - InvalidateRect (NULL, FALSE); + InvalidateRect (nullptr, FALSE); if (m_bRedraw) { UpdateWindow (); } diff --git a/Core/Tools/W3DView/ColorBar.h b/Core/Tools/W3DView/ColorBar.h index a1efce422d8..595eb26bbf9 100644 --- a/Core/Tools/W3DView/ColorBar.h +++ b/Core/Tools/W3DView/ColorBar.h @@ -103,7 +103,7 @@ class ColorBarClass : public CWnd // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(ColorBarClass) public: - virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); + virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = nullptr); //}}AFX_VIRTUAL // Implementation diff --git a/Core/Tools/W3DView/ColorPicker.cpp b/Core/Tools/W3DView/ColorPicker.cpp index ca4e95f7006..b98a48d6a22 100644 --- a/Core/Tools/W3DView/ColorPicker.cpp +++ b/Core/Tools/W3DView/ColorPicker.cpp @@ -44,14 +44,14 @@ static char THIS_FILE[] = __FILE__; // ColorPickerClass // ColorPickerClass::ColorPickerClass (void) - : m_hBitmap (NULL), + : m_hBitmap (nullptr), m_iWidth (0), m_iHeight (0), m_CurrentPoint (0, 0), m_CurrentColor (0), m_bSelecting (false), - m_pBits (NULL), - m_hMemDC (NULL), + m_pBits (nullptr), + m_hMemDC (nullptr), m_CurrentHue (0), CWnd () { @@ -65,9 +65,9 @@ ColorPickerClass::ColorPickerClass (void) // ColorPickerClass::~ColorPickerClass (void) { - if (m_hMemDC != NULL) { + if (m_hMemDC != nullptr) { ::DeleteObject (m_hMemDC); - m_hMemDC = NULL; + m_hMemDC = nullptr; } Free_Bitmap (); @@ -97,7 +97,7 @@ ColorPickerClass::OnPaint (void) { CPaintDC dc (this); - if (m_hMemDC != NULL) { + if (m_hMemDC != nullptr) { HBITMAP hold_bmp = (HBITMAP)::SelectObject (m_hMemDC, m_hBitmap); @@ -132,7 +132,7 @@ RegisterColorPicker (HINSTANCE hinst) wndclass.lpfnWndProc = fnColorPickerProc; wndclass.hInstance = hinst; wndclass.hbrBackground = (HBRUSH)COLOR_3DFACE + 1; - wndclass.hCursor = ::LoadCursor (NULL, IDC_ARROW); + wndclass.hCursor = ::LoadCursor (nullptr, IDC_ARROW); wndclass.lpszClassName = "WWCOLORPICKER"; // Let the windows manager know about this global class @@ -158,7 +158,7 @@ fnColorPickerProc LPARAM lparam ) { - //static ColorPickerClass *pwnd = NULL; + //static ColorPickerClass *pwnd = nullptr; //static bool bcreated = false; switch (message) @@ -166,12 +166,12 @@ fnColorPickerProc case WM_CREATE: { LPCREATESTRUCT pcreate_info = (LPCREATESTRUCT)lparam; - if (pcreate_info != NULL) { + if (pcreate_info != nullptr) { // Should we create a new class manager for this window? ColorPickerClass *pwnd = (ColorPickerClass *)pcreate_info->lpCreateParams; BOOL created = FALSE; - if (pwnd == NULL) { + if (pwnd == nullptr) { pwnd = new ColorPickerClass; created = TRUE; } @@ -185,7 +185,7 @@ fnColorPickerProc WNDPROC *pOldWndProc = pwnd->GetSuperWndProcAddr (); if (pOldWndProc) { WNDPROC pold_proc = (WNDPROC)::SetWindowLong (hwnd, GWL_WNDPROC, (DWORD)::AfxGetAfxWndProc ()); - ASSERT (pold_proc != NULL); + ASSERT (pold_proc != nullptr); (*pOldWndProc) = pold_proc; } @@ -203,30 +203,30 @@ fnColorPickerProc WNDPROC *pOldWndProc = pwnd->GetSuperWndProcAddr (); if (pOldWndProc) { ::SetWindowLong (hwnd, GWL_WNDPROC, (DWORD)(*pOldWndProc)); - (*pOldWndProc) = NULL; + (*pOldWndProc) = nullptr; } if (bcreated) { delete pwnd; - pwnd = NULL; + pwnd = nullptr; }*/ // Get the creation information from the window handle ColorPickerClass *pwnd = (ColorPickerClass *)::GetProp (hwnd, "CLASSPOINTER"); BOOL created = (BOOL)::GetProp (hwnd, "CREATED"); - if (pwnd != NULL) { + if (pwnd != nullptr) { pwnd->Detach (); WNDPROC *pOldWndProc = pwnd->GetSuperWndProcAddr (); if (pOldWndProc) { ::SetWindowLong (hwnd, GWL_WNDPROC, (DWORD)(*pOldWndProc)); - (*pOldWndProc) = NULL; + (*pOldWndProc) = nullptr; } if (created) { delete pwnd; - pwnd = NULL; + pwnd = nullptr; } } } @@ -249,7 +249,7 @@ ColorPickerClass::OnCreate (LPCREATESTRUCT lpCreateStruct) if (CWnd::OnCreate(lpCreateStruct) == -1) return -1; - m_hMemDC = ::CreateCompatibleDC (NULL); + m_hMemDC = ::CreateCompatibleDC (nullptr); Create_Bitmap (); return 0; } @@ -273,7 +273,7 @@ ColorPickerClass::Create ) { // Create the window (it will force the message map and everthing) - HWND hparent_wnd = (pparent_wnd != NULL) ? pparent_wnd->m_hWnd : NULL; + HWND hparent_wnd = (pparent_wnd != nullptr) ? pparent_wnd->m_hWnd : nullptr; HWND hwnd = ::CreateWindow ("WWCOLORPICKER", lpszWindowName, dwStyle, @@ -287,7 +287,7 @@ ColorPickerClass::Create this); // Return the true/false result code - return (hwnd != NULL); + return (hwnd != nullptr); } @@ -322,18 +322,18 @@ ColorPickerClass::Create_Bitmap (void) bitmap_info.biClrImportant = 0; // Get a temporary screen DC - HDC hscreen_dc = ::GetDC (NULL); + HDC hscreen_dc = ::GetDC (nullptr); // Create a bitmap that we can access the bits directly of m_hBitmap = ::CreateDIBSection (hscreen_dc, (const BITMAPINFO *)&bitmap_info, DIB_RGB_COLORS, (void **)&m_pBits, - NULL, + nullptr, 0L); // Release our temporary screen DC - ::ReleaseDC (NULL, hscreen_dc); + ::ReleaseDC (nullptr, hscreen_dc); // Paint the color range into this bitmap Paint_DIB (m_iWidth, m_iHeight, m_pBits); @@ -590,7 +590,7 @@ ColorPickerClass::Paint_DIB width = rect.Width (); height = rect.Height (); - // Build an array of column indicies where we will switch color + // Build an array of column indices where we will switch color // components... int col_remainder = (width % 6); int channel_switch_cols[6]; @@ -695,10 +695,10 @@ ColorPickerClass::Paint_DIB void ColorPickerClass::Free_Bitmap (void) { - if (m_hBitmap != NULL) { + if (m_hBitmap != nullptr) { ::DeleteObject (m_hBitmap); - m_hBitmap = NULL; - m_pBits = NULL; + m_hBitmap = nullptr; + m_pBits = nullptr; } m_iWidth = 0; @@ -775,7 +775,7 @@ ColorPickerClass::OnLButtonDown // one of the keyframes // LONG id = ::GetWindowLong (m_hWnd, GWL_ID); - CP_NMHDR notify_hdr = { 0 }; + CP_NMHDR notify_hdr = { nullptr }; notify_hdr.hdr.hwndFrom = m_hWnd; notify_hdr.hdr.idFrom = id; notify_hdr.hdr.code = CPN_COLORCHANGE; @@ -809,7 +809,7 @@ ColorPickerClass::OnLButtonUp ) { if (m_bSelecting) { - ::ClipCursor (NULL); + ::ClipCursor (nullptr); ReleaseCapture (); m_bSelecting = false; } @@ -843,7 +843,7 @@ ColorPickerClass::OnMouseMove // one of the keyframes // LONG id = ::GetWindowLong (m_hWnd, GWL_ID); - CP_NMHDR notify_hdr = { 0 }; + CP_NMHDR notify_hdr = { nullptr }; notify_hdr.hdr.hwndFrom = m_hWnd; notify_hdr.hdr.idFrom = id; notify_hdr.hdr.code = CPN_COLORCHANGE; @@ -896,7 +896,7 @@ void ColorPickerClass::Erase_Marker (void) { HDC hdc = ::GetDC (m_hWnd); - if (m_hMemDC != NULL) { + if (m_hMemDC != nullptr) { HBITMAP hold_bmp = (HBITMAP)::SelectObject (m_hMemDC, m_hBitmap); @@ -929,7 +929,7 @@ void ColorPickerClass::Paint_Marker (void) { HDC hdc = ::GetDC (m_hWnd); - if (m_hMemDC != NULL) { + if (m_hMemDC != nullptr) { HBITMAP hmarker_bmp = ::LoadBitmap (::AfxGetResourceHandle (), MAKEINTRESOURCE (IDB_MARKER)); HBITMAP hold_bmp = (HBITMAP)::SelectObject (m_hMemDC, hmarker_bmp); @@ -968,7 +968,7 @@ ColorPickerClass::Select_Color (int red, int green, int blue) m_CurrentColor = Color_From_Point (m_CurrentPoint.x, m_CurrentPoint.y); // Refresh the window - InvalidateRect (NULL, FALSE); + InvalidateRect (nullptr, FALSE); UpdateWindow (); return ; } diff --git a/Core/Tools/W3DView/ColorPicker.h b/Core/Tools/W3DView/ColorPicker.h index 6d4941b0a1b..35f96ee6c8f 100644 --- a/Core/Tools/W3DView/ColorPicker.h +++ b/Core/Tools/W3DView/ColorPicker.h @@ -77,7 +77,7 @@ class ColorPickerClass : public CWnd // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(ColorPickerClass) public: - virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL); + virtual BOOL Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = nullptr); //}}AFX_VIRTUAL // Implementation diff --git a/Core/Tools/W3DView/ColorPickerDialogClass.cpp b/Core/Tools/W3DView/ColorPickerDialogClass.cpp index 554595a4ad7..874aab91248 100644 --- a/Core/Tools/W3DView/ColorPickerDialogClass.cpp +++ b/Core/Tools/W3DView/ColorPickerDialogClass.cpp @@ -82,7 +82,7 @@ Get_Form_Color (HWND form_wnd, int *red, int *green, int *blue) BOOL retval = FALSE; ColorPickerDialogClass *dialog = (ColorPickerDialogClass *)::GetProp (form_wnd, "COLORPICKERDLGCLASS"); - if (dialog != NULL) { + if (dialog != nullptr) { (*red) = dialog->Get_Red (); (*green) = dialog->Get_Green (); (*blue) = dialog->Get_Blue (); @@ -101,7 +101,7 @@ Set_Form_Color (HWND form_wnd, int red, int green, int blue) BOOL retval = FALSE; ColorPickerDialogClass *dialog = (ColorPickerDialogClass *)::GetProp (form_wnd, "COLORPICKERDLGCLASS"); - if (dialog != NULL) { + if (dialog != nullptr) { dialog->Set_Color (red, green, blue); retval = TRUE; } @@ -118,7 +118,7 @@ Set_Form_Original_Color (HWND form_wnd, int red, int green, int blue) BOOL retval = FALSE; ColorPickerDialogClass *dialog = (ColorPickerDialogClass *)::GetProp (form_wnd, "COLORPICKERDLGCLASS"); - if (dialog != NULL) { + if (dialog != nullptr) { dialog->Set_Original_Color (red, green, blue); retval = TRUE; } @@ -154,7 +154,7 @@ Set_Update_Callback (HWND form_wnd, WWCTRL_COLORCALLBACK callback, void *arg) BOOL retval = FALSE; ColorPickerDialogClass *dialog = (ColorPickerDialogClass *)::GetProp (form_wnd, "COLORPICKERDLGCLASS"); - if (dialog != NULL) { + if (dialog != nullptr) { dialog->Set_Update_Callback(callback, arg); retval = TRUE; } @@ -181,15 +181,15 @@ ColorPickerDialogClass::ColorPickerDialogClass m_CurrentRed ((float)red), m_CurrentGreen ((float)green), m_CurrentBlue ((float)blue), - m_CurrentColorBar (NULL), - m_OrigColorBar (NULL), - m_RedColorBar (NULL), - m_GreenColorBar (NULL), - m_BlueColorBar (NULL), - m_WhitenessColorBar (NULL), - m_HuePicker (NULL), + m_CurrentColorBar (nullptr), + m_OrigColorBar (nullptr), + m_RedColorBar (nullptr), + m_GreenColorBar (nullptr), + m_BlueColorBar (nullptr), + m_WhitenessColorBar (nullptr), + m_HuePicker (nullptr), m_bDeleteOnClose (false), - m_UpdateCallback(NULL), + m_UpdateCallback(nullptr), CDialog(res_id, pParent) { //{{AFX_DATA_INIT(ColorPickerDialogClass) diff --git a/Core/Tools/W3DView/ColorPickerDialogClass.h b/Core/Tools/W3DView/ColorPickerDialogClass.h index 64f6ea6e971..4bc428d4665 100644 --- a/Core/Tools/W3DView/ColorPickerDialogClass.h +++ b/Core/Tools/W3DView/ColorPickerDialogClass.h @@ -39,7 +39,7 @@ class ColorPickerDialogClass : public CDialog { // Construction public: - ColorPickerDialogClass (int red, int green, int blue, CWnd* pParent = NULL, UINT res_id = ColorPickerDialogClass::IDD); + ColorPickerDialogClass (int red, int green, int blue, CWnd* pParent = nullptr, UINT res_id = ColorPickerDialogClass::IDD); // Dialog Data //{{AFX_DATA(ColorPickerDialogClass) diff --git a/Core/Tools/W3DView/ColorSelectionDialog.cpp b/Core/Tools/W3DView/ColorSelectionDialog.cpp index 7c5c78d1369..6a70810eb87 100644 --- a/Core/Tools/W3DView/ColorSelectionDialog.cpp +++ b/Core/Tools/W3DView/ColorSelectionDialog.cpp @@ -202,7 +202,7 @@ ColorSelectionDialogClass::Paint_Color_Window (void) m_ColorWindow.ReleaseDC (pdc); // Let the window know it doesn't need to be repainted - m_ColorWindow.ValidateRect (NULL); + m_ColorWindow.ValidateRect (nullptr); return; } diff --git a/Core/Tools/W3DView/ColorSelectionDialog.h b/Core/Tools/W3DView/ColorSelectionDialog.h index 3c42553ed3a..166c0ed70cd 100644 --- a/Core/Tools/W3DView/ColorSelectionDialog.h +++ b/Core/Tools/W3DView/ColorSelectionDialog.h @@ -33,7 +33,7 @@ class ColorSelectionDialogClass : public CDialog { // Construction public: - ColorSelectionDialogClass (const Vector3 &def_color, CWnd *pParent = NULL); // standard constructor + ColorSelectionDialogClass (const Vector3 &def_color, CWnd *pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(ColorSelectionDialogClass) diff --git a/Core/Tools/W3DView/ColorUtils.h b/Core/Tools/W3DView/ColorUtils.h index 2a440aafe3f..4883a70f7be 100644 --- a/Core/Tools/W3DView/ColorUtils.h +++ b/Core/Tools/W3DView/ColorUtils.h @@ -42,6 +42,6 @@ HWND Create_Color_Picker_Form (HWND parent, int red, int green, int blue); BOOL Get_Form_Color (HWND form_wnd, int *red, int *green, int *blue); BOOL Set_Form_Color (HWND form_wnd, int red, int green, int blue); 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); +BOOL Set_Update_Callback (HWND form_wnd, WWCTRL_COLORCALLBACK callback, void *arg=nullptr); void RegisterColorPicker (HINSTANCE hinst); void RegisterColorBar (HINSTANCE hinst); diff --git a/Core/Tools/W3DView/DataTreeView.cpp b/Core/Tools/W3DView/DataTreeView.cpp index 1b5a31d1634..895cdc0bb1a 100644 --- a/Core/Tools/W3DView/DataTreeView.cpp +++ b/Core/Tools/W3DView/DataTreeView.cpp @@ -81,14 +81,14 @@ IMPLEMENT_DYNCREATE(CDataTreeView, CTreeView) // //////////////////////////////////////////////////////////////////////////// CDataTreeView::CDataTreeView (void) - : m_hMaterialsRoot (NULL), - m_hMeshRoot (NULL), - m_hMeshCollectionRoot (NULL), - m_hAggregateRoot (NULL), - m_hPrimitivesRoot (NULL), - m_hEmitterRoot (NULL), - m_hLODRoot (NULL), - m_hSoundRoot (NULL), + : m_hMaterialsRoot (nullptr), + m_hMeshRoot (nullptr), + m_hMeshCollectionRoot (nullptr), + m_hAggregateRoot (nullptr), + m_hPrimitivesRoot (nullptr), + m_hEmitterRoot (nullptr), + m_hLODRoot (nullptr), + m_hSoundRoot (nullptr), m_iPrimitivesIcon (-1), m_iAnimationIcon (-1), m_iTCAnimationIcon(-1), @@ -263,16 +263,16 @@ CDataTreeView::Load_Materials_Into_Tree (void) TextureClass* ptexture=ite.Peek_Value(); LPCTSTR texture_name = ptexture->Get_Texture_Name(); - if ((ptexture != NULL) && - FindChildItem (m_hMaterialsRoot, texture_name) == NULL) { + if ((ptexture != nullptr) && + FindChildItem (m_hMaterialsRoot, texture_name) == nullptr) { // Add this entry to the tree HTREEITEM tree_item = GetTreeCtrl ().InsertItem (texture_name, m_iMaterialIcon, m_iMaterialIcon, m_hMaterialsRoot, TVI_SORT); - ASSERT (tree_item != NULL); + ASSERT (tree_item != nullptr); // Allocate a new asset information class to associate with this entry ptexture->Add_Ref (); - AssetInfoClass *asset_info = new AssetInfoClass (texture_name, TypeMaterial, NULL, (DWORD)ptexture); + AssetInfoClass *asset_info = new AssetInfoClass (texture_name, TypeMaterial, nullptr, (DWORD)ptexture); GetTreeCtrl ().SetItemData (tree_item, (ULONG)asset_info); } } @@ -309,7 +309,7 @@ CDataTreeView::LoadAssetsIntoTree (void) if (WW3DAssetManager::Get_Instance()->Render_Obj_Exists (pszItemName)) { BOOL bInsert = FALSE; - HTREEITEM hParentNode = NULL; + HTREEITEM hParentNode = nullptr; ASSET_TYPE assetType = TypeUnknown; int iIconIndex = -1; @@ -393,11 +393,11 @@ CDataTreeView::LoadAssetsIntoTree (void) } // If this object isn't already in the tree then add it - if (FindChildItem (hParentNode, pszItemName) == NULL) { + if (FindChildItem (hParentNode, pszItemName) == nullptr) { // Add this entry to the tree HTREEITEM hItem = GetTreeCtrl ().InsertItem (pszItemName, iIconIndex, iIconIndex, hParentNode, TVI_SORT); - ASSERT (hItem != NULL); + ASSERT (hItem != nullptr); // Allocate a new asset information class to associate with this entry AssetInfoClass *asset_info = new AssetInfoClass (pszItemName, assetType); @@ -415,7 +415,7 @@ CDataTreeView::LoadAssetsIntoTree (void) // to the new HLOD format for (int index = 0; index < dist_lod_list.Count (); index ++) { HLodClass *plod = (HLodClass *)WW3DAssetManager::Get_Instance ()->Create_Render_Obj (dist_lod_list[index]); - if (plod != NULL) { + if (plod != nullptr) { HLodDefClass *definition = new HLodDefClass (*plod); HLodPrototypeClass *prototype = new HLodPrototypeClass (definition); WW3DAssetManager::Get_Instance ()->Remove_Prototype (dist_lod_list[index]); @@ -468,16 +468,16 @@ CDataTreeView::LoadAnimationsIntoTree (void) HTREEITEM hNode; // Loop through all the hierarchies and add this animation to any pertinent ones for (hNode = FindFirstChildItemBasedOnHierarchyName (m_hHierarchyRoot, pszHierarchyName); - (hNode != NULL); + (hNode != nullptr); hNode = FindSiblingItemBasedOnHierarchyName (hNode, pszHierarchyName)) { // Is this animation already loaded into the tree? HTREEITEM hAnimationNode = FindChildItem (hNode, pszAnimName); - if (hAnimationNode == NULL) + if (hAnimationNode == nullptr) { // Add this animation as a child of the hierarchy hAnimationNode = GetTreeCtrl ().InsertItem (pszAnimName, m_iAnimationIcon, m_iAnimationIcon, hNode, TVI_SORT); - ASSERT (hAnimationNode != NULL); + ASSERT (hAnimationNode != nullptr); // Associate the items name with its entry GetTreeCtrl ().SetItemData (hAnimationNode, (ULONG)new AssetInfoClass (pszAnimName, TypeAnimation)); @@ -486,16 +486,16 @@ CDataTreeView::LoadAnimationsIntoTree (void) // Loop through all the aggregates and add this animation to any pertinent ones for (hNode = FindFirstChildItemBasedOnHierarchyName (m_hAggregateRoot, pszHierarchyName); - (hNode != NULL); + (hNode != nullptr); hNode = FindSiblingItemBasedOnHierarchyName (hNode, pszHierarchyName)) { // Is this animation already loaded into the tree? HTREEITEM hAnimationNode = FindChildItem (hNode, pszAnimName); - if (hAnimationNode == NULL) + if (hAnimationNode == nullptr) { // Add this animation as a child of the hierarchy hAnimationNode = GetTreeCtrl ().InsertItem (pszAnimName, m_iAnimationIcon, m_iAnimationIcon, hNode, TVI_SORT); - ASSERT (hAnimationNode != NULL); + ASSERT (hAnimationNode != nullptr); // Associate the items name with its entry GetTreeCtrl ().SetItemData (hAnimationNode, (ULONG)new AssetInfoClass (pszAnimName, TypeAnimation)); @@ -504,16 +504,16 @@ CDataTreeView::LoadAnimationsIntoTree (void) // Loop through all the hierarchies and add this animation to any pertinent ones for (hNode = FindFirstChildItemBasedOnHierarchyName (m_hLODRoot, pszHierarchyName); - (hNode != NULL); + (hNode != nullptr); hNode = FindSiblingItemBasedOnHierarchyName (hNode, pszHierarchyName)) { // Is this animation already loaded into the tree? HTREEITEM hAnimationNode = FindChildItem (hNode, pszAnimName); - if (hAnimationNode == NULL) + if (hAnimationNode == nullptr) { // Add this animation as a child of the hierarchy hAnimationNode = GetTreeCtrl ().InsertItem (pszAnimName, m_iAnimationIcon, m_iAnimationIcon, hNode, TVI_SORT); - ASSERT (hAnimationNode != NULL); + ASSERT (hAnimationNode != nullptr); // Associate the items name with its entry GetTreeCtrl ().SetItemData (hAnimationNode, (ULONG)new AssetInfoClass (pszAnimName, TypeAnimation)); @@ -527,7 +527,7 @@ CDataTreeView::LoadAnimationsIntoTree (void) // Free the object delete pAnimEnum; - pAnimEnum = NULL; + pAnimEnum = nullptr; } return ; @@ -542,7 +542,7 @@ CDataTreeView::LoadAnimationsIntoTree (HTREEITEM hItem) { // Get the data associated with this item AssetInfoClass *asset_info = (AssetInfoClass *)GetTreeCtrl ().GetItemData (hItem); - ASSERT (asset_info != NULL); + ASSERT (asset_info != nullptr); // Get an iterator from the asset manager that we can // use to enumerate the currently loaded assets @@ -571,11 +571,11 @@ CDataTreeView::LoadAnimationsIntoTree (HTREEITEM hItem) { // Is this animation already loaded into the tree? HTREEITEM hAnimationNode = FindChildItem (hItem, pszAnimName); - if (hAnimationNode == NULL) + if (hAnimationNode == nullptr) { // Add this animation as a child of the hierarchy hAnimationNode = GetTreeCtrl ().InsertItem (pszAnimName, m_iAnimationIcon, m_iAnimationIcon, hItem, TVI_SORT); - ASSERT (hAnimationNode != NULL); + ASSERT (hAnimationNode != nullptr); // Associate the items name with its entry GetTreeCtrl ().SetItemData (hAnimationNode, (ULONG)new AssetInfoClass (pszAnimName, TypeAnimation)); @@ -589,7 +589,7 @@ CDataTreeView::LoadAnimationsIntoTree (HTREEITEM hItem) // Free the object delete pAnimEnum; - pAnimEnum = NULL; + pAnimEnum = nullptr; } return ; @@ -669,7 +669,7 @@ CDataTreeView::Determine_Tree_Location // // Is this an aggregate? // - if (render_obj.Get_Base_Model_Name () != NULL) { + if (render_obj.Get_Base_Model_Name () != nullptr) { hroot = m_hAggregateRoot; type = TypeAggregate; icon_index = m_iAggregateIcon; @@ -753,20 +753,20 @@ CDataTreeView::Add_Asset_To_Tree bool retval = false; // Param OK? - ASSERT (name != NULL); - if (name != NULL) { + ASSERT (name != nullptr); + if (name != nullptr) { // Turn off repainting GetTreeCtrl ().SetRedraw (FALSE); // Determime where this asset should go - HTREEITEM hparent = NULL; + HTREEITEM hparent = nullptr; int icon_index = 0; Determine_Tree_Location (type, hparent, icon_index); // Is this asset already in the tree? HTREEITEM htree_item = FindChildItem (hparent, name); - if (htree_item == NULL) { + if (htree_item == nullptr) { // Add this object to the tree htree_item = GetTreeCtrl ().InsertItem (name, @@ -785,7 +785,7 @@ CDataTreeView::Add_Asset_To_Tree } // Success! - retval = (htree_item != NULL); + retval = (htree_item != nullptr); } // Select the instance (if requested) @@ -819,11 +819,11 @@ CDataTreeView::FindChildItem ) { // Assume we won't find the item - HTREEITEM hchild_item = NULL; + HTREEITEM hchild_item = nullptr; // Loop through all the children of this node for (HTREEITEM htree_item = GetTreeCtrl ().GetChildItem (hParentItem); - (htree_item != NULL) && (hchild_item == NULL); + (htree_item != nullptr) && (hchild_item == nullptr); htree_item = GetTreeCtrl ().GetNextSiblingItem (htree_item)) { // Get the data associated with this item @@ -856,11 +856,11 @@ CDataTreeView::FindChildItem ) { // Assume we won't find the item - HTREEITEM hChildItem = NULL; + HTREEITEM hChildItem = nullptr; // Loop through all the children of this node for (HTREEITEM hTreeItem = GetTreeCtrl ().GetChildItem (hParentItem); - (hTreeItem != NULL) && (hChildItem == NULL); + (hTreeItem != nullptr) && (hChildItem == nullptr); hTreeItem = GetTreeCtrl ().GetNextSiblingItem (hTreeItem)) { // Is this the child item we were looking for? @@ -888,12 +888,12 @@ CDataTreeView::FindSiblingItemBasedOnHierarchyName ) { // Assume we won't find the item - HTREEITEM hSiblingItem = NULL; + HTREEITEM hSiblingItem = nullptr; // Loop through all the siblings of this node HTREEITEM hTreeItem = hCurrentItem; - while (((hTreeItem = GetTreeCtrl ().GetNextSiblingItem (hTreeItem)) != NULL) && - (hSiblingItem == NULL)) + while (((hTreeItem = GetTreeCtrl ().GetNextSiblingItem (hTreeItem)) != nullptr) && + (hSiblingItem == nullptr)) { // Get the data associated with this item AssetInfoClass *asset_info = (AssetInfoClass *)GetTreeCtrl ().GetItemData (hTreeItem); @@ -924,11 +924,11 @@ CDataTreeView::FindFirstChildItemBasedOnHierarchyName ) { // Assume we won't find the item - HTREEITEM hChildItem = NULL; + HTREEITEM hChildItem = nullptr; // Loop through all the children of this node for (HTREEITEM hTreeItem = GetTreeCtrl ().GetChildItem (hParentItem); - (hTreeItem != NULL) && (hChildItem == NULL); + (hTreeItem != nullptr) && (hChildItem == nullptr); hTreeItem = GetTreeCtrl ().GetNextSiblingItem (hTreeItem)) { // Get the data associated with this item @@ -977,24 +977,24 @@ CDataTreeView::OnSelChanged void CDataTreeView::Display_Asset (HTREEITEM htree_item) { - if (htree_item == NULL) { + if (htree_item == nullptr) { htree_item = GetTreeCtrl ().GetSelectedItem (); } // // Get the object associated with this entry // - AssetInfoClass *asset_info = NULL; - if (htree_item != NULL) { + AssetInfoClass *asset_info = nullptr; + if (htree_item != nullptr) { asset_info = (AssetInfoClass *)GetTreeCtrl ().GetItemData (htree_item); } - if (asset_info != NULL) { + if (asset_info != nullptr) { // Get the current document, so we can get a pointer to the scene CW3DViewDoc *pdoc = (CW3DViewDoc *)GetDocument (); - ASSERT (pdoc != NULL); - if (pdoc != NULL) { + ASSERT (pdoc != nullptr); + if (pdoc != nullptr) { // What type of asset is it? switch (asset_info->Get_Type ()) @@ -1003,7 +1003,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item) case TypeAnimation: { HTREEITEM hParentItem = GetTreeCtrl ().GetParentItem (htree_item); - if (hParentItem != NULL) { + if (hParentItem != nullptr) { // Ask the document to start playing the animation for this object RenderObjClass *prender_obj = Create_Render_Obj_To_Display (hParentItem); @@ -1042,7 +1042,7 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item) // Get the main window of our app CMainFrame *pCMainWnd = (CMainFrame *)::AfxGetMainWnd (); - if (pCMainWnd != NULL) { + if (pCMainWnd != nullptr) { // Let the main window know our selection type has changed pCMainWnd->OnSelectionChanged (asset_info->Get_Type ()); @@ -1064,12 +1064,12 @@ CDataTreeView::Display_Asset (HTREEITEM htree_item) // Reset the display CW3DViewDoc* pdoc = (CW3DViewDoc *)GetDocument (); - ASSERT (pdoc != NULL); - if (pdoc != NULL) { - pdoc->DisplayObject ((RenderObjClass *)NULL); + ASSERT (pdoc != nullptr); + if (pdoc != nullptr) { + pdoc->DisplayObject ((RenderObjClass *)nullptr); CMainFrame *main_wnd = (CMainFrame *)::AfxGetMainWnd (); - if (main_wnd != NULL) { + if (main_wnd != nullptr) { main_wnd->OnSelectionChanged (TypeUnknown); } } @@ -1104,7 +1104,7 @@ CDataTreeView::OnDeleteItem SAFE_DELETE (asset_info); // Reset the data associated with this entry - GetTreeCtrl ().SetItemData (pNMTreeView->itemOld.hItem, NULL); + GetTreeCtrl ().SetItemData (pNMTreeView->itemOld.hItem, 0); (*pResult) = 0; return ; } @@ -1117,11 +1117,11 @@ CDataTreeView::OnDeleteItem AssetInfoClass * CDataTreeView::Get_Current_Asset_Info (void) const { - AssetInfoClass *asset_info = NULL; + AssetInfoClass *asset_info = nullptr; // Get the currently selected node from the tree control HTREEITEM htree_item = GetTreeCtrl ().GetSelectedItem (); - if (htree_item != NULL) { + if (htree_item != nullptr) { // Get the data associated with this item asset_info = (AssetInfoClass *)GetTreeCtrl ().GetItemData (htree_item); @@ -1139,15 +1139,15 @@ CDataTreeView::Get_Current_Asset_Info (void) const RenderObjClass * CDataTreeView::Get_Current_Render_Obj (void) const { - RenderObjClass *prender_obj = NULL; + RenderObjClass *prender_obj = nullptr; // Get the currently selected node from the tree control HTREEITEM htree_item = GetTreeCtrl ().GetSelectedItem (); - if (htree_item != NULL) { + if (htree_item != nullptr) { // Get the data associated with this item AssetInfoClass *asset_info = (AssetInfoClass *)GetTreeCtrl ().GetItemData (htree_item); - if (asset_info != NULL) { + if (asset_info != nullptr) { // Return the render object pointer prender_obj = asset_info->Peek_Render_Obj (); @@ -1166,15 +1166,15 @@ CDataTreeView::Get_Current_Render_Obj (void) const LPCTSTR CDataTreeView::GetCurrentSelectionName (void) { - LPCTSTR pname = NULL; + LPCTSTR pname = nullptr; // Get the currently selected node from the tree control HTREEITEM htree_item = GetTreeCtrl ().GetSelectedItem (); - if (htree_item != NULL) { + if (htree_item != nullptr) { // Get the data associated with this item AssetInfoClass *asset_info = (AssetInfoClass *)GetTreeCtrl ().GetItemData (htree_item); - if (asset_info != NULL) { + if (asset_info != nullptr) { // Return the name of the asset to the caller pname = asset_info->Get_Name (); @@ -1196,11 +1196,11 @@ CDataTreeView::GetCurrentSelectionType (void) // Get the currently selected node from the tree control HTREEITEM htree_item = GetTreeCtrl ().GetSelectedItem (); - if (htree_item != NULL) { + if (htree_item != nullptr) { // Get the associated asset information for this node. AssetInfoClass *asset_info = (AssetInfoClass *)GetTreeCtrl ().GetItemData (htree_item); - if (asset_info != NULL) { + if (asset_info != nullptr) { type = asset_info->Get_Type (); } } @@ -1222,7 +1222,7 @@ CDataTreeView::OnDblclk { // Get the main window of our app CMainFrame *pCMainWnd = (CMainFrame *)::AfxGetMainWnd (); - if (pCMainWnd != NULL) + if (pCMainWnd != nullptr) { // Display the properties for the currently selected object //pCMainWnd->ShowObjectProperties (); @@ -1246,12 +1246,12 @@ CDataTreeView::Build_Render_Object_List { // Loop through all the children of this node for (HTREEITEM htree_item = GetTreeCtrl ().GetChildItem (hparent); - (htree_item != NULL); + (htree_item != nullptr); htree_item = GetTreeCtrl ().GetNextSiblingItem (htree_item)) { // Determine if this is an asset type we want to add to the list AssetInfoClass *asset_info = (AssetInfoClass *)GetTreeCtrl ().GetItemData (htree_item); - if ((asset_info != NULL) && + if ((asset_info != nullptr) && (asset_info->Get_Type () != TypeAnimation) && (asset_info->Get_Type () != TypeCompressedAnimation) && (asset_info->Get_Type () != TypeMaterial)) @@ -1278,18 +1278,18 @@ RenderObjClass * CDataTreeView::Create_Render_Obj_To_Display (HTREEITEM htree_item) { // Lookup the information object associated with this asset - RenderObjClass *render_obj = NULL; + RenderObjClass *render_obj = nullptr; AssetInfoClass *asset_info = (AssetInfoClass *)GetTreeCtrl ().GetItemData (htree_item); - if (asset_info != NULL) { + if (asset_info != nullptr) { // Use the asset's instance if there is one, otherwise attempt to create one render_obj = asset_info->Get_Render_Obj (); - if (render_obj == NULL) { + if (render_obj == nullptr) { // If this is a texture, then create a special BMP obj from it if (asset_info->Get_Type () == TypeMaterial) { TextureClass *ptexture = (TextureClass *)asset_info->Get_User_Number (); - if (ptexture != NULL) { + if (ptexture != nullptr) { render_obj = new Bitmap2DObjClass (ptexture, 0.5F, 0.5F, true, false, false, true); } } @@ -1297,7 +1297,7 @@ CDataTreeView::Create_Render_Obj_To_Display (HTREEITEM htree_item) // // Finally, if we aren't successful, create a new instance based on its name // - if (render_obj == NULL) { + if (render_obj == nullptr) { render_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj (asset_info->Get_Name ()); } } @@ -1306,7 +1306,7 @@ CDataTreeView::Create_Render_Obj_To_Display (HTREEITEM htree_item) // // Force the highest level LOD // - if ( render_obj != NULL && + if ( render_obj != nullptr && ::GetCurrentDocument ()->GetScene ()->Are_LODs_Switching () == false) { Set_Highest_LOD (render_obj); @@ -1329,26 +1329,26 @@ CDataTreeView::Refresh_Asset ) { // Params OK? - if ((new_name != NULL) && (old_name != NULL)) { + if ((new_name != nullptr) && (old_name != nullptr)) { // Turn off repainting GetTreeCtrl ().SetRedraw (FALSE); // Determime where this asset should go - HTREEITEM hparent = NULL; + HTREEITEM hparent = nullptr; int icon_index = 0; Determine_Tree_Location (type, hparent, icon_index); // Can we find the item we are supposed to refresh? HTREEITEM htree_item = FindChildItem (hparent, old_name); - if (htree_item != NULL) { + if (htree_item != nullptr) { // Refresh the item's text in the tree control GetTreeCtrl ().SetItemText (htree_item, new_name); // Refresh the associated asset info structure AssetInfoClass *asset_info = (AssetInfoClass *)GetTreeCtrl ().GetItemData (htree_item); - if (asset_info != NULL) { + if (asset_info != nullptr) { asset_info->Set_Name (new_name); } } else { @@ -1380,13 +1380,13 @@ CDataTreeView::Select_Next (void) // Get the selected entry in the tree control // HTREEITEM hselected = GetTreeCtrl ().GetSelectedItem (); - if (hselected != NULL) { + if (hselected != nullptr) { // // Select the item that follows the currently selected item // HTREEITEM hitem = GetTreeCtrl ().GetNextItem (hselected, TVGN_NEXT); - if (hitem != NULL) { + if (hitem != nullptr) { GetTreeCtrl ().SelectItem (hitem); } } @@ -1406,13 +1406,13 @@ CDataTreeView::Select_Prev (void) // Get the selected entry in the tree control // HTREEITEM hselected = GetTreeCtrl ().GetSelectedItem (); - if (hselected != NULL) { + if (hselected != nullptr) { // // Select the item that follows the currently selected item // HTREEITEM hitem = GetTreeCtrl ().GetNextItem (hselected, TVGN_PREVIOUS); - if (hitem != NULL) { + if (hitem != nullptr) { GetTreeCtrl ().SelectItem (hitem); } } @@ -1448,14 +1448,14 @@ CDataTreeView::Free_Child_Models (HTREEITEM parent_item) // Loop through all the children of this node // for ( HTREEITEM tree_item = GetTreeCtrl ().GetChildItem (parent_item); - tree_item != NULL; + tree_item != nullptr; tree_item = GetTreeCtrl ().GetNextSiblingItem (tree_item)) { // // Get the data associated with this item // AssetInfoClass *asset_info = (AssetInfoClass *)GetTreeCtrl ().GetItemData (tree_item); - if (asset_info != NULL) { + if (asset_info != nullptr) { WW3DAssetManager::Get_Instance ()->Remove_Prototype (asset_info->Get_Name ()); } } @@ -1472,10 +1472,10 @@ CDataTreeView::Free_Child_Models (HTREEITEM parent_item) void Set_Highest_LOD (RenderObjClass *render_obj) { - if (render_obj != NULL) { + if (render_obj != nullptr) { for (int index = 0; index < render_obj->Get_Num_Sub_Objects (); index ++) { RenderObjClass *sub_obj = render_obj->Get_Sub_Object (index); - if (sub_obj != NULL) { + if (sub_obj != nullptr) { Set_Highest_LOD (sub_obj); } REF_PTR_RELEASE (sub_obj); diff --git a/Core/Tools/W3DView/DataTreeView.h b/Core/Tools/W3DView/DataTreeView.h index 2882cf719b4..a060943a31f 100644 --- a/Core/Tools/W3DView/DataTreeView.h +++ b/Core/Tools/W3DView/DataTreeView.h @@ -104,7 +104,7 @@ class CDataTreeView : public CTreeView // // Display methods // - void Display_Asset (HTREEITEM htree_item = NULL); + void Display_Asset (HTREEITEM htree_item = nullptr); void Select_Next (void); void Select_Prev (void); void Reload_Lightmap_Models (void); diff --git a/Core/Tools/W3DView/DeviceSelectionDialog.cpp b/Core/Tools/W3DView/DeviceSelectionDialog.cpp index fb5d7dd5275..8c0af94d1d7 100644 --- a/Core/Tools/W3DView/DeviceSelectionDialog.cpp +++ b/Core/Tools/W3DView/DeviceSelectionDialog.cpp @@ -45,7 +45,7 @@ static char THIS_FILE[] = __FILE__; CDeviceSelectionDialog::CDeviceSelectionDialog ( BOOL bLookupCachedInfo, - CWnd* pParent /*=NULL*/ + CWnd* pParent /*=nullptr*/ ) : m_iDeviceIndex (1), m_iBitsPerPixel (16), diff --git a/Core/Tools/W3DView/DeviceSelectionDialog.h b/Core/Tools/W3DView/DeviceSelectionDialog.h index 18d67c60ca5..c62f0380b84 100644 --- a/Core/Tools/W3DView/DeviceSelectionDialog.h +++ b/Core/Tools/W3DView/DeviceSelectionDialog.h @@ -28,7 +28,7 @@ class CDeviceSelectionDialog : public CDialog { // Construction public: - CDeviceSelectionDialog(BOOL bLookupCachedInfo = TRUE, CWnd* pParent = NULL); // standard constructor + CDeviceSelectionDialog(BOOL bLookupCachedInfo = TRUE, CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CDeviceSelectionDialog) diff --git a/Core/Tools/W3DView/DirectoryDialog.cpp b/Core/Tools/W3DView/DirectoryDialog.cpp index efa0cf6c38b..a542bdac8c9 100644 --- a/Core/Tools/W3DView/DirectoryDialog.cpp +++ b/Core/Tools/W3DView/DirectoryDialog.cpp @@ -78,7 +78,7 @@ Browse_For_Folder (HWND parent_wnd, LPCTSTR initial_path, CString &path) { bool retval = false; - OPENFILENAME openfilename = { sizeof (OPENFILENAME), 0 }; + OPENFILENAME openfilename = { sizeof (OPENFILENAME), nullptr }; TCHAR filename[MAX_PATH] = { 0 }; openfilename.lpstrInitialDir = initial_path; diff --git a/Core/Tools/W3DView/EditLODDialog.cpp b/Core/Tools/W3DView/EditLODDialog.cpp index f00c487d6fa..a8e46a3fefc 100644 --- a/Core/Tools/W3DView/EditLODDialog.cpp +++ b/Core/Tools/W3DView/EditLODDialog.cpp @@ -47,7 +47,7 @@ const int COL_SWITCH_DN = 2; // // CEditLODDialog // -CEditLODDialog::CEditLODDialog(CWnd* pParent /*=NULL*/) +CEditLODDialog::CEditLODDialog(CWnd* pParent /*=nullptr*/) : m_spinIncrement (0.5F), CDialog(CEditLODDialog::IDD, pParent) { @@ -117,7 +117,7 @@ CEditLODDialog::OnInitDialog (void) m_hierarchyListCtrl.InsertColumn (COL_SWITCH_DN, "Switch Down"); RenderObjClass *pfirst_subobj = pLOD->Get_Sub_Object (0); - if (pfirst_subobj != NULL) { + if (pfirst_subobj != nullptr) { m_spinIncrement = pfirst_subobj->Get_Bounding_Sphere ().Radius / 5.0F; REF_PTR_RELEASE (pfirst_subobj); } diff --git a/Core/Tools/W3DView/EditLODDialog.h b/Core/Tools/W3DView/EditLODDialog.h index 94187d1ea46..67e00330a22 100644 --- a/Core/Tools/W3DView/EditLODDialog.h +++ b/Core/Tools/W3DView/EditLODDialog.h @@ -28,7 +28,7 @@ class CEditLODDialog : public CDialog { // Construction public: - CEditLODDialog(CWnd* pParent = NULL); // standard constructor + CEditLODDialog(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CEditLODDialog) diff --git a/Core/Tools/W3DView/EmitterColorPropPage.cpp b/Core/Tools/W3DView/EmitterColorPropPage.cpp index e72c04317ab..50ab0d9c8d6 100644 --- a/Core/Tools/W3DView/EmitterColorPropPage.cpp +++ b/Core/Tools/W3DView/EmitterColorPropPage.cpp @@ -46,10 +46,10 @@ IMPLEMENT_DYNCREATE(EmitterColorPropPageClass, CPropertyPage) // ///////////////////////////////////////////////////////////// EmitterColorPropPageClass::EmitterColorPropPageClass (EmitterInstanceListClass *pemitter) - : m_pEmitterList (NULL), + : m_pEmitterList (nullptr), m_bValid (true), - m_ColorBar (NULL), - m_OpacityBar (NULL), + m_ColorBar (nullptr), + m_OpacityBar (nullptr), m_Lifetime (0), CPropertyPage (EmitterColorPropPageClass::IDD) { @@ -133,7 +133,7 @@ EmitterColorPropPageClass::Initialize (void) SAFE_DELETE_ARRAY (m_CurrentOpacities.KeyTimes); SAFE_DELETE_ARRAY (m_CurrentOpacities.Values); - if (m_pEmitterList != NULL) { + if (m_pEmitterList != nullptr) { m_Lifetime = m_pEmitterList->Get_Lifetime (); @@ -662,7 +662,7 @@ EmitterColorPropPageClass::On_Lifetime_Changed (float lifetime) m_pEmitterList->Set_Color_Keyframes (m_CurrentColors); m_pEmitterList->Set_Opacity_Keyframes (m_CurrentOpacities); m_Lifetime = lifetime; - /*if (m_hWnd != NULL) { + /*if (m_hWnd != nullptr) { Update_Colors (); Update_Opacities (); }*/ diff --git a/Core/Tools/W3DView/EmitterColorPropPage.h b/Core/Tools/W3DView/EmitterColorPropPage.h index 4c33199bbb6..f0a511c2f26 100644 --- a/Core/Tools/W3DView/EmitterColorPropPage.h +++ b/Core/Tools/W3DView/EmitterColorPropPage.h @@ -38,7 +38,7 @@ class EmitterColorPropPageClass : public CPropertyPage // Construction public: - EmitterColorPropPageClass (EmitterInstanceListClass *pemitter_list = NULL); + EmitterColorPropPageClass (EmitterInstanceListClass *pemitter_list = nullptr); ~EmitterColorPropPageClass (); // Dialog Data diff --git a/Core/Tools/W3DView/EmitterFramePropPage.cpp b/Core/Tools/W3DView/EmitterFramePropPage.cpp index 865536ae368..d18d01f9d86 100644 --- a/Core/Tools/W3DView/EmitterFramePropPage.cpp +++ b/Core/Tools/W3DView/EmitterFramePropPage.cpp @@ -44,9 +44,9 @@ IMPLEMENT_DYNCREATE(EmitterFramePropPageClass, CPropertyPage) ///////////////////////////////////////////////////////////// EmitterFramePropPageClass::EmitterFramePropPageClass() : CPropertyPage(EmitterFramePropPageClass::IDD), - m_pEmitterList(NULL), + m_pEmitterList(nullptr), m_bValid(true), - m_FrameBar(NULL), + m_FrameBar(nullptr), m_Lifetime(0), m_MinFrame(0), m_MaxFrame(1) @@ -103,7 +103,7 @@ EmitterFramePropPageClass::Initialize (void) SAFE_DELETE_ARRAY (m_Frames.KeyTimes); SAFE_DELETE_ARRAY (m_Frames.Values); - if (m_pEmitterList != NULL) { + if (m_pEmitterList != nullptr) { m_Lifetime = m_pEmitterList->Get_Lifetime (); m_pEmitterList->Get_Frame_Keyframes (m_Frames); @@ -213,7 +213,7 @@ BOOL EmitterFramePropPageClass::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* // Update the spinner controls if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); } diff --git a/Core/Tools/W3DView/EmitterGeneralPropPage.cpp b/Core/Tools/W3DView/EmitterGeneralPropPage.cpp index 20834f603de..852c078d3d9 100644 --- a/Core/Tools/W3DView/EmitterGeneralPropPage.cpp +++ b/Core/Tools/W3DView/EmitterGeneralPropPage.cpp @@ -46,8 +46,8 @@ IMPLEMENT_DYNCREATE(EmitterGeneralPropPageClass, CPropertyPage) // EmitterGeneralPropPageClass // EmitterGeneralPropPageClass::EmitterGeneralPropPageClass (EmitterInstanceListClass *pemitter) - : m_pEmitterList (NULL), - m_Parent (NULL), + : m_pEmitterList (nullptr), + m_Parent (nullptr), m_bValid (true), m_Lifetime (0), CPropertyPage(EmitterGeneralPropPageClass::IDD) @@ -105,7 +105,7 @@ END_MESSAGE_MAP() void EmitterGeneralPropPageClass::Initialize (void) { - if (m_pEmitterList != NULL) { + if (m_pEmitterList != nullptr) { // // Get the emitter's texture @@ -219,7 +219,7 @@ EmitterGeneralPropPageClass::OnApply (void) int index = SendDlgItemMessage (IDC_SHADER_COMBO, CB_GETCURSEL); if (index != CB_ERR) { ShaderClass *shader = (ShaderClass *)SendDlgItemMessage (IDC_SHADER_COMBO, CB_GETITEMDATA, (WPARAM)index); - if (shader != NULL) { + if (shader != nullptr) { m_Shader = (*shader); } } @@ -259,7 +259,7 @@ EmitterGeneralPropPageClass::OnBrowseButton (void) { CFileDialog openFileDialog (TRUE, ".tga", - NULL, + nullptr, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER, "Textures files (*.tga)|*.tga||", ::AfxGetMainWnd ()); @@ -314,7 +314,7 @@ EmitterGeneralPropPageClass::OnNotify // Update the spinner control if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); } @@ -377,7 +377,7 @@ EmitterGeneralPropPageClass::OnCommand case IDC_RENDER_MODE_COMBO: if (HIWORD (wParam) == CBN_SELCHANGE) { SetModified (); - if (m_Parent != NULL) { + if (m_Parent != nullptr) { int cur_mode = ::SendMessage ((HWND)lParam, CB_GETCURSEL, 0, 0); m_Parent->Notify_Render_Mode_Changed(cur_mode); } diff --git a/Core/Tools/W3DView/EmitterGeneralPropPage.h b/Core/Tools/W3DView/EmitterGeneralPropPage.h index bb81f4a261e..56894bd680e 100644 --- a/Core/Tools/W3DView/EmitterGeneralPropPage.h +++ b/Core/Tools/W3DView/EmitterGeneralPropPage.h @@ -38,7 +38,7 @@ class EmitterGeneralPropPageClass : public CPropertyPage // Construction public: - EmitterGeneralPropPageClass (EmitterInstanceListClass *pemitter_list = NULL); + EmitterGeneralPropPageClass (EmitterInstanceListClass *pemitter_list = nullptr); ~EmitterGeneralPropPageClass (); // Dialog Data diff --git a/Core/Tools/W3DView/EmitterInstanceList.cpp b/Core/Tools/W3DView/EmitterInstanceList.cpp index a4f66a0e971..a321224cf44 100644 --- a/Core/Tools/W3DView/EmitterInstanceList.cpp +++ b/Core/Tools/W3DView/EmitterInstanceList.cpp @@ -75,8 +75,8 @@ EmitterInstanceListClass::Free_List (void) void EmitterInstanceListClass::Add_Emitter (ParticleEmitterClass *emitter) { - ASSERT (emitter != NULL); - if (emitter != NULL) { + ASSERT (emitter != nullptr); + if (emitter != nullptr) { // // If this is the first emitter in the list, then initialize @@ -84,7 +84,7 @@ EmitterInstanceListClass::Add_Emitter (ParticleEmitterClass *emitter) // if (m_List.Count () == 0) { ParticleEmitterDefClass *def = emitter->Build_Definition (); - if (def != NULL) { + if (def != nullptr) { ParticleEmitterDefClass::operator= (*def); SAFE_DELETE (def); } @@ -216,7 +216,7 @@ void EmitterInstanceListClass::Set_Velocity_Random (Vector3Randomizer *randomizer) { ParticleEmitterDefClass::Set_Velocity_Random (randomizer); - if (randomizer != NULL) { + if (randomizer != nullptr) { // // Pass this setting onto the emitters immediately diff --git a/Core/Tools/W3DView/EmitterLineGroupPropPage.cpp b/Core/Tools/W3DView/EmitterLineGroupPropPage.cpp index 32a7faba177..1ee23a62c48 100644 --- a/Core/Tools/W3DView/EmitterLineGroupPropPage.cpp +++ b/Core/Tools/W3DView/EmitterLineGroupPropPage.cpp @@ -41,9 +41,9 @@ IMPLEMENT_DYNCREATE(EmitterLineGroupPropPageClass, CPropertyPage) EmitterLineGroupPropPageClass::EmitterLineGroupPropPageClass() : CPropertyPage(EmitterLineGroupPropPageClass::IDD), - m_pEmitterList(NULL), + m_pEmitterList(nullptr), m_bValid(true), - m_BlurTimeBar(NULL), + m_BlurTimeBar(nullptr), m_Lifetime(0), m_MinBlurTime(0), m_MaxBlurTime(1) @@ -89,7 +89,7 @@ EmitterLineGroupPropPageClass::Initialize (void) SAFE_DELETE_ARRAY (m_BlurTimes.KeyTimes); SAFE_DELETE_ARRAY (m_BlurTimes.Values); - if (m_pEmitterList != NULL) { + if (m_pEmitterList != nullptr) { m_Lifetime = m_pEmitterList->Get_Lifetime (); m_pEmitterList->Get_Blur_Time_Keyframes (m_BlurTimes); @@ -259,7 +259,7 @@ BOOL EmitterLineGroupPropPageClass::OnNotify(WPARAM wParam, LPARAM lParam, LRESU // Update the spinner controls if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); } diff --git a/Core/Tools/W3DView/EmitterLinePropPage.cpp b/Core/Tools/W3DView/EmitterLinePropPage.cpp index 91c1a5a5fff..22f0bf79e58 100644 --- a/Core/Tools/W3DView/EmitterLinePropPage.cpp +++ b/Core/Tools/W3DView/EmitterLinePropPage.cpp @@ -39,7 +39,7 @@ IMPLEMENT_DYNCREATE(EmitterLinePropPageClass, CPropertyPage) EmitterLinePropPageClass::EmitterLinePropPageClass() : CPropertyPage(EmitterLinePropPageClass::IDD), - m_pEmitterList(NULL), + m_pEmitterList(nullptr), m_bValid(true), m_MappingMode(W3D_EMITTER_RENDER_MODE_TRI_PARTICLES), m_MergeIntersections(false), @@ -92,7 +92,7 @@ END_MESSAGE_MAP() void EmitterLinePropPageClass::Initialize (void) { - if (m_pEmitterList != NULL) { + if (m_pEmitterList != nullptr) { // // Read the settings from the emitter @@ -220,7 +220,7 @@ BOOL EmitterLinePropPageClass::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* p // Update the spinner control if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); SetModified (); diff --git a/Core/Tools/W3DView/EmitterParticlePropPage.cpp b/Core/Tools/W3DView/EmitterParticlePropPage.cpp index cff67fb2418..f07e646e1ee 100644 --- a/Core/Tools/W3DView/EmitterParticlePropPage.cpp +++ b/Core/Tools/W3DView/EmitterParticlePropPage.cpp @@ -50,7 +50,7 @@ EmitterParticlePropPageClass::EmitterParticlePropPageClass (EmitterInstanceListC m_Rate (0), m_BurstSize (0), m_MaxParticles (0), - m_Randomizer (NULL), + m_Randomizer (nullptr), CPropertyPage(EmitterParticlePropPageClass::IDD) { //{{AFX_DATA_INIT(EmitterParticlePropPageClass) @@ -105,7 +105,7 @@ void EmitterParticlePropPageClass::Initialize (void) { SAFE_DELETE (m_Randomizer); - if (m_pEmitterList != NULL) { + if (m_pEmitterList != nullptr) { // // Read the settings from the emitter @@ -220,7 +220,7 @@ EmitterParticlePropPageClass::OnNotify // Update the spinner control if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); SetModified (); diff --git a/Core/Tools/W3DView/EmitterParticlePropPage.h b/Core/Tools/W3DView/EmitterParticlePropPage.h index ae3702d755b..bdb4135a1df 100644 --- a/Core/Tools/W3DView/EmitterParticlePropPage.h +++ b/Core/Tools/W3DView/EmitterParticlePropPage.h @@ -38,7 +38,7 @@ class EmitterParticlePropPageClass : public CPropertyPage // Construction public: - EmitterParticlePropPageClass (EmitterInstanceListClass *pemitter_list = NULL); + EmitterParticlePropPageClass (EmitterInstanceListClass *pemitter_list = nullptr); ~EmitterParticlePropPageClass (); // Dialog Data diff --git a/Core/Tools/W3DView/EmitterPhysicsPropPage.cpp b/Core/Tools/W3DView/EmitterPhysicsPropPage.cpp index 465b9e64b11..7449f8e0c3e 100644 --- a/Core/Tools/W3DView/EmitterPhysicsPropPage.cpp +++ b/Core/Tools/W3DView/EmitterPhysicsPropPage.cpp @@ -44,13 +44,13 @@ IMPLEMENT_DYNCREATE(EmitterPhysicsPropPageClass, CPropertyPage) // ///////////////////////////////////////////////////////////// EmitterPhysicsPropPageClass::EmitterPhysicsPropPageClass (EmitterInstanceListClass *pemitter) - : m_pEmitterList (NULL), + : m_pEmitterList (nullptr), m_bValid (true), m_Velocity (0, 0, 1), m_Acceleration (0, 0, 0), m_OutFactor (0), m_InheritanceFactor (0), - m_Randomizer (NULL), + m_Randomizer (nullptr), CPropertyPage(EmitterPhysicsPropPageClass::IDD) { //{{AFX_DATA_INIT(EmitterPhysicsPropPageClass) @@ -112,7 +112,7 @@ void EmitterPhysicsPropPageClass::Initialize (void) { SAFE_DELETE (m_Randomizer); - if (m_pEmitterList != NULL) { + if (m_pEmitterList != nullptr) { // // Get the emitter's settings @@ -204,7 +204,7 @@ EmitterPhysicsPropPageClass::OnNotify // Update the spinner control if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); On_Setting_Changed (wParam); @@ -231,7 +231,7 @@ EmitterPhysicsPropPageClass::OnSpecifyVelocityRandom (void) // SAFE_DELETE (m_Randomizer); m_Randomizer = dialog.Get_Randomizer (); - if (m_Randomizer != NULL) { + if (m_Randomizer != nullptr) { m_pEmitterList->Set_Velocity_Random (m_Randomizer->Clone ()); SetModified (); } diff --git a/Core/Tools/W3DView/EmitterPhysicsPropPage.h b/Core/Tools/W3DView/EmitterPhysicsPropPage.h index 2b2c35cd60e..9900f7e835b 100644 --- a/Core/Tools/W3DView/EmitterPhysicsPropPage.h +++ b/Core/Tools/W3DView/EmitterPhysicsPropPage.h @@ -37,7 +37,7 @@ class EmitterPhysicsPropPageClass : public CPropertyPage // Construction public: - EmitterPhysicsPropPageClass (EmitterInstanceListClass *pemitter_list = NULL); + EmitterPhysicsPropPageClass (EmitterInstanceListClass *pemitter_list = nullptr); ~EmitterPhysicsPropPageClass (); // Dialog Data diff --git a/Core/Tools/W3DView/EmitterPropertySheet.cpp b/Core/Tools/W3DView/EmitterPropertySheet.cpp index 0b3eed55b27..6258ebdf9fb 100644 --- a/Core/Tools/W3DView/EmitterPropertySheet.cpp +++ b/Core/Tools/W3DView/EmitterPropertySheet.cpp @@ -65,7 +65,7 @@ EmitterPropertySheetClass::EmitterPropertySheetClass UINT nIDCaption, CWnd *pParentWnd ) - : m_pEmitterList (NULL), + : m_pEmitterList (nullptr), CPropertySheet (nIDCaption, pParentWnd, 0) { m_pEmitterList = emitter_list; @@ -84,7 +84,7 @@ EmitterPropertySheetClass::EmitterPropertySheetClass LPCTSTR pszCaption, CWnd *pParentWnd ) - : m_pEmitterList (NULL), + : m_pEmitterList (nullptr), CPropertySheet (pszCaption, pParentWnd, 0) { m_pEmitterList = emitter_list; @@ -192,7 +192,7 @@ void EmitterPropertySheetClass::Add_Emitter_To_Viewer (void) { CW3DViewDoc *pdoc = ::GetCurrentDocument (); - if ((pdoc != NULL) && (m_pEmitterList != NULL)) { + if ((pdoc != nullptr) && (m_pEmitterList != nullptr)) { // // Create a new prototype for this emitter and add it to the asset manager @@ -244,7 +244,7 @@ void EmitterPropertySheetClass::Update_Emitter (void) { // - // Update those pages that are dependant on the particle's + // Update those pages that are dependent on the particle's // lifetime. // float lifetime = m_GeneralPage.Get_Lifetime (); @@ -286,7 +286,7 @@ EmitterPropertySheetClass::Update_Emitter (void) void EmitterPropertySheetClass::Initialize (void) { - if (m_pEmitterList == NULL) { + if (m_pEmitterList == nullptr) { Create_New_Emitter (); } else { m_LastSavedName = m_pEmitterList->Get_Name (); @@ -305,10 +305,10 @@ EmitterPropertySheetClass::Initialize (void) m_LineGroupPage.Set_Emitter (m_pEmitterList); // Initialize the user page with data from the prototype - /*if (m_pEmitter != NULL) { - ParticleEmitterPrototypeClass *proto = NULL; + /*if (m_pEmitter != nullptr) { + ParticleEmitterPrototypeClass *proto = nullptr; proto = (ParticleEmitterPrototypeClass *)WW3DAssetManager::Get_Instance ()->Find_Prototype (m_pEmitter->Get_Name ()); - if (proto != NULL) { + if (proto != nullptr) { ParticleEmitterDefClass *definition = proto->Get_Definition (); m_UserPage.Set_Type (definition->Get_User_Type ()); m_UserPage.Set_String (definition->Get_User_String ()); @@ -382,7 +382,7 @@ EmitterPropertySheetClass::Create_Emitter (void) // // Load the texture // - TextureClass *ptexture = NULL; + TextureClass *ptexture = nullptr; if (texture_name.GetLength () > 0) { ptexture = WW3DAssetManager::Get_Instance()->Get_Texture (texture_name); } @@ -428,48 +428,48 @@ EmitterPropertySheetClass::Create_New_Emitter (void) color.Start = Vector3 (1, 1, 1); color.Rand.Set (0,0,0); color.NumKeyFrames = 0; - color.KeyTimes = NULL; - color.Values = NULL; + color.KeyTimes = nullptr; + color.Values = nullptr; ParticlePropertyStruct opacity; opacity.Start = 1.0F; opacity.Rand = 0.0F; opacity.NumKeyFrames = 0; - opacity.KeyTimes = NULL; - opacity.Values = NULL; + opacity.KeyTimes = nullptr; + opacity.Values = nullptr; ParticlePropertyStruct size; size.Start = 0.1F; size.Rand = 0.0F; size.NumKeyFrames = 0; - size.KeyTimes = NULL; - size.Values = NULL; + size.KeyTimes = nullptr; + size.Values = nullptr; ParticlePropertyStruct rotation; rotation.Start = 0.0f; rotation.Rand = 0.0f; rotation.NumKeyFrames = 0; - rotation.KeyTimes = NULL; - rotation.Values = NULL; + rotation.KeyTimes = nullptr; + rotation.Values = nullptr; ParticlePropertyStruct frames; frames.Start = 0.0f; frames.Rand = 0.0f; frames.NumKeyFrames = 0; - frames.KeyTimes = NULL; - frames.Values = NULL; + frames.KeyTimes = nullptr; + frames.Values = nullptr; ParticlePropertyStruct blurtimes; blurtimes.Start = 0.0f; blurtimes.Rand = 0.0f; blurtimes.NumKeyFrames = 0; - blurtimes.KeyTimes = NULL; - blurtimes.Values = NULL; + blurtimes.KeyTimes = nullptr; + blurtimes.Values = nullptr; // // Create the new emitter // - ParticleEmitterClass *emitter = NULL; + ParticleEmitterClass *emitter = nullptr; emitter = new ParticleEmitterClass (10, 1, new Vector3SolidBoxRandomizer(Vector3(0.1F, 0.1F, 0.1F)), @@ -487,7 +487,7 @@ EmitterPropertySheetClass::Create_New_Emitter (void) Vector3 (0, 0, 0), 1.0F, 0.0F, - NULL, + nullptr, ShaderClass::_PresetAdditiveSpriteShader, 0); diff --git a/Core/Tools/W3DView/EmitterPropertySheet.h b/Core/Tools/W3DView/EmitterPropertySheet.h index f0861029c8d..1430e719738 100644 --- a/Core/Tools/W3DView/EmitterPropertySheet.h +++ b/Core/Tools/W3DView/EmitterPropertySheet.h @@ -48,8 +48,8 @@ class EmitterPropertySheetClass : public CPropertySheet // Construction public: - EmitterPropertySheetClass (EmitterInstanceListClass *emitter_list, UINT nIDCaption, CWnd* pParentWnd = NULL); - EmitterPropertySheetClass (EmitterInstanceListClass *emitter_list, LPCTSTR pszCaption, CWnd* pParentWnd = NULL); + EmitterPropertySheetClass (EmitterInstanceListClass *emitter_list, UINT nIDCaption, CWnd* pParentWnd = nullptr); + EmitterPropertySheetClass (EmitterInstanceListClass *emitter_list, LPCTSTR pszCaption, CWnd* pParentWnd = nullptr); // Attributes public: diff --git a/Core/Tools/W3DView/EmitterRotationPropPage.cpp b/Core/Tools/W3DView/EmitterRotationPropPage.cpp index d3164102f8b..4c9dc0329cd 100644 --- a/Core/Tools/W3DView/EmitterRotationPropPage.cpp +++ b/Core/Tools/W3DView/EmitterRotationPropPage.cpp @@ -45,9 +45,9 @@ IMPLEMENT_DYNCREATE(EmitterRotationPropPageClass, CPropertyPage) ///////////////////////////////////////////////////////////// EmitterRotationPropPageClass::EmitterRotationPropPageClass() : CPropertyPage(EmitterRotationPropPageClass::IDD), - m_pEmitterList(NULL), + m_pEmitterList(nullptr), m_bValid(true), - m_RotationBar(NULL), + m_RotationBar(nullptr), m_Lifetime(0), m_MinRotation(0), m_MaxRotation(1), @@ -110,7 +110,7 @@ void EmitterRotationPropPageClass::Initialize (void) SAFE_DELETE_ARRAY (m_Rotations.KeyTimes); SAFE_DELETE_ARRAY (m_Rotations.Values); - if (m_pEmitterList != NULL) { + if (m_pEmitterList != nullptr) { m_Lifetime = m_pEmitterList->Get_Lifetime (); m_pEmitterList->Get_Rotation_Keyframes (m_Rotations); m_InitialOrientationRandom = m_pEmitterList->Get_Initial_Orientation_Random(); @@ -190,7 +190,7 @@ BOOL EmitterRotationPropPageClass::OnNotify(WPARAM wParam, LPARAM lParam, LRESUL // Update the spinner controls if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); } diff --git a/Core/Tools/W3DView/EmitterSizePropPage.cpp b/Core/Tools/W3DView/EmitterSizePropPage.cpp index 11a6e7cce70..f5a5b4efe4e 100644 --- a/Core/Tools/W3DView/EmitterSizePropPage.cpp +++ b/Core/Tools/W3DView/EmitterSizePropPage.cpp @@ -44,9 +44,9 @@ IMPLEMENT_DYNCREATE(EmitterSizePropPageClass, CPropertyPage) // ///////////////////////////////////////////////////////////// EmitterSizePropPageClass::EmitterSizePropPageClass (EmitterInstanceListClass *pemitter) - : m_pEmitterList (NULL), + : m_pEmitterList (nullptr), m_bValid (true), - m_SizeBar (NULL), + m_SizeBar (nullptr), m_Lifetime (0), CPropertyPage(EmitterSizePropPageClass::IDD) { @@ -114,7 +114,7 @@ EmitterSizePropPageClass::Initialize (void) SAFE_DELETE_ARRAY (m_CurrentSizes.KeyTimes); SAFE_DELETE_ARRAY (m_CurrentSizes.Values); - if (m_pEmitterList != NULL) { + if (m_pEmitterList != nullptr) { m_Lifetime = m_pEmitterList->Get_Lifetime (); m_pEmitterList->Get_Size_Keyframes (m_OrigSizes); m_pEmitterList->Get_Size_Keyframes (m_CurrentSizes); @@ -217,7 +217,7 @@ EmitterSizePropPageClass::OnNotify // Update the spinner controls if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); } diff --git a/Core/Tools/W3DView/EmitterSizePropPage.h b/Core/Tools/W3DView/EmitterSizePropPage.h index 14e4ca369b9..b525e00392a 100644 --- a/Core/Tools/W3DView/EmitterSizePropPage.h +++ b/Core/Tools/W3DView/EmitterSizePropPage.h @@ -38,7 +38,7 @@ class EmitterSizePropPageClass : public CPropertyPage // Construction public: - EmitterSizePropPageClass(EmitterInstanceListClass *pemitter = NULL); + EmitterSizePropPageClass(EmitterInstanceListClass *pemitter = nullptr); ~EmitterSizePropPageClass(); // Dialog Data diff --git a/Core/Tools/W3DView/EmitterUserPropPage.cpp b/Core/Tools/W3DView/EmitterUserPropPage.cpp index 92a6a7ad176..bc5cf79ccf4 100644 --- a/Core/Tools/W3DView/EmitterUserPropPage.cpp +++ b/Core/Tools/W3DView/EmitterUserPropPage.cpp @@ -42,7 +42,7 @@ IMPLEMENT_DYNCREATE(EmitterUserPropPageClass, CPropertyPage) // EmitterUserPropPageClass // EmitterUserPropPageClass::EmitterUserPropPageClass (EmitterInstanceListClass *pemitter) - : m_pEmitterList (NULL), + : m_pEmitterList (nullptr), m_bValid (true), m_iType (EMITTER_TYPEID_DEFAULT), CPropertyPage(EmitterUserPropPageClass::IDD) @@ -96,7 +96,7 @@ END_MESSAGE_MAP() void EmitterUserPropPageClass::Initialize (void) { - if (m_pEmitterList != NULL) { + if (m_pEmitterList != nullptr) { // Record the user information from the emitter (if it exists) m_iType = m_pEmitterList->Get_User_Type (); diff --git a/Core/Tools/W3DView/EmitterUserPropPage.h b/Core/Tools/W3DView/EmitterUserPropPage.h index 514c98ab920..e9edf67d60e 100644 --- a/Core/Tools/W3DView/EmitterUserPropPage.h +++ b/Core/Tools/W3DView/EmitterUserPropPage.h @@ -35,7 +35,7 @@ class EmitterUserPropPageClass : public CPropertyPage // Construction public: - EmitterUserPropPageClass (EmitterInstanceListClass *pemitter_list = NULL); + EmitterUserPropPageClass (EmitterInstanceListClass *pemitter_list = nullptr); ~EmitterUserPropPageClass (); // Dialog Data diff --git a/Core/Tools/W3DView/GammaDialog.cpp b/Core/Tools/W3DView/GammaDialog.cpp index 13f1e3a4cff..600c36fcdf7 100644 --- a/Core/Tools/W3DView/GammaDialog.cpp +++ b/Core/Tools/W3DView/GammaDialog.cpp @@ -34,7 +34,7 @@ static char THIS_FILE[] = __FILE__; // GammaDialogClass dialog -GammaDialogClass::GammaDialogClass(CWnd* pParent /*=NULL*/) +GammaDialogClass::GammaDialogClass(CWnd* pParent /*=nullptr*/) : CDialog(GammaDialogClass::IDD, pParent) { //{{AFX_DATA_INIT(GammaDialogClass) diff --git a/Core/Tools/W3DView/GammaDialog.h b/Core/Tools/W3DView/GammaDialog.h index 43adf086f45..6252b3d024b 100644 --- a/Core/Tools/W3DView/GammaDialog.h +++ b/Core/Tools/W3DView/GammaDialog.h @@ -28,7 +28,7 @@ class GammaDialogClass : public CDialog { // Construction public: - GammaDialogClass(CWnd* pParent = NULL); // standard constructor + GammaDialogClass(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(GammaDialogClass) diff --git a/Core/Tools/W3DView/Globals.cpp b/Core/Tools/W3DView/Globals.cpp index 45dfd6d7a38..b0328e5920a 100644 --- a/Core/Tools/W3DView/Globals.cpp +++ b/Core/Tools/W3DView/Globals.cpp @@ -31,7 +31,7 @@ #include "ViewerAssetMgr.h" // Main asset manager for the application. -ViewerAssetMgrClass *_TheAssetMgr = NULL; +ViewerAssetMgrClass *_TheAssetMgr = nullptr; int g_iDeviceIndex = -1;//DEFAULT_DEVICEINDEX; diff --git a/Core/Tools/W3DView/GraphicView.cpp b/Core/Tools/W3DView/GraphicView.cpp index e32acee1289..fb9c4a782fd 100644 --- a/Core/Tools/W3DView/GraphicView.cpp +++ b/Core/Tools/W3DView/GraphicView.cpp @@ -71,7 +71,7 @@ IMPLEMENT_DYNCREATE(CGraphicView, CView) //////////////////////////////////////////////////////////////////////////// CGraphicView::CGraphicView (void) : m_bInitialized (FALSE), - m_pCamera (NULL), + m_pCamera (nullptr), m_TimerID (0), m_bMouseDown (FALSE), m_bRMouseDown (FALSE), @@ -83,7 +83,7 @@ CGraphicView::CGraphicView (void) m_objectRotation (NoRotation), m_LightRotation (NoRotation), m_bLightMeshInScene (false), - m_pLightMesh (NULL), + m_pLightMesh (nullptr), m_ParticleCountUpdate (0), m_CameraBonePosX (false), m_UpdateCounter (0), @@ -213,11 +213,11 @@ CGraphicView::InitializeGraphicView (void) m_iWindowed) == WW3D_ERROR_OK); ASSERT (bReturn); - if (bReturn && (m_pCamera == NULL)) + if (bReturn && (m_pCamera == nullptr)) { // Instantiate a new camera class m_pCamera = new CameraClass (); - bReturn = (m_pCamera != NULL); + bReturn = (m_pCamera != nullptr); // Were we successful in creating a camera? ASSERT (m_pCamera); @@ -239,13 +239,13 @@ CGraphicView::InitializeGraphicView (void) Reset_FOV (); - if (m_pLightMesh == NULL) + if (m_pLightMesh == nullptr) { - ResourceFileClass light_mesh_file (NULL, "Light.w3d"); + ResourceFileClass light_mesh_file (nullptr, "Light.w3d"); WW3DAssetManager::Get_Instance()->Load_3D_Assets (light_mesh_file); m_pLightMesh = WW3DAssetManager::Get_Instance()->Create_Render_Obj ("LIGHT"); - ASSERT (m_pLightMesh != NULL); + ASSERT (m_pLightMesh != nullptr); m_bLightMeshInScene = false; } @@ -324,7 +324,7 @@ CGraphicView::OnDestroy (void) // // Remove the listener from the camera // - WWAudioClass::Get_Instance ()->Get_Sound_Scene ()->Attach_Listener_To_Obj (NULL); + WWAudioClass::Get_Instance ()->Get_Sound_Scene ()->Attach_Listener_To_Obj (nullptr); // // Free the camera object @@ -382,10 +382,10 @@ CGraphicView::OnInitialUpdate (void) void Set_Lowest_LOD (RenderObjClass *render_obj) { - if (render_obj != NULL) { + if (render_obj != nullptr) { for (int index = 0; index < render_obj->Get_Num_Sub_Objects (); index ++) { RenderObjClass *psub_obj = render_obj->Get_Sub_Object (index); - if (psub_obj != NULL) { + if (psub_obj != nullptr) { Set_Lowest_LOD (psub_obj); } REF_PTR_RELEASE (psub_obj); @@ -489,7 +489,7 @@ CGraphicView::RepaintView // Reset the current lod to be the lowest possible LOD... RenderObjClass *prender_obj = doc->GetDisplayedObject (); - if ((prender_obj != NULL) && + if ((prender_obj != nullptr) && (doc->GetScene ()->Are_LODs_Switching ())) { Set_Lowest_LOD (prender_obj); @@ -561,7 +561,7 @@ CGraphicView::RepaintView m_ParticleCountUpdate = cur_ticks; doc->Update_Particle_Count (); - int polys = (prender_obj != NULL) ? prender_obj->Get_Num_Polys () : 0; + int polys = (prender_obj != nullptr) ? prender_obj->Get_Num_Polys () : 0; ((CMainFrame *)::AfxGetMainWnd ())->UpdatePolygonCount (polys); } @@ -653,7 +653,7 @@ CGraphicView::WindowProc } RepaintView (FALSE); - ValidateRect (NULL); + ValidateRect (nullptr); return 0; } else if (message == WM_KEYDOWN) { @@ -694,11 +694,11 @@ fnTimerCallback ) { HWND hwnd = (HWND)dwUser; - if (hwnd != NULL) { + if (hwnd != nullptr) { // Send this event off to the view to process (hackish, but fine for now) - if ((GetProp (hwnd, "WaitingToProcess") == NULL) && - (GetProp (hwnd, "Inactive") == NULL)) { + if ((GetProp (hwnd, "WaitingToProcess") == nullptr) && + (GetProp (hwnd, "Inactive") == nullptr)) { SetProp (hwnd, "WaitingToProcess", (HANDLE)1); @@ -771,7 +771,7 @@ CGraphicView::OnLButtonUp } else { - ::SetCursor (::LoadCursor (NULL, MAKEINTRESOURCE (IDC_ARROW))); + ::SetCursor (::LoadCursor (nullptr, MAKEINTRESOURCE (IDC_ARROW))); ((CW3DViewDoc *)GetDocument())->Set_Cursor ("cursor.tga"); } @@ -847,7 +847,7 @@ CGraphicView::OnMouseMove else if ((nFlags & MK_CONTROL) && m_bMouseDown) { LightClass *pSceneLight = doc->GetSceneLight (); - if ((pSceneLight != NULL) && (m_pLightMesh != NULL)) + if ((pSceneLight != nullptr) && (m_pLightMesh != nullptr)) { RECT rect; GetClientRect (&rect); @@ -895,7 +895,7 @@ CGraphicView::OnMouseMove CW3DViewDoc *doc= (CW3DViewDoc *)GetDocument(); LightClass *pscene_light = doc->GetSceneLight (); RenderObjClass *prender_obj = doc->GetDisplayedObject (); - if ((pscene_light != NULL) && (prender_obj != NULL)) { + if ((pscene_light != nullptr) && (prender_obj != nullptr)) { // Calculate a light adjustment factor CRect rect; @@ -1070,7 +1070,7 @@ CGraphicView::OnMouseMove // Get the main window of our app CMainFrame *pCMainWnd = (CMainFrame *)::AfxGetMainWnd (); - if (pCMainWnd != NULL) + if (pCMainWnd != nullptr) { // Ensure the background camera matches the main camera CW3DViewDoc *doc = (CW3DViewDoc *)GetDocument(); @@ -1079,7 +1079,7 @@ CGraphicView::OnMouseMove // Update the current object if necessary RenderObjClass *prender_obj = doc->GetDisplayedObject (); - if (prender_obj != NULL) { + if (prender_obj != nullptr) { // Ensure the status bar is updated with the correct poly count pCMainWnd->UpdatePolygonCount (prender_obj->Get_Num_Polys ()); @@ -1214,7 +1214,7 @@ CGraphicView::Reset_Camera_To_Display_Sphere (SphereClass &sphere) // Make the same adjustment for the scene light CW3DViewDoc* doc = (CW3DViewDoc *)GetDocument(); LightClass *pSceneLight = doc->GetSceneLight (); - if ((m_pLightMesh != NULL) && (pSceneLight != NULL)) { + if ((m_pLightMesh != nullptr) && (pSceneLight != nullptr)) { // Reposition the light and its 'mesh' as appropriate transform.Make_Identity (); @@ -1238,8 +1238,8 @@ CGraphicView::Reset_Camera_To_Display_Sphere (SphereClass &sphere) m_pCamera->Set_Clip_Planes (min_dist, max_dist); // Adjust the fog near clipping plane to the new value, but - // leave the far clip plane alone (since it is scene dependant - // not camera dependant). + // leave the far clip plane alone (since it is scene dependent + // not camera dependent). float fog_near, fog_far; doc->GetScene()->Get_Fog_Range(&fog_near, &fog_far); doc->GetScene()->Set_Fog_Range(min_dist, fog_far); @@ -1252,7 +1252,7 @@ CGraphicView::Reset_Camera_To_Display_Sphere (SphereClass &sphere) // Update the camera distance in the status bar CMainFrame *pCMainWnd = (CMainFrame *)::AfxGetMainWnd (); - if (pCMainWnd != NULL) { + if (pCMainWnd != nullptr) { pCMainWnd->UpdateCameraDistance (m_CameraDistance); pCMainWnd->UpdateFrameCount (0, 0, 0); } @@ -1298,7 +1298,7 @@ CGraphicView::Reset_Camera_To_Display_Object (RenderObjClass &render_object) // Update the polygon count in the main window CMainFrame *pCMainWnd = (CMainFrame *)::AfxGetMainWnd (); - if (pCMainWnd != NULL) { + if (pCMainWnd != nullptr) { pCMainWnd->UpdatePolygonCount (render_object.Get_Num_Polys ()); } @@ -1318,11 +1318,11 @@ CGraphicView::Load_Default_Dat (void) { // Get the directory where this executable was run from TCHAR filename[MAX_PATH]; - ::GetModuleFileName (NULL, filename, sizeof (filename)); + ::GetModuleFileName (nullptr, filename, sizeof (filename)); // Strip the filename from the path LPTSTR ppath = ::strrchr (filename, '\\'); - if (ppath != NULL) { + if (ppath != nullptr) { ppath[0] = 0; } @@ -1334,7 +1334,7 @@ CGraphicView::Load_Default_Dat (void) // Ask the document to load the settings from this data file CW3DViewDoc *pCDoc = (CW3DViewDoc *)GetDocument (); - if (pCDoc != NULL) { + if (pCDoc != nullptr) { pCDoc->LoadSettings (filename); } } @@ -1361,7 +1361,7 @@ CGraphicView::OnRButtonUp if (m_bMouseDown) { ((CW3DViewDoc *)GetDocument())->Set_Cursor ("orbit.tga"); } else { - ::SetCursor (::LoadCursor (NULL, MAKEINTRESOURCE (IDC_ARROW))); + ::SetCursor (::LoadCursor (nullptr, MAKEINTRESOURCE (IDC_ARROW))); ((CW3DViewDoc *)GetDocument())->Set_Cursor ("cursor.tga"); ReleaseCapture (); } @@ -1530,7 +1530,7 @@ CGraphicView::SetCameraPos (CAMERA_POS cameraPos) // Get the main window of our app CMainFrame *pCMainWnd = (CMainFrame *)::AfxGetMainWnd (); - if (pCMainWnd != NULL) + if (pCMainWnd != nullptr) { CW3DViewDoc* doc = (CW3DViewDoc *)GetDocument(); @@ -1603,7 +1603,7 @@ CGraphicView::ResetObject (void) if (pCRenderObj) { // Reset the rotation of the object - pCRenderObj->Set_Transform (Matrix3D(1)); + pCRenderObj->Set_Transform (Matrix3D(true)); } } @@ -1637,7 +1637,7 @@ CGraphicView::Rotate_Object (void) // Get the currently displayed object RenderObjClass *prender_obj = doc->GetDisplayedObject (); - if (prender_obj != NULL) + if (prender_obj != nullptr) { // Get the current transform for the object Matrix3D transform = prender_obj->Get_Transform (); @@ -1686,7 +1686,7 @@ CGraphicView::Rotate_Light (void) // Get the currently displayed object LightClass *pscene_light = doc->GetSceneLight (); RenderObjClass *prender_obj = doc->GetDisplayedObject (); - if ((pscene_light != NULL) && (prender_obj != NULL)) { + if ((pscene_light != nullptr) && (prender_obj != nullptr)) { Matrix3D rotation_matrix (1); // Build a rotation matrix that contains the x,y,z @@ -1818,7 +1818,7 @@ CGraphicView::Set_Camera_Distance (float dist) // Update the status bar // CMainFrame *main_wnd = (CMainFrame *)::AfxGetMainWnd (); - if (main_wnd != NULL) { + if (main_wnd != nullptr) { main_wnd->UpdateCameraDistance (m_CameraDistance); } diff --git a/Core/Tools/W3DView/HierarchyPropPage.cpp b/Core/Tools/W3DView/HierarchyPropPage.cpp index b52c698e0f6..c39fd171552 100644 --- a/Core/Tools/W3DView/HierarchyPropPage.cpp +++ b/Core/Tools/W3DView/HierarchyPropPage.cpp @@ -135,7 +135,7 @@ CHierarchyPropPage::OnInitDialog (void) // Free this object pCSubObject->Release_Ref (); - pCSubObject = NULL; + pCSubObject = nullptr; } } @@ -144,7 +144,7 @@ CHierarchyPropPage::OnInitDialog (void) // Free the object pCHierarchy->Release_Ref (); - pCHierarchy = NULL; + pCHierarchy = nullptr; } } diff --git a/Core/Tools/W3DView/MainFrm.cpp b/Core/Tools/W3DView/MainFrm.cpp index e27917e65f3..38563a531e1 100644 --- a/Core/Tools/W3DView/MainFrm.cpp +++ b/Core/Tools/W3DView/MainFrm.cpp @@ -464,7 +464,7 @@ CMainFrame::Restore_Window_State (void) if (is_max) { ::ShowWindow (m_hWnd, SW_MAXIMIZE); } else { - ::SetWindowPos (m_hWnd, NULL, rect.left, rect.top, rect.Width (), rect.Height (), SWP_NOZORDER); + ::SetWindowPos (m_hWnd, nullptr, rect.left, rect.top, rect.Width (), rect.Height (), SWP_NOZORDER); } } @@ -481,7 +481,7 @@ void CMainFrame::RestoreOriginalSize (void) { // Resize the window so its the same size it was when the application loaded - SetWindowPos (NULL, 0, 0, m_OrigRect.right-m_OrigRect.left, m_OrigRect.bottom-m_OrigRect.top, SWP_NOMOVE | SWP_NOZORDER); + SetWindowPos (nullptr, 0, 0, m_OrigRect.right-m_OrigRect.left, m_OrigRect.bottom-m_OrigRect.top, SWP_NOMOVE | SWP_NOZORDER); return ; } @@ -531,14 +531,14 @@ CMainFrame::OnCreateClient // Get a pointer to the 'graphic' pane's window CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1); - BOOL bReturn = (pCGraphicView != NULL); + BOOL bReturn = (pCGraphicView != nullptr); // Were we successful in view's getting the pointer? ASSERT (pCGraphicView); if (pCGraphicView) { TCHAR szFileName[MAX_PATH]; - ::GetModuleFileName (NULL, szFileName, sizeof (szFileName)); + ::GetModuleFileName (nullptr, szFileName, sizeof (szFileName)); LPTSTR pszPath = ::strrchr (szFileName, '\\'); if (pszPath) { pszPath[0] = 0; @@ -654,7 +654,7 @@ CMainFrame::WindowProc // We're closing the application so cleanup resources CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument (); - if (pdoc != NULL) { + if (pdoc != nullptr) { // Ask the Doc to free its resources pdoc->CleanupResources (); @@ -677,11 +677,11 @@ CMainFrame::WindowProc // Get the directory where this executable was run from TCHAR filename[MAX_PATH]; - ::GetModuleFileName (NULL, filename, sizeof (filename)); + ::GetModuleFileName (nullptr, filename, sizeof (filename)); // Strip the filename from the path LPTSTR ppath = ::strrchr (filename, '\\'); - if (ppath != NULL) { + if (ppath != nullptr) { ppath[0] = 0; } @@ -695,7 +695,7 @@ CMainFrame::WindowProc // Ask the document to load the settings from this data file CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument (); - if (pdoc != NULL) { + if (pdoc != nullptr) { pdoc->LoadSettings (full_path); } } @@ -733,7 +733,7 @@ CMainFrame::ShowObjectProperties (void) { // Get a pointer to the 'graphic' pane's window CDataTreeView *pCDataTreeView = (CDataTreeView *)m_wndSplitter.GetPane (0, 0); - BOOL bReturn = (pCDataTreeView != NULL); + BOOL bReturn = (pCDataTreeView != nullptr); // Were we successful in getting the view's pointer? ASSERT (pCDataTreeView); @@ -806,14 +806,14 @@ CMainFrame::OnUpdateObjectProperties (CCmdUI* pCmdUI) { // Get a pointer to the 'graphic' pane's window CDataTreeView *pCDataTreeView = (CDataTreeView *)m_wndSplitter.GetPane (0, 0); - BOOL bReturn = (pCDataTreeView != NULL); + BOOL bReturn = (pCDataTreeView != nullptr); // Were we successful in view's getting the pointer? ASSERT (pCDataTreeView); if (pCDataTreeView) { // Get the name of the currently selected object - pCmdUI->Enable (pCDataTreeView->GetCurrentSelectionName () != NULL); + pCmdUI->Enable (pCDataTreeView->GetCurrentSelectionName () != nullptr); } return ; @@ -982,8 +982,8 @@ CMainFrame::OnLodGenerate (void) CDataTreeView *ptree_view = (CDataTreeView *)m_wndSplitter.GetPane (0, 0); // Were we successful in view's getting the pointer? - ASSERT (ptree_view != NULL); - if ((ptree_view != NULL) && + ASSERT (ptree_view != nullptr); + if ((ptree_view != nullptr) && ptree_view->GetCurrentSelectionName ()) { // Get the name of the currently selected hierarchy @@ -1004,13 +1004,13 @@ CMainFrame::OnLodGenerate (void) // Get a pointer to the document so we can create an LOD CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument (); - ASSERT (pdoc != NULL); - if (pdoc != NULL) { + ASSERT (pdoc != nullptr); + if (pdoc != nullptr) { // Attempt to generate an LOD from the name of the // currently selected hierarchy HLodPrototypeClass *plod_prototype = pdoc->GenerateLOD (stringName, type); - if (plod_prototype != NULL) { + if (plod_prototype != nullptr) { // Add this prototype to the asset manager WW3DAssetManager::Get_Instance ()->Add_Prototype (plod_prototype); @@ -1093,7 +1093,7 @@ CMainFrame::Update_Frame_Time (DWORD clocks) // Update the resolution display CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1); - if (pCGraphicView != NULL) { + if (pCGraphicView != nullptr) { CRect rect; pCGraphicView->GetWindowRect(&rect); @@ -1186,13 +1186,13 @@ void CMainFrame::OnFileOpen (void) { CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument (); - if (doc == NULL) { + if (doc == nullptr) { return ; } CFileDialog openFileDialog (TRUE, ".w3d", - NULL, + nullptr, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT | OFN_EXPLORER, "Westwood 3D Files (*.w3d)|*.w3d||", this); @@ -1206,11 +1206,11 @@ CMainFrame::OnFileOpen (void) if (openFileDialog.DoModal () == IDOK) { // Show the wait cursor while we load assets - SetCursor (::LoadCursor (NULL, IDC_WAIT)); + SetCursor (::LoadCursor (nullptr, IDC_WAIT)); // Loop through all the selected files POSITION pPos = openFileDialog.GetStartPosition (); - while (pPos != NULL) + while (pPos != nullptr) { // Ask the doc to load the assets from this file into memory CString stringFileName = openFileDialog.GetNextPathName (pPos); @@ -1228,7 +1228,7 @@ CMainFrame::OnFileOpen (void) } // Restore the arrow cursor - SetCursor (::LoadCursor (NULL, IDC_ARROW)); + SetCursor (::LoadCursor (nullptr, IDC_ARROW)); } return ; @@ -1701,7 +1701,7 @@ CMainFrame::OnLoadSettings (void) { CFileDialog openFileDialog (TRUE, ".dat", - NULL, + nullptr, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER, "Settings data files (*.dat)|*.dat||", this); @@ -1744,7 +1744,7 @@ CMainFrame::OnLODSave (void) // Get the controlling doc object so we can have it save the // LOD for us. CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument (); - if (pdoc != NULL) { + if (pdoc != nullptr) { pdoc->Save_Selected_LOD (); } @@ -2207,18 +2207,18 @@ CMainFrame::Select_Device (bool show_dlg) // // Check to ensure the drivers are valid if the user choose glide // - if (::strstr (driver_name, "glide2") != NULL) { + if (::strstr (driver_name, "glide2") != nullptr) { // Is this glide driver an acceptable version? float driver_version = ::atof (string_version); - bool is_voodoo2 = (::strstr (chipset , "VOODOO2") != NULL); + bool is_voodoo2 = (::strstr (chipset , "VOODOO2") != nullptr); if ((is_voodoo2 && (driver_version < 2.54F)) || ((is_voodoo2 == false) && (driver_version < 2.46F))) { // Let the user know we can't use these drivers CString message; message.LoadString (IDS_UNACCEPTABLE_GLIDE_MSG); - ::MessageBox (NULL, message, "Invalid Device", MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND); + ::MessageBox (nullptr, message, "Invalid Device", MB_OK | MB_ICONEXCLAMATION | MB_SETFOREGROUND); // Force the user to choose a new device Select_Device (true); @@ -2323,11 +2323,11 @@ CMainFrame::OnCreateEmitter (void) // Clear the current display CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument (); if (pdoc) { - pdoc->DisplayObject ((RenderObjClass *)NULL); + pdoc->DisplayObject ((RenderObjClass *)nullptr); } // Display the emitter property sheet - EmitterPropertySheetClass prop_sheet (NULL, + EmitterPropertySheetClass prop_sheet (nullptr, IDS_EMITTER_PROP_TITLE, this); prop_sheet.DoModal (); @@ -2345,7 +2345,7 @@ CMainFrame::OnEditEmitter (void) { // Get a pointer to the doc object CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument (); - if (pdoc != NULL) { + if (pdoc != nullptr) { // // Make a list of emitters containing the currently displayed emitter @@ -2388,7 +2388,7 @@ CMainFrame::OnScaleEmitter (void) { // Get a pointer to the doc object CW3DViewDoc *pdoc = (CW3DViewDoc *)GetActiveDocument (); - if (pdoc != NULL) { + if (pdoc != nullptr) { // // Display a dialog that allows the user to choose the scaling factor @@ -2597,8 +2597,8 @@ void CMainFrame::OnObjectRotateYBack (void) { CGraphicView *pgraphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1); - ASSERT (pgraphic_view != NULL); - if (pgraphic_view != NULL) { + ASSERT (pgraphic_view != nullptr); + if (pgraphic_view != nullptr) { // Start or stop the rotation around Y int rotation = (pgraphic_view->GetObjectRotation () ^ (CGraphicView::RotateYBack)); @@ -2619,8 +2619,8 @@ void CMainFrame::OnObjectRotateZBack (void) { CGraphicView *pgraphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1); - ASSERT (pgraphic_view != NULL); - if (pgraphic_view != NULL) { + ASSERT (pgraphic_view != nullptr); + if (pgraphic_view != nullptr) { // Start or stop the rotation around Z int rotation = (pgraphic_view->GetObjectRotation () ^ (CGraphicView::RotateZBack)); @@ -2641,8 +2641,8 @@ void CMainFrame::OnLightRotateY (void) { CGraphicView *pgraphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1); - ASSERT (pgraphic_view != NULL); - if (pgraphic_view != NULL) { + ASSERT (pgraphic_view != nullptr); + if (pgraphic_view != nullptr) { // Start or stop the rotation around Y int rotation = (pgraphic_view->Get_Light_Rotation () ^ (CGraphicView::RotateY)); @@ -2663,8 +2663,8 @@ void CMainFrame::OnLightRotateYBack (void) { CGraphicView *pgraphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1); - ASSERT (pgraphic_view != NULL); - if (pgraphic_view != NULL) { + ASSERT (pgraphic_view != nullptr); + if (pgraphic_view != nullptr) { // Start or stop the rotation around Y int rotation = (pgraphic_view->Get_Light_Rotation () ^ (CGraphicView::RotateYBack)); @@ -2685,8 +2685,8 @@ void CMainFrame::OnLightRotateZ (void) { CGraphicView *pgraphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1); - ASSERT (pgraphic_view != NULL); - if (pgraphic_view != NULL) { + ASSERT (pgraphic_view != nullptr); + if (pgraphic_view != nullptr) { // Start or stop the rotation around Z int rotation = (pgraphic_view->Get_Light_Rotation () ^ (CGraphicView::RotateZ)); @@ -2707,8 +2707,8 @@ void CMainFrame::OnLightRotateZBack (void) { CGraphicView *pgraphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1); - ASSERT (pgraphic_view != NULL); - if (pgraphic_view != NULL) { + ASSERT (pgraphic_view != nullptr); + if (pgraphic_view != nullptr) { // Start or stop the rotation around Y int rotation = (pgraphic_view->Get_Light_Rotation () ^ (CGraphicView::RotateZBack)); @@ -2767,7 +2767,7 @@ CMainFrame::OnDecLight (void) { CW3DViewDoc *pdoc = ::GetCurrentDocument (); LightClass *plight = pdoc->GetSceneLight (); - if (plight != NULL) { + if (plight != nullptr) { // Get the current light settings Vector3 diffuse; @@ -2796,7 +2796,7 @@ CMainFrame::OnIncLight (void) { CW3DViewDoc *pdoc = ::GetCurrentDocument (); LightClass *plight = pdoc->GetSceneLight (); - if (plight != NULL) { + if (plight != nullptr) { // Get the current light settings Vector3 diffuse; @@ -2824,7 +2824,7 @@ void CMainFrame::OnDecAmbientLight (void) { CW3DViewDoc *pdoc = ::GetCurrentDocument (); - if (pdoc->GetScene () != NULL) { + if (pdoc->GetScene () != nullptr) { // Get the current ambient light settings Vector3 color = pdoc->GetScene ()->Get_Ambient_Light (); @@ -2847,7 +2847,7 @@ void CMainFrame::OnIncAmbientLight (void) { CW3DViewDoc *pdoc = ::GetCurrentDocument (); - if (pdoc->GetScene () != NULL) { + if (pdoc->GetScene () != nullptr) { // Get the current ambient light settings Vector3 color = pdoc->GetScene ()->Get_Ambient_Light (); @@ -2886,7 +2886,7 @@ CMainFrame::OnMakeAggregate (void) CDataTreeView *pdata_tree = (CDataTreeView *)m_wndSplitter.GetPane (0, 0); RenderObjClass *prender_obj = ::GetCurrentDocument ()->GetDisplayedObject (); - if (prender_obj != NULL) { + if (prender_obj != nullptr) { // Build a definition object from the hierarchy AggregateDefClass *pdefinition = new AggregateDefClass (*prender_obj); @@ -2916,7 +2916,7 @@ CMainFrame::OnRenameAggregate (void) { // Get a pointer to the current aggregate RenderObjClass *prender_obj = (::GetCurrentDocument ())->GetDisplayedObject (); - if (prender_obj != NULL) { + if (prender_obj != nullptr) { // Show the rename dialog to the user const char *old_name = prender_obj->Get_Name (); @@ -2996,7 +2996,7 @@ CMainFrame::OnCmdMsg // Hack to get MFC to enable the 'Editable Emitters List' submenu... if (nCode == CN_UPDATE_COMMAND_UI) { CCmdUI *pCmdUI = (CCmdUI *)pExtra; - if (pCmdUI != NULL && (pCmdUI->m_nID >= 1000) && (pCmdUI->m_nID < 1100)) { + if (pCmdUI != nullptr && (pCmdUI->m_nID >= 1000) && (pCmdUI->m_nID < 1100)) { pCmdUI->Enable (TRUE); return TRUE; } @@ -3016,7 +3016,7 @@ void CMainFrame::OnCrashApp (void) { // Usefull HACK to get the program to crash when needed... - LPTSTR hack = 0; + LPTSTR hack = nullptr; (*hack) = 0; return ; } @@ -3032,7 +3032,7 @@ CMainFrame::OnLODRecordScreenArea (void) { // Make sure the current object is an LOD RenderObjClass *prender_obj = ::GetCurrentDocument ()->GetDisplayedObject (); - if ((prender_obj != NULL) && + if ((prender_obj != nullptr) && (prender_obj->Class_ID () == RenderObjClass::CLASSID_HLOD)) { CGraphicView *graphic_view = (CGraphicView *)m_wndSplitter.GetPane (0, 1); @@ -3066,10 +3066,10 @@ CMainFrame::OnLODIncludeNull (void) { // Make sure the current object is an LOD RenderObjClass *prender_obj = ::GetCurrentDocument ()->GetDisplayedObject (); - if ((prender_obj != NULL) && + if ((prender_obj != nullptr) && (prender_obj->Class_ID () == RenderObjClass::CLASSID_HLOD)) { - // Toggle the NULL lod + // Toggle the nullptr lod bool include = ((HLodClass *)prender_obj)->Is_NULL_Lod_Included (); ((HLodClass *)prender_obj)->Include_NULL_Lod (!include); @@ -3091,7 +3091,7 @@ CMainFrame::OnUpdateLODIncludeNull (CCmdUI *pCmdUI) { // Make sure the current object is an LOD RenderObjClass *prender_obj = (::GetCurrentDocument ())->GetDisplayedObject (); - if ((prender_obj != NULL) && + if ((prender_obj != nullptr) && (prender_obj->Class_ID () == RenderObjClass::CLASSID_HLOD)) { // Check or uncheck the menu option depending on the state of the LOD @@ -3126,7 +3126,7 @@ CMainFrame::OnUpdateLodPrevLevel (CCmdUI *pCmdUI) { // Make sure the current object is an LOD RenderObjClass *prender_obj = (::GetCurrentDocument ())->GetDisplayedObject (); - if ((prender_obj != NULL) && + if ((prender_obj != nullptr) && (prender_obj->Class_ID () == RenderObjClass::CLASSID_HLOD)) { // Enable the menu option if there is a previous lod to display @@ -3161,7 +3161,7 @@ CMainFrame::OnUpdateLodNextLevel (CCmdUI *pCmdUI) { // Make sure the current object is an LOD RenderObjClass *prender_obj = (::GetCurrentDocument ())->GetDisplayedObject (); - if ((prender_obj != NULL) && + if ((prender_obj != nullptr) && (prender_obj->Class_ID () == RenderObjClass::CLASSID_HLOD)) { // Enable the menu option if there is another lod to display @@ -3249,13 +3249,13 @@ CMainFrame::OnSaveScreenshot (void) { // Get the directory where this executable was run from TCHAR filename[MAX_PATH]; - ::GetModuleFileName (NULL, filename, sizeof (filename)); + ::GetModuleFileName (nullptr, filename, sizeof (filename)); // // Strip the filename from the path // LPTSTR ppath = ::strrchr (filename, '\\'); - if (ppath != NULL) { + if (ppath != nullptr) { ppath[0] = 0; } @@ -3294,7 +3294,7 @@ CMainFrame::Update_Emitters_List (void) } RenderObjClass *prender_obj = GetCurrentDocument ()->GetDisplayedObject (); - if (prender_obj != NULL) { + if (prender_obj != nullptr) { DynamicVectorClass list; Build_Emitter_List (*prender_obj, list); @@ -3321,7 +3321,7 @@ void CMainFrame::OnSlideshowDown (void) { CDataTreeView *data_tree = (CDataTreeView *)m_wndSplitter.GetPane (0, 0); - if (data_tree != NULL) { + if (data_tree != nullptr) { data_tree->Select_Next (); } @@ -3338,7 +3338,7 @@ void CMainFrame::OnSlideshowUp (void) { CDataTreeView *data_tree = (CDataTreeView *)m_wndSplitter.GetPane (0, 0); - if (data_tree != NULL) { + if (data_tree != nullptr) { data_tree->Select_Prev (); } @@ -3470,13 +3470,13 @@ void CMainFrame::OnCopyAssets (void) { CString path; - if (::Browse_For_Folder (m_hWnd, NULL, path)) { + if (::Browse_For_Folder (m_hWnd, nullptr, path)) { // // Copy all dependent asset files to the selected directory // CW3DViewDoc *doc = ::GetCurrentDocument (); - if (doc != NULL) { + if (doc != nullptr) { doc->Copy_Assets_To_Dir (path); } } @@ -3494,12 +3494,12 @@ void CMainFrame::OnUpdateCopyAssets (CCmdUI *pCmdUI) { CW3DViewDoc *doc = ::GetCurrentDocument (); - if (doc != NULL) { + if (doc != nullptr) { // // Only enable this option if we are viewing an object // - pCmdUI->Enable (doc->GetDisplayedObject () != NULL); + pCmdUI->Enable (doc->GetDisplayedObject () != nullptr); } return ; @@ -3549,13 +3549,13 @@ CMainFrame::OnCreateSphere (void) // Clear the current display CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument (); if (doc) { - doc->DisplayObject ((RenderObjClass *)NULL); + doc->DisplayObject ((RenderObjClass *)nullptr); } // // Display the sphere property sheet // - SpherePropertySheetClass dialog (NULL, IDS_SPHERE_PROP_TITLE, this); + SpherePropertySheetClass dialog (nullptr, IDS_SPHERE_PROP_TITLE, this); dialog.DoModal (); return ; } @@ -3572,13 +3572,13 @@ CMainFrame::OnCreateRing (void) // Clear the current display CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument (); if (doc) { - doc->DisplayObject ((RenderObjClass *)NULL); + doc->DisplayObject ((RenderObjClass *)nullptr); } // // Display the ring property sheet // - RingPropertySheetClass dialog (NULL, IDS_RING_PROP_TITLE, this); + RingPropertySheetClass dialog (nullptr, IDS_RING_PROP_TITLE, this); dialog.DoModal (); return ; } @@ -3594,14 +3594,14 @@ CMainFrame::OnEditPrimitive (void) { // Get a pointer to the doc object CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument (); - if (doc != NULL) { + if (doc != nullptr) { // // Make a list of emitters containing the currently displayed emitter // RenderObjClass *render_obj = doc->GetDisplayedObject (); - if (render_obj != NULL) { + if (render_obj != nullptr) { if (render_obj->Class_ID () == RenderObjClass::CLASSID_SPHERE) { // @@ -3633,7 +3633,7 @@ void CMainFrame::OnUpdateEditPrimitive (CCmdUI *pCmdUI) { CDataTreeView *data_tree = (CDataTreeView *)m_wndSplitter.GetPane (0, 0); - if (data_tree != NULL && data_tree->GetCurrentSelectionType () == TypePrimitives) { + if (data_tree != nullptr && data_tree->GetCurrentSelectionType () == TypePrimitives) { pCmdUI->Enable (true); } else { pCmdUI->Enable (false); @@ -3679,7 +3679,7 @@ void CMainFrame::OnKillSceneLight() CW3DViewDoc *pdoc = ::GetCurrentDocument(); LightClass *plight = pdoc->GetSceneLight (); - if (plight != NULL) { + if (plight != nullptr) { const Vector3 black (0.0f, 0.0f, 0.0f); @@ -3827,7 +3827,7 @@ CMainFrame::OnAddToLineup (void) // that the objects we add in this manner are stacked in a horizontal // row, just like a lineup. CW3DViewDoc *pDoc = (CW3DViewDoc*)GetActiveDocument(); - ViewerSceneClass *pScene = NULL; + ViewerSceneClass *pScene = nullptr; if (pDoc) pScene = pDoc->GetScene(); CAddToLineupDialog dlg(pScene, this); @@ -3896,12 +3896,12 @@ CMainFrame::OnImportFacialAnims (void) // CW3DViewDoc *doc = ::GetCurrentDocument (); const HTreeClass *htree = doc->Get_Current_HTree (); - ASSERT (htree != NULL); - if (htree != NULL) { + ASSERT (htree != nullptr); + if (htree != nullptr) { CFileDialog dialog ( TRUE, ".txt", - NULL, + nullptr, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT | OFN_EXPLORER, "Animation Description (*.txt)|*.txt||", this); @@ -3921,7 +3921,7 @@ CMainFrame::OnImportFacialAnims (void) // Loop over all the selected files // POSITION pos = dialog.GetStartPosition (); - while (pos != NULL) { + while (pos != nullptr) { // Ask the doc to load the assets from this file into memory CString filename = dialog.GetNextPathName (pos); @@ -3932,7 +3932,7 @@ CMainFrame::OnImportFacialAnims (void) // Re-load the data list to include all new assets // CDataTreeView *data_tree = doc->GetDataTreeView (); - if (data_tree != NULL) { + if (data_tree != nullptr) { data_tree->LoadAssetsIntoTree (); } } @@ -3951,14 +3951,14 @@ void CMainFrame::OnUpdateImportFacialAnims (CCmdUI *pCmdUI) { CW3DViewDoc *doc = ::GetCurrentDocument (); - if (doc != NULL) { + if (doc != nullptr) { // // Enable this command only if the user has an htree // currently selected // const HTreeClass *htree = doc->Get_Current_HTree (); - pCmdUI->Enable (htree != NULL); + pCmdUI->Enable (htree != nullptr); } return ; @@ -3974,7 +3974,7 @@ void CMainFrame::OnRestrictAnims (void) { CDataTreeView *data_tree = ::GetCurrentDocument ()->GetDataTreeView (); - if (data_tree != NULL) { + if (data_tree != nullptr) { bool enabled = data_tree->Are_Anims_Restricted (); data_tree->Restrict_Anims (!enabled); } @@ -3994,7 +3994,7 @@ CMainFrame::OnUpdateRestrictAnims (CCmdUI *pCmdUI) bool check = true; CDataTreeView *data_tree = ::GetCurrentDocument ()->GetDataTreeView (); - if (data_tree != NULL) { + if (data_tree != nullptr) { check = data_tree->Are_Anims_Restricted (); } @@ -4012,7 +4012,7 @@ void CMainFrame::OnBindSubobjectLod (void) { CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument (); - if (doc != NULL && doc->GetDisplayedObject () != NULL) { + if (doc != nullptr && doc->GetDisplayedObject () != nullptr) { // // Toggle the state of the currently displayed object @@ -4036,10 +4036,10 @@ void CMainFrame::OnUpdateBindSubobjectLod (CCmdUI *pCmdUI) { CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument (); - if (doc != NULL && doc->GetDisplayedObject () != NULL) { + if (doc != nullptr && doc->GetDisplayedObject () != nullptr) { // - // Set the check if we are currenly forcing sub object matching + // Set the check if we are currently forcing sub object matching // RenderObjClass *render_obj = doc->GetDisplayedObject (); bool is_enabled = (render_obj->Is_Sub_Objects_Match_LOD_Enabled () != 0); @@ -4103,13 +4103,13 @@ CMainFrame::OnEditSoundObject (void) // Get a pointer to the doc object // CW3DViewDoc *doc = (CW3DViewDoc *)GetActiveDocument (); - if (doc != NULL) { + if (doc != nullptr) { // // Get a pointer to the currently displayed sound object // SoundRenderObjClass *sound_obj = (SoundRenderObjClass *)doc->GetDisplayedObject (); - if (sound_obj != NULL) { + if (sound_obj != nullptr) { // // Display the sound edit dialog @@ -4231,7 +4231,7 @@ void CMainFrame::OnCameraBonePosX() { CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1); - if (pCGraphicView != NULL) { + if (pCGraphicView != nullptr) { pCGraphicView->Set_Camera_Bone_Pos_X(!pCGraphicView->Is_Camera_Bone_Pos_X()); } } @@ -4246,7 +4246,7 @@ void CMainFrame::OnUpdateCameraBonePosX(CCmdUI* pCmdUI) { CGraphicView *pCGraphicView = (CGraphicView *)m_wndSplitter.GetPane (0, 1); - if (pCGraphicView != NULL) { + if (pCGraphicView != nullptr) { pCmdUI->SetCheck(pCGraphicView->Is_Camera_Bone_Pos_X()); } } diff --git a/Core/Tools/W3DView/MeshPropPage.cpp b/Core/Tools/W3DView/MeshPropPage.cpp index 701ead89ed8..fb766ddd8f7 100644 --- a/Core/Tools/W3DView/MeshPropPage.cpp +++ b/Core/Tools/W3DView/MeshPropPage.cpp @@ -169,7 +169,7 @@ CMeshPropPage::OnInitDialog (void) // Free the object pCMesh->Release_Ref (); - pCMesh = NULL; + pCMesh = nullptr; } } diff --git a/Core/Tools/W3DView/OpacitySettingsDialog.cpp b/Core/Tools/W3DView/OpacitySettingsDialog.cpp index 1651831971b..1d4faed13af 100644 --- a/Core/Tools/W3DView/OpacitySettingsDialog.cpp +++ b/Core/Tools/W3DView/OpacitySettingsDialog.cpp @@ -49,7 +49,7 @@ static char THIS_FILE[] = __FILE__; // ///////////////////////////////////////////////////////////////////////////// OpacitySettingsDialogClass::OpacitySettingsDialogClass (float opacity, CWnd *pParent) - : m_OpacityBar (NULL), + : m_OpacityBar (nullptr), m_Opacity (opacity), CDialog(OpacitySettingsDialogClass::IDD, pParent) { diff --git a/Core/Tools/W3DView/OpacitySettingsDialog.h b/Core/Tools/W3DView/OpacitySettingsDialog.h index f362a012e5b..216eeafdf90 100644 --- a/Core/Tools/W3DView/OpacitySettingsDialog.h +++ b/Core/Tools/W3DView/OpacitySettingsDialog.h @@ -31,7 +31,7 @@ class OpacitySettingsDialogClass : public CDialog { // Construction public: - OpacitySettingsDialogClass(float opacity, CWnd* pParent = NULL); // standard constructor + OpacitySettingsDialogClass(float opacity, CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(OpacitySettingsDialogClass) diff --git a/Core/Tools/W3DView/OpacityVectorDialog.cpp b/Core/Tools/W3DView/OpacityVectorDialog.cpp index 39401fe94c4..8485ed1dbf1 100644 --- a/Core/Tools/W3DView/OpacityVectorDialog.cpp +++ b/Core/Tools/W3DView/OpacityVectorDialog.cpp @@ -42,9 +42,9 @@ static char THIS_FILE[] = __FILE__; // OpacityVectorDialogClass // ///////////////////////////////////////////////////////////////////////////// -OpacityVectorDialogClass::OpacityVectorDialogClass(CWnd* pParent /*=NULL*/) - : m_OpacityBar (NULL), - m_RenderObj (NULL), +OpacityVectorDialogClass::OpacityVectorDialogClass(CWnd* pParent /*=nullptr*/) + : m_OpacityBar (nullptr), + m_RenderObj (nullptr), m_KeyIndex (0), CDialog(OpacityVectorDialogClass::IDD, pParent) { @@ -244,7 +244,7 @@ OpacityVectorDialogClass::Update_Value (void) void OpacityVectorDialogClass::Update_Object (const AlphaVectorStruct &value) { - if (m_RenderObj != NULL) { + if (m_RenderObj != nullptr) { // // Determine what type of object this is diff --git a/Core/Tools/W3DView/OpacityVectorDialog.h b/Core/Tools/W3DView/OpacityVectorDialog.h index d2cc35fd877..cb074b87db6 100644 --- a/Core/Tools/W3DView/OpacityVectorDialog.h +++ b/Core/Tools/W3DView/OpacityVectorDialog.h @@ -34,7 +34,7 @@ class OpacityVectorDialogClass : public CDialog { // Construction public: - OpacityVectorDialogClass(CWnd* pParent = NULL); // standard constructor + OpacityVectorDialogClass(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(OpacityVectorDialogClass) diff --git a/Core/Tools/W3DView/ParticleBlurTimeKeyDialog.cpp b/Core/Tools/W3DView/ParticleBlurTimeKeyDialog.cpp index 06aab5ef4e5..60f661d2ca4 100644 --- a/Core/Tools/W3DView/ParticleBlurTimeKeyDialog.cpp +++ b/Core/Tools/W3DView/ParticleBlurTimeKeyDialog.cpp @@ -78,7 +78,7 @@ BOOL ParticleBlurTimeKeyDialogClass::OnNotify(WPARAM wParam, LPARAM lParam, LRES // Update the spinner control if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); } diff --git a/Core/Tools/W3DView/ParticleBlurTimeKeyDialog.h b/Core/Tools/W3DView/ParticleBlurTimeKeyDialog.h index 2339682a1e4..13b95fb09b4 100644 --- a/Core/Tools/W3DView/ParticleBlurTimeKeyDialog.h +++ b/Core/Tools/W3DView/ParticleBlurTimeKeyDialog.h @@ -28,7 +28,7 @@ class ParticleBlurTimeKeyDialogClass : public CDialog { // Construction public: - ParticleBlurTimeKeyDialogClass(float blur_time, CWnd* pParent = NULL); // standard constructor + ParticleBlurTimeKeyDialogClass(float blur_time, CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(ParticleBlurTimeKeyDialogClass) diff --git a/Core/Tools/W3DView/ParticleFrameKeyDialog.cpp b/Core/Tools/W3DView/ParticleFrameKeyDialog.cpp index 9a0c7da7a4c..32632555fa7 100644 --- a/Core/Tools/W3DView/ParticleFrameKeyDialog.cpp +++ b/Core/Tools/W3DView/ParticleFrameKeyDialog.cpp @@ -34,7 +34,7 @@ static char THIS_FILE[] = __FILE__; // ParticleFrameKeyDialogClass dialog -ParticleFrameKeyDialogClass::ParticleFrameKeyDialogClass(float frame,CWnd* pParent /*=NULL*/) : +ParticleFrameKeyDialogClass::ParticleFrameKeyDialogClass(float frame,CWnd* pParent /*=nullptr*/) : CDialog(ParticleFrameKeyDialogClass::IDD, pParent), m_Frame(frame) { @@ -85,7 +85,7 @@ BOOL ParticleFrameKeyDialogClass::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT // Update the spinner control if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); } diff --git a/Core/Tools/W3DView/ParticleFrameKeyDialog.h b/Core/Tools/W3DView/ParticleFrameKeyDialog.h index 03f045ec1ed..6491a749290 100644 --- a/Core/Tools/W3DView/ParticleFrameKeyDialog.h +++ b/Core/Tools/W3DView/ParticleFrameKeyDialog.h @@ -28,7 +28,7 @@ class ParticleFrameKeyDialogClass : public CDialog { // Construction public: - ParticleFrameKeyDialogClass(float frame,CWnd* pParent = NULL); // standard constructor + ParticleFrameKeyDialogClass(float frame,CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(ParticleFrameKeyDialogClass) diff --git a/Core/Tools/W3DView/ParticleRotationKeyDialog.cpp b/Core/Tools/W3DView/ParticleRotationKeyDialog.cpp index 7607c77cec7..66b608c4b09 100644 --- a/Core/Tools/W3DView/ParticleRotationKeyDialog.cpp +++ b/Core/Tools/W3DView/ParticleRotationKeyDialog.cpp @@ -35,7 +35,7 @@ static char THIS_FILE[] = __FILE__; // ParticleRotationKeyDialogClass constructor // ///////////////////////////////////////////////////////////////////////////// -ParticleRotationKeyDialogClass::ParticleRotationKeyDialogClass(float rotation,CWnd* pParent /*=NULL*/) : +ParticleRotationKeyDialogClass::ParticleRotationKeyDialogClass(float rotation,CWnd* pParent /*=nullptr*/) : CDialog(ParticleRotationKeyDialogClass::IDD, pParent), m_Rotation(rotation) { @@ -108,7 +108,7 @@ BOOL ParticleRotationKeyDialogClass::OnNotify(WPARAM wParam, LPARAM lParam, LRES // Update the spinner control if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); } diff --git a/Core/Tools/W3DView/ParticleRotationKeyDialog.h b/Core/Tools/W3DView/ParticleRotationKeyDialog.h index 37df1e0f41e..6df2856bec6 100644 --- a/Core/Tools/W3DView/ParticleRotationKeyDialog.h +++ b/Core/Tools/W3DView/ParticleRotationKeyDialog.h @@ -28,7 +28,7 @@ class ParticleRotationKeyDialogClass : public CDialog { // Construction public: - ParticleRotationKeyDialogClass(float rotation,CWnd* pParent = NULL); // standard constructor + ParticleRotationKeyDialogClass(float rotation,CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(ParticleRotationKeyDialogClass) diff --git a/Core/Tools/W3DView/ParticleSizeDialog.cpp b/Core/Tools/W3DView/ParticleSizeDialog.cpp index c8a56a2be89..1506093d51f 100644 --- a/Core/Tools/W3DView/ParticleSizeDialog.cpp +++ b/Core/Tools/W3DView/ParticleSizeDialog.cpp @@ -118,7 +118,7 @@ ParticleSizeDialogClass::OnNotify // Update the spinner control if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); } diff --git a/Core/Tools/W3DView/ParticleSizeDialog.h b/Core/Tools/W3DView/ParticleSizeDialog.h index 80bb2be66aa..86c664797c1 100644 --- a/Core/Tools/W3DView/ParticleSizeDialog.h +++ b/Core/Tools/W3DView/ParticleSizeDialog.h @@ -28,7 +28,7 @@ class ParticleSizeDialogClass : public CDialog { // Construction public: - ParticleSizeDialogClass (float size, CWnd* pParent = NULL); // standard constructor + ParticleSizeDialogClass (float size, CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(ParticleSizeDialogClass) diff --git a/Core/Tools/W3DView/PlaySoundDialog.cpp b/Core/Tools/W3DView/PlaySoundDialog.cpp index a15b28e23ac..b97ab602238 100644 --- a/Core/Tools/W3DView/PlaySoundDialog.cpp +++ b/Core/Tools/W3DView/PlaySoundDialog.cpp @@ -37,9 +37,9 @@ static char THIS_FILE[] = __FILE__; // PlaySoundDialogClass // ///////////////////////////////////////////////////////////////////////////// -PlaySoundDialogClass::PlaySoundDialogClass(LPCTSTR filename, CWnd* pParent /*=NULL*/) +PlaySoundDialogClass::PlaySoundDialogClass(LPCTSTR filename, CWnd* pParent /*=nullptr*/) : Filename (filename), - SoundObj (NULL), + SoundObj (nullptr), CDialog(PlaySoundDialogClass::IDD, pParent) { //{{AFX_DATA_INIT(PlaySoundDialogClass) @@ -81,8 +81,8 @@ END_MESSAGE_MAP() void PlaySoundDialogClass::OnPlaySoundEffect (void) { - ASSERT (SoundObj != NULL); - if (SoundObj != NULL) { + ASSERT (SoundObj != nullptr); + if (SoundObj != nullptr) { SoundObj->Stop (); SoundObj->Play (); } @@ -126,7 +126,7 @@ PlaySoundDialogClass::OnInitDialog (void) // Create the sound effect so we can play it // SoundObj = WWAudioClass::Get_Instance ()->Create_Sound_Effect (Filename); - if (SoundObj == NULL) { + if (SoundObj == nullptr) { CString message; message.Format ("Cannot find sound file: %s!", (LPCTSTR)Filename, MB_OK); MessageBox (message, "File Not Found", MB_ICONEXCLAMATION | MB_OK); @@ -147,8 +147,8 @@ PlaySoundDialogClass::OnInitDialog (void) void PlaySoundDialogClass::OnStopSoundEffect (void) { - ASSERT (SoundObj != NULL); - if (SoundObj != NULL) { + ASSERT (SoundObj != nullptr); + if (SoundObj != nullptr) { SoundObj->Stop (); } diff --git a/Core/Tools/W3DView/PlaySoundDialog.h b/Core/Tools/W3DView/PlaySoundDialog.h index eed77d841bc..265b8878942 100644 --- a/Core/Tools/W3DView/PlaySoundDialog.h +++ b/Core/Tools/W3DView/PlaySoundDialog.h @@ -31,7 +31,7 @@ class PlaySoundDialogClass : public CDialog { // Construction public: - PlaySoundDialogClass(LPCTSTR filename, CWnd* pParent = NULL); // standard constructor + PlaySoundDialogClass(LPCTSTR filename, CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(PlaySoundDialogClass) diff --git a/Core/Tools/W3DView/ResolutionDialog.cpp b/Core/Tools/W3DView/ResolutionDialog.cpp index 1846b3dcb83..05420b607ce 100644 --- a/Core/Tools/W3DView/ResolutionDialog.cpp +++ b/Core/Tools/W3DView/ResolutionDialog.cpp @@ -42,7 +42,7 @@ static char THIS_FILE[] = __FILE__; // ResolutionDialogClass // ///////////////////////////////////////////////////////////////////////////// -ResolutionDialogClass::ResolutionDialogClass(CWnd* pParent /*=NULL*/) +ResolutionDialogClass::ResolutionDialogClass(CWnd* pParent /*=nullptr*/) : CDialog(ResolutionDialogClass::IDD, pParent) { //{{AFX_DATA_INIT(ResolutionDialogClass) diff --git a/Core/Tools/W3DView/ResolutionDialog.h b/Core/Tools/W3DView/ResolutionDialog.h index b826814f73b..9882ff5b949 100644 --- a/Core/Tools/W3DView/ResolutionDialog.h +++ b/Core/Tools/W3DView/ResolutionDialog.h @@ -30,7 +30,7 @@ class ResolutionDialogClass : public CDialog { // Construction public: - ResolutionDialogClass(CWnd* pParent = NULL); // standard constructor + ResolutionDialogClass(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(ResolutionDialogClass) diff --git a/Core/Tools/W3DView/RestrictedFileDialog.h b/Core/Tools/W3DView/RestrictedFileDialog.h index 2c4e7640e5a..4aaed15232f 100644 --- a/Core/Tools/W3DView/RestrictedFileDialog.h +++ b/Core/Tools/W3DView/RestrictedFileDialog.h @@ -30,11 +30,11 @@ class RestrictedFileDialogClass : public CFileDialog public: RestrictedFileDialogClass(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs - LPCTSTR lpszDefExt = NULL, - LPCTSTR lpszFileName = NULL, + LPCTSTR lpszDefExt = nullptr, + LPCTSTR lpszFileName = nullptr, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, - LPCTSTR lpszFilter = NULL, - CWnd* pParentWnd = NULL); + LPCTSTR lpszFilter = nullptr, + CWnd* pParentWnd = nullptr); protected: //{{AFX_MSG(RestrictedFileDialogClass) diff --git a/Core/Tools/W3DView/RingColorPropPage.cpp b/Core/Tools/W3DView/RingColorPropPage.cpp index 383616d1aeb..e60863d5473 100644 --- a/Core/Tools/W3DView/RingColorPropPage.cpp +++ b/Core/Tools/W3DView/RingColorPropPage.cpp @@ -44,8 +44,8 @@ IMPLEMENT_DYNCREATE(RingColorPropPageClass, CPropertyPage) RingColorPropPageClass::RingColorPropPageClass (RingRenderObjClass *ring) : m_RenderObj (ring), m_bValid (true), - m_ColorBar (NULL), - m_OpacityBar (NULL), + m_ColorBar (nullptr), + m_OpacityBar (nullptr), CPropertyPage(RingColorPropPageClass::IDD) { //{{AFX_DATA_INIT(RingColorPropPageClass) @@ -104,7 +104,7 @@ RingColorPropPageClass::Initialize (void) m_AlphaChannel.Reset (); m_OrigAlphaChannel.Reset (); - if (m_RenderObj != NULL) { + if (m_RenderObj != nullptr) { m_ColorChannel = m_RenderObj->Get_Color_Channel (); m_OrigColorChannel = m_RenderObj->Get_Color_Channel (); diff --git a/Core/Tools/W3DView/RingColorPropPage.h b/Core/Tools/W3DView/RingColorPropPage.h index 63bd6d40a63..b39bd6303c2 100644 --- a/Core/Tools/W3DView/RingColorPropPage.h +++ b/Core/Tools/W3DView/RingColorPropPage.h @@ -36,7 +36,7 @@ class RingColorPropPageClass : public CPropertyPage // Construction public: - RingColorPropPageClass (RingRenderObjClass *ring = NULL); + RingColorPropPageClass (RingRenderObjClass *ring = nullptr); ~RingColorPropPageClass (); // Dialog Data diff --git a/Core/Tools/W3DView/RingGeneralPropPage.cpp b/Core/Tools/W3DView/RingGeneralPropPage.cpp index 25a931856aa..aec2b8bbf42 100644 --- a/Core/Tools/W3DView/RingGeneralPropPage.cpp +++ b/Core/Tools/W3DView/RingGeneralPropPage.cpp @@ -97,13 +97,13 @@ END_MESSAGE_MAP() void RingGeneralPropPageClass::Initialize (void) { - if (m_RenderObj != NULL) { + if (m_RenderObj != nullptr) { // // Get the object's texture // TextureClass *texture = m_RenderObj->Peek_Texture (); - if (texture != NULL) { + if (texture != nullptr) { m_TextureFilename = texture->Get_Texture_Name (); } @@ -212,7 +212,7 @@ RingGeneralPropPageClass::OnApply (void) int index = SendDlgItemMessage (IDC_SHADER_COMBO, CB_GETCURSEL); if (index != CB_ERR) { ShaderClass *shader = (ShaderClass *)SendDlgItemMessage (IDC_SHADER_COMBO, CB_GETITEMDATA, (WPARAM)index); - if (shader != NULL) { + if (shader != nullptr) { m_Shader = (*shader); } } @@ -227,7 +227,7 @@ RingGeneralPropPageClass::OnApply (void) // // Create a texture and pass it onto the object // - TextureClass *texture = NULL; + TextureClass *texture = nullptr; if (m_TextureFilename.GetLength () > 0) { texture = WW3DAssetManager::Get_Instance ()->Get_Texture (::Get_Filename_From_Path (m_TextureFilename)); } @@ -264,7 +264,7 @@ RingGeneralPropPageClass::OnBrowseButton (void) { CFileDialog dialog ( TRUE, ".tga", - NULL, + nullptr, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER, "Textures files (*.tga)|*.tga||", ::AfxGetMainWnd ()); @@ -322,7 +322,7 @@ RingGeneralPropPageClass::OnNotify // Update the spinner control if necessary // NMHDR *header = (NMHDR *)lParam; - if ((header != NULL) && (header->code == UDN_DELTAPOS)) { + if ((header != nullptr) && (header->code == UDN_DELTAPOS)) { LPNMUPDOWN updown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (header->hwndFrom, updown->iDelta); } diff --git a/Core/Tools/W3DView/RingGeneralPropPage.h b/Core/Tools/W3DView/RingGeneralPropPage.h index c09517824a7..4881ed4eebd 100644 --- a/Core/Tools/W3DView/RingGeneralPropPage.h +++ b/Core/Tools/W3DView/RingGeneralPropPage.h @@ -36,7 +36,7 @@ class RingGeneralPropPageClass : public CPropertyPage // Construction public: - RingGeneralPropPageClass (RingRenderObjClass *ring = NULL); + RingGeneralPropPageClass (RingRenderObjClass *ring = nullptr); ~RingGeneralPropPageClass (); // Dialog Data diff --git a/Core/Tools/W3DView/RingPropertySheet.cpp b/Core/Tools/W3DView/RingPropertySheet.cpp index 51ca2e8a787..87d9710bf25 100644 --- a/Core/Tools/W3DView/RingPropertySheet.cpp +++ b/Core/Tools/W3DView/RingPropertySheet.cpp @@ -48,7 +48,7 @@ RingPropertySheetClass::RingPropertySheetClass CWnd * pParentWnd, UINT iSelectPage ) - : m_RenderObj (NULL), + : m_RenderObj (nullptr), CPropertySheet(nIDCaption, pParentWnd, iSelectPage) { REF_PTR_SET (m_RenderObj, ring); @@ -69,7 +69,7 @@ RingPropertySheetClass::RingPropertySheetClass CWnd * pParentWnd, UINT iSelectPage ) - : m_RenderObj (NULL), + : m_RenderObj (nullptr), CPropertySheet(pszCaption, pParentWnd, iSelectPage) { REF_PTR_SET (m_RenderObj, ring); @@ -178,7 +178,7 @@ void RingPropertySheetClass::Add_Object_To_Viewer (void) { CW3DViewDoc *doc = ::GetCurrentDocument (); - if ((doc != NULL) && (m_RenderObj != NULL)) { + if ((doc != nullptr) && (m_RenderObj != nullptr)) { // // Create a new prototype for this object @@ -239,7 +239,7 @@ RingPropertySheetClass::Update_Object (void) void RingPropertySheetClass::Initialize (void) { - if (m_RenderObj == NULL) { + if (m_RenderObj == nullptr) { Create_New_Object (); } else { m_LastSavedName = m_RenderObj->Get_Name (); diff --git a/Core/Tools/W3DView/RingPropertySheet.h b/Core/Tools/W3DView/RingPropertySheet.h index d221010715d..5bef56bf104 100644 --- a/Core/Tools/W3DView/RingPropertySheet.h +++ b/Core/Tools/W3DView/RingPropertySheet.h @@ -58,8 +58,8 @@ class RingPropertySheetClass : public CPropertySheet // Construction public: - RingPropertySheetClass (RingRenderObjClass *ring, UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); - RingPropertySheetClass (RingRenderObjClass *ring, LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); + RingPropertySheetClass (RingRenderObjClass *ring, UINT nIDCaption, CWnd* pParentWnd = nullptr, UINT iSelectPage = 0); + RingPropertySheetClass (RingRenderObjClass *ring, LPCTSTR pszCaption, CWnd* pParentWnd = nullptr, UINT iSelectPage = 0); // Attributes public: diff --git a/Core/Tools/W3DView/RingSizePropPage.cpp b/Core/Tools/W3DView/RingSizePropPage.cpp index bd2ce010146..c5d0c322823 100644 --- a/Core/Tools/W3DView/RingSizePropPage.cpp +++ b/Core/Tools/W3DView/RingSizePropPage.cpp @@ -50,10 +50,10 @@ static bool Is_LERP (float last_value, float last_time, float curr_value, float RingSizePropPageClass::RingSizePropPageClass (RingRenderObjClass *ring) : m_RenderObj (ring), m_bValid (true), - m_InnerScaleXBar (NULL), - m_InnerScaleYBar (NULL), - m_OuterScaleXBar (NULL), - m_OuterScaleYBar (NULL), + m_InnerScaleXBar (nullptr), + m_InnerScaleYBar (nullptr), + m_OuterScaleXBar (nullptr), + m_OuterScaleYBar (nullptr), m_InnerSize (0.5F, 0.5F), m_OuterSize (1.0F, 1.0F), CPropertyPage(RingSizePropPageClass::IDD) @@ -117,7 +117,7 @@ RingSizePropPageClass::Initialize (void) m_OuterScaleChannel.Reset (); m_OrigOuterScaleChannel.Reset (); - if (m_RenderObj != NULL) { + if (m_RenderObj != nullptr) { m_InnerSize = m_RenderObj->Get_Inner_Extent (); m_OuterSize = m_RenderObj->Get_Outer_Extent (); @@ -372,7 +372,7 @@ RingSizePropPageClass::OnNotify // // Determine the timeline bar which sent the notification // - ColorBarClass *timeline = NULL; + ColorBarClass *timeline = nullptr; if (color_bar_hdr->hdr.idFrom == IDC_INNER_SCALE_BAR_X) { timeline = m_InnerScaleXBar; } else if (color_bar_hdr->hdr.idFrom == IDC_INNER_SCALE_BAR_Y) { diff --git a/Core/Tools/W3DView/RingSizePropPage.h b/Core/Tools/W3DView/RingSizePropPage.h index 22def9c8f5a..384f310c62d 100644 --- a/Core/Tools/W3DView/RingSizePropPage.h +++ b/Core/Tools/W3DView/RingSizePropPage.h @@ -36,7 +36,7 @@ class RingSizePropPageClass : public CPropertyPage // Construction public: - RingSizePropPageClass(RingRenderObjClass *ring = NULL); + RingSizePropPageClass(RingRenderObjClass *ring = nullptr); ~RingSizePropPageClass(); // Dialog Data diff --git a/Core/Tools/W3DView/SaveSettingsDialog.cpp b/Core/Tools/W3DView/SaveSettingsDialog.cpp index 8746417aa0d..ac4ad7acdec 100644 --- a/Core/Tools/W3DView/SaveSettingsDialog.cpp +++ b/Core/Tools/W3DView/SaveSettingsDialog.cpp @@ -40,7 +40,7 @@ static char THIS_FILE[] = __FILE__; // // CSaveSettingsDialog // -CSaveSettingsDialog::CSaveSettingsDialog (CWnd* pParent /*=NULL*/) +CSaveSettingsDialog::CSaveSettingsDialog (CWnd* pParent /*=nullptr*/) : CDialog(CSaveSettingsDialog::IDD, pParent) { //{{AFX_DATA_INIT(CSaveSettingsDialog) @@ -100,7 +100,7 @@ void CSaveSettingsDialog::OnBrowseButton (void) { TCHAR szFileName[MAX_PATH]; - ::GetModuleFileName (NULL, szFileName, sizeof (szFileName)); + ::GetModuleFileName (nullptr, szFileName, sizeof (szFileName)); LPTSTR pszPath = ::strrchr (szFileName, '\\'); if (pszPath) { diff --git a/Core/Tools/W3DView/SaveSettingsDialog.h b/Core/Tools/W3DView/SaveSettingsDialog.h index 859caeda99f..744144a0577 100644 --- a/Core/Tools/W3DView/SaveSettingsDialog.h +++ b/Core/Tools/W3DView/SaveSettingsDialog.h @@ -28,7 +28,7 @@ class CSaveSettingsDialog : public CDialog { // Construction public: - CSaveSettingsDialog(CWnd* pParent = NULL); // standard constructor + CSaveSettingsDialog(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CSaveSettingsDialog) diff --git a/Core/Tools/W3DView/ScaleDialog.cpp b/Core/Tools/W3DView/ScaleDialog.cpp index 287f7da9001..78525e285ba 100644 --- a/Core/Tools/W3DView/ScaleDialog.cpp +++ b/Core/Tools/W3DView/ScaleDialog.cpp @@ -138,7 +138,7 @@ ScaleDialogClass::OnNotify // Update the spinner control if necessary // NMHDR *header = (NMHDR *)lParam; - if ((header != NULL) && (header->code == UDN_DELTAPOS)) { + if ((header != nullptr) && (header->code == UDN_DELTAPOS)) { //LPNMUPDOWN updown = (LPNMUPDOWN)lParam; //::Update_Spinner_Buddy (header->hwndFrom, updown->iDelta); } diff --git a/Core/Tools/W3DView/ScaleDialog.h b/Core/Tools/W3DView/ScaleDialog.h index f01746b3c53..ad685ffa7b0 100644 --- a/Core/Tools/W3DView/ScaleDialog.h +++ b/Core/Tools/W3DView/ScaleDialog.h @@ -29,7 +29,7 @@ class ScaleDialogClass : public CDialog { // Construction public: - ScaleDialogClass (float scale, CWnd* pParent=NULL, const char *prompt_string=""); + ScaleDialogClass (float scale, CWnd* pParent=nullptr, const char *prompt_string=""); // Dialog Data //{{AFX_DATA(ScaleDialogClass) diff --git a/Core/Tools/W3DView/SceneLightDialog.cpp b/Core/Tools/W3DView/SceneLightDialog.cpp index 0a1ddd85d59..b379c0c3550 100644 --- a/Core/Tools/W3DView/SceneLightDialog.cpp +++ b/Core/Tools/W3DView/SceneLightDialog.cpp @@ -40,7 +40,7 @@ static char THIS_FILE[] = __FILE__; // // CSceneLightDialog // -CSceneLightDialog::CSceneLightDialog(CWnd* pParent /*=NULL*/) +CSceneLightDialog::CSceneLightDialog(CWnd* pParent /*=nullptr*/) : m_CurrentChannel (DIFFUSE), m_InitialStartAtten (0), m_InitialEndAtten (0), @@ -138,7 +138,7 @@ CSceneLightDialog::OnInitDialog (void) // Attempt to calculate the light's distance from the object float distance = 0; - if (pCDoc->GetDisplayedObject () != NULL) { + if (pCDoc->GetDisplayedObject () != nullptr) { // Get the position of the light and the displayed object Vector3 light_pos = pCDoc->GetSceneLight ()->Get_Position (); @@ -299,7 +299,7 @@ CSceneLightDialog::WindowProc { // Did this notification come from a spin control? NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; // Get the buddy window associated with this spin control diff --git a/Core/Tools/W3DView/SceneLightDialog.h b/Core/Tools/W3DView/SceneLightDialog.h index 0dc4c05a1d6..5f36ee64d4a 100644 --- a/Core/Tools/W3DView/SceneLightDialog.h +++ b/Core/Tools/W3DView/SceneLightDialog.h @@ -32,7 +32,7 @@ class CSceneLightDialog : public CDialog { // Construction public: - CSceneLightDialog(CWnd* pParent = NULL); // standard constructor + CSceneLightDialog(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(CSceneLightDialog) diff --git a/Core/Tools/W3DView/ScreenCursor.cpp b/Core/Tools/W3DView/ScreenCursor.cpp index 28917a34f4f..ac8323e67bd 100644 --- a/Core/Tools/W3DView/ScreenCursor.cpp +++ b/Core/Tools/W3DView/ScreenCursor.cpp @@ -53,11 +53,11 @@ /////////////////////////////////////////////////////////////////// ScreenCursorClass::ScreenCursorClass (void) : m_ScreenPos (0, 0), - m_pTexture (NULL), - m_pVertMaterial (NULL), + m_pTexture (nullptr), + m_pVertMaterial (nullptr), m_Width (0), m_Height (0), - m_hWnd (NULL) + m_hWnd (nullptr) { Initialize (); return ; @@ -71,9 +71,9 @@ ScreenCursorClass::ScreenCursorClass (void) /////////////////////////////////////////////////////////////////// ScreenCursorClass::ScreenCursorClass (const ScreenCursorClass &src) : m_ScreenPos (0, 0), - m_pTexture (NULL), - m_hWnd (NULL), - m_pVertMaterial (NULL), + m_pTexture (nullptr), + m_hWnd (nullptr), + m_pVertMaterial (nullptr), m_Width (0), m_Height (0), RenderObjClass (src) @@ -156,7 +156,7 @@ ScreenCursorClass::Set_Texture (TextureClass *texture) REF_PTR_SET (m_pTexture, texture); // Find the dimensions of the texture: - if (m_pTexture != NULL) { + if (m_pTexture != nullptr) { m_Width = m_pTexture->Get_Width(); m_Height = m_pTexture->Get_Height(); } @@ -179,7 +179,7 @@ ScreenCursorClass::On_Frame_Update (void) POINT point = { 0 }; ::GetCursorPos (&point); - if (m_hWnd != NULL) { + if (m_hWnd != nullptr) { // // Normalize the screen position @@ -227,7 +227,7 @@ ScreenCursorClass::On_Frame_Update (void) z_pos = 0; // - // Build the verticies from the position and extents + // Build the vertices from the position and extents // m_Verticies[0].X = x_pos; m_Verticies[0].Y = y_pos; @@ -359,7 +359,7 @@ ScreenCursorClass::Get_Obj_Space_Bounding_Box(AABoxClass & box) const void ScreenCursorClass::Notify_Added (SceneClass * scene) { - if (scene != NULL) { + if (scene != nullptr) { scene->Register (this, SceneClass::ON_FRAME_UPDATE); } @@ -375,7 +375,7 @@ ScreenCursorClass::Notify_Added (SceneClass * scene) void ScreenCursorClass::Notify_Removed (SceneClass * scene) { - if (scene != NULL) { + if (scene != nullptr) { scene->Unregister (this, SceneClass::ON_FRAME_UPDATE); } diff --git a/Core/Tools/W3DView/SoundEditDialog.cpp b/Core/Tools/W3DView/SoundEditDialog.cpp index 6ed5c3c6acf..43af96e09b7 100644 --- a/Core/Tools/W3DView/SoundEditDialog.cpp +++ b/Core/Tools/W3DView/SoundEditDialog.cpp @@ -59,7 +59,7 @@ static char THIS_FILE[] = __FILE__; // ///////////////////////////////////////////////////////////////////////////// SoundEditDialogClass::SoundEditDialogClass (CWnd *parent) - : SoundRObj (NULL), + : SoundRObj (nullptr), CDialog (SoundEditDialogClass::IDD, parent) { //{{AFX_DATA_INIT(SoundEditDialogClass) @@ -139,7 +139,7 @@ SoundEditDialogClass::OnInitDialog (void) // // Create the reneder object if we don't already have one // - if (SoundRObj == NULL) { + if (SoundRObj == nullptr) { SoundRObj = new SoundRenderObjClass; } @@ -161,18 +161,18 @@ SoundEditDialogClass::OnInitDialog (void) // Get the real settings from the sound object (if we have one) // AudibleSoundClass *sound = SoundRObj->Peek_Sound (); - if (sound != NULL) { + if (sound != nullptr) { Sound3DClass *sound_3d = sound->As_Sound3DClass (); filename = sound->Get_Filename (); drop_off_radius = sound->Get_DropOff_Radius (); priority = sound->Peek_Priority (); - is_3d = (sound_3d != NULL); + is_3d = (sound_3d != nullptr); is_music = (sound->Get_Type () == AudibleSoundClass::TYPE_MUSIC); loop_count = sound->Get_Loop_Count (); volume = sound->Get_Volume (); - if (sound_3d != NULL) { + if (sound_3d != nullptr) { max_vol_radius = sound_3d->Get_Max_Vol_Radius (); } } @@ -267,7 +267,7 @@ SoundEditDialogClass::OnOK (void) // Add this sound object to the viewer // CW3DViewDoc *doc = ::GetCurrentDocument (); - if (doc != NULL) { + if (doc != nullptr) { // // Create a new prototype for this emitter and add it to the asset manager @@ -278,7 +278,7 @@ SoundEditDialogClass::OnOK (void) // // Update the asset manager with the new prototype // - if (OldName.Get_Length () > 0) { + if (!OldName.Is_Empty()) { WW3DAssetManager::Get_Instance()->Remove_Prototype (OldName); } WW3DAssetManager::Get_Instance()->Add_Prototype (prototype); @@ -309,7 +309,7 @@ SoundEditDialogClass::OnOK (void) AudibleSoundClass * SoundEditDialogClass::Create_Sound_Object (void) { - AudibleSoundClass *sound = NULL; + AudibleSoundClass *sound = nullptr; // // Get the filename @@ -328,7 +328,7 @@ SoundEditDialogClass::Create_Sound_Object (void) sound = WWAudioClass::Get_Instance ()->Create_Sound_Effect (filename); } - if (sound != NULL) { + if (sound != nullptr) { // // Pass the new volume and priority onto the sound diff --git a/Core/Tools/W3DView/SoundEditDialog.h b/Core/Tools/W3DView/SoundEditDialog.h index 6cf71c059f9..4540570a503 100644 --- a/Core/Tools/W3DView/SoundEditDialog.h +++ b/Core/Tools/W3DView/SoundEditDialog.h @@ -85,7 +85,7 @@ class SoundEditDialogClass : public CDialog // Public methods /////////////////////////////////////////////////////// void Set_Sound (SoundRenderObjClass *sound) { REF_PTR_SET (SoundRObj, sound); } - SoundRenderObjClass * Get_Sound (void) const { if (SoundRObj != NULL) SoundRObj->Add_Ref (); return SoundRObj; } + SoundRenderObjClass * Get_Sound (void) const { if (SoundRObj != nullptr) SoundRObj->Add_Ref (); return SoundRObj; } protected: diff --git a/Core/Tools/W3DView/SphereColorPropPage.cpp b/Core/Tools/W3DView/SphereColorPropPage.cpp index 51f2dc616f5..491648db456 100644 --- a/Core/Tools/W3DView/SphereColorPropPage.cpp +++ b/Core/Tools/W3DView/SphereColorPropPage.cpp @@ -44,8 +44,8 @@ IMPLEMENT_DYNCREATE(SphereColorPropPageClass, CPropertyPage) SphereColorPropPageClass::SphereColorPropPageClass (SphereRenderObjClass *sphere) : m_RenderObj (sphere), m_bValid (true), - m_ColorBar (NULL), - m_OpacityBar (NULL), + m_ColorBar (nullptr), + m_OpacityBar (nullptr), m_EnableOpactiyVector (false), m_InvertVector (false), CPropertyPage(SphereColorPropPageClass::IDD) @@ -110,7 +110,7 @@ SphereColorPropPageClass::Initialize (void) m_VectorChannel.Reset (); m_OrigVectorChannel.Reset (); - if (m_RenderObj != NULL) { + if (m_RenderObj != nullptr) { m_ColorChannel = m_RenderObj->Get_Color_Channel (); m_OrigColorChannel = m_RenderObj->Get_Color_Channel (); @@ -247,7 +247,7 @@ SphereColorPropPageClass::OnDestroy (void) int count = m_VectorBar->Get_Point_Count (); for (int index = 0; index < count; index ++) { AlphaVectorStruct *data = (AlphaVectorStruct *)m_VectorBar->Get_User_Data (index); - if (data != NULL) { + if (data != nullptr) { delete data; m_VectorBar->Set_User_Data (index, 0L); } @@ -354,7 +354,7 @@ SphereColorPropPageClass::OnNotify if (color_bar_hdr->hdr.code == CBRN_DBLCLK_POINT) { AlphaVectorStruct *data = (AlphaVectorStruct *)m_VectorBar->Get_User_Data (color_bar_hdr->key_index); - if (data != NULL) { + if (data != nullptr) { // // Set-up the dialog so the user can edit this keyframe @@ -385,7 +385,7 @@ SphereColorPropPageClass::OnNotify AlphaVectorStruct *next_data = (AlphaVectorStruct *)m_VectorBar->Get_User_Data (color_bar_hdr->key_index + 1); AlphaVectorStruct *new_data = new AlphaVectorStruct; - if (next_data == NULL) { + if (next_data == nullptr) { (*new_data) = (*prev_data); } else { @@ -542,7 +542,7 @@ SphereColorPropPageClass::Update_Vectors (void) m_VectorBar->Get_Point (index, &position, &red, &green, &blue); AlphaVectorStruct *data = (AlphaVectorStruct *)m_VectorBar->Get_User_Data (index); - if (data != NULL) { + if (data != nullptr) { m_VectorChannel.Add_Key (*data, position); } } diff --git a/Core/Tools/W3DView/SphereColorPropPage.h b/Core/Tools/W3DView/SphereColorPropPage.h index a461d862c78..aaf4b803f20 100644 --- a/Core/Tools/W3DView/SphereColorPropPage.h +++ b/Core/Tools/W3DView/SphereColorPropPage.h @@ -36,7 +36,7 @@ class SphereColorPropPageClass : public CPropertyPage // Construction public: - SphereColorPropPageClass (SphereRenderObjClass *sphere = NULL); + SphereColorPropPageClass (SphereRenderObjClass *sphere = nullptr); ~SphereColorPropPageClass (); // Dialog Data diff --git a/Core/Tools/W3DView/SphereGeneralPropPage.cpp b/Core/Tools/W3DView/SphereGeneralPropPage.cpp index 9e8b57fa5f7..0b0698c3f92 100644 --- a/Core/Tools/W3DView/SphereGeneralPropPage.cpp +++ b/Core/Tools/W3DView/SphereGeneralPropPage.cpp @@ -95,13 +95,13 @@ END_MESSAGE_MAP() void SphereGeneralPropPageClass::Initialize (void) { - if (m_RenderObj != NULL) { + if (m_RenderObj != nullptr) { // // Get the object's texture // TextureClass *texture = m_RenderObj->Peek_Texture (); - if (texture != NULL) { + if (texture != nullptr) { m_TextureFilename = texture->Get_Texture_Name(); } @@ -204,7 +204,7 @@ SphereGeneralPropPageClass::OnApply (void) int index = SendDlgItemMessage (IDC_SHADER_COMBO, CB_GETCURSEL); if (index != CB_ERR) { ShaderClass *shader = (ShaderClass *)SendDlgItemMessage (IDC_SHADER_COMBO, CB_GETITEMDATA, (WPARAM)index); - if (shader != NULL) { + if (shader != nullptr) { m_Shader = (*shader); } } @@ -219,7 +219,7 @@ SphereGeneralPropPageClass::OnApply (void) // // Create a texture and pass it onto the object // - TextureClass *texture = NULL; + TextureClass *texture = nullptr; if (m_TextureFilename.GetLength () > 0) { texture = WW3DAssetManager::Get_Instance ()->Get_Texture (::Get_Filename_From_Path (m_TextureFilename)); } @@ -255,7 +255,7 @@ SphereGeneralPropPageClass::OnBrowseButton (void) { CFileDialog dialog ( TRUE, ".tga", - NULL, + nullptr, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_EXPLORER, "Textures files (*.tga)|*.tga||", ::AfxGetMainWnd ()); @@ -313,7 +313,7 @@ SphereGeneralPropPageClass::OnNotify // Update the spinner control if necessary // NMHDR *header = (NMHDR *)lParam; - if ((header != NULL) && (header->code == UDN_DELTAPOS)) { + if ((header != nullptr) && (header->code == UDN_DELTAPOS)) { LPNMUPDOWN updown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (header->hwndFrom, updown->iDelta); } diff --git a/Core/Tools/W3DView/SphereGeneralPropPage.h b/Core/Tools/W3DView/SphereGeneralPropPage.h index f3e3c919edb..a4210a7d5fe 100644 --- a/Core/Tools/W3DView/SphereGeneralPropPage.h +++ b/Core/Tools/W3DView/SphereGeneralPropPage.h @@ -36,7 +36,7 @@ class SphereGeneralPropPageClass : public CPropertyPage // Construction public: - SphereGeneralPropPageClass (SphereRenderObjClass *sphere = NULL); + SphereGeneralPropPageClass (SphereRenderObjClass *sphere = nullptr); ~SphereGeneralPropPageClass (); // Dialog Data diff --git a/Core/Tools/W3DView/SpherePropertySheet.cpp b/Core/Tools/W3DView/SpherePropertySheet.cpp index 400f73d6311..28a4433dd94 100644 --- a/Core/Tools/W3DView/SpherePropertySheet.cpp +++ b/Core/Tools/W3DView/SpherePropertySheet.cpp @@ -48,7 +48,7 @@ SpherePropertySheetClass::SpherePropertySheetClass CWnd * pParentWnd, UINT iSelectPage ) - : m_RenderObj (NULL), + : m_RenderObj (nullptr), CPropertySheet(nIDCaption, pParentWnd, iSelectPage) { REF_PTR_SET (m_RenderObj, sphere); @@ -69,7 +69,7 @@ SpherePropertySheetClass::SpherePropertySheetClass CWnd * pParentWnd, UINT iSelectPage ) - : m_RenderObj (NULL), + : m_RenderObj (nullptr), CPropertySheet(pszCaption, pParentWnd, iSelectPage) { REF_PTR_SET (m_RenderObj, sphere); @@ -178,7 +178,7 @@ void SpherePropertySheetClass::Add_Object_To_Viewer (void) { CW3DViewDoc *doc = ::GetCurrentDocument (); - if ((doc != NULL) && (m_RenderObj != NULL)) { + if ((doc != nullptr) && (m_RenderObj != nullptr)) { // // Create a new prototype for this object @@ -239,7 +239,7 @@ SpherePropertySheetClass::Update_Object (void) void SpherePropertySheetClass::Initialize (void) { - if (m_RenderObj == NULL) { + if (m_RenderObj == nullptr) { Create_New_Object (); } else { m_LastSavedName = m_RenderObj->Get_Name (); diff --git a/Core/Tools/W3DView/SpherePropertySheet.h b/Core/Tools/W3DView/SpherePropertySheet.h index 65b9a5777c0..ce769f79074 100644 --- a/Core/Tools/W3DView/SpherePropertySheet.h +++ b/Core/Tools/W3DView/SpherePropertySheet.h @@ -58,8 +58,8 @@ class SpherePropertySheetClass : public CPropertySheet // Construction public: - SpherePropertySheetClass (SphereRenderObjClass *sphere, UINT nIDCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); - SpherePropertySheetClass (SphereRenderObjClass *sphere, LPCTSTR pszCaption, CWnd* pParentWnd = NULL, UINT iSelectPage = 0); + SpherePropertySheetClass (SphereRenderObjClass *sphere, UINT nIDCaption, CWnd* pParentWnd = nullptr, UINT iSelectPage = 0); + SpherePropertySheetClass (SphereRenderObjClass *sphere, LPCTSTR pszCaption, CWnd* pParentWnd = nullptr, UINT iSelectPage = 0); // Attributes public: diff --git a/Core/Tools/W3DView/SphereSizePropPage.cpp b/Core/Tools/W3DView/SphereSizePropPage.cpp index 70cd13ac186..1372a20b63e 100644 --- a/Core/Tools/W3DView/SphereSizePropPage.cpp +++ b/Core/Tools/W3DView/SphereSizePropPage.cpp @@ -50,9 +50,9 @@ static bool Is_LERP (float last_value, float last_time, float curr_value, float SphereSizePropPageClass::SphereSizePropPageClass (SphereRenderObjClass *sphere) : m_RenderObj (sphere), m_bValid (true), - m_ScaleXBar (NULL), - m_ScaleYBar (NULL), - m_ScaleZBar (NULL), + m_ScaleXBar (nullptr), + m_ScaleYBar (nullptr), + m_ScaleZBar (nullptr), m_Size (0.5F, 0.5F, 0.5F), CPropertyPage(SphereSizePropPageClass::IDD) { @@ -112,7 +112,7 @@ SphereSizePropPageClass::Initialize (void) m_ScaleChannel.Reset (); m_OrigScaleChannel.Reset (); - if (m_RenderObj != NULL) { + if (m_RenderObj != nullptr) { m_Size = m_RenderObj->Get_Box ().Extent; m_ScaleChannel = m_RenderObj->Get_Scale_Channel (); m_OrigScaleChannel = m_RenderObj->Get_Scale_Channel (); @@ -306,7 +306,7 @@ SphereSizePropPageClass::OnNotify // // Determine the timeline bar which sent the notification // - ColorBarClass *timeline = NULL; + ColorBarClass *timeline = nullptr; if (color_bar_hdr->hdr.idFrom == IDC_SCALE_BAR_X) { timeline = m_ScaleXBar; } else if (color_bar_hdr->hdr.idFrom == IDC_SCALE_BAR_Y) { diff --git a/Core/Tools/W3DView/SphereSizePropPage.h b/Core/Tools/W3DView/SphereSizePropPage.h index ac6657054e6..5d7e859b087 100644 --- a/Core/Tools/W3DView/SphereSizePropPage.h +++ b/Core/Tools/W3DView/SphereSizePropPage.h @@ -36,7 +36,7 @@ class SphereSizePropPageClass : public CPropertyPage // Construction public: - SphereSizePropPageClass(SphereRenderObjClass *sphere = NULL); + SphereSizePropPageClass(SphereRenderObjClass *sphere = nullptr); ~SphereSizePropPageClass(); // Dialog Data diff --git a/Core/Tools/W3DView/SphereUtils.cpp b/Core/Tools/W3DView/SphereUtils.cpp index 6e055391724..660aacc2336 100644 --- a/Core/Tools/W3DView/SphereUtils.cpp +++ b/Core/Tools/W3DView/SphereUtils.cpp @@ -133,7 +133,7 @@ SphereKeysClass::Free_Keys (void) void SphereKeysClass::Detach (void) { - m_Keys = NULL; + m_Keys = nullptr; m_KeyCount = 0; m_MaxKeys = 0; return ; @@ -150,8 +150,8 @@ SphereKeysClass::Detach (void) static int Key_Compare (const void *arg1, const void *arg2) { - ASSERT (arg1 != NULL); - ASSERT (arg2 != NULL); + ASSERT (arg1 != nullptr); + ASSERT (arg2 != nullptr); W3dSphereKeyFrameStruct *key1 = (W3dSphereKeyFrameStruct *)arg1; W3dSphereKeyFrameStruct *key2 = (W3dSphereKeyFrameStruct *)arg2; @@ -177,7 +177,7 @@ Key_Compare (const void *arg1, const void *arg2) void SphereKeysClass::Sort (void) { - if (m_Keys != NULL && m_KeyCount > 0) { + if (m_Keys != nullptr && m_KeyCount > 0) { ::qsort (m_Keys, m_KeyCount, sizeof (W3dSphereKeyFrameStruct), Key_Compare); } diff --git a/Core/Tools/W3DView/SphereUtils.h b/Core/Tools/W3DView/SphereUtils.h index cb60d555450..7e8b2b1c1ea 100644 --- a/Core/Tools/W3DView/SphereUtils.h +++ b/Core/Tools/W3DView/SphereUtils.h @@ -51,7 +51,7 @@ class SphereKeysClass // Public constructors/destructors ///////////////////////////////////////////////////////////// SphereKeysClass (void) - : m_Keys (NULL), + : m_Keys (nullptr), m_KeyCount (0), m_MaxKeys (0) { } diff --git a/Core/Tools/W3DView/TextureMgrDialog.cpp b/Core/Tools/W3DView/TextureMgrDialog.cpp index a639372773b..32538cb4d21 100644 --- a/Core/Tools/W3DView/TextureMgrDialog.cpp +++ b/Core/Tools/W3DView/TextureMgrDialog.cpp @@ -79,10 +79,10 @@ TextureMgrDialogClass::TextureMgrDialogClass ) : m_pBaseModel (pbase_model), m_bContainsMeshes (true), - m_pImageList (NULL), - m_pImageListSmall (NULL), - m_pTextureImageList (NULL), - m_pTextureImageListSmall (NULL), + m_pImageList (nullptr), + m_pImageListSmall (nullptr), + m_pTextureImageList (nullptr), + m_pTextureImageListSmall (nullptr), CDialog (TextureMgrDialogClass::IDD, pParent) { //{{AFX_DATA_INIT(TextureMgrDialogClass) @@ -225,9 +225,9 @@ TextureMgrDialogClass::OnInitDialog (void) CRect rect; ::GetWindowRect (::GetDlgItem (m_hWnd, IDC_TOOLBAR_SLOT), &rect); ScreenToClient (&rect); - m_Toolbar.SetWindowPos (NULL, rect.left, rect.top, rect.Width (), rect.Height (), SWP_NOZORDER); + m_Toolbar.SetWindowPos (nullptr, rect.left, rect.top, rect.Width (), rect.Height (), SWP_NOZORDER); - ASSERT (m_pBaseModel != NULL); + ASSERT (m_pBaseModel != nullptr); // Create an icon imagelist for the tree control m_pImageList = new CImageList; @@ -279,7 +279,7 @@ TextureMgrDialogClass::Add_Subobjs_To_List (RenderObjClass *prender_obj) // Get a pointer to this subobject RenderObjClass *psubobj = prender_obj->Get_Sub_Object (index); - if (psubobj != NULL) { + if (psubobj != nullptr) { // Recursively add subobjs to the list Add_Subobjs_To_List (psubobj); @@ -314,12 +314,12 @@ TextureMgrDialogClass::Add_Textures_To_Node ) { MaterialInfoClass *pmat_info = pmesh->Get_Material_Info (); - if (pmat_info != NULL) { + if (pmat_info != nullptr) { // Loop through all the textures and add them as subobjs for (int index = 0; index < pmat_info->Texture_Count (); index ++) { TextureClass *ptexture = pmat_info->Get_Texture (index); - if (ptexture != NULL) { + if (ptexture != nullptr) { // Create a node from this texture and add it to the mesh TextureListNodeClass *pnode = new TextureListNodeClass (ptexture, ::Get_Texture_Name (*ptexture)); @@ -408,7 +408,7 @@ TextureMgrDialogClass::OnDblclkMeshTextureListCtrl // Get the node associated with this entry TextureListNodeClass *pnode = (TextureListNodeClass *)m_ListCtrl.GetItemData (index); - if (pnode != NULL) { + if (pnode != nullptr) { // Is this a mesh or a texture? if (pnode->Get_Type () == TextureListNodeClass::TYPE_MESH) { @@ -425,12 +425,12 @@ TextureMgrDialogClass::OnDblclkMeshTextureListCtrl // try and find an original texture... TextureListNodeClass *pmesh_node = pnode->Get_Parent (); RenderObjClass *prender_obj = WW3DAssetManager::Get_Instance ()->Create_Render_Obj (pmesh_node->Get_Name ()); - TextureClass *poriginal_texture = NULL; - if (prender_obj != NULL) { + TextureClass *poriginal_texture = nullptr; + if (prender_obj != nullptr) { // Get the material information for this render object MaterialInfoClass *pmat_info = prender_obj->Get_Material_Info (); - if (pmat_info != NULL) { + if (pmat_info != nullptr) { // Attempt to find the original texture poriginal_texture = pmat_info->Get_Texture (pnode->Get_Texture_Index ()); @@ -506,8 +506,8 @@ void TextureMgrDialogClass::OnDestroy (void) { // Free the state image list we associated with the control - m_ListCtrl.SetImageList (NULL, LVSIL_NORMAL); - m_ListCtrl.SetImageList (NULL, LVSIL_SMALL); + m_ListCtrl.SetImageList (nullptr, LVSIL_NORMAL); + m_ListCtrl.SetImageList (nullptr, LVSIL_SMALL); SAFE_DELETE (m_pImageList); SAFE_DELETE (m_pImageListSmall); SAFE_DELETE (m_pTextureImageList); @@ -612,18 +612,18 @@ TextureMgrDialogClass::Get_Thumbnail (srTextureIFace *ptexture) // Create a windows bitmap from this texture HBITMAP hbmp = ::Make_Bitmap_From_Texture (*ptexture, TEXTURE_THUMB_X, TEXTURE_THUMB_Y); - if (hbmp != NULL) { + if (hbmp != nullptr) { // Insert this bitmap into our imagelist CBitmap temp_obj; temp_obj.Attach (hbmp); - icon_index = m_pTextureImageList->Add (&temp_obj, (CBitmap *)NULL); + icon_index = m_pTextureImageList->Add (&temp_obj, (CBitmap *)nullptr); // Create a smaller bitmap and insert it into the other imagelist HBITMAP hsmall_bitmap = (HBITMAP)::CopyImage (hbmp, IMAGE_BITMAP, TEXTURE_THUMBSMALL_X, TEXTURE_THUMBSMALL_Y, 0); CBitmap small_obj; small_obj.Attach (hsmall_bitmap); - m_pTextureImageListSmall->Add (&small_obj, (CBitmap *)NULL); + m_pTextureImageListSmall->Add (&small_obj, (CBitmap *)nullptr); // Add a name to our list to represent this texture m_TextureNames.Add (::Get_Texture_Name (*ptexture)); @@ -647,7 +647,7 @@ TextureMgrDialogClass::Insert_Texture_Details ) { TextureClass *ptexture = pnode->Peek_Texture (); - if ((index != -1) && (ptexture != NULL)) { + if ((index != -1) && (ptexture != nullptr)) { // Get the name of the texture (mark it differently if its an editable texture) CString texture_name = ::Get_Texture_Name (*ptexture); @@ -741,7 +741,7 @@ TextureMgrDialogClass::OnPropagate (void) // Does this node have the same number of replaceable textures as the src node? // TextureListNodeClass *curr_node = (TextureListNodeClass *)m_ListCtrl.GetItemData (counter); - if ( (curr_node != NULL) && + if ( (curr_node != nullptr) && (curr_node->Get_Subobj_List ().Count () == src_texture_count)) { TEXTURE_NODE_LIST &curr_texture_list = curr_node->Get_Subobj_List (); @@ -754,7 +754,7 @@ TextureMgrDialogClass::OnPropagate (void) TextureListNodeClass *curr_texture_node = curr_texture_list[texture_counter]; TextureListNodeClass *src_texture_node = src_texture_list[texture_counter]; - if (curr_texture_node != NULL && src_texture_node != NULL) { + if (curr_texture_node != nullptr && src_texture_node != nullptr) { TextureClass *curr_texture = curr_texture_node->Peek_Texture (); TextureClass *src_texture = src_texture_node->Peek_Texture (); @@ -762,7 +762,7 @@ TextureMgrDialogClass::OnPropagate (void) // // Are the textures both indirect textures? // - if ( curr_texture != NULL && src_texture != NULL && + if ( curr_texture != nullptr && src_texture != nullptr && curr_texture->getClassID () == ID_INDIRECT_TEXTURE_CLASS && src_texture->getClassID () == ID_INDIRECT_TEXTURE_CLASS) { diff --git a/Core/Tools/W3DView/TextureMgrDialog.h b/Core/Tools/W3DView/TextureMgrDialog.h index 1e109aa479b..09fea2c14f7 100644 --- a/Core/Tools/W3DView/TextureMgrDialog.h +++ b/Core/Tools/W3DView/TextureMgrDialog.h @@ -77,18 +77,18 @@ class TextureListNodeClass // // Public constructors/destructors // - TextureListNodeClass (LPCTSTR name = NULL) - : m_pTexture (NULL), + TextureListNodeClass (LPCTSTR name = nullptr) + : m_pTexture (nullptr), m_Type (TYPE_MESH), - m_pParent (NULL), + m_pParent (nullptr), m_Name (name), m_TextureIndex (0), m_IconIndex (ICON_MESH) {} - TextureListNodeClass (TextureClass *ptexture, LPCTSTR name = NULL) - : m_pTexture (NULL), + TextureListNodeClass (TextureClass *ptexture, LPCTSTR name = nullptr) + : m_pTexture (nullptr), m_Type (TYPE_TEXTURE), - m_pParent (NULL), + m_pParent (nullptr), m_Name (name), m_TextureIndex (0), m_IconIndex (ICON_DEF_TEXTURE) { REF_PTR_SET (m_pTexture, ptexture); } @@ -153,7 +153,7 @@ class TextureListNodeClass __inline void TextureListNodeClass::Free_Subobj_List (void) { - // Loop through all the subobject entries and free thier pointers + // Loop through all the subobject entries and free their pointers for (int index = 0; index < m_SubObjectList.Count (); index ++) { SAFE_DELETE (m_SubObjectList[index]); } @@ -173,7 +173,7 @@ class TextureMgrDialogClass : public CDialog // Construction public: - TextureMgrDialogClass (RenderObjClass *pbase_model, CWnd *pParent = NULL); + TextureMgrDialogClass (RenderObjClass *pbase_model, CWnd *pParent = nullptr); // Dialog Data //{{AFX_DATA(TextureMgrDialogClass) diff --git a/Core/Tools/W3DView/TexturePathDialog.cpp b/Core/Tools/W3DView/TexturePathDialog.cpp index 027e16792d4..d0d5a50d75c 100644 --- a/Core/Tools/W3DView/TexturePathDialog.cpp +++ b/Core/Tools/W3DView/TexturePathDialog.cpp @@ -38,7 +38,7 @@ static char THIS_FILE[] = __FILE__; // TexturePathDialogClass // ///////////////////////////////////////////////////////////////////////////// -TexturePathDialogClass::TexturePathDialogClass(CWnd* pParent /*=NULL*/) +TexturePathDialogClass::TexturePathDialogClass(CWnd* pParent /*=nullptr*/) : CDialog(TexturePathDialogClass::IDD, pParent) { //{{AFX_DATA_INIT(TexturePathDialogClass) diff --git a/Core/Tools/W3DView/TexturePathDialog.h b/Core/Tools/W3DView/TexturePathDialog.h index 0d83bfe3dfa..58082664864 100644 --- a/Core/Tools/W3DView/TexturePathDialog.h +++ b/Core/Tools/W3DView/TexturePathDialog.h @@ -28,7 +28,7 @@ class TexturePathDialogClass : public CDialog { // Construction public: - TexturePathDialogClass(CWnd* pParent = NULL); // standard constructor + TexturePathDialogClass(CWnd* pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(TexturePathDialogClass) diff --git a/Core/Tools/W3DView/TextureSettingsDialog.cpp b/Core/Tools/W3DView/TextureSettingsDialog.cpp index 6413def5885..1ee721e05cc 100644 --- a/Core/Tools/W3DView/TextureSettingsDialog.cpp +++ b/Core/Tools/W3DView/TextureSettingsDialog.cpp @@ -70,10 +70,10 @@ TextureSettingsDialogClass::TextureSettingsDialogClass IndirectTextureClass *poriginal_texture, CWnd *pParent ) - : m_pTexture (NULL), - m_pOriginalTexture (NULL), - m_pStartingTexture (NULL), - m_hThumbnail (NULL), + : m_pTexture (nullptr), + m_pOriginalTexture (nullptr), + m_pStartingTexture (nullptr), + m_hThumbnail (nullptr), m_bWereSettingsModified (false), CDialog(TextureSettingsDialogClass::IDD, pParent) { @@ -135,7 +135,7 @@ TextureSettingsDialogClass::OnInitDialog (void) { // Allow the base class to process this message CDialog::OnInitDialog (); - ASSERT (m_pTexture != NULL); + ASSERT (m_pTexture != nullptr); ASSERT (m_pTexture->getClassID () == ID_INDIRECT_TEXTURE_CLASS); // Determine what the starting texture was so we can restore on cancel (if necessary) @@ -153,7 +153,7 @@ TextureSettingsDialogClass::OnInitDialog (void) // Enable or disable the 'restore' button based on whether or not we // have an original texture to switch to... - ::EnableWindow (::GetDlgItem (m_hWnd, IDC_RESTORE), (m_pOriginalTexture != NULL)); + ::EnableWindow (::GetDlgItem (m_hWnd, IDC_RESTORE), (m_pOriginalTexture != nullptr)); ::EnableWindow (::GetDlgItem (m_hWnd, IDC_APPLY), FALSE); // Fill the dialog controls with data from the texture @@ -170,9 +170,9 @@ void TextureSettingsDialogClass::Load_Texture_Settings (void) { // Free the old thumbnail (if there was one) - if (m_hThumbnail != NULL) { + if (m_hThumbnail != nullptr) { DeleteObject (m_hThumbnail); - m_hThumbnail = NULL; + m_hThumbnail = nullptr; } // Get the actual texture... @@ -200,7 +200,7 @@ TextureSettingsDialogClass::Load_Texture_Settings (void) void TextureSettingsDialogClass::Fill_Controls (TextureClass *ptexture) { - srTexture *psource = NULL; + srTexture *psource = nullptr; // What type of texture is this? switch (ptexture->getClassID ()) @@ -217,7 +217,7 @@ TextureSettingsDialogClass::Fill_Controls (TextureClass *ptexture) psource = ((ResizeableTextureInstanceClass *)ptexture)->Peek_Source(); // Fill the 'filename' edit control - if (psource != NULL && (psource->getClassID () == ID_FILE_LIST_TEXTURE_CLASS)) { + if (psource != nullptr && (psource->getClassID () == ID_FILE_LIST_TEXTURE_CLASS)) { FileListTextureClass *pfile_list = static_cast(psource); SetDlgItemText (IDC_FILENAME_EDIT, pfile_list->Get_Filename (0)); } @@ -230,8 +230,8 @@ TextureSettingsDialogClass::Fill_Controls (TextureClass *ptexture) } // Set the checkboxes - ASSERT (psource != NULL); - if (psource != NULL) { + ASSERT (psource != nullptr); + if (psource != nullptr) { SendDlgItemMessage (IDC_MIPMAP_OFF_CHECK, BM_SETCHECK, (WPARAM)(psource->getMipmap () == srTextureIFace::MIPMAP_NONE)); SendDlgItemMessage (IDC_ALPHA_CHECK, BM_SETCHECK, (WPARAM)(psource->isHintEnabled(srTextureIFace::HINT_ALPHA_BITMASK))); SendDlgItemMessage (IDC_CLAMPU_CHECK, BM_SETCHECK, (WPARAM)(psource->Get_U_Addr_Mode() == TextureClass::TEXTURE_ADDRESS_CLAMP)); @@ -430,9 +430,9 @@ TextureSettingsDialogClass::WindowProc void TextureSettingsDialogClass::OnDestroy (void) { - if (m_hThumbnail != NULL) { + if (m_hThumbnail != nullptr) { ::DeleteObject (m_hThumbnail); - m_hThumbnail = NULL; + m_hThumbnail = nullptr; } // Allow the base class to process this message @@ -483,13 +483,13 @@ void TextureSettingsDialogClass::Paint_Thumbnail (void) { // Paint the thumbnail - if (m_hThumbnail != NULL) { + if (m_hThumbnail != nullptr) { // Get the misc crap windows requries before we can // paint to the screen HWND hchild_wnd = ::GetDlgItem (m_hWnd, IDC_TEXTURE_THUMBNAIL); HDC hdc = ::GetDC (hchild_wnd); - HDC hmem_dc = ::CreateCompatibleDC (NULL); + HDC hmem_dc = ::CreateCompatibleDC (nullptr); HBITMAP hold_bmp = (HBITMAP)::SelectObject (hmem_dc, m_hThumbnail); // Paint the thumbnail onto the dialog @@ -509,7 +509,7 @@ TextureSettingsDialogClass::Paint_Thumbnail (void) ::SelectObject (hmem_dc, hold_bmp); ::ReleaseDC (hchild_wnd, hmem_dc); ::DeleteDC (hmem_dc); - ::ValidateRect (hchild_wnd, NULL); + ::ValidateRect (hchild_wnd, nullptr); } return ; @@ -523,7 +523,7 @@ TextureSettingsDialogClass::Paint_Thumbnail (void) void TextureSettingsDialogClass::OnRestore (void) { - if (m_pOriginalTexture != NULL) { + if (m_pOriginalTexture != nullptr) { // Get the original texture TextureClass *pnew_texture = m_pOriginalTexture->Get_Texture (); @@ -609,8 +609,8 @@ TextureSettingsDialogClass::OnApply (void) //} } - ASSERT (pnew_texture != NULL); - if (pnew_texture != NULL) { + ASSERT (pnew_texture != nullptr); + if (pnew_texture != nullptr) { // Turn mipmapping off if necessary if (SendDlgItemMessage (IDC_MIPMAP_OFF_CHECK, BM_GETCHECK) == 1) { diff --git a/Core/Tools/W3DView/TextureSettingsDialog.h b/Core/Tools/W3DView/TextureSettingsDialog.h index ba443b4b0c4..637c143ba56 100644 --- a/Core/Tools/W3DView/TextureSettingsDialog.h +++ b/Core/Tools/W3DView/TextureSettingsDialog.h @@ -47,7 +47,7 @@ class TextureSettingsDialogClass : public CDialog { // Construction public: - TextureSettingsDialogClass (IndirectTextureClass *ptexture, IndirectTextureClass *poriginal_texture, CWnd *pParent = NULL); + TextureSettingsDialogClass (IndirectTextureClass *ptexture, IndirectTextureClass *poriginal_texture, CWnd *pParent = nullptr); virtual ~TextureSettingsDialogClass (void); // Dialog Data diff --git a/Core/Tools/W3DView/Toolbar.cpp b/Core/Tools/W3DView/Toolbar.cpp index b252d74647d..7780f0233c6 100644 --- a/Core/Tools/W3DView/Toolbar.cpp +++ b/Core/Tools/W3DView/Toolbar.cpp @@ -71,14 +71,14 @@ CFancyToolbar::~CFancyToolbar (void) { // Free the BMP for this button ::DeleteObject (m_pButtonArray[iButton].hBMPUp); - m_pButtonArray[iButton].hBMPUp = NULL; + m_pButtonArray[iButton].hBMPUp = nullptr; } if (m_pButtonArray[iButton].hBMPDn) { // Free the BMP for this button ::DeleteObject (m_pButtonArray[iButton].hBMPDn); - m_pButtonArray[iButton].hBMPDn = NULL; + m_pButtonArray[iButton].hBMPDn = nullptr; } } @@ -101,7 +101,7 @@ CFancyToolbar::RegisterFancyToolbarClass (void) classInfo.style = CS_PARENTDC; classInfo.lpfnWndProc = ::DefWindowProc; classInfo.hInstance = ::AfxGetInstanceHandle (); - classInfo.hCursor = ::LoadCursor (NULL, IDC_ARROW); + classInfo.hCursor = ::LoadCursor (nullptr, IDC_ARROW); classInfo.hbrBackground = (HBRUSH)COLOR_BTNFACE; classInfo.lpszClassName = TOOLBAR_CLASS_NAME; @@ -260,7 +260,7 @@ CFancyToolbar::Paint (void) } // Let the window know its done painting - ::ValidateRect (m_hWnd, NULL); + ::ValidateRect (m_hWnd, nullptr); return ; } @@ -351,7 +351,7 @@ CFancyToolbar::OnLButtonDown // 2 state button m_iCurrentButton = -1; - // Send the message to the window's parent to let them know a command has occured + // Send the message to the window's parent to let them know a command has occurred ::AfxGetMainWnd ()->PostMessage (WM_COMMAND, MAKELONG (m_pButtonArray[iButton].iCommandID, BN_CLICKED), (LPARAM)m_hWnd); @@ -470,7 +470,7 @@ CFancyToolbar::SetButtonState { // Repaint the toolbar //Paint (); - InvalidateRect (NULL); + InvalidateRect (nullptr); UpdateWindow (); } diff --git a/Core/Tools/W3DView/Utils.cpp b/Core/Tools/W3DView/Utils.cpp index 95ed99ff0b8..b665f1c73db 100644 --- a/Core/Tools/W3DView/Utils.cpp +++ b/Core/Tools/W3DView/Utils.cpp @@ -46,7 +46,7 @@ CW3DViewDoc * GetCurrentDocument (void) { // Assume failure - CW3DViewDoc *pCDoc = NULL; + CW3DViewDoc *pCDoc = nullptr; // Get a pointer to the main window CMainFrame *pCMainWnd = (CMainFrame *)::AfxGetMainWnd (); @@ -96,7 +96,7 @@ CenterDialogAroundTreeView (HWND hDlg) // Move the dialog so its centered in the data tree view ::SetWindowPos (hDlg, - NULL, + nullptr, rect.left + ((rect.right-rect.left) >> 1) - ((dialogRect.right-dialogRect.left) >> 1), rect.top + ((rect.bottom-rect.top) >> 1) - ((dialogRect.bottom-dialogRect.top) >> 1), 0, @@ -156,7 +156,7 @@ Paint_Gradient ::ReleaseDC (hWnd, hDC); // Validate the contents of the window so the control won't paint itself - ::ValidateRect (hWnd, NULL); + ::ValidateRect (hWnd, nullptr); return ; } @@ -226,7 +226,7 @@ Initialize_Spinner // Set the buddy's text accordingly // CWnd *buddy = ctrl.GetBuddy (); - if (buddy != NULL) { + if (buddy != nullptr) { ::SetWindowFloat (*buddy, pos); } @@ -246,7 +246,7 @@ Update_Spinner_Buddy (CSpinButtonCtrl &ctrl, int delta) // if ((::GetWindowLong (ctrl, GWL_STYLE) & UDS_SETBUDDYINT) == 0) { CWnd *buddy = ctrl.GetBuddy (); - if (buddy != NULL) { + if (buddy != nullptr) { // Get the current value, increment it, and put it back into the control float value = ::GetWindowFloat (*buddy); @@ -321,7 +321,7 @@ Enable_Dialog_Controls (HWND dlg,bool onoff) // Loop over all sub-windows enable/disabling everything except for // the static text controls // - for (HWND child = ::GetWindow(dlg,GW_CHILD) ; child != NULL ; child = ::GetWindow(child,GW_HWNDNEXT)) { + for (HWND child = ::GetWindow(dlg,GW_CHILD) ; child != nullptr ; child = ::GetWindow(child,GW_HWNDNEXT)) { char buf[64]; ::GetClassName(child,buf,sizeof(buf)); if (stricmp(buf,"STATIC") != 0) { @@ -414,9 +414,9 @@ Filename_From_Asset_Name (LPCTSTR asset_name) CString Get_Filename_From_Path (LPCTSTR path) { - // Find the last occurance of the directory deliminator + // Find the last occurrence of the directory deliminator LPCTSTR filename = ::strrchr (path, '\\'); - if (filename != NULL) { + if (filename != nullptr) { // Increment past the directory deliminator filename ++; } else { @@ -439,9 +439,9 @@ Strip_Filename_From_Path (LPCTSTR path) TCHAR temp_path[MAX_PATH]; ::lstrcpy (temp_path, path); - // Find the last occurance of the directory deliminator + // Find the last occurrence of the directory deliminator LPTSTR filename = ::strrchr (temp_path, '\\'); - if (filename != NULL) { + if (filename != nullptr) { // Strip off the filename filename[0] = 0; } @@ -478,18 +478,18 @@ Create_DIB_Section bitmap_info.biClrImportant = 0; // Get a temporary screen DC - HDC hscreen_dc = ::GetDC (NULL); + HDC hscreen_dc = ::GetDC (nullptr); // Create a bitmap that we can access the bits directly of HBITMAP hbitmap = ::CreateDIBSection (hscreen_dc, (const BITMAPINFO *)&bitmap_info, DIB_RGB_COLORS, (void **)pbits, - NULL, + nullptr, 0L); // Release our temporary screen DC - ::ReleaseDC (NULL, hscreen_dc); + ::ReleaseDC (nullptr, hscreen_dc); return hbitmap; } @@ -502,7 +502,7 @@ HBITMAP Make_Bitmap_From_Texture (TextureClass &texture, int width, int height) { // TheSuperHackers @info Not implemented - HBITMAP hbitmap = NULL; + HBITMAP hbitmap = nullptr; // Return a handle to the bitmap return hbitmap; } @@ -538,7 +538,7 @@ Build_Emitter_List // Loop through all this render obj's sub-obj's for (int index = 0; index < render_obj.Get_Num_Sub_Objects (); index ++) { RenderObjClass *psub_obj = render_obj.Get_Sub_Object (index); - if (psub_obj != NULL) { + if (psub_obj != nullptr) { // Is this sub-obj an emitter? if (psub_obj->Class_ID () == RenderObjClass::CLASSID_PARTICLEEMITTER) { @@ -579,8 +579,8 @@ Is_Aggregate (const char *asset_name) // Check to see if this object is an aggregate RenderObjClass *prender_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj (asset_name); - if ((prender_obj != NULL) && - (prender_obj->Get_Base_Model_Name () != NULL)) + if ((prender_obj != nullptr) && + (prender_obj->Get_Base_Model_Name () != nullptr)) { retval = true; } @@ -605,14 +605,14 @@ Rename_Aggregate_Prototype ) { // Params valid? - if ((old_name != NULL) && - (new_name != NULL) && + if ((old_name != nullptr) && + (new_name != nullptr) && (::lstrcmpi (old_name, new_name) != 0)) { // Get the prototype from the asset manager - AggregatePrototypeClass *proto = NULL; + AggregatePrototypeClass *proto = nullptr; proto = (AggregatePrototypeClass *)WW3DAssetManager::Get_Instance ()->Find_Prototype (old_name); - if (proto != NULL) { + if (proto != nullptr) { // Copy the definition from the prototype and remove the prototype AggregateDefClass *pdefinition = proto->Get_Definition (); @@ -642,7 +642,7 @@ Is_Real_LOD (const char *asset_name) // Check to see if this object is an aggregate RenderObjClass *prender_obj = WW3DAssetManager::Get_Instance()->Create_Render_Obj (asset_name); - if ((prender_obj != NULL) && + if ((prender_obj != nullptr) && (prender_obj->Class_ID () == RenderObjClass::CLASSID_HLOD) && (((HLodClass *)prender_obj)->Get_LOD_Count () > 1)) { retval = true; @@ -676,10 +676,10 @@ Get_File_Time HANDLE hfile = ::CreateFile (path, 0, 0, - NULL, + nullptr, OPEN_EXISTING, 0L, - NULL); + nullptr); ASSERT (hfile != INVALID_HANDLE_VALUE); if (hfile != INVALID_HANDLE_VALUE) { @@ -724,13 +724,13 @@ Are_Glide_Drivers_Acceptable (void) // Get the creation time of the glide2x driver FILETIME file_time = { 0 }; - if (::Get_File_Time (glide2x, NULL, NULL, &file_time)) { + if (::Get_File_Time (glide2x, nullptr, nullptr, &file_time)) { CTime time_obj (file_time); retval = ((time_obj.GetYear () == 1998) && (time_obj.GetMonth () == 12)) || (time_obj.GetYear () > 1998); } // Get the creation time of the glide3x driver - if (::Get_File_Time (glide3x, NULL, NULL, &file_time)) { + if (::Get_File_Time (glide3x, nullptr, nullptr, &file_time)) { CTime time_obj (file_time); retval = ((time_obj.GetYear () == 1998) && (time_obj.GetMonth () == 12)) || (time_obj.GetYear () > 1998); } @@ -748,7 +748,7 @@ Are_Glide_Drivers_Acceptable (void) TextureClass * Load_RC_Texture (LPCTSTR resource_name) { - TextureClass *texture = NULL; + TextureClass *texture = nullptr; // // Load the cursor file image from this binaries resources @@ -763,7 +763,7 @@ Load_RC_Texture (LPCTSTR resource_name) // TheSuperHackers @info Not implemented - // Reutrn a pointer to the new texture + // Return a pointer to the new texture return texture; } @@ -826,7 +826,7 @@ Copy_File bool force_copy ) { - SANITY_CHECK ((existing_filename != NULL && new_filename != NULL)) { + SANITY_CHECK ((existing_filename != nullptr && new_filename != nullptr)) { return false; } @@ -867,13 +867,13 @@ Copy_File CGraphicView * Get_Graphic_View (void) { - CGraphicView *view = NULL; + CGraphicView *view = nullptr; // // Get the view from the current document // CW3DViewDoc *doc = GetCurrentDocument (); - if (doc != NULL) { + if (doc != nullptr) { view = doc->GetGraphicView (); } diff --git a/Core/Tools/W3DView/Utils.h b/Core/Tools/W3DView/Utils.h index afd07056a7f..9d2b940466c 100644 --- a/Core/Tools/W3DView/Utils.h +++ b/Core/Tools/W3DView/Utils.h @@ -35,14 +35,14 @@ class RenderObjClass; // // Macros // -#define SAFE_DELETE(pobject) { delete pobject; pobject = NULL; } -#define SAFE_DELETE_ARRAY(pobject) { delete [] pobject; pobject = NULL; } +#define SAFE_DELETE(pobject) { delete pobject; pobject = nullptr; } +#define SAFE_DELETE_ARRAY(pobject) { delete [] pobject; pobject = nullptr; } #define COM_RELEASE(pobject) \ if (pobject) { \ pobject->Release (); \ } \ - pobject = NULL; \ + pobject = nullptr; \ #define SAFE_CLOSE(handle) \ if (handle != INVALID_HANDLE_VALUE) { \ @@ -114,7 +114,7 @@ CString Filename_From_Asset_Name (LPCTSTR asset_name); // // File routines // -bool Get_File_Time (LPCTSTR path, LPFILETIME pcreation_time, LPFILETIME paccess_time = NULL, LPFILETIME pwrite_time = NULL); +bool Get_File_Time (LPCTSTR path, LPFILETIME pcreation_time, LPFILETIME paccess_time = nullptr, LPFILETIME pwrite_time = nullptr); bool Are_Glide_Drivers_Acceptable (void); bool Copy_File (LPCTSTR existing_filename, LPCTSTR new_filename, bool bforce_copy = false); diff --git a/Core/Tools/W3DView/Vector3RndCombo.cpp b/Core/Tools/W3DView/Vector3RndCombo.cpp index 5cc5ca992d1..c923922acf6 100644 --- a/Core/Tools/W3DView/Vector3RndCombo.cpp +++ b/Core/Tools/W3DView/Vector3RndCombo.cpp @@ -74,7 +74,7 @@ int Combo_Index_From_Vector3_Rnd (Vector3Randomizer *randomizer) { int index = 0; - if (randomizer != NULL) { + if (randomizer != nullptr) { index = (int)randomizer->Class_ID (); } @@ -91,7 +91,7 @@ Combo_Index_From_Vector3_Rnd (Vector3Randomizer *randomizer) Vector3Randomizer * Vector3_Rnd_From_Combo_Index (int index, float value1, float value2, float value3) { - Vector3Randomizer *randomizer = NULL; + Vector3Randomizer *randomizer = nullptr; // // What type of randomizer should we create? diff --git a/Core/Tools/W3DView/ViewerScene.cpp b/Core/Tools/W3DView/ViewerScene.cpp index 2383988dce9..549934c81c0 100644 --- a/Core/Tools/W3DView/ViewerScene.cpp +++ b/Core/Tools/W3DView/ViewerScene.cpp @@ -105,7 +105,7 @@ RenderObjClass * ViewerSceneIterator::Current_Item(void) // // Visibility_Check // -// Note: We overide this method to remove the LOD preparation. We +// Note: We override this method to remove the LOD preparation. We // need to be able to specify an LOD and not have it switch on us. // //////////////////////////////////////////////////////////////////////// @@ -150,7 +150,7 @@ ViewerSceneClass::Add_To_Lineup (RenderObjClass *obj) assert(obj); // If this is an insignificant object (ie. we don't need to - // rearrange existing objects to accomodate it), don't bother + // rearrange existing objects to accommodate it), don't bother // adding it to the lineup. Ex: Adding a light to the lineup // is pretty silly. if (!Can_Line_Up(obj)) @@ -216,7 +216,7 @@ ViewerSceneClass::Clear_Lineup (void) { // Remove every object in the lineup from the scene, // and remove each object from the line up list. - RenderObjClass *obj = NULL; + RenderObjClass *obj = nullptr; while (obj = LineUpList.Remove_Head()) Remove_Render_Object(obj); } diff --git a/Core/Tools/W3DView/VolumeRandomDialog.cpp b/Core/Tools/W3DView/VolumeRandomDialog.cpp index 74efda04352..6c3de349a12 100644 --- a/Core/Tools/W3DView/VolumeRandomDialog.cpp +++ b/Core/Tools/W3DView/VolumeRandomDialog.cpp @@ -157,7 +157,7 @@ VolumeRandomDialogClass::OnInitDialog (void) // // Initialize from the provided randomizer // - if (m_Randomizer != NULL) { + if (m_Randomizer != nullptr) { // What type of randomizer is this? switch (m_Randomizer->Class_ID ()) @@ -315,7 +315,7 @@ VolumeRandomDialogClass::OnNotify // Update the spinner control if necessary // NMHDR *pheader = (NMHDR *)lParam; - if ((pheader != NULL) && (pheader->code == UDN_DELTAPOS)) { + if ((pheader != nullptr) && (pheader->code == UDN_DELTAPOS)) { LPNMUPDOWN pupdown = (LPNMUPDOWN)lParam; ::Update_Spinner_Buddy (pheader->hwndFrom, pupdown->iDelta); } diff --git a/Core/Tools/W3DView/VolumeRandomDialog.h b/Core/Tools/W3DView/VolumeRandomDialog.h index 10956f3122f..f1550b21428 100644 --- a/Core/Tools/W3DView/VolumeRandomDialog.h +++ b/Core/Tools/W3DView/VolumeRandomDialog.h @@ -33,7 +33,7 @@ class VolumeRandomDialogClass : public CDialog { // Construction public: - VolumeRandomDialogClass (Vector3Randomizer *randomizer, CWnd *pParent = NULL); // standard constructor + VolumeRandomDialogClass (Vector3Randomizer *randomizer, CWnd *pParent = nullptr); // standard constructor // Dialog Data //{{AFX_DATA(VolumeRandomDialogClass) diff --git a/Core/Tools/W3DView/W3DView.cpp b/Core/Tools/W3DView/W3DView.cpp index 89205622fd6..890673e4d36 100644 --- a/Core/Tools/W3DView/W3DView.cpp +++ b/Core/Tools/W3DView/W3DView.cpp @@ -47,10 +47,10 @@ static char THIS_FILE[] = __FILE__; #endif -HINSTANCE ApplicationHInstance = NULL; ///< our application instance +HINSTANCE ApplicationHInstance = nullptr; ///< our application instance /// just to satisfy the game libraries we link to -HWND ApplicationHWnd = NULL; +HWND ApplicationHWnd = nullptr; const char *gAppPrefix = "w3_"; @@ -132,7 +132,7 @@ WinMain catch (...) { - ::MessageBox (NULL, "Internal Application Error", "Unrecoverable Error", MB_ICONERROR | MB_OK); + ::MessageBox (nullptr, "Internal Application Error", "Unrecoverable Error", MB_ICONERROR | MB_OK); } #endif //RTS_DEBUG @@ -149,7 +149,7 @@ void Do_Version_Check (void) { char curr_filename[MAX_PATH]; - ::GetModuleFileName (NULL, curr_filename, MAX_PATH); + ::GetModuleFileName (nullptr, curr_filename, MAX_PATH); CString filename = "\\\\cabal\\mis\\r&d\\w3d\\w3dview\\"; filename += ::Get_Filename_From_Path (curr_filename); @@ -159,7 +159,7 @@ Do_Version_Check (void) // against the version we are running. // if (Compare_EXE_Version ((int)::AfxGetInstanceHandle (), filename) < 0) { - ::MessageBox (NULL, "There is a newer version of the W3DViewer, please run W3DUpdate to upgrade your local copy.", "Version Info", MB_ICONEXCLAMATION | MB_OK | MB_SETFOREGROUND | MB_SYSTEMMODAL); + ::MessageBox (nullptr, "There is a newer version of the W3DViewer, please run W3DUpdate to upgrade your local copy.", "Version Info", MB_ICONEXCLAMATION | MB_OK | MB_SETFOREGROUND | MB_SYSTEMMODAL); } return ; @@ -189,9 +189,9 @@ BOOL CW3DViewApp::InitInstance (void) RegisterColorBar (::AfxGetInstanceHandle ()); // Is there already an instance of the viewer running? - HWND hprev_instance = NULL; + HWND hprev_instance = nullptr; ::EnumWindows (fnTopLevelWindowSearch, (LPARAM)&hprev_instance); - if (hprev_instance == NULL) { + if (hprev_instance == nullptr) { // Change the registry key under which our settings are stored. // You should modify this string to be something appropriate @@ -258,7 +258,7 @@ BOOL CW3DViewApp::InitInstance (void) ::SetForegroundWindow (hprev_instance); } - return (hprev_instance == NULL); + return (hprev_instance == nullptr); } ///////////////////////////////////////////////////////////////////////////// @@ -347,7 +347,7 @@ void Debug_Refs(void) strcmp(search_ref->File, ref->File) == 0 && (search_ref->Line == ref->Line) ) { count++; - } else if ( (ref->File == NULL) && (search_ref->File == NULL) ) { + } else if ( (ref->File == nullptr) && (search_ref->File == nullptr) ) { count++; } @@ -405,7 +405,7 @@ CW3DViewApp::ExitInstance() // Free the asset manager // delete _TheAssetMgr; - _TheAssetMgr = NULL; + _TheAssetMgr = nullptr; } Debug_Refs (); @@ -427,7 +427,7 @@ fnTopLevelWindowSearch BOOL bcontinue = TRUE; // Is this a viewer window? - if (::GetProp (hwnd, "WW3DVIEWER") != 0) { + if (::GetProp (hwnd, "WW3DVIEWER") != nullptr) { bcontinue = false; (*((HWND *)lParam)) = hwnd; } @@ -453,7 +453,7 @@ CAboutDlg::OnInitDialog (void) // Get the name and path of the currently executing application TCHAR filename[MAX_PATH]; - ::GetModuleFileName (NULL, filename, sizeof (filename)); + ::GetModuleFileName (nullptr, filename, sizeof (filename)); // Get the version information for this file DWORD dummy_var = 0; @@ -466,7 +466,7 @@ CAboutDlg::OnInitDialog (void) // Query the block for the file version information UINT version_len = 0; - VS_FIXEDFILEINFO *pversion_info = NULL; + VS_FIXEDFILEINFO *pversion_info = nullptr; if (::VerQueryValue (pblock, "\\", (LPVOID *)&pversion_info, &version_len)) { version_major = pversion_info->dwFileVersionMS; version_minor = pversion_info->dwFileVersionLS; diff --git a/Core/Tools/W3DView/W3DViewDoc.cpp b/Core/Tools/W3DView/W3DViewDoc.cpp index 1594b538590..7dc9eb19cac 100644 --- a/Core/Tools/W3DView/W3DViewDoc.cpp +++ b/Core/Tools/W3DView/W3DViewDoc.cpp @@ -89,25 +89,25 @@ END_MESSAGE_MAP() // CW3DViewDoc // CW3DViewDoc::CW3DViewDoc (void) - : m_pCScene (NULL), - m_pC2DScene (NULL), - m_pCursorScene (NULL), - m_pCBackObjectScene (NULL), - m_pDazzleLayer (NULL), - m_pCBackObjectCamera (NULL), - m_pCBackgroundObject (NULL), - m_pC2DCamera (NULL), - m_pCSceneLight (NULL), - m_pCRenderObj (NULL), - m_pCAnimation (NULL), - m_pCAnimCombo (NULL), - m_pCBackgroundBMP (NULL), + : m_pCScene (nullptr), + m_pC2DScene (nullptr), + m_pCursorScene (nullptr), + m_pCBackObjectScene (nullptr), + m_pDazzleLayer (nullptr), + m_pCBackObjectCamera (nullptr), + m_pCBackgroundObject (nullptr), + m_pC2DCamera (nullptr), + m_pCSceneLight (nullptr), + m_pCRenderObj (nullptr), + m_pCAnimation (nullptr), + m_pCAnimCombo (nullptr), + m_pCBackgroundBMP (nullptr), m_CurrentFrame (0), m_bAnimBlend (TRUE), m_bAnimateCamera (false), m_bAutoCameraReset (true), m_bOneTimeReset (true), - m_pCursor (NULL), + m_pCursor (nullptr), m_backgroundColor (0.5F, 0.5F, 0.5F), m_ManualFOV (false), m_ManualClipPlanes (false), @@ -153,7 +153,7 @@ CW3DViewDoc::CleanupResources (void) // Release the 2D scene we allocated to display background BMPs m_pC2DScene->Release_Ref (); - m_pC2DScene = NULL; + m_pC2DScene = nullptr; } if (m_pCBackObjectScene) @@ -166,10 +166,10 @@ CW3DViewDoc::CleanupResources (void) // Release the scene we allocated to display background objects m_pCBackObjectScene->Release_Ref (); - m_pCBackObjectScene = NULL; + m_pCBackObjectScene = nullptr; } - if (m_pCursor != NULL) { + if (m_pCursor != nullptr) { m_pCursor->Remove (); } REF_PTR_RELEASE (m_pCursorScene); @@ -193,19 +193,19 @@ CW3DViewDoc::CleanupResources (void) // Release the scene object we allocated earlier m_pCScene->Release_Ref (); - m_pCScene = NULL; + m_pCScene = nullptr; } // Was there a dazzle layer? delete m_pDazzleLayer; - m_pDazzleLayer = NULL; + m_pDazzleLayer = nullptr; // Was there a valid scene object? if (m_pCBackObjectScene) { // Free the scene object m_pCBackObjectScene->Release_Ref (); - m_pCBackObjectScene = NULL; + m_pCBackObjectScene = nullptr; } // Was there a valid 2D camera? @@ -213,7 +213,7 @@ CW3DViewDoc::CleanupResources (void) { // Free the camera object m_pC2DCamera->Release_Ref (); - m_pC2DCamera = NULL; + m_pC2DCamera = nullptr; } // Was there a valid background camera? @@ -221,21 +221,21 @@ CW3DViewDoc::CleanupResources (void) { // Free the camera object m_pCBackObjectCamera->Release_Ref (); - m_pCBackObjectCamera = NULL; + m_pCBackObjectCamera = nullptr; } // Was there a valid background BMP? if (m_pCBackgroundBMP) { m_pCBackgroundBMP->Release_Ref (); - m_pCBackgroundBMP = NULL; + m_pCBackgroundBMP = nullptr; } // Was there a valid scene light? if (m_pCSceneLight) { m_pCSceneLight->Release_Ref (); - m_pCSceneLight = NULL; + m_pCSceneLight = nullptr; } // Was there a valid display object? @@ -352,7 +352,7 @@ void CW3DViewDoc::Dump(CDumpContext& dc) const void CW3DViewDoc::InitScene (void) { - if (m_pCScene == NULL) { + if (m_pCScene == nullptr) { // // Make sure the emitters don't remove themselves from the scene @@ -362,7 +362,7 @@ CW3DViewDoc::InitScene (void) m_pCScene = new ViewerSceneClass; ASSERT (m_pCScene); - if (m_pCScene != NULL) { + if (m_pCScene != nullptr) { // Set some default ambient lighting m_pCScene->Set_Ambient_Light (Vector3 (0.5F, 0.5F, 0.5F)); @@ -374,7 +374,7 @@ CW3DViewDoc::InitScene (void) m_pCSceneLight = new LightClass; ASSERT (m_pCSceneLight); - if (m_pCSceneLight != NULL) { + if (m_pCSceneLight != nullptr) { // Create some default light settings m_pCSceneLight->Set_Position (Vector3 (0, 5000, 3000)); @@ -481,7 +481,7 @@ CW3DViewDoc::OnOpenDocument (LPCTSTR lpszPathName) // Don't allow repaints while the load is going on // CGraphicView *current_view = ::Get_Graphic_View (); - if (current_view != NULL) { + if (current_view != nullptr) { current_view->Allow_Update (false); } @@ -494,14 +494,14 @@ CW3DViewDoc::OnOpenDocument (LPCTSTR lpszPathName) // Re-load the data list to include all new assets // CDataTreeView *data_view = GetDataTreeView (); - if (data_view != NULL) { + if (data_view != nullptr) { data_view->LoadAssetsIntoTree (); } // // Turn repainting back on... // - if (current_view != NULL) { + if (current_view != nullptr) { current_view->Allow_Update (true); } @@ -517,7 +517,7 @@ CW3DViewDoc::OnOpenDocument (LPCTSTR lpszPathName) void CW3DViewDoc::LoadAssetsFromFile (LPCTSTR lpszPathName) { - if (m_pCScene == NULL) { + if (m_pCScene == nullptr) { InitScene (); } @@ -535,7 +535,7 @@ CW3DViewDoc::LoadAssetsFromFile (LPCTSTR lpszPathName) // Don't allow repaints while the load is going on // CGraphicView *current_view = ::Get_Graphic_View (); - if (current_view != NULL) { + if (current_view != nullptr) { current_view->Allow_Update (false); } @@ -555,7 +555,7 @@ CW3DViewDoc::LoadAssetsFromFile (LPCTSTR lpszPathName) // Load the texture file into the asset manager TextureClass *ptexture = WW3DAssetManager::Get_Instance()->Get_Texture (::Get_Filename_From_Path (lpszPathName)); - if (ptexture != NULL) { + if (ptexture != nullptr) { ptexture->Release_Ref(); } @@ -566,7 +566,7 @@ CW3DViewDoc::LoadAssetsFromFile (LPCTSTR lpszPathName) // // Turn repainting back on... // - if (current_view != NULL) { + if (current_view != nullptr) { current_view->Allow_Update (true); } @@ -606,23 +606,23 @@ CW3DViewDoc::Display_Emitter ASSERT (m_pCScene); // Data OK? - if (m_pCScene != NULL) { + if (m_pCScene != nullptr) { // Lose the animation SAFE_DELETE (m_pCAnimCombo); REF_PTR_RELEASE (m_pCAnimation); - if (m_pCRenderObj != NULL) { + if (m_pCRenderObj != nullptr) { // Remove this object from the scene Remove_Object_From_Scene (m_pCRenderObj); m_pCRenderObj->Release_Ref (); - m_pCRenderObj = NULL; + m_pCRenderObj = nullptr; } m_pCScene->Clear_Lineup(); // Do we have a new emitter to display? - if (pemitter != NULL) { + if (pemitter != nullptr) { // Add the emitter to the scene pemitter->Set_Transform (Matrix3D (1)); @@ -678,7 +678,7 @@ CW3DViewDoc::DisplayObject // Remove this object from the scene Remove_Object_From_Scene (m_pCRenderObj); m_pCRenderObj->Release_Ref (); - m_pCRenderObj = NULL; + m_pCRenderObj = nullptr; } } m_pCScene->Clear_Lineup(); @@ -770,7 +770,7 @@ CW3DViewDoc::DisplayObject void CW3DViewDoc::ResetAnimation (void) { - if (m_pCAnimation != NULL) { + if (m_pCAnimation != nullptr) { // // Reset the frame counter @@ -919,18 +919,18 @@ CW3DViewDoc::PlayAnimation void CW3DViewDoc::Play_Animation_Sound (void) { - if (m_pCAnimation != NULL) { + if (m_pCAnimation != nullptr) { CString animation_name = m_pCAnimation->Get_Name (); // // Play a sound with the animation // const char *separator = ::strchr (animation_name , '.'); - if (separator != NULL) { + if (separator != nullptr) { CString sound_filename = separator + 1; sound_filename += ".wav"; - ::PlaySound (NULL, NULL, SND_PURGE); - ::PlaySound (sound_filename, NULL, SND_FILENAME | SND_ASYNC | SND_NODEFAULT); + ::PlaySound (nullptr, nullptr, SND_PURGE); + ::PlaySound (sound_filename, nullptr, SND_FILENAME | SND_ASYNC | SND_NODEFAULT); } } @@ -1020,10 +1020,10 @@ Get_Camera_Transform (RenderObjClass *render_obj, Matrix3D &tm) { bool retval = false; - if (render_obj != NULL) { + if (render_obj != nullptr) { for (int index = 0; (index < render_obj->Get_Num_Sub_Objects ()) && !retval; index ++) { RenderObjClass *psub_obj = render_obj->Get_Sub_Object (index); - if (psub_obj != NULL) { + if (psub_obj != nullptr) { retval = Get_Camera_Transform (psub_obj, tm); } REF_PTR_RELEASE (psub_obj); @@ -1051,7 +1051,7 @@ void CW3DViewDoc::Update_Camera (void) { // Should we update the camera's position as well? - if (m_bAnimateCamera && m_pCRenderObj != NULL) { + if (m_bAnimateCamera && m_pCRenderObj != nullptr) { Matrix3D transform (1); if (Get_Camera_Transform (m_pCRenderObj, transform)) { @@ -1138,7 +1138,7 @@ CW3DViewDoc::UpdateFrame (float relativeTimeSlice) CDataTreeView * CW3DViewDoc::GetDataTreeView (void) { - CDataTreeView *pCDataTreeView = NULL; + CDataTreeView *pCDataTreeView = nullptr; // Get a pointer to the main window CMainFrame *pCMainWnd = (CMainFrame *)::AfxGetMainWnd (); @@ -1161,7 +1161,7 @@ CW3DViewDoc::GetDataTreeView (void) CGraphicView * CW3DViewDoc::GetGraphicView (void) { - CGraphicView *pCGrephicView = NULL; + CGraphicView *pCGrephicView = nullptr; // Get a pointer to the main window CMainFrame *pCMainWnd = (CMainFrame *)::AfxGetMainWnd (); @@ -1189,7 +1189,7 @@ CW3DViewDoc::GenerateLOD ) { // Assume failure - HLodPrototypeClass *plod_prototype = NULL; + HLodPrototypeClass *plod_prototype = nullptr; // Get an iterator from the asset manager that we can // use to enumerate the currently loaded assets @@ -1225,8 +1225,8 @@ CW3DViewDoc::GenerateLOD // Create an array of LOD models RenderObjClass **plod_array = new RenderObjClass *[lod_count]; - ASSERT (plod_array != NULL); - if (plod_array != NULL) { + ASSERT (plod_array != nullptr); + if (plod_array != nullptr) { // Loop through all the levels-of-detail and add them to our array int lod_index; @@ -1285,7 +1285,7 @@ CW3DViewDoc::SetBackgroundBMP (LPCTSTR pszBackgroundBMP) // and release its pointer m_pCBackgroundBMP->Remove (); m_pCBackgroundBMP->Release_Ref (); - m_pCBackgroundBMP = NULL; + m_pCBackgroundBMP = nullptr; } // Is this a new background BMP? @@ -1324,8 +1324,8 @@ CW3DViewDoc::LoadSettings (LPCTSTR filename) BOOL bReturn = FALSE; // Params OK? - ASSERT (filename != NULL); - if (filename != NULL) { + ASSERT (filename != nullptr); + if (filename != nullptr) { // Open the INI file FileClass * pini_file = _TheFileFactory->Get_File (filename); @@ -1505,25 +1505,25 @@ CW3DViewDoc::SaveSettings HANDLE hFile = ::CreateFile (pszFilename, 0, 0, - NULL, + nullptr, OPEN_ALWAYS, 0L, - NULL); + nullptr); - ASSERT (hFile != NULL); - if (hFile == NULL) + ASSERT (hFile != nullptr); + if (hFile == nullptr) { // Invalid file, let the user know ::AfxGetMainWnd ()->MessageBox ("Unable to open file for writing. Please select another filename.", "File Error", MB_ICONERROR | MB_OK); } else if (pszFilename && (dwSettingsMask != 0L) && - (m_pCScene != NULL)) + (m_pCScene != nullptr)) { CString stringCompleteFilename = pszFilename; // Does this filename contain a path? - if (::strrchr (pszFilename, '\\') == NULL) + if (::strrchr (pszFilename, '\\') == nullptr) { // Add the current directories path to the filename TCHAR szPath[MAX_PATH] = { 0 }; @@ -1731,7 +1731,7 @@ CW3DViewDoc::Save_Selected_LOD (void) bool retval = false; // Is this an emitter? - if ((m_pCRenderObj != NULL) && + if ((m_pCRenderObj != nullptr) && m_pCRenderObj->Class_ID () == RenderObjClass::CLASSID_HLOD) { // Build the default filename from the name of the LOD @@ -1771,15 +1771,15 @@ CW3DViewDoc::Save_Current_LOD (const CString &filename) bool retval = false; // Get the prototype for this aggregate - HLodPrototypeClass *proto = NULL; + HLodPrototypeClass *proto = nullptr; proto = (HLodPrototypeClass *)WW3DAssetManager::Get_Instance ()->Find_Prototype (m_pCRenderObj->Get_Name ()); - ASSERT (proto != NULL); - if (proto != NULL) { + ASSERT (proto != nullptr); + if (proto != nullptr) { // Get the definition from the prototype HLodDefClass *pdefinition = proto->Get_Definition (); - ASSERT (pdefinition != NULL); - if (pdefinition != NULL) { + ASSERT (pdefinition != nullptr); + if (pdefinition != nullptr) { // Get a file object for the new file FileClass *pfile = _TheFileFactory->Get_File (filename); @@ -1827,7 +1827,7 @@ CW3DViewDoc::SetBackgroundObject (LPCTSTR pszBackgroundObjectName) // Free the object m_pCBackgroundObject->Release_Ref (); - m_pCBackgroundObject = NULL; + m_pCBackgroundObject = nullptr; } if (pszBackgroundObjectName) @@ -1877,8 +1877,8 @@ CW3DViewDoc::SetBackgroundObject (LPCTSTR pszBackgroundObjectName) void CW3DViewDoc::Remove_Object_From_Scene (RenderObjClass *prender_obj) { - // If the render object is NULL, then remove the current render object - if (prender_obj == NULL) { + // If the render object is null, then remove the current render object + if (prender_obj == nullptr) { prender_obj = m_pCRenderObj; } @@ -1886,14 +1886,14 @@ CW3DViewDoc::Remove_Object_From_Scene (RenderObjClass *prender_obj) //for (int index = 0; index < prender_obj->Get_Num_Sub_Objects (); index ++) { while (prender_obj->Get_Num_Sub_Objects () > 0) { RenderObjClass *psub_obj = prender_obj->Get_Sub_Object (0); - if (psub_obj != NULL) { + if (psub_obj != nullptr) { Remove_Object_From_Scene (psub_obj); } REF_PTR_RELEASE (psub_obj); } // If this is an emitter, then remove its buffer - if ((prender_obj != NULL) && + if ((prender_obj != nullptr) && prender_obj->Class_ID () == RenderObjClass::CLASSID_PARTICLEEMITTER) { // Attempt to remove this emitter's buffer @@ -1903,7 +1903,7 @@ CW3DViewDoc::Remove_Object_From_Scene (RenderObjClass *prender_obj) } // Remove the render object from the scene (if we have a valid scene) - if (m_pCScene != NULL) { + if (m_pCScene != nullptr) { prender_obj->Remove (); } @@ -1923,7 +1923,7 @@ CW3DViewDoc::Save_Selected_Primitive (void) bool retval = false; // Is this an emitter? - if ((m_pCRenderObj != NULL) && + if ((m_pCRenderObj != nullptr) && (m_pCRenderObj->Class_ID () == RenderObjClass::CLASSID_SPHERE || m_pCRenderObj->Class_ID () == RenderObjClass::CLASSID_RING)) { @@ -1975,10 +1975,10 @@ CW3DViewDoc::Save_Current_Sphere (const CString &filename) // // Get the prototype for this object // - SpherePrototypeClass *proto = NULL; + SpherePrototypeClass *proto = nullptr; proto = (SpherePrototypeClass *)WW3DAssetManager::Get_Instance ()->Find_Prototype (m_pCRenderObj->Get_Name ()); - ASSERT (proto != NULL); - if (proto != NULL) { + ASSERT (proto != nullptr); + if (proto != nullptr) { // // Get a file object for the new file @@ -2018,10 +2018,10 @@ CW3DViewDoc::Save_Current_Ring (const CString &filename) // // Get the prototype for this object // - RingPrototypeClass *proto = NULL; + RingPrototypeClass *proto = nullptr; proto = (RingPrototypeClass *)WW3DAssetManager::Get_Instance ()->Find_Prototype (m_pCRenderObj->Get_Name ()); - ASSERT (proto != NULL); - if (proto != NULL) { + ASSERT (proto != nullptr); + if (proto != nullptr) { // // Get a file object for the new file @@ -2059,7 +2059,7 @@ CW3DViewDoc::Save_Selected_Emitter (void) bool retval = false; // Is this an emitter? - if ((m_pCRenderObj != NULL) && + if ((m_pCRenderObj != nullptr) && m_pCRenderObj->Class_ID () == RenderObjClass::CLASSID_PARTICLEEMITTER) { // Build the default filename from the name of the emitter @@ -2098,15 +2098,15 @@ CW3DViewDoc::Save_Current_Emitter (const CString &filename) // Assume failure bool retval = false; // Get the prototype for this aggregate - ParticleEmitterPrototypeClass *proto = NULL; + ParticleEmitterPrototypeClass *proto = nullptr; proto = (ParticleEmitterPrototypeClass *)WW3DAssetManager::Get_Instance ()->Find_Prototype (m_pCRenderObj->Get_Name ()); - ASSERT (proto != NULL); - if (proto != NULL) { + ASSERT (proto != nullptr); + if (proto != nullptr) { // Get the definition from the prototype ParticleEmitterDefClass *pdefinition = proto->Get_Definition (); - ASSERT (pdefinition != NULL); - if (pdefinition != NULL) { + ASSERT (pdefinition != nullptr); + if (pdefinition != nullptr) { // Get a file object for the new file FileClass *pfile = _TheFileFactory->Get_File (filename); @@ -2143,7 +2143,7 @@ CW3DViewDoc::Save_Selected_Sound_Object (void) // // Is this a sound render object? // - if ((m_pCRenderObj != NULL) && + if ((m_pCRenderObj != nullptr) && m_pCRenderObj->Class_ID () == RenderObjClass::CLASSID_SOUND) { // @@ -2189,18 +2189,18 @@ CW3DViewDoc::Save_Current_Sound_Object (const CString &filename) // // Get the prototype for this sound object // - SoundRenderObjPrototypeClass *proto = NULL; + SoundRenderObjPrototypeClass *proto = nullptr; proto = (SoundRenderObjPrototypeClass *)WW3DAssetManager::Get_Instance ()->Find_Prototype (m_pCRenderObj->Get_Name ()); - ASSERT (proto != NULL); - if (proto != NULL) { + ASSERT (proto != nullptr); + if (proto != nullptr) { // // Get the definition from the prototype // SoundRenderObjDefClass *definition = proto->Peek_Definition (); - ASSERT (definition != NULL); - if (definition != NULL) { + ASSERT (definition != nullptr); + if (definition != nullptr) { // // Get a file object for the new file @@ -2240,7 +2240,7 @@ CW3DViewDoc::Save_Current_Sound_Object (const CString &filename) void CW3DViewDoc::Auto_Assign_Bones (void) { - if (m_pCRenderObj != NULL) { + if (m_pCRenderObj != nullptr) { bool bupdate_prototype = false; // Loop through all the bones in this render object @@ -2280,7 +2280,7 @@ CW3DViewDoc::Save_Selected_Aggregate (void) bool retval = false; // Do we have a valid render object? - if (m_pCRenderObj != NULL) { + if (m_pCRenderObj != nullptr) { // Build the default filename from the name of render object CString default_filename = GetDataTreeView ()->GetCurrentSelectionName (); @@ -2318,15 +2318,15 @@ CW3DViewDoc::Save_Current_Aggregate (const CString &filename) // Assume failure bool retval = false; // Get the prototype for this aggregate - AggregatePrototypeClass *proto = NULL; + AggregatePrototypeClass *proto = nullptr; proto = (AggregatePrototypeClass *)WW3DAssetManager::Get_Instance ()->Find_Prototype (m_pCRenderObj->Get_Name ()); - ASSERT (proto != NULL); - if (proto != NULL) { + ASSERT (proto != nullptr); + if (proto != nullptr) { // Get the definition from the prototype AggregateDefClass *pdefinition = proto->Get_Definition (); - ASSERT (pdefinition != NULL); - if (pdefinition != NULL) { + ASSERT (pdefinition != nullptr); + if (pdefinition != nullptr) { // Get a file object for the new file FileClass *pfile = _TheFileFactory->Get_File (filename); @@ -2425,11 +2425,11 @@ CW3DViewDoc::Make_Movie (void) // Get the directory where this executable was run from TCHAR filename[MAX_PATH]; - ::GetModuleFileName (NULL, filename, sizeof (filename)); + ::GetModuleFileName (nullptr, filename, sizeof (filename)); // Strip the filename from the path LPTSTR ppath = ::strrchr (filename, '\\'); - if (ppath != NULL) { + if (ppath != nullptr) { ppath[0] = 0; } ::SetCurrentDirectory (filename); @@ -2522,9 +2522,9 @@ CW3DViewDoc::Build_Emitter_List ) { // - // If the render object is NULL, then start from the current render object + // If the render object is null, then start from the current render object // - if (render_obj == NULL) { + if (render_obj == nullptr) { render_obj = m_pCRenderObj; } @@ -2533,7 +2533,7 @@ CW3DViewDoc::Build_Emitter_List // for (int index = 0; index < render_obj->Get_Num_Sub_Objects (); index ++) { RenderObjClass *psub_obj = render_obj->Get_Sub_Object (index); - if (psub_obj != NULL) { + if (psub_obj != nullptr) { Build_Emitter_List (emitter_list, emitter_name, psub_obj); } REF_PTR_RELEASE (psub_obj); @@ -2542,7 +2542,7 @@ CW3DViewDoc::Build_Emitter_List // // Is this the emitter we are requesting? // - if ((render_obj != NULL) && + if ((render_obj != nullptr) && (render_obj->Class_ID () == RenderObjClass::CLASSID_PARTICLEEMITTER) && (::lstrcmpi (emitter_name, render_obj->Get_Name ()) == 0)) { @@ -2561,7 +2561,7 @@ CW3DViewDoc::Build_Emitter_List void CW3DViewDoc::Show_Cursor (bool onoff) { - if (m_pCursor == NULL) { + if (m_pCursor == nullptr) { Create_Cursor (); } @@ -2578,7 +2578,7 @@ CW3DViewDoc::Show_Cursor (bool onoff) bool CW3DViewDoc::Is_Cursor_Shown (void) const { - return m_pCursor != NULL && m_pCursor->Is_Not_Hidden_At_All (); + return m_pCursor != nullptr && m_pCursor->Is_Not_Hidden_At_All (); } @@ -2603,7 +2603,7 @@ CW3DViewDoc::Set_Cursor (LPCTSTR resource_name) void CW3DViewDoc::Create_Cursor (void) { - if (m_pCursor == NULL) { + if (m_pCursor == nullptr) { m_pCursor = new ScreenCursorClass; m_pCursor->Set_Window (GetGraphicView ()->m_hWnd); m_pCursor->Set_Texture (::Load_RC_Texture ("cursor.tga")); @@ -2624,19 +2624,19 @@ CW3DViewDoc::Count_Particles (RenderObjClass *render_obj) int count = 0; // - // If the render object is NULL, then start from the current render object + // If the render object is null, then start from the current render object // - if (render_obj == NULL) { + if (render_obj == nullptr) { render_obj = m_pCRenderObj; } // // Recursively walk through the subobjects // - if (render_obj != NULL) { + if (render_obj != nullptr) { for (int index = 0; index < render_obj->Get_Num_Sub_Objects (); index ++) { RenderObjClass *psub_obj = render_obj->Get_Sub_Object (index); - if (psub_obj != NULL) { + if (psub_obj != nullptr) { count += Count_Particles (psub_obj); } REF_PTR_RELEASE (psub_obj); @@ -2651,7 +2651,7 @@ CW3DViewDoc::Count_Particles (RenderObjClass *render_obj) // ParticleEmitterClass *emitter = static_cast (render_obj); ParticleBufferClass *buffer = emitter->Peek_Buffer (); - if (buffer != NULL) { + if (buffer != nullptr) { count += buffer->Get_Particle_Count (); } } @@ -2684,19 +2684,19 @@ void CW3DViewDoc::Switch_LOD (int increment, RenderObjClass *render_obj) { // - // If the render object is NULL, then start from the current render object + // If the render object is null, then start from the current render object // - if (render_obj == NULL) { + if (render_obj == nullptr) { render_obj = m_pCRenderObj; } // // Recursively walk through the subobjects // - if (render_obj != NULL) { + if (render_obj != nullptr) { for (int index = 0; index < render_obj->Get_Num_Sub_Objects (); index ++) { RenderObjClass *psub_obj = render_obj->Get_Sub_Object (index); - if (psub_obj != NULL) { + if (psub_obj != nullptr) { Switch_LOD (increment, psub_obj); } REF_PTR_RELEASE (psub_obj); @@ -2724,13 +2724,13 @@ void CW3DViewDoc::Toggle_Alternate_Materials(RenderObjClass * render_obj) { // - // If the render object is NULL, start from the current render object + // If the render object is null, start from the current render object // - if (render_obj == NULL) { + if (render_obj == nullptr) { render_obj = m_pCRenderObj; } - if (render_obj != NULL) { + if (render_obj != nullptr) { // // If this is a mesh, toggle the materials @@ -2793,7 +2793,7 @@ void CW3DViewDoc::Copy_Assets_To_Dir (LPCTSTR directory) { CDataTreeView *data_tree = GetDataTreeView (); - SANITY_CHECK ((m_pCRenderObj != NULL && data_tree != NULL)) { + SANITY_CHECK ((m_pCRenderObj != nullptr && data_tree != nullptr)) { return ; } @@ -2986,9 +2986,9 @@ CW3DViewDoc::Import_Facial_Animation (const CString &heirarchy_name, const CStri const HTreeClass * CW3DViewDoc::Get_Current_HTree (void) const { - const HTreeClass *htree = NULL; + const HTreeClass *htree = nullptr; - if (m_pCRenderObj != NULL) { + if (m_pCRenderObj != nullptr) { htree = m_pCRenderObj->Get_HTree (); } @@ -3009,7 +3009,7 @@ CW3DViewDoc::Save_Camera_Settings (void) CGraphicView *graphic_view = ::Get_Graphic_View (); CameraClass *camera = graphic_view->GetCamera (); - if (camera != NULL) { + if (camera != nullptr) { double hfov = camera->Get_Horizontal_FOV (); double vfov = camera->Get_Vertical_FOV (); @@ -3049,9 +3049,9 @@ CW3DViewDoc::Load_Camera_Settings (void) m_ManualClipPlanes = (theApp.GetProfileInt ("Config", "UseManualClipPlanes", 0) == TRUE); CGraphicView *graphic_view = GetGraphicView (); - if (graphic_view != NULL) { + if (graphic_view != nullptr) { CameraClass *camera = graphic_view->GetCamera (); - if (camera != NULL) { + if (camera != nullptr) { // // Should we load the FOV settings from the registry? @@ -3080,7 +3080,7 @@ CW3DViewDoc::Load_Camera_Settings (void) camera->Set_Clip_Planes (znear, zfar); - if (m_pCScene != NULL) { + if (m_pCScene != nullptr) { m_pCScene->Set_Fog_Range (znear, zfar); m_pCScene->Recalculate_Fog_Planes(); } @@ -3099,7 +3099,7 @@ CW3DViewDoc::Load_Camera_Settings (void) void CW3DViewDoc::Render_Dazzles (CameraClass * camera) { - if (m_pDazzleLayer != NULL) { + if (m_pDazzleLayer != nullptr) { m_pDazzleLayer->Render(camera); } } diff --git a/Core/Tools/W3DView/W3DViewDoc.h b/Core/Tools/W3DView/W3DViewDoc.h index cab9ffd9b1a..4bbdb92d79d 100644 --- a/Core/Tools/W3DView/W3DViewDoc.h +++ b/Core/Tools/W3DView/W3DViewDoc.h @@ -130,14 +130,14 @@ class CW3DViewDoc : public CDocument bool Is_Initialized (void) { return m_IsInitialized; } void Reload_Displayed_Object (void); - void Display_Emitter (ParticleEmitterClass *pemitter = NULL, bool use_global_reset_flag = true, bool allow_reset = true); - void DisplayObject (RenderObjClass *pCModel = NULL, bool use_global_reset_flag = true, bool allow_reset = true, bool add_ghost = false); + void Display_Emitter (ParticleEmitterClass *pemitter = nullptr, bool use_global_reset_flag = true, bool allow_reset = true); + void DisplayObject (RenderObjClass *pCModel = nullptr, bool use_global_reset_flag = true, bool allow_reset = true, bool add_ghost = false); BOOL SaveSettings (LPCTSTR pszFilename, DWORD dwSettingsMask); BOOL LoadSettings (LPCTSTR pszFileName); CGraphicView * GetGraphicView (void); CDataTreeView * GetDataTreeView (void); - void Build_Emitter_List (EmitterInstanceListClass *emitter_list, LPCTSTR emitter_name, RenderObjClass *render_obj = NULL); + void Build_Emitter_List (EmitterInstanceListClass *emitter_list, LPCTSTR emitter_name, RenderObjClass *render_obj = nullptr); // // Animation methods @@ -145,7 +145,7 @@ class CW3DViewDoc : public CDocument void Make_Movie (void); void ResetAnimation (void); void StepAnimation (int frame_inc = 1); - void PlayAnimation (RenderObjClass *pobj, LPCTSTR panim_name = NULL, bool use_global_reset_flag = true, bool allow_reset = true); + void PlayAnimation (RenderObjClass *pobj, LPCTSTR panim_name = nullptr, bool use_global_reset_flag = true, bool allow_reset = true); void PlayAnimation (RenderObjClass *pobj, HAnimComboClass *pcombo, bool use_global_reset_flag = true, bool allow_reset = true); void UpdateFrame (float time_slice); void SetAnimationBlend (BOOL bBlend) { m_bAnimBlend = bBlend; } @@ -191,7 +191,7 @@ class CW3DViewDoc : public CDocument // // Scene methods // - void Remove_Object_From_Scene (RenderObjClass *prender_obj = NULL); + void Remove_Object_From_Scene (RenderObjClass *prender_obj = nullptr); // // Emitter serialization methods @@ -224,12 +224,12 @@ class CW3DViewDoc : public CDocument // bool Save_Current_LOD (const CString &filename); bool Save_Selected_LOD (void); - void Switch_LOD (int increment = 1, RenderObjClass *render_obj = NULL); + void Switch_LOD (int increment = 1, RenderObjClass *render_obj = nullptr); // // Alternate Material interface. // - void Toggle_Alternate_Materials(RenderObjClass * obj = NULL); + void Toggle_Alternate_Materials(RenderObjClass * obj = nullptr); // // Prototype methods @@ -238,7 +238,7 @@ class CW3DViewDoc : public CDocument void Update_LOD_Prototype (HLodClass &hlod); // - // Cursor managment + // Cursor management // void Show_Cursor (bool onoff); void Set_Cursor (LPCTSTR resource_name); @@ -248,7 +248,7 @@ class CW3DViewDoc : public CDocument // // Particle methods // - int Count_Particles (RenderObjClass *render_obj = NULL); + int Count_Particles (RenderObjClass *render_obj = nullptr); void Update_Particle_Count (void); // @@ -268,7 +268,7 @@ class CW3DViewDoc : public CDocument // void Copy_Assets_To_Dir (LPCTSTR directory); bool Lookup_Path (LPCTSTR asset_name, CString &path); - const char * Get_Last_Path (void) const { return (m_LastPath.IsEmpty () ? NULL : (const char *)m_LastPath); } + const char * Get_Last_Path (void) const { return (m_LastPath.IsEmpty () ? nullptr : (const char *)m_LastPath); } // // Texture search paths diff --git a/Core/Tools/WW3D/max2w3d/AlphaModifier.cpp b/Core/Tools/WW3D/max2w3d/AlphaModifier.cpp index dec1f6681a8..c9e6880c21a 100644 --- a/Core/Tools/WW3D/max2w3d/AlphaModifier.cpp +++ b/Core/Tools/WW3D/max2w3d/AlphaModifier.cpp @@ -67,7 +67,7 @@ void AlphaModifierClass::ModifyObject(TimeValue t, ModContext &mc, ObjectState * int numVert = mesh->getNumVerts(); int i = 0; - float *vdata = NULL; + float *vdata = nullptr; // Get parameters from pblock float sparam = 0.0f; @@ -248,7 +248,7 @@ static ParamBlockDesc2 alpha_param_blk ( //rollout 0, _T("AlphaModifierParams"), 0, &AlphaCD, P_AUTO_CONSTRUCT + P_AUTO_UI, 0, - IDD_ALPHA_MODIFIER, IDS_PARAMETERS, 0, 0, NULL, + IDD_ALPHA_MODIFIER, IDS_PARAMETERS, 0, 0, nullptr, // params @@ -398,7 +398,7 @@ Animatable* AlphaModifierClass::SubAnim(int i) switch (i) { case 0: return pblock; - default: return NULL; + default: return nullptr; } } @@ -418,7 +418,7 @@ RefTargetHandle AlphaModifierClass::GetReference(int i) case 0: return pblock; default: assert(TRUE); - return NULL; + return nullptr; } } diff --git a/Core/Tools/WW3D/max2w3d/AlphaModifier.h b/Core/Tools/WW3D/max2w3d/AlphaModifier.h index e698b0e20e3..775901a3c52 100644 --- a/Core/Tools/WW3D/max2w3d/AlphaModifier.h +++ b/Core/Tools/WW3D/max2w3d/AlphaModifier.h @@ -107,11 +107,11 @@ class AlphaModifierClass : public Modifier // Direct paramblock access int NumParamBlocks() {return 1;} IParamBlock2* GetParamBlock(int i) { return pblock;} - IParamBlock2* GetParamBlockByID(BlockID id) {return (pblock->ID() == id) ? pblock : NULL;} + IParamBlock2* GetParamBlockByID(BlockID id) {return (pblock->ID() == id) ? pblock : nullptr;} int GetParamBlockIndex(int id) {return id;} // Does not use createmouse callbacks - CreateMouseCallBack* GetCreateMouseCallBack() {return NULL;} + CreateMouseCallBack* GetCreateMouseCallBack() {return nullptr;} // Load and unload our UI void BeginEditParams(IObjParam *ip, ULONG flags,Animatable *prev); diff --git a/Core/Tools/WW3D/max2w3d/AppData.cpp b/Core/Tools/WW3D/max2w3d/AppData.cpp index 2290ed6d455..b707b56421d 100644 --- a/Core/Tools/WW3D/max2w3d/AppData.cpp +++ b/Core/Tools/WW3D/max2w3d/AppData.cpp @@ -82,11 +82,11 @@ Value * copy_app_data_cf (Value **arg_list, int count) ** Copy W3DAppData0Struct */ W3DAppData0Struct *app_data_0 = GetW3DAppData0(src_node); - if (app_data_0 != NULL) { + if (app_data_0 != nullptr) { // App Data 0 is now obsolete, not fatal if we don't find one W3DAppData0Struct *copy_data_0 = new W3DAppData0Struct; - if (copy_data_0 == NULL) + if (copy_data_0 == nullptr) throw RuntimeError("Out of memory."); // Copy the app data and give it to the target node. @@ -99,11 +99,11 @@ Value * copy_app_data_cf (Value **arg_list, int count) ** Copy W3DAppData1Struct */ W3DAppData1Struct *app_data_1 = GetW3DAppData1(src_node); - if (app_data_1 == NULL) + if (app_data_1 == nullptr) throw RuntimeError("Unable to retrieve W3DAppData1Struct from object: ", arg_list[1]); W3DAppData1Struct *copy_data_1 = new W3DAppData1Struct; - if (copy_data_1 == NULL) + if (copy_data_1 == nullptr) throw RuntimeError("Out of memory."); // Copy the app data and give it to the target node. @@ -116,11 +116,11 @@ Value * copy_app_data_cf (Value **arg_list, int count) ** Copy W3DAppData2Struct */ W3DAppData2Struct *app_data_2 = GetW3DAppData2(src_node); - if (app_data_2 == NULL) + if (app_data_2 == nullptr) throw RuntimeError("Unable to retrieve W3DAppData1Struct from object: ", arg_list[1]); W3DAppData2Struct *copy_data_2 = new W3DAppData2Struct; - if (copy_data_2 == NULL) + if (copy_data_2 == nullptr) throw RuntimeError("Out of memory."); // Copy the app data and give it to the target node. @@ -132,10 +132,10 @@ Value * copy_app_data_cf (Value **arg_list, int count) ** Copy W3DDazzleAppDataStruct if one is present. */ W3DDazzleAppDataStruct *dazzle_app_data = GetW3DDazzleAppData(src_node); - if (dazzle_app_data != NULL) { + if (dazzle_app_data != nullptr) { W3DDazzleAppDataStruct *copy_dazzle_data = new W3DDazzleAppDataStruct; - if (copy_dazzle_data == NULL) + if (copy_dazzle_data == nullptr) throw RuntimeError("Out of memory."); @@ -170,7 +170,7 @@ Value * set_origin_app_data_cf (Value **arg_list, int count) // Get the node's W3DAppData2Struct, and modify it accordingly. W3DAppData2Struct *data = GetW3DAppData2(origin); - if (data == NULL) + if (data == nullptr) throw RuntimeError("Unable to retrieve W3DAppData0Struct from object: ", arg_list[0]); // Turn off Export Geometry and Export Hierarchy. @@ -196,7 +196,7 @@ Value * get_hierarchy_file_cf (Value **arg_list, int count) check_arg_count("wwGetHierarchyFile", 0, count); // Retrieve the export options from the scene. - W3dExportOptionsStruct *options = NULL; + W3dExportOptionsStruct *options = nullptr; AppDataChunk * appdata = MAXScript_interface->GetScenePointer()->GetAppDataChunk(W3D_EXPORTER_CLASS_ID,SCENE_EXPORT_CLASS_ID,0); if (appdata) options = (W3dExportOptionsStruct*)(appdata->data); diff --git a/Core/Tools/WW3D/max2w3d/ExportAllDlg.cpp b/Core/Tools/WW3D/max2w3d/ExportAllDlg.cpp index 67ed5ccd8c3..7586fd38433 100644 --- a/Core/Tools/WW3D/max2w3d/ExportAllDlg.cpp +++ b/Core/Tools/WW3D/max2w3d/ExportAllDlg.cpp @@ -56,8 +56,8 @@ ExportAllDlg::ExportAllDlg (Interface *max_interface) { m_Directory[0] = '\0'; m_Recursive = TRUE; - m_hWnd = NULL; - assert(max_interface != NULL); + m_hWnd = nullptr; + assert(max_interface != nullptr); m_MaxInterface = max_interface; } @@ -81,7 +81,7 @@ int ExportAllDlg::DoModal (void) BOOL CALLBACK _thunk_dialog_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - static ExportAllDlg *dialog = NULL; + static ExportAllDlg *dialog = nullptr; if (uMsg == WM_INITDIALOG) { @@ -128,7 +128,7 @@ BOOL CALLBACK ExportAllDlg::DialogProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPA if (OnOK() == FALSE) return TRUE; - SetCursor(LoadCursor(NULL, IDC_WAIT)); + SetCursor(LoadCursor(nullptr, IDC_WAIT)); EndDialog(m_hWnd, 1); break; @@ -154,14 +154,14 @@ BOOL CALLBACK ExportAllDlg::DialogProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPA void ExportAllDlg::OnInitDialog (void) { CenterWindow(m_hWnd, m_MaxInterface->GetMAXHWnd()); - SetCursor(LoadCursor(NULL, IDC_ARROW)); + SetCursor(LoadCursor(nullptr, IDC_ARROW)); // Set the check box state. CheckDlgButton(m_hWnd, IDC_RECURSIVE, m_Recursive); // Set the default directory. HWND edit = GetDlgItem(m_hWnd, IDC_DIRECTORY); - assert(edit != NULL); + assert(edit != nullptr); SetWindowText(edit, m_Directory); } @@ -183,7 +183,7 @@ void ExportAllDlg::OnBrowse() if (SHGetPathFromIDList(il, folder_name)) { HWND edit = GetDlgItem(m_hWnd, IDC_DIRECTORY); - assert(edit != NULL); + assert(edit != nullptr); SetWindowText(edit, folder_name); } else @@ -198,7 +198,7 @@ BOOL ExportAllDlg::OnOK (void) // freak on the user. char dir[_MAX_PATH]; HWND edit = GetDlgItem(m_hWnd, IDC_DIRECTORY); - assert(edit != NULL); + assert(edit != nullptr); if (GetWindowText(edit, dir, sizeof(dir)) == 0) { // The edit box is empty, that's not a valid choice. diff --git a/Core/Tools/WW3D/max2w3d/FormClass.cpp b/Core/Tools/WW3D/max2w3d/FormClass.cpp index 28744373f69..84b3b6ff203 100644 --- a/Core/Tools/WW3D/max2w3d/FormClass.cpp +++ b/Core/Tools/WW3D/max2w3d/FormClass.cpp @@ -147,21 +147,21 @@ FormClass::fnFormProc BOOL FormClass::ExecuteDlgInit(LPCTSTR lpszResourceName) { // find resource handle - LPVOID lpResource = NULL; - HGLOBAL hResource = NULL; - if (lpszResourceName != NULL) + LPVOID lpResource = nullptr; + HGLOBAL hResource = nullptr; + if (lpszResourceName != nullptr) { HINSTANCE hInst = AppInstance; HRSRC hDlgInit = ::FindResource(hInst, lpszResourceName, RT_DLGINIT); - if (hDlgInit != NULL) + if (hDlgInit != nullptr) { // load it hResource = LoadResource(hInst, hDlgInit); - if (hResource == NULL) + if (hResource == nullptr) return FALSE; // lock it lpResource = LockResource(hResource); - assert(lpResource != NULL); + assert(lpResource != nullptr); } } @@ -169,7 +169,7 @@ BOOL FormClass::ExecuteDlgInit(LPCTSTR lpszResourceName) BOOL bResult = ExecuteDlgInit(lpResource); // cleanup - if (lpResource != NULL && hResource != NULL) + if (lpResource != nullptr && hResource != nullptr) { UnlockResource(hResource); FreeResource(hResource); @@ -195,7 +195,7 @@ BOOL FormClass::ExecuteDlgInit(LPCTSTR lpszResourceName) BOOL FormClass::ExecuteDlgInit(LPVOID lpResource) { BOOL bSuccess = TRUE; - if (lpResource != NULL) + if (lpResource != nullptr) { UNALIGNED WORD* lpnRes = (WORD*)lpResource; while (bSuccess && *lpnRes != 0) diff --git a/Core/Tools/WW3D/max2w3d/FormClass.h b/Core/Tools/WW3D/max2w3d/FormClass.h index 9f12c95df34..92ec1019a62 100644 --- a/Core/Tools/WW3D/max2w3d/FormClass.h +++ b/Core/Tools/WW3D/max2w3d/FormClass.h @@ -43,14 +43,14 @@ class FormClass : public ParamDlg { public: FormClass (void) - : m_hWnd (NULL) {} + : m_hWnd (nullptr) {} ~FormClass (void) {} HWND Create_Form (HWND parent_wnd, UINT template_id); void Show (bool show_flag = true) { ::ShowWindow (m_hWnd, show_flag ? SW_SHOW : SW_HIDE); } virtual BOOL Dialog_Proc (HWND dlg_wnd, UINT message, WPARAM wparam, LPARAM lparam) = 0; HWND Get_Hwnd(void) { return m_hWnd; } - virtual void Invalidate(void) { InvalidateRect(m_hWnd,NULL,0); } + virtual void Invalidate(void) { InvalidateRect(m_hWnd,nullptr,0); } protected: diff --git a/Core/Tools/WW3D/max2w3d/GameMtl.cpp b/Core/Tools/WW3D/max2w3d/GameMtl.cpp index 1010d91197f..cc05f0658fd 100644 --- a/Core/Tools/WW3D/max2w3d/GameMtl.cpp +++ b/Core/Tools/WW3D/max2w3d/GameMtl.cpp @@ -216,7 +216,7 @@ class GameMtlPostLoad : public PostLoadCallback */ static ParamBlockDescID MainParameterBlockDesc[] = { - { TYPE_INT, NULL, FALSE, 0 }, // Pass Count + { TYPE_INT, nullptr, FALSE, 0 }, // Pass Count }; @@ -336,366 +336,366 @@ enum // Version 0 (old version) static ParamBlockDescID PassParameterBlockDescVer0[] = { - { TYPE_POINT3, NULL, TRUE, 0 }, // Ambient - { TYPE_POINT3, NULL, TRUE, 1 }, // Diffuse - { TYPE_POINT3, NULL, TRUE, 2 }, // Specular - { TYPE_POINT3, NULL, TRUE, 3 }, // Emissive - { TYPE_FLOAT, NULL, TRUE, 4 }, // Shininess - { TYPE_FLOAT, NULL, TRUE, 5 }, // Opacity - { TYPE_FLOAT, NULL, TRUE, 6 }, // Translucency - { TYPE_INT, NULL, FALSE, 7 }, // Mapping Type - { TYPE_INT, NULL, FALSE, 8 }, // PSX Translucency Type - { TYPE_BOOL, NULL, FALSE, 9 }, // PSX Lighting Flag - - { TYPE_INT, NULL, FALSE, 10}, // Depth Compare - { TYPE_INT, NULL, FALSE, 11}, // Depth Mask - { TYPE_INT, NULL, FALSE, 12}, // Color Mask - { TYPE_INT, NULL, FALSE, 13}, // Dest Blend - { TYPE_INT, NULL, FALSE, 14}, // FogFunc - { TYPE_INT, NULL, FALSE, 15}, // PriGradient - { TYPE_INT, NULL, FALSE, 16}, // SecGradient - { TYPE_INT, NULL, FALSE, 17}, // SrcBlend - { TYPE_INT, NULL, FALSE, 18}, // DetailColorFunc - { TYPE_INT, NULL, FALSE, 19}, // DetailAlphaFunc - { TYPE_INT, NULL, FALSE, 20}, // DitherMask - { TYPE_INT, NULL, FALSE, 21}, // Shade Model - - { TYPE_BOOL, NULL, FALSE, 22}, // Stage0 Texture Enable - { TYPE_BOOL, NULL, FALSE, 23}, // Stage0 Texture Publish - { TYPE_BOOL, NULL, FALSE, 24}, // Stage0 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 25}, // Stage0 Frame Rate - { TYPE_INT, NULL, FALSE, 26}, // Stage0 Frame Count - { TYPE_INT, NULL, FALSE, 27}, // Stage0 Animation Type - - { TYPE_BOOL, NULL, FALSE, 28}, // Stage1 Texture Enable - { TYPE_BOOL, NULL, FALSE, 29}, // Stage1 Texture Publish - { TYPE_BOOL, NULL, FALSE, 30}, // Stage1 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 31}, // Stage1 Frame Rate - { TYPE_INT, NULL, FALSE, 32}, // Stage1 Frame Count - { TYPE_INT, NULL, FALSE, 33}, // Stage1 Animation Type + { TYPE_POINT3, nullptr, TRUE, 0 }, // Ambient + { TYPE_POINT3, nullptr, TRUE, 1 }, // Diffuse + { TYPE_POINT3, nullptr, TRUE, 2 }, // Specular + { TYPE_POINT3, nullptr, TRUE, 3 }, // Emissive + { TYPE_FLOAT, nullptr, TRUE, 4 }, // Shininess + { TYPE_FLOAT, nullptr, TRUE, 5 }, // Opacity + { TYPE_FLOAT, nullptr, TRUE, 6 }, // Translucency + { TYPE_INT, nullptr, FALSE, 7 }, // Mapping Type + { TYPE_INT, nullptr, FALSE, 8 }, // PSX Translucency Type + { TYPE_BOOL, nullptr, FALSE, 9 }, // PSX Lighting Flag + + { TYPE_INT, nullptr, FALSE, 10}, // Depth Compare + { TYPE_INT, nullptr, FALSE, 11}, // Depth Mask + { TYPE_INT, nullptr, FALSE, 12}, // Color Mask + { TYPE_INT, nullptr, FALSE, 13}, // Dest Blend + { TYPE_INT, nullptr, FALSE, 14}, // FogFunc + { TYPE_INT, nullptr, FALSE, 15}, // PriGradient + { TYPE_INT, nullptr, FALSE, 16}, // SecGradient + { TYPE_INT, nullptr, FALSE, 17}, // SrcBlend + { TYPE_INT, nullptr, FALSE, 18}, // DetailColorFunc + { TYPE_INT, nullptr, FALSE, 19}, // DetailAlphaFunc + { TYPE_INT, nullptr, FALSE, 20}, // DitherMask + { TYPE_INT, nullptr, FALSE, 21}, // Shade Model + + { TYPE_BOOL, nullptr, FALSE, 22}, // Stage0 Texture Enable + { TYPE_BOOL, nullptr, FALSE, 23}, // Stage0 Texture Publish + { TYPE_BOOL, nullptr, FALSE, 24}, // Stage0 Texture Display (in viewport...) + { TYPE_FLOAT, nullptr, FALSE, 25}, // Stage0 Frame Rate + { TYPE_INT, nullptr, FALSE, 26}, // Stage0 Frame Count + { TYPE_INT, nullptr, FALSE, 27}, // Stage0 Animation Type + + { TYPE_BOOL, nullptr, FALSE, 28}, // Stage1 Texture Enable + { TYPE_BOOL, nullptr, FALSE, 29}, // Stage1 Texture Publish + { TYPE_BOOL, nullptr, FALSE, 30}, // Stage1 Texture Display (in viewport...) + { TYPE_FLOAT, nullptr, FALSE, 31}, // Stage1 Frame Rate + { TYPE_INT, nullptr, FALSE, 32}, // Stage1 Frame Count + { TYPE_INT, nullptr, FALSE, 33}, // Stage1 Animation Type }; // Version 1 static ParamBlockDescID PassParameterBlockDescVer1[] = { - { TYPE_POINT3, NULL, TRUE, 0 }, // Ambient - { TYPE_POINT3, NULL, TRUE, 1 }, // Diffuse - { TYPE_POINT3, NULL, TRUE, 2 }, // Specular - { TYPE_POINT3, NULL, TRUE, 3 }, // Emissive - { TYPE_FLOAT, NULL, TRUE, 4 }, // Shininess - { TYPE_FLOAT, NULL, TRUE, 5 }, // Opacity - { TYPE_FLOAT, NULL, TRUE, 6 }, // Translucency - { TYPE_BOOL, NULL, FALSE, 34}, // Copy specular to diffuse (new to version 1) - { TYPE_INT, NULL, FALSE, 7 }, // Mapping Type - { TYPE_INT, NULL, FALSE, 8 }, // PSX Translucency Type - { TYPE_BOOL, NULL, FALSE, 9 }, // PSX Lighting Flag - - { TYPE_INT, NULL, FALSE, 10}, // Depth Compare - { TYPE_INT, NULL, FALSE, 11}, // Depth Mask - { TYPE_INT, NULL, FALSE, 12}, // Color Mask (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 13}, // Dest Blend - { TYPE_INT, NULL, FALSE, 14}, // FogFunc (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 15}, // PriGradient - { TYPE_INT, NULL, FALSE, 16}, // SecGradient - { TYPE_INT, NULL, FALSE, 17}, // SrcBlend - { TYPE_INT, NULL, FALSE, 18}, // DetailColorFunc - { TYPE_INT, NULL, FALSE, 19}, // DetailAlphaFunc - - { TYPE_BOOL, NULL, FALSE, 22}, // Stage0 Texture Enable - { TYPE_BOOL, NULL, FALSE, 23}, // Stage0 Texture Publish - { TYPE_BOOL, NULL, FALSE, 35}, // Stage0 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 39}, // Stage0 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 24}, // Stage0 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 25}, // Stage0 Frame Rate - { TYPE_INT, NULL, FALSE, 26}, // Stage0 Frame Count - { TYPE_INT, NULL, FALSE, 27}, // Stage0 Animation Type - - { TYPE_BOOL, NULL, FALSE, 28}, // Stage1 Texture Enable - { TYPE_BOOL, NULL, FALSE, 29}, // Stage1 Texture Publish - { TYPE_BOOL, NULL, FALSE, 40}, // Stage1 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 44}, // Stage1 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 30}, // Stage1 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 31}, // Stage1 Frame Rate - { TYPE_INT, NULL, FALSE, 32}, // Stage1 Frame Count - { TYPE_INT, NULL, FALSE, 33}, // Stage1 Animation Type - - { TYPE_BOOL, NULL, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) - - { TYPE_BOOL, NULL, FALSE, 47}, // Alpha Test (new to version 1) - { TYPE_INT, NULL, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) + { TYPE_POINT3, nullptr, TRUE, 0 }, // Ambient + { TYPE_POINT3, nullptr, TRUE, 1 }, // Diffuse + { TYPE_POINT3, nullptr, TRUE, 2 }, // Specular + { TYPE_POINT3, nullptr, TRUE, 3 }, // Emissive + { TYPE_FLOAT, nullptr, TRUE, 4 }, // Shininess + { TYPE_FLOAT, nullptr, TRUE, 5 }, // Opacity + { TYPE_FLOAT, nullptr, TRUE, 6 }, // Translucency + { TYPE_BOOL, nullptr, FALSE, 34}, // Copy specular to diffuse (new to version 1) + { TYPE_INT, nullptr, FALSE, 7 }, // Mapping Type + { TYPE_INT, nullptr, FALSE, 8 }, // PSX Translucency Type + { TYPE_BOOL, nullptr, FALSE, 9 }, // PSX Lighting Flag + + { TYPE_INT, nullptr, FALSE, 10}, // Depth Compare + { TYPE_INT, nullptr, FALSE, 11}, // Depth Mask + { TYPE_INT, nullptr, FALSE, 12}, // Color Mask (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 13}, // Dest Blend + { TYPE_INT, nullptr, FALSE, 14}, // FogFunc (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 15}, // PriGradient + { TYPE_INT, nullptr, FALSE, 16}, // SecGradient + { TYPE_INT, nullptr, FALSE, 17}, // SrcBlend + { TYPE_INT, nullptr, FALSE, 18}, // DetailColorFunc + { TYPE_INT, nullptr, FALSE, 19}, // DetailAlphaFunc + + { TYPE_BOOL, nullptr, FALSE, 22}, // Stage0 Texture Enable + { TYPE_BOOL, nullptr, FALSE, 23}, // Stage0 Texture Publish + { TYPE_BOOL, nullptr, FALSE, 35}, // Stage0 Texture Resize (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) + { TYPE_INT, nullptr, FALSE, 39}, // Stage0 Texture Hint (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 24}, // Stage0 Texture Display (in viewport...) + { TYPE_FLOAT, nullptr, FALSE, 25}, // Stage0 Frame Rate + { TYPE_INT, nullptr, FALSE, 26}, // Stage0 Frame Count + { TYPE_INT, nullptr, FALSE, 27}, // Stage0 Animation Type + + { TYPE_BOOL, nullptr, FALSE, 28}, // Stage1 Texture Enable + { TYPE_BOOL, nullptr, FALSE, 29}, // Stage1 Texture Publish + { TYPE_BOOL, nullptr, FALSE, 40}, // Stage1 Texture Resize (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) + { TYPE_INT, nullptr, FALSE, 44}, // Stage1 Texture Hint (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 30}, // Stage1 Texture Display (in viewport...) + { TYPE_FLOAT, nullptr, FALSE, 31}, // Stage1 Frame Rate + { TYPE_INT, nullptr, FALSE, 32}, // Stage1 Frame Count + { TYPE_INT, nullptr, FALSE, 33}, // Stage1 Animation Type + + { TYPE_BOOL, nullptr, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) + + { TYPE_BOOL, nullptr, FALSE, 47}, // Alpha Test (new to version 1) + { TYPE_INT, nullptr, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) }; // Version 2 (old version) static ParamBlockDescID PassParameterBlockDescVer2[] = { - { TYPE_POINT3, NULL, TRUE, 0 }, // Ambient - { TYPE_POINT3, NULL, TRUE, 1 }, // Diffuse - { TYPE_POINT3, NULL, TRUE, 2 }, // Specular - { TYPE_POINT3, NULL, TRUE, 3 }, // Emissive - { TYPE_FLOAT, NULL, TRUE, 4 }, // Shininess - { TYPE_FLOAT, NULL, TRUE, 5 }, // Opacity - { TYPE_FLOAT, NULL, TRUE, 6 }, // Translucency - { TYPE_BOOL, NULL, FALSE, 34}, // Copy specular to diffuse (new to version 1) - { TYPE_INT, NULL, FALSE, 7 }, // Mapping Type - { TYPE_INT, NULL, FALSE, 8 }, // PSX Translucency Type - { TYPE_BOOL, NULL, FALSE, 9 }, // PSX Lighting Flag - - { TYPE_INT, NULL, FALSE, 10}, // Depth Compare - { TYPE_INT, NULL, FALSE, 11}, // Depth Mask - { TYPE_INT, NULL, FALSE, 12}, // Color Mask (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 13}, // Dest Blend - { TYPE_INT, NULL, FALSE, 14}, // FogFunc (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 15}, // PriGradient - { TYPE_INT, NULL, FALSE, 16}, // SecGradient - { TYPE_INT, NULL, FALSE, 17}, // SrcBlend - { TYPE_INT, NULL, FALSE, 18}, // DetailColorFunc - { TYPE_INT, NULL, FALSE, 19}, // DetailAlphaFunc - - { TYPE_BOOL, NULL, FALSE, 22}, // Stage0 Texture Enable - { TYPE_BOOL, NULL, FALSE, 23}, // Stage0 Texture Publish - { TYPE_BOOL, NULL, FALSE, 35}, // Stage0 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 39}, // Stage0 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 24}, // Stage0 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 25}, // Stage0 Frame Rate - { TYPE_INT, NULL, FALSE, 26}, // Stage0 Frame Count - { TYPE_INT, NULL, FALSE, 27}, // Stage0 Animation Type - - { TYPE_BOOL, NULL, FALSE, 28}, // Stage1 Texture Enable - { TYPE_BOOL, NULL, FALSE, 29}, // Stage1 Texture Publish - { TYPE_BOOL, NULL, FALSE, 40}, // Stage1 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 44}, // Stage1 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 30}, // Stage1 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 31}, // Stage1 Frame Rate - { TYPE_INT, NULL, FALSE, 32}, // Stage1 Frame Count - { TYPE_INT, NULL, FALSE, 33}, // Stage1 Animation Type - - { TYPE_BOOL, NULL, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) - - { TYPE_BOOL, NULL, FALSE, 47}, // Alpha Test (new to version 1) - { TYPE_INT, NULL, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 49}, // PS2 Shader Param A - { TYPE_INT, NULL, FALSE, 50}, // PS2 Shader Param B - { TYPE_INT, NULL, FALSE, 51}, // PS2 Shader Param C - { TYPE_INT, NULL, FALSE, 52}, // PS2 Shader Param D + { TYPE_POINT3, nullptr, TRUE, 0 }, // Ambient + { TYPE_POINT3, nullptr, TRUE, 1 }, // Diffuse + { TYPE_POINT3, nullptr, TRUE, 2 }, // Specular + { TYPE_POINT3, nullptr, TRUE, 3 }, // Emissive + { TYPE_FLOAT, nullptr, TRUE, 4 }, // Shininess + { TYPE_FLOAT, nullptr, TRUE, 5 }, // Opacity + { TYPE_FLOAT, nullptr, TRUE, 6 }, // Translucency + { TYPE_BOOL, nullptr, FALSE, 34}, // Copy specular to diffuse (new to version 1) + { TYPE_INT, nullptr, FALSE, 7 }, // Mapping Type + { TYPE_INT, nullptr, FALSE, 8 }, // PSX Translucency Type + { TYPE_BOOL, nullptr, FALSE, 9 }, // PSX Lighting Flag + + { TYPE_INT, nullptr, FALSE, 10}, // Depth Compare + { TYPE_INT, nullptr, FALSE, 11}, // Depth Mask + { TYPE_INT, nullptr, FALSE, 12}, // Color Mask (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 13}, // Dest Blend + { TYPE_INT, nullptr, FALSE, 14}, // FogFunc (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 15}, // PriGradient + { TYPE_INT, nullptr, FALSE, 16}, // SecGradient + { TYPE_INT, nullptr, FALSE, 17}, // SrcBlend + { TYPE_INT, nullptr, FALSE, 18}, // DetailColorFunc + { TYPE_INT, nullptr, FALSE, 19}, // DetailAlphaFunc + + { TYPE_BOOL, nullptr, FALSE, 22}, // Stage0 Texture Enable + { TYPE_BOOL, nullptr, FALSE, 23}, // Stage0 Texture Publish + { TYPE_BOOL, nullptr, FALSE, 35}, // Stage0 Texture Resize (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) + { TYPE_INT, nullptr, FALSE, 39}, // Stage0 Texture Hint (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 24}, // Stage0 Texture Display (in viewport...) + { TYPE_FLOAT, nullptr, FALSE, 25}, // Stage0 Frame Rate + { TYPE_INT, nullptr, FALSE, 26}, // Stage0 Frame Count + { TYPE_INT, nullptr, FALSE, 27}, // Stage0 Animation Type + + { TYPE_BOOL, nullptr, FALSE, 28}, // Stage1 Texture Enable + { TYPE_BOOL, nullptr, FALSE, 29}, // Stage1 Texture Publish + { TYPE_BOOL, nullptr, FALSE, 40}, // Stage1 Texture Resize (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) + { TYPE_INT, nullptr, FALSE, 44}, // Stage1 Texture Hint (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 30}, // Stage1 Texture Display (in viewport...) + { TYPE_FLOAT, nullptr, FALSE, 31}, // Stage1 Frame Rate + { TYPE_INT, nullptr, FALSE, 32}, // Stage1 Frame Count + { TYPE_INT, nullptr, FALSE, 33}, // Stage1 Animation Type + + { TYPE_BOOL, nullptr, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) + + { TYPE_BOOL, nullptr, FALSE, 47}, // Alpha Test (new to version 1) + { TYPE_INT, nullptr, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 49}, // PS2 Shader Param A + { TYPE_INT, nullptr, FALSE, 50}, // PS2 Shader Param B + { TYPE_INT, nullptr, FALSE, 51}, // PS2 Shader Param C + { TYPE_INT, nullptr, FALSE, 52}, // PS2 Shader Param D }; // Version 3 (old version) static ParamBlockDescID PassParameterBlockDescVer3[] = { - { TYPE_POINT3, NULL, TRUE, 0 }, // Ambient - { TYPE_POINT3, NULL, TRUE, 1 }, // Diffuse - { TYPE_POINT3, NULL, TRUE, 2 }, // Specular - { TYPE_POINT3, NULL, TRUE, 3 }, // Emissive - { TYPE_FLOAT, NULL, TRUE, 4 }, // Shininess - { TYPE_FLOAT, NULL, TRUE, 5 }, // Opacity - { TYPE_FLOAT, NULL, TRUE, 6 }, // Translucency - { TYPE_BOOL, NULL, FALSE, 34}, // Copy specular to diffuse (new to version 1) - { TYPE_INT, NULL, FALSE, 7 }, // Mapping Type - { TYPE_INT, NULL, FALSE, 8 }, // PSX Translucency Type - { TYPE_BOOL, NULL, FALSE, 9 }, // PSX Lighting Flag - - { TYPE_INT, NULL, FALSE, 10}, // Depth Compare - { TYPE_INT, NULL, FALSE, 11}, // Depth Mask - { TYPE_INT, NULL, FALSE, 12}, // Color Mask (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 13}, // Dest Blend - { TYPE_INT, NULL, FALSE, 14}, // FogFunc (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 15}, // PriGradient - { TYPE_INT, NULL, FALSE, 16}, // SecGradient - { TYPE_INT, NULL, FALSE, 17}, // SrcBlend - { TYPE_INT, NULL, FALSE, 18}, // DetailColorFunc - { TYPE_INT, NULL, FALSE, 19}, // DetailAlphaFunc - - { TYPE_BOOL, NULL, FALSE, 22}, // Stage0 Texture Enable - { TYPE_BOOL, NULL, FALSE, 23}, // Stage0 Texture Publish - { TYPE_BOOL, NULL, FALSE, 35}, // Stage0 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 39}, // Stage0 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 24}, // Stage0 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 25}, // Stage0 Frame Rate - { TYPE_INT, NULL, FALSE, 26}, // Stage0 Frame Count - { TYPE_INT, NULL, FALSE, 27}, // Stage0 Animation Type - - { TYPE_BOOL, NULL, FALSE, 28}, // Stage1 Texture Enable - { TYPE_BOOL, NULL, FALSE, 29}, // Stage1 Texture Publish - { TYPE_BOOL, NULL, FALSE, 40}, // Stage1 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 44}, // Stage1 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 30}, // Stage1 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 31}, // Stage1 Frame Rate - { TYPE_INT, NULL, FALSE, 32}, // Stage1 Frame Count - { TYPE_INT, NULL, FALSE, 33}, // Stage1 Animation Type - - { TYPE_BOOL, NULL, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) - - { TYPE_BOOL, NULL, FALSE, 47}, // Alpha Test (new to version 1) - { TYPE_INT, NULL, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 49}, // PS2 Shader Param A - { TYPE_INT, NULL, FALSE, 50}, // PS2 Shader Param B - { TYPE_INT, NULL, FALSE, 51}, // PS2 Shader Param C - { TYPE_INT, NULL, FALSE, 52}, // PS2 Shader Param D - - { TYPE_INT, NULL, FALSE, 53}, // Stage0 UV Channel - { TYPE_INT, NULL, FALSE, 54}, // Stage1 UV Channel + { TYPE_POINT3, nullptr, TRUE, 0 }, // Ambient + { TYPE_POINT3, nullptr, TRUE, 1 }, // Diffuse + { TYPE_POINT3, nullptr, TRUE, 2 }, // Specular + { TYPE_POINT3, nullptr, TRUE, 3 }, // Emissive + { TYPE_FLOAT, nullptr, TRUE, 4 }, // Shininess + { TYPE_FLOAT, nullptr, TRUE, 5 }, // Opacity + { TYPE_FLOAT, nullptr, TRUE, 6 }, // Translucency + { TYPE_BOOL, nullptr, FALSE, 34}, // Copy specular to diffuse (new to version 1) + { TYPE_INT, nullptr, FALSE, 7 }, // Mapping Type + { TYPE_INT, nullptr, FALSE, 8 }, // PSX Translucency Type + { TYPE_BOOL, nullptr, FALSE, 9 }, // PSX Lighting Flag + + { TYPE_INT, nullptr, FALSE, 10}, // Depth Compare + { TYPE_INT, nullptr, FALSE, 11}, // Depth Mask + { TYPE_INT, nullptr, FALSE, 12}, // Color Mask (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 13}, // Dest Blend + { TYPE_INT, nullptr, FALSE, 14}, // FogFunc (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 15}, // PriGradient + { TYPE_INT, nullptr, FALSE, 16}, // SecGradient + { TYPE_INT, nullptr, FALSE, 17}, // SrcBlend + { TYPE_INT, nullptr, FALSE, 18}, // DetailColorFunc + { TYPE_INT, nullptr, FALSE, 19}, // DetailAlphaFunc + + { TYPE_BOOL, nullptr, FALSE, 22}, // Stage0 Texture Enable + { TYPE_BOOL, nullptr, FALSE, 23}, // Stage0 Texture Publish + { TYPE_BOOL, nullptr, FALSE, 35}, // Stage0 Texture Resize (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) + { TYPE_INT, nullptr, FALSE, 39}, // Stage0 Texture Hint (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 24}, // Stage0 Texture Display (in viewport...) + { TYPE_FLOAT, nullptr, FALSE, 25}, // Stage0 Frame Rate + { TYPE_INT, nullptr, FALSE, 26}, // Stage0 Frame Count + { TYPE_INT, nullptr, FALSE, 27}, // Stage0 Animation Type + + { TYPE_BOOL, nullptr, FALSE, 28}, // Stage1 Texture Enable + { TYPE_BOOL, nullptr, FALSE, 29}, // Stage1 Texture Publish + { TYPE_BOOL, nullptr, FALSE, 40}, // Stage1 Texture Resize (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) + { TYPE_INT, nullptr, FALSE, 44}, // Stage1 Texture Hint (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 30}, // Stage1 Texture Display (in viewport...) + { TYPE_FLOAT, nullptr, FALSE, 31}, // Stage1 Frame Rate + { TYPE_INT, nullptr, FALSE, 32}, // Stage1 Frame Count + { TYPE_INT, nullptr, FALSE, 33}, // Stage1 Animation Type + + { TYPE_BOOL, nullptr, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) + + { TYPE_BOOL, nullptr, FALSE, 47}, // Alpha Test (new to version 1) + { TYPE_INT, nullptr, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 49}, // PS2 Shader Param A + { TYPE_INT, nullptr, FALSE, 50}, // PS2 Shader Param B + { TYPE_INT, nullptr, FALSE, 51}, // PS2 Shader Param C + { TYPE_INT, nullptr, FALSE, 52}, // PS2 Shader Param D + + { TYPE_INT, nullptr, FALSE, 53}, // Stage0 UV Channel + { TYPE_INT, nullptr, FALSE, 54}, // Stage1 UV Channel }; // Version 4 (old version) static ParamBlockDescID PassParameterBlockDescVer4[] = { - { TYPE_POINT3, NULL, TRUE, 0 }, // Ambient - { TYPE_POINT3, NULL, TRUE, 1 }, // Diffuse - { TYPE_POINT3, NULL, TRUE, 2 }, // Specular - { TYPE_POINT3, NULL, TRUE, 3 }, // Emissive - { TYPE_FLOAT, NULL, TRUE, 4 }, // Shininess - { TYPE_FLOAT, NULL, TRUE, 5 }, // Opacity - { TYPE_FLOAT, NULL, TRUE, 6 }, // Translucency - { TYPE_BOOL, NULL, FALSE, 34}, // Copy specular to diffuse (new to version 1) - { TYPE_INT, NULL, FALSE, 7 }, // Stage0 Mapping Type - { TYPE_INT, NULL, FALSE, 8 }, // PSX Translucency Type - { TYPE_BOOL, NULL, FALSE, 9 }, // PSX Lighting Flag - - { TYPE_INT, NULL, FALSE, 10}, // Depth Compare - { TYPE_INT, NULL, FALSE, 11}, // Depth Mask - { TYPE_INT, NULL, FALSE, 12}, // Color Mask (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 13}, // Dest Blend - { TYPE_INT, NULL, FALSE, 14}, // FogFunc (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 15}, // PriGradient - { TYPE_INT, NULL, FALSE, 16}, // SecGradient - { TYPE_INT, NULL, FALSE, 17}, // SrcBlend - { TYPE_INT, NULL, FALSE, 18}, // DetailColorFunc - { TYPE_INT, NULL, FALSE, 19}, // DetailAlphaFunc - - { TYPE_BOOL, NULL, FALSE, 22}, // Stage0 Texture Enable - { TYPE_BOOL, NULL, FALSE, 23}, // Stage0 Texture Publish - { TYPE_BOOL, NULL, FALSE, 35}, // Stage0 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 39}, // Stage0 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 24}, // Stage0 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 25}, // Stage0 Frame Rate - { TYPE_INT, NULL, FALSE, 26}, // Stage0 Frame Count - { TYPE_INT, NULL, FALSE, 27}, // Stage0 Animation Type - - { TYPE_BOOL, NULL, FALSE, 28}, // Stage1 Texture Enable - { TYPE_BOOL, NULL, FALSE, 29}, // Stage1 Texture Publish - { TYPE_BOOL, NULL, FALSE, 40}, // Stage1 Texture Resize (new to version 1) - { TYPE_BOOL, NULL, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 44}, // Stage1 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 30}, // Stage1 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 31}, // Stage1 Frame Rate - { TYPE_INT, NULL, FALSE, 32}, // Stage1 Frame Count - { TYPE_INT, NULL, FALSE, 33}, // Stage1 Animation Type - - { TYPE_BOOL, NULL, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) - - { TYPE_BOOL, NULL, FALSE, 47}, // Alpha Test (new to version 1) - { TYPE_INT, NULL, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 49}, // PS2 Shader Param A - { TYPE_INT, NULL, FALSE, 50}, // PS2 Shader Param B - { TYPE_INT, NULL, FALSE, 51}, // PS2 Shader Param C - { TYPE_INT, NULL, FALSE, 52}, // PS2 Shader Param D - - { TYPE_INT, NULL, FALSE, 53}, // Stage0 UV Channel - { TYPE_INT, NULL, FALSE, 54}, // Stage1 UV Channel - - { TYPE_INT, NULL, FALSE, 9998}, // foo - { TYPE_INT, NULL, FALSE, 9999}, // bar - - { TYPE_INT, NULL, FALSE, 55}, // Stage1 Mapping Type (new to version 4) + { TYPE_POINT3, nullptr, TRUE, 0 }, // Ambient + { TYPE_POINT3, nullptr, TRUE, 1 }, // Diffuse + { TYPE_POINT3, nullptr, TRUE, 2 }, // Specular + { TYPE_POINT3, nullptr, TRUE, 3 }, // Emissive + { TYPE_FLOAT, nullptr, TRUE, 4 }, // Shininess + { TYPE_FLOAT, nullptr, TRUE, 5 }, // Opacity + { TYPE_FLOAT, nullptr, TRUE, 6 }, // Translucency + { TYPE_BOOL, nullptr, FALSE, 34}, // Copy specular to diffuse (new to version 1) + { TYPE_INT, nullptr, FALSE, 7 }, // Stage0 Mapping Type + { TYPE_INT, nullptr, FALSE, 8 }, // PSX Translucency Type + { TYPE_BOOL, nullptr, FALSE, 9 }, // PSX Lighting Flag + + { TYPE_INT, nullptr, FALSE, 10}, // Depth Compare + { TYPE_INT, nullptr, FALSE, 11}, // Depth Mask + { TYPE_INT, nullptr, FALSE, 12}, // Color Mask (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 13}, // Dest Blend + { TYPE_INT, nullptr, FALSE, 14}, // FogFunc (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 15}, // PriGradient + { TYPE_INT, nullptr, FALSE, 16}, // SecGradient + { TYPE_INT, nullptr, FALSE, 17}, // SrcBlend + { TYPE_INT, nullptr, FALSE, 18}, // DetailColorFunc + { TYPE_INT, nullptr, FALSE, 19}, // DetailAlphaFunc + + { TYPE_BOOL, nullptr, FALSE, 22}, // Stage0 Texture Enable + { TYPE_BOOL, nullptr, FALSE, 23}, // Stage0 Texture Publish + { TYPE_BOOL, nullptr, FALSE, 35}, // Stage0 Texture Resize (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) + { TYPE_INT, nullptr, FALSE, 39}, // Stage0 Texture Hint (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 24}, // Stage0 Texture Display (in viewport...) + { TYPE_FLOAT, nullptr, FALSE, 25}, // Stage0 Frame Rate + { TYPE_INT, nullptr, FALSE, 26}, // Stage0 Frame Count + { TYPE_INT, nullptr, FALSE, 27}, // Stage0 Animation Type + + { TYPE_BOOL, nullptr, FALSE, 28}, // Stage1 Texture Enable + { TYPE_BOOL, nullptr, FALSE, 29}, // Stage1 Texture Publish + { TYPE_BOOL, nullptr, FALSE, 40}, // Stage1 Texture Resize (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) + { TYPE_INT, nullptr, FALSE, 44}, // Stage1 Texture Hint (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 30}, // Stage1 Texture Display (in viewport...) + { TYPE_FLOAT, nullptr, FALSE, 31}, // Stage1 Frame Rate + { TYPE_INT, nullptr, FALSE, 32}, // Stage1 Frame Count + { TYPE_INT, nullptr, FALSE, 33}, // Stage1 Animation Type + + { TYPE_BOOL, nullptr, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) + + { TYPE_BOOL, nullptr, FALSE, 47}, // Alpha Test (new to version 1) + { TYPE_INT, nullptr, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 49}, // PS2 Shader Param A + { TYPE_INT, nullptr, FALSE, 50}, // PS2 Shader Param B + { TYPE_INT, nullptr, FALSE, 51}, // PS2 Shader Param C + { TYPE_INT, nullptr, FALSE, 52}, // PS2 Shader Param D + + { TYPE_INT, nullptr, FALSE, 53}, // Stage0 UV Channel + { TYPE_INT, nullptr, FALSE, 54}, // Stage1 UV Channel + + { TYPE_INT, nullptr, FALSE, 9998}, // foo + { TYPE_INT, nullptr, FALSE, 9999}, // bar + + { TYPE_INT, nullptr, FALSE, 55}, // Stage1 Mapping Type (new to version 4) }; // Version 5 (current version) static ParamBlockDescID PassParameterBlockDescVer5[] = { - { TYPE_POINT3, NULL, TRUE, 0 }, // Ambient - { TYPE_POINT3, NULL, TRUE, 1 }, // Diffuse - { TYPE_POINT3, NULL, TRUE, 2 }, // Specular - { TYPE_POINT3, NULL, TRUE, 3 }, // Emissive - { TYPE_FLOAT, NULL, TRUE, 4 }, // Shininess - { TYPE_FLOAT, NULL, TRUE, 5 }, // Opacity - { TYPE_FLOAT, NULL, TRUE, 6 }, // Translucency - { TYPE_BOOL, NULL, FALSE, 34}, // Copy specular to diffuse (new to version 1) - { TYPE_INT, NULL, FALSE, 7 }, // Stage0 Mapping Type - { TYPE_INT, NULL, FALSE, 8 }, // PSX Translucency Type - { TYPE_BOOL, NULL, FALSE, 9 }, // PSX Lighting Flag - - { TYPE_INT, NULL, FALSE, 10}, // Depth Compare - { TYPE_INT, NULL, FALSE, 11}, // Depth Mask - { TYPE_INT, NULL, FALSE, 12}, // Color Mask (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 13}, // Dest Blend - { TYPE_INT, NULL, FALSE, 14}, // FogFunc (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 15}, // PriGradient - { TYPE_INT, NULL, FALSE, 16}, // SecGradient - { TYPE_INT, NULL, FALSE, 17}, // SrcBlend - { TYPE_INT, NULL, FALSE, 18}, // DetailColorFunc - { TYPE_INT, NULL, FALSE, 19}, // DetailAlphaFunc - - { TYPE_BOOL, NULL, FALSE, 22}, // Stage0 Texture Enable - { TYPE_BOOL, NULL, FALSE, 23}, // Stage0 Texture Publish - { TYPE_BOOL, NULL, FALSE, 35}, // Stage0 Texture Resize (new to version 1) OBSOLETE! - { TYPE_BOOL, NULL, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) OBSOLETE! - { TYPE_BOOL, NULL, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 39}, // Stage0 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 24}, // Stage0 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 25}, // Stage0 Frame Rate - { TYPE_INT, NULL, FALSE, 26}, // Stage0 Frame Count - { TYPE_INT, NULL, FALSE, 27}, // Stage0 Animation Type - - { TYPE_BOOL, NULL, FALSE, 28}, // Stage1 Texture Enable - { TYPE_BOOL, NULL, FALSE, 29}, // Stage1 Texture Publish - { TYPE_BOOL, NULL, FALSE, 40}, // Stage1 Texture Resize (new to version 1) OBSOLETE! - { TYPE_BOOL, NULL, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) OBSOLETE! - { TYPE_BOOL, NULL, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) - { TYPE_BOOL, NULL, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) - { TYPE_INT, NULL, FALSE, 44}, // Stage1 Texture Hint (new to version 1) - { TYPE_BOOL, NULL, FALSE, 30}, // Stage1 Texture Display (in viewport...) - { TYPE_FLOAT, NULL, FALSE, 31}, // Stage1 Frame Rate - { TYPE_INT, NULL, FALSE, 32}, // Stage1 Frame Count - { TYPE_INT, NULL, FALSE, 33}, // Stage1 Animation Type - - { TYPE_BOOL, NULL, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) - { TYPE_BOOL, NULL, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) - - { TYPE_BOOL, NULL, FALSE, 47}, // Alpha Test (new to version 1) - { TYPE_INT, NULL, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) - { TYPE_INT, NULL, FALSE, 49}, // PS2 Shader Param A - { TYPE_INT, NULL, FALSE, 50}, // PS2 Shader Param B - { TYPE_INT, NULL, FALSE, 51}, // PS2 Shader Param C - { TYPE_INT, NULL, FALSE, 52}, // PS2 Shader Param D - - { TYPE_INT, NULL, FALSE, 53}, // Stage0 UV Channel - { TYPE_INT, NULL, FALSE, 54}, // Stage1 UV Channel - - { TYPE_INT, NULL, FALSE, 55 }, // Stage1 Mapping Type (new to version 4) - - { TYPE_BOOL, NULL, FALSE, 56 }, // Stage0 no texture reduction (new to version 5) - { TYPE_BOOL, NULL, FALSE, 57 }, // Stage0 no texture reduction (new to version 5) + { TYPE_POINT3, nullptr, TRUE, 0 }, // Ambient + { TYPE_POINT3, nullptr, TRUE, 1 }, // Diffuse + { TYPE_POINT3, nullptr, TRUE, 2 }, // Specular + { TYPE_POINT3, nullptr, TRUE, 3 }, // Emissive + { TYPE_FLOAT, nullptr, TRUE, 4 }, // Shininess + { TYPE_FLOAT, nullptr, TRUE, 5 }, // Opacity + { TYPE_FLOAT, nullptr, TRUE, 6 }, // Translucency + { TYPE_BOOL, nullptr, FALSE, 34}, // Copy specular to diffuse (new to version 1) + { TYPE_INT, nullptr, FALSE, 7 }, // Stage0 Mapping Type + { TYPE_INT, nullptr, FALSE, 8 }, // PSX Translucency Type + { TYPE_BOOL, nullptr, FALSE, 9 }, // PSX Lighting Flag + + { TYPE_INT, nullptr, FALSE, 10}, // Depth Compare + { TYPE_INT, nullptr, FALSE, 11}, // Depth Mask + { TYPE_INT, nullptr, FALSE, 12}, // Color Mask (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 13}, // Dest Blend + { TYPE_INT, nullptr, FALSE, 14}, // FogFunc (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 15}, // PriGradient + { TYPE_INT, nullptr, FALSE, 16}, // SecGradient + { TYPE_INT, nullptr, FALSE, 17}, // SrcBlend + { TYPE_INT, nullptr, FALSE, 18}, // DetailColorFunc + { TYPE_INT, nullptr, FALSE, 19}, // DetailAlphaFunc + + { TYPE_BOOL, nullptr, FALSE, 22}, // Stage0 Texture Enable + { TYPE_BOOL, nullptr, FALSE, 23}, // Stage0 Texture Publish + { TYPE_BOOL, nullptr, FALSE, 35}, // Stage0 Texture Resize (new to version 1) OBSOLETE! + { TYPE_BOOL, nullptr, FALSE, 36}, // Stage0 Texture No Mipmap (new to version 1) OBSOLETE! + { TYPE_BOOL, nullptr, FALSE, 37}, // Stage0 Texture Clamp U (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 38}, // Stage0 Texture Clamp V (new to version 1) + { TYPE_INT, nullptr, FALSE, 39}, // Stage0 Texture Hint (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 24}, // Stage0 Texture Display (in viewport...) + { TYPE_FLOAT, nullptr, FALSE, 25}, // Stage0 Frame Rate + { TYPE_INT, nullptr, FALSE, 26}, // Stage0 Frame Count + { TYPE_INT, nullptr, FALSE, 27}, // Stage0 Animation Type + + { TYPE_BOOL, nullptr, FALSE, 28}, // Stage1 Texture Enable + { TYPE_BOOL, nullptr, FALSE, 29}, // Stage1 Texture Publish + { TYPE_BOOL, nullptr, FALSE, 40}, // Stage1 Texture Resize (new to version 1) OBSOLETE! + { TYPE_BOOL, nullptr, FALSE, 41}, // Stage1 Texture No Mipmap (new to version 1) OBSOLETE! + { TYPE_BOOL, nullptr, FALSE, 42}, // Stage1 Texture Clamp U (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 43}, // Stage1 Texture Clamp V (new to version 1) + { TYPE_INT, nullptr, FALSE, 44}, // Stage1 Texture Hint (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 30}, // Stage1 Texture Display (in viewport...) + { TYPE_FLOAT, nullptr, FALSE, 31}, // Stage1 Frame Rate + { TYPE_INT, nullptr, FALSE, 32}, // Stage1 Frame Count + { TYPE_INT, nullptr, FALSE, 33}, // Stage1 Animation Type + + { TYPE_BOOL, nullptr, FALSE, 45}, // Stage0 Texture Alpha Bitmap (new to version 1) + { TYPE_BOOL, nullptr, FALSE, 46}, // Stage1 Texture Alpha Bitmap (new to version 1) + + { TYPE_BOOL, nullptr, FALSE, 47}, // Alpha Test (new to version 1) + { TYPE_INT, nullptr, FALSE, 48}, // Shader preset (new to version 1) (now obsolete and ignored) + { TYPE_INT, nullptr, FALSE, 49}, // PS2 Shader Param A + { TYPE_INT, nullptr, FALSE, 50}, // PS2 Shader Param B + { TYPE_INT, nullptr, FALSE, 51}, // PS2 Shader Param C + { TYPE_INT, nullptr, FALSE, 52}, // PS2 Shader Param D + + { TYPE_INT, nullptr, FALSE, 53}, // Stage0 UV Channel + { TYPE_INT, nullptr, FALSE, 54}, // Stage1 UV Channel + + { TYPE_INT, nullptr, FALSE, 55 }, // Stage1 Mapping Type (new to version 4) + + { TYPE_BOOL, nullptr, FALSE, 56 }, // Stage0 no texture reduction (new to version 5) + { TYPE_BOOL, nullptr, FALSE, 57 }, // Stage0 no texture reduction (new to version 5) }; // Array of old pass parameter block versions (for backwards compatibility) @@ -738,7 +738,7 @@ Color scale(const Color& a, const Color& b) *=============================================================================================*/ GameMtl::GameMtl(BOOL loading) { - MaterialDialog = NULL; + MaterialDialog = nullptr; SurfaceType = SURFACE_TYPE_DEFAULT; SortLevel = SORT_LEVEL_NONE; @@ -748,23 +748,23 @@ GameMtl::GameMtl(BOOL loading) Flags |= GAMEMTL_PASSCOUNT_ROLLUP_OPEN; Set_Flag(GAMEMTL_CONVERTED_TO_NOLOD,true); - DisplacementMap = NULL; + DisplacementMap = nullptr; DisplacementAmt = 0.0F; - Maps = NULL; - MainParameterBlock = NULL; + Maps = nullptr; + MainParameterBlock = nullptr; for (int pass=0; passReplaceReference(texture_ref_index(pass,stage),Texture[pass][stage]->Clone()); } else { - mnew->ReplaceReference(texture_ref_index(pass,stage),NULL); + mnew->ReplaceReference(texture_ref_index(pass,stage),nullptr); } // Copy mapper arg strings and lengths @@ -1120,7 +1120,7 @@ RefTargetHandle GameMtl::GetReference(int i) } } - return NULL; + return nullptr; } @@ -1178,9 +1178,9 @@ void GameMtl::SetSubTexmap(int i, Texmap * m) int pass,stage; texmap_index_to_pass_stage(i,&pass,&stage); - if (Texture[pass][stage] != NULL) { + if (Texture[pass][stage] != nullptr) { UVGen * uvgen = Texture[pass][stage]->GetTheUVGen(); - if (uvgen != NULL) { + if (uvgen != nullptr) { uvgen->SetMapChannel(Get_Map_Channel(pass,stage)); } } @@ -1249,7 +1249,7 @@ ParamDlg * GameMtl::CreateParamDlg(HWND hwnd_mtl_edit, IMtlParams *imp) void GameMtl::Notify_Changed(void) { NotifyDependents(FOREVER, PART_ALL, REFMSG_CHANGE); - if (MaterialDialog != NULL) { + if (MaterialDialog != nullptr) { MaterialDialog->Update_Display(); } } @@ -1283,7 +1283,7 @@ void GameMtl::Reset() ReplaceReference(pass_ref_index(pass), pblock); for (int stage = 0;stage < W3dMaterialClass::MAX_STAGES; stage++) { - ReplaceReference(texture_ref_index(pass,stage), NULL); + ReplaceReference(texture_ref_index(pass,stage), nullptr); Set_Texture_Enable(pass,stage,false); Set_Texture_Publish(pass,stage,false); @@ -1302,7 +1302,7 @@ void GameMtl::Reset() if (MapperArg[pass][stage]) { delete [] (MapperArg[pass][stage]); - MapperArg[pass][stage] = NULL; + MapperArg[pass][stage] = nullptr; MapperArgLen[pass][stage] = 0; } } @@ -1439,7 +1439,7 @@ IOResult GameMtl::Load(ILoad *iload) int len = 0; unsigned char tmp8; unsigned short tmp16; - char * tmpstring = NULL; + char * tmpstring = nullptr; float tmpfloat; IOResult res; @@ -2227,7 +2227,7 @@ int GameMtl::Compute_PC_Shader_From_PS2_Shader(int pass) } } - // The alpha paramater. + // The alpha parameter. switch(param_value[3]) { case PSS_SRC_ALPHA: @@ -3072,7 +3072,7 @@ void GameMtl::Set_Texture_Display(int pass,int stage,bool val) } else { SetMtlFlag( MTL_TEX_DISPLAY_ENABLED, FALSE ); - SetActiveTexmap(NULL); + SetActiveTexmap(nullptr); NotifyDependents(FOREVER,PART_ALL,REFMSG_CHANGE); } @@ -3176,9 +3176,9 @@ void GameMtl::Set_Map_Channel(int pass,int stage,int val) PassParameterBlock[pass]->SetValue(PB_STAGE1_MAP_CHANNEL, 0, val); } - if (Texture[pass][stage] != NULL) { + if (Texture[pass][stage] != nullptr) { UVGen * uvgen = Texture[pass][stage]->GetTheUVGen(); - if (uvgen != NULL) { + if (uvgen != nullptr) { uvgen->SetMapChannel(val); } } @@ -3204,7 +3204,7 @@ char * GameMtl::Get_Mapping_Arg_Buffer(int pass, int stage, unsigned int len) assert(strlen(MapperArg[pass][stage]) <= MapperArgLen[pass][stage]); strcpy(temp, MapperArg[pass][stage]); delete [] (MapperArg[pass][stage]); - MapperArg[pass][stage] = NULL; + MapperArg[pass][stage] = nullptr; } MapperArg[pass][stage] = temp; @@ -3229,7 +3229,7 @@ void GameMtl::texmap_index_to_pass_stage(int index,int * set_pass,int * set_stag float GameMtl::EvalDisplacement(ShadeContext& sc) { float displacement = 0.0F; - if (DisplacementMap != NULL) { + if (DisplacementMap != nullptr) { displacement = DisplacementMap->EvalMono(sc); displacement = displacement * DisplacementAmt; } @@ -3269,7 +3269,7 @@ void GameMtlPostLoad::proc(ILoad *iload) } } - m->ReplaceReference(GameMtl::REF_MAPS,NULL); + m->ReplaceReference(GameMtl::REF_MAPS,nullptr); } // older material formats did not save the map channel and will default to zero, diff --git a/Core/Tools/WW3D/max2w3d/GameMtlDlg.cpp b/Core/Tools/WW3D/max2w3d/GameMtlDlg.cpp index 67f066ab183..464d1699b3c 100644 --- a/Core/Tools/WW3D/max2w3d/GameMtlDlg.cpp +++ b/Core/Tools/WW3D/max2w3d/GameMtlDlg.cpp @@ -77,13 +77,13 @@ static int _Pass_Index_To_Flag[] = GameMtlDlg::GameMtlDlg(HWND hwMtlEdit, IMtlParams *imp, GameMtl *m) { HwndEdit = hwMtlEdit; - HwndPassCount = NULL; - HwndSurfaceType = NULL; - HwndDisplacementMap = NULL; - HpalOld = NULL; + HwndPassCount = nullptr; + HwndSurfaceType = nullptr; + HwndDisplacementMap = nullptr; + HpalOld = nullptr; for (int i=0; iUnRegisterDlgWnd(HwndSurfaceType); IParams->DeleteRollupPage(HwndSurfaceType); - HwndSurfaceType = NULL; + HwndSurfaceType = nullptr; #ifdef WANT_DISPLACEMENT_MAPS IParams->UnRegisterDlgWnd(HwndDisplacementMap); IParams->DeleteRollupPage(HwndDisplacementMap); - HwndDisplacementMap = NULL; + HwndDisplacementMap = nullptr; #endif //#ifdef WANT_DISPLACEMENT_MAPS IParams->UnRegisterDlgWnd(HwndPassCount); IParams->DeleteRollupPage(HwndPassCount); - HwndPassCount = NULL; + HwndPassCount = nullptr; for (int i=0; iSetParamDlg(NULL); + TheMtl->SetParamDlg(nullptr); } @@ -186,11 +186,11 @@ void GameMtlDlg::SetThing(ReferenceTarget *m) // destroy our old pass dialogs for (pass=0; passGet_Pass_Count();pass++) { delete PassDialog[pass]; - PassDialog[pass] = NULL; + PassDialog[pass] = nullptr; } // install the new material - TheMtl->SetParamDlg(NULL); + TheMtl->SetParamDlg(nullptr); TheMtl = (GameMtl *)m; TheMtl->SetParamDlg(this); @@ -303,13 +303,13 @@ void GameMtlDlg::ActivateDlg(BOOL onoff) *=============================================================================================*/ void GameMtlDlg::Invalidate() { - InvalidateRect(HwndSurfaceType,NULL,0); + InvalidateRect(HwndSurfaceType,nullptr,0); #ifdef WANT_DISPLACEMENT_MAPS - InvalidateRect(HwndDisplacementMap,NULL,0); + InvalidateRect(HwndDisplacementMap,nullptr,0); #endif //WANT_DISPLACEMENT_MAPS - InvalidateRect(HwndPassCount,NULL,0); + InvalidateRect(HwndPassCount,nullptr,0); } BOOL GameMtlDlg::DisplacementMapProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) @@ -327,7 +327,7 @@ BOOL GameMtlDlg::DisplacementMapProc(HWND hDlg, UINT message, WPARAM wParam, LPA SetupIntSpinner(hDlg, IDC_AMOUNT_SPIN, IDC_AMOUNT_EDIT, -999, 999, TheMtl->Get_Displacement_Amount () * 100); Texmap *map = TheMtl->Get_Displacement_Map (); - if (map != NULL) { + if (map != nullptr) { SetDlgItemText (hDlg, IDC_TEXTURE_BUTTON, map->GetFullName ()); } } @@ -496,7 +496,7 @@ static BOOL CALLBACK DisplacementMapDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara theDlg->HwndDisplacementMap = hwndDlg; SetWindowLong(hwndDlg, GWL_USERDATA,lParam); } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { + if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == nullptr) { return FALSE; } } @@ -516,7 +516,7 @@ static BOOL CALLBACK SurfaceTypePanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wPar theDlg->HwndSurfaceType = hwndDlg; SetWindowLong(hwndDlg, GWL_USERDATA,lParam); } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { + if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == nullptr) { return FALSE; } } @@ -536,7 +536,7 @@ static BOOL CALLBACK PassCountPanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam theDlg->HwndPassCount = hwndDlg; SetWindowLong(hwndDlg, GWL_USERDATA,lParam); } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { + if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == nullptr) { return FALSE; } } @@ -572,7 +572,7 @@ void GameMtlDlg::Set_Pass_Count_Dialog(void) for(int i = 0; i < TheMtl->Get_Pass_Count(); i++) { delete PassDialog[i]; - PassDialog[i] = NULL; + PassDialog[i] = nullptr; } TheMtl->Set_Pass_Count(res); diff --git a/Core/Tools/WW3D/max2w3d/GameMtlPassDlg.cpp b/Core/Tools/WW3D/max2w3d/GameMtlPassDlg.cpp index 46db41bc60b..ace80d6fef3 100644 --- a/Core/Tools/WW3D/max2w3d/GameMtlPassDlg.cpp +++ b/Core/Tools/WW3D/max2w3d/GameMtlPassDlg.cpp @@ -87,7 +87,7 @@ static BOOL CALLBACK PassDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l theDlg->HwndPanel = hwndDlg; SetWindowLong(hwndDlg, GWL_USERDATA,lParam); } else { - if ((theDlg = (GameMtlPassDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { + if ((theDlg = (GameMtlPassDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == nullptr) { return FALSE; } } @@ -145,7 +145,7 @@ GameMtlPassDlg::~GameMtlPassDlg() { TheMtl->Set_Flag(_Pass_Index_To_Flag[PassIndex],IParams->IsRollupPanelOpen(HwndPanel)); IParams->DeleteRollupPage(HwndPanel); - SetWindowLong(HwndPanel, GWL_USERDATA, NULL); + SetWindowLong(HwndPanel, GWL_USERDATA, nullptr); } @@ -208,7 +208,7 @@ BOOL GameMtlPassDlg::DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM l // Loop through all the tabs in the property sheet // Get a pointer to this tab SetWindowPos( hwnd, - NULL, + nullptr, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_NOZORDER); @@ -269,7 +269,7 @@ BOOL GameMtlPassDlg::DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM l void GameMtlPassDlg::Invalidate() { Valid = FALSE; - InvalidateRect(HwndPanel,NULL,0); + InvalidateRect(HwndPanel,nullptr,0); } diff --git a/Core/Tools/WW3D/max2w3d/GameMtlTextureDlg.cpp b/Core/Tools/WW3D/max2w3d/GameMtlTextureDlg.cpp index 5137098f49d..d6fadac371d 100644 --- a/Core/Tools/WW3D/max2w3d/GameMtlTextureDlg.cpp +++ b/Core/Tools/WW3D/max2w3d/GameMtlTextureDlg.cpp @@ -75,23 +75,23 @@ GameMtlTextureDlg::GameMtlTextureDlg ) : GameMtlFormClass(imp,mtl,pass) { - Stage0FramesSpin = NULL; - Stage1FramesSpin = NULL; - Stage0RateSpin = NULL; - Stage1RateSpin = NULL; - - Stage0PublishButton = NULL; - Stage1PublishButton = NULL; - Stage0ClampUButton = NULL; - Stage1ClampUButton = NULL; - Stage0ClampVButton = NULL; - Stage1ClampVButton = NULL; - Stage0NoLODButton = NULL; - Stage1NoLODButton = NULL; - Stage0AlphaBitmapButton = NULL; - Stage1AlphaBitmapButton = NULL; - Stage0DisplayButton = NULL; - Stage1DisplayButton = NULL; + Stage0FramesSpin = nullptr; + Stage1FramesSpin = nullptr; + Stage0RateSpin = nullptr; + Stage1RateSpin = nullptr; + + Stage0PublishButton = nullptr; + Stage1PublishButton = nullptr; + Stage0ClampUButton = nullptr; + Stage1ClampUButton = nullptr; + Stage0ClampVButton = nullptr; + Stage1ClampVButton = nullptr; + Stage0NoLODButton = nullptr; + Stage1NoLODButton = nullptr; + Stage0AlphaBitmapButton = nullptr; + Stage1AlphaBitmapButton = nullptr; + Stage0DisplayButton = nullptr; + Stage1DisplayButton = nullptr; if (mtl->Get_Shader_Type() == GameMtl::STE_PC_SHADER) { Create_Form(parent,IDD_GAMEMTL_TEXTURES); @@ -651,7 +651,7 @@ void GameMtlTextureDlg::Update_Texture_Buttons(void) TSTR filename; if (texmap) { - SplitPathFile(texmap->GetFullName(),NULL,&filename); + SplitPathFile(texmap->GetFullName(),nullptr,&filename); SetDlgItemText(m_hWnd, IDC_STAGE0_BUTTON,filename); } else { SetDlgItemText(m_hWnd, IDC_STAGE0_BUTTON,Get_String(IDS_NONE)); @@ -659,7 +659,7 @@ void GameMtlTextureDlg::Update_Texture_Buttons(void) texmap = TheMtl->Get_Texture(PassIndex,1); if (texmap) { - SplitPathFile(texmap->GetFullName(),NULL,&filename); + SplitPathFile(texmap->GetFullName(),nullptr,&filename); SetDlgItemText(m_hWnd, IDC_STAGE1_BUTTON,filename); } else { SetDlgItemText(m_hWnd, IDC_STAGE1_BUTTON,Get_String(IDS_NONE)); diff --git a/Core/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.cpp b/Core/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.cpp index 2cf7923fad9..483b39fe8c0 100644 --- a/Core/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.cpp +++ b/Core/Tools/WW3D/max2w3d/GameMtlVertexMaterialDlg.cpp @@ -67,17 +67,17 @@ GameMtlVertexMaterialDlg::GameMtlVertexMaterialDlg ) : GameMtlFormClass(imp,mtl,pass) { - AmbientSwatch = NULL; - DiffuseSwatch = NULL; - SpecularSwatch = NULL; - EmissiveSwatch = NULL; + AmbientSwatch = nullptr; + DiffuseSwatch = nullptr; + SpecularSwatch = nullptr; + EmissiveSwatch = nullptr; - OpacitySpin = NULL; - TranslucencySpin = NULL; - ShininessSpin = NULL; + OpacitySpin = nullptr; + TranslucencySpin = nullptr; + ShininessSpin = nullptr; for (int i=0; iobj->IsSubClassOf(triObjectClassID)); - MeshDeformModData *mod_data = NULL; - if (mod_context.localData == NULL) { + MeshDeformModData *mod_data = nullptr; + if (mod_context.localData == nullptr) { mod_data = new MeshDeformModData; mod_context.localData = mod_data; } else { @@ -141,7 +141,7 @@ MeshDeformClass::ModifyObject // Record the initial state of the mesh bool lock_sets = false; - if (m_pPanel != NULL) { + if (m_pPanel != nullptr) { lock_sets = (m_pPanel->Are_Sets_Tied () == TRUE); } mod_data->Record_Mesh_State (*tri_obj, m_DeformState, lock_sets); @@ -194,7 +194,7 @@ MeshDeformClass::NotifyRefChanged CreateMouseCallBack * MeshDeformClass::GetCreateMouseCallBack (void) { - return NULL; + return nullptr; } @@ -275,9 +275,9 @@ MeshDeformClass::EndEditParams ) { // Remove our deform rollup - if (m_hRollupWnd != NULL) { + if (m_hRollupWnd != nullptr) { max_interface->DeleteRollupPage (m_hRollupWnd); - m_hRollupWnd = NULL; + m_hRollupWnd = nullptr; } // @@ -297,8 +297,8 @@ MeshDeformClass::EndEditParams SAFE_DELETE (m_ModeSquash); // Release our hold on the max interface pointer - m_MaxInterface = NULL; - m_pPanel = NULL; + m_MaxInterface = nullptr; + m_pPanel = nullptr; return ; } @@ -396,11 +396,11 @@ MeshDeformClass::HitTest // Record all of the hits // for (MeshSubHitRec *hit_record = hitlist.First (); - hit_record != NULL; + hit_record != nullptr; hit_record = hit_record->Next ()) { // rec->index is the index of vertex which was hit! - viewport->LogHit (node, mod_context, hit_record->dist, hit_record->index, NULL); + viewport->LogHit (node, mod_context, hit_record->dist, hit_record->index, nullptr); } // Cleanup @@ -425,7 +425,7 @@ MeshDeformClass::SelectSubComponent ) { // Loop through all the hit records - for (; hit_record != NULL; hit_record = hit_record->Next ()) { + for (; hit_record != nullptr; hit_record = hit_record->Next ()) { // Peek at the vertex selection array for this hit record MeshDeformModData *mod_data = static_cast (hit_record->modContext->localData); @@ -499,7 +499,7 @@ MeshDeformClass::GetSubObjectCenters Matrix3 transform = node->GetObjectTM (time_val); Box3 box; - // Loop through all the selected verticies and create a bounding + // Loop through all the selected vertices and create a bounding // box which we can use to determine the selection center. for (int index = 0; index < mesh->getNumVerts (); index++ ) { if (sel_array[index]) { @@ -529,7 +529,7 @@ MeshDeformClass::ClearSelection (int selLevel) MeshDeformModData *mod_data = static_cast (mod_context_list[i]->localData); - if (mod_data != NULL) { + if (mod_data != nullptr) { mod_data->Peek_Mesh ()->vertSel.ClearAll (); } } @@ -577,7 +577,7 @@ MeshDeformClass::Move // Get the data we've cached for this modifier context MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { + if (mod_data != nullptr) { Mesh *mesh = mod_data->Peek_Mesh (); const Point3 *vertex_array = mod_data->Peek_Orig_Vertex_Array (); Point3 *opstart_array = mod_data->Peek_Vertex_OPStart_Array (); @@ -650,7 +650,7 @@ MeshDeformClass::Scale // Get the data we've cached for this modifier context MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { + if (mod_data != nullptr) { Mesh *mesh = mod_data->Peek_Mesh (); const Point3 *vertex_array = mod_data->Peek_Orig_Vertex_Array (); Point3 *opstart_array = mod_data->Peek_Vertex_OPStart_Array (); @@ -727,7 +727,7 @@ MeshDeformClass::Rotate // Get the data we've cached for this modifier context MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { + if (mod_data != nullptr) { Mesh *mesh = mod_data->Peek_Mesh (); const Point3 *vertex_array = mod_data->Peek_Orig_Vertex_Array (); Point3 *opstart_array = mod_data->Peek_Vertex_OPStart_Array (); @@ -784,7 +784,7 @@ MeshDeformClass::Rotate void MeshDeformClass::TransformStart (TimeValue time_val) { - if (m_MaxInterface != NULL) { + if (m_MaxInterface != nullptr) { m_MaxInterface->LockAxisTripods (TRUE); } @@ -809,7 +809,7 @@ MeshDeformClass::TransformStart (TimeValue time_val) // Get the data we've cached for this modifier context MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { + if (mod_data != nullptr) { Mesh *mesh = mod_data->Peek_Mesh (); Point3 *opstart_array = mod_data->Peek_Vertex_OPStart_Array (); @@ -838,7 +838,7 @@ MeshDeformClass::TransformStart (TimeValue time_val) void MeshDeformClass::TransformFinish (TimeValue time_val) { - if (m_MaxInterface != NULL) { + if (m_MaxInterface != nullptr) { m_MaxInterface->LockAxisTripods (FALSE); } @@ -856,7 +856,7 @@ MeshDeformClass::TransformFinish (TimeValue time_val) void MeshDeformClass::TransformCancel (TimeValue time_val) { - if (m_MaxInterface != NULL) { + if (m_MaxInterface != nullptr) { m_MaxInterface->LockAxisTripods (FALSE); } @@ -874,11 +874,11 @@ MeshDeformClass::TransformCancel (TimeValue time_val) void MeshDeformClass::Set_Deform_State (float state) { - if ((m_MaxInterface != NULL) && (state != m_DeformState)) { + if ((m_MaxInterface != nullptr) && (state != m_DeformState)) { m_DeformState = state; NotifyDependents (FOREVER, PART_GEOM | PART_VERTCOLOR, REFMSG_CHANGE); m_MaxInterface->RedrawViews (m_MaxInterface->GetTime ()); - if (m_pPanel != NULL) { + if (m_pPanel != nullptr) { m_pPanel->Update_Vertex_Color (); } } @@ -895,7 +895,7 @@ MeshDeformClass::Set_Deform_State (float state) void MeshDeformClass::Set_Vertex_Color (const Point3 &color, bool button_up) { - if (m_MaxInterface != NULL) { + if (m_MaxInterface != nullptr) { INodeTab nodes; ModContextList mod_context_list; @@ -913,7 +913,7 @@ MeshDeformClass::Set_Vertex_Color (const Point3 &color, bool button_up) // Get the data we've cached for this modifier context MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { + if (mod_data != nullptr) { Mesh *mesh = mod_data->Peek_Mesh (); // @@ -978,7 +978,7 @@ MeshDeformClass::Get_Vertex_Color (Point3 &color) color.y = 0; color.z = 0; - if (m_MaxInterface != NULL) { + if (m_MaxInterface != nullptr) { INodeTab nodes; ModContextList mod_context_list; @@ -994,7 +994,7 @@ MeshDeformClass::Get_Vertex_Color (Point3 &color) // Get the data we've cached for this modifier context // MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { + if (mod_data != nullptr) { Mesh *mesh = mod_data->Peek_Mesh (); // Only do this if the mesh is using vertex coloring @@ -1043,9 +1043,9 @@ MeshDeformClass::Get_Vertex_Color (Point3 &color) void MeshDeformClass::Update_UI (MeshDeformModData *mod_data) { - assert (mod_data != NULL); + assert (mod_data != nullptr); - if (m_pPanel != NULL) { + if (m_pPanel != nullptr) { Update_Set_Count (); m_CurrentSet = mod_data->Get_Current_Set (); @@ -1070,7 +1070,7 @@ MeshDeformClass::Update_UI (MeshDeformModData *mod_data) void MeshDeformClass::Auto_Apply (bool auto_apply) { - if (m_MaxInterface != NULL) { + if (m_MaxInterface != nullptr) { // Get a list of contexts that we are part of. INodeTab nodes; @@ -1084,7 +1084,7 @@ MeshDeformClass::Auto_Apply (bool auto_apply) // Let the mod context know what it's auto apply state is // MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { + if (mod_data != nullptr) { mod_data->Auto_Apply (auto_apply); } } @@ -1113,7 +1113,7 @@ MeshDeformClass::Set_Max_Deform_Sets (int max) } m_MaxSets = max; - if (m_MaxInterface != NULL) { + if (m_MaxInterface != nullptr) { // Get a list of contexts that we are part of. INodeTab nodes; @@ -1127,7 +1127,7 @@ MeshDeformClass::Set_Max_Deform_Sets (int max) // Let the mod context know the max sets have changed // MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { + if (mod_data != nullptr) { mod_data->Set_Max_Deform_Sets (max); } } @@ -1151,7 +1151,7 @@ void MeshDeformClass::Update_Set_Count (void) { m_MaxSets = 1; - if (m_MaxInterface != NULL) { + if (m_MaxInterface != nullptr) { // Get a list of contexts that we are part of. INodeTab nodes; @@ -1165,7 +1165,7 @@ MeshDeformClass::Update_Set_Count (void) // Get the count of sets for this context // MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if ((mod_data != NULL) && (mod_data->Get_Set_Count () > m_MaxSets)) { + if ((mod_data != nullptr) && (mod_data->Get_Set_Count () > m_MaxSets)) { m_MaxSets = mod_data->Get_Set_Count (); } } @@ -1195,7 +1195,7 @@ MeshDeformClass::Set_Current_Set last_delta.z = 0; m_CurrentSet = index; - if (m_MaxInterface != NULL) { + if (m_MaxInterface != nullptr) { if (update_selection) { ClearSelection (1); } @@ -1212,7 +1212,7 @@ MeshDeformClass::Set_Current_Set // Have the mod context select the verts in its set // MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { + if (mod_data != nullptr) { mod_data->Set_Current_Set (m_CurrentSet); if (update_selection) { mod_data->Select_Set (m_CurrentSet); @@ -1244,7 +1244,7 @@ MeshDeformClass::Set_Current_Set void MeshDeformClass::Update_Current_Set (void) { - if (m_MaxInterface != NULL) { + if (m_MaxInterface != nullptr) { // Get a list of contexts that we are part of. INodeTab nodes; @@ -1259,7 +1259,7 @@ MeshDeformClass::Update_Current_Set (void) // in the current set. // MeshDeformModData *mod_data = static_cast (mod_context_list[index]->localData); - if (mod_data != NULL) { + if (mod_data != nullptr) { //mod_data->Update_Set (m_CurrentSet); } } @@ -1281,7 +1281,7 @@ MeshDeformClass::Update_Current_Set (void) IOResult MeshDeformClass::SaveLocalData (ISave *save_obj, LocalModData *mod_context) { - assert (mod_context != NULL); + assert (mod_context != nullptr); return ((MeshDeformModData *)mod_context)->Save (save_obj); } @@ -1294,7 +1294,7 @@ MeshDeformClass::SaveLocalData (ISave *save_obj, LocalModData *mod_context) IOResult MeshDeformClass::LoadLocalData (ILoad *load_obj, LocalModData **mod_context) { - assert (mod_context != NULL); + assert (mod_context != nullptr); MeshDeformModData *mod_data = new MeshDeformModData; (*mod_context) = mod_data; return mod_data->Load (load_obj); @@ -1323,7 +1323,7 @@ void SkinModifierClass::SelectAll(int selLevel) SkinDataClass * skindata = (SkinDataClass *)mclist[i]->localData; - if (skindata==NULL) continue; + if (skindata==nullptr) continue; ObjectState os = nodes[i]->EvalWorldState(InterfacePtr->GetTime()); TriObject * tobj = Get_Tri_Object(InterfacePtr->GetTime(),os,valid,needsdel); @@ -1377,7 +1377,7 @@ void SkinModifierClass::InvertSelection(int selLevel) SkinDataClass * skindata = (SkinDataClass *)mclist[i]->localData; - if (skindata==NULL) continue; + if (skindata==nullptr) continue; ObjectState os = nodes[i]->EvalWorldState(InterfacePtr->GetTime()); TriObject * tobj = Get_Tri_Object(InterfacePtr->GetTime(),os,valid,needsdel); diff --git a/Core/Tools/WW3D/max2w3d/MeshDeform.h b/Core/Tools/WW3D/max2w3d/MeshDeform.h index 45ea857f2cc..fca09e5b45a 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeform.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeform.h @@ -67,20 +67,20 @@ class MeshDeformClass : public OSModifier // Public constructors/destructors ////////////////////////////////////////////////////////////////////// MeshDeformClass (void) - : m_MaxInterface (NULL), - m_ModeMove (NULL), - m_ModeSelect (NULL), - m_ModeRotate (NULL), - m_ModeUScale (NULL), - m_ModeNUScale (NULL), - m_ModeSquash (NULL), + : m_MaxInterface (nullptr), + m_ModeMove (nullptr), + m_ModeSelect (nullptr), + m_ModeRotate (nullptr), + m_ModeUScale (nullptr), + m_ModeNUScale (nullptr), + m_ModeSquash (nullptr), m_DeformState (1.0F), - m_pPanel (NULL), + m_pPanel (nullptr), m_CurrentSet (0), m_bSetDirty (true), m_VertColorChanging (false), m_MaxSets (0), - m_hRollupWnd (NULL) { SetName ("WW Mesh Deformer"); Set_Max_Deform_Sets (1); } + m_hRollupWnd (nullptr) { SetName ("WW Mesh Deformer"); Set_Max_Deform_Sets (1); } virtual ~MeshDeformClass (void) { } #if defined W3D_MAX4 //defined as in the project (.dsp) @@ -147,7 +147,7 @@ class MeshDeformClass : public OSModifier int SubObjectIndex (HitRecord *hitRec) { return hitRec->hitInfo; } void ClearSelection (int selLevel); - // Transformation managment + // Transformation management void Move (TimeValue time_val, Matrix3 &parent_tm, Matrix3 &tm_axis, Point3 &point, BOOL local_origin); void Rotate (TimeValue time_val, Matrix3 &parent_tm, Matrix3 &tm_axis, Quat &rotation, BOOL local_origin); void Scale (TimeValue time_val, Matrix3 &parent_tm, Matrix3 &tm_axis, Point3 &value, BOOL local_origin); @@ -186,7 +186,7 @@ class MeshDeformClass : public OSModifier NUScaleModBoxCMode * m_ModeNUScale; SquashModBoxCMode * m_ModeSquash; - // Set managment + // Set management bool m_bSetDirty; int m_CurrentSet; int m_MaxSets; diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformData.h b/Core/Tools/WW3D/max2w3d/MeshDeformData.h index 7e7170fe537..99c6e7745a0 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformData.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeformData.h @@ -87,7 +87,7 @@ class MeshDeformModData : public LocalModData void Set_Vertex_Position (int index, const Point3 &value) { m_SetsList[m_CurrentSet]->Set_Vertex_Position (index, value); } void Set_Vertex_Color (int index, int color_index, const VertColor &value) { m_SetsList[m_CurrentSet]->Set_Vertex_Color (index, color_index, value); } - // Set managment + // Set management void Set_Max_Deform_Sets (int max); void Set_Current_Set (int set_index) { m_CurrentSet = set_index; } int Get_Current_Set (void) const { return m_CurrentSet; } @@ -117,7 +117,7 @@ class MeshDeformModData : public LocalModData // Private member data ////////////////////////////////////////////////////////////////////// - // Set managment + // Set management int m_CurrentSet; SETS_LIST m_SetsList; }; diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformPanel.cpp b/Core/Tools/WW3D/max2w3d/MeshDeformPanel.cpp index e4cb34b7bda..a65c1823767 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformPanel.cpp +++ b/Core/Tools/WW3D/max2w3d/MeshDeformPanel.cpp @@ -82,7 +82,7 @@ MeshDeformPanelClass::Message_Proc } // Pass the message onto the controlling panel-object - if (panel_obj != NULL) { + if (panel_obj != nullptr) { result = panel_obj->On_Message (message, wparam, lparam); } @@ -154,8 +154,8 @@ MeshDeformPanelClass::On_Message // // Ensure the sliders are repainted // - //::InvalidateRect (::GetDlgItem (m_hWnd, IDC_STATE_SLIDER), NULL, TRUE); - //::InvalidateRect (::GetDlgItem (m_hWnd, IDC_CURRENT_SET_SLIDER), NULL, TRUE); + //::InvalidateRect (::GetDlgItem (m_hWnd, IDC_STATE_SLIDER), nullptr, TRUE); + //::InvalidateRect (::GetDlgItem (m_hWnd, IDC_CURRENT_SET_SLIDER), nullptr, TRUE); break; case WM_DESTROY: @@ -163,10 +163,10 @@ MeshDeformPanelClass::On_Message ::ReleaseICustEdit (m_pMaxSetsEdit); ::ReleaseISpinner (m_pMaxSetsSpin); //::ReleaseICustButton (m_pEditButton); - m_pColorSwatch = NULL; - m_pMaxSetsEdit = NULL; - m_pMaxSetsSpin = NULL; - //m_pEditButton = NULL; + m_pColorSwatch = nullptr; + m_pMaxSetsEdit = nullptr; + m_pMaxSetsSpin = nullptr; + //m_pEditButton = nullptr; break; case WM_COMMAND: @@ -285,7 +285,7 @@ MeshDeformPanelClass::Set_Deformer (MeshDeformClass *obj) void MeshDeformPanelClass::Update_Vertex_Color (void) { - if (m_pMeshDeformer != NULL) { + if (m_pMeshDeformer != nullptr) { // Update the color swatch with data from the deformer Point3 color; @@ -315,7 +315,7 @@ MeshDeformPanelClass::Set_Max_Sets if (notify == false) { m_pMaxSetsSpin->SetValue (max, TRUE); - } else if (m_pMeshDeformer != NULL) { + } else if (m_pMeshDeformer != nullptr) { // Update the deformer m_pMeshDeformer->Set_Max_Deform_Sets (max); @@ -342,7 +342,7 @@ MeshDeformPanelClass::Set_Current_Set if (notify == false) { ::SendDlgItemMessage (m_hWnd, IDC_CURRENT_SET_SLIDER, TBM_SETPOS, (WPARAM)TRUE, set + 1); - } else if (m_pMeshDeformer != NULL) { + } else if (m_pMeshDeformer != nullptr) { // Update the deformer m_pMeshDeformer->Set_Current_Set (set, true); diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformPanel.h b/Core/Tools/WW3D/max2w3d/MeshDeformPanel.h index 36322e413da..5b4fff3d268 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformPanel.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeformPanel.h @@ -56,11 +56,11 @@ class MeshDeformPanelClass ////////////////////////////////////////////////////////////////////// MeshDeformPanelClass (HWND hwnd) : m_hWnd (hwnd), - m_pColorSwatch (NULL), - m_pMaxSetsSpin (NULL), - m_pMeshDeformer (NULL), - m_pLockSetsButton (NULL), - m_pMaxSetsEdit (NULL) { } + m_pColorSwatch (nullptr), + m_pMaxSetsSpin (nullptr), + m_pMeshDeformer (nullptr), + m_pLockSetsButton (nullptr), + m_pMaxSetsEdit (nullptr) { } virtual ~MeshDeformPanelClass (void) { } ////////////////////////////////////////////////////////////////////// diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformSave.cpp b/Core/Tools/WW3D/max2w3d/MeshDeformSave.cpp index 20746a95e9a..01b79720faa 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformSave.cpp +++ b/Core/Tools/WW3D/max2w3d/MeshDeformSave.cpp @@ -67,7 +67,7 @@ MeshDeformSaveClass::Initialize // int test = object->SuperClassID (); int test2 = GEN_DERIVOB_CLASS_ID; - if ((object != NULL) && + if ((object != nullptr) && (object->SuperClassID () == GEN_DERIVOB_CLASS_ID)) { // @@ -84,13 +84,13 @@ MeshDeformSaveClass::Initialize // data it contains. // Modifier *modifier = derived_object->GetModifier (index); - if ((modifier != NULL) && (modifier->ClassID () == _MeshDeformClassID)) { + if ((modifier != nullptr) && (modifier->ClassID () == _MeshDeformClassID)) { // // Attempt to get at the modifier data for this context // ModContext *mod_context = derived_object->GetModContext (index); - if ((mod_context != NULL) && (mod_context->localData != NULL)) { + if ((mod_context != nullptr) && (mod_context->localData != nullptr)) { MeshDeformModData *mod_data = static_cast (mod_context->localData); Initialize (builder, mesh, *mod_data, transform); } @@ -277,7 +277,7 @@ MeshDeformSaveClass::Export_Keyframes if (retval) { // - // Loop through all the verticies in this keyframe + // Loop through all the vertices in this keyframe // int data_count = set_save.Get_Deform_Data_Count (keyframe_index); for (int index = 0; (index < data_count) && retval; index ++) { diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformSave.h b/Core/Tools/WW3D/max2w3d/MeshDeformSave.h index e27ff6e08ea..66013ccb3c1 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformSave.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeformSave.h @@ -75,8 +75,8 @@ class MeshDeformSaveClass ////////////////////////////////////////////////////////////////////// // Public methods ////////////////////////////////////////////////////////////////////// - void Initialize (MeshBuilderClass &builder, Object *object, Mesh &mesh, Matrix3 *transform = NULL); - void Initialize (MeshBuilderClass &builder, Mesh &mesh, MeshDeformModData &mod_data, Matrix3 *transform = NULL); + void Initialize (MeshBuilderClass &builder, Object *object, Mesh &mesh, Matrix3 *transform = nullptr); + void Initialize (MeshBuilderClass &builder, Mesh &mesh, MeshDeformModData &mod_data, Matrix3 *transform = nullptr); //void Re_Index (MeshBuilderClass &builder); bool Export (ChunkSaveClass &chunk_save); diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp b/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp index 54f747c9884..0494953b778 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp +++ b/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.cpp @@ -55,7 +55,7 @@ MeshDeformSaveSetClass::Reset (void) } m_DeformData.Delete_All (); - m_CurrentKeyFrame = NULL; + m_CurrentKeyFrame = nullptr; return ; } @@ -90,7 +90,7 @@ MeshDeformSaveSetClass::Begin_Keyframe (float state) void MeshDeformSaveSetClass::End_Keyframe (void) { - m_CurrentKeyFrame = NULL; + m_CurrentKeyFrame = nullptr; return ; } @@ -109,8 +109,8 @@ MeshDeformSaveSetClass::Add_Vert ) { // State OK? - assert (m_CurrentKeyFrame != NULL); - if (m_CurrentKeyFrame != NULL) { + assert (m_CurrentKeyFrame != nullptr); + if (m_CurrentKeyFrame != nullptr) { // // Create a structure that will hold the @@ -144,7 +144,7 @@ MeshDeformSaveSetClass::Replace_Deform_Data ) { KEYFRAME *key_frame = m_DeformData[keyframe_index]; - if (key_frame != NULL) { + if (key_frame != nullptr) { // // Replace the vertex deformation list for the keyframe @@ -171,7 +171,7 @@ MeshDeformSaveSetClass::Get_Deform_Count (void) const int count = 0; for (int index = 0; index < m_DeformData.Count (); index ++) { KEYFRAME *key_frame = m_DeformData[index]; - if (key_frame != NULL) { + if (key_frame != nullptr) { count += key_frame->deform_list.Count (); } } diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.h b/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.h index 13642bc8a07..4e74a9a1348 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeformSaveSet.h @@ -94,18 +94,18 @@ class MeshDeformSaveSetClass ////////////////////////////////////////////////////////////////////// MeshDeformSaveSetClass (void) : m_Flags (0), - m_CurrentKeyFrame (NULL) { } + m_CurrentKeyFrame (nullptr) { } ~MeshDeformSaveSetClass (void) { Reset (); } ////////////////////////////////////////////////////////////////////// // Public methods ////////////////////////////////////////////////////////////////////// - // Keyframe managment + // Keyframe management void Begin_Keyframe (float state); void End_Keyframe (void); - // Vertex managment + // Vertex management void Add_Vert (UINT vert_index, const Point3 &position, const VertColor &color); // Misc diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformSet.cpp b/Core/Tools/WW3D/max2w3d/MeshDeformSet.cpp index 44dc3a5ea2d..66f7017bfc7 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformSet.cpp +++ b/Core/Tools/WW3D/max2w3d/MeshDeformSet.cpp @@ -94,14 +94,14 @@ MeshDeformSetClass::Set_Vertex_Position const Point3 & value ) { - DEFORM_LIST &verticies = m_KeyFrames[m_CurrentKeyFrame]->verticies; + DEFORM_LIST &vertices = m_KeyFrames[m_CurrentKeyFrame]->vertices; BitArray &affected_verts = m_KeyFrames[m_CurrentKeyFrame]->affected_verts; // // Set the vert's position // m_pMesh->verts[index] = value; - verticies.Add (VERT_INFO (index, value)); + vertices.Add (VERT_INFO (index, value)); // // Make sure we remember that this vert is affected @@ -181,7 +181,7 @@ MeshDeformSetClass::Update_Set_Members (void) void MeshDeformSetClass::Collapse_Keyframe_Data (int keyframe) { - DEFORM_LIST &verticies = m_KeyFrames[keyframe]->verticies; + DEFORM_LIST &vertices = m_KeyFrames[keyframe]->vertices; DEFORM_LIST &colors = m_KeyFrames[keyframe]->colors; BitArray &affected_verts = m_KeyFrames[keyframe]->affected_verts; BitArray &affected_colors = m_KeyFrames[keyframe]->affected_colors; @@ -189,15 +189,15 @@ MeshDeformSetClass::Collapse_Keyframe_Data (int keyframe) // // Collapse the vertex position data // - for (int index = 0; index < verticies.Count (); index ++) { - VERT_INFO &info = verticies[index]; + for (int index = 0; index < vertices.Count (); index ++) { + VERT_INFO &info = vertices[index]; // // If this vertex is unchanged, then remove it // from the list. // if (m_pVertexArray[index] == info.value) { - verticies.Delete (index); + vertices.Delete (index); index --; } else { affected_verts.Set (info.index, 1); @@ -217,7 +217,7 @@ MeshDeformSetClass::Collapse_Keyframe_Data (int keyframe) // from the list. // if (m_pVertexColors[index] == info.value) { - verticies.Delete (index); + vertices.Delete (index); index --; } else { affected_colors.Set (info.index, 1); @@ -237,14 +237,14 @@ MeshDeformSetClass::Collapse_Keyframe_Data (int keyframe) void MeshDeformSetClass::Reset_Key_Frame_Verts (int keyframe) { - DEFORM_LIST &verticies = m_KeyFrames[keyframe]->verticies; + DEFORM_LIST &vertices = m_KeyFrames[keyframe]->vertices; BitArray &affected_verts = m_KeyFrames[keyframe]->affected_verts; // // Reset all data for this keyframe // affected_verts.ClearAll (); - verticies.Delete_All (); + vertices.Delete_All (); // // Regenerate the list of set members @@ -287,7 +287,7 @@ MeshDeformSetClass::Reset_Key_Frame_Colors (int keyframe) void MeshDeformSetClass::Update_Current_Data (void) { - DEFORM_LIST &verticies = m_KeyFrames[m_CurrentKeyFrame]->verticies; + DEFORM_LIST &vertices = m_KeyFrames[m_CurrentKeyFrame]->vertices; DEFORM_LIST &colors = m_KeyFrames[m_CurrentKeyFrame]->colors; BitArray &affected_verts = m_KeyFrames[m_CurrentKeyFrame]->affected_verts; BitArray &affected_colors = m_KeyFrames[m_CurrentKeyFrame]->affected_colors; @@ -297,7 +297,7 @@ MeshDeformSetClass::Update_Current_Data (void) // affected_verts.ClearAll (); affected_colors.ClearAll (); - verticies.Delete_All (); + vertices.Delete_All (); colors.Delete_All (); // @@ -319,7 +319,7 @@ MeshDeformSetClass::Update_Current_Data (void) // Record this vertex's position in our lists // affected_verts.Set (index, 1); - verticies.Add (VERT_INFO (index, m_pMesh->verts[index])); + vertices.Add (VERT_INFO (index, m_pMesh->verts[index])); } } @@ -350,7 +350,7 @@ MeshDeformSetClass::Update_Current_Data (void) } // - // Rebuild the list of verticies this 'set' affects + // Rebuild the list of vertices this 'set' affects // Update_Set_Members (); @@ -373,17 +373,17 @@ MeshDeformSetClass::Update_Current_Data (void) void MeshDeformSetClass::Update_Key_Frame (int key_frame) { - DEFORM_LIST &verticies = m_KeyFrames[key_frame]->verticies; + DEFORM_LIST &vertices = m_KeyFrames[key_frame]->vertices; DEFORM_LIST &colors = m_KeyFrames[key_frame]->colors; BitArray &affected_verts = m_KeyFrames[key_frame]->affected_verts; BitArray &affected_colors = m_KeyFrames[key_frame]->affected_colors; if ((key_frame == m_CurrentKeyFrame) || - (verticies.Count () > 0) || + (vertices.Count () > 0) || (colors.Count () > 0)) { // Clear all entries from this keyframe - verticies.Delete_All (); + vertices.Delete_All (); colors.Delete_All (); // @@ -391,7 +391,7 @@ MeshDeformSetClass::Update_Key_Frame (int key_frame) // for (int vert = 0; vert < m_pMesh->numVerts; vert ++) { if (affected_verts[vert]) { - verticies.Add (VERT_INFO (vert, m_pMesh->verts[vert])); + vertices.Add (VERT_INFO (vert, m_pMesh->verts[vert])); } } @@ -504,7 +504,7 @@ MeshDeformSetClass::Resize_Vertex_Array (int count, int color_count) { if (count != m_VertexCount) { - // Allocate a new array of verticies + // Allocate a new array of vertices Point3 *vertex_array = new Point3[count]; Point3 *opstart_array = new Point3[count]; @@ -588,7 +588,7 @@ MeshDeformSetClass::Determine_Interpolation_Indicies // Determine where we should start interpolation // for (int index = 0; index <= key_frame; index ++) { - if (position && m_KeyFrames[index]->verticies.Count () > 0) { + if (position && m_KeyFrames[index]->vertices.Count () > 0) { from = index; } else if (!position && m_KeyFrames[index]->colors.Count () > 0) { from = index; @@ -599,7 +599,7 @@ MeshDeformSetClass::Determine_Interpolation_Indicies // Determine where we should end interpolation // for (index = to; index < MAX_DEFORM_KEY_FRAMES; index ++) { - if (position && m_KeyFrames[index]->verticies.Count () > 0) { + if (position && m_KeyFrames[index]->vertices.Count () > 0) { to = index; break; } else if (!position && m_KeyFrames[index]->colors.Count () > 0) { @@ -678,14 +678,14 @@ MeshDeformSetClass::Apply_Position_Changes // Find the vertex value in the 'from' key frame and set the // triangle object's vertex to be this value (we will interplate from it). // - DEFORM_LIST &vert_from = m_KeyFrames[from]->verticies; + DEFORM_LIST &vert_from = m_KeyFrames[from]->vertices; for (int index = 0; index < vert_from.Count (); index ++) { VERT_INFO &info = vert_from[index]; if (info.index == vert) { Point3 new_pos = info.value; // Transform the new position if necessary - if (transform != NULL) { + if (transform != nullptr) { new_pos = new_pos * (*transform); } @@ -700,7 +700,7 @@ MeshDeformSetClass::Apply_Position_Changes // Find the vertex value in the 'to' key frame and interpolate // this value from the triangle object's current vertex value. // - DEFORM_LIST &vert_to = m_KeyFrames[to]->verticies; + DEFORM_LIST &vert_to = m_KeyFrames[to]->vertices; for (int index = 0; index < vert_to.Count (); index ++) { VERT_INFO &info = vert_to[index]; if (info.index == vert) { @@ -708,7 +708,7 @@ MeshDeformSetClass::Apply_Position_Changes Point3 new_pos = info.value; // Transform the new position if necessary - if (transform != NULL) { + if (transform != nullptr) { new_pos = new_pos * (*transform); } @@ -899,7 +899,7 @@ MeshDeformSetClass::Update_Mesh (TriObject &tri_obj) Copy_Vertex_Array (tri_obj.mesh); // Should we update the mesh or copy it? - if (m_pMesh != NULL) { + if (m_pMesh != nullptr) { // // Copy the vertex colors from the triangle object @@ -909,7 +909,7 @@ MeshDeformSetClass::Update_Mesh (TriObject &tri_obj) } // - // Loop through all the verticies and interpolate their + // Loop through all the vertices and interpolate their // positions and colors based on the current 'deformation state'. // for (UINT vert = 0; vert < (UINT)m_pMesh->numVerts; vert ++) { @@ -940,19 +940,19 @@ MeshDeformSetClass::Update_Mesh (TriObject &tri_obj) for (int key_frame = 0; key_frame < m_KeyFrames.Count (); key_frame ++) { // - // Update the verticies + // Update the vertices // int from = 0; int to = 0; float state = 0; Determine_Interpolation_Indicies (key_frame, true, from, to, state); - DEFORM_LIST &vert_to = m_KeyFrames[to]->verticies; + DEFORM_LIST &vert_to = m_KeyFrames[to]->vertices; if (from <= m_CurrentKeyFrame) { if (from >= 0) { - DEFORM_LIST &vert_from = m_KeyFrames[from]->verticies; + DEFORM_LIST &vert_from = m_KeyFrames[from]->vertices; for (int index = 0; index < vert_from.Count (); index ++) { VERT_INFO &info = vert_from[index]; tri_obj.mesh.verts[info.index] = info.value; @@ -1100,7 +1100,7 @@ MeshDeformSetClass::Update_Members (DEFORM_CHANNELS flags) // // Finally, add this vertex to the list of all - // verticies affected by this set. + // vertices affected by this set. // m_SetMembers.Set (vert, 1); } @@ -1249,7 +1249,7 @@ MeshDeformSetClass::Save for (int key_frame = 0; key_frame < key_frames; key_frame ++) { // - // Loop through all the verticies and see if this keyframe + // Loop through all the vertices and see if this keyframe // modifies any of them // bool verts_affected = false; @@ -1288,7 +1288,7 @@ MeshDeformSetClass::Save // Get the absolute color of this vertex // VertColor color (1, 1, 1); - if (mesh.vertCol != NULL) { + if (mesh.vertCol != nullptr) { int vert_col_index = w3d_vert.MaxVertColIndex; color = mesh.vertCol[vert_col_index]; Apply_Color_Changes (max_vert_index, vert_col_index, key_frame, color); @@ -1345,7 +1345,7 @@ MeshDeformSetClass::Save (ISave *save_obj) DeformChunkKeyframeInfo keyframe_info = { 0 }; keyframe_info.DeformPercent = state_inc * (index + 1); - keyframe_info.VertexCount = key_frame.verticies.Count (); + keyframe_info.VertexCount = key_frame.vertices.Count (); keyframe_info.ColorCount = key_frame.colors.Count (); // @@ -1356,13 +1356,13 @@ MeshDeformSetClass::Save (ISave *save_obj) //save_obj->EndChunk (); // - // Loop through the verticies and save their position + // Loop through the vertices and save their position // for ( unsigned int pos_index = 0; (pos_index < keyframe_info.VertexCount) && (result == IO_OK); pos_index ++) { - VERT_INFO &deform_data = key_frame.verticies[pos_index]; + VERT_INFO &deform_data = key_frame.vertices[pos_index]; DeformDataChunk data; data.VertexIndex = deform_data.index; @@ -1378,7 +1378,7 @@ MeshDeformSetClass::Save (ISave *save_obj) } // - // Loop through the verticies and save their color + // Loop through the vertices and save their color // for ( unsigned int color_index = 0; (color_index < keyframe_info.ColorCount) && (result == IO_OK); @@ -1485,7 +1485,7 @@ MeshDeformSetClass::Load (ILoad *load_obj) DeformDataChunk data; result = load_obj->Read (&data, sizeof (data), &bytes); if (result == IO_OK) { - key_frame.verticies.Add (VERT_INFO (data.VertexIndex, data.Value, data.ColorIndex)); + key_frame.vertices.Add (VERT_INFO (data.VertexIndex, data.Value, data.ColorIndex)); key_frame.affected_verts.Set (data.VertexIndex, 1); m_SetMembers.Set (data.VertexIndex, 1); } diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformSet.h b/Core/Tools/WW3D/max2w3d/MeshDeformSet.h index 4451fb290a7..7e5dc5cbbde 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformSet.h +++ b/Core/Tools/WW3D/max2w3d/MeshDeformSet.h @@ -64,10 +64,10 @@ class MeshDeformSetClass // Public constructors/destructors ////////////////////////////////////////////////////////////////////// MeshDeformSetClass (void) - : m_pMesh (NULL), - m_pVertexArray (NULL), - m_pVertexOPStartArray (NULL), - m_pVertexColors (NULL), + : m_pMesh (nullptr), + m_pVertexArray (nullptr), + m_pVertexOPStartArray (nullptr), + m_pVertexColors (nullptr), m_VertexColorCount (0), m_State (0), m_CurrentKeyFrame (0), @@ -114,16 +114,16 @@ class MeshDeformSetClass // Information bool Is_Empty (void) const; - int Get_Vertex_Count (int keyframe) const { return m_KeyFrames[keyframe]->verticies.Count (); } + int Get_Vertex_Count (int keyframe) const { return m_KeyFrames[keyframe]->vertices.Count (); } int Get_Color_Count (int keyframe) const { return m_KeyFrames[keyframe]->colors.Count (); } - const VERT_INFO & Get_Vertex_Data (int keyframe, int index) const { return m_KeyFrames[keyframe]->verticies[index]; } + const VERT_INFO & Get_Vertex_Data (int keyframe, int index) const { return m_KeyFrames[keyframe]->vertices[index]; } const VERT_INFO & Get_Color_Data (int keyframe, int index) const { return m_KeyFrames[keyframe]->colors[index]; } // Persistent storage IOResult Save (ISave *save_obj); IOResult Load (ILoad *load_obj); - void Save (MeshBuilderClass &builder, Mesh &mesh, MeshDeformSaveSetClass &save_set, Matrix3 *transform = NULL); + void Save (MeshBuilderClass &builder, Mesh &mesh, MeshDeformSaveSetClass &save_set, Matrix3 *transform = nullptr); protected: @@ -139,7 +139,7 @@ class MeshDeformSetClass void Determine_Interpolation_Indicies (int key_frame, bool position, int &from, int &to, float &state); // Deformation application methods - void Apply_Position_Changes (UINT vert, int frame_to_check, Point3 &position, Matrix3 *transform = NULL); + void Apply_Position_Changes (UINT vert, int frame_to_check, Point3 &position, Matrix3 *transform = nullptr); void Apply_Color_Changes (UINT vert, int frame_to_check, Mesh &mesh); void Apply_Color_Changes (UINT vert_index, UINT vert_color_index, int frame_to_check, VertColor &color); @@ -150,7 +150,7 @@ class MeshDeformSetClass ////////////////////////////////////////////////////////////////////// typedef struct { - DEFORM_LIST verticies; + DEFORM_LIST vertices; DEFORM_LIST colors; BitArray affected_verts; BitArray affected_colors; @@ -171,7 +171,7 @@ class MeshDeformSetClass float m_State; bool m_bAutoApply; - // Array representing which verticies are part of the set + // Array representing which vertices are part of the set BitArray m_SetMembers; // List of key frames diff --git a/Core/Tools/WW3D/max2w3d/MeshDeformUndo.cpp b/Core/Tools/WW3D/max2w3d/MeshDeformUndo.cpp index 839072fabd4..394d1972ab2 100644 --- a/Core/Tools/WW3D/max2w3d/MeshDeformUndo.cpp +++ b/Core/Tools/WW3D/max2w3d/MeshDeformUndo.cpp @@ -58,7 +58,7 @@ VertexRestoreClass::VertexRestoreClass m_SetIndex (0), m_KeyframeIndex (0) { - assert (mesh != NULL); + assert (mesh != nullptr); // // Remember the deformer's current settings @@ -91,9 +91,9 @@ VertexRestoreClass::Free_Vertex_Array (void) void VertexRestoreClass::Restore (int is_undo) { - assert (m_pMesh != NULL); - assert (m_pModData != NULL); - assert (m_pModifier != NULL); + assert (m_pMesh != nullptr); + assert (m_pModData != nullptr); + assert (m_pModifier != nullptr); // Is this being called as part of an undo operation? if (is_undo != 0) { @@ -129,9 +129,9 @@ VertexRestoreClass::Restore (int is_undo) void VertexRestoreClass::Redo (void) { - assert (m_pMesh != NULL); - assert (m_pModData != NULL); - assert (m_pModifier != NULL); + assert (m_pMesh != nullptr); + assert (m_pModData != nullptr); + assert (m_pModifier != nullptr); // // Ensure the modifier is in the state it was when diff --git a/Core/Tools/WW3D/max2w3d/PCToPS2Material.cpp b/Core/Tools/WW3D/max2w3d/PCToPS2Material.cpp index c8b225e3ac1..f8fd31c4f2a 100644 --- a/Core/Tools/WW3D/max2w3d/PCToPS2Material.cpp +++ b/Core/Tools/WW3D/max2w3d/PCToPS2Material.cpp @@ -75,7 +75,7 @@ void PCToPS2MaterialClass::BeginEditParams(Interface *ip,IUtil *iu) // Since we don't need any window gadgets, we'll just go through all the materials right away. INode *root = ip->GetRootNode(); - INodeListClass *meshlist = NULL; + INodeListClass *meshlist = nullptr; // Change all materials associated with the mesh, starting with the root node. if (root) { @@ -88,7 +88,7 @@ void PCToPS2MaterialClass::BeginEditParams(Interface *ip,IUtil *iu) Mtl *nodemtl = ((*meshlist)[i])->GetMtl(); - if (nodemtl == NULL) { + if (nodemtl == nullptr) { // No material on this node, go to the next. continue; } diff --git a/Core/Tools/WW3D/max2w3d/SceneSetupDlg.cpp b/Core/Tools/WW3D/max2w3d/SceneSetupDlg.cpp index 89613c12c83..e0d267f4f5d 100644 --- a/Core/Tools/WW3D/max2w3d/SceneSetupDlg.cpp +++ b/Core/Tools/WW3D/max2w3d/SceneSetupDlg.cpp @@ -58,9 +58,9 @@ SceneSetupDlg::SceneSetupDlg(Interface *max_interface) m_LodOffset = -100.0f; m_DamageProc = 3; m_LodProc = 3; - m_hWnd = NULL; + m_hWnd = nullptr; m_MaxInterface = max_interface; - assert(max_interface != NULL); + assert(max_interface != nullptr); } @@ -72,7 +72,7 @@ void SceneSetupDlg::SetEditInt (int control_id, int value) char buf[64]; sprintf(buf, "%d", value); HWND edit = GetDlgItem(m_hWnd, control_id); - assert(edit != NULL); + assert(edit != nullptr); SetWindowText(edit, buf); } @@ -81,7 +81,7 @@ void SceneSetupDlg::SetEditFloat (int control_id, float value) char buf[64]; sprintf(buf, "%.0f", value); HWND edit = GetDlgItem(m_hWnd, control_id); - assert(edit != NULL); + assert(edit != nullptr); SetWindowText(edit, buf); } @@ -89,7 +89,7 @@ int SceneSetupDlg::GetEditInt (int control_id) { char buf[64]; HWND edit = GetDlgItem(m_hWnd, control_id); - assert(edit != NULL); + assert(edit != nullptr); GetWindowText(edit, buf, sizeof(buf)); int value = 0; sscanf(buf, "%d", &value); @@ -100,7 +100,7 @@ float SceneSetupDlg::GetEditFloat (int control_id) { char buf[64]; HWND edit = GetDlgItem(m_hWnd, control_id); - assert(edit != NULL); + assert(edit != nullptr); GetWindowText(edit, buf, sizeof(buf)); float value = 0; sscanf(buf, "%f", &value); @@ -111,7 +111,7 @@ bool SceneSetupDlg::ValidateEditFloat (int control_id) { char buf[64]; HWND edit = GetDlgItem(m_hWnd, control_id); - assert(edit != NULL); + assert(edit != nullptr); GetWindowText(edit, buf, sizeof(buf)); float value = 0; if (sscanf(buf, "%f", &value) == 1) @@ -139,7 +139,7 @@ int SceneSetupDlg::DoModal (void) BOOL CALLBACK _thunk_dialog_proc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - static SceneSetupDlg *dialog = NULL; + static SceneSetupDlg *dialog = nullptr; if (uMsg == WM_INITDIALOG) { @@ -186,7 +186,7 @@ BOOL CALLBACK SceneSetupDlg::DialogProc (HWND hWnd, UINT uMsg, WPARAM wParam, LP if (OnOK() == FALSE) return TRUE; - SetCursor(LoadCursor(NULL, IDC_WAIT)); + SetCursor(LoadCursor(nullptr, IDC_WAIT)); EndDialog(m_hWnd, 1); break; @@ -209,7 +209,7 @@ BOOL CALLBACK SceneSetupDlg::DialogProc (HWND hWnd, UINT uMsg, WPARAM wParam, LP void SceneSetupDlg::OnInitDialog() { CenterWindow(m_hWnd, m_MaxInterface->GetMAXHWnd()); - SetCursor(LoadCursor(NULL, IDC_ARROW)); + SetCursor(LoadCursor(nullptr, IDC_ARROW)); // Select the appropriate radio buttons. switch (m_LodProc) diff --git a/Core/Tools/WW3D/max2w3d/SkinCopy.cpp b/Core/Tools/WW3D/max2w3d/SkinCopy.cpp index 71b95582948..765e7cecab2 100644 --- a/Core/Tools/WW3D/max2w3d/SkinCopy.cpp +++ b/Core/Tools/WW3D/max2w3d/SkinCopy.cpp @@ -138,13 +138,13 @@ Value * copy_skin_info_cf (Value **arg_list, int count) // Get the INode pointers that were passed in. INode *src_node = arg_list[0]->to_node(); INode *dest_node = arg_list[1]->to_node(); - INode *wsm_node = NULL; + INode *wsm_node = nullptr; INode *tree_root = arg_list[3]->to_node(); if (arg_list[2] == &undefined) { // Duplicate the WSM used by src_node. wsm_node = duplicate_wsm(find_skin_wsm(src_node), tree_root); - if (wsm_node == NULL) + if (wsm_node == nullptr) return &undefined; } else @@ -193,7 +193,7 @@ Value * dupe_skin_wsm_cf (Value **arg_list, int count) Value *find_skin_node_in_tree (INode *root) { - if (root == NULL) + if (root == nullptr) return &undefined; // Is this the node we're looking for? @@ -222,7 +222,7 @@ Value *find_skin_node_in_tree (INode *root) * * * INPUT: The skinned object. * * * - * OUTPUT: The skin modifier, or NULL if one doesn't exist. * + * OUTPUT: The skin modifier, or null if one doesn't exist. * * * * WARNINGS: * * * @@ -234,8 +234,8 @@ SkinModifierClass *find_skin_binding (INode *skinned_obj) // WWSkin Binding ties us to a space warp, so search the node's // WSM Derived Object for the WWSkin Binding modifier. IDerivedObject *dobj = skinned_obj->GetWSMDerivedObject(); - if (dobj == NULL) - return NULL; // not bound to a space warp + if (dobj == nullptr) + return nullptr; // not bound to a space warp // Search for the WWSkin Binding modifier on this derived object. for (int i = 0; i < dobj->NumModifiers(); i++) @@ -249,7 +249,7 @@ SkinModifierClass *find_skin_binding (INode *skinned_obj) } // Skin modifier not found. - return NULL; + return nullptr; } @@ -269,12 +269,12 @@ INode *find_skin_wsm (INode *skinned_obj) { // Find the skin modifier on this object. SkinModifierClass *skin_mod = find_skin_binding(skinned_obj); - if (skin_mod == NULL) - return NULL; + if (skin_mod == nullptr) + return nullptr; // Using the skin modifer, find the WSM's INode. INode *wsm = (INode*)( skin_mod->GetReference(SkinModifierClass::NODE_REF) ); - if (wsm == NULL) + if (wsm == nullptr) { char buf[256]; sprintf(buf, "%s has a WWSkin Binding, but I can't find its WWSkin WSM!", @@ -302,12 +302,12 @@ SkinWSMObjectClass *get_skin_wsm_obj (INode *wsm_node) { // We need a valid node. if (!wsm_node) - return NULL; + return nullptr; // The node must reference an object. Object *obj = wsm_node->GetObjectRef(); if (!obj) - return NULL; + return nullptr; // That BASE object must be a SkinWSMObject while (obj) @@ -320,7 +320,7 @@ SkinWSMObjectClass *get_skin_wsm_obj (INode *wsm_node) break; } if (obj->ClassID() != SKIN_OBJ_CLASS_ID) - return NULL; + return nullptr; // Return it. return (SkinWSMObjectClass*)obj; @@ -348,7 +348,7 @@ INode *duplicate_wsm (INode *wsm_node, INode *tree) SkinWSMObjectClass *wsm_obj = get_skin_wsm_obj(wsm_node); if (!wsm_node || !wsm_obj) - return NULL; + return nullptr; /* ** Duplicate the WSM. @@ -357,12 +357,12 @@ INode *duplicate_wsm (INode *wsm_node, INode *tree) SkinWSMObjectClass *new_wsm_obj = (SkinWSMObjectClass*)CreateInstance(WSM_OBJECT_CLASS_ID, SKIN_OBJ_CLASS_ID); if (!new_wsm_obj) - return NULL; + return nullptr; // Create a new node in the scene that points to the new WSM object. INode *new_wsm_node = MAXScript_interface->CreateObjectNode(new_wsm_obj); if (!new_wsm_node) - return NULL; + return nullptr; // Copy the bones from one to the other. for (int i = 0; i < wsm_obj->Num_Bones(); i++) @@ -370,7 +370,7 @@ INode *duplicate_wsm (INode *wsm_node, INode *tree) INode *src_bone = wsm_obj->Get_Bone(i); INode *dst_bone = find_equivalent_node(src_bone, tree); if (!src_bone || !dst_bone) - return NULL; + return nullptr; new_wsm_obj->Add_Bone(dst_bone); } @@ -386,7 +386,7 @@ INode *duplicate_wsm (INode *wsm_node, INode *tree) * INPUT: source - The node to search for an equivalent of. * * tree - The hierarchy to search in. * * * - * OUTPUT: The equivalent node, or NULL if none was found. * + * OUTPUT: The equivalent node, or null if none was found. * * * * WARNINGS: * * * @@ -397,7 +397,7 @@ INode *find_equivalent_node (INode *source, INode *tree, bool name_is_valid) { // We need a valid source and tree. if (!source || !tree) - return NULL; + return nullptr; // The name of the source object. We'll only evaluate this once as an easy optimization. static char src_name[W3D_NAME_LEN]; @@ -416,12 +416,12 @@ INode *find_equivalent_node (INode *source, INode *tree, bool name_is_valid) for (int i = 0; i < tree->NumberOfChildren(); i++) { INode *retval = find_equivalent_node(source, tree->GetChildNode(i), true); - if (retval != NULL) + if (retval != nullptr) return retval; // we found the node in our children } // No equivalent node was found. - return NULL; + return nullptr; } @@ -429,7 +429,7 @@ Value *copy_skin_info (INode *source, INode *target, INode *wsm) { // Get the "WWSkin Binding" modifier on the source object. SkinModifierClass *source_modifier = find_skin_binding(source); - if (source_modifier == NULL) + if (source_modifier == nullptr) return &undefined; // Get the WSMDerivedObject we can add our skin binding modifier to. @@ -437,7 +437,7 @@ Value *copy_skin_info (INode *source, INode *target, INode *wsm) // Create a new skin modifier and copy the source modifier's settings to it. SkinModifierClass *new_modifier = new SkinModifierClass(wsm, get_skin_wsm_obj(wsm)); - if (new_modifier == NULL) + if (new_modifier == nullptr) throw RuntimeError("Out of memory - Unable to allocate a new SkinModifierClass object!"); new_modifier->SubObjSelLevel = source_modifier->SubObjSelLevel; @@ -445,7 +445,7 @@ Value *copy_skin_info (INode *source, INode *target, INode *wsm) ModContext *source_context = find_skin_mod_context(source); ModContext *new_context = new ModContext(source_context->tm, source_context->box, source_context->localData); - if (new_context == NULL) + if (new_context == nullptr) throw RuntimeError("Out of memory - Unable to allocate a new ModContext object!"); // Add a new "WWSkin Binding" modifier to the target object to associate @@ -464,7 +464,7 @@ IDerivedObject *setup_wsm_derived_obj (INode *node) { // Check if the target object is already bound to a space warp. IDerivedObject *dobj = node->GetWSMDerivedObject(); - if (dobj != NULL) + if (dobj != nullptr) { // It's bound to a space warp. Check if WWSkin is one of the // space warp bindings. If so, remove it (we don't want to @@ -485,7 +485,7 @@ IDerivedObject *setup_wsm_derived_obj (INode *node) // This object isn't bound to a space warp. Create a // WSMDerivedObject for the node to play with. dobj = CreateWSDerivedObject(node->GetObjectRef()); - if (dobj == NULL) + if (dobj == nullptr) { char msg[128]; sprintf(msg, "Error setting up the WSMDerivedObject for %s", node->GetName()); @@ -501,14 +501,14 @@ IDerivedObject *setup_wsm_derived_obj (INode *node) ModContext *find_skin_mod_context (INode *node) { // We need a valid node - if (node == NULL) - return NULL; + if (node == nullptr) + return nullptr; // The node needs to be bound to a space warp (ie. must have // a WSMDerivedObject). IDerivedObject *dobj = node->GetWSMDerivedObject(); - if (dobj == NULL) - return NULL; + if (dobj == nullptr) + return nullptr; // It's bound to a space warp. Find the WWSkin modifier. for (int i = 0; i < dobj->NumModifiers(); i++) @@ -522,5 +522,5 @@ ModContext *find_skin_mod_context (INode *node) } // We didn't find a WWSkin binding. - return NULL; + return nullptr; } diff --git a/Core/Tools/WW3D/max2w3d/SnapPoints.cpp b/Core/Tools/WW3D/max2w3d/SnapPoints.cpp index 554cde3073d..7b97aa38e49 100644 --- a/Core/Tools/WW3D/max2w3d/SnapPoints.cpp +++ b/Core/Tools/WW3D/max2w3d/SnapPoints.cpp @@ -53,9 +53,9 @@ class PointFilterClass : public INodeFilterClass virtual BOOL Accept_Node(INode * node, TimeValue time) { - if (node == NULL) return FALSE; + if (node == nullptr) return FALSE; Object * obj = node->EvalWorldState(time).obj; - if (obj == NULL) return FALSE; + if (obj == nullptr) return FALSE; if ( @@ -73,7 +73,7 @@ class PointFilterClass : public INodeFilterClass void SnapPointsClass::Export_Points(INode * scene_root,TimeValue time,ChunkSaveClass & csave) { - if (scene_root == NULL) return; + if (scene_root == nullptr) return; PointFilterClass pointfilter; INodeListClass pointlist(scene_root,time,&pointfilter); diff --git a/Core/Tools/WW3D/max2w3d/TARGA.cpp b/Core/Tools/WW3D/max2w3d/TARGA.cpp index 8b0ffd2e417..dee2857c2e2 100644 --- a/Core/Tools/WW3D/max2w3d/TARGA.cpp +++ b/Core/Tools/WW3D/max2w3d/TARGA.cpp @@ -100,8 +100,8 @@ Targa::Targa(void) { - mImage = NULL; - mPalette = NULL; + mImage = nullptr; + mPalette = nullptr; Clear_File(); mAccess = TGA_READMODE; mFlags = 0; @@ -136,11 +136,11 @@ Targa::~Targa(void) Close(); /* Free the palette buffer if we allocated it. */ - if ((mPalette != NULL) && (mFlags & TGAF_PAL)) + if ((mPalette != nullptr) && (mFlags & TGAF_PAL)) free(mPalette); /* Free the image buffer if we allocated it. */ - if ((mImage != NULL) && (mFlags & TGAF_IMAGE)) + if ((mImage != nullptr) && (mFlags & TGAF_IMAGE)) free(mImage); } @@ -314,7 +314,7 @@ void Targa::Close(void) if (TGAFile) { TGAFile->Close(); _TheFileFactory->Return_File(TGAFile); - TGAFile = NULL; + TGAFile = nullptr; } #else /* Close the file if it is open. */ @@ -338,7 +338,7 @@ void Targa::Close(void) * * FUNCTION * Open and load the Targa into the specified buffers. If either buffer -* pointer is NULL then that field will not be processed. +* pointer is nullptr then that field will not be processed. * * INPUTS * Name - Name of Targa image file to load. @@ -357,7 +357,7 @@ long Targa::Load(const char* name, char* palette, char* image,bool invert_image) long error = 0; /* Open the Targa */ - if (Open(name, TGA_READMODE) == NULL) { + if (Open(name, TGA_READMODE) == nullptr) { /* Process ColorMap (palette) */ if (Header.ColorMapType == 1) { @@ -368,7 +368,7 @@ long Targa::Load(const char* name, char* palette, char* image,bool invert_image) /* Load the palette from the TGA if a palette buffer is provided * otherwise we will skip it. */ - if ((palette != NULL) && (Header.CMapLength > 0)) { + if ((palette != nullptr) && (Header.CMapLength > 0)) { /* Adjust palette to the starting color entry. */ palette += (Header.CMapStart * depth); @@ -388,7 +388,7 @@ long Targa::Load(const char* name, char* palette, char* image,bool invert_image) /* Load the image data from the TGA if an image buffer is provided * otherwise we are done. */ - if (!error && (image != NULL)) { + if (!error && (image != nullptr)) { depth = TGA_BytesPerPixel(Header.PixelDepth); size = ((Header.Width * Header.Height) * depth); @@ -419,7 +419,7 @@ long Targa::Load(const char* name, char* palette, char* image,bool invert_image) break; case TGA_TRUECOLOR_ENCODED: - if ((error = DecodeImage()) == NULL) { + if ((error = DecodeImage()) == nullptr) { if (invert_image) InvertImage(); } break; @@ -496,21 +496,21 @@ long Targa::Load(const char* name, long flags, bool invert_image) if ((flags & TGAF_PAL) && (Header.ColorMapType == 1)) { /* Dispose of any previous palette. */ - if ((mPalette != NULL) && (mFlags & TGAF_PAL)) { + if ((mPalette != nullptr) && (mFlags & TGAF_PAL)) { free(mPalette); - mPalette = NULL; + mPalette = nullptr; mFlags &= ~TGAF_PAL; } /* Only allocate a palette if the client hasn't assigned one. */ - if ((mPalette == NULL) && !(mFlags & TGAF_PAL)) { + if ((mPalette == nullptr) && !(mFlags & TGAF_PAL)) { /* Compute the size of the palette from the targa header. */ size = (Header.CMapLength * (Header.CMapDepth >> 3)); if (size != 0) { /* Allocate memory for the palette. */ - if ((mPalette = (char *)malloc(size)) != NULL) { + if ((mPalette = (char *)malloc(size)) != nullptr) { mFlags |= TGAF_PAL; /* We allocated the palette. */ } else { error = TGAERR_NOMEM; @@ -523,20 +523,20 @@ long Targa::Load(const char* name, long flags, bool invert_image) if (!error && (flags & TGAF_IMAGE)) { /* Dispose of any previous image. */ - if ((mImage != NULL) && (mFlags & TGAF_IMAGE)) { + if ((mImage != nullptr) && (mFlags & TGAF_IMAGE)) { free(mImage); - mImage = NULL; + mImage = nullptr; mFlags &= ~TGAF_IMAGE; } /* Only allocate an image if the client hasn't assigned one. */ - if ((mImage == NULL) && !(mFlags & TGAF_IMAGE)) { + if ((mImage == nullptr) && !(mFlags & TGAF_IMAGE)) { /* Compute the size of the image data from the targa header. */ size = ((Header.Width * Header.Height) * TGA_BytesPerPixel(Header.PixelDepth)); if (size != 0) { /* Allocate memory for the image. */ - if ((mImage = (char *)malloc(size)) != NULL) { + if ((mImage = (char *)malloc(size)) != nullptr) { mFlags |= TGAF_IMAGE; /* We allocated the image. */ } else { error = TGAERR_NOMEM; @@ -595,7 +595,7 @@ long Targa::Save(const char* name, long flags, bool addextension) TGA2Footer footer; /* Open the Targa for write. */ - if (Open(name, TGA_WRITEMODE) == NULL) + if (Open(name, TGA_WRITEMODE) == nullptr) { Header.IDLength = 0; @@ -631,7 +631,7 @@ long Targa::Save(const char* name, long flags, bool addextension) /*----------------------------------------------------------------------- * WRITE THE COLORMAP (PALETTE) DATA SECTION *---------------------------------------------------------------------*/ - if (!error && (flags & TGAF_PAL) && (mPalette != NULL) + if (!error && (flags & TGAF_PAL) && (mPalette != nullptr) && (Header.CMapLength > 0)) { /* Adjust palette to the starting color entry. */ @@ -640,7 +640,7 @@ long Targa::Save(const char* name, long flags, bool addextension) size = (Header.CMapLength * depth); /* Allocate temporary buffer for palette manipulation. */ - if ((temppal = (char *)malloc(size)) != NULL) + if ((temppal = (char *)malloc(size)) != nullptr) { memcpy(temppal, palette, size); ptr = temppal; @@ -672,7 +672,7 @@ long Targa::Save(const char* name, long flags, bool addextension) /*----------------------------------------------------------------------- * WRITE THE IMAGE DATA SECTION *---------------------------------------------------------------------*/ - if (!error && (flags & TGAF_IMAGE) && (mImage != NULL)) + if (!error && (flags & TGAF_IMAGE) && (mImage != nullptr)) { bool imageinverted; @@ -878,18 +878,18 @@ void Targa::YFlip(void) char *Targa::SetImage(char *buffer) { - char *oldbuffer = NULL; + char *oldbuffer = nullptr; /* Free any image buffer before assigning another. */ - if ((mImage != NULL) && (mFlags & TGAF_IMAGE)) + if ((mImage != nullptr) && (mFlags & TGAF_IMAGE)) { free(mImage); - mImage = NULL; + mImage = nullptr; mFlags &= ~TGAF_IMAGE; } /* Get the old user buffer. */ - if (mImage != NULL) + if (mImage != nullptr) oldbuffer = mImage; /* Assign the new image buffer. */ @@ -921,18 +921,18 @@ char *Targa::SetImage(char *buffer) char *Targa::SetPalette(char *buffer) { - char *oldbuffer = NULL; + char *oldbuffer = nullptr; /* Free any image buffer before assigning another. */ - if ((mPalette != NULL) && (mFlags & TGAF_PAL)) + if ((mPalette != nullptr) && (mFlags & TGAF_PAL)) { free(mPalette); - mPalette = NULL; + mPalette = nullptr; mFlags &= ~TGAF_PAL; } /* Get the old user buffer. */ - if (mPalette != NULL) + if (mPalette != nullptr) oldbuffer = mPalette; /* Assign the new image buffer. */ @@ -963,13 +963,13 @@ bool Targa::IsCompressed(void) * * FUNCTION * Retrieve a pointer to the Targa 2.0 extension data area. If the file -* version is 1.0 OR there is no extensio area then a NULL will be returned. +* version is 1.0 OR there is no extensio area then a nullptr will be returned. * * INPUTS * NONE * * RESULT -* Ext - Pointer to Extension data, NULL if not available. +* Ext - Pointer to Extension data, nullptr if not available. * ****************************************************************************/ @@ -978,7 +978,7 @@ TGA2Extension *Targa::GetExtension(void) if (mFlags & TGAF_TGA2) return (&mExtension); - return (NULL); + return (nullptr); } @@ -1113,7 +1113,7 @@ long Targa::EncodeImage() depth = TGA_BytesPerPixel(Header.PixelDepth); /* Allocate packet buffer to hold maximum encoded data run. */ - if ((packet = (char *)malloc(128 * depth)) != NULL) + if ((packet = (char *)malloc(128 * depth)) != nullptr) { pixels = Header.Width * Header.Height; start = mImage; @@ -1282,7 +1282,7 @@ void Targa::InvertImage(void) void Targa::Clear_File(void) { #ifdef TGA_USES_WWLIB_FILE_CLASSES - TGAFile = NULL; + TGAFile = nullptr; #else mFH = -1; #endif @@ -1290,7 +1290,7 @@ void Targa::Clear_File(void) bool Targa::Is_File_Open(void) { #ifdef TGA_USES_WWLIB_FILE_CLASSES - return (TGAFile != NULL); + return (TGAFile != nullptr); #else return (mFH != -1); #endif diff --git a/Core/Tools/WW3D/max2w3d/TARGA.h b/Core/Tools/WW3D/max2w3d/TARGA.h index 02cf38aee44..5384abf7015 100644 --- a/Core/Tools/WW3D/max2w3d/TARGA.h +++ b/Core/Tools/WW3D/max2w3d/TARGA.h @@ -197,13 +197,13 @@ typedef struct _TGA2Ratio * TGA2Footer. * * ExtSize - Extension area size. (495 bytes for 2.0) - * AuthName - Name of the person who created image (NULL terminated ASCII) - * AuthComment - Comments of the author (NULL terminated ASCII) + * AuthName - Name of the person who created image (null-terminated ASCII) + * AuthComment - Comments of the author (null-terminated ASCII) * DateStamp - Date the file was created. (See TGA2DateStamp) * TimeStamp - Time the file was created. (See TGA2TimeStamp) - * JobName - Name of job image belongs to (NULL terminated ASCII) + * JobName - Name of job image belongs to (null-terminated ASCII) * JobTime - Elapsed time of the job. - * SoftID - ID of software used to create image (NULL terminated ASCII) + * SoftID - ID of software used to create image (null-terminated ASCII) * SoftVer - Version number of software used. * KeyColor - Tranparent color value. * Aspect - Pixel aspect ratio. diff --git a/Core/Tools/WW3D/max2w3d/Utility.cpp b/Core/Tools/WW3D/max2w3d/Utility.cpp index 7a17225dd35..09a0f3a023c 100644 --- a/Core/Tools/WW3D/max2w3d/Utility.cpp +++ b/Core/Tools/WW3D/max2w3d/Utility.cpp @@ -112,7 +112,7 @@ Value * input_box_cf (Value **arg_list, int count) { // Create the input box (but don't show it yet). InputDlg input_box(MAXScript_interface->GetMAXHWnd()); - Value *param = NULL; + Value *param = nullptr; // Check the 'caption' parameter. param = key_arg(caption); diff --git a/Core/Tools/WW3D/max2w3d/aabtreebuilder.cpp b/Core/Tools/WW3D/max2w3d/aabtreebuilder.cpp index 5dce24bc68f..54380dccff9 100644 --- a/Core/Tools/WW3D/max2w3d/aabtreebuilder.cpp +++ b/Core/Tools/WW3D/max2w3d/aabtreebuilder.cpp @@ -80,12 +80,12 @@ const float COINCIDENCE_EPSILON = 0.001f; * HISTORY: * *=============================================================================================*/ AABTreeBuilderClass::AABTreeBuilderClass(void) : - Root(NULL), + Root(nullptr), CurPolyIndex(0), PolyCount(0), - Polys(NULL), + Polys(nullptr), VertCount(0), - Verts(NULL) + Verts(nullptr) { } @@ -123,17 +123,17 @@ AABTreeBuilderClass::~AABTreeBuilderClass(void) void AABTreeBuilderClass::Reset(void) { if (Root) { - delete Root; Root = NULL; + delete Root; Root = nullptr; } - if (Verts != NULL) { + if (Verts != nullptr) { delete[] Verts; - Verts = NULL; + Verts = nullptr; } - if (Polys != NULL) { + if (Polys != nullptr) { delete[] Polys; - Polys = NULL; + Polys = nullptr; } } @@ -153,8 +153,8 @@ void AABTreeBuilderClass::Build_AABTree(int polycount,Vector3i * polys,int vertc { WWASSERT(polycount > 0); WWASSERT(vertcount > 0); - WWASSERT(polys != NULL); - WWASSERT(verts != NULL); + WWASSERT(polys != nullptr); + WWASSERT(verts != nullptr); /* ** If we already have allocated data, release it @@ -190,7 +190,7 @@ void AABTreeBuilderClass::Build_AABTree(int polycount,Vector3i * polys,int vertc */ Root = new CullNodeStruct; Build_Tree(Root,PolyCount,polyindices); - polyindices = NULL; + polyindices = nullptr; /* ** fill in the remaining information needed in the tree: @@ -271,10 +271,10 @@ void AABTreeBuilderClass::Build_Tree(CullNodeStruct * node,int polycount,int * p ** deletes the poly array. */ if (arrays.FrontCount) { - WWASSERT(arrays.FrontPolys != NULL); + WWASSERT(arrays.FrontPolys != nullptr); node->Front = new CullNodeStruct; Build_Tree(node->Front,arrays.FrontCount,arrays.FrontPolys); - arrays.FrontPolys = NULL; + arrays.FrontPolys = nullptr; } /* @@ -282,11 +282,11 @@ void AABTreeBuilderClass::Build_Tree(CullNodeStruct * node,int polycount,int * p ** deletes the tile array. */ if (arrays.BackCount) { - WWASSERT(arrays.BackPolys != NULL); + WWASSERT(arrays.BackPolys != nullptr); node->Back = new CullNodeStruct; Build_Tree(node->Back,arrays.BackCount,arrays.BackPolys); - arrays.BackPolys = NULL; + arrays.BackPolys = nullptr; } } @@ -307,9 +307,9 @@ void AABTreeBuilderClass::Build_Tree(CullNodeStruct * node,int polycount,int * p AABTreeBuilderClass::SplitChoiceStruct AABTreeBuilderClass::Select_Splitting_Plane(int polycount,int * polyindices) { - WWASSERT(polyindices != NULL); + WWASSERT(polyindices != nullptr); - const int NUM_TRYS = 50; + const int NUM_TRIES = 50; SplitChoiceStruct best_plane_stats; SplitChoiceStruct considered_plane_stats; @@ -317,7 +317,7 @@ AABTreeBuilderClass::Select_Splitting_Plane(int polycount,int * polyindices) /* ** Try putting axis-aligned planes through some random vertices */ - for (int trys = 0; trys < MIN(NUM_TRYS,polycount); trys++) { + for (int tries = 0; tries < MIN(NUM_TRIES,polycount); tries++) { AAPlaneClass plane; @@ -894,9 +894,9 @@ void AABTreeBuilderClass::Build_W3D_AABTree_Recursive /* ** If this is a non-leaf node, set up the child indices, otherwise set up the polygon indices */ - if (node->Front != NULL) { + if (node->Front != nullptr) { - WWASSERT(node->Back != NULL); // if we have one child, we better have both! + WWASSERT(node->Back != nullptr); // if we have one child, we better have both! newnode->FrontOrPoly0 = node->Front->Index; newnode->BackOrPolyCount = node->Back->Index; diff --git a/Core/Tools/WW3D/max2w3d/aabtreebuilder.h b/Core/Tools/WW3D/max2w3d/aabtreebuilder.h index 604d8130c16..55ea1185fe5 100644 --- a/Core/Tools/WW3D/max2w3d/aabtreebuilder.h +++ b/Core/Tools/WW3D/max2w3d/aabtreebuilder.h @@ -84,7 +84,7 @@ class AABTreeBuilderClass */ struct CullNodeStruct { - CullNodeStruct(void) : Index(0),Min(0,0,0),Max(0,0,0),Front(NULL),Back(NULL),PolyCount(0),PolyIndices(NULL) {} + CullNodeStruct(void) : Index(0),Min(0,0,0),Max(0,0,0),Front(nullptr),Back(nullptr),PolyCount(0),PolyIndices(nullptr) {} ~CullNodeStruct(void) { if (Front) { delete Front; } @@ -133,8 +133,8 @@ class AABTreeBuilderClass SplitArraysStruct(void) : FrontCount(0), BackCount(0), - FrontPolys(NULL), - BackPolys(NULL) + FrontPolys(nullptr), + BackPolys(nullptr) { } diff --git a/Core/Tools/WW3D/max2w3d/animationcompressionsettings.cpp b/Core/Tools/WW3D/max2w3d/animationcompressionsettings.cpp index 8fc42511cc7..7f80c4bf9d5 100644 --- a/Core/Tools/WW3D/max2w3d/animationcompressionsettings.cpp +++ b/Core/Tools/WW3D/max2w3d/animationcompressionsettings.cpp @@ -50,8 +50,8 @@ //////////////////////////////////////////////////////////////////////////////////////// AnimationCompressionSettingsDialogClass::AnimationCompressionSettingsDialogClass (Interface *maxinterface, HWND parent_wnd) : MaxInterface (maxinterface), - Options (NULL), - Wnd (NULL), + Options (nullptr), + Wnd (nullptr), ParentWnd (parent_wnd) { return ; @@ -97,7 +97,7 @@ AnimationCompressionSettingsDialogClass::Real_Message_Proc LPARAM lparam ) { - AnimationCompressionSettingsDialogClass *dialog_obj = NULL; + AnimationCompressionSettingsDialogClass *dialog_obj = nullptr; // // Setup the framework we need so that the instance @@ -115,7 +115,7 @@ AnimationCompressionSettingsDialogClass::Real_Message_Proc // Allow the instance to handle the call // BOOL retval = FALSE; - if (dialog_obj != NULL) { + if (dialog_obj != nullptr) { retval = dialog_obj->Message_Proc (message, wparam, lparam); } @@ -158,7 +158,7 @@ AnimationCompressionSettingsDialogClass::Message_Proc ::GetWindowRect (Wnd, &rect); int width = parent_rect.right - parent_rect.left; int height = parent_rect.bottom - parent_rect.top; - ::SetWindowPos ( Wnd, NULL, + ::SetWindowPos ( Wnd, nullptr, parent_rect.left + (width / 2) - ((rect.right - rect.left) / 2), parent_rect.top + (height / 2) - ((rect.bottom - rect.top) / 2), 0, 0, SWP_NOZORDER | SWP_NOSIZE); diff --git a/Core/Tools/WW3D/max2w3d/animationcompressionsettings.h b/Core/Tools/WW3D/max2w3d/animationcompressionsettings.h index 921ad26d049..c3986b51111 100644 --- a/Core/Tools/WW3D/max2w3d/animationcompressionsettings.h +++ b/Core/Tools/WW3D/max2w3d/animationcompressionsettings.h @@ -55,7 +55,7 @@ class AnimationCompressionSettingsDialogClass ////////////////////////////////////////////////////////////////// // Public constructors/destructors ////////////////////////////////////////////////////////////////// - AnimationCompressionSettingsDialogClass (Interface *maxinterface, HWND parent_wnd = NULL); + AnimationCompressionSettingsDialogClass (Interface *maxinterface, HWND parent_wnd = nullptr); ~AnimationCompressionSettingsDialogClass (void); diff --git a/Core/Tools/WW3D/max2w3d/bchannel.cpp b/Core/Tools/WW3D/max2w3d/bchannel.cpp index 335f5cca220..69f09ff2935 100644 --- a/Core/Tools/WW3D/max2w3d/bchannel.cpp +++ b/Core/Tools/WW3D/max2w3d/bchannel.cpp @@ -114,7 +114,7 @@ bool BitChannelClass::Save(ChunkSaveClass & csave, bool compress) W3dTimeCodedBitChannelStruct * chn = (W3dTimeCodedBitChannelStruct *)malloc(channelsize); - if (chn == NULL) { + if (chn == nullptr) { return false; } @@ -157,7 +157,7 @@ bool BitChannelClass::Save(ChunkSaveClass & csave, bool compress) return false; } - if (chn != NULL) { + if (chn != nullptr) { free(chn); } @@ -183,7 +183,7 @@ bool BitChannelClass::Save(ChunkSaveClass & csave, bool compress) W3dBitChannelStruct * chn = (W3dBitChannelStruct *)malloc(channelsize); - if (chn == NULL) { + if (chn == nullptr) { return false; } @@ -203,7 +203,7 @@ bool BitChannelClass::Save(ChunkSaveClass & csave, bool compress) return false; } - if (chn != NULL) { + if (chn != nullptr) { free(chn); } diff --git a/Core/Tools/WW3D/max2w3d/bpick.cpp b/Core/Tools/WW3D/max2w3d/bpick.cpp index 7cea41c89c8..7915b6ade3f 100644 --- a/Core/Tools/WW3D/max2w3d/bpick.cpp +++ b/Core/Tools/WW3D/max2w3d/bpick.cpp @@ -64,7 +64,7 @@ BonePickerClass TheBonePicker; *=============================================================================================*/ BOOL BonePickerClass::Filter(INode *node) { - if (BoneList == NULL) { + if (BoneList == nullptr) { ObjectState os = node->EvalWorldState(0); if (os.obj) { return TRUE; @@ -124,8 +124,8 @@ BOOL BonePickerClass::Pick(IObjParam *ip,ViewExp *vpt) */ assert(User); User->User_Picked_Bone(node); - User = NULL; - BoneList = NULL; + User = nullptr; + BoneList = nullptr; } return TRUE; @@ -138,10 +138,10 @@ BOOL BonePickerClass::filter(INode * inode) void BonePickerClass::proc(INodeTab & nodetab) { - assert(User != NULL); + assert(User != nullptr); User->User_Picked_Bones(nodetab); - User = NULL; - BoneList = NULL; + User = nullptr; + BoneList = nullptr; } TCHAR * BonePickerClass::dialogTitle(void) diff --git a/Core/Tools/WW3D/max2w3d/bpick.h b/Core/Tools/WW3D/max2w3d/bpick.h index bb212890210..9963831bd5d 100644 --- a/Core/Tools/WW3D/max2w3d/bpick.h +++ b/Core/Tools/WW3D/max2w3d/bpick.h @@ -63,14 +63,14 @@ class BonePickerClass : public PickNodeCallback, public PickModeCallback, public { public: - BonePickerClass(void) : User(NULL), BoneList(NULL), SinglePick(FALSE) {} + BonePickerClass(void) : User(nullptr), BoneList(nullptr), SinglePick(FALSE) {} /* ** Tell this class who is using it and optionally the list ** of bones to allow the user to select from. ** Call this before giving this class to MAX... */ - void Set_User(BonePickerUserClass * user,int singlepick = FALSE, INodeTab * bonelist = NULL) { User = user; SinglePick = singlepick; BoneList = bonelist; } + void Set_User(BonePickerUserClass * user,int singlepick = FALSE, INodeTab * bonelist = nullptr) { User = user; SinglePick = singlepick; BoneList = bonelist; } /* ** From BonePickNodeCallback: @@ -111,7 +111,7 @@ class BonePickerClass : public PickNodeCallback, public PickModeCallback, public /* ** List of bones that the user is being allowed to pick from. - ** If this is NULL, then the user can pick any bone + ** If this is null, then the user can pick any bone */ INodeTab * BoneList; diff --git a/Core/Tools/WW3D/max2w3d/colboxsave.cpp b/Core/Tools/WW3D/max2w3d/colboxsave.cpp index 5e97c9d638c..918933e37c1 100644 --- a/Core/Tools/WW3D/max2w3d/colboxsave.cpp +++ b/Core/Tools/WW3D/max2w3d/colboxsave.cpp @@ -70,7 +70,7 @@ CollisionBoxSaveClass::CollisionBoxSaveClass memset(&BoxData,0,sizeof(BoxData)); BoxData.Version = W3D_BOX_CURRENT_VERSION; - if ((container_name != NULL) && (strlen(container_name) > 0)) { + if ((container_name != nullptr) && (strlen(container_name) > 0)) { strcpy(BoxData.Name,container_name); strcat(BoxData.Name,"."); } @@ -83,19 +83,19 @@ CollisionBoxSaveClass::CollisionBoxSaveClass BoxData.Attributes |= W3D_BOX_ATTRIBUTE_ORIENTED; } if (Is_Physical_Collision(inode)) { - BoxData.Attributes |= W3D_BOX_ATTRIBTUE_COLLISION_TYPE_PHYSICAL; + BoxData.Attributes |= W3D_BOX_ATTRIBUTE_COLLISION_TYPE_PHYSICAL; } if (Is_Projectile_Collision(inode)) { - BoxData.Attributes |= W3D_BOX_ATTRIBTUE_COLLISION_TYPE_PROJECTILE; + BoxData.Attributes |= W3D_BOX_ATTRIBUTE_COLLISION_TYPE_PROJECTILE; } if (Is_Vis_Collision(inode)) { - BoxData.Attributes |= W3D_BOX_ATTRIBTUE_COLLISION_TYPE_VIS; + BoxData.Attributes |= W3D_BOX_ATTRIBUTE_COLLISION_TYPE_VIS; } if (Is_Camera_Collision(inode)) { - BoxData.Attributes |= W3D_BOX_ATTRIBTUE_COLLISION_TYPE_CAMERA; + BoxData.Attributes |= W3D_BOX_ATTRIBUTE_COLLISION_TYPE_CAMERA; } if (Is_Vehicle_Collision(inode)) { - BoxData.Attributes |= W3D_BOX_ATTRIBTUE_COLLISION_TYPE_VEHICLE; + BoxData.Attributes |= W3D_BOX_ATTRIBUTE_COLLISION_TYPE_VEHICLE; } BoxData.Color.R = GetRValue(wirecolor); diff --git a/Core/Tools/WW3D/max2w3d/dazzlesave.cpp b/Core/Tools/WW3D/max2w3d/dazzlesave.cpp index 3f8ecc7b86d..4ed89fd6abb 100644 --- a/Core/Tools/WW3D/max2w3d/dazzlesave.cpp +++ b/Core/Tools/WW3D/max2w3d/dazzlesave.cpp @@ -54,14 +54,14 @@ DazzleSaveClass::DazzleSaveClass Progress_Meter_Class & meter ) { - assert(mesh_name != NULL); - assert(container_name != NULL); + assert(mesh_name != nullptr); + assert(container_name != nullptr); /* ** Set up the render object name */ memset(&W3DName,0,sizeof(W3DName)); - if ((container_name != NULL) && (strlen(container_name) > 0)) { + if ((container_name != nullptr) && (strlen(container_name) > 0)) { strcpy(W3DName,container_name); strcat(W3DName,"."); } diff --git a/Core/Tools/WW3D/max2w3d/dllmain.cpp b/Core/Tools/WW3D/max2w3d/dllmain.cpp index ce3727e08e6..46bc274f227 100644 --- a/Core/Tools/WW3D/max2w3d/dllmain.cpp +++ b/Core/Tools/WW3D/max2w3d/dllmain.cpp @@ -64,7 +64,7 @@ * Globals *****************************************************************************/ -HINSTANCE AppInstance = NULL; +HINSTANCE AppInstance = nullptr; static int ControlsInit = FALSE; static W3dClassDesc W3d_Export_Class_Descriptor; @@ -158,9 +158,9 @@ DLLEXPORT ClassDesc * LibClassDesc(int i) case 7: return Get_PS2_Material_Conversion(); break; case 8: return Get_Alpha_Desc(); break; //case 6: return Get_Mesh_Deform_Desc(); break; - //Moumine 7/24/2001 4:33:52 PM Removed #6 and shifted up instead of returning NULL - // NULL causes a crash in "File->Summary info->Plug-in ifo..." - default: return NULL; break; + //Moumine 7/24/2001 4:33:52 PM Removed #6 and shifted up instead of returning nullptr + // nullptr causes a crash in "File->Summary info->Plug-in ifo..." + default: return nullptr; break; } } @@ -199,8 +199,8 @@ TCHAR * Get_String( int id ) { static TCHAR buf[256]; if (AppInstance) - return LoadString(AppInstance, id, buf, sizeof(buf)) ? buf : NULL; - return NULL; + return LoadString(AppInstance, id, buf, sizeof(buf)) ? buf : nullptr; + return nullptr; } diff --git a/Core/Tools/WW3D/max2w3d/exportlog.cpp b/Core/Tools/WW3D/max2w3d/exportlog.cpp index 6f3aefbee80..800c3cfc94e 100644 --- a/Core/Tools/WW3D/max2w3d/exportlog.cpp +++ b/Core/Tools/WW3D/max2w3d/exportlog.cpp @@ -49,7 +49,7 @@ /* ** Static variables */ -LogDataDialogClass * _LogDialog = NULL; +LogDataDialogClass * _LogDialog = nullptr; /* @@ -73,7 +73,7 @@ LogDataDialogClass * _LogDialog = NULL; *=============================================================================================*/ void ExportLog::Init(HWND parent) { - assert(_LogDialog == NULL); + assert(_LogDialog == nullptr); _LogDialog = new LogDataDialogClass(parent); } @@ -93,14 +93,14 @@ void ExportLog::Init(HWND parent) *=============================================================================================*/ void ExportLog::Shutdown(bool wait_for_ok) { - if (_LogDialog != NULL) { + if (_LogDialog != nullptr) { if (wait_for_ok) { _LogDialog->Wait_OK(); } delete _LogDialog; - _LogDialog = NULL; + _LogDialog = nullptr; } } @@ -119,7 +119,7 @@ void ExportLog::Shutdown(bool wait_for_ok) *=============================================================================================*/ void ExportLog::printf(const char * format, ...) { - if (_LogDialog != NULL) { + if (_LogDialog != nullptr) { va_list arguments; va_start(arguments, format); _LogDialog->printf(format,arguments); @@ -141,7 +141,7 @@ void ExportLog::printf(const char * format, ...) *=============================================================================================*/ void ExportLog::rprintf(const char * format, ...) { - if (_LogDialog != NULL) { + if (_LogDialog != nullptr) { va_list arguments; va_start(arguments, format); _LogDialog->rprintf(format,arguments); @@ -163,7 +163,7 @@ void ExportLog::rprintf(const char * format, ...) *=============================================================================================*/ void ExportLog::updatebar(float position, float total) { - if (_LogDialog != NULL) { + if (_LogDialog != nullptr) { _LogDialog->updatebar(position,total); } } diff --git a/Core/Tools/WW3D/max2w3d/floaterdialog.cpp b/Core/Tools/WW3D/max2w3d/floaterdialog.cpp index 6079b238c7d..38eec49554b 100644 --- a/Core/Tools/WW3D/max2w3d/floaterdialog.cpp +++ b/Core/Tools/WW3D/max2w3d/floaterdialog.cpp @@ -87,9 +87,9 @@ BOOL CALLBACK _floater_dialog_proc(HWND hwnd,UINT message,WPARAM wParam,LPARAM l * HISTORY: * *=============================================================================================*/ FloaterDialogClass::FloaterDialogClass(void) : - Hwnd(NULL), + Hwnd(nullptr), ChildDialogTemplateID(-1), - ChildDialogProc(NULL) + ChildDialogProc(nullptr) { } @@ -107,7 +107,7 @@ FloaterDialogClass::FloaterDialogClass(void) : *=============================================================================================*/ FloaterDialogClass::~FloaterDialogClass(void) { - if (Hwnd != NULL) { + if (Hwnd != nullptr) { ::DestroyWindow(Hwnd); } } @@ -127,7 +127,7 @@ FloaterDialogClass::~FloaterDialogClass(void) *=============================================================================================*/ bool FloaterDialogClass::Is_Created(void) { - return (Hwnd != NULL); + return (Hwnd != nullptr); } @@ -204,13 +204,13 @@ bool FloaterDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM ChildDialogProc, 0 ); - if (childhwnd!= NULL) { + if (childhwnd!= nullptr) { RECT rect; LONG style = ::GetWindowLong(hWnd,GWL_STYLE); ::GetWindowRect(childhwnd,&rect); ::AdjustWindowRect(&rect,style,FALSE); - ::SetWindowPos(hWnd,NULL,0,0,rect.right - rect.left,rect.bottom - rect.top,SWP_NOZORDER|SWP_NOMOVE); - ::SetWindowPos(childhwnd,NULL,0,0,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_SHOWWINDOW); + ::SetWindowPos(hWnd,nullptr,0,0,rect.right - rect.left,rect.bottom - rect.top,SWP_NOZORDER|SWP_NOMOVE); + ::SetWindowPos(childhwnd,nullptr,0,0,0,0,SWP_NOZORDER|SWP_NOSIZE|SWP_SHOWWINDOW); } } return 1; @@ -226,7 +226,7 @@ bool FloaterDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM case WM_DESTROY: ::GetCOREInterface()->UnRegisterDlgWnd(Hwnd); - Hwnd = NULL; + Hwnd = nullptr; break; } return 0; diff --git a/Core/Tools/WW3D/max2w3d/gamemaps.cpp b/Core/Tools/WW3D/max2w3d/gamemaps.cpp index 0be2207c5c5..3c0e5325352 100644 --- a/Core/Tools/WW3D/max2w3d/gamemaps.cpp +++ b/Core/Tools/WW3D/max2w3d/gamemaps.cpp @@ -89,7 +89,7 @@ class GameMapsClassDesc : public ClassDesc { public: int IsPublic() { return 0; } - void * Create(BOOL loading) { return new GameMapsClass(NULL); } + void * Create(BOOL loading) { return new GameMapsClass(nullptr); } const TCHAR * ClassName() { return _T("GameMaps"); } SClass_ID SuperClassID() { return REF_MAKER_CLASS_ID; } Class_ID ClassID() { return _GameMapsClassID; } @@ -183,11 +183,11 @@ RefResult GameMapsClass::NotifyRefChanged *=============================================================================================*/ RefTargetHandle GameMapsClass::Clone(RemapDir &remap) { - GameMapsClass *tm = new GameMapsClass(NULL); + GameMapsClass *tm = new GameMapsClass(nullptr); for (int i=0; iTextureSlot[i].MapOn = TextureSlot[i].MapOn; - tm->TextureSlot[i].Map = NULL; + tm->TextureSlot[i].Map = nullptr; if (TextureSlot[i].Map) { tm->ReplaceReference(i,remap.CloneRef(TextureSlot[i].Map)); diff --git a/Core/Tools/WW3D/max2w3d/gamemaps.h b/Core/Tools/WW3D/max2w3d/gamemaps.h index f94e728406d..3da8ebc3cdd 100644 --- a/Core/Tools/WW3D/max2w3d/gamemaps.h +++ b/Core/Tools/WW3D/max2w3d/gamemaps.h @@ -57,7 +57,7 @@ class TexmapSlotClass float Amount; Texmap * Map; - TexmapSlotClass() : MapOn(FALSE), Amount(1.0f), Map(NULL) {}; + TexmapSlotClass() : MapOn(FALSE), Amount(1.0f), Map(nullptr) {}; RGBA Eval(ShadeContext& sc) { return Map->EvalColor(sc); } float EvalMono(ShadeContext& sc) { return Map->EvalMono(sc); } @@ -84,7 +84,7 @@ class GameMapsClass: public ReferenceTarget MtlBase * Client; TexmapSlotClass TextureSlot[NTEXMAPS]; - GameMapsClass() { Client = NULL; } + GameMapsClass() { Client = nullptr; } GameMapsClass(MtlBase *mb) { Client = mb; } void DeleteThis() { delete this; } diff --git a/Core/Tools/WW3D/max2w3d/genlodextensiondialog.cpp b/Core/Tools/WW3D/max2w3d/genlodextensiondialog.cpp index ffc8b5c36eb..c30199832f2 100644 --- a/Core/Tools/WW3D/max2w3d/genlodextensiondialog.cpp +++ b/Core/Tools/WW3D/max2w3d/genlodextensiondialog.cpp @@ -67,10 +67,10 @@ * HISTORY: * *=============================================================================================*/ GenLodExtensionDialogClass::GenLodExtensionDialogClass(Interface * maxinterface) : - Hwnd(NULL), - Options(NULL), + Hwnd(nullptr), + Options(nullptr), MaxInterface(maxinterface), - LodIndexSpin(NULL) + LodIndexSpin(nullptr) { } @@ -189,7 +189,7 @@ bool GenLodExtensionDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wPara *=============================================================================================*/ static BOOL CALLBACK _gen_lod_ext_dialog_proc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam) { - static GenLodExtensionDialogClass * dialog = NULL; + static GenLodExtensionDialogClass * dialog = nullptr; if (message == WM_INITDIALOG) { dialog = (GenLodExtensionDialogClass *)lparam; diff --git a/Core/Tools/WW3D/max2w3d/genmtlnamesdialog.cpp b/Core/Tools/WW3D/max2w3d/genmtlnamesdialog.cpp index 1347ccce465..8f625fee382 100644 --- a/Core/Tools/WW3D/max2w3d/genmtlnamesdialog.cpp +++ b/Core/Tools/WW3D/max2w3d/genmtlnamesdialog.cpp @@ -70,10 +70,10 @@ static BOOL CALLBACK _gen_mtl_names_dialog_proc(HWND Hwnd,UINT message,WPARAM wP * HISTORY: * *=============================================================================================*/ GenMtlNamesDialogClass::GenMtlNamesDialogClass(Interface * maxinterface) : - Hwnd(NULL), - Options(NULL), + Hwnd(nullptr), + Options(nullptr), MaxInterface(maxinterface), - NameIndexSpin(NULL) + NameIndexSpin(nullptr) { } @@ -192,7 +192,7 @@ bool GenMtlNamesDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LP // set initial name to root of the filename char buf[_MAX_FNAME]; - _splitpath(MaxInterface->GetCurFileName(),NULL,NULL,buf,NULL); + _splitpath(MaxInterface->GetCurFileName(),nullptr,nullptr,buf,nullptr); buf[MAX_ROOT_NAME_LEN+1] = 0; SetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),buf); @@ -244,7 +244,7 @@ bool GenMtlNamesDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LP *=============================================================================================*/ static BOOL CALLBACK _gen_mtl_names_dialog_proc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam) { - static GenMtlNamesDialogClass * dialog = NULL; + static GenMtlNamesDialogClass * dialog = nullptr; if (message == WM_INITDIALOG) { dialog = (GenMtlNamesDialogClass *)lparam; diff --git a/Core/Tools/WW3D/max2w3d/gennamesdialog.cpp b/Core/Tools/WW3D/max2w3d/gennamesdialog.cpp index c3328c7bce7..9ce03049351 100644 --- a/Core/Tools/WW3D/max2w3d/gennamesdialog.cpp +++ b/Core/Tools/WW3D/max2w3d/gennamesdialog.cpp @@ -72,10 +72,10 @@ static BOOL CALLBACK _gen_names_dialog_proc(HWND Hwnd,UINT message,WPARAM wParam * HISTORY: * *=============================================================================================*/ GenNamesDialogClass::GenNamesDialogClass(Interface * maxinterface) : - Hwnd(NULL), - Options(NULL), + Hwnd(nullptr), + Options(nullptr), MaxInterface(maxinterface), - NameIndexSpin(NULL) + NameIndexSpin(nullptr) { } @@ -251,7 +251,7 @@ bool GenNamesDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARA // set initial name to root of the filename char buf[_MAX_FNAME]; - _splitpath(MaxInterface->GetCurFileName(),NULL,NULL,buf,NULL); + _splitpath(MaxInterface->GetCurFileName(),nullptr,nullptr,buf,nullptr); buf[MAX_ROOT_NAME_LEN+1] = 0; SetWindowText(GetDlgItem(Hwnd,IDC_BASE_NAME_EDIT),buf); @@ -340,7 +340,7 @@ bool GenNamesDialogClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARA *=============================================================================================*/ static BOOL CALLBACK _gen_names_dialog_proc(HWND hwnd,UINT message,WPARAM wparam,LPARAM lparam) { - static GenNamesDialogClass * dialog = NULL; + static GenNamesDialogClass * dialog = nullptr; if (message == WM_INITDIALOG) { dialog = (GenNamesDialogClass *)lparam; diff --git a/Core/Tools/WW3D/max2w3d/geometryexportcontext.h b/Core/Tools/WW3D/max2w3d/geometryexportcontext.h index c1d83f18d8b..5315428c6b8 100644 --- a/Core/Tools/WW3D/max2w3d/geometryexportcontext.h +++ b/Core/Tools/WW3D/max2w3d/geometryexportcontext.h @@ -75,11 +75,11 @@ class GeometryExportContextClass OriginList(origin_list), Origin(origin), OriginTransform(1), - ProgressMeter(NULL), + ProgressMeter(nullptr), materialColors(materialColors), numMaterialColors(0), numHouseColors(0), - materialColorTexture(NULL) + materialColorTexture(nullptr) { ModelName = strdup(model_name); OriginTransform = Origin->GetNodeTM(CurTime); diff --git a/Core/Tools/WW3D/max2w3d/geometryexporttask.cpp b/Core/Tools/WW3D/max2w3d/geometryexporttask.cpp index 8a6a70a668c..d3a521c42be 100644 --- a/Core/Tools/WW3D/max2w3d/geometryexporttask.cpp +++ b/Core/Tools/WW3D/max2w3d/geometryexporttask.cpp @@ -79,7 +79,7 @@ class MeshGeometryExportTaskClass : public GeometryExportTaskClass MeshGeometryExportTaskClass(INode * node,GeometryExportContextClass & context) : GeometryExportTaskClass(node,context), NameDirty(false), - SingleMtl(NULL) + SingleMtl(nullptr) { /* ** Copy the export options @@ -271,7 +271,7 @@ class DazzleGeometryExportTaskClass : public GeometryExportTaskClass /** ** NullGeometryExportTaskClass -** Export task for INodes which are to generate W3D NULL objects. Note that this +** Export task for INodes which are to generate W3D null objects. Note that this ** does not do anything in the Export_Geometry call, these only create entries in ** any Hierarhcical model or collection object being exported. */ @@ -411,9 +411,9 @@ GeometryExportTaskClass::GeometryExportTaskClass(INode * node,GeometryExportCont /* ** Set up the bone index and export coordinate system. */ - if (context.HTree != NULL) { + if (context.HTree != nullptr) { if (!Is_Skin(node)) { - context.HTree->Get_Export_Coordinate_System(Node,&BoneIndex,NULL,&ExportSpace); + context.HTree->Get_Export_Coordinate_System(Node,&BoneIndex,nullptr,&ExportSpace); } else { BoneIndex = 0; ExportSpace = context.OriginTransform; @@ -506,7 +506,7 @@ GeometryExportTaskClass * GeometryExportTaskClass::Create_Task(INode * node,GeometryExportContextClass & context) { if (!::Is_Geometry(node)) { - return NULL; + return nullptr; } // NOTE: we *have* to check Is_Proxy first because it is tied to a naming convention @@ -535,7 +535,7 @@ GeometryExportTaskClass::Create_Task(INode * node,GeometryExportContextClass & c return new AggregateGeometryExportTaskClass(node,context); } - return NULL; + return nullptr; } @@ -703,9 +703,9 @@ void GeometryExportTaskClass::Generate_Name(char * root,int index,GeometryExport char * exterior_prefix = strchr(prefix,'#'); memset(Name,0,sizeof(Name)); - if (interior_prefix != NULL) { + if (interior_prefix != nullptr) { strncpy(Name,prefix,(int)(interior_prefix - prefix) + 1); - } else if (exterior_prefix != NULL) { + } else if (exterior_prefix != nullptr) { strncpy(Name,prefix,(int)(exterior_prefix - prefix) + 1); } @@ -741,15 +741,15 @@ void GeometryExportTaskClass::Generate_Name(char * root,int index,GeometryExport *=============================================================================================*/ void MeshGeometryExportTaskClass::Update_Cached_Data(void) { - SingleMtl = NULL; + SingleMtl = nullptr; Mtl * nodemtl = Node->GetMtl(); /* ** Set the SingleMtl pointer if this mesh uses only one material (again, even if its in a Multi-Sub) */ - if (nodemtl == NULL) { + if (nodemtl == nullptr) { - SingleMtl = NULL; + SingleMtl = nullptr; } else if (nodemtl->NumSubMtls() <= 1) { @@ -790,7 +790,7 @@ void MeshGeometryExportTaskClass::Update_Cached_Data(void) } if (mat_count > 1) { - SingleMtl = NULL; + SingleMtl = nullptr; } } @@ -838,7 +838,7 @@ void MeshGeometryExportTaskClass::Update_Cached_Data(void) *=============================================================================================*/ bool MeshGeometryExportTaskClass::Is_Single_Material(void) { - return ((SingleMtl != NULL) || (Node->GetMtl() == NULL)); + return ((SingleMtl != nullptr) || (Node->GetMtl() == nullptr)); } @@ -1016,7 +1016,7 @@ bool MeshGeometryExportTaskClass::Can_Combine_With(MeshGeometryExportTaskClass * ** Does the mesh use the same (single) material that we do? */ Mtl * other_mtl = other_mesh->Get_Single_Material(); - if (other_mtl == NULL) { + if (other_mtl == nullptr) { return false; } @@ -1125,7 +1125,7 @@ Point3 MeshGeometryExportTaskClass::Get_Shared_Vertex_Normal(const Point3 & worl if ((face_smgroup & smgroup) || (face_smgroup == smgroup)) { /* - ** Find out if any of the verticies of this face share the + ** Find out if any of the vertices of this face share the ** same space as the vertex we are looking for. */ bool found = false; diff --git a/Core/Tools/WW3D/max2w3d/gmtldlg.cpp b/Core/Tools/WW3D/max2w3d/gmtldlg.cpp index f2ebcba44a1..cc244f72824 100644 --- a/Core/Tools/WW3D/max2w3d/gmtldlg.cpp +++ b/Core/Tools/WW3D/max2w3d/gmtldlg.cpp @@ -99,11 +99,11 @@ static inline int FracToPc(float f) GameMtlDlg::GameMtlDlg(HWND hwMtlEdit, IMtlParams *imp, GameMtl *m) { HwndEdit = hwMtlEdit; - HwndPanel = NULL; - HwndHints = NULL; - HwndPsx = NULL; - HwndNotes = NULL; - HpalOld = NULL; + HwndPanel = nullptr; + HwndHints = nullptr; + HwndPsx = nullptr; + HwndNotes = nullptr; + HpalOld = nullptr; TheMtl = m; IParams = imp; @@ -111,28 +111,28 @@ GameMtlDlg::GameMtlDlg(HWND hwMtlEdit, IMtlParams *imp, GameMtl *m) IsActive = 0; InstCopy = FALSE; - DiffuseSwatch = NULL; - SpecularSwatch = NULL; + DiffuseSwatch = nullptr; + SpecularSwatch = nullptr; - AmbientCoeffSwatch = NULL; - DiffuseCoeffSwatch = NULL; - SpecularCoeffSwatch = NULL; - EmissiveCoeffSwatch = NULL; + AmbientCoeffSwatch = nullptr; + DiffuseCoeffSwatch = nullptr; + SpecularCoeffSwatch = nullptr; + EmissiveCoeffSwatch = nullptr; - DCTFramesSpin = NULL; - DITFramesSpin = NULL; - SCTFramesSpin = NULL; - SITFramesSpin = NULL; + DCTFramesSpin = nullptr; + DITFramesSpin = nullptr; + SCTFramesSpin = nullptr; + SITFramesSpin = nullptr; - DCTRateSpin = NULL; - DITRateSpin = NULL; - SCTRateSpin = NULL; - SITRateSpin = NULL; + DCTRateSpin = nullptr; + DITRateSpin = nullptr; + SCTRateSpin = nullptr; + SITRateSpin = nullptr; - OpacitySpin = NULL; - TranslucencySpin = NULL; - ShininessSpin = NULL; - FogSpin = NULL; + OpacitySpin = nullptr; + TranslucencySpin = nullptr; + ShininessSpin = nullptr; + FogSpin = nullptr; } /*********************************************************************************************** @@ -151,32 +151,32 @@ GameMtlDlg::~GameMtlDlg() { if (DiffuseSwatch) { ReleaseIColorSwatch(DiffuseSwatch); - DiffuseSwatch = NULL; + DiffuseSwatch = nullptr; } if (SpecularSwatch) { ReleaseIColorSwatch(SpecularSwatch); - SpecularSwatch = NULL; + SpecularSwatch = nullptr; } if (AmbientCoeffSwatch) { ReleaseIColorSwatch(AmbientCoeffSwatch); - AmbientCoeffSwatch = NULL; + AmbientCoeffSwatch = nullptr; } if (DiffuseCoeffSwatch) { ReleaseIColorSwatch(DiffuseCoeffSwatch); - DiffuseCoeffSwatch = NULL; + DiffuseCoeffSwatch = nullptr; } if (SpecularCoeffSwatch) { ReleaseIColorSwatch(SpecularCoeffSwatch); - SpecularCoeffSwatch = NULL; + SpecularCoeffSwatch = nullptr; } if (EmissiveCoeffSwatch) { ReleaseIColorSwatch(EmissiveCoeffSwatch); - EmissiveCoeffSwatch = NULL; + EmissiveCoeffSwatch = nullptr; } if (HwndPanel) { @@ -190,23 +190,23 @@ GameMtlDlg::~GameMtlDlg() TheMtl->SetFlag(GAMEMTL_ROLLUP3_OPEN,IParams->IsRollupPanelOpen(HwndHints)); TheMtl->SetFlag(GAMEMTL_ROLLUP4_OPEN,IParams->IsRollupPanelOpen(HwndNotes)); TheMtl->RollScroll = IParams->GetRollupScrollPos(); - TheMtl->SetParamDlg(NULL); + TheMtl->SetParamDlg(nullptr); IParams->UnRegisterDlgWnd(HwndPanel); IParams->DeleteRollupPage(HwndPanel); - HwndPanel = NULL; + HwndPanel = nullptr; IParams->UnRegisterDlgWnd(HwndPsx); IParams->DeleteRollupPage(HwndPsx); - HwndPsx = NULL; + HwndPsx = nullptr; IParams->UnRegisterDlgWnd(HwndHints); IParams->DeleteRollupPage(HwndHints); - HwndHints = NULL; + HwndHints = nullptr; IParams->UnRegisterDlgWnd(HwndNotes); IParams->DeleteRollupPage(HwndNotes); - HwndNotes = NULL; + HwndNotes = nullptr; } @@ -242,10 +242,10 @@ Class_ID GameMtlDlg::ClassID() void GameMtlDlg::Invalidate() { Valid = FALSE; - InvalidateRect(HwndPanel,NULL,0); - InvalidateRect(HwndPsx,NULL,0); - InvalidateRect(HwndHints,NULL,0); - InvalidateRect(HwndNotes,NULL,0); + InvalidateRect(HwndPanel,nullptr,0); + InvalidateRect(HwndPsx,nullptr,0); + InvalidateRect(HwndHints,nullptr,0); + InvalidateRect(HwndNotes,nullptr,0); } /*********************************************************************************************** @@ -436,28 +436,28 @@ BOOL GameMtlDlg::PanelProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam case IDC_MAPON_DCT: TheMtl->EnableMap(ID_DI,GetCheckBox(hwndDlg, id)); - if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_DI,NULL); + if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_DI,nullptr); UpdateTexmapDisplay(ID_DI); UpdateMtlDisplay(); TheMtl->NotifyChanged(); break; case IDC_MAPON_DIT: TheMtl->EnableMap(ID_SI,GetCheckBox(hwndDlg, id)); - if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_SI,NULL); + if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_SI,nullptr); UpdateTexmapDisplay(ID_SI); UpdateMtlDisplay(); TheMtl->NotifyChanged(); break; case IDC_MAPON_SCT: TheMtl->EnableMap(ID_SP,GetCheckBox(hwndDlg, id)); - if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_SP,NULL); + if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_SP,nullptr); UpdateTexmapDisplay(ID_SP); UpdateMtlDisplay(); TheMtl->NotifyChanged(); break; case IDC_MAPON_SIT: TheMtl->EnableMap(ID_RL,GetCheckBox(hwndDlg, id)); - if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_RL,NULL); + if (!GetCheckBox(hwndDlg,id)) TheMtl->SetSubTexmap(ID_RL,nullptr); UpdateTexmapDisplay(ID_RL); UpdateMtlDisplay(); TheMtl->NotifyChanged(); @@ -590,9 +590,9 @@ BOOL GameMtlDlg::PanelProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam ReleaseISpinner(ShininessSpin); ReleaseISpinner(FogSpin); - DCTFramesSpin = DITFramesSpin = SCTFramesSpin = SITFramesSpin = NULL; - DCTRateSpin = DITRateSpin = SCTRateSpin = SITRateSpin = NULL; - OpacitySpin = TranslucencySpin = ShininessSpin = FogSpin = NULL; + DCTFramesSpin = DITFramesSpin = SCTFramesSpin = SITFramesSpin = nullptr; + DCTRateSpin = DITRateSpin = SCTRateSpin = SITRateSpin = nullptr; + OpacitySpin = TranslucencySpin = ShininessSpin = FogSpin = nullptr; break; @@ -623,7 +623,7 @@ static BOOL CALLBACK PanelDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM theDlg->HwndPanel = hwndDlg; SetWindowLong(hwndDlg, GWL_USERDATA,lParam); } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { + if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == nullptr) { return FALSE; } } @@ -694,7 +694,7 @@ static BOOL CALLBACK NotesDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM theDlg->HwndNotes = hwndDlg; SetWindowLong(hwndDlg, GWL_USERDATA,lParam); } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { + if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == nullptr) { return FALSE; } } @@ -787,7 +787,7 @@ static BOOL CALLBACK HintsDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM theDlg->HwndHints = hwndDlg; SetWindowLong(hwndDlg, GWL_USERDATA,lParam); } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { + if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == nullptr) { return FALSE; } } @@ -883,7 +883,7 @@ static BOOL CALLBACK PsxDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP theDlg->HwndPsx = hwndDlg; SetWindowLong(hwndDlg, GWL_USERDATA,lParam); } else { - if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == NULL) { + if ((theDlg = (GameMtlDlg *)GetWindowLong(hwndDlg, GWL_USERDATA) ) == nullptr) { return FALSE; } } @@ -1100,7 +1100,7 @@ void GameMtlDlg::SetThing(ReferenceTarget *m) assert (m->ClassID()==GameMaterialClassID); if (TheMtl) { - TheMtl->ParamPanel = NULL; + TheMtl->ParamPanel = nullptr; } TheMtl = (GameMtl *)m; diff --git a/Core/Tools/WW3D/max2w3d/gridsnapmodifier.cpp b/Core/Tools/WW3D/max2w3d/gridsnapmodifier.cpp index f9aaf8773c3..cdca679defa 100644 --- a/Core/Tools/WW3D/max2w3d/gridsnapmodifier.cpp +++ b/Core/Tools/WW3D/max2w3d/gridsnapmodifier.cpp @@ -87,7 +87,7 @@ class GridSnapModifierClass : public SimpleMod2 // Direct paramblock access int NumParamBlocks() { return 1; } IParamBlock2* GetParamBlock(int i) { return pblock2; } - IParamBlock2* GetParamBlockByID(BlockID id) { return (pblock2->ID() == id) ? pblock2 : NULL; } + IParamBlock2* GetParamBlockByID(BlockID id) { return (pblock2->ID() == id) ? pblock2 : nullptr; } // From simple mod Deformer& GetDeformer(TimeValue t,ModContext &mc,Matrix3& mat,Matrix3& invmat); @@ -177,7 +177,7 @@ static ParamBlockDesc2 _GridSnapParamBlockDesc GSM_PARAMS,_T("GridSnap Parameters"), 0, &_GridSnapModifierDesc, P_AUTO_CONSTRUCT + P_AUTO_UI, SIMPMOD_PBLOCKREF, // dialog box - IDD_GRIDSNAP_PARAMS, IDS_GRIDSNAP_TITLE, 0, 0, NULL, + IDD_GRIDSNAP_PARAMS, IDS_GRIDSNAP_TITLE, 0, 0, nullptr, // parameters GSM_PARAM_GRIDDIMENSION, _T("Grid Dimension"), TYPE_FLOAT, P_RESET_DEFAULT, IDS_GRID_DIMENSION, @@ -216,7 +216,7 @@ void GridSnapModifierClass::EndEditParams( IObjParam *ip,ULONG flags,Animatable SimpleMod2::EndEditParams(ip,flags,next); _GridSnapModifierDesc.EndEditParams(ip, this, flags, next); - this->ip = NULL; + this->ip = nullptr; } RefTargetHandle GridSnapModifierClass::Clone(RemapDir& remap) @@ -258,7 +258,7 @@ RefTargetHandle SimpleMod2::GetReference(int i) case 0: return tmControl; case 1: return posControl; case 2: return pblock2; - default: return NULL; + default: return nullptr; } } @@ -277,6 +277,6 @@ Animatable * SimpleMod2::SubAnim(int i) case 0: return posControl; case 1: return tmControl; case 2: return pblock2; - default: return NULL; + default: return nullptr; } } diff --git a/Core/Tools/WW3D/max2w3d/hiersave.cpp b/Core/Tools/WW3D/max2w3d/hiersave.cpp index 70066e54d31..5722baf25d4 100644 --- a/Core/Tools/WW3D/max2w3d/hiersave.cpp +++ b/Core/Tools/WW3D/max2w3d/hiersave.cpp @@ -116,7 +116,7 @@ HierarchySaveClass::HierarchySaveClass /* ** Build our tree from the given tree of nodes */ - int rootidx = add_node(NULL,-1); + int rootidx = add_node(nullptr,-1); assert(rootidx == 0); add_tree(root,rootidx); @@ -170,7 +170,7 @@ HierarchySaveClass::HierarchySaveClass /* ** Build the tree with all leaves of all of the nodes given */ - int rootidx = add_node(NULL,-1); + int rootidx = add_node(nullptr,-1); assert(rootidx == 0); for (unsigned int i = 0; i < rootlist->Num_Nodes(); i++) { @@ -199,7 +199,7 @@ HierarchySaveClass::HierarchySaveClass * 10/26/1997 GH : Created. * *=============================================================================================*/ HierarchySaveClass::HierarchySaveClass(): - Node(NULL), + Node(nullptr), CurNode(0), CurTime(0) { @@ -452,10 +452,10 @@ void HierarchySaveClass::Get_Export_Coordinate_System ** Nope, try the next parent */ pbone = pbone->GetParentNode(); - assert(pbone != NULL); + assert(pbone != nullptr); #if 0 - if (pbone == NULL) { + if (pbone == nullptr) { /* ** mesh isn't connected to a bone, use the root @@ -468,13 +468,13 @@ void HierarchySaveClass::Get_Export_Coordinate_System } } - if (set_bone_index != NULL) { + if (set_bone_index != nullptr) { *set_bone_index = boneidx; } - if (set_bone_node != NULL) { + if (set_bone_node != nullptr) { *set_bone_node = pbone; } - if (set_transform != NULL) { + if (set_transform != nullptr) { *set_transform = Get_Fixup_Transform(boneidx) * pbone->GetNodeTM(CurTime); } } @@ -678,11 +678,11 @@ int HierarchySaveClass::add_node(INode * node,int pidx) ** types of transforms and we want to apply the same ** changes to this tree. ** - ** Note that if FixupType is not "NONE", FixupTree must be NULL, + ** Note that if FixupType is not "NONE", FixupTree must be nullptr, */ - assert(!((FixupTree != NULL) && (FixupType != MATRIX_FIXUP_NONE))); + assert(!((FixupTree != nullptr) && (FixupType != MATRIX_FIXUP_NONE))); - if (FixupTree != NULL) { + if (FixupTree != nullptr) { int fi = FixupTree->Find_Named_Node(Node[CurNode].Pivot.Name); if (fi == -1) { char buf[128]; @@ -976,7 +976,7 @@ bool HierarchySaveClass::load_header(ChunkLoadClass & cload) bool HierarchySaveClass::load_pivots(ChunkLoadClass & cload) { for (uint32 i=0; i= 2) { EndDialog(Hwnd, 1); - Hwnd = NULL; + Hwnd = nullptr; } return TRUE; @@ -301,7 +301,7 @@ bool LogDataDialogClass::Dialog_Proc void LogDataDialogClass::Dialog_Init() { - SetCursor(LoadCursor (NULL, IDC_ARROW)); + SetCursor(LoadCursor (nullptr, IDC_ARROW)); RECT desktop; RECT ourwin; diff --git a/Core/Tools/WW3D/max2w3d/maxworldinfo.cpp b/Core/Tools/WW3D/max2w3d/maxworldinfo.cpp index 095503f0980..651e660b6cb 100644 --- a/Core/Tools/WW3D/max2w3d/maxworldinfo.cpp +++ b/Core/Tools/WW3D/max2w3d/maxworldinfo.cpp @@ -42,7 +42,7 @@ /* ** Get_Shared_Vertex_Normal ** Loops through all the other meshes in the world and builds a vertex normal for -** the verticies that share the same space and are part of the same smoothing group. +** the vertices that share the same space and are part of the same smoothing group. */ Vector3 MaxWorldInfoClass::Get_Shared_Vertex_Normal (Vector3 pos, int smgroup) { @@ -51,7 +51,7 @@ Vector3 MaxWorldInfoClass::Get_Shared_Vertex_Normal (Vector3 pos, int smgroup) // // Loop through all the meshes in the world and see which ones contain - // verticies that share the same space and are part of the same smoothing group. + // vertices that share the same space and are part of the same smoothing group. // for(unsigned int index = 0; index < MeshList.Count(); index ++) { GeometryExportTaskClass * task = MeshList[index]; diff --git a/Core/Tools/WW3D/max2w3d/maxworldinfo.h b/Core/Tools/WW3D/max2w3d/maxworldinfo.h index d690edb50aa..cb4bc9e27e6 100644 --- a/Core/Tools/WW3D/max2w3d/maxworldinfo.h +++ b/Core/Tools/WW3D/max2w3d/maxworldinfo.h @@ -58,7 +58,7 @@ class MaxWorldInfoClass : public WorldInfoClass MaxWorldInfoClass(DynamicVectorClass & mesh_list) : MeshList (mesh_list), SmoothBetweenMeshes (true), - CurrentTask(NULL), + CurrentTask(nullptr), CurrentTime(0) { } virtual ~MaxWorldInfoClass(void) { } diff --git a/Core/Tools/WW3D/max2w3d/meshbuild.cpp b/Core/Tools/WW3D/max2w3d/meshbuild.cpp index 524b14c4b24..8a904c95320 100644 --- a/Core/Tools/WW3D/max2w3d/meshbuild.cpp +++ b/Core/Tools/WW3D/max2w3d/meshbuild.cpp @@ -161,7 +161,7 @@ class VertexArrayClass VertexArrayClass(int maxsize,int match_normals = 0) { - Verts = NULL; + Verts = nullptr; assert(maxsize > 0); Verts = new MeshBuilderClass::VertClass[maxsize]; assert(Verts); @@ -413,7 +413,7 @@ void MeshBuilderClass::VertClass::Reset(void) Attribute1 = 0; UniqueIndex = 0; ShadeIndex = 0; - NextHash = NULL; + NextHash = nullptr; } @@ -560,16 +560,16 @@ MeshBuilderClass::MeshBuilderClass(int pass_count,int face_count_guess,int face_ State(STATE_ACCEPTING_INPUT), PassCount(pass_count), FaceCount(0), - Faces(NULL), + Faces(nullptr), InputVertCount(0), VertCount(0), - Verts(NULL), + Verts(nullptr), CurFace(0), AllocFaceCount(0), AllocFaceGrowth(0), PolyOrderPass(0), PolyOrderStage(0), - WorldInfo (NULL) + WorldInfo(nullptr) { Reset(pass_count,face_count_guess,face_count_growth_rate); } @@ -589,7 +589,7 @@ MeshBuilderClass::MeshBuilderClass(int pass_count,int face_count_guess,int face_ MeshBuilderClass::~MeshBuilderClass(void) { Free(); - Set_World_Info(NULL); + Set_World_Info(nullptr); } @@ -607,14 +607,14 @@ MeshBuilderClass::~MeshBuilderClass(void) *=============================================================================================*/ void MeshBuilderClass::Free(void) { - if (Faces != NULL) { + if (Faces != nullptr) { delete[] Faces; - Faces = NULL; + Faces = nullptr; } - if (Verts != NULL) { + if (Verts != nullptr) { delete Verts; - Verts = NULL; + Verts = nullptr; } FaceCount = 0; @@ -825,7 +825,7 @@ void MeshBuilderClass::Compute_Vertex_Normals(void) /* ** Smooth this mesh with neighboring meshes! */ - if (WorldInfo != NULL && WorldInfo->Are_Meshes_Smoothed ()) { + if (WorldInfo != nullptr && WorldInfo->Are_Meshes_Smoothed ()) { for (vertidx = 0; vertidx < VertCount; vertidx++) { if (Verts[vertidx].ShadeIndex == vertidx) { Verts[vertidx].Normal += WorldInfo->Get_Shared_Vertex_Normal(Verts[vertidx].Position, Verts[vertidx].SharedSmGroup); @@ -834,7 +834,7 @@ void MeshBuilderClass::Compute_Vertex_Normals(void) } /* - ** Propogate the accumulated normals to all of the other verts which share them + ** Propagate the accumulated normals to all of the other verts which share them */ for (vertidx = 0; vertidx < VertCount; vertidx++) { int shadeindex = Verts[vertidx].ShadeIndex; @@ -1012,8 +1012,8 @@ void MeshBuilderClass::Compute_Bounding_Box(Vector3 * set_min,Vector3 * set_max) { int i; - assert(set_min != NULL); - assert(set_max != NULL); + assert(set_min != nullptr); + assert(set_max != nullptr); // Bounding Box // straightforward, axis-aligned bounding box. diff --git a/Core/Tools/WW3D/max2w3d/meshbuild.h b/Core/Tools/WW3D/max2w3d/meshbuild.h index bb48832aa63..348eff2823a 100644 --- a/Core/Tools/WW3D/max2w3d/meshbuild.h +++ b/Core/Tools/WW3D/max2w3d/meshbuild.h @@ -220,7 +220,7 @@ class MeshBuilderClass void Compute_Bounding_Sphere(Vector3 * set_center,float * set_radius); /* - ** World information managment. Used to give the mesh builder information + ** World information management. Used to give the mesh builder information ** about the world outside of its mesh. */ WorldInfoClass * Peek_World_Info(void) const { return WorldInfo; } diff --git a/Core/Tools/WW3D/max2w3d/meshcon.cpp b/Core/Tools/WW3D/max2w3d/meshcon.cpp index 11cdd3845f7..420d52f5b1d 100644 --- a/Core/Tools/WW3D/max2w3d/meshcon.cpp +++ b/Core/Tools/WW3D/max2w3d/meshcon.cpp @@ -69,7 +69,7 @@ MeshConnectionsClass::MeshConnectionsClass Origin(context.Origin) { unsigned int i; - assert(Origin != NULL); + assert(Origin != nullptr); /* ** Set the name, count the sub-objects and aggregates diff --git a/Core/Tools/WW3D/max2w3d/meshcon.h b/Core/Tools/WW3D/max2w3d/meshcon.h index cae17047f13..8060c23a3ee 100644 --- a/Core/Tools/WW3D/max2w3d/meshcon.h +++ b/Core/Tools/WW3D/max2w3d/meshcon.h @@ -68,7 +68,7 @@ class GeometryExportContextClass; struct ConnectionStruct { - ConnectionStruct(void) : BoneIndex(0),MeshINode(NULL) + ConnectionStruct(void) : BoneIndex(0),MeshINode(nullptr) { memset(ObjectName,0,sizeof(ObjectName)); } @@ -116,11 +116,11 @@ class MeshConnectionsClass ** out_name - name of the mesh is passed back by setting the char* pointed to by this value. ** out_boneindex - the index of the bone used is passed back by setting the int pointed to by this value. ** out_inode - mesh INode is passed by setting the INode* pointed to by this value. If this - ** parameter is NULL, the value is not passed back. + ** parameter is null, the value is not passed back. */ - bool Get_Sub_Object_Data(int index, char **out_name, int *out_boneindex, INode **out_inode = NULL); - bool Get_Aggregate_Data(int index, char **out_name, int *out_boneindex, INode **out_inode = NULL); - bool Get_Proxy_Data(int index, char **out_name, int *out_boneindex, INode **out_inode = NULL); + bool Get_Sub_Object_Data(int index, char **out_name, int *out_boneindex, INode **out_inode = nullptr); + bool Get_Aggregate_Data(int index, char **out_name, int *out_boneindex, INode **out_inode = nullptr); + bool Get_Proxy_Data(int index, char **out_name, int *out_boneindex, INode **out_inode = nullptr); /* ** Returns the origin node used by this model. diff --git a/Core/Tools/WW3D/max2w3d/meshsave.cpp b/Core/Tools/WW3D/max2w3d/meshsave.cpp index d1ff3513b1f..f2cc520e2e3 100644 --- a/Core/Tools/WW3D/max2w3d/meshsave.cpp +++ b/Core/Tools/WW3D/max2w3d/meshsave.cpp @@ -154,7 +154,7 @@ uint32 setup_mesh_attributes(INode * node) ** And, a mesh may have one or more types of collision detection enabled. ** W3D_MESH_FLAG_COLLISION_TYPE_PHYSICAL ** W3D_MESH_FLAG_COLLISION_TYPE_PROJECTILE - ** However, if the mesh is SKIN, SHADOW, ALIGNED, ORIENTED or NULL, don't let + ** However, if the mesh is SKIN, SHADOW, ALIGNED, ORIENTED or nullptr, don't let ** the collision bits get set... */ if ( attributes != W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN && @@ -252,9 +252,9 @@ MeshSaveClass::MeshSaveClass CurTime(curtime), ExportSpace(exportspace), HTree(htree), - UserText(NULL), - VertInfluences(NULL), - MaterialRemapTable(NULL) + UserText(nullptr), + VertInfluences(nullptr), + MaterialRemapTable(nullptr) { Mesh mesh = *input_mesh; // copy the mesh so we can modify it Mtl * nodemtl = inode->GetMtl(); @@ -296,8 +296,8 @@ MeshSaveClass::MeshSaveClass ////////////////////////////////////////////////////////////////////// // Prepare the mesh header. ////////////////////////////////////////////////////////////////////// - assert(mesh_name != NULL); - assert(container_name != NULL); + assert(mesh_name != nullptr); + assert(container_name != nullptr); memset(&Header,0,sizeof(Header)); Set_W3D_Name(Header.MeshName,mesh_name); @@ -342,7 +342,7 @@ MeshSaveClass::MeshSaveClass Header.VertexChannels |= W3D_VERTEX_CHANNEL_NORMAL; } - if (((Header.Attributes & W3D_MESH_FLAG_GEOMETRY_TYPE_MASK) == W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN) && (HTree != NULL)) { + if (((Header.Attributes & W3D_MESH_FLAG_GEOMETRY_TYPE_MASK) == W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN) && (HTree != nullptr)) { Header.VertexChannels |= W3D_VERTEX_CHANNEL_BONEID; } @@ -400,7 +400,7 @@ MeshSaveClass::MeshSaveClass ////////////////////////////////////////////////////////////////////// // If this is a skin, pre-deform the mesh. ////////////////////////////////////////////////////////////////////// - if (((Header.Attributes & W3D_MESH_FLAG_GEOMETRY_TYPE_MASK) == W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN) && (HTree != NULL)) { + if (((Header.Attributes & W3D_MESH_FLAG_GEOMETRY_TYPE_MASK) == W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN) && (HTree != nullptr)) { inv_deform_mesh(); } @@ -434,17 +434,17 @@ MeshSaveClass::~MeshSaveClass(void) { if (UserText) { delete[] UserText; - UserText = NULL; + UserText = nullptr; } if (VertInfluences) { delete[] VertInfluences; - VertInfluences = NULL; + VertInfluences = nullptr; } if (MaterialRemapTable) { delete[] MaterialRemapTable; - MaterialRemapTable = NULL; + MaterialRemapTable = nullptr; } } @@ -494,28 +494,28 @@ void MeshSaveClass::Build_Mesh(Mesh & mesh, Mtl *node_mtl, unsigned int *materia int face_index; int pass; int stage; - float *vdata = NULL; + float *vdata = nullptr; int firstSolidColoredMaterial=-1; Builder.Reset(true,mesh.getNumFaces(),mesh.getNumFaces()/3); // Get a pointer to the channel that has alpha values entered by the artist. - // This pointer will be NULL if they didn't use the channel. + // This pointer will be null if they didn't use the channel. vdata = mesh.vertexFloat(ALPHA_VERTEX_CHANNEL); /* ** Get the skin info */ bool is_skin = false; - SkinDataClass * skindata = NULL; - SkinWSMObjectClass * skinobj = NULL; + SkinDataClass * skindata = nullptr; + SkinWSMObjectClass * skinobj = nullptr; get_skin_modifier_objects(&skindata,&skinobj); if ( ((Header.Attributes & W3D_MESH_FLAG_GEOMETRY_TYPE_MASK) == W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN) && - (HTree != NULL) ) + (HTree != nullptr) ) { - is_skin = ((skindata != NULL) && (skinobj != NULL)); + is_skin = ((skindata != nullptr) && (skinobj != nullptr)); } /* @@ -555,11 +555,11 @@ void MeshSaveClass::Build_Mesh(Mesh & mesh, Mtl *node_mtl, unsigned int *materia ** Lookup this face's surface type */ Mtl *mtl_to_use = node_mtl; - if ((node_mtl != NULL) && (node_mtl->NumSubMtls() > 1)) { + if ((node_mtl != nullptr) && (node_mtl->NumSubMtls() > 1)) { mtl_to_use = node_mtl->GetSubMtl (maxface.getMatID() % node_mtl->NumSubMtls()); } - if ((mtl_to_use != NULL) && ((mtl_to_use->ClassID() == GameMaterialClassID) || + if ((mtl_to_use != nullptr) && ((mtl_to_use->ClassID() == GameMaterialClassID) || (mtl_to_use->ClassID() == PS2GameMaterialClassID))) { face.SurfaceType = ((GameMtl *)mtl_to_use)->Get_Surface_Type (); } @@ -659,7 +659,7 @@ void MeshSaveClass::Build_Mesh(Mesh & mesh, Mtl *node_mtl, unsigned int *materia ///@todo: MW: Forced ingoring of uv coordinates if no texture! Is this ok? W3dMapClass *map3d=MaterialDesc.Get_Texture(mat_index,pass,stage); - if (map3d && (uvarray != NULL) && (tvfacearray != NULL)) { + if (map3d && (uvarray != nullptr) && (tvfacearray != nullptr)) { int tvert_index = tvfacearray[face_index].t[max_vert_counter]; tvert = uvarray[tvert_index]; @@ -743,7 +743,7 @@ void MeshSaveClass::Build_Mesh(Mesh & mesh, Mtl *node_mtl, unsigned int *materia // If this is a valid bone, try to find the corresponding bone index in the HTree if ( (skin_bone_index != -1) && (skin_bone_index < skinobj->Num_Bones()) && - (skinobj->BoneTab[skin_bone_index] != NULL) ) + (skinobj->BoneTab[skin_bone_index] != nullptr) ) { face.Verts[vert_counter].BoneIndex = get_htree_bone_index_for_inode(skinobj->BoneTab[skin_bone_index]); } @@ -785,8 +785,8 @@ void MeshSaveClass::Build_Mesh(Mesh & mesh, Mtl *node_mtl, unsigned int *materia *=============================================================================================*/ void MeshSaveClass::get_skin_modifier_objects(SkinDataClass ** skin_data_ptr,SkinWSMObjectClass ** skin_obj_ptr) { - *skin_data_ptr = NULL; - *skin_obj_ptr = NULL; + *skin_data_ptr = nullptr; + *skin_obj_ptr = nullptr; // loop through the references that our node has for (int i = 0; i < MaxINode->NumRefs(); i++) { @@ -794,7 +794,7 @@ void MeshSaveClass::get_skin_modifier_objects(SkinDataClass ** skin_data_ptr,Ski ReferenceTarget *refTarg = MaxINode->GetReference(i); // if the reference is a WSM Derived Object. - if (refTarg != NULL && refTarg->ClassID() == Class_ID(WSM_DERIVOB_CLASS_ID,0)) { + if (refTarg != nullptr && refTarg->ClassID() == Class_ID(WSM_DERIVOB_CLASS_ID,0)) { IDerivedObject * wsm_der_obj = (IDerivedObject *)refTarg; @@ -1060,7 +1060,7 @@ int MeshSaveClass::write_header(ChunkSaveClass & csave) int MeshSaveClass::write_user_text(ChunkSaveClass & csave) { // If there's no user text, just don't write the chunk - if (UserText == NULL) { + if (UserText == nullptr) { return 0; } @@ -1068,7 +1068,7 @@ int MeshSaveClass::write_user_text(ChunkSaveClass & csave) return 1; } - // write the user text buffer (writing one extra byte to include the NULL) + // write the user text buffer (writing one extra byte to include the null terminator) if (csave.Write(UserText,strlen(UserText) + 1) != strlen(UserText) + 1) { return 1; } @@ -1204,7 +1204,7 @@ int MeshSaveClass::write_vert_influences(ChunkSaveClass & csave) { if (((Header.Attributes & W3D_MESH_FLAG_GEOMETRY_TYPE_MASK) != W3D_MESH_FLAG_GEOMETRY_TYPE_SKIN) || !(Header.VertexChannels & W3D_VERTEX_CHANNEL_BONEID) || - (VertInfluences == NULL)) { + (VertInfluences == nullptr)) { return 0; } @@ -1338,7 +1338,7 @@ int MeshSaveClass::write_vertex_materials(ChunkSaveClass & csave) // write the filename const char * name = MaterialDesc.Get_Vertex_Material_Name(i); - if (name != NULL) { + if (name != nullptr) { csave.Begin_Chunk(W3D_CHUNK_VERTEX_MATERIAL_NAME); if (csave.Write(name,strlen(name) + 1) != strlen(name) + 1) { return 1; @@ -1356,7 +1356,7 @@ int MeshSaveClass::write_vertex_materials(ChunkSaveClass & csave) // write the mapper args const char * args = MaterialDesc.Get_Mapper_Args(i, 0); - if (args != NULL) { + if (args != nullptr) { csave.Begin_Chunk(W3D_CHUNK_VERTEX_MAPPER_ARGS0); if (csave.Write(args,strlen(args) + 1) != strlen(args) + 1) { return 1; @@ -1364,7 +1364,7 @@ int MeshSaveClass::write_vertex_materials(ChunkSaveClass & csave) csave.End_Chunk(); } args = MaterialDesc.Get_Mapper_Args(i, 1); - if (args != NULL) { + if (args != nullptr) { csave.Begin_Chunk(W3D_CHUNK_VERTEX_MAPPER_ARGS1); if (csave.Write(args,strlen(args) + 1) != strlen(args) + 1) { return 1; @@ -1559,7 +1559,7 @@ int MeshSaveClass::write_textures(ChunkSaveClass & csave) csave.End_Chunk(); // optionally write an animation info chunk - if (map->AnimInfo != NULL) { + if (map->AnimInfo != nullptr) { csave.Begin_Chunk(W3D_CHUNK_TEXTURE_INFO); if (csave.Write(map->AnimInfo,sizeof(W3dTextureInfoStruct)) != sizeof(W3dTextureInfoStruct)) return 1; csave.End_Chunk(); @@ -1806,7 +1806,7 @@ int MeshSaveClass::scan_used_materials(Mesh & mesh,Mtl * nodemtl) int face_index; int mat_index; - if ((nodemtl == NULL) || (nodemtl->NumSubMtls() <= 1)) { + if ((nodemtl == nullptr) || (nodemtl->NumSubMtls() <= 1)) { MaterialRemapTable = new int[1]; MaterialRemapTable[0] = 0; @@ -1874,7 +1874,7 @@ int MeshSaveClass::getNumSolidMaterials(Mtl * nodemtl) int mat_index; int numSolid=0; - if ((nodemtl == NULL) || (nodemtl->NumSubMtls() <= 1)) + if ((nodemtl == nullptr) || (nodemtl->NumSubMtls() <= 1)) { //Check if diffuse texture present if (isTexturedMaterial(nodemtl)) return 00; @@ -2027,7 +2027,7 @@ void MeshSaveClass::create_materials(Mtl * nodemtl,DWORD wirecolor, char *materi if (isTexturedMaterial(nodemtl) == 0) mat.Init(nodemtl,materialColorTexture); else - mat.Init(nodemtl,NULL); + mat.Init(nodemtl,nullptr); W3dMaterialDescClass::ErrorType err; err = MaterialDesc.Add_Material(mat,nodemtl->GetName()); @@ -2053,7 +2053,7 @@ void MeshSaveClass::create_materials(Mtl * nodemtl,DWORD wirecolor, char *materi if (isTexturedMaterial(nodemtl->GetSubMtl(mi)) == 0) mat.Init(nodemtl->GetSubMtl(mi),materialColorTexture); else - mat.Init(nodemtl->GetSubMtl(mi),NULL); + mat.Init(nodemtl->GetSubMtl(mi),nullptr); char * name; W3dMaterialDescClass::ErrorType err; diff --git a/Core/Tools/WW3D/max2w3d/meshsave.h b/Core/Tools/WW3D/max2w3d/meshsave.h index db46e5549da..4777f987569 100644 --- a/Core/Tools/WW3D/max2w3d/meshsave.h +++ b/Core/Tools/WW3D/max2w3d/meshsave.h @@ -117,7 +117,7 @@ class MeshSaveClass int &numMaterialColors, int &numHouseColors, char * materialColorTexture, - WorldInfoClass * world_info = NULL + WorldInfoClass * world_info = nullptr ); ~MeshSaveClass(void); diff --git a/Core/Tools/WW3D/max2w3d/motion.cpp b/Core/Tools/WW3D/max2w3d/motion.cpp index c6877721475..1d2ab8bf2aa 100644 --- a/Core/Tools/WW3D/max2w3d/motion.cpp +++ b/Core/Tools/WW3D/max2w3d/motion.cpp @@ -88,7 +88,7 @@ MotionClass::MotionClass BasePose(basepose), Scene(scene), RootNode(rootnode), - RootList(NULL), + RootList(nullptr), StartFrame(options.StartFrame), EndFrame(options.EndFrame), ReduceAnimation(options.ReduceAnimation), @@ -135,7 +135,7 @@ MotionClass::MotionClass ): BasePose(basepose), Scene(scene), - RootNode(NULL), + RootNode(nullptr), RootList(rootlist), StartFrame(options.StartFrame), EndFrame(options.EndFrame), @@ -183,18 +183,18 @@ void MotionClass::init(void) ** and an XYZEulers per frame per node. */ MotionMatrix = new Matrix3 * [BasePose->Num_Nodes()]; - if (MotionMatrix == NULL) { + if (MotionMatrix == nullptr) { throw (ErrorClass("Out of Memory")); } EulerDelta = new Point3 * [BasePose->Num_Nodes()]; - if (EulerDelta == NULL) { + if (EulerDelta == nullptr) { throw (ErrorClass("Out of Memory")); } for (i=0; iNum_Nodes(); i++) { MotionMatrix[i] = new Matrix3[NumFrames]; - if (MotionMatrix[i] == NULL) { + if (MotionMatrix[i] == nullptr) { throw (ErrorClass("Out of Memory")); } @@ -208,7 +208,7 @@ void MotionClass::init(void) for (i=0; iNum_Nodes(); i++) { EulerDelta[i] = new Point3[NumFrames]; - if (EulerDelta[i] == NULL) { + if (EulerDelta[i] == nullptr) { throw (ErrorClass("Out of Memory")); } @@ -349,13 +349,13 @@ void MotionClass::compute_frame_motion(int frame) */ HierarchySaveClass * tree; - if (RootNode != NULL) { + if (RootNode != nullptr) { tree = new HierarchySaveClass(RootNode,frametime,*Meter,"NoName",false,BasePose); } else { tree = new HierarchySaveClass(RootList,frametime,*Meter,"NoName",false,BasePose,Offset); } - if (tree == NULL) { + if (tree == nullptr) { throw (ErrorClass("Out of memory!")); } @@ -428,7 +428,7 @@ void MotionClass::compute_frame_motion(int frame) if ((node)&&(vis)) { if (frame != 0) { - // sample previous frame, and an inbetween time + // sample previous frame, and an in between time // to determine if there's a binary movement TimeValue frametime_prev = frametime - GetTicksPerFrame(); diff --git a/Core/Tools/WW3D/max2w3d/namedsel.cpp b/Core/Tools/WW3D/max2w3d/namedsel.cpp index b3a831a9820..62f06758e76 100644 --- a/Core/Tools/WW3D/max2w3d/namedsel.cpp +++ b/Core/Tools/WW3D/max2w3d/namedsel.cpp @@ -43,9 +43,9 @@ NamedSelSetList::~NamedSelSetList() { for (int i=0; i 0)) { + if ((container_name != nullptr) && (strlen(container_name) > 0)) { strcpy(NullData.Name,container_name); strcat(NullData.Name,"."); } diff --git a/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.cpp b/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.cpp index 1c420590cd7..28ef55aea63 100644 --- a/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.cpp +++ b/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.cpp @@ -58,8 +58,8 @@ static const char *BROWSE_FILTER = "W3D Files (*.W3D)\0*.W3D\0WHT Files (*.WHT)\ //////////////////////////////////////////////////////////////////////////////////////// PresetExportOptionsDialogClass::PresetExportOptionsDialogClass (Interface *maxinterface, HWND parent_wnd) : MaxInterface (maxinterface), - Options (NULL), - Wnd (NULL), + Options (nullptr), + Wnd (nullptr), ParentWnd (parent_wnd), CurrentPane (-1) { @@ -107,7 +107,7 @@ PresetExportOptionsDialogClass::Real_Message_Proc LPARAM lparam ) { - PresetExportOptionsDialogClass *dialog_obj = NULL; + PresetExportOptionsDialogClass *dialog_obj = nullptr; // // Setup the framework we need so that the instance @@ -125,7 +125,7 @@ PresetExportOptionsDialogClass::Real_Message_Proc // Allow the instance to handle the call // BOOL retval = FALSE; - if (dialog_obj != NULL) { + if (dialog_obj != nullptr) { retval = dialog_obj->Message_Proc (message, wparam, lparam); } @@ -154,7 +154,7 @@ PresetExportOptionsDialogClass::Settings_Pane_Message_Proc LPARAM lparam ) { - PresetExportOptionsDialogClass *dialog_obj = NULL; + PresetExportOptionsDialogClass *dialog_obj = nullptr; // // Setup the framework we need so that the instance @@ -171,7 +171,7 @@ PresetExportOptionsDialogClass::Settings_Pane_Message_Proc // Allow the instance to handle the call // BOOL retval = FALSE; - if (dialog_obj != NULL) { + if (dialog_obj != nullptr) { retval = dialog_obj->Pane_Message_Proc (message, wparam, lparam); } @@ -213,7 +213,7 @@ PresetExportOptionsDialogClass::Pane_Message_Proc // Update the start frame // ICustEdit *edit_ctrl = GetICustEdit ((HWND)lparam); - if (edit_ctrl != NULL) { + if (edit_ctrl != nullptr) { Options->StartFrame = edit_ctrl->GetInt (); // @@ -234,7 +234,7 @@ PresetExportOptionsDialogClass::Pane_Message_Proc // Update the end frame // ICustEdit *edit_ctrl = GetICustEdit ((HWND)lparam); - if (edit_ctrl != NULL) { + if (edit_ctrl != nullptr) { Options->EndFrame = edit_ctrl->GetInt (); // @@ -255,7 +255,7 @@ PresetExportOptionsDialogClass::Pane_Message_Proc case CC_SPINNER_BUTTONUP: { ISpinnerControl *spin_ctrl = (ISpinnerControl *)lparam; - if (spin_ctrl != NULL) { + if (spin_ctrl != nullptr) { switch (LOWORD (wparam)) { @@ -406,7 +406,7 @@ PresetExportOptionsDialogClass::Message_Proc ::GetWindowRect (Wnd, &rect); int width = parent_rect.right - parent_rect.left; int height = parent_rect.bottom - parent_rect.top; - ::SetWindowPos ( Wnd, NULL, + ::SetWindowPos ( Wnd, nullptr, parent_rect.left + (width / 2) - ((rect.right - rect.left) / 2), parent_rect.top + (height / 2) - ((rect.bottom - rect.top) / 2), 0, 0, SWP_NOZORDER | SWP_NOSIZE); @@ -582,7 +582,7 @@ PresetExportOptionsDialogClass::Destroy_Settings_Panes (void) // for (int index = 0; index < PANE_MAX; index ++) { ::DestroyWindow (PaneWnds[index]); - PaneWnds[index] = NULL; + PaneWnds[index] = nullptr; } return ; @@ -696,10 +696,10 @@ PresetExportOptionsDialogClass::Initialize_Controls (void) // // Are there any animation controls on this pane to initialize? // - if (::GetDlgItem (pane_wnd, IDC_RANGE_LOW_SPIN) != NULL) { + if (::GetDlgItem (pane_wnd, IDC_RANGE_LOW_SPIN) != nullptr) { - ISpinnerControl *low_spin = NULL; - ISpinnerControl *high_spin = NULL; + ISpinnerControl *low_spin = nullptr; + ISpinnerControl *high_spin = nullptr; low_spin = ::SetupIntSpinner (pane_wnd, IDC_RANGE_LOW_SPIN, IDC_RANGE_LOW_EDIT, startframe, endframe, 0); @@ -746,7 +746,7 @@ PresetExportOptionsDialogClass::Update_Controls (void) // Enable/disable the compression settings button // HWND compress_settings_btn = ::GetDlgItem (pane_wnd, IDC_COMPRESSION_SETTINGS); - if (compress_settings_btn != NULL) { + if (compress_settings_btn != nullptr) { ::EnableWindow (compress_settings_btn, Options->CompressAnimation); } @@ -754,7 +754,7 @@ PresetExportOptionsDialogClass::Update_Controls (void) // Setup the skeleton browse button // HWND skeleten_browse_btn = ::GetDlgItem (pane_wnd, IDC_WHT_BROWSE_BUTTON); - if (skeleten_browse_btn != NULL) { + if (skeleten_browse_btn != nullptr) { // // Honor the relative path if it is present @@ -783,13 +783,13 @@ PresetExportOptionsDialogClass::Update_Controls (void) // HWND low_spin_wnd = ::GetDlgItem (pane_wnd, IDC_RANGE_LOW_SPIN); HWND high_spin_wnd = ::GetDlgItem (pane_wnd, IDC_RANGE_HIGH_SPIN); - if (low_spin_wnd != NULL && high_spin_wnd != NULL) { + if (low_spin_wnd != nullptr && high_spin_wnd != nullptr) { // // Peek at the spinner control objects // - ISpinnerControl *low_spin = NULL; - ISpinnerControl *high_spin = NULL; + ISpinnerControl *low_spin = nullptr; + ISpinnerControl *high_spin = nullptr; low_spin = (ISpinnerControl *)::GetProp (low_spin_wnd, "ISpinnerControl"); high_spin = (ISpinnerControl *)::GetProp (high_spin_wnd, "ISpinnerControl"); diff --git a/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.h b/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.h index 96fa0d295b6..321fd501e7a 100644 --- a/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.h +++ b/Core/Tools/WW3D/max2w3d/presetexportoptionsdialog.h @@ -55,7 +55,7 @@ class PresetExportOptionsDialogClass ////////////////////////////////////////////////////////////////// // Public constructors/destructors ////////////////////////////////////////////////////////////////// - PresetExportOptionsDialogClass (Interface *maxinterface, HWND parent_wnd = NULL); + PresetExportOptionsDialogClass (Interface *maxinterface, HWND parent_wnd = nullptr); ~PresetExportOptionsDialogClass (void); diff --git a/Core/Tools/WW3D/max2w3d/rcmenu.cpp b/Core/Tools/WW3D/max2w3d/rcmenu.cpp index 2c8223e5d00..42dc3f852fb 100644 --- a/Core/Tools/WW3D/max2w3d/rcmenu.cpp +++ b/Core/Tools/WW3D/max2w3d/rcmenu.cpp @@ -73,7 +73,7 @@ void RCMenuClass::Init(RightClickMenuManager* manager, HWND hWnd, IPoint2 m) /* ** Add the menu separator */ - manager->AddMenu(this, MF_SEPARATOR, MENU_SEPARATOR, NULL); + manager->AddMenu(this, MF_SEPARATOR, MENU_SEPARATOR, nullptr); /* ** Add the Name of the object diff --git a/Core/Tools/WW3D/max2w3d/simpdib.cpp b/Core/Tools/WW3D/max2w3d/simpdib.cpp index 1c06d62cfcc..2699efa99c6 100644 --- a/Core/Tools/WW3D/max2w3d/simpdib.cpp +++ b/Core/Tools/WW3D/max2w3d/simpdib.cpp @@ -39,18 +39,18 @@ SimpleDIBClass::SimpleDIBClass(HWND hwnd,int width,int height,PaletteClass & pal): IsZombie(false), - Info(NULL), + Info(nullptr), Handle(0), - Pixels(NULL), + Pixels(nullptr), Width(width), Height(height), - PixelBase(NULL), - Pitch(NULL) + PixelBase(nullptr), + Pitch(nullptr) { // Allocate a BITMAPINFO structure Info = (BITMAPINFO *) new char [sizeof(BITMAPINFO) + 256*sizeof(RGBQUAD)]; - if (Info == NULL) { + if (Info == nullptr) { IsZombie = true; return; } @@ -78,7 +78,7 @@ SimpleDIBClass::SimpleDIBClass(HWND hwnd,int width,int height,PaletteClass & pal // Create the DIB. HDC hdc = GetDC(hwnd); - Handle = CreateDIBSection(hdc, Info, DIB_RGB_COLORS,(void**)&Pixels, NULL, 0); + Handle = CreateDIBSection(hdc, Info, DIB_RGB_COLORS,(void**)&Pixels, nullptr, 0); ReleaseDC(hwnd, hdc); if (!Handle) { @@ -91,7 +91,7 @@ SimpleDIBClass::SimpleDIBClass(HWND hwnd,int width,int height,PaletteClass & pal Pitch = (Width + 3) & 0xfffffffC; // Check if the DIB is bottom-up or top-down. - // (it better be top-down, thats what I'm asking for!!!) + // (it better be top-down, that's what I'm asking for!!!) if (Info->bmiHeader.biHeight > 0) { // bottom-up DIB diff --git a/Core/Tools/WW3D/max2w3d/skin.cpp b/Core/Tools/WW3D/max2w3d/skin.cpp index 044a219940b..d16804c9ab4 100644 --- a/Core/Tools/WW3D/max2w3d/skin.cpp +++ b/Core/Tools/WW3D/max2w3d/skin.cpp @@ -63,13 +63,13 @@ static float Bone_Distance(INode * bone,TimeValue time,const Point3 & vertex); /* ** Static variables */ -HWND SkinWSMObjectClass::SotHWND = NULL; -HWND SkinWSMObjectClass::SkeletonHWND = NULL; -HWND SkinWSMObjectClass::BoneListHWND = NULL; -IObjParam * SkinWSMObjectClass::InterfacePtr = NULL; -ICustButton * SkinWSMObjectClass::AddBonesButton = NULL; -ICustButton * SkinWSMObjectClass::RemoveBonesButton = NULL; -ISpinnerControl * SkinWSMObjectClass::BasePoseSpin = NULL; +HWND SkinWSMObjectClass::SotHWND = nullptr; +HWND SkinWSMObjectClass::SkeletonHWND = nullptr; +HWND SkinWSMObjectClass::BoneListHWND = nullptr; +IObjParam * SkinWSMObjectClass::InterfacePtr = nullptr; +ICustButton * SkinWSMObjectClass::AddBonesButton = nullptr; +ICustButton * SkinWSMObjectClass::RemoveBonesButton = nullptr; +ISpinnerControl * SkinWSMObjectClass::BasePoseSpin = nullptr; /******************************************************************************* @@ -154,23 +154,23 @@ SkinWSMObjectClass::SkinWSMObjectClass() BoneTab.SetCount(0); BasePoseFrame = 0; - pblock = NULL; + pblock = nullptr; } SkinWSMObjectClass::~SkinWSMObjectClass(void) { - assert(!((InterfacePtr == NULL) && (SotHWND != NULL))); - if (SotHWND != NULL) { + assert(!((InterfacePtr == nullptr) && (SotHWND != nullptr))); + if (SotHWND != nullptr) { InterfacePtr->UnRegisterDlgWnd(SotHWND); InterfacePtr->DeleteRollupPage(SotHWND); - SotHWND = NULL; + SotHWND = nullptr; } - assert(!((InterfacePtr == NULL) && (SkeletonHWND != NULL))); - if (SkeletonHWND != NULL) { + assert(!((InterfacePtr == nullptr) && (SkeletonHWND != nullptr))); + if (SkeletonHWND != nullptr) { InterfacePtr->UnRegisterDlgWnd(SkeletonHWND); InterfacePtr->DeleteRollupPage(SkeletonHWND); - SkeletonHWND = NULL; + SkeletonHWND = nullptr; } } @@ -186,7 +186,7 @@ void SkinWSMObjectClass::BeginEditParams(IObjParam *ip, ULONG flags,Animatable /* ** Install the "supports objects of type" rollup */ - if (SotHWND == NULL) { + if (SotHWND == nullptr) { SotHWND = ip->AddRollupPage( AppInstance, MAKEINTRESOURCE(IDD_SKIN_SOT), @@ -201,7 +201,7 @@ void SkinWSMObjectClass::BeginEditParams(IObjParam *ip, ULONG flags,Animatable /* ** Install the skeleton rollup */ - if (SkeletonHWND == NULL) { + if (SkeletonHWND == nullptr) { SkeletonHWND = InterfacePtr->AddRollupPage( AppInstance, MAKEINTRESOURCE(IDD_SKELETON_PARAMETERS), @@ -224,26 +224,26 @@ void SkinWSMObjectClass::EndEditParams(IObjParam *ip, ULONG flags,Animatable *ne /* ** Remove the Sot rollup */ - if (SotHWND != NULL) { + if (SotHWND != nullptr) { InterfacePtr->UnRegisterDlgWnd(SotHWND); InterfacePtr->DeleteRollupPage(SotHWND); - SotHWND = NULL; + SotHWND = nullptr; } /* ** Remove the info rollup */ - if (SkeletonHWND != NULL) { + if (SkeletonHWND != nullptr) { InterfacePtr->UnRegisterDlgWnd(SkeletonHWND); InterfacePtr->DeleteRollupPage(SkeletonHWND); - SkeletonHWND = NULL; + SkeletonHWND = nullptr; } } /* ** get rid of our copy of the interface pointer */ - InterfacePtr = NULL; + InterfacePtr = nullptr; } RefTargetHandle SkinWSMObjectClass::Clone(RemapDir & remap) @@ -297,7 +297,7 @@ RefResult SkinWSMObjectClass::NotifyRefChanged(Interval changeInt,RefTargetHandl } if (i < BoneTab.Count()) { BoneTab.Delete(i,1); - // TODO: cause all Modifier objects to re-index to accomodate + // TODO: cause all Modifier objects to re-index to accommodate // the deletion of this bone!! } break; @@ -312,7 +312,7 @@ CreateMouseCallBack * SkinWSMObjectClass::GetCreateMouseCallBack(void) /* ** The "CreateMouseCallback" is used when creating the ** object. Since our object doesn't need an interactive - ** creation phase, we return NULL. + ** creation phase, we return null. */ return &_SkinCreateCB; } @@ -440,11 +440,11 @@ int SkinWSMObjectClass::Add_Bone(INode * node) } /* - ** Otherwise, look for a NULL bone and we'll re-use + ** Otherwise, look for a nullptr bone and we'll re-use ** its slot. This happens when a user removes a bone or ** a bone in the scene is deleted. */ - boneidx = Find_Bone(NULL); + boneidx = Find_Bone(nullptr); if (boneidx != -1) { refidx = To_Ref_Index(boneidx); MakeRefByID(FOREVER,refidx,node); @@ -476,7 +476,7 @@ void SkinWSMObjectClass::Remove_Bone(INode * node) { int boneidx = Find_Bone(node); if (boneidx != -1) { - BoneTab[boneidx] = NULL; + BoneTab[boneidx] = nullptr; DeleteReference(To_Ref_Index(boneidx)); } } @@ -493,7 +493,7 @@ void SkinWSMObjectClass::Remove_Bones(INodeTab & nodetab) void SkinWSMObjectClass::Update_Bone_List(void) { - assert(BoneListHWND != NULL); + assert(BoneListHWND != nullptr); /* ** remove all strings in the bone listbox @@ -504,7 +504,7 @@ void SkinWSMObjectClass::Update_Bone_List(void) ** loop through the bone tab and add the name of each */ for (int i=0; iGetName()); } } @@ -552,7 +552,7 @@ IOResult SkinWSMObjectClass::Load(ILoad * iload) res = iload->Read(&numbones,sizeof(numbones),&nb); BoneTab.SetCount(numbones); for (int i=0; iDeleteMode(SelectMode); if (SelectMode ) delete SelectMode; - SelectMode = NULL; + SelectMode = nullptr; /* ** Remove the rollup window(s) if needed @@ -702,7 +702,7 @@ void SkinModifierClass::EndEditParams(IObjParam *ip, ULONG flags,Animatable *nex /* ** Make sure we don't hang onto an invalid interface */ - InterfacePtr = NULL; + InterfacePtr = nullptr; } Interval SkinModifierClass::Get_Validity(TimeValue t) @@ -732,7 +732,7 @@ RefTargetHandle SkinModifierClass::GetReference(int i) switch (i) { case OBJ_REF: return WSMObjectRef; case NODE_REF: return WSMNodeRef; - default: return NULL; + default: return nullptr; } } @@ -780,7 +780,7 @@ void SkinModifierClass::ModifyObject(TimeValue t, ModContext & mc, ObjectState * ** If there is no skin data, allocate it ** Also, do an initial auto attach. */ - if (skindata == NULL) { + if (skindata == nullptr) { mc.localData = skindata = new SkinDataClass(&triobj->mesh); } @@ -813,8 +813,8 @@ void SkinModifierClass::ModifyObject(TimeValue t, ModContext & mc, ObjectState * // TODO: Allow multiple bone influences here... // issues - UI to set the weights, rebalance weights whenever - // a bone is deleted, should also then never get NULL bones - // and remove the need to check for NULL bones in this routine... + // a bone is deleted, should also then never get nullptr bones + // and remove the need to check for nullptr bones in this routine... /* ** Get a pointer to the bone that this vertex is attached to @@ -826,7 +826,7 @@ void SkinModifierClass::ModifyObject(TimeValue t, ModContext & mc, ObjectState * INode * bone = WSMObjectRef->Get_Bone(inf->BoneIdx[0]); - if (bone == NULL) { + if (bone == nullptr) { /* ** this bone has gone away for some reason so ** clear this vert's bone influence index @@ -932,7 +932,7 @@ IOResult SkinModifierClass::LoadLocalData(ILoad *iload, LocalModData **pld) /* ** Create a new SkinDataClass */ - if (*pld==NULL) { + if (*pld==nullptr) { *pld = (SkinDataClass *) new SkinDataClass(); } SkinDataClass * newskin = (SkinDataClass *)*pld; @@ -961,7 +961,7 @@ void SkinModifierClass::ActivateSubobjSel(int level, XFormModes & modes) break; case VERTEX_SEL_LEVEL: // Modifying Vertices - modes = XFormModes(NULL,NULL,NULL,NULL,NULL,SelectMode); + modes = XFormModes(nullptr,nullptr,nullptr,nullptr,nullptr,SelectMode); Install_Bone_Influence_Dialog(); break; } @@ -1048,7 +1048,7 @@ int SkinModifierClass::HitTest ** Remember that we are always turning on vertex hit testing; ** if we were testing for edges, index would be the edge index. */ - vpt->LogHit(inode,mc,rec->dist,rec->index,NULL); + vpt->LogHit(inode,mc,rec->dist,rec->index,nullptr); rec = rec->Next(); } @@ -1066,7 +1066,7 @@ int SkinModifierClass::HitTest void SkinModifierClass::SelectSubComponent(HitRecord *hitRec, BOOL selected, BOOL all, BOOL invert) { - SkinDataClass * skindata = NULL; + SkinDataClass * skindata = nullptr; int count = 0; switch (SubObjSelLevel) { @@ -1129,7 +1129,7 @@ void SkinModifierClass::ClearSelection(int selLevel) SkinDataClass * skindata = (SkinDataClass *)mcList[i]->localData; - if (skindata==NULL) continue; + if (skindata==nullptr) continue; ObjectState os = nodes[i]->EvalWorldState(InterfacePtr->GetTime()); TriObject * tobj = Get_Tri_Object(InterfacePtr->GetTime(),os,valid,needsdel); @@ -1185,7 +1185,7 @@ void SkinModifierClass::SelectAll(int selLevel) SkinDataClass * skindata = (SkinDataClass *)mclist[i]->localData; - if (skindata==NULL) continue; + if (skindata==nullptr) continue; ObjectState os = nodes[i]->EvalWorldState(InterfacePtr->GetTime()); TriObject * tobj = Get_Tri_Object(InterfacePtr->GetTime(),os,valid,needsdel); @@ -1239,7 +1239,7 @@ void SkinModifierClass::InvertSelection(int selLevel) SkinDataClass * skindata = (SkinDataClass *)mclist[i]->localData; - if (skindata==NULL) continue; + if (skindata==nullptr) continue; ObjectState os = nodes[i]->EvalWorldState(InterfacePtr->GetTime()); TriObject * tobj = Get_Tri_Object(InterfacePtr->GetTime(),os,valid,needsdel); @@ -1283,13 +1283,13 @@ void SkinModifierClass::InvertSelection(int selLevel) void SkinModifierClass::User_Picked_Bone(INode * node) { - assert(InterfacePtr != NULL); + assert(InterfacePtr != nullptr); /* ** Get a pointer to the ModContext and SkinData for ** the mesh currently being messed with. */ - ModContext * mc = NULL; + ModContext * mc = nullptr; ModContextList mclist; INodeTab nodelist; @@ -1302,7 +1302,7 @@ void SkinModifierClass::User_Picked_Bone(INode * node) ** don't */ mc = mclist[0]; - assert(mc != NULL); + assert(mc != nullptr); SkinDataClass * skindata = (SkinDataClass *)(mc->localData); /* @@ -1340,7 +1340,7 @@ void SkinModifierClass::ActivateSubSelSet(TSTR & setname) ModContextList mclist; INodeTab nodes; - if (InterfacePtr == NULL) return; + if (InterfacePtr == nullptr) return; InterfacePtr->GetModContexts(mclist,nodes); @@ -1398,16 +1398,16 @@ void SkinModifierClass::Create_Named_Selection_Sets(void) ** This function creates a named selection set of vertices ** for each bone in the skeleton. */ - if (InterfacePtr == NULL) return; + if (InterfacePtr == nullptr) return; SkinWSMObjectClass * skinobj = WSMObjectRef; - if (skinobj == NULL) return; + if (skinobj == nullptr) return; ModContextList mclist; INodeTab nodes; InterfacePtr->GetModContexts(mclist,nodes); SkinDataClass * skindata = (SkinDataClass *)mclist[0]->localData; - if (skindata == NULL) return; + if (skindata == nullptr) return; /* ** Clear out the old selection sets @@ -1419,7 +1419,7 @@ void SkinModifierClass::Create_Named_Selection_Sets(void) */ for (int boneidx = 0; boneidx < skinobj->Num_Bones(); boneidx++) { - if (skinobj->Get_Bone(boneidx) != NULL) { + if (skinobj->Get_Bone(boneidx) != nullptr) { BitArray boneverts; boneverts.SetSize(skindata->VertData.Count()); @@ -1445,13 +1445,13 @@ void SkinModifierClass::Install_Named_Selection_Sets(void) ** If we are in sub-object selection mode add the sets ** to the drop down box. */ - if ((SubObjSelLevel == VERTEX_SEL_LEVEL) && (InterfacePtr != NULL)) { + if ((SubObjSelLevel == VERTEX_SEL_LEVEL) && (InterfacePtr != nullptr)) { ModContextList mclist; INodeTab nodes; InterfacePtr->GetModContexts(mclist,nodes); SkinDataClass * skindata = (SkinDataClass *)mclist[0]->localData; - if (skindata == NULL) return; + if (skindata == nullptr) return; InterfacePtr->ClearSubObjectNamedSelSets(); for (int i=0; i < skindata->VertSelSets.Count(); i++) { @@ -1473,13 +1473,13 @@ void SkinModifierClass::Auto_Attach_Verts(BOOL all) INodeTab nodes; InterfacePtr->GetModContexts(mclist,nodes); SkinDataClass * skindata = (SkinDataClass *)mclist[0]->localData; - if (skindata == NULL) return; + if (skindata == nullptr) return; /* ** get the skin WSM object. */ SkinWSMObjectClass * skinobj = WSMObjectRef; - if (skinobj == NULL) return; + if (skinobj == nullptr) return; /* ** Get a triobject representing the object state in the base pose. @@ -1536,7 +1536,7 @@ void SkinModifierClass::Unlink_Verts(void) INodeTab nodes; InterfacePtr->GetModContexts(mclist,nodes); SkinDataClass * skindata = (SkinDataClass *)mclist[0]->localData; - if (skindata == NULL) return; + if (skindata == nullptr) return; /* ** Unlink each selected vertex (give them bone index -1) @@ -1573,7 +1573,7 @@ void SkinModifierClass::Unlink_Verts(void) void SkinModifierClass::Install_Bone_Influence_Dialog(void) { - if (BoneInfluenceHWND != NULL) return; + if (BoneInfluenceHWND != nullptr) return; /* ** loading resource string for the name of the dialog @@ -1603,10 +1603,10 @@ void SkinModifierClass::Remove_Bone_Influence_Dialog(void) /* ** If it is currently up, remove the bone influences dialog */ - if (BoneInfluenceHWND != NULL) { + if (BoneInfluenceHWND != nullptr) { InterfacePtr->UnRegisterDlgWnd(BoneInfluenceHWND); InterfacePtr->DeleteRollupPage(BoneInfluenceHWND); - BoneInfluenceHWND = NULL; + BoneInfluenceHWND = nullptr; } } @@ -1692,10 +1692,10 @@ BOOL SkinWSMObjectClass::Skeleton_Dialog_Proc(HWND hWnd,UINT message,WPARAM wPar ReleaseICustButton(RemoveBonesButton); ReleaseISpinner(BasePoseSpin); - AddBonesButton = NULL; - RemoveBonesButton = NULL; - BasePoseSpin = NULL; - BoneListHWND = NULL; + AddBonesButton = nullptr; + RemoveBonesButton = nullptr; + BasePoseSpin = nullptr; + BoneListHWND = nullptr; return FALSE; @@ -1798,10 +1798,10 @@ BOOL SkinModifierClass::Bone_Influence_Dialog_Proc(HWND hWnd,UINT message,WPARAM ReleaseICustButton(AutoLinkButton); ReleaseICustButton(UnLinkButton); - LinkButton = NULL; - LinkByNameButton = NULL; - AutoLinkButton = NULL; - UnLinkButton = NULL; + LinkButton = nullptr; + LinkByNameButton = nullptr; + AutoLinkButton = nullptr; + UnLinkButton = nullptr; return FALSE; case WM_LBUTTONDOWN: @@ -1818,7 +1818,7 @@ BOOL SkinModifierClass::Bone_Influence_Dialog_Proc(HWND hWnd,UINT message,WPARAM /* ** user picks a bone out of the scene to link to. */ - assert(WSMObjectRef != NULL); + assert(WSMObjectRef != nullptr); INodeTab * bonetab = &(WSMObjectRef->Get_Bone_List()); TheBonePicker.Set_User(this,TRUE,bonetab); InterfacePtr->SetPickMode(&TheBonePicker); @@ -1830,7 +1830,7 @@ BOOL SkinModifierClass::Bone_Influence_Dialog_Proc(HWND hWnd,UINT message,WPARAM /* ** pop up a bone selection dialog */ - assert(WSMObjectRef != NULL); + assert(WSMObjectRef != nullptr); INodeTab * bonetab = &(WSMObjectRef->Get_Bone_List()); TheBonePicker.Set_User(this,TRUE,bonetab); InterfacePtr->DoHitByNameDialog(&TheBonePicker); @@ -1870,7 +1870,7 @@ static TriObject * Get_Tri_Object(TimeValue t,ObjectState & os,Interval & valid, return tobj; } } - return NULL; + return nullptr; } diff --git a/Core/Tools/WW3D/max2w3d/skin.h b/Core/Tools/WW3D/max2w3d/skin.h index ff5f7baf2a6..afc1fc941d9 100644 --- a/Core/Tools/WW3D/max2w3d/skin.h +++ b/Core/Tools/WW3D/max2w3d/skin.h @@ -237,7 +237,7 @@ class SkinModifierClass : public Modifier, BonePickerUserClass RefResult NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, PartID& partID, RefMessage message); void BeginEditParams(IObjParam *ip, ULONG flags,Animatable *prev); void EndEditParams(IObjParam *ip, ULONG flags,Animatable *next); - CreateMouseCallBack * GetCreateMouseCallBack() { return NULL; } + CreateMouseCallBack * GetCreateMouseCallBack() { return nullptr; } /* ** From Reference Maker. These three functions give access to the "virtual array" of references. diff --git a/Core/Tools/WW3D/max2w3d/util.cpp b/Core/Tools/WW3D/max2w3d/util.cpp index d5946a9ea43..7877a9620fb 100644 --- a/Core/Tools/WW3D/max2w3d/util.cpp +++ b/Core/Tools/WW3D/max2w3d/util.cpp @@ -57,7 +57,7 @@ static char _string[256]; static int get_geometry_type(INode * node) { - assert(node != NULL); + assert(node != nullptr); return W3DAppData2Struct::Get_App_Data(node)->Get_Geometry_Type(); //return (get_w3d_bits(node) & GEO_TYPE_MASK); @@ -151,9 +151,9 @@ void Split_Node_Name(const char * name,char * set_base,char * set_exten,int * se assert(strlen(name) < MAX_NODE_NAME_LEN); // Initialize - if (set_base != NULL) set_base[0] = 0; - if (set_exten != NULL) set_exten[0] = 0; - if (set_exten_index != NULL) *set_exten_index = 0; + if (set_base != nullptr) set_base[0] = 0; + if (set_exten != nullptr) set_exten[0] = 0; + if (set_exten_index != nullptr) *set_exten_index = 0; // Get the base name strncpy(buf,name,MAX_NODE_NAME_LEN); @@ -166,20 +166,20 @@ void Split_Node_Name(const char * name,char * set_base,char * set_exten,int * se // copy what we have so far into set_base *ptr = 0; - if (set_base != NULL) strncpy(set_base,buf,MAX_NODE_NAME_LEN); + if (set_base != nullptr) strncpy(set_base,buf,MAX_NODE_NAME_LEN); // copy the rest back into the extension ptr++; - if (set_exten != NULL) strncpy(set_exten,ptr,MAX_NODE_NAME_LEN); + if (set_exten != nullptr) strncpy(set_exten,ptr,MAX_NODE_NAME_LEN); // now get the extension index ptr++; - if (set_exten_index != NULL) *set_exten_index = atoi(ptr); + if (set_exten_index != nullptr) *set_exten_index = atoi(ptr); } else { // no extension, just copy the base name - if (set_base != NULL) strncpy(set_base,buf,MAX_NODE_NAME_LEN); + if (set_base != nullptr) strncpy(set_base,buf,MAX_NODE_NAME_LEN); return; } } @@ -187,7 +187,7 @@ void Split_Node_Name(const char * name,char * set_base,char * set_exten,int * se bool Append_Lod_Character (char *meshname, int lod_level, INodeListClass *origin_list) { - if (meshname == NULL || lod_level < 0) + if (meshname == nullptr || lod_level < 0) return false; if (!origin_list) @@ -200,7 +200,7 @@ bool Append_Lod_Character (char *meshname, int lod_level, INodeListClass *origin ** If there is, we will append the current LOD level digit to the name. ** If there is not, the name will not be modified. */ - INode *conflict = NULL, *cur_origin = NULL; + INode *conflict = nullptr, *cur_origin = nullptr; int i, lod; for (i = 0; i < num_lods; i++) { @@ -253,10 +253,10 @@ void Create_Full_Path(char *full_path, const char *curr, const char *rel_path) // Copy current dir to full path. If it doesn't end with a slash, add one. strcpy(full_path, curr); int curr_len = strlen(curr); - char *full_p = full_path + curr_len; // Point at the terminating NULL + char *full_p = full_path + curr_len; // Point at the terminating nullptr if (curr_len == 0 ||(*(full_p - 1) != '/' && *(full_p - 1) != '\\')) { *full_p = '\\'; - *(++full_p) = '\000'; // Point at the terminating NULL + *(++full_p) = '\000'; // Point at the terminating nullptr } // Scan "..\"s at the beginning of the rel path, scan backwards on the @@ -312,7 +312,7 @@ void Create_Relative_Path(char *rel_path, const char *curr, const char *full_pat goto end; } - // The first different character for each string can be: a NULL, a slash, + // The first different character for each string can be: a nullptr, a slash, // or an ordinary character. PathCharType full_type, curr_type; if (*full_p == '\000') { @@ -333,14 +333,14 @@ void Create_Relative_Path(char *rel_path, const char *curr, const char *full_pat curr_type = PLAIN_CHAR; } } - // If the last fullpath char is a NULL or both are slashes, we have an + // If the last fullpath char is a nullptr or both are slashes, we have an // error - return full path if (full_type == NULL_CHAR || (full_type == SLASH_CHAR && curr_type == SLASH_CHAR)) { strcpy(rel_path, up_full); goto end; } - // If the current path has ended (last char is a NULL) and the full path's + // If the current path has ended (last char is a nullptr) and the full path's // last char is a slash, then just copy the remainder of the full path // (w/o the slash) to the relative path, and exit. if (curr_type == NULL_CHAR && full_type == SLASH_CHAR) { @@ -351,7 +351,7 @@ void Create_Relative_Path(char *rel_path, const char *curr, const char *full_pat // If one of following holds: // 1) One of the last chars is a slash and the other is a plain char - // 2) The current path has ended (last char is NULL) and the last char + // 2) The current path has ended (last char is nullptr) and the last char // of the full path is a plain char // 3) The last char of both are plain chars and the previous char is not a // slash @@ -410,7 +410,7 @@ void Create_Relative_Path(char *rel_path, const char *curr, const char *full_pat bool Is_Full_Path(char * path) { // first scan for a drive letter (scan for a colon) - if (strchr(path,':') != NULL) { + if (strchr(path,':') != nullptr) { return true; } @@ -452,7 +452,7 @@ bool Is_Max_Tri_Mesh(INode * node) bool Is_Damage_Root(INode *node) { - if (node == NULL) + if (node == nullptr) return false; // Is the node's parent the scene root? @@ -584,11 +584,11 @@ int Get_Damage_State(INode *node) INode *Find_Named_Node(char *nodename, INode *root) { if (!root || !nodename) - return NULL; + return nullptr; // Perform a breadth-first search of the tree for a node // of the given name. - INode *child = NULL; + INode *child = nullptr; int i; char cur_name[W3D_NAME_LEN]; @@ -617,6 +617,6 @@ INode *Find_Named_Node(char *nodename, INode *root) } // Didn't find the node anywhere. - return NULL; + return nullptr; } diff --git a/Core/Tools/WW3D/max2w3d/util.h b/Core/Tools/WW3D/max2w3d/util.h index 96eb55e03ff..bbeeab83597 100644 --- a/Core/Tools/WW3D/max2w3d/util.h +++ b/Core/Tools/WW3D/max2w3d/util.h @@ -99,14 +99,14 @@ INode *Find_Named_Node (char *nodename, INode *root); /* ** Macros */ -#define SAFE_DELETE(pobject) \ - if (pobject) { \ - delete pobject; \ - pobject = NULL; \ - } \ - -#define SAFE_DELETE_ARRAY(pobject) \ - if (pobject) { \ - delete [] pobject; \ - pobject = NULL; \ - } \ +#define SAFE_DELETE(pobject) \ + if (pobject) { \ + delete pobject; \ + pobject = nullptr; \ + } + +#define SAFE_DELETE_ARRAY(pobject) \ + if (pobject) { \ + delete [] pobject; \ + pobject = nullptr; \ + } diff --git a/Core/Tools/WW3D/max2w3d/vchannel.cpp b/Core/Tools/WW3D/max2w3d/vchannel.cpp index 8392aaded4c..f0f9fe61a9c 100644 --- a/Core/Tools/WW3D/max2w3d/vchannel.cpp +++ b/Core/Tools/WW3D/max2w3d/vchannel.cpp @@ -85,8 +85,8 @@ VectorChannelClass::VectorChannelClass MaxFrames(maxframes), VectorLen(vectorlength), IsEmpty(true), - IdentVect(NULL), - Data(NULL), + IdentVect(nullptr), + Data(nullptr), Begin(0), End(0), ReduceAnimation(false), @@ -173,7 +173,7 @@ bool VectorChannelClass::SaveTimeCoded(ChunkSaveClass & csave, BitChannelClass * W3dTimeCodedAnimChannelStruct * chn = (W3dTimeCodedAnimChannelStruct *)malloc(channelsize); - if (chn == NULL) { + if (chn == nullptr) { return false; } @@ -240,7 +240,7 @@ bool VectorChannelClass::SaveTimeCoded(ChunkSaveClass & csave, BitChannelClass * return false; } - if (chn != NULL) { + if (chn != nullptr) { free(chn); } @@ -439,7 +439,7 @@ bool VectorChannelClass::SaveAdaptiveDelta(ChunkSaveClass & csave, BitChannelCla W3dAdaptiveDeltaAnimChannelStruct * chn = (W3dAdaptiveDeltaAnimChannelStruct *)malloc(channelsize); - if (chn == NULL) { + if (chn == nullptr) { return false; } @@ -563,7 +563,7 @@ bool VectorChannelClass::SaveAdaptiveDelta(ChunkSaveClass & csave, BitChannelCla return false; } - if (chn != NULL) { + if (chn != nullptr) { free(chn); } @@ -629,7 +629,7 @@ bool VectorChannelClass::Save(ChunkSaveClass & csave, BitChannelClass *binmov) W3dAnimChannelStruct * chn = (W3dAnimChannelStruct *)malloc(channelsize); - if (chn == NULL) { + if (chn == nullptr) { return false; } @@ -652,7 +652,7 @@ bool VectorChannelClass::Save(ChunkSaveClass & csave, BitChannelClass *binmov) return false; } - if (chn != NULL) { + if (chn != nullptr) { free(chn); } diff --git a/Core/Tools/WW3D/max2w3d/vxl.cpp b/Core/Tools/WW3D/max2w3d/vxl.cpp index 969095a7b2d..1a0b35d4622 100644 --- a/Core/Tools/WW3D/max2w3d/vxl.cpp +++ b/Core/Tools/WW3D/max2w3d/vxl.cpp @@ -96,7 +96,7 @@ VoxelClass::VoxelClass // Allocate visibility flags array VisData = new uint8[XDim * YDim * ZDim]; - if (VisData == NULL) { + if (VisData == nullptr) { throw ErrorClass("out of memory!"); } @@ -163,7 +163,7 @@ VoxelClass::VoxelClass ************************************************************************/ VoxelClass::~VoxelClass() { - if (VisData != NULL) delete[] VisData; + if (VisData != nullptr) delete[] VisData; } diff --git a/Core/Tools/WW3D/max2w3d/vxldbg.cpp b/Core/Tools/WW3D/max2w3d/vxldbg.cpp index bbe844fa81d..a6c405c00a4 100644 --- a/Core/Tools/WW3D/max2w3d/vxldbg.cpp +++ b/Core/Tools/WW3D/max2w3d/vxldbg.cpp @@ -49,11 +49,11 @@ static PaletteClass _VoxelPalette; VoxelDebugWindowClass::VoxelDebugWindowClass(VoxelClass * vxl) : CurLayer(0), - Bitmap(NULL), + Bitmap(nullptr), Voxel(vxl), WindowHWND(0), ViewportHWND(0), - LayerSpin(NULL) + LayerSpin(nullptr) { _VoxelPalette[0] = RGBClass(0,0,0); _VoxelPalette[1] = RGBClass(128,255,128); @@ -70,7 +70,7 @@ void VoxelDebugWindowClass::Display_Window(void) ( AppInstance, MAKEINTRESOURCE (IDD_VOXEL_DEBUG_DIALOG), - NULL, + nullptr, (DLGPROC) _dialog_proc, (LPARAM) this ); @@ -120,7 +120,7 @@ bool VoxelDebugWindowClass::Dialog_Proc update_display(); - SetCursor(LoadCursor (NULL, IDC_ARROW)); + SetCursor(LoadCursor (nullptr, IDC_ARROW)); return 1; @@ -137,7 +137,7 @@ bool VoxelDebugWindowClass::Dialog_Proc case IDOK: // done! - SetCursor(LoadCursor (NULL, IDC_WAIT)); + SetCursor(LoadCursor (nullptr, IDC_WAIT)); EndDialog(hWnd, 1); break; } @@ -187,7 +187,7 @@ void VoxelDebugWindowClass::update_display(void) /* ** Bail out if everything isn't right */ - if ((Bitmap == NULL) || (Voxel == NULL)) { + if ((Bitmap == nullptr) || (Voxel == nullptr)) { return; } @@ -241,7 +241,7 @@ BOOL CALLBACK _dialog_proc LPARAM lParam ) { - static VoxelDebugWindowClass * window = NULL; + static VoxelDebugWindowClass * window = nullptr; if (message == WM_INITDIALOG) { window = (VoxelDebugWindowClass *) lParam; diff --git a/Core/Tools/WW3D/max2w3d/w3d_file.h b/Core/Tools/WW3D/max2w3d/w3d_file.h index 06e474e83af..0f17c36a129 100644 --- a/Core/Tools/WW3D/max2w3d/w3d_file.h +++ b/Core/Tools/WW3D/max2w3d/w3d_file.h @@ -46,10 +46,10 @@ NAMING CONVENTIONS: - Typical render object name is 15 characters + NULL - Meshes have 31 + NULL character name formed from the concatenation of the "container" + Typical render object name is 15 characters + null terminator + Meshes have 31 + null terminator character name formed from the concatenation of the "container" model name and the mesh's name: "ContainerName.MeshName" - Animations have 31 + NULL character names formed from the concatenation of the Hierarchy tree + Animations have 31 + null terminator character names formed from the concatenation of the Hierarchy tree name with the animation name: "AnimationName.HierarchyName" Textures have unlimited name length. Typically you can determine which 'W3D' file a render object came from by looking @@ -352,14 +352,14 @@ enum { W3D_CHUNK_VERTEX_MATERIALS =0x0000002A, // wraps the vertex materials W3D_CHUNK_VERTEX_MATERIAL =0x0000002B, - W3D_CHUNK_VERTEX_MATERIAL_NAME =0x0000002C, // vertex material name (NULL-terminated string) + W3D_CHUNK_VERTEX_MATERIAL_NAME =0x0000002C, // vertex material name (null-terminated string) W3D_CHUNK_VERTEX_MATERIAL_INFO =0x0000002D, // W3dVertexMaterialStruct W3D_CHUNK_VERTEX_MAPPER_ARGS0 =0x0000002E, // Null-terminated string W3D_CHUNK_VERTEX_MAPPER_ARGS1 =0x0000002F, // Null-terminated string W3D_CHUNK_TEXTURES =0x00000030, // wraps all of the texture info W3D_CHUNK_TEXTURE =0x00000031, // wraps a texture definition - W3D_CHUNK_TEXTURE_NAME =0x00000032, // texture filename (NULL-terminated string) + W3D_CHUNK_TEXTURE_NAME =0x00000032, // texture filename (null-terminated string) W3D_CHUNK_TEXTURE_INFO =0x00000033, // optional W3dTextureInfoStruct W3D_CHUNK_MATERIAL_PASS =0x00000038, // wraps the information for a single material pass @@ -466,7 +466,7 @@ enum { W3D_CHUNK_SPHERE, W3D_CHUNK_RING, - W3D_CHUNK_NULL_OBJECT =0x00000750, // defines a NULL object (W3dNullObjectStruct) + W3D_CHUNK_NULL_OBJECT =0x00000750, // defines a null object (W3dNullObjectStruct) W3D_CHUNK_LIGHTSCAPE =0x00000800, // wrapper for lights created with Lightscape. W3D_CHUNK_LIGHTSCAPE_LIGHT, // definition of a light created with Lightscape. @@ -593,7 +593,7 @@ struct W3dRGBAStruct // MATERIALS // // Surrender 1.40 significantly changed the way that materials are described. To -// accomodate this, the w3d file format has changed since there are new features and +// accommodate this, the w3d file format has changed since there are new features and // optimizations that we want to take advangage of. // // The VertexMaterial defines parameters which control the calculation of the primary @@ -1985,11 +1985,11 @@ struct W3dHLodSubObjectStruct #define W3D_BOX_ATTRIBUTE_ALIGNED 0x00000002 #define W3D_BOX_ATTRIBUTE_COLLISION_TYPE_MASK 0x00000FF0 // mask for the collision type bits #define W3D_BOX_ATTRIBUTE_COLLISION_TYPE_SHIFT 4 // shifting to get to the collision type bits -#define W3D_BOX_ATTRIBTUE_COLLISION_TYPE_PHYSICAL 0x00000010 // physical collisions -#define W3D_BOX_ATTRIBTUE_COLLISION_TYPE_PROJECTILE 0x00000020 // projectiles (rays) collide with this -#define W3D_BOX_ATTRIBTUE_COLLISION_TYPE_VIS 0x00000040 // vis rays collide with this mesh -#define W3D_BOX_ATTRIBTUE_COLLISION_TYPE_CAMERA 0x00000080 // cameras collide with this mesh -#define W3D_BOX_ATTRIBTUE_COLLISION_TYPE_VEHICLE 0x00000100 // vehicles collide with this mesh +#define W3D_BOX_ATTRIBUTE_COLLISION_TYPE_PHYSICAL 0x00000010 // physical collisions +#define W3D_BOX_ATTRIBUTE_COLLISION_TYPE_PROJECTILE 0x00000020 // projectiles (rays) collide with this +#define W3D_BOX_ATTRIBUTE_COLLISION_TYPE_VIS 0x00000040 // vis rays collide with this mesh +#define W3D_BOX_ATTRIBUTE_COLLISION_TYPE_CAMERA 0x00000080 // cameras collide with this mesh +#define W3D_BOX_ATTRIBUTE_COLLISION_TYPE_VEHICLE 0x00000100 // vehicles collide with this mesh struct W3dBoxStruct { @@ -2006,7 +2006,7 @@ struct W3dBoxStruct /******************************************************************************** - NULL Objects + Null Objects Null objects are used by the LOD system to make meshes dissappear at lower levels of detail. diff --git a/Core/Tools/WW3D/max2w3d/w3d_obsolete.h b/Core/Tools/WW3D/max2w3d/w3d_obsolete.h index 6d36fd2ac2b..d9b6c901ea0 100644 --- a/Core/Tools/WW3D/max2w3d/w3d_obsolete.h +++ b/Core/Tools/WW3D/max2w3d/w3d_obsolete.h @@ -80,9 +80,9 @@ enum ///////////////////////////////////////////////////////////////////////////////////////////// struct W3dMaterialStruct { - char MaterialName[W3D_NAME_LEN]; // name of the material (NULL terminated) - char PrimaryName[W3D_NAME_LEN]; // primary texture name (NULL terminated) - char SecondaryName[W3D_NAME_LEN]; // secondary texture name (NULL terminated) + char MaterialName[W3D_NAME_LEN]; // name of the material (null-terminated) + char PrimaryName[W3D_NAME_LEN]; // primary texture name (null-terminated) + char SecondaryName[W3D_NAME_LEN]; // secondary texture name (null-terminated) uint32 RenderFlags; // Rendering flags uint8 Red; // Rgb colors uint8 Green; @@ -94,9 +94,9 @@ struct W3dMaterialStruct ///////////////////////////////////////////////////////////////////////////////////////////// struct W3dMaterial2Struct { - char MaterialName[W3D_NAME_LEN]; // name of the material (NULL terminated) - char PrimaryName[W3D_NAME_LEN]; // primary texture name (NULL terminated) - char SecondaryName[W3D_NAME_LEN]; // secondary texture name (NULL terminated) + char MaterialName[W3D_NAME_LEN]; // name of the material (null-terminated) + char PrimaryName[W3D_NAME_LEN]; // primary texture name (null-terminated) + char SecondaryName[W3D_NAME_LEN]; // secondary texture name (null-terminated) uint32 RenderFlags; // Rendering flags uint8 Red; // Rgb colors uint8 Green; diff --git a/Core/Tools/WW3D/max2w3d/w3dappdata.cpp b/Core/Tools/WW3D/max2w3d/w3dappdata.cpp index 5800a967a90..5ac137255da 100644 --- a/Core/Tools/WW3D/max2w3d/w3dappdata.cpp +++ b/Core/Tools/WW3D/max2w3d/w3dappdata.cpp @@ -213,7 +213,7 @@ W3DAppData2Struct * W3DAppData2Struct::Get_App_Data /* ** Try to get our AppData which has the export flags */ - W3DAppData2Struct * wdata = NULL; + W3DAppData2Struct * wdata = nullptr; AppDataChunk * appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,W3D_APPDATA_2); /* @@ -294,7 +294,7 @@ W3DDazzleAppDataStruct * W3DDazzleAppDataStruct::Get_App_Data(INode * node,bool /* ** Try to get the existing AppData chunk */ - W3DDazzleAppDataStruct * dazzledata = NULL; + W3DDazzleAppDataStruct * dazzledata = nullptr; AppDataChunk * appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,W3D_DAZZLE_APPDATA); if (appdata) { @@ -330,7 +330,7 @@ W3DDazzleAppDataStruct * W3DDazzleAppDataStruct::Get_App_Data(INode * node,bool static int get_geometry_type(INode * node) { - assert(node != NULL); + assert(node != nullptr); return W3DAppData2Struct::Get_App_Data(node)->Get_Geometry_Type(); } @@ -489,10 +489,10 @@ bool Is_Skin(INode * node) ReferenceTarget *refTarg = node->GetReference(i); - if (refTarg != NULL && refTarg->ClassID() == Class_ID(WSM_DERIVOB_CLASS_ID,0)) { + if (refTarg != nullptr && refTarg->ClassID() == Class_ID(WSM_DERIVOB_CLASS_ID,0)) { IDerivedObject * wsm_der_obj = (IDerivedObject *)refTarg; - //MessageBox(NULL, "WSM found", _T("WSM"), MB_OK); + //MessageBox(nullptr, "WSM found", _T("WSM"), MB_OK); for (int j = 0; j < wsm_der_obj->NumModifiers(); j++) { Modifier * mod = wsm_der_obj->GetModifier(j); @@ -683,7 +683,7 @@ bool Is_Vehicle_Collision(INode * node) * * * WARNINGS: * * This has nothing to do with its hidden status inside of max. Things hidden in max are * - * ignored by the exporter. (artist request way back...wierd huh?) * + * ignored by the exporter. (artist request way back...weird huh?) * * * * HISTORY: * * 11/18/98 GTH : Created. * diff --git a/Core/Tools/WW3D/max2w3d/w3dappdata.h b/Core/Tools/WW3D/max2w3d/w3dappdata.h index a79acf429ac..23eb9e86b96 100644 --- a/Core/Tools/WW3D/max2w3d/w3dappdata.h +++ b/Core/Tools/WW3D/max2w3d/w3dappdata.h @@ -58,7 +58,7 @@ ** structure! ** ** - There are bits stored in AppData for each node -** - These bits indicate wether something should be exported as hierarchy, +** - These bits indicate whether something should be exported as hierarchy, ** geometry (and if so, what type of geometry: mesh, collision box, bitmap, etc) ** ** When we say something is "Hierarchy" that means its transform should be put @@ -118,7 +118,7 @@ bool Is_NPatchable(INode * node); */ inline bool Is_Proxy(INode &node) { - return (::strchr (node.GetName (), '~') != NULL); + return (::strchr (node.GetName (), '~') != nullptr); } diff --git a/Core/Tools/WW3D/max2w3d/w3ddlg.cpp b/Core/Tools/WW3D/max2w3d/w3ddlg.cpp index 081f736e44a..47a96169d22 100644 --- a/Core/Tools/WW3D/max2w3d/w3ddlg.cpp +++ b/Core/Tools/WW3D/max2w3d/w3ddlg.cpp @@ -80,8 +80,8 @@ W3dOptionsDialogClass::W3dOptionsDialogClass(Interface * maxinterface,ExpInterfa if (!_OfnInited) _init_ofn(); GotHierarchyFilename = false; - RangeLowSpin = NULL; - RangeHighSpin = NULL; + RangeLowSpin = nullptr; + RangeHighSpin = nullptr; GetMasterUnitInfo(&UnitsType, &UnitsScale); } @@ -171,7 +171,7 @@ bool W3dOptionsDialogClass::Dialog_Proc return 1; } - SetCursor(LoadCursor (NULL, IDC_WAIT)); + SetCursor(LoadCursor (nullptr, IDC_WAIT)); EndDialog(Hwnd, 1); break; @@ -211,7 +211,7 @@ bool W3dOptionsDialogClass::Dialog_Proc // use the open file common dialog to get a hierarchy filename. _HierarchyFileOFN.hwndOwner = Hwnd; - _HierarchyFileOFN.lpstrFileTitle = NULL; + _HierarchyFileOFN.lpstrFileTitle = nullptr; _HierarchyFileOFN.lpstrFile = Options->HierarchyFilename; if (GetOpenFileName(&_HierarchyFileOFN)) { @@ -234,7 +234,7 @@ bool W3dOptionsDialogClass::Dialog_Proc SetSaveRequiredFlag(true); } - _HierarchyFileOFN.lpstrFile = NULL; + _HierarchyFileOFN.lpstrFile = nullptr; break; } return 1; @@ -272,7 +272,7 @@ bool W3dOptionsDialogClass::Dialog_Proc void W3dOptionsDialogClass::Dialog_Init() { CenterWindow(Hwnd, GetParent(Hwnd)); - SetCursor(LoadCursor (NULL, IDC_ARROW)); + SetCursor(LoadCursor (nullptr, IDC_ARROW)); // initialize the export radio buttons if (Options->ExportHierarchy) { @@ -766,7 +766,7 @@ BOOL CALLBACK _options_dialog_proc LPARAM lParam ) { - static W3dOptionsDialogClass * optdialog = NULL; + static W3dOptionsDialogClass * optdialog = nullptr; if (message == WM_INITDIALOG) { optdialog = (W3dOptionsDialogClass *) lParam; @@ -798,25 +798,25 @@ void _init_ofn(void) static char _szhierarchyfilter[] = "W3D Files (*.W3D)\0*.W3D\0WHT Files (*.WHT)\0*.WHT\0\0"; _HierarchyFileOFN.lStructSize = sizeof(OPENFILENAME); - _HierarchyFileOFN.hwndOwner = NULL; - _HierarchyFileOFN.hInstance = NULL; + _HierarchyFileOFN.hwndOwner = nullptr; + _HierarchyFileOFN.hInstance = nullptr; _HierarchyFileOFN.lpstrFilter = _szhierarchyfilter; - _HierarchyFileOFN.lpstrCustomFilter = NULL; + _HierarchyFileOFN.lpstrCustomFilter = nullptr; _HierarchyFileOFN.nMaxCustFilter = 0; _HierarchyFileOFN.nFilterIndex = 0; - _HierarchyFileOFN.lpstrFile = NULL; + _HierarchyFileOFN.lpstrFile = nullptr; _HierarchyFileOFN.nMaxFile = _MAX_PATH; - _HierarchyFileOFN.lpstrFileTitle = NULL; + _HierarchyFileOFN.lpstrFileTitle = nullptr; _HierarchyFileOFN.nMaxFileTitle = _MAX_FNAME + _MAX_EXT; - _HierarchyFileOFN.lpstrInitialDir = NULL; - _HierarchyFileOFN.lpstrTitle = NULL; + _HierarchyFileOFN.lpstrInitialDir = nullptr; + _HierarchyFileOFN.lpstrTitle = nullptr; _HierarchyFileOFN.Flags = OFN_HIDEREADONLY | OFN_CREATEPROMPT; _HierarchyFileOFN.nFileOffset = 0; _HierarchyFileOFN.nFileExtension = 0; _HierarchyFileOFN.lpstrDefExt = "wht"; _HierarchyFileOFN.lCustData = 0L; - _HierarchyFileOFN.lpfnHook = NULL; - _HierarchyFileOFN.lpTemplateName = NULL; + _HierarchyFileOFN.lpfnHook = nullptr; + _HierarchyFileOFN.lpTemplateName = nullptr; _OfnInited = true; } diff --git a/Core/Tools/WW3D/max2w3d/w3dexp.cpp b/Core/Tools/WW3D/max2w3d/w3dexp.cpp index b1ade39381f..7d996d566eb 100644 --- a/Core/Tools/WW3D/max2w3d/w3dexp.cpp +++ b/Core/Tools/WW3D/max2w3d/w3dexp.cpp @@ -225,10 +225,10 @@ int W3dExportClass::DoExport { ExportInterface = do_export; MaxInterface = max; - RootNode = NULL; - OriginList = NULL; - DamageRootList = NULL; - HierarchyTree = NULL; + RootNode = nullptr; + OriginList = nullptr; + DamageRootList = nullptr; + HierarchyTree = nullptr; try { @@ -243,7 +243,7 @@ int W3dExportClass::DoExport char rootname[_MAX_FNAME + 1]; char drivename[_MAX_DRIVE + 1]; char dirname[_MAX_DIR + 1]; - _splitpath(filename, drivename, dirname, rootname, NULL); + _splitpath(filename, drivename, dirname, rootname, nullptr); sprintf(CurrentExportPath, "%s%s", drivename, dirname); /* @@ -251,7 +251,7 @@ int W3dExportClass::DoExport ** MAX file being exported. This is so that it can use the old relative pathname of the ** W3D file containing the hierarchy. */ - _splitpath(max->GetCurFilePath(), drivename, dirname, NULL, NULL); + _splitpath(max->GetCurFilePath(), drivename, dirname, nullptr, nullptr); sprintf(CurrentScenePath, "%s%s", drivename, dirname); /* @@ -271,7 +271,7 @@ int W3dExportClass::DoExport /* ** Initialize the logging system */ - ExportLog::Init(NULL); + ExportLog::Init(nullptr); /* ** Create a chunk saver to write the w3d file with @@ -279,7 +279,7 @@ int W3dExportClass::DoExport RawFileClass stream(filename); if (!stream.Open(FileClass::WRITE)) { - MessageBox(NULL,"Unable to open file.","Error",MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr,"Unable to open file.","Error",MB_OK | MB_SETFOREGROUND); return 1; } @@ -301,24 +301,24 @@ int W3dExportClass::DoExport */ stream.Close(); - if (HierarchyTree != NULL) { + if (HierarchyTree != nullptr) { delete HierarchyTree; - HierarchyTree = NULL; + HierarchyTree = nullptr; } - if (OriginList != NULL) { + if (OriginList != nullptr) { delete OriginList; - OriginList = NULL; + OriginList = nullptr; } - if (DamageRootList != NULL) { + if (DamageRootList != nullptr) { delete DamageRootList; - DamageRootList = NULL; + DamageRootList = nullptr; } } catch (ErrorClass error) { - MessageBox(NULL,error.error_message,"Error",MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr,error.error_message,"Error",MB_OK | MB_SETFOREGROUND); } ExportLog::Shutdown(ExportOptions.ReviewLog); @@ -350,7 +350,7 @@ void W3dExportClass::DoOriginBasedExport(char *rootname,ChunkSaveClass &csave) ** Build the damage root list. */ INodeListClass *damage_list = get_damage_root_list(); - assert(damage_list != NULL); + assert(damage_list != nullptr); /* ** Start the progress meter @@ -372,7 +372,7 @@ void W3dExportClass::DoOriginBasedExport(char *rootname,ChunkSaveClass &csave) bool is_base_object = false; INodeListClass *origin_list = get_origin_list(); unsigned int i, count = origin_list->Num_Nodes(); - INode *base_origin = NULL; + INode *base_origin = nullptr; for (i = 0; i < count; i++) { @@ -390,7 +390,7 @@ void W3dExportClass::DoOriginBasedExport(char *rootname,ChunkSaveClass &csave) Progress_Meter_Class treemeter(meter, meter.Increment); if (!Export_Hierarchy(rootname, csave, treemeter, base_origin)) { - MessageBox(NULL,"Hierarchy Export Failure!","Error",MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr,"Hierarchy Export Failure!","Error",MB_OK | MB_SETFOREGROUND); End_Progress_Bar(); return; } @@ -404,7 +404,7 @@ void W3dExportClass::DoOriginBasedExport(char *rootname,ChunkSaveClass &csave) Progress_Meter_Class animmeter(meter, meter.Increment); if (!Export_Animation(rootname, csave, animmeter, base_origin)) { - MessageBox(NULL,"Animation Export Failure!","Error",MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr,"Animation Export Failure!","Error",MB_OK | MB_SETFOREGROUND); End_Progress_Bar(); return; } @@ -420,7 +420,7 @@ void W3dExportClass::DoOriginBasedExport(char *rootname,ChunkSaveClass &csave) { if (!Export_Damage_Animations(rootname, csave, damagemeter, (*damage_list)[i])) { - MessageBox(NULL, "Damage Animation Export Failure!", "Error", MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr, "Damage Animation Export Failure!", "Error", MB_OK | MB_SETFOREGROUND); End_Progress_Bar(); return; } @@ -436,7 +436,7 @@ void W3dExportClass::DoOriginBasedExport(char *rootname,ChunkSaveClass &csave) MeshConnectionsClass **connections = new MeshConnectionsClass*[count]; if (!connections) { - MessageBox(NULL, "Memory allocation failure!", "Error", MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr, "Memory allocation failure!", "Error", MB_OK | MB_SETFOREGROUND); End_Progress_Bar(); return; } @@ -466,11 +466,11 @@ void W3dExportClass::DoOriginBasedExport(char *rootname,ChunkSaveClass &csave) /* ** Write each mesh (if needed) */ - MeshConnectionsClass *meshcon = NULL; + MeshConnectionsClass *meshcon = nullptr; Progress_Meter_Class meshmeter(meter, meter.Increment); if (!Export_Geometry(rootname, csave, meshmeter, origin, &meshcon)) { - MessageBox(NULL, "Geometry Export Failure!", "Error", MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr, "Geometry Export Failure!", "Error", MB_OK | MB_SETFOREGROUND); End_Progress_Bar(); return; } @@ -481,14 +481,14 @@ void W3dExportClass::DoOriginBasedExport(char *rootname,ChunkSaveClass &csave) ** the array in order of LOD (top-level last). */ int lod_level = Get_Lod_Level(origin); - if (lod_level >= count || connections[count - lod_level - 1] != NULL) + if (lod_level >= count || connections[count - lod_level - 1] != nullptr) { char text[256]; sprintf(text, "Origin Naming Error! There are %d models defined in this " "scene, therefore your origin names should be\n\"Origin.00\" through " "\"Origin.%02d\", 00 being the high-poly model and %02d being the " "lowest detail LOD.", count, count-1, count-1); - MessageBox(NULL, text, "Error", MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr, text, "Error", MB_OK | MB_SETFOREGROUND); End_Progress_Bar(); return; } @@ -506,7 +506,7 @@ void W3dExportClass::DoOriginBasedExport(char *rootname,ChunkSaveClass &csave) Progress_Meter_Class hlod_meter(meter, meter.Increment); if (!Export_HLod(rootname, htree->Get_Name(), csave, hlod_meter, connections, count)) { - MessageBox(NULL, "HLOD Generation Failure!", "Error", MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr, "HLOD Generation Failure!", "Error", MB_OK | MB_SETFOREGROUND); End_Progress_Bar(); return; } @@ -519,7 +519,7 @@ void W3dExportClass::DoOriginBasedExport(char *rootname,ChunkSaveClass &csave) */ for (i = 0; i < count; i++) { - if (connections[i] != NULL) + if (connections[i] != nullptr) delete connections[i]; } delete []connections; @@ -549,12 +549,12 @@ bool W3dExportClass::Export_Hierarchy(char *name,ChunkSaveClass & csave,Progress if (!ExportOptions.ExportHierarchy) return true; HierarchySaveClass::Enable_Terrain_Optimization(ExportOptions.EnableTerrainMode); - if (root == NULL) return false; + if (root == nullptr) return false; try { HierarchyTree = new HierarchySaveClass(root,CurTime,meter,name,FixupType); } catch (ErrorClass err) { - MessageBox(NULL, err.error_message,"Error!",MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr, err.error_message,"Error!",MB_OK | MB_SETFOREGROUND); return false; } @@ -584,11 +584,11 @@ bool W3dExportClass::Export_Animation(char * name,ChunkSaveClass & csave,Progres if (!ExportOptions.ExportAnimation) return true; HierarchySaveClass * htree = get_hierarchy_tree(); - if ((root == NULL) || (htree == NULL)) { + if ((root == nullptr) || (htree == nullptr)) { return false; } - MotionClass * motion = NULL; + MotionClass * motion = nullptr; try { motion = new MotionClass( ExportInterface->theScene, @@ -600,7 +600,7 @@ bool W3dExportClass::Export_Animation(char * name,ChunkSaveClass & csave,Progres MaxInterface->GetMAXHWnd(), name); } catch (ErrorClass err) { - MessageBox(NULL,err.error_message,"Error!",MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr,err.error_message,"Error!",MB_OK | MB_SETFOREGROUND); return false; } @@ -631,7 +631,7 @@ bool W3dExportClass::Export_Damage_Animations(char *name, ChunkSaveClass &csave, if (!ExportOptions.ExportAnimation) return true; HierarchySaveClass *htree = get_hierarchy_tree(); - if ((damage_root == NULL) || (htree == NULL)) + if ((damage_root == nullptr) || (htree == nullptr)) return false; int damage_state = Get_Damage_State(damage_root); @@ -664,7 +664,7 @@ bool W3dExportClass::Export_Damage_Animations(char *name, ChunkSaveClass &csave, sprintf(anim_name, "damage%d-%d", current_region, damage_state); // Export an animation for this damage region. - MotionClass *motion = NULL; + MotionClass *motion = nullptr; try { motion = new MotionClass( ExportInterface->theScene, @@ -679,11 +679,11 @@ bool W3dExportClass::Export_Damage_Animations(char *name, ChunkSaveClass &csave, } catch (ErrorClass err) { - MessageBox(NULL, err.error_message, "Error!", MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr, err.error_message, "Error!", MB_OK | MB_SETFOREGROUND); return false; } - assert(motion != NULL); + assert(motion != nullptr); motion->Save(csave); delete motion; @@ -691,7 +691,7 @@ bool W3dExportClass::Export_Damage_Animations(char *name, ChunkSaveClass &csave, if (num_damage_bones <= 0) { - MessageBox(NULL, "Warning: Your damage bones need to be given damage region numbers. " + MessageBox(nullptr, "Warning: Your damage bones need to be given damage region numbers. " "You can do this in the W3D Tools panel.", name, MB_OK | MB_ICONINFORMATION | MB_SETFOREGROUND); } @@ -724,22 +724,22 @@ bool W3dExportClass::Export_Geometry(char * name,ChunkSaveClass & csave,Progress { unsigned int i; - assert(root != NULL); + assert(root != nullptr); if (!ExportOptions.ExportGeometry) return true; /* ** If we're attaching the meshes to a hierarchy, get the tree */ - HierarchySaveClass * htree = NULL; + HierarchySaveClass * htree = nullptr; if (ExportOptions.LoadHierarchy || ExportOptions.ExportHierarchy) { htree = get_hierarchy_tree(); - if (htree == NULL) { + if (htree == nullptr) { return false; } } DynamicVectorClass export_tasks; - INodeListClass *geometry_list = NULL; + INodeListClass *geometry_list = nullptr; /* ** Create the lists of nodes that we're going to work with @@ -783,14 +783,14 @@ bool W3dExportClass::Export_Geometry(char * name,ChunkSaveClass & csave,Progress ** If we're only exporting geometry, only export the first mesh. (no more collections) */ int geometry_count = geometry_list->Num_Nodes(); - if ((htree == NULL) && (geometry_list->Num_Nodes() > 1)) { + if ((htree == nullptr) && (geometry_list->Num_Nodes() > 1)) { geometry_count = MIN(geometry_count,1); ExportLog::printf("\nDiscarding extra meshes since we are not exporting a hierarchical model.\n"); } for (i=0; iSet_Name(name); export_tasks[0]->Set_Container_Name(""); @@ -816,13 +816,13 @@ bool W3dExportClass::Export_Geometry(char * name,ChunkSaveClass & csave,Progress /* ** Generate the mesh-connections object to return to the caller */ - MeshConnectionsClass * meshcon = NULL; - if (htree != NULL) { + MeshConnectionsClass * meshcon = nullptr; + if (htree != nullptr) { Progress_Meter_Class mcmeter(meter,meter.Increment); try { meshcon = new MeshConnectionsClass(export_tasks,context); } catch (ErrorClass err) { - MessageBox(NULL,err.error_message,"Error!",MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr,err.error_message,"Error!",MB_OK | MB_SETFOREGROUND); return false; } *out_connection = meshcon; @@ -941,7 +941,7 @@ HierarchySaveClass * W3dExportClass::get_hierarchy_tree(void) /* ** If the hierarchy tree pointer has been initialized, just return it */ - if (HierarchyTree != NULL) return HierarchyTree; + if (HierarchyTree != nullptr) return HierarchyTree; /* ** If we are supposed to be loading a hierarchy from disk, then @@ -955,7 +955,7 @@ HierarchySaveClass * W3dExportClass::get_hierarchy_tree(void) char buf[256]; sprintf(buf,"Unable to load hierarchy file: %s\nIf this Max file has been moved, please re-select the hierarchy file.",HierarchyFilename); MessageBox(MaxInterface->GetMAXHWnd(),buf,"Error",MB_OK | MB_SETFOREGROUND); - return NULL; + return nullptr; } } @@ -965,7 +965,7 @@ HierarchySaveClass * W3dExportClass::get_hierarchy_tree(void) ** function failed to create a hierarchy tree for us. */ assert(0); - return NULL; + return nullptr; } @@ -983,7 +983,7 @@ HierarchySaveClass * W3dExportClass::get_hierarchy_tree(void) *=============================================================================================*/ INodeListClass * W3dExportClass::get_damage_root_list(void) { - if (DamageRootList != NULL) return DamageRootList; + if (DamageRootList != nullptr) return DamageRootList; /* ** Create a list of all damage root objects in the scene. @@ -1008,7 +1008,7 @@ INodeListClass * W3dExportClass::get_damage_root_list(void) *=============================================================================================*/ INodeListClass * W3dExportClass::get_origin_list(void) { - if (OriginList != NULL) return OriginList; + if (OriginList != nullptr) return OriginList; /* ** Create a list of all origins in the scene. @@ -1019,7 +1019,7 @@ INodeListClass * W3dExportClass::get_origin_list(void) /* ** If we didn't find any origins, add the scene root as an origin. ** NOTE: it would also be a problem if the origin list contained both the scene root - ** and the user placed origins. Thats not happening now because the OriginList + ** and the user placed origins. That's not happening now because the OriginList ** does not collect the scene root... were that to change we'd have to update this ** code as well. */ @@ -1051,7 +1051,7 @@ bool W3dExportClass::get_export_options(BOOL suppress_prompts) // scene pointer. If there is no such AppDataChunk create one and set it // to default values. - W3dExportOptionsStruct *options = NULL; + W3dExportOptionsStruct *options = nullptr; AppDataChunk * appdata = MaxInterface->GetScenePointer()->GetAppDataChunk(W3D_EXPORTER_CLASS_ID,SCENE_EXPORT_CLASS_ID,0); @@ -1159,7 +1159,7 @@ void W3dExportClass::Start_Progress_Bar(void) "Processing Triangle Mesh", TRUE, progress_callback, - NULL); + nullptr); } /*********************************************************************************************** @@ -1192,7 +1192,7 @@ static bool dupe_check(const INodeListClass & list) if (stricmp(list[i]->GetName(),list[j]->GetName()) == 0) { char buf[256]; sprintf(buf,"Geometry Nodes with duplicated names found!\nDuplicated Name: %s\n",list[i]->GetName()); - MessageBox(NULL,buf,"Error",MB_OK | MB_SETFOREGROUND); + MessageBox(nullptr,buf,"Error",MB_OK | MB_SETFOREGROUND); return true; } } @@ -1205,12 +1205,12 @@ static bool check_lod_extensions (INodeListClass &list, INode *origin) { /* ** Assumptions: - ** - If origin == NULL, then we're just exporting a single model and don't need to + ** - If origin == nullptr, then we're just exporting a single model and don't need to ** worry about lod extensions at all. ** - If origin is the root of the scene, then we're just exporting a single model as well. ** - Otherwise origin actually points to an Origin and not just any INode. */ - if (origin == NULL) return true; + if (origin == nullptr) return true; if (origin->IsRootNode()) return true; char *extension = strrchr(origin->GetName(), '.'); @@ -1219,8 +1219,8 @@ static bool check_lod_extensions (INodeListClass &list, INode *origin) { char *this_ext = strrchr(list[i]->GetName(), '.'); - // Check for the existance of an extension in this node. - if (this_ext == NULL) + // Check for the existence of an extension in this node. + if (this_ext == nullptr) return false; // Check that the extensions are the same. @@ -1239,7 +1239,7 @@ bool W3dExportClass::get_base_object_tm (Matrix3 &tm) return false; unsigned int i, count = origin_list->Num_Nodes(); - INode *base_origin = NULL; + INode *base_origin = nullptr; for (i = 0; i < count; i++) { INode *node = (*origin_list)[i]; @@ -1265,12 +1265,12 @@ static DWORD WINAPI progress_callback( LPVOID arg ) static HierarchySaveClass * load_hierarchy_file(char * filename) { - HierarchySaveClass * hier = NULL; + HierarchySaveClass * hier = nullptr; RawFileClass file(filename); if (!file.Open()) { - return NULL; + return nullptr; } ChunkLoadClass cload(&file); @@ -1279,9 +1279,9 @@ static HierarchySaveClass * load_hierarchy_file(char * filename) hier = new HierarchySaveClass(); hier->Load(cload); } else { - hier = NULL; + hier = nullptr; file.Close(); - return NULL; + return nullptr; } cload.Close_Chunk(); diff --git a/Core/Tools/WW3D/max2w3d/w3dexp.h b/Core/Tools/WW3D/max2w3d/w3dexp.h index df69186b380..aaf57fed649 100644 --- a/Core/Tools/WW3D/max2w3d/w3dexp.h +++ b/Core/Tools/WW3D/max2w3d/w3dexp.h @@ -108,7 +108,7 @@ class W3dExportClass : public SceneExport bool Export_Hierarchy(char * name,ChunkSaveClass & csave,Progress_Meter_Class & meter,INode *root); bool Export_Animation(char * name,ChunkSaveClass & csave,Progress_Meter_Class & meter,INode *root); bool Export_Damage_Animations(char * name,ChunkSaveClass & csave,Progress_Meter_Class &meter,INode *damage_root); - bool Export_Geometry(char * name,ChunkSaveClass & csave,Progress_Meter_Class & meter,INode *root=NULL, MeshConnectionsClass **out_connection=NULL); + bool Export_Geometry(char * name,ChunkSaveClass & csave,Progress_Meter_Class & meter,INode *root=nullptr, MeshConnectionsClass **out_connection=nullptr); bool Export_HLod (char *name, const char *htree_name, ChunkSaveClass &csave, Progress_Meter_Class &meter, MeshConnectionsClass **connections, int lod_count); bool Export_Collection(const char * name,ChunkSaveClass & csave,DynamicVectorClass & objlist,INodeListClass & placeholder_list,INodeListClass & transform_node_list); diff --git a/Core/Tools/WW3D/max2w3d/w3dmtl.cpp b/Core/Tools/WW3D/max2w3d/w3dmtl.cpp index f86727e9d2d..163ca9d331f 100644 --- a/Core/Tools/WW3D/max2w3d/w3dmtl.cpp +++ b/Core/Tools/WW3D/max2w3d/w3dmtl.cpp @@ -87,8 +87,8 @@ void W3dMapClass::Reset(void) { if (Filename) free(Filename); if (AnimInfo) delete AnimInfo; - Filename = NULL; - AnimInfo = NULL; + Filename = nullptr; + AnimInfo = nullptr; } void W3dMapClass::Set_Filename(const char * fullpath) @@ -101,25 +101,25 @@ void W3dMapClass::Set_Filename(const char * fullpath) char exten[_MAX_EXT]; char fname[_MAX_FNAME+_MAX_EXT+2]; - _splitpath(fullpath,NULL,NULL,name,exten); - _makepath(fname,NULL,NULL,name,exten); + _splitpath(fullpath,nullptr,nullptr,name,exten); + _makepath(fname,nullptr,nullptr,name,exten); //strupr(fname); (gth) need to preserve case since unix/PS2 is case sensitive... Filename = strdup(fname); } else { - Filename = NULL; + Filename = nullptr; } } void W3dMapClass::Set_Anim_Info(const W3dTextureInfoStruct * info) { - if (info == NULL) { + if (info == nullptr) { if (AnimInfo) { delete AnimInfo; - AnimInfo = NULL; + AnimInfo = nullptr; return; } } else { - if (AnimInfo == NULL) { + if (AnimInfo == nullptr) { AnimInfo = new W3dTextureInfoStruct; } *AnimInfo = *info; @@ -128,7 +128,7 @@ void W3dMapClass::Set_Anim_Info(const W3dTextureInfoStruct * info) void W3dMapClass::Set_Anim_Info(int framecount,float framerate) { - if (AnimInfo == NULL) { + if (AnimInfo == nullptr) { AnimInfo = new W3dTextureInfoStruct; } @@ -152,12 +152,12 @@ W3dMaterialClass::W3dMaterialClass(void) PassCount = 0; SortLevel = SORT_LEVEL_NONE; for (int pass = 0; pass < MAX_PASSES; pass++) { - Materials[pass] = NULL; + Materials[pass] = nullptr; W3d_Shader_Reset(&(Shaders[pass])); for (int stage = 0; stage < MAX_STAGES; stage++) { - Textures[pass][stage] = NULL; + Textures[pass][stage] = nullptr; MapChannel[pass][stage] = 1; - MapperArgs[pass][stage] = NULL; + MapperArgs[pass][stage] = nullptr; } } } @@ -173,18 +173,18 @@ void W3dMaterialClass::Free(void) if (Materials[pass]) { delete Materials[pass]; - Materials[pass] = NULL; + Materials[pass] = nullptr; } for (int stage = 0; stage < MAX_STAGES; stage++) { if (Textures[pass][stage]) { delete Textures[pass][stage]; - Textures[pass][stage] = NULL; + Textures[pass][stage] = nullptr; } if (MapperArgs[pass][stage]) { delete [] MapperArgs[pass][stage]; - MapperArgs[pass][stage] = NULL; + MapperArgs[pass][stage] = nullptr; } } } @@ -226,7 +226,7 @@ void W3dMaterialClass::Set_Vertex_Material(const W3dVertexMaterialStruct & vmat, assert(pass >= 0); assert(pass < PassCount); - if (Materials[pass] == NULL) { + if (Materials[pass] == nullptr) { Materials[pass] = new W3dVertexMaterialStruct; } *(Materials[pass]) = vmat; @@ -239,9 +239,9 @@ void W3dMaterialClass::Set_Mapper_Args(const char *args_buffer, int pass, int st assert(stage >= 0); assert(stage < MAX_STAGES); - if (MapperArgs[pass][stage] != NULL) { + if (MapperArgs[pass][stage] != nullptr) { delete [] MapperArgs[pass][stage]; - MapperArgs[pass][stage] = NULL; + MapperArgs[pass][stage] = nullptr; } if (args_buffer) { int len = strlen(args_buffer); @@ -263,7 +263,7 @@ void W3dMaterialClass::Set_Texture(const W3dMapClass & map,int pass,int stage) assert(pass >= 0); assert(pass < PassCount); - if (Textures[pass][stage] == NULL) { + if (Textures[pass][stage] == nullptr) { Textures[pass][stage] = new W3dMapClass; } *(Textures[pass][stage]) = map; @@ -583,7 +583,7 @@ void W3dMaterialClass::Init(GameMtl * gamemtl, char *materialColorTexture) ** install the two textures if present */ W3dMapClass w3dmap; - BitmapTex * tex = NULL; + BitmapTex * tex = nullptr; for (int stage=0; stage < MAX_STAGES; stage++) { @@ -679,10 +679,10 @@ bool W3dMaterialClass::Is_Multi_Pass_Transparent(void) const W3dMaterialDescClass::VertMatClass::VertMatClass(void) : PassIndex(-1), Crc(0), - Name(NULL) + Name(nullptr) { for (int stage=0; stage < W3dMaterialClass::MAX_STAGES; ++stage) { - MapperArgs[stage] = NULL; + MapperArgs[stage] = nullptr; } } @@ -693,7 +693,7 @@ W3dMaterialDescClass::VertMatClass::~VertMatClass(void) for (int stage=0; stage < W3dMaterialClass::MAX_STAGES; ++stage) { if (MapperArgs[stage]) { delete [] (MapperArgs[stage]); - MapperArgs[stage] = NULL; + MapperArgs[stage] = nullptr; } } } @@ -730,7 +730,7 @@ void W3dMaterialDescClass::VertMatClass::Set_Name(const char * name) if (name) { Name = strdup(name); } else { - Name = NULL; + Name = nullptr; } } @@ -738,7 +738,7 @@ void W3dMaterialDescClass::VertMatClass::Set_Mapper_Args(const char * args, int { if (MapperArgs[stage]) { delete [] (MapperArgs[stage]); - MapperArgs[stage] = NULL; + MapperArgs[stage] = nullptr; } if (args) { @@ -746,7 +746,7 @@ void W3dMaterialDescClass::VertMatClass::Set_Mapper_Args(const char * args, int MapperArgs[stage] = new char [len + 1]; strcpy(MapperArgs[stage], args); } else { - MapperArgs[stage] = NULL; + MapperArgs[stage] = nullptr; } } @@ -970,7 +970,7 @@ W3dVertexMaterialStruct * W3dMaterialDescClass::Get_Vertex_Material(int mat_inde { int index = Get_Vertex_Material_Index(mat_index,pass); if (index == -1) { - return NULL; + return nullptr; } else { return Get_Vertex_Material(index); } @@ -980,7 +980,7 @@ const char * W3dMaterialDescClass::Get_Mapper_Args(int mat_index,int pass,int st { int index = Get_Vertex_Material_Index(mat_index,pass); if (index == -1) { - return NULL; + return nullptr; } else { return Get_Mapper_Args(index,stage); } @@ -990,7 +990,7 @@ W3dShaderStruct * W3dMaterialDescClass::Get_Shader(int mat_index,int pass) { int index = Get_Shader_Index(mat_index,pass); if (index == -1) { - return NULL; + return nullptr; } else { return Get_Shader(index); } @@ -1000,7 +1000,7 @@ W3dMapClass * W3dMaterialDescClass::Get_Texture(int mat_index,int pass,int stage { int index = Get_Texture_Index(mat_index,pass,stage); if (index == -1) { - return NULL; + return nullptr; } else { return Get_Texture(index); } @@ -1015,7 +1015,7 @@ const char * W3dMaterialDescClass::Get_Vertex_Material_Name(int mat_index,int pa { int index = Get_Vertex_Material_Index(mat_index,pass); if (index == -1) { - return NULL; + return nullptr; } else { return VertexMaterials[index].Name; } @@ -1087,7 +1087,7 @@ bool W3dMaterialDescClass::Pass_Uses_Alpha(int pass) int W3dMaterialDescClass::Add_Vertex_Material(W3dVertexMaterialStruct * vmat, const char *mapper_args0,const char *mapper_args1,int pass,const char * name) { - if (vmat == NULL) { + if (vmat == nullptr) { return -1; } @@ -1131,7 +1131,7 @@ int W3dMaterialDescClass::Add_Shader(const W3dShaderStruct & shader,int pass) int W3dMaterialDescClass::Add_Texture(W3dMapClass * map,int pass,int stage) { - if ((map == NULL) || (map->Filename == NULL)) { + if ((map == nullptr) || (map->Filename == nullptr)) { return -1; } @@ -1185,7 +1185,7 @@ unsigned long W3dMaterialDescClass::Compute_Crc(const W3dShaderStruct & shader) unsigned long W3dMaterialDescClass::Compute_Crc(const W3dMapClass & map) { unsigned long crc = 0; - if (map.AnimInfo != NULL) { + if (map.AnimInfo != nullptr) { crc = CRC_Memory((const unsigned char *)&map.AnimInfo->Attributes,sizeof(map.AnimInfo->Attributes),crc); crc = CRC_Memory((const unsigned char *)&map.AnimInfo->AnimType,sizeof(map.AnimInfo->AnimType),crc); crc = CRC_Memory((const unsigned char *)&map.AnimInfo->FrameCount,sizeof(map.AnimInfo->FrameCount),crc); diff --git a/Core/Tools/WW3D/max2w3d/w3dmtl.h b/Core/Tools/WW3D/max2w3d/w3dmtl.h index 54fb2bd9a13..9de097f5e3f 100644 --- a/Core/Tools/WW3D/max2w3d/w3dmtl.h +++ b/Core/Tools/WW3D/max2w3d/w3dmtl.h @@ -52,7 +52,7 @@ class ChunkSaveClass; class W3dMapClass { public: - W3dMapClass(void) : Filename(NULL), AnimInfo(NULL) {}; + W3dMapClass(void) : Filename(nullptr), AnimInfo(nullptr) {}; W3dMapClass(const W3dMapClass & that); ~W3dMapClass(void); @@ -88,8 +88,8 @@ class W3dMaterialClass /* ** Construction from Max materials */ - void Init(Mtl * mtl, char *materialColorTexture=NULL); - void Init(GameMtl * gamemtl, char *materialColorTexture=NULL); + void Init(Mtl * mtl, char *materialColorTexture=nullptr); + void Init(GameMtl * gamemtl, char *materialColorTexture=nullptr); /* ** Manual Construction @@ -163,7 +163,7 @@ class W3dMaterialDescClass ** order, then use their indices to find the remapped vertex materials, textures, ** and shaders... */ - ErrorType Add_Material(const W3dMaterialClass & mat,const char * name = NULL); + ErrorType Add_Material(const W3dMaterialClass & mat,const char * name = nullptr); /* ** Global Information. These methods give access to all of the unique vertex materials, diff --git a/Core/Tools/WW3D/max2w3d/w3dutil.cpp b/Core/Tools/WW3D/max2w3d/w3dutil.cpp index 7cf6ad3b1f8..a0fc1bcb735 100644 --- a/Core/Tools/WW3D/max2w3d/w3dutil.cpp +++ b/Core/Tools/WW3D/max2w3d/w3dutil.cpp @@ -130,7 +130,7 @@ class SettingsFormClass void Init(void); void Destroy(void); void Disable_Controls(void); - void Update_Controls(INodeListClass * nodelist = NULL); + void Update_Controls(INodeListClass * nodelist = nullptr); HWND Hwnd; ISpinnerControl * RegionSpin; @@ -239,7 +239,7 @@ class W3DUtilityClass : public UtilityObj /* ** Update the controls in any active settings panels */ - static void update_settings_controls(INodeListClass * node_list = NULL); + static void update_settings_controls(INodeListClass * node_list = nullptr); /* ** Modify the state of all selected nodes @@ -332,9 +332,9 @@ ClassDesc * Get_W3D_Utility_Desc(void) **********************************************************************************************/ W3DUtilityClass::W3DUtilityClass(void) { - InterfacePtr = NULL; - SettingsPanelHWND = NULL; - ToolsPanelHWND = NULL; + InterfacePtr = nullptr; + SettingsPanelHWND = nullptr; + ToolsPanelHWND = nullptr; UpdateSpinnerValue = true; } @@ -372,13 +372,13 @@ void W3DUtilityClass::BeginEditParams(Interface *ip,IUtil *iu) void W3DUtilityClass::EndEditParams(Interface *ip,IUtil *iu) { - InterfacePtr = NULL; + InterfacePtr = nullptr; ip->DeleteRollupPage(SettingsPanelHWND); ip->DeleteRollupPage(ToolsPanelHWND); - SettingsPanelHWND = NULL; - ToolsPanelHWND = NULL; + SettingsPanelHWND = nullptr; + ToolsPanelHWND = nullptr; } void W3DUtilityClass::SelectionSetChanged(Interface *ip,IUtil *iu) @@ -741,7 +741,7 @@ void W3DUtilityClass::generate_lod_ext(INode * node) char *oldname = node->GetName(); char *ext = strrchr(oldname, '.'); int old_lod; - if ( (ext != NULL) && (sscanf(ext, ".%d", &old_lod) == 1) ) + if ( (ext != nullptr) && (sscanf(ext, ".%d", &old_lod) == 1) ) { /* ** An existing LOD index. If it's different than the new @@ -769,7 +769,7 @@ void W3DUtilityClass::generate_lod_ext(INode * node) "extension to \"%s\" will pass this limit! Please shorten its name.", W3D_NAME_LEN - 1, oldname); *ext = '.'; - MessageBox(NULL, msg, "Error", MB_OK); + MessageBox(nullptr, msg, "Error", MB_OK); } } else @@ -789,7 +789,7 @@ void W3DUtilityClass::generate_lod_ext(INode * node) sprintf(msg, "The maximum W3D object name is %d characters. Adding the LOD " "extension to \"%s\" will pass this limit! Please shorten its name.", W3D_NAME_LEN - 1, oldname); - MessageBox(NULL, msg, "Error", MB_OK); + MessageBox(nullptr, msg, "Error", MB_OK); } } } @@ -805,28 +805,28 @@ void W3DUtilityClass::export_with_standard_materials() char *convertingmessage = "Converting materials..."; // Count the no. of references to game materials. - MaterialReferenceMaker::ReferenceCount = convert_materials (GAME_REFERENCE_COUNT, NULL); + MaterialReferenceMaker::ReferenceCount = convert_materials (GAME_REFERENCE_COUNT, nullptr); - MaterialReferenceMaker *gamenodematerials = NULL; + MaterialReferenceMaker *gamenodematerials = nullptr; if (MaterialReferenceMaker::ReferenceCount > 0) { gamenodematerials = new MaterialReferenceMaker [MaterialReferenceMaker::ReferenceCount]; - assert (gamenodematerials != NULL); + assert (gamenodematerials != nullptr); } InterfacePtr->PushPrompt (convertingmessage); - SetCursor (LoadCursor (NULL, IDC_WAIT)); + SetCursor (LoadCursor (nullptr, IDC_WAIT)); convert_materials (GAME_TO_STANDARD, gamenodematerials); InterfacePtr->PopPrompt(); InterfacePtr->FileExport(); UpdateWindow (InterfacePtr->GetMAXHWnd()); InterfacePtr->PushPrompt (convertingmessage); - SetCursor (LoadCursor (NULL, IDC_WAIT)); + SetCursor (LoadCursor (nullptr, IDC_WAIT)); convert_materials (STANDARD_TO_GAME, gamenodematerials); InterfacePtr->PopPrompt(); // Clean-up. - if (gamenodematerials != NULL) delete [] gamenodematerials; + if (gamenodematerials != nullptr) delete [] gamenodematerials; } int W3DUtilityClass::convert_materials (MaterialConversionEnum conversion, MaterialReferenceMaker *gamenodematerials) @@ -834,17 +834,17 @@ int W3DUtilityClass::convert_materials (MaterialConversionEnum conversion, Mater int gamenodematerialindex = 0; INode *rootnode = InterfacePtr->GetRootNode(); - if (rootnode != NULL) { + if (rootnode != nullptr) { INodeListClass *meshlist = new INodeListClass (rootnode, 0); - if (meshlist != NULL) { + if (meshlist != nullptr) { for (unsigned nodeindex = 0; nodeindex < meshlist->Num_Nodes(); nodeindex++) { Mtl *nodemtl = ((*meshlist) [nodeindex])->GetMtl(); // Is this a non-null material? - if (nodemtl != NULL) { + if (nodemtl != nullptr) { // Is this not a multi-material? if (!nodemtl->IsMultiMtl()) { @@ -853,7 +853,7 @@ int W3DUtilityClass::convert_materials (MaterialConversionEnum conversion, Mater case GAME_REFERENCE_COUNT: if (nodemtl->ClassID() == GameMaterialClassID) { - assert (((GameMtl*) nodemtl)->Substitute_Material() == NULL); + assert (((GameMtl*) nodemtl)->Substitute_Material() == nullptr); } break; @@ -865,13 +865,13 @@ int W3DUtilityClass::convert_materials (MaterialConversionEnum conversion, Mater gamenodematerials [gamenodematerialindex].MakeRefByID (FOREVER, gamenodematerialindex, nodemtl); // Does this material already have an equivalent standard material? - if (((GameMtl*) nodemtl)->Substitute_Material() == NULL) { + if (((GameMtl*) nodemtl)->Substitute_Material() == nullptr) { ((GameMtl*) nodemtl)->Set_Substitute_Material (new_standard_material ((GameMtl*) nodemtl)); } ((*meshlist) [nodeindex])->SetMtl (((GameMtl*) nodemtl)->Substitute_Material()); } else { - gamenodematerials [gamenodematerialindex].MaterialPtr = NULL; + gamenodematerials [gamenodematerialindex].MaterialPtr = nullptr; } break; @@ -879,9 +879,9 @@ int W3DUtilityClass::convert_materials (MaterialConversionEnum conversion, Mater // Change materials to game materials if they were previously game materials before being // converted to standard materials. - if (gamenodematerials [gamenodematerialindex].MaterialPtr != NULL) { + if (gamenodematerials [gamenodematerialindex].MaterialPtr != nullptr) { ((*meshlist) [nodeindex])->SetMtl (gamenodematerials [gamenodematerialindex].MaterialPtr); - ((GameMtl*) gamenodematerials [gamenodematerialindex].MaterialPtr)->Set_Substitute_Material (NULL); + ((GameMtl*) gamenodematerials [gamenodematerialindex].MaterialPtr)->Set_Substitute_Material (nullptr); } break; } @@ -895,13 +895,13 @@ int W3DUtilityClass::convert_materials (MaterialConversionEnum conversion, Mater Mtl *submaterial = nodemtl->GetSubMtl (materialindex); // Is this a non-null submaterial? - if (submaterial != NULL) { + if (submaterial != nullptr) { switch (conversion) { case GAME_REFERENCE_COUNT: if (submaterial->ClassID() == GameMaterialClassID) { - assert (((GameMtl*) submaterial)->Substitute_Material() == NULL); + assert (((GameMtl*) submaterial)->Substitute_Material() == nullptr); } break; @@ -913,13 +913,13 @@ int W3DUtilityClass::convert_materials (MaterialConversionEnum conversion, Mater gamenodematerials [gamenodematerialindex].MakeRefByID (FOREVER, gamenodematerialindex, submaterial); // Does this material already have an equivalent standard material? - if (((GameMtl*) submaterial)->Substitute_Material() == NULL) { + if (((GameMtl*) submaterial)->Substitute_Material() == nullptr) { ((GameMtl*) submaterial)->Set_Substitute_Material (new_standard_material ((GameMtl*) submaterial)); } nodemtl->SetSubMtl (materialindex, ((GameMtl*) submaterial)->Substitute_Material()); } else { - gamenodematerials [gamenodematerialindex].MaterialPtr = NULL; + gamenodematerials [gamenodematerialindex].MaterialPtr = nullptr; } break; @@ -927,9 +927,9 @@ int W3DUtilityClass::convert_materials (MaterialConversionEnum conversion, Mater // Change materials to game materials if they were previously game materials before being // converted to standard materials. - if (gamenodematerials [gamenodematerialindex].MaterialPtr != NULL) { + if (gamenodematerials [gamenodematerialindex].MaterialPtr != nullptr) { nodemtl->SetSubMtl (materialindex, gamenodematerials [gamenodematerialindex].MaterialPtr); - ((GameMtl*) gamenodematerials [gamenodematerialindex].MaterialPtr)->Set_Substitute_Material (NULL); + ((GameMtl*) gamenodematerials [gamenodematerialindex].MaterialPtr)->Set_Substitute_Material (nullptr); } break; } @@ -975,7 +975,7 @@ StdMat *W3DUtilityClass::new_standard_material (GameMtl *gamemtl) void W3DUtilityClass::Select_Hierarchy(void) { - InterfacePtr->SelectNode(NULL); + InterfacePtr->SelectNode(nullptr); INode * root = InterfacePtr->GetRootNode(); descend_tree(root,SELECT_HIER); InterfacePtr->ForceCompleteRedraw(); @@ -983,7 +983,7 @@ void W3DUtilityClass::Select_Hierarchy(void) void W3DUtilityClass::Select_Geometry(void) { - InterfacePtr->SelectNode(NULL); + InterfacePtr->SelectNode(nullptr); INode * root = InterfacePtr->GetRootNode(); descend_tree(root,SELECT_GEOM); InterfacePtr->ForceCompleteRedraw(); @@ -991,7 +991,7 @@ void W3DUtilityClass::Select_Geometry(void) void W3DUtilityClass::Select_Alpha(void) { - InterfacePtr->SelectNode(NULL); + InterfacePtr->SelectNode(nullptr); INode * root = InterfacePtr->GetRootNode(); descend_tree(root,SELECT_ALPHA); InterfacePtr->ForceCompleteRedraw(); @@ -999,7 +999,7 @@ void W3DUtilityClass::Select_Alpha(void) void W3DUtilityClass::Select_Physical(void) { - InterfacePtr->SelectNode(NULL); + InterfacePtr->SelectNode(nullptr); INode * root = InterfacePtr->GetRootNode(); descend_tree(root,SELECT_PHYSICAL); InterfacePtr->ForceCompleteRedraw(); @@ -1007,7 +1007,7 @@ void W3DUtilityClass::Select_Physical(void) void W3DUtilityClass::Select_Projectile(void) { - InterfacePtr->SelectNode(NULL); + InterfacePtr->SelectNode(nullptr); INode * root = InterfacePtr->GetRootNode(); descend_tree(root,SELECT_PROJECTILE); InterfacePtr->ForceCompleteRedraw(); @@ -1015,7 +1015,7 @@ void W3DUtilityClass::Select_Projectile(void) void W3DUtilityClass::Select_Vis(void) { - InterfacePtr->SelectNode(NULL); + InterfacePtr->SelectNode(nullptr); INode * root = InterfacePtr->GetRootNode(); descend_tree(root,SELECT_VIS); InterfacePtr->ForceCompleteRedraw(); @@ -1134,7 +1134,7 @@ void W3DUtilityClass::select_vis_node(INode * node) bool W3DUtilityClass::is_alpha_material(Mtl * nodemtl) { - if (nodemtl == NULL) { + if (nodemtl == nullptr) { return false; } @@ -1165,13 +1165,13 @@ bool W3DUtilityClass::is_alpha_mesh(INode * node,Mtl * nodemtl) Object * obj = node->EvalWorldState(0).obj; TriObject * tri = (TriObject *)obj->ConvertToType(0, triObjectClassID); - if (tri != NULL) { + if (tri != nullptr) { Mesh & mesh = tri->mesh; int face_index; int mat_index; - if (nodemtl == NULL) { + if (nodemtl == nullptr) { return false; @@ -1260,7 +1260,7 @@ void W3DUtilityClass::generate_material_names_for_node(INode * node) void W3DUtilityClass::generate_material_names(Mtl * mtl) { - if (mtl == NULL) { + if (mtl == nullptr) { return; } @@ -1284,11 +1284,11 @@ W3DAppData0Struct * W3DUtilityClass::get_app_data_0(INode * node) /* ** Try to get our AppData which has the export flags */ - W3DAppData0Struct * wdata = NULL; + W3DAppData0Struct * wdata = nullptr; AppDataChunk * appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,0); /* - ** If there wasn't one, return NULL since this app data chunk is obsolete now. + ** If there wasn't one, return nullptr since this app data chunk is obsolete now. ** If there was one, get the data from it */ if (appdata) { @@ -1302,7 +1302,7 @@ W3DAppData0Struct * W3DUtilityClass::get_app_data_0(INode * node) W3DAppData1Struct * W3DUtilityClass::get_app_data_1(INode * node) { // Try to get our AppData which has the damage region - W3DAppData1Struct * wdata = NULL; + W3DAppData1Struct * wdata = nullptr; AppDataChunk * appdata = node->GetAppDataChunk(W3DUtilityClassID,UTILITY_CLASS_ID,1); // If there wasn't one, add one. If there was one, get the data from it @@ -1421,7 +1421,7 @@ static BOOL CALLBACK _w3d_utility_tools_dlg_proc(HWND hWnd, UINT msg, WPARAM wPa ** the window is destroyed. ** **********************************************************************************************/ -SettingsFormClass * SettingsFormClass::ActiveList = NULL; +SettingsFormClass * SettingsFormClass::ActiveList = nullptr; BOOL CALLBACK _settings_form_dlg_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -1445,7 +1445,7 @@ static void _settings_form_selection_changed_callback(void * param,NotifyInfo * SettingsFormClass::SettingsFormClass(HWND hwnd) : Hwnd(hwnd), - RegionSpin(NULL) + RegionSpin(nullptr) { /* ** Link into the active list @@ -1476,7 +1476,7 @@ SettingsFormClass::~SettingsFormClass(void) SettingsFormClass * prev = ActiveList; SettingsFormClass * cur = ActiveList->Next; - while ((cur != this) && (cur != NULL)) { + while ((cur != this) && (cur != nullptr)) { cur = cur->Next; prev = prev->Next; } @@ -1487,13 +1487,13 @@ SettingsFormClass::~SettingsFormClass(void) } } - Hwnd = NULL; + Hwnd = nullptr; } void SettingsFormClass::Update_All_Instances(void) { - if (ActiveList == NULL) { + if (ActiveList == nullptr) { return; } @@ -1508,7 +1508,7 @@ void SettingsFormClass::Update_All_Instances(void) ** Update all settings forms */ SettingsFormClass * form = ActiveList; - while (form != NULL) { + while (form != nullptr) { form->Update_Controls(&node_list); form = form->Next; } @@ -1520,11 +1520,11 @@ void SettingsFormClass::Init(void) // Initialize the contents of the dazzle combo // Reset the dazzle combo HWND dazzle_combo = GetDlgItem(Hwnd,IDC_DAZZLE_COMBO); - assert(dazzle_combo != NULL); + assert(dazzle_combo != nullptr); SendMessage(dazzle_combo,CB_RESETCONTENT,0,0); // Load the section of Dazzle.INI that defines all of the types. The windows function - // that I'm using here, reads in a NULL-terminated string for each entry in the section. Each + // that I'm using here, reads in a null-terminated string for each entry in the section. Each // string is of the form 'key=value'. Based on my testing, it appears that windows removes any white // space before or after the equal sign as well. char dllpath[_MAX_PATH]; @@ -1540,10 +1540,10 @@ void SettingsFormClass::Init(void) // Now we need to handle each string in the section buffer; skipping the 'key=' and adding // the dazzle type name into the combo box. char * entry = dazzle_types_buffer; - if (entry != NULL) { - while (*entry != NULL) { + if (entry != nullptr) { + while (*entry != nullptr) { entry = strchr(entry,'='); - if (entry != NULL) { + if (entry != nullptr) { entry++; ::SendMessage(dazzle_combo,CB_ADDSTRING,0,(LPARAM)entry); entry += strlen(entry) + 1; @@ -1573,7 +1573,7 @@ void SettingsFormClass::Init(void) void SettingsFormClass::Destroy(void) { ReleaseISpinner(RegionSpin); - RegionSpin = NULL; + RegionSpin = nullptr; } bool SettingsFormClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) @@ -1726,7 +1726,7 @@ bool SettingsFormClass::Dialog_Proc(HWND hWnd,UINT message,WPARAM wParam,LPARAM if (HIWORD(wParam) == CBN_SELCHANGE) { HWND dazzle_combo = GetDlgItem(hWnd,IDC_DAZZLE_COMBO); - if (dazzle_combo != NULL) { + if (dazzle_combo != nullptr) { char dazzle_type[128]; int cursel = ::SendMessage(dazzle_combo,CB_GETCURSEL,0,0); @@ -1801,7 +1801,7 @@ void SettingsFormClass::Update_Controls(INodeListClass * node_list) ** "Multiple" if more than one, "None" if no selected objs... */ ICustEdit * edit_ctrl = GetICustEdit(GetDlgItem(Hwnd,IDC_OBJ_NAME)); - if (edit_ctrl != NULL) { + if (edit_ctrl != nullptr) { if (node_list->Num_Nodes() == 0) { edit_ctrl->Enable(FALSE); edit_ctrl->SetText(Get_String(IDS_NO_OBJECT)); diff --git a/Core/Tools/WW3D/pluglib/CMakeLists.txt b/Core/Tools/WW3D/pluglib/CMakeLists.txt index e329dd35b99..05a76d1950a 100644 --- a/Core/Tools/WW3D/pluglib/CMakeLists.txt +++ b/Core/Tools/WW3D/pluglib/CMakeLists.txt @@ -59,7 +59,7 @@ set_target_properties(core_pluglib PROPERTIES OUTPUT_NAME pluglib) target_sources(core_pluglib PRIVATE ${PLUGLIB_SRC}) target_link_libraries(core_pluglib PUBLIC - core_utility + corei_always ) target_link_libraries(core_pluglib PRIVATE diff --git a/Core/Tools/WW3D/pluglib/Vector.h b/Core/Tools/WW3D/pluglib/Vector.h index aa2ce7b26f1..627752273b1 100644 --- a/Core/Tools/WW3D/pluglib/Vector.h +++ b/Core/Tools/WW3D/pluglib/Vector.h @@ -127,7 +127,7 @@ class VectorClass * * * This constructor for the vector class is passed the initial size of the vector and an * * optional pointer to a preallocated block of memory that the vector will be placed in. * - * If this optional pointer is NULL (or not provided), then the vector is allocated out * + * If this optional pointer is nullptr (or not provided), then the vector is allocated out * * of free store (with the "new" operator). * * * * INPUT: size -- The number of elements to initialize this vector to. * @@ -417,7 +417,7 @@ bool VectorClass::Resize(int newsize, T const * array) ** If there is an old vector, then it must be copied (as much as is feasible) ** to the new vector. */ - if (Vector != NULL) { + if (Vector != nullptr) { /* ** Copy as much of the old vector into the new vector as possible. This @@ -522,7 +522,7 @@ class DynamicVectorClass : public VectorClass // Uninitialized Add - does everything an Add does, except copying an // object into the 'new' spot in the array. It returns a pointer to - // the 'new' spot. (NULL if the Add failed). NOTE - you must then fill + // the 'new' spot. (null if the Add failed). NOTE - you must then fill // this memory area with a valid object (e.g. by using placement new), // or chaos will result! T * Uninitialized_Add(void); @@ -637,7 +637,7 @@ int DynamicVectorClass::ID(T const & object) * DynamicVectorClass::Add -- Add an element to the vector. * * * * Use this routine to add an element to the vector. The vector will automatically be * - * resized to accomodate the new element IF the vector was allocated previously and the * + * resized to accommodate the new element IF the vector was allocated previously and the * * growth rate is not zero. * * * * INPUT: object -- Reference to the object that will be added to the vector. * @@ -809,7 +809,7 @@ bool DynamicVectorClass::Delete(int index) * INPUT: none. * * * * OUTPUT: T *; Points to the empty space where the new object is to be created. (If the * - * space was not added succesfully, returns NULL). * + * space was not added successfully, returns nullptr). * * * * WARNINGS: If memory area is left uninitialized, Very Bad Things will happen. * * * @@ -827,7 +827,7 @@ T * DynamicVectorClass::Uninitialized_Add(void) ** Failure to increase the size of the vector is an error condition. ** Return with the error value. */ - return(NULL); + return(nullptr); } } else { @@ -835,7 +835,7 @@ T * DynamicVectorClass::Uninitialized_Add(void) ** Increasing the size of this vector is not allowed! Bail this ** routine with the error value. */ - return(NULL); + return(nullptr); } } @@ -972,7 +972,7 @@ int Pointer_Vector_Add(T * ptr, VectorClass & vec) int id = 0; bool foundspot = false; for (int index = 0; index < vec.Length(); index++) { - if (vec[index] == NULL) { + if (vec[index] == nullptr) { id = index; foundspot = true; break; @@ -982,7 +982,7 @@ int Pointer_Vector_Add(T * ptr, VectorClass & vec) id = vec.Length(); vec.Resize((vec.Length()+1) * 2); for (int index = id; index < vec.Length(); index++) { - vec[index] = NULL; + vec[index] = nullptr; } } vec[id] = ptr; @@ -995,7 +995,7 @@ bool Pointer_Vector_Remove(T const * ptr, VectorClass & vec) { int id = vec.ID((T *)ptr); if (id != -1) { - vec[id] = NULL; + vec[id] = nullptr; return(true); } return(false); diff --git a/Core/Tools/WW3D/pluglib/always.h b/Core/Tools/WW3D/pluglib/always.h index 79a856d2386..85034e70b00 100644 --- a/Core/Tools/WW3D/pluglib/always.h +++ b/Core/Tools/WW3D/pluglib/always.h @@ -88,7 +88,7 @@ void* __cdecl operator new(unsigned int s); ** 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 relpacing 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 @@ -146,10 +146,6 @@ template T max(T a,T b) #endif -#ifndef NULL - #define NULL 0 -#endif - /********************************************************************** ** This macro serves as a general way to determine the number of elements ** within an array. diff --git a/Core/Tools/WW3D/pluglib/chunkio.cpp b/Core/Tools/WW3D/pluglib/chunkio.cpp index 0a34f075264..26745513a42 100644 --- a/Core/Tools/WW3D/pluglib/chunkio.cpp +++ b/Core/Tools/WW3D/pluglib/chunkio.cpp @@ -733,7 +733,7 @@ uint32 ChunkLoadClass::Read(void * buf,uint32 nbytes) *=============================================================================================*/ uint32 ChunkLoadClass::Read(IOVector2Struct * v) { - assert(v != NULL); + assert(v != nullptr); return Read(v,sizeof(v)); } @@ -752,7 +752,7 @@ uint32 ChunkLoadClass::Read(IOVector2Struct * v) *=============================================================================================*/ uint32 ChunkLoadClass::Read(IOVector3Struct * v) { - assert(v != NULL); + assert(v != nullptr); return Read(v,sizeof(v)); } @@ -771,7 +771,7 @@ uint32 ChunkLoadClass::Read(IOVector3Struct * v) *=============================================================================================*/ uint32 ChunkLoadClass::Read(IOVector4Struct * v) { - assert(v != NULL); + assert(v != nullptr); return Read(v,sizeof(v)); } @@ -790,7 +790,7 @@ uint32 ChunkLoadClass::Read(IOVector4Struct * v) *=============================================================================================*/ uint32 ChunkLoadClass::Read(IOQuaternionStruct * q) { - assert(q != NULL); + assert(q != nullptr); return Read(q,sizeof(q)); } diff --git a/Core/Tools/WW3D/pluglib/errclass.h b/Core/Tools/WW3D/pluglib/errclass.h index 60c26fa0cf2..ee641c9012c 100644 --- a/Core/Tools/WW3D/pluglib/errclass.h +++ b/Core/Tools/WW3D/pluglib/errclass.h @@ -45,7 +45,7 @@ class ErrorClass public: ErrorClass(char * format,...); ErrorClass(const ErrorClass & that); - ~ErrorClass(void) { if (error_message != NULL) free(error_message); } + ~ErrorClass(void) { if (error_message != nullptr) free(error_message); } ErrorClass & operator = (const ErrorClass & that); @@ -64,19 +64,19 @@ inline ErrorClass::ErrorClass(char * format,...) } inline ErrorClass::ErrorClass(const ErrorClass & that) : - error_message(NULL) + error_message(nullptr) { *this = that; } inline ErrorClass & ErrorClass::operator = (const ErrorClass & that) { - if (error_message != NULL) { + if (error_message != nullptr) { free(error_message); - error_message = NULL; + error_message = nullptr; } - if (that.error_message != NULL) { + if (that.error_message != nullptr) { error_message = strdup(that.error_message); } diff --git a/Core/Tools/WW3D/pluglib/matrix3d.cpp b/Core/Tools/WW3D/pluglib/matrix3d.cpp index 0b9afa7fcc5..a64d67d05e8 100644 --- a/Core/Tools/WW3D/pluglib/matrix3d.cpp +++ b/Core/Tools/WW3D/pluglib/matrix3d.cpp @@ -580,7 +580,7 @@ void Matrix3D::Copy_3x3_Matrix(float matrix[3][3]) //void print_matrix(const Matrix3D & m); void Matrix3D::Multiply(const Matrix3D & A,const Matrix3D & B,Matrix3D * set_res) { - assert(set_res != NULL); + assert(set_res != nullptr); Matrix3D tmp; Matrix3D * Aptr; diff --git a/Core/Tools/WW3D/pluglib/nodefilt.cpp b/Core/Tools/WW3D/pluglib/nodefilt.cpp index be1d3886fad..2d24c17e6fb 100644 --- a/Core/Tools/WW3D/pluglib/nodefilt.cpp +++ b/Core/Tools/WW3D/pluglib/nodefilt.cpp @@ -245,14 +245,14 @@ BOOL AnimatedINodeFilter::Accept_Node(INode * node, TimeValue time) Control * rotcon = node->GetTMController()->GetRotationController(); int numkeys = 0; - if (poscon != NULL) { + if (poscon != nullptr) { IKeyControl * poskeys = GetKeyControlInterface(poscon); - if (poskeys != NULL) numkeys += poskeys->GetNumKeys(); + if (poskeys != nullptr) numkeys += poskeys->GetNumKeys(); } - if (rotcon != NULL) { + if (rotcon != nullptr) { IKeyControl * rotkeys = GetKeyControlInterface(rotcon); - if (rotkeys != NULL) numkeys += rotkeys->GetNumKeys(); + if (rotkeys != nullptr) numkeys += rotkeys->GetNumKeys(); } if (obj && !node->IsHidden() && numkeys > 0) { diff --git a/Core/Tools/WW3D/pluglib/nodelist.cpp b/Core/Tools/WW3D/pluglib/nodelist.cpp index ef13af11c7d..9d4bc0b6da3 100644 --- a/Core/Tools/WW3D/pluglib/nodelist.cpp +++ b/Core/Tools/WW3D/pluglib/nodelist.cpp @@ -84,10 +84,10 @@ class INodeListEntryClass INodeListClass::INodeListClass(TimeValue time,INodeFilterClass * inodefilter) : NumNodes(0), Time(time), - ListHead(NULL), + ListHead(nullptr), INodeFilter(inodefilter) { - if (INodeFilter == NULL) { + if (INodeFilter == nullptr) { INodeFilter = &_AnyFilter; } } @@ -110,10 +110,10 @@ INodeListClass::INodeListClass(TimeValue time,INodeFilterClass * inodefilter) : INodeListClass::INodeListClass(IScene * scene,TimeValue time,INodeFilterClass * inodefilter) : NumNodes(0), Time(time), - ListHead(NULL), + ListHead(nullptr), INodeFilter(inodefilter) { - if (INodeFilter == NULL) { + if (INodeFilter == nullptr) { INodeFilter = &_AnyFilter; } scene->EnumTree(this); @@ -135,10 +135,10 @@ INodeListClass::INodeListClass(IScene * scene,TimeValue time,INodeFilterClass * INodeListClass::INodeListClass(INode * root,TimeValue time,INodeFilterClass * nodefilter) : NumNodes(0), Time(time), - ListHead(NULL), + ListHead(nullptr), INodeFilter(nodefilter) { - if (INodeFilter == NULL) { + if (INodeFilter == nullptr) { INodeFilter = &_AnyFilter; } Add_Tree(root); @@ -160,10 +160,10 @@ INodeListClass::INodeListClass(INode * root,TimeValue time,INodeFilterClass * no INodeListClass::INodeListClass(INodeListClass & copyfrom,TimeValue time,INodeFilterClass * inodefilter) : NumNodes(0), Time(time), - ListHead(NULL), + ListHead(nullptr), INodeFilter(inodefilter) { - if (INodeFilter == NULL) { + if (INodeFilter == nullptr) { INodeFilter = &_AnyFilter; } for (unsigned i=0; i 0 && entry != NULL ) + while (index > 0 && entry != nullptr ) { entry = entry->Next; index--; @@ -290,7 +290,7 @@ void INodeListClass::Remove(int i) } INodeListEntryClass * deleteme = prev->Next; - if (deleteme != NULL) { + if (deleteme != nullptr) { prev->Next = prev->Next->Next; delete deleteme; } @@ -311,7 +311,7 @@ void INodeListClass::Remove(int i) *=============================================================================================*/ void INodeListClass::Add_Tree(INode * root) { - if (root == NULL) return; + if (root == nullptr) return; Insert(root); for (int i=0; iNumberOfChildren(); i++) { @@ -363,7 +363,7 @@ void INodeListClass::Sort(const INodeCompareClass & node_compare) INodeListEntryClass * INodeListClass::get_nth_item(int index) { INodeListEntryClass * entry = ListHead; - while (index > 0 && entry != NULL ) + while (index > 0 && entry != nullptr ) { entry = entry->Next; index--; diff --git a/Core/Tools/WW3D/pluglib/nodelist.h b/Core/Tools/WW3D/pluglib/nodelist.h index e7adc255e38..b39a44dabf0 100644 --- a/Core/Tools/WW3D/pluglib/nodelist.h +++ b/Core/Tools/WW3D/pluglib/nodelist.h @@ -60,10 +60,10 @@ class INodeListClass : public ITreeEnumProc { public: - INodeListClass(TimeValue time,INodeFilterClass * nodefilter = NULL); - INodeListClass(IScene * scene,TimeValue time,INodeFilterClass * nodefilter = NULL); - INodeListClass(INode * root,TimeValue time,INodeFilterClass * nodefilter = NULL); - INodeListClass(INodeListClass & copyfrom,TimeValue time,INodeFilterClass * inodefilter = NULL); + INodeListClass(TimeValue time,INodeFilterClass * nodefilter = nullptr); + INodeListClass(IScene * scene,TimeValue time,INodeFilterClass * nodefilter = nullptr); + INodeListClass(INode * root,TimeValue time,INodeFilterClass * nodefilter = nullptr); + INodeListClass(INodeListClass & copyfrom,TimeValue time,INodeFilterClass * inodefilter = nullptr); ~INodeListClass(); void Set_Filter(INodeFilterClass * inodefilter) { INodeFilter = inodefilter; } diff --git a/Core/Tools/WW3D/pluglib/rawfile.cpp b/Core/Tools/WW3D/pluglib/rawfile.cpp index 996312b9f94..b56bbb7b85f 100644 --- a/Core/Tools/WW3D/pluglib/rawfile.cpp +++ b/Core/Tools/WW3D/pluglib/rawfile.cpp @@ -294,7 +294,7 @@ void RawFileClass::Reset(void) Close(); if (Allocated && Filename) { free((char *)Filename); - Filename = NULL; + Filename = nullptr; Allocated = false; } } @@ -321,18 +321,18 @@ void RawFileClass::Reset(void) *=============================================================================================*/ char const * RawFileClass::Set_Name(char const * filename) { - if (Filename != NULL && Allocated) { + if (Filename != nullptr && Allocated) { free((char *)Filename); - Filename = NULL; + Filename = nullptr; Allocated = false; } - if (filename == NULL) return(NULL); + if (filename == nullptr) return(nullptr); Bias(0); char *nameptr = strdup(filename); - if (nameptr == NULL) { + if (nameptr == nullptr) { Error(ENOMEM, false, filename); } @@ -409,7 +409,7 @@ int RawFileClass::Open(int rights) ** Verify that there is a filename associated with this file object. If not, then this is a ** big error condition. */ - if (Filename == NULL) { + if (Filename == nullptr) { Error(ENOENT, false); } @@ -442,7 +442,7 @@ int RawFileClass::Open(int rights) Handle = fopen(Filename, "r"); #else Handle = CreateFileA(Filename, GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #endif break; @@ -451,7 +451,7 @@ int RawFileClass::Open(int rights) Handle = fopen(Filename, "w"); #else Handle = CreateFileA(Filename, GENERIC_WRITE, 0, - NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); #endif break; @@ -462,7 +462,7 @@ int RawFileClass::Open(int rights) // SKB 5/13/99 use OPEN_ALWAYS instead of CREATE_ALWAYS so that files // does not get destroyed. Handle = CreateFileA(Filename, GENERIC_READ | GENERIC_WRITE, 0, - NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr); #endif break; } @@ -511,7 +511,7 @@ int RawFileClass::Open(int rights) *=============================================================================================*/ bool RawFileClass::Is_Available(int forced) { - if (Filename == NULL) return(false); + if (Filename == nullptr) return(false); /* ** If the file is already open, then is must have already passed the availability check. @@ -540,7 +540,7 @@ bool RawFileClass::Is_Available(int forced) Handle=fopen(Filename,"r"); #else Handle = CreateFileA(Filename, GENERIC_READ, FILE_SHARE_READ, - NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); #endif if (Handle == NULL_HANDLE) { @@ -620,10 +620,10 @@ void RawFileClass::Close(void) * the file. This condition can result in fewer bytes being read than requested. Determine * * this by examining the return value. * * * - * INPUT: buffer -- Pointer to the buffer to read data into. If NULL is passed, no read * + * INPUT: buffer -- Pointer to the buffer to read data into. If nullptr is passed, no read * * is performed. * * * - * size -- The number of bytes to read. If NULL is passed, then no read is * + * size -- The number of bytes to read. If nullptr is passed, then no read is * * performed. * * * * OUTPUT: Returns with the number of bytes read into the buffer. If this number is less * @@ -675,7 +675,7 @@ int RawFileClass::Read(void * buffer, int size) if ((bytesread == 0)&&( ! feof(Handle))) readok=ferror(Handle); #else - readok=ReadFile(Handle, buffer, size, &(unsigned long&)bytesread, NULL); + readok=ReadFile(Handle, buffer, size, &(unsigned long&)bytesread, nullptr); #endif @@ -741,7 +741,7 @@ int RawFileClass::Write(void const * buffer, int size) if (byteswritten != size) writeok = FALSE; #else - writeok=WriteFile(Handle, buffer, size, &(unsigned long&)byteswritten, NULL); + writeok=WriteFile(Handle, buffer, size, &(unsigned long&)byteswritten, nullptr); #endif if (! writeok) { @@ -799,7 +799,7 @@ int RawFileClass::Seek(int pos, int dir) /* ** A file that is biased will have a seek operation modified so that the file appears to ** exist only within the bias range. All bytes outside of this range appear to be - ** non-existant. + ** non-existent. */ if (BiasLength != -1) { switch (dir) { @@ -891,7 +891,7 @@ int RawFileClass::Size(void) size=endpos-startpos; fsetpos(Handle,&curpos); #else - size = GetFileSize(Handle, NULL); + size = GetFileSize(Handle, nullptr); #endif /* @@ -1190,7 +1190,7 @@ int RawFileClass::Raw_Seek(int pos, int dir) dir = FILE_END; break; } - pos = SetFilePointer(Handle, pos, NULL, dir); + pos = SetFilePointer(Handle, pos, nullptr, dir); #endif /* diff --git a/Core/Tools/WW3D/pluglib/rawfile.h b/Core/Tools/WW3D/pluglib/rawfile.h index 40d81d696ae..61626403e42 100644 --- a/Core/Tools/WW3D/pluglib/rawfile.h +++ b/Core/Tools/WW3D/pluglib/rawfile.h @@ -47,7 +47,7 @@ #ifdef _UNIX #include #include "osdep.h" - #define NULL_HANDLE NULL + #define NULL_HANDLE nullptr #define HANDLE_TYPE FILE* #else #define NULL_HANDLE INVALID_HANDLE_VALUE @@ -105,7 +105,7 @@ class RawFileClass : public FileClass virtual void Close(void); virtual unsigned long Get_Date_Time(void); virtual bool Set_Date_Time(unsigned long datetime); - virtual void Error(int error, int canretry = false, char const * filename=NULL); + virtual void Error(int error, int canretry = false, char const * filename=nullptr); void Bias(int start, int length=-1); @@ -145,7 +145,7 @@ class RawFileClass : public FileClass #endif /* - ** This points to the filename as a NULL terminated string. It may point to either a + ** This points to the filename as a null-terminated string. It may point to either a ** constant or an allocated string as indicated by the "Allocated" flag. */ char const * Filename; @@ -179,11 +179,11 @@ class RawFileClass : public FileClass * RawFileClass::File_Name -- Returns with the filename associate with the file object. * * * * Use this routine to determine what filename is associated with this file object. If no * - * filename has yet been assigned, then this routing will return NULL. * + * filename has yet been assigned, then this routing will return null. * * * * INPUT: none * * * - * OUTPUT: Returns with a pointer to the file name associated with this file object or NULL * + * OUTPUT: Returns with a pointer to the file name associated with this file object or nullptr * * if one doesn't exist. * * * * WARNINGS: none * diff --git a/Core/Tools/WW3D/pluglib/rgb.h b/Core/Tools/WW3D/pluglib/rgb.h index 20b76bd4a6e..cb9110c6d62 100644 --- a/Core/Tools/WW3D/pluglib/rgb.h +++ b/Core/Tools/WW3D/pluglib/rgb.h @@ -42,7 +42,7 @@ class HSVClass; /* ** Each color entry is represented by this class. It holds the values for the color -** guns. The gun values are recorded in device dependant format, but the interface +** guns. The gun values are recorded in device dependent format, but the interface ** uses gun values from 0 to 255. */ class RGBClass @@ -78,7 +78,7 @@ class RGBClass friend class PaletteClass; /* - ** These hold the actual color gun values in machine independant scale. This + ** These hold the actual color gun values in machine independent scale. This ** means the values range from 0 to 255. */ unsigned char Red; diff --git a/Core/Tools/WW3D/pluglib/uarray.h b/Core/Tools/WW3D/pluglib/uarray.h index 1b89db61b3d..8312c808019 100644 --- a/Core/Tools/WW3D/pluglib/uarray.h +++ b/Core/Tools/WW3D/pluglib/uarray.h @@ -151,9 +151,9 @@ UniqueArrayClass::UniqueArrayClass(int initial_size,int growth_rate,HashCalcu template UniqueArrayClass::~UniqueArrayClass(void) { - if (HashTable != NULL) { + if (HashTable != nullptr) { delete[] HashTable; - HashTable = NULL; + HashTable = nullptr; } } diff --git a/Core/Tools/WW3D/pluglib/vector2.h b/Core/Tools/WW3D/pluglib/vector2.h index 91ff7d7e937..8cbd0f38db3 100644 --- a/Core/Tools/WW3D/pluglib/vector2.h +++ b/Core/Tools/WW3D/pluglib/vector2.h @@ -36,7 +36,7 @@ * Scalar Division Operator -- Divide a vector by a scalar * * Scalar Multiply Operator -- Multiply a vector by a scalar * * Vector Addition Operator -- Add two vectors * - * Vector Subtraction Operator -- Subract two vectors * + * Vector Subtraction Operator -- Subtract two vectors * * Vector Inner Product Operator -- Compute the inner or dot product * * Vector Equality Operator -- Detemine if two vectors are identical * * Equal_Within_Epsilon -- Determine if two vectors are identical within * @@ -45,7 +45,7 @@ * Vector2::Is_Valid -- Verifies that all components are valid floats * * Vector2::Update_Min -- sets each component of the vector to the min of this and a. * * Vector2::Update_Max -- sets each component of the vector to the max of this and a. * - * Vector2::Scale -- multiply components of a vector by independant scaling factors. * + * Vector2::Scale -- multiply components of a vector by independent scaling factors. * * Vector2::Lerp -- linearly interpolates two Vector2's * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ @@ -208,7 +208,7 @@ inline Vector2 operator + (const Vector2 &a,const Vector2 &b) } /************************************************************************** - * Vector Subtraction Operator -- Subract two vectors * + * Vector Subtraction Operator -- Subtract two vectors * * * * INPUT: * * * @@ -533,7 +533,7 @@ inline void Vector2::Update_Max (const Vector2 & a) /*********************************************************************************************** - * Vector2::Scale -- multiply components of a vector by independant scaling factors. * + * Vector2::Scale -- multiply components of a vector by independent scaling factors. * * * * INPUT: * * * @@ -625,7 +625,7 @@ inline float Distance(float x1, float y1, float x2, float y2) *=============================================================================================*/ inline void Vector2::Lerp(const Vector2 & a,const Vector2 & b,float t,Vector2 * set_result) { - assert(set_result != NULL); + assert(set_result != nullptr); set_result->X = (a.X + (b.X - a.X)*t); set_result->Y = (a.Y + (b.Y - a.Y)*t); } diff --git a/Core/Tools/WW3D/pluglib/vector3.h b/Core/Tools/WW3D/pluglib/vector3.h index 9249b8a5c1a..0cbb8c39e1f 100644 --- a/Core/Tools/WW3D/pluglib/vector3.h +++ b/Core/Tools/WW3D/pluglib/vector3.h @@ -36,7 +36,7 @@ * Scalar Division Operator -- Divide a vector by a scalar * * Scalar Multiply Operator -- Multiply a vector by a scalar * * Vector Addition Operator -- Add two vectors * - * Vector Subtraction Operator -- Subract two vectors * + * Vector Subtraction Operator -- Subtract two vectors * * Vector Inner Product Operator -- Compute the inner or dot product * * Vector Equality Operator -- Determine if two vectors are identical * * Vector Inequality Operator -- Determine if two vectors are identical * @@ -244,7 +244,7 @@ WWINLINE Vector3 operator + (const Vector3 &a,const Vector3 &b) } /************************************************************************** - * Vector Subtraction Operator -- Subract two vectors * + * Vector Subtraction Operator -- Subtract two vectors * * * * INPUT: * * * @@ -535,7 +535,7 @@ WWINLINE Vector3 Lerp(const Vector3 & a, const Vector3 & b, float alpha) *=============================================================================================*/ WWINLINE void Lerp(const Vector3 & a, const Vector3 & b, float alpha,Vector3 * set_result) { - assert(set_result != NULL); + assert(set_result != nullptr); set_result->X = (a.X + (b.X - a.X)*alpha); set_result->Y = (a.Y + (b.Y - a.Y)*alpha); set_result->Z = (a.Z + (b.Z - a.Z)*alpha); @@ -543,7 +543,7 @@ WWINLINE void Lerp(const Vector3 & a, const Vector3 & b, float alpha,Vector3 * s WWINLINE void Vector3::Lerp(const Vector3 & a, const Vector3 & b, float alpha,Vector3 * set_result) { - assert(set_result != NULL); + assert(set_result != nullptr); set_result->X = (a.X + (b.X - a.X)*alpha); set_result->Y = (a.Y + (b.Y - a.Y)*alpha); set_result->Z = (a.Z + (b.Z - a.Z)*alpha); @@ -563,7 +563,7 @@ WWINLINE void Vector3::Lerp(const Vector3 & a, const Vector3 & b, float alpha,Ve *=============================================================================================*/ WWINLINE void Vector3::Add(const Vector3 &a,const Vector3 &b,Vector3 * set_result) { - assert(set_result != NULL); + assert(set_result != nullptr); set_result->X = a.X + b.X; set_result->Y = a.Y + b.Y; set_result->Z = a.Z + b.Z; @@ -584,7 +584,7 @@ WWINLINE void Vector3::Add(const Vector3 &a,const Vector3 &b,Vector3 * set_resul *=============================================================================================*/ WWINLINE void Vector3::Subtract(const Vector3 &a,const Vector3 &b,Vector3 * set_result) { - assert(set_result != NULL); + assert(set_result != nullptr); set_result->X = a.X - b.X; set_result->Y = a.Y - b.Y; set_result->Z = a.Z - b.Z; diff --git a/Core/Tools/WW3D/pluglib/vector4.h b/Core/Tools/WW3D/pluglib/vector4.h index 620664a313d..e0145c6f6a8 100644 --- a/Core/Tools/WW3D/pluglib/vector4.h +++ b/Core/Tools/WW3D/pluglib/vector4.h @@ -36,7 +36,7 @@ * Scalar Division Operator -- Divide a vector by a scalar * * Scalar Multiply Operator -- Multiply a vector by a scalar * * Vector Addition Operator -- Add two vectors * - * Vector Subtraction Operator -- Subract two vectors * + * Vector Subtraction Operator -- Subtract two vectors * * Vector Inner Product Operator -- Compute the inner or dot product * * Vector Equality Operator -- Detemine if two vectors are identical * * Vector Inequality Operator -- Detemine if two vectors are identical * @@ -175,7 +175,7 @@ inline Vector4 operator + (const Vector4 &a,const Vector4 &b) } /************************************************************************** - * Vector Subtraction Operator -- Subract two vectors * + * Vector Subtraction Operator -- Subtract two vectors * * * * INPUT: * * * diff --git a/Core/Tools/WW3D/pluglib/w3d_file.h b/Core/Tools/WW3D/pluglib/w3d_file.h index 98f09b88e07..644cfa4fa15 100644 --- a/Core/Tools/WW3D/pluglib/w3d_file.h +++ b/Core/Tools/WW3D/pluglib/w3d_file.h @@ -310,7 +310,7 @@ struct W3dChunkHeader make the importer faster, the triangles will also be stored in this format. The application can read whichever chunk it wants to. - The mesh user text chunk is a NULL-terminated text buffer. + The mesh user text chunk is a null-terminated text buffer. ********************************************************************************/ @@ -359,9 +359,9 @@ struct W3dRGBStruct ///////////////////////////////////////////////////////////////////////////////////////////// struct W3dMaterialStruct { - char MaterialName[W3D_NAME_LEN]; // name of the material (NULL terminated) - char PrimaryName[W3D_NAME_LEN]; // primary texture name (NULL terminated) - char SecondaryName[W3D_NAME_LEN]; // secondary texture name (NULL terminated) + char MaterialName[W3D_NAME_LEN]; // name of the material (null-terminated) + char PrimaryName[W3D_NAME_LEN]; // primary texture name (null-terminated) + char SecondaryName[W3D_NAME_LEN]; // secondary texture name (null-terminated) uint32 RenderFlags; // Rendering flags uint8 Red; // Rgb colors uint8 Green; @@ -373,9 +373,9 @@ struct W3dMaterialStruct ///////////////////////////////////////////////////////////////////////////////////////////// struct W3dMaterial2Struct { - char MaterialName[W3D_NAME_LEN]; // name of the material (NULL terminated) - char PrimaryName[W3D_NAME_LEN]; // primary texture name (NULL terminated) - char SecondaryName[W3D_NAME_LEN]; // secondary texture name (NULL terminated) + char MaterialName[W3D_NAME_LEN]; // name of the material (null-terminated) + char PrimaryName[W3D_NAME_LEN]; // primary texture name (null-terminated) + char SecondaryName[W3D_NAME_LEN]; // secondary texture name (null-terminated) uint32 RenderFlags; // Rendering flags uint8 Red; // Rgb colors uint8 Green; @@ -788,8 +788,8 @@ struct W3dBitChannelStruct struct W3dHModelHeaderStruct { uint32 Version; - char Name[W3D_NAME_LEN]; // Name of this connection set (NULL terminated) - char HierarchyName[W3D_NAME_LEN]; // Name of hierarchy associated with these connections (NULL terminated) + char Name[W3D_NAME_LEN]; // Name of this connection set (null-terminated) + char HierarchyName[W3D_NAME_LEN]; // Name of hierarchy associated with these connections (null-terminated) uint16 NumConnections; }; diff --git a/Core/Tools/WW3D/pluglib/w3dquat.cpp b/Core/Tools/WW3D/pluglib/w3dquat.cpp index f50922fbe5a..f544ea304a7 100644 --- a/Core/Tools/WW3D/pluglib/w3dquat.cpp +++ b/Core/Tools/WW3D/pluglib/w3dquat.cpp @@ -337,7 +337,7 @@ void Slerp_Setup(const Quaternion & p,const Quaternion & q,SlerpInfoStruct * sle { float cos_t; - assert(slerpinfo != NULL); + assert(slerpinfo != nullptr); // cos theta = dot product of p and q cos_t = p.X * q.X + p.Y * q.Y + p.Z * q.Z + p.W * q.W; diff --git a/Core/Tools/WW3D/pluglib/w3dquat.h b/Core/Tools/WW3D/pluglib/w3dquat.h index b0ddb01e276..550396b2d7b 100644 --- a/Core/Tools/WW3D/pluglib/w3dquat.h +++ b/Core/Tools/WW3D/pluglib/w3dquat.h @@ -125,7 +125,7 @@ inline Quaternion operator + (const Quaternion & a,const Quaternion & b) return Quaternion(a[0] + b[0], a[1] + b[1], a[2] + b[2], a[3] + b[3]); } -// Subract two quaternions +// Subtract two quaternions inline Quaternion operator - (const Quaternion & a,const Quaternion & b) { return Quaternion(a[0] - b[0], a[1] - b[1], a[2] - b[2], a[3] - b[3]); @@ -231,7 +231,7 @@ inline Vector3 Quaternion::Rotate_Vector(const Vector3 & v) const inline void Quaternion::Rotate_Vector(const Vector3 & v,Vector3 * result) const { - assert(result != NULL); + assert(result != nullptr); float x = W*v.X + (Y*v.Z - v.Y*Z); float y = W*v.Y - (X*v.Z - v.X*Z); diff --git a/Core/Tools/WW3D/pluglib/wwfile.h b/Core/Tools/WW3D/pluglib/wwfile.h index 1ae0e39403a..217d45b2ebb 100644 --- a/Core/Tools/WW3D/pluglib/wwfile.h +++ b/Core/Tools/WW3D/pluglib/wwfile.h @@ -53,10 +53,6 @@ #define SEEK_END 2 // Seek from end of file. #endif -#ifndef NULL - #define NULL 0 -#endif - class FileClass { @@ -86,7 +82,7 @@ class FileClass virtual void Close(void) = 0; virtual unsigned long Get_Date_Time(void) {return(0);} virtual bool Set_Date_Time(unsigned long ) {return(false);} - virtual void Error(int error, int canretry = false, char const * filename=NULL) = 0; + virtual void Error(int error, int canretry = false, char const * filename=nullptr) = 0; virtual void * Get_File_Handle(void) { return reinterpret_cast(-1); } operator char const * () diff --git a/Core/Tools/assetcull/CMakeLists.txt b/Core/Tools/assetcull/CMakeLists.txt index ce70dc9ab7f..f38e1473d01 100644 --- a/Core/Tools/assetcull/CMakeLists.txt +++ b/Core/Tools/assetcull/CMakeLists.txt @@ -8,7 +8,7 @@ set_target_properties(core_assetcull PROPERTIES OUTPUT_NAME assetcull) target_sources(core_assetcull PRIVATE ${ASSETCULL_SRC}) target_link_libraries(core_assetcull PRIVATE - core_config + corei_always ) if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") diff --git a/Core/Tools/buildVersionUpdate/CMakeLists.txt b/Core/Tools/buildVersionUpdate/CMakeLists.txt index cad2418d55e..9b66a560d39 100644 --- a/Core/Tools/buildVersionUpdate/CMakeLists.txt +++ b/Core/Tools/buildVersionUpdate/CMakeLists.txt @@ -8,6 +8,6 @@ set_target_properties(core_buildversionupdate PROPERTIES OUTPUT_NAME buildversio target_sources(core_buildversionupdate PRIVATE ${BUILDVERSIONUPDATE_SRC}) target_link_libraries(core_buildversionupdate PRIVATE - core_config core_wwlib + corei_always ) diff --git a/Core/Tools/buildVersionUpdate/buildVersionUpdate.cpp b/Core/Tools/buildVersionUpdate/buildVersionUpdate.cpp index 18de6bd75b7..f20719c7404 100644 --- a/Core/Tools/buildVersionUpdate/buildVersionUpdate.cpp +++ b/Core/Tools/buildVersionUpdate/buildVersionUpdate.cpp @@ -83,13 +83,13 @@ int APIENTRY WinMain(HINSTANCE hInstance, */ int argc = 1; char * argv[20]; - argv[0] = NULL; + argv[0] = nullptr; char * token = strtok(lpCmdLine, " "); - while (argc < 20 && token != NULL) + while (argc < 20 && token != nullptr) { argv[argc++] = strtrim(token); - token = strtok(NULL, " "); + token = strtok(nullptr, " "); } int major = 1; @@ -110,27 +110,27 @@ int APIENTRY WinMain(HINSTANCE hInstance, if (filePtr) { char buffer[256]; - char *stringPtr = NULL; + char *stringPtr = nullptr; while (!feof(filePtr)) { fread(buffer, 256, 1, filePtr); - if ((stringPtr = strstr(buffer, VERSION_STRING)) != NULL) + if ((stringPtr = strstr(buffer, VERSION_STRING)) != nullptr) { char *ptr; // Looking for '#define VERSION "x.y.z"' ptr = strtok(stringPtr, " "); // The VERSION - ptr = strtok(NULL, "\n"); // The remainder + ptr = strtok(nullptr, "\n"); // The remainder if (*ptr == '\"') { ptr++; // Inc past the first " ptr = strtok(ptr, "."); // The first number major = atoi(ptr); - ptr = strtok(NULL, "."); // The second number + ptr = strtok(nullptr, "."); // The second number minor = atoi(ptr); - ptr = strtok(NULL, "\""); // The final number + ptr = strtok(nullptr, "\""); // The final number build = atoi(ptr); fclose(filePtr); diff --git a/Core/Tools/mangler/CMakeLists.txt b/Core/Tools/mangler/CMakeLists.txt index ae7e3ded640..012961be88b 100644 --- a/Core/Tools/mangler/CMakeLists.txt +++ b/Core/Tools/mangler/CMakeLists.txt @@ -67,8 +67,7 @@ target_include_directories(core_manglerlib PRIVATE ) target_link_libraries(core_manglerlib PRIVATE wsock32) target_link_libraries(core_manglerlib PUBLIC - core_config - core_utility + corei_always ) # mangler app diff --git a/Core/Tools/mangler/mangler.cpp b/Core/Tools/mangler/mangler.cpp index 5f758520f2a..86dcbf1707d 100644 --- a/Core/Tools/mangler/mangler.cpp +++ b/Core/Tools/mangler/mangler.cpp @@ -51,7 +51,7 @@ int main(int argc, char **argv) if( argc <= 1 ) { // No args - use a default config file - if ((conf = fopen("mangler.cfg", "r")) == NULL) { + if ((conf = fopen("mangler.cfg", "r")) == nullptr) { cout << "Cannot open mangler.cfg for reading." << endl; DisplayHelp(argv[0]); } @@ -64,7 +64,7 @@ int main(int argc, char **argv) else if( argc == 2 ) { // Use a user-supplied config file - if ((conf = fopen(argv[1], "r")) == NULL) { + if ((conf = fopen(argv[1], "r")) == nullptr) { cout << "Cannot open " << argv[1] << " for reading." << endl; DisplayHelp(argv[0]); } diff --git a/Core/Tools/mangler/manglertest.cpp b/Core/Tools/mangler/manglertest.cpp index 033359a3d18..cf13c9961e7 100644 --- a/Core/Tools/mangler/manglertest.cpp +++ b/Core/Tools/mangler/manglertest.cpp @@ -47,9 +47,9 @@ unsigned long ResolveIP(const char *Server) struct hostent *serverStruct; struct in_addr *serverNode; - if (Server == NULL) + if (Server == nullptr) { - ERRMSG("Can't resolve NULL"); + ERRMSG("Can't resolve null"); return 0; } @@ -59,7 +59,7 @@ unsigned long ResolveIP(const char *Server) strcpy(serverName, Server); serverStruct = gethostbyname(Server); - if (serverStruct == NULL) + if (serverStruct == nullptr) { ERRMSG("Can't resolve " << Server); return 0; @@ -82,7 +82,7 @@ int main(int argc, char **argv) if( argc <= 1 ) { // No args - use a default config file - if ((conf = fopen("manglertest.cfg", "r")) == NULL) { + if ((conf = fopen("manglertest.cfg", "r")) == nullptr) { cout << "Cannot open mangler.cfg for reading." << endl; DisplayHelp(argv[0]); } @@ -95,7 +95,7 @@ int main(int argc, char **argv) else if( argc == 2 ) { // Use a user-supplied config file - if ((conf = fopen(argv[1], "r")) == NULL) { + if ((conf = fopen(argv[1], "r")) == nullptr) { cout << "Cannot open " << argv[1] << " for reading." << endl; DisplayHelp(argv[0]); } diff --git a/Core/Tools/mangler/wlib/arraylist.h b/Core/Tools/mangler/wlib/arraylist.h index 58c8481842b..5b1d4356730 100644 --- a/Core/Tools/mangler/wlib/arraylist.h +++ b/Core/Tools/mangler/wlib/arraylist.h @@ -131,7 +131,7 @@ ArrayList::ArrayList() { Entries_=0; Slots_=0; - Vector_=NULL; + Vector_=nullptr; } // copy constructor @@ -140,7 +140,7 @@ ArrayList::ArrayList(ArrayList &other) { Entries_=0; Slots_=0; - Vector_=NULL; + Vector_=nullptr; (*this)=other; } @@ -653,7 +653,7 @@ bit8 ArrayList::growVector(void) T *newVector=(T *)(new uint8[newSlots * sizeof(T)]); memset(newVector,0,newSlots * sizeof(T)); // zero just to be safe - if (Vector_ != NULL) + if (Vector_ != nullptr) memcpy(newVector,Vector_,Entries_*sizeof(T)); delete[]((uint8 *)Vector_); // Get rid of the old vector without calling @@ -692,7 +692,7 @@ bit8 ArrayList::shrinkVector(void) // T *newVector=(T *)(new uint8[newSlots * sizeof(T)]); - if (Vector_ != NULL) // Vector_ better not be NULL! + if (Vector_ != nullptr) // Vector_ better not be nullptr! memcpy(newVector,Vector_,Entries_*sizeof(T)); delete[]((uint8 *)Vector_); // Get rid of the old vector without calling diff --git a/Core/Tools/mangler/wlib/configfile.cpp b/Core/Tools/mangler/wlib/configfile.cpp index b8d465b750a..ec38b358598 100644 --- a/Core/Tools/mangler/wlib/configfile.cpp +++ b/Core/Tools/mangler/wlib/configfile.cpp @@ -97,7 +97,7 @@ bit8 ConfigFile::readFile(FILE *in) continue; } - if (strchr(cptr,'=')==NULL) // All config entries must have a '=' + if (strchr(cptr,'=')==nullptr) // All config entries must have a '=' continue; key=cptr; key.truncate('='); @@ -152,7 +152,7 @@ bit8 ConfigFile::enumerate(int &index, int &offset, Wstring &key, Wstring &value } Critsec_.unlock(); - if (section==NULL) // no specified section, so any will do... + if (section==nullptr) // no specified section, so any will do... break; if (strlen(section)+2 >= strlen(key.get())) // key should have form: X[section] diff --git a/Core/Tools/mangler/wlib/configfile.h b/Core/Tools/mangler/wlib/configfile.h index eba5a02c811..cf793ca1e34 100644 --- a/Core/Tools/mangler/wlib/configfile.h +++ b/Core/Tools/mangler/wlib/configfile.h @@ -40,25 +40,25 @@ class ConfigFile ConfigFile(); ~ConfigFile(); bit8 readFile(FILE *config); - bit8 getString(IN Wstring &key,OUT Wstring &value, IN char *section=NULL) const; - bit8 getString(IN char *key,OUT Wstring &value, IN char *section=NULL) const; + bit8 getString(IN Wstring &key,OUT Wstring &value, IN char *section=nullptr) const; + bit8 getString(IN char *key,OUT Wstring &value, IN char *section=nullptr) const; - bit8 getInt(IN Wstring &key,OUT sint32 &value, IN char *section=NULL) const; - bit8 getInt(IN char *key,OUT sint32 &value, IN char *section=NULL) const; + bit8 getInt(IN Wstring &key,OUT sint32 &value, IN char *section=nullptr) const; + bit8 getInt(IN char *key,OUT sint32 &value, IN char *section=nullptr) const; - bit8 getInt(IN Wstring &key,OUT sint16 &value, IN char *section=NULL) const; - bit8 getInt(IN char *key,OUT sint16 &value, IN char *section=NULL) const; + bit8 getInt(IN Wstring &key,OUT sint16 &value, IN char *section=nullptr) const; + bit8 getInt(IN char *key,OUT sint16 &value, IN char *section=nullptr) const; // Enumerate through the config lines - bit8 enumerate(int &index, int &offset, Wstring &key, Wstring &value, IN char *section=NULL) const; + bit8 enumerate(int &index, int &offset, Wstring &key, Wstring &value, IN char *section=nullptr) const; // Manual update of config file - bit8 setString(IN Wstring &key,IN Wstring &value, IN char *section=NULL); - bit8 setString(IN char *key,IN Wstring &value, IN char *section=NULL); - bit8 setInt(IN Wstring &key,IN sint32 &value, IN char *section=NULL); - bit8 setInt(IN char *key,IN sint32 &value, IN char *section=NULL); - bit8 removeEntry(IN Wstring &key, IN char *section=NULL); - bit8 removeEntry(IN char *key, IN char *section=NULL); + bit8 setString(IN Wstring &key,IN Wstring &value, IN char *section=nullptr); + bit8 setString(IN char *key,IN Wstring &value, IN char *section=nullptr); + bit8 setInt(IN Wstring &key,IN sint32 &value, IN char *section=nullptr); + bit8 setInt(IN char *key,IN sint32 &value, IN char *section=nullptr); + bit8 removeEntry(IN Wstring &key, IN char *section=nullptr); + bit8 removeEntry(IN char *key, IN char *section=nullptr); bit8 writeFile(FILE *config); // Does not preserve comments, etc ArrayList sectionList; // stores the names of all sections diff --git a/Core/Tools/mangler/wlib/critsec.cpp b/Core/Tools/mangler/wlib/critsec.cpp index d02aae76c9b..f0df292f172 100644 --- a/Core/Tools/mangler/wlib/critsec.cpp +++ b/Core/Tools/mangler/wlib/critsec.cpp @@ -25,7 +25,7 @@ CritSec::CritSec() { #ifdef _UNIX - pthread_mutex_init(&Mutex_, NULL); + pthread_mutex_init(&Mutex_, nullptr); RefCount_ = 0; #elif defined(_WIN32) InitializeCriticalSection(&CritSec_); diff --git a/Core/Tools/mangler/wlib/critsec.h b/Core/Tools/mangler/wlib/critsec.h index 687667d74d8..07d21bee973 100644 --- a/Core/Tools/mangler/wlib/critsec.h +++ b/Core/Tools/mangler/wlib/critsec.h @@ -45,7 +45,7 @@ class CritSec CritSec(); ~CritSec(); - sint32 lock(int *refcount=NULL) RO; + sint32 lock(int *refcount=nullptr) RO; sint32 unlock(void) RO; protected: diff --git a/Core/Tools/mangler/wlib/dictionary.h b/Core/Tools/mangler/wlib/dictionary.h index 2a21b5273b3..fde42c3c4a7 100644 --- a/Core/Tools/mangler/wlib/dictionary.h +++ b/Core/Tools/mangler/wlib/dictionary.h @@ -83,7 +83,7 @@ Dictionary(uint32 (*hashFn)(const K &key)) : //Table is a pointer to a list of pointers (the hash table) table=(DNode **)new DNode* [size]; - assert(table!=NULL); + assert(table!=nullptr); memset((void *)table,0,size*sizeof(void *)); hashFunc=hashFn; @@ -151,13 +151,13 @@ void Dictionary::clear() for (i=0; ihashNext; delete(del); } - table[i]=NULL; + table[i]=nullptr; } entries=0; @@ -189,7 +189,7 @@ void Dictionary::print(FILE *out) RO fprintf(out," |\n"); fprintf(out,"[ ]"); - while (temp!=NULL) + while (temp!=nullptr) { fprintf(out,"--[ ]"); temp=temp->hashNext; @@ -223,27 +223,27 @@ bit8 Dictionary::iterate(INOUT int &index,INOUT int &offset, return(FALSE); temp=table[index]; - while ((temp==NULL)&&((++index) < (int)getSize())) + while ((temp==nullptr)&&((++index) < (int)getSize())) { temp=table[index]; offset=0; } - if (temp==NULL) // no more slots with data + if (temp==nullptr) // no more slots with data return(FALSE); uint32 i=0; - while ((temp!=NULL) && ((int)i < offset)) + while ((temp!=nullptr) && ((int)i < offset)) { temp=temp->hashNext; i++; } - if (temp==NULL) // should never happen + if (temp==nullptr) // should never happen return(FALSE); value=temp->value; - if (temp->hashNext==NULL) + if (temp->hashNext==nullptr) { index++; offset=0; @@ -272,28 +272,28 @@ bit8 Dictionary::iterate(INOUT int &index,INOUT int &offset, return(FALSE); temp=table[index]; - while ((temp==NULL)&&((++index) < (int)getSize())) + while ((temp==nullptr)&&((++index) < (int)getSize())) { temp=table[index]; offset=0; } - if (temp==NULL) // no more slots with data + if (temp==nullptr) // no more slots with data return(FALSE); uint32 i=0; - while ((temp!=NULL) && ((int)i < offset)) + while ((temp!=nullptr) && ((int)i < offset)) { temp=temp->hashNext; i++; } - if (temp==NULL) // should never happen + if (temp==nullptr) // should never happen return(FALSE); value=temp->value; key=temp->key; - if (temp->hashNext==NULL) + if (temp->hashNext==nullptr) { index++; offset=0; @@ -330,10 +330,10 @@ bit8 Dictionary::contains(IN K &key) RO node=table[offset]; - if (node==NULL) + if (node==nullptr) { return(FALSE); } // can't find it - while(node!=NULL) + while(node!=nullptr) { if ((node->key)==key) { return(TRUE); } @@ -367,7 +367,7 @@ bit8 Dictionary::add(IN K &key,IN V &value) float percent; item=(DNode *)new DNode; - assert(item!=NULL); + assert(item!=nullptr); #ifdef KEY_MEM_OPS memcpy(&(item->key),&key,sizeof(K)); @@ -381,7 +381,7 @@ bit8 Dictionary::add(IN K &key,IN V &value) item->value=value; #endif - item->hashNext=NULL; + item->hashNext=nullptr; //If key already exists, it will be overwritten remove(key); // Hopefully this will be false... @@ -390,7 +390,7 @@ bit8 Dictionary::add(IN K &key,IN V &value) node=table[offset]; - if (node==NULL) + if (node==nullptr) { table[offset]=item; } else { @@ -425,7 +425,7 @@ bit8 Dictionary::remove(IN K &key,OUT V &value) node=table[offset]; last=node; - if (node==NULL) + if (node==nullptr) return(FALSE); //special case table points to thing to delete @@ -454,7 +454,7 @@ bit8 Dictionary::remove(IN K &key,OUT V &value) bit8 retval=FALSE; // wow, didn't add this for years... (DOH!) //Now the case if the thing to delete is not the first - while (node!=NULL) + while (node!=nullptr) { #ifdef KEY_MEM_OPS if (0==memcmp(&(node->key),&key,sizeof(K))) @@ -508,7 +508,7 @@ bit8 Dictionary::removeAny(OUT K &key,OUT V &value) int i; offset=-1; for (i=0; i<(int)getSize(); i++) - if (table[i]!=NULL) + if (table[i]!=nullptr) { offset=i; break; @@ -544,7 +544,7 @@ bit8 Dictionary::removeAny(OUT K &key,OUT V &value) template bool Dictionary::getValue(IN K &key,OUT V &value) RO { - V *valptr=NULL; + V *valptr=nullptr; bool retval=getPointer(key,&valptr); if (retval && valptr) { @@ -572,17 +572,17 @@ bool Dictionary::getPointer(IN K &key,OUT V **valptr) RO node=table[offset]; - if (node==NULL) + if (node==nullptr) return(FALSE); #ifdef KEY_MEM_OPS - while ((node!=NULL)&&(memcmp(&(node->key),&key,sizeof(K)))) + while ((node!=nullptr)&&(memcmp(&(node->key),&key,sizeof(K)))) #else - while ((node!=NULL)&&( ! ((node->key)==key)) ) // odd syntax so you don't + while ((node!=nullptr)&&( ! ((node->key)==key)) ) // odd syntax so you don't #endif // have to do oper != { node=node->hashNext; } - if (node==NULL) + if (node==nullptr) { return(FALSE); } *valptr=&(node->value); @@ -615,13 +615,13 @@ void Dictionary::shrink(void) tableBits--; table=(DNode **)new DNode*[size]; - assert(table!=NULL); + assert(table!=nullptr); memset((void *)table,0,size*sizeof(void *)); for (i=0; ikey); first=table[offset]; @@ -654,13 +654,13 @@ void Dictionary::expand(void) tableBits++; table=(DNode **)new DNode* [size]; - assert(table!=NULL); + assert(table!=nullptr); memset((void *)table,0,size*sizeof(void *)); for (i=0; ikey); first=table[offset]; diff --git a/Core/Tools/mangler/wlib/filed.h b/Core/Tools/mangler/wlib/filed.h index 2d00ab1afa3..4d2a6fa29cd 100644 --- a/Core/Tools/mangler/wlib/filed.h +++ b/Core/Tools/mangler/wlib/filed.h @@ -26,7 +26,7 @@ class FileD : public OutputDevice FileD(IN char *filename, IN char *mode = "w") { out=fopen(filename,mode); - if (out==NULL) + if (out==nullptr) out=fopen("FileDev.out",mode); } diff --git a/Core/Tools/mangler/wlib/linkedlist.h b/Core/Tools/mangler/wlib/linkedlist.h index 8589c3c45c3..a0cc1908348 100644 --- a/Core/Tools/mangler/wlib/linkedlist.h +++ b/Core/Tools/mangler/wlib/linkedlist.h @@ -63,9 +63,9 @@ class LinkedList void clear(void); // Add a node after the zero based 'pos' - bit8 add(IN T &node,sint32 pos, OUT T **newnodeptr=NULL); - bit8 addTail(IN T &node, OUT T **newnodeptr=NULL); - bit8 addHead(IN T &node, OUT T **newnodeptr=NULL); + bit8 add(IN T &node,sint32 pos, OUT T **newnodeptr=nullptr); + bit8 addTail(IN T &node, OUT T **newnodeptr=nullptr); + bit8 addHead(IN T &node, OUT T **newnodeptr=nullptr); // Remove a node bit8 remove(OUT T &node,sint32 pos); @@ -106,7 +106,7 @@ template LinkedList::LinkedList() { Entries=0; - Head=Tail=Current=NULL; + Head=Tail=Current=nullptr; CurIndex=-1; // Not valid when 0 entries } @@ -115,7 +115,7 @@ template LinkedList::LinkedList(LinkedList &other) { Entries=0; - Head=Tail=Current=NULL; + Head=Tail=Current=nullptr; CurIndex=-1; // Not valid when 0 entries (*this)=other; } @@ -156,7 +156,7 @@ void LinkedList::clear() } Entries=0; CurIndex=-1; - Head=Tail=Current=NULL; + Head=Tail=Current=nullptr; } // When adding into a position, the new node goes at the zero based slot @@ -173,10 +173,10 @@ bit8 LinkedList::add(IN T &node,sint32 pos, OUT T **newnodeptr) pos=Entries; item=(LNode *)new LNode; - assert(item!=NULL); + assert(item!=nullptr); item->Node=node; // copy the passed in object - item->Prev=NULL; - item->Next=NULL; + item->Prev=nullptr; + item->Next=nullptr; if (newnodeptr) *newnodeptr=&(item->Node); @@ -228,7 +228,7 @@ bit8 LinkedList::add(IN T &node,sint32 pos, OUT T **newnodeptr) temp=Head->Next; // Can start at node '1' because head was special cased for (int i=1; iNext; - assert(temp!=NULL); + assert(temp!=nullptr); } item->Next=temp; item->Prev=temp->Prev; @@ -278,7 +278,7 @@ bit8 LinkedList::remove(OUT T &node, sint32 pos) if (pos==0) { item=Head; if (item->Next) - item->Next->Prev=NULL; + item->Next->Prev=nullptr; Head=item->Next; node=item->Node; Current=Head; @@ -287,7 +287,7 @@ bit8 LinkedList::remove(OUT T &node, sint32 pos) if (pos==Entries-1) { item=Tail; if (item->Prev) - item->Prev->Next=NULL; + item->Prev->Next=nullptr; Tail=item->Prev; node=item->Node; Current=Tail; @@ -297,10 +297,10 @@ bit8 LinkedList::remove(OUT T &node, sint32 pos) Entries--; if (Entries==0) { // Super paranoia check - assert(Current==NULL); + assert(Current==nullptr); assert(CurIndex==-1); - assert(Head==NULL); - assert(Tail==NULL); + assert(Head==nullptr); + assert(Tail==nullptr); } return(TRUE); } @@ -337,7 +337,7 @@ bit8 LinkedList::remove(OUT T &node, sint32 pos) item=Head->Next; // Can start at node '1' because head was special cased for (int i=1; iNext; - assert(item!=NULL); + assert(item!=nullptr); } item->Prev->Next=item->Next; @@ -441,7 +441,7 @@ bit8 LinkedList::getPointer(OUT T **node,sint32 pos) item=Head->Next; // Can start at node '1' because head was special cased for (int i=1; iNext; - assert(item!=NULL); + assert(item!=nullptr); } *node=&(item->Node); CurIndex=pos; diff --git a/Core/Tools/mangler/wlib/mboxd.h b/Core/Tools/mangler/wlib/mboxd.h index a45eff3700a..4f61e9ae7ca 100644 --- a/Core/Tools/mangler/wlib/mboxd.h +++ b/Core/Tools/mangler/wlib/mboxd.h @@ -29,7 +29,7 @@ class MboxD : public OutputDevice char *string=new char[len+1]; memset(string,0,len+1); memcpy(string,str,len); - MessageBox(NULL,string,"Debug Message", MB_OK | MB_ICONINFORMATION); + MessageBox(nullptr,string,"Debug Message", MB_OK | MB_ICONINFORMATION); delete[](string); return(len); } diff --git a/Core/Tools/mangler/wlib/monod.cpp b/Core/Tools/mangler/wlib/monod.cpp index 103409de5c2..ffda85ac28c 100644 --- a/Core/Tools/mangler/wlib/monod.cpp +++ b/Core/Tools/mangler/wlib/monod.cpp @@ -22,12 +22,12 @@ MonoD::MonoD(void) { #ifdef _WIN32 unsigned long retval; - handle = CreateFile("\\\\.\\MONO", GENERIC_READ|GENERIC_WRITE, 0, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + handle = CreateFile("\\\\.\\MONO", GENERIC_READ|GENERIC_WRITE, 0, nullptr, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (handle != INVALID_HANDLE_VALUE) { - DeviceIoControl(handle, (DWORD)IOCTL_MONO_CLEAR_SCREEN, NULL, 0, NULL, 0, + DeviceIoControl(handle, (DWORD)IOCTL_MONO_CLEAR_SCREEN, nullptr, 0, nullptr, 0, &retval,0); } #endif @@ -37,7 +37,7 @@ MonoD::~MonoD() { #ifdef _WIN32 CloseHandle(handle); - handle=NULL; + handle = nullptr; #endif } @@ -45,8 +45,8 @@ int MonoD::print(const char *str, int len) { #ifdef _WIN32 unsigned long retval; - WriteFile(handle, str, len, &retval, NULL); - ////DeviceIoControl(handle, (DWORD)IOCTL_MONO_PRINT_RAW, (void *)str, len, NULL, 0, + WriteFile(handle, str, len, &retval, nullptr); + ////DeviceIoControl(handle, (DWORD)IOCTL_MONO_PRINT_RAW, (void *)str, len, nullptr, 0, //// &retval,0); return(len); #else diff --git a/Core/Tools/mangler/wlib/sem4.cpp b/Core/Tools/mangler/wlib/sem4.cpp index e11b95a362f..12ccb5c6480 100644 --- a/Core/Tools/mangler/wlib/sem4.cpp +++ b/Core/Tools/mangler/wlib/sem4.cpp @@ -34,7 +34,7 @@ Sem4::Sem4() #ifndef _WIN32 sem_init(&sem,1,1); #else - sem = CreateSemaphore(NULL, 1, 1, NULL); + sem = CreateSemaphore(nullptr, 1, 1, nullptr); #endif } @@ -43,7 +43,7 @@ Sem4::Sem4(uint32 value) #ifndef _WIN32 sem_init(&sem,1,value); #else - sem = CreateSemaphore(NULL, value, value, NULL); + sem = CreateSemaphore(nullptr, value, value, nullptr); #endif } @@ -84,7 +84,7 @@ sint32 Sem4::Post(void) const #else if (!sem) return -1; - if (!ReleaseSemaphore(sem, 1 ,NULL)) + if (!ReleaseSemaphore(sem, 1 ,nullptr)) return -1; return 0; #endif diff --git a/Core/Tools/mangler/wlib/streamer.cpp b/Core/Tools/mangler/wlib/streamer.cpp index 061baad77db..f81be59597f 100644 --- a/Core/Tools/mangler/wlib/streamer.cpp +++ b/Core/Tools/mangler/wlib/streamer.cpp @@ -28,7 +28,7 @@ #define STREAMER_UNBUFFERED 0 #endif -Streamer::Streamer() : streambuf(), Output_Device(NULL), Buf(NULL) +Streamer::Streamer() : streambuf(), Output_Device(nullptr), Buf(nullptr) { #if defined(USING_STLPORT) || (defined(_MSC_VER) && _MSC_VER < 1300) int state=unbuffered(); @@ -101,7 +101,7 @@ int Streamer::underflow(void) int Streamer::doallocate() { - if (Buf==NULL) + if (Buf==nullptr) { Buf=new char[(2*STREAMER_BUFSIZ)]; // deleted by destructor memset(Buf,0,2*STREAMER_BUFSIZ); diff --git a/Core/Tools/mangler/wlib/threadfac.cpp b/Core/Tools/mangler/wlib/threadfac.cpp index e9934e71b6d..3973335f8fb 100644 --- a/Core/Tools/mangler/wlib/threadfac.cpp +++ b/Core/Tools/mangler/wlib/threadfac.cpp @@ -52,7 +52,7 @@ struct ThreadInformation // // Start a thread inside a class // -bit8 ThreadFactory::startThread(Runnable &runable, void *data, bit8 destroy) +bit8 ThreadFactory::startThread(Runnable &runnable, void *data, bit8 destroy) { #ifdef _REENTRANT @@ -64,7 +64,7 @@ bit8 ThreadFactory::startThread(Runnable &runable, void *data, bit8 destroy) ThreadInformation *tInfo=new ThreadInformation; - tInfo->startPoint=(void *)&runable; + tInfo->startPoint=(void *)&runnable; tInfo->data=data; tInfo->destroy=destroy; @@ -73,15 +73,15 @@ bit8 ThreadFactory::startThread(Runnable &runable, void *data, bit8 destroy) // use all the normal C library stuff. (IMPORTANT!!!) uint32 handle; uint32 stup1d; - handle=_beginthreadex(NULL,0, threadClassLauncher, tInfo, 0, &stup1d); - if (handle!=NULL) + handle=_beginthreadex(nullptr,0, threadClassLauncher, tInfo, 0, &stup1d); + if (handle!=nullptr) return(TRUE); else { { - runable.CritSec_.lock(); - runable.ThreadCount_--; // Ok, so it didn't really start - runable.CritSec_.unlock(); + runnable.CritSec_.lock(); + runnable.ThreadCount_--; // Ok, so it didn't really start + runnable.CritSec_.unlock(); } return(FALSE); } @@ -92,15 +92,15 @@ bit8 ThreadFactory::startThread(Runnable &runable, void *data, bit8 destroy) pthread_attr_init(&threadAttr); pthread_attr_setdetachstate(&threadAttr, PTHREAD_CREATE_DETACHED); pthread_attr_setscope(&threadAttr,PTHREAD_SCOPE_SYSTEM); - retval=pthread_create(NULL,&threadAttr, threadClassLauncher, tInfo); + retval=pthread_create(nullptr,&threadAttr, threadClassLauncher, tInfo); if (retval==0) return(TRUE); else { { - runable.CritSec_.lock(); - runable.ThreadCount_--; // Ok, so it didn't really start - runable.CritSec_.unlock(); + runnable.CritSec_.lock(); + runnable.ThreadCount_--; // Ok, so it didn't really start + runnable.CritSec_.unlock(); } return(FALSE); } @@ -126,8 +126,8 @@ bit8 ThreadFactory::startThread(void (*start_func)(void *), void *data) // use all the normal C library stuff. (IMPORTANT!!!) uint32 handle; unsigned temp; - handle=_beginthreadex(NULL,0, threadFuncLauncher, tInfo, 0, &temp); - if (handle!=NULL) + handle=_beginthreadex(nullptr,0, threadFuncLauncher, tInfo, 0, &temp); + if (handle!=nullptr) return(TRUE); return(FALSE); #else // UNIX @@ -137,7 +137,7 @@ bit8 ThreadFactory::startThread(void (*start_func)(void *), void *data) pthread_attr_init(&threadAttr); pthread_attr_setdetachstate(&threadAttr, PTHREAD_CREATE_DETACHED); pthread_attr_setscope(&threadAttr,PTHREAD_SCOPE_SYSTEM); - retval=pthread_create(NULL,&threadAttr, threadFuncLauncher, tInfo); + retval=pthread_create(nullptr,&threadAttr, threadFuncLauncher, tInfo); if (retval==0) return(TRUE); else diff --git a/Core/Tools/mangler/wlib/threadfac.h b/Core/Tools/mangler/wlib/threadfac.h index 027de9be53b..68d8fe0bd71 100644 --- a/Core/Tools/mangler/wlib/threadfac.h +++ b/Core/Tools/mangler/wlib/threadfac.h @@ -74,7 +74,7 @@ class ThreadFactory { public: static bit8 startThread(void (*start_func)(void *), void *data); - static bit8 startThread(Runnable &runable, void *data, bit8 destroy=FALSE); + static bit8 startThread(Runnable &runnable, void *data, bit8 destroy=FALSE); }; diff --git a/Core/Tools/mangler/wlib/wdebug.cpp b/Core/Tools/mangler/wlib/wdebug.cpp index a7490a1bbb1..505b6330cc8 100644 --- a/Core/Tools/mangler/wlib/wdebug.cpp +++ b/Core/Tools/mangler/wlib/wdebug.cpp @@ -22,22 +22,22 @@ #include "odevice.h" -static MsgManager *msg_manager=NULL; +static MsgManager *msg_manager=nullptr; static int debug_enabled=0; -static ostream *debug_ostream=NULL; +static ostream *debug_ostream=nullptr; static Streamer debug_streamer; static int info_enabled=0; -static ostream *info_ostream=NULL; +static ostream *info_ostream=nullptr; static Streamer info_streamer; static int warn_enabled=0; -static ostream *warn_ostream=NULL; +static ostream *warn_ostream=nullptr; static Streamer warn_streamer; static int error_enabled=0; -static ostream *error_ostream=NULL; +static ostream *error_ostream=nullptr; static Streamer error_streamer; @@ -51,7 +51,7 @@ CritSec DebugLibSemaphore; int MsgManager::setAllStreams(OutputDevice *device) { - if (device==NULL) + if (device==nullptr) return(1); DEBUGLOCK; @@ -86,10 +86,10 @@ int MsgManager::ReplaceAllStreams(FileD * output_device, IN char *device_filenam delete(warn_ostream); delete(error_ostream); - if (output_device != NULL) + if (output_device != nullptr) { delete(output_device); - output_device = NULL; + output_device = nullptr; } rename(device_filename, copy_filename); @@ -117,7 +117,7 @@ int MsgManager::ReplaceAllStreams(FileD * output_device, IN char *device_filenam int MsgManager::setDebugStream(OutputDevice *device) { - if (device==NULL) + if (device==nullptr) return(1); DEBUGLOCK; @@ -130,7 +130,7 @@ int MsgManager::setDebugStream(OutputDevice *device) int MsgManager::setInfoStream(OutputDevice *device) { - if (device==NULL) + if (device==nullptr) return(1); DEBUGLOCK; @@ -143,7 +143,7 @@ int MsgManager::setInfoStream(OutputDevice *device) int MsgManager::setWarnStream(OutputDevice *device) { - if (device==NULL) + if (device==nullptr) return(1); DEBUGLOCK; @@ -156,7 +156,7 @@ int MsgManager::setWarnStream(OutputDevice *device) int MsgManager::setErrorStream(OutputDevice *device) { - if (device==NULL) + if (device==nullptr) return(1); DEBUGLOCK; diff --git a/Core/Tools/mangler/wlib/wdebug.h b/Core/Tools/mangler/wlib/wdebug.h index e16319f4daf..5af0c8658f8 100644 --- a/Core/Tools/mangler/wlib/wdebug.h +++ b/Core/Tools/mangler/wlib/wdebug.h @@ -25,8 +25,8 @@ MT-LEVEL The debugging module is pretty good for debugging and it has some message printing stuff as well. The basic idea is that you write a class that inherits from OutputDevice (several are provided) and assign that output -device to a stream. There are seperate streams for debugging, information, -warning, and error messages. Each one can have a seperate output device, +device to a stream. There are separate streams for debugging, information, +warning, and error messages. Each one can have a separate output device, or they can all have the same one. Debugging messages only get compiled in if your module defines 'DEBUG'. If you don't define debug, then not even the text of the debugging message gets into the binary. All the other diff --git a/Core/Tools/mangler/wlib/wstring.cpp b/Core/Tools/mangler/wlib/wstring.cpp index a19c9aaa002..5f5d558c1cb 100644 --- a/Core/Tools/mangler/wlib/wstring.cpp +++ b/Core/Tools/mangler/wlib/wstring.cpp @@ -39,15 +39,15 @@ string to it's own memory (for assignment or construction). #define PADSIZE 32 // include a little padding on alloc for future growth -Wstring::Wstring() : str(NULL), strsize(0) +Wstring::Wstring() : str(nullptr), strsize(0) { } -Wstring::Wstring(const char *string):str(NULL), strsize(0) +Wstring::Wstring(const char *string):str(nullptr), strsize(0) { set(string); } -Wstring::Wstring(const Wstring &other):str(NULL), strsize(0) +Wstring::Wstring(const Wstring &other):str(nullptr), strsize(0) { - if (other.str!=NULL) + if (other.str!=nullptr) { str=new char[strlen(other.str)+PADSIZE+1]; strsize=strlen(other.str)+PADSIZE+1; @@ -62,10 +62,10 @@ Wstring::~Wstring() bool Wstring::operator<(const Wstring &other) const { - if (str == NULL && other.str == NULL) + if (str == nullptr && other.str == nullptr) return false; - if (str == NULL) + if (str == nullptr) return true; return ( strcmp(str, other.str) < 0 ); @@ -73,7 +73,7 @@ bool Wstring::operator<(const Wstring &other) const bit8 Wstring::operator==(const char *other) const { - if ((str==NULL)&&(other==NULL)) + if ((str==nullptr)&&(other==nullptr)) return(TRUE); if(strcmp(str, other) != 0) return(FALSE); @@ -83,10 +83,10 @@ bit8 Wstring::operator==(const char *other) const bit8 Wstring::operator==(const Wstring &other) const { - if((str == NULL) && (other.str == NULL)) + if((str == nullptr) && (other.str == nullptr)) return(TRUE); - if((str == NULL) || (other.str == NULL)) + if((str == nullptr) || (other.str == nullptr)) return(FALSE); if(strcmp(str, other.str) != 0) @@ -107,10 +107,10 @@ bit8 Wstring::operator!=(const char *other) const bit8 Wstring::operator!=(const Wstring &other) const { - if((str == NULL) && (other.str == NULL)) + if((str == nullptr) && (other.str == nullptr)) return(FALSE); - if((str == NULL) || (other.str == NULL)) + if((str == nullptr) || (other.str == nullptr)) return(TRUE); if(strcmp(str, other.str) != 0) @@ -141,7 +141,7 @@ bit8 Wstring::cat(const char *s) { uint32 len; - if (s==NULL) // it's OK to cat nothing + if (s==nullptr) // it's OK to cat nothing return(TRUE); // Determine the length of the resultant string. @@ -240,14 +240,14 @@ char Wstring::remove(sint32 pos,sint32 count) bit8 Wstring::removeChar(char c) { int len=0; - char *cptr=NULL; + char *cptr=nullptr; bit8 removed=FALSE; - if (str==NULL) + if (str==nullptr) return(FALSE); len=strlen(str); - while ((cptr=strchr(str,c)) !=NULL) + while ((cptr=strchr(str,c)) !=nullptr) { memmove(cptr,cptr+1,len-1-((int)(cptr-str))); len--; @@ -267,7 +267,7 @@ void Wstring::clear(void) { delete[](str); strsize=0; - str=NULL; + str=nullptr; } // This is usually used for raw storage instead of string ops... @@ -308,7 +308,7 @@ char Wstring::get(uint32 index) const uint32 Wstring::length(void) const { - if(str == NULL) + if(str == nullptr) return(0); return((uint32)strlen(str)); } @@ -317,7 +317,7 @@ uint32 Wstring::length(void) const // Insert at given position and shift old stuff to right bit8 Wstring::insert(const char *instring, uint32 pos) { - if (str==NULL) + if (str==nullptr) return(set(instring)); if (pos>strlen(str)) pos=strlen(str); @@ -397,7 +397,7 @@ bit8 Wstring::replace(const char *replaceThis,const char *withThis) if(!dest.cat(src)) return(FALSE); - src=NULL; + src=nullptr; } } return(set(dest.get())); @@ -445,7 +445,7 @@ char Wstring::set(uint32 size, const char *string) // work in all cases, but this should be good enough for 99% of Wstring usage. char Wstring::setFormatted(const char *msg, ...) { - if( msg == NULL || strlen(msg) <= 0 ) return FALSE; + if( msg == nullptr || strlen(msg) <= 0 ) return FALSE; char* string; va_list args; @@ -506,18 +506,18 @@ bit8 Wstring::truncate(char c) { sint32 len; - if (str==NULL) + if (str==nullptr) return(FALSE); char *cptr=strchr(str,c); - if (cptr==NULL) + if (cptr==nullptr) return(FALSE); len=(sint32)(cptr-str); truncate((uint32)len); return(TRUE); } -// Get a token from this string that's seperated by one or more +// Get a token from this string that's separated by one or more // chars from the 'delim' string , start at offset & return offset sint32 Wstring::getToken(int offset,const char *delim,Wstring &out) const { @@ -529,7 +529,7 @@ sint32 Wstring::getToken(int offset,const char *delim,Wstring &out) const return(-1); for (i=offset; i<(int)length(); i++) { - if(strchr(delim,str[i])==NULL) + if(strchr(delim,str[i])==nullptr) break; } if (i>=(int)length()) @@ -537,7 +537,7 @@ sint32 Wstring::getToken(int offset,const char *delim,Wstring &out) const start=i; for (; i<(int)length(); i++) { - if(strchr(delim,str[i])!=NULL) + if(strchr(delim,str[i])!=nullptr) break; } stop=i-1; @@ -558,7 +558,7 @@ sint32 Wstring::getLine(int offset, Wstring &out) return(-1); for (; i<(int)length(); i++) { - if(strchr("\r\n",str[i])!=NULL) + if(strchr("\r\n",str[i])!=nullptr) break; } stop=i; @@ -575,7 +575,7 @@ sint32 Wstring::getLine(int offset, Wstring &out) // void Wstring::strgrow(int length) { - if (str==NULL) + if (str==nullptr) { str=new char[length+PADSIZE]; str[0]=0; diff --git a/Core/Tools/mangler/wlib/wstypes.h b/Core/Tools/mangler/wlib/wstypes.h index c13ef1fa3c8..f46fd77ab86 100644 --- a/Core/Tools/mangler/wlib/wstypes.h +++ b/Core/Tools/mangler/wlib/wstypes.h @@ -72,10 +72,6 @@ Standard type definitions for the sake of portability and readability. #define MAX(x,y) (((x)>(y))?(x):(y)) #endif -#ifndef NULL -#define NULL 0 -#endif - //These are used for readability purposes mostly, when a method takes a // pointer or reference these help specify what will happen to the data // that is sent in. diff --git a/Core/Tools/mangler/wlib/xtime.cpp b/Core/Tools/mangler/wlib/xtime.cpp index d36a7ec1875..95f6533d144 100644 --- a/Core/Tools/mangler/wlib/xtime.cpp +++ b/Core/Tools/mangler/wlib/xtime.cpp @@ -205,7 +205,7 @@ int main(int argc, char *argv[]) unixtime.tv_usec=0; //gettimeofday(&unixtime,&unixtzone); - //ttime=time(NULL); + //ttime=time(nullptr); tmtime=*gmtime(&ttime); printf("TIME->CTIME = %s\n",ctime(&ttime)); diff --git a/Core/Tools/mangler/wnet/field.cpp b/Core/Tools/mangler/wnet/field.cpp index 699b52507cd..a8f405bd145 100644 --- a/Core/Tools/mangler/wnet/field.cpp +++ b/Core/Tools/mangler/wnet/field.cpp @@ -51,56 +51,56 @@ void FieldClass::Clear(void) strcpy(ID,""); DataType=0; Size=0; - Data=NULL; - Next=NULL; + Data=nullptr; + Next=nullptr; } FieldClass::FieldClass(char *id, char data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, unsigned char data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, short data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, unsigned short data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, long data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, unsigned long data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, char *data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, void *data, int length) { - Data=NULL; + Data=nullptr; Set(id,data,length); } diff --git a/Core/Tools/mangler/wnet/field.h b/Core/Tools/mangler/wnet/field.h index de573ddbeec..da3e5d00d39 100644 --- a/Core/Tools/mangler/wnet/field.h +++ b/Core/Tools/mangler/wnet/field.h @@ -35,6 +35,8 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +#pragma once + #define FIELD_HEADER_SIZE (sizeof(FieldClass) - (sizeof(void *) * 2)) #define TYPE_CHAR 1 diff --git a/Core/Tools/mangler/wnet/packet.cpp b/Core/Tools/mangler/wnet/packet.cpp index 8cda4f64b01..5426d75b6ae 100644 --- a/Core/Tools/mangler/wnet/packet.cpp +++ b/Core/Tools/mangler/wnet/packet.cpp @@ -114,7 +114,7 @@ PacketClass::PacketClass(char *curbuf) ID = *((short *)curbuf); curbuf += sizeof(unsigned short); ID = ntohs(ID); - Head = NULL; + Head = nullptr; // // Calculate the remaining size so that we can loop through the @@ -268,7 +268,7 @@ FieldClass *PacketClass::Find_Field(char *id) if ( strncmp(id, current->ID, 4) == 0) return current; } - return NULL; + return nullptr; } // gks 9/25/2000 @@ -280,7 +280,7 @@ FieldClass *PacketClass::Get_Field_At(int position) } if (current) return current; - else return NULL; + else return nullptr; } // gks 9/25/2000 diff --git a/Core/Tools/mangler/wnet/tcp.cpp b/Core/Tools/mangler/wnet/tcp.cpp index 66ea079c7af..f48622cd564 100644 --- a/Core/Tools/mangler/wnet/tcp.cpp +++ b/Core/Tools/mangler/wnet/tcp.cpp @@ -472,7 +472,7 @@ char *TCP::Gets(char *string,int n,int whichFD) whichFD=GetFD(); if (whichFD <= 0) - return(NULL); + return(nullptr); memset(string,0,n); @@ -485,7 +485,7 @@ char *TCP::Gets(char *string,int n,int whichFD) if (! FD_ISSET(whichFD,&fdSet)) { DBGMSG("Gets timeout: " << inputDelay); - return(NULL); + return(nullptr); } retval=Read((unsigned char *)&c,1,whichFD); @@ -499,7 +499,7 @@ char *TCP::Gets(char *string,int n,int whichFD) else if ((retval==0)&&(i==0)) { DBGMSG("Remote endpoint closed (1)"); - return(NULL); + return(nullptr); } else if (retval==0) return(string); @@ -551,8 +551,8 @@ sint32 TCP::TimedRead(uint8 *msg,uint32 len,int seconds,sint32 whichFD) sint32 bytes_read=0; sint32 retval; - time_t stop_time=time(NULL)+seconds; - while ((time(NULL)<=stop_time)&&((uint32)bytes_read=0) done=1; @@ -892,7 +892,7 @@ bit8 TCP::Bind(char *Host,uint16 port,bit8 reuseAddr) strcpy(hostName, Host); hostStruct = gethostbyname(Host); - if (hostStruct == NULL) + if (hostStruct == nullptr) return (0); hostNode = (struct in_addr *) hostStruct->h_addr; return ( Bind(ntohl(hostNode->s_addr),port,reuseAddr) ); @@ -978,7 +978,7 @@ bit8 TCP::Connect(char *Host,uint16 port) strcpy(hostName, Host); hostStruct = gethostbyname(Host); - if (hostStruct == NULL) + if (hostStruct == nullptr) {ERRMSG("Can't resolve host");return (0);} hostNode = (struct in_addr *) hostStruct->h_addr; return ( Connect(ntohl(hostNode->s_addr),port) ); @@ -1064,7 +1064,7 @@ bit8 TCP::ConnectAsync(char *Host,uint16 port) strcpy(hostName, Host); hostStruct = gethostbyname(Host); - if (hostStruct == NULL) + if (hostStruct == nullptr) return (0); hostNode = (struct in_addr *) hostStruct->h_addr; return ( ConnectAsync(ntohl(hostNode->s_addr),port) ); diff --git a/Core/Tools/mangler/wnet/udp.cpp b/Core/Tools/mangler/wnet/udp.cpp index bba9479b658..96037517e29 100644 --- a/Core/Tools/mangler/wnet/udp.cpp +++ b/Core/Tools/mangler/wnet/udp.cpp @@ -40,7 +40,7 @@ sint32 UDP::Bind(char *Host,uint16 port) strcpy(hostName, Host); hostStruct = gethostbyname(Host); - if (hostStruct == NULL) + if (hostStruct == nullptr) return (0); hostNode = (struct in_addr *) hostStruct->h_addr; return ( Bind(ntohl(hostNode->s_addr),port) ); @@ -158,7 +158,7 @@ sint32 UDP::Read(uint8 *msg,uint32 len,sockaddr_in *from) sint32 retval; int alen=sizeof(sockaddr_in); - if (from!=NULL) + if (from!=nullptr) { retval=recvfrom(fd,(char *)msg,len,0,(struct sockaddr *)from,&alen); #ifdef _WIN32 @@ -168,7 +168,7 @@ sint32 UDP::Read(uint8 *msg,uint32 len,sockaddr_in *from) } else { - retval=recvfrom(fd,(char *)msg,len,0,NULL,NULL); + retval=recvfrom(fd,(char *)msg,len,0,nullptr,nullptr); #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; @@ -267,7 +267,7 @@ int UDP::Wait(sint32 sec,sint32 usec,fd_set &givenSet,fd_set &returnSet) while( ! done) { if (noTimeout) - retval=select(givenMax+1,&returnSet,0,0,NULL); + retval=select(givenMax+1,&returnSet,0,0,nullptr); else { timeout.GetTimevalMT(tv); diff --git a/Core/Tools/matchbot/CMakeLists.txt b/Core/Tools/matchbot/CMakeLists.txt index b37c128ccc6..f9002e54272 100644 --- a/Core/Tools/matchbot/CMakeLists.txt +++ b/Core/Tools/matchbot/CMakeLists.txt @@ -71,9 +71,8 @@ target_include_directories(core_matchbot PRIVATE ) target_link_libraries(core_matchbot PRIVATE + corei_always gamespy::gamespy - core_config - core_utility stlport ) diff --git a/Core/Tools/matchbot/encrypt.cpp b/Core/Tools/matchbot/encrypt.cpp index c0ed7b12e15..d4519c4d3dd 100644 --- a/Core/Tools/matchbot/encrypt.cpp +++ b/Core/Tools/matchbot/encrypt.cpp @@ -69,7 +69,7 @@ char *do_encrypt(char *String) for (Cnt = 0; Cnt < MAX_ENCRYPTED_STRING; Cnt++) Return_Buffer[Cnt] = Base_String[Temp_Buffer[Cnt] & 0x3F]; - Return_Buffer[Cnt] = NULL; + Return_Buffer[Cnt] = '\0'; return (Return_Buffer); } diff --git a/Core/Tools/matchbot/generals.cpp b/Core/Tools/matchbot/generals.cpp index 8c6837a8790..408e3193b53 100644 --- a/Core/Tools/matchbot/generals.cpp +++ b/Core/Tools/matchbot/generals.cpp @@ -135,7 +135,7 @@ GeneralsUser::GeneralsUser(void) minPoints = maxPoints = 100; country = color = -1; pseudoPing.clear(); - matchStart = time(NULL); + matchStart = time(nullptr); timeToWiden = 0; widened = false; numPlayers = 2; @@ -189,12 +189,12 @@ GeneralsMatcher::GeneralsMatcher() INFMSG("weightAvgPoints = " << weightAvgPoints); INFMSG("totalWeight = " << totalWeight); - Global.config.getInt("SecondsBetweenPoolSizeAnnouncements", m_secondsBetweenPoolSizeAnnouncements, NULL); + Global.config.getInt("SecondsBetweenPoolSizeAnnouncements", m_secondsBetweenPoolSizeAnnouncements, nullptr); if (m_secondsBetweenPoolSizeAnnouncements < 10) { m_secondsBetweenPoolSizeAnnouncements = 10; } - m_nextPoolSizeAnnouncement = time(NULL); + m_nextPoolSizeAnnouncement = time(nullptr); } void GeneralsMatcher::init(void) @@ -434,7 +434,7 @@ void GeneralsMatcher::sendMatchInfo(std::string name1, std::string name2, std::s void GeneralsMatcher::checkMatches(void) { bool showPoolSize = false; - time_t now = time(NULL); + time_t now = time(nullptr); if (now > m_nextPoolSizeAnnouncement) { m_nextPoolSizeAnnouncement = now + m_secondsBetweenPoolSizeAnnouncements; @@ -524,7 +524,7 @@ void GeneralsMatcher::checkMatchesInUserMap(UserMap& userMap, int ladderID, int UserMap::iterator i1, i2, i3, i4, i5, i6, i7, i8; GeneralsUser *u1, *u2, *u3, *u4, *u5, *u6, *u7, *u8; static const double fitnessThreshold = 0.3; - time_t now = time(NULL); + time_t now = time(nullptr); std::string s; if (showPoolSize) @@ -533,7 +533,7 @@ void GeneralsMatcher::checkMatchesInUserMap(UserMap& userMap, int ladderID, int s.append(intToString(userMap.size())); } - // iterate through users, timing them out as neccessary + // iterate through users, timing them out as necessary for (i1 = userMap.begin(); i1 != userMap.end(); ++i1) { if (showPoolSize) @@ -560,7 +560,7 @@ void GeneralsMatcher::checkMatchesInUserMap(UserMap& userMap, int ladderID, int if (u1->status != STATUS_WORKING) continue; - GeneralsUser *bestUser = NULL; + GeneralsUser *bestUser = nullptr; double bestMatchFitness = 0.0; std::string bestName = ""; @@ -619,7 +619,7 @@ void GeneralsMatcher::checkMatchesInUserMap(UserMap& userMap, int ladderID, int { // match 4 players sendMatchInfo(i1->first, i2->first, i3->first, i4->first, "", "", "", "", - u1, u2, u3, u4, NULL, NULL, NULL, NULL, 4, ladderID); + u1, u2, u3, u4, nullptr, nullptr, nullptr, nullptr, 4, ladderID); break; } else @@ -665,7 +665,7 @@ void GeneralsMatcher::checkMatchesInUserMap(UserMap& userMap, int ladderID, int { // match 6 players sendMatchInfo(i1->first, i2->first, i3->first, i4->first, i5->first, i6->first, "", "", - u1, u2, u3, u4, u5, u6, NULL, NULL, 6, ladderID); + u1, u2, u3, u4, u5, u6, nullptr, nullptr, 6, ladderID); break; } else @@ -749,7 +749,7 @@ void GeneralsMatcher::checkMatchesInUserMap(UserMap& userMap, int ladderID, int "\tping in ms: " << sqrt(1000000 * calcPingDelta(u1, bestUser) / (255*255*2)) << "\n" "\tprevious attempts: " << u1->widened << ", " << bestUser->widened); sendMatchInfo(i1->first, bestName, "", "", "", "", "", "", - u1, bestUser, NULL, NULL, NULL, NULL, NULL, NULL, 2, ladderID); + u1, bestUser, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, 2, ladderID); break; } } @@ -814,7 +814,7 @@ bool GeneralsMatcher::handleUserInfo(const char *nick, const std::string& msg) { int val = atoi(v.c_str()); if (val > 0) - userInfo->timeToWiden = time(NULL) + val; + userInfo->timeToWiden = time(nullptr) + val; else userInfo->timeToWiden = 0; } @@ -911,7 +911,7 @@ bool GeneralsMatcher::handleUserInfo(const char *nick, const std::string& msg) { buf2[0] = *buf++; buf2[1] = *buf++; - ping = (int)strtol(buf2, NULL, 16); + ping = (int)strtol(buf2, nullptr, 16); userInfo->pseudoPing.push_back(ping); } } @@ -959,7 +959,7 @@ bool GeneralsMatcher::handleUserInfo(const char *nick, const std::string& msg) } userInfo->status = STATUS_WORKING; - userInfo->matchStart = time(NULL); + userInfo->matchStart = time(nullptr); peerMessagePlayer(m_peer, nick, s.c_str(), NormalMessage); DBGMSG("Player " << nick << " is matching now, ack was [" << s << "]"); @@ -979,7 +979,7 @@ GeneralsUser* GeneralsMatcher::findUser(const std::string& who) if (user) return user; - return NULL; + return nullptr; } GeneralsUser* GeneralsMatcher::findUserInAnyLadder(const std::string& who) @@ -990,18 +990,18 @@ GeneralsUser* GeneralsMatcher::findUserInAnyLadder(const std::string& who) if (uIt != lIt->second.end()) return uIt->second; } - return NULL; + return nullptr; } GeneralsUser* GeneralsMatcher::findUserInLadder(const std::string& who, int ladderID) { LadderMap::iterator lIt = m_ladders.find(ladderID); if (lIt == m_ladders.end()) - return NULL; + return nullptr; UserMap::iterator uIt = lIt->second.find(who); if (uIt == lIt->second.end()) - return NULL; + return nullptr; return uIt->second; } @@ -1024,14 +1024,14 @@ GeneralsUser* GeneralsMatcher::findNonLadderUser(const std::string& who) if (it != m_nonLadderUsers4v4.end()) return it->second; - return NULL; + return nullptr; } GeneralsUser* GeneralsMatcher::findNonMatchingUser(const std::string& who) { UserMap::iterator it = m_nonMatchingUsers.find(who); if (it == m_nonMatchingUsers.end()) - return NULL; + return nullptr; return it->second; } @@ -1106,11 +1106,11 @@ GeneralsUser* GeneralsMatcher::removeUserInLadder(const std::string& who, int la { LadderMap::iterator lIt = m_ladders.find(ladderID); if (lIt == m_ladders.end()) - return NULL; + return nullptr; UserMap::iterator uIt = lIt->second.find(who); if (uIt == lIt->second.end()) - return NULL; + return nullptr; GeneralsUser *user = uIt->second; lIt->second.erase(uIt); @@ -1129,7 +1129,7 @@ GeneralsUser* GeneralsMatcher::removeUserInAnyLadder(const std::string& who) return user; } } - return NULL; + return nullptr; } GeneralsUser* GeneralsMatcher::removeNonLadderUser(const std::string& who) @@ -1166,14 +1166,14 @@ GeneralsUser* GeneralsMatcher::removeNonLadderUser(const std::string& who) return user; } - return NULL; + return nullptr; } GeneralsUser* GeneralsMatcher::removeNonMatchingUser(const std::string& who) { UserMap::iterator it = m_nonMatchingUsers.find(who); if (it == m_nonMatchingUsers.end()) - return NULL; + return nullptr; GeneralsUser *user = it->second; m_nonMatchingUsers.erase(it); @@ -1292,7 +1292,7 @@ GeneralsClientMatcher::GeneralsClientMatcher() void GeneralsClientMatcher::init(void) { - m_baseNick.setFormatted("qmBot%d", time(NULL)); + m_baseNick.setFormatted("qmBot%d", time(nullptr)); m_profileID = 0; } diff --git a/Core/Tools/matchbot/global.cpp b/Core/Tools/matchbot/global.cpp index 1abe63c1cf4..d6ea067d362 100644 --- a/Core/Tools/matchbot/global.cpp +++ b/Core/Tools/matchbot/global.cpp @@ -27,7 +27,7 @@ GlobalClass::GlobalClass(void) bool GlobalClass::ReadFile(const char *fname) { FILE *fp; - if ((fp = fopen(fname, "r")) == NULL) + if ((fp = fopen(fname, "r")) == nullptr) return false; config.readFile(fp); fclose(fp); diff --git a/Core/Tools/matchbot/main.cpp b/Core/Tools/matchbot/main.cpp index 8b0a78fb571..6365cab7ce8 100644 --- a/Core/Tools/matchbot/main.cpp +++ b/Core/Tools/matchbot/main.cpp @@ -56,8 +56,8 @@ static const char *Program_Usage = "A config filename can be given on the comman void logMonitor(void *); void paranoidLogMonitor(void *); -OutputDevice * output_device = NULL; -OutputDevice * paranoid_output_device = NULL; +OutputDevice * output_device = nullptr; +OutputDevice * paranoid_output_device = nullptr; void Signal_Quit(int) @@ -111,8 +111,8 @@ int VerifyFileDescriptors(int requested) -GeneralsMatcher *s_generalsMatcher = NULL; -GeneralsClientMatcher *s_generalsClientMatcher = NULL; +GeneralsMatcher *s_generalsMatcher = nullptr; +GeneralsClientMatcher *s_generalsClientMatcher = nullptr; int main(int argc, char ** argv) { @@ -124,7 +124,7 @@ int main(int argc, char ** argv) // Read the config file FILE *fp; - if ((fp = fopen(config_fname.get(), "r")) == NULL) + if ((fp = fopen(config_fname.get(), "r")) == nullptr) { cerr << "\nCan't open the config file '" << config_fname.get() << "'\n\n"; cerr << Program_Usage << endl; @@ -241,10 +241,10 @@ int main(int argc, char ** argv) } delete s_generalsMatcher; - s_generalsMatcher = NULL; + s_generalsMatcher = nullptr; delete s_generalsClientMatcher; - s_generalsClientMatcher = NULL; + s_generalsClientMatcher = nullptr; return 0; } @@ -269,7 +269,7 @@ void logMonitor(void *) return ; while (1) { - curtime = time(NULL); + curtime = time(nullptr); // get the number of seconds that have passed since midnight // of the current day. curtime -= TimezoneOffset(); @@ -345,7 +345,7 @@ void paranoidLogMonitor(void *) return ; while (1) { - curtime = time(NULL); + curtime = time(nullptr); // get the number of seconds that have passed since midnight // of the current day. curtime -= TimezoneOffset(); diff --git a/Core/Tools/matchbot/matcher.cpp b/Core/Tools/matchbot/matcher.cpp index 53f4c95a568..7549239d2e1 100644 --- a/Core/Tools/matchbot/matcher.cpp +++ b/Core/Tools/matchbot/matcher.cpp @@ -61,7 +61,7 @@ void MatcherClass::readLoop(void) do { static time_t lastLogTime = 0; - time_t now = time(NULL); + time_t now = time(nullptr); if (now > lastLogTime + 300) { lastLogTime = now; @@ -89,7 +89,7 @@ void MatcherClass::readLoop(void) #ifdef _UNIX Xtime xtime; time_t curtime; - curtime = time(NULL); + curtime = time(nullptr); // get the number of seconds that have passed since midnight // of the current day. curtime -= TimezoneOffset(); @@ -219,7 +219,7 @@ static void NickErrorCallback ( PEER peer, int type, const char * badNick, int n else { // Cancel the connect. - peerRetryWithNick(peer, NULL); + peerRetryWithNick(peer, nullptr); MatcherClass *matcher = (MatcherClass *)param; if (matcher) matcher->handleNickError( badNick ); @@ -228,7 +228,7 @@ static void NickErrorCallback ( PEER peer, int type, const char * badNick, int n else { // Cancel the connect. - peerRetryWithNick(peer, NULL); + peerRetryWithNick(peer, nullptr); MatcherClass *matcher = (MatcherClass *)param; if (matcher) matcher->handleNickError( badNick ); @@ -272,7 +272,7 @@ void MatcherClass::handleConnect( bool success ) m_connectSuccess = success; //DEBUG_LOG(("Enumerating chat channels")); - //chatEnumChannels( peerGetChat(m_peer), "", callbackEach, callbackAll, NULL, CHATTrue ); + //chatEnumChannels( peerGetChat(m_peer), "", callbackEach, callbackAll, nullptr, CHATTrue ); //DEBUG_LOG(("Done enumerating chat channels")); } @@ -312,7 +312,7 @@ static void AuthenticateCDKeyCallback void MatcherClass::connectAndLoop(void) { - // Game-specific initializations, if neccessary + // Game-specific initializations, if necessary init(); // Check for possible quit from init()-based self-tests @@ -396,7 +396,7 @@ void MatcherClass::connectAndLoop(void) } m_groupID = 0; - peerListGroupRooms(m_peer, NULL, ListGroupRoomsCallback, &m_groupID, PEERTrue); + peerListGroupRooms(m_peer, nullptr, ListGroupRoomsCallback, &m_groupID, PEERTrue); m_groupID = s_groupID; DBGMSG("QuickMatch room is " << m_groupID); diff --git a/Core/Tools/matchbot/mydebug.cpp b/Core/Tools/matchbot/mydebug.cpp index 3ad1e156e40..5ae6a702c12 100644 --- a/Core/Tools/matchbot/mydebug.cpp +++ b/Core/Tools/matchbot/mydebug.cpp @@ -22,10 +22,10 @@ #include "odevice.h" -// static MyMsgManager *msg_manager=NULL; +// static MyMsgManager *msg_manager=nullptr; // static int paranoid_enabled=0; -static ostream *paranoid_ostream=NULL; +static ostream *paranoid_ostream=nullptr; static Streamer paranoid_streamer; // Don't dare touch this semaphore in application code! @@ -38,7 +38,7 @@ CritSec MyDebugLibSemaphore; int MyMsgManager::setAllStreams(OutputDevice *device) { - if (device==NULL) + if (device==nullptr) return(1); MYDEBUGLOCK; @@ -54,7 +54,7 @@ int MyMsgManager::setAllStreams(OutputDevice *device) int MyMsgManager::setParanoidStream(OutputDevice *device) { - if (device==NULL) + if (device==nullptr) return(1); MYDEBUGLOCK; diff --git a/Core/Tools/matchbot/mydebug.h b/Core/Tools/matchbot/mydebug.h index 91227b3cfaa..698dd7a6db4 100644 --- a/Core/Tools/matchbot/mydebug.h +++ b/Core/Tools/matchbot/mydebug.h @@ -25,8 +25,8 @@ MT-LEVEL The debugging module is pretty good for debugging and it has some message printing stuff as well. The basic idea is that you write a class that inherits from OutputDevice (several are provided) and assign that output -device to a stream. There are seperate streams for debugging, information, -warning, and error messages. Each one can have a seperate output device, +device to a stream. There are separate streams for debugging, information, +warning, and error messages. Each one can have a separate output device, or they can all have the same one. Debugging messages only get compiled in if your module defines 'DEBUG'. If you don't define debug, then not even the text of the debugging message gets into the binary. All the other diff --git a/Core/Tools/matchbot/wlib/arraylist.h b/Core/Tools/matchbot/wlib/arraylist.h index 58c8481842b..5b1d4356730 100644 --- a/Core/Tools/matchbot/wlib/arraylist.h +++ b/Core/Tools/matchbot/wlib/arraylist.h @@ -131,7 +131,7 @@ ArrayList::ArrayList() { Entries_=0; Slots_=0; - Vector_=NULL; + Vector_=nullptr; } // copy constructor @@ -140,7 +140,7 @@ ArrayList::ArrayList(ArrayList &other) { Entries_=0; Slots_=0; - Vector_=NULL; + Vector_=nullptr; (*this)=other; } @@ -653,7 +653,7 @@ bit8 ArrayList::growVector(void) T *newVector=(T *)(new uint8[newSlots * sizeof(T)]); memset(newVector,0,newSlots * sizeof(T)); // zero just to be safe - if (Vector_ != NULL) + if (Vector_ != nullptr) memcpy(newVector,Vector_,Entries_*sizeof(T)); delete[]((uint8 *)Vector_); // Get rid of the old vector without calling @@ -692,7 +692,7 @@ bit8 ArrayList::shrinkVector(void) // T *newVector=(T *)(new uint8[newSlots * sizeof(T)]); - if (Vector_ != NULL) // Vector_ better not be NULL! + if (Vector_ != nullptr) // Vector_ better not be nullptr! memcpy(newVector,Vector_,Entries_*sizeof(T)); delete[]((uint8 *)Vector_); // Get rid of the old vector without calling diff --git a/Core/Tools/matchbot/wlib/configfile.cpp b/Core/Tools/matchbot/wlib/configfile.cpp index b8d465b750a..ec38b358598 100644 --- a/Core/Tools/matchbot/wlib/configfile.cpp +++ b/Core/Tools/matchbot/wlib/configfile.cpp @@ -97,7 +97,7 @@ bit8 ConfigFile::readFile(FILE *in) continue; } - if (strchr(cptr,'=')==NULL) // All config entries must have a '=' + if (strchr(cptr,'=')==nullptr) // All config entries must have a '=' continue; key=cptr; key.truncate('='); @@ -152,7 +152,7 @@ bit8 ConfigFile::enumerate(int &index, int &offset, Wstring &key, Wstring &value } Critsec_.unlock(); - if (section==NULL) // no specified section, so any will do... + if (section==nullptr) // no specified section, so any will do... break; if (strlen(section)+2 >= strlen(key.get())) // key should have form: X[section] diff --git a/Core/Tools/matchbot/wlib/configfile.h b/Core/Tools/matchbot/wlib/configfile.h index eba5a02c811..cf793ca1e34 100644 --- a/Core/Tools/matchbot/wlib/configfile.h +++ b/Core/Tools/matchbot/wlib/configfile.h @@ -40,25 +40,25 @@ class ConfigFile ConfigFile(); ~ConfigFile(); bit8 readFile(FILE *config); - bit8 getString(IN Wstring &key,OUT Wstring &value, IN char *section=NULL) const; - bit8 getString(IN char *key,OUT Wstring &value, IN char *section=NULL) const; + bit8 getString(IN Wstring &key,OUT Wstring &value, IN char *section=nullptr) const; + bit8 getString(IN char *key,OUT Wstring &value, IN char *section=nullptr) const; - bit8 getInt(IN Wstring &key,OUT sint32 &value, IN char *section=NULL) const; - bit8 getInt(IN char *key,OUT sint32 &value, IN char *section=NULL) const; + bit8 getInt(IN Wstring &key,OUT sint32 &value, IN char *section=nullptr) const; + bit8 getInt(IN char *key,OUT sint32 &value, IN char *section=nullptr) const; - bit8 getInt(IN Wstring &key,OUT sint16 &value, IN char *section=NULL) const; - bit8 getInt(IN char *key,OUT sint16 &value, IN char *section=NULL) const; + bit8 getInt(IN Wstring &key,OUT sint16 &value, IN char *section=nullptr) const; + bit8 getInt(IN char *key,OUT sint16 &value, IN char *section=nullptr) const; // Enumerate through the config lines - bit8 enumerate(int &index, int &offset, Wstring &key, Wstring &value, IN char *section=NULL) const; + bit8 enumerate(int &index, int &offset, Wstring &key, Wstring &value, IN char *section=nullptr) const; // Manual update of config file - bit8 setString(IN Wstring &key,IN Wstring &value, IN char *section=NULL); - bit8 setString(IN char *key,IN Wstring &value, IN char *section=NULL); - bit8 setInt(IN Wstring &key,IN sint32 &value, IN char *section=NULL); - bit8 setInt(IN char *key,IN sint32 &value, IN char *section=NULL); - bit8 removeEntry(IN Wstring &key, IN char *section=NULL); - bit8 removeEntry(IN char *key, IN char *section=NULL); + bit8 setString(IN Wstring &key,IN Wstring &value, IN char *section=nullptr); + bit8 setString(IN char *key,IN Wstring &value, IN char *section=nullptr); + bit8 setInt(IN Wstring &key,IN sint32 &value, IN char *section=nullptr); + bit8 setInt(IN char *key,IN sint32 &value, IN char *section=nullptr); + bit8 removeEntry(IN Wstring &key, IN char *section=nullptr); + bit8 removeEntry(IN char *key, IN char *section=nullptr); bit8 writeFile(FILE *config); // Does not preserve comments, etc ArrayList sectionList; // stores the names of all sections diff --git a/Core/Tools/matchbot/wlib/critsec.cpp b/Core/Tools/matchbot/wlib/critsec.cpp index d02aae76c9b..f0df292f172 100644 --- a/Core/Tools/matchbot/wlib/critsec.cpp +++ b/Core/Tools/matchbot/wlib/critsec.cpp @@ -25,7 +25,7 @@ CritSec::CritSec() { #ifdef _UNIX - pthread_mutex_init(&Mutex_, NULL); + pthread_mutex_init(&Mutex_, nullptr); RefCount_ = 0; #elif defined(_WIN32) InitializeCriticalSection(&CritSec_); diff --git a/Core/Tools/matchbot/wlib/critsec.h b/Core/Tools/matchbot/wlib/critsec.h index 687667d74d8..07d21bee973 100644 --- a/Core/Tools/matchbot/wlib/critsec.h +++ b/Core/Tools/matchbot/wlib/critsec.h @@ -45,7 +45,7 @@ class CritSec CritSec(); ~CritSec(); - sint32 lock(int *refcount=NULL) RO; + sint32 lock(int *refcount=nullptr) RO; sint32 unlock(void) RO; protected: diff --git a/Core/Tools/matchbot/wlib/dictionary.h b/Core/Tools/matchbot/wlib/dictionary.h index 2a21b5273b3..fde42c3c4a7 100644 --- a/Core/Tools/matchbot/wlib/dictionary.h +++ b/Core/Tools/matchbot/wlib/dictionary.h @@ -83,7 +83,7 @@ Dictionary(uint32 (*hashFn)(const K &key)) : //Table is a pointer to a list of pointers (the hash table) table=(DNode **)new DNode* [size]; - assert(table!=NULL); + assert(table!=nullptr); memset((void *)table,0,size*sizeof(void *)); hashFunc=hashFn; @@ -151,13 +151,13 @@ void Dictionary::clear() for (i=0; ihashNext; delete(del); } - table[i]=NULL; + table[i]=nullptr; } entries=0; @@ -189,7 +189,7 @@ void Dictionary::print(FILE *out) RO fprintf(out," |\n"); fprintf(out,"[ ]"); - while (temp!=NULL) + while (temp!=nullptr) { fprintf(out,"--[ ]"); temp=temp->hashNext; @@ -223,27 +223,27 @@ bit8 Dictionary::iterate(INOUT int &index,INOUT int &offset, return(FALSE); temp=table[index]; - while ((temp==NULL)&&((++index) < (int)getSize())) + while ((temp==nullptr)&&((++index) < (int)getSize())) { temp=table[index]; offset=0; } - if (temp==NULL) // no more slots with data + if (temp==nullptr) // no more slots with data return(FALSE); uint32 i=0; - while ((temp!=NULL) && ((int)i < offset)) + while ((temp!=nullptr) && ((int)i < offset)) { temp=temp->hashNext; i++; } - if (temp==NULL) // should never happen + if (temp==nullptr) // should never happen return(FALSE); value=temp->value; - if (temp->hashNext==NULL) + if (temp->hashNext==nullptr) { index++; offset=0; @@ -272,28 +272,28 @@ bit8 Dictionary::iterate(INOUT int &index,INOUT int &offset, return(FALSE); temp=table[index]; - while ((temp==NULL)&&((++index) < (int)getSize())) + while ((temp==nullptr)&&((++index) < (int)getSize())) { temp=table[index]; offset=0; } - if (temp==NULL) // no more slots with data + if (temp==nullptr) // no more slots with data return(FALSE); uint32 i=0; - while ((temp!=NULL) && ((int)i < offset)) + while ((temp!=nullptr) && ((int)i < offset)) { temp=temp->hashNext; i++; } - if (temp==NULL) // should never happen + if (temp==nullptr) // should never happen return(FALSE); value=temp->value; key=temp->key; - if (temp->hashNext==NULL) + if (temp->hashNext==nullptr) { index++; offset=0; @@ -330,10 +330,10 @@ bit8 Dictionary::contains(IN K &key) RO node=table[offset]; - if (node==NULL) + if (node==nullptr) { return(FALSE); } // can't find it - while(node!=NULL) + while(node!=nullptr) { if ((node->key)==key) { return(TRUE); } @@ -367,7 +367,7 @@ bit8 Dictionary::add(IN K &key,IN V &value) float percent; item=(DNode *)new DNode; - assert(item!=NULL); + assert(item!=nullptr); #ifdef KEY_MEM_OPS memcpy(&(item->key),&key,sizeof(K)); @@ -381,7 +381,7 @@ bit8 Dictionary::add(IN K &key,IN V &value) item->value=value; #endif - item->hashNext=NULL; + item->hashNext=nullptr; //If key already exists, it will be overwritten remove(key); // Hopefully this will be false... @@ -390,7 +390,7 @@ bit8 Dictionary::add(IN K &key,IN V &value) node=table[offset]; - if (node==NULL) + if (node==nullptr) { table[offset]=item; } else { @@ -425,7 +425,7 @@ bit8 Dictionary::remove(IN K &key,OUT V &value) node=table[offset]; last=node; - if (node==NULL) + if (node==nullptr) return(FALSE); //special case table points to thing to delete @@ -454,7 +454,7 @@ bit8 Dictionary::remove(IN K &key,OUT V &value) bit8 retval=FALSE; // wow, didn't add this for years... (DOH!) //Now the case if the thing to delete is not the first - while (node!=NULL) + while (node!=nullptr) { #ifdef KEY_MEM_OPS if (0==memcmp(&(node->key),&key,sizeof(K))) @@ -508,7 +508,7 @@ bit8 Dictionary::removeAny(OUT K &key,OUT V &value) int i; offset=-1; for (i=0; i<(int)getSize(); i++) - if (table[i]!=NULL) + if (table[i]!=nullptr) { offset=i; break; @@ -544,7 +544,7 @@ bit8 Dictionary::removeAny(OUT K &key,OUT V &value) template bool Dictionary::getValue(IN K &key,OUT V &value) RO { - V *valptr=NULL; + V *valptr=nullptr; bool retval=getPointer(key,&valptr); if (retval && valptr) { @@ -572,17 +572,17 @@ bool Dictionary::getPointer(IN K &key,OUT V **valptr) RO node=table[offset]; - if (node==NULL) + if (node==nullptr) return(FALSE); #ifdef KEY_MEM_OPS - while ((node!=NULL)&&(memcmp(&(node->key),&key,sizeof(K)))) + while ((node!=nullptr)&&(memcmp(&(node->key),&key,sizeof(K)))) #else - while ((node!=NULL)&&( ! ((node->key)==key)) ) // odd syntax so you don't + while ((node!=nullptr)&&( ! ((node->key)==key)) ) // odd syntax so you don't #endif // have to do oper != { node=node->hashNext; } - if (node==NULL) + if (node==nullptr) { return(FALSE); } *valptr=&(node->value); @@ -615,13 +615,13 @@ void Dictionary::shrink(void) tableBits--; table=(DNode **)new DNode*[size]; - assert(table!=NULL); + assert(table!=nullptr); memset((void *)table,0,size*sizeof(void *)); for (i=0; ikey); first=table[offset]; @@ -654,13 +654,13 @@ void Dictionary::expand(void) tableBits++; table=(DNode **)new DNode* [size]; - assert(table!=NULL); + assert(table!=nullptr); memset((void *)table,0,size*sizeof(void *)); for (i=0; ikey); first=table[offset]; diff --git a/Core/Tools/matchbot/wlib/filed.h b/Core/Tools/matchbot/wlib/filed.h index 2d00ab1afa3..4d2a6fa29cd 100644 --- a/Core/Tools/matchbot/wlib/filed.h +++ b/Core/Tools/matchbot/wlib/filed.h @@ -26,7 +26,7 @@ class FileD : public OutputDevice FileD(IN char *filename, IN char *mode = "w") { out=fopen(filename,mode); - if (out==NULL) + if (out==nullptr) out=fopen("FileDev.out",mode); } diff --git a/Core/Tools/matchbot/wlib/linkedlist.h b/Core/Tools/matchbot/wlib/linkedlist.h index 8589c3c45c3..a0cc1908348 100644 --- a/Core/Tools/matchbot/wlib/linkedlist.h +++ b/Core/Tools/matchbot/wlib/linkedlist.h @@ -63,9 +63,9 @@ class LinkedList void clear(void); // Add a node after the zero based 'pos' - bit8 add(IN T &node,sint32 pos, OUT T **newnodeptr=NULL); - bit8 addTail(IN T &node, OUT T **newnodeptr=NULL); - bit8 addHead(IN T &node, OUT T **newnodeptr=NULL); + bit8 add(IN T &node,sint32 pos, OUT T **newnodeptr=nullptr); + bit8 addTail(IN T &node, OUT T **newnodeptr=nullptr); + bit8 addHead(IN T &node, OUT T **newnodeptr=nullptr); // Remove a node bit8 remove(OUT T &node,sint32 pos); @@ -106,7 +106,7 @@ template LinkedList::LinkedList() { Entries=0; - Head=Tail=Current=NULL; + Head=Tail=Current=nullptr; CurIndex=-1; // Not valid when 0 entries } @@ -115,7 +115,7 @@ template LinkedList::LinkedList(LinkedList &other) { Entries=0; - Head=Tail=Current=NULL; + Head=Tail=Current=nullptr; CurIndex=-1; // Not valid when 0 entries (*this)=other; } @@ -156,7 +156,7 @@ void LinkedList::clear() } Entries=0; CurIndex=-1; - Head=Tail=Current=NULL; + Head=Tail=Current=nullptr; } // When adding into a position, the new node goes at the zero based slot @@ -173,10 +173,10 @@ bit8 LinkedList::add(IN T &node,sint32 pos, OUT T **newnodeptr) pos=Entries; item=(LNode *)new LNode; - assert(item!=NULL); + assert(item!=nullptr); item->Node=node; // copy the passed in object - item->Prev=NULL; - item->Next=NULL; + item->Prev=nullptr; + item->Next=nullptr; if (newnodeptr) *newnodeptr=&(item->Node); @@ -228,7 +228,7 @@ bit8 LinkedList::add(IN T &node,sint32 pos, OUT T **newnodeptr) temp=Head->Next; // Can start at node '1' because head was special cased for (int i=1; iNext; - assert(temp!=NULL); + assert(temp!=nullptr); } item->Next=temp; item->Prev=temp->Prev; @@ -278,7 +278,7 @@ bit8 LinkedList::remove(OUT T &node, sint32 pos) if (pos==0) { item=Head; if (item->Next) - item->Next->Prev=NULL; + item->Next->Prev=nullptr; Head=item->Next; node=item->Node; Current=Head; @@ -287,7 +287,7 @@ bit8 LinkedList::remove(OUT T &node, sint32 pos) if (pos==Entries-1) { item=Tail; if (item->Prev) - item->Prev->Next=NULL; + item->Prev->Next=nullptr; Tail=item->Prev; node=item->Node; Current=Tail; @@ -297,10 +297,10 @@ bit8 LinkedList::remove(OUT T &node, sint32 pos) Entries--; if (Entries==0) { // Super paranoia check - assert(Current==NULL); + assert(Current==nullptr); assert(CurIndex==-1); - assert(Head==NULL); - assert(Tail==NULL); + assert(Head==nullptr); + assert(Tail==nullptr); } return(TRUE); } @@ -337,7 +337,7 @@ bit8 LinkedList::remove(OUT T &node, sint32 pos) item=Head->Next; // Can start at node '1' because head was special cased for (int i=1; iNext; - assert(item!=NULL); + assert(item!=nullptr); } item->Prev->Next=item->Next; @@ -441,7 +441,7 @@ bit8 LinkedList::getPointer(OUT T **node,sint32 pos) item=Head->Next; // Can start at node '1' because head was special cased for (int i=1; iNext; - assert(item!=NULL); + assert(item!=nullptr); } *node=&(item->Node); CurIndex=pos; diff --git a/Core/Tools/matchbot/wlib/mboxd.h b/Core/Tools/matchbot/wlib/mboxd.h index a45eff3700a..4f61e9ae7ca 100644 --- a/Core/Tools/matchbot/wlib/mboxd.h +++ b/Core/Tools/matchbot/wlib/mboxd.h @@ -29,7 +29,7 @@ class MboxD : public OutputDevice char *string=new char[len+1]; memset(string,0,len+1); memcpy(string,str,len); - MessageBox(NULL,string,"Debug Message", MB_OK | MB_ICONINFORMATION); + MessageBox(nullptr,string,"Debug Message", MB_OK | MB_ICONINFORMATION); delete[](string); return(len); } diff --git a/Core/Tools/matchbot/wlib/monod.cpp b/Core/Tools/matchbot/wlib/monod.cpp index 103409de5c2..ffda85ac28c 100644 --- a/Core/Tools/matchbot/wlib/monod.cpp +++ b/Core/Tools/matchbot/wlib/monod.cpp @@ -22,12 +22,12 @@ MonoD::MonoD(void) { #ifdef _WIN32 unsigned long retval; - handle = CreateFile("\\\\.\\MONO", GENERIC_READ|GENERIC_WRITE, 0, NULL, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + handle = CreateFile("\\\\.\\MONO", GENERIC_READ|GENERIC_WRITE, 0, nullptr, + OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (handle != INVALID_HANDLE_VALUE) { - DeviceIoControl(handle, (DWORD)IOCTL_MONO_CLEAR_SCREEN, NULL, 0, NULL, 0, + DeviceIoControl(handle, (DWORD)IOCTL_MONO_CLEAR_SCREEN, nullptr, 0, nullptr, 0, &retval,0); } #endif @@ -37,7 +37,7 @@ MonoD::~MonoD() { #ifdef _WIN32 CloseHandle(handle); - handle=NULL; + handle = nullptr; #endif } @@ -45,8 +45,8 @@ int MonoD::print(const char *str, int len) { #ifdef _WIN32 unsigned long retval; - WriteFile(handle, str, len, &retval, NULL); - ////DeviceIoControl(handle, (DWORD)IOCTL_MONO_PRINT_RAW, (void *)str, len, NULL, 0, + WriteFile(handle, str, len, &retval, nullptr); + ////DeviceIoControl(handle, (DWORD)IOCTL_MONO_PRINT_RAW, (void *)str, len, nullptr, 0, //// &retval,0); return(len); #else diff --git a/Core/Tools/matchbot/wlib/sem4.cpp b/Core/Tools/matchbot/wlib/sem4.cpp index e11b95a362f..12ccb5c6480 100644 --- a/Core/Tools/matchbot/wlib/sem4.cpp +++ b/Core/Tools/matchbot/wlib/sem4.cpp @@ -34,7 +34,7 @@ Sem4::Sem4() #ifndef _WIN32 sem_init(&sem,1,1); #else - sem = CreateSemaphore(NULL, 1, 1, NULL); + sem = CreateSemaphore(nullptr, 1, 1, nullptr); #endif } @@ -43,7 +43,7 @@ Sem4::Sem4(uint32 value) #ifndef _WIN32 sem_init(&sem,1,value); #else - sem = CreateSemaphore(NULL, value, value, NULL); + sem = CreateSemaphore(nullptr, value, value, nullptr); #endif } @@ -84,7 +84,7 @@ sint32 Sem4::Post(void) const #else if (!sem) return -1; - if (!ReleaseSemaphore(sem, 1 ,NULL)) + if (!ReleaseSemaphore(sem, 1 ,nullptr)) return -1; return 0; #endif diff --git a/Core/Tools/matchbot/wlib/streamer.cpp b/Core/Tools/matchbot/wlib/streamer.cpp index 061baad77db..f81be59597f 100644 --- a/Core/Tools/matchbot/wlib/streamer.cpp +++ b/Core/Tools/matchbot/wlib/streamer.cpp @@ -28,7 +28,7 @@ #define STREAMER_UNBUFFERED 0 #endif -Streamer::Streamer() : streambuf(), Output_Device(NULL), Buf(NULL) +Streamer::Streamer() : streambuf(), Output_Device(nullptr), Buf(nullptr) { #if defined(USING_STLPORT) || (defined(_MSC_VER) && _MSC_VER < 1300) int state=unbuffered(); @@ -101,7 +101,7 @@ int Streamer::underflow(void) int Streamer::doallocate() { - if (Buf==NULL) + if (Buf==nullptr) { Buf=new char[(2*STREAMER_BUFSIZ)]; // deleted by destructor memset(Buf,0,2*STREAMER_BUFSIZ); diff --git a/Core/Tools/matchbot/wlib/threadfac.cpp b/Core/Tools/matchbot/wlib/threadfac.cpp index e9934e71b6d..3973335f8fb 100644 --- a/Core/Tools/matchbot/wlib/threadfac.cpp +++ b/Core/Tools/matchbot/wlib/threadfac.cpp @@ -52,7 +52,7 @@ struct ThreadInformation // // Start a thread inside a class // -bit8 ThreadFactory::startThread(Runnable &runable, void *data, bit8 destroy) +bit8 ThreadFactory::startThread(Runnable &runnable, void *data, bit8 destroy) { #ifdef _REENTRANT @@ -64,7 +64,7 @@ bit8 ThreadFactory::startThread(Runnable &runable, void *data, bit8 destroy) ThreadInformation *tInfo=new ThreadInformation; - tInfo->startPoint=(void *)&runable; + tInfo->startPoint=(void *)&runnable; tInfo->data=data; tInfo->destroy=destroy; @@ -73,15 +73,15 @@ bit8 ThreadFactory::startThread(Runnable &runable, void *data, bit8 destroy) // use all the normal C library stuff. (IMPORTANT!!!) uint32 handle; uint32 stup1d; - handle=_beginthreadex(NULL,0, threadClassLauncher, tInfo, 0, &stup1d); - if (handle!=NULL) + handle=_beginthreadex(nullptr,0, threadClassLauncher, tInfo, 0, &stup1d); + if (handle!=nullptr) return(TRUE); else { { - runable.CritSec_.lock(); - runable.ThreadCount_--; // Ok, so it didn't really start - runable.CritSec_.unlock(); + runnable.CritSec_.lock(); + runnable.ThreadCount_--; // Ok, so it didn't really start + runnable.CritSec_.unlock(); } return(FALSE); } @@ -92,15 +92,15 @@ bit8 ThreadFactory::startThread(Runnable &runable, void *data, bit8 destroy) pthread_attr_init(&threadAttr); pthread_attr_setdetachstate(&threadAttr, PTHREAD_CREATE_DETACHED); pthread_attr_setscope(&threadAttr,PTHREAD_SCOPE_SYSTEM); - retval=pthread_create(NULL,&threadAttr, threadClassLauncher, tInfo); + retval=pthread_create(nullptr,&threadAttr, threadClassLauncher, tInfo); if (retval==0) return(TRUE); else { { - runable.CritSec_.lock(); - runable.ThreadCount_--; // Ok, so it didn't really start - runable.CritSec_.unlock(); + runnable.CritSec_.lock(); + runnable.ThreadCount_--; // Ok, so it didn't really start + runnable.CritSec_.unlock(); } return(FALSE); } @@ -126,8 +126,8 @@ bit8 ThreadFactory::startThread(void (*start_func)(void *), void *data) // use all the normal C library stuff. (IMPORTANT!!!) uint32 handle; unsigned temp; - handle=_beginthreadex(NULL,0, threadFuncLauncher, tInfo, 0, &temp); - if (handle!=NULL) + handle=_beginthreadex(nullptr,0, threadFuncLauncher, tInfo, 0, &temp); + if (handle!=nullptr) return(TRUE); return(FALSE); #else // UNIX @@ -137,7 +137,7 @@ bit8 ThreadFactory::startThread(void (*start_func)(void *), void *data) pthread_attr_init(&threadAttr); pthread_attr_setdetachstate(&threadAttr, PTHREAD_CREATE_DETACHED); pthread_attr_setscope(&threadAttr,PTHREAD_SCOPE_SYSTEM); - retval=pthread_create(NULL,&threadAttr, threadFuncLauncher, tInfo); + retval=pthread_create(nullptr,&threadAttr, threadFuncLauncher, tInfo); if (retval==0) return(TRUE); else diff --git a/Core/Tools/matchbot/wlib/threadfac.h b/Core/Tools/matchbot/wlib/threadfac.h index 027de9be53b..68d8fe0bd71 100644 --- a/Core/Tools/matchbot/wlib/threadfac.h +++ b/Core/Tools/matchbot/wlib/threadfac.h @@ -74,7 +74,7 @@ class ThreadFactory { public: static bit8 startThread(void (*start_func)(void *), void *data); - static bit8 startThread(Runnable &runable, void *data, bit8 destroy=FALSE); + static bit8 startThread(Runnable &runnable, void *data, bit8 destroy=FALSE); }; diff --git a/Core/Tools/matchbot/wlib/wdebug.cpp b/Core/Tools/matchbot/wlib/wdebug.cpp index 8dd5005ecbc..f61cc34aadd 100644 --- a/Core/Tools/matchbot/wlib/wdebug.cpp +++ b/Core/Tools/matchbot/wlib/wdebug.cpp @@ -22,22 +22,22 @@ #include "odevice.h" -static MsgManager *msg_manager=NULL; +static MsgManager *msg_manager=nullptr; static int debug_enabled=0; -static ostream *debug_ostream=NULL; +static ostream *debug_ostream=nullptr; static Streamer debug_streamer; static int info_enabled=0; -static ostream *info_ostream=NULL; +static ostream *info_ostream=nullptr; static Streamer info_streamer; static int warn_enabled=0; -static ostream *warn_ostream=NULL; +static ostream *warn_ostream=nullptr; static Streamer warn_streamer; static int error_enabled=0; -static ostream *error_ostream=NULL; +static ostream *error_ostream=nullptr; static Streamer error_streamer; @@ -51,7 +51,7 @@ CritSec DebugLibSemaphore; int MsgManager::setAllStreams(OutputDevice *device) { - if (device==NULL) + if (device==nullptr) return(1); DEBUGLOCK; @@ -112,7 +112,7 @@ int MsgManager::ReplaceAllStreams(FileD * output_device, IN char *device_filenam int MsgManager::setDebugStream(OutputDevice *device) { - if (device==NULL) + if (device==nullptr) return(1); DEBUGLOCK; @@ -125,7 +125,7 @@ int MsgManager::setDebugStream(OutputDevice *device) int MsgManager::setInfoStream(OutputDevice *device) { - if (device==NULL) + if (device==nullptr) return(1); DEBUGLOCK; @@ -138,7 +138,7 @@ int MsgManager::setInfoStream(OutputDevice *device) int MsgManager::setWarnStream(OutputDevice *device) { - if (device==NULL) + if (device==nullptr) return(1); DEBUGLOCK; @@ -151,7 +151,7 @@ int MsgManager::setWarnStream(OutputDevice *device) int MsgManager::setErrorStream(OutputDevice *device) { - if (device==NULL) + if (device==nullptr) return(1); DEBUGLOCK; diff --git a/Core/Tools/matchbot/wlib/wdebug.h b/Core/Tools/matchbot/wlib/wdebug.h index 4b5a8568d12..142a881fb29 100644 --- a/Core/Tools/matchbot/wlib/wdebug.h +++ b/Core/Tools/matchbot/wlib/wdebug.h @@ -25,8 +25,8 @@ MT-LEVEL The debugging module is pretty good for debugging and it has some message printing stuff as well. The basic idea is that you write a class that inherits from OutputDevice (several are provided) and assign that output -device to a stream. There are seperate streams for debugging, information, -warning, and error messages. Each one can have a seperate output device, +device to a stream. There are separate streams for debugging, information, +warning, and error messages. Each one can have a separate output device, or they can all have the same one. Debugging messages only get compiled in if your module defines 'DEBUG'. If you don't define debug, then not even the text of the debugging message gets into the binary. All the other diff --git a/Core/Tools/matchbot/wlib/wstring.cpp b/Core/Tools/matchbot/wlib/wstring.cpp index a19c9aaa002..5f5d558c1cb 100644 --- a/Core/Tools/matchbot/wlib/wstring.cpp +++ b/Core/Tools/matchbot/wlib/wstring.cpp @@ -39,15 +39,15 @@ string to it's own memory (for assignment or construction). #define PADSIZE 32 // include a little padding on alloc for future growth -Wstring::Wstring() : str(NULL), strsize(0) +Wstring::Wstring() : str(nullptr), strsize(0) { } -Wstring::Wstring(const char *string):str(NULL), strsize(0) +Wstring::Wstring(const char *string):str(nullptr), strsize(0) { set(string); } -Wstring::Wstring(const Wstring &other):str(NULL), strsize(0) +Wstring::Wstring(const Wstring &other):str(nullptr), strsize(0) { - if (other.str!=NULL) + if (other.str!=nullptr) { str=new char[strlen(other.str)+PADSIZE+1]; strsize=strlen(other.str)+PADSIZE+1; @@ -62,10 +62,10 @@ Wstring::~Wstring() bool Wstring::operator<(const Wstring &other) const { - if (str == NULL && other.str == NULL) + if (str == nullptr && other.str == nullptr) return false; - if (str == NULL) + if (str == nullptr) return true; return ( strcmp(str, other.str) < 0 ); @@ -73,7 +73,7 @@ bool Wstring::operator<(const Wstring &other) const bit8 Wstring::operator==(const char *other) const { - if ((str==NULL)&&(other==NULL)) + if ((str==nullptr)&&(other==nullptr)) return(TRUE); if(strcmp(str, other) != 0) return(FALSE); @@ -83,10 +83,10 @@ bit8 Wstring::operator==(const char *other) const bit8 Wstring::operator==(const Wstring &other) const { - if((str == NULL) && (other.str == NULL)) + if((str == nullptr) && (other.str == nullptr)) return(TRUE); - if((str == NULL) || (other.str == NULL)) + if((str == nullptr) || (other.str == nullptr)) return(FALSE); if(strcmp(str, other.str) != 0) @@ -107,10 +107,10 @@ bit8 Wstring::operator!=(const char *other) const bit8 Wstring::operator!=(const Wstring &other) const { - if((str == NULL) && (other.str == NULL)) + if((str == nullptr) && (other.str == nullptr)) return(FALSE); - if((str == NULL) || (other.str == NULL)) + if((str == nullptr) || (other.str == nullptr)) return(TRUE); if(strcmp(str, other.str) != 0) @@ -141,7 +141,7 @@ bit8 Wstring::cat(const char *s) { uint32 len; - if (s==NULL) // it's OK to cat nothing + if (s==nullptr) // it's OK to cat nothing return(TRUE); // Determine the length of the resultant string. @@ -240,14 +240,14 @@ char Wstring::remove(sint32 pos,sint32 count) bit8 Wstring::removeChar(char c) { int len=0; - char *cptr=NULL; + char *cptr=nullptr; bit8 removed=FALSE; - if (str==NULL) + if (str==nullptr) return(FALSE); len=strlen(str); - while ((cptr=strchr(str,c)) !=NULL) + while ((cptr=strchr(str,c)) !=nullptr) { memmove(cptr,cptr+1,len-1-((int)(cptr-str))); len--; @@ -267,7 +267,7 @@ void Wstring::clear(void) { delete[](str); strsize=0; - str=NULL; + str=nullptr; } // This is usually used for raw storage instead of string ops... @@ -308,7 +308,7 @@ char Wstring::get(uint32 index) const uint32 Wstring::length(void) const { - if(str == NULL) + if(str == nullptr) return(0); return((uint32)strlen(str)); } @@ -317,7 +317,7 @@ uint32 Wstring::length(void) const // Insert at given position and shift old stuff to right bit8 Wstring::insert(const char *instring, uint32 pos) { - if (str==NULL) + if (str==nullptr) return(set(instring)); if (pos>strlen(str)) pos=strlen(str); @@ -397,7 +397,7 @@ bit8 Wstring::replace(const char *replaceThis,const char *withThis) if(!dest.cat(src)) return(FALSE); - src=NULL; + src=nullptr; } } return(set(dest.get())); @@ -445,7 +445,7 @@ char Wstring::set(uint32 size, const char *string) // work in all cases, but this should be good enough for 99% of Wstring usage. char Wstring::setFormatted(const char *msg, ...) { - if( msg == NULL || strlen(msg) <= 0 ) return FALSE; + if( msg == nullptr || strlen(msg) <= 0 ) return FALSE; char* string; va_list args; @@ -506,18 +506,18 @@ bit8 Wstring::truncate(char c) { sint32 len; - if (str==NULL) + if (str==nullptr) return(FALSE); char *cptr=strchr(str,c); - if (cptr==NULL) + if (cptr==nullptr) return(FALSE); len=(sint32)(cptr-str); truncate((uint32)len); return(TRUE); } -// Get a token from this string that's seperated by one or more +// Get a token from this string that's separated by one or more // chars from the 'delim' string , start at offset & return offset sint32 Wstring::getToken(int offset,const char *delim,Wstring &out) const { @@ -529,7 +529,7 @@ sint32 Wstring::getToken(int offset,const char *delim,Wstring &out) const return(-1); for (i=offset; i<(int)length(); i++) { - if(strchr(delim,str[i])==NULL) + if(strchr(delim,str[i])==nullptr) break; } if (i>=(int)length()) @@ -537,7 +537,7 @@ sint32 Wstring::getToken(int offset,const char *delim,Wstring &out) const start=i; for (; i<(int)length(); i++) { - if(strchr(delim,str[i])!=NULL) + if(strchr(delim,str[i])!=nullptr) break; } stop=i-1; @@ -558,7 +558,7 @@ sint32 Wstring::getLine(int offset, Wstring &out) return(-1); for (; i<(int)length(); i++) { - if(strchr("\r\n",str[i])!=NULL) + if(strchr("\r\n",str[i])!=nullptr) break; } stop=i; @@ -575,7 +575,7 @@ sint32 Wstring::getLine(int offset, Wstring &out) // void Wstring::strgrow(int length) { - if (str==NULL) + if (str==nullptr) { str=new char[length+PADSIZE]; str[0]=0; diff --git a/Core/Tools/matchbot/wlib/wstypes.h b/Core/Tools/matchbot/wlib/wstypes.h index c13ef1fa3c8..f46fd77ab86 100644 --- a/Core/Tools/matchbot/wlib/wstypes.h +++ b/Core/Tools/matchbot/wlib/wstypes.h @@ -72,10 +72,6 @@ Standard type definitions for the sake of portability and readability. #define MAX(x,y) (((x)>(y))?(x):(y)) #endif -#ifndef NULL -#define NULL 0 -#endif - //These are used for readability purposes mostly, when a method takes a // pointer or reference these help specify what will happen to the data // that is sent in. diff --git a/Core/Tools/matchbot/wlib/xtime.cpp b/Core/Tools/matchbot/wlib/xtime.cpp index d36a7ec1875..95f6533d144 100644 --- a/Core/Tools/matchbot/wlib/xtime.cpp +++ b/Core/Tools/matchbot/wlib/xtime.cpp @@ -205,7 +205,7 @@ int main(int argc, char *argv[]) unixtime.tv_usec=0; //gettimeofday(&unixtime,&unixtzone); - //ttime=time(NULL); + //ttime=time(nullptr); tmtime=*gmtime(&ttime); printf("TIME->CTIME = %s\n",ctime(&ttime)); diff --git a/Core/Tools/matchbot/wnet/field.cpp b/Core/Tools/matchbot/wnet/field.cpp index 699b52507cd..a8f405bd145 100644 --- a/Core/Tools/matchbot/wnet/field.cpp +++ b/Core/Tools/matchbot/wnet/field.cpp @@ -51,56 +51,56 @@ void FieldClass::Clear(void) strcpy(ID,""); DataType=0; Size=0; - Data=NULL; - Next=NULL; + Data=nullptr; + Next=nullptr; } FieldClass::FieldClass(char *id, char data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, unsigned char data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, short data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, unsigned short data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, long data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, unsigned long data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, char *data) { - Data=NULL; + Data=nullptr; Set(id,data); } FieldClass::FieldClass(char *id, void *data, int length) { - Data=NULL; + Data=nullptr; Set(id,data,length); } diff --git a/Core/Tools/matchbot/wnet/field.h b/Core/Tools/matchbot/wnet/field.h index de573ddbeec..da3e5d00d39 100644 --- a/Core/Tools/matchbot/wnet/field.h +++ b/Core/Tools/matchbot/wnet/field.h @@ -35,6 +35,8 @@ * Functions: * * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ +#pragma once + #define FIELD_HEADER_SIZE (sizeof(FieldClass) - (sizeof(void *) * 2)) #define TYPE_CHAR 1 diff --git a/Core/Tools/matchbot/wnet/packet.cpp b/Core/Tools/matchbot/wnet/packet.cpp index 8cda4f64b01..5426d75b6ae 100644 --- a/Core/Tools/matchbot/wnet/packet.cpp +++ b/Core/Tools/matchbot/wnet/packet.cpp @@ -114,7 +114,7 @@ PacketClass::PacketClass(char *curbuf) ID = *((short *)curbuf); curbuf += sizeof(unsigned short); ID = ntohs(ID); - Head = NULL; + Head = nullptr; // // Calculate the remaining size so that we can loop through the @@ -268,7 +268,7 @@ FieldClass *PacketClass::Find_Field(char *id) if ( strncmp(id, current->ID, 4) == 0) return current; } - return NULL; + return nullptr; } // gks 9/25/2000 @@ -280,7 +280,7 @@ FieldClass *PacketClass::Get_Field_At(int position) } if (current) return current; - else return NULL; + else return nullptr; } // gks 9/25/2000 diff --git a/Core/Tools/matchbot/wnet/tcp.cpp b/Core/Tools/matchbot/wnet/tcp.cpp index 66ea079c7af..f48622cd564 100644 --- a/Core/Tools/matchbot/wnet/tcp.cpp +++ b/Core/Tools/matchbot/wnet/tcp.cpp @@ -472,7 +472,7 @@ char *TCP::Gets(char *string,int n,int whichFD) whichFD=GetFD(); if (whichFD <= 0) - return(NULL); + return(nullptr); memset(string,0,n); @@ -485,7 +485,7 @@ char *TCP::Gets(char *string,int n,int whichFD) if (! FD_ISSET(whichFD,&fdSet)) { DBGMSG("Gets timeout: " << inputDelay); - return(NULL); + return(nullptr); } retval=Read((unsigned char *)&c,1,whichFD); @@ -499,7 +499,7 @@ char *TCP::Gets(char *string,int n,int whichFD) else if ((retval==0)&&(i==0)) { DBGMSG("Remote endpoint closed (1)"); - return(NULL); + return(nullptr); } else if (retval==0) return(string); @@ -551,8 +551,8 @@ sint32 TCP::TimedRead(uint8 *msg,uint32 len,int seconds,sint32 whichFD) sint32 bytes_read=0; sint32 retval; - time_t stop_time=time(NULL)+seconds; - while ((time(NULL)<=stop_time)&&((uint32)bytes_read=0) done=1; @@ -892,7 +892,7 @@ bit8 TCP::Bind(char *Host,uint16 port,bit8 reuseAddr) strcpy(hostName, Host); hostStruct = gethostbyname(Host); - if (hostStruct == NULL) + if (hostStruct == nullptr) return (0); hostNode = (struct in_addr *) hostStruct->h_addr; return ( Bind(ntohl(hostNode->s_addr),port,reuseAddr) ); @@ -978,7 +978,7 @@ bit8 TCP::Connect(char *Host,uint16 port) strcpy(hostName, Host); hostStruct = gethostbyname(Host); - if (hostStruct == NULL) + if (hostStruct == nullptr) {ERRMSG("Can't resolve host");return (0);} hostNode = (struct in_addr *) hostStruct->h_addr; return ( Connect(ntohl(hostNode->s_addr),port) ); @@ -1064,7 +1064,7 @@ bit8 TCP::ConnectAsync(char *Host,uint16 port) strcpy(hostName, Host); hostStruct = gethostbyname(Host); - if (hostStruct == NULL) + if (hostStruct == nullptr) return (0); hostNode = (struct in_addr *) hostStruct->h_addr; return ( ConnectAsync(ntohl(hostNode->s_addr),port) ); diff --git a/Core/Tools/matchbot/wnet/udp.cpp b/Core/Tools/matchbot/wnet/udp.cpp index bba9479b658..96037517e29 100644 --- a/Core/Tools/matchbot/wnet/udp.cpp +++ b/Core/Tools/matchbot/wnet/udp.cpp @@ -40,7 +40,7 @@ sint32 UDP::Bind(char *Host,uint16 port) strcpy(hostName, Host); hostStruct = gethostbyname(Host); - if (hostStruct == NULL) + if (hostStruct == nullptr) return (0); hostNode = (struct in_addr *) hostStruct->h_addr; return ( Bind(ntohl(hostNode->s_addr),port) ); @@ -158,7 +158,7 @@ sint32 UDP::Read(uint8 *msg,uint32 len,sockaddr_in *from) sint32 retval; int alen=sizeof(sockaddr_in); - if (from!=NULL) + if (from!=nullptr) { retval=recvfrom(fd,(char *)msg,len,0,(struct sockaddr *)from,&alen); #ifdef _WIN32 @@ -168,7 +168,7 @@ sint32 UDP::Read(uint8 *msg,uint32 len,sockaddr_in *from) } else { - retval=recvfrom(fd,(char *)msg,len,0,NULL,NULL); + retval=recvfrom(fd,(char *)msg,len,0,nullptr,nullptr); #ifdef _WIN32 if (retval==SOCKET_ERROR) retval=-1; @@ -267,7 +267,7 @@ int UDP::Wait(sint32 sec,sint32 usec,fd_set &givenSet,fd_set &returnSet) while( ! done) { if (noTimeout) - retval=select(givenMax+1,&returnSet,0,0,NULL); + retval=select(givenMax+1,&returnSet,0,0,nullptr); else { timeout.GetTimevalMT(tv); diff --git a/Core/Tools/textureCompress/CMakeLists.txt b/Core/Tools/textureCompress/CMakeLists.txt index 818499c6cc0..241355822b7 100644 --- a/Core/Tools/textureCompress/CMakeLists.txt +++ b/Core/Tools/textureCompress/CMakeLists.txt @@ -9,9 +9,8 @@ set_target_properties(core_texturecompress PROPERTIES OUTPUT_NAME texturecompres target_sources(core_texturecompress PRIVATE ${TEXTURECOMPRESS_SRC}) target_link_libraries(core_texturecompress PRIVATE - core_config - core_utility core_wwlib + corei_always ) if(WIN32 OR "${CMAKE_SYSTEM}" MATCHES "Windows") diff --git a/Core/Tools/textureCompress/textureCompress.cpp b/Core/Tools/textureCompress/textureCompress.cpp index 0eefe77166c..b13a413c9ac 100644 --- a/Core/Tools/textureCompress/textureCompress.cpp +++ b/Core/Tools/textureCompress/textureCompress.cpp @@ -41,14 +41,14 @@ static const char *nodxtPrefix[] = { "zhca", "caust", - NULL, + nullptr, }; static const char *nodxtAnywhere[] = { "userinterface", "controlbar", "commandbar", - NULL, + nullptr, }; #define LOG(x) logStuff x @@ -61,7 +61,7 @@ static void logStuff(const char *fmt, ...) va_end( va ); puts(buffer); - ::MessageBox(NULL, buffer, "textureCompress", MB_OK); + ::MessageBox(nullptr, buffer, "textureCompress", MB_OK); } #ifdef RTS_DEBUG @@ -70,12 +70,12 @@ class DebugMunkee { public: DebugMunkee(const char *fname = "debugLog.txt") { m_fp = fopen(fname, "w"); } - ~DebugMunkee() { if (m_fp) fclose(m_fp); m_fp = NULL; } + ~DebugMunkee() { if (m_fp) fclose(m_fp); m_fp = nullptr; } FILE *m_fp; }; -static DebugMunkee *theDebugMunkee = NULL; +static DebugMunkee *theDebugMunkee = nullptr; #define DEBUG_LOG(x) debugLog x static void debugLog(const char *fmt, ...) @@ -317,7 +317,7 @@ void compressOrigFiles(const std::string& sourceDirName, const std::string& targ char tmpFname[_MAX_PATH] = "C:\\temp\\tmp.txt"; GetTempPath(_MAX_PATH, tmpPath); GetTempFileName(tmpPath, "tex", 0, tmpFname); - HANDLE h = CreateFile(tmpFname, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, NULL); + HANDLE h = CreateFile(tmpFname, GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY, nullptr); if (!h) { DEBUG_LOG(("Could not create temp file '%s'! Unable to compress textures!", tmpFname)); @@ -332,7 +332,7 @@ void compressOrigFiles(const std::string& sourceDirName, const std::string& targ tmp.append("\n"); DEBUG_LOG(("Compressing file: %s", tmp.c_str())); DWORD len; - WriteFile(h, tmp.c_str(), tmp.length(), &len, NULL); + WriteFile(h, tmp.c_str(), tmp.length(), &len, nullptr); } CloseHandle(h); @@ -596,13 +596,13 @@ int APIENTRY WinMain(HINSTANCE hInstance, */ int argc = 1; char * argv[20]; - argv[0] = NULL; + argv[0] = nullptr; char * token = strtok(lpCmdLine, " "); - while (argc < 20 && token != NULL) + while (argc < 20 && token != nullptr) { argv[argc++] = strtrim(token); - token = strtok(NULL, " "); + token = strtok(nullptr, " "); } #else int main(int argc, const char **argv) @@ -633,7 +633,7 @@ int main(int argc, const char **argv) #ifdef RTS_DEBUG delete theDebugMunkee; - theDebugMunkee = NULL; + theDebugMunkee = nullptr; #endif } diff --git a/Core/Tools/timingTest/CMakeLists.txt b/Core/Tools/timingTest/CMakeLists.txt index ac7207e0895..ad1d51be766 100644 --- a/Core/Tools/timingTest/CMakeLists.txt +++ b/Core/Tools/timingTest/CMakeLists.txt @@ -10,8 +10,7 @@ set_target_properties(core_timingtest PROPERTIES OUTPUT_NAME timingtest) target_sources(core_timingtest PRIVATE ${TIMINGTEST_SRC}) target_link_libraries(core_timingtest PRIVATE - core_config - core_utility + corei_always winmm ) diff --git a/Core/Tools/versionUpdate/CMakeLists.txt b/Core/Tools/versionUpdate/CMakeLists.txt index e9d1f21dec5..052ae04d482 100644 --- a/Core/Tools/versionUpdate/CMakeLists.txt +++ b/Core/Tools/versionUpdate/CMakeLists.txt @@ -8,6 +8,6 @@ set_target_properties(core_versionupdate PROPERTIES OUTPUT_NAME versionupdate) target_sources(core_versionupdate PRIVATE ${VERSIONUPDATE_SRC}) target_link_libraries(core_versionupdate PRIVATE - core_config core_wwlib + corei_always ) diff --git a/Core/Tools/versionUpdate/versionUpdate.cpp b/Core/Tools/versionUpdate/versionUpdate.cpp index e8c1a90929b..6e1bd19b250 100644 --- a/Core/Tools/versionUpdate/versionUpdate.cpp +++ b/Core/Tools/versionUpdate/versionUpdate.cpp @@ -99,13 +99,13 @@ int APIENTRY WinMain(HINSTANCE hInstance, */ int argc = 1; char * argv[20]; - argv[0] = NULL; + argv[0] = nullptr; char * token = strtok(lpCmdLine, " "); - while (argc < 20 && token != NULL) + while (argc < 20 && token != nullptr) { argv[argc++] = strtrim(token); - token = strtok(NULL, " "); + token = strtok(nullptr, " "); } int build = 0; @@ -124,18 +124,18 @@ int APIENTRY WinMain(HINSTANCE hInstance, if (filePtr) { char buffer[256]; - char *stringPtr = NULL; + char *stringPtr = nullptr; while (!feof(filePtr)) { fread(buffer, 256, 1, filePtr); - if ((stringPtr = strstr(buffer, VERSION_STRING)) != NULL) + if ((stringPtr = strstr(buffer, VERSION_STRING)) != nullptr) { char *ptr; // Looking for '#define VERSION "x.y.z"' ptr = strtok(stringPtr, " "); // The VERSION - ptr = strtok(NULL, "\n"); // The remainder + ptr = strtok(nullptr, "\n"); // The remainder if (*ptr == '\"') { diff --git a/Core/Tools/wolSetup/CMakeLists.txt b/Core/Tools/wolSetup/CMakeLists.txt index 01e253838f7..8c8a2418cc9 100644 --- a/Core/Tools/wolSetup/CMakeLists.txt +++ b/Core/Tools/wolSetup/CMakeLists.txt @@ -21,7 +21,7 @@ set_target_properties(core_wolsetup PROPERTIES OUTPUT_NAME wolsetup) target_sources(core_wolsetup PRIVATE ${WOLSETUP_SRC}) target_link_libraries(core_wolsetup PRIVATE - core_config + corei_always Version ) diff --git a/Core/Tools/wolSetup/WOLAPI/chatdefs.h b/Core/Tools/wolSetup/WOLAPI/chatdefs.h index e0175d75740..c05e140794e 100644 --- a/Core/Tools/wolSetup/WOLAPI/chatdefs.h +++ b/Core/Tools/wolSetup/WOLAPI/chatdefs.h @@ -34,13 +34,13 @@ #define CHAT_E_NICKINUSE MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 100) // Your password is incorrect during login #define CHAT_E_BADPASS MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 101) -// Reference made to non-existant user or channel +// Reference made to non-existent user or channel #define CHAT_E_NONESUCH MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 102) // The network layer is down or cannot be initialized for some reason #define CHAT_E_CON_NETDOWN MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 103) // Name lookup (e.g DNS) failed for some reason #define CHAT_E_CON_LOOKUP_FAILED MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 104) -// Some fatal error occured with the net connection +// Some fatal error occurred with the net connection #define CHAT_E_CON_ERROR MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 105) // General request timeout for a request #define CHAT_E_TIMEOUT MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 106) @@ -48,7 +48,7 @@ #define CHAT_E_MUSTPATCH MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 107) // Miscellaneous internal status error #define CHAT_E_STATUSERROR MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 108) -// Server has returned something we don't recognise +// Server has returned something we don't recognize #define CHAT_E_UNKNOWNRESPONSE MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 109) // Tried to join a channel that has enough players already #define CHAT_E_CHANNELFULL MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 110) @@ -123,13 +123,13 @@ #define CHAT_E_NOTIMPLEMENTED MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 502) // The request was made while while a conflicting request was still pending #define CHAT_E_PENDINGREQUEST MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 503) -// Invalid parameter passed - usually a NULL pointer +// Invalid parameter passed - usually a nullptr pointer #define CHAT_E_PARAMERROR MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 504) // Tried to create or join a channel before leaving the previous one #define CHAT_E_LEAVECHANNEL MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 508) // Tried to send something to a channel when not a member of any channel #define CHAT_E_JOINCHANNEL MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 509) -// Tried to join a non-existant channel +// Tried to join a non-existent channel #define CHAT_E_UNKNOWNCHANNEL MAKE_HRESULT( SEVERITY_ERROR, FACILITY_ITF, 510) diff --git a/Core/Tools/wolSetup/verchk.cpp b/Core/Tools/wolSetup/verchk.cpp index 3f51d306aa5..eefabe20665 100644 --- a/Core/Tools/wolSetup/verchk.cpp +++ b/Core/Tools/wolSetup/verchk.cpp @@ -34,7 +34,7 @@ */ bool GetVersionInfo(char* filename, VS_FIXEDFILEINFO* fileInfo) { - if (filename == NULL || fileInfo == NULL) + if (filename == nullptr || fileInfo == nullptr) { return false; } diff --git a/Core/Tools/wolSetup/wolInit.cpp b/Core/Tools/wolSetup/wolInit.cpp index 912f470522f..a9dbe6cca09 100644 --- a/Core/Tools/wolSetup/wolInit.cpp +++ b/Core/Tools/wolSetup/wolInit.cpp @@ -20,9 +20,6 @@ // Westwood Online DLL/COM/ initialization/teardown // Author: Matthew D. Campbell, December 2001 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif #include #include @@ -78,7 +75,7 @@ void getPathsFromRegistry( void ) if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, GENERALS_REG_KEY_PATH, 0, KEY_ALL_ACCESS, &handle ) == ERROR_SUCCESS) { - returnValue = RegQueryValueEx(handle, GENERALS_REG_KEY_INSTALLPATH, NULL, &type, (unsigned char *) &g_generalsFilename, &size); + returnValue = RegQueryValueEx(handle, GENERALS_REG_KEY_INSTALLPATH, nullptr, &type, (unsigned char *) &g_generalsFilename, &size); if (returnValue != ERROR_SUCCESS) { @@ -93,7 +90,7 @@ void getPathsFromRegistry( void ) if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, GENERALS_REG_KEY_PATH, 0, KEY_ALL_ACCESS, &handle ) == ERROR_SUCCESS) { - returnValue = RegQueryValueEx(handle, GENERALS_REG_KEY_SERIAL, NULL, &type, (unsigned char *) &g_generalsSerial, &size); + returnValue = RegQueryValueEx(handle, GENERALS_REG_KEY_SERIAL, nullptr, &type, (unsigned char *) &g_generalsSerial, &size); if (returnValue != ERROR_SUCCESS) { @@ -109,7 +106,7 @@ void getPathsFromRegistry( void ) if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, WOLAPI_REG_KEY_PATH, 0, KEY_ALL_ACCESS, &handle ) == ERROR_SUCCESS) { - returnValue = RegQueryValueEx(handle, WOLAPI_REG_KEY_INSTALLPATH, NULL, &type, (unsigned char *) &g_wolapiRegFilename, &size); + returnValue = RegQueryValueEx(handle, WOLAPI_REG_KEY_INSTALLPATH, nullptr, &type, (unsigned char *) &g_wolapiRegFilename, &size); if (returnValue != ERROR_SUCCESS) { @@ -125,7 +122,7 @@ void getPathsFromRegistry( void ) if (RegOpenKeyEx( HKEY_CLASSES_ROOT, DLL_REG_KEY_PATH, 0, KEY_ALL_ACCESS, &handle ) == ERROR_SUCCESS) { - returnValue = RegQueryValueEx(handle, DLL_REG_KEY_LOCATION, NULL, &type, (unsigned char *) &g_wolapiRealFilename, &size); + returnValue = RegQueryValueEx(handle, DLL_REG_KEY_LOCATION, nullptr, &type, (unsigned char *) &g_wolapiRealFilename, &size); if (returnValue != ERROR_SUCCESS) { @@ -145,7 +142,7 @@ void setupGenerals( const char *genPath, const char *genSerial ) int size; char lpClass[] = "REG_NONE"; - if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, GENERALS_REG_KEY_PATH, 0, lpClass, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &handle, NULL ) == ERROR_SUCCESS) { + if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, GENERALS_REG_KEY_PATH, 0, lpClass, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, nullptr, &handle, nullptr ) == ERROR_SUCCESS) { type = REG_SZ; size = strlen(genPath)+1; @@ -177,13 +174,13 @@ void setupGenerals( const char *genPath, const char *genSerial ) class OLEInitializer { public: - OLEInitializer() { OleInitialize(NULL); } + OLEInitializer() { OleInitialize(nullptr); } ~OLEInitializer() { OleUninitialize(); } }; OLEInitializer g_OLEInitializer; CComModule _Module; -IChat *g_pChat = NULL; +IChat *g_pChat = nullptr; /** * checkInstalledWolapiVersion inits WOLAPI if possible and gets its version @@ -192,10 +189,10 @@ IChat *g_pChat = NULL; void checkInstalledWolapiVersion( void ) { // Initialize this instance - _Module.Init(NULL, g_hInst); + _Module.Init(nullptr, g_hInst); // Create the WOLAPI instance - CoCreateInstance(CLSID_Chat, NULL, CLSCTX_INPROC_SERVER, \ + CoCreateInstance(CLSID_Chat, nullptr, CLSCTX_INPROC_SERVER, \ IID_IChat, (void**)&g_pChat); if (g_pChat) diff --git a/Core/Tools/wolSetup/wolSetup.cpp b/Core/Tools/wolSetup/wolSetup.cpp index 5ef59825bf5..0b044b6fe32 100644 --- a/Core/Tools/wolSetup/wolSetup.cpp +++ b/Core/Tools/wolSetup/wolSetup.cpp @@ -20,9 +20,6 @@ // Defines the entry point for the application. // Author: Matthew D. Campbell, December 2001 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif #include #include #include @@ -44,7 +41,7 @@ void registerDLL(const char *dllName) // Find the entry point. (FARPROC&)lpDllEntryPoint = GetProcAddress(hLib, "DllRegisterServer"); - if (lpDllEntryPoint != NULL) + if (lpDllEntryPoint != nullptr) (*lpDllEntryPoint)(); else ;//unable to locate entry point @@ -52,7 +49,7 @@ void registerDLL(const char *dllName) -HINSTANCE g_hInst = NULL; +HINSTANCE g_hInst = nullptr; LRESULT CALLBACK MainDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam); @@ -65,13 +62,13 @@ int APIENTRY WinMain(HINSTANCE hInstance, checkInstalledWolapiVersion(); - DialogBox(g_hInst, (LPCTSTR)IDD_MAINBOX, NULL, (DLGPROC)MainDialogProc); + DialogBox(g_hInst, (LPCTSTR)IDD_MAINBOX, nullptr, (DLGPROC)MainDialogProc); return 0; } -// Mesage handler for generals setup box. +// Message handler for generals setup box. LRESULT CALLBACK GeneralsSetupDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) @@ -124,7 +121,7 @@ void updateDisplay(HWND hDlg) SetDlgItemText(hDlg, IDC_TEXT_GENERALSDIR, g_generalsFilename); } -// Mesage handler for main dialog box. +// Message handler for main dialog box. LRESULT CALLBACK MainDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) diff --git a/Dependencies/Utility/CMakeLists.txt b/Dependencies/Utility/CMakeLists.txt index 1140f751c95..a810813bd62 100644 --- a/Dependencies/Utility/CMakeLists.txt +++ b/Dependencies/Utility/CMakeLists.txt @@ -1,3 +1,33 @@ +set(UTILITY_SRC + Utility/compat.h + Utility/CppMacros.h + Utility/endian_compat.h + Utility/fstream_adapter.h + Utility/hash_map_adapter.h + Utility/intrin_compat.h + Utility/iostream_adapter.h + Utility/mem_compat.h + Utility/sstream_adapter.h + Utility/stdint_adapter.h + Utility/stdio_adapter.h + Utility/string_compat.h + Utility/tchar_compat.h + Utility/thread_compat.h + Utility/time_compat.h + Utility/wchar_compat.h +) + +## core_utility + add_library(core_utility INTERFACE) +target_include_directories(core_utility INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_precompile_headers(core_utility INTERFACE + [["Utility/CppMacros.h"]] # Must be first, to be removed when abandoning VC6 +) +target_sources(core_utility PRIVATE ${UTILITY_SRC}) + +## core_utility_no_pch -target_include_directories(core_utility INTERFACE ".") +add_library(core_utility_no_pch INTERFACE) +target_include_directories(core_utility_no_pch INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) +target_sources(core_utility_no_pch PRIVATE ${UTILITY_SRC}) diff --git a/Dependencies/Utility/Utility/CppMacros.h b/Dependencies/Utility/Utility/CppMacros.h index 8bfb0297f29..d8f1bdddded 100644 --- a/Dependencies/Utility/Utility/CppMacros.h +++ b/Dependencies/Utility/Utility/CppMacros.h @@ -17,30 +17,57 @@ */ // This file contains macros to help upgrade the code for newer cpp standards. +// Must be C compliant + #pragma once +#if __cplusplus >= 201103L +#include +#endif + +#if __cplusplus >= 201103L +#define CPP_11(code) code +#else +#define CPP_11(code) +#define static_assert(expr, msg) +#define constexpr +#define noexcept +#define nullptr 0 +#endif + #if __cplusplus >= 201703L -#define NOEXCEPT_17 noexcept #define REGISTER #define FALLTHROUGH [[fallthrough]] #else -#define NOEXCEPT_17 #define REGISTER register #define FALLTHROUGH #endif // noexcept for methods of IUNKNOWN interface #if defined(_MSC_VER) -#define IUNKNOWN_NOEXCEPT NOEXCEPT_17 +#define IUNKNOWN_NOEXCEPT noexcept #else #define IUNKNOWN_NOEXCEPT #endif +#ifdef __cplusplus +namespace stl +{ + +// Helper to move-assign from reference: uses std::move in C++11, swap in C++98 +template +inline void move_or_swap(T& dest, T& src) +{ #if __cplusplus >= 201103L -#define CPP_11(code) code + dest = std::move(src); #else -#define CPP_11(code) -#define static_assert(expr, msg) -#define constexpr -#define nullptr 0 + // C++03 fallback: mimic move semantics + // dest gets src's value, src becomes empty + T empty; + dest.swap(src); + src.swap(empty); +#endif +} + +} // namespace stl #endif diff --git a/Dependencies/Utility/Utility/atl_compat.h b/Dependencies/Utility/Utility/atl_compat.h new file mode 100644 index 00000000000..5be3b20f591 --- /dev/null +++ b/Dependencies/Utility/Utility/atl_compat.h @@ -0,0 +1,89 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2026 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 . +*/ + +/** + * @file atl_compat.h + * @brief ATL compatibility layer for MinGW-w64 with ReactOS ATL + * + * Provides compatibility definitions for using ReactOS ATL headers + * with MinGW-w64 GCC compiler. Uses ReactOS PSEH in C++-compatible + * dummy mode (_USE_DUMMY_PSEH) because MinGW-w64's PSEH uses GNU C + * nested functions which are not valid in C++. + */ + +#pragma once + +#ifdef __MINGW32__ + +// Include Windows types needed for ATL compatibility +#include + +// Include PSEH compatibility first (uses ReactOS PSEH in dummy mode) +#include "pseh_compat.h" + +// Define _ATL_IIDOF macro for ReactOS ATL (uses MinGW-w64's __uuidof) +#ifndef _ATL_IIDOF +#define _ATL_IIDOF(x) __uuidof(x) +#endif + +// Forward declare _Delegate function for COM aggregation support +// ReactOS ATL's COM_INTERFACE_ENTRY_AGGREGATE macro uses _Delegate but doesn't define it +// The actual function pointer will be defined after atlbase.h provides _ATL_CREATORARGFUNC +extern "C" HRESULT WINAPI _ATL_DelegateQueryInterface(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw); + +// Suppress additional warnings from ReactOS ATL headers +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma GCC diagnostic ignored "-Wattributes" + +// NOTE: ReactOS ATL compile definitions are set in cmake/reactos-atl.cmake: +// - _ATL_CSTRING_EXPLICIT_CONSTRUCTORS +// - _ATL_NO_DEBUG_CRT +// - ATL_NO_ASSERT_ON_DESTROY_NONEXISTENT_WINDOW +// - ATL_NO_DEFAULT_LIBS +// These are applied via target_compile_definitions() on the reactos_atl target. +// Any target linking to reactos_atl will automatically inherit these definitions. +// +// IMPORTANT: _ATL_NO_AUTOMATIC_NAMESPACE is NOT defined because the codebase +// uses ATL types (CComModule, CComObject, CString, etc.) without namespace +// qualification and relies on the automatic 'using namespace ATL;' from ATL headers. + +// Define _Delegate implementation and macro now that ATL types are available +inline HRESULT WINAPI _ATL_DelegateQueryInterface(void* pv, REFIID riid, LPVOID* ppv, DWORD_PTR dw) +{ + IUnknown** ppunk = reinterpret_cast(reinterpret_cast(pv) + dw); + if (*ppunk == nullptr) + return E_NOINTERFACE; + return (*ppunk)->QueryInterface(riid, ppv); +} + +#ifndef _Delegate +#define _Delegate ((ATL::_ATL_CREATORARGFUNC*)_ATL_DelegateQueryInterface) +#endif + +// Restore compiler warnings after ATL includes +#define ATL_COMPAT_RESTORE_WARNINGS() \ + do { \ + _Pragma("GCC diagnostic pop") \ + PSEH_COMPAT_RESTORE_WARNINGS() \ + } while(0) + +#else +// Non-MinGW platforms don't need these workarounds +#define ATL_COMPAT_RESTORE_WARNINGS() +#endif // __MINGW32__ diff --git a/Dependencies/Utility/Utility/comsupp_compat.h b/Dependencies/Utility/Utility/comsupp_compat.h new file mode 100644 index 00000000000..053e4e081ed --- /dev/null +++ b/Dependencies/Utility/Utility/comsupp_compat.h @@ -0,0 +1,143 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2026 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 . +*/ + +/** + * @file comsupp_compat.h + * @brief COM Support compatibility layer for MinGW-w64 + * + * Provides _com_util::ConvertStringToBSTR() and ConvertBSTRToString() + * as header-only implementations for MinGW-w64 builds. + * + * These functions are required by the _bstr_t class (from ReactOS comutil.h) + * for char* <-> BSTR conversions. They are called internally when constructing + * _bstr_t objects from C strings or converting _bstr_t back to char*. + * + * Used indirectly by: + * - Core/Libraries/Source/WWVegas/WW3D2/dx8webbrowser.cpp (8+ _bstr_t constructions) + * - Core/GameEngine/Include/GameNetwork/WOLBrowser/FEBDispatch.h (_bstr_t usage) + * + * MinGW-w64 provides COM error handling (comdef.h) but lacks the string + * conversion utilities. ReactOS provides comsupp.cpp with implementations, + * but we use this header-only version to avoid building/linking an extra + * library. This must be included BEFORE comutil.h to provide definitions + * before _bstr_t's inline methods are instantiated. + * + * @note Include this header before in MinGW builds to provide + * symbol definitions for _bstr_t's internal string conversion calls. + * Without this, you will get "undefined reference" linker errors. + */ + +#pragma once + +#ifdef __MINGW32__ + +#include +#include +#include +#include + +namespace _com_util +{ + +inline BSTR WINAPI ConvertStringToBSTR(const char *pSrc) +{ + DWORD cwch; + BSTR wsOut = nullptr; + + if (!pSrc) + return nullptr; + + // Compute the needed size with the null terminator + cwch = MultiByteToWideChar(CP_ACP, 0, pSrc, -1, nullptr, 0); + if (cwch == 0) + return nullptr; + + // Allocate the BSTR (without the null terminator) + wsOut = SysAllocStringLen(nullptr, cwch - 1); + if (!wsOut) + { + _com_issue_error(HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY)); + return nullptr; + } + + // Convert the string + if (MultiByteToWideChar(CP_ACP, 0, pSrc, -1, wsOut, cwch) == 0) + { + // We failed, clean everything up + cwch = GetLastError(); + + SysFreeString(wsOut); + wsOut = nullptr; + + _com_issue_error(!IS_ERROR(cwch) ? HRESULT_FROM_WIN32(cwch) : cwch); + } + + return wsOut; +} + +inline char* WINAPI ConvertBSTRToString(BSTR pSrc) +{ + DWORD cb, cwch; + char *szOut = nullptr; + + if (!pSrc) + return nullptr; + + // Retrieve the size of the BSTR with the null terminator + cwch = SysStringLen(pSrc) + 1; + + // Compute the needed size with the null terminator + cb = WideCharToMultiByte(CP_ACP, 0, pSrc, cwch, nullptr, 0, nullptr, nullptr); + if (cb == 0) + { + cwch = GetLastError(); + _com_issue_error(!IS_ERROR(cwch) ? HRESULT_FROM_WIN32(cwch) : cwch); + return nullptr; + } + + // Allocate the string + szOut = (char*)::operator new(cb * sizeof(char)); + if (!szOut) + { + _com_issue_error(HRESULT_FROM_WIN32(ERROR_OUTOFMEMORY)); + return nullptr; + } + + // Convert the string and null-terminate + szOut[cb - 1] = '\0'; + if (WideCharToMultiByte(CP_ACP, 0, pSrc, cwch, szOut, cb, nullptr, nullptr) == 0) + { + // We failed, clean everything up + cwch = GetLastError(); + + ::operator delete(szOut); + szOut = nullptr; + + _com_issue_error(!IS_ERROR(cwch) ? HRESULT_FROM_WIN32(cwch) : cwch); + } + + return szOut; +} + +} + +// Provide vtMissing global variable +// Use inline variable (C++17) to avoid multiple definition errors +inline _variant_t vtMissing(DISP_E_PARAMNOTFOUND, VT_ERROR); + +#endif // __MINGW32__ diff --git a/Dependencies/Utility/Utility/endian_compat.h b/Dependencies/Utility/Utility/endian_compat.h index 08c6fdb16f4..d79ed176e8f 100644 --- a/Dependencies/Utility/Utility/endian_compat.h +++ b/Dependencies/Utility/Utility/endian_compat.h @@ -22,7 +22,6 @@ #ifndef ENDIAN_COMPAT_H #define ENDIAN_COMPAT_H -#include #include diff --git a/Dependencies/Utility/Utility/pseh_compat.h b/Dependencies/Utility/Utility/pseh_compat.h new file mode 100644 index 00000000000..eeab3097632 --- /dev/null +++ b/Dependencies/Utility/Utility/pseh_compat.h @@ -0,0 +1,51 @@ +/* +** Command & Conquer Generals Zero Hour(tm) +** Copyright 2026 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 . +*/ + +/** + * @file pseh_compat.h + * @brief PSEH compatibility for MinGW-w64 with ReactOS ATL + * + * ReactOS ATL headers include . This header ensures + * that ReactOS PSEH is used in C++-compatible dummy mode (_USE_DUMMY_PSEH). + * The cmake configuration (reactos-atl.cmake) adds ReactOS PSEH headers + * to the include path before system headers, and defines _USE_DUMMY_PSEH. + */ + +#pragma once + +#ifdef __MINGW32__ + +// Suppress PSEH-related warnings from ReactOS PSEH headers +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunknown-pragmas" +#pragma GCC diagnostic ignored "-Wattributes" +#pragma GCC diagnostic ignored "-Wunused-variable" +#pragma GCC diagnostic ignored "-Wunused-but-set-variable" +#pragma GCC diagnostic ignored "-Wunused-label" + +// ReactOS PSEH headers will be included by ATL headers +// No need to include them explicitly here + +// Restore compiler warnings after PSEH includes +#define PSEH_COMPAT_RESTORE_WARNINGS() \ + _Pragma("GCC diagnostic pop") + +#else +// Non-MinGW platforms use native SEH or don't need PSEH +#define PSEH_COMPAT_RESTORE_WARNINGS() +#endif // __MINGW32__ diff --git a/Generals/CMakeLists.txt b/Generals/CMakeLists.txt index 78f920244e6..bfacf3af3b6 100644 --- a/Generals/CMakeLists.txt +++ b/Generals/CMakeLists.txt @@ -48,14 +48,14 @@ if(RTS_INSTALL_PREFIX_GENERALS) install(FILES $ DESTINATION "${RTS_INSTALL_PREFIX_GENERALS}" OPTIONAL) endif() - if(TARGET g_particleeditor) - install(TARGETS g_particleeditor RUNTIME DESTINATION "${RTS_INSTALL_PREFIX_GENERALS}") - install(FILES $ DESTINATION "${RTS_INSTALL_PREFIX_GENERALS}" OPTIONAL) + if(TARGET core_particleeditor) + install(TARGETS core_particleeditor RUNTIME DESTINATION "${RTS_INSTALL_PREFIX_GENERALS}") + install(FILES $ DESTINATION "${RTS_INSTALL_PREFIX_GENERALS}" OPTIONAL) endif() - if(TARGET g_debugwindow) - install(TARGETS g_debugwindow RUNTIME DESTINATION "${RTS_INSTALL_PREFIX_GENERALS}") - install(FILES $ DESTINATION "${RTS_INSTALL_PREFIX_GENERALS}" OPTIONAL) + if(TARGET core_debugwindow) + install(TARGETS core_debugwindow RUNTIME DESTINATION "${RTS_INSTALL_PREFIX_GENERALS}") + install(FILES $ DESTINATION "${RTS_INSTALL_PREFIX_GENERALS}" OPTIONAL) endif() if(TARGET g_guiedit) diff --git a/Generals/Code/CMakeLists.txt b/Generals/Code/CMakeLists.txt index 33576cba689..85838bb94d6 100644 --- a/Generals/Code/CMakeLists.txt +++ b/Generals/Code/CMakeLists.txt @@ -1,24 +1,28 @@ # g stands for Generals, i stands for Interface add_library(gi_gameengine_include INTERFACE) -add_library(gi_libraries_include INTERFACE) add_library(gi_libraries_source_wwvegas INTERFACE) add_library(gi_main INTERFACE) add_library(gi_always INTERFACE) +add_library(gi_always_no_pch INTERFACE) # Use this for Shared Libs with MFC AFX target_include_directories(gi_gameengine_include INTERFACE "GameEngine/Include") -target_link_libraries(gi_gameengine_include INTERFACE corei_gameengine_include) -target_include_directories(gi_libraries_include INTERFACE "Libraries/Include") target_include_directories(gi_libraries_source_wwvegas INTERFACE "Libraries/Source/WWVegas") target_include_directories(gi_main INTERFACE "Main") target_compile_definitions(gi_always INTERFACE RTS_GENERALS=1 ) +target_compile_definitions(gi_always_no_pch INTERFACE + RTS_GENERALS=1 +) +target_link_libraries(gi_gameengine_include INTERFACE + corei_gameengine_include +) target_link_libraries(gi_always INTERFACE - core_utility - gi_libraries_include - # Must stay below so headers from game are included first - corei_libraries_include + corei_always # Must stay below so headers from game are included first +) +target_link_libraries(gi_always_no_pch INTERFACE + corei_always_no_pch # Must stay below so headers from game are included first ) # Contains internal libraries diff --git a/Generals/Code/GameEngine/CMakeLists.txt b/Generals/Code/GameEngine/CMakeLists.txt index 9553884b67f..991e6a72698 100644 --- a/Generals/Code/GameEngine/CMakeLists.txt +++ b/Generals/Code/GameEngine/CMakeLists.txt @@ -16,7 +16,6 @@ set(GAMEENGINE_SRC Include/Common/BitFlags.h Include/Common/BitFlagsIO.h Include/Common/BuildAssistant.h - Include/Common/CDManager.h Include/Common/ClientUpdateModule.h Include/Common/CommandLine.h # Include/Common/crc.h @@ -33,12 +32,12 @@ set(GAMEENGINE_SRC Include/Common/DrawModule.h Include/Common/encrypt.h Include/Common/Energy.h - Include/Common/Errors.h +# Include/Common/Errors.h # Include/Common/file.h # Include/Common/FileSystem.h Include/Common/FunctionLexicon.h # Include/Common/GameAudio.h - Include/Common/GameCommon.h +# Include/Common/GameCommon.h # Include/Common/GameDefines.h Include/Common/GameEngine.h Include/Common/GameLOD.h @@ -48,12 +47,12 @@ set(GAMEENGINE_SRC Include/Common/GameSpyMiscPreferences.h Include/Common/GameState.h Include/Common/GameStateMap.h - Include/Common/GameType.h +# Include/Common/GameType.h Include/Common/Geometry.h Include/Common/GlobalData.h Include/Common/Handicap.h Include/Common/IgnorePreferences.h - Include/Common/INI.h +# Include/Common/INI.h Include/Common/INIException.h Include/Common/KindOf.h Include/Common/LadderPreferences.h @@ -98,7 +97,7 @@ set(GAMEENGINE_SRC Include/Common/ScoreKeeper.h Include/Common/SkirmishBattleHonors.h Include/Common/SkirmishPreferences.h - Include/Common/Snapshot.h +# Include/Common/Snapshot.h Include/Common/SparseMatchFinder.h Include/Common/SpecialPower.h Include/Common/SpecialPowerMaskType.h @@ -106,9 +105,9 @@ set(GAMEENGINE_SRC Include/Common/StackDump.h Include/Common/StateMachine.h Include/Common/StatsCollector.h - Include/Common/STLTypedefs.h +# Include/Common/STLTypedefs.h # Include/Common/StreamingArchiveFile.h - Include/Common/SubsystemInterface.h +# Include/Common/SubsystemInterface.h Include/Common/SystemInfo.h Include/Common/Team.h Include/Common/Terrain.h @@ -121,7 +120,7 @@ set(GAMEENGINE_SRC # Include/Common/UnicodeString.h Include/Common/UnitTimings.h Include/Common/Upgrade.h - Include/Common/UserPreferences.h +# Include/Common/UserPreferences.h Include/Common/version.h Include/Common/WellKnownKeys.h # Include/Common/WorkerProcess.h @@ -132,8 +131,8 @@ set(GAMEENGINE_SRC # Include/Common/XferSave.h Include/GameClient/Anim2D.h Include/GameClient/AnimateWindowManager.h +# Include/GameClient/ChallengeGenerals.h Include/GameClient/CampaignManager.h - Include/GameClient/CDCheck.h Include/GameClient/ClientInstance.h # Include/GameClient/ClientRandomValue.h Include/GameClient/Color.h @@ -199,7 +198,7 @@ set(GAMEENGINE_SRC Include/GameClient/Module/BeaconClientUpdate.h Include/GameClient/Module/SwayClientUpdate.h Include/GameClient/Mouse.h - Include/GameClient/ParticleSys.h +# Include/GameClient/ParticleSys.h Include/GameClient/PlaceEventTranslator.h Include/GameClient/ProcessAnimateWindow.h Include/GameClient/RadiusDecal.h @@ -532,7 +531,7 @@ set(GAMEENGINE_SRC Source/Common/GameLOD.cpp Source/Common/GameMain.cpp Source/Common/GlobalData.cpp - Source/Common/INI/INI.cpp +# Source/Common/INI/INI.cpp Source/Common/INI/INIAiData.cpp Source/Common/INI/INIAnimation.cpp # Source/Common/INI/INIAudioEventInfo.cpp @@ -591,7 +590,6 @@ set(GAMEENGINE_SRC # Source/Common/System/ArchiveFileSystem.cpp # Source/Common/System/AsciiString.cpp Source/Common/System/BuildAssistant.cpp - Source/Common/System/CDManager.cpp Source/Common/System/CriticalSection.cpp Source/Common/System/DataChunk.cpp # Source/Common/System/Debug.cpp @@ -601,9 +599,9 @@ set(GAMEENGINE_SRC # Source/Common/System/File.cpp # Source/Common/System/FileSystem.cpp Source/Common/System/FunctionLexicon.cpp - Source/Common/System/GameCommon.cpp +# Source/Common/System/GameCommon.cpp #Source/Common/System/GameMemory.cpp - Source/Common/System/GameType.cpp +# Source/Common/System/GameType.cpp Source/Common/System/Geometry.cpp Source/Common/System/KindOf.cpp Source/Common/System/List.cpp @@ -617,10 +615,10 @@ set(GAMEENGINE_SRC Source/Common/System/registry.cpp Source/Common/System/SaveGame/GameState.cpp Source/Common/System/SaveGame/GameStateMap.cpp - Source/Common/System/Snapshot.cpp +# Source/Common/System/Snapshot.cpp Source/Common/System/StackDump.cpp # Source/Common/System/StreamingArchiveFile.cpp - Source/Common/System/SubsystemInterface.cpp +# Source/Common/System/SubsystemInterface.cpp Source/Common/System/Trig.cpp # Source/Common/System/UnicodeString.cpp Source/Common/System/Upgrade.cpp @@ -635,7 +633,7 @@ set(GAMEENGINE_SRC Source/Common/Thing/Thing.cpp Source/Common/Thing/ThingFactory.cpp Source/Common/Thing/ThingTemplate.cpp - Source/Common/UserPreferences.cpp +# Source/Common/UserPreferences.cpp Source/Common/version.cpp # Source/Common/WorkerProcess.cpp Source/GameClient/ClientInstance.cpp @@ -657,6 +655,7 @@ set(GAMEENGINE_SRC Source/GameClient/GlobalLanguage.cpp Source/GameClient/GraphDraw.cpp Source/GameClient/GUI/AnimateWindowManager.cpp +# Source/GameClient/GUI/ChallengeGenerals.cpp Source/GameClient/GUI/ControlBar/ControlBar.cpp Source/GameClient/GUI/ControlBar/ControlBarBeacon.cpp Source/GameClient/GUI/ControlBar/ControlBarCommand.cpp @@ -771,7 +770,7 @@ set(GAMEENGINE_SRC # "Source/GameClient/System/Debug Displayers/AudioDebugDisplay.cpp" Source/GameClient/System/DebugDisplay.cpp Source/GameClient/System/Image.cpp - Source/GameClient/System/ParticleSys.cpp +# Source/GameClient/System/ParticleSys.cpp Source/GameClient/System/RayEffect.cpp # Source/GameClient/Terrain/TerrainRoads.cpp # Source/GameClient/Terrain/TerrainVisual.cpp @@ -1096,4 +1095,7 @@ target_link_libraries(g_gameengine PUBLIC g_wwvegas ) -target_precompile_headers(g_gameengine PRIVATE Include/Precompiled/PreRTS.h) +target_precompile_headers(g_gameengine PRIVATE + [["Utility/CppMacros.h"]] # Must be first, to be removed when abandoning VC6 + Include/Precompiled/PreRTS.h +) diff --git a/Generals/Code/GameEngine/Include/Common/BitFlags.h b/Generals/Code/GameEngine/Include/Common/BitFlags.h index 2616939a118..5c572210109 100644 --- a/Generals/Code/GameEngine/Include/Common/BitFlags.h +++ b/Generals/Code/GameEngine/Include/Common/BitFlags.h @@ -43,7 +43,7 @@ class AsciiString; us initialize stuff in useful ways, and (2) provide a default constructor that implicitly converts ints into bitsets in a "wrong" way (ie, it treats the int as a mask, not an index). So we wrap to correct this, but leave the bitset "exposed" so that we can use all the non-ctor - functions on it directly (since it doesn't overload operator= to do the "wrong" thing, strangley enough) + functions on it directly (since it doesn't overload operator= to do the "wrong" thing, strangely enough) */ template class BitFlags @@ -58,15 +58,26 @@ class BitFlags /* just a little syntactic sugar so that there is no "foo = 0" compatible constructor */ - enum BogusInitType - { - kInit = 0 - }; + enum BogusInitType { kInit }; + enum InitSetAllType { kInitSetAll }; BitFlags() { } + // This constructor sets all bits to 1 + BitFlags(InitSetAllType) + { + m_bits.set(); + } + + BitFlags(UnsignedInt value) + : m_bits(static_cast(value)) + { + } + + // TheSuperHackers @todo Replace with variadic template + BitFlags(BogusInitType k, Int idx1) { m_bits.set(idx1); @@ -102,33 +113,15 @@ class BitFlags m_bits.set(idx5); } - BitFlags(BogusInitType k, - Int idx1, - Int idx2, - Int idx3, - Int idx4, - Int idx5, - Int idx6, - Int idx7, - Int idx8, - Int idx9, - Int idx10, - Int idx11, - Int idx12 - ) + // Set all given indices in the array. + BitFlags(BogusInitType, const Int* idxs, Int count) { - m_bits.set(idx1); - m_bits.set(idx2); - m_bits.set(idx3); - m_bits.set(idx4); - m_bits.set(idx5); - m_bits.set(idx6); - m_bits.set(idx7); - m_bits.set(idx8); - m_bits.set(idx9); - m_bits.set(idx10); - m_bits.set(idx11); - m_bits.set(idx12); + const Int* idx = idxs; + const Int* end = idxs + count; + for (; idx < end; ++idx) + { + m_bits.set(*idx); + } } Bool operator==(const BitFlags& that) const @@ -259,6 +252,17 @@ class BitFlags return true; } + // TheSuperHackers @info Function for rare use cases where we must access the flags as an integer. + // Not using to_ulong because that can throw. Truncates all bits above 32. + UnsignedInt toUnsignedInt() const noexcept + { + UnsignedInt val = 0; + const UnsignedInt count = min(m_bits.size(), sizeof(val) * 8); + for (UnsignedInt i = 0; i < count; ++i) + val |= m_bits.test(i) * (1u << i); + return val; + } + static const char* const* getBitNames() { return s_bitNameList; @@ -266,7 +270,7 @@ class BitFlags static const char* getNameFromSingleBit(Int i) { - return (i >= 0 && i < NUMBITS) ? s_bitNameList[i] : NULL; + return (i >= 0 && i < NUMBITS) ? s_bitNameList[i] : nullptr; } static Int getSingleBitFromName(const char* token) @@ -284,7 +288,7 @@ class BitFlags const char* getBitNameIfSet(Int i) const { - return test(i) ? s_bitNameList[i] : NULL; + return test(i) ? s_bitNameList[i] : nullptr; } Bool setBitByName(const char* token) @@ -309,14 +313,14 @@ class BitFlags void buildDescription( AsciiString* str ) const { - if ( str == NULL ) + if ( str == nullptr ) return;//sanity for( Int i = 0; i < size(); ++i ) { const char* bitName = getBitNameIfSet(i); - if (bitName != NULL) + if (bitName != nullptr) { str->concat( bitName ); str->concat( ",\n"); @@ -324,5 +328,38 @@ class BitFlags } } + // TheSuperHackers @feature Stubbjax 23/01/2026 Add function for outputting debug data. + AsciiString toHexString() const + { + constexpr const int numChunks = (NUMBITS + 63) / 64; + char chunkBuf[32]; // Enough for 16 hex digits + null terminator + AsciiString result; + bool printedAny = false; + + for (int chunk = numChunks - 1; chunk >= 0; --chunk) + { + unsigned long long val = 0; + for (int bit = 0; bit < 64 && (chunk * 64 + bit) < NUMBITS; ++bit) + { + if (m_bits.test(chunk * 64 + bit)) + val |= (unsigned long long)(1) << bit; + } + if (val != 0 || chunk == 0 || printedAny) + { + if (printedAny) + snprintf(chunkBuf, sizeof(chunkBuf), "%016llX", val); + else + snprintf(chunkBuf, sizeof(chunkBuf), "%llX", val); + + result.concat(chunkBuf); + printedAny = true; + } + } + + if (!printedAny) + result = "0"; + + return result; + } }; diff --git a/Generals/Code/GameEngine/Include/Common/BitFlagsIO.h b/Generals/Code/GameEngine/Include/Common/BitFlagsIO.h index 197c79f31fa..16306b2d023 100644 --- a/Generals/Code/GameEngine/Include/Common/BitFlagsIO.h +++ b/Generals/Code/GameEngine/Include/Common/BitFlagsIO.h @@ -39,14 +39,14 @@ template void BitFlags::buildDescription( AsciiString* str ) const { - if ( str == NULL ) + if ( str == nullptr ) return;//sanity for( Int i = 0; i < size(); ++i ) { const char* bitName = getBitNameIfSet(i); - if (bitName != NULL) + if (bitName != nullptr) { str->concat( bitName ); str->concat( ",\n"); @@ -67,7 +67,7 @@ void BitFlags::parse(INI* ini, AsciiString* str) Bool foundAddOrSub = false; // loop through all tokens - for (const char *token = ini->getNextTokenOrNull(); token != NULL; token = ini->getNextTokenOrNull()) + for (const char *token = ini->getNextTokenOrNull(); token != nullptr; token = ini->getNextTokenOrNull()) { if (str) { @@ -132,7 +132,7 @@ void BitFlags::parse(INI* ini, AsciiString* str) template /*static*/ void BitFlags::parseFromINI(INI* ini, void* /*instance*/, void *store, const void* /*userData*/) { - ((BitFlags*)store)->parse(ini, NULL); + ((BitFlags*)store)->parse(ini, nullptr); } //------------------------------------------------------------------------------------------------- @@ -172,7 +172,7 @@ void BitFlags::xfer(Xfer* xfer) const char* bitName = getBitNameIfSet(i); // ignore if this kindof is not set in our mask data - if (bitName == NULL) + if (bitName == nullptr) continue; // this bit is set, write the string value diff --git a/Generals/Code/GameEngine/Include/Common/BuildAssistant.h b/Generals/Code/GameEngine/Include/Common/BuildAssistant.h index 84a2d206781..f478a709858 100644 --- a/Generals/Code/GameEngine/Include/Common/BuildAssistant.h +++ b/Generals/Code/GameEngine/Include/Common/BuildAssistant.h @@ -111,7 +111,7 @@ class BuildAssistant : public SubsystemInterface { TERRAIN_RESTRICTIONS = 0x00000001, ///< Check for basic terrain restrictions CLEAR_PATH = 0x00000002, ///< Must be able to path find to location - NO_OBJECT_OVERLAP = 0X00000004, ///< Can't overlap enemy objects, or locally controled objects that can't move out of the way + NO_OBJECT_OVERLAP = 0X00000004, ///< Can't overlap enemy objects, or locally controlled objects that can't move out of the way USE_QUICK_PATHFIND = 0x00000008, ///< Use the quick pathfind method for CLEAR_PATH SHROUD_REVEALED = 0x00000010, ///< Check to make sure the shroud is revealed NO_ENEMY_OBJECT_OVERLAP=0x00000020, ///< Can't overlap enemy objects only. @@ -165,7 +165,7 @@ class BuildAssistant : public SubsystemInterface /// tiling wall object helper function, we can use this to "tile" walls when building virtual TileBuildInfo *buildTiledLocations( const ThingTemplate *thingBeingTiled, - Real angle, // angle to consturct thing being tiled + Real angle, // angle to construct thing being tiled const Coord3D *start, const Coord3D *end, Real tilingSize, Int maxTiles, Object *builderObject ); diff --git a/Generals/Code/GameEngine/Include/Common/CDManager.h b/Generals/Code/GameEngine/Include/Common/CDManager.h deleted file mode 100644 index 2b5a60b1574..00000000000 --- a/Generals/Code/GameEngine/Include/Common/CDManager.h +++ /dev/null @@ -1,185 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//---------------------------------------------------------------------------- -// -// Project: Generals -// -// Module: Game Engine Common -// -// File name: Common/CDManager.h -// -// Created: 11/26/01 TR -// -//---------------------------------------------------------------------------- - -#pragma once - -//---------------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------------- - -#include "Common/List.h" -#include "Common/SubsystemInterface.h" -#include "Common/AsciiString.h" - - -//---------------------------------------------------------------------------- -// Forward References -//---------------------------------------------------------------------------- - - - -//---------------------------------------------------------------------------- -// Type Defines -//---------------------------------------------------------------------------- - -namespace CD -{ - enum Disk - { - UNKNOWN_DISK = -3, - NO_DISK = -2, - ANY_DISK = -1, - DISK_1 = 0, - NUM_DISKS - }; -}; - -//=============================== -// CDDriveInterface -//=============================== -/** - * Interface to a CD ROM drive - */ -//=============================== - -class CDDriveInterface -{ - public: - - virtual ~CDDriveInterface() {}; - - virtual void refreshInfo( void ) = 0; ///< Update drive with least - - virtual AsciiString getDiskName( void ) = 0; ///< Returns the drive path for this drive - virtual AsciiString getPath( void ) = 0; ///< Returns the drive path for this drive - virtual CD::Disk getDisk( void ) = 0; ///< Returns ID of current disk in this drive - -}; - -//=============================== -// CDDrive -//=============================== - -class CDDrive : public CDDriveInterface -{ - friend class CDManager; - public: - - CDDrive(); - virtual ~CDDrive(); - - // CDDriveInterface operations - virtual AsciiString getPath( void ); ///< Returns the drive path for this drive - virtual AsciiString getDiskName( void ); ///< Returns the drive path for this drive - virtual CD::Disk getDisk( void ); ///< Returns ID of current disk in this drive - virtual void refreshInfo( void ); ///< Update drive with least - - // CDDrive operations - void setPath( const Char *path ); ///< Set the drive's path - - protected: - - LListNode m_node; ///< Link list node - AsciiString m_diskName; ///< disk's volume name - AsciiString m_drivePath; ///< drive's device path - CD::Disk m_disk; ///< ID of disk in drive -}; - - -//=============================== -// CDManagerInterface -//=============================== - -class CDManagerInterface : public SubsystemInterface -{ - public: - - virtual ~CDManagerInterface(){}; - - virtual Int driveCount( void ) = 0; ///< Number of CD drives detected - virtual CDDriveInterface* getDrive( Int index ) = 0; ///< Return the specified drive - virtual CDDriveInterface* newDrive( const Char *path ) = 0; ///< add new drive of specified path - virtual void refreshDrives( void ) = 0; ///< Refresh drive info - virtual void destroyAllDrives( void ) = 0; ///< Like it says, destroy all drives - - protected: - - virtual CDDriveInterface* createDrive( void ) = 0; -}; - -//=============================== -// CDManager -//=============================== - -class CDManager : public CDManagerInterface -{ - public: - - CDManager(); - virtual ~CDManager(); - - // sub system operations - virtual void init( void ); - virtual void update( void ); - virtual void reset( void ); - - // - virtual Int driveCount( void ); ///< Number of CD drives detected - virtual CDDriveInterface* getDrive( Int index ); ///< Return the specified drive - virtual CDDriveInterface* newDrive( const Char *path ); ///< add new drive of specified path - virtual void refreshDrives( void ); ///< Refresh drive info - virtual void destroyAllDrives( void ); ///< Like it says, destroy all drives - - - - protected: - - LList m_drives; ///< List of drives detected on this machine -}; - -//---------------------------------------------------------------------------- -// Inlining -//---------------------------------------------------------------------------- - -extern CDManagerInterface *TheCDManager; -CDManagerInterface* CreateCDManager( void ); diff --git a/Generals/Code/GameEngine/Include/Common/CriticalSection.h b/Generals/Code/GameEngine/Include/Common/CriticalSection.h index b44a88f2ffb..98b10c6af08 100644 --- a/Generals/Code/GameEngine/Include/Common/CriticalSection.h +++ b/Generals/Code/GameEngine/Include/Common/CriticalSection.h @@ -92,7 +92,7 @@ class ScopedCriticalSection } }; -// These should be NULL on creation then non-NULL in WinMain or equivalent. +// These should be null on creation then non-null in WinMain or equivalent. // This allows us to be silently non-threadsafe for WB and other single-threaded apps. extern CriticalSection *TheAsciiStringCriticalSection; extern CriticalSection *TheUnicodeStringCriticalSection; diff --git a/Generals/Code/GameEngine/Include/Common/DamageFX.h b/Generals/Code/GameEngine/Include/Common/DamageFX.h index 710a76e55cc..d41752782cf 100644 --- a/Generals/Code/GameEngine/Include/Common/DamageFX.h +++ b/Generals/Code/GameEngine/Include/Common/DamageFX.h @@ -116,8 +116,8 @@ class DamageFX void clear() { m_amountForMajorFX = 0.0f; - m_majorDamageFXList = NULL; - m_minorDamageFXList = NULL; + m_majorDamageFXList = nullptr; + m_minorDamageFXList = nullptr; m_damageFXThrottleTime = 0; } }; diff --git a/Generals/Code/GameEngine/Include/Common/DataChunk.h b/Generals/Code/GameEngine/Include/Common/DataChunk.h index 9c0e747d9c2..8e31ede5e6f 100644 --- a/Generals/Code/GameEngine/Include/Common/DataChunk.h +++ b/Generals/Code/GameEngine/Include/Common/DataChunk.h @@ -187,8 +187,8 @@ class DataChunkInput // to create an object, and a subsequent chunk to // parse values into that object. However, the second // chunk parser could also create and parse an object - // of its own if this pointer is NULL. - // The parser of the base class should NULL this pointer. + // of its own if this pointer is null. + // The parser of the base class should set this pointer to null. void *m_userData; // user data hook public: @@ -196,10 +196,10 @@ class DataChunkInput ~DataChunkInput(); // register a parser function for data chunks with labels matching "label", whose parent - // chunks labels match "parentLabel" (or NULL for global scope) - void registerParser( const AsciiString& label, const AsciiString& parentLabel, DataChunkParserPtr parser, void *userData = NULL ); + // chunks labels match "parentLabel" (or null for global scope) + void registerParser( const AsciiString& label, const AsciiString& parentLabel, DataChunkParserPtr parser, void *userData = nullptr ); - Bool parse( void *userData = NULL ); // parse the chunk stream using registered parsers + Bool parse( void *userData = nullptr ); // parse the chunk stream using registered parsers // assumed to be at the start of chunk when called // can be called recursively diff --git a/Generals/Code/GameEngine/Include/Common/Dict.h b/Generals/Code/GameEngine/Include/Common/Dict.h index 424fa3ae6bf..9bc7ffb12b3 100644 --- a/Generals/Code/GameEngine/Include/Common/Dict.h +++ b/Generals/Code/GameEngine/Include/Common/Dict.h @@ -141,31 +141,31 @@ class Dict if there is no pair with the given key, or the value is not of the correct type, 0 is returned. */ - Bool getBool(NameKeyType key, Bool* exists = NULL) const; + Bool getBool(NameKeyType key, Bool* exists = nullptr) const; /** return the value for the pair with the given key. if there is no pair with the given key, or the value is not of the correct type, 0 is returned. */ - Int getInt(NameKeyType key, Bool* exists = NULL) const; + Int getInt(NameKeyType key, Bool* exists = nullptr) const; /** return the value for the pair with the given key. if there is no pair with the given key, or the value is not of the correct type, 0 is returned. */ - Real getReal(NameKeyType key, Bool* exists = NULL) const; + Real getReal(NameKeyType key, Bool* exists = nullptr) const; /** return the value for the pair with the given key. if there is no pair with the given key, or the value is not of the correct type, "" is returned. */ - AsciiString getAsciiString(NameKeyType key, Bool* exists = NULL) const; + AsciiString getAsciiString(NameKeyType key, Bool* exists = nullptr) const; /** return the value for the pair with the given key. if there is no pair with the given key, or the value is not of the correct type, "" is returned. */ - UnicodeString getUnicodeString(NameKeyType key, Bool* exists = NULL) const; + UnicodeString getUnicodeString(NameKeyType key, Bool* exists = nullptr) const; /** return the value for the pair with the given index. diff --git a/Generals/Code/GameEngine/Include/Common/DisabledTypes.h b/Generals/Code/GameEngine/Include/Common/DisabledTypes.h index 31fd14a0b70..eb7e004eeb3 100644 --- a/Generals/Code/GameEngine/Include/Common/DisabledTypes.h +++ b/Generals/Code/GameEngine/Include/Common/DisabledTypes.h @@ -45,10 +45,10 @@ enum DisabledType CPP_11(: Int) DISABLED_HELD, //Special case -- held means it can fire and isHeld checks to make sure ONLY held is set! DISABLED_PARALYZED, //Battle plans have changed, and unit is confused/paralyzed DISABLED_UNMANNED, //Vehicle is unmanned - DISABLED_UNDERPOWERED,//Seperate from ScriptUnderpowered, the owning player has insufficient power. Energy status controls this + DISABLED_UNDERPOWERED,//Separate from ScriptUnderpowered, the owning player has insufficient power. Energy status controls this DISABLED_FREEFALL, //This unit has been disabled via being in free fall - //These ones are specificially for scripts to enable/reenable! + //These ones are specifically for scripts to enable/reenable! DISABLED_SCRIPT_DISABLED, DISABLED_SCRIPT_UNDERPOWERED, @@ -105,4 +105,3 @@ inline void FLIP_DISABLEDMASK(DisabledMaskType& m) extern const char *TheDisabledNames[]; extern DisabledMaskType DISABLEDMASK_NONE; // inits to all zeroes extern DisabledMaskType DISABLEDMASK_ALL; // inits to all bits set. -void initDisabledMasks(); diff --git a/Generals/Code/GameEngine/Include/Common/DrawModule.h b/Generals/Code/GameEngine/Include/Common/DrawModule.h index e13310fa187..a68ffba6b1d 100644 --- a/Generals/Code/GameEngine/Include/Common/DrawModule.h +++ b/Generals/Code/GameEngine/Include/Common/DrawModule.h @@ -93,20 +93,20 @@ class DrawModule : public DrawableModule virtual Bool isLaser() const { return false; } // interface acquisition - virtual ObjectDrawInterface* getObjectDrawInterface() { return NULL; } - virtual const ObjectDrawInterface* getObjectDrawInterface() const { return NULL; } + virtual ObjectDrawInterface* getObjectDrawInterface() { return nullptr; } + virtual const ObjectDrawInterface* getObjectDrawInterface() const { return nullptr; } - virtual DebrisDrawInterface* getDebrisDrawInterface() { return NULL; } - virtual const DebrisDrawInterface* getDebrisDrawInterface() const { return NULL; } + virtual DebrisDrawInterface* getDebrisDrawInterface() { return nullptr; } + virtual const DebrisDrawInterface* getDebrisDrawInterface() const { return nullptr; } - virtual TracerDrawInterface* getTracerDrawInterface() { return NULL; } - virtual const TracerDrawInterface* getTracerDrawInterface() const { return NULL; } + virtual TracerDrawInterface* getTracerDrawInterface() { return nullptr; } + virtual const TracerDrawInterface* getTracerDrawInterface() const { return nullptr; } - virtual RopeDrawInterface* getRopeDrawInterface() { return NULL; } - virtual const RopeDrawInterface* getRopeDrawInterface() const { return NULL; } + virtual RopeDrawInterface* getRopeDrawInterface() { return nullptr; } + virtual const RopeDrawInterface* getRopeDrawInterface() const { return nullptr; } - virtual LaserDrawInterface* getLaserDrawInterface() { return NULL; } - virtual const LaserDrawInterface* getLaserDrawInterface() const { return NULL; } + virtual LaserDrawInterface* getLaserDrawInterface() { return nullptr; } + virtual const LaserDrawInterface* getLaserDrawInterface() const { return nullptr; } }; inline DrawModule::DrawModule( Thing *thing, const ModuleData* moduleData ) : DrawableModule( thing, moduleData ) { } @@ -199,7 +199,7 @@ class ObjectDrawInterface /** similar to the above, but assumes that the current state is a "ONCE", and is smart about transition states... if there is a transition state - "inbetween", it is included in the completion time. + "in between", it is included in the completion time. */ virtual void setAnimationCompletionTime(UnsignedInt numFrames) = 0; virtual Bool updateBonesForClientParticleSystems( void ) = 0;///< this will reposition particle systems on the fly ML diff --git a/Generals/Code/GameEngine/Include/Common/Energy.h b/Generals/Code/GameEngine/Include/Common/Energy.h index ecdda0f2f6f..bf2ea16935d 100644 --- a/Generals/Code/GameEngine/Include/Common/Energy.h +++ b/Generals/Code/GameEngine/Include/Common/Energy.h @@ -44,7 +44,7 @@ #pragma once -// INLCUDES ///////////////////////////////////////////////////////////////////////////////////// +// INCLUDES ///////////////////////////////////////////////////////////////////////////////////// #include "Common/Snapshot.h" // ---------------------------------------------------------------------------------------------- diff --git a/Generals/Code/GameEngine/Include/Common/Errors.h b/Generals/Code/GameEngine/Include/Common/Errors.h deleted file mode 100644 index 2c2cec27c6c..00000000000 --- a/Generals/Code/GameEngine/Include/Common/Errors.h +++ /dev/null @@ -1,67 +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: Errors.h -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: Errors.h -// -// Created: Steven Johnson, August 2001 -// -// Desc: Error codes -// -//----------------------------------------------------------------------------- -/////////////////////////////////////////////////////////////////////////////// - -#pragma once - -/** - An ErrorCode is the repository for failure modes. In almost all situations, - these values will be THROWN, not returned as error codes. Feel free - to add to this list as necessary; however, there should generally be very - few codes needed. -*/ -enum ErrorCode CPP_11(: UnsignedInt) -{ - ERROR_BASE = 0xdead0001, // a nice, distinctive value - - ERROR_BUG = (ERROR_BASE + 0x0000), ///< should not be possible under normal operation - ERROR_OUT_OF_MEMORY = (ERROR_BASE + 0x0001), ///< unable to allocate memory. - ERROR_BAD_ARG = (ERROR_BASE + 0x0002), ///< generic "bad argument". - ERROR_INVALID_FILE_VERSION = (ERROR_BASE + 0x0003), ///< Unrecognized file version. - ERROR_CORRUPT_FILE_FORMAT = (ERROR_BASE + 0x0004), ///< Invalid file format. - ERROR_BAD_INI = (ERROR_BASE + 0x0005), ///< Bad INI data. - ERROR_INVALID_D3D = (ERROR_BASE + 0x0006), ///< Error initing D3D - - ERROR_LAST -}; diff --git a/Generals/Code/GameEngine/Include/Common/FunctionLexicon.h b/Generals/Code/GameEngine/Include/Common/FunctionLexicon.h index bdc82b65de3..8426652bb65 100644 --- a/Generals/Code/GameEngine/Include/Common/FunctionLexicon.h +++ b/Generals/Code/GameEngine/Include/Common/FunctionLexicon.h @@ -84,12 +84,12 @@ class FunctionLexicon : public SubsystemInterface TableEntry *getTable( TableIndex index ); // - // !NOTE! We do NOT have a functionToName() method becuase we assume + // !NOTE! We do NOT have a functionToName() method because we assume // that functions in the tables are unique and that there is a 1 to 1 // mapping of a symbol to a function address. However, when compiling // in release, functions that have the same arguments and the same // body (mainly empty stub functions) get optimized to the - // SAME ADDRESS. That destroyes our 1 to 1 mapping so it is something + // SAME ADDRESS. That destroys our 1 to 1 mapping so it is something // that we must avoid // // translate a function pointer to its symbolic name diff --git a/Generals/Code/GameEngine/Include/Common/GameCommon.h b/Generals/Code/GameEngine/Include/Common/GameCommon.h deleted file mode 100644 index 77d9eb99d8b..00000000000 --- a/Generals/Code/GameEngine/Include/Common/GameCommon.h +++ /dev/null @@ -1,488 +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: GameCommon.h //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: GameCommon.h -// -// Created: Steven Johnson, October 2001 -// -// Desc: This is a catchall header for some basic types and definitions -// needed by various bits of the GameLogic/GameClient, but that -// we haven't found a good place for yet. Hopefully this file -// should go away someday, but for now is a convenient spot. -// -//----------------------------------------------------------------------------- - -#pragma once - -// ---------------------------------------------------------------------------------------------- -#include "Lib/BaseType.h" -#include "WWCommon.h" -#include "Common/GameDefines.h" - -// ---------------------------------------------------------------------------------------------- -#if defined(RTS_DEBUG) - #define NO_DUMP_PERF_STATS -#else - #define NO_DUMP_PERF_STATS -#endif - -// ---------------------------------------------------------------------------------------------- -enum -{ - 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)); -const Real MSEC_PER_LOGICFRAME_REAL = (((Real)MSEC_PER_SECOND) / ((Real)LOGICFRAMES_PER_SECOND)); -const Real LOGICFRAMES_PER_SECONDS_REAL = (Real)LOGICFRAMES_PER_SECOND; -const Real SECONDS_PER_LOGICFRAME_REAL = 1.0f / LOGICFRAMES_PER_SECONDS_REAL; - -// ---------------------------------------------------------------------------------------------- -// note that this returns a REAL value, not an int... most callers will want to -// call ceil() on the result, so that partial frames get converted to full frames! -inline Real ConvertDurationFromMsecsToFrames(Real msec) -{ - return (msec * LOGICFRAMES_PER_MSEC_REAL); -} - -// ---------------------------------------------------------------------------------------------- -inline Real ConvertVelocityInSecsToFrames(Real distPerMsec) -{ - // this looks wrong, but is the correct conversion factor. - return (distPerMsec * SECONDS_PER_LOGICFRAME_REAL); -} - -// ---------------------------------------------------------------------------------------------- -inline Real ConvertAccelerationInSecsToFrames(Real distPerSec2) -{ - // this looks wrong, but is the correct conversion factor. - const Real SEC_PER_LOGICFRAME_SQR = (SECONDS_PER_LOGICFRAME_REAL * SECONDS_PER_LOGICFRAME_REAL); - return (distPerSec2 * SEC_PER_LOGICFRAME_SQR); -} - -// ---------------------------------------------------------------------------------------------- -inline Real ConvertAngularVelocityInDegreesPerSecToRadsPerFrame(Real degPerSec) -{ - const Real RADS_PER_DEGREE = PI / 180.0f; - return (degPerSec * (SECONDS_PER_LOGICFRAME_REAL * RADS_PER_DEGREE)); -} - -// ---------------------------------------------------------------------------------------------- -enum -{ - MAX_PLAYER_COUNT = 16 ///< max number of Players. -}; - -// ---------------------------------------------------------------------------------------------- -/** - a bitmask that can uniquely represent each player. -*/ -#if MAX_PLAYER_COUNT <= 16 - typedef UnsignedShort PlayerMaskType; - const PlayerMaskType PLAYERMASK_ALL = 0xffff; - const PlayerMaskType PLAYERMASK_NONE = 0x0; -#else - #error "this is the wrong size" -#endif - -//------------------------------------------------------------------------------------------------- -enum GameDifficulty CPP_11(: Int) -{ - DIFFICULTY_EASY, - DIFFICULTY_NORMAL, - DIFFICULTY_HARD, - - DIFFICULTY_COUNT -}; - -//------------------------------------------------------------------------------------------------- -enum PlayerType CPP_11(: Int) -{ - PLAYER_HUMAN, ///< player is human-controlled - PLAYER_COMPUTER, ///< player is computer-controlled - - PLAYERTYPE_COUNT -}; - -//------------------------------------------------------------------------------------------------- -/// A PartitionCell can be one of three states for Shroud -enum CellShroudStatus CPP_11(: Int) -{ - CELLSHROUD_CLEAR, - CELLSHROUD_FOGGED, - CELLSHROUD_SHROUDED, -}; - -//------------------------------------------------------------------------------------------------- -/// Since an object can take up more than a single PartitionCell, this is a status that applies to the whole Object -enum ObjectShroudStatus CPP_11(: Int) -{ - OBJECTSHROUD_INVALID, ///< indeterminate state, will recompute - OBJECTSHROUD_CLEAR, ///< object is not shrouded at all (ie, completely visible) - OBJECTSHROUD_PARTIAL_CLEAR, ///< object is partly clear (rest is shroud or fog) - 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) -}; - -//------------------------------------------------------------------------------------------------- -enum GuardMode CPP_11(: Int) -{ - GUARDMODE_NORMAL, - GUARDMODE_GUARD_WITHOUT_PURSUIT, // no pursuit out of guard area - GUARDMODE_GUARD_FLYING_UNITS_ONLY // ignore nonflyers -}; - -// --------------------------------------------------- -enum -{ - NEVER = 0, - FOREVER = 0x3fffffff // (we use 0x3fffffff so that we can add offsets and not overflow... - // at 30fps we're still pretty safe!) -}; - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- - -/// Veterancy level define needed by several files that don't need the full Experience code. -// NOTE NOTE NOTE: Keep TheVeterencyNames in sync with these. -enum VeterancyLevel CPP_11(: Int) -{ - LEVEL_REGULAR, - LEVEL_VETERAN, - LEVEL_ELITE, - LEVEL_HEROIC, - - LEVEL_COUNT, - LEVEL_INVALID, - - LEVEL_FIRST = 0, - LEVEL_LAST = LEVEL_HEROIC -}; - -// TheVeterancyNames is defined in GameCommon.cpp -extern const char *const TheVeterancyNames[]; - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -enum CommandSourceType CPP_11(: Int) -{ - - CMD_FROM_PLAYER = 0, - CMD_FROM_SCRIPT, - 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. - - COMMAND_SOURCE_TYPE_COUNT -}; - -//------------------------------------------------------------------------------------------------- -enum AbleToAttackType CPP_11(: Int) -{ - _ATTACK_FORCED = 0x01, - _ATTACK_CONTINUED = 0x02, - _ATTACK_TUNNELNETWORK_GUARD = 0x04, - - /** - can we attack if this is a new target? - */ - ATTACK_NEW_TARGET = (0), - - /** - can we attack if this is a new target, via force-fire? - (The only current difference between this and ATTACK_NEW_TARGET is that disguised units - are force-attackable even when stealthed.) - */ - ATTACK_NEW_TARGET_FORCED= (_ATTACK_FORCED), - - /** - can we attack if this is continuation of an existing attack? - (The only current difference between this and ATTACK_NEW_TARGET is you are allowed to follow - immobile shrouded units into the fog) - */ - ATTACK_CONTINUED_TARGET = (_ATTACK_CONTINUED), - - /** - can we attack if this is continuation of an existing attack? - (The only current difference between this and ATTACK_NEW_TARGET is you are allowed to follow - immobile shrouded units into the fog) - */ - ATTACK_CONTINUED_TARGET_FORCED = (_ATTACK_FORCED | _ATTACK_CONTINUED), - - /** - Special case that bypasses some of the checks for units guarding from within tunnel networks! - For example, a unit inside couldn't normally see outside and would fail. - */ - ATTACK_TUNNEL_NETWORK_GUARD = (_ATTACK_TUNNELNETWORK_GUARD) - -}; - -//------------------------------------------------------------------------------------------------- -inline Bool isForcedAttack(AbleToAttackType t) -{ - return (((Int)t) & _ATTACK_FORCED) != 0; -} - -//------------------------------------------------------------------------------------------------- -inline Bool isContinuedAttack(AbleToAttackType t) -{ - return (((Int)t) & _ATTACK_CONTINUED) != 0; -} - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- - -typedef UnsignedInt VeterancyLevelFlags; - -const VeterancyLevelFlags VETERANCY_LEVEL_FLAGS_ALL = 0xffffffff; -const VeterancyLevelFlags VETERANCY_LEVEL_FLAGS_NONE = 0x00000000; - -inline Bool getVeterancyLevelFlag(VeterancyLevelFlags flags, VeterancyLevel dt) -{ - return (flags & (1UL << (dt - 1))) != 0; -} - -inline VeterancyLevelFlags setVeterancyLevelFlag(VeterancyLevelFlags flags, VeterancyLevel dt) -{ - return (flags | (1UL << (dt - 1))); -} - -inline VeterancyLevelFlags clearVeterancyLevelFlag(VeterancyLevelFlags flags, VeterancyLevel dt) -{ - return (flags & ~(1UL << (dt - 1))); -} - -// ---------------------------------------------------------------------------------------------- -#define BOGUSPTR(p) ((((unsigned int)(p)) & 1) != 0) - -// ---------------------------------------------------------------------------------------------- -#define MAKE_DLINK_HEAD(OBJCLASS, LISTNAME) \ -public: \ - inline DLINK_ITERATOR iterate_##LISTNAME() const \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr")); \ - return DLINK_ITERATOR(m_dlinkhead_##LISTNAME.m_head, &OBJCLASS::dlink_next_##LISTNAME); \ - } \ - inline OBJCLASS *getFirstItemIn_##LISTNAME() const \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr")); \ - return m_dlinkhead_##LISTNAME.m_head; \ - } \ - inline Bool isInList_##LISTNAME(OBJCLASS* o) const \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr")); \ - return o->dlink_isInList_##LISTNAME(&m_dlinkhead_##LISTNAME.m_head); \ - } \ - inline void prependTo_##LISTNAME(OBJCLASS* o) \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr")); \ - if (!isInList_##LISTNAME(o)) \ - o->dlink_prependTo_##LISTNAME(&m_dlinkhead_##LISTNAME.m_head); \ - } \ - inline void removeFrom_##LISTNAME(OBJCLASS* o) \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr")); \ - if (isInList_##LISTNAME(o)) \ - o->dlink_removeFrom_##LISTNAME(&m_dlinkhead_##LISTNAME.m_head); \ - } \ - typedef void (*RemoveAllProc_##LISTNAME)(OBJCLASS* o); \ - inline void removeAll_##LISTNAME(RemoveAllProc_##LISTNAME p = NULL) \ - { \ - while (m_dlinkhead_##LISTNAME.m_head) \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(m_dlinkhead_##LISTNAME.m_head), ("bogus head ptr"));\ - OBJCLASS *tmp = m_dlinkhead_##LISTNAME.m_head; \ - removeFrom_##LISTNAME(tmp); \ - if (p) (*p)(tmp); \ - } \ - } \ - inline void reverse_##LISTNAME() \ - { \ - OBJCLASS* cur = m_dlinkhead_##LISTNAME.m_head; \ - OBJCLASS* prev = NULL; \ - while (cur) \ - { \ - OBJCLASS* originalNext = cur->dlink_next_##LISTNAME(); \ - cur->dlink_swapLinks_##LISTNAME(); \ - prev = cur; \ - cur = originalNext; \ - } \ - m_dlinkhead_##LISTNAME.m_head = prev; \ - } \ -private: \ - /* a trick: init head to zero */ \ - struct DLINKHEAD_##LISTNAME \ - { \ - public: \ - OBJCLASS* m_head; \ - inline DLINKHEAD_##LISTNAME() : \ - m_head(0) { } \ - inline ~DLINKHEAD_##LISTNAME() \ - { DEBUG_ASSERTCRASH(!m_head,("destroying dlinkhead still in a list " #LISTNAME)); } \ - }; \ - DLINKHEAD_##LISTNAME m_dlinkhead_##LISTNAME; - -// ---------------------------------------------------------------------------------------------- -#define MAKE_DLINK(OBJCLASS, LISTNAME) \ -public: \ - OBJCLASS* dlink_prev_##LISTNAME() const { return m_dlink_##LISTNAME.m_prev; } \ - OBJCLASS* dlink_next_##LISTNAME() const { return m_dlink_##LISTNAME.m_next; } \ - void dlink_swapLinks_##LISTNAME() \ - { \ - OBJCLASS* originalNext = m_dlink_##LISTNAME.m_next; \ - m_dlink_##LISTNAME.m_next = m_dlink_##LISTNAME.m_prev; \ - m_dlink_##LISTNAME.m_prev = originalNext; \ - } \ - Bool dlink_isInList_##LISTNAME(OBJCLASS* const* pListHead) const \ - { \ - DEBUG_ASSERTCRASH(!BOGUSPTR(*pListHead) && !BOGUSPTR(m_dlink_##LISTNAME.m_next) && !BOGUSPTR(m_dlink_##LISTNAME.m_prev), ("bogus ptrs")); \ - return *pListHead == this || m_dlink_##LISTNAME.m_prev || m_dlink_##LISTNAME.m_next; \ - } \ - void dlink_prependTo_##LISTNAME(OBJCLASS** pListHead) \ - { \ - DEBUG_ASSERTCRASH(!dlink_isInList_##LISTNAME(pListHead), ("already in list " #LISTNAME)); \ - DEBUG_ASSERTCRASH(!BOGUSPTR(*pListHead) && !BOGUSPTR(m_dlink_##LISTNAME.m_next) && !BOGUSPTR(m_dlink_##LISTNAME.m_prev), ("bogus ptrs")); \ - m_dlink_##LISTNAME.m_next = *pListHead; \ - if (*pListHead) \ - (*pListHead)->m_dlink_##LISTNAME.m_prev = this; \ - *pListHead = this; \ - DEBUG_ASSERTCRASH(!BOGUSPTR(*pListHead) && !BOGUSPTR(m_dlink_##LISTNAME.m_next) && !BOGUSPTR(m_dlink_##LISTNAME.m_prev), ("bogus ptrs")); \ - } \ - void dlink_removeFrom_##LISTNAME(OBJCLASS** pListHead) \ - { \ - DEBUG_ASSERTCRASH(dlink_isInList_##LISTNAME(pListHead), ("not in list" #LISTNAME)); \ - DEBUG_ASSERTCRASH(!BOGUSPTR(*pListHead) && !BOGUSPTR(m_dlink_##LISTNAME.m_next) && !BOGUSPTR(m_dlink_##LISTNAME.m_prev), ("bogus ptrs")); \ - if (m_dlink_##LISTNAME.m_next) \ - m_dlink_##LISTNAME.m_next->m_dlink_##LISTNAME.m_prev = m_dlink_##LISTNAME.m_prev; \ - if (m_dlink_##LISTNAME.m_prev) \ - m_dlink_##LISTNAME.m_prev->m_dlink_##LISTNAME.m_next = m_dlink_##LISTNAME.m_next; \ - else \ - *pListHead = m_dlink_##LISTNAME.m_next; \ - m_dlink_##LISTNAME.m_prev = 0; \ - m_dlink_##LISTNAME.m_next = 0; \ - DEBUG_ASSERTCRASH(!BOGUSPTR(*pListHead) && !BOGUSPTR(m_dlink_##LISTNAME.m_next) && !BOGUSPTR(m_dlink_##LISTNAME.m_prev), ("bogus ptrs")); \ - } \ -private: \ - /* a trick: init links to zero */ \ - struct DLINK_##LISTNAME \ - { \ - public: \ - OBJCLASS* m_prev; \ - OBJCLASS* m_next; \ - inline DLINK_##LISTNAME() : \ - m_prev(0), m_next(0) { } \ - inline ~DLINK_##LISTNAME() \ - { DEBUG_ASSERTCRASH(!m_prev && !m_next,("destroying dlink still in a list " #LISTNAME)); } \ - }; \ - DLINK_##LISTNAME m_dlink_##LISTNAME; - -// ------------------------------------------------------------------------ -// this is the weird C++ syntax for "call pointer-to-member-function"... see C++ FAQ LITE for details. -#define callMemberFunction(object,ptrToMember) ((object).*(ptrToMember)) - -// ------------------------------------------------------------------------ -template -class DLINK_ITERATOR -{ -public: - // this is the weird C++ syntax for "pointer-to-member-function" - typedef OBJCLASS* (OBJCLASS::*GetNextFunc)() const; -private: - OBJCLASS* m_cur; - GetNextFunc m_getNextFunc; // this is the weird C++ syntax for "pointer-to-member-function" -public: - DLINK_ITERATOR(OBJCLASS* cur, GetNextFunc getNextFunc) : m_cur(cur), m_getNextFunc(getNextFunc) - { - } - - void advance() - { - if (m_cur) - m_cur = callMemberFunction(*m_cur, m_getNextFunc)(); - } - - Bool done() const - { - return m_cur == NULL; - } - - OBJCLASS* cur() const - { - return m_cur; - } - -}; - -// ------------------------------------------------------------------------ - -enum WhichTurretType CPP_11(: Int) -{ - TURRET_INVALID = -1, - - TURRET_MAIN = 0, - TURRET_ALT, - - MAX_TURRETS -}; - -// ------------------------------------------------------------------------ -// 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); - -// ------------------------------------------------------------------------ -// this returns the difference between a1 and a2, normalized. -inline Real stdAngleDiff(Real a1, Real a2) -{ - return normalizeAngle(a1 - a2); -} - -// ------------------------------------------------------------------------ -// NOTE NOTE NOTE: Keep TheRelationShipNames in sync with this enum -enum Relationship CPP_11(: Int) -{ - ENEMIES, - NEUTRAL, - ALLIES, - - RELATIONSHIP_COUNT -}; - - -// TheRelationShipNames is defined in Common/GameCommon.cpp -extern const char *const TheRelationshipNames[]; diff --git a/Generals/Code/GameEngine/Include/Common/GameState.h b/Generals/Code/GameEngine/Include/Common/GameState.h index 5259cc99dab..bcdcc7edd25 100644 --- a/Generals/Code/GameEngine/Include/Common/GameState.h +++ b/Generals/Code/GameEngine/Include/Common/GameState.h @@ -165,7 +165,7 @@ class GameState : public SubsystemInterface, SaveGameInfo *getSaveGameInfo( void ) { return &m_gameInfo; } // snapshot interaction - void addPostProcessSnapshot( Snapshot *snapshot ); ///< add snapshot to post process laod + void addPostProcessSnapshot( Snapshot *snapshot ); ///< add snapshot to post process load // manipulating files Bool doesSaveGameExist( AsciiString filename ); ///< does the save file exist diff --git a/Generals/Code/GameEngine/Include/Common/GameStateMap.h b/Generals/Code/GameEngine/Include/Common/GameStateMap.h index bbfad135a5c..b615599901d 100644 --- a/Generals/Code/GameEngine/Include/Common/GameStateMap.h +++ b/Generals/Code/GameEngine/Include/Common/GameStateMap.h @@ -29,7 +29,7 @@ #pragma once -// INLCUDES /////////////////////////////////////////////////////////////////////////////////////// +// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// #include "Common/Snapshot.h" #include "Common/SubsystemInterface.h" diff --git a/Generals/Code/GameEngine/Include/Common/GameType.h b/Generals/Code/GameEngine/Include/Common/GameType.h deleted file mode 100644 index 23a9a129281..00000000000 --- a/Generals/Code/GameEngine/Include/Common/GameType.h +++ /dev/null @@ -1,191 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// GameType.h -// Basic data types needed for the game engine. This is an extension of BaseType.h. -// Author: Michael S. Booth, April 2001 - -#pragma once - -#include "Lib/BaseType.h" - -// the default size of the world map -#define DEFAULT_WORLD_WIDTH 64 -#define DEFAULT_WORLD_HEIGHT 64 - -/// A unique, generic "identifier" used to access Objects. -enum ObjectID CPP_11(: Int) -{ - INVALID_ID = 0, - FORCE_OBJECTID_TO_LONG_SIZE = 0x7ffffff -}; - -/// A unique, generic "identifier" used to access Drawables. -enum DrawableID CPP_11(: Int) -{ - INVALID_DRAWABLE_ID = 0, - FORCE_DRAWABLEID_TO_LONG_SIZE = 0x7ffffff -}; - -/// A unique, generic "identifier" used to identify player specified formations. -enum FormationID CPP_11(: Int) -{ - NO_FORMATION_ID = 0, // Unit is not a member of any formation - FORCE_FORMATIONID_TO_LONG_SIZE = 0x7ffffff -}; - -#define INVALID_ANGLE -100.0f - -class INI; - -//------------------------------------------------------------------------------------------------- -/** The time of day enumeration, keep in sync with TimeOfDayNames[] */ -//------------------------------------------------------------------------------------------------- -enum TimeOfDay CPP_11(: Int) -{ - TIME_OF_DAY_INVALID, - - TIME_OF_DAY_MORNING, - TIME_OF_DAY_AFTERNOON, - TIME_OF_DAY_EVENING, - TIME_OF_DAY_NIGHT, - - TIME_OF_DAY_COUNT, - TIME_OF_DAY_FIRST = TIME_OF_DAY_MORNING, -}; - -extern const char *const TimeOfDayNames[]; -// defined in Common/GameType.cpp - -//------------------------------------------------------------------------------------------------- -enum Weather CPP_11(: Int) -{ - WEATHER_NORMAL = 0, - WEATHER_SNOWY = 1, - - WEATHER_COUNT -}; - -extern const char *const WeatherNames[]; - -enum Scorches CPP_11(: Int) -{ - SCORCH_1 = 0, - SCORCH_2 = 1, - SCORCH_3 = 2, - SCORCH_4 = 3, - SHADOW_SCORCH = 4, -/* SCORCH_6 = 5, - SCORCH_7 = 6, - SCORCH_8 = 7, - - CRATER_1 = 8, - CRATER_2 = 9, - CRATER_3 = 10, - CRATER_4 = 11, - CRATER_5 = 12, - CRATER_6 = 13, - CRATER_7 = 14, - CRATER_8 = 15, - - - MISC_DECAL_1 = 16, - MISC_DECAL_2 = 17, - MISC_DECAL_3 = 18, - MISC_DECAL_4 = 19, - MISC_DECAL_5 = 20, - MISC_DECAL_6 = 21, - MISC_DECAL_7 = 22, - MISC_DECAL_8 = 23, - - MISC_DECAL_9 = 24, - MISC_DECAL_10 = 25, - MISC_DECAL_11 = 26, - MISC_DECAL_12 = 27, - MISC_DECAL_13 = 28, - MISC_DECAL_14 = 29, - MISC_DECAL_15 = 30, - MISC_DECAL_16 = 31, - - MISC_DECAL_17 = 32, - MISC_DECAL_18 = 33, - MISC_DECAL_19 = 34, - MISC_DECAL_20 = 35, - MISC_DECAL_21 = 36, - MISC_DECAL_22 = 37, - MISC_DECAL_23 = 38, - MISC_DECAL_24 = 39, - - MISC_DECAL_25 = 40, - MISC_DECAL_26 = 41, - MISC_DECAL_27 = 42, - MISC_DECAL_28 = 43, - MISC_DECAL_29 = 44, - MISC_DECAL_30 = 45, - MISC_DECAL_31 = 46, - MISC_DECAL_32 = 47, - - MISC_DECAL_33 = 48, - MISC_DECAL_34 = 49, - MISC_DECAL_35 = 50, - MISC_DECAL_36 = 51, - MISC_DECAL_37 = 52, - MISC_DECAL_38 = 53, - MISC_DECAL_39 = 54, - MISC_DECAL_40 = 55, - - MISC_DECAL_41 = 56, - MISC_DECAL_42 = 57, - MISC_DECAL_43 = 58, - MISC_DECAL_44 = 59, - MISC_DECAL_45 = 60, - MISC_DECAL_46 = 61, - MISC_DECAL_47 = 62, - MISC_DECAL_48 = 63, -*/ - SCORCH_COUNT -}; - -//------------------------------------------------------------------------------------------------- -enum WeaponSlotType CPP_11(: Int) -{ - PRIMARY_WEAPON = 0, - SECONDARY_WEAPON, - TERTIARY_WEAPON, - - WEAPONSLOT_COUNT -}; - -//------------------------------------------------------------------------------------------------- -// Pathfind layers - ground is the first layer, each bridge is another. jba. -// Layer 1 is the ground. -// Layer 2 is the top layer - bridge if one is present, ground otherwise. -// Layer 2 - LAYER_LAST -1 are bridges. -// Layer_WALL is a special "wall" layer for letting units run aroound on top of a wall -// made of structures. -// Note that the bridges just index in the pathfinder, so you don't actually -// have a LAYER_BRIDGE_1 enum value. -enum PathfindLayerEnum CPP_11(: Int) {LAYER_INVALID = 0, LAYER_GROUND = 1, LAYER_WALL = 15, LAYER_LAST=15}; - -//------------------------------------------------------------------------------------------------- diff --git a/Generals/Code/GameEngine/Include/Common/Geometry.h b/Generals/Code/GameEngine/Include/Common/Geometry.h index 35930f6fa19..a1b2809103c 100644 --- a/Generals/Code/GameEngine/Include/Common/Geometry.h +++ b/Generals/Code/GameEngine/Include/Common/Geometry.h @@ -59,7 +59,7 @@ static const char *const GeometryNames[] = "SPHERE", "CYLINDER", "BOX", - NULL + nullptr }; static_assert(ARRAY_SIZE(GeometryNames) == GEOMETRY_NUM_TYPES + 1, "Incorrect array size"); #endif // end DEFINE_GEOMETRY_NAMES diff --git a/Generals/Code/GameEngine/Include/Common/GlobalData.h b/Generals/Code/GameEngine/Include/Common/GlobalData.h index cb7c0d1dda5..401c19cd1f1 100644 --- a/Generals/Code/GameEngine/Include/Common/GlobalData.h +++ b/Generals/Code/GameEngine/Include/Common/GlobalData.h @@ -110,6 +110,7 @@ class GlobalData : public SubsystemInterface Bool m_useTrees; Bool m_useTreeSway; Bool m_useDrawModuleLOD; + Bool m_useHeatEffects; Bool m_useFpsLimit; Bool m_dumpAssetUsage; Int m_framesPerSecondLimit; @@ -138,6 +139,8 @@ class GlobalData : public SubsystemInterface Bool m_enableStaticLOD; Int m_terrainLODTargetTimeMS; Bool m_useAlternateMouse; + Bool m_clientRetaliationModeEnabled; + Bool m_doubleClickAttackMove; Bool m_rightMouseAlwaysScrolls; Bool m_useWaterPlane; Bool m_useCloudPlane; @@ -280,6 +283,8 @@ class GlobalData : public SubsystemInterface #ifdef DUMP_PERF_STATS Bool m_dumpPerformanceStatistics; + Bool m_dumpStatsAtInterval;///< should I automatically dump stats every N frames + Int m_statsInterval; ///< if so, how many is N? #endif Bool m_forceBenchmark; ///. -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: INI.h //////////////////////////////////////////////////////////////////////////////////// -// Author: Colin Day, November 2001 -// Desc: INI Reader -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -// INCLUDES /////////////////////////////////////////////////////////////////////////////////////// -#include // for offsetof, which we don't use but everyone who includes us does -#include "Common/STLTypedefs.h" -#include "Common/AsciiString.h" -#include "Common/GameCommon.h" - -//------------------------------------------------------------------------------------------------- -class INI; -class Xfer; -class File; -enum ScienceType CPP_11(: Int); - -//------------------------------------------------------------------------------------------------- -/** These control the behavior of loading the INI data into items */ -//------------------------------------------------------------------------------------------------- -enum INILoadType CPP_11(: Int) -{ - INI_LOAD_INVALID, ///< invalid load type - INI_LOAD_OVERWRITE, ///< create new or load *over* existing data instance - INI_LOAD_CREATE_OVERRIDES, ///< create new or load into *new* override data instance - INI_LOAD_MULTIFILE ///< create new or continue loading into existing data instance. -}; - -//------------------------------------------------------------------------------------------------- -/** INI constant defines */ -//------------------------------------------------------------------------------------------------- -enum -{ - INI_MAX_CHARS_PER_LINE = 1028, ///< max characters per line entry in any ini file -}; - -//------------------------------------------------------------------------------------------------- -/** Status return codes for the INI reader */ -//------------------------------------------------------------------------------------------------- -enum -{ - // we map all of these to the same "real" error code, because - // we generally don't care why it failed; but since the code distinguishes, - // I didn't want to wipe out that intelligence. if we ever need to distinguish - // failure modes at runtime, just put in real values for these. - INI_CANT_SEARCH_DIR = ERROR_BAD_INI, - INI_INVALID_DIRECTORY = ERROR_BAD_INI, - INI_INVALID_PARAMS = ERROR_BAD_INI, - INI_INVALID_NAME_LIST = ERROR_BAD_INI, - INI_INVALID_DATA = ERROR_BAD_INI, - INI_MISSING_END_TOKEN = ERROR_BAD_INI, - INI_UNKNOWN_TOKEN = ERROR_BAD_INI, - INI_BUFFER_TOO_SMALL = ERROR_BAD_INI, - INI_FILE_NOT_OPEN = ERROR_BAD_INI, - INI_FILE_ALREADY_OPEN = ERROR_BAD_INI, - INI_CANT_OPEN_FILE = ERROR_BAD_INI, - INI_UNKNOWN_ERROR = ERROR_BAD_INI, - INI_END_OF_FILE = ERROR_BAD_INI -}; - -//------------------------------------------------------------------------------------------------- -/** 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) - * 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* const ConstCharPtr; -typedef ConstCharPtr* ConstCharPtrArray; - -//------------------------------------------------------------------------------------------------- -struct LookupListRec -{ - const char* name; - Int value; -}; -typedef const LookupListRec *ConstLookupListRecArray; - -//------------------------------------------------------------------------------------------------- -/** Parse tables for all fields of each data block are created using these */ -//------------------------------------------------------------------------------------------------- -struct FieldParse -{ - const char* token; ///< token of the field - INIFieldParseProc parse; ///< the parse function - const void* userData; ///< field-specific data - Int offset; ///< offset to data field - - void set(const char* t, INIFieldParseProc p, const void* u, Int o) - { - token = t; - parse = p; - userData = u; - offset = o; - } -}; - -//------------------------------------------------------------------------------------------------- -class MultiIniFieldParse -{ -private: - enum { MAX_MULTI_FIELDS = 16 }; - - const FieldParse* m_fieldParse[MAX_MULTI_FIELDS]; - UnsignedInt m_extraOffset[MAX_MULTI_FIELDS]; - Int m_count; - -public: - MultiIniFieldParse() : m_count(0) - { - for(Int i = 0; i < MAX_MULTI_FIELDS; i++) - m_extraOffset[i] = 0; - } - - void add(const FieldParse* f, UnsignedInt e = 0); - - 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]; } -}; - -//------------------------------------------------------------------------------------------------- -/** Function typedef for parsing INI types blocks */ -//------------------------------------------------------------------------------------------------- -typedef void (*INIBlockParse)( INI *ini ); -typedef void (*BuildMultiIniFieldProc)(MultiIniFieldParse& p); - -//------------------------------------------------------------------------------------------------- -/** INI Reader interface */ -//------------------------------------------------------------------------------------------------- -class INI -{ - -public: - - INI(); - ~INI(); - - // 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 ); - - // data type parsing (the highest level of what type of thing we're parsing) - static void parseObjectDefinition( INI *ini ); - static void parseObjectReskinDefinition( INI *ini ); - static void parseWeaponTemplateDefinition( INI *ini ); - static void parseScienceDefinition( INI *ini ); - static void parseRankDefinition( INI *ini ); - static void parseCrateTemplateDefinition( INI *ini ); - static void parseLocomotorTemplateDefinition( INI *ini ); - static void parseLanguageDefinition( INI *ini ); - static void parsePlayerTemplateDefinition( INI *ini ); - static void parseGameDataDefinition( INI *ini ); - static void parseMapDataDefinition( INI *ini ); - static void parseAnim2DDefinition( INI *ini ); - static void parseAudioEventDefinition( INI *ini ); - static void parseDialogDefinition( INI *ini ); - static void parseMusicTrackDefinition( INI *ini ); - static void parseWebpageURLDefinition( INI *ini ); - static void parseHeaderTemplateDefinition( INI *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 ); - static void parseDrawGroupNumberDefinition( INI *ini ); - static void parseTerrainDefinition( INI *ini ); - static void parseTerrainRoadDefinition( INI *ini ); - static void parseTerrainBridgeDefinition( INI *ini ); - static void parseMetaMapDefinition( INI *ini ); - static void parseFXListDefinition( INI *ini ); - static void parseObjectCreationListDefinition( INI* ini ); - static void parseMultiplayerSettingsDefinition( INI* ini ); - static void parseMultiplayerColorDefinition( INI* ini ); - static void parseOnlineChatColorDefinition( INI* ini ); - static void parseMapCacheDefinition( INI* ini ); - static void parseVideoDefinition( INI* ini ); - static void parseCommandButtonDefinition( INI *ini ); - static void parseCommandSetDefinition( INI *ini ); - static void parseUpgradeDefinition( INI *ini ); - static void parseMouseDefinition( INI* ini ); - static void parseMouseCursorDefinition( INI* ini ); - static void parseAIDataDefinition( INI *ini ); - static void parseSpecialPowerDefinition( INI *ini ); - static void parseInGameUIDefinition( INI *ini ); - static void parseControlBarSchemeDefinition( INI *ini ); - static void parseControlBarResizerDefinition( INI *ini ); - static void parseShellMenuSchemeDefinition( INI *ini ); - static void parseCampaignDefinition( INI *ini ); - static void parseAudioSettingsDefinition( INI *ini ); - static void parseMiscAudio( INI *ini ); - static void parseStaticGameLODDefinition( INI *ini); - static void parseDynamicGameLODDefinition( INI *ini); - static void parseStaticGameLODLevel( INI* ini, void * , void *store, const void*); - static void parseDynamicGameLODLevel( INI* ini, void * , void *store, const void*); - static void parseLODPreset( INI* ini); - static void parseBenchProfile( INI* ini); - static void parseEvaEvent( INI* ini ); - static void parseCredits( INI* ini ); - static void parseWindowTransitions( INI* ini ); - - - 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 ); - void initFromINIMultiProc( void *what, BuildMultiIniFieldProc proc ); - - static void parseUnsignedByte( INI *ini, void *instance, void *store, const void* userData ); - static void parseShort( INI *ini, void *instance, void *store, const void* userData ); - static void parseUnsignedShort( INI *ini, void *instance, void *store, const void* userData ); - static void parseInt( INI *ini, void *instance, void *store, const void* userData ); - static void parseUnsignedInt( INI *ini, void *instance, void *store, const void* userData ); - static void parseReal( INI *ini, void *instance, void *store, const void* userData ); - static void parsePositiveNonZeroReal( INI *ini, void *instance, void *store, const void* userData ); - static void parseBool( INI *ini, void *instance, void *store, const void* userData ); - static void parseBitInInt32( INI *ini, void *instance, void *store, const void* userData ); - static void parseAsciiString( INI *ini, void *instance, void *store, const void* userData ); - static void parseQuotedAsciiString( INI *ini, void *instance, void *store, const void* userData ); - static void parseAsciiStringVector( INI *ini, void *instance, void *store, const void* userData ); - static void parseAsciiStringVectorAppend( INI *ini, void *instance, void *store, const void* userData ); - static void parseAndTranslateLabel( INI *ini, void *instance, void *store, const void* userData ); - static void parseMappedImage( INI *ini, void *instance, void *store, const void *userData ); - static void parseAnim2DTemplate( INI *ini, void *instance, void *store, const void *userData ); - static void parsePercentToReal( INI *ini, void *instance, void *store, const void* userData ); - static void parseRGBColor( INI *ini, void *instance, void *store, const void* userData ); - static void parseRGBAColorInt( INI *ini, void *instance, void *store, const void* userData ); - static void parseColorInt( INI *ini, void *instance, void *store, const void* userData ); - static void parseCoord3D( INI *ini, void *instance, void *store, const void* userData ); - static void parseCoord2D( INI *ini, void *instance, void *store, const void *userData ); - static void parseICoord2D( INI *ini, void *instance, void *store, const void *userData ); - static void parseDynamicAudioEventRTS( INI *ini, void *instance, void *store, const void* userData ); - static void parseAudioEventRTS( INI *ini, void *instance, void *store, const void* userData ); - static void parseFXList( INI *ini, void *instance, void *store, const void* userData ); - static void parseParticleSystemTemplate( INI *ini, void *instance, void *store, const void *userData ); - static void parseObjectCreationList( INI *ini, void *instance, void *store, const void* userData ); - static void parseSpecialPowerTemplate( INI *ini, void *instance, void *store, const void *userData ); - static void parseUpgradeTemplate( INI *ini, void *instance, void *store, const void *userData ); - static void parseScience( INI *ini, void *instance, void *store, const void *userData ); - static void parseScienceVector( INI *ini, void *instance, void *store, const void *userData ); - static void parseGameClientRandomVariable( INI* ini, void *instance, void *store, const void* userData ); - static void parseBitString8( INI *ini, void *instance, void *store, const void* userData ); - static void parseBitString32( INI *ini, void *instance, void *store, const void* userData ); - static void parseByteSizedIndexList( INI *ini, void *instance, void *store, const void* userData ); - static void parseIndexList( INI *ini, void *instance, void *store, const void* userData ); - static void parseLookupList( INI *ini, void *instance, void *store, const void* userData ); - static void parseThingTemplate( INI *ini, void *instance, void *store, const void* userData ); - static void parseArmorTemplate( INI *ini, void *instance, void *store, const void* userData ); - static void parseDamageFX( INI *ini, void *instance, void *store, const void* userData ); - static void parseWeaponTemplate( INI *ini, void *instance, void *store, const void* userData ); - // parse a duration in msec and convert to duration in frames - static void parseDurationReal( INI *ini, void *instance, void *store, const void* userData ); - // parse a duration in msec and convert to duration in integral number of frames, (unsignedint) rounding UP - static void parseDurationUnsignedInt( INI *ini, void *instance, void *store, const void* userData ); - static void parseDurationUnsignedShort( INI *ini, void *instance, void *store, const void *userData ); - // parse acceleration in (dist/sec) and convert to (dist/frame) - static void parseVelocityReal( INI *ini, void *instance, void *store, const void* userData ); - // parse acceleration in (dist/sec^2) and convert to (dist/frame^2) - static void parseAccelerationReal( INI *ini, void *instance, void *store, const void* userData ); - // parse angle in degrees and convert to radians - static void parseAngleReal( INI *ini, void *instance, void *store, const void *userData ); - // note that this parses in degrees/sec, and converts to rads/frame! - static void parseAngularVelocityReal( INI *ini, void *instance, void *store, const void *userData ); - static void parseDamageTypeFlags(INI* ini, void* instance, void* store, const void* userData); - static void parseDeathTypeFlags(INI* ini, void* instance, void* store, const void* userData); - static void parseVeterancyLevelFlags(INI* ini, void* instance, void* store, const void* userData); - static void parseSoundsList( INI* ini, void *instance, void *store, const void* /*userData*/ ); - - - /** - return the next token. if seps is null (or omitted), the standard seps are used. - - this will *never* return null; if there are no more tokens, an exception will be thrown. - */ - const char* getNextToken(const char* seps = NULL); - - /** - just like getNextToken(), except that null is returned if no more tokens are present - (rather than throwing an exception). usually you should call getNextToken(), - but for some cases this is handier (ie, parsing a variable-length number of tokens). - */ - const char* getNextTokenOrNull(const char* seps = NULL); - - /** - This is called when the next thing you expect is something like: - - Tag:value - - pass "Tag" (without the colon) for 'expected', and you will have the 'value' - token returned. - - If "Tag" is not the next token, an error is thrown. - */ - const char* getNextSubToken(const char* expected); - - /** - return the next ascii string. this is usually the same the result of getNextToken(), - except that it allows for quote-delimited strings (eg, "foo bar"), so you can - get strings with spaces, and/or empty strings. - */ - AsciiString getNextAsciiString(); - AsciiString getNextQuotedAsciiString(); //fixed version of above. We can't fix the regular one for fear of breaking existing code. :-( - - /** - utility routine that does a sscanf() on the string to get the Science, and throws - an exception if not of the right form. - */ - static ScienceType scanScience(const char* token); - - /** - utility routine that does a sscanf() on the string to get the int, and throws - an exception if not of the right form. - */ - static Int scanInt(const char* token); - - /** - utility routine that does a sscanf() on the string to get the unsigned int, and throws - an exception if not of the right form. - */ - static UnsignedInt scanUnsignedInt(const char* token); - - /** - utility routine that does a sscanf() on the string to get the real, and throws - an exception if not of the right form. - */ - static Real scanReal(const char* token); - static Real scanPercentToReal(const char* token); - - static Int scanIndexList(const char* token, ConstCharPtrArray nameList); - static Int scanLookupList(const char* token, ConstLookupListRecArray lookupList); - - static Bool scanBool(const char* token); - -protected: - - static Bool isValidINIFilename( const char *filename ); ///< is this a valid .ini filename - - void prepFile( AsciiString filename, INILoadType loadType ); - void unPrepFile(); - - void readLine( void ); - -// FILE *m_file; ///< file pointer of file currently loading - File *m_file; ///< file pointer of file currently loading - AsciiString m_filename; ///< filename of file currently loading - INILoadType m_loadType; ///< load time for current file - UnsignedInt m_lineNum; ///< current line number that's been read - char m_buffer[ INI_MAX_CHARS_PER_LINE ]; ///< buffer to read file contents into - const char *m_seps; ///< for strtok parsing - const char *m_sepsPercent; ///< m_seps with percent delimiter as well - const char *m_sepsColon; ///< m_seps with colon delimiter as well - const char *m_sepsQuote; ///< token to represent a quoted ascii string - const char *m_blockEndToken; ///< token to represent end of data block - Bool m_endOfFile; ///< TRUE when we've hit EOF -#ifdef DEBUG_CRASHING - char m_curBlockStart[ INI_MAX_CHARS_PER_LINE ]; ///< first line of cur block -#endif -}; diff --git a/Generals/Code/GameEngine/Include/Common/INIException.h b/Generals/Code/GameEngine/Include/Common/INIException.h index 5afca81bc13..88300bc02bd 100644 --- a/Generals/Code/GameEngine/Include/Common/INIException.h +++ b/Generals/Code/GameEngine/Include/Common/INIException.h @@ -35,7 +35,7 @@ class INIException public: char *mFailureMessage; - INIException(const char* errorMessage) : mFailureMessage(NULL) + INIException(const char* errorMessage) : mFailureMessage(nullptr) { if (errorMessage) { mFailureMessage = new char[strlen(errorMessage) + 1]; diff --git a/Generals/Code/GameEngine/Include/Common/KindOf.h b/Generals/Code/GameEngine/Include/Common/KindOf.h index 8dbec5da7cc..caa345ee57d 100644 --- a/Generals/Code/GameEngine/Include/Common/KindOf.h +++ b/Generals/Code/GameEngine/Include/Common/KindOf.h @@ -93,12 +93,12 @@ enum KindOfType CPP_11(: Int) KINDOF_CAN_SURRENDER, ///< object that can surrender #endif KINDOF_CAN_BE_REPULSED, ///< object that runs away from a repulsor object. - KINDOF_MOB_NEXUS, ///< object that cooyrdinates the members of a mob (i.e. GLAInfantryAngryMob) + KINDOF_MOB_NEXUS, ///< object that coordinates the members of a mob (i.e. GLAInfantryAngryMob) KINDOF_IGNORED_IN_GUI, ///< object that is the members of a mob (i.e. GLAInfantryAngryMob) KINDOF_CRATE, ///< a bonus crate KINDOF_CAPTURABLE, ///< is "capturable" even if not an enemy (should generally be used only for structures, eg, Tech bldgs) KINDOF_CLEARED_BY_BUILD, ///< is auto-cleared from the map when built over via construction - KINDOF_SMALL_MISSILE, ///< Missile object: ONLY USED FOR ANTI-MISSILE TARGETTING PURPOSES! Keep using PROJECTILE! + KINDOF_SMALL_MISSILE, ///< Missile object: ONLY USED FOR ANTI-MISSILE TARGETING PURPOSES! Keep using PROJECTILE! KINDOF_ALWAYS_VISIBLE, ///< is never obscured by fog of war or shroud. mostly for UI feedback objects. KINDOF_UNATTACKABLE, ///< You cannot target this thing, it probably doesn't really exist KINDOF_MINE, ///< a landmine. (possibly also extend to Col. Burton timed charges?) diff --git a/Generals/Code/GameEngine/Include/Common/List.h b/Generals/Code/GameEngine/Include/Common/List.h index ef47c1ee819..3a48782adc6 100644 --- a/Generals/Code/GameEngine/Include/Common/List.h +++ b/Generals/Code/GameEngine/Include/Common/List.h @@ -86,8 +86,8 @@ class LListNode void append( LListNode *new_node ); ///< Appends new node after itself LListNode* next( void ); ///< Returns next node in list LListNode* prev( void ); ///< Returns previous node in list - LListNode* loopNext( void ); ///< Returns next node in list, warpping round to start of list if nessecary - LListNode* loopPrev( void ); ///< Returns previous node in list, wrapping round to end of list if nessecary + LListNode* loopNext( void ); ///< Returns next node in list, wrapping round to start of list if necessary + LListNode* loopPrev( void ); ///< Returns previous node in list, wrapping round to end of list if necessary Bool inList( void ); ///< Returns whether or not node in list Bool isHead( void ); ///< Returns whether or not this node is the head/tail node Int priority( void ); ///< Returns node's priority diff --git a/Generals/Code/GameEngine/Include/Common/MessageStream.h b/Generals/Code/GameEngine/Include/Common/MessageStream.h index 8c5e6c188eb..25413a73f80 100644 --- a/Generals/Code/GameEngine/Include/Common/MessageStream.h +++ b/Generals/Code/GameEngine/Include/Common/MessageStream.h @@ -103,7 +103,7 @@ class GameMessage : public MemoryPoolObject /// The various messages which can be sent in a MessageStream /// @todo Replace this hardcoded enum with a generalized system that can be easily changed and updated - /** @todo Because the Client will run faster than Logic, we'll need "superceding" messages for events + /** @todo Because the Client will run faster than Logic, we'll need "superseding" messages for events such as mouse movements so we only send the latest one over the net */ /** @todo Create two classes of message: raw input messages, and command messages. Raw input messages will be destroyed when they reach the end of the stream, whereas command messages will be @@ -213,7 +213,7 @@ class GameMessage : public MemoryPoolObject MSG_META_VIEW_TEAM8, ///< center view on given user-defined team (but do not affect selection) MSG_META_VIEW_TEAM9, ///< center view on given user-defined team (but do not affect selection) - MSG_META_SELECT_MATCHING_UNITS, ///< selects mathcing units, used for both on screen and across map + MSG_META_SELECT_MATCHING_UNITS, ///< selects matching units, used for both on screen and across map MSG_META_SELECT_NEXT_UNIT, ///< select 'next' unit MSG_META_SELECT_PREV_UNIT, ///< select 'prev' unit MSG_META_SELECT_NEXT_WORKER, ///< select 'next' worker @@ -522,7 +522,7 @@ class GameMessage : public MemoryPoolObject selecting what to build, selecting where to build it ... this construct message will start the actual build process */ - MSG_DOZER_CONSTRUCT_LINE, ///< Like MSG_CONSTRUCT, but for build procesess that occur in a line (like walls) + MSG_DOZER_CONSTRUCT_LINE, ///< Like MSG_CONSTRUCT, but for build processes that occur in a line (like walls) MSG_DOZER_CANCEL_CONSTRUCT, ///< cancel construction of a building MSG_SELL, ///< sell a structure MSG_EXIT, ///< WE want to exit from whatever WE are inside of @@ -741,7 +741,7 @@ class MessageStream : public GameMessageList { TranslatorData *m_next, *m_prev; ///< List links for list of translators TranslatorID m_id; ///< The unique ID of this translator - GameMessageTranslator *m_translator; ///< The translor's interface function + GameMessageTranslator *m_translator; ///< The translator's interface function UnsignedInt m_priority; ///< The priority level of this translator TranslatorData() : m_next(0), m_prev(0), m_id(0), m_translator(0), m_priority(0) diff --git a/Generals/Code/GameEngine/Include/Common/ModelState.h b/Generals/Code/GameEngine/Include/Common/ModelState.h index 5997dd8e2e1..b0eb182a2e0 100644 --- a/Generals/Code/GameEngine/Include/Common/ModelState.h +++ b/Generals/Code/GameEngine/Include/Common/ModelState.h @@ -54,7 +54,7 @@ YUCK, WHAT NOW -------------- - Let's represent the Model State with two dictinct pieces: + Let's represent the Model State with two distinct pieces: -- an "ActionState" piece, representing the mutually-exclusive states, which are almost always an action of some sort @@ -222,7 +222,6 @@ typedef BitFlags ModelConditionFlags; #define MAKE_MODELCONDITION_MASK3(k,a,b) ModelConditionFlags(ModelConditionFlags::kInit, (k), (a), (b)) #define MAKE_MODELCONDITION_MASK4(k,a,b,c) ModelConditionFlags(ModelConditionFlags::kInit, (k), (a), (b), (c)) #define MAKE_MODELCONDITION_MASK5(k,a,b,c,d) ModelConditionFlags(ModelConditionFlags::kInit, (k), (a), (b), (c), (d)) -#define MAKE_MODELCONDITION_MASK12(a,b,c,d,e,f,g,h,i,j,k,l) ModelConditionFlags(ModelConditionFlags::kInit, (a), (b), (c), (d), (e), (f), (g), (h), (i), (j), (k), (l)) //------------------------------------------------------------------------------------------------- diff --git a/Generals/Code/GameEngine/Include/Common/Module.h b/Generals/Code/GameEngine/Include/Common/Module.h index adc0e98e27f..e397cb16642 100644 --- a/Generals/Code/GameEngine/Include/Common/Module.h +++ b/Generals/Code/GameEngine/Include/Common/Module.h @@ -108,7 +108,7 @@ class ModuleData : public Snapshot virtual Bool isAiModuleData() const { return false; } // ugh, hack - virtual const W3DModelDrawModuleData* getAsW3DModelDrawModuleData() const { return NULL; } + virtual const W3DModelDrawModuleData* getAsW3DModelDrawModuleData() const { return nullptr; } virtual StaticGameLODLevel getMinimumRequiredGameLOD() const { return (StaticGameLODLevel)0;} static void buildFieldParse(MultiIniFieldParse& p) @@ -275,7 +275,7 @@ class ObjectModule : public Module //================================================================================================= //------------------------------------------------------------------------------------------------- -/** Module interface specific for Drawbles, this is really just to make a clear distinction +/** Module interface specific for Drawables, this is really just to make a clear distinction * between modules intended for use in objects and modules intended for use * in drawables */ //------------------------------------------------------------------------------------------------- diff --git a/Generals/Code/GameEngine/Include/Common/ModuleFactory.h b/Generals/Code/GameEngine/Include/Common/ModuleFactory.h index f3f4182f90f..ef48cfc5403 100644 --- a/Generals/Code/GameEngine/Include/Common/ModuleFactory.h +++ b/Generals/Code/GameEngine/Include/Common/ModuleFactory.h @@ -25,7 +25,7 @@ // FILE: ModuleFactory.h ////////////////////////////////////////////////////////////////////////// // Author: Colin Day, September 2001 // Desc: TheModuleFactory is where we actually instance modules for objects -// and drawbles. Those modules are things such as an UpdateModule +// and drawables. Those modules are things such as an UpdateModule // or DamageModule or DrawModule etc. // // TheModuleFactory will contain a list of ModuleTemplates, when we @@ -57,7 +57,7 @@ typedef Module *(*NewModuleProc)(Thing *thing, const ModuleData* moduleData); typedef ModuleData* (*NewModuleDataProc)(INI* ini); //------------------------------------------------------------------------------------------------- -/** We use TheModulyFactory to register classes that will be attached +/** We use TheModuleFactory to register classes that will be attached * to objects and drawables which will be executed or "called back" in the * correct situations ... such as Die, Damage, Update etc or just as * a place to store data specific to that type of thing */ @@ -91,7 +91,7 @@ class ModuleFactory : public SubsystemInterface, public Snapshot class ModuleTemplate { public: - ModuleTemplate() : m_createProc(NULL), m_createDataProc(NULL), m_whichInterfaces(0) + ModuleTemplate() : m_createProc(nullptr), m_createDataProc(nullptr), m_whichInterfaces(0) { } diff --git a/Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h b/Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h index 2662543140c..5a5ed8a3693 100644 --- a/Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h +++ b/Generals/Code/GameEngine/Include/Common/NameKeyGenerator.h @@ -66,7 +66,7 @@ class Bucket : public MemoryPoolObject AsciiString m_nameString; }; -inline Bucket::Bucket() : m_nextInSocket(NULL), m_key(NAMEKEY_INVALID) { } +inline Bucket::Bucket() : m_nextInSocket(nullptr), m_key(NAMEKEY_INVALID) { } inline Bucket::~Bucket() { } //------------------------------------------------------------------------------------------------- diff --git a/Generals/Code/GameEngine/Include/Common/Overridable.h b/Generals/Code/GameEngine/Include/Common/Overridable.h index f3951278843..98add739199 100644 --- a/Generals/Code/GameEngine/Include/Common/Overridable.h +++ b/Generals/Code/GameEngine/Include/Common/Overridable.h @@ -47,9 +47,9 @@ class Overridable : public MemoryPoolObject Bool m_isOverride; public: - Overridable() : m_nextOverride(NULL), m_isOverride(false) {} + Overridable() : m_nextOverride(nullptr), m_isOverride(false) {} - // return a constant version of m_nextOverride, which can be NULL if there is no + // return a constant version of m_nextOverride, which can be null if there is no // override const Overridable *getNextOverride( void ) const { @@ -99,14 +99,14 @@ class Overridable : public MemoryPoolObject m_isOverride = true; } - // used in factory reset() calls at the end of a game to clean up overrides. Can return NULL + // used in factory reset() calls at the end of a game to clean up overrides. Can return nullptr // if the first Overridable is itself an override Overridable *deleteOverrides( void ) { if ( m_isOverride ) { deleteInstance(this); - return NULL; + return nullptr; } else if ( m_nextOverride ) { diff --git a/Generals/Code/GameEngine/Include/Common/Override.h b/Generals/Code/GameEngine/Include/Common/Override.h index d89ee693241..90c9f3cc92d 100644 --- a/Generals/Code/GameEngine/Include/Common/Override.h +++ b/Generals/Code/GameEngine/Include/Common/Override.h @@ -49,8 +49,8 @@ template class OVERRIDE { public: - // Provide useful constructores to go from a T* to an OVERRIDE - OVERRIDE(const T *overridable = NULL); + // Provide useful constructors to go from a T* to an OVERRIDE + OVERRIDE(const T *overridable = nullptr); // Copy constructor OVERRIDE(OVERRIDE &overridable); // Operator= for copying from another OVERRIDE and T* @@ -107,7 +107,7 @@ template const T *OVERRIDE::operator->() const { if (!m_overridable) - return NULL; + return nullptr; return (T*) m_overridable->getFinalOverride(); } @@ -116,7 +116,7 @@ template const T *OVERRIDE::operator*() const { if (!m_overridable) - return NULL; + return nullptr; return (T*) m_overridable->getFinalOverride(); } diff --git a/Generals/Code/GameEngine/Include/Common/PerfTimer.h b/Generals/Code/GameEngine/Include/Common/PerfTimer.h index 071b35b3485..0b88b581394 100644 --- a/Generals/Code/GameEngine/Include/Common/PerfTimer.h +++ b/Generals/Code/GameEngine/Include/Common/PerfTimer.h @@ -85,7 +85,8 @@ __forceinline void GetPrecisionTimer(Int64* t) class PerfGather { public: - PerfGather( const char *identifier ); + // If net only (default), subtract perf timers running inside. [8/12/2003] + PerfGather( const char *identifier, Bool netOnly=true ); virtual ~PerfGather( ); __forceinline void startTimer(); @@ -126,6 +127,7 @@ class PerfGather PerfGather* m_next; PerfGather* m_prev; Bool m_ignore; + Bool m_netTimeOnly; }; //------------------------------------------------------------------------------------------------- @@ -138,7 +140,7 @@ void PerfGather::startTimer() //------------------------------------------------------------------------------------------------- void PerfGather::stopTimer() { - DEBUG_ASSERTCRASH(this != NULL, ("I am null, uh oh")); + DEBUG_ASSERTCRASH(this != nullptr, ("I am null, uh oh")); Int64 runTime; GetPrecisionTimer(&runTime); @@ -151,7 +153,7 @@ void PerfGather::stopTimer() ++m_callCount; #ifdef RTS_DEBUG - DEBUG_ASSERTCRASH(*m_activeHead != NULL, ("m_activeHead is null, uh oh")); + DEBUG_ASSERTCRASH(*m_activeHead != nullptr, ("m_activeHead is null, uh oh")); DEBUG_ASSERTCRASH(*m_activeHead == this, ("I am not the active timer, uh oh")); DEBUG_ASSERTCRASH(m_activeHead >= &m_active[0] && m_activeHead <= &m_active[MAX_ACTIVE_STACK-1], ("active under/over flow")); #endif @@ -161,7 +163,9 @@ void PerfGather::stopTimer() { // don't add the time it took for us to actually get the ticks (in startTimer) to our parent... (*m_activeHead)->m_runningTimeGross -= (s_stopStartOverhead); - (*m_activeHead)->m_runningTimeNet -= (runTime + s_stopStartOverhead); + if ((*m_activeHead)->m_netTimeOnly) { + (*m_activeHead)->m_runningTimeNet -= (runTime + s_stopStartOverhead); + } } } @@ -224,6 +228,7 @@ AutoPerfGatherIgnore::~AutoPerfGatherIgnore() } //------------------------------------------------------------------------------------------------- +#define DECLARE_TOTAL_PERF_TIMER(id) static PerfGather s_##id(#id, false); #define DECLARE_PERF_TIMER(id) static PerfGather s_##id(#id); #define USE_PERF_TIMER(id) AutoPerfGather a_##id(s_##id); #define IGNORE_PERF_TIMER(id) AutoPerfGatherIgnore a_##id(s_##id); @@ -308,6 +313,7 @@ extern void StatMetricsDisplay( DebugDisplayInterface *dd, void *, FILE *fp ); #else // PERF_TIMERS #define DECLARE_PERF_TIMER(id) + #define DECLARE_TOTAL_PERF_TIMER(id) #define USE_PERF_TIMER(id) #define IGNORE_PERF_TIMER(id) diff --git a/Generals/Code/GameEngine/Include/Common/Player.h b/Generals/Code/GameEngine/Include/Common/Player.h index 69327b447fa..3bcfa6d3502 100644 --- a/Generals/Code/GameEngine/Include/Common/Player.h +++ b/Generals/Code/GameEngine/Include/Common/Player.h @@ -102,7 +102,7 @@ static const char *const ScienceAvailabilityNames[] = "Available", "Disabled", "Hidden", - NULL + nullptr }; static_assert(ARRAY_SIZE(ScienceAvailabilityNames) == SCIENCE_AVAILABILITY_COUNT + 1, "Incorrect array size"); #endif // end DEFINE_SCIENCE_AVAILABILITY_NAMES @@ -158,7 +158,7 @@ class PlayerRelationMap : public MemoryPoolObject, PlayerRelationMap( void ); // virtual destructor provided by memory pool object - /** @todo I'm jsut wrappign this up in a nice snapshot object, we really should isolate + /** @todo I'm just wrapping this up in a nice snapshot object, we really should isolate * m_map from public access and make access methods for our operations */ PlayerRelationMapType m_map; @@ -289,15 +289,15 @@ class Player : public Snapshot Bool hasPrereqsForScience(ScienceType t) const; 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 hasUpgradeComplete( const UpgradeMaskType& testMask ) const; ///< does player have totally done and produced upgrade + const 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, UpgradeStatusType status ); ///< add upgrade, or update existing upgrade status - void removeUpgrade( const UpgradeTemplate *upgradeTemplate ); ///< remove thsi upgrade from us + void removeUpgrade( const UpgradeTemplate *upgradeTemplate ); ///< remove this upgrade from us /** find upgrade, NOTE, the upgrade may *NOT* be "complete" and therefore "active", it could be in production - This function is for actually retrieving the Upgrade. To test existance, use the fast bit testers hasUpgradeX() + This function is for actually retrieving the Upgrade. To test existence, use the fast bit testers hasUpgradeX() */ Upgrade *findUpgrade( const UpgradeTemplate *upgradeTemplate ); @@ -419,7 +419,7 @@ class Player : public Snapshot virtual void computeSuperweaponTarget(const SpecialPowerTemplate *power, Coord3D *pos, Int playerNdx, Real weaponRadius); ///< Calculates best pos for weapon given radius. - /// Get the enemy an ai player is currently focused on. NOTE - Can be NULL. + /// Get the enemy an ai player is currently focused on. NOTE - Can be nullptr. Player *getCurrentEnemy( void ); /// Is this player a skirmish ai player? @@ -434,7 +434,7 @@ class Player : public Snapshot /// Have the ai check for bridges. virtual void repairStructure(ObjectID structureID); - /// a structuer was just created, but is under construction + /// a structure was just created, but is under construction void onStructureCreated( Object *builder, Object *structure ); /// a structure that was under construction has become completed @@ -507,8 +507,8 @@ class Player : public Snapshot /** return this player's "default" team. */ - Team *getDefaultTeam() { DEBUG_ASSERTCRASH(m_defaultTeam!=NULL,("default team is null")); return m_defaultTeam; } - const Team *getDefaultTeam() const { DEBUG_ASSERTCRASH(m_defaultTeam!=NULL,("default team is null")); return m_defaultTeam; } + Team *getDefaultTeam() { DEBUG_ASSERTCRASH(m_defaultTeam!=nullptr,("default team is null")); return m_defaultTeam; } + const Team *getDefaultTeam() const { DEBUG_ASSERTCRASH(m_defaultTeam!=nullptr,("default team is null")); return m_defaultTeam; } void setBuildList(BuildListInfo *pBuildList); ///< sets the build list. BuildListInfo *getBuildList( void ) { return m_pBuildList; } ///< returns the build list. (build list might be modified by the solo AI) @@ -706,7 +706,7 @@ class Player : public Snapshot UnicodeString m_playerDisplayName; ///< This player's persistent name. Handicap m_handicap; ///< adjustment to varied capabilities (@todo: is this persistent or recalced each time?) - AsciiString m_playerName; ///< player's itnernal name 9for matching map objects) + AsciiString m_playerName; ///< player's internal name (for matching map objects) NameKeyType m_playerNameKey; ///< This player's internal name (for matching map objects) PlayerIndex m_playerIndex; ///< player unique index. AsciiString m_side; ///< the "side" this player is on @@ -733,7 +733,7 @@ class Player : public Snapshot AIPlayer* m_ai; ///< if PLAYER_COMPUTER, the entity that does the thinking Int m_mpStartIndex; ///< The player's starting index for multiplayer. ResourceGatheringManager* m_resourceGatheringManager; ///< Keeps track of all Supply Centers and Warehouses - TunnelTracker* m_tunnelSystem; ///< All TunnelContain buildings use this part of me for actual conatinment + TunnelTracker* m_tunnelSystem; ///< All TunnelContain buildings use this part of me for actual containment Team* m_defaultTeam; ///< our "default" team. ScienceVec m_sciences; ///< (SAVE) sciences that we know (either intrinsically or via later purchases) diff --git a/Generals/Code/GameEngine/Include/Common/PlayerList.h b/Generals/Code/GameEngine/Include/Common/PlayerList.h index 2f0362b4895..94db9062ccc 100644 --- a/Generals/Code/GameEngine/Include/Common/PlayerList.h +++ b/Generals/Code/GameEngine/Include/Common/PlayerList.h @@ -106,7 +106,7 @@ class PlayerList : public SubsystemInterface, all other players (this is so that everything can be associated with a nonnull Player, to simplify the universe). This will never return null. */ - Player *getNeutralPlayer() { DEBUG_ASSERTCRASH(m_players[0] != NULL, ("null neutral")); return m_players[0]; } + Player *getNeutralPlayer() { DEBUG_ASSERTCRASH(m_players[0] != nullptr, ("null neutral")); return m_players[0]; } /** return the Player with the given internal name, or null if none found. @@ -117,7 +117,7 @@ class PlayerList : public SubsystemInterface, Return the "local" player (ie, the human playing the game). This will never return null. */ - inline Player *getLocalPlayer() { DEBUG_ASSERTCRASH(m_local != NULL, ("null m_local")); return m_local; } + inline Player *getLocalPlayer() { DEBUG_ASSERTCRASH(m_local != nullptr, ("null m_local")); return m_local; } /** Set the local player. You cannot set it to null; if you pass null, you'll diff --git a/Generals/Code/GameEngine/Include/Common/PlayerTemplate.h b/Generals/Code/GameEngine/Include/Common/PlayerTemplate.h index 1caf4221674..f5c4964fecd 100644 --- a/Generals/Code/GameEngine/Include/Common/PlayerTemplate.h +++ b/Generals/Code/GameEngine/Include/Common/PlayerTemplate.h @@ -125,6 +125,7 @@ class PlayerTemplate AsciiString getLoadScreenMusic( void ) const {return m_loadScreenMusic; } + Bool isOldFaction( void ) const { return m_oldFaction; } static const FieldParse* getFieldParse(); @@ -162,6 +163,7 @@ class PlayerTemplate AsciiString m_tooltip; ///< The tooltip describing this player template Bool m_observer; Bool m_playableSide; + Bool m_oldFaction; ///< Faction existed in the original Generals Int m_intrinsicSPP; diff --git a/Generals/Code/GameEngine/Include/Common/Registry.h b/Generals/Code/GameEngine/Include/Common/Registry.h index 83ecb7dd24b..ec20865c8c4 100644 --- a/Generals/Code/GameEngine/Include/Common/Registry.h +++ b/Generals/Code/GameEngine/Include/Common/Registry.h @@ -23,13 +23,17 @@ //////////////////////////////////////////////////////////////////////////////// // Registry.h -// Simple interface for storing/retreiving registry values +// Simple interface for storing/retrieving registry values // Author: Matthew D. Campbell, December 2001 #pragma once #include +/** + * Get a string from the original Generals Registry + */ +Bool GetStringFromGeneralsRegistry(AsciiString path, AsciiString key, AsciiString& val); /** * Get a string from the registry */ diff --git a/Generals/Code/GameEngine/Include/Common/ResourceGatheringManager.h b/Generals/Code/GameEngine/Include/Common/ResourceGatheringManager.h index 437f6d2fdd3..ed79ff6c44b 100644 --- a/Generals/Code/GameEngine/Include/Common/ResourceGatheringManager.h +++ b/Generals/Code/GameEngine/Include/Common/ResourceGatheringManager.h @@ -50,8 +50,8 @@ class ResourceGatheringManager : public MemoryPoolObject, void addSupplyCenter( Object *newCenter ); ///< I captured or built a Supply Center, so record it void removeSupplyCenter( Object *oldCenter ); ///< Lost a supply center - void addSupplyWarehouse( Object *newWarehouse ); ///< Warehouse created, or this is starrt of game recording - void removeSupplyWarehouse( Object *oldWarehouse ); ///< Warehouse that doesn't replinish has run out of Supply + void addSupplyWarehouse( Object *newWarehouse ); ///< Warehouse created, or this is start of game recording + void removeSupplyWarehouse( Object *oldWarehouse ); ///< Warehouse that doesn't replenish has run out of Supply protected: diff --git a/Generals/Code/GameEngine/Include/Common/STLTypedefs.h b/Generals/Code/GameEngine/Include/Common/STLTypedefs.h deleted file mode 100644 index 484b3f33e80..00000000000 --- a/Generals/Code/GameEngine/Include/Common/STLTypedefs.h +++ /dev/null @@ -1,297 +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: STLTypedefs.h //////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -// -// Westwood Studios Pacific. -// -// Confidential Information -// Copyright (C) 2001 - All Rights Reserved -// -//----------------------------------------------------------------------------- -// -// Project: RTS3 -// -// File name: STLTypedefs.h -// -// Created: John McDonald -// -// Desc: @todo -// -//----------------------------------------------------------------------------- - -#pragma once - -//----------------------------------------------------------------------------- -// srj sez: this must come first, first, first. -#define _STLP_USE_NEWALLOC 1 -//#define _STLP_USE_CUSTOM_NEWALLOC STLSpecialAlloc -class STLSpecialAlloc; - -//----------------------------------------------------------------------------- -#include "Common/AsciiString.h" -#include "Common/UnicodeString.h" -#include "Common/GameCommon.h" -#include "Common/GameMemory.h" - -//----------------------------------------------------------------------------- - - -// FORWARD DECLARATIONS -class Object; -enum NameKeyType CPP_11(: Int); -enum ObjectID CPP_11(: Int); -enum DrawableID CPP_11(: Int); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// List of AsciiStrings to allow list of ThingTemplate names from INI and such -typedef std::list< AsciiString > AsciiStringList; -typedef std::list< AsciiString >::iterator AsciiStringListIterator; -typedef std::list< AsciiString >::const_iterator AsciiStringListConstIterator; - -// One is used in GameLogic to keep track of objects to be destroyed -typedef std::list ObjectPointerList; -typedef std::list::iterator ObjectPointerListIterator; - -typedef std::vector ObjectIDVector; -typedef std::vector::iterator ObjectIDVectorIterator; - -// Terribly useful, especially with Bezier curves -typedef std::vector VecCoord3D; -typedef VecCoord3D::iterator VecCoord3DIt; - -// Used for cursor->3D position request caching in the heightmap -typedef std::pair PosRequest; -typedef std::vector VecPosRequests; -typedef std::vector::iterator VecPosRequestsIt; - -// Used to cache off names of objects for faster lookup -typedef std::pair NamedRequest; -typedef std::vector VecNamedRequests; -typedef std::vector::iterator VecNamedRequestsIt; - -// Rumor has it that a Vector of Bools gets stored as a bitfield internally. -typedef std::vector BoolVector; -typedef std::vector::iterator BoolVectorIterator; - -typedef std::map< NameKeyType, Real, std::less > ProductionChangeMap; -typedef std::map< NameKeyType, VeterancyLevel, std::less > ProductionVeterancyMap; - -// Some useful, common hash and equal_to functors for use with hash_map -namespace rts -{ - - // Generic hash functor. This should almost always be overridden for - // specific types. - template struct hash - { - size_t operator()(const T& __t) const - { - std::hash tmp; - return tmp(__t); - } - }; - - // Generic equal_to functor. This should be overridden if there is no - // operator==, or if that isn't the behavior desired. (For instance, in - // the case of pointers.) - template struct equal_to - { - Bool operator()(const T& __t1, const T& __t2) const - { - return (__t1 == __t2); - } - }; - - // Generic less_than_nocase functor. This should be overridden if there is no - // operator<, or if that isn't the behavior desired. (For instance, in - // the case of pointers, or strings.) - template struct less_than_nocase - { - bool operator()(const T& __t1, const T& __t2) const - { - return (__t1 < __t2); - } - }; - - template<> struct hash - { - size_t operator()(NameKeyType nkt) const - { - std::hash tmp; - return tmp((UnsignedInt)nkt); - } - }; - - template<> struct hash - { - size_t operator()(DrawableID nkt) const - { - std::hash tmp; - return tmp((UnsignedInt)nkt); - } - }; - - template<> struct hash - { - size_t operator()(ObjectID nkt) const - { - std::hash tmp; - return tmp((UnsignedInt)nkt); - } - }; - - 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 to be used in lots of places.) - template<> struct equal_to - { - Bool operator()(const char* s1, const char* s2) const - { - return strcmp(s1, s2) == 0; - } - }; - - template<> struct hash - { - size_t operator()(const AsciiString& ast) const - { -#ifdef USING_STLPORT - std::hash tmp; - return tmp((const char *) ast.str()); -#else - // TheSuperHackers @bugfix xezon 16/03/2024 Re-implements hash function that works with non-STLPort. - std::hash hasher; - return hasher(std::string_view(ast.str(), ast.getLength())); -#endif - } - }; - - template<> struct equal_to - { - Bool operator()(const AsciiString& __t1, const AsciiString& __t2) const - { - return (__t1 == __t2); - } - }; - - template<> struct less_than_nocase - { - bool operator()(const AsciiString& __t1, const AsciiString& __t2) const - { - return (__t1.compareNoCase(__t2) < 0); - } - }; - - template<> struct less_than_nocase - { - bool operator()(const UnicodeString& __t1, const UnicodeString& __t2) const - { - return (__t1.compareNoCase(__t2) < 0); - } - }; - - // 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 f7bfcd6ce04..f5565c6d5c6 100644 --- a/Generals/Code/GameEngine/Include/Common/Science.h +++ b/Generals/Code/GameEngine/Include/Common/Science.h @@ -24,7 +24,7 @@ // FILE: Science.h //////////////////////////////////////////////////////////////////////////////// // Author: Steven Johnson, Colin Day November 2001 -// Desc: Science descriptoins +// Desc: Science descriptions /////////////////////////////////////////////////////////////////////////////////////////////////// #pragma once diff --git a/Generals/Code/GameEngine/Include/Common/ScoreKeeper.h b/Generals/Code/GameEngine/Include/Common/ScoreKeeper.h index 98bf12b894e..1d46551f8ab 100644 --- a/Generals/Code/GameEngine/Include/Common/ScoreKeeper.h +++ b/Generals/Code/GameEngine/Include/Common/ScoreKeeper.h @@ -107,7 +107,7 @@ class ScoreKeeper : public Snapshot Int m_totalMoneyEarned; ///< The total money that was harvested, refined, received in crates Int m_totalMoneySpent; ///< The total money spent on units, buildings, repairs - Int m_totalUnitsDestroyed[MAX_PLAYER_COUNT]; ///< The total number of enimies that we've killed + Int m_totalUnitsDestroyed[MAX_PLAYER_COUNT]; ///< The total number of enemies that we've killed Int m_totalUnitsBuilt; ///< The total number of units we've created (created meaning that we built from a building) Int m_totalUnitsLost; ///< The total number of our units lost Int m_totalBuildingsDestroyed[MAX_PLAYER_COUNT]; ///< The total number of Buildings we've destroyed diff --git a/Generals/Code/GameEngine/Include/Common/Snapshot.h b/Generals/Code/GameEngine/Include/Common/Snapshot.h deleted file mode 100644 index e8a3ef7434c..00000000000 --- a/Generals/Code/GameEngine/Include/Common/Snapshot.h +++ /dev/null @@ -1,67 +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: Snapshot.h /////////////////////////////////////////////////////////////////////////////// -// Author: Colin Day, February 2002 -// Desc: The Snapshot object is the base class interface for data structures that will -// be considered during game saves, loads, and CRC checks. -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -// USER INCLUDES ////////////////////////////////////////////////////////////////////////////////// -#include "Common/AsciiString.h" - -// FORWARD REFERENCES ///////////////////////////////////////////////////////////////////////////// -class Xfer; - -//------------------------------------------------------------------------------------------------- -//------------------------------------------------------------------------------------------------- -class Snapshot -{ - -friend class GameState; -friend class XferLoad; -friend class XferSave; -friend class XferCRC; - -public: - - Snapshot( void ); - ~Snapshot( void ); - -protected: - - /// run the "light" crc check on this data structure - virtual void crc( Xfer *xfer ) = 0; - - /** run save, load, or deep CRC check on this data structure, the type depends on the - setup of the Xfer pointer */ - virtual void xfer( Xfer *xfer ) = 0; - - /** post process phase for loading save games. All save systems have their xfer - run using XferLoad mode, and then all systems each have their post process run */ - virtual void loadPostProcess( void ) = 0; - -}; diff --git a/Generals/Code/GameEngine/Include/Common/SparseMatchFinder.h b/Generals/Code/GameEngine/Include/Common/SparseMatchFinder.h index 38e3bbed4d3..e96bf0f9380 100644 --- a/Generals/Code/GameEngine/Include/Common/SparseMatchFinder.h +++ b/Generals/Code/GameEngine/Include/Common/SparseMatchFinder.h @@ -123,7 +123,7 @@ class SparseMatchFinder //------------------------------------------------------------------------------------------------- const MATCHABLE* findBestInfoSlow(const std::vector& v, const BITSET& bits) const { - const MATCHABLE* result = NULL; + const MATCHABLE* result = nullptr; Int bestYesMatch = 0; // want to maximize this Int bestYesExtraneousBits = 999; // want to minimize this @@ -220,19 +220,19 @@ class SparseMatchFinder { typename MatchMap::const_iterator it = m_bestMatches.find(bits); - const MATCHABLE *first = NULL; + const MATCHABLE *first = nullptr; if (it != m_bestMatches.end()) { first = (*it).second; } - if (first != NULL) { + if (first != nullptr) { return first; } const MATCHABLE* info = findBestInfoSlow(v, bits); - DEBUG_ASSERTCRASH(info != NULL, ("no suitable match for criteria was found!")); - if (info != NULL) { + DEBUG_ASSERTCRASH(info != nullptr, ("no suitable match for criteria was found!")); + if (info != nullptr) { m_bestMatches[bits] = info; } diff --git a/Generals/Code/GameEngine/Include/Common/StackDump.h b/Generals/Code/GameEngine/Include/Common/StackDump.h index 9a0e836dcf2..2d11b754b94 100644 --- a/Generals/Code/GameEngine/Include/Common/StackDump.h +++ b/Generals/Code/GameEngine/Include/Common/StackDump.h @@ -24,18 +24,17 @@ #pragma once -#ifndef IG_DEGBUG_STACKTRACE +#ifndef IG_DEBUG_STACKTRACE #define IG_DEBUG_STACKTRACE 1 -#endif - +#endif // Unsure about this one -ML 3/25/03 #if defined(RTS_DEBUG) || defined(IG_DEBUG_STACKTRACE) // Writes a stackdump (provide a callback : gets called per line) -// If callback is NULL then will write using OuputDebugString +// If callback is nullptr then will write using OuputDebugString void StackDump(void (*callback)(const char*)); // Writes a stackdump (provide a callback : gets called per line) -// If callback is NULL then will write using OuputDebugString +// If callback is nullptr then will write using OuputDebugString void StackDumpFromContext(DWORD eip,DWORD esp,DWORD ebp, void (*callback)(const char*)); // Gets count* addresses from the current stack diff --git a/Generals/Code/GameEngine/Include/Common/StateMachine.h b/Generals/Code/GameEngine/Include/Common/StateMachine.h index 964612308b1..bea16f4bf25 100644 --- a/Generals/Code/GameEngine/Include/Common/StateMachine.h +++ b/Generals/Code/GameEngine/Include/Common/StateMachine.h @@ -170,7 +170,7 @@ class State : public MemoryPoolObject, public Snapshot 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 + void friend_onCondition( StateTransFuncPtr test, StateID toStateID, void* userData, const char* description = nullptr ); ///< define when to change state StateReturnType friend_checkForTransitions( StateReturnType status ); ///< given a return code, handle state transitions StateReturnType friend_checkForSleepTransitions( StateReturnType status ); ///< given a return code, handle state transitions @@ -288,7 +288,7 @@ class StateMachine : public MemoryPoolObject, public Snapshot { m_locked = false; #ifdef STATE_MACHINE_DEBUG - m_lockedby = NULL; + m_lockedby = nullptr; #endif } @@ -349,7 +349,7 @@ class StateMachine : public MemoryPoolObject, public Snapshot void defineState( StateID id, State *state, StateID successID, StateID failureID, - const StateConditionInfo* conditions = NULL); + const StateConditionInfo* conditions = nullptr); State* internalGetState( StateID id ); @@ -478,6 +478,6 @@ EMPTY_DTOR(SleepState) // @todo Replace calls to deleteInstance with RefCountPtr when so appropriate. inline void deleteInstance(StateMachine* machine) { - if (machine != NULL) + if (machine != nullptr) machine->Release_Ref(); } diff --git a/Generals/Code/GameEngine/Include/Common/StatsCollector.h b/Generals/Code/GameEngine/Include/Common/StatsCollector.h index 9b67159c405..3ccf09a1672 100644 --- a/Generals/Code/GameEngine/Include/Common/StatsCollector.h +++ b/Generals/Code/GameEngine/Include/Common/StatsCollector.h @@ -68,7 +68,7 @@ class StatsCollector StatsCollector( void ); ~StatsCollector( void ); - void reset( void ); ///< Reset's all values and writes the file header + void reset( void ); ///< Resets all values and writes the file header void collectMsgStats( const GameMessage *msg ); ///< collects Msg Stats if void collectUnitCountStats( void ); ///< cycle through all units and takes count diff --git a/Generals/Code/GameEngine/Include/Common/SubsystemInterface.h b/Generals/Code/GameEngine/Include/Common/SubsystemInterface.h deleted file mode 100644 index 740accba46a..00000000000 --- a/Generals/Code/GameEngine/Include/Common/SubsystemInterface.h +++ /dev/null @@ -1,164 +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: SubsystemInterface.h ///////////////////////////////////////////////////////////////////// -// Author: Colin Day, October 2001 -// Description: Framework for subsystems singletons of the game engine -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "Common/INI.h" -#include "Common/STLTypedefs.h" - -class Xfer; - -//------------------------------------------------------------------------------------------------- -/** This is the abstract base class from which all game engine subsytems should derive from. - * In order to provide consistent behaviors across all these systems, any implementation - * must obey the rules defined in here - * - * Nothing about the subsystems is automatic, this interface does not wrap up automated - * functions, it is only here to provide a basic interface and rules for behavior - * all subsystems - */ -class SubsystemInterface -{ - -public: - - //----------------------------------------------------------------------------------------------- - /** - Constructors should initialize any data to a valid state. That DOES NOT mean - * the data has default values (something done in the init() method), only that - * nothing is left pointing to garbage, un-initialized memory. In most cases - * this probably means just setting members to zero or NULL. - */ - SubsystemInterface(); - - //----------------------------------------------------------------------------------------------- - /** - Free any resources allocated for this class. - * - * - DO NOT throw exceptions during any destruction ever, and do not call other - * methods that have the possibility of throwing exceptions. Try to keep it - * simple and keep as much work actually inside the destructor as possible. - */ - virtual ~SubsystemInterface(); - - //----------------------------------------------------------------------------------------------- - /** - Assign any default values to data required for the class - * - * - Allocate any memory and resources needed throughout the lifetime of the class - */ - virtual void init() = 0; - - //----------------------------------------------------------------------------------------------- - /** - Called for all subsystems after all other Subsystems are inited. - * (allows for initializing inter-system dependencies) - */ - virtual void postProcessLoad() { } - - //----------------------------------------------------------------------------------------------- - /** - Any system should be able to reset all data and go back to an empty state - * that is ready to accept a completely new set of data. Reset() can expect - * to be used in the context of resetting the engine in order to start or - * load a new game. - * - * - Do NOT free and re-allocate resources needed, where possible reorganize and - * re-initialize the resources already allocated. - * - * - After a reset, the system does not need to be in EXACTLY the same state as a - * fresh instantiation. If there are persistent state information for the - * system make sure you maintain it while restoring or re-initializing other - * transient parts. - */ - virtual void reset() = 0; - - //----------------------------------------------------------------------------------------------- - /** - Update methods are the place to do system per frame processing. You - * should call the system update once each time through the game loop - * to service the system. - * - * - Note that currently the GameClient and GameLogic will be updating - * at different rates where the logic is running real time, and the - * client will adjust how many loops can be done during one server - * time slice in order to improve performance on low end machines. - */ - virtual void update() = 0; - - - virtual void draw( void ){DEBUG_CRASH(("Shouldn't call base class. jba."));} - -#ifdef DUMP_PERF_STATS - void UPDATE(void); - void DRAW(void); - Real getUpdateTime(void) {return m_curUpdateTime;} - Real getDrawTime(void) {return m_curDrawTime;} - static Real getTotalTime(void) {return s_msConsumed;} - static void clearTotalTime(void) {s_msConsumed = 0;} -protected: - static Real s_msConsumed; - Real m_startTimeConsumed; - Real m_curUpdateTime; - - Real m_startDrawTimeConsumed; - Real m_curDrawTime; -#else - void UPDATE(void) {update();} - void DRAW(void) {draw();} -#endif -protected: - AsciiString m_name; -public: - AsciiString getName(void) {return m_name;} - void setName(AsciiString name) {m_name = name;} - -}; - -//------------------------------------------------------------------------------------------------- -class SubsystemInterfaceList -{ -public: - - SubsystemInterfaceList(); - ~SubsystemInterfaceList(); - - void initSubsystem(SubsystemInterface* sys, const char* path1, const char* path2, Xfer *pXfer, AsciiString name=""); - void addSubsystem(SubsystemInterface* sys); - void removeSubsystem(SubsystemInterface* sys); - void postProcessLoadAll(); - void resetAll(); - void shutdownAll(); -#ifdef DUMP_PERF_STATS - AsciiString dumpTimesForAll(); -#endif - -private: - - typedef std::vector SubsystemList; - SubsystemList m_subsystems; - SubsystemList m_allSubsystems; - -}; - -extern SubsystemInterfaceList* TheSubsystemList; diff --git a/Generals/Code/GameEngine/Include/Common/Team.h b/Generals/Code/GameEngine/Include/Common/Team.h index d510d1cc5c9..83f6a544a35 100644 --- a/Generals/Code/GameEngine/Include/Common/Team.h +++ b/Generals/Code/GameEngine/Include/Common/Team.h @@ -54,7 +54,7 @@ class TeamRelationMap : public MemoryPoolObject, TeamRelationMap( void ); // virtual destructor provided by memory pool object - /** @todo I'm jsut wrappign this up in a nice snapshot object, we really should isolate + /** @todo I'm just wrapping this up in a nice snapshot object, we really should isolate * m_map from public access and make access methods for our operations */ TeamRelationMapType m_map; @@ -259,7 +259,7 @@ class Team : public MemoryPoolObject, Player *getControllingPlayer() const; /** - set the team's owner. (NULL is not allowed) + set the team's owner. (nullptr is not allowed) */ void setControllingPlayer(Player *newController); @@ -540,7 +540,7 @@ class TeamPrototype : public MemoryPoolObject, Team *findTeamByID( TeamID teamID ); /** - set the team's owner. (NULL is not allowed) + set the team's owner. (nullptr is not allowed) */ void setControllingPlayer(Player *newController); @@ -696,10 +696,10 @@ class TeamFactory : public SubsystemInterface, /// return the TeamPrototype with the given name. if none exists, return null. TeamPrototype *findTeamPrototype(const AsciiString& name); - /// return TeamPrototype with matching ID. if none exists NULL is returned + /// return TeamPrototype with matching ID. if none exists nullptr is returned TeamPrototype *findTeamPrototypeByID( TeamPrototypeID id ); - /// search all prototypes for the team with the matching id, if none found NULL is returned + /// search all prototypes for the team with the matching id, if none found nullptr is returned Team *findTeamByID( TeamID teamID ); // note that there is no way to directly destroy a specific TeamPrototype (or a Team); the only @@ -710,7 +710,7 @@ class TeamFactory : public SubsystemInterface, /// create a team. there must be a TeamPrototype with the given name, or an exception is thrown. Team *createTeam(const AsciiString& name); - /// create a team given an explicity team prototype rather than a prototype name + /// create a team given an explicitly team prototype rather than a prototype name Team *createTeamOnPrototype( TeamPrototype *prototype ); /// create a team. there must be a TeamPrototype with the given name, or an exception is thrown. diff --git a/Generals/Code/GameEngine/Include/Common/Terrain.h b/Generals/Code/GameEngine/Include/Common/Terrain.h index dd6ea409a39..fe1905568e1 100644 --- a/Generals/Code/GameEngine/Include/Common/Terrain.h +++ b/Generals/Code/GameEngine/Include/Common/Terrain.h @@ -37,4 +37,4 @@ // USER INCLUDES ////////////////////////////////////////////////////////////// // DEFINE ///////////////////////////////////////////////////////////////////// -#define MAX_TERRAIN_NAME_LEN 64 ///< max size of map filename with extenstion +#define MAX_TERRAIN_NAME_LEN 64 ///< max size of map filename with extension diff --git a/Generals/Code/GameEngine/Include/Common/TerrainTypes.h b/Generals/Code/GameEngine/Include/Common/TerrainTypes.h index b0b2e2013e2..e29943bfeb2 100644 --- a/Generals/Code/GameEngine/Include/Common/TerrainTypes.h +++ b/Generals/Code/GameEngine/Include/Common/TerrainTypes.h @@ -56,8 +56,6 @@ typedef enum TERRAIN_SNOW_3, // remove all the terrain types below when Todd says he's redone them all - TERRAIN_ASPHALT, - TERRAIN_CONCRETE, TERRAIN_DIRT, TERRAIN_GRASS, TERRAIN_TRANSITION, @@ -67,6 +65,25 @@ typedef enum TERRAIN_WOOD, TERRAIN_BLEND_EDGES, + // New terrain types (for Samm Ivri) + TERRAIN_LIVE_DESERT, + TERRAIN_DRY_DESERT, + TERRAIN_ACCENT_SAND, + TERRAIN_TROPICAL_BEACH, + TERRAIN_BEACH_PARK, + TERRAIN_RUGGED_MOUNTAIN, + TERRAIN_COBBLESTONE_GRASS, + TERRAIN_ACCENT_GRASS, + TERRAIN_RESIDENTIAL, + TERRAIN_RUGGED_SNOW, + TERRAIN_FLAT_SNOW, + TERRAIN_FIELD, + TERRAIN_ASPHALT, + TERRAIN_CONCRETE, + TERRAIN_CHINA, + TERRAIN_ACCENT_ROCK, + TERRAIN_URBAN, + TERRAIN_NUM_CLASSES } TerrainClass; @@ -88,8 +105,6 @@ static const char *const terrainTypeNames[] = "SNOW_3", // remove all the terrain types below when Todd says he's redone them all - "ASPHALT", - "CONCRETE", "DIRT", "GRASS", "TRANSITION", @@ -99,7 +114,26 @@ static const char *const terrainTypeNames[] = "WOOD", "BLEND_EDGE", - NULL + // New terrain types (for Samm Ivri) + "DESERT_LIVE", + "DESERT_DRY", + "SAND_ACCENT", + "BEACH_TROPICAL", + "BEACH_PARK", + "MOUNTAIN_RUGGED", + "GRASS_COBBLESTONE", + "GRASS_ACCENT", + "RESIDENTIAL", + "SNOW_RUGGED", + "SNOW_FLAT", + "FIELD", + "ASPHALT", + "CONCRETE", + "CHINA", + "ROCK_ACCENT", + "URBAN", + + nullptr }; static_assert(ARRAY_SIZE(terrainTypeNames) == TERRAIN_NUM_CLASSES + 1, "Incorrect array size"); #endif // end DEFINE_TERRAIN_TYPE_NAMES diff --git a/Generals/Code/GameEngine/Include/Common/Thing.h b/Generals/Code/GameEngine/Include/Common/Thing.h index 838480831ed..78eef69ab53 100644 --- a/Generals/Code/GameEngine/Include/Common/Thing.h +++ b/Generals/Code/GameEngine/Include/Common/Thing.h @@ -84,10 +84,10 @@ class Thing : public MemoryPoolObject { // note, it is explicitly OK to pass null for 'thing' here; // they will check for null and return null in these cases. - friend inline Object *AsObject(Thing *thing) { return thing ? thing->asObjectMeth() : NULL; } - friend inline Drawable *AsDrawable(Thing *thing) { return thing ? thing->asDrawableMeth() : NULL; } - friend inline const Object *AsObject(const Thing *thing) { return thing ? thing->asObjectMeth() : NULL; } - friend inline const Drawable *AsDrawable(const Thing *thing) { return thing ? thing->asDrawableMeth() : NULL; } + friend inline Object *AsObject(Thing *thing) { return thing ? thing->asObjectMeth() : nullptr; } + friend inline Drawable *AsDrawable(Thing *thing) { return thing ? thing->asDrawableMeth() : nullptr; } + friend inline const Object *AsObject(const Thing *thing) { return thing ? thing->asObjectMeth() : nullptr; } + friend inline const Drawable *AsDrawable(const Thing *thing) { return thing ? thing->asDrawableMeth() : nullptr; } MEMORY_POOL_GLUE_ABC(Thing) @@ -145,13 +145,13 @@ class Thing : public MemoryPoolObject protected: - // Virtual method since objects can be on bridges and need to calculate heigh above terrain differently. + // Virtual method since objects can be on bridges and need to calculate height above terrain differently. virtual Real calculateHeightAboveTerrain(void) const; // Calculates the actual height above terrain. Doesn't use cache. - virtual Object *asObjectMeth() { return NULL; } - virtual Drawable *asDrawableMeth() { return NULL; } - virtual const Object *asObjectMeth() const { return NULL; } - virtual const Drawable *asDrawableMeth() const { return NULL; } + virtual Object *asObjectMeth() { return nullptr; } + virtual Drawable *asDrawableMeth() { return nullptr; } + virtual const Object *asObjectMeth() const { return nullptr; } + virtual const Drawable *asDrawableMeth() const { return nullptr; } virtual void reactToTransformChange(const Matrix3D* oldMtx, const Coord3D* oldPos, Real oldAngle) = 0; diff --git a/Generals/Code/GameEngine/Include/Common/ThingFactory.h b/Generals/Code/GameEngine/Include/Common/ThingFactory.h index c9469239c2f..467a7f19fd1 100644 --- a/Generals/Code/GameEngine/Include/Common/ThingFactory.h +++ b/Generals/Code/GameEngine/Include/Common/ThingFactory.h @@ -95,7 +95,7 @@ class ThingFactory : public SubsystemInterface private: - /// free all template databse data + /// free all template database data void freeDatabase( void ); void addTemplate( ThingTemplate *thing ); ///< add the template to the DB diff --git a/Generals/Code/GameEngine/Include/Common/ThingSort.h b/Generals/Code/GameEngine/Include/Common/ThingSort.h index e35702922c8..93cdf8cfd4f 100644 --- a/Generals/Code/GameEngine/Include/Common/ThingSort.h +++ b/Generals/Code/GameEngine/Include/Common/ThingSort.h @@ -29,7 +29,7 @@ #pragma once -#include "GameCommon.h" +#include "Common/GameCommon.h" //------------------------------------------------------------------------------------------------- enum EditorSortingType CPP_11(: Int) @@ -71,7 +71,7 @@ static const char *const EditorSortingNames[] = "ROAD", "WAYPOINT", - NULL + nullptr }; static_assert(ARRAY_SIZE(EditorSortingNames) == ES_NUM_SORTING_TYPES + 1, "Incorrect array size"); #endif diff --git a/Generals/Code/GameEngine/Include/Common/ThingTemplate.h b/Generals/Code/GameEngine/Include/Common/ThingTemplate.h index f01dc7038ea..ac72b4a37ff 100644 --- a/Generals/Code/GameEngine/Include/Common/ThingTemplate.h +++ b/Generals/Code/GameEngine/Include/Common/ThingTemplate.h @@ -119,7 +119,7 @@ enum ThingTemplateAudioType CPP_11(: Int) TTAUDIO_soundStealthOff, ///< Sound when unit destealths TTAUDIO_soundCreated, ///< Sound when unit is created TTAUDIO_soundOnDamaged, ///< Sound when unit enters damaged state - TTAUDIO_soundOnReallyDamaged, ///< Sound when unit enters reallyd damaged state + TTAUDIO_soundOnReallyDamaged, ///< Sound when unit enters really damaged state TTAUDIO_soundDieFire, ///< Sound when unit dies by fire. NOTE: Replaces soundDie if present and unit dies by fire. TTAUDIO_soundDieToxin, ///< Sound when unit dies by Toxin. NOTE: Replaces soundDie if present and unit dies by fire. TTAUDIO_soundEnter, ///< Sound when another unit enters me. @@ -149,7 +149,7 @@ class AudioArray AudioArray() { for (Int i = 0; i < TTAUDIO_COUNT; ++i) - m_audio[i] = NULL; + m_audio[i] = nullptr; } ~AudioArray() @@ -165,7 +165,7 @@ class AudioArray if (that.m_audio[i]) m_audio[i] = newInstance(DynamicAudioEventRTS)(*that.m_audio[i]); else - m_audio[i] = NULL; + m_audio[i] = nullptr; } } @@ -184,7 +184,7 @@ class AudioArray } else { - m_audio[i] = NULL; + m_audio[i] = nullptr; } } } @@ -210,7 +210,7 @@ static const char *const BuildCompletionNames[] = "APPEARS_AT_RALLY_POINT", "PLACED_BY_PLAYER", - NULL + nullptr }; static_assert(ARRAY_SIZE(BuildCompletionNames) == BC_NUM_TYPES + 1, "Incorrect array size"); #endif // end DEFINE_BUILD_COMPLETION_NAMES @@ -233,7 +233,7 @@ static const char *const BuildableStatusNames[] = "Ignore_Prerequisites", "No", "Only_By_AI", - NULL + nullptr }; static_assert(ARRAY_SIZE(BuildableStatusNames) == BSTATUS_NUM_TYPES + 1, "Incorrect array size"); #endif // end DEFINE_BUILDABLE_STATUS_NAMES @@ -288,7 +288,7 @@ class ModuleInfo Bool containsPartialName(const char* n) const { for (size_t i = 0; i < m_info.size(); i++) - if (strstr(m_info[i].first.str(), n) != NULL) + if (strstr(m_info[i].first.str(), n) != nullptr) return true; return false; } @@ -318,7 +318,7 @@ class ModuleInfo { return m_info[i].second; } - return NULL; + return nullptr; } // for use only by ThingTemplate::friend_getAIModuleInfo @@ -592,7 +592,7 @@ class ThingTemplate : public Overridable void setCopiedFromDefault(); - void setReskinnedFrom(const ThingTemplate* tt) { DEBUG_ASSERTCRASH(m_reskinnedFrom == NULL, ("should be null")); m_reskinnedFrom = tt; } + void setReskinnedFrom(const ThingTemplate* tt) { DEBUG_ASSERTCRASH(m_reskinnedFrom == nullptr, ("should be null")); m_reskinnedFrom = tt; } Bool isPrerequisite() const { return m_isPrerequisite; } @@ -698,7 +698,7 @@ class ThingTemplate : public Overridable // ---- Pointer-sized things ThingTemplate* m_nextThingTemplate; - const ThingTemplate* m_reskinnedFrom; ///< non NULL if we were generated via a reskin + const ThingTemplate* m_reskinnedFrom; ///< non nullptr if we were generated via a reskin const Image * m_selectedPortraitImage; /// portrait image when selected (to display in GUI) const Image * m_buttonImage; diff --git a/Generals/Code/GameEngine/Include/Common/Upgrade.h b/Generals/Code/GameEngine/Include/Common/Upgrade.h index 9f587e36bc7..c43f5df46ad 100644 --- a/Generals/Code/GameEngine/Include/Common/Upgrade.h +++ b/Generals/Code/GameEngine/Include/Common/Upgrade.h @@ -51,7 +51,9 @@ enum UpgradeStatusType CPP_11(: Int) }; //The maximum number of upgrades. -#define UPGRADE_MAX_COUNT 64 +// TheSuperHackers @tweak Stubbjax 22/01/2026 Increases max upgrade count from 64 to allow for more upgrades. +// A value of 512 was chosen to allow room for plenty of upgrades while also conserving memory. +#define UPGRADE_MAX_COUNT 512 typedef BitFlags UpgradeMaskType; @@ -172,7 +174,7 @@ class UpgradeTemplate : public MemoryPoolObject void setUpgradeNameKey( NameKeyType key ) { m_nameKey = key; } NameKeyType getUpgradeNameKey( void ) const { return m_nameKey; } const AsciiString& getDisplayNameLabel( void ) const { return m_displayNameLabel; } - UpgradeMaskType getUpgradeMask() const { return m_upgradeMask; } + const UpgradeMaskType& getUpgradeMask() const { return m_upgradeMask; } UpgradeType getUpgradeType( void ) const { return m_type; } const AudioEventRTS* getResearchCompleteSound() const { return &m_researchSound; } const AudioEventRTS* getUnitSpecificSound() const { return &m_unitSpecificSound; } diff --git a/Generals/Code/GameEngine/Include/Common/UserPreferences.h b/Generals/Code/GameEngine/Include/Common/UserPreferences.h deleted file mode 100644 index aef49361d36..00000000000 --- a/Generals/Code/GameEngine/Include/Common/UserPreferences.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. // -// // -//////////////////////////////////////////////////////////////////////////////// - -/////////////////////////////////////////////////////////////////////////////////////// -// FILE: UserPreferences.h -// Author: Matthew D. Campbell, April 2002 -// Description: Saving/Loading of user preferences -/////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -//----------------------------------------------------------------------------- -// USER INCLUDES ////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- -#include "Common/STLTypedefs.h" - -class Money; -typedef UnsignedInt CursorCaptureMode; -typedef UnsignedInt ScreenEdgeScrollMode; - -//----------------------------------------------------------------------------- -// PUBLIC TYPES /////////////////////////////////////////////////////////////// -//----------------------------------------------------------------------------- - -typedef std::map PreferenceMap; - -//----------------------------------------------------------------------------- -// UserPreferences base class -//----------------------------------------------------------------------------- -class UserPreferences : public PreferenceMap -{ -public: - UserPreferences(); - virtual ~UserPreferences(); - - // Loads or creates a file with the given name in the user data directory. - virtual Bool load(AsciiString fname); - virtual Bool write(void); - - Bool getBool(AsciiString key, Bool defaultValue) const; - Real getReal(AsciiString key, Real defaultValue) const; - Int getInt(AsciiString key, Int defaultValue) const; - AsciiString getAsciiString(AsciiString key, AsciiString defaultValue) const; - - void setBool(AsciiString key, Bool val); - void setReal(AsciiString key, Real val); - void setInt(AsciiString key, Int val); - void setAsciiString(AsciiString key, AsciiString val); - -protected: - AsciiString m_filename; -}; - -//----------------------------------------------------------------------------- -// OptionsPreferences options menu class -//----------------------------------------------------------------------------- -class OptionPreferences : public UserPreferences -{ -public: - OptionPreferences( ); - virtual ~OptionPreferences(); - - Bool loadFromIniFile(); - - UnsignedInt getLANIPAddress(void); // convenience function - UnsignedInt getOnlineIPAddress(void); // convenience function - void setLANIPAddress(AsciiString IP); // convenience function - 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 - UnsignedShort getFirewallPortOverride(void); // convenience function - Bool getFirewallNeedToRefresh(void); // convenience function - Bool usesSystemMapDir(void); // convenience function - AsciiString getPreferred3DProvider(void); // convenience function - AsciiString getSpeakerType(void); // convenience function - Real getSoundVolume(void); // convenience function - Real get3DSoundVolume(void); // convenience function - Real getSpeechVolume(void); // convenience function - Real getMusicVolume(void); // convenience function - 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); - Int getTextureReduction(void); - void getResolution(Int *xres, Int *yres); - Bool get3DShadowsEnabled(void); - Bool get2DShadowsEnabled(void); - Bool getCloudShadowsEnabled(void); - Bool getLightmapEnabled(void); - Bool getSmoothWaterEnabled(void); - Bool getTreesEnabled(void); - Bool getExtraAnimationsDisabled(void); - Bool getDynamicLODEnabled(void); - Bool getFPSLimitEnabled(void); - Bool getNoDynamicLODEnabled(void); - Bool getBuildingOcclusionEnabled(void); - Int getParticleCap(void); - - 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; -}; - -//----------------------------------------------------------------------------- -// LANPreferences class -//----------------------------------------------------------------------------- -class LANPreferences : public UserPreferences -{ -public: - LANPreferences(); - virtual ~LANPreferences(); - - Bool loadFromIniFile(); - - UnicodeString getUserName(void); // convenience function - Int getPreferredFaction(void); // convenience function - Int getPreferredColor(void); // convenience function - AsciiString getPreferredMap(void); // convenience function - Bool usesSystemMapDir(void); // convenience function - Int getNumRemoteIPs(void); // convenience function - UnicodeString getRemoteIPEntry(Int i); // convenience function - - 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/version.h b/Generals/Code/GameEngine/Include/Common/version.h index 088a0f7217c..e4ea743336e 100644 --- a/Generals/Code/GameEngine/Include/Common/version.h +++ b/Generals/Code/GameEngine/Include/Common/version.h @@ -47,8 +47,8 @@ class Version AsciiString getAsciiVersion() const; ///< Return a human-readable game version number UnicodeString getUnicodeVersion() const; ///< Return a human-readable game version number. Is decorated with localized string - AsciiString getAsciiBuildTime() const; ///< Return a formated date/time string for build time - UnicodeString getUnicodeBuildTime() const; ///< Return a formated date/time string for build time. Is decorated with localized string + AsciiString getAsciiBuildTime() const; ///< Return a formatted date/time string for build time + UnicodeString getUnicodeBuildTime() const; ///< Return a formatted date/time string for build time. Is decorated with localized string AsciiString getAsciiBuildLocation() const; ///< Return a string with the build location UnicodeString getUnicodeBuildLocation() const; ///< Return a string with the build location. Is decorated with localized string @@ -66,6 +66,9 @@ class Version AsciiString getAsciiGitTagOrHash() const; ///< Returns the git head commit tag or hash. Is prefixed with ~ if there were uncommitted changes. UnicodeString getUnicodeGitTagOrHash() const; ///< Returns the git head commit tag or hash. Is prefixed with ~ if there were uncommitted changes. + AsciiString getAsciiGitShortHash() const; ///< Returns the git head commit short hash. Is prefixed with ~ if there were uncommitted changes. + UnicodeString getUnicodeGitShortHash() const; ///< Returns the git head commit short hash. Is prefixed with ~ if there were uncommitted changes. + AsciiString getAsciiGitCommitTime() const; ///< Returns the git head commit time in YYYY-mm-dd HH:MM:SS format UnicodeString getUnicodeGitCommitTime() const; ///< Returns the git head commit time in YYYY-mm-dd HH:MM:SS format @@ -95,6 +98,9 @@ class Version static AsciiString buildAsciiGitTagOrHash(); static UnicodeString buildUnicodeGitTagOrHash(); + static AsciiString buildAsciiGitShortHash(); + static UnicodeString buildUnicodeGitShortHash(); + static AsciiString buildAsciiGitCommitTime(); static UnicodeString buildUnicodeGitCommitTime(); @@ -109,9 +115,11 @@ class Version AsciiString m_buildDate; AsciiString m_asciiGitCommitCount; AsciiString m_asciiGitTagOrHash; + AsciiString m_asciiGitShortHash; AsciiString m_asciiGitCommitTime; UnicodeString m_unicodeGitCommitCount; UnicodeString m_unicodeGitTagOrHash; + UnicodeString m_unicodeGitShortHash; UnicodeString m_unicodeGitCommitTime; Bool m_showFullVersion; }; diff --git a/Generals/Code/GameEngine/Include/GameClient/Anim2D.h b/Generals/Code/GameEngine/Include/GameClient/Anim2D.h index e3853a37102..9f469309ce1 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Anim2D.h +++ b/Generals/Code/GameEngine/Include/GameClient/Anim2D.h @@ -33,6 +33,7 @@ #include "Common/Snapshot.h" // FORWARD REFERENCES ///////////////////////////////////////////////////////////////////////////// +class Anim2DCollection; class Image; // ------------------------------------------------------------------------------------------------ @@ -62,7 +63,7 @@ static const char *const Anim2DModeNames[] = "LOOP_BACKWARDS", "PING_PONG", "PING_PONG_BACKWARDS", - NULL + nullptr }; static_assert(ARRAY_SIZE(Anim2DModeNames) == ANIM_2D_NUM_MODES + 1, "Incorrect array size"); #endif @@ -160,7 +161,7 @@ friend class Anim2DCollection; UnsignedInt getCurrentFrameHeight( void ) const; ///< return natural height of image in the current frame const Anim2DTemplate *getAnimTemplate( void ) const { return m_template; } ///< return our template - void draw( Int x, Int y ); ///< draw iamge at location using natural width/height + void draw( Int x, Int y ); ///< draw image at location using natural width/height void draw( Int x, Int y, Int width, Int height ); ///< draw image at location using forced width/height protected: diff --git a/Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h b/Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h index 523a4276f5c..2b907083278 100644 --- a/Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h +++ b/Generals/Code/GameEngine/Include/GameClient/AnimateWindowManager.h @@ -139,7 +139,7 @@ class AnimateWindow : public MemoryPoolObject private: UnsignedInt m_delay; ///< Holds the delay time in which the animation will start (in milliseconds) ICoord2D m_startPos; ///< Holds the starting position of the animation - ///<(usuall is also the end position of the animation when the animation is reversed) + ///<(usually is also the end position of the animation when the animation is reversed) ICoord2D m_endPos; ///< Holds the target End Position (usually is the same as the rest position) ICoord2D m_curPos; ///< It's Current Position ICoord2D m_restPos; ///< When the Manager Resets, It sets the window's position to this position diff --git a/Generals/Code/GameEngine/Include/GameClient/CDCheck.h b/Generals/Code/GameEngine/Include/GameClient/CDCheck.h deleted file mode 100644 index e5e3a8921ef..00000000000 --- a/Generals/Code/GameEngine/Include/GameClient/CDCheck.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -** Command & Conquer Generals(tm) -** Copyright 2025 Electronic Arts Inc. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation, either version 3 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program. If not, see . -*/ - -//////////////////////////////////////////////////////////////////////////////// -// // -// (c) 2001-2003 Electronic Arts Inc. // -// // -//////////////////////////////////////////////////////////////////////////////// - -// FILE: CDCheck.h //////////////////////////////////////////////////////////////////////////////// -// Author: Matt Campbell, January 2003 -// Description: check for CD, popping up an in-game message box at game start. -/////////////////////////////////////////////////////////////////////////////////////////////////// - -#pragma once - -typedef void (*gameStartCallback) (void); - -Bool IsFirstCDPresent(void); -void CheckForCDAtGameStart( gameStartCallback callback ); diff --git a/Generals/Code/GameEngine/Include/GameClient/CampaignManager.h b/Generals/Code/GameEngine/Include/GameClient/CampaignManager.h index 2ea11594e4d..77b4fe19875 100644 --- a/Generals/Code/GameEngine/Include/GameClient/CampaignManager.h +++ b/Generals/Code/GameEngine/Include/GameClient/CampaignManager.h @@ -122,7 +122,7 @@ class CampaignManager : public Snapshot Campaign *getCurrentCampaign( void ); ///< Returns a point to the current Campaign Mission *getCurrentMission( void ); ///< Returns a point to the current mission Mission *gotoNextMission( void ); ///< Set the next mission as the current Mission, and returns a point to it - void setCampaignAndMission( AsciiString campaign, AsciiString mission ); ///< Sets the campaing and Mission we're on + void setCampaignAndMission( AsciiString campaign, AsciiString mission ); ///< Sets the campaign and Mission we're on void setCampaign( AsciiString campaign ); ///< sets the campaign and set's it's first mission AsciiString getCurrentMap( void ); ///< Get the map located in m_currentMission; enum { INVALID_MISSION_NUMBER = -1 }; diff --git a/Generals/Code/GameEngine/Include/GameClient/Color.h b/Generals/Code/GameEngine/Include/GameClient/Color.h index 87c497de181..842827c3028 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Color.h +++ b/Generals/Code/GameEngine/Include/GameClient/Color.h @@ -55,7 +55,7 @@ // TYPE DEFINES /////////////////////////////////////////////////////////////// enum { GAME_COLOR_UNDEFINED = 0x00FFFFFF }; // this is white with zero alpha... safe to use! -/** @todo we need real color representation, this is just palce holder so we +/** @todo we need real color representation, this is just placeholder so we can more easily identify sections of the code that need it */ typedef Int Color; diff --git a/Generals/Code/GameEngine/Include/GameClient/CommandXlat.h b/Generals/Code/GameEngine/Include/GameClient/CommandXlat.h index aebea584fa2..41e256dfc98 100644 --- a/Generals/Code/GameEngine/Include/GameClient/CommandXlat.h +++ b/Generals/Code/GameEngine/Include/GameClient/CommandXlat.h @@ -50,7 +50,7 @@ class CommandTranslator : public GameMessageTranslator Int m_objective; Bool m_teamExists; ///< is there a currently selected "team"? - // these are for determining if a drag occurred or it wasjust a sloppy click + // these are for determining if a drag occurred or it was just a sloppy click ICoord2D m_mouseRightDragAnchor; // the location of a possible mouse drag start ICoord2D m_mouseRightDragLift; // the location of a possible mouse drag end UnsignedInt m_mouseRightDown; // when the mouse down happened @@ -117,8 +117,8 @@ class PickAndPlayInfo Bool m_air; //Are we attacking an airborned target? Drawable *m_drawTarget; //Do we have an override draw target? - WeaponSlotType *m_weaponSlot; //Are we forcing a specific weapon slot? NULL if unspecified. + WeaponSlotType *m_weaponSlot; //Are we forcing a specific weapon slot? nullptr if unspecified. SpecialPowerType m_specialPowerType; //Which special power are use using? SPECIAL_INVALID if unspecified. }; -extern void pickAndPlayUnitVoiceResponse( const DrawableList *list, GameMessage::Type msgType, PickAndPlayInfo *info = NULL ); +extern void pickAndPlayUnitVoiceResponse( const DrawableList *list, GameMessage::Type msgType, PickAndPlayInfo *info = nullptr ); diff --git a/Generals/Code/GameEngine/Include/GameClient/ControlBar.h b/Generals/Code/GameEngine/Include/GameClient/ControlBar.h index 19e6580aae9..7ba126f9800 100644 --- a/Generals/Code/GameEngine/Include/GameClient/ControlBar.h +++ b/Generals/Code/GameEngine/Include/GameClient/ControlBar.h @@ -128,7 +128,7 @@ static const char *const TheCommandOptionNames[] = "IGNORES_UNDERPOWERED", "USES_MINE_CLEARING_WEAPONSET", - NULL + nullptr }; #endif // end DEFINE_COMMAND_OPTION_NAMES @@ -206,7 +206,7 @@ enum GUICommandType CPP_11(: Int) GUI_COMMAND_NUM_COMMANDS }; -#ifdef DEFINE_GUI_COMMMAND_NAMES +#ifdef DEFINE_GUI_COMMAND_NAMES static const char *const TheGuiCommandNames[] = { "NONE", @@ -247,7 +247,7 @@ static const char *const TheGuiCommandNames[] = "PLACE_BEACON", "SPECIAL_POWER_FROM_COMMAND_CENTER", - NULL + nullptr }; static_assert(ARRAY_SIZE(TheGuiCommandNames) == GUI_COMMAND_NUM_COMMANDS + 1, "Incorrect array size"); #endif // end DEFINE_GUI_COMMAND_NAMES @@ -271,7 +271,7 @@ static const LookupListRec CommandButtonMappedBorderTypeNames[] = { "ACTION", COMMAND_BUTTON_BORDER_ACTION }, { "SYSTEM", COMMAND_BUTTON_BORDER_SYSTEM }, - { NULL, 0 } + { nullptr, 0 } }; static_assert(ARRAY_SIZE(CommandButtonMappedBorderTypeNames) == COMMAND_BUTTON_BORDER_COUNT + 1, "Incorrect array size"); //------------------------------------------------------------------------------------------------- @@ -300,7 +300,7 @@ class CommandButton : public Overridable Bool isValidObjectTarget(const Object* sourceObj, const Object* targetObj) const; Bool isValidObjectTarget(const Drawable* source, const Drawable* target) const; - // Note: It is perfectly valid for either (or both!) of targetObj and targetLocation to be NULL. + // Note: It is perfectly valid for either (or both!) of targetObj and targetLocation to be nullptr. // This is a convenience function to make several calls to other functions. Bool isValidToUseOn(const Object *sourceObj, const Object *targetObj, const Coord3D *targetLocation, CommandSourceType commandSource) const; Bool isReady(const Object *sourceObj) const; @@ -434,29 +434,29 @@ class SideSelectWindowData public: SideSelectWindowData(void) { - generalSpeak = NULL; + generalSpeak = nullptr; m_currColor = 0; - m_gereralsNameWin = NULL; + m_gereralsNameWin = nullptr; m_lastTime = 0; - m_pTemplate = NULL; - m_sideNameWin = NULL; + m_pTemplate = nullptr; + m_sideNameWin = nullptr; m_startTime = 0; m_state = 0; - m_upgradeImage1 = NULL; - m_upgradeImage1Win = NULL; - m_upgradeImage2 = NULL; - m_upgradeImage2Win = NULL; - m_upgradeImage3 = NULL; - m_upgradeImage3Win = NULL; - m_upgradeImage4 = NULL; - m_upgradeImage4Win = NULL; + m_upgradeImage1 = nullptr; + m_upgradeImage1Win = nullptr; + m_upgradeImage2 = nullptr; + m_upgradeImage2Win = nullptr; + m_upgradeImage3 = nullptr; + m_upgradeImage3Win = nullptr; + m_upgradeImage4 = nullptr; + m_upgradeImage4Win = nullptr; m_upgradeImageSize.x = m_upgradeImageSize.y = 0; - m_upgradeLabel1Win = NULL; - m_upgradeLabel2Win = NULL; - m_upgradeLabel3Win = NULL; - m_upgradeLabel4Win = NULL; - sideWindow = NULL; + m_upgradeLabel1Win = nullptr; + m_upgradeLabel2Win = nullptr; + m_upgradeLabel3Win = nullptr; + m_upgradeLabel4Win = nullptr; + sideWindow = nullptr; } ~SideSelectWindowData(void); @@ -727,7 +727,7 @@ class ControlBar : public SubsystemInterface void setObservedPlayer(Player *player); ///< Sets the observed player. Used to present the game world as if that player was the local player. Player *getObservedPlayer() const { return m_observedPlayer; } ///< Return the observed player. Can return null. - /// Returns the currently viewed player. May return NULL if no player is selected while observing. + /// Returns the currently viewed player. May return nullptr if no player is selected while observing. Player* getCurrentlyViewedPlayer(); /// Returns the relationship with the currently viewed player. May return NEUTRAL if no player is selected while observing. Relationship getCurrentlyViewedPlayerRelationship(const Team* team); @@ -799,13 +799,13 @@ class ControlBar : public SubsystemInterface /// show/hide the portrait window image using the image from the object void setPortraitByObject( Object *obj ); - /// show rally point at world location, a NULL location will hide any visible rally point marker + /// show rally point at world location, a nullptr location will hide any visible rally point marker void showRallyPoint( const Coord3D *loc ); /// post process step, after all commands and command sets are loaded void postProcessCommands( void ); - // the following methods are for resetting data for vaious contexts + // the following methods are for resetting data for various contexts void resetCommonCommandData( void ); /// reset shared command data void resetContainData( void ); /// reset container data we use to tie controls to objects IDs for containment void resetBuildQueueData( void ); /// reset the build queue data we use to die queue entires to control @@ -958,7 +958,7 @@ class ControlBar : public SubsystemInterface void hideBuildTooltipLayout( void ); void deleteBuildTooltipLayout( void ); Bool getShowBuildTooltipLayout( void ){return m_showBuildToolTipLayout; } - void populateBuildTooltipLayout( const CommandButton *commandButton, GameWindow *tooltipWin = NULL ); + void populateBuildTooltipLayout( const CommandButton *commandButton, GameWindow *tooltipWin = nullptr ); void repopulateBuildTooltipLayout( void ); private: @@ -973,7 +973,7 @@ class ControlBar : public SubsystemInterface void setCommandBarBorder( GameWindow *button, CommandButtonMappedBorderType type); public: - void updateCommanBarBorderColors(Color build, Color action, Color upgrade, Color system ); + void updateCommandBarBorderColors(Color build, Color action, Color upgrade, Color system ); private: diff --git a/Generals/Code/GameEngine/Include/GameClient/ControlBarScheme.h b/Generals/Code/GameEngine/Include/GameClient/ControlBarScheme.h index 7c4852c2626..10871b80738 100644 --- a/Generals/Code/GameEngine/Include/GameClient/ControlBarScheme.h +++ b/Generals/Code/GameEngine/Include/GameClient/ControlBarScheme.h @@ -81,7 +81,7 @@ class ControlBarSchemeImage ICoord2D m_size; ///< the size of the image needed when we draw it Image *m_image; ///< the actual pointer to the mapped image - // m_layer is where the image will get drawn, everything in layer 0-2 gets drawn during the forground draw + // m_layer is where the image will get drawn, everything in layer 0-2 gets drawn during the foreground draw // the layers 3-5 gets drawn during the background draw Int m_layer; //layer means how deep the image will be drawn, it's a number between 0-5 with 0 being on top }; @@ -270,7 +270,7 @@ class ControlBarSchemeManager private: ControlBarScheme *m_currentScheme; ///< the current scheme that everythign uses - Coord2D m_multiplyer; + Coord2D m_multiplier; typedef std::list< ControlBarScheme* > ControlBarSchemeList; ///< list of control bar schemes ControlBarSchemeList m_schemeList; diff --git a/Generals/Code/GameEngine/Include/GameClient/Credits.h b/Generals/Code/GameEngine/Include/GameClient/Credits.h index bba068bd64f..5055907b0dd 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Credits.h +++ b/Generals/Code/GameEngine/Include/GameClient/Credits.h @@ -81,7 +81,7 @@ static const LookupListRec CreditStyleNames[] = { "NORMAL", CREDIT_STYLE_NORMAL }, { "COLUMN", CREDIT_STYLE_COLUMN }, // CREDIT_STYLE_BLANK - { NULL, 0 } + { nullptr, 0 } }; static_assert(ARRAY_SIZE(CreditStyleNames) == MAX_CREDIT_STYLES, "Incorrect array size"); diff --git a/Generals/Code/GameEngine/Include/GameClient/Display.h b/Generals/Code/GameEngine/Include/GameClient/Display.h index 3d6a9d857cc..33238a7a450 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Display.h +++ b/Generals/Code/GameEngine/Include/GameClient/Display.h @@ -84,7 +84,7 @@ class Display : public SubsystemInterface virtual Int getDisplayModeCount(void) {return 0;} ///getNextView(); - return NULL; + return nullptr; } virtual void drawViews( void ); ///< Render all views of the world @@ -133,7 +133,7 @@ class Display : public SubsystemInterface virtual void drawFillRect( Int startX, Int startY, Int width, Int height, UnsignedInt color ) = 0; - /// Draw a percentage of a rectange, much like a clock + /// Draw a percentage of a rectangle, much like a clock virtual void drawRectClock(Int startX, Int startY, Int width, Int height, Int percent, UnsignedInt color) = 0; virtual void drawRemainingRectClock(Int startX, Int startY, Int width, Int height, Int percent, UnsignedInt color) = 0; @@ -153,7 +153,7 @@ class Display : public SubsystemInterface virtual Bool isMoviePlaying(void); /// Register debug display callback - virtual void setDebugDisplayCallback( DebugDisplayCallback *callback, void *userData = NULL ); + virtual void setDebugDisplayCallback( DebugDisplayCallback *callback, void *userData = nullptr ); virtual DebugDisplayCallback *getDebugDisplayCallback(); virtual void setShroudLevel(Int x, Int y, CellShroudStatus setting ) = 0; ///< set shroud @@ -216,7 +216,7 @@ class Display : public SubsystemInterface // the singleton extern Display *TheDisplay; -extern void StatDebugDisplay( DebugDisplayInterface *dd, void *, FILE *fp = NULL ); +extern void StatDebugDisplay( DebugDisplayInterface *dd, void *, FILE *fp = nullptr ); //Necessary for display resolution confirmation dialog box //Holds the previous and current display settings diff --git a/Generals/Code/GameEngine/Include/GameClient/Drawable.h b/Generals/Code/GameEngine/Include/GameClient/Drawable.h index 8d4c158d7c4..2fa0fd40c63 100644 --- a/Generals/Code/GameEngine/Include/GameClient/Drawable.h +++ b/Generals/Code/GameEngine/Include/GameClient/Drawable.h @@ -311,6 +311,8 @@ class Drawable : public Thing, TintEnvelope *getColorTintEnvelope( void ) { return m_colorTintEnvelope; } void setColorTintEnvelope( TintEnvelope &source ) { if (m_colorTintEnvelope) *m_colorTintEnvelope = source; } + void imitateStealthLook( Drawable& otherDraw ); + void setTerrainDecal(TerrainDecalType type); ///m_wheelInfo : NULL; } + const TWheelInfo *getWheelInfo(void) const { return m_locoInfo ? &m_locoInfo->m_wheelInfo : nullptr; } // this method must ONLY be called from the client, NEVER From the logic, not even indirectly. Bool clientOnly_getFirstRenderObjInfo(Coord3D* pos, Real* boundingSphereRadius, Matrix3D* transform); @@ -478,7 +477,7 @@ class Drawable : public Thing, // this is a special-purpose call for W3DModelDraw. (srj) Bool getCurrentWorldspaceClientBonePositions(const char* boneName, Matrix3D& transform) const; - Bool getProjectileLaunchOffset(WeaponSlotType wslot, Int specificBarrelToUse, Matrix3D* launchPos, WhichTurretType tur, Coord3D* turretRotPos, Coord3D* turretPitchPos = NULL) const; + Bool getProjectileLaunchOffset(WeaponSlotType wslot, Int specificBarrelToUse, Matrix3D* launchPos, WhichTurretType tur, Coord3D* turretRotPos, Coord3D* turretPitchPos = nullptr) const; /** This call says, "I want the current animation (if any) to take n frames to complete a single cycle". @@ -490,7 +489,7 @@ class Drawable : public Thing, /** similar to the above, but assumes that the current state is a "ONCE", and is smart about transition states... if there is a transition state - "inbetween", it is included in the completion time. + "in between", it is included in the completion time. */ void setAnimationCompletionTime(UnsignedInt numFrames); void updateSubObjects(); @@ -538,8 +537,6 @@ class Drawable : public Thing, Bool getShouldAnimate( Bool considerPower ) const; - void friend_setParticle( Particle *particle ) { m_particle = particle; } - // flash drawable methods --------------------------------------------------------- Int getFlashCount( void ) { return m_flashCount; } void setFlashCount( Int count ) { m_flashCount = count; } @@ -555,9 +552,13 @@ class Drawable : public Thing, DrawableIconInfo* getIconInfo(); ///< lazily allocates, if necessary void killIcon(DrawableIconType t) { if (m_iconInfo) m_iconInfo->killIcon(t); } - Bool hasIconInfo() const { return m_iconInfo != NULL; } + Bool hasIconInfo() const { return m_iconInfo != nullptr; } + + const AudioEventRTS * getAmbientSound() const { return m_ambientSound == nullptr ? nullptr : &m_ambientSound->m_event; } + + Bool getReceivesDynamicLights( void ) { return m_receivesDynamicLights; }; + void setReceivesDynamicLights( Bool set ) { m_receivesDynamicLights = set; }; - const AudioEventRTS * getAmbientSound() const { return m_ambientSound == NULL ? NULL : &m_ambientSound->m_event; } protected: // snapshot methods @@ -636,7 +637,6 @@ class Drawable : public Thing, Real m_decalOpacity; Object *m_object; ///< object (if any) that this drawable represents - Particle *m_particle; ///< particle (if any) that this Drawable is associated with DrawableID m_id; ///< this drawable's unique ID Drawable *m_nextDrawable; @@ -694,6 +694,9 @@ class Drawable : public Thing, Bool m_hiddenByStealth; ///< drawable is hidden due to stealth Bool m_instanceIsIdentity; ///< If true, instance matrix can be skipped Bool m_drawableFullyObscuredByShroud; ///