summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-08-06 13:44:02 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-08-06 13:44:02 +0200
commit8fc268558586584479c622a3852f647eaf3a9b0e (patch)
tree86a5a2d9b0c014e2e02cc79dcfc01fca7b3ead49 /src
parentf7ec4f3c2724edfdac2e1a64f1ec151f7f35f9e8 (diff)
m_ojoin Change allocation of NetworkPrefix to be physically part of the object containing it
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_ojoin.cpp31
1 files changed, 8 insertions, 23 deletions
diff --git a/src/modules/m_ojoin.cpp b/src/modules/m_ojoin.cpp
index e26646c3a..3710757aa 100644
--- a/src/modules/m_ojoin.cpp
+++ b/src/modules/m_ojoin.cpp
@@ -30,8 +30,9 @@ class CommandOjoin : public SplitCommand
bool notice;
bool op;
ModeHandler* npmh;
- CommandOjoin(Module* parent) :
- SplitCommand(parent, "OJOIN", 1)
+ CommandOjoin(Module* parent, ModeHandler& mode)
+ : SplitCommand(parent, "OJOIN", 1)
+ , npmh(&mode)
{
flags_needed = 'o'; Penalty = 0; syntax = "<channel>";
active = false;
@@ -105,33 +106,22 @@ class NetworkPrefix : public PrefixMode
class ModuleOjoin : public Module
{
- NetworkPrefix* np;
+ NetworkPrefix np;
CommandOjoin mycommand;
public:
ModuleOjoin()
- : np(NULL), mycommand(this)
+ : np(this, ServerInstance->Config->ConfValue("ojoin")->getString("prefix").c_str()[0])
+ , mycommand(this, np)
{
}
- void init() CXX11_OVERRIDE
- {
- std::string npre = ServerInstance->Config->ConfValue("ojoin")->getString("prefix");
- char NPrefix = npre.empty() ? 0 : npre[0];
-
- /* Initialise module variables */
- np = new NetworkPrefix(this, NPrefix);
- mycommand.npmh = np;
-
- ServerInstance->Modules->AddService(*np);
- }
-
ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven) CXX11_OVERRIDE
{
if (mycommand.active)
{
- privs += np->GetModeChar();
+ privs += np.GetModeChar();
if (mycommand.op)
privs += 'o';
return MOD_RES_ALLOW;
@@ -150,7 +140,7 @@ class ModuleOjoin : public Module
ModResult OnUserPreKick(User* source, Membership* memb, const std::string &reason) CXX11_OVERRIDE
{
// Don't do anything if they're not +Y
- if (!memb->hasMode(np->GetModeChar()))
+ if (!memb->hasMode(np.GetModeChar()))
return MOD_RES_PASSTHRU;
// Let them do whatever they want to themselves.
@@ -161,11 +151,6 @@ class ModuleOjoin : public Module
return MOD_RES_DENY;
}
- ~ModuleOjoin()
- {
- delete np;
- }
-
void Prioritize()
{
ServerInstance->Modules->SetPriority(this, I_OnUserPreJoin, PRIORITY_FIRST);