Permalink
Browse files

Core/Entities: Extended SpawnMask to 64 bit

  • Loading branch information...
joschiwald committed Jan 6, 2018
1 parent 769db08 commit 5e3e4182c892413d02efc78af9f231dcb1a05c79
@@ -0,0 +1,5 @@
ALTER TABLE `creature`
CHANGE `spawnMask` `spawnMask` BIGINT(20) UNSIGNED DEFAULT 1 NOT NULL;
ALTER TABLE `gameobject`
CHANGE `spawnMask` `spawnMask` BIGINT(20) UNSIGNED DEFAULT 1 NOT NULL;
@@ -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);
@@ -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;
@@ -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
@@ -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;
@@ -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;
@@ -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; }
@@ -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,19 +952,18 @@ 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;
GOState go_state = data->go_state;
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)
{
@@ -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();
@@ -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;
@@ -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();
}
@@ -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);
Oops, something went wrong.

0 comments on commit 5e3e418

Please sign in to comment.