summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-08-23 21:49:42 +0300
committerAndrei Karas <akaras@inbox.ru>2013-08-24 21:08:16 +0300
commite8a4474319aca4a32869fa1ebb8b5ebbd98237f6 (patch)
tree889a347ac3fb3998566fe07d2c170ad5748aa1f3
parent1a59946dd91a9de55f114413a520bf36204222ff (diff)
downloadmanaplus-e8a4474319aca4a32869fa1ebb8b5ebbd98237f6.tar.gz
manaplus-e8a4474319aca4a32869fa1ebb8b5ebbd98237f6.tar.bz2
manaplus-e8a4474319aca4a32869fa1ebb8b5ebbd98237f6.tar.xz
manaplus-e8a4474319aca4a32869fa1ebb8b5ebbd98237f6.zip
save Client object into global variable.
-rw-r--r--src/client.cpp27
-rw-r--r--src/client.h6
-rw-r--r--src/game.cpp11
-rw-r--r--src/main.cpp14
4 files changed, 33 insertions, 25 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 2d1a2d82b..6cb9ac028 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -155,6 +155,7 @@ Configuration serverConfig; // XML file server configuration reader
Configuration features; // XML file features
Configuration branding; // XML branding information reader
Configuration paths; // XML default paths information reader
+Client *client = nullptr;
Logger *logger = nullptr; // Log object
ChatLogger *chatLogger = nullptr; // Chat log object
KeyboardConfig keyboard;
@@ -1000,16 +1001,7 @@ int Client::gameExec()
#ifdef USE_SDL2
case SDL_WINDOWEVENT:
{
- switch (event.window.event)
- {
- // +++ need add other window events
- case SDL_WINDOWEVENT_RESIZED:
- resizeVideo(event.window.data1,
- event.window.data2, false);
- break;
- default:
- break;
- }
+ handleSDL2WindowEvent(event);
break;
}
#else
@@ -3165,3 +3157,18 @@ void Client::setIcon()
}
#endif
}
+
+#ifdef USE_SDL2
+void Client::handleSDL2WindowEvent(const SDL_Event &event)
+{
+ switch (event.window.event)
+ {
+ // +++ need add other window events
+ case SDL_WINDOWEVENT_RESIZED:
+ resizeVideo(event.window.data1, event.window.data2, false);
+ break;
+ default:
+ break;
+ }
+}
+#endif
diff --git a/src/client.h b/src/client.h
index 938170610..a4d7a288c 100644
--- a/src/client.h
+++ b/src/client.h
@@ -317,6 +317,10 @@ public:
static void applyKeyRepeat();
+#ifdef USE_SDL2
+ void handleSDL2WindowEvent(const SDL_Event &event);
+#endif
+
void optionChanged(const std::string &name) override;
void action(const gcn::ActionEvent &event) override;
@@ -443,4 +447,6 @@ private:
bool mLogInput;
};
+extern Client *client;
+
#endif // CLIENT_H
diff --git a/src/game.cpp b/src/game.cpp
index f4dc97ed6..80408f836 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -972,16 +972,7 @@ void Game::handleInput()
#ifdef USE_SDL2
case SDL_WINDOWEVENT:
{
- switch (event.window.event)
- {
- // +++ need add other window events
- case SDL_WINDOWEVENT_RESIZED:
- Client::resize(event.window.data1,
- event.window.data2, false);
- break;
- default:
- break;
- }
+ client->handleSDL2WindowEvent(event);
break;
}
#else
diff --git a/src/main.cpp b/src/main.cpp
index 7bedd1b9d..f367d80fa 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -308,17 +308,21 @@ int main(int argc, char *argv[])
SetCurrentDirectory(PhysFs::getBaseDir());
#endif
setPriority(true);
- Client client(options);
+ client = new Client(options);
+ int ret = 0;
if (!options.testMode)
{
- client.gameInit();
- return client.gameExec();
+ client->gameInit();
+ ret = client->gameExec();
}
else
{
- client.testsInit();
- return client.testsExec();
+ client->testsInit();
+ ret = client->testsExec();
}
+ delete client;
+ client = nullptr;
+ return ret;
}
#else