Compare commits

...
Author SHA1 Message Date
Mike Klaas 6efe7ed869 Implement sfall HOOK_ONGAMEMODECHANGE
Pretty straight forward one
2026-03-19 23:08:19 -07:00
phobos2077 5a71d7c46d opcode: get_sfall_args 2026-03-20 00:26:07 +01:00
github-actions[bot] f7fe0a92d6 chore: auto-format with clang-format 2026-03-19 23:17:34 +00:00
phobos2077 b4756744a7 Add hooks: useobj, useobjon 2026-03-20 00:17:02 +01:00
github-actions[bot] 189361c2cb chore: auto-format with clang-format 2026-03-18 21:58:23 +00:00
phobos2077 094c377637 HOOK_TOHIT 2026-03-18 22:54:30 +01:00
phobos2077 66903073b9 mf_obj_under_cursor + some test script 2026-03-18 22:39:43 +01:00
phobos2077 0c0f0fa423 HOOK_KEYPRESS and first working hooks 2026-03-18 21:00:47 +01:00
phobos2077 2c80f4b1ad ScriptHookCall refactoring and all basic hook script opcode implementation 2026-03-18 13:23:22 +01:00
phobos2077 4c50266aa1 Interpreter: add programPrintError(), Program->procedureCount(), rename string-related functions 2026-03-18 13:22:11 +01:00
phobos2077 be5d8bf4fe Script hooks WIP 2026-03-18 00:49:51 +01:00
phobos2077 caa6ebdea0 Deobfuscate some script-related procedures and flags 2026-03-18 00:49:33 +01:00
phobos2077 3ba666d033 hooks: an empty cc and a list of hook types with useful comments 2026-03-17 20:54:40 +01:00
Vlad K ed23b0f502 Fix crash when trying to run missing combat_p_proc and start is not the first in the script (#310) 2026-03-17 07:38:04 +00:00
Vlad K f0404596d0 Add fallout2.cfg->preferences->ui_anim_speed setting (#305)
* Use ui_anim_speed for fading, dialog panel, combat panel, pipboy rest
2026-03-17 08:33:16 +01:00
Vasilii Rogin 72da5eb879 Merge pull request #308 from fallout2-ce/fix/tile-from-screen-xy-signature
Remove unused elevation from tileFromScreenXY call sites
2026-03-16 22:14:21 +02:00
Vasilii Rogin e0384a37b5 Fix tileFromScreenXY signature cleanup 2026-03-16 18:18:02 +02:00
Vasilii Rogin c8cf50540f Merge pull request #304 from fallout2-ce/remove_unused_elevation_from_tileToScreenXY
Remove unused elevation in tileToScreenXY
2026-03-16 18:09:29 +02:00
Mike KlaasandCopilot Autofix powered by AI ebcd124ba4 Add a few more proto extendedFlags names (#306)
* Add a few more proto extendedFlags

Added a few names based on the list in fallout-tools: https://github.com/rotators/fallout-tools/blob/4a54255f3403e90cff8a20e657df152cb2602a65/F2_ProtoManager/ProtoManager/SetFlagsForm.Designer.vb#L883

Follow up to https://github.com/fallout2-ce/fallout2-ce/pull/301

* Potential fix for pull request finding

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

---------

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-15 23:51:23 +00:00
Mike Klaas 07c55842b4 Enums for proto flags (#301) 2026-03-15 22:43:52 +00:00
Vasilii Rogin 7ad7c43ce6 Remove unused elevation in tileToScreenXY 2026-03-15 20:42:42 +02:00
Mike Klaas c352107b09 Dobfuscate region, game_sound, art (#300) 2026-03-14 22:05:30 -07:00
Mike Klaas b6bfcff9b3 Deobfuscate window_manager, inventory, string_parsers (#299)
Also fix bug in _adjust_fid
2026-03-14 04:45:16 +00:00
Mike Klaas 1df5841810 Update preferences window slider when +/- is pressed (#298)
* Update preferences window slider when +/- is pressed

* do not save brightness when in perferences window
2026-03-13 20:54:31 -07:00
Mike Klaas 98ff03c0b9 Deobfuscations of draw,endgame,interface,preferences (#297)
* Deobfuscations of draw,endgame,interface,preferences

This is _mostly_ mechanical renames.

There are a few other changes:
* Extracted two helper functions
* Added a couple constants that virtually eliminated "magic numbers" in a couple functions
* Switched one int -> bool
* Made sure interfaceGetCurrentHand() is compared against HAND_RIGHT/LEFT instead of treated as boolean

* comment dev by zero issues
2026-03-13 04:14:22 +00:00
Mike Klaas 404236c0cb Deobfuscate audio_file, character_selector, options, dictionary, map, elevator, movie.cc/h (#293)
* Debobfuscate audio_file, character_selector, options, and others

* dictionary, font_manager, nevs

* elevator, map, movie

* item, mp_proto, skill

* proto_instance

* proto, proto_types

* revert dictionary, step -> i

* PR feedback

* criticalChanceModifier -> skillBonus

* skillOrCritSuccessBonus
2026-03-09 05:14:20 +00:00
Mike Klaas 3cd817d4b5 Deobfuscate export,game_movie,random,select_file_list,widget and more (#292)
* Deobfuscate export,game_movie,random,select_file_list,widget

* add automap,cache,display_monitor,game_mouse,geometry,window_manager_pricate

* add static to forward-declared static functions for c++ tidiness
2026-03-01 09:23:04 -08:00
Mike Klaas e8d85dbdd8 Revert to original behaviour in window.cc window existence checks (#291)
revert to original behaviour in window.cc window existence checks

* flagging probably mistaken function
2026-02-28 16:39:56 -08:00
Mike Klaas 3633652884 Rename window* -> scriptWindow* (#288)
* Rename window* -> scriptWindow*

This disambiguates the function names from those in managed_window.cc (which also used window*)

Plus a few items of PR feedback from https://github.com/fallout2-ce/fallout2-ce/pull/286
2026-02-27 05:05:49 +00:00
Mike Klaas e86dce3266 more deobfuscation (#286)
Deobfuscation of several files that were close to complete. There are mechanical renames for the most part. A couple exceptions noted in the changeset
2026-02-22 21:55:37 -08:00
a738c38a81 Function renaming part 2 (#285)
* Rename functions with RE-based names for consistency with new scheme

* Rename sub_* that have equivalents in original source

sub_* names pulled from https://raw.githubusercontent.com/sfall-team/sfall/master/sfall/FalloutEngine/FunctionOffsets_def.h if possible

Per discussion in Discord, sticking with camelCase names

* build fix

* window*

* Rename several more window* functions, add explanatory comment

---------

Co-authored-by: phobos2077 <phobos2077@gmail.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Vlad K <phobos2077@users.noreply.github.com>
2026-02-22 16:58:01 +00:00
Vlad Kandgithub-actions[bot] be4569315f Function naming consistency, part 1 (#284)
* Rename functions with RE-based names for consistency with new scheme

* chore: auto-format with clang-format

* Fix typo

* critterHealByHours - better comment

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2026-02-22 17:47:45 +01:00
Mike Klaas a2505f8412 Deobfuscate audio/critter/heap.cc (#282)
Mechanical renames only
2026-02-17 22:35:36 -08:00
Mike Klaas 018d3dd48b Deobfuscate datafile.cc/h (#281)
Also, removed unused functions from the .h file

This PR contains only mechanical renames
2026-02-17 22:35:05 -08:00
Vlad 41eafedf87 Fix release standard library used in debug config (#280)
* Fix release standard library used in debug config

* Github Actions: Update MSVC build tools version
2026-02-17 17:54:07 +01:00
Vasilii Rogin c914e62f44 Merge pull request #277 from ololoken/emscripten-mouse-touch
[emscripten] do not lock mouse; improve mobile browsers compatibility;
2026-02-17 10:23:20 +02:00
cambragol a478e24c8a Merge pull request #279 from fallout2-ce/context-menu-fix
Update game_mouse.cc to fix context menu
2026-01-31 09:19:39 +09:00
cambragol 2703af882c Update game_mouse.cc to fix context menu
Don't set mouse to new position, set it to the original click point.
2026-01-30 22:27:18 +09:00
Roman Turchin 36e8b90831 [emscripten] do not lock mouse; improve mobile browsers compatibility; 2026-01-27 13:24:20 +01:00
137 changed files with 3767 additions and 2664 deletions
+4 -4
View File
@@ -328,16 +328,16 @@ jobs:
- name: Clone
uses: actions/checkout@v4
- name: Install Visual Studio 2019 Build Tools with v141_xp
- name: Install Visual Studio 2022 Build Tools with v141_xp
shell: cmd
run: |
choco install visualstudio2019buildtools -y --package-parameters="'--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 --add Microsoft.VisualStudio.Component.VC.v141.xp --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.10240 --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.WinXP --add Microsoft.VisualStudio.Component.WinXP'"
choco install visualstudio2022buildtools -y --package-parameters="'--add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.v141.x86.x64 --add Microsoft.VisualStudio.Component.VC.v141.xp --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK.10240 --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.WinXP --add Microsoft.VisualStudio.Component.WinXP'"
- name: Cache cmake build
uses: actions/cache@v4
with:
path: out
key: windows-${{ matrix.arch }}-cmake-v101
key: windows-${{ matrix.arch }}-cmake-v102
- name: Configure
shell: cmd
@@ -432,4 +432,4 @@ jobs:
tag_name: continious
draft: false
prerelease: true
name: Fallout2-CE Continuous Build
name: Fallout2-CE Continuous Build
+3 -1
View File
@@ -286,6 +286,7 @@ target_sources(${EXECUTABLE_NAME} PUBLIC
"src/sfall_metarules.h"
"src/sfall_opcodes.cc"
"src/sfall_opcodes.h"
"src/sfall_script_hooks.cc"
"src/sfall_arrays.cc"
"src/sfall_arrays.h"
"src/sfall_callbacks.cc"
@@ -318,7 +319,8 @@ endif()
if(WIN32)
target_link_libraries(${EXECUTABLE_NAME}
winmm
libcpmt
debug libcpmtd
optimized libcpmt
)
endif()
+2 -2
View File
@@ -28,7 +28,7 @@
"inherits": [
"windows-base"
],
"generator": "Visual Studio 16 2019",
"generator": "Visual Studio 17 2022",
"architecture": "Win32",
"cacheVariables": {
"CMAKE_GENERATOR_TOOLSET": "v141_xp",
@@ -42,7 +42,7 @@
"inherits": [
"windows-base"
],
"generator": "Visual Studio 16 2019",
"generator": "Visual Studio 17 2022",
"architecture": "x64",
"cacheVariables": {
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>"
+1
View File
@@ -1 +1,2 @@
*.int
sfall
+120
View File
@@ -0,0 +1,120 @@
#include "../sfall/sfall.h"
#include "../sfall/dik.h"
#include "../sfall/define_lite.h"
#include "../test_utils.h"
variable last_game_mode;
variable gamemodechange_assertions_enabled := false;
variable gamemodechange_reported := false;
procedure test_with_args(variable arg1) begin
display_msg("test_w_arg" + arg1);
end
procedure test_wo_args begin
display_msg("test_wo_args");
end
procedure tohit_handler begin
variable
attacker := get_sfall_arg_at(1),
target := get_sfall_arg_at(2),
chanceRaw := get_sfall_arg_at(7);
display_msg(string_format("tohit %s -> %s (%d)", obj_name(attacker), obj_name(target), chanceRaw));
if (attacker == dude_obj) then
set_sfall_return(100);
else if (target == dude_obj) then
set_sfall_return(0);
end
procedure useobj_handler begin
variable
user := get_sfall_arg,
item := get_sfall_arg;
display_msg(string_format("useobj %s (%s)", obj_name(user), obj_name(item)));
set_sfall_return(2);
end
procedure useobjon_handler begin
variable args := get_sfall_args,
target := args[0],
user := args[1],
item := args[2];
display_msg(string_format("useobjon %s (%s) -> %s [len: %d]", obj_name(user), obj_name(item), obj_name(target), len_array(args)));
set_sfall_return(0);
end
procedure keypress_handler begin
variable
pressed := get_sfall_arg_at(0),
key := get_sfall_arg_at(1);
display_msg(string_format("keypress %d dx: %d", pressed, key));
if (not pressed) then return;
if (key == DIK_F2) then begin
display_msg(string_format("tile %d, elev %d, map %d", tile_under_cursor, elevation(dude_obj), cur_map_index));
end if (key == DIK_F3) then begin
if (key_pressed(DIK_LCONTROL)) then begin
variable cr := obj_under_cursor(true, false);
if (cr) then
critter_dmg(cr, 1000, DMG_BYPASS_ARMOR);
end else
move_to(dude_obj, tile_under_cursor, elevation(dude_obj));
end
end
procedure gamemodechange_handler begin
variable
event_type := get_sfall_arg_at(0),
previous_mode := get_sfall_arg_at(1),
current_mode := get_game_mode;
display_msg(string_format("gamemodechange event=%d prev=%d cur=%d", event_type, previous_mode, current_mode));
if (not gamemodechange_assertions_enabled) then begin
last_game_mode := current_mode;
return;
end
call assertTrue("gamemodechange event_type is 0 or 1", event_type == 0 or event_type == 1);
call assertEquals("gamemodechange previous mode", previous_mode, last_game_mode);
if (event_type == 0) then
call assertNotEquals("gamemodechange mode changed", current_mode, previous_mode);
else if (not gamemodechange_reported) then begin
gamemodechange_reported := true;
call report_test_results("hook_gamemodechange");
end
last_game_mode := current_mode;
end
procedure start begin
//call test_with_args(777);
display_msg("start hook test");
if (not game_loaded) then return;
add_obj_to_inven(dude_obj, create_object_sid(40, 0, 0, -1));
add_obj_to_inven(dude_obj, create_object_sid(76, 0, 0, -1));
add_obj_to_inven(dude_obj, create_object_sid(85, 0, 0, -1));
last_game_mode := get_game_mode;
gamemodechange_assertions_enabled := true;
register_hook_proc(HOOK_KEYPRESS, keypress_handler);
register_hook_proc(HOOK_TOHIT, tohit_handler);
register_hook_proc(HOOK_USEOBJ, useobj_handler);
register_hook_proc(HOOK_USEOBJON, useobjon_handler);
register_hook_proc(HOOK_GAMEMODECHANGE, gamemodechange_handler);
end
procedure map_enter_p_proc begin
display_msg("Map Enter hook test");
end
+27 -27
View File
@@ -103,7 +103,7 @@ static int hideProjectile(void* _, void* projectile);
// 0x410468
int actionKnockdown(Object* obj, int* anim, int maxDistance, int rotation, int delay)
{
if (_critter_flag_check(obj->pid, CRITTER_NO_KNOCKBACK)) {
if (critterFlagCheck(obj->pid, CRITTER_NO_KNOCKBACK)) {
return -1;
}
@@ -208,7 +208,7 @@ int _pick_death(Object* attacker, Object* defender, Object* weapon, int damage,
int violenceLevel = settings.preferences.violence_level;
if (_critter_flag_check(defender->pid, CRITTER_SPECIAL_DEATH)) {
if (critterFlagCheck(defender->pid, CRITTER_SPECIAL_DEATH)) {
return _check_death(defender, ANIM_EXPLODED_TO_NOTHING, VIOLENCE_LEVEL_NORMAL, hitFromFront);
}
@@ -285,7 +285,7 @@ int _check_death(Object* obj, int anim, int minViolenceLevel, bool hitFromFront)
// 0x4108C8
int _internal_destroy(Object* _, Object* toDestroy)
{
return _obj_destroy(toDestroy);
return objectDestroy(toDestroy);
}
// TODO: Check very carefully, lots of conditions and jumps.
@@ -297,12 +297,12 @@ void _show_damage_to_object(Object* defender, int damage, int flags, Object* wea
int fid;
const char* sfx_name;
if (_critter_flag_check(defender->pid, CRITTER_NO_KNOCKBACK)) {
if (critterFlagCheck(defender->pid, CRITTER_NO_KNOCKBACK)) {
knockbackDistance = 0;
}
anim = FID_ANIM_TYPE(defender->fid);
if (!_critter_is_prone(defender)) {
if (!critterIsProne(defender)) {
if ((flags & DAM_DEAD) != 0) {
fid = buildFid(OBJ_TYPE_MISC, 10, 0, 0, 0);
if (fid == attacker->fid) {
@@ -447,7 +447,7 @@ void _show_damage_to_object(Object* defender, int damage, int flags, Object* wea
if (weapon != nullptr) {
if ((flags & DAM_EXPLODE) != 0) {
animationRegisterCallbackForced(defender, weapon, (AnimationCallback*)_obj_drop, -1);
animationRegisterCallbackForced(defender, weapon, (AnimationCallback*)objectDrop, -1);
fid = buildFid(OBJ_TYPE_MISC, 10, 0, 0, 0);
animationRegisterSetFid(weapon, fid, 0);
animationRegisterAnimateAndHide(weapon, ANIM_STAND, 0);
@@ -459,7 +459,7 @@ void _show_damage_to_object(Object* defender, int damage, int flags, Object* wea
} else if ((flags & DAM_DESTROY) != 0) {
animationRegisterCallbackForced(defender, weapon, (AnimationCallback*)_internal_destroy, -1);
} else if ((flags & DAM_DROP) != 0) {
animationRegisterCallbackForced(defender, weapon, (AnimationCallback*)_obj_drop, -1);
animationRegisterCallbackForced(defender, weapon, (AnimationCallback*)objectDrop, -1);
}
}
@@ -488,7 +488,7 @@ int _show_death(Object* obj, int anim)
}
}
if (!_critter_flag_check(obj->pid, CRITTER_FLAT)) {
if (!critterFlagCheck(obj->pid, CRITTER_FLAT)) {
obj->flags |= OBJECT_NO_BLOCK;
if (_obj_toggle_flat(obj, &tempRect) == 0) {
rectUnion(&dirtyRect, &tempRect, &dirtyRect);
@@ -499,7 +499,7 @@ int _show_death(Object* obj, int anim)
rectUnion(&dirtyRect, &tempRect, &dirtyRect);
}
if (anim >= 30 && anim <= 31 && !_critter_flag_check(obj->pid, CRITTER_SPECIAL_DEATH) && !_critter_flag_check(obj->pid, CRITTER_NO_DROP)) {
if (anim >= 30 && anim <= 31 && !critterFlagCheck(obj->pid, CRITTER_SPECIAL_DEATH) && !critterFlagCheck(obj->pid, CRITTER_NO_DROP)) {
itemDropAll(obj, obj->tile);
}
@@ -1040,7 +1040,7 @@ int _action_climb_ladder(Object* critter, Object* ladder)
animationRegisterCallbackForced(critter, ladder, (AnimationCallback*)_is_next_to, -1);
animationRegisterRotateToTile(critter, ladder->tile);
animationRegisterCallbackForced(critter, ladder, (AnimationCallback*)_check_scenery_ap_cost, -1);
animationRegisterCallbackForced(critter, ladder, (AnimationCallback*)checkSceneryUseActionPointCost, -1);
int weaponAnimationCode = (critter->fid & 0xF000) >> 12;
if (weaponAnimationCode != 0) {
@@ -1052,7 +1052,7 @@ int _action_climb_ladder(Object* critter, Object* ladder)
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);
animationRegisterCallback(critter, ladder, (AnimationCallback*)objectUse, -1);
if (weaponAnimationCode != 0) {
animationRegisterTakeOutWeapon(critter, weaponAnimationCode, -1);
@@ -1108,7 +1108,7 @@ int _action_use_an_item_on_object(Object* user, Object* targetObj, Object* item)
animationRegisterCallbackForced(user, targetObj, (AnimationCallback*)_is_next_to, -1);
if (item == nullptr) {
animationRegisterCallback(user, targetObj, (AnimationCallback*)_check_scenery_ap_cost, -1);
animationRegisterCallback(user, targetObj, (AnimationCallback*)checkSceneryUseActionPointCost, -1);
}
int weaponAnimCode = (user->fid & 0xF000) >> 12;
@@ -1120,9 +1120,9 @@ int _action_use_an_item_on_object(Object* user, Object* targetObj, Object* item)
int anim;
int objectType = FID_TYPE(targetObj->fid);
if (objectType == OBJ_TYPE_CRITTER && _critter_is_prone(targetObj)) {
if (objectType == OBJ_TYPE_CRITTER && critterIsProne(targetObj)) {
anim = ANIM_MAGIC_HANDS_GROUND;
} else if (objectType == OBJ_TYPE_SCENERY && (proto->scenery.extendedFlags & 0x01) != 0) {
} else if (objectType == OBJ_TYPE_SCENERY && (proto->scenery.extendedFlags & PROTO_EXT_FLAG_MAGIC_HANDS_GROUND) != 0) {
anim = ANIM_MAGIC_HANDS_GROUND;
} else {
anim = ANIM_MAGIC_HANDS_MIDDLE;
@@ -1134,9 +1134,9 @@ int _action_use_an_item_on_object(Object* user, Object* targetObj, Object* item)
if (item != nullptr) {
// TODO: Get rid of cast.
animationRegisterCallback3(user, targetObj, item, (AnimationCallback3*)_obj_use_item_on, -1);
animationRegisterCallback3(user, targetObj, item, (AnimationCallback3*)objectUseItemOn, -1);
} else {
animationRegisterCallback(user, targetObj, (AnimationCallback*)_obj_use, -1);
animationRegisterCallback(user, targetObj, (AnimationCallback*)objectUse, -1);
}
if (weaponAnimCode != 0) {
@@ -1182,7 +1182,7 @@ int actionPickUp(Object* critter, Object* item)
}
animationRegisterCallbackForced(critter, item, (AnimationCallback*)_is_next_to, -1);
animationRegisterCallback(critter, item, (AnimationCallback*)_check_scenery_ap_cost, -1);
animationRegisterCallback(critter, item, (AnimationCallback*)checkSceneryUseActionPointCost, -1);
Proto* itemProto;
protoGetProto(item->pid, &itemProto);
@@ -1207,7 +1207,7 @@ int actionPickUp(Object* critter, Object* item)
animationRegisterPlaySoundEffect(item, sfx, actionFrame);
}
animationRegisterCallback(critter, item, (AnimationCallback*)_obj_pickup, actionFrame);
animationRegisterCallback(critter, item, (AnimationCallback*)objectPickup, actionFrame);
} else {
int weaponAnimationCode = (critter->fid & 0xF000) >> 12;
if (weaponAnimationCode != 0) {
@@ -1235,7 +1235,7 @@ int actionPickUp(Object* critter, Object* item)
}
if (item->frame != 1) {
animationRegisterCallback(critter, item, (AnimationCallback*)_obj_use_container, actionFrame);
animationRegisterCallback(critter, item, (AnimationCallback*)objectUseContainer, actionFrame);
}
if (weaponAnimationCode != 0) {
@@ -1263,7 +1263,7 @@ int _action_loot_container(Object* critter, Object* container)
}
// SFALL: Fix for trying to loot corpses with the "NoSteal" flag.
if (_critter_flag_check(container->pid, CRITTER_NO_STEAL)) {
if (critterFlagCheck(container->pid, CRITTER_NO_STEAL)) {
return -1;
}
@@ -1288,7 +1288,7 @@ int _action_loot_container(Object* critter, Object* container)
}
animationRegisterCallbackForced(critter, container, (AnimationCallback*)_is_next_to, -1);
animationRegisterCallback(critter, container, (AnimationCallback*)_check_scenery_ap_cost, -1);
animationRegisterCallback(critter, container, (AnimationCallback*)checkSceneryUseActionPointCost, -1);
animationRegisterCallback(critter, container, (AnimationCallback*)scriptsRequestLooting, -1);
return reg_anim_end();
}
@@ -1494,7 +1494,7 @@ int actionUseSkill(Object* user, Object* target, int skill)
animationRegisterCallbackForced(performer, target, (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(target->fid) == OBJ_TYPE_CRITTER && critterIsProne(target)) ? ANIM_MAGIC_HANDS_GROUND : ANIM_MAGIC_HANDS_MIDDLE;
int fid = buildFid(OBJ_TYPE_CRITTER, performer->fid & 0xFFF, anim, 0, performer->rotation + 1);
CacheEntry* artHandle;
@@ -1506,7 +1506,7 @@ int actionUseSkill(Object* user, Object* target, int skill)
animationRegisterAnimate(performer, anim, -1);
// TODO: Get rid of casts.
animationRegisterCallback3(performer, target, (void*)(uintptr_t)skill, (AnimationCallback3*)_obj_use_skill_on, -1);
animationRegisterCallback3(performer, target, (void*)(uintptr_t)skill, (AnimationCallback3*)objectUseSkillOn, -1);
return reg_anim_end();
}
@@ -1753,7 +1753,7 @@ int _report_explosion(Attack* attack, Object* sourceObj)
xp += critterGetExp(attack->defender);
}
} else {
_critter_set_who_hit_me(attack->defender, sourceObj);
critterSetWhoHitMe(attack->defender, sourceObj);
anyDefender = attack->defender;
}
}
@@ -1766,7 +1766,7 @@ int _report_explosion(Attack* attack, Object* sourceObj)
xp += critterGetExp(critter);
}
} else {
_critter_set_who_hit_me(critter, sourceObj);
critterSetWhoHitMe(critter, sourceObj);
if (anyDefender == nullptr) {
anyDefender = critter;
@@ -1972,7 +1972,7 @@ int _report_dmg(Attack* attack, Object* _)
// 0x413660
int _compute_dmg_damage(int min, int max, Object* obj, int* knockbackDistancePtr, int damageType)
{
if (!_critter_flag_check(obj->pid, CRITTER_NO_KNOCKBACK)) {
if (!critterFlagCheck(obj->pid, CRITTER_NO_KNOCKBACK)) {
knockbackDistancePtr = nullptr;
}
@@ -2046,7 +2046,7 @@ int actionPush(Object* obj, Object* target)
}
int sid;
if (_obj_sid(target, &sid) == 0) {
if (objectGetSid(target, &sid) == 0) {
scriptSetObjects(sid, obj, target);
scriptExecProc(sid, SCRIPT_PROC_PUSH);
+24 -24
View File
@@ -1418,7 +1418,7 @@ static int animationRunSequence(int animationSequenceIndex)
rc = _anim_animate(animationDescription->owner, animationDescription->anim, animationSequenceIndex, ANIM_SAD_FOREVER);
break;
case ANIM_KIND_ROTATE_TO_TILE:
if (!_critter_is_prone(animationDescription->owner)) {
if (!critterIsProne(animationDescription->owner)) {
int rotation = tileGetRotationTo(animationDescription->owner->tile, animationDescription->tile);
_dude_stand(animationDescription->owner, rotation, -1);
}
@@ -1637,7 +1637,7 @@ static int _anim_set_end(int animationSequenceIndex)
}
}
if ((animationSequence->flags & ANIM_SEQ_NO_STAND) == 0 && !_critter_is_prone(owner)) {
if ((animationSequence->flags & ANIM_SEQ_NO_STAND) == 0 && !critterIsProne(owner)) {
_dude_stand(owner, owner->rotation, -1);
}
}
@@ -1755,7 +1755,7 @@ int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotation
int toScreenX;
int toScreenY;
tileToScreenXY(to, &toScreenX, &toScreenY, object->elevation);
tileToScreenXY(to, &toScreenX, &toScreenY);
int closedPathNodeListLength = 0;
int openPathNodeListLength = 1;
@@ -1840,7 +1840,7 @@ int pathfinderFindPath(Object* object, int from, int to, unsigned char* rotation
int newX;
int newY;
tileToScreenXY(tile, &newX, &newY, object->elevation);
tileToScreenXY(tile, &newX, &newY);
v27->estimate = _idist(newX, newY, toScreenX, toScreenY);
v27->cost = temp.cost + 50;
@@ -1940,11 +1940,11 @@ static int _tile_idistance(int tile1, int tile2)
{
int x1;
int y1;
tileToScreenXY(tile1, &x1, &y1, gElevation);
tileToScreenXY(tile1, &x1, &y1);
int x2;
int y2;
tileToScreenXY(tile2, &x2, &y2, gElevation);
tileToScreenXY(tile2, &x2, &y2);
return _idist(x1, y1, x2, y2);
}
@@ -1977,13 +1977,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);
fromX += 16;
fromY += 8;
int toX;
int toY;
tileToScreenXY(to, &toX, &toY, obj->elevation);
tileToScreenXY(to, &toX, &toY);
toX += 16;
toY += 8;
@@ -2021,7 +2021,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);
v22 += 1;
if (v22 == a6) {
@@ -2034,7 +2034,7 @@ int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* st
pathNode->tile = tile;
pathNode->elevation = obj->elevation;
tileToScreenXY(tile, &fromX, &fromY, obj->elevation);
tileToScreenXY(tile, &fromX, &fromY);
pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8;
}
@@ -2074,7 +2074,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);
v22 += 1;
if (v22 == a6) {
@@ -2087,7 +2087,7 @@ int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* st
pathNode->tile = tile;
pathNode->elevation = obj->elevation;
tileToScreenXY(tile, &fromX, &fromY, obj->elevation);
tileToScreenXY(tile, &fromX, &fromY);
pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8;
}
@@ -2136,7 +2136,7 @@ int _make_straight_path_func(Object* obj, int from, int to, StraightPathNode* st
pathNode->tile = tile;
pathNode->elevation = obj->elevation;
tileToScreenXY(tile, &fromX, &fromY, obj->elevation);
tileToScreenXY(tile, &fromX, &fromY);
pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8;
}
@@ -2201,13 +2201,13 @@ int _make_stair_path(Object* object, int from, int fromElevation, int to, int to
int fromX;
int fromY;
tileToScreenXY(from, &fromX, &fromY, fromElevation);
tileToScreenXY(from, &fromX, &fromY);
fromX += 16;
fromY += 8;
int toX;
int toY;
tileToScreenXY(to, &toX, &toY, toElevation);
tileToScreenXY(to, &toX, &toY);
toX += 16;
toY += 8;
@@ -2250,7 +2250,7 @@ int _make_stair_path(Object* object, int from, int fromElevation, int to, int to
if (ddx > ddy) {
int middle = ddy - ddx / 2;
while (true) {
tile = tileFromScreenXY(tileX, tileY, elevation);
tile = tileFromScreenXY(tileX, tileY);
iteration += 1;
if (iteration == 16) {
@@ -2263,7 +2263,7 @@ int _make_stair_path(Object* object, int from, int fromElevation, int to, int to
pathNode->tile = tile;
pathNode->elevation = elevation;
tileToScreenXY(tile, &fromX, &fromY, elevation);
tileToScreenXY(tile, &fromX, &fromY);
pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8;
}
@@ -2297,7 +2297,7 @@ int _make_stair_path(Object* object, int from, int fromElevation, int to, int to
} else {
int middle = ddx - ddy / 2;
while (true) {
tile = tileFromScreenXY(tileX, tileY, elevation);
tile = tileFromScreenXY(tileX, tileY);
iteration += 1;
if (iteration == 16) {
@@ -2310,7 +2310,7 @@ int _make_stair_path(Object* object, int from, int fromElevation, int to, int to
pathNode->tile = tile;
pathNode->elevation = elevation;
tileToScreenXY(tile, &fromX, &fromY, elevation);
tileToScreenXY(tile, &fromX, &fromY);
pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8;
}
@@ -2353,7 +2353,7 @@ int _make_stair_path(Object* object, int from, int fromElevation, int to, int to
pathNode->tile = tile;
pathNode->elevation = elevation;
tileToScreenXY(tile, &fromX, &fromY, elevation);
tileToScreenXY(tile, &fromX, &fromY);
pathNode->x = tileX - fromX - 16;
pathNode->y = tileY - fromY - 8;
}
@@ -2613,7 +2613,7 @@ static void _object_move(int index)
}
nextTile = -1;
} else {
_obj_use_door(object, obstacle, 0);
objectUseDoor(object, obstacle, 0);
}
}
@@ -2962,7 +2962,7 @@ int _check_move(int* actionPointsPtr)
int y;
mouseGetPosition(&x, &y);
int tile = tileFromScreenXY(x, y, gElevation);
int tile = tileFromScreenXY(x, y);
if (tile == -1) {
return -1;
}
@@ -3219,7 +3219,7 @@ void _dude_standup(Object* a1)
// 0x4185EC
static int actionRotate(Object* obj, int delta, int animationSequenceIndex)
{
if (!_critter_is_prone(obj)) {
if (!critterIsProne(obj)) {
int rotation = obj->rotation + delta;
if (rotation >= ROTATION_COUNT) {
rotation = ROTATION_NE;
@@ -3293,7 +3293,7 @@ static int _check_gravity(int tile, int elevation)
for (; elevation > 0; elevation--) {
int x;
int y;
tileToScreenXY(tile, &x, &y, elevation);
tileToScreenXY(tile, &x, &y);
int squareTile = squareTileFromScreenXY(x + 2, y + 8, elevation);
int fid = buildFid(OBJ_TYPE_TILE, _square[elevation]->field_0[squareTile] & 0xFFF, 0, 0, 0);
+51 -53
View File
@@ -542,72 +542,72 @@ int artCopyFileName(int objectType, int id, char* dest)
}
// 0x419314
int _art_get_code(int animation, int weaponType, char* a3, char* a4)
int _art_get_code(int animation, int weaponType, char* weaponCodePtr, char* animationCodePtr)
{
if (weaponType < 0 || weaponType >= WEAPON_ANIMATION_COUNT) {
return -1;
}
if (animation >= ANIM_TAKE_OUT && animation <= ANIM_FIRE_CONTINUOUS) {
*a4 = 'c' + (animation - ANIM_TAKE_OUT);
*animationCodePtr = 'c' + (animation - ANIM_TAKE_OUT);
if (weaponType == WEAPON_ANIMATION_NONE) {
return -1;
}
*a3 = 'd' + (weaponType - 1);
*weaponCodePtr = 'd' + (weaponType - 1);
return 0;
} else if (animation == ANIM_PRONE_TO_STANDING) {
*a4 = 'h';
*a3 = 'c';
*animationCodePtr = 'h';
*weaponCodePtr = 'c';
return 0;
} else if (animation == ANIM_BACK_TO_STANDING) {
*a4 = 'j';
*a3 = 'c';
*animationCodePtr = 'j';
*weaponCodePtr = 'c';
return 0;
} else if (animation == ANIM_CALLED_SHOT_PIC) {
*a4 = 'a';
*a3 = 'n';
*animationCodePtr = 'a';
*weaponCodePtr = 'n';
return 0;
} else if (animation >= FIRST_SF_DEATH_ANIM) {
*a4 = 'a' + (animation - FIRST_SF_DEATH_ANIM);
*a3 = 'r';
*animationCodePtr = 'a' + (animation - FIRST_SF_DEATH_ANIM);
*weaponCodePtr = 'r';
return 0;
} else if (animation >= FIRST_KNOCKDOWN_AND_DEATH_ANIM) {
*a4 = 'a' + (animation - FIRST_KNOCKDOWN_AND_DEATH_ANIM);
*a3 = 'b';
*animationCodePtr = 'a' + (animation - FIRST_KNOCKDOWN_AND_DEATH_ANIM);
*weaponCodePtr = 'b';
return 0;
} else if (animation == ANIM_THROW_ANIM) {
if (weaponType == WEAPON_ANIMATION_KNIFE) {
// knife
*a3 = 'd';
*a4 = 'm';
*weaponCodePtr = 'd';
*animationCodePtr = 'm';
} else if (weaponType == WEAPON_ANIMATION_SPEAR) {
// spear
*a3 = 'g';
*a4 = 'm';
*weaponCodePtr = 'g';
*animationCodePtr = 'm';
} else {
// other -> probably rock or grenade
*a3 = 'a';
*a4 = 's';
*weaponCodePtr = 'a';
*animationCodePtr = 's';
}
return 0;
} else if (animation == ANIM_DODGE_ANIM) {
if (weaponType <= 0) {
*a3 = 'a';
*a4 = 'n';
*weaponCodePtr = 'a';
*animationCodePtr = 'n';
} else {
*a3 = 'd' + (weaponType - 1);
*a4 = 'e';
*weaponCodePtr = 'd' + (weaponType - 1);
*animationCodePtr = 'e';
}
return 0;
}
*a4 = 'a' + animation;
*animationCodePtr = 'a' + animation;
if (animation <= ANIM_WALK && weaponType > 0) {
*a3 = 'd' + (weaponType - 1);
*weaponCodePtr = 'd' + (weaponType - 1);
return 0;
}
*a3 = 'a';
*weaponCodePtr = 'a';
return 0;
}
@@ -615,53 +615,51 @@ int _art_get_code(int animation, int weaponType, char* a3, char* a4)
// 0x419428
char* artBuildFilePath(int fid)
{
int v1, v2, v3, v4, v5, type, v8, v10;
char v9, v11, v12;
int baseFid = fid;
int rotation = FID_ROTATION(fid);
v2 = fid;
v10 = FID_ROTATION(fid);
v1 = artAliasFid(fid);
if (v1 != -1) {
v2 = v1;
int aliasFid = artAliasFid(fid);
if (aliasFid != -1) {
baseFid = aliasFid;
}
*_art_name = '\0';
v3 = v2 & 0xFFF;
v4 = FID_ANIM_TYPE(v2);
v5 = (v2 & 0xF000) >> 12;
type = FID_TYPE(v2);
int frmId = baseFid & 0xFFF;
int animType = FID_ANIM_TYPE(baseFid);
int weaponCode = (baseFid & 0xF000) >> 12;
int objectType = FID_TYPE(baseFid);
if (type < OBJ_TYPE_ITEM || type >= OBJ_TYPE_COUNT) {
if (objectType < OBJ_TYPE_ITEM || objectType >= OBJ_TYPE_COUNT) {
return nullptr;
}
if (v3 >= gArtListDescriptions[type].fileNamesLength) {
if (frmId >= gArtListDescriptions[objectType].fileNamesLength) {
return nullptr;
}
v8 = v3 * 13;
int fileNameOffset = frmId * 13;
if (type == 1) {
if (_art_get_code(v4, v5, &v11, &v12) == -1) {
if (objectType == OBJ_TYPE_CRITTER) {
char critterWeaponCode;
char critterAnimationCode;
if (_art_get_code(animType, weaponCode, &critterWeaponCode, &critterAnimationCode) == -1) {
return nullptr;
}
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);
if (rotation != 0) {
snprintf(_art_name, sizeof(_art_name), "%s%s%s\\%s%c%c.fr%c", _cd_path_base, "art\\", gArtListDescriptions[OBJ_TYPE_CRITTER].name, gArtListDescriptions[OBJ_TYPE_CRITTER].fileNames + fileNameOffset, critterWeaponCode, critterAnimationCode, rotation + 47);
} else {
snprintf(_art_name, sizeof(_art_name), "%s%s%s\\%s%c%c.frm", _cd_path_base, "art\\", gArtListDescriptions[1].name, gArtListDescriptions[1].fileNames + v8, v11, v12);
snprintf(_art_name, sizeof(_art_name), "%s%s%s\\%s%c%c.frm", _cd_path_base, "art\\", gArtListDescriptions[OBJ_TYPE_CRITTER].name, gArtListDescriptions[OBJ_TYPE_CRITTER].fileNames + fileNameOffset, critterWeaponCode, critterAnimationCode);
}
} else if (type == 8) {
v9 = _head2[v4];
if (v9 == 'f') {
snprintf(_art_name, sizeof(_art_name), "%s%s%s\\%s%c%c%d.frm", _cd_path_base, "art\\", gArtListDescriptions[8].name, gArtListDescriptions[8].fileNames + v8, _head1[v4], 102, v5);
} else if (objectType == OBJ_TYPE_HEAD) {
char headSuffix = _head2[animType];
if (headSuffix == 'f') {
snprintf(_art_name, sizeof(_art_name), "%s%s%s\\%s%c%c%d.frm", _cd_path_base, "art\\", gArtListDescriptions[OBJ_TYPE_HEAD].name, gArtListDescriptions[OBJ_TYPE_HEAD].fileNames + fileNameOffset, _head1[animType], 102, weaponCode);
} else {
snprintf(_art_name, sizeof(_art_name), "%s%s%s\\%s%c%c.frm", _cd_path_base, "art\\", gArtListDescriptions[8].name, gArtListDescriptions[8].fileNames + v8, _head1[v4], v9);
snprintf(_art_name, sizeof(_art_name), "%s%s%s\\%s%c%c.frm", _cd_path_base, "art\\", gArtListDescriptions[OBJ_TYPE_HEAD].name, gArtListDescriptions[OBJ_TYPE_HEAD].fileNames + fileNameOffset, _head1[animType], headSuffix);
}
} else {
snprintf(_art_name, sizeof(_art_name), "%s%s%s\\%s", _cd_path_base, "art\\", gArtListDescriptions[type].name, gArtListDescriptions[type].fileNames + v8);
snprintf(_art_name, sizeof(_art_name), "%s%s%s\\%s", _cd_path_base, "art\\", gArtListDescriptions[objectType].name, gArtListDescriptions[objectType].fileNames + fileNameOffset);
}
return _art_name;
+3 -3
View File
@@ -129,8 +129,8 @@ 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);
int artCopyFileName(int objectType, int id, char* dest);
int _art_get_code(int animation, int weaponType, char* weaponCodePtr, char* animationCodePtr);
char* artBuildFilePath(int fid);
int artGetFramesPerSecond(Art* art);
int artGetActionFrame(Art* art);
@@ -138,7 +138,7 @@ int artGetFrameCount(Art* art);
int artGetWidth(Art* art, int frame, int direction);
int artGetHeight(Art* art, int frame, int direction);
int artGetSize(Art* art, int frame, int direction, int* out_width, int* out_height);
int artGetFrameOffsets(Art* art, int frame, int direction, int* a4, int* a5);
int artGetFrameOffsets(Art* art, int frame, int direction, int* xPtr, int* yPtr);
int artGetRotationOffsets(Art* art, int rotation, int* out_offset_x, int* out_offset_y);
unsigned char* artGetFrameData(Art* art, int frame, int direction);
ArtFrame* artGetFrame(Art* art, int frame, int direction);
+6 -6
View File
@@ -148,7 +148,7 @@ long audioSeek(int handle, long offset, int origin)
{
int pos;
unsigned char* buf;
int v10;
int remainingBytesToSkip;
Audio* audioFile = &(gAudioList[handle - 1]);
@@ -189,14 +189,14 @@ long audioSeek(int handle, long offset, int origin)
}
} else {
buf = (unsigned char*)internal_malloc_safe(1024, __FILE__, __LINE__); // "..\int\audio.c", 321
v10 = audioFile->position - pos;
while (v10 > 1024) {
v10 -= 1024;
remainingBytesToSkip = audioFile->position - pos;
while (remainingBytesToSkip > 1024) {
remainingBytesToSkip -= 1024;
audioRead(handle, buf, 1024);
}
if (v10 != 0) {
audioRead(handle, buf, v10);
if (remainingBytesToSkip != 0) {
audioRead(handle, buf, remainingBytesToSkip);
}
// TODO: Probably leaks memory.
+11 -11
View File
@@ -148,26 +148,26 @@ long audioFileSeek(int handle, long offset, int origin)
{
void* buf;
int remaining;
int a4;
int targetPosition;
AudioFile* audioFile = &(gAudioFileList[handle - 1]);
switch (origin) {
case SEEK_SET:
a4 = offset;
targetPosition = offset;
break;
case SEEK_CUR:
a4 = audioFile->fileSize + offset;
targetPosition = audioFile->fileSize + offset;
break;
case SEEK_END:
a4 = audioFile->position + offset;
targetPosition = audioFile->position + offset;
break;
default:
assert(false && "Should be unreachable");
}
if ((audioFile->flags & AUDIO_FILE_COMPRESSED) != 0) {
if (a4 <= audioFile->position) {
if (targetPosition <= audioFile->position) {
soundDecoderFree(audioFile->soundDecoder);
fseek(audioFile->stream, 0, 0);
@@ -176,20 +176,20 @@ long audioFileSeek(int handle, long offset, int origin)
audioFile->fileSize *= 2;
audioFile->position = 0;
if (a4) {
if (targetPosition != 0) {
buf = internal_malloc_safe(4096, __FILE__, __LINE__); // "..\int\audiof.c", 364
while (a4 > 4096) {
while (targetPosition > 4096) {
audioFileRead(handle, buf, 4096);
a4 -= 4096;
targetPosition -= 4096;
}
if (a4 != 0) {
audioFileRead(handle, buf, a4);
if (targetPosition != 0) {
audioFileRead(handle, buf, targetPosition);
}
internal_free_safe(buf, __FILE__, __LINE__); // "..\int\audiof.c", 370
}
} else {
buf = internal_malloc_safe(0x400, __FILE__, __LINE__); // "..\int\audiof.c", 316
remaining = audioFile->position - a4;
remaining = audioFile->position - targetPosition;
while (remaining > 1024) {
audioFileRead(handle, buf, 1024);
remaining -= 1024;
+25 -25
View File
@@ -373,7 +373,7 @@ void automapShow(bool isInGame, bool isUsingScanner)
frmImages[AUTOMAP_FRM_SWITCH_UP].getData(),
frmImages[AUTOMAP_FRM_SWITCH_DOWN].getData(),
nullptr,
BUTTON_FLAG_TRANSPARENT | BUTTON_FLAG_0x01);
BUTTON_FLAG_TRANSPARENT | BUTTON_FLAG_CHECKABLE);
if (switchBtn != -1) {
buttonSetCallbacks(switchBtn, _gsound_toggle_butt_press_, _gsound_toggle_butt_press_);
}
@@ -550,7 +550,7 @@ static void automapRenderInMapWindow(int window, int elevation, unsigned char* b
}
}
int v10 = -2 * (object->tile % 200) - 10 + AUTOMAP_WINDOW_WIDTH * (2 * (object->tile / 200) + 9) - 60;
int pixelOffset = -2 * (object->tile % 200) - 10 + AUTOMAP_WINDOW_WIDTH * (2 * (object->tile / 200) + 9) - 60;
if ((flags & AUTOMAP_IN_GAME) == 0) {
switch (objectType) {
case OBJ_TYPE_ITEM:
@@ -574,28 +574,28 @@ static void automapRenderInMapWindow(int window, int elevation, unsigned char* b
}
if (objectColor != _colorTable[0]) {
unsigned char* v12 = windowBuffer + v10;
unsigned char* pixel = windowBuffer + pixelOffset;
if ((flags & AUTOMAP_IN_GAME) != 0) {
if (*v12 != _colorTable[992] || objectColor != _colorTable[480]) {
v12[0] = objectColor;
v12[1] = objectColor;
if (*pixel != _colorTable[992] || objectColor != _colorTable[480]) {
pixel[0] = objectColor;
pixel[1] = objectColor;
}
if (object == gDude) {
v12[-1] = objectColor;
v12[-AUTOMAP_WINDOW_WIDTH] = objectColor;
v12[AUTOMAP_WINDOW_WIDTH] = objectColor;
pixel[-1] = objectColor;
pixel[-AUTOMAP_WINDOW_WIDTH] = objectColor;
pixel[AUTOMAP_WINDOW_WIDTH] = objectColor;
}
} else {
v12[0] = objectColor;
v12[1] = objectColor;
v12[AUTOMAP_WINDOW_WIDTH] = objectColor;
v12[AUTOMAP_WINDOW_WIDTH + 1] = objectColor;
pixel[0] = objectColor;
pixel[1] = objectColor;
pixel[AUTOMAP_WINDOW_WIDTH] = objectColor;
pixel[AUTOMAP_WINDOW_WIDTH + 1] = objectColor;
v12[AUTOMAP_WINDOW_WIDTH - 1] = objectColor;
v12[AUTOMAP_WINDOW_WIDTH + 2] = objectColor;
v12[AUTOMAP_WINDOW_WIDTH * 2] = objectColor;
v12[AUTOMAP_WINDOW_WIDTH * 2 + 1] = objectColor;
pixel[AUTOMAP_WINDOW_WIDTH - 1] = objectColor;
pixel[AUTOMAP_WINDOW_WIDTH + 2] = objectColor;
pixel[AUTOMAP_WINDOW_WIDTH * 2] = objectColor;
pixel[AUTOMAP_WINDOW_WIDTH * 2 + 1] = objectColor;
}
}
}
@@ -639,8 +639,8 @@ int automapRenderInPipboyWindow(int window, int map, int elevation)
return -1;
}
int v1 = 0;
unsigned char v2 = 0;
int bitsRemaining = 0; // Number of 2-bit tile entries left in `byte`.
unsigned char byte = 0;
unsigned char* ptr = gAutomapEntry.data;
// FIXME: This loop is implemented incorrectly. Automap requires 400x400 px,
@@ -650,13 +650,13 @@ int automapRenderInPipboyWindow(int window, int map, int elevation)
// crash.
for (int y = 0; y < HEX_GRID_HEIGHT; y++) {
for (int x = 0; x < HEX_GRID_WIDTH; x++) {
v1 -= 1;
if (v1 <= 0) {
v1 = 4;
v2 = *ptr++;
bitsRemaining -= 1;
if (bitsRemaining <= 0) {
bitsRemaining = 4;
byte = *ptr++;
}
switch ((v2 & 0xC0) >> 6) {
switch ((byte & 0xC0) >> 6) {
case 1:
*windowBuffer++ = wallColor;
*windowBuffer++ = wallColor;
@@ -670,7 +670,7 @@ int automapRenderInPipboyWindow(int window, int map, int elevation)
break;
}
v2 <<= 2;
byte <<= 2;
}
windowBuffer += 640 + 240;
+12 -12
View File
@@ -575,26 +575,26 @@ static bool cacheSetCapacity(Cache* cache, int newCapacity)
// 0x420A74
static int cacheEntriesCompareByUsage(const void* a1, const void* a2)
{
CacheEntry* v1 = *(CacheEntry**)a1;
CacheEntry* v2 = *(CacheEntry**)a2;
CacheEntry* lhs = *(CacheEntry**)a1;
CacheEntry* rhs = *(CacheEntry**)a2;
if (v1->referenceCount != 0 && v2->referenceCount == 0) {
if (lhs->referenceCount != 0 && rhs->referenceCount == 0) {
return 1;
}
if (v2->referenceCount != 0 && v1->referenceCount == 0) {
if (rhs->referenceCount != 0 && lhs->referenceCount == 0) {
return -1;
}
if (v1->hits < v2->hits) {
if (lhs->hits < rhs->hits) {
return -1;
} else if (v1->hits > v2->hits) {
} else if (lhs->hits > rhs->hits) {
return 1;
}
if (v1->mru < v2->mru) {
if (lhs->mru < rhs->mru) {
return -1;
} else if (v1->mru > v2->mru) {
} else if (lhs->mru > rhs->mru) {
return 1;
}
@@ -604,12 +604,12 @@ static int cacheEntriesCompareByUsage(const void* a1, const void* a2)
// 0x420AE8
static int cacheEntriesCompareByMostRecentHit(const void* a1, const void* a2)
{
CacheEntry* v1 = *(CacheEntry**)a1;
CacheEntry* v2 = *(CacheEntry**)a2;
CacheEntry* lhs = *(CacheEntry**)a1;
CacheEntry* rhs = *(CacheEntry**)a2;
if (v1->mru < v2->mru) {
if (lhs->mru < rhs->mru) {
return 1;
} else if (v1->mru > v2->mru) {
} else if (lhs->mru > rhs->mru) {
return -1;
} else {
return 0;
+6 -6
View File
@@ -3627,7 +3627,7 @@ static void characterEditorEditGender()
_editorFrmImages[EDITOR_GRAPHIC_MALE_OFF].getData(),
_editorFrmImages[EDITOR_GRAPHIC_MALE_ON].getData(),
nullptr,
BUTTON_FLAG_TRANSPARENT | BUTTON_FLAG_0x04 | BUTTON_FLAG_0x02 | BUTTON_FLAG_0x01);
BUTTON_FLAG_TRANSPARENT | BUTTON_FLAG_NO_TOGGLE_OFF | BUTTON_FLAG_CHECK_ON_DOWN | BUTTON_FLAG_CHECKABLE);
if (btns[0] != -1) {
buttonSetCallbacks(doneBtn, _gsound_red_butt_press, nullptr);
}
@@ -3644,7 +3644,7 @@ static void characterEditorEditGender()
_editorFrmImages[EDITOR_GRAPHIC_FEMALE_OFF].getData(),
_editorFrmImages[EDITOR_GRAPHIC_FEMALE_ON].getData(),
nullptr,
BUTTON_FLAG_TRANSPARENT | BUTTON_FLAG_0x04 | BUTTON_FLAG_0x02 | BUTTON_FLAG_0x01);
BUTTON_FLAG_TRANSPARENT | BUTTON_FLAG_NO_TOGGLE_OFF | BUTTON_FLAG_CHECK_ON_DOWN | BUTTON_FLAG_CHECKABLE);
if (btns[1] != -1) {
_win_group_radio_buttons(2, btns);
buttonSetCallbacks(doneBtn, _gsound_red_butt_press, nullptr);
@@ -3946,7 +3946,7 @@ static int characterEditorShowOptions()
strcat(string4, "TXT");
char** fileList;
int fileListLength = fileNameListInit(string4, &fileList, 0, 0);
int fileListLength = fileNameListInit(string4, &fileList);
if (fileListLength != -1) {
// PRINT
strcpy(string1, getmsg(&gCharacterEditorMessageList, &gCharacterEditorMessageListItem, 616));
@@ -4018,7 +4018,7 @@ static int characterEditorShowOptions()
strcat(string4, "GCD");
char** fileNameList;
int fileNameListLength = fileNameListInit(string4, &fileNameList, 0, 0);
int fileNameListLength = fileNameListInit(string4, &fileNameList);
if (fileNameListLength != -1) {
// NOTE: This value is not copied as in save dialog.
char* title = getmsg(&gCharacterEditorMessageList, &gCharacterEditorMessageListItem, 601);
@@ -4111,7 +4111,7 @@ static int characterEditorShowOptions()
strcat(string4, "GCD");
char** fileNameList;
int fileNameListLength = fileNameListInit(string4, &fileNameList, 0, 0);
int fileNameListLength = fileNameListInit(string4, &fileNameList);
if (fileNameListLength != -1) {
strcpy(string1, getmsg(&gCharacterEditorMessageList, &gCharacterEditorMessageListItem, 617));
strcpy(string4, getmsg(&gCharacterEditorMessageList, &gCharacterEditorMessageListItem, 600));
@@ -4198,7 +4198,7 @@ static int characterEditorShowOptions()
strcpy(pattern, "*.TXT");
char** fileNames;
int filesCount = fileNameListInit(pattern, &fileNames, 0, 0);
int filesCount = fileNameListInit(pattern, &fileNames);
if (filesCount == -1) {
soundPlayFile("iisxxxx1");
+3 -3
View File
@@ -77,7 +77,7 @@ typedef enum PremadeCharacter {
typedef struct PremadeCharacterDescription {
char fileName[20];
int face;
char field_18[20];
char vid[20];
} PremadeCharacterDescription;
static bool characterSelectorWindowInit();
@@ -959,7 +959,7 @@ void premadeCharactersInit()
faceFidsString = pch + 1;
gCustomPremadeCharacterDescriptions[index].field_18[0] = '\0';
gCustomPremadeCharacterDescriptions[index].vid[0] = '\0';
}
}
@@ -969,7 +969,7 @@ void premadeCharactersInit()
for (int index = 0; index < PREMADE_CHARACTER_COUNT; index++) {
strcpy(gCustomPremadeCharacterDescriptions[index].fileName, gPremadeCharacterDescriptions[index].fileName);
gCustomPremadeCharacterDescriptions[index].face = gPremadeCharacterDescriptions[index].face;
strcpy(gCustomPremadeCharacterDescriptions[index].field_18, gPremadeCharacterDescriptions[index].field_18);
strcpy(gCustomPremadeCharacterDescriptions[index].vid, gPremadeCharacterDescriptions[index].vid);
}
}
+71 -83
View File
@@ -11,9 +11,9 @@
namespace fallout {
static void _setIntensityTableColor(int a1);
static void _setIntensityTableColor(int color);
static void _setIntensityTables();
static void _setMixTableColor(int a1);
static void _setMixTableColor(int color);
static void _buildBlendTable(unsigned char* ptr, unsigned char ch);
static void _rebuildColorBlendTables();
@@ -203,88 +203,76 @@ static void _setIntensityTables()
}
// 0x4C769C
static void _setMixTableColor(int a1)
static void _setMixTableColor(int color)
{
int i;
int v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16, v17, v18, v19;
int v20, v21, v22, v23, v24, v25, v26, v27, v28, v29;
for (int otherColor = 0; otherColor < 256; otherColor++) {
if (_mappedColor[color] && _mappedColor[otherColor]) {
int colorRgb = Color2RGB(color);
int otherColorRgb = Color2RGB(otherColor);
for (i = 0; i < 256; i++) {
if (_mappedColor[a1] && _mappedColor[i]) {
v2 = (Color2RGB(a1) & 0x7C00) >> 10;
v3 = (Color2RGB(a1) & 0x3E0) >> 5;
v4 = (Color2RGB(a1) & 0x1F);
int colorR = (colorRgb & 0x7C00) >> 10;
int colorG = (colorRgb & 0x3E0) >> 5;
int colorB = colorRgb & 0x1F;
v5 = (Color2RGB(i) & 0x7C00) >> 10;
v6 = (Color2RGB(i) & 0x3E0) >> 5;
v7 = (Color2RGB(i) & 0x1F);
int otherColorR = (otherColorRgb & 0x7C00) >> 10;
int otherColorG = (otherColorRgb & 0x3E0) >> 5;
int otherColorB = otherColorRgb & 0x1F;
v8 = v2 + v5;
v9 = v3 + v6;
v10 = v4 + v7;
int addedR = colorR + otherColorR;
int addedG = colorG + otherColorG;
int addedB = colorB + otherColorB;
v11 = v8;
if (v9 > v11) {
v11 = v9;
int maxAddedChannel = addedR;
if (addedG > maxAddedChannel) {
maxAddedChannel = addedG;
}
if (addedB > maxAddedChannel) {
maxAddedChannel = addedB;
}
if (v10 > v11) {
v11 = v10;
}
if (v11 <= 0x1F) {
int paletteIndex = (v8 << 10) | (v9 << 5) | v10;
v12 = _colorTable[paletteIndex];
int additiveColor;
if (maxAddedChannel <= 0x1F) {
int paletteIndex = (addedR << 10) | (addedG << 5) | addedB;
additiveColor = _colorTable[paletteIndex];
} else {
v13 = v11 - 0x1F;
int overflow = maxAddedChannel - 0x1F;
v14 = v8 - v13;
v15 = v9 - v13;
v16 = v10 - v13;
int normalizedR = addedR - overflow;
int normalizedG = addedG - overflow;
int normalizedB = addedB - overflow;
if (v14 < 0) {
v14 = 0;
if (normalizedR < 0) {
normalizedR = 0;
}
if (normalizedG < 0) {
normalizedG = 0;
}
if (normalizedB < 0) {
normalizedB = 0;
}
if (v15 < 0) {
v15 = 0;
}
int saturatedPaletteIndex = (normalizedR << 10) | (normalizedG << 5) | normalizedB;
int saturatedColor = _colorTable[saturatedPaletteIndex];
if (v16 < 0) {
v16 = 0;
}
v17 = (v14 << 10) | (v15 << 5) | v16;
v18 = _colorTable[v17];
v19 = (int)((((double)v11 + (-31.0)) * 0.0078125 + 1.0) * 65536.0);
v12 = _calculateColor(v19, v18);
int intensity = (int)((((double)maxAddedChannel + (-31.0)) * 0.0078125 + 1.0) * 65536.0);
additiveColor = _calculateColor(intensity, saturatedColor);
}
colorMixAddTable[a1][i] = v12;
colorMixAddTable[color][otherColor] = additiveColor;
v20 = (Color2RGB(a1) & 0x7C00) >> 10;
v21 = (Color2RGB(a1) & 0x3E0) >> 5;
v22 = (Color2RGB(a1) & 0x1F);
int multipliedR = (colorR * otherColorR) >> 5;
int multipliedG = (colorG * otherColorG) >> 5;
int multipliedB = (colorB * otherColorB) >> 5;
v23 = (Color2RGB(i) & 0x7C00) >> 10;
v24 = (Color2RGB(i) & 0x3E0) >> 5;
v25 = (Color2RGB(i) & 0x1F);
v26 = (v20 * v23) >> 5;
v27 = (v21 * v24) >> 5;
v28 = (v22 * v25) >> 5;
v29 = (v26 << 10) | (v27 << 5) | v28;
colorMixMulTable[a1][i] = _colorTable[v29];
int multiplyPaletteIndex = (multipliedR << 10) | (multipliedG << 5) | multipliedB;
colorMixMulTable[color][otherColor] = _colorTable[multiplyPaletteIndex];
} else {
if (_mappedColor[i]) {
colorMixAddTable[a1][i] = i;
colorMixMulTable[a1][i] = i;
if (_mappedColor[otherColor]) {
colorMixAddTable[color][otherColor] = otherColor;
colorMixMulTable[color][otherColor] = otherColor;
} else {
colorMixAddTable[a1][i] = a1;
colorMixMulTable[a1][i] = a1;
colorMixAddTable[color][otherColor] = color;
colorMixMulTable[color][otherColor] = color;
}
}
}
@@ -376,7 +364,7 @@ static void _buildBlendTable(unsigned char* ptr, unsigned char ch)
{
int r, g, b;
int i, j;
int v12, v14, v16;
int mixedR, mixedG, mixedB;
unsigned char* beg;
beg = ptr;
@@ -392,7 +380,7 @@ static void _buildBlendTable(unsigned char* ptr, unsigned char ch)
ptr += 256;
int b_1 = b;
int v31 = 6;
int blendWeight = 6;
int g_1 = g;
int r_1 = r;
@@ -402,31 +390,31 @@ static void _buildBlendTable(unsigned char* ptr, unsigned char ch)
for (j = 0; j < 7; j++) {
for (i = 0; i < 256; i++) {
v12 = (Color2RGB(i) & 0x7C00) >> 10;
v14 = (Color2RGB(i) & 0x3E0) >> 5;
v16 = (Color2RGB(i) & 0x1F);
mixedR = (Color2RGB(i) & 0x7C00) >> 10;
mixedG = (Color2RGB(i) & 0x3E0) >> 5;
mixedB = (Color2RGB(i) & 0x1F);
int index = 0;
index |= (r_2 + v12 * v31) / 7 << 10;
index |= (g_2 + v14 * v31) / 7 << 5;
index |= (b_2 + v16 * v31) / 7;
index |= (r_2 + mixedR * blendWeight) / 7 << 10;
index |= (g_2 + mixedG * blendWeight) / 7 << 5;
index |= (b_2 + mixedB * blendWeight) / 7;
ptr[i] = _colorTable[index];
}
v31--;
blendWeight--;
ptr += 256;
r_2 += r_1;
g_2 += g_1;
b_2 += b_1;
}
int v18 = 0;
int shadeStep = 0;
for (j = 0; j < 6; j++) {
int v20 = v18 / 7 + 0xFFFF;
int shadeIntensity = shadeStep / 7 + 0xFFFF;
for (i = 0; i < 256; i++) {
ptr[i] = _calculateColor(v20, ch);
ptr[i] = _calculateColor(shadeIntensity, ch);
}
v18 += 0x10000;
shadeStep += 0x10000;
ptr += 256;
}
}
@@ -462,15 +450,15 @@ unsigned char* _getColorBlendTable(int ch)
}
// 0x4C7E20
void _freeColorBlendTable(int a1)
void _freeColorBlendTable(int color)
{
unsigned char* v2 = _blendTable[a1];
if (v2 != nullptr) {
int* count = (int*)(v2 - sizeof(int));
unsigned char* blendTable = _blendTable[color];
if (blendTable != nullptr) {
int* count = (int*)(blendTable - sizeof(int));
*count -= 1;
if (*count == 0) {
internal_free(count);
_blendTable[a1] = nullptr;
_blendTable[color] = nullptr;
}
}
}
+2 -2
View File
@@ -24,11 +24,11 @@ void colorPaletteFadeBetween(unsigned char* oldPalette, unsigned char* newPalett
void colorPaletteSetTransitionCallback(ColorTransitionCallback* callback);
void _setSystemPalette(unsigned char* palette);
unsigned char* _getSystemPalette();
void _setSystemPaletteEntries(unsigned char* a1, int a2, int a3);
void _setSystemPaletteEntries(unsigned char* palette, int start, int end);
bool colorPaletteLoad(const char* path);
char* _colorError();
unsigned char* _getColorBlendTable(int ch);
void _freeColorBlendTable(int a1);
void _freeColorBlendTable(int color);
void colorSetBrightness(double value);
bool _initColors();
void _colorsClose();
+18 -15
View File
@@ -39,6 +39,7 @@
#include "sfall_callbacks.h"
#include "sfall_config.h"
#include "sfall_global_scripts.h"
#include "sfall_script_hooks.h"
#include "skill.h"
#include "stat.h"
#include "svga.h"
@@ -2839,7 +2840,7 @@ static void _combat_over()
gameMouseSetMode(GAME_MOUSE_MODE_MOVE);
interfaceRenderArmorClass(true);
if (_critter_is_prone(gDude) && !critterIsDead(gDude) && _combat_ending_guy == nullptr) {
if (critterIsProne(gDude) && !critterIsDead(gDude) && _combat_ending_guy == nullptr) {
queueRemoveEventsByType(gDude, EVENT_TYPE_KNOCKOUT);
knockoutEventProcess(gDude, nullptr);
}
@@ -3013,11 +3014,11 @@ static void _combat_sequence_init(Object* attacker, Object* defender)
_list_noncom -= next;
if (attacker != nullptr) {
_critter_set_who_hit_me(attacker, defender);
critterSetWhoHitMe(attacker, defender);
}
if (defender != nullptr) {
_critter_set_who_hit_me(defender, attacker);
critterSetWhoHitMe(defender, attacker);
}
}
@@ -3262,7 +3263,7 @@ static int _combat_turn(Object* obj, bool a2)
}
if (!scriptOverrides) {
if (!a2 && _critter_is_prone(obj)) {
if (!a2 && critterIsProne(obj)) {
_combat_standup(obj);
}
@@ -3552,7 +3553,7 @@ int _combat_attack(Object* attacker, Object* defender, int hitMode, int hitLocat
if (attacker == gDude) {
interfaceRenderActionPoints(attacker->data.critter.combat.ap, _combat_free_move);
_critter_set_who_hit_me(attacker, defender);
critterSetWhoHitMe(attacker, defender);
}
// SFALL
@@ -3907,7 +3908,7 @@ static int attackCompute(Attack* attack)
}
}
if (_item_w_compute_ammo_cost(attack->weapon, &(attack->ammoQuantity)) == -1) {
if (weaponComputeAmmoCost(attack->weapon, &(attack->ammoQuantity)) == -1) {
return -1;
}
@@ -4094,7 +4095,7 @@ void _compute_explosion_on_extras(Attack* attack, bool isFromAttacker, bool isGr
static int attackComputeCriticalHit(Attack* attack)
{
Object* defender = attack->defender;
if (defender != nullptr && _critter_flag_check(defender->pid, CRITTER_INVULNERABLE)) {
if (defender != nullptr && critterFlagCheck(defender->pid, CRITTER_INVULNERABLE)) {
return 2;
}
@@ -4168,7 +4169,7 @@ static int _attackFindInvalidFlags(Object* critter, Object* item)
{
int flags = 0;
if (critter != nullptr && PID_TYPE(critter->pid) == OBJ_TYPE_CRITTER && _critter_flag_check(critter->pid, CRITTER_NO_DROP)) {
if (critter != nullptr && PID_TYPE(critter->pid) == OBJ_TYPE_CRITTER && critterFlagCheck(critter->pid, CRITTER_NO_DROP)) {
flags |= DAM_DROP;
}
@@ -4184,7 +4185,7 @@ static int attackComputeCriticalFailure(Attack* attack)
{
attack->attackerFlags &= ~DAM_HIT;
if (attack->attacker != nullptr && _critter_flag_check(attack->attacker->pid, CRITTER_INVULNERABLE)) {
if (attack->attacker != nullptr && critterFlagCheck(attack->attacker->pid, CRITTER_INVULNERABLE)) {
return 0;
}
@@ -4491,6 +4492,7 @@ static int attackDetermineToHit(Object* attacker, int tile, Object* defender, in
}
}
int toHitUncapped = toHit;
if (toHit > 95) {
toHit = 95;
}
@@ -4499,6 +4501,7 @@ static int attackDetermineToHit(Object* attacker, int tile, Object* defender, in
debugPrint("Whoa! Bad skill value in determine_to_hit!\n");
}
toHit = scriptHooks_ToHit(attacker, defender, tile, hitMode, hitLocation, toHit, toHitUncapped, useDistance);
return toHit;
}
@@ -4639,7 +4642,7 @@ static void attackComputeDamage(Attack* attack, int ammoQuantity, int bonusDamag
&& (critter->flags & OBJECT_MULTIHEX) == 0
&& (damageType == DAMAGE_TYPE_EXPLOSION || attack->weapon == nullptr || weaponGetAttackTypeForHitMode(attack->weapon, attack->hitMode) == ATTACK_TYPE_MELEE)
&& PID_TYPE(critter->pid) == OBJ_TYPE_CRITTER
&& !_critter_flag_check(critter->pid, CRITTER_NO_KNOCKBACK)) {
&& !critterFlagCheck(critter->pid, CRITTER_NO_KNOCKBACK)) {
bool shouldKnockback = true;
bool hasStonewall = false;
if (critter == gDude) {
@@ -4716,7 +4719,7 @@ void _apply_damage(Attack* attack, bool animated)
if (defenderIsCritter) {
if ((defender->data.critter.combat.results & (DAM_DEAD | DAM_KNOCKED_OUT)) != 0) {
if (!v5 || defender != gDude) {
_critter_set_who_hit_me(defender, attack->attacker);
critterSetWhoHitMe(defender, attack->attacker);
}
} else if (defender == attack->oops || defender->data.critter.combat.team != attack->attacker->data.critter.combat.team) {
_combatai_check_retaliation(defender, attack->attacker);
@@ -4745,7 +4748,7 @@ void _apply_damage(Attack* attack, bool animated)
if (defenderIsCritter) {
if ((obj->data.critter.combat.results & (DAM_DEAD | DAM_KNOCKED_OUT)) != 0) {
_critter_set_who_hit_me(obj, attack->attacker);
critterSetWhoHitMe(obj, attack->attacker);
} else if (obj->data.critter.combat.team != attack->attacker->data.critter.combat.team) {
_combatai_check_retaliation(obj, attack->attacker);
}
@@ -4770,7 +4773,7 @@ void _apply_damage(Attack* attack, bool animated)
// 0x424EE8
static void _check_for_death(Object* object, int damage, int* flags)
{
if (object == nullptr || !_critter_flag_check(object->pid, CRITTER_INVULNERABLE)) {
if (object == nullptr || !critterFlagCheck(object->pid, CRITTER_INVULNERABLE)) {
if (object == nullptr || PID_TYPE(object->pid) == OBJ_TYPE_CRITTER) {
if (damage > 0) {
if (critterGetHitPoints(object) - damage <= 0) {
@@ -4792,7 +4795,7 @@ static void _set_new_results(Object* critter, int flags)
return;
}
if (_critter_flag_check(critter->pid, CRITTER_INVULNERABLE)) {
if (critterFlagCheck(critter->pid, CRITTER_INVULNERABLE)) {
return;
}
@@ -4833,7 +4836,7 @@ static void _damage_object(Object* a1, int damage, bool animated, int a4, Object
return;
}
if (_critter_flag_check(a1->pid, CRITTER_INVULNERABLE)) {
if (critterFlagCheck(a1->pid, CRITTER_INVULNERABLE)) {
return;
}
+25 -25
View File
@@ -997,7 +997,7 @@ static int _ai_check_drugs(Object* critter)
int minHp = critterGetStat(critter, STAT_MAXIMUM_HIT_POINTS) * hpRatio / 100;
int inventoryItemIndex = -1;
while (critterGetStat(critter, STAT_CURRENT_HIT_POINTS) < minHp && critter->data.critter.combat.ap >= 2) {
Object* drug = _inven_find_type(critter, ITEM_TYPE_DRUG, &inventoryItemIndex);
Object* drug = inventoryFindByType(critter, ITEM_TYPE_DRUG, &inventoryItemIndex);
if (drug == nullptr) {
searchCompleted = true;
break;
@@ -1006,12 +1006,12 @@ static int _ai_check_drugs(Object* critter)
int drugPid = drug->pid;
if (itemIsHealing(drugPid)) {
if (itemRemove(critter, drug, 1) == 0) {
if (_item_d_take_drug(critter, drug) == -1) {
if (drugItemTakeDrug(critter, drug) == -1) {
itemAdd(critter, drug, 1);
} else {
_ai_magic_hands(critter, drug, 5000);
_obj_connect(drug, critter->tile, critter->elevation, nullptr);
_obj_destroy(drug);
objectDestroy(drug);
drugUsed = true;
}
@@ -1054,7 +1054,7 @@ static int _ai_check_drugs(Object* critter)
// The alternative is to use a pair of `std::vector`s and let
// them manage the memory.
while (true) {
Object* drug = _inven_find_type(critter, ITEM_TYPE_DRUG, &inventoryItemIndex);
Object* drug = inventoryFindByType(critter, ITEM_TYPE_DRUG, &inventoryItemIndex);
if (drug == nullptr) {
searchCompleted = true;
break;
@@ -1103,12 +1103,12 @@ static int _ai_check_drugs(Object* critter)
*availableDrugsCountPtr -= 1;
if (itemRemove(critter, drug, 1) == 0) {
if (_item_d_take_drug(critter, drug) == -1) {
if (drugItemTakeDrug(critter, drug) == -1) {
itemAdd(critter, drug, 1);
} else {
_ai_magic_hands(critter, drug, 5000);
_obj_connect(drug, critter->tile, critter->elevation, nullptr);
_obj_destroy(drug);
objectDestroy(drug);
drugUsed = true;
drugCount += 1;
}
@@ -1148,12 +1148,12 @@ static int _ai_check_drugs(Object* critter)
}
if (itemRemove(critter, lastItem, 1) == 0) {
if (_item_d_take_drug(critter, lastItem) == -1) {
if (drugItemTakeDrug(critter, lastItem) == -1) {
itemAdd(critter, lastItem, 1);
} else {
_ai_magic_hands(critter, lastItem, 5000);
_obj_connect(lastItem, critter->tile, critter->elevation, nullptr);
_obj_destroy(lastItem);
objectDestroy(lastItem);
lastItem = nullptr;
}
@@ -1775,7 +1775,7 @@ static bool aiHaveAmmo(Object* critter, Object* weapon, Object** ammoPtr)
int inventoryItemIndex = -1;
while (1) {
Object* ammo = _inven_find_type(critter, ITEM_TYPE_AMMO, &inventoryItemIndex);
Object* ammo = inventoryFindByType(critter, ITEM_TYPE_AMMO, &inventoryItemIndex);
if (ammo == nullptr) {
break;
}
@@ -1789,10 +1789,10 @@ static bool aiHaveAmmo(Object* critter, Object* weapon, Object** ammoPtr)
if (weaponGetAnimationCode(weapon)) {
if (weaponGetRange(critter, HIT_MODE_RIGHT_WEAPON_PRIMARY) < 3) {
_inven_unwield(critter, HAND_RIGHT);
inventoryUnequip(critter, HAND_RIGHT);
}
} else {
_inven_unwield(critter, HAND_RIGHT);
inventoryUnequip(critter, HAND_RIGHT);
}
}
@@ -2012,7 +2012,7 @@ Object* _ai_search_inven_weap(Object* critter, bool checkRequiredActionPoints, O
Object* bestWeapon = nullptr;
Object* rightHandWeapon = critterGetItem2(critter);
while (true) {
Object* weapon = _inven_find_type(critter, ITEM_TYPE_WEAPON, &token);
Object* weapon = inventoryFindByType(critter, ITEM_TYPE_WEAPON, &token);
if (weapon == nullptr) {
break;
}
@@ -2073,7 +2073,7 @@ Object* _ai_search_inven_armor(Object* critter)
int inventoryItemIndex = -1;
while (true) {
Object* candidate = _inven_find_type(critter, ITEM_TYPE_ARMOR, &inventoryItemIndex);
Object* candidate = inventoryFindByType(critter, ITEM_TYPE_ARMOR, &inventoryItemIndex);
if (candidate == nullptr) {
break;
}
@@ -2245,7 +2245,7 @@ static Object* _ai_retrieve_object(Object* critter, Object* item)
// Find the item in NPC's inventory. This step is needed because NPC could
// not get the item on this turn.
Object* retrievedItem = _inven_find_id(critter, item->id);
Object* retrievedItem = inventoryFindById(critter, item->id);
if (retrievedItem != nullptr || item->owner != nullptr) {
// Either NPC have the item, or someone else have picked it up.
@@ -2620,7 +2620,7 @@ static int _ai_switch_weapons(Object* attacker, int* hitMode, Object** weapon, O
}
if (*weapon != nullptr) {
_inven_wield(attacker, *weapon, HAND_RIGHT);
inventoryEquip(attacker, *weapon, HAND_RIGHT);
_combat_turn_run();
if (weaponGetActionPointCost(attacker, *hitMode, 0) <= attacker->data.critter.combat.ap) {
return 0;
@@ -2691,7 +2691,7 @@ static int _ai_attack(Object* attacker, Object* defender, int hitMode)
// 0x42A7D8
static int _ai_try_attack(Object* attacker, Object* defender)
{
_critter_set_who_hit_me(attacker, defender);
critterSetWhoHitMe(attacker, defender);
CritterCombatData* combatData = &(attacker->data.critter.combat);
bool taunt = true;
@@ -2736,7 +2736,7 @@ static int _ai_try_attack(Object* attacker, Object* defender)
while (aiHaveAmmo(attacker, weapon, &ammo)) {
int remainingAmmoQuantity = weaponReload(weapon, ammo);
if (remainingAmmoQuantity == 0 && ammo != nullptr) {
_obj_destroy(ammo);
objectDestroy(ammo);
++roundsLoaded;
} else {
break;
@@ -2768,7 +2768,7 @@ static int _ai_try_attack(Object* attacker, Object* defender)
if (ammo != nullptr) {
int remainingAmmoQuantity = weaponReload(weapon, ammo);
if (remainingAmmoQuantity == 0) {
_obj_destroy(ammo);
objectDestroy(ammo);
}
if (remainingAmmoQuantity != -1) {
@@ -2796,7 +2796,7 @@ static int _ai_try_attack(Object* attacker, Object* defender)
_gsound_play_sfx_file_volume(sfx, volume);
_ai_magic_hands(attacker, weapon, 5001);
if (_inven_unwield(attacker, 1) == 0) {
if (inventoryUnequip(attacker, 1) == 0) {
_combat_turn_run();
}
@@ -2911,7 +2911,7 @@ static int _ai_try_attack(Object* attacker, Object* defender)
int _cAIPrepWeaponItem(Object* critter, Object* item)
{
if (item != nullptr && critterGetStat(critter, STAT_INTELLIGENCE) >= 3 && item->pid == PROTO_ID_FLARE && lightGetAmbientIntensity() < LIGHT_INTENSITY_MAX * 0.85) {
_protinst_use_item(critter, item);
objectUseItem(critter, item);
}
return 0;
}
@@ -2933,7 +2933,7 @@ void aiAttemptWeaponReload(Object* critter, int animate)
if (aiHaveAmmo(critter, weapon, &ammo)) {
int rc = weaponReload(weapon, ammo);
if (rc == 0) {
_obj_destroy(ammo);
objectDestroy(ammo);
++loadedRounds;
} else {
break;
@@ -3252,7 +3252,7 @@ int critterSetTeam(Object* obj, int team)
obj->data.critter.combat.team = team;
if (obj->data.critter.combat.whoHitMeCid == -1) {
_critter_set_who_hit_me(obj, nullptr);
critterSetWhoHitMe(obj, nullptr);
debugPrint("\nError: CombatData found with invalid who_hit_me!");
return -1;
}
@@ -3260,7 +3260,7 @@ int critterSetTeam(Object* obj, int team)
Object* whoHitMe = obj->data.critter.combat.whoHitMe;
if (whoHitMe != nullptr) {
if (whoHitMe->data.critter.combat.team == team) {
_critter_set_who_hit_me(obj, nullptr);
critterSetWhoHitMe(obj, nullptr);
}
}
@@ -3502,10 +3502,10 @@ void _combatai_check_retaliation(Object* a1, Object* a2)
int candidateRating = _combatai_rating(a2);
int whoHitMeRating = _combatai_rating(whoHitMe);
if (candidateRating > whoHitMeRating) {
_critter_set_who_hit_me(a1, a2);
critterSetWhoHitMe(a1, a2);
}
} else {
_critter_set_who_hit_me(a1, a2);
critterSetWhoHitMe(a1, a2);
}
}
+23 -1
View File
@@ -13,7 +13,7 @@
namespace fallout {
#define CONFIG_FILE_MAX_LINE_LENGTH (256)
#define CONFIG_FILE_MAX_LINE_LENGTH (1024)
// The initial number of sections (or key-value) pairs in the config.
#define CONFIG_INITIAL_CAPACITY (10)
@@ -143,6 +143,17 @@ bool configGetString(Config* config, const char* sectionKey, const char* key, ch
return true;
}
bool configGetString(Config* config, const char* sectionKey, const char* key, char** valuePtr, const char* defaultValue)
{
if (config == nullptr || sectionKey == nullptr || key == nullptr || valuePtr == nullptr) {
return false;
}
if (!configGetString(config, sectionKey, key, valuePtr) || (*valuePtr)[0] == '\0') {
*valuePtr = const_cast<char*>(defaultValue);
}
return true;
}
// 0x42BF90
bool configSetString(Config* config, const char* sectionKey, const char* key, const char* value)
{
@@ -217,6 +228,17 @@ bool configGetInt(Config* config, const char* sectionKey, const char* key, int*
return true;
}
bool configGetInt(Config* config, const char* sectionKey, const char* key, int* valuePtr, const int defaultValue, unsigned char base)
{
if (config == nullptr || sectionKey == nullptr || key == nullptr || valuePtr == nullptr) {
return false;
}
if (!configGetInt(config, sectionKey, key, valuePtr, base)) {
*valuePtr = defaultValue;
}
return true;
}
// 0x42C090
bool configGetIntList(Config* config, const char* sectionKey, const char* key, int* arr, int count)
{

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