Browse Source

Corrected a few minor issues
* Follow up to 2cfb844.
* Adjusted the instance_db documentation.
* Adjusted script command instance_announce to check when instance ID is 0 rather than -1 since instance IDs are stored as unsigned now.
* Added a couple of checks when sending instance information to the client.
* Fixed a compile warning.

aleos89 9 years ago
parent
commit
6babca3689

+ 1 - 1
db/import-tmpl/instance_db.txt

@@ -1,6 +1,6 @@
 // Instance Database
 // Instance Database
 //
 //
 // Structure of Database:
 // Structure of Database:
-// ID,Name,LimitTime,IdleTimeOut,EnterMap,EnterX,EnterY,Map2,Map3,Map4,Map5,Map6,Map7,Map8,Map9,Map10
+// ID,Name,LimitTime,IdleTimeOut,EnterMap,EnterX,EnterY,Map2,Map3,...,Map255
 //
 //
 // EnterMap is considered as Map1
 // EnterMap is considered as Map1

+ 1 - 1
db/pre-re/instance_db.txt

@@ -1,7 +1,7 @@
 // Instance Database
 // Instance Database
 //
 //
 // Structure of Database:
 // Structure of Database:
-// ID,Name,LimitTime,IdleTimeOut,EnterMap,EnterX,EnterY,Map2,Map3,Map4,Map5,Map6,Map7,Map8,Map9,Map10
+// ID,Name,LimitTime,IdleTimeOut,EnterMap,EnterX,EnterY,Map2,Map3,...,Map255
 //
 //
 // EnterMap is considered as Map1
 // EnterMap is considered as Map1
 
 

+ 1 - 1
db/re/instance_db.txt

@@ -1,7 +1,7 @@
 // Instance Database
 // Instance Database
 //
 //
 // Structure of Database:
 // Structure of Database:
-// ID,Name,LimitTime,IdleTimeOut,EnterMap,EnterX,EnterY,Map2,Map3,Map4,Map5,Map6,Map7,Map8,Map9,Map10
+// ID,Name,LimitTime,IdleTimeOut,EnterMap,EnterX,EnterY,Map2,...,Map255
 //
 //
 // EnterMap is considered as Map1
 // EnterMap is considered as Map1
 
 

+ 1 - 1
doc/script_commands.txt

@@ -8201,7 +8201,7 @@ fails, the script will come to a halt.
 *instance_announce <instance id>,"<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};
 *instance_announce <instance id>,"<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};
 
 
 Broadcasts a message to all players in the instance <instance id> currently
 Broadcasts a message to all players in the instance <instance id> currently
-residing on an instance map. If -1 is specified for <instance id>, the instance
+residing on an instance map. If 0 is specified for <instance id>, the instance
 the script is attached to is used. If the script is not attached to an instance,
 the script is attached to is used. If the script is not attached to an instance,
 the instance of the currently attached player is used (if it is a character,
 the instance of the currently attached player is used (if it is a character,
 party, or guild mode). If it is not owned by anyone, no player needs to be attached.
 party, or guild mode). If it is not owned by anyone, no player needs to be attached.

+ 10 - 2
src/map/clif.c

@@ -16589,8 +16589,12 @@ void clif_instance_create(unsigned short instance_id, int num)
 		return;
 		return;
 
 
 	db = instance_searchtype_db(instance_data[instance_id].type);
 	db = instance_searchtype_db(instance_data[instance_id].type);
+
+	if (!db)
+		return;
+
 	WBUFW(buf,0) = 0x2cb;
 	WBUFW(buf,0) = 0x2cb;
-	safestrncpy(WBUFP(buf,2), StringBuf_Value(db->name), INSTANCE_NAME_LENGTH);
+	safestrncpy((char *)WBUFP(buf,2), StringBuf_Value(db->name), INSTANCE_NAME_LENGTH);
 	WBUFW(buf,63) = num;
 	WBUFW(buf,63) = num;
 	clif_send(buf,packet_len(0x2cb),&sd->bl,target);
 	clif_send(buf,packet_len(0x2cb),&sd->bl,target);
 #endif
 #endif
