Added DataLoadOrderPatch option to use a modified data load order for the engine to find game data (from Crafty's mod)

Updated version number.
This commit is contained in:
NovaRain
2016-10-11 11:58:17 +08:00
parent c880ae93a9
commit de5c12484d
6 changed files with 95 additions and 9 deletions
+8 -3
View File
@@ -1,5 +1,5 @@
;sfall configuration settings
;v3.7.3
;v3.7.4
[Main]
;Change to 1 if you want to use command line args to tell sfall to use another ini file.
@@ -201,10 +201,15 @@ WorldMapSlots=0
;To use a patch file other than patch000.dat, uncomment the next line and add your new file name
;If you want to check for multiple patch files, you can include a %d in the file name (sprintf syntax)
;By default, only the first patch file found will be used.
;If you want to load multiple patch files at once, uncomment the MultiPatches line and set it to 1
;If you want to load multiple patch files (up to 1000) at once, uncomment the MultiPatches line and set it to 1
;PatchFile=patch%03d.dat
;MultiPatches=0
;Set to 1 to enable the modified data load order for the engine to find game data
;Original: patchXXX.dat > critter_patches > critter_dat > f2_res_patches > f2_res_dat > master_patches > master_dat
;Modified: master_patches > critter_patches > patchXXX.dat > critter_dat > f2_res_patches > f2_res_dat > master_dat
DataLoadOrderPatch=0
;To change the default and starting player models, uncomment the next four lines.
;The default models can also be changed ingame via script
;MaleStartModel=hmwarr
@@ -477,7 +482,7 @@ QuickPocketsApCostReduction=2
;Set to 1 to allow objects seeing through other objects with their ShootThru flag set
ObjCanSeeObj_ShootThru_Fix=0
;Set to 1 to use the balanced bullet distribution formula for burst attacks
;Set to 1 to enable the balanced bullet distribution formula for burst attacks
ComputeSprayMod=1
;These options modify the bullet distribution of burst attacks if ComputeSprayMod is 1
+2
View File
@@ -375,6 +375,7 @@ const DWORD stat_pc_add_experience_ = 0x4AFAA8;
const DWORD stat_pc_get_ = 0x4AF8FC;
const DWORD stat_pc_set_ = 0x4AF910;
const DWORD stat_set_bonus_ = 0x4AF63C;
const DWORD stricmp_ = 0x4DECE6;
const DWORD strncpy_ = 0x4F014F;
const DWORD switch_hand_ = 0x4714E0;
const DWORD talk_to_translucent_trans_buf_to_buf_ = 0x44AC68;
@@ -419,6 +420,7 @@ const DWORD xfread_ = 0x4DF44C;
const DWORD xfseek_ = 0x4DF5D8;
const DWORD xftell_ = 0x4DF690;
const DWORD xfwrite_ = 0x4DF4E8;
const DWORD xremovepath_ = 0x4DFAB4;
const DWORD xrewind_ = 0x4DF6E4;
const DWORD xungetc_ = 0x4DF3F4;
const DWORD xvfprintf_ = 0x4DF1AC;
+4
View File
@@ -46,6 +46,7 @@
#define _combat_turn_running 0x51093C
#define _combatNumTurns 0x510940
#define _crit_succ_eff 0x510978
#define _critter_db_handle 0x58E94C
#define _critterClearObj 0x518438
#define _crnt_func 0x664508
#define _curr_font_num 0x51E3B0
@@ -113,6 +114,7 @@
#define _main_window 0x5194F0
#define _map_elevation 0x519578
#define _map_global_vars 0x51956C
#define _master_db_handle 0x58E948
#define _max 0x56FB50
#define _Meet_Frank_Horrigan 0x672E04
#define _mouse_hotx 0x6AC7D0
@@ -539,6 +541,7 @@ extern const DWORD stat_pc_add_experience_;
extern const DWORD stat_pc_get_;
extern const DWORD stat_pc_set_;
extern const DWORD stat_set_bonus_;
extern const DWORD stricmp_;
extern const DWORD strncpy_;
extern const DWORD switch_hand_;
extern const DWORD talk_to_translucent_trans_buf_to_buf_;
@@ -583,6 +586,7 @@ extern const DWORD xfread_;
extern const DWORD xfseek_;
extern const DWORD xftell_;
extern const DWORD xfwrite_;
extern const DWORD xremovepath_;
extern const DWORD xrewind_;
extern const DWORD xungetc_;
extern const DWORD xvfprintf_;
+1 -3
View File
@@ -170,9 +170,7 @@ void _stdcall SetShaderMode(DWORD d, DWORD mode) {
}
int _stdcall LoadShader(const char* path) {
if(GraphicsMode < 4) return -1;
if(strstr(path, "..")) return -1;
if(strstr(path, ":")) return -1;
if ((GraphicsMode < 4) || (strstr(path, "..")) || (strstr(path, ":"))) return -1;
char buf[MAX_PATH];
sprintf(buf, "%s\\shaders\\%s", *(char**)_patches, path);
for(DWORD d=0;d<shaders.size();d++) {
+77
View File
@@ -417,6 +417,74 @@ c15:
jmp art_get_code_;
}
}
static void __declspec(naked) removeDatabase() {
__asm {
cmp eax, -1
je end
mov ebx, ds:[_paths]
mov ecx, ebx
nextPath:
mov edx, [esp+0x104+4+4] // path_patches
mov eax, [ebx+0x0] // database.path
call stricmp_
test eax, eax // found path?
jz skip // Yes
mov ecx, ebx
mov ebx, [ebx+0xC] // database.next
jmp nextPath
skip:
mov eax, [ebx+0xC] // database.next
mov [ecx+0xC], eax // database.next
xchg ebx, eax
cmp eax, ecx
jne end
mov ds:[_paths], ebx
end:
retn
}
}
static void __declspec(naked) game_init_databases_hack1() {
__asm {
call removeDatabase
mov ds:[_master_db_handle], eax
retn
}
}
static void __declspec(naked) game_init_databases_hack2() {
__asm {
cmp eax, -1
je end
mov eax, ds:[_master_db_handle]
mov eax, [eax+0x0] // eax = master_patches.path
call xremovepath_
dec eax // remove path (critter_patches == master_patches)?
jz end // Yes
inc eax
call removeDatabase
end:
mov ds:[_critter_db_handle], eax
retn
}
}
static void __declspec(naked) game_init_databases_hook() {
// eax = _master_db_handle
__asm {
mov ecx, ds:[_critter_db_handle]
mov edx, ds:[_paths]
jecxz skip
mov [ecx+0xC], edx // critter_patches.next->_paths
mov edx, ecx
skip:
mov [eax+0xC], edx // master_patches.next
mov ds:[_paths], eax
retn
}
}
static char KarmaGainMsg[128];
static char KarmaLossMsg[128];
static void _stdcall SetKarma(int value) {
@@ -1215,6 +1283,15 @@ static void DllMain2() {
dlogr(" Done", DL_INIT);
}
if (GetPrivateProfileIntA("Misc", "DataLoadOrderPatch", 0, ini)) {
dlog("Applying data load order patch.", DL_INIT);
MakeCall(0x444259, &game_init_databases_hack1, false);
MakeCall(0x4442F1, &game_init_databases_hack2, false);
HookCall(0x44436D, &game_init_databases_hook);
SafeWrite8(0x4DFAEC, 0x1D); // error correction
dlogr(" Done", DL_INIT);
}
if(GetPrivateProfileInt("Misc", "DisplayKarmaChanges", 0, ini)) {
dlog("Applying display karma changes patch.", DL_INIT);
GetPrivateProfileString("sfall", "KarmaGain", "You gained %d karma.", KarmaGainMsg, 128, translationIni);
+3 -3
View File
@@ -22,12 +22,12 @@
#define VERSION_MAJOR 3
#define VERSION_MINOR 7
#define VERSION_BUILD 3
#define VERSION_BUILD 4
#define VERSION_REV 0
#ifdef WIN2K
#define VERSION_STRING "3.7.3 win2k"
#define VERSION_STRING "3.7.4 win2k"
#else
#define VERSION_STRING "3.7.3"
#define VERSION_STRING "3.7.4"
#endif
#define CHECK_VAL (4)