[Sync] Some long overdue project sync pt2

This commit is contained in:
Antz 2019-01-09 23:01:24 +00:00 committed by Antz
parent 65ec4ea06e
commit f5bb0529c1
70 changed files with 1211 additions and 736 deletions

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -21,6 +21,7 @@
* World of Warcraft, and all World of Warcraft or Warcraft art, images, * World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc. * and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef __BATTLEGROUNDAA_H #ifndef __BATTLEGROUNDAA_H
#define __BATTLEGROUNDAA_H #define __BATTLEGROUNDAA_H

View file

@ -321,6 +321,13 @@ class BattleGroundAB : public BattleGround
* @param delay * @param delay
*/ */
void _CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay); void _CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay);
/**
* @brief
*
* @param node
* @param type
* @param teamIndex
*/
void _DelBanner(uint8 node, uint8 type, uint8 teamIndex); void _DelBanner(uint8 node, uint8 type, uint8 teamIndex);
/** /**
* @brief * @brief

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -21,6 +21,7 @@
* World of Warcraft, and all World of Warcraft or Warcraft art, images, * World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc. * and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef __BATTLEGROUNDBE_H #ifndef __BATTLEGROUNDBE_H
#define __BATTLEGROUNDBE_H #define __BATTLEGROUNDBE_H

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -21,6 +21,7 @@
* World of Warcraft, and all World of Warcraft or Warcraft art, images, * World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc. * and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef __BATTLEGROUNDDS_H #ifndef __BATTLEGROUNDDS_H
#define __BATTLEGROUNDDS_H #define __BATTLEGROUNDDS_H
@ -41,7 +42,11 @@ class BattleGroundDS : public BattleGround
public: public:
BattleGroundDS(); BattleGroundDS();
/* inherited from BattlegroundClass */ /**
* @brief inherited from BattlegroundClass
*
* @param plr
*/
virtual void AddPlayer(Player* plr) override; virtual void AddPlayer(Player* plr) override;
}; };
#endif #endif

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -61,7 +61,7 @@ void WorldSession::HandleBattlemasterHelloOpcode(WorldPacket& recv_data)
BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(pCreature->GetEntry()); BattleGroundTypeId bgTypeId = sBattleGroundMgr.GetBattleMasterBG(pCreature->GetEntry());
if (bgTypeId == BATTLEGROUND_TYPE_NONE) if (bgTypeId == BATTLEGROUND_TYPE_NONE)
return; { return; }
if (!_player->GetBGAccessByLevel(bgTypeId)) if (!_player->GetBGAccessByLevel(bgTypeId))
{ {
@ -112,7 +112,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data)
// ignore if player is already in BG // ignore if player is already in BG
if (_player->InBattleGround()) if (_player->InBattleGround())
return; { return; }
// get bg instance or bg template if instance not found // get bg instance or bg template if instance not found
BattleGround* bg = NULL; BattleGround* bg = NULL;
@ -158,7 +158,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recv_data)
if (!grp) if (!grp)
{ return; } { return; }
if (grp->GetLeaderGuid() != _player->GetObjectGuid()) if (grp->GetLeaderGuid() != _player->GetObjectGuid())
return; { return; }
err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0); err = grp->CanJoinBattleGroundQueue(bg, bgQueueTypeId, 0, bg->GetMaxPlayersPerTeam(), false, 0);
isPremade = sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH) && isPremade = sWorld.getConfig(CONFIG_UINT32_BATTLEGROUND_PREMADE_GROUP_WAIT_FOR_MATCH) &&
(grp->GetMembersCount() >= bg->GetMinPlayersPerTeam()); (grp->GetMembersCount() >= bg->GetMinPlayersPerTeam());
@ -286,7 +286,7 @@ void WorldSession::HandlePVPLogDataOpcode(WorldPacket & /*recv_data*/)
BattleGround* bg = _player->GetBattleGround(); BattleGround* bg = _player->GetBattleGround();
if (!bg) if (!bg)
{ return; } return;
// arena finish version will send in BattleGround::EndBattleGround directly // arena finish version will send in BattleGround::EndBattleGround directly
if (bg->isArena()) if (bg->isArena())
@ -393,7 +393,7 @@ void WorldSession::HandleBattleFieldPortOpcode(WorldPacket& recv_data)
if (!bracketEntry) if (!bracketEntry)
return; return;
// some checks if player isn't cheating - it is not exactly cheating, but we cannot allow it // some checks if player isn't cheating - it is not exactly cheating, but we can not allow it
if (action == 1 && ginfo.arenaType == ARENA_TYPE_NONE) if (action == 1 && ginfo.arenaType == ARENA_TYPE_NONE)
{ {
// if player is trying to enter battleground (not arena!) and he has deserter debuff, we must just remove him from queue // if player is trying to enter battleground (not arena!) and he has deserter debuff, we must just remove him from queue

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -41,7 +41,11 @@ class BattleGroundIC : public BattleGround
public: public:
BattleGroundIC(); BattleGroundIC();
/* inherited from BattlegroundClass */ /**
* @brief inherited from BattlegroundClass
*
* @param plr
*/
virtual void AddPlayer(Player* plr) override; virtual void AddPlayer(Player* plr) override;
/* Scorekeeping */ /* Scorekeeping */

View file

@ -2300,8 +2300,9 @@ void BattleGroundMgr::LoadBattleMastersEntry()
{ {
BarGoLink bar(1); BarGoLink bar(1);
bar.step(); bar.step();
sLog.outString(">> Loaded 0 battlemaster entries - table is empty!");
sLog.outString(); sLog.outString();
sLog.outString(">> Loaded 0 battlemaster entries - table is empty!");
return; return;
} }
@ -2328,8 +2329,8 @@ void BattleGroundMgr::LoadBattleMastersEntry()
delete result; delete result;
sLog.outString(">> Loaded %u battlemaster entries", count);
sLog.outString(); sLog.outString();
sLog.outString(">> Loaded %u battlemaster entries", count);
} }
HolidayIds BattleGroundMgr::BGTypeToWeekendHolidayId(BattleGroundTypeId bgTypeId) HolidayIds BattleGroundMgr::BGTypeToWeekendHolidayId(BattleGroundTypeId bgTypeId)
@ -2417,8 +2418,9 @@ void BattleGroundMgr::LoadBattleEventIndexes()
{ {
BarGoLink bar(1); BarGoLink bar(1);
bar.step(); bar.step();
sLog.outErrorDb(">> Loaded 0 battleground eventindexes.");
sLog.outString(); sLog.outString();
sLog.outErrorDb(">> Loaded 0 battleground eventindexes.");
return; return;
} }
@ -2477,7 +2479,7 @@ void BattleGroundMgr::LoadBattleEventIndexes()
} }
while (result->NextRow()); while (result->NextRow());
sLog.outString(">> Loaded %u battleground eventindexes", count);
sLog.outString(); sLog.outString();
sLog.outString(">> Loaded %u battleground eventindexes", count);
delete result; delete result;
} }

View file

@ -132,6 +132,15 @@ class BattleGroundQueue
*/ */
~BattleGroundQueue(); ~BattleGroundQueue();
/**
* @brief
*
* @param bgTypeId
* @param bracket_id
* @param ArenaType
* @param isRated
* @param minRating
*/
void Update(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id, ArenaType arenaType = ARENA_TYPE_NONE, bool isRated = false, uint32 minRating = 0); void Update(BattleGroundTypeId bgTypeId, BattleGroundBracketId bracket_id, ArenaType arenaType = ARENA_TYPE_NONE, bool isRated = false, uint32 minRating = 0);
/** /**

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -21,6 +21,7 @@
* World of Warcraft, and all World of Warcraft or Warcraft art, images, * World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc. * and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef __BATTLEGROUNDNA_H #ifndef __BATTLEGROUNDNA_H
#define __BATTLEGROUNDNA_H #define __BATTLEGROUNDNA_H

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -41,7 +41,11 @@ class BattleGroundRB : public BattleGround
public: public:
BattleGroundRB(); BattleGroundRB();
/* inherited from BattlegroundClass */ /**
* @brief inherited from BattlegroundClass
*
* @param plr
*/
virtual void AddPlayer(Player* plr) override; virtual void AddPlayer(Player* plr) override;
/* Scorekeeping */ /* Scorekeeping */

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -21,6 +21,7 @@
* World of Warcraft, and all World of Warcraft or Warcraft art, images, * World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc. * and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef __BATTLEGROUNDRL_H #ifndef __BATTLEGROUNDRL_H
#define __BATTLEGROUNDRL_H #define __BATTLEGROUNDRL_H

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -21,6 +21,7 @@
* World of Warcraft, and all World of Warcraft or Warcraft art, images, * World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc. * and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef __BATTLEGROUNDRV_H #ifndef __BATTLEGROUNDRV_H
#define __BATTLEGROUNDRV_H #define __BATTLEGROUNDRV_H
@ -41,7 +42,11 @@ class BattleGroundRV : public BattleGround
public: public:
BattleGroundRV(); BattleGroundRV();
/* inherited from BattlegroundClass */ /**
* @brief inherited from BattlegroundClass
*
* @param plr
*/
virtual void AddPlayer(Player* plr) override; virtual void AddPlayer(Player* plr) override;
}; };
#endif #endif

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -44,7 +44,11 @@ class BattleGroundSA : public BattleGround
public: public:
BattleGroundSA(); BattleGroundSA();
/* inherited from BattlegroundClass */ /**
* @brief inherited from BattlegroundClass
*
* @param plr
*/
virtual void AddPlayer(Player* plr) override; virtual void AddPlayer(Player* plr) override;
/* Scorekeeping */ /* Scorekeeping */

View file

@ -165,7 +165,9 @@ bool ChatHandler::HandleGMCommand(char* args)
m_session->SendNotification(LANG_GM_ON); m_session->SendNotification(LANG_GM_ON);
} }
else else
{
m_session->SendNotification(LANG_GM_OFF); m_session->SendNotification(LANG_GM_OFF);
}
return true; return true;
} }

View file

@ -59,7 +59,6 @@ AuctionHouseMgr::~AuctionHouseMgr()
{ delete itr->second; } { delete itr->second; }
} }
AuctionHouseObject* AuctionHouseMgr::GetAuctionsMap(AuctionHouseEntry const* house) AuctionHouseObject* AuctionHouseMgr::GetAuctionsMap(AuctionHouseEntry const* house)
{ {
if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION)) if (sWorld.getConfig(CONFIG_BOOL_ALLOW_TWO_SIDE_INTERACTION_AUCTION))
@ -381,7 +380,6 @@ void AuctionHouseMgr::LoadAuctions()
auction->itemTemplate = fields[3].GetUInt32(); auction->itemTemplate = fields[3].GetUInt32();
auction->itemCount = fields[4].GetUInt32(); auction->itemCount = fields[4].GetUInt32();
auction->itemRandomPropertyId = fields[5].GetUInt32(); auction->itemRandomPropertyId = fields[5].GetUInt32();
auction->owner = fields[6].GetUInt32(); auction->owner = fields[6].GetUInt32();
if (auction->owner) if (auction->owner)

View file

