aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp7
-rw-r--r--src/server/game/Entities/Creature/CreatureData.h2
-rw-r--r--src/server/game/Events/GameEventMgr.cpp12
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp8
4 files changed, 19 insertions, 10 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 304f3d2df8d..884d48f6f7e 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -1439,7 +1439,7 @@ void Creature::SaveToDB(uint32 mapid, std::vector<Difficulty> const& spawnDiffic
CreatureTemplate const* cinfo = GetCreatureTemplate();
if (cinfo)
{
- for (CreatureModel model : cinfo->Models)
+ for (CreatureModel const& model : cinfo->Models)
if (displayId && displayId == model.CreatureDisplayID)
displayId = 0;
@@ -1460,7 +1460,10 @@ void Creature::SaveToDB(uint32 mapid, std::vector<Difficulty> const& spawnDiffic
data.spawnId = m_spawnId;
ASSERT(data.spawnId == m_spawnId);
data.id = GetEntry();
- data.displayid = displayId;
+ if (displayId)
+ data.display.emplace(displayId, DEFAULT_PLAYER_DISPLAY_SCALE, 1.0f);
+ else
+ data.display.reset();
data.equipmentId = GetCurrentEquipmentId();
if (!GetTransport())
{
diff --git a/src/server/game/Entities/Creature/CreatureData.h b/src/server/game/Entities/Creature/CreatureData.h
index 949c4ab3fa7..31961aa04c9 100644
--- a/src/server/game/Entities/Creature/CreatureData.h
+++ b/src/server/game/Entities/Creature/CreatureData.h
@@ -613,7 +613,7 @@ struct EquipmentInfo
struct CreatureData : public SpawnData
{
CreatureData() : SpawnData(SPAWN_TYPE_CREATURE) { }
- uint32 displayid = 0;
+ Optional<CreatureModel> display;
int8 equipmentId = 0;
float wander_distance = 0.0f;
uint32 currentwaypoint = 0;
diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp
index 59ce82d1b3c..12781909151 100644
--- a/src/server/game/Events/GameEventMgr.cpp
+++ b/src/server/game/Events/GameEventMgr.cpp
@@ -1364,14 +1364,20 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
CreatureData& data2 = sObjectMgr->NewOrExistCreatureData(itr->first);
if (activate)
{
- itr->second.modelid_prev = data2.displayid;
+ itr->second.modelid_prev = data2.display ? data2.display->CreatureDisplayID : 0;
itr->second.equipement_id_prev = data2.equipmentId;
- data2.displayid = itr->second.modelid;
+ if (itr->second.modelid)
+ data2.display.emplace(itr->second.modelid, DEFAULT_PLAYER_DISPLAY_SCALE, 1.0f);
+ else
+ data2.display.reset();
data2.equipmentId = itr->second.equipment_id;
}
else
{
- data2.displayid = itr->second.modelid_prev;
+ if (itr->second.modelid_prev)
+ data2.display.emplace(itr->second.modelid_prev, DEFAULT_PLAYER_DISPLAY_SCALE, 1.0f);
+ else
+ data2.display.reset();
data2.equipmentId = itr->second.equipement_id_prev;
}
}
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index 4aa8e3b7304..5dc45d50536 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -1627,9 +1627,8 @@ CreatureSummonedData const* ObjectMgr::GetCreatureSummonedData(uint32 entryId) c
CreatureModel const* ObjectMgr::ChooseDisplayId(CreatureTemplate const* cinfo, CreatureData const* data /*= nullptr*/)
{
// Load creature model (display id)
- if (data && data->displayid)
- if (CreatureModel const* model = cinfo->GetModelWithDisplayId(data->displayid))
- return model;
+ if (data && data->display)
+ return &*data->display;
if (!(cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER))
if (CreatureModel const* model = cinfo->GetRandomValidModel())
@@ -2171,7 +2170,8 @@ void ObjectMgr::LoadCreatures()
data.id = entry;
data.mapId = fields[2].GetUInt16();
data.spawnPoint.Relocate(fields[3].GetFloat(), fields[4].GetFloat(), fields[5].GetFloat(), fields[6].GetFloat());
- data.displayid = fields[7].GetUInt32();
+ if (uint32 displayId = fields[7].GetUInt32())
+ data.display.emplace(displayId, DEFAULT_PLAYER_DISPLAY_SCALE, 1.0f);
data.equipmentId = fields[8].GetInt8();
data.spawntimesecs = fields[9].GetUInt32();
data.wander_distance = fields[10].GetFloat();