bool C4ObjectList::CheckSort(C4ObjectList *pList) { C4ObjectLink *cLnk = First, *cLnk2 = pList->First; while (cLnk && (!cLnk->Obj->Status || cLnk->Obj->Unsorted)) cLnk = cLnk->Next; while (cLnk) if (!cLnk2) { Log("CheckSort failure"); C4ValueNumbers numbers; LogSilent(DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(C4ObjectListDumpHelper(this, &numbers), "SectorList")).getData()); LogSilent(DecompileToBuf<StdCompilerINIWrite>(mkNamingAdapt(C4ObjectListDumpHelper(pList, &numbers), "MainList")).getData()); return false; } else { if (cLnk->Obj == cLnk2->Obj) { cLnk = cLnk->Next; while (cLnk && (!cLnk->Obj->Status || cLnk->Obj->Unsorted)) cLnk = cLnk->Next; } cLnk2 = cLnk2->Next; } return true; }
bool DebugLog(const char *strMessage) { if (Game.DebugMode) return Log(strMessage); else return LogSilent(strMessage); }
bool Log(const char *szMessage) { if (!Application.AssertMainThread()) return false; if (iDisableLog) return true; // security if (!szMessage) return false; #ifndef NOAULDEBUG // Pass on to debugger if (C4AulDebug *pDebug = C4AulDebug::GetDebugger()) pDebug->OnLog(szMessage); #endif // Pass on to console Console.Out(szMessage); // pass on to lobby C4GameLobby::MainDlg *pLobby = ::Network.GetLobby(); if (pLobby) pLobby->OnLog(szMessage); // Add message to log buffer bool fNotifyMsgBoard = false; if (::GraphicsSystem.MessageBoard) { ::GraphicsSystem.MessageBoard->AddLog(szMessage); fNotifyMsgBoard = true; } // log LogSilent(szMessage, true); // Notify message board if (fNotifyMsgBoard) ::GraphicsSystem.MessageBoard->LogNotify(); return true; }
bool Log(const char *szMessage) { if (!Application.AssertMainThread()) return false; if (iDisableLog) return true; // security if (!szMessage) return false; // Pass on to console Console.Out(szMessage); // pass on to lobby C4GameLobby::MainDlg *pLobby = Game.Network.GetLobby(); if (pLobby && Game.pGUI) pLobby->OnLog(szMessage); // Add message to log buffer bool fNotifyMsgBoard = false; if (Game.GraphicsSystem.MessageBoard.Active) { Game.GraphicsSystem.MessageBoard.AddLog(szMessage); fNotifyMsgBoard = true; } // log LogSilent(szMessage, true); // Notify message board if (fNotifyMsgBoard) Game.GraphicsSystem.MessageBoard.LogNotify(); return true; }
void C4LSectors::Dump() { C4ValueNumbers numbers; LogSilent(DecompileToBuf<StdCompilerINIWrite>( mkNamingAdapt( mkArrayAdaptMap(Sectors, Size, mkParAdaptMaker(&numbers)), "Sector")).getData()); }
bool LogSilentF(const char *strMessage, ...) { va_list args; va_start(args, strMessage); // Compose formatted message StdStrBuf Buf; Buf.FormatV(strMessage, args); // Log return LogSilent(Buf.getData()); }
void CPNGFile::WaitForSaves() { // Yield main thread until all pending saves have finished.Wait for bool first = true; while (CPNGSaveThread::HasPendingThreads()) { // English message because localization data is no longer loaded if (first) LogSilent("Waiting for pending image files to be written to disc..."); first = false; #ifdef HAVE_WINTHREAD Sleep(100); #else sched_yield(); #endif } }
void C4InteractiveThread::ProcessEvents() // by main thread { C4InteractiveEventType eEventType; void *pEventData; while (PopEvent(&eEventType, &pEventData)) switch (eEventType) { // Logging case Ev_Log: case Ev_LogSilent: case Ev_LogFatal: case Ev_LogDebug: { // Reconstruct the StdStrBuf which allocated the data. StdStrBuf pLog; pLog.Take(reinterpret_cast<char *>(pEventData)); switch (eEventType) { case Ev_Log: Log(pLog.getData()); break; case Ev_LogSilent: LogSilent(pLog.getData()); break; case Ev_LogFatal: LogFatal(pLog.getData()); break; case Ev_LogDebug: DebugLog(pLog.getData()); break; default: assert(eEventType == Ev_Log || eEventType == Ev_LogSilent || eEventType == Ev_LogFatal || eEventType == Ev_LogDebug); // obviously will not happen, but someone tell gcc } } break; case Ev_Function: { std::unique_ptr<std::function<void ()> > func(static_cast<std::function<void()>*>(pEventData)); (*func)(); } // Other events: check for a registered handler default: if (eEventType >= Ev_None && eEventType <= Ev_Last) if (pCallbacks[eEventType]) pCallbacks[eEventType]->OnThreadEvent(eEventType, pEventData); // Note that memory might leak if the event wasn't processed.... } }
bool LogSilent(const char *szMessage) { return LogSilent(szMessage, false); }
void C4MainStat::Show() { // count stats unsigned int iCnt = 0; C4Stat* pAkt; for (pAkt = pFirst; pAkt; pAkt = pAkt->pNext) iCnt++; // create array C4Stat** StatArray = new C4Stat*[iCnt]; bool* bHS = new bool[iCnt]; // sort it unsigned int i,ii; for (ii=0; ii<iCnt; ii++) bHS[ii] = false; for (i=0; i<iCnt; i++) { C4Stat* pBestStat = NULL; unsigned int iBestNr = ~0; for (ii=0, pAkt = pFirst; ii<iCnt; ii++, pAkt = pAkt->pNext) if (!bHS[ii]) { if (iBestNr == ~0u) { iBestNr = ii; pBestStat = pAkt; } else if (stricmp(pBestStat->strName, pAkt->strName) > 0) { iBestNr = ii; pBestStat = pAkt; } } if (iBestNr == (unsigned int) -1) break; bHS[iBestNr] = true; StatArray[i] = pBestStat; } delete bHS; LogSilent("** Stat"); // output in order for (i=0; i<iCnt; i++) { pAkt = StatArray[i]; // output it! if (pAkt->iCount) LogSilentF("%s: n = %u, t = %u, td = %.2f", pAkt->strName, pAkt->iCount, pAkt->tTimeSum, double(pAkt->tTimeSum) / pAkt->iCount * 1000); } // delete... delete[] StatArray; // ok. job done LogSilent("** Stat end"); }