From d1438cbd7c18ab01d2baf57912c958ba8b804e6c Mon Sep 17 00:00:00 2001 From: Kenpachi Developer Date: Tue, 7 Jan 2020 23:47:20 +0100 Subject: Re-added mapflag restrictions to warpparty() and introduced a flag to disable them as requested. --- src/map/script.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/map/script.c b/src/map/script.c index 9881f8d97..f450549ff 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -6757,7 +6757,7 @@ static BUILDIN(warpchar) * Warps a party to a specific/random map or save point. * * @code{.herc} - * warpparty("", , , {, ""{, }}); + * warpparty("", , , {{, }, ""{, }}); * @endcode * **/ @@ -6819,23 +6819,47 @@ static BUILDIN(warpparty) } for (int i = 0; i < MAX_PARTY; i++) { - const bool include_leader = script_hasdata(st, 7) ? script_getnum(st, 7) : true; - const char *m_name_from = script_hasdata(st, 6) ? script_getstr(st, 6) : NULL; + if ((p_sd = p->data[i].sd) == NULL || p_sd->status.party_id != p_id || pc_isdead(p_sd)) + continue; + + int offset = 0; + bool ignore_mapflags = false; + + if (script_hasdata(st, 6) && script_isinttype(st, 6)) { + offset = 1; + ignore_mapflags = (script_getnum(st, 6) != 0); + } + + if (!ignore_mapflags) { + if (((type == 0 || type > 2) && map->list[p_sd->bl.m].flag.nowarp == 1) || + (type > 0 && map->list[p_sd->bl.m].flag.noreturn == 1)) + continue; + } + + const bool include_leader = script_hasdata(st, 7 + offset) ? script_getnum(st, 7 + offset) : true; if (p->party.member[i].online == 0 || (!include_leader && p->party.member[i].leader == 1)) continue; - if ((p_sd = p->data[i].sd) == NULL || p_sd->status.party_id != p_id || pc_isdead(p_sd)) - continue; + const char *m_name_from = script_hasdata(st, 6 + offset) ? script_getstr(st, 6 + offset) : NULL; + + if (m_name_from != NULL && script->mapindexname2id(st, m_name_from) == 0) { + ShowError("script:%s: Source map not found! (%s)\n", script->getfuncname(st), m_name_from); + script_pushint(st, 0); + return false; + } if (m_name_from != NULL && strcmp(m_name_from, map->list[p_sd->bl.m].name) != 0) continue; - if (type > 1) + if (type == 1) { + map_index = p_sd->status.save_point.map; + x = p_sd->status.save_point.x; + y = p_sd->status.save_point.y; + } + + if (type > 0) pc->setpos(p_sd, map_index, x, y, CLR_TELEPORT); - else if (type == 1) - pc->setpos(p_sd, p_sd->status.save_point.map, p_sd->status.save_point.x, - p_sd->status.save_point.y, CLR_TELEPORT); else pc->randomwarp(p_sd, CLR_TELEPORT); } -- cgit v1.2.3-70-g09d2