diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-10 17:21:26 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-07-10 17:21:26 +0000 |
commit | 0942fe7405f0ff38038f7445c241fdae0bd7d1a2 (patch) | |
tree | 2d386c188161a949e7c32e28744a097c0d06247c | |
parent | 3eefd1dfbdf611e526670b89dbd738e17c392c2c (diff) |
Convert to templated GetExt
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4285 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/modules/m_nicklock.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_park.cpp | 24 | ||||
-rw-r--r-- | src/modules/m_remove.cpp | 12 |
3 files changed, 30 insertions, 18 deletions
diff --git a/src/modules/m_nicklock.cpp b/src/modules/m_nicklock.cpp index cd36f1747..47c15e792 100644 --- a/src/modules/m_nicklock.cpp +++ b/src/modules/m_nicklock.cpp @@ -30,11 +30,12 @@ static Server *Srv; class cmd_nicklock : public command_t { + char* dummy; public: - cmd_nicklock () : command_t("NICKLOCK", 'o', 2) - { + cmd_nicklock () : command_t("NICKLOCK", 'o', 2) + { this->source = "m_nicklock.so"; - } + } void Handle(char **parameters, int pcnt, userrec *user) { @@ -44,7 +45,7 @@ class cmd_nicklock : public command_t if (source) { - if (source->GetExt("nick_locked")) + if (source->GetExt("nick_locked", dummy)) { WriteServ(user->fd,"946 %s %s :This user's nickname is already locked.",user->nick,source->nick); return; @@ -88,6 +89,7 @@ class ModuleNickLock : public Module { cmd_nicklock* cmd1; cmd_nickunlock* cmd2; + char* n; public: ModuleNickLock(Server* Me) : Module::Module(Me) @@ -115,7 +117,7 @@ class ModuleNickLock : public Module virtual int OnUserPreNick(userrec* user, const std::string &newnick) { - if (user->GetExt("nick_locked")) + if (user->GetExt("nick_locked", n)) { WriteServ(user->fd,"447 %s :You cannot change your nickname (your nick is locked)",user->nick); return 1; diff --git a/src/modules/m_park.cpp b/src/modules/m_park.cpp index a5c62da19..8b800138a 100644 --- a/src/modules/m_park.cpp +++ b/src/modules/m_park.cpp @@ -80,12 +80,13 @@ class cmd_park : public command_t { awaylog* aw; char msg[MAXBUF]; - unsigned long key = abs(random() * 12345); - snprintf(msg,MAXBUF,"You are now parked. To unpark use /UNPARK %s %lu",user->nick,key); + unsigned long* key = new unsigned long; + *key = abs(random() * 12345); + snprintf(msg,MAXBUF,"You are now parked. To unpark use /UNPARK %s %lu",user->nick, *key); Srv->UserToPseudo(user,std::string(msg)); aw = new awaylog; - user->Extend("park_awaylog",(char*)aw); - user->Extend("park_key",(char*)key); + user->Extend("park_awaylog", aw); + user->Extend("park_key", key); pi.nick = user->nick; pi.host = user->host; pi.parktime = time(NULL); @@ -143,14 +144,16 @@ class cmd_unpark : public command_t WriteServ(user->fd,"942 %s %s :Invalid user specified.",user->nick, parameters[0]); return; } - awaylog* awy = (awaylog*)unpark->GetExt("park_awaylog"); - long key = (long)unpark->GetExt("park_key"); + awaylog* awy; + unpark->GetExt("park_awaylog", awy); + long* key; + unpark->GetExt("park_key", key); if (!awy) { WriteServ(user->fd,"943 %s %s :This user is not parked.",user->nick, unpark->nick); return; } - if (key == atoi(parameters[1])) + if (*key == atoi(parameters[1])) { // first part the user from all chans theyre on, so things dont get messy for (std::vector<ucrec*>::iterator i = user->chans.begin(); i != user->chans.end(); i++) @@ -177,6 +180,7 @@ class cmd_unpark : public command_t WriteServ(unpark->fd,"NOTICE %s :From %s at %s: \2%s\2",unpark->nick,i->from.c_str(),timebuf,i->text.c_str()); } DELETE(awy); + DELETE(key); unpark->Shrink("park_awaylog"); unpark->Shrink("park_key"); for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) @@ -262,7 +266,8 @@ class ModulePark : public Module virtual void OnPrePrivmsg(userrec* user, userrec* dest, const std::string &text) { - awaylog* awy = (awaylog*)dest->GetExt("park_awaylog"); + awaylog* awy; + dest->GetExt("park_awaylog", awy); if (awy) { if (awy->size() <= (unsigned)ParkMaxMsgs) @@ -334,7 +339,8 @@ class ModulePark : public Module virtual void OnWhois(userrec* src, userrec* dst) { - if (dst->GetExt("park_awaylog")) + char* dummy; + if (dst->GetExt("park_awaylog", dummy)) Srv->SendTo(NULL,src,"335 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is a parked client"); } diff --git a/src/modules/m_remove.cpp b/src/modules/m_remove.cpp index aa8246464..d865066b3 100644 --- a/src/modules/m_remove.cpp +++ b/src/modules/m_remove.cpp @@ -60,6 +60,7 @@ class cmd_remove : public command_t userrec* target; chanrec* channel; int tlevel, ulevel; + char* dummy; std::string tprivs, uprivs, reason; @@ -102,16 +103,19 @@ class cmd_remove : public command_t /* This is adding support for the +q and +a channel modes, basically if they are enabled, and the remover has them set. */ /* Then we change the @|%|+ to & if they are +a, or ~ if they are +q */ + + std::string protect = "cm_protect_" + std::string(channel->name); + std::string founder = "cm_founder_"+std::string(channel->name); - if (user->GetExt("cm_protect_" + std::string(channel->name))) + if (user->GetExt(protect, dummy)) uprivs = "&"; - if (user->GetExt("cm_founder_"+std::string(channel->name))) + if (user->GetExt(founder, dummy)) uprivs = "~"; /* Now it's the same idea, except for the target */ - if (target->GetExt("cm_protect_"+std::string(channel->name))) + if (target->GetExt(protect, dummy)) tprivs = "&"; - if (target->GetExt("cm_founder_"+std::string(channel->name))) + if (target->GetExt(founder, dummy)) tprivs = "~"; tlevel = chartolevel(tprivs); |