diff --git a/src/char/char.c b/src/char/char.c index 7d6af5c275..63214e1646 100644 --- a/src/char/char.c +++ b/src/char/char.c @@ -2167,7 +2167,7 @@ int loginif_BankingReq(int32 account_id, int8 type, int32 data){ WFIFOB(login_fd,6) = type; WFIFOL(login_fd,7) = data; WFIFOSET(login_fd,11); - return 1; + return 1; } return 0; } @@ -2184,18 +2184,18 @@ int loginif_parse_BankingAck(int fd){ int32 bank_vault = RFIFOL(fd,6); char not_fw = RFIFOB(fd,10); RFIFOSKIP(fd,11); - - if(!not_fw) mapif_BankingAck(aid, bank_vault); + + if(not_fw==0) mapif_BankingAck(aid, bank_vault); return 1; } //HZ 0x2b29 L L int mapif_BankingAck(int32 account_id, int32 bank_vault){ - unsigned char buf[14]; + unsigned char buf[11]; WBUFW(buf,0) = 0x2b29; WBUFL(buf,2) = account_id; WBUFL(buf,6) = bank_vault; - mapif_sendall(buf, 10); //inform all maps-attached + mapif_sendall(buf, 10); //inform all maps-attached return 1; } @@ -2226,7 +2226,7 @@ int mapif_parse_ReqBankInfo(int fd){ return 0; uint32 aid = RFIFOL(fd,2); RFIFOSKIP(fd,6); - loginif_BankingReq(aid, 1, 0); + loginif_BankingReq(aid, 1, 0); return 1; } diff --git a/src/login/login.c b/src/login/login.c index 9bc540295e..0d5232e633 100644 --- a/src/login/login.c +++ b/src/login/login.c @@ -956,12 +956,14 @@ int parse_fromchar(int fd){ if( !accounts->load_num(accounts, &acc, account_id) ) ShowNotice("Char-server '%s': Error on banking (account: %d not found, ip: %s).\n", server[id].name, account_id, ip); else{ - unsigned char buf[11]; + unsigned char buf[12]; if(type==2){ // upd and Save acc.bank_vault = data; accounts->save(accounts, &acc); WBUFB(buf,10) = 1; - } + } else { + WBUFB(buf,10) = 0; + } // announce to other servers WBUFW(buf,0) = 0x2741; WBUFL(buf,2) = account_id; diff --git a/src/map/chrif.c b/src/map/chrif.c index 209ed97c3e..c0bfe9d18e 100644 --- a/src/map/chrif.c +++ b/src/map/chrif.c @@ -1198,7 +1198,7 @@ int chrif_bankdata_request(int account_id, int char_id) { WFIFOW(char_fd,0) = 0x2b2a; WFIFOL(char_fd,2) = account_id; WFIFOSET(char_fd,6); - return 0; + return 0; } int chrif_load_bankdata(int fd){ @@ -1215,7 +1215,7 @@ int chrif_load_bankdata(int fd){ return -1; } sd->status.bank_vault = bank_vault; - return 1; + return 1; } int chrif_save_bankdata(struct map_session_data *sd){ @@ -1226,7 +1226,7 @@ int chrif_save_bankdata(struct map_session_data *sd){ WFIFOL(char_fd,2) = sd->status.account_id; WFIFOL(char_fd,6) = sd->status.bank_vault; WFIFOSET(char_fd,10); - return 1; + return 1; } int chrif_save_scdata(struct map_session_data *sd) { //parses the sc_data of the player and sends it to the char-server for saving. [Skotlex] diff --git a/src/map/clif.c b/src/map/clif.c index dec3da8572..761e3514b0 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -6140,7 +6140,10 @@ void clif_cart_additem_ack(struct map_session_data *sd, uint8 flag) // 09B7 (ZC_ACK_OPEN_BANKING) void clif_bank_open(struct map_session_data *sd){ - int fd = sd->fd; + int fd; + + nullpo_retv(sd); + fd = sd->fd; WFIFOHEAD(fd,4); WFIFOW(fd,0) = 0x09b7; @@ -6155,6 +6158,7 @@ void clif_bank_open(struct map_session_data *sd){ void clif_parse_BankOpen(int fd, struct map_session_data* sd) { //TODO check if preventing trade or stuff like that //also mark something in case char ain't available for saving, should we check now ? + nullpo_retv(sd); if( !battle_config.feature_banking ) { clif_colormes(sd,color_table[COLOR_RED],msg_txt(sd,1496)); //Banking is disabled return; @@ -6162,19 +6166,24 @@ void clif_parse_BankOpen(int fd, struct map_session_data* sd) { else { struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; int aid = RFIFOL(fd,info->pos[0]); //unused should we check vs fd ? + if(sd->status.account_id == aid){ sd->state.banking = 1; + //request save ? + //chrif_bankdata_request(sd->status.account_id, sd->status.char_id); + //on succes open bank ? + clif_bank_open(sd); + } } - //request save ? -// chrif_bankdata_request(sd->status.account_id, sd->status.char_id); - //on succes open bank ? - clif_bank_open(sd); } // 09B9 (ZC_ACK_CLOSE_BANKING) void clif_bank_close(struct map_session_data *sd){ - int fd = sd->fd; - + int fd; + + nullpo_retv(sd); + fd = sd->fd; + WFIFOHEAD(fd,4); WFIFOW(fd,0) = 0x09B9; WFIFOW(fd,2) = 0; @@ -6188,12 +6197,16 @@ void clif_bank_close(struct map_session_data *sd){ void clif_parse_BankClose(int fd, struct map_session_data* sd) { struct s_packet_db* info = &packet_db[sd->packet_ver][RFIFOW(fd,0)]; int aid = RFIFOL(fd,info->pos[0]); //unused should we check vs fd ? + + nullpo_retv(sd); if( !battle_config.feature_banking ) { clif_colormes(sd,color_table[COLOR_RED],msg_txt(sd,1496)); //Banking is disabled //still allow to go trough to not stuck player if we have disable it while they was in } - sd->state.banking = 0; - clif_bank_close(sd); + if(sd->status.account_id == aid){ + sd->state.banking = 0; + clif_bank_close(sd); + } } /* @@ -6269,6 +6282,7 @@ void clif_bank_deposit(struct map_session_data *sd, enum e_BANKING_DEPOSIT_ACK r * 09A7 L L (PACKET_CZ_REQ_BANKING_DEPOSIT) */ void clif_parse_BankDeposit(int fd, struct map_session_data* sd) { + nullpo_retv(sd); if( !battle_config.feature_banking ) { clif_colormes(sd,color_table[COLOR_RED],msg_txt(sd,1496)); //Banking is disabled return; @@ -6315,7 +6329,8 @@ void clif_bank_withdraw(struct map_session_data *sd,enum e_BANKING_WITHDRAW_ACK * Request Withdrawing some money from bank * 09A9 L L (PACKET_CZ_REQ_BANKING_WITHDRAW) */ -void clif_parse_BankWithdraw(int fd, struct map_session_data* sd) { +void clif_parse_BankWithdraw(int fd, struct map_session_data* sd) { + nullpo_retv(sd); if( !battle_config.feature_banking ) { clif_colormes(sd,color_table[COLOR_RED],msg_txt(sd,1496)); //Banking is disabled return;