mirror of
https://github.com/edubart/otclient.git
synced 2025-12-18 14:47:11 +01:00
Platform fixes and rework ping
This commit is contained in:
@@ -60,7 +60,7 @@ void AdaptativeFrameCounter::processNextFrame()
|
||||
m_lastFrame = now ;
|
||||
}
|
||||
|
||||
void AdaptativeFrameCounter::update()
|
||||
bool AdaptativeFrameCounter::update()
|
||||
{
|
||||
ticks_t now = g_clock.micros();
|
||||
ticks_t delta = now - m_lastPartialFpsUpdate;
|
||||
@@ -82,7 +82,9 @@ void AdaptativeFrameCounter::update()
|
||||
m_frameDelaySum = 0;
|
||||
|
||||
//dump << stdext::format("FPS => %d Partial FPS => %d Frame Delay Hit => %.2f%%", m_lastFps, (int)m_partialFps, getFrameDelayHit());
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void AdaptativeFrameCounter::setMaxFps(int maxFps)
|
||||
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
bool shouldProcessNextFrame();
|
||||
void processNextFrame();
|
||||
void update();
|
||||
bool update();
|
||||
void setMaxFps(int maxFps);
|
||||
bool isFpsLimitActive() { return m_maxFps != 0; }
|
||||
|
||||
|
||||
@@ -184,7 +184,8 @@ void GraphicalApplication::run()
|
||||
// only update the current time once per frame to gain performance
|
||||
g_clock.update();
|
||||
|
||||
m_backgroundFrameCounter.update();
|
||||
if(m_backgroundFrameCounter.update())
|
||||
g_lua.callGlobalField("g_app", "onFps", m_backgroundFrameCounter.getLastFps());
|
||||
m_foregroundFrameCounter.update();
|
||||
|
||||
int sleepMicros = m_backgroundFrameCounter.getMaximumSleepMicros();
|
||||
|
||||
@@ -45,10 +45,11 @@ void ResourceManager::terminate()
|
||||
bool ResourceManager::discoverWorkDir(const std::string& existentFile)
|
||||
{
|
||||
// search for modules directory
|
||||
std::string possiblePaths[] = { g_resources.getCurrentDir(),
|
||||
std::string possiblePaths[] = { g_platform.getCurrentDir(),
|
||||
g_resources.getBaseDir(),
|
||||
g_resources.getBaseDir() + "../",
|
||||
g_resources.getBaseDir() + "../share/" + g_app.getCompactName() + "/" };
|
||||
|
||||
bool found = false;
|
||||
for(const std::string& dir : possiblePaths) {
|
||||
if(!PHYSFS_addToSearchPath(dir.c_str(), 0))
|
||||
@@ -296,11 +297,6 @@ std::string ResourceManager::getRealDir(const std::string& path)
|
||||
return dir;
|
||||
}
|
||||
|
||||
std::string ResourceManager::getCurrentDir()
|
||||
{
|
||||
return g_platform.getCurrentDir();
|
||||
}
|
||||
|
||||
std::string ResourceManager::getBaseDir()
|
||||
{
|
||||
return PHYSFS_getBaseDir();
|
||||
|
||||
@@ -64,7 +64,6 @@ public:
|
||||
|
||||
std::string resolvePath(const std::string& path);
|
||||
std::string getRealDir(const std::string& path);
|
||||
std::string getCurrentDir();
|
||||
std::string getBaseDir();
|
||||
std::string getUserDir();
|
||||
std::string getWriteDir() { return m_writeDir; }
|
||||
|
||||
Reference in New Issue
Block a user