Reverted LoadGame_hook to previous revision and changed EndLoadHook to only call LoadHeroAppearance (attempted to fix issue #117 and #94)

Removed redundant LoadHeroAppearance calling.
This commit is contained in:
NovaRain
2017-09-19 11:58:41 +08:00
parent 848f29b468
commit b4168fe934
2 changed files with 18 additions and 27 deletions
+4 -19
View File
@@ -225,7 +225,6 @@ void UnloadDat(void *dat) {
/* /*
void DrawLineX(int WinRef, DWORD XStartPos, DWORD XEndPos, DWORD Ypos, BYTE ColourIndex) { void DrawLineX(int WinRef, DWORD XStartPos, DWORD XEndPos, DWORD Ypos, BYTE ColourIndex) {
__asm { __asm {
xor eax, eax xor eax, eax
mov al, ColourIndex mov al, ColourIndex
@@ -243,7 +242,6 @@ void DrawLineX(int WinRef, DWORD XStartPos, DWORD XEndPos, DWORD Ypos, BYTE Colo
//--------------------------------------------------------- //---------------------------------------------------------
void PlayAcm(char *AcmName) { void PlayAcm(char *AcmName) {
__asm { __asm {
mov eax, AcmName mov eax, AcmName
call fo::funcoffs::gsound_play_sfx_file_ call fo::funcoffs::gsound_play_sfx_file_
@@ -262,10 +260,8 @@ int CheckFile(char*FileName, DWORD *size_out) {
return retVal; return retVal;
} }
/////////////////////////////////////////////////////////////////APP MOD FUNCTIONS//////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////APP MOD FUNCTIONS////////////////////////////////////////////////////////////////////////
//----------------------------------------- //-----------------------------------------
char _stdcall GetSex(void) { char _stdcall GetSex(void) {
using fo::STAT_gender; using fo::STAT_gender;
@@ -324,7 +320,7 @@ int _stdcall LoadHeroDat(unsigned int Race, unsigned int Style) {
tempPathPtr = &heroPathPtr; //set path for selected appearance tempPathPtr = &heroPathPtr; //set path for selected appearance
heroPathPtr->next = &fo::var::paths[0]; heroPathPtr->next = &fo::var::paths[0];
if (Style != 0){ if (Style != 0) {
sprintf_s(racePathPtr->path, 64, "Appearance\\h%cR%02dS%02d.dat\0", GetSex(), Race, 0); sprintf_s(racePathPtr->path, 64, "Appearance\\h%cR%02dS%02d.dat\0", GetSex(), Race, 0);
if (GetFileAttributes(racePathPtr->path) != INVALID_FILE_ATTRIBUTES) { //check if Dat exists for selected race base appearance if (GetFileAttributes(racePathPtr->path) != INVALID_FILE_ATTRIBUTES) { //check if Dat exists for selected race base appearance
racePathPtr->pDat = LoadDat(racePathPtr->path); racePathPtr->pDat = LoadDat(racePathPtr->path);
@@ -344,7 +340,6 @@ int _stdcall LoadHeroDat(unsigned int Race, unsigned int Style) {
//--------------------------------------------------------- //---------------------------------------------------------
//insert hero art path in front of main path structure when loading art //insert hero art path in front of main path structure when loading art
static void __declspec(naked) LoadNewHeroArt() { static void __declspec(naked) LoadNewHeroArt() {
__asm { __asm {
cmp byte ptr ds:[esi], 'r' cmp byte ptr ds:[esi], 'r'
je isReading je isReading
@@ -360,7 +355,6 @@ setPath:
//--------------------------------------------------------- //---------------------------------------------------------
static void __declspec(naked) CheckHeroExist() { static void __declspec(naked) CheckHeroExist() {
__asm { __asm {
//pushad //pushad
cmp esi, critterArraySize //check if loading hero art cmp esi, critterArraySize //check if loading hero art
@@ -393,7 +387,6 @@ EndFunc:
//--------------------------------------------------------- //---------------------------------------------------------
//adjust base hero art if num below hero art range //adjust base hero art if num below hero art range
static void __declspec(naked) AdjustHeroBaseArt() { static void __declspec(naked) AdjustHeroBaseArt() {
__asm { __asm {
//cmp eax, critterListSize //cmp eax, critterListSize
// jg EndFunc // jg EndFunc
@@ -417,7 +410,6 @@ static void AdjustHeroArmorArt(DWORD fid) {
//----------------------------------------- //-----------------------------------------
void _stdcall SetHeroArt(int NewArtFlag) { void _stdcall SetHeroArt(int NewArtFlag) {
__asm { __asm {
mov eax, dword ptr ds:[FO_VAR_obj_dude] //hero state struct mov eax, dword ptr ds:[FO_VAR_obj_dude] //hero state struct
mov eax, dword ptr ds:[eax + 0x20] //get hero FrmID mov eax, dword ptr ds:[eax + 0x20] //get hero FrmID
@@ -472,7 +464,6 @@ static void __declspec(naked) SavCritNumFix() {
//--------------------------------------------------------- //---------------------------------------------------------
static void __declspec(naked) DoubleArt() { static void __declspec(naked) DoubleArt() {
__asm { __asm {
cmp dword ptr ss:[esp+0xCC], 0x510774 //check if loading critter lst. 0x510774= addr of critter list size val cmp dword ptr ss:[esp+0xCC], 0x510774 //check if loading critter lst. 0x510774= addr of critter list size val
jne EndFunc jne EndFunc
@@ -936,7 +927,6 @@ void DrawCharNote(bool Style, int WinRef, DWORD xPosWin, DWORD yPosWin, BYTE *BG
/* /*
void DrawCharNote(DWORD LstNum, char *TitleTxt, char *AltTitleTxt, char *Message) { void DrawCharNote(DWORD LstNum, char *TitleTxt, char *AltTitleTxt, char *Message) {
__asm { __asm {
MOV ECX,Message//100//DWORD PTR ds:[FO_VAR_folder_card_desc] MOV ECX,Message//100//DWORD PTR ds:[FO_VAR_folder_card_desc]
MOV EBX,AltTitleTxt//DWORD PTR ds:[FO_VAR_folder_card_title2] MOV EBX,AltTitleTxt//DWORD PTR ds:[FO_VAR_folder_card_title2]
@@ -1042,7 +1032,6 @@ void _stdcall HeroSelectWindow(int RaceStyleFlag) {
memset(mainSurface + 484*(10 + titleTextHeight) + 94 - titleTextWidth/2, textColour, titleTextWidth ); memset(mainSurface + 484*(10 + titleTextHeight) + 94 - titleTextWidth/2, textColour, titleTextWidth );
memset(mainSurface + 484*(10 + titleTextHeight + 1) + 94 - titleTextWidth/2, textColour, titleTextWidth ); memset(mainSurface + 484*(10 + titleTextHeight + 1) + 94 - titleTextWidth/2, textColour, titleTextWidth );
sub_draw(484, 230, 484, 230, 0, 0, mainSurface, 484, 230, 0, 0, winSurface, 0); sub_draw(484, 230, 484, 230, 0, 0, mainSurface, 484, 230, 0, 0, winSurface, 0);
fo::func::win_show(winRef); fo::func::win_show(winRef);
@@ -1281,7 +1270,7 @@ int _stdcall CheckCharButtons() {
} }
} }
switch(button) { switch (button) {
case 0x9: //tab button pushed case 0x9: //tab button pushed
if (fo::var::info_line >= 0x3D && fo::var::info_line < 0x4F) { //if menu ref in last menu go to race if (fo::var::info_line >= 0x3D && fo::var::info_line < 0x4F) { //if menu ref in last menu go to race
button = 0x501, drawFlag = 0; button = 0x501, drawFlag = 0;
@@ -1312,7 +1301,7 @@ int _stdcall CheckCharButtons() {
raceVal--; raceVal--;
LoadHeroDat(raceVal, styleVal); LoadHeroDat(raceVal, styleVal);
} }
drawFlag=0; drawFlag = 0;
break; break;
case 0x512: //style left button pushed case 0x512: //style left button pushed
fo::func::art_flush(); fo::func::art_flush();
@@ -1348,7 +1337,7 @@ int _stdcall CheckCharButtons() {
DrawCharNoteNewChar(1); DrawCharNoteNewChar(1);
//DrawCharNote(1, fo::var::edit_win, 348, 272, CharScrnBackSurface, 348, 272, 640, 480); //DrawCharNote(1, fo::var::edit_win, 348, 272, CharScrnBackSurface, 348, 272, 640, 480);
} }
else if (drawFlag==0) { else if (drawFlag == 0) {
PlayAcm("ib3p1xx1"); PlayAcm("ib3p1xx1");
fo::var::info_line = 0x501; fo::var::info_line = 0x501;
FixTextHighLight(); FixTextHighLight();
@@ -1511,7 +1500,6 @@ static void __declspec(naked) AddCharScrnButtons(void) {
} }
} }
//------------------------------------------ //------------------------------------------
static void __declspec(naked) FixCharScrnBack(void) { static void __declspec(naked) FixCharScrnBack(void) {
//00432B92 |. A3 A4075700 MOV DWORD PTR DS:[5707A4],EAX //00432B92 |. A3 A4075700 MOV DWORD PTR DS:[5707A4],EAX
@@ -1643,7 +1631,6 @@ ExitFunc:
//Set path to normal before printing or saving character details------------ //Set path to normal before printing or saving character details------------
static void __declspec(naked) FixCharScrnSaveNPrint() { static void __declspec(naked) FixCharScrnSaveNPrint() {
//00432359 |> E8 AA580000 |CALL fallout2.00437C08 //00432359 |> E8 AA580000 |CALL fallout2.00437C08
__asm { __asm {
push TempPathPtr //store current path push TempPathPtr //store current path
mov eax, _paths mov eax, _paths
@@ -1659,7 +1646,6 @@ static void __declspec(naked) FixCharScrnSaveNPrint() {
} }
*/ */
// Load Appearance data from GCD file------------ // Load Appearance data from GCD file------------
void _stdcall LoadGCDAppearance(fo::DbFile* fileStream) { void _stdcall LoadGCDAppearance(fo::DbFile* fileStream) {
currentRaceVal = 0; currentRaceVal = 0;
@@ -1871,7 +1857,6 @@ void HeroAppearance::init() {
EnableHeroAppearanceMod(); EnableHeroAppearanceMod();
LoadGameHook::OnAfterNewGame() += SetNewCharAppearanceGlobals; LoadGameHook::OnAfterNewGame() += SetNewCharAppearanceGlobals;
LoadGameHook::OnAfterGameStarted() += LoadHeroAppearance;
Inventory::OnAdjustFid() += AdjustHeroArmorArt; Inventory::OnAdjustFid() += AdjustHeroArmorArt;
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
+7 -1
View File
@@ -25,6 +25,7 @@
#include "AI.h" #include "AI.h"
#include "FileSystem.h" #include "FileSystem.h"
#include "HeroAppearance.h"
#include "PartyControl.h" #include "PartyControl.h"
#include "Perks.h" #include "Perks.h"
#include "ScriptExtender.h" #include "ScriptExtender.h"
@@ -200,6 +201,11 @@ static void __declspec(naked) LoadGame_hook() {
or inLoop, LOADGAME; or inLoop, LOADGAME;
call fo::funcoffs::LoadGame_; call fo::funcoffs::LoadGame_;
and inLoop, (-1 ^ LOADGAME); and inLoop, (-1 ^ LOADGAME);
cmp eax, 1;
jne end;
call LoadGame_After;
mov eax, 1;
end:
pop edx; pop edx;
pop ecx; pop ecx;
pop ebx; pop ebx;
@@ -211,7 +217,7 @@ static void __declspec(naked) EndLoadHook() {
__asm { __asm {
call fo::funcoffs::EndLoad_; call fo::funcoffs::EndLoad_;
pushad; pushad;
call LoadGame_After; call LoadHeroAppearance;
popad; popad;
retn; retn;
} }