mirror of
https://github.com/edubart/otclient.git
synced 2025-12-16 05:39:47 +01:00
display motd message only once, remove update loop, use g_platform.getTicks() instead
This commit is contained in:
@@ -14,8 +14,11 @@ public:
|
||||
/// Poll platform input/window events
|
||||
void poll();
|
||||
|
||||
/// Get current time in milliseconds since init
|
||||
int getTicks();
|
||||
void updateTicks();
|
||||
|
||||
/// Get current time in milliseconds since last application init
|
||||
int getTicks() { return m_lastTicks; }
|
||||
|
||||
/// Sleep in current thread
|
||||
void sleep(ulong ms);
|
||||
|
||||
@@ -58,6 +61,7 @@ public:
|
||||
|
||||
private:
|
||||
PlatformListener* m_listener;
|
||||
int m_lastTicks;
|
||||
};
|
||||
|
||||
extern Platform g_platform;
|
||||
|
||||
@@ -38,6 +38,7 @@ struct X11PlatformPrivate {
|
||||
int height;
|
||||
int x;
|
||||
int y;
|
||||
int lastTicks;
|
||||
std::string clipboardText;
|
||||
std::map<int, uchar> keyMap;
|
||||
PlatformListener* listener;
|
||||
@@ -240,7 +241,7 @@ void Platform::init(PlatformListener* platformListener, const char *appName)
|
||||
x11.atomWindowMaximizedHorz = XInternAtom(x11.display, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
|
||||
|
||||
// force first tick
|
||||
Platform::getTicks();
|
||||
updateTicks();
|
||||
}
|
||||
|
||||
void Platform::terminate()
|
||||
@@ -447,7 +448,7 @@ void Platform::poll()
|
||||
}
|
||||
}
|
||||
|
||||
int Platform::getTicks()
|
||||
void Platform::updateTicks()
|
||||
{
|
||||
static timeval tv;
|
||||
static ulong firstTick = 0;
|
||||
@@ -456,7 +457,7 @@ int Platform::getTicks()
|
||||
if(!firstTick)
|
||||
firstTick = tv.tv_sec;
|
||||
|
||||
return ((tv.tv_sec - firstTick) * 1000) + (tv.tv_usec / 1000);
|
||||
m_lastTicks = ((tv.tv_sec - firstTick) * 1000) + (tv.tv_usec / 1000);
|
||||
}
|
||||
|
||||
void Platform::sleep(ulong miliseconds)
|
||||
|
||||
Reference in New Issue
Block a user