aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/bnetserver/Packets/ConnectionPackets.h4
-rw-r--r--src/server/game/Battlefield/Battlefield.cpp32
-rw-r--r--src/server/game/Conditions/DisableMgr.cpp51
-rw-r--r--src/server/game/DataStores/DB2Stores.cpp4
-rw-r--r--src/server/game/DataStores/DB2Stores.h2
-rw-r--r--src/server/game/DataStores/DBCStores.h3
-rw-r--r--src/server/game/DataStores/DBCStructure.h5
-rw-r--r--src/server/game/DungeonFinding/LFGMgr.cpp2
-rw-r--r--src/server/game/Entities/Object/Object.cpp65
-rw-r--r--src/server/game/Entities/Object/Object.h34
-rw-r--r--src/server/game/Entities/Object/ObjectGuid.cpp2
-rw-r--r--src/server/game/Entities/Player/Player.cpp6
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp10
-rw-r--r--src/server/game/Entities/Unit/Unit.h2
-rw-r--r--src/server/game/Globals/ObjectMgr.cpp21
-rw-r--r--src/server/game/Handlers/AuthHandler.cpp4
-rw-r--r--src/server/game/Handlers/CharacterHandler.cpp8
-rw-r--r--src/server/game/Handlers/LFGHandler.cpp2
-rw-r--r--src/server/game/Handlers/QueryHandler.cpp7
-rw-r--r--src/server/game/Handlers/TradeHandler.cpp2
-rw-r--r--src/server/game/Movement/Spline/MoveSpline.h16
-rw-r--r--src/server/game/Movement/Spline/MoveSplineFlag.h3
-rw-r--r--src/server/game/Movement/Spline/MoveSplineInit.cpp3
-rw-r--r--src/server/game/Movement/Spline/MovementPacketBuilder.cpp182
-rw-r--r--src/server/game/Movement/Spline/MovementPacketBuilder.h41
-rw-r--r--src/server/game/Movement/Spline/MovementTypedefs.h16
-rw-r--r--src/server/game/Movement/Spline/MovementUtil.cpp179
-rw-r--r--src/server/game/Quests/QuestDef.h3
-rw-r--r--src/server/game/Reputation/ReputationMgr.cpp6
-rw-r--r--src/server/game/Server/Packets/CombatLogPackets.h18
-rw-r--r--src/server/game/Server/Packets/MovementPackets.cpp258
-rw-r--r--src/server/game/Server/Packets/MovementPackets.h17
-rw-r--r--src/server/game/Server/Packets/QueryPackets.cpp9
-rw-r--r--src/server/game/Server/Packets/QueryPackets.h55
-rw-r--r--src/server/game/Server/Packets/SpellPackets.h40
-rw-r--r--src/server/game/Server/Protocol/Opcodes.cpp5
-rw-r--r--src/server/game/Server/WorldSession.h2
-rw-r--r--src/server/game/Spells/Spell.cpp74
-rw-r--r--src/server/game/Spells/Spell.h6
-rw-r--r--src/server/game/Spells/SpellEffects.cpp22
-rw-r--r--src/server/game/Spells/SpellInfo.cpp1
-rw-r--r--src/server/game/Spells/SpellScript.cpp7
-rw-r--r--src/server/game/Spells/SpellScript.h3
-rw-r--r--src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp14
-rw-r--r--src/server/scripts/Kalimdor/zone_winterspring.cpp24
-rw-r--r--src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp24
-rw-r--r--src/server/scripts/Northrend/zone_dragonblight.cpp46
-rw-r--r--src/server/scripts/Spells/spell_dk.cpp5
-rw-r--r--src/server/scripts/Spells/spell_druid.cpp2
-rw-r--r--src/server/scripts/Spells/spell_generic.cpp30
-rw-r--r--src/server/scripts/Spells/spell_item.cpp2
-rw-r--r--src/server/scripts/Spells/spell_mage.cpp54
-rw-r--r--src/server/scripts/Spells/spell_warlock.cpp8
-rw-r--r--src/server/scripts/Spells/spell_warrior.cpp10
-rw-r--r--src/server/shared/DataStores/DB2StorageLoader.h2
-rw-r--r--src/server/shared/DataStores/DB2Store.h13
-rw-r--r--src/server/shared/DataStores/DBCFileLoader.h1
-rw-r--r--src/server/shared/DataStores/DBCStore.h2
-rw-r--r--src/server/shared/Utilities/Util.cpp2
59 files changed, 709 insertions, 762 deletions
diff --git a/src/server/bnetserver/Packets/ConnectionPackets.h b/src/server/bnetserver/Packets/ConnectionPackets.h
index 238b2bff760..0e6cd2c49ca 100644
--- a/src/server/bnetserver/Packets/ConnectionPackets.h
+++ b/src/server/bnetserver/Packets/ConnectionPackets.h
@@ -134,9 +134,9 @@ namespace Battlenet
void CallHandler(Session* session) override;
PacketHeader Header;
- ClosingReason Reason;
+ ClosingReason Reason = PACKET_CORRUPT;
std::vector<PacketInfo> Packets;
- time_t Now;
+ time_t Now = 0;
};
class Pong final : public ServerPacket
diff --git a/src/server/game/Battlefield/Battlefield.cpp b/src/server/game/Battlefield/Battlefield.cpp
index d4aa1d37f11..73b9822af0d 100644
--- a/src/server/game/Battlefield/Battlefield.cpp
+++ b/src/server/game/Battlefield/Battlefield.cpp
@@ -771,6 +771,13 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
return nullptr;
}
+ CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
+ if (!cinfo)
+ {
+ TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: entry %u does not exist.", entry);
+ return nullptr;
+ }
+
Creature* creature = new Creature();
if (!creature->Create(sObjectMgr->GetGenerator<HighGuid::Creature>()->Generate(), map, PHASEMASK_NORMAL, entry, x, y, z, o))
{
@@ -778,14 +785,8 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
delete creature;
return nullptr;
}
- creature->SetHomePosition(x, y, z, o);
- CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
- if (!cinfo)
- {
- TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: entry %u does not exist.", entry);
- return nullptr;
- }
+ creature->SetHomePosition(x, y, z, o);
// Set creature in world
map->AddToMap(creature);
@@ -798,18 +799,27 @@ Creature* Battlefield::SpawnCreature(uint32 entry, float x, float y, float z, fl
GameObject* Battlefield::SpawnGameObject(uint32 entry, float x, float y, float z, float o)
{
// Get map object
- Map* map = sMapMgr->CreateBaseMap(571); // *vomits*
+ Map* map = sMapMgr->CreateBaseMap(m_MapId);
if (!map)
- return 0;
+ {
+ TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Can't create GameObject (Entry: %u). Map not found.", entry);
+ return nullptr;
+ }
+
+ GameObjectTemplate const* goInfo = sObjectMgr->GetGameObjectTemplate(entry);
+ if (!goInfo)
+ {
+ TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: GameObject template %u not found in database! Battlefield not created!", entry);
+ return nullptr;
+ }
// Create gameobject
GameObject* go = new GameObject;
if (!go->Create(sObjectMgr->GetGenerator<HighGuid::GameObject>()->Generate(), entry, map, PHASEMASK_NORMAL, x, y, z, o, 0, 0, 0, 0, 100, GO_STATE_READY))
{
- TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Gameobject template %u not found in database! Battlefield not created!", entry);
TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Cannot create gameobject template %u! Battlefield not created!", entry);
delete go;
- return NULL;
+ return nullptr;
}
// Add to world
diff --git a/src/server/game/Conditions/DisableMgr.cpp b/src/server/game/Conditions/DisableMgr.cpp
index 65c5ec6873a..8c962ab9d6c 100644
--- a/src/server/game/Conditions/DisableMgr.cpp
+++ b/src/server/game/Conditions/DisableMgr.cpp
@@ -27,6 +27,16 @@
namespace DisableMgr
{
+char const* MapTypeNames[] =
+{
+ "World",
+ "Dungeon",
+ "Raid",
+ "Battleground",
+ "Arena",
+ "Scenario"
+};
+
namespace
{
struct DisableData
@@ -194,30 +204,19 @@ void LoadDisables()
{
case MAP_COMMON:
if (flags & VMAP::VMAP_DISABLE_AREAFLAG)
- TC_LOG_INFO("misc", "Areaflag disabled for world map %u.", entry);
+ TC_LOG_INFO("misc", "Areaflag disabled for %s map %u.", MapTypeNames[mapEntry->InstanceType], entry);
if (flags & VMAP::VMAP_DISABLE_LIQUIDSTATUS)
- TC_LOG_INFO("misc", "Liquid status disabled for world map %u.", entry);
+ TC_LOG_INFO("misc", "Liquid status disabled for %s map %u.", MapTypeNames[mapEntry->InstanceType], entry);
break;
case MAP_INSTANCE:
case MAP_RAID:
- if (flags & VMAP::VMAP_DISABLE_HEIGHT)
- TC_LOG_INFO("misc", "Height disabled for instance map %u.", entry);
- if (flags & VMAP::VMAP_DISABLE_LOS)
- TC_LOG_INFO("misc", "LoS disabled for instance map %u.", entry);
- break;
case MAP_BATTLEGROUND:
- if (flags & VMAP::VMAP_DISABLE_HEIGHT)
- TC_LOG_INFO("misc", "Height disabled for battleground map %u.", entry);
- if (flags & VMAP::VMAP_DISABLE_LOS)
- TC_LOG_INFO("misc", "LoS disabled for battleground map %u.", entry);
- break;
case MAP_ARENA:
+ case MAP_SCENARIO:
if (flags & VMAP::VMAP_DISABLE_HEIGHT)
- TC_LOG_INFO("misc", "Height disabled for arena map %u.", entry);
+ TC_LOG_INFO("misc", "Height disabled for %s map %u.", MapTypeNames[mapEntry->InstanceType], entry);
if (flags & VMAP::VMAP_DISABLE_LOS)
- TC_LOG_INFO("misc", "LoS disabled for arena map %u.", entry);
- break;
- default:
+ TC_LOG_INFO("misc", "LoS disabled for %s map %u.", MapTypeNames[mapEntry->InstanceType], entry);
break;
}
break;
@@ -230,24 +229,8 @@ void LoadDisables()
TC_LOG_ERROR("sql.sql", "Map entry %u from `disables` doesn't exist in dbc, skipped.", entry);
continue;
}
- switch (mapEntry->InstanceType)
- {
- case MAP_COMMON:
- TC_LOG_INFO("misc", "Pathfinding disabled for world map %u.", entry);
- break;
- case MAP_INSTANCE:
- case MAP_RAID:
- TC_LOG_INFO("misc", "Pathfinding disabled for instance map %u.", entry);
- break;
- case MAP_BATTLEGROUND:
- TC_LOG_INFO("misc", "Pathfinding disabled for battleground map %u.", entry);
- break;
- case MAP_ARENA:
- TC_LOG_INFO("misc", "Pathfinding disabled for arena map %u.", entry);
- break;
- default:
- break;
- }
+ if (mapEntry->InstanceType <= MAP_SCENARIO)
+ TC_LOG_INFO("misc", "Pathfinding disabled for %s map %u.", MapTypeNames[mapEntry->InstanceType], entry);
break;
}
default:
diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp
index ec0bd63efc7..f27e48f71ff 100644
--- a/src/server/game/DataStores/DB2Stores.cpp
+++ b/src/server/game/DataStores/DB2Stores.cpp
@@ -66,8 +66,8 @@ inline void LoadDB2(uint32& availableDb2Locales, DB2StoreProblemList& errlist, D
{
// compatibility format and C++ structure sizes
ASSERT(DB2FileLoader::GetFormatRecordSize(storage.GetFormat()) == sizeof(T),
- "Size of '%s' set by format string (%u) not equal size of C++ structure (%u).",
- DB2FileLoader::GetFormatRecordSize(storage.GetFormat()), sizeof(T), filename.c_str());
+ "Size of '%s' set by format string (" SZFMTD ") not equal size of C++ structure (%u).",
+ filename.c_str(), DB2FileLoader::GetFormatRecordSize(storage.GetFormat()), sizeof(T));
++DB2FilesCount;
diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h
index 878498a94da..d901082b69f 100644
--- a/src/server/game/DataStores/DB2Stores.h
+++ b/src/server/game/DataStores/DB2Stores.h
@@ -20,8 +20,6 @@
#include "DB2Store.h"
#include "DB2Structure.h"
-#include <string>
-#include <map>
#include "SharedDefines.h"
extern DB2Storage<BroadcastTextEntry> sBroadcastTextStore;
diff --git a/src/server/game/DataStores/DBCStores.h b/src/server/game/DataStores/DBCStores.h
index 92770e2e618..5db9df1d300 100644
--- a/src/server/game/DataStores/DBCStores.h
+++ b/src/server/game/DataStores/DBCStores.h
@@ -19,13 +19,10 @@
#ifndef TRINITY_DBCSTORES_H
#define TRINITY_DBCSTORES_H
-#include "Common.h"
#include "DBCStore.h"
#include "DBCStructure.h"
#include "SharedDefines.h"
-#include <list>
-
typedef std::map<uint32, uint32> SpecializationOverrideSpellsList;
typedef std::map<uint32, SpecializationOverrideSpellsList> SpecializationOverrideSpellsMap;
diff --git a/src/server/game/DataStores/DBCStructure.h b/src/server/game/DataStores/DBCStructure.h
index 32bd3c35fee..6e0d5835f09 100644
--- a/src/server/game/DataStores/DBCStructure.h
+++ b/src/server/game/DataStores/DBCStructure.h
@@ -21,7 +21,6 @@
#include "Common.h"
#include "DBCEnums.h"
-#include "Define.h"
#include "Path.h"
#include "Util.h"
@@ -57,7 +56,6 @@ struct AchievementEntry
uint32 CriteriaTree; // 14
};
-//19116
struct AchievementCategoryEntry
{
uint32 ID; // 0
@@ -1708,14 +1706,11 @@ struct SpellItemEnchantmentConditionEntry
{
uint32 ID; // 0
uint8 LTOperandType[5]; // 1-2
- //uint8 Padding[3]; // 1-2
uint32 LTOperand[5]; // 2-6
uint8 Operator[5]; // 7-8
uint8 RTOperandType[5]; // 8-9
- //uint8 Padding[2]; // 9
uint32 RTOperand[5]; // 10-14
uint8 Logic[5]; // 15-16
- //uint8 Padding[3]; // 16
};
struct StableSlotPricesEntry
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp
index 7099d38d428..9033a85b083 100644
--- a/src/server/game/DungeonFinding/LFGMgr.cpp
+++ b/src/server/game/DungeonFinding/LFGMgr.cpp
@@ -1577,7 +1577,7 @@ LfgLockMap const LFGMgr::GetLockedDungeons(ObjectGuid guid)
}
uint8 level = player->getLevel();
- uint8 expansion = player->GetSession()->Expansion();
+ uint8 expansion = player->GetSession()->GetExpansion();
LfgDungeonSet const& dungeons = GetDungeonsByRandom(0);
bool denyJoin = !player->GetSession()->HasPermission(rbac::RBAC_PERM_JOIN_DUNGEON_FINDER);
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 0aa9098adf1..eabb2f3f202 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -44,8 +44,8 @@
#include "UpdateFieldFlags.h"
#include "TemporarySummon.h"
#include "Totem.h"
+#include "MovementPackets.h"
#include "OutdoorPvPMgr.h"
-#include "MovementPacketBuilder.h"
#include "DynamicTree.h"
#include "Unit.h"
#include "Group.h"
@@ -432,24 +432,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint32 flags) const
data->WriteBit(0); // RemoteTimeValid
if (!unit->m_movementInfo.transport.guid.IsEmpty())
- {
- *data << unit->m_movementInfo.transport.guid; // Transport Guid
- *data << float(unit->GetTransOffsetX());
- *data << float(unit->GetTransOffsetY());
- *data << float(unit->GetTransOffsetZ());
- *data << float(unit->GetTransOffsetO());
- *data << int8(unit->m_movementInfo.transport.seat); // VehicleSeatIndex
- *data << uint32(unit->m_movementInfo.transport.time); // MoveTime
-
- data->WriteBit(unit->m_movementInfo.transport.prevTime != 0);
- data->WriteBit(unit->m_movementInfo.transport.vehicleId != 0);
-
- if (unit->m_movementInfo.transport.prevTime)
- *data << uint32(unit->m_movementInfo.transport.prevTime); // PrevMoveTime
-
- if (unit->m_movementInfo.transport.vehicleId)
- *data << uint32(unit->m_movementInfo.transport.vehicleId); // VehicleRecID
- }
+ *data << unit->m_movementInfo.transport;
if (HasFall)
{
@@ -488,28 +471,13 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint32 flags) const
// HasMovementSpline - marks that spline data is present in packet
if (data->WriteBit(HasSpline))
- Movement::PacketBuilder::WriteCreate(*unit->movespline, *data);
+ WorldPackets::Movement::CommonMovement::WriteCreateObjectSplineDataBlock(*unit->movespline, *data);
}
if (HasMovementTransport)
{
WorldObject const* self = static_cast<WorldObject const*>(this);
- *data << self->m_movementInfo.transport.guid; // Transport Guid
- *data << float(self->GetTransOffsetX());
- *data << float(self->GetTransOffsetY());
- *data << float(self->GetTransOffsetZ());
- *data << float(self->GetTransOffsetO());
- *data << int8(self->m_movementInfo.transport.seat); // VehicleSeatIndex
- *data << uint32(self->m_movementInfo.transport.time); // MoveTime
-
- data->WriteBit(self->m_movementInfo.transport.prevTime != 0);
- data->WriteBit(self->m_movementInfo.transport.vehicleId != 0);
-
- if (self->m_movementInfo.transport.prevTime)
- *data << uint32(self->m_movementInfo.transport.prevTime); // PrevMoveTime
-
- if (self->m_movementInfo.transport.vehicleId)
- *data << uint32(self->m_movementInfo.transport.vehicleId); // VehicleRecID
+ *data << self->m_movementInfo.transport;
}
if (Stationary)
@@ -1506,7 +1474,7 @@ bool Position::operator==(Position const &a)
return (G3D::fuzzyEq(a.m_positionX, m_positionX) &&
G3D::fuzzyEq(a.m_positionY, m_positionY) &&
G3D::fuzzyEq(a.m_positionZ, m_positionZ) &&
- G3D::fuzzyEq(a.m_orientation, m_orientation));
+ G3D::fuzzyEq(a._orientation, _orientation));
}
bool Position::HasInLine(WorldObject const* target, float width) const
@@ -1521,7 +1489,7 @@ bool Position::HasInLine(WorldObject const* target, float width) const
std::string Position::ToString() const
{
std::stringstream sstr;
- sstr << "X: " << m_positionX << " Y: " << m_positionY << " Z: " << m_positionZ << " O: " << m_orientation;
+ sstr << "X: " << m_positionX << " Y: " << m_positionY << " Z: " << m_positionZ << " O: " << _orientation;
return sstr.str();
}
@@ -1529,14 +1497,14 @@ ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const& st
{
float x, y, z, o;
buf >> x >> y >> z >> o;
- streamer.m_pos->Relocate(x, y, z, o);
+ streamer.Pos->Relocate(x, y, z, o);
return buf;
}
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer)
{
- float x, y, z;
- streamer.m_pos->GetPosition(x, y, z);
- buf << x << y << z;
+ buf << streamer.Pos->GetPositionX();
+ buf << streamer.Pos->GetPositionY();
+ buf << streamer.Pos->GetPositionZ();
return buf;
}
@@ -1544,15 +1512,16 @@ ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const& str
{
float x, y, z;
buf >> x >> y >> z;
- streamer.m_pos->Relocate(x, y, z);
+ streamer.Pos->Relocate(x, y, z);
return buf;
}
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer)
{
- float x, y, z, o;
- streamer.m_pos->GetPosition(x, y, z, o);
- buf << x << y << z << o;
+ buf << streamer.Pos->GetPositionX();
+ buf << streamer.Pos->GetPositionY();
+ buf << streamer.Pos->GetPositionZ();
+ buf << streamer.Pos->GetOrientation();
return buf;
}
@@ -1989,7 +1958,7 @@ bool Position::HasInArc(float arc, const Position* obj, float border) const
arc = NormalizeOrientation(arc);
float angle = GetAngle(obj);
- angle -= m_orientation;
+ angle -= _orientation;
// move angle to range -pi ... +pi
angle = NormalizeOrientation(angle);
@@ -2136,7 +2105,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
bool Position::IsPositionValid() const
{
- return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, m_orientation);
+ return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, _orientation);
}
float WorldObject::GetGridActivationRange() const
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index d2dd0108d20..18e5e29028c 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -261,30 +261,30 @@ class Object
struct Position
{
Position(float x = 0, float y = 0, float z = 0, float o = 0)
- : m_positionX(x), m_positionY(y), m_positionZ(z), m_orientation(NormalizeOrientation(o)) { }
+ : m_positionX(x), m_positionY(y), m_positionZ(z), _orientation(NormalizeOrientation(o)) { }
- Position(const Position &loc) { Relocate(loc); }
+ Position(Position const& loc) { Relocate(loc); }
struct PositionXYZStreamer
{
- explicit PositionXYZStreamer(Position& pos) : m_pos(&pos) { }
- Position* m_pos;
+ explicit PositionXYZStreamer(Position& pos) : Pos(&pos) { }
+ Position* Pos;
};
struct PositionXYZOStreamer
{
- explicit PositionXYZOStreamer(Position& pos) : m_pos(&pos) { }
- Position* m_pos;
+ explicit PositionXYZOStreamer(Position& pos) : Pos(&pos) { }
+ Position* Pos;
};
float m_positionX;
float m_positionY;
float m_positionZ;
-// Better to limit access to m_orientation field, but this will be hard to achieve with many scripts using array initialization for this structure
-//private:
- float m_orientation;
-//public:
+// Better to limit access to _orientation field, to guarantee the value is normalized
+private:
+ float _orientation;
+public:
bool operator==(Position const &a);
inline bool operator!=(Position const &a)
@@ -299,24 +299,24 @@ struct Position
void Relocate(float x, float y, float z, float orientation)
{ m_positionX = x; m_positionY = y; m_positionZ = z; SetOrientation(orientation); }
void Relocate(Position const &pos)
- { m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; SetOrientation(pos.m_orientation); }
+ { m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; SetOrientation(pos._orientation); }
void Relocate(Position const* pos)
- { m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; SetOrientation(pos->m_orientation); }
+ { m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; SetOrientation(pos->_orientation); }
void RelocateOffset(Position const &offset);
void SetOrientation(float orientation)
- { m_orientation = NormalizeOrientation(orientation); }
+ { _orientation = NormalizeOrientation(orientation); }
float GetPositionX() const { return m_positionX; }
float GetPositionY() const { return m_positionY; }
float GetPositionZ() const { return m_positionZ; }
- float GetOrientation() const { return m_orientation; }
+ float GetOrientation() const { return _orientation; }
void GetPosition(float &x, float &y) const
{ x = m_positionX; y = m_positionY; }
void GetPosition(float &x, float &y, float &z) const
{ x = m_positionX; y = m_positionY; z = m_positionZ; }
void GetPosition(float &x, float &y, float &z, float &o) const
- { x = m_positionX; y = m_positionY; z = m_positionZ; o = m_orientation; }
+ { x = m_positionX; y = m_positionY; z = m_positionZ; o = _orientation; }
Position GetPosition() const
{
@@ -357,8 +357,8 @@ struct Position
float GetAngle(Position const* pos) const;
float GetAngle(float x, float y) const;
float GetRelativeAngle(Position const* pos) const
- { return GetAngle(pos) - m_orientation; }
- float GetRelativeAngle(float x, float y) const { return GetAngle(x, y) - m_orientation; }
+ { return GetAngle(pos) - _orientation; }
+ float GetRelativeAngle(float x, float y) const { return GetAngle(x, y) - _orientation; }
void GetSinCos(float x, float y, float &vsin, float &vcos) const;
bool IsInDist2d(float x, float y, float dist) const
diff --git a/src/server/game/Entities/Object/ObjectGuid.cpp b/src/server/game/Entities/Object/ObjectGuid.cpp
index 327b83ba6d4..8fc88003faf 100644
--- a/src/server/game/Entities/Object/ObjectGuid.cpp
+++ b/src/server/game/Entities/Object/ObjectGuid.cpp
@@ -72,7 +72,7 @@ char const* TypeNames[] =
char const* ObjectGuid::GetTypeName(HighGuid high)
{
- if (high > HighGuid::Count)
+ if (high >= HighGuid::Count)
return "<unknown>";
return TypeNames[uint32(high)];
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 71c83154307..241c0564655 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -1979,7 +1979,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
return false;
// client without expansion support
- if (GetSession()->Expansion() < mEntry->Expansion())
+ if (GetSession()->GetExpansion() < mEntry->Expansion())
{
TC_LOG_DEBUG("maps", "Player %s using client without required expansion tried teleport to non accessible map %u", GetName().c_str(), mapid);
@@ -16962,7 +16962,7 @@ bool Player::LoadFromDB(ObjectGuid guid, SQLQueryHolder *holder)
// client without expansion support
if (mapEntry)
{
- if (GetSession()->Expansion() < mapEntry->Expansion())
+ if (GetSession()->GetExpansion() < mapEntry->Expansion())
{
TC_LOG_DEBUG("entities.player.loading", "Player %s using client without required expansion tried login at non accessible map %u", GetName().c_str(), mapId);
RelocateToHomebind();
@@ -18743,7 +18743,7 @@ bool Player::_LoadHomeBind(PreparedQueryResult result)
// accept saved data only for valid position (and non instanceable), and accessable
if (MapManager::IsValidMapCoord(m_homebindMapId, m_homebindX, m_homebindY, m_homebindZ) &&
- !bindMapEntry->Instanceable() && GetSession()->Expansion() >= bindMapEntry->Expansion())
+ !bindMapEntry->Instanceable() && GetSession()->GetExpansion() >= bindMapEntry->Expansion())
ok = true;
else
{
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 87f01633a8a..cb05413d33a 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -7688,15 +7688,13 @@ void Unit::SetMinion(Minion *minion, bool apply)
}
}
-void Unit::GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry)
+void Unit::GetAllMinionsByEntry(std::list<TempSummon*>& Minions, uint32 entry)
{
- for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end();)
+ for (Unit::ControlList::iterator itr = m_Controlled.begin(); itr != m_Controlled.end(); ++itr)
{
Unit* unit = *itr;
- ++itr;
- if (unit->GetEntry() == entry && unit->GetTypeId() == TYPEID_UNIT
- && unit->ToCreature()->IsSummon()) // minion, actually
- Minions.push_back(unit->ToCreature());
+ if (unit->GetEntry() == entry && unit->IsSummon()) // minion, actually
+ Minions.push_back(unit->ToTempSummon());
}
}
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 2b9b4d932ad..0adba8f3dc6 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1731,7 +1731,7 @@ class Unit : public WorldObject
Player* GetAffectingPlayer() const;
void SetMinion(Minion *minion, bool apply);
- void GetAllMinionsByEntry(std::list<Creature*>& Minions, uint32 entry);
+ void GetAllMinionsByEntry(std::list<TempSummon*>& Minions, uint32 entry);
void RemoveAllMinionsByEntry(uint32 entry);
void SetCharm(Unit* target, bool apply);
Unit* GetNextRandomRaidMemberOrPet(float radius);
diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp
index ef5a681ef04..237b1e18194 100644
--- a/src/server/game/Globals/ObjectMgr.cpp
+++ b/src/server/game/Globals/ObjectMgr.cpp
@@ -584,17 +584,18 @@ void ObjectMgr::LoadCreatureTemplateAddons()
creatureAddon.auras.resize(tokens.size());
for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
{
- SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(atoul(*itr));
+ uint32 spellId = uint32(atoul(*itr));
+ SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!AdditionalSpellInfo)
{
- TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has wrong spell %lu defined in `auras` field in `creature_template_addon`.", entry, atoul(*itr));
+ TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has wrong spell %u defined in `auras` field in `creature_template_addon`.", entry, spellId);
continue;
}
if (AdditionalSpellInfo->HasAura(DIFFICULTY_NONE, SPELL_AURA_CONTROL_VEHICLE))
- TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has SPELL_AURA_CONTROL_VEHICLE aura %u defined in `auras` field in `creature_template_addon`.", entry, uint32(atol(*itr)));
+ TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has SPELL_AURA_CONTROL_VEHICLE aura %u defined in `auras` field in `creature_template_addon`.", entry, spellId);
- creatureAddon.auras[i++] = atoul(*itr);
+ creatureAddon.auras[i++] = spellId;
}
if (creatureAddon.mount)
@@ -1041,18 +1042,18 @@ void ObjectMgr::LoadCreatureAddons()
creatureAddon.auras.resize(tokens.size());
for (Tokenizer::const_iterator itr = tokens.begin(); itr != tokens.end(); ++itr)
{
- SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(atoul(*itr));
+ uint32 spellId = uint32(atoul(*itr));
+ SpellInfo const* AdditionalSpellInfo = sSpellMgr->GetSpellInfo(spellId);
if (!AdditionalSpellInfo)
{
- TC_LOG_ERROR("sql.sql", "Creature (GUID: " UI64FMTD ") has wrong spell %lu defined in `auras` field in `creature_addon`.", guid, atoul(*itr));
+ TC_LOG_ERROR("sql.sql", "Creature (GUID: " UI64FMTD ") has wrong spell %u defined in `auras` field in `creature_addon`.", guid, spellId);
continue;
}
if (AdditionalSpellInfo->HasAura(DIFFICULTY_NONE, SPELL_AURA_CONTROL_VEHICLE))
- TC_LOG_ERROR("sql.sql", "Creature (GUID: " UI64FMTD ") has SPELL_AURA_CONTROL_VEHICLE aura %u defined in `auras` field in `creature_addon`.", guid, uint32(atol(*itr)));
+ TC_LOG_ERROR("sql.sql", "Creature (GUID: " UI64FMTD ") has SPELL_AURA_CONTROL_VEHICLE aura %u defined in `auras` field in `creature_addon`.", guid, spellId);
-
- creatureAddon.auras[i++] = atoul(*itr);
+ creatureAddon.auras[i++] = spellId;
}
if (creatureAddon.mount)
@@ -6811,7 +6812,7 @@ void ObjectMgr::LoadReputationSpilloverTemplate()
continue;
}
- if (factionSpillover->ReputationIndex < 0)
+ if (!factionSpillover->CanHaveReputation())
{
TC_LOG_ERROR("sql.sql", "Spillover faction (faction.dbc) %u for faction %u in `reputation_spillover_template` can not be listed for client, and then useless, skipping", repTemplate.faction[i], factionId);
continue;
diff --git a/src/server/game/Handlers/AuthHandler.cpp b/src/server/game/Handlers/AuthHandler.cpp
index d8b8f4fe018..921ed6eeecc 100644
--- a/src/server/game/Handlers/AuthHandler.cpp
+++ b/src/server/game/Handlers/AuthHandler.cpp
@@ -30,8 +30,8 @@ void WorldSession::SendAuthResponse(uint8 code, bool queued, uint32 queuePos)
response.WaitInfo.Value.WaitCount = queuePos;
if (code == AUTH_OK)
{
- response.SuccessInfo.Value.AccountExpansionLevel = Expansion();
- response.SuccessInfo.Value.ActiveExpansionLevel = Expansion();
+ response.SuccessInfo.Value.AccountExpansionLevel = GetExpansion();
+ response.SuccessInfo.Value.ActiveExpansionLevel = GetExpansion();
response.SuccessInfo.Value.VirtualRealmAddress = GetVirtualRealmAddress();
std::string realmName = sObjectMgr->GetRealmName(realmHandle.Index);
diff --git a/src/server/game/Handlers/CharacterHandler.cpp b/src/server/game/Handlers/CharacterHandler.cpp
index 86256eb08e4..be7d83fa9d7 100644
--- a/src/server/game/Handlers/CharacterHandler.cpp
+++ b/src/server/game/Handlers/CharacterHandler.cpp
@@ -370,18 +370,18 @@ void WorldSession::HandleCharCreateOpcode(WorldPackets::Character::CreateChar& c
// prevent character creating Expansion race without Expansion account
uint8 raceExpansionRequirement = sObjectMgr->GetRaceExpansionRequirement(charCreate.CreateInfo->Race);
- if (raceExpansionRequirement > Expansion())
+ if (raceExpansionRequirement > GetExpansion())
{
- TC_LOG_ERROR("network", "Expansion %u account:[%d] tried to Create character with expansion %u race (%u)", Expansion(), GetAccountId(), raceExpansionRequirement, charCreate.CreateInfo->Race);
+ TC_LOG_ERROR("network", "Expansion %u account:[%d] tried to Create character with expansion %u race (%u)", GetExpansion(), GetAccountId(), raceExpansionRequirement, charCreate.CreateInfo->Race);
SendCharCreate(CHAR_CREATE_EXPANSION);
return;
}
// prevent character creating Expansion class without Expansion account
uint8 classExpansionRequirement = sObjectMgr->GetClassExpansionRequirement(charCreate.CreateInfo->Class);
- if (classExpansionRequirement > Expansion())
+ if (classExpansionRequirement > GetExpansion())
{
- TC_LOG_ERROR("network", "Expansion %u account:[%d] tried to Create character with expansion %u class (%u)", Expansion(), GetAccountId(), classExpansionRequirement, charCreate.CreateInfo->Class);
+ TC_LOG_ERROR("network", "Expansion %u account:[%d] tried to Create character with expansion %u class (%u)", GetExpansion(), GetAccountId(), classExpansionRequirement, charCreate.CreateInfo->Class);
SendCharCreate(CHAR_CREATE_EXPANSION_CLASS);
return;
}
diff --git a/src/server/game/Handlers/LFGHandler.cpp b/src/server/game/Handlers/LFGHandler.cpp
index 2c5bb78867a..eda60827a8d 100644
--- a/src/server/game/Handlers/LFGHandler.cpp
+++ b/src/server/game/Handlers/LFGHandler.cpp
@@ -287,7 +287,7 @@ void WorldSession::SendLfgPlayerLockInfo()
// Get Random dungeons that can be done at a certain level and expansion
uint8 level = GetPlayer()->getLevel();
lfg::LfgDungeonSet const& randomDungeons =
- sLFGMgr->GetRandomAndSeasonalDungeons(level, GetPlayer()->GetSession()->Expansion());
+ sLFGMgr->GetRandomAndSeasonalDungeons(level, GetExpansion());
// Get player locked Dungeons
lfg::LfgLockMap const& lock = sLFGMgr->GetLockedDungeons(guid);
diff --git a/src/server/game/Handlers/QueryHandler.cpp b/src/server/game/Handlers/QueryHandler.cpp
index ce4a9fa4e66..c662be65334 100644
--- a/src/server/game/Handlers/QueryHandler.cpp
+++ b/src/server/game/Handlers/QueryHandler.cpp
@@ -135,11 +135,10 @@ void WorldSession::HandleCreatureQuery(WorldPackets::Query::QueryCreature& packe
void WorldSession::HandleGameObjectQueryOpcode(WorldPackets::Query::QueryGameObject& packet)
{
WorldPackets::Query::QueryGameObjectResponse response;
- GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(packet.Entry);
- response.Entry = packet.Entry;
+ response.GameObjectID = packet.GameObjectID;
- if (gameObjectInfo)
+ if (GameObjectTemplate const* gameObjectInfo = sObjectMgr->GetGameObjectTemplate(packet.GameObjectID))
{
response.Allow = true;
WorldPackets::Query::GameObjectStats& stats = response.Stats;
@@ -419,7 +418,7 @@ void WorldSession::HandleDBQueryBulk(WorldPackets::Query::DBQueryBulk& packet)
return;
}
- for (WorldPackets::Query::DBQueryRecord const& rec : packet.Queries)
+ for (WorldPackets::Query::DBQueryBulk::DBQueryRecord const& rec : packet.Queries)
{
WorldPackets::Query::DBReply response;
response.TableHash = packet.TableHash;
diff --git a/src/server/game/Handlers/TradeHandler.cpp b/src/server/game/Handlers/TradeHandler.cpp
index aa4579508f2..502d814fe1f 100644
--- a/src/server/game/Handlers/TradeHandler.cpp
+++ b/src/server/game/Handlers/TradeHandler.cpp
@@ -775,7 +775,7 @@ void WorldSession::HandleInitiateTradeOpcode(WorldPacket& recvPacket)
if (pOther->GetTeam() != _player->GetTeam() &&
(!sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_TRADE) &&
- !GetPlayer()->GetSession()->HasPermission(rbac::RBAC_PERM_ALLOW_TWO_SIDE_TRADE)))
+ !HasPermission(rbac::RBAC_PERM_ALLOW_TWO_SIDE_TRADE)))
{
info.Status = TRADE_STATUS_WRONG_FACTION;
SendTradeStatus(info);
diff --git a/src/server/game/Movement/Spline/MoveSpline.h b/src/server/game/Movement/Spline/MoveSpline.h
index 209f978d658..cb42e4b589e 100644
--- a/src/server/game/Movement/Spline/MoveSpline.h
+++ b/src/server/game/Movement/Spline/MoveSpline.h
@@ -22,6 +22,15 @@
#include "Spline.h"
#include "MoveSplineInitArgs.h"
+namespace WorldPackets
+{
+ namespace Movement
+ {
+ class CommonMovement;
+ class MonsterMove;
+ }
+}
+
namespace Movement
{
struct Location : public Vector3
@@ -36,11 +45,15 @@ namespace Movement
// MoveSpline represents smooth catmullrom or linear curve and point that moves belong it
// curve can be cyclic - in this case movement will be cyclic
- // point can have vertical acceleration motion componemt(used in fall, parabolic movement)
+ // point can have vertical acceleration motion component (used in fall, parabolic movement)
class MoveSpline
{
+ friend class WorldPackets::Movement::CommonMovement;
+ friend class WorldPackets::Movement::MonsterMove;
+
public:
typedef Spline<int32> MySpline;
+
enum UpdateResult
{
Result_None = 0x01,
@@ -48,7 +61,6 @@ namespace Movement
Result_NextCycle = 0x04,
Result_NextSegment = 0x08
};
- friend class PacketBuilder;
protected:
MySpline spline;
diff --git a/src/server/game/Movement/Spline/MoveSplineFlag.h b/src/server/game/Movement/Spline/MoveSplineFlag.h
index f9151c53fc2..d93c19ff869 100644
--- a/src/server/game/Movement/Spline/MoveSplineFlag.h
+++ b/src/server/game/Movement/Spline/MoveSplineFlag.h
@@ -18,9 +18,8 @@
#ifndef TRINITYSERVER_MOVESPLINEFLAG_H
#define TRINITYSERVER_MOVESPLINEFLAG_H
-#include "MovementTypedefs.h"
-#include <string>
+#include "MovementTypedefs.h"
namespace Movement
{
diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp
index 560f40143bb..8e6fdd96280 100644
--- a/src/server/game/Movement/Spline/MoveSplineInit.cpp
+++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp
@@ -18,7 +18,6 @@
#include "MoveSplineInit.h"
#include "MoveSpline.h"
-#include "MovementPacketBuilder.h"
#include "Unit.h"
#include "Transport.h"
#include "Vehicle.h"
@@ -119,7 +118,7 @@ namespace Movement
WorldPackets::Movement::MonsterMove packet;
packet.MoverGUID = unit->GetGUID();
packet.Pos = real_position;
- PacketBuilder::WriteMonsterMove(move_spline, packet.SplineData);
+ packet.InitializeSplineData(move_spline);
unit->SendMessageToSet(packet.Write(), true);
return move_spline.Duration();
diff --git a/src/server/game/Movement/Spline/MovementPacketBuilder.cpp b/src/server/game/Movement/Spline/MovementPacketBuilder.cpp
deleted file mode 100644
index 7d2b40af409..00000000000
--- a/src/server/game/Movement/Spline/MovementPacketBuilder.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
- * Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "MovementPacketBuilder.h"
-#include "MoveSpline.h"
-#include "WorldPacket.h"
-#include "Object.h"
-#include "MovementPackets.h"
-
-namespace Movement
-{
- void PacketBuilder::WriteMonsterMove(const MoveSpline& move_spline, WorldPackets::Movement::MovementMonsterSpline& movementMonsterSpline)
- {
- movementMonsterSpline.ID = move_spline.m_Id;
- WorldPackets::Movement::MovementSpline& movementSpline = movementMonsterSpline.Move;
-
- MoveSplineFlag splineflags = move_spline.splineflags;
- splineflags.enter_cycle = move_spline.isCyclic();
- movementSpline.Flags = uint32(splineflags & uint32(~MoveSplineFlag::Mask_No_Monster_Move));
-
- switch (move_spline.splineflags & MoveSplineFlag::Mask_Final_Facing)
- {
- case MoveSplineFlag::Final_Point:
- movementSpline.Face = MONSTER_MOVE_FACING_SPOT;
- movementSpline.FaceSpot = move_spline.facing.f;
- break;
- case MoveSplineFlag::Final_Target:
- movementSpline.Face = MONSTER_MOVE_FACING_TARGET;
- movementSpline.FaceGUID = move_spline.facing.target;
- break;
- case MoveSplineFlag::Final_Angle:
- movementSpline.Face = MONSTER_MOVE_FACING_ANGLE;
- movementSpline.FaceDirection = move_spline.facing.angle;
- break;
- default:
- movementSpline.Face = MONSTER_MOVE_NORMAL;
- break;
- }
-
- if (splineflags.animation)
- {
- movementSpline.AnimTier = splineflags.getAnimationId();
- movementSpline.TierTransStartTime = move_spline.effect_start_time;
- }
-
- movementSpline.MoveTime = move_spline.Duration();
-
- if (splineflags.parabolic)
- {
- movementSpline.JumpGravity = move_spline.vertical_acceleration;
- movementSpline.SpecialTime = move_spline.effect_start_time;
- }
-
- Spline<int32> const& spline = move_spline.spline;
- std::vector<Vector3> const& array = spline.getPoints();
-
- if (splineflags & MoveSplineFlag::UncompressedPath)
- {
- if (!splineflags.cyclic)
- {
- uint32 count = spline.getPointCount() - 3;
- for (uint32 i = 2; i < count; ++i)
- movementSpline.Points.push_back(array[i]);
- }
- else
- {
- uint32 count = spline.getPointCount() - 3;
- movementSpline.Points.push_back(array[1]);
- for (uint32 i = 1; i < count; ++i)
- movementSpline.Points.push_back(array[i]);
- }
- }
- else
- {
- uint32 last_idx = spline.getPointCount() - 3;
- Vector3 const* real_path = &spline.getPoint(1);
-
- movementSpline.Points.push_back(real_path[last_idx]);
-
- if (last_idx > 1)
- {
- Vector3 middle = (real_path[0] + real_path[last_idx]) / 2.f;
- Vector3 offset;
- // first and last points already appended
- for (uint32 i = 1; i < last_idx; ++i)
- {
- offset = middle - real_path[i];
- movementSpline.PackedDeltas.push_back(offset);
- }
- }
- }
- }
-
- void PacketBuilder::WriteCreate(MoveSpline const& moveSpline, ByteBuffer& data)
- {
- data << uint32(moveSpline.GetId()); // ID
- if (!moveSpline.isCyclic()) // Destination
- {
- Vector3 dest = moveSpline.FinalDestination();
- data << float(dest.z);
- data << float(dest.x);
- data << float(dest.y);
- }
- else
- data << Vector3::zero();
-
- if (data.WriteBit(!moveSpline.Finalized())) // MovementSplineMove
- {
- MoveSplineFlag const& splineFlags = moveSpline.splineflags;
- data.FlushBits();
-
- data.WriteBits(moveSpline.splineflags.raw(), 25); // SplineFlags
-
- if (splineFlags.final_angle)
- data.WriteBits(3, 2); // Face
- else if (splineFlags.final_target)
- data.WriteBits(2, 2); // Face
- else if (splineFlags.final_point)
- data.WriteBits(1, 2); // Face
- else
- data.WriteBits(0, 2); // Face
-
- bool HasJumpGravity = data.WriteBit(moveSpline.splineflags & (MoveSplineFlag::Parabolic | MoveSplineFlag::Animation)); // HasJumpGravity
- bool HasSpecialTime = data.WriteBit((moveSpline.splineflags & MoveSplineFlag::Parabolic) && moveSpline.effect_start_time < moveSpline.Duration()); // HasSpecialTime
-
- data.WriteBits(uint8(moveSpline.spline.mode()), 2); // Mode
-
- data.WriteBit(0); // HasSplineFilterKey
-
- data << int32(moveSpline.timePassed()); // Elapsed
- data << uint32(moveSpline.Duration()); // Duration
- data << float(1.0f); // DurationModifier
- data << float(1.0f); // NextDurationModifier
-
- uint32 PointsCount = moveSpline.getPath().size();
- data << uint32(PointsCount);
-
- if (splineFlags.final_angle) // FaceDirection
- data << moveSpline.facing.angle;
- else if (splineFlags.final_target) // FaceGUID
- data << moveSpline.facing.target;
- else if (splineFlags.final_point) // FaceSpot
- data << moveSpline.facing.f.x << moveSpline.facing.f.y << moveSpline.facing.f.z;
-
- if (HasJumpGravity)
- data << float(moveSpline.vertical_acceleration); // JumpGravity
-
- if (HasSpecialTime)
- data << uint32(moveSpline.effect_start_time); // SpecialTime
-
- //if (HasSplineFilterKey)
- //{
- // data << uint32(FilterKeysCount);
- // for (var i = 0; i < PointsCount; ++i)
- // {
- // data << float(In);
- // data << float(Out);
- // }
-
- // data.WriteBits(FilterFlags, 2);
- //}
-
- data.append<Vector3>(&moveSpline.getPath()[0], PointsCount); // Points
- }
- }
-}
diff --git a/src/server/game/Movement/Spline/MovementPacketBuilder.h b/src/server/game/Movement/Spline/MovementPacketBuilder.h
deleted file mode 100644
index 720c0b3b244..00000000000
--- a/src/server/game/Movement/Spline/MovementPacketBuilder.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
- * Copyright (C) 2005-2011 MaNGOS <http://getmangos.com/>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef TRINITYSERVER_PACKET_BUILDER_H
-#define TRINITYSERVER_PACKET_BUILDER_H
-
-#include "Define.h" // for uint32
-#include "G3D/Vector3.h"
-#include "MovementPackets.h"
-using G3D::Vector3;
-
-class ByteBuffer;
-class WorldPacket;
-
-namespace Movement
-{
- class MoveSpline;
- class PacketBuilder
- {
- public:
- static void WriteMonsterMove(const MoveSpline& mov, WorldPackets::Movement::MovementMonsterSpline& movementMonsterSpline);
- static void WriteCreate(MoveSpline const& moveSpline, ByteBuffer& data);
- };
-}
-#endif // TRINITYSERVER_PACKET_BUILDER_H
diff --git a/src/server/game/Movement/Spline/MovementTypedefs.h b/src/server/game/Movement/Spline/MovementTypedefs.h
index 14c4e19b19b..927707bfd56 100644
--- a/src/server/game/Movement/Spline/MovementTypedefs.h
+++ b/src/server/game/Movement/Spline/MovementTypedefs.h
@@ -21,14 +21,6 @@
#include "Common.h"
-enum MonsterMoveType
-{
- MONSTER_MOVE_NORMAL = 0,
- MONSTER_MOVE_FACING_SPOT = 1,
- MONSTER_MOVE_FACING_TARGET = 2,
- MONSTER_MOVE_FACING_ANGLE = 3
-};
-
namespace G3D
{
class Vector3;
@@ -40,6 +32,14 @@ namespace Movement
using G3D::Vector3;
using G3D::Vector4;
+ enum MonsterMoveType
+ {
+ MONSTER_MOVE_NORMAL = 0,
+ MONSTER_MOVE_FACING_SPOT = 1,
+ MONSTER_MOVE_FACING_TARGET = 2,
+ MONSTER_MOVE_FACING_ANGLE = 3
+ };
+
inline uint32 SecToMS(float sec)
{
return static_cast<uint32>(sec * 1000.f);
diff --git a/src/server/game/Movement/Spline/MovementUtil.cpp b/src/server/game/Movement/Spline/MovementUtil.cpp
index 3f629238948..a7aa84f3680 100644
--- a/src/server/game/Movement/Spline/MovementUtil.cpp
+++ b/src/server/game/Movement/Spline/MovementUtil.cpp
@@ -17,8 +17,6 @@
*/
#include "MoveSplineFlag.h"
-#include <cmath>
-#include <string>
namespace Movement
{
@@ -85,103 +83,100 @@ namespace Movement
return result;
}
- #define STR(x) #x
-
- char const* g_MovementFlag_names[] =
+ char const* MovementFlagNames[] =
{
- STR(Forward ), // 0x00000001,
- STR(Backward ), // 0x00000002,
- STR(Strafe_Left ), // 0x00000004,
- STR(Strafe_Right ), // 0x00000008,
- STR(Turn_Left ), // 0x00000010,
- STR(Turn_Right ), // 0x00000020,
- STR(Pitch_Up ), // 0x00000040,
- STR(Pitch_Down ), // 0x00000080,
-
- STR(Walking ), // 0x00000100, // Walking
- STR(DisableGravity ), // 0x00000200,
- STR(Root ), // 0x00000400,
- STR(Falling ), // 0x00000800,
- STR(FallingFar ), // 0x00001000,
- STR(PendingStop ), // 0x00002000,
- STR(PendingStrafeStop ), // 0x00004000,
- STR(PendingForward ), // 0x00008000,
- STR(PendingBackward ), // 0x00010000,
- STR(PendingStrafeLeft ), // 0x00020000,
- STR(PendingStrafeRight ), // 0x00040000,
- STR(PendingRoot ), // 0x00080000,
- STR(Swimming ), // 0x00100000, // Appears With Fly Flag Also
- STR(Ascending ), // 0x00200000, // Swim Up Also
- STR(Descending ), // 0x00400000, // Swim Down Also
- STR(Can_Fly ), // 0x00800000, // Can Fly In 3.3?
- STR(Flying ), // 0x01000000, // Actual Flying Mode
- STR(Spline_Elevation ), // 0x02000000, // Used For Flight Paths
- STR(Waterwalking ), // 0x04000000, // Prevent Unit From Falling Through Water
- STR(Safe_Fall ), // 0x08000000, // Active Rogue Safe Fall Spell (Passive)
- STR(Hover ), // 0x10000000
- STR(Local_Dirty ), // 0x20000000
- STR(None31 ), // 0x40000000
- STR(None32 ), // 0x80000000
+ STRINGIZE(Forward ), // 0x00000001
+ STRINGIZE(Backward ), // 0x00000002
+ STRINGIZE(Strafe_Left ), // 0x00000004
+ STRINGIZE(Strafe_Right ), // 0x00000008
+ STRINGIZE(Turn_Left ), // 0x00000010
+ STRINGIZE(Turn_Right ), // 0x00000020
+ STRINGIZE(Pitch_Up ), // 0x00000040
+ STRINGIZE(Pitch_Down ), // 0x00000080
+ STRINGIZE(Walking ), // 0x00000100 // Walking
+ STRINGIZE(DisableGravity ), // 0x00000200
+ STRINGIZE(Root ), // 0x00000400
+ STRINGIZE(Falling ), // 0x00000800
+ STRINGIZE(FallingFar ), // 0x00001000
+ STRINGIZE(PendingStop ), // 0x00002000
+ STRINGIZE(PendingStrafeStop ), // 0x00004000
+ STRINGIZE(PendingForward ), // 0x00008000
+ STRINGIZE(PendingBackward ), // 0x00010000
+ STRINGIZE(PendingStrafeLeft ), // 0x00020000
+ STRINGIZE(PendingStrafeRight), // 0x00040000
+ STRINGIZE(PendingRoot ), // 0x00080000
+ STRINGIZE(Swimming ), // 0x00100000 // Appears With Fly Flag Also
+ STRINGIZE(Ascending ), // 0x00200000 // Swim Up Also
+ STRINGIZE(Descending ), // 0x00400000 // Swim Down Also
+ STRINGIZE(Can_Fly ), // 0x00800000 // Can Fly In 3.3?
+ STRINGIZE(Flying ), // 0x01000000 // Actual Flying Mode
+ STRINGIZE(Spline_Elevation ), // 0x02000000 // Used For Flight Paths
+ STRINGIZE(Waterwalking ), // 0x04000000 // Prevent Unit From Falling Through Water
+ STRINGIZE(Safe_Fall ), // 0x08000000 // Active Rogue Safe Fall Spell (Passive)
+ STRINGIZE(Hover ), // 0x10000000
+ STRINGIZE(Local_Dirty ), // 0x20000000
+ STRINGIZE(None31 ), // 0x40000000
+ STRINGIZE(None32 ), // 0x80000000
};
- char const* g_MovementFlagExtra_names[] =
+ char const* MovementFlagExtraNames[] =
{
- STR(NoStrafe ),
- STR(NoJump ),
- STR(FullSpeedTurning ),
- STR(FullSpeedPitching ),
- STR(Allow_Pitching ),
- STR(Unk6 ),
- STR(Unk7 ),
- STR(Unk8 ),
- STR(Unk9 ),
- STR(Unk10 ),
- STR(Unk11 ),
- STR(Unk12 ),
- STR(Unk13 ),
- STR(Interpolated_Movement),
- STR(Interpolated_Turning ),
- STR(Interpolated_Pitching),
+ STRINGIZE(NoStrafe ),
+ STRINGIZE(NoJump ),
+ STRINGIZE(FullSpeedTurning ),
+ STRINGIZE(FullSpeedPitching ),
+ STRINGIZE(Allow_Pitching ),
+ STRINGIZE(Unk6 ),
+ STRINGIZE(Unk7 ),
+ STRINGIZE(Unk8 ),
+ STRINGIZE(Unk9 ),
+ STRINGIZE(Unk10 ),
+ STRINGIZE(Unk11 ),
+ STRINGIZE(Unk12 ),
+ STRINGIZE(Unk13 ),
+ STRINGIZE(Interpolated_Movement),
+ STRINGIZE(Interpolated_Turning ),
+ STRINGIZE(Interpolated_Pitching),
};
- char const* g_SplineFlag_names[32] =
+ char const* SplineFlagNames[32] =
{
- STR(AnimBit1 ), // 0x00000001,
- STR(AnimBit2 ), // 0x00000002,
- STR(AnimBit3 ), // 0x00000004,
- STR(Unknown0 ), // 0x00000008,
- STR(FallingSlow ), // 0x00000010,
- STR(Done ), // 0x00000020,
- STR(Falling ), // 0x00000040, // Not Compartible With Trajectory Movement
- STR(No_Spline ), // 0x00000080,
- STR(Unknown2 ), // 0x00000100,
- STR(Flying ), // 0x00000200, // Smooth Movement(Catmullrom Interpolation Mode), Flying Animation
- STR(OrientationFixed ), // 0x00000400, // Model Orientation Fixed
- STR(Catmullrom ), // 0x00000800, // Used Catmullrom Interpolation Mode
- STR(Cyclic ), // 0x00001000, // Movement By Cycled Spline
- STR(Enter_Cycle ), // 0x00002000, // Everytime Appears With Cyclic Flag In Monster Move Packet
- STR(Frozen ), // 0x00004000,
- STR(TransportEnter ), // 0x00008000
- STR(TransportExit ), // 0x00010000
- STR(Unknown3 ), // 0x00020000,
- STR(Unknown4 ), // 0x00040000,
- STR(OrientationInversed), // 0x00080000, // Appears With Runmode Flag, Nodes ), // 1, Handles Orientation
- STR(SmoothGroundPath ), // 0x00100000,
- STR(Walkmode ), // 0x00200000,
- STR(UncompressedPath ), // 0x00400000,
- STR(Unknown6 ), // 0x00800000,
- STR(Animation ), // 0x01000000, // Animationid (0...3), Uint32 Time, Not Compartible With Trajectory And Fall Movement
- STR(Parabolic ), // 0x02000000, // Not Compartible With Fall Movement
- STR(Final_Point ), // 0x04000000,
- STR(Final_Target ), // 0x08000000,
- STR(Final_Angle ), // 0x10000000,
- STR(Unknown7 ), // 0x20000000,
- STR(Unknown8 ), // 0x40000000,
- STR(Unknown9 ), // 0x80000000,
+ STRINGIZE(AnimBit1 ), // 0x00000001
+ STRINGIZE(AnimBit2 ), // 0x00000002
+ STRINGIZE(AnimBit3 ), // 0x00000004
+ STRINGIZE(Unknown0 ), // 0x00000008
+ STRINGIZE(FallingSlow ), // 0x00000010
+ STRINGIZE(Done ), // 0x00000020
+ STRINGIZE(Falling ), // 0x00000040 // Not Compartible With Trajectory Movement
+ STRINGIZE(No_Spline ), // 0x00000080
+ STRINGIZE(Unknown2 ), // 0x00000100
+ STRINGIZE(Flying ), // 0x00000200 // Smooth Movement(Catmullrom Interpolation Mode), Flying Animation
+ STRINGIZE(OrientationFixed ), // 0x00000400 // Model Orientation Fixed
+ STRINGIZE(Catmullrom ), // 0x00000800 // Used Catmullrom Interpolation Mode
+ STRINGIZE(Cyclic ), // 0x00001000 // Movement By Cycled Spline
+ STRINGIZE(Enter_Cycle ), // 0x00002000 // Everytime Appears With Cyclic Flag In Monster Move Packet
+ STRINGIZE(Frozen ), // 0x00004000
+ STRINGIZE(TransportEnter ), // 0x00008000
+ STRINGIZE(TransportExit ), // 0x00010000
+ STRINGIZE(Unknown3 ), // 0x00020000
+ STRINGIZE(Unknown4 ), // 0x00040000
+ STRINGIZE(OrientationInversed), // 0x00080000 // Appears With Runmode Flag, Nodes ), // 1, Handles Orientation
+ STRINGIZE(SmoothGroundPath ), // 0x00100000
+ STRINGIZE(Walkmode ), // 0x00200000
+ STRINGIZE(UncompressedPath ), // 0x00400000
+ STRINGIZE(Unknown6 ), // 0x00800000
+ STRINGIZE(Animation ), // 0x01000000 // Animationid (0...3), Uint32 Time, Not Compartible With Trajectory And Fall Movement
+ STRINGIZE(Parabolic ), // 0x02000000 // Not Compartible With Fall Movement
+ STRINGIZE(Final_Point ), // 0x04000000
+ STRINGIZE(Final_Target ), // 0x08000000
+ STRINGIZE(Final_Angle ), // 0x10000000
+ STRINGIZE(Unknown7 ), // 0x20000000
+ STRINGIZE(Unknown8 ), // 0x40000000
+ STRINGIZE(Unknown9 ), // 0x80000000
};
template<class Flags, int N>
- void print_flags(Flags t, char const* (&names)[N], std::string& str)
+ void PrintFlags(Flags t, char const* (&names)[N], std::string& str)
{
for (int i = 0; i < N; ++i)
{
@@ -193,21 +188,21 @@ namespace Movement
std::string MoveSplineFlag::ToString() const
{
std::string str;
- print_flags(raw(), g_SplineFlag_names, str);
+ PrintFlags(raw(), SplineFlagNames, str);
return str;
}
std::string MovementFlags_ToString(uint32 flags)
{
std::string str;
- print_flags(flags, g_MovementFlag_names, str);
+ PrintFlags(flags, MovementFlagNames, str);
return str;
}
std::string MovementFlagsExtra_ToString(uint32 flags)
{
std::string str;
- print_flags(flags, g_MovementFlagExtra_names, str);
+ PrintFlags(flags, MovementFlagExtraNames, str);
return str;
}
}
diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h
index cfbf3241019..75981d30368 100644
--- a/src/server/game/Quests/QuestDef.h
+++ b/src/server/game/Quests/QuestDef.h
@@ -434,7 +434,7 @@ class Quest
uint32 EmoteOnCompleteDelay = 0;
uint32 EmoteOnIncompleteDelay = 0;
std::string RequestItemsText;
-
+
// quest_offer_reward table
uint32 OfferRewardEmote[QUEST_EMOTE_COUNT] = {};
uint32 OfferRewardEmoteDelay[QUEST_EMOTE_COUNT] = {};
@@ -469,4 +469,5 @@ struct QuestStatusData
uint32 Timer;
std::vector<int32> ObjectiveData;
};
+
#endif
diff --git a/src/server/game/Reputation/ReputationMgr.cpp b/src/server/game/Reputation/ReputationMgr.cpp
index 3bf3464f016..0a0980691ed 100644
--- a/src/server/game/Reputation/ReputationMgr.cpp
+++ b/src/server/game/Reputation/ReputationMgr.cpp
@@ -243,7 +243,7 @@ void ReputationMgr::Initialize()
{
FactionEntry const* factionEntry = sFactionStore.LookupEntry(i);
- if (factionEntry && (factionEntry->ReputationIndex >= 0))
+ if (factionEntry && factionEntry->CanHaveReputation())
{
FactionState newFaction;
newFaction.ID = factionEntry->ID;
@@ -395,7 +395,7 @@ void ReputationMgr::SetVisible(FactionTemplateEntry const* factionTemplateEntry)
void ReputationMgr::SetVisible(FactionEntry const* factionEntry)
{
- if (factionEntry->ReputationIndex < 0)
+ if (!factionEntry->CanHaveReputation())
return;
FactionStateList::iterator itr = _factions.find(factionEntry->ReputationIndex);
@@ -499,7 +499,7 @@ void ReputationMgr::LoadFromDB(PreparedQueryResult result)
Field* fields = result->Fetch();
FactionEntry const* factionEntry = sFactionStore.LookupEntry(fields[0].GetUInt16());
- if (factionEntry && (factionEntry->ReputationIndex >= 0))
+ if (factionEntry && factionEntry->CanHaveReputation())
{
FactionState* faction = &_factions[factionEntry->ReputationIndex];
diff --git a/src/server/game/Server/Packets/CombatLogPackets.h b/src/server/game/Server/Packets/CombatLogPackets.h
index 6cca0127ef6..b72bb1b883e 100644
--- a/src/server/game/Server/Packets/CombatLogPackets.h
+++ b/src/server/game/Server/Packets/CombatLogPackets.h
@@ -32,19 +32,19 @@ namespace WorldPackets
WorldPacket const* Write() override;
- int32 Absorbed;
- int32 ShieldBlock;
+ int32 Absorbed = 0;
+ int32 ShieldBlock = 0;
ObjectGuid Me;
- int32 SpellID;
- int32 Resisted;
- bool Periodic;
- uint8 SchoolMask;
+ int32 SpellID = 0;
+ int32 Resisted = 0;
+ bool Periodic = 0.0f;
+ uint8 SchoolMask = 0;
ObjectGuid CasterGUID;
Optional<Spells::SpellCastLogData> LogData;
- int32 Damage;
+ int32 Damage = 0;
// Optional<SpellNonMeleeDamageLogDebugInfo> Debug Info;
- int32 Flags;
- int32 Overkill;
+ int32 Flags = 0;
+ int32 Overkill = 0;
};
}
}
diff --git a/src/server/game/Server/Packets/MovementPackets.cpp b/src/server/game/Server/Packets/MovementPackets.cpp
index c4621495e3d..78f00e613cf 100644
--- a/src/server/game/Server/Packets/MovementPackets.cpp
+++ b/src/server/game/Server/Packets/MovementPackets.cpp
@@ -16,6 +16,8 @@
*/
#include "MovementPackets.h"
+#include "MoveSpline.h"
+#include "MoveSplineFlag.h"
#include "MovementTypedefs.h"
#include "Unit.h"
@@ -34,8 +36,6 @@ ByteBuffer& operator>>(ByteBuffer& data, G3D::Vector3& v)
ByteBuffer& operator<<(ByteBuffer& data, MovementInfo& movementInfo)
{
bool hasTransportData = !movementInfo.transport.guid.IsEmpty();
- bool hasTransportPrevTime = hasTransportData && movementInfo.transport.prevTime != 0;
- bool hasTransportVehicleId = hasTransportData && movementInfo.transport.vehicleId != 0;
bool hasFallDirection = movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR);
bool hasFallData = hasFallDirection || movementInfo.jump.fallTime != 0;
@@ -66,21 +66,7 @@ ByteBuffer& operator<<(ByteBuffer& data, MovementInfo& movementInfo)
data.WriteBit(0); // RemoteTimeValid
if (hasTransportData)
- {
- data << movementInfo.transport.guid;
- data << movementInfo.transport.pos.PositionXYZOStream();
- data << movementInfo.transport.seat;
- data << movementInfo.transport.time;
-
- data.WriteBit(hasTransportPrevTime);
- data.WriteBit(hasTransportVehicleId);
-
- if (hasTransportPrevTime)
- data << movementInfo.transport.prevTime;
-
- if (hasTransportVehicleId)
- data << movementInfo.transport.vehicleId;
- }
+ data << movementInfo.transport;
if (hasFallData)
{
@@ -131,21 +117,7 @@ ByteBuffer& operator>>(ByteBuffer& data, MovementInfo& movementInfo)
data.ReadBit(); // RemoteTimeValid
if (hasTransport)
- {
- data >> movementInfo.transport.guid;
- data >> movementInfo.transport.pos.PositionXYZOStream();
- data >> movementInfo.transport.seat;
- data >> movementInfo.transport.time;
-
- bool hasPrevTime = data.ReadBit();
- bool hasVehicleId = data.ReadBit();
-
- if (hasPrevTime)
- data >> movementInfo.transport.prevTime;
-
- if (hasVehicleId)
- data >> movementInfo.transport.vehicleId;
- }
+ data >> movementInfo.transport;
if (hasFall)
{
@@ -166,12 +138,58 @@ ByteBuffer& operator>>(ByteBuffer& data, MovementInfo& movementInfo)
return data;
}
+ByteBuffer& operator>>(ByteBuffer& data, MovementInfo::TransportInfo& transportInfo)
+{
+ data >> transportInfo.guid; // Transport Guid
+ data >> transportInfo.pos.PositionXYZOStream();
+ data >> transportInfo.seat; // VehicleSeatIndex
+ data >> transportInfo.time; // MoveTime
+
+ bool hasPrevTime = data.ReadBit();
+ bool hasVehicleId = data.ReadBit();
+
+ if (hasPrevTime)
+ data >> transportInfo.prevTime; // PrevMoveTime
+
+ if (hasVehicleId)
+ data >> transportInfo.vehicleId; // VehicleRecID
+
+ return data;
+}
+
+ByteBuffer& operator<<(ByteBuffer& data, MovementInfo::TransportInfo const& transportInfo)
+{
+ bool hasPrevTime = transportInfo.prevTime != 0;
+ bool hasVehicleId = transportInfo.vehicleId != 0;
+
+ data << transportInfo.guid; // Transport Guid
+ data << transportInfo.pos.GetPositionX();
+ data << transportInfo.pos.GetPositionY();
+ data << transportInfo.pos.GetPositionZ();
+ data << transportInfo.pos.GetOrientation();
+ data << transportInfo.seat; // VehicleSeatIndex
+ data << transportInfo.time; // MoveTime
+
+ data.WriteBit(hasPrevTime);
+ data.WriteBit(hasVehicleId);
+
+ if (hasPrevTime)
+ data << transportInfo.prevTime; // PrevMoveTime
+
+ if (hasVehicleId)
+ data << transportInfo.vehicleId; // VehicleRecID
+
+ data.FlushBits();
+
+ return data;
+}
+
void WorldPackets::Movement::ClientPlayerMovement::Read()
{
_worldPacket >> movementInfo;
}
-ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MonsterSplineFilterKey& monsterSplineFilterKey)
+ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MonsterSplineFilterKey const& monsterSplineFilterKey)
{
data << monsterSplineFilterKey.Idx;
data << monsterSplineFilterKey.Speed;
@@ -179,13 +197,13 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MonsterSplineFi
return data;
}
-ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MonsterSplineFilter& monsterSplineFilter)
+ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MonsterSplineFilter const& monsterSplineFilter)
{
data << uint32(monsterSplineFilter.FilterKeys.size());
data << monsterSplineFilter.BaseSpeed;
data << monsterSplineFilter.StartOffset;
data << monsterSplineFilter.DistToPrevFilterKey;
- for (WorldPackets::Movement::MonsterSplineFilterKey& filterKey : monsterSplineFilter.FilterKeys)
+ for (WorldPackets::Movement::MonsterSplineFilterKey const& filterKey : monsterSplineFilter.FilterKeys)
data << filterKey;
data << monsterSplineFilter.AddedToStart;
data.WriteBits(monsterSplineFilter.FilterFlags, 2);
@@ -194,7 +212,7 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MonsterSplineFi
return data;
}
-ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MovementSpline& movementSpline)
+ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MovementSpline const& movementSpline)
{
data << movementSpline.Flags;
data << movementSpline.AnimTier;
@@ -219,14 +237,14 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MovementSpline&
switch (movementSpline.Face)
{
- case MONSTER_MOVE_FACING_SPOT:
+ case ::Movement::MONSTER_MOVE_FACING_SPOT:
data << movementSpline.FaceSpot;
break;
- case MONSTER_MOVE_FACING_TARGET:
+ case ::Movement::MONSTER_MOVE_FACING_TARGET:
data << movementSpline.FaceDirection;
data << movementSpline.FaceGUID;
break;
- case MONSTER_MOVE_FACING_ANGLE:
+ case ::Movement::MONSTER_MOVE_FACING_ANGLE:
data << movementSpline.FaceDirection;
break;
}
@@ -237,7 +255,7 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MovementSpline&
return data;
}
-ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MovementMonsterSpline& movementMonsterSpline)
+ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MovementMonsterSpline const& movementMonsterSpline)
{
data << movementMonsterSpline.ID;
data << movementMonsterSpline.Destination;
@@ -255,6 +273,166 @@ ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MovementMonster
return data;
}
+void WorldPackets::Movement::CommonMovement::WriteCreateObjectSplineDataBlock(::Movement::MoveSpline const& moveSpline, ByteBuffer& data)
+{
+ data << uint32(moveSpline.GetId()); // ID
+ if (!moveSpline.isCyclic()) // Destination
+ {
+ G3D::Vector3 dest = moveSpline.FinalDestination();
+ data << float(dest.z);
+ data << float(dest.x);
+ data << float(dest.y);
+ }
+ else
+ data << G3D::Vector3::zero();
+
+ if (data.WriteBit(!moveSpline.Finalized())) // MovementSplineMove
+ {
+ data.FlushBits();
+
+ ::Movement::MoveSplineFlag const& splineFlags = moveSpline.splineflags;
+
+ data.WriteBits(moveSpline.splineflags.raw(), 25); // SplineFlags
+
+ uint8 face = ::Movement::MONSTER_MOVE_NORMAL;
+ if (splineFlags.final_angle)
+ face = ::Movement::MONSTER_MOVE_FACING_ANGLE;
+ else if (splineFlags.final_target)
+ face = ::Movement::MONSTER_MOVE_FACING_TARGET;
+ else if (splineFlags.final_point)
+ face = ::Movement::MONSTER_MOVE_FACING_SPOT;
+
+ data.WriteBits(face, 2); // Face
+
+ bool HasJumpGravity = data.WriteBit(moveSpline.splineflags & (::Movement::MoveSplineFlag::Parabolic | ::Movement::MoveSplineFlag::Animation)); // HasJumpGravity
+ bool HasSpecialTime = data.WriteBit((moveSpline.splineflags & ::Movement::MoveSplineFlag::Parabolic) && moveSpline.effect_start_time < moveSpline.Duration()); // HasSpecialTime
+
+ data.WriteBits(uint8(moveSpline.spline.mode()), 2); // Mode
+
+ data.WriteBit(0); // HasSplineFilterKey
+
+ data << int32(moveSpline.timePassed()); // Elapsed
+ data << uint32(moveSpline.Duration()); // Duration
+ data << float(1.0f); // DurationModifier
+ data << float(1.0f); // NextDurationModifier
+
+ uint32 PointsCount = moveSpline.getPath().size();
+ data << uint32(PointsCount);
+
+ switch (face)
+ {
+ case ::Movement::MONSTER_MOVE_FACING_SPOT:
+ data << moveSpline.facing.f; // FaceSpot
+ break;
+ case ::Movement::MONSTER_MOVE_FACING_TARGET:
+ data << moveSpline.facing.target; // FaceGUID
+ break;
+ case ::Movement::MONSTER_MOVE_FACING_ANGLE:
+ data << moveSpline.facing.angle; // FaceDirection
+ break;
+ }
+
+ if (HasJumpGravity)
+ data << float(moveSpline.vertical_acceleration); // JumpGravity
+
+ if (HasSpecialTime)
+ data << uint32(moveSpline.effect_start_time); // SpecialTime
+
+ //if (HasSplineFilterKey)
+ //{
+ // data << uint32(FilterKeysCount);
+ // for (var i = 0; i < PointsCount; ++i)
+ // {
+ // data << float(In);
+ // data << float(Out);
+ // }
+
+ // data.WriteBits(FilterFlags, 2);
+ //}
+
+ data.append<G3D::Vector3>(&moveSpline.getPath()[0], PointsCount); // Points
+ }
+}
+
+void WorldPackets::Movement::MonsterMove::InitializeSplineData(::Movement::MoveSpline const& moveSpline)
+{
+ SplineData.ID = moveSpline.m_Id;
+ WorldPackets::Movement::MovementSpline& movementSpline = SplineData.Move;
+
+ ::Movement::MoveSplineFlag splineFlags = moveSpline.splineflags;
+ splineFlags.enter_cycle = moveSpline.isCyclic();
+ movementSpline.Flags = uint32(splineFlags & uint32(~::Movement::MoveSplineFlag::Mask_No_Monster_Move));
+
+ switch (moveSpline.splineflags & ::Movement::MoveSplineFlag::Mask_Final_Facing)
+ {
+ case ::Movement::MoveSplineFlag::Final_Point:
+ movementSpline.Face = ::Movement::MONSTER_MOVE_FACING_SPOT;
+ movementSpline.FaceSpot = moveSpline.facing.f;
+ break;
+ case ::Movement::MoveSplineFlag::Final_Target:
+ movementSpline.Face = ::Movement::MONSTER_MOVE_FACING_TARGET;
+ movementSpline.FaceGUID = moveSpline.facing.target;
+ break;
+ case ::Movement::MoveSplineFlag::Final_Angle:
+ movementSpline.Face = ::Movement::MONSTER_MOVE_FACING_ANGLE;
+ movementSpline.FaceDirection = moveSpline.facing.angle;
+ break;
+ default:
+ movementSpline.Face = ::Movement::MONSTER_MOVE_NORMAL;
+ break;
+ }
+
+ if (splineFlags.animation)
+ {
+ movementSpline.AnimTier = splineFlags.getAnimationId();
+ movementSpline.TierTransStartTime = moveSpline.effect_start_time;
+ }
+
+ movementSpline.MoveTime = moveSpline.Duration();
+
+ if (splineFlags.parabolic)
+ {
+ movementSpline.JumpGravity = moveSpline.vertical_acceleration;
+ movementSpline.SpecialTime = moveSpline.effect_start_time;
+ }
+
+ ::Movement::Spline<int32> const& spline = moveSpline.spline;
+ std::vector<G3D::Vector3> const& array = spline.getPoints();
+
+ if (splineFlags & ::Movement::MoveSplineFlag::UncompressedPath)
+ {
+ if (!splineFlags.cyclic)
+ {
+ uint32 count = spline.getPointCount() - 3;
+ for (uint32 i = 2; i < count; ++i)
+ movementSpline.Points.push_back(array[i]);
+ }
+ else
+ {
+ uint32 count = spline.getPointCount() - 3;
+ movementSpline.Points.push_back(array[1]);
+ for (uint32 i = 1; i < count; ++i)
+ movementSpline.Points.push_back(array[i]);
+ }
+ }
+ else
+ {
+ uint32 lastIdx = spline.getPointCount() - 3;
+ G3D::Vector3 const* realPath = &spline.getPoint(1);
+
+ movementSpline.Points.push_back(realPath[lastIdx]);
+
+ if (lastIdx > 1)
+ {
+ G3D::Vector3 middle = (realPath[0] + realPath[lastIdx]) / 2.f;
+
+ // first and last points already appended
+ for (uint32 i = 1; i < lastIdx; ++i)
+ movementSpline.PackedDeltas.push_back(middle - realPath[i]);
+ }
+ }
+}
+
WorldPacket const* WorldPackets::Movement::MonsterMove::Write()
{
_worldPacket << MoverGUID;
diff --git a/src/server/game/Server/Packets/MovementPackets.h b/src/server/game/Server/Packets/MovementPackets.h
index 6d5d10526b3..b30be8cfb6f 100644
--- a/src/server/game/Server/Packets/MovementPackets.h
+++ b/src/server/game/Server/Packets/MovementPackets.h
@@ -20,8 +20,14 @@
#include "Packet.h"
#include "Object.h"
+
#include <G3D/Vector3.h>
+namespace Movement
+{
+ class MoveSpline;
+}
+
namespace WorldPackets
{
namespace Movement
@@ -92,11 +98,19 @@ namespace WorldPackets
MovementSpline Move;
};
+ class CommonMovement
+ {
+ public:
+ static void WriteCreateObjectSplineDataBlock(::Movement::MoveSpline const& moveSpline, ByteBuffer& data);
+ };
+
class MonsterMove final : public ServerPacket
{
public:
MonsterMove() : ServerPacket(SMSG_MONSTER_MOVE) { }
+ void InitializeSplineData(::Movement::MoveSpline const& moveSpline);
+
WorldPacket const* Write() override;
MovementMonsterSpline SplineData;
@@ -280,6 +294,9 @@ ByteBuffer& operator>>(ByteBuffer& data, G3D::Vector3& v);
ByteBuffer& operator>>(ByteBuffer& data, MovementInfo& movementInfo);
ByteBuffer& operator<<(ByteBuffer& data, MovementInfo& movementInfo);
+ByteBuffer& operator>>(ByteBuffer& data, MovementInfo::TransportInfo& transportInfo);
+ByteBuffer& operator<<(ByteBuffer& data, MovementInfo::TransportInfo const& transportInfo);
+
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MonsterSplineFilterKey const& monsterSplineFilterKey);
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MonsterSplineFilter const& monsterSplineFilter);
ByteBuffer& operator<<(ByteBuffer& data, WorldPackets::Movement::MovementSpline const& movementSpline);
diff --git a/src/server/game/Server/Packets/QueryPackets.cpp b/src/server/game/Server/Packets/QueryPackets.cpp
index e80312c7adb..57b67f3a737 100644
--- a/src/server/game/Server/Packets/QueryPackets.cpp
+++ b/src/server/game/Server/Packets/QueryPackets.cpp
@@ -174,6 +174,8 @@ WorldPacket const* WorldPackets::Query::QueryNPCTextResponse::Write()
_worldPacket << BroadcastTextID[i];
}
+ _worldPacket.FlushBits();
+
return &_worldPacket;
}
@@ -182,7 +184,6 @@ void WorldPackets::Query::DBQueryBulk::Read()
_worldPacket >> TableHash;
uint32 count = _worldPacket.ReadBits(13);
- _worldPacket.ResetBitPos();
Queries.resize(count);
for (uint32 i = 0; i < count; ++i)
@@ -204,7 +205,7 @@ WorldPacket const* WorldPackets::Query::DBReply::Write()
if (Data)
Data->WriteRecord(RecordID, Locale, _worldPacket);
- _worldPacket.put<int32>(sizePos, _worldPacket.wpos() - sizePos - 4);
+ _worldPacket.put<int32>(sizePos, _worldPacket.wpos() - sizePos - sizeof(int32));
return &_worldPacket;
}
@@ -224,13 +225,13 @@ WorldPacket const* WorldPackets::Query::HotfixNotifyBlob::Write()
void WorldPackets::Query::QueryGameObject::Read()
{
- _worldPacket >> Entry;
+ _worldPacket >> GameObjectID;
_worldPacket >> Guid;
}
WorldPacket const* WorldPackets::Query::QueryGameObjectResponse::Write()
{
- _worldPacket << Entry;
+ _worldPacket << GameObjectID;
_worldPacket.WriteBit(Allow);
if (Allow)
diff --git a/src/server/game/Server/Packets/QueryPackets.h b/src/server/game/Server/Packets/QueryPackets.h
index 211f0cbf46b..7f4dbd77ab3 100644
--- a/src/server/game/Server/Packets/QueryPackets.h
+++ b/src/server/game/Server/Packets/QueryPackets.h
@@ -1,27 +1,27 @@
/*
-* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
-*
-* This program is free software; you can redistribute it and/or modify it
-* under the terms of the GNU General Public License as published by the
-* Free Software Foundation; either version 2 of the License, or (at your
-* option) any later version.
-*
-* This program is distributed in the hope that it will be useful, but WITHOUT
-* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-* more details.
-*
-* You should have received a copy of the GNU General Public License along
-* with this program. If not, see <http://www.gnu.org/licenses/>.
-*/
+ * Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
#ifndef QueryPackets_h__
#define QueryPackets_h__
#include "Packet.h"
#include "Creature.h"
-#include "NPCHandler.h"
#include "DB2Stores.h"
+#include "NPCHandler.h"
namespace WorldPackets
{
@@ -168,15 +168,15 @@ namespace WorldPackets
uint32 BroadcastTextID[MAX_GOSSIP_TEXT_OPTIONS];
};
- struct DBQueryRecord
- {
- ObjectGuid GUID;
- uint32 RecordID;
- };
-
class DBQueryBulk final : public ClientPacket
{
public:
+ struct DBQueryRecord
+ {
+ ObjectGuid GUID;
+ int32 RecordID = 0;
+ };
+
DBQueryBulk(WorldPacket&& packet) : ClientPacket(CMSG_DB_QUERY_BULK, std::move(packet)) { }
void Read() override;
@@ -217,8 +217,9 @@ namespace WorldPackets
QueryGameObject(WorldPacket&& packet) : ClientPacket(CMSG_GAMEOBJECT_QUERY, std::move(packet)) { }
void Read() override;
- uint32 Entry = 0;
+
ObjectGuid Guid;
+ uint32 GameObjectID = 0;
};
struct GameObjectStats
@@ -236,17 +237,19 @@ namespace WorldPackets
size_t GetDataSize() const
{
- return sizeof(Type) + sizeof(DisplayID) + (Name->length() + (4 * 1)) + (IconName.size() + 1) + (CastBarCaption.size() + 1) + (UnkString.size() + 1) + sizeof(Data) + sizeof(Size) + sizeof(uint8) + (QuestItems.size() * sizeof(uint32)) + sizeof(Expansion);
+ // [1..3] always empty '\0' '\0' '\0' '\0' QuestItems counter
+ return sizeof(Type) + sizeof(DisplayID) + (Name->length() + (4 * 1)) + (IconName.size() + 1) + (CastBarCaption.size() + 1) + (UnkString.size() + 1) + sizeof(Data) + sizeof(Size) + sizeof(uint8) + (QuestItems.size() * sizeof(int32)) + sizeof(Expansion);
}
};
class QueryGameObjectResponse final : public ServerPacket
{
public:
- QueryGameObjectResponse() : ServerPacket(SMSG_GAMEOBJECT_QUERY_RESPONSE, 165) { } // Guess size
+ QueryGameObjectResponse() : ServerPacket(SMSG_GAMEOBJECT_QUERY_RESPONSE, 165) { }
WorldPacket const* Write() override;
- uint32 Entry = 0;
+
+ uint32 GameObjectID = 0;
bool Allow = false;
GameObjectStats Stats;
};
diff --git a/src/server/game/Server/Packets/SpellPackets.h b/src/server/game/Server/Packets/SpellPackets.h
index 98882fc2e26..18d3df5b00d 100644
--- a/src/server/game/Server/Packets/SpellPackets.h
+++ b/src/server/game/Server/Packets/SpellPackets.h
@@ -120,7 +120,7 @@ namespace WorldPackets
WorldPacket const* Write() override;
void Init(bool IsFullUpdate, ObjectGuid Target, uint32 Count);
void BuildUpdatePacket(AuraApplication* aurApp, bool remove, uint16 level);
- };
+ };
class SpellCastRequest final : public ClientPacket
{
@@ -133,34 +133,34 @@ namespace WorldPackets
void Read() override;
ObjectGuid PetGuid;
- uint8 CastID;
- uint32 SpellID;
- uint32 Misc;
- uint32 TargetFlags;
+ uint8 CastID = 0;
+ uint32 SpellID = 0;
+ uint32 Misc = 0;
+ uint32 TargetFlags = 0;
ObjectGuid UnitGuid;
ObjectGuid ItemGuid;
-
+
ObjectGuid SrcTransportGuid;
ObjectGuid DstTransportGuid;
Position SrcPos;
Position DstPos;
- float Orientation;
+ float Orientation = 0.0f;
std::string Name;
- float Pitch;
- float Speed;
+ float Pitch = 0.0f;
+ float Speed = 0.0f;
ObjectGuid Guid;
- uint32 SendCastFlags;
+ uint32 SendCastFlags = 0;
MovementInfo movementInfo;
};
-
+
struct TargetLocation
{
ObjectGuid Transport;
Position Location;
};
-
+
struct SpellTargetData
{
uint32 Flags = 0;
@@ -171,49 +171,49 @@ namespace WorldPackets
Optional<float> Orientation; // Not found in JAM structures
std::string Name;
};
-
+
struct SpellMissStatus
{
uint8 Reason = 0;
uint8 ReflectStatus = 0;
};
-
+
struct SpellPowerData
{
int32 Cost = 0;
int8 Type = 0;
};
-
+
struct RuneData
{
uint8 Start = 0;
uint8 Count = 0;
std::vector<uint8> Cooldowns;
};
-
+
struct MissileTrajectoryResult
{
uint32 TravelTime = 0;
float Pitch = 0.0f;
};
-
+
struct SpellAmmo
{
int32 DisplayID = 0;
int8 InventoryType = 0;
};
-
+
struct ProjectileVisualData
{
int32 ID[2];
};
-
+
struct CreatureImmunities
{
uint32 School = 0;
uint32 Value = 0;
};
-
+
struct SpellHealPrediction
{
ObjectGuid BeaconGUID;
diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp
index 85a639b6161..1612b01ccd2 100644
--- a/src/server/game/Server/Protocol/Opcodes.cpp
+++ b/src/server/game/Server/Protocol/Opcodes.cpp
@@ -18,13 +18,16 @@
#include "Opcodes.h"
#include "WorldSession.h"
+#include "Packets/AchievementPackets.h"
#include "Packets/CharacterPackets.h"
#include "Packets/ChannelPackets.h"
#include "Packets/ChatPackets.h"
#include "Packets/ClientConfigPackets.h"
#include "Packets/CombatPackets.h"
#include "Packets/EquipmentSetPackets.h"
+#include "Packets/GameObjectPackets.h"
#include "Packets/GuildPackets.h"
+#include "Packets/ItemPackets.h"
#include "Packets/MiscPackets.h"
#include "Packets/MovementPackets.h"
#include "Packets/NPCPackets.h"
@@ -32,8 +35,6 @@
#include "Packets/QuestPackets.h"
#include "Packets/TalentPackets.h"
#include "Packets/TradePackets.h"
-#include "Packets/ItemPackets.h"
-#include "Packets/GameObjectPackets.h"
template<class PacketClass, void(WorldSession::*HandlerFunction)(PacketClass&)>
class PacketHandler : public ClientOpcodeHandler
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index b8d9020e440..68b89af6ce6 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -416,7 +416,7 @@ class WorldSession
void SetSecurity(AccountTypes security) { _security = security; }
std::string const& GetRemoteAddress() { return m_Address; }
void SetPlayer(Player* player);
- uint8 Expansion() const { return m_expansion; }
+ uint8 GetExpansion() const { return m_expansion; }
void InitWarden(BigNumber* k, std::string const& os);
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 9daf32188df..72653d700ec 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -2110,9 +2110,12 @@ void Spell::CleanupTargetList()
void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*= true*/, bool implicit /*= true*/, Position const* losPosition /*= nullptr*/)
{
+ uint32 validEffectMask = 0;
for (SpellEffectInfo const* effect : GetEffects())
- if (effect && (!effect->IsEffect() || !CheckEffectTarget(target, effect->EffectIndex, losPosition)))
- effectMask &= ~(1 << effect->EffectIndex);
+ if (effect && (effectMask & effect->EffectIndex) != 0 && CheckEffectTarget(target, effect, losPosition))
+ validEffectMask |= 1 << effect->EffectIndex;
+
+ effectMask &= validEffectMask;
// no effects left
if (!effectMask)
@@ -2218,29 +2221,14 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
void Spell::AddGOTarget(GameObject* go, uint32 effectMask)
{
+ uint32 validEffectMask = 0;
for (SpellEffectInfo const* effect : GetEffects())
- {
- if (!effect)
- continue;
+ if (effect && (effectMask & effect->EffectIndex) != 0 && CheckEffectTarget(go, effect))
+ validEffectMask |= 1 << effect->EffectIndex;
- if (!effect->IsEffect())
- effectMask &= ~(1 << effect->EffectIndex);
- else
- {
- switch (effect->Effect)
- {
- case SPELL_EFFECT_GAMEOBJECT_DAMAGE:
- case SPELL_EFFECT_GAMEOBJECT_REPAIR:
- case SPELL_EFFECT_GAMEOBJECT_SET_DESTRUCTION_STATE:
- if (go->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
- effectMask &= ~(1 << effect->EffectIndex);
- break;
- default:
- break;
- }
- }
- }
+ effectMask &= validEffectMask;
+ // no effects left
if (!effectMask)
return;
@@ -2288,9 +2276,12 @@ void Spell::AddGOTarget(GameObject* go, uint32 effectMask)
void Spell::AddItemTarget(Item* item, uint32 effectMask)
{
+ uint32 validEffectMask = 0;
for (SpellEffectInfo const* effect : GetEffects())
- if (!effect || !effect->IsEffect())
- effectMask &= ~(1 << effect->EffectIndex);
+ if (effect && (effectMask & effect->EffectIndex) != 0 && CheckEffectTarget(item, effect))
+ validEffectMask |= 1 << effect->EffectIndex;
+
+ effectMask &= validEffectMask;
// no effects left
if (!effectMask)
@@ -6723,10 +6714,9 @@ CurrentSpellTypes Spell::GetCurrentContainer() const
return(CURRENT_GENERIC_SPELL);
}
-bool Spell::CheckEffectTarget(Unit const* target, uint32 eff, Position const* losPosition) const
+bool Spell::CheckEffectTarget(Unit const* target, SpellEffectInfo const* effect, Position const* losPosition) const
{
- SpellEffectInfo const* effect = GetEffect(eff);
- if (!effect)
+ if (!effect->IsEffect())
return false;
switch (effect->ApplyAuraName)
@@ -6741,7 +6731,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff, Position const* lo
return false;
if (!target->GetCharmerGUID().IsEmpty())
return false;
- if (int32 damage = CalculateDamage(eff, target))
+ if (int32 damage = CalculateDamage(effect->EffectIndex, target))
if ((int32)target->getLevel() > damage)
return false;
break;
@@ -6803,6 +6793,34 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff, Position const* lo
return true;
}
+bool Spell::CheckEffectTarget(GameObject const* target, SpellEffectInfo const* effect) const
+{
+ if (!effect->IsEffect())
+ return false;
+
+ switch (effect->Effect)
+ {
+ case SPELL_EFFECT_GAMEOBJECT_DAMAGE:
+ case SPELL_EFFECT_GAMEOBJECT_REPAIR:
+ case SPELL_EFFECT_GAMEOBJECT_SET_DESTRUCTION_STATE:
+ if (target->GetGoType() != GAMEOBJECT_TYPE_DESTRUCTIBLE_BUILDING)
+ return false;
+ break;
+ default:
+ break;
+ }
+
+ return true;
+}
+
+bool Spell::CheckEffectTarget(Item const* target, SpellEffectInfo const* effect) const
+{
+ if (!effect->IsEffect())
+ return false;
+
+ return true;
+}
+
bool Spell::IsNextMeleeSwingSpell() const
{
return (m_spellInfo->Attributes & SPELL_ATTR0_ON_NEXT_SWING) != 0;
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 66eb4ae6ded..3e83478e492 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -437,7 +437,9 @@ class Spell
void DoCreateItem(uint32 i, uint32 itemtype);
void WriteSpellGoTargets(WorldPacket* data);
- bool CheckEffectTarget(Unit const* target, uint32 eff, Position const* losPosition) const;
+ bool CheckEffectTarget(Unit const* target, SpellEffectInfo const* effect, Position const* losPosition) const;
+ bool CheckEffectTarget(GameObject const* target, SpellEffectInfo const* effect) const;
+ bool CheckEffectTarget(Item const* target, SpellEffectInfo const* effect) const;
bool CanAutoCast(Unit* target);
void CheckSrc() { if (!m_targets.HasSrc()) m_targets.SetSrc(*m_caster); }
void CheckDst() { if (!m_targets.HasDst()) m_targets.SetDst(*m_caster); }
@@ -701,7 +703,7 @@ class Spell
// effect helpers
void SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* properties, uint32 numSummons);
- void CalculateJumpSpeeds(uint8 i, float dist, float & speedxy, float & speedz);
+ void CalculateJumpSpeeds(SpellEffectInfo const* effInfo, float dist, float& speedxy, float& speedz);
SpellCastResult CanOpenLock(uint32 effIndex, uint32 lockid, SkillType& skillid, int32& reqSkillValue, int32& skillValue);
// -------------------------------------------
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 7f445791d4e..039bd5784d5 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -927,7 +927,7 @@ void Spell::EffectJump(SpellEffIndex effIndex)
unitTarget->GetContactPoint(m_caster, x, y, z, CONTACT_DISTANCE);
float speedXY, speedZ;
- CalculateJumpSpeeds(effIndex, m_caster->GetExactDist2d(x, y), speedXY, speedZ);
+ CalculateJumpSpeeds(effectInfo, m_caster->GetExactDist2d(x, y), speedXY, speedZ);
m_caster->GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ);
}
@@ -947,21 +947,19 @@ void Spell::EffectJumpDest(SpellEffIndex effIndex)
destTarget->GetPosition(x, y, z);
float speedXY, speedZ;
- CalculateJumpSpeeds(effIndex, m_caster->GetExactDist2d(x, y), speedXY, speedZ);
+ CalculateJumpSpeeds(effectInfo, m_caster->GetExactDist2d(x, y), speedXY, speedZ);
m_caster->GetMotionMaster()->MoveJump(x, y, z, speedXY, speedZ);
}
-void Spell::CalculateJumpSpeeds(uint8 i, float dist, float & speedXY, float & speedZ)
+void Spell::CalculateJumpSpeeds(SpellEffectInfo const* effInfo, float dist, float& speedXY, float& speedZ)
{
- if (SpellEffectInfo const* effect = GetEffect(i))
- {
- if (effect->MiscValue)
- speedZ = float(effect->MiscValue) / 10;
- else if (effect->MiscValueB)
- speedZ = float(effect->MiscValueB) / 10;
- else
- speedZ = 10.0f;
- }
+ if (effInfo->MiscValue)
+ speedZ = float(effInfo->MiscValue) / 10;
+ else if (effInfo->MiscValueB)
+ speedZ = float(effInfo->MiscValueB) / 10;
+ else
+ speedZ = 10.0f;
+
speedXY = dist * 10.0f / speedZ;
}
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 607fbe84471..01bf2a4dae2 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -1049,6 +1049,7 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry, SpellEffectEntryMap effects)
Targets = _target ? _target->Targets : 0;
TargetCreatureType = _target ? _target->TargetCreatureType : 0;
MaxAffectedTargets = _target ? _target->MaxAffectedTargets : 0;
+ MaxTargetLevel = _target ? _target->MaxTargetLevel : 0;
// SpellTotemsEntry
SpellTotemsEntry const* _totem = GetSpellTotems();
diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp
index 1bd4d3be5d6..6ec8b62e55b 100644
--- a/src/server/game/Spells/SpellScript.cpp
+++ b/src/server/game/Spells/SpellScript.cpp
@@ -590,6 +590,13 @@ void SpellScript::PreventHitDefaultEffect(SpellEffIndex effIndex)
m_hitPreventDefaultEffectMask |= 1 << effIndex;
}
+SpellEffectInfo const* SpellScript::GetEffectInfo() const
+{
+ ASSERT(IsInEffectHook(), "Script: `%s` Spell: `%u`: function SpellScript::GetEffectInfo was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
+
+ return m_spell->effectInfo;
+}
+
int32 SpellScript::GetEffectValue() const
{
if (!IsInEffectHook())
diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h
index 0e4c78283bd..2312e9d9f4a 100644
--- a/src/server/game/Spells/SpellScript.h
+++ b/src/server/game/Spells/SpellScript.h
@@ -417,7 +417,8 @@ class SpellScript : public _SpellScript
// will not work if effects were already handled
void PreventHitDefaultEffect(SpellEffIndex effIndex);
- // method avalible only in EffectHandler method
+ // method available only in EffectHandler method
+ SpellEffectInfo const* GetEffectInfo() const;
int32 GetEffectValue() const;
void SetEffectValue(int32 value);
diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
index 7249480108f..ce359603176 100644
--- a/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
+++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/chapter1.cpp
@@ -934,20 +934,16 @@ public:
void FindMinions(Unit* owner)
{
- std::list<Creature*> MinionList;
+ std::list<TempSummon*> MinionList;
owner->GetAllMinionsByEntry(MinionList, NPC_GHOULS);
if (!MinionList.empty())
{
- for (std::list<Creature*>::const_iterator itr = MinionList.begin(); itr != MinionList.end(); ++itr)
+ for (TempSummon* summon : MinionList)
{
- if ((*itr)->GetOwner()->GetGUID() == me->GetOwner()->GetGUID())
- {
- if ((*itr)->IsInCombat() && (*itr)->getAttackerForHelper())
- {
- AttackStart((*itr)->getAttackerForHelper());
- }
- }
+ if (summon->GetOwnerGUID() == me->GetOwnerGUID())
+ if (summon->IsInCombat() && summon->getAttackerForHelper())
+ AttackStart(summon->getAttackerForHelper());
}
}
}
diff --git a/src/server/scripts/Kalimdor/zone_winterspring.cpp b/src/server/scripts/Kalimdor/zone_winterspring.cpp
index ee73d9b27a9..b8200c59258 100644
--- a/src/server/scripts/Kalimdor/zone_winterspring.cpp
+++ b/src/server/scripts/Kalimdor/zone_winterspring.cpp
@@ -377,15 +377,15 @@ public:
void DoSummonPriestess()
{
// Summon 2 Elune priestess and make each of them move to a different spot
- if (Creature* priestess = me->SummonCreature(NPC_PRIESTESS_ELUNE, wingThicketLocations[0].m_positionX, wingThicketLocations[0].m_positionY, wingThicketLocations[0].m_positionZ, wingThicketLocations[0].m_orientation, TEMPSUMMON_CORPSE_DESPAWN, 0))
+ if (Creature* priestess = me->SummonCreature(NPC_PRIESTESS_ELUNE, wingThicketLocations[0], TEMPSUMMON_CORPSE_DESPAWN, 0))
{
- priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[3].m_positionX, wingThicketLocations[3].m_positionY, wingThicketLocations[3].m_positionZ);
+ priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[3]);
_firstPriestessGUID = priestess->GetGUID();
}
- if (Creature* priestess = me->SummonCreature(NPC_PRIESTESS_ELUNE, wingThicketLocations[1].m_positionX, wingThicketLocations[1].m_positionY, wingThicketLocations[1].m_positionZ, wingThicketLocations[1].m_orientation, TEMPSUMMON_CORPSE_DESPAWN, 0))
+ if (Creature* priestess = me->SummonCreature(NPC_PRIESTESS_ELUNE, wingThicketLocations[1], TEMPSUMMON_CORPSE_DESPAWN, 0))
{
// Left priestess should have a distinct move point because she is the one who starts the dialogue at point reach
- priestess->GetMotionMaster()->MovePoint(1, wingThicketLocations[4].m_positionX, wingThicketLocations[4].m_positionY, wingThicketLocations[4].m_positionZ);
+ priestess->GetMotionMaster()->MovePoint(1, wingThicketLocations[4]);
_secondPriestessGUID = priestess->GetGUID();
}
}
@@ -476,19 +476,19 @@ public:
case SAY_PRIESTESS_ALTAR_9:
// move near the escort npc
if (Creature* priestess = me->GetMap()->GetCreature(_firstPriestessGUID))
- priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[6].m_positionX, wingThicketLocations[6].m_positionY, wingThicketLocations[6].m_positionZ);
+ priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[6]);
break;
case SAY_PRIESTESS_ALTAR_13:
// summon the Guardian of Elune
- if (Creature* guard = me->SummonCreature(NPC_GUARDIAN_ELUNE, wingThicketLocations[2].m_positionX, wingThicketLocations[2].m_positionY, wingThicketLocations[2].m_positionZ, wingThicketLocations[2].m_orientation, TEMPSUMMON_CORPSE_DESPAWN, 0))
+ if (Creature* guard = me->SummonCreature(NPC_GUARDIAN_ELUNE, wingThicketLocations[2], TEMPSUMMON_CORPSE_DESPAWN, 0))
{
- guard->GetMotionMaster()->MovePoint(0, wingThicketLocations[5].m_positionX, wingThicketLocations[5].m_positionY, wingThicketLocations[5].m_positionZ);
+ guard->GetMotionMaster()->MovePoint(0, wingThicketLocations[5]);
_guardEluneGUID = guard->GetGUID();
}
// summon the Voice of Elune
if (GameObject* altar = me->GetMap()->GetGameObject(_altarGUID))
{
- if (Creature* voice = me->SummonCreature(NPC_VOICE_ELUNE, altar->GetPositionX(), altar->GetPositionY(), altar->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 30000))
+ if (Creature* voice = me->SummonCreature(NPC_VOICE_ELUNE, *altar, TEMPSUMMON_TIMED_DESPAWN, 30000))
_voiceEluneGUID = voice->GetGUID();
}
break;
@@ -497,14 +497,14 @@ public:
if (Creature* priestess = me->GetMap()->GetCreature(_secondPriestessGUID))
{
priestess->AI()->Talk(SAY_PRIESTESS_ALTAR_14);
- priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[7].m_positionX, wingThicketLocations[7].m_positionY, wingThicketLocations[7].m_positionZ);
+ priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[7]);
}
break;
case SAY_PRIESTESS_ALTAR_19:
// make the voice of elune leave
if (Creature* guard = me->GetMap()->GetCreature(_guardEluneGUID))
{
- guard->GetMotionMaster()->MovePoint(0, wingThicketLocations[2].m_positionX, wingThicketLocations[2].m_positionY, wingThicketLocations[2].m_positionZ);
+ guard->GetMotionMaster()->MovePoint(0, wingThicketLocations[2]);
guard->DespawnOrUnsummon(4000);
}
break;
@@ -512,7 +512,7 @@ public:
// make the first priestess leave
if (Creature* priestess = me->GetMap()->GetCreature(_firstPriestessGUID))
{
- priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[0].m_positionX, wingThicketLocations[0].m_positionY, wingThicketLocations[0].m_positionZ);
+ priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[0]);
priestess->DespawnOrUnsummon(4000);
}
break;
@@ -520,7 +520,7 @@ public:
// make the second priestess leave
if (Creature* priestess = me->GetMap()->GetCreature(_secondPriestessGUID))
{
- priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[1].m_positionX, wingThicketLocations[1].m_positionY, wingThicketLocations[1].m_positionZ);
+ priestess->GetMotionMaster()->MovePoint(0, wingThicketLocations[1]);
priestess->DespawnOrUnsummon(4000);
}
break;
diff --git a/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp b/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp
index a5feb4fac16..d2c38c47d55 100644
--- a/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp
+++ b/src/server/scripts/Northrend/Nexus/Nexus/boss_keristrasza.cpp
@@ -111,23 +111,15 @@ class boss_keristrasza : public CreatureScript
Talk(SAY_SLAY);
}
- bool CheckContainmentSpheres(bool remove_prison = false)
+ bool CheckContainmentSpheres(bool removePrison = false)
{
- ContainmentSphereGUIDs[0] = instance->GetGuidData(ANOMALUS_CONTAINMET_SPHERE);
- ContainmentSphereGUIDs[1] = instance->GetGuidData(ORMOROKS_CONTAINMET_SPHERE);
- ContainmentSphereGUIDs[2] = instance->GetGuidData(TELESTRAS_CONTAINMET_SPHERE);
-
- GameObject* ContainmentSpheres[DATA_CONTAINMENT_SPHERES];
-
- for (uint8 i = 0; i < DATA_CONTAINMENT_SPHERES; ++i)
+ for (uint32 i = ANOMALUS_CONTAINMET_SPHERE; i < (ANOMALUS_CONTAINMET_SPHERE + DATA_CONTAINMENT_SPHERES); ++i)
{
- ContainmentSpheres[i] = ObjectAccessor::GetGameObject(*me, ContainmentSphereGUIDs[i]);
- if (!ContainmentSpheres[i])
- return false;
- if (ContainmentSpheres[i]->GetGoState() != GO_STATE_ACTIVE)
+ GameObject* containmentSpheres = ObjectAccessor::GetGameObject(*me, instance->GetGuidData(i));
+ if (!containmentSpheres || containmentSpheres->GetGoState() != GO_STATE_ACTIVE)
return false;
}
- if (remove_prison)
+ if (removePrison)
RemovePrison(true);
return true;
}
@@ -207,7 +199,7 @@ class boss_keristrasza : public CreatureScript
private:
bool _intenseCold;
bool _enrage;
- ObjectGuid ContainmentSphereGUIDs[DATA_CONTAINMENT_SPHERES];
+
public:
GuidList _intenseColdList;
};
@@ -285,9 +277,9 @@ class achievement_intense_cold : public AchievementCriteriaScript
if (!target)
return false;
- GuidList _intenseColdList = ENSURE_AI(boss_keristrasza::boss_keristraszaAI, target->ToCreature()->AI())->_intenseColdList;
+ GuidList const& _intenseColdList = ENSURE_AI(boss_keristrasza::boss_keristraszaAI, target->ToCreature()->AI())->_intenseColdList;
if (!_intenseColdList.empty())
- for (GuidList::iterator itr = _intenseColdList.begin(); itr != _intenseColdList.end(); ++itr)
+ for (GuidList::const_iterator itr = _intenseColdList.begin(); itr != _intenseColdList.end(); ++itr)
if (player->GetGUID() == *itr)
return false;
diff --git a/src/server/scripts/Northrend/zone_dragonblight.cpp b/src/server/scripts/Northrend/zone_dragonblight.cpp
index eff84365f63..7058f8689f0 100644
--- a/src/server/scripts/Northrend/zone_dragonblight.cpp
+++ b/src/server/scripts/Northrend/zone_dragonblight.cpp
@@ -174,34 +174,29 @@ class npc_commander_eligor_dawnbringer : public CreatureScript
{
if (id == 1)
{
- me->SetFacingTo(PosTalkLocations[talkWing].m_orientation);
+ me->SetFacingTo(PosTalkLocations[talkWing].GetOrientation());
TurnAudience();
switch (talkWing)
{
- case 0: // Pinnacle of Naxxramas
- {
- switch (urand (0, 1))
+ case 0: // Pinnacle of Naxxramas
+ switch (urand(0, 1))
{
case 0: ChangeImage(NPC_IMAGE_OF_KELTHUZAD, MODEL_IMAGE_OF_KELTHUZAD, SAY_KELTHUZAD_1);
- _events.ScheduleEvent(EVENT_KELTHUZAD_2, 8000); break;
+ _events.ScheduleEvent(EVENT_KELTHUZAD_2, 8000); break;
case 1: ChangeImage(NPC_IMAGE_OF_SAPPHIRON, MODEL_IMAGE_OF_SAPPHIRON, SAY_SAPPHIRON); break;
}
- }
- break;
- case 1: // Death knight wing of Naxxramas
- {
- switch (urand (0, 2))
+ break;
+ case 1: // Death knight wing of Naxxramas
+ switch (urand(0, 2))
{
case 0: ChangeImage(NPC_IMAGE_OF_RAZUVIOUS, MODEL_IMAGE_OF_RAZUVIOUS, SAY_RAZUVIOUS); break;
case 1: ChangeImage(NPC_IMAGE_OF_GOTHIK, MODEL_IMAGE_OF_GOTHIK, SAY_GOTHIK); break;
case 2: ChangeImage(NPC_IMAGE_OF_THANE, MODEL_IMAGE_OF_THANE, SAY_DEATH_KNIGHTS_1);
- _events.ScheduleEvent(EVENT_DEATH_KNIGHTS_2, 10000); break;
+ _events.ScheduleEvent(EVENT_DEATH_KNIGHTS_2, 10000); break;
}
- }
- break;
- case 2: // Blighted abomination wing of Naxxramas
- {
+ break;
+ case 2: // Blighted abomination wing of Naxxramas
switch (urand (0, 3))
{
case 0: ChangeImage(NPC_IMAGE_OF_PATCHWERK, MODEL_IMAGE_OF_PATCHWERK, SAY_PATCHWERK); break;
@@ -209,20 +204,16 @@ class npc_commander_eligor_dawnbringer : public CreatureScript
case 2: ChangeImage(NPC_IMAGE_OF_THADDIUS, MODEL_IMAGE_OF_THADDIUS, SAY_THADDIUS); break;
case 3: ChangeImage(NPC_IMAGE_OF_GLUTH, MODEL_IMAGE_OF_GLUTH, SAY_GLUTH); break;
}
- }
- break;
- case 3: // Accursed spider wing of Naxxramas
- {
+ break;
+ case 3: // Accursed spider wing of Naxxramas
switch (urand (0, 2))
{
case 0: ChangeImage(NPC_IMAGE_OF_ANUBREKHAN, MODEL_IMAGE_OF_ANUBREKHAN, SAY_ANUBREKHAN); break;
case 1: ChangeImage(NPC_IMAGE_OF_FAERLINA, MODEL_IMAGE_OF_FAERLINA, SAY_FAERLINA); break;
case 2: ChangeImage(NPC_IMAGE_OF_MAEXXNA, MODEL_IMAGE_OF_MAEXXNA, SAY_MAEXXNA); break;
}
- }
- break;
- case 4: // Dread plague wing of Naxxramas
- {
+ break;
+ case 4: // Dread plague wing of Naxxramas
switch (urand (0, 2))
{
case 0: ChangeImage(NPC_IMAGE_OF_NOTH, MODEL_IMAGE_OF_NOTH, SAY_NOTH); break;
@@ -230,11 +221,10 @@ class npc_commander_eligor_dawnbringer : public CreatureScript
_events.ScheduleEvent(EVENT_HEIGAN_2, 8000); break;
case 2: ChangeImage(NPC_IMAGE_OF_LOATHEB, MODEL_IMAGE_OF_LOATHEB, SAY_LOATHEB); break;
}
- }
- break;
- case 5: // Home
- _events.ScheduleEvent(EVENT_START_RANDOM, 30000);
- break;
+ break;
+ case 5: // Home
+ _events.ScheduleEvent(EVENT_START_RANDOM, 30000);
+ break;
}
}
}
diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp
index cc96b27cb0a..5a2e19f08c2 100644
--- a/src/server/scripts/Spells/spell_dk.cpp
+++ b/src/server/scripts/Spells/spell_dk.cpp
@@ -1231,12 +1231,11 @@ class spell_dk_raise_dead : public SpellScriptLoader
private:
bool Validate(SpellInfo const* spellInfo) override
{
- // 6.x effects changed
- /*if (!sSpellMgr->GetSpellInfo(spellInfo->GetEffect(EFFECT_1)->CalcValue())
+ if (!sSpellMgr->GetSpellInfo(spellInfo->GetEffect(EFFECT_1)->CalcValue())
|| !sSpellMgr->GetSpellInfo(spellInfo->GetEffect(EFFECT_2)->CalcValue())
|| !sSpellMgr->GetSpellInfo(SPELL_DK_RAISE_DEAD_USE_REAGENT)
|| !sSpellMgr->GetSpellInfo(SPELL_DK_MASTER_OF_GHOULS))
- return false;*/
+ return false;
return false;
}
diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp
index c38d6b07124..01501c04c2e 100644
--- a/src/server/scripts/Spells/spell_druid.cpp
+++ b/src/server/scripts/Spells/spell_druid.cpp
@@ -159,7 +159,7 @@ class spell_dru_eclipse_energize : public SpellScriptLoader
return true;
}
- void HandleEnergize(SpellEffIndex effIndex)
+ void HandleEnergize(SpellEffIndex /*effIndex*/)
{
Player* caster = GetCaster()->ToPlayer();
diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp
index 87619460ee7..8800903b095 100644
--- a/src/server/scripts/Spells/spell_generic.cpp
+++ b/src/server/scripts/Spells/spell_generic.cpp
@@ -1180,13 +1180,12 @@ class spell_gen_defend : public SpellScriptLoader
bool Validate(SpellInfo const* /*spellInfo*/) override
{
- // 6.x effects changed
- //if (!sSpellMgr->GetSpellInfo(SPELL_VISUAL_SHIELD_1))
- // return false;
- //if (!sSpellMgr->GetSpellInfo(SPELL_VISUAL_SHIELD_2))
- // return false;
- //if (!sSpellMgr->GetSpellInfo(SPELL_VISUAL_SHIELD_3))
- // return false;
+ if (!sSpellMgr->GetSpellInfo(SPELL_VISUAL_SHIELD_1))
+ return false;
+ if (!sSpellMgr->GetSpellInfo(SPELL_VISUAL_SHIELD_2))
+ return false;
+ if (!sSpellMgr->GetSpellInfo(SPELL_VISUAL_SHIELD_3))
+ return false;
return false;
}
@@ -1221,26 +1220,29 @@ class spell_gen_defend : public SpellScriptLoader
void Register() override
{
+ /*
SpellInfo const* spell = sSpellMgr->EnsureSpellInfo(m_scriptSpellId);
// 6.x effects removed
// Defend spells cast by NPCs (add visuals)
- /*if (spell->GetEffect(EFFECT_0)->ApplyAuraName == SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)
+ if (spell->GetEffect(EFFECT_0)->ApplyAuraName == SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)
{
AfterEffectApply += AuraEffectApplyFn(spell_gen_defend_AuraScript::RefreshVisualShields, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
OnEffectRemove += AuraEffectRemoveFn(spell_gen_defend_AuraScript::RemoveVisualShields, EFFECT_0, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK);
- }*/
+ }
+
// Remove Defend spell from player when he dismounts
- //if (spell->GetEffect(EFFECT_2)->ApplyAuraName == SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)
- // OnEffectRemove += AuraEffectRemoveFn(spell_gen_defend_AuraScript::RemoveDummyFromDriver, EFFECT_2, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL);
+ if (spell->GetEffect(EFFECT_2)->ApplyAuraName == SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN)
+ OnEffectRemove += AuraEffectRemoveFn(spell_gen_defend_AuraScript::RemoveDummyFromDriver, EFFECT_2, SPELL_AURA_MOD_DAMAGE_PERCENT_TAKEN, AURA_EFFECT_HANDLE_REAL);
// Defend spells cast by players (add/remove visuals)
- /*if (spell->GetEffect(EFFECT_1)->ApplyAuraName == SPELL_AURA_DUMMY)
+ if (spell->GetEffect(EFFECT_1)->ApplyAuraName == SPELL_AURA_DUMMY)
{
AfterEffectApply += AuraEffectApplyFn(spell_gen_defend_AuraScript::RefreshVisualShields, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
OnEffectRemove += AuraEffectRemoveFn(spell_gen_defend_AuraScript::RemoveVisualShields, EFFECT_1, SPELL_AURA_DUMMY, AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK);
- }*/
+ }
+ */
}
};
@@ -1913,6 +1915,8 @@ class spell_gen_mounted_charge: public SpellScriptLoader
}
break;
}
+ default:
+ break;
}
}
diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp
index a8f8dc1f31c..ed888b2d33d 100644
--- a/src/server/scripts/Spells/spell_item.cpp
+++ b/src/server/scripts/Spells/spell_item.cpp
@@ -1485,7 +1485,7 @@ class spell_item_gift_of_the_harvester : public SpellScriptLoader
SpellCastResult CheckRequirement()
{
- std::list<Creature*> ghouls;
+ std::list<TempSummon*> ghouls;
GetCaster()->GetAllMinionsByEntry(ghouls, NPC_GHOUL);
if (ghouls.size() >= MAX_GHOULS)
{
diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp
index fc8ba0ffad0..782a4ca6190 100644
--- a/src/server/scripts/Spells/spell_mage.cpp
+++ b/src/server/scripts/Spells/spell_mage.cpp
@@ -1294,51 +1294,53 @@ class spell_mage_ring_of_frost : public SpellScriptLoader
return true;
}
- bool Load() override
- {
- ringOfFrost = NULL;
- return true;
- }
-
void HandleEffectPeriodic(AuraEffect const* /*aurEff*/)
{
- if (ringOfFrost)
- if (GetMaxDuration() - (int32)ringOfFrost->GetTimer() >= sSpellMgr->GetSpellInfo(SPELL_MAGE_RING_OF_FROST_DUMMY)->GetDuration())
+ if (TempSummon* ringOfFrost = GetRingOfFrostMinion())
+ if (GetMaxDuration() - int32(ringOfFrost->GetTimer()) >= sSpellMgr->EnsureSpellInfo(SPELL_MAGE_RING_OF_FROST_DUMMY)->GetDuration())
GetTarget()->CastSpell(ringOfFrost->GetPositionX(), ringOfFrost->GetPositionY(), ringOfFrost->GetPositionZ(), SPELL_MAGE_RING_OF_FROST_FREEZE, true);
}
void Apply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
- std::list<Creature*> MinionList;
+ std::list<TempSummon*> MinionList;
GetTarget()->GetAllMinionsByEntry(MinionList, GetSpellInfo()->GetEffect(EFFECT_0)->MiscValue);
// Get the last summoned RoF, save it and despawn older ones
- for (std::list<Creature*>::iterator itr = MinionList.begin(); itr != MinionList.end(); itr++)
+ for (std::list<TempSummon*>::iterator itr = MinionList.begin(); itr != MinionList.end(); itr++)
{
- TempSummon* summon = (*itr)->ToTempSummon();
+ TempSummon* summon = (*itr);
- if (ringOfFrost && summon)
+ if (TempSummon* ringOfFrost = GetRingOfFrostMinion())
{
if (summon->GetTimer() > ringOfFrost->GetTimer())
{
ringOfFrost->DespawnOrUnsummon();
- ringOfFrost = summon;
+ _ringOfFrostGUID = summon->GetGUID();
}
else
summon->DespawnOrUnsummon();
}
- else if (summon)
- ringOfFrost = summon;
+ else
+ _ringOfFrostGUID = summon->GetGUID();
}
}
- TempSummon* ringOfFrost;
-
void Register() override
{
- OnEffectPeriodic += AuraEffectPeriodicFn(spell_mage_ring_of_frost_AuraScript::HandleEffectPeriodic, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
- OnEffectApply += AuraEffectApplyFn(spell_mage_ring_of_frost_AuraScript::Apply, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
+ OnEffectPeriodic += AuraEffectPeriodicFn(spell_mage_ring_of_frost_AuraScript::HandleEffectPeriodic, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL);
+ OnEffectApply += AuraEffectApplyFn(spell_mage_ring_of_frost_AuraScript::Apply, EFFECT_1, SPELL_AURA_PERIODIC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL_OR_REAPPLY_MASK);
}
+
+ private:
+ TempSummon* GetRingOfFrostMinion() const
+ {
+ if (Creature* creature = ObjectAccessor::GetCreature(*GetOwner(), _ringOfFrostGUID))
+ return creature->ToTempSummon();
+ return nullptr;
+ }
+
+ ObjectGuid _ringOfFrostGUID;
};
AuraScript* GetAuraScript() const override
@@ -1369,13 +1371,17 @@ class spell_mage_ring_of_frost_freeze : public SpellScriptLoader
void FilterTargets(std::list<WorldObject*>& targets)
{
- float outRadius = sSpellMgr->GetSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON)->GetEffect(EFFECT_0)->CalcRadius();
+ WorldLocation const* dest = GetExplTargetDest();
+ float outRadius = sSpellMgr->EnsureSpellInfo(SPELL_MAGE_RING_OF_FROST_SUMMON)->GetEffect(EFFECT_0)->CalcRadius();
float inRadius = 4.7f;
- for (std::list<WorldObject*>::iterator itr = targets.begin(); itr != targets.end(); ++itr)
- if (Unit* unit = (*itr)->ToUnit())
- if (unit->HasAura(SPELL_MAGE_RING_OF_FROST_DUMMY) || unit->HasAura(SPELL_MAGE_RING_OF_FROST_FREEZE) || unit->GetExactDist(GetExplTargetDest()) > outRadius || unit->GetExactDist(GetExplTargetDest()) < inRadius)
- targets.erase(itr--);
+ targets.remove_if([dest, outRadius, inRadius](WorldObject* target)
+ {
+ Unit* unit = target->ToUnit();
+ if (!unit)
+ return true;
+ return unit->HasAura(SPELL_MAGE_RING_OF_FROST_DUMMY) || unit->HasAura(SPELL_MAGE_RING_OF_FROST_FREEZE) || unit->GetExactDist(dest) > outRadius || unit->GetExactDist(dest) < inRadius;
+ });
}
void Register() override
diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp
index fba40986c31..727748c2f3f 100644
--- a/src/server/scripts/Spells/spell_warlock.cpp
+++ b/src/server/scripts/Spells/spell_warlock.cpp
@@ -1251,17 +1251,13 @@ class spell_warl_soul_swap_dot_marker : public SpellScriptLoader
{
PrepareSpellScript(spell_warl_soul_swap_dot_marker_SpellScript);
- void HandleHit(SpellEffIndex effIndex)
+ void HandleHit(SpellEffIndex /*effIndex*/)
{
Unit* swapVictim = GetCaster();
Unit* warlock = GetHitUnit();
if (!warlock || !swapVictim)
return;
- // effect existance checked in dbc, should not be removed by core at any time, so no need to check for null
- SpellEffectInfo const* effect = GetSpellInfo()->GetEffect(DIFFICULTY_NONE, EFFECT_0);
- flag128 classMask = effect->SpellClassMask;
-
Unit::AuraApplicationMap const& appliedAuras = swapVictim->GetAppliedAuras();
SoulSwapOverrideAuraScript* swapSpellScript = nullptr;
if (Aura* swapOverrideAura = warlock->GetAura(SPELL_WARLOCK_SOUL_SWAP_OVERRIDE))
@@ -1270,6 +1266,8 @@ class spell_warl_soul_swap_dot_marker : public SpellScriptLoader
if (!swapSpellScript)
return;
+ flag128 classMask = GetEffectInfo()->SpellClassMask;
+
for (Unit::AuraApplicationMap::const_iterator itr = appliedAuras.begin(); itr != appliedAuras.end(); ++itr)
{
SpellInfo const* spellProto = itr->second->GetBase()->GetSpellInfo();
diff --git a/src/server/scripts/Spells/spell_warrior.cpp b/src/server/scripts/Spells/spell_warrior.cpp
index d6ff9375544..3279a5181a7 100644
--- a/src/server/scripts/Spells/spell_warrior.cpp
+++ b/src/server/scripts/Spells/spell_warrior.cpp
@@ -866,6 +866,7 @@ class spell_warr_vigilance : public SpellScriptLoader
return true;
}
+ /*
bool CheckProc(ProcEventInfo& eventInfo)
{
_procTarget = GetCaster();
@@ -874,12 +875,13 @@ class spell_warr_vigilance : public SpellScriptLoader
void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo)
{
- /*PreventDefaultAction();
+ PreventDefaultAction();
int32 damage = int32(CalculatePct(eventInfo.GetDamageInfo()->GetDamage(), aurEff->GetSpellInfo()->Effects[EFFECT_1].CalcValue()));
GetTarget()->CastSpell(_procTarget, SPELL_WARRIOR_VIGILANCE_PROC, true, NULL, aurEff);
- _procTarget->CastCustomSpell(_procTarget, SPELL_WARRIOR_VENGEANCE, &damage, &damage, &damage, true, NULL, aurEff);*/
+ _procTarget->CastCustomSpell(_procTarget, SPELL_WARRIOR_VENGEANCE, &damage, &damage, &damage, true, NULL, aurEff);
}
+ */
void HandleRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
{
@@ -892,8 +894,8 @@ class spell_warr_vigilance : public SpellScriptLoader
void Register() override
{
- DoCheckProc += AuraCheckProcFn(spell_warr_vigilance_AuraScript::CheckProc);
- OnEffectProc += AuraEffectProcFn(spell_warr_vigilance_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
+ //DoCheckProc += AuraCheckProcFn(spell_warr_vigilance_AuraScript::CheckProc);
+ //OnEffectProc += AuraEffectProcFn(spell_warr_vigilance_AuraScript::HandleProc, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL);
OnEffectRemove += AuraEffectRemoveFn(spell_warr_vigilance_AuraScript::HandleRemove, EFFECT_0, SPELL_AURA_PROC_TRIGGER_SPELL, AURA_EFFECT_HANDLE_REAL);
}
diff --git a/src/server/shared/DataStores/DB2StorageLoader.h b/src/server/shared/DataStores/DB2StorageLoader.h
index cc9bfa76b5c..0bd8c8a9403 100644
--- a/src/server/shared/DataStores/DB2StorageLoader.h
+++ b/src/server/shared/DataStores/DB2StorageLoader.h
@@ -20,9 +20,9 @@
#include "Define.h"
#include "Utilities/ByteConverter.h"
+
#include <cassert>
#include <list>
-#include "Common.h"
class DB2FileLoader
{
diff --git a/src/server/shared/DataStores/DB2Store.h b/src/server/shared/DataStores/DB2Store.h
index c8f42d6d4e7..9204d68754b 100644
--- a/src/server/shared/DataStores/DB2Store.h
+++ b/src/server/shared/DataStores/DB2Store.h
@@ -18,10 +18,9 @@
#ifndef DB2STORE_H
#define DB2STORE_H
-#include "DB2StorageLoader.h"
#include "Common.h"
+#include "DB2StorageLoader.h"
#include "ByteBuffer.h"
-#include <vector>
/// Interface class for common access
class DB2StorageBase
@@ -127,7 +126,7 @@ public:
bool Load(char const* fn, uint32 locale)
{
DB2FileLoader db2;
- // Check if load was sucessful, only then continue
+ // Check if load was successful, only then continue
if (!db2.Load(fn, fmt))
return false;
@@ -142,17 +141,17 @@ public:
{
m_stringPoolList.push_back(stringHolders);
- // load strings from dbc data
+ // load strings from db2 data
m_stringPoolList.push_back(db2.AutoProduceStrings(fmt, (char*)m_dataTable, locale));
}
- // error in dbc file at loading if NULL
+ // error in db2 file at loading if NULL
return indexTable.asT != NULL;
}
bool LoadStringsFrom(char const* fn, uint32 locale)
{
- // DBC must be already loaded using Load
+ // DB2 must be already loaded using Load
if (!indexTable.asT)
return false;
@@ -161,7 +160,7 @@ public:
if (!db2.Load(fn, fmt))
return false;
- // load strings from another locale dbc data
+ // load strings from another locale db2 data
if (DB2FileLoader::GetFormatStringFieldCount(fmt))
m_stringPoolList.push_back(db2.AutoProduceStrings(fmt, (char*)m_dataTable, locale));
diff --git a/src/server/shared/DataStores/DBCFileLoader.h b/src/server/shared/DataStores/DBCFileLoader.h
index f05e7800d3b..a4a2a3dd1c1 100644
--- a/src/server/shared/DataStores/DBCFileLoader.h
+++ b/src/server/shared/DataStores/DBCFileLoader.h
@@ -18,6 +18,7 @@
#ifndef DBC_FILE_LOADER_H
#define DBC_FILE_LOADER_H
+
#include "Define.h"
#include "Utilities/ByteConverter.h"
#include <cassert>
diff --git a/src/server/shared/DataStores/DBCStore.h b/src/server/shared/DataStores/DBCStore.h
index 055a8691a87..f2907535da2 100644
--- a/src/server/shared/DataStores/DBCStore.h
+++ b/src/server/shared/DataStores/DBCStore.h
@@ -94,7 +94,7 @@ class DBCStorage
bool Load(char const* fn, SqlDbc* sql)
{
DBCFileLoader dbc;
- // Check if load was sucessful, only then continue
+ // Check if load was successful, only then continue
if (!dbc.Load(fn, fmt))
return false;
diff --git a/src/server/shared/Utilities/Util.cpp b/src/server/shared/Utilities/Util.cpp
index c4049ae6315..acc18c0a066 100644
--- a/src/server/shared/Utilities/Util.cpp
+++ b/src/server/shared/Utilities/Util.cpp
@@ -197,7 +197,7 @@ int64 MoneyStringToMoney(const std::string& moneyString)
if (gCount + sCount + cCount != 1)
return 0;
- uint64 amount = atol(*itr);
+ uint64 amount = atoull(*itr);
if (gCount == 1)
money += amount * 100 * 100;
else if (sCount == 1)