diff options
author | Haru <haru@dotalux.com> | 2018-06-22 00:20:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-22 00:20:29 +0200 |
commit | 3e3a0935340a607f6b4a4c6ff193de63e5d69430 (patch) | |
tree | 68e1554ea8174c0f63d44659306aad4f1a3fae97 /src/map/script.c | |
parent | b57232ac29732ff526eca750dee295a871861ed6 (diff) | |
parent | 82d5ed8ee5349e0338f1819ecf472efe95523ae9 (diff) | |
download | hercules-3e3a0935340a607f6b4a4c6ff193de63e5d69430.tar.gz hercules-3e3a0935340a607f6b4a4c6ff193de63e5d69430.tar.bz2 hercules-3e3a0935340a607f6b4a4c6ff193de63e5d69430.tar.xz hercules-3e3a0935340a607f6b4a4c6ff193de63e5d69430.zip |
Merge pull request #1924 from Asheraf/instance3
Update Instance generating behaviour
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/src/map/script.c b/src/map/script.c index 410a707f1..39552a441 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -21160,6 +21160,7 @@ BUILDIN(instance_create) const char *name; int owner_id, res; int type = IOT_PARTY; + struct map_session_data *sd = map->id2sd(st->rid); name = script_getstr(st, 2); owner_id = script_getnum(st, 3); @@ -21172,22 +21173,43 @@ BUILDIN(instance_create) } res = instance->create(owner_id, name, (enum instance_owner_type) type); - if( res == -4 ) { // Already exists - script_pushint(st, -1); - return true; - } else if( res < 0 ) { + if (sd != NULL) { + switch (res) { + case -4: // Already exists + clif->msgtable_str(sd, MSG_MDUNGEON_SUBSCRIPTION_ERROR_DUPLICATE, name); + break; + case -3: // No free instances + clif->msgtable_str(sd, MSG_MDUNGEON_SUBSCRIPTION_ERROR_EXIST, name); + break; + case -2: // Invalid type + clif->msgtable_str(sd, MSG_MDUNGEON_SUBSCRIPTION_ERROR_RIGHT, name); + break; + case -1: // Unknown + clif->msgtable_str(sd, MSG_MDUNGEON_SUBSCRIPTION_ERROR_UNKNOWN, name); + break; + default: + if (res < 0) + ShowError("buildin_instance_create: failed to unknown reason [%d].\n", res); + } + } else { const char *err; - switch(res) { - case -3: err = "No free instances"; break; - case -2: err = "Invalid party ID"; break; - case -1: err = "Invalid type"; break; - default: err = "Unknown"; break; + switch (res) { + case -3: + err = "No free instances"; + break; + case -2: + err = "Invalid party ID"; + break; + case -1: + err = "Invalid type"; + break; + default: + err = "Unknown"; + break; } - ShowError("buildin_instance_create: %s [%d].\n", err, res); - script_pushint(st, -2); - return true; + if (res < 0) + ShowError("buildin_instance_create: %s [%d].\n", err, res); } - script_pushint(st, res); return true; } |