@ -33,11 +33,11 @@ ObjectPosSelector::ObjectPosSelector(float x, float y, float dist, float searche
{ {
// if size == 0, m_anglestep will become 0 -> freeze // if size == 0, m_anglestep will become 0 -> freeze
if (searchedForSize == 0.0f) if (searchedForSize == 0.0f)
searchedForSize = DEFAULT_WORLD_OBJECT_SIZE; { searchedForSize = DEFAULT_WORLD_OBJECT_SIZE; }
// undefined behaviour // undefined behaviour
if (m_searcherDist == 0.0f) if (m_searcherDist == 0.0f)
m_searcherDist = DEFAULT_WORLD_OBJECT_SIZE; { m_searcherDist = DEFAULT_WORLD_OBJECT_SIZE; }
m_searchedForReqHAngle = atan(OCCUPY_POS_ANGLE_ATAN_FACTOR * searchedForSize / m_searcherDist); m_searchedForReqHAngle = atan(OCCUPY_POS_ANGLE_ATAN_FACTOR * searchedForSize / m_searcherDist);
@ -64,15 +64,15 @@ void ObjectPosSelector::AddUsedArea(WorldObject const* obj, float angle, float d
// skip some unexpected results. // skip some unexpected results.
if (dist == 0.0f) if (dist == 0.0f)
return; { return; }
// (half) angle that obj occupies // (half) angle that obj occupies
float sr_angle = atan(OCCUPY_POS_ANGLE_ATAN_FACTOR * obj->GetObjectBoundingRadius() / dist); float sr_angle = atan(OCCUPY_POS_ANGLE_ATAN_FACTOR * obj->GetObjectBoundingRadius() / dist);
if (angle >= 0) if (angle >= 0)
m_UsedAreaLists[USED_POS_PLUS].insert(UsedArea(angle, OccupiedArea(sr_angle, obj))); { m_UsedAreaLists[USED_POS_PLUS].insert(UsedArea(angle, OccupiedArea(sr_angle, obj))); }
else else
m_UsedAreaLists[USED_POS_MINUS].insert(UsedArea(-angle, OccupiedArea(sr_angle, obj))); { m_UsedAreaLists[USED_POS_MINUS].insert(UsedArea(-angle, OccupiedArea(sr_angle, obj))); }
} }
/** /**
@ -86,9 +86,9 @@ void ObjectPosSelector::AddUsedArea(WorldObject const* obj, float angle, float d
*/ */
bool ObjectPosSelector::CheckAngle(UsedArea const& usedArea, UsedAreaSide side, float angle) const bool ObjectPosSelector::CheckAngle(UsedArea const& usedArea, UsedAreaSide side, float angle) const
{ {
float used_offset = usedArea.second.angleOffset;
float used_angle = usedArea.first * SignOf(side); float used_angle = usedArea.first * SignOf(side);
// check first left/right used angles if exists float used_offset = usedArea.second.angleOffset;
return fabs(used_angle - angle) > used_offset || (m_searchPosFor && usedArea.second.occupyingObj == m_searchPosFor); return fabs(used_angle - angle) > used_offset || (m_searchPosFor && usedArea.second.occupyingObj == m_searchPosFor);
} }
@ -119,6 +119,7 @@ void ObjectPosSelector::InitializeAngle()
void ObjectPosSelector::InitializeAngle(UsedAreaSide side) void ObjectPosSelector::InitializeAngle(UsedAreaSide side)
{ {
m_nextUsedAreaItr[side] = m_UsedAreaLists[side].begin(); m_nextUsedAreaItr[side] = m_UsedAreaLists[side].begin();
// if another side not alow use 0.0f angle calculate possible value in 0..m_searchedForReqHAngle range // if another side not alow use 0.0f angle calculate possible value in 0..m_searchedForReqHAngle range
if (!m_UsedAreaLists[~side].empty()) if (!m_UsedAreaLists[~side].empty())
{ {
@ -126,7 +127,7 @@ void ObjectPosSelector::InitializeAngle(UsedAreaSide side)
m_stepAngle[side] = std::max(m_searchedForReqHAngle + otherArea.second.angleOffset - otherArea.first, 0.0f); m_stepAngle[side] = std::max(m_searchedForReqHAngle + otherArea.second.angleOffset - otherArea.first, 0.0f);
} }
else // Other side empty. start from 0 else // Other side empty. start from 0
m_stepAngle[side] = 0.0f; { m_stepAngle[side] = 0.0f; }
// As m_stepAngle will be incremented first in ::NextSideAngle // As m_stepAngle will be incremented first in ::NextSideAngle
m_stepAngle[side] -= m_searchedForReqHAngle; m_stepAngle[side] -= m_searchedForReqHAngle;
@ -148,17 +149,17 @@ bool ObjectPosSelector::NextAngle(float& angle)
if (m_stepAngle[USED_POS_PLUS] < M_PI_F && m_stepAngle[USED_POS_PLUS] <= m_stepAngle[USED_POS_MINUS]) if (m_stepAngle[USED_POS_PLUS] < M_PI_F && m_stepAngle[USED_POS_PLUS] <= m_stepAngle[USED_POS_MINUS])
{ {
if (NextSideAngle(USED_POS_PLUS, angle)) if (NextSideAngle(USED_POS_PLUS, angle))
return true; { return true; }
} }
// -- direction less updated // -- direction less updated
else if (m_stepAngle[USED_POS_MINUS] < M_PI_F) else if (m_stepAngle[USED_POS_MINUS] < M_PI_F)
{ {
if (NextSideAngle(USED_POS_MINUS, angle)) if (NextSideAngle(USED_POS_MINUS, angle))
return true; { return true; }
} }
// both sides finishes // both sides finishes
else else
break; { break; }
} }
// no angles // no angles
@ -181,7 +182,7 @@ bool ObjectPosSelector::NextSideAngle(UsedAreaSide side, float& angle)
// prevent jump to another side // prevent jump to another side
if (m_stepAngle[side] > M_PI_F) if (m_stepAngle[side] > M_PI_F)
return false; { return false; }
// no used area anymore on this side // no used area anymore on this side
if (m_nextUsedAreaItr[side] == m_UsedAreaLists[side].end()) if (m_nextUsedAreaItr[side] == m_UsedAreaLists[side].end())
@ -218,7 +219,7 @@ bool ObjectPosSelector::NextUsedAngle(float& angle)
{ {
if (m_nextUsedAreaItr[USED_POS_PLUS] == m_UsedAreaLists[USED_POS_PLUS].end() && if (m_nextUsedAreaItr[USED_POS_PLUS] == m_UsedAreaLists[USED_POS_PLUS].end() &&
m_nextUsedAreaItr[USED_POS_MINUS] == m_UsedAreaLists[USED_POS_MINUS].end()) m_nextUsedAreaItr[USED_POS_MINUS] == m_UsedAreaLists[USED_POS_MINUS].end())
return false; { return false; }
// ++ direction less updated // ++ direction less updated
if (m_nextUsedAreaItr[USED_POS_PLUS] != m_UsedAreaLists[USED_POS_PLUS].end() && if (m_nextUsedAreaItr[USED_POS_PLUS] != m_UsedAreaLists[USED_POS_PLUS].end() &&

View file

@ -51,7 +51,7 @@ Pet::Pet(PetType type) :
CharmInfo* charmInfo = InitCharmInfo(this); CharmInfo* charmInfo = InitCharmInfo(this);
if (type == MINI_PET) // always passive if (type == MINI_PET) // always passive
charmInfo->SetReactState(REACT_PASSIVE); { charmInfo->SetReactState(REACT_PASSIVE); }
} }
Pet::~Pet() Pet::~Pet()
@ -63,7 +63,7 @@ void Pet::AddToWorld()
{ {
///- Register the pet for guid lookup ///- Register the pet for guid lookup
if (!IsInWorld()) if (!IsInWorld())
GetMap()->GetObjectsStore().insert<Pet>(GetObjectGuid(), (Pet*)this); { GetMap()->GetObjectsStore().insert<Pet>(GetObjectGuid(), (Pet*)this); }
Unit::AddToWorld(); Unit::AddToWorld();
} }
@ -72,7 +72,7 @@ void Pet::RemoveFromWorld()
{ {
///- Remove the pet from the accessor ///- Remove the pet from the accessor
if (IsInWorld()) if (IsInWorld())
GetMap()->GetObjectsStore().erase<Pet>(GetObjectGuid(), (Pet*)NULL); { GetMap()->GetObjectsStore().erase<Pet>(GetObjectGuid(), (Pet*)NULL); }
///- Don't call the function for Creature, normal mobs + totems go in a different storage ///- Don't call the function for Creature, normal mobs + totems go in a different storage
Unit::RemoveFromWorld(); Unit::RemoveFromWorld();
@ -95,13 +95,13 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
// current pet (slot 0) 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 // current pet (slot 0) 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType "
"FROM character_pet WHERE owner = '%u' AND slot = '%u'", "FROM character_pet WHERE owner = '%u' AND slot = '%u'",
ownerid, PET_SAVE_AS_CURRENT ); ownerid, PET_SAVE_AS_CURRENT);
else if (petentry) else if (petentry)
// known petentry entry (unique for summoned pet, but non unique for hunter pet (only from current or not stabled pets) // known petentry entry (unique for summoned pet, but non unique for hunter pet (only from current or not stabled pets)
// 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 // 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType " result = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, slot, name, renamed, curhealth, curmana, abdata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType "
"FROM character_pet WHERE owner = '%u' AND entry = '%u' AND (slot = '%u' OR slot > '%u') ", "FROM character_pet WHERE owner = '%u' AND entry = '%u' AND (slot = '%u' OR slot > '%u') ",
ownerid, petentry,PET_SAVE_AS_CURRENT,PET_SAVE_LAST_STABLE_SLOT); ownerid, petentry, PET_SAVE_AS_CURRENT, PET_SAVE_LAST_STABLE_SLOT);
else else
// any current or other non-stabled pet (for hunter "call pet") // any current or other non-stabled pet (for hunter "call pet")
// 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 // 0 1 2(?) 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
@ -200,7 +200,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
sLog.outError("Pet have incorrect type (%u) for pet loading.", getPetType()); sLog.outError("Pet have incorrect type (%u) for pet loading.", getPetType());
if (owner->IsPvP()) if (owner->IsPvP())
SetPvP(true); { SetPvP(true); }
if (owner->IsFFAPvP()) if (owner->IsFFAPvP())
SetFFAPvP(true); SetFFAPvP(true);
@ -292,7 +292,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
{ {
((Player*)owner)->PetSpellInitialize(); ((Player*)owner)->PetSpellInitialize();
if (((Player*)owner)->GetGroup()) if (((Player*)owner)->GetGroup())
((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_PET); { ((Player*)owner)->SetGroupUpdateFlag(GROUP_UPDATE_PET); }
((Player*)owner)->SendTalentsInfoData(true); ((Player*)owner)->SendTalentsInfoData(true);
} }
@ -323,19 +323,19 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petentry, uint32 petnumber, bool c
void Pet::SavePetToDB(PetSaveMode mode) void Pet::SavePetToDB(PetSaveMode mode)
{ {
if (!GetEntry()) if (!GetEntry())
return; { return; }
// save only fully controlled creature // save only fully controlled creature
if (!isControlled()) if (!isControlled())
return; { return; }
// not save not player pets // not save not player pets
if (!GetOwnerGuid().IsPlayer()) if (!GetOwnerGuid().IsPlayer())
return; { return; }
Player* pOwner = (Player*)GetOwner(); Player* pOwner = (Player*)GetOwner();
if (!pOwner) if (!pOwner)
return; { return; }
// current/stable/not_in_slot // current/stable/not_in_slot
if (mode >= PET_SAVE_AS_CURRENT) if (mode >= PET_SAVE_AS_CURRENT)
@ -355,7 +355,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
{ {
// pet will lost anyway at restore temporary unsummoned // pet will lost anyway at restore temporary unsummoned
if (getPetType() == HUNTER_PET) if (getPetType() == HUNTER_PET)
return; { return; }
// for warlock case // for warlock case
mode = PET_SAVE_NOT_IN_SLOT; mode = PET_SAVE_NOT_IN_SLOT;
@ -366,7 +366,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
// stable and not in slot saves // stable and not in slot saves
if (mode != PET_SAVE_AS_CURRENT) if (mode != PET_SAVE_AS_CURRENT)
RemoveAllAuras(); { RemoveAllAuras(); }
// save pet's data as one single transaction // save pet's data as one single transaction
CharacterDatabase.BeginTransaction(); CharacterDatabase.BeginTransaction();
@ -445,7 +445,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
void Pet::DeleteFromDB(uint32 guidlow, bool separate_transaction) void Pet::DeleteFromDB(uint32 guidlow, bool separate_transaction)
{ {
if (separate_transaction) if (separate_transaction)
CharacterDatabase.BeginTransaction(); { CharacterDatabase.BeginTransaction(); }
static SqlStatementID delPet ; static SqlStatementID delPet ;
static SqlStatementID delDeclName ; static SqlStatementID delDeclName ;
@ -469,7 +469,7 @@ void Pet::DeleteFromDB(uint32 guidlow, bool separate_transaction)
stmt.PExecute(guidlow); stmt.PExecute(guidlow);
if (separate_transaction) if (separate_transaction)
CharacterDatabase.CommitTransaction(); { CharacterDatabase.CommitTransaction(); }
} }
void Pet::SetDeathState(DeathState s) // overwrite virtual Creature::SetDeathState and Unit::SetDeathState void Pet::SetDeathState(DeathState s) // overwrite virtual Creature::SetDeathState and Unit::SetDeathState
@ -479,7 +479,7 @@ void Pet::SetDeathState(DeathState s) // overwrite virtual
{ {
// remove summoned pet (no corpse) // remove summoned pet (no corpse)
if (getPetType() == SUMMON_PET) if (getPetType() == SUMMON_PET)
Unsummon(PET_SAVE_NOT_IN_SLOT); { Unsummon(PET_SAVE_NOT_IN_SLOT); }
// other will despawn at corpse desppawning (Pet::Update code) // other will despawn at corpse desppawning (Pet::Update code)
else else
{ {
@ -500,7 +500,7 @@ void Pet::SetDeathState(DeathState s) // overwrite virtual
void Pet::Update(uint32 update_diff, uint32 diff) void Pet::Update(uint32 update_diff, uint32 diff)
{ {
if (m_removed) // pet already removed, just wait in remove queue, no updates if (m_removed) // pet already removed, just wait in remove queue, no updates
return; { return; }
switch (m_deathState) switch (m_deathState)
{ {
@ -538,7 +538,7 @@ void Pet::Update(uint32 update_diff, uint32 diff)
if (m_duration > 0) if (m_duration > 0)
{ {
if (m_duration > (int32)update_diff) if (m_duration > (int32)update_diff)
m_duration -= (int32)update_diff; { m_duration -= (int32)update_diff; }
else else
{ {
Unsummon(getPetType() != SUMMON_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT, owner); Unsummon(getPetType() != SUMMON_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT, owner);
@ -560,14 +560,14 @@ void Pet::RegenerateAll(uint32 update_diff)
if (m_regenTimer <= update_diff) if (m_regenTimer <= update_diff)
{ {
if (!IsInCombat() || IsPolymorphed()) if (!IsInCombat() || IsPolymorphed())
RegenerateHealth(); { RegenerateHealth(); }
RegeneratePower(); RegeneratePower();
m_regenTimer = 4000; m_regenTimer = 4000;
} }
else else
m_regenTimer -= update_diff; { m_regenTimer -= update_diff; }
} }
bool Pet::CanTakeMoreActiveSpells(uint32 spellid) bool Pet::CanTakeMoreActiveSpells(uint32 spellid)
@ -576,17 +576,17 @@ bool Pet::CanTakeMoreActiveSpells(uint32 spellid)
uint32 chainstartstore[ACTIVE_SPELLS_MAX]; uint32 chainstartstore[ACTIVE_SPELLS_MAX];
if (IsPassiveSpell(spellid)) if (IsPassiveSpell(spellid))
return true; { return true; }
chainstartstore[0] = sSpellMgr.GetFirstSpellInChain(spellid); chainstartstore[0] = sSpellMgr.GetFirstSpellInChain(spellid);
for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr) for (PetSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
{ {
if (itr->second.state == PETSPELL_REMOVED) if (itr->second.state == PETSPELL_REMOVED)
continue; { continue; }
if (IsPassiveSpell(itr->first)) if (IsPassiveSpell(itr->first))
continue; { continue; }
uint32 chainstart = sSpellMgr.GetFirstSpellInChain(itr->first); uint32 chainstart = sSpellMgr.GetFirstSpellInChain(itr->first);
@ -595,14 +595,14 @@ bool Pet::CanTakeMoreActiveSpells(uint32 spellid)
for (x = 0; x < activecount; ++x) for (x = 0; x < activecount; ++x)
{ {
if (chainstart == chainstartstore[x]) if (chainstart == chainstartstore[x])
break; { break; }
} }
if (x == activecount) // spellchain not yet saved -> add active count if (x == activecount) // spellchain not yet saved -> add active count
{ {
++activecount; ++activecount;
if (activecount > ACTIVE_SPELLS_MAX) if (activecount > ACTIVE_SPELLS_MAX)
return false; { return false; }
chainstartstore[x] = chainstart; chainstartstore[x] = chainstart;
} }
} }
@ -612,30 +612,29 @@ bool Pet::CanTakeMoreActiveSpells(uint32 spellid)
void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/) void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/)
{ {
if (!owner) if (!owner)
owner = GetOwner(); { owner = GetOwner(); }
CombatStop(); CombatStop();
if (owner) if (owner)
{ {
if (GetOwnerGuid() != owner->GetObjectGuid()) if (GetOwnerGuid() != owner->GetObjectGuid())
return; { return; }
Player* p_owner = owner->GetTypeId() == TYPEID_PLAYER ? (Player*)owner : NULL; Player* p_owner = owner->GetTypeId() == TYPEID_PLAYER ? (Player*)owner : NULL;
if (p_owner) if (p_owner)
{ {
// not save secondary permanent pet as current // not save secondary permanent pet as current
if (mode == PET_SAVE_AS_CURRENT && p_owner->GetTemporaryUnsummonedPetNumber() && if (mode == PET_SAVE_AS_CURRENT && p_owner->GetTemporaryUnsummonedPetNumber() &&
p_owner->GetTemporaryUnsummonedPetNumber() != GetCharmInfo()->GetPetNumber()) p_owner->GetTemporaryUnsummonedPetNumber() != GetCharmInfo()->GetPetNumber())
mode = PET_SAVE_NOT_IN_SLOT; { mode = PET_SAVE_NOT_IN_SLOT; }
if (mode == PET_SAVE_REAGENTS) if (mode == PET_SAVE_REAGENTS)
{ {
// returning of reagents only for players, so best done here // returning of reagents only for players, so best done here
uint32 spellId = GetUInt32Value(UNIT_CREATED_BY_SPELL); uint32 spellId = GetUInt32Value(UNIT_CREATED_BY_SPELL);
SpellEntry const *spellInfo = sSpellStore.LookupEntry(spellId); SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellId);
SpellReagentsEntry const* spellReagents = spellInfo ? spellInfo->GetSpellReagents() : NULL; SpellReagentsEntry const* spellReagents = spellInfo ? spellInfo->GetSpellReagents() : NULL;
if (spellReagents) if (spellReagents)
@ -644,7 +643,7 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/)
{ {
if (spellReagents->Reagent[i] > 0) if (spellReagents->Reagent[i] > 0)
{ {
ItemPosCountVec dest; //for succubus, voidwalker, felhunter and felguard credit soulshard when despawn reason other than death (out of range, logout) ItemPosCountVec dest; // for succubus, voidwalker, felhunter and felguard credit soulshard when despawn reason other than death (out of range, logout)
uint8 msg = p_owner->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, spellReagents->Reagent[i], spellReagents->ReagentCount[i]); uint8 msg = p_owner->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, spellReagents->Reagent[i], spellReagents->ReagentCount[i]);
if (msg == EQUIP_ERR_OK) if (msg == EQUIP_ERR_OK)
{ {
@ -662,7 +661,7 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/)
p_owner->RemovePetActionBar(); p_owner->RemovePetActionBar();
if (p_owner->GetGroup()) if (p_owner->GetGroup())
p_owner->SetGroupUpdateFlag(GROUP_UPDATE_PET); { p_owner->SetGroupUpdateFlag(GROUP_UPDATE_PET); }
} }
} }
@ -679,7 +678,7 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/)
break; break;
default: default:
if (owner->GetPetGuid() == GetObjectGuid()) if (owner->GetPetGuid() == GetObjectGuid())
owner->SetPet(NULL); { owner->SetPet(NULL); }
break; break;
} }
} }
@ -692,20 +691,20 @@ void Pet::Unsummon(PetSaveMode mode, Unit* owner /*= NULL*/)
void Pet::GivePetXP(uint32 xp) void Pet::GivePetXP(uint32 xp)
{ {
if (getPetType() != HUNTER_PET) if (getPetType() != HUNTER_PET)
return; { return; }
if (xp < 1) if (xp < 1)
return; { return; }
if (!IsAlive()) if (!IsAlive())
return; { return; }
uint32 level = getLevel(); uint32 level = getLevel();
uint32 maxlevel = std::min(sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL), GetOwner()->getLevel()); uint32 maxlevel = std::min(sWorld.getConfig(CONFIG_UINT32_MAX_PLAYER_LEVEL), GetOwner()->getLevel());
// pet not receive xp for level equal to owner level // pet not receive xp for level equal to owner level
if (level >= maxlevel) if (level >= maxlevel)
return; { return; }
xp *= sWorld.getConfig(CONFIG_FLOAT_RATE_PET_XP_KILL); xp *= sWorld.getConfig(CONFIG_FLOAT_RATE_PET_XP_KILL);
@ -729,7 +728,7 @@ void Pet::GivePetXP(uint32 xp)
void Pet::GivePetLevel(uint32 level) void Pet::GivePetLevel(uint32 level)
{ {
if (!level || level == getLevel()) if (!level || level == getLevel())
return; { return; }
if (getPetType() == HUNTER_PET) if (getPetType() == HUNTER_PET)
{ {
@ -757,7 +756,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
BASIC_LOG("Create pet"); BASIC_LOG("Create pet");
uint32 pet_number = sObjectMgr.GeneratePetNumber(); uint32 pet_number = sObjectMgr.GeneratePetNumber();
if (!Create(guid, pos, creature->GetCreatureInfo(), pet_number)) if (!Create(guid, pos, creature->GetCreatureInfo(), pet_number))
return false; { return false; }
CreatureInfo const* cInfo = GetCreatureInfo(); CreatureInfo const* cInfo = GetCreatureInfo();
if (!cInfo) if (!cInfo)
@ -775,9 +774,9 @@ bool Pet::CreateBaseAtCreature(Creature* creature)
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
if (CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->Family)) if (CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->Family))
SetName(cFamily->Name[sWorld.GetDefaultDbcLocale()]); { SetName(cFamily->Name[sWorld.GetDefaultDbcLocale()]); }
else else
SetName(creature->GetNameForLocaleIdx(sObjectMgr.GetDBCLocaleIndex())); { SetName(creature->GetNameForLocaleIdx(sObjectMgr.GetDBCLocaleIndex())); }
SetByteValue(UNIT_FIELD_BYTES_0, 1, CLASS_WARRIOR); SetByteValue(UNIT_FIELD_BYTES_0, 1, CLASS_WARRIOR);
SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_NONE); SetByteValue(UNIT_FIELD_BYTES_0, 2, GENDER_NONE);
@ -919,7 +918,7 @@ void Pet::InitStatsForLevel(uint32 petlevel)
// 40% damage bonus of mage's frost damage // 40% damage bonus of mage's frost damage
float val = owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST) * 0.4f; float val = owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FROST) * 0.4f;
if (val < 0) if (val < 0)
val = 0; { val = 0; }
SetBonusDamage(int32(val)); SetBonusDamage(int32(val));
break; break;
} }
@ -1098,15 +1097,15 @@ void Pet::InitStatsForLevel(uint32 petlevel)
bool Pet::HaveInDiet(ItemPrototype const* item) const bool Pet::HaveInDiet(ItemPrototype const* item) const
{ {
if (!item->FoodType) if (!item->FoodType)
return false; { return false; }
CreatureInfo const* cInfo = GetCreatureInfo(); CreatureInfo const* cInfo = GetCreatureInfo();
if (!cInfo) if (!cInfo)
return false; { return false; }
CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->Family); CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->Family);
if (!cFamily) if (!cFamily)
return false; { return false; }
uint32 diet = cFamily->petFoodMask; uint32 diet = cFamily->petFoodMask;
uint32 FoodMask = 1 << (item->FoodType - 1); uint32 FoodMask = 1 << (item->FoodType - 1);
@ -1117,16 +1116,16 @@ uint32 Pet::GetCurrentFoodBenefitLevel(uint32 itemlevel)
{ {
// -5 or greater food level // -5 or greater food level
if (getLevel() <= itemlevel + 5) // possible to feed level 60 pet with level 55 level food for full effect if (getLevel() <= itemlevel + 5) // possible to feed level 60 pet with level 55 level food for full effect
return 35000; { return 35000; }
// -10..-6 // -10..-6
else if (getLevel() <= itemlevel + 10) // pure guess, but sounds good else if (getLevel() <= itemlevel + 10) // pure guess, but sounds good
return 17000; { return 17000; }
// -14..-11 // -14..-11
else if (getLevel() <= itemlevel + 14) // level 55 food gets green on 70, makes sense to me else if (getLevel() <= itemlevel + 14) // level 55 food gets green on 70, makes sense to me
return 8000; { return 8000; }
// -15 or less // -15 or less
else else
return 0; // food too low level { return 0; } // food too low level
} }
void Pet::_LoadSpellCooldowns() void Pet::_LoadSpellCooldowns()
@ -1159,7 +1158,7 @@ void Pet::_LoadSpellCooldowns()
// skip outdated cooldown // skip outdated cooldown
if (db_time <= curTime) if (db_time <= curTime)
continue; { continue; }
data << uint32(spell_id); data << uint32(spell_id);
data << uint32(uint32(db_time - curTime)*IN_MILLISECONDS); data << uint32(uint32(db_time - curTime)*IN_MILLISECONDS);
@ -1193,7 +1192,7 @@ void Pet::_SaveSpellCooldowns()
for (CreatureSpellCooldowns::iterator itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end();) for (CreatureSpellCooldowns::iterator itr = m_CreatureSpellCooldowns.begin(); itr != m_CreatureSpellCooldowns.end();)
{ {
if (itr->second <= curTime) if (itr->second <= curTime)
m_CreatureSpellCooldowns.erase(itr++); { m_CreatureSpellCooldowns.erase(itr++); }
else else
{ {
stmt = CharacterDatabase.CreateStatement(insSpellCD, "INSERT INTO pet_spell_cooldown (guid,spell,time) VALUES (?, ?, ?)"); stmt = CharacterDatabase.CreateStatement(insSpellCD, "INSERT INTO pet_spell_cooldown (guid,spell,time) VALUES (?, ?, ?)");
@ -1232,7 +1231,7 @@ void Pet::_SaveSpells()
// prevent saving family passives to DB // prevent saving family passives to DB
if (itr->second.type == PETSPELL_FAMILY) if (itr->second.type == PETSPELL_FAMILY)
continue; { continue; }
switch (itr->second.state) switch (itr->second.state)
{ {
@ -1304,12 +1303,12 @@ void Pet::_LoadAuras(uint32 timediff)
// do not load single target auras (unless they were cast by the player) // do not load single target auras (unless they were cast by the player)
if (casterGuid != GetObjectGuid() && IsSingleTargetSpell(spellproto)) if (casterGuid != GetObjectGuid() && IsSingleTargetSpell(spellproto))
continue; { continue; }
if (remaintime != -1 && !IsPositiveSpell(spellproto)) if (remaintime != -1 && !IsPositiveSpell(spellproto))
{ {
if (remaintime / IN_MILLISECONDS <= int32(timediff)) if (remaintime / IN_MILLISECONDS <= int32(timediff))
continue; { continue; }
remaintime -= timediff * IN_MILLISECONDS; remaintime -= timediff * IN_MILLISECONDS;
} }
@ -1322,15 +1321,15 @@ void Pet::_LoadAuras(uint32 timediff)
remaincharges = procCharges; remaincharges = procCharges;
} }
else else
remaincharges = 0; { remaincharges = 0; }
uint32 defstackamount = spellproto->GetStackAmount(); uint32 defstackamount = spellproto->GetStackAmount();
if (!defstackamount) if (!defstackamount)
stackcount = 1; { stackcount = 1; }
else if (defstackamount < stackcount) else if (defstackamount < stackcount)
stackcount = defstackamount; stackcount = defstackamount;
else if (!stackcount) else if (!stackcount)
stackcount = 1; { stackcount = 1; }
SpellAuraHolder* holder = CreateSpellAuraHolder(spellproto, this, NULL); SpellAuraHolder* holder = CreateSpellAuraHolder(spellproto, this, NULL);
holder->SetLoadedState(casterGuid, ObjectGuid(HIGHGUID_ITEM, item_lowguid), stackcount, remaincharges, maxduration, remaintime); holder->SetLoadedState(casterGuid, ObjectGuid(HIGHGUID_ITEM, item_lowguid), stackcount, remaincharges, maxduration, remaintime);
@ -1338,20 +1337,20 @@ void Pet::_LoadAuras(uint32 timediff)
for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i) for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
{ {
if ((effIndexMask & (1 << i)) == 0) if ((effIndexMask & (1 << i)) == 0)
continue; { continue; }
Aura* aura = CreateAura(spellproto, SpellEffectIndex(i), NULL, holder, this); Aura* aura = CreateAura(spellproto, SpellEffectIndex(i), NULL, holder, this);
if (!damage[i]) if (!damage[i])
damage[i] = aura->GetModifier()->m_amount; { damage[i] = aura->GetModifier()->m_amount; }
aura->SetLoadedState(damage[i], periodicTime[i]); aura->SetLoadedState(damage[i], periodicTime[i]);
holder->AddAura(aura, SpellEffectIndex(i)); holder->AddAura(aura, SpellEffectIndex(i));
} }
if (!holder->IsEmptyHolder()) if (!holder->IsEmptyHolder())
AddSpellAuraHolder(holder); { AddSpellAuraHolder(holder); }
else else
delete holder; { delete holder; }
} }
while (result->NextRow()); while (result->NextRow());
@ -1370,7 +1369,7 @@ void Pet::_SaveAuras()
SpellAuraHolderMap const& auraHolders = GetSpellAuraHolderMap(); SpellAuraHolderMap const& auraHolders = GetSpellAuraHolderMap();
if (auraHolders.empty()) if (auraHolders.empty())
return; { return; }
stmt = CharacterDatabase.CreateStatement(insAuras, "INSERT INTO pet_aura (guid, caster_guid, item_guid, spell, stackcount, remaincharges, " stmt = CharacterDatabase.CreateStatement(insAuras, "INSERT INTO pet_aura (guid, caster_guid, item_guid, spell, stackcount, remaincharges, "
"basepoints0, basepoints1, basepoints2, periodictime0, periodictime1, periodictime2, maxduration, remaintime, effIndexMask) " "basepoints0, basepoints1, basepoints2, periodictime0, periodictime1, periodictime2, maxduration, remaintime, effIndexMask) "
@ -1414,7 +1413,7 @@ void Pet::_SaveAuras()
{ {
// don't save not own area auras // don't save not own area auras
if (aur->IsAreaAura() && holder->GetCasterGuid() != GetObjectGuid()) if (aur->IsAreaAura() && holder->GetCasterGuid() != GetObjectGuid())
continue; { continue; }
damage[i] = aur->GetModifier()->m_amount; damage[i] = aur->GetModifier()->m_amount;
periodicTime[i] = aur->GetModifier()->periodictime; periodicTime[i] = aur->GetModifier()->periodictime;
@ -1423,7 +1422,7 @@ void Pet::_SaveAuras()
} }
if (!effIndexMask) if (!effIndexMask)
continue; { continue; }
stmt.addUInt32(m_charmInfo->GetPetNumber()); stmt.addUInt32(m_charmInfo->GetPetNumber());
stmt.addUInt64(holder->GetCasterGuid().GetRawValue()); stmt.addUInt64(holder->GetCasterGuid().GetRawValue());
@ -1433,10 +1432,10 @@ void Pet::_SaveAuras()
stmt.addUInt8(holder->GetAuraCharges()); stmt.addUInt8(holder->GetAuraCharges());
for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i)
stmt.addInt32(damage[i]); { stmt.addInt32(damage[i]); }
for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i) for (uint32 i = 0; i < MAX_EFFECT_INDEX; ++i)
stmt.addUInt32(periodicTime[i]); { stmt.addUInt32(periodicTime[i]); }
stmt.addInt32(holder->GetAuraMaxDuration()); stmt.addInt32(holder->GetAuraMaxDuration());
stmt.addInt32(holder->GetAuraDuration()); stmt.addInt32(holder->GetAuraDuration());
@ -1458,7 +1457,7 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe
CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE spell = '%u'", spell_id); CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE spell = '%u'", spell_id);
} }
else else
sLog.outError("Pet::addSpell: nonexistent in SpellStore spell #%u request.", spell_id); { sLog.outError("Pet::addSpell: nonexistent in SpellStore spell #%u request.", spell_id); }
return false; return false;
} }
@ -1477,14 +1476,14 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe
itr->second.state = PETSPELL_UNCHANGED; itr->second.state = PETSPELL_UNCHANGED;
if (active == ACT_ENABLED) if (active == ACT_ENABLED)
ToggleAutocast(spell_id, true); { ToggleAutocast(spell_id, true); }
else if (active == ACT_DISABLED) else if (active == ACT_DISABLED)
ToggleAutocast(spell_id, false); { ToggleAutocast(spell_id, false); }
return false; return false;
} }
else else
return false; { return false; }
} }
uint32 oldspell_id = 0; uint32 oldspell_id = 0;
@ -1496,12 +1495,12 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe
if (active == ACT_DECIDE) // active was not used before, so we save it's autocast/passive state here if (active == ACT_DECIDE) // active was not used before, so we save it's autocast/passive state here
{ {
if (IsPassiveSpell(spellInfo)) if (IsPassiveSpell(spellInfo))
newspell.active = ACT_PASSIVE; { newspell.active = ACT_PASSIVE; }
else else
newspell.active = ACT_DISABLED; { newspell.active = ACT_DISABLED; }
} }
else else
newspell.active = active; { newspell.active = active; }
// talent: unlearn all other talent ranks (high and low) // talent: unlearn all other talent ranks (high and low)
if (TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id)) if (TalentSpellPos const* talentPos = GetTalentSpellPos(spell_id))
@ -1544,7 +1543,7 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe
} }
// ignore new lesser rank // ignore new lesser rank
else if (sSpellMgr.IsHighRankOfSpell(itr2->first, spell_id)) else if (sSpellMgr.IsHighRankOfSpell(itr2->first, spell_id))
return false; { return false; }
} }
} }
} }
@ -1552,12 +1551,12 @@ bool Pet::addSpell(uint32 spell_id, ActiveStates active /*= ACT_DECIDE*/, PetSpe
m_spells[spell_id] = newspell; m_spells[spell_id] = newspell;
if (IsPassiveSpell(spellInfo)) if (IsPassiveSpell(spellInfo))
CastSpell(this, spell_id, true); { CastSpell(this, spell_id, true); }
else else
m_charmInfo->AddSpellToActionBar(spell_id, ActiveStates(newspell.active)); { m_charmInfo->AddSpellToActionBar(spell_id, ActiveStates(newspell.active)); }
if (newspell.active == ACT_ENABLED) if (newspell.active == ACT_ENABLED)
ToggleAutocast(spell_id, true); { ToggleAutocast(spell_id, true); }
uint32 talentCost = GetTalentSpellCost(spell_id); uint32 talentCost = GetTalentSpellCost(spell_id);
if (talentCost) if (talentCost)
@ -1572,7 +1571,7 @@ bool Pet::learnSpell(uint32 spell_id)
{ {
// prevent duplicated entires in spell book // prevent duplicated entires in spell book
if (!addSpell(spell_id)) if (!addSpell(spell_id))
return false; { return false; }
if (!m_loading) if (!m_loading)
{ {
@ -1583,7 +1582,7 @@ bool Pet::learnSpell(uint32 spell_id)
data << uint32(spell_id); data << uint32(spell_id);
((Player*)owner)->GetSession()->SendPacket(&data); ((Player*)owner)->GetSession()->SendPacket(&data);
((Player*)owner)->PetSpellInitialize(); { ((Player*)owner)->PetSpellInitialize(); }
} }
} }
return true; return true;
@ -1620,7 +1619,7 @@ void Pet::InitLevelupSpellsForLevel()
// will called first if level down // will called first if level down
if(spellEntry->GetSpellLevel() > level) if(spellEntry->GetSpellLevel() > level)
unlearnSpell(spellEntry->Id,true); unlearnSpell(spellEntry->Id, true);
// will called if level up // will called if level up
else else
learnSpell(spellEntry->Id); learnSpell(spellEntry->Id);
@ -1644,7 +1643,7 @@ bool Pet::unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
} }
} }
} }
return true; { return true; }
} }
return false; return false;
} }
@ -1653,15 +1652,15 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
{ {
PetSpellMap::iterator itr = m_spells.find(spell_id); PetSpellMap::iterator itr = m_spells.find(spell_id);
if (itr == m_spells.end()) if (itr == m_spells.end())
return false; { return false; }
if (itr->second.state == PETSPELL_REMOVED) if (itr->second.state == PETSPELL_REMOVED)
return false; { return false; }
if (itr->second.state == PETSPELL_NEW) if (itr->second.state == PETSPELL_NEW)
m_spells.erase(itr); { m_spells.erase(itr); }
else else
itr->second.state = PETSPELL_REMOVED; { itr->second.state = PETSPELL_REMOVED; }
RemoveAurasDueToSpell(spell_id); RemoveAurasDueToSpell(spell_id);
@ -1679,9 +1678,9 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
if (learn_prev) if (learn_prev)
{ {
if (uint32 prev_id = sSpellMgr.GetPrevSpellInChain(spell_id)) if (uint32 prev_id = sSpellMgr.GetPrevSpellInChain(spell_id))
learnSpell(prev_id); { learnSpell(prev_id); }
else else
learn_prev = false; { learn_prev = false; }
} }
// if remove last rank or non-ranked then update action bar at server and client if need // if remove last rank or non-ranked then update action bar at server and client if need
@ -1692,7 +1691,7 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab)
// need update action bar for last removed rank // need update action bar for last removed rank
if (Unit* owner = GetOwner()) if (Unit* owner = GetOwner())
if (owner->GetTypeId() == TYPEID_PLAYER) if (owner->GetTypeId() == TYPEID_PLAYER)
((Player*)owner)->PetSpellInitialize(); { ((Player*)owner)->PetSpellInitialize(); }
} }
} }
@ -1705,7 +1704,7 @@ void Pet::CleanupActionBar()
if (UnitActionBarEntry const* ab = m_charmInfo->GetActionBarEntry(i)) if (UnitActionBarEntry const* ab = m_charmInfo->GetActionBarEntry(i))
if (uint32 action = ab->GetAction()) if (uint32 action = ab->GetAction())
if (ab->IsActionBarForSpell() && !HasSpell(action)) if (ab->IsActionBarForSpell() && !HasSpell(action))
m_charmInfo->SetActionBar(i, 0, ACT_DISABLED); { m_charmInfo->SetActionBar(i, 0, ACT_DISABLED); }
} }
void Pet::InitPetCreateSpells() void Pet::InitPetCreateSpells()
@ -1915,16 +1914,16 @@ uint32 Pet::resetTalentsCost() const
// The first time reset costs 10 silver; after 1 day cost is reset to 10 silver // The first time reset costs 10 silver; after 1 day cost is reset to 10 silver
if (m_resetTalentsCost < 10 * SILVER || days > 0) if (m_resetTalentsCost < 10 * SILVER || days > 0)
return 10 * SILVER; { return 10 * SILVER; }
// then 50 silver // then 50 silver
else if (m_resetTalentsCost < 50 * SILVER) else if (m_resetTalentsCost < 50 * SILVER)
return 50 * SILVER; { return 50 * SILVER; }
// then 1 gold // then 1 gold
else if (m_resetTalentsCost < 1 * GOLD) else if (m_resetTalentsCost < 1 * GOLD)
return 1 * GOLD; { return 1 * GOLD; }
// then increasing at a rate of 1 gold; cap 10 gold // then increasing at a rate of 1 gold; cap 10 gold
else else
return (m_resetTalentsCost + 1 * GOLD > 10 * GOLD ? 10 * GOLD : m_resetTalentsCost + 1 * GOLD); { return (m_resetTalentsCost + 1 * GOLD > 10 * GOLD ? 10 * GOLD : m_resetTalentsCost + 1 * GOLD); }
} }
uint8 Pet::GetMaxTalentPointsForLevel(uint32 level) uint8 Pet::GetMaxTalentPointsForLevel(uint32 level)
@ -1939,17 +1938,17 @@ uint8 Pet::GetMaxTalentPointsForLevel(uint32 level)
void Pet::ToggleAutocast(uint32 spellid, bool apply) void Pet::ToggleAutocast(uint32 spellid, bool apply)
{ {
if (IsPassiveSpell(spellid)) if (IsPassiveSpell(spellid))
return; { return; }
PetSpellMap::iterator itr = m_spells.find(spellid); PetSpellMap::iterator itr = m_spells.find(spellid);
PetSpell& petSpell = itr->second; PetSpell &petSpell = itr->second;
uint32 i; uint32 i;
if (apply) if (apply)
{ {
for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i) for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i)
; // just search { ; } // just search
if (i == m_autospells.size()) if (i == m_autospells.size())
{ {
@ -1959,7 +1958,7 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)
{ {
petSpell.active = ACT_ENABLED; petSpell.active = ACT_ENABLED;
if (petSpell.state != PETSPELL_NEW) if (petSpell.state != PETSPELL_NEW)
petSpell.state = PETSPELL_CHANGED; { petSpell.state = PETSPELL_CHANGED; }
} }
} }
} }
@ -1967,7 +1966,7 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)
{ {
AutoSpellList::iterator itr2 = m_autospells.begin(); AutoSpellList::iterator itr2 = m_autospells.begin();
for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i, ++itr2) for (i = 0; i < m_autospells.size() && m_autospells[i] != spellid; ++i, ++itr2)
; // just search { ; } // just search
if (i < m_autospells.size()) if (i < m_autospells.size())
{ {
@ -1976,7 +1975,7 @@ void Pet::ToggleAutocast(uint32 spellid, bool apply)
{ {
petSpell.active = ACT_DISABLED; petSpell.active = ACT_DISABLED;
if (petSpell.state != PETSPELL_NEW) if (petSpell.state != PETSPELL_NEW)
petSpell.state = PETSPELL_CHANGED; { petSpell.state = PETSPELL_CHANGED; }
} }
} }
} }
@ -1992,17 +1991,17 @@ bool Pet::Create(uint32 guidlow, CreatureCreatePos& cPos, CreatureInfo const* ci
m_originalEntry = cinfo->Entry; m_originalEntry = cinfo->Entry;
if (!InitEntry(cinfo->Entry)) if (!InitEntry(cinfo->Entry))
return false; { return false; }
cPos.SelectFinalPoint(this); cPos.SelectFinalPoint(this);
if (!cPos.Relocate(this)) if (!cPos.Relocate(this))
return false; { return false; }
SetSheath(SHEATH_STATE_MELEE); SetSheath(SHEATH_STATE_MELEE);
if (getPetType() == MINI_PET) // always non-attackable if (getPetType() == MINI_PET) // always non-attackable
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); { SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); }
return true; return true;
} }
@ -2018,17 +2017,17 @@ void Pet::LearnPetPassives()
{ {
CreatureInfo const* cInfo = GetCreatureInfo(); CreatureInfo const* cInfo = GetCreatureInfo();
if (!cInfo) if (!cInfo)
return; { return; }
CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->Family); CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cInfo->Family);
if (!cFamily) if (!cFamily)
return; { return; }
PetFamilySpellsStore::const_iterator petStore = sPetFamilySpellsStore.find(cFamily->ID); PetFamilySpellsStore::const_iterator petStore = sPetFamilySpellsStore.find(cFamily->ID);
if (petStore != sPetFamilySpellsStore.end()) if (petStore != sPetFamilySpellsStore.end())
{ {
for (PetFamilySpellsSet::const_iterator petSet = petStore->second.begin(); petSet != petStore->second.end(); ++petSet) for (PetFamilySpellsSet::const_iterator petSet = petStore->second.begin(); petSet != petStore->second.end(); ++petSet)
addSpell(*petSet, ACT_DECIDE, PETSPELL_NEW, PETSPELL_FAMILY); { addSpell(*petSet, ACT_DECIDE, PETSPELL_NEW, PETSPELL_FAMILY); }
} }
} }
@ -2045,9 +2044,9 @@ void Pet::CastPetAuras(bool current)
++itr; ++itr;
if (!current && pa->IsRemovedOnChangePet()) if (!current && pa->IsRemovedOnChangePet())
owner->RemovePetAura(pa); { owner->RemovePetAura(pa); }
else else
CastPetAura(pa); { CastPetAura(pa); }
} }
} }
@ -2056,7 +2055,7 @@ void Pet::CastOwnerTalentAuras()
if (!GetOwner() || GetOwner()->GetTypeId() != TYPEID_PLAYER) if (!GetOwner() || GetOwner()->GetTypeId() != TYPEID_PLAYER)
return; return;
Player* pOwner = static_cast<Player*>(GetOwner()); Player* pOwner = static_cast<Player *>(GetOwner());
// Handle Ferocious Inspiration Talent // Handle Ferocious Inspiration Talent
if (pOwner && pOwner->getClass() == CLASS_HUNTER) if (pOwner && pOwner->getClass() == CLASS_HUNTER)
@ -2093,7 +2092,7 @@ void Pet::CastPetAura(PetAura const* aura)
{ {
uint32 auraId = aura->GetAura(GetEntry()); uint32 auraId = aura->GetAura(GetEntry());
if (!auraId) if (!auraId)
return; { return; }
if (auraId == 35696) // Demonic Knowledge if (auraId == 35696) // Demonic Knowledge
{ {
@ -2101,7 +2100,7 @@ void Pet::CastPetAura(PetAura const* aura)
CastCustomSpell(this, auraId, &basePoints, NULL, NULL, true); CastCustomSpell(this, auraId, &basePoints, NULL, NULL, true);
} }
else else
CastSpell(this, auraId, true); { CastSpell(this, auraId, true); }
} }
struct DoPetLearnSpell struct DoPetLearnSpell
@ -2123,7 +2122,7 @@ void Pet::SynchronizeLevelWithOwner()
{ {
Unit* owner = GetOwner(); Unit* owner = GetOwner();
if (!owner || owner->GetTypeId() != TYPEID_PLAYER) if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
return; { return; }
switch (getPetType()) switch (getPetType())
{ {
@ -2134,7 +2133,7 @@ void Pet::SynchronizeLevelWithOwner()
// can't be greater owner level // can't be greater owner level
case HUNTER_PET: case HUNTER_PET:
if (getLevel() > owner->getLevel()) if (getLevel() > owner->getLevel())
GivePetLevel(owner->getLevel()); { GivePetLevel(owner->getLevel()); }
else if (getLevel() + 5 < owner->getLevel()) else if (getLevel() + 5 < owner->getLevel())
GivePetLevel(owner->getLevel() - 5); GivePetLevel(owner->getLevel() - 5);
break; break;
@ -2149,7 +2148,7 @@ void Pet::SetModeFlags(PetModeFlags mode)
Unit* owner = GetOwner(); Unit* owner = GetOwner();
if (!owner || owner->GetTypeId() != TYPEID_PLAYER) if (!owner || owner->GetTypeId() != TYPEID_PLAYER)
return; { return; }
WorldPacket data(SMSG_PET_MODE, 12); WorldPacket data(SMSG_PET_MODE, 12);
data << GetObjectGuid(); data << GetObjectGuid();

View file

@ -37,7 +37,7 @@
int PetAI::Permissible(const Creature* creature) int PetAI::Permissible(const Creature* creature)
{ {
if (creature->IsPet()) if (creature->IsPet())
return PERMIT_BASE_SPECIAL; { return PERMIT_BASE_SPECIAL; }
return PERMIT_BASE_NO; return PERMIT_BASE_NO;
} }
@ -75,7 +75,7 @@ void PetAI::MoveInLineOfSight(Unit* pWho)
void PetAI::AttackStart(Unit* u) void PetAI::AttackStart(Unit* u)
{ {
if (!u || (m_creature->IsPet() && ((Pet*)m_creature)->getPetType() == MINI_PET)) if (!u || (m_creature->IsPet() && ((Pet*)m_creature)->getPetType() == MINI_PET))
return; { return; }
if (m_creature->Attack(u, true)) if (m_creature->Attack(u, true))
{ {
@ -103,7 +103,7 @@ bool PetAI::_needToStop() const
{ {
// This is needed for charmed creatures, as once their target was reset other effects can trigger threat // This is needed for charmed creatures, as once their target was reset other effects can trigger threat
if (m_creature->IsCharmed() && m_creature->getVictim() == m_creature->GetCharmer()) if (m_creature->IsCharmed() && m_creature->getVictim() == m_creature->GetCharmer())
return true; { return true; }
return !m_creature->getVictim()->IsTargetableForAttack(); return !m_creature->getVictim()->IsTargetableForAttack();
} }
@ -129,7 +129,7 @@ void PetAI::_stopAttack()
void PetAI::UpdateAI(const uint32 diff) void PetAI::UpdateAI(const uint32 diff)
{ {
if (!m_creature->IsAlive()) if (!m_creature->IsAlive())
return; { return; }
Unit* owner = m_creature->GetCharmerOrOwner(); Unit* owner = m_creature->GetCharmerOrOwner();
Unit* victim = NULL; Unit* victim = NULL;
@ -144,9 +144,9 @@ void PetAI::UpdateAI(const uint32 diff)
if (m_updateAlliesTimer <= diff) if (m_updateAlliesTimer <= diff)
// UpdateAllies self set update timer // UpdateAllies self set update timer
UpdateAllies(); { UpdateAllies(); }
else else
m_updateAlliesTimer -= diff; { m_updateAlliesTimer -= diff; }
if (inCombat && !victim) if (inCombat && !victim)
{ {
@ -218,21 +218,21 @@ void PetAI::UpdateAI(const uint32 diff)
{ {
uint32 spellID = m_creature->GetPetAutoSpellOnPos(i); uint32 spellID = m_creature->GetPetAutoSpellOnPos(i);
if (!spellID) if (!spellID)
continue; { continue; }
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellID); SpellEntry const* spellInfo = sSpellStore.LookupEntry(spellID);
if (!spellInfo) if (!spellInfo)
continue; { continue; }
if (m_creature->GetCharmInfo() && m_creature->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo)) if (m_creature->GetCharmInfo() && m_creature->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))
continue; { continue; }
// ignore some combinations of combat state and combat/noncombat spells // ignore some combinations of combat state and combat/noncombat spells
if (!inCombat) if (!inCombat)
{ {
// ignore attacking spells, and allow only self/around spells // ignore attacking spells, and allow only self/around spells
if (!IsPositiveSpell(spellInfo->Id)) if (!IsPositiveSpell(spellInfo->Id))
continue; { continue; }
// non combat spells allowed // non combat spells allowed
// only pet spells have IsNonCombatSpell and not fit this reqs: // only pet spells have IsNonCombatSpell and not fit this reqs:
@ -242,14 +242,14 @@ void PetAI::UpdateAI(const uint32 diff)
int32 duration = GetSpellDuration(spellInfo); int32 duration = GetSpellDuration(spellInfo);
SpellPowerEntry const* spellPower = spellInfo->GetSpellPower(); SpellPowerEntry const* spellPower = spellInfo->GetSpellPower();
if (spellPower && (spellPower->manaCost || spellPower->ManaCostPercentage || spellPower->manaPerSecond) && duration > 0) if (spellPower && (spellPower->manaCost || spellPower->ManaCostPercentage || spellPower->manaPerSecond) && duration > 0)
continue; { continue; }
// allow only spell without cooldown > duration // allow only spell without cooldown > duration
int32 cooldown = GetSpellRecoveryTime(spellInfo); int32 cooldown = GetSpellRecoveryTime(spellInfo);
// allow only spell not on cooldown // allow only spell not on cooldown
if (cooldown != 0 && duration < cooldown) if (cooldown != 0 && duration < cooldown)
continue; { continue; }
} }
} }
// just ignore non-combat spells // just ignore non-combat spells
@ -272,7 +272,7 @@ void PetAI::UpdateAI(const uint32 diff)
// only buff targets that are in combat, unless the spell can only be cast while out of combat // only buff targets that are in combat, unless the spell can only be cast while out of combat
if (!Target) if (!Target)
continue; { continue; }
if (spell->CanAutoCast(Target)) if (spell->CanAutoCast(Target))
{ {
@ -282,7 +282,7 @@ void PetAI::UpdateAI(const uint32 diff)
} }
} }
if (!spellUsed) if (!spellUsed)
delete spell; { delete spell; }
} }
} }
@ -303,10 +303,10 @@ void PetAI::UpdateAI(const uint32 diff)
{ {
m_creature->SetInFront(target); m_creature->SetInFront(target);
if (target->GetTypeId() == TYPEID_PLAYER) if (target->GetTypeId() == TYPEID_PLAYER)
m_creature->SendCreateUpdateToPlayer((Player*)target); { m_creature->SendCreateUpdateToPlayer((Player*)target); }
if (owner && owner->GetTypeId() == TYPEID_PLAYER) if (owner && owner->GetTypeId() == TYPEID_PLAYER)
m_creature->SendCreateUpdateToPlayer((Player*)owner); { m_creature->SendCreateUpdateToPlayer((Player*)owner); }
} }
m_creature->AddCreatureSpellCooldown(spell->m_spellInfo->Id); m_creature->AddCreatureSpellCooldown(spell->m_spellInfo->Id);
@ -316,7 +316,7 @@ void PetAI::UpdateAI(const uint32 diff)
// deleted cached Spell objects // deleted cached Spell objects
for (TargetSpellList::const_iterator itr = targetSpellStore.begin(); itr != targetSpellStore.end(); ++itr) for (TargetSpellList::const_iterator itr = targetSpellStore.begin(); itr != targetSpellStore.end(); ++itr)
delete itr->second; { delete itr->second; }
} }
// Guardians will always look in threat list for victim // Guardians will always look in threat list for victim
@ -433,16 +433,16 @@ void PetAI::UpdateAllies()
m_updateAlliesTimer = 10 * IN_MILLISECONDS; // update friendly targets every 10 seconds, lesser checks increase performance m_updateAlliesTimer = 10 * IN_MILLISECONDS; // update friendly targets every 10 seconds, lesser checks increase performance
if (!owner) if (!owner)
return; { return; }
else if (owner->GetTypeId() == TYPEID_PLAYER) else if (owner->GetTypeId() == TYPEID_PLAYER)
pGroup = ((Player*)owner)->GetGroup(); { pGroup = ((Player*)owner)->GetGroup(); }
// only pet and owner/not in group->ok // only pet and owner/not in group->ok
if (m_AllySet.size() == 2 && !pGroup) if (m_AllySet.size() == 2 && !pGroup)
return; { return; }
// owner is in group; group members filled in already (no raid -> subgroupcount = whole count) // owner is in group; group members filled in already (no raid -> subgroupcount = whole count)
if (pGroup && !pGroup->isRaidGroup() && m_AllySet.size() == (pGroup->GetMembersCount() + 2)) if (pGroup && !pGroup->isRaidGroup() && m_AllySet.size() == (pGroup->GetMembersCount() + 2))
return; { return; }
m_AllySet.clear(); m_AllySet.clear();
m_AllySet.insert(m_creature->GetObjectGuid()); m_AllySet.insert(m_creature->GetObjectGuid());
@ -452,16 +452,16 @@ void PetAI::UpdateAllies()
{ {
Player* target = itr->getSource(); Player* target = itr->getSource();
if (!target || !pGroup->SameSubGroup((Player*)owner, target)) if (!target || !pGroup->SameSubGroup((Player*)owner, target))
continue; { continue; }
if (target->GetObjectGuid() == owner->GetObjectGuid()) if (target->GetObjectGuid() == owner->GetObjectGuid())
continue; { continue; }
m_AllySet.insert(target->GetObjectGuid()); m_AllySet.insert(target->GetObjectGuid());
} }
} }
else // remove group else // remove group
m_AllySet.insert(owner->GetObjectGuid()); { m_AllySet.insert(owner->GetObjectGuid()); }
} }
void PetAI::AttackedBy(Unit* attacker) void PetAI::AttackedBy(Unit* attacker)
@ -470,5 +470,5 @@ void PetAI::AttackedBy(Unit* attacker)
if (!(m_creature->getVictim() || ((Pet*)m_creature)->GetIsRetreating() == true) if (!(m_creature->getVictim() || ((Pet*)m_creature)->GetIsRetreating() == true)
&& !(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE) && !(m_creature->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PASSIVE)
|| (m_creature->GetCharmInfo() && m_creature->GetCharmInfo()->HasReactState(REACT_PASSIVE)))) || (m_creature->GetCharmInfo() && m_creature->GetCharmInfo()->HasReactState(REACT_PASSIVE))))
AttackStart(attacker); { AttackStart(attacker); }
} }

