summaryrefslogtreecommitdiff
path: root/src/map/pc.c
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/map/pc.c
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/map/pc.c')
-rw-r--r--src/map/pc.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index 6b7d6c735..ffc3427c7 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -10079,6 +10079,51 @@ void pc_itemcd_do(struct map_session_data *sd, bool load) {
return;
}
+void pc_bank_deposit(struct map_session_data *sd, int money) {
+ unsigned int limit_check = money+sd->status.bank_vault;
+
+ if( money <= 0 || limit_check > MAX_BANK_ZENY ) {
+ clif->bank_deposit(sd,BDA_OVERFLOW);
+ return;
+ } else if ( money > sd->status.zeny ) {
+ clif->bank_deposit(sd,BDA_NO_MONEY);
+ return;
+ }
+
+ if( pc->payzeny(sd,money, LOG_TYPE_BANK, NULL) )
+ clif->bank_deposit(sd,BDA_NO_MONEY);
+ else {
+ sd->status.bank_vault += money;
+ if( map->save_settings&256 )
+ chrif->save(sd,0);
+ clif->bank_deposit(sd,BDA_SUCCESS);
+ }
+}
+void pc_bank_withdraw(struct map_session_data *sd, int money) {
+ unsigned int limit_check = money+sd->status.zeny;
+
+ if( money <= 0 ) {
+ clif->bank_withdraw(sd,BWA_UNKNOWN_ERROR);
+ return;
+ } else if ( money > sd->status.bank_vault ) {
+ clif->bank_withdraw(sd,BWA_NO_MONEY);
+ return;
+ } else if ( limit_check > MAX_ZENY ) {
+ /* no official response for this scenario exists. */
+ clif->colormes(sd->fd,COLOR_RED,msg_txt(1482));
+ return;
+ }
+
+ if( pc->getzeny(sd,money, LOG_TYPE_BANK, NULL) )
+ clif->bank_withdraw(sd,BWA_NO_MONEY);
+ else {
+ sd->status.bank_vault -= money;
+ if( map->save_settings&256 )
+ chrif->save(sd,0);
+ clif->bank_withdraw(sd,BWA_SUCCESS);
+ }
+}
+
/*==========================================
* pc Init/Terminate
*------------------------------------------*/
@@ -10402,4 +10447,7 @@ void pc_defaults(void) {
pc->checkcombo = pc_checkcombo;
pc->calcweapontype = pc_calcweapontype;
pc->removecombo = pc_removecombo;
+
+ pc->bank_withdraw = pc_bank_withdraw;
+ pc->bank_deposit = pc_bank_deposit;
}