Compare commits

..
22 changed files with 482 additions and 881 deletions
-105
View File
@@ -1,105 +0,0 @@
name: Build and deploy webassembly version
on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
jobs:
build_webassembly_version:
name: Build webassembly version
runs-on: ubuntu-latest
permissions: write-all
steps:
- name: Clone
uses: actions/checkout@v4
- name: Install Emscripten SDK
run: |
git clone https://github.com/emscripten-core/emsdk.git
cd emsdk
./emsdk install 4.0.4
./emsdk activate 4.0.4
- name: Build fallout2 wasm module
run: |
source emsdk/emsdk_env.sh
git config --global --add safe.directory "*"
mkdir -p build
cd build
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
export BUILD_TYPE=Debug
else
export BUILD_TYPE=Release
fi
emcmake cmake ../ -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/Emscripten.cmake -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
emmake make VERBOSE=1 -j 4
cd ..
- name: Add node
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
uses: actions/setup-node@v2
with:
node-version: '22'
- name: Checkout web interface
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
uses: actions/checkout@v4
with:
repository: fallout2-ce/fallout2-ce-ems
ref: 8dc61ba6e8e62116f4810ffe89d0cece00f508d7
path: fallout2-ce-ems
- name: Set deployment path
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
id: set-path
run: |
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
echo "DEST_DIR=PR-${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
echo "SITE_BASE=/fallout2-ce/PR-${{ github.event.pull_request.number }}/" >> $GITHUB_OUTPUT
else
echo "DEST_DIR=." >> $GITHUB_OUTPUT
echo "SITE_BASE=/fallout2-ce/" >> $GITHUB_OUTPUT
fi
echo ===============================
cat $GITHUB_OUTPUT
- name: Build web interface
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
run: |
cd fallout2-ce-ems
npm install
cp ../build/fallout2-ce.js src/assets/fallout2ce
cp ../build/fallout2-ce.wasm src/assets/fallout2ce
export F2_WEB_INFO=Web=$(git rev-parse HEAD)
echo "F2_WEB_INFO=$F2_WEB_INFO"
echo "F2_GAME_VERSION=$F2_GAME_VERSION"
npm run build
env:
SITE_BASE: ${{ steps.set-path.outputs.SITE_BASE }}
F2_GAME_VERSION: Game=${{github.event.pull_request.head.sha || github.sha }}
- name: Install rsync (required for the next step)
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
run: |
sudo apt-get update && sudo apt-get install -y rsync
- name: Deploy PR preview or main site
if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: fallout2-ce-ems/dist
target-folder: ${{ steps.set-path.outputs.DEST_DIR }}
clean: false
- name: Comment preview URL on PR
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
run: |
gh pr comment ${{ github.event.pull_request.number }} \
--body "🚀 WebAssembly PR Preview for ${{github.event.pull_request.head.sha || github.sha }} is available at: https://${{ github.repository_owner }}.github.io/fallout2-ce/PR-${{ github.event.pull_request.number }}/"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+95 -19
View File
@@ -32,46 +32,58 @@ jobs:
run: cppcheck --std=c++17 src/
code-format:
name: Code format check
name: Code format check and apply
runs-on: ubuntu-latest
permissions:
contents: write # Allows the workflow to push changes back to the repository
steps:
- name: Clone
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0 # Ensures full history and correct branch checkout
ref: ${{ github.head_ref }} # Uses the original branch:
- name: Show clang-format version
run: |
clang-format --version
- name: clang-format
- name: Find and format files
run: find src -type f \( -name \*.cc -o -name \*.h \) | xargs clang-format -i
- name: Commit and push changes (if any)
run: |
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
echo "Showing PR labels..."
gh pr view ${{ github.event.pull_request.number }} --repo "${{ github.repository }}" --json labels
echo "Checking labels on PR..."
if gh pr view ${{ github.event.pull_request.number }} --repo "${{ github.repository }}" --json labels --jq '.labels[].name' | grep -q "skip-formatting"; then
echo "skip-formatting label found - do not raise error"
echo "==============================="
find src -type f \( -name \*.cc -o -name \*.h \) | xargs clang-format --dry-run
exit 0
if [[ -n "$(git status --porcelain)" ]]; then
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "This is a PR from forked repository. Open a PR from branch using this repository or fix the formatting manually."
exit 1
fi
fi
echo "skip-formatting label not found - raise error if formatting is not correct"
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Apply clang-format to submitted files"
git push origin HEAD:${{ github.head_ref }}
echo "Changes pushed. Exiting early to avoid workflow stuck."
exit 0
else
echo "Not a PR, do not check labels"
echo "No formatting changes to commit."
fi
find src -type f \( -name \*.cc -o -name \*.h \) | xargs clang-format --dry-run --Werror
echo "Code is formatted correctly"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
android:
name: Android
runs-on: ubuntu-latest
needs: code-format
steps:
- name: Clone
uses: actions/checkout@v4
@@ -120,6 +132,8 @@ jobs:
runs-on: macos-14
needs: code-format
steps:
- name: Clone
uses: actions/checkout@v4
@@ -155,6 +169,8 @@ jobs:
runs-on: ubuntu-22.04
needs: code-format
strategy:
fail-fast: false
matrix:
@@ -209,6 +225,8 @@ jobs:
runs-on: ubuntu-22.04-arm
needs: code-format
steps:
- name: Clone
uses: actions/checkout@v4
@@ -249,6 +267,8 @@ jobs:
runs-on: ubuntu-22.04-arm
needs: code-format
steps:
- name: Clone
uses: actions/checkout@v4
@@ -280,6 +300,8 @@ jobs:
runs-on: macos-14
needs: code-format
steps:
- name: Clone
uses: actions/checkout@v4
@@ -315,6 +337,8 @@ jobs:
runs-on: windows-2019
needs: code-format
strategy:
fail-fast: false
matrix:
@@ -353,6 +377,58 @@ jobs:
path: out/build/windows-${{ matrix.arch }}/RelWithDebInfo/fallout2-ce-${{ matrix.arch }}.exe
retention-days: 7
build_webassembly_version:
name: Build webassembly version
runs-on: ubuntu-latest
container: emscripten/emsdk:4.0.4
needs: code-format
permissions: write-all
steps:
- name: Clone
uses: actions/checkout@v4
- name: Build fallout2 wasm module
run: |
git config --global --add safe.directory "*"
mkdir -p build
cd build
emcmake cmake ../ -DCMAKE_TOOLCHAIN_FILE=../cmake/toolchain/Emscripten.cmake -DCMAKE_BUILD_TYPE=Release && emmake make VERBOSE=1 -j 4
cd ..
- name: Add node
if: github.ref == 'refs/heads/main'
uses: actions/setup-node@v2
with:
node-version: '22'
- name: Checkout web interface
if: github.ref == 'refs/heads/main'
uses: actions/checkout@v4
with:
repository: ololoken/fallout2-ce-ems
ref: 46ac3be3da9d01ef204779073b1c1254fa037021
path: fallout2-ce-ems
- name: Build web interface
if: github.ref == 'refs/heads/main'
run: |
cd fallout2-ce-ems
npm install
cp ../build/fallout2-ce.js src/assets/fallout2ce
cp ../build/fallout2-ce.wasm src/assets/fallout2ce
sed -i 's/\/fallout2-ce-ems/\/fallout2-ce/' vite.config.ts
npm run build
- name: Install rsync (required for the next step)
run: |
apt-get update && apt-get install -y rsync
- name: Deploy to gh-pages
uses: JamesIves/github-pages-deploy-action@v4
if: github.ref == 'refs/heads/main'
with:
branch: gh-pages
folder: fallout2-ce-ems/dist
release:
name: Release Continuous build
@@ -1,33 +0,0 @@
name: Cleanup PR Preview
on:
pull_request:
types:
- closed
jobs:
delete_pr_preview:
name: Delete PR preview from gh-pages
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout gh-pages branch
uses: actions/checkout@v4
with:
ref: gh-pages
token: ${{ secrets.GITHUB_TOKEN }}
- name: Remove PR preview folder
run: |
PR_FOLDER="PR-${{ github.event.pull_request.number }}"
echo "Removing preview folder: $PR_FOLDER"
git rm -r --ignore-unmatch "$PR_FOLDER" || true
- name: Commit and push changes
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit -am "đźš® Remove preview for closed PR #${{ github.event.pull_request.number }}"
git push
-52
View File
@@ -447,55 +447,3 @@ if(APPLE)
include(CPack)
endif()
# Add option to enable AddressSanitizer
option(ENABLE_ASAN "Enable AddressSanitizer for debug builds" OFF)
# Set C++ standard and other existing settings
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
# Define ASan flags for supported compilers (GCC, Clang, MSVC)
if(ENABLE_ASAN)
if(CMAKE_SYSTEM_NAME MATCHES "Emscripten|Android|iOS")
message(WARNING "AddressSanitizer is not supported on ${CMAKE_SYSTEM_NAME}. Disabling ASan.")
set(ENABLE_ASAN OFF)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
message(STATUS "Enabling AddressSanitizer for debug build (GCC/Clang)")
set(ASAN_FLAGS "-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${ASAN_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${ASAN_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${ASAN_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${ASAN_FLAGS}")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
# Check if using clang-cl or native MSVC
if(CMAKE_CXX_COMPILER MATCHES "clang-cl")
message(STATUS "Enabling AddressSanitizer for debug build (clang-cl)")
set(ASAN_FLAGS "-fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${ASAN_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${ASAN_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -fsanitize=address")
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fsanitize=address")
else()
message(STATUS "Enabling AddressSanitizer for debug build (MSVC)")
set(ASAN_FLAGS "/fsanitize=address")
# MSVC requires /Zi or /Z7 for debug info with ASan
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${ASAN_FLAGS} /Zi")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${ASAN_FLAGS} /Zi")
# No additional linker flags needed for MSVC ASan
# Disable incremental linking as it's incompatible with ASan
string(REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
string(REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
endif()
else()
message(WARNING "AddressSanitizer is not supported with ${CMAKE_CXX_COMPILER_ID}. Disabling ASan.")
set(ENABLE_ASAN OFF)
endif()
endif()
# Existing debug flags for Emscripten (ensure ASan doesn't conflict)
if(CMAKE_SYSTEM_NAME MATCHES "Emscripten")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -g")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
endif()
+93 -95
View File
@@ -73,32 +73,30 @@ static const int gMaximumBloodDeathAnimations[DAMAGE_TYPE_COUNT] = {
ANIM_EXPLODED_TO_NOTHING,
};
// Note: some of these are callbacks that always take two Object*, but may not use them.
// Ignored parameters are marked with underscores.
static int actionKnockdown(Object* obj, int* anim, int maxDistance, int rotation, int delay);
static int _action_blood(Object* obj, int anim, int delay);
static int _pick_death(Object* attacker, Object* defender, Object* weapon, int damage, int attackerAnimation, bool hitFromFront);
static int _check_death(Object* obj, int anim, int minViolenceLevel, bool hitFromFront);
static int _internal_destroy(Object* _, Object* toDestroy);
static int _internal_destroy(Object* a1, Object* a2);
static void _show_damage_to_object(Object* defender, int damage, int flags, Object* weapon, bool hitFromFront, int knockbackDistance, int knockbackRotation, int attackerAnimation, Object* attacker, int delay);
static int _show_death(Object* obj, int anim);
static int _show_damage_extras(Attack* attack);
static void _show_damage(Attack* attack, int attackerAnimation, int delay);
static int _action_melee(Attack* attack, int anim);
static int _action_ranged(Attack* attack, int anim);
static int _is_next_to(Object* obj1, Object* obj2);
static int _action_climb_ladder(Object* critter, Object* ladder);
static int _action_melee(Attack* attack, int a2);
static int _action_ranged(Attack* attack, int a2);
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 _finished_explosion(Object*, Object*);
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* obj, Object* critter);
static int _talk_to(Object* _, Object* critter);
static int _report_dmg(Attack* attack, Object* _);
static int _can_talk_to(Object* a1, Object* a2);
static int _talk_to(Object* a1, Object* a2);
static int _report_dmg(Attack* attack, Object* a2);
static int _compute_dmg_damage(int min, int max, Object* obj, int* knockbackDistancePtr, int damageType);
static int hideProjectile(void* _, void* projectile);
static int hideProjectile(void* a1, void* a2);
// 0x410468
int actionKnockdown(Object* obj, int* anim, int maxDistance, int rotation, int delay)
@@ -283,9 +281,9 @@ int _check_death(Object* obj, int anim, int minViolenceLevel, bool hitFromFront)
}
// 0x4108C8
int _internal_destroy(Object* _, Object* toDestroy)
int _internal_destroy(Object* a1, Object* a2)
{
return _obj_destroy(toDestroy);
return _obj_destroy(a2);
}
// TODO: Check very carefully, lots of conditions and jumps.
@@ -987,10 +985,10 @@ int _action_ranged(Attack* attack, int anim)
}
// 0x411D68
int _is_next_to(Object* obj1, Object* obj2)
int _is_next_to(Object* a1, Object* a2)
{
if (objectGetDistanceBetween(obj1, obj2) > 1) {
if (obj2 == gDude) {
if (objectGetDistanceBetween(a1, a2) > 1) {
if (a2 == gDude) {
MessageListItem messageListItem;
// You cannot get there.
messageListItem.num = 2000;
@@ -1005,9 +1003,9 @@ int _is_next_to(Object* obj1, Object* obj2)
}
// 0x411DB4
int _action_climb_ladder(Object* critter, Object* ladder)
int _action_climb_ladder(Object* a1, Object* a2)
{
if (critter == gDude) {
if (a1 == gDude) {
int anim = FID_ANIM_TYPE(gDude->fid);
if (anim == ANIM_WALK || anim == ANIM_RUNNING) {
reg_anim_clear(gDude);
@@ -1018,46 +1016,46 @@ int _action_climb_ladder(Object* critter, Object* ladder)
int actionPoints;
if (isInCombat()) {
animationRequestOptions = ANIMATION_REQUEST_RESERVED;
actionPoints = critter->data.critter.combat.ap;
actionPoints = a1->data.critter.combat.ap;
} else {
animationRequestOptions = ANIMATION_REQUEST_UNRESERVED;
actionPoints = -1;
}
if (critter == gDude) {
if (a1 == gDude) {
animationRequestOptions = ANIMATION_REQUEST_RESERVED;
}
animationRequestOptions |= ANIMATION_REQUEST_NO_STAND;
reg_anim_begin(animationRequestOptions);
int tile = tileGetTileInDirection(ladder->tile, ROTATION_SE, 1);
int tile = tileGetTileInDirection(a2->tile, ROTATION_SE, 1);
int walkDistance = 5;
configGetInt(&gSfallConfig, SFALL_CONFIG_MISC_KEY, SFALL_CONFIG_USE_WALK_DISTANCE, &walkDistance);
if (actionPoints != -1 || objectGetDistanceBetween(critter, ladder) < walkDistance) {
animationRegisterMoveToTile(critter, tile, ladder->elevation, actionPoints, 0);
if (actionPoints != -1 || objectGetDistanceBetween(a1, a2) < walkDistance) {
animationRegisterMoveToTile(a1, tile, a2->elevation, actionPoints, 0);
} else {
animationRegisterRunToTile(critter, tile, ladder->elevation, actionPoints, 0);
animationRegisterRunToTile(a1, tile, a2->elevation, actionPoints, 0);
}
animationRegisterCallbackForced(critter, ladder, (AnimationCallback*)_is_next_to, -1);
animationRegisterRotateToTile(critter, ladder->tile);
animationRegisterCallbackForced(critter, ladder, (AnimationCallback*)_check_scenery_ap_cost, -1);
animationRegisterCallbackForced(a1, a2, (AnimationCallback*)_is_next_to, -1);
animationRegisterRotateToTile(a1, a2->tile);
animationRegisterCallbackForced(a1, a2, (AnimationCallback*)_check_scenery_ap_cost, -1);
int weaponAnimationCode = (critter->fid & 0xF000) >> 12;
int weaponAnimationCode = (a1->fid & 0xF000) >> 12;
if (weaponAnimationCode != 0) {
const char* puttingAwaySfx = sfxBuildCharName(critter, ANIM_PUT_AWAY, CHARACTER_SOUND_EFFECT_UNUSED);
animationRegisterPlaySoundEffect(critter, puttingAwaySfx, -1);
animationRegisterAnimate(critter, ANIM_PUT_AWAY, 0);
const char* puttingAwaySfx = sfxBuildCharName(a1, ANIM_PUT_AWAY, CHARACTER_SOUND_EFFECT_UNUSED);
animationRegisterPlaySoundEffect(a1, puttingAwaySfx, -1);
animationRegisterAnimate(a1, ANIM_PUT_AWAY, 0);
}
const char* climbingSfx = sfxBuildCharName(critter, ANIM_CLIMB_LADDER, CHARACTER_SOUND_EFFECT_UNUSED);
animationRegisterPlaySoundEffect(critter, climbingSfx, -1);
animationRegisterAnimate(critter, ANIM_CLIMB_LADDER, 0);
animationRegisterCallback(critter, ladder, (AnimationCallback*)_obj_use, -1);
const char* climbingSfx = sfxBuildCharName(a1, ANIM_CLIMB_LADDER, CHARACTER_SOUND_EFFECT_UNUSED);
animationRegisterPlaySoundEffect(a1, climbingSfx, -1);
animationRegisterAnimate(a1, ANIM_CLIMB_LADDER, 0);
animationRegisterCallback(a1, a2, (AnimationCallback*)_obj_use, -1);
if (weaponAnimationCode != 0) {
animationRegisterTakeOutWeapon(critter, weaponAnimationCode, -1);
animationRegisterTakeOutWeapon(a1, weaponAnimationCode, -1);
}
return reg_anim_end();
@@ -1524,9 +1522,9 @@ int actionUseSkill(Object* user, Object* target, int skill)
}
// 0x412BC4
bool _is_hit_from_front(Object* attacker, Object* defender)
bool _is_hit_from_front(Object* a1, Object* a2)
{
int diff = attacker->rotation - defender->rotation;
int diff = a1->rotation - a2->rotation;
if (diff < 0) {
diff = -diff;
}
@@ -1535,11 +1533,11 @@ bool _is_hit_from_front(Object* attacker, Object* defender)
}
// 0x412BEC
bool _can_see(Object* source, Object* target)
bool _can_see(Object* a1, Object* a2)
{
int diff;
diff = source->rotation - tileGetRotationTo(source->tile, target->tile);
diff = a1->rotation - tileGetRotationTo(a1->tile, a2->tile);
if (diff < 0) {
diff = -diff;
}
@@ -1815,7 +1813,7 @@ int _report_explosion(Attack* attack, Object* sourceObj)
}
// 0x4132C0
int _finished_explosion(Object* _, Object* __)
int _finished_explosion(Object* a1, Object* a2)
{
_action_in_explode = false;
return 0;
@@ -1844,13 +1842,13 @@ int _compute_explosion_damage(int min, int max, Object* defender, int* knockback
}
// 0x413330
int actionTalk(Object* obj, Object* critter)
int actionTalk(Object* a1, Object* a2)
{
if (obj != gDude) {
if (a1 != gDude) {
return -1;
}
if (FID_TYPE(critter->fid) != OBJ_TYPE_CRITTER) {
if (FID_TYPE(a2->fid) != OBJ_TYPE_CRITTER) {
return -1;
}
@@ -1861,25 +1859,25 @@ int actionTalk(Object* obj, Object* critter)
if (isInCombat()) {
reg_anim_begin(ANIMATION_REQUEST_RESERVED);
animationRegisterMoveToObject(obj, critter, obj->data.critter.combat.ap, 0);
animationRegisterMoveToObject(a1, a2, a1->data.critter.combat.ap, 0);
} else {
reg_anim_begin(obj == gDude ? ANIMATION_REQUEST_RESERVED : ANIMATION_REQUEST_UNRESERVED);
reg_anim_begin(a1 == gDude ? ANIMATION_REQUEST_RESERVED : ANIMATION_REQUEST_UNRESERVED);
if (objectGetDistanceBetween(obj, critter) >= 9 || _combat_is_shot_blocked(obj, obj->tile, critter->tile, critter, nullptr)) {
animationRegisterRunToObject(obj, critter, -1, 0);
if (objectGetDistanceBetween(a1, a2) >= 9 || _combat_is_shot_blocked(a1, a1->tile, a2->tile, a2, nullptr)) {
animationRegisterRunToObject(a1, a2, -1, 0);
}
}
animationRegisterCallbackForced(obj, critter, (AnimationCallback*)_can_talk_to, -1);
animationRegisterCallback(obj, critter, (AnimationCallback*)_talk_to, -1);
animationRegisterCallbackForced(a1, a2, (AnimationCallback*)_can_talk_to, -1);
animationRegisterCallback(a1, a2, (AnimationCallback*)_talk_to, -1);
return reg_anim_end();
}
// 0x413420
int _can_talk_to(Object* obj, Object* critter)
int _can_talk_to(Object* a1, Object* a2)
{
if (_combat_is_shot_blocked(obj, obj->tile, critter->tile, critter, nullptr) || objectGetDistanceBetween(obj, critter) >= 9) {
if (obj == gDude) {
if (_combat_is_shot_blocked(a1, a1->tile, a2->tile, a2, nullptr) || objectGetDistanceBetween(a1, a2) >= 9) {
if (a1 == gDude) {
// You cannot get there. (used in actions.c)
MessageListItem messageListItem;
messageListItem.num = 2000;
@@ -1895,9 +1893,9 @@ int _can_talk_to(Object* obj, Object* critter)
}
// 0x413488
int _talk_to(Object* _, Object* critter)
int _talk_to(Object* a1, Object* a2)
{
scriptsRequestDialog(critter);
scriptsRequestDialog(a2);
return 0;
}
@@ -1971,7 +1969,7 @@ void actionDamage(int tile, int elevation, int minDamage, int maxDamage, int dam
}
// 0x41363C
int _report_dmg(Attack* attack, Object* _)
int _report_dmg(Attack* attack, Object* a2)
{
_combat_display(attack);
_apply_damage(attack, false);
@@ -2008,42 +2006,42 @@ int _compute_dmg_damage(int min, int max, Object* obj, int* knockbackDistancePtr
}
// 0x4136EC
bool actionCheckPush(Object* obj, Object* target)
bool actionCheckPush(Object* a1, Object* a2)
{
// Cannot push anything but critters.
if (FID_TYPE(target->fid) != OBJ_TYPE_CRITTER) {
if (FID_TYPE(a2->fid) != OBJ_TYPE_CRITTER) {
return false;
}
// Cannot push itself.
if (obj == target) {
if (a1 == a2) {
return false;
}
// Cannot push inactive critters.
if (!critterIsActive(target)) {
if (!critterIsActive(a2)) {
return false;
}
if (_action_can_talk_to(obj, target) != 0) {
if (_action_can_talk_to(a1, a2) != 0) {
return false;
}
// Can only push critters that have push handler.
if (!scriptHasProc(target->sid, SCRIPT_PROC_PUSH)) {
if (!scriptHasProc(a2->sid, SCRIPT_PROC_PUSH)) {
return false;
}
if (isInCombat()) {
if (target->data.critter.combat.team == obj->data.critter.combat.team
&& target == obj->data.critter.combat.whoHitMe) {
if (a2->data.critter.combat.team == a1->data.critter.combat.team
&& a2 == a1->data.critter.combat.whoHitMe) {
return false;
}
// TODO: Check.
Object* whoHitMe = target->data.critter.combat.whoHitMe;
Object* whoHitMe = a2->data.critter.combat.whoHitMe;
if (whoHitMe != nullptr
&& whoHitMe->data.critter.combat.team == obj->data.critter.combat.team) {
&& whoHitMe->data.critter.combat.team == a1->data.critter.combat.team) {
return false;
}
}
@@ -2052,15 +2050,15 @@ bool actionCheckPush(Object* obj, Object* target)
}
// 0x413790
int actionPush(Object* obj, Object* target)
int actionPush(Object* a1, Object* a2)
{
if (!actionCheckPush(obj, target)) {
if (!actionCheckPush(a1, a2)) {
return -1;
}
int sid;
if (_obj_sid(target, &sid) == 0) {
scriptSetObjects(sid, obj, target);
if (_obj_sid(a2, &sid) == 0) {
scriptSetObjects(sid, a1, a2);
scriptExecProc(sid, SCRIPT_PROC_PUSH);
bool scriptOverrides = false;
@@ -2075,36 +2073,36 @@ int actionPush(Object* obj, Object* target)
}
}
int rotation = tileGetRotationTo(obj->tile, target->tile);
int rotation = tileGetRotationTo(a1->tile, a2->tile);
int tile;
do {
tile = tileGetTileInDirection(target->tile, rotation, 1);
if (_obj_blocking_at(target, tile, target->elevation) == nullptr) {
tile = tileGetTileInDirection(a2->tile, rotation, 1);
if (_obj_blocking_at(a2, tile, a2->elevation) == nullptr) {
break;
}
tile = tileGetTileInDirection(target->tile, (rotation + 1) % ROTATION_COUNT, 1);
if (_obj_blocking_at(target, tile, target->elevation) == nullptr) {
tile = tileGetTileInDirection(a2->tile, (rotation + 1) % ROTATION_COUNT, 1);
if (_obj_blocking_at(a2, tile, a2->elevation) == nullptr) {
break;
}
tile = tileGetTileInDirection(target->tile, (rotation + 5) % ROTATION_COUNT, 1);
if (_obj_blocking_at(target, tile, target->elevation) == nullptr) {
tile = tileGetTileInDirection(a2->tile, (rotation + 5) % ROTATION_COUNT, 1);
if (_obj_blocking_at(a2, tile, a2->elevation) == nullptr) {
break;
}
tile = tileGetTileInDirection(target->tile, (rotation + 2) % ROTATION_COUNT, 1);
if (_obj_blocking_at(target, tile, target->elevation) == nullptr) {
tile = tileGetTileInDirection(a2->tile, (rotation + 2) % ROTATION_COUNT, 1);
if (_obj_blocking_at(a2, tile, a2->elevation) == nullptr) {
break;
}
tile = tileGetTileInDirection(target->tile, (rotation + 4) % ROTATION_COUNT, 1);
if (_obj_blocking_at(target, tile, target->elevation) == nullptr) {
tile = tileGetTileInDirection(a2->tile, (rotation + 4) % ROTATION_COUNT, 1);
if (_obj_blocking_at(a2, tile, a2->elevation) == nullptr) {
break;
}
tile = tileGetTileInDirection(target->tile, (rotation + 3) % ROTATION_COUNT, 1);
if (_obj_blocking_at(target, tile, target->elevation) == nullptr) {
tile = tileGetTileInDirection(a2->tile, (rotation + 3) % ROTATION_COUNT, 1);
if (_obj_blocking_at(a2, tile, a2->elevation) == nullptr) {
break;
}
@@ -2113,14 +2111,14 @@ int actionPush(Object* obj, Object* target)
int actionPoints;
if (isInCombat()) {
actionPoints = target->data.critter.combat.ap;
actionPoints = a2->data.critter.combat.ap;
} else {
actionPoints = -1;
}
reg_anim_begin(ANIMATION_REQUEST_RESERVED);
animationRegisterRotateToTile(target, tile);
animationRegisterMoveToTile(target, tile, target->elevation, actionPoints, 0);
animationRegisterRotateToTile(a2, tile);
animationRegisterMoveToTile(a2, tile, a2->elevation, actionPoints, 0);
return reg_anim_end();
}
@@ -2128,29 +2126,29 @@ int actionPush(Object* obj, Object* target)
// Returns -2 if it's too far (> 12 tiles).
//
// 0x413970
int _action_can_talk_to(Object* obj, Object* target)
int _action_can_talk_to(Object* a1, Object* a2)
{
if (pathfinderFindPath(obj, obj->tile, target->tile, nullptr, 0, _obj_sight_blocking_at) == 0) {
if (pathfinderFindPath(a1, a1->tile, a2->tile, nullptr, 0, _obj_sight_blocking_at) == 0) {
return -1;
}
if (tileDistanceBetween(obj->tile, target->tile) > 12) {
if (tileDistanceBetween(a1->tile, a2->tile) > 12) {
return -2;
}
return 0;
}
static int hideProjectile(void* _, void* projectile)
static int hideProjectile(void* a1, void* a2)
{
Object* proj = reinterpret_cast<Object*>(projectile);
Object* projectile = reinterpret_cast<Object*>(a2);
Rect rect;
if (objectHide(proj, &rect) == 0) {
tileWindowRefreshRect(&rect, proj->elevation);
if (objectHide(projectile, &rect) == 0) {
tileWindowRefreshRect(&rect, projectile->elevation);
}
proj->flags |= OBJECT_NO_SAVE;
projectile->flags |= OBJECT_NO_SAVE;
return 0;
}
+5 -5
View File
@@ -16,14 +16,14 @@ 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);
bool _can_see(Object* source, Object* target);
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 actionTalk(Object* obj, Object* critter);
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* obj, Object* target);
int actionPush(Object* obj, Object* target);
int _action_can_talk_to(Object* obj, Object* critter);
bool actionCheckPush(Object* a1, Object* a2);
int actionPush(Object* a1, Object* a2);
int _action_can_talk_to(Object* a1, Object* a2);
} // namespace fallout
+88 -100
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -31,8 +31,8 @@ typedef struct HeadDescription {
} HeadDescription;
static int artReadList(const char* path, char** out_arr, int* out_count);
static int artCacheGetFileSizeImpl(int fid, int* out_size);
static int artCacheReadDataImpl(int fid, int* sizePtr, unsigned char* data);
static int artCacheGetFileSizeImpl(int a1, int* out_size);
static int artCacheReadDataImpl(int a1, int* a2, unsigned char* data);
static void artCacheFreeImpl(void* ptr);
static int artReadFrameData(unsigned char* data, File* stream, int count, int* paddingPtr);
static int artReadHeader(Art* art, File* stream);
+5 -5
View File
@@ -129,9 +129,9 @@ unsigned char* artLockFrameData(int fid, int frame, int direction, CacheEntry**
unsigned char* artLockFrameDataReturningSize(int fid, CacheEntry** out_cache_entry, int* widthPtr, int* heightPtr);
int artUnlock(CacheEntry* cache_entry);
int artCacheFlush();
int artCopyFileName(int objectType, int id, char* a3);
int _art_get_code(int animation, int weaponType, char* a3, char* a4);
char* artBuildFilePath(int fid);
int artCopyFileName(int objectType, int a2, char* a3);
int _art_get_code(int a1, int a2, char* a3, char* a4);
char* artBuildFilePath(int a1);
int artGetFramesPerSecond(Art* art);
int artGetActionFrame(Art* art);
int artGetFrameCount(Art* art);
@@ -144,8 +144,8 @@ unsigned char* artGetFrameData(Art* art, int frame, int direction);
ArtFrame* artGetFrame(Art* art, int frame, int direction);
bool artExists(int fid);
bool _art_fid_valid(int fid);
int _art_alias_num(int index);
int artCritterFidShouldRun(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);
Art* artLoad(const char* path);
+16 -30
View File
@@ -2731,19 +2731,13 @@ static int _ai_try_attack(Object* attacker, Object* defender)
int reason = _combat_check_bad_shot(attacker, defender, hitMode, false);
if (reason == COMBAT_BAD_SHOT_NO_AMMO) {
// out of ammo
int roundsLoaded = 0;
if (aiHaveAmmo(attacker, weapon, &ammo)) {
while (aiHaveAmmo(attacker, weapon, &ammo)) {
int remainingAmmoQuantity = weaponReload(weapon, ammo);
if (remainingAmmoQuantity == 0 && ammo != nullptr) {
_obj_destroy(ammo);
++roundsLoaded;
} else {
break;
}
int remainingAmmoQuantity = weaponReload(weapon, ammo);
if (remainingAmmoQuantity == 0 && ammo != nullptr) {
_obj_destroy(ammo);
}
if (roundsLoaded > 0) {
if (remainingAmmoQuantity != -1) {
int volume = _gsound_compute_relative_volume(attacker);
const char* sfx = sfxBuildWeaponName(WEAPON_SOUND_EFFECT_READY, weapon, hitMode, nullptr);
_gsound_play_sfx_file_volume(sfx, volume);
@@ -2926,30 +2920,22 @@ void aiAttemptWeaponReload(Object* critter, int animate)
int ammoQuantity = ammoGetQuantity(weapon);
int ammoCapacity = ammoGetCapacity(weapon);
int loadedRounds = 0;
if (ammoQuantity < ammoCapacity) {
for (int i = 0; i < (ammoCapacity - ammoQuantity); ++i) {
Object* ammo;
if (aiHaveAmmo(critter, weapon, &ammo)) {
int rc = weaponReload(weapon, ammo);
if (rc == 0) {
_obj_destroy(ammo);
++loadedRounds;
} else {
break;
}
} else {
break;
Object* ammo;
if (aiHaveAmmo(critter, weapon, &ammo)) {
int rc = weaponReload(weapon, ammo);
if (rc == 0) {
_obj_destroy(ammo);
}
}
if (loadedRounds != 0 && objectIsPartyMember(critter)) {
int volume = _gsound_compute_relative_volume(critter);
const char* sfx = sfxBuildWeaponName(WEAPON_SOUND_EFFECT_READY, weapon, HIT_MODE_RIGHT_WEAPON_PRIMARY, nullptr);
_gsound_play_sfx_file_volume(sfx, volume);
if (rc != -1 && objectIsPartyMember(critter)) {
int volume = _gsound_compute_relative_volume(critter);
const char* sfx = sfxBuildWeaponName(WEAPON_SOUND_EFFECT_READY, weapon, HIT_MODE_RIGHT_WEAPON_PRIMARY, nullptr);
_gsound_play_sfx_file_volume(sfx, volume);
if (animate) {
_ai_magic_hands(critter, weapon, 5002);
if (animate) {
_ai_magic_hands(critter, weapon, 5002);
}
}
}
}
+2 -7
View File
@@ -172,9 +172,6 @@ int gameInitWithOptions(const char* windowTitle, bool isMapper, int font, int a4
showSplash();
}
#if (defined(__EMSCRIPTEN__) && !defined(NDEBUG))
debugPrint("This is a web build with debug mode so print to the console\n");
#else
// CE: Handle debug mode (exactly as seen in `mapper2.exe`).
const char* debugMode = settings.debug.mode.c_str();
if (compat_stricmp(debugMode, "environment") == 0) {
@@ -188,7 +185,6 @@ int gameInitWithOptions(const char* windowTitle, bool isMapper, int font, int a4
} else if (compat_stricmp(debugMode, "gnw") == 0) {
_debug_register_func(_win_debug);
}
#endif
interfaceFontsInit();
fontManagerAdd(&gModernFontManager);
@@ -956,12 +952,11 @@ int gameHandleKey(int eventCode, bool isInCombatMode)
// game_ui_disable
// 0x443BFC
// pass allowScrolling = 1 to allow scrolling
void gameUiDisable(int allowScrolling)
void gameUiDisable(int a1)
{
if (!gGameUiDisabled) {
gameMouseObjectsHide();
_gmouse_disable(allowScrolling);
_gmouse_disable(a1);
keyboardDisable();
interfaceBarDisable();
gGameUiDisabled = true;
+1 -1
View File
@@ -27,7 +27,7 @@ int gameInitWithOptions(const char* windowTitle, bool isMapper, int a3, int a4,
void gameReset();
void gameExit();
int gameHandleKey(int eventCode, bool isInCombatMode);
void gameUiDisable(int allowScrolling);
void gameUiDisable(int a1);
void gameUiEnable();
bool gameUiIsDisabled();
int gameGetGlobalVar(int var);
+2 -2
View File
@@ -408,13 +408,13 @@ void _gmouse_enable()
}
// 0x44B48C
void _gmouse_disable(int allowScrolling)
void _gmouse_disable(int a1)
{
if (_gmouse_enabled) {
gameMouseSetCursor(MOUSE_CURSOR_NONE);
_gmouse_enabled = 0;
if (allowScrolling & 1) {
if (a1 & 1) {
_gmouse_scrolling_enabled = 1;
} else {
_gmouse_scrolling_enabled = 0;
+1 -1
View File
@@ -77,7 +77,7 @@ int gameMouseInit();
int gameMouseReset();
void gameMouseExit();
void _gmouse_enable();
void _gmouse_disable(int allowScrolling);
void _gmouse_disable(int a1);
void _gmouse_enable_scrolling();
void _gmouse_disable_scrolling();
bool gmouse_scrolling_is_enabled();
+104 -348
View File
File diff suppressed because it is too large Load Diff
+9 -22
View File
@@ -298,7 +298,7 @@ MessageListItem gPipboyMessageListItem;
// pipboy.msg
//
// 0x664348
MessageList gPipboyMessageList = { 0, nullptr };
MessageList gPipboyMessageList;
// 0x664350
STRUCT_664350 _sortlist[24];
@@ -488,26 +488,6 @@ int pipboyOpen(int intent)
return 0;
}
int pipboyMessageListInit()
{
if (gPipboyMessageList.entries != nullptr) {
messageListFree(&gPipboyMessageList);
}
if (!messageListInit(&gPipboyMessageList)) {
return -1;
}
char path[COMPAT_MAX_PATH];
snprintf(path, sizeof(path), "%s%s", asc_5186C8, "pipboy.msg");
if (!(messageListLoad(&gPipboyMessageList, path))) {
return -1;
}
return 0;
}
// 0x497228
static int pipboyWindowInit(int intent)
{
@@ -539,7 +519,14 @@ static int pipboyWindowInit(int intent)
return -1;
}
if (pipboyMessageListInit() == -1) {
if (!messageListInit(&gPipboyMessageList)) {
return -1;
}
char path[COMPAT_MAX_PATH];
snprintf(path, sizeof(path), "%s%s", asc_5186C8, "pipboy.msg");
if (!(messageListLoad(&gPipboyMessageList, path))) {
return -1;
}
-4
View File
@@ -2,7 +2,6 @@
#define PIPBOY_H
#include "db.h"
#include "message.h"
namespace fallout {
@@ -17,9 +16,6 @@ void pipboyReset();
int pipboySave(File* stream);
int pipboyLoad(File* stream);
extern MessageList gPipboyMessageList;
int pipboyMessageListInit();
} // namespace fallout
#endif /* PIPBOY_H */
+6 -6
View File
@@ -15,17 +15,17 @@ int reactionSetValue(Object* critter, int value)
}
// 0x4A29E8
int reactionTranslateValue(int value)
int reactionTranslateValue(int a1)
{
if (value > 10) {
if (a1 > 10) {
return NPC_REACTION_GOOD;
} else if (value > -10) {
} else if (a1 > -10) {
return NPC_REACTION_NEUTRAL;
} else if (value > -25) {
} else if (a1 > -25) {
return NPC_REACTION_BAD;
} else if (value > -50) {
} else if (a1 > -50) {
return NPC_REACTION_BAD;
} else if (value > -75) {
} else if (a1 > -75) {
return NPC_REACTION_BAD;
} else {
return NPC_REACTION_BAD;
+2 -2
View File
@@ -11,8 +11,8 @@ typedef enum NpcReaction {
NPC_REACTION_GOOD,
} NpcReaction;
int reactionSetValue(Object* critter, int value);
int reactionTranslateValue(int value);
int reactionSetValue(Object* critter, int a2);
int reactionTranslateValue(int a1);
int _reaction_influence_();
int reactionGetValue(Object* critter);
-3
View File
@@ -181,9 +181,6 @@ int statsSave(File* stream)
// 0x4AEF48
int critterGetStat(Object* critter, int stat)
{
if (PID_TYPE(critter->pid) != OBJ_TYPE_CRITTER) {
return 0;
}
int value;
if (stat >= 0 && stat < SAVEABLE_STAT_COUNT) {
value = critterGetBaseStatWithTraitModifier(critter, stat);

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