mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Misc: Update locales_achievement_reward to simple system
Closes #19528
(cherry picked from commit 309a7f7e2a)
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
-- achievement_reward
|
||||
ALTER TABLE `achievement_reward` CHANGE `entry` `ID` int(10) unsigned NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `achievement_reward` CHANGE `title_A` `TitleA` int(10) unsigned NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `achievement_reward` CHANGE `title_H` `TitleH` int(10) unsigned NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `achievement_reward` CHANGE `item` `ItemID` int(10) unsigned NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `achievement_reward` CHANGE `sender` `Sender` int(10) unsigned NOT NULL DEFAULT '0';
|
||||
ALTER TABLE `achievement_reward` CHANGE `subject` `Subject` varchar(255) DEFAULT NULL;
|
||||
ALTER TABLE `achievement_reward` CHANGE `text` `Body` text;
|
||||
ALTER TABLE `achievement_reward` CHANGE `mailTemplate` `MailTemplateID` int(10) unsigned DEFAULT '0';
|
||||
|
||||
-- achievement_reward_locale
|
||||
DROP TABLE IF EXISTS `achievement_reward_locale`;
|
||||
CREATE TABLE IF NOT EXISTS `achievement_reward_locale` (
|
||||
`ID` int(10) unsigned NOT NULL DEFAULT '0',
|
||||
`Locale` varchar(4) NOT NULL,
|
||||
`Subject` text,
|
||||
`Body` text,
|
||||
PRIMARY KEY (`ID`, `Locale`)
|
||||
) ENGINE=MYISAM DEFAULT CHARSET=utf8;
|
||||
|
||||
-- koKR
|
||||
INSERT INTO `achievement_reward_locale` (`ID`, `Locale`, `Subject`, `Body`)
|
||||
(SELECT `entry`, "koKR", `subject_loc1`, `text_loc1` FROM `locales_achievement_reward` WHERE LENGTH(subject_loc1) > 0 OR LENGTH(text_loc1) > 0);
|
||||
|
||||
-- frFR
|
||||
INSERT INTO `achievement_reward_locale` (`ID`, `locale`, `Subject`, `Body`)
|
||||
(SELECT `entry`, "frFR", `subject_loc2`, `text_loc2` FROM `locales_achievement_reward` WHERE LENGTH(subject_loc2) > 0 OR LENGTH(text_loc2) > 0);
|
||||
|
||||
-- deDE
|
||||
INSERT INTO `achievement_reward_locale` (`ID`, `locale`, `Subject`, `Body`)
|
||||
(SELECT `entry`, "deDE", `subject_loc3`, `text_loc3` FROM `locales_achievement_reward` WHERE LENGTH(subject_loc3) > 0 OR LENGTH(text_loc3) > 0);
|
||||
|
||||
-- zhCN
|
||||
INSERT INTO `achievement_reward_locale` (`ID`, `locale`, `Subject`, `Body`)
|
||||
(SELECT `entry`, "zhCN", `subject_loc4`, `text_loc4` FROM `locales_achievement_reward` WHERE LENGTH(subject_loc4) > 0 OR LENGTH(text_loc4) > 0);
|
||||
|
||||
-- zhTW
|
||||
INSERT INTO `achievement_reward_locale` (`ID`, `locale`, `Subject`, `Body`)
|
||||
(SELECT `entry`, "zhTW", `subject_loc5`, `text_loc5` FROM `locales_achievement_reward` WHERE LENGTH(subject_loc5) > 0 OR LENGTH(text_loc5) > 0);
|
||||
|
||||
-- esES
|
||||
INSERT INTO `achievement_reward_locale` (`ID`, `locale`, `Subject`, `Body`)
|
||||
(SELECT `entry`, "esES", `subject_loc6`, `text_loc6` FROM `locales_achievement_reward` WHERE LENGTH(subject_loc6) > 0 OR LENGTH(text_loc6) > 0);
|
||||
|
||||
-- esMX
|
||||
INSERT INTO `achievement_reward_locale` (`ID`, `locale`, `Subject`, `Body`)
|
||||
(SELECT `entry`, "esMX", `subject_loc7`, `text_loc7` FROM `locales_achievement_reward` WHERE LENGTH(subject_loc7) > 0 OR LENGTH(text_loc7) > 0);
|
||||
|
||||
-- ruRU
|
||||
INSERT INTO `achievement_reward_locale` (`ID`, `locale`, `Subject`, `Body`)
|
||||
(SELECT `entry`, "ruRU", `subject_loc8`, `text_loc8` FROM `locales_achievement_reward` WHERE LENGTH(subject_loc8) > 0 OR LENGTH(text_loc8) > 0);
|
||||
|
||||
DROP TABLE IF EXISTS `locales_achievement_reward`;
|
||||
@@ -1115,8 +1115,8 @@ void AchievementGlobalMgr::LoadRewards()
|
||||
|
||||
_achievementRewards.clear(); // need for reload case
|
||||
|
||||
// 0 1 2 3 4 5 6 7
|
||||
QueryResult result = WorldDatabase.Query("SELECT entry, title_A, title_H, item, sender, subject, text, mailTemplate FROM achievement_reward");
|
||||
// 0 1 2 3 4 5 6 7
|
||||
QueryResult result = WorldDatabase.Query("SELECT ID, TitleA, TitleH, ItemID, Sender, Subject, Body, MailTemplateID FROM achievement_reward");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@@ -1124,16 +1124,14 @@ void AchievementGlobalMgr::LoadRewards()
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
AchievementEntry const* achievement = sAchievementStore.LookupEntry(entry);
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
AchievementEntry const* achievement = sAchievementStore.LookupEntry(id);
|
||||
if (!achievement)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` contains a wrong achievement entry (Entry: %u), ignored.", entry);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` contains a wrong achievement ID (%u), ignored.", id);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1149,19 +1147,19 @@ void AchievementGlobalMgr::LoadRewards()
|
||||
// must be title or mail at least
|
||||
if (!reward.TitleId[0] && !reward.TitleId[1] && !reward.SenderCreatureId)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) does not contain title or item reward data. Ignored.", entry);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (ID: %u) does not contain title or item reward data. Ignored.", id);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (achievement->Faction == ACHIEVEMENT_FACTION_ANY && (!reward.TitleId[0] ^ !reward.TitleId[1]))
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) contains the title (A: %u H: %u) for only one team.", entry, reward.TitleId[0], reward.TitleId[1]);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (ID: %u) contains the title (A: %u H: %u) for only one team.", id, reward.TitleId[0], reward.TitleId[1]);
|
||||
|
||||
if (reward.TitleId[0])
|
||||
{
|
||||
CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(reward.TitleId[0]);
|
||||
if (!titleEntry)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) contains an invalid title id (%u) in `title_A`, set to 0", entry, reward.TitleId[0]);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) contains an invalid title id (%u) in `title_A`, set to 0", id, reward.TitleId[0]);
|
||||
reward.TitleId[0] = 0;
|
||||
}
|
||||
}
|
||||
@@ -1171,7 +1169,7 @@ void AchievementGlobalMgr::LoadRewards()
|
||||
CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(reward.TitleId[1]);
|
||||
if (!titleEntry)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) contains an invalid title id (%u) in `title_H`, set to 0", entry, reward.TitleId[1]);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) contains an invalid title id (%u) in `title_H`, set to 0", id, reward.TitleId[1]);
|
||||
reward.TitleId[1] = 0;
|
||||
}
|
||||
}
|
||||
@@ -1181,51 +1179,49 @@ void AchievementGlobalMgr::LoadRewards()
|
||||
{
|
||||
if (!sObjectMgr->GetCreatureTemplate(reward.SenderCreatureId))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) contains an invalid creature entry %u as sender, mail reward skipped.", entry, reward.SenderCreatureId);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (ID: %u) contains an invalid creature ID %u as sender, mail reward skipped.", id, reward.SenderCreatureId);
|
||||
reward.SenderCreatureId = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (reward.ItemId)
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) does not have sender data, but contains an item reward. Item will not be rewarded.", entry);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (ID: %u) does not have sender data, but contains an item reward. Item will not be rewarded.", id);
|
||||
|
||||
if (!reward.Subject.empty())
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) does not have sender data, but contains a mail subject.", entry);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (ID: %u) does not have sender data, but contains a mail subject.", id);
|
||||
|
||||
if (!reward.Body.empty())
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) does not have sender data, but contains mail text.", entry);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (ID: %u) does not have sender data, but contains mail text.", id);
|
||||
|
||||
if (reward.MailTemplateId)
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) does not have sender data, but has a MailTemplateId.", entry);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (ID: %u) does not have sender data, but has a MailTemplate.", id);
|
||||
}
|
||||
|
||||
if (reward.MailTemplateId)
|
||||
{
|
||||
if (!sMailTemplateStore.LookupEntry(reward.MailTemplateId))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) is using an invalid MailTemplateId (%u).", entry, reward.MailTemplateId);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (ID: %u) is using an invalid MailTemplate (%u).", id, reward.MailTemplateId);
|
||||
reward.MailTemplateId = 0;
|
||||
}
|
||||
else if (!reward.Subject.empty() || !reward.Body.empty())
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) is using MailTemplateId (%u) and mail subject/text.", entry, reward.MailTemplateId);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (ID: %u) is using MailTemplate (%u) and mail subject/text.", id, reward.MailTemplateId);
|
||||
}
|
||||
|
||||
if (reward.ItemId)
|
||||
{
|
||||
if (!sObjectMgr->GetItemTemplate(reward.ItemId))
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (Entry: %u) contains an invalid item id %u, reward mail will not contain the rewarded item.", entry, reward.ItemId);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward` (ID: %u) contains an invalid item id %u, reward mail will not contain the rewarded item.", id, reward.ItemId);
|
||||
reward.ItemId = 0;
|
||||
}
|
||||
}
|
||||
|
||||
_achievementRewards[entry] = reward;
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
_achievementRewards[id] = reward;
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u achievement rewards in %u ms.", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u achievement rewards in %u ms.", uint32(_achievementRewards.size()), GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
void AchievementGlobalMgr::LoadRewardLocales()
|
||||
@@ -1234,13 +1230,12 @@ void AchievementGlobalMgr::LoadRewardLocales()
|
||||
|
||||
_achievementRewardLocales.clear(); // need for reload case
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT entry, subject_loc1, text_loc1, subject_loc2, text_loc2, subject_loc3, text_loc3, subject_loc4, text_loc4, "
|
||||
"subject_loc5, text_loc5, subject_loc6, text_loc6, subject_loc7, text_loc7, subject_loc8, text_loc8"
|
||||
" FROM locales_achievement_reward");
|
||||
// 0 1 2 3
|
||||
QueryResult result = WorldDatabase.Query("SELECT ID, Locale, Subject, Body FROM achievement_reward_locale");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
TC_LOG_INFO("server.loading", ">> Loaded 0 achievement reward locale strings. DB table `locales_achievement_reward` is empty.");
|
||||
TC_LOG_INFO("server.loading", ">> Loaded 0 achievement reward locale strings. DB table `achievement_reward_locale` is empty.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1248,24 +1243,23 @@ void AchievementGlobalMgr::LoadRewardLocales()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
uint32 id = fields[0].GetUInt32();
|
||||
std::string localeName = fields[1].GetString();
|
||||
|
||||
if (_achievementRewards.find(entry) == _achievementRewards.end())
|
||||
if (_achievementRewards.find(id) == _achievementRewards.end())
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `locales_achievement_reward` (Entry: %u) contains locale strings for a non-existing achievement reward.", entry);
|
||||
TC_LOG_ERROR("sql.sql", "Table `achievement_reward_locale` (ID: %u) contains locale strings for a non-existing achievement reward.", id);
|
||||
continue;
|
||||
}
|
||||
|
||||
AchievementRewardLocale& data = _achievementRewardLocales[entry];
|
||||
AchievementRewardLocale& data = _achievementRewardLocales[id];
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
if (locale == LOCALE_enUS)
|
||||
continue;
|
||||
|
||||
for (uint8 i = OLD_TOTAL_LOCALES - 1; i > 0; --i)
|
||||
{
|
||||
LocaleConstant locale = (LocaleConstant) i;
|
||||
ObjectMgr::AddLocaleString(fields[1 + 2 * (i - 1)].GetString(), locale, data.Subject);
|
||||
ObjectMgr::AddLocaleString(fields[1 + 2 * (i - 1) + 1].GetString(), locale, data.Body);
|
||||
}
|
||||
}
|
||||
while (result->NextRow());
|
||||
ObjectMgr::AddLocaleString(fields[2].GetString(), locale, data.Subject);
|
||||
ObjectMgr::AddLocaleString(fields[3].GetString(), locale, data.Body);
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u achievement reward locale strings in %u ms.", uint32(_achievementRewardLocales.size()), GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user