summaryrefslogtreecommitdiff
path: root/src/emap
diff options
context:
space:
mode:
authoracsvln <acsvln@disroot.org>2018-10-28 17:35:03 +0300
committeracsvln <acsvln@disroot.org>2018-10-28 17:36:50 +0300
commiteaa15fb6aaf52bf63c8fffafe8ed955d8647189e (patch)
tree011d05c2e6aecb38fc38792824d1f1fc6322ce9e /src/emap
parent8fd6db7f3cff3ffe08cbf4a95b573f1f88d2cd77 (diff)
downloadevol-hercules-eaa15fb6aaf52bf63c8fffafe8ed955d8647189e.tar.gz
evol-hercules-eaa15fb6aaf52bf63c8fffafe8ed955d8647189e.tar.bz2
evol-hercules-eaa15fb6aaf52bf63c8fffafe8ed955d8647189e.tar.xz
evol-hercules-eaa15fb6aaf52bf63c8fffafe8ed955d8647189e.zip
Implementation of function jump_iterate rewrited
Removed async map->get users() function call due to potential bugs
Diffstat (limited to 'src/emap')
-rw-r--r--src/emap/atcommand.c67
1 files changed, 30 insertions, 37 deletions
diff --git a/src/emap/atcommand.c b/src/emap/atcommand.c
index e37a320..32ed750 100644
--- a/src/emap/atcommand.c
+++ b/src/emap/atcommand.c
@@ -68,7 +68,7 @@ const char* eatcommand_msgfd_pre(int *fdPtr,
return lang_pctrans(atcommand->msg_table[0][msg_number], sd);
}
-bool jump_iterate(struct map_session_data *sd, bool forward)
+static bool eatcommand_jump_iterate(struct map_session_data *sd, bool forward)
{
struct SessionExt *session_ext = session_get_bysd(sd);
@@ -78,21 +78,16 @@ bool jump_iterate(struct map_session_data *sd, bool forward)
struct map_session_data *pl_sd = map->id2sd(session_ext->jump_iterate_id);
struct map_session_data *buff_sd = NULL;
- bool has_next = false;
int fd = NULL != pl_sd ? pl_sd->fd : sd->fd;
- int user_count = map->getusers();
-
- if (user_count == 1)
- {
- session_ext->jump_iterate_id = 0;
- clif->message(sd->fd, "You are alone at map server!");
- return true;
- }
+ bool has_skipped = false;
+ int start_fd = fd;
int max_counter = sockt->fd_max;
do
{
+ bool has_next = false;
+
if (forward)
{
fd++;
@@ -108,37 +103,37 @@ bool jump_iterate(struct map_session_data *sd, bool forward)
{
fd = (forward ? -1 : sockt->fd_max + 1);
}
- else
+ else if (sockt->session_is_active(fd))
{
- if (sockt->session_is_active(fd))
+ buff_sd = sockt->session[fd]->session_data;
+
+ if (
+ NULL != buff_sd &&
+ (
+ (sd == buff_sd) ||
+ (map->list[buff_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE)) ||
+ (sd->bl.m == buff_sd->bl.m && sd->bl.x == buff_sd->bl.x && sd->bl.y == buff_sd->bl.y)
+ )
+ )
{
- buff_sd = sockt->session[fd]->session_data;
-
- if (NULL != buff_sd)
+ if (sd != buff_sd)
{
- if (
- (sd == buff_sd) ||
- (map->list[buff_sd->bl.m].flag.nowarpto && !pc_has_permission(sd, PC_PERM_WARP_ANYWHERE))
- )
- {
- buff_sd = NULL;
- }
- else if (sd->bl.m == buff_sd->bl.m && sd->bl.x == buff_sd->bl.x && sd->bl.y == buff_sd->bl.y)
- {
- if (user_count == 2) {
- return true;
- }
-
- buff_sd = NULL;
- }
+ has_skipped = true;
}
+
+ buff_sd = NULL;
}
}
--max_counter;
- } while (NULL == buff_sd && (max_counter >= 0));
+ } while ((NULL == buff_sd) && (fd != start_fd) && (max_counter >= 0));
- if (NULL != buff_sd)
+ if (NULL == buff_sd && !has_skipped)
+ {
+ session_ext->jump_iterate_id = 0;
+ clif->message(sd->fd, "You are alone at map server!");
+ }
+ else if (NULL != buff_sd)
{
char message[80];
@@ -149,11 +144,9 @@ bool jump_iterate(struct map_session_data *sd, bool forward)
clif->message(sd->fd, message);
session_ext->jump_iterate_id = buff_sd->bl.id;
-
- return true;
}
- return false;
+ return true;
}
ACMD2(setSkill)
@@ -223,12 +216,12 @@ ACMD2(slide)
ACMD3(hugo)
{
- return jump_iterate(sd, true);
+ return eatcommand_jump_iterate(sd, true);
}
ACMD3(linus)
{
- return jump_iterate(sd, false);
+ return eatcommand_jump_iterate(sd, false);
}
ACMD1(mapExit)