View file

@ -75,7 +75,7 @@
#include "Calendar.h" #include "Calendar.h"
#ifdef ENABLE_ELUNA #ifdef ENABLE_ELUNA
#include "LuaEngine.h" #include "LuaEngine.h"
#endif /*ENABLE_ELUNA*/ #endif /* ENABLE_ELUNA */
#include <cmath> #include <cmath>
@ -223,11 +223,11 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, Team
} }
if (m_TaxiDestinations.empty()) if (m_TaxiDestinations.empty())
return true; { return true; }
// Check integrity // Check integrity
if (m_TaxiDestinations.size() < 2) if (m_TaxiDestinations.size() < 2)
return false; { return false; }
for (size_t i = 1; i < m_TaxiDestinations.size(); ++i) for (size_t i = 1; i < m_TaxiDestinations.size(); ++i)
{ {
@ -235,12 +235,12 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, Team
uint32 path; uint32 path;
sObjectMgr.GetTaxiPath(m_TaxiDestinations[i - 1], m_TaxiDestinations[i], path, cost); sObjectMgr.GetTaxiPath(m_TaxiDestinations[i - 1], m_TaxiDestinations[i], path, cost);
if (!path) if (!path)
return false; { return false; }
} }
// can't load taxi path without mount set (quest taxi path?) // can't load taxi path without mount set (quest taxi path?)
if (!sObjectMgr.GetTaxiMountDisplayId(GetTaxiSource(), team, true)) if (!sObjectMgr.GetTaxiMountDisplayId(GetTaxiSource(), team, true))
return false; { return false; }
return true; return true;
} }
@ -248,12 +248,12 @@ bool PlayerTaxi::LoadTaxiDestinationsFromString(const std::string& values, Team
std::string PlayerTaxi::SaveTaxiDestinationsToString() std::string PlayerTaxi::SaveTaxiDestinationsToString()
{ {
if (m_TaxiDestinations.empty()) if (m_TaxiDestinations.empty())
return ""; { return ""; }
std::ostringstream ss; std::ostringstream ss;
for (size_t i = 0; i < m_TaxiDestinations.size(); ++i) for (size_t i = 0; i < m_TaxiDestinations.size(); ++i)
ss << m_TaxiDestinations[i] << " "; { ss << m_TaxiDestinations[i] << " "; }
return ss.str(); return ss.str();
} }
@ -261,7 +261,7 @@ std::string PlayerTaxi::SaveTaxiDestinationsToString()
uint32 PlayerTaxi::GetCurrentTaxiPath() const uint32 PlayerTaxi::GetCurrentTaxiPath() const
{ {
if (m_TaxiDestinations.size() < 2) if (m_TaxiDestinations.size() < 2)
return 0; { return 0; }
uint32 path; uint32 path;
uint32 cost; uint32 cost;
@ -293,10 +293,11 @@ bool TradeData::HasItem(ObjectGuid item_guid) const
{ {
for (int i = 0; i < TRADE_SLOT_COUNT; ++i) for (int i = 0; i < TRADE_SLOT_COUNT; ++i)
if (m_items[i] == item_guid) if (m_items[i] == item_guid)
return true; { return true; }
return false; return false;
} }
Item* TradeData::GetSpellCastItem() const Item* TradeData::GetSpellCastItem() const
{ {
return m_spellCastItem ? m_player->GetItemByGuid(m_spellCastItem) : NULL; return m_spellCastItem ? m_player->GetItemByGuid(m_spellCastItem) : NULL;
@ -307,7 +308,7 @@ void TradeData::SetItem(TradeSlots slot, Item* item)
ObjectGuid itemGuid = item ? item->GetObjectGuid() : ObjectGuid(); ObjectGuid itemGuid = item ? item->GetObjectGuid() : ObjectGuid();
if (m_items[slot] == itemGuid) if (m_items[slot] == itemGuid)
return; { return; }
m_items[slot] = itemGuid; m_items[slot] = itemGuid;
@ -318,7 +319,7 @@ void TradeData::SetItem(TradeSlots slot, Item* item)
// need remove possible trader spell applied to changed item // need remove possible trader spell applied to changed item
if (slot == TRADE_SLOT_NONTRADED) if (slot == TRADE_SLOT_NONTRADED)
GetTraderData()->SetSpell(0); { GetTraderData()->SetSpell(0); }
// need remove possible player spell applied (possible move reagent) // need remove possible player spell applied (possible move reagent)
SetSpell(0); SetSpell(0);
@ -329,7 +330,7 @@ void TradeData::SetSpell(uint32 spell_id, Item* castItem /*= NULL*/)
ObjectGuid itemGuid = castItem ? castItem->GetObjectGuid() : ObjectGuid(); ObjectGuid itemGuid = castItem ? castItem->GetObjectGuid() : ObjectGuid();
if (m_spell == spell_id && m_spellCastItem == itemGuid) if (m_spell == spell_id && m_spellCastItem == itemGuid)
return; { return; }
m_spell = spell_id; m_spell = spell_id;
m_spellCastItem = itemGuid; m_spellCastItem = itemGuid;
@ -344,7 +345,7 @@ void TradeData::SetSpell(uint32 spell_id, Item* castItem /*= NULL*/)
void TradeData::SetMoney(uint64 money) void TradeData::SetMoney(uint64 money)
{ {
if (m_money == money) if (m_money == money)
return; { return; }
if (money > m_player->GetMoney()) if (money > m_player->GetMoney())
{ {
@ -363,9 +364,9 @@ void TradeData::SetMoney(uint64 money)
void TradeData::Update(bool for_trader /*= true*/) void TradeData::Update(bool for_trader /*= true*/)
{ {
if (for_trader) if (for_trader)
m_trader->GetSession()->SendUpdateTrade(true); // player state for trader { m_trader->GetSession()->SendUpdateTrade(true); } // player state for trader
else else
m_player->GetSession()->SendUpdateTrade(false); // player state for player { m_player->GetSession()->SendUpdateTrade(false); } // player state for player
} }
void TradeData::SetAccepted(bool state, bool crosssend /*= false*/) void TradeData::SetAccepted(bool state, bool crosssend /*= false*/)
@ -375,9 +376,9 @@ void TradeData::SetAccepted(bool state, bool crosssend /*= false*/)
if (!state) if (!state)
{ {
if (crosssend) if (crosssend)
m_trader->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); { m_trader->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); }
else else
m_player->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); { m_player->GetSession()->SendTradeStatus(TRADE_STATUS_BACK_TO_TRADE); }
} }
} }
@ -403,11 +404,11 @@ Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_
m_ExtraFlags = 0; m_ExtraFlags = 0;
if (GetSession()->GetSecurity() >= SEC_GAMEMASTER) if (GetSession()->GetSecurity() >= SEC_GAMEMASTER)
SetAcceptTicket(true); { SetAcceptTicket(true); }
// players always accept // players always accept
if (GetSession()->GetSecurity() == SEC_PLAYER) if (GetSession()->GetSecurity() == SEC_PLAYER)
SetAcceptWhispers(true); { SetAcceptWhispers(true); }
m_comboPoints = 0; m_comboPoints = 0;
@ -471,7 +472,7 @@ Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_
m_lastLiquid = NULL; m_lastLiquid = NULL;
for (int i = 0; i < MAX_TIMERS; ++i) for (int i = 0; i < MAX_TIMERS; ++i)
m_MirrorTimer[i] = DISABLED_MIRROR_TIMER; { m_MirrorTimer[i] = DISABLED_MIRROR_TIMER; }
m_MirrorTimerFlags = UNDERWATER_NONE; m_MirrorTimerFlags = UNDERWATER_NONE;
m_MirrorTimerFlagsLast = UNDERWATER_NONE; m_MirrorTimerFlagsLast = UNDERWATER_NONE;
@ -520,7 +521,7 @@ Player::Player(WorldSession* session): Unit(), m_mover(this), m_camera(this), m_
m_itemUpdateQueueBlocked = false; m_itemUpdateQueueBlocked = false;
for (int i = 0; i < MAX_MOVE_TYPE; ++i) for (int i = 0; i < MAX_MOVE_TYPE; ++i)
m_forced_speed_changes[i] = 0; { m_forced_speed_changes[i] = 0; }
m_stableSlots = 0; m_stableSlots = 0;
@ -591,10 +592,10 @@ Player::~Player()
// all mailed items should be deleted, also all mail should be deallocated // all mailed items should be deleted, also all mail should be deallocated
for (PlayerMails::const_iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr) for (PlayerMails::const_iterator itr = m_mail.begin(); itr != m_mail.end(); ++itr)
delete *itr; { delete *itr; }
for (ItemMap::const_iterator iter = mMitems.begin(); iter != mMitems.end(); ++iter) for (ItemMap::const_iterator iter = mMitems.begin(); iter != mMitems.end(); ++iter)
delete iter->second; // if item is duplicated... then server may crash ... but that item should be deallocated { delete iter->second; } // if item is duplicated... then server may crash ... but that item should be deallocated
delete PlayerTalkClass; delete PlayerTalkClass;
@ -604,7 +605,7 @@ Player::~Player()
} }
for (size_t x = 0; x < ItemSetEff.size(); ++x) for (size_t x = 0; x < ItemSetEff.size(); ++x)
delete ItemSetEff[x]; { delete ItemSetEff[x]; }
// clean up player-instance binds, may unload some instance saves // clean up player-instance binds, may unload some instance saves
for (uint8 i = 0; i < MAX_DIFFICULTY; ++i) for (uint8 i = 0; i < MAX_DIFFICULTY; ++i)
@ -659,7 +660,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
} }
for (int i = 0; i < PLAYER_SLOTS_COUNT; ++i) for (int i = 0; i < PLAYER_SLOTS_COUNT; ++i)
m_items[i] = NULL; { m_items[i] = NULL; }
SetLocationMapId(info->mapId); SetLocationMapId(info->mapId);
Relocate(info->positionX, info->positionY, info->positionZ, info->orientation); Relocate(info->positionX, info->positionY, info->positionZ, info->orientation);
@ -675,7 +676,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
SetByteValue(UNIT_FIELD_BYTES_0, 2, gender); SetByteValue(UNIT_FIELD_BYTES_0, 2, gender);
SetByteValue(UNIT_FIELD_BYTES_0, 3, powertype); SetByteValue(UNIT_FIELD_BYTES_0, 3, powertype);
InitDisplayIds(); // model, Scale and model data InitDisplayIds(); // model, scale and model data
SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP); SetByteFlag(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP);
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE); SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);
@ -784,14 +785,14 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
for (int j = 0; j < MAX_OUTFIT_ITEMS; ++j) for (int j = 0; j < MAX_OUTFIT_ITEMS; ++j)
{ {
if (oEntry->ItemId[j] <= 0) if (oEntry->ItemId[j] <= 0)
continue; { continue; }
uint32 item_id = oEntry->ItemId[j]; uint32 item_id = oEntry->ItemId[j];
// just skip, reported in ObjectMgr::LoadItemPrototypes // just skip, reported in ObjectMgr::LoadItemPrototypes
ItemPrototype const* iProto = ObjectMgr::GetItemPrototype(item_id); ItemPrototype const* iProto = ObjectMgr::GetItemPrototype(item_id);
if (!iProto) if (!iProto)
continue; { continue; }
// BuyCount by default // BuyCount by default
int32 count = iProto->BuyCount; int32 count = iProto->BuyCount;
@ -817,7 +818,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
} }
for (PlayerCreateInfoItems::const_iterator item_id_itr = info->item.begin(); item_id_itr != info->item.end(); ++item_id_itr) for (PlayerCreateInfoItems::const_iterator item_id_itr = info->item.begin(); item_id_itr != info->item.end(); ++item_id_itr)
StoreNewItemInBestSlots(item_id_itr->item_id, item_id_itr->item_amount); { StoreNewItemInBestSlots(item_id_itr->item_id, item_id_itr->item_amount); }
// bags and main-hand weapon must equipped at this moment // bags and main-hand weapon must equipped at this moment
// now second pass for not equipped (offhand weapon/shield if it attempt equipped before main-hand weapon) // now second pass for not equipped (offhand weapon/shield if it attempt equipped before main-hand weapon)
@ -848,7 +849,7 @@ bool Player::Create(uint32 guidlow, const std::string& name, uint8 race, uint8 c
// if this is ammo then use it // if this is ammo then use it
msg = CanUseAmmo(pItem->GetEntry()); msg = CanUseAmmo(pItem->GetEntry());
if (msg == EQUIP_ERR_OK) if (msg == EQUIP_ERR_OK)
SetAmmo(pItem->GetEntry()); { SetAmmo(pItem->GetEntry()); }
} }
} }
} }
@ -870,7 +871,7 @@ bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount)
uint16 eDest; uint16 eDest;
uint8 msg = CanEquipNewItem(NULL_SLOT, eDest, titem_id, false); uint8 msg = CanEquipNewItem(NULL_SLOT, eDest, titem_id, false);
if (msg != EQUIP_ERR_OK) if (msg != EQUIP_ERR_OK)
break; { break; }
EquipNewItem(eDest, titem_id, true); EquipNewItem(eDest, titem_id, true);
AutoUnequipOffhandIfNeed(); AutoUnequipOffhandIfNeed();
@ -878,7 +879,7 @@ bool Player::StoreNewItemInBestSlots(uint32 titem_id, uint32 titem_amount)
} }
if (titem_amount == 0) if (titem_amount == 0)
return true; // equipped { return true; } // equipped
// attempt store // attempt store
ItemPosCountVec sDest; ItemPosCountVec sDest;
@ -905,7 +906,7 @@ Item* Player::StoreNewItemInInventorySlot(uint32 itemEntry, uint32 amount)
if (msg == EQUIP_ERR_OK) if (msg == EQUIP_ERR_OK)
{ {
if (Item* pItem = StoreNewItem(vDest, itemEntry, true, Item::GenerateItemRandomPropertyId(itemEntry))) if (Item* pItem = StoreNewItem(vDest, itemEntry, true, Item::GenerateItemRandomPropertyId(itemEntry)))
return pItem; { return pItem; }
} }
return NULL; return NULL;
@ -916,7 +917,7 @@ void Player::SendMirrorTimer(MirrorTimerType Type, uint32 MaxValue, uint32 Curre
if (int(MaxValue) == DISABLED_MIRROR_TIMER) if (int(MaxValue) == DISABLED_MIRROR_TIMER)
{ {
if (int(CurrentValue) != DISABLED_MIRROR_TIMER) if (int(CurrentValue) != DISABLED_MIRROR_TIMER)
StopMirrorTimer(Type); { StopMirrorTimer(Type); }
return; return;
} }
WorldPacket data(SMSG_START_MIRROR_TIMER, (21)); WorldPacket data(SMSG_START_MIRROR_TIMER, (21));
@ -940,15 +941,15 @@ void Player::StopMirrorTimer(MirrorTimerType Type)
uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage) uint32 Player::EnvironmentalDamage(EnviromentalDamage type, uint32 damage)
{ {
if (!IsAlive() || isGameMaster()) if (!IsAlive() || isGameMaster())
return 0; { return 0; }
// Absorb, resist some environmental damage type // Absorb, resist some environmental damage type
uint32 absorb = 0; uint32 absorb = 0;
uint32 resist = 0; uint32 resist = 0;
if (type == DAMAGE_LAVA) if (type == DAMAGE_LAVA)
CalculateDamageAbsorbAndResist(this, SPELL_SCHOOL_MASK_FIRE, DIRECT_DAMAGE, damage, &absorb, &resist); { CalculateDamageAbsorbAndResist(this, SPELL_SCHOOL_MASK_FIRE, DIRECT_DAMAGE, damage, &absorb, &resist); }
else if (type == DAMAGE_SLIME) else if (type == DAMAGE_SLIME)
CalculateDamageAbsorbAndResist(this, SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, damage, &absorb, &resist); { CalculateDamageAbsorbAndResist(this, SPELL_SCHOOL_MASK_NATURE, DIRECT_DAMAGE, damage, &absorb, &resist); }
damage -= absorb + resist; damage -= absorb + resist;
@ -991,23 +992,23 @@ int32 Player::getMaxTimer(MirrorTimerType timer)
{ {
case FATIGUE_TIMER: case FATIGUE_TIMER:
if (GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FATIGUE_GMLEVEL)) if (GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FATIGUE_GMLEVEL))
return DISABLED_MIRROR_TIMER; { return DISABLED_MIRROR_TIMER; }
return sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FATIGUE_MAX) * IN_MILLISECONDS; return sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FATIGUE_MAX) * IN_MILLISECONDS;
case BREATH_TIMER: case BREATH_TIMER:
{ {
if (!IsAlive() || HasAuraType(SPELL_AURA_WATER_BREATHING) || if (!IsAlive() || HasAuraType(SPELL_AURA_WATER_BREATHING) ||
GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_BREATH_GMLEVEL)) GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_BREATH_GMLEVEL))
return DISABLED_MIRROR_TIMER; { return DISABLED_MIRROR_TIMER; }
int32 UnderWaterTime = sWorld.getConfig(CONFIG_UINT32_TIMERBAR_BREATH_MAX) * IN_MILLISECONDS; int32 UnderWaterTime = sWorld.getConfig(CONFIG_UINT32_TIMERBAR_BREATH_MAX) * IN_MILLISECONDS;
AuraList const& mModWaterBreathing = GetAurasByType(SPELL_AURA_MOD_WATER_BREATHING); AuraList const& mModWaterBreathing = GetAurasByType(SPELL_AURA_MOD_WATER_BREATHING);
for (AuraList::const_iterator i = mModWaterBreathing.begin(); i != mModWaterBreathing.end(); ++i) for (AuraList::const_iterator i = mModWaterBreathing.begin(); i != mModWaterBreathing.end(); ++i)
UnderWaterTime = uint32(UnderWaterTime * (100.0f + (*i)->GetModifier()->m_amount) / 100.0f); { UnderWaterTime = uint32(UnderWaterTime * (100.0f + (*i)->GetModifier()->m_amount) / 100.0f); }
return UnderWaterTime; return UnderWaterTime;
} }
case FIRE_TIMER: case FIRE_TIMER:
{ {
if (!IsAlive() || GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FIRE_GMLEVEL)) if (!IsAlive() || GetSession()->GetSecurity() >= (AccountTypes)sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FIRE_GMLEVEL))
return DISABLED_MIRROR_TIMER; { return DISABLED_MIRROR_TIMER; }
return sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FIRE_MAX) * IN_MILLISECONDS; return sWorld.getConfig(CONFIG_UINT32_TIMERBAR_FIRE_MAX) * IN_MILLISECONDS;
} }
default: default:
@ -1020,13 +1021,13 @@ void Player::UpdateMirrorTimers()
{ {
// Desync flags for update on next HandleDrowning // Desync flags for update on next HandleDrowning
if (m_MirrorTimerFlags) if (m_MirrorTimerFlags)
m_MirrorTimerFlagsLast = ~m_MirrorTimerFlags; { m_MirrorTimerFlagsLast = ~m_MirrorTimerFlags; }
} }
void Player::HandleDrowning(uint32 time_diff) void Player::HandleDrowning(uint32 time_diff)
{ {
if (!m_MirrorTimerFlags) if (!m_MirrorTimerFlags)
return; { return; }
// In water // In water
if (m_MirrorTimerFlags & UNDERWATER_INWATER) if (m_MirrorTimerFlags & UNDERWATER_INWATER)
@ -1050,7 +1051,7 @@ void Player::HandleDrowning(uint32 time_diff)
EnvironmentalDamage(DAMAGE_DROWNING, damage); EnvironmentalDamage(DAMAGE_DROWNING, damage);
} }
else if (!(m_MirrorTimerFlagsLast & UNDERWATER_INWATER)) // Update time in client if need else if (!(m_MirrorTimerFlagsLast & UNDERWATER_INWATER)) // Update time in client if need
SendMirrorTimer(BREATH_TIMER, getMaxTimer(BREATH_TIMER), m_MirrorTimer[BREATH_TIMER], -1); { SendMirrorTimer(BREATH_TIMER, getMaxTimer(BREATH_TIMER), m_MirrorTimer[BREATH_TIMER], -1); }
} }
} }
else if (m_MirrorTimer[BREATH_TIMER] != DISABLED_MIRROR_TIMER) // Regen timer else if (m_MirrorTimer[BREATH_TIMER] != DISABLED_MIRROR_TIMER) // Regen timer
@ -1059,9 +1060,9 @@ void Player::HandleDrowning(uint32 time_diff)
// Need breath regen // Need breath regen
m_MirrorTimer[BREATH_TIMER] += 10 * time_diff; m_MirrorTimer[BREATH_TIMER] += 10 * time_diff;
if (m_MirrorTimer[BREATH_TIMER] >= UnderWaterTime || !IsAlive()) if (m_MirrorTimer[BREATH_TIMER] >= UnderWaterTime || !IsAlive())
StopMirrorTimer(BREATH_TIMER); { StopMirrorTimer(BREATH_TIMER); }
else if (m_MirrorTimerFlagsLast & UNDERWATER_INWATER) else if (m_MirrorTimerFlagsLast & UNDERWATER_INWATER)
SendMirrorTimer(BREATH_TIMER, UnderWaterTime, m_MirrorTimer[BREATH_TIMER], 10); { SendMirrorTimer(BREATH_TIMER, UnderWaterTime, m_MirrorTimer[BREATH_TIMER], 10); }
} }
// In dark water // In dark water
@ -1086,10 +1087,10 @@ void Player::HandleDrowning(uint32 time_diff)
EnvironmentalDamage(DAMAGE_EXHAUSTED, damage); EnvironmentalDamage(DAMAGE_EXHAUSTED, damage);
} }
else if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) // Teleport ghost to graveyard else if (HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_GHOST)) // Teleport ghost to graveyard
RepopAtGraveyard(); { RepopAtGraveyard(); }
} }
else if (!(m_MirrorTimerFlagsLast & UNDERWATER_INDARKWATER)) else if (!(m_MirrorTimerFlagsLast & UNDERWATER_INDARKWATER))
SendMirrorTimer(FATIGUE_TIMER, getMaxTimer(FATIGUE_TIMER), m_MirrorTimer[FATIGUE_TIMER], -1); { SendMirrorTimer(FATIGUE_TIMER, getMaxTimer(FATIGUE_TIMER), m_MirrorTimer[FATIGUE_TIMER], -1); }
} }
} }
else if (m_MirrorTimer[FATIGUE_TIMER] != DISABLED_MIRROR_TIMER) // Regen timer else if (m_MirrorTimer[FATIGUE_TIMER] != DISABLED_MIRROR_TIMER) // Regen timer
@ -1097,16 +1098,16 @@ void Player::HandleDrowning(uint32 time_diff)
int32 DarkWaterTime = getMaxTimer(FATIGUE_TIMER); int32 DarkWaterTime = getMaxTimer(FATIGUE_TIMER);
m_MirrorTimer[FATIGUE_TIMER] += 10 * time_diff; m_MirrorTimer[FATIGUE_TIMER] += 10 * time_diff;
if (m_MirrorTimer[FATIGUE_TIMER] >= DarkWaterTime || !IsAlive()) if (m_MirrorTimer[FATIGUE_TIMER] >= DarkWaterTime || !IsAlive())
StopMirrorTimer(FATIGUE_TIMER); { StopMirrorTimer(FATIGUE_TIMER); }
else if (m_MirrorTimerFlagsLast & UNDERWATER_INDARKWATER) else if (m_MirrorTimerFlagsLast & UNDERWATER_INDARKWATER)
SendMirrorTimer(FATIGUE_TIMER, DarkWaterTime, m_MirrorTimer[FATIGUE_TIMER], 10); { SendMirrorTimer(FATIGUE_TIMER, DarkWaterTime, m_MirrorTimer[FATIGUE_TIMER], 10); }
} }
if (m_MirrorTimerFlags & (UNDERWATER_INLAVA /*| UNDERWATER_INSLIME*/) && !(m_lastLiquid && m_lastLiquid->SpellId)) if (m_MirrorTimerFlags & (UNDERWATER_INLAVA /*| UNDERWATER_INSLIME*/) && !(m_lastLiquid && m_lastLiquid->SpellId))
{ {
// Breath timer not activated - activate it // Breath timer not activated - activate it
if (m_MirrorTimer[FIRE_TIMER] == DISABLED_MIRROR_TIMER) if (m_MirrorTimer[FIRE_TIMER] == DISABLED_MIRROR_TIMER)
m_MirrorTimer[FIRE_TIMER] = getMaxTimer(FIRE_TIMER); { m_MirrorTimer[FIRE_TIMER] = getMaxTimer(FIRE_TIMER); }
else else
{ {
m_MirrorTimer[FIRE_TIMER] -= time_diff; m_MirrorTimer[FIRE_TIMER] -= time_diff;
@ -1117,7 +1118,7 @@ void Player::HandleDrowning(uint32 time_diff)
// TODO: Check this formula // TODO: Check this formula
uint32 damage = urand(600, 700); uint32 damage = urand(600, 700);
if (m_MirrorTimerFlags & UNDERWATER_INLAVA) if (m_MirrorTimerFlags & UNDERWATER_INLAVA)
EnvironmentalDamage(DAMAGE_LAVA, damage); { EnvironmentalDamage(DAMAGE_LAVA, damage); }
// need to skip Slime damage in Undercity, // need to skip Slime damage in Undercity,
// maybe someone can find better way to handle environmental damage // maybe someone can find better way to handle environmental damage
//else if (m_zoneUpdateId != 1497) //else if (m_zoneUpdateId != 1497)
@ -1126,7 +1127,7 @@ void Player::HandleDrowning(uint32 time_diff)
} }
} }
else else
m_MirrorTimer[FIRE_TIMER] = DISABLED_MIRROR_TIMER; { m_MirrorTimer[FIRE_TIMER] = DISABLED_MIRROR_TIMER; }
// Recheck timers flag // Recheck timers flag
m_MirrorTimerFlags &= ~UNDERWATER_EXIST_TIMERS; m_MirrorTimerFlags &= ~UNDERWATER_EXIST_TIMERS;
@ -1139,7 +1140,7 @@ void Player::HandleDrowning(uint32 time_diff)
m_MirrorTimerFlagsLast = m_MirrorTimerFlags; m_MirrorTimerFlagsLast = m_MirrorTimerFlags;
} }
// The player sobers by 1% every 9 seconds /// The player sobers by 1% every 9 seconds
void Player::HandleSobering() void Player::HandleSobering()
{ {
uint8 currentDrunkValue = GetDrunkValue(); uint8 currentDrunkValue = GetDrunkValue();
@ -2434,7 +2435,7 @@ void Player::SetGameMaster(bool on)
} }
else else
{ {
m_ExtraFlags &= ~PLAYER_EXTRA_GM_ON; m_ExtraFlags &= ~ PLAYER_EXTRA_GM_ON;
setFactionForRace(getRace()); setFactionForRace(getRace());
RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM); RemoveFlag(PLAYER_FLAGS, PLAYER_FLAGS_GM);
@ -5561,7 +5562,7 @@ bool Player::UpdateSkill(uint32 skill_id, uint32 step)
uint16 value = GetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset); uint16 value = GetUInt16Value(PLAYER_SKILL_RANK_0 + field, offset);
uint16 max = GetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset); uint16 max = GetUInt16Value(PLAYER_SKILL_MAX_RANK_0 + field, offset);
if (!max || !value || value >= max) if ((!max) || (!value) || (value >= max))
return false; return false;
uint32 new_value = value + step; uint32 new_value = value + step;
@ -6975,7 +6976,7 @@ void Player::UpdateZone(uint32 newZone, uint32 newArea)
// Used by Eluna // Used by Eluna
#ifdef ENABLE_ELUNA #ifdef ENABLE_ELUNA
sEluna->OnUpdateZone(this, newZone, newArea); sEluna->OnUpdateZone(this, newZone, newArea);
#endif /* ENABLE_ELUNA */ #endif
m_zoneUpdateId = newZone; m_zoneUpdateId = newZone;
m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL; m_zoneUpdateTimer = ZONE_UPDATE_INTERVAL;

