From e62b02bdb5fcb7498f002dfea9b5869bfe763b18 Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Thu, 29 Dec 2005 00:27:32 +0000 Subject: Applied patch by r0nny that makes main.cpp a bit nicer. --- ChangeLog | 2 ++ src/main.cpp | 33 ++++++++++++++++++++------------- 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 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 TMW_WORLD_TICK 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 : 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 session(new NetSession()); -- cgit v1.2.3-60-g2f50