summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-12-23 08:41:22 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-12-23 08:41:22 +0000
commit80cbac3769b03d6e88c509ef6cfbe4e1983ca748 (patch)
tree0c2607fa08e3b04cb6a8db4f04109a241ebb7785
parentf82640af7cc534f284914e12233098c4882a484d (diff)
Replaced some static_casts related to modes with dynamic_cast - its a bit safer
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2715 5417fbe8-f217-4b02-8779-1006273d7864
-rw-r--r--src/channels.c30
-rw-r--r--src/chanserv.c4
-rw-r--r--src/core/cs_set.c2
-rw-r--r--src/core/os_defcon.c2
-rw-r--r--src/modes.cpp2
-rw-r--r--src/protocol/ratbox.c6
6 files changed, 23 insertions, 23 deletions
diff --git a/src/channels.c b/src/channels.c
index bb4b04cff..85028b584 100644
--- a/src/channels.c
+++ b/src/channels.c
@@ -167,7 +167,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string &param, bool En
if (debug)
alog("debug: Setting +%c on %s for %s", cm->ModeChar, this->name, u->nick);
- ChannelModeStatus *cms = static_cast<ChannelModeStatus *>(cm);
+ ChannelModeStatus *cms = dynamic_cast<ChannelModeStatus *>(cm);
/* Set the new status on the user */
chan_set_user_status(this, u, cms->Status);
/* Enforce secureops, etc */
@@ -183,7 +183,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string &param, bool En
return;
}
- ChannelModeList *cml = static_cast<ChannelModeList *>(cm);
+ ChannelModeList *cml = dynamic_cast<ChannelModeList *>(cm);
cml->AddMask(this, param.c_str());
return;
}
@@ -228,7 +228,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string &param, bool En
/* Remove the mode */
if (cm->Type == MODE_PARAM)
{
- ChannelModeParam *cmp = static_cast<ChannelModeParam *>(cmp);
+ ChannelModeParam *cmp = dynamic_cast<ChannelModeParam *>(cmp);
if (!cmp->MinusNoArg)
{
@@ -246,7 +246,7 @@ void Channel::SetModeInternal(ChannelMode *cm, const std::string &param, bool En
/* 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 = static_cast<ChannelModeParam *>(cm);
+ ChannelModeParam *cmp = dynamic_cast<ChannelModeParam *>(cm);
std::string cparam, ciparam;
/* Get the param currently set on this channel */
GetParam(cmp->Name, &cparam);
@@ -295,7 +295,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string &param, bool
if (debug)
alog("debug: Setting +%c on %s for %s", cm->ModeChar, this->name, u->nick);
- ChannelModeStatus *cms = static_cast<ChannelModeStatus *>(cm);
+ ChannelModeStatus *cms = dynamic_cast<ChannelModeStatus *>(cm);
chan_remove_user_status(this, u, cms->Status);
return;
}
@@ -308,7 +308,7 @@ void Channel::RemoveModeInternal(ChannelMode *cm, const std::string &param, bool
return;
}
- ChannelModeList *cml = static_cast<ChannelModeList *>(cm);
+ ChannelModeList *cml = dynamic_cast<ChannelModeList *>(cm);
cml->DelMask(this, param.c_str());
return;
}
@@ -495,7 +495,7 @@ void Channel::ClearModes(BotInfo *bi)
}
else if (cm->Type == MODE_PARAM)
{
- cmp = static_cast<ChannelModeParam *>(cm);
+ cmp = dynamic_cast<ChannelModeParam *>(cm);
if (!cmp->MinusNoArg)
{
@@ -522,7 +522,7 @@ void Channel::ClearBans(BotInfo *bi)
Entry *entry, *nexte;
ChannelModeList *cml;
- cml = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_BAN));
+ cml = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_BAN));
if (cml && this->bans && this->bans->count)
{
@@ -543,7 +543,7 @@ void Channel::ClearExcepts(BotInfo *bi)
Entry *entry, *nexte;
ChannelModeList *cml;
- cml = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_EXCEPT));
+ cml = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_EXCEPT));
if (cml && this->excepts && this->excepts->count)
{
@@ -564,7 +564,7 @@ void Channel::ClearInvites(BotInfo *bi)
Entry *entry, *nexte;
ChannelModeList *cml;
- cml = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE));
+ cml = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE));
if (cml && this->invites && this->invites->count)
{
@@ -674,7 +674,7 @@ void ChanSetInternalModes(Channel *c, int ac, const char **av)
}
else if (cm->Type == MODE_PARAM)
{
- ChannelModeParam *cmp = static_cast<ChannelModeParam *>(cm);
+ ChannelModeParam *cmp = dynamic_cast<ChannelModeParam *>(cm);
if (!add && cmp->MinusNoArg)
{
@@ -771,7 +771,7 @@ char *chan_get_modes(Channel * chan, int complete, int plus)
{
if (cm->Type == MODE_PARAM)
{
- cmp = static_cast<ChannelModeParam *>(cm);
+ cmp = dynamic_cast<ChannelModeParam *>(cm);
if (plus || !cmp->MinusNoArg)
{
@@ -1358,7 +1358,7 @@ void do_sjoin(const char *source, int ac, const char **av)
if (*s == ircd->sjoinbanchar && keep_their_modes) {
buf = myStrGetToken(s, ircd->sjoinbanchar, 1);
- cml = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_BAN));
+ cml = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_BAN));
if (cml->IsValid(buf))
cml->AddMask(c, buf);
@@ -1373,7 +1373,7 @@ void do_sjoin(const char *source, int ac, const char **av)
if (*s == ircd->sjoinexchar && keep_their_modes) {
buf = myStrGetToken(s, ircd->sjoinexchar, 1);
- cml = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_EXCEPT));
+ cml = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_EXCEPT));
if (cml->IsValid(buf))
cml->AddMask(c, buf);
@@ -1389,7 +1389,7 @@ void do_sjoin(const char *source, int ac, const char **av)
if (*s == ircd->sjoininvchar && keep_their_modes) {
buf = myStrGetToken(s, ircd->sjoininvchar, 1);
- cml = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE));
+ cml = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByName(CMODE_INVITEOVERRIDE));
if (cml->IsValid(buf))
cml->AddMask(c, buf);
diff --git a/src/chanserv.c b/src/chanserv.c
index 941925b1b..dc5345ed6 100644
--- a/src/chanserv.c
+++ b/src/chanserv.c
@@ -193,7 +193,7 @@ char *get_mlock_modes(ChannelInfo * ci, int complete)
if (cm->Type == MODE_PARAM)
{
- cmp = static_cast<ChannelModeParam *>(cm);
+ cmp = dynamic_cast<ChannelModeParam *>(cm);
ci->GetParam(cmp->Name, &param);
@@ -395,7 +395,7 @@ void check_modes(Channel *c)
/* Add the eventual parameter */
if (cm->Type == MODE_PARAM)
{
- cmp = static_cast<ChannelModeParam *>(cm);
+ cmp = dynamic_cast<ChannelModeParam *>(cm);
if (!cmp->MinusNoArg)
{
diff --git a/src/core/cs_set.c b/src/core/cs_set.c
index 1ac511e17..3d2876f38 100644
--- a/src/core/cs_set.c
+++ b/src/core/cs_set.c
@@ -212,7 +212,7 @@ class CommandCSSet : public Command
if (cm->Type == MODE_PARAM)
{
- cmp = static_cast<ChannelModeParam *>(cm);
+ cmp = dynamic_cast<ChannelModeParam *>(cm);
if (!modeparams.GetToken(param))
continue;
diff --git a/src/core/os_defcon.c b/src/core/os_defcon.c
index 4b427d602..804839bf8 100644
--- a/src/core/os_defcon.c
+++ b/src/core/os_defcon.c
@@ -445,7 +445,7 @@ void defconParseModeString(const char *str)
if (cm->Type == MODE_PARAM)
{
- cmp = static_cast<ChannelModeParam *>(cm);
+ cmp = dynamic_cast<ChannelModeParam *>(cm);
if (!ss.GetToken(param))
{
diff --git a/src/modes.cpp b/src/modes.cpp
index 90a3a648c..9fed6da55 100644
--- a/src/modes.cpp
+++ b/src/modes.cpp
@@ -713,7 +713,7 @@ char ModeManager::GetStatusChar(char Value)
cm = it->second;
if (cm->Type == MODE_STATUS)
{
- cms = static_cast<ChannelModeStatus *>(cm);
+ cms = dynamic_cast<ChannelModeStatus *>(cm);
if (Value == cms->Symbol)
{
diff --git a/src/protocol/ratbox.c b/src/protocol/ratbox.c
index f10a4abcd..3b9f982aa 100644
--- a/src/protocol/ratbox.c
+++ b/src/protocol/ratbox.c
@@ -735,15 +735,15 @@ int anope_event_bmask(const char *source, int ac, const char **av)
for (i = 0; i <= count - 1; i++) {
b = myStrGetToken(bans, ' ', i);
if (!stricmp(av[2], "b")) {
- cms = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('b'));
+ cms = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('b'));
cms->AddMask(c, b);
}
if (!stricmp(av[2], "e")) {
- cms = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('e'));
+ cms = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('e'));
cms->AddMask(c, b);
}
if (!stricmp(av[2], "I")) {
- cms = static_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('I'));
+ cms = dynamic_cast<ChannelModeList *>(ModeManager::FindChannelModeByChar('I'));
cms->AddMask(c, b);
}
if (b)