summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2007-01-05 09:51:59 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2007-01-05 09:51:59 +0000
commitc14e8075938da01140ac307b66b69f749be133d6 (patch)
treef71f0533e5d4055b85ebec69e82c50e434305f28 /src
parent7465e9bf8fe03961c02b360002439c1072090bf0 (diff)
downloadmanaserv-c14e8075938da01140ac307b66b69f749be133d6.tar.gz
manaserv-c14e8075938da01140ac307b66b69f749be133d6.tar.bz2
manaserv-c14e8075938da01140ac307b66b69f749be133d6.tar.xz
manaserv-c14e8075938da01140ac307b66b69f749be133d6.zip
Removed log level argument from LOG_FATAL helper macro, with the assumption
that fatal messages should always have highest log level.
Diffstat (limited to 'src')
-rw-r--r--src/account-server/main-account.cpp4
-rw-r--r--src/account-server/serverhandler.cpp13
-rw-r--r--src/game-server/main-game.cpp44
-rw-r--r--src/utils/logger.h4
4 files changed, 34 insertions, 31 deletions
diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp
index 87fe68b8..1d83020b 100644
--- a/src/account-server/main-account.cpp
+++ b/src/account-server/main-account.cpp
@@ -147,7 +147,7 @@ void initialize()
// --- Initialize enet.
if (enet_initialize() != 0) {
- LOG_FATAL("An error occurred while initializing ENet", 0);
+ LOG_FATAL("An error occurred while initializing ENet");
exit(2);
}
@@ -277,7 +277,7 @@ int main(int argc, char *argv[])
if (!accountHandler->startListen(port) ||
!serverHandler->startListen(port + 1) ||
!chatHandler->startListen(port + 2)) {
- LOG_ERROR("Unable to create an ENet server host.", 0);
+ LOG_FATAL("Unable to create an ENet server host.");
return 3;
}
diff --git a/src/account-server/serverhandler.cpp b/src/account-server/serverhandler.cpp
index b7e51bce..572492e7 100644
--- a/src/account-server/serverhandler.cpp
+++ b/src/account-server/serverhandler.cpp
@@ -60,7 +60,8 @@ void ServerHandler::computerDisconnected(NetComputer *comp)
delete comp;
}
-bool ServerHandler::getGameServerFromMap(unsigned mapId, std::string &address, short &port)
+bool ServerHandler::getGameServerFromMap(unsigned mapId, std::string &address,
+ short &port)
{
Servers::const_iterator i = servers.find(mapId);
if (i == servers.end()) return false;
@@ -97,7 +98,7 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
LOG_INFO("Game server " << address << ':' << port
<< " wants to register " << (msg.getUnreadLength() / 2)
<< " maps.", 0);
-
+
while (msg.getUnreadLength())
{
int id = msg.readShort();
@@ -135,7 +136,8 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
PlayerPtr ptr = store.getCharacter(id);
std::string address;
short port;
- if (serverHandler->getGameServerFromMap(ptr->getMap(), address, port))
+ if (serverHandler->getGameServerFromMap(ptr->getMap(), address,
+ port))
{
registerGameClient(magic_token, ptr);
result.writeShort(AGMSG_REDIRECT_RESPONSE);
@@ -146,12 +148,13 @@ void ServerHandler::processMessage(NetComputer *comp, MessageIn &msg)
}
else
{
- LOG_ERROR("Server Change: No game server for the map.", 0);
+ LOG_ERROR("Server Change: No game server for map " <<
+ ptr->getMap() << ".", 0);
}
} break;
default:
- LOG_WARN("Invalid message type.", 0);
+ LOG_WARN("Invalid message type: " << msg.getId(), 0);
result.writeShort(XXMSG_INVALID);
break;
}
diff --git a/src/game-server/main-game.cpp b/src/game-server/main-game.cpp
index 7ebbc292..62a0c0e1 100644
--- a/src/game-server/main-game.cpp
+++ b/src/game-server/main-game.cpp
@@ -102,13 +102,9 @@ State *gameState;
*/
void initialize()
{
-
// Reset to default segmentation fault handling for debugging purposes
signal(SIGSEGV, SIG_DFL);
- // Set enet to quit on exit.
- atexit(enet_deinitialize);
-
/*
* If the path values aren't defined, we set the default
* depending on the platform.
@@ -150,12 +146,12 @@ void initialize()
using namespace utils;
Logger::instance().setLogFile(logPath);
- // write the messages to both the screen and the log file.
+ // Write the messages to both the screen and the log file.
Logger::instance().setTeeMode(true);
config.init(configPath);
- LOG_INFO("Using Config File: " << configPath, 0);
- LOG_INFO("Using Log File: " << logPath, 0);
+ LOG_INFO("Using config file: " << configPath, 0);
+ LOG_INFO("Using log file: " << logPath, 0);
// --- Initialize the managers
// Initialize the slang's and double quotes filter.
@@ -173,13 +169,16 @@ void initialize()
// --- Initialize enet.
if (enet_initialize() != 0) {
- LOG_FATAL("An error occurred while initializing ENet", 0);
+ LOG_FATAL("An error occurred while initializing ENet");
exit(2);
}
+ // Set enet to quit on exit.
+ atexit(enet_deinitialize);
+
// --- Initialize scripting subsystem.
#ifdef RUBY_SUPPORT
- LOG_INFO("Script Language: " << scriptLanguage, 0);
+ LOG_INFO("Script language: " << scriptLanguage, 0);
// Initialize ruby
ruby_init();
@@ -193,7 +192,7 @@ void initialize()
rb_load_file("scripts/init.rb");
rubyStatus = ruby_exec();
#else
- LOG_WARN("No Scripting Language Support.", 0);
+ LOG_WARN("No scripting language support.", 0);
#endif
}
@@ -203,16 +202,12 @@ void initialize()
*/
void deinitialize()
{
- delete stringFilter;
// Write configuration file
config.write();
// Stop world timer
worldTimer.stop();
- // Quit ENet
- enet_deinitialize();
-
#ifdef RUBY_SUPPORT
// Finish up ruby
ruby_finalize();
@@ -224,6 +219,7 @@ void deinitialize()
delete accountHandler;
// Destroy Managers
+ delete stringFilter;
delete itemManager;
delete mapManager;
@@ -276,14 +272,14 @@ void parseOptions(int argc, char *argv[])
unsigned short verbosityLevel;
verbosityLevel = atoi(optarg);
utils::Logger::instance().setVerbosity(verbosityLevel);
- LOG_INFO("Setting Log Verbosity Level to " << verbosityLevel, 0);
+ LOG_INFO("Setting log verbosity level to " << verbosityLevel, 0);
break;
case 'p':
// Change the port to listen on.
unsigned short portToListenOn;
portToListenOn = atoi(optarg);
config.setValue("gameServerPort", portToListenOn);
- LOG_INFO("Setting Default Port to " << portToListenOn, 0);
+ LOG_INFO("Setting default port to " << portToListenOn, 0);
break;
}
}
@@ -299,19 +295,23 @@ int main(int argc, char *argv[])
LOG_INFO("The Mana World Server v" << PACKAGE_VERSION, 0);
- // Parse Command Line Options
+ // Parse command line options
parseOptions(argc, argv);
- // General Initialization
+ // General initialization
initialize();
if (!accountHandler->start()) {
- LOG_ERROR("Unable to create a connection to an account server.", 0);
+ LOG_FATAL("Unable to create a connection to an account server.");
return 3;
}
- if (!gameHandler->startListen(int(config.getValue("gameServerPort", DEFAULT_SERVER_PORT + 3)))) {
- LOG_ERROR("Unable to create an ENet server host.", 0);
+ int gameServerPort =
+ (int) config.getValue("gameServerPort", DEFAULT_SERVER_PORT + 3);
+
+ if (!gameHandler->startListen(gameServerPort))
+ {
+ LOG_FATAL("Unable to create an ENet server host.");
return 3;
}
@@ -329,7 +329,7 @@ int main(int argc, char *argv[])
if (elapsedWorldTicks > 1)
{
LOG_WARN(elapsedWorldTicks -1 << " World Tick(s) skipped "
- "because of insufficient time. please buy a faster "
+ "because of insufficient time. Please buy a faster "
"machine ;-)", 0);
};
diff --git a/src/utils/logger.h b/src/utils/logger.h
index 6ce97a71..2eeaded8 100644
--- a/src/utils/logger.h
+++ b/src/utils/logger.h
@@ -313,11 +313,11 @@ class Logger: public Singleton<Logger>
::utils::Logger::instance().error(os.str(), atVerbosity); \
} while (0)
-#define LOG_FATAL(msg, atVerbosity) \
+#define LOG_FATAL(msg) \
do { \
std::ostringstream os; \
os << msg; \
- ::utils::Logger::instance().fatal(os.str(), atVerbosity); \
+ ::utils::Logger::instance().fatal(os.str(), 0); \
} while (0)
#endif // _TMWSERV_LOGGER_H_