Pārlūkot izejas kodu

Resolved some more inventory issues
* Moved storage type loading further up the chain to ensure data is loaded sooner.
* Resolved cart weight and cart count to update properly.
* Resolved item display index not displaying in the correct order when opening a Vending Shop.
Thanks to @Tokeiburu!

aleos89 8 gadi atpakaļ
vecāks
revīzija
c0bd422af2
3 mainītis faili ar 20 papildinājumiem un 10 dzēšanām
  1. 2 1
      src/map/intif.c
  2. 6 5
      src/map/pc.c
  3. 12 4
      src/map/status.c

+ 2 - 1
src/map/intif.c

@@ -3213,11 +3213,12 @@ static bool intif_parse_StorageReceived(int fd)
 
 		case TABLE_CART:
 			pc_check_available_item(sd, ITMCHK_CART);
-			status_calc_cart_weight(sd, 1|2);
 			if (sd->state.autotrade) {
 				clif_parse_LoadEndAck(sd->fd, sd);
 				sd->autotrade_tid = add_timer(gettick() + battle_config.feature_autotrade_open_delay, pc_autotrade_timer, sd->bl.id, 0);
 			}else if( sd->state.prevend ){
+				clif_clearcart(sd->fd);
+				clif_cartlist(sd);
 				clif_openvendingreq(sd, sd->vend_skill_lv+2);
 			}
 			break;

+ 6 - 5
src/map/pc.c

@@ -1399,6 +1399,12 @@ void pc_reg_received(struct map_session_data *sd)
 		return;
 	sd->state.active = 1;
 
+	intif_storage_request(sd,TABLE_INVENTORY); // Request inventory data
+	intif_storage_request(sd,TABLE_CART); // Request cart data
+	intif_storage_request(sd,TABLE_STORAGE); // Request storage data
+
+	sd->storage_size = MIN_STORAGE; //default to min
+
 	if (sd->status.party_id)
 		party_member_joined(sd);
 	if (sd->status.guild_id)
@@ -1423,7 +1429,6 @@ void pc_reg_received(struct map_session_data *sd)
 
 	chrif_skillcooldown_request(sd->status.account_id, sd->status.char_id);
 	chrif_bsdata_request(sd->status.char_id);
-	sd->storage_size = MIN_STORAGE; //default to min
 #ifdef VIP_ENABLE
 	sd->vip.time = 0;
 	sd->vip.enabled = 0;
@@ -1451,10 +1456,6 @@ void pc_reg_received(struct map_session_data *sd)
 
 		clif_changeoption( &sd->bl );
 	}
-
-	intif_storage_request(sd,TABLE_STORAGE); // Request storage data
-	intif_storage_request(sd,TABLE_CART); // Request cart data
-	intif_storage_request(sd,TABLE_INVENTORY); // Request inventory data
 }
 
 static int pc_calc_skillpoint(struct map_session_data* sd)

+ 12 - 4
src/map/status.c

@@ -3134,6 +3134,10 @@ bool status_calc_weight(struct map_session_data *sd, uint8 flag)
 /**
  * Calculates player's cart weight
  * @param sd: Player object
+ * @param flag: Calculation type
+ *   1 - Cart item weight
+ *   2 - Skill/Status/Configuration max weight bonus
+ *   4 - Whether to check for cart status
  * @return false - failed, true - success
  */
 bool status_calc_cart_weight(struct map_session_data *sd, uint8 flag)
@@ -3142,7 +3146,7 @@ bool status_calc_cart_weight(struct map_session_data *sd, uint8 flag)
 
 	nullpo_retr(false, sd);
 
-	if (!pc_iscarton(sd))
+	if (!pc_iscarton(sd) && !(flag&4))
 		return false;
 
 	b_cart_weight_max = sd->cart_weight_max; // Store cart max weight for later comparison
@@ -3201,9 +3205,6 @@ int status_calc_pc_(struct map_session_data* sd, enum e_status_calc_opt opt)
 		sd->battle_status.sp = sd->status.sp;
 		sd->regen.sregen = &sd->sregen;
 		sd->regen.ssregen = &sd->ssregen;
-
-		status_calc_weight(sd, 1);
-		status_calc_cart_weight(sd, 1);
 	}
 
 	base_status = &sd->base_status;
@@ -8479,6 +8480,13 @@ int status_change_start(struct block_list* src, struct block_list* bl,enum sc_ty
 			return 0;
 		break;
 
+	case SC_PUSH_CART:
+	if (sd) {
+		sd->cart_weight_max = 0; // Force a client refesh
+		status_calc_cart_weight(sd, 1|2|4);
+	}
+	break;
+
 	case SC_WEDDING:
 	case SC_XMAS:
 	case SC_SUMMER: