From 190672e6da2f3fd3bb740ba886693b0e3c3727ba Mon Sep 17 00:00:00 2001 From: gumi Date: Sun, 18 Mar 2018 18:56:49 -0400 Subject: skip @hidden players (such as bots) when iterating with @hugo --- src/map/atcommand.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/map') diff --git a/src/map/atcommand.cpp b/src/map/atcommand.cpp index 81b0e2b..a21848b 100644 --- a/src/map/atcommand.cpp +++ b/src/map/atcommand.cpp @@ -4897,11 +4897,29 @@ ATCE atcommand_jump_iterate(Session *s, dumb_ptr sd, if (!pl_sd) pl_sd = get_start(); - if (pl_sd == sd) + for (int i = 0, e = map_getusers(); i <= e; ++i) { + if (pl_sd != sd && !bool(pl_sd->status.option & Opt0::HIDE)) + break; + + // the target player is either hidden or is ourselves, so find another one pl_sd = get_next(pl_sd); if (!pl_sd) pl_sd = get_start(); + + if (i == e) + { + // we reached the end of the list, and couldn't find anyone else + if (e == map_getusers()) + { + pl_sd = sd; // silently warp to ourselves if no new user came online + break; + } + + // or, if number of online players changed, try again + i = 0; + e = map_getusers(); + } } if (pl_sd->bl_m->flag.get(MapFlag::NOWARPTO) -- cgit v1.2.3-60-g2f50