X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Ffjoin.cpp;h=4ec6e1dbb0f3d502209775cbde367ce325455ba3;hb=b111d5098fe1ee306d2718c82c72f969db9d183d;hp=71d837b2840b4bf0b150029ac935fd12a484115e;hpb=772dad05a42e20e03a5445b84a7f6612ee44283f;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/fjoin.cpp b/src/modules/m_spanningtree/fjoin.cpp index 71d837b28..4ec6e1dbb 100644 --- a/src/modules/m_spanningtree/fjoin.cpp +++ b/src/modules/m_spanningtree/fjoin.cpp @@ -66,7 +66,8 @@ CmdResult CommandFJoin::Handle(const std::vector& params, User *src bool created = !chan; /* True if the channel doesnt exist here yet */ std::string item; /* One item in the list of nicks */ - TreeSocket* src_socket = Utils->FindServer(srcuser->server)->GetRoute()->GetSocket(); + TreeServer* src_server = Utils->FindServer(srcuser->server); + TreeSocket* src_socket = src_server->GetRoute()->GetSocket(); if (!TS) { @@ -85,8 +86,8 @@ CmdResult CommandFJoin::Handle(const std::vector& params, User *src time_t ourTS = chan->age; if (TS != ourTS) - ServerInstance->SNO->WriteToSnoMask('d', "Merge FJOIN received for %s, ourTS: %lu, TS: %lu, difference: %lu", - chan->name.c_str(), (unsigned long)ourTS, (unsigned long)TS, (unsigned long)(ourTS - TS)); + ServerInstance->SNO->WriteToSnoMask('d', "Merge FJOIN received for %s, ourTS: %lu, TS: %lu, difference: %ld", + chan->name.c_str(), (unsigned long)ourTS, (unsigned long)TS, (long)(ourTS - TS)); /* If our TS is less than theirs, we dont accept their modes */ if (ourTS < TS) { @@ -106,6 +107,14 @@ CmdResult CommandFJoin::Handle(const std::vector& params, User *src chan->ClearInvites(); param_list.push_back(channel); this->RemoveStatus(ServerInstance->FakeClient, param_list); + + // XXX: If the channel does not exist in the chan hash at this point, create it so the remote modes can be applied on it. + // This happens to 0-user permanent channels on the losing side, because those are removed (from the chan hash, then + // deleted later) as soon as the permchan mode is removed from them. + if (ServerInstance->FindChan(channel) == NULL) + { + chan = new Channel(channel, TS); + } } // The silent case here is ourTS == TS, we don't need to remove modes here, just to merge them later on. } @@ -113,19 +122,38 @@ CmdResult CommandFJoin::Handle(const std::vector& params, User *src /* First up, apply their modes if they won the TS war */ if (apply_other_sides_modes) { - unsigned int idx = 2; + // Need to use a modestacker here due to maxmodes + irc::modestacker stack(true); + std::vector::const_iterator paramit = params.begin() + 3; + const std::vector::const_iterator lastparamit = ((params.size() > 3) ? (params.end() - 1) : params.end()); + for (std::string::const_iterator i = params[2].begin(); i != params[2].end(); ++i) + { + ModeHandler* mh = ServerInstance->Modes->FindMode(*i, MODETYPE_CHANNEL); + if (!mh) + continue; + + std::string modeparam; + if ((paramit != lastparamit) && (mh->GetNumParams(true))) + { + modeparam = *paramit; + ++paramit; + } + + stack.Push(*i, modeparam); + } + std::vector modelist; // Mode parser needs to know what channel to act on. modelist.push_back(params[0]); - /* Remember, params[params.size() - 1] is nicklist, and we don't want to apply *that* */ - for (idx = 2; idx != (params.size() - 1); idx++) + while (stack.GetStackedLine(modelist)) { - modelist.push_back(params[idx]); + ServerInstance->Modes->Process(modelist, srcuser, true); + modelist.erase(modelist.begin() + 1, modelist.end()); } - ServerInstance->SendMode(modelist, srcuser); + ServerInstance->Modes->Process(modelist, srcuser, true); } /* Now, process every 'modes,nick' pair */ @@ -169,11 +197,11 @@ CmdResult CommandFJoin::Handle(const std::vector& params, User *src for (std::string::iterator x = modes.begin(); x != modes.end(); ++x) modestack.Push(*x, who->nick); - Channel::JoinUser(who, channel.c_str(), true, "", route_back_again->bursting, TS); + Channel::JoinUser(who, channel.c_str(), true, "", src_server->bursting, TS); } else { - ServerInstance->Logs->Log("m_spanningtree",SPARSE, "Ignored nonexistant user %s in fjoin to %s (probably quit?)", usr, channel.c_str()); + ServerInstance->Logs->Log("m_spanningtree",SPARSE, "Ignored nonexistent user %s in fjoin to %s (probably quit?)", usr, channel.c_str()); continue; } }