summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/accounthandler.cpp12
-rw-r--r--src/dalstorage.cpp11
-rw-r--r--src/dalstorage.h2
-rw-r--r--src/storage.h2
4 files changed, 14 insertions, 13 deletions
diff --git a/src/accounthandler.cpp b/src/accounthandler.cpp
index ca65cd1e..fff2223f 100644
--- a/src/accounthandler.cpp
+++ b/src/accounthandler.cpp
@@ -73,7 +73,7 @@ void AccountHandler::receiveMessage(NetComputer &computer, MessageIn &message)
}
// see if the account exists
- tmwserv::AccountPtr acc = tmwserv::AccountPtr(store.getAccount(username));
+ tmwserv::AccountPtr acc = store.getAccount(username);
if (!acc.get()) {
// account doesn't exist -- send error to client
@@ -190,8 +190,8 @@ void AccountHandler::receiveMessage(NetComputer &computer, MessageIn &message)
}
// see if the account exists
- Account *accPtr = store.getAccount(username);
- if ( accPtr ) // Account already exists.
+ tmwserv::AccountPtr accPtr = store.getAccount(username);
+ if ( accPtr.get() ) // Account already exists.
{
result.writeShort(SMSG_REGISTER_RESPONSE);
result.writeByte(REGISTER_EXISTS_USERNAME);
@@ -236,15 +236,15 @@ void AccountHandler::receiveMessage(NetComputer &computer, MessageIn &message)
LOG_INFO(username << " wants to be deleted from our accounts.", 1)
// see if the account exists
- Account *acc = store.getAccount(username);
+ tmwserv::AccountPtr accPtr = store.getAccount(username);
- if (!acc) {
+ if (!accPtr.get()) {
// account doesn't exist -- send error to client
LOG_INFO(username << ": Account doesn't exist anyway.", 1)
result.writeShort(SMSG_UNREGISTER_RESPONSE);
result.writeByte(UNREGISTER_INVALID_USERNAME);
- } else if (acc->getPassword() != password) {
+ } else if (accPtr->getPassword() != password) {
// bad password -- send error to client
LOG_INFO("Won't delete it : Bad password for " << username << ".", 1)
diff --git a/src/dalstorage.cpp b/src/dalstorage.cpp
index 5723a040..c0359754 100644
--- a/src/dalstorage.cpp
+++ b/src/dalstorage.cpp
@@ -158,7 +158,7 @@ DALStorage::close(void)
/**
* Get an account by user name.
*/
-Account*
+AccountPtr
DALStorage::getAccount(const std::string& userName)
{
// connect to the database (if not connected yet).
@@ -173,7 +173,7 @@ DALStorage::getAccount(const std::string& userName)
);
if (it != mAccounts.end()) {
- return (it->first).get();
+ return it->first;
}
using namespace dal;
@@ -190,7 +190,7 @@ DALStorage::getAccount(const std::string& userName)
// if the account is not even in the database then
// we have no choice but to return nothing.
if (accountInfo.isEmpty()) {
- return NULL;
+ return AccountPtr(NULL);
}
// create an Account instance
@@ -288,10 +288,10 @@ DALStorage::getAccount(const std::string& userName)
account->setCharacters(beings);
} // End if there are characters.
- return account.get();
+ return account;
}
catch (const DbSqlQueryExecFailure& e) {
- return NULL; // TODO: Throw exception here
+ return AccountPtr(NULL); // TODO: Throw exception here
}
}
@@ -303,6 +303,7 @@ void
DALStorage::addAccount(const AccountPtr& account)
{
if (account.get() == 0) {
+ LOG_WARN("Cannot add a NULL Account.", 0)
// maybe we should throw an exception instead
return;
}
diff --git a/src/dalstorage.h b/src/dalstorage.h
index af109dc2..d3785568 100644
--- a/src/dalstorage.h
+++ b/src/dalstorage.h
@@ -71,7 +71,7 @@ class DALStorage: public Storage
*
* @return the account associated to the user name.
*/
- Account*
+ AccountPtr
getAccount(const std::string& userName);
diff --git a/src/storage.h b/src/storage.h
index 6381fea7..534eca0a 100644
--- a/src/storage.h
+++ b/src/storage.h
@@ -259,7 +259,7 @@ class Storage
*
* @return the account associated to the user name.
*/
- virtual Account*
+ virtual AccountPtr
getAccount(const std::string& userName) = 0;