Small adjustments for the instance system

* Follow up to 32c829d.
* Added a missing break on guild type instance creation.
- Thanks to @Canoe!
* Added instance name back to script command instance_enter.
- This will present the proper error message when trying to enter another instance.
This commit is contained in:
aleos89 2016-05-26 09:06:49 -04:00
parent 5ac2292cc3
commit 161a4c01c9
17 changed files with 36 additions and 31 deletions

View File

@ -8151,7 +8151,7 @@ that fails, the script will come to a halt.
---------------------------------------
*instance_enter({<x>,<y>,<char_id>});
*instance_enter("<instance name>",{<x>,<y>,<char_id>});
Warps player to the specified instance after the script terminates. The map and
coordinates are located in 'db/(pre-)re/instance_db.txt'.

View File

@ -291,7 +291,7 @@ e_tower,81,105,0 script Tower Protection Stone 406,{
}
L_Enter:
switch(instance_enter()) {
switch(instance_enter("Endless Tower")) {
case 3:
mes "An unknown error has occurred.";
close;

View File

@ -192,7 +192,7 @@ nyd_dun02,100,201,3 script Yggdrasil Gatekeeper 111,8,8,{
close;
L_Enter:
switch(instance_enter()) {
switch(instance_enter("Nidhoggur's Nest")) {
case 3:
mes "[Yggdrasil Gatekeeper]";
mes "An unknown error has occurred.";

View File

@ -84,7 +84,7 @@ gef_fild10,242,202,0 script Dimensional Gorge Piece 406,{
mes "In order to generate a dungeon you must be the Party Leader and have at least 2 members in the party.";
close;
L_Enter:
switch(instance_enter()) {
switch(instance_enter("Orc's Memory")) {
case 3:
mes "An unknown error has occurred.";
close;

View File

@ -214,7 +214,7 @@ monk_test,306,151,3 script Grave of Baphomet#edq 111,{
//set .@ins_bapho_check2,checkquest(3045,PLAYTIME);
if (.@ins_bapho_check == -1) {
switch(instance_enter()) {
switch(instance_enter("Sealed Catacomb")) {
case 3:
case 2:
mes "It's cold to the touch. It doesn't respond.";

View File

@ -74,7 +74,7 @@ ma_scene01,174,179,4 script Taho 541,{
mes "Now I'm weaving, so you can go down when I'm done.";
close;
case 2:
switch(instance_enter()) {
switch(instance_enter(.@md_name$)) {
case 3:
mes "[Taho]";
mes "An unknown error occurred.";

View File

@ -282,7 +282,7 @@ L_Enter:
cutin "",255;
end;
case 2:
switch(instance_enter()) {
switch(instance_enter(.@md_name$)) {
case 3:
mes "[Nurse Maenne]";
mes "A critical situation has happened.";

View File

@ -126,7 +126,7 @@ OnTouch:
}
switch(select("Enter.:Turn back.")) {
case 1:
switch(instance_enter()) {
switch(instance_enter("Buwaya Cave")) {
case 3:
mes "[Guard]";
mes "Oh, now is not a good time.";

View File

@ -74,7 +74,7 @@ ecl_hub01,130,15,0 script It is closed shut. 844,{
mes "It is pretty difficult to guide an outsider like you.";
close;
}
switch (instance_enter()) {
switch (instance_enter(.@md_name$)) {
case 3:
mes "An unknown error has occurred.";
close;

View File

@ -139,7 +139,7 @@ bif_fild01,161,355,0 script Log Tunnel 844,{
next;
if(select("Enter the tunnel.:Give up.") == 2)
close;
switch(instance_enter()) {
switch(instance_enter("Mistwood Maze")) {
case 3:
mes "[Laphine Soldier]";
mes "Something doesn't feel right. Looks like something dangerous is going on, so you'd better turn back today.";

View File

@ -432,7 +432,7 @@ mal_in01,160,34,4 script Missing, the Cleaner 545,{
}
end;
L_Enter:
switch(instance_enter()) {
switch(instance_enter("Culvert")) {
case 3:
mes "An unknown error has occurred.";
close;

View File

@ -119,7 +119,7 @@ mal_dun01,153,237,5 script Weird Entrance 844,{
switch(select("Go in.:Stop.")) {
case 1:
if (countitem(6442)) {
switch(instance_enter()) {
switch(instance_enter("Octopus Cave")) {
case 3:
mes "[Starfish]";
mes "Ah, now is not the time...";

View File

@ -51,7 +51,7 @@ glast_01,204,273,6 script Hugin#ghinstance 755,{
mes "The time gap was created. When you're ready, talk to me again.";
close;
case 2:
switch(instance_enter()) {
switch(instance_enter(.@md_name$)) {
case 3:
mes "An unknown error has occurred.";
close;

View File

@ -877,7 +877,7 @@ lhz_dun04,147,279,0 script Laboratory Entrance#memo CLEAR_NPC,{
mes "You have stopped entering to Wolfchev's laboratory.";
close;
}
if (instance_enter() != 0) { // probably missing failure cases
if (instance_enter("Wolfchev's Laboratory") != 0) { // probably missing failure cases
mes "^FF0000Warning^000000";
mes ""+ strcharinfo(0) +". . .";
mes "^FF0000Unregistered personnel^000000";

View File

@ -499,10 +499,10 @@ int instance_addmap(unsigned short instance_id) {
* instance_id : where to search
* result : mapid of map "name" in this instance
*------------------------------------------*/
int instance_mapname2mapid(const char *name, unsigned short instance_id)
int16 instance_mapname2mapid(const char *name, unsigned short instance_id)
{
struct instance_data *im;
int m = map_mapname2mapid(name);
int16 m = map_mapname2mapid(name);
char iname[MAP_NAME_LENGTH];
int i;
@ -632,29 +632,31 @@ int instance_destroy(unsigned short instance_id)
/*==========================================
* Allows a user to enter an instance
*------------------------------------------*/
int instance_enter(struct map_session_data *sd, unsigned short instance_id)
int instance_enter(struct map_session_data *sd, unsigned short instance_id, const char *name)
{
struct instance_db *db = instance_searchtype_db(instance_data[instance_id].type);
struct instance_db *db = instance_searchname_db(name);
nullpo_retr(-1, sd);
if (db == NULL)
return 2;
return instance_enter_position(sd, instance_id, db->enter.x, db->enter.y);
return instance_enter_position(sd, instance_id, name, db->enter.x, db->enter.y);
}
/*==========================================
* Warp a user into instance
*------------------------------------------*/
int instance_enter_position(struct map_session_data *sd, unsigned short instance_id, short x, short y)
int instance_enter_position(struct map_session_data *sd, unsigned short instance_id, const char *name, short x, short y)
{
struct instance_data *im = &instance_data[instance_id];
struct instance_db *db = instance_searchname_db(name);
struct party_data *p = NULL;
struct guild *g = NULL;
int16 m;
nullpo_retr(-1, sd);
nullpo_retr(3, db);
switch(instance_data[instance_id].mode) {
case IM_NONE:
@ -689,9 +691,11 @@ int instance_enter_position(struct map_session_data *sd, unsigned short instance
if (im->state != INSTANCE_BUSY)
return 3;
if (im->type != db->id)
return 3;
// Does the instance match?
if ((m = instance_mapname2mapid(map_mapid2mapname(im->map[0]->m), instance_id)) < 0)
if ((m = instance_mapname2mapid(StringBuf_Value(db->enter.mapname), instance_id)) < 0)
return 3;
if (pc_setpos(sd, map_id2index(m), x, y, CLR_OUTSIGHT))
@ -941,7 +945,7 @@ void do_reload_instance(void)
if (instance_data[map[sd->bl.m].instance_id].mode == IM_GUILD && (!(g = guild_search(sd->status.guild_id)) || g->instance_id != map[sd->bl.m].instance_id)) // Someone not in guild is on instance map
continue;
im = &instance_data[p->instance_id];
if((db = instance_searchtype_db(im->type)) != NULL && !instance_enter(sd, i)) { // All good
if((db = instance_searchtype_db(im->type)) != NULL && !instance_enter(sd, i, StringBuf_Value(db->name))) { // All good
clif_displaymessage(sd->fd, msg_txt(sd,515)); // Instance has been reloaded
instance_reqinfo(sd,p->instance_id);
} else // Something went wrong

View File

@ -68,12 +68,12 @@ void instance_getsd(unsigned short instance_id, struct map_session_data **sd, en
int instance_create(int owner_id, const char *name, enum instance_mode mode);
int instance_destroy(unsigned short instance_id);
int instance_enter(struct map_session_data *sd, unsigned short instance_id);
int instance_enter_position(struct map_session_data *sd, unsigned short instance_id, short x, short y);
int instance_enter(struct map_session_data *sd, unsigned short instance_id, const char *name);
int instance_enter_position(struct map_session_data *sd, unsigned short instance_id, const char *name, short x, short y);
int instance_reqinfo(struct map_session_data *sd, unsigned short instance_id);
int instance_addusers(unsigned short instance_id);
int instance_delusers(unsigned short instance_id);
int instance_mapname2mapid(const char *name, unsigned short instance_id);
int16 instance_mapname2mapid(const char *name, unsigned short instance_id);
int instance_addmap(unsigned short instance_id);
void instance_addnpc(struct instance_data *im);

View File

@ -18892,6 +18892,7 @@ BUILDIN_FUNC(instance_create)
case IM_GUILD:
if (sd)
owner_id = sd->status.guild_id;
break;
default:
ShowError("buildin_instance_create: Invalid instance mode (instance name: %s)\n", script_getstr(st, 2));
return SCRIPT_CMD_FAILURE;
@ -18937,16 +18938,16 @@ BUILDIN_FUNC(instance_destroy)
BUILDIN_FUNC(instance_enter)
{
struct map_session_data *sd = NULL;
int x = script_hasdata(st,2) ? script_getnum(st, 2) : -1;
int y = script_hasdata(st,3) ? script_getnum(st, 3) : -1;
int x = script_hasdata(st,3) ? script_getnum(st, 3) : -1;
int y = script_hasdata(st,4) ? script_getnum(st, 4) : -1;
if (!script_charid2sd(4,sd))
if (!script_charid2sd(5,sd))
return SCRIPT_CMD_FAILURE;
if (x != -1 && y != -1)
script_pushint(st, instance_enter_position(sd, script_instancegetid(st), x, y));
script_pushint(st, instance_enter_position(sd, script_instancegetid(st), script_getstr(st, 2), x, y));
else
script_pushint(st, instance_enter(sd, script_instancegetid(st)));
script_pushint(st, instance_enter(sd, script_instancegetid(st), script_getstr(st, 2)));
return SCRIPT_CMD_SUCCESS;
}
@ -21917,7 +21918,7 @@ struct script_function buildin_func[] = {
BUILDIN_DEF(instance_create,"s??"),
BUILDIN_DEF(instance_destroy,"?"),
BUILDIN_DEF(instance_id,""),
BUILDIN_DEF(instance_enter,"???"),
BUILDIN_DEF(instance_enter,"s???"),
BUILDIN_DEF(instance_npcname,"s?"),
BUILDIN_DEF(instance_mapname,"s?"),
BUILDIN_DEF(instance_warpall,"sii?"),