Ver código fonte

* Experimental tweak to npc_parse_function - Overwrite existing functions.

modified   Changelog-Trunk.txt
modified   src/map/npc.c


git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@9084 54d463be-8e91-2dee-dedb-b68131a5f0ec
Lance 18 anos atrás
pai
commit
bdca3b4cc2
2 arquivos alterados com 12 adições e 4 exclusões
  1. 1 0
      Changelog-Trunk.txt
  2. 11 4
      src/map/npc.c

+ 1 - 0
Changelog-Trunk.txt

@@ -5,6 +5,7 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 2006/10/26
 	* Updated sql files [Playtester]
+	* Experimental tweak to npc_parse_function - Overwrite existing functions. [Lance]
 2006/10/25
 	* Cleaned up some more the event dequeue code, it will no longer clear out
 	  the npc_id if there's no events waiting to be executed (why does it clears

+ 11 - 4
src/map/npc.c

@@ -2101,6 +2101,7 @@ static int npc_parse_function (char *w1, char *w2, char *w3, char *w4, char *fir
 {
 	unsigned char *srcbuf, *p;
 	struct script_code *script;
+	struct script_code *oldscript;
 	int srcsize = 65536;
 	int startline = 0;
 	char line[1024];
@@ -2151,11 +2152,17 @@ 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();
-	if(strdb_get(user_db, p) != NULL) {
+	oldscript = (struct script_code *)strdb_get(user_db, p);
+	if(oldscript != 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);
+		//ShowWarning("parse_function: Duplicate user function [%s] (%s:%d)\n", p, file, *lines);
+		//aFree(p);
+		//script_free_code(script);
+		// Experimental function overwriting - [Lance]
+		ShowInfo("parse_function: Overwriting user function [%s] (%s:%d)\n", p, file, *lines);
+		script_free_code(oldscript);
+		user_db->remove(user_db,p);
+		strdb_put(user_db, p, script);
 	} else
 		strdb_put(user_db, p, script);