summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt5
-rw-r--r--docs/C++CASTING5
-rw-r--r--include/extensible.h6
-rw-r--r--include/services.h17
-rw-r--r--include/sysconf.h.cmake2
-rw-r--r--modules/core/cs_set_mlock.cpp2
-rw-r--r--modules/core/db_plain.cpp6
-rw-r--r--modules/core/os_defcon.cpp2
-rw-r--r--modules/extra/mysql/db_mysql_write.cpp4
-rw-r--r--modules/protocol/bahamut.cpp2
-rw-r--r--modules/protocol/inspircd11.cpp2
-rw-r--r--modules/protocol/inspircd12.cpp2
-rw-r--r--modules/protocol/inspircd20.cpp2
-rw-r--r--modules/protocol/ratbox.cpp8
-rw-r--r--modules/protocol/unreal32.cpp8
-rw-r--r--src/channels.cpp26
-rw-r--r--src/chanserv.cpp4
-rw-r--r--src/config.cpp24
-rw-r--r--src/modes.cpp4
-rw-r--r--src/regchannel.cpp6
20 files changed, 83 insertions, 54 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 795d04b09..81be03bd3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -309,6 +309,11 @@ if(NOT DEFUMASK)
endif(RUNGROUP)
endif(NOT DEFUMASK)
+# Set the DEBUG_BUILD for sysconf.h
+if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
+ set(DEBUG_BUILD TRUE)
+endif(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")
+
# Check for the existance of the following include files
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(strings.h HAVE_STRINGS_H)
diff --git a/docs/C++CASTING b/docs/C++CASTING
index 5a121a5d1..bae24a24c 100644
--- a/docs/C++CASTING
+++ b/docs/C++CASTING
@@ -78,6 +78,11 @@ This is safer than C-style casting in that an invalid pointer conversion will
return a NULL pointer, and an invalid reference conversion will throw a
Bad_cast exception.
+Note that in Anope we prefer if Anope::debug_cast is used.
+This uses dynamic_cast (and checks for a NULL pointer return) on debug builds
+and static_cast on release builds, to speed up the program beacuse of dynamic_cast's
+reliance on RTTI.
+
reinterpret_cast
----------------
diff --git a/include/extensible.h b/include/extensible.h
index 523a25b6d..5ab32c6eb 100644
--- a/include/extensible.h
+++ b/include/extensible.h
@@ -153,7 +153,7 @@ class CoreExport Extensible
if (it != this->Extension_Items.end())
{
- p = dynamic_cast<ExtensibleItemRegular<T> *>(it->second)->GetItem();
+ p = debug_cast<ExtensibleItemRegular<T> *>(it->second)->GetItem();
return true;
}
@@ -172,7 +172,7 @@ class CoreExport Extensible
if (it != this->Extension_Items.end())
{
- p = dynamic_cast<ExtensibleItemPointer<T> *>(it->second)->GetItem();
+ p = debug_cast<ExtensibleItemPointer<T> *>(it->second)->GetItem();
return true;
}
@@ -192,7 +192,7 @@ class CoreExport Extensible
if (it != this->Extension_Items.end())
{
- p = dynamic_cast<ExtensibleItemPointerArray<T> *>(it->second)->GetItem();
+ p = debug_cast<ExtensibleItemPointerArray<T> *>(it->second)->GetItem();
return true;
}
diff --git a/include/services.h b/include/services.h
index 16f365a09..8e1adcf01 100644
--- a/include/services.h
+++ b/include/services.h
@@ -41,6 +41,7 @@
#include <sys/types.h>
#include <assert.h>
#include <fcntl.h>
+#include <typeinfo>
#ifndef _WIN32
# include <unistd.h>
@@ -268,6 +269,22 @@ class DatabaseException : public CoreException
virtual ~DatabaseException() throw() { }
};
+/** Debug cast to be used instead of dynamic_cast, this uses dynamic_cast
+ * for debug builds and static_cast on releass builds to speed up the program
+ * because dynamic_cast relies on RTTI.
+ */
+template<typename T, typename O> inline T debug_cast(O ptr)
+{
+#ifdef DEBUG_BUILD
+ T ret = dynamic_cast<T>(ptr);
+ if (ret == NULL)
+ throw CoreException(Anope::string("debug_cast<") + typeid(T).name() + ">(" + typeid(O).name() + ") fail");
+ return ret;
+#else
+ return static_cast<T>(ptr);
+#endif
+}
+
/*************************************************************************/
/** Class with the ability to keep flags on items, they should extend from this
diff --git a/include/sysconf.h.cmake b/include/sysconf.h.cmake
index 5884a3284..0184c5359 100644
--- a/include/sysconf.h.cmake
+++ b/include/sysconf.h.cmake
@@ -1,6 +1,8 @@
#ifndef _SYSCONF_H_
#define _SYSCONF_H_
+#cmakedefine DEBUG_BUILD
+
#cmakedefine DEFUMASK @DEFUMASK@
#cmakedefine HAVE_SYS_TYPES_H 1
#cmakedefine HAVE_STDINT_H 1
diff --git a/modules/core/cs_set_mlock.cpp b/modules/core/cs_set_mlock.cpp
index 2dc1ef2a7..166f6f71c 100644
--- a/modules/core/cs_set_mlock.cpp
+++ b/modules/core/cs_set_mlock.cpp
@@ -66,7 +66,7 @@ class CommandCSSetMLock : public Command
Anope::string param = params[paramcount];
- ChannelModeParam *cmp = dynamic_cast<ChannelModeParam *>(cm);
+ ChannelModeParam *cmp = debug_cast<ChannelModeParam *>(cm);
if (!cmp || !cmp->IsValid(param))
continue;
diff --git a/modules/core/db_plain.cpp b/modules/core/db_plain.cpp
index 331901f86..a9d87fab7 100644
--- a/modules/core/db_plain.cpp
+++ b/modules/core/db_plain.cpp
@@ -1014,7 +1014,7 @@ class DBPlain : public Module
{
if ((*it)->Class == MC_CHANNEL)
{
- ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
+ ChannelMode *cm = debug_cast<ChannelMode *>(*it);
if (ci->HasMLock(cm->Name, true))
db << " " << cm->NameAsString;
@@ -1029,7 +1029,7 @@ class DBPlain : public Module
{
if ((*it)->Class == MC_CHANNEL)
{
- ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
+ ChannelMode *cm = debug_cast<ChannelMode *>(*it);
if (ci->HasMLock(cm->Name, false))
db << " " << cm->NameAsString;
@@ -1042,7 +1042,7 @@ class DBPlain : public Module
{
if ((*it)->Class == MC_CHANNEL)
{
- ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
+ ChannelMode *cm = debug_cast<ChannelMode *>(*it);
if (ci->GetParam(cm->Name, Param))
db << "MD MLP " << cm->NameAsString << " " << Param << endl;
diff --git a/modules/core/os_defcon.cpp b/modules/core/os_defcon.cpp
index 155937753..cb25b50bf 100644
--- a/modules/core/os_defcon.cpp
+++ b/modules/core/os_defcon.cpp
@@ -428,7 +428,7 @@ void defconParseModeString(const Anope::string &str)
if (cm->Type == MODE_PARAM)
{
- cmp = dynamic_cast<ChannelModeParam *>(cm);
+ cmp = debug_cast<ChannelModeParam *>(cm);
if (!ss.GetToken(param))
{
diff --git a/modules/extra/mysql/db_mysql_write.cpp b/modules/extra/mysql/db_mysql_write.cpp
index 2d44450c1..5d2ef2a78 100644
--- a/modules/extra/mysql/db_mysql_write.cpp
+++ b/modules/extra/mysql/db_mysql_write.cpp
@@ -66,7 +66,7 @@ static std::string MakeMLock(ChannelInfo *ci, bool status)
{
if ((*it)->Class == MC_CHANNEL)
{
- ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
+ ChannelMode *cm = debug_cast<ChannelMode *>(*it);
if (ci->HasMLock(cm->Name, status))
ret += " " + cm->NameAsString;
@@ -97,7 +97,7 @@ static std::string GetMLockParams(ChannelInfo *ci)
{
if ((*it)->Class == MC_CHANNEL)
{
- ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
+ ChannelMode *cm = debug_cast<ChannelMode *>(*it);
std::string param;
if (ci->GetParam(cm->Name, param))
diff --git a/modules/protocol/bahamut.cpp b/modules/protocol/bahamut.cpp
index d80fb953b..9e28b1f9f 100644
--- a/modules/protocol/bahamut.cpp
+++ b/modules/protocol/bahamut.cpp
@@ -319,7 +319,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
if (m->Type != MODE_STATUS)
continue;
- ChannelMode *cm = dynamic_cast<ChannelMode *>(m);
+ ChannelMode *cm = debug_cast<ChannelMode *>(m);
for (CUserList::const_iterator uit = c->users.begin(), uit_end = c->users.end(); uit != uit_end; ++uit)
{
diff --git a/modules/protocol/inspircd11.cpp b/modules/protocol/inspircd11.cpp
index c58c011c9..3234ae81e 100644
--- a/modules/protocol/inspircd11.cpp
+++ b/modules/protocol/inspircd11.cpp
@@ -413,7 +413,7 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av)
if (m->Type != MODE_STATUS)
continue;
- ChannelMode *cm = dynamic_cast<ChannelMode *>(m);
+ ChannelMode *cm = debug_cast<ChannelMode *>(m);
for (CUserList::const_iterator uit = c->users.begin(), uit_end = c->users.end(); uit != uit_end; ++uit)
{
diff --git a/modules/protocol/inspircd12.cpp b/modules/protocol/inspircd12.cpp
index 4c1a5407e..f8d0c1563 100644
--- a/modules/protocol/inspircd12.cpp
+++ b/modules/protocol/inspircd12.cpp
@@ -454,7 +454,7 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av)
if (m->Type != MODE_STATUS)
continue;
- ChannelMode *cm = dynamic_cast<ChannelMode *>(m);
+ ChannelMode *cm = debug_cast<ChannelMode *>(m);
for (CUserList::const_iterator uit = c->users.begin(), uit_end = c->users.end(); uit != uit_end; ++uit)
{
diff --git a/modules/protocol/inspircd20.cpp b/modules/protocol/inspircd20.cpp
index 5097f24b8..043e3d256 100644
--- a/modules/protocol/inspircd20.cpp
+++ b/modules/protocol/inspircd20.cpp
@@ -452,7 +452,7 @@ int anope_event_fjoin(const Anope::string &source, int ac, const char **av)
if (m->Type != MODE_STATUS)
continue;
- ChannelMode *cm = dynamic_cast<ChannelMode *>(m);
+ ChannelMode *cm = debug_cast<ChannelMode *>(m);
for (CUserList::const_iterator uit = c->users.begin(), uit_end = c->users.end(); uit != uit_end; ++uit)
{
diff --git a/modules/protocol/ratbox.cpp b/modules/protocol/ratbox.cpp
index a01207a5d..df241e3fc 100644
--- a/modules/protocol/ratbox.cpp
+++ b/modules/protocol/ratbox.cpp
@@ -302,7 +302,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
if (m->Type != MODE_STATUS)
continue;
- ChannelMode *cm = dynamic_cast<ChannelMode *>(m);
+ ChannelMode *cm = debug_cast<ChannelMode *>(m);
for (CUserList::const_iterator uit = c->users.begin(), uit_end = c->users.end(); uit != uit_end; ++uit)
{
@@ -726,17 +726,17 @@ int anope_event_bmask(const Anope::string &source, int ac, const char **av)
Anope::string b = myStrGetToken(bans, ' ', i);
if (!stricmp(av[2], "b"))
{
- cms = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('b'));
+ cms = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('b'));
cms->AddMask(c, b);
}
if (!stricmp(av[2], "e"))
{
- cms = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('e'));
+ cms = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('e'));
cms->AddMask(c, b);
}
if (!stricmp(av[2], "I"))
{
- cms = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('I'));
+ cms = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('I'));
cms->AddMask(c, b);
}
}
diff --git a/modules/protocol/unreal32.cpp b/modules/protocol/unreal32.cpp
index 4383d88c4..486e248d4 100644
--- a/modules/protocol/unreal32.cpp
+++ b/modules/protocol/unreal32.cpp
@@ -1008,7 +1008,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
if (m->Type != MODE_STATUS)
continue;
- ChannelMode *cm = dynamic_cast<ChannelMode *>(m);
+ ChannelMode *cm = debug_cast<ChannelMode *>(m);
for (CUserList::const_iterator uit = c->users.begin(), uit_end = c->users.end(); uit != uit_end; ++uit)
{
@@ -1052,7 +1052,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
if (keep_their_modes && buf[0] == '&')
{
buf.erase(buf.begin());
- ChannelModeList *cml = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_BAN));
+ ChannelModeList *cml = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_BAN));
if (cml->IsValid(buf))
cml->AddMask(c, buf);
@@ -1061,7 +1061,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
else if (keep_their_modes && buf[0] == '"')
{
buf.erase(buf.begin());
- ChannelModeList *cml = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_EXCEPT));
+ ChannelModeList *cml = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_EXCEPT));
if (cml->IsValid(buf))
cml->AddMask(c, buf);
@@ -1070,7 +1070,7 @@ int anope_event_sjoin(const Anope::string &source, int ac, const char **av)
else if (keep_their_modes && buf[0] == '\'')
{
buf.erase(buf.begin());
- ChannelModeList *cml = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE));
+ ChannelModeList *cml = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE));
if (cml->IsValid(buf))
cml->AddMask(c, buf);
diff --git a/src/channels.cpp b/src/channels.cpp
index 9654b295b..0d034f222 100644
--- a/src/channels.cpp
+++ b/src/channels.cpp
@@ -232,7 +232,7 @@ bool Channel::HasUserStatus(User *u, ChannelModeStatus *cms) const
*/
bool Channel::HasUserStatus(User *u, ChannelModeName Name) const
{
- return HasUserStatus(u, dynamic_cast<ChannelModeStatus *>(ModeManager::FindChannelModeByName(Name)));
+ return HasUserStatus(u, debug_cast<ChannelModeStatus *>(ModeManager::FindChannelModeByName(Name)));
}
/**
@@ -298,7 +298,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const Anope::string &param, bool
return;
}
- ChannelModeList *cml = dynamic_cast<ChannelModeList *>(cm);
+ ChannelModeList *cml = debug_cast<ChannelModeList *>(cm);
cml->AddMask(this, param);
return;
}
@@ -357,7 +357,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const Anope::string &param, bool
/* If this is a param mode and its mlocked +, check to ensure someone didn't reset it with the wrong param */
else if (cm->Type == MODE_PARAM && ci->HasMLock(cm->Name, true))
{
- ChannelModeParam *cmp = dynamic_cast<ChannelModeParam *>(cm);
+ ChannelModeParam *cmp = debug_cast<ChannelModeParam *>(cm);
Anope::string cparam, ciparam;
/* Get the param currently set on this channel */
GetParam(cmp->Name, cparam);
@@ -429,7 +429,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const Anope::string &param, bo
return;
}
- ChannelModeList *cml = dynamic_cast<ChannelModeList *>(cm);
+ ChannelModeList *cml = debug_cast<ChannelModeList *>(cm);
cml->DelMask(this, param);
return;
}
@@ -509,7 +509,7 @@ void Channel::SetMode(BotInfo *bi, ChannelMode *cm, const Anope::string &param,
else if (cm->Type == MODE_STATUS)
{
User *u = finduser(param);
- if (u && HasUserStatus(u, dynamic_cast<ChannelModeStatus *>(cm)))
+ if (u && HasUserStatus(u, debug_cast<ChannelModeStatus *>(cm)))
return;
}
else if (cm->Type == MODE_LIST)
@@ -562,7 +562,7 @@ void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string &para
else if (cm->Type == MODE_STATUS)
{
User *u = finduser(param);
- if (u && !HasUserStatus(u, dynamic_cast<ChannelModeStatus *>(cm)))
+ if (u && !HasUserStatus(u, debug_cast<ChannelModeStatus *>(cm)))
return;
}
else if (cm->Type == MODE_LIST)
@@ -574,7 +574,7 @@ void Channel::RemoveMode(BotInfo *bi, ChannelMode *cm, const Anope::string &para
bool SendParam = true;
if (cm->Type == MODE_PARAM)
{
- ChannelModeParam *cmp = dynamic_cast<ChannelModeParam *>(cm);
+ ChannelModeParam *cmp = debug_cast<ChannelModeParam *>(cm);
if (cmp->MinusNoArg)
SendParam = false;
}
@@ -677,7 +677,7 @@ void Channel::ClearBans(BotInfo *bi)
Entry *entry, *nexte;
ChannelModeList *cml;
- cml = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_BAN));
+ cml = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_BAN));
if (cml && this->bans && this->bans->count)
for (entry = this->bans->entries; entry; entry = nexte)
@@ -696,7 +696,7 @@ void Channel::ClearExcepts(BotInfo *bi)
Entry *entry, *nexte;
ChannelModeList *cml;
- cml = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_EXCEPT));
+ cml = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_EXCEPT));
if (cml && this->excepts && this->excepts->count)
for (entry = this->excepts->entries; entry; entry = nexte)
@@ -715,7 +715,7 @@ void Channel::ClearInvites(BotInfo *bi)
Entry *entry, *nexte;
ChannelModeList *cml;
- cml = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE));
+ cml = debug_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE));
if (cml && this->invites && this->invites->count)
for (entry = this->invites->entries; entry; entry = nexte)
@@ -823,7 +823,7 @@ void ChanSetInternalModes(Channel *c, int ac, const char **av)
}
else if (cm->Type == MODE_PARAM)
{
- ChannelModeParam *cmp = dynamic_cast<ChannelModeParam *>(cm);
+ ChannelModeParam *cmp = debug_cast<ChannelModeParam *>(cm);
if (!add && cmp->MinusNoArg)
{
@@ -927,7 +927,7 @@ Anope::string chan_get_modes(Channel *chan, int complete, int plus)
if ((*it)->Class != MC_CHANNEL)
continue;
- ChannelMode *cm = dynamic_cast<ChannelMode *>(*it);
+ ChannelMode *cm = debug_cast<ChannelMode *>(*it);
if (chan->HasMode(cm->Name))
{
@@ -937,7 +937,7 @@ Anope::string chan_get_modes(Channel *chan, int complete, int plus)
{
if (cm->Type == MODE_PARAM)
{
- ChannelModeParam *cmp = dynamic_cast<ChannelModeParam *>(cm);
+ ChannelModeParam *cmp = debug_cast<ChannelModeParam *>(cm);
if (plus || !cmp->MinusNoArg)
{
diff --git a/src/chanserv.cpp b/src/chanserv.cpp
index bcfe239cd..07ebe9525 100644
--- a/src/chanserv.cpp
+++ b/src/chanserv.cpp
@@ -160,7 +160,7 @@ Anope::string get_mlock_modes(ChannelInfo *ci, int complete)
if (cm->Type == MODE_PARAM)
{
- cmp = dynamic_cast<ChannelModeParam *>(cm);
+ cmp = debug_cast<ChannelModeParam *>(cm);
ci->GetParam(cmp->Name, param);
@@ -343,7 +343,7 @@ void check_modes(Channel *c)
/* Add the eventual parameter */
if (cm->Type == MODE_PARAM)
{
- ChannelModeParam *cmp = dynamic_cast<ChannelModeParam *>(cm);
+ ChannelModeParam *cmp = debug_cast<ChannelModeParam *>(cm);
if (!cmp->MinusNoArg)
{
diff --git a/src/config.cpp b/src/config.cpp
index 7dbce6a61..725138516 100644
--- a/src/config.cpp
+++ b/src/config.cpp
@@ -838,82 +838,82 @@ int ServerConfig::Read(bool bail)
{
case DT_NOSPACES:
{
- ValueContainerString *vcs = dynamic_cast<ValueContainerString *>(Values[Index].val);
+ ValueContainerString *vcs = debug_cast<ValueContainerString *>(Values[Index].val);
ValidateNoSpaces(vi.GetValue(), Values[Index].tag, Values[Index].value);
vcs->Set(vi.GetValue());
}
break;
case DT_HOSTNAME:
{
- ValueContainerString *vcs = dynamic_cast<ValueContainerString *>(Values[Index].val);
+ ValueContainerString *vcs = debug_cast<ValueContainerString *>(Values[Index].val);
ValidateHostname(vi.GetValue(), Values[Index].tag, Values[Index].value);
vcs->Set(vi.GetValue());
}
break;
case DT_IPADDRESS:
{
- ValueContainerString *vcs = dynamic_cast<ValueContainerString *>(Values[Index].val);
+ ValueContainerString *vcs = debug_cast<ValueContainerString *>(Values[Index].val);
ValidateIP(vi.GetValue(), Values[Index].tag, Values[Index].value, allow_wild);
vcs->Set(vi.GetValue());
}
break;
case DT_CHARPTR:
{
- ValueContainerChar *vcc = dynamic_cast<ValueContainerChar *>(Values[Index].val);
+ ValueContainerChar *vcc = debug_cast<ValueContainerChar *>(Values[Index].val);
// Make sure we also copy the null terminator
vcc->Set(vi.GetString(), strlen(vi.GetString()) + 1);
}
break;
case DT_CSSTRING:
{
- ValueContainerCSString *vcs = dynamic_cast<ValueContainerCSString *>(Values[Index].val);
+ ValueContainerCSString *vcs = debug_cast<ValueContainerCSString *>(Values[Index].val);
vcs->Set(vi.GetCSValue());
}
break;
case DT_CISTRING:
{
- ValueContainerCIString *vcs = dynamic_cast<ValueContainerCIString *>(Values[Index].val);
+ ValueContainerCIString *vcs = debug_cast<ValueContainerCIString *>(Values[Index].val);
vcs->Set(vi.GetCIValue());
}
break;
case DT_STRING:
{
- ValueContainerString *vcs = dynamic_cast<ValueContainerString *>(Values[Index].val);
+ ValueContainerString *vcs = debug_cast<ValueContainerString *>(Values[Index].val);
vcs->Set(vi.GetValue());
}
break;
case DT_INTEGER:
{
int val = vi.GetInteger();
- ValueContainerInt *vci = dynamic_cast<ValueContainerInt *>(Values[Index].val);
+ ValueContainerInt *vci = debug_cast<ValueContainerInt *>(Values[Index].val);
vci->Set(&val, sizeof(int));
}
break;
case DT_UINTEGER:
{
unsigned val = vi.GetInteger();
- ValueContainerUInt *vci = dynamic_cast<ValueContainerUInt *>(Values[Index].val);
+ ValueContainerUInt *vci = debug_cast<ValueContainerUInt *>(Values[Index].val);
vci->Set(&val, sizeof(unsigned));
}
break;
case DT_LUINTEGER:
{
unsigned long val = vi.GetInteger();
- ValueContainerLUInt *vci = dynamic_cast<ValueContainerLUInt *>(Values[Index].val);
+ ValueContainerLUInt *vci = debug_cast<ValueContainerLUInt *>(Values[Index].val);
vci->Set(&val, sizeof(unsigned long));
}
break;
case DT_TIME:
{
time_t time = dotime(vi.GetValue());
- ValueContainerTime *vci = dynamic_cast<ValueContainerTime *>(Values[Index].val);
+ ValueContainerTime *vci = debug_cast<ValueContainerTime *>(Values[Index].val);
vci->Set(&time, sizeof(time_t));
}
break;
case DT_BOOLEAN:
{
bool val = vi.GetBool();
- ValueContainerBool *vcb = dynamic_cast<ValueContainerBool *>(Values[Index].val);
+ ValueContainerBool *vcb = debug_cast<ValueContainerBool *>(Values[Index].val);
vcb->Set(&val, sizeof(bool));
}
break;
diff --git a/src/modes.cpp b/src/modes.cpp
index af4c2f879..6d8fca77e 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -87,7 +87,7 @@ void SetDefaultMLock()
ChannelMode *cm = ModeManager::FindChannelModeByChar(Config.BotModes[i]);
if (cm && cm->Type == MODE_STATUS && std::find(BotModes.begin(), BotModes.end(), cm) == BotModes.end())
- BotModes.push_back(dynamic_cast<ChannelModeStatus *>(cm));
+ BotModes.push_back(debug_cast<ChannelModeStatus *>(cm));
}
}
@@ -730,7 +730,7 @@ char ModeManager::GetStatusChar(char Value)
cm = it->second;
if (cm->Type == MODE_STATUS)
{
- cms = dynamic_cast<ChannelModeStatus *>(cm);
+ cms = debug_cast<ChannelModeStatus *>(cm);
if (Value == cms->Symbol)
return it->first;
diff --git a/src/regchannel.cpp b/src/regchannel.cpp
index 019f173e5..ea16b05da 100644
--- a/src/regchannel.cpp
+++ b/src/regchannel.cpp
@@ -352,7 +352,7 @@ void ChannelInfo::LoadMLock()
{
if ((*mit)->Class == MC_CHANNEL)
{
- ChannelMode *cm = dynamic_cast<ChannelMode *>(*mit);
+ ChannelMode *cm = debug_cast<ChannelMode *>(*mit);
if (cm->NameAsString.equals_ci(*it))
this->SetMLock(cm->Name, true);
@@ -371,7 +371,7 @@ void ChannelInfo::LoadMLock()
{
if ((*mit)->Class == MC_CHANNEL)
{
- ChannelMode *cm = dynamic_cast<ChannelMode *>(*mit);
+ ChannelMode *cm = debug_cast<ChannelMode *>(*mit);
if (cm->NameAsString.equals_ci(*it))
this->SetMLock(cm->Name, false);
@@ -392,7 +392,7 @@ void ChannelInfo::LoadMLock()
{
if ((*mit)->Class == MC_CHANNEL)
{
- ChannelMode *cm = dynamic_cast<ChannelMode *>(*mit);
+ ChannelMode *cm = debug_cast<ChannelMode *>(*mit);
if (cm->NameAsString.equals_ci(it->first))
this->SetMLock(cm->Name, true, it->second);