summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2005-12-29 21:33:44 +0000
committerYohann Ferreira <bertram@cegetel.net>2005-12-29 21:33:44 +0000
commitf408b59ad69cd9877fd1a657109255545f677e37 (patch)
tree2dc5e2174d30e6a001149fc84b94ea089756cb52
parent49e964aeacd761aa3da03ff542a38ae3966aed43 (diff)
downloadmanaserv-f408b59ad69cd9877fd1a657109255545f677e37.tar.gz
manaserv-f408b59ad69cd9877fd1a657109255545f677e37.tar.bz2
manaserv-f408b59ad69cd9877fd1a657109255545f677e37.tar.xz
manaserv-f408b59ad69cd9877fd1a657109255545f677e37.zip
Adding changes thought by Elven and an option for setting the port to listen on at startup.
-rw-r--r--ChangeLog212
-rw-r--r--src/chathandler.cpp10
-rw-r--r--src/connectionhandler.cpp4
-rw-r--r--src/defines.h5
-rw-r--r--src/main.cpp43
5 files changed, 150 insertions, 124 deletions
diff --git a/ChangeLog b/ChangeLog
index 35e1adab..72912d47 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2005-12-29 Bjørn Lindeijer <bjorn@lindeijer.nl>
+ * src/main.cpp, src/connectionhandler.cpp, src/defines.h,
+ src/chathandler.cpp: Adding changes thought by Elven and an option for
+ setting the port to listen on at startup.
+
+2005-12-29 Bjørn Lindeijer <bjorn@lindeijer.nl>
+
* configure.ac: Added errors when SDL_net or libcrypto are not found.
* src/main.cpp: Reset SEGV signal handling after SDL initialisation to
allow cores to be dumped.
@@ -21,14 +27,14 @@
2005-12-27 Yohann Ferreira <bertram@cegetel.net>
- * src/chathandler.h, src/chathandler.cpp, src/defines.h,
- src/utils/slangsfilter.h, src/utils/slangsfilter.cpp,
- src/Makefile.am, src/main.cpp, src/accounthandler.cpp,
- src/connectionhandler.h, src/connectionhandler.cpp: Implemented
- common chat handling, except for chatting in channels. Also the
- Channel registering/unregistering isn't there yet and the commands
- needs to be implemented. Added a small slangs filter to reduce bad
- words in account names and in conversations a little.
+ * src/chathandler.h, src/chathandler.cpp, src/defines.h,
+ src/utils/slangsfilter.h, src/utils/slangsfilter.cpp,
+ src/Makefile.am, src/main.cpp, src/accounthandler.cpp,
+ src/connectionhandler.h, src/connectionhandler.cpp: Implemented
+ common chat handling, except for chatting in channels. Also the
+ Channel registering/unregistering isn't there yet and the commands
+ needs to be implemented. Added a small slangs filter to reduce bad
+ words in account names and in conversations a little.
2005-12-26 Bjørn Lindeijer <bjorn@lindeijer.nl>
@@ -38,13 +44,13 @@
2005-12-20 Yohann Ferreira <bertram@cegetel.net>
- * src/Makefile.am: Adding the MapManager to files list.
- * src/utils/logger.cpp, src/utils/logger.h, src/main.cpp,
- src/configuration.cpp, src/connectionhandler.cpp,
- src/mapmanager.cpp, src/mapreader.cpp, src/messagehandler.cpp,
- src/skill.cpp, src/resourcemanager.cpp, src/dalstorage.cpp,
- src/accounthandler.cpp: Adding command line argument parsing and
- log verbosity level handling.
+ * src/Makefile.am: Adding the MapManager to files list.
+ * src/utils/logger.cpp, src/utils/logger.h, src/main.cpp,
+ src/configuration.cpp, src/connectionhandler.cpp,
+ src/mapmanager.cpp, src/mapreader.cpp, src/messagehandler.cpp,
+ src/skill.cpp, src/resourcemanager.cpp, src/dalstorage.cpp,
+ src/accounthandler.cpp: Adding command line argument parsing and
+ log verbosity level handling.
2005-12-18 Eugenio Favalli <elvenprogrammer@gmail.com>
@@ -54,117 +60,117 @@
2005-12-18 Yohann Ferreira <bertram@cegetel.net>
- * src/accounthandler.cpp, src/netcomputer.h, src/netcomputer.cpp,
- src/chathandler.cpp, src/connectionhandler.cpp,
- src/gamehandler.cpp, src/connectionhandler.h, src/state.h,
- src/state.cpp: Made the handlers use the countedPtr for Beings
- as they should. Fixed a segfault when removing a being from the
- world. Also made use of AccountPtr instead of Account* to fix a
- not seen but yet present account reselection segfault bug.
+ * src/accounthandler.cpp, src/netcomputer.h, src/netcomputer.cpp,
+ src/chathandler.cpp, src/connectionhandler.cpp,
+ src/gamehandler.cpp, src/connectionhandler.h, src/state.h,
+ src/state.cpp: Made the handlers use the countedPtr for Beings
+ as they should. Fixed a segfault when removing a being from the
+ world. Also made use of AccountPtr instead of Account* to fix a
+ not seen but yet present account reselection segfault bug.
2005-12-17 Bjorn Steinbrink <B.Steinbrink@gmx.de>
- * src/messageout.h: Fixed some 64bit issue.
+ * src/messageout.h: Fixed some 64bit issue.
2005-12-12 Yohann Ferreira <bertram@cegetel.net>
- * src/accounthandler.cpp, src/netcomputer.h,
- src/netcomputer.cpp, src/defines.h, src/dalstorage.cpp,
- src/dalstorage.h, src/storage.h, src/client.cpp, src/main.cpp:
- Now beings are handled in netcomputer when added and removed
- from the world. addBeing() and removeBeing() are still crashy.
- Added check if the character's name already exists. Forgot about
- that. Added CMSG_CHAR_LIST packet support.
+ * src/accounthandler.cpp, src/netcomputer.h,
+ src/netcomputer.cpp, src/defines.h, src/dalstorage.cpp,
+ src/dalstorage.h, src/storage.h, src/client.cpp, src/main.cpp:
+ Now beings are handled in netcomputer when added and removed
+ from the world. addBeing() and removeBeing() are still crashy.
+ Added check if the character's name already exists. Forgot about
+ that. Added CMSG_CHAR_LIST packet support.
2005-12-11 Yohann Ferreira <bertram@cegetel.net>
- * src/accounthandler.cpp, src/main.cpp, src/account.h,
- src/account.cpp, src/dalstorage.cpp, src/client.cpp,
- src/defines.h: Added Logout, and character deletion support.
- Also changed the response code when trying to login when already
- logged.
- * src/accounthandler.cpp, src/main.cpp, src/dalstorage.cpp,
- src/client.cpp, src/connectionhandler.cpp, src/defines.h:
- Added unregistering, checking on character's name and email
- length support. Also made some little tweaks.
+ * src/accounthandler.cpp, src/main.cpp, src/account.h,
+ src/account.cpp, src/dalstorage.cpp, src/client.cpp,
+ src/defines.h: Added Logout, and character deletion support.
+ Also changed the response code when trying to login when already
+ logged.
+ * src/accounthandler.cpp, src/main.cpp, src/dalstorage.cpp,
+ src/client.cpp, src/connectionhandler.cpp, src/defines.h:
+ Added unregistering, checking on character's name and email
+ length support. Also made some little tweaks.
2005-12-10 Yohann Ferreira <bertram@cegetel.net>
- * src/dalstorage.cpp: Fixed the buggy part of getAccount()
- where the mapInfo() recordSet erased the value of charInfo.
- Now, characters can be created and selected, with the map
- they were in, set.
+ * src/dalstorage.cpp: Fixed the buggy part of getAccount()
+ where the mapInfo() recordSet erased the value of charInfo.
+ Now, characters can be created and selected, with the map
+ they were in, set.
2005-12-09 Yohann Ferreira <bertram@cegetel.net>
- * src/dalstorage.cpp, src/accounthandler.cpp: Temporary
- made a workaround the character misloading at login.
- Work is to be made to see why the mapInfo recordset is
- buggy. Also made the server more verbose about characters.
+ * src/dalstorage.cpp, src/accounthandler.cpp: Temporary
+ made a workaround the character misloading at login.
+ Work is to be made to see why the mapInfo recordset is
+ buggy. Also made the server more verbose about characters.
2005-12-08 Yohann Ferreira <bertram@cegetel.net>
- * src/dalstorage.cpp, src/dalstorage.h, src/storage.h:
- Radically improve the getEmailList() again based on
- MrLindeijer's good idea.
- * src/accounthandler.cpp: Simplify the code of Email check
- based on the previous improvement.
+ * src/dalstorage.cpp, src/dalstorage.h, src/storage.h:
+ Radically improve the getEmailList() again based on
+ MrLindeijer's good idea.
+ * src/accounthandler.cpp: Simplify the code of Email check
+ based on the previous improvement.
2005-12-06 Yohann Ferreira <bertram@cegetel.net>
- * src/dalstorage.cpp: Improved the getEmailList() function.
- Now the file used as db or the db name is shown in log.
- * src/defines.h: Added some missing messages and values for
- them. Login, pass min, max length can be changed there now.
- * src/accounthandler.cpp: Added check and appropriate response
- when selecting, creating a character.
+ * src/dalstorage.cpp: Improved the getEmailList() function.
+ Now the file used as db or the db name is shown in log.
+ * src/defines.h: Added some missing messages and values for
+ them. Login, pass min, max length can be changed there now.
+ * src/accounthandler.cpp: Added check and appropriate response
+ when selecting, creating a character.
2005-12-05 Yohann Ferreira <bertram@cegetel.net>
- * src/dalstorage.cpp: Added a working getEmailList() function.
- * src/accounthandler: Now tests if email already exists.
- * src/accounthandler.cpp, src/defines.h: Strengthens the way
- email addresses checked. Added good response for selecting
- a char when not logged.
- * src/storage.h, src/dalstorage.h, src/dalstorage.cpp: Added
- the getEmailList function, doesn't seem to work, but committed
- to see why.
+ * src/dalstorage.cpp: Added a working getEmailList() function.
+ * src/accounthandler: Now tests if email already exists.
+ * src/accounthandler.cpp, src/defines.h: Strengthens the way
+ email addresses checked. Added good response for selecting
+ a char when not logged.
+ * src/storage.h, src/dalstorage.h, src/dalstorage.cpp: Added
+ the getEmailList function, doesn't seem to work, but committed
+ to see why.
2005-12-03 Yohann Ferreira <bertram@cegetel.net>
- * src/accounthandler.cpp: Handling good conditions to register.
- Still lacks checking if the Email already exists.
- * src/dalstorage.cpp: Fixed a bug that throwed an exception when
- logging with an account that had no mapInfo yet.
- Still has to set these to defaults in such case.
+ * src/accounthandler.cpp: Handling good conditions to register.
+ Still lacks checking if the Email already exists.
+ * src/dalstorage.cpp: Fixed a bug that throwed an exception when
+ logging with an account that had no mapInfo yet.
+ Still has to set these to defaults in such case.
2005-12-02 Yohann Ferreira <bertram@cegetel.net>
- * src/main.cpp, src/accounthandler.h, src/accounthandler.cpp,
- src/configuration.h: Made the accounthandler reopen the db for
- SQLite to enable registering ! Now working.
+ * src/main.cpp, src/accounthandler.h, src/accounthandler.cpp,
+ src/configuration.h: Made the accounthandler reopen the db for
+ SQLite to enable registering ! Now working.
2005-11-21 Aaron Marks <nymacro@gmail.com>
- * src/state.cpp: Re-ordered a few statements to work better.
- * src/dalstorage.cpp: Now sets being's current map when getting a
- player's account.
+ * src/state.cpp: Re-ordered a few statements to work better.
+ * src/dalstorage.cpp: Now sets being's current map when getting a
+ player's account.
2005-11-16 Aaron Marks <nymacro@gmail.com>
- * src/state.h, src/state.cpp: Updated world related functions.
- * src/accounthandler.cpp: Now adds players who have selected a
- character to the game world.
- * src/object.h: Updated to include member variable for current map
- the object is located.
+ * src/state.h, src/state.cpp: Updated world related functions.
+ * src/accounthandler.cpp: Now adds players who have selected a
+ character to the game world.
+ * src/object.h: Updated to include member variable for current map
+ the object is located.
2005-11-15 Aaron Marks <nymacro@gmail.com>
- * src/state.h, src/state.cpp: Updated world representation, added
- various methods which provide easy access to the game world.
- * src/defines.h: Added "private message" message.
- * src/client.cpp, scripts/init.rb: Added experimental remote access
- to Ruby's functionality.
+ * src/state.h, src/state.cpp: Updated world representation, added
+ various methods which provide easy access to the game world.
+ * src/defines.h: Added "private message" message.
+ * src/client.cpp, scripts/init.rb: Added experimental remote access
+ to Ruby's functionality.
2005-11-14 Aaron Marks <nymacro@gmail.com>
@@ -173,25 +179,25 @@
2005-11-12 Aaron Marks <nymacro@gmail.com>
- * src/main.cpp: Added scripting with Ruby support
- * src/bindings.i: Created basic SWIG bindings.
- * src/Makefile.am: Updated to support Ruby & generate SWIG
- bindings.
- * configure.ac: Updated to detect SWIG & Ruby, using them
- appropriately.
- * scripts/init.rb: Server initialization test script.
+ * src/main.cpp: Added scripting with Ruby support
+ * src/bindings.i: Created basic SWIG bindings.
+ * src/Makefile.am: Updated to support Ruby & generate SWIG
+ bindings.
+ * configure.ac: Updated to detect SWIG & Ruby, using them
+ appropriately.
+ * scripts/init.rb: Server initialization test script.
2005-11-10 Aaron Marks <nymacro@gmail.com>
- * src/client.cpp: Updated client to support moving and equipping.
- * src/being.h, src/being.cpp: Added "hasItem"
- * src/state.cpp: Added beings updating.
+ * src/client.cpp: Updated client to support moving and equipping.
+ * src/being.h, src/being.cpp: Added "hasItem"
+ * src/state.cpp: Added beings updating.
2005-10-24 Yohann Ferreira <Bertram@cegetel.net>
- * src/main.cpp: Added more useful infos at startup.
- * src/dal/dataprovider.h, src/dal/dataprovider.cpp,
- src/dal/sqlitedataprovider.cpp, src/dal/mysqldataprovider.cpp,
- src/dal/pqdataprovider.cpp, src/main.cpp, src/client.cpp:
- Grammar corrections, and a little bit of work on getting the name
- of the Db.
+ * src/main.cpp: Added more useful infos at startup.
+ * src/dal/dataprovider.h, src/dal/dataprovider.cpp,
+ src/dal/sqlitedataprovider.cpp, src/dal/mysqldataprovider.cpp,
+ src/dal/pqdataprovider.cpp, src/main.cpp, src/client.cpp:
+ Grammar corrections, and a little bit of work on getting the name
+ of the Db.
diff --git a/src/chathandler.cpp b/src/chathandler.cpp
index 73906275..3e5f6010 100644
--- a/src/chathandler.cpp
+++ b/src/chathandler.cpp
@@ -140,8 +140,7 @@ void ChatHandler::handleCommand(NetComputer &computer, std::string command)
LOG_INFO("Chat: Recieved unhandled command: " << command, 2)
MessageOut result;
result.writeShort(SMSG_CHAT);
- result.writeShort(0); // The Channel
- result.writeString("SERVER: Unknown or unhandled command.");
+ result.writeByte(CHATCMD_UNHANDLED_COMMAND);
computer.send(result.getPacket());
}
@@ -150,8 +149,7 @@ void ChatHandler::warnPlayerAboutBadWords(NetComputer &computer)
// We could later count if the player is really often unpolite.
MessageOut result;
result.writeShort(SMSG_CHAT);
- result.writeShort(0); // The Channel
- result.writeString("SERVER: Take care not to use bad words when you speak...");
+ result.writeByte(CHAT_USING_BAD_WORDS); // The Channel
computer.send(result.getPacket());
LOG_INFO(computer.getCharacter()->getName() << " says bad words.", 2)
@@ -171,8 +169,8 @@ void ChatHandler::announce(NetComputer &computer, std::string text)
}
else
{
- result.writeShort(SMSG_SYSTEM);
- result.writeString("Cannot make announcements. You have not enough rights.");
+ result.writeShort(SMSG_CHAT);
+ result.writeByte(CHATCMD_UNSUFFICIENT_RIGHTS);
computer.send(result.getPacket());
LOG_INFO(computer.getCharacter()->getName() <<
" couldn't make an announcement due to insufficient rights.", 2)
diff --git a/src/connectionhandler.cpp b/src/connectionhandler.cpp
index b8172fe0..3009ae56 100644
--- a/src/connectionhandler.cpp
+++ b/src/connectionhandler.cpp
@@ -122,7 +122,7 @@ ConnectionHandler::startListen(ListenThreadData *ltd)
perror("SDLNet_CheckSockets");
}
else if (numready > 0) {
- LOG_INFO(numready << " sockets with activity!", 0)
+ LOG_INFO(numready << " socket(s) with activity!", 0)
// Check server socket
if (SDLNet_SocketReady(ltd->socket)) {
@@ -295,5 +295,3 @@ void ConnectionHandler::sendAround(tmwserv::BeingPtr beingPtr, MessageOut &msg)
}
}
}
-
-
diff --git a/src/defines.h b/src/defines.h
index f1b27a27..8bc7218c 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -230,7 +230,10 @@ enum {
enum {
// CHAT_OK = 0,
CHAT_NOLOGIN = 1,
- CHAT_NO_CHARACTER_SELECTED
+ CHAT_NO_CHARACTER_SELECTED,
+ CHAT_USING_BAD_WORDS,
+ CHATCMD_UNHANDLED_COMMAND,
+ CHATCMD_UNSUFFICIENT_RIGHTS
};
// Object type enumeration
diff --git a/src/main.cpp b/src/main.cpp
index d1e26e04..766ca33c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -68,11 +68,18 @@ std::string scriptLanguage = "lua";
std::string scriptLanugage = "none";
#endif // SCRIPT_SUPPORT
+// Default options that automake should be able to override.
+#ifndef LOG_FILE
#define LOG_FILE "tmwserv.log"
+#endif
+#ifndef CONFIG_FILE
+#define CONFIG_FILE "tmwserv.xml"
+#endif
+#ifndef DEFAULT_SERVER_PORT
+#define DEFAULT_SERVER_PORT 9601
+#endif
#define TMW_WORLD_TICK SDL_USEREVENT
-#define SERVER_PORT 9601
-
SDL_TimerID worldTimerID; /**< Timer ID of world timer */
int worldTime = 0; /**< Current world time in 100ms ticks */
@@ -187,15 +194,20 @@ void initialize()
config.setValue("dbpass", "");
config.setValue("dbhost", "");
-#ifdef WIN32
- std::string configPath = ".";
-#else
+#ifdef __USE_UNIX98
std::string configPath = getenv("HOME");
+ configPath += "/.";
+ configPath += CONFIG_FILE;
+ std::string logPath = getenv("HOME");
+ logPath += "/.";
+ logPath += LOG_FILE;
+#else
+ std::string configPath = CONFIG_FILE;
+ std::string logPath = LOG_FILE;
#endif
- configPath += "/.tmwserv.xml";
config.init(configPath);
LOG_INFO("Using Config File: " << configPath, 0)
- LOG_INFO("Using Log File: " << LOG_FILE, 0)
+ LOG_INFO("Using Log File: " << logPath, 0)
// Initialize PhysicsFS
PHYSFS_init("");
@@ -262,6 +274,7 @@ void parseOptions(int argc, char *argv[])
const struct option long_options[] = {
{ "help", no_argument, 0, 'h' },
{ "verbosity", required_argument, 0, 'v' },
+ { "port", required_argument, 0, 'p' },
0
};
@@ -280,10 +293,18 @@ void parseOptions(int argc, char *argv[])
break;
case 'v':
// Set Verbosity to level
- unsigned short verbosityLevel = atoi(optarg);
+ unsigned short verbosityLevel;
+ verbosityLevel = atoi(optarg);
tmwserv::utils::Logger::instance().setVerbosity(verbosityLevel);
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("ListenOnPort", portToListenOn);
+ LOG_INFO("Setting Default Port to " << portToListenOn, 0)
+ break;
}
}
}
@@ -335,8 +356,8 @@ int main(int argc, char *argv[])
connectionHandler->registerHandler(CMSG_REQ_TRADE, gameHandler);
connectionHandler->registerHandler(CMSG_EQUIP, gameHandler);
- session->startListen(connectionHandler, SERVER_PORT);
- LOG_INFO("Listening on port " << SERVER_PORT << "...", 0)
+ session->startListen(connectionHandler, int(config.getValue("ListenOnPort", DEFAULT_SERVER_PORT)));
+ LOG_INFO("Listening on port " << config.getValue("ListenOnPort", DEFAULT_SERVER_PORT) << "...", 0)
using namespace tmwserv;
@@ -380,7 +401,7 @@ int main(int argc, char *argv[])
}
LOG_INFO("Received: Quit signal, closing down...", 0)
- session->stopListen(SERVER_PORT);
+ session->stopListen(int(config.getValue("ListenOnPort", DEFAULT_SERVER_PORT)));
deinitialize();
}