From 6babca36897e4e3ebbf2301e8c53acd9e68273e4 Mon Sep 17 00:00:00 2001 From: aleos89 Date: Tue, 24 May 2016 09:22:03 -0400 Subject: [PATCH] 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. --- db/import-tmpl/instance_db.txt | 2 +- db/pre-re/instance_db.txt | 2 +- db/re/instance_db.txt | 2 +- doc/script_commands.txt | 2 +- src/map/clif.c | 12 ++++++++++-- src/map/script.c | 14 +++++++------- 6 files changed, 21 insertions(+), 13 deletions(-) diff --git a/db/import-tmpl/instance_db.txt b/db/import-tmpl/instance_db.txt index eb33400dad..5672eec9e4 100644 --- a/db/import-tmpl/instance_db.txt +++ b/db/import-tmpl/instance_db.txt @@ -1,6 +1,6 @@ // Instance 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 diff --git a/db/pre-re/instance_db.txt b/db/pre-re/instance_db.txt index 7501545263..e9cf668f15 100644 --- a/db/pre-re/instance_db.txt +++ b/db/pre-re/instance_db.txt @@ -1,7 +1,7 @@ // Instance 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 diff --git a/db/re/instance_db.txt b/db/re/instance_db.txt index 8a1d10e712..255371e80f 100644 --- a/db/re/instance_db.txt +++ b/db/re/instance_db.txt @@ -1,7 +1,7 @@ // Instance 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 diff --git a/doc/script_commands.txt b/doc/script_commands.txt index d8404c22cb..d1ae5ad030 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -8201,7 +8201,7 @@ fails, the script will come to a halt. *instance_announce ,"",{,{,{,{,{,}}}}}; Broadcasts a message to all players in the instance currently -residing on an instance map. If -1 is specified for , the instance +residing on an instance map. If 0 is specified for , the 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, party, or guild mode). If it is not owned by anyone, no player needs to be attached. diff --git a/src/map/clif.c b/src/map/clif.c index 17b6b00da5..da523fa2ec 100644 --- a/src/map/clif.c +++ b/src/map/clif.c @@ -16589,8 +16589,12 @@ void clif_instance_create(unsigned short instance_id, int num) return; db = instance_searchtype_db(instance_data[instance_id].type); + + if (!db) + return; + 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; clif_send(buf,packet_len(0x2cb),&sd->bl,target); #endif @@ -16636,8 +16640,12 @@ void clif_instance_status(unsigned short instance_id, unsigned int limit1, unsig return; db = instance_searchtype_db(instance_data[instance_id].type); + + if (!db) + return; + 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,67) = limit2; clif_send(buf,packet_len(0x2cd),&sd->bl,target); diff --git a/src/map/script.c b/src/map/script.c index 60f89c2892..fd1a903dee 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -18866,7 +18866,7 @@ BUILDIN_FUNC(instance_create) mode = script_getnum(st, 3); 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; } } @@ -18916,8 +18916,8 @@ BUILDIN_FUNC(instance_destroy) else 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; } @@ -18970,10 +18970,10 @@ BUILDIN_FUNC(instance_npcname) if( instance_id && (nd = npc_name2id(str)) != NULL ) { 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); } 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; return SCRIPT_CMD_FAILURE; } @@ -19087,7 +19087,7 @@ BUILDIN_FUNC(instance_warpall) * Broadcasts to all maps inside an instance * * instance_announce ,"",{,{,{,{,{,}}}}}; - * Using -1 for will auto-detect the id. + * Using 0 for will auto-detect the id. *------------------------------------------*/ BUILDIN_FUNC(instance_announce) { 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 i; - if( instance_id == -1 ) { + if( instance_id == 0 ) { instance_id = script_instancegetid(st); }