Permalink
Browse files

Having these references to bots bugged out older compilers, so simpli…

…fy this by just moving pointers to the core
  • Loading branch information...
Adam- committed Dec 19, 2012
1 parent 3b20943 commit 784683a68dc3882f9507b9d304f4adf10fb403ae
View
@@ -35,7 +35,7 @@ enum BotFlag
};
/* A service bot (NickServ, ChanServ, a BotServ bot, etc). */
-class CoreExport BotInfo : public User, public Flags<BotFlag>, public Serializable, public Service
+class CoreExport BotInfo : public User, public Flags<BotFlag>, public Serializable
{
public:
time_t created;
@@ -139,4 +139,6 @@ class CoreExport BotInfo : public User, public Flags<BotFlag>, public Serializab
static BotInfo* Find(const Anope::string &nick, bool nick_only = false);
};
+extern CoreExport BotInfo *BotServ, *ChanServ, *Global, *HostServ, *MemoServ, *NickServ, *OperServ;
+
#endif // BOTS_H
View
@@ -47,12 +47,8 @@
#include "users.h"
#include "xline.h"
-#include "chanserv.h"
-#include "botserv.h"
#include "global.h"
-#include "hostserv.h"
#include "memoserv.h"
#include "nickserv.h"
-#include "operserv.h"
#endif // MODULE_H
@@ -20,20 +20,24 @@ class BotServCore : public Module
{
this->SetAuthor("Anope");
- BotInfo *bi = BotInfo::Find(Config->BotServ);
- if (!bi)
+ BotServ = BotInfo::Find(Config->BotServ);
+ if (!BotServ)
throw ModuleException("No bot named " + Config->BotServ);
- Implementation i[] = { I_OnPrivmsg, I_OnJoinChannel, I_OnLeaveChannel,
+ Implementation i[] = { I_OnBotDelete, I_OnPrivmsg, I_OnJoinChannel, I_OnLeaveChannel,
I_OnPreHelp, I_OnPostHelp, I_OnChannelModeSet };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- Service::AddAlias("BotInfo", "BotServ", bi->nick);
}
~BotServCore()
{
- Service::DelAlias("BotInfo", "BotServ");
+ BotServ = NULL;
+ }
+
+ void OnBotDelete(BotInfo *bi) anope_override
+ {
+ if (bi == BotServ)
+ BotServ = NULL;
}
void OnPrivmsg(User *u, Channel *c, Anope::string &msg) anope_override
@@ -1,6 +0,0 @@
-#ifndef BOTSERV_H
-#define BOTSERV_H
-
-static ServiceReference<BotInfo> BotServ("BotInfo", "BotServ");
-
-#endif // BOTSERV_H
@@ -61,19 +61,23 @@ class ChanServCore : public Module
{
this->SetAuthor("Anope");
- BotInfo *bi = BotInfo::Find(Config->ChanServ);
- if (!bi)
+ ChanServ = BotInfo::Find(Config->ChanServ);
+ if (!ChanServ)
throw ModuleException("No bot named " + Config->ChanServ);
- Implementation i[] = { I_OnBotPrivmsg, I_OnDelCore, I_OnPreHelp, I_OnPostHelp, I_OnCheckModes };
+ Implementation i[] = { I_OnBotDelete, I_OnBotPrivmsg, I_OnDelCore, I_OnPreHelp, I_OnPostHelp, I_OnCheckModes };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- Service::AddAlias("BotInfo", "ChanServ", bi->nick);
}
~ChanServCore()
{
- Service::DelAlias("BotInfo", "ChanServ");
+ ChanServ = NULL;
+ }
+
+ void OnBotDelete(BotInfo *bi) anope_override
+ {
+ if (bi == ChanServ)
+ ChanServ = NULL;
}
EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) anope_override
@@ -1,6 +0,0 @@
-#ifndef CHANSERV_H
-#define CHANSERV_H
-
-static ServiceReference<BotInfo> ChanServ("BotInfo", "ChanServ");
-
-#endif // CHANSERV_H
@@ -53,19 +53,23 @@ class GlobalCore : public Module
{
this->SetAuthor("Anope");
- BotInfo *bi = BotInfo::Find(Config->Global);
- if (!bi)
+ Global = BotInfo::Find(Config->Global);
+ if (!Global)
throw ModuleException("No bot named " + Config->Global);
- Implementation i[] = { I_OnRestart, I_OnShutdown, I_OnNewServer, I_OnPreHelp };
+ Implementation i[] = { I_OnBotDelete, I_OnRestart, I_OnShutdown, I_OnNewServer, I_OnPreHelp };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- Service::AddAlias("BotInfo", "Global", bi->nick);
}
~GlobalCore()
{
- Service::DelAlias("BotInfo", "Global");
+ Global = NULL;
+ }
+
+ void OnBotDelete(BotInfo *bi) anope_override
+ {
+ if (bi == Global)
+ Global = NULL;
}
void OnRestart() anope_override
@@ -15,7 +15,6 @@ class GlobalService : public Service
};
static ServiceReference<GlobalService> GlobalService("GlobalService", "Global");
-static ServiceReference<BotInfo> Global("BotInfo", "Global");
#endif // GLOBAL_H
@@ -23,19 +23,23 @@ class HostServCore : public Module
if (!IRCD || !IRCD->CanSetVHost)
throw ModuleException("Your IRCd does not support vhosts");
- BotInfo *bi = BotInfo::Find(Config->HostServ);
- if (!bi)
+ HostServ = BotInfo::Find(Config->HostServ);
+ if (!HostServ)
throw ModuleException("No bot named " + Config->HostServ);
- Implementation i[] = { I_OnNickIdentify, I_OnNickUpdate, I_OnPreHelp };
+ Implementation i[] = { I_OnBotDelete, I_OnNickIdentify, I_OnNickUpdate, I_OnPreHelp };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- Service::AddAlias("BotInfo", "HostServ", bi->nick);
}
~HostServCore()
{
- Service::DelAlias("BotInfo", "HostServ");
+ HostServ = NULL;
+ }
+
+ void OnBotDelete(BotInfo *bi) anope_override
+ {
+ if (bi == HostServ)
+ HostServ = NULL;
}
void OnNickIdentify(User *u) anope_override
@@ -1,6 +0,0 @@
-#ifndef HOSTSERV_H
-#define HOSTSERV_H
-
-static ServiceReference<BotInfo> HostServ("BotInfo", "HostServ");
-
-#endif // HOSTSERV_H
@@ -165,19 +165,23 @@ class MemoServCore : public Module
{
this->SetAuthor("Anope");
- BotInfo *bi = BotInfo::Find(Config->MemoServ);
- if (!bi)
+ MemoServ = BotInfo::Find(Config->MemoServ);
+ if (!MemoServ)
throw ModuleException("No bot named " + Config->MemoServ);
- Implementation i[] = { I_OnNickIdentify, I_OnJoinChannel, I_OnUserAway, I_OnNickUpdate, I_OnPreHelp, I_OnPostHelp };
+ Implementation i[] = { I_OnBotDelete, I_OnNickIdentify, I_OnJoinChannel, I_OnUserAway, I_OnNickUpdate, I_OnPreHelp, I_OnPostHelp };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- Service::AddAlias("BotInfo", "MemoServ", bi->nick);
}
~MemoServCore()
{
- Service::DelAlias("BotInfo", "MemoServ");
+ MemoServ = NULL;
+ }
+
+ void OnBotDelete(BotInfo *bi) anope_override
+ {
+ if (bi == MemoServ)
+ MemoServ = NULL;
}
void OnNickIdentify(User *u) anope_override
@@ -36,7 +36,6 @@ class MemoServService : public Service
};
static ServiceReference<MemoServService> MemoServService("MemoServService", "MemoServ");
-static ServiceReference<BotInfo> MemoServ("BotInfo", "MemoServ");
#endif // MEMOSERV_H
@@ -185,20 +185,24 @@ class NickServCore : public Module
{
this->SetAuthor("Anope");
- BotInfo *bi = BotInfo::Find(Config->NickServ);
- if (!bi)
+ NickServ = BotInfo::Find(Config->NickServ);
+ if (!NickServ)
throw ModuleException("No bot named " + Config->NickServ);
- Implementation i[] = { I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickIdentify, I_OnNickGroup,
- I_OnNickUpdate, I_OnUserNickChange, I_OnPreHelp, I_OnPostHelp, I_OnUserConnect };
+ Implementation i[] = { I_OnBotDelete, I_OnDelNick, I_OnDelCore, I_OnChangeCoreDisplay, I_OnNickIdentify, I_OnNickGroup,
+ I_OnNickUpdate, I_OnUserNickChange, I_OnPreHelp, I_OnPostHelp, I_OnUserConnect };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
-
- Service::AddAlias("BotInfo", "NickServ", bi->nick);
}
~NickServCore()
{
- Service::DelAlias("BotInfo", "NickServ");
+ NickServ = NULL;
+ }
+
+ void OnBotDelete(BotInfo *bi) anope_override
+ {
+ if (bi == NickServ)
+ NickServ = NULL;
}
void OnDelNick(NickAlias *na) anope_override
@@ -10,7 +10,6 @@ class NickServService : public Service
};
static ServiceReference<NickServService> NickServService("NickServService", "NickServ");
-static ServiceReference<BotInfo> NickServ("BotInfo", "NickServ");
#endif // NICKSERV_H
@@ -175,24 +175,22 @@ class OperServCore : public Module
{
this->SetAuthor("Anope");
- BotInfo *bi = BotInfo::Find(Config->OperServ);
- if (!bi)
+ OperServ = BotInfo::Find(Config->OperServ);
+ if (!OperServ)
throw ModuleException("No bot named " + Config->OperServ);
- Implementation i[] = { I_OnBotPrivmsg, I_OnServerQuit, I_OnUserModeSet, I_OnUserModeUnset, I_OnUserConnect, I_OnUserNickChange, I_OnPreHelp };
+ Implementation i[] = { I_OnBotDelete, I_OnBotPrivmsg, I_OnServerQuit, I_OnUserModeSet, I_OnUserModeUnset, I_OnUserConnect, I_OnUserNickChange, I_OnPreHelp };
ModuleManager::Attach(i, this, sizeof(i) / sizeof(Implementation));
/* Yes, these are in this order for a reason. Most violent->least violent. */
XLineManager::RegisterXLineManager(&sglines);
XLineManager::RegisterXLineManager(&sqlines);
XLineManager::RegisterXLineManager(&snlines);
-
- Service::AddAlias("BotInfo", "OperServ", bi->nick);
}
~OperServCore()
{
- Service::DelAlias("BotInfo", "OperServ");
+ OperServ = NULL;
this->sglines.Clear();
this->sqlines.Clear();
@@ -203,6 +201,12 @@ class OperServCore : public Module
XLineManager::UnregisterXLineManager(&snlines);
}
+ void OnBotDelete(BotInfo *bi) anope_override
+ {
+ if (bi == OperServ)
+ OperServ = NULL;
+ }
+
EventReturn OnBotPrivmsg(User *u, BotInfo *bi, Anope::string &message) anope_override
{
if (Config->OSOpersOnly && !u->HasMode(UMODE_OPER) && bi->nick == Config->OperServ)
@@ -1,6 +0,0 @@
-#ifndef OPERSERV_H
-#define OPERSERV_H
-
-static ServiceReference<BotInfo> OperServ("BotInfo", "OperServ");
-
-#endif // OPERSERV_H
View
@@ -32,7 +32,9 @@ static const Anope::string BotServFlagStrings[] = {
};
template<> const Anope::string* Flags<BotServFlag>::flags_strings = BotServFlagStrings;
-BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", Servers::TS6_UID_Retrieve()), Serializable("BotInfo"), Service(NULL, "BotInfo", nnick), botmodes(bmodes)
+BotInfo *BotServ = NULL, *ChanServ = NULL, *Global = NULL, *HostServ = NULL, *MemoServ = NULL, *NickServ = NULL, *OperServ = NULL;
+
+BotInfo::BotInfo(const Anope::string &nnick, const Anope::string &nuser, const Anope::string &nhost, const Anope::string &nreal, const Anope::string &bmodes) : User(nnick, nuser, nhost, "", "", Me, nreal, Anope::CurTime, "", Servers::TS6_UID_Retrieve()), Serializable("BotInfo"), botmodes(bmodes)
{
this->lastmsg = this->created = Anope::CurTime;
this->introduced = false;
View
@@ -23,7 +23,6 @@
#include "config.h"
#include "access.h"
#include "sockets.h"
-#include "chanserv.h"
channel_map ChannelList;
View
@@ -22,8 +22,6 @@
#include "uplink.h"
#include "protocol.h"
#include "global.h"
-#include "operserv.h"
-#include "chanserv.h"
#ifndef _WIN32
#include <sys/time.h>
View
@@ -19,7 +19,6 @@
#include "uplink.h"
#include "bots.h"
#include "channels.h"
-#include "operserv.h"
IRCDProto *IRCD = NULL;
View
@@ -20,7 +20,6 @@
#include "bots.h"
#include "language.h"
#include "servers.h"
-#include "chanserv.h"
Serialize::Checker<registered_channel_map> RegisteredChannelList("ChannelInfo");
View
@@ -22,7 +22,6 @@
#include "config.h"
#include "opertype.h"
#include "nickserv.h"
-#include "operserv.h"
#include "language.h"
user_map UserListByNick, UserListByUID;

0 comments on commit 784683a

Please sign in to comment.