summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormeko <mekolat@users.noreply.github.com>2015-07-05 13:18:09 -0400
committermeko <mekolat@users.noreply.github.com>2015-07-05 13:18:09 -0400
commit98e908eec29e9b5b02fb7d7bf29886dfeb98c7dd (patch)
tree3c6c6812614dd5e77a65450176b9cc94f2a41d71
parentaaa7c09e2d0846734213dd6577b7c99dfe8c79c0 (diff)
parent21b5b56e7428a85c2dd6f50d19ca966b964d2bd1 (diff)
downloadtmwa-15.7.06.tar.gz
tmwa-15.7.06.tar.bz2
tmwa-15.7.06.tar.xz
tmwa-15.7.06.zip
Merge pull request #126 from mekolat/fix2v15.7.06
fix getmapusers
-rw-r--r--CHANGELOG2
-rw-r--r--src/map/map.cpp4
-rw-r--r--src/map/script-fun.cpp23
3 files changed, 19 insertions, 10 deletions
diff --git a/CHANGELOG b/CHANGELOG
index c51bc5e..0387af1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,5 @@
+v15.7.06
+ - another fix for "do not count hidden players with getmapusers builtin"
v15.7.05
- fix for "do not count hidden players with getmapusers builtin"
v15.6.30
diff --git a/src/map/map.cpp b/src/map/map.cpp
index 97b9e2e..d40977f 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -183,7 +183,7 @@ int map_addblock(dumb_ptr<block_list> bl)
if (bl->bl_next)
bl->bl_next->bl_prev = bl;
m->blocks.ref(x / BLOCK_SIZE, y / BLOCK_SIZE).normal = bl;
- if (bl->bl_type == BL::PC && !bool(bl->is_player()->status.option & Opt0::HIDE))
+ if (bl->bl_type == BL::PC)
m->users++;
}
@@ -211,7 +211,7 @@ int map_delblock(dumb_ptr<block_list> bl)
return 0;
}
- if (bl->bl_type == BL::PC && !bool(bl->is_player()->status.option & Opt0::HIDE))
+ if (bl->bl_type == BL::PC)
bl->bl_m->users--;
if (bl->bl_next)
diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 2822550..5e55e53 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -1752,29 +1752,36 @@ void builtin_getusers(ScriptState *st)
* マップ指定ユーザー数所得
*------------------------------------------
*/
+ static
+ void builtin_getareausers_sub(dumb_ptr<block_list> bl, int *users)
+ {
+ if (bool(bl->is_player()->status.option & Opt0::HIDE))
+ return;
+ (*users)++;
+ }
+
static
void builtin_getmapusers(ScriptState *st)
{
+ int users = 0;
MapName str = stringish<MapName>(ZString(conv_str(st, &AARG(0))));
P<map_local> m = TRY_UNWRAP(map_mapname2mapid(str),
{
push_int<ScriptDataInt>(st->stack, -1);
return;
});
- push_int<ScriptDataInt>(st->stack, m->users);
+ map_foreachinarea(std::bind(builtin_getareausers_sub, ph::_1, &users),
+ m,
+ 0, 0,
+ m->xs, m->ys,
+ BL::PC);
+ push_int<ScriptDataInt>(st->stack, users);
}
/*==========================================
* エリア指定ユーザー数所得
*------------------------------------------
*/
-static
-void builtin_getareausers_sub(dumb_ptr<block_list> bl, int *users)
-{
- if (bool(bl->is_player()->status.option & Opt0::HIDE))
- return;
- (*users)++;
-}
static
void builtin_getareausers_living_sub(dumb_ptr<block_list> bl, int *users)