From 5ca8f406e4efb4a4890343d9bb4d0ad6717258b8 Mon Sep 17 00:00:00 2001 From: aleos89 Date: Fri, 23 May 2014 12:18:27 -0400 Subject: [PATCH] Follow up to 1d1a58c when using self skills while storage is open. (Hercules 31486a8) --- src/map/clif.c | 36 +++++++++++++++++++++++++++++++----- src/map/clif.h | 1 + src/map/skill.c | 7 ++++++- src/map/storage.c | 10 ++++------ src/map/storage.h | 1 + src/map/unit.c | 13 ++++++++----- 6 files changed, 51 insertions(+), 17 deletions(-) diff --git a/src/map/clif.c b/src/map/clif.c index 2a02407be9..82b261e619 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -8632,6 +8632,34 @@ void clif_messagecolor(struct block_list* bl, unsigned long color, const char* m clif_send(buf, WBUFW(buf,2), bl, AREA_CHAT_WOC); } +/** + * Notifies the client that the storage window is still open + * + * Should only be used in cases where the client closed the + * storage window without server's consent + */ +void clif_refresh_storagewindow(struct map_session_data *sd) { + // Notify the client that the storage is open + if( sd->state.storage_flag == 1 ) { + storage_sortitem(sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items)); + clif_storagelist(sd, sd->status.storage.items, ARRAYLENGTH(sd->status.storage.items)); + clif_updatestorageamount(sd, sd->status.storage.storage_amount, MAX_STORAGE); + } + // Notify the client that the gstorage is open otherwise it will + // remain locked forever and nobody will be able to access it + if( sd->state.storage_flag == 2 ) { + struct guild_storage *gstor = guild2storage2(sd->status.guild_id); + + if( !gstor ) // Shouldn't happen. The information should already be at the map-server + intif_request_guild_storage(sd->status.account_id, sd->status.guild_id); + else { + storage_sortitem(gstor->items, ARRAYLENGTH(gstor->items)); + clif_storagelist(sd, gstor->items, ARRAYLENGTH(gstor->items)); + clif_updatestorageamount(sd, gstor->storage_amount, MAX_GUILD_STORAGE); + } + } +} + // refresh the client's screen, getting rid of any effects void clif_refresh(struct map_session_data *sd) { @@ -8692,6 +8720,7 @@ void clif_refresh(struct map_session_data *sd) pc_disguise(sd, 0); pc_disguise(sd, disguise); } + clif_refresh_storagewindow(sd); } @@ -11301,10 +11330,6 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) sd->state.storage_flag && !(tmp&INF_SELF_SKILL) ) //SELF skills can be used with the storage open, issue: 8027 return; - //Some self skills need to close the storage to work properly - if( skill_id == AL_TELEPORT && sd->state.storage_flag ) - storage_storageclose(sd); - if( pc_issit(sd) ) return; @@ -11498,7 +11523,8 @@ void clif_parse_UseSkillMap(int fd, struct map_session_data* sd) if(skill_id != sd->menuskill_id) return; - if( pc_cant_act(sd) ) { + //It is possible to use teleport with the storage window open bugreport:8027 + if (pc_cant_act(sd) && !sd->state.storage_flag && skill_id != AL_TELEPORT) { clif_menuskill_clear(sd); return; } diff --git a/src/map/clif.h b/src/map/clif.h index 28e1afc6fd..ec81cdd5c8 100644 --- a/src/map/clif.h +++ b/src/map/clif.h @@ -460,6 +460,7 @@ void clif_changechatowner(struct chat_data* cd, struct map_session_data* sd); // void clif_clearchat(struct chat_data *cd,int fd); // area or fd void clif_leavechat(struct chat_data* cd, struct map_session_data* sd, bool flag); // chat void clif_changechatstatus(struct chat_data* cd); // chat +void clif_refresh_storagewindow(struct map_session_data *sd); void clif_refresh(struct map_session_data *sd); // self void clif_fame_blacksmith(struct map_session_data *sd, int points); diff --git a/src/map/skill.c b/src/map/skill.c index 2617a8ab20..c828761e12 100755 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -11514,10 +11514,15 @@ int skill_castend_map (struct map_session_data *sd, uint16 skill_id, const char { case AL_TELEPORT: case ALL_ODINS_RECALL: - if(strcmp(map,"Random")==0) + //The storage window is closed automatically by the client when there's + //any kind of map change, so we need to restore it automatically + //bugreport:8027 + if(strcmp(map,"Random") == 0) pc_randomwarp(sd,CLR_TELEPORT); else if (sd->menuskill_val > 1 || skill_id == ALL_ODINS_RECALL) //Need lv2 to be able to warp here. pc_setpos(sd,sd->status.save_point.map,sd->status.save_point.x,sd->status.save_point.y,CLR_TELEPORT); + + clif_refresh_storagewindow(sd); break; case AL_WARP: diff --git a/src/map/storage.c b/src/map/storage.c index a01a6733d8..58c876b0d8 100644 --- a/src/map/storage.c +++ b/src/map/storage.c @@ -53,23 +53,21 @@ static int storage_comp_item(const void *_i1, const void *_i2) * @param items : list of items to sort * @param size : number of item in list */ -static void storage_sortitem(struct item* items, unsigned int size) +void storage_sortitem(struct item* items, unsigned int size) { nullpo_retv(items); if( battle_config.client_sort_storage ) - { qsort(items, size, sizeof(struct item), storage_comp_item); - } } /** * Initiate storage module * Called from map.c::do_init() - * @return 1 */ -void do_init_storage(void){ - guild_storage_db=idb_alloc(DB_OPT_RELEASE_DATA); +void do_init_storage(void) +{ + guild_storage_db = idb_alloc(DB_OPT_RELEASE_DATA); } /** diff --git a/src/map/storage.h b/src/map/storage.h index 3405fa19c4..b67dc327dd 100644 --- a/src/map/storage.h +++ b/src/map/storage.h @@ -18,6 +18,7 @@ int storage_storageget(struct map_session_data *sd,int index,int amount); int storage_storageaddfromcart(struct map_session_data *sd,int index,int amount); int storage_storagegettocart(struct map_session_data *sd,int index,int amount); void storage_storageclose(struct map_session_data *sd); +void storage_sortitem(struct item* items, unsigned int size); void do_init_storage(void); void do_final_storage(void); void do_reconnect_storage(void); diff --git a/src/map/unit.c b/src/map/unit.c index 1d3d26eb02..0647680beb 100644 --- a/src/map/unit.c +++ b/src/map/unit.c @@ -2392,11 +2392,14 @@ int unit_remove_map_(struct block_list *bl, clr_type clrtype, const char* file, trade_tradecancel(sd); buyingstore_close(sd); searchstore_close(sd); - if(sd->state.storage_flag == 1) - storage_storage_quit(sd,0); - else if (sd->state.storage_flag == 2) - storage_guild_storage_quit(sd,0); - sd->state.storage_flag = 0; // Force close it when being warped. + if (sd->menuskill_id != AL_TELEPORT) { //bugreport:8027 + if (sd->state.storage_flag == 1) + storage_storage_quit(sd,0); + else if (sd->state.storage_flag == 2) + storage_guild_storage_quit(sd,0); + + sd->state.storage_flag = 0; //Force close it when being warped. + } if(sd->party_invite>0) party_reply_invite(sd,sd->party_invite,0); if(sd->guild_invite>0)