summaryrefslogtreecommitdiff
path: root/src/map/channel.c
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2018-11-13 17:40:48 +0100
committerHaru <haru@dotalux.com>2018-11-13 17:40:48 +0100
commit60643f1b7bbc2a21f44ab6663dee03d962ff6d6b (patch)
treeefe41e13e8014fe394476ce68c3e78392824de56 /src/map/channel.c
parent35ee16dd3908c021752e439a4fe4ea9e83af9ec0 (diff)
downloadhercules-60643f1b7bbc2a21f44ab6663dee03d962ff6d6b.tar.gz
hercules-60643f1b7bbc2a21f44ab6663dee03d962ff6d6b.tar.bz2
hercules-60643f1b7bbc2a21f44ab6663dee03d962ff6d6b.tar.xz
hercules-60643f1b7bbc2a21f44ab6663dee03d962ff6d6b.zip
Fix an issue that caused some guild channels not to be left when leaving allychat
- The issue was caused by an array compaction while iterating through the array members. - A visible effect was that under certain conditions (depending on the alliance size), a character that left a guild could still see allychat messages from some of the allied guilds. Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/channel.c')
-rw-r--r--src/map/channel.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/map/channel.c b/src/map/channel.c
index 86ca44ea2..e27e9fb0b 100644
--- a/src/map/channel.c
+++ b/src/map/channel.c
@@ -565,7 +565,8 @@ static void channel_guild_leave_alliance(const struct guild *g_source, const str
static void channel_quit_guild(struct map_session_data *sd)
{
nullpo_retv(sd);
- for (int i = 0; i < VECTOR_LENGTH(sd->channels); i++) { // FIXME
+ for (int i = VECTOR_LENGTH(sd->channels) - 1; i >= 0; i--) {
+ // Loop downward to avoid issues when channel->leave() compacts the array
struct channel_data *chan = VECTOR_INDEX(sd->channels, i);
if (chan->type != HCS_TYPE_ALLY)