+ }
+ else
+ flags |= HasFlag(sptr, FLAG_TS8) ? CHFL_SERVOPOK : 0;
+ /* Always copy the timestamp when it is older, that is the only way to
+ ensure network-wide synchronization of creation times.
+ We now also copy a creation time that only 1 second younger...
+ this is needed because the timestamp must be incremented
+ by one when someone joins an existing, but empty, channel.
+ However, this is only necessary when the channel is still
+ empty (also here) and when this channel doesn't have +A set.
+
+ To prevent this from allowing net-rides on the channel, we
+ clear all modes from the channel.
+
+ (Scenario for a net ride: c1 - s1 - s2 - c2, with c1 the only
+ user in the channel; c1 parts and rejoins, gaining ops.
+ Before s2 sees c1's part, c2 joins the channel and parts
+ immediately. s1 sees c1 part, c1 create, c2 join, c2 part;
+ c2's join resets the timestamp. s2 sees c2 join, c2 part, c1
+ part, c1 create; but since s2 sees the channel as a zannel or
+ non-existent, it does not bounce the create with the newer
+ timestamp.)
+ */
+ if (creation && (creation < chptr->creationtime ||
+ (!chptr->mode.apass[0] && chptr->users == 0))) {
+ struct Membership *member;
+ struct ModeBuf mbuf;
+
+ chptr->creationtime = creation;
+ /* Wipe out the current modes on the channel. */
+ modebuf_init(&mbuf, sptr, cptr, chptr, MODEBUF_DEST_CHANNEL | MODEBUF_DEST_HACK3);
+
+ modebuf_mode(&mbuf, MODE_DEL | chptr->mode.mode);
+ chptr->mode.mode &= MODE_BURSTADDED | MODE_WASDELJOINS;
+
+ if (chptr->mode.limit) {
+ modebuf_mode_uint(&mbuf, MODE_DEL | MODE_LIMIT, chptr->mode.limit);
+ chptr->mode.limit = 0;
+ }
+
+ if (chptr->mode.key[0]) {
+ modebuf_mode_string(&mbuf, MODE_DEL | MODE_KEY, chptr->mode.key, 0);
+ chptr->mode.key[0] = '\0';
+ }
+
+ if (chptr->mode.upass[0]) {
+ modebuf_mode_string(&mbuf, MODE_DEL | MODE_UPASS, chptr->mode.upass, 0);
+ chptr->mode.upass[0] = '\0';
+ }
+
+ if (chptr->mode.apass[0]) {
+ modebuf_mode_string(&mbuf, MODE_DEL | MODE_APASS, chptr->mode.apass, 0);
+ chptr->mode.apass[0] = '\0';
+ }
+
+ for (member = chptr->members; member; member = member->next_member)
+ {
+ if (IsChanOp(member)) {
+ modebuf_mode_client(&mbuf, MODE_DEL | MODE_CHANOP, member->user, OpLevel(member));
+ member->status &= ~CHFL_CHANOP;
+ }
+ if (HasVoice(member)) {
+ modebuf_mode_client(&mbuf, MODE_DEL | MODE_VOICE, member->user, OpLevel(member));
+ member->status &= ~CHFL_VOICE;
+ }
+ }
+ modebuf_flush(&mbuf);
+ }
+ }