Jelajahi Sumber

Fixed a possible crash with NPC currencies (fixes #1002 and fixes #1005)
* Resolved the nullpo return message.
* If the Cash Shop opened through the client button is used it will now properly return the cash value.

aleos89 9 tahun lalu
induk
melakukan
3a5f3a3f98
2 mengubah file dengan 8 tambahan dan 2 penghapusan
  1. 0 2
      src/map/clif.c
  2. 8 0
      src/map/npc.c

+ 0 - 2
src/map/clif.c

@@ -15671,8 +15671,6 @@ void clif_cashshop_ack(struct map_session_data* sd, int error)
 	fd = sd->fd;
 	nd = map_id2nd(sd->npc_shopid);
 
-	nullpo_retv(nd);
-
 	npc_shop_currency_type(sd, nd, cost, false);
 
 	WFIFOHEAD(fd, packet_len(0x289));

+ 8 - 0
src/map/npc.c

@@ -1498,6 +1498,14 @@ int npc_cashshop_buylist(struct map_session_data *sd, int points, int count, uns
  */
 void npc_shop_currency_type(struct map_session_data *sd, struct npc_data *nd, int cost[2], bool display)
 {
+	nullpo_retv(sd);
+
+	if (!nd) { // Assume it's Cash Shop through the button
+		cost[0] = sd->cashPoints;
+		cost[1] = sd->kafraPoints;
+		return;
+	}
+
 	switch(nd->subtype) {
 		case NPCTYPE_CASHSHOP:
 			cost[0] = sd->cashPoints;