summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-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
9 files changed, 80 insertions, 53 deletions
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