aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2020-06-27 13:33:17 +0200
committerShauren <shauren.trinity@gmail.com>2020-06-27 13:33:17 +0200
commitdeca201f7787f31187e2b9fab9cba7760313e786 (patch)
tree25c2b18ccd39760e2665a99c247980b606279e63 /src/server/scripts
parenteccc015ce7c9d54cb79e113706ef028cfc34b144 (diff)
Core/DataStores: Simplified string memory allocation in db2 files, dropped unneccessary level of indirection
Diffstat (limited to 'src/server/scripts')
-rw-r--r--src/server/scripts/Commands/cs_character.cpp4
-rw-r--r--src/server/scripts/Commands/cs_go.cpp2
-rw-r--r--src/server/scripts/Commands/cs_group.cpp2
-rw-r--r--src/server/scripts/Commands/cs_learn.cpp10
-rw-r--r--src/server/scripts/Commands/cs_lookup.cpp72
-rw-r--r--src/server/scripts/Commands/cs_message.cpp4
-rw-r--r--src/server/scripts/Commands/cs_misc.cpp18
-rw-r--r--src/server/scripts/Commands/cs_modify.cpp4
-rw-r--r--src/server/scripts/Commands/cs_titles.cpp6
9 files changed, 61 insertions, 61 deletions
diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp
index 9f43772a430..8d46abfa58e 100644
--- a/src/server/scripts/Commands/cs_character.cpp
+++ b/src/server/scripts/Commands/cs_character.cpp
@@ -279,7 +279,7 @@ public:
if (titleInfo && target->HasTitle(titleInfo))
{
- std::string name = (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)->Str[handler->GetSessionDbcLocale()];
+ std::string name = (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[handler->GetSessionDbcLocale()];
if (name.empty())
continue;
@@ -647,7 +647,7 @@ public:
{
FactionState const& faction = itr->second;
FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction.ID);
- char const* factionName = factionEntry ? factionEntry->Name->Str[loc] : "#Not found#";
+ char const* factionName = factionEntry ? factionEntry->Name[loc] : "#Not found#";
ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry);
std::string rankName = handler->GetTrinityString(ReputationRankStrIndex[rank]);
std::ostringstream ss;
diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp
index bfc3c8956dd..53efc8bf5b4 100644
--- a/src/server/scripts/Commands/cs_go.cpp
+++ b/src/server/scripts/Commands/cs_go.cpp
@@ -510,7 +510,7 @@ public:
if (map->Instanceable())
{
- handler->PSendSysMessage(LANG_INVALID_ZONE_MAP, areaId, areaEntry->AreaName->Str[handler->GetSessionDbcLocale()], map->GetId(), map->GetMapName());
+ handler->PSendSysMessage(LANG_INVALID_ZONE_MAP, areaId, areaEntry->AreaName[handler->GetSessionDbcLocale()], map->GetId(), map->GetMapName());
handler->SetSentErrorMessage(true);
return false;
}
diff --git a/src/server/scripts/Commands/cs_group.cpp b/src/server/scripts/Commands/cs_group.cpp
index f6866734a7c..284f50942c4 100644
--- a/src/server/scripts/Commands/cs_group.cpp
+++ b/src/server/scripts/Commands/cs_group.cpp
@@ -361,7 +361,7 @@ public:
{
AreaTableEntry const* zone = sAreaTableStore.LookupEntry(area->ParentAreaID);
if (zone)
- zoneName = zone->AreaName->Str[handler->GetSessionDbcLocale()];
+ zoneName = zone->AreaName[handler->GetSessionDbcLocale()];
}
}
else
diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp
index 1de918cbc81..a9c9db0c816 100644
--- a/src/server/scripts/Commands/cs_learn.cpp
+++ b/src/server/scripts/Commands/cs_learn.cpp
@@ -370,20 +370,20 @@ public:
!skillInfo->CanLink) // only prof with recipes have set
continue;
- int locale = handler->GetSessionDbcLocale();
- name = skillInfo->DisplayName->Str[locale];
+ LocaleConstant locale = handler->GetSessionDbcLocale();
+ name = skillInfo->DisplayName[locale];
if (name.empty())
continue;
if (!Utf8FitTo(name, namePart))
{
- locale = 0;
- for (; locale < TOTAL_LOCALES; ++locale)
+ locale = LOCALE_enUS;
+ for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
{
if (locale == handler->GetSessionDbcLocale())
continue;
- name = skillInfo->DisplayName->Str[locale];
+ name = skillInfo->DisplayName[locale];
if (name.empty())
continue;
diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp
index 7db339d63c6..6c16d7e6005 100644
--- a/src/server/scripts/Commands/cs_lookup.cpp
+++ b/src/server/scripts/Commands/cs_lookup.cpp
@@ -108,20 +108,20 @@ public:
AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(i);
if (areaEntry)
{
- int32 locale = handler->GetSessionDbcLocale();
- std::string name = areaEntry->AreaName->Str[locale];
+ LocaleConstant locale = handler->GetSessionDbcLocale();
+ std::string name = areaEntry->AreaName[locale];
if (name.empty())
continue;
if (!Utf8FitTo(name, wNamePart))
{
- locale = 0;
- for (; locale < TOTAL_LOCALES; ++locale)
+ locale = LOCALE_enUS;
+ for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
{
if (locale == handler->GetSessionDbcLocale())
continue;
- name = areaEntry->AreaName->Str[locale];
+ name = areaEntry->AreaName[locale];
if (name.empty())
continue;
@@ -320,20 +320,20 @@ public:
{
FactionState const* factionState = target ? target->GetReputationMgr().GetState(factionEntry) : NULL;
- int locale = handler->GetSessionDbcLocale();
- std::string name = factionEntry->Name->Str[locale];
+ LocaleConstant locale = handler->GetSessionDbcLocale();
+ std::string name = factionEntry->Name[locale];
if (name.empty())
continue;
if (!Utf8FitTo(name, wNamePart))
{
- locale = 0;
- for (; locale < TOTAL_LOCALES; ++locale)
+ locale = LOCALE_enUS;
+ for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
{
if (locale == handler->GetSessionDbcLocale())
continue;
- name = factionEntry->Name->Str[locale];
+ name = factionEntry->Name[locale];
if (name.empty())
continue;
@@ -468,20 +468,20 @@ public:
ItemSetEntry const* set = sItemSetStore.LookupEntry(id);
if (set)
{
- int32 locale = handler->GetSessionDbcLocale();
- std::string name = set->Name->Str[locale];
+ LocaleConstant locale = handler->GetSessionDbcLocale();
+ std::string name = set->Name[locale];
if (name.empty())
continue;
if (!Utf8FitTo(name, wNamePart))
{
- locale = 0;
- for (; locale < TOTAL_LOCALES; ++locale)
+ locale = LOCALE_enUS;
+ for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
{
if (locale == handler->GetSessionDbcLocale())
continue;
- name = set->Name->Str[locale];
+ name = set->Name[locale];
if (name.empty())
continue;
@@ -757,20 +757,20 @@ public:
SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(id);
if (skillInfo)
{
- int locale = handler->GetSessionDbcLocale();
- std::string name = skillInfo->DisplayName->Str[locale];
+ LocaleConstant locale = handler->GetSessionDbcLocale();
+ std::string name = skillInfo->DisplayName[locale];
if (name.empty())
continue;
if (!Utf8FitTo(name, wNamePart))
{
- locale = 0;
- for (; locale < TOTAL_LOCALES; ++locale)
+ locale = LOCALE_enUS;
+ for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
{
if (locale == handler->GetSessionDbcLocale())
continue;
- name = skillInfo->DisplayName->Str[locale];
+ name = skillInfo->DisplayName[locale];
if (name.empty())
continue;
@@ -844,15 +844,15 @@ public:
{
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellName->ID, DIFFICULTY_NONE))
{
- int locale = handler->GetSessionDbcLocale();
+ LocaleConstant locale = handler->GetSessionDbcLocale();
std::string name = spellInfo->SpellName->Str[locale];
if (name.empty())
continue;
if (!Utf8FitTo(name, wNamePart))
{
- locale = 0;
- for (; locale < TOTAL_LOCALES; ++locale)
+ locale = LOCALE_enUS;
+ for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
{
if (locale == handler->GetSessionDbcLocale())
continue;
@@ -939,7 +939,7 @@ public:
if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id, DIFFICULTY_NONE))
{
- int locale = handler->GetSessionDbcLocale();
+ LocaleConstant locale = handler->GetSessionDbcLocale();
std::string name = spellInfo->SpellName->Str[locale];
if (name.empty())
{
@@ -1014,12 +1014,12 @@ public:
bool found = false;
uint32 count = 0;
uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS);
- int32 locale = handler->GetSessionDbcLocale();
+ LocaleConstant locale = handler->GetSessionDbcLocale();
// Search in TaxiNodes.dbc
for (TaxiNodesEntry const* nodeEntry : sTaxiNodesStore)
{
- std::string name = nodeEntry->Name->Str[locale];
+ std::string name = nodeEntry->Name[locale];
if (name.empty())
continue;
@@ -1141,21 +1141,21 @@ public:
if (target && target->getGender() != gender)
continue;
- int32 locale = handler->GetSessionDbcLocale();
- std::string name = (gender == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)->Str[locale];
+ LocaleConstant locale = handler->GetSessionDbcLocale();
+ std::string name = (gender == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[locale];
if (name.empty())
continue;
if (!Utf8FitTo(name, wNamePart))
{
- locale = 0;
- for (; locale < TOTAL_LOCALES; ++locale)
+ locale = LOCALE_enUS;
+ for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
{
if (locale == handler->GetSessionDbcLocale())
continue;
- name = (gender == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)->Str[locale];
+ name = (gender == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[locale];
if (name.empty())
continue;
@@ -1218,20 +1218,20 @@ public:
{
if (MapEntry const* mapInfo = sMapStore.LookupEntry(id))
{
- int32 locale = handler->GetSessionDbcLocale();
- std::string name = mapInfo->MapName->Str[locale];
+ LocaleConstant locale = handler->GetSessionDbcLocale();
+ std::string name = mapInfo->MapName[locale];
if (name.empty())
continue;
if (!Utf8FitTo(name, wNamePart) && handler->GetSession())
{
- locale = 0;
- for (; locale < TOTAL_LOCALES; ++locale)
+ locale = LOCALE_enUS;
+ for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1))
{
if (locale == handler->GetSessionDbcLocale())
continue;
- name = mapInfo->MapName->Str[locale];
+ name = mapInfo->MapName[locale];
if (name.empty())
continue;
diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp
index 1a889ec1122..cccbd6a37fa 100644
--- a/src/server/scripts/Commands/cs_message.cpp
+++ b/src/server/scripts/Commands/cs_message.cpp
@@ -83,7 +83,7 @@ public:
if (!channelEntry)
continue;
- if (strstr(channelEntry->Name->Str[handler->GetSessionDbcLocale()], channelStr))
+ if (strstr(channelEntry->Name[handler->GetSessionDbcLocale()], channelStr))
{
channelId = i;
break;
@@ -97,7 +97,7 @@ public:
if (!entry)
continue;
- if (strstr(entry->AreaName->Str[handler->GetSessionDbcLocale()], channelStr))
+ if (strstr(entry->AreaName[handler->GetSessionDbcLocale()], channelStr))
{
zoneEntry = entry;
break;
diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp
index 2a5f821e8d7..f2b012c4b17 100644
--- a/src/server/scripts/Commands/cs_misc.cpp
+++ b/src/server/scripts/Commands/cs_misc.cpp
@@ -285,9 +285,9 @@ public:
char const* unknown = handler->GetTrinityString(LANG_UNKNOWN);
handler->PSendSysMessage(LANG_MAP_POSITION,
- mapId, (mapEntry ? mapEntry->MapName->Str[handler->GetSessionDbcLocale()] : unknown),
- zoneId, (zoneEntry ? zoneEntry->AreaName->Str[handler->GetSessionDbcLocale()] : unknown),
- areaId, (areaEntry ? areaEntry->AreaName->Str[handler->GetSessionDbcLocale()] : unknown),
+ mapId, (mapEntry ? mapEntry->MapName[handler->GetSessionDbcLocale()] : unknown),
+ zoneId, (zoneEntry ? zoneEntry->AreaName[handler->GetSessionDbcLocale()] : unknown),
+ areaId, (areaEntry ? areaEntry->AreaName[handler->GetSessionDbcLocale()] : unknown),
object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation());
if (Transport* transport = object->GetTransport())
handler->PSendSysMessage(LANG_TRANSPORT_POSITION,
@@ -1269,8 +1269,8 @@ public:
std::string itemName = itemNameStr+1;
auto itr = std::find_if(sItemSparseStore.begin(), sItemSparseStore.end(), [&itemName](ItemSparseEntry const* sparse)
{
- for (uint32 i = 0; i < TOTAL_LOCALES; ++i)
- if (itemName == sparse->Display->Str[i])
+ for (LocaleConstant i = LOCALE_enUS; i < TOTAL_LOCALES; i = LocaleConstant(i + 1))
+ if (itemName == sparse->Display[i])
return true;
return false;
});
@@ -1549,7 +1549,7 @@ public:
// add the skill to the player's book with step 1 (which is the first rank, in most cases something
// like 'Apprentice <skill>'.
target->SetSkill(skill, targetHasSkill ? target->GetSkillStep(skill) : 1, level, max);
- handler->PSendSysMessage(LANG_SET_SKILL, skill, skillLine->DisplayName->Str[handler->GetSessionDbcLocale()], handler->GetNameLink(target).c_str(), level, max);
+ handler->PSendSysMessage(LANG_SET_SKILL, skill, skillLine->DisplayName[handler->GetSessionDbcLocale()], handler->GetNameLink(target).c_str(), level, max);
return true;
}
@@ -1887,15 +1887,15 @@ public:
AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId);
if (area)
{
- areaName = area->AreaName->Str[handler->GetSessionDbcLocale()];
+ areaName = area->AreaName[handler->GetSessionDbcLocale()];
AreaTableEntry const* zone = sAreaTableStore.LookupEntry(area->ParentAreaID);
if (zone)
- zoneName = zone->AreaName->Str[handler->GetSessionDbcLocale()];
+ zoneName = zone->AreaName[handler->GetSessionDbcLocale()];
}
if (target)
- handler->PSendSysMessage(LANG_PINFO_CHR_MAP, map->MapName->Str[handler->GetSessionDbcLocale()],
+ handler->PSendSysMessage(LANG_PINFO_CHR_MAP, map->MapName[handler->GetSessionDbcLocale()],
(!zoneName.empty() ? zoneName.c_str() : handler->GetTrinityString(LANG_UNKNOWN)),
(!areaName.empty() ? areaName.c_str() : handler->GetTrinityString(LANG_UNKNOWN)));
diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp
index 83ac3e43b4f..17a4c71b5cf 100644
--- a/src/server/scripts/Commands/cs_modify.cpp
+++ b/src/server/scripts/Commands/cs_modify.cpp
@@ -742,14 +742,14 @@ public:
if (factionEntry->ReputationIndex < 0)
{
- handler->PSendSysMessage(LANG_COMMAND_FACTION_NOREP_ERROR, factionEntry->Name->Str[handler->GetSessionDbcLocale()], factionId);
+ handler->PSendSysMessage(LANG_COMMAND_FACTION_NOREP_ERROR, factionEntry->Name[handler->GetSessionDbcLocale()], factionId);
handler->SetSentErrorMessage(true);
return false;
}
target->GetReputationMgr().SetOneFactionReputation(factionEntry, amount, false);
target->GetReputationMgr().SendState(target->GetReputationMgr().GetState(factionEntry));
- handler->PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->Name->Str[handler->GetSessionDbcLocale()], factionId,
+ handler->PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->Name[handler->GetSessionDbcLocale()], factionId,
handler->GetNameLink(target).c_str(), target->GetReputationMgr().GetReputation(factionEntry));
return true;
}
diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp
index f60d36cbccc..40c367838cb 100644
--- a/src/server/scripts/Commands/cs_titles.cpp
+++ b/src/server/scripts/Commands/cs_titles.cpp
@@ -96,7 +96,7 @@ public:
target->SetChosenTitle(titleInfo->MaskID);
handler->PSendSysMessage(LANG_TITLE_CURRENT_RES, id,
- (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)->Str[handler->GetSessionDbcLocale()],
+ (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[handler->GetSessionDbcLocale()],
tNameLink.c_str());
return true;
}
@@ -139,7 +139,7 @@ public:
std::string tNameLink = handler->GetNameLink(target);
std::string titleNameStr = Trinity::StringFormat(
- (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)->Str[handler->GetSessionDbcLocale()],
+ (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[handler->GetSessionDbcLocale()],
target->GetName().c_str()
);
@@ -189,7 +189,7 @@ public:
std::string tNameLink = handler->GetNameLink(target);
std::string titleNameStr = Trinity::StringFormat(
- (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)->Str[handler->GetSessionDbcLocale()],
+ (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[handler->GetSessionDbcLocale()],
target->GetName().c_str()
);