summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-12-29 00:27:32 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-12-29 00:27:32 +0000
commite62b02bdb5fcb7498f002dfea9b5869bfe763b18 (patch)
treeb5f1405e395bb4089341197c761edd991ea33840
parent30c26cc0e1c09c579fb8575e4d4bafd418e1463e (diff)
downloadmanaserv-e62b02bdb5fcb7498f002dfea9b5869bfe763b18.tar.gz
manaserv-e62b02bdb5fcb7498f002dfea9b5869bfe763b18.tar.bz2
manaserv-e62b02bdb5fcb7498f002dfea9b5869bfe763b18.tar.xz
manaserv-e62b02bdb5fcb7498f002dfea9b5869bfe763b18.zip
Applied patch by r0nny that makes main.cpp a bit nicer.
-rw-r--r--ChangeLog2
-rw-r--r--src/main.cpp33
2 files changed, 22 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 9253d68e..c4952ad3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,8 @@
* makeclient.sh, src/Makefile.am: Integrated the building of tmwclient
with the default make command, as contributed by r0nny.
+ * src/main.cpp: Applied patch by r0nny that makes main.cpp a bit
+ nicer.
2005-12-27 Yohann Ferreira <bertram@cegetel.net>
diff --git a/src/main.cpp b/src/main.cpp
index 46a87b9b..48191e83 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -82,16 +82,16 @@ Skill skillTree("base"); /**< Skill tree */
Configuration config; /**< XML config reader */
/** Account message handler */
-AccountHandler *accountHandler = new AccountHandler();
+AccountHandler *accountHandler;
/** Communications (chat) message handler */
-ChatHandler *chatHandler = new ChatHandler();
+ChatHandler *chatHandler;
/** Core game message handler */
-GameHandler *gameHandler = new GameHandler();
+GameHandler *gameHandler;
/** Primary connection handler */
-ConnectionHandler *connectionHandler = new ConnectionHandler();
+ConnectionHandler *connectionHandler;
/**
* SDL timer callback, sends a <code>TMW_WORLD_TICK</code> event.
@@ -121,7 +121,15 @@ void initialize()
// write the messages to both the screen and the log file.
Logger::instance().setTeeMode(true);
- // initialize SDL.
+ // Initialize the global handlers
+ // FIXME: Make the global handlers global vars or part of a bigger
+ // singleton or a local vatiable in the event-loop
+ accountHandler = new AccountHandler();
+ chatHandler = new ChatHandler();
+ gameHandler = new GameHandler();
+ connectionHandler = new ConnectionHandler();
+
+ // Initialize SDL
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) == -1) {
LOG_FATAL("SDL_Init: " << SDL_GetError(), 0)
exit(1);
@@ -168,7 +176,6 @@ void initialize()
LOG_WARN("No Database Backend Support.", 0)
#endif
- // initialize configuration
// initialize configuration defaults
config.setValue("dbuser", "");
config.setValue("dbpass", "");
@@ -232,11 +239,10 @@ void deinitialize()
*/
void printHelp()
{
- std::cout << "tmwserv" << std::endl << std::endl;
- std::cout << "Options: " << std::endl;
- std::cout << " -h --help : Display this help" << std::endl;
- std::cout << " --verbosity n : Set the verbosity level" << std::endl;
- deinitialize();
+ std::cout << "tmwserv" << std::endl << std::endl
+ << "Options: " << std::endl
+ << " -h --help : Display this help" << std::endl
+ << " --verbosity <n> : Set the verbosity level" << std::endl;
exit(0);
}
@@ -285,12 +291,13 @@ int main(int argc, char *argv[])
#ifdef __USE_UNIX98
LOG_INFO("The Mana World Server v" << PACKAGE_VERSION, 0)
#endif
- // General Initialization
- initialize();
// Parse Command Line Options
parseOptions(argc, argv);
+ // General Initialization
+ initialize();
+
// Ready for server work...
std::auto_ptr<NetSession> session(new NetSession());