summaryrefslogtreecommitdiff
path: root/src/dalstorage.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <bertram@cegetel.net>2005-12-12 22:17:35 +0000
committerYohann Ferreira <bertram@cegetel.net>2005-12-12 22:17:35 +0000
commitd187c54000b40dcebb742a89f9962a6f12921a62 (patch)
tree5711f5a05f7c1d0a28327203eb8fa001d8d25e4e /src/dalstorage.cpp
parent5ef4627a825d2c1ffd59a8ad33d05a6d72240a69 (diff)
downloadmanaserv-d187c54000b40dcebb742a89f9962a6f12921a62.tar.gz
manaserv-d187c54000b40dcebb742a89f9962a6f12921a62.tar.bz2
manaserv-d187c54000b40dcebb742a89f9962a6f12921a62.tar.xz
manaserv-d187c54000b40dcebb742a89f9962a6f12921a62.zip
Use setCharacter() and unsetcharacter() to deal with addBeing() and removeBeing() in the world (which are buggy). Add check when character's name already exists. Added Character list packet support.
Diffstat (limited to 'src/dalstorage.cpp')
-rw-r--r--src/dalstorage.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/dalstorage.cpp b/src/dalstorage.cpp
index 5d45ba56..1a9a5141 100644
--- a/src/dalstorage.cpp
+++ b/src/dalstorage.cpp
@@ -447,6 +447,49 @@ DALStorage::doesEmailAlreadyExists(std::string email)
return false;
}
+/**
+ * Tells if the character's name already exists
+ * @return true if character's name exists.
+ */
+bool
+DALStorage::doesCharacterNameExists(std::string name)
+{
+ // If not opened already
+ open();
+
+ try {
+ std::string sql("select count(name) from ");
+ sql += CHARACTERS_TBL_NAME;
+ sql += " where name = '";
+ sql += name;
+ sql += "';";
+ const dal::RecordSet& accountInfo = mDb->execSql(sql);
+
+ // if the account is empty then
+ // we have no choice but to return false.
+ if (accountInfo.isEmpty()) {
+ return false;
+ }
+
+ std::stringstream ssStream(accountInfo(0,0));
+ int iReturn = -1;
+ ssStream >> iReturn;
+ if ( iReturn > 0 )
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch (const dal::DbSqlQueryExecFailure& e) {
+ // TODO: throw an exception.
+ LOG_ERROR("SQL query failure: " << e.what())
+ }
+
+ return false;
+}
/**
* Save changes to the database permanently.