summaryrefslogtreecommitdiff
path: root/src/char
diff options
context:
space:
mode:
authorshennetsind <ind@henn.et>2013-10-10 12:25:22 -0300
committershennetsind <ind@henn.et>2013-10-10 12:25:22 -0300
commitc5c3381b0b8b0b59c669d474acf749db82d7edb1 (patch)
tree5947d2a80594a1be87d3f5390cd04207c54e6ca3 /src/char
parentfc4ae790a3e4c0a86beb2eec140479a9511b265d (diff)
downloadhercules-c5c3381b0b8b0b59c669d474acf749db82d7edb1.tar.gz
hercules-c5c3381b0b8b0b59c669d474acf749db82d7edb1.tar.bz2
hercules-c5c3381b0b8b0b59c669d474acf749db82d7edb1.tar.xz
hercules-c5c3381b0b8b0b59c669d474acf749db82d7edb1.zip
Introducing Bank Support
http://hercules.ws/board/topic/2455-introducing-bank-support/ Thanks to Yommy, Haru! Signed-off-by: shennetsind <ind@henn.et>
Diffstat (limited to 'src/char')
-rw-r--r--src/char/char.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 7a948398c..5a51130de 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -70,6 +70,7 @@ char mercenary_owner_db[256] = "mercenary_owner";
char ragsrvinfo_db[256] = "ragsrvinfo";
char elemental_db[256] = "elemental";
char interreg_db[32] = "interreg";
+char account_data_db[256] = "account_data";
// show loading/saving messages
int save_log = 1;
@@ -497,6 +498,14 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
} else
strcat(save_status, " status");
}
+
+ if( p->bank_vault != cp->bank_vault ) {
+ if( SQL_ERROR == SQL->Query(sql_handle, "REPLACE INTO `%s` (`account_id`,`bank_vault`) VALUES ('%d','%d')",account_data_db,p->account_id,p->bank_vault) ) {
+ Sql_ShowDebug(sql_handle);
+ errors++;
+ } else
+ strcat(save_status, " bank");
+ }
//Values that will seldom change (to speed up saving)
if (
@@ -675,6 +684,7 @@ int mmo_char_tosql(int char_id, struct mmo_charstatus* p)
strcat(save_status, " hotkeys");
}
#endif
+
StrBuf->Destroy(&buf);
if (save_status[0]!='\0' && save_log)
ShowInfo("Saved char %d - %s:%s.\n", char_id, p->name, save_status);
@@ -1085,6 +1095,7 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
int hotkey_num;
#endif
unsigned int opt;
+ int account_id;
memset(p, 0, sizeof(struct mmo_charstatus));
@@ -1174,6 +1185,9 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
SQL->StmtFree(stmt);
return 0;
}
+
+ account_id = p->account_id;
+
p->last_point.map = mapindex_name2id(last_map);
p->save_point.map = mapindex_name2id(save_map);
@@ -1338,6 +1352,15 @@ int mmo_char_fromsql(int char_id, struct mmo_charstatus* p, bool load_everything
mercenary_owner_fromsql(char_id, p);
strcat(t_msg, " mercenary");
+ //`account_data` (`account_id`,`bank_vault`)
+ if( SQL_ERROR == SQL->StmtPrepare(stmt, "SELECT `bank_vault` FROM `%s` WHERE `account_id`=? LIMIT 1", account_data_db)
+ || SQL_ERROR == SQL->StmtBindParam(stmt, 0, SQLDT_INT, &account_id, 0)
+ || SQL_ERROR == SQL->StmtExecute(stmt)
+ || SQL_ERROR == SQL->StmtBindColumn(stmt, 0, SQLDT_INT, &p->bank_vault, 0, NULL, NULL) )
+ SqlStmt_ShowDebug(stmt);
+
+ if( SQL_SUCCESS == SQL->StmtNextRow(stmt) )
+ strcat(t_msg, " bank");
if (save_log) ShowInfo("Loaded char (%d - %s): %s\n", char_id, p->name, t_msg); //ok. all data load successfuly!
SQL->StmtFree(stmt);
@@ -4721,6 +4744,8 @@ void sql_config_read(const char* cfgName)
safestrncpy(elemental_db,w2,sizeof(elemental_db));
else if(!strcmpi(w1,"interreg_db"))
safestrncpy(interreg_db,w2,sizeof(interreg_db));
+ else if(!strcmpi(w1,"account_data_db"))
+ safestrncpy(account_data_db,w2,sizeof(account_data_db));
//support the import command, just like any other config
else if(!strcmpi(w1,"import"))
sql_config_read(w2);