From 971d55d4633fa648f263cb6c14cc100eabb04643 Mon Sep 17 00:00:00 2001 From: r0m1ntik Date: Sun, 30 Aug 2020 19:42:36 +0200 Subject: [PATCH] fix (Core/Quest) Correct link quest and fix command lookup quest for multilanguage dbc (#3271) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Francesco Borzì Co-authored-by: Stefano Borzì --- src/server/game/Chat/ChatLink.cpp | 8 +++ src/server/scripts/Commands/cs_lookup.cpp | 79 +++++++++++++++++++---- 2 files changed, 74 insertions(+), 13 deletions(-) diff --git a/src/server/game/Chat/ChatLink.cpp b/src/server/game/Chat/ChatLink.cpp index 6a36a7ecb..f451f4d27 100644 --- a/src/server/game/Chat/ChatLink.cpp +++ b/src/server/game/Chat/ChatLink.cpp @@ -259,6 +259,14 @@ bool QuestChatLink::ValidateName(char* buffer, const char* context) ChatLink::ValidateName(buffer, context); bool res = (_quest->GetTitle() == buffer); + if (!res) + if (QuestLocale const* ql = sObjectMgr->GetQuestLocale(_quest->GetQuestId())) + for (uint8 i = 0; i < ql->Title.size(); i++) + if (ql->Title[i] == buffer) + { + res = true; + break; + } #if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS) if (!res) diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index e037ab6d7..8cd13822b 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -171,7 +171,7 @@ public: if (creatureLocale->Name.size() > localeIndex && !creatureLocale->Name[localeIndex].empty()) { std::string name = creatureLocale->Name[localeIndex]; - + if (Utf8FitTo(name, wNamePart)) { if (maxResults && count++ == maxResults) @@ -179,15 +179,15 @@ public: handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); return true; } - + if (handler->GetSession()) handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CHAT, id, id, name.c_str()); else handler->PSendSysMessage(LANG_CREATURE_ENTRY_LIST_CONSOLE, id, name.c_str()); - + if (!found) found = true; - + continue; } } @@ -409,7 +409,7 @@ public: if (il->Name.size() > ulocaleIndex && !il->Name[ulocaleIndex].empty()) { std::string name = il->Name[ulocaleIndex]; - + if (Utf8FitTo(name, wNamePart)) { if (maxResults && count++ == maxResults) @@ -417,15 +417,15 @@ public: handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); return true; } - + if (handler->GetSession()) handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itr->second.ItemId, itr->second.ItemId, name.c_str()); else handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itr->second.ItemId, name.c_str()); - + if (!found) found = true; - + continue; } } @@ -558,7 +558,7 @@ public: if (objectLocalte->Name.size() > localeIndex && !objectLocalte->Name[localeIndex].empty()) { std::string name = objectLocalte->Name[localeIndex]; - + if (Utf8FitTo(name, wNamePart)) { if (maxResults && count++ == maxResults) @@ -566,15 +566,15 @@ public: handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); return true; } - + if (handler->GetSession()) handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, itr->second.entry, itr->second.entry, name.c_str()); else handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, itr->second.entry, name.c_str()); - + if (!found) found = true; - + continue; } } @@ -634,6 +634,59 @@ public: { Quest* qInfo = iter->second; + int localeIndex = handler->GetSessionDbLocaleIndex(); + if (localeIndex >= 0) + { + uint8 ulocaleIndex = uint8(localeIndex); + if (QuestLocale const* questLocale = sObjectMgr->GetQuestLocale(qInfo->GetQuestId())) + { + if (questLocale->Title.size() > ulocaleIndex && !questLocale->Title[ulocaleIndex].empty()) + { + std::string title = questLocale->Title[ulocaleIndex]; + + if (Utf8FitTo(title, wNamePart)) + { + if (maxResults && count++ == maxResults) + { + handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults); + return true; + } + + char const* statusStr = ""; + + if (target) + { + QuestStatus status = target->GetQuestStatus(qInfo->GetQuestId()); + + switch (status) + { + case QUEST_STATUS_COMPLETE: + statusStr = handler->GetAcoreString(LANG_COMMAND_QUEST_COMPLETE); + break; + case QUEST_STATUS_INCOMPLETE: + statusStr = handler->GetAcoreString(LANG_COMMAND_QUEST_ACTIVE); + break; + case QUEST_STATUS_REWARDED: + statusStr = handler->GetAcoreString(LANG_COMMAND_QUEST_REWARDED); + break; + default: + break; + } + } + + if (handler->GetSession()) + handler->PSendSysMessage(LANG_QUEST_LIST_CHAT, qInfo->GetQuestId(), qInfo->GetQuestId(), qInfo->GetQuestLevel(), title.c_str(), statusStr); + else + handler->PSendSysMessage(LANG_QUEST_LIST_CONSOLE, qInfo->GetQuestId(), title.c_str(), statusStr); + + if (!found) + found = true; + continue; + } + } + } + } + std::string title = qInfo->GetTitle(); if (title.empty()) continue; @@ -965,7 +1018,7 @@ public: found = true; } } - + if (!found) handler->SendSysMessage(LANG_COMMAND_NOSPELLFOUND);