summaryrefslogtreecommitdiff
path: root/src/login/account_sql.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/login/account_sql.c')
-rw-r--r--src/login/account_sql.c79
1 files changed, 37 insertions, 42 deletions
diff --git a/src/login/account_sql.c b/src/login/account_sql.c
index 5f9357c81..adbb7914d 100644
--- a/src/login/account_sql.c
+++ b/src/login/account_sql.c
@@ -222,7 +222,7 @@ static bool account_db_sql_get_property(AccountDB* self, const char* key, char*
if( strcmpi(key, "db_username") == 0 )
safesnprintf(buf, buflen, "%s", db->global_db_username);
else
- if( strcmpi(key, "db_password") == 0 )
+ if( strcmpi(key, "db_password") == 0 )
safesnprintf(buf, buflen, "%s", db->global_db_password);
else
if( strcmpi(key, "db_database") == 0 )
@@ -248,7 +248,7 @@ static bool account_db_sql_get_property(AccountDB* self, const char* key, char*
if( strcmpi(key, "db_username") == 0 )
safesnprintf(buf, buflen, "%s", db->db_username);
else
- if( strcmpi(key, "db_password") == 0 )
+ if( strcmpi(key, "db_password") == 0 )
safesnprintf(buf, buflen, "%s", db->db_password);
else
if( strcmpi(key, "db_database") == 0 )
@@ -573,7 +573,7 @@ static bool mmo_auth_fromsql(AccountDB_SQL* db, struct mmo_account* acc, int acc
SQL->GetData(sql_handle, 13, &data, NULL); acc->char_slots = (uint8)atoi(data);
SQL->GetData(sql_handle, 14, &data, NULL); safestrncpy(acc->pincode, data, sizeof(acc->pincode));
SQL->GetData(sql_handle, 15, &data, NULL); acc->pincode_change = (unsigned int)atol(data);
-
+
SQL->FreeResult(sql_handle);
return true;
@@ -665,19 +665,19 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
Sql* sql_handle = ((AccountDB_SQL*)self)->accounts;
AccountDB_SQL* db = (AccountDB_SQL*)self;
int count = RFIFOW(fd, 12);
-
+
if( count ) {
int cursor = 14, i;
char key[32], sval[254];
unsigned int index;
-
+
for(i = 0; i < count; i++) {
safestrncpy(key, (char*)RFIFOP(fd, cursor + 1), RFIFOB(fd, cursor));
cursor += RFIFOB(fd, cursor) + 1;
-
+
index = RFIFOL(fd, cursor);
cursor += 4;
-
+
switch (RFIFOB(fd, cursor++)) {
/* int */
case 0:
@@ -700,24 +700,21 @@ void mmo_save_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
if( SQL_ERROR == SQL->Query(sql_handle, "DELETE FROM `%s` WHERE `account_id` = '%d' AND `key` = '%s' AND `index` = '%u' LIMIT 1", db->global_acc_reg_str_db, account_id, key, index) )
Sql_ShowDebug(sql_handle);
break;
-
default:
ShowError("mmo_save_accreg2: DA HOO UNKNOWN TYPE %d\n",RFIFOB(fd, cursor - 1));
return;
}
-
}
-
}
-
}
+
void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
Sql* sql_handle = ((AccountDB_SQL*)self)->accounts;
AccountDB_SQL* db = (AccountDB_SQL*)self;
char* data;
int plen = 0;
size_t len;
-
+
if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", db->global_acc_reg_str_db, account_id) )
Sql_ShowDebug(sql_handle);
@@ -730,7 +727,7 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
WFIFOB(fd, 13) = 1;/* is string type */
WFIFOW(fd, 14) = 0;/* count */
plen = 16;
-
+
/**
* Vessel!
*
@@ -738,36 +735,35 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
* { keyLength(B), key(<keyLength>), index(L), valLength(B), val(<valLength>) }
**/
while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
-
SQL->GetData(sql_handle, 0, &data, NULL);
len = strlen(data)+1;
-
+
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */
plen += 1;
-
+
safestrncpy((char*)WFIFOP(fd,plen), data, len);
plen += len;
-
+
SQL->GetData(sql_handle, 1, &data, NULL);
-
+
WFIFOL(fd, plen) = (unsigned int)atol(data);
plen += 4;
-
+
SQL->GetData(sql_handle, 2, &data, NULL);
len = strlen(data)+1;
-
+
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 254 */
plen += 1;
-
+
safestrncpy((char*)WFIFOP(fd,plen), data, len);
plen += len;
-
+
WFIFOW(fd, 14) += 1;
-
+
if( plen > 60000 ) {
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
-
+
/* prepare follow up */
WFIFOHEAD(fd, 60000 + 300);
WFIFOW(fd, 0) = 0x3804;
@@ -780,16 +776,16 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
plen = 16;
}
}
-
+
/* mark & go. */
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
-
+
SQL->FreeResult(sql_handle);
-
+
if( SQL_ERROR == SQL->Query(sql_handle, "SELECT `key`, `index`, `value` FROM `%s` WHERE `account_id`='%d'", db->global_acc_reg_num_db, account_id) )
Sql_ShowDebug(sql_handle);
-
+
WFIFOHEAD(fd, 60000 + 300);
WFIFOW(fd, 0) = 0x3804;
/* 0x2 = length, set prior to being sent */
@@ -799,7 +795,7 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
WFIFOB(fd, 13) = 0;/* is int type */
WFIFOW(fd, 14) = 0;/* count */
plen = 16;
-
+
/**
* Vessel!
*
@@ -807,32 +803,31 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
* { keyLength(B), key(<keyLength>), index(L), value(L) }
**/
while ( SQL_SUCCESS == SQL->NextRow(sql_handle) ) {
-
SQL->GetData(sql_handle, 0, &data, NULL);
len = strlen(data)+1;
-
+
WFIFOB(fd, plen) = (unsigned char)len;/* won't be higher; the column size is 32 */
plen += 1;
-
+
safestrncpy((char*)WFIFOP(fd,plen), data, len);
plen += len;
-
+
SQL->GetData(sql_handle, 1, &data, NULL);
-
+
WFIFOL(fd, plen) = (unsigned int)atol(data);
plen += 4;
-
+
SQL->GetData(sql_handle, 2, &data, NULL);
-
+
WFIFOL(fd, plen) = atoi(data);
plen += 4;
-
+
WFIFOW(fd, 14) += 1;
-
+
if( plen > 60000 ) {
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
-
+
/* prepare follow up */
WFIFOHEAD(fd, 60000 + 300);
WFIFOW(fd, 0) = 0x3804;
@@ -842,15 +837,15 @@ void mmo_send_accreg2(AccountDB* self, int fd, int account_id, int char_id) {
WFIFOB(fd, 12) = 0;/* var type (only set when all vars have been sent, regardless of type) */
WFIFOB(fd, 13) = 0;/* is int type */
WFIFOW(fd, 14) = 0;/* count */
-
+
plen = 16;
}
}
-
+
/* mark as complete & go. */
WFIFOB(fd, 12) = 1;
WFIFOW(fd, 2) = plen;
WFIFOSET(fd, plen);
-
+
SQL->FreeResult(sql_handle);
}