summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AUTHORS11
-rw-r--r--ChangeLog12
-rw-r--r--docs/tmwserv.xml22
-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
7 files changed, 73 insertions, 37 deletions
diff --git a/AUTHORS b/AUTHORS
index 32a1909c..6dafbd8f 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,3 +1,8 @@
-Bjorn 'Hammerbear' Lindeijer <b_lindeijer@users.sourceforge.net>
-Kiyoshi Kyokai <kyokai@users.sourceforge.net>
-Huynh Ngoc Chau Tran aka kindjal <nthuynh at users dot sourceforge dot net>
+Aaron Marks <nymacro@gmail.com>
+Bjørn Lindeijer <bjorn@lindeijer.nl>
+Björn Steinbrink <B.Steinbrink@gmx.de>
+Eugenio Favalli <elvenprogrammer@gmail.com>
+Guillaume Melquiond <guillaume.melquiond@gmail.com>
+Huynh Ngoc Chau Tran aka kindjal <nthuynh at users dot sourceforge dot net>
+Philipp Sehmisch <tmw@crushnet.org>
+Yohann Ferreira <Bertram@cegetel.net>
diff --git a/ChangeLog b/ChangeLog
index 1de5e2db..526cdce2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-01-05 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
+ * AUTHORS: Updated to include all current authors.
+ * src/account-server/main-account.cpp,
+ src/account-server/serverhandler.cpp, src/utils/logger.h,
+ src/game-server/main-game.cpp: Removed log level argument from
+ LOG_FATAL helper macro, with the assumption that fatal messages should
+ always have highest log level.
+ * docs/tmwserv.xml: Added some documentation to example config file.
+
2007-01-05 Guillaume Melquiond <guillaume.melquiond@gmail.com>
* src/game-server/player.cpp: Delayed update of persistent position.
@@ -175,7 +185,7 @@
src/accounthandler.h, src/accounthandler.cpp: Moved to
src/account-server directory and changed header extension to hpp.
* src/chathandler.h, src/chathandler.cpp, src/chatchannelmanager.h,
- src/chatchannel.cpp, src/chatchannel.h, src/chatchannelmanager.cpp:
+ src/chatchannel.cpp, src/chatchannel.h, src/chatchannelmanager.cpp:
Moved to src/chat-server directory and changed header extension to hpp.
* src/itemmanger.h, src/itemmanager.cpp, src/state.h, src/state.cpp,
src/gamehandler.h, src/gamehandler.cpp, src/gameclient.h,
diff --git a/docs/tmwserv.xml b/docs/tmwserv.xml
index 0fa6768b..a16b063c 100644
--- a/docs/tmwserv.xml
+++ b/docs/tmwserv.xml
@@ -1,12 +1,30 @@
<?xml version="1.0"?>
<!-- An example configuration file for ~/.tmwserv.xml -->
<configuration>
+ <!--
+ Database configuration (unused by sqlite3).
+ -->
<option name="dbhost" value=""/>
<option name="dbpass" value=""/>
<option name="dbuser" value=""/>
+
+ <!--
+ New player starting location. The map should be defined in data/maps.xml.
+ -->
<option name="defaultMap" value="1"/>
<option name="startX" value="720"/>
<option name="startY" value="840"/>
- <option name="clientGameServerAddress" value="localhost"/>
- <option name="clientChatServerAddress" value="localhost"/>
+
+ <!--
+ The game server uses this address to connect to the account server. Clients
+ will also need to be able to connect to the account server.
+ -->
+ <option name="accountServerAddress" value="localhost"/>
+ <option name="accountServerPort" value="9601"/>
+
+ <!--
+ The clients use this address to connect to a game server on this machine.
+ -->
+ <option name="gameServerAddress" value="localhost"/>
+ <option name="gameServerPort" value="9604"/>
</configuration>
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_