Przeglądaj źródła

Follow up to 1d1a58c when using self skills while storage is open. (Hercules 31486a8)

aleos89 11 lat temu
rodzic
commit
5ca8f406e4
6 zmienionych plików z 51 dodań i 17 usunięć
  1. 31 5
      src/map/clif.c
  2. 1 0
      src/map/clif.h
  3. 6 1
      src/map/skill.c
  4. 4 6
      src/map/storage.c
  5. 1 0
      src/map/storage.h
  6. 8 5
      src/map/unit.c

+ 31 - 5
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;
 	}

+ 1 - 0
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);

+ 6 - 1
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:

+ 4 - 6
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);
 }
 
 /**

+ 1 - 0
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);

+ 8 - 5
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)