diff options
author | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-09-22 00:02:05 +0200 |
---|---|---|
committer | Yohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer> | 2010-09-22 00:02:05 +0200 |
commit | 4b0892691729e5efba27c796e29002b1e1d54166 (patch) | |
tree | 80daf14e04fdb7dbc76a16759ed310fec20d5ce7 /src/account-server | |
parent | 4c0ba5cf58f09926f5b06ed0e91a5f7d6878c1f8 (diff) | |
download | manaserv-4b0892691729e5efba27c796e29002b1e1d54166.tar.gz manaserv-4b0892691729e5efba27c796e29002b1e1d54166.tar.bz2 manaserv-4b0892691729e5efba27c796e29002b1e1d54166.tar.xz manaserv-4b0892691729e5efba27c796e29002b1e1d54166.zip |
Centralized the servers' exit values.
Also made random code format clean-ups.
Resolves: Mana-Mantis #217
Reviewed-by: Jaxad0127.
Diffstat (limited to 'src/account-server')
-rw-r--r-- | src/account-server/accounthandler.cpp | 22 | ||||
-rw-r--r-- | src/account-server/main-account.cpp | 15 |
2 files changed, 19 insertions, 18 deletions
diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp index 28b92024..ab049dd5 100644 --- a/src/account-server/accounthandler.cpp +++ b/src/account-server/accounthandler.cpp @@ -138,7 +138,7 @@ AccountHandler::AccountHandler(const std::string &attrFile): if (absPathFile.empty()) { LOG_FATAL("Account handler: Could not find " << attrFile << "!"); - exit(3); + exit(EXIT_XML_NOT_FOUND); } XML::Document doc(absPathFile, int()); @@ -147,7 +147,7 @@ AccountHandler::AccountHandler(const std::string &attrFile): { LOG_FATAL("Account handler: " << attrFile << ": " << " is not a valid database file!"); - exit(3); + exit(EXIT_XML_BAD_PARAMETER); } for_each_xml_child_node(attributenode, node) @@ -187,7 +187,7 @@ AccountHandler::AccountHandler(const std::string &attrFile): LOG_FATAL("Account handler: " << attrFile << ": " << " The characters starting points " << "are incomplete or not set!"); - exit(3); + exit(EXIT_XML_BAD_PARAMETER); } } } // End for each XML nodes @@ -197,7 +197,7 @@ AccountHandler::AccountHandler(const std::string &attrFile): { LOG_FATAL("Account handler: " << attrFile << ": " << "No modifiable attributes found!"); - exit(3); + exit(EXIT_XML_BAD_PARAMETER); } // Sanity checks on starting points. @@ -208,7 +208,7 @@ AccountHandler::AccountHandler(const std::string &attrFile): LOG_FATAL("Account handler: " << attrFile << ": " << "Character's point values make " << "the character's creation impossible!"); - exit(3); + exit(EXIT_XML_BAD_PARAMETER); } LOG_DEBUG("Character start points: " << startPoints << " (Min: " @@ -358,15 +358,15 @@ void AccountHandler::handleLoginMessage(AccountClient &client, MessageIn &msg) return; } - // The client successfully logged in + // The client successfully logged in... - // set lastLogin date of the account + // Set lastLogin date of the account. time_t login; time(&login); acc->setLastLogin(login); storage->updateLastLogin(acc); - // Associate account with connection + // Associate account with connection. client.setAccount(acc); client.status = CLIENT_CONNECTED; @@ -502,11 +502,11 @@ void AccountHandler::handleRegisterMessage(AccountClient &client, acc->setPassword(sha256(password)); // We hash email server-side for additional privacy // we ask for it again when we need it and verify it - // through comparing it with the hash + // through comparing it with the hash. acc->setEmail(sha256(email)); acc->setLevel(AL_PLAYER); - // set the date and time of the account registration, and the last login + // Set the date and time of the account registration, and the last login time_t regdate; time(®date); acc->setRegistrationDate(regdate); @@ -723,7 +723,7 @@ void AccountHandler::handleCharacterCreateMessage(AccountClient &client, return; } - // LATER_ON: Add race, face and maybe special attributes. + // TODO: Add race, face and maybe special attributes. // Customization of character's attributes... std::vector<int> attributes = std::vector<int>(initAttr.size(), 0); diff --git a/src/account-server/main-account.cpp b/src/account-server/main-account.cpp index 733369d7..0be05abe 100644 --- a/src/account-server/main-account.cpp +++ b/src/account-server/main-account.cpp @@ -39,6 +39,7 @@ #include "utils/processorutils.hpp" #include "utils/stringfilter.h" #include "utils/timer.h" +#include "defines.h" #include <cstdlib> #include <getopt.h> @@ -106,7 +107,7 @@ static void initializeConfiguration(std::string configPath = std::string()) { LOG_FATAL("Refusing to run without configuration!" << std::endl << "Invalid config path: " << configPath << "."); - exit(1); + exit(EXIT_CONFIG_NOT_FOUND); } } @@ -116,7 +117,7 @@ static void initializeConfiguration(std::string configPath = std::string()) if (Configuration::getValue("net_password", "") == "") { LOG_FATAL("SECURITY WARNING: 'net_password' not set!"); - exit(3); + exit(EXIT_BAD_CONFIG_PARAMETER); } } @@ -169,7 +170,7 @@ static void initialize() catch (std::string &error) { LOG_FATAL("Error opening the database: " << error); - exit(1); + exit(EXIT_DB_EXCEPTION); } // --- Initialize the managers @@ -188,7 +189,7 @@ static void initialize() if (enet_initialize() != 0) { LOG_FATAL("An error occurred while initializing ENet"); - exit(2); + exit(EXIT_NET_EXCEPTION); } // Initialize the processor utility functions @@ -257,7 +258,7 @@ static void printHelp() << " - 3. Plus standard information." << std::endl << " - 4. Plus debugging information." << std::endl << " --port <n> : Set the default port to listen on" << std::endl; - exit(0); + exit(EXIT_NORMAL); } struct CommandLineOptions @@ -365,7 +366,7 @@ int main(int argc, char *argv[]) !chatHandler->startListen(options.port + 2, host)) { LOG_FATAL("Unable to create an ENet server host."); - return 3; + return EXIT_NET_EXCEPTION; } // Dump statistics every 10 seconds. @@ -402,5 +403,5 @@ int main(int argc, char *argv[]) chatHandler->stopListen(); deinitializeServer(); - return 0; + return EXIT_NORMAL; } |