aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2014-07-13 16:52:38 -0500
committerSubv <subv2112@gmail.com>2014-07-13 16:52:38 -0500
commitdfdc19f3bc57757965d1d3b760a27622e411eb05 (patch)
tree08025cfd4bbdef881149291e926eaf1d4676f441 /src/server/game
parentf14399d7887b221eb61378863c9c314adbcdebc1 (diff)
Merge branch `master` into `boost`
Conflicts: BattlegroundMgr.h
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/Accounts/RBAC.h2
-rw-r--r--src/server/game/Battlefield/Zones/BattlefieldWG.cpp8
-rw-r--r--src/server/game/Battlefield/Zones/BattlefieldWG.h8
-rw-r--r--src/server/game/Battlegrounds/Battleground.cpp36
-rw-r--r--src/server/game/Battlegrounds/Battleground.h24
-rw-r--r--src/server/game/Battlegrounds/BattlegroundMgr.cpp299
-rw-r--r--src/server/game/Battlegrounds/BattlegroundMgr.h82
-rw-r--r--src/server/game/Battlegrounds/BattlegroundQueue.cpp5
-rw-r--r--src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp12
-rw-r--r--src/server/game/DungeonFinding/LFGMgr.cpp10
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp3
-rw-r--r--src/server/game/Entities/GameObject/GameObject.cpp11
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h2
-rw-r--r--src/server/game/Entities/Player/Player.cpp262
-rw-r--r--src/server/game/Entities/Player/Player.h21
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp28
-rw-r--r--src/server/game/Groups/Group.cpp1
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp4
-rw-r--r--src/server/game/Handlers/NPCHandler.cpp2
-rw-r--r--src/server/game/Handlers/SkillHandler.cpp2
-rw-r--r--src/server/game/Instances/InstanceScript.cpp19
-rw-r--r--src/server/game/Instances/InstanceScript.h4
-rw-r--r--src/server/game/Maps/MapManager.cpp18
-rw-r--r--src/server/game/Movement/PathGenerator.cpp26
-rw-r--r--src/server/game/Scripting/ScriptLoader.cpp2
-rw-r--r--src/server/game/Spells/Spell.cpp1
-rw-r--r--src/server/game/Spells/SpellEffects.cpp9
-rw-r--r--src/server/game/World/World.cpp2
28 files changed, 444 insertions, 459 deletions
diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h
index 9ce1f9bb67a..f2637a5febc 100644
--- a/src/server/game/Accounts/RBAC.h
+++ b/src/server/game/Accounts/RBAC.h
@@ -534,7 +534,7 @@ enum RBACPermissions
RBAC_PERM_COMMAND_RELOAD_COMMAND = 628,
RBAC_PERM_COMMAND_RELOAD_CONDITIONS = 629,
RBAC_PERM_COMMAND_RELOAD_CONFIG = 630,
- RBAC_PERM_UNUSED_631 = 631, // unused
+ RBAC_PERM_COMMAND_RELOAD_BATTLEGROUND_TEMPLATE = 631,
RBAC_PERM_UNUSED_632 = 632, // unused
RBAC_PERM_COMMAND_RELOAD_CREATURE_LINKED_RESPAWN = 633,
RBAC_PERM_COMMAND_RELOAD_CREATURE_LOOT_TEMPLATE = 634,
diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
index 41539b9cda6..b16ac1e84de 100644
--- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
+++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp
@@ -683,9 +683,9 @@ void BattlefieldWG::PromotePlayer(Player* killer)
if (!m_isActive)
return;
// Updating rank of player
- if (Aura* aur = killer->GetAura(SPELL_RECRUIT))
+ if (Aura* auraRecruit = killer->GetAura(SPELL_RECRUIT))
{
- if (aur->GetStackAmount() >= 5)
+ if (auraRecruit->GetStackAmount() >= 5)
{
killer->RemoveAura(SPELL_RECRUIT);
killer->CastSpell(killer, SPELL_CORPORAL, true);
@@ -694,9 +694,9 @@ void BattlefieldWG::PromotePlayer(Player* killer)
else
killer->CastSpell(killer, SPELL_RECRUIT, true);
}
- else if (Aura* aur = killer->GetAura(SPELL_CORPORAL))
+ else if (Aura* auraCorporal = killer->GetAura(SPELL_CORPORAL))
{
- if (aur->GetStackAmount() >= 5)
+ if (auraCorporal->GetStackAmount() >= 5)
{
killer->RemoveAura(SPELL_CORPORAL);
killer->CastSpell(killer, SPELL_LIEUTENANT, true);
diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.h b/src/server/game/Battlefield/Zones/BattlefieldWG.h
index 3a64458c48b..c01e6eb22ee 100644
--- a/src/server/game/Battlefield/Zones/BattlefieldWG.h
+++ b/src/server/game/Battlefield/Zones/BattlefieldWG.h
@@ -1277,10 +1277,10 @@ struct BfWGGameObjectBuilding
for (uint8 i = 0; i < AttackTowers[towerid - 4].nbObject; i++)
{
WintergraspObjectPositionData gobData = AttackTowers[towerid - 4].GameObject[i];
- if (GameObject* go = m_WG->SpawnGameObject(gobData.entryHorde, gobData.x, gobData.y, gobData.z, gobData.o))
- m_GameObjectList[TEAM_HORDE].insert(go->GetGUID());
- if (GameObject* go = m_WG->SpawnGameObject(gobData.entryAlliance, gobData.x, gobData.y, gobData.z, gobData.o))
- m_GameObjectList[TEAM_ALLIANCE].insert(go->GetGUID());
+ if (GameObject* goHorde = m_WG->SpawnGameObject(gobData.entryHorde, gobData.x, gobData.y, gobData.z, gobData.o))
+ m_GameObjectList[TEAM_HORDE].insert(goHorde->GetGUID());
+ if (GameObject* goAlliance = m_WG->SpawnGameObject(gobData.entryAlliance, gobData.x, gobData.y, gobData.z, gobData.o))
+ m_GameObjectList[TEAM_ALLIANCE].insert(goAlliance->GetGUID());
}
// Spawn associate npc bottom
diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp
index 4e077979b3e..a0d35d4c742 100644
--- a/src/server/game/Battlegrounds/Battleground.cpp
+++ b/src/server/game/Battlegrounds/Battleground.cpp
@@ -152,18 +152,6 @@ Battleground::Battleground()
m_StartMaxDist = 0.0f;
ScriptId = 0;
- m_TeamStartLocX[TEAM_ALLIANCE] = 0;
- m_TeamStartLocX[TEAM_HORDE] = 0;
-
- m_TeamStartLocY[TEAM_ALLIANCE] = 0;
- m_TeamStartLocY[TEAM_HORDE] = 0;
-
- m_TeamStartLocZ[TEAM_ALLIANCE] = 0;
- m_TeamStartLocZ[TEAM_HORDE] = 0;
-
- m_TeamStartLocO[TEAM_ALLIANCE] = 0;
- m_TeamStartLocO[TEAM_HORDE] = 0;
-
m_ArenaTeamIds[TEAM_ALLIANCE] = 0;
m_ArenaTeamIds[TEAM_HORDE] = 0;
@@ -300,16 +288,15 @@ inline void Battleground::_CheckSafePositions(uint32 diff)
{
m_ValidStartPositionTimer = 0;
- float x, y, z, o;
for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
if (Player* player = ObjectAccessor::FindPlayer(itr->first))
{
Position pos = player->GetPosition();
- GetTeamStartLoc(player->GetBGTeam(), x, y, z, o);
- if (pos.GetExactDistSq(x, y, z) > maxDist)
+ Position const* startPos = GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(player->GetBGTeam()));
+ if (pos.GetExactDistSq(startPos) > maxDist)
{
TC_LOG_DEBUG("bg.battleground", "BATTLEGROUND: Sending %s back to start location (map: %u) (possible exploit)", player->GetName().c_str(), GetMapId());
- player->TeleportTo(GetMapId(), x, y, z, o);
+ player->TeleportTo(GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation());
}
}
}
@@ -550,7 +537,7 @@ inline void Battleground::_ProcessJoin(uint32 diff)
}
// Announce BG starting
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE))
- sWorld->SendWorldText(LANG_BG_STARTED_ANNOUNCE_WORLD, GetName(), GetMinLevel(), GetMaxLevel());
+ sWorld->SendWorldText(LANG_BG_STARTED_ANNOUNCE_WORLD, GetName().c_str(), GetMinLevel(), GetMaxLevel());
}
}
}
@@ -614,13 +601,16 @@ inline Player* Battleground::_GetPlayerForTeam(uint32 teamId, BattlegroundPlayer
return player;
}
-void Battleground::SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O)
+void Battleground::SetTeamStartPosition(TeamId teamId, Position const& pos)
+{
+ ASSERT(teamId < TEAM_NEUTRAL);
+ StartPosition[teamId] = pos;
+}
+
+Position const* Battleground::GetTeamStartPosition(TeamId teamId) const
{
- TeamId idx = GetTeamIndexByTeamId(TeamID);
- m_TeamStartLocX[idx] = X;
- m_TeamStartLocY[idx] = Y;
- m_TeamStartLocZ[idx] = Z;
- m_TeamStartLocO[idx] = O;
+ ASSERT(teamId < TEAM_NEUTRAL);
+ return &StartPosition[teamId];
}
void Battleground::SendPacketToAll(WorldPacket* packet)
diff --git a/src/server/game/Battlegrounds/Battleground.h b/src/server/game/Battlegrounds/Battleground.h
index 2904ec1dc7e..468b73c51ab 100644
--- a/src/server/game/Battlegrounds/Battleground.h
+++ b/src/server/game/Battlegrounds/Battleground.h
@@ -23,6 +23,7 @@
#include "SharedDefines.h"
#include "DBCEnums.h"
#include "WorldPacket.h"
+#include "Object.h"
class Creature;
class GameObject;
@@ -34,7 +35,6 @@ class WorldPacket;
class BattlegroundMap;
struct BattlegroundScore;
-struct Position;
struct PvPDifficultyEntry;
struct WorldSafeLocsEntry;
@@ -256,7 +256,7 @@ class Battleground
/* Battleground */
// Get methods:
- char const* GetName() const { return m_Name; }
+ std::string const& GetName() const { return m_Name; }
BattlegroundTypeId GetTypeID(bool GetRandom = false) const { return GetRandom ? m_RandomTypeID : m_TypeID; }
BattlegroundBracketId GetBracketId() const { return m_BracketId; }
uint32 GetInstanceID() const { return m_InstanceID; }
@@ -282,7 +282,7 @@ class Battleground
bool IsRandom() const { return m_IsRandom; }
// Set methods:
- void SetName(char const* Name) { m_Name = Name; }
+ void SetName(std::string const& name) { m_Name = name; }
void SetTypeID(BattlegroundTypeId TypeID) { m_TypeID = TypeID; }
void SetRandomTypeID(BattlegroundTypeId TypeID) { m_RandomTypeID = TypeID; }
//here we can count minlevel and maxlevel for players
@@ -352,15 +352,8 @@ class Battleground
BattlegroundMap* GetBgMap() const { ASSERT(m_Map); return m_Map; }
BattlegroundMap* FindBgMap() const { return m_Map; }
- void SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O);
- void GetTeamStartLoc(uint32 TeamID, float &X, float &Y, float &Z, float &O) const
- {
- TeamId idx = GetTeamIndexByTeamId(TeamID);
- X = m_TeamStartLocX[idx];
- Y = m_TeamStartLocY[idx];
- Z = m_TeamStartLocZ[idx];
- O = m_TeamStartLocO[idx];
- }
+ void SetTeamStartPosition(TeamId teamId, Position const& pos);
+ Position const* GetTeamStartPosition(TeamId teamId) const;
void SetStartMaxDist(float startMaxDist) { m_StartMaxDist = startMaxDist; }
float GetStartMaxDist() const { return m_StartMaxDist; }
@@ -559,7 +552,7 @@ class Battleground
bool m_IsRated; // is this battle rated?
bool m_PrematureCountDown;
uint32 m_PrematureCountDownTimer;
- char const* m_Name;
+ std::string m_Name;
/* Pre- and post-update hooks */
@@ -669,10 +662,7 @@ class Battleground
// Start location
uint32 m_MapId;
BattlegroundMap* m_Map;
- float m_TeamStartLocX[BG_TEAMS_COUNT];
- float m_TeamStartLocY[BG_TEAMS_COUNT];
- float m_TeamStartLocZ[BG_TEAMS_COUNT];
- float m_TeamStartLocO[BG_TEAMS_COUNT];
+ Position StartPosition[BG_TEAMS_COUNT];
float m_StartMaxDist;
uint32 ScriptId;
};
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.cpp b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
index ef78594626a..615bbc12199 100644
--- a/src/server/game/Battlegrounds/BattlegroundMgr.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.cpp
@@ -343,20 +343,7 @@ uint32 BattlegroundMgr::CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeI
// create a new battleground that will really be used to play
Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId originalBgTypeId, PvPDifficultyEntry const* bracketEntry, uint8 arenaType, bool isRated)
{
- BattlegroundTypeId bgTypeId = originalBgTypeId;
- bool isRandom = false;
-
- switch (originalBgTypeId)
- {
- case BATTLEGROUND_RB:
- isRandom = true;
- /// Intentional fallback, "All Arenas" is random too
- case BATTLEGROUND_AA:
- bgTypeId = GetRandomBG(originalBgTypeId);
- break;
- default:
- break;
- }
+ BattlegroundTypeId bgTypeId = GetRandomBG(originalBgTypeId);
// get the template BG
Battleground* bg_template = GetBattlegroundTemplate(bgTypeId);
@@ -406,15 +393,15 @@ Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId original
break;
case BATTLEGROUND_RB:
case BATTLEGROUND_AA:
- bg = new Battleground(*bg_template);
- break;
default:
return NULL;
}
+ bool isRandom = bgTypeId != originalBgTypeId && !bg->isArena();
+
bg->SetBracket(bracketEntry);
bg->SetInstanceID(sMapMgr->GenerateInstanceId());
- bg->SetClientInstanceID(CreateClientVisibleInstanceId(isRandom ? BATTLEGROUND_RB : bgTypeId, bracketEntry->GetBracketId()));
+ bg->SetClientInstanceID(CreateClientVisibleInstanceId(originalBgTypeId, bracketEntry->GetBracketId()));
bg->Reset(); // reset the new bg (set status to status_wait_queue from status_none)
bg->SetStatus(STATUS_WAIT_JOIN); // start the joining of the bg
bg->SetArenaType(arenaType);
@@ -448,82 +435,88 @@ Battleground* BattlegroundMgr::CreateNewBattleground(BattlegroundTypeId original
}
// used to create the BG templates
-bool BattlegroundMgr::CreateBattleground(CreateBattlegroundData& data)
+bool BattlegroundMgr::CreateBattleground(BattlegroundTemplate const* bgTemplate)
{
- // Create the BG
- Battleground* bg = NULL;
- switch (data.bgTypeId)
+ Battleground* bg = GetBattlegroundTemplate(bgTemplate->Id);
+ if (!bg)
{
- case BATTLEGROUND_AV:
- bg = new BattlegroundAV;
- break;
- case BATTLEGROUND_WS:
- bg = new BattlegroundWS;
- break;
- case BATTLEGROUND_AB:
- bg = new BattlegroundAB;
- break;
- case BATTLEGROUND_NA:
- bg = new BattlegroundNA;
- break;
- case BATTLEGROUND_BE:
- bg = new BattlegroundBE;
- break;
- case BATTLEGROUND_EY:
- bg = new BattlegroundEY;
- break;
- case BATTLEGROUND_RL:
- bg = new BattlegroundRL;
- break;
- case BATTLEGROUND_SA:
- bg = new BattlegroundSA;
- break;
- case BATTLEGROUND_DS:
- bg = new BattlegroundDS;
- break;
- case BATTLEGROUND_RV:
- bg = new BattlegroundRV;
- break;
- case BATTLEGROUND_IC:
- bg = new BattlegroundIC;
- break;
- case BATTLEGROUND_AA:
- bg = new Battleground;
- break;
- case BATTLEGROUND_RB:
- bg = new Battleground;
- bg->SetRandom(true);
- break;
- default:
- return false;
+ // Create the BG
+ switch (bgTemplate->Id)
+ {
+ case BATTLEGROUND_AV:
+ bg = new BattlegroundAV();
+ break;
+ case BATTLEGROUND_WS:
+ bg = new BattlegroundWS();
+ break;
+ case BATTLEGROUND_AB:
+ bg = new BattlegroundAB();
+ break;
+ case BATTLEGROUND_NA:
+ bg = new BattlegroundNA();
+ break;
+ case BATTLEGROUND_BE:
+ bg = new BattlegroundBE();
+ break;
+ case BATTLEGROUND_EY:
+ bg = new BattlegroundEY();
+ break;
+ case BATTLEGROUND_RL:
+ bg = new BattlegroundRL();
+ break;
+ case BATTLEGROUND_SA:
+ bg = new BattlegroundSA();
+ break;
+ case BATTLEGROUND_DS:
+ bg = new BattlegroundDS();
+ break;
+ case BATTLEGROUND_RV:
+ bg = new BattlegroundRV();
+ break;
+ case BATTLEGROUND_IC:
+ bg = new BattlegroundIC();
+ break;
+ case BATTLEGROUND_AA:
+ bg = new Battleground();
+ break;
+ case BATTLEGROUND_RB:
+ bg = new Battleground();
+ bg->SetRandom(true);
+ break;
+ default:
+ return false;
+ }
+
+ bg->SetTypeID(bgTemplate->Id);
+ bg->SetInstanceID(0);
+ AddBattleground(bg);
}
- bg->SetMapId(data.MapID);
- bg->SetTypeID(data.bgTypeId);
- bg->SetInstanceID(0);
- bg->SetArenaorBGType(data.IsArena);
- bg->SetMinPlayersPerTeam(data.MinPlayersPerTeam);
- bg->SetMaxPlayersPerTeam(data.MaxPlayersPerTeam);
- bg->SetMinPlayers(data.MinPlayersPerTeam * 2);
- bg->SetMaxPlayers(data.MaxPlayersPerTeam * 2);
- bg->SetName(data.BattlegroundName);
- bg->SetTeamStartLoc(ALLIANCE, data.Team1StartLocX, data.Team1StartLocY, data.Team1StartLocZ, data.Team1StartLocO);
- bg->SetTeamStartLoc(HORDE, data.Team2StartLocX, data.Team2StartLocY, data.Team2StartLocZ, data.Team2StartLocO);
- bg->SetStartMaxDist(data.StartMaxDist);
- bg->SetLevelRange(data.LevelMin, data.LevelMax);
- bg->SetScriptId(data.scriptId);
-
- AddBattleground(bg);
+ bg->SetMapId(bgTemplate->BattlemasterEntry->mapid[0]);
+ bg->SetName(bgTemplate->BattlemasterEntry->name[sWorld->GetDefaultDbcLocale()]);
+ bg->SetArenaorBGType(bgTemplate->IsArena());
+ bg->SetMinPlayersPerTeam(bgTemplate->MinPlayersPerTeam);
+ bg->SetMaxPlayersPerTeam(bgTemplate->MaxPlayersPerTeam);
+ bg->SetMinPlayers(bgTemplate->MinPlayersPerTeam * 2);
+ bg->SetMaxPlayers(bgTemplate->MaxPlayersPerTeam * 2);
+ bg->SetTeamStartPosition(TEAM_ALLIANCE, bgTemplate->StartLocation[TEAM_ALLIANCE]);
+ bg->SetTeamStartPosition(TEAM_HORDE, bgTemplate->StartLocation[TEAM_HORDE]);
+ bg->SetStartMaxDist(bgTemplate->MaxStartDistSq);
+ bg->SetLevelRange(bgTemplate->MinLevel, bgTemplate->MaxLevel);
+ bg->SetScriptId(bgTemplate->ScriptId);
return true;
}
-void BattlegroundMgr::CreateInitialBattlegrounds()
+void BattlegroundMgr::LoadBattlegroundTemplates()
{
uint32 oldMSTime = getMSTime();
+
+ _battlegroundMapTemplates.clear();
+ _battlegroundTemplates.clear();
+
// 0 1 2 3 4 5 6 7 8 9 10 11
QueryResult result = WorldDatabase.Query("SELECT id, MinPlayersPerTeam, MaxPlayersPerTeam, MinLvl, MaxLvl, AllianceStartLoc, AllianceStartO, HordeStartLoc, HordeStartO, StartMaxDist, Weight, ScriptName FROM battleground_template");
-
if (!result)
{
TC_LOG_ERROR("server.loading", ">> Loaded 0 battlegrounds. DB table `battleground_template` is empty.");
@@ -536,7 +529,8 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
{
Field* fields = result->Fetch();
- uint32 bgTypeId = fields[0].GetUInt32();
+ BattlegroundTypeId bgTypeId = BattlegroundTypeId(fields[0].GetUInt32());
+
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId, NULL))
continue;
@@ -548,86 +542,64 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
continue;
}
- CreateBattlegroundData data;
- data.bgTypeId = BattlegroundTypeId(bgTypeId);
- data.IsArena = (bl->type == TYPE_ARENA);
- data.MinPlayersPerTeam = fields[1].GetUInt16();
- data.MaxPlayersPerTeam = fields[2].GetUInt16();
- data.LevelMin = fields[3].GetUInt8();
- data.LevelMax = fields[4].GetUInt8();
- float dist = fields[9].GetFloat();
- data.StartMaxDist = dist * dist;
-
- data.scriptId = sObjectMgr->GetScriptId(fields[11].GetCString());
- data.BattlegroundName = bl->name[sWorld->GetDefaultDbcLocale()];
- data.MapID = bl->mapid[0];
-
- if (data.MaxPlayersPerTeam == 0 || data.MinPlayersPerTeam > data.MaxPlayersPerTeam)
+ BattlegroundTemplate bgTemplate;
+ bgTemplate.Id = bgTypeId;
+ bgTemplate.MinPlayersPerTeam = fields[1].GetUInt16();
+ bgTemplate.MaxPlayersPerTeam = fields[2].GetUInt16();
+ bgTemplate.MinLevel = fields[3].GetUInt8();
+ bgTemplate.MaxLevel = fields[4].GetUInt8();
+ float dist = fields[9].GetFloat();
+ bgTemplate.MaxStartDistSq = dist * dist;
+ bgTemplate.Weight = fields[10].GetUInt8();
+ bgTemplate.ScriptId = sObjectMgr->GetScriptId(fields[11].GetCString());
+ bgTemplate.BattlemasterEntry = bl;
+
+ if (bgTemplate.MaxPlayersPerTeam == 0 || bgTemplate.MinPlayersPerTeam > bgTemplate.MaxPlayersPerTeam)
{
TC_LOG_ERROR("sql.sql", "Table `battleground_template` for id %u has bad values for MinPlayersPerTeam (%u) and MaxPlayersPerTeam(%u)",
- data.bgTypeId, data.MinPlayersPerTeam, data.MaxPlayersPerTeam);
+ bgTemplate.Id, bgTemplate.MinPlayersPerTeam, bgTemplate.MaxPlayersPerTeam);
continue;
}
- if (data.LevelMin == 0 || data.LevelMax == 0 || data.LevelMin > data.LevelMax)
+ if (bgTemplate.MinLevel == 0 || bgTemplate.MaxLevel == 0 || bgTemplate.MinLevel > bgTemplate.MaxLevel)
{
- TC_LOG_ERROR("sql.sql", "Table `battleground_template` for id %u has bad values for LevelMin (%u) and LevelMax(%u)",
- data.bgTypeId, data.LevelMin, data.LevelMax);
+ TC_LOG_ERROR("sql.sql", "Table `battleground_template` for id %u has bad values for MinLevel (%u) and MaxLevel (%u)",
+ bgTemplate.Id, bgTemplate.MinLevel, bgTemplate.MaxLevel);
continue;
}
- if (data.bgTypeId == BATTLEGROUND_AA || data.bgTypeId == BATTLEGROUND_RB)
- {
- data.Team1StartLocX = 0;
- data.Team1StartLocY = 0;
- data.Team1StartLocZ = 0;
- data.Team1StartLocO = fields[6].GetFloat();
- data.Team2StartLocX = 0;
- data.Team2StartLocY = 0;
- data.Team2StartLocZ = 0;
- data.Team2StartLocO = fields[8].GetFloat();
- }
- else
+ if (bgTemplate.Id != BATTLEGROUND_AA && bgTemplate.Id != BATTLEGROUND_RB)
{
uint32 startId = fields[5].GetUInt32();
if (WorldSafeLocsEntry const* start = sWorldSafeLocsStore.LookupEntry(startId))
{
- data.Team1StartLocX = start->x;
- data.Team1StartLocY = start->y;
- data.Team1StartLocZ = start->z;
- data.Team1StartLocO = fields[6].GetFloat();
+ bgTemplate.StartLocation[TEAM_ALLIANCE].Relocate(start->x, start->y, start->z, fields[6].GetFloat());
}
else
{
- TC_LOG_ERROR("sql.sql", "Table `battleground_template` for id %u have non-existed WorldSafeLocs.dbc id %u in field `AllianceStartLoc`. BG not created.", data.bgTypeId, startId);
+ TC_LOG_ERROR("sql.sql", "Table `battleground_template` for id %u has non-existed WorldSafeLocs.dbc id %u in field `AllianceStartLoc`. BG not created.", bgTemplate.Id, startId);
continue;
}
startId = fields[7].GetUInt32();
if (WorldSafeLocsEntry const* start = sWorldSafeLocsStore.LookupEntry(startId))
{
- data.Team2StartLocX = start->x;
- data.Team2StartLocY = start->y;
- data.Team2StartLocZ = start->z;
- data.Team2StartLocO = fields[8].GetFloat();
+ bgTemplate.StartLocation[TEAM_HORDE].Relocate(start->x, start->y, start->z, fields[8].GetFloat());
}
else
{
- TC_LOG_ERROR("sql.sql", "Table `battleground_template` for id %u have non-existed WorldSafeLocs.dbc id %u in field `HordeStartLoc`. BG not created.", data.bgTypeId, startId);
+ TC_LOG_ERROR("sql.sql", "Table `battleground_template` for id %u has non-existed WorldSafeLocs.dbc id %u in field `HordeStartLoc`. BG not created.", bgTemplate.Id, startId);
continue;
}
}
- if (!CreateBattleground(data))
+ if (!CreateBattleground(&bgTemplate))
continue;
- if (data.IsArena)
- {
- if (data.bgTypeId != BATTLEGROUND_AA)
- m_ArenaSelectionWeights[data.bgTypeId] = fields[10].GetUInt8();
- }
- else if (data.bgTypeId != BATTLEGROUND_RB)
- m_BGSelectionWeights[data.bgTypeId] = fields[10].GetUInt8();
+ _battlegroundTemplates[bgTypeId] = bgTemplate;
+
+ if (bgTemplate.BattlemasterEntry->mapid[1] == -1) // in this case we have only one mapId
+ _battlegroundMapTemplates[bgTemplate.BattlemasterEntry->mapid[0]] = &_battlegroundTemplates[bgTypeId];
++count;
}
@@ -722,15 +694,14 @@ void BattlegroundMgr::SendToBattleground(Player* player, uint32 instanceId, Batt
{
if (Battleground* bg = GetBattleground(instanceId, bgTypeId))
{
- float x, y, z, O;
uint32 mapid = bg->GetMapId();
uint32 team = player->GetBGTeam();
if (team == 0)
team = player->GetTeam();
- bg->GetTeamStartLoc(team, x, y, z, O);
- TC_LOG_DEBUG("bg.battleground", "BattlegroundMgr::SendToBattleground: Sending %s to map %u, X %f, Y %f, Z %f, O %f (bgType %u)", player->GetName().c_str(), mapid, x, y, z, O, bgTypeId);
- player->TeleportTo(mapid, x, y, z, O);
+ Position const* pos = bg->GetTeamStartPosition(Battleground::GetTeamIndexByTeamId(team));
+ TC_LOG_DEBUG("bg.battleground", "BattlegroundMgr::SendToBattleground: Sending %s to map %u, %s (bgType %u)", player->GetName().c_str(), mapid, pos->ToString().c_str(), bgTypeId);
+ player->TeleportTo(mapid, pos->GetPositionX(), pos->GetPositionY(), pos->GetPositionZ(), pos->GetOrientation());
}
else
TC_LOG_ERROR("bg.battleground", "BattlegroundMgr::SendToBattleground: Instance %u (bgType %u) not found while trying to teleport player %s", instanceId, bgTypeId, player->GetName().c_str());
@@ -987,51 +958,43 @@ bool BattlegroundMgr::IsBGWeekend(BattlegroundTypeId bgTypeId)
BattlegroundTypeId BattlegroundMgr::GetRandomBG(BattlegroundTypeId bgTypeId)
{
- uint32 weight = 0;
- BattlegroundTypeId returnBgTypeId = BATTLEGROUND_TYPE_NONE;
- BattlegroundSelectionWeightMap selectionWeights;
-
- if (bgTypeId == BATTLEGROUND_AA)
+ if (BattlegroundTemplate const* bgTemplate = GetBattlegroundTemplateByTypeId(bgTypeId))
{
- for (BattlegroundSelectionWeightMap::const_iterator it = m_ArenaSelectionWeights.begin(); it != m_ArenaSelectionWeights.end(); ++it)
- {
- if (it->second)
- {
- weight += it->second;
- selectionWeights[it->first] = it->second;
- }
- }
- }
- else if (bgTypeId == BATTLEGROUND_RB)
- {
- for (BattlegroundSelectionWeightMap::const_iterator it = m_BGSelectionWeights.begin(); it != m_BGSelectionWeights.end(); ++it)
+ uint32 weight = 0;
+ BattlegroundSelectionWeightMap selectionWeights;
+
+ for (int32 mapId : bgTemplate->BattlemasterEntry->mapid)
{
- if (it->second)
+ if (mapId == -1)
+ break;
+
+ if (BattlegroundTemplate const* bg = GetBattlegroundTemplateByMapId(mapId))
{
- weight += it->second;
- selectionWeights[it->first] = it->second;
+ weight += bg->Weight;
+ selectionWeights[bg->Id] = bg->Weight;
}
}
- }
- if (weight)
- {
- // Select a random value
- uint32 selectedWeight = urand(0, weight - 1);
- // Select the correct bg (if we have in DB A(10), B(20), C(10), D(15) --> [0---A---9|10---B---29|30---C---39|40---D---54])
- weight = 0;
- for (BattlegroundSelectionWeightMap::const_iterator it = selectionWeights.begin(); it != selectionWeights.end(); ++it)
+ // there is only one bg to select
+ if (selectionWeights.size() == 1)
+ return bgTypeId;
+
+ if (weight)
{
- weight += it->second;
- if (selectedWeight < weight)
+ // Select a random value
+ uint32 selectedWeight = urand(0, weight - 1);
+ // Select the correct bg (if we have in DB A(10), B(20), C(10), D(15) --> [0---A---9|10---B---29|30---C---39|40---D---54])
+ weight = 0;
+ for (auto it : selectionWeights)
{
- returnBgTypeId = it->first;
- break;
+ weight += it.second;
+ if (selectedWeight < weight)
+ return it.first;
}
}
}
- return returnBgTypeId;
+ return BATTLEGROUND_TYPE_NONE;
}
BGFreeSlotQueueContainer& BattlegroundMgr::GetBGFreeSlotQueueStore(BattlegroundTypeId bgTypeId)
diff --git a/src/server/game/Battlegrounds/BattlegroundMgr.h b/src/server/game/Battlegrounds/BattlegroundMgr.h
index d9cedbc4546..20cd8e4f7be 100644
--- a/src/server/game/Battlegrounds/BattlegroundMgr.h
+++ b/src/server/game/Battlegrounds/BattlegroundMgr.h
@@ -23,6 +23,7 @@
#include "DBCEnums.h"
#include "Battleground.h"
#include "BattlegroundQueue.h"
+#include <ace/Singleton.h>
typedef std::map<uint32, Battleground*> BattlegroundContainer;
typedef std::set<uint32> BattlegroundClientIdsContainer;
@@ -32,28 +33,6 @@ typedef std::unordered_map<uint32, BattlegroundTypeId> BattleMastersMap;
#define BATTLEGROUND_ARENA_POINT_DISTRIBUTION_DAY 86400 // seconds in a day
#define WS_ARENA_DISTRIBUTION_TIME 20001 // Custom worldstate
-struct CreateBattlegroundData
-{
- BattlegroundTypeId bgTypeId;
- bool IsArena;
- uint32 MinPlayersPerTeam;
- uint32 MaxPlayersPerTeam;
- uint32 LevelMin;
- uint32 LevelMax;
- char* BattlegroundName;
- uint32 MapID;
- float Team1StartLocX;
- float Team1StartLocY;
- float Team1StartLocZ;
- float Team1StartLocO;
- float Team2StartLocX;
- float Team2StartLocY;
- float Team2StartLocZ;
- float Team2StartLocO;
- float StartMaxDist;
- uint32 scriptId;
-};
-
struct BattlegroundData
{
BattlegroundContainer m_Battlegrounds;
@@ -61,19 +40,31 @@ struct BattlegroundData
BGFreeSlotQueueContainer BGFreeSlotQueue;
};
+struct BattlegroundTemplate
+{
+ BattlegroundTypeId Id;
+ uint16 MinPlayersPerTeam;
+ uint16 MaxPlayersPerTeam;
+ uint8 MinLevel;
+ uint8 MaxLevel;
+ Position StartLocation[BG_TEAMS_COUNT];
+ float MaxStartDistSq;
+ uint8 Weight;
+ uint32 ScriptId;
+ BattlemasterListEntry const* BattlemasterEntry;
+
+ bool IsArena() const { return BattlemasterEntry->type == MAP_ARENA; }
+};
+
class BattlegroundMgr
{
+ friend class ACE_Singleton<BattlegroundMgr, ACE_Null_Mutex>;
+
private:
BattlegroundMgr();
~BattlegroundMgr();
public:
- static BattlegroundMgr* instance()
- {
- static BattlegroundMgr* instance = new BattlegroundMgr();
- return instance;
- }
-
void Update(uint32 diff);
/* Packet Building */
@@ -98,7 +89,7 @@ class BattlegroundMgr
void RemoveFromBGFreeSlotQueue(BattlegroundTypeId bgTypeId, uint32 instanceId);
BGFreeSlotQueueContainer& GetBGFreeSlotQueueStore(BattlegroundTypeId bgTypeId);
- void CreateInitialBattlegrounds();
+ void LoadBattlegroundTemplates();
void DeleteAllBattlegrounds();
void SendToBattleground(Player* player, uint32 InstanceID, BattlegroundTypeId bgTypeId);
@@ -138,7 +129,7 @@ class BattlegroundMgr
}
private:
- bool CreateBattleground(CreateBattlegroundData& data);
+ bool CreateBattleground(BattlegroundTemplate const* bgTemplate);
uint32 CreateClientVisibleInstanceId(BattlegroundTypeId bgTypeId, BattlegroundBracketId bracket_id);
static bool IsArenaType(BattlegroundTypeId bgTypeId);
BattlegroundTypeId GetRandomBG(BattlegroundTypeId id);
@@ -148,9 +139,6 @@ class BattlegroundMgr
BattlegroundQueue m_BattlegroundQueues[MAX_BATTLEGROUND_QUEUE_TYPES];
- typedef std::map<BattlegroundTypeId, uint8> BattlegroundSelectionWeightMap; // TypeId and its selectionWeight
- BattlegroundSelectionWeightMap m_ArenaSelectionWeights;
- BattlegroundSelectionWeightMap m_BGSelectionWeights;
std::vector<uint64> m_QueueUpdateScheduler;
uint32 m_NextRatedArenaUpdate;
time_t m_NextAutoDistributionTime;
@@ -158,7 +146,31 @@ class BattlegroundMgr
bool m_ArenaTesting;
bool m_Testing;
BattleMastersMap mBattleMastersMap;
+
+ BattlegroundTemplate const* GetBattlegroundTemplateByTypeId(BattlegroundTypeId id)
+ {
+ BattlegroundTemplateMap::const_iterator itr = _battlegroundTemplates.find(id);
+ if (itr != _battlegroundTemplates.end())
+ return &itr->second;
+ return nullptr;
+ }
+
+ BattlegroundTemplate const* GetBattlegroundTemplateByMapId(uint32 mapId)
+ {
+ BattlegroundMapTemplateContainer::const_iterator itr = _battlegroundMapTemplates.find(mapId);
+ if (itr != _battlegroundMapTemplates.end())
+ return itr->second;
+ return nullptr;
+ }
+
+ typedef std::map<BattlegroundTypeId, uint8 /*weight*/> BattlegroundSelectionWeightMap;
+
+ typedef std::map<BattlegroundTypeId, BattlegroundTemplate> BattlegroundTemplateMap;
+ typedef std::map<uint32 /*mapId*/, BattlegroundTemplate*> BattlegroundMapTemplateContainer;
+ BattlegroundTemplateMap _battlegroundTemplates;
+ BattlegroundMapTemplateContainer _battlegroundMapTemplates;
};
-#define sBattlegroundMgr BattlegroundMgr::instance()
-#endif
+#define sBattlegroundMgr ACE_Singleton<BattlegroundMgr, ACE_Null_Mutex>::instance()
+
+#endif // __BATTLEGROUNDMGR_H
diff --git a/src/server/game/Battlegrounds/BattlegroundQueue.cpp b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
index 2f632377756..e52f75a1c41 100644
--- a/src/server/game/Battlegrounds/BattlegroundQueue.cpp
+++ b/src/server/game/Battlegrounds/BattlegroundQueue.cpp
@@ -198,7 +198,6 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr
{
if (Battleground* bg = sBattlegroundMgr->GetBattlegroundTemplate(ginfo->BgTypeId))
{
- char const* bgName = bg->GetName();
uint32 MinPlayers = bg->GetMinPlayersPerTeam();
uint32 qHorde = 0;
uint32 qAlliance = 0;
@@ -215,13 +214,13 @@ GroupQueueInfo* BattlegroundQueue::AddGroup(Player* leader, Group* grp, Battlegr
// Show queue status to player only (when joining queue)
if (sWorld->getBoolConfig(CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_PLAYERONLY))
{
- ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bgName, q_min_level, q_max_level,
+ ChatHandler(leader->GetSession()).PSendSysMessage(LANG_BG_QUEUE_ANNOUNCE_SELF, bg->GetName().c_str(), q_min_level, q_max_level,
qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
}
// System message
else
{
- sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bgName, q_min_level, q_max_level,
+ sWorld->SendWorldText(LANG_BG_QUEUE_ANNOUNCE_WORLD, bg->GetName().c_str(), q_min_level, q_max_level,
qAlliance, (MinPlayers > qAlliance) ? MinPlayers - qAlliance : (uint32)0, qHorde, (MinPlayers > qHorde) ? MinPlayers - qHorde : (uint32)0);
}
}
diff --git a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp
index da0b00af40f..1685f06f92d 100644
--- a/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp
+++ b/src/server/game/Battlegrounds/Zones/BattlegroundIC.cpp
@@ -110,8 +110,8 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff)
GetBGObject(BG_IC_GO_DOODAD_ND_HUMAN_GATE_CLOSEDFX_DOOR01)->RemoveFromWorld();
GetBGObject(BG_IC_GO_DOODAD_ND_WINTERORC_WALL_GATEFX_DOOR01)->RemoveFromWorld();
- GetBGObject(BG_IC_GO_ALLIANCE_GATE_3)->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); // Alliance door
- GetBGObject(BG_IC_GO_HORDE_GATE_1)->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); // Horde door
+ GetBGObject(BG_IC_GO_ALLIANCE_GATE_3)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); // Alliance door
+ GetBGObject(BG_IC_GO_HORDE_GATE_1)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED); // Horde door
doorsClosed = true;
} else closeFortressDoorsTimer -= diff;
@@ -241,10 +241,10 @@ void BattlegroundIC::PostUpdateImpl(uint32 diff)
void BattlegroundIC::StartingEventCloseDoors()
{
// Show Full Gate Displays
- GetBGObject(BG_IC_GO_ALLIANCE_GATE_1)->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); // Alliance door
- GetBGObject(BG_IC_GO_ALLIANCE_GATE_2)->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); // Alliance door
- GetBGObject(BG_IC_GO_HORDE_GATE_2)->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); // Horde door
- GetBGObject(BG_IC_GO_HORDE_GATE_3)->SetFlag(GAMEOBJECT_FLAGS, GO_FLAG_DAMAGED); // Horde door
+ GetBGObject(BG_IC_GO_ALLIANCE_GATE_1)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED);
+ GetBGObject(BG_IC_GO_ALLIANCE_GATE_2)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED);
+ GetBGObject(BG_IC_GO_HORDE_GATE_2)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED);
+ GetBGObject(BG_IC_GO_HORDE_GATE_3)->SetDestructibleState(GO_DESTRUCTIBLE_DAMAGED);
}
void BattlegroundIC::StartingEventOpenDoors()
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp
index d353efb58c7..a24b3e3878a 100644
--- a/src/server/game/DungeonFinding/LFGMgr.cpp
+++ b/src/server/game/DungeonFinding/LFGMgr.cpp
@@ -355,7 +355,6 @@ void LFGMgr::Update(uint32 diff)
if (m_QueueTimer > LFG_QUEUEUPDATE_INTERVAL)
{
m_QueueTimer = 0;
- time_t currTime = time(NULL);
for (LfgQueueContainer::iterator it = QueuesStore.begin(); it != QueuesStore.end(); ++it)
it->second.UpdateQueueTimers(currTime);
}
@@ -1707,14 +1706,13 @@ void LFGMgr::RemoveGroupData(uint64 guid)
LfgState state = GetState(guid);
// If group is being formed after proposal success do nothing more
LfgGuidSet const& players = it->second.GetPlayers();
- for (LfgGuidSet::const_iterator it = players.begin(); it != players.end(); ++it)
+ for (uint64 playerGUID : players)
{
- uint64 guid = (*it);
- SetGroup(*it, 0);
+ SetGroup(playerGUID, 0);
if (state != LFG_STATE_PROPOSAL)
{
- SetState(*it, LFG_STATE_NONE);
- SendLfgUpdateParty(guid, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE));
+ SetState(playerGUID, LFG_STATE_NONE);
+ SendLfgUpdateParty(playerGUID, LfgUpdateData(LFG_UPDATETYPE_REMOVED_FROM_QUEUE));
}
}
GroupsStore.erase(it);
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index fd8aaff8159..341225741ea 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -2276,6 +2276,7 @@ void Creature::AllLootRemovedFromCorpse()
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
time_t now = time(NULL);
+ // Do not reset corpse remove time if corpse is already removed
if (m_corpseRemoveTime <= now)
return;
@@ -2283,7 +2284,7 @@ void Creature::AllLootRemovedFromCorpse()
// corpse skinnable, but without skinning flag, and then skinned, corpse will despawn next update
if (loot.loot_type == LOOT_SKINNING)
- m_corpseRemoveTime = time(NULL);
+ m_corpseRemoveTime = now;
else
m_corpseRemoveTime = now + m_corpseDelay * decayRate;
diff --git a/src/server/game/Entities/GameObject/GameObject.cpp b/src/server/game/Entities/GameObject/GameObject.cpp
index ae08a4251a5..23e40382fa2 100644
--- a/src/server/game/Entities/GameObject/GameObject.cpp
+++ b/src/server/game/Entities/GameObject/GameObject.cpp
@@ -958,6 +958,17 @@ void GameObject::SaveRespawnTime()
GetMap()->SaveGORespawnTime(m_DBTableGuid, m_respawnTime);
}
+bool GameObject::IsNeverVisible() const
+{
+ if (WorldObject::IsNeverVisible())
+ return true;
+
+ if (GetGoType() == GAMEOBJECT_TYPE_SPELL_FOCUS && GetGOInfo()->spellFocus.serverOnly == 1)
+ return true;
+
+ return false;
+}
+
bool GameObject::IsAlwaysVisibleFor(WorldObject const* seer) const
{
if (WorldObject::IsAlwaysVisibleFor(seer))
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index 8f70fc0e907..549de28bb12 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -778,6 +778,8 @@ class GameObject : public WorldObject, public GridObject<GameObject>, public Map
void TriggeringLinkedGameObject(uint32 trapEntry, Unit* target);
+ bool IsNeverVisible() const override;
+
bool IsAlwaysVisibleFor(WorldObject const* seer) const;
bool IsInvisibleDueToDespawn() const;
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index e00728d25c6..6eda51667e1 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -3116,7 +3116,7 @@ void Player::InitTalentForLevel()
// Remove all talent points
if (m_usedTalentCount > 0) // Free any used talents
{
- resetTalents(true); /// @todo: Has to (collectively) be renamed to ResetTalents
+ ResetTalents(true); /// @todo: Has to (collectively) be renamed to ResetTalents
SetFreeTalentPoints(0);
}
}
@@ -3134,7 +3134,7 @@ void Player::InitTalentForLevel()
if (m_usedTalentCount > talentPointsForLevel)
{
if (!GetSession()->HasPermission(rbac::RBAC_PERM_SKIP_CHECK_MORE_TALENTS_THAN_ALLOWED))
- resetTalents(true);
+ ResetTalents(true);
else
SetFreeTalentPoints(0);
}
@@ -3525,7 +3525,7 @@ bool Player::AddTalent(uint32 spellId, uint8 spec, bool learning)
return false;
}
-bool Player::addSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading /*= false*/)
+bool Player::AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading /*= false*/, bool fromSkill /*= false*/)
{
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!spellInfo)
@@ -3688,7 +3688,7 @@ bool Player::addSpell(uint32 spellId, bool active, bool learning, bool dependent
if (!rankSpellId || rankSpellId == spellId)
continue;
- removeSpell(rankSpellId, false, false);
+ RemoveSpell(rankSpellId, false, false);
}
}
}
@@ -3696,9 +3696,9 @@ bool Player::addSpell(uint32 spellId, bool active, bool learning, bool dependent
else if (uint32 prev_spell = sSpellMgr->GetPrevSpellInChain(spellId))
{
if (!IsInWorld() || disabled) // at spells loading, no output, but allow save
- addSpell(prev_spell, active, true, true, disabled);
+ AddSpell(prev_spell, active, true, true, disabled, false, fromSkill);
else // at normal learning
- learnSpell(prev_spell, true);
+ LearnSpell(prev_spell, true, fromSkill);
}
PlayerSpell* newspell = new PlayerSpell;
@@ -3797,45 +3797,44 @@ bool Player::addSpell(uint32 spellId, bool active, bool learning, bool dependent
SetFreePrimaryProfessions(freeProfs-1);
}
- // add dependent skills
- uint16 maxskill = GetMaxSkillValueForLevel();
-
- SpellLearnSkillNode const* spellLearnSkill = sSpellMgr->GetSpellLearnSkill(spellId);
-
SkillLineAbilityMapBounds skill_bounds = sSpellMgr->GetSkillLineAbilityMapBounds(spellId);
- if (spellLearnSkill)
+ // add dependent skills if this spell is not learned from adding skill already
+ if (!fromSkill)
{
- uint32 skill_value = GetPureSkillValue(spellLearnSkill->skill);
- uint32 skill_max_value = GetPureMaxSkillValue(spellLearnSkill->skill);
+ if (SpellLearnSkillNode const* spellLearnSkill = sSpellMgr->GetSpellLearnSkill(spellId))
+ {
+ uint32 skill_value = GetPureSkillValue(spellLearnSkill->skill);
+ uint32 skill_max_value = GetPureMaxSkillValue(spellLearnSkill->skill);
- if (skill_value < spellLearnSkill->value)
- skill_value = spellLearnSkill->value;
+ if (skill_value < spellLearnSkill->value)
+ skill_value = spellLearnSkill->value;
- uint32 new_skill_max_value = spellLearnSkill->maxvalue == 0 ? maxskill : spellLearnSkill->maxvalue;
+ uint32 new_skill_max_value = spellLearnSkill->maxvalue == 0 ? GetMaxSkillValueForLevel() : spellLearnSkill->maxvalue;
- if (skill_max_value < new_skill_max_value)
- skill_max_value = new_skill_max_value;
+ if (skill_max_value < new_skill_max_value)
+ skill_max_value = new_skill_max_value;
- SetSkill(spellLearnSkill->skill, spellLearnSkill->step, skill_value, skill_max_value);
- }
- else
- {
- // not ranked skills
- for (SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx)
+ SetSkill(spellLearnSkill->skill, spellLearnSkill->step, skill_value, skill_max_value);
+ }
+ else
{
- SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId);
- if (!pSkill)
- continue;
+ // not ranked skills
+ for (SkillLineAbilityMap::const_iterator _spell_idx = skill_bounds.first; _spell_idx != skill_bounds.second; ++_spell_idx)
+ {
+ SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(_spell_idx->second->skillId);
+ if (!pSkill)
+ continue;
- if (_spell_idx->second->AutolearnType == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(pSkill->id))
- LearnDefaultSkill(pSkill->id, 0);
+ if (_spell_idx->second->AutolearnType == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN && !HasSkill(pSkill->id))
+ LearnDefaultSkill(pSkill->id, 0);
- if (pSkill->id == SKILL_MOUNTS && !Has310Flyer(false))
- for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
- if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED &&
- spellInfo->Effects[i].CalcValue() == 310)
- SetHas310Flyer(true);
+ if (pSkill->id == SKILL_MOUNTS && !Has310Flyer(false))
+ for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ if (spellInfo->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED &&
+ spellInfo->Effects[i].CalcValue() == 310)
+ SetHas310Flyer(true);
+ }
}
}
@@ -3847,9 +3846,9 @@ bool Player::addSpell(uint32 spellId, bool active, bool learning, bool dependent
if (!itr2->second.autoLearned)
{
if (!IsInWorld() || !itr2->second.active) // at spells loading, no output, but allow save
- addSpell(itr2->second.spell, itr2->second.active, true, true, false);
+ AddSpell(itr2->second.spell, itr2->second.active, true, true, false);
else // at normal learning
- learnSpell(itr2->second.spell, true);
+ LearnSpell(itr2->second.spell, true);
}
}
@@ -3908,14 +3907,14 @@ bool Player::IsNeedCastPassiveSpellAtLearn(SpellInfo const* spellInfo) const
return need_cast && (!spellInfo->CasterAuraState || HasAuraState(AuraStateType(spellInfo->CasterAuraState)));
}
-void Player::learnSpell(uint32 spell_id, bool dependent)
+void Player::LearnSpell(uint32 spell_id, bool dependent, bool fromSkill /*= false*/)
{
PlayerSpellMap::iterator itr = m_spells.find(spell_id);
bool disabled = (itr != m_spells.end()) ? itr->second->disabled : false;
bool active = disabled ? itr->second->active : true;
- bool learning = addSpell(spell_id, active, true, dependent, false);
+ bool learning = AddSpell(spell_id, active, true, dependent, false, false, fromSkill);
// prevent duplicated entires in spell book, also not send if not in world (loading)
if (learning && IsInWorld())
@@ -3933,7 +3932,7 @@ void Player::learnSpell(uint32 spell_id, bool dependent)
{
PlayerSpellMap::iterator iter = m_spells.find(nextSpell);
if (iter != m_spells.end() && iter->second->disabled)
- learnSpell(nextSpell, false);
+ LearnSpell(nextSpell, false, fromSkill);
}
SpellsRequiringSpellMapBounds spellsRequiringSpell = sSpellMgr->GetSpellsRequiringSpellBounds(spell_id);
@@ -3941,12 +3940,12 @@ void Player::learnSpell(uint32 spell_id, bool dependent)
{
PlayerSpellMap::iterator iter2 = m_spells.find(itr2->second);
if (iter2 != m_spells.end() && iter2->second->disabled)
- learnSpell(itr2->second, false);
+ LearnSpell(itr2->second, false, fromSkill);
}
}
}
-void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank)
+void Player::RemoveSpell(uint32 spell_id, bool disabled, bool learn_low_rank)
{
PlayerSpellMap::iterator itr = m_spells.find(spell_id);
if (itr == m_spells.end())
@@ -3959,12 +3958,12 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank)
if (uint32 nextSpell = sSpellMgr->GetNextSpellInChain(spell_id))
{
if (HasSpell(nextSpell) && !GetTalentSpellPos(nextSpell))
- removeSpell(nextSpell, disabled, false);
+ RemoveSpell(nextSpell, disabled, false);
}
//unlearn spells dependent from recently removed spells
SpellsRequiringSpellMapBounds spellsRequiringSpell = sSpellMgr->GetSpellsRequiringSpellBounds(spell_id);
for (SpellsRequiringSpellMap::const_iterator itr2 = spellsRequiringSpell.first; itr2 != spellsRequiringSpell.second; ++itr2)
- removeSpell(itr2->second, disabled);
+ RemoveSpell(itr2->second, disabled);
// re-search, it can be corrupted in prev loop
itr = m_spells.find(spell_id);
@@ -4089,7 +4088,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank)
SpellLearnSpellMapBounds spell_bounds = sSpellMgr->GetSpellLearnSpellMapBounds(spell_id);
for (SpellLearnSpellMap::const_iterator itr2 = spell_bounds.first; itr2 != spell_bounds.second; ++itr2)
- removeSpell(itr2->second.spell, disabled);
+ RemoveSpell(itr2->second.spell, disabled);
// activate lesser rank in spellbook/action bar, and cast it if need
bool prev_activate = false;
@@ -4121,7 +4120,7 @@ void Player::removeSpell(uint32 spell_id, bool disabled, bool learn_low_rank)
// now re-learn if need re-activate
if (cur_active && !prev_itr->second->active && learn_low_rank)
{
- if (addSpell(prev_id, true, false, prev_itr->second->dependent, prev_itr->second->disabled))
+ if (AddSpell(prev_id, true, false, prev_itr->second->dependent, prev_itr->second->disabled))
{
// downgrade spell ranks in spellbook and action bar
WorldPacket data(SMSG_SUPERCEDED_SPELL, 4 + 4);
@@ -4336,7 +4335,7 @@ void Player::_SaveSpellCooldowns(SQLTransaction& trans)
trans->Append(ss.str().c_str());
}
-uint32 Player::resetTalentsCost() const
+uint32 Player::ResetTalentsCost() const
{
// The first time reset costs 1 gold
if (m_resetTalentsCost < 1*GOLD)
@@ -4369,7 +4368,7 @@ uint32 Player::resetTalentsCost() const
}
}
-bool Player::resetTalents(bool no_cost)
+bool Player::ResetTalents(bool no_cost)
{
sScriptMgr->OnPlayerTalentsReset(this, no_cost);
@@ -4389,7 +4388,7 @@ bool Player::resetTalents(bool no_cost)
if (!no_cost && !sWorld->getBoolConfig(CONFIG_NO_RESET_TALENT_COST))
{
- cost = resetTalentsCost();
+ cost = ResetTalentsCost();
if (!HasEnoughMoney(cost))
{
@@ -4426,11 +4425,11 @@ bool Player::resetTalents(bool no_cost)
const SpellInfo* _spellEntry = sSpellMgr->GetSpellInfo(talentInfo->RankID[rank]);
if (!_spellEntry)
continue;
- removeSpell(talentInfo->RankID[rank], true);
+ RemoveSpell(talentInfo->RankID[rank], true);
// search for spells that the talent teaches and unlearn them
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (_spellEntry->Effects[i].TriggerSpell > 0 && _spellEntry->Effects[i].Effect == SPELL_EFFECT_LEARN_SPELL)
- removeSpell(_spellEntry->Effects[i].TriggerSpell, true);
+ RemoveSpell(_spellEntry->Effects[i].TriggerSpell, true);
// if this talent rank can be found in the PlayerTalentMap, mark the talent as removed so it gets deleted
PlayerTalentMap::iterator plrTalent = m_talents[m_activeSpec]->find(talentInfo->RankID[rank]);
if (plrTalent != m_talents[m_activeSpec]->end())
@@ -6113,7 +6112,7 @@ bool Player::UpdateCraftSkill(uint32 spellid)
if (spellEntry && spellEntry->Mechanic == MECHANIC_DISCOVERY)
{
if (uint32 discoveredSpell = GetSkillDiscoverySpell(_spell_idx->second->skillId, spellid, this))
- learnSpell(discoveredSpell, false);
+ LearnSpell(discoveredSpell, false);
}
uint32 craft_skill_gain = sWorld->getIntConfig(CONFIG_SKILL_GAIN_CRAFTING);
@@ -6216,7 +6215,7 @@ bool Player::UpdateSkillPro(uint16 SkillId, int32 Chance, uint32 step)
uint32 bsl = bonusSkillLevels[i];
if (SkillValue < bsl && new_value >= bsl)
{
- learnSkillRewardedSpells(SkillId, new_value);
+ LearnSkillRewardedSpells(SkillId, new_value);
break;
}
}
@@ -6423,7 +6422,7 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(itr->second.pos), MAKE_SKILL_VALUE(newVal, maxVal));
if (itr->second.uState != SKILL_NEW)
itr->second.uState = SKILL_CHANGED;
- learnSkillRewardedSpells(id, newVal);
+ LearnSkillRewardedSpells(id, newVal);
// if skill value is going up, update enchantments after setting the new value
if (newVal > currVal)
UpdateSkillEnchantments(id, currVal, newVal);
@@ -6449,55 +6448,57 @@ void Player::SetSkill(uint16 id, uint16 step, uint16 newVal, uint16 maxVal)
for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
if (SkillLineAbilityEntry const* pAbility = sSkillLineAbilityStore.LookupEntry(j))
if (pAbility->skillId == id)
- removeSpell(sSpellMgr->GetFirstSpellInChain(pAbility->spellId));
+ RemoveSpell(sSpellMgr->GetFirstSpellInChain(pAbility->spellId));
}
}
else if (newVal) //add
{
currVal = 0;
for (int i=0; i < PLAYER_MAX_SKILLS; ++i)
- if (!GetUInt32Value(PLAYER_SKILL_INDEX(i)))
{
- SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(id);
- if (!pSkill)
+ if (!GetUInt32Value(PLAYER_SKILL_INDEX(i)))
{
- TC_LOG_ERROR("entities.player.skills", "Skill not found in SkillLineStore: skill #%u", id);
- return;
- }
+ SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(id);
+ if (!pSkill)
+ {
+ TC_LOG_ERROR("entities.player.skills", "Skill not found in SkillLineStore: skill #%u", id);
+ return;
+ }
- SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id, step));
- SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i), MAKE_SKILL_VALUE(newVal, maxVal));
- UpdateSkillEnchantments(id, currVal, newVal);
- UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, id);
- UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, id);
+ SetUInt32Value(PLAYER_SKILL_INDEX(i), MAKE_PAIR32(id, step));
+ SetUInt32Value(PLAYER_SKILL_VALUE_INDEX(i), MAKE_SKILL_VALUE(newVal, maxVal));
+ UpdateSkillEnchantments(id, currVal, newVal);
+ UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_REACH_SKILL_LEVEL, id);
+ UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_LEARN_SKILL_LEVEL, id);
- // insert new entry or update if not deleted old entry yet
- if (itr != mSkillStatus.end())
- {
- itr->second.pos = i;
- itr->second.uState = SKILL_CHANGED;
- }
- else
- mSkillStatus.insert(SkillStatusMap::value_type(id, SkillStatusData(i, SKILL_NEW)));
+ // insert new entry or update if not deleted old entry yet
+ if (itr != mSkillStatus.end())
+ {
+ itr->second.pos = i;
+ itr->second.uState = SKILL_CHANGED;
+ }
+ else
+ mSkillStatus.insert(SkillStatusMap::value_type(id, SkillStatusData(i, SKILL_NEW)));
- // apply skill bonuses
- SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i), 0);
+ // apply skill bonuses
+ SetUInt32Value(PLAYER_SKILL_BONUS_INDEX(i), 0);
- // temporary bonuses
- AuraEffectList const& mModSkill = GetAuraEffectsByType(SPELL_AURA_MOD_SKILL);
- for (AuraEffectList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j)
- if ((*j)->GetMiscValue() == int32(id))
+ // temporary bonuses
+ AuraEffectList const& mModSkill = GetAuraEffectsByType(SPELL_AURA_MOD_SKILL);
+ for (AuraEffectList::const_iterator j = mModSkill.begin(); j != mModSkill.end(); ++j)
+ if ((*j)->GetMiscValue() == int32(id))
(*j)->HandleEffect(this, AURA_EFFECT_HANDLE_SKILL, true);
- // permanent bonuses
- AuraEffectList const& mModSkillTalent = GetAuraEffectsByType(SPELL_AURA_MOD_SKILL_TALENT);
- for (AuraEffectList::const_iterator j = mModSkillTalent.begin(); j != mModSkillTalent.end(); ++j)
- if ((*j)->GetMiscValue() == int32(id))
+ // permanent bonuses
+ AuraEffectList const& mModSkillTalent = GetAuraEffectsByType(SPELL_AURA_MOD_SKILL_TALENT);
+ for (AuraEffectList::const_iterator j = mModSkillTalent.begin(); j != mModSkillTalent.end(); ++j)
+ if ((*j)->GetMiscValue() == int32(id))
(*j)->HandleEffect(this, AURA_EFFECT_HANDLE_SKILL, true);
- // Learn all spells for skill
- learnSkillRewardedSpells(id, newVal);
- return;
+ // Learn all spells for skill
+ LearnSkillRewardedSpells(id, newVal);
+ return;
+ }
}
}
}
@@ -9774,7 +9775,7 @@ void Player::SendTalentWipeConfirm(uint64 guid)
{
WorldPacket data(MSG_TALENT_WIPE_CONFIRM, (8+4));
data << uint64(guid);
- uint32 cost = sWorld->getBoolConfig(CONFIG_NO_RESET_TALENT_COST) ? 0 : resetTalentsCost();
+ uint32 cost = sWorld->getBoolConfig(CONFIG_NO_RESET_TALENT_COST) ? 0 : ResetTalentsCost();
data << cost;
GetSession()->SendPacket(&data);
}
@@ -18502,7 +18503,7 @@ void Player::_LoadQuestStatusRewarded(PreparedQueryResult result)
if (quest)
{
// learn rewarded spell if unknown
- learnQuestRewardedSpells(quest);
+ LearnQuestRewardedSpells(quest);
// set rewarded title if any
if (quest->GetCharTitleId())
@@ -18650,7 +18651,7 @@ void Player::_LoadSpells(PreparedQueryResult result)
if (result)
{
do
- addSpell((*result)[0].GetUInt32(), (*result)[1].GetBool(), false, false, (*result)[2].GetBool(), true);
+ AddSpell((*result)[0].GetUInt32(), (*result)[1].GetBool(), false, false, (*result)[2].GetBool(), true);
while (result->NextRow());
}
}
@@ -22061,6 +22062,27 @@ void Player::AddSpellCooldown(uint32 spellid, uint32 itemid, time_t end_time)
m_spellCooldowns[spellid] = sc;
}
+void Player::ModifySpellCooldown(uint32 spellId, int32 cooldown)
+{
+ SpellCooldowns::iterator itr = m_spellCooldowns.find(spellId);
+ if (itr == m_spellCooldowns.end())
+ return;
+
+ time_t now = time(NULL);
+ if (itr->second.end + (cooldown / IN_MILLISECONDS) > now)
+ itr->second.end += (cooldown / IN_MILLISECONDS);
+ else
+ m_spellCooldowns.erase(itr);
+
+ WorldPacket data(SMSG_MODIFY_COOLDOWN, 4 + 8 + 4);
+ data << uint32(spellId); // Spell ID
+ data << uint64(GetGUID()); // Player GUID
+ data << int32(cooldown); // Cooldown mod in milliseconds
+ GetSession()->SendPacket(&data);
+
+ TC_LOG_DEBUG("misc", "ModifySpellCooldown:: Player: %s (GUID: %u) Spell: %u cooldown: %u", GetName().c_str(), GetGUIDLow(), spellId, GetSpellCooldownDelay(spellId));
+}
+
void Player::SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId /*= 0*/, Spell* spell /*= NULL*/, bool setCooldown /*= true*/)
{
// start cooldowns at server side, if any
@@ -23017,7 +23039,7 @@ void Player::ApplyEquipCooldown(Item* pItem)
}
}
-void Player::resetSpells(bool myClassOnly)
+void Player::ResetSpells(bool myClassOnly)
{
// not need after this call
if (HasAtLoginFlag(AT_LOGIN_RESET_SPELLS))
@@ -23066,11 +23088,11 @@ void Player::resetSpells(bool myClassOnly)
}
else
for (PlayerSpellMap::const_iterator iter = smap.begin(); iter != smap.end(); ++iter)
- removeSpell(iter->first, false, false); // only iter->first can be accessed, object by iter->second can be deleted already
+ RemoveSpell(iter->first, false, false); // only iter->first can be accessed, object by iter->second can be deleted already
LearnDefaultSkills();
LearnCustomSpells();
- learnQuestRewardedSpells();
+ LearnQuestRewardedSpells();
}
void Player::LearnCustomSpells()
@@ -23085,9 +23107,9 @@ void Player::LearnCustomSpells()
uint32 tspell = *itr;
TC_LOG_DEBUG("entities.player.loading", "PLAYER (Class: %u Race: %u): Adding initial spell, id = %u", uint32(getClass()), uint32(getRace()), tspell);
if (!IsInWorld()) // will send in INITIAL_SPELLS in list anyway at map add
- addSpell(tspell, true, true, true, false);
+ AddSpell(tspell, true, true, true, false);
else // but send in normal spell in game learn case
- learnSpell(tspell, true);
+ LearnSpell(tspell, true);
}
}
@@ -23153,7 +23175,7 @@ void Player::LearnDefaultSkill(uint32 skillId, uint16 rank)
}
}
-void Player::learnQuestRewardedSpells(Quest const* quest)
+void Player::LearnQuestRewardedSpells(Quest const* quest)
{
int32 spell_id = quest->GetRewSpellCast();
uint32 src_spell_id = quest->GetSrcSpell();
@@ -23233,7 +23255,7 @@ void Player::learnQuestRewardedSpells(Quest const* quest)
CastSpell(this, spell_id, true);
}
-void Player::learnQuestRewardedSpells()
+void Player::LearnQuestRewardedSpells()
{
// learn spells received from quest completing
for (RewardedQuestSet::const_iterator itr = m_RewardedQuests.begin(); itr != m_RewardedQuests.end(); ++itr)
@@ -23242,43 +23264,42 @@ void Player::learnQuestRewardedSpells()
if (!quest)
continue;
- learnQuestRewardedSpells(quest);
+ LearnQuestRewardedSpells(quest);
}
}
-void Player::learnSkillRewardedSpells(uint32 skill_id, uint32 skill_value)
+void Player::LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue)
{
uint32 raceMask = getRaceMask();
uint32 classMask = getClassMask();
for (uint32 j = 0; j < sSkillLineAbilityStore.GetNumRows(); ++j)
{
- SkillLineAbilityEntry const* pAbility = sSkillLineAbilityStore.LookupEntry(j);
- if (!pAbility || pAbility->skillId != skill_id)
+ SkillLineAbilityEntry const* ability = sSkillLineAbilityStore.LookupEntry(j);
+ if (!ability || ability->skillId != skillId)
continue;
- SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(pAbility->spellId);
- if (!spellInfo)
+ if (!sSpellMgr->GetSpellInfo(ability->spellId))
continue;
- if (pAbility->AutolearnType != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_VALUE && pAbility->AutolearnType != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN)
+ if (ability->AutolearnType != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_VALUE && ability->AutolearnType != SKILL_LINE_ABILITY_LEARNED_ON_SKILL_LEARN)
continue;
// Check race if set
- if (pAbility->racemask && !(pAbility->racemask & raceMask))
+ if (ability->racemask && !(ability->racemask & raceMask))
continue;
// Check class if set
- if (pAbility->classmask && !(pAbility->classmask & classMask))
+ if (ability->classmask && !(ability->classmask & classMask))
continue;
// need unlearn spell
- if (skill_value < pAbility->req_skill_value && pAbility->AutolearnType == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_VALUE)
- removeSpell(pAbility->spellId);
+ if (skillValue < ability->req_skill_value && ability->AutolearnType == SKILL_LINE_ABILITY_LEARNED_ON_SKILL_VALUE)
+ RemoveSpell(ability->spellId);
// need learn
else if (!IsInWorld())
- addSpell(pAbility->spellId, true, true, true, false);
+ AddSpell(ability->spellId, true, true, true, false, false, true);
else
- learnSpell(pAbility->spellId, true);
+ LearnSpell(ability->spellId, true, true);
}
}
@@ -24946,12 +24967,12 @@ bool Player::IsKnowHowFlyIn(uint32 mapid, uint32 zone) const
return v_map != 571 || HasSpell(54197); // Cold Weather Flying
}
-void Player::learnSpellHighRank(uint32 spellid)
+void Player::LearnSpellHighestRank(uint32 spellid)
{
- learnSpell(spellid, false);
+ LearnSpell(spellid, false);
if (uint32 next = sSpellMgr->GetNextSpellInChain(spellid))
- learnSpellHighRank(next);
+ LearnSpellHighestRank(next);
}
void Player::_LoadSkills(PreparedQueryResult result)
@@ -24972,7 +24993,10 @@ void Player::_LoadSkills(PreparedQueryResult result)
SkillRaceClassInfoEntry const* rcEntry = GetSkillRaceClassInfo(skill, getRace(), getClass());
if (!rcEntry)
{
- TC_LOG_ERROR("entities.player", "Character %u has skill %u that does not exist.", GetGUIDLow(), skill);
+ TC_LOG_ERROR("entities.player", "Character: %s (GUID: %u Race: %u Class: %u) has skill %u not allowed for his race/class combination",
+ GetName().c_str(), GetGUIDLow(), uint32(getRace()), uint32(getClass()), skill);
+
+ mSkillStatus.insert(SkillStatusMap::value_type(skill, SkillStatusData(0, SKILL_DELETED)));
continue;
}
@@ -25025,7 +25049,7 @@ void Player::_LoadSkills(PreparedQueryResult result)
mSkillStatus.insert(SkillStatusMap::value_type(skill, SkillStatusData(count, SKILL_UNCHANGED)));
- learnSkillRewardedSpells(skill, value);
+ LearnSkillRewardedSpells(skill, value);
++count;
@@ -25333,7 +25357,7 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank)
return;
// learn! (other talent ranks will unlearned at learning)
- learnSpell(spellid, false);
+ LearnSpell(spellid, false);
AddTalent(spellid, m_activeSpec, true);
TC_LOG_INFO("entities.player", "TalentID: %u Rank: %u Spell: %u Spec: %u\n", talentId, talentRank, spellid, m_activeSpec);
@@ -26144,11 +26168,11 @@ void Player::ActivateSpec(uint8 spec)
// skip non-existant talent ranks
if (talentInfo->RankID[rank] == 0)
continue;
- removeSpell(talentInfo->RankID[rank], true); // removes the talent, and all dependant, learned, and chained spells..
+ RemoveSpell(talentInfo->RankID[rank], true); // removes the talent, and all dependant, learned, and chained spells..
if (const SpellInfo* _spellEntry = sSpellMgr->GetSpellInfo(talentInfo->RankID[rank]))
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) // search through the SpellInfo for valid trigger spells
if (_spellEntry->Effects[i].TriggerSpell > 0 && _spellEntry->Effects[i].Effect == SPELL_EFFECT_LEARN_SPELL)
- removeSpell(_spellEntry->Effects[i].TriggerSpell, true); // and remove any spells that the talent teaches
+ RemoveSpell(_spellEntry->Effects[i].TriggerSpell, true); // and remove any spells that the talent teaches
// if this talent rank can be found in the PlayerTalentMap, mark the talent as removed so it gets deleted
//PlayerTalentMap::iterator plrTalent = m_talents[m_activeSpec]->find(talentInfo->RankID[rank]);
//if (plrTalent != m_talents[m_activeSpec]->end())
@@ -26191,7 +26215,7 @@ void Player::ActivateSpec(uint8 spec)
// if the talent can be found in the newly activated PlayerTalentMap
if (HasTalent(talentInfo->RankID[rank], m_activeSpec))
{
- learnSpell(talentInfo->RankID[rank], false); // add the talent to the PlayerSpellMap
+ LearnSpell(talentInfo->RankID[rank], false); // add the talent to the PlayerSpellMap
spentTalents += (rank + 1); // increment the spentTalents count
}
}
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 5f500b7f1d8..d815b37f98f 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1578,16 +1578,16 @@ class Player : public Unit, public GridObject<Player>
void SendProficiency(ItemClass itemClass, uint32 itemSubclassMask);
void SendInitialSpells();
- bool addSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false);
- void learnSpell(uint32 spell_id, bool dependent);
- void removeSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true);
- void resetSpells(bool myClassOnly = false);
+ bool AddSpell(uint32 spellId, bool active, bool learning, bool dependent, bool disabled, bool loading = false, bool fromSkill = false);
+ void LearnSpell(uint32 spell_id, bool dependent, bool fromSkill = false);
+ void RemoveSpell(uint32 spell_id, bool disabled = false, bool learn_low_rank = true);
+ void ResetSpells(bool myClassOnly = false);
void LearnCustomSpells();
void LearnDefaultSkills();
void LearnDefaultSkill(uint32 skillId, uint16 rank);
- void learnQuestRewardedSpells();
- void learnQuestRewardedSpells(Quest const* quest);
- void learnSpellHighRank(uint32 spellid);
+ void LearnQuestRewardedSpells();
+ void LearnQuestRewardedSpells(Quest const* quest);
+ void LearnSpellHighestRank(uint32 spellid);
void AddTemporarySpell(uint32 spellId);
void RemoveTemporarySpell(uint32 spellId);
void SetReputation(uint32 factionentry, uint32 value);
@@ -1595,8 +1595,8 @@ class Player : public Unit, public GridObject<Player>
std::string const& GetGuildName();
uint32 GetFreeTalentPoints() const { return GetUInt32Value(PLAYER_CHARACTER_POINTS1); }
void SetFreeTalentPoints(uint32 points);
- bool resetTalents(bool no_cost = false);
- uint32 resetTalentsCost() const;
+ bool ResetTalents(bool no_cost = false);
+ uint32 ResetTalentsCost() const;
void InitTalentForLevel();
void BuildPlayerTalentsInfoData(WorldPacket* data);
void BuildPetTalentsInfoData(WorldPacket* data);
@@ -1647,6 +1647,7 @@ class Player : public Unit, public GridObject<Player>
uint32 GetSpellCooldownDelay(uint32 spell_id) const;
void AddSpellAndCategoryCooldowns(SpellInfo const* spellInfo, uint32 itemId, Spell* spell = NULL, bool infinityCooldown = false);
void AddSpellCooldown(uint32 spell_id, uint32 itemid, time_t end_time);
+ void ModifySpellCooldown(uint32 spellId, int32 cooldown);
void SendCooldownEvent(SpellInfo const* spellInfo, uint32 itemId = 0, Spell* spell = NULL, bool setCooldown = true);
void ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs);
void RemoveSpellCooldown(uint32 spell_id, bool update = false);
@@ -1889,7 +1890,7 @@ class Player : public Unit, public GridObject<Player>
int16 GetSkillTempBonusValue(uint32 skill) const;
uint16 GetSkillStep(uint16 skill) const; // 0...6
bool HasSkill(uint32 skill) const;
- void learnSkillRewardedSpells(uint32 id, uint32 value);
+ void LearnSkillRewardedSpells(uint32 skillId, uint32 skillValue);
WorldLocation& GetTeleportDest() { return m_teleport_dest; }
bool IsBeingTeleported() const { return mSemaphoreTeleport_Near || mSemaphoreTeleport_Far; }
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 72c1a071487..730bafa4c06 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -6889,31 +6889,6 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
}
break;
}
- // Item - Shaman T10 Elemental 2P Bonus
- case 70811:
- {
- // Lightning Bolt & Chain Lightning
- if (procSpell->SpellFamilyFlags[0] & 0x3)
- {
- if (ToPlayer()->HasSpellCooldown(16166))
- {
- uint32 newCooldownDelay = ToPlayer()->GetSpellCooldownDelay(16166);
- if (newCooldownDelay < 3)
- newCooldownDelay = 0;
- else
- newCooldownDelay -= 2;
- ToPlayer()->AddSpellCooldown(16166, 0, uint32(time(NULL) + newCooldownDelay));
-
- WorldPacket data(SMSG_MODIFY_COOLDOWN, 4+8+4);
- data << uint32(16166); // Spell ID
- data << uint64(GetGUID()); // Player GUID
- data << int32(-2000); // Cooldown mod in milliseconds
- ToPlayer()->GetSession()->SendPacket(&data);
- return true;
- }
- }
- return false;
- }
// Item - Shaman T10 Elemental 4P Bonus
case 70817:
{
@@ -11156,6 +11131,9 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons
if (!spellInfo || !spellInfo->Effects[index].IsEffect())
return false;
+ if (spellInfo->Attributes & SPELL_ATTR0_UNAFFECTED_BY_INVULNERABILITY)
+ return false;
+
// If m_immuneToEffect type contain this effect type, IMMUNE effect.
uint32 effect = spellInfo->Effects[index].Effect;
SpellImmuneList const& effectList = m_spellImmune[IMMUNITY_EFFECT];
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp
index 45ecbf0c3df..00106d971ec 100644
--- a/src/server/game/Groups/Group.cpp
+++ b/src/server/game/Groups/Group.cpp
@@ -400,7 +400,6 @@ bool Group::AddMember(Player* player)
stmt->setUInt8(4, member.roles);
CharacterDatabase.Execute(stmt);
-
}
SendUpdate();
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index 9ad382b4686..6c4c657ba2c 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -1003,13 +1003,13 @@ void WorldSession::HandlePlayerLogin(LoginQueryHolder* holder)
// Apply at_login requests
if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_SPELLS))
{
- pCurrChar->resetSpells();
+ pCurrChar->ResetSpells();
SendNotification(LANG_RESET_SPELLS);
}
if (pCurrChar->HasAtLoginFlag(AT_LOGIN_RESET_TALENTS))
{
- pCurrChar->resetTalents(true);
+ pCurrChar->ResetTalents(true);
pCurrChar->SendTalentsInfoData(false); // original talents send already in to SendInitialPacketsBeforeAddToMap, resend reset state
SendNotification(LANG_RESET_TALENTS);
}
diff --git a/src/server/game/Handlers/NPCHandler.cpp b/src/server/game/Handlers/NPCHandler.cpp
index d8a518a24db..4f65bcee4e5 100644
--- a/src/server/game/Handlers/NPCHandler.cpp
+++ b/src/server/game/Handlers/NPCHandler.cpp
@@ -288,7 +288,7 @@ void WorldSession::HandleTrainerBuySpellOpcode(WorldPacket& recvData)
if (trainer_spell->IsCastable())
_player->CastSpell(_player, trainer_spell->spell, true);
else
- _player->learnSpell(spellId, false);
+ _player->LearnSpell(spellId, false);
WorldPacket data(SMSG_TRAINER_BUY_SUCCEEDED, 12);
data << uint64(guid);
diff --git a/src/server/game/Handlers/SkillHandler.cpp b/src/server/game/Handlers/SkillHandler.cpp
index 8a94753b692..92c7c60bca0 100644
--- a/src/server/game/Handlers/SkillHandler.cpp
+++ b/src/server/game/Handlers/SkillHandler.cpp
@@ -80,7 +80,7 @@ void WorldSession::HandleTalentWipeConfirmOpcode(WorldPacket& recvData)
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
- if (!(_player->resetTalents()))
+ if (!(_player->ResetTalents()))
{
WorldPacket data(MSG_TALENT_WIPE_CONFIRM, 8+4); //you have not any talent
data << uint64(0);
diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp
index d21ebca9a91..adef21fe7a2 100644
--- a/src/server/game/Instances/InstanceScript.cpp
+++ b/src/server/game/Instances/InstanceScript.cpp
@@ -148,7 +148,7 @@ void InstanceScript::AddDoor(GameObject* door, bool add)
if (add)
{
- data.bossInfo->door[data.type].insert(door);
+ data.bossInfo->door[data.type].insert(door->GetGUID());
switch (data.boundary)
{
default:
@@ -173,7 +173,7 @@ void InstanceScript::AddDoor(GameObject* door, bool add)
}
}
else
- data.bossInfo->door[data.type].erase(door);
+ data.bossInfo->door[data.type].erase(door->GetGUID());
}
if (add)
@@ -187,9 +187,9 @@ void InstanceScript::AddMinion(Creature* minion, bool add)
return;
if (add)
- itr->second.bossInfo->minion.insert(minion);
+ itr->second.bossInfo->minion.insert(minion->GetGUID());
else
- itr->second.bossInfo->minion.erase(minion);
+ itr->second.bossInfo->minion.erase(minion->GetGUID());
}
bool InstanceScript::SetBossState(uint32 id, EncounterState state)
@@ -210,8 +210,9 @@ bool InstanceScript::SetBossState(uint32 id, EncounterState state)
if (state == DONE)
for (MinionSet::iterator i = bossInfo->minion.begin(); i != bossInfo->minion.end(); ++i)
- if ((*i)->isWorldBoss() && (*i)->IsAlive())
- return false;
+ if (Creature* minion = instance->GetCreature(*i))
+ if (minion->isWorldBoss() && minion->IsAlive())
+ return false;
bossInfo->state = state;
SaveToDB();
@@ -219,10 +220,12 @@ bool InstanceScript::SetBossState(uint32 id, EncounterState state)
for (uint32 type = 0; type < MAX_DOOR_TYPES; ++type)
for (DoorSet::iterator i = bossInfo->door[type].begin(); i != bossInfo->door[type].end(); ++i)
- UpdateDoorState(*i);
+ if (GameObject* door = instance->GetGameObject(*i))
+ UpdateDoorState(door);
for (MinionSet::iterator i = bossInfo->minion.begin(); i != bossInfo->minion.end(); ++i)
- UpdateMinionState(*i, state);
+ if (Creature* minion = instance->GetCreature(*i))
+ UpdateMinionState(minion, state);
return true;
}
diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h
index 9e11c566c22..f379572961c 100644
--- a/src/server/game/Instances/InstanceScript.h
+++ b/src/server/game/Instances/InstanceScript.h
@@ -35,8 +35,8 @@ class Player;
class GameObject;
class Creature;
-typedef std::set<GameObject*> DoorSet;
-typedef std::set<Creature*> MinionSet;
+typedef std::set<uint64> DoorSet;
+typedef std::set<uint64> MinionSet;
enum EncounterFrameType
{
diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp
index 1de13d137c4..9c023b86bc9 100644
--- a/src/server/game/Maps/MapManager.cpp
+++ b/src/server/game/Maps/MapManager.cpp
@@ -131,21 +131,15 @@ bool MapManager::CanPlayerEnter(uint32 mapid, Player* player, bool loginCheck)
if (!instance)
return false;
- Difficulty targetDifficulty = player->GetDifficulty(entry->IsRaid());
- //The player has a heroic mode and tries to enter into instance which has no a heroic mode
- MapDifficulty const* mapDiff = GetMapDifficultyData(entry->MapID, targetDifficulty);
+ Difficulty targetDifficulty, requestedDifficulty;
+ targetDifficulty = requestedDifficulty = player->GetDifficulty(entry->IsRaid());
+ // Get the highest available difficulty if current setting is higher than the instance allows
+ MapDifficulty const* mapDiff = GetDownscaledMapDifficultyData(entry->MapID, targetDifficulty);
if (!mapDiff)
{
- // Send aborted message for dungeons
- if (entry->IsNonRaidDungeon())
- {
- player->SendTransferAborted(mapid, TRANSFER_ABORT_DIFFICULTY, player->GetDungeonDifficulty());
- return false;
- }
- else // attempt to downscale
- mapDiff = GetDownscaledMapDifficultyData(entry->MapID, targetDifficulty);
+ player->SendTransferAborted(mapid, TRANSFER_ABORT_DIFFICULTY, requestedDifficulty);
+ return false;
}
- // FIXME: mapDiff is never used
//Bypass checks for GMs
if (player->IsGameMaster())
diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp
index 3140fc23296..f2e1bb518d4 100644
--- a/src/server/game/Movement/PathGenerator.cpp
+++ b/src/server/game/Movement/PathGenerator.cpp
@@ -477,11 +477,29 @@ void PathGenerator::BuildPointPath(const float *startPoint, const float *endPoin
dtStatus dtResult = DT_FAILURE;
if (_straightLine)
{
- // if the path is a straight line then start and end position are enough
dtResult = DT_SUCCESS;
- pointCount = 2;
- memcpy(&pathPoints[0], startPoint, sizeof(float)* 3);
- memcpy(&pathPoints[3], endPoint, sizeof(float)* 3);
+ pointCount = 1;
+ memcpy(&pathPoints[VERTEX_SIZE * 0], startPoint, sizeof(float)* 3); // first point
+
+ // path has to be split into polygons with dist SMOOTH_PATH_STEP_SIZE between them
+ G3D::Vector3 startVec = G3D::Vector3(startPoint[0], startPoint[1], startPoint[2]);
+ G3D::Vector3 endVec = G3D::Vector3(endPoint[0], endPoint[1], endPoint[2]);
+ G3D::Vector3 diffVec = (endVec - startVec);
+ G3D::Vector3 prevVec = startVec;
+ float len = diffVec.length();
+ diffVec *= SMOOTH_PATH_STEP_SIZE / len;
+ while (len > SMOOTH_PATH_STEP_SIZE)
+ {
+ len -= SMOOTH_PATH_STEP_SIZE;
+ prevVec += diffVec;
+ pathPoints[VERTEX_SIZE * pointCount + 0] = prevVec.x;
+ pathPoints[VERTEX_SIZE * pointCount + 1] = prevVec.y;
+ pathPoints[VERTEX_SIZE * pointCount + 2] = prevVec.z;
+ ++pointCount;
+ }
+
+ memcpy(&pathPoints[VERTEX_SIZE * pointCount], endPoint, sizeof(float)* 3); // last point
+ ++pointCount;
}
else if (_useStraightPath)
{
diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp
index f1359b70aa6..ce01273ab3b 100644
--- a/src/server/game/Scripting/ScriptLoader.cpp
+++ b/src/server/game/Scripting/ScriptLoader.cpp
@@ -263,7 +263,6 @@ void AddSC_instance_zulgurub();
//void AddSC_alterac_mountains();
void AddSC_arathi_highlands();
void AddSC_blasted_lands();
-void AddSC_boss_kruul();
void AddSC_burning_steppes();
void AddSC_duskwood();
void AddSC_eastern_plaguelands();
@@ -978,7 +977,6 @@ void AddEasternKingdomsScripts()
//AddSC_alterac_mountains();
AddSC_arathi_highlands();
AddSC_blasted_lands();
- AddSC_boss_kruul();
AddSC_burning_steppes();
AddSC_duskwood();
AddSC_eastern_plaguelands();
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 0d7dd8819af..d223425a027 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -1305,6 +1305,7 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici
void Spell::SelectImplicitTargetDestTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType)
{
+ ASSERT(m_targets.GetObjectTarget() && "Spell::SelectImplicitTargetDestTargets - no explicit object target available!");
WorldObject* target = m_targets.GetObjectTarget();
SpellDestination dest(*target);
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index abeeb394218..4c0d5770cea 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -866,7 +866,10 @@ void Spell::EffectTriggerSpell(SpellEffIndex effIndex)
if (spellInfo->GetExplicitTargetMask() & TARGET_FLAG_DEST_LOCATION)
targets.SetDst(m_targets);
- targets.SetUnitTarget(m_caster);
+ if (Unit* target = m_targets.GetUnitTarget())
+ targets.SetUnitTarget(target);
+ else
+ targets.SetUnitTarget(m_caster);
}
CustomSpellValues values;
@@ -1227,7 +1230,7 @@ void Spell::EffectUnlearnSpecialization(SpellEffIndex effIndex)
Player* player = unitTarget->ToPlayer();
uint32 spellToUnlearn = m_spellInfo->Effects[effIndex].TriggerSpell;
- player->removeSpell(spellToUnlearn);
+ player->RemoveSpell(spellToUnlearn);
TC_LOG_DEBUG("spells", "Spell: Player %u has unlearned spell %u from NpcGUID: %u", player->GetGUIDLow(), spellToUnlearn, m_caster->GetGUIDLow());
}
@@ -2370,7 +2373,7 @@ void Spell::EffectLearnSpell(SpellEffIndex effIndex)
Player* player = unitTarget->ToPlayer();
uint32 spellToLearn = (m_spellInfo->Id == 483 || m_spellInfo->Id == 55884) ? damage : m_spellInfo->Effects[effIndex].TriggerSpell;
- player->learnSpell(spellToLearn, false);
+ player->LearnSpell(spellToLearn, false);
TC_LOG_DEBUG("spells", "Spell: Player %u has learned spell %u from NpcGUID=%u", player->GetGUIDLow(), spellToLearn, m_caster->GetGUIDLow());
}
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp
index 08bccd75f0c..631c4e61d5f 100644
--- a/src/server/game/World/World.cpp
+++ b/src/server/game/World/World.cpp
@@ -1781,7 +1781,7 @@ void World::SetInitialWorldSettings()
///- Initialize Battlegrounds
TC_LOG_INFO("server.loading", "Starting Battleground System");
- sBattlegroundMgr->CreateInitialBattlegrounds();
+ sBattlegroundMgr->LoadBattlegroundTemplates();
sBattlegroundMgr->InitAutomaticArenaPointDistribution();
///- Initialize outdoor pvp