Преглед изворни кода

New NPC range now working.
Sorry guys, back in my days it was as easy as this, but I did not test it. So now tested and working. :)

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

lemongrass3110 пре 12 година
родитељ
комит
48431ee9db
2 измењених фајлова са 16 додато и 3 уклоњено
  1. 10 2
      src/map/npc.c
  2. 6 1
      src/map/npc.h

+ 10 - 2
src/map/npc.c

@@ -95,6 +95,7 @@ static DBMap *npc_path_db;
 
 //For holding the view data of npc classes. [Skotlex]
 static struct view_data npc_viewdb[MAX_NPC_CLASS];
+static struct view_data npc_viewdb2[MAX_NPC_CLASS2_END-MAX_NPC_CLASS2_START];
 
 static struct script_event_s
 {	//Holds pointers to the commonly executed scripts for speedup. [Skotlex]
@@ -107,8 +108,13 @@ struct view_data* npc_get_viewdata(int class_)
 {	//Returns the viewdata for normal npc classes.
 	if( class_ == INVISIBLE_CLASS )
 		return &npc_viewdb[0];
-	if (npcdb_checkid(class_) || class_ == WARP_CLASS)
-		return &npc_viewdb[class_];
+	if (npcdb_checkid(class_) || class_ == WARP_CLASS){
+		if( class_ > MAX_NPC_CLASS2_START ){
+			return &npc_viewdb2[class_-MAX_NPC_CLASS2_START];
+		}else{
+			return &npc_viewdb[class_];
+		}
+	}
 	return NULL;
 }
 
@@ -3857,6 +3863,8 @@ int do_init_npc(void)
 	npc_viewdb[0].class_ = INVISIBLE_CLASS; //Invisible class is stored here.
 	for( i = 1; i < MAX_NPC_CLASS; i++ )
 		npc_viewdb[i].class_ = i;
+	for( i = MAX_NPC_CLASS2_START; i < MAX_NPC_CLASS2_END; i++ )
+		npc_viewdb2[i - MAX_NPC_CLASS2_START].class_ = i;
 
 	ev_db = strdb_alloc((DBOptions)(DB_OPT_DUP_KEY|DB_OPT_RELEASE_DATA),2*NAME_LENGTH+2+1);
 	npcname_db = strdb_alloc(DB_OPT_BASE,NAME_LENGTH);

+ 6 - 1
src/map/npc.h

@@ -88,10 +88,15 @@ enum actor_classes
 	INVISIBLE_CLASS = 32767,
 };
 
+// Old NPC range
 #define MAX_NPC_CLASS 1000
+// New NPC range
+#define MAX_NPC_CLASS2_START 10000
+#define MAX_NPC_CLASS2_END 10049
+
 //Checks if a given id is a valid npc id. [Skotlex]
 //Since new npcs are added all the time, the max valid value is the one before the first mob (Scorpion = 1001)
-#define npcdb_checkid(id) ( ( (id) >= 46 && (id) <= 125) || (id) == HIDDEN_WARP_CLASS || ( (id) > 400 && (id) < MAX_NPC_CLASS ) || (id) == INVISIBLE_CLASS || ( id > 10000 && id < 10049 ) )
+#define npcdb_checkid(id) ( ( (id) >= 46 && (id) <= 125) || (id) == HIDDEN_WARP_CLASS || ( (id) > 400 && (id) < MAX_NPC_CLASS ) || (id) == INVISIBLE_CLASS || ( id > MAX_NPC_CLASS2_START && id < MAX_NPC_CLASS2_END ) )
 
 #ifdef PCRE_SUPPORT
 void npc_chat_finalize(struct npc_data* nd);