mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Replace adjust_fid engine function with C++ implementation
This commit is contained in:
@@ -34,6 +34,7 @@ WRAP_WATCOM_FUNC2(long, db_fwriteInt, DbFile*, file, long, value)
|
|||||||
WRAP_WATCOM_FUNC2(long, combat_turn, GameObject*, critter, long, isDudeTurn)
|
WRAP_WATCOM_FUNC2(long, combat_turn, GameObject*, critter, long, isDudeTurn)
|
||||||
WRAP_WATCOM_FUNC1(long, gmouse_set_cursor, long, picNum)
|
WRAP_WATCOM_FUNC1(long, gmouse_set_cursor, long, picNum)
|
||||||
WRAP_WATCOM_FUNC1(Window*, GNW_find, long, winRef)
|
WRAP_WATCOM_FUNC1(Window*, GNW_find, long, winRef)
|
||||||
|
WRAP_WATCOM_FUNC0(long, intface_is_item_right_hand)
|
||||||
WRAP_WATCOM_FUNC0(void, intface_toggle_item_state)
|
WRAP_WATCOM_FUNC0(void, intface_toggle_item_state)
|
||||||
WRAP_WATCOM_FUNC0(void, intface_use_item)
|
WRAP_WATCOM_FUNC0(void, intface_use_item)
|
||||||
WRAP_WATCOM_FUNC1(long, item_w_max_ammo, GameObject*, item)
|
WRAP_WATCOM_FUNC1(long, item_w_max_ammo, GameObject*, item)
|
||||||
|
|||||||
@@ -63,10 +63,10 @@ VAR_(holo_flag, DWORD)
|
|||||||
VAR_(holopages, DWORD)
|
VAR_(holopages, DWORD)
|
||||||
VAR_(hot_line_count, DWORD)
|
VAR_(hot_line_count, DWORD)
|
||||||
VAR_(i_fid, DWORD)
|
VAR_(i_fid, DWORD)
|
||||||
VAR_(i_lhand, DWORD)
|
VAR_(i_lhand, GameObject*)
|
||||||
VAR_(i_rhand, DWORD)
|
VAR_(i_rhand, GameObject*)
|
||||||
VAR_(i_wid, DWORD)
|
VAR_(i_wid, DWORD)
|
||||||
VAR_(i_worn, DWORD)
|
VAR_(i_worn, GameObject*)
|
||||||
VAR_(idle_func, DWORD)
|
VAR_(idle_func, DWORD)
|
||||||
VAR_(In_WorldMap, DWORD)
|
VAR_(In_WorldMap, DWORD)
|
||||||
VAR_(info_line, DWORD)
|
VAR_(info_line, DWORD)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "..\main.h"
|
#include "..\main.h"
|
||||||
#include "..\FalloutEngine\Fallout2.h"
|
#include "..\FalloutEngine\Fallout2.h"
|
||||||
|
#include "Inventory.h"
|
||||||
#include "LoadGameHook.h"
|
#include "LoadGameHook.h"
|
||||||
#include "Message.h"
|
#include "Message.h"
|
||||||
#include "PartyControl.h"
|
#include "PartyControl.h"
|
||||||
@@ -395,23 +396,12 @@ static void __declspec(naked) AdjustHeroBaseArt() {
|
|||||||
|
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
//adjust armor art if num below hero art range
|
//adjust armor art if num below hero art range
|
||||||
static void __declspec(naked) AdjustHeroArmorArt() {
|
static void AdjustHeroArmorArt(DWORD fid) {
|
||||||
__asm {
|
if (!PartyControl::IsNpcControlled()) {
|
||||||
pop ebx //get ret addr
|
DWORD fidBase = fid & 0xFFF;
|
||||||
mov dword ptr ss:[esp], ebx //reinsert ret addr in old (push 0)
|
if (fidBase <= critterListSize) {
|
||||||
xor ebx, ebx
|
fo::var::i_fid += critterListSize;
|
||||||
push 0
|
}
|
||||||
call fo::funcoffs::art_id_ //call load frm func
|
|
||||||
cmp isControllingNPC, 1;
|
|
||||||
jz EndFunc;
|
|
||||||
mov dx, ax
|
|
||||||
and dh, 0xFF00 //mask out current weapon flag
|
|
||||||
cmp edx, critterListSize //check if critter art in PC range
|
|
||||||
jg EndFunc
|
|
||||||
add eax, critterListSize //shift critter art index up into hero range
|
|
||||||
EndFunc:
|
|
||||||
//mov dword ptr ds:[FO_VAR_i_fid],eax
|
|
||||||
ret
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1866,10 +1856,11 @@ void HeroAppearance::init() {
|
|||||||
if (GetConfigInt("Misc", "EnableHeroAppearanceMod", 0)) {
|
if (GetConfigInt("Misc", "EnableHeroAppearanceMod", 0)) {
|
||||||
dlog("Setting up Appearance Char Screen buttons.", DL_INIT);
|
dlog("Setting up Appearance Char Screen buttons.", DL_INIT);
|
||||||
EnableHeroAppearanceMod();
|
EnableHeroAppearanceMod();
|
||||||
dlogr(" Done", DL_INIT);
|
|
||||||
|
|
||||||
LoadGameHook::OnAfterNewGame() += SetNewCharAppearanceGlobals;
|
LoadGameHook::OnAfterNewGame() += SetNewCharAppearanceGlobals;
|
||||||
LoadGameHook::OnAfterGameStarted() += LoadHeroAppearance;
|
LoadGameHook::OnAfterGameStarted() += LoadHeroAppearance;
|
||||||
|
Inventory::OnAdjustFid() += AdjustHeroArmorArt;
|
||||||
|
dlogr(" Done", DL_INIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
namespace sfall
|
namespace sfall
|
||||||
{
|
{
|
||||||
|
|
||||||
|
static Delegate<DWORD> onAdjustFid;
|
||||||
|
|
||||||
static DWORD mode;
|
static DWORD mode;
|
||||||
static DWORD maxItemSize;
|
static DWORD maxItemSize;
|
||||||
static DWORD reloadWeaponKey = 0;
|
static DWORD reloadWeaponKey = 0;
|
||||||
@@ -606,6 +608,56 @@ void __declspec(naked) ItemCountFix() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// reimplementation adjust_fid engine function
|
||||||
|
DWORD __stdcall adjust_fid_replacement2() {
|
||||||
|
using namespace fo;
|
||||||
|
|
||||||
|
DWORD fid;
|
||||||
|
if ((var::inven_dude->artFid & 0xF000000) >> 24 == OBJ_TYPE_CRITTER) {
|
||||||
|
DWORD frameNum = var::art_vault_guy_num;
|
||||||
|
DWORD weaponAnimCode = 0;
|
||||||
|
auto critterPro = GetProto(var::inven_pid);
|
||||||
|
if (critterPro != nullptr) {
|
||||||
|
frameNum = critterPro->fid & 0xFFF;
|
||||||
|
}
|
||||||
|
if (var::i_worn != nullptr) {
|
||||||
|
auto armorPro = GetProto(var::i_worn->protoId);
|
||||||
|
frameNum = func::stat_level(var::inven_dude, STAT_gender) == GENDER_FEMALE
|
||||||
|
? armorPro->item.armor.femaleFid
|
||||||
|
: armorPro->item.armor.maleFid;
|
||||||
|
if (frameNum == -1) {
|
||||||
|
frameNum = var::art_vault_guy_num;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto itemInHand = func::intface_is_item_right_hand()
|
||||||
|
? var::i_rhand
|
||||||
|
: var::i_lhand;
|
||||||
|
|
||||||
|
if (itemInHand != nullptr) {
|
||||||
|
auto itemPro = GetProto(itemInHand->protoId);
|
||||||
|
if (itemPro->item.type == item_type_weapon) {
|
||||||
|
weaponAnimCode = itemPro->item.weapon.animationCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fid = func::art_id(OBJ_TYPE_CRITTER, frameNum, 0, weaponAnimCode, 0);
|
||||||
|
} else {
|
||||||
|
fid = var::inven_dude->artFid;
|
||||||
|
}
|
||||||
|
var::i_fid = fid;
|
||||||
|
onAdjustFid.invoke(fid);
|
||||||
|
return var::i_fid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void __declspec(naked) adjust_fid_replacement() {
|
||||||
|
__asm {
|
||||||
|
pushad;
|
||||||
|
call adjust_fid_replacement2;
|
||||||
|
popad;
|
||||||
|
mov eax, [FO_VAR_i_fid];
|
||||||
|
retn;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void InventoryReset() {
|
void InventoryReset() {
|
||||||
invenapcost = GetConfigInt("Misc", "InventoryApCost", 4);
|
invenapcost = GetConfigInt("Misc", "InventoryApCost", 4);
|
||||||
}
|
}
|
||||||
@@ -614,6 +666,8 @@ void Inventory::init() {
|
|||||||
OnKeyPressed() += InventoryKeyPressedHook;
|
OnKeyPressed() += InventoryKeyPressedHook;
|
||||||
LoadGameHook::OnGameReset() += InventoryReset;
|
LoadGameHook::OnGameReset() += InventoryReset;
|
||||||
|
|
||||||
|
MakeJump(fo::funcoffs::adjust_fid_, adjust_fid_replacement);
|
||||||
|
|
||||||
mode = GetConfigInt("Misc", "CritterInvSizeLimitMode", 0);
|
mode = GetConfigInt("Misc", "CritterInvSizeLimitMode", 0);
|
||||||
invenapcost = GetConfigInt("Misc", "InventoryApCost", 4);
|
invenapcost = GetConfigInt("Misc", "InventoryApCost", 4);
|
||||||
invenapqpreduction = GetConfigInt("Misc", "QuickPocketsApCostReduction", 2);
|
invenapqpreduction = GetConfigInt("Misc", "QuickPocketsApCostReduction", 2);
|
||||||
@@ -687,4 +741,10 @@ void Inventory::init() {
|
|||||||
MakeJump(0x47808C, ItemCountFix); // replacing item_count_ function
|
MakeJump(0x47808C, ItemCountFix); // replacing item_count_ function
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Delegate<DWORD>& Inventory::OnAdjustFid() {
|
||||||
|
return onAdjustFid;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,14 +18,19 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "Delegate.h"
|
||||||
#include "Module.h"
|
#include "Module.h"
|
||||||
|
|
||||||
namespace sfall
|
namespace sfall
|
||||||
{
|
{
|
||||||
|
|
||||||
class Inventory : public Module {
|
class Inventory : public Module {
|
||||||
|
public:
|
||||||
const char* name() { return "Inventory"; }
|
const char* name() { return "Inventory"; }
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
|
// Called after game calculated dude FID for displaying on inventory screen
|
||||||
|
static Delegate<DWORD>& OnAdjustFid();
|
||||||
};
|
};
|
||||||
|
|
||||||
void _stdcall SetInvenApCost(int a);
|
void _stdcall SetInvenApCost(int a);
|
||||||
|
|||||||
Reference in New Issue
Block a user