Reduced buffer flush in Logging.cpp

Edited some description in ddraw.ini.
This commit is contained in:
NovaRain
2023-06-15 13:24:02 +08:00
parent 7bf562338c
commit 7baa6de014
2 changed files with 22 additions and 24 deletions
+6 -6
View File
@@ -523,7 +523,7 @@ ScienceOnCritters=0
;Default is 166 (lower - faster; valid range: 0..1000) ;Default is 166 (lower - faster; valid range: 0..1000)
SpeedInventoryPCRotation=166 SpeedInventoryPCRotation=166
;Modify the number of the extra interface boxes available to modders. (Default is 5, and the maximum is 95) ;Modify the number of the extra interface boxes available to modders (Default is 5, and the maximum is 95)
BoxBarCount=5 BoxBarCount=5
;Uncomment to set the text colour of the extra interface boxes ;Uncomment to set the text colour of the extra interface boxes
@@ -536,7 +536,7 @@ BonusHtHDamageFix=1
;Set to 1 to display additional points of damage from Bonus HtH/Ranged Damage perks in the inventory ;Set to 1 to display additional points of damage from Bonus HtH/Ranged Damage perks in the inventory
DisplayBonusDamage=0 DisplayBonusDamage=0
;Modify the maximum number of animations allowed to run on a map. (Default is 32, and the maximum is 127) ;Modify the maximum number of animations allowed to run on a map (Default is 32, and the maximum is 127)
AnimationsAtOnceLimit=64 AnimationsAtOnceLimit=64
;Set to 1 to remove the limits that stop the game from rolling critical successes/failures in the first few days of game time ;Set to 1 to remove the limits that stop the game from rolling critical successes/failures in the first few days of game time
@@ -846,7 +846,7 @@ AllowUnsafeScripting=0
SkipCompatModeCheck=0 SkipCompatModeCheck=0
;Fallout 2 Debug Patch ;Fallout 2 Debug Patch
;Set to 1 to send debug output to the screen, 2 to a debug.log file, or 3 to both the screen and debug.log ;Set to 1 to send debug output to the screen, 2 to a debug.log file, or 3 to both
;Does not require sfall debugging mode ;Does not require sfall debugging mode
;While you don't need to create an environment variable, you do still need to set the appropriate lines in fallout2.cfg ;While you don't need to create an environment variable, you do still need to set the appropriate lines in fallout2.cfg
;------- ;-------
@@ -895,9 +895,9 @@ Criticals=1
;Prints messages relating to engine fixes ;Prints messages relating to engine fixes
Fixes=1 Fixes=1
;Duplicate log to dedicated console window, shown alongside the main game window ;Duplicates logs to a dedicated console window alongside the game window
;Set to 1 to display debug.log output (requires DebugMode > 0), 2 to display sfall log, 3 for both. ;Set to 1 to display debug output (requires DebugMode to be enabled), 2 to display sfall log, or 3 for both
ConsoleWindow=0 ConsoleWindow=0
;Updated automatically, don't change ;Console window position and size data. Do not modify
ConsoleWindowData= ConsoleWindowData=
+16 -18
View File
@@ -93,7 +93,7 @@ void ConsoleWindow::loadPosition() {
windowData[i] = atoi(windowDataSplit.at(i).c_str()); windowData[i] = atoi(windowDataSplit.at(i).c_str());
} }
if (!SetWindowPos(wnd, HWND_TOP, windowData[0], windowData[1], windowData[2], windowData[3], 0)) { if (!SetWindowPos(wnd, HWND_TOP, windowData[0], windowData[1], windowData[2], windowData[3], 0)) {
dlog_f("Error Repositioning console window: %x \n", DL_MAIN, GetLastError()); dlog_f("Error repositioning console window: 0x%x\n", DL_MAIN, GetLastError());
} }
} }
@@ -101,17 +101,17 @@ void ConsoleWindow::savePosition() {
HWND wnd; HWND wnd;
if (!tryGetWindow(&wnd)) return; if (!tryGetWindow(&wnd)) return;
tagRECT wndRect; RECT wndRect;
if (!GetWindowRect(wnd, &wndRect)) { if (!GetWindowRect(wnd, &wndRect)) {
dlog_f("Error getting console window position: %x \n", DL_MAIN, GetLastError()); dlog_f("Error getting console window position: 0x%x\n", DL_MAIN, GetLastError());
} }
int width = wndRect.right - wndRect.left; int width = wndRect.right - wndRect.left;
int height = wndRect.bottom - wndRect.top; int height = wndRect.bottom - wndRect.top;
std::ostringstream ss; std::ostringstream ss;
ss << wndRect.left << "," << wndRect.top << "," << width << "," << height; ss << wndRect.left << "," << wndRect.top << "," << width << "," << height;
auto wndDataStr = ss.str(); auto wndDataStr = ss.str();
dlog_f("Saving console window position & size: %s", DL_MAIN, wndDataStr.c_str()); dlog_f("Saving console window position & size: %s\n", DL_MAIN, wndDataStr.c_str());
IniReader::SetDefaultConfigString(IniSection, IniPositionKey, wndDataStr.c_str()); IniReader::SetDefaultConfigString(IniSection, IniPositionKey, wndDataStr.c_str());
} }
@@ -119,16 +119,14 @@ static void __fastcall PrintToConsole(const char* a) {
ConsoleWindow::instance().falloutLog(a); ConsoleWindow::instance().falloutLog(a);
} }
static void __declspec(naked) debug_printf_hack() { static void __declspec(naked) debug_printf_hook() {
static const DWORD backRet = 0x4C6F7C;
__asm { __asm {
call fo::funcoffs::vsprintf_; call fo::funcoffs::vsprintf_;
pushadc; pushadc;
mov ecx, esp; lea ecx, [esp + 16];
add ecx, 12;
call PrintToConsole; call PrintToConsole;
popadc; popadc;
jmp backRet; retn;
} }
} }
@@ -136,17 +134,17 @@ void ConsoleWindow::init() {
_mode = IniReader::GetIntDefaultConfig(IniSection, IniModeKey, 0); _mode = IniReader::GetIntDefaultConfig(IniSection, IniModeKey, 0);
if (_mode == 0) return; if (_mode == 0) return;
if (!AllocConsole()) { if (!AllocConsole()) {
dlog_f("Failed to alloc console: %x", DL_MAIN, GetLastError()); dlog_f("Failed to allocate console: 0x%x\n", DL_MAIN, GetLastError());
return; return;
} }
freopen("CONOUT$", "w", stdout); // this allows to print to console via std::cout freopen("CONOUT$", "w", stdout); // this allows to print to console via std::cout
if (_mode & ConsoleSource::GAME) { if (_mode & ConsoleSource::GAME) {
std::cout << "Displaying debug_printf output." << std::endl; std::cout << "Displaying debug_printf output.\n";
MakeJump(0x4C6F77, debug_printf_hack); HookCall(0x4C6F77, debug_printf_hook);
} }
if (_mode & ConsoleSource::SFALL) { if (_mode & ConsoleSource::SFALL) {
std::cout << "Displaying sfall debug output." << std::endl; std::cout << "Displaying sfall debug output.\n";
} }
std::cout << std::endl; std::cout << std::endl;
@@ -168,7 +166,7 @@ void ConsoleWindow::sfallLog(const std::string& a, int type) {
if (!(_mode & ConsoleSource::SFALL)) return; if (!(_mode & ConsoleSource::SFALL)) return;
if (_lastSource == ConsoleSource::GAME) { if (_lastSource == ConsoleSource::GAME) {
std::cout << std::endl; // To make logs prettier, because debug_msg places newline before the message. std::cout << "\n"; // To make logs prettier, because debug_msg places newline before the message.
} }
std::cout << a; std::cout << a;
_lastSource = ConsoleSource::SFALL; _lastSource = ConsoleSource::SFALL;
@@ -182,11 +180,11 @@ static void OutLog(T a, int type, bool newLine = false) {
ss << "[" << DebugTypeToStr(type) << "] "; ss << "[" << DebugTypeToStr(type) << "] ";
} }
ss << a; ss << a;
if (newLine) ss << std::endl; if (newLine) ss << "\n";
std::string str = ss.str(); std::string str = ss.str();
ConsoleWindow::instance().sfallLog(str, type); ConsoleWindow::instance().sfallLog(str, type);
Log << str; Log << str;
Log.flush(); Log.flush();
@@ -278,7 +276,7 @@ void LoggingInit() {
if (IniReader::GetIntDefaultConfig("Debugging", "Fixes", 0)) { if (IniReader::GetIntDefaultConfig("Debugging", "Fixes", 0)) {
DebugTypes |= DL_FIX; DebugTypes |= DL_FIX;
} }
ConsoleWindow::instance().init(); ConsoleWindow::instance().init();
} }