summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-02-09 07:32:58 +0100
committerGitHub <noreply@github.com>2018-02-09 07:32:58 +0100
commiteb0d54e10cf59a72c78dae6101c12a8de0c9d381 (patch)
tree848f3e978f1c89ee2ac2b9ce12562741f84c8938
parent19c94017a31d86f7848085162ffb741770975128 (diff)
parentda1b096806c868b1e9f4a82b88d05a6b032c1a63 (diff)
downloadhercules-eb0d54e10cf59a72c78dae6101c12a8de0c9d381.tar.gz
hercules-eb0d54e10cf59a72c78dae6101c12a8de0c9d381.tar.bz2
hercules-eb0d54e10cf59a72c78dae6101c12a8de0c9d381.tar.xz
hercules-eb0d54e10cf59a72c78dae6101c12a8de0c9d381.zip
Merge pull request #1968 from 4144/fixclancrash
Fix different clan issues.
-rw-r--r--src/map/clan.c5
-rw-r--r--src/map/clif.c2
2 files changed, 5 insertions, 2 deletions
diff --git a/src/map/clan.c b/src/map/clan.c
index b67726b37..6855e449d 100644
--- a/src/map/clan.c
+++ b/src/map/clan.c
@@ -103,7 +103,7 @@ struct map_session_data *clan_getonlinesd(struct clan *c)
int i;
nullpo_retr(NULL, c);
- ARR_FIND(0, VECTOR_LENGTH(c->members), i, VECTOR_INDEX(c->members, i).sd != NULL);
+ ARR_FIND(0, VECTOR_LENGTH(c->members), i, (VECTOR_INDEX(c->members, i).sd != NULL && VECTOR_INDEX(c->members, i).online == 1));
return (i < VECTOR_LENGTH(c->members)) ? VECTOR_INDEX(c->members, i).sd : NULL;
}
@@ -294,6 +294,7 @@ void clan_member_online(struct map_session_data *sd, bool first)
if (c->kick_time > 0 && inactivity > c->kick_time) {
if (m->online == 1) {
m->online = 0;
+ m->sd = NULL;
c->connect_member--;
c->member_count--;
}
@@ -306,6 +307,7 @@ void clan_member_online(struct map_session_data *sd, bool first)
return;
}
+ m->sd = sd;
m->online = 1;
m->last_login = sd->status.last_login;
}
@@ -403,6 +405,7 @@ void clan_member_offline(struct map_session_data *sd)
if (i != INDEX_NOT_FOUND && VECTOR_INDEX(c->members, i).online == 1) {
// Only if it is online, because unit->free is called twice
VECTOR_INDEX(c->members, i).online = 0;
+ VECTOR_INDEX(c->members, i).sd = NULL;
c->connect_member--;
}
clif->clan_onlinecount(c);
diff --git a/src/map/clif.c b/src/map/clif.c
index 8adb1ae58..ea239ba21 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -673,7 +673,7 @@ bool clif_send(const void* buf, int len, struct block_list* bl, enum send_target
nullpo_retr(false, c);
for (i = 0; i < VECTOR_LENGTH(c->members); i++) {
- if ((sd = VECTOR_INDEX(c->members, i).sd) == NULL || (fd = sd->fd) <= 0)
+ if (VECTOR_INDEX(c->members, i).online == 0 || (sd = VECTOR_INDEX(c->members, i).sd) == NULL || (fd = sd->fd) <= 0)
continue;
WFIFOHEAD(fd, len);
memcpy(WFIFOP(fd, 0), buf, len);