void ModeHandler::ChangeCount(int modifier)
{
count += modifier;
+ ServerInstance->Log(DEBUG,"Change count for mode %c is now %d", mode, count);
}
ModeType ModeHandler::GetModeType()
chanrec* targetchannel = ServerInstance->FindChan(parameters[0]);
userrec* targetuser = ServerInstance->FindNick(parameters[0]);
- LastParse = "";
+ LastParse.clear();
/* Special case for displaying the list for listmodes,
* e.g. MODE #chan b, or MODE #chan +b without a parameter
}
std::string mode_sequence = parameters[1];
- std::string parameter = "";
+ std::string parameter;
std::ostringstream parameter_list;
- std::string output_sequence = "";
+ std::string output_sequence;
bool adding = true, state_change = false;
unsigned char handler_id = 0;
int parameter_counter = 2; /* Index of first parameter */
/* Yerk, invalid! */
if ((parameter.find(':') == 0) || (parameter.rfind(' ') != std::string::npos))
- parameter = "";
+ parameter.clear();
}
else
{
for (ModeWatchIter watchers = modewatchers[handler_id].begin(); watchers != modewatchers[handler_id].end(); watchers++)
{
- ServerInstance->Log(DEBUG,"Call mode watcher");
if ((*watchers)->BeforeMode(user, targetuser, targetchannel, parameter, adding, type) == false)
{
abort = true;
/* Call the handler for the mode */
ModeAction ma = modehandlers[handler_id]->OnModeChange(user, targetuser, targetchannel, parameter, adding);
- if ((modehandlers[handler_id]->GetNumParams(adding)) && (parameter == ""))
+ if ((modehandlers[handler_id]->GetNumParams(adding)) && (parameter.empty()))
{
/* The handler nuked the parameter and they are supposed to have one.
* We CANT continue now, even if they actually returned MODEACTION_ALLOW,
/* Add the mode letter */
output_sequence.push_back(modechar);
+ modehandlers[handler_id]->ChangeCount(adding ? 1 : -1);
+
/* Is there a valid parameter for this mode? If so add it to the parameter list */
- if ((modehandlers[handler_id]->GetNumParams(adding)) && (parameter != ""))
+ if ((modehandlers[handler_id]->GetNumParams(adding)) && (!parameter.empty()))
{
parameter_list << " " << parameter;
parameter_count++;
break;
}
}
+
/* Was there at least one valid mode in the sequence? */
- if (output_sequence != "")
+ if (!output_sequence.empty())
{
if (servermode)
{
* If they do that, thats their problem, and if i ever EVER see an
* official InspIRCd developer do that, i'll beat them with a paddle!
*/
- if ((mh->GetModeChar() < 'A') || (mh->GetModeChar() > 'z'))
+ if ((mh->GetModeChar() < 'A') || (mh->GetModeChar() > 'z') || (mh->GetPrefix() > 126))
return false;
/* A mode prefix of ',' is not acceptable, it would fuck up server to server.
for (unsigned char mode = 'A'; mode <= 'z'; mode++)
{
+ if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
+ continue;
+
unsigned char pos = (mode-65) | MASK_CHANNEL;
if (modehandlers[pos])
for (unsigned char mode = 'A'; mode <= 'z'; mode++)
{
+ if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
+ continue;
+
unsigned char pos = (mode-65) | MASK_CHANNEL;
if ((modehandlers[pos]) && (modehandlers[pos]->GetNumParams(true)))
for (unsigned char mode = 'A'; mode <= 'z'; mode++)
{
+ if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
+ continue;
+
unsigned char pos = (mode-65) | MASK_CHANNEL;
/* One parameter when adding */
if (modehandlers[pos])
return type1 + "," + type2 + "," + type3 + "," + type4;
}
-bool ModeParser::PrefixComparison(const prefixtype one, const prefixtype two)
+bool ModeParser::PrefixComparison(prefixtype one, prefixtype two)
{
return one.second > two.second;
}
std::string ModeParser::BuildPrefixes()
{
- std::string mletters = "";
- std::string mprefixes = "";
+ std::string mletters;
+ std::string mprefixes;
pfxcontainer pfx;
std::map<char,char> prefix_to_mode;
for (unsigned char mode = 'A'; mode <= 'z'; mode++)
{
+ if ((!ServerInstance->Config->AllowHalfop) && (mode == 'h'))
+ continue;
+
unsigned char pos = (mode-65) | MASK_CHANNEL;
if ((modehandlers[pos]) && (modehandlers[pos]->GetPrefix()))
memset(modewatchers, 0, sizeof(modewatchers));
/* Last parse string */
- LastParse = "";
+ LastParse.clear();
/* Initialise the RFC mode letters */
for (int index = 0; modes[index].modechar; index++)