Added WorldMapTerrainInfo option for toggling the display

Minor code refactoring in MiscPatches/PlayerModel modules.

Updated compiler document.
This commit is contained in:
NovaRain
2020-01-08 16:50:49 +08:00
parent e0305983de
commit af049eaa38
6 changed files with 167 additions and 181 deletions
+4 -1
View File
@@ -120,7 +120,7 @@ ExpandWorldMap=0
ActionPointsBar=0 ActionPointsBar=0
;Set to 1 to enable drawing a dotted line when traveling on the world map (similar to Fallout 1) ;Set to 1 to enable drawing a dotted line when traveling on the world map (similar to Fallout 1)
WorldTravelMarkers=0 WorldMapTravelMarkers=0
;Uncomment these lines to change the appearance of the markers ;Uncomment these lines to change the appearance of the markers
;The color index in Fallout default palette (valid range: 1..255; default is 133) ;The color index in Fallout default palette (valid range: 1..255; default is 133)
;TravelMarkerColor=133 ;TravelMarkerColor=133
@@ -129,6 +129,9 @@ WorldTravelMarkers=0
;The spacing between the dots in pixels (valid range: 1..10) ;The spacing between the dots in pixels (valid range: 1..10)
;TravelMarkerSpaces=2 ;TravelMarkerSpaces=2
;Set to 1 to display terrain types when moving the cursor over a green triangle on the world map
WorldMapTerrainInfo=0
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[Input] [Input]
;Set to 1 to enable the mouse scroll wheel to scroll through the inventory, barter, and loot screens ;Set to 1 to enable the mouse scroll wheel to scroll through the inventory, barter, and loot screens
+28 -19
View File
@@ -82,6 +82,14 @@ old:
X := value2; X := value2;
> To assign values, you can use the alternative assignment operator from C/Java instead of Pascal syntax.
new:
x = 5;
old:
x := 5;
> Multiple variable decleration: Multiple variables can be declared on one line, seperated by commas. This is an alterative to the ugly begin/end block, or the bulky single variable per line style. > Multiple variable decleration: Multiple variables can be declared on one line, seperated by commas. This is an alterative to the ugly begin/end block, or the bulky single variable per line style.
new: new:
@@ -102,12 +110,12 @@ old:
NOTE: if your expression starts with a constant (eg. 2+2), enclose it in parentheses, otherwise compiler will be confused and give you errors. NOTE: if your expression starts with a constant (eg. 2+2), enclose it in parentheses, otherwise compiler will be confused and give you errors.
> hexadecimal numerical constants: Simply prefix a number with 0x to create a hexadecimal. The numbers 0 to 9 and a-f are allowed in the number. The number may not have a decimal point. > Hexadecimal numerical constants: Simply prefix a number with 0x to create a hexadecimal. The numbers 0 to 9 and a-f are allowed in the number. The number may not have a decimal point.
new: new:
a:=0x1000; a := 0x1000;
old: old:
a:=4096; a := 4096;
> increment/decrement operators: ++ and -- can be used as shorthand for +=1 and -=1 respectively. They are mearly a syntactic shorthand to improve readability, and so their use is only allowed where +=1 would normally be allowed. > increment/decrement operators: ++ and -- can be used as shorthand for +=1 and -=1 respectively. They are mearly a syntactic shorthand to improve readability, and so their use is only allowed where +=1 would normally be allowed.
@@ -115,7 +123,7 @@ old:
new: new:
a++; a++;
old: old:
a+=1; a += 1;
> "break" & "continue" statements: they work just like in most high-level languages. "break" jumps out of the loop. "continue" jumps right to the beginning of the next iteration (see "for" and "foreach" sections for additional details). > "break" & "continue" statements: they work just like in most high-level languages. "break" jumps out of the loop. "continue" jumps right to the beginning of the next iteration (see "for" and "foreach" sections for additional details).
@@ -157,12 +165,12 @@ old:
> "for" loops: Another piece of syntactic shorthand, to shorten while loops in many cases. Parentheses around the loop statements are recommended but not required (when not using parentheses, a semicolon is required after the 3rd loop statement). > "for" loops: Another piece of syntactic shorthand, to shorten while loops in many cases. Parentheses around the loop statements are recommended but not required (when not using parentheses, a semicolon is required after the 3rd loop statement).
new: new:
for (i:=0; i<5; i++) begin for (i := 0; i < 5; i++) begin
display_msg("i = "+i); display_msg("i = "+i);
end end
old old
i:=0; i := 0;
while i<5 do begin while (i < 5) do begin
display_msg("i = "+i); display_msg("i = "+i);
i++; i++;
end end
@@ -179,7 +187,7 @@ new:
end end
old: old:
variable tmp; variable tmp;
tmp:=get_attack_type; tmp := get_attack_type;
if tmp == ATKTYPE_PUNCH then begin if tmp == ATKTYPE_PUNCH then begin
display_msg("punch"); display_msg("punch");
end else if tmp == ATKTYPE_KICK then begin end else if tmp == ATKTYPE_KICK then begin
@@ -219,17 +227,17 @@ new:
new: new:
procedure bingle begin procedure bingle begin
variable a[2]; variable a[2];
a[0]:=5; a[0] := 5;
a[a[0]-4]:=a[0] + 4; a[a[0] - 4] := a[0] + 4;
display_msg("a[0]="+a[0]+", a[1]="+a[1]); display_msg("a[0]=" + a[0] + ", a[1]=" + a[1]);
end end
old: old:
procedure bingle begin procedure bingle begin
variable a; variable a;
a:=temp_array(2, 4); a := temp_array(2, 4);
set_array(a, 0, 5); set_array(a, 0, 5);
set_array(a, get_array(a, 0) - 4, get_array(a, 0) + 4); set_array(a, get_array(a, 0) - 4, get_array(a, 0) + 4);
display_msg("a[0]="+get_array(a, 0)+", a[1]="+get_array(a, 1)); display_msg("a[0]=" + get_array(a, 0) + ", a[1]=" + get_array(a, 1));
end end
@@ -273,12 +281,12 @@ new:
old: old:
procedure bingle begin procedure bingle begin
variable begin critter; array; len; count; end variable begin critter; array; len; count; end
array:=list_as_array(LIST_CRITTERS); array := list_as_array(LIST_CRITTERS);
len:=len_array(array); len := len_array(array);
count:=0; count := 0;
while count < len do begin while count < len do begin
critter:=array[count]; critter := array[count];
display_msg(""+critter); display_msg("" + critter);
end end
end end
@@ -334,7 +342,8 @@ There are several changes in this version of sslc which may result in problems f
> sfall 4.2.3 > sfall 4.2.3
- fixed compiler giving "assignment operator expected" error when a variable-like macro is not being defined properly - fixed compiler giving "assignment operator expected" error when a variable-like macro is not being defined properly
- added new logical operators 'AndAlso', 'OrElse' for short-circuit evaluation of logical expressions - added new logical operators "AndAlso", "OrElse" for short-circuit evaluation of logical expressions
- added an alternative (C/Java-style) assignment operator "="
> sfall 4.2.2 > sfall 4.2.2
- added support for new opcode "reg_anim_callback" - added support for new opcode "reg_anim_callback"
+11 -7
View File
@@ -23,7 +23,6 @@
#include "..\FalloutEngine\EngineUtils.h" #include "..\FalloutEngine\EngineUtils.h"
#include "Graphics.h" #include "Graphics.h"
#include "LoadGameHook.h" #include "LoadGameHook.h"
//#include "Worldmap.h"
#include "Interface.h" #include "Interface.h"
@@ -463,7 +462,7 @@ static void WorldmapViewportPatch() {
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
////////////////////////////// FALLOUT 1 FEATURES ////////////////////////////// ///////////////////////// FALLOUT 1 WORLDMAP FEATURES //////////////////////////
enum TerrainHoverImage { enum TerrainHoverImage {
width = 100, width = 100,
@@ -595,7 +594,7 @@ static long __fastcall wmDetectHotspotHover(long wmMouseX, long wmMouseY) {
fo::MemCopyToWinBuffer(x_offset, y, TerrainHoverImage::width, TerrainHoverImage::height, wmapWinWidth, *(BYTE**)FO_VAR_wmBkWinBuf, wmTmpBuffer.data()); fo::MemCopyToWinBuffer(x_offset, y, TerrainHoverImage::width, TerrainHoverImage::height, wmapWinWidth, *(BYTE**)FO_VAR_wmBkWinBuf, wmTmpBuffer.data());
backImageIsCopy = false; backImageIsCopy = false;
} }
// redraw worldmap interface rectangle // redraw rectangle on worldmap interface
RECT rect; RECT rect;
rect.top = y; rect.top = y;
rect.left = x_offset; rect.left = x_offset;
@@ -689,7 +688,9 @@ static void WorldMapInterfacePatch() {
} }
} }
if (GetConfigInt("Interface", "WorldTravelMarkers", 0)) { // Fallout 1 features, travel markers and displaying terrain types
bool showTravelMarkers, showTerrainType;
if (showTravelMarkers = GetConfigInt("Interface", "WorldMapTravelMarkers", 0) != 0) {
dlog("Applying world map travel markers patch.", DL_INIT); dlog("Applying world map travel markers patch.", DL_INIT);
optionLenDot = GetConfigInt("Interface", "TravelMarkerLength", optionLenDot); optionLenDot = GetConfigInt("Interface", "TravelMarkerLength", optionLenDot);
optionSpaceDot = GetConfigInt("Interface", "TravelMarkerSpaces", optionSpaceDot); optionSpaceDot = GetConfigInt("Interface", "TravelMarkerSpaces", optionSpaceDot);
@@ -706,9 +707,12 @@ static void WorldMapInterfacePatch() {
}; };
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
// Fallout 1 features, travel markers and displaying terrain type if (showTerrainType = GetConfigInt("Interface", "WorldMapTerrainInfo", 0) != 0) {
HookCall(0x4C3C7E, wmInterfaceRefresh_hook); // when calling wmDrawCursorStopped_ dlog("Applying display terrain types patch.", DL_INIT);
MakeCall(0x4BFE84, wmWorldMap_hack); MakeCall(0x4BFE84, wmWorldMap_hack);
dlogr(" Done", DL_INIT);
}
if (showTravelMarkers || showTerrainType) HookCall(0x4C3C7E, wmInterfaceRefresh_hook); // when calling wmDrawCursorStopped_
// Car fuel gauge graphics patch // Car fuel gauge graphics patch
MakeCall(0x4C528A, wmInterfaceRefreshCarFuel_hack_empty); MakeCall(0x4C528A, wmInterfaceRefreshCarFuel_hack_empty);
+3 -3
View File
@@ -706,7 +706,7 @@ void Inventory::init() {
MakeJump(fo::funcoffs::adjust_fid_, adjust_fid_hack_replacement); MakeJump(fo::funcoffs::adjust_fid_, adjust_fid_hack_replacement);
long weightWidth = 135; long widthWeight = 135;
sizeLimitMode = GetConfigInt("Misc", "CritterInvSizeLimitMode", 0); sizeLimitMode = GetConfigInt("Misc", "CritterInvSizeLimitMode", 0);
if (sizeLimitMode > 0 && sizeLimitMode <= 7) { if (sizeLimitMode > 0 && sizeLimitMode <= 7) {
@@ -740,7 +740,7 @@ void Inventory::init() {
SafeWrite32(0x4725F9, 0x9C + 0x0C); SafeWrite32(0x4725F9, 0x9C + 0x0C);
SafeWrite8(0x472606, 0x10 + 0x0C); SafeWrite8(0x472606, 0x10 + 0x0C);
SafeWrite8(0x472638, 0); // x offset position SafeWrite8(0x472638, 0); // x offset position
weightWidth = 150; widthWeight = 150;
// Display item size when examining // Display item size when examining
HookCall(0x472FFE, inven_obj_examine_func_hook); HookCall(0x472FFE, inven_obj_examine_func_hook);
@@ -758,7 +758,7 @@ void Inventory::init() {
} }
} }
// Adjust the max text width of the total weight display on the inventory screen // Adjust the max text width of the total weight display on the inventory screen
SafeWrite32(0x472632, weightWidth); SafeWrite32(0x472632, widthWeight);
if (GetConfigInt("Misc", "SuperStimExploitFix", 0)) { if (GetConfigInt("Misc", "SuperStimExploitFix", 0)) {
superStimMsg = Translate("sfall", "SuperStimExploitMsg", "You cannot use a super stim on someone who is not injured!"); superStimMsg = Translate("sfall", "SuperStimExploitMsg", "You cannot use a super stim on someone who is not injured!");
+117 -143
View File
@@ -16,13 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <math.h>
#include <stdio.h>
#include "..\main.h" #include "..\main.h"
#include "..\FalloutEngine\Fallout2.h" #include "..\FalloutEngine\Fallout2.h"
#include "..\SimplePatch.h" #include "..\SimplePatch.h"
#include "ScriptExtender.h"
#include "LoadGameHook.h" #include "LoadGameHook.h"
#include "MiscPatches.h" #include "MiscPatches.h"
@@ -30,31 +26,13 @@
namespace sfall namespace sfall
{ {
// TODO: split this into smaller files static char mapName[65] = {};
static char configName[65] = {};
static char mapName[65]; static char patchName[65] = {};
static char configName[65]; static char versionString[65] = {};
static char patchName[65];
static char versionString[65];
static int* scriptDialog = nullptr; static int* scriptDialog = nullptr;
static const DWORD PutAwayWeapon[] = {
0x411EA2, // action_climb_ladder_
0x412046, // action_use_an_item_on_object_
0x41224A, // action_get_an_object_
0x4606A5, // intface_change_fid_animate_
0x472996, // invenWieldFunc_
};
static const DWORD script_dialog_msgs[] = {
0x4A50C2, 0x4A5169, 0x4A52FA, 0x4A5302, 0x4A6B86, 0x4A6BE0, 0x4A6C37,
};
static const DWORD walkDistanceAddr[] = {
0x411FF0, 0x4121C4, 0x412475, 0x412906,
};
static void __declspec(naked) WeaponAnimHook() { static void __declspec(naked) WeaponAnimHook() {
__asm { __asm {
cmp edx, 11; cmp edx, 11;
@@ -72,88 +50,88 @@ c15:
} }
static void __declspec(naked) register_object_take_out_hack() { static void __declspec(naked) register_object_take_out_hack() {
using namespace fo::Fields;
__asm { __asm {
push ecx push ecx;
push eax push eax;
mov ecx, edx // ID1 mov ecx, edx; // ID1
mov edx, [eax + 0x1C] // cur_rot mov edx, [eax + rotation]; // cur_rot
inc edx inc edx;
push edx // ID3 push edx; // ID3
xor ebx, ebx // ID2 xor ebx, ebx; // ID2
mov edx, [eax + 0x20] // fid mov edx, [eax + artFid]; // fid
and edx, 0xFFF // Index and edx, 0xFFF; // Index
xor eax, eax xor eax, eax;
inc eax // Obj_Type inc eax; // Obj_Type CRITTER
call fo::funcoffs::art_id_ call fo::funcoffs::art_id_;
xor ebx, ebx mov edx, eax;
dec ebx xor ebx, ebx;
xchg edx, eax dec ebx; // delay -1
pop eax pop eax; // critter
call fo::funcoffs::register_object_change_fid_ call fo::funcoffs::register_object_change_fid_;
pop ecx pop ecx;
xor eax, eax xor eax, eax;
retn retn;
} }
} }
static void __declspec(naked) gdAddOptionStr_hack() { static void __declspec(naked) gdAddOptionStr_hack() {
__asm { __asm {
mov ecx, ds:[FO_VAR_gdNumOptions] mov ecx, ds:[FO_VAR_gdNumOptions];
add ecx, '1' add ecx, '1';
push ecx push ecx;
push 0x4458FA mov ecx, 0x4458FA;
retn jmp ecx;
} }
} }
static void __declspec(naked) ScienceCritterCheckHook() { static void __declspec(naked) action_use_skill_on_hook_science() {
using namespace fo;
__asm { __asm {
cmp esi, ds:[FO_VAR_obj_dude]; cmp esi, ds:[FO_VAR_obj_dude];
jne end; jne end;
mov eax, 10; mov eax, robot_type; // KillType
retn; retn;
end: end:
jmp fo::funcoffs::critter_kill_count_type_; jmp fo::funcoffs::critter_kill_count_type_;
} }
} }
static void __declspec(naked) ReloadHook() { static void __declspec(naked) intface_item_reload_hook() {
__asm { __asm {
push eax; push eax;
push ebx; mov eax, dword ptr ds:[FO_VAR_obj_dude];
push edx;
mov eax, dword ptr ds:[FO_VAR_obj_dude];
call fo::funcoffs::register_clear_; call fo::funcoffs::register_clear_;
xor eax, eax; test eax, eax;
inc eax; jnz fail;
inc eax;
call fo::funcoffs::register_begin_; call fo::funcoffs::register_begin_;
xor edx, edx; xor edx, edx;
xor ebx, ebx; xor ebx, ebx;
mov eax, dword ptr ds:[FO_VAR_obj_dude]; mov eax, dword ptr ds:[FO_VAR_obj_dude];
dec ebx; dec ebx;
call fo::funcoffs::register_object_animate_; call fo::funcoffs::register_object_animate_;
call fo::funcoffs::register_end_; call fo::funcoffs::register_end_;
pop edx; fail:
pop ebx; pop eax;
pop eax; jmp fo::funcoffs::gsound_play_sfx_file_;
jmp fo::funcoffs::gsound_play_sfx_file_;
} }
} }
static const DWORD ScannerHookRet = 0x41BC1D; static const DWORD ScannerHookRet = 0x41BC1D;
static const DWORD ScannerHookFail = 0x41BC65; static const DWORD ScannerHookFail = 0x41BC65;
static void __declspec(naked) ScannerAutomapHook() { static void __declspec(naked) automap_hack() {
using fo::PID_MOTION_SENSOR; using fo::PID_MOTION_SENSOR;
__asm { __asm {
mov eax, ds:[FO_VAR_obj_dude]; mov eax, ds:[FO_VAR_obj_dude];
mov edx, PID_MOTION_SENSOR; mov edx, PID_MOTION_SENSOR;
call fo::funcoffs::inven_pid_is_carried_ptr_; call fo::funcoffs::inven_pid_is_carried_ptr_;
test eax, eax; test eax, eax;
jz fail; jz fail;
mov edx, eax; mov edx, eax;
jmp ScannerHookRet; jmp ScannerHookRet;
fail: fail:
jmp ScannerHookFail; jmp ScannerHookFail;
} }
} }
@@ -185,12 +163,12 @@ static void __declspec(naked) display_stats_hook() {
__asm { __asm {
push eax; push eax;
push ecx; push ecx;
mov ecx, ds:[esp + edi + 0xA8 + 0xC]; // get itemPtr mov ecx, ds:[esp + edi + 0xA8 + 0xC]; // get itemPtr
call GetWeaponSlotMode; // ecx - itemPtr, edx - mode; call GetWeaponSlotMode; // ecx - itemPtr, edx - mode;
mov edx, eax; mov edx, eax;
pop ecx; pop ecx;
pop eax; pop eax;
jmp fo::funcoffs::item_w_range_; jmp fo::funcoffs::item_w_range_;
} }
} }
@@ -234,19 +212,19 @@ static void __declspec(naked) switch_hand_hack() {
__asm { __asm {
pushfd; pushfd;
test ebx, ebx; test ebx, ebx;
jz skip; jz skip;
cmp ebx, edx; cmp ebx, edx;
jz skip; jz skip;
push ecx; push ecx;
mov ecx, eax; mov ecx, eax;
call SwapHandSlots; call SwapHandSlots;
pop ecx; pop ecx;
skip: skip:
popfd; popfd;
jz end; jz end;
retn; retn;
end: end:
mov dword ptr [esp], 0x4715B7; mov dword ptr [esp], 0x4715B7;
retn; retn;
} }
} }
@@ -269,26 +247,21 @@ end:
} }
} }
static const DWORD EncounterTableSize[] = {
0x4BD1A3, 0x4BD1D9, 0x4BD270, 0x4BD604, 0x4BDA14, 0x4BDA44, 0x4BE707,
0x4C0815, 0x4C0D4A, 0x4C0FD4,
};
void AdditionalWeaponAnimsPatch() { void AdditionalWeaponAnimsPatch() {
if (GetConfigInt("Misc", "AdditionalWeaponAnims", 0)) { if (GetConfigInt("Misc", "AdditionalWeaponAnims", 0)) {
dlog("Applying additional weapon animations patch.", DL_INIT); dlog("Applying additional weapon animations patch.", DL_INIT);
SafeWrite8(0x419320, 0x12); SafeWrite8(0x419320, 18); // art_get_code_
HookCall(0x4194CC, WeaponAnimHook); HookCalls(WeaponAnimHook, {
HookCall(0x451648, WeaponAnimHook); 0x451648, 0x451671, // gsnd_build_character_sfx_name_
HookCall(0x451671, WeaponAnimHook); 0x4194CC // art_get_name_
});
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
} }
void SkilldexImagesPatch() { void SkilldexImagesPatch() {
DWORD tmp;
dlog("Checking for changed skilldex images.", DL_INIT); dlog("Checking for changed skilldex images.", DL_INIT);
tmp = GetConfigInt("Misc", "Lockpick", 293); long tmp = GetConfigInt("Misc", "Lockpick", 293);
if (tmp != 293) { if (tmp != 293) {
SafeWrite32(0x518D54, tmp); SafeWrite32(0x518D54, tmp);
} }
@@ -322,15 +295,19 @@ void SkilldexImagesPatch() {
void ScienceOnCrittersPatch() { void ScienceOnCrittersPatch() {
switch (GetConfigInt("Misc", "ScienceOnCritters", 0)) { switch (GetConfigInt("Misc", "ScienceOnCritters", 0)) {
case 1: case 1:
HookCall(0x41276E, ScienceCritterCheckHook); HookCall(0x41276E, action_use_skill_on_hook_science);
break; break;
case 2: case 2:
SafeWrite8(0x41276A, 0xeb); SafeWrite8(0x41276A, 0xEB);
break; break;
} }
} }
void BoostScriptDialogLimitPatch() { void BoostScriptDialogLimitPatch() {
const DWORD script_dialog_msgs[] = {
0x4A50C2, 0x4A5169, 0x4A52FA, 0x4A5302, 0x4A6B86, 0x4A6BE0, 0x4A6C37,
};
if (GetConfigInt("Misc", "BoostScriptDialogLimit", 0)) { if (GetConfigInt("Misc", "BoostScriptDialogLimit", 0)) {
const int scriptDialogCount = 10000; const int scriptDialogCount = 10000;
dlog("Applying script dialog limit patch.", DL_INIT); dlog("Applying script dialog limit patch.", DL_INIT);
@@ -338,9 +315,7 @@ void BoostScriptDialogLimitPatch() {
SafeWrite32(0x4A50E3, scriptDialogCount); // scr_init SafeWrite32(0x4A50E3, scriptDialogCount); // scr_init
SafeWrite32(0x4A519F, scriptDialogCount); // scr_game_init SafeWrite32(0x4A519F, scriptDialogCount); // scr_game_init
SafeWrite32(0x4A534F, scriptDialogCount * 8); // scr_message_free SafeWrite32(0x4A534F, scriptDialogCount * 8); // scr_message_free
for (int i = 0; i < sizeof(script_dialog_msgs) / 4; i++) { SafeWriteBatch<DWORD>((DWORD)scriptDialog, script_dialog_msgs); // scr_get_dialog_msg_file
SafeWrite32(script_dialog_msgs[i], (DWORD)scriptDialog); // scr_get_dialog_msg_file
}
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
} }
@@ -361,15 +336,21 @@ void NumbersInDialoguePatch() {
} }
void InstantWeaponEquipPatch() { void InstantWeaponEquipPatch() {
const DWORD PutAwayWeapon[] = {
0x411EA2, // action_climb_ladder_
0x412046, // action_use_an_item_on_object_
0x41224A, // action_get_an_object_
0x4606A5, // intface_change_fid_animate_
0x472996, // invenWieldFunc_
};
if (GetConfigInt("Misc", "InstantWeaponEquip", 0)) { if (GetConfigInt("Misc", "InstantWeaponEquip", 0)) {
//Skip weapon equip/unequip animations //Skip weapon equip/unequip animations
dlog("Applying instant weapon equip patch.", DL_INIT); dlog("Applying instant weapon equip patch.", DL_INIT);
for (int i = 0; i < sizeof(PutAwayWeapon) / 4; i++) { SafeWriteBatch<BYTE>(0xEB, PutAwayWeapon); // jmps
SafeWrite8(PutAwayWeapon[i], 0xEB); // jmps BlockCall(0x472AD5); //
} BlockCall(0x472AE0); // invenUnwieldFunc_
BlockCall(0x472AD5); // BlockCall(0x472AF0); //
BlockCall(0x472AE0); // invenUnwieldFunc_
BlockCall(0x472AF0); //
MakeJump(0x415238, register_object_take_out_hack); MakeJump(0x415238, register_object_take_out_hack);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
@@ -386,16 +367,15 @@ void DontTurnOffSneakIfYouRunPatch() {
void PlayIdleAnimOnReloadPatch() { void PlayIdleAnimOnReloadPatch() {
if (GetConfigInt("Misc", "PlayIdleAnimOnReload", 0)) { if (GetConfigInt("Misc", "PlayIdleAnimOnReload", 0)) {
dlog("Applying idle anim on reload patch.", DL_INIT); dlog("Applying idle anim on reload patch.", DL_INIT);
HookCall(0x460B8C, ReloadHook); HookCall(0x460B8C, intface_item_reload_hook);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
} }
void MotionScannerFlagsPatch() { void MotionScannerFlagsPatch() {
DWORD flags; if (long flags = GetConfigInt("Misc", "MotionScannerFlags", 1)) {
if (flags = GetConfigInt("Misc", "MotionScannerFlags", 1)) {
dlog("Applying MotionScannerFlags patch.", DL_INIT); dlog("Applying MotionScannerFlags patch.", DL_INIT);
if (flags & 1) MakeJump(0x41BBE9, ScannerAutomapHook); if (flags & 1) MakeJump(0x41BBE9, automap_hack);
if (flags & 2) { if (flags & 2) {
// automap_ // automap_
SafeWrite16(0x41BC24, 0x9090); SafeWrite16(0x41BC24, 0x9090);
@@ -408,14 +388,17 @@ void MotionScannerFlagsPatch() {
} }
void EncounterTableSizePatch() { void EncounterTableSizePatch() {
const DWORD EncounterTableSize[] = {
0x4BD1A3, 0x4BD1D9, 0x4BD270, 0x4BD604, 0x4BDA14, 0x4BDA44, 0x4BE707,
0x4C0815, 0x4C0D4A, 0x4C0FD4,
};
DWORD tableSize = GetConfigInt("Misc", "EncounterTableSize", 0); DWORD tableSize = GetConfigInt("Misc", "EncounterTableSize", 0);
if (tableSize > 40 && tableSize <= 127) { if (tableSize > 40 && tableSize <= 127) {
dlog("Applying EncounterTableSize patch.", DL_INIT); dlog("Applying EncounterTableSize patch.", DL_INIT);
SafeWrite8(0x4BDB17, (BYTE)tableSize); SafeWrite8(0x4BDB17, (BYTE)tableSize);
DWORD nsize = (tableSize + 1) * 180 + 0x50; DWORD nsize = (tableSize + 1) * 180 + 0x50;
for (int i = 0; i < sizeof(EncounterTableSize) / 4; i++) { SafeWriteBatch<DWORD>(nsize, EncounterTableSize);
SafeWrite32(EncounterTableSize[i], nsize);
}
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
} }
@@ -439,13 +422,10 @@ void ObjCanSeeShootThroughPatch() {
static const char* musicOverridePath = "data\\sound\\music\\"; static const char* musicOverridePath = "data\\sound\\music\\";
void OverrideMusicDirPatch() { void OverrideMusicDirPatch() {
DWORD overrideMode; if (long overrideMode = GetConfigInt("Sound", "OverrideMusicDir", 0)) {
if (overrideMode = GetConfigInt("Sound", "OverrideMusicDir", 0)) { SafeWriteBatch<DWORD>((DWORD)musicOverridePath, {0x4449C2, 0x4449DB});
SafeWrite32(0x4449C2, (DWORD)musicOverridePath);
SafeWrite32(0x4449DB, (DWORD)musicOverridePath);
if (overrideMode == 2) { if (overrideMode == 2) {
SafeWrite32(0x518E78, (DWORD)musicOverridePath); SafeWriteBatch<DWORD>((DWORD)musicOverridePath, {0x518E78, 0x518E7C});
SafeWrite32(0x518E7C, (DWORD)musicOverridePath);
} }
} }
} }
@@ -474,7 +454,7 @@ void RemoveWindowRoundingPatch() {
} }
void InventoryCharacterRotationSpeedPatch() { void InventoryCharacterRotationSpeedPatch() {
DWORD setting = GetConfigInt("Misc", "SpeedInventoryPCRotation", 166); long setting = GetConfigInt("Misc", "SpeedInventoryPCRotation", 166);
if (setting != 166 && setting <= 1000) { if (setting != 166 && setting <= 1000) {
dlog("Applying SpeedInventoryPCRotation patch.", DL_INIT); dlog("Applying SpeedInventoryPCRotation patch.", DL_INIT);
SafeWrite32(0x47066B, setting); SafeWrite32(0x47066B, setting);
@@ -483,18 +463,20 @@ void InventoryCharacterRotationSpeedPatch() {
} }
void UIAnimationSpeedPatch() { void UIAnimationSpeedPatch() {
DWORD addrs[2] = {0x45F9DE, 0x45FB33}; DWORD addrs[] = {
0x45F9DE, 0x45FB33,
0x447DF4, 0x447EB6,
0x499B99, 0x499DA8
};
SimplePatch<WORD>(addrs, 2, "Misc", "CombatPanelAnimDelay", 1000, 0, 65535); SimplePatch<WORD>(addrs, 2, "Misc", "CombatPanelAnimDelay", 1000, 0, 65535);
addrs[0] = 0x447DF4; addrs[1] = 0x447EB6; SimplePatch<BYTE>(&addrs[2], 2, "Misc", "DialogPanelAnimDelay", 33, 0, 255);
SimplePatch<BYTE>(addrs, 2, "Misc", "DialogPanelAnimDelay", 33, 0, 255); SimplePatch<BYTE>(&addrs[4], 2, "Misc", "PipboyTimeAnimDelay", 50, 0, 127);
addrs[0] = 0x499B99; addrs[1] = 0x499DA8;
SimplePatch<BYTE>(addrs, 2, "Misc", "PipboyTimeAnimDelay", 50, 0, 127);
} }
void MusicInDialoguePatch() { void MusicInDialoguePatch() {
if (GetConfigInt("Misc", "EnableMusicInDialogue", 0)) { if (GetConfigInt("Misc", "EnableMusicInDialogue", 0)) {
dlog("Applying music in dialogue patch.", DL_INIT); dlog("Applying music in dialogue patch.", DL_INIT);
SafeWrite8(0x44525B, 0x0); SafeWrite8(0x44525B, 0);
//BlockCall(0x450627); //BlockCall(0x450627);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
@@ -523,7 +505,7 @@ void DisableHorriganPatch() {
} }
void DisplaySecondWeaponRangePatch() { void DisplaySecondWeaponRangePatch() {
if (GetConfigInt("Misc", "DisplaySecondWeaponRange", 1)) { if (GetConfigInt("Misc", "DisplaySecondWeaponRange", 1)) { // TODO: remove option?
dlog("Applying display second weapon range patch.", DL_INIT); dlog("Applying display second weapon range patch.", DL_INIT);
HookCall(0x472201, display_stats_hook); HookCall(0x472201, display_stats_hook);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
@@ -581,7 +563,7 @@ void UseWalkDistancePatch() {
int distance = GetConfigInt("Misc", "UseWalkDistance", 3) + 2; int distance = GetConfigInt("Misc", "UseWalkDistance", 3) + 2;
if (distance > 1 && distance < 5) { if (distance > 1 && distance < 5) {
dlog("Applying walk distance for using objects patch.", DL_INIT); dlog("Applying walk distance for using objects patch.", DL_INIT);
SafeWriteBatch<BYTE>(distance, walkDistanceAddr); // default is 5 SafeWriteBatch<BYTE>(distance, {0x411FF0, 0x4121C4, 0x412475, 0x412906}); // default is 5
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
} }
@@ -596,29 +578,24 @@ void F1EngineBehaviorPatch() {
} }
void MiscPatches::init() { void MiscPatches::init() {
mapName[64] = 0;
if (GetConfigString("Misc", "StartingMap", "", mapName, 64)) { if (GetConfigString("Misc", "StartingMap", "", mapName, 64)) {
dlog("Applying starting map patch.", DL_INIT); dlog("Applying starting map patch.", DL_INIT);
SafeWrite32(0x480AAA, (DWORD)&mapName); SafeWrite32(0x480AAA, (DWORD)&mapName);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
versionString[64] = 0;
if (GetConfigString("Misc", "VersionString", "", versionString, 64)) { if (GetConfigString("Misc", "VersionString", "", versionString, 64)) {
dlog("Applying version string patch.", DL_INIT); dlog("Applying version string patch.", DL_INIT);
SafeWrite32(0x4B4588, (DWORD)&versionString); SafeWrite32(0x4B4588, (DWORD)&versionString);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
configName[64] = 0;
if (GetConfigString("Misc", "ConfigFile", "", configName, 64)) { if (GetConfigString("Misc", "ConfigFile", "", configName, 64)) {
dlog("Applying config file patch.", DL_INIT); dlog("Applying config file patch.", DL_INIT);
SafeWrite32(0x444BA5, (DWORD)&configName); SafeWriteBatch<DWORD>((DWORD)&configName, {0x444BA5, 0x444BCA});
SafeWrite32(0x444BCA, (DWORD)&configName);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
patchName[64] = 0;
if (GetConfigString("Misc", "PatchFile", "", patchName, 64)) { if (GetConfigString("Misc", "PatchFile", "", patchName, 64)) {
dlog("Applying patch file patch.", DL_INIT); dlog("Applying patch file patch.", DL_INIT);
SafeWrite32(0x444323, (DWORD)&patchName); SafeWrite32(0x444323, (DWORD)&patchName);
@@ -640,8 +617,7 @@ void MiscPatches::init() {
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
int time = GetConfigInt("Misc", "CorpseDeleteTime", 6); // time in days if (int time = GetConfigInt("Misc", "CorpseDeleteTime", 6) != 6) { // time in days
if (time != 6) {
dlog("Applying corpse deletion time patch.", DL_INIT); dlog("Applying corpse deletion time patch.", DL_INIT);
if (time <= 0) { if (time <= 0) {
time = 12; // hours time = 12; // hours
@@ -710,9 +686,7 @@ void MiscPatches::init() {
} }
void MiscPatches::exit() { void MiscPatches::exit() {
if (scriptDialog != nullptr) { if (scriptDialog) delete[] scriptDialog;
delete[] scriptDialog;
}
} }
} }
+4 -8
View File
@@ -26,33 +26,29 @@
namespace sfall namespace sfall
{ {
static char startMaleModelName[65]; static char startMaleModelName[65] = {};
char defaultMaleModelName[65]; char defaultMaleModelName[65] = {};
static char startFemaleModelName[65]; static char startFemaleModelName[65] = {};
char defaultFemaleModelName[65]; char defaultFemaleModelName[65] = {};
void PlayerModel::init() { void PlayerModel::init() {
startMaleModelName[64] = 0;
if (GetConfigString("Misc", "MaleStartModel", "", startMaleModelName, 64)) { if (GetConfigString("Misc", "MaleStartModel", "", startMaleModelName, 64)) {
dlog("Applying male start model patch.", DL_INIT); dlog("Applying male start model patch.", DL_INIT);
SafeWrite32(0x418B88, (DWORD)&startMaleModelName); SafeWrite32(0x418B88, (DWORD)&startMaleModelName);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
startFemaleModelName[64] = 0;
if (GetConfigString("Misc", "FemaleStartModel", "", startFemaleModelName, 64)) { if (GetConfigString("Misc", "FemaleStartModel", "", startFemaleModelName, 64)) {
dlog("Applying female start model patch.", DL_INIT); dlog("Applying female start model patch.", DL_INIT);
SafeWrite32(0x418BAB, (DWORD)&startFemaleModelName); SafeWrite32(0x418BAB, (DWORD)&startFemaleModelName);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
defaultMaleModelName[64] = 0;
GetConfigString("Misc", "MaleDefaultModel", "hmjmps", defaultMaleModelName, 64); GetConfigString("Misc", "MaleDefaultModel", "hmjmps", defaultMaleModelName, 64);
dlog("Applying male model patch.", DL_INIT); dlog("Applying male model patch.", DL_INIT);
SafeWrite32(0x418B50, (DWORD)&defaultMaleModelName); SafeWrite32(0x418B50, (DWORD)&defaultMaleModelName);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
defaultFemaleModelName[64] = 0;
GetConfigString("Misc", "FemaleDefaultModel", "hfjmps", defaultFemaleModelName, 64); GetConfigString("Misc", "FemaleDefaultModel", "hfjmps", defaultFemaleModelName, 64);
dlog("Applying female model patch.", DL_INIT); dlog("Applying female model patch.", DL_INIT);
SafeWrite32(0x418B6D, (DWORD)&defaultFemaleModelName); SafeWrite32(0x418B6D, (DWORD)&defaultFemaleModelName);