Переглянути джерело

* [Fixed]:
- Execution of sleep/sleep2 more than once will hang the script_state.

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

Lance 19 роки тому
батько
коміт
73afac7540
2 змінених файлів з 14 додано та 8 видалено
  1. 3 0
      Changelog-Trunk.txt
  2. 11 8
      src/map/script.c

+ 3 - 0
Changelog-Trunk.txt

@@ -4,6 +4,9 @@ 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/06/09
+	* [Fixed]:
+	  - Execution of sleep/sleep2 more than once will hang the script_state.
+	    [Lance]
 	* Fixed @mapinfo displaying incorrectly maps with nosave which send you
 	  back to your last savepoint. [Skotlex]
 	* Moved guild_exp_rate from a mapserver battle config setting to a char

+ 11 - 8
src/map/script.c

@@ -11442,6 +11442,15 @@ int run_script_main(struct script_state *st)
 		aFree(st);
 		st = NULL;
 		return 0;
+	}else{ 
+		if(st->sleep.tick > 0)
+	  	{	//Delay execution
+			TBL_PC *sd = (TBL_PC *)map_id2bl(st->rid);
+			st->sleep.charid = sd?sd->char_id:0;
+			st->sleep.timer  = add_timer(gettick()+st->sleep.tick,
+				run_script_timer, st->sleep.charid, (int)st);
+			linkdb_insert(&sleep_db, (void*)st->oid, st);
+		} 
 	}
 
 	return 1;
@@ -11507,15 +11516,9 @@ int run_script(struct script_code *rootscript,int pos,int rid,int oid)
 	st->sleep.timer = -1;
 
 	if(run_script_main(st)){
-		if(st->state != END){ 
+		if (st->state != END){
 			pos = st->pos;
-			if(st->sleep.tick > 0)
-	  		{	//Delay execution
-				st->sleep.charid = sd?sd->char_id:0;
-				st->sleep.timer  = add_timer(gettick()+st->sleep.tick,
-					run_script_timer, st->sleep.charid, (int)st);
-				linkdb_insert(&sleep_db, (void*)st->oid, st);
-			} else if (sd) {
+			if(!st->sleep.tick && sd) {
 				// script is not finished, store data in sd.
 				sd->npc_script      = st->script;
 				sd->npc_scriptroot  = rootscript;