summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-03-23 10:59:50 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-03-23 10:59:50 +0000
commit4a606d557d1185f01f4b4944804fd24491605d2b (patch)
tree861dd84d78936ce530be5a9d83d0fd1f1674b54f
parent97024b3b51a3d9e2daf2832fe8598b38b6670cab (diff)
downloadmanaserv-4a606d557d1185f01f4b4944804fd24491605d2b.tar.gz
manaserv-4a606d557d1185f01f4b4944804fd24491605d2b.tar.bz2
manaserv-4a606d557d1185f01f4b4944804fd24491605d2b.tar.xz
manaserv-4a606d557d1185f01f4b4944804fd24491605d2b.zip
Corrections to syntax, includes, headers and comments. Updated architecture.txt
with a distributed approach.
-rw-r--r--docs/architecture.txt24
-rw-r--r--src/Makefile.am3
-rw-r--r--src/accounthandler.cpp16
-rw-r--r--src/accounthandler.h43
-rw-r--r--src/connectionhandler.h2
-rw-r--r--src/debug.cpp3
-rw-r--r--src/debug.h1
-rw-r--r--src/defines.h55
-rw-r--r--src/main.cpp9
-rw-r--r--src/netcomputer.h1
10 files changed, 96 insertions, 61 deletions
diff --git a/docs/architecture.txt b/docs/architecture.txt
index 7cd54d53..3886f083 100644
--- a/docs/architecture.txt
+++ b/docs/architecture.txt
@@ -64,7 +64,7 @@ melt togheter.
C - L - M
/ \
C M
-
+
The login server manages new connections and stores all the informations about
the player. The map server is pretty the same as the eAthena one. The login
server manages also connections to a new map server when changing map. Having
@@ -72,10 +72,9 @@ only one server (L) to manage all the connections between clients and map
servers is a bad point: if the login server crashes players won't be able to
play anymore. In fact new connecting players won't be able to connect to login
server, while map server will disconnect every player, since they can't save
-their infos.
-The solutions are:
+their infos. Some solutions are:
- - implementing a distributed login server which can manage crashes and
+ - Implementing a distributed login server which can manage crashes and
redirect new connections to another login server. This way means a more
complex implementation and probably the need to other computers since we
want the login servers to be independent from each other crashes at all.
@@ -95,10 +94,19 @@ The solutions are:
if some of the data was already stored before the crash, what if both of
them crash?
- - waiting it's the only solution! Let's design the login server as much
+ - Waiting it's the only solution! Let's design the login server as much
simple and stable as possible and create a smart restarting system.
This way we will have less frequent crashes and a very low restarting
- time. Obiouvlsy this is the easiest and less expensive solution.
+ time. Obviously this is the easiest and less expensive solution.
+
+ - Make the server completely distributed and replicating data to all of
+ them. This is the way Hammerbear would like to try.
+
+ C ----- S
+ / | \ C = client
+ C ---/ S | S = server (login, char, map, database)
+ | /
+ C ----- S
5. Network protocol: TCP
@@ -107,7 +115,7 @@ RO is TCP based, mainly because you use the mouse to move the player. When you
want to reach a point on the map, you click on it and the client send a packet
to the server with destination coordinates. The server replies with an
agreement if there's a path to that way. Using this way you don't need high
-speed nor a lot of packets, so TCP it's enough.
+speed nor a lot of packets, so TCP is enough.
With our custom server we want to achieve pixel movements, by that we mean that
the player is not always positioned in the center of the tile, but will have
@@ -219,4 +227,4 @@ Other ways to reduce bandwidth can be considered such as:
as well. RLE compression or more advanced statistical techniques can be
used. Compression can be disabled in very slow systems (If using
compression is declared to the server when the client connects to map
- server. \ No newline at end of file
+ server.
diff --git a/src/Makefile.am b/src/Makefile.am
index 5915f280..8aa36d07 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,9 +1,12 @@
bin_PROGRAMS = tmwserv
tmwserv_SOURCES = main.cpp \
+ accounthandler.h \
+ accounthandler.cpp \
connectionhandler.h \
connectionhandler.cpp \
debug.h \
debug.cpp \
+ defines.h \
messagehandler.h \
messagehandler.cpp \
messagein.h \
diff --git a/src/accounthandler.cpp b/src/accounthandler.cpp
index f4058bf7..7c3a92b1 100644
--- a/src/accounthandler.cpp
+++ b/src/accounthandler.cpp
@@ -18,12 +18,13 @@
* along with The Mana World; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- *
+ * $Id$
*/
+#include "accounthandler.h"
+#include "debug.h"
-
-/* ----Receive Message----
+/**
* Generic interface convention for getting a message and sending it to the
* correct subroutines. Account handler takes care of determining the
* current step in the account process, be it creation, setup, or login.
@@ -33,12 +34,14 @@ void AccountHandler::receiveMessage(NetComputer &computer, MessageIn &message)
int result = 0;
// determine message type
+ /*
switch(message.type)
{
case TYPE_LOGIN:
result = loginMessage(computer, message);
break;
}
+ */
debugCatch(result);
}
@@ -76,7 +79,7 @@ int AccountHandler::loginMessage(NetComputer &computer, MessageIn &message)
}
/* ----Account Assignment----
- * Assigns the computer to this accout, and allows it to make account
+ * Assigns the computer to this account, and allows it to make account
* changes using this structure.
* Preconditions: This structure already contains a valid accountHandle
* Postconditions: The player is connected to the account through this handle
@@ -84,7 +87,7 @@ int AccountHandler::loginMessage(NetComputer &computer, MessageIn &message)
* requested handle, ERROR on early termination of the
* routine.
*/
-int AccountHandler::accountAssign(NetComputer &computer, accountData *account)
+int AccountHandler::assignAccount(NetComputer &computer, AccountData *account)
{
// RETURN TMW_ACCOUNTERROR_ASSIGNFAILED if: the account was accessed before
// being initalized.
@@ -93,5 +96,4 @@ int AccountHandler::accountAssign(NetComputer &computer, accountData *account)
return TMW_SUCCESS;
-
-} \ No newline at end of file
+}
diff --git a/src/accounthandler.h b/src/accounthandler.h
index e27c4a81..56ef30cf 100644
--- a/src/accounthandler.h
+++ b/src/accounthandler.h
@@ -19,36 +19,43 @@
* along with The Mana World; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
- *
+ * $Id$
*/
-// INCLUDES
-#include "debug.h"
+#ifndef _TMW_SERVER_ACCOUNTHANDLER_
+#define _TMW_SERVER_ACCOUNTHANDLER_
+
#include "messagehandler.h"
-#include <string>
+#include "netcomputer.h"
+#include "messagein.h"
#include "defines.h"
-/* Account Handler Class
- *
+/**
* Manages the data stored in user accounts and provides a reliable interface
* for working with an account. The account handler class can be used as a link
* to a working account handle, and can be assigned to a user persistently as
* an interface between the computer and account. (Messages from the user can
* be traced to this account through the NetComputer structure, then processed
* here with the persistent stored data).
- *
*/
-
-class AccountHandler public: MessageHandler
+class AccountHandler : public MessageHandler
{
- public: // functions
- // generic message handling
+ public:
+ /**
+ * Receives account related messages.
+ */
void receiveMessage(NetComputer &computer, MessageIn &message);
- // message interpretation subroutine
+
+ private:
+ /**
+ * Handles the login message.
+ */
int loginMessage(NetComputer &computer, MessageIn &message);
-
- private: // functions
- // account assignment
- int assignAccount(NetComputer &computer, accountData *account);
-
-} \ No newline at end of file
+
+ /**
+ * Account assignment.
+ */
+ int assignAccount(NetComputer &computer, AccountData *account);
+};
+
+#endif
diff --git a/src/connectionhandler.h b/src/connectionhandler.h
index 805ae0af..bc5f0965 100644
--- a/src/connectionhandler.h
+++ b/src/connectionhandler.h
@@ -29,8 +29,6 @@
#include "packet.h"
#include <map>
-#include "accounthandler.h" // acount handling interface for the connection
-
/**
* This class represents the connection handler interface. The connection
* handler will respond to connect/reconnect/disconnect events and handle
diff --git a/src/debug.cpp b/src/debug.cpp
index 09b730a8..671528a2 100644
--- a/src/debug.cpp
+++ b/src/debug.cpp
@@ -18,9 +18,10 @@
* along with The Mana World; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
+ * $Id$
*/
- // This file contains debugging global functions
+// This file contains debugging global functions
#include "debug.h"
diff --git a/src/debug.h b/src/debug.h
index b024935e..37d191f0 100644
--- a/src/debug.h
+++ b/src/debug.h
@@ -18,6 +18,7 @@
* along with The Mana World; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
+ * $Id$
*/
#ifndef _TMW_SERVER_DEBUG_
diff --git a/src/defines.h b/src/defines.h
index ae1f1f38..72a0aff6 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -18,46 +18,53 @@
* along with The Mana World; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
+ * $Id$
*/
+
+#ifndef _TMW_SERVER_DEFINES_
+#define _TMW_SERVER_DEFINES_
+
+#include <string>
- // this file holds the global definitions and constants to be included
- // in multiple places throughout the server
-
- // debug and error definitions go in debug.h, not here
+// this file holds the global definitions and constants to be included
+// in multiple places throughout the server
+// debug and error definitions go in debug.h, not here
+
+
// I. ACCOUNT DEFINITIONS
- // A. Account Types
- #define STATUS_NORMAL 0 // denotes normal account status
- #define STATUS_ADMIN 1 // denotes admin acount status
- #define STATUS_GM 2 // denotes GM account status
- #define STATUS_BANNED 3 // denotes a temporarily banned account
- #define STATUS_RESTRICTED 4 // denotes a restricted access account
-
-
-
+
+// A. Account Types
+
+#define STATUS_NORMAL 0 // denotes normal account status
+#define STATUS_ADMIN 1 // denotes admin acount status
+#define STATUS_GM 2 // denotes GM account status
+#define STATUS_BANNED 3 // denotes a temporarily banned account
+#define STATUS_RESTRICTED 4 // denotes a restricted access account
+
// DATA STRUCTURES DEFINITIONS
// persistent character data
-struct charData
+struct CharData
{
- string charName; // character's name
+ std::string charName; // character's name
//equipData charEquip; // structure of equipped items
//estateData charEstate; // character's estate data
//petData charPet[3]; // character's pets
//itemData charItem; // character's inventory
//graphicData charGraphic; // character's appearance
-}
+};
// Account Data Structure
-struct accountData
+struct AccountData
{
- string accountID; // the account's ID
- string accountEMail; // the email of the account's owner
- string accountPass; // the account's password
- int accountStatus; // the account's status: normal, gm, banned, etc.
- charData accountChar[5]; // the characters stored in the account.
-}
-
+ std::string accountID; // the account's ID
+ std::string accountEMail; // the email of the account's owner
+ std::string accountPass; // the account's password
+ int accountStatus; // the account's status: normal, gm, banned, etc.
+ CharData accountChar[5]; // the characters stored in the account.
+};
+#endif
diff --git a/src/main.cpp b/src/main.cpp
index e7db308d..ac45dee2 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,6 +22,8 @@
*/
#include "netsession.h"
+#include "connectionhandler.h"
+#include "accounthandler.h"
#include <SDL.h>
#include <SDL_net.h>
@@ -90,6 +92,13 @@ int main(int argc, char *argv[])
ConnectionHandler *connectionHandler = new ConnectionHandler();
NetSession *session = new NetSession();
+ // Note: This is just an idea, we could also pass the connection handler
+ // to the constructor of the account handler, upon which is would register
+ // itself for the messages it handles.
+ //
+ //AccountHandler *accountHandler = new AccountHandler();
+ //connectionHandler->registerHandler(C2S_LOGIN, accountHandler);
+
session->startListen(connectionHandler, SERVER_PORT);
SDL_Event event;
diff --git a/src/netcomputer.h b/src/netcomputer.h
index ea3e157a..02948207 100644
--- a/src/netcomputer.h
+++ b/src/netcomputer.h
@@ -66,7 +66,6 @@ class NetComputer
*/
void send(Packet *p);
//void send(Packet *p, bool reliable = true);
-
};
#endif