aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/database/Database/Implementation/WorldDatabase.cpp2
-rw-r--r--src/server/game/Conditions/ConditionMgr.cpp4
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp19
-rw-r--r--src/server/game/Entities/Creature/Creature.h2
-rw-r--r--src/server/game/Entities/Creature/CreatureData.h9
-rw-r--r--src/server/game/Entities/Creature/TemporarySummon.h2
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp19
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h2
-rw-r--r--src/server/game/Entities/GameObject/GameObjectData.h9
-rw-r--r--src/server/game/Entities/Pet/Pet.h2
-rw-r--r--src/server/game/Entities/Transport/Transport.cpp4
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp58
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp11
-rw-r--r--src/server/scripts/Commands/cs_gobject.cpp2
-rw-r--r--src/server/scripts/Commands/cs_npc.cpp9
-rw-r--r--src/server/scripts/Commands/cs_wp.cpp8
16 files changed, 77 insertions, 85 deletions
diff --git a/src/server/database/Database/Implementation/WorldDatabase.cpp b/src/server/database/Database/Implementation/WorldDatabase.cpp
index 9082daab43e..a1270f178bb 100644
--- a/src/server/database/Database/Implementation/WorldDatabase.cpp
+++ b/src/server/database/Database/Implementation/WorldDatabase.cpp
@@ -85,7 +85,7 @@ void WorldDatabaseConnection::DoPrepareStatements()
PrepareStatement(WORLD_INS_CREATURE, "INSERT INTO creature (guid, id , map, spawnMask, PhaseId, PhaseGroup, modelid, equipment_id, position_x, position_y, position_z, orientation, spawntimesecs, spawndist, currentwaypoint, curhealth, curmana, MovementType, npcflag, unit_flags, unit_flags2, unit_flags3, dynamicflags) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(WORLD_DEL_GAME_EVENT_CREATURE, "DELETE FROM game_event_creature WHERE guid = ?", CONNECTION_ASYNC);
PrepareStatement(WORLD_DEL_GAME_EVENT_MODEL_EQUIP, "DELETE FROM game_event_model_equip WHERE guid = ?", CONNECTION_ASYNC);
- PrepareStatement(WORLD_INS_GAMEOBJECT, "INSERT INTO gameobject (guid, id, map, spawnMask, position_x, position_y, position_z, orientation, rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
+ PrepareStatement(WORLD_INS_GAMEOBJECT, "INSERT INTO gameobject (guid, id, map, spawnMask, PhaseId, PhaseGroup, position_x, position_y, position_z, orientation, rotation0, rotation1, rotation2, rotation3, spawntimesecs, animprogress, state) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(WORLD_INS_DISABLES, "INSERT INTO disables (entry, sourceType, flags, comment) VALUES (?, ?, ?, ?)", CONNECTION_ASYNC);
PrepareStatement(WORLD_SEL_DISABLES, "SELECT entry FROM disables WHERE entry = ? AND sourceType = ?", CONNECTION_SYNCH);
PrepareStatement(WORLD_DEL_DISABLES, "DELETE FROM disables WHERE entry = ? AND sourceType = ?", CONNECTION_ASYNC);
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index 10527cc2568..8ff968d697b 100644
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -424,7 +424,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) const
}
case CONDITION_SPAWNMASK:
{
- condMeets = ((1 << object->GetMap()->GetSpawnMode()) & ConditionValue1) != 0;
+ condMeets = ((UI64LIT(1) << object->GetMap()->GetSpawnMode()) & ConditionValue1) != 0;
break;
}
case CONDITION_UNIT_STATE:
@@ -2260,7 +2260,7 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) const
}
case CONDITION_SPAWNMASK:
{
- if (cond->ConditionValue1 > SPAWNMASK_RAID_ALL)
+ if (cond->ConditionValue1 >= (UI64LIT(1) << MAX_DIFFICULTY))
{
TC_LOG_ERROR("sql.sql", "%s has non existing SpawnMask in value1 (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
return false;
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 3f480de69f2..22ae6fa5e5e 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -854,8 +854,8 @@ bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 /*phaseMask*
ASSERT(map);
SetMap(map);
- if (data && data->phaseid)
- SetInPhase(data->phaseid, false, true);
+ if (data && data->phaseId)
+ SetInPhase(data->phaseId, false, true);
if (data && data->phaseGroup)
for (auto ph : sDB2Manager.GetPhasesForGroup(data->phaseGroup))
@@ -1062,10 +1062,10 @@ void Creature::SaveToDB()
}
uint32 mapId = GetTransport() ? GetTransport()->GetGOInfo()->moTransport.SpawnMap : GetMapId();
- SaveToDB(mapId, data->spawnMask, GetPhaseMask());
+ SaveToDB(mapId, data->spawnMask);
}
-void Creature::SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask)
+void Creature::SaveToDB(uint32 mapid, uint64 spawnMask)
{
// update in loaded data
if (!m_spawnId)
@@ -1107,7 +1107,6 @@ void Creature::SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask)
// data->guid = guid must not be updated at save
data.id = GetEntry();
data.mapid = mapid;
- data.phaseMask = phaseMask;
data.displayid = displayId;
data.equipmentId = GetCurrentEquipmentId();
if (!GetTransport())
@@ -1141,8 +1140,8 @@ void Creature::SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask)
data.unit_flags3 = unitFlags3;
data.dynamicflags = dynamicflags;
- data.phaseid = GetDBPhase() > 0 ? GetDBPhase() : 0;
- data.phaseGroup = GetDBPhase() < 0 ? abs(GetDBPhase()) : 0;
+ data.phaseId = GetDBPhase() > 0 ? GetDBPhase() : 0;
+ data.phaseGroup = GetDBPhase() < 0 ? std::abs(GetDBPhase()) : 0;
// update in DB
SQLTransaction trans = WorldDatabase.BeginTransaction();
@@ -1157,8 +1156,8 @@ void Creature::SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask)
stmt->setUInt64(index++, m_spawnId);
stmt->setUInt32(index++, GetEntry());
stmt->setUInt16(index++, uint16(mapid));
- stmt->setUInt32(index++, spawnMask);
- stmt->setUInt32(index++, data.phaseid);
+ stmt->setUInt64(index++, spawnMask);
+ stmt->setUInt32(index++, data.phaseId);
stmt->setUInt32(index++, data.phaseGroup);
stmt->setUInt32(index++, displayId);
stmt->setUInt8(index++, GetCurrentEquipmentId());
@@ -1414,7 +1413,7 @@ bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool ad
m_spawnId = spawnId;
m_creatureData = data;
- if (!Create(map->GenerateLowGuid<HighGuid::Creature>(), map, data->phaseMask, data->id, data->posX, data->posY, data->posZ, data->orientation, data))
+ if (!Create(map->GenerateLowGuid<HighGuid::Creature>(), map, PHASEMASK_NORMAL, data->id, data->posX, data->posY, data->posZ, data->orientation, data))
return false;
//We should set first home position, because then AI calls home movement
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index 0761914de23..0e5261293a4 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -179,7 +179,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
bool LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap = true, bool allowDuplicate = false);
void SaveToDB();
// overriden in Pet
- virtual void SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask);
+ virtual void SaveToDB(uint32 mapid, uint64 spawnMask);
virtual void DeleteFromDB(); // overriden in Pet
Loot loot;
diff --git a/src/server/game/Entities/Creature/CreatureData.h b/src/server/game/Entities/Creature/CreatureData.h
index b8923c6ac8a..b933f6cb399 100644
--- a/src/server/game/Entities/Creature/CreatureData.h
+++ b/src/server/game/Entities/Creature/CreatureData.h
@@ -496,14 +496,13 @@ struct EquipmentInfo
// from `creature` table
struct CreatureData
{
- CreatureData() : id(0), mapid(0), phaseMask(0), displayid(0), equipmentId(0),
+ CreatureData() : id(0), mapid(0), displayid(0), equipmentId(0),
posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), spawntimesecs(0),
spawndist(0.0f), currentwaypoint(0), curhealth(0), curmana(0), movementType(0),
spawnMask(0), npcflag(0), unit_flags(0), unit_flags2(0), unit_flags3(0), dynamicflags(0),
- phaseid(0), phaseGroup(0), ScriptId(0), dbData(true) { }
+ phaseId(0), phaseGroup(0), ScriptId(0), dbData(true) { }
uint32 id; // entry in creature_template
uint16 mapid;
- uint32 phaseMask;
uint32 displayid;
int8 equipmentId;
float posX;
@@ -516,13 +515,13 @@ struct CreatureData
uint32 curhealth;
uint32 curmana;
uint8 movementType;
- uint32 spawnMask;
+ uint64 spawnMask;
uint64 npcflag;
uint32 unit_flags; // enum UnitFlags mask values
uint32 unit_flags2; // enum UnitFlags2 mask values
uint32 unit_flags3; // enum UnitFlags3 mask values
uint32 dynamicflags;
- uint32 phaseid;
+ uint32 phaseId;
uint32 phaseGroup;
uint32 ScriptId;
bool dbData;
diff --git a/src/server/game/Entities/Creature/TemporarySummon.h b/src/server/game/Entities/Creature/TemporarySummon.h
index f9372789652..29067791364 100644
--- a/src/server/game/Entities/Creature/TemporarySummon.h
+++ b/src/server/game/Entities/Creature/TemporarySummon.h
@@ -35,7 +35,7 @@ class TC_GAME_API TempSummon : public Creature
virtual void UnSummon(uint32 msTime = 0);
void RemoveFromWorld() override;
void SetTempSummonType(TempSummonType type);
- void SaveToDB(uint32 /*mapid*/, uint32 /*spawnMask*/, uint32 /*phaseMask*/) override { }
+ void SaveToDB(uint32 /*mapid*/, uint64 /*spawnMask*/) override { }
Unit* GetSummoner() const;
Creature* GetSummonerCreatureBase() const;
ObjectGuid GetSummonerGUID() const { return m_summonerGUID; }
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index 33aded2266a..7c0a9216b85 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -876,10 +876,10 @@ void GameObject::SaveToDB()
return;
}
- SaveToDB(GetMapId(), data->spawnMask, data->phaseMask);
+ SaveToDB(GetMapId(), data->spawnMask);
}
-void GameObject::SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask)
+void GameObject::SaveToDB(uint32 mapid, uint64 spawnMask)
{
const GameObjectTemplate* goI = GetGOInfo();
@@ -895,7 +895,6 @@ void GameObject::SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask)
// data->guid = guid must not be updated at save
data.id = GetEntry();
data.mapid = mapid;
- data.phaseMask = phaseMask;
data.posX = GetPositionX();
data.posY = GetPositionY();
data.posZ = GetPositionZ();
@@ -907,6 +906,9 @@ void GameObject::SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask)
data.spawnMask = spawnMask;
data.artKit = GetGoArtKit();
+ data.phaseId = GetDBPhase() > 0 ? GetDBPhase() : 0;
+ data.phaseGroup = GetDBPhase() < 0 ? std::abs(GetDBPhase()) : 0;
+
// Update in DB
SQLTransaction trans = WorldDatabase.BeginTransaction();
@@ -920,7 +922,9 @@ void GameObject::SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask)
stmt->setUInt64(index++, m_spawnId);
stmt->setUInt32(index++, GetEntry());
stmt->setUInt16(index++, uint16(mapid));
- stmt->setUInt8(index++, spawnMask);
+ stmt->setUInt64(index++, spawnMask);
+ stmt->setUInt32(index++, data.phaseId);
+ stmt->setUInt32(index++, data.phaseGroup);
stmt->setFloat(index++, GetPositionX());
stmt->setFloat(index++, GetPositionY());
stmt->setFloat(index++, GetPositionZ());
@@ -948,7 +952,6 @@ bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, boo
uint32 entry = data->id;
//uint32 map_id = data->mapid; // already used before call
- uint32 phaseMask = data->phaseMask;
Position pos(data->posX, data->posY, data->posZ, data->orientation);
uint32 animprogress = data->animprogress;
@@ -956,11 +959,11 @@ bool GameObject::LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, boo
uint32 artKit = data->artKit;
m_spawnId = spawnId;
- if (!Create(entry, map, phaseMask, pos, data->rotation, animprogress, go_state, artKit))
+ if (!Create(entry, map, PHASEMASK_NORMAL, pos, data->rotation, animprogress, go_state, artKit))
return false;
- if (data->phaseid)
- SetInPhase(data->phaseid, false, true);
+ if (data->phaseId)
+ SetInPhase(data->phaseId, false, true);
if (data->phaseGroup)
{
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index 097475dd082..6822d5207cf 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -114,7 +114,7 @@ class TC_GAME_API GameObject : public WorldObject, public GridObject<GameObject>
std::string const& GetNameForLocaleIdx(LocaleConstant locale_idx) const override;
void SaveToDB();
- void SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask);
+ void SaveToDB(uint32 mapid, uint64 spawnMask);
bool LoadFromDB(ObjectGuid::LowType spawnId, Map* map) { return LoadGameObjectFromDB(spawnId, map, false); }
bool LoadGameObjectFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap = true);
void DeleteFromDB();
diff --git a/src/server/game/Entities/GameObject/GameObjectData.h b/src/server/game/Entities/GameObject/GameObjectData.h
index f674062f9d4..5dddb33aeee 100644
--- a/src/server/game/Entities/GameObject/GameObjectData.h
+++ b/src/server/game/Entities/GameObject/GameObjectData.h
@@ -854,11 +854,10 @@ struct GameObjectAddon
// from `gameobject`
struct GameObjectData
{
- explicit GameObjectData() : id(0), mapid(0), phaseMask(0), posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), spawntimesecs(0),
- animprogress(0), go_state(GO_STATE_ACTIVE), spawnMask(0), artKit(0), phaseid(0), phaseGroup(0), ScriptId(0), dbData(true) { }
+ explicit GameObjectData() : id(0), mapid(0), posX(0.0f), posY(0.0f), posZ(0.0f), orientation(0.0f), spawntimesecs(0),
+ animprogress(0), go_state(GO_STATE_ACTIVE), spawnMask(0), artKit(0), phaseId(0), phaseGroup(0), ScriptId(0), dbData(true) { }
uint32 id; // entry in gamobject_template
uint16 mapid;
- uint32 phaseMask;
float posX;
float posY;
float posZ;
@@ -867,9 +866,9 @@ struct GameObjectData
int32 spawntimesecs;
uint32 animprogress;
GOState go_state;
- uint32 spawnMask;
+ uint64 spawnMask;
uint8 artKit;
- uint32 phaseid;
+ uint32 phaseId;
uint32 phaseGroup;
uint32 ScriptId;
bool dbData;
diff --git a/src/server/game/Entities/Pet/Pet.h b/src/server/game/Entities/Pet/Pet.h
index 96acc8a9485..e6652501b86 100644
--- a/src/server/game/Entities/Pet/Pet.h
+++ b/src/server/game/Entities/Pet/Pet.h
@@ -160,7 +160,7 @@ class TC_GAME_API Pet : public Guardian
uint16 m_petSpecialization;
private:
- void SaveToDB(uint32, uint32, uint32) override // override of Creature::SaveToDB - must not be called
+ void SaveToDB(uint32, uint64) override // override of Creature::SaveToDB - must not be called
{
ABORT();
}
diff --git a/src/server/game/Entities/Transport/Transport.cpp b/src/server/game/Entities/Transport/Transport.cpp
index 93cf3482664..07db65f7620 100644
--- a/src/server/game/Entities/Transport/Transport.cpp
+++ b/src/server/game/Entities/Transport/Transport.cpp
@@ -329,8 +329,8 @@ Creature* Transport::CreateNPCPassenger(ObjectGuid::LowType guid, CreatureData c
return NULL;
}
- if (data->phaseid)
- creature->SetInPhase(data->phaseid, false, true);
+ if (data->phaseId)
+ creature->SetInPhase(data->phaseId, false, true);
else if (data->phaseGroup)
for (auto phase : sDB2Manager.GetPhasesForGroup(data->phaseGroup))
creature->SetInPhase(phase, false, true);
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index d2a97e2cd16..e17286abc18 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -1886,10 +1886,10 @@ void ObjectMgr::LoadCreatures()
}
// Build single time for check spawnmask
- std::map<uint32, uint32> spawnMasks;
+ std::map<uint32, uint64> spawnMasks;
for (auto& mapDifficultyPair : sDB2Manager.GetMapDifficulties())
for (auto& difficultyPair : mapDifficultyPair.second)
- spawnMasks[mapDifficultyPair.first] |= (1 << difficultyPair.first);
+ spawnMasks[mapDifficultyPair.first] |= UI64LIT(1) << difficultyPair.first;
_creatureDataStore.rehash(result->GetRowCount());
@@ -1923,7 +1923,7 @@ void ObjectMgr::LoadCreatures()
data.curhealth = fields[12].GetUInt32();
data.curmana = fields[13].GetUInt32();
data.movementType = fields[14].GetUInt8();
- data.spawnMask = fields[15].GetUInt32();
+ data.spawnMask = fields[15].GetUInt64();
int16 gameEvent = fields[16].GetInt8();
uint32 PoolId = fields[17].GetUInt32();
data.npcflag = fields[18].GetUInt64();
@@ -1931,7 +1931,7 @@ void ObjectMgr::LoadCreatures()
data.unit_flags2 = fields[20].GetUInt32();
data.unit_flags3 = fields[21].GetUInt32();
data.dynamicflags = fields[22].GetUInt32();
- data.phaseid = fields[23].GetUInt32();
+ data.phaseId = fields[23].GetUInt32();
data.phaseGroup = fields[24].GetUInt32();
data.ScriptId = GetScriptId(fields[25].GetString());
if (!data.ScriptId)
@@ -1962,7 +1962,7 @@ void ObjectMgr::LoadCreatures()
// Skip spawnMask check for transport maps
if (!IsTransportMap(data.mapid) && data.spawnMask & ~spawnMasks[data.mapid])
- 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);
+ TC_LOG_ERROR("sql.sql", "Table `creature` has creature (GUID: " UI64FMTD ") that have wrong spawn mask " UI64FMTD " including unsupported difficulty modes for map (Id: %u).", guid, data.spawnMask, data.mapid);
bool ok = true;
for (uint32 diff = 0; diff < MAX_CREATURE_DIFFICULTIES && ok; ++diff)
@@ -2021,20 +2021,18 @@ void ObjectMgr::LoadCreatures()
data.orientation = Position::NormalizeOrientation(data.orientation);
}
- data.phaseMask = 1;
-
- if (data.phaseGroup && data.phaseid)
+ if (data.phaseGroup && data.phaseId)
{
TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: " UI64FMTD " Entry: %u) with both `phaseid` and `phasegroup` set, `phasegroup` set to 0", guid, data.id);
data.phaseGroup = 0;
}
- if (data.phaseid)
+ if (data.phaseId)
{
- if (!sPhaseStore.LookupEntry(data.phaseid))
+ if (!sPhaseStore.LookupEntry(data.phaseId))
{
- TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: " UI64FMTD " Entry: %u) with `phaseid` %u does not exist, set to 0", guid, data.id, data.phaseid);
- data.phaseid = 0;
+ TC_LOG_ERROR("sql.sql", "Table `creature` have creature (GUID: " UI64FMTD " Entry: %u) with `phaseid` %u does not exist, set to 0", guid, data.id, data.phaseId);
+ data.phaseId = 0;
}
}
@@ -2073,7 +2071,7 @@ void ObjectMgr::LoadCreatures()
void ObjectMgr::AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const* data)
{
- uint32 mask = data->spawnMask;
+ uint64 mask = data->spawnMask;
for (uint8 i = 0; mask != 0; i++, mask >>= 1)
{
if (mask & 1)
@@ -2087,7 +2085,7 @@ void ObjectMgr::AddCreatureToGrid(ObjectGuid::LowType guid, CreatureData const*
void ObjectMgr::RemoveCreatureFromGrid(ObjectGuid::LowType guid, CreatureData const* data)
{
- uint32 mask = data->spawnMask;
+ uint64 mask = data->spawnMask;
for (uint8 i = 0; mask != 0; i++, mask >>= 1)
{
if (mask & 1)
@@ -2123,9 +2121,8 @@ ObjectGuid::LowType ObjectMgr::AddGOData(uint32 entry, uint32 mapId, float x, fl
data.rotation.w = rotation3;
data.spawntimesecs = spawntimedelay;
data.animprogress = 100;
- data.spawnMask = 1;
+ data.spawnMask = SPAWNMASK_CONTINENT;
data.go_state = GO_STATE_READY;
- data.phaseMask = PHASEMASK_NORMAL;
data.artKit = goinfo->type == GAMEOBJECT_TYPE_CONTROL_ZONE ? 21 : 0;
data.dbData = false;
@@ -2177,8 +2174,7 @@ ObjectGuid::LowType ObjectMgr::AddCreatureData(uint32 entry, uint32 mapId, float
data.curhealth = stats->GenerateHealth(cInfo);
data.curmana = stats->GenerateMana(cInfo);
data.movementType = cInfo->MovementType;
- data.spawnMask = 1;
- data.phaseMask = PHASEMASK_NORMAL;
+ data.spawnMask = SPAWNMASK_CONTINENT;
data.dbData = false;
data.npcflag = cInfo->npcflag;
data.unit_flags = cInfo->unit_flags;
@@ -2221,10 +2217,10 @@ void ObjectMgr::LoadGameobjects()
}
// build single time for check spawnmask
- std::map<uint32, uint32> spawnMasks;
+ std::map<uint32, uint64> spawnMasks;
for (auto& mapDifficultyPair : sDB2Manager.GetMapDifficulties())
for (auto& difficultyPair : mapDifficultyPair.second)
- spawnMasks[mapDifficultyPair.first] |= (1 << difficultyPair.first);
+ spawnMasks[mapDifficultyPair.first] |= UI64LIT(1) << difficultyPair.first;
_gameObjectDataStore.rehash(result->GetRowCount());
@@ -2317,28 +2313,28 @@ void ObjectMgr::LoadGameobjects()
}
data.go_state = GOState(go_state);
- data.spawnMask = fields[14].GetUInt32();
+ data.spawnMask = fields[14].GetUInt64();
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);
+ TC_LOG_ERROR("sql.sql", "Table `gameobject` has gameobject (GUID: " UI64FMTD " Entry: %u) that has wrong spawn mask " UI64FMTD " including unsupported difficulty modes for map (Id: %u), skip", guid, data.id, data.spawnMask, data.mapid);
int16 gameEvent = fields[15].GetInt8();
uint32 PoolId = fields[16].GetUInt32();
- data.phaseid = fields[17].GetUInt32();
+ data.phaseId = fields[17].GetUInt32();
data.phaseGroup = fields[18].GetUInt32();
- if (data.phaseGroup && data.phaseid)
+ if (data.phaseGroup && data.phaseId)
{
TC_LOG_ERROR("sql.sql", "Table `gameobject` have gameobject (GUID: " UI64FMTD " Entry: %u) with both `phaseid` and `phasegroup` set, `phasegroup` set to 0", guid, data.id);
data.phaseGroup = 0;
}
- if (data.phaseid)
+ if (data.phaseId)
{
- if (!sPhaseStore.LookupEntry(data.phaseid))
+ if (!sPhaseStore.LookupEntry(data.phaseId))
{
- TC_LOG_ERROR("sql.sql", "Table `gameobject` have gameobject (GUID: " UI64FMTD " Entry: %u) with `phaseid` %u does not exist, set to 0", guid, data.id, data.phaseid);
- data.phaseid = 0;
+ TC_LOG_ERROR("sql.sql", "Table `gameobject` have gameobject (GUID: " UI64FMTD " Entry: %u) with `phaseid` %u does not exist, set to 0", guid, data.id, data.phaseId);
+ data.phaseId = 0;
}
}
@@ -2391,8 +2387,6 @@ void ObjectMgr::LoadGameobjects()
continue;
}
- data.phaseMask = 1;
-
if (sWorld->getBoolConfig(CONFIG_CALCULATE_GAMEOBJECT_ZONE_AREA_DATA))
{
uint32 zoneId = 0;
@@ -2418,7 +2412,7 @@ void ObjectMgr::LoadGameobjects()
void ObjectMgr::AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData const* data)
{
- uint32 mask = data->spawnMask;
+ uint64 mask = data->spawnMask;
for (uint8 i = 0; mask != 0; i++, mask >>= 1)
{
if (mask & 1)
@@ -2432,7 +2426,7 @@ void ObjectMgr::AddGameobjectToGrid(ObjectGuid::LowType guid, GameObjectData con
void ObjectMgr::RemoveGameobjectFromGrid(ObjectGuid::LowType guid, GameObjectData const* data)
{
- uint32 mask = data->spawnMask;
+ uint64 mask = data->spawnMask;
for (uint8 i = 0; mask != 0; i++, mask >>= 1)
{
if (mask & 1)
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index 5646cac033a..417e8aeb7bd 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -1470,13 +1470,10 @@ public:
return false;
}
- if (target->GetTypeId() == TYPEID_UNIT)
- {
- if (target->ToCreature()->GetDBPhase() > 0)
- handler->PSendSysMessage("Target creature's PhaseId in DB: %d", target->ToCreature()->GetDBPhase());
- else if (target->ToCreature()->GetDBPhase() < 0)
- handler->PSendSysMessage("Target creature's PhaseGroup in DB: %d", abs(target->ToCreature()->GetDBPhase()));
- }
+ if (target->GetDBPhase() > 0)
+ handler->PSendSysMessage("Target creature's PhaseId in DB: %d", target->GetDBPhase());
+ else if (target->GetDBPhase() < 0)
+ handler->PSendSysMessage("Target creature's PhaseGroup in DB: %d", abs(target->GetDBPhase()));
std::stringstream phases;
diff --git a/src/server/scripts/Commands/cs_gobject.cpp b/src/server/scripts/Commands/cs_gobject.cpp
index 4c454ce37c2..c7611d7e3f4 100644
--- a/src/server/scripts/Commands/cs_gobject.cpp
+++ b/src/server/scripts/Commands/cs_gobject.cpp
@@ -159,7 +159,7 @@ public:
}
// fill the gameobject data and save to the db
- object->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), player->GetPhaseMask());
+ object->SaveToDB(map->GetId(), UI64LIT(1) << map->GetSpawnMode());
ObjectGuid::LowType spawnId = object->GetSpawnId();
// delete the old object and do a clean load from DB with a fresh new GameObject instance.
diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp
index b877ce90e91..719fd6a5992 100644
--- a/src/server/scripts/Commands/cs_npc.cpp
+++ b/src/server/scripts/Commands/cs_npc.cpp
@@ -296,15 +296,15 @@ public:
ObjectGuid::LowType guid = map->GenerateLowGuid<HighGuid::Creature>();
CreatureData& data = sObjectMgr->NewOrExistCreatureData(guid);
data.id = id;
- data.phaseMask = chr->GetPhaseMask();
data.posX = chr->GetTransOffsetX();
data.posY = chr->GetTransOffsetY();
data.posZ = chr->GetTransOffsetZ();
data.orientation = chr->GetTransOffsetO();
+ /// @todo: add phases
Creature* creature = trans->CreateNPCPassenger(guid, &data);
- creature->SaveToDB(trans->GetGOInfo()->moTransport.SpawnMap, 1 << map->GetSpawnMode(), chr->GetPhaseMask());
+ creature->SaveToDB(trans->GetGOInfo()->moTransport.SpawnMap, UI64LIT(1) << map->GetSpawnMode());
sObjectMgr->AddCreatureToGrid(guid, &data);
return true;
@@ -317,7 +317,8 @@ public:
return false;
}
- creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMask());
+ creature->CopyPhaseFrom(chr);
+ creature->SaveToDB(map->GetId(), UI64LIT(1) << map->GetSpawnMode());
ObjectGuid::LowType db_guid = creature->GetSpawnId();
@@ -769,7 +770,7 @@ public:
if (CreatureData const* data = sObjectMgr->GetCreatureData(target->GetSpawnId()))
{
- handler->PSendSysMessage(LANG_NPCINFO_PHASES, data->phaseid, data->phaseGroup);
+ handler->PSendSysMessage(LANG_NPCINFO_PHASES, data->phaseId, data->phaseGroup);
if (data->phaseGroup)
{
std::set<uint32> _phases = target->GetPhases();
diff --git a/src/server/scripts/Commands/cs_wp.cpp b/src/server/scripts/Commands/cs_wp.cpp
index e72437c9bd2..e58b15ece40 100644
--- a/src/server/scripts/Commands/cs_wp.cpp
+++ b/src/server/scripts/Commands/cs_wp.cpp
@@ -674,7 +674,7 @@ public:
}
wpCreature->CopyPhaseFrom(chr);
- wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMask());
+ wpCreature->SaveToDB(map->GetId(), UI64LIT(1) << map->GetSpawnMode());
// To call _LoadGoods(); _LoadQuests(); CreateTrainerSpells();
/// @todo Should we first use "Create" then use "LoadFromDB"?
if (!wpCreature->LoadCreatureFromDB(wpCreature->GetSpawnId(), map))
@@ -887,7 +887,7 @@ public:
}
wpCreature->CopyPhaseFrom(chr);
- wpCreature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMask());
+ wpCreature->SaveToDB(map->GetId(), UI64LIT(1) << map->GetSpawnMode());
// Set "wpguid" column to the visual waypoint
stmt = WorldDatabase.GetPreparedStatement(WORLD_UPD_WAYPOINT_DATA_WPGUID);
@@ -951,8 +951,8 @@ public:
}
creature->CopyPhaseFrom(chr);
+ creature->SaveToDB(map->GetId(), UI64LIT(1) << map->GetSpawnMode());
- creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMask());
if (!creature->LoadCreatureFromDB(creature->GetSpawnId(), map))
{
handler->PSendSysMessage(LANG_WAYPOINT_VP_NOTCREATED, id);
@@ -1002,8 +1002,8 @@ public:
}
creature->CopyPhaseFrom(chr);
+ creature->SaveToDB(map->GetId(), UI64LIT(1) << map->GetSpawnMode());
- creature->SaveToDB(map->GetId(), (1 << map->GetSpawnMode()), chr->GetPhaseMask());
if (!creature->LoadCreatureFromDB(creature->GetSpawnId(), map))
{
handler->PSendSysMessage(LANG_WAYPOINT_NOTCREATED, id);