ForgottenNot
Member
- Joined
- Feb 10, 2023
- Messages
- 192
- Reaction score
- 19
ExUrA will work(and all others)
Ex Ura will work(and all others)
Utevo lux "blabla works
the problem is that certain spells were quotes are not being used, are crashing the server. ex: exani hur up or utevo res orc
if we use quotes everything is okey. is there a way to add param monster name
in xml do we have this
is there a way to add a parameter so if params="1" in spells.xml it will add quotes automatically
if (instantSpell->getHasParam() && !param.empty()) {
words += " \"" + param + "\"";
}
or add monstername parameter + up word something like that
spells.cpp
Ex Ura will work(and all others)
Utevo lux "blabla works
the problem is that certain spells were quotes are not being used, are crashing the server. ex: exani hur up or utevo res orc
if we use quotes everything is okey. is there a way to add param monster name
in xml do we have this
Lua:
params="1"
if (instantSpell->getHasParam() && !param.empty()) {
words += " \"" + param + "\"";
}
or add monstername parameter + up word something like that
spells.cpp
Code:
TalkActionResult_t Spells::playerSaySpell(Player* player, std::string& words)
{
std::string str_words = words;
//strip trailing spaces
trimString(str_words);
InstantSpell* instantSpell = getInstantSpell(str_words);
if (!instantSpell) {
return TALKACTION_CONTINUE;
}
std::string param;
if (instantSpell->getHasParam()) {
size_t spellLen = instantSpell->getWords().length();
size_t paramLen = str_words.length() - spellLen;
std::string paramText = str_words.substr(spellLen, paramLen);
if (!paramText.empty() && paramText.front() == ' ') {
size_t loc1 = paramText.find('"', 1);
if (loc1 != std::string::npos) {
size_t loc2 = paramText.find('"', loc1 + 1);
if (loc2 == std::string::npos) {
loc2 = paramText.length();
} else if (paramText.find_last_not_of(' ') != loc2) {
return TALKACTION_CONTINUE;
}
param = paramText.substr(loc1 + 1, loc2 - loc1 - 1);
} else {
trimString(paramText);
loc1 = paramText.find(' ', 0);
if (loc1 == std::string::npos) {
param = paramText;
} else {
return TALKACTION_CONTINUE;
}
}
}
}
if (instantSpell->playerCastInstant(player, param)) {
words = instantSpell->getWords();
//words = words /*instantSpell->getWords()*/;
if (instantSpell->getHasParam() && !param.empty()) {
words += " \"" + param + "\"";
}
//words = instantSpell->getWords();
//words = words /*instantSpell->getWords()*/;
// if (instantSpell->getHasParam() && !param.empty()) {
// words += " \"" + param + "\"";
//}
return TALKACTION_BREAK;
}
return TALKACTION_FAILED;
}
Code:
InstantSpell* Spells::getInstantSpell(const std::string& words)
{
InstantSpell* result = nullptr;
for (auto& it : instants) {
const std::string& instantSpellWords = it.second.getWords();
size_t spellLen = instantSpellWords.length();
if (caseInsensitiveStartsWith(words, instantSpellWords)) {
if (!result || spellLen > result->getWords().size()) {
result = &it.second;
if (words.length() == spellLen) {
break;
}
}
}
}
/*if (result) {
const std::string& resultWords = result->getWords();
if (words.length() > resultWords.length()) {
if (!result->getHasParam()) {
return nullptr;
}*/
if (result && words.length() > result->getWords().length())
{
std::string param = words.substr(result->getWords().length(), words.length());
if (param[0] != ' ' || (param.length() > 1 && (!result->getHasParam() || param.find(' ', 1) != std::string::npos) && param[1] != '"'))
return nullptr;
}
//size_t spellLen = resultWords.length();
//size_t spellLen = words.length();
//size_t paramLen = words.length() - spellLen;
//if (paramLen < 2 || words[spellLen] != ' ') {
//return nullptr;
//}
//}
return result;
//}
return nullptr;
}