Skip to content
Permalink
Browse files

Sync broadcast_text naming (#24102)

* Sync broadcast_text naming

official namings for broadcast_text

* Rename 2020_01_24_00_world_335.sql to 2020_02_01_02_world_335.sql

Co-authored-by: Giacomo Pozzoni <giacomopoz@gmail.com>
  • Loading branch information
funjoker and jackpoz committed Feb 1, 2020
1 parent ba1e5cd commit 6c85964065dc2b2d397904d79755eacc43a8ab0d
@@ -0,0 +1,17 @@
ALTER TABLE `broadcast_text`
CHANGE COLUMN `Language` `LanguageID` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `ID`,
CHANGE COLUMN `MaleText` `Text` LONGTEXT NULL AFTER `LanguageID`,
CHANGE COLUMN `FemaleText` `Text1` LONGTEXT NULL AFTER `Text`,
CHANGE COLUMN `EmoteID0` `EmoteID1` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `Text1`,
CHANGE COLUMN `EmoteID1` `EmoteID2` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `EmoteID1`,
CHANGE COLUMN `EmoteID2` `EmoteID3` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `EmoteID2`,
CHANGE COLUMN `EmoteDelay0` `EmoteDelay1` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `EmoteID3`,
CHANGE COLUMN `EmoteDelay1` `EmoteDelay2` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `EmoteDelay1`,
CHANGE COLUMN `EmoteDelay2` `EmoteDelay3` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `EmoteDelay2`,
CHANGE COLUMN `SoundId` `SoundEntriesID` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `EmoteDelay3`,
CHANGE COLUMN `Unk1` `EmotesID` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `SoundEntriesID`,
CHANGE COLUMN `Unk2` `Flags` MEDIUMINT(8) UNSIGNED NOT NULL DEFAULT '0' AFTER `EmotesID`;

ALTER TABLE `broadcast_text_locale`
CHANGE COLUMN `MaleText` `Text` TEXT NULL AFTER `locale`,
CHANGE COLUMN `FemaleText` `Text1` TEXT NULL AFTER `Text`;
@@ -6116,10 +6116,10 @@ void ObjectMgr::LoadGossipText()
{
if (BroadcastText const* bcText = sObjectMgr->GetBroadcastText(gOption.BroadcastTextID))
{
if (bcText->MaleText[DEFAULT_LOCALE] != gOption.Text_0)
TC_LOG_INFO("sql.sql", "Row %u in table `npc_text` has mismatch between text%u_0 and the corresponding MaleText in `broadcast_text` row %u", id, i, gOption.BroadcastTextID);
if (bcText->FemaleText[DEFAULT_LOCALE] != gOption.Text_1)
TC_LOG_INFO("sql.sql", "Row %u in table `npc_text` has mismatch between text%u_1 and the corresponding FemaleText in `broadcast_text` row %u", id, i, gOption.BroadcastTextID);
if (bcText->Text[DEFAULT_LOCALE] != gOption.Text_0)
TC_LOG_INFO("sql.sql", "Row %u in table `npc_text` has mismatch between text%u_0 and the corresponding Text in `broadcast_text` row %u", id, i, gOption.BroadcastTextID);
if (bcText->Text1[DEFAULT_LOCALE] != gOption.Text_1)
TC_LOG_INFO("sql.sql", "Row %u in table `npc_text` has mismatch between text%u_1 and the corresponding Text1 in `broadcast_text` row %u", id, i, gOption.BroadcastTextID);
}
else
{
@@ -9623,8 +9623,8 @@ void ObjectMgr::LoadBroadcastTexts()

_broadcastTextStore.clear(); // for reload case

// 0 1 2 3 4 5 6 7 8 9 10 11 12
QueryResult result = WorldDatabase.Query("SELECT ID, Language, MaleText, FemaleText, EmoteID0, EmoteID1, EmoteID2, EmoteDelay0, EmoteDelay1, EmoteDelay2, SoundId, Unk1, Unk2 FROM broadcast_text");
// 0 1 2 3 4 5 6 7 8 9 10 11 12
QueryResult result = WorldDatabase.Query("SELECT ID, LanguageID, Text, Text1, EmoteID1, EmoteID2, EmoteID3, EmoteDelay1, EmoteDelay2, EmoteDelay3, SoundEntriesID, EmotesID, Flags FROM broadcast_text");
if (!result)
{
TC_LOG_INFO("server.loading", ">> Loaded 0 broadcast texts. DB table `broadcast_text` is empty.");
@@ -9640,41 +9640,32 @@ void ObjectMgr::LoadBroadcastTexts()
BroadcastText bct;

bct.Id = fields[0].GetUInt32();
bct.Language = fields[1].GetUInt32();
bct.MaleText[DEFAULT_LOCALE] = fields[2].GetString();
bct.FemaleText[DEFAULT_LOCALE] = fields[3].GetString();
bct.EmoteId0 = fields[4].GetUInt32();
bct.EmoteId1 = fields[5].GetUInt32();
bct.EmoteId2 = fields[6].GetUInt32();
bct.EmoteDelay0 = fields[7].GetUInt32();
bct.EmoteDelay1 = fields[8].GetUInt32();
bct.EmoteDelay2 = fields[9].GetUInt32();
bct.SoundId = fields[10].GetUInt32();
bct.Unk1 = fields[11].GetUInt32();
bct.Unk2 = fields[12].GetUInt32();
bct.LanguageID = fields[1].GetUInt32();
bct.Text[DEFAULT_LOCALE] = fields[2].GetString();
bct.Text1[DEFAULT_LOCALE] = fields[3].GetString();
bct.EmoteId1 = fields[4].GetUInt32();
bct.EmoteId2 = fields[5].GetUInt32();
bct.EmoteId3 = fields[6].GetUInt32();
bct.EmoteDelay1 = fields[7].GetUInt32();
bct.EmoteDelay2 = fields[8].GetUInt32();
bct.EmoteDelay3 = fields[9].GetUInt32();
bct.SoundEntriesID = fields[10].GetUInt32();
bct.EmotesID = fields[11].GetUInt32();
bct.Flags = fields[12].GetUInt32();

if (bct.SoundId)
if (bct.SoundEntriesID)
{
if (!sSoundEntriesStore.LookupEntry(bct.SoundId))
if (!sSoundEntriesStore.LookupEntry(bct.SoundEntriesID))
{
TC_LOG_DEBUG("broadcasttext", "BroadcastText (Id: %u) in table `broadcast_text` has SoundId %u but sound does not exist.", bct.Id, bct.SoundId);
bct.SoundId = 0;
TC_LOG_DEBUG("broadcasttext", "BroadcastText (Id: %u) in table `broadcast_text` has SoundEntriesID %u but sound does not exist.", bct.Id, bct.SoundEntriesID);
bct.SoundEntriesID = 0;
}
}

if (!GetLanguageDescByID(bct.Language))
if (!GetLanguageDescByID(bct.LanguageID))
{
TC_LOG_DEBUG("broadcasttext", "BroadcastText (Id: %u) in table `broadcast_text` using Language %u but Language does not exist.", bct.Id, bct.Language);
bct.Language = LANG_UNIVERSAL;
}

if (bct.EmoteId0)
{
if (!sEmotesStore.LookupEntry(bct.EmoteId0))
{
TC_LOG_DEBUG("broadcasttext", "BroadcastText (Id: %u) in table `broadcast_text` has EmoteId0 %u but emote does not exist.", bct.Id, bct.EmoteId0);
bct.EmoteId0 = 0;
}
TC_LOG_DEBUG("broadcasttext", "BroadcastText (Id: %u) in table `broadcast_text` using LanguageID %u but Language does not exist.", bct.Id, bct.LanguageID);
bct.LanguageID = LANG_UNIVERSAL;
}

if (bct.EmoteId1)
@@ -9695,6 +9686,15 @@ void ObjectMgr::LoadBroadcastTexts()
}
}

if (bct.EmoteId3)
{
if (!sEmotesStore.LookupEntry(bct.EmoteId3))
{
TC_LOG_DEBUG("broadcasttext", "BroadcastText (Id: %u) in table `broadcast_text` has EmoteId3 %u but emote does not exist.", bct.Id, bct.EmoteId3);
bct.EmoteId3 = 0;
}
}

_broadcastTextStore[bct.Id] = bct;
}
while (result->NextRow());
@@ -9706,8 +9706,8 @@ void ObjectMgr::LoadBroadcastTextLocales()
{
uint32 oldMSTime = getMSTime();

// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT ID, locale, MaleText, FemaleText FROM broadcast_text_locale");
// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT ID, locale, Text, Text1 FROM broadcast_text_locale");
if (!result)
{
TC_LOG_INFO("server.loading", ">> Loaded 0 broadcast text locales. DB table `broadcast_text_locale` is empty.");
@@ -9720,8 +9720,8 @@ void ObjectMgr::LoadBroadcastTextLocales()

uint32 id = fields[0].GetUInt32();
std::string localeName = fields[1].GetString();
std::string MaleText = fields[2].GetString();
std::string FemaleText = fields[3].GetString();
std::string Text = fields[2].GetString();
std::string Text1 = fields[3].GetString();

BroadcastTextContainer::iterator bct = _broadcastTextStore.find(id);
if (bct == _broadcastTextStore.end())
@@ -9734,8 +9734,8 @@ void ObjectMgr::LoadBroadcastTextLocales()
if (locale == LOCALE_enUS)
continue;

AddLocaleString(MaleText, locale, bct->second.MaleText);
AddLocaleString(FemaleText, locale, bct->second.FemaleText);
AddLocaleString(Text, locale, bct->second.Text);
AddLocaleString(Text1, locale, bct->second.Text1);
} while (result->NextRow());

TC_LOG_INFO("server.loading", ">> Loaded %u broadcast text locales in %u ms", uint32(_broadcastTextStore.size()), GetMSTimeDiffToNow(oldMSTime));
@@ -474,41 +474,41 @@ struct AccessRequirement

struct BroadcastText
{
BroadcastText() : Id(0), Language(0), EmoteId0(0), EmoteId1(0), EmoteId2(0),
EmoteDelay0(0), EmoteDelay1(0), EmoteDelay2(0), SoundId(0), Unk1(0), Unk2(0)
BroadcastText() : Id(0), LanguageID(0), EmoteId1(0), EmoteId2(0), EmoteId3(0),
EmoteDelay1(0), EmoteDelay2(0), EmoteDelay3(0), SoundEntriesID(0), EmotesID(0), Flags(0)
{
MaleText.resize(DEFAULT_LOCALE + 1);
FemaleText.resize(DEFAULT_LOCALE + 1);
Text.resize(DEFAULT_LOCALE + 1);
Text1.resize(DEFAULT_LOCALE + 1);
}

uint32 Id;
uint32 Language;
std::vector<std::string> MaleText;
std::vector<std::string> FemaleText;
uint32 EmoteId0;
uint32 LanguageID;
std::vector<std::string> Text;
std::vector<std::string> Text1;
uint32 EmoteId1;
uint32 EmoteId2;
uint32 EmoteDelay0;
uint32 EmoteId3;
uint32 EmoteDelay1;
uint32 EmoteDelay2;
uint32 SoundId;
uint32 Unk1;
uint32 Unk2;
uint32 EmoteDelay3;
uint32 SoundEntriesID;
uint32 EmotesID;
uint32 Flags;
// uint32 VerifiedBuild;

std::string const& GetText(LocaleConstant locale = DEFAULT_LOCALE, uint8 gender = GENDER_MALE, bool forceGender = false) const
{
if ((gender == GENDER_FEMALE || gender == GENDER_NONE) && (forceGender || !FemaleText[DEFAULT_LOCALE].empty()))
if ((gender == GENDER_FEMALE || gender == GENDER_NONE) && (forceGender || !Text1[DEFAULT_LOCALE].empty()))
{
if (FemaleText.size() > size_t(locale) && !FemaleText[locale].empty())
return FemaleText[locale];
return FemaleText[DEFAULT_LOCALE];
if (Text1.size() > size_t(locale) && !Text1[locale].empty())
return Text1[locale];
return Text1[DEFAULT_LOCALE];
}
// else if (gender == GENDER_MALE)
{
if (MaleText.size() > size_t(locale) && !MaleText[locale].empty())
return MaleText[locale];
return MaleText[DEFAULT_LOCALE];
if (Text.size() > size_t(locale) && !Text[locale].empty())
return Text[locale];
return Text[DEFAULT_LOCALE];
}
}
};
@@ -23,13 +23,13 @@
void Trinity::BroadcastTextBuilder::operator()(WorldPacket& data, LocaleConstant locale) const
{
BroadcastText const* bct = sObjectMgr->GetBroadcastText(_textId);
ChatHandler::BuildChatPacket(data, _msgType, bct ? Language(bct->Language) : LANG_UNIVERSAL, _source, _target, bct ? bct->GetText(locale, _gender) : "", _achievementId, "", locale);
ChatHandler::BuildChatPacket(data, _msgType, bct ? Language(bct->LanguageID) : LANG_UNIVERSAL, _source, _target, bct ? bct->GetText(locale, _gender) : "", _achievementId, "", locale);
}

size_t Trinity::BroadcastTextBuilder::operator()(WorldPacket* data, LocaleConstant locale) const
{
BroadcastText const* bct = sObjectMgr->GetBroadcastText(_textId);
return ChatHandler::BuildChatPacket(*data, _msgType, bct ? Language(bct->Language) : LANG_UNIVERSAL, _source, _target, bct ? bct->GetText(locale, _gender) : "", _achievementId, "", locale);
return ChatHandler::BuildChatPacket(*data, _msgType, bct ? Language(bct->LanguageID) : LANG_UNIVERSAL, _source, _target, bct ? bct->GetText(locale, _gender) : "", _achievementId, "", locale);
}

void Trinity::CustomChatTextBuilder::operator()(WorldPacket& data, LocaleConstant locale) const

6 comments on commit 6c85964

@intra32

This comment has been minimized.

Copy link

intra32 replied Feb 2, 2020

Trying to launch worldserver.exe after pulling this commit and updating the DB gives me an error:

[1054] Unknown column 'Language' in 'field list'
Your database structure is not up to date. Please make sure you've executed all queries in the sql/updates folders.

@illfated

This comment has been minimized.

Copy link

illfated replied Feb 2, 2020

Maybe you have not recompiled with this commit included? What is your worldserver.exe rev. hash?

@intra32

This comment has been minimized.

Copy link

intra32 replied Feb 2, 2020

@illfated
I've made sure that I have the latest version (after this commit). Even wiped out my databases and reapplied everything.
Launching TrinityCore it says:

TrinityCore rev. e102393+ 2020-02-01 14:55:16 +0100 (3.3.5 branch) (Win64, Release, Static) (worldserver-daemon)

So it should be good. That's one commit after this one. Does it work for you when you pull the newest version?

@Aokromes

This comment has been minimized.

Copy link
Member

Aokromes replied Feb 2, 2020

ser in
TC>TrinityCore rev. e102393 2020-02-01 14:55:16 +0100 (3.3.5 branch) (Unix, None, Static)

works for me (TM)

@intra32

This comment has been minimized.

Copy link

intra32 replied Feb 2, 2020

Update, did a git reset --hard HEAD on the repository then wiped the world DB and applied everything again. It works. Sorry for bothering you guys with this, I suspect I messed some files up when transferring the sources to another directory.

@illfated

This comment has been minimized.

Copy link

illfated replied Feb 2, 2020

That is OK. I should have suggested deleting the world DB and let core rebuild it. Thanks for confirming what you did to make it work again.

Please sign in to comment.
You can’t perform that action at this time.