diff options
-rw-r--r-- | include/channels.h | 4 | ||||
-rw-r--r-- | include/inspircd.h | 1 | ||||
-rw-r--r-- | include/mode.h | 5 | ||||
-rw-r--r-- | include/modules.h | 3 | ||||
-rw-r--r-- | include/users.h | 6 | ||||
-rw-r--r-- | src/channels.cpp | 4 | ||||
-rw-r--r-- | src/inspircd.cpp | 12 | ||||
-rw-r--r-- | src/mode.cpp | 5 | ||||
-rw-r--r-- | src/modules.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_callerid.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_delayjoin.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_nicklock.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_operprefix.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_permchannels.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 6 | ||||
-rw-r--r-- | src/users.cpp | 12 |
16 files changed, 34 insertions, 52 deletions
diff --git a/include/channels.h b/include/channels.h index 7b6999316..fb32f1156 100644 --- a/include/channels.h +++ b/include/channels.h @@ -94,10 +94,6 @@ class CoreExport Channel : public Extensible int maxbans; public: - /** Pointer to creator object - */ - InspIRCd* ServerInstance; - /** Creates a channel record and initialises it with default values * @throw Nothing at present. */ diff --git a/include/inspircd.h b/include/inspircd.h index a7eed47ff..45b219096 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -936,6 +936,7 @@ class CoreExport InspIRCd : public classbase } }; +extern InspIRCd* ServerInstance; ENTRYPOINT; template<class Cmd> diff --git a/include/mode.h b/include/mode.h index 0c367a1c2..db115a3c9 100644 --- a/include/mode.h +++ b/include/mode.h @@ -152,7 +152,6 @@ class CoreExport ModeHandler : public classbase int levelrequired; public: - static InspIRCd* ServerInstance; /** Module that created this mode. NULL for core modes */ Module* creator; @@ -425,10 +424,6 @@ typedef std::vector<ModeWatcher*>::iterator ModeWatchIter; class CoreExport ModeParser : public classbase { private: - /** - * Creator/owner pointer - */ - InspIRCd* ServerInstance; /** Mode handlers for each mode, to access a handler subtract * 65 from the ascii value of the mode letter. * The upper bit of the value indicates if its a usermode diff --git a/include/modules.h b/include/modules.h index 81381ab8b..4e960ec64 100644 --- a/include/modules.h +++ b/include/modules.h @@ -425,9 +425,6 @@ class ConfigReader; class CoreExport Module : public Extensible { public: - /** Creator/owner pointer - */ - InspIRCd* ServerInstance; /** File that this module was loaded from */ std::string ModuleSourceFile; diff --git a/include/users.h b/include/users.h index f91280139..505c43b9e 100644 --- a/include/users.h +++ b/include/users.h @@ -255,12 +255,6 @@ class CoreExport User : public EventHandler std::bitset<64> AllowedChanModes; public: - /** Pointer to creator. - * This is required to make use of core functions - * from within the User class. - */ - InspIRCd* ServerInstance; - static LocalIntExt NICKForced; static LocalStringExt OperQuit; diff --git a/src/channels.cpp b/src/channels.cpp index 3685f6604..7f2cefd2b 100644 --- a/src/channels.cpp +++ b/src/channels.cpp @@ -17,7 +17,7 @@ #include <cstdarg> #include "mode.h" -Channel::Channel(InspIRCd* Instance, const std::string &cname, time_t ts) : ServerInstance(Instance) +Channel::Channel(InspIRCd* Instance, const std::string &cname, time_t ts) { chan_hash::iterator findchan = ServerInstance->chanlist->find(cname); if (findchan != Instance->chanlist->end()) @@ -930,7 +930,7 @@ unsigned int Membership::getRank() unsigned int rv = 0; if (mchar) { - ModeHandler* mh = chan->ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL); + ModeHandler* mh = ServerInstance->Modes->FindMode(mchar, MODETYPE_CHANNEL); if (mh) rv = mh->GetPrefixRank(); } diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 3d80f5250..8f763e2b6 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -43,7 +43,7 @@ #include "caller.h" #include "testsuite.h" -InspIRCd* SI = NULL; +InspIRCd* ServerInstance = NULL; int* mysig = NULL; /** Seperate from the other casemap tables so that code *can* still exclusively rely on RFC casemapping @@ -351,6 +351,8 @@ InspIRCd::InspIRCd(int argc, char** argv) : WindowsIPC = 0; #endif + ServerInstance = this; + Extensible::Register(&User::NICKForced); Extensible::Register(&User::OperQuit); @@ -888,9 +890,9 @@ void InspIRCd::SetSignal(int signal) */ ENTRYPOINT { - SI = new InspIRCd(argc, argv); - mysig = &SI->s_signal; - SI->Run(); - delete SI; + new InspIRCd(argc, argv); + mysig = &ServerInstance->s_signal; + ServerInstance->Run(); + delete ServerInstance; return 0; } diff --git a/src/mode.cpp b/src/mode.cpp index 86438bf73..9c608c37a 100644 --- a/src/mode.cpp +++ b/src/mode.cpp @@ -49,8 +49,6 @@ /* +s (server notice masks) */ #include "modes/umode_s.h" -InspIRCd* ModeHandler::ServerInstance; - ModeHandler::ModeHandler(Module* Creator, char modeletter, ParamSpec Params, ModeType type) : mode(modeletter), parameters_taken(Params), list(false), m_type(type), m_paramtype(TR_TEXT), oper(false), prefix(0), count(0), levelrequired(HALFOP_VALUE), creator(Creator) @@ -941,9 +939,8 @@ void ModeHandler::RemoveMode(Channel* channel, irc::modestacker* stack) } } -ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance) +ModeParser::ModeParser(InspIRCd* Instance) { - ModeHandler::ServerInstance = Instance; ModeHandler* modes[] = { new ModeChannelSecret(Instance), diff --git a/src/modules.cpp b/src/modules.cpp index 979c42119..9664e817f 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -28,7 +28,7 @@ // version is a simple class for holding a modules version number Version::Version(const std::string &modv, int flags, int api_ver, const std::string& rev) -: version(modv + " " + rev), Flags(flags), API(api_ver) +: version(modv + " - " + rev), Flags(flags), API(api_ver) { } @@ -90,7 +90,7 @@ Module* Event::GetSource() return this->source; } -char* Event::Send(InspIRCd* ServerInstance) +char* Event::Send(InspIRCd* SI) { FOREACH_MOD(I_OnEvent,OnEvent(this)); return NULL; @@ -104,7 +104,7 @@ std::string Event::GetEventID() // These declarations define the behavours of the base class Module (which does nothing at all) -Module::Module(InspIRCd* Me) : ServerInstance(Me) { } +Module::Module(InspIRCd*) { } Module::~Module() { } ModResult Module::OnSendSnotice(char &snomask, std::string &type, const std::string &message) { return MOD_RES_PASSTHRU; } diff --git a/src/modules/m_callerid.cpp b/src/modules/m_callerid.cpp index 16b883f63..b84ee2c9c 100644 --- a/src/modules/m_callerid.cpp +++ b/src/modules/m_callerid.cpp @@ -32,7 +32,7 @@ class callerid_data : public classbase std::list<callerid_data *> wholistsme; callerid_data() : lastnotify(0) { } - callerid_data(const std::string& str, InspIRCd* ServerInstance) + callerid_data(const std::string& str) { irc::commasepstream s(str); std::string tok; @@ -85,7 +85,7 @@ struct CallerIDExtInfo : public ExtensionItem void unserialize(Module* requestor, Extensible* container, const std::string& value) { - callerid_data* dat = new callerid_data(value, requestor->ServerInstance); + callerid_data* dat = new callerid_data(value); set_raw(container, dat); } diff --git a/src/modules/m_delayjoin.cpp b/src/modules/m_delayjoin.cpp index ffaf1223b..a7a8575b4 100644 --- a/src/modules/m_delayjoin.cpp +++ b/src/modules/m_delayjoin.cpp @@ -169,7 +169,7 @@ void ModuleDelayJoin::OnText(User* user, void* dest, int target_type, const std: /* Display the join to everyone else (the user who joined got it earlier) */ channel->WriteAllExceptSender(user, false, 0, "JOIN %s", channel->name.c_str()); - std::string n = this->ServerInstance->Modes->ModeString(user, channel); + std::string n = ServerInstance->Modes->ModeString(user, channel); if (n.length() > 0) channel->WriteAllExceptSender(user, false, 0, "MODE %s +%s", channel->name.c_str(), n.c_str()); } diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp index ddfc47455..9a3eb3222 100644 --- a/src/modules/m_nicklock.cpp +++ b/src/modules/m_nicklock.cpp @@ -21,7 +21,7 @@ class CommandNicklock : public Command { public: LocalIntExt& locked; - CommandNicklock (Module* Creator, LocalIntExt& ext) : Command(Creator->ServerInstance, Creator,"NICKLOCK", "o", 2), + CommandNicklock (Module* Creator, LocalIntExt& ext) : Command(ServerInstance, Creator,"NICKLOCK", "o", 2), locked(ext) { syntax = "<oldnick> <newnick>"; @@ -89,7 +89,7 @@ class CommandNickunlock : public Command { public: LocalIntExt& locked; - CommandNickunlock (Module* Creator, LocalIntExt& ext) : Command(Creator->ServerInstance, Creator,"NICKUNLOCK", "o", 1), + CommandNickunlock (Module* Creator, LocalIntExt& ext) : Command(ServerInstance, Creator,"NICKUNLOCK", "o", 1), locked(ext) { syntax = "<locked-nick>"; diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index 47f19e90d..7bf3a3623 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -98,7 +98,7 @@ class ModuleOperPrefixMode : public Module modechange.push_back(channel->name); modechange.push_back(modeline); modechange.push_back(user->nick); - ServerInstance->SendMode(modechange,this->ServerInstance->FakeClient); + ServerInstance->SendMode(modechange,ServerInstance->FakeClient); } void OnPostJoin(Membership* memb) diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index 41a5daf33..674a6dca5 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -17,7 +17,7 @@ // Not in a class due to circular dependancy hell. static std::string permchannelsconf; -static bool WriteDatabase(InspIRCd *ServerInstance) +static bool WriteDatabase() { FILE *f; @@ -100,7 +100,7 @@ class PermChannel : public ModeHandler channel->SetMode('P',true); // Save permchannels db if needed. - WriteDatabase(ServerInstance); + WriteDatabase(); return MODEACTION_ALLOW; } } @@ -134,7 +134,7 @@ class PermChannel : public ModeHandler channel->SetMode('P',false); // Save permchannels db if needed. - WriteDatabase(ServerInstance); + WriteDatabase(); return MODEACTION_ALLOW; } } @@ -253,7 +253,7 @@ public: virtual ModResult OnRawMode(User* user, Channel* chan, const char mode, const std::string ¶m, bool adding, int pcnt) { if (chan && chan->IsModeSet('P')) - WriteDatabase(ServerInstance); + WriteDatabase(); return MOD_RES_PASSTHRU; } @@ -261,7 +261,7 @@ public: virtual void OnPostTopicChange(User*, Channel *c, const std::string&) { if (c->IsModeSet('P')) - WriteDatabase(ServerInstance); + WriteDatabase(); } virtual Version GetVersion() diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 2549461f1..3877daf42 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -250,7 +250,7 @@ void ModuleSpanningTree::ConnectServer(Link* x) if (InspIRCd::Match(ServerInstance->Config->ServerName, assign(x->Name))) { - this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Not connecting to myself."); + ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Not connecting to myself."); return; } @@ -282,7 +282,7 @@ void ModuleSpanningTree::ConnectServer(Link* x) } else { - this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(),strerror(errno)); + ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(),strerror(errno)); if (ServerInstance->SocketCull.find(newsocket) == ServerInstance->SocketCull.end()) ServerInstance->SocketCull[newsocket] = newsocket; Utils->DoFailOver(x); @@ -298,7 +298,7 @@ void ModuleSpanningTree::ConnectServer(Link* x) } catch (ModuleException& e) { - this->ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(), e.GetReason()); + ServerInstance->SNO->WriteToSnoMask('l', "CONNECT: Error connecting \002%s\002: %s.",x->Name.c_str(), e.GetReason()); Utils->DoFailOver(x); } } diff --git a/src/users.cpp b/src/users.cpp index 7f60b2f93..b361205da 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -109,9 +109,9 @@ void User::StartDNSLookup() UserResolver *res_reverse; QueryType resolvtype = this->client_sa.sa.sa_family == AF_INET6 ? DNS_QUERY_PTR6 : DNS_QUERY_PTR4; - res_reverse = new UserResolver(this->ServerInstance, this, sip, resolvtype, cached); + res_reverse = new UserResolver(ServerInstance, this, sip, resolvtype, cached); - this->ServerInstance->AddResolver(res_reverse, cached); + ServerInstance->AddResolver(res_reverse, cached); } catch (CoreException& e) { @@ -205,7 +205,7 @@ void User::DecrementModes() } } -User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance) +User::User(InspIRCd* Instance, const std::string &uid) { server = Instance->FindServerNamePtr(Instance->Config->ServerName); age = ServerInstance->Time(); @@ -716,7 +716,7 @@ void User::FlushWriteBuf() this->bytes_out += n_sent; this->cmds_out++; if (n_sent != old_sendq_length) - this->ServerInstance->SE->WantWrite(this); + ServerInstance->SE->WantWrite(this); } } @@ -1219,7 +1219,7 @@ void User::Write(const std::string& text) this->AddWriteBuf("\r\n"); } ServerInstance->stats->statsSent += text.length() + 2; - this->ServerInstance->SE->WantWrite(this); + ServerInstance->SE->WantWrite(this); } /** Write() @@ -1567,7 +1567,7 @@ void User::DoHostCycle(const std::string &quitline) Channel* c = *v; snprintf(buffer, MAXBUF, ":%s JOIN %s", GetFullHost().c_str(), c->name.c_str()); std::string joinline(buffer); - std::string modeline = this->ServerInstance->Modes->ModeString(this, c); + std::string modeline = ServerInstance->Modes->ModeString(this, c); if (modeline.length() > 0) { snprintf(buffer, MAXBUF, ":%s MODE %s +%s", GetFullHost().c_str(), c->name.c_str(), modeline.c_str()); |