diff options
author | Asheraf <acheraf1998@gmail.com> | 2018-06-05 08:08:49 +0000 |
---|---|---|
committer | Asheraf <acheraf1998@gmail.com> | 2018-06-05 08:08:49 +0000 |
commit | 97dc1ef1695404ea5276813616a17653439ede46 (patch) | |
tree | bff79281a9940fa2a28ffa729858296c0965fa56 /src | |
parent | fb16806ce0588414c5b808df535b72ef9e7ff6ba (diff) | |
download | hercules-97dc1ef1695404ea5276813616a17653439ede46.tar.gz hercules-97dc1ef1695404ea5276813616a17653439ede46.tar.bz2 hercules-97dc1ef1695404ea5276813616a17653439ede46.tar.xz hercules-97dc1ef1695404ea5276813616a17653439ede46.zip |
Update buildin instance_create to follow official behaviour
Diffstat (limited to 'src')
-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 d9350081a..0fba00dd5 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -21158,6 +21158,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); @@ -21170,22 +21171,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; } |