View file

@ -1132,8 +1132,14 @@ class Player : public Unit
void ToggleAFK(); void ToggleAFK();
void ToggleDND(); void ToggleDND();
bool isAFK() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK); } bool isAFK() const
bool isDND() const { return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND); } {
return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_AFK);
}
bool isDND() const
{
return HasFlag(PLAYER_FLAGS, PLAYER_FLAGS_DND);
}
ChatTagFlags GetChatTag() const; ChatTagFlags GetChatTag() const;
std::string autoReplyMsg; std::string autoReplyMsg;
@ -1163,10 +1169,17 @@ class Player : public Unit
void SetTaxiCheater(bool on) { if (on) { m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; } else { m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; } } void SetTaxiCheater(bool on) { if (on) { m_ExtraFlags |= PLAYER_EXTRA_TAXICHEAT; } else { m_ExtraFlags &= ~PLAYER_EXTRA_TAXICHEAT; } }
bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); } bool isGMVisible() const { return !(m_ExtraFlags & PLAYER_EXTRA_GM_INVISIBLE); }
void SetGMVisible(bool on); void SetGMVisible(bool on);
void SetPvPDeath(bool on) { if (on) m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; else m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; } void SetPvPDeath(bool on)
{
if (on) { m_ExtraFlags |= PLAYER_EXTRA_PVP_DEATH; }
else { m_ExtraFlags &= ~PLAYER_EXTRA_PVP_DEATH; }
}
// 0 = own auction, -1 = enemy auction, 1 = goblin auction // 0 = own auction, -1 = enemy auction, 1 = goblin auction
int GetAuctionAccessMode() const { return m_ExtraFlags & PLAYER_EXTRA_AUCTION_ENEMY ? -1 : (m_ExtraFlags & PLAYER_EXTRA_AUCTION_NEUTRAL ? 1 : 0); } int GetAuctionAccessMode() const
{
return m_ExtraFlags & PLAYER_EXTRA_AUCTION_ENEMY ? -1 : (m_ExtraFlags & PLAYER_EXTRA_AUCTION_NEUTRAL ? 1 : 0);
}
void SetAuctionAccessMode(int state) void SetAuctionAccessMode(int state)
{ {
m_ExtraFlags &= ~(PLAYER_EXTRA_AUCTION_ENEMY | PLAYER_EXTRA_AUCTION_NEUTRAL); m_ExtraFlags &= ~(PLAYER_EXTRA_AUCTION_ENEMY | PLAYER_EXTRA_AUCTION_NEUTRAL);
@ -1571,7 +1584,7 @@ class Player : public Unit
void AddTimedQuest(uint32 quest_id) { m_timedquests.insert(quest_id); } void AddTimedQuest(uint32 quest_id) { m_timedquests.insert(quest_id); }
void RemoveTimedQuest(uint32 quest_id) { m_timedquests.erase(quest_id); } void RemoveTimedQuest(uint32 quest_id) { m_timedquests.erase(quest_id); }
//! Return collision height sent to client /// Return collision height sent to client
float GetCollisionHeight(bool mounted) const; float GetCollisionHeight(bool mounted) const;
/*********************************************************/ /*********************************************************/

View file

@ -40,7 +40,7 @@
bool Player::UpdateStats(Stats stat) bool Player::UpdateStats(Stats stat)
{ {
if (stat > STAT_SPIRIT) if (stat > STAT_SPIRIT)
return false; { return false; }
// value = ((base_value * base_pct) + total_value) * total_pct // value = ((base_value * base_pct) + total_value) * total_pct
float value = GetTotalStatValue(stat); float value = GetTotalStatValue(stat);
@ -135,7 +135,7 @@ bool Player::UpdateAllStats()
UpdateMaxHealth(); UpdateMaxHealth();
for (uint32 i = POWER_MANA; i < MAX_POWERS; ++i) for (uint32 i = POWER_MANA; i < MAX_POWERS; ++i)
UpdateMaxPower(Powers(i)); { UpdateMaxPower(Powers(i)); }
UpdateAllRatings(); UpdateAllRatings();
UpdateAllCritPercentages(); UpdateAllCritPercentages();
@ -150,7 +150,7 @@ bool Player::UpdateAllStats()
UpdateExpertise(BASE_ATTACK); UpdateExpertise(BASE_ATTACK);
UpdateExpertise(OFF_ATTACK); UpdateExpertise(OFF_ATTACK);
for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
UpdateResistances(i); { UpdateResistances(i); }
return true; return true;
} }
@ -167,7 +167,7 @@ void Player::UpdateResistances(uint32 school)
pet->UpdateResistances(school); pet->UpdateResistances(school);
} }
else else
UpdateArmor(); { UpdateArmor(); }
} }
void Player::UpdateArmor() void Player::UpdateArmor()
@ -346,7 +346,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
{ {
UpdateDamagePhysical(BASE_ATTACK); UpdateDamagePhysical(BASE_ATTACK);
if (CanDualWield() && haveOffhandWeapon()) // allow update offhand damage only if player knows DualWield Spec and has equipped offhand weapon if (CanDualWield() && haveOffhandWeapon()) // allow update offhand damage only if player knows DualWield Spec and has equipped offhand weapon
UpdateDamagePhysical(OFF_ATTACK); { UpdateDamagePhysical(OFF_ATTACK); }
} }
} }
@ -638,7 +638,7 @@ void Player::UpdateSpellHitChances()
void Player::UpdateAllSpellCritChances() void Player::UpdateAllSpellCritChances()
{ {
for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
UpdateSpellCritChance(i); { UpdateSpellCritChance(i); }
} }
void Player::UpdateExpertise(WeaponAttackType attack) void Player::UpdateExpertise(WeaponAttackType attack)
@ -711,7 +711,7 @@ void Player::UpdateManaRegen()
// Set regen rate in cast state apply only on spirit based regen // Set regen rate in cast state apply only on spirit based regen
int32 modManaRegenInterrupt = GetTotalAuraModifier(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT); int32 modManaRegenInterrupt = GetTotalAuraModifier(SPELL_AURA_MOD_MANA_REGEN_INTERRUPT);
if (modManaRegenInterrupt > 100) if (modManaRegenInterrupt > 100)
modManaRegenInterrupt = 100; { modManaRegenInterrupt = 100; }
SetStatFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER, base_regen + power_regen_mp5 + spirit_regen * modManaRegenInterrupt / 100.0f); SetStatFloatValue(UNIT_FIELD_POWER_REGEN_INTERRUPTED_FLAT_MODIFIER, base_regen + power_regen_mp5 + spirit_regen * modManaRegenInterrupt / 100.0f);
SetStatFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER, base_regen + 0.001f + power_regen_mp5 + spirit_regen); SetStatFloatValue(UNIT_FIELD_POWER_REGEN_FLAT_MODIFIER, base_regen + 0.001f + power_regen_mp5 + spirit_regen);
@ -803,10 +803,10 @@ bool Creature::UpdateAllStats()
UpdateAttackPowerAndDamage(); UpdateAttackPowerAndDamage();
for (uint32 i = POWER_MANA; i < MAX_POWERS; ++i) for (uint32 i = POWER_MANA; i < MAX_POWERS; ++i)
UpdateMaxPower(Powers(i)); { UpdateMaxPower(Powers(i)); }
for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
UpdateResistances(i); { UpdateResistances(i); }
return true; return true;
} }
@ -819,7 +819,7 @@ void Creature::UpdateResistances(uint32 school)
SetResistance(SpellSchools(school), int32(value)); SetResistance(SpellSchools(school), int32(value));
} }
else else
UpdateArmor(); { UpdateArmor(); }
} }
void Creature::UpdateArmor() void Creature::UpdateArmor()
@ -868,7 +868,7 @@ void Creature::UpdateAttackPowerAndDamage(bool ranged)
SetFloatValue(index_mult, attPowerMultiplier); // UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field SetFloatValue(index_mult, attPowerMultiplier); // UNIT_FIELD_(RANGED)_ATTACK_POWER_MULTIPLIER field
if (ranged) if (ranged)
return; { return; }
// automatically update weapon damage after attack power modification // automatically update weapon damage after attack power modification
UpdateDamagePhysical(BASE_ATTACK); UpdateDamagePhysical(BASE_ATTACK);
@ -878,7 +878,7 @@ void Creature::UpdateAttackPowerAndDamage(bool ranged)
void Creature::UpdateDamagePhysical(WeaponAttackType attType) void Creature::UpdateDamagePhysical(WeaponAttackType attType)
{ {
if (attType > OFF_ATTACK) if (attType > OFF_ATTACK)
return; { return; }
UnitMods unitMod = (attType == BASE_ATTACK ? UNIT_MOD_DAMAGE_MAINHAND : UNIT_MOD_DAMAGE_OFFHAND); UnitMods unitMod = (attType == BASE_ATTACK ? UNIT_MOD_DAMAGE_MAINHAND : UNIT_MOD_DAMAGE_OFFHAND);
@ -909,7 +909,7 @@ void Creature::UpdateDamagePhysical(WeaponAttackType attType)
bool Pet::UpdateStats(Stats stat) bool Pet::UpdateStats(Stats stat)
{ {
if (stat > STAT_SPIRIT) if (stat > STAT_SPIRIT)
return false; { return false; }
// value = ((base_value * base_pct) + total_value) * total_pct // value = ((base_value * base_pct) + total_value) * total_pct
float value = GetTotalStatValue(stat); float value = GetTotalStatValue(stat);
@ -946,13 +946,13 @@ bool Pet::UpdateStats(Stats stat)
bool Pet::UpdateAllStats() bool Pet::UpdateAllStats()
{ {
for (int i = STAT_STRENGTH; i < MAX_STATS; ++i) for (int i = STAT_STRENGTH; i < MAX_STATS; ++i)
UpdateStats(Stats(i)); { UpdateStats(Stats(i)); }
for (uint32 i = POWER_MANA; i < MAX_POWERS; ++i) for (uint32 i = POWER_MANA; i < MAX_POWERS; ++i)
UpdateMaxPower(Powers(i)); { UpdateMaxPower(Powers(i)); }
for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i) for (int i = SPELL_SCHOOL_NORMAL; i < MAX_SPELL_SCHOOL; ++i)
UpdateResistances(i); { UpdateResistances(i); }
return true; return true;
} }
@ -971,7 +971,7 @@ void Pet::UpdateResistances(uint32 school)
SetResistance(SpellSchools(school), int32(value)); SetResistance(SpellSchools(school), int32(value));
} }
else else
UpdateArmor(); { UpdateArmor(); }
} }
void Pet::UpdateArmor() void Pet::UpdateArmor()
@ -1026,16 +1026,16 @@ void Pet::UpdateMaxPower(Powers power)
void Pet::UpdateAttackPowerAndDamage(bool ranged) void Pet::UpdateAttackPowerAndDamage(bool ranged)
{ {
if (ranged) if (ranged)
return; { return; }
float val = 0.0f; float val = 0.0f;
float bonusAP = 0.0f; float bonusAP = 0.0f;
UnitMods unitMod = UNIT_MOD_ATTACK_POWER; UnitMods unitMod = UNIT_MOD_ATTACK_POWER;
if (GetEntry() == 416) // imp's attack power if (GetEntry() == 416) // imp's attack power
val = GetStat(STAT_STRENGTH) - 10.0f; { val = GetStat(STAT_STRENGTH) - 10.0f; }
else else
val = 2 * GetStat(STAT_STRENGTH) - 20.0f; { val = 2 * GetStat(STAT_STRENGTH) - 20.0f; }
Unit* owner = GetOwner(); Unit* owner = GetOwner();
if (owner && owner->GetTypeId() == TYPEID_PLAYER) if (owner && owner->GetTypeId() == TYPEID_PLAYER)
@ -1087,7 +1087,7 @@ void Pet::UpdateAttackPowerAndDamage(bool ranged)
void Pet::UpdateDamagePhysical(WeaponAttackType attType) void Pet::UpdateDamagePhysical(WeaponAttackType attType)
{ {
if (attType > BASE_ATTACK) if (attType > BASE_ATTACK)
return; { return; }
UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND; UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND;

View file

@ -61,7 +61,7 @@ void TemporarySummon::Update(uint32 update_diff, uint32 diff)
m_timer -= update_diff; m_timer -= update_diff;
} }
else if (m_timer != m_lifetime) else if (m_timer != m_lifetime)
m_timer = m_lifetime; { m_timer = m_lifetime; }
break; break;
} }
@ -122,10 +122,10 @@ void TemporarySummon::Update(uint32 update_diff, uint32 diff)
return; return;
} }
else else
m_timer -= update_diff; { m_timer -= update_diff; }
} }
else if (m_timer != m_lifetime) else if (m_timer != m_lifetime)
m_timer = m_lifetime; { m_timer = m_lifetime; }
break; break;
} }
case TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN: case TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN:
@ -145,10 +145,10 @@ void TemporarySummon::Update(uint32 update_diff, uint32 diff)
return; return;
} }
else else
m_timer -= update_diff; { m_timer -= update_diff; }
} }
else if (m_timer != m_lifetime) else if (m_timer != m_lifetime)
m_timer = m_lifetime; { m_timer = m_lifetime; }
break; break;
} }
case TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN: case TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN:

View file

