summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-02-18 21:47:43 +0300
committerAndrei Karas <akaras@inbox.ru>2013-02-18 22:27:06 +0300
commite73c5ecc896c14fa43b19e42e5b24c79766cdb44 (patch)
tree9ee72afa6d4b8e150534f64a6c15085d1ce168b9 /src
parent25907c03212110f10c910b0ef90a416dff450ca7 (diff)
downloadmanaplus-e73c5ecc896c14fa43b19e42e5b24c79766cdb44.tar.gz
manaplus-e73c5ecc896c14fa43b19e42e5b24c79766cdb44.tar.bz2
manaplus-e73c5ecc896c14fa43b19e42e5b24c79766cdb44.tar.xz
manaplus-e73c5ecc896c14fa43b19e42e5b24c79766cdb44.zip
Change process priority depend on game state.
implimented only for windows version.
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp3
-rw-r--r--src/main.cpp2
-rw-r--r--src/utils/process.cpp15
-rw-r--r--src/utils/process.h2
4 files changed, 22 insertions, 0 deletions
diff --git a/src/game.cpp b/src/game.cpp
index c024c41dc..d5cebe6a1 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -89,6 +89,7 @@
#include "utils/gettext.h"
#include "utils/mkdir.h"
#include "utils/physfstools.h"
+#include "utils/process.h"
#include <guichan/exception.hpp>
#include <guichan/focushandler.hpp>
@@ -863,6 +864,7 @@ void Game::handleActive(const SDL_Event &event)
fpsLimit = config.getIntValue("fpslimit");
if (player_node)
player_node->setHalfAway(false);
+ setPriority(true);
}
else
{ // window minimisation
@@ -875,6 +877,7 @@ void Game::handleActive(const SDL_Event &event)
fpsLimit = config.getIntValue("altfpslimit");
player_node->setHalfAway(true);
}
+ setPriority(false);
#endif
}
if (player_node)
diff --git a/src/main.cpp b/src/main.cpp
index 0266dde21..a7817d31a 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -33,6 +33,7 @@
#include "utils/mkdir.h"
#endif
#include "utils/paths.h"
+#include "utils/process.h"
#include "utils/physfstools.h"
#include "utils/xml.h"
@@ -264,6 +265,7 @@ int main(int argc, char *argv[])
#ifdef WIN32
SetCurrentDirectory(PhysFs::getBaseDir());
#endif
+ setPriority(true);
Client client(options);
if (!options.testMode)
{
diff --git a/src/utils/process.cpp b/src/utils/process.cpp
index b424b42e3..1efd850cc 100644
--- a/src/utils/process.cpp
+++ b/src/utils/process.cpp
@@ -257,3 +257,18 @@ bool openBrowser(std::string url)
}
#endif
+
+#ifdef WIN32
+void setPriority(const bool big)
+{
+ HANDLE hCurrentProcess = GetCurrentProcess();
+ if (big)
+ SetPriorityClass(hCurrentProcess, ABOVE_NORMAL_PRIORITY_CLASS);
+ else
+ SetPriorityClass(hCurrentProcess, BELOW_NORMAL_PRIORITY_CLASS);
+}
+#else
+void setPriority(const bool big A_UNUSED)
+{
+}
+#endif
diff --git a/src/utils/process.h b/src/utils/process.h
index 6b34fd22d..95c868372 100644
--- a/src/utils/process.h
+++ b/src/utils/process.h
@@ -31,4 +31,6 @@ bool execFile(std::string pathName, std::string name,
bool openBrowser(std::string url);
+void setPriority(const bool big);
+
#endif // UTILS_PROCESS_H