[[project @ 2003-07-23 05:56:23 by unknown_lamer] unknown_lamer**20030723055623 * source/Parser.C (parseMessage): use the find method of std::map to find the command to call instead of [] and then extract the pointer to the userFunction from that if it exists. This appears to fix the crash when one uses an undefined command followed by any defined command. ] { hunk ./source/Parser.C 918 - userFunction * f = cnx->bot->userFunctions[command]; + std::map >::const_iterator uf_iter + = cnx->bot->userFunctions.find (command); + userFunction * f = 0; + + if (uf_iter != cnx->bot->userFunctions.end ()) + f = uf_iter->second; + else + return; + hunk ./source/Parser.C 938 - if (!Utils::isChannel (to)) - { - from->sendNotice ("\002You need to supply a channel name" - " for this command\002"); - return; - } - if (!cnx->bot->channelList->getChannel (to)) - { - from->sendNotice (String ("\002I am not on channel\002 ") + - to); - return; - } - level = Utils::getLevel (cnx->bot, from->getAddress (), to); - User *u = 0; - if (Channel * c = cnx->bot->channelList->getChannel (to)) - u = c->getUser (from->getNick ()); - if (!u || !u->userListItem) - identified = true; - else - identified = u->userListItem->passwd == "" - || u->userListItem->identified > 0; - } - else - { - level = Utils::getLevel (cnx->bot, from->getAddress ()); + if (!Utils::isChannel (to)) + { + from->sendNotice ("\002You need to supply a channel name" + " for this command\002"); + return; + } + if (!cnx->bot->channelList->getChannel (to)) + { + from->sendNotice (String ("\002I am not on channel\002 ") + + to); + return; + } + level = Utils::getLevel (cnx->bot, from->getAddress (), to); + User *u = 0; + if (Channel * c = cnx->bot->channelList->getChannel (to)) + u = c->getUser (from->getNick ()); + if (!u || !u->userListItem) hunk ./source/Parser.C 956 - } - if (level >= f->minLevel) - { - cnx->bot->logLine (from->getAddress () + " did " + command + - " " + rest); + else + identified = u->userListItem->passwd == "" + || u->userListItem->identified > 0; + } + else + { + level = Utils::getLevel (cnx->bot, from->getAddress ()); + identified = true; + } + if (level >= f->minLevel) + { + cnx->bot->logLine (from->getAddress () + " did " + command + + " " + rest); hunk ./source/Parser.C 970 - if (f->argsCount != -1) - { - Parser::parseScriptFunction (cnx, to, f->needsChannelName, - f->scmFunc, f->argsCount, - rest); - } - else - { - f->function (cnx, from, to, rest); - } + if (f->argsCount != -1) + { + Parser::parseScriptFunction (cnx, to, f->needsChannelName, + f->scmFunc, f->argsCount, + rest); + } + else + { + f->function (cnx, from, to, rest); + } hunk ./source/Parser.C 981 - f->function (cnx, from, to, rest); + f->function (cnx, from, to, rest); hunk ./source/Parser.C 983 - } - else - { - if (!identified) - from-> - sendNotice (String - ("\002You are not identified on channel\002 ") + - to); - } - } + } + else + { + if (!identified) + from-> + sendNotice (String + ("\002You are not identified on channel\002 ") + + to); + } + } }