@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#include "OutdoorPvP.h" #include "OutdoorPvP.h"
@ -50,7 +53,7 @@ void OutdoorPvP::HandlePlayerLeaveZone(Player* player, bool isMainZone)
{ {
// remove the world state information from the player // remove the world state information from the player
if (isMainZone && !player->GetSession()->PlayerLogout()) if (isMainZone && !player->GetSession()->PlayerLogout())
SendRemoveWorldStates(player); { SendRemoveWorldStates(player); }
sLog.outDebug("Player %s left an Outdoor PvP zone", player->GetName()); sLog.outDebug("Player %s left an Outdoor PvP zone", player->GetName());
} }
@ -68,10 +71,10 @@ void OutdoorPvP::SendUpdateWorldState(uint32 field, uint32 value)
{ {
// only send world state update to main zone // only send world state update to main zone
if (!itr->second) if (!itr->second)
continue; { continue; }
if (Player* player = sObjectMgr.GetPlayer(itr->first)) if (Player* player = sObjectMgr.GetPlayer(itr->first))
player->SendUpdateWorldState(field, value); { player->SendUpdateWorldState(field, value); }
} }
} }
@ -114,23 +117,23 @@ void OutdoorPvP::HandlePlayerKill(Player* killer, Player* victim)
Player* groupMember = itr->getSource(); Player* groupMember = itr->getSource();
if (!groupMember) if (!groupMember)
continue; { continue; }
// skip if too far away // skip if too far away
if (!groupMember->IsAtGroupRewardDistance(victim)) if (!groupMember->IsAtGroupRewardDistance(victim))
continue; { continue; }
// creature kills must be notified, even if not inside objective / not outdoor pvp active // creature kills must be notified, even if not inside objective / not outdoor pvp active
// player kills only count if active and inside objective // player kills only count if active and inside objective
if (groupMember->CanUseCapturePoint()) if (groupMember->CanUseCapturePoint())
HandlePlayerKillInsideArea(groupMember); { HandlePlayerKillInsideArea(groupMember); }
} }
} }
else else
{ {
// creature kills must be notified, even if not inside objective / not outdoor pvp active // creature kills must be notified, even if not inside objective / not outdoor pvp active
if (killer && killer->CanUseCapturePoint()) if (killer && killer->CanUseCapturePoint())
HandlePlayerKillInsideArea(killer); { HandlePlayerKillInsideArea(killer); }
} }
} }
@ -143,9 +146,9 @@ void OutdoorPvP::BuffTeam(Team team, uint32 spellId, bool remove /*= false*/)
if (player && player->GetTeam() == team) if (player && player->GetTeam() == team)
{ {
if (remove) if (remove)
player->RemoveAurasDueToSpell(spellId); { player->RemoveAurasDueToSpell(spellId); }
else else
player->CastSpell(player, spellId, true); { player->CastSpell(player, spellId, true); }
} }
} }
} }
@ -166,7 +169,7 @@ uint32 OutdoorPvP::GetBannerArtKit(Team team, uint32 artKitAlliance /*= CAPTURE_
void OutdoorPvP::SetBannerVisual(const WorldObject* objRef, ObjectGuid goGuid, uint32 artKit, uint32 animId) void OutdoorPvP::SetBannerVisual(const WorldObject* objRef, ObjectGuid goGuid, uint32 artKit, uint32 animId)
{ {
if (GameObject* go = objRef->GetMap()->GetGameObject(goGuid)) if (GameObject* go = objRef->GetMap()->GetGameObject(goGuid))
SetBannerVisual(go, artKit, animId); { SetBannerVisual(go, artKit, animId); }
} }
void OutdoorPvP::SetBannerVisual(GameObject* go, uint32 artKit, uint32 animId) void OutdoorPvP::SetBannerVisual(GameObject* go, uint32 artKit, uint32 animId)
@ -183,8 +186,8 @@ void OutdoorPvP::RespawnGO(const WorldObject* objRef, ObjectGuid goGuid, bool re
go->SetRespawnTime(7 * DAY); go->SetRespawnTime(7 * DAY);
if (respawn) if (respawn)
go->Refresh(); { go->Refresh(); }
else if (go->isSpawned()) else if (go->isSpawned())
go->SetLootState(GO_JUST_DEACTIVATED); { go->SetLootState(GO_JUST_DEACTIVATED); }
} }
} }

View file

@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef OUTDOOR_PVP_H #ifndef OUTDOOR_PVP_H
@ -27,6 +30,7 @@
#include "SharedDefines.h" #include "SharedDefines.h"
#include "OutdoorPvPMgr.h" #include "OutdoorPvPMgr.h"
// forward declaration
class WorldPacket; class WorldPacket;
class WorldObject; class WorldObject;
class Player; class Player;
@ -34,6 +38,10 @@ class GameObject;
class Unit; class Unit;
class Creature; class Creature;
/**
* @brief
*
*/
enum CapturePointArtKits enum CapturePointArtKits
{ {
CAPTURE_ARTKIT_ALLIANCE = 2, CAPTURE_ARTKIT_ALLIANCE = 2,
@ -41,6 +49,10 @@ enum CapturePointArtKits
CAPTURE_ARTKIT_NEUTRAL = 21 CAPTURE_ARTKIT_NEUTRAL = 21
}; };
/**
* @brief
*
*/
enum CapturePointAnimations enum CapturePointAnimations
{ {
CAPTURE_ANIM_ALLIANCE = 1, CAPTURE_ANIM_ALLIANCE = 1,
@ -48,80 +60,216 @@ enum CapturePointAnimations
CAPTURE_ANIM_NEUTRAL = 2 CAPTURE_ANIM_NEUTRAL = 2
}; };
typedef std::map<ObjectGuid /*playerGuid*/, bool /*isMainZone*/> GuidZoneMap; /**
* @brief
*
*/
typedef std::map < ObjectGuid /*playerGuid*/, bool /*isMainZone*/ > GuidZoneMap;
/**
* @brief
*
*/
class OutdoorPvP class OutdoorPvP
{ {
friend class OutdoorPvPMgr; friend class OutdoorPvPMgr;
public: public:
/**
* @brief
*
*/
OutdoorPvP() {} OutdoorPvP() {}
/**
* @brief
*
*/
virtual ~OutdoorPvP() {} virtual ~OutdoorPvP() {}
// called when the zone is initialized /**
* @brief called when the zone is initialized
*
* @param
* @param
*/
virtual void FillInitialWorldStates(WorldPacket& /*data*/, uint32& /*count*/) {} virtual void FillInitialWorldStates(WorldPacket& /*data*/, uint32& /*count*/) {}
// Process Capture event /**
* @brief Process Capture event
*
* @param uint32
* @param
* @return bool
*/
virtual bool HandleEvent(uint32 /*eventId*/, GameObject* /*go*/) { return false; } virtual bool HandleEvent(uint32 /*eventId*/, GameObject* /*go*/) { return false; }
// handle capture objective complete /**
* @brief handle capture objective complete
*
* @param uint32
* @param >
* @param Team
*/
virtual void HandleObjectiveComplete(uint32 /*eventId*/, const std::list<Player*>& /*players*/, Team /*team*/) {} virtual void HandleObjectiveComplete(uint32 /*eventId*/, const std::list<Player*>& /*players*/, Team /*team*/) {}
// Called when a creature is created /**
* @brief Called when a creature is created
*
* @param
*/
virtual void HandleCreatureCreate(Creature* /*creature*/) {} virtual void HandleCreatureCreate(Creature* /*creature*/) {}
// Called when a gameobject is created or removed /**
* @brief Called when a gameobject is created or removed
*
* @param
*/
virtual void HandleGameObjectCreate(GameObject* /*go*/); virtual void HandleGameObjectCreate(GameObject* /*go*/);
/**
* @brief
*
* @param
*/
virtual void HandleGameObjectRemove(GameObject* /*go*/); virtual void HandleGameObjectRemove(GameObject* /*go*/);
// Called on creature death /**
* @brief Called on creature death
*
* @param
*/
virtual void HandleCreatureDeath(Creature* /*creature*/) {} virtual void HandleCreatureDeath(Creature* /*creature*/) {}
// called when a player uses a gameobject related to outdoor pvp events /**
* @brief called when a player uses a gameobject related to outdoor pvp events
*
* @param
* @param
* @return bool
*/
virtual bool HandleGameObjectUse(Player* /*player*/, GameObject* /*go*/) { return false; } virtual bool HandleGameObjectUse(Player* /*player*/, GameObject* /*go*/) { return false; }
// called when a player triggers an areatrigger /**
* @brief called when a player triggers an areatrigger
*
* @param
* @param uint32
* @return bool
*/
virtual bool HandleAreaTrigger(Player* /*player*/, uint32 /*triggerId*/) { return false; } virtual bool HandleAreaTrigger(Player* /*player*/, uint32 /*triggerId*/) { return false; }
// called when a player drops a flag /**
* @brief called when a player drops a flag
*
* @param
* @param uint32
* @return bool
*/
virtual bool HandleDropFlag(Player* /*player*/, uint32 /*spellId*/) { return false; } virtual bool HandleDropFlag(Player* /*player*/, uint32 /*spellId*/) { return false; }
// update - called by the OutdoorPvPMgr /**
* @brief update - called by the OutdoorPvPMgr
*
* @param uint32
*/
virtual void Update(uint32 /*diff*/) {} virtual void Update(uint32 /*diff*/) {}
// Handle player kill /**
* @brief Handle player kill
*
* @param killer
* @param victim
*/
void HandlePlayerKill(Player* killer, Player* victim); void HandlePlayerKill(Player* killer, Player* victim);
protected: protected:
// Player related stuff // Player related stuff
/**
* @brief
*
* @param
* @param bool
*/
virtual void HandlePlayerEnterZone(Player* /*player*/, bool /*isMainZone*/); virtual void HandlePlayerEnterZone(Player* /*player*/, bool /*isMainZone*/);
/**
* @brief
*
* @param
* @param bool
*/
virtual void HandlePlayerLeaveZone(Player* /*player*/, bool /*isMainZone*/); virtual void HandlePlayerLeaveZone(Player* /*player*/, bool /*isMainZone*/);
// remove world states //
/**
* @brief remove world states
*
* @param
*/
virtual void SendRemoveWorldStates(Player* /*player*/) {} virtual void SendRemoveWorldStates(Player* /*player*/) {}
// handle npc/player kill /**
* @brief handle npc/player kill
*
* @param
*/
virtual void HandlePlayerKillInsideArea(Player* /*killer*/) {} virtual void HandlePlayerKillInsideArea(Player* /*killer*/) {}
// send world state update to all players present /**
* @brief send world state update to all players present
*
* @param field
* @param value
*/
void SendUpdateWorldState(uint32 field, uint32 value); void SendUpdateWorldState(uint32 field, uint32 value);
// applies buff to a team inside the specific zone /**
* @brief applies buff to a team inside the specific zone
*
* @param team
* @param spellId
* @param remove
*/
void BuffTeam(Team team, uint32 spellId, bool remove = false); void BuffTeam(Team team, uint32 spellId, bool remove = false);
// get banner artkit based on controlling team /**
* @brief get banner artkit based on controlling team
*
* @param team
* @param artKitAlliance
* @param artKitHorde
* @param artKitNeutral
* @return uint32
*/
uint32 GetBannerArtKit(Team team, uint32 artKitAlliance = CAPTURE_ARTKIT_ALLIANCE, uint32 artKitHorde = CAPTURE_ARTKIT_HORDE, uint32 artKitNeutral = CAPTURE_ARTKIT_NEUTRAL); uint32 GetBannerArtKit(Team team, uint32 artKitAlliance = CAPTURE_ARTKIT_ALLIANCE, uint32 artKitHorde = CAPTURE_ARTKIT_HORDE, uint32 artKitNeutral = CAPTURE_ARTKIT_NEUTRAL);
// set banner visual /**
* @brief set banner visual
*
* @param objRef
* @param goGuid
* @param artKit
* @param animId
*/
void SetBannerVisual(const WorldObject* objRef, ObjectGuid goGuid, uint32 artKit, uint32 animId); void SetBannerVisual(const WorldObject* objRef, ObjectGuid goGuid, uint32 artKit, uint32 animId);
/**
* @brief
*
* @param go
* @param artKit
* @param animId
*/
void SetBannerVisual(GameObject* go, uint32 artKit, uint32 animId); void SetBannerVisual(GameObject* go, uint32 artKit, uint32 animId);
// Handle gameobject spawn / despawn /**
* @brief Handle gameobject spawn / despawn
*
* @param objRef
* @param goGuid
* @param respawn
*/
void RespawnGO(const WorldObject* objRef, ObjectGuid goGuid, bool respawn); void RespawnGO(const WorldObject* objRef, ObjectGuid goGuid, bool respawn);
// store the players inside the area GuidZoneMap m_zonePlayers; /**< store the players inside the area */
GuidZoneMap m_zonePlayers;
}; };
#endif #endif

View file

@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#include "OutdoorPvPEP.h" #include "OutdoorPvPEP.h"
@ -38,7 +41,7 @@ OutdoorPvPEP::OutdoorPvPEP() : OutdoorPvP(),
m_towerWorldState[3] = WORLD_STATE_EP_PLAGUEWOOD_NEUTRAL; m_towerWorldState[3] = WORLD_STATE_EP_PLAGUEWOOD_NEUTRAL;
for (uint8 i = 0; i < MAX_EP_TOWERS; ++i) for (uint8 i = 0; i < MAX_EP_TOWERS; ++i)
m_towerOwner[i] = TEAM_NONE; { m_towerOwner[i] = TEAM_NONE; }
// initially set graveyard owner to neither faction // initially set graveyard owner to neither faction
sObjectMgr.SetGraveYardLinkTeam(GRAVEYARD_ID_EASTERN_PLAGUE, GRAVEYARD_ZONE_EASTERN_PLAGUE, TEAM_INVALID); sObjectMgr.SetGraveYardLinkTeam(GRAVEYARD_ID_EASTERN_PLAGUE, GRAVEYARD_ZONE_EASTERN_PLAGUE, TEAM_INVALID);
@ -50,13 +53,13 @@ void OutdoorPvPEP::FillInitialWorldStates(WorldPacket& data, uint32& count)
FillInitialWorldState(data, count, WORLD_STATE_EP_TOWER_COUNT_HORDE, m_towersHorde); FillInitialWorldState(data, count, WORLD_STATE_EP_TOWER_COUNT_HORDE, m_towersHorde);
for (uint8 i = 0; i < MAX_EP_TOWERS; ++i) for (uint8 i = 0; i < MAX_EP_TOWERS; ++i)
FillInitialWorldState(data, count, m_towerWorldState[i], WORLD_STATE_ADD); { FillInitialWorldState(data, count, m_towerWorldState[i], WORLD_STATE_ADD); }
} }
void OutdoorPvPEP::SendRemoveWorldStates(Player* player) void OutdoorPvPEP::SendRemoveWorldStates(Player* player)
{ {
for (uint8 i = 0; i < MAX_EP_TOWERS; ++i) for (uint8 i = 0; i < MAX_EP_TOWERS; ++i)
player->SendUpdateWorldState(m_towerWorldState[i], WORLD_STATE_REMOVE); { player->SendUpdateWorldState(m_towerWorldState[i], WORLD_STATE_REMOVE); }
} }
void OutdoorPvPEP::HandlePlayerEnterZone(Player* player, bool isMainZone) void OutdoorPvPEP::HandlePlayerEnterZone(Player* player, bool isMainZone)
@ -65,18 +68,18 @@ void OutdoorPvPEP::HandlePlayerEnterZone(Player* player, bool isMainZone)
// remove the buff from the player first; Sometimes on relog players still have the aura // remove the buff from the player first; Sometimes on relog players still have the aura
for (uint8 i = 0; i < MAX_EP_TOWERS; ++i) for (uint8 i = 0; i < MAX_EP_TOWERS; ++i)
player->RemoveAurasDueToSpell(player->GetTeam() == ALLIANCE ? plaguelandsTowerBuffs[i].spellIdAlliance : plaguelandsTowerBuffs[i].spellIdHorde); { player->RemoveAurasDueToSpell(player->GetTeam() == ALLIANCE ? plaguelandsTowerBuffs[i].spellIdAlliance : plaguelandsTowerBuffs[i].spellIdHorde); }
// buff the player // buff the player
switch (player->GetTeam()) switch (player->GetTeam())
{ {
case ALLIANCE: case ALLIANCE:
if (m_towersAlliance > 0) if (m_towersAlliance > 0)
player->CastSpell(player, plaguelandsTowerBuffs[m_towersAlliance - 1].spellIdAlliance, true); { player->CastSpell(player, plaguelandsTowerBuffs[m_towersAlliance - 1].spellIdAlliance, true); }
break; break;
case HORDE: case HORDE:
if (m_towersHorde > 0) if (m_towersHorde > 0)
player->CastSpell(player, plaguelandsTowerBuffs[m_towersHorde - 1].spellIdHorde, true); { player->CastSpell(player, plaguelandsTowerBuffs[m_towersHorde - 1].spellIdHorde, true); }
break; break;
default: default:
break; break;
@ -87,7 +90,7 @@ void OutdoorPvPEP::HandlePlayerLeaveZone(Player* player, bool isMainZone)
{ {
// remove the buff from the player // remove the buff from the player
for (uint8 i = 0; i < MAX_EP_TOWERS; ++i) for (uint8 i = 0; i < MAX_EP_TOWERS; ++i)
player->RemoveAurasDueToSpell(player->GetTeam() == ALLIANCE ? plaguelandsTowerBuffs[i].spellIdAlliance : plaguelandsTowerBuffs[i].spellIdHorde); { player->RemoveAurasDueToSpell(player->GetTeam() == ALLIANCE ? plaguelandsTowerBuffs[i].spellIdAlliance : plaguelandsTowerBuffs[i].spellIdHorde); }
OutdoorPvP::HandlePlayerLeaveZone(player, isMainZone); OutdoorPvP::HandlePlayerLeaveZone(player, isMainZone);
} }
@ -131,13 +134,13 @@ void OutdoorPvPEP::HandleGameObjectCreate(GameObject* go)
case GO_TOWER_BANNER: case GO_TOWER_BANNER:
// sort banners // sort banners
if (go->IsWithinDist2d(plaguelandsTowerLocations[TOWER_ID_NORTHPASS][0], plaguelandsTowerLocations[TOWER_ID_NORTHPASS][1], 50.0f)) if (go->IsWithinDist2d(plaguelandsTowerLocations[TOWER_ID_NORTHPASS][0], plaguelandsTowerLocations[TOWER_ID_NORTHPASS][1], 50.0f))
InitBanner(go, TOWER_ID_NORTHPASS); { InitBanner(go, TOWER_ID_NORTHPASS); }
else if (go->IsWithinDist2d(plaguelandsTowerLocations[TOWER_ID_CROWNGUARD][0], plaguelandsTowerLocations[TOWER_ID_CROWNGUARD][1], 50.0f)) else if (go->IsWithinDist2d(plaguelandsTowerLocations[TOWER_ID_CROWNGUARD][0], plaguelandsTowerLocations[TOWER_ID_CROWNGUARD][1], 50.0f))
InitBanner(go, TOWER_ID_CROWNGUARD); { InitBanner(go, TOWER_ID_CROWNGUARD); }
else if (go->IsWithinDist2d(plaguelandsTowerLocations[TOWER_ID_EASTWALL][0], plaguelandsTowerLocations[TOWER_ID_EASTWALL][1], 50.0f)) else if (go->IsWithinDist2d(plaguelandsTowerLocations[TOWER_ID_EASTWALL][0], plaguelandsTowerLocations[TOWER_ID_EASTWALL][1], 50.0f))
InitBanner(go, TOWER_ID_EASTWALL); { InitBanner(go, TOWER_ID_EASTWALL); }
else if (go->IsWithinDist2d(plaguelandsTowerLocations[TOWER_ID_PLAGUEWOOD][0], plaguelandsTowerLocations[TOWER_ID_PLAGUEWOOD][1], 50.0f)) else if (go->IsWithinDist2d(plaguelandsTowerLocations[TOWER_ID_PLAGUEWOOD][0], plaguelandsTowerLocations[TOWER_ID_PLAGUEWOOD][1], 50.0f))
InitBanner(go, TOWER_ID_PLAGUEWOOD); { InitBanner(go, TOWER_ID_PLAGUEWOOD); }
break; break;
case GO_LORDAERON_SHRINE_ALLIANCE: case GO_LORDAERON_SHRINE_ALLIANCE:
m_lordaeronShrineAlliance = go->GetObjectGuid(); m_lordaeronShrineAlliance = go->GetObjectGuid();
@ -199,7 +202,7 @@ bool OutdoorPvPEP::HandleEvent(uint32 eventId, GameObject* go)
if (plaguelandsTowerEvents[i][j].team != m_towerOwner[i]) if (plaguelandsTowerEvents[i][j].team != m_towerOwner[i])
{ {
if (plaguelandsTowerEvents[i][j].defenseMessage) if (plaguelandsTowerEvents[i][j].defenseMessage)
sWorld.SendDefenseMessage(ZONE_ID_EASTERN_PLAGUELANDS, plaguelandsTowerEvents[i][j].defenseMessage); { sWorld.SendDefenseMessage(ZONE_ID_EASTERN_PLAGUELANDS, plaguelandsTowerEvents[i][j].defenseMessage); }
return ProcessCaptureEvent(go, i, plaguelandsTowerEvents[i][j].team, plaguelandsTowerEvents[i][j].worldState); return ProcessCaptureEvent(go, i, plaguelandsTowerEvents[i][j].team, plaguelandsTowerEvents[i][j].worldState);
} }
@ -221,7 +224,7 @@ bool OutdoorPvPEP::ProcessCaptureEvent(GameObject* go, uint32 towerId, Team team
{ {
// update banner // update banner
for (GuidList::const_iterator itr = m_towerBanners[towerId].begin(); itr != m_towerBanners[towerId].end(); ++itr) for (GuidList::const_iterator itr = m_towerBanners[towerId].begin(); itr != m_towerBanners[towerId].end(); ++itr)
SetBannerVisual(go, (*itr), CAPTURE_ARTKIT_ALLIANCE, CAPTURE_ANIM_ALLIANCE); { SetBannerVisual(go, (*itr), CAPTURE_ARTKIT_ALLIANCE, CAPTURE_ANIM_ALLIANCE); }
// update counter // update counter
++m_towersAlliance; ++m_towersAlliance;
@ -234,7 +237,7 @@ bool OutdoorPvPEP::ProcessCaptureEvent(GameObject* go, uint32 towerId, Team team
{ {
// update banner // update banner
for (GuidList::const_iterator itr = m_towerBanners[towerId].begin(); itr != m_towerBanners[towerId].end(); ++itr) for (GuidList::const_iterator itr = m_towerBanners[towerId].begin(); itr != m_towerBanners[towerId].end(); ++itr)
SetBannerVisual(go, (*itr), CAPTURE_ARTKIT_HORDE, CAPTURE_ANIM_HORDE); { SetBannerVisual(go, (*itr), CAPTURE_ARTKIT_HORDE, CAPTURE_ANIM_HORDE); }
// update counter // update counter
++m_towersHorde; ++m_towersHorde;
@ -247,7 +250,7 @@ bool OutdoorPvPEP::ProcessCaptureEvent(GameObject* go, uint32 towerId, Team team
{ {
// update banner // update banner
for (GuidList::const_iterator itr = m_towerBanners[towerId].begin(); itr != m_towerBanners[towerId].end(); ++itr) for (GuidList::const_iterator itr = m_towerBanners[towerId].begin(); itr != m_towerBanners[towerId].end(); ++itr)
SetBannerVisual(go, (*itr), CAPTURE_ARTKIT_NEUTRAL, CAPTURE_ANIM_NEUTRAL); { SetBannerVisual(go, (*itr), CAPTURE_ARTKIT_NEUTRAL, CAPTURE_ANIM_NEUTRAL); }
if (m_towerOwner[towerId] == ALLIANCE) if (m_towerOwner[towerId] == ALLIANCE)
{ {
@ -256,7 +259,7 @@ bool OutdoorPvPEP::ProcessCaptureEvent(GameObject* go, uint32 towerId, Team team
SendUpdateWorldState(WORLD_STATE_EP_TOWER_COUNT_ALLIANCE, m_towersAlliance); SendUpdateWorldState(WORLD_STATE_EP_TOWER_COUNT_ALLIANCE, m_towersAlliance);
if (m_towersAlliance == 0) if (m_towersAlliance == 0)
BuffTeam(ALLIANCE, plaguelandsTowerBuffs[0].spellIdAlliance, true); { BuffTeam(ALLIANCE, plaguelandsTowerBuffs[0].spellIdAlliance, true); }
} }
else else
{ {
@ -265,7 +268,7 @@ bool OutdoorPvPEP::ProcessCaptureEvent(GameObject* go, uint32 towerId, Team team
SendUpdateWorldState(WORLD_STATE_EP_TOWER_COUNT_HORDE, m_towersHorde); SendUpdateWorldState(WORLD_STATE_EP_TOWER_COUNT_HORDE, m_towersHorde);
if (m_towersHorde == 0) if (m_towersHorde == 0)
BuffTeam(HORDE, plaguelandsTowerBuffs[0].spellIdHorde, true); { BuffTeam(HORDE, plaguelandsTowerBuffs[0].spellIdHorde, true); }
} }
} }
@ -288,7 +291,7 @@ bool OutdoorPvPEP::ProcessCaptureEvent(GameObject* go, uint32 towerId, Team team
case TOWER_ID_EASTWALL: case TOWER_ID_EASTWALL:
// Return false - allow the DB to handle summons // Return false - allow the DB to handle summons
if (m_towerOwner[TOWER_ID_NORTHPASS] != team) if (m_towerOwner[TOWER_ID_NORTHPASS] != team)
eventHandled = false; { eventHandled = false; }
break; break;
case TOWER_ID_PLAGUEWOOD: case TOWER_ID_PLAGUEWOOD:
// Return false - allow the DB to handle summons // Return false - allow the DB to handle summons
@ -332,7 +335,7 @@ bool OutdoorPvPEP::HandleGameObjectUse(Player* /*player*/, GameObject* go)
{ {
// prevent despawning after go use // prevent despawning after go use
if (go->GetEntry() == GO_LORDAERON_SHRINE_ALLIANCE || go->GetEntry() == GO_LORDAERON_SHRINE_HORDE) if (go->GetEntry() == GO_LORDAERON_SHRINE_ALLIANCE || go->GetEntry() == GO_LORDAERON_SHRINE_HORDE)
go->SetRespawnTime(0); { go->SetRespawnTime(0); }
return false; return false;
} }
@ -347,7 +350,7 @@ void OutdoorPvPEP::InitBanner(GameObject* go, uint32 towerId)
void OutdoorPvPEP::UnsummonFlightMaster(const WorldObject* objRef) void OutdoorPvPEP::UnsummonFlightMaster(const WorldObject* objRef)
{ {
if (Creature* flightMaster = objRef->GetMap()->GetCreature(m_flightMaster)) if (Creature* flightMaster = objRef->GetMap()->GetCreature(m_flightMaster))
flightMaster->ForcedDespawn(); { flightMaster->ForcedDespawn(); }
} }
// Handle the unsummon of the soldiers when the Eastwall tower is lost // Handle the unsummon of the soldiers when the Eastwall tower is lost
@ -356,7 +359,7 @@ void OutdoorPvPEP::UnsummonSoldiers(const WorldObject* objRef)
for (GuidList::const_iterator itr = m_soldiers.begin(); itr != m_soldiers.end(); ++itr) for (GuidList::const_iterator itr = m_soldiers.begin(); itr != m_soldiers.end(); ++itr)
{ {
if (Creature* soldier = objRef->GetMap()->GetCreature(*itr)) if (Creature* soldier = objRef->GetMap()->GetCreature(*itr))
soldier->ForcedDespawn(); { soldier->ForcedDespawn(); }
} }
m_soldiers.clear(); m_soldiers.clear();

View file

@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef WORLD_PVP_EP #ifndef WORLD_PVP_EP
@ -26,6 +29,10 @@
#include "OutdoorPvP.h" #include "OutdoorPvP.h"
#include "Language.h" #include "Language.h"
/**
* @brief
*
*/
enum enum
{ {
TOWER_ID_NORTHPASS = 0, TOWER_ID_NORTHPASS = 0,
@ -167,12 +174,16 @@ enum
WORLD_STATE_EP_CROWNGUARD_NEUTRAL = 2355 WORLD_STATE_EP_CROWNGUARD_NEUTRAL = 2355
}; };
/**
* @brief
*
*/
struct PlaguelandsTowerBuff struct PlaguelandsTowerBuff
{ {
uint32 spellIdAlliance, spellIdHorde; uint32 spellIdAlliance, spellIdHorde; /**< TODO */
}; };
static const PlaguelandsTowerBuff plaguelandsTowerBuffs[MAX_EP_TOWERS] = static const PlaguelandsTowerBuff plaguelandsTowerBuffs[MAX_EP_TOWERS] = /**< TODO */
{ {
{SPELL_ECHOES_OF_LORDAERON_ALLIANCE_1, SPELL_ECHOES_OF_LORDAERON_HORDE_1}, {SPELL_ECHOES_OF_LORDAERON_ALLIANCE_1, SPELL_ECHOES_OF_LORDAERON_HORDE_1},
{SPELL_ECHOES_OF_LORDAERON_ALLIANCE_2, SPELL_ECHOES_OF_LORDAERON_HORDE_2}, {SPELL_ECHOES_OF_LORDAERON_ALLIANCE_2, SPELL_ECHOES_OF_LORDAERON_HORDE_2},
@ -180,8 +191,7 @@ static const PlaguelandsTowerBuff plaguelandsTowerBuffs[MAX_EP_TOWERS] =
{SPELL_ECHOES_OF_LORDAERON_ALLIANCE_4, SPELL_ECHOES_OF_LORDAERON_HORDE_4} {SPELL_ECHOES_OF_LORDAERON_ALLIANCE_4, SPELL_ECHOES_OF_LORDAERON_HORDE_4}
}; };
// capture points coordinates to sort the banners static const float plaguelandsTowerLocations[MAX_EP_TOWERS][2] = /**< capture points coordinates to sort the banners */
static const float plaguelandsTowerLocations[MAX_EP_TOWERS][2] =
{ {
{3181.08f, -4379.36f}, // Northpass {3181.08f, -4379.36f}, // Northpass
{1860.85f, -3731.23f}, // Crownguard {1860.85f, -3731.23f}, // Crownguard
@ -189,15 +199,19 @@ static const float plaguelandsTowerLocations[MAX_EP_TOWERS][2] =
{2962.71f, -3042.31f} // Plaguewood {2962.71f, -3042.31f} // Plaguewood
}; };
/**
* @brief
*
*/
struct PlaguelandsTowerEvent struct PlaguelandsTowerEvent
{ {
uint32 eventEntry; uint32 eventEntry; /**< TODO */
Team team; Team team; /**< TODO */
uint32 defenseMessage; uint32 defenseMessage; /**< TODO */
uint32 worldState; uint32 worldState; /**< TODO */
}; };
static const PlaguelandsTowerEvent plaguelandsTowerEvents[MAX_EP_TOWERS][4] = static const PlaguelandsTowerEvent plaguelandsTowerEvents[MAX_EP_TOWERS][4] = /**< TODO */
{ {
{ {
{EVENT_NORTHPASS_PROGRESS_ALLIANCE, ALLIANCE, LANG_OPVP_EP_CAPTURE_NPT_A, WORLD_STATE_EP_NORTHPASS_ALLIANCE}, {EVENT_NORTHPASS_PROGRESS_ALLIANCE, ALLIANCE, LANG_OPVP_EP_CAPTURE_NPT_A, WORLD_STATE_EP_NORTHPASS_ALLIANCE},
@ -225,48 +239,132 @@ static const PlaguelandsTowerEvent plaguelandsTowerEvents[MAX_EP_TOWERS][4] =
}, },
}; };
static const uint32 plaguelandsBanners[MAX_EP_TOWERS] = {GO_TOWER_BANNER_NORTHPASS, GO_TOWER_BANNER_CROWNGUARD, GO_TOWER_BANNER_EASTWALL, GO_TOWER_BANNER_PLAGUEWOOD}; static const uint32 plaguelandsBanners[MAX_EP_TOWERS] = {GO_TOWER_BANNER_NORTHPASS, GO_TOWER_BANNER_CROWNGUARD, GO_TOWER_BANNER_EASTWALL, GO_TOWER_BANNER_PLAGUEWOOD}; /**< TODO */
/**
* @brief
*
*/
class OutdoorPvPEP : public OutdoorPvP class OutdoorPvPEP : public OutdoorPvP
{ {
public: public:
/**
* @brief
*
*/
OutdoorPvPEP(); OutdoorPvPEP();
/**
* @brief
*
* @param player
* @param isMainZone
*/
void HandlePlayerEnterZone(Player* player, bool isMainZone) override; void HandlePlayerEnterZone(Player* player, bool isMainZone) override;
/**
* @brief
*
* @param player
* @param isMainZone
*/
void HandlePlayerLeaveZone(Player* player, bool isMainZone) override; void HandlePlayerLeaveZone(Player* player, bool isMainZone) override;
/**
* @brief
*
* @param data
* @param count
*/
void FillInitialWorldStates(WorldPacket& data, uint32& count) override; void FillInitialWorldStates(WorldPacket& data, uint32& count) override;
/**
* @brief
*
* @param player
*/
void SendRemoveWorldStates(Player* player) override; void SendRemoveWorldStates(Player* player) override;
/**
* @brief
*
* @param eventId
* @param go
* @return bool
*/
bool HandleEvent(uint32 eventId, GameObject* go) override; bool HandleEvent(uint32 eventId, GameObject* go) override;
/**
* @brief
*
* @param eventId
* @param players
* @param team
*/
void HandleObjectiveComplete(uint32 eventId, const std::list<Player*>& players, Team team) override; void HandleObjectiveComplete(uint32 eventId, const std::list<Player*>& players, Team team) override;
/**
* @brief
*
* @param creature
*/
void HandleCreatureCreate(Creature* creature) override; void HandleCreatureCreate(Creature* creature) override;
/**
* @brief
*
* @param go
*/
void HandleGameObjectCreate(GameObject* go) override; void HandleGameObjectCreate(GameObject* go) override;
/**
* @brief
*
* @param player
* @param go
* @return bool
*/
bool HandleGameObjectUse(Player* player, GameObject* go) override; bool HandleGameObjectUse(Player* player, GameObject* go) override;
private: private:
// process capture events /**
* @brief process capture events
*
* @param go
* @param towerId
* @param team
* @param newWorldState
* @return bool
*/
bool ProcessCaptureEvent(GameObject* go, uint32 towerId, Team team, uint32 newWorldState); bool ProcessCaptureEvent(GameObject* go, uint32 towerId, Team team, uint32 newWorldState);
/**
* @brief
*
* @param go
* @param towerId
*/
void InitBanner(GameObject* go, uint32 towerId); void InitBanner(GameObject* go, uint32 towerId);
// Plaguewood bonus - flight master /**
* @brief Plaguewood bonus - flight master
*
* @param objRef
*/
void UnsummonFlightMaster(const WorldObject* objRef); void UnsummonFlightMaster(const WorldObject* objRef);
// Eastwall bonus - soldiers /**
* @brief Eastwall bonus - soldiers
*
* @param objRef
*/
void UnsummonSoldiers(const WorldObject* objRef); void UnsummonSoldiers(const WorldObject* objRef);
Team m_towerOwner[MAX_EP_TOWERS]; Team m_towerOwner[MAX_EP_TOWERS]; /**< TODO */
uint32 m_towerWorldState[MAX_EP_TOWERS]; uint32 m_towerWorldState[MAX_EP_TOWERS]; /**< TODO */
uint8 m_towersAlliance; uint8 m_towersAlliance; /**< TODO */
uint8 m_towersHorde; uint8 m_towersHorde; /**< TODO */
ObjectGuid m_flightMaster; ObjectGuid m_flightMaster; /**< TODO */
ObjectGuid m_lordaeronShrineAlliance; ObjectGuid m_lordaeronShrineAlliance; /**< TODO */
ObjectGuid m_lordaeronShrineHorde; ObjectGuid m_lordaeronShrineHorde; /**< TODO */
GuidList m_soldiers; GuidList m_soldiers; /**< TODO */
GuidList m_towerBanners[MAX_EP_TOWERS]; GuidList m_towerBanners[MAX_EP_TOWERS]; /**< TODO */
}; };
#endif #endif

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#include "OutdoorPvPHP.h" #include "OutdoorPvPHP.h"

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef WORLD_PVP_HP #ifndef WORLD_PVP_HP

View file

@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#include "OutdoorPvPMgr.h" #include "OutdoorPvPMgr.h"
@ -43,7 +46,7 @@ OutdoorPvPMgr::OutdoorPvPMgr()
OutdoorPvPMgr::~OutdoorPvPMgr() OutdoorPvPMgr::~OutdoorPvPMgr()
{ {
for (uint8 i = 0; i < MAX_OPVP_ID; ++i) for (uint8 i = 0; i < MAX_OPVP_ID; ++i)
delete m_scripts[i]; { delete m_scripts[i]; }
} }
#define LOAD_OPVP_ZONE(a) \ #define LOAD_OPVP_ZONE(a) \
@ -135,7 +138,7 @@ OutdoorPvP* OutdoorPvPMgr::GetScriptOfAffectedZone(uint32 zoneId)
void OutdoorPvPMgr::HandlePlayerEnterZone(Player* player, uint32 zoneId) void OutdoorPvPMgr::HandlePlayerEnterZone(Player* player, uint32 zoneId)
{ {
if (OutdoorPvP* script = GetScript(zoneId)) if (OutdoorPvP* script = GetScript(zoneId))
script->HandlePlayerEnterZone(player, true); { script->HandlePlayerEnterZone(player, true); }
else if (OutdoorPvP* affectedScript = GetScriptOfAffectedZone(zoneId)) else if (OutdoorPvP* affectedScript = GetScriptOfAffectedZone(zoneId))
affectedScript->HandlePlayerEnterZone(player, false); affectedScript->HandlePlayerEnterZone(player, false);
} }
@ -150,7 +153,7 @@ void OutdoorPvPMgr::HandlePlayerLeaveZone(Player* player, uint32 zoneId)
{ {
// teleport: called once from Player::CleanupsBeforeDelete, once from Player::UpdateZone // teleport: called once from Player::CleanupsBeforeDelete, once from Player::UpdateZone
if (OutdoorPvP* script = GetScript(zoneId)) if (OutdoorPvP* script = GetScript(zoneId))
script->HandlePlayerLeaveZone(player, true); { script->HandlePlayerLeaveZone(player, true); }
else if (OutdoorPvP* affectedScript = GetScriptOfAffectedZone(zoneId)) else if (OutdoorPvP* affectedScript = GetScriptOfAffectedZone(zoneId))
affectedScript->HandlePlayerLeaveZone(player, false); affectedScript->HandlePlayerLeaveZone(player, false);
} }
@ -159,11 +162,11 @@ void OutdoorPvPMgr::Update(uint32 diff)
{ {
m_updateTimer.Update(diff); m_updateTimer.Update(diff);
if (!m_updateTimer.Passed()) if (!m_updateTimer.Passed())
return; { return; }
for (uint8 i = 0; i < MAX_OPVP_ID; ++i) for (uint8 i = 0; i < MAX_OPVP_ID; ++i)
if (m_scripts[i]) if (m_scripts[i])
m_scripts[i]->Update(m_updateTimer.GetCurrent()); { m_scripts[i]->Update(m_updateTimer.GetCurrent()); }
m_updateTimer.Reset(); m_updateTimer.Reset();
} }

View file

@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef WORLD_PVP_MGR_H #ifndef WORLD_PVP_MGR_H
@ -26,11 +29,19 @@
#include "Policies/Singleton.h" #include "Policies/Singleton.h"
#include "Timer.h" #include "Timer.h"
/**
* @brief
*
*/
enum enum
{ {
TIMER_OPVP_MGR_UPDATE = MINUTE * IN_MILLISECONDS // 1 minute is enough for us but this might change with wintergrasp support TIMER_OPVP_MGR_UPDATE = MINUTE * IN_MILLISECONDS // 1 minute is enough for us but this might change with wintergrasp support
}; };
/**
* @brief
*
*/
enum OutdoorPvPTypes enum OutdoorPvPTypes
{ {
OPVP_ID_SI = 0, OPVP_ID_SI = 0,
@ -44,6 +55,10 @@ enum OutdoorPvPTypes
MAX_OPVP_ID MAX_OPVP_ID
}; };
/**
* @brief
*
*/
enum OutdoorPvPZones enum OutdoorPvPZones
{ {
ZONE_ID_SILITHUS = 1377, ZONE_ID_SILITHUS = 1377,
@ -88,48 +103,96 @@ struct CapturePointSlider
bool IsLocked; bool IsLocked;
}; };
// forward declaration
class Player; class Player;
class GameObject; class GameObject;
class Creature; class Creature;
class OutdoorPvP; class OutdoorPvP;
/**
* @brief
*
*/
typedef std::map<uint32 /*capture point entry*/, CapturePointSlider /*slider value and lock state*/> CapturePointSliderMap; typedef std::map<uint32 /*capture point entry*/, CapturePointSlider /*slider value and lock state*/> CapturePointSliderMap;
class OutdoorPvPMgr class OutdoorPvPMgr
{ {
public: public:
/**
* @brief
*
*/
OutdoorPvPMgr(); OutdoorPvPMgr();
/**
* @brief
*
*/
~OutdoorPvPMgr(); ~OutdoorPvPMgr();
// load all outdoor pvp scripts /**
* @brief load all outdoor pvp scripts
*
*/
void InitOutdoorPvP(); void InitOutdoorPvP();
// called when a player enters an outdoor pvp area /**
* @brief called when a player enters an outdoor pvp area
*
* @param player
* @param zoneId
*/
void HandlePlayerEnterZone(Player* player, uint32 zoneId); void HandlePlayerEnterZone(Player* player, uint32 zoneId);
// called when player leaves an outdoor pvp area /**
* @brief called when player leaves an outdoor pvp area
*
* @param player
* @param zoneId
*/
void HandlePlayerLeaveZone(Player* player, uint32 zoneId); void HandlePlayerLeaveZone(Player* player, uint32 zoneId);
// return assigned outdoor pvp script /**
* @brief return assigned outdoor pvp script
*
* @param zoneId
* @return OutdoorPvP
*/
OutdoorPvP* GetScript(uint32 zoneId); OutdoorPvP* GetScript(uint32 zoneId);
/**
* @brief
*
* @param diff
*/
void Update(uint32 diff); void Update(uint32 diff);
// Save and load capture point slider /**
* Save and load capture point slider
*
* @param entry
* @param value
*/
CapturePointSliderMap const* GetCapturePointSliderMap() const { return &m_capturePointSlider; } CapturePointSliderMap const* GetCapturePointSliderMap() const { return &m_capturePointSlider; }
void SetCapturePointSlider(uint32 entry, CapturePointSlider value) { m_capturePointSlider[entry] = value; } void SetCapturePointSlider(uint32 entry, CapturePointSlider value) { m_capturePointSlider[entry] = value; }
private: private:
// return assigned outdoor pvp script /**
* @brief return assigned outdoor pvp script
*
* @param zoneId
* @return OutdoorPvP
*/
OutdoorPvP* GetScriptOfAffectedZone(uint32 zoneId); OutdoorPvP* GetScriptOfAffectedZone(uint32 zoneId);
// contains all outdoor pvp scripts OutdoorPvP* m_scripts[MAX_OPVP_ID]; /**< contains all outdoor pvp scripts */
OutdoorPvP* m_scripts[MAX_OPVP_ID];
/**
* @brief
*
*/
CapturePointSliderMap m_capturePointSlider; CapturePointSliderMap m_capturePointSlider;
// update interval ShortIntervalTimer m_updateTimer; /**< update interval */
ShortIntervalTimer m_updateTimer;
}; };
#define sOutdoorPvPMgr MaNGOS::Singleton<OutdoorPvPMgr>::Instance() #define sOutdoorPvPMgr MaNGOS::Singleton<OutdoorPvPMgr>::Instance()

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#include "OutdoorPvPNA.h" #include "OutdoorPvPNA.h"

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef WORLD_PVP_NA #ifndef WORLD_PVP_NA

View file

@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#include "OutdoorPvPSI.h" #include "OutdoorPvPSI.h"
@ -53,7 +56,7 @@ void OutdoorPvPSI::HandlePlayerEnterZone(Player* player, bool isMainZone)
// buff the player if same team is controlling the zone // buff the player if same team is controlling the zone
if (player->GetTeam() == m_zoneOwner) if (player->GetTeam() == m_zoneOwner)
player->CastSpell(player, SPELL_CENARION_FAVOR, true); { player->CastSpell(player, SPELL_CENARION_FAVOR, true); }
} }
// Remove buffs when player leaves zone // Remove buffs when player leaves zone
@ -69,13 +72,13 @@ void OutdoorPvPSI::HandlePlayerLeaveZone(Player* player, bool isMainZone)
bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 triggerId) bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 triggerId)
{ {
if (player->isGameMaster() || player->IsDead()) if (player->isGameMaster() || player->IsDead())
return false; { return false; }
switch (triggerId) switch (triggerId)
{ {
case AREATRIGGER_SILITHUS_ALLIANCE: case AREATRIGGER_SILITHUS_ALLIANCE:
if (player->GetTeam() != ALLIANCE || !player->HasAura(SPELL_SILITHYST)) if (player->GetTeam() != ALLIANCE || !player->HasAura(SPELL_SILITHYST))
return false; { return false; }
// update counter // update counter
++ m_resourcesAlliance; ++ m_resourcesAlliance;
@ -101,11 +104,11 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 triggerId)
// give quest credit if necessary // give quest credit if necessary
if (player->GetQuestStatus(QUEST_SCOURING_DESERT_ALLIANCE) == QUEST_STATUS_INCOMPLETE) if (player->GetQuestStatus(QUEST_SCOURING_DESERT_ALLIANCE) == QUEST_STATUS_INCOMPLETE)
player->KilledMonsterCredit(NPC_SILITHUS_DUST_QUEST_ALLIANCE); { player->KilledMonsterCredit(NPC_SILITHUS_DUST_QUEST_ALLIANCE); }
break; break;
case AREATRIGGER_SILITHUS_HORDE: case AREATRIGGER_SILITHUS_HORDE:
if (player->GetTeam() != HORDE || !player->HasAura(SPELL_SILITHYST)) if (player->GetTeam() != HORDE || !player->HasAura(SPELL_SILITHYST))
return false; { return false; }
// update counter // update counter
++ m_resourcesHorde; ++ m_resourcesHorde;
@ -131,7 +134,7 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 triggerId)
// give quest credit if necessary // give quest credit if necessary
if (player->GetQuestStatus(QUEST_SCOURING_DESERT_HORDE) == QUEST_STATUS_INCOMPLETE) if (player->GetQuestStatus(QUEST_SCOURING_DESERT_HORDE) == QUEST_STATUS_INCOMPLETE)
player->KilledMonsterCredit(NPC_SILITHUS_DUST_QUEST_HORDE); { player->KilledMonsterCredit(NPC_SILITHUS_DUST_QUEST_HORDE); }
break; break;
default: default:
return false; return false;
@ -164,7 +167,7 @@ static SilithusSpawnLocation silithusFlagDropLocations[2] =
bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId) bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId)
{ {
if (spellId != SPELL_SILITHYST) if (spellId != SPELL_SILITHYST)
return false; { return false; }
// don't drop flag at area trigger // don't drop flag at area trigger
// we are checking distance from the AT hard-coded coordinates because it's much faster than checking the area trigger store // we are checking distance from the AT hard-coded coordinates because it's much faster than checking the area trigger store
@ -172,11 +175,11 @@ bool OutdoorPvPSI::HandleDropFlag(Player* player, uint32 spellId)
{ {
case ALLIANCE: case ALLIANCE:
if (player->IsWithinDist3d(silithusFlagDropLocations[0].x, silithusFlagDropLocations[0].y, silithusFlagDropLocations[0].z, 5.0f)) if (player->IsWithinDist3d(silithusFlagDropLocations[0].x, silithusFlagDropLocations[0].y, silithusFlagDropLocations[0].z, 5.0f))
return false; { return false; }
break; break;
case HORDE: case HORDE:
if (player->IsWithinDist3d(silithusFlagDropLocations[1].x, silithusFlagDropLocations[1].y, silithusFlagDropLocations[1].z, 5.0f)) if (player->IsWithinDist3d(silithusFlagDropLocations[1].x, silithusFlagDropLocations[1].y, silithusFlagDropLocations[1].z, 5.0f))
return false; { return false; }
break; break;
default: default:
break; break;

View file

@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef WORLD_PVP_SI #ifndef WORLD_PVP_SI
@ -26,6 +29,10 @@
#include "OutdoorPvP.h" #include "OutdoorPvP.h"
#include "Language.h" #include "Language.h"
/**
* @brief
*
*/
enum enum
{ {
// npcs // npcs
@ -63,23 +70,70 @@ enum
WORLD_STATE_SI_SILITHYST_MAX = 2317 WORLD_STATE_SI_SILITHYST_MAX = 2317
}; };
/**
* @brief
*
*/
class OutdoorPvPSI : public OutdoorPvP class OutdoorPvPSI : public OutdoorPvP
{ {
public: public:
/**
* @brief
*
*/
OutdoorPvPSI(); OutdoorPvPSI();
/**
* @brief
*
* @param player
* @param isMainZone
*/
void HandlePlayerEnterZone(Player* player, bool isMainZone) override; void HandlePlayerEnterZone(Player* player, bool isMainZone) override;
/**
* @brief
*
* @param player
* @param isMainZone
*/
void HandlePlayerLeaveZone(Player* player, bool isMainZone) override; void HandlePlayerLeaveZone(Player* player, bool isMainZone) override;
/**
* @brief
*
* @param data
* @param count
*/
void FillInitialWorldStates(WorldPacket& data, uint32& count) override; void FillInitialWorldStates(WorldPacket& data, uint32& count) override;
/**
* @brief
*
* @param player
* @param triggerId
* @return bool
*/
bool HandleAreaTrigger(Player* player, uint32 triggerId) override; bool HandleAreaTrigger(Player* player, uint32 triggerId) override;
/**
* @brief
*
* @param player
* @param go
* @return bool
*/
bool HandleGameObjectUse(Player* player, GameObject* go) override; bool HandleGameObjectUse(Player* player, GameObject* go) override;
/**
* @brief
*
* @param player
* @param spellId
* @return bool
*/
bool HandleDropFlag(Player* player, uint32 spellId) override; bool HandleDropFlag(Player* player, uint32 spellId) override;
private: private:
uint8 m_resourcesAlliance; uint8 m_resourcesAlliance; /**< TODO */
uint8 m_resourcesHorde; uint8 m_resourcesHorde; /**< TODO */
Team m_zoneOwner; Team m_zoneOwner; /**< TODO */
}; };
#endif #endif

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#include "OutdoorPvPTF.h" #include "OutdoorPvPTF.h"

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef WORLD_PVP_TF #ifndef WORLD_PVP_TF

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#include "OutdoorPvPZM.h" #include "OutdoorPvPZM.h"

View file

@ -1,4 +1,4 @@
/* /**
* MaNGOS is a full featured server for World of Warcraft, supporting * MaNGOS is a full featured server for World of Warcraft, supporting
* the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8 * the following clients: 1.12.x, 2.4.3, 3.3.5a, 4.3.4a and 5.4.8
* *
@ -17,6 +17,9 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* World of Warcraft, and all World of Warcraft or Warcraft art, images,
* and lore are copyrighted by Blizzard Entertainment, Inc.
*/ */
#ifndef WORLD_PVP_ZM #ifndef WORLD_PVP_ZM

View file

@ -40,7 +40,7 @@ class MapReference : public Reference<Map, Player>
void targetObjectDestroyLink() override void targetObjectDestroyLink() override
{ {
// called from unlink() // called from unlink()
if (isValid()) getTarget()->m_mapRefManager.decSize(); if (isValid()) { getTarget()->m_mapRefManager.decSize(); }
} }
void sourceObjectDestroyLink() override void sourceObjectDestroyLink() override
{ {

View file

@ -40,18 +40,18 @@ float ThreatCalcHelper::CalcThreat(Unit* pHatedUnit, Unit* /*pHatingUnit*/, floa
{ {
// all flat mods applied early // all flat mods applied early
if (!threat) if (!threat)
return 0.0f; { return 0.0f; }
if (pThreatSpell) if (pThreatSpell)
{ {
if (pThreatSpell->HasAttribute(SPELL_ATTR_EX_NO_THREAT)) if (pThreatSpell->HasAttribute(SPELL_ATTR_EX_NO_THREAT))
return 0.0f; { return 0.0f; }
if (Player* modOwner = pHatedUnit->GetSpellModOwner()) if (Player* modOwner = pHatedUnit->GetSpellModOwner())
modOwner->ApplySpellMod(pThreatSpell->Id, SPELLMOD_THREAT, threat); { modOwner->ApplySpellMod(pThreatSpell->Id, SPELLMOD_THREAT, threat); }
if (crit) if (crit)
threat *= pHatedUnit->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRITICAL_THREAT, schoolMask); { threat *= pHatedUnit->GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRITICAL_THREAT, schoolMask); }
} }
threat = pHatedUnit->ApplyTotalThreatModifier(threat, schoolMask); threat = pHatedUnit->ApplyTotalThreatModifier(threat, schoolMask);
@ -100,7 +100,7 @@ void HostileReference::sourceObjectDestroyLink()
void HostileReference::fireStatusChanged(ThreatRefStatusChangeEvent& pThreatRefStatusChangeEvent) void HostileReference::fireStatusChanged(ThreatRefStatusChangeEvent& pThreatRefStatusChangeEvent)
{ {
if (getSource()) if (getSource())
getSource()->processThreatEvent(&pThreatRefStatusChangeEvent); { getSource()->processThreatEvent(&pThreatRefStatusChangeEvent); }
} }
//============================================================ //============================================================
@ -114,7 +114,7 @@ void HostileReference::addThreat(float pMod)
// the threat is changed. Source and target unit have to be availabe // the threat is changed. Source and target unit have to be availabe
// if the link was cut before relink it again // if the link was cut before relink it again
if (!isOnline()) if (!isOnline())
updateOnlineStatus(); { updateOnlineStatus(); }
if (pMod != 0.0f) if (pMod != 0.0f)
{ {
ThreatRefStatusChangeEvent event(UEV_THREAT_REF_THREAT_CHANGE, this, pMod); ThreatRefStatusChangeEvent event(UEV_THREAT_REF_THREAT_CHANGE, this, pMod);
@ -125,7 +125,7 @@ void HostileReference::addThreat(float pMod)
{ {
Unit* victim_owner = getTarget()->GetOwner(); Unit* victim_owner = getTarget()->GetOwner();
if (victim_owner && victim_owner->IsAlive()) if (victim_owner && victim_owner->IsAlive())
getSource()->addThreat(victim_owner, 0.0f); // create a threat to the owner of a pet, if the pet attacks { getSource()->addThreat(victim_owner, 0.0f); } // create a threat to the owner of a pet, if the pet attacks
} }
} }
@ -140,7 +140,7 @@ void HostileReference::updateOnlineStatus()
if (!isValid()) if (!isValid())
{ {
if (Unit* target = ObjectAccessor::GetUnit(*getSourceUnit(), getUnitGuid())) if (Unit* target = ObjectAccessor::GetUnit(*getSourceUnit(), getUnitGuid()))
link(target, getSource()); { link(target, getSource()); }
} }
// only check for online status if // only check for online status if
// ref is valid // ref is valid
@ -155,10 +155,10 @@ void HostileReference::updateOnlineStatus()
if (!online) if (!online)
{ {
if (creature->AI()->canReachByRangeAttack(getTarget())) if (creature->AI()->canReachByRangeAttack(getTarget()))
online = true; // not accessable but stays online { online = true; } // not accessable but stays online
} }
else else
accessible = true; { accessible = true; }
} }
setAccessibleState(accessible); setAccessibleState(accessible);
setOnlineOfflineState(online); setOnlineOfflineState(online);
@ -173,7 +173,7 @@ void HostileReference::setOnlineOfflineState(bool pIsOnline)
{ {
iOnline = pIsOnline; iOnline = pIsOnline;
if (!iOnline) if (!iOnline)
setAccessibleState(false); // if not online that not accessable as well { setAccessibleState(false); } // if not online that not accessable as well
ThreatRefStatusChangeEvent event(UEV_THREAT_REF_ONLINE_STATUS, this); ThreatRefStatusChangeEvent event(UEV_THREAT_REF_ONLINE_STATUS, this);
fireStatusChanged(event); fireStatusChanged(event);
@ -251,7 +251,7 @@ HostileReference* ThreatContainer::addThreat(Unit* pVictim, float pThreat)
{ {
HostileReference* ref = getReferenceByTarget(pVictim); HostileReference* ref = getReferenceByTarget(pVictim);
if (ref) if (ref)
ref->addThreat(pThreat); { ref->addThreat(pThreat); }
return ref; return ref;
} }
@ -267,7 +267,7 @@ void ThreatContainer::modifyThreatPercent(Unit* pVictim, int32 pPercent)
delete ref; delete ref;
} }
else else
ref->addThreatPercent(pPercent); { ref->addThreatPercent(pPercent); }
} }
} }
@ -318,7 +318,7 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* pAttacker, Hostile
if (!onlySecondChoiceTargetsFound && pAttacker->IsSecondChoiceTarget(pTarget, pCurrentRef == pCurrentVictim)) if (!onlySecondChoiceTargetsFound && pAttacker->IsSecondChoiceTarget(pTarget, pCurrentRef == pCurrentVictim))
{ {
if (iter != lastRef) if (iter != lastRef)
++iter; { ++iter; }
else else
{ {
// if we reached to this point, everyone in the threatlist is a second choice target. In such a situation the target with the highest threat should be attacked. // if we reached to this point, everyone in the threatlist is a second choice target. In such a situation the target with the highest threat should be attacked.
@ -328,7 +328,7 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* pAttacker, Hostile
// current victim is a second choice target, so don't compare threat with it below // current victim is a second choice target, so don't compare threat with it below
if (pCurrentRef == pCurrentVictim) if (pCurrentRef == pCurrentVictim)
pCurrentVictim = NULL; { pCurrentVictim = NULL; }
// second choice targets are only handled threat dependend if we have only have second choice targets // second choice targets are only handled threat dependend if we have only have second choice targets
continue; continue;
@ -385,7 +385,7 @@ HostileReference* ThreatContainer::selectNextVictim(Creature* pAttacker, Hostile
++iter; ++iter;
} }
if (!found) if (!found)
pCurrentRef = NULL; { pCurrentRef = NULL; }
return pCurrentRef; return pCurrentRef;
} }
@ -421,15 +421,15 @@ void ThreatManager::addThreat(Unit* pVictim, float pThreat, bool crit, SpellScho
// not to self // not to self
if (pVictim == getOwner()) if (pVictim == getOwner())
return; { return; }
// not to GM // not to GM
if (!pVictim || (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster())) if (!pVictim || (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster()))
return; { return; }
// not to dead and not for dead // not to dead and not for dead
if (!pVictim->IsAlive() || !getOwner()->IsAlive()) if (!pVictim->IsAlive() || !getOwner()->IsAlive())
return; { return; }
MANGOS_ASSERT(getOwner()->GetTypeId() == TYPEID_UNIT); MANGOS_ASSERT(getOwner()->GetTypeId() == TYPEID_UNIT);
@ -472,7 +472,7 @@ void ThreatManager::addThreatDirectly(Unit* pVictim, float threat)
hostileReference->addThreat(threat); // now we add the real threat hostileReference->addThreat(threat); // now we add the real threat
iUpdateNeed = true; iUpdateNeed = true;
if (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster()) if (pVictim->GetTypeId() == TYPEID_PLAYER && ((Player*)pVictim)->isGameMaster())
hostileReference->setOnlineOfflineState(false); // GM is always offline { hostileReference->setOnlineOfflineState(false); } // GM is always offline
} }
} }
@ -570,7 +570,7 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat
case UEV_THREAT_REF_THREAT_CHANGE: case UEV_THREAT_REF_THREAT_CHANGE:
if ((getCurrentVictim() == hostileReference && threatRefStatusChangeEvent->getFValue() < 0.0f) || if ((getCurrentVictim() == hostileReference && threatRefStatusChangeEvent->getFValue() < 0.0f) ||
(getCurrentVictim() != hostileReference && threatRefStatusChangeEvent->getFValue() > 0.0f)) (getCurrentVictim() != hostileReference && threatRefStatusChangeEvent->getFValue() > 0.0f))
setDirty(true); // the order in the threat list might have changed { setDirty(true); } // the order in the threat list might have changed
break; break;
case UEV_THREAT_REF_ONLINE_STATUS: case UEV_THREAT_REF_ONLINE_STATUS:
if (!hostileReference->isOnline()) if (!hostileReference->isOnline())
@ -588,7 +588,7 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat
else else
{ {
if (getCurrentVictim() && hostileReference->getThreat() > (1.1f * getCurrentVictim()->getThreat())) if (getCurrentVictim() && hostileReference->getThreat() > (1.1f * getCurrentVictim()->getThreat()))
setDirty(true); { setDirty(true); }
iThreatContainer.addReference(hostileReference); iThreatContainer.addReference(hostileReference);
iUpdateNeed = true; iUpdateNeed = true;
iThreatOfflineContainer.remove(hostileReference); iThreatOfflineContainer.remove(hostileReference);
@ -607,7 +607,7 @@ void ThreatManager::processThreatEvent(ThreatRefStatusChangeEvent* threatRefStat
iUpdateNeed = true; iUpdateNeed = true;
} }
else else
iThreatOfflineContainer.remove(hostileReference); { iThreatOfflineContainer.remove(hostileReference); }
break; break;
} }
} }

View file

@ -78,7 +78,7 @@ class HostileReference : public Reference<Unit, ThreatManager>
// used for temporary setting a threat and reducting it later again. // used for temporary setting a threat and reducting it later again.
// the threat modification is stored // the threat modification is stored
void setTempThreat(float pThreat) { iTempThreatModifyer = pThreat - getThreat(); if (iTempThreatModifyer != 0.0f) addThreat(iTempThreatModifyer); } void setTempThreat(float pThreat) { iTempThreatModifyer = pThreat - getThreat(); if (iTempThreatModifyer != 0.0f) { addThreat(iTempThreatModifyer); } }
void resetTempThreat() void resetTempThreat()
{ {
@ -169,7 +169,7 @@ class ThreatContainer
bool isDirty() const { return iDirty; } bool isDirty() const { return iDirty; }
bool empty() const { return iThreatList.empty(); } bool empty() const { return(iThreatList.empty()); }
HostileReference* getMostHated() { return iThreatList.empty() ? NULL : iThreatList.front(); } HostileReference* getMostHated() { return iThreatList.empty() ? NULL : iThreatList.front(); }

View file

@ -539,11 +539,17 @@ enum SpellCastTargetFlags
TARGET_FLAG_VISUAL_CHAIN = 0x00080000 // uint32, loop { vec3, guid -> if guid == 0 break } TARGET_FLAG_VISUAL_CHAIN = 0x00080000 // uint32, loop { vec3, guid -> if guid == 0 break }
}; };
/**
* Used in \ref Unit::HasAura for example, also used in \ref Spell::m_currentBasePoints. These
* reference the three effects a \ref Spell can have which do different things, for instance it
* can be applying a \ref Aura. For a reference see QSW which you can get at
* https://bitbucket.org/sidsukana/qsw
*/
enum SpellEffectIndex enum SpellEffectIndex
{ {
EFFECT_INDEX_0 = 0, EFFECT_INDEX_0 = 0, ///< The first spell effect
EFFECT_INDEX_1 = 1, EFFECT_INDEX_1 = 1, ///< The second spell effect
EFFECT_INDEX_2 = 2 EFFECT_INDEX_2 = 2 ///< The third spell effect
}; };
#define MAX_EFFECT_INDEX 3 #define MAX_EFFECT_INDEX 3

View file

@ -260,7 +260,7 @@ bool IsAcceptableClientBuild(uint32 build)
int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD; int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD;
for (int i = 0; accepted_versions[i]; ++i) for (int i = 0; accepted_versions[i]; ++i)
if (int(build) == accepted_versions[i]) if (int(build) == accepted_versions[i])
return true; { return true; }
return false; return false;
} }
@ -270,7 +270,7 @@ std::string AcceptableClientBuildsListStr()
std::ostringstream data; std::ostringstream data;
int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD; int accepted_versions[] = EXPECTED_MANGOSD_CLIENT_BUILD;
for (int i = 0; accepted_versions[i]; ++i) for (int i = 0; accepted_versions[i]; ++i)
data << accepted_versions[i] << " "; { data << accepted_versions[i] << " "; }
return data.str(); return data.str();
} }
@ -1039,9 +1039,9 @@ ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id)
bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId) bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredTotemCategoryId)
{ {
if (requiredTotemCategoryId==0) if (requiredTotemCategoryId == 0)
return true; return true;
if (itemTotemCategoryId==0) if (itemTotemCategoryId == 0)
return false; return false;
TotemCategoryEntry const* itemEntry = sTotemCategoryStore.LookupEntry(itemTotemCategoryId); TotemCategoryEntry const* itemEntry = sTotemCategoryStore.LookupEntry(itemTotemCategoryId);
@ -1051,10 +1051,10 @@ bool IsTotemCategoryCompatiableWith(uint32 itemTotemCategoryId, uint32 requiredT
if (!reqEntry) if (!reqEntry)
return false; return false;
if (itemEntry->categoryType!=reqEntry->categoryType) if (itemEntry->categoryType != reqEntry->categoryType)
return false; return false;
return (itemEntry->categoryMask & reqEntry->categoryMask)==reqEntry->categoryMask; return (itemEntry->categoryMask & reqEntry->categoryMask) == reqEntry->categoryMask;
} }
bool Zone2MapCoordinates(float& x, float& y, uint32 zone) bool Zone2MapCoordinates(float& x, float& y, uint32 zone)
@ -1066,13 +1066,13 @@ bool Zone2MapCoordinates(float& x, float& y, uint32 zone)
return false; return false;
std::swap(x, y); // at client map coords swapped std::swap(x, y); // at client map coords swapped
x = x * ((maEntry->x2-maEntry->x1) / 100) + maEntry->x1; x = x * ((maEntry->x2 - maEntry->x1) / 100) + maEntry->x1;
y = y * ((maEntry->y2-maEntry->y1) / 100) + maEntry->y1; // client y coord from top to down y = y * ((maEntry->y2 - maEntry->y1) / 100) + maEntry->y1; // client y coord from top to down
return true; return true;
} }
bool Map2ZoneCoordinates(float& x,float& y,uint32 zone) bool Map2ZoneCoordinates(float& x, float& y, uint32 zone)
{ {
WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone); WorldMapAreaEntry const* maEntry = sWorldMapAreaStore.LookupEntry(zone);
@ -1080,9 +1080,9 @@ bool Map2ZoneCoordinates(float& x,float& y,uint32 zone)
if (!maEntry || maEntry->x2 == maEntry->x1 || maEntry->y2 == maEntry->y1) if (!maEntry || maEntry->x2 == maEntry->x1 || maEntry->y2 == maEntry->y1)
return false; return false;
x = (x-maEntry->x1)/((maEntry->x2-maEntry->x1)/100); x = (x - maEntry->x1) / ((maEntry->x2 - maEntry->x1) / 100);
y = (y-maEntry->y1)/((maEntry->y2-maEntry->y1)/100); // client y coord from top to down y = (y - maEntry->y1) / ((maEntry->y2 - maEntry->y1) / 100); // client y coord from top to down
std::swap(x,y); // client have map coords swapped std::swap(x, y); // client have map coords swapped
return true; return true;
} }

