diff options
-rw-r--r-- | src/map/script.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/src/map/script.c b/src/map/script.c index 3ccb6a45a..be73fe5b2 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -10091,12 +10091,13 @@ int buildin_getareausers_sub(struct block_list *bl,va_list ap) (*users)++; return 0; } + BUILDIN(getareausers) { int16 m = -1, x0, y0, x1, y1; int users = 0; int idx = 2; - struct npc_data *nd = NULL; + if (script_hasdata(st, 2) && script_isstringtype(st, 2)) { const char *str = script_getstr(st, 2); if ((m = map->mapname2mapid(str)) < 0) { @@ -10104,46 +10105,41 @@ BUILDIN(getareausers) return true; } idx = 3; - } - if (m == -1) - { - TBL_PC *sd = NULL; - sd = script->rid2sd(st); - if (!sd) - { + } else { + TBL_PC *sd = script->rid2sd(st); + if (!sd) { script_pushint(st, -1); return false; } m = sd->bl.m; } - if (st->oid) - nd = map->id2nd(st->oid); + if (script_hasdata(st, idx + 3)) { x0 = script_getnum(st, idx + 0); y0 = script_getnum(st, idx + 1); x1 = script_getnum(st, idx + 2); y1 = script_getnum(st, idx + 3); - } else if (script_hasdata(st, idx)) { - if (!nd) - { + } else if (st->oid) { + struct npc_data *nd = map->id2nd(st->oid); + if (!nd) { script_pushint(st, -1); return true; } - int sz = script_getnum(st, idx); - x0 = nd->bl.x - sz; - y0 = nd->bl.y - sz; - x1 = nd->bl.x + sz; - y1 = nd->bl.y + sz; - } else if (st->oid) { - if (!nd || nd->u.scr.xs == -1 || nd->u.scr.ys == -1) - { + if (script_hasdata(st, idx)) { + int range = script_getnum(st, idx); + x0 = nd->bl.x - range; + y0 = nd->bl.y - range; + x1 = nd->bl.x + range; + y1 = nd->bl.y + range; + } else if (nd->u.scr.xs != -1 && nd->u.scr.ys != -1) { + x0 = nd->bl.x - nd->u.scr.xs; + y0 = nd->bl.y - nd->u.scr.ys; + x1 = nd->bl.x + nd->u.scr.xs; + y1 = nd->bl.y + nd->u.scr.ys; + } else { script_pushint(st, -1); return true; } - x0 = nd->bl.x - nd->u.scr.xs; - y0 = nd->bl.y - nd->u.scr.ys; - x1 = nd->bl.x + nd->u.scr.xs; - y1 = nd->bl.y + nd->u.scr.ys; } else { script_pushint(st, -1); return false; |