Core/DBC Move WorldSafeLocs.dbc storage to DB (#932)

This commit is contained in:
Kargatum
2019-01-08 13:37:31 +07:00
committed by Viste(Кирилл)
parent 3d416de893
commit 1a9f8dfc0c
38 changed files with 1262 additions and 414 deletions
+5 -4
View File
@@ -20,6 +20,7 @@
#include "CreatureTextMgr.h"
#include "GroupMgr.h"
#include "Transport.h"
#include "GameGraveyard.h"
Battlefield::Battlefield()
{
@@ -583,7 +584,7 @@ BfGraveyard* Battlefield::GetGraveyardById(uint32 id) const
return NULL;
}
WorldSafeLocsEntry const * Battlefield::GetClosestGraveyard(Player* player)
GraveyardStruct const * Battlefield::GetClosestGraveyard(Player* player)
{
BfGraveyard* closestGY = NULL;
float maxdist = -1;
@@ -604,7 +605,7 @@ WorldSafeLocsEntry const * Battlefield::GetClosestGraveyard(Player* player)
}
if (closestGY)
return sWorldSafeLocsStore.LookupEntry(closestGY->GetGraveyardId());
return sGraveyard->GetGraveyard(closestGY->GetGraveyardId());
return NULL;
}
@@ -682,7 +683,7 @@ void BfGraveyard::SetSpirit(Creature* spirit, TeamId team)
float BfGraveyard::GetDistance(Player* player)
{
const WorldSafeLocsEntry* safeLoc = sWorldSafeLocsStore.LookupEntry(m_GraveyardId);
const GraveyardStruct* safeLoc = sGraveyard->GetGraveyard(m_GraveyardId);
return player->GetDistance2d(safeLoc->x, safeLoc->y);
}
@@ -744,7 +745,7 @@ void BfGraveyard::GiveControlTo(TeamId team)
void BfGraveyard::RelocateDeadPlayers()
{
WorldSafeLocsEntry const* closestGrave = NULL;
GraveyardStruct const* closestGrave = NULL;
for (GuidSet::const_iterator itr = m_ResurrectQueue.begin(); itr != m_ResurrectQueue.end(); ++itr)
{
Player* player = ObjectAccessor::FindPlayer(*itr);
+1 -1
View File
@@ -285,7 +285,7 @@ class Battlefield : public ZoneScript
// Graveyard methods
// Find which graveyard the player must be teleported to to be resurrected by spiritguide
WorldSafeLocsEntry const * GetClosestGraveyard(Player* player);
GraveyardStruct const * GetClosestGraveyard(Player* player);
virtual void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid);
void RemovePlayerFromResurrectQueue(uint64 player_guid);
@@ -32,6 +32,7 @@
#include "BattlegroundRV.h"
#include "Transport.h"
#include "ScriptMgr.h"
#include "GameGraveyard.h"
#ifdef ELUNA
#include "LuaEngine.h"
#endif
@@ -1434,7 +1435,7 @@ void Battleground::RelocateDeadPlayers(uint64 queueIndex)
std::vector<uint64>& ghostList = m_ReviveQueue[queueIndex];
if (!ghostList.empty())
{
WorldSafeLocsEntry const* closestGrave = NULL;
GraveyardStruct const* closestGrave = NULL;
for (std::vector<uint64>::const_iterator itr = ghostList.begin(); itr != ghostList.end(); ++itr)
{
Player* player = ObjectAccessor::FindPlayer(*itr);
@@ -1914,9 +1915,9 @@ void Battleground::SetBgRaid(TeamId teamId, Group* bg_raid)
old_raid = bg_raid;
}
WorldSafeLocsEntry const* Battleground::GetClosestGraveyard(Player* player)
GraveyardStruct const* Battleground::GetClosestGraveyard(Player* player)
{
return sObjectMgr->GetClosestGraveyard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetBgTeamId());
return sGraveyard->GetClosestGraveyard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), player->GetBgTeamId());
}
void Battleground::StartTimedAchievement(AchievementCriteriaTimedTypes type, uint32 entry)
+2 -2
View File
@@ -31,7 +31,7 @@ class BattlegroundRV;
class BattlegroundIC;
struct PvPDifficultyEntry;
struct WorldSafeLocsEntry;
struct GraveyardStruct;
enum BattlegroundDesertionType
{
@@ -541,7 +541,7 @@ class Battleground
virtual void HandlePlayerResurrect(Player* /*player*/) {}
// Death related
virtual WorldSafeLocsEntry const* GetClosestGraveyard(Player* player);
virtual GraveyardStruct const* GetClosestGraveyard(Player* player);
virtual void AddPlayer(Player* player); // must be implemented in BG subclass
@@ -34,6 +34,7 @@
#include "DisableMgr.h"
#include "Opcodes.h"
#include "BattlegroundQueue.h"
#include "GameGraveyard.h"
#ifdef ELUNA
#include "LuaEngine.h"
#endif
@@ -649,7 +650,7 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
else
{
uint32 startId = fields[5].GetUInt32();
if (WorldSafeLocsEntry const* start = sWorldSafeLocsStore.LookupEntry(startId))
if (GraveyardStruct const* start = sGraveyard->GetGraveyard(startId))
{
data.Team1StartLocX = start->x;
data.Team1StartLocY = start->y;
@@ -658,12 +659,12 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
}
else
{
sLog->outError("Table `battleground_template` for id %u have non-existed WorldSafeLocs.dbc id %u in field `AllianceStartLoc`. BG not created.", data.bgTypeId, startId);
sLog->outError("Table `battleground_template` for id %u have non-existed `game_graveyard` table id %u in field `AllianceStartLoc`. BG not created.", data.bgTypeId, startId);
continue;
}
startId = fields[7].GetUInt32();
if (WorldSafeLocsEntry const* start = sWorldSafeLocsStore.LookupEntry(startId))
if (GraveyardStruct const* start = sGraveyard->GetGraveyard(startId))
{
data.Team2StartLocX = start->x;
data.Team2StartLocY = start->y;
@@ -672,7 +673,7 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
}
else
{
sLog->outError("Table `battleground_template` for id %u have non-existed WorldSafeLocs.dbc id %u in field `HordeStartLoc`. BG not created.", data.bgTypeId, startId);
sLog->outError("Table `battleground_template` for id %u have non-existed `game_graveyard` table id %u in field `HordeStartLoc`. BG not created.", data.bgTypeId, startId);
continue;
}
}
@@ -13,6 +13,7 @@
#include "Player.h"
#include "Util.h"
#include "WorldSession.h"
#include "GameGraveyard.h"
BattlegroundAB::BattlegroundAB()
{
@@ -424,10 +425,10 @@ void BattlegroundAB::EndBattleground(TeamId winnerTeamId)
_bgEvents.Reset();
}
WorldSafeLocsEntry const* BattlegroundAB::GetClosestGraveyard(Player* player)
GraveyardStruct const* BattlegroundAB::GetClosestGraveyard(Player* player)
{
WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[BG_AB_SPIRIT_ALIANCE + player->GetTeamId()]);
WorldSafeLocsEntry const* nearestEntry = entry;
GraveyardStruct const* entry = sGraveyard->GetGraveyard(BG_AB_GraveyardIds[BG_AB_SPIRIT_ALIANCE + player->GetTeamId()]);
GraveyardStruct const* nearestEntry = entry;
float pX = player->GetPositionX();
float pY = player->GetPositionY();
@@ -437,7 +438,7 @@ WorldSafeLocsEntry const* BattlegroundAB::GetClosestGraveyard(Player* player)
for (uint8 i = BG_AB_NODE_STABLES; i < BG_AB_DYNAMIC_NODES_COUNT; ++i)
if (_capturePointInfo[i]._ownerTeamId == player->GetTeamId())
{
entry = sWorldSafeLocsStore.LookupEntry(BG_AB_GraveyardIds[i]);
entry = sGraveyard->GetGraveyard(BG_AB_GraveyardIds[i]);
dist = (entry->x - pX)*(entry->x - pX) + (entry->y - pY)*(entry->y - pY);
if (dist < minDist)
{
@@ -235,7 +235,7 @@ class BattlegroundAB : public Battleground
bool SetupBattleground();
void Init();
void EndBattleground(TeamId winnerTeamId);
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player);
GraveyardStruct const* GetClosestGraveyard(Player* player);
void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true);
void FillInitialWorldStates(WorldPacket& data);
@@ -15,6 +15,7 @@
#include "SpellAuras.h"
#include "GameEventMgr.h"
#include "WorldSession.h"
#include "GameGraveyard.h"
BattlegroundAV::BattlegroundAV()
{
@@ -1174,23 +1175,23 @@ void BattlegroundAV::SendMineWorldStates(uint32 mine)
UpdateWorldState(BG_AV_MineWorldStates[mine][owner], 1);
}
WorldSafeLocsEntry const* BattlegroundAV::GetClosestGraveyard(Player* player)
GraveyardStruct const* BattlegroundAV::GetClosestGraveyard(Player* player)
{
WorldSafeLocsEntry const* pGraveyard = NULL;
WorldSafeLocsEntry const* entry = NULL;
GraveyardStruct const* pGraveyard = NULL;
GraveyardStruct const* entry = NULL;
float dist = 0;
float minDist = 0;
float x, y;
player->GetPosition(x, y);
pGraveyard = sWorldSafeLocsStore.LookupEntry(BG_AV_GraveyardIds[player->GetTeamId()+7]);
pGraveyard = sGraveyard->GetGraveyard(BG_AV_GraveyardIds[player->GetTeamId()+7]);
minDist = (pGraveyard->x - x)*(pGraveyard->x - x)+(pGraveyard->y - y)*(pGraveyard->y - y);
for (uint8 i = BG_AV_NODES_FIRSTAID_STATION; i <= BG_AV_NODES_FROSTWOLF_HUT; ++i)
if (m_Nodes[i].OwnerId == player->GetTeamId() && m_Nodes[i].State == POINT_CONTROLED)
{
entry = sWorldSafeLocsStore.LookupEntry(BG_AV_GraveyardIds[i]);
entry = sGraveyard->GetGraveyard(BG_AV_GraveyardIds[i]);
if (entry)
{
dist = (entry->x - x)*(entry->x - x)+(entry->y - y)*(entry->y - y);
@@ -1591,7 +1591,7 @@ class BattlegroundAV : public Battleground
void EndBattleground(TeamId winnerTeamId);
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player);
GraveyardStruct const* GetClosestGraveyard(Player* player);
/* achievement req. */
bool IsBothMinesControlledByTeam(TeamId teamId) const;
@@ -13,6 +13,7 @@
#include "Player.h"
#include "Util.h"
#include "WorldSession.h"
#include "GameGraveyard.h"
BattlegroundEY::BattlegroundEY()
{
@@ -309,11 +310,11 @@ bool BattlegroundEY::SetupBattleground()
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);
}
WorldSafeLocsEntry const* sg = NULL;
sg = sWorldSafeLocsStore.LookupEntry(BG_EY_GRAVEYARD_MAIN_ALLIANCE);
GraveyardStruct const* sg = NULL;
sg = sGraveyard->GetGraveyard(BG_EY_GRAVEYARD_MAIN_ALLIANCE);
AddSpiritGuide(BG_EY_SPIRIT_MAIN_ALLIANCE, sg->x, sg->y, sg->z, 3.124139f, TEAM_ALLIANCE);
sg = sWorldSafeLocsStore.LookupEntry(BG_EY_GRAVEYARD_MAIN_HORDE);
sg = sGraveyard->GetGraveyard(BG_EY_GRAVEYARD_MAIN_HORDE);
AddSpiritGuide(BG_EY_SPIRIT_MAIN_HORDE, sg->x, sg->y, sg->z, 3.193953f, TEAM_HORDE);
for (uint32 i = BG_EY_OBJECT_DOOR_A; i < BG_EY_OBJECT_MAX; ++i)
@@ -480,7 +481,7 @@ void BattlegroundEY::EventTeamCapturedPoint(TeamId teamId, uint32 point)
if (BgCreatures[point])
DelCreature(point);
WorldSafeLocsEntry const* sg = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[point].GraveYardId);
GraveyardStruct const* sg = sGraveyard->GetGraveyard(m_CapturingPointTypes[point].GraveYardId);
AddSpiritGuide(point, sg->x, sg->y, sg->z, 3.124139f, teamId);
UpdatePointsIcons(point);
@@ -565,10 +566,10 @@ void BattlegroundEY::FillInitialWorldStates(WorldPacket& data)
data << uint32(PROGRESS_BAR_STATUS) << uint32(0);
}
WorldSafeLocsEntry const* BattlegroundEY::GetClosestGraveyard(Player* player)
GraveyardStruct const* BattlegroundEY::GetClosestGraveyard(Player* player)
{
WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(BG_EY_GRAVEYARD_MAIN_ALLIANCE + player->GetTeamId());
WorldSafeLocsEntry const* nearestEntry = entry;
GraveyardStruct const* entry = sGraveyard->GetGraveyard(BG_EY_GRAVEYARD_MAIN_ALLIANCE + player->GetTeamId());
GraveyardStruct const* nearestEntry = entry;
float pX = player->GetPositionX();
float pY = player->GetPositionY();
@@ -579,7 +580,7 @@ WorldSafeLocsEntry const* BattlegroundEY::GetClosestGraveyard(Player* player)
for (uint8 i = 0; i < EY_POINTS_MAX; ++i)
if (_capturePointInfo[i].IsUnderControl(player->GetTeamId()))
{
entry = sWorldSafeLocsStore.LookupEntry(m_CapturingPointTypes[i].GraveYardId);
entry = sGraveyard->GetGraveyard(m_CapturingPointTypes[i].GraveYardId);
dist = (entry->x - pX)*(entry->x - pX) + (entry->y - pY)*(entry->y - pY) + (entry->z - pZ)*(entry->z - pZ);
if (dist < minDist)
{
@@ -336,7 +336,7 @@ class BattlegroundEY : public Battleground
void HandleBuffUse(uint64 buff_guid);
void HandleAreaTrigger(Player* player, uint32 trigger);
void HandleKillPlayer(Player* player, Player* killer);
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player);
GraveyardStruct const* GetClosestGraveyard(Player* player);
bool SetupBattleground();
void Init();
void EndBattleground(TeamId winnerTeamId);
@@ -15,6 +15,7 @@
#include "Transport.h"
#include "WorldSession.h"
#include "ScriptedCreature.h"
#include "GameGraveyard.h"
BattlegroundIC::BattlegroundIC()
{
@@ -950,7 +951,7 @@ void BattlegroundIC::EventPlayerDamagedGO(Player* /*player*/, GameObject* /*go*/
}
WorldSafeLocsEntry const* BattlegroundIC::GetClosestGraveyard(Player* player)
GraveyardStruct const* BattlegroundIC::GetClosestGraveyard(Player* player)
{
// Is there any occupied node for this team?
std::vector<uint8> nodes;
@@ -958,7 +959,7 @@ WorldSafeLocsEntry const* BattlegroundIC::GetClosestGraveyard(Player* player)
if (nodePoint[i].faction == player->GetTeamId() && !nodePoint[i].needChange) // xinef: controlled by faction and not contested!
nodes.push_back(i);
WorldSafeLocsEntry const* good_entry = NULL;
GraveyardStruct const* good_entry = NULL;
// If so, select the closest node to place ghost on
if (!nodes.empty())
{
@@ -968,7 +969,7 @@ WorldSafeLocsEntry const* BattlegroundIC::GetClosestGraveyard(Player* player)
float mindist = 999999.0f;
for (uint8 i = 0; i < nodes.size(); ++i)
{
WorldSafeLocsEntry const*entry = sWorldSafeLocsStore.LookupEntry(BG_IC_GraveyardIds[nodes[i]]);
GraveyardStruct const*entry = sGraveyard->GetGraveyard(BG_IC_GraveyardIds[nodes[i]]);
if (!entry)
continue;
float dist = (entry->x - plr_x)*(entry->x - plr_x)+(entry->y - plr_y)*(entry->y - plr_y);
@@ -982,7 +983,7 @@ WorldSafeLocsEntry const* BattlegroundIC::GetClosestGraveyard(Player* player)
}
// If not, place ghost on starting location
if (!good_entry)
good_entry = sWorldSafeLocsStore.LookupEntry(BG_IC_GraveyardIds[player->GetTeamId()+MAX_NODE_TYPES]);
good_entry = sGraveyard->GetGraveyard(BG_IC_GraveyardIds[player->GetTeamId()+MAX_NODE_TYPES]);
return good_entry;
}
@@ -911,7 +911,7 @@ class BattlegroundIC : public Battleground
void EventPlayerDamagedGO(Player* /*player*/, GameObject* go, uint32 eventType);
void DestroyGate(Player* player, GameObject* go);
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player);
GraveyardStruct const* GetClosestGraveyard(Player* player);
/* Scorekeeping */
void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true);
@@ -11,6 +11,7 @@
#include "ObjectMgr.h"
#include "WorldPacket.h"
#include "WorldSession.h"
#include "GameGraveyard.h"
BattlegroundSA::BattlegroundSA()
{
@@ -163,8 +164,8 @@ bool BattlegroundSA::ResetObjs()
//Graveyards!
for (uint8 i = 0;i < BG_SA_MAX_GY; i++)
{
WorldSafeLocsEntry const* sg = NULL;
sg = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]);
GraveyardStruct const* sg = NULL;
sg = sGraveyard->GetGraveyard(BG_SA_GYEntries[i]);
if (!sg)
{
@@ -761,9 +762,9 @@ void BattlegroundSA::DestroyGate(Player* player, GameObject* go)
}
}
WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveyard(Player* player)
GraveyardStruct const* BattlegroundSA::GetClosestGraveyard(Player* player)
{
WorldSafeLocsEntry const* closest = NULL;
GraveyardStruct const* closest = NULL;
float mindist = 999999.0f;
float x, y;
@@ -774,7 +775,7 @@ WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveyard(Player* player)
if (GraveyardStatus[i] != player->GetTeamId())
continue;
WorldSafeLocsEntry const* ret = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]);
GraveyardStruct const* ret = sGraveyard->GetGraveyard(BG_SA_GYEntries[i]);
// if on beach
if (i == BG_SA_BEACH_GY)
@@ -792,7 +793,7 @@ WorldSafeLocsEntry const* BattlegroundSA::GetClosestGraveyard(Player* player)
}
}
if (!closest && GraveyardStatus[BG_SA_BEACH_GY] == player->GetTeamId())
return sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[BG_SA_BEACH_GY]);
return sGraveyard->GetGraveyard(BG_SA_GYEntries[BG_SA_BEACH_GY]);
return closest;
@@ -883,7 +884,7 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player *Source)
std::vector<uint64> ghost_list = m_ReviveQueue[BgCreatures[BG_SA_MAXNPC + i]];
if (!ghost_list.empty())
{
WorldSafeLocsEntry const* ClosestGrave = NULL;
GraveyardStruct const* ClosestGrave = NULL;
for (std::vector<uint64>::const_iterator itr = ghost_list.begin(); itr != ghost_list.end(); ++itr)
{
Player* player = ObjectAccessor::FindPlayer(*itr);
@@ -902,7 +903,7 @@ void BattlegroundSA::CaptureGraveyard(BG_SA_Graveyards i, Player *Source)
DelCreature(BG_SA_MAXNPC + i);
WorldSafeLocsEntry const* sg = sWorldSafeLocsStore.LookupEntry(BG_SA_GYEntries[i]);
GraveyardStruct const* sg = sGraveyard->GetGraveyard(BG_SA_GYEntries[i]);
if (!sg)
{
sLog->outError("BattlegroundSA::CaptureGraveyard: non-existant GY entry: %u", BG_SA_GYEntries[i]);
@@ -445,7 +445,7 @@ class BattlegroundSA : public Battleground
/// Called when a player kill a unit in bg
void HandleKillUnit(Creature* creature, Player* killer);
/// Return the nearest graveyard where player can respawn
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player);
GraveyardStruct const* GetClosestGraveyard(Player* player);
/// Called when a player click on flag (graveyard flag)
void EventPlayerClickedOnFlag(Player* Source, GameObject* gameObject);
/// Called when a player use a gamobject (relic)
@@ -12,6 +12,7 @@
#include "Player.h"
#include "World.h"
#include "WorldPacket.h"
#include "GameGraveyard.h"
BattlegroundWS::BattlegroundWS()
{
@@ -401,10 +402,10 @@ bool BattlegroundWS::SetupBattleground()
AddObject(BG_WS_OBJECT_DOOR_H_4, BG_OBJECT_DOOR_H_4_WS_ENTRY, 950.7952f, 1459.583f, 342.1523f, 0.05235988f, 0, 0, 0.02617695f, 0.9996573f, RESPAWN_IMMEDIATELY);
WorldSafeLocsEntry const* sg = sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_ALLIANCE);
GraveyardStruct const* sg = sGraveyard->GetGraveyard(WS_GRAVEYARD_MAIN_ALLIANCE);
AddSpiritGuide(WS_SPIRIT_MAIN_ALLIANCE, sg->x, sg->y, sg->z, 3.124139f, TEAM_ALLIANCE);
sg = sWorldSafeLocsStore.LookupEntry(WS_GRAVEYARD_MAIN_HORDE);
sg = sGraveyard->GetGraveyard(WS_GRAVEYARD_MAIN_HORDE);
AddSpiritGuide(WS_SPIRIT_MAIN_HORDE, sg->x, sg->y, sg->z, 3.193953f, TEAM_HORDE);
for (uint32 i = BG_WS_OBJECT_DOOR_A_1; i < BG_WS_OBJECT_MAX; ++i)
@@ -495,12 +496,12 @@ void BattlegroundWS::UpdatePlayerScore(Player* player, uint32 type, uint32 value
}
}
WorldSafeLocsEntry const* BattlegroundWS::GetClosestGraveyard(Player* player)
GraveyardStruct const* BattlegroundWS::GetClosestGraveyard(Player* player)
{
if (GetStatus() == STATUS_IN_PROGRESS)
return sWorldSafeLocsStore.LookupEntry(player->GetTeamId() == TEAM_ALLIANCE ? WS_GRAVEYARD_MAIN_ALLIANCE : WS_GRAVEYARD_MAIN_HORDE);
return sGraveyard->GetGraveyard(player->GetTeamId() == TEAM_ALLIANCE ? WS_GRAVEYARD_MAIN_ALLIANCE : WS_GRAVEYARD_MAIN_HORDE);
else
return sWorldSafeLocsStore.LookupEntry(player->GetTeamId() == TEAM_ALLIANCE ? WS_GRAVEYARD_FLAGROOM_ALLIANCE : WS_GRAVEYARD_FLAGROOM_HORDE);
return sGraveyard->GetGraveyard(player->GetTeamId() == TEAM_ALLIANCE ? WS_GRAVEYARD_FLAGROOM_ALLIANCE : WS_GRAVEYARD_FLAGROOM_HORDE);
}
void BattlegroundWS::FillInitialWorldStates(WorldPacket& data)
@@ -176,7 +176,7 @@ class BattlegroundWS : public Battleground
bool SetupBattleground();
void Init();
void EndBattleground(TeamId winnerTeamId);
WorldSafeLocsEntry const* GetClosestGraveyard(Player* player);
GraveyardStruct const* GetClosestGraveyard(Player* player);
void UpdateFlagState(TeamId teamId, uint32 value);
void UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true);
-2
View File
@@ -183,7 +183,6 @@ DBCStorage <VehicleSeatEntry> sVehicleSeatStore(VehicleSeatEntryfmt);
DBCStorage <WMOAreaTableEntry> sWMOAreaTableStore(WMOAreaTableEntryfmt);
DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore(WorldMapAreaEntryfmt);
DBCStorage <WorldMapOverlayEntry> sWorldMapOverlayStore(WorldMapOverlayEntryfmt);
DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore(WorldSafeLocsEntryfmt);
typedef std::list<std::string> StoreProblemList;
@@ -589,7 +588,6 @@ void LoadDBCStores(const std::string& dataPath)
sWMOAreaInfoByTripple.insert(WMOAreaInfoByTripple::value_type(WMOAreaTableTripple(entry->rootId, entry->adtId, entry->groupId), entry));
LoadDBC(availableDbcLocales, bad_dbc_files, sWorldMapAreaStore, dbcPath, "WorldMapArea.dbc");
LoadDBC(availableDbcLocales, bad_dbc_files, sWorldMapOverlayStore, dbcPath, "WorldMapOverlay.dbc");
LoadDBC(availableDbcLocales, bad_dbc_files, sWorldSafeLocsStore, dbcPath, "WorldSafeLocs.dbc");
// error checks
if (bad_dbc_files.size() >= DBCFileCount)
-1
View File
@@ -159,7 +159,6 @@ extern DBCStorage <VehicleSeatEntry> sVehicleSeatStore;
extern DBCStorage <WMOAreaTableEntry> sWMOAreaTableStore;
//extern DBCStorage <WorldMapAreaEntry> sWorldMapAreaStore; -- use Zone2MapCoordinates and Map2ZoneCoordinates
extern DBCStorage <WorldMapOverlayEntry> sWorldMapOverlayStore;
extern DBCStorage <WorldSafeLocsEntry> sWorldSafeLocsStore;
void LoadDBCStores(const std::string& dataPath);
-11
View File
@@ -2044,17 +2044,6 @@ struct WorldMapOverlayEntry
// 9-16 some ints
};
struct WorldSafeLocsEntry
{
uint32 ID; // 0
uint32 map_id; // 1
float x; // 2
float y; // 3
float z; // 4
//char* name[16] // 5-20 name, unused
// 21 name flags, unused
};
/*
struct WorldStateSounds
{
-1
View File
@@ -116,6 +116,5 @@ char const VehicleSeatEntryfmt[] = "niiffffffffffiiiiiifffffffiiifffiiiiiiiffiii
char const WMOAreaTableEntryfmt[] = "niiixxxxxiixxxxxxxxxxxxxxxxx";
char const WorldMapAreaEntryfmt[] = "xinxffffixx";
char const WorldMapOverlayEntryfmt[] = "nxiiiixxxxxxxxxxx";
char const WorldSafeLocsEntryfmt[] = "nifffxxxxxxxxxxxxxxxxx";
#endif
+7 -6
View File
@@ -76,6 +76,7 @@
#include "SavingSystem.h"
#include "TicketMgr.h"
#include "ScriptMgr.h"
#include "GameGraveyard.h"
#ifdef ELUNA
#include "LuaEngine.h"
@@ -5566,7 +5567,7 @@ void Player::RepopAtGraveyard()
SpawnCorpseBones();
}
WorldSafeLocsEntry const* ClosestGrave = NULL;
GraveyardStruct const* ClosestGrave = NULL;
// Special handle for battleground maps
if (Battleground* bg = GetBattleground())
@@ -5576,7 +5577,7 @@ void Player::RepopAtGraveyard()
if (sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId()))
ClosestGrave = sBattlefieldMgr->GetBattlefieldToZoneId(GetZoneId())->GetClosestGraveyard(this);
else
ClosestGrave = sObjectMgr->GetClosestGraveyard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeamId());
ClosestGrave = sGraveyard->GetClosestGraveyard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeamId());
}
// stop countdown until repop
@@ -5586,11 +5587,11 @@ void Player::RepopAtGraveyard()
// and don't show spirit healer location
if (ClosestGrave)
{
TeleportTo(ClosestGrave->map_id, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, GetOrientation());
TeleportTo(ClosestGrave->Map, ClosestGrave->x, ClosestGrave->y, ClosestGrave->z, GetOrientation());
if (isDead()) // not send if alive, because it used in TeleportTo()
{
WorldPacket data(SMSG_DEATH_RELEASE_LOC, 4*4); // show spirit healer position on minimap
data << ClosestGrave->map_id;
data << ClosestGrave->Map;
data << ClosestGrave->x;
data << ClosestGrave->y;
data << ClosestGrave->z;
@@ -22564,8 +22565,8 @@ void Player::SetEntryPoint()
if (GetMap()->IsDungeon())
{
if (const WorldSafeLocsEntry* entry = sObjectMgr->GetClosestGraveyard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeamId()))
m_entryPointData.joinPos = WorldLocation(entry->map_id, entry->x, entry->y, entry->z, 0.0f);
if (const GraveyardStruct* entry = sGraveyard->GetClosestGraveyard(GetPositionX(), GetPositionY(), GetPositionZ(), GetMapId(), GetTeamId()))
m_entryPointData.joinPos = WorldLocation(entry->Map, entry->x, entry->y, entry->z, 0.0f);
}
else if (!GetMap()->IsBattlegroundOrArena())
m_entryPointData.joinPos = WorldLocation(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation());
-287
View File
@@ -5858,293 +5858,6 @@ uint32 ObjectMgr::GetTaxiMountDisplayId(uint32 id, TeamId teamId, bool allowed_a
return mount_id;
}
void ObjectMgr::LoadGraveyardZones()
{
uint32 oldMSTime = getMSTime();
GraveyardStore.clear(); // need for reload case
// 0 1 2
QueryResult result = WorldDatabase.Query("SELECT id, ghost_zone, faction FROM game_graveyard_zone");
if (!result)
{
sLog->outString(">> Loaded 0 graveyard-zone links. DB table `game_graveyard_zone` is empty.");
sLog->outString();
return;
}
uint32 count = 0;
do
{
++count;
Field* fields = result->Fetch();
uint32 safeLocId = fields[0].GetUInt32();
uint32 zoneId = fields[1].GetUInt32();
uint32 team = fields[2].GetUInt16();
TeamId teamId = team == 0 ? TEAM_NEUTRAL : (team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE);
WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(safeLocId);
if (!entry)
{
sLog->outErrorDb("Table `game_graveyard_zone` has a record for not existing graveyard (WorldSafeLocs.dbc id) %u, skipped.", safeLocId);
continue;
}
AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(zoneId);
if (!areaEntry)
{
sLog->outErrorDb("Table `game_graveyard_zone` has a record for not existing zone id (%u), skipped.", zoneId);
continue;
}
if (areaEntry->zone != 0)
{
sLog->outErrorDb("Table `game_graveyard_zone` has a record for subzone id (%u) instead of zone, skipped.", zoneId);
continue;
}
if (team != 0 && team != HORDE && team != ALLIANCE)
{
sLog->outErrorDb("Table `game_graveyard_zone` has a record for non player faction (%u), skipped.", team);
continue;
}
if (!AddGraveyardLink(safeLocId, zoneId, teamId, false))
sLog->outErrorDb("Table `game_graveyard_zone` has a duplicate record for Graveyard (ID: %u) and Zone (ID: %u), skipped.", safeLocId, zoneId);
} while (result->NextRow());
sLog->outString(">> Loaded %u graveyard-zone links in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
WorldSafeLocsEntry const* ObjectMgr::GetDefaultGraveyard(TeamId teamId)
{
enum DefaultGraveyard
{
HORDE_GRAVEYARD = 10, // Crossroads
ALLIANCE_GRAVEYARD = 4, // Westfall
};
return sWorldSafeLocsStore.LookupEntry(teamId == TEAM_HORDE ? HORDE_GRAVEYARD : ALLIANCE_GRAVEYARD);
}
WorldSafeLocsEntry const* ObjectMgr::GetClosestGraveyard(float x, float y, float z, uint32 MapId, TeamId teamId)
{
// search for zone associated closest graveyard
uint32 zoneId = sMapMgr->GetZoneId(MapId, x, y, z);
if (!zoneId)
{
if (z > -500)
{
sLog->outError("ZoneId not found for map %u coords (%f, %f, %f)", MapId, x, y, z);
return GetDefaultGraveyard(teamId);
}
}
// Simulate std. algorithm:
// found some graveyard associated to (ghost_zone, ghost_map)
//
// if mapId == graveyard.mapId (ghost in plain zone or city or battleground) and search graveyard at same map
// then check faction
// if mapId != graveyard.mapId (ghost in instance) and search any graveyard associated
// then check faction
GraveyardMapBounds range = GraveyardStore.equal_range(zoneId);
MapEntry const* map = sMapStore.LookupEntry(MapId);
// not need to check validity of map object; MapId _MUST_ be valid here
if (range.first == range.second && !map->IsBattlegroundOrArena())
{
sLog->outErrorDb("Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.", zoneId, teamId);
return GetDefaultGraveyard(teamId);
}
// at corpse map
bool foundNear = false;
float distNear = 10000;
WorldSafeLocsEntry const* entryNear = NULL;
// at entrance map for corpse map
bool foundEntr = false;
float distEntr = 10000;
WorldSafeLocsEntry const* entryEntr = NULL;
// some where other
WorldSafeLocsEntry const* entryFar = NULL;
MapEntry const* mapEntry = sMapStore.LookupEntry(MapId);
for (; range.first != range.second; ++range.first)
{
GraveyardData const& data = range.first->second;
WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(data.safeLocId);
if (!entry)
{
sLog->outErrorDb("Table `game_graveyard_zone` has record for not existing graveyard (WorldSafeLocs.dbc id) %u, skipped.", data.safeLocId);
continue;
}
// skip enemy faction graveyard
// team == 0 case can be at call from .neargrave
if (data.teamId != TEAM_NEUTRAL && teamId != TEAM_NEUTRAL && data.teamId != teamId)
continue;
// find now nearest graveyard at other map
if (MapId != entry->map_id)
{
// if find graveyard at different map from where entrance placed (or no entrance data), use any first
if (!mapEntry
|| mapEntry->entrance_map < 0
|| uint32(mapEntry->entrance_map) != entry->map_id
|| (mapEntry->entrance_x == 0 && mapEntry->entrance_y == 0))
{
// not have any corrdinates for check distance anyway
entryFar = entry;
continue;
}
// at entrance map calculate distance (2D);
float dist2 = (entry->x - mapEntry->entrance_x)*(entry->x - mapEntry->entrance_x)
+(entry->y - mapEntry->entrance_y)*(entry->y - mapEntry->entrance_y);
if (foundEntr)
{
if (dist2 < distEntr)
{
distEntr = dist2;
entryEntr = entry;
}
}
else
{
foundEntr = true;
distEntr = dist2;
entryEntr = entry;
}
}
// find now nearest graveyard at same map
else
{
float dist2 = (entry->x - x)*(entry->x - x)+(entry->y - y)*(entry->y - y)+(entry->z - z)*(entry->z - z);
if (foundNear)
{
if (dist2 < distNear)
{
distNear = dist2;
entryNear = entry;
}
}
else
{
foundNear = true;
distNear = dist2;
entryNear = entry;
}
}
}
if (entryNear)
return entryNear;
if (entryEntr)
return entryEntr;
return entryFar;
}
GraveyardData const* ObjectMgr::FindGraveyardData(uint32 id, uint32 zoneId)
{
GraveyardMapBounds range = GraveyardStore.equal_range(zoneId);
for (; range.first != range.second; ++range.first)
{
GraveyardData const& data = range.first->second;
if (data.safeLocId == id)
return &data;
}
return NULL;
}
bool ObjectMgr::AddGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, bool persist /*= true*/)
{
if (FindGraveyardData(id, zoneId))
return false;
// add link to loaded data
GraveyardData data;
data.safeLocId = id;
data.teamId = teamId;
GraveyardStore.insert(GraveyardContainer::value_type(zoneId, data));
// add link to DB
if (persist)
{
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GRAVEYARD_ZONE);
stmt->setUInt32(0, id);
stmt->setUInt32(1, zoneId);
// Xinef: DB Data compatibility...
stmt->setUInt16(2, uint16(teamId == TEAM_NEUTRAL ? 0 : (teamId == TEAM_ALLIANCE ? ALLIANCE : HORDE)));
WorldDatabase.Execute(stmt);
}
return true;
}
void ObjectMgr::RemoveGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, bool persist /*= false*/)
{
GraveyardMapBoundsNonConst range = GraveyardStore.equal_range(zoneId);
if (range.first == range.second)
{
//sLog->outError("Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.", zoneId, team);
return;
}
bool found = false;
for (; range.first != range.second; ++range.first)
{
GraveyardData & data = range.first->second;
// skip not matching safezone id
if (data.safeLocId != id)
continue;
// skip enemy faction graveyard at same map (normal area, city, or battleground)
// team == 0 case can be at call from .neargrave
if (data.teamId != TEAM_NEUTRAL && teamId != TEAM_NEUTRAL && data.teamId != teamId)
continue;
found = true;
break;
}
// no match, return
if (!found)
return;
// remove from links
GraveyardStore.erase(range.first);
// remove link from DB
if (persist)
{
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GRAVEYARD_ZONE);
stmt->setUInt32(0, id);
stmt->setUInt32(1, zoneId);
// Xinef: DB Data compatibility...
stmt->setUInt16(2, uint16(teamId == TEAM_NEUTRAL ? 0 : (teamId == TEAM_ALLIANCE ? ALLIANCE : HORDE)));
WorldDatabase.Execute(stmt);
}
}
void ObjectMgr::LoadAreaTriggers()
{
uint32 oldMSTime = getMSTime();
+1 -21
View File
@@ -625,16 +625,6 @@ struct QuestPOI
typedef std::vector<QuestPOI> QuestPOIVector;
typedef UNORDERED_MAP<uint32, QuestPOIVector> QuestPOIContainer;
struct GraveyardData
{
uint32 safeLocId;
TeamId teamId;
};
typedef std::multimap<uint32, GraveyardData> GraveyardContainer;
typedef std::pair<GraveyardContainer::const_iterator, GraveyardContainer::const_iterator> GraveyardMapBounds;
typedef std::pair<GraveyardContainer::iterator, GraveyardContainer::iterator> GraveyardMapBoundsNonConst;
typedef UNORDERED_MAP<uint32, VendorItemData> CacheVendorItemContainer;
typedef UNORDERED_MAP<uint32, TrainerSpellData> CacheTrainerSpellContainer;
@@ -811,14 +801,7 @@ class ObjectMgr
return _tavernAreaTriggerStore.find(Trigger_ID) != _tavernAreaTriggerStore.end();
}
GossipText const* GetGossipText(uint32 Text_ID) const;
WorldSafeLocsEntry const* GetDefaultGraveyard(TeamId teamId);
WorldSafeLocsEntry const* GetClosestGraveyard(float x, float y, float z, uint32 MapId, TeamId teamId);
bool AddGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, bool persist = true);
void RemoveGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, bool persist = false);
void LoadGraveyardZones();
GraveyardData const* FindGraveyardData(uint32 id, uint32 zone);
GossipText const* GetGossipText(uint32 Text_ID) const;
AreaTrigger const* GetAreaTrigger(uint32 trigger) const
{
@@ -1304,9 +1287,6 @@ class ObjectMgr
return _gossipMenuItemsStore.equal_range(uiMenuId);
}
// for wintergrasp only
GraveyardContainer GraveyardStore;
static void AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data);
static inline void GetLocaleString(const StringVector& data, int loc_idx, std::string& value)
{
+3 -3
View File
@@ -24,6 +24,7 @@
#include "Chat.h"
#include "BattlegroundMgr.h"
#include "ScriptMgr.h"
#include "GameGraveyard.h"
#define MOVEMENT_PACKET_TIME_DELAY 0
@@ -487,11 +488,10 @@ void WorldSession::HandleMovementOpcodes(WorldPacket & recvData)
}
else if (!plrMover->HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_IS_OUT_OF_BOUNDS))
{
WorldSafeLocsEntry const* grave = sObjectMgr->GetClosestGraveyard(plrMover->GetPositionX(), plrMover->GetPositionY(), plrMover->GetPositionZ(), plrMover->GetMapId(), plrMover->GetTeamId());
GraveyardStruct const* grave = sGraveyard->GetClosestGraveyard(plrMover->GetPositionX(), plrMover->GetPositionY(), plrMover->GetPositionZ(), plrMover->GetMapId(), plrMover->GetTeamId());
if (grave)
{
plrMover->TeleportTo(grave->map_id, grave->x, grave->y, grave->z, plrMover->GetOrientation());
plrMover->TeleportTo(grave->Map, grave->x, grave->y, grave->z, plrMover->GetOrientation());
plrMover->Relocate(grave->x, grave->y, grave->z, plrMover->GetOrientation());
}
}
+5 -4
View File
@@ -25,6 +25,7 @@
#include "ScriptMgr.h"
#include "CreatureAI.h"
#include "SpellInfo.h"
#include "GameGraveyard.h"
enum StableResultCode
{
@@ -446,10 +447,10 @@ void WorldSession::SendSpiritResurrect()
_player->DurabilityLossAll(0.25f, true);
// get corpse nearest graveyard
WorldSafeLocsEntry const* corpseGrave = NULL;
GraveyardStruct const* corpseGrave = NULL;
Corpse* corpse = _player->GetCorpse();
if (corpse)
corpseGrave = sObjectMgr->GetClosestGraveyard(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetMapId(), _player->GetTeamId());
corpseGrave = sGraveyard->GetClosestGraveyard(corpse->GetPositionX(), corpse->GetPositionY(), corpse->GetPositionZ(), corpse->GetMapId(), _player->GetTeamId());
// now can spawn bones
_player->SpawnCorpseBones();
@@ -457,10 +458,10 @@ void WorldSession::SendSpiritResurrect()
// teleport to nearest from corpse graveyard, if different from nearest to player ghost
if (corpseGrave)
{
WorldSafeLocsEntry const* ghostGrave = sObjectMgr->GetClosestGraveyard(_player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeamId());
GraveyardStruct const* ghostGrave = sGraveyard->GetClosestGraveyard(_player->GetPositionX(), _player->GetPositionY(), _player->GetPositionZ(), _player->GetMapId(), _player->GetTeamId());
if (corpseGrave != ghostGrave)
_player->TeleportTo(corpseGrave->map_id, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation());
_player->TeleportTo(corpseGrave->Map, corpseGrave->x, corpseGrave->y, corpseGrave->z, _player->GetOrientation());
// or update at original position
//else
// _player->UpdateObjectVisibility(); // xinef: not needed, called in ResurrectPlayer
+371
View File
@@ -0,0 +1,371 @@
#include "GameGraveyard.h"
#include "MapManager.h"
#include "DBCStores.h"
#include "Log.h"
void Graveyard::LoadGraveyardFromDB()
{
uint32 oldMSTime = getMSTime();
_graveyardStore.clear();
QueryResult result = WorldDatabase.Query("SELECT ID, Map, x, y, z, Comment FROM game_graveyard");
if (!result)
{
sLog->outString(">> Loaded 0 graveyard. Table `game_graveyard` is empty!");
sLog->outString();
return;
}
int32 Count = 0;
do
{
Field* fields = result->Fetch();
uint32 ID = fields[0].GetUInt32();
GraveyardStruct Graveyard;
Graveyard.Map = fields[1].GetUInt32();
Graveyard.x = fields[2].GetFloat();
Graveyard.y = fields[3].GetFloat();
Graveyard.z = fields[4].GetFloat();
Graveyard.name = fields[5].GetString();
if (!Utf8toWStr(Graveyard.name, Graveyard.wnameLow))
{
sLog->outErrorDb("Wrong UTF8 name for id %u in `game_graveyard` table, ignoring.", ID);
continue;
}
wstrToLower(Graveyard.wnameLow);
_graveyardStore[ID] = Graveyard;
++Count;
} while (result->NextRow());
sLog->outString(">> Loaded %i graveyard in %u ms", Count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
GraveyardStruct const* Graveyard::GetGraveyard(uint32 ID) const
{
GraveyardContainer::const_iterator itr = _graveyardStore.find(ID);
if (itr != _graveyardStore.end())
return &itr->second;
return NULL;
}
GraveyardStruct const* Graveyard::GetDefaultGraveyard(TeamId teamId)
{
enum DefaultGraveyard
{
HORDE_GRAVEYARD = 10, // Crossroads
ALLIANCE_GRAVEYARD = 4, // Westfall
};
return sGraveyard->GetGraveyard(teamId == TEAM_HORDE ? HORDE_GRAVEYARD : ALLIANCE_GRAVEYARD);
}
GraveyardStruct const* Graveyard::GetClosestGraveyard(float x, float y, float z, uint32 MapId, TeamId teamId)
{
// search for zone associated closest graveyard
uint32 zoneId = sMapMgr->GetZoneId(MapId, x, y, z);
if (!zoneId)
{
if (z > -500)
{
sLog->outError("ZoneId not found for map %u coords (%f, %f, %f)", MapId, x, y, z);
return GetDefaultGraveyard(teamId);
}
}
// Simulate std. algorithm:
// found some graveyard associated to (ghost_zone, ghost_map)
//
// if mapId == graveyard.mapId (ghost in plain zone or city or battleground) and search graveyard at same map
// then check faction
// if mapId != graveyard.mapId (ghost in instance) and search any graveyard associated
// then check faction
GraveyardMapBounds range = GraveyardStore.equal_range(zoneId);
MapEntry const* map = sMapStore.LookupEntry(MapId);
// not need to check validity of map object; MapId _MUST_ be valid here
if (range.first == range.second && !map->IsBattlegroundOrArena())
{
sLog->outErrorDb("Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.", zoneId, teamId);
return GetDefaultGraveyard(teamId);
}
// at corpse map
bool foundNear = false;
float distNear = 10000;
GraveyardStruct const* entryNear = NULL;
// at entrance map for corpse map
bool foundEntr = false;
float distEntr = 10000;
GraveyardStruct const* entryEntr = NULL;
// some where other
GraveyardStruct const* entryFar = NULL;
MapEntry const* mapEntry = sMapStore.LookupEntry(MapId);
for (; range.first != range.second; ++range.first)
{
GraveyardData const& data = range.first->second;
GraveyardStruct const* entry = sGraveyard->GetGraveyard(data.safeLocId);
if (!entry)
{
sLog->outErrorDb("Table `game_graveyard_zone` has record for not existing `game_graveyard` table %u, skipped.", data.safeLocId);
continue;
}
// skip enemy faction graveyard
// team == 0 case can be at call from .neargrave
if (data.teamId != TEAM_NEUTRAL && teamId != TEAM_NEUTRAL && data.teamId != teamId)
continue;
// find now nearest graveyard at other map
if (MapId != entry->Map)
{
// if find graveyard at different map from where entrance placed (or no entrance data), use any first
if (!mapEntry
|| mapEntry->entrance_map < 0
|| uint32(mapEntry->entrance_map) != entry->Map
|| (mapEntry->entrance_x == 0 && mapEntry->entrance_y == 0))
{
// not have any corrdinates for check distance anyway
entryFar = entry;
continue;
}
// at entrance map calculate distance (2D);
float dist2 = (entry->x - mapEntry->entrance_x)*(entry->x - mapEntry->entrance_x)
+ (entry->y - mapEntry->entrance_y)*(entry->y - mapEntry->entrance_y);
if (foundEntr)
{
if (dist2 < distEntr)
{
distEntr = dist2;
entryEntr = entry;
}
}
else
{
foundEntr = true;
distEntr = dist2;
entryEntr = entry;
}
}
// find now nearest graveyard at same map
else
{
float dist2 = (entry->x - x)*(entry->x - x) + (entry->y - y)*(entry->y - y) + (entry->z - z)*(entry->z - z);
if (foundNear)
{
if (dist2 < distNear)
{
distNear = dist2;
entryNear = entry;
}
}
else
{
foundNear = true;
distNear = dist2;
entryNear = entry;
}
}
}
if (entryNear)
return entryNear;
if (entryEntr)
return entryEntr;
return entryFar;
}
GraveyardData const* Graveyard::FindGraveyardData(uint32 id, uint32 zoneId)
{
GraveyardMapBounds range = GraveyardStore.equal_range(zoneId);
for (; range.first != range.second; ++range.first)
{
GraveyardData const& data = range.first->second;
if (data.safeLocId == id)
return &data;
}
return NULL;
}
bool Graveyard::AddGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, bool persist /*= true*/)
{
if (FindGraveyardData(id, zoneId))
return false;
// add link to loaded data
GraveyardData data;
data.safeLocId = id;
data.teamId = teamId;
GraveyardStore.insert(WGGraveyardContainer::value_type(zoneId, data));
// add link to DB
if (persist)
{
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_INS_GRAVEYARD_ZONE);
stmt->setUInt32(0, id);
stmt->setUInt32(1, zoneId);
// Xinef: DB Data compatibility...
stmt->setUInt16(2, uint16(teamId == TEAM_NEUTRAL ? 0 : (teamId == TEAM_ALLIANCE ? ALLIANCE : HORDE)));
WorldDatabase.Execute(stmt);
}
return true;
}
void Graveyard::RemoveGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, bool persist /*= false*/)
{
GraveyardMapBoundsNonConst range = GraveyardStore.equal_range(zoneId);
if (range.first == range.second)
{
sLog->outError("Table `game_graveyard_zone` incomplete: Zone %u Team %u does not have a linked graveyard.", zoneId, teamId);
return;
}
bool found = false;
for (; range.first != range.second; ++range.first)
{
GraveyardData & data = range.first->second;
// skip not matching safezone id
if (data.safeLocId != id)
continue;
// skip enemy faction graveyard at same map (normal area, city, or battleground)
// team == 0 case can be at call from .neargrave
if (data.teamId != TEAM_NEUTRAL && teamId != TEAM_NEUTRAL && data.teamId != teamId)
continue;
found = true;
break;
}
// no match, return
if (!found)
return;
// remove from links
GraveyardStore.erase(range.first);
// remove link from DB
if (persist)
{
PreparedStatement* stmt = WorldDatabase.GetPreparedStatement(WORLD_DEL_GRAVEYARD_ZONE);
stmt->setUInt32(0, id);
stmt->setUInt32(1, zoneId);
// Xinef: DB Data compatibility...
stmt->setUInt16(2, uint16(teamId == TEAM_NEUTRAL ? 0 : (teamId == TEAM_ALLIANCE ? ALLIANCE : HORDE)));
WorldDatabase.Execute(stmt);
}
}
void Graveyard::LoadGraveyardZones()
{
uint32 oldMSTime = getMSTime();
GraveyardStore.clear(); // need for reload case
// 0 1 2
QueryResult result = WorldDatabase.Query("SELECT id, ghost_zone, faction FROM game_graveyard_zone");
if (!result)
{
sLog->outString(">> Loaded 0 graveyard-zone links. DB table `game_graveyard_zone` is empty.");
sLog->outString();
return;
}
uint32 count = 0;
do
{
++count;
Field* fields = result->Fetch();
uint32 safeLocId = fields[0].GetUInt32();
uint32 zoneId = fields[1].GetUInt32();
uint32 team = fields[2].GetUInt16();
TeamId teamId = team == 0 ? TEAM_NEUTRAL : (team == ALLIANCE ? TEAM_ALLIANCE : TEAM_HORDE);
GraveyardStruct const* entry = sGraveyard->GetGraveyard(safeLocId);
if (!entry)
{
sLog->outErrorDb("Table `game_graveyard_zone` has a record for not existing `game_graveyard` table %u, skipped.", safeLocId);
continue;
}
AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(zoneId);
if (!areaEntry)
{
sLog->outErrorDb("Table `game_graveyard_zone` has a record for not existing zone id (%u), skipped.", zoneId);
continue;
}
if (areaEntry->zone != 0)
{
sLog->outErrorDb("Table `game_graveyard_zone` has a record for subzone id (%u) instead of zone, skipped.", zoneId);
continue;
}
if (team != 0 && team != HORDE && team != ALLIANCE)
{
sLog->outErrorDb("Table `game_graveyard_zone` has a record for non player faction (%u), skipped.", team);
continue;
}
if (!AddGraveyardLink(safeLocId, zoneId, teamId, false))
sLog->outErrorDb("Table `game_graveyard_zone` has a duplicate record for Graveyard (ID: %u) and Zone (ID: %u), skipped.", safeLocId, zoneId);
} while (result->NextRow());
sLog->outString(">> Loaded %u graveyard-zone links in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
GraveyardStruct const* Graveyard::GetGraveyard(const std::string& name) const
{
// explicit name case
std::wstring wname;
if (!Utf8toWStr(name, wname))
return NULL;
// converting string that we try to find to lower case
wstrToLower(wname);
// Alternative first GameTele what contains wnameLow as substring in case no GameTele location found
const GraveyardStruct* alt = NULL;
for (GraveyardContainer::const_iterator itr = _graveyardStore.begin(); itr != _graveyardStore.end(); ++itr)
{
if (itr->second.wnameLow == wname)
return &itr->second;
else if (alt == NULL && itr->second.wnameLow.find(wname) != std::wstring::npos)
alt = &itr->second;
}
return alt;
}
+58
View File
@@ -0,0 +1,58 @@
#ifndef _GAMEGRAVEYARD_H_
#define _GAMEGRAVEYARD_H_
#include "Common.h"
#include "SharedDefines.h"
#include <ace/Singleton.h>
struct GraveyardStruct
{
uint32 ID;
uint32 Map;
float x;
float y;
float z;
std::string name;
std::wstring wnameLow;
};
struct GraveyardData
{
uint32 safeLocId;
TeamId teamId;
};
typedef std::multimap<uint32, GraveyardData> WGGraveyardContainer;
typedef std::pair<WGGraveyardContainer::const_iterator, WGGraveyardContainer::const_iterator> GraveyardMapBounds;
typedef std::pair<WGGraveyardContainer::iterator, WGGraveyardContainer::iterator> GraveyardMapBoundsNonConst;
class Graveyard
{
friend class ACE_Singleton<Graveyard, ACE_Null_Mutex>;
public:
typedef UNORDERED_MAP<uint32, GraveyardStruct> GraveyardContainer;
GraveyardStruct const* GetGraveyard(uint32 ID) const;
GraveyardStruct const* GetGraveyard(const std::string& name) const;
GraveyardStruct const* GetDefaultGraveyard(TeamId teamId);
GraveyardStruct const* GetClosestGraveyard(float x, float y, float z, uint32 MapId, TeamId teamId);
GraveyardData const* FindGraveyardData(uint32 id, uint32 zone);
GraveyardContainer const& GetGraveyardData() const { return _graveyardStore; }
bool AddGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, bool persist = true);
void RemoveGraveyardLink(uint32 id, uint32 zoneId, TeamId teamId, bool persist = false);
void LoadGraveyardZones();
void LoadGraveyardFromDB();
private:
GraveyardContainer _graveyardStore;
// for wintergrasp only
WGGraveyardContainer GraveyardStore;
};
#define sGraveyard ACE_Singleton<Graveyard, ACE_Null_Mutex>::instance()
#endif // _GAMEGRAVEYARD_H_
+5 -4
View File
@@ -22,6 +22,7 @@
#include "BattlefieldMgr.h"
#include "InstanceScript.h"
#include "Player.h"
#include "GameGraveyard.h"
bool IsPrimaryProfessionSkill(uint32 skill)
{
@@ -6335,10 +6336,10 @@ void SpellMgr::LoadDbcDataCorrections()
// Ring of Valor starting Locations
WorldSafeLocsEntry const* entry = sWorldSafeLocsStore.LookupEntry(1364);
const_cast<WorldSafeLocsEntry*>(entry)->z += 6.0f;
entry = sWorldSafeLocsStore.LookupEntry(1365);
const_cast<WorldSafeLocsEntry*>(entry)->z += 6.0f;
GraveyardStruct const* entry = sGraveyard->GetGraveyard(1364);
const_cast<GraveyardStruct*>(entry)->z += 6.0f;
entry = sGraveyard->GetGraveyard(1365);
const_cast<GraveyardStruct*>(entry)->z += 6.0f;
LockEntry* key = const_cast<LockEntry*>(sLockStore.LookupEntry(36)); // 3366 Opening, allows to open without proper key
key->Type[2] = LOCK_KEY_NONE;
+5 -1
View File
@@ -75,6 +75,7 @@
#include "WhoListCache.h"
#include "AsyncAuctionListing.h"
#include "SavingSystem.h"
#include "GameGraveyard.h"
#include <VMapManager2.h>
#ifdef ELUNA
#include "LuaEngine.h"
@@ -1413,6 +1414,9 @@ void World::SetInitialWorldSettings()
LoadDBCStores(m_dataPath);
DetectDBCLang();
sLog->outString("Loading Game Graveyard...");
sGraveyard->LoadGraveyardFromDB();
sLog->outString("Loading spell dbc data corrections...");
sSpellMgr->LoadDbcDataCorrections();
@@ -1641,7 +1645,7 @@ void World::SetInitialWorldSettings()
sLFGMgr->LoadRewards();
sLog->outString("Loading Graveyard-zone links...");
sObjectMgr->LoadGraveyardZones();
sGraveyard->LoadGraveyardZones();
sLog->outString("Loading spell pet auras...");
sSpellMgr->LoadSpellPetAuras();
+5 -4
View File
@@ -18,6 +18,7 @@ EndScriptData */
#include "Chat.h"
#include "Language.h"
#include "Player.h"
#include "GameGraveyard.h"
class go_commandscript : public CommandScript
{
@@ -171,7 +172,7 @@ public:
if (!graveyardId)
return false;
WorldSafeLocsEntry const* gy = sWorldSafeLocsStore.LookupEntry(graveyardId);
GraveyardStruct const* gy = sGraveyard->GetGraveyard(graveyardId);
if (!gy)
{
handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDNOEXIST, graveyardId);
@@ -179,9 +180,9 @@ public:
return false;
}
if (!MapManager::IsValidMapCoord(gy->map_id, gy->x, gy->y, gy->z))
if (!MapManager::IsValidMapCoord(gy->Map, gy->x, gy->y, gy->z))
{
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, gy->x, gy->y, gy->map_id);
handler->PSendSysMessage(LANG_INVALID_TARGET_COORD, gy->x, gy->y, gy->Map);
handler->SetSentErrorMessage(true);
return false;
}
@@ -196,7 +197,7 @@ public:
else
player->SaveRecallPosition();
player->TeleportTo(gy->map_id, gy->x, gy->y, gy->z, player->GetOrientation());
player->TeleportTo(gy->Map, gy->x, gy->y, gy->z, player->GetOrientation());
return true;
}
+5 -4
View File
@@ -27,6 +27,7 @@
#include "GroupMgr.h"
#include "BattlegroundMgr.h"
#include "MapManager.h"
#include "GameGraveyard.h"
class misc_commandscript : public CommandScript
{
@@ -1268,7 +1269,7 @@ public:
else
return false;
WorldSafeLocsEntry const* graveyard = sWorldSafeLocsStore.LookupEntry(graveyardId);
GraveyardStruct const* graveyard = sGraveyard->GetGraveyard(graveyardId);
if (!graveyard)
{
@@ -1289,7 +1290,7 @@ public:
return false;
}
if (sObjectMgr->AddGraveyardLink(graveyardId, zoneId, teamId))
if (sGraveyard->AddGraveyardLink(graveyardId, zoneId, teamId))
handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDLINKED, graveyardId, zoneId);
else
handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDALRLINKED, graveyardId, zoneId);
@@ -1315,13 +1316,13 @@ public:
Player* player = handler->GetSession()->GetPlayer();
uint32 zone_id = player->GetZoneId();
WorldSafeLocsEntry const* graveyard = sObjectMgr->GetClosestGraveyard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), teamId);
GraveyardStruct const* graveyard = sGraveyard->GetClosestGraveyard(player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetMapId(), teamId);
if (graveyard)
{
uint32 graveyardId = graveyard->ID;
GraveyardData const* data = sObjectMgr->FindGraveyardData(graveyardId, zone_id);
GraveyardData const* data = sGraveyard->FindGraveyardData(graveyardId, zone_id);
if (!data)
{
handler->PSendSysMessage(LANG_COMMAND_GRAVEYARDERROR, graveyardId);
+11 -1
View File
@@ -29,6 +29,7 @@ EndScriptData */
#include "TicketMgr.h"
#include "WardenCheckMgr.h"
#include "WaypointManager.h"
#include "GameGraveyard.h"
class reload_commandscript : public CommandScript
{
@@ -80,6 +81,7 @@ public:
{ "disenchant_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesDisenchantCommand, "" },
{ "event_scripts", SEC_ADMINISTRATOR, true, &HandleReloadEventScriptsCommand, "" },
{ "fishing_loot_template", SEC_ADMINISTRATOR, true, &HandleReloadLootTemplatesFishingCommand, "" },
{ "game_graveyard", SEC_ADMINISTRATOR, true, &HandleReloadGameGraveyardCommand, "" },
{ "game_graveyard_zone", SEC_ADMINISTRATOR, true, &HandleReloadGameGraveyardZoneCommand, "" },
{ "game_tele", SEC_ADMINISTRATOR, true, &HandleReloadGameTeleCommand, "" },
{ "gameobject_questender", SEC_ADMINISTRATOR, true, &HandleReloadGOQuestEnderCommand, "" },
@@ -1022,7 +1024,7 @@ public:
{
sLog->outString("Re-Loading Graveyard-zone links...");
sObjectMgr->LoadGraveyardZones();
sGraveyard->LoadGraveyardZones();
handler->SendGlobalGMSysMessage("DB table `game_graveyard_zone` reloaded.");
@@ -1203,6 +1205,14 @@ public:
handler->SendGlobalGMSysMessage("Vehicle template accessories reloaded.");
return true;
}
static bool HandleReloadGameGraveyardCommand(ChatHandler* handler, const char* /*args*/)
{
sLog->outString("Reloading game_graveyard table...");
sGraveyard->LoadGraveyardFromDB();
handler->SendGlobalGMSysMessage("DB table `game_graveyard` reloaded.");
return true;
}
};
void AddSC_reload_commandscript()
@@ -28,6 +28,7 @@
#include "CombatAI.h"
#include "Player.h"
#include "PoolMgr.h"
#include "GameGraveyard.h"
#include "World.h"
#define GOSSIP_HELLO_DEMO1 "Build catapult."
@@ -227,8 +228,8 @@ class npc_wg_spirit_guide : public CreatureScript
GraveyardVect gy = wintergrasp->GetGraveyardVector();
for (uint8 i = 0; i < gy.size(); i++)
if (action - GOSSIP_ACTION_INFO_DEF == i && gy[i]->GetControlTeamId() == player->GetTeamId())
if (WorldSafeLocsEntry const* safeLoc = sWorldSafeLocsStore.LookupEntry(gy[i]->GetGraveyardId()))
player->TeleportTo(safeLoc->map_id, safeLoc->x, safeLoc->y, safeLoc->z, 0);
if (GraveyardStruct const* safeLoc = sGraveyard->GetGraveyard(gy[i]->GetGraveyardId()))
player->TeleportTo(safeLoc->Map, safeLoc->x, safeLoc->y, safeLoc->z, 0);
}
return true;
}
@@ -16,6 +16,7 @@
#include "Language.h"
#include "World.h"
#include "GossipDef.h"
#include "GameGraveyard.h"
OPvPCapturePointEP_EWT::OPvPCapturePointEP_EWT(OutdoorPvP* pvp)
: OPvPCapturePoint(pvp), m_TowerState(EP_TS_N), m_UnitsSummonedSideId(TEAM_NEUTRAL)
@@ -419,8 +420,8 @@ void OPvPCapturePointEP_CGT::LinkGraveyard(TeamId teamId)
{
if (m_GraveyardSide != teamId)
{
sObjectMgr->RemoveGraveyardLink(EP_GraveYardId, EP_GraveYardZone, m_GraveyardSide, false);
sObjectMgr->AddGraveyardLink(EP_GraveYardId, EP_GraveYardZone, teamId, false);
sGraveyard->RemoveGraveyardLink(EP_GraveYardId, EP_GraveYardZone, m_GraveyardSide, false);
sGraveyard->AddGraveyardLink(EP_GraveYardId, EP_GraveYardZone, teamId, false);
m_GraveyardSide = teamId;
}
}
@@ -12,6 +12,7 @@
#include "WorldPacket.h"
#include "Language.h"
#include "World.h"
#include "GameGraveyard.h"
OutdoorPvPNA::OutdoorPvPNA()
{
@@ -120,7 +121,7 @@ void OPvPCapturePointNA::DeSpawnGOs()
void OPvPCapturePointNA::FactionTakeOver(TeamId teamId)
{
if (m_ControllingFaction != TEAM_NEUTRAL)
sObjectMgr->RemoveGraveyardLink(NA_HALAA_GRAVEYARD, NA_HALAA_GRAVEYARD_ZONE, m_ControllingFaction, false);
sGraveyard->RemoveGraveyardLink(NA_HALAA_GRAVEYARD, NA_HALAA_GRAVEYARD_ZONE, m_ControllingFaction, false);
if (m_ControllingFaction == TEAM_ALLIANCE)
sWorld->SendZoneText(NA_HALAA_GRAVEYARD_ZONE, sObjectMgr->GetTrinityStringForDBCLocale(LANG_OPVP_NA_LOSE_A));
else if (m_ControllingFaction == TEAM_HORDE)
@@ -128,7 +129,7 @@ void OPvPCapturePointNA::FactionTakeOver(TeamId teamId)
m_ControllingFaction = teamId;
if (m_ControllingFaction != TEAM_NEUTRAL)
sObjectMgr->AddGraveyardLink(NA_HALAA_GRAVEYARD, NA_HALAA_GRAVEYARD_ZONE, m_ControllingFaction, false);
sGraveyard->AddGraveyardLink(NA_HALAA_GRAVEYARD, NA_HALAA_GRAVEYARD_ZONE, m_ControllingFaction, false);
DeSpawnGOs();
DeSpawnNPCs();
SpawnGOsForTeam(teamId);
@@ -14,6 +14,7 @@
#include "WorldPacket.h"
#include "GossipDef.h"
#include "World.h"
#include "GameGraveyard.h"
OPvPCapturePointZM_Beacon::OPvPCapturePointZM_Beacon(OutdoorPvP* pvp, ZM_BeaconType type)
: OPvPCapturePoint(pvp), m_TowerType(type), m_TowerState(ZM_TOWERSTATE_N)
@@ -214,8 +215,8 @@ int32 OPvPCapturePointZM_GraveYard::HandleOpenGo(Player* player, uint64 guid)
m_GraveYardState = ZM_GRAVEYARD_A;
DelObject(0); // only one gotype is used in the whole outdoor pvp, no need to call it a constant
AddObject(0, ZM_Banner_A.entry, ZM_Banner_A.map, ZM_Banner_A.x, ZM_Banner_A.y, ZM_Banner_A.z, ZM_Banner_A.o, ZM_Banner_A.rot0, ZM_Banner_A.rot1, ZM_Banner_A.rot2, ZM_Banner_A.rot3);
sObjectMgr->RemoveGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, TEAM_HORDE); // rem gy
sObjectMgr->AddGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, TEAM_ALLIANCE, false); // add gy
sGraveyard->RemoveGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, TEAM_HORDE); // rem gy
sGraveyard->AddGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, TEAM_ALLIANCE, false); // add gy
m_PvP->TeamApplyBuff(TEAM_ALLIANCE, ZM_CAPTURE_BUFF, 0, player);
player->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_A);
sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetTrinityStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_A));
@@ -227,8 +228,8 @@ int32 OPvPCapturePointZM_GraveYard::HandleOpenGo(Player* player, uint64 guid)
m_GraveYardState = ZM_GRAVEYARD_H;
DelObject(0); // only one gotype is used in the whole outdoor pvp, no need to call it a constant
AddObject(0, ZM_Banner_H.entry, ZM_Banner_H.map, ZM_Banner_H.x, ZM_Banner_H.y, ZM_Banner_H.z, ZM_Banner_H.o, ZM_Banner_H.rot0, ZM_Banner_H.rot1, ZM_Banner_H.rot2, ZM_Banner_H.rot3);
sObjectMgr->RemoveGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, TEAM_ALLIANCE); // rem gy
sObjectMgr->AddGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, TEAM_HORDE, false); // add gy
sGraveyard->RemoveGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, TEAM_ALLIANCE); // rem gy
sGraveyard->AddGraveyardLink(ZM_GRAVEYARD_ID, ZM_GRAVEYARD_ZONE, TEAM_HORDE, false); // add gy
m_PvP->TeamApplyBuff(TEAM_HORDE, ZM_CAPTURE_BUFF, 0, player);
player->RemoveAurasDueToSpell(ZM_BATTLE_STANDARD_H);
sWorld->SendZoneText(ZM_GRAVEYARD_ZONE, sObjectMgr->GetTrinityStringForDBCLocale(LANG_OPVP_ZM_CAPTURE_GY_H));