View file

@ -26,7 +26,7 @@
#define MANGOS_DBCSTORES_H #define MANGOS_DBCSTORES_H
#include "Common.h" #include "Common.h"
#include"DataStores/DBCStore.h" #include "DataStores/DBCStore.h"
#include "DBCStructure.h" #include "DBCStructure.h"
#include <list> #include <list>
@ -69,7 +69,6 @@ enum ContentLevels
CONTENT_71_80, CONTENT_71_80,
CONTENT_81_85, CONTENT_81_85,
}; };
ContentLevels GetContentLevelsForMapAndZone(uint32 mapId, uint32 zoneId); ContentLevels GetContentLevelsForMapAndZone(uint32 mapId, uint32 zoneId);
ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id); ChatChannelsEntry const* GetChannelEntryFor(uint32 channel_id);

View file

@ -155,7 +155,7 @@ const char TaxiPathEntryfmt[] = "niii";
const char TaxiPathNodeEntryfmt[] = "diiifffiiii"; const char TaxiPathNodeEntryfmt[] = "diiifffiiii";
const char TotemCategoryEntryfmt[]="nxii"; const char TotemCategoryEntryfmt[]="nxii";
const char TransportAnimationEntryfmt[]="diixxxx"; const char TransportAnimationEntryfmt[]="diixxxx";
const char VehicleEntryfmt[]="niffffiiiiiiiifffffffffffffffssssfifiixx"; const char VehicleEntryfmt[] = "niffffiiiiiiiifffffffffffffffssssfifiixx";
// 1 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 // 1 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160
const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiiixxxxxxxxxxxxxxxxxxxx"; const char VehicleSeatEntryfmt[]="niiffffffffffiiiiiifffffffiiifffiiiiiiiffiiiiixxxxxxxxxxxxxxxxxxxx";
const char WMOAreaTableEntryfmt[]="niiixxxxxiixxxx"; const char WMOAreaTableEntryfmt[]="niiixxxxxiixxxx";

View file

