summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-29 15:36:33 +0000
committerGuillaume Melquiond <guillaume.melquiond@gmail.com>2007-08-29 15:36:33 +0000
commiteb905a28219dc7af2669b8b0db8415c3e8c4ab23 (patch)
tree0f70ec07541e8448808ba17417e168fec81c848d
parent26b3e1094d85ef89c90376688000836c8ee43979 (diff)
downloadmanaserv-eb905a28219dc7af2669b8b0db8415c3e8c4ab23.tar.gz
manaserv-eb905a28219dc7af2669b8b0db8415c3e8c4ab23.tar.xz
manaserv-eb905a28219dc7af2669b8b0db8415c3e8c4ab23.zip
Fixed handling of account levels.
-rw-r--r--ChangeLog4
-rw-r--r--src/account-server/account.cpp24
-rw-r--r--src/account-server/account.hpp15
-rw-r--r--src/account-server/accounthandler.cpp2
-rw-r--r--src/account-server/dalstorage.cpp3
-rw-r--r--src/game-server/command.cpp4
6 files changed, 14 insertions, 38 deletions
diff --git a/ChangeLog b/ChangeLog
index d643bfe..d63a306 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,10 @@
use the new event system.
* src/game-server/quest.cpp: Fixed event listener on character removal
and/or disconnection.
+ * src/account-server/account.hpp, src/account-server/dalstorage.cpp,
+ src/account-server/accounthandler.cpp, src/account-server/account.cpp:
+ Fixed account levels not being loaded from the database.
+ * src/game-server/command.cpp: Fixed level checking.
2007-08-28 Guillaume Melquiond <guillaume.melquiond@gmail.com>
diff --git a/src/account-server/account.cpp b/src/account-server/account.cpp
index fb4e057..883654f 100644
--- a/src/account-server/account.cpp
+++ b/src/account-server/account.cpp
@@ -20,10 +20,10 @@
* $Id$
*/
-#include "account-server/account.hpp"
-
#include <cassert>
+#include "account-server/account.hpp"
+
#include "account-server/accountclient.hpp"
#include "utils/functors.h"
@@ -33,30 +33,14 @@
Account::Account(const std::string& name,
const std::string& password,
const std::string& email,
+ int level,
int id)
: mName(name),
mPassword(password),
mEmail(email),
mCharacters(),
mID(id),
- mLevel(AL_NORMAL)
-{
- // NOOP
-}
-
-
-/**
- * Constructor with initial account info.
- */
-Account::Account(const std::string& name,
- const std::string& password,
- const std::string& email,
- const Characters& characters)
- : mName(name),
- mPassword(password),
- mEmail(email),
- mCharacters(characters),
- mLevel(AL_NORMAL)
+ mLevel(level)
{
// NOOP
}
diff --git a/src/account-server/account.hpp b/src/account-server/account.hpp
index 6b1cf8a..7c5b570 100644
--- a/src/account-server/account.hpp
+++ b/src/account-server/account.hpp
@@ -56,24 +56,11 @@ class Account
Account(const std::string& name,
const std::string& password,
const std::string& email,
+ int level,
int id = -1);
/**
- * Constructor with initial account info.
- *
- * @param name the user name.
- * @param password the user password.
- * @param email the user email.
- * @param characters the characters.
- */
- Account(const std::string& name,
- const std::string& password,
- const std::string& email,
- const Characters& characters);
-
-
- /**
* Destructor.
*/
~Account();
diff --git a/src/account-server/accounthandler.cpp b/src/account-server/accounthandler.cpp
index a199a96..edb72b7 100644
--- a/src/account-server/accounthandler.cpp
+++ b/src/account-server/accounthandler.cpp
@@ -337,7 +337,7 @@ AccountHandler::handleRegisterMessage(AccountClient &computer, MessageIn &msg)
}
else
{
- AccountPtr acc(new Account(username, password, email));
+ AccountPtr acc(new Account(username, password, email, AL_NORMAL));
store.addAccount(acc);
reply.writeByte(ERRMSG_OK);
diff --git a/src/account-server/dalstorage.cpp b/src/account-server/dalstorage.cpp
index 612d056..5709fb7 100644
--- a/src/account-server/dalstorage.cpp
+++ b/src/account-server/dalstorage.cpp
@@ -234,7 +234,8 @@ AccountPtr DALStorage::getAccountBySQL(std::string const &query)
// and initialize it with information about the user.
AccountPtr account(new Account(accountInfo(0, 1),
accountInfo(0, 2),
- accountInfo(0, 3), id));
+ accountInfo(0, 3),
+ toUint(accountInfo(0, 4)), id));
mAccounts.insert(std::make_pair(id, account));
diff --git a/src/game-server/command.cpp b/src/game-server/command.cpp
index 342a14f..41bee29 100644
--- a/src/game-server/command.cpp
+++ b/src/game-server/command.cpp
@@ -85,9 +85,9 @@ template<> struct Argument< MonsterClass * >
struct Command
{
char const *name;
- char type[4];
void (*handler)(void (*f)(), Character *, intptr_t[]);
void (*target)();
+ char type[4];
unsigned char level;
};
@@ -254,7 +254,7 @@ void runCommand(Character *ch, std::string const &text)
}
}
- if (!c || c->level < ch->getAccountLevel())
+ if (!c || c->level > ch->getAccountLevel())
{
// No such command or no sufficient rights.
return;