X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_park.cpp;h=1cf69b46fea9a2dc9e72b9382ee693b9195483bc;hb=eb4229deed0281ae566ef7e55a144e5d3183a4b2;hp=910930f12b5ba9187bc57b8d7d13c115f261074e;hpb=253a4270f27c7d667a68147b4ebe9aa439290445;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_park.cpp b/src/modules/m_park.cpp index 910930f12..1cf69b46f 100644 --- a/src/modules/m_park.cpp +++ b/src/modules/m_park.cpp @@ -19,6 +19,7 @@ #include #include "users.h" #include "channels.h" +#include "helperfuncs.h" #include "modules.h" /* $ModDesc: Provides support for user parking/unparking */ @@ -46,6 +47,7 @@ parkinfo pinfo; long ParkMaxTime; long ConcurrentParks; long ParkMaxMsgs; +parkedinfo pi; void handle_park(char **parameters, int pcnt, userrec *user) { @@ -66,10 +68,9 @@ void handle_park(char **parameters, int pcnt, userrec *user) else { awaylog* aw; - parkedinfo pi; char msg[MAXBUF]; - long key = abs(random() * 12345); - snprintf(msg,MAXBUF,"You are now parked. To unpark use /UNPARK %s %d",user->nick,key); + 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); @@ -84,7 +85,7 @@ void handle_park(char **parameters, int pcnt, userrec *user) void handle_parkstats(char **parameters, int pcnt, userrec *user) { char status[MAXBUF]; - snprintf(status,MAXBUF,"NOTICE %s :There are a total of %d parked clients on this server, with a maximum of %d parked sessions allowed per user.",user->nick,pinfo.size(),ConcurrentParks); + snprintf(status,MAXBUF,"NOTICE %s :There are a total of %lu parked clients on this server, with a maximum of %lu parked sessions allowed per user.",user->nick,(unsigned long)pinfo.size(),(unsigned long)ConcurrentParks); Srv->SendServ(user->fd,status); } @@ -185,6 +186,7 @@ class ModulePark : public Module { Srv = new Server; pinfo.clear(); + this->ReadSettings(); Srv->AddCommand("PARK",handle_park,0,0,"m_park.so"); Srv->AddCommand("UNPARK",handle_unpark,0,2,"m_park.so"); Srv->AddCommand("PARKSTATS",handle_parkstats,'o',0,"m_park.so"); @@ -205,6 +207,21 @@ class ModulePark : public Module output = output + std::string(" PARK"); } + virtual void OnUserQuit(userrec* user) + { + 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) { awaylog* awy = (awaylog*)dest->GetExt("park_awaylog"); @@ -252,9 +269,12 @@ class ModulePark : public Module 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"); - pinfo.erase(j); go_again = true; break; } @@ -268,7 +288,6 @@ class ModulePark : public Module { userrec* u = (userrec*)dest; OnPrePrivmsg(user,u,text); - return 1; } return 0; }