mw4print: add -debug flag for step-by-step diagnostic logging

Adds runtime diagnostic logging to track down why printing is broken.
Pass -debug (or /debug) on the command line; all output goes to
mw4print-debug.txt next to the exe (append mode, timestamped lines).
No effect on normal operation when the flag is absent.

What is logged:
- Startup: AssetsDirectory1 path and full command line
- OnCreate: DB config loaded, timer created
- DoCopyData / OnFileOpen: each file queued for printing with filename
- OnTimer: which file is being processed each second, LoadPR result
- DoPrint: nPlayers count, PrintDlg call + result (on failure logs
  CommDlgExtendedError hex code), DB export call/result, SetupFonts
  result, StartDoc result, EndDoc vs AbortDoc, final return code

The CommDlgExtendedError value on a PrintDlg failure will identify the
root cause (e.g. CDERR_NODEFAULTPRN = no default printer configured).

Co-authored-by: Claude Sonnet 4.6 (Anthropic) <noreply@anthropic.com>
Co-authored-by: GitHub Copilot <copilot@github.com>
This commit is contained in:
2026-08-07 21:53:02 -05:00
co-authored by Claude Sonnet 4.6 GitHub Copilot
parent 10301ee5dd
commit 3256c103a2
5 changed files with 88 additions and 3 deletions
@@ -55,6 +55,14 @@ BOOL CMW4PrintApp::InitInstance()
AssetsDirectory1[0] = '\0';
}
const char* pszCmd = GetCommandLine();
if (strstr(pszCmd, "-debug") || strstr(pszCmd, "/debug")) {
g_bDebugLog = true;
DbgLog("=== mw4print started ===");
DbgLog("AssetsDirectory1: %s", AssetsDirectory1);
DbgLog("CommandLine: %s", pszCmd);
}
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else