From 6e5b811b87ffcfebb48973805cac87ae087db192 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Thu, 9 Mar 2017 13:56:37 +0800 Subject: [PATCH] Fix a crash when clicking on empty space in the inventory list opened by "Use Inventory Item On" (backpack) action icon (from Crafty) Improved the functionality of ScrollMod: now the minimum is scrolling 1 inventory slot per click; before setting ScrollMod too high or negative values will result in scrolling not working. Changed BodyHit_Torso to BodyHit_Torso_Uncalled because it sets both body_torso and body_uncalled hit modifiers. --- artifacts/ddraw.ini | 48 +++++++++++++++++--------------- sfall/InputFuncs.cpp | 7 ++--- sfall/Modules/BugFixes.cpp | 19 +++++++++++-- sfall/Modules/ScriptExtender.cpp | 18 ++++++------ 4 files changed, 54 insertions(+), 38 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index cabf9f16..e6afbb88 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -1,5 +1,5 @@ ;sfall configuration settings -;v3.8 +;v3.8.3 [Main] ;Change to 1 if you want to use command line args to tell sfall to use another ini file. @@ -48,26 +48,26 @@ SpeedMultiInitial=100 ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX [Graphics] ;Set to 0 for 8 bit fullscreen -;Set to 4 for dx9 fullscreen -;Set to 5 for dx9 windowed -;A dx9 mode is required for any graphics related script extender functions to work (i.e. fullscreen shaders) +;Set to 4 for DX9 fullscreen +;Set to 5 for DX9 windowed +;A DX9 mode is required for any graphics related script extender functions to work (i.e. fullscreen shaders) ;Modes 1, 2 and 3 are no longer supported Mode=0 -;If using a dx9 mode, this changes the resolution +;If using a DX9 mode, this changes the resolution ;The graphics are simply stretched to fit the new window; this does _not_ let you see more of the map ;If set to 0, use Fallout's native resolution GraphicsWidth=0 GraphicsHeight=0 -;Set to 1 to do the palette conversion on the gpu -;Set to 2 to do the palette conversion on the cpu +;Set to 1 to do the palette conversion on the GPU +;Set to 2 to do the palette conversion on the CPU ;Set to 0 to pick automatically ;GPU is faster, but requires v2.0 pixel shader support GPUBlt=0 ;Set to 1 to allow using 32 bit graphics for talking heads -;Requires graphics mode 4 or 5, and gpublt set to 1 +;Requires graphics mode 4 or 5, and GPUBlt set to 1 Use32BitHeadGraphics=0 ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX @@ -259,7 +259,7 @@ PipBoyAvailableAtGameStart=0 ;Set to 1 to double the number of available kill types ;If you use this, you need to provide the extra descriptions in proto.msg (entries from 1450 to 1487 are names and 1488 to 1525 are descriptions) -;Changing this option mid game will not invalidate old save games, but the players kill counters will be completely screwed. +;Changing this option mid game will not invalidate old save games, but the player's kill counters will be completely screwed. ;Setting this to 1 may cause problems if the player kills more than 32767 of any one critter type ;Additional kill types must have their new critical tables set! (See the OverrideCriticalTable option) ExtraKillTypes=0 @@ -281,8 +281,8 @@ TownMapHotkeysFix=1 ;Set to 1 to disable the horrigan encounter DisableHorrigan=0 -;Set to 1 to disable the random element in npc levelling. -;This will cause all npc party members to automatically level up as soon as the player reaches the requirements +;Set to 1 to disable the random element in NPC levelling. +;This will cause all NPC party members to automatically level up as soon as the player reaches the requirements NPCAutoLevel=0 ;Change the initial starting location and world map viewport @@ -307,7 +307,7 @@ SaveInCombatFix=1 ;ElevatorsFile=Elevators.ini ;Uncomment and set a comma delimited list of numbers to use a custom xp table. -;Players level is capped once the highest specified level is reached +;Player's level is capped once the highest specified level is reached ;XPTable=50,100,200 ;Set to 1 to enable additional weapon animations codes from o-t @@ -319,7 +319,7 @@ AdditionalWeaponAnims=1 ;BodyHit_Head=-40 ;BodyHit_Left_Arm=-30 ;BodyHit_Right_Arm=-30 -;BodyHit_Torso=0 +;BodyHit_Torso_Uncalled=0 ;BodyHit_Right_Leg=-20 ;BodyHit_Left_Leg=-20 ;BodyHit_Eyes=-60 @@ -347,7 +347,7 @@ CorpseLineOfFireFix=0 ;Set a number of milliseconds to idle each input loop ;Set to -1 to disable ;Set to 0 to idle only if other processes are waiting for processor time -;Set to 1 (or some higher number if needed, the maximum is 127) to prevent 100% cpu use +;Set to 1 (or some higher number if needed, the maximum is 127) to prevent 100% CPU use ProcessorIdle=-1 ;Set to 1 if using the hero appearance mod @@ -356,17 +356,17 @@ EnableHeroAppearanceMod=0 ;Set to 1 to skip the 3 opening movies SkipOpeningMovies=0 -;Causes npc's who complete their combat turn with ap left over will try and find other ways to spend it. -;Only npcs with ap left equal to or greater than the value given here will be considered. +;Causes NPCs who complete their combat turn with ap left over will try and find other ways to spend it. +;Only NPCs with ap left equal to or greater than the value given here will be considered. ;Set to 0 to disable NPCsTryToSpendExtraAP=0 ;Allows the use of tiles over 80*36 in size. sfall will just split and resave them at startup ;Set to 1 to check all tiles on started (slow) -;set to 2 if you provide a XLtiles.lst file in art/tiles/ containing a list of the tile ids that need checking +;Set to 2 if you provide a XLtiles.lst file in art/tiles/ containing a list of the tile ids that need checking AllowLargeTiles=0 -;Change the skilldex cursor frm numbers +;Change the Skilldex cursor frm numbers ;Default is 293 for all skills Lockpick=293 Steal=293 @@ -389,6 +389,7 @@ UseScrollingQuestsList=1 ;Use this line to modify the list of cities and their associated global variables used for city reputations ;Syntax is 'city id : global id',with each city/global pair separated by a comma. +;CityRepsCount=19 ;CityRepsList=0:47,2:48,1:49,4:50,5:51,3:52,8:53,6:54,7:55,13:56,10:57,11:59,14:61,17:63,19:64,18:65,25:66,9:294,20:308 ;Set this to a valid path to save a copy of the console contents @@ -397,19 +398,20 @@ UseScrollingQuestsList=1 ;Set to 1 to add additional pages of save slots ExtraSaveSlots=0 -;Set to 1 to speed up the hp/ac counter animations -;Set to 2 to update the hp/ac counters instantly +;Set to 1 to speed up the HP/AC counter animations +;Set to 2 to update the HP/AC counters instantly SpeedInterfaceCounterAnims=0 ;These lines allow you to control the karma frm's displayed on the character screen ;Number of KarmaPoints should be 1 less than number of KarmaFRMs +;KarmaFRMsCount=3 ;KarmaFRMs=47,48,49 ;KarmaPoints=-100,100 ;Set to 1 to allow science and repair to be used on the player, or 2 for all critters. (Rather than only brahmin/robots) ScienceOnCritters=0 -;Modify this value to change the players speed of rotation on the inventory and character screens +;Modify this value to change the player's speed of rotation on the inventory and character screens ;Default is 166 SpeedInventoryPCRotation=166 @@ -454,7 +456,7 @@ BoostScriptDialogLimit=0 ;DerivedStats=Stats.ini ;These options modify the checks to see if a critter can carry an additional item, changing which items are counted towards the weight limit and adding an additional size check -;Set the mode to 0 to disable the size check, 1 to apply to pc only, 2 to apply to the pc and party members, or 3 to apply to all critters +;Set the mode to 0 to disable the size check, 1 to apply to the PC only, 2 to apply to the PC and party members, or 3 to apply to all critters ;Only the PC uses CritterInvSizeLimit. Other critters will use the extra unused stat (STAT_unused = 10) ;Add 4 to the mode to limit the weight check to used items only CritterInvSizeLimitMode=0 @@ -609,7 +611,7 @@ SkipCompatModeCheck=0 ;Set to 1 to skip the executable file size check SkipSizeCheck=0 -;If you're testing changes to the Fallout exe, you can override the crc that sfall looks for here +;If you're testing changes to the Fallout exe, you can override the CRC that sfall looks for here ;You can use several hex values, separated by commas ;ExtraCRC=0x00000000,0x00000000 diff --git a/sfall/InputFuncs.cpp b/sfall/InputFuncs.cpp index 97f6f170..4bd14754 100644 --- a/sfall/InputFuncs.cpp +++ b/sfall/InputFuncs.cpp @@ -208,15 +208,14 @@ public: MouseState.lY = (LONG)d; } if (useScrollWheel) { + int count = 1; if (MouseState.lZ > 0) { - int count; if (wheelMod) count = MouseState.lZ / wheelMod; - else count = 1; + if (count < 1) count = 1; while (count--) TapKey(DIK_UP); } else if (MouseState.lZ < 0) { - int count; if (wheelMod) count = (-MouseState.lZ) / wheelMod; - else count = 1; + if (count < 1) count = 1; while (count--) TapKey(DIK_DOWN); } } diff --git a/sfall/Modules/BugFixes.cpp b/sfall/Modules/BugFixes.cpp index 14ff1e4f..998043af 100644 --- a/sfall/Modules/BugFixes.cpp +++ b/sfall/Modules/BugFixes.cpp @@ -654,7 +654,7 @@ end: } } -static void __declspec(naked) partyMemberPrepLoadInstance_hack() { +static void __declspec(naked) partyMemberPrepLoadInstance_hook() { __asm { and word ptr [eax+0x44], 0x7FFD // not (DAM_LOSE_TURN or DAM_KNOCKED_DOWN) jmp fo::funcoffs::dude_stand_ @@ -931,6 +931,18 @@ end: } } +static void __declspec(naked) use_inventory_on_hack() { + __asm { + inc ecx + mov edx, [eax] // Inventory.inv_size + sub edx, ecx + jge end + mov edx, [eax] // Inventory.inv_size +end: + retn + } +} + void BugFixes::init() { @@ -1117,7 +1129,7 @@ void BugFixes::init() MakeCall(0x424F8E, &set_new_results_hack, false); MakeCall(0x42E46E, &critter_wake_clear_hack, true); MakeCall(0x488EF3, &obj_load_func_hack, true); - HookCall(0x4949B2, &partyMemberPrepLoadInstance_hack); + HookCall(0x4949B2, &partyMemberPrepLoadInstance_hook); dlogr(" Done", DL_INIT); //} @@ -1191,6 +1203,9 @@ void BugFixes::init() // Fix crash when trying to open bag/backpack on the table in the bartering interface MakeCall(0x473191, &inven_action_cursor_hack, false); //} + + // Fix crash when clicking on empty space in the inventory list opened by "Use Inventory Item On" (backpack) action icon + MakeCall(0x471A94, &use_inventory_on_hack, false); } } diff --git a/sfall/Modules/ScriptExtender.cpp b/sfall/Modules/ScriptExtender.cpp index 7bf46583..f9825008 100644 --- a/sfall/Modules/ScriptExtender.cpp +++ b/sfall/Modules/ScriptExtender.cpp @@ -605,15 +605,15 @@ void ClearGlobalScripts() { //HP bonus SafeWrite8(0x4AFBC1, 2); //Bodypart hit chances - *((DWORD*)0x510954) = GetConfigInt("Misc", "BodyHit_Head", 0xFFFFFFD8); - *((DWORD*)0x510958) = GetConfigInt("Misc", "BodyHit_Left_Arm", 0xFFFFFFE2); - *((DWORD*)0x51095C) = GetConfigInt("Misc", "BodyHit_Right_Arm", 0xFFFFFFE2); - *((DWORD*)0x510960) = GetConfigInt("Misc", "BodyHit_Torso", 0x00000000); - *((DWORD*)0x510964) = GetConfigInt("Misc", "BodyHit_Right_Leg", 0xFFFFFFEC); - *((DWORD*)0x510968) = GetConfigInt("Misc", "BodyHit_Left_Leg", 0xFFFFFFEC); - *((DWORD*)0x51096C) = GetConfigInt("Misc", "BodyHit_Eyes", 0xFFFFFFC4); - *((DWORD*)0x510970) = GetConfigInt("Misc", "BodyHit_Groin", 0xFFFFFFE2); - *((DWORD*)0x510974) = GetConfigInt("Misc", "BodyHit_Torso", 0x00000000); + *((DWORD*)0x510954) = GetConfigInt("Misc", "BodyHit_Head", 0xFFFFFFD8, ini); + *((DWORD*)0x510958) = GetConfigInt("Misc", "BodyHit_Left_Arm", 0xFFFFFFE2, ini); + *((DWORD*)0x51095C) = GetConfigInt("Misc", "BodyHit_Right_Arm", 0xFFFFFFE2, ini); + *((DWORD*)0x510960) = GetConfigInt("Misc", "BodyHit_Torso_Uncalled", 0x00000000, ini); + *((DWORD*)0x510964) = GetConfigInt("Misc", "BodyHit_Right_Leg", 0xFFFFFFEC, ini); + *((DWORD*)0x510968) = GetConfigInt("Misc", "BodyHit_Left_Leg", 0xFFFFFFEC, ini); + *((DWORD*)0x51096C) = GetConfigInt("Misc", "BodyHit_Eyes", 0xFFFFFFC4, ini); + *((DWORD*)0x510970) = GetConfigInt("Misc", "BodyHit_Groin", 0xFFFFFFE2, ini); + *((DWORD*)0x510974) = GetConfigInt("Misc", "BodyHit_Torso_Uncalled", 0x00000000, ini); //skillpoints per level mod SafeWrite8(0x43C27a, 5); }