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.cpp37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 72b4d7be0b0..6c29b9a64a9 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -467,7 +467,7 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields)
creatureTemplate.Entry = entry;
- for (uint8 i = 0; i < MAX_DIFFICULTY - 1; ++i)
+ for (uint8 i = 0; i < MAX_CREATURE_DIFFICULTIES; ++i)
creatureTemplate.DifficultyEntry[i] = fields[1 + i].GetUInt32();
for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i)
@@ -626,7 +626,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
return;
bool ok = true; // bool to allow continue outside this loop
- for (uint32 diff = 0; diff < MAX_DIFFICULTY - 1 && ok; ++diff)
+ for (uint32 diff = 0; diff < MAX_CREATURE_DIFFICULTIES && ok; ++diff)
{
if (!cInfo->DifficultyEntry[diff])
continue;
@@ -641,7 +641,7 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
}
bool ok2 = true;
- for (uint32 diff2 = 0; diff2 < MAX_DIFFICULTY - 1 && ok2; ++diff2)
+ for (uint32 diff2 = 0; diff2 < MAX_CREATURE_DIFFICULTIES && ok2; ++diff2)
{
ok2 = false;
if (_difficultyEntries[diff2].find(cInfo->Entry) != _difficultyEntries[diff2].end())
@@ -1660,11 +1660,10 @@ void ObjectMgr::LoadCreatures()
// Build single time for check spawnmask
std::map<uint32, uint32> spawnMasks;
- for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
- if (sMapStore.LookupEntry(i))
- for (int k = 0; k < MAX_DIFFICULTY; ++k)
- if (GetMapDifficultyData(i, Difficulty(k)))
- spawnMasks[i] |= (1 << k);
+ for (auto& mapDifficultyPair : sMapDifficultyMap)
+ for (auto& difficultyPair : mapDifficultyPair.second)
+ spawnMasks[mapDifficultyPair.first] |= (1 << difficultyPair.first);
+
_creatureDataStore.rehash(result->GetRowCount());
@@ -1697,7 +1696,7 @@ void ObjectMgr::LoadCreatures()
data.curhealth = fields[12].GetUInt32();
data.curmana = fields[13].GetUInt32();
data.movementType = fields[14].GetUInt8();
- data.spawnMask = fields[15].GetUInt8();
+ data.spawnMask = fields[15].GetUInt32();
data.phaseMask = fields[16].GetUInt32();
int16 gameEvent = fields[17].GetInt8();
uint32 PoolId = fields[18].GetUInt32();
@@ -1719,7 +1718,7 @@ void ObjectMgr::LoadCreatures()
TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD ") 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)
+ for (uint32 diff = 0; diff < MAX_CREATURE_DIFFICULTIES && ok; ++diff)
{
if (_difficultyEntries[diff].find(data.id) != _difficultyEntries[diff].end())
{
@@ -1813,7 +1812,7 @@ void ObjectMgr::LoadCreatures()
void ObjectMgr::AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const* data)
{
- uint8 mask = data->spawnMask;
+ uint32 mask = data->spawnMask;
for (uint8 i = 0; mask != 0; i++, mask >>= 1)
{
if (mask & 1)
@@ -1827,7 +1826,7 @@ void ObjectMgr::AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const*
void ObjectMgr::RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const* data)
{
- uint8 mask = data->spawnMask;
+ uint32 mask = data->spawnMask;
for (uint8 i = 0; mask != 0; i++, mask >>= 1)
{
if (mask & 1)
@@ -1994,11 +1993,9 @@ void ObjectMgr::LoadGameobjects()
// build single time for check spawnmask
std::map<uint32, uint32> spawnMasks;
- for (uint32 i = 0; i < sMapStore.GetNumRows(); ++i)
- if (sMapStore.LookupEntry(i))
- for (int k = 0; k < MAX_DIFFICULTY; ++k)
- if (GetMapDifficultyData(i, Difficulty(k)))
- spawnMasks[i] |= (1 << k);
+ for (auto& mapDifficultyPair : sMapDifficultyMap)
+ for (auto& difficultyPair : mapDifficultyPair.second)
+ spawnMasks[mapDifficultyPair.first] |= (1 << difficultyPair.first);
_gameObjectDataStore.rehash(result->GetRowCount());
@@ -2075,7 +2072,7 @@ void ObjectMgr::LoadGameobjects()
}
data.go_state = GOState(go_state);
- data.spawnMask = fields[14].GetUInt8();
+ data.spawnMask = fields[14].GetUInt32();
if (!IsTransportMap(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) that has wrong spawn mask %u including unsupported difficulty modes for map (Id: %u), skip", guid, data.id, data.spawnMask, data.mapid);
@@ -2147,7 +2144,7 @@ void ObjectMgr::LoadGameobjects()
void ObjectMgr::AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const* data)
{
- uint8 mask = data->spawnMask;
+ uint32 mask = data->spawnMask;
for (uint8 i = 0; mask != 0; i++, mask >>= 1)
{
if (mask & 1)
@@ -2161,7 +2158,7 @@ void ObjectMgr::AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData con
void ObjectMgr::RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const* data)
{
- uint8 mask = data->spawnMask;
+ uint32 mask = data->spawnMask;
for (uint8 i = 0; mask != 0; i++, mask >>= 1)
{
if (mask & 1)