Implemented new ini reading funcs (part 2)

Refactored Premade.cpp, Reputations.cpp, KarmaFRMs in main.cpp, and
XPTable in Stats.cpp using 4.x implementation.
This commit is contained in:
NovaRain
2019-10-15 21:57:49 +08:00
parent 8924257aee
commit da7cd2a060
11 changed files with 134 additions and 175 deletions
-2
View File
@@ -437,7 +437,6 @@ UseScrollingQuestsList=1
;Use this line to modify the list of cities and their associated global variables used for city reputations ;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. ;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 ;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 ;Set this to a valid path to save a copy of the console contents
@@ -453,7 +452,6 @@ SpeedInterfaceCounterAnims=0
;These lines allow you to control the karma FRMs displayed on the character screen ;These lines allow you to control the karma FRMs displayed on the character screen
;Number of KarmaPoints should be 1 less than number of KarmaFRMs ;Number of KarmaPoints should be 1 less than number of KarmaFRMs
;KarmaFRMsCount=3
;KarmaFRMs=47,48,49 ;KarmaFRMs=47,48,49
;KarmaPoints=-100,100 ;KarmaPoints=-100,100
+3 -5
View File
@@ -24,7 +24,6 @@
static int BooksCount = 0; static int BooksCount = 0;
static const int BooksMax = 50; static const int BooksMax = 50;
static char iniBooks[MAX_PATH];
struct sBook { struct sBook {
DWORD bookPid; DWORD bookPid;
@@ -82,11 +81,10 @@ static void LoadVanillaBooks() {
} }
void BooksInit() { void BooksInit() {
char buf[MAX_PATH - 3]; std::string booksFile = GetConfigString("Misc", "BooksFile", "", MAX_PATH);
GetPrivateProfileString("Misc", "BooksFile", "", buf, MAX_PATH - 3, ini); if (!booksFile.empty()) {
if (strlen(buf) > 0) {
dlog("Applying books patch...", DL_INIT); dlog("Applying books patch...", DL_INIT);
sprintf(iniBooks, ".\\%s", buf); const char* iniBooks = booksFile.insert(0, ".\\").c_str();
bool includeVanilla = (GetPrivateProfileIntA("main", "overrideVanilla", 0, iniBooks) == 0); bool includeVanilla = (GetPrivateProfileIntA("main", "overrideVanilla", 0, iniBooks) == 0);
if (includeVanilla) BooksCount = 5; if (includeVanilla) BooksCount = 5;
+4 -8
View File
@@ -17,15 +17,15 @@
*/ */
#include "main.h" #include "main.h"
#include "FalloutEngine.h"
#include "Elevators.h" #include "Elevators.h"
#include "FalloutEngine.h"
static const int exitsPerElevator = 4; static const int exitsPerElevator = 4;
static const int vanillaElevatorCount = 24; static const int vanillaElevatorCount = 24;
static const int elevatorCount = 50; static const int elevatorCount = 50;
static char elevFile[MAX_PATH] = ".\\"; //static char elevFile[MAX_PATH] = ".\\";
struct sElevator { struct sElevator {
DWORD ID1; DWORD ID1;
@@ -122,7 +122,7 @@ void ResetElevators() {
//for (int i = vanillaElevatorCount; i < elevatorCount; i++) elevatorType[i] = 0; //for (int i = vanillaElevatorCount; i < elevatorCount; i++) elevatorType[i] = 0;
} }
static void LoadElevators() { void LoadElevators(const char* elevFile) {
//ResetElevators(); //ResetElevators();
memcpy(elevators, (void*)_retvals, sizeof(sElevator) * vanillaElevatorCount); memcpy(elevators, (void*)_retvals, sizeof(sElevator) * vanillaElevatorCount);
@@ -161,9 +161,7 @@ static void LoadElevators() {
} }
} }
void ElevatorsInit(char* file) { void ElevatorsInit() {
strcat_s(elevFile, file);
HookCall(0x43EF83, GetMenuHook); HookCall(0x43EF83, GetMenuHook);
HookCall(0x43F141, CheckHotKeysHook); HookCall(0x43F141, CheckHotKeysHook);
//HookCall(0x43F2D2, UnknownHook2); // unused //HookCall(0x43F2D2, UnknownHook2); // unused
@@ -185,6 +183,4 @@ void ElevatorsInit(char* file) {
MakeCall(0x43F05D, GetNumButtonsHook1, 2); MakeCall(0x43F05D, GetNumButtonsHook1, 2);
MakeCall(0x43F184, GetNumButtonsHook2, 2); MakeCall(0x43F184, GetNumButtonsHook2, 2);
MakeCall(0x43F1E4, GetNumButtonsHook3, 2); MakeCall(0x43F1E4, GetNumButtonsHook3, 2);
LoadElevators();
} }
+2 -1
View File
@@ -18,4 +18,5 @@
#pragma once #pragma once
void ElevatorsInit(char* file); void ElevatorsInit();
void LoadElevators(const char* elevFile);
+1 -1
View File
@@ -87,7 +87,7 @@ static void _stdcall ResetState(DWORD onLoad) {
if (!onLoad) FileSystemReset(); if (!onLoad) FileSystemReset();
ClearGlobalScripts(); ClearGlobalScripts();
ClearGlobals(); ClearGlobals();
ForceGraphicsRefresh(0); ForceGraphicsRefresh(0); // disable refresh
WipeSounds(); WipeSounds();
if (GraphicsMode > 3) GraphicsResetOnGameLoad(); if (GraphicsMode > 3) GraphicsResetOnGameLoad();
Combat_OnGameLoad(); Combat_OnGameLoad();
+9 -24
View File
@@ -27,30 +27,15 @@ struct PremadeChar {
PremadeChar* premade; PremadeChar* premade;
void PremadeInit() { void PremadeInit() {
char buf[512]; std::vector<std::string> premadePaths = GetConfigList("misc", "PremadePaths", "", 512);
GetPrivateProfileString("misc", "PremadePaths", "", buf, 512, ini); std::vector<std::string> premadeFids = GetConfigList("misc", "PremadeFIDs", "", 512);
if(buf[0]) { if (!premadePaths.empty() && !premadeFids.empty()) {
char buf2[512]; int count = min(premadePaths.size(), premadeFids.size());
GetPrivateProfileString("misc", "PremadeFIDs", "", buf2, 512, ini); premade = new PremadeChar[count];
for (int i = 0; i < count; i++) {
int count=1; std::string path = "premade\\" + premadePaths[i];
char* tmp=buf; strcpy_s(premade[i].path, 20, path.c_str());
while(tmp=strchr(tmp, ',')) { tmp++; count++; } premade[i].fid = atoi(premadeFids[i].c_str());
premade=new PremadeChar[count];
tmp=buf;
char* tmp2=buf2;
for(int i=0;i<count;i++) {
char* tmp3=strchr(tmp, ',');
if(tmp3) *tmp3=0;
strcpy_s(premade[i].path, 20, "premade\\");
strcat_s(premade[i].path, 20, tmp);
tmp=tmp3 + 1;
tmp3=strchr(tmp2, ',');
if(tmp3) *tmp3=0;
premade[i].fid=atoi(tmp2);
tmp2=tmp3 + 1;
} }
SafeWrite32(0x51C8D4, count); SafeWrite32(0x51C8D4, count);
+15 -18
View File
@@ -16,35 +16,32 @@
* 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 <iterator>
#include "main.h" #include "main.h"
#include "Utils.h"
struct CityRep { struct CityRep {
DWORD globalID; DWORD globalID;
DWORD cityID; DWORD cityID;
}; };
// C-array is neccessary, because it is used by game engine
static CityRep* repList = nullptr; static CityRep* repList = nullptr;
void ReputationsInit() { void ReputationsInit() {
int count; std::vector<std::string> cityRepList = GetConfigList("Misc", "CityRepsList", "", 512);
if (count = GetPrivateProfileIntA("Misc", "CityRepsCount", 0, ini)) { size_t count = cityRepList.size();
if (count > 0) {
repList = new CityRep[count]; repList = new CityRep[count];
char buf[512]; std::vector<std::string> pair;
GetPrivateProfileStringA("Misc", "CityRepsList", "", buf, 512, ini); pair.reserve(2);
char* end; for (size_t i = 0; i < count; i++) {
char* start = buf; pair.clear();
for(int i = 0; i < count; i++) { split(cityRepList[i], ':', std::back_inserter(pair), 2);
end = strchr(start, ':'); repList[i].cityID = atoi(pair[0].c_str());
*end = '\0'; if (pair.size() >= 2) {
repList[i].cityID = atoi(start); repList[i].globalID = atoi(pair[1].c_str());
start = end + 1;
if (i == count - 1) {
repList[i].globalID = atoi(start);
} else {
end = strchr(start, ',');
*end = '\0';
repList[i].globalID = atoi(start);
start = end + 1;
} }
} }
+8 -15
View File
@@ -227,28 +227,21 @@ void StatsInit() {
MakeCall(0x4AF54E, stat_set_base_hack_allow); MakeCall(0x4AF54E, stat_set_base_hack_allow);
MakeCall(0x455D65, op_set_critter_stat_hack); // STAT_unused for other critters MakeCall(0x455D65, op_set_critter_stat_hack); // STAT_unused for other critters
char table[2048]; std::vector<std::string> xpTableList = GetConfigList("Misc", "XPTable", "", 2048);
GetConfigString("Misc", "XPTable", "", table, 2048); size_t numLevels = xpTableList.size();
if (strlen(table) > 0) { if (numLevels > 0) {
char *ptr = table, *ptr2;
DWORD level = 0;
HookCall(0x434AA7, GetNextLevelXPHook); HookCall(0x434AA7, GetNextLevelXPHook);
HookCall(0x439642, GetNextLevelXPHook); HookCall(0x439642, GetNextLevelXPHook);
HookCall(0x4AFB22, GetNextLevelXPHook); HookCall(0x4AFB22, GetNextLevelXPHook);
HookCall(0x496C8D, GetLevelXPHook); HookCall(0x496C8D, GetLevelXPHook);
HookCall(0x4AFC53, GetLevelXPHook); HookCall(0x4AFC53, GetLevelXPHook);
while ((ptr2 = strstr(ptr, ",")) && level < 99) { for (size_t i = 0; i < 99; i++) {
ptr2[0] = '\0'; xpTable[i] = (i < numLevels)
xpTable[level++] = atoi(ptr); ? atoi(xpTableList[i].c_str())
ptr = ptr2 + 1; : -1;
} }
if (level < 99 && ptr[0] != '\0') { SafeWrite8(0x4AFB1B, static_cast<BYTE>(numLevels + 1));
xpTable[level++] = atoi(ptr);
}
for (int i = level; i < 99; i++) xpTable[i] = -1;
SafeWrite8(0x4AFB1B, static_cast<BYTE>(level + 1));
} }
std::string statsFile = GetConfigString("Misc", "DerivedStats", "", MAX_PATH); std::string statsFile = GetConfigString("Misc", "DerivedStats", "", MAX_PATH);
+88 -97
View File
@@ -75,7 +75,7 @@ bool hrpIsEnabled = false;
bool hrpVersionValid = false; // HRP 4.1.8 version validation bool hrpVersionValid = false; // HRP 4.1.8 version validation
const char ddrawIniDef[] = ".\\ddraw.ini"; const char ddrawIniDef[] = ".\\ddraw.ini";
char ini[65] = ".\\"; static char ini[65] = ".\\";
static char translationIni[65]; static char translationIni[65];
DWORD modifiedIni; DWORD modifiedIni;
@@ -136,6 +136,13 @@ size_t Translate(const char* section, const char* setting, const char* defaultVa
static std::vector<int> savPrototypes; static std::vector<int> savPrototypes;
struct KarmaFrmSetting {
DWORD frm;
int points;
};
static std::vector<KarmaFrmSetting> karmaFrms;
static char mapName[65]; static char mapName[65];
static char configName[65]; static char configName[65];
static char patchName[65]; static char patchName[65];
@@ -410,7 +417,7 @@ static void _stdcall SetKarma(int value) {
mov old, eax; mov old, eax;
} }
old = value - old; old = value - old;
char buf[64]; char buf[128];
if (old == 0) return; if (old == 0) return;
if (old > 0) { if (old > 0) {
sprintf_s(buf, KarmaGainMsg, old); sprintf_s(buf, KarmaGainMsg, old);
@@ -422,12 +429,12 @@ static void _stdcall SetKarma(int value) {
static void __declspec(naked) SetGlobalVarWrapper() { static void __declspec(naked) SetGlobalVarWrapper() {
__asm { __asm {
test eax, eax; test eax, eax; // GVar number
jnz end; jnz end;
pushad; pushadc;
push edx; push edx;
call SetKarma; call SetKarma;
popad; popadc;
end: end:
jmp game_set_global_var_; jmp game_set_global_var_;
} }
@@ -522,15 +529,14 @@ end:
} }
} }
static DWORD KarmaFrmCount;
static DWORD* KarmaFrms = nullptr;
static int* KarmaPoints = nullptr;
static DWORD _stdcall DrawCard() { static DWORD _stdcall DrawCard() {
int rep = **(int**)_game_global_vars; int reputation = **(int**)_game_global_vars;
for (DWORD i = 0; i < KarmaFrmCount - 1; i++) { for (std::vector<KarmaFrmSetting>::const_iterator it = karmaFrms.begin(); it != karmaFrms.end(); ++it) {
if (rep < KarmaPoints[i]) return KarmaFrms[i]; if (reputation < it->points) {
return it->frm;
}
} }
return KarmaFrms[KarmaFrmCount - 1]; return karmaFrms.end()->frm;
} }
static void __declspec(naked) DrawInfoWin_hook() { static void __declspec(naked) DrawInfoWin_hook() {
@@ -664,14 +670,14 @@ static void DllMain2() {
dlogr("Running TalkingHeadsInit().", DL_INIT); dlogr("Running TalkingHeadsInit().", DL_INIT);
TalkingHeadsInit(); TalkingHeadsInit();
//if (GetPrivateProfileIntA("Input", "Enable", 0, ini)) { //if (GetConfigInt("Input", "Enable", 0)) {
dlog("Applying input patch.", DL_INIT); dlog("Applying input patch.", DL_INIT);
SafeWriteStr(0x50FB70, "ddraw.dll"); SafeWriteStr(0x50FB70, "ddraw.dll");
AvailableGlobalScriptTypes |= 1; AvailableGlobalScriptTypes |= 1;
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
//} //}
if (GetPrivateProfileIntA("Misc", "DataLoadOrderPatch", 1, ini)) { if (GetConfigInt("Misc", "DataLoadOrderPatch", 1)) {
dlog("Applying data load order patch.", DL_INIT); dlog("Applying data load order patch.", DL_INIT);
MakeCall(0x444259, game_init_databases_hack1); MakeCall(0x444259, game_init_databases_hack1);
MakeCall(0x4442F1, game_init_databases_hack2); MakeCall(0x4442F1, game_init_databases_hack2);
@@ -703,21 +709,21 @@ static void DllMain2() {
ObjectsInit(); ObjectsInit();
mapName[64] = 0; mapName[64] = 0;
if (GetPrivateProfileString("Misc", "StartingMap", "", mapName, 64, ini)) { 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; versionString[64] = 0;
if (GetPrivateProfileString("Misc", "VersionString", "", versionString, 64, ini)) { 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; configName[64] = 0;
if (GetPrivateProfileString("Misc", "ConfigFile", "", configName, 64, ini)) { if (GetConfigString("Misc", "ConfigFile", "", configName, 64)) {
dlog("Applying config file patch.", DL_INIT); dlog("Applying config file patch.", DL_INIT);
SafeWrite32(0x444BA5, (DWORD)&configName); SafeWrite32(0x444BA5, (DWORD)&configName);
SafeWrite32(0x444BCA, (DWORD)&configName); SafeWrite32(0x444BCA, (DWORD)&configName);
@@ -725,34 +731,34 @@ static void DllMain2() {
} }
patchName[64] = 0; patchName[64] = 0;
if (GetPrivateProfileString("Misc", "PatchFile", "", patchName, 64, ini)) { 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);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
startMaleModelName[64] = 0; startMaleModelName[64] = 0;
if (GetPrivateProfileString("Misc", "MaleStartModel", "", startMaleModelName, 64, ini)) { 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; startFemaleModelName[64] = 0;
if (GetPrivateProfileString("Misc", "FemaleStartModel", "", startFemaleModelName, 64, ini)) { 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; defaultMaleModelName[64] = 0;
GetPrivateProfileString("Misc", "MaleDefaultModel", "hmjmps", defaultMaleModelName, 64, ini); 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; defaultFemaleModelName[64] = 0;
GetPrivateProfileString("Misc", "FemaleDefaultModel", "hfjmps", defaultFemaleModelName, 64, ini); 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);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
@@ -760,7 +766,7 @@ static void DllMain2() {
dlogr("Running WorldmapInit().", DL_INIT); dlogr("Running WorldmapInit().", DL_INIT);
WorldmapInit(); WorldmapInit();
if (GetPrivateProfileIntA("Misc", "DialogueFix", 1, ini)) { if (GetConfigInt("Misc", "DialogueFix", 1)) {
dlog("Applying dialogue patch.", DL_INIT); dlog("Applying dialogue patch.", DL_INIT);
SafeWrite8(0x446848, 0x31); SafeWrite8(0x446848, 0x31);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
@@ -769,13 +775,13 @@ static void DllMain2() {
dlogr("Running CriticalsInit().", DL_INIT); dlogr("Running CriticalsInit().", DL_INIT);
CriticalsInit(); CriticalsInit();
if (GetPrivateProfileIntA("Misc", "ExtraKillTypes", 0, ini)) { if (GetConfigInt("Misc", "ExtraKillTypes", 0)) {
dlog("Applying extra kill types patch.", DL_INIT); dlog("Applying extra kill types patch.", DL_INIT);
KillCounterInit(); KillCounterInit();
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
//if (GetPrivateProfileIntA("Misc", "ScriptExtender", 0, ini)) { //if (GetConfigInt("Misc", "ScriptExtender", 0)) {
dlogr("Running StatsInit().", DL_INIT); dlogr("Running StatsInit().", DL_INIT);
StatsInit(); StatsInit();
dlogr("Running ScriptExtenderSetup().", DL_INIT); dlogr("Running ScriptExtenderSetup().", DL_INIT);
@@ -796,7 +802,7 @@ static void DllMain2() {
dlogr("Running DebugEditorInit().", DL_INIT); dlogr("Running DebugEditorInit().", DL_INIT);
DebugEditorInit(); DebugEditorInit();
if (GetPrivateProfileIntA("Misc", "SingleCore", 1, ini)) { if (GetConfigInt("Misc", "SingleCore", 1)) {
dlog("Applying single core patch.", DL_INIT); dlog("Applying single core patch.", DL_INIT);
HANDLE process = GetCurrentProcess(); HANDLE process = GetCurrentProcess();
SetProcessAffinityMask(process, 1); SetProcessAffinityMask(process, 1);
@@ -804,22 +810,22 @@ static void DllMain2() {
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
if (GetPrivateProfileIntA("Misc", "OverrideArtCacheSize", 0, ini)) { if (GetConfigInt("Misc", "OverrideArtCacheSize", 0)) {
dlog("Applying override art cache size patch.", DL_INIT); dlog("Applying override art cache size patch.", DL_INIT);
SafeWrite32(0x418867, 0x90909090); SafeWrite32(0x418867, 0x90909090);
SafeWrite32(0x418872, 256); SafeWrite32(0x418872, 256);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
char elevPath[MAX_PATH - 3]; std::string elevPath = GetConfigString("Misc", "ElevatorsFile", "", MAX_PATH);
GetPrivateProfileString("Misc", "ElevatorsFile", "", elevPath, MAX_PATH - 3, ini); if (!elevPath.empty()) {
if (strlen(elevPath) > 0) {
dlog("Applying elevator patch.", DL_INIT); dlog("Applying elevator patch.", DL_INIT);
ElevatorsInit(elevPath); ElevatorsInit();
LoadElevators(elevPath.insert(0, ".\\").c_str());
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
if (GetPrivateProfileIntA("Misc", "AdditionalWeaponAnims", 0, ini)) { 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, 0x12);
HookCall(0x4194CC, WeaponAnimHook); HookCall(0x4194CC, WeaponAnimHook);
@@ -828,34 +834,34 @@ static void DllMain2() {
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
//if (GetPrivateProfileIntA("Misc", "MultiPatches", 0, ini)) { //if (GetConfigInt("Misc", "MultiPatches", 0)) {
dlog("Applying load multiple patches patch.", DL_INIT); dlog("Applying load multiple patches patch.", DL_INIT);
SafeWrite8(0x444354, 0x90); // Change step from 2 to 1 SafeWrite8(0x444354, 0x90); // Change step from 2 to 1
SafeWrite8(0x44435C, 0xC4); // Disable check SafeWrite8(0x44435C, 0xC4); // Disable check
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
//} //}
if (GetPrivateProfileInt("Misc", "DisplayKarmaChanges", 0, ini)) { if (GetConfigInt("Misc", "DisplayKarmaChanges", 0)) {
dlog("Applying display karma changes patch.", DL_INIT); dlog("Applying display karma changes patch.", DL_INIT);
GetPrivateProfileString("sfall", "KarmaGain", "You gained %d karma.", KarmaGainMsg, 128, translationIni); Translate("sfall", "KarmaGain", "You gained %d karma.", KarmaGainMsg);
GetPrivateProfileString("sfall", "KarmaLoss", "You lost %d karma.", KarmaLossMsg, 128, translationIni); Translate("sfall", "KarmaLoss", "You lost %d karma.", KarmaLossMsg);
HookCall(0x455A6D, SetGlobalVarWrapper); HookCall(0x455A6D, SetGlobalVarWrapper);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
if (GetPrivateProfileInt("Misc", "AlwaysReloadMsgs", 0, ini)) { if (GetConfigInt("Misc", "AlwaysReloadMsgs", 0)) {
dlog("Applying always reload messages patch.", DL_INIT); dlog("Applying always reload messages patch.", DL_INIT);
SafeWrite8(0x4A6B8D, 0x0); SafeWrite8(0x4A6B8D, 0x0);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
if (GetPrivateProfileInt("Misc", "PlayIdleAnimOnReload", 0, ini)) { 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, ReloadHook);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
if (GetPrivateProfileInt("Misc", "CorpseLineOfFireFix", 1, ini)) { if (GetConfigInt("Misc", "CorpseLineOfFireFix", 1)) {
dlog("Applying corpse line of fire patch.", DL_INIT); dlog("Applying corpse line of fire patch.", DL_INIT);
MakeJump(0x48B994, CorpseHitFix2); MakeJump(0x48B994, CorpseHitFix2);
MakeJump(0x48BA04, CorpseHitFix2b); MakeJump(0x48BA04, CorpseHitFix2b);
@@ -863,19 +869,19 @@ static void DllMain2() {
} }
dlog("Checking for changed skilldex images.", DL_INIT); dlog("Checking for changed skilldex images.", DL_INIT);
tmp = GetPrivateProfileIntA("Misc", "Lockpick", 293, ini); tmp = GetConfigInt("Misc", "Lockpick", 293);
if (tmp != 293) SafeWrite32(0x518D54, tmp); if (tmp != 293) SafeWrite32(0x518D54, tmp);
tmp = GetPrivateProfileIntA("Misc", "Steal", 293, ini); tmp = GetConfigInt("Misc", "Steal", 293);
if (tmp != 293) SafeWrite32(0x518D58, tmp); if (tmp != 293) SafeWrite32(0x518D58, tmp);
tmp = GetPrivateProfileIntA("Misc", "Traps", 293, ini); tmp = GetConfigInt("Misc", "Traps", 293);
if (tmp != 293) SafeWrite32(0x518D5C, tmp); if (tmp != 293) SafeWrite32(0x518D5C, tmp);
tmp = GetPrivateProfileIntA("Misc", "FirstAid", 293, ini); tmp = GetConfigInt("Misc", "FirstAid", 293);
if (tmp != 293) SafeWrite32(0x518D4C, tmp); if (tmp != 293) SafeWrite32(0x518D4C, tmp);
tmp = GetPrivateProfileIntA("Misc", "Doctor", 293, ini); tmp = GetConfigInt("Misc", "Doctor", 293);
if (tmp != 293) SafeWrite32(0x518D50, tmp); if (tmp != 293) SafeWrite32(0x518D50, tmp);
tmp = GetPrivateProfileIntA("Misc", "Science", 293, ini); tmp = GetConfigInt("Misc", "Science", 293);
if (tmp != 293) SafeWrite32(0x518D60, tmp); if (tmp != 293) SafeWrite32(0x518D60, tmp);
tmp = GetPrivateProfileIntA("Misc", "Repair", 293, ini); tmp = GetConfigInt("Misc", "Repair", 293);
if (tmp != 293) SafeWrite32(0x518D64, tmp); if (tmp != 293) SafeWrite32(0x518D64, tmp);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
@@ -904,12 +910,12 @@ static void DllMain2() {
dlogr("Running ConsoleInit().", DL_INIT); dlogr("Running ConsoleInit().", DL_INIT);
ConsoleInit(); ConsoleInit();
if (GetPrivateProfileIntA("Misc", "ExtraSaveSlots", 0, ini)) { if (GetConfigInt("Misc", "ExtraSaveSlots", 0)) {
dlogr("Running EnableSuperSaving().", DL_INIT); dlogr("Running EnableSuperSaving().", DL_INIT);
EnableSuperSaving(); EnableSuperSaving();
} }
switch (GetPrivateProfileIntA("Misc", "SpeedInterfaceCounterAnims", 0, ini)) { switch (GetConfigInt("Misc", "SpeedInterfaceCounterAnims", 0)) {
case 1: case 1:
dlog("Applying SpeedInterfaceCounterAnims patch.", DL_INIT); dlog("Applying SpeedInterfaceCounterAnims patch.", DL_INIT);
MakeJump(0x460BA1, intface_rotate_numbers_hack); MakeJump(0x460BA1, intface_rotate_numbers_hack);
@@ -922,35 +928,24 @@ static void DllMain2() {
break; break;
} }
KarmaFrmCount = GetPrivateProfileIntA("Misc", "KarmaFRMsCount", 0, ini); std::vector<std::string> karmaFrmList = GetConfigList("Misc", "KarmaFRMs", "", 512);
if (KarmaFrmCount) { if (!karmaFrmList.empty()) {
KarmaFrms = new DWORD[KarmaFrmCount];
KarmaPoints = new int[KarmaFrmCount - 1];
dlog("Applying karma FRM patch.", DL_INIT); dlog("Applying karma FRM patch.", DL_INIT);
char buf[512];
GetPrivateProfileStringA("Misc", "KarmaFRMs", "", buf, 512, ini); std::vector<std::string> karmaPointsList = GetConfigList("Misc", "KarmaPoints", "", 512);
char *ptr = buf, *ptr2; karmaFrms.resize(karmaFrmList.size());
for (DWORD i = 0; i < KarmaFrmCount - 1; i++) { for (size_t i = 0; i < karmaFrmList.size(); i++) {
ptr2 = strchr(ptr, ','); karmaFrms[i].frm = atoi(karmaFrmList[i].c_str());
*ptr2 = '\0'; karmaFrms[i].points = (karmaPointsList.size() > i)
KarmaFrms[i] = atoi(ptr); ? atoi(karmaPointsList[i].c_str())
ptr = ptr2 + 1; : INT_MAX;
} }
KarmaFrms[KarmaFrmCount - 1] = atoi(ptr);
GetPrivateProfileStringA("Misc", "KarmaPoints", "", buf, 512, ini);
ptr = buf;
for (DWORD i = 0; i < KarmaFrmCount - 2; i++) {
ptr2 = strchr(ptr, ',');
*ptr2 = '\0';
KarmaPoints[i] = atoi(ptr);
ptr = ptr2 + 1;
}
KarmaPoints[KarmaFrmCount - 2] = atoi(ptr);
HookCall(0x4367A9, DrawInfoWin_hook); HookCall(0x4367A9, DrawInfoWin_hook);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
switch (GetPrivateProfileIntA("Misc", "ScienceOnCritters", 0, ini)) { switch (GetConfigInt("Misc", "ScienceOnCritters", 0)) {
case 1: case 1:
HookCall(0x41276E, ScienceCritterCheckHook); HookCall(0x41276E, ScienceCritterCheckHook);
break; break;
@@ -959,7 +954,7 @@ static void DllMain2() {
break; break;
} }
tmp = GetPrivateProfileIntA("Misc", "SpeedInventoryPCRotation", 166, ini); tmp = GetConfigInt("Misc", "SpeedInventoryPCRotation", 166);
if (tmp != 166 && tmp <= 1000) { if (tmp != 166 && tmp <= 1000) {
dlog("Applying SpeedInventoryPCRotation patch.", DL_INIT); dlog("Applying SpeedInventoryPCRotation patch.", DL_INIT);
SafeWrite32(0x47066B, tmp); SafeWrite32(0x47066B, tmp);
@@ -975,7 +970,7 @@ static void DllMain2() {
dlogr("Running AnimationsAtOnceInit().", DL_INIT); dlogr("Running AnimationsAtOnceInit().", DL_INIT);
AnimationsAtOnceInit(); AnimationsAtOnceInit();
if (tmp = GetPrivateProfileIntA("Sound", "OverrideMusicDir", 0, ini)) { if (tmp = GetConfigInt("Sound", "OverrideMusicDir", 0)) {
SafeWrite32(0x4449C2, (DWORD)musicOverridePath); SafeWrite32(0x4449C2, (DWORD)musicOverridePath);
SafeWrite32(0x4449DB, (DWORD)musicOverridePath); SafeWrite32(0x4449DB, (DWORD)musicOverridePath);
if (tmp == 2) { if (tmp == 2) {
@@ -984,7 +979,7 @@ static void DllMain2() {
} }
} }
if (GetPrivateProfileIntA("Misc", "BoostScriptDialogLimit", 0, ini)) { 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);
scriptDialog = new int[scriptDialogCount * 2]; // Because the msg structure is 8 bytes, not 4. scriptDialog = new int[scriptDialogCount * 2]; // Because the msg structure is 8 bytes, not 4.
@@ -1000,7 +995,7 @@ static void DllMain2() {
dlogr("Running InventoryInit().", DL_INIT); dlogr("Running InventoryInit().", DL_INIT);
InventoryInit(); InventoryInit();
if (tmp = GetPrivateProfileIntA("Misc", "MotionScannerFlags", 1, ini)) { if (tmp = GetConfigInt("Misc", "MotionScannerFlags", 1)) {
dlog("Applying MotionScannerFlags patch.", DL_INIT); dlog("Applying MotionScannerFlags patch.", DL_INIT);
if (tmp & 1) MakeJump(0x41BBE9, ScannerAutomapHook); if (tmp & 1) MakeJump(0x41BBE9, ScannerAutomapHook);
if (tmp & 2) { if (tmp & 2) {
@@ -1013,7 +1008,7 @@ static void DllMain2() {
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
tmp = GetPrivateProfileIntA("Misc", "EncounterTableSize", 0, ini); tmp = GetConfigInt("Misc", "EncounterTableSize", 0);
if (tmp > 40 && tmp <= 127) { if (tmp > 40 && tmp <= 127) {
dlog("Applying EncounterTableSize patch.", DL_INIT); dlog("Applying EncounterTableSize patch.", DL_INIT);
SafeWrite8(0x4BDB17, (BYTE)tmp); SafeWrite8(0x4BDB17, (BYTE)tmp);
@@ -1024,7 +1019,7 @@ static void DllMain2() {
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
if (GetPrivateProfileIntA("Misc", "DisablePipboyAlarm", 0, ini)) { if (GetConfigInt("Misc", "DisablePipboyAlarm", 0)) {
dlog("Applying Disable Pip-Boy alarm button patch.", DL_INIT); dlog("Applying Disable Pip-Boy alarm button patch.", DL_INIT);
SafeWrite8(0x499518, 0xC3); SafeWrite8(0x499518, 0xC3);
SafeWrite8(0x443601, 0x0); SafeWrite8(0x443601, 0x0);
@@ -1037,7 +1032,7 @@ static void DllMain2() {
dlogr("Initializing party control.", DL_INIT); dlogr("Initializing party control.", DL_INIT);
PartyControlInit(); PartyControlInit();
if (GetPrivateProfileIntA("Misc", "ObjCanSeeObj_ShootThru_Fix", 0, ini)) { if (GetConfigInt("Misc", "ObjCanSeeObj_ShootThru_Fix", 0)) {
dlog("Applying ObjCanSeeObj ShootThru Fix.", DL_INIT); dlog("Applying ObjCanSeeObj ShootThru Fix.", DL_INIT);
HookCall(0x456BC6, op_obj_can_see_obj_hook); HookCall(0x456BC6, op_obj_can_see_obj_hook);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
@@ -1057,21 +1052,21 @@ static void DllMain2() {
addrs[0] = 0x499B99; addrs[1] = 0x499DA8; addrs[0] = 0x499B99; addrs[1] = 0x499DA8;
SimplePatch<BYTE>(addrs, 2, "Misc", "PipboyTimeAnimDelay", 50, 0, 127); SimplePatch<BYTE>(addrs, 2, "Misc", "PipboyTimeAnimDelay", 50, 0, 127);
if (GetPrivateProfileIntA("Misc", "EnableMusicInDialogue", 0, ini)) { 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, 0x0);
//BlockCall(0x450627); //BlockCall(0x450627);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
if (GetPrivateProfileIntA("Misc", "DontTurnOffSneakIfYouRun", 0, ini)) { if (GetConfigInt("Misc", "DontTurnOffSneakIfYouRun", 0)) {
dlog("Applying DontTurnOffSneakIfYouRun patch.", DL_INIT); dlog("Applying DontTurnOffSneakIfYouRun patch.", DL_INIT);
SafeWrite8(0x418135, 0xEB); SafeWrite8(0x418135, 0xEB);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
if (GetPrivateProfileIntA("Misc", "InstantWeaponEquip", 0, ini)) { 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++) { for (int i = 0; i < sizeof(PutAwayWeapon) / 4; i++) {
SafeWrite8(PutAwayWeapon[i], 0xEB); // jmps SafeWrite8(PutAwayWeapon[i], 0xEB); // jmps
@@ -1083,7 +1078,7 @@ static void DllMain2() {
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
if (GetPrivateProfileIntA("Misc", "NumbersInDialogue", 0, ini)) { if (GetConfigInt("Misc", "NumbersInDialogue", 0)) {
dlog("Applying numbers in dialogue patch.", DL_INIT); dlog("Applying numbers in dialogue patch.", DL_INIT);
SafeWrite32(0x502C32, 0x2000202E); SafeWrite32(0x502C32, 0x2000202E);
SafeWrite8(0x446F3B, 0x35); SafeWrite8(0x446F3B, 0x35);
@@ -1096,29 +1091,29 @@ static void DllMain2() {
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
if (GetPrivateProfileIntA("Misc", "DisplaySecondWeaponRange", 1, ini)) { if (GetConfigInt("Misc", "DisplaySecondWeaponRange", 1)) {
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);
} }
if (GetPrivateProfileIntA("Misc", "InterfaceDontMoveOnTop", 0, ini)) { if (GetConfigInt("Misc", "InterfaceDontMoveOnTop", 0)) {
dlog("Applying InterfaceDontMoveOnTop patch.", DL_INIT); dlog("Applying InterfaceDontMoveOnTop patch.", DL_INIT);
SafeWrite8(0x46ECE9, 0x10); // set only Exclusive flag for Player Inventory/Loot/UseOn SafeWrite8(0x46ECE9, 0x10); // set only Exclusive flag for Player Inventory/Loot/UseOn
SafeWrite8(0x41B966, 0x10); // set only Exclusive flag for Automap SafeWrite8(0x41B966, 0x10); // set only Exclusive flag for Automap
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
tmp = GetPrivateProfileIntA("Misc", "UseWalkDistance", 3, ini) + 2; int distance = GetConfigInt("Misc", "UseWalkDistance", 3) + 2;
if (tmp > 1 && tmp < 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);
for (int i = 0; i < sizeof(WalkDistanceAddr) / 4; i++) { for (int i = 0; i < sizeof(WalkDistanceAddr) / 4; i++) {
SafeWrite8(WalkDistanceAddr[i], (BYTE)tmp); // default is 5 SafeWrite8(WalkDistanceAddr[i], static_cast<BYTE>(distance)); // default is 5
} }
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
} }
int time = GetPrivateProfileIntA("Misc", "CorpseDeleteTime", 6, ini); // time in days int time = GetConfigInt("Misc", "CorpseDeleteTime", 6); // time in days
if (time != 6) { 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) {
@@ -1135,7 +1130,7 @@ static void DllMain2() {
SimplePatch<DWORD>(0x440C2A, "Misc", "SpecialDeathGVAR", 491); // GVAR_MODOC_SHITTY_DEATH SimplePatch<DWORD>(0x440C2A, "Misc", "SpecialDeathGVAR", 491); // GVAR_MODOC_SHITTY_DEATH
// Remove hardcoding for maps with IDs 19 and 37 // Remove hardcoding for maps with IDs 19 and 37
if (GetPrivateProfileIntA("Misc", "DisableSpecialMapIDs", 0, ini)) { if (GetConfigInt("Misc", "DisableSpecialMapIDs", 0)) {
dlog("Applying disable special map IDs patch.", DL_INIT); dlog("Applying disable special map IDs patch.", DL_INIT);
SafeWrite8(0x4836D6, 0); SafeWrite8(0x4836D6, 0);
SafeWrite8(0x4836DB, 0); SafeWrite8(0x4836DB, 0);
@@ -1146,7 +1141,7 @@ static void DllMain2() {
SafeWrite8(0x43ACD5, 144); // 136 SafeWrite8(0x43ACD5, 144); // 136
SafeWrite8(0x43DD37, 144); // 133 SafeWrite8(0x43DD37, 144); // 133
if (GetPrivateProfileIntA("Misc", "Fallout1Behavior", 0, ini)) { if (GetConfigInt("Misc", "Fallout1Behavior", 0)) {
dlog("Applying Fallout 1 engine behavior patch.", DL_INIT); dlog("Applying Fallout 1 engine behavior patch.", DL_INIT);
BlockCall(0x4A4343); // disable playing the final movie/credits after the endgame slideshow BlockCall(0x4A4343); // disable playing the final movie/credits after the endgame slideshow
SafeWrite8(0x477C71, 0xEB); // disable halving the weight for power armor items SafeWrite8(0x477C71, 0xEB); // disable halving the weight for power armor items
@@ -1160,10 +1155,6 @@ static void _stdcall OnExit() {
if (scriptDialog != nullptr) { if (scriptDialog != nullptr) {
delete[] scriptDialog; delete[] scriptDialog;
} }
if (KarmaFrmCount) {
delete[] KarmaFrms;
delete[] KarmaPoints;
}
SpeedPatchExit(); SpeedPatchExit();
ClearReadExtraGameMsgFiles(); ClearReadExtraGameMsgFiles();
ReputationsExit(); ReputationsExit();
@@ -1328,8 +1319,8 @@ defaultIni:
strcpy_s(ini, ddrawIniDef); strcpy_s(ini, ddrawIniDef);
} }
GetPrivateProfileStringA("Main", "TranslationsINI", ".\\Translations.ini", translationIni, 65, ini); GetConfigString("Main", "TranslationsINI", ".\\Translations.ini", translationIni, 65);
modifiedIni = GetPrivateProfileIntA("Main", "ModifiedIni", 0, ini); modifiedIni = GetConfigInt("Main", "ModifiedIni", 0);
hrpIsEnabled = (*(DWORD*)0x4E4480 != 0x278805C7); // check if HRP is enabled hrpIsEnabled = (*(DWORD*)0x4E4480 != 0x278805C7); // check if HRP is enabled
if (hrpIsEnabled) { if (hrpIsEnabled) {
-1
View File
@@ -103,7 +103,6 @@ size_t Translate(const char* section, const char* setting, const char* defaultVa
DWORD HRPAddressOffset(DWORD offset); DWORD HRPAddressOffset(DWORD offset);
extern const char ddrawIniDef[]; extern const char ddrawIniDef[];
extern char ini[65];
extern DWORD modifiedIni; extern DWORD modifiedIni;
extern bool hrpIsEnabled; extern bool hrpIsEnabled;
+4 -3
View File
@@ -346,11 +346,12 @@ void SkillsInit() {
// 0x00000400 - Energy Weapon (forces weapon to use Energy Weapons skill) // 0x00000400 - Energy Weapon (forces weapon to use Energy Weapons skill)
HookCall(0x47831E, item_w_skill_hook); HookCall(0x47831E, item_w_skill_hook);
char buf[512], key[16], file[MAX_PATH]; char buf[512], key[16];
if (GetPrivateProfileStringA("Misc", "SkillsFile", "", buf, MAX_PATH - 3, ini) > 0) { std::string skillsFile = GetConfigString("Misc", "SkillsFile", "", MAX_PATH);
if (!skillsFile.empty()) {
SkillInfo *skills = (SkillInfo*)_skill_data; SkillInfo *skills = (SkillInfo*)_skill_data;
sprintf(file, ".\\%s", buf); const char* file = skillsFile.insert(0, ".\\").c_str();
multipliers = new double[7 * SKILL_count](); multipliers = new double[7 * SKILL_count]();
for (int i = 0; i < SKILL_count; i++) { for (int i = 0; i < SKILL_count; i++) {