summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-10 16:51:19 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-10 16:51:19 +0000
commit9941a616cbba8ad5dec07bdf908a1d08d81e568e (patch)
treef8699db21a5e344e9d47da7aec7d8e646af3c4f2
parent91436d31a4ab6657012743285a1e635073e8966f (diff)
If you ask me, it looks a hell of a lot tidier without forcing the cast.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4277 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/base.h15
-rw-r--r--include/u_listmode.h15
-rw-r--r--src/base.cpp8
-rw-r--r--src/modules/m_banexception.cpp3
-rw-r--r--src/modules/m_blockamsg.cpp6
5 files changed, 34 insertions, 13 deletions
diff --git a/include/base.h b/include/base.h
index d3cc77e05..ac5fec63f 100644
--- a/include/base.h
+++ b/include/base.h
@@ -94,7 +94,20 @@ public:
*
* @return If you provide a non-existent key name, the function returns NULL, otherwise a pointer to the item referenced by the key is returned.
*/
- char* GetExt(const std::string &key);
+ template<typename T> bool GetExt(const std::string &key, T* &p)
+ {
+ ExtensibleStore::iterator iter = this->Extension_Items.find(key);
+ if(iter != this->Extension_Items.end())
+ {
+ p = (T*)iter->second;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ //char* GetExt(const std::string &key);
/** Get a list of all extension items names.
*
diff --git a/include/u_listmode.h b/include/u_listmode.h
index 1618754a3..9c34cc982 100644
--- a/include/u_listmode.h
+++ b/include/u_listmode.h
@@ -66,7 +66,8 @@ class ListModeBase : public ModeHandler
virtual void DisplayList(userrec* user, chanrec* channel)
{
- modelist* el = (modelist*)channel->GetExt(infokey);
+ modelist* el;
+ channel->GetExt(infokey, el);
if (el)
{
for(modelist::iterator it = el->begin(); it != el->end(); it++)
@@ -117,7 +118,8 @@ class ListModeBase : public ModeHandler
virtual ModeAction OnModeChange(userrec* source, userrec* dest, chanrec* channel, std::string &parameter, bool adding)
{
// Try and grab the list
- modelist* el = (modelist*)channel->GetExt(infokey);
+ modelist* el;
+ channel->GetExt(infokey, el);
if (adding)
{
@@ -238,7 +240,8 @@ class ListModeBase : public ModeHandler
virtual void DoChannelDelete(chanrec* chan)
{
- modelist* list = (modelist*)chan->GetExt(infokey);
+ modelist* list;
+ chan->GetExt(infokey, list);
if (list)
{
@@ -249,7 +252,8 @@ class ListModeBase : public ModeHandler
virtual void DoSyncChannel(chanrec* chan, Module* proto, void* opaque)
{
- modelist* list = (modelist*)chan->GetExt(infokey);
+ modelist* list;
+ chan->GetExt(infokey, list);
if (list)
{
for (modelist::iterator it = list->begin(); it != list->end(); it++)
@@ -265,7 +269,8 @@ class ListModeBase : public ModeHandler
{
chanrec* chan = (chanrec*)item;
- modelist* list = (modelist*)chan->GetExt(infokey);
+ modelist* list;
+ chan->GetExt(infokey, list);
if (list)
{
diff --git a/src/base.cpp b/src/base.cpp
index eb6ea900a..a7aa456f2 100644
--- a/src/base.cpp
+++ b/src/base.cpp
@@ -63,13 +63,13 @@ bool Extensible::Shrink(const std::string &key)
}
}
-char* Extensible::GetExt(const std::string &key)
+/*char* Extensible::GetExt(const std::string &key)
{
- /* This was calling ExtensibleStore::find() twice,
+ * This was calling ExtensibleStore::find() twice,
* once to see if there was a value, and again to
* get that value if it was there. Now we store
* the iterator so we only have to search for it once.
- */
+ *
ExtensibleStore::iterator iter = this->Extension_Items.find(key);
if(iter != this->Extension_Items.end())
@@ -80,7 +80,7 @@ char* Extensible::GetExt(const std::string &key)
{
return NULL;
}
-}
+}*/
void Extensible::GetExtList(std::deque<std::string> &list)
{
diff --git a/src/modules/m_banexception.cpp b/src/modules/m_banexception.cpp
index ba3a1b38a..ef8dc4d91 100644
--- a/src/modules/m_banexception.cpp
+++ b/src/modules/m_banexception.cpp
@@ -54,7 +54,8 @@ public:
{
if(chan != NULL)
{
- modelist* list = (modelist*)chan->GetExt(be->GetInfoKey());
+ modelist* list;
+ chan->GetExt(be->GetInfoKey(), list);
Srv->Log(DEBUG, std::string(user->nick)+" is trying to join "+std::string(chan->name)+", checking for ban exceptions");
if(list)
diff --git a/src/modules/m_blockamsg.cpp b/src/modules/m_blockamsg.cpp
index 0472e2417..fd28625d2 100644
--- a/src/modules/m_blockamsg.cpp
+++ b/src/modules/m_blockamsg.cpp
@@ -126,7 +126,8 @@ public:
userchans++;
// Check that this message wasn't already sent within a few seconds.
- BlockedMessage* m = (BlockedMessage*)user->GetExt("amsgblock");
+ BlockedMessage* m;
+ user->GetExt("amsgblock", m);
// If the message is identical and within the time.
// We check the target is *not* identical, that'd straying into the realms of flood control. Which isn't what we're doing...
@@ -168,7 +169,8 @@ public:
if(target_type == TYPE_USER)
{
userrec* user = (userrec*)item;
- BlockedMessage* m = (BlockedMessage*)user->GetExt("amsgblock");
+ BlockedMessage* m;
+ user->GetExt("amsgblock", m);
if(m)
{
DELETE(m);