Added a new argument to HOOK_ADJUSTFID.

Fixed incorrect FRM being displayed for opened bag/backpack in the
inventory when Hero Appearance Mod is enabled (#262)

Fixed MainMenuFontColour not changing the font color for the copyright
text on the main menu (#261)

Code correction in main.cpp.
This commit is contained in:
NovaRain
2019-08-22 13:12:32 +08:00
parent 9fea48093e
commit 477ff9668c
8 changed files with 41 additions and 35 deletions
+1 -1
View File
@@ -503,7 +503,7 @@ RemoveCriticalTimelimits=0
;Set to 1 to enable party members with level 6 protos to reach level 6 ;Set to 1 to enable party members with level 6 protos to reach level 6
NPCStage6Fix=0 NPCStage6Fix=0
;Change the colour of the font used on the main menu for the Fallout/sfall version number ;Change the colour of the font used on the main menu for the Fallout/sfall version number and copyright text
;It's the last byte ('3c' by default) that picks the colour used. The first byte supplies additional flags ;It's the last byte ('3c' by default) that picks the colour used. The first byte supplies additional flags
;MainMenuFontColour=0x0600003c ;MainMenuFontColour=0x0600003c
+2 -1
View File
@@ -452,7 +452,8 @@ Also happens on other screens, like barter.
NOTE: FID has following format: 0x0ABBCDDD, where A is object type, BB - animation code (always 0 in this case), C - weapon code, DDD - FRM index in LST file. NOTE: FID has following format: 0x0ABBCDDD, where A is object type, BB - animation code (always 0 in this case), C - weapon code, DDD - FRM index in LST file.
int arg1 - the vanilla fid calculated by the engine according to critter base FID and armor/weapon being used int arg1 - the vanilla FID calculated by the engine according to critter base FID and armor/weapon being used
int arg2 - the modified FID calculated by the internal sfall code (like Hero Appearance Mod)
int ret1 - overrides the calculated FID with provided value int ret1 - overrides the calculated FID with provided value
+9 -9
View File
@@ -63,7 +63,7 @@ typedef struct LineNode {
} }
} LineNode; } LineNode;
/////////////////////////////////////////////////////////////////TEXT FUNCTIONS//////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////TEXT FUNCTIONS//////////////////////////////////////////////////////////////////////
static void SetFont(long ref) { static void SetFont(long ref) {
fo::func::text_font(ref); fo::func::text_font(ref);
@@ -141,7 +141,7 @@ static void DeleteWordWrapList(LineNode *CurrentLine) {
} }
} }
/////////////////////////////////////////////////////////////////DAT FUNCTIONS//////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////DAT FUNCTIONS///////////////////////////////////////////////////////////////////////
static void* LoadDat(char*fileName) { static void* LoadDat(char*fileName) {
return fo::func::dbase_open(fileName); return fo::func::dbase_open(fileName);
@@ -151,7 +151,7 @@ static void UnloadDat(void *dat) {
fo::func::dbase_close(dat); fo::func::dbase_close(dat);
} }
/////////////////////////////////////////////////////////////////OTHER FUNCTIONS//////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////OTHER FUNCTIONS/////////////////////////////////////////////////////////////////////
static DWORD BuildFrmId(DWORD lstRef, DWORD lstNum) { static DWORD BuildFrmId(DWORD lstRef, DWORD lstNum) {
return fo::func::art_id(lstRef, lstNum, 0, 0, 0); return fo::func::art_id(lstRef, lstNum, 0, 0, 0);
@@ -164,7 +164,7 @@ static void PlayAcm(char *acmName) {
} }
} }
/////////////////////////////////////////////////////////////////APP MOD FUNCTIONS//////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////APP MOD FUNCTIONS///////////////////////////////////////////////////////////////////
static char GetSex() { static char GetSex() {
return (fo::HeroIsFemale()) ? 'F' : 'M'; return (fo::HeroIsFemale()) ? 'F' : 'M';
@@ -275,7 +275,7 @@ 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 AdjustHeroArmorArt(DWORD fid) { static void AdjustHeroArmorArt(DWORD fid) {
if (!PartyControl::IsNpcControlled()) { if ((fid & 0xF000000) == (fo::OBJ_TYPE_CRITTER << 24) && !PartyControl::IsNpcControlled()) {
DWORD fidBase = fid & 0xFFF; DWORD fidBase = fid & 0xFFF;
if (fidBase <= critterListSize) { if (fidBase <= critterListSize) {
fo::var::i_fid += critterListSize; fo::var::i_fid += critterListSize;
@@ -349,7 +349,7 @@ static long _stdcall AddHeroCritNames() { // art_init_
return critterArt.total; return critterArt.total;
} }
///////////////////////////////////////////////////////////////GRAPHICS HERO FUNCTIONS////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////GRAPHICS HERO FUNCTIONS///////////////////////////////////////////////////////////////
static void DrawPC() { static void DrawPC() {
fo::RedrawObject(fo::var::obj_dude); fo::RedrawObject(fo::var::obj_dude);
@@ -479,7 +479,7 @@ endFunc:
} }
} }
/////////////////////////////////////////////////////////////////INTERFACE FUNCTIONS/////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////INTERFACE FUNCTIONS/////////////////////////////////////////////////////////////////
static void sub_draw(long subWidth, long subHeight, long fromWidth, long fromHeight, long fromX, long fromY, BYTE *fromBuff, static void sub_draw(long subWidth, long subHeight, long fromWidth, long fromHeight, long fromX, long fromY, BYTE *fromBuff,
long toWidth, long toHeight, long toX, long toY, BYTE *toBuff, int maskRef) { long toWidth, long toHeight, long toX, long toY, BYTE *toBuff, int maskRef) {
@@ -1263,7 +1263,7 @@ static void __declspec(naked) CharScrnEnd() {
} }
} }
//////////////////////////////////////////////////////////////////////FIX FUNCTIONS//////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////FIX FUNCTIONS//////////////////////////////////////////////////////////////////
// Adjust PC SFX acm name. Skip Underscore char at the start of PC App Name // Adjust PC SFX acm name. Skip Underscore char at the start of PC App Name
static void __declspec(naked) FixPcSFX() { static void __declspec(naked) FixPcSFX() {
@@ -1323,7 +1323,7 @@ skip:
} }
} }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Load Appearance data from GCD file // Load Appearance data from GCD file
static void __fastcall LoadGCDAppearance(fo::DbFile* fileStream) { static void __fastcall LoadGCDAppearance(fo::DbFile* fileStream) {
+3 -2
View File
@@ -432,8 +432,9 @@ void AdjustFidHook(DWORD vanillaFid) {
if (!HookScripts::HookHasScript(HOOK_ADJUSTFID)) return; if (!HookScripts::HookHasScript(HOOK_ADJUSTFID)) return;
BeginHook(); BeginHook();
argCount = 1; argCount = 2;
args[0] = vanillaFid; args[0] = vanillaFid;
args[1] = fo::var::i_fid; // modified FID by sfall code
RunHookScript(HOOK_ADJUSTFID); RunHookScript(HOOK_ADJUSTFID);
if (cRet > 0) { if (cRet > 0) {
fo::var::i_fid = rets[0]; fo::var::i_fid = rets[0];
@@ -502,7 +503,7 @@ void InitInventoryHookScripts() {
LoadHookScript("hs_invenwield", HOOK_INVENWIELD); LoadHookScript("hs_invenwield", HOOK_INVENWIELD);
LoadHookScript("hs_adjustfid", HOOK_ADJUSTFID); LoadHookScript("hs_adjustfid", HOOK_ADJUSTFID);
Inventory::OnAdjustFid() += AdjustFidHook; Inventory::OnAdjustFid() += AdjustFidHook; // should be registered last
} }
} }
-4
View File
@@ -26,8 +26,6 @@
namespace sfall namespace sfall
{ {
bool hrpIsEnabled = false;
static BYTE movePointBackground[16 * 9 * 5]; static BYTE movePointBackground[16 * 9 * 5];
static fo::UnlistedFrm* ifaceFrm = nullptr; static fo::UnlistedFrm* ifaceFrm = nullptr;
@@ -447,8 +445,6 @@ static void WorldMapInterfacePatch() {
} }
void Interface::init() { void Interface::init() {
hrpIsEnabled = (*(DWORD*)0x4E4480 != 0x278805C7); // check if HRP is enabled
if (GetConfigInt("Interface", "ActionPointsBar", 0)) { if (GetConfigInt("Interface", "ActionPointsBar", 0)) {
ActionPointsBarPatch(); ActionPointsBarPatch();
if (hrpIsEnabled) LoadGameHook::OnAfterGameInit() += APBarRectPatch; if (hrpIsEnabled) LoadGameHook::OnAfterGameInit() += APBarRectPatch;
+15 -13
View File
@@ -25,9 +25,17 @@
namespace sfall namespace sfall
{ {
#ifdef NDEBUG
static const char* VerString1 = "SFALL " VERSION_STRING;
#else
static const char* VerString1 = "SFALL " VERSION_STRING " Debug Build";
#endif
static DWORD MainMenuYOffset; static DWORD MainMenuYOffset;
static DWORD MainMenuTextOffset; static DWORD MainMenuTextOffset;
static long OverrideColour;
static const DWORD MainMenuButtonYHookRet = 0x48184A; static const DWORD MainMenuButtonYHookRet = 0x48184A;
static void __declspec(naked) MainMenuButtonYHook() { static void __declspec(naked) MainMenuButtonYHook() {
__asm { __asm {
@@ -45,23 +53,16 @@ static void __declspec(naked) MainMenuTextYHook() {
} }
} }
#ifdef NDEBUG
static const char* VerString1 = "SFALL " VERSION_STRING;
#else
static const char* VerString1 = "SFALL " VERSION_STRING " Debug Build";
#endif
static DWORD OverrideColour;
static void __declspec(naked) FontColour() { static void __declspec(naked) FontColour() {
__asm { __asm {
cmp OverrideColour, 0; cmp OverrideColour, 0;
je skip; jg override;
mov eax, OverrideColour;
retn;
skip:
movzx eax, byte ptr ds:[0x6A8B33]; movzx eax, byte ptr ds:[0x6A8B33];
or eax, 0x6000000; or eax, 0x6000000;
retn; retn;
override:
mov eax, OverrideColour;
retn;
} }
} }
@@ -121,8 +122,9 @@ void MainMenu::init() {
MakeJump(0x4817AB, MainMenuTextHook); MakeJump(0x4817AB, MainMenuTextHook);
OverrideColour = GetConfigInt("Misc", "MainMenuFontColour", 0); OverrideColour = GetConfigInt("Misc", "MainMenuFontColour", 0);
if (OverrideColour) { if (OverrideColour > 0) {
MakeCall(0x48174C, FontColour); OverrideColour |= 0x6000000;
SafeWrite32(0x481748, (DWORD)&OverrideColour);
} }
} }
+10 -5
View File
@@ -86,10 +86,12 @@ namespace sfall
{ {
bool isDebug = false; bool isDebug = false;
bool hrpIsEnabled = false;
const char ddrawIni[] = ".\\ddraw.ini"; const char ddrawIni[] = ".\\ddraw.ini";
static char ini[65] = ".\\"; static char ini[65] = ".\\";
static char translationIni[65]; static char translationIni[65];
DWORD modifiedIni; DWORD modifiedIni;
unsigned int GetConfigInt(const char* section, const char* setting, int defaultValue) { unsigned int GetConfigInt(const char* section, const char* setting, int defaultValue) {
@@ -144,6 +146,8 @@ static void InitModules() {
manager.add<LoadGameHook>(); manager.add<LoadGameHook>();
manager.add<MainLoopHook>(); manager.add<MainLoopHook>();
manager.add<Movies>(); manager.add<Movies>();
manager.add<MainMenu>();
manager.add<Interface>();
manager.add<Objects>(); manager.add<Objects>();
manager.add<PlayerModel>(); manager.add<PlayerModel>();
manager.add<Worldmap>(); manager.add<Worldmap>();
@@ -163,7 +167,6 @@ static void InitModules() {
manager.add<Console>(); manager.add<Console>();
manager.add<ExtraSaveSlots>(); manager.add<ExtraSaveSlots>();
manager.add<Inventory>(); manager.add<Inventory>();
manager.add<MainMenu>();
manager.add<Drugs>(); // should be loaded before PartyControl manager.add<Drugs>(); // should be loaded before PartyControl
manager.add<PartyControl>(); manager.add<PartyControl>();
manager.add<BurstMods>(); manager.add<BurstMods>();
@@ -172,7 +175,6 @@ static void InitModules() {
manager.add<Message>(); manager.add<Message>();
manager.add<Elevators>(); manager.add<Elevators>();
manager.add<KillCounter>(); manager.add<KillCounter>();
manager.add<Interface>();
// //
manager.add<AI>(); manager.add<AI>();
manager.add<DamageMod>(); manager.add<DamageMod>();
@@ -271,23 +273,26 @@ inline void SfallInit() {
} }
} }
if (cmdlineexists && strlen(cmdline)) { if (cmdlineexists && *cmdline != 0) {
HANDLE h = CreateFileA(cmdline, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0); HANDLE h = CreateFileA(cmdline, GENERIC_READ, 0, 0, OPEN_EXISTING, 0, 0);
if (h != INVALID_HANDLE_VALUE) { if (h != INVALID_HANDLE_VALUE) {
CloseHandle(h); CloseHandle(h);
strcat_s(ini, cmdline); strcat_s(ini, cmdline);
} else { } else {
MessageBox(0, "You gave a command line argument to fallout, but it couldn't be matched to a file\n" \ MessageBox(0, "You gave a command line argument to fallout, but it couldn't be matched to a file\n" \
"Using default ddraw.ini instead", "Warning", MB_TASKMODAL); "Using default ddraw.ini instead", "Warning", MB_TASKMODAL);
strcpy_s(ini, ::sfall::ddrawIni); goto defaultIni;
} }
} else { } else {
defaultIni:
strcpy_s(ini, ::sfall::ddrawIni); strcpy_s(ini, ::sfall::ddrawIni);
} }
GetConfigString("Main", "TranslationsINI", ".\\Translations.ini", translationIni, 65); GetConfigString("Main", "TranslationsINI", ".\\Translations.ini", translationIni, 65);
modifiedIni = GetConfigInt("Main", "ModifiedIni", 0); modifiedIni = GetConfigInt("Main", "ModifiedIni", 0);
hrpIsEnabled = (*(DWORD*)0x4E4480 != 0x278805C7); // check if HRP is enabled
InitModules(); InitModules();
} }
+1
View File
@@ -92,5 +92,6 @@ size_t Translate(const char* section, const char* setting, const char* defaultVa
extern const char ddrawIni[]; extern const char ddrawIni[];
extern DWORD modifiedIni; extern DWORD modifiedIni;
extern bool hrpIsEnabled;
} }