mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-01 18:13:48 +00:00
Move area trigger storage from DBC to database (#742)
Renamed AreaTrigger + related stuff to AreaTriggerTeleport
This commit is contained in:
@@ -5551,7 +5551,7 @@ void ObjectMgr::LoadQuestAreaTriggers()
|
||||
uint32 trigger_ID = fields[0].GetUInt32();
|
||||
uint32 quest_ID = fields[1].GetUInt32();
|
||||
|
||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(trigger_ID);
|
||||
AreaTrigger const* atEntry = GetAreaTrigger(trigger_ID);
|
||||
if (!atEntry)
|
||||
{
|
||||
sLog->outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.", trigger_ID);
|
||||
@@ -5609,7 +5609,7 @@ void ObjectMgr::LoadTavernAreaTriggers()
|
||||
|
||||
uint32 Trigger_ID = fields[0].GetUInt32();
|
||||
|
||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);
|
||||
AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
|
||||
if (!atEntry)
|
||||
{
|
||||
sLog->outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
|
||||
@@ -5648,7 +5648,7 @@ void ObjectMgr::LoadAreaTriggerScripts()
|
||||
uint32 Trigger_ID = fields[0].GetUInt32();
|
||||
const char *scriptName = fields[1].GetCString();
|
||||
|
||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);
|
||||
AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
|
||||
if (!atEntry)
|
||||
{
|
||||
sLog->outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
|
||||
@@ -6048,11 +6048,62 @@ void ObjectMgr::RemoveGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, boo
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadAreaTriggers()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
_areaTriggerStore.clear();
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT entry, map, x, y, z, radius, length, width, height, orientation FROM areatrigger");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
sLog->outString(">> Loaded 0 area trigger definitions. DB table `areatrigger` is empty.");
|
||||
sLog->outString();
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 count = 0;
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
++count;
|
||||
|
||||
AreaTrigger at;
|
||||
|
||||
at.entry = fields[0].GetUInt32();
|
||||
at.map = fields[1].GetUInt32();
|
||||
at.x = fields[2].GetFloat();
|
||||
at.y = fields[3].GetFloat();
|
||||
at.z = fields[4].GetFloat();
|
||||
at.radius = fields[5].GetFloat();
|
||||
at.length = fields[6].GetFloat();
|
||||
at.width = fields[7].GetFloat();
|
||||
at.height = fields[8].GetFloat();
|
||||
at.orientation = fields[9].GetFloat();
|
||||
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(at.map);
|
||||
if (!mapEntry)
|
||||
{
|
||||
sLog->outErrorDb("Area trigger (ID:%u) map (ID: %u) does not exist in `Map.dbc`.", at.entry, at.map);
|
||||
continue;
|
||||
}
|
||||
|
||||
_areaTriggerStore[at.entry] = at;
|
||||
|
||||
} while (result->NextRow());
|
||||
|
||||
sLog->outString(">> Loaded %u area trigger definitions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
sLog->outString();
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadAreaTriggerTeleports()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
_areaTriggerStore.clear(); // need for reload case
|
||||
_areaTriggerTeleportStore.clear(); // need for reload case
|
||||
|
||||
// 0 1 2 3 4 5
|
||||
QueryResult result = WorldDatabase.Query("SELECT ID, target_map, target_position_x, target_position_y, target_position_z, target_orientation FROM areatrigger_teleport");
|
||||
@@ -6074,7 +6125,7 @@ void ObjectMgr::LoadAreaTriggerTeleports()
|
||||
|
||||
uint32 Trigger_ID = fields[0].GetUInt32();
|
||||
|
||||
AreaTrigger at;
|
||||
AreaTriggerTeleport at;
|
||||
|
||||
at.target_mapId = fields[1].GetUInt16();
|
||||
at.target_X = fields[2].GetFloat();
|
||||
@@ -6082,7 +6133,7 @@ void ObjectMgr::LoadAreaTriggerTeleports()
|
||||
at.target_Z = fields[4].GetFloat();
|
||||
at.target_Orientation = fields[5].GetFloat();
|
||||
|
||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(Trigger_ID);
|
||||
AreaTrigger const* atEntry = GetAreaTrigger(Trigger_ID);
|
||||
if (!atEntry)
|
||||
{
|
||||
sLog->outErrorDb("Area trigger (ID:%u) does not exist in `AreaTrigger.dbc`.", Trigger_ID);
|
||||
@@ -6102,7 +6153,7 @@ void ObjectMgr::LoadAreaTriggerTeleports()
|
||||
continue;
|
||||
}
|
||||
|
||||
_areaTriggerStore[Trigger_ID] = at;
|
||||
_areaTriggerTeleportStore[Trigger_ID] = at;
|
||||
|
||||
} while (result->NextRow());
|
||||
|
||||
@@ -6212,7 +6263,7 @@ void ObjectMgr::LoadAccessRequirements()
|
||||
/*
|
||||
* Searches for the areatrigger which teleports players out of the given map with instance_template.parent field support
|
||||
*/
|
||||
AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 Map) const
|
||||
AreaTriggerTeleport const* ObjectMgr::GetGoBackTrigger(uint32 Map) const
|
||||
{
|
||||
bool useParentDbValue = false;
|
||||
uint32 parentId = 0;
|
||||
@@ -6232,11 +6283,11 @@ AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 Map) const
|
||||
}
|
||||
|
||||
uint32 entrance_map = uint32(mapEntry->entrance_map);
|
||||
for (AreaTriggerContainer::const_iterator itr = _areaTriggerStore.begin(); itr != _areaTriggerStore.end(); ++itr)
|
||||
for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
|
||||
if ((!useParentDbValue && itr->second.target_mapId == entrance_map) || (useParentDbValue && itr->second.target_mapId == parentId))
|
||||
{
|
||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(itr->first);
|
||||
if (atEntry && atEntry->mapid == Map)
|
||||
AreaTrigger const* atEntry = GetAreaTrigger(itr->first);
|
||||
if (atEntry && atEntry->map == Map)
|
||||
return &itr->second;
|
||||
}
|
||||
return NULL;
|
||||
@@ -6245,9 +6296,9 @@ AreaTrigger const* ObjectMgr::GetGoBackTrigger(uint32 Map) const
|
||||
/**
|
||||
* Searches for the areatrigger which teleports players to the given map
|
||||
*/
|
||||
AreaTrigger const* ObjectMgr::GetMapEntranceTrigger(uint32 Map) const
|
||||
AreaTriggerTeleport const* ObjectMgr::GetMapEntranceTrigger(uint32 Map) const
|
||||
{
|
||||
for (AreaTriggerContainer::const_iterator itr = _areaTriggerStore.begin(); itr != _areaTriggerStore.end(); ++itr)
|
||||
for (AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.begin(); itr != _areaTriggerTeleportStore.end(); ++itr)
|
||||
{
|
||||
if (itr->second.target_mapId == Map) // Id is used to determine correct Scarlet Monastery instance
|
||||
{
|
||||
|
||||
@@ -389,7 +389,7 @@ struct SpellClickInfo
|
||||
typedef std::multimap<uint32, SpellClickInfo> SpellClickInfoContainer;
|
||||
typedef std::pair<SpellClickInfoContainer::const_iterator, SpellClickInfoContainer::const_iterator> SpellClickInfoMapBounds;
|
||||
|
||||
struct AreaTrigger
|
||||
struct AreaTriggerTeleport
|
||||
{
|
||||
uint32 target_mapId;
|
||||
float target_X;
|
||||
@@ -398,6 +398,20 @@ struct AreaTrigger
|
||||
float target_Orientation;
|
||||
};
|
||||
|
||||
struct AreaTrigger
|
||||
{
|
||||
uint32 entry;
|
||||
uint32 map;
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
float radius;
|
||||
float length;
|
||||
float width;
|
||||
float height;
|
||||
float orientation;
|
||||
};
|
||||
|
||||
struct BroadcastText
|
||||
{
|
||||
BroadcastText() : Id(0), Language(0), EmoteId0(0), EmoteId1(0), EmoteId2(0),
|
||||
@@ -685,6 +699,8 @@ class ObjectMgr
|
||||
|
||||
typedef UNORDERED_MAP<uint32, AreaTrigger> AreaTriggerContainer;
|
||||
|
||||
typedef UNORDERED_MAP<uint32, AreaTriggerTeleport> AreaTriggerTeleportContainer;
|
||||
|
||||
typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptContainer;
|
||||
|
||||
typedef UNORDERED_MAP<uint32, AccessRequirement*> AccessRequirementContainer;
|
||||
@@ -812,6 +828,14 @@ class ObjectMgr
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AreaTriggerTeleport const* GetAreaTriggerTeleport(uint32 trigger) const
|
||||
{
|
||||
AreaTriggerTeleportContainer::const_iterator itr = _areaTriggerTeleportStore.find(trigger);
|
||||
if (itr != _areaTriggerTeleportStore.end())
|
||||
return &itr->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AccessRequirement const* GetAccessRequirement(uint32 mapid, Difficulty difficulty) const
|
||||
{
|
||||
AccessRequirementContainer::const_iterator itr = _accessRequirementStore.find(MAKE_PAIR32(mapid, difficulty));
|
||||
@@ -820,8 +844,8 @@ class ObjectMgr
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AreaTrigger const* GetGoBackTrigger(uint32 Map) const;
|
||||
AreaTrigger const* GetMapEntranceTrigger(uint32 Map) const;
|
||||
AreaTriggerTeleport const* GetGoBackTrigger(uint32 Map) const;
|
||||
AreaTriggerTeleport const* GetMapEntranceTrigger(uint32 Map) const;
|
||||
|
||||
uint32 GetAreaTriggerScriptId(uint32 trigger_id);
|
||||
SpellScriptsBounds GetSpellScriptsBounds(uint32 spell_id);
|
||||
@@ -984,6 +1008,7 @@ class ObjectMgr
|
||||
|
||||
void LoadGossipText();
|
||||
|
||||
void LoadAreaTriggers();
|
||||
void LoadAreaTriggerTeleports();
|
||||
void LoadAccessRequirements();
|
||||
void LoadQuestAreaTriggers();
|
||||
@@ -1333,6 +1358,7 @@ class ObjectMgr
|
||||
TavernAreaTriggerContainer _tavernAreaTriggerStore;
|
||||
GossipTextContainer _gossipTextStore;
|
||||
AreaTriggerContainer _areaTriggerStore;
|
||||
AreaTriggerTeleportContainer _areaTriggerTeleportStore;
|
||||
AreaTriggerScriptContainer _areaTriggerScriptStore;
|
||||
AccessRequirementContainer _accessRequirementStore;
|
||||
DungeonEncounterContainer _dungeonEncounterStore;
|
||||
|
||||
Reference in New Issue
Block a user