Przeglądaj źródła

- The memory leak reports will now print out in the logs also the revision they belong to.
- Cleaned up the scriptable npc-shop code, it should be crash-proof now.


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@8525 54d463be-8e91-2dee-dedb-b68131a5f0ec

skotlex 19 lat temu
rodzic
commit
a45d7c414d
4 zmienionych plików z 29 dodań i 19 usunięć
  1. 4 0
      Changelog-Trunk.txt
  2. 1 1
      src/common/malloc.c
  3. 3 18
      src/map/clif.c
  4. 21 0
      src/map/npc.c

+ 4 - 0
Changelog-Trunk.txt

@@ -4,6 +4,10 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/08/28
+	* The memory leak reports will now print out in the logs also the revision
+	  they belong to. [Skotlex]
+	* Cleaned up the scriptable npc-shop code, it should be crash-proof now.
+	  [Skotlex]
 	* Added TK level-up buffs to SG too, and extended them to 10 min [DracoRPG]
 	* Added "Barefeet Mastery" effect to TK_RUN (thanks Tharis for both) [DracoRPG]
 	* Changed the produce_db format, now there's a skill-lv column right after

+ 1 - 1
src/common/malloc.c

@@ -583,7 +583,7 @@ static void memmgr_log (char *buf)
 	if (!log_fp) {
 		log_fp = fopen(memmer_logfile,"w");
 		if (!log_fp) log_fp = stdout;
-		fprintf(log_fp, "Memory manager: Memory leaks found.\n");
+		fprintf(log_fp, "Memory manager: Memory leaks found (Revision %s).\n", get_svn_revision());
 	}
 	fprintf(log_fp, buf);
 	return;

+ 3 - 18
src/map/clif.c

@@ -9420,10 +9420,8 @@ void clif_parse_NpcBuySellSelected(int fd,struct map_session_data *sd)
  */
 void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd)
 {
-	int fail=0,n, i;
+	int fail=0,n;
 	unsigned short *item_list;
-	unsigned char npc_ev[51];
-	struct npc_data *nd;
 	RFIFOHEAD(fd);
 
 	n = (RFIFOW(fd,2)-4) /4;
@@ -9431,21 +9429,8 @@ void clif_parse_NpcBuyListSend(int fd,struct map_session_data *sd)
 
 	if (sd->state.trading|| !sd->npc_shopid)
 		fail = 1;
-	else {
-		if((nd = ((struct npc_data *)map_id2bl(sd->npc_shopid))->master_nd)){
-			int regkey = add_str("@bought_nameid");
-			int regkey2 = add_str("@bought_quantity");
-			sprintf(npc_ev, "%s::OnBuyItem", nd->exname);
-			for(i=0;i<n;i++){
-				pc_setreg(sd,regkey+(i<<24),(int)item_list[i*2+1]);
-				pc_setreg(sd,regkey2+(i<<24),(int)item_list[i*2]);
-			}
-			npc_event(sd, npc_ev, 0);
-			fail = 0;
-		}else{
-			fail = npc_buylist(sd,n,item_list);
-		}
-	}
+	else
+		fail = npc_buylist(sd,n,item_list);
 
 	sd->npc_shopid = 0; //Clear shop data.
 	WFIFOHEAD(fd,packet_len_table[0xca]);

+ 21 - 0
src/map/npc.c

@@ -1164,6 +1164,24 @@ int npc_buysellsel(struct map_session_data *sd,int id,int type)
 	return 0;
 }
 
+//npc_buylist for script-controlled shops.
+static int npc_buylist_sub(
+	struct map_session_data *sd,int n,
+	unsigned short *item_list, struct npc_data *nd)
+{
+	unsigned char npc_ev[51];
+	int i;
+	int regkey = add_str("@bought_nameid");
+	int regkey2 = add_str("@bought_quantity");
+	sprintf(npc_ev, "%s::OnBuyItem", nd->exname);
+	for(i=0;i<n;i++){
+		pc_setreg(sd,regkey+(i<<24),(int)item_list[i*2+1]);
+		pc_setreg(sd,regkey2+(i<<24),(int)item_list[i*2]);
+	}
+	npc_event(sd, npc_ev, 0);
+	return 0;
+}
+
 /*==========================================
  *
  *------------------------------------------
@@ -1180,6 +1198,9 @@ int npc_buylist(struct map_session_data *sd,int n,unsigned short *item_list)
 	if ((nd = npc_checknear(sd,map_id2bl(sd->npc_shopid))) == NULL)
 		return 3;
 
+	if (nd->master_nd) //Script-based shops.
+		return npc_buylist_sub(sd,n,item_list,nd->master_nd);
+
 	if (nd->bl.subtype!=SHOP)
 		return 3;