Move area trigger storage from DBC to database (#742)
Renamed AreaTrigger + related stuff to AreaTriggerTeleport
This commit is contained in:
@@ -1174,17 +1174,17 @@ class SmartTrigger : public AreaTriggerScript
|
||||
|
||||
SmartTrigger() : AreaTriggerScript("SmartTrigger") {}
|
||||
|
||||
bool OnTrigger(Player* player, AreaTriggerEntry const* trigger)
|
||||
bool OnTrigger(Player* player, AreaTrigger const* trigger)
|
||||
{
|
||||
if (!player->IsAlive())
|
||||
return false;
|
||||
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "AreaTrigger %u is using SmartTrigger script", trigger->id);
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "AreaTrigger %u is using SmartTrigger script", trigger->entry);
|
||||
#endif
|
||||
SmartScript script;
|
||||
script.OnInitialize(NULL, trigger);
|
||||
script.ProcessEventsFor(SMART_EVENT_AREATRIGGER_ONTRIGGER, player, trigger->id);
|
||||
script.ProcessEventsFor(SMART_EVENT_AREATRIGGER_ONTRIGGER, player, trigger->entry);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -4096,7 +4096,7 @@ void SmartScript::OnUpdate(uint32 const diff)
|
||||
}
|
||||
}
|
||||
|
||||
void SmartScript::FillScript(SmartAIEventList e, WorldObject* obj, AreaTriggerEntry const* at)
|
||||
void SmartScript::FillScript(SmartAIEventList e, WorldObject* obj, AreaTrigger const* at)
|
||||
{
|
||||
if (e.empty())
|
||||
{
|
||||
@@ -4105,7 +4105,7 @@ void SmartScript::FillScript(SmartAIEventList e, WorldObject* obj, AreaTriggerEn
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript: EventMap for Entry %u is empty but is using SmartScript.", obj->GetEntry());
|
||||
|
||||
if (at)
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript: EventMap for AreaTrigger %u is empty but is using SmartScript.", at->id);
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript: EventMap for AreaTrigger %u is empty but is using SmartScript.", at->entry);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@@ -4132,7 +4132,7 @@ void SmartScript::FillScript(SmartAIEventList e, WorldObject* obj, AreaTriggerEn
|
||||
if (mEvents.empty() && obj)
|
||||
sLog->outErrorDb("SmartScript: Entry %u has events but no events added to list because of instance flags.", obj->GetEntry());
|
||||
if (mEvents.empty() && at)
|
||||
sLog->outErrorDb("SmartScript: AreaTrigger %u has events but no events added to list because of instance flags. NOTE: triggers can not handle any instance flags.", at->id);
|
||||
sLog->outErrorDb("SmartScript: AreaTrigger %u has events but no events added to list because of instance flags. NOTE: triggers can not handle any instance flags.", at->entry);
|
||||
}
|
||||
|
||||
void SmartScript::GetScript()
|
||||
@@ -4154,12 +4154,12 @@ void SmartScript::GetScript()
|
||||
}
|
||||
else if (trigger)
|
||||
{
|
||||
e = sSmartScriptMgr->GetScript((int32)trigger->id, mScriptType);
|
||||
e = sSmartScriptMgr->GetScript((int32)trigger->entry, mScriptType);
|
||||
FillScript(e, NULL, trigger);
|
||||
}
|
||||
}
|
||||
|
||||
void SmartScript::OnInitialize(WorldObject* obj, AreaTriggerEntry const* at)
|
||||
void SmartScript::OnInitialize(WorldObject* obj, AreaTrigger const* at)
|
||||
{
|
||||
if (obj)//handle object based scripts
|
||||
{
|
||||
@@ -4189,7 +4189,7 @@ void SmartScript::OnInitialize(WorldObject* obj, AreaTriggerEntry const* at)
|
||||
mScriptType = SMART_SCRIPT_TYPE_AREATRIGGER;
|
||||
trigger = at;
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::OnInitialize: source is AreaTrigger %u", trigger->id);
|
||||
sLog->outDebug(LOG_FILTER_DATABASE_AI, "SmartScript::OnInitialize: source is AreaTrigger %u", trigger->entry);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
|
||||
@@ -23,9 +23,9 @@ class SmartScript
|
||||
SmartScript();
|
||||
~SmartScript();
|
||||
|
||||
void OnInitialize(WorldObject* obj, AreaTriggerEntry const* at = NULL);
|
||||
void OnInitialize(WorldObject* obj, AreaTrigger const* at = NULL);
|
||||
void GetScript();
|
||||
void FillScript(SmartAIEventList e, WorldObject* obj, AreaTriggerEntry const* at);
|
||||
void FillScript(SmartAIEventList e, WorldObject* obj, AreaTrigger const* at);
|
||||
|
||||
void ProcessEventsFor(SMART_EVENT e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
|
||||
void ProcessEvent(SmartScriptHolder& e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
|
||||
@@ -267,7 +267,7 @@ class SmartScript
|
||||
uint64 meOrigGUID;
|
||||
GameObject* go;
|
||||
uint64 goOrigGUID;
|
||||
AreaTriggerEntry const* trigger;
|
||||
AreaTrigger const* trigger;
|
||||
SmartScriptType mScriptType;
|
||||
uint32 mEventPhase;
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ void SmartAIMgr::LoadSmartAIFromDB()
|
||||
}
|
||||
case SMART_SCRIPT_TYPE_AREATRIGGER:
|
||||
{
|
||||
if (!sAreaTriggerStore.LookupEntry((uint32)temp.entryOrGuid))
|
||||
if (!sObjectMgr->GetAreaTrigger((uint32)temp.entryOrGuid))
|
||||
{
|
||||
sLog->outErrorDb("SmartAIMgr::LoadSmartAIFromDB: AreaTrigger entry (%u) does not exist, skipped loading.", uint32(temp.entryOrGuid));
|
||||
continue;
|
||||
|
||||
@@ -1761,7 +1761,7 @@ class SmartAIMgr
|
||||
|
||||
bool IsAreaTriggerValid(SmartScriptHolder const& e, uint32 entry)
|
||||
{
|
||||
if (!sAreaTriggerStore.LookupEntry(entry))
|
||||
if (!sObjectMgr->GetAreaTrigger(entry))
|
||||
{
|
||||
sLog->outErrorDb("SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent AreaTrigger entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), entry);
|
||||
return false;
|
||||
|
||||
@@ -303,7 +303,7 @@ bool BattlegroundEY::SetupBattleground()
|
||||
|
||||
for (uint8 i = 0; i < EY_POINTS_MAX; ++i)
|
||||
{
|
||||
AreaTriggerEntry const* at = sAreaTriggerStore.LookupEntry(_capturePointInfo[i]._areaTrigger);
|
||||
AreaTrigger const* at = sObjectMgr->GetAreaTrigger(_capturePointInfo[i]._areaTrigger);
|
||||
AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3 + 0, Buff_Entries[0], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY);
|
||||
AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3 + 1, Buff_Entries[1], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY);
|
||||
AddObject(BG_EY_OBJECT_SPEEDBUFF_FEL_REAVER + i * 3 + 2, Buff_Entries[2], at->x, at->y, at->z, 0.907571f, 0, 0, 0.438371f, 0.898794f, RESPAWN_ONE_DAY);
|
||||
|
||||
@@ -47,7 +47,6 @@ static WMOAreaInfoByTripple sWMOAreaInfoByTripple;
|
||||
DBCStorage <AchievementEntry> sAchievementStore(Achievementfmt);
|
||||
DBCStorage <AchievementCategoryEntry> sAchievementCategoryStore(AchievementCategoryfmt);
|
||||
DBCStorage <AchievementCriteriaEntry> sAchievementCriteriaStore(AchievementCriteriafmt);
|
||||
DBCStorage <AreaTriggerEntry> sAreaTriggerStore(AreaTriggerEntryfmt);
|
||||
DBCStorage <AuctionHouseEntry> sAuctionHouseStore(AuctionHouseEntryfmt);
|
||||
DBCStorage <BankBagSlotPricesEntry> sBankBagSlotPricesStore(BankBagSlotPricesEntryfmt);
|
||||
DBCStorage <BattlemasterListEntry> sBattlemasterListStore(BattlemasterListEntryfmt);
|
||||
@@ -258,7 +257,6 @@ void LoadDBCStores(const std::string& dataPath)
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sAchievementStore, dbcPath, "Achievement.dbc", &CustomAchievementfmt, &CustomAchievementIndex);
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sAchievementCategoryStore, dbcPath, "Achievement_Category.dbc");
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sAchievementCriteriaStore, dbcPath, "Achievement_Criteria.dbc");
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sAreaTriggerStore, dbcPath, "AreaTrigger.dbc");
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sAreaGroupStore, dbcPath, "AreaGroup.dbc");
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sAreaPOIStore, dbcPath, "AreaPOI.dbc");
|
||||
LoadDBC(availableDbcLocales, bad_dbc_files, sAuctionHouseStore, dbcPath, "AuctionHouse.dbc");
|
||||
|
||||
@@ -57,7 +57,6 @@ extern DBCStorage <AchievementCategoryEntry> sAchievementCategoryStore;
|
||||
extern DBCStorage <AreaTableEntry> sAreaTableStore;
|
||||
extern DBCStorage <AreaGroupEntry> sAreaGroupStore;
|
||||
extern DBCStorage <AreaPOIEntry> sAreaPOIStore;
|
||||
extern DBCStorage <AreaTriggerEntry> sAreaTriggerStore;
|
||||
extern DBCStorage <AuctionHouseEntry> sAuctionHouseStore;
|
||||
extern DBCStorage <BankBagSlotPricesEntry> sBankBagSlotPricesStore;
|
||||
extern DBCStorage <BarberShopStyleEntry> sBarberShopStyleStore;
|
||||
|
||||
@@ -561,20 +561,6 @@ struct AreaPOIEntry
|
||||
//uint32 val2; //53
|
||||
};
|
||||
|
||||
struct AreaTriggerEntry
|
||||
{
|
||||
uint32 id; // 0 m_ID
|
||||
uint32 mapid; // 1 m_ContinentID
|
||||
float x; // 2 m_x
|
||||
float y; // 3 m_y
|
||||
float z; // 4 m_z
|
||||
float radius; // 5 m_radius
|
||||
float box_x; // 6 m_box_length
|
||||
float box_y; // 7 m_box_width
|
||||
float box_z; // 8 m_box_heigh
|
||||
float box_orientation; // 9 m_box_yaw
|
||||
};
|
||||
|
||||
struct AuctionHouseEntry
|
||||
{
|
||||
uint32 houseId; // 0 index
|
||||
|
||||
@@ -15,15 +15,13 @@ char const AchievementCriteriafmt[] = "niiiiiiiixxxxxxxxxxxxxxxxxiiiix";
|
||||
char const AreaTableEntryfmt[] = "niiiixxxxxissssssssssssssssxiiiiixxx";
|
||||
char const AreaGroupEntryfmt[] = "niiiiiii";
|
||||
char const AreaPOIEntryfmt[] = "niiiiiiiiiiifffixixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxix";
|
||||
char const AreaTriggerEntryfmt[] = "niffffffff";
|
||||
char const AuctionHouseEntryfmt[] = "niiixxxxxxxxxxxxxxxxx";
|
||||
char const BankBagSlotPricesEntryfmt[] = "ni";
|
||||
char const BarberShopStyleEntryfmt[] = "nixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiii";
|
||||
char const BattlemasterListEntryfmt[] = "niiiiiiiiixssssssssssssssssxiixx";
|
||||
char const CharStartOutfitEntryfmt[] = "dbbbXiiiiiiiiiiiiiiiiiiiiiiiixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
|
||||
char const CharTitlesEntryfmt[] = "nxssssssssssssssssxssssssssssssssssxi";
|
||||
char const ChatChannelsEntryfmt[] = "nixssssssssssssssssxxxxxxxxxxxxxxxxxx";
|
||||
// ChatChannelsEntryfmt, index not used (more compact store)
|
||||
char const ChatChannelsEntryfmt[] = "nixssssssssssssssssxxxxxxxxxxxxxxxxxx"; // ChatChannelsEntryfmt, index not used (more compact store)
|
||||
char const ChrClassesEntryfmt[] = "nxixxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxixii";
|
||||
char const ChrRacesEntryfmt[] = "nxixiixixxxxixssssssssssssssssxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxi";
|
||||
char const CinematicSequencesEntryfmt[] = "nxxxxxxxxx";
|
||||
|
||||
@@ -224,7 +224,7 @@ void LFGMgr::LoadLFGDungeons(bool reload /* = false */)
|
||||
// No teleport coords in database, load from areatriggers
|
||||
if (dungeon.type != LFG_TYPE_RANDOM && dungeon.x == 0.0f && dungeon.y == 0.0f && dungeon.z == 0.0f)
|
||||
{
|
||||
AreaTrigger const* at = sObjectMgr->GetMapEntranceTrigger(dungeon.map);
|
||||
AreaTriggerTeleport const* at = sObjectMgr->GetMapEntranceTrigger(dungeon.map);
|
||||
if (!at)
|
||||
{
|
||||
sLog->outError("LFGMgr::LoadLFGDungeons: Failed to load dungeon %s, cant find areatrigger for map %u", dungeon.name.c_str(), dungeon.map);
|
||||
|
||||
@@ -2978,9 +2978,9 @@ void Player::SetInWater(bool apply)
|
||||
getHostileRefManager().updateThreatTables();
|
||||
}
|
||||
|
||||
bool Player::IsInAreaTriggerRadius(const AreaTriggerEntry* trigger) const
|
||||
bool Player::IsInAreaTriggerRadius(const AreaTrigger* trigger) const
|
||||
{
|
||||
if (!trigger || GetMapId() != trigger->mapid)
|
||||
if (!trigger || GetMapId() != trigger->map)
|
||||
return false;
|
||||
|
||||
if (trigger->radius > 0.f)
|
||||
@@ -2992,8 +2992,8 @@ bool Player::IsInAreaTriggerRadius(const AreaTriggerEntry* trigger) const
|
||||
}
|
||||
else
|
||||
{
|
||||
Position center = {trigger->x, trigger->y, trigger->z, trigger->box_orientation};
|
||||
if (!IsWithinBox(center, trigger->box_x / 2.f, trigger->box_y / 2.f, trigger->box_z / 2.f))
|
||||
Position center = {trigger->x, trigger->y, trigger->z, trigger->orientation};
|
||||
if (!IsWithinBox(center, trigger->length / 2.f, trigger->width / 2.f, trigger->height / 2.f))
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -7608,7 +7608,7 @@ void Player::UpdateArea(uint32 newArea)
|
||||
}
|
||||
else if (!(areaFlags & AREA_FLAG_CAPITAL))
|
||||
{
|
||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(GetInnTriggerId());
|
||||
AreaTrigger const* atEntry = sObjectMgr->GetAreaTrigger(GetInnTriggerId());
|
||||
if (!atEntry || !IsInAreaTriggerRadius(atEntry))
|
||||
RemoveRestState();
|
||||
}
|
||||
@@ -17784,7 +17784,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
if (uint32 destInstId = sInstanceSaveMgr->PlayerGetDestinationInstanceId(this, mapId, GetDifficulty(mapEntry->IsRaid())))
|
||||
{
|
||||
instanceId = destInstId;
|
||||
if (AreaTrigger const* at = sObjectMgr->GetMapEntranceTrigger(mapId))
|
||||
if (AreaTriggerTeleport const* at = sObjectMgr->GetMapEntranceTrigger(mapId))
|
||||
{
|
||||
Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation);
|
||||
fixed = true;
|
||||
@@ -17876,7 +17876,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
{
|
||||
bool fixed = false;
|
||||
if (mapEntry->Instanceable())
|
||||
if (AreaTrigger const* at = sObjectMgr->GetMapEntranceTrigger(mapId))
|
||||
if (AreaTriggerTeleport const* at = sObjectMgr->GetMapEntranceTrigger(mapId))
|
||||
{
|
||||
fixed = true;
|
||||
Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation);
|
||||
@@ -17922,7 +17922,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
// if the player is in an instance and it has been reset in the meantime teleport him to the entrance
|
||||
if ((instanceId && !sInstanceSaveMgr->GetInstanceSave(instanceId) && !mapEntry->IsBattlegroundOrArena()) || (!instanceId && mapEntry->IsDungeon()))
|
||||
{
|
||||
AreaTrigger const* at = sObjectMgr->GetMapEntranceTrigger(mapId);
|
||||
AreaTriggerTeleport const* at = sObjectMgr->GetMapEntranceTrigger(mapId);
|
||||
if (at)
|
||||
Relocate(at->target_X, at->target_Y, at->target_Z, at->target_Orientation);
|
||||
else
|
||||
@@ -17936,7 +17936,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
if (!map)
|
||||
{
|
||||
instanceId = 0;
|
||||
AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(mapId);
|
||||
AreaTriggerTeleport const* at = sObjectMgr->GetGoBackTrigger(mapId);
|
||||
if (at)
|
||||
{
|
||||
sLog->outError("Player (guidlow %d) is teleported to gobacktrigger (Map: %u X: %f Y: %f Z: %f O: %f).", guid, mapId, GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "Unit.h"
|
||||
#include "Battleground.h"
|
||||
#include "WorldSession.h"
|
||||
#include "ObjectMgr.h"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -1128,7 +1129,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
bool IsInWater(bool allowAbove = false) const;
|
||||
bool IsUnderWater() const;
|
||||
bool IsFalling() const;
|
||||
bool IsInAreaTriggerRadius(const AreaTriggerEntry* trigger) const;
|
||||
bool IsInAreaTriggerRadius(const AreaTrigger* trigger) const;
|
||||
|
||||
void SendInitialPacketsBeforeAddToMap();
|
||||
void SendInitialPacketsAfterAddToMap();
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -991,7 +991,7 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder* holder)
|
||||
|
||||
if (!pCurrChar->GetMap()->AddPlayerToMap(pCurrChar) || !pCurrChar->CheckInstanceLoginValid())
|
||||
{
|
||||
AreaTrigger const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId());
|
||||
AreaTriggerTeleport const* at = sObjectMgr->GetGoBackTrigger(pCurrChar->GetMapId());
|
||||
if (at)
|
||||
pCurrChar->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, pCurrChar->GetOrientation());
|
||||
else
|
||||
|
||||
@@ -886,7 +886,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
||||
return;
|
||||
}
|
||||
|
||||
AreaTriggerEntry const* atEntry = sAreaTriggerStore.LookupEntry(triggerId);
|
||||
AreaTrigger const* atEntry = sObjectMgr->GetAreaTrigger(triggerId);
|
||||
if (!atEntry)
|
||||
{
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
@@ -900,7 +900,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
||||
{
|
||||
#if defined(ENABLE_EXTRAS) && defined(ENABLE_EXTRA_LOGS)
|
||||
sLog->outDebug(LOG_FILTER_NETWORKIO, "HandleAreaTriggerOpcode: Player '%s' (GUID: %u) too far (trigger map: %u player map: %u), ignore Area Trigger ID: %u",
|
||||
player->GetName().c_str(), atEntry->mapid, player->GetMapId(), player->GetGUIDLow(), triggerId);
|
||||
player->GetName().c_str(), atEntry->map, player->GetMapId(), player->GetGUIDLow(), triggerId);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
@@ -919,7 +919,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
||||
if (sObjectMgr->IsTavernAreaTrigger(triggerId))
|
||||
{
|
||||
// set resting flag we are in the inn
|
||||
player->SetRestState(atEntry->id);
|
||||
player->SetRestState(atEntry->entry);
|
||||
|
||||
if (sWorld->IsFFAPvPRealm())
|
||||
player->RemoveByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_FFA_PVP);
|
||||
@@ -938,7 +938,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recv_data)
|
||||
if (pvp->HandleAreaTrigger(_player, triggerId))
|
||||
return;
|
||||
|
||||
AreaTrigger const* at = sObjectMgr->GetAreaTrigger(triggerId);
|
||||
AreaTriggerTeleport const* at = sObjectMgr->GetAreaTriggerTeleport(triggerId);
|
||||
if (!at)
|
||||
return;
|
||||
|
||||
|
||||
@@ -933,12 +933,12 @@ GameObjectAI* ScriptMgr::GetGameObjectAI(GameObject* go)
|
||||
return tmpscript->GetAI(go);
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger)
|
||||
bool ScriptMgr::OnAreaTrigger(Player* player, AreaTrigger const* trigger)
|
||||
{
|
||||
ASSERT(player);
|
||||
ASSERT(trigger);
|
||||
|
||||
GET_SCRIPT_RET(AreaTriggerScript, sObjectMgr->GetAreaTriggerScriptId(trigger->id), tmpscript, false);
|
||||
GET_SCRIPT_RET(AreaTriggerScript, sObjectMgr->GetAreaTriggerScriptId(trigger->entry), tmpscript, false);
|
||||
return tmpscript->OnTrigger(player, trigger);
|
||||
}
|
||||
|
||||
|
||||
@@ -586,7 +586,7 @@ class AreaTriggerScript : public ScriptObject
|
||||
bool IsDatabaseBound() const { return true; }
|
||||
|
||||
// Called when the area trigger is activated by a player.
|
||||
virtual bool OnTrigger(Player* /*player*/, AreaTriggerEntry const* /*trigger*/) { return false; }
|
||||
virtual bool OnTrigger(Player* /*player*/, AreaTrigger const* /*trigger*/) { return false; }
|
||||
};
|
||||
|
||||
class BattlegroundScript : public ScriptObject
|
||||
@@ -1136,7 +1136,7 @@ class ScriptMgr
|
||||
|
||||
public: /* AreaTriggerScript */
|
||||
|
||||
bool OnAreaTrigger(Player* player, AreaTriggerEntry const* trigger);
|
||||
bool OnAreaTrigger(Player* player, AreaTrigger const* trigger);
|
||||
|
||||
public: /* BattlegroundScript */
|
||||
|
||||
|
||||
@@ -1545,7 +1545,10 @@ void World::SetInitialWorldSettings()
|
||||
sLog->outString("Loading SpellArea Data..."); // must be after quest load
|
||||
sSpellMgr->LoadSpellAreas();
|
||||
|
||||
sLog->outString("Loading AreaTrigger definitions...");
|
||||
sLog->outString("Loading Area Trigger definitions");
|
||||
sObjectMgr->LoadAreaTriggers();
|
||||
|
||||
sLog->outString("Loading Area Trigger Teleport definitions...");
|
||||
sObjectMgr->LoadAreaTriggerTeleports();
|
||||
|
||||
sLog->outString("Loading Access Requirements...");
|
||||
|
||||
Reference in New Issue
Block a user