Compare commits

..
Author SHA1 Message Date
Mike Klaas 1e65aa70e8 Fix book feedback at configured skill cap 2026-07-26 16:03:02 -07:00
github-actions[bot] 7704d160ac chore: auto-format with clang-format 2026-07-26 22:04:09 +00:00
Mike Klaas f750c4b595 [Et tu] Implement set_skill_max 2026-07-26 15:03:17 -07:00
Mike Klaas 1db054e47a [Et tu] Implement Start{X|Y}Pos (#585)
* [Et tu] Implement `Start{X|Y}Pos`, `ViewX|Y`
2026-07-26 14:07:55 -07:00
8e60a2fba2 Show weight instead of size in container loot dialog for better comparison (#551)
* show weight instead of size in loot dialog

* chore: auto-format with clang-format

* added configuration

* chore: auto-format with clang-format

* added percentage mode only

* chore: auto-format with clang-format

* use percentage for simple indiator in containers, remove the percentage mode only, change default to simple indicator

* Update src/settings.h

typo

Co-authored-by: Mike Klaas <mike.klaas@gmail.com>

* changed the threshold to be applicable only to the containers and se it to 50%.. changed the colors for the weight indicator and the party member name in the loot dialog.. also tweaked label position for bigger critters like Marcus

* restore font to the previous value in case threshold filters out the indicator

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* missing leading space in  weight indicator comments in fallout2.cfg

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* use actual runtime value of the size of the columns instead of trusting the setting value

Co-authored-by: Mike Klaas <mike.klaas@gmail.com>

* minor reformulation of the comments in fallout2.cfg

Co-authored-by: Mike Klaas <mike.klaas@gmail.com>

* explicitly use std::ceil() over ceil() to follow convention in this file and to make copilot happy

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Mike Klaas <mike.klaas@gmail.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-07-26 09:52:04 +02:00
Mike Klaas ca89abad6c [Et tu] Fix TMA (Tell me about) (#596)
* Honor frm global offsets in draw_image

* Return correct dialog window in getInterfaceWindowByType
2026-07-25 20:44:25 -07:00
Mike Klaas 21a98bebb1 Correct PC placement when screen is large (#591)
Fixes https://github.com/fallout2-ce/fallout2-ce/issues/578
2026-07-25 15:37:09 -07:00
Mike Klaas 283107bebe [Et tu] Move pipboy GAMEMODECHANGE hook (#595)
This now fires when the window is created, allowing scripts to manipulate it (and in particular, add "X days left" note)
2026-07-25 08:57:50 -07:00
Mike Klaas dd21129464 [Et tu] get/set_terrain_name (#593)
* [Et tu] get/set_terrain_name
2026-07-24 21:42:30 -07:00
Mike Klaas 7604061e1c Fix script use-after-free when scripts remove themselves (#573)
* Fix script use-after-free when scripts remove themselves
2026-07-24 08:02:15 -07:00
Mike Klaas f832d78949 [Et tu] Filter out GL* scripts as global if they are in scripts.lst (#586)
* [Et tu] Filter out GL* scripts as global if they are in scripts.lst

Matches Sfall, prevents Et tu problems since a lot of Fo1 scripts start with GL*
2026-07-23 22:26:32 -07:00
Mike Klaas 57b784b8a0 Trigger GameMode::kLoot later (#590)
Mods like https://github.com/FalloutTeamX/sfall-Extended/blob/Extended/artifacts/mods/gl_auto_closebox.ssl access loot_obj in the GAMEMODECHANGE handler.  We need to move it later to prevent crashes (and match Sfall)

Fixes https://github.com/fallout2-ce/fallout2-ce/issues/589
2026-07-23 22:07:31 -07:00
Mike Klaas d5fd197dd9 Fix OOM memory access with alternate damage calculation (#584)
Was causing absurd values and/or lock ups due to using uninitized memory.

Also fix correctness bugs with it.
2026-07-23 21:48:30 -07:00
jirik2077andgithub-actions[bot] 6375604af8 Typesafe combat_defs.h enum usages (#580)
* change HitMode, HitLocation, CriticalHitDescriptionDataMember and CombatBatShot to its respective underlying integer types and enforce enum usage in the functions

* chore: auto-format with clang-format

* renamed CriticalHitDescriptionDataMember to CriticalHitDataMember. implemented isValid functions for the refactored enums in combat_defs.h. created template function for getting validated enum value in interpreter.h.. used isValid enum functions around the place

* chore: auto-format with clang-format

* changed gCombatState from uint handling to bit flags enum

* chore: auto-format with clang-format

* remove unused valid/interpreter method for CombatBadShot

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-07-23 20:16:18 +02:00
Mike Klaas c02c5efcf6 Don't crash on long config file lengths (#581) 2026-07-22 21:36:56 -07:00
Mike Klaas 94a7e7207c Solidify opcode_exists (#579)
* Solidify opcode_exists

* add arg validation
2026-07-21 08:54:38 -07:00
alpacacommunist-cmd b8988b69a8 combatAi: heap fragmentation fix, free previously initialized lists before init (#569)
* free previously initialized lists before init

* adds reasoning comment, safer verification
2026-07-21 13:36:18 +03:00
Mike Klaas 9467f4f778 Allow compat_resolve_path to handle duplicate path separators (#575)
Alternate fix for https://github.com/fallout2-ce/fallout2-ce/pull/563.
2026-07-20 21:49:04 -07:00
V4nnura 447cf6edff Unify linux-armhf and linux-arm64 yaml code. (#574)
* Unify linux-armhf and linux-arm64.
2026-07-20 20:56:26 -07:00
alpacacommunist-cmd c9bcb719ee adds combatSave OBJECT_NO_SAVE predicate + combat list filters (#553)
* adds combatSave OBJECT_NO_SAVE predicate + combat list filters
2026-07-20 20:43:16 -07:00
53 changed files with 1133 additions and 788 deletions
+29 -52
View File
@@ -255,23 +255,38 @@ jobs:
path: out/dist/fallout2-ce-linux-${{ matrix.arch }}.tar.gz
retention-days: 7
linux-armhf:
name: Linux (armhf)
linux-arm:
name: Linux (${{ matrix.arch }})
runs-on: ubuntu-22.04-arm
needs: [ce-dat]
strategy:
fail-fast: false
matrix:
arch:
- armhf
- arm64
steps:
- name: Clone
uses: actions/checkout@v4
- name: Dependencies
- name: Dependencies (armhf)
if: matrix.arch == 'armhf'
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: Dependencies (arm64)
if: matrix.arch == 'arm64'
run: |
sudo apt update
sudo apt install libsdl2-dev zlib1g-dev
- name: Configure (armhf)
if: matrix.arch == 'armhf'
run: |
cmake \
-B build \
@@ -282,46 +297,8 @@ jobs:
-D CMAKE_CXX_COMPILER=arm-linux-gnueabihf-g++ \
# EOL
- name: Build
run: cmake --build build
- name: Download ce.dat
uses: actions/download-artifact@v4
with:
name: ce-dat
path: out/dist
- name: Package
run: |
mkdir -p out/dist/fallout2-ce-linux-armhf
cp build/fallout2-ce out/dist/fallout2-ce-linux-armhf/fallout2-ce
cp out/dist/ce.dat out/dist/fallout2-ce-linux-armhf/ce.dat
cp files/fallout2.cfg out/dist/fallout2-ce-linux-armhf/EXAMPLE_fallout2.cfg
tar -czvf out/dist/fallout2-ce-linux-armhf.tar.gz -C out/dist fallout2-ce-linux-armhf
- name: Upload
uses: actions/upload-artifact@v4
with:
name: fallout2-ce-linux-armhf
path: out/dist/fallout2-ce-linux-armhf.tar.gz
retention-days: 7
linux-arm64:
name: Linux (arm64)
runs-on: ubuntu-22.04-arm
needs: [ce-dat]
steps:
- name: Clone
uses: actions/checkout@v4
- name: Dependencies
run: |
sudo apt update
sudo apt install libsdl2-dev zlib1g-dev
- name: Configure
- name: Configure (arm64)
if: matrix.arch == 'arm64'
run: cmake -B build -D CMAKE_BUILD_TYPE=Debug -D FALLOUT_VENDORED=OFF
- name: Build
@@ -335,17 +312,17 @@ jobs:
- name: Package
run: |
mkdir -p out/dist/fallout2-ce-linux-arm64
cp build/fallout2-ce out/dist/fallout2-ce-linux-arm64/fallout2-ce
cp out/dist/ce.dat out/dist/fallout2-ce-linux-arm64/ce.dat
cp files/fallout2.cfg out/dist/fallout2-ce-linux-arm64/EXAMPLE_fallout2.cfg
tar -czvf out/dist/fallout2-ce-linux-arm64.tar.gz -C out/dist fallout2-ce-linux-arm64
mkdir -p out/dist/fallout2-ce-linux-${{ matrix.arch }}
cp build/fallout2-ce out/dist/fallout2-ce-linux-${{ matrix.arch }}/fallout2-ce
cp out/dist/ce.dat out/dist/fallout2-ce-linux-${{ matrix.arch }}/ce.dat
cp files/fallout2.cfg out/dist/fallout2-ce-linux-${{ matrix.arch }}/EXAMPLE_fallout2.cfg
tar -czvf out/dist/fallout2-ce-linux-${{ matrix.arch }}.tar.gz -C out/dist fallout2-ce-linux-${{ matrix.arch }}
- name: Upload
uses: actions/upload-artifact@v4
with:
name: fallout2-ce-linux-arm64
path: out/dist/fallout2-ce-linux-arm64.tar.gz
name: fallout2-ce-linux-${{ matrix.arch }}
path: out/dist/fallout2-ce-linux-${{ matrix.arch }}.tar.gz
retention-days: 7
macos:
@@ -451,7 +428,7 @@ jobs:
release:
name: Release Continuous build
runs-on: ubuntu-latest
needs: [android, ios, linux, linux-armhf, linux-arm64, macos, windows]
needs: [android, ios, linux, linux-arm, macos, windows]
permissions:
contents: write
steps:
+8 -2
View File
@@ -42,6 +42,11 @@ The following settings were moved into [`<DAT>/config/game.cfg`](files/ce.dat/co
| ddraw.ini section | ddraw.ini key | game.cfg section | game.cfg key |
| --- | --- | --- | --- |
| `Misc` | `StartingMap` | `start` | `map` |
| `Misc` | `StartXPos` | `start` | `worldmap_x` |
| `Misc` | `StartYPos` | `start` | `worldmap_y` |
| `Misc` | `ViewXPos` | `start` | `worldmap_view_x` |
| `Misc` | `ViewYPos` | `start` | `worldmap_view_y` |
| `Misc` | `StartGDialogFix` | `dialog` | `start_gdialog_fix` |
## Opcodes / Metarules
@@ -53,13 +58,14 @@ See [`https://sfall-team.github.io/sfall/`](https://sfall-team.github.io/sfall/)
| Direct memory access| read_byte,short,int,string<br>write_byte,short,int,string<br>call_offset_vX | đźš« | Not possible. Open an issue if you need functionality not covered by other opcodes. |
| Stats | get/set_pc_base_stat<br>get/set_pc_extra_stat<br>get/set_critter_base_stat<br>get/set_critter_extra_stat | âś… | CE uses engine stat helpers here instead of sfall's direct proto-field behavior, so derived-stat update behavior can differ. |
| Stats / Alter min/max | get/set_stat_min/max<br>set_pc_stat_min/max<br>set_npc_stat_min/max | not implemented | - |
| Skills | get/set_critter_skill_points<br>get/set_available_skill_points<br>set_skill_max<br>set_critter_skill_mod<br>set_base_skill_mod<br>mod_skill_points_per_level | not implemented | - |
| Skills | set_skill_max | âś… | - |
| Skills | get/set_critter_skill_points<br>get/set_available_skill_points<br>set_critter_skill_mod<br>set_base_skill_mod<br>mod_skill_points_per_level | not implemented | - |
| Graphics | graphics_funcs_available<br>force_graphics_refresh<br>get_screen_width<br>get_screen_height<br>set_palette | implemented: only get_screen_width, get_screen_height | - |
| Shaders | load_shader<br>free_shader<br>activate_shader<br>deactivate_shader<br>set/get_shader_* | đźš« | likely will not implement direct compatibility
| Perks and traits | set_perk_image<br>set_perk_*<br>set_pyromaniac_mod<br>apply_heaveho_fix<br>set_swiftlearner_mod<br>has/set_fake_perk<br>has/set_fake_trait<br>set_selectable_perk<br>set_perkbox_title<br>show/hide_real_perks<br>perk_add_mode<br>clear_selectable_perks<br>add/remove_trait<br>seq_perk_freq | not implemented | - |
| Virtual file system | fs_create<br>fs_copy<br>fs_find<br>fs_read/write_*<br>fs_delete<br>fs_size<br>fs_pos<br>fs_seek<br>fs_resize | đźš« | Open an issue if you have a use case for these |
| Combat / Knockback | set_weapon_knockback<br>set_target_knockback<br>set_attacker_knockback<br>remove_weapon_knockback<br>remove_target_knockback<br>remove_attacker_knockback | not implemented | - |
| Maps and encounters | in_world_map<br>force_encounter{_with_flags}<br>set_map_time_multi<br>get/set_map_enter_position<br>exec_map_update_scripts<br>get/set_terrain_name<br>set_town_title<br>get/set_can_rest_on_map<br>set_rest_heal_time<br>set_rest_mode<br>set_worldmap_heal_time | implemented: in_world_map, force_encounter, force_encounter_with_flags, set_map_time_multi | - |
| Maps and encounters | in_world_map<br>force_encounter{_with_flags}<br>set_map_time_multi<br>get/set_map_enter_position<br>exec_map_update_scripts<br>get/set_terrain_name<br>set_town_title<br>get/set_can_rest_on_map<br>set_rest_heal_time<br>set_rest_mode<br>set_worldmap_heal_time | implemented: in_world_map, force_encounter, force_encounter_with_flags, set_map_time_multi, get_terrain_name, set_terrain_name | - |
| Maps and encounters / Worldmap | get_world_map_x/y_pos<br>set_world_map_pos | âś… | - |
| Audio | play_sfall_sound<br>stop_sfall_sound | âś… | `play_sfall_sound` currently supports `.acm`, `.wav`, `.ogg` formats, and can load from `.dat` archives. `.mp3` is not yet supported. |
| Combat / Weapons and ammo | get/set_weapon_ammo_pid<br>get/set_weapon_ammo_count | âś… | - |
+6
View File
@@ -11,6 +11,12 @@ month=6
day=24
; To start a new game somewhere other than artemple.map, set this to the map file name.
map=
; Starting worldmap marker position. -1 uses the starting map's world area.
worldmap_x=-1
worldmap_y=-1
; Starting worldmap viewport position. -1 uses the default upper-left view.
worldmap_view_x=-1
worldmap_view_y=-1
; Starting (tribal) and default (jumpsuit) player models. Can also be changed in-game via script.
model_male=hmwarr
model_male_default=hmjmps
+10 -3
View File
@@ -161,13 +161,20 @@ inventory_columns=2
; Set to 1 to scale only the main menu background image to fit the screen while maintaining aspect ratio.
; Set to 2 to also scale the main menu button panel, red buttons, and button labels with the menu art.
main_menu_scale_mode=1
;Set to 1 to keep the main menu visible behind the 640x480 New Game, Load Game, and Options screens,
;but only when the effective main menu background is larger than 640x480.
main_menu_overlay_subscreens=1
; Set to 1 to show a Help option in the in-game options menu which opens the F1 help screen.
in_game_menu_help=1
; Weight/size indicator for PC, critters and containers
; Set to 0 for vanilla behavior (no weight indicator)
; Set to 1 to show a simple weight indicator; works with all inventory_columns values
; Set to 2 to show a detailed weight indicator; works with inventory_columns > 1 only
loot_weight_indicator=1
; Set to 0 to show container indicator at all times
; Set to XX to show container indicator when size reaches XX%
; Set to 100 to show container indicator when full
loot_container_size_indicator_threshold=50
[qol]
; Automatically open doors that are unlocked and has no script attached.
+27
View File
@@ -0,0 +1,27 @@
#include "test_utils.h"
#include "sfall.h"
procedure start begin
variable defaultName;
display_msg("Testing terrain name metarules...");
call assertEquals("get metarule exists", metarule_exist("get_terrain_name"), 1);
call assertEquals("set metarule exists", metarule_exist("set_terrain_name"), 1);
defaultName := get_terrain_name(0, 0);
call assertNotEquals("default terrain name is not error", defaultName, "Error");
call assertNotEquals("default terrain name is not empty", defaultName, "");
set_terrain_name(0, 0, "CE Terrain Override");
call assertEquals("terrain override is returned", get_terrain_name(0, 0), "CE Terrain Override");
set_terrain_name(0, 0, "CE Terrain Override 2");
call assertEquals("latest terrain override wins", get_terrain_name(0, 0), "CE Terrain Override 2");
call assertEquals("one argument get returns error", sfall_func1("get_terrain_name", 0), -1);
call assertEquals("invalid get returns error", get_terrain_name(-1, 0), "Error");
call assertNotEquals("current terrain name is available", get_current_terrain_name, "Error");
call report_test_results("terrain_name");
signal_close_game;
end
+2 -1
View File
@@ -21,10 +21,11 @@ procedure start begin
call assertEquals("opcode_exists OP_NOOP", opcode_exists(OP_NOOP), 1);
// Probably will never be implemented on fallout2-ce
call assertEquals("opcode_exists OP_WRITE_INT", opcode_exists(OP_WRITE_INT), 0);
call assertEquals("opcode_exists bare index", opcode_exists(0x1B3), 0);
call assertEquals("opcode_exists 0xFFFF", opcode_exists(0xFFFF), 0);
end else begin
display_msg("Opcode exists metarule is not available, skipping tests.");
end
call report_test_results("metarule_exist");
end
end
+38
View File
@@ -0,0 +1,38 @@
#include "define_lite.h"
#include "define_extra.h"
#include "sfall.h"
#include "test_utils.h"
procedure start begin
variable skill_offset;
variable original_points;
variable original_value;
variable capped_points;
if (not game_loaded) then return;
display_msg("Testing set_skill_max...");
test_suite_errors := 0;
skill_offset := PROTO_CR_SKILLS + (SKILL_SMALL_GUNS * 4);
original_points := get_proto_data(obj_pid(dude_obj), skill_offset);
original_value := has_skill(dude_obj, SKILL_SMALL_GUNS);
set_skill_max(300);
critter_mod_skill(dude_obj, SKILL_SMALL_GUNS, 1000);
call assertEquals("skill raised to vanilla cap", has_skill(dude_obj, SKILL_SMALL_GUNS), 300);
capped_points := get_proto_data(obj_pid(dude_obj), skill_offset);
set_skill_max(200);
call assertEquals("existing skill clamped to 200", has_skill(dude_obj, SKILL_SMALL_GUNS), 200);
critter_mod_skill(dude_obj, SKILL_SMALL_GUNS, 1);
call assertEquals("skill points unchanged at cap", get_proto_data(obj_pid(dude_obj), skill_offset), capped_points);
set_skill_max(300);
set_proto_data(obj_pid(dude_obj), skill_offset, original_points);
call assertEquals("original skill restored", has_skill(dude_obj, SKILL_SMALL_GUNS), original_value);
call report_test_results("set_skill_max");
signal_close_game;
end
+1 -1
View File
@@ -3019,7 +3019,7 @@ int _check_move(int* actionPointsPtr)
if (isInCombat()) {
if (*actionPointsPtr != -1) {
if (gPressedPhysicalKeys[SDL_SCANCODE_RCTRL] || gPressedPhysicalKeys[SDL_SCANCODE_LCTRL]) {
int hitMode;
HitMode hitMode;
bool aiming;
interfaceGetCurrentHitMode(&hitMode, &aiming);
+3 -1
View File
@@ -1789,11 +1789,13 @@ void FrmImage::resetInternal()
bool FrmImage::setFrame(const Art* art, int frame, int direction)
{
unsigned char* data = artGetFrameData(art, frame, direction, &_width, &_height, &_xOffset, &_yOffset);
unsigned char* data = artGetFrameData(art, frame, direction, &_width, &_height, nullptr, nullptr);
if (data == nullptr) {
return false;
}
_xOffset = art->xOffsets[direction];
_yOffset = art->yOffsets[direction];
_data = data;
return true;
}
+6 -13
View File
@@ -28,7 +28,6 @@
#include "interface.h"
#include "item.h"
#include "kb.h"
#include "mainmenu.h"
#include "map.h"
#include "memory.h"
#include "message.h"
@@ -233,7 +232,6 @@ typedef struct KillInfo {
static int characterEditorWindowInit();
static void characterEditorWindowFree();
static int characterEditorGetModalWindowFlags();
static int _get_input_str(int win, int cancelKeyCode, char* text, int maxLength, int x, int y, int textColor, int backgroundColor, int flags);
static void characterEditorDrawFolders();
static void characterEditorDrawPerksFolder();
@@ -1206,11 +1204,6 @@ int characterEditorShow(bool isCreationMode)
return rc;
}
static int characterEditorGetModalWindowFlags()
{
return mainMenuSubscreenWindowFlags(WINDOW_MODAL | WINDOW_DONT_MOVE_TOP, WINDOW_MODAL | WINDOW_MOVE_ON_TOP);
}
// 0x4329EC CharEditStart
static int characterEditorWindowInit()
{
@@ -1385,7 +1378,7 @@ static int characterEditorWindowInit()
EDITOR_WINDOW_WIDTH,
EDITOR_WINDOW_HEIGHT,
256,
characterEditorGetModalWindowFlags());
WINDOW_MODAL | WINDOW_DONT_MOVE_TOP);
if (gCharacterEditorWindow == -1) {
for (i = 0; i < EDITOR_GRAPHIC_COUNT; i++) {
if (gCharacterEditorFrmShouldCopy[i]) {
@@ -3218,7 +3211,7 @@ static int characterEditorEditName()
int nameWindowX = (screenGetWidth() - EDITOR_WINDOW_WIDTH) / 2 + 17;
int nameWindowY = (screenGetHeight() - EDITOR_WINDOW_HEIGHT) / 2;
int win = windowCreate(nameWindowX, nameWindowY, windowWidth, windowHeight, 256, characterEditorGetModalWindowFlags());
int win = windowCreate(nameWindowX, nameWindowY, windowWidth, windowHeight, 256, WINDOW_MODAL | WINDOW_DONT_MOVE_TOP);
if (win == -1) {
return -1;
}
@@ -3350,7 +3343,7 @@ static int characterEditorEditAge()
int ageWindowX = (screenGetWidth() - EDITOR_WINDOW_WIDTH) / 2 + _editorFrmImages[EDITOR_GRAPHIC_NAME_ON].getWidth() + 9;
int ageWindowY = (screenGetHeight() - EDITOR_WINDOW_HEIGHT) / 2;
win = windowCreate(ageWindowX, ageWindowY, windowWidth, windowHeight, 256, characterEditorGetModalWindowFlags());
win = windowCreate(ageWindowX, ageWindowY, windowWidth, windowHeight, 256, WINDOW_MODAL | WINDOW_DONT_MOVE_TOP);
if (win == -1) {
return -1;
}
@@ -3589,7 +3582,7 @@ static void characterEditorEditGender()
+ _editorFrmImages[EDITOR_GRAPHIC_NAME_ON].getWidth()
+ _editorFrmImages[EDITOR_GRAPHIC_AGE_ON].getWidth();
int genderWindowY = (screenGetHeight() - EDITOR_WINDOW_HEIGHT) / 2;
int win = windowCreate(genderWindowX, genderWindowY, windowWidth, windowHeight, 256, characterEditorGetModalWindowFlags());
int win = windowCreate(genderWindowX, genderWindowY, windowWidth, windowHeight, 256, WINDOW_MODAL | WINDOW_DONT_MOVE_TOP);
if (win == -1) {
return;
@@ -3832,7 +3825,7 @@ static int characterEditorShowOptions()
int optionsWindowY = (screenGetHeight() != 480)
? (screenGetHeight() - _editorFrmImages[41].getHeight()) / 2
: 90;
int win = windowCreate(optionsWindowX, optionsWindowY, _editorFrmImages[41].getWidth(), _editorFrmImages[41].getHeight(), 256, characterEditorGetModalWindowFlags());
int win = windowCreate(optionsWindowX, optionsWindowY, _editorFrmImages[41].getWidth(), _editorFrmImages[41].getHeight(), 256, WINDOW_MODAL | WINDOW_DONT_MOVE_TOP);
if (win == -1) {
return -1;
}
@@ -5837,7 +5830,7 @@ static int perkDialogShow()
int perkWindowY = screenGetHeight() != 480
? (screenGetHeight() - PERK_WINDOW_HEIGHT) / 2
: PERK_WINDOW_Y;
gPerkDialogWindow = windowCreate(perkWindowX, perkWindowY, PERK_WINDOW_WIDTH, PERK_WINDOW_HEIGHT, 256, characterEditorGetModalWindowFlags());
gPerkDialogWindow = windowCreate(perkWindowX, perkWindowY, PERK_WINDOW_WIDTH, PERK_WINDOW_HEIGHT, 256, WINDOW_MODAL | WINDOW_DONT_MOVE_TOP);
if (gPerkDialogWindow == -1) {
_perkDialogBackgroundFrmImage.unlock();
debugPrint("\n *** Error running perks dialog window ***\n");
+4 -9
View File
@@ -18,7 +18,6 @@
#include "game_sound.h"
#include "input.h"
#include "kb.h"
#include "mainmenu.h"
#include "memory.h"
#include "message.h"
#include "mouse.h"
@@ -161,7 +160,8 @@ int characterSelectorOpen()
mouseShowCursor();
}
mainMenuShowSubscreen(true);
colorPaletteLoad("color.pal");
paletteFadeTo(_cmap);
int rc = 0;
bool done = false;
@@ -247,11 +247,7 @@ int characterSelectorOpen()
sharedFpsLimiter.throttle();
}
if (rc == 2) {
mainMenuFadeOutAfterSubscreen(true);
} else {
mainMenuRestoreAfterSubscreen(true);
}
paletteFadeTo(gPaletteBlack);
characterSelectorWindowFree();
if (cursorWasHidden) {
@@ -273,8 +269,7 @@ static bool characterSelectorWindowInit()
int characterSelectorWindowX = (screenGetWidth() - CS_WINDOW_WIDTH) / 2;
int characterSelectorWindowY = (screenGetHeight() - CS_WINDOW_HEIGHT) / 2;
int characterSelectorWindowFlags = mainMenuSubscreenWindowFlags(0, WINDOW_MODAL | WINDOW_MOVE_ON_TOP);
gCharacterSelectorWindow = windowCreate(characterSelectorWindowX, characterSelectorWindowY, CS_WINDOW_WIDTH, CS_WINDOW_HEIGHT, _colorTable[0], characterSelectorWindowFlags);
gCharacterSelectorWindow = windowCreate(characterSelectorWindowX, characterSelectorWindowY, CS_WINDOW_WIDTH, CS_WINDOW_HEIGHT, COLOR_BLACK, 0);
if (gCharacterSelectorWindow == -1) {
return characterSelectorWindowFatalError(false);
}
+119 -76
View File
File diff suppressed because it is too large Load Diff
+21 -21
View File
@@ -9,7 +9,7 @@
namespace fallout {
extern int _combatNumTurns;
extern unsigned int gCombatState;
extern CombatState gCombatState;
extern int _combat_free_move;
@@ -19,7 +19,7 @@ void combatExit();
int _find_cid(int a1, int a2, Object** a3, int a4);
int combatLoad(File* stream);
int combatSave(File* stream);
bool _combat_safety_invalidate_weapon(Object* attacker, Object* weapon, int hitMode, Object* defender, int* safeDistancePtr);
bool _combat_safety_invalidate_weapon(Object* attacker, Object* weapon, HitMode hitMode, Object* defender, int* safeDistancePtr);
bool _combatTestIncidentalHit(Object* attacker, Object* defender, Object* attackerFriend, Object* weapon);
Object* _combat_whose_turn();
void _combat_data_init(Object* obj);
@@ -34,19 +34,19 @@ 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);
void attackInit(Attack* attack, Object* attacker, Object* defender, HitMode hitMode, HitLocation hitLocation);
int _combat_attack(Object* attacker, Object* defender, HitMode hitMode, HitLocation hitLocation);
int _combat_bullet_start(const Object* attacker, const Object* target);
void _compute_explosion_on_extras(Attack* attack, bool isFromAttacker, bool isGrenade, bool noDamage);
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(Object* a1, Object* a2, HitLocation hitLocation, HitMode hitMode);
int _determine_to_hit_no_range(Object* attacker, Object* defender, HitLocation hitLocation, HitMode hitMode, unsigned char* a5);
int _determine_to_hit_from_tile(Object* attacker, int tile, Object* defender, HitLocation hitLocation, HitMode hitMode);
void attackComputeDeathFlags(Attack* attack);
void _apply_damage(Attack* attack, bool animated);
void _combat_display(Attack* attack);
void _combat_anim_begin();
void _combat_anim_finished();
int _combat_check_bad_shot(Object* attacker, Object* defender, int hitMode, bool aiming);
CombatBadShot _combat_check_bad_shot(Object* attacker, Object* defender, HitMode hitMode, bool aiming);
bool _combat_to_hit(Object* target, int* accuracy);
void _combat_attack_this(Object* target);
void _combat_outline_on();
@@ -59,21 +59,21 @@ void _combat_delete_critter(Object* obj);
void _combatKillCritterOutsideCombat(Object* critter_obj, char* msg);
int combatGetTargetHighlight();
int criticalsGetValue(int killType, int hitLocation, int effect, int dataMember);
void criticalsSetValue(int killType, int hitLocation, int effect, int dataMember, int value);
void criticalsResetValue(int killType, int hitLocation, int effect, int dataMember);
int criticalsGetValue(int killType, HitLocation hitLocation, int effect, CriticalHitDataMember dataMember);
void criticalsSetValue(int killType, HitLocation hitLocation, int effect, CriticalHitDataMember dataMember, int value);
void criticalsResetValue(int killType, HitLocation hitLocation, int effect, CriticalHitDataMember dataMember);
bool criticalsNoTimeLimits();
int unarmedGetDamage(int hitMode, int* minDamagePtr, int* maxDamagePtr);
int unarmedGetBonusCriticalChance(int hitMode);
int unarmedGetActionPointCost(int hitMode);
bool unarmedIsPenetrating(int hitMode);
int unarmedGetPunchHitMode(bool isSecondary);
int unarmedGetKickHitMode(bool isSecondary);
bool unarmedIsPenetrating(int hitMode);
int unarmedGetDamage(HitMode hitMode, int* minDamagePtr, int* maxDamagePtr);
int unarmedGetBonusCriticalChance(HitMode hitMode);
int unarmedGetActionPointCost(HitMode hitMode);
bool unarmedIsPenetrating(HitMode hitMode);
HitMode unarmedGetPunchHitMode(bool isSecondary);
HitMode unarmedGetKickHitMode(bool isSecondary);
bool unarmedIsPenetrating(HitMode hitMode);
bool damageModGetBonusHthDamageFix();
bool damageModGetDisplayBonusDamage();
int combat_get_hit_location_penalty(int hit_location);
void combat_set_hit_location_penalty(int hit_location, int penalty);
int combat_get_hit_location_penalty(HitLocation hitLocation);
void combat_set_hit_location_penalty(HitLocation hitLocation, int penalty);
void combat_reset_hit_location_penalty();
Attack* combat_get_data();
@@ -82,7 +82,7 @@ static inline bool isInCombat()
return (gCombatState & COMBAT_STATE_IN_COMBAT) != 0;
}
static inline bool isUnarmedHitMode(int hitMode)
static inline bool isUnarmedHitMode(HitMode hitMode)
{
return hitMode == HIT_MODE_PUNCH
|| hitMode == HIT_MODE_KICK
+30 -24
View File
@@ -93,19 +93,19 @@ static Object* _ai_danger_source(Object* a1);
static bool aiHaveAmmo(Object* critter, Object* weapon, Object** ammoPtr);
static bool _caiHasWeapPrefType(AiPacket* ai, int attackType);
static Object* _ai_best_weapon(Object* a1, Object* a2, Object* a3, Object* a4);
static bool _ai_can_use_weapon(Object* critter, Object* weapon, int hitMode);
static bool _ai_can_use_weapon(Object* critter, Object* weapon, HitMode hitMode);
static bool aiCanUseItem(Object* obj, Object* a2);
static Object* _ai_search_environ(Object* critter, int itemType);
static Object* _ai_retrieve_object(Object* critter, Object* item);
static int _ai_pick_hit_mode(Object* attacker, Object* weapon, Object* defender);
static HitMode _ai_pick_hit_mode(Object* attacker, Object* weapon, Object* defender);
static int _ai_move_steps_closer(Object* a1, Object* a2, int actionPoints, bool taunt);
static int _ai_move_closer(Object* a1, Object* a2, bool taunt);
static int _cai_retargetTileFromFriendlyFire(Object* source, Object* target, int* tilePtr);
static int _cai_retargetTileFromFriendlyFireSubFunc(AiRetargetData* aiRetargetData, int tile);
static bool _cai_attackWouldIntersect(Object* attacker, Object* defender, Object* attackerFriend, int tile, int* distance);
static int _ai_switch_weapons(Object* a1, int* hitMode, Object** weapon, Object* a4);
static int _ai_called_shot(Object* attacker, Object* defender, int hitMode);
static int _ai_attack(Object* attacker, Object* defender, int hitMode);
static int _ai_switch_weapons(Object* a1, HitMode* hitMode, Object** weapon, Object* a4);
static HitLocation _ai_called_shot(Object* attacker, Object* defender, HitMode hitMode);
static int _ai_attack(Object* attacker, Object* defender, HitMode hitMode);
static int _ai_try_attack(Object* a1, Object* a2);
static int _cai_get_min_hp(AiPacket* ai);
static int _ai_print_msg(Object* critter, int type);
@@ -1619,7 +1619,7 @@ static Object* _ai_danger_source(Object* a1)
// Check if we can attack it. No ammo and out of
// range are ok results, since we can reload weapon
// move closer if necessary.
int badShot = _combat_check_bad_shot(a1, critter, HIT_MODE_RIGHT_WEAPON_PRIMARY, false);
CombatBadShot badShot = _combat_check_bad_shot(a1, critter, HIT_MODE_RIGHT_WEAPON_PRIMARY, false);
if (badShot != COMBAT_BAD_SHOT_OK
&& badShot != COMBAT_BAD_SHOT_NO_AMMO
&& badShot != COMBAT_BAD_SHOT_OUT_OF_RANGE) {
@@ -1975,7 +1975,7 @@ static Object* _ai_best_weapon(Object* attacker, Object* weapon1, Object* weapon
}
// 0x4298EC
static bool _ai_can_use_weapon(Object* critter, Object* weapon, int hitMode)
static bool _ai_can_use_weapon(Object* critter, Object* weapon, HitMode hitMode)
{
bool result = critterCanUseWeapon(critter, weapon, hitMode);
@@ -2260,7 +2260,7 @@ static Object* _ai_retrieve_object(Object* critter, Object* item)
}
// 0x429DB4
static int _ai_pick_hit_mode(Object* attacker, Object* weapon, Object* defender)
static HitMode _ai_pick_hit_mode(Object* attacker, Object* weapon, Object* defender)
{
if (weapon == nullptr) {
return HIT_MODE_PUNCH;
@@ -2302,19 +2302,19 @@ static int _ai_pick_hit_mode(Object* attacker, Object* weapon, Object* defender)
break;
case AREA_ATTACK_MODE_BE_SURE:
if (_determine_to_hit(attacker, defender, HIT_LOCATION_TORSO, HIT_MODE_RIGHT_WEAPON_SECONDARY) >= 85
&& !_combat_safety_invalidate_weapon(attacker, weapon, 3, defender, nullptr)) {
&& !_combat_safety_invalidate_weapon(attacker, weapon, HIT_MODE_RIGHT_WEAPON_SECONDARY, defender, nullptr)) {
useSecondaryMode = true;
}
break;
case AREA_ATTACK_MODE_BE_CAREFUL:
if (_determine_to_hit(attacker, defender, HIT_LOCATION_TORSO, HIT_MODE_RIGHT_WEAPON_SECONDARY) >= 50
&& !_combat_safety_invalidate_weapon(attacker, weapon, 3, defender, nullptr)) {
&& !_combat_safety_invalidate_weapon(attacker, weapon, HIT_MODE_RIGHT_WEAPON_SECONDARY, defender, nullptr)) {
useSecondaryMode = true;
}
break;
case AREA_ATTACK_MODE_BE_ABSOLUTELY_SURE:
if (_determine_to_hit(attacker, defender, HIT_LOCATION_TORSO, HIT_MODE_RIGHT_WEAPON_SECONDARY) >= 95
&& !_combat_safety_invalidate_weapon(attacker, weapon, 3, defender, nullptr)) {
&& !_combat_safety_invalidate_weapon(attacker, weapon, HIT_MODE_RIGHT_WEAPON_SECONDARY, defender, nullptr)) {
useSecondaryMode = true;
}
break;
@@ -2574,7 +2574,7 @@ static int _cai_retargetTileFromFriendlyFireSubFunc(AiRetargetData* aiRetargetDa
// 0x42A518
static bool _cai_attackWouldIntersect(Object* attacker, Object* defender, Object* attackerFriend, int tile, int* distance)
{
int hitMode = HIT_MODE_RIGHT_WEAPON_PRIMARY;
HitMode hitMode = HIT_MODE_RIGHT_WEAPON_PRIMARY;
bool aiming = false;
if (attacker == gDude) {
interfaceGetCurrentHitMode(&hitMode, &aiming);
@@ -2601,7 +2601,7 @@ static bool _cai_attackWouldIntersect(Object* attacker, Object* defender, Object
}
// 0x42A5B8
static int _ai_switch_weapons(Object* attacker, int* hitMode, Object** weapon, Object* defender)
static int _ai_switch_weapons(Object* attacker, HitMode* hitMode, Object** weapon, Object* defender)
{
*weapon = nullptr;
*hitMode = HIT_MODE_PUNCH;
@@ -2639,9 +2639,9 @@ static int _ai_switch_weapons(Object* attacker, int* hitMode, Object** weapon, O
}
// 0x42A670
static int _ai_called_shot(Object* attacker, Object* defender, int hitMode)
static HitLocation _ai_called_shot(Object* attacker, Object* defender, HitMode hitMode)
{
int hitLocation = HIT_LOCATION_TORSO;
HitLocation hitLocation = HIT_LOCATION_TORSO;
if (weaponGetActionPointCost(attacker, hitMode, true) <= attacker->data.critter.combat.ap) {
if (critterCanAim(attacker, hitMode)) {
@@ -2661,8 +2661,8 @@ static int _ai_called_shot(Object* attacker, Object* defender, int hitMode)
}
if (critterGetStat(attacker, STAT_INTELLIGENCE) >= intelligenceRequired) {
hitLocation = randomBetween(0, HIT_LOCATION_SPECIFIC_COUNT);
int chanceToHit = _determine_to_hit(attacker, defender, hitMode, hitLocation);
hitLocation = static_cast<HitLocation>(randomBetween(HIT_LOCATION_HEAD, HIT_LOCATION_SPECIFIC_COUNT));
int chanceToHit = _determine_to_hit(attacker, defender, hitLocation, hitMode);
if (chanceToHit < ai->min_to_hit) {
hitLocation = HIT_LOCATION_TORSO;
}
@@ -2675,7 +2675,7 @@ static int _ai_called_shot(Object* attacker, Object* defender, int hitMode)
}
// 0x42A748
static int _ai_attack(Object* attacker, Object* defender, int hitMode)
static int _ai_attack(Object* attacker, Object* defender, HitMode hitMode)
{
if (attacker->data.critter.combat.maneuver & CRITTER_MANUEVER_FLEEING) {
return -1;
@@ -2686,7 +2686,7 @@ static int _ai_attack(Object* attacker, Object* defender, int hitMode)
reg_anim_end();
_combat_turn_run();
int hitLocation = _ai_called_shot(attacker, defender, hitMode);
HitLocation hitLocation = _ai_called_shot(attacker, defender, hitMode);
if (_combat_attack(attacker, defender, hitMode, hitLocation)) {
return -1;
}
@@ -2709,7 +2709,7 @@ static int _ai_try_attack(Object* attacker, Object* defender)
weapon = nullptr;
}
int hitMode = _ai_pick_hit_mode(attacker, weapon, defender);
HitMode hitMode = _ai_pick_hit_mode(attacker, weapon, defender);
int minToHit = aiGetPacket(attacker)->min_to_hit;
int actionPoints = attacker->data.critter.combat.ap;
@@ -2736,7 +2736,7 @@ static int _ai_try_attack(Object* attacker, Object* defender)
break;
}
int reason = _combat_check_bad_shot(attacker, defender, hitMode, false);
CombatBadShot reason = _combat_check_bad_shot(attacker, defender, hitMode, false);
if (reason == COMBAT_BAD_SHOT_NO_AMMO) {
// If the secondary attack (for example, burst fire) does not have enough ammo,
// try the primary attack, which may have a lower ammo cost.
@@ -2821,9 +2821,6 @@ static int _ai_try_attack(Object* attacker, Object* defender)
}
}
} else if (reason == COMBAT_BAD_SHOT_NOT_ENOUGH_AP || reason == COMBAT_BAD_SHOT_ARM_CRIPPLED || reason == COMBAT_BAD_SHOT_BOTH_ARMS_CRIPPLED) {
// 3 - not enough action points
// 6 - crippled one arm for two-handed weapon
// 7 - both hands crippled
if (_ai_switch_weapons(attacker, &hitMode, &weapon, defender) == -1) {
return -1;
}
@@ -3593,6 +3590,15 @@ bool isWithinPerception(Object* watcher, Object* target)
// 0x42BB34
static int aiMessageListInit()
{
// Prevent chronic memory leak on preference/language filter reloads.
// If gCombatAiMessageList was already populated from a previous init cascade,
// we must deeply free its entries before re-initializing the layout,
// otherwise the subsequent load will overwrite active pointers and isolate strings in the heap.
if (gCombatAiMessageList.entries != nullptr && gCombatAiMessageList.entries_num > 0) {
messageListRepositorySetStandardMessageList(STANDARD_MESSAGE_LIST_COMBAT_AI, nullptr);
messageListFree(&gCombatAiMessageList);
}
if (!messageListInit(&gCombatAiMessageList)) {
return -1;
}
+93 -32
View File
@@ -12,13 +12,38 @@
namespace fallout {
typedef enum CombatState {
enum CombatState : unsigned int {
COMBAT_STATE_OUT_COMBAT = 0x00,
COMBAT_STATE_IN_COMBAT = 0x01,
COMBAT_STATE_PLAYER_TURN = 0x02,
COMBAT_STATE_EXIT_REQUESTED = 0x08,
} CombatState;
};
typedef enum HitMode {
inline fallout::CombatState& operator&=(fallout::CombatState& lhs, unsigned int rhs)
{
lhs = static_cast<fallout::CombatState>(static_cast<unsigned int>(lhs) & rhs);
return lhs;
}
inline constexpr CombatState operator~(CombatState rhs)
{
return static_cast<CombatState>(~static_cast<unsigned int>(rhs));
}
inline CombatState& operator&=(CombatState& lhs, CombatState rhs)
{
lhs = static_cast<CombatState>(static_cast<unsigned int>(lhs) & static_cast<unsigned int>(rhs));
return lhs;
}
inline CombatState& operator|=(CombatState& lhs, CombatState rhs)
{
lhs = static_cast<CombatState>(static_cast<unsigned int>(lhs) | static_cast<unsigned int>(rhs));
return lhs;
}
enum HitMode : int {
HIT_MODE_INVALID = -1,
HIT_MODE_LEFT_WEAPON_PRIMARY = 0,
HIT_MODE_LEFT_WEAPON_SECONDARY = 1,
HIT_MODE_RIGHT_WEAPON_PRIMARY = 2,
@@ -70,21 +95,45 @@ typedef enum HitMode {
LAST_ADVANCED_KICK_HIT_MODE = HIT_MODE_PIERCING_KICK,
FIRST_ADVANCED_UNARMED_HIT_MODE = FIRST_ADVANCED_PUNCH_HIT_MODE,
LAST_ADVANCED_UNARMED_HIT_MODE = LAST_ADVANCED_KICK_HIT_MODE,
} HitMode;
};
typedef enum HitLocation {
HIT_LOCATION_HEAD,
HIT_LOCATION_LEFT_ARM,
HIT_LOCATION_RIGHT_ARM,
HIT_LOCATION_TORSO,
HIT_LOCATION_RIGHT_LEG,
HIT_LOCATION_LEFT_LEG,
HIT_LOCATION_EYES,
HIT_LOCATION_GROIN,
HIT_LOCATION_UNCALLED,
HIT_LOCATION_COUNT,
inline static bool hitModeIsValid(int hitMode)
{
return hitMode >= HIT_MODE_LEFT_WEAPON_PRIMARY && hitMode < HIT_MODE_COUNT;
}
inline HitMode operator++(HitMode& e, int)
{
HitMode result = e;
e = static_cast<HitMode>(static_cast<int>(e) + 1);
return result;
}
enum HitLocation : int {
HIT_LOCATION_HEAD = 0,
HIT_LOCATION_LEFT_ARM = 1,
HIT_LOCATION_RIGHT_ARM = 2,
HIT_LOCATION_TORSO = 3,
HIT_LOCATION_RIGHT_LEG = 4,
HIT_LOCATION_LEFT_LEG = 5,
HIT_LOCATION_EYES = 6,
HIT_LOCATION_GROIN = 7,
HIT_LOCATION_UNCALLED = 8,
HIT_LOCATION_COUNT = 9,
HIT_LOCATION_SPECIFIC_COUNT = HIT_LOCATION_COUNT - 1,
} HitLocation;
};
inline static bool hitLocationIsValid(int hitLocation)
{
return hitLocation >= HIT_LOCATION_HEAD && hitLocation < HIT_LOCATION_COUNT;
}
inline HitLocation operator++(HitLocation& e, int)
{
HitLocation result = e;
e = static_cast<HitLocation>(static_cast<int>(e) + 1);
return result;
}
typedef struct CombatStartData {
Object* attacker;
@@ -101,16 +150,16 @@ typedef struct CombatStartData {
typedef struct Attack {
Object* attacker;
int hitMode;
HitMode hitMode;
Object* weapon;
int attackHitLocation; // UNUSED?
HitLocation attackHitLocation; // UNUSED?
int attackerDamage;
int attackerFlags;
int ammoQuantity;
int criticalMessageId;
Object* defender;
int tile;
int defenderHitLocation;
HitLocation defenderHitLocation;
int defenderDamage;
int defenderFlags;
int defenderKnockback;
@@ -123,16 +172,28 @@ typedef struct Attack {
int extrasKnockback[EXPLOSION_TARGET_COUNT];
} Attack;
typedef enum CriticalHitDescriptionDataMember {
CRIT_DATA_MEMBER_DAMAGE_MULTIPLIER,
CRIT_DATA_MEMBER_FLAGS,
CRIT_DATA_MEMBER_MASSIVE_CRITICAL_STAT,
CRIT_DATA_MEMBER_MASSIVE_CRITICAL_STAT_MODIFIER,
CRIT_DATA_MEMBER_MASSIVE_CRITICAL_FLAGS,
CRIT_DATA_MEMBER_MESSAGE_ID,
CRIT_DATA_MEMBER_MASSIVE_CRITICAL_MESSAGE_ID,
CRIT_DATA_MEMBER_COUNT,
} CriticalHitDescriptionDataMember;
enum CriticalHitDataMember : int {
CRIT_DATA_MEMBER_DAMAGE_MULTIPLIER = 0,
CRIT_DATA_MEMBER_FLAGS = 1,
CRIT_DATA_MEMBER_MASSIVE_CRITICAL_STAT = 2,
CRIT_DATA_MEMBER_MASSIVE_CRITICAL_STAT_MODIFIER = 3,
CRIT_DATA_MEMBER_MASSIVE_CRITICAL_FLAGS = 4,
CRIT_DATA_MEMBER_MESSAGE_ID = 5,
CRIT_DATA_MEMBER_MASSIVE_CRITICAL_MESSAGE_ID = 6,
CRIT_DATA_MEMBER_COUNT = 7,
};
inline static bool criticalHitDataMemberIsValid(int criticalHitDataMember)
{
return criticalHitDataMember >= CRIT_DATA_MEMBER_DAMAGE_MULTIPLIER && criticalHitDataMember < CRIT_DATA_MEMBER_COUNT;
}
inline CriticalHitDataMember operator++(CriticalHitDataMember& e, int)
{
CriticalHitDataMember result = e;
e = static_cast<CriticalHitDataMember>(static_cast<int>(e) + 1);
return result;
}
// Provides metadata about critical hit effect.
typedef union CriticalHitDescription {
@@ -160,7 +221,7 @@ typedef union CriticalHitDescription {
int values[CRIT_DATA_MEMBER_COUNT];
} CriticalHitDescription;
typedef enum CombatBadShot {
enum CombatBadShot : int {
COMBAT_BAD_SHOT_OK = 0,
COMBAT_BAD_SHOT_NO_AMMO = 1,
COMBAT_BAD_SHOT_OUT_OF_RANGE = 2,
@@ -168,8 +229,8 @@ typedef enum CombatBadShot {
COMBAT_BAD_SHOT_ALREADY_DEAD = 4,
COMBAT_BAD_SHOT_AIM_BLOCKED = 5,
COMBAT_BAD_SHOT_ARM_CRIPPLED = 6,
COMBAT_BAD_SHOT_BOTH_ARMS_CRIPPLED = 7,
} CombatBadShot;
COMBAT_BAD_SHOT_BOTH_ARMS_CRIPPLED = 7
};
} // namespace fallout
+32 -15
View File
@@ -17,7 +17,7 @@
namespace fallout {
#define CONFIG_FILE_MAX_LINE_LENGTH (1024)
#define CONFIG_FILE_MAX_LINE_LENGTH (2048)
// The initial number of sections (or key-value) pairs in the config.
#define CONFIG_INITIAL_CAPACITY (10)
@@ -32,9 +32,10 @@ struct CaseInsensitiveLess {
typedef std::set<std::string, CaseInsensitiveLess> StringSet;
static bool configParseLine(Config* config, char* string);
static bool configParseKeyValue(char* string, char* key, char* value);
static bool configParseKeyValue(char* string, std::string& key, std::string& value);
static bool configEnsureSectionExists(Config* config, const char* sectionKey);
static bool configTrimString(char* string);
static std::string configGetTrimmedString(const char* string);
static bool configWriteDb(Config* config, const char* filePath);
static bool configWriteStandard(Config* config, const char* filePath);
@@ -120,10 +121,10 @@ bool configParseCommandLineArguments(Config* config, int argc, char** argv)
*pch = '\0';
char key[260];
char value[260];
std::string key;
std::string value;
if (configParseKeyValue(pch + 1, key, value)) {
if (!configSetString(config, sectionKey, key, value)) {
if (!configSetString(config, sectionKey, key.c_str(), value.c_str())) {
*pch = ']';
return false;
}
@@ -683,13 +684,13 @@ static bool configParseLine(Config* config, char* string)
}
}
char key[260];
char value[260];
std::string key;
std::string value;
if (!configParseKeyValue(string, key, value)) {
return false;
}
return configSetString(config, gConfigLastSectionKey, key, value);
return configSetString(config, gConfigLastSectionKey, key.c_str(), value.c_str());
}
// Splits "key=value" pair from [string] and copy appropriate parts into [key]
@@ -698,9 +699,9 @@ static bool configParseLine(Config* config, char* string)
// Both key and value are trimmed.
//
// 0x42C594
static bool configParseKeyValue(char* string, char* key, char* value)
static bool configParseKeyValue(char* string, std::string& key, std::string& value)
{
if (string == nullptr || key == nullptr || value == nullptr) {
if (string == nullptr) {
return false;
}
@@ -712,14 +713,11 @@ static bool configParseKeyValue(char* string, char* key, char* value)
*pch = '\0';
strcpy(key, string);
strcpy(value, pch + 1);
key = configGetTrimmedString(string);
value = configGetTrimmedString(pch + 1);
*pch = '=';
configTrimString(key);
configTrimString(value);
return true;
}
@@ -791,6 +789,25 @@ static bool configTrimString(char* string)
return true;
}
static std::string configGetTrimmedString(const char* string)
{
if (string == nullptr) {
return std::string();
}
const char* start = string;
while (isspace(static_cast<unsigned char>(*start))) {
start++;
}
const char* end = start + strlen(start);
while (end > start && isspace(static_cast<unsigned char>(*(end - 1)))) {
end--;
}
return std::string(start, end);
}
// 0x42C718
bool configGetDouble(Config* config, const char* sectionKey, const char* key, double* valuePtr)
{
+1 -1
View File
@@ -1024,7 +1024,7 @@ int critterGetBodyType(Object* critter)
return proto->critter.data.bodyType;
}
bool critterCanUseWeapon(Object* critter, Object* weapon, int hitMode)
bool critterCanUseWeapon(Object* critter, Object* weapon, HitMode hitMode)
{
if (critter == nullptr || weapon == nullptr || itemGetType(weapon) != ITEM_TYPE_WEAPON) {
return false;
+2 -1
View File
@@ -1,6 +1,7 @@
#ifndef CRITTER_H
#define CRITTER_H
#include "combat_defs.h"
#include "db.h"
#include "obj_types.h"
#include "proto_types.h"
@@ -56,7 +57,7 @@ bool critterIsProne(Object* critter);
int critterGetBodyType(Object* critter);
// Checks physical/art capability only. Callers that expose weapon usability
// decisions must still call scriptHooks_CanUseWeapon with the final result.
bool critterCanUseWeapon(Object* critter, Object* weapon, int hitMode);
bool critterCanUseWeapon(Object* critter, Object* weapon, HitMode hitMode);
int critterBuildGorisFid(Object* critter, int frmId);
int gcdLoad(const char* path);
int protoCritterDataRead(File* stream, CritterProtoData* critterData);
-1
View File
@@ -24,7 +24,6 @@ namespace fallout {
#define GAME_CONFIG_WINDOWED_KEY "windowed"
#define GAME_CONFIG_SCALE_KEY "scale"
#define GAME_CONFIG_MAIN_MENU_SCALE_MODE_KEY "main_menu_scale_mode"
#define GAME_CONFIG_MAIN_MENU_OVERLAY_SUBSCREENS_KEY "main_menu_overlay_subscreens"
#define GAME_CONFIG_IFACE_BAR_MODE_KEY "iface_bar_mode"
#define GAME_CONFIG_IFACE_BAR_WIDTH_KEY "iface_bar_width"
#define GAME_CONFIG_IFACE_BAR_SIDE_ART_KEY "iface_bar_side_art"
+4
View File
@@ -175,6 +175,10 @@ namespace {
constexpr SfallMigrationEntry kSfallMigrationEntries[] = {
// [start]
{ kSfallMisc, "StartingMap", CONTENT_CONFIG_START_SECTION, "map", "" },
{ kSfallMisc, "StartXPos", CONTENT_CONFIG_START_SECTION, "worldmap_x", "-1" },
{ kSfallMisc, "StartYPos", CONTENT_CONFIG_START_SECTION, "worldmap_y", "-1" },
{ kSfallMisc, "ViewXPos", CONTENT_CONFIG_START_SECTION, "worldmap_view_x", "-1" },
{ kSfallMisc, "ViewYPos", CONTENT_CONFIG_START_SECTION, "worldmap_view_y", "-1" },
{ kSfallMisc, "MaleStartModel", CONTENT_CONFIG_START_SECTION, "model_male", "hmwarr" },
{ kSfallMisc, "MaleDefaultModel", CONTENT_CONFIG_START_SECTION, "model_male_default", "hmjmps" },
{ kSfallMisc, "FemaleStartModel", CONTENT_CONFIG_START_SECTION, "model_female", "hfprim" },

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