Compare commits

...

2 Commits

Author SHA1 Message Date
Kayne Ruse e5a98efd7d Merge branch 'develop' (bugfix, read more)
Found an error in the SQL save statements; fixed.

Character positions are now saved between logins.
2014-05-13 04:37:33 +10:00
Kayne Ruse 14b330009b BUGFIX: Found an error in SQL save statements
The character's positions are now persistent between logins.
2014-05-13 04:36:59 +10:00
2 changed files with 7 additions and 9 deletions
+3 -4
View File
@@ -31,7 +31,7 @@
static const char* CREATE_USER_ACCOUNT = "INSERT INTO UserAccounts (username) VALUES (?);";
static const char* LOAD_USER_ACCOUNT = "SELECT * FROM UserAccounts WHERE username = ?;";
static const char* SAVE_USER_ACCOUNT = "INSERT OR REPLACE INTO UserAccounts VALUES (?, ?, ?, ?);";
static const char* SAVE_USER_ACCOUNT = "UPDATE OR FAIL UserAccounts SET blacklisted = ?2, whitelisted = ?3 WHERE uid = ?1;";
static const char* DELETE_USER_ACCOUNT = "DELETE FROM UserAccounts WHERE uid = ?;";
//-------------------------
@@ -135,9 +135,8 @@ int ServerApplication::SaveUserAccount(int uid) {
//parameters
bool ret = false;
ret |= sqlite3_bind_int(statement, 1, uid) != SQLITE_OK;
ret |= sqlite3_bind_text(statement, 2, account.username.c_str(), account.username.size() + 1, SQLITE_STATIC) != SQLITE_OK;
ret |= sqlite3_bind_int(statement, 3, account.blackListed) != SQLITE_OK;
ret |= sqlite3_bind_int(statement, 4, account.whiteListed) != SQLITE_OK;
ret |= sqlite3_bind_int(statement, 2, account.blackListed) != SQLITE_OK;
ret |= sqlite3_bind_int(statement, 3, account.whiteListed) != SQLITE_OK;
//check for binding errors
if (ret) {
+4 -5
View File
@@ -31,7 +31,7 @@
static const char* CREATE_CHARACTER = "INSERT INTO PlayerCharacters (owner, handle, avatar) VALUES (?, ?, ?);";
static const char* LOAD_CHARACTER = "SELECT * FROM PlayerCharacters WHERE handle = ?;";
static const char* SAVE_CHARACTER = "INSERT OR REPLACE INTO PlayerCharacters (uid, owner, mapIndex, positionX, positionY) VALUES (?, ?, ?, ?, ?);";
static const char* SAVE_CHARACTER = "UPDATE OR FAIL PlayerCharacters SET mapIndex = ?2, positionX = ?3, positionY = ?4 WHERE uid = ?1;";
static const char* DELETE_CHARACTER = "DELETE FROM PlayerCharacters WHERE uid = ?;";
//-------------------------
@@ -172,10 +172,9 @@ int ServerApplication::SaveCharacter(int uid) {
//parameters
bool ret = false;
ret |= sqlite3_bind_int(statement, 1, uid) != SQLITE_OK;
ret |= sqlite3_bind_int(statement, 2, character.owner) != SQLITE_OK;
ret |= sqlite3_bind_int(statement, 3, character.mapIndex) != SQLITE_OK;
ret |= sqlite3_bind_int(statement, 4, (int)character.position.x) != SQLITE_OK;
ret |= sqlite3_bind_int(statement, 5, (int)character.position.y) != SQLITE_OK;
ret |= sqlite3_bind_int(statement, 2, character.mapIndex) != SQLITE_OK;
ret |= sqlite3_bind_int(statement, 3, (int)character.position.x) != SQLITE_OK;
ret |= sqlite3_bind_int(statement, 4, (int)character.position.y) != SQLITE_OK;
//TODO: stats, etc.
//check for binding errors