3 Commits

Author SHA1 Message Date
Alexander Batalov 8d4057366e Handle objects in opGetRotationToTile
Fixes #302
2023-06-12 08:13:31 +03:00
Alexander Batalov 80b58bd174 clang-format 2023-06-03 08:18:12 +03:00
Alexander Batalov ca268ecb2c Fix global scripts on non-Windows platforms 2023-06-03 08:14:19 +03:00
187 changed files with 9412 additions and 13029 deletions
-1
View File
@@ -7,7 +7,6 @@
*.java text eol=lf
*.json text eol=lf
*.md text eol=lf
*.mm text eol=lf
*.plist text eol=lf
*.pro text eol=lf
*.properties text eol=lf
+86 -106
View File
@@ -26,7 +26,7 @@ jobs:
sudo apt install cppcheck
- name: Clone
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: cppcheck
run: cppcheck --std=c++17 src/
@@ -38,7 +38,7 @@ jobs:
steps:
- name: Clone
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: clang-format
run: find src -type f -name \*.cc -o -name \*.h | xargs clang-format --dry-run --Werror
@@ -50,7 +50,7 @@ jobs:
steps:
- name: Clone
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
@@ -60,10 +60,10 @@ jobs:
cache: gradle
- name: Cache cmake build
uses: actions/cache@v4
uses: actions/cache@v3
with:
path: os/android/app/.cxx
key: android-cmake-v2
key: android-cmake-v1
- name: Setup signing config
if: env.KEYSTORE_FILE_BASE64 != '' && env.KEYSTORE_PROPERTIES_FILE_BASE64 != ''
@@ -81,7 +81,7 @@ jobs:
./gradlew assembleDebug
- name: Upload
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: fallout2-ce-debug.apk
path: os/android/app/build/outputs/apk/debug/app-debug.apk
@@ -90,42 +90,53 @@ jobs:
ios:
name: iOS
runs-on: macos-13
runs-on: macos-12
steps:
- name: Clone
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Cache cmake build
uses: actions/cache@v4
uses: actions/cache@v3
with:
path: out
key: ios-cmake-v5
path: build
key: ios-cmake-v2
- name: Configure
run: |
cmake --preset ios
cmake \
-B build \
-D CMAKE_TOOLCHAIN_FILE=cmake/toolchain/ios.toolchain.cmake \
-D ENABLE_BITCODE=0 \
-D PLATFORM=OS64 \
-G Xcode \
-D CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY='' \
# EOL
- name: Build
run: |
cmake --build --preset ios-debug
cmake \
--build build \
--config RelWithDebInfo \
-j $(sysctl -n hw.physicalcpu) \
# EOL
- name: Pack
run: |
cd out/build/ios
cpack -C Debug
cd build
cpack -C RelWithDebInfo
- name: Upload
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: fallout2-ce.ipa
path: out/build/ios/fallout2-ce.ipa
path: build/fallout2-ce.ipa
retention-days: 7
linux:
name: Linux (${{ matrix.arch }})
runs-on: ubuntu-22.04
runs-on: ubuntu-20.04
strategy:
fail-fast: false
@@ -136,13 +147,14 @@ jobs:
steps:
- name: Clone
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Dependencies (x86)
if: matrix.arch == 'x86'
run: |
sudo dpkg --add-architecture i386
sudo apt update
sudo apt install --allow-downgrades libpcre2-8-0=10.34-7
sudo apt install g++-multilib libsdl2-dev:i386 zlib1g-dev:i386
- name: Dependencies (x64)
@@ -152,122 +164,83 @@ jobs:
sudo apt install libsdl2-dev zlib1g-dev
- name: Cache cmake build
uses: actions/cache@v4
uses: actions/cache@v3
with:
path: out
key: linux-${{ matrix.arch }}-cmake-v3
path: build
key: linux-${{ matrix.arch }}-cmake-v1
- name: Configure
run: |
cmake --preset linux-${{ matrix.arch }}-debug
- name: Build
run: |
cmake --build --preset linux-${{ matrix.arch }}-debug
- name: Upload
uses: actions/upload-artifact@v4
with:
name: fallout2-ce-linux-${{ matrix.arch }}
path: out/build/linux-${{ matrix.arch }}-debug/fallout2-ce
retention-days: 7
linux-armhf:
name: Linux (armhf)
runs-on: ubuntu-22.04-arm
steps:
- name: Clone
uses: actions/checkout@v4
- name: Dependencies
run: |
sudo dpkg --add-architecture armhf
sudo apt update
sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf libsdl2-dev:armhf zlib1g-dev:armhf
- name: Configure
- name: Configure (x86)
if: matrix.arch == 'x86'
run: |
cmake \
-B build \
-D CMAKE_BUILD_TYPE=Debug \
-D FALLOUT_VENDORED=OFF \
-D CMAKE_SYSTEM_PROCESSOR=arm \
-D CMAKE_C_COMPILER=arm-linux-gnueabihf-gcc \
-D CMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
-D CMAKE_TOOLCHAIN_FILE=cmake/toolchain/Linux32.cmake \
# EOL
- name: Configure (x64)
if: matrix.arch == 'x64'
run: |
cmake \
-B build \
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
# EOL
- name: Build
run: cmake --build build
- name: Upload
uses: actions/upload-artifact@v4
with:
name: fallout2-ce-linux-armhf
path: build/fallout2-ce
retention-days: 7
linux-arm64:
name: Linux (arm64)
runs-on: ubuntu-22.04-arm
steps:
- name: Clone
uses: actions/checkout@v4
- name: Dependencies
run: |
sudo apt update
sudo apt install libsdl2-dev zlib1g-dev
- name: Configure
run: cmake -B build -D CMAKE_BUILD_TYPE=Debug -D FALLOUT_VENDORED=OFF
- name: Build
run: cmake --build build
cmake \
--build build \
-j $(nproc) \
# EOL
- name: Upload
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: fallout2-ce-linux-arm64
name: fallout2-ce-linux-${{ matrix.arch }}
path: build/fallout2-ce
retention-days: 7
macos:
name: macOS
runs-on: macos-13
runs-on: macos-11
steps:
- name: Clone
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Cache cmake build
uses: actions/cache@v4
uses: actions/cache@v3
with:
path: out
key: macos-cmake-v6
path: build
key: macos-cmake-v4
- name: Configure
run: |
cmake --preset macos
cmake \
-B build \
-G Xcode \
-D CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY='' \
# EOL
- name: Build
run: |
cmake --build --preset macos-debug
cmake \
--build build \
--config RelWithDebInfo \
-j $(sysctl -n hw.physicalcpu) \
# EOL
- name: Pack
run: |
cd out/build/macos
cpack -C Debug
cd build
cpack -C RelWithDebInfo
- name: Upload
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: fallout2-ce-macos.dmg
path: out/build/macos/Fallout II Community Edition.dmg
path: build/Fallout II Community Edition.dmg
retention-days: 7
windows:
@@ -286,25 +259,32 @@ jobs:
steps:
- name: Clone
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Cache cmake build
uses: actions/cache@v4
uses: actions/cache@v3
with:
path: out
key: windows-${{ matrix.arch }}-cmake-v2
path: build
key: windows-${{ matrix.arch }}-cmake-v1
- name: Configure
run: |
cmake --preset windows-${{ matrix.arch }}
cmake \
-B build \
-G "Visual Studio 16 2019" \
-A ${{ matrix.generator-platform }} \
# EOL
- name: Build
run: |
cmake --build --preset windows-${{ matrix.arch }}-debug
cmake \
--build build \
--config RelWithDebInfo \
# EOL
- name: Upload
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v3
with:
name: fallout2-ce-windows-${{ matrix.arch }}
path: out/build/windows-${{ matrix.arch }}/Debug/fallout2-ce.exe
path: build/RelWithDebInfo/fallout2-ce.exe
retention-days: 7
+40 -49
View File
@@ -17,17 +17,17 @@ jobs:
steps:
- name: Clone
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Setup Java
uses: actions/setup-java@v3
uses: actions/setup-java@v2
with:
distribution: temurin
java-version: 11
cache: gradle
- name: Cache cmake build
uses: actions/cache@v4
uses: actions/cache@v3
with:
path: os/android/app/.cxx
key: android-cmake-v1
@@ -51,7 +51,7 @@ jobs:
run: |
cd os/android/app/build/outputs/apk/release
cp app-release.apk fallout2-ce-android.apk
gh release upload ${{ github.event.release.tag_name }} fallout2-ce-android.apk
gh release upload ${{ github.ref_name }} fallout2-ce-android.apk
rm fallout2-ce-android.apk
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -59,14 +59,14 @@ jobs:
ios:
name: iOS
runs-on: macos-12
runs-on: macos-11
steps:
- name: Clone
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Cache cmake build
uses: actions/cache@v4
uses: actions/cache@v3
with:
path: build
key: ios-cmake-v1
@@ -75,31 +75,25 @@ jobs:
run: |
cmake \
-B build \
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
-D CMAKE_TOOLCHAIN_FILE=cmake/toolchain/ios.toolchain.cmake \
-D ENABLE_BITCODE=0 \
-D PLATFORM=OS64 \
-G Xcode \
-D CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY='' \
# EOL
- name: Build
run: |
cmake \
--build build \
--config RelWithDebInfo \
-j $(sysctl -n hw.physicalcpu) \
--target package \
# EOL
- name: Pack
run: |
cd build
cpack -C RelWithDebInfo
- name: Upload
run: |
cd build
cp fallout2-ce.ipa fallout2-ce-ios.ipa
gh release upload ${{ github.event.release.tag_name }} fallout2-ce-ios.ipa
cp fallout2-ce.zip fallout2-ce-ios.ipa
gh release upload ${{ github.ref_name }} fallout2-ce-ios.ipa
rm fallout2-ce-ios.ipa
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -118,7 +112,7 @@ jobs:
steps:
- name: Clone
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Dependencies (x86)
if: matrix.arch == 'x86'
@@ -135,7 +129,7 @@ jobs:
sudo apt install libsdl2-dev zlib1g-dev
- name: Cache cmake build
uses: actions/cache@v4
uses: actions/cache@v3
with:
path: build
key: linux-${{ matrix.arch }}-cmake-v1
@@ -168,7 +162,7 @@ jobs:
run: |
cd build
tar -czvf fallout2-ce-linux-${{ matrix.arch }}.tar.gz fallout2-ce
gh release upload ${{ github.event.release.tag_name }} fallout2-ce-linux-${{ matrix.arch }}.tar.gz
gh release upload ${{ github.ref_name }} fallout2-ce-linux-${{ matrix.arch }}.tar.gz
rm fallout2-ce-linux-${{ matrix.arch }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -180,16 +174,16 @@ jobs:
steps:
- name: Clone
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Import code signing certificates
uses: apple-actions/import-codesign-certs@v2
uses: apple-actions/import-codesign-certs@v1
with:
p12-file-base64: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_FILE_BASE64 }}
p12-password: ${{ secrets.APPLE_DEVELOPER_CERTIFICATE_P12_PASSWORD }}
- name: Cache cmake build
uses: actions/cache@v4
uses: actions/cache@v3
with:
path: build
key: macos-cmake-v3
@@ -198,44 +192,41 @@ jobs:
run: |
cmake \
-B build \
-G Xcode \
-D CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY="${{ secrets.APPLE_DEVELOPER_CERTIFICATE_IDENTITY }}" \
-D CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_INJECT_BASE_ENTITLEMENTS="NO" \
-D CMAKE_XCODE_ATTRIBUTE_OTHER_CODE_SIGN_FLAGS="--options=runtime --timestamp" \
-D CMAKE_BUILD_TYPE=RelWithDebInfo \
-D CPACK_BUNDLE_APPLE_CERT_APP="${{ secrets.APPLE_DEVELOPER_CERTIFICATE_IDENTITY }}" \
# EOL
- name: Build
run: |
cmake \
--build build \
--config RelWithDebInfo \
-j $(sysctl -n hw.physicalcpu) \
--target package \
# EOL
- name: Pack
run: |
cd build
cpack -C RelWithDebInfo
- name: Notarize
run: |
xcrun notarytool submit \
"build/Fallout II Community Edition.dmg" \
--apple-id "${{ secrets.APPLE_DEVELOPER_AC_USERNAME }}" \
--team-id "${{ secrets.APPLE_DEVELOPER_AC_TEAM }}" \
--password "${{ secrets.APPLE_DEVELOPER_AC_PASSWORD }}" \
--wait
- name: Staple
run: |
xcrun stapler staple \
"build/Fallout II Community Edition.dmg"
brew install mitchellh/gon/gon
cat << EOF > config.json
{
"notarize": {
"path": "build/fallout2-ce.dmg",
"bundle_id": "$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" build/fallout2-ce.app/Contents/Info.plist)",
"staple": true
}
}
EOF
gon config.json
rm config.json
env:
AC_USERNAME: ${{ secrets.APPLE_DEVELOPER_AC_USERNAME }}
AC_PASSWORD: ${{ secrets.APPLE_DEVELOPER_AC_PASSWORD }}
- name: Upload
run: |
cd build
cp "Fallout II Community Edition.dmg" fallout2-ce-macos.dmg
gh release upload ${{ github.event.release.tag_name }} fallout2-ce-macos.dmg
cp fallout2-ce.dmg fallout2-ce-macos.dmg
gh release upload ${{ github.ref_name }} fallout2-ce-macos.dmg
rm fallout2-ce-macos.dmg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -256,10 +247,10 @@ jobs:
steps:
- name: Clone
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: Cache cmake build
uses: actions/cache@v4
uses: actions/cache@v3
with:
path: build
key: windows-${{ matrix.arch }}-cmake-v1
@@ -283,7 +274,7 @@ jobs:
run: |
cd build/RelWithDebInfo
7z a fallout2-ce-windows-${{ matrix.arch }}.zip fallout2-ce.exe
gh release upload ${{ github.event.release.tag_name }} fallout2-ce-windows-${{ matrix.arch }}.zip
gh release upload ${{ github.ref_name }} fallout2-ce-windows-${{ matrix.arch }}.zip
rm fallout2-ce-windows-${{ matrix.arch }}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-1
View File
@@ -391,4 +391,3 @@ FodyWeavers.xsd
# CMake
/out
/build
CMakeUserPresets.json
+15 -14
View File
@@ -6,10 +6,10 @@ set(EXECUTABLE_NAME fallout2-ce)
if(APPLE)
if(IOS)
set(CMAKE_OSX_DEPLOYMENT_TARGET "12" CACHE STRING "")
set(CMAKE_OSX_DEPLOYMENT_TARGET "11" CACHE STRING "")
set(CMAKE_OSX_ARCHITECTURES "arm64" CACHE STRING "")
else()
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "")
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.11" CACHE STRING "")
set(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "")
endif()
endif()
@@ -20,8 +20,6 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
option(FALLOUT_VENDORED "Use vendored third-party libraries" ON)
if(ANDROID)
add_library(${EXECUTABLE_NAME} SHARED)
else()
@@ -255,8 +253,6 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
target_sources(${EXECUTABLE_NAME} PUBLIC
"src/audio_engine.cc"
"src/audio_engine.h"
"src/delay.cc"
"src/delay.h"
"src/fps_limiter.cc"
"src/fps_limiter.h"
"src/platform_compat.cc"
@@ -279,8 +275,6 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
"src/sfall_kb_helpers.h"
"src/sfall_lists.cc"
"src/sfall_lists.h"
"src/sfall_metarules.cc"
"src/sfall_metarules.h"
"src/sfall_opcodes.cc"
"src/sfall_opcodes.h"
"src/sfall_arrays.cc"
@@ -358,14 +352,15 @@ if(APPLE)
endif()
set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.alexbatalov.fallout2-ce")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "1.3.0")
set(MACOSX_BUNDLE_BUNDLE_VERSION "1.3.0")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "1.2.0")
set(MACOSX_BUNDLE_BUNDLE_VERSION "1.2.0")
endif()
add_subdirectory("third_party/fpattern")
target_link_libraries(${EXECUTABLE_NAME} fpattern::fpattern)
target_link_libraries(${EXECUTABLE_NAME} ${FPATTERN_LIBRARY})
target_include_directories(${EXECUTABLE_NAME} PRIVATE ${FPATTERN_INCLUDE_DIR})
if(FALLOUT_VENDORED)
if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_subdirectory("third_party/zlib")
add_subdirectory("third_party/sdl2")
else()
@@ -390,9 +385,15 @@ if(APPLE)
else()
install(TARGETS ${EXECUTABLE_NAME} DESTINATION .)
if(CPACK_BUNDLE_APPLE_CERT_APP)
install(CODE "
execute_process(COMMAND codesign --deep --force --options runtime --sign \"${CPACK_BUNDLE_APPLE_CERT_APP}\" ${CMAKE_BINARY_DIR}/Fallout II Community Edition.app)
"
COMPONENT Runtime)
endif()
set(CPACK_GENERATOR "DragNDrop")
set(CPACK_DMG_DS_STORE_SETUP_SCRIPT "${CMAKE_SOURCE_DIR}/os/macos/dmg/setup.scpt")
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/os/macos/dmg/background.png")
set(CPACK_DMG_DISABLE_APPLICATIONS_SYMLINK ON)
set(CPACK_PACKAGE_FILE_NAME "Fallout II Community Edition")
endif()
-196
View File
@@ -1,196 +0,0 @@
{
"version": 6,
"cmakeMinimumRequired": {
"major": 3,
"minor": 19,
"patch": 0
},
"configurePresets": [
{
"name": "base",
"hidden": true,
"binaryDir": "${sourceDir}/out/build/${presetName}"
},
{
"name": "windows-base",
"hidden": true,
"inherits": [
"base"
],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Windows"
}
},
{
"name": "windows-x86",
"inherits": [
"windows-base"
],
"generator": "Visual Studio 16 2019",
"architecture": "Win32"
},
{
"name": "windows-x64",
"inherits": [
"windows-base"
],
"generator": "Visual Studio 16 2019",
"architecture": "x64"
},
{
"name": "linux-base",
"hidden": true,
"inherits": [
"base"
],
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Linux"
},
"cacheVariables": {
"FALLOUT_VENDORED": "OFF"
}
},
{
"name": "linux-x86-base",
"hidden": true,
"inherits": [
"linux-base"
],
"cacheVariables": {
"CMAKE_C_FLAGS": "-m32",
"CMAKE_CXX_FLAGS": "-m32",
"CMAKE_SYSTEM_NAME": "Linux",
"CMAKE_SYSTEM_PROCESSOR": "i386"
}
},
{
"name": "linux-x86-debug",
"inherits": [
"linux-x86-base"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "linux-x86-release",
"inherits": [
"linux-x86-base"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "linux-x64-debug",
"inherits": [
"linux-base"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug"
}
},
{
"name": "linux-x64-release",
"inherits": [
"linux-base"
],
"cacheVariables": {
"CMAKE_BUILD_TYPE": "RelWithDebInfo"
}
},
{
"name": "darwin-base",
"hidden": true,
"inherits": [
"base"
],
"generator": "Xcode",
"cacheVariables": {
"CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY": ""
},
"condition": {
"type": "equals",
"lhs": "${hostSystemName}",
"rhs": "Darwin"
}
},
{
"name": "macos",
"inherits": [
"darwin-base"
]
},
{
"name": "ios",
"inherits": [
"darwin-base"
],
"cacheVariables": {
"CMAKE_SYSTEM_NAME": "iOS"
}
}
],
"buildPresets": [
{
"name": "windows-x86-debug",
"configurePreset": "windows-x86",
"configuration": "Debug"
},
{
"name": "windows-x86-release",
"configurePreset": "windows-x86",
"configuration": "Release"
},
{
"name": "windows-x64-debug",
"configurePreset": "windows-x64",
"configuration": "Debug"
},
{
"name": "windows-x64-release",
"configurePreset": "windows-x64",
"configuration": "Release"
},
{
"name": "linux-x86-debug",
"configurePreset": "linux-x86-debug"
},
{
"name": "linux-x86-release",
"configurePreset": "linux-x86-release"
},
{
"name": "linux-x64-debug",
"configurePreset": "linux-x64-debug"
},
{
"name": "linux-x64-release",
"configurePreset": "linux-x64-release"
},
{
"name": "macos-debug",
"configurePreset": "macos",
"configuration": "Debug"
},
{
"name": "macos-release",
"configurePreset": "macos",
"configuration": "RelWithDebInfo"
},
{
"name": "ios-debug",
"configurePreset": "ios",
"configuration": "Debug"
},
{
"name": "ios-release",
"configurePreset": "ios",
"configuration": "RelWithDebInfo"
}
]
}
+50
View File
@@ -0,0 +1,50 @@
{
"configurations": [
{
"name": "x86-Debug",
"generator": "Visual Studio 16 2019",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x86" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x86-Release",
"generator": "Visual Studio 16 2019",
"configurationType": "Release",
"inheritEnvironments": [ "msvc_x86" ],
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": ""
},
{
"name": "x64-Debug",
"generator": "Visual Studio 16 2019 Win64",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": []
},
{
"name": "x64-Release",
"generator": "Visual Studio 16 2019 Win64",
"configurationType": "Release",
"buildRoot": "${projectDir}\\out\\build\\${name}",
"installRoot": "${projectDir}\\out\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": []
}
]
}
+1 -1
View File
@@ -8,7 +8,7 @@ There is also [Fallout Community Edition](https://github.com/alexbatalov/fallout
## Installation
You must own the game to play. Purchase your copy on [GOG](https://www.gog.com/game/fallout_2), [Epic Games](https://store.epicgames.com/p/fallout-2) or [Steam](https://store.steampowered.com/app/38410). Download latest [release](https://github.com/alexbatalov/fallout2-ce/releases) or build from source. You can also check latest [debug](https://github.com/alexbatalov/fallout2-ce/actions) build intended for testers.
You must own the game to play. Purchase your copy on [GOG](https://www.gog.com/game/fallout_2) or [Steam](https://store.steampowered.com/app/38410). Download latest [release](https://github.com/alexbatalov/fallout2-ce/releases) or build from source. You can also check latest [debug](https://github.com/alexbatalov/fallout2-ce/actions) build intended for testers.
### Windows
+4
View File
@@ -0,0 +1,4 @@
set( CMAKE_SYSTEM_NAME "Linux" )
set( CMAKE_SYSTEM_PROCESSOR "i386" )
set( CMAKE_C_FLAGS "-m32" )
set( CMAKE_CXX_FLAGS "-m32" )
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -9,8 +9,8 @@ android {
applicationId 'com.alexbatalov.fallout2ce'
minSdk 21
targetSdk 32
versionCode 4
versionName '1.3.0'
versionCode 3
versionName '1.2.0'
externalNativeBuild {
cmake {
arguments '-DANDROID_STL=c++_static'
-2
View File
@@ -24,8 +24,6 @@
<string>11.0</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>UIApplicationSupportsIndirectInputEvents</key>
Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

-46
View File
@@ -1,46 +0,0 @@
on run argv
set image_name to item 1 of argv
tell application "Finder"
tell disk image_name
set open_attempts to 0
repeat while open_attempts < 4
try
open
delay 1
set open_attempts to 5
close
on error errStr number errorNumber
set open_attempts to open_attempts + 1
delay 10
end try
end repeat
delay 5
open
set current view of container window to icon view
set theViewOptions to the icon view options of container window
set background picture of theViewOptions to file ".background:background.png"
set arrangement of theViewOptions to not arranged
set icon size of theViewOptions to 128
delay 5
close
open
update without registering applications
tell container window
set sidebar width to 0
set statusbar visible to false
set toolbar visible to false
set the bounds to {400, 100, 1040, 609}
set position of item "Fallout II Community Edition.app" to {160, 240}
set position of item "Applications" to {480, 240}
end tell
update without registering applications
delay 5
close
end tell
delay 1
end tell
end run
+168 -171
View File
@@ -48,9 +48,6 @@ typedef enum ScienceRepairTargetType {
// 0x5106D0
static bool _action_in_explode = false;
// 0x5106D4
int rotation;
// 0x5106E0
static const int gNormalDeathAnimations[DAMAGE_TYPE_COUNT] = {
ANIM_DANCING_AUTOFIRE,
@@ -88,7 +85,7 @@ static int _is_next_to(Object* a1, Object* a2);
static int _action_climb_ladder(Object* a1, Object* a2);
static int _action_use_skill_in_combat_error(Object* critter);
static int _pick_fall(Object* obj, int anim);
static int _report_explosion(Attack* attack, Object* sourceObj);
static int _report_explosion(Attack* attack, Object* a2);
static int _finished_explosion(Object* a1, Object* a2);
static int _compute_explosion_damage(int min, int max, Object* defender, int* knockbackDistancePtr);
static int _can_talk_to(Object* a1, Object* a2);
@@ -121,7 +118,7 @@ int actionKnockdown(Object* obj, int* anim, int maxDistance, int rotation, int d
int tile;
for (distance = 1; distance <= maxDistance; distance++) {
tile = tileGetTileInDirection(obj->tile, rotation, distance);
if (_obj_blocking_at(obj, tile, obj->elevation) != nullptr) {
if (_obj_blocking_at(obj, tile, obj->elevation) != NULL) {
distance--;
break;
}
@@ -187,7 +184,7 @@ int _pick_death(Object* attacker, Object* defender, Object* weapon, int damage,
int damageType = weaponGetDamageType(attacker, weapon);
if (weapon != nullptr && weapon->pid == PROTO_ID_MOLOTOV_COCKTAIL) {
if (weapon != NULL && weapon->pid == PROTO_ID_MOLOTOV_COCKTAIL) {
normalViolenceLevelDamageThreshold = 5;
maximumBloodViolenceLevelDamageThreshold = 15;
damageType = DAMAGE_TYPE_FIRE;
@@ -199,7 +196,7 @@ int _pick_death(Object* attacker, Object* defender, Object* weapon, int damage,
maximumBloodViolenceLevelDamageThreshold = 1;
}
if (weapon != nullptr && weaponGetPerk(weapon) == PERK_WEAPON_FLAMEBOY) {
if (weapon != NULL && weaponGetPerk(weapon) == PERK_WEAPON_FLAMEBOY) {
normalViolenceLevelDamageThreshold /= 3;
maximumBloodViolenceLevelDamageThreshold /= 3;
}
@@ -371,9 +368,9 @@ void _show_damage_to_object(Object* defender, int damage, int flags, Object* wea
while (true) {
int tile = tileGetTileInDirection(defender->tile, (rotation + randomRotation) % ROTATION_COUNT, distance);
if (!isExitGridAt(tile, defender->elevation)) {
Object* obstacle = nullptr;
_make_straight_path(defender, defender->tile, tile, nullptr, &obstacle, 4);
if (obstacle == nullptr) {
Object* obstacle = NULL;
_make_straight_path(defender, defender->tile, tile, NULL, &obstacle, 4);
if (obstacle == NULL) {
animationRegisterRotateToTile(defender, tile);
animationRegisterMoveToTileStraight(defender, tile, defender->elevation, anim, 0);
break;
@@ -443,7 +440,7 @@ void _show_damage_to_object(Object* defender, int damage, int flags, Object* wea
}
}
if (weapon != nullptr) {
if (weapon != NULL) {
if ((flags & DAM_EXPLODE) != 0) {
animationRegisterCallbackForced(defender, weapon, (AnimationCallback*)_obj_drop, -1);
fid = buildFid(OBJ_TYPE_MISC, 10, 0, 0, 0);
@@ -544,7 +541,7 @@ void _show_damage(Attack* attack, int attackerAnimation, int delay)
_show_damage_to_object(attack->attacker, attack->attackerDamage, attack->attackerFlags, attack->weapon, 1, 0, 0, attackerAnimation, attack->attacker, -1);
}
} else {
if (attack->defender != nullptr) {
if (attack->defender != NULL) {
// NOTE: Uninline.
bool hitFromFront = _is_hit_from_front(attack->defender, attack->attacker);
@@ -609,7 +606,7 @@ int _action_melee(Attack* attack, int anim)
fid = buildFid(OBJ_TYPE_CRITTER, attack->attacker->fid & 0xFFF, anim, (attack->attacker->fid & 0xF000) >> 12, attack->attacker->rotation + 1);
art = artLock(fid, &cache_entry);
if (art != nullptr) {
if (art != NULL) {
delay = artGetActionFrame(art);
} else {
delay = 0;
@@ -649,7 +646,7 @@ int _action_melee(Attack* attack, int anim)
} else {
fid = buildFid(OBJ_TYPE_CRITTER, attack->defender->fid & 0xFFF, ANIM_DODGE_ANIM, (attack->defender->fid & 0xF000) >> 12, attack->defender->rotation + 1);
art = artLock(fid, &cache_entry);
if (art != nullptr) {
if (art != NULL) {
int dodgeDelay = artGetActionFrame(art);
artUnlock(cache_entry);
@@ -693,14 +690,14 @@ int _action_ranged(Attack* attack, int anim)
{
Object* adjacentObjects[ROTATION_COUNT];
for (int rotation = 0; rotation < ROTATION_COUNT; rotation++) {
adjacentObjects[rotation] = nullptr;
adjacentObjects[rotation] = NULL;
}
reg_anim_begin(ANIMATION_REQUEST_RESERVED);
_register_priority(1);
Object* projectile = nullptr;
Object* replacedWeapon = nullptr;
Object* projectile = NULL;
Object* replacedWeapon = NULL;
int weaponFid = -1;
Proto* weaponProto;
@@ -710,7 +707,7 @@ int _action_ranged(Attack* attack, int anim)
int fid = buildFid(OBJ_TYPE_CRITTER, attack->attacker->fid & 0xFFF, anim, (attack->attacker->fid & 0xF000) >> 12, attack->attacker->rotation + 1);
CacheEntry* artHandle;
Art* art = artLock(fid, &artHandle);
int delay = (art != nullptr) ? artGetActionFrame(art) : 0;
int delay = (art != NULL) ? artGetActionFrame(art) : 0;
artUnlock(artHandle);
weaponGetRange(attack->attacker, attack->hitMode);
@@ -761,11 +758,11 @@ int _action_ranged(Attack* attack, int anim)
itemRemove(attack->attacker, weapon, 1);
replacedWeapon = itemReplace(attack->attacker, weapon, weaponFlags & OBJECT_IN_ANY_HAND);
objectSetFid(projectile, projectileProto->fid, nullptr);
objectSetFid(projectile, projectileProto->fid, NULL);
_cAIPrepWeaponItem(attack->attacker, weapon);
if (attack->attacker == gDude) {
if (replacedWeapon == nullptr) {
if (replacedWeapon == NULL) {
if ((weaponFlags & OBJECT_IN_LEFT_HAND) != 0) {
leftItemAction = INTERFACE_ITEM_ACTION_DEFAULT;
} else if ((weaponFlags & OBJECT_IN_RIGHT_HAND) != 0) {
@@ -775,25 +772,25 @@ int _action_ranged(Attack* attack, int anim)
interfaceUpdateItems(false, leftItemAction, rightItemAction);
}
_obj_connect(weapon, attack->attacker->tile, attack->attacker->elevation, nullptr);
_obj_connect(weapon, attack->attacker->tile, attack->attacker->elevation, NULL);
} else {
objectCreateWithFidPid(&projectile, projectileProto->fid, -1);
}
objectHide(projectile, nullptr);
objectHide(projectile, NULL);
// SFALL
if (explosionEmitsLight() && projectile->lightIntensity == 0) {
objectSetLight(projectile, projectileProto->item.lightDistance, projectileProto->item.lightIntensity, nullptr);
objectSetLight(projectile, projectileProto->item.lightDistance, projectileProto->item.lightIntensity, NULL);
} else {
objectSetLight(projectile, 9, projectile->lightIntensity, nullptr);
objectSetLight(projectile, 9, projectile->lightIntensity, NULL);
}
int projectileOrigin = _combat_bullet_start(attack->attacker, attack->defender);
objectSetLocation(projectile, projectileOrigin, attack->attacker->elevation, nullptr);
objectSetLocation(projectile, projectileOrigin, attack->attacker->elevation, NULL);
int projectileRotation = tileGetRotationTo(attack->attacker->tile, attack->defender->tile);
objectSetRotation(projectile, projectileRotation, nullptr);
objectSetRotation(projectile, projectileRotation, NULL);
animationRegisterUnsetFlag(projectile, OBJECT_HIDDEN, delay);
@@ -803,7 +800,7 @@ int _action_ranged(Attack* attack, int anim)
int explosionCenterTile;
if ((attack->attackerFlags & DAM_HIT) != 0) {
animationRegisterMoveToTileStraight(projectile, attack->defender->tile, attack->defender->elevation, ANIM_WALK, 0);
delay = _make_straight_path(projectile, projectileOrigin, attack->defender->tile, nullptr, nullptr, 32) - 1;
delay = _make_straight_path(projectile, projectileOrigin, attack->defender->tile, NULL, NULL, 32) - 1;
explosionCenterTile = attack->defender->tile;
} else {
animationRegisterMoveToTileStraight(projectile, attack->tile, attack->defender->elevation, ANIM_WALK, 0);
@@ -865,10 +862,10 @@ int _action_ranged(Attack* attack, int anim)
for (int rotation = startRotation; rotation < endRotation; rotation++) {
if (objectCreateWithFidPid(&(adjacentObjects[rotation]), explosionFid, -1) != -1) {
objectHide(adjacentObjects[rotation], nullptr);
objectHide(adjacentObjects[rotation], NULL);
int adjacentTile = tileGetTileInDirection(explosionCenterTile, rotation, 1);
objectSetLocation(adjacentObjects[rotation], adjacentTile, projectile->elevation, nullptr);
objectSetLocation(adjacentObjects[rotation], adjacentTile, projectile->elevation, NULL);
int delay;
if (rotation != ROTATION_NE) {
@@ -923,7 +920,7 @@ int _action_ranged(Attack* attack, int anim)
}
// SFALL
if (projectile != nullptr && (isGrenade || damageType == explosionGetDamageType())) {
if (projectile != NULL && (isGrenade || damageType == explosionGetDamageType())) {
// CE: Use custom callback to hide projectile instead of relying on
// `animationRegisterHideObjectForced`. The problem is that completing
// `ANIM_KIND_HIDE` removes (frees) object entirely. When this happens
@@ -934,12 +931,12 @@ int _action_ranged(Attack* attack, int anim)
// `opDestroyObject` for self-deleting objects (mark it hidden +
// no-save).
animationRegisterCallbackForced(attack, projectile, hideProjectile, -1);
} else if (anim == ANIM_THROW_ANIM && projectile != nullptr) {
} else if (anim == ANIM_THROW_ANIM && projectile != NULL) {
animationRegisterSetFid(projectile, weaponFid, -1);
}
for (int rotation = 0; rotation < ROTATION_COUNT; rotation++) {
if (adjacentObjects[rotation] != nullptr) {
if (adjacentObjects[rotation] != NULL) {
animationRegisterHideObjectForced(adjacentObjects[rotation]);
}
}
@@ -947,7 +944,7 @@ int _action_ranged(Attack* attack, int anim)
if ((attack->attackerFlags & (DAM_KNOCKED_OUT | DAM_KNOCKED_DOWN | DAM_DEAD)) == 0) {
if (anim == ANIM_THROW_ANIM) {
bool takeOutAnimationRegistered = false;
if (replacedWeapon != nullptr) {
if (replacedWeapon != NULL) {
int weaponAnimationCode = weaponGetAnimationCode(replacedWeapon);
if (weaponAnimationCode != 0) {
animationRegisterTakeOutWeapon(attack->attacker, weaponAnimationCode, -1);
@@ -966,13 +963,13 @@ int _action_ranged(Attack* attack, int anim)
if (reg_anim_end() == -1) {
debugPrint("Something went wrong with a ranged attack sequence!\n");
if (projectile != nullptr && (isGrenade || damageType == DAMAGE_TYPE_EXPLOSION || anim != ANIM_THROW_ANIM)) {
objectDestroy(projectile, nullptr);
if (projectile != NULL && (isGrenade || damageType == DAMAGE_TYPE_EXPLOSION || anim != ANIM_THROW_ANIM)) {
objectDestroy(projectile, NULL);
}
for (int rotation = 0; rotation < ROTATION_COUNT; rotation++) {
if (adjacentObjects[rotation] != nullptr) {
objectDestroy(adjacentObjects[rotation], nullptr);
if (adjacentObjects[rotation] != NULL) {
objectDestroy(adjacentObjects[rotation], NULL);
}
}
@@ -1060,21 +1057,21 @@ int _action_climb_ladder(Object* a1, Object* a2)
}
// 0x411F2C
int _action_use_an_item_on_object(Object* user, Object* targetObj, Object* item)
int _action_use_an_item_on_object(Object* a1, Object* a2, Object* a3)
{
Proto* proto = nullptr;
int type = FID_TYPE(targetObj->fid);
Proto* proto = NULL;
int type = FID_TYPE(a2->fid);
int sceneryType = -1;
if (type == OBJ_TYPE_SCENERY) {
if (protoGetProto(targetObj->pid, &proto) == -1) {
if (protoGetProto(a2->pid, &proto) == -1) {
return -1;
}
sceneryType = proto->scenery.type;
}
if (sceneryType != SCENERY_TYPE_LADDER_UP || item != nullptr) {
if (user == gDude) {
if (sceneryType != SCENERY_TYPE_LADDER_UP || a3 != NULL) {
if (a1 == gDude) {
int anim = FID_ANIM_TYPE(gDude->fid);
if (anim == ANIM_WALK || anim == ANIM_RUNNING) {
reg_anim_clear(gDude);
@@ -1085,40 +1082,40 @@ int _action_use_an_item_on_object(Object* user, Object* targetObj, Object* item)
int actionPoints;
if (isInCombat()) {
animationRequestOptions = ANIMATION_REQUEST_RESERVED;
actionPoints = user->data.critter.combat.ap;
actionPoints = a1->data.critter.combat.ap;
} else {
animationRequestOptions = ANIMATION_REQUEST_UNRESERVED;
actionPoints = -1;
}
if (user == gDude) {
if (a1 == gDude) {
animationRequestOptions = ANIMATION_REQUEST_RESERVED;
}
reg_anim_begin(animationRequestOptions);
if (actionPoints != -1 || objectGetDistanceBetween(user, targetObj) < 5) {
animationRegisterMoveToObject(user, targetObj, actionPoints, 0);
if (actionPoints != -1 || objectGetDistanceBetween(a1, a2) < 5) {
animationRegisterMoveToObject(a1, a2, actionPoints, 0);
} else {
animationRegisterRunToObject(user, targetObj, -1, 0);
animationRegisterRunToObject(a1, a2, -1, 0);
}
animationRegisterCallbackForced(user, targetObj, (AnimationCallback*)_is_next_to, -1);
animationRegisterCallbackForced(a1, a2, (AnimationCallback*)_is_next_to, -1);
if (item == nullptr) {
animationRegisterCallback(user, targetObj, (AnimationCallback*)_check_scenery_ap_cost, -1);
if (a3 == NULL) {
animationRegisterCallback(a1, a2, (AnimationCallback*)_check_scenery_ap_cost, -1);
}
int weaponAnimCode = (user->fid & 0xF000) >> 12;
if (weaponAnimCode != 0) {
const char* sfx = sfxBuildCharName(user, ANIM_PUT_AWAY, CHARACTER_SOUND_EFFECT_UNUSED);
animationRegisterPlaySoundEffect(user, sfx, -1);
animationRegisterAnimate(user, ANIM_PUT_AWAY, 0);
int a2a = (a1->fid & 0xF000) >> 12;
if (a2a != 0) {
const char* sfx = sfxBuildCharName(a1, ANIM_PUT_AWAY, CHARACTER_SOUND_EFFECT_UNUSED);
animationRegisterPlaySoundEffect(a1, sfx, -1);
animationRegisterAnimate(a1, ANIM_PUT_AWAY, 0);
}
int anim;
int objectType = FID_TYPE(targetObj->fid);
if (objectType == OBJ_TYPE_CRITTER && _critter_is_prone(targetObj)) {
int objectType = FID_TYPE(a2->fid);
if (objectType == OBJ_TYPE_CRITTER && _critter_is_prone(a2)) {
anim = ANIM_MAGIC_HANDS_GROUND;
} else if (objectType == OBJ_TYPE_SCENERY && (proto->scenery.extendedFlags & 0x01) != 0) {
anim = ANIM_MAGIC_HANDS_GROUND;
@@ -1126,31 +1123,31 @@ int _action_use_an_item_on_object(Object* user, Object* targetObj, Object* item)
anim = ANIM_MAGIC_HANDS_MIDDLE;
}
if (sceneryType != SCENERY_TYPE_STAIRS && item == nullptr) {
animationRegisterAnimate(user, anim, -1);
if (sceneryType != SCENERY_TYPE_STAIRS && a3 == NULL) {
animationRegisterAnimate(a1, anim, -1);
}
if (item != nullptr) {
if (a3 != NULL) {
// TODO: Get rid of cast.
animationRegisterCallback3(user, targetObj, item, (AnimationCallback3*)_obj_use_item_on, -1);
animationRegisterCallback3(a1, a2, a3, (AnimationCallback3*)_obj_use_item_on, -1);
} else {
animationRegisterCallback(user, targetObj, (AnimationCallback*)_obj_use, -1);
animationRegisterCallback(a1, a2, (AnimationCallback*)_obj_use, -1);
}
if (weaponAnimCode != 0) {
animationRegisterTakeOutWeapon(user, weaponAnimCode, -1);
if (a2a != 0) {
animationRegisterTakeOutWeapon(a1, a2a, -1);
}
return reg_anim_end();
}
return _action_climb_ladder(user, targetObj);
return _action_climb_ladder(a1, a2);
}
// 0x412114
int _action_use_an_object(Object* user, Object* targetObj)
int _action_use_an_object(Object* a1, Object* a2)
{
return _action_use_an_item_on_object(user, targetObj, nullptr);
return _action_use_an_item_on_object(a1, a2, NULL);
}
// 0x412134
@@ -1193,7 +1190,7 @@ int actionPickUp(Object* critter, Object* item)
int actionFrame;
CacheEntry* cacheEntry;
Art* art = artLock(fid, &cacheEntry);
if (art != nullptr) {
if (art != NULL) {
actionFrame = artGetActionFrame(art);
} else {
actionFrame = -1;
@@ -1225,7 +1222,7 @@ int actionPickUp(Object* critter, Object* item)
int actionFrame;
CacheEntry* cacheEntry;
Art* art = artLock(fid, &cacheEntry);
if (art == nullptr) {
if (art == NULL) {
actionFrame = artGetActionFrame(art);
artUnlock(cacheEntry);
} else {
@@ -1322,27 +1319,27 @@ static int _action_use_skill_in_combat_error(Object* critter)
// skill_use
// 0x41255C
int actionUseSkill(Object* user, Object* target, int skill)
int actionUseSkill(Object* a1, Object* a2, int skill)
{
switch (skill) {
case SKILL_FIRST_AID:
case SKILL_DOCTOR:
if (isInCombat()) {
// NOTE: Uninline.
return _action_use_skill_in_combat_error(user);
return _action_use_skill_in_combat_error(a1);
}
if (PID_TYPE(target->pid) != OBJ_TYPE_CRITTER) {
if (PID_TYPE(a2->pid) != OBJ_TYPE_CRITTER) {
return -1;
}
break;
case SKILL_LOCKPICK:
if (isInCombat()) {
// NOTE: Uninline.
return _action_use_skill_in_combat_error(user);
return _action_use_skill_in_combat_error(a1);
}
if (PID_TYPE(target->pid) != OBJ_TYPE_ITEM && PID_TYPE(target->pid) != OBJ_TYPE_SCENERY) {
if (PID_TYPE(a2->pid) != OBJ_TYPE_ITEM && PID_TYPE(a2->pid) != OBJ_TYPE_SCENERY) {
return -1;
}
@@ -1350,14 +1347,14 @@ int actionUseSkill(Object* user, Object* target, int skill)
case SKILL_STEAL:
if (isInCombat()) {
// NOTE: Uninline.
return _action_use_skill_in_combat_error(user);
return _action_use_skill_in_combat_error(a1);
}
if (PID_TYPE(target->pid) != OBJ_TYPE_ITEM && PID_TYPE(target->pid) != OBJ_TYPE_CRITTER) {
if (PID_TYPE(a2->pid) != OBJ_TYPE_ITEM && PID_TYPE(a2->pid) != OBJ_TYPE_CRITTER) {
return -1;
}
if (target == user) {
if (a2 == a1) {
return -1;
}
@@ -1365,10 +1362,10 @@ int actionUseSkill(Object* user, Object* target, int skill)
case SKILL_TRAPS:
if (isInCombat()) {
// NOTE: Uninline.
return _action_use_skill_in_combat_error(user);
return _action_use_skill_in_combat_error(a1);
}
if (PID_TYPE(target->pid) == OBJ_TYPE_CRITTER) {
if (PID_TYPE(a2->pid) == OBJ_TYPE_CRITTER) {
return -1;
}
@@ -1377,18 +1374,18 @@ int actionUseSkill(Object* user, Object* target, int skill)
case SKILL_REPAIR:
if (isInCombat()) {
// NOTE: Uninline.
return _action_use_skill_in_combat_error(user);
return _action_use_skill_in_combat_error(a1);
}
if (PID_TYPE(target->pid) != OBJ_TYPE_CRITTER) {
if (PID_TYPE(a2->pid) != OBJ_TYPE_CRITTER) {
break;
}
if (critterGetKillType(target) == KILL_TYPE_ROBOT) {
if (critterGetKillType(a2) == KILL_TYPE_ROBOT) {
break;
}
if (critterGetKillType(target) == KILL_TYPE_BRAHMIN
if (critterGetKillType(a2) == KILL_TYPE_BRAHMIN
&& skill == SKILL_SCIENCE) {
break;
}
@@ -1398,7 +1395,7 @@ int actionUseSkill(Object* user, Object* target, int skill)
int targetType = SCIENCE_REPAIR_TARGET_TYPE_DEFAULT;
configGetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_SCIENCE_REPAIR_TARGET_TYPE_KEY, &targetType);
if (targetType == SCIENCE_REPAIR_TARGET_TYPE_DUDE) {
if (target == gDude) {
if (a2 == gDude) {
break;
}
} else if (targetType == SCIENCE_REPAIR_TARGET_TYPE_ANYONE) {
@@ -1418,40 +1415,40 @@ int actionUseSkill(Object* user, Object* target, int skill)
// skill in entire party, and this skill is his/her own best.
Object* performer = gDude;
if (user == gDude) {
if (a1 == gDude) {
Object* partyMember = partyMemberGetBestInSkill(skill);
if (partyMember == gDude) {
partyMember = nullptr;
partyMember = NULL;
}
// Only dude can perform stealing.
if (skill == SKILL_STEAL) {
partyMember = nullptr;
partyMember = NULL;
}
if (partyMember != nullptr) {
if (partyMember != NULL) {
if (partyMemberGetBestSkill(partyMember) != skill) {
partyMember = nullptr;
partyMember = NULL;
}
}
if (partyMember != nullptr) {
if (partyMember != NULL) {
performer = partyMember;
int anim = FID_ANIM_TYPE(partyMember->fid);
if (anim != ANIM_WALK && anim != ANIM_RUNNING) {
if (anim != ANIM_STAND) {
performer = gDude;
partyMember = nullptr;
partyMember = NULL;
}
} else {
reg_anim_clear(partyMember);
}
}
if (partyMember != nullptr) {
if (partyMember != NULL) {
bool isDude = false;
if (objectGetDistanceBetween(gDude, target) <= 1) {
if (objectGetDistanceBetween(gDude, a2) <= 1) {
isDude = true;
}
@@ -1464,11 +1461,11 @@ int actionUseSkill(Object* user, Object* target, int skill)
if (isDude) {
performer = gDude;
partyMember = nullptr;
partyMember = NULL;
}
}
if (partyMember == nullptr) {
if (partyMember == NULL) {
int anim = FID_ANIM_TYPE(performer->fid);
if (anim == ANIM_WALK || anim == ANIM_RUNNING) {
reg_anim_clear(performer);
@@ -1478,33 +1475,33 @@ int actionUseSkill(Object* user, Object* target, int skill)
if (isInCombat()) {
reg_anim_begin(ANIMATION_REQUEST_RESERVED);
animationRegisterMoveToObject(performer, target, performer->data.critter.combat.ap, 0);
animationRegisterMoveToObject(performer, a2, performer->data.critter.combat.ap, 0);
} else {
reg_anim_begin(user == gDude ? ANIMATION_REQUEST_RESERVED : ANIMATION_REQUEST_UNRESERVED);
if (target != gDude) {
if (objectGetDistanceBetween(performer, target) >= 5) {
animationRegisterRunToObject(performer, target, -1, 0);
reg_anim_begin(a1 == gDude ? ANIMATION_REQUEST_RESERVED : ANIMATION_REQUEST_UNRESERVED);
if (a2 != gDude) {
if (objectGetDistanceBetween(performer, a2) >= 5) {
animationRegisterRunToObject(performer, a2, -1, 0);
} else {
animationRegisterMoveToObject(performer, target, -1, 0);
animationRegisterMoveToObject(performer, a2, -1, 0);
}
}
}
animationRegisterCallbackForced(performer, target, (AnimationCallback*)_is_next_to, -1);
animationRegisterCallbackForced(performer, a2, (AnimationCallback*)_is_next_to, -1);
int anim = (FID_TYPE(target->fid) == OBJ_TYPE_CRITTER && _critter_is_prone(target)) ? ANIM_MAGIC_HANDS_GROUND : ANIM_MAGIC_HANDS_MIDDLE;
int anim = (FID_TYPE(a2->fid) == OBJ_TYPE_CRITTER && _critter_is_prone(a2)) ? ANIM_MAGIC_HANDS_GROUND : ANIM_MAGIC_HANDS_MIDDLE;
int fid = buildFid(OBJ_TYPE_CRITTER, performer->fid & 0xFFF, anim, 0, performer->rotation + 1);
CacheEntry* artHandle;
Art* art = artLock(fid, &artHandle);
if (art != nullptr) {
if (art != NULL) {
artGetActionFrame(art);
artUnlock(artHandle);
}
animationRegisterAnimate(performer, anim, -1);
// TODO: Get rid of casts.
animationRegisterCallback3(performer, target, (void*)skill, (AnimationCallback3*)_obj_use_skill_on, -1);
animationRegisterCallback3(performer, a2, (void*)skill, (AnimationCallback3*)_obj_use_skill_on, -1);
return reg_anim_end();
}
@@ -1545,7 +1542,7 @@ int _pick_fall(Object* obj, int anim)
rotation = obj->rotation;
for (i = 1; i < 3; i++) {
tile_num = tileGetTileInDirection(obj->tile, rotation, i);
if (_obj_blocking_at(obj, tile_num, obj->elevation) != nullptr) {
if (_obj_blocking_at(obj, tile_num, obj->elevation) != NULL) {
anim = ANIM_FALL_BACK;
break;
}
@@ -1554,7 +1551,7 @@ int _pick_fall(Object* obj, int anim)
rotation = (obj->rotation + 3) % ROTATION_COUNT;
for (i = 1; i < 3; i++) {
tile_num = tileGetTileInDirection(obj->tile, rotation, i);
if (_obj_blocking_at(obj, tile_num, obj->elevation) != nullptr) {
if (_obj_blocking_at(obj, tile_num, obj->elevation) != NULL) {
anim = ANIM_FALL_FRONT;
break;
}
@@ -1579,14 +1576,14 @@ bool _action_explode_running()
// action_explode
// 0x412CF4
int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object* sourceObj, bool animate)
int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object* a5, bool a6)
{
if (animate && _action_in_explode) {
if (a6 && _action_in_explode) {
return -2;
}
Attack* attack = (Attack*)internal_malloc(sizeof(*attack));
if (attack == nullptr) {
if (attack == NULL) {
return -1;
}
@@ -1597,35 +1594,35 @@ int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object*
return -1;
}
objectHide(explosion, nullptr);
objectHide(explosion, NULL);
explosion->flags |= OBJECT_NO_SAVE;
objectSetLocation(explosion, tile, elevation, nullptr);
objectSetLocation(explosion, tile, elevation, NULL);
Object* adjacentExplosions[ROTATION_COUNT];
for (int rotation = 0; rotation < ROTATION_COUNT; rotation++) {
int fid = buildFid(OBJ_TYPE_MISC, 10, 0, 0, 0);
if (objectCreateWithFidPid(&(adjacentExplosions[rotation]), fid, -1) == -1) {
while (--rotation >= 0) {
objectDestroy(adjacentExplosions[rotation], nullptr);
objectDestroy(adjacentExplosions[rotation], NULL);
}
objectDestroy(explosion, nullptr);
objectDestroy(explosion, NULL);
internal_free(attack);
return -1;
}
objectHide(adjacentExplosions[rotation], nullptr);
objectHide(adjacentExplosions[rotation], NULL);
adjacentExplosions[rotation]->flags |= OBJECT_NO_SAVE;
int adjacentTile = tileGetTileInDirection(tile, rotation, 1);
objectSetLocation(adjacentExplosions[rotation], adjacentTile, elevation, nullptr);
objectSetLocation(adjacentExplosions[rotation], adjacentTile, elevation, NULL);
}
Object* critter = _obj_blocking_at(nullptr, tile, elevation);
if (critter != nullptr) {
Object* critter = _obj_blocking_at(NULL, tile, elevation);
if (critter != NULL) {
if (FID_TYPE(critter->fid) != OBJ_TYPE_CRITTER || (critter->data.critter.combat.results & DAM_DEAD) != 0) {
critter = nullptr;
critter = NULL;
}
}
@@ -1636,7 +1633,7 @@ int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object*
gameUiDisable(1);
if (critter != nullptr) {
if (critter != NULL) {
if (reg_anim_clear(critter) == -2) {
debugPrint("Cannot clear target's animation for action_explode!\n");
}
@@ -1656,7 +1653,7 @@ int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object*
attackComputeDeathFlags(attack);
if (animate) {
if (a6) {
_action_in_explode = true;
reg_anim_begin(ANIMATION_REQUEST_RESERVED);
@@ -1671,22 +1668,22 @@ int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object*
animationRegisterAnimateAndHide(adjacentExplosions[rotation], ANIM_STAND, 0);
}
animationRegisterCallbackForced(explosion, nullptr, (AnimationCallback*)_combat_explode_scenery, -1);
animationRegisterCallbackForced(explosion, 0, (AnimationCallback*)_combat_explode_scenery, -1);
animationRegisterHideObjectForced(explosion);
for (int rotation = 0; rotation < ROTATION_COUNT; rotation++) {
animationRegisterHideObjectForced(adjacentExplosions[rotation]);
}
animationRegisterCallbackForced(attack, sourceObj, (AnimationCallback*)_report_explosion, -1);
animationRegisterCallbackForced(nullptr, nullptr, (AnimationCallback*)_finished_explosion, -1);
animationRegisterCallbackForced(attack, a5, (AnimationCallback*)_report_explosion, -1);
animationRegisterCallbackForced(NULL, NULL, (AnimationCallback*)_finished_explosion, -1);
if (reg_anim_end() == -1) {
_action_in_explode = false;
objectDestroy(explosion, nullptr);
objectDestroy(explosion, NULL);
for (int rotation = 0; rotation < ROTATION_COUNT; rotation++) {
objectDestroy(adjacentExplosions[rotation], nullptr);
objectDestroy(adjacentExplosions[rotation], NULL);
}
internal_free(attack);
@@ -1697,7 +1694,7 @@ int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object*
_show_damage_extras(attack);
} else {
if (critter != nullptr) {
if (critter != NULL) {
if ((attack->defenderFlags & DAM_DEAD) != 0) {
critterKill(critter, -1, false);
}
@@ -1709,14 +1706,14 @@ int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object*
}
}
_report_explosion(attack, sourceObj);
_report_explosion(attack, a5);
_combat_explode_scenery(explosion, nullptr);
_combat_explode_scenery(explosion, NULL);
objectDestroy(explosion, nullptr);
objectDestroy(explosion, NULL);
for (int rotation = 0; rotation < ROTATION_COUNT; rotation++) {
objectDestroy(adjacentExplosions[rotation], nullptr);
objectDestroy(adjacentExplosions[rotation], NULL);
}
}
@@ -1724,10 +1721,10 @@ int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object*
}
// 0x413144
int _report_explosion(Attack* attack, Object* sourceObj)
int _report_explosion(Attack* attack, Object* a2)
{
bool mainTargetWasDead;
if (attack->defender != nullptr) {
if (attack->defender != NULL) {
mainTargetWasDead = (attack->defender->data.critter.combat.results & DAM_DEAD) != 0;
} else {
mainTargetWasDead = false;
@@ -1742,48 +1739,48 @@ int _report_explosion(Attack* attack, Object* sourceObj)
_combat_display(attack);
_apply_damage(attack, false);
Object* anyDefender = nullptr;
Object* anyDefender = NULL;
int xp = 0;
if (sourceObj != nullptr) {
if (attack->defender != nullptr && attack->defender != sourceObj) {
if (a2 != NULL) {
if (attack->defender != NULL && attack->defender != a2) {
if ((attack->defender->data.critter.combat.results & DAM_DEAD) != 0) {
if (sourceObj == gDude && !mainTargetWasDead) {
if (a2 == gDude && !mainTargetWasDead) {
xp += critterGetExp(attack->defender);
}
} else {
_critter_set_who_hit_me(attack->defender, sourceObj);
_critter_set_who_hit_me(attack->defender, a2);
anyDefender = attack->defender;
}
}
for (int index = 0; index < attack->extrasLength; index++) {
Object* critter = attack->extras[index];
if (critter != sourceObj) {
if (critter != a2) {
if ((critter->data.critter.combat.results & DAM_DEAD) != 0) {
if (sourceObj == gDude && !extrasWasDead[index]) {
if (a2 == gDude && !extrasWasDead[index]) {
xp += critterGetExp(critter);
}
} else {
_critter_set_who_hit_me(critter, sourceObj);
_critter_set_who_hit_me(critter, a2);
if (anyDefender == nullptr) {
if (anyDefender == NULL) {
anyDefender = critter;
}
}
}
}
if (anyDefender != nullptr) {
if (anyDefender != NULL) {
if (!isInCombat()) {
CombatStartData combat;
STRUCT_664980 combat;
combat.attacker = anyDefender;
combat.defender = sourceObj;
combat.defender = a2;
combat.actionPointsBonus = 0;
combat.accuracyBonus = 0;
combat.damageBonus = 0;
combat.minDamage = 0;
combat.maxDamage = INT_MAX;
combat.overrideAttackResults = 0;
combat.field_1C = 0;
scriptsRequestCombat(&combat);
}
}
@@ -1792,7 +1789,7 @@ int _report_explosion(Attack* attack, Object* sourceObj)
internal_free(attack);
gameUiEnable();
if (sourceObj == gDude) {
if (a2 == gDude) {
_combat_give_exps(xp);
}
@@ -1819,7 +1816,7 @@ int _compute_explosion_damage(int min, int max, Object* defender, int* knockback
damage = 0;
}
if (knockbackDistancePtr != nullptr) {
if (knockbackDistancePtr != NULL) {
if ((defender->flags & OBJECT_MULTIHEX) == 0) {
*knockbackDistancePtr = damage / 10;
}
@@ -1850,7 +1847,7 @@ int actionTalk(Object* a1, Object* a2)
} else {
reg_anim_begin(a1 == gDude ? ANIMATION_REQUEST_RESERVED : ANIMATION_REQUEST_UNRESERVED);
if (objectGetDistanceBetween(a1, a2) >= 9 || _combat_is_shot_blocked(a1, a1->tile, a2->tile, a2, nullptr)) {
if (objectGetDistanceBetween(a1, a2) >= 9 || _combat_is_shot_blocked(a1, a1->tile, a2->tile, a2, NULL)) {
animationRegisterRunToObject(a1, a2, -1, 0);
}
}
@@ -1863,7 +1860,7 @@ int actionTalk(Object* a1, Object* a2)
// 0x413420
int _can_talk_to(Object* a1, Object* a2)
{
if (_combat_is_shot_blocked(a1, a1->tile, a2->tile, a2, nullptr) || objectGetDistanceBetween(a1, a2) >= 9) {
if (_combat_is_shot_blocked(a1, a1->tile, a2->tile, a2, NULL) || objectGetDistanceBetween(a1, a2) >= 9) {
if (a1 == gDude) {
// You cannot get there. (used in actions.c)
MessageListItem messageListItem;
@@ -1890,7 +1887,7 @@ int _talk_to(Object* a1, Object* a2)
void actionDamage(int tile, int elevation, int minDamage, int maxDamage, int damageType, bool animated, bool bypassArmor)
{
Attack* attack = (Attack*)internal_malloc(sizeof(*attack));
if (attack == nullptr) {
if (attack == NULL) {
return;
}
@@ -1900,19 +1897,19 @@ void actionDamage(int tile, int elevation, int minDamage, int maxDamage, int dam
return;
}
objectHide(attacker, nullptr);
objectHide(attacker, NULL);
attacker->flags |= OBJECT_NO_SAVE;
objectSetLocation(attacker, tile, elevation, nullptr);
objectSetLocation(attacker, tile, elevation, NULL);
Object* defender = _obj_blocking_at(nullptr, tile, elevation);
Object* defender = _obj_blocking_at(NULL, tile, elevation);
attackInit(attack, attacker, defender, HIT_MODE_PUNCH, HIT_LOCATION_TORSO);
attack->tile = tile;
attack->attackerFlags = DAM_HIT;
gameUiDisable(1);
if (defender != nullptr) {
if (defender != NULL) {
reg_anim_clear(defender);
int damage;
@@ -1931,25 +1928,25 @@ void actionDamage(int tile, int elevation, int minDamage, int maxDamage, int dam
reg_anim_begin(ANIMATION_REQUEST_RESERVED);
animationRegisterPlaySoundEffect(attacker, "whc1xxx1", 0);
_show_damage(attack, gMaximumBloodDeathAnimations[damageType], 0);
animationRegisterCallbackForced(attack, nullptr, (AnimationCallback*)_report_dmg, 0);
animationRegisterCallbackForced(attack, NULL, (AnimationCallback*)_report_dmg, 0);
animationRegisterHideObjectForced(attacker);
if (reg_anim_end() == -1) {
objectDestroy(attacker, nullptr);
objectDestroy(attacker, NULL);
internal_free(attack);
return;
}
} else {
if (defender != nullptr) {
if (defender != NULL) {
if ((attack->defenderFlags & DAM_DEAD) != 0) {
critterKill(defender, -1, 1);
}
}
// NOTE: Uninline.
_report_dmg(attack, nullptr);
_report_dmg(attack, NULL);
objectDestroy(attacker, nullptr);
objectDestroy(attacker, NULL);
}
gameUiEnable();
@@ -1971,7 +1968,7 @@ int _report_dmg(Attack* attack, Object* a2)
int _compute_dmg_damage(int min, int max, Object* obj, int* knockbackDistancePtr, int damageType)
{
if (!_critter_flag_check(obj->pid, CRITTER_NO_KNOCKBACK)) {
knockbackDistancePtr = nullptr;
knockbackDistancePtr = NULL;
}
int damage = randomBetween(min, max) - critterGetStat(obj, STAT_DAMAGE_THRESHOLD + damageType);
@@ -1983,7 +1980,7 @@ int _compute_dmg_damage(int min, int max, Object* obj, int* knockbackDistancePtr
damage = 0;
}
if (knockbackDistancePtr != nullptr) {
if (knockbackDistancePtr != NULL) {
if ((obj->flags & OBJECT_MULTIHEX) == 0 && damageType != DAMAGE_TYPE_ELECTRICAL) {
*knockbackDistancePtr = damage / 10;
}
@@ -2027,7 +2024,7 @@ bool actionCheckPush(Object* a1, Object* a2)
// TODO: Check.
Object* whoHitMe = a2->data.critter.combat.whoHitMe;
if (whoHitMe != nullptr
if (whoHitMe != NULL
&& whoHitMe->data.critter.combat.team == a1->data.critter.combat.team) {
return false;
}
@@ -2064,32 +2061,32 @@ int actionPush(Object* a1, Object* a2)
int tile;
do {
tile = tileGetTileInDirection(a2->tile, rotation, 1);
if (_obj_blocking_at(a2, tile, a2->elevation) == nullptr) {
if (_obj_blocking_at(a2, tile, a2->elevation) == NULL) {
break;
}
tile = tileGetTileInDirection(a2->tile, (rotation + 1) % ROTATION_COUNT, 1);
if (_obj_blocking_at(a2, tile, a2->elevation) == nullptr) {
if (_obj_blocking_at(a2, tile, a2->elevation) == NULL) {
break;
}
tile = tileGetTileInDirection(a2->tile, (rotation + 5) % ROTATION_COUNT, 1);
if (_obj_blocking_at(a2, tile, a2->elevation) == nullptr) {
if (_obj_blocking_at(a2, tile, a2->elevation) == NULL) {
break;
}
tile = tileGetTileInDirection(a2->tile, (rotation + 2) % ROTATION_COUNT, 1);
if (_obj_blocking_at(a2, tile, a2->elevation) == nullptr) {
if (_obj_blocking_at(a2, tile, a2->elevation) == NULL) {
break;
}
tile = tileGetTileInDirection(a2->tile, (rotation + 4) % ROTATION_COUNT, 1);
if (_obj_blocking_at(a2, tile, a2->elevation) == nullptr) {
if (_obj_blocking_at(a2, tile, a2->elevation) == NULL) {
break;
}
tile = tileGetTileInDirection(a2->tile, (rotation + 3) % ROTATION_COUNT, 1);
if (_obj_blocking_at(a2, tile, a2->elevation) == nullptr) {
if (_obj_blocking_at(a2, tile, a2->elevation) == NULL) {
break;
}
@@ -2115,7 +2112,7 @@ int actionPush(Object* a1, Object* a2)
// 0x413970
int _action_can_talk_to(Object* a1, Object* a2)
{
if (pathfinderFindPath(a1, a1->tile, a2->tile, nullptr, 0, _obj_sight_blocking_at) == 0) {
if (pathfinderFindPath(a1, a1->tile, a2->tile, NULL, 0, _obj_sight_blocking_at) == 0) {
return -1;
}
+6 -8
View File
@@ -6,19 +6,17 @@
namespace fallout {
extern int rotation;
int _action_attack(Attack* attack);
int _action_use_an_item_on_object(Object* user, Object* targetObj, Object* item);
int _action_use_an_object(Object* user, Object* targetObj);
int _action_use_an_item_on_object(Object* a1, Object* a2, Object* a3);
int _action_use_an_object(Object* a1, Object* a2);
int actionPickUp(Object* critter, Object* item);
int _action_loot_container(Object* critter, Object* container);
int _action_skill_use(int skill);
int actionUseSkill(Object* user, Object* target, int skill);
bool _is_hit_from_front(Object* attacker, Object* defender);
int _action_skill_use(int a1);
int actionUseSkill(Object* a1, Object* a2, int skill);
bool _is_hit_from_front(Object* a1, Object* a2);
bool _can_see(Object* a1, Object* a2);
bool _action_explode_running();
int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object* sourceObj, bool animate);
int actionExplode(int tile, int elevation, int minDamage, int maxDamage, Object* a5, bool a6);
int actionTalk(Object* a1, Object* a2);
void actionDamage(int tile, int elevation, int minDamage, int maxDamage, int damageType, bool animated, bool bypassArmor);
bool actionCheckPush(Object* a1, Object* a2);
+104 -106
View File
@@ -34,7 +34,6 @@
#include "tile.h"
#include "trait.h"
#include "vcr.h"
#include "worldmap.h"
namespace fallout {
@@ -504,11 +503,11 @@ int reg_anim_end()
// 0x413D6C
static int _anim_preload(Object* object, int fid, CacheEntry** cacheEntryPtr)
{
*cacheEntryPtr = nullptr;
*cacheEntryPtr = NULL;
if (artLock(fid, cacheEntryPtr) != nullptr) {
if (artLock(fid, cacheEntryPtr) != NULL) {
artUnlock(*cacheEntryPtr);
*cacheEntryPtr = nullptr;
*cacheEntryPtr = NULL;
return 0;
}
@@ -529,7 +528,7 @@ static void _anim_cleanup()
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
for (int index = 0; index < gAnimationDescriptionCurrentIndex; index++) {
AnimationDescription* animationDescription = &(animationSequence->animations[index]);
if (animationDescription->artCacheKey != nullptr) {
if (animationDescription->artCacheKey != NULL) {
artUnlock(animationDescription->artCacheKey);
}
@@ -552,7 +551,7 @@ static int _check_registry(Object* obj)
return -1;
}
if (obj == nullptr) {
if (obj == NULL) {
return 0;
}
@@ -581,7 +580,7 @@ static int _check_registry(Object* obj)
// 0x413EC8
int animationIsBusy(Object* a1)
{
if (gAnimationDescriptionCurrentIndex >= ANIMATION_DESCRIPTION_LIST_CAPACITY || a1 == nullptr) {
if (gAnimationDescriptionCurrentIndex >= ANIMATION_DESCRIPTION_LIST_CAPACITY || a1 == NULL) {
return 0;
}
@@ -886,7 +885,7 @@ int animationRegisterAnimateReversed(Object* owner, int anim, int delay)
animationDescription->owner = owner;
animationDescription->anim = anim;
animationDescription->delay = delay;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
int fid = buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, animationDescription->anim, (owner->fid & 0xF000) >> 12, owner->rotation + 1);
@@ -915,7 +914,7 @@ int animationRegisterAnimateAndHide(Object* owner, int anim, int delay)
animationDescription->owner = owner;
animationDescription->anim = anim;
animationDescription->delay = delay;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
int fid = buildFid(FID_TYPE(owner->fid), owner->fid & 0xFFF, anim, (owner->fid & 0xF000) >> 12, owner->rotation + 1);
@@ -942,7 +941,7 @@ int animationRegisterRotateToTile(Object* owner, int tile)
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_ROTATE_TO_TILE;
animationDescription->delay = -1;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
animationDescription->owner = owner;
animationDescription->tile = tile;
@@ -963,7 +962,7 @@ int animationRegisterRotateClockwise(Object* owner)
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_ROTATE_CLOCKWISE;
animationDescription->delay = -1;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
animationDescription->owner = owner;
gAnimationDescriptionCurrentIndex++;
@@ -983,7 +982,7 @@ int animationRegisterRotateCounterClockwise(Object* owner)
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_ROTATE_COUNTER_CLOCKWISE;
animationDescription->delay = -1;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
animationDescription->owner = owner;
gAnimationDescriptionCurrentIndex++;
@@ -1005,7 +1004,7 @@ int animationRegisterHideObject(Object* object)
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_HIDE;
animationDescription->delay = -1;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
animationDescription->extendedFlags = 0;
animationDescription->owner = object;
gAnimationDescriptionCurrentIndex++;
@@ -1025,7 +1024,7 @@ int animationRegisterHideObjectForced(Object* object)
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_HIDE;
animationDescription->delay = -1;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
animationDescription->extendedFlags = ANIMATION_SEQUENCE_FORCED;
animationDescription->owner = object;
gAnimationDescriptionCurrentIndex++;
@@ -1034,9 +1033,9 @@ int animationRegisterHideObjectForced(Object* object)
}
// 0x414E98
int animationRegisterCallback(void* param1, void* param2, AnimationCallback* proc, int delay)
int animationRegisterCallback(void* a1, void* a2, AnimationCallback* proc, int delay)
{
if (_check_registry(nullptr) == -1 || proc == nullptr) {
if (_check_registry(NULL) == -1 || proc == NULL) {
_anim_cleanup();
return -1;
}
@@ -1045,9 +1044,9 @@ int animationRegisterCallback(void* param1, void* param2, AnimationCallback* pro
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_CALLBACK;
animationDescription->extendedFlags = 0;
animationDescription->artCacheKey = nullptr;
animationDescription->param2 = param2;
animationDescription->param1 = param1;
animationDescription->artCacheKey = NULL;
animationDescription->param2 = a2;
animationDescription->param1 = a1;
animationDescription->callback = proc;
animationDescription->delay = delay;
@@ -1059,9 +1058,9 @@ int animationRegisterCallback(void* param1, void* param2, AnimationCallback* pro
// Same as `animationRegisterCallback` but accepting 3 parameters.
//
// 0x414F20
int animationRegisterCallback3(void* param1, void* param2, void* param3, AnimationCallback3* proc, int delay)
int animationRegisterCallback3(void* a1, void* a2, void* a3, AnimationCallback3* proc, int delay)
{
if (_check_registry(nullptr) == -1 || proc == nullptr) {
if (_check_registry(NULL) == -1 || proc == NULL) {
_anim_cleanup();
return -1;
}
@@ -1070,11 +1069,11 @@ int animationRegisterCallback3(void* param1, void* param2, void* param3, Animati
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_CALLBACK3;
animationDescription->extendedFlags = 0;
animationDescription->artCacheKey = nullptr;
animationDescription->param2 = param2;
animationDescription->param1 = param1;
animationDescription->artCacheKey = NULL;
animationDescription->param2 = a2;
animationDescription->param1 = a1;
animationDescription->callback3 = proc;
animationDescription->param3 = param3;
animationDescription->param3 = a3;
animationDescription->delay = delay;
gAnimationDescriptionCurrentIndex++;
@@ -1085,7 +1084,7 @@ int animationRegisterCallback3(void* param1, void* param2, void* param3, Animati
// 0x414FAC
int animationRegisterCallbackForced(void* a1, void* a2, AnimationCallback* proc, int delay)
{
if (_check_registry(nullptr) == -1 || proc == nullptr) {
if (_check_registry(NULL) == -1 || proc == NULL) {
_anim_cleanup();
return -1;
}
@@ -1094,7 +1093,7 @@ int animationRegisterCallbackForced(void* a1, void* a2, AnimationCallback* proc,
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_CALLBACK;
animationDescription->extendedFlags = ANIMATION_SEQUENCE_FORCED;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
animationDescription->param2 = a2;
animationDescription->param1 = a1;
animationDescription->callback = proc;
@@ -1122,7 +1121,7 @@ int animationRegisterSetFlag(Object* object, int flag, int delay)
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_SET_FLAG;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
animationDescription->owner = object;
animationDescription->objectFlag = flag;
animationDescription->delay = delay;
@@ -1147,7 +1146,7 @@ int animationRegisterUnsetFlag(Object* object, int flag, int delay)
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_UNSET_FLAG;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
animationDescription->owner = object;
animationDescription->objectFlag = flag;
animationDescription->delay = delay;
@@ -1228,7 +1227,7 @@ int animationRegisterSetLightDistance(Object* owner, int lightDistance, int dela
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_SET_LIGHT_DISTANCE;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
animationDescription->owner = owner;
animationDescription->lightDistance = lightDistance;
animationDescription->delay = delay;
@@ -1251,7 +1250,7 @@ int animationRegisterToggleOutline(Object* object, bool outline, int delay)
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_TOGGLE_OUTLINE;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
animationDescription->owner = object;
animationDescription->outline = outline;
animationDescription->delay = delay;
@@ -1273,10 +1272,10 @@ int animationRegisterPlaySoundEffect(Object* owner, const char* soundEffectName,
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_CALLBACK;
animationDescription->owner = owner;
if (soundEffectName != nullptr) {
if (soundEffectName != NULL) {
int volume = _gsound_compute_relative_volume(owner);
animationDescription->param1 = soundEffectLoadWithVolume(soundEffectName, owner, volume);
if (animationDescription->param1 != nullptr) {
if (animationDescription->param1 != NULL) {
animationDescription->callback = (AnimationCallback*)_gsnd_anim_sound;
} else {
animationDescription->kind = ANIM_KIND_CONTINUE;
@@ -1285,7 +1284,7 @@ int animationRegisterPlaySoundEffect(Object* owner, const char* soundEffectName,
animationDescription->kind = ANIM_KIND_CONTINUE;
}
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
animationDescription->delay = delay;
gAnimationDescriptionCurrentIndex++;
@@ -1324,7 +1323,7 @@ int animationRegisterAnimateForever(Object* owner, int anim, int delay)
// 0x415598
int animationRegisterPing(int flags, int delay)
{
if (_check_registry(nullptr) == -1) {
if (_check_registry(NULL) == -1) {
_anim_cleanup();
return -1;
}
@@ -1338,9 +1337,9 @@ int animationRegisterPing(int flags, int delay)
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->owner = nullptr;
animationDescription->owner = NULL;
animationDescription->kind = ANIM_KIND_PING;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
animationDescription->animationSequenceIndex = animationSequenceIndex;
animationDescription->delay = delay;
@@ -1712,12 +1711,11 @@ int _make_path(Object* object, int from, int to, unsigned char* rotations, int a
return pathfinderFindPath(object, from, to, rotations, a5, _obj_blocking_at);
}
// TODO: move pathfinding into another unit
// 0x415EFC
int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotations, int a5, PathBuilderCallback* callback)
{
if (a5) {
if (callback(object, to, object->elevation) != nullptr) {
if (callback(object, to, object->elevation) != NULL) {
return 0;
}
}
@@ -1756,7 +1754,7 @@ int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotation
while (1) {
int v63 = -1;
PathNode* prev = nullptr;
PathNode* prev = NULL;
int v12 = 0;
for (int index = 0; v12 < openPathNodeListLength; index += 1) {
PathNode* curr = &(gOpenPathNodeList[index]);
@@ -1802,7 +1800,7 @@ int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotation
if (tile != to) {
Object* v24 = callback(object, tile, object->elevation);
if (v24 != nullptr) {
if (v24 != NULL) {
if (!canUseDoor(object, v24)) {
continue;
}
@@ -1842,14 +1840,14 @@ int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotation
if (isCritter) {
Object* o = objectFindFirstAtLocation(object->elevation, v27->tile);
while (o != nullptr) {
while (o != NULL) {
if (o->pid >= FIRST_RADIOACTIVE_GOO_PID && o->pid <= LAST_RADIOACTIVE_GOO_PID) {
break;
}
o = objectFindNextAtLocation();
}
if (o != nullptr) {
if (o != NULL) {
if (critterType == KILL_TYPE_GECKO) {
v27->cost += 100;
} else {
@@ -1872,7 +1870,7 @@ int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotation
break;
}
if (v39 != nullptr) {
if (v39 != NULL) {
*v39 = temp.rotation & 0xFF;
v39 += 1;
}
@@ -1886,7 +1884,7 @@ int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotation
memcpy(&temp, v36, sizeof(temp));
}
if (rotations != nullptr) {
if (rotations != NULL) {
// Looks like array resevering, probably because A* finishes it's path from end to start,
// this probably reverses it start-to-end.
unsigned char* beginning = rotations;
@@ -1941,19 +1939,19 @@ static int _tile_idistance(int tile1, int tile2)
}
// 0x4163AC
int _make_straight_path(Object* obj, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6)
int _make_straight_path(Object* a1, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6)
{
return _make_straight_path_func(obj, from, to, straightPathNodeList, obstaclePtr, a6, _obj_blocking_at);
return _make_straight_path_func(a1, from, to, straightPathNodeList, obstaclePtr, a6, _obj_blocking_at);
}
// TODO: Rather complex, but understandable, needs testing.
//
// 0x4163C8
int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6, PathBuilderCallback* callback)
int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6, PathBuilderCallback* callback)
{
if (obstaclePtr != nullptr) {
Object* obstacle = callback(obj, from, obj->elevation);
if (obstacle != nullptr) {
if (obstaclePtr != NULL) {
Object* obstacle = callback(a1, from, a1->elevation);
if (obstacle != NULL) {
if (obstacle != *obstaclePtr && (a6 != 32 || (obstacle->flags & OBJECT_SHOOT_THRU) == 0)) {
*obstaclePtr = obstacle;
return 0;
@@ -1963,13 +1961,13 @@ int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* st
int fromX;
int fromY;
tileToScreenXY(from, &fromX, &fromY, obj->elevation);
tileToScreenXY(from, &fromX, &fromY, a1->elevation);
fromX += 16;
fromY += 8;
int toX;
int toY;
tileToScreenXY(to, &toX, &toY, obj->elevation);
tileToScreenXY(to, &toX, &toY, a1->elevation);
toX += 16;
toY += 8;
@@ -2007,7 +2005,7 @@ int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* st
if (ddx <= ddy) {
int middle = ddx - ddy / 2;
while (true) {
tile = tileFromScreenXY(tileX, tileY, obj->elevation);
tile = tileFromScreenXY(tileX, tileY, a1->elevation);
v22 += 1;
if (v22 == a6) {
@@ -2015,12 +2013,12 @@ int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* st
return 0;
}
if (straightPathNodeList != nullptr) {
if (straightPathNodeList != NULL) {
StraightPathNode* pathNode = &(straightPathNodeList[pathNodeIndex]);
pathNode->tile = tile;
pathNode->elevation = obj->elevation;
pathNode->elevation = a1->elevation;
tileToScreenXY(tile, &fromX, &fromY, obj->elevation);
tileToScreenXY(tile, &fromX, &fromY, a1->elevation);
pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8;
}
@@ -2030,8 +2028,8 @@ int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* st
}
if (tileY == toY) {
if (obstaclePtr != nullptr) {
*obstaclePtr = nullptr;
if (obstaclePtr != NULL) {
*obstaclePtr = NULL;
}
break;
}
@@ -2045,11 +2043,11 @@ int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* st
middle += ddx;
if (tile != prevTile) {
if (obstaclePtr != nullptr) {
Object* obstacle = callback(obj, tile, obj->elevation);
if (obstacle != nullptr) {
if (obstacle != *obstaclePtr && (a6 != 32 || (obstacle->flags & OBJECT_SHOOT_THRU) == 0)) {
*obstaclePtr = obstacle;
if (obstaclePtr != NULL) {
Object* obj = callback(a1, tile, a1->elevation);
if (obj != NULL) {
if (obj != *obstaclePtr && (a6 != 32 || (obj->flags & OBJECT_SHOOT_THRU) == 0)) {
*obstaclePtr = obj;
break;
}
}
@@ -2060,7 +2058,7 @@ int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* st
} else {
int middle = ddy - ddx / 2;
while (true) {
tile = tileFromScreenXY(tileX, tileY, obj->elevation);
tile = tileFromScreenXY(tileX, tileY, a1->elevation);
v22 += 1;
if (v22 == a6) {
@@ -2068,12 +2066,12 @@ int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* st
return 0;
}
if (straightPathNodeList != nullptr) {
if (straightPathNodeList != NULL) {
StraightPathNode* pathNode = &(straightPathNodeList[pathNodeIndex]);
pathNode->tile = tile;
pathNode->elevation = obj->elevation;
pathNode->elevation = a1->elevation;
tileToScreenXY(tile, &fromX, &fromY, obj->elevation);
tileToScreenXY(tile, &fromX, &fromY, a1->elevation);
pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8;
}
@@ -2083,8 +2081,8 @@ int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* st
}
if (tileX == toX) {
if (obstaclePtr != nullptr) {
*obstaclePtr = nullptr;
if (obstaclePtr != NULL) {
*obstaclePtr = NULL;
}
break;
}
@@ -2098,11 +2096,11 @@ int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* st
middle += ddy;
if (tile != prevTile) {
if (obstaclePtr != nullptr) {
Object* obstacle = callback(obj, tile, obj->elevation);
if (obstacle != nullptr) {
if (obstacle != *obstaclePtr && (a6 != 32 || (obstacle->flags & OBJECT_SHOOT_THRU) == 0)) {
*obstaclePtr = obstacle;
if (obstaclePtr != NULL) {
Object* obj = callback(a1, tile, a1->elevation);
if (obj != NULL) {
if (obj != *obstaclePtr && (a6 != 32 || (obj->flags & OBJECT_SHOOT_THRU) == 0)) {
*obstaclePtr = obj;
break;
}
}
@@ -2117,20 +2115,20 @@ int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* st
return 0;
}
if (straightPathNodeList != nullptr) {
if (straightPathNodeList != NULL) {
StraightPathNode* pathNode = &(straightPathNodeList[pathNodeIndex]);
pathNode->tile = tile;
pathNode->elevation = obj->elevation;
pathNode->elevation = a1->elevation;
tileToScreenXY(tile, &fromX, &fromY, obj->elevation);
tileToScreenXY(tile, &fromX, &fromY, a1->elevation);
pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8;
}
pathNodeIndex += 1;
} else {
if (pathNodeIndex > 0 && straightPathNodeList != nullptr) {
straightPathNodeList[pathNodeIndex - 1].elevation = obj->elevation;
if (pathNodeIndex > 0 && straightPathNodeList != NULL) {
straightPathNodeList[pathNodeIndex - 1].elevation = a1->elevation;
}
}
@@ -2197,8 +2195,8 @@ int _make_stair_path(Object* object, int from, int fromElevation, int to, int to
toX += 16;
toY += 8;
if (obstaclePtr != nullptr) {
*obstaclePtr = nullptr;
if (obstaclePtr != NULL) {
*obstaclePtr = NULL;
}
int ddx = 2 * abs(toX - fromX);
@@ -2244,7 +2242,7 @@ int _make_stair_path(Object* object, int from, int fromElevation, int to, int to
return 0;
}
if (a6 != nullptr) {
if (a6 != NULL) {
StraightPathNode* pathNode = &(a6[pathNodeIndex]);
pathNode->tile = tile;
pathNode->elevation = elevation;
@@ -2271,9 +2269,9 @@ int _make_stair_path(Object* object, int from, int fromElevation, int to, int to
middle += ddy;
if (tile != prevTile) {
if (obstaclePtr != nullptr) {
if (obstaclePtr != NULL) {
*obstaclePtr = _obj_blocking_at(object, tile, object->elevation);
if (*obstaclePtr != nullptr) {
if (*obstaclePtr != NULL) {
break;
}
}
@@ -2291,7 +2289,7 @@ int _make_stair_path(Object* object, int from, int fromElevation, int to, int to
return 0;
}
if (a6 != nullptr) {
if (a6 != NULL) {
StraightPathNode* pathNode = &(a6[pathNodeIndex]);
pathNode->tile = tile;
pathNode->elevation = elevation;
@@ -2318,9 +2316,9 @@ int _make_stair_path(Object* object, int from, int fromElevation, int to, int to
middle += ddx;
if (tile != prevTile) {
if (obstaclePtr != nullptr) {
if (obstaclePtr != NULL) {
*obstaclePtr = _obj_blocking_at(object, tile, object->elevation);
if (*obstaclePtr != nullptr) {
if (*obstaclePtr != NULL) {
break;
}
}
@@ -2334,7 +2332,7 @@ int _make_stair_path(Object* object, int from, int fromElevation, int to, int to
return 0;
}
if (a6 != nullptr) {
if (a6 != NULL) {
StraightPathNode* pathNode = &(a6[pathNodeIndex]);
pathNode->tile = tile;
pathNode->elevation = elevation;
@@ -2347,7 +2345,7 @@ int _make_stair_path(Object* object, int from, int fromElevation, int to, int to
pathNodeIndex++;
} else {
if (pathNodeIndex > 0) {
if (a6 != nullptr) {
if (a6 != NULL) {
a6[pathNodeIndex - 1].elevation = toElevation;
}
}
@@ -2449,7 +2447,7 @@ static int animateMoveObjectToTileStraight(Object* obj, int tile, int elevation,
v15 = 32;
}
sad->field_1C = _make_straight_path(obj, obj->tile, tile, sad->straightPathNodeList, nullptr, v15);
sad->field_1C = _make_straight_path(obj, obj->tile, tile, sad->straightPathNodeList, NULL, v15);
if (sad->field_1C == 0) {
sad->field_20 = -1000;
return -1;
@@ -2480,7 +2478,7 @@ static int _anim_move_on_stairs(Object* obj, int tile, int elevation, int anim,
sad->animationTimestamp = 0;
sad->ticksPerFrame = animationComputeTicksPerFrame(obj, sad->fid);
sad->animationSequenceIndex = animationSequenceIndex;
sad->field_1C = _make_stair_path(obj, obj->tile, obj->elevation, tile, elevation, sad->straightPathNodeList, nullptr);
sad->field_1C = _make_stair_path(obj, obj->tile, obj->elevation, tile, elevation, sad->straightPathNodeList, NULL);
if (sad->field_1C == 0) {
sad->field_20 = -1000;
return -1;
@@ -2515,7 +2513,7 @@ static int _check_for_falling(Object* obj, int anim, int a3)
sad->animationTimestamp = 0;
sad->ticksPerFrame = animationComputeTicksPerFrame(obj, sad->fid);
sad->animationSequenceIndex = a3;
sad->field_1C = _make_straight_path_func(obj, obj->tile, obj->tile, sad->straightPathNodeList, nullptr, 16, _obj_blocking_at);
sad->field_1C = _make_straight_path_func(obj, obj->tile, obj->tile, sad->straightPathNodeList, 0, 16, _obj_blocking_at);
if (sad->field_1C == 0) {
sad->field_20 = -1000;
return -1;
@@ -2558,7 +2556,7 @@ static void _object_move(int index)
CacheEntry* cacheHandle;
Art* art = artLock(object->fid, &cacheHandle);
if (art != nullptr) {
if (art != NULL) {
artGetFrameOffsets(art, object->frame, object->rotation, &frameX, &frameY);
artUnlock(cacheHandle);
} else {
@@ -2578,7 +2576,7 @@ static void _object_move(int index)
int nextTile = tileGetTileInDirection(object->tile, rotation, 1);
Object* obstacle = _obj_blocking_at(object, nextTile, object->elevation);
if (obstacle != nullptr) {
if (obstacle != NULL) {
if (!canUseDoor(object, obstacle)) {
sad->field_1C = _make_path(object, object->tile, sad->field_24, sad->rotations, 1);
if (sad->field_1C != 0) {
@@ -2665,7 +2663,7 @@ static void _object_straight_move(int index)
CacheEntry* cacheHandle;
Art* art = artLock(object->fid, &cacheHandle);
if (art != nullptr) {
if (art != NULL) {
int lastFrame = artGetFrameCount(art) - 1;
artUnlock(cacheHandle);
@@ -2798,7 +2796,7 @@ void _object_animate()
if ((sad->flags & ANIM_SAD_REVERSE) == 0) {
CacheEntry* cacheHandle;
Art* art = artLock(object->fid, &cacheHandle);
if (art != nullptr) {
if (art != NULL) {
if ((sad->flags & ANIM_SAD_FOREVER) == 0 && object->frame == artGetFrameCount(art) - 1) {
sad->field_20 = -1000;
artUnlock(cacheHandle);
@@ -2836,7 +2834,7 @@ void _object_animate()
CacheEntry* cacheHandle;
Art* art = artLock(object->fid, &cacheHandle);
if (art != nullptr) {
if (art != NULL) {
artGetFrameOffsets(art, object->frame, object->rotation, &x, &y);
artUnlock(cacheHandle);
}
@@ -2859,7 +2857,7 @@ void _object_animate()
CacheEntry* cacheHandle;
Art* art = artLock(object->fid, &cacheHandle);
if (art != nullptr) {
if (art != NULL) {
artGetRotationOffsets(art, object->rotation, &x, &y);
artUnlock(cacheHandle);
} else {
@@ -2871,7 +2869,7 @@ void _object_animate()
rectUnion(&dirtyRect, &tempRect, &dirtyRect);
art = artLock(object->fid, &cacheHandle);
if (art != nullptr) {
if (art != NULL) {
int frame;
if ((sad->flags & ANIM_SAD_REVERSE) != 0) {
frame = artGetFrameCount(art) - 1;
@@ -3053,7 +3051,7 @@ void _dude_fidget()
int candidatesLength = 0;
Object* object = objectFindFirstAtElevation(gDude->elevation);
while (object != nullptr) {
while (object != NULL) {
if (candidatesLength >= 100) {
break;
}
@@ -3063,7 +3061,7 @@ void _dude_fidget()
objectGetRect(object, &rect);
Rect intersection;
if (rectIntersection(&rect, &_scr_size, &intersection) == 0 && (gMapHeader.index != MAP_SPECIAL_RND_WOODSMAN || object->pid != 0x10000FA)) {
if (rectIntersection(&rect, &_scr_size, &intersection) == 0 && (gMapHeader.field_34 != 97 || object->pid != 0x10000FA)) {
candidates[candidatesLength++] = object;
}
}
@@ -3130,7 +3128,7 @@ void _dude_stand(Object* obj, int rotation, int fid)
int takeOutFid = buildFid(FID_TYPE(obj->fid), obj->fid & 0xFFF, ANIM_TAKE_OUT, weaponAnimationCode, obj->rotation + 1);
CacheEntry* takeOutFrmHandle;
Art* takeOutFrm = artLock(takeOutFid, &takeOutFrmHandle);
if (takeOutFrm != nullptr) {
if (takeOutFrm != NULL) {
int frameCount = artGetFrameCount(takeOutFrm);
for (int frame = 0; frame < frameCount; frame++) {
int offsetX;
@@ -3144,7 +3142,7 @@ void _dude_stand(Object* obj, int rotation, int fid)
CacheEntry* standFrmHandle;
int standFid = buildFid(FID_TYPE(obj->fid), obj->fid & 0xFFF, ANIM_STAND, 0, obj->rotation + 1);
Art* standFrm = artLock(standFid, &standFrmHandle);
if (standFrm != nullptr) {
if (standFrm != NULL) {
int offsetX;
int offsetY;
if (artGetRotationOffsets(standFrm, obj->rotation, &offsetX, &offsetY) == 0) {
@@ -3295,7 +3293,7 @@ static unsigned int animationComputeTicksPerFrame(Object* object, int fid)
CacheEntry* handle;
Art* frm = artLock(fid, &handle);
if (frm != nullptr) {
if (frm != NULL) {
fps = artGetFramesPerSecond(frm);
artUnlock(handle);
} else {
@@ -3323,7 +3321,7 @@ int animationRegisterSetLightIntensity(Object* owner, int lightDistance, int lig
AnimationSequence* animationSequence = &(gAnimationSequences[gAnimationSequenceCurrentIndex]);
AnimationDescription* animationDescription = &(animationSequence->animations[gAnimationDescriptionCurrentIndex]);
animationDescription->kind = ANIM_KIND_SET_LIGHT_INTENSITY;
animationDescription->artCacheKey = nullptr;
animationDescription->artCacheKey = NULL;
animationDescription->owner = owner;
animationDescription->lightDistance = lightDistance;
animationDescription->lightIntensity = lightIntensity;
+3 -3
View File
@@ -92,7 +92,7 @@ typedef enum AnimationType {
LAST_SF_DEATH_ANIM = ANIM_FALL_FRONT_BLOOD_SF,
} AnimationType;
#define FID_ANIM_TYPE(value) ((value) & 0xFF0000) >> 16
#define FID_ANIM_TYPE(value) ((value)&0xFF0000) >> 16
// Signature of animation callback accepting 2 parameters.
typedef int(AnimationCallback)(void* a1, void* a2);
@@ -145,8 +145,8 @@ int animationRegisterAnimateForever(Object* owner, int anim, int delay);
int animationRegisterPing(int flags, int delay);
int _make_path(Object* object, int from, int to, unsigned char* a4, int a5);
int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotations, int a5, PathBuilderCallback* callback);
int _make_straight_path(Object* object, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6);
int _make_straight_path_func(Object* object, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6, PathBuilderCallback* callback);
int _make_straight_path(Object* a1, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6);
int _make_straight_path_func(Object* a1, int from, int to, StraightPathNode* straightPathNodeList, Object** obstaclePtr, int a6, PathBuilderCallback* callback);
void _object_animate();
int _check_move(int* actionPointsPtr);
int _dude_move(int actionPoints);
+122 -113
View File
@@ -53,17 +53,17 @@ static char gDefaultTribalFemaleFileName[] = "hfprim";
// 0x510738
static ArtListDescription gArtListDescriptions[OBJ_TYPE_COUNT] = {
{ 0, "items", nullptr, nullptr, 0 },
{ 0, "critters", nullptr, nullptr, 0 },
{ 0, "scenery", nullptr, nullptr, 0 },
{ 0, "walls", nullptr, nullptr, 0 },
{ 0, "tiles", nullptr, nullptr, 0 },
{ 0, "misc", nullptr, nullptr, 0 },
{ 0, "intrface", nullptr, nullptr, 0 },
{ 0, "inven", nullptr, nullptr, 0 },
{ 0, "heads", nullptr, nullptr, 0 },
{ 0, "backgrnd", nullptr, nullptr, 0 },
{ 0, "skilldex", nullptr, nullptr, 0 },
{ 0, "items", 0, 0, 0 },
{ 0, "critters", 0, 0, 0 },
{ 0, "scenery", 0, 0, 0 },
{ 0, "walls", 0, 0, 0 },
{ 0, "tiles", 0, 0, 0 },
{ 0, "misc", 0, 0, 0 },
{ 0, "intrface", 0, 0, 0 },
{ 0, "inven", 0, 0, 0 },
{ 0, "heads", 0, 0, 0 },
{ 0, "backgrnd", 0, 0, 0 },
{ 0, "skilldex", 0, 0, 0 },
};
// This flag denotes that localized arts should be looked up first. Used
@@ -159,7 +159,7 @@ int artInit()
}
_anon_alias = (int*)internal_malloc(sizeof(*_anon_alias) * gArtListDescriptions[OBJ_TYPE_CRITTER].fileNamesLength);
if (_anon_alias == nullptr) {
if (_anon_alias == NULL) {
gArtListDescriptions[OBJ_TYPE_CRITTER].fileNamesLength = 0;
debugPrint("Out of memory for anon_alias in art_init\n");
cacheFree(&gArtCache);
@@ -167,7 +167,7 @@ int artInit()
}
gArtCritterFidShoudRunData = (int*)internal_malloc(sizeof(*gArtCritterFidShoudRunData) * gArtListDescriptions[1].fileNamesLength);
if (gArtCritterFidShoudRunData == nullptr) {
if (gArtCritterFidShoudRunData == NULL) {
gArtListDescriptions[OBJ_TYPE_CRITTER].fileNamesLength = 0;
debugPrint("Out of memory for artCritterFidShouldRunData in art_init\n");
cacheFree(&gArtCache);
@@ -181,34 +181,34 @@ int artInit()
snprintf(path, sizeof(path), "%s%s%s\\%s.lst", _cd_path_base, "art\\", gArtListDescriptions[OBJ_TYPE_CRITTER].name, gArtListDescriptions[OBJ_TYPE_CRITTER].name);
stream = fileOpen(path, "rt");
if (stream == nullptr) {
if (stream == NULL) {
debugPrint("Unable to open %s in art_init\n", path);
cacheFree(&gArtCache);
return -1;
}
// SFALL: Modify player model settings.
char* jumpsuitMaleFileName = nullptr;
char* jumpsuitMaleFileName = NULL;
configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_DUDE_NATIVE_LOOK_JUMPSUIT_MALE_KEY, &jumpsuitMaleFileName);
if (jumpsuitMaleFileName == nullptr || jumpsuitMaleFileName[0] == '\0') {
if (jumpsuitMaleFileName == NULL || jumpsuitMaleFileName[0] == '\0') {
jumpsuitMaleFileName = gDefaultJumpsuitMaleFileName;
}
char* jumpsuitFemaleFileName = nullptr;
char* jumpsuitFemaleFileName = NULL;
configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_DUDE_NATIVE_LOOK_JUMPSUIT_FEMALE_KEY, &jumpsuitFemaleFileName);
if (jumpsuitFemaleFileName == nullptr || jumpsuitFemaleFileName[0] == '\0') {
if (jumpsuitFemaleFileName == NULL || jumpsuitFemaleFileName[0] == '\0') {
jumpsuitFemaleFileName = gDefaultJumpsuitFemaleFileName;
}
char* tribalMaleFileName = nullptr;
char* tribalMaleFileName = NULL;
configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_DUDE_NATIVE_LOOK_TRIBAL_MALE_KEY, &tribalMaleFileName);
if (tribalMaleFileName == nullptr || tribalMaleFileName[0] == '\0') {
if (tribalMaleFileName == NULL || tribalMaleFileName[0] == '\0') {
tribalMaleFileName = gDefaultTribalMaleFileName;
}
char* tribalFemaleFileName = nullptr;
char* tribalFemaleFileName = NULL;
configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_DUDE_NATIVE_LOOK_TRIBAL_FEMALE_KEY, &tribalFemaleFileName);
if (tribalFemaleFileName == nullptr || tribalFemaleFileName[0] == '\0') {
if (tribalFemaleFileName == NULL || tribalFemaleFileName[0] == '\0') {
tribalFemaleFileName = gDefaultTribalFemaleFileName;
}
@@ -236,11 +236,11 @@ int artInit()
}
char* sep1 = strchr(string, ',');
if (sep1 != nullptr) {
if (sep1 != NULL) {
_anon_alias[critterIndex] = atoi(sep1 + 1);
char* sep2 = strchr(sep1 + 1, ',');
if (sep2 != nullptr) {
if (sep2 != NULL) {
gArtCritterFidShoudRunData[critterIndex] = atoi(sep2 + 1);
} else {
gArtCritterFidShoudRunData[critterIndex] = 0;
@@ -262,7 +262,7 @@ int artInit()
}
gHeadDescriptions = (HeadDescription*)internal_malloc(sizeof(*gHeadDescriptions) * gArtListDescriptions[OBJ_TYPE_HEAD].fileNamesLength);
if (gHeadDescriptions == nullptr) {
if (gHeadDescriptions == NULL) {
gArtListDescriptions[OBJ_TYPE_HEAD].fileNamesLength = 0;
debugPrint("Out of memory for head_info in art_init\n");
cacheFree(&gArtCache);
@@ -272,7 +272,7 @@ int artInit()
snprintf(path, sizeof(path), "%s%s%s\\%s.lst", _cd_path_base, "art\\", gArtListDescriptions[OBJ_TYPE_HEAD].name, gArtListDescriptions[OBJ_TYPE_HEAD].name);
stream = fileOpen(path, "rt");
if (stream == nullptr) {
if (stream == NULL) {
debugPrint("Unable to open %s in art_init\n", path);
cacheFree(&gArtCache);
return -1;
@@ -284,14 +284,14 @@ int artInit()
}
char* sep1 = strchr(string, ',');
if (sep1 != nullptr) {
if (sep1 != NULL) {
*sep1 = '\0';
} else {
sep1 = string;
}
char* sep2 = strchr(sep1, ',');
if (sep2 != nullptr) {
if (sep2 != NULL) {
*sep2 = '\0';
} else {
sep2 = sep1;
@@ -300,7 +300,7 @@ int artInit()
gHeadDescriptions[headIndex].goodFidgetCount = atoi(sep1 + 1);
char* sep3 = strchr(sep2, ',');
if (sep3 != nullptr) {
if (sep3 != NULL) {
*sep3 = '\0';
} else {
sep3 = sep2;
@@ -309,7 +309,7 @@ int artInit()
gHeadDescriptions[headIndex].neutralFidgetCount = atoi(sep2 + 1);
char* sep4 = strpbrk(sep3 + 1, " ,;\t\n");
if (sep4 != nullptr) {
if (sep4 != NULL) {
*sep4 = '\0';
}
@@ -336,10 +336,10 @@ void artExit()
for (int index = 0; index < OBJ_TYPE_COUNT; index++) {
internal_free(gArtListDescriptions[index].fileNames);
gArtListDescriptions[index].fileNames = nullptr;
gArtListDescriptions[index].fileNames = NULL;
internal_free(gArtListDescriptions[index].field_18);
gArtListDescriptions[index].field_18 = nullptr;
gArtListDescriptions[index].field_18 = NULL;
}
internal_free(gHeadDescriptions);
@@ -348,7 +348,7 @@ void artExit()
// 0x418F1C
char* artGetObjectTypeName(int objectType)
{
return objectType >= OBJ_TYPE_ITEM && objectType < OBJ_TYPE_COUNT ? gArtListDescriptions[objectType].name : nullptr;
return objectType >= OBJ_TYPE_ITEM && objectType < OBJ_TYPE_COUNT ? gArtListDescriptions[objectType].name : NULL;
}
// 0x418F34
@@ -396,7 +396,7 @@ void artRender(int fid, unsigned char* dest, int width, int height, int pitch)
CacheEntry* handle;
Art* frm = artLock(fid, &handle);
if (frm == nullptr) {
if (frm == NULL) {
return;
}
@@ -438,22 +438,14 @@ void artRender(int fid, unsigned char* dest, int width, int height, int pitch)
artUnlock(handle);
}
// mapper2.exe: 0x40A03C
int art_list_str(int fid, char* name)
{
// TODO: Incomplete.
return -1;
}
// 0x419160
Art* artLock(int fid, CacheEntry** handlePtr)
{
if (handlePtr == nullptr) {
return nullptr;
if (handlePtr == NULL) {
return NULL;
}
Art* art = nullptr;
Art* art = NULL;
cacheLock(&gArtCache, fid, (void**)&art, handlePtr);
return art;
}
@@ -464,44 +456,44 @@ unsigned char* artLockFrameData(int fid, int frame, int direction, CacheEntry**
Art* art;
ArtFrame* frm;
art = nullptr;
art = NULL;
if (handlePtr) {
cacheLock(&gArtCache, fid, (void**)&art, handlePtr);
}
if (art != nullptr) {
if (art != NULL) {
frm = artGetFrame(art, frame, direction);
if (frm != nullptr) {
if (frm != NULL) {
return (unsigned char*)frm + sizeof(*frm);
}
}
return nullptr;
return NULL;
}
// 0x4191CC
unsigned char* artLockFrameDataReturningSize(int fid, CacheEntry** handlePtr, int* widthPtr, int* heightPtr)
{
*handlePtr = nullptr;
*handlePtr = NULL;
Art* art = nullptr;
Art* art = NULL;
cacheLock(&gArtCache, fid, (void**)&art, handlePtr);
if (art == nullptr) {
return nullptr;
if (art == NULL) {
return NULL;
}
// NOTE: Uninline.
*widthPtr = artGetWidth(art, 0, 0);
if (*widthPtr == -1) {
return nullptr;
return NULL;
}
// NOTE: Uninline.
*heightPtr = artGetHeight(art, 0, 0);
if (*heightPtr == -1) {
return nullptr;
return NULL;
}
// NOTE: Uninline.
@@ -525,7 +517,7 @@ int artCopyFileName(int objectType, int id, char* dest)
{
ArtListDescription* ptr;
if (objectType < OBJ_TYPE_ITEM || objectType >= OBJ_TYPE_COUNT) {
if (objectType < OBJ_TYPE_ITEM && objectType >= OBJ_TYPE_COUNT) {
return -1;
}
@@ -633,19 +625,19 @@ char* artBuildFilePath(int fid)
v5 = (v2 & 0xF000) >> 12;
type = FID_TYPE(v2);
if (type < OBJ_TYPE_ITEM || type >= OBJ_TYPE_COUNT) {
return nullptr;
if (v3 >= gArtListDescriptions[type].fileNamesLength) {
return NULL;
}
if (v3 >= gArtListDescriptions[type].fileNamesLength) {
return nullptr;
if (type < OBJ_TYPE_ITEM || type >= OBJ_TYPE_COUNT) {
return NULL;
}
v8 = v3 * 13;
if (type == 1) {
if (_art_get_code(v4, v5, &v11, &v12) == -1) {
return nullptr;
return NULL;
}
if (v10) {
snprintf(_art_name, sizeof(_art_name), "%s%s%s\\%s%c%c.fr%c", _cd_path_base, "art\\", gArtListDescriptions[1].name, gArtListDescriptions[1].fileNames + v8, v11, v12, v10 + 47);
@@ -671,7 +663,7 @@ char* artBuildFilePath(int fid)
static int artReadList(const char* path, char** artListPtr, int* artListSizePtr)
{
File* stream = fileOpen(path, "rt");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -687,14 +679,14 @@ static int artReadList(const char* path, char** artListPtr, int* artListSizePtr)
char* artList = (char*)internal_malloc(13 * count);
*artListPtr = artList;
if (artList == nullptr) {
if (artList == NULL) {
fileClose(stream);
return -1;
}
while (fileReadString(string, sizeof(string), stream)) {
char* brk = strpbrk(string, " ,;\r\t\n");
if (brk != nullptr) {
if (brk != NULL) {
*brk = '\0';
}
@@ -712,7 +704,7 @@ static int artReadList(const char* path, char** artListPtr, int* artListSizePtr)
// 0x419760
int artGetFramesPerSecond(Art* art)
{
if (art == nullptr) {
if (art == NULL) {
return 10;
}
@@ -722,13 +714,13 @@ int artGetFramesPerSecond(Art* art)
// 0x419778
int artGetActionFrame(Art* art)
{
return art == nullptr ? -1 : art->actionFrame;
return art == NULL ? -1 : art->actionFrame;
}
// 0x41978C
int artGetFrameCount(Art* art)
{
return art == nullptr ? -1 : art->frameCount;
return art == NULL ? -1 : art->frameCount;
}
// 0x4197A0
@@ -737,7 +729,7 @@ int artGetWidth(Art* art, int frame, int direction)
ArtFrame* frm;
frm = artGetFrame(art, frame, direction);
if (frm == nullptr) {
if (frm == NULL) {
return -1;
}
@@ -750,7 +742,7 @@ int artGetHeight(Art* art, int frame, int direction)
ArtFrame* frm;
frm = artGetFrame(art, frame, direction);
if (frm == nullptr) {
if (frm == NULL) {
return -1;
}
@@ -763,23 +755,23 @@ int artGetSize(Art* art, int frame, int direction, int* widthPtr, int* heightPtr
ArtFrame* frm;
frm = artGetFrame(art, frame, direction);
if (frm == nullptr) {
if (widthPtr != nullptr) {
if (frm == NULL) {
if (widthPtr != NULL) {
*widthPtr = 0;
}
if (heightPtr != nullptr) {
if (heightPtr != NULL) {
*heightPtr = 0;
}
return -1;
}
if (widthPtr != nullptr) {
if (widthPtr != NULL) {
*widthPtr = frm->width;
}
if (heightPtr != nullptr) {
if (heightPtr != NULL) {
*heightPtr = frm->height;
}
@@ -792,7 +784,7 @@ int artGetFrameOffsets(Art* art, int frame, int direction, int* xPtr, int* yPtr)
ArtFrame* frm;
frm = artGetFrame(art, frame, direction);
if (frm == nullptr) {
if (frm == NULL) {
return -1;
}
@@ -805,7 +797,7 @@ int artGetFrameOffsets(Art* art, int frame, int direction, int* xPtr, int* yPtr)
// 0x41984C
int artGetRotationOffsets(Art* art, int rotation, int* xPtr, int* yPtr)
{
if (art == nullptr) {
if (art == NULL) {
return -1;
}
@@ -821,8 +813,8 @@ unsigned char* artGetFrameData(Art* art, int frame, int direction)
ArtFrame* frm;
frm = artGetFrame(art, frame, direction);
if (frm == nullptr) {
return nullptr;
if (frm == NULL) {
return NULL;
}
return (unsigned char*)frm + sizeof(*frm);
@@ -832,15 +824,15 @@ unsigned char* artGetFrameData(Art* art, int frame, int direction)
ArtFrame* artGetFrame(Art* art, int frame, int rotation)
{
if (rotation < 0 || rotation >= 6) {
return nullptr;
return NULL;
}
if (art == nullptr) {
return nullptr;
if (art == NULL) {
return NULL;
}
if (frame < 0 || frame >= art->frameCount) {
return nullptr;
return NULL;
}
ArtFrame* frm = (ArtFrame*)((unsigned char*)art + sizeof(*art) + art->dataOffsets[rotation] + art->padding[rotation]);
@@ -856,7 +848,7 @@ bool artExists(int fid)
bool result = false;
char* filePath = artBuildFilePath(fid);
if (filePath != nullptr) {
if (filePath != NULL) {
int fileSize;
if (dbGetFileSize(filePath, &fileSize) != -1) {
result = true;
@@ -874,7 +866,7 @@ bool _art_fid_valid(int fid)
bool result = false;
char* filePath = artBuildFilePath(fid);
if (filePath != nullptr) {
if (filePath != NULL) {
int fileSize;
if (dbGetFileSize(filePath, &fileSize) != -1) {
result = true;
@@ -930,13 +922,13 @@ static int artCacheGetFileSizeImpl(int fid, int* sizePtr)
int result = -1;
char* artFilePath = artBuildFilePath(fid);
if (artFilePath != nullptr) {
if (artFilePath != NULL) {
bool loaded = false;
File* stream = nullptr;
File* stream = NULL;
if (gArtLanguageInitialized) {
char* pch = strchr(artFilePath, '\\');
if (pch == nullptr) {
if (pch == NULL) {
pch = artFilePath;
}
@@ -946,11 +938,11 @@ static int artCacheGetFileSizeImpl(int fid, int* sizePtr)
stream = fileOpen(localizedPath, "rb");
}
if (stream == nullptr) {
if (stream == NULL) {
stream = fileOpen(artFilePath, "rb");
}
if (stream != nullptr) {
if (stream != NULL) {
Art art;
if (artReadHeader(&art, stream) == 0) {
*sizePtr = artGetDataSize(&art);
@@ -969,11 +961,11 @@ static int artCacheReadDataImpl(int fid, int* sizePtr, unsigned char* data)
int result = -1;
char* artFileName = artBuildFilePath(fid);
if (artFileName != nullptr) {
if (artFileName != NULL) {
bool loaded = false;
if (gArtLanguageInitialized) {
char* pch = strchr(artFileName, '\\');
if (pch == nullptr) {
if (pch == NULL) {
pch = artFileName;
}
@@ -1006,28 +998,45 @@ static void artCacheFreeImpl(void* ptr)
internal_free(ptr);
}
static int buildFidInternal(unsigned short frmId, unsigned char weaponCode, unsigned char animType, unsigned char objectType, unsigned char rotation)
{
return ((rotation << 28) & 0x70000000) | (objectType << 24) | ((animType << 16) & 0xFF0000) | ((weaponCode << 12) & 0xF000) | (frmId & 0xFFF);
}
// 0x419C88
int buildFid(int objectType, int frmId, int animType, int weaponCode, int rotation)
int buildFid(int objectType, int frmId, int animType, int a3, int rotation)
{
// Always use rotation 0 (NE) for non-critters, for certain critter animations.
// For other critter animations, check if art for the given rotation exists, if not try rotation 1 (E) and if that also doesn't exist, then default to 0 (NE).
if (objectType != OBJ_TYPE_CRITTER
|| animType == ANIM_FIRE_DANCE
|| animType < ANIM_FALL_BACK
|| animType > ANIM_FALL_FRONT_BLOOD) {
rotation = ROTATION_NE;
} else if (!artExists(buildFidInternal(frmId, weaponCode, animType, OBJ_TYPE_CRITTER, rotation))) {
rotation = rotation != ROTATION_E
&& artExists(buildFidInternal(frmId, weaponCode, animType, OBJ_TYPE_CRITTER, ROTATION_E))
? ROTATION_E
: ROTATION_NE;
int v7, v8, v9, v10;
v10 = rotation;
if (objectType != OBJ_TYPE_CRITTER) {
goto zero;
}
return buildFidInternal(frmId, weaponCode, animType, objectType, rotation);
if (animType == ANIM_FIRE_DANCE || animType < ANIM_FALL_BACK || animType > ANIM_FALL_FRONT_BLOOD) {
goto zero;
}
v7 = ((a3 << 12) & 0xF000) | ((animType << 16) & 0xFF0000) | 0x1000000;
v8 = ((rotation << 28) & 0x70000000) | v7;
v9 = frmId & 0xFFF;
if (artExists(v9 | v8) != 0) {
goto out;
}
if (objectType == rotation) {
goto zero;
}
v10 = objectType;
if (artExists(v9 | v7 | 0x10000000) != 0) {
goto out;
}
zero:
v10 = 0;
out:
return ((v10 << 28) & 0x70000000) | (objectType << 24) | ((animType << 16) & 0xFF0000) | ((a3 << 12) & 0xF000) | (frmId & 0xFFF);
}
// 0x419D60
@@ -1113,7 +1122,7 @@ Art* artLoad(const char* path)
int artRead(const char* path, unsigned char* data)
{
File* stream = fileOpen(path, "rb");
if (stream == nullptr) {
if (stream == NULL) {
return -2;
}
@@ -1188,12 +1197,12 @@ int artWriteHeader(Art* art, File* stream)
// 0x41A1E8
int artWrite(const char* path, unsigned char* data)
{
if (data == nullptr) {
if (data == NULL) {
return -1;
}
File* stream = fileOpen(path, "wb");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
+1 -2
View File
@@ -123,7 +123,6 @@ char* artGetObjectTypeName(int objectType);
int artIsObjectTypeHidden(int objectType);
int artGetFidgetCount(int headFid);
void artRender(int fid, unsigned char* dest, int width, int height, int pitch);
int art_list_str(int fid, char* name);
Art* artLock(int fid, CacheEntry** cache_entry);
unsigned char* artLockFrameData(int fid, int frame, int direction, CacheEntry** out_cache_entry);
unsigned char* artLockFrameDataReturningSize(int fid, CacheEntry** out_cache_entry, int* widthPtr, int* heightPtr);
@@ -147,7 +146,7 @@ bool _art_fid_valid(int fid);
int _art_alias_num(int a1);
int artCritterFidShouldRun(int a1);
int artAliasFid(int fid);
int buildFid(int objectType, int frmId, int animType, int weaponCode, int rotation);
int buildFid(int objectType, int frmId, int animType, int a4, int rotation);
Art* artLoad(const char* path);
int artRead(const char* path, unsigned char* data);
int artWrite(const char* path, unsigned char* data);
+6 -6
View File
@@ -43,7 +43,7 @@ static Audio* gAudioList;
static bool defaultCompressionFunc(char* filePath)
{
char* pch = strrchr(filePath, '.');
if (pch != nullptr) {
if (pch != NULL) {
strcpy(pch + 1, "raw");
}
@@ -71,7 +71,7 @@ int audioOpen(const char* fname, int* sampleRate)
}
File* stream = fileOpen(path, "rb");
if (stream == nullptr) {
if (stream == NULL) {
debugPrint("AudioOpen: Couldn't open %s for read\n", path);
return -1;
}
@@ -84,7 +84,7 @@ int audioOpen(const char* fname, int* sampleRate)
}
if (index == gAudioListLength) {
if (gAudioList != nullptr) {
if (gAudioList != NULL) {
gAudioList = (Audio*)internal_realloc_safe(gAudioList, sizeof(*gAudioList) * (gAudioListLength + 1), __FILE__, __LINE__); // "..\int\audio.c", 216
} else {
gAudioList = (Audio*)internal_malloc_safe(sizeof(*gAudioList), __FILE__, __LINE__); // "..\int\audio.c", 218
@@ -234,7 +234,7 @@ int audioWrite(int handle, const void* buf, unsigned int size)
int audioInit(AudioQueryCompressedFunc* func)
{
queryCompressedFunc = func;
gAudioList = nullptr;
gAudioList = NULL;
gAudioListLength = 0;
return soundSetDefaultFileIO(audioOpen, audioClose, audioRead, audioWrite, audioSeek, audioTell, audioGetSize);
@@ -243,12 +243,12 @@ int audioInit(AudioQueryCompressedFunc* func)
// 0x41A818
void audioExit()
{
if (gAudioList != nullptr) {
if (gAudioList != NULL) {
internal_free_safe(gAudioList, __FILE__, __LINE__); // "..\int\audio.c", 406
}
gAudioListLength = 0;
gAudioList = nullptr;
gAudioList = NULL;
}
} // namespace fallout
+13 -13
View File
@@ -106,7 +106,7 @@ bool audioEngineInit()
desiredSpec.samples = 1024;
desiredSpec.callback = audioEngineMixin;
gAudioEngineDeviceId = SDL_OpenAudioDevice(nullptr, 0, &desiredSpec, &gAudioEngineSpec, SDL_AUDIO_ALLOW_ANY_CHANGE);
gAudioEngineDeviceId = SDL_OpenAudioDevice(NULL, 0, &desiredSpec, &gAudioEngineSpec, SDL_AUDIO_ALLOW_ANY_CHANGE);
if (gAudioEngineDeviceId == -1) {
return false;
}
@@ -191,10 +191,10 @@ bool audioEngineSoundBufferRelease(int soundBufferIndex)
soundBuffer->active = false;
free(soundBuffer->data);
soundBuffer->data = nullptr;
soundBuffer->data = NULL;
SDL_FreeAudioStream(soundBuffer->stream);
soundBuffer->stream = nullptr;
soundBuffer->stream = NULL;
return true;
}
@@ -331,11 +331,11 @@ bool audioEngineSoundBufferGetCurrentPosition(int soundBufferIndex, unsigned int
return false;
}
if (readPosPtr != nullptr) {
if (readPosPtr != NULL) {
*readPosPtr = soundBuffer->pos;
}
if (writePosPtr != nullptr) {
if (writePosPtr != NULL) {
*writePosPtr = soundBuffer->pos;
if (soundBuffer->playing) {
@@ -388,12 +388,12 @@ bool audioEngineSoundBufferLock(int soundBufferIndex, unsigned int writePos, uns
return false;
}
if (audioBytes1 == nullptr) {
if (audioBytes1 == NULL) {
return false;
}
if ((flags & AUDIO_ENGINE_SOUND_BUFFER_LOCK_FROM_WRITE_POS) != 0) {
if (!audioEngineSoundBufferGetCurrentPosition(soundBufferIndex, nullptr, &writePos)) {
if (!audioEngineSoundBufferGetCurrentPosition(soundBufferIndex, NULL, &writePos)) {
return false;
}
}
@@ -406,11 +406,11 @@ bool audioEngineSoundBufferLock(int soundBufferIndex, unsigned int writePos, uns
*(unsigned char**)audioPtr1 = (unsigned char*)soundBuffer->data + writePos;
*audioBytes1 = writeBytes;
if (audioPtr2 != nullptr) {
*audioPtr2 = nullptr;
if (audioPtr2 != NULL) {
*audioPtr2 = NULL;
}
if (audioBytes2 != nullptr) {
if (audioBytes2 != NULL) {
*audioBytes2 = 0;
}
} else {
@@ -418,11 +418,11 @@ bool audioEngineSoundBufferLock(int soundBufferIndex, unsigned int writePos, uns
*(unsigned char**)audioPtr1 = (unsigned char*)soundBuffer->data + writePos;
*audioBytes1 = soundBuffer->size - writePos;
if (audioPtr2 != nullptr) {
if (audioPtr2 != NULL) {
*(unsigned char**)audioPtr2 = (unsigned char*)soundBuffer->data;
}
if (audioBytes2 != nullptr) {
if (audioBytes2 != NULL) {
*audioBytes2 = writeBytes - (soundBuffer->size - writePos);
}
}
@@ -471,7 +471,7 @@ bool audioEngineSoundBufferGetStatus(int soundBufferIndex, unsigned int* statusP
return false;
}
if (statusPtr == nullptr) {
if (statusPtr == NULL) {
return false;
}
+6 -6
View File
@@ -43,7 +43,7 @@ static int gAudioFileListLength;
static bool defaultCompressionFunc(char* filePath)
{
char* pch = strrchr(filePath, '.');
if (pch != nullptr) {
if (pch != NULL) {
strcpy(pch + 1, "raw");
}
@@ -70,7 +70,7 @@ int audioFileOpen(const char* fname, int* sampleRate)
}
FILE* stream = compat_fopen(path, "rb");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -82,7 +82,7 @@ int audioFileOpen(const char* fname, int* sampleRate)
}
if (index == gAudioFileListLength) {
if (gAudioFileList != nullptr) {
if (gAudioFileList != NULL) {
gAudioFileList = (AudioFile*)internal_realloc_safe(gAudioFileList, sizeof(*gAudioFileList) * (gAudioFileListLength + 1), __FILE__, __LINE__); // "..\int\audiof.c", 207
} else {
gAudioFileList = (AudioFile*)internal_malloc_safe(sizeof(*gAudioFileList), __FILE__, __LINE__); // "..\int\audiof.c", 209
@@ -231,7 +231,7 @@ int audioFileWrite(int handle, const void* buffer, unsigned int size)
int audioFileInit(AudioFileQueryCompressedFunc* func)
{
queryCompressedFunc = func;
gAudioFileList = nullptr;
gAudioFileList = NULL;
gAudioFileListLength = 0;
return soundSetDefaultFileIO(audioFileOpen, audioFileClose, audioFileRead, audioFileWrite, audioFileSeek, audioFileTell, audioFileGetSize);
@@ -240,12 +240,12 @@ int audioFileInit(AudioFileQueryCompressedFunc* func)
// 0x41ADAC
void audioFileExit()
{
if (gAudioFileList != nullptr) {
if (gAudioFileList != NULL) {
internal_free_safe(gAudioFileList, __FILE__, __LINE__); // "..\int\audiof.c", 405
}
gAudioFileListLength = 0;
gAudioFileList = nullptr;
gAudioFileList = NULL;
}
} // namespace fallout
+23 -23
View File
@@ -336,7 +336,7 @@ void automapShow(bool isInGame, bool isUsingScanner)
KEY_LOWERCASE_S,
frmImages[AUTOMAP_FRM_BUTTON_UP].getData(),
frmImages[AUTOMAP_FRM_BUTTON_DOWN].getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (scannerBtn != -1) {
buttonSetCallbacks(scannerBtn, _gsound_red_butt_press, _gsound_red_butt_release);
@@ -353,7 +353,7 @@ void automapShow(bool isInGame, bool isUsingScanner)
KEY_ESCAPE,
frmImages[AUTOMAP_FRM_BUTTON_UP].getData(),
frmImages[AUTOMAP_FRM_BUTTON_DOWN].getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (cancelBtn != -1) {
buttonSetCallbacks(cancelBtn, _gsound_red_butt_press, _gsound_red_butt_release);
@@ -370,7 +370,7 @@ void automapShow(bool isInGame, bool isUsingScanner)
KEY_LOWERCASE_H,
frmImages[AUTOMAP_FRM_SWITCH_UP].getData(),
frmImages[AUTOMAP_FRM_SWITCH_DOWN].getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT | BUTTON_FLAG_0x01);
if (switchBtn != -1) {
buttonSetCallbacks(switchBtn, _gsound_toggle_butt_press_, _gsound_toggle_butt_press_);
@@ -435,19 +435,19 @@ void automapShow(bool isInGame, bool isUsingScanner)
}
if ((gAutomapFlags & AUTOMAP_WITH_SCANNER) == 0) {
Object* scanner = nullptr;
Object* scanner = NULL;
Object* item1 = critterGetItem1(gDude);
if (item1 != nullptr && item1->pid == PROTO_ID_MOTION_SENSOR) {
if (item1 != NULL && item1->pid == PROTO_ID_MOTION_SENSOR) {
scanner = item1;
} else {
Object* item2 = critterGetItem2(gDude);
if (item2 != nullptr && item2->pid == PROTO_ID_MOTION_SENSOR) {
if (item2 != NULL && item2->pid == PROTO_ID_MOTION_SENSOR) {
scanner = item2;
}
}
if (scanner != nullptr && miscItemGetCharges(scanner) > 0) {
if (scanner != NULL && miscItemGetCharges(scanner) > 0) {
needsRefresh = true;
gAutomapFlags |= AUTOMAP_WITH_SCANNER;
miscItemConsumeCharge(scanner);
@@ -457,8 +457,8 @@ void automapShow(bool isInGame, bool isUsingScanner)
MessageListItem messageListItem;
// 17 - The motion sensor is not installed.
// 18 - The motion sensor has no charges remaining.
const char* title = getmsg(&gMiscMessageList, &messageListItem, scanner != nullptr ? 18 : 17);
showDialogBox(title, nullptr, 0, 165, 140, _colorTable[32328], nullptr, _colorTable[32328], 0);
const char* title = getmsg(&gMiscMessageList, &messageListItem, scanner != NULL ? 18 : 17);
showDialogBox(title, NULL, 0, 165, 140, _colorTable[32328], NULL, _colorTable[32328], 0);
}
}
@@ -512,7 +512,7 @@ static void automapRenderInMapWindow(int window, int elevation, unsigned char* b
unsigned char* windowBuffer = windowGetBuffer(window);
blitBufferToBuffer(backgroundData, AUTOMAP_WINDOW_WIDTH, AUTOMAP_WINDOW_HEIGHT, AUTOMAP_WINDOW_WIDTH, windowBuffer, AUTOMAP_WINDOW_WIDTH);
for (Object* object = objectFindFirstAtElevation(elevation); object != nullptr; object = objectFindNextAtElevation()) {
for (Object* object = objectFindFirstAtElevation(elevation); object != NULL; object = objectFindNextAtElevation()) {
if (object->tile == -1) {
continue;
}
@@ -626,7 +626,7 @@ int automapRenderInPipboyWindow(int window, int map, int elevation)
unsigned char sceneryColor = _colorTable[480];
gAutomapEntry.data = (unsigned char*)internal_malloc(11024);
if (gAutomapEntry.data == nullptr) {
if (gAutomapEntry.data == NULL) {
debugPrint("\nAUTOMAP: Error allocating data buffer!\n");
return -1;
}
@@ -694,9 +694,9 @@ int automapSaveCurrent()
bool dataBuffersAllocated = false;
gAutomapEntry.data = (unsigned char*)internal_malloc(11024);
if (gAutomapEntry.data != nullptr) {
if (gAutomapEntry.data != NULL) {
gAutomapEntry.compressedData = (unsigned char*)internal_malloc(11024);
if (gAutomapEntry.compressedData != nullptr) {
if (gAutomapEntry.compressedData != NULL) {
dataBuffersAllocated = true;
}
}
@@ -712,7 +712,7 @@ int automapSaveCurrent()
snprintf(path, sizeof(path), "%s\\%s", "MAPS", AUTOMAP_DB);
File* stream1 = fileOpen(path, "r+b");
if (stream1 == nullptr) {
if (stream1 == NULL) {
debugPrint("\nAUTOMAP: Error opening automap database file!\n");
debugPrint("Error continued: automap_pip_save: path: %s", path);
internal_free(gAutomapEntry.data);
@@ -743,7 +743,7 @@ int automapSaveCurrent()
snprintf(path, sizeof(path), "%s\\%s", "MAPS", AUTOMAP_TMP);
File* stream2 = fileOpen(path, "wb");
if (stream2 == nullptr) {
if (stream2 == NULL) {
debugPrint("\nAUTOMAP: Error creating temp file!\n");
internal_free(gAutomapEntry.data);
internal_free(gAutomapEntry.compressedData);
@@ -928,7 +928,7 @@ err:
// 0x41C8CC
static int automapLoadEntry(int map, int elevation)
{
gAutomapEntry.compressedData = nullptr;
gAutomapEntry.compressedData = NULL;
char path[COMPAT_MAX_PATH];
snprintf(path, sizeof(path), "%s\\%s", "MAPS", AUTOMAP_DB);
@@ -936,7 +936,7 @@ static int automapLoadEntry(int map, int elevation)
bool success = true;
File* stream = fileOpen(path, "r+b");
if (stream == nullptr) {
if (stream == NULL) {
debugPrint("\nAUTOMAP: Error opening automap database file!\n");
debugPrint("Error continued: AM_ReadEntry: path: %s", path);
return -1;
@@ -970,7 +970,7 @@ static int automapLoadEntry(int map, int elevation)
if (gAutomapEntry.isCompressed == 1) {
gAutomapEntry.compressedData = (unsigned char*)internal_malloc(11024);
if (gAutomapEntry.compressedData == nullptr) {
if (gAutomapEntry.compressedData == NULL) {
debugPrint("\nAUTOMAP: Error allocating decompression buffer!\n");
fileClose(stream);
return -1;
@@ -1003,7 +1003,7 @@ out:
return -1;
}
if (gAutomapEntry.compressedData != nullptr) {
if (gAutomapEntry.compressedData != NULL) {
internal_free(gAutomapEntry.compressedData);
}
@@ -1073,7 +1073,7 @@ static void _decode_map_data(int elevation)
_obj_process_seen();
Object* object = objectFindFirstAtElevation(elevation);
while (object != nullptr) {
while (object != NULL) {
if (object->tile != -1 && (object->flags & OBJECT_SEEN) != 0) {
int contentType;
@@ -1109,7 +1109,7 @@ static int automapCreate()
snprintf(path, sizeof(path), "%s\\%s", "MAPS", AUTOMAP_DB);
File* stream = fileOpen(path, "wb");
if (stream == nullptr) {
if (stream == NULL) {
debugPrint("\nAUTOMAP: Error creating automap database file!\n");
return -1;
}
@@ -1129,7 +1129,7 @@ static int automapCreate()
static int _copy_file_data(File* stream1, File* stream2, int length)
{
void* buffer = internal_malloc(0xFFFF);
if (buffer == nullptr) {
if (buffer == NULL) {
return -1;
}
@@ -1164,7 +1164,7 @@ int automapGetHeader(AutomapHeader** automapHeaderPtr)
snprintf(path, sizeof(path), "%s\\%s", "MAPS", AUTOMAP_DB);
File* stream = fileOpen(path, "rb");
if (stream == nullptr) {
if (stream == NULL) {
debugPrint("\nAUTOMAP: Error opening database file for reading!\n");
debugPrint("Error continued: ReadAMList: path: %s", path);
return -1;
+2 -2
View File
@@ -15,7 +15,7 @@ namespace fallout {
bool autorunMutexCreate()
{
#ifdef _WIN32
gInterplayGenericAutorunMutex = CreateMutexA(nullptr, FALSE, "InterplayGenericAutorunMutex");
gInterplayGenericAutorunMutex = CreateMutexA(NULL, FALSE, "InterplayGenericAutorunMutex");
if (GetLastError() == ERROR_ALREADY_EXISTS) {
CloseHandle(gInterplayGenericAutorunMutex);
return false;
@@ -29,7 +29,7 @@ bool autorunMutexCreate()
void autorunMutexClose()
{
#ifdef _WIN32
if (gInterplayGenericAutorunMutex != nullptr) {
if (gInterplayGenericAutorunMutex != NULL) {
CloseHandle(gInterplayGenericAutorunMutex);
}
#endif
+19 -19
View File
@@ -51,7 +51,7 @@ bool cacheInit(Cache* cache, CacheSizeProc* sizeProc, CacheReadProc* readProc, C
cache->readProc = readProc;
cache->freeProc = freeProc;
if (cache->entries == nullptr) {
if (cache->entries == NULL) {
return false;
}
@@ -64,7 +64,7 @@ bool cacheInit(Cache* cache, CacheSizeProc* sizeProc, CacheReadProc* readProc, C
// 0x41FD50
bool cacheFree(Cache* cache)
{
if (cache == nullptr) {
if (cache == NULL) {
return false;
}
@@ -78,14 +78,14 @@ bool cacheFree(Cache* cache)
cache->entriesCapacity = 0;
cache->hits = 0;
if (cache->entries != nullptr) {
if (cache->entries != NULL) {
internal_free(cache->entries);
cache->entries = nullptr;
cache->entries = NULL;
}
cache->sizeProc = nullptr;
cache->readProc = nullptr;
cache->freeProc = nullptr;
cache->sizeProc = NULL;
cache->readProc = NULL;
cache->freeProc = NULL;
return true;
}
@@ -93,11 +93,11 @@ bool cacheFree(Cache* cache)
// 0x41FDE8
bool cacheLock(Cache* cache, int key, void** data, CacheEntry** cacheEntryPtr)
{
if (cache == nullptr || data == nullptr || cacheEntryPtr == nullptr) {
if (cache == NULL || data == NULL || cacheEntryPtr == NULL) {
return false;
}
*cacheEntryPtr = nullptr;
*cacheEntryPtr = NULL;
int index;
int rc = cacheFindIndexForKey(cache, key, &index);
@@ -148,7 +148,7 @@ bool cacheLock(Cache* cache, int key, void** data, CacheEntry** cacheEntryPtr)
// 0x4200B8
bool cacheUnlock(Cache* cache, CacheEntry* cacheEntry)
{
if (cache == nullptr || cacheEntry == nullptr) {
if (cache == NULL || cacheEntry == NULL) {
return false;
}
@@ -169,7 +169,7 @@ bool cacheUnlock(Cache* cache, CacheEntry* cacheEntry)
// 0x42012C
bool cacheFlush(Cache* cache)
{
if (cache == nullptr) {
if (cache == NULL) {
return false;
}
@@ -196,7 +196,7 @@ bool cacheFlush(Cache* cache)
// 0x42019C
bool cachePrintStats(Cache* cache, char* dest, size_t size)
{
if (cache == nullptr || dest == nullptr) {
if (cache == NULL || dest == NULL) {
return false;
}
@@ -211,7 +211,7 @@ bool cachePrintStats(Cache* cache, char* dest, size_t size)
static bool cacheFetchEntryForKey(Cache* cache, int key, int* indexPtr)
{
CacheEntry* cacheEntry = (CacheEntry*)internal_malloc(sizeof(*cacheEntry));
if (cacheEntry == nullptr) {
if (cacheEntry == NULL) {
return false;
}
@@ -376,7 +376,7 @@ static bool cacheEntryInit(CacheEntry* cacheEntry)
{
cacheEntry->key = 0;
cacheEntry->size = 0;
cacheEntry->data = nullptr;
cacheEntry->data = NULL;
cacheEntry->referenceCount = 0;
cacheEntry->hits = 0;
cacheEntry->flags = 0;
@@ -389,7 +389,7 @@ static bool cacheEntryInit(CacheEntry* cacheEntry)
// 0x420740
static bool cacheEntryFree(Cache* cache, CacheEntry* cacheEntry)
{
if (cacheEntry->data != nullptr) {
if (cacheEntry->data != NULL) {
heapBlockDeallocate(&(cache->heap), &(cacheEntry->heapHandleIndex));
}
@@ -420,12 +420,12 @@ static bool cacheClean(Cache* cache)
// 0x4207D4
static bool cacheResetStatistics(Cache* cache)
{
if (cache == nullptr) {
if (cache == NULL) {
return false;
}
CacheEntry** entries = (CacheEntry**)internal_malloc(sizeof(*entries) * cache->entriesLength);
if (entries == nullptr) {
if (entries == NULL) {
return false;
}
@@ -462,7 +462,7 @@ static bool cacheEnsureSize(Cache* cache, int size)
}
CacheEntry** entries = (CacheEntry**)internal_malloc(sizeof(*entries) * cache->entriesLength);
if (entries != nullptr) {
if (entries != NULL) {
memcpy(entries, cache->entries, sizeof(*entries) * cache->entriesLength);
qsort(entries, cache->entriesLength, sizeof(*entries), cacheEntriesCompareByUsage);
@@ -562,7 +562,7 @@ static bool cacheSetCapacity(Cache* cache, int newCapacity)
}
CacheEntry** entries = (CacheEntry**)internal_realloc(cache->entries, sizeof(*cache->entries) * newCapacity);
if (entries == nullptr) {
if (entries == NULL) {
return false;
}
+223 -207
View File
File diff suppressed because it is too large Load Diff
+25 -25
View File
@@ -107,10 +107,10 @@ static int gPremadeCharacterCount = PREMADE_CHARACTER_COUNT;
static int gCharacterSelectorWindow = -1;
// 0x51C7FC
static unsigned char* gCharacterSelectorWindowBuffer = nullptr;
static unsigned char* gCharacterSelectorWindowBuffer = NULL;
// 0x51C800
static unsigned char* gCharacterSelectorBackground = nullptr;
static unsigned char* gCharacterSelectorBackground = NULL;
// 0x51C804
static int gCharacterSelectorWindowPreviousButton = -1;
@@ -269,7 +269,7 @@ static bool characterSelectorWindowInit()
}
gCharacterSelectorWindowBuffer = windowGetBuffer(gCharacterSelectorWindow);
if (gCharacterSelectorWindowBuffer == nullptr) {
if (gCharacterSelectorWindowBuffer == NULL) {
return characterSelectorWindowFatalError(false);
}
@@ -287,7 +287,7 @@ static bool characterSelectorWindowInit()
CS_WINDOW_WIDTH);
gCharacterSelectorBackground = (unsigned char*)internal_malloc(CS_WINDOW_BACKGROUND_WIDTH * CS_WINDOW_BACKGROUND_HEIGHT);
if (gCharacterSelectorBackground == nullptr)
if (gCharacterSelectorBackground == NULL)
return characterSelectorWindowFatalError(false);
blitBufferToBuffer(backgroundFrmImage.getData() + CS_WINDOW_WIDTH * CS_WINDOW_BACKGROUND_Y + CS_WINDOW_BACKGROUND_X,
@@ -323,7 +323,7 @@ static bool characterSelectorWindowInit()
500,
_previousButtonNormalFrmImage.getData(),
_previousButtonPressedFrmImage.getData(),
nullptr,
NULL,
0);
if (gCharacterSelectorWindowPreviousButton == -1) {
return characterSelectorWindowFatalError(false);
@@ -353,7 +353,7 @@ static bool characterSelectorWindowInit()
501,
_nextButtonNormalFrmImage.getData(),
_nextButtonPressedFrmImage.getData(),
nullptr,
NULL,
0);
if (gCharacterSelectorWindowNextButton == -1) {
return characterSelectorWindowFatalError(false);
@@ -383,7 +383,7 @@ static bool characterSelectorWindowInit()
KEY_LOWERCASE_T,
_takeButtonNormalFrmImage.getData(),
_takeButtonPressedFrmImage.getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (gCharacterSelectorWindowTakeButton == -1) {
return characterSelectorWindowFatalError(false);
@@ -412,7 +412,7 @@ static bool characterSelectorWindowInit()
KEY_LOWERCASE_M,
_modifyButtonNormalFrmImage.getData(),
_modifyButtonPressedFrmImage.getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (gCharacterSelectorWindowModifyButton == -1) {
return characterSelectorWindowFatalError(false);
@@ -442,7 +442,7 @@ static bool characterSelectorWindowInit()
KEY_LOWERCASE_C,
_createButtonNormalFrmImage.getData(),
_createButtonPressedFrmImage.getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (gCharacterSelectorWindowCreateButton == -1) {
return characterSelectorWindowFatalError(false);
@@ -472,7 +472,7 @@ static bool characterSelectorWindowInit()
KEY_ESCAPE,
_backButtonNormalFrmImage.getData(),
_backButtonPressedFrmImage.getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (gCharacterSelectorWindowBackButton == -1) {
return characterSelectorWindowFatalError(false);
@@ -546,9 +546,9 @@ static void characterSelectorWindowFree()
_backButtonNormalFrmImage.unlock();
_backButtonPressedFrmImage.unlock();
if (gCharacterSelectorBackground != nullptr) {
if (gCharacterSelectorBackground != NULL) {
internal_free(gCharacterSelectorBackground);
gCharacterSelectorBackground = nullptr;
gCharacterSelectorBackground = NULL;
}
windowDestroy(gCharacterSelectorWindow);
@@ -595,7 +595,7 @@ static bool characterSelectorWindowRenderFace()
int faceFid = buildFid(OBJ_TYPE_INTERFACE, gCustomPremadeCharacterDescriptions[gCurrentPremadeCharacter].face, 0, 0, 0);
if (faceFrmImage.lock(faceFid)) {
unsigned char* data = faceFrmImage.getData();
if (data != nullptr) {
if (data != NULL) {
int width = faceFrmImage.getWidth();
int height = faceFrmImage.getHeight();
blitBufferToBufferTrans(data, width, height, width, (gCharacterSelectorWindowBuffer + CS_WINDOW_WIDTH * 23 + 27), CS_WINDOW_WIDTH);
@@ -870,7 +870,7 @@ static bool characterSelectorWindowRenderBio()
premadeCharactersLocalizePath(path);
File* stream = fileOpen(path, "rt");
if (stream != nullptr) {
if (stream != NULL) {
int y = 40;
int lineHeight = fontGetLineHeight();
@@ -901,24 +901,24 @@ void premadeCharactersInit()
{
char* fileNamesString;
configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_PREMADE_CHARACTERS_FILE_NAMES_KEY, &fileNamesString);
if (fileNamesString != nullptr && *fileNamesString == '\0') {
fileNamesString = nullptr;
if (fileNamesString != NULL && *fileNamesString == '\0') {
fileNamesString = NULL;
}
char* faceFidsString;
configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_PREMADE_CHARACTERS_FACE_FIDS_KEY, &faceFidsString);
if (faceFidsString != nullptr && *faceFidsString == '\0') {
faceFidsString = nullptr;
if (faceFidsString != NULL && *faceFidsString == '\0') {
faceFidsString = NULL;
}
if (fileNamesString != nullptr && faceFidsString != nullptr) {
if (fileNamesString != NULL && faceFidsString != NULL) {
int fileNamesLength = 0;
for (char* pch = fileNamesString; pch != nullptr; pch = strchr(pch + 1, ',')) {
for (char* pch = fileNamesString; pch != NULL; pch = strchr(pch + 1, ',')) {
fileNamesLength++;
}
int faceFidsLength = 0;
for (char* pch = faceFidsString; pch != nullptr; pch = strchr(pch + 1, ',')) {
for (char* pch = faceFidsString; pch != NULL; pch = strchr(pch + 1, ',')) {
faceFidsLength++;
}
@@ -929,7 +929,7 @@ void premadeCharactersInit()
char* pch;
pch = strchr(fileNamesString, ',');
if (pch != nullptr) {
if (pch != NULL) {
*pch = '\0';
}
@@ -940,20 +940,20 @@ void premadeCharactersInit()
snprintf(gCustomPremadeCharacterDescriptions[index].fileName, sizeof(gCustomPremadeCharacterDescriptions[index].fileName), "premade\\%s", fileNamesString);
if (pch != nullptr) {
if (pch != NULL) {
*pch = ',';
}
fileNamesString = pch + 1;
pch = strchr(faceFidsString, ',');
if (pch != nullptr) {
if (pch != NULL) {
*pch = '\0';
}
gCustomPremadeCharacterDescriptions[index].face = atoi(faceFidsString);
if (pch != nullptr) {
if (pch != NULL) {
*pch = ',';
}
+189 -22
View File
@@ -5,12 +5,24 @@
#include <algorithm>
#include "db.h"
#include "memory.h"
#include "svga.h"
namespace fallout {
#define COLOR_PALETTE_STACK_CAPACITY 16
typedef struct ColorPaletteStackEntry {
unsigned char mappedColors[256];
unsigned char cmap[768];
unsigned char colorTable[32768];
} ColorPaletteStackEntry;
static int colorPaletteFileOpen(const char* filePath, int flags);
static int colorPaletteFileRead(int fd, void* buffer, size_t size);
static int colorPaletteFileClose(int fd);
static void* colorPaletteMallocDefaultImpl(size_t size);
static void* colorPaletteReallocDefaultImpl(void* ptr, size_t size);
static void colorPaletteFreeDefaultImpl(void* ptr);
static void _setIntensityTableColor(int a1);
static void _setIntensityTables();
static void _setMixTableColor(int a1);
@@ -39,16 +51,28 @@ static bool _colorsInited = false;
static double gBrightness = 1.0;
// 0x51DF20
static ColorTransitionCallback* gColorPaletteTransitionCallback = nullptr;
static ColorTransitionCallback* gColorPaletteTransitionCallback = NULL;
// 0x51DF24
static MallocProc* gColorPaletteMallocProc = colorPaletteMallocDefaultImpl;
// 0x51DF28
static ReallocProc* gColorPaletteReallocProc = colorPaletteReallocDefaultImpl;
// 0x51DF2C
static FreeProc* gColorPaletteFreeProc = colorPaletteFreeDefaultImpl;
// 0x51DF30
static ColorFileNameManger* gColorFileNameMangler = nullptr;
static ColorFileNameManger* gColorFileNameMangler = NULL;
// 0x51DF34
unsigned char _cmap[768] = {
0x3F, 0x3F, 0x3F
};
// 0x673050
static ColorPaletteStackEntry* gColorPaletteStack[COLOR_PALETTE_STACK_CAPACITY];
// 0x673090
unsigned char _systemCmap[256 * 3];
@@ -73,6 +97,80 @@ Color colorMixMulTable[256][256];
// 0x6A38D0
unsigned char _colorTable[32768];
// 0x6AB8D0
static int gColorPaletteStackSize;
// 0x6AB928
static ColorPaletteFileReadProc* gColorPaletteFileReadProc;
// 0x6AB92C
static ColorPaletteCloseProc* gColorPaletteFileCloseProc;
// 0x6AB930
static ColorPaletteFileOpenProc* gColorPaletteFileOpenProc;
// NOTE: Inlined.
//
// 0x4C7200
static int colorPaletteFileOpen(const char* filePath, int flags)
{
if (gColorPaletteFileOpenProc != NULL) {
return gColorPaletteFileOpenProc(filePath, flags);
}
return -1;
}
// NOTE: Inlined.
//
// 0x4C7218
static int colorPaletteFileRead(int fd, void* buffer, size_t size)
{
if (gColorPaletteFileReadProc != NULL) {
return gColorPaletteFileReadProc(fd, buffer, size);
}
return -1;
}
// NOTE: Inlined.
//
// 0x4C7230
static int colorPaletteFileClose(int fd)
{
if (gColorPaletteFileCloseProc != NULL) {
return gColorPaletteFileCloseProc(fd);
}
return -1;
}
// 0x4C7248
void colorPaletteSetFileIO(ColorPaletteFileOpenProc* openProc, ColorPaletteFileReadProc* readProc, ColorPaletteCloseProc* closeProc)
{
gColorPaletteFileOpenProc = openProc;
gColorPaletteFileReadProc = readProc;
gColorPaletteFileCloseProc = closeProc;
}
// 0x4C725C
static void* colorPaletteMallocDefaultImpl(size_t size)
{
return malloc(size);
}
// 0x4C7264
static void* colorPaletteReallocDefaultImpl(void* ptr, size_t size)
{
return realloc(ptr, size);
}
// 0x4C726C
static void colorPaletteFreeDefaultImpl(void* ptr)
{
free(ptr);
}
// 0x4C72B4
int _calculateColor(int intensity, Color color)
{
@@ -103,7 +201,7 @@ void colorPaletteFadeBetween(unsigned char* oldPalette, unsigned char* newPalett
palette[index] = oldPalette[index] - (oldPalette[index] - newPalette[index]) * step / steps;
}
if (gColorPaletteTransitionCallback != nullptr) {
if (gColorPaletteTransitionCallback != NULL) {
if (step % 128 == 0) {
gColorPaletteTransitionCallback();
}
@@ -293,12 +391,13 @@ static void _setMixTableColor(int a1)
// 0x4C78E4
bool colorPaletteLoad(const char* path)
{
if (gColorFileNameMangler != nullptr) {
if (gColorFileNameMangler != NULL) {
path = gColorFileNameMangler(path);
}
File* stream = fileOpen(path, "rb");
if (stream == nullptr) {
// NOTE: Uninline.
int fd = colorPaletteFileOpen(path, 0x200);
if (fd == -1) {
_errorStr = _aColor_cColorTa;
return false;
}
@@ -309,13 +408,13 @@ bool colorPaletteLoad(const char* path)
unsigned char b;
// NOTE: Uninline.
fileRead(&r, sizeof(r), 1, stream);
colorPaletteFileRead(fd, &r, sizeof(r));
// NOTE: Uninline.
fileRead(&g, sizeof(g), 1, stream);
colorPaletteFileRead(fd, &g, sizeof(g));
// NOTE: Uninline.
fileRead(&b, sizeof(b), 1, stream);
colorPaletteFileRead(fd, &b, sizeof(b));
if (r <= 0x3F && g <= 0x3F && b <= 0x3F) {
_mappedColor[index] = 1;
@@ -332,23 +431,23 @@ bool colorPaletteLoad(const char* path)
}
// NOTE: Uninline.
fileRead(_colorTable, 0x8000, 1, stream);
colorPaletteFileRead(fd, _colorTable, 0x8000);
unsigned int type;
// NOTE: Uninline.
fileRead(&type, sizeof(type), 1, stream);
colorPaletteFileRead(fd, &type, sizeof(type));
// NOTE: The value is "NEWC". Original code uses cmp opcode, not stricmp,
// or comparing characters one-by-one.
if (type == 'NEWC') {
// NOTE: Uninline.
fileRead(intensityColorTable, sizeof(intensityColorTable), 1, stream);
colorPaletteFileRead(fd, intensityColorTable, sizeof(intensityColorTable));
// NOTE: Uninline.
fileRead(colorMixAddTable, sizeof(colorMixAddTable), 1, stream);
colorPaletteFileRead(fd, colorMixAddTable, sizeof(colorMixAddTable));
// NOTE: Uninline.
fileRead(colorMixMulTable, sizeof(colorMixMulTable), 1, stream);
colorPaletteFileRead(fd, colorMixMulTable, sizeof(colorMixMulTable));
} else {
_setIntensityTables();
@@ -360,7 +459,7 @@ bool colorPaletteLoad(const char* path)
_rebuildColorBlendTables();
// NOTE: Uninline.
fileClose(stream);
colorPaletteFileClose(fd);
return true;
}
@@ -448,8 +547,8 @@ unsigned char* _getColorBlendTable(int ch)
{
unsigned char* ptr;
if (_blendTable[ch] == nullptr) {
ptr = (unsigned char*)internal_malloc(4100);
if (_blendTable[ch] == NULL) {
ptr = (unsigned char*)gColorPaletteMallocProc(4100);
*(int*)ptr = 1;
_blendTable[ch] = ptr + 4;
_buildBlendTable(_blendTable[ch], ch);
@@ -465,16 +564,24 @@ unsigned char* _getColorBlendTable(int ch)
void _freeColorBlendTable(int a1)
{
unsigned char* v2 = _blendTable[a1];
if (v2 != nullptr) {
if (v2 != NULL) {
int* count = (int*)(v2 - sizeof(int));
*count -= 1;
if (*count == 0) {
internal_free(count);
_blendTable[a1] = nullptr;
gColorPaletteFreeProc(count);
_blendTable[a1] = NULL;
}
}
}
// 0x4C7E58
void colorPaletteSetMemoryProcs(MallocProc* mallocProc, ReallocProc* reallocProc, FreeProc* freeProc)
{
gColorPaletteMallocProc = mallocProc;
gColorPaletteReallocProc = reallocProc;
gColorPaletteFreeProc = freeProc;
}
// 0x4C7E6C
void colorSetBrightness(double value)
{
@@ -488,6 +595,60 @@ void colorSetBrightness(double value)
_setSystemPalette(_systemCmap);
}
// NOTE: Unused.
//
// 0x4C8828
bool colorPushColorPalette()
{
if (gColorPaletteStackSize >= COLOR_PALETTE_STACK_CAPACITY) {
_errorStr = _aColor_cColorpa;
return false;
}
ColorPaletteStackEntry* entry = (ColorPaletteStackEntry*)malloc(sizeof(*entry));
gColorPaletteStack[gColorPaletteStackSize] = entry;
memcpy(entry->mappedColors, _mappedColor, sizeof(_mappedColor));
memcpy(entry->cmap, _cmap, sizeof(_cmap));
memcpy(entry->colorTable, _colorTable, sizeof(_colorTable));
gColorPaletteStackSize++;
return true;
}
// NOTE: Unused.
//
// 0x4C88E0
bool colorPopColorPalette()
{
if (gColorPaletteStackSize == 0) {
_errorStr = aColor_cColor_0;
return false;
}
gColorPaletteStackSize--;
ColorPaletteStackEntry* entry = gColorPaletteStack[gColorPaletteStackSize];
memcpy(_mappedColor, entry->mappedColors, sizeof(_mappedColor));
memcpy(_cmap, entry->cmap, sizeof(_cmap));
memcpy(_colorTable, entry->colorTable, sizeof(_colorTable));
free(entry);
gColorPaletteStack[gColorPaletteStackSize] = NULL;
_setIntensityTables();
for (int index = 0; index < 256; index++) {
_setMixTableColor(index);
}
_rebuildColorBlendTables();
return true;
}
// 0x4C89CC
bool _initColors()
{
@@ -514,6 +675,12 @@ void _colorsClose()
for (int index = 0; index < 256; index++) {
_freeColorBlendTable(index);
}
for (int index = 0; index < gColorPaletteStackSize; index++) {
free(gColorPaletteStack[index]);
}
gColorPaletteStackSize = 0;
}
} // namespace fallout
+10
View File
@@ -1,12 +1,18 @@
#ifndef COLOR_H
#define COLOR_H
#include "memory_defs.h"
namespace fallout {
typedef unsigned char Color;
typedef const char*(ColorFileNameManger)(const char*);
typedef void(ColorTransitionCallback)();
typedef int(ColorPaletteFileOpenProc)(const char* path, int mode);
typedef int(ColorPaletteFileReadProc)(int fd, void* buffer, size_t size);
typedef int(ColorPaletteCloseProc)(int fd);
extern unsigned char _cmap[768];
extern unsigned char _systemCmap[256 * 3];
@@ -18,6 +24,7 @@ extern Color intensityColorTable[256][256];
extern Color colorMixMulTable[256][256];
extern unsigned char _colorTable[32768];
void colorPaletteSetFileIO(ColorPaletteFileOpenProc* openProc, ColorPaletteFileReadProc* readProc, ColorPaletteCloseProc* closeProc);
int _calculateColor(int intensity, Color color);
int Color2RGB(Color c);
void colorPaletteFadeBetween(unsigned char* oldPalette, unsigned char* newPalette, int steps);
@@ -29,7 +36,10 @@ bool colorPaletteLoad(const char* path);
char* _colorError();
unsigned char* _getColorBlendTable(int ch);
void _freeColorBlendTable(int a1);
void colorPaletteSetMemoryProcs(MallocProc* mallocProc, ReallocProc* reallocProc, FreeProc* freeProc);
void colorSetBrightness(double value);
bool colorPushColorPalette();
bool colorPopColorPalette();
bool _initColors();
void _colorsClose();
+409 -421
View File
File diff suppressed because it is too large Load Diff
+9 -10
View File
@@ -33,14 +33,14 @@ void _combat_update_critter_outline_for_los(Object* critter, bool a2);
void _combat_over_from_load();
void _combat_give_exps(int exp_points);
void _combat_turn_run();
void _combat(CombatStartData* csd);
void attackInit(Attack* attack, Object* attacker, Object* defender, int hitMode, int hitLocation);
int _combat_attack(Object* attacker, Object* defender, int hitMode, int hitLocation);
int _combat_bullet_start(const Object* attacker, const Object* target);
void _compute_explosion_on_extras(Attack* attack, bool isFromAttacker, bool isGrenade, bool noDamage);
void _combat(STRUCT_664980* attack);
void attackInit(Attack* attack, Object* a2, Object* a3, int a4, int a5);
int _combat_attack(Object* a1, Object* a2, int a3, int a4);
int _combat_bullet_start(const Object* a1, const Object* a2);
void _compute_explosion_on_extras(Attack* attack, int a2, bool isGrenade, int a4);
int _determine_to_hit(Object* a1, Object* a2, int hitLocation, int hitMode);
int _determine_to_hit_no_range(Object* attacker, Object* defender, int hitLocation, int hitMode, unsigned char* a5);
int _determine_to_hit_from_tile(Object* attacker, int tile, Object* defender, int hitLocation, int hitMode);
int _determine_to_hit_no_range(Object* a1, Object* a2, int a3, int a4, unsigned char* a5);
int _determine_to_hit_from_tile(Object* a1, int a2, Object* a3, int a4, int a5);
void attackComputeDeathFlags(Attack* attack);
void _apply_damage(Attack* attack, bool animated);
void _combat_display(Attack* attack);
@@ -48,11 +48,11 @@ void _combat_anim_begin();
void _combat_anim_finished();
int _combat_check_bad_shot(Object* attacker, Object* defender, int hitMode, bool aiming);
bool _combat_to_hit(Object* target, int* accuracy);
void _combat_attack_this(Object* target);
void _combat_attack_this(Object* a1);
void _combat_outline_on();
void _combat_outline_off();
void _combat_highlight_change();
bool _combat_is_shot_blocked(Object* sourceObj, int from, int to, Object* targetObj, int* numCrittersOnLof);
bool _combat_is_shot_blocked(Object* a1, int from, int to, Object* a4, int* a5);
int _combat_player_knocked_out_by();
int _combat_explode_scenery(Object* a1, Object* a2);
void _combat_delete_critter(Object* obj);
@@ -74,7 +74,6 @@ bool damageModGetDisplayBonusDamage();
int combat_get_hit_location_penalty(int hit_location);
void combat_set_hit_location_penalty(int hit_location, int penalty);
void combat_reset_hit_location_penalty();
Attack* combat_get_data();
static inline bool isInCombat()
{
+301 -326
View File
File diff suppressed because it is too large Load Diff
-2
View File
@@ -30,8 +30,6 @@ void aiReset();
int aiExit();
int aiLoad(File* stream);
int aiSave(File* stream);
int combat_ai_num();
char* combat_ai_name(int packet_num);
int aiGetAreaAttackMode(Object* obj);
int aiGetRunAwayMode(Object* obj);
int aiGetBestWeapon(Object* obj);
+5 -5
View File
@@ -86,7 +86,7 @@ typedef enum HitLocation {
HIT_LOCATION_SPECIFIC_COUNT = HIT_LOCATION_COUNT - 1,
} HitLocation;
typedef struct CombatStartData {
typedef struct STRUCT_664980 {
Object* attacker;
Object* defender;
int actionPointsBonus;
@@ -94,10 +94,10 @@ typedef struct CombatStartData {
int damageBonus;
int minDamage;
int maxDamage;
int overrideAttackResults;
int attackerResults;
int targetResults;
} CombatStartData;
int field_1C; // probably bool, indicating field_20 and field_24 used
int field_20; // flags on attacker
int field_24; // flags on defender
} STRUCT_664980;
typedef struct Attack {
Object* attacker;
+32 -32
View File
@@ -31,11 +31,11 @@ static char gConfigLastSectionKey[CONFIG_FILE_MAX_LINE_LENGTH] = "unknown";
// 0x42BD90
bool configInit(Config* config)
{
if (config == nullptr) {
if (config == NULL) {
return false;
}
if (dictionaryInit(config, CONFIG_INITIAL_CAPACITY, sizeof(ConfigSection), nullptr) != 0) {
if (dictionaryInit(config, CONFIG_INITIAL_CAPACITY, sizeof(ConfigSection), NULL) != 0) {
return false;
}
@@ -45,7 +45,7 @@ bool configInit(Config* config)
// 0x42BDBC
void configFree(Config* config)
{
if (config == nullptr) {
if (config == NULL) {
return;
}
@@ -58,7 +58,7 @@ void configFree(Config* config)
char** value = (char**)keyValueEntry->value;
internal_free(*value);
*value = nullptr;
*value = NULL;
}
dictionaryFree(section);
@@ -78,7 +78,7 @@ void configFree(Config* config)
// 0x42BE38
bool configParseCommandLineArguments(Config* config, int argc, char** argv)
{
if (config == nullptr) {
if (config == NULL) {
return false;
}
@@ -88,7 +88,7 @@ bool configParseCommandLineArguments(Config* config, int argc, char** argv)
// Find opening bracket.
pch = strchr(string, '[');
if (pch == nullptr) {
if (pch == NULL) {
continue;
}
@@ -96,7 +96,7 @@ bool configParseCommandLineArguments(Config* config, int argc, char** argv)
// Find closing bracket.
pch = strchr(sectionKey, ']');
if (pch == nullptr) {
if (pch == NULL) {
continue;
}
@@ -120,7 +120,7 @@ bool configParseCommandLineArguments(Config* config, int argc, char** argv)
// 0x42BF48
bool configGetString(Config* config, const char* sectionKey, const char* key, char** valuePtr)
{
if (config == nullptr || sectionKey == nullptr || key == nullptr || valuePtr == nullptr) {
if (config == NULL || sectionKey == NULL || key == NULL || valuePtr == NULL) {
return false;
}
@@ -146,7 +146,7 @@ bool configGetString(Config* config, const char* sectionKey, const char* key, ch
// 0x42BF90
bool configSetString(Config* config, const char* sectionKey, const char* key, const char* value)
{
if (config == nullptr || sectionKey == nullptr || key == nullptr || value == nullptr) {
if (config == NULL || sectionKey == NULL || key == NULL || value == NULL) {
return false;
}
@@ -167,13 +167,13 @@ bool configSetString(Config* config, const char* sectionKey, const char* key, co
char** existingValue = (char**)keyValueEntry->value;
internal_free(*existingValue);
*existingValue = nullptr;
*existingValue = NULL;
dictionaryRemoveValue(section, key);
}
char* valueCopy = internal_strdup(value);
if (valueCopy == nullptr) {
if (valueCopy == NULL) {
return false;
}
@@ -188,7 +188,7 @@ bool configSetString(Config* config, const char* sectionKey, const char* key, co
// 0x42C05C
bool configGetInt(Config* config, const char* sectionKey, const char* key, int* valuePtr, unsigned char base /* = 0 */)
{
if (valuePtr == nullptr) {
if (valuePtr == NULL) {
return false;
}
@@ -220,7 +220,7 @@ bool configGetInt(Config* config, const char* sectionKey, const char* key, int*
// 0x42C090
bool configGetIntList(Config* config, const char* sectionKey, const char* key, int* arr, int count)
{
if (arr == nullptr || count < 2) {
if (arr == NULL || count < 2) {
return false;
}
@@ -234,7 +234,7 @@ bool configGetIntList(Config* config, const char* sectionKey, const char* key, i
while (1) {
char* pch = strchr(string, ',');
if (pch == nullptr) {
if (pch == NULL) {
break;
}
@@ -272,7 +272,7 @@ bool configSetInt(Config* config, const char* sectionKey, const char* key, int v
// 0x42C280
bool configRead(Config* config, const char* filePath, bool isDb)
{
if (config == nullptr || filePath == nullptr) {
if (config == NULL || filePath == NULL) {
return false;
}
@@ -282,11 +282,11 @@ bool configRead(Config* config, const char* filePath, bool isDb)
File* stream = fileOpen(filePath, "rb");
// CE: Return `false` if file does not exists in database.
if (stream == nullptr) {
if (stream == NULL) {
return false;
}
while (fileReadString(string, sizeof(string), stream) != nullptr) {
while (fileReadString(string, sizeof(string), stream) != NULL) {
configParseLine(config, string);
}
fileClose(stream);
@@ -294,11 +294,11 @@ bool configRead(Config* config, const char* filePath, bool isDb)
FILE* stream = compat_fopen(filePath, "rt");
// CE: Return `false` if file does not exists on the file system.
if (stream == nullptr) {
if (stream == NULL) {
return false;
}
while (compat_fgets(string, sizeof(string), stream) != nullptr) {
while (compat_fgets(string, sizeof(string), stream) != NULL) {
configParseLine(config, string);
}
fclose(stream);
@@ -312,13 +312,13 @@ bool configRead(Config* config, const char* filePath, bool isDb)
// 0x42C324
bool configWrite(Config* config, const char* filePath, bool isDb)
{
if (config == nullptr || filePath == nullptr) {
if (config == NULL || filePath == NULL) {
return false;
}
if (isDb) {
File* stream = fileOpen(filePath, "wt");
if (stream == nullptr) {
if (stream == NULL) {
return false;
}
@@ -338,7 +338,7 @@ bool configWrite(Config* config, const char* filePath, bool isDb)
fileClose(stream);
} else {
FILE* stream = compat_fopen(filePath, "wt");
if (stream == nullptr) {
if (stream == NULL) {
return false;
}
@@ -381,7 +381,7 @@ static bool configParseLine(Config* config, char* string)
// Find comment marker and truncate the string.
pch = strchr(string, ';');
if (pch != nullptr) {
if (pch != NULL) {
*pch = '\0';
}
@@ -407,7 +407,7 @@ static bool configParseLine(Config* config, char* string)
// Find closing bracket.
pch = strchr(sectionKey, ']');
if (pch != nullptr) {
if (pch != NULL) {
*pch = '\0';
strcpy(gConfigLastSectionKey, sectionKey);
return configTrimString(gConfigLastSectionKey);
@@ -431,13 +431,13 @@ static bool configParseLine(Config* config, char* string)
// 0x42C594
static bool configParseKeyValue(char* string, char* key, char* value)
{
if (string == nullptr || key == nullptr || value == nullptr) {
if (string == NULL || key == NULL || value == NULL) {
return false;
}
// Find equals character.
char* pch = strchr(string, '=');
if (pch == nullptr) {
if (pch == NULL) {
return false;
}
@@ -462,7 +462,7 @@ static bool configParseKeyValue(char* string, char* key, char* value)
// 0x42C638
static bool configEnsureSectionExists(Config* config, const char* sectionKey)
{
if (config == nullptr || sectionKey == nullptr) {
if (config == NULL || sectionKey == NULL) {
return false;
}
@@ -472,7 +472,7 @@ static bool configEnsureSectionExists(Config* config, const char* sectionKey)
}
ConfigSection section;
if (dictionaryInit(&section, CONFIG_INITIAL_CAPACITY, sizeof(char**), nullptr) == -1) {
if (dictionaryInit(&section, CONFIG_INITIAL_CAPACITY, sizeof(char**), NULL) == -1) {
return false;
}
@@ -488,7 +488,7 @@ static bool configEnsureSectionExists(Config* config, const char* sectionKey)
// 0x42C698
static bool configTrimString(char* string)
{
if (string == nullptr) {
if (string == NULL) {
return false;
}
@@ -525,7 +525,7 @@ static bool configTrimString(char* string)
// 0x42C718
bool configGetDouble(Config* config, const char* sectionKey, const char* key, double* valuePtr)
{
if (valuePtr == nullptr) {
if (valuePtr == NULL) {
return false;
}
@@ -534,7 +534,7 @@ bool configGetDouble(Config* config, const char* sectionKey, const char* key, do
return false;
}
*valuePtr = strtod(stringValue, nullptr);
*valuePtr = strtod(stringValue, NULL);
return true;
}
@@ -551,7 +551,7 @@ bool configSetDouble(Config* config, const char* sectionKey, const char* key, do
// NOTE: Boolean-typed variant of [configGetInt].
bool configGetBool(Config* config, const char* sectionKey, const char* key, bool* valuePtr)
{
if (valuePtr == nullptr) {
if (valuePtr == NULL) {
return false;
}
+8 -7
View File
@@ -9,7 +9,6 @@
#include "cycle.h"
#include "db.h"
#include "debug.h"
#include "delay.h"
#include "draw.h"
#include "game_mouse.h"
#include "input.h"
@@ -68,7 +67,7 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
char localizedPath[COMPAT_MAX_PATH];
if (_message_make_path(localizedPath, sizeof(localizedPath), filePath)) {
gCreditsFile = fileOpen(localizedPath, "rt");
if (gCreditsFile != nullptr) {
if (gCreditsFile != NULL) {
soundContinueAll();
colorCycleDisable();
@@ -85,7 +84,7 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
soundContinueAll();
if (window != -1) {
unsigned char* windowBuffer = windowGetBuffer(window);
if (windowBuffer != nullptr) {
if (windowBuffer != NULL) {
unsigned char* backgroundBuffer = (unsigned char*)internal_malloc(windowWidth * windowHeight);
if (backgroundBuffer) {
soundContinueAll();
@@ -106,7 +105,7 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
}
unsigned char* intermediateBuffer = (unsigned char*)internal_malloc(windowWidth * windowHeight);
if (intermediateBuffer != nullptr) {
if (intermediateBuffer != NULL) {
memset(intermediateBuffer, 0, windowWidth * windowHeight);
fontSetCurrent(gCreditsWindowTitleFont);
@@ -118,7 +117,7 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
int lineHeight = std::max(titleFontLineHeight, nameFontLineHeight);
int stringBufferSize = windowWidth * lineHeight;
unsigned char* stringBuffer = (unsigned char*)internal_malloc(stringBufferSize);
if (stringBuffer != nullptr) {
if (stringBuffer != NULL) {
blitBufferToBuffer(backgroundBuffer,
windowWidth,
windowHeight,
@@ -173,7 +172,8 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
windowBuffer,
windowWidth);
delay_ms(CREDITS_WINDOW_SCROLLING_DELAY - (getTicks() - tick));
while (getTicksSince(tick) < CREDITS_WINDOW_SCROLLING_DELAY) {
}
tick = getTicks();
@@ -215,7 +215,8 @@ void creditsOpen(const char* filePath, int backgroundFid, bool useReversedStyle)
windowBuffer,
windowWidth);
delay_ms(CREDITS_WINDOW_SCROLLING_DELAY - (getTicks() - tick));
while (getTicksSince(tick) < CREDITS_WINDOW_SCROLLING_DELAY) {
}
tick = getTicks();
+34 -70
View File
@@ -135,7 +135,7 @@ static const int gRadiationEffectPenalties[RADIATION_LEVEL_COUNT][RADIATION_EFFE
};
// 0x518438
static Object* _critterClearObj = nullptr;
static Object* _critterClearObj = NULL;
// scrname.msg
//
@@ -238,25 +238,25 @@ char* critterGetName(Object* obj)
return gDudeName;
}
if (obj->scriptIndex == -1) {
if (obj->field_80 == -1) {
if (obj->sid != -1) {
Script* script;
if (scriptGetScript(obj->sid, &script) != -1) {
obj->scriptIndex = script->index;
obj->field_80 = script->field_14;
}
}
}
char* name = nullptr;
if (obj->scriptIndex != -1) {
char* name = NULL;
if (obj->field_80 != -1) {
MessageListItem messageListItem;
messageListItem.num = 101 + obj->scriptIndex;
messageListItem.num = 101 + obj->field_80;
if (messageListGetItem(&gCritterMessageList, &messageListItem)) {
name = messageListItem.text;
}
}
if (name == nullptr || *name == '\0') {
if (name == NULL || *name == '\0') {
name = protoGetName(obj->pid);
}
@@ -347,8 +347,8 @@ int critterAdjustPoison(Object* critter, int amount)
if (newPoison > 0) {
critter->data.critter.poison = newPoison;
_queue_clear_type(EVENT_TYPE_POISON, nullptr);
queueAddEvent(10 * (505 - 5 * newPoison), gDude, nullptr, EVENT_TYPE_POISON);
_queue_clear_type(EVENT_TYPE_POISON, NULL);
queueAddEvent(10 * (505 - 5 * newPoison), gDude, NULL, EVENT_TYPE_POISON);
// You have been poisoned!
messageListItem.num = 3000;
@@ -429,23 +429,23 @@ int critterAdjustRadiation(Object* obj, int amount)
}
if (amount > 0) {
Object* geigerCounter = nullptr;
Object* geigerCounter = NULL;
Object* item1 = critterGetItem1(gDude);
if (item1 != nullptr) {
if (item1 != NULL) {
if (item1->pid == PROTO_ID_GEIGER_COUNTER_I || item1->pid == PROTO_ID_GEIGER_COUNTER_II) {
geigerCounter = item1;
}
}
Object* item2 = critterGetItem2(gDude);
if (item2 != nullptr) {
if (item2 != NULL) {
if (item2->pid == PROTO_ID_GEIGER_COUNTER_I || item2->pid == PROTO_ID_GEIGER_COUNTER_II) {
geigerCounter = item2;
}
}
if (geigerCounter != nullptr) {
if (geigerCounter != NULL) {
if (miscItemIsOn(geigerCounter)) {
if (amount > 5) {
// The geiger counter is clicking wildly.
@@ -517,14 +517,14 @@ int _critter_check_rads(Object* obj)
else
radiationLevel = RADIATION_LEVEL_NONE;
if (statRoll(obj, STAT_ENDURANCE, gRadiationEnduranceModifiers[radiationLevel], nullptr) <= ROLL_FAILURE) {
if (statRoll(obj, STAT_ENDURANCE, gRadiationEnduranceModifiers[radiationLevel], NULL) <= ROLL_FAILURE) {
radiationLevel++;
}
if (radiationLevel > _old_rad_level) {
// Create timer event for applying radiation damage.
RadiationEvent* radiationEvent = (RadiationEvent*)internal_malloc(sizeof(*radiationEvent));
if (radiationEvent == nullptr) {
if (radiationEvent == NULL) {
return 0;
}
@@ -630,7 +630,7 @@ int radiationEventProcess(Object* obj, void* data)
if (!radiationEvent->isHealing) {
// Schedule healing stats event in 7 days.
RadiationEvent* newRadiationEvent = (RadiationEvent*)internal_malloc(sizeof(*newRadiationEvent));
if (newRadiationEvent != nullptr) {
if (newRadiationEvent != NULL) {
_queue_clear_type(EVENT_TYPE_RADIATION, _clear_rad_damage);
newRadiationEvent->radiationLevel = radiationEvent->radiationLevel;
newRadiationEvent->isHealing = 1;
@@ -647,7 +647,7 @@ int radiationEventProcess(Object* obj, void* data)
int radiationEventRead(File* stream, void** dataPtr)
{
RadiationEvent* radiationEvent = (RadiationEvent*)internal_malloc(sizeof(*radiationEvent));
if (radiationEvent == nullptr) {
if (radiationEvent == NULL) {
return -1;
}
@@ -770,7 +770,7 @@ char* killTypeGetName(int killType)
MessageListItem messageListItem;
return getmsg(&gProtoMessageList, &messageListItem, 1450 + killType);
} else {
return nullptr;
return NULL;
}
} else {
return byte_501494;
@@ -785,7 +785,7 @@ char* killTypeGetDescription(int killType)
MessageListItem messageListItem;
return getmsg(&gProtoMessageList, &messageListItem, 1469 + killType);
} else {
return nullptr;
return NULL;
}
} else {
return byte_501494;
@@ -927,7 +927,7 @@ int critterGetExp(Object* critter)
// 0x42DCDC
bool critterIsActive(Object* critter)
{
if (critter == nullptr) {
if (critter == NULL) {
return false;
}
@@ -949,7 +949,7 @@ bool critterIsActive(Object* critter)
// 0x42DD18
bool critterIsDead(Object* critter)
{
if (critter == nullptr) {
if (critter == NULL) {
return false;
}
@@ -971,7 +971,7 @@ bool critterIsDead(Object* critter)
// 0x42DD58
bool critterIsCrippled(Object* critter)
{
if (critter == nullptr) {
if (critter == NULL) {
return false;
}
@@ -985,7 +985,7 @@ bool critterIsCrippled(Object* critter)
// 0x42DD80
bool _critter_is_prone(Object* critter)
{
if (critter == nullptr) {
if (critter == NULL) {
return false;
}
@@ -1004,7 +1004,7 @@ bool _critter_is_prone(Object* critter)
// 0x42DDC4
int critterGetBodyType(Object* critter)
{
if (critter == nullptr) {
if (critter == NULL) {
debugPrint("\nError: critter_body_type: pobj was NULL!");
return 0;
}
@@ -1022,7 +1022,7 @@ int critterGetBodyType(Object* critter)
int gcdLoad(const char* path)
{
File* stream = fileOpen(path, "rb");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -1094,7 +1094,7 @@ int protoCritterDataRead(File* stream, CritterProtoData* critterData)
int gcdSave(const char* path)
{
File* stream = fileOpen(path, "wb");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -1166,7 +1166,7 @@ void dudeEnableState(int state)
proto->critter.data.flags |= (1 << state);
if (state == DUDE_STATE_SNEAKING) {
sneakEventProcess(nullptr, nullptr);
sneakEventProcess(NULL, NULL);
}
indicatorBarRefresh();
@@ -1197,7 +1197,7 @@ int sneakEventProcess(Object* obj, void* data)
int time;
int sneak = skillGetValue(gDude, SKILL_SNEAK);
if (skillRoll(gDude, SKILL_SNEAK, 0, nullptr) < ROLL_SUCCESS) {
if (skillRoll(gDude, SKILL_SNEAK, 0, NULL) < ROLL_SUCCESS) {
time = 600;
_sneak_working = false;
@@ -1218,7 +1218,7 @@ int sneakEventProcess(Object* obj, void* data)
_sneak_working = true;
}
queueAddEvent(time, gDude, nullptr, EVENT_TYPE_SNEAK);
queueAddEvent(time, gDude, NULL, EVENT_TYPE_SNEAK);
return 0;
}
@@ -1276,7 +1276,7 @@ int _critter_wake_clear(Object* obj, void* data)
obj->data.critter.combat.results &= ~(DAM_KNOCKED_OUT | DAM_KNOCKED_DOWN);
int fid = buildFid(FID_TYPE(obj->fid), obj->fid & 0xFFF, ANIM_STAND, (obj->fid & 0xF000) >> 12, obj->rotation + 1);
objectSetFid(obj, fid, nullptr);
objectSetFid(obj, fid, 0);
return 0;
}
@@ -1284,16 +1284,16 @@ int _critter_wake_clear(Object* obj, void* data)
// 0x42E4C0
int _critter_set_who_hit_me(Object* a1, Object* a2)
{
if (a1 == nullptr) {
if (a1 == NULL) {
return -1;
}
if (a2 != nullptr && FID_TYPE(a2->fid) != OBJ_TYPE_CRITTER) {
if (a2 != NULL && FID_TYPE(a2->fid) != OBJ_TYPE_CRITTER) {
return -1;
}
if (PID_TYPE(a1->pid) == OBJ_TYPE_CRITTER) {
if (a2 == nullptr || a1->data.critter.combat.team != a2->data.critter.combat.team || (statRoll(a1, STAT_INTELLIGENCE, -1, nullptr) < 2 && (!objectIsPartyMember(a1) || !objectIsPartyMember(a2)))) {
if (a2 == NULL || a1->data.critter.combat.team != a2->data.critter.combat.team || (statRoll(a1, STAT_INTELLIGENCE, -1, NULL) < 2 && (!objectIsPartyMember(a1) || !objectIsPartyMember(a2)))) {
a1->data.critter.combat.whoHitMe = a2;
if (a2 == gDude) {
reactionSetValue(a1, -3);
@@ -1373,7 +1373,7 @@ bool critterIsEncumbered(Object* critter)
// 0x42E690
bool critterIsFleeing(Object* critter)
{
return critter != nullptr
return critter != NULL
? (critter->data.critter.combat.maneuver & CRITTER_MANUEVER_FLEEING) != 0
: false;
}
@@ -1396,40 +1396,4 @@ bool _critter_flag_check(int pid, int flag)
return (proto->critter.data.flags & flag) != 0;
}
// 0x42E6F0
void critter_flag_set(int pid, int flag)
{
Proto* proto;
if (pid == -1) {
return;
}
if (PID_TYPE(pid) != OBJ_TYPE_CRITTER) {
return;
}
protoGetProto(pid, &proto);
proto->critter.data.flags |= flag;
}
// 0x42E71C
void critter_flag_unset(int pid, int flag)
{
Proto* proto;
if (pid == -1) {
return;
}
if (PID_TYPE(pid) != OBJ_TYPE_CRITTER) {
return;
}
protoGetProto(pid, &proto);
proto->critter.data.flags &= ~flag;
}
} // namespace fallout
-2
View File
@@ -70,8 +70,6 @@ int critterGetMovementPointCostAdjustedForCrippledLegs(Object* critter, int a2);
bool critterIsEncumbered(Object* critter);
bool critterIsFleeing(Object* a1);
bool _critter_flag_check(int pid, int flag);
void critter_flag_set(int pid, int flag);
void critter_flag_unset(int pid, int flag);
} // namespace fallout
+11 -11
View File
@@ -11,7 +11,7 @@
namespace fallout {
// 0x5184AC
DatafileLoader* gDatafileLoader = nullptr;
DatafileLoader* gDatafileLoader = NULL;
// 0x5184B0
DatafileNameMangler* gDatafileNameMangler = datafileDefaultNameManglerImpl;
@@ -90,24 +90,24 @@ unsigned char* datafileReadRaw(char* path, int* widthPtr, int* heightPtr)
{
char* mangledPath = gDatafileNameMangler(path);
char* dot = strrchr(mangledPath, '.');
if (dot != nullptr) {
if (dot != NULL) {
if (compat_stricmp(dot + 1, "pcx") == 0) {
return pcxRead(mangledPath, widthPtr, heightPtr, gDatafilePalette);
}
}
if (gDatafileLoader != nullptr) {
if (gDatafileLoader != NULL) {
return gDatafileLoader(mangledPath, gDatafilePalette, widthPtr, heightPtr);
}
return nullptr;
return NULL;
}
// 0x42EFCC
unsigned char* datafileRead(char* path, int* widthPtr, int* heightPtr)
{
unsigned char* v1 = datafileReadRaw(path, widthPtr, heightPtr);
if (v1 != nullptr) {
if (v1 != NULL) {
sub_42EE84(v1, gDatafilePalette, *widthPtr, *heightPtr);
}
return v1;
@@ -121,12 +121,12 @@ unsigned char* sub_42EFF4(char* path)
int width;
int height;
unsigned char* v3 = datafileReadRaw(path, &width, &height);
if (v3 != nullptr) {
if (v3 != NULL) {
internal_free_safe(v3, __FILE__, __LINE__); // "..\\int\\DATAFILE.C", 148
return gDatafilePalette;
}
return nullptr;
return NULL;
}
// NOTE: Unused.
@@ -177,17 +177,17 @@ unsigned char* datafileLoad(char* path, int* sizePtr)
{
const char* mangledPath = gDatafileNameMangler(path);
File* stream = fileOpen(mangledPath, "rb");
if (stream == nullptr) {
return nullptr;
if (stream == NULL) {
return NULL;
}
int size = fileGetSize(stream);
unsigned char* data = (unsigned char*)internal_malloc_safe(size, __FILE__, __LINE__); // "..\\int\\DATAFILE.C", 185
if (data == nullptr) {
if (data == NULL) {
// NOTE: This code is unreachable, internal_malloc_safe never fails.
// Otherwise it leaks stream.
*sizePtr = 0;
return nullptr;
return NULL;
}
fileRead(data, 1, size, stream);
+21 -21
View File
@@ -19,7 +19,7 @@ static int _db_list_compare(const void* p1, const void* p2);
// Generic file progress report handler.
//
// 0x51DEEC
static FileReadProgressHandler* gFileReadProgressHandler = nullptr;
static FileReadProgressHandler* gFileReadProgressHandler = NULL;
// Bytes read so far while tracking progress.
//
@@ -50,13 +50,13 @@ static FileList* gFileListHead;
// 0x4C5D30
int dbOpen(const char* filePath1, int a2, const char* filePath2, int a4)
{
if (filePath1 != nullptr) {
if (filePath1 != NULL) {
if (!xbaseOpen(filePath1)) {
return -1;
}
}
if (filePath2 != nullptr) {
if (filePath2 != NULL) {
xbaseOpen(filePath2);
}
@@ -64,15 +64,15 @@ int dbOpen(const char* filePath1, int a2, const char* filePath2, int a4)
}
// 0x4C5D58
int db_total()
int _db_total()
{
return 1;
return 0;
}
// 0x4C5D60
void dbExit()
{
xbaseReopenAll(nullptr);
xbaseReopenAll(NULL);
}
// TODO: sizePtr should be long*.
@@ -84,7 +84,7 @@ int dbGetFileSize(const char* filePath, int* sizePtr)
assert(sizePtr); // "de", "db.c", 109
File* stream = xfileOpen(filePath, "rb");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -102,12 +102,12 @@ int dbGetFileContents(const char* filePath, void* ptr)
assert(ptr); // "buf", "db.c", 142
File* stream = xfileOpen(filePath, "rb");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
long size = xfileGetSize(stream);
if (gFileReadProgressHandler != nullptr) {
if (gFileReadProgressHandler != NULL) {
unsigned char* byteBuffer = (unsigned char*)ptr;
long remainingSize = size;
@@ -166,7 +166,7 @@ int filePrintFormatted(File* stream, const char* format, ...)
// 0x4C5F24
int fileReadChar(File* stream)
{
if (gFileReadProgressHandler != nullptr) {
if (gFileReadProgressHandler != NULL) {
int ch = xfileReadChar(stream);
gFileReadProgressBytesRead++;
@@ -184,9 +184,9 @@ int fileReadChar(File* stream)
// 0x4C5F70
char* fileReadString(char* string, size_t size, File* stream)
{
if (gFileReadProgressHandler != nullptr) {
if (xfileReadString(string, size, stream) == nullptr) {
return nullptr;
if (gFileReadProgressHandler != NULL) {
if (xfileReadString(string, size, stream) == NULL) {
return NULL;
}
gFileReadProgressBytesRead += strlen(string);
@@ -210,7 +210,7 @@ int fileWriteString(const char* string, File* stream)
// 0x4C5FFC
size_t fileRead(void* ptr, size_t size, size_t count, File* stream)
{
if (gFileReadProgressHandler != nullptr) {
if (gFileReadProgressHandler != NULL) {
unsigned char* byteBuffer = (unsigned char*)ptr;
size_t totalBytesRead = 0;
@@ -602,7 +602,7 @@ int fileWriteUInt32List(File* stream, unsigned int* arr, int count)
int fileNameListInit(const char* pattern, char*** fileNameListPtr, int a3, int a4)
{
FileList* fileList = (FileList*)malloc(sizeof(*fileList));
if (fileList == nullptr) {
if (fileList == NULL) {
return 0;
}
@@ -638,9 +638,9 @@ int fileNameListInit(const char* pattern, char*** fileNameListPtr, int a3, int a
char fileName[COMPAT_MAX_FNAME];
char extension[COMPAT_MAX_EXT];
compat_windows_path_to_native(name);
compat_splitpath(name, nullptr, dir, fileName, extension);
compat_splitpath(name, NULL, dir, fileName, extension);
if (!isWildcard || *dir == '\0' || (strchr(dir, '\\') == nullptr && strchr(dir, '/') == nullptr)) {
if (!isWildcard || *dir == '\0' || (strchr(dir, '\\') == NULL && strchr(dir, '/') == NULL)) {
// NOTE: Quick and dirty fix to buffer overflow. See RE to
// understand the problem.
char path[COMPAT_MAX_PATH];
@@ -663,7 +663,7 @@ int fileNameListInit(const char* pattern, char*** fileNameListPtr, int a3, int a
// 0x4C6868
void fileNameListFree(char*** fileNameListPtr, int a2)
{
if (gFileListHead == nullptr) {
if (gFileListHead == NULL) {
return;
}
@@ -672,7 +672,7 @@ void fileNameListFree(char*** fileNameListPtr, int a2)
while (*fileNameListPtr != currentFileList->xlist.fileNames) {
previousFileList = currentFileList;
currentFileList = currentFileList->next;
if (currentFileList == nullptr) {
if (currentFileList == NULL) {
return;
}
}
@@ -699,11 +699,11 @@ int fileGetSize(File* stream)
// 0x4C68C4
void fileSetReadProgressHandler(FileReadProgressHandler* handler, int size)
{
if (handler != nullptr && size != 0) {
if (handler != NULL && size != 0) {
gFileReadProgressHandler = handler;
gFileReadProgressChunkSize = size;
} else {
gFileReadProgressHandler = nullptr;
gFileReadProgressHandler = NULL;
gFileReadProgressChunkSize = 0;
}
}
+1 -1
View File
@@ -12,7 +12,7 @@ typedef void FileReadProgressHandler();
typedef char* StrdupProc(const char* string);
int dbOpen(const char* filePath1, int a2, const char* filePath2, int a4);
int db_total();
int _db_total();
void dbExit();
int dbGetFileSize(const char* filePath, int* sizePtr);
int dbGetFileContents(const char* filePath, void* ptr);
+29 -27
View File
@@ -9,7 +9,6 @@
#include "character_editor.h"
#include "color.h"
#include "debug.h"
#include "delay.h"
#include "draw.h"
#include "game.h"
#include "game_sound.h"
@@ -157,12 +156,12 @@ int showDialogBox(const char* title, const char** body, int bodyLength, int x, i
bool v86 = false;
bool hasTwoButtons = false;
if (a8 != nullptr) {
if (a8 != NULL) {
hasTwoButtons = true;
}
bool hasTitle = false;
if (title != nullptr) {
if (title != NULL) {
hasTitle = true;
}
@@ -298,7 +297,7 @@ int showDialogBox(const char* title, const char** body, int bodyLength, int x, i
500,
buttonNormalFrmImage.getData(),
buttonPressedFrmImage.getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (btn != -1) {
buttonSetCallbacks(btn, _gsound_red_butt_press, _gsound_red_butt_release);
@@ -339,7 +338,7 @@ int showDialogBox(const char* title, const char** body, int bodyLength, int x, i
501,
buttonNormalFrmImage.getData(),
buttonPressedFrmImage.getData(),
nullptr,
0,
BUTTON_FLAG_TRANSPARENT);
if (btn != -1) {
buttonSetCallbacks(btn, _gsound_red_butt_press, _gsound_red_butt_release);
@@ -404,7 +403,7 @@ int showDialogBox(const char* title, const char** body, int bodyLength, int x, i
501,
buttonNormalFrmImage.getData(),
buttonPressedFrmImage.getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (btn != -1) {
buttonSetCallbacks(btn, _gsound_red_butt_press, _gsound_red_butt_release);
@@ -644,7 +643,7 @@ int showLoadFileDialog(char* title, char** fileList, char* dest, int fileListLen
500,
frmImages[FILE_DIALOG_FRM_LITTLE_RED_BUTTON_NORMAL].getData(),
frmImages[FILE_DIALOG_FRM_LITTLE_RED_BUTTON_PRESSED].getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (doneBtn != -1) {
buttonSetCallbacks(doneBtn, _gsound_red_butt_press, _gsound_red_butt_release);
@@ -661,7 +660,7 @@ int showLoadFileDialog(char* title, char** fileList, char* dest, int fileListLen
501,
frmImages[FILE_DIALOG_FRM_LITTLE_RED_BUTTON_NORMAL].getData(),
frmImages[FILE_DIALOG_FRM_LITTLE_RED_BUTTON_PRESSED].getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (cancelBtn != -1) {
buttonSetCallbacks(cancelBtn, _gsound_red_butt_press, _gsound_red_butt_release);
@@ -678,7 +677,7 @@ int showLoadFileDialog(char* title, char** fileList, char* dest, int fileListLen
505,
frmImages[FILE_DIALOG_FRM_SCROLL_UP_ARROW_NORMAL].getData(),
frmImages[FILE_DIALOG_FRM_SCROLL_UP_ARROW_PRESSED].getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (scrollUpBtn != -1) {
buttonSetCallbacks(cancelBtn, _gsound_red_butt_press, _gsound_red_butt_release);
@@ -695,7 +694,7 @@ int showLoadFileDialog(char* title, char** fileList, char* dest, int fileListLen
503,
frmImages[FILE_DIALOG_FRM_SCROLL_DOWN_ARROW_NORMAL].getData(),
frmImages[FILE_DIALOG_FRM_SCROLL_DOWN_ARROW_PRESSED].getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (scrollUpBtn != -1) {
buttonSetCallbacks(cancelBtn, _gsound_red_butt_press, _gsound_red_butt_release);
@@ -711,12 +710,12 @@ int showLoadFileDialog(char* title, char** fileList, char* dest, int fileListLen
-1,
-1,
502,
nullptr,
nullptr,
nullptr,
NULL,
NULL,
NULL,
0);
if (title != nullptr) {
if (title != NULL) {
fontDrawText(windowBuffer + backgroundWidth * FILE_DIALOG_TITLE_Y + FILE_DIALOG_TITLE_X, title, backgroundWidth, backgroundWidth, _colorTable[18979]);
}
@@ -886,8 +885,8 @@ int showLoadFileDialog(char* title, char** fileList, char* dest, int fileListLen
}
unsigned int delay = (scrollCounter > 14.4) ? 1000 / scrollDelay : 1000 / 24;
delay_ms(delay - (getTicks() - scrollTick));
while (getTicksSince(scrollTick) < delay) {
}
if (_game_user_wants_to_quit != 0) {
rc = 1;
@@ -910,7 +909,8 @@ int showLoadFileDialog(char* title, char** fileList, char* dest, int fileListLen
doubleClickSelectedFileIndex = -2;
}
delay_ms(1000 / 24 - (getTicks() - tick));
while (getTicksSince(tick) < (1000 / 24)) {
}
}
if (_game_user_wants_to_quit) {
@@ -1009,7 +1009,7 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen
500,
frmImages[FILE_DIALOG_FRM_LITTLE_RED_BUTTON_NORMAL].getData(),
frmImages[FILE_DIALOG_FRM_LITTLE_RED_BUTTON_PRESSED].getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (doneBtn != -1) {
buttonSetCallbacks(doneBtn, _gsound_red_butt_press, _gsound_red_butt_release);
@@ -1026,7 +1026,7 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen
501,
frmImages[FILE_DIALOG_FRM_LITTLE_RED_BUTTON_NORMAL].getData(),
frmImages[FILE_DIALOG_FRM_LITTLE_RED_BUTTON_PRESSED].getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (cancelBtn != -1) {
buttonSetCallbacks(cancelBtn, _gsound_red_butt_press, _gsound_red_butt_release);
@@ -1043,7 +1043,7 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen
505,
frmImages[FILE_DIALOG_FRM_SCROLL_UP_ARROW_NORMAL].getData(),
frmImages[FILE_DIALOG_FRM_SCROLL_UP_ARROW_PRESSED].getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (scrollUpBtn != -1) {
buttonSetCallbacks(cancelBtn, _gsound_red_butt_press, _gsound_red_butt_release);
@@ -1060,7 +1060,7 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen
503,
frmImages[FILE_DIALOG_FRM_SCROLL_DOWN_ARROW_NORMAL].getData(),
frmImages[FILE_DIALOG_FRM_SCROLL_DOWN_ARROW_PRESSED].getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (scrollUpBtn != -1) {
buttonSetCallbacks(cancelBtn, _gsound_red_butt_press, _gsound_red_butt_release);
@@ -1076,12 +1076,12 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen
-1,
-1,
502,
nullptr,
nullptr,
nullptr,
NULL,
NULL,
NULL,
0);
if (title != nullptr) {
if (title != NULL) {
fontDrawText(windowBuffer + backgroundWidth * FILE_DIALOG_TITLE_Y + FILE_DIALOG_TITLE_X, title, backgroundWidth, backgroundWidth, _colorTable[18979]);
}
@@ -1335,7 +1335,8 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen
// FIXME: Missing windowRefresh makes blinking useless.
unsigned int delay = (scrollCounter > 14.4) ? 1000 / scrollDelay : 1000 / 24;
delay_ms(delay - (getTicks() - scrollTick));
while (getTicksSince(scrollTick) < delay) {
}
if (_game_user_wants_to_quit != 0) {
rc = 1;
@@ -1368,7 +1369,8 @@ int showSaveFileDialog(char* title, char** fileList, char* dest, int fileListLen
doubleClickSelectedFileIndex = -2;
}
delay_ms(1000 / 24 - (getTicks() - tick));
while (getTicksSince(tick) < (1000 / 24)) {
}
}
if (_game_user_wants_to_quit != 0) {
+27 -21
View File
@@ -22,7 +22,7 @@ static void _debug_putc(int ch);
static void _debug_scroll();
// 0x51DEF8
static FILE* _fd = nullptr;
static FILE* _fd = NULL;
// 0x51DEFC
static int _curx = 0;
@@ -31,7 +31,7 @@ static int _curx = 0;
static int _cury = 0;
// 0x51DF04
static DebugPrintProc* gDebugPrintProc = nullptr;
static DebugPrintProc* gDebugPrintProc = NULL;
// 0x4C6CD0
void _GNW_debug_init()
@@ -43,9 +43,9 @@ void _GNW_debug_init()
void _debug_register_mono()
{
if (gDebugPrintProc != _debug_mono) {
if (_fd != nullptr) {
if (_fd != NULL) {
fclose(_fd);
_fd = nullptr;
_fd = NULL;
}
gDebugPrintProc = _debug_mono;
@@ -56,8 +56,8 @@ void _debug_register_mono()
// 0x4C6D18
void _debug_register_log(const char* fileName, const char* mode)
{
if ((mode[0] == 'w' || mode[0] == 'a') && mode[1] == 't') {
if (_fd != nullptr) {
if ((mode[0] == 'w' && mode[1] == 'a') && mode[1] == 't') {
if (_fd != NULL) {
fclose(_fd);
}
@@ -70,9 +70,9 @@ void _debug_register_log(const char* fileName, const char* mode)
void _debug_register_screen()
{
if (gDebugPrintProc != _debug_screen) {
if (_fd != nullptr) {
if (_fd != NULL) {
fclose(_fd);
_fd = nullptr;
_fd = NULL;
}
gDebugPrintProc = _debug_screen;
@@ -83,12 +83,12 @@ void _debug_register_screen()
void _debug_register_env()
{
const char* type = getenv("DEBUGACTIVE");
if (type == nullptr) {
if (type == NULL) {
return;
}
char* copy = (char*)internal_malloc(strlen(type) + 1);
if (copy == nullptr) {
if (copy == NULL) {
return;
}
@@ -104,8 +104,14 @@ void _debug_register_env()
// NOTE: Uninline.
_debug_register_screen();
} else if (strcmp(copy, "gnw") == 0) {
// NOTE: Uninline.
_debug_register_func(_win_debug);
if (gDebugPrintProc != _win_debug) {
if (_fd != NULL) {
fclose(_fd);
_fd = NULL;
}
gDebugPrintProc = _win_debug;
}
}
internal_free(copy);
@@ -115,9 +121,9 @@ void _debug_register_env()
void _debug_register_func(DebugPrintProc* proc)
{
if (gDebugPrintProc != proc) {
if (_fd != nullptr) {
if (_fd != NULL) {
fclose(_fd);
_fd = nullptr;
_fd = NULL;
}
gDebugPrintProc = proc;
@@ -132,13 +138,13 @@ int debugPrint(const char* format, ...)
int rc;
if (gDebugPrintProc != nullptr) {
if (gDebugPrintProc != NULL) {
char string[260];
vsnprintf(string, sizeof(string), format, args);
rc = gDebugPrintProc(string);
} else {
#ifndef NDEBUG
#ifdef _DEBUG
SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, format, args);
#endif
rc = -1;
@@ -152,7 +158,7 @@ int debugPrint(const char* format, ...)
// 0x4C6F94
static int _debug_puts(char* string)
{
if (gDebugPrintProc != nullptr) {
if (gDebugPrintProc != NULL) {
return gDebugPrintProc(string);
}
@@ -166,7 +172,7 @@ static void _debug_clear()
int x;
int y;
buffer = nullptr;
buffer = NULL;
if (gDebugPrintProc == _debug_mono) {
buffer = (char*)0xB0000;
@@ -174,7 +180,7 @@ static void _debug_clear()
buffer = (char*)0xB8000;
}
if (buffer != nullptr) {
if (buffer != NULL) {
for (y = 0; y < 25; y++) {
for (x = 0; x < 80; x++) {
*buffer++ = ' ';
@@ -202,7 +208,7 @@ static int _debug_mono(char* string)
static int _debug_log(char* string)
{
if (gDebugPrintProc == _debug_log) {
if (_fd == nullptr) {
if (_fd == NULL) {
return -1;
}
@@ -300,7 +306,7 @@ static void _debug_scroll()
// 0x4C71E8
void _debug_exit(void)
{
if (_fd != nullptr) {
if (_fd != NULL) {
fclose(_fd);
}
}
-11
View File
@@ -1,11 +0,0 @@
#include "delay.h"
#include <SDL.h>
void delay_ms(int ms)
{
if (ms <= 0) {
return;
}
SDL_Delay(ms);
}
-6
View File
@@ -1,6 +0,0 @@
#ifndef DELAY_H
#define DELAY_H
void delay_ms(int ms);
#endif
+66 -41
View File
@@ -7,7 +7,7 @@
#include <algorithm>
#include <fpattern/fpattern.h>
#include <fpattern.h>
#include "platform_compat.h"
@@ -43,6 +43,8 @@ static int dfileReadCharInternal(DFile* stream);
static bool dfileReadCompressed(DFile* stream, void* ptr, size_t size);
static void dfileUngetCompressed(DFile* stream, int ch);
static void dfile_normalize_path(char* path);
// Reads .DAT file contents.
//
// 0x4E4F58
@@ -51,14 +53,14 @@ DBase* dbaseOpen(const char* filePath)
assert(filePath); // "filename", "dfile.c", 74
FILE* stream = compat_fopen(filePath, "rb");
if (stream == nullptr) {
return nullptr;
if (stream == NULL) {
return NULL;
}
DBase* dbase = (DBase*)malloc(sizeof(*dbase));
if (dbase == nullptr) {
if (dbase == NULL) {
fclose(stream);
return nullptr;
return NULL;
}
memset(dbase, 0, sizeof(*dbase));
@@ -95,7 +97,7 @@ DBase* dbaseOpen(const char* filePath)
}
dbase->entries = (DBaseEntry*)malloc(sizeof(*dbase->entries) * dbase->entriesLength);
if (dbase->entries == nullptr) {
if (dbase->entries == NULL) {
goto err;
}
@@ -112,7 +114,7 @@ DBase* dbaseOpen(const char* filePath)
}
entry->path = (char*)malloc(pathLength + 1);
if (entry->path == nullptr) {
if (entry->path == NULL) {
break;
}
@@ -122,6 +124,9 @@ DBase* dbaseOpen(const char* filePath)
entry->path[pathLength] = '\0';
// CE: Normalize entry path.
dfile_normalize_path(entry->path);
if (fread(&(entry->compressed), sizeof(entry->compressed), 1, stream) != 1) {
break;
}
@@ -158,7 +163,7 @@ err:
fclose(stream);
return nullptr;
return NULL;
}
// Closes [dbase], all open file handles, frees all associated resources,
@@ -170,24 +175,24 @@ bool dbaseClose(DBase* dbase)
assert(dbase); // "dbase", "dfile.c", 173
DFile* curr = dbase->dfileHead;
while (curr != nullptr) {
while (curr != NULL) {
DFile* next = curr->next;
dfileClose(curr);
curr = next;
}
if (dbase->entries != nullptr) {
if (dbase->entries != NULL) {
for (int index = 0; index < dbase->entriesLength; index++) {
DBaseEntry* entry = &(dbase->entries[index]);
char* entryName = entry->path;
if (entryName != nullptr) {
if (entryName != NULL) {
free(entryName);
}
}
free(dbase->entries);
}
if (dbase->path != nullptr) {
if (dbase->path != NULL) {
free(dbase->path);
}
@@ -201,11 +206,18 @@ bool dbaseClose(DBase* dbase)
// 0x4E5308
bool dbaseFindFirstEntry(DBase* dbase, DFileFindData* findFileData, const char* pattern)
{
// CE: Normalize pattern to match entries. Underlying `fpattern`
// implementation is case-sensitive on non-Windows platforms, so both
// pattern and entries should match in case and have native path separators.
char normalizedPattern[COMPAT_MAX_PATH];
strcpy(normalizedPattern, pattern);
dfile_normalize_path(normalizedPattern);
for (int index = 0; index < dbase->entriesLength; index++) {
DBaseEntry* entry = &(dbase->entries[index]);
if (fpattern_match(pattern, entry->path)) {
if (fpattern_match(normalizedPattern, entry->path)) {
strcpy(findFileData->fileName, entry->path);
strcpy(findFileData->pattern, pattern);
strcpy(findFileData->pattern, normalizedPattern);
findFileData->index = index;
return true;
}
@@ -258,15 +270,15 @@ int dfileClose(DFile* stream)
}
}
if (stream->decompressionStream != nullptr) {
if (stream->decompressionStream != NULL) {
free(stream->decompressionStream);
}
if (stream->decompressionBuffer != nullptr) {
if (stream->decompressionBuffer != NULL) {
free(stream->decompressionBuffer);
}
if (stream->stream != nullptr) {
if (stream->stream != NULL) {
fclose(stream->stream);
}
@@ -275,8 +287,8 @@ int dfileClose(DFile* stream)
//
// NOTE: Compiled code is slightly different.
DFile* curr = stream->dbase->dfileHead;
DFile* prev = nullptr;
while (curr != nullptr) {
DFile* prev = NULL;
while (curr != NULL) {
if (curr == stream) {
break;
}
@@ -285,8 +297,8 @@ int dfileClose(DFile* stream)
curr = curr->next;
}
if (curr != nullptr) {
if (prev == nullptr) {
if (curr != NULL) {
if (prev == NULL) {
stream->dbase->dfileHead = stream->next;
} else {
prev->next = stream->next;
@@ -309,7 +321,7 @@ DFile* dfileOpen(DBase* dbase, const char* filePath, const char* mode)
assert(filePath); // dfile.c, 296
assert(mode); // dfile.c, 297
return dfileOpenInternal(dbase, filePath, mode, nullptr);
return dfileOpenInternal(dbase, filePath, mode, 0);
}
// [vfprintf].
@@ -363,7 +375,7 @@ char* dfileReadString(char* string, int size, DFile* stream)
assert(stream); // "stream", "dfile.c", 409
if ((stream->flags & DFILE_EOF) != 0 || (stream->flags & DFILE_ERROR) != 0) {
return nullptr;
return NULL;
}
char* pch = string;
@@ -391,7 +403,7 @@ char* dfileReadString(char* string, int size, DFile* stream)
if (pch == string) {
// No character was set into the buffer.
return nullptr;
return NULL;
}
*pch = '\0';
@@ -632,8 +644,15 @@ static int dbaseFindEntryByFilePath(const void* a1, const void* a2)
// 0x4E5D9C
static DFile* dfileOpenInternal(DBase* dbase, const char* filePath, const char* mode, DFile* dfile)
{
DBaseEntry* entry = (DBaseEntry*)bsearch(filePath, dbase->entries, dbase->entriesLength, sizeof(*dbase->entries), dbaseFindEntryByFilePath);
if (entry == nullptr) {
// CE: Normalize path to match entries. Even though
// `dbaseFindEntryByFilePath` uses case-insensitive compare, it still needs
// native path separators.
char normalizedFilePath[COMPAT_MAX_PATH];
strcpy(normalizedFilePath, filePath);
dfile_normalize_path(normalizedFilePath);
DBaseEntry* entry = (DBaseEntry*)bsearch(normalizedFilePath, dbase->entries, dbase->entriesLength, sizeof(*dbase->entries), dbaseFindEntryByFilePath);
if (entry == NULL) {
goto err;
}
@@ -641,10 +660,10 @@ static DFile* dfileOpenInternal(DBase* dbase, const char* filePath, const char*
goto err;
}
if (dfile == nullptr) {
if (dfile == NULL) {
dfile = (DFile*)malloc(sizeof(*dfile));
if (dfile == nullptr) {
return nullptr;
if (dfile == NULL) {
return NULL;
}
memset(dfile, 0, sizeof(*dfile));
@@ -656,9 +675,9 @@ static DFile* dfileOpenInternal(DBase* dbase, const char* filePath, const char*
goto err;
}
if (dfile->stream != nullptr) {
if (dfile->stream != NULL) {
fclose(dfile->stream);
dfile->stream = nullptr;
dfile->stream = NULL;
}
dfile->compressedBytesRead = 0;
@@ -670,7 +689,7 @@ static DFile* dfileOpenInternal(DBase* dbase, const char* filePath, const char*
// Open stream to .DAT file.
dfile->stream = compat_fopen(dbase->path, "rb");
if (dfile->stream == nullptr) {
if (dfile->stream == NULL) {
goto err;
}
@@ -684,14 +703,14 @@ static DFile* dfileOpenInternal(DBase* dbase, const char* filePath, const char*
// buffer. This step is not needed when previous instance of dfile is
// passed via parameter, which might already have stream and
// buffer allocated.
if (dfile->decompressionStream == nullptr) {
if (dfile->decompressionStream == NULL) {
dfile->decompressionStream = (z_streamp)malloc(sizeof(*dfile->decompressionStream));
if (dfile->decompressionStream == nullptr) {
if (dfile->decompressionStream == NULL) {
goto err;
}
dfile->decompressionBuffer = (unsigned char*)malloc(DFILE_DECOMPRESSION_BUFFER_SIZE);
if (dfile->decompressionBuffer == nullptr) {
if (dfile->decompressionBuffer == NULL) {
goto err;
}
}
@@ -709,14 +728,14 @@ static DFile* dfileOpenInternal(DBase* dbase, const char* filePath, const char*
// Entry is not compressed, there is no need to keep decompression
// stream and decompression buffer (in case [dfile] was passed via
// parameter).
if (dfile->decompressionStream != nullptr) {
if (dfile->decompressionStream != NULL) {
free(dfile->decompressionStream);
dfile->decompressionStream = nullptr;
dfile->decompressionStream = NULL;
}
if (dfile->decompressionBuffer != nullptr) {
if (dfile->decompressionBuffer != NULL) {
free(dfile->decompressionBuffer);
dfile->decompressionBuffer = nullptr;
dfile->decompressionBuffer = NULL;
}
}
@@ -728,11 +747,11 @@ static DFile* dfileOpenInternal(DBase* dbase, const char* filePath, const char*
err:
if (dfile != nullptr) {
if (dfile != NULL) {
dfileClose(dfile);
}
return nullptr;
return NULL;
}
// 0x4E5F9C
@@ -854,4 +873,10 @@ static void dfileUngetCompressed(DFile* stream, int ch)
stream->position--;
}
static void dfile_normalize_path(char* path)
{
compat_windows_path_to_native(path);
compat_strlwr(path);
}
} // namespace fallout
+32 -32
View File
@@ -28,10 +28,10 @@ int _topDialogLine = 0;
int _topDialogReply = 0;
// 0x5184E4
DialogFunc1* _replyWinDrawCallback = nullptr;
DialogFunc1* _replyWinDrawCallback = NULL;
// 0x5184E8
DialogFunc2* _optionsWinDrawCallback = nullptr;
DialogFunc2* _optionsWinDrawCallback = NULL;
// 0x5184EC
int gDialogBorderX = 7;
@@ -171,7 +171,7 @@ STRUCT_56DAE0_FIELD_4* _getReply()
STRUCT_56DAE0_FIELD_4_FIELD_C* v1;
v0 = &(_dialog[_tods].field_4[_dialog[_tods].field_C]);
if (v0->field_C == nullptr) {
if (v0->field_C == NULL) {
v0->field_14 = 1;
v1 = (STRUCT_56DAE0_FIELD_4_FIELD_C*)internal_malloc_safe(sizeof(STRUCT_56DAE0_FIELD_4_FIELD_C), __FILE__, __LINE__); // "..\\int\\DIALOG.C", 789
} else {
@@ -195,20 +195,20 @@ void _replyAddOption(const char* a1, const char* a2, int a3)
v17 = v18->field_14 - 1;
v18->field_C[v17].kind = 2;
if (a1 != nullptr) {
if (a1 != NULL) {
v14 = (char*)internal_malloc_safe(strlen(a1) + 1, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 805
strcpy(v14, a1);
v18->field_C[v17].field_0 = v14;
} else {
v18->field_C[v17].field_0 = nullptr;
v18->field_C[v17].field_0 = NULL;
}
if (a2 != nullptr) {
if (a2 != NULL) {
v15 = (char*)internal_malloc_safe(strlen(a2) + 1, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 810
strcpy(v15, a2);
v18->field_C[v17].string = v15;
} else {
v18->field_C[v17].string = nullptr;
v18->field_C[v17].string = NULL;
}
v18->field_C[v17].field_18 = windowGetFont();
@@ -228,12 +228,12 @@ void _replyAddOptionProc(const char* a1, int a2, int a3)
v5->field_C[v13].kind = 1;
if (a1 != nullptr) {
if (a1 != NULL) {
v11 = (char*)internal_malloc_safe(strlen(a1) + 1, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 830
strcpy(v11, a1);
v5->field_C[v13].field_0 = v11;
} else {
v5->field_C[v13].field_0 = nullptr;
v5->field_C[v13].field_0 = NULL;
}
v5->field_C[v13].proc = a2;
@@ -246,12 +246,12 @@ void _replyAddOptionProc(const char* a1, int a2, int a3)
// 0x42F714
void _optionFree(STRUCT_56DAE0_FIELD_4_FIELD_C* a1)
{
if (a1->field_0 != nullptr) {
if (a1->field_0 != NULL) {
internal_free_safe(a1->field_0, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 844
}
if (a1->kind == 2) {
if (a1->string != nullptr) {
if (a1->string != NULL) {
internal_free_safe(a1->string, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 846
}
}
@@ -269,7 +269,7 @@ void _replyFree()
for (i = 0; i < ptr->field_8; i++) {
v6 = &(_dialog[_tods].field_4[i]);
if (v6->field_C != nullptr) {
if (v6->field_C != NULL) {
for (j = 0; j < v6->field_14; j++) {
_optionFree(&(v6->field_C[j]));
}
@@ -277,20 +277,20 @@ void _replyFree()
internal_free_safe(v6->field_C, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 857
}
if (v6->field_8 != nullptr) {
if (v6->field_8 != NULL) {
internal_free_safe(v6->field_8, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 860
}
if (v6->field_4 != nullptr) {
if (v6->field_4 != NULL) {
internal_free_safe(v6->field_4, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 862
}
if (v6->field_0 != nullptr) {
if (v6->field_0 != NULL) {
internal_free_safe(v6->field_0, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 864
}
}
if (ptr->field_4 != nullptr) {
if (ptr->field_4 != NULL) {
internal_free_safe(ptr->field_4, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 867
}
}
@@ -305,9 +305,9 @@ int _endDialog()
_topDialogReply = _dialog[_tods].field_10;
_replyFree();
if (gDialogReplyTitle != nullptr) {
if (gDialogReplyTitle != NULL) {
internal_free_safe(gDialogReplyTitle, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 986
gDialogReplyTitle = nullptr;
gDialogReplyTitle = NULL;
}
--_tods;
@@ -414,7 +414,7 @@ int _dialogStart(Program* a1)
ptr = &(_dialog[_tods]);
ptr->field_0 = a1;
ptr->field_4 = nullptr;
ptr->field_4 = 0;
ptr->field_8 = 0;
ptr->field_C = -1;
ptr->field_10 = -1;
@@ -449,11 +449,11 @@ int _dialogGotoReply(const char* a1)
return 1;
}
if (a1 != nullptr) {
if (a1 != NULL) {
ptr = &(_dialog[_tods]);
for (i = 0; i < ptr->field_8; i++) {
v5 = &(ptr->field_4[i]);
if (v5->field_4 != nullptr && compat_stricmp(v5->field_4, a1) == 0) {
if (v5->field_4 != NULL && compat_stricmp(v5->field_4, a1) == 0) {
ptr->field_10 = i;
return 0;
}
@@ -470,15 +470,15 @@ int _dialogGotoReply(const char* a1)
// 0x430E84
int dialogSetReplyTitle(const char* a1)
{
if (gDialogReplyTitle != nullptr) {
if (gDialogReplyTitle != NULL) {
internal_free_safe(gDialogReplyTitle, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 2561
}
if (a1 != nullptr) {
if (a1 != NULL) {
gDialogReplyTitle = (char*)internal_malloc_safe(strlen(a1) + 1, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 2564
strcpy(gDialogReplyTitle, a1);
} else {
gDialogReplyTitle = nullptr;
gDialogReplyTitle = NULL;
}
return 0;
@@ -586,22 +586,22 @@ int _dialogSetScrollUp(int a1, int a2, char* a3, char* a4, char* a5, char* a6, i
_upButton = a1;
dword_56DBD8 = a2;
if (off_56DBE0 != nullptr) {
if (off_56DBE0 != NULL) {
internal_free_safe(off_56DBE0, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 2750
}
off_56DBE0 = a3;
if (off_56DBE4 != nullptr) {
if (off_56DBE4 != NULL) {
internal_free_safe(off_56DBE4, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 2752
}
off_56DBE4 = a4;
if (off_56DBE8 != nullptr) {
if (off_56DBE8 != NULL) {
internal_free_safe(off_56DBE8, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 2754
}
off_56DBE8 = a5;
if (off_56DBEC != nullptr) {
if (off_56DBEC != NULL) {
internal_free_safe(off_56DBEC, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 2756
}
off_56DBEC = a5;
@@ -617,22 +617,22 @@ int _dialogSetScrollDown(int a1, int a2, char* a3, char* a4, char* a5, char* a6,
_downButton = a1;
dword_56DBB8 = a2;
if (off_56DBC0 != nullptr) {
if (off_56DBC0 != NULL) {
internal_free_safe(off_56DBC0, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 2765
}
off_56DBC0 = a3;
if (off_56DBC4 != nullptr) {
if (off_56DBC4 != NULL) {
internal_free_safe(off_56DBC4, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 2767
}
off_56DBC4 = a4;
if (off_56DBC8 != nullptr) {
if (off_56DBC8 != NULL) {
internal_free_safe(off_56DBC8, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 2769
}
off_56DBC8 = a5;
if (off_56DBCC != nullptr) {
if (off_56DBCC != NULL) {
internal_free_safe(off_56DBCC, __FILE__, __LINE__); // "..\\int\\DIALOG.C", 2771
}
off_56DBCC = a6;
+87 -44
View File
@@ -4,7 +4,6 @@
#include <stdlib.h>
#include <string.h>
#include "memory.h"
#include "platform_compat.h"
namespace fallout {
@@ -14,8 +13,38 @@ namespace fallout {
// with a check for this value.
#define DICTIONARY_MARKER 0xFEBAFEBA
static void* dictionaryMallocDefaultImpl(size_t size);
static void* dictionaryReallocDefaultImpl(void* ptr, size_t newSize);
static void dictionaryFreeDefaultImpl(void* ptr);
static int dictionaryFindIndexForKey(Dictionary* dictionary, const char* key, int* index);
// 0x51E408
static MallocProc* gDictionaryMallocProc = dictionaryMallocDefaultImpl;
// 0x51E40C
static ReallocProc* gDictionaryReallocProc = dictionaryReallocDefaultImpl;
// 0x51E410
static FreeProc* gDictionaryFreeProc = dictionaryFreeDefaultImpl;
// 0x4D9B90
static void* dictionaryMallocDefaultImpl(size_t size)
{
return malloc(size);
}
// 0x4D9B98
static void* dictionaryReallocDefaultImpl(void* ptr, size_t newSize)
{
return realloc(ptr, newSize);
}
// 0x4D9BA0
static void dictionaryFreeDefaultImpl(void* ptr)
{
free(ptr);
}
// 0x4D9BA8
int dictionaryInit(Dictionary* dictionary, int initialCapacity, size_t valueSize, DictionaryIO* io)
{
@@ -23,11 +52,11 @@ int dictionaryInit(Dictionary* dictionary, int initialCapacity, size_t valueSize
dictionary->valueSize = valueSize;
dictionary->entriesLength = 0;
if (io != nullptr) {
if (io != NULL) {
memcpy(&(dictionary->io), io, sizeof(*io));
} else {
dictionary->io.readProc = nullptr;
dictionary->io.writeProc = nullptr;
dictionary->io.readProc = NULL;
dictionary->io.writeProc = NULL;
dictionary->io.field_8 = 0;
dictionary->io.field_C = 0;
}
@@ -35,12 +64,12 @@ int dictionaryInit(Dictionary* dictionary, int initialCapacity, size_t valueSize
int rc = 0;
if (initialCapacity != 0) {
dictionary->entries = (DictionaryEntry*)internal_malloc(sizeof(*dictionary->entries) * initialCapacity);
if (dictionary->entries == nullptr) {
dictionary->entries = (DictionaryEntry*)gDictionaryMallocProc(sizeof(*dictionary->entries) * initialCapacity);
if (dictionary->entries == NULL) {
rc = -1;
}
} else {
dictionary->entries = nullptr;
dictionary->entries = NULL;
}
if (rc != -1) {
@@ -61,8 +90,8 @@ int dictionarySetCapacity(Dictionary* dictionary, int newCapacity)
return -1;
}
DictionaryEntry* entries = (DictionaryEntry*)internal_realloc(dictionary->entries, sizeof(*dictionary->entries) * newCapacity);
if (entries == nullptr) {
DictionaryEntry* entries = (DictionaryEntry*)gDictionaryReallocProc(dictionary->entries, sizeof(*dictionary->entries) * newCapacity);
if (entries == NULL) {
return -1;
}
@@ -81,17 +110,17 @@ int dictionaryFree(Dictionary* dictionary)
for (int index = 0; index < dictionary->entriesLength; index++) {
DictionaryEntry* entry = &(dictionary->entries[index]);
if (entry->key != nullptr) {
internal_free(entry->key);
if (entry->key != NULL) {
gDictionaryFreeProc(entry->key);
}
if (entry->value != nullptr) {
internal_free(entry->value);
if (entry->value != NULL) {
gDictionaryFreeProc(entry->value);
}
}
if (dictionary->entries != nullptr) {
internal_free(dictionary->entries);
if (dictionary->entries != NULL) {
gDictionaryFreeProc(dictionary->entries);
}
memset(dictionary, 0, sizeof(*dictionary));
@@ -194,24 +223,24 @@ int dictionaryAddValue(Dictionary* dictionary, const char* key, const void* valu
}
// Make a copy of the key.
char* keyCopy = (char*)internal_malloc(strlen(key) + 1);
if (keyCopy == nullptr) {
char* keyCopy = (char*)gDictionaryMallocProc(strlen(key) + 1);
if (keyCopy == NULL) {
return -1;
}
strcpy(keyCopy, key);
// Make a copy of the value.
void* valueCopy = nullptr;
if (value != nullptr && dictionary->valueSize != 0) {
valueCopy = internal_malloc(dictionary->valueSize);
if (valueCopy == nullptr) {
internal_free(keyCopy);
void* valueCopy = NULL;
if (value != NULL && dictionary->valueSize != 0) {
valueCopy = gDictionaryMallocProc(dictionary->valueSize);
if (valueCopy == NULL) {
gDictionaryFreeProc(keyCopy);
return -1;
}
}
if (valueCopy != nullptr && dictionary->valueSize != 0) {
if (valueCopy != NULL && dictionary->valueSize != 0) {
memcpy(valueCopy, value, dictionary->valueSize);
}
@@ -252,9 +281,9 @@ int dictionaryRemoveValue(Dictionary* dictionary, const char* key)
DictionaryEntry* entry = &(dictionary->entries[indexToRemove]);
// Free key and value (which are copies).
internal_free(entry->key);
if (entry->value != nullptr) {
internal_free(entry->value);
gDictionaryFreeProc(entry->key);
if (entry->value != NULL) {
gDictionaryFreeProc(entry->value);
}
dictionary->entriesLength--;
@@ -368,38 +397,38 @@ int dictionaryLoad(FILE* stream, Dictionary* dictionary, int a3)
for (int index = 0; index < dictionary->entriesLength; index++) {
DictionaryEntry* entry = &(dictionary->entries[index]);
if (entry->key != nullptr) {
internal_free(entry->key);
if (entry->key != NULL) {
gDictionaryFreeProc(entry->key);
}
if (entry->value != nullptr) {
internal_free(entry->value);
if (entry->value != NULL) {
gDictionaryFreeProc(entry->value);
}
}
if (dictionary->entries != nullptr) {
internal_free(dictionary->entries);
if (dictionary->entries != NULL) {
gDictionaryFreeProc(dictionary->entries);
}
if (dictionaryReadHeader(stream, dictionary) != 0) {
return -1;
}
dictionary->entries = nullptr;
dictionary->entries = NULL;
if (dictionary->entriesCapacity <= 0) {
return 0;
}
dictionary->entries = (DictionaryEntry*)internal_malloc(sizeof(*dictionary->entries) * dictionary->entriesCapacity);
if (dictionary->entries == nullptr) {
dictionary->entries = (DictionaryEntry*)gDictionaryMallocProc(sizeof(*dictionary->entries) * dictionary->entriesCapacity);
if (dictionary->entries == NULL) {
return -1;
}
for (int index = 0; index < dictionary->entriesLength; index++) {
DictionaryEntry* entry = &(dictionary->entries[index]);
entry->key = nullptr;
entry->value = nullptr;
entry->key = NULL;
entry->value = NULL;
}
if (dictionary->entriesLength <= 0) {
@@ -413,22 +442,22 @@ int dictionaryLoad(FILE* stream, Dictionary* dictionary, int a3)
return -1;
}
entry->key = (char*)internal_malloc(keyLength + 1);
if (entry->key == nullptr) {
entry->key = (char*)gDictionaryMallocProc(keyLength + 1);
if (entry->key == NULL) {
return -1;
}
if (compat_fgets(entry->key, keyLength + 1, stream) == nullptr) {
if (compat_fgets(entry->key, keyLength + 1, stream) == NULL) {
return -1;
}
if (dictionary->valueSize != 0) {
entry->value = internal_malloc(dictionary->valueSize);
if (entry->value == nullptr) {
entry->value = gDictionaryMallocProc(dictionary->valueSize);
if (entry->value == NULL) {
return -1;
}
if (dictionary->io.readProc != nullptr) {
if (dictionary->io.readProc != NULL) {
if (dictionary->io.readProc(stream, entry->value, dictionary->valueSize, a3) != 0) {
return -1;
}
@@ -494,7 +523,7 @@ int dictionaryWrite(FILE* stream, Dictionary* dictionary, int a3)
return -1;
}
if (dictionary->io.writeProc != nullptr) {
if (dictionary->io.writeProc != NULL) {
if (dictionary->valueSize != 0) {
if (dictionary->io.writeProc(stream, entry->value, dictionary->valueSize, a3) != 0) {
return -1;
@@ -512,4 +541,18 @@ int dictionaryWrite(FILE* stream, Dictionary* dictionary, int a3)
return 0;
}
// 0x4DA498
void dictionarySetMemoryProcs(MallocProc* mallocProc, ReallocProc* reallocProc, FreeProc* freeProc)
{
if (mallocProc != NULL && reallocProc != NULL && freeProc != NULL) {
gDictionaryMallocProc = mallocProc;
gDictionaryReallocProc = reallocProc;
gDictionaryFreeProc = freeProc;
} else {
gDictionaryMallocProc = dictionaryMallocDefaultImpl;
gDictionaryReallocProc = dictionaryReallocDefaultImpl;
gDictionaryFreeProc = dictionaryFreeDefaultImpl;
}
}
} // namespace fallout
+3
View File
@@ -3,6 +3,8 @@
#include <stdio.h>
#include "memory_defs.h"
namespace fallout {
typedef int(DictionaryReadProc)(FILE* stream, void* buffer, unsigned int size, int a4);
@@ -61,6 +63,7 @@ int dictionaryLoad(FILE* stream, Dictionary* dictionary, int a3);
int dictionaryWriteInt(FILE* stream, int value);
int dictionaryWriteHeader(FILE* stream, Dictionary* dictionary);
int dictionaryWrite(FILE* stream, Dictionary* dictionary, int a3);
void dictionarySetMemoryProcs(MallocProc* mallocProc, ReallocProc* reallocProc, FreeProc* freeProc);
} // namespace fallout
+19 -19
View File
@@ -118,7 +118,7 @@ int displayMonitorInit()
fontSetCurrent(oldFont);
gDisplayMonitorBackgroundFrmData = (unsigned char*)internal_malloc(DISPLAY_MONITOR_WIDTH * DISPLAY_MONITOR_HEIGHT);
if (gDisplayMonitorBackgroundFrmData == nullptr) {
if (gDisplayMonitorBackgroundFrmData == NULL) {
return -1;
}
@@ -158,16 +158,16 @@ int displayMonitorInit()
-1,
-1,
-1,
nullptr,
nullptr,
nullptr,
NULL,
NULL,
NULL,
0);
if (gDisplayMonitorScrollUpButton != -1) {
buttonSetMouseCallbacks(gDisplayMonitorScrollUpButton,
displayMonitorScrollUpOnMouseEnter,
displayMonitorOnMouseExit,
displayMonitorScrollUpOnMouseDown,
nullptr);
NULL);
}
gDisplayMonitorScrollDownButton = buttonCreate(gInterfaceBarWindow,
@@ -179,16 +179,16 @@ int displayMonitorInit()
-1,
-1,
-1,
nullptr,
nullptr,
nullptr,
NULL,
NULL,
NULL,
0);
if (gDisplayMonitorScrollDownButton != -1) {
buttonSetMouseCallbacks(gDisplayMonitorScrollDownButton,
displayMonitorScrollDownOnMouseEnter,
displayMonitorOnMouseExit,
displayMonitorScrollDownOnMouseDown,
nullptr);
NULL);
}
gDisplayMonitorEnabled = true;
@@ -257,7 +257,7 @@ void displayMonitorAddMessage(char* str)
}
// TODO: Refactor these two loops.
char* v1 = nullptr;
char* v1 = NULL;
while (true) {
while (fontGetStringWidth(str) < DISPLAY_MONITOR_WIDTH - _max_disp - knobWidth) {
char* temp = gDisplayMonitorLines[_disp_start];
@@ -274,7 +274,7 @@ void displayMonitorAddMessage(char* str)
gDisplayMonitorLines[_disp_start][DISPLAY_MONITOR_LINE_LENGTH - 1] = '\0';
_disp_start = (_disp_start + 1) % gDisplayMonitorLinesCapacity;
if (v1 == nullptr) {
if (v1 == NULL) {
fontSetCurrent(oldFont);
_disp_curr = _disp_start;
displayMonitorRefresh();
@@ -283,20 +283,20 @@ void displayMonitorAddMessage(char* str)
str = v1 + 1;
*v1 = ' ';
v1 = nullptr;
v1 = NULL;
}
char* space = strrchr(str, ' ');
if (space == nullptr) {
if (space == NULL) {
break;
}
if (v1 != nullptr) {
if (v1 != NULL) {
*v1 = ' ';
}
v1 = space;
if (space != nullptr) {
if (space != NULL) {
*space = '\0';
}
}
@@ -347,7 +347,7 @@ static void displayMonitorRefresh()
}
unsigned char* buf = windowGetBuffer(gInterfaceBarWindow);
if (buf == nullptr) {
if (buf == NULL) {
return;
}
@@ -438,11 +438,11 @@ static void consoleFileInit()
{
char* consoleFilePath;
configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CONSOLE_OUTPUT_FILE_KEY, &consoleFilePath);
if (consoleFilePath != nullptr && *consoleFilePath == '\0') {
consoleFilePath = nullptr;
if (consoleFilePath != NULL && *consoleFilePath == '\0') {
consoleFilePath = NULL;
}
if (consoleFilePath != nullptr) {
if (consoleFilePath != NULL) {
gConsoleFileStream.open(consoleFilePath);
}
}
+1 -1
View File
@@ -27,7 +27,7 @@ void bufferDrawLine(unsigned char* buf, int pitch, int x1, int y1, int x2, int y
p1 = buf + pitch * y1 + x1;
p2 = buf + pitch * y2 + x2;
while (p1 <= p2) {
while (p1 < p2) {
*p1 = color;
*p2 = color;
p1 += pitch;
+7 -7
View File
@@ -8,7 +8,6 @@
#include "art.h"
#include "cycle.h"
#include "debug.h"
#include "delay.h"
#include "draw.h"
#include "game_mouse.h"
#include "game_sound.h"
@@ -454,7 +453,8 @@ int elevatorSelectLevel(int elevator, int* mapPtr, int* elevationPtr, int* tileP
windowRefresh(gElevatorWindow);
delay_ms(delay - (getTicks() - tick));
while (getTicksSince(tick) < delay) {
}
renderPresent();
sharedFpsLimiter.throttle();
@@ -593,10 +593,10 @@ static int elevatorWindowInit(int elevator)
500 + level,
_elevatorFrmImages[ELEVATOR_FRM_BUTTON_UP].getData(),
_elevatorFrmImages[ELEVATOR_FRM_BUTTON_DOWN].getData(),
nullptr,
NULL,
BUTTON_FLAG_TRANSPARENT);
if (btn != -1) {
buttonSetCallbacks(btn, _gsound_red_butt_press, nullptr);
buttonSetCallbacks(btn, _gsound_red_butt_press, NULL);
}
y += 60;
}
@@ -650,11 +650,11 @@ void elevatorsInit()
{
char* elevatorsFileName;
configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_ELEVATORS_FILE_KEY, &elevatorsFileName);
if (elevatorsFileName != nullptr && *elevatorsFileName == '\0') {
elevatorsFileName = nullptr;
if (elevatorsFileName != NULL && *elevatorsFileName == '\0') {
elevatorsFileName = NULL;
}
if (elevatorsFileName != nullptr) {
if (elevatorsFileName != NULL) {
Config elevatorsConfig;
if (configInit(&elevatorsConfig)) {
if (configRead(&elevatorsConfig, elevatorsFileName, false)) {
+52 -52
View File
@@ -112,7 +112,7 @@ static int _endgame_maybe_done = 0;
// enddeath.txt
//
// 0x518678
static EndgameDeathEnding* gEndgameDeathEndings = nullptr;
static EndgameDeathEnding* gEndgameDeathEndings = NULL;
// The number of death endings in [gEndgameDeathEndings] array.
//
@@ -248,7 +248,7 @@ void endgamePlayMovie()
creditsOpen("credits.txt", -1, false);
backgroundSoundDelete();
backgroundSoundSetEndCallback(nullptr);
backgroundSoundSetEndCallback(NULL);
tickersRemove(_endgame_movie_bk_process);
backgroundSoundDelete();
colorPaletteLoad("color.pal");
@@ -286,7 +286,7 @@ static int endgameEndingHandleContinuePlaying()
MessageListItem messageListItem;
messageListItem.num = 30;
if (messageListGetItem(&gMiscMessageList, &messageListItem)) {
rc = showDialogBox(messageListItem.text, nullptr, 0, 169, 117, _colorTable[32328], nullptr, _colorTable[32328], DIALOG_BOX_YES_NO);
rc = showDialogBox(messageListItem.text, NULL, 0, 169, 117, _colorTable[32328], NULL, _colorTable[32328], DIALOG_BOX_YES_NO);
if (rc == 0) {
_game_user_wants_to_quit = 2;
}
@@ -317,7 +317,7 @@ static void endgameEndingRenderPanningScene(int direction, const char* narratorF
CacheEntry* backgroundHandle;
Art* background = artLock(fid, &backgroundHandle);
if (background != nullptr) {
if (background != NULL) {
int width = artGetWidth(background, 0, 0);
int height = artGetHeight(background, 0, 0);
unsigned char* backgroundData = artGetFrameData(background, 0, 0);
@@ -449,12 +449,12 @@ static void endgameEndingRenderStaticScene(int fid, const char* narratorFileName
{
CacheEntry* backgroundHandle;
Art* background = artLock(fid, &backgroundHandle);
if (background == nullptr) {
if (background == NULL) {
return;
}
unsigned char* backgroundData = artGetFrameData(background, 0, 0);
if (backgroundData != nullptr) {
if (backgroundData != NULL) {
blitBufferToBuffer(backgroundData, ENDGAME_ENDING_WINDOW_WIDTH, ENDGAME_ENDING_WINDOW_HEIGHT, ENDGAME_ENDING_WINDOW_WIDTH, gEndgameEndingSlideshowWindowBuffer, ENDGAME_ENDING_WINDOW_WIDTH);
windowRefresh(gEndgameEndingSlideshowWindow);
@@ -584,7 +584,7 @@ static int endgameEndingSlideshowWindowInit()
}
gEndgameEndingSlideshowWindowBuffer = windowGetBuffer(gEndgameEndingSlideshowWindow);
if (gEndgameEndingSlideshowWindowBuffer == nullptr) {
if (gEndgameEndingSlideshowWindowBuffer == NULL) {
return -1;
}
@@ -600,17 +600,17 @@ static int endgameEndingSlideshowWindowInit()
snprintf(gEndgameEndingSubtitlesLocalizedPath, sizeof(gEndgameEndingSubtitlesLocalizedPath), "text\\%s\\cuts\\", settings.system.language.c_str());
gEndgameEndingSubtitles = (char**)internal_malloc(sizeof(*gEndgameEndingSubtitles) * ENDGAME_ENDING_MAX_SUBTITLES);
if (gEndgameEndingSubtitles == nullptr) {
if (gEndgameEndingSubtitles == NULL) {
gEndgameEndingSubtitlesEnabled = false;
return 0;
}
for (int index = 0; index < ENDGAME_ENDING_MAX_SUBTITLES; index++) {
gEndgameEndingSubtitles[index] = nullptr;
gEndgameEndingSubtitles[index] = NULL;
}
gEndgameEndingSubtitlesTimings = (unsigned int*)internal_malloc(sizeof(*gEndgameEndingSubtitlesTimings) * ENDGAME_ENDING_MAX_SUBTITLES);
if (gEndgameEndingSubtitlesTimings == nullptr) {
if (gEndgameEndingSubtitlesTimings == NULL) {
internal_free(gEndgameEndingSubtitles);
gEndgameEndingSubtitlesEnabled = false;
return 0;
@@ -628,7 +628,7 @@ static void endgameEndingSlideshowWindowFree()
internal_free(gEndgameEndingSubtitlesTimings);
internal_free(gEndgameEndingSubtitles);
gEndgameEndingSubtitles = nullptr;
gEndgameEndingSubtitles = NULL;
gEndgameEndingSubtitlesEnabled = false;
}
@@ -637,7 +637,7 @@ static void endgameEndingSlideshowWindowFree()
fontSetCurrent(gEndgameEndingSlideshowOldFont);
speechSetEndCallback(nullptr);
speechSetEndCallback(NULL);
windowDestroy(gEndgameEndingSlideshowWindow);
windowDestroy(gEndgameEndingOverlay);
@@ -741,7 +741,7 @@ static void endgameEndingLoadPalette(int type, int id)
// Remove extension from file name.
char* pch = strrchr(fileName, '.');
if (pch != nullptr) {
if (pch != NULL) {
*pch = '\0';
}
@@ -766,7 +766,7 @@ static int endgameEndingSubtitlesLoad(const char* filePath)
endgameEndingSubtitlesFree();
File* stream = fileOpen(filePath, "rt");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -778,14 +778,14 @@ static int endgameEndingSubtitlesLoad(const char* filePath)
// Find and clamp string at EOL.
pch = strchr(string, '\n');
if (pch != nullptr) {
if (pch != NULL) {
*pch = '\0';
}
// Find separator. The value before separator is ignored (as opposed to
// movie subtitles, where the value before separator is a timing).
pch = strchr(string, ':');
if (pch != nullptr) {
if (pch != NULL) {
if (gEndgameEndingSubtitlesLength < ENDGAME_ENDING_MAX_SUBTITLES) {
gEndgameEndingSubtitles[gEndgameEndingSubtitlesLength] = internal_strdup(pch + 1);
gEndgameEndingSubtitlesLength++;
@@ -817,7 +817,7 @@ static void endgameEndingRefreshSubtitles()
}
char* text = gEndgameEndingSubtitles[gEndgameEndingSubtitlesCurrentLine];
if (text == nullptr) {
if (text == NULL) {
return;
}
@@ -856,9 +856,9 @@ static void endgameEndingRefreshSubtitles()
static void endgameEndingSubtitlesFree()
{
for (int index = 0; index < gEndgameEndingSubtitlesLength; index++) {
if (gEndgameEndingSubtitles[index] != nullptr) {
if (gEndgameEndingSubtitles[index] != NULL) {
internal_free(gEndgameEndingSubtitles[index]);
gEndgameEndingSubtitles[index] = nullptr;
gEndgameEndingSubtitles[index] = NULL;
}
}
@@ -878,7 +878,7 @@ static void _endgame_movie_bk_process()
{
if (_endgame_maybe_done) {
backgroundSoundLoad("10labone", 11, 14, 16);
backgroundSoundSetEndCallback(nullptr);
backgroundSoundSetEndCallback(NULL);
tickersRemove(_endgame_movie_bk_process);
}
}
@@ -894,15 +894,15 @@ static int endgameEndingInit()
EndgameEnding* entries;
size_t narratorFileNameLength;
if (gEndgameEndings != nullptr) {
if (gEndgameEndings != NULL) {
internal_free(gEndgameEndings);
gEndgameEndings = nullptr;
gEndgameEndings = NULL;
}
gEndgameEndingsLength = 0;
stream = fileOpen("data\\endgame.txt", "rt");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -917,28 +917,28 @@ static int endgameEndingInit()
}
tok = strtok(ch, delim);
if (tok == nullptr) {
if (tok == NULL) {
continue;
}
entry.gvar = atoi(tok);
tok = strtok(nullptr, delim);
if (tok == nullptr) {
tok = strtok(NULL, delim);
if (tok == NULL) {
continue;
}
entry.value = atoi(tok);
tok = strtok(nullptr, delim);
if (tok == nullptr) {
tok = strtok(NULL, delim);
if (tok == NULL) {
continue;
}
entry.art_num = atoi(tok);
tok = strtok(nullptr, delim);
if (tok == nullptr) {
tok = strtok(NULL, delim);
if (tok == NULL) {
continue;
}
@@ -949,15 +949,15 @@ static int endgameEndingInit()
entry.voiceOverBaseName[narratorFileNameLength - 1] = '\0';
}
tok = strtok(nullptr, delim);
if (tok != nullptr) {
tok = strtok(NULL, delim);
if (tok != NULL) {
entry.direction = atoi(tok);
} else {
entry.direction = 1;
}
entries = (EndgameEnding*)internal_realloc(gEndgameEndings, sizeof(*entries) * (gEndgameEndingsLength + 1));
if (entries == nullptr) {
if (entries == NULL) {
goto err;
}
@@ -983,9 +983,9 @@ err:
// 0x44095C
static void endgameEndingFree()
{
if (gEndgameEndings != nullptr) {
if (gEndgameEndings != NULL) {
internal_free(gEndgameEndings);
gEndgameEndings = nullptr;
gEndgameEndings = NULL;
}
gEndgameEndingsLength = 0;
@@ -1007,7 +1007,7 @@ int endgameDeathEndingInit()
strcpy(gEndgameDeathEndingFileName, "narrator\\nar_5");
stream = fileOpen("data\\enddeath.txt", "rt");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -1022,49 +1022,49 @@ int endgameDeathEndingInit()
}
tok = strtok(ch, delim);
if (tok == nullptr) {
if (tok == NULL) {
continue;
}
entry.gvar = atoi(tok);
tok = strtok(nullptr, delim);
if (tok == nullptr) {
tok = strtok(NULL, delim);
if (tok == NULL) {
continue;
}
entry.value = atoi(tok);
tok = strtok(nullptr, delim);
if (tok == nullptr) {
tok = strtok(NULL, delim);
if (tok == NULL) {
continue;
}
entry.worldAreaKnown = atoi(tok);
tok = strtok(nullptr, delim);
if (tok == nullptr) {
tok = strtok(NULL, delim);
if (tok == NULL) {
continue;
}
entry.worldAreaNotKnown = atoi(tok);
tok = strtok(nullptr, delim);
if (tok == nullptr) {
tok = strtok(NULL, delim);
if (tok == NULL) {
continue;
}
entry.min_level = atoi(tok);
tok = strtok(nullptr, delim);
if (tok == nullptr) {
tok = strtok(NULL, delim);
if (tok == NULL) {
continue;
}
entry.percentage = atoi(tok);
tok = strtok(nullptr, delim);
if (tok == nullptr) {
tok = strtok(NULL, delim);
if (tok == NULL) {
continue;
}
@@ -1079,7 +1079,7 @@ int endgameDeathEndingInit()
}
entries = (EndgameDeathEnding*)internal_realloc(gEndgameDeathEndings, sizeof(*entries) * (gEndgameDeathEndingsLength + 1));
if (entries == nullptr) {
if (entries == NULL) {
goto err;
}
@@ -1103,9 +1103,9 @@ err:
// 0x440BA8
int endgameDeathEndingExit()
{
if (gEndgameDeathEndings != nullptr) {
if (gEndgameDeathEndings != NULL) {
internal_free(gEndgameDeathEndings);
gEndgameDeathEndings = nullptr;
gEndgameDeathEndings = NULL;
gEndgameDeathEndingsLength = 0;
}
+21 -21
View File
@@ -61,7 +61,7 @@ ExternalProcedure* externalProcedureFind(const char* identifier)
unsigned int v2 = v1;
ExternalProcedure* externalProcedure = &(gExternalProcedures[v1]);
if (externalProcedure->program != nullptr) {
if (externalProcedure->program != NULL) {
if (compat_stricmp(externalProcedure->name, identifier) == 0) {
return externalProcedure;
}
@@ -74,14 +74,14 @@ ExternalProcedure* externalProcedureFind(const char* identifier)
}
externalProcedure = &(gExternalProcedures[v1]);
if (externalProcedure->program != nullptr) {
if (externalProcedure->program != NULL) {
if (compat_stricmp(externalProcedure->name, identifier) == 0) {
return externalProcedure;
}
}
} while (v1 != v2);
return nullptr;
return NULL;
}
// 0x441018
@@ -108,7 +108,7 @@ ExternalProcedure* externalProcedureAdd(const char* identifier)
}
} while (v1 != a2);
return nullptr;
return NULL;
}
// 0x4410AC
@@ -140,7 +140,7 @@ ExternalVariable* externalVariableFind(const char* identifier)
}
} while (v1 != v2);
return nullptr;
return NULL;
}
// 0x44118C
@@ -167,14 +167,14 @@ ExternalVariable* externalVariableAdd(const char* identifier)
}
} while (v1 != v2);
return nullptr;
return NULL;
}
// 0x44127C
int externalVariableSetValue(Program* program, const char* name, ProgramValue& programValue)
{
ExternalVariable* exportedVariable = externalVariableFind(name);
if (exportedVariable == nullptr) {
if (exportedVariable == NULL) {
return 1;
}
@@ -183,7 +183,7 @@ int externalVariableSetValue(Program* program, const char* name, ProgramValue& p
}
if ((programValue.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_STRING) {
if (program != nullptr) {
if (program != NULL) {
const char* stringValue = programGetString(program, programValue.opcode, programValue.integerValue);
exportedVariable->value.opcode = VALUE_TYPE_DYNAMIC_STRING;
@@ -201,7 +201,7 @@ int externalVariableSetValue(Program* program, const char* name, ProgramValue& p
int externalVariableGetValue(Program* program, const char* name, ProgramValue& value)
{
ExternalVariable* exportedVariable = externalVariableFind(name);
if (exportedVariable == nullptr) {
if (exportedVariable == NULL) {
return 1;
}
@@ -221,7 +221,7 @@ int externalVariableCreate(Program* program, const char* identifier)
const char* programName = program->name;
ExternalVariable* exportedVariable = externalVariableFind(identifier);
if (exportedVariable != nullptr) {
if (exportedVariable != NULL) {
if (compat_stricmp(exportedVariable->programName, programName) != 0) {
return 1;
}
@@ -231,7 +231,7 @@ int externalVariableCreate(Program* program, const char* identifier)
}
} else {
exportedVariable = externalVariableAdd(identifier);
if (exportedVariable == nullptr) {
if (exportedVariable == NULL) {
return 1;
}
@@ -254,7 +254,7 @@ void _removeProgramReferences(Program* program)
ExternalProcedure* externalProcedure = &(gExternalProcedures[index]);
if (externalProcedure->program == program) {
externalProcedure->name[0] = '\0';
externalProcedure->program = nullptr;
externalProcedure->program = NULL;
}
}
}
@@ -285,12 +285,12 @@ void externalVariablesClear()
Program* externalProcedureGetProgram(const char* identifier, int* addressPtr, int* argumentCountPtr)
{
ExternalProcedure* externalProcedure = externalProcedureFind(identifier);
if (externalProcedure == nullptr) {
return nullptr;
if (externalProcedure == NULL) {
return NULL;
}
if (externalProcedure->program == nullptr) {
return nullptr;
if (externalProcedure->program == NULL) {
return NULL;
}
*addressPtr = externalProcedure->address;
@@ -303,13 +303,13 @@ Program* externalProcedureGetProgram(const char* identifier, int* addressPtr, in
int externalProcedureCreate(Program* program, const char* identifier, int address, int argumentCount)
{
ExternalProcedure* externalProcedure = externalProcedureFind(identifier);
if (externalProcedure != nullptr) {
if (externalProcedure != NULL) {
if (program != externalProcedure->program) {
return 1;
}
} else {
externalProcedure = externalProcedureAdd(identifier);
if (externalProcedure == nullptr) {
if (externalProcedure == NULL) {
return 1;
}
@@ -330,14 +330,14 @@ void _exportClearAllVariables()
ExternalVariable* exportedVariable = &(gExternalVariables[index]);
if (exportedVariable->name[0] != '\0') {
if ((exportedVariable->value.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_STRING) {
if (exportedVariable->stringValue != nullptr) {
if (exportedVariable->stringValue != NULL) {
internal_free_safe(exportedVariable->stringValue, __FILE__, __LINE__); // "..\\int\\EXPORT.C", 387
}
}
if (exportedVariable->programName != nullptr) {
if (exportedVariable->programName != NULL) {
internal_free_safe(exportedVariable->programName, __FILE__, __LINE__); // "..\\int\\EXPORT.C", 393
exportedVariable->programName = nullptr;
exportedVariable->programName = NULL;
}
exportedVariable->name[0] = '\0';
+23 -28
View File
@@ -3,7 +3,7 @@
#include <stddef.h>
#include <string.h>
#include <fpattern/fpattern.h>
#include <fpattern.h>
namespace fallout {
@@ -16,41 +16,33 @@ bool fileFindFirst(const char* path, DirectoryFileFindData* findData)
return false;
}
#else
strcpy(findData->path, path);
char drive[COMPAT_MAX_DRIVE];
char dir[COMPAT_MAX_DIR];
char fname[COMPAT_MAX_FNAME];
char ext[COMPAT_MAX_EXT];
compat_splitpath(path, drive, dir, fname, ext);
// Reassemble file name and extension to serve as a pattern. It has to be
// lowercased because underlying `fpattern` implementation uses lowercased
// char-by-char matching.
compat_makepath(findData->pattern, nullptr, nullptr, fname, ext);
compat_strlwr(findData->pattern);
compat_splitpath(path, drive, dir, NULL, NULL);
char basePath[COMPAT_MAX_PATH];
compat_makepath(basePath, drive, dir, nullptr, nullptr);
compat_resolve_path(basePath);
compat_makepath(basePath, drive, dir, NULL, NULL);
findData->dir = opendir(basePath);
if (findData->dir == nullptr) {
if (findData->dir == NULL) {
return false;
}
findData->entry = readdir(findData->dir);
while (findData->entry != nullptr) {
char entryName[COMPAT_MAX_FNAME];
strcpy(entryName, fileFindGetName(findData));
compat_strlwr(entryName);
if (fpattern_match(findData->pattern, entryName)) {
while (findData->entry != NULL) {
char entryPath[COMPAT_MAX_PATH];
compat_makepath(entryPath, drive, dir, fileFindGetName(findData), NULL);
if (fpattern_match(findData->path, entryPath)) {
break;
}
findData->entry = readdir(findData->dir);
}
if (findData->entry == nullptr) {
if (findData->entry == NULL) {
closedir(findData->dir);
findData->dir = nullptr;
findData->dir = NULL;
return false;
}
#endif
@@ -66,20 +58,23 @@ bool fileFindNext(DirectoryFileFindData* findData)
return false;
}
#else
char drive[COMPAT_MAX_DRIVE];
char dir[COMPAT_MAX_DIR];
compat_splitpath(findData->path, drive, dir, NULL, NULL);
findData->entry = readdir(findData->dir);
while (findData->entry != nullptr) {
char entryName[COMPAT_MAX_FNAME];
strcpy(entryName, fileFindGetName(findData));
compat_strlwr(entryName);
if (fpattern_match(findData->pattern, entryName)) {
while (findData->entry != NULL) {
char entryPath[COMPAT_MAX_PATH];
compat_makepath(entryPath, drive, dir, fileFindGetName(findData), NULL);
if (fpattern_match(findData->path, entryPath)) {
break;
}
findData->entry = readdir(findData->dir);
}
if (findData->entry == nullptr) {
if (findData->entry == NULL) {
closedir(findData->dir);
findData->dir = nullptr;
findData->dir = NULL;
return false;
}
#endif
@@ -93,7 +88,7 @@ bool findFindClose(DirectoryFileFindData* findData)
#if defined(_MSC_VER)
FindClose(findData->hFind);
#else
if (findData->dir != nullptr) {
if (findData->dir != NULL) {
if (closedir(findData->dir) != 0) {
return false;
}
+1 -1
View File
@@ -37,7 +37,7 @@ typedef struct DirectoryFileFindData {
#else
DIR* dir;
struct dirent* entry;
char pattern[COMPAT_MAX_FNAME];
char path[COMPAT_MAX_PATH];
#endif
} DirectoryFileFindData;
+12 -12
View File
@@ -19,7 +19,7 @@ static void fileCopy(const char* existingFilePath, const char* newFilePath);
int fileCopyDecompressed(const char* existingFilePath, const char* newFilePath)
{
FILE* stream = compat_fopen(existingFilePath, "rb");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -32,7 +32,7 @@ int fileCopyDecompressed(const char* existingFilePath, const char* newFilePath)
gzFile inStream = compat_gzopen(existingFilePath, "rb");
FILE* outStream = compat_fopen(newFilePath, "wb");
if (inStream != nullptr && outStream != nullptr) {
if (inStream != NULL && outStream != NULL) {
for (;;) {
int ch = gzgetc(inStream);
if (ch == -1) {
@@ -45,11 +45,11 @@ int fileCopyDecompressed(const char* existingFilePath, const char* newFilePath)
gzclose(inStream);
fclose(outStream);
} else {
if (inStream != nullptr) {
if (inStream != NULL) {
gzclose(inStream);
}
if (outStream != nullptr) {
if (outStream != NULL) {
fclose(outStream);
}
@@ -66,7 +66,7 @@ int fileCopyDecompressed(const char* existingFilePath, const char* newFilePath)
int fileCopyCompressed(const char* existingFilePath, const char* newFilePath)
{
FILE* inStream = compat_fopen(existingFilePath, "rb");
if (inStream == nullptr) {
if (inStream == NULL) {
return -1;
}
@@ -82,7 +82,7 @@ int fileCopyCompressed(const char* existingFilePath, const char* newFilePath)
fileCopy(existingFilePath, newFilePath);
} else {
gzFile outStream = compat_gzopen(newFilePath, "wb");
if (outStream == nullptr) {
if (outStream == NULL) {
fclose(inStream);
return -1;
}
@@ -108,7 +108,7 @@ int fileCopyCompressed(const char* existingFilePath, const char* newFilePath)
int _gzdecompress_file(const char* existingFilePath, const char* newFilePath)
{
FILE* stream = compat_fopen(existingFilePath, "rb");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -120,12 +120,12 @@ int _gzdecompress_file(const char* existingFilePath, const char* newFilePath)
// TODO: Is it broken?
if (magic[0] != 0x1F || magic[1] != 0x8B) {
gzFile gzstream = compat_gzopen(existingFilePath, "rb");
if (gzstream == nullptr) {
if (gzstream == NULL) {
return -1;
}
stream = compat_fopen(newFilePath, "wb");
if (stream == nullptr) {
if (stream == NULL) {
gzclose(gzstream);
return -1;
}
@@ -152,7 +152,7 @@ static void fileCopy(const char* existingFilePath, const char* newFilePath)
{
FILE* in = compat_fopen(existingFilePath, "rb");
FILE* out = compat_fopen(newFilePath, "wb");
if (in != nullptr && out != nullptr) {
if (in != NULL && out != NULL) {
std::vector<unsigned char> buffer(0xFFFF);
size_t bytesRead;
@@ -171,11 +171,11 @@ static void fileCopy(const char* existingFilePath, const char* newFilePath)
}
}
if (in != nullptr) {
if (in != NULL) {
fclose(in);
}
if (out != nullptr) {
if (out != NULL) {
fclose(out);
}
}
+5 -5
View File
@@ -82,7 +82,7 @@ int interfaceFontsInit()
for (int font = 0; font < INTERFACE_FONT_MAX; font++) {
if (interfaceFontLoad(font) == -1) {
gInterfaceFontDescriptors[font].maxHeight = 0;
gInterfaceFontDescriptors[font].data = nullptr;
gInterfaceFontDescriptors[font].data = NULL;
} else {
++gInterfaceFontsLength;
@@ -107,7 +107,7 @@ int interfaceFontsInit()
void interfaceFontsExit()
{
for (int font = 0; font < INTERFACE_FONT_MAX; font++) {
if (gInterfaceFontDescriptors[font].data != nullptr) {
if (gInterfaceFontDescriptors[font].data != NULL) {
internal_free_safe(gInterfaceFontDescriptors[font].data, __FILE__, __LINE__); // FONTMGR.C, 124
}
}
@@ -122,7 +122,7 @@ static int interfaceFontLoad(int font_index)
snprintf(path, sizeof(path), "font%d.aaf", font_index);
File* stream = fileOpen(path, "rb");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -189,7 +189,7 @@ static int interfaceFontLoad(int font_index)
int glyphDataSize = fileSize - 2060;
fontDescriptor->data = (unsigned char*)internal_malloc_safe(glyphDataSize, __FILE__, __LINE__); // FONTMGR.C, 259
if (fontDescriptor->data == nullptr) {
if (fontDescriptor->data == NULL) {
fileClose(stream);
return -1;
}
@@ -213,7 +213,7 @@ static void interfaceFontSetCurrentImpl(int font)
font -= 100;
if (gInterfaceFontDescriptors[font].data != nullptr) {
if (gInterfaceFontDescriptors[font].data != NULL) {
gCurrentInterfaceFont = font;
gCurrentInterfaceFontDescriptor = &(gInterfaceFontDescriptors[font]);
}
+30 -52
View File
@@ -65,7 +65,6 @@
#include "trait.h"
#include "version.h"
#include "window_manager.h"
#include "window_manager_private.h"
#include "worldmap.h"
namespace fallout {
@@ -100,7 +99,7 @@ static int gGameState = GAME_STATE_0;
static bool gIsMapper = false;
// 0x5186C0
int* gGameGlobalVars = nullptr;
int* gGameGlobalVars = NULL;
// 0x5186C4
int gGameGlobalVarsLength = 0;
@@ -169,26 +168,12 @@ int gameInitWithOptions(const char* windowTitle, bool isMapper, int font, int a4
showSplash();
}
// CE: Handle debug mode (exactly as seen in `mapper2.exe`).
const char* debugMode = settings.debug.mode.c_str();
if (compat_stricmp(debugMode, "environment") == 0) {
_debug_register_env();
} else if (compat_stricmp(debugMode, "screen") == 0) {
_debug_register_screen();
} else if (compat_stricmp(debugMode, "log") == 0) {
_debug_register_log("debug.log", "wt");
} else if (compat_stricmp(debugMode, "mono") == 0) {
_debug_register_mono();
} else if (compat_stricmp(debugMode, "gnw") == 0) {
_debug_register_func(_win_debug);
}
interfaceFontsInit();
fontManagerAdd(&gModernFontManager);
fontSetCurrent(font);
screenshotHandlerConfigure(KEY_F12, gameTakeScreenshot);
pauseHandlerConfigure(-1, nullptr);
pauseHandlerConfigure(-1, NULL);
tileDisable();
@@ -599,7 +584,7 @@ int gameHandleKey(int eventCode, bool isInCombatMode)
case KEY_LOWERCASE_A:
if (interfaceBarEnabled()) {
if (!isInCombatMode) {
_combat(nullptr);
_combat(NULL);
}
}
break;
@@ -661,7 +646,7 @@ int gameHandleKey(int eventCode, bool isInCombatMode)
MessageListItem messageListItem;
char title[128];
strcpy(title, getmsg(&gMiscMessageList, &messageListItem, 7));
showDialogBox(title, nullptr, 0, 192, 116, _colorTable[32328], nullptr, _colorTable[32328], 0);
showDialogBox(title, NULL, 0, 192, 116, _colorTable[32328], NULL, _colorTable[32328], 0);
} else {
soundPlayFile("ib1p1xx1");
pipboyOpen(PIPBOY_OPEN_INTENT_UNSPECIFIED);
@@ -729,7 +714,7 @@ int gameHandleKey(int eventCode, bool isInCombatMode)
MessageListItem messageListItem;
char title[128];
strcpy(title, getmsg(&gMiscMessageList, &messageListItem, 7));
showDialogBox(title, nullptr, 0, 192, 116, _colorTable[32328], nullptr, _colorTable[32328], 0);
showDialogBox(title, NULL, 0, 192, 116, _colorTable[32328], NULL, _colorTable[32328], 0);
} else {
soundPlayFile("ib1p1xx1");
pipboyOpen(PIPBOY_OPEN_INTENT_REST);
@@ -1047,18 +1032,18 @@ int globalVarsRead(const char* path, const char* section, int* variablesListLeng
_inven_reset_dude();
File* stream = fileOpen(path, "rt");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
if (*variablesListLengthPtr != 0) {
internal_free(*variablesListPtr);
*variablesListPtr = nullptr;
*variablesListPtr = NULL;
*variablesListLengthPtr = 0;
}
char string[260];
if (section != nullptr) {
if (section != NULL) {
while (fileReadString(string, 258, stream)) {
if (strncmp(string, section, 16) == 0) {
break;
@@ -1076,19 +1061,19 @@ int globalVarsRead(const char* path, const char* section, int* variablesListLeng
}
char* semicolon = strchr(string, ';');
if (semicolon != nullptr) {
if (semicolon != NULL) {
*semicolon = '\0';
}
*variablesListLengthPtr = *variablesListLengthPtr + 1;
*variablesListPtr = (int*)internal_realloc(*variablesListPtr, sizeof(int) * *variablesListLengthPtr);
if (*variablesListPtr == nullptr) {
if (*variablesListPtr == NULL) {
exit(1);
}
char* equals = strchr(string, '=');
if (equals != nullptr) {
if (equals != NULL) {
sscanf(equals + 1, "%d", *variablesListPtr + *variablesListLengthPtr - 1);
} else {
*variablesListPtr[*variablesListLengthPtr - 1] = 0;
@@ -1175,9 +1160,9 @@ static int gameTakeScreenshot(int width, int height, unsigned char* buffer, unsi
static void gameFreeGlobalVars()
{
gGameGlobalVarsLength = 0;
if (gGameGlobalVars != nullptr) {
if (gGameGlobalVars != NULL) {
internal_free(gGameGlobalVars);
gGameGlobalVars = nullptr;
gGameGlobalVars = NULL;
}
if (gGameGlobalPointers != nullptr) {
@@ -1208,7 +1193,7 @@ static void showHelp()
int win = windowCreate(helpWindowX, helpWindowY, HELP_SCREEN_WIDTH, HELP_SCREEN_HEIGHT, 0, WINDOW_HIDDEN | WINDOW_MOVE_ON_TOP);
if (win != -1) {
unsigned char* windowBuffer = windowGetBuffer(win);
if (windowBuffer != nullptr) {
if (windowBuffer != NULL) {
FrmImage backgroundFrmImage;
int backgroundFid = buildFid(OBJ_TYPE_INTERFACE, 297, 0, 0, 0);
if (backgroundFrmImage.lock(backgroundFid)) {
@@ -1295,7 +1280,7 @@ int showQuitConfirmationDialog()
MessageListItem messageListItem;
messageListItem.num = 0;
if (messageListGetItem(&gMiscMessageList, &messageListItem)) {
rc = showDialogBox(messageListItem.text, nullptr, 0, 169, 117, _colorTable[32328], nullptr, _colorTable[32328], DIALOG_BOX_YES_NO);
rc = showDialogBox(messageListItem.text, 0, 0, 169, 117, _colorTable[32328], NULL, _colorTable[32328], DIALOG_BOX_YES_NO);
if (rc != 0) {
_game_user_wants_to_quit = 2;
}
@@ -1328,17 +1313,17 @@ static int gameDbInit()
int patch_index;
char filename[COMPAT_MAX_PATH];
main_file_name = nullptr;
patch_file_name = nullptr;
main_file_name = NULL;
patch_file_name = NULL;
main_file_name = settings.system.master_dat_path.c_str();
if (*main_file_name == '\0') {
main_file_name = nullptr;
main_file_name = NULL;
}
patch_file_name = settings.system.master_patches_path.c_str();
if (*patch_file_name == '\0') {
patch_file_name = nullptr;
patch_file_name = NULL;
}
int master_db_handle = dbOpen(main_file_name, 0, patch_file_name, 1);
@@ -1349,12 +1334,12 @@ static int gameDbInit()
main_file_name = settings.system.critter_dat_path.c_str();
if (*main_file_name == '\0') {
main_file_name = nullptr;
main_file_name = NULL;
}
patch_file_name = settings.system.critter_patches_path.c_str();
if (*patch_file_name == '\0') {
patch_file_name = nullptr;
patch_file_name = NULL;
}
int critter_db_handle = dbOpen(main_file_name, 0, patch_file_name, 1);
@@ -1363,23 +1348,16 @@ static int gameDbInit()
return -1;
}
// SFALL: custom patch file name.
char* path_file_name_template = nullptr;
configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_PATCH_FILE, &path_file_name_template);
if (path_file_name_template == nullptr || *path_file_name_template == '\0') {
path_file_name_template = "patch%03d.dat";
}
for (patch_index = 0; patch_index < 1000; patch_index++) {
snprintf(filename, sizeof(filename), path_file_name_template, patch_index);
snprintf(filename, sizeof(filename), "patch%03d.dat", patch_index);
if (compat_access(filename, 0) == 0) {
dbOpen(filename, 0, nullptr, 1);
dbOpen(filename, 0, NULL, 1);
}
}
if (compat_access("f2_res.dat", 0) == 0) {
dbOpen("f2_res.dat", 0, nullptr, 1);
dbOpen("f2_res.dat", 0, NULL, 1);
}
return 0;
@@ -1403,7 +1381,7 @@ static void showSplash()
char filePath[64];
snprintf(filePath, sizeof(filePath), "%ssplash%d.rix", path, splash);
stream = fileOpen(filePath, "rb");
if (stream != nullptr) {
if (stream != NULL) {
break;
}
@@ -1414,12 +1392,12 @@ static void showSplash()
}
}
if (stream == nullptr) {
if (stream == NULL) {
return;
}
unsigned char* palette = reinterpret_cast<unsigned char*>(internal_malloc(768));
if (palette == nullptr) {
if (palette == NULL) {
fileClose(stream);
return;
}
@@ -1438,7 +1416,7 @@ static void showSplash()
fileRead(&height, sizeof(height), 1, stream);
unsigned char* data = reinterpret_cast<unsigned char*>(internal_malloc(width * height));
if (data == nullptr) {
if (data == NULL) {
internal_free(palette);
fileClose(stream);
return;
@@ -1483,7 +1461,7 @@ static void showSplash()
}
unsigned char* scaled = reinterpret_cast<unsigned char*>(internal_malloc(scaledWidth * scaledHeight));
if (scaled != nullptr) {
if (scaled != NULL) {
blitBufferToBufferStretch(data, width, height, width, scaled, scaledWidth, scaledHeight, scaledWidth);
int x = screenWidth > scaledWidth ? (screenWidth - scaledWidth) / 2 : 0;
@@ -1532,7 +1510,7 @@ int gameShowDeathDialog(const char* message)
int oldUserWantsToQuit = _game_user_wants_to_quit;
_game_user_wants_to_quit = 0;
int rc = showDialogBox(message, nullptr, 0, 169, 117, _colorTable[32328], nullptr, _colorTable[32328], DIALOG_BOX_LARGE);
int rc = showDialogBox(message, 0, 0, 169, 117, _colorTable[32328], NULL, _colorTable[32328], DIALOG_BOX_LARGE);
_game_user_wants_to_quit = oldUserWantsToQuit;
+3 -64
View File
@@ -1,17 +1,13 @@
#include "game_config.h"
#include "sfall_config.h"
#include <stdio.h>
#include <string.h>
#include "db.h"
#include "main.h"
#include "platform_compat.h"
namespace fallout {
static void gameConfigResolvePath(const char* section, const char* key);
// A flag indicating if [gGameConfig] was initialized.
//
// 0x5186D0
@@ -124,55 +120,15 @@ bool gameConfigInit(bool isMapper, int argc, char** argv)
configSetInt(&gGameConfig, GAME_CONFIG_MAPPER_KEY, GAME_CONFIG_SORT_SCRIPT_LIST_KEY, 0);
}
// CE: Detect alternative default music directory.
char alternativeMusicPath[COMPAT_MAX_PATH];
strcpy(alternativeMusicPath, "data\\sound\\music\\*.acm");
compat_windows_path_to_native(alternativeMusicPath);
compat_resolve_path(alternativeMusicPath);
char** acms;
int acmsLength = fileNameListInit(alternativeMusicPath, &acms, 0, 0);
if (acmsLength != -1) {
if (acmsLength > 0) {
configSetString(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_PATH1_KEY, "data\\sound\\music\\");
configSetString(&gGameConfig, GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_PATH2_KEY, "data\\sound\\music\\");
}
fileNameListFree(&acms, 0);
}
// SFALL: Custom config file name.
char* customConfigFileName = nullptr;
configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_CONFIG_FILE, &customConfigFileName);
const char* configFileName = customConfigFileName != nullptr && *customConfigFileName != '\0'
? customConfigFileName
: DEFAULT_GAME_CONFIG_FILE_NAME;
// Make `fallout2.cfg` file path.
char* executable = argv[0];
char* ch = strrchr(executable, '\\');
if (ch != nullptr) {
if (ch != NULL) {
*ch = '\0';
if (isMapper) {
snprintf(gGameConfigFilePath,
sizeof(gGameConfigFilePath),
"%s\\%s",
executable,
MAPPER_CONFIG_FILE_NAME);
} else {
snprintf(gGameConfigFilePath,
sizeof(gGameConfigFilePath),
"%s\\%s",
executable,
configFileName);
}
snprintf(gGameConfigFilePath, sizeof(gGameConfigFilePath), "%s\\%s", executable, GAME_CONFIG_FILE_NAME);
*ch = '\\';
} else {
if (isMapper) {
strcpy(gGameConfigFilePath, MAPPER_CONFIG_FILE_NAME);
} else {
strcpy(gGameConfigFilePath, configFileName);
}
strcpy(gGameConfigFilePath, GAME_CONFIG_FILE_NAME);
}
// Read contents of `fallout2.cfg` into config. The values from the file
@@ -183,15 +139,6 @@ bool gameConfigInit(bool isMapper, int argc, char** argv)
// whatever was loaded from `fallout2.cfg`.
configParseCommandLineArguments(&gGameConfig, argc, argv);
// CE: Normalize and resolve asset bundle paths.
gameConfigResolvePath(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_DAT_KEY);
gameConfigResolvePath(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_MASTER_PATCHES_KEY);
gameConfigResolvePath(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_CRITTER_DAT_KEY);
gameConfigResolvePath(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_CRITTER_PATCHES_KEY);
gameConfigResolvePath(GAME_CONFIG_SYSTEM_KEY, GAME_CONFIG_CRITTER_PATCHES_KEY);
gameConfigResolvePath(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_PATH1_KEY);
gameConfigResolvePath(GAME_CONFIG_SOUND_KEY, GAME_CONFIG_MUSIC_PATH2_KEY);
gGameConfigInitialized = true;
return true;
@@ -237,12 +184,4 @@ bool gameConfigExit(bool shouldSave)
return result;
}
static void gameConfigResolvePath(const char* section, const char* key)
{
char* path;
configGetString(&gGameConfig, section, key, &path);
compat_windows_path_to_native(path);
compat_resolve_path(path);
}
} // namespace fallout
+2 -2
View File
@@ -5,8 +5,8 @@
namespace fallout {
#define DEFAULT_GAME_CONFIG_FILE_NAME "fallout2.cfg"
#define MAPPER_CONFIG_FILE_NAME "mapper2.cfg"
// The file name of the main config file.
#define GAME_CONFIG_FILE_NAME "fallout2.cfg"
#define GAME_CONFIG_SYSTEM_KEY "system"
#define GAME_CONFIG_PREFERENCES_KEY "preferences"
+212 -210
View File
File diff suppressed because it is too large Load Diff
+4
View File
@@ -1,6 +1,9 @@
#include "game_memory.h"
#include "db.h"
#include "dictionary.h"
#include "memory.h"
#include "memory_defs.h"
#include "memory_manager.h"
namespace fallout {
@@ -12,6 +15,7 @@ static void gameMemoryFree(void* ptr);
// 0x44B250
int gameMemoryInit()
{
dictionarySetMemoryProcs(internal_malloc, internal_realloc, internal_free);
memoryManagerSetProcs(gameMemoryMalloc, gameMemoryRealloc, gameMemoryFree);
return 0;
+131 -142
View File
@@ -104,7 +104,7 @@ static unsigned int _gmouse_3d_last_move_time = 0;
// actmenu.frm
// 0x518C8C
static Art* gGameMouseActionMenuFrm = nullptr;
static Art* gGameMouseActionMenuFrm = NULL;
// 0x518C90
static CacheEntry* gGameMouseActionMenuFrmHandle = INVALID_CACHE_ENTRY;
@@ -125,11 +125,11 @@ static int _gmouse_3d_menu_frame_hot_x = 0;
static int _gmouse_3d_menu_frame_hot_y = 0;
// 0x518CA8
static unsigned char* gGameMouseActionMenuFrmData = nullptr;
static unsigned char* gGameMouseActionMenuFrmData = NULL;
// actpick.frm
// 0x518CAC
static Art* gGameMouseActionPickFrm = nullptr;
static Art* gGameMouseActionPickFrm = NULL;
// 0x518CB0
static CacheEntry* gGameMouseActionPickFrmHandle = INVALID_CACHE_ENTRY;
@@ -150,11 +150,11 @@ static int _gmouse_3d_pick_frame_hot_x = 0;
static int _gmouse_3d_pick_frame_hot_y = 0;
// 0x518CC8
static unsigned char* gGameMouseActionPickFrmData = nullptr;
static unsigned char* gGameMouseActionPickFrmData = NULL;
// acttohit.frm
// 0x518CCC
static Art* gGameMouseActionHitFrm = nullptr;
static Art* gGameMouseActionHitFrm = NULL;
// 0x518CD0
static CacheEntry* gGameMouseActionHitFrmHandle = INVALID_CACHE_ENTRY;
@@ -169,11 +169,11 @@ static int gGameMouseActionHitFrmHeight = 0;
static int gGameMouseActionHitFrmDataSize = 0;
// 0x518CE0
static unsigned char* gGameMouseActionHitFrmData = nullptr;
static unsigned char* gGameMouseActionHitFrmData = NULL;
// blank.frm
// 0x518CE4
static Art* gGameMouseBouncingCursorFrm = nullptr;
static Art* gGameMouseBouncingCursorFrm = NULL;
// 0x518CE8
static CacheEntry* gGameMouseBouncingCursorFrmHandle = INVALID_CACHE_ENTRY;
@@ -188,11 +188,11 @@ static int gGameMouseBouncingCursorFrmHeight = 0;
static int gGameMouseBouncingCursorFrmDataSize = 0;
// 0x518CF8
static unsigned char* gGameMouseBouncingCursorFrmData = nullptr;
static unsigned char* gGameMouseBouncingCursorFrmData = NULL;
// msef000.frm
// 0x518CFC
static Art* gGameMouseHexCursorFrm = nullptr;
static Art* gGameMouseHexCursorFrm = NULL;
// 0x518D00
static CacheEntry* gGameMouseHexCursorFrmHandle = INVALID_CACHE_ENTRY;
@@ -207,13 +207,13 @@ static int gGameMouseHexCursorHeight = 0;
static int gGameMouseHexCursorDataSize = 0;
// 0x518D10
static unsigned char* gGameMouseHexCursorFrmData = nullptr;
static unsigned char* gGameMouseHexCursorFrmData = NULL;
// 0x518D14
static unsigned char gGameMouseActionMenuItemsLength = 0;
// 0x518D18
static unsigned char* _gmouse_3d_menu_actions_start = nullptr;
static unsigned char* _gmouse_3d_menu_actions_start = NULL;
// 0x518D1C
static unsigned char gGameMouseActionMenuHighlightedItemIndex = 0;
@@ -277,7 +277,7 @@ static int _gmouse_bk_last_cursor = -1;
static bool gGameMouseItemHighlightEnabled = true;
// 0x518D94
static Object* gGameMouseHighlightedItem = nullptr;
static Object* gGameMouseHighlightedItem = NULL;
// 0x518D98
bool _gmouse_clicked_on_edge = false;
@@ -318,7 +318,7 @@ static int gameMouseActionMenuInit();
static void gameMouseActionMenuFree();
static int gmouse_3d_set_flat_fid(int fid, Rect* rect);
static int gameMouseUpdateHexCursorFid(Rect* rect);
static int _gmouse_3d_move_to(int x, int y, int elevation, Rect* rect);
static int _gmouse_3d_move_to(int x, int y, int elevation, Rect* a4);
static int gameMouseHandleScrolling(int x, int y, int cursor);
static int objectIsDoor(Object* object);
static bool gameMouseClickOnInterfaceBar();
@@ -380,7 +380,7 @@ void gameMouseExit()
mouseHideCursor();
mouseSetFrame(nullptr, 0, 0, 0, 0, 0, 0);
mouseSetFrame(NULL, 0, 0, 0, 0, 0, 0);
// NOTE: Uninline.
gameMouseObjectsFree();
@@ -669,7 +669,7 @@ void gameMouseRefresh()
_gmouse_3d_hover_test = true;
Object* pointedObject = gameMouseGetObjectUnderCursor(-1, true, gElevation);
if (pointedObject != nullptr) {
if (pointedObject != NULL) {
int primaryAction = -1;
switch (FID_TYPE(pointedObject->fid)) {
@@ -732,14 +732,14 @@ void gameMouseRefresh()
}
} else if (gGameMouseMode == GAME_MOUSE_MODE_CROSSHAIR) {
Object* pointedObject = gameMouseGetObjectUnderCursor(OBJ_TYPE_CRITTER, false, gElevation);
if (pointedObject == nullptr) {
if (pointedObject == NULL) {
pointedObject = gameMouseGetObjectUnderCursor(-1, false, gElevation);
if (!objectIsDoor(pointedObject)) {
pointedObject = nullptr;
pointedObject = NULL;
}
}
if (pointedObject != nullptr) {
if (pointedObject != NULL) {
bool pointedObjectIsCritter = FID_TYPE(pointedObject->fid) == OBJ_TYPE_CRITTER;
if (settings.preferences.combat_looks) {
@@ -804,7 +804,7 @@ void gameMouseRefresh()
char formattedActionPoints[8];
int color;
int distance = _make_path(gDude, gDude->tile, gGameMouseHexCursor->tile, nullptr, 1);
int distance = _make_path(gDude, gDude->tile, gGameMouseHexCursor->tile, NULL, 1);
if (distance != 0) {
if (!isInCombat()) {
formattedActionPoints[0] = '\0';
@@ -856,11 +856,11 @@ void gameMouseRefresh()
v34 |= 1;
}
if (gGameMouseHighlightedItem != nullptr) {
if (gGameMouseHighlightedItem != NULL) {
if (objectClearOutline(gGameMouseHighlightedItem, &r26) == 0) {
v34 |= 2;
}
gGameMouseHighlightedItem = nullptr;
gGameMouseHighlightedItem = NULL;
}
switch (v34) {
@@ -950,46 +950,46 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
}
if (gGameMouseMode == GAME_MOUSE_MODE_ARROW) {
Object* targetObj = gameMouseGetObjectUnderCursor(-1, true, gElevation);
if (targetObj != nullptr) {
switch (FID_TYPE(targetObj->fid)) {
Object* v5 = gameMouseGetObjectUnderCursor(-1, true, gElevation);
if (v5 != NULL) {
switch (FID_TYPE(v5->fid)) {
case OBJ_TYPE_ITEM:
actionPickUp(gDude, targetObj);
actionPickUp(gDude, v5);
break;
case OBJ_TYPE_CRITTER:
if (targetObj == gDude) {
if (v5 == gDude) {
if (FID_ANIM_TYPE(gDude->fid) == ANIM_STAND) {
Rect dudeRect;
if (objectRotateClockwise(targetObj, &dudeRect) == 0) {
tileWindowRefreshRect(&dudeRect, targetObj->elevation);
Rect a1;
if (objectRotateClockwise(v5, &a1) == 0) {
tileWindowRefreshRect(&a1, v5->elevation);
}
}
} else {
if (_obj_action_can_talk_to(targetObj)) {
if (_obj_action_can_talk_to(v5)) {
if (isInCombat()) {
if (_obj_examine(gDude, targetObj) == -1) {
_obj_look_at(gDude, targetObj);
if (_obj_examine(gDude, v5) == -1) {
_obj_look_at(gDude, v5);
}
} else {
actionTalk(gDude, targetObj);
actionTalk(gDude, v5);
}
} else {
_action_loot_container(gDude, targetObj);
_action_loot_container(gDude, v5);
}
}
break;
case OBJ_TYPE_SCENERY:
if (_obj_action_can_use(targetObj)) {
_action_use_an_object(gDude, targetObj);
if (_obj_action_can_use(v5)) {
_action_use_an_object(gDude, v5);
} else {
if (_obj_examine(gDude, targetObj) == -1) {
_obj_look_at(gDude, targetObj);
if (_obj_examine(gDude, v5) == -1) {
_obj_look_at(gDude, v5);
}
}
break;
case OBJ_TYPE_WALL:
if (_obj_examine(gDude, targetObj) == -1) {
_obj_look_at(gDude, targetObj);
if (_obj_examine(gDude, v5) == -1) {
_obj_look_at(gDude, v5);
}
break;
}
@@ -998,16 +998,16 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
}
if (gGameMouseMode == GAME_MOUSE_MODE_CROSSHAIR) {
Object* targetObj = gameMouseGetObjectUnderCursor(OBJ_TYPE_CRITTER, false, gElevation);
if (targetObj == nullptr) {
targetObj = gameMouseGetObjectUnderCursor(-1, false, gElevation);
if (!objectIsDoor(targetObj)) {
targetObj = nullptr;
Object* v7 = gameMouseGetObjectUnderCursor(OBJ_TYPE_CRITTER, false, gElevation);
if (v7 == NULL) {
v7 = gameMouseGetObjectUnderCursor(-1, false, gElevation);
if (!objectIsDoor(v7)) {
v7 = NULL;
}
}
if (targetObj != nullptr) {
_combat_attack_this(targetObj);
if (v7 != NULL) {
_combat_attack_this(v7);
_gmouse_3d_hover_test = true;
gGameMouseLastY = mouseY;
gGameMouseLastX = mouseX;
@@ -1018,7 +1018,7 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
if (gGameMouseMode == GAME_MOUSE_MODE_USE_CROSSHAIR) {
Object* object = gameMouseGetObjectUnderCursor(-1, true, gElevation);
if (object != nullptr) {
if (object != NULL) {
Object* weapon;
if (interfaceGetActiveItem(&weapon) != -1) {
if (isInCombat()) {
@@ -1056,7 +1056,7 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
|| gGameMouseMode == GAME_MOUSE_MODE_USE_SCIENCE
|| gGameMouseMode == GAME_MOUSE_MODE_USE_REPAIR) {
Object* object = gameMouseGetObjectUnderCursor(-1, 1, gElevation);
if (object == nullptr || actionUseSkill(gDude, object, gGameMouseModeSkills[gGameMouseMode - FIRST_GAME_MOUSE_MODE_SKILL]) != -1) {
if (object == NULL || actionUseSkill(gDude, object, gGameMouseModeSkills[gGameMouseMode - FIRST_GAME_MOUSE_MODE_SKILL]) != -1) {
gameMouseSetCursor(MOUSE_CURSOR_NONE);
gameMouseSetMode(GAME_MOUSE_MODE_MOVE);
}
@@ -1065,35 +1065,35 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
}
if ((mouseState & MOUSE_EVENT_LEFT_BUTTON_DOWN_REPEAT) == MOUSE_EVENT_LEFT_BUTTON_DOWN_REPEAT && gGameMouseMode == GAME_MOUSE_MODE_ARROW) {
Object* targetObj = gameMouseGetObjectUnderCursor(-1, true, gElevation);
if (targetObj != nullptr) {
Object* v16 = gameMouseGetObjectUnderCursor(-1, true, gElevation);
if (v16 != NULL) {
int actionMenuItemsCount = 0;
int actionMenuItems[6];
switch (FID_TYPE(targetObj->fid)) {
switch (FID_TYPE(v16->fid)) {
case OBJ_TYPE_ITEM:
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_USE;
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_LOOK;
if (itemGetType(targetObj) == ITEM_TYPE_CONTAINER) {
if (itemGetType(v16) == ITEM_TYPE_CONTAINER) {
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_INVENTORY;
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_USE_SKILL;
}
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_CANCEL;
break;
case OBJ_TYPE_CRITTER:
if (targetObj == gDude) {
if (v16 == gDude) {
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_ROTATE;
} else {
if (_obj_action_can_talk_to(targetObj)) {
if (_obj_action_can_talk_to(v16)) {
if (!isInCombat()) {
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_TALK;
}
} else {
if (!_critter_flag_check(targetObj->pid, CRITTER_NO_STEAL)) {
if (!_critter_flag_check(v16->pid, CRITTER_NO_STEAL)) {
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_USE;
}
}
if (actionCheckPush(gDude, targetObj)) {
if (actionCheckPush(gDude, v16)) {
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_PUSH;
}
}
@@ -1104,7 +1104,7 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_CANCEL;
break;
case OBJ_TYPE_SCENERY:
if (_obj_action_can_use(targetObj)) {
if (_obj_action_can_use(v16)) {
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_USE;
}
@@ -1115,7 +1115,7 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
break;
case OBJ_TYPE_WALL:
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_LOOK;
if (_obj_action_can_use(targetObj)) {
if (_obj_action_can_use(v16)) {
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_INVENTORY;
}
actionMenuItems[actionMenuItemsCount++] = GAME_MOUSE_ACTION_MENU_ITEM_CANCEL;
@@ -1123,14 +1123,14 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
}
if (gameMouseRenderActionMenuItems(mouseX, mouseY, actionMenuItems, actionMenuItemsCount, _scr_size.right - _scr_size.left + 1, _scr_size.bottom - _scr_size.top - 99) == 0) {
Rect cursorRect;
Rect v43;
int fid = buildFid(OBJ_TYPE_INTERFACE, 283, 0, 0, 0);
// NOTE: Uninline.
if (gmouse_3d_set_flat_fid(fid, &cursorRect) == 0 && _gmouse_3d_move_to(mouseX, mouseY, gElevation, &cursorRect) == 0) {
tileWindowRefreshRect(&cursorRect, gElevation);
if (gmouse_3d_set_flat_fid(fid, &v43) == 0 && _gmouse_3d_move_to(mouseX, mouseY, gElevation, &v43) == 0) {
tileWindowRefreshRect(&v43, gElevation);
isoDisable();
int newMouseY = mouseY;
int v33 = mouseY;
int actionIndex = 0;
while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_UP) == 0) {
sharedFpsLimiter.mark();
@@ -1141,21 +1141,21 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
actionMenuItems[actionIndex] = 0;
}
int updatedMouseX;
int updatedMouseY;
mouseGetPosition(&updatedMouseX, &updatedMouseY);
int v48;
int v47;
mouseGetPosition(&v48, &v47);
if (abs(updatedMouseY - newMouseY) > 10) {
if (newMouseY >= updatedMouseY) {
if (abs(v47 - v33) > 10) {
if (v33 >= v47) {
actionIndex -= 1;
} else {
actionIndex += 1;
}
if (gameMouseHighlightActionMenuItemAtIndex(actionIndex) == 0) {
tileWindowRefreshRect(&cursorRect, gElevation);
tileWindowRefreshRect(&v43, gElevation);
}
newMouseY = updatedMouseY;
v33 = v47;
}
renderPresent();
@@ -1169,39 +1169,39 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
gGameMouseLastY = mouseY;
_gmouse_3d_last_move_time = getTicks();
_mouse_set_position(mouseX, newMouseY);
_mouse_set_position(mouseX, v33);
if (gameMouseUpdateHexCursorFid(&cursorRect) == 0) {
tileWindowRefreshRect(&cursorRect, gElevation);
if (gameMouseUpdateHexCursorFid(&v43) == 0) {
tileWindowRefreshRect(&v43, gElevation);
}
switch (actionMenuItems[actionIndex]) {
case GAME_MOUSE_ACTION_MENU_ITEM_INVENTORY:
inventoryOpenUseItemOn(targetObj);
inventoryOpenUseItemOn(v16);
break;
case GAME_MOUSE_ACTION_MENU_ITEM_LOOK:
if (_obj_examine(gDude, targetObj) == -1) {
_obj_look_at(gDude, targetObj);
if (_obj_examine(gDude, v16) == -1) {
_obj_look_at(gDude, v16);
}
break;
case GAME_MOUSE_ACTION_MENU_ITEM_ROTATE:
if (objectRotateClockwise(targetObj, &cursorRect) == 0) {
tileWindowRefreshRect(&cursorRect, targetObj->elevation);
if (objectRotateClockwise(v16, &v43) == 0) {
tileWindowRefreshRect(&v43, v16->elevation);
}
break;
case GAME_MOUSE_ACTION_MENU_ITEM_TALK:
actionTalk(gDude, targetObj);
actionTalk(gDude, v16);
break;
case GAME_MOUSE_ACTION_MENU_ITEM_USE:
switch (FID_TYPE(targetObj->fid)) {
switch (FID_TYPE(v16->fid)) {
case OBJ_TYPE_SCENERY:
_action_use_an_object(gDude, targetObj);
_action_use_an_object(gDude, v16);
break;
case OBJ_TYPE_CRITTER:
_action_loot_container(gDude, targetObj);
_action_loot_container(gDude, v16);
break;
default:
actionPickUp(gDude, targetObj);
actionPickUp(gDude, v16);
break;
}
break;
@@ -1238,12 +1238,12 @@ void _gmouse_handle_event(int mouseX, int mouseY, int mouseState)
}
if (skill != -1) {
actionUseSkill(gDude, targetObj, skill);
actionUseSkill(gDude, v16, skill);
}
}
break;
case GAME_MOUSE_ACTION_MENU_ITEM_PUSH:
actionPush(gDude, targetObj);
actionPush(gDude, v16);
break;
}
}
@@ -1266,7 +1266,7 @@ int gameMouseSetCursor(int cursor)
CacheEntry* mouseCursorFrmHandle;
int fid = buildFid(OBJ_TYPE_INTERFACE, gGameMouseCursorFrmIds[cursor], 0, 0, 0);
Art* mouseCursorFrm = artLock(fid, &mouseCursorFrmHandle);
if (mouseCursorFrm == nullptr) {
if (mouseCursorFrm == NULL) {
return -1;
}
@@ -1328,12 +1328,6 @@ int gameMouseGetCursor()
return gGameMouseCursor;
}
// 0x44C9F0
void gmouse_set_mapper_mode(int mode)
{
_gmouse_mapper_mode = mode;
}
// 0x44C9F8
void _gmouse_3d_enable_modes()
{
@@ -1370,9 +1364,9 @@ void gameMouseSetMode(int mode)
int mouseY;
mouseGetPosition(&mouseX, &mouseY);
Rect cursorRect;
if (_gmouse_3d_move_to(mouseX, mouseY, gElevation, &cursorRect) == 0) {
rectUnion(&rect, &cursorRect, &rect);
Rect r2;
if (_gmouse_3d_move_to(mouseX, mouseY, gElevation, &r2) == 0) {
rectUnion(&rect, &r2, &rect);
}
int v5 = 0;
@@ -1386,13 +1380,13 @@ void gameMouseSetMode(int mode)
}
if (gGameMouseMode == 0) {
if (objectDisableOutline(gGameMouseHexCursor, &cursorRect) == 0) {
rectUnion(&rect, &cursorRect, &rect);
if (objectDisableOutline(gGameMouseHexCursor, &r2) == 0) {
rectUnion(&rect, &r2, &rect);
}
}
} else {
if (objectEnableOutline(gGameMouseHexCursor, &cursorRect) == 0) {
rectUnion(&rect, &cursorRect, &rect);
if (objectEnableOutline(gGameMouseHexCursor, &r2) == 0) {
rectUnion(&rect, &r2, &rect);
}
}
@@ -1426,7 +1420,7 @@ void gameMouseCycleMode()
if (isInCombat()) {
Object* item;
if (interfaceGetActiveItem(&item) == 0) {
if (item != nullptr && itemGetType(item) != ITEM_TYPE_WEAPON && mode == GAME_MOUSE_MODE_CROSSHAIR) {
if (item != NULL && itemGetType(item) != ITEM_TYPE_WEAPON && mode == GAME_MOUSE_MODE_CROSSHAIR) {
mode = GAME_MOUSE_MODE_MOVE;
}
}
@@ -1465,7 +1459,7 @@ int gameMouseSetBouncingCursorFid(int fid)
}
if (!_gmouse_mapper_mode) {
return objectSetFid(gGameMouseBouncingCursor, fid, nullptr);
return objectSetFid(gGameMouseBouncingCursor, fid, NULL);
}
int v1 = 0;
@@ -1620,7 +1614,7 @@ Object* gameMouseGetObjectUnderCursor(int objectType, bool a2, int elevation)
}
}
Object* v4 = nullptr;
Object* v4 = NULL;
if (!v13) {
ObjectWithFlags* entries;
int count = _obj_create_intersect_list(mouseX, mouseY, elevation, objectType, &entries);
@@ -1651,14 +1645,14 @@ int gameMouseRenderPrimaryAction(int x, int y, int menuItem, int width, int heig
CacheEntry* menuItemFrmHandle;
int menuItemFid = buildFid(OBJ_TYPE_INTERFACE, gGameMouseActionMenuItemFrmIds[menuItem], 0, 0, 0);
Art* menuItemFrm = artLock(menuItemFid, &menuItemFrmHandle);
if (menuItemFrm == nullptr) {
if (menuItemFrm == NULL) {
return -1;
}
CacheEntry* arrowFrmHandle;
int arrowFid = buildFid(OBJ_TYPE_INTERFACE, gGameMouseModeFrmIds[GAME_MOUSE_MODE_ARROW], 0, 0, 0);
Art* arrowFrm = artLock(arrowFid, &arrowFrmHandle);
if (arrowFrm == nullptr) {
if (arrowFrm == NULL) {
artUnlock(menuItemFrmHandle);
// FIXME: Why this is success?
return 0;
@@ -1733,11 +1727,11 @@ int _gmouse_3d_pick_frame_hot(int* a1, int* a2)
// 0x44D214
int gameMouseRenderActionMenuItems(int x, int y, const int* menuItems, int menuItemsLength, int width, int height)
{
_gmouse_3d_menu_actions_start = nullptr;
_gmouse_3d_menu_actions_start = NULL;
gGameMouseActionMenuHighlightedItemIndex = 0;
gGameMouseActionMenuItemsLength = 0;
if (menuItems == nullptr) {
if (menuItems == NULL) {
return -1;
}
@@ -1757,7 +1751,7 @@ int gameMouseRenderActionMenuItems(int x, int y, const int* menuItems, int menuI
int fid = buildFid(OBJ_TYPE_INTERFACE, frmId, 0, 0, 0);
menuItemFrms[index] = artLock(fid, &(menuItemFrmHandles[index]));
if (menuItemFrms[index] == nullptr) {
if (menuItemFrms[index] == NULL) {
while (--index >= 0) {
artUnlock(menuItemFrmHandles[index]);
}
@@ -1768,7 +1762,7 @@ int gameMouseRenderActionMenuItems(int x, int y, const int* menuItems, int menuI
int fid = buildFid(OBJ_TYPE_INTERFACE, gGameMouseModeFrmIds[GAME_MOUSE_MODE_ARROW], 0, 0, 0);
CacheEntry* arrowFrmHandle;
Art* arrowFrm = artLock(fid, &arrowFrmHandle);
if (arrowFrm == nullptr) {
if (arrowFrm == NULL) {
// FIXME: Unlock arts.
return -1;
}
@@ -1833,8 +1827,8 @@ int gameMouseRenderActionMenuItems(int x, int y, const int* menuItems, int menuI
gGameMouseActionMenuItemsLength = menuItemsLength;
_gmouse_3d_menu_actions_start = v58;
Sound* sound = soundEffectLoad("iaccuxx1", nullptr);
if (sound != nullptr) {
Sound* sound = soundEffectLoad("iaccuxx1", NULL);
if (sound != NULL) {
soundEffectPlay(sound);
}
@@ -1851,7 +1845,7 @@ int gameMouseHighlightActionMenuItemAtIndex(int menuItemIndex)
CacheEntry* handle;
int fid = buildFid(OBJ_TYPE_INTERFACE, gGameMouseActionMenuItemFrmIds[gGameMouseActionMenuItems[gGameMouseActionMenuHighlightedItemIndex]], 0, 0, 0);
Art* art = artLock(fid, &handle);
if (art == nullptr) {
if (art == NULL) {
return -1;
}
@@ -1863,7 +1857,7 @@ int gameMouseHighlightActionMenuItemAtIndex(int menuItemIndex)
fid = buildFid(OBJ_TYPE_INTERFACE, gGameMouseActionMenuItemFrmIds[gGameMouseActionMenuItems[menuItemIndex]] - 1, 0, 0, 0);
art = artLock(fid, &handle);
if (art == nullptr) {
if (art == NULL) {
return -1;
}
@@ -1882,7 +1876,7 @@ int gameMouseRenderAccuracy(const char* string, int color)
CacheEntry* crosshairFrmHandle;
int fid = buildFid(OBJ_TYPE_INTERFACE, gGameMouseModeFrmIds[GAME_MOUSE_MODE_CROSSHAIR], 0, 0, 0);
Art* crosshairFrm = artLock(fid, &crosshairFrmHandle);
if (crosshairFrm == nullptr) {
if (crosshairFrm == NULL) {
return -1;
}
@@ -1970,7 +1964,7 @@ int gameMouseObjectsInit()
return -1;
}
if (objectSetOutline(gGameMouseHexCursor, OUTLINE_PALETTED | OUTLINE_TYPE_2, nullptr) != 0) {
if (objectSetOutline(gGameMouseHexCursor, OUTLINE_PALETTED | OUTLINE_TYPE_2, NULL) != 0) {
return -1;
}
@@ -1990,7 +1984,7 @@ int gameMouseObjectsInit()
gGameMouseHexCursor->flags |= OBJECT_SHOOT_THRU;
gGameMouseHexCursor->flags |= OBJECT_NO_BLOCK;
_obj_toggle_flat(gGameMouseHexCursor, nullptr);
_obj_toggle_flat(gGameMouseHexCursor, NULL);
int x;
int y;
@@ -2044,8 +2038,8 @@ void gameMouseObjectsFree()
gGameMouseBouncingCursor->flags &= ~OBJECT_NO_SAVE;
gGameMouseHexCursor->flags &= ~OBJECT_NO_SAVE;
objectDestroy(gGameMouseBouncingCursor, nullptr);
objectDestroy(gGameMouseHexCursor, nullptr);
objectDestroy(gGameMouseBouncingCursor, NULL);
objectDestroy(gGameMouseHexCursor, NULL);
gGameMouseObjectsInitialized = false;
}
@@ -2059,35 +2053,35 @@ int gameMouseActionMenuInit()
// actmenu.frm - action menu
fid = buildFid(OBJ_TYPE_INTERFACE, 283, 0, 0, 0);
gGameMouseActionMenuFrm = artLock(fid, &gGameMouseActionMenuFrmHandle);
if (gGameMouseActionMenuFrm == nullptr) {
if (gGameMouseActionMenuFrm == NULL) {
goto err;
}
// actpick.frm - action pick
fid = buildFid(OBJ_TYPE_INTERFACE, 282, 0, 0, 0);
gGameMouseActionPickFrm = artLock(fid, &gGameMouseActionPickFrmHandle);
if (gGameMouseActionPickFrm == nullptr) {
if (gGameMouseActionPickFrm == NULL) {
goto err;
}
// acttohit.frm - action to hit
fid = buildFid(OBJ_TYPE_INTERFACE, 284, 0, 0, 0);
gGameMouseActionHitFrm = artLock(fid, &gGameMouseActionHitFrmHandle);
if (gGameMouseActionHitFrm == nullptr) {
if (gGameMouseActionHitFrm == NULL) {
goto err;
}
// blank.frm - used be mset000.frm for top of bouncing mouse cursor
fid = buildFid(OBJ_TYPE_INTERFACE, 0, 0, 0, 0);
gGameMouseBouncingCursorFrm = artLock(fid, &gGameMouseBouncingCursorFrmHandle);
if (gGameMouseBouncingCursorFrm == nullptr) {
if (gGameMouseBouncingCursorFrm == NULL) {
goto err;
}
// msef000.frm - hex mouse cursor
fid = buildFid(OBJ_TYPE_INTERFACE, 1, 0, 0, 0);
gGameMouseHexCursorFrm = artLock(fid, &gGameMouseHexCursorFrmHandle);
if (gGameMouseHexCursorFrm == nullptr) {
if (gGameMouseHexCursorFrm == NULL) {
goto err;
}
@@ -2134,35 +2128,35 @@ void gameMouseActionMenuFree()
if (gGameMouseBouncingCursorFrmHandle != INVALID_CACHE_ENTRY) {
artUnlock(gGameMouseBouncingCursorFrmHandle);
}
gGameMouseBouncingCursorFrm = nullptr;
gGameMouseBouncingCursorFrm = NULL;
gGameMouseBouncingCursorFrmHandle = INVALID_CACHE_ENTRY;
if (gGameMouseHexCursorFrmHandle != INVALID_CACHE_ENTRY) {
artUnlock(gGameMouseHexCursorFrmHandle);
}
gGameMouseHexCursorFrm = nullptr;
gGameMouseHexCursorFrm = NULL;
gGameMouseHexCursorFrmHandle = INVALID_CACHE_ENTRY;
if (gGameMouseActionHitFrmHandle != INVALID_CACHE_ENTRY) {
artUnlock(gGameMouseActionHitFrmHandle);
}
gGameMouseActionHitFrm = nullptr;
gGameMouseActionHitFrm = NULL;
gGameMouseActionHitFrmHandle = INVALID_CACHE_ENTRY;
if (gGameMouseActionMenuFrmHandle != INVALID_CACHE_ENTRY) {
artUnlock(gGameMouseActionMenuFrmHandle);
}
gGameMouseActionMenuFrm = nullptr;
gGameMouseActionMenuFrm = NULL;
gGameMouseActionMenuFrmHandle = INVALID_CACHE_ENTRY;
if (gGameMouseActionPickFrmHandle != INVALID_CACHE_ENTRY) {
artUnlock(gGameMouseActionPickFrmHandle);
}
gGameMouseActionPickFrm = nullptr;
gGameMouseActionPickFrm = NULL;
gGameMouseActionPickFrmHandle = INVALID_CACHE_ENTRY;
gGameMouseActionPickFrmData = nullptr;
gGameMouseActionPickFrmData = NULL;
gGameMouseActionPickFrmWidth = 0;
gGameMouseActionPickFrmHeight = 0;
gGameMouseActionPickFrmDataSize = 0;
@@ -2193,7 +2187,7 @@ int gameMouseUpdateHexCursorFid(Rect* rect)
}
// 0x44DF94
int _gmouse_3d_move_to(int x, int y, int elevation, Rect* rect)
int _gmouse_3d_move_to(int x, int y, int elevation, Rect* a4)
{
if (_gmouse_mapper_mode == 0) {
if (gGameMouseMode != GAME_MOUSE_MODE_MOVE) {
@@ -2201,7 +2195,7 @@ int _gmouse_3d_move_to(int x, int y, int elevation, Rect* rect)
int offsetY = 0;
CacheEntry* hexCursorFrmHandle;
Art* hexCursorFrm = artLock(gGameMouseHexCursor->fid, &hexCursorFrmHandle);
if (hexCursorFrm != nullptr) {
if (hexCursorFrm != NULL) {
artGetRotationOffsets(hexCursorFrm, 0, &offsetX, &offsetY);
int frameOffsetX;
@@ -2214,7 +2208,7 @@ int _gmouse_3d_move_to(int x, int y, int elevation, Rect* rect)
artUnlock(hexCursorFrmHandle);
}
_obj_move(gGameMouseHexCursor, x + offsetX, y + offsetY, elevation, rect);
_obj_move(gGameMouseHexCursor, x + offsetX, y + offsetY, elevation, a4);
} else {
int tile = tileFromScreenXY(x, y, 0);
if (tile != -1) {
@@ -2237,7 +2231,7 @@ int _gmouse_3d_move_to(int x, int y, int elevation, Rect* rect)
rectCopy(&rect1, &rect2);
}
rectCopy(rect, &rect1);
rectCopy(a4, &rect1);
}
}
}
@@ -2290,7 +2284,7 @@ int _gmouse_3d_move_to(int x, int y, int elevation, Rect* rect)
int offsetY = 0;
CacheEntry* hexCursorFrmHandle;
Art* hexCursorFrm = artLock(gGameMouseHexCursor->fid, &hexCursorFrmHandle);
if (hexCursorFrm != nullptr) {
if (hexCursorFrm != NULL) {
artGetRotationOffsets(hexCursorFrm, 0, &offsetX, &offsetY);
int frameOffsetX;
@@ -2323,7 +2317,7 @@ int _gmouse_3d_move_to(int x, int y, int elevation, Rect* rect)
}
if (v1) {
rectCopy(rect, &rect1);
rectCopy(a4, &rect1);
}
}
@@ -2419,19 +2413,19 @@ int gameMouseHandleScrolling(int x, int y, int cursor)
// 0x44E544
void _gmouse_remove_item_outline(Object* object)
{
if (gGameMouseHighlightedItem != nullptr && gGameMouseHighlightedItem == object) {
if (gGameMouseHighlightedItem != NULL && gGameMouseHighlightedItem == object) {
Rect rect;
if (objectClearOutline(object, &rect) == 0) {
tileWindowRefreshRect(&rect, gElevation);
}
gGameMouseHighlightedItem = nullptr;
gGameMouseHighlightedItem = NULL;
}
}
// 0x44E580
int objectIsDoor(Object* object)
{
if (object == nullptr) {
if (object == NULL) {
return false;
}
@@ -2464,9 +2458,4 @@ void gameMouseRefreshImmediately()
renderPresent();
}
Object* gmouse_get_outlined_object()
{
return gGameMouseHighlightedItem;
}
} // namespace fallout
-2
View File
@@ -86,7 +86,6 @@ void gameMouseRefresh();
void _gmouse_handle_event(int mouseX, int mouseY, int mouseState);
int gameMouseSetCursor(int cursor);
int gameMouseGetCursor();
void gmouse_set_mapper_mode(int mode);
void gameMouseSetMode(int a1);
int gameMouseGetMode();
void gameMouseCycleMode();
@@ -103,7 +102,6 @@ void gameMouseLoadItemHighlight();
void _gmouse_remove_item_outline(Object* object);
void gameMouseRefreshImmediately();
Object* gmouse_get_outlined_object();
} // namespace fallout
+10 -10
View File
@@ -54,18 +54,18 @@ static const char* gMovieFileNames[MOVIE_COUNT] = {
// 0x518DE4
static const char* gMoviePaletteFilePaths[MOVIE_COUNT] = {
nullptr,
NULL,
"art\\cuts\\introsub.pal",
"art\\cuts\\eldersub.pal",
nullptr,
NULL,
"art\\cuts\\artmrsub.pal",
nullptr,
nullptr,
nullptr,
NULL,
NULL,
NULL,
"art\\cuts\\artmrsub.pal",
nullptr,
nullptr,
nullptr,
NULL,
NULL,
NULL,
"art\\cuts\\artmrsub.pal",
"art\\cuts\\artmrsub.pal",
"art\\cuts\\artmrsub.pal",
@@ -210,7 +210,7 @@ int gameMoviePlay(int movie, int flags)
int oldFont;
if (subtitlesEnabled) {
const char* subtitlesPaletteFilePath;
if (gMoviePaletteFilePaths[movie] != nullptr) {
if (gMoviePaletteFilePaths[movie] != NULL) {
subtitlesPaletteFilePath = gMoviePaletteFilePaths[movie];
} else {
subtitlesPaletteFilePath = "art\\cuts\\subtitle.pal";
@@ -338,7 +338,7 @@ static char* gameMovieBuildSubtitlesFilePath(char* movieFilePath)
char* path = movieFilePath;
char* separator = strrchr(path, '\\');
if (separator != nullptr) {
if (separator != NULL) {
path = separator + 1;
}
+88 -100
View File
@@ -68,16 +68,16 @@ static bool gSoundEffectsEnabled = false;
static int _gsound_active_effect_counter;
// 0x518E50
static Sound* gBackgroundSound = nullptr;
static Sound* gBackgroundSound = NULL;
// 0x518E54
static Sound* gSpeechSound = nullptr;
static Sound* gSpeechSound = NULL;
// 0x518E58
static SoundEndCallback* gBackgroundSoundEndCallback = nullptr;
static SoundEndCallback* gBackgroundSoundEndCallback = NULL;
// 0x518E5C
static SoundEndCallback* gSpeechEndCallback = nullptr;
static SoundEndCallback* gSpeechEndCallback = NULL;
// 0x518E60
static char _snd_lookup_weapon_type[WEAPON_SOUND_EFFECT_COUNT] = {
@@ -107,10 +107,10 @@ static int _background_loop_requested = -1;
static char* _sound_sfx_path = _aSoundSfx;
// 0x518E78
static char* _sound_music_path1 = nullptr;
static char* _sound_music_path1 = _aSoundMusic_0;
// 0x518E7C
static char* _sound_music_path2 = nullptr;
static char* _sound_music_path2 = _aSoundMusic_0;
// 0x518E80
static char* _sound_speech_path = _aSoundSpeech_0;
@@ -391,9 +391,6 @@ int gameSoundExit()
audioFileExit();
audioExit();
internal_free(_sound_music_path1);
internal_free(_sound_music_path2);
gGameSoundInitialized = false;
return 0;
@@ -550,7 +547,7 @@ void backgroundSoundSetVolume(int volume)
}
if (gMusicEnabled) {
if (gBackgroundSound != nullptr) {
if (gBackgroundSound != NULL) {
soundSetVolume(gBackgroundSound, (int)(gMusicVolume * 0.94));
}
}
@@ -624,18 +621,18 @@ int backgroundSoundLoad(const char* fileName, int a2, int a3, int a4)
debugPrint("failed because sound could not be allocated.\n");
}
gBackgroundSound = nullptr;
gBackgroundSound = NULL;
return -1;
}
rc = soundSetFileIO(gBackgroundSound, audioFileOpen, audioFileClose, audioFileRead, nullptr, audioFileSeek, gameSoundFileTellNotImplemented, audioFileGetSize);
rc = soundSetFileIO(gBackgroundSound, audioFileOpen, audioFileClose, audioFileRead, NULL, audioFileSeek, gameSoundFileTellNotImplemented, audioFileGetSize);
if (rc != 0) {
if (gGameSoundDebugEnabled) {
debugPrint("failed because file IO could not be set for compression.\n");
}
soundDelete(gBackgroundSound);
gBackgroundSound = nullptr;
gBackgroundSound = NULL;
return -1;
}
@@ -647,7 +644,7 @@ int backgroundSoundLoad(const char* fileName, int a2, int a3, int a4)
}
soundDelete(gBackgroundSound);
gBackgroundSound = nullptr;
gBackgroundSound = NULL;
return -1;
}
@@ -665,7 +662,7 @@ int backgroundSoundLoad(const char* fileName, int a2, int a3, int a4)
}
soundDelete(gBackgroundSound);
gBackgroundSound = nullptr;
gBackgroundSound = NULL;
return -1;
}
@@ -678,13 +675,13 @@ int backgroundSoundLoad(const char* fileName, int a2, int a3, int a4)
}
soundDelete(gBackgroundSound);
gBackgroundSound = nullptr;
gBackgroundSound = NULL;
return -1;
}
}
rc = soundSetCallback(gBackgroundSound, backgroundSoundCallback, nullptr);
rc = soundSetCallback(gBackgroundSound, backgroundSoundCallback, NULL);
if (rc != SOUND_NO_ERROR) {
if (gGameSoundDebugEnabled) {
debugPrint("soundSetCallback failed for background sound\n");
@@ -707,7 +704,7 @@ int backgroundSoundLoad(const char* fileName, int a2, int a3, int a4)
}
soundDelete(gBackgroundSound);
gBackgroundSound = nullptr;
gBackgroundSound = NULL;
return -1;
}
@@ -732,7 +729,7 @@ int backgroundSoundLoad(const char* fileName, int a2, int a3, int a4)
}
soundDelete(gBackgroundSound);
gBackgroundSound = nullptr;
gBackgroundSound = NULL;
return -1;
}
@@ -756,13 +753,13 @@ void backgroundSoundDelete()
if (gGameSoundInitialized && gMusicEnabled && gBackgroundSound) {
if (_gsound_background_fade) {
if (_soundFade(gBackgroundSound, 2000, 0) == 0) {
gBackgroundSound = nullptr;
gBackgroundSound = NULL;
return;
}
}
soundDelete(gBackgroundSound);
gBackgroundSound = nullptr;
gBackgroundSound = NULL;
}
}
@@ -780,7 +777,7 @@ void backgroundSoundRestart(int value)
// 0x450B50
void backgroundSoundPause()
{
if (gBackgroundSound != nullptr) {
if (gBackgroundSound != NULL) {
soundPause(gBackgroundSound);
}
}
@@ -788,7 +785,7 @@ void backgroundSoundPause()
// 0x450B64
void backgroundSoundResume()
{
if (gBackgroundSound != nullptr) {
if (gBackgroundSound != NULL) {
soundResume(gBackgroundSound);
}
}
@@ -841,7 +838,7 @@ void speechSetVolume(int volume)
gSpeechVolume = volume;
if (gSpeechEnabled) {
if (gSpeechSound != nullptr) {
if (gSpeechSound != NULL) {
soundSetVolume(gSpeechSound, (int)(volume * 0.69));
}
}
@@ -897,16 +894,16 @@ int speechLoad(const char* fname, int a2, int a3, int a4)
if (gGameSoundDebugEnabled) {
debugPrint("failed because sound could not be allocated.\n");
}
gSpeechSound = nullptr;
gSpeechSound = NULL;
return -1;
}
if (soundSetFileIO(gSpeechSound, audioOpen, audioClose, audioRead, nullptr, audioSeek, gameSoundFileTellNotImplemented, audioGetSize)) {
if (soundSetFileIO(gSpeechSound, audioOpen, audioClose, audioRead, NULL, audioSeek, gameSoundFileTellNotImplemented, audioGetSize)) {
if (gGameSoundDebugEnabled) {
debugPrint("failed because file IO could not be set for compression.\n");
}
soundDelete(gSpeechSound);
gSpeechSound = nullptr;
gSpeechSound = NULL;
return -1;
}
@@ -915,7 +912,7 @@ int speechLoad(const char* fname, int a2, int a3, int a4)
debugPrint("failed because the file could not be found.\n");
}
soundDelete(gSpeechSound);
gSpeechSound = nullptr;
gSpeechSound = NULL;
return -1;
}
@@ -925,12 +922,12 @@ int speechLoad(const char* fname, int a2, int a3, int a4)
debugPrint("failed because looping could not be set.\n");
}
soundDelete(gSpeechSound);
gSpeechSound = nullptr;
gSpeechSound = NULL;
return -1;
}
}
if (soundSetCallback(gSpeechSound, speechCallback, nullptr)) {
if (soundSetCallback(gSpeechSound, speechCallback, NULL)) {
if (gGameSoundDebugEnabled) {
debugPrint("soundSetCallback failed for speech sound\n");
}
@@ -949,7 +946,7 @@ int speechLoad(const char* fname, int a2, int a3, int a4)
debugPrint("failed on call to soundLoad.\n");
}
soundDelete(gSpeechSound);
gSpeechSound = nullptr;
gSpeechSound = NULL;
return -1;
}
@@ -970,7 +967,7 @@ int speechLoad(const char* fname, int a2, int a3, int a4)
debugPrint("failed starting to play.\n");
}
soundDelete(gSpeechSound);
gSpeechSound = nullptr;
gSpeechSound = NULL;
return -1;
}
@@ -992,7 +989,7 @@ int _gsound_speech_play_preloaded()
return -1;
}
if (gSpeechSound == nullptr) {
if (gSpeechSound == NULL) {
return -1;
}
@@ -1010,7 +1007,7 @@ int _gsound_speech_play_preloaded()
if (speechPlay() != 0) {
soundDelete(gSpeechSound);
gSpeechSound = nullptr;
gSpeechSound = NULL;
return -1;
}
@@ -1022,9 +1019,9 @@ int _gsound_speech_play_preloaded()
void speechDelete()
{
if (gGameSoundInitialized && gSpeechEnabled) {
if (gSpeechSound != nullptr) {
if (gSpeechSound != NULL) {
soundDelete(gSpeechSound);
gSpeechSound = nullptr;
gSpeechSound = NULL;
}
}
}
@@ -1032,7 +1029,7 @@ void speechDelete()
// 0x451054
void speechPause()
{
if (gSpeechSound != nullptr) {
if (gSpeechSound != NULL) {
soundPause(gSpeechSound);
}
}
@@ -1040,7 +1037,7 @@ void speechPause()
// 0x451068
void speechResume()
{
if (gSpeechSound != nullptr) {
if (gSpeechSound != NULL) {
soundResume(gSpeechSound);
}
}
@@ -1058,8 +1055,8 @@ int _gsound_play_sfx_file_volume(const char* a1, int a2)
return -1;
}
v1 = soundEffectLoadWithVolume(a1, nullptr, a2);
if (v1 == nullptr) {
v1 = soundEffectLoadWithVolume(a1, NULL, a2);
if (v1 == NULL) {
return -1;
}
@@ -1072,11 +1069,11 @@ int _gsound_play_sfx_file_volume(const char* a1, int a2)
Sound* soundEffectLoad(const char* name, Object* object)
{
if (!gGameSoundInitialized) {
return nullptr;
return NULL;
}
if (!gSoundEffectsEnabled) {
return nullptr;
return NULL;
}
if (gGameSoundDebugEnabled) {
@@ -1088,16 +1085,16 @@ Sound* soundEffectLoad(const char* name, Object* object)
debugPrint("failed because there are already %d active effects.\n", _gsound_active_effect_counter);
}
return nullptr;
return NULL;
}
Sound* sound = _gsound_get_sound_ready_for_effect();
if (sound == nullptr) {
if (sound == NULL) {
if (gGameSoundDebugEnabled) {
debugPrint("failed.\n");
}
return nullptr;
return NULL;
}
++_gsound_active_effect_counter;
@@ -1113,7 +1110,7 @@ Sound* soundEffectLoad(const char* name, Object* object)
return sound;
}
if (object != nullptr) {
if (object != NULL) {
if (FID_TYPE(object->fid) == OBJ_TYPE_CRITTER && (name[0] == 'H' || name[0] == 'N')) {
char v9 = name[1];
if (v9 == 'A' || v9 == 'F' || v9 == 'M') {
@@ -1182,7 +1179,7 @@ Sound* soundEffectLoad(const char* name, Object* object)
debugPrint("failed.\n");
}
return nullptr;
return NULL;
}
// 0x45145C
@@ -1190,7 +1187,7 @@ Sound* soundEffectLoadWithVolume(const char* name, Object* object, int volume)
{
Sound* sound = soundEffectLoad(name, object);
if (sound != nullptr) {
if (sound != NULL) {
soundSetVolume(sound, (volume * gSoundEffectsVolume) / VOLUME_MAX);
}
@@ -1236,7 +1233,7 @@ int _gsnd_anim_sound(Sound* sound, void* a2)
return 0;
}
if (sound == nullptr) {
if (sound == NULL) {
return 0;
}
@@ -1256,7 +1253,7 @@ int soundEffectPlay(Sound* sound)
return -1;
}
if (sound == nullptr) {
if (sound == NULL) {
return -1;
}
@@ -1322,16 +1319,16 @@ char* sfxBuildCharName(Object* a1, int anim, int extra)
char v9;
if (artCopyFileName(FID_TYPE(a1->fid), a1->fid & 0xFFF, v7) == -1) {
return nullptr;
return NULL;
}
if (anim == ANIM_TAKE_OUT) {
if (_art_get_code(anim, extra, &v8, &v9) == -1) {
return nullptr;
return NULL;
}
} else {
if (_art_get_code(anim, (a1->fid & 0xF000) >> 12, &v8, &v9) == -1) {
return nullptr;
return NULL;
}
}
@@ -1373,7 +1370,7 @@ char* gameSoundBuildInterfaceName(const char* a1)
// 0x451760
char* sfxBuildWeaponName(int effectType, Object* weapon, int hitMode, Object* target)
{
int soundVariant;
int v6;
char weaponSoundCode;
char effectTypeCode;
char materialCode;
@@ -1387,18 +1384,18 @@ char* sfxBuildWeaponName(int effectType, Object* weapon, int hitMode, Object* ta
if (hitMode != HIT_MODE_LEFT_WEAPON_PRIMARY
&& hitMode != HIT_MODE_RIGHT_WEAPON_PRIMARY
&& hitMode != HIT_MODE_PUNCH) {
soundVariant = 2;
v6 = 2;
} else {
soundVariant = 1;
v6 = 1;
}
} else {
soundVariant = 1;
v6 = 1;
}
int damageType = weaponGetDamageType(nullptr, weapon);
int damageType = weaponGetDamageType(NULL, weapon);
// SFALL
if (effectTypeCode != 'H' || target == nullptr || damageType == explosionGetDamageType() || damageType == DAMAGE_TYPE_PLASMA || damageType == DAMAGE_TYPE_EMP) {
if (effectTypeCode != 'H' || target == NULL || damageType == explosionGetDamageType() || damageType == DAMAGE_TYPE_PLASMA || damageType == DAMAGE_TYPE_EMP) {
materialCode = 'X';
} else {
const int type = FID_TYPE(target->fid);
@@ -1441,7 +1438,7 @@ char* sfxBuildWeaponName(int effectType, Object* weapon, int hitMode, Object* ta
}
}
snprintf(_sfx_file_name, sizeof(_sfx_file_name), "W%c%c%1d%cXX%1d", effectTypeCode, weaponSoundCode, soundVariant, materialCode, 1);
snprintf(_sfx_file_name, sizeof(_sfx_file_name), "W%c%c%1d%cXX%1d", effectTypeCode, weaponSoundCode, v6, materialCode, 1);
compat_strupr(_sfx_file_name);
return _sfx_file_name;
}
@@ -1534,8 +1531,8 @@ int soundPlayFile(const char* name)
return -1;
}
Sound* sound = soundEffectLoad(name, nullptr);
if (sound == nullptr) {
Sound* sound = soundEffectLoad(name, NULL);
if (sound == NULL) {
return -1;
}
@@ -1554,7 +1551,7 @@ void _gsound_bkg_proc()
int gameSoundFileOpen(const char* fname, int* sampleRate)
{
File* stream = fileOpen(fname, "rb");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -1650,7 +1647,7 @@ bool gameSoundIsCompressed(char* filePath)
void speechCallback(void* userData, int a2)
{
if (a2 == 1) {
gSpeechSound = nullptr;
gSpeechSound = NULL;
if (gSpeechEndCallback) {
gSpeechEndCallback();
@@ -1662,7 +1659,7 @@ void speechCallback(void* userData, int a2)
void backgroundSoundCallback(void* userData, int a2)
{
if (a2 == 1) {
gBackgroundSound = nullptr;
gBackgroundSound = NULL;
if (gBackgroundSoundEndCallback) {
gBackgroundSoundEndCallback();
@@ -1696,7 +1693,7 @@ int _gsound_background_allocate(Sound** soundPtr, int a2, int a3)
}
Sound* sound = soundAllocate(type, soundFlags);
if (sound == nullptr) {
if (sound == NULL) {
return -1;
}
@@ -1740,7 +1737,7 @@ int gameSoundFindBackgroundSoundPathWithCopy(char* dest, const char* src)
snprintf(inPath, sizeof(inPath), "%s%s%s", _sound_music_path2, src, ".ACM");
FILE* inStream = compat_fopen(inPath, "rb");
if (inStream == nullptr) {
if (inStream == NULL) {
if (gGameSoundDebugEnabled) {
debugPrint("Unable to find music file %s to copy down.\n", src);
}
@@ -1749,7 +1746,7 @@ int gameSoundFindBackgroundSoundPathWithCopy(char* dest, const char* src)
}
FILE* outStream = compat_fopen(outPath, "wb");
if (outStream == nullptr) {
if (outStream == NULL) {
if (gGameSoundDebugEnabled) {
debugPrint("Unable to open music file %s for copying to.", src);
}
@@ -1760,7 +1757,7 @@ int gameSoundFindBackgroundSoundPathWithCopy(char* dest, const char* src)
}
void* buffer = internal_malloc(0x2000);
if (buffer == nullptr) {
if (buffer == NULL) {
if (gGameSoundDebugEnabled) {
debugPrint("Out of memory in gsound_background_find_with_copy.\n", src);
}
@@ -1960,20 +1957,17 @@ int _gsound_get_music_path(char** out_value, const char* key)
char* copy;
char* value;
if (!configGetString(&gGameConfig, GAME_CONFIG_SOUND_KEY, key, &value)) {
*out_value = internal_strdup(_aSoundMusic_0);
return 0;
}
configGetString(&gGameConfig, GAME_CONFIG_SOUND_KEY, key, out_value);
value = *out_value;
len = strlen(value);
if (value[len - 1] == '\\' || value[len - 1] == '/') {
*out_value = internal_strdup(value);
return 0;
}
copy = (char*)internal_malloc(len + 2);
if (copy == nullptr) {
if (copy == NULL) {
if (gGameSoundDebugEnabled) {
debugPrint("Out of memory in gsound_get_music_path.\n");
}
@@ -1984,9 +1978,7 @@ int _gsound_get_music_path(char** out_value, const char* key)
copy[len] = '\\';
copy[len + 1] = '\0';
if (!configSetString(&gGameConfig, GAME_CONFIG_SOUND_KEY, key, copy)) {
internal_free(copy);
if (configSetString(&gGameConfig, GAME_CONFIG_SOUND_KEY, key, copy) != 1) {
if (gGameSoundDebugEnabled) {
debugPrint("config_set_string failed in gsound_music_path.\n");
}
@@ -1994,20 +1986,16 @@ int _gsound_get_music_path(char** out_value, const char* key)
return -1;
}
if (!configGetString(&gGameConfig, GAME_CONFIG_SOUND_KEY, key, &value)) {
if (configGetString(&gGameConfig, GAME_CONFIG_SOUND_KEY, key, out_value)) {
internal_free(copy);
if (gGameSoundDebugEnabled) {
debugPrint("config_get_string failed in gsound_music_path.\n");
}
return -1;
return 0;
}
internal_free(copy);
if (gGameSoundDebugEnabled) {
debugPrint("config_get_string failed in gsound_music_path.\n");
}
*out_value = internal_strdup(value);
return 0;
return -1;
}
// 0x452378
@@ -2016,7 +2004,7 @@ Sound* _gsound_get_sound_ready_for_effect()
int rc;
Sound* sound = soundAllocate(SOUND_TYPE_MEMORY | SOUND_TYPE_FIRE_AND_FORGET, SOUND_FLAG_0x02 | SOUND_16BIT);
if (sound == nullptr) {
if (sound == NULL) {
if (gGameSoundDebugEnabled) {
debugPrint(" Can't allocate sound for effect. ");
}
@@ -2025,13 +2013,13 @@ Sound* _gsound_get_sound_ready_for_effect()
debugPrint("soundAllocate returned: %d, %s\n", 0, soundGetErrorDescription(0));
}
return nullptr;
return NULL;
}
if (soundEffectsCacheInitialized()) {
rc = soundSetFileIO(sound, soundEffectsCacheFileOpen, soundEffectsCacheFileClose, soundEffectsCacheFileRead, soundEffectsCacheFileWrite, soundEffectsCacheFileSeek, soundEffectsCacheFileTell, soundEffectsCacheFileLength);
} else {
rc = soundSetFileIO(sound, audioOpen, audioClose, audioRead, nullptr, audioSeek, gameSoundFileTellNotImplemented, audioGetSize);
rc = soundSetFileIO(sound, audioOpen, audioClose, audioRead, NULL, audioSeek, gameSoundFileTellNotImplemented, audioGetSize);
}
if (rc != 0) {
@@ -2045,10 +2033,10 @@ Sound* _gsound_get_sound_ready_for_effect()
soundDelete(sound);
return nullptr;
return NULL;
}
rc = soundSetCallback(sound, soundEffectCallback, nullptr);
rc = soundSetCallback(sound, soundEffectCallback, NULL);
if (rc != 0) {
if (gGameSoundDebugEnabled) {
debugPrint("failed because the callback could not be set.\n");
@@ -2060,7 +2048,7 @@ Sound* _gsound_get_sound_ready_for_effect()
soundDelete(sound);
return nullptr;
return NULL;
}
soundSetVolume(sound, gSoundEffectsVolume);
@@ -2074,7 +2062,7 @@ Sound* _gsound_get_sound_ready_for_effect()
bool _gsound_file_exists_f(const char* fname)
{
FILE* f = compat_fopen(fname, "rb");
if (f == nullptr) {
if (f == NULL) {
return false;
}
@@ -2095,17 +2083,17 @@ int _gsound_setup_paths()
// 0x452628
int _gsound_sfx_q_start()
{
return ambientSoundEffectEventProcess(nullptr, nullptr);
return ambientSoundEffectEventProcess(0, NULL);
}
// 0x452634
int ambientSoundEffectEventProcess(Object* a1, void* data)
{
_queue_clear_type(EVENT_TYPE_GSOUND_SFX_EVENT, nullptr);
_queue_clear_type(EVENT_TYPE_GSOUND_SFX_EVENT, NULL);
AmbientSoundEffectEvent* soundEffectEvent = (AmbientSoundEffectEvent*)data;
int ambientSoundEffectIndex = -1;
if (soundEffectEvent != nullptr) {
if (soundEffectEvent != NULL) {
ambientSoundEffectIndex = soundEffectEvent->ambientSoundEffectIndex;
} else {
if (wmSfxMaxCount() > 0) {
@@ -2114,7 +2102,7 @@ int ambientSoundEffectEventProcess(Object* a1, void* data)
}
AmbientSoundEffectEvent* nextSoundEffectEvent = (AmbientSoundEffectEvent*)internal_malloc(sizeof(*nextSoundEffectEvent));
if (nextSoundEffectEvent == nullptr) {
if (nextSoundEffectEvent == NULL) {
return -1;
}
@@ -2125,7 +2113,7 @@ int ambientSoundEffectEventProcess(Object* a1, void* data)
int delay = 10 * randomBetween(15, 20);
if (wmSfxMaxCount() > 0) {
nextSoundEffectEvent->ambientSoundEffectIndex = wmSfxRollNextIdx();
if (queueAddEvent(delay, nullptr, nextSoundEffectEvent, EVENT_TYPE_GSOUND_SFX_EVENT) == -1) {
if (queueAddEvent(delay, NULL, nextSoundEffectEvent, EVENT_TYPE_GSOUND_SFX_EVENT) == -1) {
return -1;
}
}
+11 -67
View File
@@ -9,12 +9,12 @@
namespace fallout {
// 0x51DEF4
static RectListNode* _rectList = nullptr;
static RectListNode* _rectList = NULL;
// 0x4C6900
void _GNW_rect_exit()
{
while (_rectList != nullptr) {
while (_rectList != NULL) {
RectListNode* next = _rectList->next;
internal_free(_rectList);
_rectList = next;
@@ -28,7 +28,7 @@ void _rect_clip_list(RectListNode** rectListNodePtr, Rect* rect)
rectCopy(&v1, rect);
// NOTE: Original code is slightly different.
while (*rectListNodePtr != nullptr) {
while (*rectListNodePtr != NULL) {
RectListNode* rectListNode = *rectListNodePtr;
if (v1.right >= rectListNode->rect.left
&& v1.bottom >= rectListNode->rect.top
@@ -44,7 +44,7 @@ void _rect_clip_list(RectListNode** rectListNodePtr, Rect* rect)
if (v2.top < v1.top) {
RectListNode* newRectListNode = _rect_malloc();
if (newRectListNode == nullptr) {
if (newRectListNode == NULL) {
return;
}
@@ -60,7 +60,7 @@ void _rect_clip_list(RectListNode** rectListNodePtr, Rect* rect)
if (v2.bottom > v1.bottom) {
RectListNode* newRectListNode = _rect_malloc();
if (newRectListNode == nullptr) {
if (newRectListNode == NULL) {
return;
}
@@ -76,7 +76,7 @@ void _rect_clip_list(RectListNode** rectListNodePtr, Rect* rect)
if (v2.left < v1.left) {
RectListNode* newRectListNode = _rect_malloc();
if (newRectListNode == nullptr) {
if (newRectListNode == NULL) {
return;
}
@@ -90,7 +90,7 @@ void _rect_clip_list(RectListNode** rectListNodePtr, Rect* rect)
if (v2.right > v1.right) {
RectListNode* newRectListNode = _rect_malloc();
if (newRectListNode == nullptr) {
if (newRectListNode == NULL) {
return;
}
@@ -107,69 +107,13 @@ void _rect_clip_list(RectListNode** rectListNodePtr, Rect* rect)
}
}
// 0x4C6AAC
RectListNode* rect_clip(Rect* b, Rect* t)
{
RectListNode* list = nullptr;
Rect clipped_t;
if (rectIntersection(t, b, &clipped_t) == 0) {
RectListNode** next = &list;
Rect clipped_b[4];
int k;
clipped_b[0].left = b->left;
clipped_b[0].top = b->top;
clipped_b[0].right = b->right;
clipped_b[0].bottom = clipped_t.top - 1;
clipped_b[1].left = b->left;
clipped_b[1].top = clipped_t.top;
clipped_b[1].right = clipped_t.left - 1;
clipped_b[1].bottom = clipped_t.bottom;
clipped_b[2].left = clipped_t.right + 1;
clipped_b[2].top = clipped_t.top;
clipped_b[2].right = b->right;
clipped_b[2].bottom = clipped_t.bottom;
clipped_b[3].left = b->left;
clipped_b[3].top = clipped_t.bottom + 1;
clipped_b[3].right = b->right;
clipped_b[3].bottom = b->bottom;
for (k = 0; k < 4; k++) {
if (clipped_b[k].left <= clipped_b[k].right && clipped_b[k].top <= clipped_b[k].bottom) {
*next = _rect_malloc();
if (*next == nullptr) {
return nullptr;
}
(*next)->rect = clipped_b[k];
(*next)->next = nullptr;
next = &((*next)->next);
}
}
} else {
list = _rect_malloc();
if (list == nullptr) {
return nullptr;
}
list->rect = *b;
list->next = nullptr;
}
return list;
}
// 0x4C6BB8
RectListNode* _rect_malloc()
{
if (_rectList == nullptr) {
if (_rectList == NULL) {
for (int index = 0; index < 10; index++) {
RectListNode* rectListNode = (RectListNode*)internal_malloc(sizeof(*rectListNode));
if (rectListNode == nullptr) {
if (rectListNode == NULL) {
break;
}
@@ -178,8 +122,8 @@ RectListNode* _rect_malloc()
}
}
if (_rectList == nullptr) {
return nullptr;
if (_rectList == NULL) {
return NULL;
}
RectListNode* rectListNode = _rectList;
-1
View File
@@ -27,7 +27,6 @@ typedef struct RectListNode {
void _GNW_rect_exit();
void _rect_clip_list(RectListNode** rectListNodePtr, Rect* rect);
RectListNode* rect_clip(Rect* b, Rect* t);
RectListNode* _rect_malloc();
void _rect_free(RectListNode* entry);
void rectUnion(const Rect* s1, const Rect* s2, Rect* r);
+10 -18
View File
@@ -52,21 +52,13 @@ unsigned char HighRGB(unsigned char color)
return std::max(std::max(r, g), b);
}
// 0x44ED98
int load_lbm_to_buf(const char* path, unsigned char* buffer, int a3, int a4, int a5, int a6, int a7)
{
// TODO: Incomplete.
return -1;
}
// 0x44F250
int graphCompress(unsigned char* a1, unsigned char* a2, int a3)
{
_dad_2 = nullptr;
_rson = nullptr;
_lson = nullptr;
_text_buf = nullptr;
_dad_2 = NULL;
_rson = NULL;
_lson = NULL;
_text_buf = NULL;
// NOTE: Original code is slightly different, it uses deep nesting or a
// bunch of gotos.
@@ -75,20 +67,20 @@ int graphCompress(unsigned char* a1, unsigned char* a2, int a3)
_dad_2 = (int*)internal_malloc(sizeof(*_dad_2) * 4104);
_text_buf = (unsigned char*)internal_malloc(sizeof(*_text_buf) * 4122);
if (_lson == nullptr || _rson == nullptr || _dad_2 == nullptr || _text_buf == nullptr) {
if (_lson == NULL || _rson == NULL || _dad_2 == NULL || _text_buf == NULL) {
debugPrint("\nGRAPHLIB: Error allocating compression buffers!\n");
if (_dad_2 != nullptr) {
if (_dad_2 != NULL) {
internal_free(_dad_2);
}
if (_rson != nullptr) {
if (_rson != NULL) {
internal_free(_rson);
}
if (_lson != nullptr) {
if (_lson != NULL) {
internal_free(_lson);
}
if (_text_buf != nullptr) {
if (_text_buf != NULL) {
internal_free(_text_buf);
}
@@ -355,7 +347,7 @@ static void _DeleteNode(int a1)
int graphDecompress(unsigned char* src, unsigned char* dest, int length)
{
_text_buf = (unsigned char*)internal_malloc(sizeof(*_text_buf) * 4122);
if (_text_buf == nullptr) {
if (_text_buf == NULL) {
debugPrint("\nGRAPHLIB: Error allocating decompression buffer!\n");
return -1;
}
-1
View File
@@ -4,7 +4,6 @@
namespace fallout {
unsigned char HighRGB(unsigned char color);
int load_lbm_to_buf(const char* path, unsigned char* buffer, int a3, int a4, int a5, int a6, int a7);
int graphCompress(unsigned char* a1, unsigned char* a2, int a3);
int graphDecompress(unsigned char* a1, unsigned char* a2, int a3);
void grayscalePaletteUpdate(int a1, int a2);
+40 -40
View File
@@ -85,23 +85,23 @@ static bool heapBuildMoveableBlocksList(int extentIndex);
// An array of pointers to free heap blocks.
//
// 0x518E9C
static unsigned char** gHeapFreeBlocks = nullptr;
static unsigned char** gHeapFreeBlocks = NULL;
// An array of moveable extents in heap.
//
// 0x518EA0
static HeapMoveableExtent* gHeapMoveableExtents = nullptr;
static HeapMoveableExtent* gHeapMoveableExtents = NULL;
// An array of pointers to moveable heap blocks.
//
// 0x518EA4
static unsigned char** gHeapMoveableBlocks = nullptr;
static unsigned char** gHeapMoveableBlocks = NULL;
// An array of indexes into [gHeapFreeBlocks] array to track which free blocks
// were already reserved for subsequent moving.
//
// 0x518EA8
static int* gHeapReservedFreeBlockIndexes = nullptr;
static int* gHeapReservedFreeBlockIndexes = NULL;
// The length of the [gHeapFreeBlocks] array.
//
@@ -139,26 +139,26 @@ static bool heapInternalsInit()
// it has failed.
do {
gHeapFreeBlocks = (unsigned char**)internal_malloc(sizeof(*gHeapFreeBlocks) * HEAP_FREE_BLOCKS_INITIAL_LENGTH);
if (gHeapFreeBlocks == nullptr) {
if (gHeapFreeBlocks == NULL) {
break;
}
gHeapFreeBlocksLength = HEAP_FREE_BLOCKS_INITIAL_LENGTH;
gHeapMoveableExtents = (HeapMoveableExtent*)internal_malloc(sizeof(*gHeapMoveableExtents) * HEAP_MOVEABLE_EXTENTS_INITIAL_LENGTH);
if (gHeapMoveableExtents == nullptr) {
if (gHeapMoveableExtents == NULL) {
break;
}
gHeapMoveableExtentsLength = HEAP_MOVEABLE_EXTENTS_INITIAL_LENGTH;
gHeapMoveableBlocks = (unsigned char**)internal_malloc(sizeof(*gHeapMoveableBlocks) * HEAP_MOVEABLE_BLOCKS_INITIAL_LENGTH);
if (gHeapMoveableBlocks == nullptr) {
if (gHeapMoveableBlocks == NULL) {
break;
}
gHeapMoveableBlocksLength = HEAP_MOVEABLE_BLOCKS_INITIAL_LENGTH;
gHeapReservedFreeBlockIndexes = (int*)internal_malloc(sizeof(*gHeapReservedFreeBlockIndexes) * HEAP_RESERVED_FREE_BLOCK_INDEXES_INITIAL_LENGTH);
if (gHeapReservedFreeBlockIndexes == nullptr) {
if (gHeapReservedFreeBlockIndexes == NULL) {
break;
}
gHeapReservedFreeBlockIndexesLength = HEAP_RESERVED_FREE_BLOCK_INDEXES_INITIAL_LENGTH;
@@ -175,27 +175,27 @@ static bool heapInternalsInit()
// 0x4533A0
static void heapInternalsFree()
{
if (gHeapReservedFreeBlockIndexes != nullptr) {
if (gHeapReservedFreeBlockIndexes != NULL) {
internal_free(gHeapReservedFreeBlockIndexes);
gHeapReservedFreeBlockIndexes = nullptr;
gHeapReservedFreeBlockIndexes = NULL;
}
gHeapReservedFreeBlockIndexesLength = 0;
if (gHeapMoveableBlocks != nullptr) {
if (gHeapMoveableBlocks != NULL) {
internal_free(gHeapMoveableBlocks);
gHeapMoveableBlocks = nullptr;
gHeapMoveableBlocks = NULL;
}
gHeapMoveableBlocksLength = 0;
if (gHeapMoveableExtents != nullptr) {
if (gHeapMoveableExtents != NULL) {
internal_free(gHeapMoveableExtents);
gHeapMoveableExtents = nullptr;
gHeapMoveableExtents = NULL;
}
gHeapMoveableExtentsLength = 0;
if (gHeapFreeBlocks != nullptr) {
if (gHeapFreeBlocks != NULL) {
internal_free(gHeapFreeBlocks);
gHeapFreeBlocks = nullptr;
gHeapFreeBlocks = NULL;
}
gHeapFreeBlocksLength = 0;
}
@@ -203,7 +203,7 @@ static void heapInternalsFree()
// 0x452974
bool heapInit(Heap* heap, int a2)
{
if (heap == nullptr) {
if (heap == NULL) {
return false;
}
@@ -218,7 +218,7 @@ bool heapInit(Heap* heap, int a2)
if (heapHandleListInit(heap)) {
int size = (a2 >> 10) + a2;
heap->data = (unsigned char*)internal_malloc(size);
if (heap->data != nullptr) {
if (heap->data != NULL) {
heap->size = size;
heap->freeBlocks = 1;
heap->freeSize = heap->size - HEAP_BLOCK_OVERHEAD_SIZE;
@@ -248,24 +248,24 @@ bool heapInit(Heap* heap, int a2)
// 0x452A3C
bool heapFree(Heap* heap)
{
if (heap == nullptr) {
if (heap == NULL) {
return false;
}
for (int index = 0; index < heap->handlesLength; index++) {
HeapHandle* handle = &(heap->handles[index]);
if (handle->state == 4 && handle->data != nullptr) {
if (handle->state == 4 && handle->data != NULL) {
internal_free(handle->data);
}
}
if (heap->handles != nullptr) {
if (heap->handles != NULL) {
internal_free(heap->handles);
heap->handles = nullptr;
heap->handles = NULL;
heap->handlesLength = 0;
}
if (heap->data != nullptr) {
if (heap->data != NULL) {
internal_free(heap->data);
}
@@ -283,7 +283,7 @@ bool heapFree(Heap* heap)
static bool heapHandleListInit(Heap* heap)
{
heap->handles = (HeapHandle*)internal_malloc(sizeof(*heap->handles) * HEAP_HANDLES_INITIAL_LENGTH);
if (heap->handles == nullptr) {
if (heap->handles == NULL) {
debugPrint("Heap Error : Could not initialize handles.\n");
return false;
}
@@ -291,7 +291,7 @@ static bool heapHandleListInit(Heap* heap)
for (int index = 0; index < HEAP_HANDLES_INITIAL_LENGTH; index++) {
HeapHandle* handle = &(heap->handles[index]);
handle->state = HEAP_HANDLE_STATE_INVALID;
handle->data = nullptr;
handle->data = NULL;
}
heap->handlesLength = HEAP_HANDLES_INITIAL_LENGTH;
@@ -309,7 +309,7 @@ bool heapBlockAllocate(Heap* heap, int* handleIndexPtr, int size, int a4)
size += 4 - size % 4;
if (heap == nullptr || handleIndexPtr == nullptr || size == 0) {
if (heap == NULL || handleIndexPtr == NULL || size == 0) {
goto err;
}
@@ -401,7 +401,7 @@ bool heapBlockAllocate(Heap* heap, int* handleIndexPtr, int size, int a4)
}
handle->state = HEAP_HANDLE_STATE_INVALID;
handle->data = nullptr;
handle->data = NULL;
debugPrint("Heap Error: Unknown block state during allocation.\n");
@@ -422,7 +422,7 @@ err:
// 0x452CB4
bool heapBlockDeallocate(Heap* heap, int* handleIndexPtr)
{
if (heap == nullptr || handleIndexPtr == nullptr) {
if (heap == NULL || handleIndexPtr == NULL) {
debugPrint("Heap Error: Could not deallocate block.\n");
return false;
}
@@ -466,7 +466,7 @@ bool heapBlockDeallocate(Heap* heap, int* handleIndexPtr)
// Reset handle
handle->state = HEAP_HANDLE_STATE_INVALID;
handle->data = nullptr;
handle->data = NULL;
return true;
}
@@ -481,7 +481,7 @@ bool heapBlockDeallocate(Heap* heap, int* handleIndexPtr)
// Reset handle
handle->state = HEAP_HANDLE_STATE_INVALID;
handle->data = nullptr;
handle->data = NULL;
return true;
}
@@ -493,7 +493,7 @@ bool heapBlockDeallocate(Heap* heap, int* handleIndexPtr)
// 0x452DE0
bool heapLock(Heap* heap, int handleIndex, unsigned char** bufferPtr)
{
if (heap == nullptr) {
if (heap == NULL) {
debugPrint("Heap Error: Could not lock block");
return false;
}
@@ -554,7 +554,7 @@ bool heapLock(Heap* heap, int handleIndex, unsigned char** bufferPtr)
// 0x452EE4
bool heapUnlock(Heap* heap, int handleIndex)
{
if (heap == nullptr) {
if (heap == NULL) {
debugPrint("Heap Error: Could not unlock block.\n");
return false;
}
@@ -603,7 +603,7 @@ bool heapUnlock(Heap* heap, int handleIndex)
// 0x4532AC
static bool heapPrintStats(Heap* heap, char* dest, size_t size)
{
if (heap == nullptr || dest == nullptr) {
if (heap == NULL || dest == NULL) {
return false;
}
@@ -649,7 +649,7 @@ static bool heapFindFreeHandle(Heap* heap, int* handleIndexPtr)
// If we're here the search above failed, we have to allocate more handles.
HeapHandle* handles = (HeapHandle*)internal_realloc(heap->handles, sizeof(*handles) * (heap->handlesLength + HEAP_HANDLES_INITIAL_LENGTH));
if (handles == nullptr) {
if (handles == NULL) {
return false;
}
@@ -659,7 +659,7 @@ static bool heapFindFreeHandle(Heap* heap, int* handleIndexPtr)
for (int index = heap->handlesLength; index < heap->handlesLength + HEAP_HANDLES_INITIAL_LENGTH; index++) {
HeapHandle* handle = &(heap->handles[index]);
handle->state = HEAP_HANDLE_STATE_INVALID;
handle->data = nullptr;
handle->data = NULL;
}
*handleIndexPtr = heap->handlesLength;
@@ -725,7 +725,7 @@ static bool heapFindFreeBlock(Heap* heap, int size, void** blockPtr, int a4)
// to index all blocks for longest moveable extent.
if (maxBlocksCount > gHeapReservedFreeBlockIndexesLength) {
int* indexes = (int*)internal_realloc(gHeapReservedFreeBlockIndexes, sizeof(*gHeapReservedFreeBlockIndexes) * maxBlocksCount);
if (indexes == nullptr) {
if (indexes == NULL) {
goto system;
}
@@ -921,7 +921,7 @@ system:
if (a4 == 0) {
debugPrint("Allocating block from system memory...\n");
unsigned char* block = (unsigned char*)internal_malloc(size + HEAP_BLOCK_OVERHEAD_SIZE);
if (block == nullptr) {
if (block == NULL) {
debugPrint("fatal error: internal_malloc() failed in heap_find_free_block()!\n");
return false;
}
@@ -952,7 +952,7 @@ static bool heapBuildMoveableBlocksList(int extentIndex)
HeapMoveableExtent* extent = &(gHeapMoveableExtents[extentIndex]);
if (extent->moveableBlocksLength > gHeapMoveableBlocksLength) {
unsigned char** moveableBlocks = (unsigned char**)internal_realloc(gHeapMoveableBlocks, sizeof(*gHeapMoveableBlocks) * extent->moveableBlocksLength);
if (moveableBlocks == nullptr) {
if (moveableBlocks == NULL) {
return false;
}
@@ -990,7 +990,7 @@ static bool heapBuildFreeBlocksList(Heap* heap)
if (heap->freeBlocks > gHeapFreeBlocksLength) {
unsigned char** freeBlocks = (unsigned char**)internal_realloc(gHeapFreeBlocks, sizeof(*freeBlocks) * heap->freeBlocks);
if (freeBlocks == nullptr) {
if (freeBlocks == NULL) {
return false;
}
@@ -1063,7 +1063,7 @@ static bool heapBuildMoveableExtentsList(Heap* heap, int* moveableExtentsLengthP
if (maxExtentsCount > gHeapMoveableExtentsLength) {
HeapMoveableExtent* moveableExtents = (HeapMoveableExtent*)internal_realloc(gHeapMoveableExtents, sizeof(*gHeapMoveableExtents) * maxExtentsCount);
if (moveableExtents == nullptr) {
if (moveableExtents == NULL) {
return false;
}
+22 -25
View File
@@ -4,7 +4,6 @@
#include "audio_engine.h"
#include "color.h"
#include "delay.h"
#include "dinput.h"
#include "draw.h"
#include "kb.h"
@@ -49,10 +48,10 @@ static void _GNW95_process_key(KeyboardData* data);
static void idleImpl();
// 0x51E234
static IdleFunc* _idle_func = nullptr;
static IdleFunc* _idle_func = NULL;
// 0x51E238
static FocusFunc* _focus_func = nullptr;
static FocusFunc* _focus_func = NULL;
// 0x51E23C
static int gKeyboardKeyRepeatRate = 80;
@@ -150,7 +149,7 @@ int inputInit(int a1)
gPauseKeyCode = KEY_ALT_P;
gPauseHandler = pauseHandlerDefaultImpl;
gScreenshotHandler = screenshotHandlerDefaultImpl;
gTickerListHead = nullptr;
gTickerListHead = NULL;
gScreenshotKeyCode = KEY_ALT_C;
// SFALL: Set idle function.
@@ -169,7 +168,7 @@ void inputExit()
directInputFree();
TickerListNode* curr = gTickerListHead;
while (curr != nullptr) {
while (curr != NULL) {
TickerListNode* next = curr->next;
internal_free(curr);
curr = next;
@@ -200,13 +199,6 @@ int inputGetInput()
return -1;
}
// 0x4C8BC8
void get_input_position(int* x, int* y)
{
*x = _input_mx;
*y = _input_my;
}
// 0x4C8BDC
void _process_bk()
{
@@ -318,7 +310,7 @@ void tickersExecute()
TickerListNode* curr = gTickerListHead;
TickerListNode** currPtr = &(gTickerListHead);
while (curr != nullptr) {
while (curr != NULL) {
TickerListNode* next = curr->next;
if (curr->flags & 1) {
*currPtr = next;
@@ -336,7 +328,7 @@ void tickersExecute()
void tickersAdd(TickerProc* proc)
{
TickerListNode* curr = gTickerListHead;
while (curr != nullptr) {
while (curr != NULL) {
if (curr->proc == proc) {
if ((curr->flags & 0x01) != 0) {
curr->flags &= ~0x01;
@@ -357,7 +349,7 @@ void tickersAdd(TickerProc* proc)
void tickersRemove(TickerProc* proc)
{
TickerListNode* curr = gTickerListHead;
while (curr != nullptr) {
while (curr != NULL) {
if (curr->proc == proc) {
curr->flags |= 0x01;
return;
@@ -439,7 +431,7 @@ void pauseHandlerConfigure(int keyCode, PauseHandler* handler)
{
gPauseKeyCode = keyCode;
if (handler == nullptr) {
if (handler == NULL) {
handler = pauseHandlerDefaultImpl;
}
@@ -452,7 +444,7 @@ void takeScreenshot()
int width = _scr_size.right - _scr_size.left + 1;
int height = _scr_size.bottom - _scr_size.top + 1;
gScreenshotBuffer = (unsigned char*)internal_malloc(width * height);
if (gScreenshotBuffer == nullptr) {
if (gScreenshotBuffer == NULL) {
return;
}
@@ -463,7 +455,7 @@ void takeScreenshot()
_mouse_blit = screenshotBlitter;
WindowDrawingProc2* v1 = _mouse_blit_trans;
_mouse_blit_trans = nullptr;
_mouse_blit_trans = NULL;
windowRefreshAll(&_scr_size);
@@ -496,7 +488,7 @@ int screenshotHandlerDefaultImpl(int width, int height, unsigned char* data, uns
snprintf(fileName, sizeof(fileName), "scr%.5d.bmp", index);
stream = compat_fopen(fileName, "rb");
if (stream == nullptr) {
if (stream == NULL) {
break;
}
@@ -508,7 +500,7 @@ int screenshotHandlerDefaultImpl(int width, int height, unsigned char* data, uns
}
stream = compat_fopen(fileName, "wb");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -607,7 +599,7 @@ void screenshotHandlerConfigure(int keyCode, ScreenshotHandler* handler)
{
gScreenshotKeyCode = keyCode;
if (handler == nullptr) {
if (handler == NULL) {
handler = screenshotHandlerDefaultImpl;
}
@@ -642,7 +634,12 @@ void inputPauseForTocks(unsigned int delay)
// 0x4C93B8
void inputBlockForTocks(unsigned int ms)
{
delay_ms(ms);
unsigned int start = SDL_GetTicks();
unsigned int diff;
do {
// NOTE: Uninline
diff = getTicksSince(start);
} while (diff < ms);
}
// 0x4C93E0
@@ -1197,19 +1194,19 @@ static void _GNW95_process_key(KeyboardData* data)
// 0x4C9EEC
void _GNW95_lost_focus()
{
if (_focus_func != nullptr) {
if (_focus_func != NULL) {
_focus_func(false);
}
while (!gProgramIsActive) {
_GNW95_process_message();
if (_idle_func != nullptr) {
if (_idle_func != NULL) {
_idle_func();
}
}
if (_focus_func != nullptr) {
if (_focus_func != NULL) {
_focus_func(true);
}
}
-1
View File
@@ -13,7 +13,6 @@ typedef int(ScreenshotHandler)(int width, int height, unsigned char* buffer, uns
int inputInit(int a1);
void inputExit();
int inputGetInput();
void get_input_position(int* x, int* y);
void _process_bk();
void enqueueInputEvent(int a1);
void inputEventQueueReset();
+39 -39
View File
@@ -194,11 +194,11 @@ static Rect gInterfaceBarActionPointsBarRect;
// 0x518FE8
static IndicatorDescription gIndicatorDescriptions[INDICATOR_COUNT] = {
{ 102, true, nullptr }, // ADDICT
{ 100, false, nullptr }, // SNEAK
{ 101, false, nullptr }, // LEVEL
{ 103, true, nullptr }, // POISONED
{ 104, true, nullptr }, // RADIATED
{ 102, true, NULL }, // ADDICT
{ 100, false, NULL }, // SNEAK
{ 101, false, NULL }, // LEVEL
{ 103, true, NULL }, // POISONED
{ 104, true, NULL }, // RADIATED
};
// 0x519024
@@ -327,7 +327,7 @@ int interfaceInit()
}
gInterfaceWindowBuffer = windowGetBuffer(gInterfaceBarWindow);
if (gInterfaceWindowBuffer == nullptr) {
if (gInterfaceWindowBuffer == NULL) {
// NOTE: Uninline.
return intface_fatal_error(-1);
}
@@ -357,7 +357,7 @@ int interfaceInit()
return intface_fatal_error(-1);
}
gInventoryButton = buttonCreate(gInterfaceBarWindow, 211 + gInterfaceBarContentOffset, 40, 32, 21, -1, -1, -1, KEY_LOWERCASE_I, _inventoryButtonNormalFrmImage.getData(), _inventoryButtonPressedFrmImage.getData(), nullptr, 0);
gInventoryButton = buttonCreate(gInterfaceBarWindow, 211 + gInterfaceBarContentOffset, 40, 32, 21, -1, -1, -1, KEY_LOWERCASE_I, _inventoryButtonNormalFrmImage.getData(), _inventoryButtonPressedFrmImage.getData(), NULL, 0);
if (gInventoryButton == -1) {
// NOTE: Uninline.
return intface_fatal_error(-1);
@@ -377,7 +377,7 @@ int interfaceInit()
return intface_fatal_error(-1);
}
gOptionsButton = buttonCreate(gInterfaceBarWindow, 210 + gInterfaceBarContentOffset, 61, 34, 34, -1, -1, -1, KEY_LOWERCASE_O, _optionsButtonNormalFrmImage.getData(), _optionsButtonPressedFrmImage.getData(), nullptr, 0);
gOptionsButton = buttonCreate(gInterfaceBarWindow, 210 + gInterfaceBarContentOffset, 61, 34, 34, -1, -1, -1, KEY_LOWERCASE_O, _optionsButtonNormalFrmImage.getData(), _optionsButtonPressedFrmImage.getData(), NULL, 0);
if (gOptionsButton == -1) {
// NOTE: Uninline.
return intface_fatal_error(-1);
@@ -403,7 +403,7 @@ int interfaceInit()
return intface_fatal_error(-1);
}
gSkilldexButton = buttonCreate(gInterfaceBarWindow, 523 + gInterfaceBarContentOffset, 6, 22, 21, -1, -1, -1, KEY_LOWERCASE_S, _skilldexButtonNormalFrmImage.getData(), _skilldexButtonPressedFrmImage.getData(), nullptr, BUTTON_FLAG_TRANSPARENT);
gSkilldexButton = buttonCreate(gInterfaceBarWindow, 523 + gInterfaceBarContentOffset, 6, 22, 21, -1, -1, -1, KEY_LOWERCASE_S, _skilldexButtonNormalFrmImage.getData(), _skilldexButtonPressedFrmImage.getData(), NULL, BUTTON_FLAG_TRANSPARENT);
if (gSkilldexButton == -1) {
// NOTE: Uninline.
return intface_fatal_error(-1);
@@ -430,7 +430,7 @@ int interfaceInit()
return intface_fatal_error(-1);
}
gMapButton = buttonCreate(gInterfaceBarWindow, 526 + gInterfaceBarContentOffset, 39, 41, 19, -1, -1, -1, KEY_TAB, _mapButtonNormalFrmImage.getData(), _mapButtonPressedFrmImage.getData(), nullptr, BUTTON_FLAG_TRANSPARENT);
gMapButton = buttonCreate(gInterfaceBarWindow, 526 + gInterfaceBarContentOffset, 39, 41, 19, -1, -1, -1, KEY_TAB, _mapButtonNormalFrmImage.getData(), _mapButtonPressedFrmImage.getData(), NULL, BUTTON_FLAG_TRANSPARENT);
if (gMapButton == -1) {
// NOTE: Uninline.
return intface_fatal_error(-1);
@@ -451,7 +451,7 @@ int interfaceInit()
return intface_fatal_error(-1);
}
gPipboyButton = buttonCreate(gInterfaceBarWindow, 526 + gInterfaceBarContentOffset, 77, 41, 19, -1, -1, -1, KEY_LOWERCASE_P, _pipboyButtonNormalFrmImage.getData(), _pipboyButtonPressedFrmImage.getData(), nullptr, 0);
gPipboyButton = buttonCreate(gInterfaceBarWindow, 526 + gInterfaceBarContentOffset, 77, 41, 19, -1, -1, -1, KEY_LOWERCASE_P, _pipboyButtonNormalFrmImage.getData(), _pipboyButtonPressedFrmImage.getData(), NULL, 0);
if (gPipboyButton == -1) {
// NOTE: Uninline.
return intface_fatal_error(-1);
@@ -472,7 +472,7 @@ int interfaceInit()
return intface_fatal_error(-1);
}
gCharacterButton = buttonCreate(gInterfaceBarWindow, 526 + gInterfaceBarContentOffset, 58, 41, 19, -1, -1, -1, KEY_LOWERCASE_C, _characterButtonNormalFrmImage.getData(), _characterButtonPressedFrmImage.getData(), nullptr, 0);
gCharacterButton = buttonCreate(gInterfaceBarWindow, 526 + gInterfaceBarContentOffset, 58, 41, 19, -1, -1, -1, KEY_LOWERCASE_C, _characterButtonNormalFrmImage.getData(), _characterButtonPressedFrmImage.getData(), NULL, 0);
if (gCharacterButton == -1) {
// NOTE: Uninline.
return intface_fatal_error(-1);
@@ -502,13 +502,13 @@ int interfaceInit()
memcpy(_itemButtonUp, _itemButtonNormalFrmImage.getData(), sizeof(_itemButtonUp));
memcpy(_itemButtonDown, _itemButtonPressedFrmImage.getData(), sizeof(_itemButtonDown));
gSingleAttackButton = buttonCreate(gInterfaceBarWindow, 267 + gInterfaceBarContentOffset, 26, 188, 67, -1, -1, -1, -20, _itemButtonUp, _itemButtonDown, nullptr, BUTTON_FLAG_TRANSPARENT);
gSingleAttackButton = buttonCreate(gInterfaceBarWindow, 267 + gInterfaceBarContentOffset, 26, 188, 67, -1, -1, -1, -20, _itemButtonUp, _itemButtonDown, NULL, BUTTON_FLAG_TRANSPARENT);
if (gSingleAttackButton == -1) {
// NOTE: Uninline.
return intface_fatal_error(-1);
}
buttonSetRightMouseCallbacks(gSingleAttackButton, -1, KEY_LOWERCASE_N, nullptr, nullptr);
buttonSetRightMouseCallbacks(gSingleAttackButton, -1, KEY_LOWERCASE_N, NULL, NULL);
buttonSetCallbacks(gSingleAttackButton, _gsound_lrg_butt_press, _gsound_lrg_butt_release);
fid = buildFid(OBJ_TYPE_INTERFACE, 6, 0, 0, 0);
@@ -530,7 +530,7 @@ int interfaceInit()
}
// Swap hands button
gChangeHandsButton = buttonCreate(gInterfaceBarWindow, 218 + gInterfaceBarContentOffset, 6, 22, 21, -1, -1, -1, KEY_LOWERCASE_B, _changeHandsButtonNormalFrmImage.getData(), _changeHandsButtonPressedFrmImage.getData(), nullptr, BUTTON_FLAG_TRANSPARENT);
gChangeHandsButton = buttonCreate(gInterfaceBarWindow, 218 + gInterfaceBarContentOffset, 6, 22, 21, -1, -1, -1, KEY_LOWERCASE_B, _changeHandsButtonNormalFrmImage.getData(), _changeHandsButtonPressedFrmImage.getData(), NULL, BUTTON_FLAG_TRANSPARENT);
if (gChangeHandsButton == -1) {
// NOTE: Uninline.
return intface_fatal_error(-1);
@@ -1053,8 +1053,8 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction)
InterfaceItemState* leftItemState = &(gInterfaceItemStates[HAND_LEFT]);
Object* item1 = critterGetItem1(gDude);
if (item1 == leftItemState->item && leftItemState->item != nullptr) {
if (leftItemState->item != nullptr) {
if (item1 == leftItemState->item && leftItemState->item != NULL) {
if (leftItemState->item != NULL) {
leftItemState->isDisabled = dudeIsWeaponDisabled(item1);
leftItemState->itemFid = itemGetInventoryFid(item1);
}
@@ -1064,7 +1064,7 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction)
leftItemState->item = item1;
if (item1 != nullptr) {
if (item1 != NULL) {
leftItemState->isDisabled = dudeIsWeaponDisabled(item1);
leftItemState->primaryHitMode = HIT_MODE_LEFT_WEAPON_PRIMARY;
leftItemState->secondaryHitMode = HIT_MODE_LEFT_WEAPON_SECONDARY;
@@ -1093,7 +1093,7 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction)
// SFALL: Keep selected attack mode.
// CE: Implementation is different.
if (oldItem == nullptr) {
if (oldItem == NULL) {
leftItemState->action = oldAction;
}
}
@@ -1102,8 +1102,8 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction)
InterfaceItemState* rightItemState = &(gInterfaceItemStates[HAND_RIGHT]);
Object* item2 = critterGetItem2(gDude);
if (item2 == rightItemState->item && rightItemState->item != nullptr) {
if (rightItemState->item != nullptr) {
if (item2 == rightItemState->item && rightItemState->item != NULL) {
if (rightItemState->item != NULL) {
rightItemState->isDisabled = dudeIsWeaponDisabled(rightItemState->item);
rightItemState->itemFid = itemGetInventoryFid(rightItemState->item);
}
@@ -1113,7 +1113,7 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction)
rightItemState->item = item2;
if (item2 != nullptr) {
if (item2 != NULL) {
rightItemState->isDisabled = dudeIsWeaponDisabled(item2);
rightItemState->primaryHitMode = HIT_MODE_RIGHT_WEAPON_PRIMARY;
rightItemState->secondaryHitMode = HIT_MODE_RIGHT_WEAPON_SECONDARY;
@@ -1141,7 +1141,7 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction)
// SFALL: Keep selected attack mode.
// CE: Implementation is different.
if (oldItem == nullptr) {
if (oldItem == NULL) {
rightItemState->action = oldAction;
}
}
@@ -1151,7 +1151,7 @@ int interfaceUpdateItems(bool animated, int leftItemAction, int rightItemAction)
Object* newCurrentItem = gInterfaceItemStates[gInterfaceCurrentHand].item;
if (newCurrentItem != oldCurrentItem) {
int animationCode = 0;
if (newCurrentItem != nullptr) {
if (newCurrentItem != NULL) {
if (itemGetType(newCurrentItem) == ITEM_TYPE_WEAPON) {
animationCode = weaponGetAnimationCode(newCurrentItem);
}
@@ -1180,7 +1180,7 @@ int interfaceBarSwapHands(bool animated)
if (animated) {
Object* item = gInterfaceItemStates[gInterfaceCurrentHand].item;
int animationCode = 0;
if (item != nullptr) {
if (item != NULL) {
if (itemGetType(item) == ITEM_TYPE_WEAPON) {
animationCode = weaponGetAnimationCode(item);
}
@@ -1298,7 +1298,7 @@ void _intface_use_item()
gameMouseSetCursor(MOUSE_CURSOR_CROSSHAIR);
gameMouseSetMode(GAME_MOUSE_MODE_CROSSHAIR);
if (!isInCombat()) {
_combat(nullptr);
_combat(NULL);
}
}
} else if (_proto_action_can_use_on(ptr->item->pid)) {
@@ -1389,7 +1389,7 @@ void interfaceBarEndButtonsShow(bool animated)
int fid = buildFid(OBJ_TYPE_INTERFACE, 104, 0, 0, 0);
CacheEntry* handle;
Art* art = artLock(fid, &handle);
if (art == nullptr) {
if (art == NULL) {
return;
}
@@ -1405,7 +1405,7 @@ void interfaceBarEndButtonsShow(bool animated)
if (getTicksSince(time) >= delay) {
unsigned char* src = artGetFrameData(art, frame, 0);
if (src != nullptr) {
if (src != NULL) {
blitBufferToBuffer(src, 57, 58, 57, gInterfaceWindowBuffer + gInterfaceBarWidth * 38 + 580 + gInterfaceBarContentOffset, gInterfaceBarWidth);
windowRefreshRect(gInterfaceBarWindow, &gInterfaceBarEndButtonsRect);
}
@@ -1446,7 +1446,7 @@ void interfaceBarEndButtonsHide(bool animated)
int fid = buildFid(OBJ_TYPE_INTERFACE, 104, 0, 0, 0);
CacheEntry* handle;
Art* art = artLock(fid, &handle);
if (art == nullptr) {
if (art == NULL) {
return;
}
@@ -1465,7 +1465,7 @@ void interfaceBarEndButtonsHide(bool animated)
if (getTicksSince(time) >= delay) {
unsigned char* src = artGetFrameData(art, frame - 1, 0);
unsigned char* dest = gInterfaceWindowBuffer + gInterfaceBarWidth * 38 + 580 + gInterfaceBarContentOffset;
if (src != nullptr) {
if (src != NULL) {
blitBufferToBuffer(src, 57, 58, 57, dest, gInterfaceBarWidth);
windowRefreshRect(gInterfaceBarWindow, &gInterfaceBarEndButtonsRect);
}
@@ -1827,10 +1827,10 @@ static void interfaceBarSwapHandsAnimatePutAwayTakeOutSequence(int previousWeapo
}
// TODO: Get rid of cast.
animationRegisterCallbackForced(nullptr, nullptr, (AnimationCallback*)_intface_redraw_items_callback, -1);
animationRegisterCallbackForced(NULL, NULL, (AnimationCallback*)_intface_redraw_items_callback, -1);
Object* item = gInterfaceItemStates[gInterfaceCurrentHand].item;
if (item != nullptr && item->lightDistance > 4) {
if (item != NULL && item->lightDistance > 4) {
animationRegisterSetLightDistance(gDude, item->lightDistance, 0);
}
@@ -1842,7 +1842,7 @@ static void interfaceBarSwapHandsAnimatePutAwayTakeOutSequence(int previousWeapo
}
// TODO: Get rid of cast.
animationRegisterCallbackForced(nullptr, nullptr, (AnimationCallback*)_intface_change_fid_callback, -1);
animationRegisterCallbackForced(NULL, NULL, (AnimationCallback*)_intface_change_fid_callback, -1);
if (reg_anim_end() == -1) {
return;
@@ -1900,7 +1900,7 @@ static int endTurnButtonInit()
return -1;
}
gEndTurnButton = buttonCreate(gInterfaceBarWindow, 590 + gInterfaceBarContentOffset, 43, 38, 22, -1, -1, -1, 32, _endTurnButtonNormalFrmImage.getData(), _endTurnButtonPressedFrmImage.getData(), nullptr, 0);
gEndTurnButton = buttonCreate(gInterfaceBarWindow, 590 + gInterfaceBarContentOffset, 43, 38, 22, -1, -1, -1, 32, _endTurnButtonNormalFrmImage.getData(), _endTurnButtonPressedFrmImage.getData(), NULL, 0);
if (gEndTurnButton == -1) {
return -1;
}
@@ -1952,7 +1952,7 @@ static int endCombatButtonInit()
return -1;
}
gEndCombatButton = buttonCreate(gInterfaceBarWindow, 590 + gInterfaceBarContentOffset, 65, 38, 22, -1, -1, -1, 13, _endCombatButtonNormalFrmImage.getData(), _endCombatButtonPressedFrmImage.getData(), nullptr, 0);
gEndCombatButton = buttonCreate(gInterfaceBarWindow, 590 + gInterfaceBarContentOffset, 65, 38, 22, -1, -1, -1, 13, _endCombatButtonNormalFrmImage.getData(), _endCombatButtonPressedFrmImage.getData(), NULL, 0);
if (gEndCombatButton == -1) {
return -1;
}
@@ -2034,7 +2034,7 @@ static int _intface_item_reload()
return -1;
}
const char* sfx = sfxBuildWeaponName(WEAPON_SOUND_EFFECT_READY, gInterfaceItemStates[gInterfaceCurrentHand].item, HIT_MODE_RIGHT_WEAPON_PRIMARY, nullptr);
const char* sfx = sfxBuildWeaponName(WEAPON_SOUND_EFFECT_READY, gInterfaceItemStates[gInterfaceCurrentHand].item, HIT_MODE_RIGHT_WEAPON_PRIMARY, NULL);
soundPlayFile(sfx);
return 0;
@@ -2222,7 +2222,7 @@ static int indicatorBarInit()
IndicatorDescription* indicatorDescription = &(gIndicatorDescriptions[index]);
indicatorDescription->data = (unsigned char*)internal_malloc(INDICATOR_BOX_WIDTH * INDICATOR_BOX_HEIGHT);
if (indicatorDescription->data == nullptr) {
if (indicatorDescription->data == NULL) {
debugPrint("\nINTRFACE: Error initializing indicator box graphics! **");
while (--index >= 0) {
@@ -2276,9 +2276,9 @@ static void interfaceBarFree()
for (int index = 0; index < INDICATOR_COUNT; index++) {
IndicatorDescription* indicatorBoxDescription = &(gIndicatorDescriptions[index]);
if (indicatorBoxDescription->data != nullptr) {
if (indicatorBoxDescription->data != NULL) {
internal_free(indicatorBoxDescription->data);
indicatorBoxDescription->data = nullptr;
indicatorBoxDescription->data = NULL;
}
}
}
+8
View File
@@ -6,6 +6,14 @@
namespace fallout {
typedef enum Hand {
// Item1 (Punch)
HAND_LEFT,
// Item2 (Kick)
HAND_RIGHT,
HAND_COUNT,
} Hand;
#define INDICATOR_BOX_WIDTH 130
#define INDICATOR_BOX_HEIGHT 21
+100 -110
View File
@@ -31,13 +31,13 @@ static int _outputStr(char* a1);
static int _checkWait(Program* program);
static char* programGetCurrentProcedureName(Program* s);
static opcode_t stackReadInt16(unsigned char* data, int pos);
static int stackReadInt32(unsigned char* data, int pos);
static void stackWriteInt16(int value, unsigned char* data, int pos);
static void stackWriteInt32(int value, unsigned char* data, int pos);
static void stackPushInt16(unsigned char* data, int* pointer, int value);
static void stackPushInt32(unsigned char* data, int* pointer, int value);
static int stackPopInt32(unsigned char* data, int* pointer);
static opcode_t stackPopInt16(unsigned char* data, int* pointer);
static int stackReadInt32(unsigned char* a1, int a2);
static void stackWriteInt16(int value, unsigned char* a2, int a3);
static void stackWriteInt32(int value, unsigned char* stack, int pos);
static void stackPushInt16(unsigned char* a1, int* a2, int value);
static void stackPushInt32(unsigned char* a1, int* a2, int value);
static int stackPopInt32(unsigned char* a1, int* a2);
static opcode_t stackPopInt16(unsigned char* a1, int* a2);
static void _interpretIncStringRef(Program* program, opcode_t opcode, int value);
static void programReturnStackPushInt16(Program* program, int value);
static opcode_t programReturnStackPopInt16(Program* program);
@@ -51,7 +51,7 @@ static void opPush(Program* program);
static void opPushBase(Program* program);
static void opPopBase(Program* program);
static void opPopToBase(Program* program);
static void opSetGlobal(Program* program);
static void op802C(Program* program);
static void opDump(Program* program);
static void opDelayedCall(Program* program);
static void opConditionalCall(Program* program);
@@ -208,7 +208,7 @@ void _interpretOutputFunc(int (*func)(char*))
// 0x467104
int _interpretOutput(const char* format, ...)
{
if (_outputFunc == nullptr) {
if (_outputFunc == NULL) {
return 0;
}
@@ -230,17 +230,17 @@ static char* programGetCurrentProcedureName(Program* program)
int procedureCount = stackReadInt32(program->procedures, 0);
unsigned char* ptr = program->procedures + 4;
int procedureOffset = stackReadInt32(ptr, offsetof(Procedure, bodyOffset));
int identifierOffset = stackReadInt32(ptr, offsetof(Procedure, nameOffset));
int procedureOffset = stackReadInt32(ptr, 16);
int identifierOffset = stackReadInt32(ptr, 0);
for (int index = 0; index < procedureCount; index++) {
int nextProcedureOffset = stackReadInt32(ptr + 24, offsetof(Procedure, bodyOffset));
int nextProcedureOffset = stackReadInt32(ptr + 24, 16);
if (program->instructionPointer >= procedureOffset && program->instructionPointer < nextProcedureOffset) {
return (char*)(program->identifiers + identifierOffset);
}
ptr += 24;
identifierOffset = stackReadInt32(ptr, offsetof(Procedure, nameOffset));
identifierOffset = stackReadInt32(ptr, 0);
}
return _aCouldnTFindPro;
@@ -258,7 +258,7 @@ static char* programGetCurrentProcedureName(Program* program)
debugPrint("\nError during execution: %s\n", string);
if (gInterpreterCurrentProgram == nullptr) {
if (gInterpreterCurrentProgram == NULL) {
debugPrint("No current script");
} else {
char* procedureName = programGetCurrentProcedureName(gInterpreterCurrentProgram);
@@ -402,11 +402,11 @@ void _interpretDecStringRef(Program* program, opcode_t opcode, int value)
static void _detachProgram(Program* program)
{
Program* parent = program->parent;
if (parent != nullptr) {
if (parent != NULL) {
parent->flags &= ~PROGRAM_FLAG_0x20;
parent->flags &= ~PROGRAM_FLAG_0x0100;
if (program == parent->child) {
parent->child = nullptr;
parent->child = NULL;
}
}
}
@@ -427,14 +427,14 @@ void programFree(Program* program)
_detachProgram(program);
Program* curr = program->child;
while (curr != nullptr) {
while (curr != NULL) {
// NOTE: Uninline.
_purgeProgram(curr);
curr->parent = nullptr;
curr->parent = NULL;
Program* next = curr->child;
curr->child = nullptr;
curr->child = NULL;
curr = next;
}
@@ -442,15 +442,15 @@ void programFree(Program* program)
// NOTE: Uninline.
_purgeProgram(program);
if (program->dynamicStrings != nullptr) {
if (program->dynamicStrings != NULL) {
internal_free_safe(program->dynamicStrings, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 429
}
if (program->data != nullptr) {
if (program->data != NULL) {
internal_free_safe(program->data, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 430
}
if (program->name != nullptr) {
if (program->name != NULL) {
internal_free_safe(program->name, __FILE__, __LINE__); // "..\\int\\INTRPRET.C", 431
}
@@ -464,11 +464,11 @@ void programFree(Program* program)
Program* programCreateByPath(const char* path)
{
File* stream = fileOpen(path, "rb");
if (stream == nullptr) {
if (stream == NULL) {
char err[260];
snprintf(err, sizeof(err), "Couldn't open %s for read\n", path);
programFatalError(err);
return nullptr;
return NULL;
}
int fileSize = fileGetSize(stream);
@@ -483,8 +483,8 @@ Program* programCreateByPath(const char* path)
program->name = (char*)internal_malloc_safe(strlen(path) + 1, __FILE__, __LINE__); // ..\\int\\INTRPRET.C, 466
strcpy(program->name, path);
program->child = nullptr;
program->parent = nullptr;
program->child = NULL;
program->parent = NULL;
program->field_78 = -1;
program->exited = false;
program->basePointer = -1;
@@ -528,7 +528,7 @@ char* programGetString(Program* program, opcode_t opcode, int offset)
return (char*)(program->staticStrings + 4 + offset);
}
return nullptr;
return NULL;
}
// 0x46790C
@@ -554,7 +554,7 @@ static void programMarkHeap(Program* program)
short next_len;
short diff;
if (program->dynamicStrings == nullptr) {
if (program->dynamicStrings == NULL) {
return;
}
@@ -593,7 +593,7 @@ int programPushString(Program* program, char* string)
unsigned char* v20;
unsigned char* v23;
if (program == nullptr) {
if (program == NULL) {
return 0;
}
@@ -604,7 +604,7 @@ int programPushString(Program* program, char* string)
v27++;
}
if (program->dynamicStrings != nullptr) {
if (program->dynamicStrings != NULL) {
// TODO: Needs testing, lots of pointer stuff.
unsigned char* heap = program->dynamicStrings + 4;
while (*(unsigned short*)heap != 0x8000) {
@@ -712,7 +712,7 @@ static void opPopToBase(Program* program)
}
// 0x467DE0
static void opSetGlobal(Program* program)
static void op802C(Program* program)
{
program->basePointer = program->stackValues->size();
}
@@ -745,10 +745,10 @@ static void opDelayedCall(Program* program)
delay += 1000 * _timerFunc() / _timerTick;
}
int flags = stackReadInt32(procedure_ptr, offsetof(Procedure, flags));
int flags = stackReadInt32(procedure_ptr, 4);
stackWriteInt32(delay, procedure_ptr, offsetof(Procedure, time));
stackWriteInt32(flags | PROCEDURE_FLAG_TIMED, procedure_ptr, offsetof(Procedure, flags));
stackWriteInt32(delay, procedure_ptr, 8);
stackWriteInt32(flags | PROCEDURE_FLAG_TIMED, procedure_ptr, 4);
}
// 0x468034
@@ -761,10 +761,10 @@ static void opConditionalCall(Program* program)
}
unsigned char* procedure_ptr = program->procedures + 4 + 24 * data[0];
int flags = stackReadInt32(procedure_ptr, offsetof(Procedure, flags));
int flags = stackReadInt32(procedure_ptr, 4);
stackWriteInt32(flags | PROCEDURE_FLAG_CONDITIONAL, procedure_ptr, offsetof(Procedure, flags));
stackWriteInt32(data[1], procedure_ptr, offsetof(Procedure, conditionOffset));
stackWriteInt32(flags | PROCEDURE_FLAG_CONDITIONAL, procedure_ptr, 4);
stackWriteInt32(data[1], procedure_ptr, 12);
}
// 0x46817C
@@ -788,9 +788,9 @@ static void opCancel(Program* program)
}
Procedure* proc = (Procedure*)(program->procedures + 4 + data * sizeof(*proc));
proc->flags = 0;
proc->time = 0;
proc->conditionOffset = 0;
proc->field_4 = 0;
proc->field_8 = 0;
proc->field_C = 0;
}
// 0x468330
@@ -802,9 +802,9 @@ static void opCancelAll(Program* program)
// TODO: Original code uses different approach, check.
Procedure* proc = (Procedure*)(program->procedures + 4 + index * sizeof(*proc));
proc->flags = 0;
proc->time = 0;
proc->conditionOffset = 0;
proc->field_4 = 0;
proc->field_8 = 0;
proc->field_C = 0;
}
}
@@ -1131,12 +1131,7 @@ static void opConditionalOperatorLessThanEquals(Program* program)
case VALUE_TYPE_PTR:
switch (value[0].opcode) {
case VALUE_TYPE_INT:
if (value[0].integerValue > 0) {
result = (uintptr_t)value[1].pointerValue <= (uintptr_t)value[0].integerValue;
} else {
// (ptr <= int{0 or negative}) means (ptr == nullptr)
result = nullptr == value[1].pointerValue;
}
result = (uintptr_t)value[1].pointerValue <= (uintptr_t)value[0].integerValue;
break;
default:
assert(false && "Should be unreachable");
@@ -1390,12 +1385,7 @@ static void opConditionalOperatorGreaterThan(Program* program)
case VALUE_TYPE_PTR:
switch (value[0].opcode) {
case VALUE_TYPE_INT:
if (value[0].integerValue > 0) {
result = (uintptr_t)value[1].pointerValue > (uintptr_t)value[0].integerValue;
} else {
// (ptr > int{0 or negative}) means (ptr != nullptr)
result = nullptr != value[1].pointerValue;
}
result = (uintptr_t)value[1].pointerValue > (uintptr_t)value[0].integerValue;
break;
default:
assert(false && "Should be unreachable");
@@ -2040,12 +2030,12 @@ static void opCall(Program* program)
unsigned char* ptr = program->procedures + 4 + 24 * value;
int flags = stackReadInt32(ptr, offsetof(Procedure, flags));
if ((flags & PROCEDURE_FLAG_IMPORTED) != 0) {
int flags = stackReadInt32(ptr, 4);
if ((flags & 4) != 0) {
// TODO: Incomplete.
} else {
program->instructionPointer = stackReadInt32(ptr, offsetof(Procedure, bodyOffset));
if ((flags & PROCEDURE_FLAG_CRITICAL) != 0) {
program->instructionPointer = stackReadInt32(ptr, 16);
if ((flags & 0x10) != 0) {
program->flags |= PROGRAM_FLAG_CRITICAL_SECTION;
}
}
@@ -2248,7 +2238,7 @@ static void opFetchProcedureAddress(Program* program)
{
int procedureIndex = programStackPopInteger(program);
int address = stackReadInt32(program->procedures + 4 + sizeof(Procedure) * procedureIndex, offsetof(Procedure, bodyOffset));
int address = stackReadInt32(program->procedures + 4 + sizeof(Procedure) * procedureIndex, 16);
programStackPushInteger(program, address);
}
@@ -2308,8 +2298,8 @@ static void opExportProcedure(Program* program)
unsigned char* proc_ptr = program->procedures + 4 + sizeof(Procedure) * procedureIndex;
char* procedureName = programGetIdentifier(program, stackReadInt32(proc_ptr, offsetof(Procedure, nameOffset)));
int procedureAddress = stackReadInt32(proc_ptr, offsetof(Procedure, bodyOffset));
char* procedureName = programGetIdentifier(program, stackReadInt32(proc_ptr, 0));
int procedureAddress = stackReadInt32(proc_ptr, 16);
if (externalProcedureCreate(program, procedureName, procedureAddress, argumentCount) != 0) {
char err[256];
@@ -2338,7 +2328,7 @@ static void opExit(Program* program)
program->flags |= PROGRAM_FLAG_EXITED;
Program* parent = program->parent;
if (parent != nullptr) {
if (parent != NULL) {
if ((parent->flags & PROGRAM_FLAG_0x0100) != 0) {
parent->flags &= ~PROGRAM_FLAG_0x0100;
}
@@ -2354,7 +2344,7 @@ static void opExit(Program* program)
static void opDetach(Program* program)
{
Program* parent = program->parent;
if (parent == nullptr) {
if (parent == NULL) {
return;
}
@@ -2362,7 +2352,7 @@ static void opDetach(Program* program)
parent->flags &= ~PROGRAM_FLAG_0x0100;
if (parent->child == program) {
parent->child = nullptr;
parent->child = NULL;
}
}
@@ -2380,7 +2370,7 @@ static void opCallStart(Program* program)
// NOTE: Uninline.
program->child = runScript(name);
if (program->child == nullptr) {
if (program->child == NULL) {
char err[260];
snprintf(err, sizeof(err), "Error spawning child %s", name);
programFatalError(err);
@@ -2404,7 +2394,7 @@ static void opSpawn(Program* program)
// NOTE: Uninline.
program->child = runScript(name);
if (program->child == nullptr) {
if (program->child == NULL) {
char err[260];
snprintf(err, sizeof(err), "Error spawning child %s", name);
programFatalError(err);
@@ -2426,7 +2416,7 @@ static Program* forkProgram(Program* program)
char* name = programStackPopString(program);
Program* forked = runScript(name);
if (forked == nullptr) {
if (forked == NULL) {
char err[256];
snprintf(err, sizeof(err), "couldn't fork script '%s'", name);
programFatalError(err);
@@ -2451,19 +2441,19 @@ static void opExec(Program* program)
Program* parent = program->parent;
Program* fork = forkProgram(program);
if (parent != nullptr) {
if (parent != NULL) {
fork->parent = parent;
parent->child = fork;
}
fork->child = nullptr;
fork->child = NULL;
program->parent = nullptr;
program->parent = NULL;
program->flags |= PROGRAM_FLAG_EXITED;
// probably inlining due to check for null
parent = program->parent;
if (parent != nullptr) {
if (parent != NULL) {
if ((parent->flags & PROGRAM_FLAG_0x0100) != 0) {
parent->flags &= ~PROGRAM_FLAG_0x0100;
}
@@ -2478,9 +2468,9 @@ static void opCheckProcedureArgumentCount(Program* program)
int expectedArgumentCount = programStackPopInteger(program);
int procedureIndex = programStackPopInteger(program);
int actualArgumentCount = stackReadInt32(program->procedures + 4 + 24 * procedureIndex, offsetof(Procedure, argCount));
int actualArgumentCount = stackReadInt32(program->procedures + 4 + 24 * procedureIndex, 20);
if (actualArgumentCount != expectedArgumentCount) {
const char* identifier = programGetIdentifier(program, stackReadInt32(program->procedures + 4 + 24 * procedureIndex, offsetof(Procedure, nameOffset)));
const char* identifier = programGetIdentifier(program, stackReadInt32(program->procedures + 4 + 24 * procedureIndex, 0));
char err[260];
snprintf(err, sizeof(err), "Wrong number of args to procedure %s\n", identifier);
programFatalError(err);
@@ -2501,7 +2491,7 @@ static void opLookupStringProc(Program* program)
// Start with 1 since we've skipped main procedure, which is always at
// index 0.
for (int index = 1; index < procedureCount; index++) {
int offset = stackReadInt32(procedurePtr, offsetof(Procedure, nameOffset));
int offset = stackReadInt32(procedurePtr, 0);
const char* procedureName = programGetIdentifier(program, offset);
if (compat_stricmp(procedureName, procedureNameToLookup) == 0) {
programStackPushInteger(program, index);
@@ -2566,7 +2556,7 @@ void interpreterRegisterOpcodeHandlers()
interpreterRegisterOpcode(OPCODE_POP_BASE, opPopBase);
interpreterRegisterOpcode(OPCODE_POP_TO_BASE, opPopToBase);
interpreterRegisterOpcode(OPCODE_PUSH_BASE, opPushBase);
interpreterRegisterOpcode(OPCODE_SET_GLOBAL, opSetGlobal);
interpreterRegisterOpcode(OPCODE_SET_GLOBAL, op802C);
interpreterRegisterOpcode(OPCODE_FETCH_PROCEDURE_ADDRESS, opFetchProcedureAddress);
interpreterRegisterOpcode(OPCODE_DUMP, opDump);
interpreterRegisterOpcode(OPCODE_IF, opIf);
@@ -2657,7 +2647,7 @@ void _interpret(Program* program, int a2)
if ((program->flags & PROGRAM_IS_WAITING) != 0) {
_busy = 1;
if (program->checkWaitFunc != nullptr) {
if (program->checkWaitFunc != NULL) {
if (!program->checkWaitFunc(program)) {
_busy = 0;
continue;
@@ -2665,7 +2655,7 @@ void _interpret(Program* program, int a2)
}
_busy = 0;
program->checkWaitFunc = nullptr;
program->checkWaitFunc = NULL;
program->flags &= ~PROGRAM_IS_WAITING;
}
@@ -2683,7 +2673,7 @@ void _interpret(Program* program, int a2)
unsigned int opcodeIndex = opcode & 0x3FF;
OpcodeHandler* handler = gInterpreterOpcodeHandlers[opcodeIndex];
if (handler == nullptr) {
if (handler == NULL) {
snprintf(err, sizeof(err), "Undefined opcode %x.", opcode);
programFatalError(err);
}
@@ -2692,11 +2682,11 @@ void _interpret(Program* program, int a2)
}
if ((program->flags & PROGRAM_FLAG_EXITED) != 0) {
if (program->parent != nullptr) {
if (program->parent != NULL) {
if (program->parent->flags & PROGRAM_FLAG_0x20) {
program->parent->flags &= ~PROGRAM_FLAG_0x20;
program->parent->child = nullptr;
program->parent = nullptr;
program->parent->child = NULL;
program->parent = NULL;
}
}
}
@@ -2786,11 +2776,11 @@ void _executeProc(Program* program, int procedureIndex)
char err[256];
procedurePtr = program->procedures + 4 + sizeof(Procedure) * procedureIndex;
procedureFlags = stackReadInt32(procedurePtr, offsetof(Procedure, flags));
procedureFlags = stackReadInt32(procedurePtr, 4);
if ((procedureFlags & PROCEDURE_FLAG_IMPORTED) != 0) {
procedureIdentifier = programGetIdentifier(program, stackReadInt32(procedurePtr, offsetof(Procedure, nameOffset)));
procedureIdentifier = programGetIdentifier(program, stackReadInt32(procedurePtr, 0));
externalProgram = externalProcedureGetProgram(procedureIdentifier, &externalProcedureAddress, &externalProcedureArgumentCount);
if (externalProgram != nullptr) {
if (externalProgram != NULL) {
if (externalProcedureArgumentCount == 0) {
} else {
snprintf(err, sizeof(err), "External procedure cannot take arguments in interrupt context");
@@ -2805,7 +2795,7 @@ void _executeProc(Program* program, int procedureIndex)
_setupExternalCall(program, externalProgram, externalProcedureAddress, 28);
procedurePtr = externalProgram->procedures + 4 + sizeof(Procedure) * procedureIndex;
procedureFlags = stackReadInt32(procedurePtr, offsetof(Procedure, flags));
procedureFlags = stackReadInt32(procedurePtr, 4);
if ((procedureFlags & PROCEDURE_FLAG_CRITICAL) != 0) {
// NOTE: Uninline.
@@ -2813,7 +2803,7 @@ void _executeProc(Program* program, int procedureIndex)
_interpret(externalProgram, 0);
}
} else {
procedureAddress = stackReadInt32(procedurePtr, offsetof(Procedure, bodyOffset));
procedureAddress = stackReadInt32(procedurePtr, 16);
// NOTE: Uninline.
_setupCall(program, procedureAddress, 20);
@@ -2836,7 +2826,7 @@ int programFindProcedure(Program* program, const char* name)
unsigned char* ptr = program->procedures + 4;
for (int index = 0; index < procedureCount; index++) {
int identifierOffset = stackReadInt32(ptr, offsetof(Procedure, nameOffset));
int identifierOffset = stackReadInt32(ptr, offsetof(Procedure, field_0));
if (compat_stricmp((char*)(program->identifiers + identifierOffset), name) == 0) {
return index;
}
@@ -2861,12 +2851,12 @@ void _executeProcedure(Program* program, int procedureIndex)
jmp_buf env;
procedurePtr = program->procedures + 4 + sizeof(Procedure) * procedureIndex;
procedureFlags = stackReadInt32(procedurePtr, offsetof(Procedure, flags));
procedureFlags = stackReadInt32(procedurePtr, 4);
if ((procedureFlags & PROCEDURE_FLAG_IMPORTED) != 0) {
procedureIdentifier = programGetIdentifier(program, stackReadInt32(procedurePtr, offsetof(Procedure, nameOffset)));
procedureIdentifier = programGetIdentifier(program, stackReadInt32(procedurePtr, 0));
externalProgram = externalProcedureGetProgram(procedureIdentifier, &externalProcedureAddress, &externalProcedureArgumentCount);
if (externalProgram != nullptr) {
if (externalProgram != NULL) {
if (externalProcedureArgumentCount == 0) {
// NOTE: Uninline.
_setupExternalCall(program, externalProgram, externalProcedureAddress, 32);
@@ -2882,7 +2872,7 @@ void _executeProcedure(Program* program, int procedureIndex)
_interpretOutput(err);
}
} else {
procedureAddress = stackReadInt32(procedurePtr, offsetof(Procedure, bodyOffset));
procedureAddress = stackReadInt32(procedurePtr, 16);
// NOTE: Uninline.
_setupCall(program, procedureAddress, 24);
@@ -2913,19 +2903,19 @@ static void _doEvents()
programListNode = gInterpreterProgramListHead;
time = 1000 * _timerFunc() / _timerTick;
while (programListNode != nullptr) {
while (programListNode != NULL) {
procedureCount = stackReadInt32(programListNode->program->procedures, 0);
procedurePtr = programListNode->program->procedures + 4;
for (procedureIndex = 0; procedureIndex < procedureCount; procedureIndex++) {
procedureFlags = stackReadInt32(procedurePtr, offsetof(Procedure, flags));
procedureFlags = stackReadInt32(procedurePtr, 4);
if ((procedureFlags & PROCEDURE_FLAG_CONDITIONAL) != 0) {
memcpy(env, programListNode->program, sizeof(env));
oldProgramFlags = programListNode->program->flags;
oldInstructionPointer = programListNode->program->instructionPointer;
programListNode->program->flags = 0;
programListNode->program->instructionPointer = stackReadInt32(procedurePtr, offsetof(Procedure, conditionOffset));
programListNode->program->instructionPointer = stackReadInt32(procedurePtr, 12);
_interpret(programListNode->program, -1);
if ((programListNode->program->flags & PROGRAM_FLAG_0x04) == 0) {
@@ -2936,16 +2926,16 @@ static void _doEvents()
if (data != 0) {
// NOTE: Uninline.
stackWriteInt32(0, procedurePtr, offsetof(Procedure, flags));
stackWriteInt32(0, procedurePtr, 4);
_executeProc(programListNode->program, procedureIndex);
}
}
memcpy(programListNode->program, env, sizeof(env));
} else if ((procedureFlags & PROCEDURE_FLAG_TIMED) != 0) {
if ((unsigned int)stackReadInt32(procedurePtr, offsetof(Procedure, time)) < time) {
if ((unsigned int)stackReadInt32(procedurePtr, 8) < time) {
// NOTE: Uninline.
stackWriteInt32(0, procedurePtr, offsetof(Procedure, flags));
stackWriteInt32(0, procedurePtr, 4);
_executeProc(programListNode->program, procedureIndex);
}
}
@@ -2962,12 +2952,12 @@ static void programListNodeFree(ProgramListNode* programListNode)
ProgramListNode* tmp;
tmp = programListNode->next;
if (tmp != nullptr) {
if (tmp != NULL) {
tmp->prev = programListNode->prev;
}
tmp = programListNode->prev;
if (tmp != nullptr) {
if (tmp != NULL) {
tmp->next = programListNode->next;
} else {
gInterpreterProgramListHead = programListNode->next;
@@ -2983,9 +2973,9 @@ void programListNodeCreate(Program* program)
ProgramListNode* programListNode = (ProgramListNode*)internal_malloc_safe(sizeof(*programListNode), __FILE__, __LINE__); // .\\int\\INTRPRET.C, 2907
programListNode->program = program;
programListNode->next = gInterpreterProgramListHead;
programListNode->prev = nullptr;
programListNode->prev = NULL;
if (gInterpreterProgramListHead != nullptr) {
if (gInterpreterProgramListHead != NULL) {
gInterpreterProgramListHead->prev = programListNode;
}
@@ -3010,7 +3000,7 @@ Program* runScript(char* name)
// NOTE: Uninline.
program = programCreateByPath(_interpretMangleName(name));
if (program != nullptr) {
if (program != NULL) {
// NOTE: Uninline.
runProgram(program);
_interpret(program, 24);
@@ -3032,9 +3022,9 @@ void _updatePrograms()
sfall_gl_scr_update(_cpuBurstSize);
ProgramListNode* curr = gInterpreterProgramListHead;
while (curr != nullptr) {
while (curr != NULL) {
ProgramListNode* next = curr->next;
if (curr->program != nullptr) {
if (curr->program != NULL) {
_interpret(curr->program, _cpuBurstSize);
if (curr->program->exited) {
@@ -3051,7 +3041,7 @@ void _updatePrograms()
void programListFree()
{
ProgramListNode* curr = gInterpreterProgramListHead;
while (curr != nullptr) {
while (curr != NULL) {
ProgramListNode* next = curr->next;
programListNodeFree(curr);
curr = next;
@@ -3074,12 +3064,12 @@ void interpreterRegisterOpcode(int opcode, OpcodeHandler* handler)
static void interpreterPrintStats()
{
ProgramListNode* programListNode = gInterpreterProgramListHead;
while (programListNode != nullptr) {
while (programListNode != NULL) {
Program* program = programListNode->program;
if (program != nullptr) {
if (program != NULL) {
int total = 0;
if (program->dynamicStrings != nullptr) {
if (program->dynamicStrings != NULL) {
debugPrint("Program %s\n");
unsigned char* heap = program->dynamicStrings + sizeof(int);
@@ -3204,7 +3194,7 @@ void* programStackPopPointer(Program* program)
// uninitialized exported variables designed to hold objects (pointers).
// If this is one theses places simply return NULL.
if (programValue.opcode == VALUE_TYPE_INT && programValue.integerValue == 0) {
return nullptr;
return NULL;
}
if (programValue.opcode != VALUE_TYPE_PTR) {
+6 -6
View File
@@ -133,12 +133,12 @@ enum RawValueType {
typedef unsigned short opcode_t;
typedef struct Procedure {
int nameOffset;
int flags;
int time;
int conditionOffset;
int bodyOffset;
int argCount;
int field_0;
int field_4;
int field_8;
int field_C;
int field_10;
int field_14;
} Procedure;
class ProgramValue {
+201 -197
View File
File diff suppressed because it is too large Load Diff
+50 -50
View File
@@ -171,7 +171,7 @@ void opFillWin3x3(Program* program)
int imageWidth;
int imageHeight;
unsigned char* imageData = datafileRead(mangledFileName, &imageWidth, &imageHeight);
if (imageData == nullptr) {
if (imageData == NULL) {
programFatalError("cannot load 3x3 file '%s'", mangledFileName);
}
@@ -250,11 +250,11 @@ void opSelectFileList(Program* program)
int fileListLength;
char** fileList = _getFileList(_interpretMangleName(pattern), &fileListLength);
if (fileList != nullptr && fileListLength != 0) {
if (fileList != NULL && fileListLength != 0) {
int selectedIndex = _win_list_select(title,
fileList,
fileListLength,
nullptr,
NULL,
320 - fontGetStringWidth(title) / 2,
200,
_colorTable[0x7FFF] | 0x10000);
@@ -281,7 +281,7 @@ void opTokenize(Program* program)
ProgramValue prevValue = programStackPopValue(program);
char* prev = nullptr;
char* prev = NULL;
if ((prevValue.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_INT) {
if (prevValue.integerValue != 0) {
programFatalError("Error, invalid arg 2 to tokenize. (only accept 0 for int value)");
@@ -293,11 +293,11 @@ void opTokenize(Program* program)
}
char* string = programStackPopString(program);
char* temp = nullptr;
char* temp = NULL;
if (prev != nullptr) {
if (prev != NULL) {
char* start = strstr(string, prev);
if (start != nullptr) {
if (start != NULL) {
start += strlen(prev);
while (*start != ch && *start != '\0') {
start++;
@@ -326,7 +326,7 @@ void opTokenize(Program* program)
length++;
}
if (string != nullptr) {
if (string != NULL) {
temp = (char*)internal_calloc_safe(1, length + 1, __FILE__, __LINE__); // "..\\int\\INTLIB.C", 248
strncpy(temp, string, length);
programStackPushString(program, temp);
@@ -335,7 +335,7 @@ void opTokenize(Program* program)
}
}
if (temp != nullptr) {
if (temp != NULL) {
internal_free_safe(temp, __FILE__, __LINE__); // "..\\int\\INTLIB.C" , 260
}
}
@@ -589,7 +589,7 @@ void opPlayMovie(Program* program)
strcpy(gIntLibPlayMovieFileName, movieFileName);
if (strrchr(gIntLibPlayMovieFileName, '.') == nullptr) {
if (strrchr(gIntLibPlayMovieFileName, '.') == NULL) {
strcat(gIntLibPlayMovieFileName, ".mve");
}
@@ -616,7 +616,7 @@ void opPlayMovieRect(Program* program)
strcpy(gIntLibPlayMovieRectFileName, movieFileName);
if (strrchr(gIntLibPlayMovieRectFileName, '.') == nullptr) {
if (strrchr(gIntLibPlayMovieRectFileName, '.') == NULL) {
strcat(gIntLibPlayMovieRectFileName, ".mve");
}
@@ -659,7 +659,7 @@ static void opDeleteRegion(Program* program)
_selectWindowID(program->windowId);
const char* regionName = value.integerValue != -1 ? programGetString(program, value.opcode, value.integerValue) : nullptr;
const char* regionName = value.integerValue != -1 ? programGetString(program, value.opcode, value.integerValue) : NULL;
_windowDeleteRegion(regionName);
}
@@ -858,7 +858,7 @@ static void opSayReplyTitle(Program* program)
{
ProgramValue value = programStackPopValue(program);
char* string = nullptr;
char* string = NULL;
if ((value.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_STRING) {
string = programGetString(program, value.opcode, value.integerValue);
}
@@ -874,7 +874,7 @@ static void opSayGoToReply(Program* program)
{
ProgramValue value = programStackPopValue(program);
char* string = nullptr;
char* string = NULL;
if ((value.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_STRING) {
string = programGetString(program, value.opcode, value.integerValue);
}
@@ -897,7 +897,7 @@ void opSayReply(Program* program)
if ((v2.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_STRING) {
v1 = programGetString(program, v2.opcode, v2.integerValue);
} else {
v1 = nullptr;
v1 = NULL;
}
if ((v3.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_STRING) {
@@ -930,14 +930,14 @@ void opSayOption(Program* program)
if ((v4.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_STRING) {
v1 = programGetString(program, v4.opcode, v4.integerValue);
} else {
v1 = nullptr;
v1 = NULL;
}
const char* v2;
if ((v3.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_STRING) {
v2 = programGetString(program, v3.opcode, v3.integerValue);
} else {
v2 = nullptr;
v2 = NULL;
}
if (_dialogReply(v1, v2) != 0) {
@@ -1028,14 +1028,14 @@ void opSayMessage(Program* program)
if ((v4.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_STRING) {
v1 = programGetString(program, v4.opcode, v4.integerValue);
} else {
v1 = nullptr;
v1 = NULL;
}
const char* v2;
if ((v3.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_STRING) {
v2 = programGetString(program, v3.opcode, v3.integerValue);
} else {
v2 = nullptr;
v2 = NULL;
}
if (sub_430FD4(v1, v2, _TimeOut) != 0) {
@@ -1201,7 +1201,7 @@ static void opDeleteButton(Program* program)
_selectWindowID(program->windowId);
if ((value.opcode & 0xF7FF) == VALUE_TYPE_INT) {
if (_windowDeleteButton(nullptr)) {
if (_windowDeleteButton(NULL)) {
return;
}
} else {
@@ -1424,13 +1424,13 @@ static void opDeleteKey(Program* program)
if (key == -1) {
gIntLibGenericKeyHandlerProc = 0;
gIntLibGenericKeyHandlerProgram = nullptr;
gIntLibGenericKeyHandlerProgram = NULL;
} else {
if (key > INT_LIB_KEY_HANDLERS_CAPACITY - 1) {
programFatalError("Key out of range");
}
gIntLibKeyHandlerEntries[key].program = nullptr;
gIntLibKeyHandlerEntries[key].program = NULL;
gIntLibKeyHandlerEntries[key].proc = 0;
}
}
@@ -1596,7 +1596,7 @@ void opSayReplyWindow(Program* program)
v1 = _interpretMangleName(v1);
v1 = strdup_safe(v1, __FILE__, __LINE__); // "..\\int\\INTLIB.C", 1510
} else if ((v2.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_INT && v2.integerValue == 0) {
v1 = nullptr;
v1 = NULL;
} else {
programFatalError("Invalid arg 5 given to sayreplywindow");
}
@@ -1644,7 +1644,7 @@ void opSayOptionWindow(Program* program)
v1 = _interpretMangleName(v1);
v1 = strdup_safe(v1, __FILE__, __LINE__); // "..\\int\\INTLIB.C", 1556
} else if ((v2.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_INT && v2.integerValue == 0) {
v1 = nullptr;
v1 = NULL;
} else {
programFatalError("Invalid arg 5 given to sayoptionwindow");
}
@@ -1677,10 +1677,10 @@ void opSayScrollUp(Program* program)
int y = programStackPopInteger(program);
int x = programStackPopInteger(program);
char* v1 = nullptr;
char* v2 = nullptr;
char* v3 = nullptr;
char* v4 = nullptr;
char* v1 = NULL;
char* v2 = NULL;
char* v3 = NULL;
char* v4 = NULL;
int v5 = 0;
if ((v6.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_INT) {
@@ -1749,10 +1749,10 @@ void opSayScrollDown(Program* program)
int y = programStackPopInteger(program);
int x = programStackPopInteger(program);
char* v1 = nullptr;
char* v2 = nullptr;
char* v3 = nullptr;
char* v4 = nullptr;
char* v1 = NULL;
char* v2 = NULL;
char* v3 = NULL;
char* v4 = NULL;
int v5 = 0;
if ((v6.opcode & VALUE_TYPE_MASK) == VALUE_TYPE_INT) {
@@ -1837,7 +1837,7 @@ static void intLibSoundCallback(void* userData, int a2)
{
if (a2 == 1) {
Sound** sound = (Sound**)userData;
*sound = nullptr;
*sound = NULL;
}
}
@@ -1854,7 +1854,7 @@ static int intLibSoundDelete(int value)
int index = value & ~0xA0000000;
Sound* sound = gIntLibSounds[index];
if (sound == nullptr) {
if (sound == NULL) {
return 0;
}
@@ -1864,7 +1864,7 @@ static int intLibSoundDelete(int value)
soundDelete(sound);
gIntLibSounds[index] = nullptr;
gIntLibSounds[index] = NULL;
return 1;
}
@@ -1899,7 +1899,7 @@ static int intLibSoundPlay(char* fileName, int mode)
int index;
for (index = 0; index < INT_LIB_SOUNDS_CAPACITY; index++) {
if (gIntLibSounds[index] == nullptr) {
if (gIntLibSounds[index] == NULL) {
break;
}
}
@@ -1909,7 +1909,7 @@ static int intLibSoundPlay(char* fileName, int mode)
}
Sound* sound = gIntLibSounds[index] = soundAllocate(type, soundFlags);
if (sound == nullptr) {
if (sound == NULL) {
return -1;
}
@@ -1984,7 +1984,7 @@ static int intLibSoundPlay(char* fileName, int mode)
err:
soundDelete(sound);
gIntLibSounds[index] = nullptr;
gIntLibSounds[index] = NULL;
return -1;
}
@@ -2001,7 +2001,7 @@ static int intLibSoundPause(int value)
int index = value & ~0xA0000000;
Sound* sound = gIntLibSounds[index];
if (sound == nullptr) {
if (sound == NULL) {
return 0;
}
@@ -2027,7 +2027,7 @@ static int intLibSoundRewind(int value)
int index = value & ~0xA0000000;
Sound* sound = gIntLibSounds[index];
if (sound == nullptr) {
if (sound == NULL) {
return 0;
}
@@ -2053,7 +2053,7 @@ static int intLibSoundResume(int value)
int index = value & ~0xA0000000;
Sound* sound = gIntLibSounds[index];
if (sound == nullptr) {
if (sound == NULL) {
return 0;
}
@@ -2152,16 +2152,16 @@ void intLibExit()
_intExtraClose_();
for (int index = 0; index < INT_LIB_SOUNDS_CAPACITY; index++) {
if (gIntLibSounds[index] != nullptr) {
if (gIntLibSounds[index] != NULL) {
intLibSoundDelete(index | 0xA0000000);
}
}
_nevs_close();
if (gIntLibProgramDeleteCallbacks != nullptr) {
if (gIntLibProgramDeleteCallbacks != NULL) {
internal_free_safe(gIntLibProgramDeleteCallbacks, __FILE__, __LINE__); // "..\\int\\INTLIB.C", 1976
gIntLibProgramDeleteCallbacks = nullptr;
gIntLibProgramDeleteCallbacks = NULL;
gIntLibProgramDeleteCallbacksLength = 0;
}
}
@@ -2173,7 +2173,7 @@ static bool intLibDoInput(int key)
return false;
}
if (gIntLibGenericKeyHandlerProgram != nullptr) {
if (gIntLibGenericKeyHandlerProgram != NULL) {
if (gIntLibGenericKeyHandlerProc != 0) {
_executeProc(gIntLibGenericKeyHandlerProgram, gIntLibGenericKeyHandlerProc);
}
@@ -2181,7 +2181,7 @@ static bool intLibDoInput(int key)
}
IntLibKeyHandlerEntry* entry = &(gIntLibKeyHandlerEntries[key]);
if (entry->program == nullptr) {
if (entry->program == NULL) {
return false;
}
@@ -2291,13 +2291,13 @@ void intLibRegisterProgramDeleteCallback(IntLibProgramDeleteCallback* callback)
{
int index;
for (index = 0; index < gIntLibProgramDeleteCallbacksLength; index++) {
if (gIntLibProgramDeleteCallbacks[index] == nullptr) {
if (gIntLibProgramDeleteCallbacks[index] == NULL) {
break;
}
}
if (index == gIntLibProgramDeleteCallbacksLength) {
if (gIntLibProgramDeleteCallbacks != nullptr) {
if (gIntLibProgramDeleteCallbacks != NULL) {
gIntLibProgramDeleteCallbacks = (IntLibProgramDeleteCallback**)internal_realloc_safe(gIntLibProgramDeleteCallbacks, sizeof(*gIntLibProgramDeleteCallbacks) * (gIntLibProgramDeleteCallbacksLength + 1), __FILE__, __LINE__); // ..\\int\\INTLIB.C, 2110
} else {
gIntLibProgramDeleteCallbacks = (IntLibProgramDeleteCallback**)internal_malloc_safe(sizeof(*gIntLibProgramDeleteCallbacks), __FILE__, __LINE__); // ..\\int\\INTLIB.C, 2112
@@ -2313,7 +2313,7 @@ void intLibRemoveProgramReferences(Program* program)
{
for (int index = 0; index < INT_LIB_KEY_HANDLERS_CAPACITY; index++) {
if (program == gIntLibKeyHandlerEntries[index].program) {
gIntLibKeyHandlerEntries[index].program = nullptr;
gIntLibKeyHandlerEntries[index].program = NULL;
}
}
@@ -2321,7 +2321,7 @@ void intLibRemoveProgramReferences(Program* program)
for (int index = 0; index < gIntLibProgramDeleteCallbacksLength; index++) {
IntLibProgramDeleteCallback* callback = gIntLibProgramDeleteCallbacks[index];
if (callback != nullptr) {
if (callback != NULL) {
callback(program);
}
}
+728 -740
View File
File diff suppressed because it is too large Load Diff
+15 -29
View File
@@ -5,42 +5,28 @@
namespace fallout {
typedef enum Hand {
// Item1 (Punch)
HAND_LEFT,
// Item2 (Kick)
HAND_RIGHT,
HAND_COUNT,
} Hand;
typedef void InventoryPrintItemDescriptionHandler(char* string);
void _inven_reset_dude();
void inventoryOpen();
void _adjust_ac(Object* critter, Object* oldArmor, Object* newArmor);
void inventoryOpenUseItemOn(Object* targetObj);
Object* critterGetItem2(Object* critter);
Object* critterGetItem1(Object* critter);
Object* critterGetArmor(Object* critter);
void inventoryOpenUseItemOn(Object* a1);
Object* critterGetItem2(Object* obj);
Object* critterGetItem1(Object* obj);
Object* critterGetArmor(Object* obj);
Object* objectGetCarriedObjectByPid(Object* obj, int pid);
int objectGetCarriedQuantityByPid(Object* obj, int pid);
Object* _inven_find_type(Object* obj, int itemType, int* indexPtr);
Object* _inven_find_id(Object* obj, int id);
Object* _inven_index_ptr(Object* obj, int index);
// Makes critter equip a given item in a given hand slot with an animation.
// 0 - left hand, 1 - right hand. If item is armor, hand value is ignored.
int _inven_wield(Object* critter, Object* item, int hand);
// Same as inven_wield but allows to wield item without animation.
int _invenWieldFunc(Object* critter, Object* item, int hand, bool animate);
// Makes critter unequip an item in a given hand slot with an animation.
int _inven_unwield(Object* critter, int hand);
// Same as inven_unwield but allows to unwield item without animation.
int _invenUnwieldFunc(Object* critter, int hand, bool animate);
int inventoryOpenLooting(Object* looter, Object* target);
int inventoryOpenStealing(Object* thief, Object* target);
void inventoryOpenTrade(int win, Object* barterer, Object* playerTable, Object* bartererTable, int barterMod);
int _inven_set_timer(Object* item);
Object* inven_get_current_target_obj();
Object* _inven_find_type(Object* obj, int a2, int* inout_a3);
Object* _inven_find_id(Object* obj, int a2);
Object* _inven_index_ptr(Object* obj, int a2);
int _inven_wield(Object* a1, Object* a2, int a3);
int _invenWieldFunc(Object* a1, Object* a2, int a3, bool a4);
int _inven_unwield(Object* critter_obj, int a2);
int _invenUnwieldFunc(Object* obj, int a2, int a3);
int inventoryOpenLooting(Object* a1, Object* a2);
int inventoryOpenStealing(Object* a1, Object* a2);
void inventoryOpenTrade(int win, Object* a2, Object* a3, Object* a4, int a5);
int _inven_set_timer(Object* a1);
} // namespace fallout
+193 -191
View File
File diff suppressed because it is too large Load Diff
+47 -48
View File
@@ -15,7 +15,7 @@
namespace fallout {
static char* lips_fix_string(const char* fileName, size_t length);
static char* _lips_fix_string(const char* fileName, size_t length);
static int lipsReadV1(LipsData* a1, File* stream);
static int _lips_make_speech();
@@ -36,16 +36,16 @@ LipsData gLipsData = {
2,
22528,
0,
nullptr,
NULL,
-1,
nullptr,
nullptr,
0,
0,
0,
0,
0,
nullptr,
0,
0,
0,
0,
0,
50,
@@ -65,15 +65,14 @@ static int _speechStartTime = 0;
// 0x613CA0
static char _lips_subdir_name[14];
// 0x47AAC0
static char* lips_fix_string(const char* fileName, size_t length)
{
// 0x613CAE
static char tmp_str[50];
// 0x613CAE
static char _tmp_str[50];
strncpy(tmp_str, fileName, length);
tmp_str[length] = '\0';
return tmp_str;
// 0x47AAC0
static char* _lips_fix_string(const char* fileName, size_t length)
{
strncpy(_tmp_str, fileName, length);
return _tmp_str;
}
// 0x47AAD8
@@ -213,7 +212,7 @@ static int lipsReadV1(LipsData* lipsData, File* stream)
if (fileReadInt32(stream, &(lipsData->field_44)) == -1) return -1;
if (fileReadInt32(stream, &(lipsData->field_48)) == -1) return -1;
if (fileReadInt32(stream, &(lipsData->field_4C)) == -1) return -1;
if (fileReadFixedLengthString(stream, lipsData->file_name, 8) == -1) return -1;
if (fileReadFixedLengthString(stream, lipsData->field_50, 8) == -1) return -1;
if (fileReadFixedLengthString(stream, lipsData->field_58, 4) == -1) return -1;
if (fileReadFixedLengthString(stream, lipsData->field_5C, 4) == -1) return -1;
if (fileReadFixedLengthString(stream, lipsData->field_60, 4) == -1) return -1;
@@ -222,10 +221,10 @@ static int lipsReadV1(LipsData* lipsData, File* stream)
// NOTE: Original code is different. For unknown reason it assigns values
// from file (integers) and treat them as pointers, which is obviously wrong
// is in this case.
lipsData->sound = nullptr;
lipsData->field_14 = nullptr;
lipsData->phonemes = nullptr;
lipsData->markers = nullptr;
lipsData->sound = NULL;
lipsData->field_14 = NULL;
lipsData->phonemes = NULL;
lipsData->markers = NULL;
return 0;
}
@@ -236,7 +235,7 @@ int lipsLoad(const char* audioFileName, const char* headFileName)
{
char* sep;
int i;
char audioBaseName[16];
char v60[16];
SpeechMarker* speech_marker;
SpeechMarker* prev_speech_marker;
@@ -251,20 +250,20 @@ int lipsLoad(const char* audioFileName, const char* headFileName)
strcat(path, "\\");
sep = strchr(path, '.');
if (sep != nullptr) {
if (sep != NULL) {
*sep = '\0';
}
strcpy(audioBaseName, audioFileName);
strcpy(v60, audioFileName);
sep = strchr(audioBaseName, '.');
if (sep != nullptr) {
sep = strchr(v60, '.');
if (sep != NULL) {
*sep = '\0';
}
strncpy(gLipsData.file_name, audioBaseName, sizeof(gLipsData.file_name));
strcpy(gLipsData.field_50, v60);
strcat(path, lips_fix_string(gLipsData.file_name, sizeof(gLipsData.file_name)));
strcat(path, _lips_fix_string(gLipsData.field_50, sizeof(gLipsData.field_50)));
strcat(path, ".");
strcat(path, gLipsData.field_60);
@@ -272,7 +271,7 @@ int lipsLoad(const char* audioFileName, const char* headFileName)
// FIXME: stream is not closed if any error is encountered during reading.
File* stream = fileOpen(path, "rb");
if (stream != nullptr) {
if (stream != NULL) {
if (fileReadInt32(stream, &(gLipsData.version)) == -1) {
return -1;
}
@@ -297,7 +296,7 @@ int lipsLoad(const char* audioFileName, const char* headFileName)
if (fileReadInt32(stream, &(gLipsData.field_24)) == -1) return -1;
if (fileReadInt32(stream, &(gLipsData.field_28)) == -1) return -1;
if (fileReadInt32(stream, &(gLipsData.field_2C)) == -1) return -1;
if (fileReadFixedLengthString(stream, gLipsData.file_name, 8) == -1) return -1;
if (fileReadFixedLengthString(stream, gLipsData.field_50, 8) == -1) return -1;
if (fileReadFixedLengthString(stream, gLipsData.field_58, 4) == -1) return -1;
} else {
debugPrint("\nError: Lips file WRONG version: %s!", path);
@@ -305,12 +304,12 @@ int lipsLoad(const char* audioFileName, const char* headFileName)
}
gLipsData.phonemes = (unsigned char*)internal_malloc(gLipsData.field_24);
if (gLipsData.phonemes == nullptr) {
if (gLipsData.phonemes == NULL) {
debugPrint("Out of memory in lips_load_file.'\n");
return -1;
}
if (stream != nullptr) {
if (stream != NULL) {
for (i = 0; i < gLipsData.field_24; i++) {
if (fileReadUInt8(stream, &(gLipsData.phonemes[i])) == -1) {
debugPrint("lips_load_file: Error reading phoneme type.\n");
@@ -327,12 +326,12 @@ int lipsLoad(const char* audioFileName, const char* headFileName)
}
gLipsData.markers = (SpeechMarker*)internal_malloc(sizeof(*speech_marker) * gLipsData.field_2C);
if (gLipsData.markers == nullptr) {
if (gLipsData.markers == NULL) {
debugPrint("Out of memory in lips_load_file.'\n");
return -1;
}
if (stream != nullptr) {
if (stream != NULL) {
for (i = 0; i < gLipsData.field_2C; i++) {
speech_marker = &(gLipsData.markers[i]);
@@ -369,7 +368,7 @@ int lipsLoad(const char* audioFileName, const char* headFileName)
}
}
if (stream != nullptr) {
if (stream != NULL) {
fileClose(stream);
}
@@ -400,34 +399,34 @@ int lipsLoad(const char* audioFileName, const char* headFileName)
// 0x47B5D0
static int _lips_make_speech()
{
if (gLipsData.field_14 != nullptr) {
if (gLipsData.field_14 != NULL) {
internal_free(gLipsData.field_14);
gLipsData.field_14 = nullptr;
gLipsData.field_14 = NULL;
}
char path[COMPAT_MAX_PATH];
char* v1 = lips_fix_string(gLipsData.file_name, sizeof(gLipsData.file_name));
char* v1 = _lips_fix_string(gLipsData.field_50, sizeof(gLipsData.field_50));
snprintf(path, sizeof(path), "%s%s\\%s.%s", "SOUND\\SPEECH\\", _lips_subdir_name, v1, "ACM");
if (gLipsData.sound != nullptr) {
if (gLipsData.sound != NULL) {
soundDelete(gLipsData.sound);
gLipsData.sound = nullptr;
gLipsData.sound = NULL;
}
gLipsData.sound = soundAllocate(SOUND_TYPE_MEMORY, SOUND_16BIT);
if (gLipsData.sound == nullptr) {
if (gLipsData.sound == NULL) {
debugPrint("\nsoundAllocate falied in lips_make_speech!");
return -1;
}
if (soundSetFileIO(gLipsData.sound, audioOpen, audioClose, audioRead, nullptr, audioSeek, nullptr, audioGetSize)) {
if (soundSetFileIO(gLipsData.sound, audioOpen, audioClose, audioRead, NULL, audioSeek, NULL, audioGetSize)) {
debugPrint("Ack!");
debugPrint("Error!");
}
if (soundLoad(gLipsData.sound, path)) {
soundDelete(gLipsData.sound);
gLipsData.sound = nullptr;
gLipsData.sound = NULL;
debugPrint("lips_make_speech: soundLoad failed with path ");
debugPrint("%s -- file probably doesn't exist.\n", path);
@@ -442,12 +441,12 @@ static int _lips_make_speech()
// 0x47B730
int lipsFree()
{
if (gLipsData.field_14 != nullptr) {
if (gLipsData.field_14 != NULL) {
internal_free(gLipsData.field_14);
gLipsData.field_14 = nullptr;
gLipsData.field_14 = NULL;
}
if (gLipsData.sound != nullptr) {
if (gLipsData.sound != NULL) {
_head_marker_current = 0;
soundStop(gLipsData.sound);
@@ -456,17 +455,17 @@ int lipsFree()
soundDelete(gLipsData.sound);
gLipsData.sound = nullptr;
gLipsData.sound = NULL;
}
if (gLipsData.phonemes != nullptr) {
if (gLipsData.phonemes != NULL) {
internal_free(gLipsData.phonemes);
gLipsData.phonemes = nullptr;
gLipsData.phonemes = NULL;
}
if (gLipsData.markers != nullptr) {
if (gLipsData.markers != NULL) {
internal_free(gLipsData.markers);
gLipsData.markers = nullptr;
gLipsData.markers = NULL;
}
return 0;
+1 -1
View File
@@ -40,7 +40,7 @@ typedef struct LipsData {
int field_44;
int field_48;
int field_4C;
char file_name[8];
char field_50[8];
char field_58[4];
char field_5C[4];
char field_60[4];
+214 -233
View File
File diff suppressed because it is too large Load Diff
+1 -2
View File
@@ -18,9 +18,8 @@ void _InitLoadSave();
void _ResetLoadSave();
int lsgSaveGame(int mode);
int lsgLoadGame(int mode);
bool _isLoadingGame();
int _isLoadingGame();
void lsgInit();
int MapDirErase(const char* path, const char* extension);
int _MapDirEraseFile_(const char* a1, const char* a2);
} // namespace fallout
+19 -19
View File
@@ -69,7 +69,7 @@ static char _mainMap[] = "artemple.map";
static int _main_game_paused = 0;
// 0x5194DC
static char** _main_selfrun_list = nullptr;
static char** _main_selfrun_list = NULL;
// 0x5194E0
static int _main_selfrun_count = 0;
@@ -127,7 +127,7 @@ int falloutMain(int argc, char** argv)
switch (mainMenuRc) {
case MAIN_MENU_INTRO:
mainMenuWindowHide(true);
gameMoviePlay(MOVIE_INTRO, GAME_MOVIE_STOP_MUSIC);
gameMoviePlay(MOVIE_INTRO, GAME_MOVIE_PAUSE_MUSIC);
gameMoviePlay(MOVIE_CREDITS, 0);
break;
case MAIN_MENU_NEW_GAME:
@@ -138,14 +138,14 @@ int falloutMain(int argc, char** argv)
randomSeedPrerandom(-1);
// SFALL: Override starting map.
char* mapName = nullptr;
char* mapName = NULL;
if (configGetString(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_STARTING_MAP_KEY, &mapName)) {
if (*mapName == '\0') {
mapName = nullptr;
mapName = NULL;
}
}
char* mapNameCopy = compat_strdup(mapName != nullptr ? mapName : _mainMap);
char* mapNameCopy = compat_strdup(mapName != NULL ? mapName : _mainMap);
_main_load_new(mapNameCopy);
free(mapNameCopy);
@@ -257,7 +257,7 @@ static bool falloutInit(int argc, char** argv)
return false;
}
if (_main_selfrun_list != nullptr) {
if (_main_selfrun_list != NULL) {
_main_selfrun_exit();
}
@@ -297,7 +297,7 @@ static int _main_load_new(char* mapFileName)
_game_user_wants_to_quit = 0;
_main_show_death_scene = 0;
gDude->flags &= ~OBJECT_FLAT;
objectShow(gDude, nullptr);
objectShow(gDude, NULL);
mouseHideCursor();
int win = windowCreate(0, 0, screenGetWidth(), screenGetHeight(), _colorTable[0], WINDOW_MODAL | WINDOW_MOVE_ON_TOP);
@@ -327,7 +327,7 @@ static int main_loadgame_new()
gDude->flags &= ~OBJECT_FLAT;
objectShow(gDude, nullptr);
objectShow(gDude, NULL);
mouseHideCursor();
_map_init();
@@ -341,7 +341,7 @@ static int main_loadgame_new()
// 0x480E34
static void main_unload_new()
{
objectHide(gDude, nullptr);
objectHide(gDude, NULL);
_map_exit();
}
@@ -395,13 +395,13 @@ static void mainLoop()
// 0x480F38
static void _main_selfrun_exit()
{
if (_main_selfrun_list != nullptr) {
if (_main_selfrun_list != NULL) {
selfrunFreeFileList(&_main_selfrun_list);
}
_main_selfrun_count = 0;
_main_selfrun_index = 0;
_main_selfrun_list = nullptr;
_main_selfrun_list = NULL;
}
// 0x480F64
@@ -413,7 +413,7 @@ static void _main_selfrun_record()
char** fileList;
int fileListLength = fileNameListInit("maps\\*.map", &fileList, 0, 0);
if (fileListLength != 0) {
int selectedFileIndex = _win_list_select("Select Map", fileList, fileListLength, nullptr, 80, 80, 0x10000 | 0x100 | 4);
int selectedFileIndex = _win_list_select("Select Map", fileList, fileListLength, 0, 80, 80, 0x10000 | 0x100 | 4);
if (selectedFileIndex != -1) {
// NOTE: It's size is likely 13 chars (on par with SelfrunData
// fields), but due to the padding it takes 16 chars on stack.
@@ -451,7 +451,7 @@ static void _main_selfrun_record()
mainMenuWindowInit();
if (_main_selfrun_list != nullptr) {
if (_main_selfrun_list != NULL) {
_main_selfrun_exit();
}
@@ -524,7 +524,7 @@ static void showDeath()
if (win != -1) {
do {
unsigned char* windowBuffer = windowGetBuffer(win);
if (windowBuffer == nullptr) {
if (windowBuffer == NULL) {
break;
}
@@ -603,7 +603,7 @@ static void showDeath()
sharedFpsLimiter.throttle();
} while (keyCode == -1 && !_main_death_voiceover_done && getTicksSince(time) < delay);
speechSetEndCallback(nullptr);
speechSetEndCallback(NULL);
speechDelete();
@@ -647,7 +647,7 @@ static void _main_death_voiceover_callback()
static int _mainDeathGrabTextFile(const char* fileName, char* dest)
{
const char* p = strrchr(fileName, '\\');
if (p == nullptr) {
if (p == NULL) {
return -1;
}
@@ -655,7 +655,7 @@ static int _mainDeathGrabTextFile(const char* fileName, char* dest)
snprintf(path, sizeof(path), "text\\%s\\cuts\\%s%s", settings.system.language.c_str(), p + 1, ".TXT");
File* stream = fileOpen(path, "rt");
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -684,7 +684,7 @@ static int _mainDeathWordWrap(char* text, int width, short* beginnings, short* c
{
while (true) {
char* sep = strchr(text, ':');
if (sep == nullptr) {
if (sep == NULL) {
break;
}
@@ -709,7 +709,7 @@ static int _mainDeathWordWrap(char* text, int width, short* beginnings, short* c
beginnings[index]--;
}
if (p != nullptr) {
if (p != NULL) {
*p = '\0';
beginnings[index]++;
}
+2 -2
View File
@@ -40,7 +40,7 @@ static void main_menu_play_sound(const char* fileName);
static int gMainMenuWindow = -1;
// 0x5194F4
static unsigned char* gMainMenuWindowBuffer = nullptr;
static unsigned char* gMainMenuWindowBuffer = NULL;
// 0x519504
static bool _in_main_menu = false;
@@ -189,7 +189,7 @@ int mainMenuWindowInit()
gMainMenuButtonKeyBindings[index],
_mainMenuButtonNormalFrmImage.getData(),
_mainMenuButtonPressedFrmImage.getData(),
nullptr,
0,
BUTTON_FLAG_TRANSPARENT);
if (gMainMenuButtons[index] == -1) {
// NOTE: Uninline.
+66 -69
View File
@@ -104,11 +104,11 @@ int gMapSid = -1;
// local_vars
// 0x519568
int* gMapLocalVars = nullptr;
int* gMapLocalVars = NULL;
// map_vars
// 0x51956C
int* gMapGlobalVars = nullptr;
static int* gMapGlobalVars = NULL;
// local_vars_num
// 0x519570
@@ -116,7 +116,7 @@ int gMapLocalVarsLength = 0;
// map_vars_num
// 0x519574
int gMapGlobalVarsLength = 0;
static int gMapGlobalVarsLength = 0;
// Current elevation.
//
@@ -187,7 +187,7 @@ int isoInit()
}
gIsoWindowBuffer = windowGetBuffer(gIsoWindow);
if (gIsoWindowBuffer == nullptr) {
if (gIsoWindowBuffer == NULL) {
debugPrint("win_get_buf failed in iso_init\n");
return -1;
}
@@ -373,7 +373,7 @@ int mapSetElevation(int elevation)
}
if (elevation != gElevation) {
wmMapMarkMapEntranceState(gMapHeader.index, elevation, 1);
wmMapMarkMapEntranceState(gMapHeader.field_34, elevation, 1);
}
gElevation = elevation;
@@ -478,7 +478,7 @@ int _map_malloc_local_var(int a1)
gMapLocalVarsLength += a1;
int* vars = (int*)internal_realloc(gMapLocalVars, sizeof(*vars) * gMapLocalVarsLength);
if (vars == nullptr) {
if (vars == NULL) {
debugPrint("\nError: Ran out of memory!");
}
@@ -502,11 +502,11 @@ void mapSetStart(int tile, int elevation, int rotation)
char* mapGetName(int map, int elevation)
{
if (map < 0 || map >= wmMapMaxCount()) {
return nullptr;
return NULL;
}
if (!elevationIsValid(elevation)) {
return nullptr;
return NULL;
}
MessageListItem messageListItem;
@@ -596,7 +596,7 @@ char* _map_get_description_idx_(int map)
// 0x4826B8
int mapGetCurrentMap()
{
return gMapHeader.index;
return gMapHeader.field_34;
}
// 0x4826C0
@@ -760,7 +760,7 @@ int mapLoadByName(char* fileName)
rc = -1;
char* extension = strstr(fileName, ".MAP");
if (extension != nullptr) {
if (extension != NULL) {
strcpy(extension, ".SAV");
const char* filePath = mapBuildPath(fileName);
@@ -769,7 +769,7 @@ int mapLoadByName(char* fileName)
strcpy(extension, ".MAP");
if (stream != nullptr) {
if (stream != NULL) {
fileClose(stream);
rc = mapLoadSaved(fileName);
wmMapMusicStart();
@@ -779,14 +779,14 @@ int mapLoadByName(char* fileName)
if (rc == -1) {
const char* filePath = mapBuildPath(fileName);
File* stream = fileOpen(filePath, "rb");
if (stream != nullptr) {
if (stream != NULL) {
rc = mapLoad(stream);
fileClose(stream);
}
if (rc == 0) {
strcpy(gMapHeader.name, fileName);
gDude->data.critter.combat.whoHitMe = nullptr;
gDude->data.critter.combat.whoHitMe = NULL;
}
}
@@ -840,10 +840,10 @@ static int mapLoad(File* stream)
gMapSid = -1;
const char* error = nullptr;
const char* error = NULL;
error = "Invalid file handle";
if (stream == nullptr) {
if (stream == NULL) {
goto err;
}
@@ -925,20 +925,20 @@ static int mapLoad(File* stream)
}
lightSetAmbientIntensity(LIGHT_INTENSITY_MAX, false);
objectSetLocation(gDude, gCenterTile, gElevation, nullptr);
objectSetRotation(gDude, gEnteringRotation, nullptr);
gMapHeader.index = wmMapMatchNameToIdx(gMapHeader.name);
objectSetLocation(gDude, gCenterTile, gElevation, NULL);
objectSetRotation(gDude, gEnteringRotation, NULL);
gMapHeader.field_34 = wmMapMatchNameToIdx(gMapHeader.name);
if ((gMapHeader.flags & 1) == 0) {
char path[COMPAT_MAX_PATH];
snprintf(path, sizeof(path), "maps\\%s", gMapHeader.name);
char* extension = strstr(path, ".MAP");
if (extension == nullptr) {
if (extension == NULL) {
extension = strstr(path, ".map");
}
if (extension != nullptr) {
if (extension != NULL) {
*extension = '\0';
}
@@ -959,16 +959,16 @@ static int mapLoad(File* stream)
int fid = buildFid(OBJ_TYPE_MISC, 12, 0, 0, 0);
objectCreateWithFidPid(&object, fid, -1);
object->flags |= (OBJECT_LIGHT_THRU | OBJECT_NO_SAVE | OBJECT_HIDDEN);
objectSetLocation(object, 1, 0, nullptr);
objectSetLocation(object, 1, 0, NULL);
object->sid = gMapSid;
scriptSetFixedParam(gMapSid, (gMapHeader.flags & 1) == 0);
Script* script;
scriptGetScript(gMapSid, &script);
script->index = gMapHeader.scriptIndex - 1;
script->field_14 = gMapHeader.scriptIndex - 1;
script->flags |= SCRIPT_FLAG_0x08;
object->id = scriptsNewObjectId();
script->ownerId = object->id;
script->field_1C = object->id;
script->owner = object;
_scr_spatials_disable();
scriptExecProc(gMapSid, SCRIPT_PROC_MAP_ENTER);
@@ -980,11 +980,11 @@ static int mapLoad(File* stream)
}
}
error = nullptr;
error = NULL;
err:
if (error != nullptr) {
if (error != NULL) {
char message[100]; // TODO: Size is probably wrong.
snprintf(message, sizeof(message), "%s while loading map.", error);
debugPrint(message);
@@ -998,7 +998,7 @@ err:
interfaceBarShow();
_proto_dude_update_gender();
_map_place_dude_and_mouse();
fileSetReadProgressHandler(nullptr, 0);
fileSetReadProgressHandler(NULL, 0);
isoEnable();
_gmouse_disable_scrolling();
gameMouseSetCursor(MOUSE_CURSOR_WAIT_PLANET);
@@ -1013,7 +1013,7 @@ err:
if (gMapTransition.map > 0) {
if (gMapTransition.rotation >= 0) {
objectSetRotation(gDude, gMapTransition.rotation, nullptr);
objectSetRotation(gDude, gMapTransition.rotation, NULL);
}
} else {
tileWindowRefresh();
@@ -1025,14 +1025,14 @@ err:
rc = -1;
}
wmMapMarkVisited(gMapHeader.index);
wmMapMarkMapEntranceState(gMapHeader.index, gElevation, 1);
wmMapMarkVisited(gMapHeader.field_34);
wmMapMarkMapEntranceState(gMapHeader.field_34, gElevation, 1);
if (wmCheckGameAreaEvents() != 0) {
rc = -1;
}
fileSetReadProgressHandler(nullptr, 0);
fileSetReadProgressHandler(NULL, 0);
if (gameUiIsDisabled() == 0) {
_gmouse_enable_scrolling();
@@ -1100,7 +1100,7 @@ static int _map_age_dead_critters()
}
Object* obj = objectFindFirst();
while (obj != nullptr) {
while (obj != NULL) {
if (PID_TYPE(obj->pid) == OBJ_TYPE_CRITTER
&& obj != gDude
&& !objectIsPartyMember(obj)
@@ -1127,7 +1127,7 @@ static int _map_age_dead_critters()
Object** objects = (Object**)internal_malloc(sizeof(*objects) * capacity);
obj = objectFindFirst();
while (obj != nullptr) {
while (obj != NULL) {
int type = PID_TYPE(obj->pid);
if (type == OBJ_TYPE_CRITTER) {
if (obj != gDude && critterIsDead(obj)) {
@@ -1137,7 +1137,7 @@ static int _map_age_dead_critters()
if (count >= capacity) {
capacity *= 2;
objects = (Object**)internal_realloc(objects, sizeof(*objects) * capacity);
if (objects == nullptr) {
if (objects == NULL) {
debugPrint("\nError: Out of Memory!");
return -1;
}
@@ -1149,7 +1149,7 @@ static int _map_age_dead_critters()
if (count >= capacity) {
capacity *= 2;
objects = (Object**)internal_realloc(objects, sizeof(*objects) * capacity);
if (objects == nullptr) {
if (objects == NULL) {
debugPrint("\nError: Out of Memory!");
return -1;
}
@@ -1172,7 +1172,7 @@ static int _map_age_dead_critters()
break;
}
objectSetLocation(blood, obj->tile, obj->elevation, nullptr);
objectSetLocation(blood, obj->tile, obj->elevation, NULL);
Proto* proto;
protoGetProto(obj->pid, &proto);
@@ -1187,11 +1187,11 @@ static int _map_age_dead_critters()
}
}
objectSetFrame(blood, frame, nullptr);
objectSetFrame(blood, frame, NULL);
}
reg_anim_clear(obj);
objectDestroy(obj, nullptr);
objectDestroy(obj, NULL);
}
internal_free(objects);
@@ -1203,7 +1203,7 @@ static int _map_age_dead_critters()
int _map_target_load_area()
{
int city = -1;
if (wmMatchAreaContainingMapIdx(gMapHeader.index, &city) == -1) {
if (wmMatchAreaContainingMapIdx(gMapHeader.field_34, &city) == -1) {
city = -1;
}
return city;
@@ -1212,7 +1212,7 @@ int _map_target_load_area()
// 0x4835B4
int mapSetTransition(MapTransition* transition)
{
if (transition == nullptr) {
if (transition == NULL) {
return -1;
}
@@ -1254,19 +1254,16 @@ int mapHandleTransition()
}
} else {
if (!isInCombat()) {
if (gMapTransition.map != gMapHeader.index || gElevation == gMapTransition.elevation) {
// SFALL: Remove text floaters after moving to another map.
textObjectsReset();
if (gMapTransition.map != gMapHeader.field_34 || gElevation == gMapTransition.elevation) {
mapLoadById(gMapTransition.map);
}
if (gMapTransition.tile != -1 && gMapTransition.tile != 0
&& gMapHeader.index != MAP_MODOC_BEDNBREAKFAST && gMapHeader.index != MAP_THE_SQUAT_A
&& gMapHeader.field_34 != MAP_MODOC_BEDNBREAKFAST && gMapHeader.field_34 != MAP_THE_SQUAT_A
&& elevationIsValid(gMapTransition.elevation)) {
objectSetLocation(gDude, gMapTransition.tile, gMapTransition.elevation, nullptr);
objectSetLocation(gDude, gMapTransition.tile, gMapTransition.elevation, NULL);
mapSetElevation(gMapTransition.elevation);
objectSetRotation(gDude, gMapTransition.rotation, nullptr);
objectSetRotation(gDude, gMapTransition.rotation, NULL);
}
if (tileSetCenter(gDude->tile, TILE_SET_CENTER_REFRESH_WINDOW) == -1) {
@@ -1276,7 +1273,7 @@ int mapHandleTransition()
memset(&gMapTransition, 0, sizeof(gMapTransition));
int city;
wmMatchAreaContainingMapIdx(gMapHeader.index, &city);
wmMatchAreaContainingMapIdx(gMapHeader.field_34, &city);
if (wmTeleportToArea(city) == -1) {
debugPrint("\nError: couldn't make jump on worldmap for map jump!");
}
@@ -1289,7 +1286,7 @@ int mapHandleTransition()
// 0x483784
static void _map_fix_critter_combat_data()
{
for (Object* object = objectFindFirst(); object != nullptr; object = objectFindNext()) {
for (Object* object = objectFindFirst(); object != NULL; object = objectFindNext()) {
if (object->pid == -1) {
continue;
}
@@ -1299,7 +1296,7 @@ static void _map_fix_critter_combat_data()
}
if (object->data.critter.combat.whoHitMeCid == -1) {
object->data.critter.combat.whoHitMe = nullptr;
object->data.critter.combat.whoHitMe = NULL;
}
}
}
@@ -1321,7 +1318,7 @@ static int _map_save()
if (gMapHeader.name[0] != '\0') {
char* mapFileName = mapBuildPath(gMapHeader.name);
File* stream = fileOpen(mapFileName, "wb");
if (stream != nullptr) {
if (stream != NULL) {
rc = _map_save_file(stream);
fileClose(stream);
} else {
@@ -1343,7 +1340,7 @@ static int _map_save()
// 0x483980
static int _map_save_file(File* stream)
{
if (stream == nullptr) {
if (stream == NULL) {
return -1;
}
@@ -1367,13 +1364,13 @@ static int _map_save_file(File* stream)
if (tile == SQUARE_GRID_SIZE) {
Object* object = objectFindFirstAtElevation(elevation);
if (object != nullptr) {
if (object != NULL) {
// TODO: Implementation is slightly different, check in debugger.
while (object != nullptr && (object->flags & OBJECT_NO_SAVE)) {
while (object != NULL && (object->flags & OBJECT_NO_SAVE)) {
object = objectFindNextAtElevation();
}
if (object != nullptr) {
if (object != NULL) {
gMapHeader.flags &= ~_map_data_elev_flags[elevation];
} else {
gMapHeader.flags |= _map_data_elev_flags[elevation];
@@ -1555,7 +1552,7 @@ static int mapGlobalVariablesInit(int count)
if (count != 0) {
gMapGlobalVars = (int*)internal_malloc(sizeof(*gMapGlobalVars) * count);
if (gMapGlobalVars == nullptr) {
if (gMapGlobalVars == NULL) {
return -1;
}
@@ -1570,9 +1567,9 @@ static int mapGlobalVariablesInit(int count)
// 0x484038
static void mapGlobalVariablesFree()
{
if (gMapGlobalVars != nullptr) {
if (gMapGlobalVars != NULL) {
internal_free(gMapGlobalVars);
gMapGlobalVars = nullptr;
gMapGlobalVars = NULL;
gMapGlobalVarsLength = 0;
}
@@ -1600,7 +1597,7 @@ static int mapLocalVariablesInit(int count)
if (count != 0) {
gMapLocalVars = (int*)internal_malloc(sizeof(*gMapLocalVars) * count);
if (gMapLocalVars == nullptr) {
if (gMapLocalVars == NULL) {
return -1;
}
@@ -1615,9 +1612,9 @@ static int mapLocalVariablesInit(int count)
// 0x4840D4
static void mapLocalVariablesFree()
{
if (gMapLocalVars != nullptr) {
if (gMapLocalVars != NULL) {
internal_free(gMapLocalVars);
gMapLocalVars = nullptr;
gMapLocalVars = NULL;
gMapLocalVarsLength = 0;
}
@@ -1641,18 +1638,18 @@ static void _map_place_dude_and_mouse()
{
_obj_clear_seen();
if (gDude != nullptr) {
if (gDude != NULL) {
if (FID_ANIM_TYPE(gDude->fid) != ANIM_STAND) {
objectSetFrame(gDude, 0, nullptr);
objectSetFrame(gDude, 0, 0);
gDude->fid = buildFid(OBJ_TYPE_CRITTER, gDude->fid & 0xFFF, ANIM_STAND, (gDude->fid & 0xF000) >> 12, gDude->rotation + 1);
}
if (gDude->tile == -1) {
objectSetLocation(gDude, gCenterTile, gElevation, nullptr);
objectSetRotation(gDude, gMapHeader.enteringRotation, nullptr);
objectSetLocation(gDude, gCenterTile, gElevation, NULL);
objectSetRotation(gDude, gMapHeader.enteringRotation, 0);
}
objectSetLight(gDude, 4, 0x10000, nullptr);
objectSetLight(gDude, 4, 0x10000, 0);
gDude->flags |= OBJECT_NO_SAVE;
_dude_stand(gDude, gDude->rotation, gDude->fid);
@@ -1748,8 +1745,8 @@ static int mapHeaderWrite(MapHeader* ptr, File* stream)
if (fileWriteInt32(stream, ptr->flags) == -1) return -1;
if (fileWriteInt32(stream, ptr->darkness) == -1) return -1;
if (fileWriteInt32(stream, ptr->globalVariablesCount) == -1) return -1;
if (fileWriteInt32(stream, ptr->index) == -1) return -1;
if (fileWriteUInt32(stream, ptr->lastVisitTime) == -1) return -1;
if (fileWriteInt32(stream, ptr->field_34) == -1) return -1;
if (fileWriteInt32(stream, ptr->lastVisitTime) == -1) return -1;
if (fileWriteInt32List(stream, ptr->field_3C, 44) == -1) return -1;
return 0;
@@ -1768,8 +1765,8 @@ static int mapHeaderRead(MapHeader* ptr, File* stream)
if (fileReadInt32(stream, &(ptr->flags)) == -1) return -1;
if (fileReadInt32(stream, &(ptr->darkness)) == -1) return -1;
if (fileReadInt32(stream, &(ptr->globalVariablesCount)) == -1) return -1;
if (fileReadInt32(stream, &(ptr->index)) == -1) return -1;
if (fileReadUInt32(stream, &(ptr->lastVisitTime)) == -1) return -1;
if (fileReadInt32(stream, &(ptr->field_34)) == -1) return -1;
if (fileReadInt32(stream, &(ptr->lastVisitTime)) == -1) return -1;
if (fileReadInt32List(stream, ptr->field_3C, 44) == -1) return -1;
return 0;
+2 -4
View File
@@ -51,10 +51,10 @@ typedef struct MapHeader {
int globalVariablesCount;
// map_number
int index;
int field_34;
// Time in game ticks when PC last visited this map.
unsigned int lastVisitTime;
int lastVisitTime;
int field_3C[44];
} MapHeader;
@@ -69,9 +69,7 @@ typedef void IsoWindowRefreshProc(Rect* rect);
extern int gMapSid;
extern int* gMapLocalVars;
extern int* gMapGlobalVars;
extern int gMapLocalVarsLength;
extern int gMapGlobalVarsLength;
extern int gElevation;
extern MessageList gMapMessageList;
-180
View File
@@ -1,180 +0,0 @@
#include "mapper/map_func.h"
#include "actions.h"
#include "color.h"
#include "game_mouse.h"
#include "input.h"
#include "map.h"
#include "memory.h"
#include "mouse.h"
#include "proto.h"
#include "svga.h"
#include "tile.h"
#include "window_manager.h"
#include "window_manager_private.h"
namespace fallout {
// 0x5595CC
static bool block_obj_view_on = false;
// 0x4825B0
void setup_map_dirs()
{
// TODO: Incomplete.
}
// 0x4826B4
void copy_proto_lists()
{
// TODO: Incomplete.
}
// 0x482708
void place_entrance_hex()
{
int x;
int y;
int tile;
while (inputGetInput() != -2) {
}
if ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_DOWN) != 0) {
if (_mouse_click_in(0, 0, _scr_size.right - _scr_size.left, _scr_size.bottom - _scr_size.top - 100)) {
mouseGetPosition(&x, &y);
tile = tileFromScreenXY(x, y, gElevation);
if (tile != -1) {
if (tileSetCenter(tile, TILE_SET_CENTER_FLAG_IGNORE_SCROLL_RESTRICTIONS) == 0) {
mapSetEnteringLocation(tile, gElevation, rotation);
} else {
win_timed_msg("ERROR: Entrance out of range!", _colorTable[31744]);
}
}
}
}
}
// 0x4841C4
void pick_region(Rect* rect)
{
Rect temp;
int x;
int y;
gameMouseSetCursor(MOUSE_CURSOR_PLUS);
gameMouseObjectsHide();
while (1) {
if (inputGetInput() == -2
&& (mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_DOWN) != 0) {
break;
}
}
get_input_position(&x, &y);
temp.left = x;
temp.top = y;
temp.right = x;
temp.bottom = y;
while ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_UP) == 0) {
inputGetInput();
get_input_position(&x, &y);
if (x != temp.right || y != temp.bottom) {
erase_rect(rect);
sort_rect(rect, &temp);
draw_rect(rect, _colorTable[32747]);
}
}
erase_rect(rect);
gameMouseSetCursor(MOUSE_CURSOR_ARROW);
gameMouseObjectsShow();
}
// 0x484294
void sort_rect(Rect* a, Rect* b)
{
if (b->right > b->left) {
a->left = b->left;
a->right = b->right;
} else {
a->left = b->right;
a->right = b->left;
}
if (b->bottom > b->top) {
a->top = b->top;
a->bottom = b->bottom;
} else {
a->top = b->bottom;
a->bottom = b->top;
}
}
// 0x4842D4
void draw_rect(Rect* rect, unsigned char color)
{
int width = rect->right - rect->left;
int height = rect->bottom - rect->top;
int max_dimension;
if (height < width) {
max_dimension = width;
} else {
max_dimension = height;
}
unsigned char* buffer = (unsigned char*)internal_malloc(max_dimension);
if (buffer != NULL) {
memset(buffer, color, max_dimension);
_scr_blit(buffer, width, 1, 0, 0, width, 1, rect->left, rect->top);
_scr_blit(buffer, 1, height, 0, 0, 1, height, rect->left, rect->top);
_scr_blit(buffer, width, 1, 0, 0, width, 1, rect->left, rect->bottom);
_scr_blit(buffer, 1, height, 0, 0, 1, height, rect->right, rect->top);
internal_free(buffer);
}
}
// 0x4843A0
void erase_rect(Rect* rect)
{
Rect r = *rect;
r.bottom = rect->top;
windowRefreshAll(&r);
r.bottom = rect->bottom;
r.left = rect->right;
windowRefreshAll(&r);
r.left = rect->left;
r.top = rect->bottom;
windowRefreshAll(&r);
r.top = rect->top;
r.right = rect->left;
windowRefreshAll(&r);
}
// 0x484400
int toolbar_proto(int type, int id)
{
if (id < proto_max_id(type)) {
return (type << 24) | id;
} else {
return -1;
}
}
// 0x485D44
bool map_toggle_block_obj_viewing_on()
{
return block_obj_view_on;
}
} // namespace fallout
-20
View File
@@ -1,20 +0,0 @@
#ifndef FALLOUT_MAPPER_MAP_FUNC_H_
#define FALLOUT_MAPPER_MAP_FUNC_H_
#include "geometry.h"
namespace fallout {
void setup_map_dirs();
void copy_proto_lists();
void place_entrance_hex();
void pick_region(Rect* rect);
void sort_rect(Rect* a, Rect* b);
void draw_rect(Rect* rect, unsigned char color);
void erase_rect(Rect* rect);
int toolbar_proto(int type, int id);
bool map_toggle_block_obj_viewing_on();
} // namespace fallout
#endif /* FALLOUT_MAPPER_MAP_FUNC_H_ */
-1743
View File
File diff suppressed because it is too large Load Diff
-23
View File
@@ -1,23 +0,0 @@
#ifndef FALLOUT_MAPPER_MAPPER_H_
#define FALLOUT_MAPPER_MAPPER_H_
#include "map.h"
#include "obj_types.h"
namespace fallout {
extern MapTransition mapInfo;
extern int menu_val_0[8];
extern int menu_val_2[8];
extern int menu_val_1[21];
extern unsigned char* tool;
extern int tool_win;
int mapper_main(int argc, char** argv);
void print_toolbar_name(int object_type);
int mapper_inven_unwield(Object* obj, int right_hand);
} // namespace fallout
#endif /* FALLOUT_MAPPER_MAPPER_H_ */
-607
View File
@@ -1,607 +0,0 @@
#include "mapper/mp_proto.h"
#include <string.h>
#include "art.h"
#include "color.h"
#include "combat_ai.h"
#include "critter.h"
#include "input.h"
#include "kb.h"
#include "mapper/mp_targt.h"
#include "memory.h"
#include "proto.h"
#include "svga.h"
#include "window_manager.h"
#include "window_manager_private.h"
namespace fallout {
#define CRITTER_FLAG_COUNT 10
#define YES 0
#define NO 1
static int proto_choose_container_flags(Proto* proto);
static int proto_subdata_setup_int_button(const char* title, int key, int value, int min_value, int max_value, int* y, int a7);
static int proto_subdata_setup_fid_button(const char* title, int key, int fid, int* y, int a5);
static int proto_subdata_setup_pid_button(const char* title, int key, int pid, int* y, int a5);
static void proto_critter_flags_redraw(int win, int pid);
static int proto_critter_flags_modify(int pid);
static int mp_pick_kill_type();
static char kYes[] = "YES";
static char kNo[] = "NO";
// 0x53DAFC
static char default_proto_builder_name[36] = "EVERTS SCOTTY";
// 0x559924
char* proto_builder_name = default_proto_builder_name;
// 0x559B94
static const char* wall_light_strs[] = {
"North/South",
"East/West",
"North Corner",
"South Corner",
"East Corner",
"West Corner",
};
// 0x559C50
static char* yesno[] = {
kYes,
kNo,
};
// 0x559C58
int edit_window_color = 1;
// 0x559C60
bool can_modify_protos = false;
// 0x559C68
static int subwin = -1;
// 0x559C6C
static int critFlagList[CRITTER_FLAG_COUNT] = {
CRITTER_NO_STEAL,
CRITTER_NO_DROP,
CRITTER_NO_LIMBS,
CRITTER_NO_AGE,
CRITTER_NO_HEAL,
CRITTER_INVULNERABLE,
CRITTER_FLAT,
CRITTER_SPECIAL_DEATH,
CRITTER_LONG_LIMBS,
CRITTER_NO_KNOCKBACK,
};
// 0x559C94
static const char* critFlagStrs[CRITTER_FLAG_COUNT] = {
"_Steal",
"_Drop",
"_Limbs",
"_Ages",
"_Heal",
"Invuln.,",
"_Flattens",
"Special",
"Rng",
"_Knock",
};
// 0x4922F8
void init_mapper_protos()
{
edit_window_color = _colorTable[10570];
can_modify_protos = target_overriden();
}
// 0x492840
int proto_choose_container_flags(Proto* proto)
{
int win = windowCreate(320,
185,
220,
205,
edit_window_color,
WINDOW_MOVE_ON_TOP);
if (win == -1) {
return -1;
}
_win_register_text_button(win,
10,
11,
-1,
-1,
-1,
'1',
"Magic Hands Grnd",
0);
if ((proto->item.data.container.openFlags & 0x1) != 0) {
windowDrawText(win,
yesno[YES],
50,
125,
15,
_colorTable[32747] | 0x10000);
} else {
windowDrawText(win,
yesno[NO],
50,
125,
15,
_colorTable[32747] | 0x10000);
}
_win_register_text_button(win,
10,
32,
-1,
-1,
-1,
'2',
"Cannot Pick Up",
0);
if (_proto_action_can_pickup(proto->pid)) {
windowDrawText(win,
yesno[YES],
50,
125,
36,
_colorTable[32747] | 0x10000);
} else {
windowDrawText(win,
yesno[NO],
50,
125,
36,
_colorTable[32747] | 0x10000);
}
windowDrawBorder(win);
windowRefresh(win);
while (1) {
sharedFpsLimiter.mark();
int input = inputGetInput();
if (input == KEY_ESCAPE
|| input == KEY_BAR
|| input == KEY_RETURN) {
break;
}
if (input == '1') {
proto->item.data.container.openFlags ^= 0x1;
if ((proto->item.data.container.openFlags & 0x1) != 0) {
windowDrawText(win,
yesno[YES],
50,
125,
15,
_colorTable[32747] | 0x10000);
} else {
windowDrawText(win,
yesno[NO],
50,
125,
15,
_colorTable[32747] | 0x10000);
}
windowRefresh(win);
} else if (input == '2') {
proto->item.extendedFlags ^= 0x8000;
if (_proto_action_can_pickup(proto->pid)) {
windowDrawText(win,
yesno[YES],
50,
125,
36,
_colorTable[32747] | 0x10000);
} else {
windowDrawText(win,
yesno[NO],
50,
125,
36,
_colorTable[32747] | 0x10000);
}
windowRefresh(win);
}
renderPresent();
sharedFpsLimiter.throttle();
}
windowDestroy(win);
return 0;
}
// 0x492A3C
int proto_subdata_setup_int_button(const char* title, int key, int value, int min_value, int max_value, int* y, int a7)
{
char text[36];
int button_x;
int value_offset_x;
button_x = 10;
value_offset_x = 90;
if (a7 == 9) {
*y -= 189;
}
if (a7 > 8) {
button_x = 165;
value_offset_x -= 16;
}
_win_register_text_button(subwin,
button_x,
*y,
-1,
-1,
-1,
key,
title,
0);
if (value >= min_value && value < max_value) {
sprintf(text, "%d", value);
windowDrawText(subwin,
text,
38,
button_x + value_offset_x,
*y + 4,
_colorTable[32747] | 0x10000);
} else {
windowDrawText(subwin,
"<ERROR>",
38,
button_x + value_offset_x,
*y + 4,
_colorTable[31744] | 0x10000);
}
*y += 21;
return 0;
}
// 0x492B28
int proto_subdata_setup_fid_button(const char* title, int key, int fid, int* y, int a5)
{
char text[36];
char* pch;
int button_x;
int value_offset_x;
button_x = 10;
value_offset_x = 90;
if (a5 == 9) {
*y -= 189;
}
if (a5 > 8) {
button_x = 165;
value_offset_x -= 16;
}
_win_register_text_button(subwin,
button_x,
*y,
-1,
-1,
-1,
key,
title,
0);
if (art_list_str(fid, text) != -1) {
pch = strchr(text, '.');
if (pch != NULL) {
*pch = '\0';
}
windowDrawText(subwin,
text,
80,
button_x + value_offset_x,
*y + 4,
_colorTable[32747] | 0x10000);
} else {
windowDrawText(subwin,
"None",
80,
button_x + value_offset_x,
*y + 4,
_colorTable[992] | 0x10000);
}
*y += 21;
return 0;
}
// 0x492C20
int proto_subdata_setup_pid_button(const char* title, int key, int pid, int* y, int a5)
{
int button_x;
int value_offset_x;
button_x = 10;
value_offset_x = 90;
if (a5 == 9) {
*y -= 189;
}
if (a5 > 8) {
button_x = 165;
value_offset_x = 74;
}
_win_register_text_button(subwin,
button_x,
*y,
-1,
-1,
-1,
key,
title,
0);
if (pid != -1) {
windowDrawText(subwin,
protoGetName(pid),
49,
button_x + value_offset_x,
*y + 4,
_colorTable[32747] | 0x10000);
} else {
windowDrawText(subwin,
"None",
49,
button_x + value_offset_x,
*y + 4,
_colorTable[992] | 0x10000);
}
*y += 21;
return 0;
}
// 0x495438
const char* proto_wall_light_str(int flags)
{
if ((flags & 0x8000000) != 0) {
return wall_light_strs[1];
}
if ((flags & 0x10000000) != 0) {
return wall_light_strs[2];
}
if ((flags & 0x20000000) != 0) {
return wall_light_strs[3];
}
if ((flags & 0x40000000) != 0) {
return wall_light_strs[4];
}
if ((flags & 0x80000000) != 0) {
return wall_light_strs[5];
}
return wall_light_strs[0];
}
// 0x4960B8
void proto_critter_flags_redraw(int win, int pid)
{
int index;
int color;
int x = 110;
for (index = 0; index < CRITTER_FLAG_COUNT; index++) {
if (_critter_flag_check(pid, critFlagList[index])) {
color = _colorTable[992];
} else {
color = _colorTable[10570];
}
windowDrawText(win, critFlagStrs[index], 44, x, 195, color | 0x10000);
x += 48;
}
}
// 0x496120
int proto_critter_flags_modify(int pid)
{
Proto* proto;
int rc;
int flags = 0;
int index;
if (protoGetProto(pid, &proto) == -1) {
return -1;
}
rc = win_yes_no("Can't be stolen from?", 340, 200, _colorTable[15855]);
if (rc == -1) {
return -1;
}
if (rc == 1) {
flags |= CRITTER_NO_STEAL;
}
rc = win_yes_no("Can't Drop items?", 340, 200, _colorTable[15855]);
if (rc == -1) {
return -1;
}
if (rc == 1) {
flags |= CRITTER_NO_DROP;
}
rc = win_yes_no("Can't lose limbs?", 340, 200, _colorTable[15855]);
if (rc == -1) {
return -1;
}
if (rc == 1) {
flags |= CRITTER_NO_LIMBS;
}
rc = win_yes_no("Dead Bodies Can't Age?", 340, 200, _colorTable[15855]);
if (rc == -1) {
return -1;
}
if (rc == 1) {
flags |= CRITTER_NO_AGE;
}
rc = win_yes_no("Can't Heal by Aging?", 340, 200, _colorTable[15855]);
if (rc == -1) {
return -1;
}
if (rc == 1) {
flags |= CRITTER_NO_HEAL;
}
rc = win_yes_no("Is Invlunerable????", 340, 200, _colorTable[15855]);
if (rc == -1) {
return -1;
}
if (rc == 1) {
flags |= CRITTER_INVULNERABLE;
}
rc = win_yes_no("Can't Flatten on Death?", 340, 200, _colorTable[15855]);
if (rc == -1) {
return -1;
}
if (rc == 1) {
flags |= CRITTER_FLAT;
}
rc = win_yes_no("Has Special Death?", 340, 200, _colorTable[15855]);
if (rc == -1) {
return -1;
}
if (rc == 1) {
flags |= CRITTER_SPECIAL_DEATH;
}
rc = win_yes_no("Has Extra Hand-To-Hand Range?", 340, 200, _colorTable[15855]);
if (rc == -1) {
return -1;
}
if (rc == 1) {
flags |= CRITTER_LONG_LIMBS;
}
rc = win_yes_no("Can't be knocked back?", 340, 200, _colorTable[15855]);
if (rc == -1) {
return -1;
}
if (rc == 1) {
flags |= CRITTER_NO_KNOCKBACK;
}
if (!can_modify_protos) {
win_timed_msg("Can't modify protos!", _colorTable[31744] | 0x10000);
return -1;
}
for (index = 0; index < CRITTER_FLAG_COUNT; index++) {
if ((critFlagList[index] & flags) != 0) {
critter_flag_set(pid, critFlagList[index]);
} else {
critter_flag_unset(pid, critFlagList[index]);
}
}
return 0;
}
// 0x497520
int mp_pick_kill_type()
{
char* names[KILL_TYPE_COUNT];
int index;
for (index = 0; index < KILL_TYPE_COUNT; index++) {
names[index] = killTypeGetName(index);
}
return _win_list_select("Kill Type",
names,
KILL_TYPE_COUNT,
NULL,
50,
100,
_colorTable[15855]);
}
// 0x497568
int proto_pick_ai_packet(int* value)
{
int count;
char** names;
int index;
int rc;
count = combat_ai_num();
if (count <= 0) {
return -1;
}
names = (char**)internal_malloc(sizeof(char*) * count);
for (index = 0; index < count; index++) {
names[index] = (char*)internal_malloc(strlen(combat_ai_name(index)) + 1);
strcpy(names[index], combat_ai_name(index));
}
rc = _win_list_select("AI Packet",
names,
count,
NULL,
50,
100,
_colorTable[15855]);
if (rc != -1) {
*value = rc;
}
for (index = 0; index < count; index++) {
internal_free(names[index]);
}
internal_free(names);
return 0;
}
} // namespace fallout
-15
View File
@@ -1,15 +0,0 @@
#ifndef FALLOUT_MAPPER_MP_PROTO_H_
#define FALLOUT_MAPPER_MP_PROTO_H_
namespace fallout {
extern char* proto_builder_name;
extern bool can_modify_protos;
void init_mapper_protos();
const char* proto_wall_light_str(int flags);
int proto_pick_ai_packet(int* value);
} // namespace fallout
#endif /* FALLOUT_MAPPER_MP_PROTO_H_ */
-90
View File
@@ -1,90 +0,0 @@
#include "mapper/mp_scrpt.h"
#include "art.h"
#include "object.h"
#include "scripts.h"
#include "tile.h"
namespace fallout {
// 0x49B170
int map_scr_remove_spatial(int tile, int elevation)
{
Script* scr;
Object* obj;
Rect rect;
scr = scriptGetFirstSpatialScript(elevation);
while (scr != NULL) {
if (builtTileGetTile(scr->sp.built_tile) == tile) {
scriptRemove(scr->sid);
scr = scriptGetFirstSpatialScript(elevation);
continue;
}
scr = scriptGetNextSpatialScript();
}
obj = objectFindFirstAtElevation(elevation);
while (obj != NULL) {
if (obj->tile == tile && buildFid(OBJ_TYPE_INTERFACE, 3, 0, 0, 0) == obj->fid) {
objectDestroy(obj, &rect);
tileWindowRefreshRect(&rect, elevation);
obj = objectFindFirstAtElevation(elevation);
continue;
}
obj = objectFindNextAtElevation();
}
return 0;
}
// 0x49B214
int map_scr_remove_all_spatials()
{
int elevation;
Script* scr;
Object* obj;
int sid;
for (elevation = 0; elevation < ELEVATION_COUNT; elevation++) {
scr = scriptGetFirstSpatialScript(elevation);
while (scr != NULL) {
scriptRemove(scr->sid);
scr = scriptGetFirstSpatialScript(elevation);
}
obj = objectFindFirstAtElevation(elevation);
while (obj != NULL) {
if (buildFid(OBJ_TYPE_INTERFACE, 3, 0, 0, 0) == obj->fid) {
objectDestroy(obj, NULL);
obj = objectFindFirstAtElevation(elevation);
continue;
}
obj = objectFindNextAtElevation();
}
}
tileWindowRefresh();
for (sid = 0; sid < 15000; sid++) {
if (scriptGetScript(sid, &scr) != -1) {
if (scr->owner != NULL) {
if (scr->owner->pid == 0x500000C) {
scr->owner->sid = -1;
scriptRemove(sid);
}
}
}
}
return 0;
}
} // namespace fallout
-11
View File
@@ -1,11 +0,0 @@
#ifndef FALLOUT_MAPPER_MP_SCRPTR_H_
#define FALLOUT_MAPPER_MP_SCRPTR_H_
namespace fallout {
int map_scr_remove_spatial(int tile, int elevation);
int map_scr_remove_all_spatials();
} // namespace fallout
#endif /* FALLOUT_MAPPER_MP_SCRPTR_H_ */

Some files were not shown because too many files have changed in this diff Show More