Skip to content

Commit dfb1ba5

Browse files
committed
Fixed code.
1 parent e8487ec commit dfb1ba5

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

sfall/Modules/Interface.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -943,14 +943,12 @@ static void __declspec(naked) main_death_scene_hook() {
943943
}
944944

945945
static void __declspec(naked) display_body_hook() {
946-
static const DWORD display_body_hook_Ret = 0x47098D;
947946
__asm {
948947
mov ebx, [esp + 0x60 - 0x28 + 8];
949948
cmp ebx, 1; // check mode 0 or 1
950949
jbe fix;
951-
add esp, 8;
952-
mov dword ptr [esp + 0x60 - 0x40], 0; // frm_ptr
953-
jmp display_body_hook_Ret;
950+
xor ebx, ebx;
951+
jmp fo::funcoffs::art_id_;
954952
fix:
955953
dec edx; // USE.FRM
956954
mov ecx, 48; // INVBOX.FRM
@@ -989,15 +987,15 @@ void Interface::init() {
989987
if (hrpIsEnabled == false || hrpVersionValid) SafeWrite8(0x481345, 4); // main_death_scene_
990988
if (hrpVersionValid) SafeWrite8(HRPAddress(0x10011738), 10);
991989

992-
// Cosmetic fix for the background image of the character portrait on the inventory and character screens
990+
// Cosmetic fix for the background image of the character portrait for the player's inventory screen
993991
HookCall(0x47093C, display_body_hook);
994992
BYTE code[11] = {
995993
0x8B, 0xD3, // mov edx, ebx
996994
0x66, 0x8B, 0x58, 0xF4, // mov bx, [eax - 12] [sizeof(frame)]
997995
0x0F, 0xAF, 0xD3, // imul edx, ebx (y * frame width)
998996
0x53, 0x90 // push ebx (frame width)
999997
};
1000-
SafeWriteBytes(0x470971, code, 11);
998+
SafeWriteBytes(0x470971, code, 11); // calculates the offset in the pixel array for x/y coordinates
1001999
}
10021000

10031001
void Interface::exit() {

sfall/Modules/Scripting/Handlers/Interface.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,8 @@ static long GetArtFIDFile(long fid, const char* &file) {
512512
}
513513

514514
static long DrawImage(OpcodeContext& ctx, bool isScaled) {
515-
fo::func::selectWindowID(ctx.program()->currentScriptWin);
516-
if (*(DWORD*)FO_VAR_currentWindow == -1) {
517-
ctx.printOpcodeError("%s() - no created/selected window for the image.", ctx.getMetaruleName());
515+
if (!fo::func::selectWindowID(ctx.program()->currentScriptWin) || *(DWORD*)FO_VAR_currentWindow == -1) {
516+
ctx.printOpcodeError("%s() - no created or selected window.", ctx.getMetaruleName());
518517
return 0;
519518
}
520519
long direction = 0;
@@ -785,9 +784,9 @@ void mf_interface_print(OpcodeContext& ctx) { // same as vanilla PrintRect
785784
}
786785

787786
void mf_win_fill_color(OpcodeContext& ctx) {
788-
fo::func::selectWindowID(ctx.program()->currentScriptWin);
787+
long result = fo::func::selectWindowID(ctx.program()->currentScriptWin);
789788
long iWin = *(DWORD*)FO_VAR_currentWindow;
790-
if (iWin == -1) {
789+
if (!result || iWin == -1) {
791790
ctx.printOpcodeError("%s() - no created or selected window.", ctx.getMetaruleName());
792791
ctx.setReturn(-1);
793792
return;

0 commit comments

Comments
 (0)