fix(Core/Creature): Remove automated z spawn correction (#18200)

* fix(Core/Creature): Remove automated z spawn correction

* comment out unused parameter

* remove gridLoad parameter from Creature::LoadCreatureFromDB()
This commit is contained in:
sudlud
2024-01-21 11:33:00 +01:00
committed by GitHub
parent a7e098af0c
commit e447351b0f
7 changed files with 10 additions and 21 deletions

View File

@@ -1627,7 +1627,7 @@ bool Creature::isVendorWithIconSpeak() const
return m_creatureInfo->IconName == "Speak" && m_creatureData->npcflag & UNIT_NPC_FLAG_VENDOR;
}
bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap, bool gridLoad, bool allowDuplicate /*= false*/)
bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool addToMap, bool allowDuplicate /*= false*/)
{
if (!allowDuplicate)
{
@@ -1666,16 +1666,6 @@ bool Creature::LoadCreatureFromDB(ObjectGuid::LowType spawnId, Map* map, bool ad
return false;
}
// xinef: fix from db
if ((addToMap || gridLoad) && !data->overwrittenZ)
{
float tz = map->GetHeight(data->posX, data->posY, data->posZ + 0.42f, true);
if (tz >= data->posZ && tz - data->posZ <= 0.42f)
const_cast<CreatureData*>(data)->posZ = tz + 0.1f;
const_cast<CreatureData*>(data)->overwrittenZ = true;
}
// xinef: this has to be assigned before Create function, properly loads equipment id from DB
m_creatureData = data;
m_spawnId = spawnId;

View File

@@ -210,8 +210,8 @@ public:
void setDeathState(DeathState s, bool despawn = false) override; // override virtual Unit::setDeathState
bool LoadFromDB(ObjectGuid::LowType guid, Map* map, bool allowDuplicate = false) { return LoadCreatureFromDB(guid, map, false, true, allowDuplicate); }
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map* map, bool addToMap = true, bool gridLoad = false, bool allowDuplicate = false);
bool LoadFromDB(ObjectGuid::LowType guid, Map* map, bool allowDuplicate = false) { return LoadCreatureFromDB(guid, map, false, allowDuplicate); }
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map* map, bool addToMap = true, bool allowDuplicate = false);
void SaveToDB();
// overriden in Pet
virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);

View File

@@ -381,7 +381,6 @@ struct CreatureData
uint32 dynamicflags{0};
uint32 ScriptId;
bool dbData{true};
bool overwrittenZ{false};
};
struct CreatureModelInfo

View File

@@ -2466,7 +2466,7 @@ uint32 ObjectMgr::AddCreData(uint32 entry, uint32 mapId, float x, float y, float
if (!map->Instanceable() && !map->IsRemovalGrid(x, y))
{
Creature* creature = new Creature();
if (!creature->LoadCreatureFromDB(spawnId, map, true, false, true))
if (!creature->LoadCreatureFromDB(spawnId, map, true, true))
{
LOG_ERROR("sql.sql", "AddCreature: Cannot add creature entry {} to map", entry);
delete creature;