mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Added missing sounds for the buttons on the world map interface (#373)
Changed the game speed tweak to be active only during the game.
This commit is contained in:
@@ -53,5 +53,9 @@ bool AIHelpers::AttackInRange(fo::GameObject* source, fo::GameObject* weapon, lo
|
||||
return (Items::item_weapon_range(source, weapon, fo::AttackType::ATKTYPE_RWEAPON_SECONDARY) >= distance);
|
||||
}
|
||||
|
||||
bool AIHelpers::AttackInRange(fo::GameObject* source, fo::GameObject* weapon, fo::GameObject* target) {
|
||||
return AIHelpers::AttackInRange(source, weapon, fo::func::obj_dist(source, target));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public:
|
||||
static fo::GameObject* CheckFriendlyFire(fo::GameObject* target, fo::GameObject* attacker);
|
||||
|
||||
static bool AttackInRange(fo::GameObject* source, fo::GameObject* weapon, long distance);
|
||||
static bool AttackInRange(fo::GameObject* source, fo::GameObject* weapon, fo::GameObject* target);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -249,7 +249,7 @@ static long __fastcall ai_try_attack_switch_fix(fo::GameObject* target, long &hi
|
||||
// is using a close range weapon?
|
||||
long wType = fo::func::item_w_subtype(item, fo::AttackType::ATKTYPE_RWEAPON_PRIMARY);
|
||||
if (wType <= fo::AttackSubType::MELEE) { // unarmed and melee weapons, check the distance before switching
|
||||
if (!game::ai::AIHelpers::AttackInRange(source, item, fo::func::obj_dist(source, target))) return -1; // target out of range, exit ai_try_attack_
|
||||
if (!game::ai::AIHelpers::AttackInRange(source, item, target)) return -1; // target out of range, exit ai_try_attack_
|
||||
}
|
||||
return 1; // all good, execute vanilla behavior of ai_switch_weapons_ function
|
||||
}
|
||||
|
||||
@@ -781,6 +781,20 @@ static void __declspec(naked) wmInterfaceRefreshCarFuel_hack() {
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) register_button() {
|
||||
static DWORD retAddr;
|
||||
__asm {
|
||||
pop retAddr;
|
||||
call fo::funcoffs::win_register_button_;
|
||||
push eax;
|
||||
mov ebx, fo::funcoffs::gsound_red_butt_release_;
|
||||
mov edx, fo::funcoffs::gsound_red_butt_press_;
|
||||
call fo::funcoffs::win_register_button_sound_func_;
|
||||
pop eax;
|
||||
jmp retAddr;
|
||||
}
|
||||
}
|
||||
|
||||
static void WorldMapInterfacePatch() {
|
||||
BlockCall(0x4C2380); // Remove disabling palette animations (can be used as a place to call a hack function in wmInterfaceInit_)
|
||||
|
||||
@@ -790,6 +804,14 @@ static void WorldMapInterfacePatch() {
|
||||
dlogr(" Done", DL_INIT);
|
||||
}
|
||||
|
||||
// Add missing sounds for the buttons on the world map interface (wmInterfaceInit_)
|
||||
HookCalls(register_button, {
|
||||
0x4C2BF4, // location labels
|
||||
0x4C2BB5, // town/world
|
||||
0x4C2D4C, // up
|
||||
0x4C2D8A // down
|
||||
});
|
||||
|
||||
// Fix images for up/down buttons
|
||||
SafeWrite32(0x4C2C0A, 199); // index of UPARWOFF.FRM
|
||||
SafeWrite8(0x4C2C7C, 0x43); // dec ebx > inc ebx
|
||||
|
||||
@@ -47,13 +47,14 @@ static const DWORD offsets[] = {
|
||||
// 0x4F482B, // unused
|
||||
0x4FE036, // unused???
|
||||
|
||||
// for MVE
|
||||
// Affect the playback speed of MVE video files without an audio track
|
||||
// 0x4F4E53, // syncWait_
|
||||
// 0x4F5542, // syncInit_
|
||||
// 0x4F56CC, 0x4F59C6, // MVE_syncSync_
|
||||
};
|
||||
|
||||
static DWORD getLocalTimeOffs;
|
||||
|
||||
DWORD SpeedPatch::getTickCountOffs = (DWORD)&GetTickCount;
|
||||
|
||||
DWORD SpeedPatch::getTickCount() {
|
||||
@@ -129,7 +130,7 @@ static DWORD __stdcall FakeGetTickCount() {
|
||||
|
||||
// Multiply the tick count difference by the multiplier
|
||||
long mode = GetLoopFlags();
|
||||
if (enabled && (!mode || (mode & (LoopFlag::WORLDMAP | LoopFlag::PCOMBAT | LoopFlag::COMBAT))) && !slideShow) {
|
||||
if (IsGameLoaded() && enabled && (!mode || (mode & (LoopFlag::WORLDMAP | LoopFlag::PCOMBAT | LoopFlag::COMBAT))) && !slideShow) {
|
||||
elapsed *= multi;
|
||||
elapsed += tickCountFraction;
|
||||
tickCountFraction = modf(elapsed, &elapsed);
|
||||
@@ -216,17 +217,12 @@ void SpeedPatch::init() {
|
||||
getTickCountOffs = (DWORD)&FakeGetTickCount;
|
||||
getLocalTimeOffs = (DWORD)&FakeGetLocalTime;
|
||||
|
||||
int size = sizeof(offsets) / 4;
|
||||
// Affect the playback speed of MVE video files without an audio track
|
||||
//if (IniReader::GetConfigInt("Speed", "AffectPlayback", 0) == 0) size -= 4;
|
||||
|
||||
for (int i = 0; i < size; i++) {
|
||||
for (int i = 0; i < sizeof(offsets) / 4; i++) {
|
||||
SafeWrite32(offsets[i], (DWORD)&getTickCountOffs);
|
||||
}
|
||||
SafeWrite32(0x4FDF58, (DWORD)&getLocalTimeOffs);
|
||||
HookCall(0x4A433E, scripts_check_state_hook);
|
||||
|
||||
SetKeyboardDelay();
|
||||
TimerInit();
|
||||
dlogr(" Done", DL_INIT);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user