diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-12-23 00:27:06 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-12-23 00:27:06 +0300 |
commit | a901facc32f489dbce6f9193f618d9d46a91f32c (patch) | |
tree | fcdb928294e8839eae1172873f63c3c0493fb968 | |
parent | 2ad5d25e30d7247d67a4784a6cb9e96245643960 (diff) | |
download | manaverse-a901facc32f489dbce6f9193f618d9d46a91f32c.tar.gz manaverse-a901facc32f489dbce6f9193f618d9d46a91f32c.tar.bz2 manaverse-a901facc32f489dbce6f9193f618d9d46a91f32c.tar.xz manaverse-a901facc32f489dbce6f9193f618d9d46a91f32c.zip |
Probably fix auto adjusting perfomance after going from sleep mode.
-rw-r--r-- | src/client.cpp | 8 | ||||
-rw-r--r-- | src/client.h | 2 | ||||
-rw-r--r-- | src/game.cpp | 30 |
3 files changed, 28 insertions, 12 deletions
diff --git a/src/client.cpp b/src/client.cpp index d2b26f662..b5cbffd40 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -2238,6 +2238,14 @@ void Client::setFramerate(int fpsLimit) SDL_setFramerate(&instance()->mFpsManager, fpsLimit); } +int Client::getFramerate() +{ + if (!instance()->mLimitFps) + return 0; + + return SDL_getFramerate(&instance()->mFpsManager); +} + void Client::closeDialogs() { Net::getNpcHandler()->clearDialogs(); diff --git a/src/client.h b/src/client.h index 3bcc5f597..fcb14a660 100644 --- a/src/client.h +++ b/src/client.h @@ -256,6 +256,8 @@ public: static void setFramerate(int fpsLimit); + static int getFramerate(); + static bool isTmw(); void optionChanged(const std::string &name); diff --git a/src/game.cpp b/src/game.cpp index 9245e213d..c40a7da59 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -572,6 +572,7 @@ void Game::logic() } closeDialogs(); Client::setFramerate(config.getIntValue("fpslimit")); + mNextAdjustTime = cur_time + adjustDelay; if (Client::getState() != STATE_ERROR) errorMessage = ""; } @@ -603,7 +604,10 @@ void Game::adjustPerfomance() return; } - int maxFps = config.getIntValue("fpslimit"); + int maxFps = Client::getFramerate(); + if (maxFps != config.getIntValue("fpslimit")) + return; + if (!maxFps) maxFps = 30; else if (maxFps < 10) @@ -1579,7 +1583,6 @@ void Game::handleActive(SDL_Event &event) player_node->setHalfAway(true); } } - Client::setFramerate(fpsLimit); } if (player_node) player_node->updateName(); @@ -1589,19 +1592,22 @@ void Game::handleActive(SDL_Event &event) if (event.active.state & SDL_APPMOUSEFOCUS) Client::setMouseFocused(event.active.gain); - if (player_node && player_node->getAway()) + if (!fpsLimit) { - if (Client::getInputFocused() || Client::getMouseFocused()) - fpsLimit = config.getIntValue("fpslimit"); + if (player_node && player_node->getAway()) + { + if (Client::getInputFocused() || Client::getMouseFocused()) + fpsLimit = config.getIntValue("fpslimit"); + else + fpsLimit = config.getIntValue("altfpslimit"); + } else - fpsLimit = config.getIntValue("altfpslimit"); - Client::setFramerate(fpsLimit); - } - else - { - fpsLimit = config.getIntValue("fpslimit"); - Client::setFramerate(fpsLimit); + { + fpsLimit = config.getIntValue("fpslimit"); + } } + Client::setFramerate(fpsLimit); + mNextAdjustTime = cur_time + adjustDelay; } /** |