summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2014-12-17 02:04:11 +0100
committerHaru <haru@dotalux.com>2014-12-17 02:05:52 +0100
commit251f5d933c49fc2dcb52cd76a2570cae4cb827fe (patch)
treec4ebcdb9aef9efa41d5e2a3584130ecf61fa4e68 /src/map
parent57efadd40016af332be6c19f5f5e84b4104805bb (diff)
downloadhercules-251f5d933c49fc2dcb52cd76a2570cae4cb827fe.tar.gz
hercules-251f5d933c49fc2dcb52cd76a2570cae4cb827fe.tar.bz2
hercules-251f5d933c49fc2dcb52cd76a2570cae4cb827fe.tar.xz
hercules-251f5d933c49fc2dcb52cd76a2570cae4cb827fe.zip
Fixed a compile error on MSVC < 2013
Thanks to Ind, Michieru Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map')
-rw-r--r--src/map/script.c46
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;