Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
NovaRain committed May 21, 2020
2 parents 9a4f0c7 + b263b69 commit ea921aa
Show file tree
Hide file tree
Showing 32 changed files with 705 additions and 697 deletions.
3 changes: 2 additions & 1 deletion sfall/FalloutEngine/EngineUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void ToggleNpcFlag(fo::GameObject* npc, long flag, bool set) {
}
}

// Returns the number of party members in the existing table (begins from 1)
// Returns the position of party member in the existing table (begins from 1)
long IsPartyMemberByPid(long pid) {
size_t patryCount = fo::var::partyMemberMaxCount;
if (patryCount) {
Expand All @@ -178,6 +178,7 @@ long IsPartyMemberByPid(long pid) {
return 0;
}

// Returns True if the NPC belongs to the player's potential (set in party.txt) party members (analog of broken isPotentialPartyMember_)
bool IsPartyMember(fo::GameObject* critter) {
if (critter->id < PLAYER_ID) return false;
return (IsPartyMemberByPid(critter->protoId) > 0);
Expand Down
3 changes: 2 additions & 1 deletion sfall/FalloutEngine/EngineUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ long __fastcall IsRadInfluence();

void ToggleNpcFlag(fo::GameObject* npc, long flag, bool set);

// Returns the number of party members in the existing table (begins from 1)
// Returns the position of party member in the existing table (begins from 1)
long IsPartyMemberByPid(long pid);

// Returns True if the NPC belongs to the player's potential (set in party.txt) party members (analog of broken isPotentialPartyMember_)
bool IsPartyMember(fo::GameObject* critter);

// Returns the number of local variables of the object script
Expand Down
5 changes: 3 additions & 2 deletions sfall/Modules/AI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ fo::GameObject* AI::sf_check_critters_in_lof(fo::GameObject* object, DWORD check
fo::GameObject* AI::CheckFriendlyFire(fo::GameObject* target, fo::GameObject* attacker) {
fo::GameObject* object = nullptr;
fo::func::make_straight_path_func(attacker, attacker->tile, target->tile, 0, (DWORD*)&object, 32, (void*)fo::funcoffs::obj_shoot_blocking_at_);
return sf_check_critters_in_lof(object, target->tile, attacker->critter.teamNum); // 0 if there are no friendly critters
object = sf_check_critters_in_lof(object, target->tile, attacker->critter.teamNum);
return (!object || object->TypeFid() == fo::ObjType::OBJ_TYPE_CRITTER) ? object : nullptr; // 0 if there are no friendly critters
}

static void __declspec(naked) ai_try_attack_hook_FleeFix() {
Expand All @@ -59,7 +60,7 @@ static void __declspec(naked) ai_try_attack_hook_FleeFix() {
}

static void __declspec(naked) combat_ai_hook_FleeFix() {
static const DWORD combat_ai_hook_flee_Ret = 0x42B22F;
static const DWORD combat_ai_hook_flee_Ret = 0x42B206;
__asm {
test byte ptr [ebp], 8; // 'ReTarget' flag (critter.combat_state)
jnz reTarget;
Expand Down
7 changes: 6 additions & 1 deletion sfall/Modules/DebugEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,11 @@ static void __declspec(naked) art_data_size_hook() {
push edx;
push artDbgMsg;
call fo::funcoffs::debug_printf_;
cmp isDebug, 0;
jne display;
add esp, 8;
retn;
display:
push edx; // filename
push artDbgMsg;
lea eax, [esp + 0x124 - 0x124 + 20]; // buf
Expand Down Expand Up @@ -379,7 +384,7 @@ static void DebugModePatch() {
if (iniGetInt("Debugging", "HideObjIsNullMsg", 0, ::sfall::ddrawIni)) {
MakeJump(0x453FD2, dbg_error_hack);
}
// prints a debug message about missing art file for critters to both debug.log and the message window
// prints a debug message about missing art file for critters to both debug.log and the message window in sfall debugging mode
HookCall(0x419B65, art_data_size_hook);

// Fix to prevent crashes when there is a '%' character in the printed message
Expand Down
20 changes: 10 additions & 10 deletions sfall/Modules/Scripting/Handlers/Anims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,18 @@ bool checkCombatMode() {
return (regAnimCombatCheck & fo::var::combat_state) != 0;
}

void sf_reg_anim_combat_check(OpcodeContext& ctx) {
void op_reg_anim_combat_check(OpcodeContext& ctx) {
RegAnimCombatCheck(ctx.arg(0).rawValue());
}

void sf_reg_anim_destroy(OpcodeContext& ctx) {
void op_reg_anim_destroy(OpcodeContext& ctx) {
if (!checkCombatMode()) {
auto obj = ctx.arg(0).object();
fo::func::register_object_must_erase(obj);
}
}

void sf_reg_anim_animate_and_hide(OpcodeContext& ctx) {
void op_reg_anim_animate_and_hide(OpcodeContext& ctx) {
if (!checkCombatMode()) {
auto obj = ctx.arg(0).object();
int animId = ctx.arg(1).rawValue(),
Expand All @@ -72,7 +72,7 @@ void sf_reg_anim_animate_and_hide(OpcodeContext& ctx) {
}
}

void sf_reg_anim_light(OpcodeContext& ctx) {
void op_reg_anim_light(OpcodeContext& ctx) {
if (!checkCombatMode()) {
auto obj = ctx.arg(0).object();
int radius = ctx.arg(1).rawValue(),
Expand All @@ -87,7 +87,7 @@ void sf_reg_anim_light(OpcodeContext& ctx) {
}
}

void sf_reg_anim_change_fid(OpcodeContext& ctx) {
void op_reg_anim_change_fid(OpcodeContext& ctx) {
if (!checkCombatMode()) {
auto obj = ctx.arg(0).object();
int fid = ctx.arg(1).rawValue(),
Expand All @@ -97,7 +97,7 @@ void sf_reg_anim_change_fid(OpcodeContext& ctx) {
}
}

void sf_reg_anim_take_out(OpcodeContext& ctx) {
void op_reg_anim_take_out(OpcodeContext& ctx) {
if (!checkCombatMode()) {
auto obj = ctx.arg(0).object();
int holdFrame = ctx.arg(1).rawValue(),
Expand All @@ -107,7 +107,7 @@ void sf_reg_anim_take_out(OpcodeContext& ctx) {
}
}

void sf_reg_anim_turn_towards(OpcodeContext& ctx) {
void op_reg_anim_turn_towards(OpcodeContext& ctx) {
if (!checkCombatMode()) {
auto obj = ctx.arg(0).object();
int tile = ctx.arg(1).rawValue(),
Expand All @@ -124,7 +124,7 @@ static void __declspec(naked) ExecuteCallback() {
}
}

void sf_reg_anim_callback(OpcodeContext& ctx) {
void op_reg_anim_callback(OpcodeContext& ctx) {
fo::func::register_object_call(
reinterpret_cast<long*>(ctx.program()),
reinterpret_cast<long*>(ctx.arg(0).rawValue()), // callback procedure
Expand All @@ -133,7 +133,7 @@ void sf_reg_anim_callback(OpcodeContext& ctx) {
);
}

void sf_explosions_metarule(OpcodeContext& ctx) {
void op_explosions_metarule(OpcodeContext& ctx) {
int mode = ctx.arg(0).rawValue(),
result = ExplosionsMetaruleFunc(mode, ctx.arg(1).rawValue(), ctx.arg(2).rawValue());

Expand All @@ -143,7 +143,7 @@ void sf_explosions_metarule(OpcodeContext& ctx) {
ctx.setReturn(result);
}

void sf_art_cache_flush(OpcodeContext& ctx) {
void mf_art_cache_flush(OpcodeContext& ctx) {
__asm call fo::funcoffs::art_flush_;
}

Expand Down
24 changes: 12 additions & 12 deletions sfall/Modules/Scripting/Handlers/Anims.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ void RegAnimCombatCheck(DWORD newValue);

class OpcodeContext;

void sf_reg_anim_combat_check(OpcodeContext&);
void sf_reg_anim_destroy(OpcodeContext&);
void sf_reg_anim_animate_and_hide(OpcodeContext&);
void sf_reg_anim_light(OpcodeContext&);
void sf_reg_anim_change_fid(OpcodeContext&);
void sf_reg_anim_take_out(OpcodeContext&);
void sf_reg_anim_turn_towards(OpcodeContext&);
void sf_reg_anim_callback(OpcodeContext&);

void sf_explosions_metarule(OpcodeContext&);

void sf_art_cache_flush(OpcodeContext&);
void op_reg_anim_combat_check(OpcodeContext&);
void op_reg_anim_destroy(OpcodeContext&);
void op_reg_anim_animate_and_hide(OpcodeContext&);
void op_reg_anim_light(OpcodeContext&);
void op_reg_anim_change_fid(OpcodeContext&);
void op_reg_anim_take_out(OpcodeContext&);
void op_reg_anim_turn_towards(OpcodeContext&);
void op_reg_anim_callback(OpcodeContext&);

void op_explosions_metarule(OpcodeContext&);

void mf_art_cache_flush(OpcodeContext&);

}
}
34 changes: 17 additions & 17 deletions sfall/Modules/Scripting/Handlers/Arrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ namespace sfall
namespace script
{

void sf_create_array(OpcodeContext& ctx) {
void op_create_array(OpcodeContext& ctx) {
auto arrayId = CreateArray(ctx.arg(0).rawValue(), ctx.arg(1).rawValue());
ctx.setReturn(arrayId);
}

void sf_set_array(OpcodeContext& ctx) {
void op_set_array(OpcodeContext& ctx) {
SetArray(
ctx.arg(0).rawValue(),
ctx.arg(1),
Expand All @@ -47,7 +47,7 @@ void sf_set_array(OpcodeContext& ctx) {
so it works as get_array if first argument is int and as substr(x, y, 1) if first argument is string
example: vartext[5]
*/
void sf_get_array(OpcodeContext& ctx) {
void op_get_array(OpcodeContext& ctx) {
if (ctx.arg(0).isInt()) {
ctx.setReturn(
GetArray(ctx.arg(0).rawValue(), ctx.arg(1))
Expand All @@ -70,54 +70,54 @@ void sf_get_array(OpcodeContext& ctx) {
}
}

void sf_free_array(OpcodeContext& ctx) {
void op_free_array(OpcodeContext& ctx) {
FreeArray(ctx.arg(0).rawValue());
}

void sf_len_array(OpcodeContext& ctx) {
void op_len_array(OpcodeContext& ctx) {
ctx.setReturn(
LenArray(ctx.arg(0).rawValue())
);
}

void sf_resize_array(OpcodeContext& ctx) {
void op_resize_array(OpcodeContext& ctx) {
if (ResizeArray(ctx.arg(0).rawValue(), ctx.arg(1).rawValue())) {
ctx.printOpcodeError("%s() - array sorting error.", ctx.getOpcodeName());
}
}

void sf_temp_array(OpcodeContext& ctx) {
void op_temp_array(OpcodeContext& ctx) {
auto arrayId = TempArray(ctx.arg(0).rawValue(), ctx.arg(1).rawValue());
ctx.setReturn(arrayId);
}

void sf_fix_array(OpcodeContext& ctx) {
void op_fix_array(OpcodeContext& ctx) {
FixArray(ctx.arg(0).rawValue());
}

void sf_scan_array(OpcodeContext& ctx) {
void op_scan_array(OpcodeContext& ctx) {
ctx.setReturn(
ScanArray(ctx.arg(0).rawValue(), ctx.arg(1))
);
}

void sf_save_array(OpcodeContext& ctx) {
void op_save_array(OpcodeContext& ctx) {
SaveArray(ctx.arg(0), ctx.arg(1).rawValue());
}

void sf_load_array(OpcodeContext& ctx) {
void op_load_array(OpcodeContext& ctx) {
ctx.setReturn(
LoadArray(ctx.arg(0))
);
}

void sf_get_array_key(OpcodeContext& ctx) {
void op_get_array_key(OpcodeContext& ctx) {
ctx.setReturn(
GetArrayKey(ctx.arg(0).rawValue(), ctx.arg(1).rawValue())
);
}

void sf_stack_array(OpcodeContext& ctx) {
void op_stack_array(OpcodeContext& ctx) {
ctx.setReturn(
StackArray(ctx.arg(0), ctx.arg(1))
);
Expand Down Expand Up @@ -203,7 +203,7 @@ static DWORD ListAsArray(DWORD type) {
return id;
}

void sf_list_as_array(OpcodeContext& ctx) {
void op_list_as_array(OpcodeContext& ctx) {
auto arrayId = ListAsArray(ctx.arg(0).rawValue());
ctx.setReturn(arrayId);
}
Expand All @@ -216,15 +216,15 @@ static DWORD ListBegin(DWORD type) {
return listID;
}

void sf_list_begin(OpcodeContext& ctx) {
void op_list_begin(OpcodeContext& ctx) {
ctx.setReturn(ListBegin(ctx.arg(0).rawValue()));
}

static fo::GameObject* ListNext(sList* list) {
return (!list || list->pos == list->len) ? 0 : list->obj[list->pos++];
}

void sf_list_next(OpcodeContext& ctx) {
void op_list_next(OpcodeContext& ctx) {
fo::GameObject* obj = nullptr;
auto id = ctx.arg(0).rawValue();
if (id != 0) {
Expand Down Expand Up @@ -252,7 +252,7 @@ static void ListEnd(DWORD id) {
}
}

void sf_list_end(OpcodeContext& ctx) {
void op_list_end(OpcodeContext& ctx) {
ListEnd(ctx.arg(0).rawValue());
}

Expand Down
34 changes: 17 additions & 17 deletions sfall/Modules/Scripting/Handlers/Arrays.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,43 +23,43 @@ namespace sfall
namespace script
{

void sf_create_array(OpcodeContext&);
void op_create_array(OpcodeContext&);

void sf_set_array(OpcodeContext&);
void op_set_array(OpcodeContext&);

/*
used in place of [] operator when compiling in sslc
so it works as get_array if first argument is int and as substr(x, y, 1) if first argument is string
*/
void sf_get_array(OpcodeContext&);
void op_get_array(OpcodeContext&);

void sf_free_array(OpcodeContext&);
void op_free_array(OpcodeContext&);

void sf_len_array(OpcodeContext&);
void op_len_array(OpcodeContext&);

void sf_resize_array(OpcodeContext&);
void op_resize_array(OpcodeContext&);

void sf_temp_array(OpcodeContext&);
void op_temp_array(OpcodeContext&);

void sf_fix_array(OpcodeContext&);
void op_fix_array(OpcodeContext&);

void sf_scan_array(OpcodeContext&);
void op_scan_array(OpcodeContext&);

void sf_save_array(OpcodeContext&);
void op_save_array(OpcodeContext&);

void sf_load_array(OpcodeContext&);
void op_load_array(OpcodeContext&);

void sf_get_array_key(OpcodeContext&);
void op_get_array_key(OpcodeContext&);

void sf_stack_array(OpcodeContext&);
void op_stack_array(OpcodeContext&);

void sf_list_begin(OpcodeContext&);
void op_list_begin(OpcodeContext&);

void sf_list_as_array(OpcodeContext&);
void op_list_as_array(OpcodeContext&);

void sf_list_next(OpcodeContext&);
void op_list_next(OpcodeContext&);

void sf_list_end(OpcodeContext&);
void op_list_end(OpcodeContext&);

}
}
Loading

0 comments on commit ea921aa

Please sign in to comment.