Platform fixes and rework ping

This commit is contained in:
Eduardo Bart
2013-02-24 17:26:19 -03:00
parent a8c175452b
commit 06e2b6eca2
31 changed files with 178 additions and 111 deletions

View File

@@ -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)

View File

@@ -43,7 +43,7 @@ public:
bool shouldProcessNextFrame();
void processNextFrame();
void update();
bool update();
void setMaxFps(int maxFps);
bool isFpsLimitActive() { return m_maxFps != 0; }

View File

@@ -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();

View File

@@ -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();

View File

@@ -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; }