Skip to content

Commit

Permalink
Merge pull request #126 from mekolat/fix2
Browse files Browse the repository at this point in the history
fix getmapusers
  • Loading branch information
meko committed Jul 5, 2015
2 parents aaa7c09 + 21b5b56 commit 98e908e
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
}

Expand Down Expand Up @@ -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)
Expand Down
23 changes: 15 additions & 8 deletions src/map/script-fun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 98e908e

Please sign in to comment.