summaryrefslogtreecommitdiff
path: root/src/modules/m_swhois.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-10 17:42:23 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-10 17:42:23 +0000
commita3e7dffd20d2bc3e308cdba31409765a724663f4 (patch)
tree401b9bbe259035bb9372f770a4118b242960aa20 /src/modules/m_swhois.cpp
parent392ad3a51808ca6540043274216e5e4a0d36c3f6 (diff)
Convert to templated GetExt, and a lot more readable
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4290 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/m_swhois.cpp')
-rw-r--r--src/modules/m_swhois.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp
index 98ed007d0..b561a9660 100644
--- a/src/modules/m_swhois.cpp
+++ b/src/modules/m_swhois.cpp
@@ -45,7 +45,8 @@ class cmd_swhois : public command_t
line.append(parameters[i]);
}
- std::string* text = (std::string*)dest->GetExt("swhois");
+ std::string* text;
+ dest->GetExt("swhois", text);
if(text)
{
@@ -99,10 +100,10 @@ class ModuleSWhois : public Module
// :kenny.chatspike.net 320 Brain Azhrarn :is getting paid to play games.
virtual void OnWhois(userrec* source, userrec* dest)
{
- char* desc = dest->GetExt("swhois");
- if (desc)
+ std::string* swhois;
+ dest->GetExt("swhois", swhois);
+ if (swhois)
{
- std::string* swhois = (std::string*)desc;
WriteServ(source->fd,"320 %s %s :%s",source->nick,dest->nick,swhois->c_str());
}
}
@@ -118,11 +119,10 @@ class ModuleSWhois : public Module
if (extname == "swhois")
{
// check if this user has an swhois field to send
- char* field = user->GetExt("swhois");
- if (field)
+ std::string* swhois;
+ user->GetExt("swhois", swhois);
+ if (swhois)
{
- // get our extdata out with a cast
- std::string* swhois = (std::string*)field;
// call this function in the linking module, let it format the data how it
// sees fit, and send it on its way. We dont need or want to know how.
proto->ProtoSendMetaData(opaque,TYPE_USER,user,extname,*swhois);
@@ -133,10 +133,10 @@ class ModuleSWhois : public Module
// when a user quits, tidy up their metadata
virtual void OnUserQuit(userrec* user, const std::string &message)
{
- char* field = user->GetExt("swhois");
- if (field)
+ std::string* swhois;
+ user->GetExt("swhois", swhois);
+ if (swhois)
{
- std::string* swhois = (std::string*)field;
user->Shrink("swhois");
DELETE(swhois);
}
@@ -148,10 +148,10 @@ class ModuleSWhois : public Module
if (target_type == TYPE_USER)
{
userrec* user = (userrec*)item;
- char* field = user->GetExt("swhois");
- if (field)
+ std::string* swhois;
+ user->GetExt("swhois", swhois);
+ if (swhois)
{
- std::string* swhois = (std::string*)field;
user->Shrink("swhois");
DELETE(swhois);
}
@@ -172,10 +172,11 @@ class ModuleSWhois : public Module
{
userrec* dest = (userrec*)target;
// if they dont already have an swhois field, accept the remote server's
- if (!dest->GetExt("swhois"))
+ std::string* text;
+ if (!dest->GetExt("swhois", text))
{
std::string* text = new std::string(extdata);
- dest->Extend("swhois",(char*)text);
+ dest->Extend("swhois",text);
}
}
}
@@ -192,14 +193,15 @@ class ModuleSWhois : public Module
if(swhois.length())
{
- if(std::string* old = (std::string*)user->GetExt("swhois"))
+ std::string* old;
+ if(user->GetExt("swhois", old))
{
user->Shrink("swhois");
DELETE(old);
}
std::string* text = new std::string(swhois);
- user->Extend("swhois", (char*)text);
+ user->Extend("swhois", text);
break;
}