diff --git a/CMakeLists.txt b/CMakeLists.txt index d22e29674..3746f4911 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -459,6 +459,7 @@ set(OC_CLONK_SOURCES src/platform/C4ViewportWindow.cpp src/platform/C4ViewportWindow.h src/platform/C4windowswrapper.h + src/platform/GetTime.cpp src/platform/PlatformAbstraction.h src/platform/StdConfig.cpp src/platform/StdConfig.h @@ -870,6 +871,7 @@ add_executable(netpuncher src/C4Include.cpp src/lib/StdBuf.cpp src/lib/Standard.cpp + src/platform/GetTime.cpp src/platform/StdScheduler.cpp src/platform/StdFile.cpp src/network/C4NetIO.cpp @@ -893,6 +895,7 @@ add_executable(c4script EXCLUDE_FROM_ALL src/lib/StdMarkup.h src/lib/StdResStr2.cpp src/lib/StdResStr2.h + src/platform/GetTime.cpp src/platform/StdConfig.cpp src/platform/StdConfig.h src/platform/StdFile.cpp diff --git a/Makefile.am b/Makefile.am index b2a60604b..1f127f95b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -135,6 +135,7 @@ src/lib/StdMarkup.h \ src/lib/StdResStr2.cpp \ src/lib/StdResStr2.h \ src/network/C4NetIO.cpp \ +src/platform/GetTime.cpp \ src/platform/StdConfig.cpp \ src/platform/StdConfig.h \ src/platform/StdFile.cpp \ diff --git a/src/C4Application.cpp b/src/C4Application.cpp index 980010ac6..e5baae315 100644 --- a/src/C4Application.cpp +++ b/src/C4Application.cpp @@ -804,7 +804,7 @@ bool C4ApplicationGameTimer::Execute(int iTimeout, pollfd *) { // Check timer and reset if (!CheckAndReset()) return true; - unsigned int Now = timeGetTime(); + unsigned int Now = GetTime(); // Execute if (Now >= iLastGameTick + iGameTickDelay || Game.GameGo) { diff --git a/src/C4FullScreen.cpp b/src/C4FullScreen.cpp index ade179aa1..650f39d39 100644 --- a/src/C4FullScreen.cpp +++ b/src/C4FullScreen.cpp @@ -188,7 +188,7 @@ void C4FullScreen::HandleMessage (XEvent &e) switch (e.xbutton.button) { case Button1: - if (timeGetTime() - last_left_click < 400) + if (GetTime() - last_left_click < 400) { C4GUI::MouseMove(C4MC_Button_LeftDouble, e.xbutton.x, e.xbutton.y, e.xbutton.state, NULL); @@ -198,7 +198,7 @@ void C4FullScreen::HandleMessage (XEvent &e) { C4GUI::MouseMove(C4MC_Button_LeftDown, e.xbutton.x, e.xbutton.y, e.xbutton.state, NULL); - last_left_click = timeGetTime(); + last_left_click = GetTime(); } break; case Button2: @@ -206,7 +206,7 @@ void C4FullScreen::HandleMessage (XEvent &e) e.xbutton.x, e.xbutton.y, e.xbutton.state, NULL); break; case Button3: - if (timeGetTime() - last_right_click < 400) + if (GetTime() - last_right_click < 400) { C4GUI::MouseMove(C4MC_Button_RightDouble, e.xbutton.x, e.xbutton.y, e.xbutton.state, NULL); @@ -216,7 +216,7 @@ void C4FullScreen::HandleMessage (XEvent &e) { C4GUI::MouseMove(C4MC_Button_RightDown, e.xbutton.x, e.xbutton.y, e.xbutton.state, NULL); - last_right_click = timeGetTime(); + last_right_click = GetTime(); } break; case Button4: @@ -281,14 +281,14 @@ namespace { case SDL_BUTTON_LEFT: if (e.state == SDL_PRESSED) - if (timeGetTime() - lastLeftClick < 400 && abs(lastX-e.x) <= clickDist && abs(lastY-e.y) <= clickDist) + if (GetTime() - lastLeftClick < 400 && abs(lastX-e.x) <= clickDist && abs(lastY-e.y) <= clickDist) { lastLeftClick = 0; button = C4MC_Button_LeftDouble; } else { - lastLeftClick = timeGetTime(); + lastLeftClick = GetTime(); button = C4MC_Button_LeftDown; } else @@ -296,14 +296,14 @@ namespace break; case SDL_BUTTON_RIGHT: if (e.state == SDL_PRESSED) - if (timeGetTime() - lastRightClick < 400) + if (GetTime() - lastRightClick < 400) { lastRightClick = 0; button = C4MC_Button_RightDouble; } else { - lastRightClick = timeGetTime(); + lastRightClick = GetTime(); button = C4MC_Button_RightDown; } else diff --git a/src/C4Game.cpp b/src/C4Game.cpp index 76d566cc4..fcb86a3db 100644 --- a/src/C4Game.cpp +++ b/src/C4Game.cpp @@ -3199,7 +3199,7 @@ void C4Game::SetInitProgress(float fToProgress) if (InitProgress > LastInitProgress) { LastInitProgress=InitProgress; - LastInitProgressShowTime=timeGetTime(); + LastInitProgressShowTime=GetTime(); GraphicsSystem.MessageBoard.LogNotify(); } // Cheap hack to get the Console window updated while loading diff --git a/src/control/C4PlayerControl.cpp b/src/control/C4PlayerControl.cpp index e6cd38954..e0b77b43c 100644 --- a/src/control/C4PlayerControl.cpp +++ b/src/control/C4PlayerControl.cpp @@ -296,7 +296,7 @@ bool C4PlayerControlAssignment::IsComboMatched(const C4PlayerControlRecentKeyLis // check if combo is currently fulfilled (assuming TriggerKey is already matched) if (fComboIsSequence) { - DWORD tKeyLast = timeGetTime(); + DWORD tKeyLast = GetTime(); // combo is a sequence: The last keys of RecentKeys must match the sequence // the last ComboKey is the TriggerKey, which is omitted because it has already been matched and is not to be found in RecentKeys yet C4PlayerControlRecentKeyList::const_reverse_iterator ri = RecentKeys.rbegin(); @@ -809,7 +809,7 @@ bool C4PlayerControl::ProcessKeyDown(const C4KeyCodeEx &pressed_key, const C4Key { // add key to local "down" list if it's not already in there // except for some mouse events for which a down state does not make sense - C4PlayerControlRecentKey RKey(pressed_key,matched_key,timeGetTime()); + C4PlayerControlRecentKey RKey(pressed_key,matched_key,GetTime()); if (!Key_IsMouse(pressed_key.Key) || Inside(Key_GetMouseEvent(pressed_key.Key) & ~KEY_MOUSE_GameMask, KEY_MOUSE_Button1, KEY_MOUSE_ButtonMax)) { if (std::find(DownKeys.begin(), DownKeys.end(), pressed_key) == DownKeys.end()) DownKeys.push_back(RKey); @@ -1040,7 +1040,7 @@ void C4PlayerControl::Execute() } // cleanup old recent keys C4PlayerControlRecentKeyList::iterator irk; - DWORD tNow = timeGetTime(); + DWORD tNow = GetTime(); for (irk = RecentKeys.begin(); irk != RecentKeys.end(); ++irk) { C4PlayerControlRecentKey &rk = *irk; diff --git a/src/editor/C4ConsoleWin32.cpp b/src/editor/C4ConsoleWin32.cpp index 7cab89cb2..cf6a5094a 100644 --- a/src/editor/C4ConsoleWin32.cpp +++ b/src/editor/C4ConsoleWin32.cpp @@ -53,6 +53,8 @@ #include "C4ConsoleGUI.h" #include "C4Viewport.h" +#include +#include #include #include "resource.h" diff --git a/src/game/script/C4GameScript.cpp b/src/game/script/C4GameScript.cpp index d537ee7c1..956f0c7d5 100644 --- a/src/game/script/C4GameScript.cpp +++ b/src/game/script/C4GameScript.cpp @@ -1615,7 +1615,7 @@ static long FnGetTime(C4AulContext *) { // check network, record, etc if (::Control.SyncMode()) return 0; - return timeGetTime(); + return GetTime(); } static C4Value FnSetPlrExtraData(C4AulContext *cthr, C4Value *iPlayer_C4V, C4Value *strDataName_C4V, C4Value *Data) diff --git a/src/gui/C4Gui.h b/src/gui/C4Gui.h index 3abe25f69..910a59e7b 100644 --- a/src/gui/C4Gui.h +++ b/src/gui/C4Gui.h @@ -2449,7 +2449,7 @@ namespace C4GUI int32_t LDownX, LDownY; // position where left button was pressed last DWORD dwKeys; // shift, ctrl, etc. bool fActive; - time_t tLastMovementTime; // timeGetTime() when the mouse pos changed last + time_t tLastMovementTime; // GetTime() when the mouse pos changed last // whether last input was done by mouse // set to true whenever mouse pos changes or buttons are pressed @@ -2480,8 +2480,8 @@ namespace C4GUI void SetOwnedMouse(bool fToVal) { fActive=fToVal; } - void ResetToolTipTime() { tLastMovementTime = timeGetTime(); } - bool IsMouseStill() { return timeGetTime()-tLastMovementTime >= C4GUI_ToolTipShowTime; } + void ResetToolTipTime() { tLastMovementTime = GetTime(); } + bool IsMouseStill() { return GetTime()-tLastMovementTime >= C4GUI_ToolTipShowTime; } void ResetActiveInput() { fActiveInput = false; } bool IsActiveInput() { return fActiveInput; } diff --git a/src/gui/C4GuiDialogs.cpp b/src/gui/C4GuiDialogs.cpp index 7aa46728a..628440a82 100644 --- a/src/gui/C4GuiDialogs.cpp +++ b/src/gui/C4GuiDialogs.cpp @@ -364,7 +364,7 @@ namespace C4GUI switch (e.xbutton.button) { case Button1: - if (timeGetTime() - last_left_click < 400) + if (GetTime() - last_left_click < 400) { ::pGUI->MouseInput(C4MC_Button_LeftDouble, e.xbutton.x, e.xbutton.y, e.xbutton.state, pDlg, NULL); @@ -374,7 +374,7 @@ namespace C4GUI { ::pGUI->MouseInput(C4MC_Button_LeftDown, e.xbutton.x, e.xbutton.y, e.xbutton.state, pDlg, NULL); - last_left_click = timeGetTime(); + last_left_click = GetTime(); } break; case Button2: @@ -382,7 +382,7 @@ namespace C4GUI e.xbutton.x, e.xbutton.y, e.xbutton.state, pDlg, NULL); break; case Button3: - if (timeGetTime() - last_right_click < 400) + if (GetTime() - last_right_click < 400) { ::pGUI->MouseInput(C4MC_Button_RightDouble, e.xbutton.x, e.xbutton.y, e.xbutton.state, pDlg, NULL); @@ -392,7 +392,7 @@ namespace C4GUI { ::pGUI->MouseInput(C4MC_Button_RightDown, e.xbutton.x, e.xbutton.y, e.xbutton.state, pDlg, NULL); - last_right_click = timeGetTime(); + last_right_click = GetTime(); } break; case Button4: diff --git a/src/gui/C4GuiEdit.cpp b/src/gui/C4GuiEdit.cpp index 90613283f..0959d1eab 100644 --- a/src/gui/C4GuiEdit.cpp +++ b/src/gui/C4GuiEdit.cpp @@ -136,7 +136,7 @@ namespace C4GUI // reset selection iSelectionStart = iSelectionEnd = 0; // cursor might have moved: ensure it is shown - dwLastInputTime=timeGetTime(); + dwLastInputTime=GetTime(); } void Edit::DeleteSelection() @@ -148,7 +148,7 @@ namespace C4GUI // adjust cursor pos if (iCursorPos > iSelBegin) iCursorPos = Max(iSelBegin, iCursorPos - iSelEnd + iSelBegin); // cursor might have moved: ensure it is shown - dwLastInputTime=timeGetTime(); + dwLastInputTime=GetTime(); // nothing selected iSelectionStart = iSelectionEnd = iSelBegin; } @@ -175,7 +175,7 @@ namespace C4GUI // advance cursor iCursorPos += iTextLen; // cursor moved: ensure it is shown - dwLastInputTime=timeGetTime(); + dwLastInputTime=GetTime(); ScrollCursorInView(); } // done; return whether everything was inserted @@ -429,7 +429,7 @@ namespace C4GUI iCursorPos += iMoveLength; } // show cursor - dwLastInputTime=timeGetTime(); + dwLastInputTime=GetTime(); ScrollCursorInView(); // operation recognized return true; @@ -533,7 +533,7 @@ namespace C4GUI // select all iSelectionStart=0; iSelectionEnd=iCursorPos=SLen(Text); // begin with a flashing cursor - dwLastInputTime=timeGetTime(); + dwLastInputTime=GetTime(); } void Edit::OnLooseFocus() @@ -606,7 +606,7 @@ namespace C4GUI // draw edit text lpDDraw->TextOut(pDrawText, *pFont, 1.0f, cgo.Surface, rcClientRect.x + cgo.TargetX - iXScroll, iY0 + cgo.TargetY - 1, dwFontClr, ALeft, false); // draw cursor - if (HasDrawFocus() && !(((dwLastInputTime-timeGetTime())/500)%2)) + if (HasDrawFocus() && !(((dwLastInputTime-GetTime())/500)%2)) { char cAtCursor = pDrawText[iCursorPos]; pDrawText[iCursorPos]=0; int32_t w,h,wc; pFont->GetTextExtent(pDrawText, w, h, false); diff --git a/src/gui/C4GuiLabels.cpp b/src/gui/C4GuiLabels.cpp index 3d8acdc90..1d23ea756 100644 --- a/src/gui/C4GuiLabels.cpp +++ b/src/gui/C4GuiLabels.cpp @@ -153,7 +153,7 @@ namespace C4GUI if (iAlign == ALeft) iXOff += 5; if (tAutoScrollDelay) { - time_t tNow = timeGetTime(); + time_t tNow = GetTime(); if (!tLastChangeTime) tLastChangeTime = tNow; else if (tNow - tLastChangeTime >= tAutoScrollDelay) diff --git a/src/gui/C4GuiTabular.cpp b/src/gui/C4GuiTabular.cpp index a86331755..cfc52d2d6 100644 --- a/src/gui/C4GuiTabular.cpp +++ b/src/gui/C4GuiTabular.cpp @@ -363,7 +363,7 @@ namespace C4GUI void Tabular::DoCaptionScroll(int32_t iDir) { // store time of scrolling change - tLastScrollTime = timeGetTime(); + tLastScrollTime = GetTime(); // change scrolling within max range int32_t iAvailableTabSpace = rcBounds.Wdt; int32_t iScrollPinSize = GetTopSize(); @@ -376,7 +376,7 @@ namespace C4GUI if (!fDrawSelf) return; bool fGfx = HasGfx(); // execute scrolling - if ((fScrollingLeftDown || fScrollingRightDown) && timeGetTime()-tLastScrollTime >= C4GUI_TabCaptionScrollTime) + if ((fScrollingLeftDown || fScrollingRightDown) && GetTime()-tLastScrollTime >= C4GUI_TabCaptionScrollTime) DoCaptionScroll(fScrollingRightDown - fScrollingLeftDown); // border if (!fGfx) Draw3DFrame(cgo, false, 1, 0xaf, eTabPos!=tbTop, GetTopSize(), eTabPos!=tbLeft, GetLeftSize()); diff --git a/src/lib/C4Stat.h b/src/lib/C4Stat.h index 58cca6efb..94aa57f5b 100644 --- a/src/lib/C4Stat.h +++ b/src/lib/C4Stat.h @@ -59,7 +59,7 @@ public: inline void Start() { if (!iStartCalled) - iStartTick = timeGetTime(); + iStartTick = GetTime(); iCount ++; iCountPart ++; iStartCalled ++; @@ -71,7 +71,7 @@ public: iStartCalled --; if (!iStartCalled && iCount >= 100) { - unsigned int iTime = timeGetTime() - iStartTick; + unsigned int iTime = GetTime() - iStartTick; iTimeSum += iTime; iTimeSumPart += iTime; diff --git a/src/lib/Standard.cpp b/src/lib/Standard.cpp index cce95f5ca..4565c00f3 100644 --- a/src/lib/Standard.cpp +++ b/src/lib/Standard.cpp @@ -762,17 +762,3 @@ long InterlockedDecrement(long * var) return --(*var); } #endif - -#ifndef _WIN32 - -#include - -unsigned long timeGetTime(void) -{ - static time_t sec_offset; - timeval tv; - gettimeofday(&tv, 0); - if (!sec_offset) sec_offset = tv.tv_sec; - return (tv.tv_sec - sec_offset) * 1000 + tv.tv_usec / 1000; -} -#endif diff --git a/src/netio/TstC4NetIO.cpp b/src/netio/TstC4NetIO.cpp index 55c62dce4..60d1643ce 100644 --- a/src/netio/TstC4NetIO.cpp +++ b/src/netio/TstC4NetIO.cpp @@ -49,7 +49,7 @@ public: virtual bool OnConn(const C4NetIO::addr_t &addr, const C4NetIO::addr_t &addr2, C4NetIO *pNetIO) { cout << "got connection from " << inet_ntoa(addr.sin_addr) << endl; - iTime = timeGetTime(); iPcks = 0; + iTime = GetTime(); iPcks = 0; #ifdef ASYNC_CONNECT if (!fHost) @@ -63,10 +63,10 @@ public: } virtual void OnPacket(const class C4NetIOPacket &rPacket, C4NetIO *pNetIO) { - if (timeGetTime() > iTime + 1000) + if (GetTime() > iTime + 1000) { - cout << iPcks << " packets in " << timeGetTime() - iTime << " ms (" << iPcks * 1000 / (timeGetTime() - iTime) << " per second, " << (iPcks ? (timeGetTime() - iTime) * 1000 / iPcks : -1u) << "us per packet)" << endl; - iTime = timeGetTime(); iPcks = 0; + cout << iPcks << " packets in " << GetTime() - iTime << " ms (" << iPcks * 1000 / (GetTime() - iTime) << " per second, " << (iPcks ? (GetTime() - iTime) * 1000 / iPcks : -1u) << "us per packet)" << endl; + iTime = GetTime(); iPcks = 0; } if (!rPacket.getStatus()) { diff --git a/src/network/C4GameControlNetwork.cpp b/src/network/C4GameControlNetwork.cpp index 871860b83..23afb2433 100644 --- a/src/network/C4GameControlNetwork.cpp +++ b/src/network/C4GameControlNetwork.cpp @@ -62,7 +62,7 @@ bool C4GameControlNetwork::Init(int32_t inClientID, bool fnHost, int32_t iStartT pNetwork->Clients.BroadcastMsgToConnClients(MkC4NetIOPacket(PID_ControlReq, C4PacketControlReq(iControlReady + 1))); // ok fEnabled = true; fRunning = false; - iTargetFPS = 38; iNextControlReqeust = timeGetTime() + C4ControlRequestInterval; + iTargetFPS = 38; iNextControlReqeust = GetTime() + C4ControlRequestInterval; return true; } @@ -89,7 +89,7 @@ void C4GameControlNetwork::Execute() // by main thread // Save time the control tick was reached if (iWaitStart == -1) - iWaitStart = timeGetTime(); + iWaitStart = GetTime(); // Execute any queued sync control ExecQueuedSyncCtrl(); @@ -735,7 +735,7 @@ void C4GameControlNetwork::CheckCompleteCtrl(bool fSetEvent) // by both // target ctrl tick to reach? if (iControlReady < iTargetTick && (!fActivated || iControlSent > iControlReady) && - timeGetTime() >= iNextControlReqeust) + GetTime() >= iNextControlReqeust) { Application.InteractiveThread.ThreadLogS("Network: Recovering: Requesting control for tick %d...", iControlReady + 1); // make request @@ -746,7 +746,7 @@ void C4GameControlNetwork::CheckCompleteCtrl(bool fSetEvent) // by both else ::Network.Clients.BroadcastMsgToConnClients(Pkt); // set time for next request - iNextControlReqeust = timeGetTime() + C4ControlRequestInterval; + iNextControlReqeust = GetTime() + C4ControlRequestInterval; } } @@ -764,7 +764,7 @@ C4GameControlPacket *C4GameControlNetwork::PackCompleteCtrl(int32_t iTick) { // async mode: wait n extra frames for slow clients const int iMaxWait = (Config.Network.AsyncMaxWait * 1000) / iTargetFPS; - if (eMode != CNM_Async || iWaitStart == -1 || timeGetTime() <= uint32_t(iWaitStart + iMaxWait)) + if (eMode != CNM_Async || iWaitStart == -1 || GetTime() <= uint32_t(iWaitStart + iMaxWait)) return false; } @@ -795,7 +795,7 @@ C4GameControlPacket *C4GameControlNetwork::PackCompleteCtrl(int32_t iTick) ::Network.Clients.BroadcastMsgToConnClients(MkC4NetIOPacket(PID_Control, *pComplete)); // advance control request time - iNextControlReqeust = Max(iNextControlReqeust, timeGetTime() + C4ControlRequestInterval); + iNextControlReqeust = Max(iNextControlReqeust, GetTime() + C4ControlRequestInterval); // return return pComplete; @@ -851,7 +851,7 @@ void C4GameControlNetwork::ExecQueuedSyncCtrl() // by main thread C4GameControlPacket::C4GameControlPacket() : iClientID(C4ClientIDUnknown), iCtrlTick(-1), - iTime(timeGetTime()), + iTime(GetTime()), pNext(NULL) { @@ -860,7 +860,7 @@ C4GameControlPacket::C4GameControlPacket() C4GameControlPacket::C4GameControlPacket(const C4GameControlPacket &Pkt2) : C4PacketBase(Pkt2), iClientID(Pkt2.getClientID()), iCtrlTick(Pkt2.getCtrlTick()), - iTime(timeGetTime()), + iTime(GetTime()), pNext(NULL) { Ctrl.Copy(Pkt2.getControl()); diff --git a/src/network/C4InteractiveThread.cpp b/src/network/C4InteractiveThread.cpp index 4a4b2ae33..bb8e06a7f 100644 --- a/src/network/C4InteractiveThread.cpp +++ b/src/network/C4InteractiveThread.cpp @@ -87,7 +87,7 @@ bool C4InteractiveThread::PushEvent(C4InteractiveEventType eEvent, void *pData) pEvent->Type = eEvent; pEvent->Data = pData; #ifdef _DEBUG - pEvent->Time = timeGetTime(); + pEvent->Time = GetTime(); #endif pEvent->Next = NULL; // add item (at end) @@ -117,7 +117,7 @@ bool C4InteractiveThread::PopEvent(C4InteractiveEventType *pEventType, void **pp *ppData = pEvent->Data; #ifdef _DEBUG if (Game.IsRunning) - AvgNetEvDelay += ((timeGetTime() - pEvent->Time) - AvgNetEvDelay) / 100; + AvgNetEvDelay += ((GetTime() - pEvent->Time) - AvgNetEvDelay) / 100; #endif // remove delete pFirstEvent; diff --git a/src/network/C4NetIO.cpp b/src/network/C4NetIO.cpp index c9d28662c..88bf87c95 100644 --- a/src/network/C4NetIO.cpp +++ b/src/network/C4NetIO.cpp @@ -1827,7 +1827,7 @@ bool C4NetIOUDP::Init(uint16_t inPort) // set flags fInit = true; fMultiCast = false; - iNextCheck = timeGetTime() + iCheckInterval; + iNextCheck = GetTime() + iCheckInterval; // ok, that's all for now. // call InitBroadcast for more initialization fun @@ -1999,7 +1999,7 @@ bool C4NetIOUDP::Execute(int iMaxTime, pollfd *) // (mt-safe) ResetError(); // adjust maximum block time - int Now = timeGetTime(); + int Now = GetTime(); int iMaxBlock = GetNextTick(Now) - Now; if (iMaxTime == TO_INF || iMaxTime > iMaxBlock) iMaxTime = iMaxBlock; @@ -2008,7 +2008,7 @@ bool C4NetIOUDP::Execute(int iMaxTime, pollfd *) // (mt-safe) return false; // connection check needed? - if (iNextCheck <= timeGetTime()) + if (iNextCheck <= GetTime()) DoCheck(); // client timeout? for (Peer *pPeer = pPeerList; pPeer; pPeer = pPeer->Next) @@ -2527,7 +2527,7 @@ bool C4NetIOUDP::Peer::Check(bool fForceCheck) if (eStatus != CS_Works) return true; // prevent re-check (check floods) // instead, ask for other packets that are missing until recheck is allowed - bool fNoReCheck = !!iNextReCheck && iNextReCheck > timeGetTime(); + bool fNoReCheck = !!iNextReCheck && iNextReCheck > GetTime(); if (!fNoReCheck) iLastPacketAsked = iLastMCPacketAsked = 0; unsigned int iStartAt = fNoReCheck ? Max(iLastPacketAsked + 1, iIPacketCounter) : iIPacketCounter; unsigned int iStartAtMC = fNoReCheck ? Max(iLastMCPacketAsked + 1, iIMCPacketCounter) : iIMCPacketCounter; @@ -2545,7 +2545,7 @@ bool C4NetIOUDP::Peer::Check(bool fForceCheck) int iEAskCnt = iAskCnt + iMCAskCnt; // no re-check limit? set it if (!fNoReCheck) - iNextReCheck = iEAskCnt ? timeGetTime() + iReCheckInterval : 0; + iNextReCheck = iEAskCnt ? GetTime() + iReCheckInterval : 0; // something to ask for? (or check forced?) if (iEAskCnt || fForceCheck) return DoCheck(iAskCnt, iMCAskCnt, iAskList); @@ -2771,7 +2771,7 @@ void C4NetIOUDP::Peer::CheckTimeout() // timeout set? if (!iTimeout) return; // check - if (timeGetTime() > iTimeout) + if (GetTime() > iTimeout) OnTimeout(); } @@ -2920,7 +2920,7 @@ void C4NetIOUDP::Peer::CheckCompleteIPackets() void C4NetIOUDP::Peer::SetTimeout(int iLength, int iRetryCnt) // (mt-safe) { if (iLength != TO_INF) - iTimeout = timeGetTime() + iLength; + iTimeout = GetTime() + iLength; else iTimeout = 0; iRetries = iRetryCnt; @@ -3139,7 +3139,7 @@ void C4NetIOUDP::DoCheck() // (mt-safe) if (pPeer->Open()) pPeer->Check(); // set time for next check - iNextCheck = timeGetTime() + iCheckInterval; + iNextCheck = GetTime() + iCheckInterval; } // debug @@ -3187,7 +3187,7 @@ void C4NetIOUDP::CloseDebugLog() void C4NetIOUDP::DebugLogPkt(bool fOut, const C4NetIOPacket &Pkt) { StdStrBuf O; - unsigned int iTime = timeGetTime(); + unsigned int iTime = GetTime(); O.Format("%s %d:%02d:%02d:%03d %s:%d:", fOut ? "out" : "in ", (iTime / 1000 / 60 / 60), (iTime / 1000 / 60) % 60, (iTime / 1000) % 60, iTime % 1000, inet_ntoa(Pkt.getAddr().sin_addr), htons(Pkt.getAddr().sin_port)); diff --git a/src/network/C4Network2.cpp b/src/network/C4Network2.cpp index c96a2cacc..198e41b9c 100644 --- a/src/network/C4Network2.cpp +++ b/src/network/C4Network2.cpp @@ -1503,7 +1503,7 @@ C4Network2Res::Ref C4Network2::RetrieveRes(const C4Network2ResCore &Core, int32_ { C4GUI::ProgressDialog *pDlg = NULL; bool fLog = false; - int32_t iProcess = -1; uint32_t iTimeout = timeGetTime() + iTimeoutLen; + int32_t iProcess = -1; uint32_t iTimeout = GetTime() + iTimeoutLen; // wait for ressource while (isEnabled()) { @@ -1535,12 +1535,12 @@ C4Network2Res::Ref C4Network2::RetrieveRes(const C4Network2ResCore &Core, int32_ if (pRes && pRes->getPresentPercent() != iProcess) { iProcess = pRes->getPresentPercent(); - iTimeout = timeGetTime() + iTimeoutLen; + iTimeout = GetTime() + iTimeoutLen; } else { // if not: check timeout - if (timeGetTime() > iTimeout) + if (GetTime() > iTimeout) { LogFatal(FormatString(LoadResStr("IDS_NET_ERR_RESTIMEOUT"), szResName).getData()); if (pDlg) delete pDlg; @@ -1577,7 +1577,7 @@ C4Network2Res::Ref C4Network2::RetrieveRes(const C4Network2ResCore &Core, int32_ } else { - if (!Application.ScheduleProcs(iTimeout - timeGetTime())) + if (!Application.ScheduleProcs(iTimeout - GetTime())) { return NULL; } } @@ -1775,7 +1775,7 @@ void C4Network2::RequestActivate() return; } // ensure interval - if (iLastActivateRequest && timeGetTime() < iLastActivateRequest + C4NetActivationReqInterval) + if (iLastActivateRequest && GetTime() < iLastActivateRequest + C4NetActivationReqInterval) return; // status not reached yet? May be chasing, let's delay this. if (!fStatusReached) @@ -1786,7 +1786,7 @@ void C4Network2::RequestActivate() // request Clients.SendMsgToHost(MkC4NetIOPacket(PID_ClientActReq, C4PacketActivateReq(Game.FrameCounter))); // store time - iLastActivateRequest = timeGetTime(); + iLastActivateRequest = GetTime(); } void C4Network2::DeactivateInactiveClients() diff --git a/src/network/C4Network2IO.cpp b/src/network/C4Network2IO.cpp index 6d07a1c0d..be87aeed4 100644 --- a/src/network/C4Network2IO.cpp +++ b/src/network/C4Network2IO.cpp @@ -74,7 +74,7 @@ bool C4Network2IO::Init(int16_t iPortTCP, int16_t iPortUDP, int16_t iPortDiscove if (pNetIO_TCP || pNetIO_UDP) Clear(); // init members - iLastPing = iLastStatistic = timeGetTime(); + iLastPing = iLastStatistic = GetTime(); iTCPIRate = iTCPORate = iTCPBCRate = 0; iUDPIRate = iUDPORate = iUDPBCRate = 0; @@ -190,7 +190,7 @@ bool C4Network2IO::Init(int16_t iPortTCP, int16_t iPortUDP, int16_t iPortDiscove } // own timer - iLastExecute = timeGetTime(); + iLastExecute = GetTime(); Thread.AddProc(this); // ok @@ -493,7 +493,7 @@ bool C4Network2IO::OnConn(const C4NetIO::addr_t &PeerAddr, const C4NetIO::addr_t return false; } #if(C4NET2IO_DUMP_LEVEL > 1) - unsigned int iTime = timeGetTime(); + unsigned int iTime = GetTime(); ThreadLogS("OnConn: %d:%02d:%02d:%03d: %s", (iTime / 1000 / 60 / 60), (iTime / 1000 / 60) % 60, (iTime / 1000) % 60, iTime % 1000, getNetIOName(pNetIO)); @@ -548,7 +548,7 @@ void C4Network2IO::OnDisconn(const C4NetIO::addr_t &addr, C4NetIO *pNetIO, const return; } #if(C4NET2IO_DUMP_LEVEL > 1) - unsigned int iTime = timeGetTime(); + unsigned int iTime = GetTime(); ThreadLogS("OnDisconn: %d:%02d:%02d:%03d: %s", (iTime / 1000 / 60 / 60), (iTime / 1000 / 60) % 60, (iTime / 1000) % 60, iTime % 1000, getNetIOName(pNetIO)); @@ -578,7 +578,7 @@ void C4Network2IO::OnDisconn(const C4NetIO::addr_t &addr, C4NetIO *pNetIO, const void C4Network2IO::OnPacket(const class C4NetIOPacket &rPacket, C4NetIO *pNetIO) { #if(C4NET2IO_DUMP_LEVEL > 1) - unsigned int iTime = timeGetTime(); + unsigned int iTime = GetTime(); ThreadLogS("OnPacket: %d:%02d:%02d:%03d: status %02x %s", (iTime / 1000 / 60 / 60), (iTime / 1000 / 60) % 60, (iTime / 1000) % 60, iTime % 1000, rPacket.getStatus(), getNetIOName(pNetIO)); @@ -588,8 +588,8 @@ void C4Network2IO::OnPacket(const class C4NetIOPacket &rPacket, C4NetIO *pNetIO) C4Network2IOConnection *pConn = GetConnection(rPacket.getAddr(), pNetIO); if (!pConn) { Application.InteractiveThread.ThreadLog("Network: could not find connection for packet from %s:%d!", inet_ntoa(rPacket.getAddr().sin_addr), htons(rPacket.getAddr().sin_port)); return; } #if(C4NET2IO_DUMP_LEVEL > 2) - if (timeGetTime() - iTime > 100) - ThreadLogS("OnPacket: ... blocked %d ms for finding the connection!", timeGetTime() - iTime); + if (GetTime() - iTime > 100) + ThreadLogS("OnPacket: ... blocked %d ms for finding the connection!", GetTime() - iTime); #endif // notify pConn->OnPacketReceived(rPacket.getStatus()); @@ -597,8 +597,8 @@ void C4Network2IO::OnPacket(const class C4NetIOPacket &rPacket, C4NetIO *pNetIO) HandlePacket(rPacket, pConn, true); // log time #if(C4NET2IO_DUMP_LEVEL > 1) - if (timeGetTime() - iTime > 100) - ThreadLogS("OnPacket: ... blocked %d ms for handling!", timeGetTime() - iTime); + if (GetTime() - iTime > 100) + ThreadLogS("OnPacket: ... blocked %d ms for handling!", GetTime() - iTime); #endif } @@ -610,20 +610,20 @@ void C4Network2IO::OnError(const char *strError, C4NetIO *pNetIO) bool C4Network2IO::Execute(int iTimeout, pollfd *) { - iLastExecute = timeGetTime(); + iLastExecute = GetTime(); // check for timeout CheckTimeout(); // ping all open connections - if (!Inside(iLastPing, timeGetTime() - C4NetPingFreq, timeGetTime())) + if (!Inside(iLastPing, GetTime() - C4NetPingFreq, GetTime())) { Ping(); iLastPing = iLastExecute; } // do statistics - if (!Inside(iLastStatistic, timeGetTime() - C4NetStatisticsFreq, timeGetTime())) + if (!Inside(iLastStatistic, GetTime() - C4NetStatisticsFreq, GetTime())) { GenerateStatistics(iLastExecute - iLastStatistic); iLastStatistic = iLastExecute; @@ -827,7 +827,7 @@ bool C4Network2IO::HandlePacket(const C4NetIOPacket &rPacket, C4Network2IOConnec #if(C4NET2IO_DUMP_LEVEL > 0) if (fThread && Pkt.getPktType() != PID_Ping && Pkt.getPktType() != PID_Pong && Pkt.getPktType() != PID_NetResData) { - unsigned int iTime = timeGetTime(); + unsigned int iTime = GetTime(); // StdStrBuf PacketDump = DecompileToBuf(mkNamingAdaptrPacket); StdStrBuf PacketHeader = FormatString("HandlePacket: %d:%02d:%02d:%03d by %s:%d (%lu bytes, counter %d)", (iTime / 1000 / 60 / 60), (iTime / 1000 / 60) % 60, (iTime / 1000) % 60, iTime % 1000, @@ -852,15 +852,15 @@ bool C4Network2IO::HandlePacket(const C4NetIOPacket &rPacket, C4Network2IOConnec { fHandled = true; #if(C4NET2IO_DUMP_LEVEL > 2) - unsigned int iStart = timeGetTime(); + unsigned int iStart = GetTime(); #endif // call handler(s) CallHandlers(pHData->HandlerID, &Pkt, pConn, fThread); #if(C4NET2IO_DUMP_LEVEL > 2) - if (fThread && timeGetTime() - iStart > 100) - ThreadLogS("HandlePacket: ... blocked for %d ms!", timeGetTime() - iStart); + if (fThread && GetTime() - iStart > 100) + ThreadLogS("HandlePacket: ... blocked for %d ms!", GetTime() - iStart); #endif } @@ -1308,7 +1308,7 @@ int C4Network2IOConnection::getLag() const // Last ping not answered yet? if (iPingTime != -1 && iLastPing != ULONG_MAX && (iLastPong == ~0u || iLastPing > iLastPong)) { - int iPingLag = timeGetTime() - iLastPing; + int iPingLag = GetTime() - iLastPing; // Use it for lag measurement once it's larger then the last ping time // (the ping time won't be better than this anyway once the pong's here) return Max(iPingLag, iPingTime); @@ -1347,7 +1347,7 @@ void C4Network2IOConnection::OnPing() if (iLastPong < iLastPing) return; // Save time - iLastPing = timeGetTime(); + iLastPing = GetTime(); } void C4Network2IOConnection::SetPingTime(int inPingTime) @@ -1355,7 +1355,7 @@ void C4Network2IOConnection::SetPingTime(int inPingTime) // save it iPingTime = inPingTime; // pong received - save timestamp - iLastPong = timeGetTime(); + iLastPong = GetTime(); } void C4Network2IOConnection::SetStatus(C4Network2IOConnStatus nStatus) diff --git a/src/network/C4Packet2.cpp b/src/network/C4Packet2.cpp index cf41e3887..f9889b5fd 100644 --- a/src/network/C4Packet2.cpp +++ b/src/network/C4Packet2.cpp @@ -509,14 +509,14 @@ void C4PacketJoinData::CompileFunc(StdCompiler *pComp) // *** C4PacketPing C4PacketPing::C4PacketPing(uint32_t iPacketCounter, uint32_t iRemotePacketCounter) - : iTime(timeGetTime()), + : iTime(GetTime()), iPacketCounter(iPacketCounter) { } uint32_t C4PacketPing::getTravelTime() const { - return timeGetTime() - iTime; + return GetTime() - iTime; } void C4PacketPing::CompileFunc(StdCompiler *pComp) diff --git a/src/platform/C4SoundSystem.cpp b/src/platform/C4SoundSystem.cpp index 475df1872..78314ec06 100644 --- a/src/platform/C4SoundSystem.cpp +++ b/src/platform/C4SoundSystem.cpp @@ -236,7 +236,7 @@ bool C4SoundInstance::Create(C4SoundEffect *pnEffect, bool fLoop, int32_t inVolu // Set effect pEffect = pnEffect; // Set - iStarted = timeGetTime(); + iStarted = GetTime(); iVolume = inVolume; iPan = 0; iChannel = -1; iNearInstanceMax = inNearInstanceMax; this->iFalloffDistance = iFalloffDistance; @@ -254,7 +254,7 @@ bool C4SoundInstance::CheckStart() // already started? if (isStarted()) return true; // don't bother if half the time is up and the sound is not looping - if (timeGetTime() > iStarted + pEffect->Length / 2 && !fLooping) + if (GetTime() > iStarted + pEffect->Length / 2 && !fLooping) return false; // do near-instances check int32_t iNearInstances = pObj ? pEffect->GetStartedInstanceCount(pObj->GetX(), pObj->GetY(), C4NearSoundRadius) @@ -274,10 +274,10 @@ bool C4SoundInstance::Start() if (!FSOUND_SetLoopMode(iChannel, fLooping ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF)) { Stop(); return false; } // set position - if (timeGetTime() > iStarted + 20) + if (GetTime() > iStarted + 20) { assert(pEffect->Length > 0); - int32_t iTime = (timeGetTime() - iStarted) % pEffect->Length; + int32_t iTime = (GetTime() - iStarted) % pEffect->Length; FSOUND_SetCurrentPosition(iChannel, iTime / 10 * pEffect->SampleRate / 100); } #elif defined HAVE_LIBSDL_MIXER @@ -328,7 +328,7 @@ bool C4SoundInstance::Playing() #ifdef HAVE_FMOD if (fLooping) return true; return isStarted() ? FSOUND_GetCurrentSample(iChannel) == pEffect->pSample - : timeGetTime() < iStarted + pEffect->Length; + : GetTime() < iStarted + pEffect->Length; #endif #ifdef HAVE_LIBSDL_MIXER return Application.MusicSystem.MODInitialized && (iChannel != -1) && Mix_Playing(iChannel); diff --git a/src/platform/C4VideoPlayback.cpp b/src/platform/C4VideoPlayback.cpp index 83ace6fb5..3af327bf9 100644 --- a/src/platform/C4VideoPlayback.cpp +++ b/src/platform/C4VideoPlayback.cpp @@ -231,7 +231,7 @@ void C4VideoShowDialog::DrawElement(C4TargetFacet &cgo) // draw current video frame #ifdef _WIN32 // get frame to be drawn - time_t iCurrFrameTime = timeGetTime(); + time_t iCurrFrameTime = GetTime(); int32_t iGetFrame; if (!iStartFrameTime) iStartFrameTime = iCurrFrameTime; if (!AVIFile.GetFrameByTime(iCurrFrameTime - iStartFrameTime, &iGetFrame)) diff --git a/src/platform/C4ViewportWindow.cpp b/src/platform/C4ViewportWindow.cpp index cc0d7660f..14136fe4f 100644 --- a/src/platform/C4ViewportWindow.cpp +++ b/src/platform/C4ViewportWindow.cpp @@ -708,7 +708,7 @@ void C4ViewportWindow::HandleMessage (XEvent & e) switch (e.xbutton.button) { case Button1: - if (timeGetTime() - last_left_click < 400) + if (GetTime() - last_left_click < 400) { C4GUI::MouseMove(C4MC_Button_LeftDouble, e.xbutton.x, e.xbutton.y, e.xbutton.state, cvp); @@ -718,7 +718,7 @@ void C4ViewportWindow::HandleMessage (XEvent & e) { C4GUI::MouseMove(C4MC_Button_LeftDown, e.xbutton.x, e.xbutton.y, e.xbutton.state, cvp); - last_left_click = timeGetTime(); + last_left_click = GetTime(); } break; case Button2: @@ -726,7 +726,7 @@ void C4ViewportWindow::HandleMessage (XEvent & e) e.xbutton.x, e.xbutton.y, e.xbutton.state, cvp); break; case Button3: - if (timeGetTime() - last_right_click < 400) + if (GetTime() - last_right_click < 400) { C4GUI::MouseMove(C4MC_Button_RightDouble, e.xbutton.x, e.xbutton.y, e.xbutton.state, cvp); @@ -736,7 +736,7 @@ void C4ViewportWindow::HandleMessage (XEvent & e) { C4GUI::MouseMove(C4MC_Button_RightDown, e.xbutton.x, e.xbutton.y, e.xbutton.state, cvp); - last_right_click = timeGetTime(); + last_right_click = GetTime(); } break; case Button4: diff --git a/src/platform/GetTime.cpp b/src/platform/GetTime.cpp new file mode 100644 index 000000000..7700818f8 --- /dev/null +++ b/src/platform/GetTime.cpp @@ -0,0 +1,45 @@ +/* + * OpenClonk, http://www.openclonk.org + * + * Copyright (c) 2005, 2011 Günther Brammer + * Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de + * + * Portions might be copyrighted by other authors who have contributed + * to OpenClonk. + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * See isc_license.txt for full license and disclaimer. + * + * "Clonk" is a registered trademark of Matthes Bender. + * See clonk_trademark_license.txt for full license. + */ + +#include "C4Include.h" + +#ifdef _WIN32 + +#include +#include + +unsigned int GetTime() +{ + return timeGetTime(); +} + +#else + +#include + +unsigned int GetTime() +{ + static time_t sec_offset; + timeval tv; + gettimeofday(&tv, 0); + if (!sec_offset) sec_offset = tv.tv_sec; + return (tv.tv_sec - sec_offset) * 1000 + tv.tv_usec / 1000; +} + +#endif + diff --git a/src/platform/PlatformAbstraction.h b/src/platform/PlatformAbstraction.h index 6d98f8cf8..d7dc0ff61 100644 --- a/src/platform/PlatformAbstraction.h +++ b/src/platform/PlatformAbstraction.h @@ -60,7 +60,6 @@ # define NOMINMAX # endif # include -# include # endif #endif @@ -189,8 +188,6 @@ typedef struct int32_t left; int32_t top; int32_t right; int32_t bottom; } RECT; -unsigned long timeGetTime(void); - #include inline int stricmp(const char *s1, const char *s2) { @@ -226,4 +223,7 @@ bool IsGermanSystem(); // open a weblink in an external browser bool OpenURL(const char* szURL); +// Get a monotonically increasing timestamp in milliseconds +unsigned int GetTime(); + #endif // INC_PLATFORMABSTRACTION diff --git a/src/platform/StdScheduler.cpp b/src/platform/StdScheduler.cpp index f8f22ab15..019c625d0 100644 --- a/src/platform/StdScheduler.cpp +++ b/src/platform/StdScheduler.cpp @@ -66,14 +66,14 @@ bool StdSchedulerProc::ExecuteUntil(int iTimeout) if (!Execute()) return false; // Calculate endpoint - unsigned int iStopTime = timeGetTime() + iTimeout; + unsigned int iStopTime = GetTime() + iTimeout; for (;;) { // Call execute with given timeout if (!Execute(Max(iTimeout, 0))) return false; // Calculate timeout - unsigned int iTime = timeGetTime(); + unsigned int iTime = GetTime(); if (iTime >= iStopTime) break; iTimeout = int(iStopTime - iTime); @@ -176,7 +176,7 @@ bool StdScheduler::ScheduleProcs(int iTimeout) if (!iProcCnt) return false; // Get timeout - int i; int iProcTick; int Now = timeGetTime(); + int i; int iProcTick; int Now = GetTime(); for (i = 0; i < iProcCnt; i++) if ((iProcTick = ppProcs[i]->GetNextTick(Now)) >= 0) if (iTimeout == -1 || iTimeout + Now > iProcTick) @@ -284,7 +284,7 @@ bool StdScheduler::ScheduleProcs(int iTimeout) if (fProcessTimeouts) { // Execute all processes with timeout - Now = timeGetTime(); + Now = GetTime(); for (i = 0; i < iProcCnt; i++) { iProcTick = ppProcs[i]->GetNextTick(Now); diff --git a/src/platform/StdScheduler.h b/src/platform/StdScheduler.h index a700891ea..b5dab4995 100644 --- a/src/platform/StdScheduler.h +++ b/src/platform/StdScheduler.h @@ -97,12 +97,12 @@ private: public: void Set() { iLastTimer = 0; } void SetDelay(uint32_t inDelay) { iDelay = inDelay; } - bool Check() { return timeGetTime() >= iLastTimer + iDelay; } + bool Check() { return GetTime() >= iLastTimer + iDelay; } bool CheckAndReset() { if (!Check()) return false; // Compensate light drifting - uint32_t iTime = timeGetTime(); + uint32_t iTime = GetTime(); uint32_t iDrift = iTime - iLastTimer - iDelay; // >= 0 because of Check() iLastTimer = iTime - Min(iDrift, iDelay / 2); return true; diff --git a/src/platform/StdXPrivate.h b/src/platform/StdXPrivate.h index 73540c379..dc55101d6 100644 --- a/src/platform/StdXPrivate.h +++ b/src/platform/StdXPrivate.h @@ -123,7 +123,7 @@ public: // StdSchedulerProc override virtual void GetFDs(std::vector & rfds) { - if (query_time < 0) query(timeGetTime()); + if (query_time < 0) query(GetTime()); rfds.insert(rfds.end(), fds.begin(), fds.end()); } virtual int GetNextTick(int Now) diff --git a/src/script/C4AulExec.cpp b/src/script/C4AulExec.cpp index 30f08d765..3d14a6eeb 100644 --- a/src/script/C4AulExec.cpp +++ b/src/script/C4AulExec.cpp @@ -975,7 +975,7 @@ void C4AulExec::StartProfiling(C4AulScript *pProfiledScript) fProfiling = true; // resets profling times and starts recording the times this->pProfiledScript = pProfiledScript; - time_t tNow = timeGetTime(); + time_t tNow = GetTime(); tDirectExecStart = tNow; // in case profiling is started from DirectExec tDirectExecTotal = 0; pProfiledScript->ResetProfilerTimes(); @@ -1008,7 +1008,7 @@ void C4AulExec::PushContext(const C4AulScriptContext &rContext) pCurCtx->dump(Buf); } // Profiler: Safe time to measure difference afterwards - if (fProfiling) pCurCtx->tTime = timeGetTime(); + if (fProfiling) pCurCtx->tTime = GetTime(); } void C4AulExec::PopContext() @@ -1018,7 +1018,7 @@ void C4AulExec::PopContext() // Profiler adding up times if (fProfiling) { - time_t dt = timeGetTime() - pCurCtx->tTime; + time_t dt = GetTime() - pCurCtx->tTime; if (dt && pCurCtx->Func) pCurCtx->Func->tProfileTime += dt; } diff --git a/src/script/C4AulExec.h b/src/script/C4AulExec.h index 968197d12..35accd2fc 100644 --- a/src/script/C4AulExec.h +++ b/src/script/C4AulExec.h @@ -51,8 +51,8 @@ public: void StartProfiling(C4AulScript *pScript); // resets profling times and starts recording the times void StopProfiling(); // stop the profiler and displays results void AbortProfiling() { fProfiling=false; } - inline void StartDirectExec() { if (fProfiling) tDirectExecStart = timeGetTime(); } - inline void StopDirectExec() { if (fProfiling) tDirectExecTotal += timeGetTime() - tDirectExecStart; } + inline void StartDirectExec() { if (fProfiling) tDirectExecStart = GetTime(); } + inline void StopDirectExec() { if (fProfiling) tDirectExecTotal += GetTime() - tDirectExecStart; } int GetContextDepth() const { return pCurCtx - Contexts + 1; } C4AulScriptContext *GetContext(int iLevel) { return iLevel >= 0 && iLevel < GetContextDepth() ? Contexts + iLevel : NULL; }