diff --git a/sfall/Books.cpp b/sfall/Books.cpp index e72adcdc..b1c399a0 100644 --- a/sfall/Books.cpp +++ b/sfall/Books.cpp @@ -89,7 +89,7 @@ void BooksInit() { GetPrivateProfileString("Misc", "BooksFile", "", buf, MAX_PATH, ini); if (strlen(buf)>0) { sprintf(iniBooks, ".\\%s", buf); - dlog("Applying books patch... ", DL_INIT); + dlog("Applying books patch...", DL_INIT); memset(books,0,sizeof(sBook)*BooksCount); int i, n = 0, count; @@ -111,6 +111,6 @@ void BooksInit() { } MakeCall(0x49B9FB, &obj_use_book_hook, true); - dlog_f(" (%d/%d books) Done\r\n", DL_INIT, n, count); + dlog_f(" (%d/%d books) Done\n", DL_INIT, n, count); } } \ No newline at end of file diff --git a/sfall/Bugs.cpp b/sfall/Bugs.cpp index 0f1c930c..23c35c7d 100644 --- a/sfall/Bugs.cpp +++ b/sfall/Bugs.cpp @@ -590,13 +590,6 @@ end: } } -static void __declspec(naked) item_d_take_drug_hack1() { - __asm { - push 0x47A168 - retn - } -} - static void __declspec(naked) op_wield_obj_critter_adjust_ac_hook() { __asm { call adjust_ac_ @@ -1176,7 +1169,7 @@ void BugsInit() //if (GetPrivateProfileIntA("Misc", "JetAntidoteFix", 1, ini)) { dlog("Applying Jet Antidote fix.", DL_INIT); // the original jet antidote fix - MakeCall(0x47A013, &item_d_take_drug_hack1, true); + MakeCall(0x47A013, (void*)0x47A168, true); dlogr(" Done", DL_INIT); //} diff --git a/sfall/CRC.cpp b/sfall/CRC.cpp index 1a162e7b..e8bef470 100644 --- a/sfall/CRC.cpp +++ b/sfall/CRC.cpp @@ -22,8 +22,8 @@ #include "version.h" #include "Logging.h" -static const DWORD ExpectedSize=0x00122800; -static const DWORD ExpectedCRC[]= {0xe1680293, 0xef34f989}; +static const DWORD ExpectedSize = 0x00122800; +static const DWORD ExpectedCRC[] = {0xe1680293, 0xef34f989}; static void inline Fail(const char* a) { MessageBoxA(0, a, "Error", MB_TASKMODAL); ExitProcess(1); } @@ -63,11 +63,11 @@ static const DWORD CRC_table[256] = { }; static DWORD crcInternal(BYTE* data, DWORD size) { - DWORD crc=0xffffffff; - for (DWORD i = 0;i < size;i++) { + DWORD crc = 0xffffffff; + for (DWORD i = 0; i < size; i++) { crc = CRC_table[(((BYTE)(crc)) ^ data[i])] ^ (crc >> 8); } - return crc^0xffffffff; + return crc ^ 0xffffffff; } void CRC(const char* filepath) { @@ -101,7 +101,7 @@ void CRC(const char* filepath) { } } - for (int i=0; i < sizeof(ExpectedCRC)/4; i++) { + for (int i = 0; i < sizeof(ExpectedCRC) / 4; i++) { if (crc == ExpectedCRC[i]) matchedCRC = true; } if (!matchedCRC) { diff --git a/sfall/Criticals.cpp b/sfall/Criticals.cpp index eddea814..d45163e7 100644 --- a/sfall/Criticals.cpp +++ b/sfall/Criticals.cpp @@ -133,7 +133,7 @@ void CritLoad() { } } } - dlogr("Completed critical hit table", DL_CRITICALS); + dlogr("Completed critical hit table.", DL_CRITICALS); } #define SetEntry(a,b,c,d,e) defaultTable[a*9*6 + b*6 + c].values[d]=e; @@ -143,12 +143,11 @@ void CritInit() { if(!mode) return; - dlog("Initilizing critical table override.", DL_INIT); + dlog("Initializing critical table override.", DL_INIT); critTable=new CritStruct[CritTableSize]; playerCrit=&critTable[6*9*38]; SafeWrite32(0x423F96, (DWORD)playerCrit); SafeWrite32(0x423FB3, (DWORD)critTable); - dlog(". ", DL_INIT); if(mode==2 || mode==3) { CritStruct* defaultTable=(CritStruct*)_crit_succ_eff; diff --git a/sfall/Explosions.cpp b/sfall/Explosions.cpp index c360381a..7aa09ea0 100644 --- a/sfall/Explosions.cpp +++ b/sfall/Explosions.cpp @@ -212,7 +212,7 @@ void ExplosionLightingInit() { MakeCall(0x411AB4, &explosion_effect_hook, true); // required for explosions_metarule if (GetPrivateProfileIntA("Misc", "ExplosionsEmitLight", 0, ini)) { - dlog("Initing Explosion changes.", DL_INIT); + dlog("Applying Explosion changes.", DL_INIT); lightingEnabled = true; MakeCall(0x4118E1, &ranged_attack_lighting_fix, true); MakeCall(0x410A4A, &fire_dance_lighting_fix1, true); diff --git a/sfall/HookScripts.cpp b/sfall/HookScripts.cpp index 06279631..1b33c814 100644 --- a/sfall/HookScripts.cpp +++ b/sfall/HookScripts.cpp @@ -91,7 +91,7 @@ static void _stdcall RunSpecificHookScript(sHookScript *hook) { static void _stdcall RunHookScript(DWORD hook) { if (hooks[hook].size()) { - dlog_f("Running hook %d, which has %0d entries attached\r\n", DL_HOOK, hook, hooks[hook].size()); + dlog_f("Running hook %d, which has %0d entries attached\n", DL_HOOK, hook, hooks[hook].size()); cRet=0; for(int i=hooks[hook].size()-1;i>=0;i--) RunSpecificHookScript(&hooks[hook][i]); } else { @@ -1106,7 +1106,7 @@ void _stdcall RegisterHook( DWORD script, DWORD id, DWORD procNum ) } sScriptProgram *prog = GetGlobalScriptProgram(script); if (prog) { - dlog_f("Global script %08x registered as hook id %d\r\n", DL_HOOK, script, id); + dlog_f("Global script %08x registered as hook id %d\n", DL_HOOK, script, id); sHookScript hook; hook.prog = *prog; hook.callback = procNum; @@ -1308,7 +1308,7 @@ static void HookScriptInit2() { call db_free_file_list_ } - dlogr("Finished loading hook scripts", DL_HOOK|DL_INIT); + dlogr("Finished loading hook scripts.", DL_HOOK|DL_INIT); } void HookScriptClear() { diff --git a/sfall/LoadGameHook.cpp b/sfall/LoadGameHook.cpp index 104b3f17..7fefb8de 100644 --- a/sfall/LoadGameHook.cpp +++ b/sfall/LoadGameHook.cpp @@ -90,7 +90,7 @@ static void _stdcall SaveGame2() { char buf[MAX_PATH]; GetSavePath(buf, "gv"); - dlog_f("Saving game: %s\r\n", DL_MAIN, buf); + dlog_f("Saving game: %s\n", DL_MAIN, buf); DWORD size, unused = 0; HANDLE h = CreateFileA(buf, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); @@ -177,7 +177,7 @@ static void _stdcall LoadGame2_Before() { char buf[MAX_PATH]; GetSavePath(buf, "gv"); - dlog_f("Loading save game: %s\r\n", DL_MAIN, buf); + dlog_f("Loading save game: %s\n", DL_MAIN, buf); ClearGlobals(); HANDLE h = CreateFileA(buf, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0); diff --git a/sfall/Logging.cpp b/sfall/Logging.cpp index 0f146b25..46f55327 100644 --- a/sfall/Logging.cpp +++ b/sfall/Logging.cpp @@ -36,7 +36,7 @@ void dlog(const char* a, int type) { } void dlogr(const char* a, int type) { if (IsDebug && (type == DL_MAIN || (type & DebugTypes))) { - Log << a << "\r\n"; + Log << a << "\n"; Log.flush(); } } diff --git a/sfall/PartyControl.cpp b/sfall/PartyControl.cpp index dd17acea..01840c0f 100644 --- a/sfall/PartyControl.cpp +++ b/sfall/PartyControl.cpp @@ -368,7 +368,7 @@ void PartyControlInit() { if (strlen(ptr) > 0) Chars.push_back((WORD)strtoul(ptr, 0, 0)); } - dlog_f(" Mode %d, Chars read: %d.", DL_INIT, Mode, Chars.size()); + dlog_f(" Mode %d, Chars read: %d.\n", DL_INIT, Mode, Chars.size()); HookCall(0x46EBEE, &FidChangeHook); @@ -380,7 +380,7 @@ void PartyControlInit() { HookCall(0x4124F1, &pc_flag_toggle_hook); HookCall(0x41279A, &pc_flag_toggle_hook); } else - dlog(" Disabled.", DL_INIT); + dlogr(" Disabled.", DL_INIT); } void __stdcall PartyControlReset() { diff --git a/sfall/ScriptExtender.cpp b/sfall/ScriptExtender.cpp index b650d5b9..52ec7a63 100644 --- a/sfall/ScriptExtender.cpp +++ b/sfall/ScriptExtender.cpp @@ -1011,7 +1011,7 @@ static DWORD __stdcall GetGlobalExportedVarPtr(const char* name) { return 0; } static DWORD __stdcall CreateGlobalExportedVar(DWORD scr, const char* name) { - //dlog_f("\nTrying to export variable %s (%d)\r\n", DL_MAIN, name, isGlobalScriptLoading); + //dlog_f("\nTrying to export variable %s (%d)\n", DL_MAIN, name, isGlobalScriptLoading); std::string str(name); globalExportedVars[str] = sExportedVar(); // add new return 1; @@ -1203,8 +1203,8 @@ void ScriptExtenderSetup() { modifiedIni = GetPrivateProfileIntA("Main", "ModifiedIni", 0, ini); dlogr("Adding additional opcodes", DL_SCRIPT); - if(AllowUnsafeScripting) dlogr(" Unsafe opcodes enabled", DL_SCRIPT); - else dlogr(" Unsafe opcodes disabled", DL_SCRIPT); + if(AllowUnsafeScripting) dlogr(" Unsafe opcodes enabled.", DL_SCRIPT); + else dlogr(" Unsafe opcodes disabled.", DL_SCRIPT); arraysBehavior = GetPrivateProfileIntA("Misc", "arraysBehavior", 1, ini); if (arraysBehavior > 0) { @@ -1643,7 +1643,7 @@ void LoadGlobalScripts() { lea eax, filenames call db_free_file_list_ } - dlogr("Finished loading global scripts", DL_SCRIPT|DL_INIT); + dlogr("Finished loading global scripts.", DL_SCRIPT|DL_INIT); //ButtonsReload(); } diff --git a/sfall/main.cpp b/sfall/main.cpp index a4c6498b..489545fc 100644 --- a/sfall/main.cpp +++ b/sfall/main.cpp @@ -800,9 +800,8 @@ static void DllMain2() { DWORD tmp; dlogr("In DllMain2", DL_MAIN); - dlogr("Running BugsInit.", DL_INIT); + dlogr("Running BugsInit().", DL_INIT); BugsInit(); - dlogr(" Done", DL_INIT); if (GetPrivateProfileIntA("Speed", "Enable", 0, ini)) { dlog("Applying speed patch.", DL_INIT); @@ -1047,8 +1046,10 @@ static void DllMain2() { dlog(".", DL_INIT); SkillsInit(); dlog(".", DL_INIT); + dlogr(" Done", DL_INIT); //Ray's combat_p_proc fix + dlog("Applying combat_p_proc fix.", DL_INIT); SafeWrite32(0x0425253, ((DWORD)&Combat_p_procFix) - 0x0425257); SafeWrite8(0x0424dbc, 0xE9); SafeWrite32(0x0424dbd, 0x00000034); @@ -1057,7 +1058,6 @@ static void DllMain2() { //if (GetPrivateProfileIntA("Misc", "WorldMapCitiesListFix", 0, ini)) { dlog("Applying world map cities list patch.", DL_INIT); - SafeWrite32(0x004C04BA, ((DWORD)&ScrollCityListHook) - 0x004C04BE); SafeWrite32(0x004C04C9, ((DWORD)&ScrollCityListHook) - 0x004C04CD); SafeWrite32(0x004C4A35, ((DWORD)&ScrollCityListHook) - 0x004C4A39); @@ -1146,7 +1146,7 @@ static void DllMain2() { npcautolevel = GetPrivateProfileIntA("Misc", "NPCAutoLevel", 0, ini) != 0; if (npcautolevel) { - dlog("Applying npc autolevel patch.", DL_INIT); + dlog("Applying NPC autolevel patch.", DL_INIT); SafeWrite8(0x495CFB, 0xEB); // jmps 0x495D28 (skip random check) dlogr(" Done", DL_INIT); } @@ -1288,17 +1288,18 @@ static void DllMain2() { dlogr("Running TilesInit().", DL_INIT); TilesInit(); - dlogr("Applying main menu text patch", DL_INIT); + dlogr("Running CreditsInit().", DL_INIT); CreditsInit(); if (GetPrivateProfileIntA("Misc", "UseScrollingQuestsList", 0, ini)) { - dlog("Applying quests list patch ", DL_INIT); + dlog("Applying quests list patch.", DL_INIT); QuestListInit(); dlogr(" Done", DL_INIT); } - dlog("Applying premade characters patch", DL_INIT); + dlog("Applying premade characters patch.", DL_INIT); PremadeInit(); + dlogr(" Done", DL_INIT); dlogr("Running SoundInit().", DL_INIT); SoundInit(); @@ -1310,9 +1311,8 @@ static void DllMain2() { ConsoleInit(); if (GetPrivateProfileIntA("Misc", "ExtraSaveSlots", 0, ini)) { - dlog("Running EnableSuperSaving()", DL_INIT); + dlogr("Running EnableSuperSaving().", DL_INIT); EnableSuperSaving(); - dlogr(" Done", DL_INIT); } switch (GetPrivateProfileIntA("Misc", "SpeedInterfaceCounterAnims", 0, ini)) { @@ -1440,9 +1440,8 @@ static void DllMain2() { dlogr(" Done", DL_INIT); } - dlog("Running InventoryInit.", DL_INIT); + dlogr("Running InventoryInit().", DL_INIT); InventoryInit(); - dlogr(" Done", DL_INIT); if (tmp = GetPrivateProfileIntA("Misc", "MotionScannerFlags", 1, ini)) { dlog("Applying MotionScannerFlags patch.", DL_INIT); @@ -1468,7 +1467,7 @@ static void DllMain2() { dlogr(" Done", DL_INIT); } - dlog("Initing main menu patches.", DL_INIT); + dlog("Applying main menu patches.", DL_INIT); MainMenuInit(); dlogr(" Done", DL_INIT); @@ -1476,13 +1475,12 @@ static void DllMain2() { SafeWrite8(0x499518, 0xc3); } - dlog("Initing AI patches.", DL_INIT); + dlog("Applying AI patches.", DL_INIT); AIInit(); dlogr(" Done", DL_INIT); - dlog("Initing AI control.", DL_INIT); + dlogr("Initializing AI control.", DL_INIT); PartyControlInit(); - dlogr(" Done", DL_INIT); //HookCall(0x413105, explosion_crash_fix_hook);//test for explosives //SafeWrite32(0x413034, (DWORD)&explosion_crash_fix_hook); diff --git a/sfall/main.h b/sfall/main.h index c4e69c50..fa9cf9c5 100644 --- a/sfall/main.h +++ b/sfall/main.h @@ -55,7 +55,7 @@ T SimplePatch(DWORD *addrs, int numAddrs, const char* iniSection, const char* in value = minValue; else if (value > maxValue) value = maxValue; - sprintf(msg, "Applying patch: %s = %d.", iniKey, value); + _snprintf_s(msg, sizeof msg, _TRUNCATE, "Applying patch: %s = %d.", iniKey, value); dlog((const char *)msg, DL_INIT); for (int i=0; i(addrs[i], (T)value);