mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-14 16:03:45 +00:00
refactor(Core/GameObject): Move the GameObject state save handling to… (#18080)
* refactor(Core/GameObject): Move the GameObject state save handling to instance level * Update GameObject.h * remove leftover * small improvements
This commit is contained in:
@@ -740,6 +740,26 @@ void InstanceScript::SendEncounterUnit(uint32 type, Unit* unit /*= nullptr*/, ui
|
||||
instance->SendToPlayers(&data);
|
||||
}
|
||||
|
||||
void InstanceScript::LoadInstanceSavedGameobjectStateData()
|
||||
{
|
||||
_objectStateMap.clear();
|
||||
|
||||
CharacterDatabasePreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SELECT_INSTANCE_SAVED_DATA);
|
||||
stmt->SetData(0, instance->GetInstanceId());
|
||||
|
||||
if (PreparedQueryResult result = CharacterDatabase.Query(stmt))
|
||||
{
|
||||
Field* fields;
|
||||
|
||||
do
|
||||
{
|
||||
fields = result->Fetch();
|
||||
StoreGameObjectState(fields[0].Get<uint32>(), fields[1].Get<uint8>());
|
||||
|
||||
} while (result->NextRow());
|
||||
}
|
||||
}
|
||||
|
||||
std::string InstanceScript::GetBossStateName(uint8 state)
|
||||
{
|
||||
// See enum EncounterState in InstanceScript.h
|
||||
@@ -762,6 +782,18 @@ std::string InstanceScript::GetBossStateName(uint8 state)
|
||||
}
|
||||
}
|
||||
|
||||
uint8 InstanceScript::GetStoredGameObjectState(ObjectGuid::LowType spawnId) const
|
||||
{
|
||||
auto i = _objectStateMap.find(spawnId);
|
||||
|
||||
if (i != _objectStateMap.end())
|
||||
{
|
||||
return i->second;
|
||||
}
|
||||
|
||||
return 3; // Any state higher than 2 to get the default state for the object we are loading.
|
||||
}
|
||||
|
||||
bool InstanceHasScript(WorldObject const* obj, char const* scriptName)
|
||||
{
|
||||
if (InstanceMap* instance = obj->GetMap()->ToInstanceMap())
|
||||
|
||||
Reference in New Issue
Block a user