@ -157,6 +157,10 @@ enum Stats
#define MAX_STATS 5 #define MAX_STATS 5
/**
* These are the different possible powers that are available to us, they should
* be fairly familiar if you've played WoW.
*/
enum Powers enum Powers
{ {
POWER_MANA = 0, POWER_MANA = 0,
@ -233,7 +237,7 @@ inline SpellSchools GetFirstSchoolInMask(SpellSchoolMask mask)
{ {
for (int i = 0; i < MAX_SPELL_SCHOOL; ++i) for (int i = 0; i < MAX_SPELL_SCHOOL; ++i)
if (mask & (1 << i)) if (mask & (1 << i))
return SpellSchools(i); { return SpellSchools(i); }
return SPELL_SCHOOL_NORMAL; return SPELL_SCHOOL_NORMAL;
} }
@ -1349,7 +1353,7 @@ enum Mechanics
#define IMMUNE_TO_INTERRUPT_AND_SILENCE_MASK ( \ #define IMMUNE_TO_INTERRUPT_AND_SILENCE_MASK ( \
(1<<(MECHANIC_INTERRUPT-1))|(1<<(MECHANIC_SILENCE-1))) (1<<(MECHANIC_INTERRUPT-1))|(1<<(MECHANIC_SILENCE-1)))
// Daze and all croud control spells except polymorph are not removed /// Daze and all crowd control spells except polymorph are not removed
#define MECHANIC_NOT_REMOVED_BY_SHAPESHIFT ( \ #define MECHANIC_NOT_REMOVED_BY_SHAPESHIFT ( \
(1<<(MECHANIC_CHARM -1))|(1<<(MECHANIC_DISORIENTED-1))|(1<<(MECHANIC_FEAR -1))| \ (1<<(MECHANIC_CHARM -1))|(1<<(MECHANIC_DISORIENTED-1))|(1<<(MECHANIC_FEAR -1))| \
(1<<(MECHANIC_PACIFY-1))|(1<<(MECHANIC_STUN -1))|(1<<(MECHANIC_FREEZE-1))| \ (1<<(MECHANIC_PACIFY-1))|(1<<(MECHANIC_STUN -1))|(1<<(MECHANIC_FREEZE-1))| \
@ -1397,10 +1401,12 @@ enum SpellImmunity
*/ */
enum WeaponAttackType // The different weapon attack-types enum WeaponAttackType // The different weapon attack-types
{ {
///Main-hand weapon
BASE_ATTACK = 0, // Main-hand weapon BASE_ATTACK = 0,
OFF_ATTACK = 1, // Off-hand weapon ///Off-hand weapon
RANGED_ATTACK = 2 ///Ranged weapon, bow/wand etc. OFF_ATTACK = 1,
///Ranged weapon, bow/wand etc.
RANGED_ATTACK = 2
}; };
#define MAX_ATTACK 3 #define MAX_ATTACK 3
@ -1503,7 +1509,7 @@ enum Targets
TARGET_VEHICLE_PASSENGER_6 = 102, TARGET_VEHICLE_PASSENGER_6 = 102,
TARGET_VEHICLE_PASSENGER_7 = 103, TARGET_VEHICLE_PASSENGER_7 = 103,
TARGET_IN_FRONT_OF_CASTER_30 = 104, TARGET_IN_FRONT_OF_CASTER_30 = 104,
TARGET_105 = 105, TARGET_105 = 105, // 1 spell
TARGET_106 = 106, TARGET_106 = 106,
TARGET_107 = 107, // possible TARGET_WMO(GO?)_IN_FRONT_OF_CASTER(_30 ?) TODO: Verify the angle! TARGET_107 = 107, // possible TARGET_WMO(GO?)_IN_FRONT_OF_CASTER(_30 ?) TODO: Verify the angle!
TARGET_GO_IN_FRONT_OF_CASTER_90 = 108, TARGET_GO_IN_FRONT_OF_CASTER_90 = 108,
@ -1528,11 +1534,16 @@ enum Targets
TARGET_127 = 127, TARGET_127 = 127,
}; };
/**
* Tells how a spell that was cast missed or hit, ie it might have been
* resisted or dodged etc. This enum tells which of those it was. The only
* one which indicates a hit is SPELL_MISS_NONE
*/
enum SpellMissInfo enum SpellMissInfo
{ {
SPELL_MISS_NONE = 0, SPELL_MISS_NONE = 0, ///< Indicates an actual hit
SPELL_MISS_MISS = 1, SPELL_MISS_MISS = 1,
SPELL_MISS_RESIST = 2, SPELL_MISS_RESIST = 2, ///< The spell was resisted
SPELL_MISS_DODGE = 3, SPELL_MISS_DODGE = 3,
SPELL_MISS_PARRY = 4, SPELL_MISS_PARRY = 4,
SPELL_MISS_BLOCK = 5, SPELL_MISS_BLOCK = 5,
@ -1597,9 +1608,8 @@ enum DamageEffectType
DOT = 2, DOT = 2,
HEAL = 3, HEAL = 3,
/// used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc /// used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc
NODAMAGE = 4, NODAMAGE = 4, //< used also in case when damage applied to health but not applied to spell channelInterruptFlags/etc
/// used to avoid rogue loosing stealth on falling damage SELF_DAMAGE_ROGUE_FALL = 5, //< used to avoid rogue loosing stealth on falling damage
SELF_DAMAGE_ROGUE_FALL = 5,
SELF_DAMAGE = 6 SELF_DAMAGE = 6
}; };
@ -1649,9 +1659,9 @@ enum GameObjectFlags
{ {
GO_FLAG_IN_USE = 0x00000001, // disables interaction while animated GO_FLAG_IN_USE = 0x00000001, // disables interaction while animated
GO_FLAG_LOCKED = 0x00000002, // require key, spell, event, etc to be opened. Makes "Locked" appear in tooltip GO_FLAG_LOCKED = 0x00000002, // require key, spell, event, etc to be opened. Makes "Locked" appear in tooltip
GO_FLAG_INTERACT_COND = 0x00000004, // cannot interact (condition to interact) GO_FLAG_INTERACT_COND = 0x00000004, // can not interact (condition to interact)
GO_FLAG_TRANSPORT = 0x00000008, // any kind of transport? Object can transport (elevator, boat, car) GO_FLAG_TRANSPORT = 0x00000008, // any kind of transport? Object can transport (elevator, boat, car)
GO_FLAG_NO_INTERACT = 0x00000010, // players cannot interact with this go (often need to remove flag in event) GO_FLAG_NO_INTERACT = 0x00000010, // players can not interact with this go (often need to remove flag in event)
GO_FLAG_NODESPAWN = 0x00000020, // never despawn, typically for doors, they just change state GO_FLAG_NODESPAWN = 0x00000020, // never despawn, typically for doors, they just change state
GO_FLAG_TRIGGERED = 0x00000040, // typically, summoned objects. Triggered by spell or other events GO_FLAG_TRIGGERED = 0x00000040, // typically, summoned objects. Triggered by spell or other events
GO_FLAG_UNK_8 = 0x00000080, GO_FLAG_UNK_8 = 0x00000080,
@ -3206,7 +3216,7 @@ enum UnitDynFlags
UNIT_DYNFLAG_NONE = 0x0000, UNIT_DYNFLAG_NONE = 0x0000,
UNIT_DYNFLAG_LOOTABLE = 0x0001, UNIT_DYNFLAG_LOOTABLE = 0x0001,
UNIT_DYNFLAG_TRACK_UNIT = 0x0002, UNIT_DYNFLAG_TRACK_UNIT = 0x0002,
UNIT_DYNFLAG_TAPPED = 0x0004, // Lua_UnitIsTapped UNIT_DYNFLAG_TAPPED = 0x0004, // Lua_UnitIsTapped - Indicates the target as grey for the client.
UNIT_DYNFLAG_TAPPED_BY_PLAYER = 0x0008, // Lua_UnitIsTappedByPlayer UNIT_DYNFLAG_TAPPED_BY_PLAYER = 0x0008, // Lua_UnitIsTappedByPlayer
UNIT_DYNFLAG_SPECIALINFO = 0x0010, UNIT_DYNFLAG_SPECIALINFO = 0x0010,
UNIT_DYNFLAG_DEAD = 0x0020, UNIT_DYNFLAG_DEAD = 0x0020,
@ -3652,7 +3662,12 @@ enum PetTameFailureReason
PETTAME_UNKNOWNERROR = 14, PETTAME_UNKNOWNERROR = 14,
}; };
// Stored in SummonProperties.dbc with slot+1 values /**
* These are the different totem types that are available.
* Stored in SummonProperties.dbc with slot+1 values
* \see Totem
* \see Unit::GetTotemGuid
*/
enum TotemSlot enum TotemSlot
{ {
TOTEM_SLOT_FIRE = 0, TOTEM_SLOT_FIRE = 0,

View file

@ -129,7 +129,7 @@ WorldSocket::~WorldSocket(void)
delete m_RecvWPct; delete m_RecvWPct;
if (m_OutBuffer) if (m_OutBuffer)
m_OutBuffer->release(); { m_OutBuffer->release(); }
closing_ = true; closing_ = true;
@ -147,7 +147,7 @@ void WorldSocket::CloseSocket(void)
ACE_GUARD(LockType, Guard, m_OutBufferLock); ACE_GUARD(LockType, Guard, m_OutBufferLock);
if (closing_) if (closing_)
return; { return; }
closing_ = true; closing_ = true;
peer().close_writer(); peer().close_writer();
@ -170,7 +170,7 @@ int WorldSocket::SendPacket(const WorldPacket& pct)
ACE_GUARD_RETURN(LockType, Guard, m_OutBufferLock, -1); ACE_GUARD_RETURN(LockType, Guard, m_OutBufferLock, -1);
if (closing_) if (closing_)
return -1; { return -1; }
// Dump outgoing packet. // Dump outgoing packet.
sLog.outWorldPacketDump(uint32(get_handle()), pct.GetOpcode(), pct.GetOpcodeName(), &pct, false); sLog.outWorldPacketDump(uint32(get_handle()), pct.GetOpcode(), pct.GetOpcodeName(), &pct, false);
@ -232,7 +232,7 @@ int WorldSocket::open(void* a)
// Prevent double call to this func. // Prevent double call to this func.
if (m_OutBuffer) if (m_OutBuffer)
return -1; { return -1; }
// This will also prevent the socket from being Updated // This will also prevent the socket from being Updated
// while we are initializing it. // while we are initializing it.
@ -240,7 +240,7 @@ int WorldSocket::open(void* a)
// Hook for the manager. // Hook for the manager.
if (sWorldSocketMgr->OnSocketOpen(this) == -1) if (sWorldSocketMgr->OnSocketOpen(this) == -1)
return -1; { return -1; }
// Allocate the buffer. // Allocate the buffer.
ACE_NEW_RETURN(m_OutBuffer, ACE_Message_Block(m_OutBufferSize), -1); ACE_NEW_RETURN(m_OutBuffer, ACE_Message_Block(m_OutBufferSize), -1);
@ -272,8 +272,8 @@ int WorldSocket::open(void* a)
packet << m_Seed; packet << m_Seed;
packet << uint8(1); packet << uint8(1);
if (SendPacket (packet) == -1) if (SendPacket(packet) == -1)
return -1; { return -1; }
// Register with ACE Reactor // Register with ACE Reactor
if (reactor()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1) if (reactor()->register_handler(this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::WRITE_MASK) == -1)
@ -295,7 +295,7 @@ int WorldSocket::HandleWowConnection(WorldPacket& recvPacket)
return 0; return 0;
} }
int WorldSocket::close (int) int WorldSocket::close(int)
{ {
shutdown(); shutdown();
@ -309,7 +309,7 @@ int WorldSocket::close (int)
int WorldSocket::handle_input(ACE_HANDLE) int WorldSocket::handle_input(ACE_HANDLE)
{ {
if (closing_) if (closing_)
return -1; { return -1; }
switch (handle_input_missing_data()) switch (handle_input_missing_data())
{ {
@ -347,7 +347,7 @@ int WorldSocket::handle_output(ACE_HANDLE)
ACE_GUARD_RETURN(LockType, Guard, m_OutBufferLock, -1); ACE_GUARD_RETURN(LockType, Guard, m_OutBufferLock, -1);
if (closing_) if (closing_)
return -1; { return -1; }
const size_t send_len = m_OutBuffer->length(); const size_t send_len = m_OutBuffer->length();
@ -361,11 +361,11 @@ int WorldSocket::handle_output(ACE_HANDLE)
#endif // MSG_NOSIGNAL #endif // MSG_NOSIGNAL
if (n == 0) if (n == 0)
return -1; { return -1; }
else if (n == -1) else if (n == -1)
{ {
if (errno == EWOULDBLOCK || errno == EAGAIN) if (errno == EWOULDBLOCK || errno == EAGAIN)
return schedule_wakeup_output(Guard); { return schedule_wakeup_output(Guard); }
return -1; return -1;
} }
@ -458,7 +458,7 @@ int WorldSocket::handle_close(ACE_HANDLE h, ACE_Reactor_Mask)
closing_ = true; closing_ = true;
if (h == ACE_INVALID_HANDLE) if (h == ACE_INVALID_HANDLE)
peer().close_writer(); { peer().close_writer(); }
} }
// Critical section // Critical section
@ -475,10 +475,10 @@ int WorldSocket::handle_close(ACE_HANDLE h, ACE_Reactor_Mask)
int WorldSocket::Update(void) int WorldSocket::Update(void)
{ {
if (closing_) if (closing_)
return -1; { return -1; }
if (m_OutActive || (m_OutBuffer->length() == 0 && msg_queue()->is_empty())) if (m_OutActive || (m_OutBuffer->length() == 0 && msg_queue()->is_empty()))
return 0; { return 0; }
int ret; int ret;
do do
@ -545,7 +545,7 @@ int WorldSocket::handle_input_payload(void)
m_Header.reset(); m_Header.reset();
if (ret == -1) if (ret == -1)
errno = EINVAL; { errno = EINVAL; }
return ret; return ret;
} }
@ -572,7 +572,7 @@ int WorldSocket::handle_input_missing_data(void)
recv_size); recv_size);
if (n <= 0) if (n <= 0)
return (int)n; { return (int)n; }
message_block.wr_ptr(n); message_block.wr_ptr(n);
@ -642,7 +642,7 @@ int WorldSocket::handle_input_missing_data(void)
int WorldSocket::cancel_wakeup_output(GuardType& g) int WorldSocket::cancel_wakeup_output(GuardType& g)
{ {
if (!m_OutActive) if (!m_OutActive)
return 0; { return 0; }
m_OutActive = false; m_OutActive = false;
@ -662,7 +662,7 @@ int WorldSocket::cancel_wakeup_output(GuardType& g)
int WorldSocket::schedule_wakeup_output(GuardType& g) int WorldSocket::schedule_wakeup_output(GuardType& g)
{ {
if (m_OutActive) if (m_OutActive)
return 0; { return 0; }
m_OutActive = true; m_OutActive = true;
@ -688,7 +688,7 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct)
const ACE_UINT16 opcode = new_pct->GetOpcode(); const ACE_UINT16 opcode = new_pct->GetOpcode();
if (closing_) if (closing_)
return -1; { return -1; }
// Dump received packet. // Dump received packet.
sLog.outWorldPacketDump(uint32(get_handle()), new_pct->GetOpcode(), new_pct->GetOpcodeName(), new_pct, true); sLog.outWorldPacketDump(uint32(get_handle()), new_pct->GetOpcode(), new_pct->GetOpcodeName(), new_pct, true);
@ -759,13 +759,13 @@ int WorldSocket::ProcessIncoming(WorldPacket* new_pct)
return -1; return -1;
} }
else else
return 0; { return 0; }
} }
ACE_NOTREACHED(return 0); ACE_NOTREACHED(return 0);
} }
int WorldSocket::HandleAuthSession (WorldPacket& recvPacket) int WorldSocket::HandleAuthSession(WorldPacket& recvPacket)
{ {
// NOTE: ATM the socket is singlethread, have this in mind ... // NOTE: ATM the socket is singlethread, have this in mind ...
uint8 digest[20]; uint8 digest[20];
@ -833,11 +833,11 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
packet.Initialize (SMSG_AUTH_RESPONSE, 2); packet.Initialize (SMSG_AUTH_RESPONSE, 2);
packet.WriteBit(false); packet.WriteBit(false);
packet.WriteBit(false); packet.WriteBit(false);
packet << uint8 (AUTH_VERSION_MISMATCH); packet << uint8(AUTH_VERSION_MISMATCH);
SendPacket (packet); SendPacket(packet);
sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (version mismatch)."); sLog.outError("WorldSocket::HandleAuthSession: Sent Auth Response (version mismatch).");
return -1; return -1;
} }
@ -868,15 +868,15 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
packet.Initialize (SMSG_AUTH_RESPONSE, 2); packet.Initialize (SMSG_AUTH_RESPONSE, 2);
packet.WriteBit(false); packet.WriteBit(false);
packet.WriteBit(false); packet.WriteBit(false);
packet << uint8 (AUTH_UNKNOWN_ACCOUNT); packet << uint8(AUTH_UNKNOWN_ACCOUNT);
SendPacket (packet); SendPacket(packet);
sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (unknown account)."); sLog.outError("WorldSocket::HandleAuthSession: Sent Auth Response (unknown account).");
return -1; return -1;
} }
Field* fields = result->Fetch (); Field* fields = result->Fetch();
expansion = ((sWorld.getConfig(CONFIG_UINT32_EXPANSION) > fields[7].GetUInt8()) ? fields[7].GetUInt8() : sWorld.getConfig(CONFIG_UINT32_EXPANSION)); expansion = ((sWorld.getConfig(CONFIG_UINT32_EXPANSION) > fields[7].GetUInt8()) ? fields[7].GetUInt8() : sWorld.getConfig(CONFIG_UINT32_EXPANSION));
@ -887,26 +887,26 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
s.SetHexStr(fields[6].GetString()); s.SetHexStr(fields[6].GetString());
m_s = s; m_s = s;
const char* sStr = s.AsHexStr (); //Must be freed by OPENSSL_free() const char* sStr = s.AsHexStr(); // Must be freed by OPENSSL_free()
const char* vStr = v.AsHexStr (); //Must be freed by OPENSSL_free() const char* vStr = v.AsHexStr(); // Must be freed by OPENSSL_free()
DEBUG_LOG ("WorldSocket::HandleAuthSession: (s,v) check s: %s v: %s", DEBUG_LOG("WorldSocket::HandleAuthSession: (s,v) check s: %s v: %s",
sStr, sStr,
vStr); vStr);
OPENSSL_free ((void*) sStr); OPENSSL_free((void*) sStr);
OPENSSL_free ((void*) vStr); OPENSSL_free((void*) vStr);
///- Re-check ip locking (same check as in realmd). ///- Re-check ip locking (same check as in realmd).
if (fields[4].GetUInt8 () == 1) // if ip is locked if (fields[4].GetUInt8() == 1) // if ip is locked
{ {
if (strcmp (fields[3].GetString(), GetRemoteAddress().c_str())) if (strcmp(fields[3].GetString(), GetRemoteAddress().c_str()))
{ {
packet.Initialize (SMSG_AUTH_RESPONSE, 2); packet.Initialize (SMSG_AUTH_RESPONSE, 2);
packet.WriteBit(false); packet.WriteBit(false);
packet.WriteBit(false); packet.WriteBit(false);
packet << uint8 (AUTH_FAILED); packet << uint8(AUTH_FAILED);
SendPacket (packet); SendPacket(packet);
delete result; delete result;
BASIC_LOG("WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs)."); BASIC_LOG("WorldSocket::HandleAuthSession: Sent Auth Response (Account IP differs).");
@ -916,22 +916,22 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
id = fields[0].GetUInt32(); id = fields[0].GetUInt32();
security = fields[1].GetUInt16(); security = fields[1].GetUInt16();
if(security > SEC_ADMINISTRATOR) // prevent invalid security settings in DB if (security > SEC_ADMINISTRATOR) // prevent invalid security settings in DB
security = SEC_ADMINISTRATOR; { security = SEC_ADMINISTRATOR; }
K.SetHexStr (fields[2].GetString()); K.SetHexStr(fields[2].GetString());
time_t mutetime = time_t (fields[8].GetUInt64()); time_t mutetime = time_t (fields[8].GetUInt64());
locale = LocaleConstant (fields[9].GetUInt8()); locale = LocaleConstant(fields[9].GetUInt8());
if (locale >= MAX_LOCALE) if (locale >= MAX_LOCALE)
locale = LOCALE_enUS; { locale = LOCALE_enUS; }
delete result; delete result;
// Re-check account ban (same check as in realmd) // Re-check account ban (same check as in realmd)
QueryResult *banresult = QueryResult* banresult =
LoginDatabase.PQuery ("SELECT 1 FROM account_banned WHERE id = %u AND active = 1 AND (unbandate > UNIX_TIMESTAMP() OR unbandate = bandate)" LoginDatabase.PQuery("SELECT 1 FROM account_banned WHERE id = %u AND active = 1 AND (unbandate > UNIX_TIMESTAMP() OR unbandate = bandate)"
"UNION " "UNION "
"SELECT 1 FROM ip_banned WHERE (unbandate = bandate OR unbandate > UNIX_TIMESTAMP()) AND ip = '%s'", "SELECT 1 FROM ip_banned WHERE (unbandate = bandate OR unbandate > UNIX_TIMESTAMP()) AND ip = '%s'",
id, GetRemoteAddress().c_str()); id, GetRemoteAddress().c_str());
@ -941,8 +941,8 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
packet.Initialize (SMSG_AUTH_RESPONSE, 2); packet.Initialize (SMSG_AUTH_RESPONSE, 2);
packet.WriteBit(false); packet.WriteBit(false);
packet.WriteBit(false); packet.WriteBit(false);
packet << uint8 (AUTH_BANNED); packet << uint8(AUTH_BANNED);
SendPacket (packet); SendPacket(packet);
delete banresult; delete banresult;
@ -958,9 +958,9 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
WorldPacket Packet (SMSG_AUTH_RESPONSE, 2); WorldPacket Packet (SMSG_AUTH_RESPONSE, 2);
packet.WriteBit(false); packet.WriteBit(false);
packet.WriteBit(false); packet.WriteBit(false);
Packet << uint8 (AUTH_UNAVAILABLE); Packet << uint8(AUTH_UNAVAILABLE);
SendPacket (packet); SendPacket(packet);
BASIC_LOG("WorldSocket::HandleAuthSession: User tries to login but his security level is not enough"); BASIC_LOG("WorldSocket::HandleAuthSession: User tries to login but his security level is not enough");
return -1; return -1;
@ -973,30 +973,30 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
uint32 seed = m_Seed; uint32 seed = m_Seed;
sha.UpdateData (accountName); sha.UpdateData (accountName);
sha.UpdateData ((uint8 *) & t, 4); sha.UpdateData((uint8*) & t, 4);
sha.UpdateData ((uint8 *) & clientSeed, 4); sha.UpdateData((uint8*) & clientSeed, 4);
sha.UpdateData ((uint8 *) & seed, 4); sha.UpdateData((uint8*) & seed, 4);
sha.UpdateBigNumbers (&K, NULL); sha.UpdateBigNumbers(&K, NULL);
sha.Finalize (); sha.Finalize();
if (memcmp (sha.GetDigest (), digest, 20)) if (memcmp(sha.GetDigest(), digest, 20))
{ {
packet.Initialize (SMSG_AUTH_RESPONSE, 2); packet.Initialize (SMSG_AUTH_RESPONSE, 2);
packet.WriteBit(false); packet.WriteBit(false);
packet.WriteBit(false); packet.WriteBit(false);
packet << uint8 (AUTH_FAILED); packet << uint8(AUTH_FAILED);
SendPacket (packet); SendPacket(packet);
sLog.outError ("WorldSocket::HandleAuthSession: Sent Auth Response (authentification failed)."); sLog.outError("WorldSocket::HandleAuthSession: Sent Auth Response (authentification failed).");
return -1; return -1;
} }
std::string address = GetRemoteAddress (); std::string address = GetRemoteAddress();
DEBUG_LOG ("WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.", DEBUG_LOG("WorldSocket::HandleAuthSession: Client '%s' authenticated successfully from %s.",
accountName.c_str (), accountName.c_str (),
address.c_str ()); address.c_str());
// Update the last_ip in the database // Update the last_ip in the database
// No SQL injection, username escaped. // No SQL injection, username escaped.
@ -1006,7 +1006,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
stmt.PExecute(address.c_str(), accountName.c_str()); stmt.PExecute(address.c_str(), accountName.c_str());
// NOTE ATM the socket is single-threaded, have this in mind ... // NOTE ATM the socket is single-threaded, have this in mind ...
ACE_NEW_RETURN (m_Session, WorldSession (id, this, AccountTypes(security), expansion, mutetime, locale), -1); ACE_NEW_RETURN(m_Session, WorldSession(id, this, AccountTypes(security), expansion, mutetime, locale), -1);
m_Crypt.Init(&K); m_Crypt.Init(&K);
@ -1017,7 +1017,7 @@ int WorldSocket::HandleAuthSession (WorldPacket& recvPacket)
// In case needed sometime the second arg is in microseconds 1 000 000 = 1 sec // In case needed sometime the second arg is in microseconds 1 000 000 = 1 sec
ACE_OS::sleep (ACE_Time_Value (0, 10000)); ACE_OS::sleep (ACE_Time_Value (0, 10000));
sWorld.AddSession (m_Session); sWorld.AddSession(m_Session);
return 0; return 0;
} }
@ -1032,7 +1032,7 @@ int WorldSocket::HandlePing(WorldPacket& recvPacket)
recvPacket >> latency; recvPacket >> latency;
if (m_LastPingTime == ACE_Time_Value::zero) if (m_LastPingTime == ACE_Time_Value::zero)
m_LastPingTime = ACE_OS::gettimeofday(); // for 1st ping { m_LastPingTime = ACE_OS::gettimeofday(); } // for 1st ping
else else
{ {
ACE_Time_Value cur_time = ACE_OS::gettimeofday(); ACE_Time_Value cur_time = ACE_OS::gettimeofday();
@ -1061,7 +1061,7 @@ int WorldSocket::HandlePing(WorldPacket& recvPacket)
} }
} }
else else
m_OverSpeedPings = 0; { m_OverSpeedPings = 0; }
} }
// critical section // critical section

View file

@ -29,7 +29,6 @@
*/ */
#ifndef MANGOS_H_WORLDSOCKETMGR #ifndef MANGOS_H_WORLDSOCKETMGR
#define MANGOS_H_WORLDSOCKETMGR #define MANGOS_H_WORLDSOCKETMGR
#include <ace/Basic_Types.h> #include <ace/Basic_Types.h>

View file

@ -33,14 +33,14 @@ void CharacterDatabaseCleaner::CleanDatabase()
{ {
// config to disable // config to disable
if (!sWorld.getConfig(CONFIG_BOOL_CLEAN_CHARACTER_DB)) if (!sWorld.getConfig(CONFIG_BOOL_CLEAN_CHARACTER_DB))
return; { return; }
sLog.outString("Cleaning character database..."); sLog.outString("Cleaning character database...");
// check flags which clean ups are necessary // check flags which clean ups are necessary
QueryResult* result = CharacterDatabase.PQuery("SELECT cleaning_flags FROM saved_variables"); QueryResult* result = CharacterDatabase.PQuery("SELECT cleaning_flags FROM saved_variables");
if (!result) if (!result)
return; { return; }
uint32 flags = (*result)[0].GetUInt32(); uint32 flags = (*result)[0].GetUInt32();
delete result; delete result;
@ -48,9 +48,9 @@ void CharacterDatabaseCleaner::CleanDatabase()
if (flags & CLEANING_FLAG_ACHIEVEMENT_PROGRESS) if (flags & CLEANING_FLAG_ACHIEVEMENT_PROGRESS)
CleanCharacterAchievementProgress(); CleanCharacterAchievementProgress();
if (flags & CLEANING_FLAG_SKILLS) if (flags & CLEANING_FLAG_SKILLS)
CleanCharacterSkills(); { CleanCharacterSkills(); }
if (flags & CLEANING_FLAG_SPELLS) if (flags & CLEANING_FLAG_SPELLS)
CleanCharacterSpell(); { CleanCharacterSpell(); }
if (flags & CLEANING_FLAG_TALENTS) if (flags & CLEANING_FLAG_TALENTS)
CleanCharacterTalent(); CleanCharacterTalent();
CharacterDatabase.Execute("UPDATE saved_variables SET cleaning_flags = 0"); CharacterDatabase.Execute("UPDATE saved_variables SET cleaning_flags = 0");
@ -84,7 +84,7 @@ void CharacterDatabaseCleaner::CheckUnique(const char* column, const char* table
found = true; found = true;
} }
else else
ss << ","; { ss << ","; }
ss << id; ss << id;
} }
} }

View file

@ -1037,5 +1037,4 @@ enum MangosStrings
// `db_script_string` table index 2000000000-2000999999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID) // `db_script_string` table index 2000000000-2000999999 (MIN_DB_SCRIPT_STRING_ID-MAX_DB_SCRIPT_STRING_ID)
// For other tables maybe 2001000000-2147483647 (max index) // For other tables maybe 2001000000-2147483647 (max index)
}; };
#endif #endif

View file

