Core/DB: Update all locales to actual TrinityCore (#1160)

* Core/Misc Update all locales table structure to simple system. Port from TrinityCore
Co-Authored-By: Winfidonarleyan <dowlandtop@yandex.com>
* Core/Db/Gossip Update structure gossip_menu and gossip_menu_action to actual TrinityCore
* Core/DB Update Broadcast system to actual TC
* Core/Mail: implement Quest Mail Sender
* Core/Quest Split quest template locales
This commit is contained in:
Kargatum
2019-01-13 05:56:06 +07:00
committed by Viste(Кирилл)
parent 76772e434d
commit b34bc28e5b
26 changed files with 59397 additions and 525 deletions

View File

@@ -75,23 +75,44 @@ void GossipMenu::AddMenuItem(uint32 menuId, uint32 menuItemId, uint32 sender, ui
for (GossipMenuItemsContainer::const_iterator itr = bounds.first; itr != bounds.second; ++itr)
{
/// Find the one with the given menu item id.
if (itr->second.OptionIndex != menuItemId)
if (itr->second.OptionID != menuItemId)
continue;
/// Store texts for localization.
std::string strOptionText = itr->second.OptionText;
std::string strBoxText = itr->second.BoxText;
std::string strOptionText, strBoxText;
BroadcastText const* optionBroadcastText = sObjectMgr->GetBroadcastText(itr->second.OptionBroadcastTextID);
BroadcastText const* boxBroadcastText = sObjectMgr->GetBroadcastText(itr->second.BoxBroadcastTextID);
/// OptionText
if (optionBroadcastText)
ObjectMgr::GetLocaleString(optionBroadcastText->MaleText, GetLocale(), strOptionText);
else
strOptionText = itr->second.OptionText;
/// BoxText
if (boxBroadcastText)
ObjectMgr::GetLocaleString(boxBroadcastText->MaleText, GetLocale(), strBoxText);
else
strBoxText = itr->second.BoxText;
/// Check need of localization.
if (GetLocale() != DEFAULT_LOCALE)
/// Find localizations from database.
if (GossipMenuItemsLocale const* no = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuItemId)))
{
if (!optionBroadcastText)
{
/// Translate texts if there are any.
ObjectMgr::GetLocaleString(no->OptionText, GetLocale(), strOptionText);
ObjectMgr::GetLocaleString(no->BoxText, GetLocale(), strBoxText);
/// Find localizations from database.
if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuItemId)))
ObjectMgr::GetLocaleString(gossipMenuLocale->OptionText, GetLocale(), strOptionText);
}
if (!boxBroadcastText)
{
/// Find localizations from database.
if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuItemId)))
ObjectMgr::GetLocaleString(gossipMenuLocale->BoxText, GetLocale(), strBoxText);
}
}
/// Add menu item with existing method. Menu item id -1 is also used in ADD_GOSSIP_ITEM macro.
AddMenuItem(-1, itr->second.OptionIcon, strOptionText, sender, action, strBoxText, itr->second.BoxMoney, itr->second.BoxCoded);
}
@@ -588,23 +609,23 @@ void PlayerMenu::SendQuestQueryResponse(Quest const* quest) const
void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, bool enableNext) const
{
std::string questTitle = quest->GetTitle();
std::string questOfferRewardText = quest->GetOfferRewardText();
std::string RewardText = quest->GetOfferRewardText();
int32 locale = _session->GetSessionDbLocaleIndex();
if (locale >= 0)
{
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
{
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
ObjectMgr::GetLocaleString(localeData->OfferRewardText, locale, questOfferRewardText);
}
if (QuestOfferRewardLocale const* questOfferRewardLocale = sObjectMgr->GetQuestOfferRewardLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(questOfferRewardLocale->RewardText, locale, RewardText);
}
WorldPacket data(SMSG_QUESTGIVER_OFFER_REWARD, 400); // guess size
data << uint64(npcGUID);
data << uint32(quest->GetQuestId());
data << questTitle;
data << questOfferRewardText;
data << RewardText;
data << uint8(enableNext ? 1 : 0); // Auto Finish
data << uint32(quest->GetFlags()); // 3.3.3 questFlags
@@ -690,10 +711,10 @@ void PlayerMenu::SendQuestGiverRequestItems(Quest const* quest, uint64 npcGUID,
if (locale >= 0)
{
if (QuestLocale const* localeData = sObjectMgr->GetQuestLocale(quest->GetQuestId()))
{
ObjectMgr::GetLocaleString(localeData->Title, locale, questTitle);
ObjectMgr::GetLocaleString(localeData->RequestItemsText, locale, requestItemsText);
}
if (QuestRequestItemsLocale const* questRequestItemsLocale = sObjectMgr->GetQuestRequestItemsLocale(quest->GetQuestId()))
ObjectMgr::GetLocaleString(questRequestItemsLocale->CompletionText, locale, requestItemsText);
}
if (!quest->GetReqItemsCount() && canComplete)

View File

@@ -1849,8 +1849,17 @@ namespace Trinity
: i_object(obj), i_msgtype(msgtype), i_textId(textId), i_language(Language(language)), i_target(target) { }
void operator()(WorldPacket& data, LocaleConstant loc_idx)
{
char const* text = sObjectMgr->GetTrinityString(i_textId, loc_idx);
ChatHandler::BuildChatPacket(data, i_msgtype, i_language, i_object, i_target, text, 0, "", loc_idx);
if (BroadcastText const* broadcastText = sObjectMgr->GetBroadcastText(i_textId))
{
uint8 gender = GENDER_MALE;
if (Unit const* unit = i_object->ToUnit())
gender = unit->getGender();
std::string text = broadcastText->GetText(loc_idx, gender);
ChatHandler::BuildChatPacket(data, i_msgtype, i_language, i_object, i_target, text, 0, "", loc_idx);
}
else
sLog->outError("MonsterChatBuilder: `broadcast_text` id %i missing", i_textId);
}
private:
@@ -1975,10 +1984,17 @@ void WorldObject::MonsterWhisper(int32 textId, Player const* target, bool IsBoss
if (!target)
return;
uint8 gender = GENDER_MALE;
if (Unit const* unit = ToUnit())
gender = unit->getGender();
LocaleConstant loc_idx = target->GetSession()->GetSessionDbLocaleIndex();
char const* text = sObjectMgr->GetTrinityString(textId, loc_idx);
BroadcastText const* broadcastText = sObjectMgr->GetBroadcastText(textId);
std::string text = broadcastText->GetText(loc_idx, gender);
WorldPacket data;
ChatHandler::BuildChatPacket(data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, text, 0, "", loc_idx);
ChatHandler::BuildChatPacket(data, IsBossWhisper ? CHAT_MSG_RAID_BOSS_WHISPER : CHAT_MSG_MONSTER_WHISPER, LANG_UNIVERSAL, this, target, text.c_str(), 0, "", loc_idx);
target->GetSession()->SendPacket(&data);
}

View File

@@ -14818,7 +14818,7 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
if (Creature* creature = source->ToCreature())
{
if (!(itr->second.OptionNpcflag & npcflags))
if (!(itr->second.OptionNpcFlag & npcflags))
continue;
switch (itr->second.OptionType)
@@ -14881,7 +14881,7 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
canTalk = false;
break;
default:
sLog->outErrorDb("Creature entry %u has unknown gossip option %u for menu %u", creature->GetEntry(), itr->second.OptionType, itr->second.MenuId);
sLog->outErrorDb("Creature entry %u has unknown gossip option %u for menu %u", creature->GetEntry(), itr->second.OptionType, itr->second.MenuID);
canTalk = false;
break;
}
@@ -14902,22 +14902,40 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
if (canTalk)
{
std::string strOptionText = itr->second.OptionText;
std::string strBoxText = itr->second.BoxText;
std::string strOptionText, strBoxText;
BroadcastText const* optionBroadcastText = sObjectMgr->GetBroadcastText(itr->second.OptionBroadcastTextID);
BroadcastText const* boxBroadcastText = sObjectMgr->GetBroadcastText(itr->second.BoxBroadcastTextID);
LocaleConstant locale = GetSession()->GetSessionDbLocaleIndex();
int32 locale = GetSession()->GetSessionDbLocaleIndex();
if (locale >= 0)
if (optionBroadcastText)
ObjectMgr::GetLocaleString(getGender() == GENDER_MALE ? optionBroadcastText->MaleText : optionBroadcastText->FemaleText, locale, strOptionText);
else
strOptionText = itr->second.OptionText;
if (boxBroadcastText)
ObjectMgr::GetLocaleString(getGender() == GENDER_MALE ? boxBroadcastText->MaleText : boxBroadcastText->FemaleText, locale, strBoxText);
else
strBoxText = itr->second.BoxText;
if (locale != DEFAULT_LOCALE)
{
uint32 idxEntry = MAKE_PAIR32(menuId, itr->second.OptionIndex);
if (GossipMenuItemsLocale const* no = sObjectMgr->GetGossipMenuItemsLocale(idxEntry))
if (!optionBroadcastText)
{
ObjectMgr::GetLocaleString(no->OptionText, locale, strOptionText);
ObjectMgr::GetLocaleString(no->BoxText, locale, strBoxText);
/// Find localizations from database.
if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuId)))
ObjectMgr::GetLocaleString(gossipMenuLocale->OptionText, locale, strOptionText);
}
if (!boxBroadcastText)
{
/// Find localizations from database.
if (GossipMenuItemsLocale const* gossipMenuLocale = sObjectMgr->GetGossipMenuItemsLocale(MAKE_PAIR32(menuId, menuId)))
ObjectMgr::GetLocaleString(gossipMenuLocale->BoxText, locale, strBoxText);
}
}
menu->GetGossipMenu().AddMenuItem(itr->second.OptionIndex, itr->second.OptionIcon, strOptionText, 0, itr->second.OptionType, strBoxText, itr->second.BoxMoney, itr->second.BoxCoded);
menu->GetGossipMenu().AddGossipMenuItemData(itr->second.OptionIndex, itr->second.ActionMenuId, itr->second.ActionPoiId);
menu->GetGossipMenu().AddMenuItem(itr->second.OptionID, itr->second.OptionIcon, strOptionText, 0, itr->second.OptionType, strBoxText, itr->second.BoxMoney, itr->second.BoxCoded);
menu->GetGossipMenu().AddGossipMenuItemData(itr->second.OptionID, itr->second.ActionMenuID, itr->second.ActionPoiID);
}
}
}
@@ -15111,8 +15129,8 @@ uint32 Player::GetGossipTextId(uint32 menuId, WorldObject* source)
for (GossipMenusContainer::const_iterator itr = menuBounds.first; itr != menuBounds.second; ++itr)
{
if (sConditionMgr->IsObjectMeetToConditions(this, source, itr->second.conditions))
textId = itr->second.text_id;
if (sConditionMgr->IsObjectMeetToConditions(this, source, itr->second.Conditions))
textId = itr->second.TextID;
}
return textId;
@@ -15887,7 +15905,10 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
{
//- TODO: Poor design of mail system
SQLTransaction trans = CharacterDatabase.BeginTransaction();
MailDraft(mail_template_id).SendMailTo(trans, this, questGiver, MAIL_CHECK_MASK_HAS_BODY, quest->GetRewMailDelaySecs());
if (quest->GetRewMailSenderEntry() != 0)
MailDraft(mail_template_id).SendMailTo(trans, this, quest->GetRewMailSenderEntry(), MAIL_CHECK_MASK_HAS_BODY, quest->GetRewMailDelaySecs());
else
MailDraft(mail_template_id).SendMailTo(trans, this, questGiver, MAIL_CHECK_MASK_HAS_BODY, quest->GetRewMailDelaySecs());
CharacterDatabase.CommitTransaction(trans);
}