瀏覽代碼

Fixed instances not initializing after reloadscript (bugreport:3522).

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@14167 54d463be-8e91-2dee-dedb-b68131a5f0ec
ultramage 15 年之前
父節點
當前提交
ada5a13abe
共有 4 個文件被更改,包括 13 次插入9 次删除
  1. 4 7
      src/map/instance.c
  2. 1 1
      src/map/map.c
  3. 1 1
      src/map/npc.c
  4. 7 0
      src/map/script.c

+ 4 - 7
src/map/instance.c

@@ -214,12 +214,9 @@ int instance_map_npcsub(struct block_list* bl, va_list args)
 void instance_init(int instance_id)
 {
 	int i;
-	if( !instance_id ) return;
-	if( instance[instance_id].state != INSTANCE_IDLE )
-	{
-		ShowError("instance_init: instance already initialited.\n");
-		return;
-	}
+
+	if( !instance_id )
+		return; // nothing to do
 
 	for( i = 0; i < instance[instance_id].num_map; i++ )
 		map_foreachinmap(instance_map_npcsub, map[instance[instance_id].map[i]].instance_src_map, BL_NPC, instance[instance_id].map[i]);
@@ -314,7 +311,7 @@ void instance_destroy(int instance_id)
 	time_t now = time(NULL);
 
 	if( !instance_id || instance[instance_id].state == INSTANCE_FREE )
-		return;
+		return; // nothing to do
 
 	if( instance[instance_id].progress_timeout && instance[instance_id].progress_timeout <= now )
 		type = 1;

+ 1 - 1
src/map/map.c

@@ -3371,7 +3371,7 @@ void do_final(void)
 	mapit_free(iter);
 	
 	for( i = 0; i < MAX_INSTANCE; i++ )
-		if( instance[i].state != INSTANCE_FREE ) instance_destroy(i);
+		instance_destroy(i);
 
 	id_db->foreach(id_db,cleanup_db_sub);
 	chrif_char_reset_offline();

+ 1 - 1
src/map/npc.c

@@ -3347,7 +3347,7 @@ int npc_reload(void)
 		npc_id - npc_new_min, npc_warp, npc_shop, npc_script, npc_mob, npc_cache_mob, npc_delay_mob);
 
 	for( i = 0; i < ARRAYLENGTH(instance); ++i )
-		if( instance[i].instance_id ) instance_init(instance[i].instance_id);
+		instance_init(instance[i].instance_id);
 
 	//Re-read the NPC Script Events cache.
 	npc_read_event_script();

+ 7 - 0
src/map/script.c

@@ -14004,6 +14004,13 @@ BUILDIN_FUNC(instance_set_timeout)
 BUILDIN_FUNC(instance_init)
 {
 	int instance_id = script_getnum(st, 2);
+
+	if( instance[instance_id].state != INSTANCE_IDLE )
+	{
+		ShowError("instance_init: instance already initialized.\n");
+		return 0;
+	}
+
 	instance_init(instance_id);
 	return 0;
 }