Browse Source

crashfix to attach/detach timers

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@12748 54d463be-8e91-2dee-dedb-b68131a5f0ec
Lupus 17 years ago
parent
commit
51b885b417
2 changed files with 34 additions and 3 deletions
  1. 2 0
      Changelog-Trunk.txt
  2. 32 3
      src/map/script.c

+ 2 - 0
Changelog-Trunk.txt

@@ -3,6 +3,8 @@ Date	Added
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 AS OF SVN REV. 5091, WE ARE NOW USING TRUNK.  ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
 
 
+2008/05/31
+	* Crashfix to attach/detach timers, thanks to Konard (fixed recent crashes) [Lupus]
 2008/05/28
 2008/05/28
 	* Updated Ankle Snare duration (bugreport:1438) [Playtester]
 	* Updated Ankle Snare duration (bugreport:1438) [Playtester]
 	- agi now has only half the effect on the duration (100 agi reduces it by 50%)
 	- agi now has only half the effect on the duration (100 agi reduces it by 50%)

+ 32 - 3
src/map/script.c

@@ -7768,7 +7768,7 @@ BUILDIN_FUNC(getnpctimer)
 	if (!nd || nd->bl.type != BL_NPC)
 	if (!nd || nd->bl.type != BL_NPC)
 	{
 	{
 		script_pushint(st,0);
 		script_pushint(st,0);
-		ShowError("getnpctimer: Invalid NPC\n");
+		ShowError("getnpctimer: Invalid NPC.\n");
 		return 1;
 		return 1;
 	}
 	}
 
 
@@ -7803,7 +7803,15 @@ BUILDIN_FUNC(setnpctimer)
 	else
 	else
 		nd=(struct npc_data *)map_id2bl(st->oid);
 		nd=(struct npc_data *)map_id2bl(st->oid);
 
 
+	if (!nd || nd->bl.type != BL_NPC)
+	{
+		script_pushint(st,1);
+		ShowError("setnpctimer: Invalid NPC.\n");
+		return 1;
+	}
+
 	npc_settimerevent_tick(nd,tick);
 	npc_settimerevent_tick(nd,tick);
+	script_pushint(st,0);
 	return 0;
 	return 0;
 }
 }
 
 
@@ -7816,15 +7824,28 @@ BUILDIN_FUNC(attachnpctimer)
 	struct npc_data *nd;
 	struct npc_data *nd;
 
 
 	nd=(struct npc_data *)map_id2bl(st->oid);
 	nd=(struct npc_data *)map_id2bl(st->oid);
+
+	if (!nd || nd->bl.type != BL_NPC)
+	{
+		script_pushint(st,1);
+		ShowError("setnpctimer: Invalid NPC.\n");
+		return 1;
+	}
+
 	if( script_hasdata(st,2) )
 	if( script_hasdata(st,2) )
 		sd=map_nick2sd(script_getstr(st,2));
 		sd=map_nick2sd(script_getstr(st,2));
 	else
 	else
 		sd = script_rid2sd(st);
 		sd = script_rid2sd(st);
 
 
-	if (sd==NULL)
-		return 0;
+	if (!sd)
+	{
+		script_pushint(st,1);
+		ShowWarning("attachnpctimer: Invalid player.\n");
+		return 1;
+	}
 
 
 	nd->u.scr.rid = sd->bl.id;
 	nd->u.scr.rid = sd->bl.id;
+	script_pushint(st,0);
 	return 0;
 	return 0;
 }
 }
 
 
@@ -7839,7 +7860,15 @@ BUILDIN_FUNC(detachnpctimer)
 	else
 	else
 		nd=(struct npc_data *)map_id2bl(st->oid);
 		nd=(struct npc_data *)map_id2bl(st->oid);
 
 
+	if (!nd || nd->bl.type != BL_NPC)
+	{
+		script_pushint(st,1);
+		ShowError("detachnpctimer: Invalid NPC.\n");
+		return 1;
+	}
+
 	nd->u.scr.rid = 0;
 	nd->u.scr.rid = 0;
+	script_pushint(st,0);
 	return 0;
 	return 0;
 }
 }