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:
co-authored by
Claude Sonnet 4.6
GitHub Copilot
parent
10301ee5dd
commit
3256c103a2
@@ -296,6 +296,7 @@ bool CChildView::DoCopyData(HWND hwnd, const MW4PRINT_COPYDATASTRUCT& cd)
|
||||
#endif // _DEBUG
|
||||
CMyPrintInfo* p = new CMyPrintInfo(pcsz, g_bPRTest);
|
||||
m_lstMPIs.AddTail(p);
|
||||
DbgLog("DoCopyData: queued file '%s' bIncludeBot=%d", pcsz, (int)g_bPRTest);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -309,8 +310,10 @@ int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
||||
return -1;
|
||||
|
||||
DB_LoadConfig();
|
||||
DbgLog("OnCreate: DB_LoadConfig done, bEnabled=%d", (int)g_dbConfig.bEnabled);
|
||||
|
||||
m_uTimer = SetTimer(IDT_TIMER, 1 * 1000, NULL);
|
||||
DbgLog("OnCreate: timer id=%u", m_uTimer);
|
||||
if (!m_uTimer)
|
||||
return -1;
|
||||
|
||||
@@ -331,17 +334,27 @@ void CChildView::OnTimer(UINT nIDEvent)
|
||||
// TODO: Add your message handler code here and/or call default
|
||||
if (nIDEvent == IDT_TIMER) {
|
||||
CMyPrintInfo* p = m_lstMPIs.GetHead();
|
||||
if (p) DbgLog("OnTimer: head item='%s' bPrinted=%d", (const char*)p->m_strFile, (int)p->m_bPrinted);
|
||||
while(p) {
|
||||
if (!p->m_bPrinted) {
|
||||
hWindow = m_hWnd;
|
||||
g_bPRTest = p->m_bIncludeBot;
|
||||
if (g_RSF.LoadPR(p->m_strFile)) {
|
||||
DbgLog("OnTimer: calling LoadPR for '%s'", (const char*)p->m_strFile);
|
||||
bool bLoaded = g_RSF.LoadPR(p->m_strFile);
|
||||
DbgLog("OnTimer: LoadPR returned %d", (int)bLoaded);
|
||||
if (bLoaded) {
|
||||
int nErr = g_RSF.DoPrint();
|
||||
DbgLog("OnTimer: DoPrint returned %d", nErr);
|
||||
if (nErr == 0) {
|
||||
p->m_bPrinted = true;
|
||||
m_lstMPIs.Cut(p);
|
||||
delete p;
|
||||
DbgLog("OnTimer: item printed and removed from queue");
|
||||
} else {
|
||||
DbgLog("OnTimer: DoPrint FAILED nErr=%d, item stays in queue", nErr);
|
||||
}
|
||||
} else {
|
||||
DbgLog("OnTimer: LoadPR FAILED for '%s'", (const char*)p->m_strFile);
|
||||
}
|
||||
g_RSF.Reset();
|
||||
break;
|
||||
@@ -514,6 +527,7 @@ void CChildView::OnFileOpen()
|
||||
g_bPRTest = (FD.m_ofn.Flags & OFN_READONLY) ? true: false;
|
||||
#endif // _DEBUG
|
||||
CString str(FD.GetPathName());
|
||||
DbgLog("OnFileOpen: queuing file '%s' bIncludeBot=%d", (const char*)str, (int)g_bPRTest);
|
||||
CMyPrintInfo* p = new CMyPrintInfo(str, g_bPRTest);
|
||||
m_lstMPIs.AddTail(p);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user