Browse Source

- Fixed a memory leak when there exists more than one user function with the same name, added the appropiate warning when this happens.
- Added reporting source file when an npc shops item's price is exploitable.


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

skotlex 19 năm trước cách đây
mục cha
commit
6178d109d3
2 tập tin đã thay đổi với 15 bổ sung5 xóa
  1. 4 0
      Changelog-Trunk.txt
  2. 11 5
      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/07/27
+	* Fixed a memory leak when there exists more than one user function with
+	  the same name, added the appropiate warning when this happens. [Skotlex]
+	* Added reporting source file when an npc shops item's price is
+	  exploitable. [Skotlex]
 	* The picklog will now record negative values for items sold to npcs.
 	  [Skotlex]
 	* Added inmediate position and hp-bar update when a character joins a

+ 11 - 5
src/map/npc.c

@@ -1625,11 +1625,11 @@ static int npc_parse_shop (char *w1, char *w2, char *w3, char *w4)
 		if (value/124. < id->value_sell/75.) {  //Clened up formula to prevent overflows.
 			printf("\r"); //Carriage return to clear the 'loading..' line. [Skotlex]
 			if (value < id->value_sell)
-				ShowWarning ("Item %s [%d] buying price (%d) is less than selling price (%d)\n",
-					id->name, id->nameid, value, id->value_sell);
+				ShowWarning ("Item %s [%d] buying price (%d) is less than selling price (%d) at %s\n",
+					id->name, id->nameid, value, id->value_sell, current_file);
 			else
-				ShowWarning ("Item %s [%d] discounted buying price (%d) is less than overcharged selling price (%d)\n",
-					id->name, id->nameid, value/100*75, id->value_sell/100*124);
+				ShowWarning ("Item %s [%d] discounted buying price (%d) is less than overcharged selling price (%d) at %s\n",
+					id->name, id->nameid, value/100*75, id->value_sell/100*124, current_file);
 		}
 		//for logs filters, atcommands and iteminfo script command
 		if (id->maxchance<=0)
@@ -2124,7 +2124,13 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *fir
 	strncpy(p, w3, 50);
 
 	user_db = script_get_userfunc_db();
-	strdb_put(user_db, p, script);
+	if(strdb_get(user_db, p) != NULL) {
+		printf("\r"); //Carriage return to clear the 'loading..' line. [Skotlex]
+		ShowWarning("parse_function: Duplicate user function [%s] (%s:%d)\n", p, file, *lines);
+		aFree(p);
+		script_free_code(script);
+	} else
+		strdb_put(user_db, p, script);
 
 	// もう使わないのでバッファ解放
 	aFree(srcbuf);