forked from Mirrors/openclonk
replace global function GetTime() with class function C4TimeMilliseconds::Now()
parent
3c4ba7f494
commit
fe2a400c02
|
@ -108,6 +108,4 @@ inline void operator delete(void *p, const char *, long)
|
|||
|
||||
#include "C4Game.h"
|
||||
|
||||
#include "C4TimeMilliseconds.h"
|
||||
|
||||
#endif // INC_C4Include
|
||||
|
|
|
@ -362,7 +362,7 @@ bool C4PlayerControlAssignment::IsComboMatched(const C4PlayerControlRecentKeyLis
|
|||
// check if combo is currently fulfilled (assuming TriggerKey is already matched)
|
||||
if (fComboIsSequence)
|
||||
{
|
||||
C4TimeMilliseconds tKeyLast = GetTime();
|
||||
C4TimeMilliseconds tKeyLast = C4TimeMilliseconds::Now();
|
||||
// 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
|
||||
KeyComboVec::const_reverse_iterator i = KeyCombo.rbegin()+1;
|
||||
|
@ -1038,7 +1038,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,GetTime());
|
||||
C4PlayerControlRecentKey RKey(pressed_key,matched_key,C4TimeMilliseconds::Now());
|
||||
if (!Key_IsMouse(pressed_key.Key) || Inside<uint8_t>(Key_GetMouseEvent(pressed_key.Key), KEY_MOUSE_Button1, KEY_MOUSE_ButtonMax))
|
||||
{
|
||||
if (std::find(DownKeys.begin(), DownKeys.end(), pressed_key) == DownKeys.end()) DownKeys.push_back(RKey);
|
||||
|
@ -1288,7 +1288,7 @@ void C4PlayerControl::Execute()
|
|||
}
|
||||
}
|
||||
// cleanup old recent keys
|
||||
C4TimeMilliseconds tNow = GetTime();
|
||||
C4TimeMilliseconds tNow = C4TimeMilliseconds::Now();
|
||||
C4PlayerControlRecentKeyList::iterator irk;
|
||||
for (irk = RecentKeys.begin(); irk != RecentKeys.end(); ++irk)
|
||||
{
|
||||
|
|
|
@ -868,7 +868,7 @@ bool C4ApplicationGameTimer::Execute(int iTimeout, pollfd *)
|
|||
{
|
||||
// Check timer and reset
|
||||
if (!CheckAndReset()) return true;
|
||||
C4TimeMilliseconds tNow = GetTime();
|
||||
C4TimeMilliseconds tNow = C4TimeMilliseconds::Now();
|
||||
// Execute
|
||||
if (tNow >= tLastGameTick + iGameTickDelay || Game.GameGo)
|
||||
{
|
||||
|
|
|
@ -1479,7 +1479,7 @@ static long FnGetTime(C4PropList * _this)
|
|||
{
|
||||
// check network, record, etc
|
||||
if (::Control.SyncMode()) return 0;
|
||||
return GetTime().AsInt();
|
||||
return C4TimeMilliseconds::Now().AsInt();
|
||||
}
|
||||
|
||||
static C4Value FnSetPlrExtraData(C4PropList * _this, int iPlayer, C4String * DataName, const C4Value & Data)
|
||||
|
|
|
@ -539,7 +539,7 @@ namespace C4GUI
|
|||
|
||||
public:
|
||||
WoodenLabel(const char *szLblText, const C4Rect &rcBounds, DWORD dwFClr=0xffffffff, CStdFont *pFont=NULL, int32_t iAlign=ACenter, bool fMarkup=true) // ctor
|
||||
: Label(szLblText, rcBounds, iAlign, dwFClr, pFont, true, true, fMarkup), iAutoScrollDelay(0), tLastChangeTime(GetTime()), iScrollPos(0), iScrollDir(0), iRightIndent(0)
|
||||
: Label(szLblText, rcBounds, iAlign, dwFClr, pFont, true, true, fMarkup), iAutoScrollDelay(0), tLastChangeTime(C4TimeMilliseconds::Now()), iScrollPos(0), iScrollDir(0), iRightIndent(0)
|
||||
{ SetAutosize(false); this->rcBounds=rcBounds; }// ctor - re-sets bounds after SetText
|
||||
|
||||
static int32_t GetDefaultHeight(CStdFont *pUseFont=NULL);
|
||||
|
@ -2451,7 +2451,7 @@ namespace C4GUI
|
|||
int32_t LDownX, LDownY; // position where left button was pressed last
|
||||
DWORD dwKeys; // shift, ctrl, etc.
|
||||
bool fActive;
|
||||
C4TimeMilliseconds tLastMovementTime; // GetTime() when the mouse pos changed last
|
||||
C4TimeMilliseconds tLastMovementTime; // C4TimeMilliseconds::Now() when the mouse pos changed last
|
||||
|
||||
// whether last input was done by mouse
|
||||
// set to true whenever mouse pos changes or buttons are pressed
|
||||
|
@ -2482,8 +2482,8 @@ namespace C4GUI
|
|||
|
||||
void SetOwnedMouse(bool fToVal) { fActive=fToVal; }
|
||||
|
||||
void ResetToolTipTime() { tLastMovementTime = GetTime(); }
|
||||
bool IsMouseStill() { return GetTime()-tLastMovementTime >= C4GUI_ToolTipShowTime; }
|
||||
void ResetToolTipTime() { tLastMovementTime = C4TimeMilliseconds::Now(); }
|
||||
bool IsMouseStill() { return C4TimeMilliseconds::Now()-tLastMovementTime >= C4GUI_ToolTipShowTime; }
|
||||
void ResetActiveInput() { fActiveInput = false; }
|
||||
bool IsActiveInput() { return fActiveInput; }
|
||||
|
||||
|
|
|
@ -150,7 +150,7 @@ namespace C4GUI
|
|||
// reset selection
|
||||
iSelectionStart = iSelectionEnd = 0;
|
||||
// cursor might have moved: ensure it is shown
|
||||
tLastInputTime=GetTime();
|
||||
tLastInputTime = C4TimeMilliseconds::Now();
|
||||
}
|
||||
|
||||
void Edit::DeleteSelection()
|
||||
|
@ -162,7 +162,7 @@ namespace C4GUI
|
|||
// adjust cursor pos
|
||||
if (iCursorPos > iSelBegin) iCursorPos = Max(iSelBegin, iCursorPos - iSelEnd + iSelBegin);
|
||||
// cursor might have moved: ensure it is shown
|
||||
tLastInputTime=GetTime();
|
||||
tLastInputTime = C4TimeMilliseconds::Now();
|
||||
// nothing selected
|
||||
iSelectionStart = iSelectionEnd = iSelBegin;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ namespace C4GUI
|
|||
// advance cursor
|
||||
iCursorPos += iTextLen;
|
||||
// cursor moved: ensure it is shown
|
||||
tLastInputTime=GetTime();
|
||||
tLastInputTime = C4TimeMilliseconds::Now();
|
||||
ScrollCursorInView();
|
||||
}
|
||||
// done; return whether everything was inserted
|
||||
|
@ -452,7 +452,7 @@ namespace C4GUI
|
|||
iCursorPos += iMoveLength;
|
||||
}
|
||||
// show cursor
|
||||
tLastInputTime=GetTime();
|
||||
tLastInputTime = C4TimeMilliseconds::Now();
|
||||
ScrollCursorInView();
|
||||
// operation recognized
|
||||
return true;
|
||||
|
@ -556,7 +556,7 @@ namespace C4GUI
|
|||
// select all
|
||||
iSelectionStart=0; iSelectionEnd=iCursorPos=SLen(Text);
|
||||
// begin with a flashing cursor
|
||||
tLastInputTime=GetTime();
|
||||
tLastInputTime = C4TimeMilliseconds::Now();
|
||||
}
|
||||
|
||||
void Edit::OnLooseFocus()
|
||||
|
@ -629,7 +629,8 @@ namespace C4GUI
|
|||
// draw edit text
|
||||
pDraw->TextOut(pDrawText, *pFont, 1.0f, cgo.Surface, rcClientRect.x + cgo.TargetX - iXScroll, iY0 + cgo.TargetY - 1, dwFontClr, ALeft, false);
|
||||
// draw cursor
|
||||
if (HasDrawFocus() && !(((tLastInputTime-GetTime())/500)%2))
|
||||
bool fBlink = ((tLastInputTime - C4TimeMilliseconds::Now())/500)%2 == 0;
|
||||
if (HasDrawFocus() && fBlink)
|
||||
{
|
||||
char cAtCursor = pDrawText[iCursorPos]; pDrawText[iCursorPos]=0; int32_t w,h,wc;
|
||||
pFont->GetTextExtent(pDrawText, w, h, false);
|
||||
|
|
|
@ -153,7 +153,7 @@ namespace C4GUI
|
|||
if (iAlign == ALeft) iXOff += 5;
|
||||
if (iAutoScrollDelay)
|
||||
{
|
||||
C4TimeMilliseconds tNow = GetTime();
|
||||
C4TimeMilliseconds tNow = C4TimeMilliseconds::Now();
|
||||
if (tNow - tLastChangeTime >= iAutoScrollDelay)
|
||||
{
|
||||
if (!iScrollDir) iScrollDir=1;
|
||||
|
|
|
@ -364,7 +364,7 @@ namespace C4GUI
|
|||
void Tabular::DoCaptionScroll(int32_t iDir)
|
||||
{
|
||||
// store time of scrolling change
|
||||
tLastScrollTime = GetTime();
|
||||
tLastScrollTime = C4TimeMilliseconds::Now();
|
||||
// change scrolling within max range
|
||||
int32_t iAvailableTabSpace = rcBounds.Wdt;
|
||||
int32_t iScrollPinSize = GetTopSize();
|
||||
|
@ -377,7 +377,8 @@ namespace C4GUI
|
|||
if (!fDrawSelf) return;
|
||||
bool fGfx = HasGfx();
|
||||
// execute scrolling
|
||||
if ((fScrollingLeftDown || fScrollingRightDown) && GetTime()-tLastScrollTime >= C4GUI_TabCaptionScrollTime)
|
||||
bool fCaptionScrollDelayOver = C4TimeMilliseconds::Now() - tLastScrollTime >= C4GUI_TabCaptionScrollTime;
|
||||
if ((fScrollingLeftDown || fScrollingRightDown) && fCaptionScrollDelayOver)
|
||||
DoCaptionScroll(fScrollingRightDown - fScrollingLeftDown);
|
||||
// border
|
||||
if (!fGfx) Draw3DFrame(cgo, false, 1, 0xaf, eTabPos!=tbTop, GetTopSize(), eTabPos!=tbLeft, GetLeftSize());
|
||||
|
|
|
@ -929,7 +929,7 @@ void C4LandscapeRenderGL::BuildMatMap(GLfloat *pFMap, GLubyte *pIMap)
|
|||
while(p = strchr(p, '-')) { p++; iPhases++; }
|
||||
// Hard-coded hack. Fix me!
|
||||
const int iPhaseLength = 300;
|
||||
float phase = (iPhases == 1 ? 0 : float(GetTime().AsInt() % (iPhases * iPhaseLength)) / iPhaseLength);
|
||||
float phase = (iPhases == 1 ? 0 : float(C4TimeMilliseconds::Now().AsInt() % (iPhases * iPhaseLength)) / iPhaseLength);
|
||||
|
||||
// Find our transition
|
||||
const char *pFrom = pEntry->GetTextureName();
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
inline void Start()
|
||||
{
|
||||
if (!iStartCalled)
|
||||
tStartTime = GetTime();
|
||||
tStartTime = C4TimeMilliseconds::Now();
|
||||
iCount ++;
|
||||
iCountPart ++;
|
||||
iStartCalled ++;
|
||||
|
@ -71,7 +71,7 @@ public:
|
|||
iStartCalled --;
|
||||
if (!iStartCalled && iCount >= 100)
|
||||
{
|
||||
uint32_t tTime = GetTime() - tStartTime;
|
||||
uint32_t tTime = C4TimeMilliseconds::Now() - tStartTime;
|
||||
|
||||
tTimeSum += tTime;
|
||||
tTimeSumPart += tTime;
|
||||
|
|
|
@ -43,12 +43,13 @@ char DummyData[1024 * 1024];
|
|||
|
||||
class MyCBClass : public C4NetIOMan
|
||||
{
|
||||
unsigned int iTime, iPcks;
|
||||
unsigned int tTime, iPcks;
|
||||
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 = GetTime(); iPcks = 0;
|
||||
tTime = C4TimeMilliseconds::Now();
|
||||
iPcks = 0;
|
||||
|
||||
#ifdef ASYNC_CONNECT
|
||||
if (!fHost)
|
||||
|
@ -62,10 +63,12 @@ public:
|
|||
}
|
||||
virtual void OnPacket(const class C4NetIOPacket &rPacket, C4NetIO *pNetIO)
|
||||
{
|
||||
if (GetTime() > iTime + 1000)
|
||||
C4TimeMilliseconds tNow = C4TimeMilliseconds::Now();
|
||||
if (tNow > tTime + 1000)
|
||||
{
|
||||
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;
|
||||
cout << iPcks << " packets in " << tNow - tTime << " ms (" << iPcks * 1000 / (tNow - tTime) << " per second, " << (iPcks ? (tNow - tTime) * 1000 / iPcks : -1u) << "us per packet)" << endl;
|
||||
tTime = C4TimeMilliseconds::Now();
|
||||
iPcks = 0;
|
||||
}
|
||||
if (!rPacket.getStatus())
|
||||
{
|
||||
|
|
|
@ -63,7 +63,7 @@ bool C4GameControlNetwork::Init(int32_t inClientID, bool fnHost, int32_t iStartT
|
|||
// ok
|
||||
fEnabled = true; fRunning = false;
|
||||
iTargetFPS = 38;
|
||||
tNextControlRequest = GetTime() + C4ControlRequestInterval;
|
||||
tNextControlRequest = C4TimeMilliseconds::Now() + C4ControlRequestInterval;
|
||||
if(tWaitStart)
|
||||
{
|
||||
delete tWaitStart;
|
||||
|
@ -95,7 +95,7 @@ void C4GameControlNetwork::Execute() // by main thread
|
|||
|
||||
// Save time the control tick was reached
|
||||
if (!tWaitStart)
|
||||
tWaitStart = new C4TimeMilliseconds(GetTime());
|
||||
tWaitStart = new C4TimeMilliseconds(C4TimeMilliseconds::Now());
|
||||
|
||||
// Execute any queued sync control
|
||||
ExecQueuedSyncCtrl();
|
||||
|
@ -745,7 +745,7 @@ void C4GameControlNetwork::CheckCompleteCtrl(bool fSetEvent) // by both
|
|||
// target ctrl tick to reach?
|
||||
if (iControlReady < iTargetTick &&
|
||||
(!fActivated || iControlSent > iControlReady) &&
|
||||
GetTime() >= tNextControlRequest)
|
||||
C4TimeMilliseconds::Now() >= tNextControlRequest)
|
||||
{
|
||||
Application.InteractiveThread.ThreadLogS("Network: Recovering: Requesting control for tick %d...", iControlReady + 1);
|
||||
// make request
|
||||
|
@ -756,7 +756,7 @@ void C4GameControlNetwork::CheckCompleteCtrl(bool fSetEvent) // by both
|
|||
else
|
||||
::Network.Clients.BroadcastMsgToConnClients(Pkt);
|
||||
// set time for next request
|
||||
tNextControlRequest = GetTime() + C4ControlRequestInterval;
|
||||
tNextControlRequest = C4TimeMilliseconds::Now() + C4ControlRequestInterval;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -774,7 +774,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 || !tWaitStart || GetTime() <= *tWaitStart + iMaxWait)
|
||||
if (eMode != CNM_Async || !tWaitStart || C4TimeMilliseconds::Now() <= *tWaitStart + iMaxWait)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -805,7 +805,7 @@ C4GameControlPacket *C4GameControlNetwork::PackCompleteCtrl(int32_t iTick)
|
|||
::Network.Clients.BroadcastMsgToConnClients(MkC4NetIOPacket(PID_Control, *pComplete));
|
||||
|
||||
// advance control request time
|
||||
tNextControlRequest = Max(tNextControlRequest, GetTime() + C4ControlRequestInterval);
|
||||
tNextControlRequest = Max(tNextControlRequest, C4TimeMilliseconds::Now() + C4ControlRequestInterval);
|
||||
|
||||
// return
|
||||
return pComplete;
|
||||
|
@ -861,7 +861,7 @@ void C4GameControlNetwork::ExecQueuedSyncCtrl() // by main thread
|
|||
C4GameControlPacket::C4GameControlPacket()
|
||||
: iClientID(C4ClientIDUnknown),
|
||||
iCtrlTick(-1),
|
||||
tTime(GetTime()),
|
||||
tTime(C4TimeMilliseconds::Now()),
|
||||
pNext(NULL)
|
||||
{
|
||||
|
||||
|
@ -870,7 +870,7 @@ C4GameControlPacket::C4GameControlPacket()
|
|||
C4GameControlPacket::C4GameControlPacket(const C4GameControlPacket &Pkt2)
|
||||
: C4PacketBase(Pkt2), iClientID(Pkt2.getClientID()),
|
||||
iCtrlTick(Pkt2.getCtrlTick()),
|
||||
tTime(GetTime()),
|
||||
tTime(C4TimeMilliseconds::Now()),
|
||||
pNext(NULL)
|
||||
{
|
||||
Ctrl.Copy(Pkt2.getControl());
|
||||
|
|
|
@ -88,7 +88,7 @@ bool C4InteractiveThread::PushEvent(C4InteractiveEventType eEvent, void *pData)
|
|||
pEvent->Type = eEvent;
|
||||
pEvent->Data = pData;
|
||||
#ifdef _DEBUG
|
||||
pEvent->Time = GetTime();
|
||||
pEvent->Time = C4TimeMilliseconds::Now();
|
||||
#endif
|
||||
pEvent->Next = NULL;
|
||||
// add item (at end)
|
||||
|
@ -118,7 +118,7 @@ bool C4InteractiveThread::PopEvent(C4InteractiveEventType *pEventType, void **pp
|
|||
*ppData = pEvent->Data;
|
||||
#ifdef _DEBUG
|
||||
if (Game.IsRunning)
|
||||
AvgNetEvDelay += ((GetTime() - pEvent->Time) - AvgNetEvDelay) / 100;
|
||||
AvgNetEvDelay += ((C4TimeMilliseconds::Now() - pEvent->Time) - AvgNetEvDelay) / 100;
|
||||
#endif
|
||||
// remove
|
||||
delete pFirstEvent;
|
||||
|
|
|
@ -1832,7 +1832,7 @@ bool C4NetIOUDP::Init(uint16_t inPort)
|
|||
fMultiCast = false;
|
||||
|
||||
if(!tNextCheck) tNextCheck = new C4TimeMilliseconds();
|
||||
*tNextCheck = GetTime() + iCheckInterval;
|
||||
*tNextCheck = C4TimeMilliseconds::Now() + iCheckInterval;
|
||||
|
||||
// ok, that's all for now.
|
||||
// call InitBroadcast for more initialization fun
|
||||
|
@ -2004,7 +2004,7 @@ bool C4NetIOUDP::Execute(int iMaxTime, pollfd *) // (mt-safe)
|
|||
ResetError();
|
||||
|
||||
// adjust maximum block time
|
||||
C4TimeMilliseconds tNow = GetTime();
|
||||
C4TimeMilliseconds tNow = C4TimeMilliseconds::Now();
|
||||
uint32_t iMaxBlock = GetNextTick(tNow) - tNow;
|
||||
if (iMaxTime == TO_INF || iMaxTime > (int) iMaxBlock) iMaxTime = iMaxBlock;
|
||||
|
||||
|
@ -2014,7 +2014,7 @@ bool C4NetIOUDP::Execute(int iMaxTime, pollfd *) // (mt-safe)
|
|||
|
||||
// connection check needed?
|
||||
if (tNextCheck)
|
||||
if (*tNextCheck <= GetTime())
|
||||
if (*tNextCheck <= C4TimeMilliseconds::Now())
|
||||
DoCheck();
|
||||
// client timeout?
|
||||
for (Peer *pPeer = pPeerList; pPeer; pPeer = pPeer->Next)
|
||||
|
@ -2540,7 +2540,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 = !!tNextReCheck && *tNextReCheck > GetTime();
|
||||
bool fNoReCheck = !!tNextReCheck && *tNextReCheck > C4TimeMilliseconds::Now();
|
||||
if (!fNoReCheck) iLastPacketAsked = iLastMCPacketAsked = 0;
|
||||
unsigned int iStartAt = fNoReCheck ? Max(iLastPacketAsked + 1, iIPacketCounter) : iIPacketCounter;
|
||||
unsigned int iStartAtMC = fNoReCheck ? Max(iLastMCPacketAsked + 1, iIMCPacketCounter) : iIMCPacketCounter;
|
||||
|
@ -2560,7 +2560,7 @@ bool C4NetIOUDP::Peer::Check(bool fForceCheck)
|
|||
if (!fNoReCheck)
|
||||
{
|
||||
if(!tNextReCheck) tNextReCheck = new C4TimeMilliseconds();
|
||||
*tNextReCheck = iEAskCnt ? GetTime() + iReCheckInterval : 0;
|
||||
*tNextReCheck = iEAskCnt ? C4TimeMilliseconds::Now() + iReCheckInterval : 0;
|
||||
}
|
||||
// something to ask for? (or check forced?)
|
||||
if (iEAskCnt || fForceCheck)
|
||||
|
@ -2795,7 +2795,7 @@ void C4NetIOUDP::Peer::CheckTimeout()
|
|||
// timeout set?
|
||||
if (!tTimeout) return;
|
||||
// check
|
||||
if (GetTime() > *tTimeout)
|
||||
if (C4TimeMilliseconds::Now() > *tTimeout)
|
||||
OnTimeout();
|
||||
}
|
||||
|
||||
|
@ -2946,7 +2946,7 @@ void C4NetIOUDP::Peer::SetTimeout(int iLength, int iRetryCnt) // (mt-safe)
|
|||
if (iLength != TO_INF)
|
||||
{
|
||||
if(!tTimeout) tTimeout = new C4TimeMilliseconds();
|
||||
*tTimeout = GetTime() + iLength;
|
||||
*tTimeout = C4TimeMilliseconds::Now() + iLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3171,7 +3171,7 @@ void C4NetIOUDP::DoCheck() // (mt-safe)
|
|||
|
||||
// set time for next check
|
||||
if(!tNextCheck) tNextCheck = new C4TimeMilliseconds();
|
||||
*tNextCheck = GetTime() + iCheckInterval;
|
||||
*tNextCheck = C4TimeMilliseconds::Now() + iCheckInterval;
|
||||
}
|
||||
|
||||
// debug
|
||||
|
@ -3219,7 +3219,7 @@ void C4NetIOUDP::CloseDebugLog()
|
|||
void C4NetIOUDP::DebugLogPkt(bool fOut, const C4NetIOPacket &Pkt)
|
||||
{
|
||||
StdStrBuf O;
|
||||
uint32_t tTime = GetTime().AsInt();
|
||||
uint32_t tTime = C4TimeMilliseconds::Now().AsInt();
|
||||
O.Format("%s %u:%02u:%02u:%03u %s:%d:", fOut ? "out" : "in ",
|
||||
(tTime / 1000 / 60 / 60), (tTime / 1000 / 60) % 60, (tTime / 1000) % 60, tTime % 1000,
|
||||
inet_ntoa(Pkt.getAddr().sin_addr), htons(Pkt.getAddr().sin_port));
|
||||
|
|
|
@ -1508,7 +1508,7 @@ C4Network2Res::Ref C4Network2::RetrieveRes(const C4Network2ResCore &Core, int32_
|
|||
C4GUI::ProgressDialog *pDlg = NULL;
|
||||
bool fLog = false;
|
||||
int32_t iProcess = -1;
|
||||
C4TimeMilliseconds tTimeout = GetTime() + iTimeoutLen;
|
||||
C4TimeMilliseconds tTimeout = C4TimeMilliseconds::Now() + iTimeoutLen;
|
||||
// wait for resource
|
||||
while (isEnabled())
|
||||
{
|
||||
|
@ -1542,12 +1542,12 @@ C4Network2Res::Ref C4Network2::RetrieveRes(const C4Network2ResCore &Core, int32_
|
|||
if (pRes && pRes->getPresentPercent() != iProcess)
|
||||
{
|
||||
iProcess = pRes->getPresentPercent();
|
||||
tTimeout = GetTime() + iTimeoutLen;
|
||||
tTimeout = C4TimeMilliseconds::Now() + iTimeoutLen;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if not: check timeout
|
||||
if (GetTime() > tTimeout)
|
||||
if (C4TimeMilliseconds::Now() > tTimeout)
|
||||
{
|
||||
LogFatal(FormatString(LoadResStr("IDS_NET_ERR_RESTIMEOUT"), szResName).getData());
|
||||
if (pDlg) delete pDlg;
|
||||
|
@ -1584,7 +1584,7 @@ C4Network2Res::Ref C4Network2::RetrieveRes(const C4Network2ResCore &Core, int32_
|
|||
}
|
||||
else
|
||||
{
|
||||
if (!Application.ScheduleProcs(tTimeout - GetTime()))
|
||||
if (!Application.ScheduleProcs(tTimeout - C4TimeMilliseconds::Now()))
|
||||
{ return NULL; }
|
||||
}
|
||||
|
||||
|
@ -1787,7 +1787,7 @@ void C4Network2::RequestActivate()
|
|||
}
|
||||
// ensure interval
|
||||
if (tLastActivateRequest)
|
||||
if(GetTime() < *tLastActivateRequest + C4NetActivationReqInterval)
|
||||
if(C4TimeMilliseconds::Now() < *tLastActivateRequest + C4NetActivationReqInterval)
|
||||
return;
|
||||
// status not reached yet? May be chasing, let's delay this.
|
||||
if (!fStatusReached)
|
||||
|
@ -1799,9 +1799,9 @@ void C4Network2::RequestActivate()
|
|||
Clients.SendMsgToHost(MkC4NetIOPacket(PID_ClientActReq, C4PacketActivateReq(Game.FrameCounter)));
|
||||
// store time
|
||||
if(!tLastActivateRequest)
|
||||
tLastActivateRequest = new C4TimeMilliseconds(GetTime());
|
||||
tLastActivateRequest = new C4TimeMilliseconds(C4TimeMilliseconds::Now());
|
||||
else
|
||||
*tLastActivateRequest = GetTime();
|
||||
*tLastActivateRequest = C4TimeMilliseconds::Now();
|
||||
}
|
||||
|
||||
void C4Network2::DeactivateInactiveClients()
|
||||
|
|
|
@ -77,7 +77,7 @@ bool C4Network2IO::Init(int16_t iPortTCP, int16_t iPortUDP, int16_t iPortDiscove
|
|||
if (pNetIO_TCP || pNetIO_UDP) Clear();
|
||||
|
||||
// init members
|
||||
tLastPing = tLastStatistic = GetTime();
|
||||
tLastPing = tLastStatistic = C4TimeMilliseconds::Now();
|
||||
iTCPIRate = iTCPORate = iTCPBCRate = 0;
|
||||
iUDPIRate = iUDPORate = iUDPBCRate = 0;
|
||||
|
||||
|
@ -201,7 +201,7 @@ bool C4Network2IO::Init(int16_t iPortTCP, int16_t iPortUDP, int16_t iPortDiscove
|
|||
}
|
||||
|
||||
// own timer
|
||||
tLastExecute = GetTime();
|
||||
tLastExecute = C4TimeMilliseconds::Now();
|
||||
Thread.AddProc(this);
|
||||
|
||||
// ok
|
||||
|
@ -506,7 +506,7 @@ bool C4Network2IO::OnConn(const C4NetIO::addr_t &PeerAddr, const C4NetIO::addr_t
|
|||
return false;
|
||||
}
|
||||
#if(C4NET2IO_DUMP_LEVEL > 1)
|
||||
uint32_t tTime = GetTime().AsInt();
|
||||
uint32_t tTime = C4TimeMilliseconds::Now().AsInt();
|
||||
ThreadLogS("OnConn: %u:%02u:%02u:%03u: %s",
|
||||
(tTime / 1000 / 60 / 60), (tTime / 1000 / 60) % 60, (tTime / 1000) % 60, tTime % 1000,
|
||||
getNetIOName(pNetIO));
|
||||
|
@ -561,7 +561,7 @@ void C4Network2IO::OnDisconn(const C4NetIO::addr_t &addr, C4NetIO *pNetIO, const
|
|||
return;
|
||||
}
|
||||
#if(C4NET2IO_DUMP_LEVEL > 1)
|
||||
uint32_t tTime = GetTime().AsInt();
|
||||
uint32_t tTime = C4TimeMilliseconds::Now().AsInt();
|
||||
ThreadLogS("OnDisconn: %u:%02u:%02u:%03u: %s",
|
||||
(tTime / 1000 / 60 / 60), (tTime / 1000 / 60) % 60, (tTime / 1000) % 60, tTime % 1000,
|
||||
getNetIOName(pNetIO));
|
||||
|
@ -591,7 +591,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)
|
||||
uint32_t tTime = GetTime().AsInt();
|
||||
uint32_t tTime = C4TimeMilliseconds::Now().AsInt();
|
||||
ThreadLogS("OnPacket: %u:%02u:%02u:%03u: status %02x %s",
|
||||
(tTime / 1000 / 60 / 60), (tTime / 1000 / 60) % 60, (tTime / 1000) % 60, tTime % 1000,
|
||||
rPacket.getStatus(), getNetIOName(pNetIO));
|
||||
|
@ -601,8 +601,9 @@ 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 (GetTime() - tTime > 100)
|
||||
ThreadLogS("OnPacket: ... blocked %d ms for finding the connection!", GetTime() - tTime);
|
||||
uint32_t iFindConnectionBlocked = C4TimeMilliseconds::Now() - tTime;
|
||||
if (iFindConnectionBlocked > 100)
|
||||
ThreadLogS("OnPacket: ... blocked %d ms for finding the connection!", iFindConnectionBlocked);
|
||||
#endif
|
||||
// notify
|
||||
pConn->OnPacketReceived(rPacket.getStatus());
|
||||
|
@ -610,8 +611,9 @@ void C4Network2IO::OnPacket(const class C4NetIOPacket &rPacket, C4NetIO *pNetIO)
|
|||
HandlePacket(rPacket, pConn, true);
|
||||
// log time
|
||||
#if(C4NET2IO_DUMP_LEVEL > 1)
|
||||
if (GetTime() - tTime > 100)
|
||||
ThreadLogS("OnPacket: ... blocked %d ms for handling!", GetTime() - tTime);
|
||||
uint32_t iHandlingBlocked = C4TimeMilliseconds::Now() - tTime;
|
||||
if (iHandlingBlocked > 100)
|
||||
ThreadLogS("OnPacket: ... blocked %d ms for handling!", iHandlingBlocked);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -623,7 +625,7 @@ void C4Network2IO::OnError(const char *strError, C4NetIO *pNetIO)
|
|||
|
||||
bool C4Network2IO::Execute(int iTimeout, pollfd *)
|
||||
{
|
||||
tLastExecute = GetTime();
|
||||
tLastExecute = C4TimeMilliseconds::Now();
|
||||
|
||||
// check for timeout
|
||||
CheckTimeout();
|
||||
|
@ -845,7 +847,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)
|
||||
{
|
||||
uint32_t tTime = GetTime().AsInt();
|
||||
uint32_t tTime = C4TimeMilliseconds::Now().AsInt();
|
||||
// StdStrBuf PacketDump = DecompileToBuf<StdCompilerINIWrite>(mkNamingAdaptrPacket);
|
||||
StdStrBuf PacketHeader = FormatString("HandlePacket: %u:%02u:%02u:%03u by %s:%d (%lu bytes, counter %d)",
|
||||
tTime / 1000 / 60 / 60, (tTime / 1000 / 60) % 60, (tTime / 1000) % 60, tTime % 1000,
|
||||
|
@ -870,14 +872,14 @@ bool C4Network2IO::HandlePacket(const C4NetIOPacket &rPacket, C4Network2IOConnec
|
|||
{
|
||||
fHandled = true;
|
||||
#if(C4NET2IO_DUMP_LEVEL > 2)
|
||||
C4TimeMilliseconds tStart = GetTime();
|
||||
C4TimeMilliseconds tStart = C4TimeMilliseconds::Now();
|
||||
#endif
|
||||
|
||||
// call handler(s)
|
||||
CallHandlers(pHData->HandlerID, &Pkt, pConn, fThread);
|
||||
|
||||
#if(C4NET2IO_DUMP_LEVEL > 2)
|
||||
uint32_t iBlockedTime = GetTime() - tStart;
|
||||
uint32_t iBlockedTime = C4TimeMilliseconds::Now() - tStart;
|
||||
if (fThread && iBlockedTime > 100)
|
||||
{
|
||||
ThreadLogS("HandlePacket: ... blocked for %u ms!", iBlockedTime);
|
||||
|
@ -1334,7 +1336,7 @@ int C4Network2IOConnection::getLag() const
|
|||
// Last ping not answered yet?
|
||||
if(tLastPing && (!tLastPong || *tLastPing > *tLastPong))
|
||||
{
|
||||
int iPingLag = GetTime() - *tLastPing;
|
||||
int iPingLag = C4TimeMilliseconds::Now() - *tLastPing;
|
||||
// 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);
|
||||
|
@ -1377,7 +1379,7 @@ void C4Network2IOConnection::OnPing()
|
|||
|
||||
// Save time
|
||||
if(!tLastPing) tLastPing = new C4TimeMilliseconds();
|
||||
*tLastPing = GetTime();
|
||||
*tLastPing = C4TimeMilliseconds::Now();
|
||||
}
|
||||
|
||||
void C4Network2IOConnection::SetPingTime(int inPingTime)
|
||||
|
@ -1386,7 +1388,7 @@ void C4Network2IOConnection::SetPingTime(int inPingTime)
|
|||
iPingTime = inPingTime;
|
||||
// pong received - save timestamp
|
||||
if(!tLastPong) tLastPong = new C4TimeMilliseconds();
|
||||
*tLastPong = GetTime();
|
||||
*tLastPong = C4TimeMilliseconds::Now();
|
||||
}
|
||||
|
||||
void C4Network2IOConnection::SetStatus(C4Network2IOConnStatus nStatus)
|
||||
|
|
|
@ -513,14 +513,14 @@ void C4PacketJoinData::CompileFunc(StdCompiler *pComp)
|
|||
// *** C4PacketPing
|
||||
|
||||
C4PacketPing::C4PacketPing(uint32_t iPacketCounter, uint32_t iRemotePacketCounter)
|
||||
: tTime(GetTime()),
|
||||
: tTime(C4TimeMilliseconds::Now()),
|
||||
iPacketCounter(iPacketCounter)
|
||||
{
|
||||
}
|
||||
|
||||
uint32_t C4PacketPing::getTravelTime() const
|
||||
{
|
||||
return GetTime() - tTime;
|
||||
return C4TimeMilliseconds::Now() - tTime;
|
||||
}
|
||||
|
||||
void C4PacketPing::CompileFunc(StdCompiler *pComp)
|
||||
|
|
|
@ -99,7 +99,7 @@ public:
|
|||
// StdSchedulerProc override
|
||||
virtual void GetFDs(std::vector<struct pollfd> & rfds)
|
||||
{
|
||||
if (!query_time) query(GetTime());
|
||||
if (!query_time) query(C4TimeMilliseconds::Now());
|
||||
rfds.insert(rfds.end(), fds.begin(), fds.end());
|
||||
}
|
||||
virtual C4TimeMilliseconds GetNextTick(C4TimeMilliseconds Now)
|
||||
|
|
|
@ -37,10 +37,13 @@
|
|||
|
||||
static void sdlToC4MCBtn(const SDL_MouseButtonEvent &e, int32_t& button, DWORD& flags)
|
||||
{
|
||||
static int lastLeftClick = 0, lastRightClick = 0;
|
||||
C4TimeMilliseconds lastLeftClick = C4TimeMilliseconds::Now();
|
||||
C4TimeMilliseconds lastRightClick = C4TimeMilliseconds::Now();
|
||||
static int lastX = 0, lastY = 0;
|
||||
|
||||
static const int clickDist = 2;
|
||||
|
||||
static const int clickDelay = 400;
|
||||
|
||||
button = C4MC_Button_None;
|
||||
flags = 0;
|
||||
|
||||
|
@ -48,14 +51,14 @@ static void sdlToC4MCBtn(const SDL_MouseButtonEvent &e, int32_t& button, DWORD&
|
|||
{
|
||||
case SDL_BUTTON_LEFT:
|
||||
if (e.state == SDL_PRESSED)
|
||||
if (GetTime() - lastLeftClick < 400 && abs(lastX-e.x) <= clickDist && abs(lastY-e.y) <= clickDist)
|
||||
if (C4TimeMilliseconds::Now() - lastLeftClick < clickDelay && abs(lastX-e.x) <= clickDist && abs(lastY-e.y) <= clickDist)
|
||||
{
|
||||
lastLeftClick = 0;
|
||||
button = C4MC_Button_LeftDouble;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastLeftClick = GetTime();
|
||||
lastLeftClick = C4TimeMilliseconds::Now();
|
||||
button = C4MC_Button_LeftDown;
|
||||
}
|
||||
else
|
||||
|
@ -63,14 +66,14 @@ static void sdlToC4MCBtn(const SDL_MouseButtonEvent &e, int32_t& button, DWORD&
|
|||
break;
|
||||
case SDL_BUTTON_RIGHT:
|
||||
if (e.state == SDL_PRESSED)
|
||||
if (GetTime() - lastRightClick < 400)
|
||||
if (C4TimeMilliseconds::Now() - lastRightClick < clickDelay)
|
||||
{
|
||||
lastRightClick = 0;
|
||||
button = C4MC_Button_RightDouble;
|
||||
}
|
||||
else
|
||||
{
|
||||
lastRightClick = GetTime();
|
||||
lastRightClick = C4TimeMilliseconds::Now();
|
||||
button = C4MC_Button_RightDown;
|
||||
}
|
||||
else
|
||||
|
|
|
@ -232,7 +232,7 @@ bool C4SoundInstance::Create(C4SoundEffect *pnEffect, bool fLoop, int32_t inVolu
|
|||
// Set effect
|
||||
pEffect = pnEffect;
|
||||
// Set
|
||||
tStarted = GetTime();
|
||||
tStarted = C4TimeMilliseconds::Now();
|
||||
iVolume = inVolume; iPan = 0; iChannel = -1;
|
||||
iNearInstanceMax = inNearInstanceMax;
|
||||
this->iFalloffDistance = iFalloffDistance;
|
||||
|
@ -248,7 +248,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 (GetTime() > tStarted + pEffect->Length / 2 && !fLooping)
|
||||
if (C4TimeMilliseconds::Now() > tStarted + pEffect->Length / 2 && !fLooping)
|
||||
return false;
|
||||
// do near-instances check
|
||||
int32_t iNearInstances = pObj ? pEffect->GetStartedInstanceCount(pObj->GetX(), pObj->GetY(), C4NearSoundRadius)
|
||||
|
@ -268,10 +268,10 @@ bool C4SoundInstance::Start()
|
|||
if (!FSOUND_SetLoopMode(iChannel, fLooping ? FSOUND_LOOP_NORMAL : FSOUND_LOOP_OFF))
|
||||
{ Stop(); return false; }
|
||||
// set position
|
||||
if (GetTime() > tStarted + 20)
|
||||
if (C4TimeMilliseconds::Now() > tStarted + 20)
|
||||
{
|
||||
assert(pEffect->Length > 0);
|
||||
int32_t iTime = (GetTime() - tStarted) % pEffect->Length;
|
||||
int32_t iTime = (C4TimeMilliseconds::Now() - tStarted) % pEffect->Length;
|
||||
FSOUND_SetCurrentPosition(iChannel, iTime / 10 * pEffect->SampleRate / 100);
|
||||
}
|
||||
#elif defined HAVE_LIBSDL_MIXER
|
||||
|
@ -329,7 +329,7 @@ bool C4SoundInstance::Playing()
|
|||
#ifdef HAVE_FMOD
|
||||
if (fLooping) return true;
|
||||
return isStarted() ? FSOUND_GetCurrentSample(iChannel) == pEffect->pSample
|
||||
: GetTime() < tStarted + pEffect->Length;
|
||||
: C4TimeMilliseconds::Now() < tStarted + pEffect->Length;
|
||||
#endif
|
||||
#ifdef HAVE_LIBSDL_MIXER
|
||||
return Application.MusicSystem.MODInitialized && (iChannel != -1) && Mix_Playing(iChannel);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
/*
|
||||
* OpenClonk, http://www.openclonk.org
|
||||
*
|
||||
* Copyright (c) 2005, 2011 Günther Brammer
|
||||
* Copyright (c) 2013 Tobias Zwick
|
||||
* Copyright (c) 2005, 2011 Günther Brammer
|
||||
* Copyright (c) 2012 Martin Plicht
|
||||
* Copyright (c) 2001-2009, RedWolf Design GmbH, http://www.clonk.de
|
||||
*
|
||||
|
@ -17,7 +18,6 @@
|
|||
* See clonk_trademark_license.txt for full license.
|
||||
*/
|
||||
|
||||
#include "C4Include.h"
|
||||
#include "C4TimeMilliseconds.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -25,7 +25,7 @@
|
|||
#include <C4windowswrapper.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
C4TimeMilliseconds GetTime()
|
||||
C4TimeMilliseconds C4TimeMilliseconds::Now()
|
||||
{
|
||||
return C4TimeMilliseconds(timeGetTime());
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ C4TimeMilliseconds GetTime()
|
|||
#include <time.h>
|
||||
#endif
|
||||
|
||||
C4TimeMilliseconds GetTime()
|
||||
C4TimeMilliseconds C4TimeMilliseconds::Now()
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
static time_t sec_offset;
|
||||
|
@ -54,4 +54,4 @@ C4TimeMilliseconds GetTime()
|
|||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
|
@ -40,6 +40,8 @@ private:
|
|||
uint32_t time;
|
||||
|
||||
public:
|
||||
static C4TimeMilliseconds Now();
|
||||
|
||||
C4TimeMilliseconds() : time(0) { }
|
||||
C4TimeMilliseconds(uint32_t millis) : time(millis) { }
|
||||
C4TimeMilliseconds(const C4TimeMilliseconds& rhs) : time(rhs.time) { }
|
||||
|
|
|
@ -229,10 +229,6 @@ bool IsGermanSystem();
|
|||
// open a weblink in an external browser
|
||||
bool OpenURL(const char* szURL);
|
||||
|
||||
// Get a monotonically increasing timestamp in milliseconds
|
||||
class C4TimeMilliseconds;
|
||||
C4TimeMilliseconds GetTime();
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <io.h>
|
||||
#define F_OK 0
|
||||
|
|
|
@ -65,14 +65,14 @@ bool StdSchedulerProc::ExecuteUntil(int iTimeout)
|
|||
if (!Execute())
|
||||
return false;
|
||||
// Calculate endpoint
|
||||
C4TimeMilliseconds tStopTime = GetTime() + iTimeout;
|
||||
C4TimeMilliseconds tStopTime = C4TimeMilliseconds::Now() + iTimeout;
|
||||
for (;;)
|
||||
{
|
||||
// Call execute with given timeout
|
||||
if (!Execute(Max(iTimeout, 0)))
|
||||
return false;
|
||||
// Calculate timeout
|
||||
C4TimeMilliseconds tTime = GetTime();
|
||||
C4TimeMilliseconds tTime = C4TimeMilliseconds::Now();
|
||||
if (tTime >= tStopTime)
|
||||
break;
|
||||
iTimeout = tStopTime - tTime;
|
||||
|
@ -177,7 +177,7 @@ bool StdScheduler::ScheduleProcs(int iTimeout)
|
|||
// Get timeout
|
||||
int i;
|
||||
C4TimeMilliseconds tProcTick;
|
||||
C4TimeMilliseconds tNow = GetTime();
|
||||
C4TimeMilliseconds tNow = C4TimeMilliseconds::Now();
|
||||
for (i = 0; i < iProcCnt; i++)
|
||||
{
|
||||
if(ppProcs[i]->IsScheduledExecution())
|
||||
|
@ -234,7 +234,7 @@ bool StdScheduler::ScheduleProcs(int iTimeout)
|
|||
}
|
||||
|
||||
// Execute all processes with timeout
|
||||
tNow = GetTime();
|
||||
tNow = C4TimeMilliseconds::Now();
|
||||
for (i = 0; i < iProcCnt; i++)
|
||||
{
|
||||
if(ppProcs[i]->IsScheduledExecution())
|
||||
|
@ -272,7 +272,7 @@ bool StdScheduler::ScheduleProcs(int iTimeout)
|
|||
if (cnt >= 0)
|
||||
{
|
||||
bool any_executed = false;
|
||||
tNow = GetTime();
|
||||
tNow = C4TimeMilliseconds::Now();
|
||||
// Which process?
|
||||
for (i = 0; i < iProcCnt; i++)
|
||||
{
|
||||
|
|
|
@ -102,7 +102,7 @@ public:
|
|||
void SetDelay(uint32_t inDelay) { iDelay = inDelay; }
|
||||
bool CheckAndReset()
|
||||
{
|
||||
C4TimeMilliseconds tTime = GetTime();
|
||||
C4TimeMilliseconds tTime = C4TimeMilliseconds::Now();
|
||||
// first execution
|
||||
if(!tLastTimer)
|
||||
{
|
||||
|
|
|
@ -941,7 +941,7 @@ void C4AulExec::StartProfiling(C4AulScript *pProfiledScript)
|
|||
fProfiling = true;
|
||||
// resets profling times and starts recording the times
|
||||
this->pProfiledScript = pProfiledScript;
|
||||
C4TimeMilliseconds tNow = GetTime();
|
||||
C4TimeMilliseconds tNow = C4TimeMilliseconds::Now();
|
||||
tDirectExecStart = tNow; // in case profiling is started from DirectExec
|
||||
tDirectExecTotal = 0;
|
||||
pProfiledScript->ResetProfilerTimes();
|
||||
|
@ -974,7 +974,7 @@ void C4AulExec::PushContext(const C4AulScriptContext &rContext)
|
|||
pCurCtx->dump(Buf);
|
||||
}
|
||||
// Profiler: Safe time to measure difference afterwards
|
||||
if (fProfiling) pCurCtx->tTime = GetTime();
|
||||
if (fProfiling) pCurCtx->tTime = C4TimeMilliseconds::Now();
|
||||
}
|
||||
|
||||
void C4AulExec::PopContext()
|
||||
|
@ -984,7 +984,7 @@ void C4AulExec::PopContext()
|
|||
// Profiler adding up times
|
||||
if (fProfiling)
|
||||
{
|
||||
uint32_t dt = GetTime() - pCurCtx->tTime;
|
||||
uint32_t dt = C4TimeMilliseconds::Now() - pCurCtx->tTime;
|
||||
if (pCurCtx->Func)
|
||||
pCurCtx->Func->tProfileTime += dt;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#define C4AULEXEC_H
|
||||
|
||||
#include <C4Aul.h>
|
||||
#include "C4TimeMilliseconds.h"
|
||||
|
||||
const int MAX_CONTEXT_STACK = 512;
|
||||
const int MAX_VALUE_STACK = 1024;
|
||||
|
@ -65,8 +66,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 = GetTime(); }
|
||||
inline void StopDirectExec() { if (fProfiling) tDirectExecTotal += GetTime() - tDirectExecStart; }
|
||||
inline void StartDirectExec() { if (fProfiling) tDirectExecStart = C4TimeMilliseconds::Now(); }
|
||||
inline void StopDirectExec() { if (fProfiling) tDirectExecTotal += C4TimeMilliseconds::Now() - tDirectExecStart; }
|
||||
|
||||
int GetContextDepth() const { return pCurCtx - Contexts + 1; }
|
||||
C4AulScriptContext *GetContext(int iLevel) { return iLevel >= 0 && iLevel < GetContextDepth() ? Contexts + iLevel : NULL; }
|
||||
|
|
Loading…
Reference in New Issue