mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Fixed the load order of f2_res.dat & sfall.dat
Changed the default graphics mode back to 0 (now DD7).
This commit is contained in:
+1
-1
@@ -330,7 +330,7 @@ void Setting::init(const char* exeFileName, std::string &cmdline) {
|
||||
if (fo::var::getInt(0x475231) == 144) sf::SafeWrite32(0x475231, 164); // x_end
|
||||
}
|
||||
|
||||
// add before sfall.dat and after critter.dat
|
||||
// add: patchXXX.dat > sfall.dat > [add here] > critter.dat > master.dat
|
||||
sf::LoadOrder::AddResourcePatches(
|
||||
sf::IniReader::GetString("Main", "f2_res_dat", "f2_res.dat", MAX_PATH, f2ResIni),
|
||||
sf::IniReader::GetString("Main", "f2_res_patches", "", MAX_PATH, f2ResIni)
|
||||
|
||||
@@ -35,8 +35,7 @@ static long yPosition;
|
||||
static long xOffset;
|
||||
static long xyOffsetCBtn;
|
||||
static long xyOffsetAP;
|
||||
|
||||
bool IFaceBar::UseExpandAPBar = false;
|
||||
static bool expandAPBar = false;
|
||||
|
||||
long IFaceBar::display_width = 0; // width of the area for text output
|
||||
char* IFaceBar::display_string_buf = (char*)FO_VAR_display_string_buf;
|
||||
@@ -204,7 +203,7 @@ static long __cdecl InterfaceArt(BYTE* scr, long w, long h, long srcWidth, BYTE*
|
||||
fo::var::itemButtonRect.offx += xOffset;
|
||||
|
||||
char file[33];
|
||||
std::sprintf(file, "HR_IFACE_%i%s.frm", IFaceBar::IFACE_BAR_WIDTH, ((IFaceBar::UseExpandAPBar) ? "E" : ""));
|
||||
std::sprintf(file, "HR_IFACE_%i%s.frm", IFaceBar::IFACE_BAR_WIDTH, ((expandAPBar) ? "E" : ""));
|
||||
|
||||
auto* frm = fo::util::LoadUnlistedFrm(file, fo::ArtType::OBJ_TYPE_INTRFACE);
|
||||
if (frm && frm->frames->width == IFaceBar::IFACE_BAR_WIDTH) {
|
||||
@@ -218,7 +217,7 @@ static long __cdecl InterfaceArt(BYTE* scr, long w, long h, long srcWidth, BYTE*
|
||||
}
|
||||
|
||||
// no required file, use the default one provided by HRP
|
||||
if (!frm) frm = fo::util::LoadUnlistedFrm(((IFaceBar::UseExpandAPBar) ? "HR_IFACE_800E.frm" : "HR_IFACE_800.frm"), fo::ArtType::OBJ_TYPE_INTRFACE);
|
||||
if (!frm) frm = fo::util::LoadUnlistedFrm(((expandAPBar) ? "HR_IFACE_800E.frm" : "HR_IFACE_800.frm"), fo::ArtType::OBJ_TYPE_INTRFACE);
|
||||
|
||||
if (frm) {
|
||||
// scale the 800px wide interface to the width of IFACE_BAR_WIDTH
|
||||
@@ -471,6 +470,10 @@ static void __declspec(naked) intface_update_ammo_lights_hook() {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void IFaceBar::SetExpandAPBar() {
|
||||
expandAPBar = true;
|
||||
}
|
||||
|
||||
void IFaceBar::Hide() {
|
||||
InterfaceHide(fo::var::getInt(FO_VAR_interfaceWindow));
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public:
|
||||
static long display_width;
|
||||
static char* display_string_buf;
|
||||
|
||||
static bool UseExpandAPBar;
|
||||
static void SetExpandAPBar();
|
||||
|
||||
static void Hide();
|
||||
static void Show();
|
||||
|
||||
@@ -1166,7 +1166,7 @@ void Graphics::BackgroundClearColor(long indxColor) {
|
||||
}
|
||||
|
||||
void Graphics::init() {
|
||||
int gMode = IniReader::GetConfigInt("Graphics", "Mode", 4);
|
||||
int gMode = IniReader::GetConfigInt("Graphics", "Mode", 0);
|
||||
if (gMode >= 4) Graphics::mode = gMode;
|
||||
|
||||
if (Graphics::mode < 0 || Graphics::mode > 6) {
|
||||
@@ -1174,7 +1174,6 @@ void Graphics::init() {
|
||||
}
|
||||
IsWindowedMode = (mode == 2 || mode == 3 || mode == 5 || mode == 6);
|
||||
|
||||
// DirectX9 mode
|
||||
if (Graphics::mode >= 4) {
|
||||
dlog("Applying DX9 graphics patch.", DL_INIT);
|
||||
#define _DLL_NAME "d3dx9_43.dll"
|
||||
|
||||
@@ -148,7 +148,7 @@ static void APBarRectPatch() {
|
||||
}
|
||||
|
||||
static void ActionPointsBarPatch() {
|
||||
HRP::IFaceBar::UseExpandAPBar = true;
|
||||
HRP::IFaceBar::SetExpandAPBar();
|
||||
|
||||
dlog("Applying expanded action points bar patch.", DL_INIT);
|
||||
if (HRP::Setting::ExternalEnabled()) {
|
||||
@@ -838,7 +838,7 @@ static void WorldMapInterfacePatch() {
|
||||
dlogr(" Done", DL_INIT);
|
||||
}
|
||||
|
||||
if (HRP::Setting::IsEnabled() || (/*HRP::Setting::ExternalEnabled() &&*/ HRP::Setting::VersionIsValid)) { // was available only for 4.1.8?
|
||||
if (HRP::Setting::IsEnabled() || HRP::Setting::VersionIsValid) { // was available only for 4.1.8?
|
||||
if (worldmapInterface = IniReader::GetConfigInt("Interface", "ExpandWorldMap", 0)) {
|
||||
LoadGameHook::OnAfterGameInit() += WorldmapViewportPatch; // Note: must be applied after WorldMapSlots patch
|
||||
}
|
||||
@@ -930,8 +930,6 @@ static void SpeedInterfaceCounterAnimsPatch() {
|
||||
}
|
||||
}
|
||||
|
||||
static bool IFACE_BAR_MODE = false;
|
||||
|
||||
static long gmouse_handle_event_hook() {
|
||||
// check whether the player clicks on the clipping area of the map
|
||||
if (!HRP::EdgeClipping::CheckMapClipping()) return 0; // block
|
||||
@@ -949,7 +947,7 @@ static long gmouse_handle_event_hook() {
|
||||
}
|
||||
}
|
||||
|
||||
if (IFACE_BAR_MODE) return 1;
|
||||
if (HRP::IFaceBar::IFACE_BAR_MODE) return 1;
|
||||
|
||||
// if IFACE_BAR_MODE is not enabled, check the display_win window area
|
||||
win = fo::func::GNW_find(fo::var::getInt(FO_VAR_display_win));
|
||||
@@ -1041,10 +1039,6 @@ static void UIAnimationSpeedPatch() {
|
||||
SimplePatch<BYTE>(&addrs[4], 2, "Misc", "PipboyTimeAnimDelay", 50, 0, 127);
|
||||
}
|
||||
|
||||
static void HackMouseEvent() {
|
||||
HookCall(0x44C018, gmouse_handle_event_hook);
|
||||
}
|
||||
|
||||
void Interface::init() {
|
||||
InterfaceWindowPatch();
|
||||
InventoryCharacterRotationSpeedPatch();
|
||||
@@ -1065,15 +1059,8 @@ void Interface::init() {
|
||||
// Transparent/Hidden - will not toggle the mouse cursor when the cursor hovers over a transparent/hidden window
|
||||
// ScriptWindow - prevents the player from moving when clicking on the window if the 'Transparent' flag is not set
|
||||
HookCall(0x44B737, gmouse_bk_process_hook);
|
||||
if (HRP::Setting::IsEnabled()) {
|
||||
IFACE_BAR_MODE = (HRP::IFaceBar::IFACE_BAR_MODE != 0);
|
||||
HackMouseEvent();
|
||||
} else {
|
||||
LoadGameHook::OnBeforeGameInit() += []() {
|
||||
if (HRP::Setting::VersionIsValid) IFACE_BAR_MODE = (GetIntHRPValue(HRP_VAR_IFACE_BAR_MODE) != 0);
|
||||
HackMouseEvent(); // replaces hack function from HRP by Mash
|
||||
};
|
||||
}
|
||||
HookCall(0x44C018, gmouse_handle_event_hook); // (replaces hack function from HRP by Mash)
|
||||
if (HRP::Setting::VersionIsValid) HRP::IFaceBar::IFACE_BAR_MODE = (GetIntHRPValue(HRP_VAR_IFACE_BAR_MODE) != 0);
|
||||
}
|
||||
|
||||
void Interface::exit() {
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "..\main.h"
|
||||
#include "..\FalloutEngine\Fallout2.h"
|
||||
#include "..\Utils.h"
|
||||
#include "LoadGameHook.h"
|
||||
#include "LoadOrder.h"
|
||||
|
||||
@@ -37,6 +38,7 @@ static DWORD format;
|
||||
static bool cutsPatch = false;
|
||||
|
||||
static std::vector<std::string> patchFiles;
|
||||
static std::vector<std::string> sfPatchFiles;
|
||||
static std::vector<int> savPrototypes;
|
||||
|
||||
static void PlayerGenderCutsRestore() {
|
||||
@@ -110,6 +112,15 @@ static void __declspec(naked) gnw_main_hack() {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static void __stdcall InitSystemPatches() {
|
||||
for (auto it = sfPatchFiles.begin(); it != sfPatchFiles.end(); ++it) {
|
||||
if (!it->empty()) fo::func::db_init(it->c_str(), 0);
|
||||
}
|
||||
// free memory
|
||||
sfPatchFiles.clear();
|
||||
sfPatchFiles.shrink_to_fit();
|
||||
}
|
||||
|
||||
static fo::PathNode* __fastcall RemoveDatabase(const char* pathPatches) {
|
||||
auto paths = fo::var::paths; // curr.node (beginning of the chain of paths)
|
||||
auto _paths = paths; // prev.node
|
||||
@@ -138,7 +149,7 @@ static void __declspec(naked) game_init_databases_hack1() {
|
||||
mov ecx, [esp + 0x104 + 4]; // path_patches
|
||||
call RemoveDatabase;
|
||||
skip:
|
||||
mov ds:[FO_VAR_master_db_handle], eax; // the pointer of master_patches node will be saved here
|
||||
mov ds:[FO_VAR_master_db_handle], eax; // the pointer of master_patches node will be saved here
|
||||
retn;
|
||||
}
|
||||
}
|
||||
@@ -151,12 +162,13 @@ static void __declspec(naked) game_init_databases_hack2() {
|
||||
mov eax, ds:[FO_VAR_master_db_handle]; // pointer to master_patches node
|
||||
mov eax, [eax]; // eax = master_patches.path
|
||||
call fo::funcoffs::xremovepath_;
|
||||
dec eax; // remove path (critter_patches == master_patches)?
|
||||
jz end; // Yes (jump if 0)
|
||||
dec eax; // 1 = remove path (critter_patches == master_patches)?
|
||||
jz end; // yes (jump if removed)
|
||||
mov ecx, [esp + 0x104 + 4]; // path_patches
|
||||
call RemoveDatabase;
|
||||
end:
|
||||
mov ds:[FO_VAR_critter_db_handle], eax; // the pointer of critter_patches node will be saved here
|
||||
call InitSystemPatches;
|
||||
retn;
|
||||
}
|
||||
}
|
||||
@@ -184,6 +196,26 @@ static void __fastcall game_init_databases_hook() { // eax = _master_db_handle
|
||||
}
|
||||
master_patches->next = paths; // master_patches.next -> paths
|
||||
fo::var::paths = master_patches; // set master_patches node at the beginning of the chain of paths
|
||||
|
||||
// remove paths that are identical to master_patches (i.e. the DATA folder)
|
||||
fo::PathNode* parentPath = fo::var::paths;
|
||||
paths = parentPath->next;
|
||||
while (paths) {
|
||||
if (!paths->isDat && _stricmp(paths->path, fo::var::paths->path) == 0) {
|
||||
auto nextPaths = paths->next;
|
||||
__asm {
|
||||
mov eax, [paths];
|
||||
call fo::funcoffs::nfree_; // free path string
|
||||
mov eax, paths;
|
||||
call fo::funcoffs::nfree_; // free self
|
||||
}
|
||||
parentPath->next = nextPaths;
|
||||
paths = nextPaths;
|
||||
} else {
|
||||
parentPath = paths;
|
||||
paths = paths->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
static void __fastcall game_init_databases_hook1() {
|
||||
@@ -483,17 +515,23 @@ static void SfallResourceFile() {
|
||||
} while (FindNextFileA(hFind, &findData));
|
||||
FindClose(hFind);
|
||||
}
|
||||
patchFiles.push_back(sfallRes);
|
||||
sfPatchFiles.push_back(sfallRes);
|
||||
}
|
||||
|
||||
// last: master.dat < critter.dat < [add here] < sfall.dat < patchXXX.dat
|
||||
void LoadOrder::AddResourcePatches(std::string &dat, std::string &patches) {
|
||||
if (!dat.empty()) patchFiles.push_back(std::move(dat));
|
||||
if (!patches.empty()) patchFiles.push_back(std::move(patches));
|
||||
if (!dat.empty()) sfPatchFiles.push_back(std::move(dat));
|
||||
if (!patches.empty()) {
|
||||
size_t pos = patches.find('\\');
|
||||
while (pos != std::string::npos) {
|
||||
patches.replace(pos, 1, " ");
|
||||
pos = patches.find('\\', pos + 1);
|
||||
}
|
||||
sfPatchFiles.push_back(std::move(trim(patches)));
|
||||
}
|
||||
}
|
||||
|
||||
void LoadOrder::init() {
|
||||
SfallResourceFile(); // Add external sfall resource file (load order is before patchXXX.dat)
|
||||
SfallResourceFile(); // Add external sfall resource file (load order: > patchXXX.dat > sfall.dat > ... [last])
|
||||
GetExtraPatches();
|
||||
MultiPatchesPatch();
|
||||
|
||||
|
||||
+2
-2
@@ -184,8 +184,8 @@ void WinProc::SetStyle(long windowStyle) {
|
||||
|
||||
void WinProc::SetTitle(long wWidth, long wHeight, long gMode) {
|
||||
char windowTitle[128];
|
||||
char mode[4] = "DX9";
|
||||
if (gMode < 4) std::strcpy(mode, "DD7");
|
||||
char mode[4] = "DD7";
|
||||
if (gMode >= 4) std::strcpy(mode, "DX9");
|
||||
|
||||
if (HRP::Setting::ScreenWidth() != wWidth || HRP::Setting::ScreenHeight() != wHeight) {
|
||||
std::sprintf(windowTitle, "%s @sfall " VERSION_STRING " %ix%i >> %ix%i [%s]",
|
||||
|
||||
Reference in New Issue
Block a user