diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 60e5689a4..a91a81539 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -612,7 +612,7 @@ StackEmptyWeapons=0 ;If the amount of ammo boxes in the inventory is less than or equal to the reserve, only one box will be used ReloadReserve=-1 -;Set to 1 to change the counter in the 'Move Items' window to start at the maximum number of items +;Set to 1 to change the counter in the 'Move Items' window to start with maximum number except in the barter screen ItemCounterDefaultMax=0 ;Set to 1 to leave the music playing in dialogue with talking heads diff --git a/sfall/BugFixes.cpp b/sfall/BugFixes.cpp index 5c34b4c23..ba740efb1 100644 --- a/sfall/BugFixes.cpp +++ b/sfall/BugFixes.cpp @@ -1740,7 +1740,7 @@ static void __declspec(naked) process_rads_hook() { __asm { push eax; // death message for DialogOut call display_print_; - call GetCurrentLoops; + call GetLoopFlags; test eax, PIPBOY; jz skip; mov eax, 1; diff --git a/sfall/Graphics.cpp b/sfall/Graphics.cpp index 0ff948b14..816c5a537 100644 --- a/sfall/Graphics.cpp +++ b/sfall/Graphics.cpp @@ -62,12 +62,13 @@ static DDSURFACEDESC surfaceDesc; static DDSURFACEDESC movieDesc; static DWORD palette[256]; +//static bool paletteInit = false; static DWORD gWidth; static DWORD gHeight; static int ScrollWindowKey; -static bool windowIsInit; +static bool windowInit = false; static DWORD windowLeft = 0; static DWORD windowTop = 0; @@ -388,7 +389,8 @@ static void Present() { if (ScrollWindowKey != 0 && ((ScrollWindowKey > 0 && KeyDown((BYTE)ScrollWindowKey)) || (ScrollWindowKey == -1 && (KeyDown(DIK_LCONTROL) || KeyDown(DIK_RCONTROL))) || (ScrollWindowKey == -2 && (KeyDown(DIK_LMENU) || KeyDown(DIK_RMENU))) - || (ScrollWindowKey == -3 && (KeyDown(DIK_LSHIFT) || KeyDown(DIK_RSHIFT))))) { + || (ScrollWindowKey == -3 && (KeyDown(DIK_LSHIFT) || KeyDown(DIK_RSHIFT))))) + { int winx, winy; GetMouse(&winx, &winy); windowLeft += winx; @@ -474,8 +476,8 @@ void RefreshGraphics() { } for (int d = shadersSize - 1; d >= 0; d--) { if (!shaders[d].Effect || !shaders[d].Active) continue; - if (shaders[d].mode2 && !(shaders[d].mode2 & GetCurrentLoops())) continue; - if (shaders[d].mode & GetCurrentLoops()) continue; + if (shaders[d].mode2 && !(shaders[d].mode2 & GetLoopFlags())) continue; + if (shaders[d].mode & GetLoopFlags()) continue; if (shaders[d].ehTicks) shaders[d].Effect->SetInt(shaders[d].ehTicks, GetTickCount()); UINT passes; @@ -624,7 +626,7 @@ class FakePalette2 : IDirectDrawPalette { HRESULT _stdcall Initialize(LPDIRECTDRAW, DWORD, LPPALETTEENTRY) { UNUSEDFUNCTION; } HRESULT _stdcall SetEntries(DWORD, DWORD b, DWORD c, LPPALETTEENTRY destPal) { - if (!windowIsInit || c == 0 || b + c > 256) return DDERR_INVALIDPARAMS; + if (!windowInit || c == 0 || b + c > 256) return DDERR_INVALIDPARAMS; CopyMemory(&palette[b], destPal, c * 4); if (GPUBlt) { @@ -638,8 +640,8 @@ class FakePalette2 : IDirectDrawPalette { } else { for (DWORD i = b; i < b + c; i++) { // swap color R <> B //palette[i]&=0x00ffffff; - BYTE clr = *(BYTE*)((DWORD)&palette[i]); - *(BYTE*)((DWORD)&palette[i]) = *(BYTE*)((DWORD)&palette[i] + 2); + BYTE clr = *(BYTE*)((DWORD)&palette[i]); // B + *(BYTE*)((DWORD)&palette[i]) = *(BYTE*)((DWORD)&palette[i] + 2); // R *(BYTE*)((DWORD)&palette[i] + 2) = clr; } } @@ -1061,7 +1063,7 @@ HRESULT _stdcall FakeDirectDrawCreate2(void*, IDirectDraw** b, void*) { static __declspec(naked) void game_init_hook() { __asm { - mov windowIsInit, 1; + mov windowInit, 1; jmp palette_init_; } } diff --git a/sfall/Inventory.cpp b/sfall/Inventory.cpp index 0ac2335ed..78fc12907 100644 --- a/sfall/Inventory.cpp +++ b/sfall/Inventory.cpp @@ -59,7 +59,7 @@ TGameObj* GetActiveItem() { } void InventoryKeyPressedHook(DWORD dxKey, bool pressed, DWORD vKey) { - if (pressed && reloadWeaponKey && dxKey == reloadWeaponKey && IsMapLoaded() && (GetCurrentLoops() & ~(COMBAT | PCOMBAT)) == 0) { + if (pressed && reloadWeaponKey && dxKey == reloadWeaponKey && IsMapLoaded() && (GetLoopFlags() & ~(COMBAT | PCOMBAT)) == 0) { DWORD maxAmmo, curAmmo; TGameObj* item = GetActiveItem(); __asm { @@ -707,6 +707,16 @@ static void __declspec(naked) do_move_timer_hook() { } } +static void __declspec(naked) do_move_timer_hack() { + __asm { + mov ebx, 1; + call GetLoopFlags; + test eax, BARTER; + cmovz ebx, ebp; // set max when not in barter + retn; + } +} + static int invenApCost, invenApCostDef; static char invenApQPReduction; static const DWORD inven_ap_cost_Ret = 0x46E812; @@ -832,7 +842,7 @@ void InventoryInit() { } if (GetPrivateProfileIntA("Misc", "ItemCounterDefaultMax", 0, ini)) { - BlockCall(0x4768A3); // mov ebx, 1 + MakeCall(0x4768A3, do_move_timer_hack); } // Move items from bag/backpack to the main inventory list by dragging them on the character portrait (similar to Fallout 1 behavior) diff --git a/sfall/LoadGameHook.cpp b/sfall/LoadGameHook.cpp index 78349bd96..34e6cb811 100644 --- a/sfall/LoadGameHook.cpp +++ b/sfall/LoadGameHook.cpp @@ -70,7 +70,7 @@ DWORD InDialog() { return (InLoop & DIALOG) ? 1 : 0; } -DWORD GetCurrentLoops() { +DWORD GetLoopFlags() { return InLoop; } diff --git a/sfall/LoadGameHook.h b/sfall/LoadGameHook.h index 41c5ad021..9fcee2178 100644 --- a/sfall/LoadGameHook.h +++ b/sfall/LoadGameHook.h @@ -47,4 +47,4 @@ DWORD InDialog(); #define BARTER (1<<17) // 0x20000 #define RESERVED (1<<31) -DWORD GetCurrentLoops(); +DWORD GetLoopFlags(); diff --git a/sfall/ScriptExtender.cpp b/sfall/ScriptExtender.cpp index f8d9c485f..91e9cedf0 100644 --- a/sfall/ScriptExtender.cpp +++ b/sfall/ScriptExtender.cpp @@ -1329,7 +1329,7 @@ static void __declspec(naked) queue_add_hack() { pop edx; pop ecx; end: - xor edi, edi; // fix: don't set "Used" flag for critter objects + xor edi, edi; // fix: don't set "Used" flag for non-item objects retn; } } @@ -1372,7 +1372,7 @@ void ScriptExtenderSetup() { // Fix mapper bug by reassigning object IDs to critters (for unvisited maps) MakeCall(0x482E6B, map_load_file_hack); SafeWrite8(0x482E71, 0x85); // jz > jnz - // Additionally fix object IDs for queue events + // Additionally fix object IDs for queued events MakeCall(0x4A25BA, queue_add_hack); arraysBehavior = GetPrivateProfileIntA("Misc", "arraysBehavior", 1, ini); diff --git a/sfall/ScriptOps/InterfaceOp.hpp b/sfall/ScriptOps/InterfaceOp.hpp index c54ffdaa2..1dcc96c1b 100644 --- a/sfall/ScriptOps/InterfaceOp.hpp +++ b/sfall/ScriptOps/InterfaceOp.hpp @@ -405,14 +405,14 @@ static void sf_set_cursor_mode() { static void sf_display_stats() { // calling the function outside of inventory screen will crash the game - if (GetCurrentLoops() & INVENTORY) { + if (GetLoopFlags() & INVENTORY) { __asm call display_stats_; } } static void sf_inventory_redraw() { int mode; - DWORD loopFlag = GetCurrentLoops(); + DWORD loopFlag = GetLoopFlags(); if (loopFlag & INVENTORY) { mode = 0; } else if (loopFlag & INTFACEUSE) { diff --git a/sfall/ScriptOps/ObjectsOps.hpp b/sfall/ScriptOps/ObjectsOps.hpp index 416782de2..bc2804db9 100644 --- a/sfall/ScriptOps/ObjectsOps.hpp +++ b/sfall/ScriptOps/ObjectsOps.hpp @@ -644,7 +644,7 @@ static void sf_get_obj_under_cursor() { } static void sf_get_loot_object() { - opHandler.setReturn((GetCurrentLoops() & INTFACELOOT) ? LoadGameHook_LootTarget : 0, DATATYPE_INT); + opHandler.setReturn((GetLoopFlags() & INTFACELOOT) ? LoadGameHook_LootTarget : 0, DATATYPE_INT); } static void sf_get_object_data() { diff --git a/sfall/ScriptOps/WorldmapOps.hpp b/sfall/ScriptOps/WorldmapOps.hpp index a4a2dc3a6..51ffbb05a 100644 --- a/sfall/ScriptOps/WorldmapOps.hpp +++ b/sfall/ScriptOps/WorldmapOps.hpp @@ -117,7 +117,7 @@ static void __declspec(naked) GetGameMode() { push ecx; push edx; push eax; - call GetCurrentLoops; + call GetLoopFlags; mov edx, eax; pop eax; _RET_VAL_INT2(ecx); diff --git a/sfall/SpeedPatch.cpp b/sfall/SpeedPatch.cpp index f404513cf..ead34b234 100644 --- a/sfall/SpeedPatch.cpp +++ b/sfall/SpeedPatch.cpp @@ -93,7 +93,7 @@ static DWORD _stdcall FakeGetTickCount() { // Multiply the tick count difference by the multiplier if (enabled && !slideShow - && !(GetCurrentLoops() & (INVENTORY | INTFACEUSE | INTFACELOOT | DIALOG))) + && !(GetLoopFlags() & (INVENTORY | INTFACEUSE | INTFACELOOT | DIALOG))) { elapsed *= multi; tickCountFraction += modf(elapsed, &elapsed);