Explorar o código

* Random updates to instance system.
- Introduced a constant for instance name length.
- Corrected comments related to instance packets 0x2cb (ZC_MEMORIALDUNGEON_SUBSCRIPTION_INFO) and 0x2ce (ZC_MEMORIALDUNGEON_NOTIFY).
- Moved instance finalization out of map.c into instance.c

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

ai4rei %!s(int64=14) %!d(string=hai) anos
pai
achega
b91aa20b3d
Modificáronse 5 ficheiros con 27 adicións e 11 borrados
  1. 5 0
      Changelog-Trunk.txt
  2. 6 4
      src/map/clif.c
  3. 9 1
      src/map/instance.c
  4. 6 3
      src/map/instance.h
  5. 1 3
      src/map/map.c

+ 5 - 0
Changelog-Trunk.txt

@@ -1,5 +1,10 @@
 Date	Added
 
+2011/07/02
+	* Random updates to instance system. [Ai4rei]
+	- Introduced a constant for instance name length.
+	- Corrected comments related to instance packets 0x2cb (ZC_MEMORIALDUNGEON_SUBSCRIPTION_INFO) and 0x2ce (ZC_MEMORIALDUNGEON_NOTIFY).
+	- Moved instance finalization out of map.c into instance.c
 2011/07/01
 	* CMake: marked executables as different components and other miscellaneous changes. [FlavioJS]
 2011/06/29

+ 6 - 4
src/map/clif.c

@@ -13997,11 +13997,11 @@ int clif_instance(int instance_id, int type, int flag)
 	switch( type )
 	{
 	case 1:
-		// S 0x2cb <Instance name>.63B <Standby Position>.W
+		// S 0x2cb <Instance name>.61B <Standby Position>.W
 		// Required to start the instancing information window on Client
 		// This window re-appear each "refresh" of client automatically until type 4 is send to client.
 		WBUFW(buf,0) = 0x02CB;
-		memcpy(WBUFP(buf,2),instance[instance_id].name,61);
+		memcpy(WBUFP(buf,2),instance[instance_id].name,INSTANCE_NAME_LENGTH);
 		WBUFW(buf,63) = flag;
 		clif_send(buf,packet_len(0x02CB),&sd->bl,PARTY);
 		break;
@@ -14029,14 +14029,16 @@ int clif_instance(int instance_id, int type, int flag)
 		}
 		clif_send(buf,packet_len(0x02CD),&sd->bl,PARTY);
 		break;
-	case 5: // R 02CE <message ID>.L
+	case 5:
 		// S 0x2ce <Message ID>.L
+		// 0 = Notification (EnterLimitDate update?)
 		// 1 = The Memorial Dungeon expired; it has been destroyed
 		// 2 = The Memorial Dungeon's entry time limit expired; it has been destroyed
 		// 3 = The Memorial Dungeon has been removed.
-		// 4 = Just remove the window, maybe party/guild leave
+		// 4 = Create failure (removes the instance window)
 		WBUFW(buf,0) = 0x02CE;
 		WBUFL(buf,2) = flag;
+		//WBUFL(buf,6) = EnterLimitDate;
 		clif_send(buf,packet_len(0x02CE),&sd->bl,PARTY);
 		break;
 	}

+ 9 - 1
src/map/instance.c

@@ -220,7 +220,7 @@ void instance_init(int instance_id)
 	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]);
 
-	instance[instance_id].state = INSTANCE_BUSSY;
+	instance[instance_id].state = INSTANCE_BUSY;
 	ShowInfo("[Instance] Initialized %s.\n", instance[instance_id].name);
 }
 
@@ -444,6 +444,14 @@ void instance_check_kick(struct map_session_data *sd)
 	}
 }
 
+void do_final_instance(void)
+{
+	int i;
+
+	for( i = 1; i < MAX_INSTANCE; i++ )
+		instance_destroy(i);
+}
+
 void do_init_instance(void)
 {
 	memset(instance, 0x00, sizeof(instance));

+ 6 - 3
src/map/instance.h

@@ -7,10 +7,12 @@
 #define MAX_MAP_PER_INSTANCE 10
 #define MAX_INSTANCE 500
 
-typedef enum instance_state { INSTANCE_FREE, INSTANCE_IDLE, INSTANCE_BUSSY } instance_state;
+#define INSTANCE_NAME_LENGTH (60+1)
+
+typedef enum instance_state { INSTANCE_FREE, INSTANCE_IDLE, INSTANCE_BUSY } instance_state;
 
 struct s_instance {
-	char name[61]; // Instance Name - required for clif functions.
+	char name[INSTANCE_NAME_LENGTH]; // Instance Name - required for clif functions.
 	instance_state state;
 	short instance_id;
 	int party_id;
@@ -43,6 +45,7 @@ void instance_check_idle(int instance_id);
 void instance_check_kick(struct map_session_data *sd);
 void instance_set_timeout(int instance_id, unsigned int progress_timeout, unsigned int idle_timeout);
 
-void do_init_instance();
+void do_final_instance(void);
+void do_init_instance(void);
 
 #endif

+ 1 - 3
src/map/map.c

@@ -3436,9 +3436,6 @@ void do_final(void)
 	for( sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); sd = (TBL_PC*)mapit_next(iter) )
 		map_quit(sd);
 	mapit_free(iter);
-	
-	for( i = 0; i < MAX_INSTANCE; i++ )
-		instance_destroy(i);
 
 	id_db->foreach(id_db,cleanup_db_sub);
 	chrif_char_reset_offline();
@@ -3449,6 +3446,7 @@ void do_final(void)
 	do_final_chrif();
 	do_final_npc();
 	do_final_script();
+	do_final_instance();
 	do_final_itemdb();
 	do_final_storage();
 	do_final_guild();