@@ -16636,8 +16640,12 @@ void clif_instance_status(unsigned short instance_id, unsigned int limit1, unsig
 		return;
 		return;
 
 
 	db = instance_searchtype_db(instance_data[instance_id].type);
 	db = instance_searchtype_db(instance_data[instance_id].type);
+
+	if (!db)
+		return;
+
 	WBUFW(buf,0) = 0x2cd;
 	WBUFW(buf,0) = 0x2cd;
-	safestrncpy(WBUFP(buf,2), StringBuf_Value(db->name), INSTANCE_NAME_LENGTH);
+	safestrncpy((char *)WBUFP(buf,2), StringBuf_Value(db->name), INSTANCE_NAME_LENGTH);
 	WBUFL(buf,63) = limit1;
 	WBUFL(buf,63) = limit1;
 	WBUFL(buf,67) = limit2;
 	WBUFL(buf,67) = limit2;
 	clif_send(buf,packet_len(0x2cd),&sd->bl,target);
 	clif_send(buf,packet_len(0x2cd),&sd->bl,target);

+ 7 - 7
src/map/script.c

@@ -18866,7 +18866,7 @@ BUILDIN_FUNC(instance_create)
 		mode = script_getnum(st, 3);
 		mode = script_getnum(st, 3);
 
 
 		if (mode < IM_NONE || mode >= IM_MAX) {
 		if (mode < IM_NONE || mode >= IM_MAX) {
-			ShowError("buildin_instance_create: Unknown instance owner type %d for '%s'\n", mode, script_getstr(st, 2));
+			ShowError("buildin_instance_create: Unknown instance mode %d for '%s'\n", mode, script_getstr(st, 2));
 			return SCRIPT_CMD_FAILURE;
 			return SCRIPT_CMD_FAILURE;
 		}
 		}
 	}
 	}
@@ -18916,8 +18916,8 @@ BUILDIN_FUNC(instance_destroy)
 	else
 	else
 		instance_id = script_instancegetid(st);
 		instance_id = script_instancegetid(st);
 
 
-	if( instance_id <= 0 || instance_id >= MAX_MAP_PER_SERVER ) {
-		ShowError("buildin_instance_destroy: Trying to destroy invalid instance %d.\n", instance_id);
+	if( instance_id == 0 || instance_id >= MAX_MAP_PER_SERVER ) {
+		ShowError("buildin_instance_destroy: Trying to destroy invalid instance %hu.\n", instance_id);
 		return SCRIPT_CMD_FAILURE;
 		return SCRIPT_CMD_FAILURE;
 	}
 	}
 
 
@@ -18970,10 +18970,10 @@ BUILDIN_FUNC(instance_npcname)
 
 
 	if( instance_id && (nd = npc_name2id(str)) != NULL ) {
 	if( instance_id && (nd = npc_name2id(str)) != NULL ) {
 		static char npcname[NAME_LENGTH];
 		static char npcname[NAME_LENGTH];
-		snprintf(npcname, sizeof(npcname), "dup_%d_%d", instance_id, nd->bl.id);
+		snprintf(npcname, sizeof(npcname), "dup_%hu_%d", instance_id, nd->bl.id);
 		script_pushconststr(st,npcname);
 		script_pushconststr(st,npcname);
 	} else {
 	} else {
-		ShowError("buildin_instance_npcname: Invalid instance NPC (instance_id: %d, NPC name: \"%s\".)\n", instance_id, str);
+		ShowError("buildin_instance_npcname: Invalid instance NPC (instance_id: %hu, NPC name: \"%s\".)\n", instance_id, str);
 		st->state = END;
 		st->state = END;
 		return SCRIPT_CMD_FAILURE;
 		return SCRIPT_CMD_FAILURE;
 	}
 	}
@@ -19087,7 +19087,7 @@ BUILDIN_FUNC(instance_warpall)
  * Broadcasts to all maps inside an instance
  * Broadcasts to all maps inside an instance
  *
  *
  * instance_announce <instance id>,"<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};
  * instance_announce <instance id>,"<text>",<flag>{,<fontColor>{,<fontType>{,<fontSize>{,<fontAlign>{,<fontY>}}}}};
- * Using -1 for <instance id> will auto-detect the id.
+ * Using 0 for <instance id> will auto-detect the id.
  *------------------------------------------*/
  *------------------------------------------*/
 BUILDIN_FUNC(instance_announce) {
 BUILDIN_FUNC(instance_announce) {
 	unsigned short instance_id = script_getnum(st,2);
 	unsigned short instance_id = script_getnum(st,2);
@@ -19100,7 +19100,7 @@ BUILDIN_FUNC(instance_announce) {
 	int            fontY       = script_hasdata(st,9) ? script_getnum(st,9) : 0;     // default fontY
 	int            fontY       = script_hasdata(st,9) ? script_getnum(st,9) : 0;     // default fontY
 	int i;
 	int i;
 
 
-	if( instance_id == -1 ) {
+	if( instance_id == 0 ) {
 		instance_id = script_instancegetid(st);
 		instance_id = script_instancegetid(st);
 	}
 	}