@ -78,9 +78,9 @@ static bool findtoknth(std::string& str, int n, std::string::size_type& s, std::
{ {
int i; s = e = 0; int i; s = e = 0;
std::string::size_type size = str.size(); std::string::size_type size = str.size();
for (i = 1; s < size && i < n; ++s) if (str[s] == ' ') ++i; for (i = 1; s < size && i < n; ++s) if (str[s] == ' ') { ++i; }
if (i < n) if (i < n)
return false; { return false; }
e = str.find(' ', s); e = str.find(' ', s);
@ -91,7 +91,7 @@ std::string gettoknth(std::string& str, int n)
{ {
std::string::size_type s = 0, e = 0; std::string::size_type s = 0, e = 0;
if (!findtoknth(str, n, s, e)) if (!findtoknth(str, n, s, e))
return ""; { return ""; }
return str.substr(s, e - s); return str.substr(s, e - s);
} }
@ -100,13 +100,13 @@ bool findnth(std::string& str, int n, std::string::size_type& s, std::string::si
{ {
s = str.find("VALUES ('") + 9; s = str.find("VALUES ('") + 9;
if (s == std::string::npos) if (s == std::string::npos)
return false; { return false; }
do do
{ {
e = str.find("'", s); e = str.find("'", s);
if (e == std::string::npos) if (e == std::string::npos)
return false; { return false; }
} }
while (str[e - 1] == '\\'); while (str[e - 1] == '\\');
@ -117,7 +117,7 @@ bool findnth(std::string& str, int n, std::string::size_type& s, std::string::si
s = e + 4; s = e + 4;
e = str.find("'", s); e = str.find("'", s);
if (e == std::string::npos) if (e == std::string::npos)
return false; { return false; }
} }
while (str[e - 1] == '\\'); while (str[e - 1] == '\\');
} }
@ -129,7 +129,7 @@ std::string gettablename(std::string& str)
std::string::size_type s = 13; std::string::size_type s = 13;
std::string::size_type e = str.find(_TABLE_SIM_, s); std::string::size_type e = str.find(_TABLE_SIM_, s);
if (e == std::string::npos) if (e == std::string::npos)
return ""; { return ""; }
return str.substr(s, e - s); return str.substr(s, e - s);
} }
@ -138,14 +138,14 @@ bool changenth(std::string& str, int n, const char* with, bool insert = false, b
{ {
std::string::size_type s, e; std::string::size_type s, e;
if (!findnth(str, n, s, e)) if (!findnth(str, n, s, e))
return false; { return false; }
if (nonzero && str.substr(s, e - s) == "0") if (nonzero && str.substr(s, e - s) == "0")
return true; // not an error { return true; } // not an error
if (!insert) if (!insert)
str.replace(s, e - s, with); { str.replace(s, e - s, with); }
else else
str.insert(s, with); { str.insert(s, with); }
return true; return true;
} }
@ -154,7 +154,7 @@ std::string getnth(std::string& str, int n)
{ {
std::string::size_type s, e; std::string::size_type s, e;
if (!findnth(str, n, s, e)) if (!findnth(str, n, s, e))
return ""; { return ""; }
return str.substr(s, e - s); return str.substr(s, e - s);
} }
@ -163,13 +163,13 @@ bool changetoknth(std::string& str, int n, const char* with, bool insert = false
{ {
std::string::size_type s = 0, e = 0; std::string::size_type s = 0, e = 0;
if (!findtoknth(str, n, s, e)) if (!findtoknth(str, n, s, e))
return false; { return false; }
if (nonzero && str.substr(s, e - s) == "0") if (nonzero && str.substr(s, e - s) == "0")
return true; // not an error { return true; } // not an error
if (!insert) if (!insert)
str.replace(s, e - s, with); { str.replace(s, e - s, with); }
else else
str.insert(s, with); { str.insert(s, with); }
return true; return true;
} }
@ -178,7 +178,7 @@ uint32 registerNewGuid(uint32 oldGuid, std::map<uint32, uint32>& guidMap, uint32
{ {
std::map<uint32, uint32>::const_iterator itr = guidMap.find(oldGuid); std::map<uint32, uint32>::const_iterator itr = guidMap.find(oldGuid);
if (itr != guidMap.end()) if (itr != guidMap.end())
return itr->second; { return itr->second; }
uint32 newguid = hiGuid + guidMap.size(); uint32 newguid = hiGuid + guidMap.size();
guidMap[oldGuid] = newguid; guidMap[oldGuid] = newguid;
@ -190,7 +190,7 @@ bool changeGuid(std::string& str, int n, std::map<uint32, uint32>& guidMap, uint
char chritem[20]; char chritem[20];
uint32 oldGuid = atoi(getnth(str, n).c_str()); uint32 oldGuid = atoi(getnth(str, n).c_str());
if (nonzero && oldGuid == 0) if (nonzero && oldGuid == 0)
return true; // not an error { return true; } // not an error
uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid); uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid);
snprintf(chritem, 20, "%u", newGuid); snprintf(chritem, 20, "%u", newGuid);
@ -203,7 +203,7 @@ bool changetokGuid(std::string& str, int n, std::map<uint32, uint32>& guidMap, u
char chritem[20]; char chritem[20];
uint32 oldGuid = atoi(gettoknth(str, n).c_str()); uint32 oldGuid = atoi(gettoknth(str, n).c_str());
if (nonzero && oldGuid == 0) if (nonzero && oldGuid == 0)
return true; // not an error { return true; } // not an error
uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid); uint32 newGuid = registerNewGuid(oldGuid, guidMap, hiGuid);
snprintf(chritem, 20, "%u", newGuid); snprintf(chritem, 20, "%u", newGuid);
@ -214,7 +214,7 @@ bool changetokGuid(std::string& str, int n, std::map<uint32, uint32>& guidMap, u
std::string CreateDumpString(char const* tableName, QueryResult* result) std::string CreateDumpString(char const* tableName, QueryResult* result)
{ {
if (!tableName || !result) if (!tableName || !result)
return ""; { return ""; }
std::ostringstream ss; std::ostringstream ss;
ss << "INSERT INTO " << _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES ("; ss << "INSERT INTO " << _TABLE_SIM_ << tableName << _TABLE_SIM_ << " VALUES (";
@ -222,10 +222,10 @@ std::string CreateDumpString(char const* tableName, QueryResult* result)
for (uint32 i = 0; i < result->GetFieldCount(); ++i) for (uint32 i = 0; i < result->GetFieldCount(); ++i)
{ {
if (i != 0) if (i != 0)
ss << ", "; { ss << ", "; }
if (fields[i].IsNULL()) if (fields[i].IsNULL())
ss << "NULL"; { ss << "NULL"; }
else else
{ {
std::string s = fields[i].GetCppString(); std::string s = fields[i].GetCppString();
@ -261,7 +261,7 @@ std::string PlayerDumpWriter::GenerateWhereStr(char const* field, GUIDs const& g
GUIDs::const_iterator itr2 = itr; GUIDs::const_iterator itr2 = itr;
if (++itr2 != guids.end()) if (++itr2 != guids.end())
wherestr << "','"; { wherestr << "','"; }
} }
wherestr << "')"; wherestr << "')";
return wherestr.str(); return wherestr.str();
@ -272,7 +272,7 @@ void StoreGUID(QueryResult* result, uint32 field, std::set<uint32>& guids)
Field* fields = result->Fetch(); Field* fields = result->Fetch();
uint32 guid = fields[field].GetUInt32(); uint32 guid = fields[field].GetUInt32();
if (guid) if (guid)
guids.insert(guid); { guids.insert(guid); }
} }
void StoreGUID(QueryResult* result, uint32 data, uint32 field, std::set<uint32>& guids) void StoreGUID(QueryResult* result, uint32 data, uint32 field, std::set<uint32>& guids)
@ -281,7 +281,7 @@ void StoreGUID(QueryResult* result, uint32 data, uint32 field, std::set<uint32>&
std::string dataStr = fields[data].GetCppString(); std::string dataStr = fields[data].GetCppString();
uint32 guid = atoi(gettoknth(dataStr, field).c_str()); uint32 guid = atoi(gettoknth(dataStr, field).c_str());
if (guid) if (guid)
guids.insert(guid); { guids.insert(guid); }
} }
// Writing - High-level functions // Writing - High-level functions
@ -305,25 +305,25 @@ void PlayerDumpWriter::DumpTableContent(std::string& dump, uint32 guid, char con
// for guid set stop if set is empty // for guid set stop if set is empty
if (guids && guids->empty()) if (guids && guids->empty())
return; // nothing to do { return; } // nothing to do
// setup for guids case start position // setup for guids case start position
GUIDs::const_iterator guids_itr; GUIDs::const_iterator guids_itr;
if (guids) if (guids)
guids_itr = guids->begin(); { guids_itr = guids->begin(); }
do do
{ {
std::string wherestr; std::string wherestr;
if (guids) // set case, get next guids string if (guids) // set case, get next guids string
wherestr = GenerateWhereStr(fieldname, *guids, guids_itr); { wherestr = GenerateWhereStr(fieldname, *guids, guids_itr); }
else // not set case, get single guid string else // not set case, get single guid string
wherestr = GenerateWhereStr(fieldname, guid); { wherestr = GenerateWhereStr(fieldname, guid); }
QueryResult* result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str()); QueryResult* result = CharacterDatabase.PQuery("SELECT * FROM %s WHERE %s", tableFrom, wherestr.c_str());
if (!result) if (!result)
return; { return; }
do do
{ {
@ -379,15 +379,15 @@ std::string PlayerDumpWriter::GetDump(uint32 guid)
dump += "UPDATE character_db_version SET " + reqName + " = 1 WHERE FALSE;\n\n"; dump += "UPDATE character_db_version SET " + reqName + " = 1 WHERE FALSE;\n\n";
} }
else else
sLog.outError("Table 'character_db_version' not have revision guard field, revision guard query not added to pdump."); { sLog.outError("Table 'character_db_version' not have revision guard field, revision guard query not added to pdump."); }
delete result; delete result;
} }
else else
sLog.outError("Character DB not have 'character_db_version' table, revision guard query not added to pdump."); { sLog.outError("Character DB not have 'character_db_version' table, revision guard query not added to pdump."); }
for (DumpTable* itr = &dumpTables[0]; itr->isValid(); ++itr) for (DumpTable* itr = &dumpTables[0]; itr->isValid(); ++itr)
DumpTableContent(dump, guid, itr->name, itr->name, itr->type); { DumpTableContent(dump, guid, itr->name, itr->name, itr->type); }
// TODO: Add instance/group.. // TODO: Add instance/group..
// TODO: Add a dump level option to skip some non-important tables // TODO: Add a dump level option to skip some non-important tables
@ -399,7 +399,7 @@ DumpReturn PlayerDumpWriter::WriteDump(const std::string& file, uint32 guid)
{ {
FILE* fout = fopen(file.c_str(), "w"); FILE* fout = fopen(file.c_str(), "w");
if (!fout) if (!fout)
return DUMP_FILE_OPEN_ERROR; { return DUMP_FILE_OPEN_ERROR; }
std::string dump = GetDump(guid); std::string dump = GetDump(guid);
@ -418,11 +418,11 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
// check character count // check character count
uint32 charcount = sAccountMgr.GetCharactersCount(account); uint32 charcount = sAccountMgr.GetCharactersCount(account);
if (charcount >= 10) if (charcount >= 10)
return DUMP_TOO_MANY_CHARS; { return DUMP_TOO_MANY_CHARS; }
FILE* fin = fopen(file.c_str(), "r"); FILE* fin = fopen(file.c_str(), "r");
if (!fin) if (!fin)
return DUMP_FILE_OPEN_ERROR; { return DUMP_FILE_OPEN_ERROR; }
QueryResult* result = NULL; QueryResult* result = NULL;
char newguid[20], chraccount[20], newpetid[20], currpetid[20], lastpetid[20]; char newguid[20], chraccount[20], newpetid[20], currpetid[20], lastpetid[20];
@ -437,10 +437,10 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
guid = sObjectMgr.m_CharGuids.GetNextAfterMaxUsed(); guid = sObjectMgr.m_CharGuids.GetNextAfterMaxUsed();
delete result; delete result;
} }
else incHighest = false; else { incHighest = false; }
} }
else else
guid = sObjectMgr.m_CharGuids.GetNextAfterMaxUsed(); { guid = sObjectMgr.m_CharGuids.GetNextAfterMaxUsed(); }
// normalize the name if specified and check if it exists // normalize the name if specified and check if it exists
if (!normalizePlayerName(name)) if (!normalizePlayerName(name))
@ -480,7 +480,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
{ {
if (!fgets(buf, 32000, fin)) if (!fgets(buf, 32000, fin))
{ {
if (feof(fin)) break; if (feof(fin)) { break; }
ROLLBACK(DUMP_FILE_BROKEN); ROLLBACK(DUMP_FILE_BROKEN);
} }
@ -489,17 +489,17 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
// skip empty strings // skip empty strings
size_t nw_pos = line.find_first_not_of(" \t\n\r\7"); size_t nw_pos = line.find_first_not_of(" \t\n\r\7");
if (nw_pos == std::string::npos) if (nw_pos == std::string::npos)
continue; { continue; }
// skip NOTE // skip NOTE
if (line.substr(nw_pos, 15) == "IMPORTANT NOTE:") if (line.substr(nw_pos, 15) == "IMPORTANT NOTE:")
continue; { continue; }
// add required_ check // add required_ check
if (line.substr(nw_pos, 41) == "UPDATE character_db_version SET required_") if (line.substr(nw_pos, 41) == "UPDATE character_db_version SET required_")
{ {
if (!CharacterDatabase.Execute(line.c_str())) if (!CharacterDatabase.Execute(line.c_str()))
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
continue; continue;
} }
@ -536,7 +536,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
{ {
case DTT_CHAR_TABLE: case DTT_CHAR_TABLE:
if (!changenth(line, 1, newguid)) // character_*.guid update if (!changenth(line, 1, newguid)) // character_*.guid update
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
break; break;
case DTT_CHAR_NAME_TABLE: case DTT_CHAR_NAME_TABLE:
@ -553,10 +553,10 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
case DTT_CHARACTER: case DTT_CHARACTER:
{ {
if (!changenth(line, 1, newguid)) // characters.guid update if (!changenth(line, 1, newguid)) // characters.guid update
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
if (!changenth(line, 2, chraccount)) // characters.account update if (!changenth(line, 2, chraccount)) // characters.account update
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
if (name.empty()) if (name.empty())
{ {
@ -570,7 +570,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
delete result; delete result;
if (!changenth(line, 36, "1")) // characters.at_login set to "rename on login" if (!changenth(line, 36, "1")) // characters.at_login set to "rename on login"
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
nameInvalidated = true; nameInvalidated = true;
} }
@ -578,7 +578,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
else else
{ {
if (!changenth(line, 3, name.c_str())) // characters.name update if (!changenth(line, 3, name.c_str())) // characters.name update
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
nameInvalidated = true; nameInvalidated = true;
} }
@ -588,45 +588,45 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
case DTT_INVENTORY: case DTT_INVENTORY:
{ {
if (!changenth(line, 1, newguid)) // character_inventory.guid update if (!changenth(line, 1, newguid)) // character_inventory.guid update
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
if (!changeGuid(line, 2, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed(), true)) if (!changeGuid(line, 2, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed(), true))
ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.bag update { ROLLBACK(DUMP_FILE_BROKEN); } // character_inventory.bag update
if (!changeGuid(line, 4, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) if (!changeGuid(line, 4, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed()))
ROLLBACK(DUMP_FILE_BROKEN); // character_inventory.item update { ROLLBACK(DUMP_FILE_BROKEN); } // character_inventory.item update
break; break;
} }
case DTT_ITEM: case DTT_ITEM:
{ {
// item, owner, data field:item, owner guid // item, owner, data field:item, owner guid
if (!changeGuid(line, 1, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) if (!changeGuid(line, 1, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed()))
ROLLBACK(DUMP_FILE_BROKEN); // item_instance.guid update { ROLLBACK(DUMP_FILE_BROKEN); } // item_instance.guid update
if (!changenth(line, 2, newguid)) // item_instance.owner_guid update if (!changenth(line, 2, newguid)) // item_instance.owner_guid update
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
std::string vals = getnth(line, 3); // item_instance.data get std::string vals = getnth(line, 3); // item_instance.data get
if (!changetokGuid(vals, OBJECT_FIELD_GUID + 1, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) if (!changetokGuid(vals, OBJECT_FIELD_GUID + 1, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed()))
ROLLBACK(DUMP_FILE_BROKEN); // item_instance.data.OBJECT_FIELD_GUID update { ROLLBACK(DUMP_FILE_BROKEN); } // item_instance.data.OBJECT_FIELD_GUID update
if (!changetoknth(vals, ITEM_FIELD_OWNER + 1, newguid)) if (!changetoknth(vals, ITEM_FIELD_OWNER + 1, newguid))
ROLLBACK(DUMP_FILE_BROKEN); // item_instance.data.ITEM_FIELD_OWNER update { ROLLBACK(DUMP_FILE_BROKEN); } // item_instance.data.ITEM_FIELD_OWNER update
if (!changenth(line, 3, vals.c_str())) // item_instance.data update if (!changenth(line, 3, vals.c_str())) // item_instance.data update
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
break; break;
} }
case DTT_ITEM_GIFT: case DTT_ITEM_GIFT:
{ {
if (!changenth(line, 1, newguid)) // character_gifts.guid update if (!changenth(line, 1, newguid)) // character_gifts.guid update
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
if (!changeGuid(line, 2, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) if (!changeGuid(line, 2, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed()))
ROLLBACK(DUMP_FILE_BROKEN); // character_gifts.item_guid update { ROLLBACK(DUMP_FILE_BROKEN); } // character_gifts.item_guid update
break; break;
} }
case DTT_ITEM_LOOT: case DTT_ITEM_LOOT:
{ {
// item, owner // item, owner
if (!changeGuid(line, 1, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) if (!changeGuid(line, 1, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed()))
ROLLBACK(DUMP_FILE_BROKEN); // item_loot.guid update { ROLLBACK(DUMP_FILE_BROKEN); } // item_loot.guid update
if (!changenth(line, 2, newguid)) // item_Loot.owner_guid update if (!changenth(line, 2, newguid)) // item_Loot.owner_guid update
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
break; break;
} }
case DTT_PET: case DTT_PET:
@ -634,7 +634,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
// store a map of old pet id to new inserted pet id for use by type 5 tables // store a map of old pet id to new inserted pet id for use by type 5 tables
snprintf(currpetid, 20, "%s", getnth(line, 1).c_str()); snprintf(currpetid, 20, "%s", getnth(line, 1).c_str());
if (strlen(lastpetid) == 0) if (strlen(lastpetid) == 0)
snprintf(lastpetid, 20, "%s", currpetid); { snprintf(lastpetid, 20, "%s", currpetid); }
if (strcmp(lastpetid, currpetid) != 0) if (strcmp(lastpetid, currpetid) != 0)
{ {
@ -650,9 +650,9 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
} }
if (!changenth(line, 1, newpetid)) // character_pet.id update if (!changenth(line, 1, newpetid)) // character_pet.id update
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
if (!changenth(line, 3, newguid)) // character_pet.owner update if (!changenth(line, 3, newguid)) // character_pet.owner update
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
break; break;
} }
@ -663,12 +663,12 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
// lookup currpetid and match to new inserted pet id // lookup currpetid and match to new inserted pet id
std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid)); std::map<uint32, uint32> :: const_iterator petids_iter = petids.find(atoi(currpetid));
if (petids_iter == petids.end()) // couldn't find new inserted id if (petids_iter == petids.end()) // couldn't find new inserted id
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
snprintf(newpetid, 20, "%d", petids_iter->second); snprintf(newpetid, 20, "%d", petids_iter->second);
if (!changenth(line, 1, newpetid)) // pet_*.guid -> petid in fact if (!changenth(line, 1, newpetid)) // pet_*.guid -> petid in fact
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
break; break;
} }
@ -694,19 +694,19 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
case DTT_MAIL: // mail case DTT_MAIL: // mail
{ {
if (!changeGuid(line, 1, mails, sObjectMgr.m_MailIds.GetNextAfterMaxUsed())) if (!changeGuid(line, 1, mails, sObjectMgr.m_MailIds.GetNextAfterMaxUsed()))
ROLLBACK(DUMP_FILE_BROKEN); // mail.id update { ROLLBACK(DUMP_FILE_BROKEN); } // mail.id update
if (!changenth(line, 6, newguid)) // mail.receiver update if (!changenth(line, 6, newguid)) // mail.receiver update
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
break; break;
} }
case DTT_MAIL_ITEM: // mail_items case DTT_MAIL_ITEM: // mail_items
{ {
if (!changeGuid(line, 1, mails, sObjectMgr.m_MailIds.GetNextAfterMaxUsed())) if (!changeGuid(line, 1, mails, sObjectMgr.m_MailIds.GetNextAfterMaxUsed()))
ROLLBACK(DUMP_FILE_BROKEN); // mail_items.id { ROLLBACK(DUMP_FILE_BROKEN); } // mail_items.id
if (!changeGuid(line, 2, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed())) if (!changeGuid(line, 2, items, sObjectMgr.m_ItemGuids.GetNextAfterMaxUsed()))
ROLLBACK(DUMP_FILE_BROKEN); // mail_items.item_guid { ROLLBACK(DUMP_FILE_BROKEN); } // mail_items.item_guid
if (!changenth(line, 4, newguid)) // mail_items.receiver if (!changenth(line, 4, newguid)) // mail_items.receiver
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
break; break;
} }
case DTT_EQSET_TABLE: case DTT_EQSET_TABLE:
@ -726,7 +726,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
} }
if (execute_ok && !CharacterDatabase.Execute(line.c_str())) if (execute_ok && !CharacterDatabase.Execute(line.c_str()))
ROLLBACK(DUMP_FILE_BROKEN); { ROLLBACK(DUMP_FILE_BROKEN); }
} }
CharacterDatabase.CommitTransaction(); CharacterDatabase.CommitTransaction();
@ -737,7 +737,7 @@ DumpReturn PlayerDumpReader::LoadDump(const std::string& file, uint32 account, s
sObjectMgr.m_EquipmentSetIds.Set(sObjectMgr.m_EquipmentSetIds.GetNextAfterMaxUsed() + eqsets.size()); sObjectMgr.m_EquipmentSetIds.Set(sObjectMgr.m_EquipmentSetIds.GetNextAfterMaxUsed() + eqsets.size());
if (incHighest) if (incHighest)
sObjectMgr.m_CharGuids.Set(sObjectMgr.m_CharGuids.GetNextAfterMaxUsed() + 1); { sObjectMgr.m_CharGuids.Set(sObjectMgr.m_CharGuids.GetNextAfterMaxUsed() + 1); }
fclose(fin); fclose(fin);

View file

@ -44,18 +44,18 @@ AccountMgr::~AccountMgr()
AccountOpResult AccountMgr::CreateAccount(std::string username, std::string password) AccountOpResult AccountMgr::CreateAccount(std::string username, std::string password)
{ {
if (utf8length(username) > MAX_ACCOUNT_STR) if (utf8length(username) > MAX_ACCOUNT_STR)
return AOR_NAME_TOO_LONG; // username's too long { return AOR_NAME_TOO_LONG; } // username's too long
normalizeString(username); normalizeString(username);
normalizeString(password); normalizeString(password);
if (GetId(username)) if (GetId(username))
{ {
return AOR_NAME_ALREADY_EXIST; // username does already exist { return AOR_NAME_ALREADY_EXIST; } // username does already exist
} }
if (!LoginDatabase.PExecute("INSERT INTO account(username,sha_pass_hash,joindate) VALUES('%s','%s',NOW())", username.c_str(), CalculateShaPassHash(username, password).c_str())) if (!LoginDatabase.PExecute("INSERT INTO account(username,sha_pass_hash,joindate) VALUES('%s','%s',NOW())", username.c_str(), CalculateShaPassHash(username, password).c_str()))
return AOR_DB_INTERNAL_ERROR; // unexpected error { return AOR_DB_INTERNAL_ERROR; } // unexpected error
LoginDatabase.Execute("INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist,account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL"); LoginDatabase.Execute("INSERT INTO realmcharacters (realmid, acctid, numchars) SELECT realmlist.id, account.id, 0 FROM realmlist,account LEFT JOIN realmcharacters ON acctid=account.id WHERE acctid IS NULL");
return AOR_OK; // everything's fine return AOR_OK; // everything's fine
@ -85,7 +85,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
{ {
QueryResult* result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%u'", accid); QueryResult* result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%u'", accid);
if (!result) if (!result)
return AOR_NAME_NOT_EXIST; // account doesn't exist { return AOR_NAME_NOT_EXIST; } // account doesn't exist
delete result; delete result;
// existing characters list // existing characters list
@ -119,7 +119,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accid)
LoginDatabase.CommitTransaction(); LoginDatabase.CommitTransaction();
if (!res) if (!res)
return AOR_DB_INTERNAL_ERROR; // unexpected error; { return AOR_DB_INTERNAL_ERROR; } // unexpected error;
return AOR_OK; return AOR_OK;
} }
@ -128,14 +128,14 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname,
{ {
QueryResult* result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%u'", accid); QueryResult* result = LoginDatabase.PQuery("SELECT 1 FROM account WHERE id='%u'", accid);
if (!result) if (!result)
return AOR_NAME_NOT_EXIST; // account doesn't exist { return AOR_NAME_NOT_EXIST; } // account doesn't exist
delete result; delete result;
if (utf8length(new_uname) > MAX_ACCOUNT_STR) if (utf8length(new_uname) > MAX_ACCOUNT_STR)
return AOR_NAME_TOO_LONG; { return AOR_NAME_TOO_LONG; }
if (utf8length(new_passwd) > MAX_ACCOUNT_STR) if (utf8length(new_passwd) > MAX_ACCOUNT_STR)
return AOR_PASS_TOO_LONG; { return AOR_PASS_TOO_LONG; }
normalizeString(new_uname); normalizeString(new_uname);
normalizeString(new_passwd); normalizeString(new_passwd);
@ -145,7 +145,7 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname,
if (!LoginDatabase.PExecute("UPDATE account SET v='0',s='0',username='%s',sha_pass_hash='%s' WHERE id='%u'", safe_new_uname.c_str(), if (!LoginDatabase.PExecute("UPDATE account SET v='0',s='0',username='%s',sha_pass_hash='%s' WHERE id='%u'", safe_new_uname.c_str(),
CalculateShaPassHash(new_uname, new_passwd).c_str(), accid)) CalculateShaPassHash(new_uname, new_passwd).c_str(), accid))
return AOR_DB_INTERNAL_ERROR; // unexpected error { return AOR_DB_INTERNAL_ERROR; } // unexpected error
return AOR_OK; return AOR_OK;
} }
@ -155,17 +155,17 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd)
std::string username; std::string username;
if (!GetName(accid, username)) if (!GetName(accid, username))
return AOR_NAME_NOT_EXIST; // account doesn't exist { return AOR_NAME_NOT_EXIST; } // account doesn't exist
if (utf8length(new_passwd) > MAX_ACCOUNT_STR) if (utf8length(new_passwd) > MAX_ACCOUNT_STR)
return AOR_PASS_TOO_LONG; { return AOR_PASS_TOO_LONG; }
normalizeString(new_passwd); normalizeString(new_passwd);
// also reset s and v to force update at next realmd login // also reset s and v to force update at next realmd login
if (!LoginDatabase.PExecute("UPDATE account SET v='0', s='0', sha_pass_hash='%s' WHERE id='%u'", if (!LoginDatabase.PExecute("UPDATE account SET v='0', s='0', sha_pass_hash='%s' WHERE id='%u'",
CalculateShaPassHash(username, new_passwd).c_str(), accid)) CalculateShaPassHash(username, new_passwd).c_str(), accid))
return AOR_DB_INTERNAL_ERROR; // unexpected error { return AOR_DB_INTERNAL_ERROR; } // unexpected error
return AOR_OK; return AOR_OK;
} }
@ -175,7 +175,7 @@ uint32 AccountMgr::GetId(std::string username)
LoginDatabase.escape_string(username); LoginDatabase.escape_string(username);
QueryResult* result = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", username.c_str()); QueryResult* result = LoginDatabase.PQuery("SELECT id FROM account WHERE username = '%s'", username.c_str());
if (!result) if (!result)
return 0; { return 0; }
else else
{ {
uint32 id = (*result)[0].GetUInt32(); uint32 id = (*result)[0].GetUInt32();
@ -222,14 +222,14 @@ uint32 AccountMgr::GetCharactersCount(uint32 acc_id)
return charcount; return charcount;
} }
else else
return 0; { return 0; }
} }
bool AccountMgr::CheckPassword(uint32 accid, std::string passwd) bool AccountMgr::CheckPassword(uint32 accid, std::string passwd)
{ {
std::string username; std::string username;
if (!GetName(accid, username)) if (!GetName(accid, username))
return false; { return false; }
normalizeString(passwd); normalizeString(passwd);
normalizeString(username); normalizeString(username);
@ -250,7 +250,7 @@ bool AccountMgr::normalizeString(std::string& utf8str)
size_t wstr_len = MAX_ACCOUNT_STR; size_t wstr_len = MAX_ACCOUNT_STR;
if (!Utf8toWStr(utf8str, wstr_buf, wstr_len)) if (!Utf8toWStr(utf8str, wstr_buf, wstr_len))
return false; { return false; }
for (uint32 i = 0; i <= wstr_len; ++i) for (uint32 i = 0; i <= wstr_len; ++i)
wstr_buf[i] = wcharToUpperOnlyLatin(wstr_buf[i]); wstr_buf[i] = wcharToUpperOnlyLatin(wstr_buf[i]);

View file

@ -42,7 +42,7 @@ namespace MMAP
MMapManager* MMapFactory::createOrGetMMapManager() MMapManager* MMapFactory::createOrGetMMapManager()
{ {
if (g_MMapManager == NULL) if (g_MMapManager == NULL)
g_MMapManager = new MMapManager(); { g_MMapManager = new MMapManager(); }
return g_MMapManager; return g_MMapManager;
} }
@ -50,7 +50,7 @@ namespace MMAP
void MMapFactory::preventPathfindingOnMaps(const char* ignoreMapIds) void MMapFactory::preventPathfindingOnMaps(const char* ignoreMapIds)
{ {
if (!g_mmapDisabledIds) if (!g_mmapDisabledIds)
g_mmapDisabledIds = new std::set<uint32>(); { g_mmapDisabledIds = new std::set<uint32>(); }
uint32 strLenght = strlen(ignoreMapIds) + 1; uint32 strLenght = strlen(ignoreMapIds) + 1;
char* mapList = new char[strLenght]; char* mapList = new char[strLenght];
@ -133,7 +133,7 @@ namespace MMAP
MMapManager::~MMapManager() MMapManager::~MMapManager()
{ {
for (MMapDataSet::iterator i = loadedMMaps.begin(); i != loadedMMaps.end(); ++i) for (MMapDataSet::iterator i = loadedMMaps.begin(); i != loadedMMaps.end(); ++i)
delete i->second; { delete i->second; }
// by now we should not have maps loaded // by now we should not have maps loaded
// if we had, tiles in MMapData->mmapLoadedTiles, their actual data is lost! // if we had, tiles in MMapData->mmapLoadedTiles, their actual data is lost!
@ -143,7 +143,7 @@ namespace MMAP
{ {
// we already have this map loaded? // we already have this map loaded?
if (loadedMMaps.find(mapId) != loadedMMaps.end()) if (loadedMMaps.find(mapId) != loadedMMaps.end())
return true; { return true; }
// load and init dtNavMesh - read parameters from file // load and init dtNavMesh - read parameters from file
uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i.mmap") + 1; uint32 pathLen = sWorld.GetDataPath().length() + strlen("mmaps/%03i.mmap") + 1;
@ -154,7 +154,7 @@ namespace MMAP
if (!file) if (!file)
{ {
if (MMapFactory::IsPathfindingEnabled(mapId)) if (MMapFactory::IsPathfindingEnabled(mapId))
sLog.outError("MMAP:loadMapData: Error: Could not open mmap file '%s'", fileName); { sLog.outError("MMAP:loadMapData: Error: Could not open mmap file '%s'", fileName); }
delete[] fileName; delete[] fileName;
return false; return false;
} }
@ -194,7 +194,7 @@ namespace MMAP
{ {
// make sure the mmap is loaded and ready to load tiles // make sure the mmap is loaded and ready to load tiles
if (!loadMapData(mapId)) if (!loadMapData(mapId))
return false; { return false; }
// get this mmap data // get this mmap data
MMapData* mmap = loadedMMaps[mapId]; MMapData* mmap = loadedMMaps[mapId];