mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Replaced HRP addresses with the define values
Refactored get_attack_type opcode.
This commit is contained in:
@@ -625,6 +625,26 @@ TGameObj* GetActiveItem() {
|
||||
return ptr_itemButtonItems[*ptr_itemCurrentItem].item;
|
||||
}
|
||||
|
||||
long GetCurrentAttackMode() {
|
||||
long hitMode = -1;
|
||||
if (*ptr_interfaceWindow != -1) {
|
||||
long activeHand = *ptr_itemCurrentItem; // 0 - left, 1 - right
|
||||
switch (ptr_itemButtonItems[activeHand].mode) {
|
||||
case 1:
|
||||
case 2: // called shot
|
||||
hitMode = ptr_itemButtonItems[activeHand].primaryAttack;
|
||||
break;
|
||||
case 3:
|
||||
case 4: // called shot
|
||||
hitMode = ptr_itemButtonItems[activeHand].secondaryAttack;
|
||||
break;
|
||||
case 5: // reload mode
|
||||
hitMode = ATKTYPE_LWEAPON_RELOAD + activeHand;
|
||||
}
|
||||
}
|
||||
return hitMode;
|
||||
}
|
||||
|
||||
AttackSubType GetWeaponType(DWORD weaponFlag) {
|
||||
static const AttackSubType weapon_types[9] = {
|
||||
ATKSUBTYPE_NONE,
|
||||
|
||||
@@ -346,6 +346,16 @@
|
||||
#define FO_VAR_WhiteColor 0x6AB8CF
|
||||
#define FO_VAR_YellowColor 0x6AB8BB // Light
|
||||
|
||||
// HRP offsets
|
||||
#define HRP_VAR_disp_width 0x1006EB70
|
||||
#define HRP_VAR_display_string_buf 0x10068708
|
||||
|
||||
#define HRP_VAR_FOG_OF_WAR 0x100683D4
|
||||
#define HRP_VAR_MOVIE_SIZE 0x1006EC10
|
||||
#define HRP_VAR_IFACE_BAR_MODE 0x1006EB0C
|
||||
#define HRP_VAR_HR_IFACE_FRM_STR 0x10039358
|
||||
#define HRP_VAR_VERSION_STR 0x10039940
|
||||
|
||||
// Global variable pointers
|
||||
// TODO: move to separate namespace
|
||||
|
||||
@@ -555,6 +565,8 @@ long& GetActiveItemMode();
|
||||
|
||||
TGameObj* GetActiveItem();
|
||||
|
||||
long GetCurrentAttackMode();
|
||||
|
||||
AttackSubType GetWeaponType(DWORD weaponFlag);
|
||||
|
||||
bool HeroIsFemale();
|
||||
|
||||
@@ -220,45 +220,14 @@ end:
|
||||
}
|
||||
}
|
||||
|
||||
static void __stdcall intface_attack_type() {
|
||||
__asm {
|
||||
sub esp, 8;
|
||||
lea edx, [esp];
|
||||
lea eax, [esp + 4];
|
||||
call intface_get_attack_;
|
||||
pop edx; // is_secondary
|
||||
pop ecx; // hit_mode
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) op_get_attack_type() {
|
||||
__asm {
|
||||
push edx;
|
||||
push ecx;
|
||||
push eax;
|
||||
call intface_attack_type;
|
||||
mov edx, ecx; // hit_mode
|
||||
test eax, eax;
|
||||
jz skip;
|
||||
// get reload
|
||||
cmp ds:[FO_VAR_interfaceWindow], eax;
|
||||
jz end;
|
||||
mov ecx, ds:[FO_VAR_itemCurrentItem]; // 0 - left, 1 - right
|
||||
imul edx, ecx, 0x18;
|
||||
cmp ds:[FO_VAR_itemButtonItems + 5 + edx], 1; // .itsWeapon
|
||||
jnz end;
|
||||
lea eax, [ecx + 6];
|
||||
end:
|
||||
mov edx, eax; // result
|
||||
skip:
|
||||
pop ecx;
|
||||
mov eax, ecx;
|
||||
call interpretPushLong_;
|
||||
mov eax, ecx;
|
||||
mov edx, VAR_TYPE_INT;
|
||||
call interpretPushShort_;
|
||||
pop ecx;
|
||||
pop edx;
|
||||
mov esi, ecx;
|
||||
call GetCurrentAttackMode;
|
||||
mov edx, eax;
|
||||
mov eax, ebx;
|
||||
_RET_VAL_INT;
|
||||
mov ecx, esi;
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -85,7 +85,7 @@ bool hrpVersionValid = false; // HRP 4.1.8 version validation
|
||||
static DWORD hrpDLLBaseAddr = 0x10000000;
|
||||
|
||||
DWORD HRPAddress(DWORD addr) {
|
||||
return (hrpDLLBaseAddr + (addr & 0xFFFFF));
|
||||
return (hrpDLLBaseAddr | (addr & 0xFFFFF));
|
||||
}
|
||||
|
||||
char falloutConfigName[65] = {0};
|
||||
@@ -241,9 +241,9 @@ static void InitModules() {
|
||||
|
||||
static void __stdcall OnExit() {
|
||||
Graphics_Exit();
|
||||
EngineTweaks_Exit();
|
||||
//EngineTweaks_Exit();
|
||||
Books_Exit();
|
||||
Movies_Exit();
|
||||
//Movies_Exit();
|
||||
Interface_Exit();
|
||||
SpeedPatch_Exit();
|
||||
Skills_Exit();
|
||||
@@ -253,7 +253,7 @@ static void __stdcall OnExit() {
|
||||
Console_Exit();
|
||||
ExtraSaveSlots_Exit();
|
||||
Message_Exit();
|
||||
Animations_Exit();
|
||||
//Animations_Exit();
|
||||
BarBoxes_Exit();
|
||||
HeroAppearance_Exit();
|
||||
MiscPatches_Exit();
|
||||
|
||||
+10
-2
@@ -78,9 +78,17 @@ struct ddrawDll {
|
||||
#define pushadc __asm push eax __asm push edx __asm push ecx
|
||||
#define popadc __asm pop ecx __asm pop edx __asm pop eax
|
||||
|
||||
DWORD HRPAddress(DWORD addr);
|
||||
|
||||
extern bool hrpIsEnabled;
|
||||
extern bool hrpVersionValid;
|
||||
|
||||
extern char falloutConfigName[65];
|
||||
|
||||
DWORD HRPAddress(DWORD addr);
|
||||
|
||||
__inline long GetIntHRPValue(DWORD addr) {
|
||||
return *reinterpret_cast<DWORD*>(HRPAddress(addr));
|
||||
}
|
||||
|
||||
__inline char GetByteHRPValue(DWORD addr) {
|
||||
return *reinterpret_cast<BYTE*>(HRPAddress(addr));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user