X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_park.cpp;h=a5c62da190fda453c81246a062c6aeec66ceea40;hb=9dd72b7003963d868a23da930a91300b49ab4959;hp=a5c123a5dbeaf479256e6a92ff0a912e7eb807c9;hpb=e2e581f0d3d5d844dc4b5210f566e5a5571a0570;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_park.cpp b/src/modules/m_park.cpp index a5c123a5d..a5c62da19 100644 --- a/src/modules/m_park.cpp +++ b/src/modules/m_park.cpp @@ -69,7 +69,7 @@ class cmd_park : public command_t int othersessions = 0; /* XXX - why can't just use pinfo.size() like we do below, rather than iterating over the whole vector? -- w00t */ if (pinfo.size()) - for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) + for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) if (j->host == std::string(user->host)) othersessions++; if (othersessions >= ConcurrentParks) @@ -153,22 +153,19 @@ class cmd_unpark : public command_t if (key == atoi(parameters[1])) { // first part the user from all chans theyre on, so things dont get messy - for (unsigned int i = 0; i < user->chans.size(); i++) - { - if (user->chans[i].channel != NULL) - { - if (user->chans[i].channel->name) - { - Srv->PartUserFromChannel(user,user->chans[i].channel->name,"Unparking"); - } + for (std::vector::iterator i = user->chans.begin(); i != user->chans.end(); i++) + { + if (((ucrec*)(*i))->channel != NULL) + { + Srv->PartUserFromChannel(user,((ucrec*)(*i))->channel->name,"Unparking"); } } // remove all their old modes - WriteServ(user->fd,"MODE %s -%s",user->nick,user->modes); + WriteServ(user->fd,"MODE %s -%s",user->nick,user->FormatModes()); // now, map them to the parked user, while nobody can see :p Srv->PseudoToUser(user,unpark,"Unparked to "+std::string(parameters[0])); // set all their new modes - WriteServ(unpark->fd,"MODE %s +%s",unpark->nick,unpark->modes); + WriteServ(unpark->fd,"MODE %s +%s",unpark->nick,unpark->FormatModes()); // spool their away log to them WriteServ(unpark->fd,"NOTICE %s :*** You are now unparked. You have successfully taken back the nickname and privilages of %s.",unpark->nick,unpark->nick); for (awaylog::iterator i = awy->begin(); i != awy->end(); i++) @@ -179,7 +176,7 @@ class cmd_unpark : public command_t timebuf[strlen(timebuf)-1] = '\0'; 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(awy); unpark->Shrink("park_awaylog"); unpark->Shrink("park_key"); for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) @@ -212,7 +209,7 @@ class ModulePark : public Module ParkMaxTime = Conf->ReadInteger("park","maxtime",0,true); ConcurrentParks = Conf->ReadInteger("park","maxperip",0,true); ParkMaxMsgs = Conf->ReadInteger("park","maxmessages",0,true); - delete Conf; + DELETE(Conf); } ModulePark(Server* Me) @@ -238,32 +235,32 @@ class ModulePark : public Module List[I_On005Numeric] = List[I_OnRehash] = List[I_OnUserQuit] = List[I_OnUserPreMessage] = List[I_OnUserPreNick] = List[I_OnBackgroundTimer] = List[I_OnWhois] = 1; } - virtual void OnRehash(std::string parameter) + virtual void OnRehash(const std::string ¶meter) { this->ReadSettings(); } - virtual void On005Numeric(std::string &output) - { - output = output + std::string(" PARK"); - } + virtual void On005Numeric(std::string &output) + { + output = output + std::string(" PARK"); + } - virtual void OnUserQuit(userrec* user, std::string reason) - { - std::string nick = user->nick; - // track quits in our parked user list - for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) - { - if (j->nick == nick) - { - pinfo.erase(j); - break; - } - } - } + virtual void OnUserQuit(userrec* user, const std::string &reason) + { + std::string nick = user->nick; + // track quits in our parked user list + for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) + { + if (j->nick == nick) + { + pinfo.erase(j); + break; + } + } + } - virtual void OnPrePrivmsg(userrec* user, userrec* dest, std::string text) + virtual void OnPrePrivmsg(userrec* user, userrec* dest, const std::string &text) { awaylog* awy = (awaylog*)dest->GetExt("park_awaylog"); if (awy) @@ -281,47 +278,47 @@ class ModulePark : public Module } } - virtual int OnUserPreNick(userrec* user, std::string newnick) + virtual int OnUserPreNick(userrec* user, const std::string &newnick) { // track nickchanges in our parked user list // (this isnt too efficient, i'll tidy it up some time) /* XXX - perhaps extend the user record, or, that wouldn't work - perhaps use a map? -- w00t */ - for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) - { - if (j->nick == std::string(user->nick)) - { - j->nick = newnick; - break; - } - } + for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) + { + if (j->nick == std::string(user->nick)) + { + j->nick = newnick; + break; + } + } return 0; } virtual void OnBackgroundTimer(time_t curtime) { - // look for parked clients which have timed out (this needs tidying) - if (pinfo.empty()) - return; - bool go_again = true; - while (go_again) - { - go_again = false; - for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) - { - if (time(NULL) >= (j->parktime+ParkMaxTime)) - { - userrec* thisnick = Srv->FindNick(j->nick); + // look for parked clients which have timed out (this needs tidying) + if (pinfo.empty()) + return; + bool go_again = true; + while (go_again) + { + go_again = false; + for (parkinfo::iterator j = pinfo.begin(); j != pinfo.end(); j++) + { + if (time(NULL) >= (j->parktime+ParkMaxTime)) + { + userrec* thisnick = Srv->FindNick(j->nick); // THIS MUST COME BEFORE THE QuitUser - QuitUser can // create a recursive call to OnUserQuit in this module // and then corrupt the pointer! pinfo.erase(j); - if (thisnick) - Srv->QuitUser(thisnick,"PARK timeout"); - go_again = true; - break; - } - } - } + if (thisnick) + Srv->QuitUser(thisnick,"PARK timeout"); + go_again = true; + break; + } + } + } } /* XXX - why is OnPrePrivmsg seperated here, I assume there is reason for the extra function call? --w00t */ @@ -335,11 +332,11 @@ class ModulePark : public Module return 0; } - virtual void OnWhois(userrec* src, userrec* dst) - { + virtual void OnWhois(userrec* src, userrec* dst) + { if (dst->GetExt("park_awaylog")) - Srv->SendTo(NULL,src,"335 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is a parked client"); - } + Srv->SendTo(NULL,src,"335 "+std::string(src->nick)+" "+std::string(dst->nick)+" :is a parked client"); + } virtual Version GetVersion() {