Fixed the path to load global shaders in the previous commit

* when DataLoadOrderPatch is disabled, the path was set to
"sfall.dat\shaders\".
This commit is contained in:
NovaRain
2019-12-15 09:56:47 +08:00
parent 9f3299b47a
commit 7ed8dd286c
7 changed files with 28 additions and 13 deletions
+1 -1
View File
@@ -81,7 +81,7 @@ GraphicsWidth=0
GraphicsHeight=0
;Uncomment the option to use a hardware shader (requires DX9 graphics mode 4 or 5)
;The shader file <name>.fx must be placed in data\shaders\ and must contain one technique with one or more passes
;The shader file <name>.fx must be placed in <GameRoot>\<master_patches>\shaders\ and must contain one technique with one or more passes
;GlobalShaderFile=global.fx
;Set to 1 to do the palette conversion on the GPU
+1 -1
View File
@@ -24,7 +24,7 @@ The input functions are only available if the user has the input hook turned on
The graphics functions are only available if the user is using graphics mode 4 or 5. Use graphics_funcs_available to check; it returns 1 if you can use them or 0 if you can't. Calling graphics functions when graphics_funcs_available returns 0 will do nothing.
load_shader takes a path relative to the data\shaders\ directory as an argument and returns a shader ID. That ID should be passed as the first argument to all other shader functions, and is valid until free_shader is called on the ID, the player loads a saved game or the player quits to the main menu.
load_shader takes a path relative to the <GameRoot>\<master_patches>\shaders\ directory as an argument and returns a shader ID. That ID should be passed as the first argument to all other shader functions, and is valid until free_shader is called on the ID, the player loads a saved game or the player quits to the main menu.
get_shader_version gives you the highest shader version supported by the player's graphics cards. Possible return values are 11, 12, 13, 14, 20, 21 and 30.
+1
View File
@@ -77,6 +77,7 @@
#define FO_VAR_game_global_vars 0x5186C0
#define FO_VAR_game_ui_disabled 0x5186B4
#define FO_VAR_game_user_wants_to_quit 0x5186CC
#define FO_VAR_gconfig_file_name 0x58E978
#define FO_VAR_gcsd 0x51094C
#define FO_VAR_gdBarterMod 0x51873C
#define FO_VAR_gDialogMusicVol 0x5187D8
+2 -2
View File
@@ -27,7 +27,7 @@ VAR_(combat_state, DWORD)
VAR_(combat_turn_running, DWORD)
VAR_(combatNumTurns, DWORD)
VAR3(crit_succ_eff, CritInfo, 20, 9, 6) // 20 critters with 9 body parts and 6 effects each
VAR_(critter_db_handle, DWORD)
VAR_(critter_db_handle, PathNode*)
VAR_(critterClearObj, DWORD)
VAR_(crnt_func, DWORD)
VAR_(curr_font_num, DWORD)
@@ -108,7 +108,7 @@ VAR_(main_ctd, DWORD)
VAR_(main_window, DWORD)
VAR_(map_elevation, DWORD)
VAR_(map_global_vars, long*) // array
VAR_(master_db_handle, DWORD)
VAR_(master_db_handle, PathNode*)
VAR_(max, DWORD)
VAR_(maxScriptNum, long)
VAR_(Meet_Frank_Horrigan, bool)
+1 -1
View File
@@ -1006,11 +1006,11 @@ void Graphics::init() {
if (!h) {
MessageBoxA(0, "You have selected graphics mode 4 or 5, but " _DLL_NAME " is missing.\n"
"Switch back to mode 0, or install an up to date version of DirectX.", "Error", MB_TASKMODAL | MB_ICONERROR);
#undef _DLL_NAME
ExitProcess(-1);
} else {
FreeLibrary(h);
}
#undef _DLL_NAME
SafeWrite8(0x50FB6B, '2'); // Set call DirectDrawCreate2
HookCall(0x44260C, game_init_hook);
dlogr(" Done", DL_INIT);
+20 -6
View File
@@ -153,7 +153,7 @@ end:
}
}
static void __stdcall InitExtraPatches() {
static void InitExtraPatches() {
for (auto it = patchFiles.begin(); it != patchFiles.end(); it++) {
if (!it->empty()) fo::func::db_init(it->c_str(), 0);
}
@@ -163,11 +163,11 @@ static void __stdcall InitExtraPatches() {
}
static void __fastcall game_init_databases_hook() { // eax = _master_db_handle
fo::PathNode* master_patches = (fo::PathNode*)fo::var::master_db_handle;
fo::PathNode* master_patches = fo::var::master_db_handle;
if (!patchFiles.empty()) InitExtraPatches();
/*if (!patchFiles.empty())*/ InitExtraPatches();
fo::PathNode* critter_patches = (fo::PathNode*)fo::var::critter_db_handle;
fo::PathNode* critter_patches = fo::var::critter_db_handle;
fo::PathNode* paths = fo::var::paths; // beginning of the chain of paths
// insert master_patches/critter_patches at the beginning of the chain of paths
if (critter_patches) {
@@ -178,6 +178,20 @@ static void __fastcall game_init_databases_hook() { // eax = _master_db_handle
fo::var::paths = master_patches; // set master_patches node at the beginning of the chain of paths
}
static void __fastcall game_init_databases_hook1() {
char masterPatch[MAX_PATH];
iniGetString("system", "master_patches", "", masterPatch, MAX_PATH - 1, (const char*)FO_VAR_gconfig_file_name);
fo::PathNode* node = fo::var::paths;
while (node->next) {
if (!_stricmp(node->path, masterPatch)) break;
node = node->next;
}
fo::var::master_db_handle = node; // set pointer to master_patches node
InitExtraPatches();
}
static bool NormalizePath(std::string &path) {
if (path.find(':') != std::string::npos) return false;
int pos = 0;
@@ -388,8 +402,8 @@ void LoadOrder::init() {
HookCall(0x44436D, game_init_databases_hook);
SafeWrite8(0x4DFAEC, 0x1D); // error correction (ecx > ebx)
dlogr(" Done", DL_INIT);
} else if (!patchFiles.empty()) {
HookCall(0x44436D, InitExtraPatches);
} else /*if (!patchFiles.empty())*/ {
HookCall(0x44436D, game_init_databases_hook1);
}
femaleMsgs = GetConfigInt("Misc", "FemaleDialogMsgs", 0);
+2 -2
View File
@@ -61,7 +61,7 @@ void _stdcall SetShaderMode(DWORD d, DWORD mode) {
int _stdcall LoadShader(const char* file) {
if (!Graphics::mode || strstr(file, "..") || strstr(file, ":")) return -1;
char buf[MAX_PATH];
sprintf_s(buf, "%s\\shaders\\%s", fo::var::paths->path, file); // fo::var::patches
sprintf_s(buf, "%s\\shaders\\%s", fo::var::master_db_handle->path, file); // fo::var::patches
for (DWORD d = 0; d < shadersSize; d++) {
if (!shaders[d].Effect) {
if (FAILED(D3DXCreateEffectFromFile(d3d9Device, buf, 0, 0, 0, 0, &shaders[d].Effect, 0))) {
@@ -82,7 +82,7 @@ int _stdcall LoadShader(const char* file) {
sprintf(buf, "texname%d", i);
if (FAILED(shader.Effect->GetString(buf, &name))) break;
sprintf_s(buf, "%s\\art\\stex\\%s", fo::var::patches, name);
sprintf_s(buf, "%s\\art\\stex\\%s", fo::var::master_db_handle->path, name); // fo::var::patches
if (FAILED(D3DXCreateTextureFromFileA(d3d9Device, buf, &tex))) continue;
sprintf(buf, "tex%d", i);
shader.Effect->SetTexture(buf, tex);