void ChatTab::chatInput(const std::string &message) { std::string msg = message; trim(msg); if (msg.empty()) return; replaceItemLinks(msg); replaceVars(msg); switch (msg[0]) { case '/': handleCommandStr(std::string(msg, 1)); break; case '?': if (msg.size() > 1 && msg[1] != '!' && msg[1] != '?' && msg[1] != '.' && msg[1] != ' ' && msg[1] != ',') { handleHelp(std::string(msg, 1)); } else { handleInput(msg); } break; default: handleInput(msg); break; } }
static void loadQuest(const int var, XmlNodeConstPtr node) { if (node == nullptr) return; QuestItem *const quest = new QuestItem; // TRANSLATORS: quests window quest name quest->name = XML::langProperty(node, "name", _("unknown")); quest->group = XML::getProperty(node, "group", ""); std::string incompleteStr = XML::getProperty(node, "incomplete", ""); std::string completeStr = XML::getProperty(node, "complete", ""); if (incompleteStr.empty() && completeStr.empty()) { logger->log("complete flags incorrect"); delete quest; return; } splitToIntSet(quest->incomplete, incompleteStr, ','); splitToIntSet(quest->complete, completeStr, ','); if (quest->incomplete.empty() && quest->complete.empty()) { logger->log("complete flags incorrect"); delete quest; return; } if (quest->incomplete.empty() || quest->complete.empty()) quest->broken = true; for_each_xml_child_node(dataNode, node) { if (!xmlTypeEqual(dataNode, XML_ELEMENT_NODE)) continue; XmlChar *const data = reinterpret_cast<XmlChar*>( XmlNodeGetContent(dataNode)); if (data == nullptr) continue; std::string str = translator->getStr(data); XmlFree(data); for (int f = 1; f < 100; f ++) { const std::string key = strprintf("text%d", f); const std::string val = XML::getProperty(dataNode, key.c_str(), ""); if (val.empty()) break; const std::string param = strprintf("{@@%d}", f); replaceAll(str, param, val); } replaceItemLinks(str); if (xmlNameEqual(dataNode, "text")) { quest->texts.push_back(QuestItemText(str, QuestType::TEXT, std::string(), std::string())); } else if (xmlNameEqual(dataNode, "name")) { quest->texts.push_back(QuestItemText(str, QuestType::NAME, std::string(), std::string())); } else if (xmlNameEqual(dataNode, "reward")) { quest->texts.push_back(QuestItemText(str, QuestType::REWARD, std::string(), std::string())); } else if (xmlNameEqual(dataNode, "questgiver") || xmlNameEqual(dataNode, "giver")) { quest->texts.push_back(QuestItemText(str, QuestType::GIVER, std::string(), std::string())); } else if (xmlNameEqual(dataNode, "coordinates")) { const std::string str1 = toString(XML::getIntProperty( dataNode, "x", 0, 1, 1000)); const std::string str2 = toString(XML::getIntProperty( dataNode, "y", 0, 1, 1000)); quest->texts.push_back(QuestItemText(str, QuestType::COORDINATES, str1, str2)); } else if (xmlNameEqual(dataNode, "npc")) { quest->texts.push_back(QuestItemText(str, QuestType::NPC, std::string(), std::string())); } } quest->var = var; mQuests[var].push_back(quest); }