aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Globals/ObjectMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Globals/ObjectMgr.cpp')
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp208
1 files changed, 71 insertions, 137 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index d44c11f886a..2bdfb57adb4 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -1290,7 +1290,7 @@ void ObjectMgr::LoadCreatureModelInfo()
// Checks
if (!sCreatureDisplayInfoStore.LookupEntry(modelId))
- TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has model for not existed display id (%u).", modelId);
+ TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has model for nonexistent display id (%u).", modelId);
if (modelInfo.gender > GENDER_NONE)
{
@@ -1300,7 +1300,7 @@ void ObjectMgr::LoadCreatureModelInfo()
if (modelInfo.modelid_other_gender && !sCreatureDisplayInfoStore.LookupEntry(modelInfo.modelid_other_gender))
{
- TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has not existed alt.gender model (%u) for existed display id (%u).", modelInfo.modelid_other_gender, modelId);
+ TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has nonexistent alt.gender model (%u) for existed display id (%u).", modelInfo.modelid_other_gender, modelId);
modelInfo.modelid_other_gender = 0;
}
@@ -1336,7 +1336,7 @@ void ObjectMgr::LoadLinkedRespawn()
uint32 linkedGuidLow = fields[1].GetUInt32();
uint8 linkType = fields[2].GetUInt8();
- uint64 guid = 0, linkedGuid = 0;
+ ObjectGuid guid, linkedGuid;
bool error = false;
switch (linkType)
{
@@ -1373,8 +1373,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
- guid = MAKE_NEW_GUID(guidLow, slave->id, HIGHGUID_UNIT);
- linkedGuid = MAKE_NEW_GUID(linkedGuidLow, master->id, HIGHGUID_UNIT);
+ guid = ObjectGuid(HIGHGUID_UNIT, slave->id, guidLow);
+ linkedGuid = ObjectGuid(HIGHGUID_UNIT, master->id, linkedGuidLow);
break;
}
case CREATURE_TO_GO:
@@ -1410,8 +1410,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
- guid = MAKE_NEW_GUID(guidLow, slave->id, HIGHGUID_UNIT);
- linkedGuid = MAKE_NEW_GUID(linkedGuidLow, master->id, HIGHGUID_GAMEOBJECT);
+ guid = ObjectGuid(HIGHGUID_UNIT, slave->id, guidLow);
+ linkedGuid = ObjectGuid(HIGHGUID_GAMEOBJECT, master->id, linkedGuidLow);
break;
}
case GO_TO_GO:
@@ -1447,8 +1447,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
- guid = MAKE_NEW_GUID(guidLow, slave->id, HIGHGUID_GAMEOBJECT);
- linkedGuid = MAKE_NEW_GUID(linkedGuidLow, master->id, HIGHGUID_GAMEOBJECT);
+ guid = ObjectGuid(HIGHGUID_GAMEOBJECT, slave->id, guidLow);
+ linkedGuid = ObjectGuid(HIGHGUID_GAMEOBJECT, master->id, linkedGuidLow);
break;
}
case GO_TO_CREATURE:
@@ -1484,8 +1484,8 @@ void ObjectMgr::LoadLinkedRespawn()
break;
}
- guid = MAKE_NEW_GUID(guidLow, slave->id, HIGHGUID_GAMEOBJECT);
- linkedGuid = MAKE_NEW_GUID(linkedGuidLow, master->id, HIGHGUID_UNIT);
+ guid = ObjectGuid(HIGHGUID_GAMEOBJECT, slave->id, guidLow);
+ linkedGuid = ObjectGuid(HIGHGUID_UNIT, master->id, linkedGuidLow);
break;
}
}
@@ -1503,9 +1503,9 @@ bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guidLow, uint32 linkedGuidLow)
if (!guidLow)
return false;
- const CreatureData* master = GetCreatureData(guidLow);
+ CreatureData const* master = GetCreatureData(guidLow);
ASSERT(master);
- uint64 guid = MAKE_NEW_GUID(guidLow, master->id, HIGHGUID_UNIT);
+ ObjectGuid guid(HIGHGUID_UNIT, master->id, guidLow);
if (!linkedGuidLow) // we're removing the linking
{
@@ -1516,14 +1516,14 @@ bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guidLow, uint32 linkedGuidLow)
return true;
}
- const CreatureData* slave = GetCreatureData(linkedGuidLow);
+ CreatureData const* slave = GetCreatureData(linkedGuidLow);
if (!slave)
{
TC_LOG_ERROR("sql.sql", "Creature '%u' linking to non-existent creature '%u'.", guidLow, linkedGuidLow);
return false;
}
- const MapEntry* const map = sMapStore.LookupEntry(master->mapid);
+ MapEntry const* map = sMapStore.LookupEntry(master->mapid);
if (!map || !map->Instanceable() || (master->mapid != slave->mapid))
{
TC_LOG_ERROR("sql.sql", "Creature '%u' linking to '%u' on an unpermitted map.", guidLow, linkedGuidLow);
@@ -1536,7 +1536,7 @@ bool ObjectMgr::SetCreatureLinkedRespawn(uint32 guidLow, uint32 linkedGuidLow)
return false;
}
- uint64 linkedGuid = MAKE_NEW_GUID(linkedGuidLow, slave->id, HIGHGUID_UNIT);
+ ObjectGuid linkedGuid(HIGHGUID_UNIT, slave->id, linkedGuidLow);
_linkedRespawnStore[guid] = linkedGuid;
PreparedStatement *stmt = WorldDatabase.GetPreparedStatement(WORLD_REP_CREATURE_LINKED_RESPAWN);
@@ -1704,20 +1704,20 @@ void ObjectMgr::LoadCreatures()
MapEntry const* mapEntry = sMapStore.LookupEntry(data.mapid);
if (!mapEntry)
{
- TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u Entry: %u) that spawned at not existed map (Id: %u), skipped.", guid, data.id, data.mapid);
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u) that spawned at nonexistent map (Id: %u), skipped.", guid, data.mapid);
continue;
}
// Skip spawnMask check for transport maps
if (!IsTransportMap(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
- TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u Entry: %u) that have wrong spawn mask %u including not supported difficulty modes for map (Id: %u) spawnMasks[data.mapid]: %u.", guid, data.id, data.spawnMask, data.mapid, spawnMasks[data.mapid]);
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u) that have wrong spawn mask %u including unsupported difficulty modes for map (Id: %u).", guid, data.spawnMask, data.mapid);
bool ok = true;
for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
{
if (_difficultyEntries[diff].find(data.id) != _difficultyEntries[diff].end())
{
- TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u) that listed as difficulty %u template (entry: %u) in `creature_template`, skipped.",
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u) that is listed as difficulty %u template (entry: %u) in `creature_template`, skipped.",
guid, diff + 1, data.id);
ok = false;
}
@@ -1730,7 +1730,7 @@ void ObjectMgr::LoadCreatures()
{
if (!GetEquipmentInfo(data.id, data.equipmentId))
{
- TC_LOG_ERROR("sql.sql", "Table `creature` have creature (Entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", data.id, data.equipmentId);
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (Entry: %u) with equipment_id %u not found in table `creature_equip_template`, set to no equipment.", data.id, data.equipmentId);
data.equipmentId = 0;
}
}
@@ -1738,19 +1738,19 @@ void ObjectMgr::LoadCreatures()
if (cInfo->flags_extra & CREATURE_FLAG_EXTRA_INSTANCE_BIND)
{
if (!mapEntry || !mapEntry->IsDungeon())
- TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature are not in instance.", guid, data.id);
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u Entry: %u) with `creature_template`.`flags_extra` including CREATURE_FLAG_EXTRA_INSTANCE_BIND but creature is not in instance.", guid, data.id);
}
if (data.spawndist < 0.0f)
{
- TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u Entry: %u) with `spawndist`< 0, set to 0.", guid, data.id);
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u Entry: %u) with `spawndist`< 0, set to 0.", guid, data.id);
data.spawndist = 0.0f;
}
else if (data.movementType == RANDOM_MOTION_TYPE)
{
if (data.spawndist == 0.0f)
{
- TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=1 (random movement) but with `spawndist`=0, replace by idle movement type (0).", guid, data.id);
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u Entry: %u) with `MovementType`=1 (random movement) but with `spawndist`=0, replace by idle movement type (0).", guid, data.id);
data.movementType = IDLE_MOTION_TYPE;
}
}
@@ -1758,14 +1758,14 @@ void ObjectMgr::LoadCreatures()
{
if (data.spawndist != 0.0f)
{
- TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u Entry: %u) with `MovementType`=0 (idle) have `spawndist`<>0, set to 0.", guid, data.id);
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u Entry: %u) with `MovementType`=0 (idle) have `spawndist`<>0, set to 0.", guid, data.id);
data.spawndist = 0.0f;
}
}
if (data.phaseMask == 0)
{
- TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.", guid, data.id);
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: %u Entry: %u) with `phaseMask`=0 (not visible for anyone), set to 1.", guid, data.id);
data.phaseMask = 1;
}
@@ -2051,7 +2051,7 @@ void ObjectMgr::LoadGameobjects()
data.spawnMask = fields[14].GetUInt8();
if (!IsTransportMap(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
- TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: %u Entry: %u) that has wrong spawn mask %u including not supported difficulty modes for map (Id: %u), skip", guid, data.id, data.spawnMask, data.mapid);
+ TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: %u Entry: %u) that has wrong spawn mask %u including unsupported difficulty modes for map (Id: %u), skip", guid, data.id, data.spawnMask, data.mapid);
data.phaseMask = fields[15].GetUInt32();
int16 gameEvent = fields[16].GetInt8();
@@ -2127,15 +2127,13 @@ void ObjectMgr::RemoveGameobjectFromGrid(uint32 guid, GameObjectData const* data
Player* ObjectMgr::GetPlayerByLowGUID(uint32 lowguid) const
{
- uint64 guid = MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER);
+ ObjectGuid guid(HIGHGUID_PLAYER, lowguid);
return ObjectAccessor::FindPlayer(guid);
}
// name must be checked to correctness (if received) before call this function
-uint64 ObjectMgr::GetPlayerGUIDByName(std::string const& name) const
+ObjectGuid ObjectMgr::GetPlayerGUIDByName(std::string const& name) const
{
- uint64 guid = 0;
-
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_GUID_BY_NAME);
stmt->setString(0, name);
@@ -2143,12 +2141,12 @@ uint64 ObjectMgr::GetPlayerGUIDByName(std::string const& name) const
PreparedQueryResult result = CharacterDatabase.Query(stmt);
if (result)
- guid = MAKE_NEW_GUID((*result)[0].GetUInt32(), 0, HIGHGUID_PLAYER);
+ return ObjectGuid(HIGHGUID_PLAYER, (*result)[0].GetUInt32());
- return guid;
+ return ObjectGuid::Empty;
}
-bool ObjectMgr::GetPlayerNameByGUID(uint64 guid, std::string& name) const
+bool ObjectMgr::GetPlayerNameByGUID(ObjectGuid guid, std::string& name) const
{
// prevent DB access for online player
if (Player* player = ObjectAccessor::FindPlayer(guid))
@@ -2159,7 +2157,7 @@ bool ObjectMgr::GetPlayerNameByGUID(uint64 guid, std::string& name) const
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARACTER_NAME);
- stmt->setUInt32(0, GUID_LOPART(guid));
+ stmt->setUInt32(0, guid.GetCounter());
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -2172,7 +2170,7 @@ bool ObjectMgr::GetPlayerNameByGUID(uint64 guid, std::string& name) const
return false;
}
-uint32 ObjectMgr::GetPlayerTeamByGUID(uint64 guid) const
+uint32 ObjectMgr::GetPlayerTeamByGUID(ObjectGuid guid) const
{
// prevent DB access for online player
if (Player* player = ObjectAccessor::FindPlayer(guid))
@@ -2182,7 +2180,7 @@ uint32 ObjectMgr::GetPlayerTeamByGUID(uint64 guid) const
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHAR_RACE);
- stmt->setUInt32(0, GUID_LOPART(guid));
+ stmt->setUInt32(0, guid.GetCounter());
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -2195,7 +2193,7 @@ uint32 ObjectMgr::GetPlayerTeamByGUID(uint64 guid) const
return 0;
}
-uint32 ObjectMgr::GetPlayerAccountIdByGUID(uint64 guid) const
+uint32 ObjectMgr::GetPlayerAccountIdByGUID(ObjectGuid guid) const
{
// prevent DB access for online player
if (Player* player = ObjectAccessor::FindPlayer(guid))
@@ -2205,7 +2203,7 @@ uint32 ObjectMgr::GetPlayerAccountIdByGUID(uint64 guid) const
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_ACCOUNT_BY_GUID);
- stmt->setUInt32(0, GUID_LOPART(guid));
+ stmt->setUInt32(0, guid.GetCounter());
PreparedQueryResult result = CharacterDatabase.Query(stmt);
@@ -4775,7 +4773,7 @@ void ObjectMgr::LoadScripts(ScriptsType type)
info->type == GAMEOBJECT_TYPE_BUTTON ||
info->type == GAMEOBJECT_TYPE_TRAP)
{
- TC_LOG_ERROR("sql.sql", "Table `%s` have gameobject type (%u) unsupported by command SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id %u",
+ TC_LOG_ERROR("sql.sql", "Table `%s` has gameobject type (%u) unsupported by command SCRIPT_COMMAND_RESPAWN_GAMEOBJECT for script id %u",
tableName.c_str(), info->entry, tmp.id);
continue;
}
@@ -4821,7 +4819,7 @@ void ObjectMgr::LoadScripts(ScriptsType type)
if (info->type != GAMEOBJECT_TYPE_DOOR)
{
- TC_LOG_ERROR("sql.sql", "Table `%s` has gameobject type (%u) non supported by command %s for script id %u",
+ TC_LOG_ERROR("sql.sql", "Table `%s` has gameobject type (%u) unsupported by command %s for script id %u",
tableName.c_str(), info->entry, GetScriptCommandName(tmp.command).c_str(), tmp.id);
continue;
}
@@ -5537,7 +5535,7 @@ void ObjectMgr::ReturnOrDeleteOldMails(bool serverUp)
Player* player = NULL;
if (serverUp)
- player = ObjectAccessor::FindPlayer((uint64)m->receiver);
+ player = ObjectAccessor::FindPlayer(ObjectGuid(HIGHGUID_PLAYER, m->receiver));
if (player && player->m_mailsLoaded)
{ // this code will run very improbably (the time is between 4 and 5 am, in game is online a player, who has old mail
@@ -6344,7 +6342,7 @@ void ObjectMgr::SetHighestGuids()
if (result)
_hiItemGuid = (*result)[0].GetUInt32()+1;
- // Cleanup other tables from not existed guids ( >= _hiItemGuid)
+ // Cleanup other tables from nonexistent guids ( >= _hiItemGuid)
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item >= '%u'", _hiItemGuid); // One-time query
CharacterDatabase.PExecute("DELETE FROM mail_items WHERE item_guid >= '%u'", _hiItemGuid); // One-time query
CharacterDatabase.PExecute("DELETE FROM auctionhouse WHERE itemguid >= '%u'", _hiItemGuid); // One-time query
@@ -7047,7 +7045,7 @@ void ObjectMgr::LoadReputationOnKill()
if (!GetCreatureTemplate(creature_id))
{
- TC_LOG_ERROR("sql.sql", "Table `creature_onkill_reputation` have data for not existed creature entry (%u), skipped", creature_id);
+ TC_LOG_ERROR("sql.sql", "Table `creature_onkill_reputation` has data for nonexistent creature entry (%u), skipped", creature_id);
continue;
}
@@ -7473,9 +7471,9 @@ void ObjectMgr::LoadGameobjectQuestStarters()
{
GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
if (!goInfo)
- TC_LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data for not existed gameobject entry (%u) and existed quest %u", itr->first, itr->second);
+ TC_LOG_ERROR("sql.sql", "Table `gameobject_queststarter` has data for nonexistent gameobject entry (%u) and existed quest %u", itr->first, itr->second);
else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
- TC_LOG_ERROR("sql.sql", "Table `gameobject_queststarter` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
+ TC_LOG_ERROR("sql.sql", "Table `gameobject_queststarter` has data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
}
}
@@ -7487,9 +7485,9 @@ void ObjectMgr::LoadGameobjectQuestEnders()
{
GameObjectTemplate const* goInfo = GetGameObjectTemplate(itr->first);
if (!goInfo)
- TC_LOG_ERROR("sql.sql", "Table `gameobject_questender` have data for not existed gameobject entry (%u) and existed quest %u", itr->first, itr->second);
+ TC_LOG_ERROR("sql.sql", "Table `gameobject_questender` has data for nonexistent gameobject entry (%u) and existed quest %u", itr->first, itr->second);
else if (goInfo->type != GAMEOBJECT_TYPE_QUESTGIVER)
- TC_LOG_ERROR("sql.sql", "Table `gameobject_questender` have data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
+ TC_LOG_ERROR("sql.sql", "Table `gameobject_questender` has data gameobject entry (%u) for quest %u, but GO is not GAMEOBJECT_TYPE_QUESTGIVER", itr->first, itr->second);
}
}
@@ -7501,7 +7499,7 @@ void ObjectMgr::LoadCreatureQuestStarters()
{
CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
if (!cInfo)
- TC_LOG_ERROR("sql.sql", "Table `creature_queststarter` have data for not existed creature entry (%u) and existed quest %u", itr->first, itr->second);
+ TC_LOG_ERROR("sql.sql", "Table `creature_queststarter` has data for nonexistent creature entry (%u) and existed quest %u", itr->first, itr->second);
else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
TC_LOG_ERROR("sql.sql", "Table `creature_queststarter` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second);
}
@@ -7515,7 +7513,7 @@ void ObjectMgr::LoadCreatureQuestEnders()
{
CreatureTemplate const* cInfo = GetCreatureTemplate(itr->first);
if (!cInfo)
- TC_LOG_ERROR("sql.sql", "Table `creature_questender` have data for not existed creature entry (%u) and existed quest %u", itr->first, itr->second);
+ TC_LOG_ERROR("sql.sql", "Table `creature_questender` has data for nonexistent creature entry (%u) and existed quest %u", itr->first, itr->second);
else if (!(cInfo->npcflag & UNIT_NPC_FLAG_QUESTGIVER))
TC_LOG_ERROR("sql.sql", "Table `creature_questender` has creature entry (%u) for quest %u, but npcflag does not include UNIT_NPC_FLAG_QUESTGIVER", itr->first, itr->second);
}
@@ -7546,7 +7544,7 @@ void ObjectMgr::LoadReservedPlayersNames()
std::wstring wstr;
if (!Utf8toWStr (name, wstr))
{
- TC_LOG_ERROR("misc", "Table `reserved_name` have invalid name: %s", name.c_str());
+ TC_LOG_ERROR("misc", "Table `reserved_name` has invalid name: %s", name.c_str());
continue;
}
@@ -7770,112 +7768,48 @@ void ObjectMgr::LoadGameObjectForQuests()
TC_LOG_INFO("server.loading", ">> Loaded %u GameObjects for quests in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
-bool ObjectMgr::LoadTrinityStrings(const char* table, int32 min_value, int32 max_value)
+bool ObjectMgr::LoadTrinityStrings()
{
uint32 oldMSTime = getMSTime();
- int32 start_value = min_value;
- int32 end_value = max_value;
- // some string can have negative indexes range
- if (start_value < 0)
- {
- if (end_value >= start_value)
- {
- TC_LOG_ERROR("sql.sql", "Table '%s' attempt loaded with invalid range (%d - %d), strings not loaded.", table, min_value, max_value);
- return false;
- }
-
- // real range (max+1, min+1) exaple: (-10, -1000) -> -999...-10+1
- std::swap(start_value, end_value);
- ++start_value;
- ++end_value;
- }
- else
- {
- if (start_value >= end_value)
- {
- TC_LOG_ERROR("sql.sql", "Table '%s' attempt loaded with invalid range (%d - %d), strings not loaded.", table, min_value, max_value);
- return false;
- }
- }
-
- // cleanup affected map part for reloading case
- for (TrinityStringLocaleContainer::iterator itr = _trinityStringLocaleStore.begin(); itr != _trinityStringLocaleStore.end();)
- {
- if (itr->first >= start_value && itr->first < end_value)
- _trinityStringLocaleStore.erase(itr++);
- else
- ++itr;
- }
-
- QueryResult result = WorldDatabase.PQuery("SELECT entry, content_default, content_loc1, content_loc2, content_loc3, content_loc4, content_loc5, content_loc6, content_loc7, content_loc8 FROM %s", table);
+ _trinityStringStore.clear(); // for reload case
+ QueryResult result = WorldDatabase.Query("SELECT entry, content_default, content_loc1, content_loc2, content_loc3, content_loc4, content_loc5, content_loc6, content_loc7, content_loc8 FROM trinity_string");
if (!result)
{
- if (min_value == MIN_TRINITY_STRING_ID) // error only in case internal strings
- TC_LOG_ERROR("server.loading", ">> Loaded 0 trinity strings. DB table `%s` is empty. Cannot continue.", table);
- else
- TC_LOG_INFO("server.loading", ">> Loaded 0 string templates. DB table `%s` is empty.", table);
-
+ TC_LOG_ERROR("server.loading", ">> Loaded 0 trinity strings. DB table `trinity_string` is empty.");
return false;
}
- uint32 count = 0;
-
do
{
Field* fields = result->Fetch();
- int32 entry = fields[0].GetInt32();
+ uint32 entry = fields[0].GetUInt32();
- if (entry == 0)
- {
- TC_LOG_ERROR("sql.sql", "Table `%s` contain reserved entry 0, ignored.", table);
- continue;
- }
- else if (entry < start_value || entry >= end_value)
- {
- TC_LOG_ERROR("sql.sql", "Table `%s` contain entry %i out of allowed range (%d - %d), ignored.", table, entry, min_value, max_value);
- continue;
- }
+ TrinityString& data = _trinityStringStore[entry];
- TrinityStringLocale& data = _trinityStringLocaleStore[entry];
-
- if (!data.Content.empty())
- {
- TC_LOG_ERROR("sql.sql", "Table `%s` contain data for already loaded entry %i (from another table?), ignored.", table, entry);
- continue;
- }
-
- data.Content.resize(1);
- ++count;
+ data.Content.resize(DEFAULT_LOCALE + 1);
for (int8 i = TOTAL_LOCALES - 1; i >= 0; --i)
AddLocaleString(fields[i + 1].GetString(), LocaleConstant(i), data.Content);
- } while (result->NextRow());
-
- if (min_value == MIN_TRINITY_STRING_ID)
- TC_LOG_INFO("server.loading", ">> Loaded %u Trinity strings from table %s in %u ms", count, table, GetMSTimeDiffToNow(oldMSTime));
- else
- TC_LOG_INFO("server.loading", ">> Loaded %u string templates from %s in %u ms", count, table, GetMSTimeDiffToNow(oldMSTime));
+ }
+ while (result->NextRow());
+ TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " trinity strings in %u ms", _trinityStringStore.size(), GetMSTimeDiffToNow(oldMSTime));
return true;
}
-const char *ObjectMgr::GetTrinityString(int32 entry, LocaleConstant locale_idx) const
+char const* ObjectMgr::GetTrinityString(uint32 entry, LocaleConstant locale) const
{
- if (TrinityStringLocale const* msl = GetTrinityStringLocale(entry))
+ if (TrinityString const* ts = GetTrinityString(entry))
{
- if (msl->Content.size() > size_t(locale_idx) && !msl->Content[locale_idx].empty())
- return msl->Content[locale_idx].c_str();
-
- return msl->Content[DEFAULT_LOCALE].c_str();
+ if (ts->Content.size() > size_t(locale) && !ts->Content[locale].empty())
+ return ts->Content[locale].c_str();
+ return ts->Content[DEFAULT_LOCALE].c_str();
}
- if (entry > 0)
- TC_LOG_ERROR("sql.sql", "Entry %i not found in `trinity_string` table.", entry);
- else
- TC_LOG_ERROR("sql.sql", "Trinity string entry %i not found in DB.", entry);
+ TC_LOG_ERROR("sql.sql", "Trinity string entry %u not found in DB.", entry);
return "<error>";
}
@@ -8183,25 +8117,25 @@ void ObjectMgr::LoadMailLevelRewards()
if (level > MAX_LEVEL)
{
- TC_LOG_ERROR("sql.sql", "Table `mail_level_reward` have data for level %u that more supported by client (%u), ignoring.", level, MAX_LEVEL);
+ TC_LOG_ERROR("sql.sql", "Table `mail_level_reward` has data for level %u that more supported by client (%u), ignoring.", level, MAX_LEVEL);
continue;
}
if (!(raceMask & RACEMASK_ALL_PLAYABLE))
{
- TC_LOG_ERROR("sql.sql", "Table `mail_level_reward` have raceMask (%u) for level %u that not include any player races, ignoring.", raceMask, level);
+ TC_LOG_ERROR("sql.sql", "Table `mail_level_reward` has raceMask (%u) for level %u that not include any player races, ignoring.", raceMask, level);
continue;
}
if (!sMailTemplateStore.LookupEntry(mailTemplateId))
{
- TC_LOG_ERROR("sql.sql", "Table `mail_level_reward` have invalid mailTemplateId (%u) for level %u that invalid not include any player races, ignoring.", mailTemplateId, level);
+ TC_LOG_ERROR("sql.sql", "Table `mail_level_reward` has invalid mailTemplateId (%u) for level %u that invalid not include any player races, ignoring.", mailTemplateId, level);
continue;
}
if (!GetCreatureTemplate(senderEntry))
{
- TC_LOG_ERROR("sql.sql", "Table `mail_level_reward` have not existed sender creature entry (%u) for level %u that invalid not include any player races, ignoring.", senderEntry, level);
+ TC_LOG_ERROR("sql.sql", "Table `mail_level_reward` has nonexistent sender creature entry (%u) for level %u that invalid not include any player races, ignoring.", senderEntry, level);
continue;
}
@@ -8596,7 +8530,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 id, int32 maxcount
if (player)
ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
else
- TC_LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not existed creature template (Entry: %u), ignore", vendor_entry);
+ TC_LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` has data for nonexistent creature template (Entry: %u), ignore", vendor_entry);
return false;
}
@@ -8607,7 +8541,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 id, int32 maxcount
if (player)
ChatHandler(player->GetSession()).SendSysMessage(LANG_COMMAND_VENDORSELECTION);
else
- TC_LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have data for not creature template (Entry: %u) without vendor flag, ignore", vendor_entry);
+ TC_LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` has data for creature template (Entry: %u) without vendor flag, ignore", vendor_entry);
if (skip_vendors)
skip_vendors->insert(vendor_entry);
@@ -8630,7 +8564,7 @@ bool ObjectMgr::IsVendorItemValid(uint32 vendor_entry, uint32 id, int32 maxcount
if (player)
ChatHandler(player->GetSession()).PSendSysMessage(LANG_EXTENDED_COST_NOT_EXIST, ExtendedCost);
else
- TC_LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` have Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore", id, ExtendedCost, vendor_entry);
+ TC_LOG_ERROR("sql.sql", "Table `(game_event_)npc_vendor` has Item (Entry: %u) with wrong ExtendedCost (%u) for vendor (%u), ignore", id, ExtendedCost, vendor_entry);
return false;
}