aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSpp <spp@jorge.gr>2013-03-25 14:34:22 +0100
committerSpp <spp@jorge.gr>2013-03-25 14:34:22 +0100
commitc97c381ea0b63963b3756f531b8c64636cb5d66b (patch)
treec5a99580d20b16b3eb957faab142b7761fefd507 /src
parent132cc295ca7f1eeb29aaa1ff821faa47ef3478f9 (diff)
parent1a6a23ec96c7646d2753198f93eaba62d2732a83 (diff)
Merge branch 'master' into 4.3.4
Conflicts: src/server/game/Entities/Object/Object.cpp src/server/game/Entities/Object/Object.h src/server/game/Entities/Pet/Pet.cpp src/server/game/Entities/Player/Player.cpp src/server/game/Entities/Player/Player.h src/server/game/Events/GameEventMgr.cpp src/server/game/Loot/LootMgr.cpp src/server/shared/Packets/ByteBuffer.h
Diffstat (limited to 'src')
-rw-r--r--src/server/authserver/Authentication/AuthCodes.h13
-rw-r--r--src/server/game/Entities/Creature/Creature.h6
-rw-r--r--src/server/game/Entities/GameObject/GameObject.h1
-rw-r--r--src/server/game/Entities/Object/Object.cpp199
-rw-r--r--src/server/game/Entities/Object/Object.h111
-rw-r--r--src/server/game/Entities/Object/Updates/UpdateData.h2
-rw-r--r--src/server/game/Entities/Pet/Pet.cpp60
-rw-r--r--src/server/game/Entities/Player/Player.cpp16
-rw-r--r--src/server/game/Entities/Player/Player.h4
-rw-r--r--src/server/game/Entities/Player/SocialMgr.cpp11
-rw-r--r--src/server/game/Entities/Player/SocialMgr.h1
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp2
-rw-r--r--src/server/game/Entities/Unit/Unit.h42
-rw-r--r--src/server/game/Events/GameEventMgr.cpp4
-rw-r--r--src/server/game/Globals/ObjectAccessor.cpp29
-rw-r--r--src/server/game/Globals/ObjectAccessor.h29
-rw-r--r--src/server/game/Grids/GridDefines.h6
-rw-r--r--src/server/game/Grids/NGrid.h13
-rw-r--r--src/server/game/Groups/Group.cpp10
-rw-r--r--src/server/game/Instances/InstanceSaveMgr.cpp3
-rw-r--r--src/server/game/Loot/LootMgr.cpp8
-rw-r--r--src/server/game/Maps/MapInstanced.cpp2
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.h13
-rw-r--r--src/server/game/Spells/Spell.h4
-rw-r--r--src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp1
-rw-r--r--src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp2
-rw-r--r--src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp20
-rw-r--r--src/server/scripts/Outland/zone_shattrath_city.cpp54
-rw-r--r--src/server/scripts/Spells/spell_item.cpp3
-rw-r--r--src/server/shared/CMakeLists.txt3
-rw-r--r--src/server/shared/Containers.h1
-rw-r--r--src/server/shared/Cryptography/Authentication/AuthCrypt.cpp13
-rw-r--r--src/server/shared/Cryptography/Authentication/AuthCrypt.h1
-rw-r--r--src/server/shared/Cryptography/BigNumber.cpp9
-rw-r--r--src/server/shared/Cryptography/HMACSHA1.cpp2
-rw-r--r--src/server/shared/DataStores/DB2Store.h3
-rw-r--r--src/server/shared/Database/DatabaseWorkerPool.h4
-rw-r--r--src/server/shared/Debugging/Errors.cpp38
-rw-r--r--src/server/shared/Debugging/Errors.h24
-rw-r--r--src/server/shared/Debugging/WheatyExceptionReport.cpp2
-rw-r--r--src/server/shared/Logging/Appender.cpp2
-rw-r--r--src/server/shared/Logging/Appender.h13
-rw-r--r--src/server/shared/Logging/LogOperation.h3
-rw-r--r--src/server/shared/Packets/ByteBuffer.cpp95
-rw-r--r--src/server/shared/Packets/ByteBuffer.h142
-rw-r--r--src/server/worldserver/worldserver.conf.dist3
46 files changed, 563 insertions, 464 deletions
diff --git a/src/server/authserver/Authentication/AuthCodes.h b/src/server/authserver/Authentication/AuthCodes.h
index 416d14ba5a0..df7de3ed684 100644
--- a/src/server/authserver/Authentication/AuthCodes.h
+++ b/src/server/authserver/Authentication/AuthCodes.h
@@ -30,17 +30,22 @@ enum AuthResult
WOW_FAIL_DB_BUSY = 0x08,
WOW_FAIL_VERSION_INVALID = 0x09,
WOW_FAIL_VERSION_UPDATE = 0x0A,
+ WOW_FAIL_INVALID_SERVER = 0x0B,
WOW_FAIL_SUSPENDED = 0x0C,
+ WOW_FAIL_FAIL_NOACCESS = 0x0D,
WOW_SUCCESS_SURVEY = 0x0E,
WOW_FAIL_PARENTCONTROL = 0x0F,
WOW_FAIL_LOCKED_ENFORCED = 0x10,
WOW_FAIL_TRIAL_ENDED = 0x11,
WOW_FAIL_USE_BATTLENET = 0x12,
- WOW_FAIL_TOO_FAST = 0x16,
- WOW_FAIL_CHARGEBACK = 0x17,
+ WOW_FAIL_ANTI_INDULGENCE = 0x13,
+ WOW_FAIL_EXPIRED = 0x14,
+ WOW_FAIL_NO_GAME_ACCOUNT = 0x15,
+ WOW_FAIL_CHARGEBACK = 0x16,
+ WOW_FAIL_INTERNET_GAME_ROOM_WITHOUT_BNET = 0x17,
WOW_FAIL_GAME_ACCOUNT_LOCKED = 0x18,
- WOW_FAIL_INTERNET_GAME_ROOM_WITHOUT_BNET = 0x19,
- WOW_FAIL_UNLOCKABLE_LOCK = 0x20,
+ WOW_FAIL_UNLOCKABLE_LOCK = 0x19,
+ WOW_FAIL_CONVERSION_REQUIRED = 0x20,
WOW_FAIL_DISCONNECTED = 0xFF
};
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index c4c768c445a..4d55b97732d 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -29,13 +29,13 @@
#include <list>
-class SpellInfo;
-
class CreatureAI;
+class CreatureGroup;
+class Group;
class Quest;
class Player;
+class SpellInfo;
class WorldSession;
-class CreatureGroup;
enum CreatureFlagsExtra
{
diff --git a/src/server/game/Entities/GameObject/GameObject.h b/src/server/game/Entities/GameObject/GameObject.h
index 94444ac8765..b1d55a6b200 100644
--- a/src/server/game/Entities/GameObject/GameObject.h
+++ b/src/server/game/Entities/GameObject/GameObject.h
@@ -27,6 +27,7 @@
#include "DatabaseEnv.h"
class GameObjectAI;
+class Group;
#define MAX_GAMEOBJECT_QUEST_ITEMS 6
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index e0a183b48de..c1eb9821935 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -16,13 +16,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "Object.h"
#include "Common.h"
#include "SharedDefines.h"
#include "WorldPacket.h"
#include "Opcodes.h"
#include "Log.h"
#include "World.h"
-#include "Object.h"
#include "Creature.h"
#include "Player.h"
#include "Vehicle.h"
@@ -200,8 +200,9 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
updateType = UPDATETYPE_CREATE_OBJECT2;
break;
case HIGHGUID_UNIT:
- if (ToUnit()->ToTempSummon() && IS_PLAYER_GUID(ToUnit()->ToTempSummon()->GetSummonerGUID()))
- updateType = UPDATETYPE_CREATE_OBJECT2;
+ if (TempSummon const* summon = ToUnit()->ToTempSummon())
+ if (IS_PLAYER_GUID(summon->GetSummonerGUID()))
+ updateType = UPDATETYPE_CREATE_OBJECT2;
break;
case HIGHGUID_GAMEOBJECT:
if (IS_PLAYER_GUID(ToGameObject()->GetOwnerGUID()))
@@ -214,7 +215,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
// UPDATETYPE_CREATE_OBJECT2 for some gameobject types...
if (isType(TYPEMASK_GAMEOBJECT))
{
- switch (((GameObject*)this)->GetGoType())
+ switch (ToGameObject()->GetGoType())
{
case GAMEOBJECT_TYPE_TRAP:
case GAMEOBJECT_TYPE_DUEL_ARBITER:
@@ -231,8 +232,10 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
}
}
- if (ToUnit() && ToUnit()->getVictim())
- flags |= UPDATEFLAG_HAS_TARGET;
+ if (Unit const* unit = ToUnit())
+ if (unit->getVictim())
+ flags |= UPDATEFLAG_HAS_TARGET;
+
ByteBuffer buf(500);
buf << uint8(updateType);
@@ -349,6 +352,17 @@ uint16 Object::GetUInt16Value(uint16 index, uint8 offset) const
void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
{
+ Unit const* self = NULL;
+ ObjectGuid guid = GetGUID();
+ uint32 movementFlags = 0;
+ uint16 movementFlagsExtra = 0;
+
+ bool hasFallDirection = false;
+ bool hasFallData = false;
+ bool hasPitch = false;
+ bool hasSpline = false;
+ bool hasSplineElevation = false;
+
uint32 unkLoopCounter = 0;
// Bit content
data->WriteBit(0);
@@ -369,10 +383,16 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
if (flags & UPDATEFLAG_LIVING)
{
- Unit const* self = ToUnit();
- ObjectGuid guid = GetGUID();
- uint32 movementFlags = self->m_movementInfo.GetMovementFlags();
- uint16 movementFlagsExtra = self->m_movementInfo.GetExtraMovementFlags();
+ self = ToUnit();
+ movementFlags = self->m_movementInfo.GetMovementFlags();
+ movementFlagsExtra = self->m_movementInfo.GetExtraMovementFlags();
+ hasPitch = ((movementFlags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) ||
+ (movementFlagsExtra & MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING));
+ hasSpline = self->IsSplineEnabled();
+ hasSplineElevation = movementFlags & MOVEMENTFLAG_SPLINE_ELEVATION;
+ hasFallData = movementFlagsExtra & MOVEMENTFLAG2_INTERPOLATED_TURNING;
+ hasFallDirection = movementFlags & MOVEMENTFLAG_FALLING;
+
if (GetTypeId() == TYPEID_UNIT)
movementFlags &= MOVEMENTFLAG_MASK_CREATURE_ALLOWED;
@@ -385,14 +405,14 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
data->WriteBits(movementFlags, 30);
data->WriteBit(0);
- data->WriteBit(!((movementFlags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) ||
- (movementFlagsExtra & MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING))); // Has pitch
- data->WriteBit(self->IsSplineEnabled()); // Has spline data
- data->WriteBit(movementFlagsExtra & MOVEMENTFLAG2_INTERPOLATED_TURNING);// Has fall data
- data->WriteBit(!(movementFlags & MOVEMENTFLAG_SPLINE_ELEVATION)); // Has spline elevation
+ data->WriteBit(!hasPitch); // Has pitch
+ data->WriteBit(hasSpline); // Has spline data
+ data->WriteBit(hasFallData); // Has fall data
+ data->WriteBit(!hasSplineElevation); // Has spline elevation
data->WriteBit(guid[5]);
data->WriteBit(self->m_movementInfo.t_guid); // Has transport data
data->WriteBit(0); // Is missing time
+
if (self->m_movementInfo.t_guid)
{
ObjectGuid transGuid = self->m_movementInfo.t_guid;
@@ -410,12 +430,13 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
}
data->WriteBit(guid[4]);
- if (self->IsSplineEnabled())
+
+ if (hasSpline)
Movement::PacketBuilder::WriteCreateBits(*self->movespline, *data);
data->WriteBit(guid[6]);
- if (movementFlagsExtra & MOVEMENTFLAG2_INTERPOLATED_TURNING)
- data->WriteBit(movementFlags & MOVEMENTFLAG_FALLING);
+ if (hasFallData)
+ data->WriteBit(hasFallDirection);
data->WriteBit(guid[0]);
data->WriteBit(guid[1]);
@@ -443,7 +464,7 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
if (flags & UPDATEFLAG_HAS_TARGET)
{
- ObjectGuid victimGuid = ToUnit()->getVictim()->GetGUID(); // checked in BuildCreateUpdateBlockForPlayer
+ ObjectGuid victimGuid = self->getVictim()->GetGUID(); // checked in BuildCreateUpdateBlockForPlayer
data->WriteBit(victimGuid[2]);
data->WriteBit(victimGuid[7]);
data->WriteBit(victimGuid[0]);
@@ -469,18 +490,12 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
if (flags & UPDATEFLAG_LIVING)
{
- Unit const* self = ToUnit();
- ObjectGuid guid = GetGUID();
- uint32 movementFlags = self->m_movementInfo.GetMovementFlags();
- uint16 movementFlagsExtra = self->m_movementInfo.GetExtraMovementFlags();
- if (GetTypeId() == TYPEID_UNIT)
- movementFlags &= MOVEMENTFLAG_MASK_CREATURE_ALLOWED;
-
data->WriteByteSeq(guid[4]);
*data << self->GetSpeed(MOVE_RUN_BACK);
- if (movementFlagsExtra & MOVEMENTFLAG2_INTERPOLATED_TURNING)
+
+ if (hasFallData)
{
- if (movementFlags & MOVEMENTFLAG_FALLING)
+ if (hasFallDirection)
{
*data << float(self->m_movementInfo.j_cosAngle);
*data << float(self->m_movementInfo.j_xyspeed);
@@ -492,14 +507,15 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
}
*data << self->GetSpeed(MOVE_SWIM_BACK);
- if (movementFlags & MOVEMENTFLAG_SPLINE_ELEVATION)
+ if (hasSplineElevation)
*data << float(self->m_movementInfo.splineElevation);
- if (self->IsSplineEnabled())
+ if (hasSpline)
Movement::PacketBuilder::WriteCreateData(*self->movespline, *data);
*data << float(self->GetPositionZMinusOffset());
data->WriteByteSeq(guid[5]);
+
if (self->m_movementInfo.t_guid)
{
ObjectGuid transGuid = self->m_movementInfo.t_guid;
@@ -547,8 +563,7 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
*data << float(self->GetOrientation());
*data << self->GetSpeed(MOVE_RUN);
- if ((movementFlags & (MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_FLYING)) ||
- (movementFlagsExtra & MOVEMENTFLAG2_ALWAYS_ALLOW_PITCHING))
+ if (hasPitch)
*data << float(self->m_movementInfo.pitch);
*data << self->GetSpeed(MOVE_FLIGHT);
@@ -556,7 +571,6 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
if (flags & UPDATEFLAG_VEHICLE)
{
- Unit const* self = ToUnit();
*data << float(self->GetOrientation());
*data << uint32(self->GetVehicleKit()->GetVehicleInfo()->m_ID);
}
@@ -625,7 +639,7 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
if (flags & UPDATEFLAG_HAS_TARGET)
{
- ObjectGuid victimGuid = ToUnit()->getVictim()->GetGUID(); // checked in BuildCreateUpdateBlockForPlayer
+ ObjectGuid victimGuid = self->getVictim()->GetGUID(); // checked in BuildCreateUpdateBlockForPlayer
data->WriteByteSeq(victimGuid[4]);
data->WriteByteSeq(victimGuid[0]);
data->WriteByteSeq(victimGuid[3]);
@@ -650,45 +664,50 @@ void Object::_BuildMovementUpdate(ByteBuffer* data, uint16 flags) const
*data << uint32(getMSTime()); // Unknown - getMSTime is wrong.
}
-void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask* updateMask, Player* target) const
+void Object::_BuildValuesUpdate(uint8 updateType, ByteBuffer* data, UpdateMask* updateMask, Player* target) const
{
if (!target)
return;
bool IsActivateToQuest = false;
- if (updatetype == UPDATETYPE_CREATE_OBJECT || updatetype == UPDATETYPE_CREATE_OBJECT2)
- {
- if (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsDynTransport())
- {
- if (((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
- IsActivateToQuest = true;
- if (((GameObject*)this)->GetGoArtKit())
- updateMask->SetBit(GAMEOBJECT_BYTES_1);
- }
- else if (isType(TYPEMASK_UNIT))
- {
- if (((Unit*)this)->HasFlag(UNIT_FIELD_AURASTATE, PER_CASTER_AURA_STATE_MASK))
- updateMask->SetBit(UNIT_FIELD_AURASTATE);
- }
+ // Before trying to convert to each type there is a check, so safe
+ Unit const* unit = ToUnit();
+ GameObject const* go = ToGameObject();
+
+ if (unit)
+ {
+ if (unit->HasFlag(UNIT_FIELD_AURASTATE, PER_CASTER_AURA_STATE_MASK))
+ updateMask->SetBit(UNIT_FIELD_AURASTATE);
}
- else // case UPDATETYPE_VALUES
+ else if (go)
{
- if (isType(TYPEMASK_GAMEOBJECT) && !((GameObject*)this)->IsTransport())
+ if (updateType == UPDATETYPE_CREATE_OBJECT || updateType == UPDATETYPE_CREATE_OBJECT2)
{
- if (((GameObject*)this)->ActivateToQuest(target) || target->isGameMaster())
- IsActivateToQuest = true;
-
- updateMask->SetBit(GAMEOBJECT_BYTES_1);
+ if (!go->IsDynTransport())
+ {
+ if (go->ActivateToQuest(target) || target->isGameMaster())
+ IsActivateToQuest = true;
- if (ToGameObject()->GetGoType() == GAMEOBJECT_TYPE_CHEST && ToGameObject()->GetGOInfo()->chest.groupLootRules &&
- ToGameObject()->HasLootRecipient())
- updateMask->SetBit(GAMEOBJECT_FLAGS);
+ if (go->GetGoArtKit())
+ updateMask->SetBit(GAMEOBJECT_BYTES_1);
+ }
}
- else if (isType(TYPEMASK_UNIT))
+ else
{
- if (((Unit*)this)->HasFlag(UNIT_FIELD_AURASTATE, PER_CASTER_AURA_STATE_MASK))
- updateMask->SetBit(UNIT_FIELD_AURASTATE);
+ if (!go->IsTransport())
+ {
+ if (go->ActivateToQuest(target) || target->isGameMaster())
+ IsActivateToQuest = true;
+
+ updateMask->SetBit(GAMEOBJECT_BYTES_1);
+
+ if (go->GetGoType() == GAMEOBJECT_TYPE_CHEST && go->GetGOInfo()->chest.groupLootRules &&
+ go->HasLootRecipient())
+ {
+ updateMask->SetBit(GAMEOBJECT_FLAGS);
+ }
+ }
}
}
@@ -696,14 +715,15 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask*
if (GetTypeId() == TYPEID_PLAYER && target != this)
valCount = PLAYER_END_NOT_SELF;
- WPAssert(updateMask && updateMask->GetCount() == valCount);
+ ASSERT(updateMask && updateMask->GetCount() == valCount);
- *data << (uint8)updateMask->GetBlockCount();
+ *data << uint8(updateMask->GetBlockCount());
updateMask->AppendToPacket(data);
// 2 specialized loops for speed optimization in non-unit case
- if (isType(TYPEMASK_UNIT)) // unit (creature/player) case
+ if (unit) // unit (creature/player) case
{
+ Creature const* creature = ToCreature();
for (uint16 index = 0; index < valCount; ++index)
{
if (updateMask->GetBit(index))
@@ -720,7 +740,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask*
if (appendValue & UNIT_NPC_FLAG_TRAINER)
{
- if (!this->ToCreature()->isCanTrainingOf(target, false))
+ if (!creature->isCanTrainingOf(target, false))
appendValue &= ~(UNIT_NPC_FLAG_TRAINER | UNIT_NPC_FLAG_TRAINER_CLASS | UNIT_NPC_FLAG_TRAINER_PROFESSION);
}
}
@@ -729,8 +749,8 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask*
}
else if (index == UNIT_FIELD_AURASTATE)
{
- // Check per caster aura states to not enable using a pell in client if specified aura is not by target
- *data << ((Unit*)this)->BuildAuraStateUpdateForTarget(target);
+ // Check per caster aura states to not enable using a spell in client if specified aura is not by target
+ *data << unit->BuildAuraStateUpdateForTarget(target);
}
// FIXME: Some values at server stored in float format but must be sent to client in uint32 format
else if (index >= UNIT_FIELD_BASEATTACKTIME && index <= UNIT_FIELD_RANGEDATTACKTIME)
@@ -759,7 +779,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask*
{
if (GetTypeId() == TYPEID_UNIT)
{
- CreatureTemplate const* cinfo = ToCreature()->GetCreatureTemplate();
+ CreatureTemplate const* cinfo = creature->GetCreatureTemplate();
// this also applies for transform auras
if (SpellInfo const* transform = sSpellMgr->GetSpellInfo(ToUnit()->getTransForm()))
@@ -799,7 +819,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask*
{
uint32 dynamicFlags = m_uint32Values[index];
- if (Creature const* creature = ToCreature())
+ if (creature)
{
if (creature->hasLootRecipient())
{
@@ -824,16 +844,14 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask*
}
// unit UNIT_DYNFLAG_TRACK_UNIT should only be sent to caster of SPELL_AURA_MOD_STALKED auras
- if (Unit const* unit = ToUnit())
- if (dynamicFlags & UNIT_DYNFLAG_TRACK_UNIT)
- if (!unit->HasAuraTypeWithCaster(SPELL_AURA_MOD_STALKED, target->GetGUID()))
- dynamicFlags &= ~UNIT_DYNFLAG_TRACK_UNIT;
+ if (dynamicFlags & UNIT_DYNFLAG_TRACK_UNIT)
+ if (!unit->HasAuraTypeWithCaster(SPELL_AURA_MOD_STALKED, target->GetGUID()))
+ dynamicFlags &= ~UNIT_DYNFLAG_TRACK_UNIT;
*data << dynamicFlags;
}
// FG: pretend that OTHER players in own group are friendly ("blue")
else if (index == UNIT_FIELD_BYTES_2 || index == UNIT_FIELD_FACTIONTEMPLATE)
{
- Unit const* unit = ToUnit();
if (unit->IsControlledByPlayer() && target != this && sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && unit->IsInRaidWith(target))
{
FactionTemplateEntry const* ft1 = unit->getFactionTemplateEntry();
@@ -866,7 +884,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask*
}
}
}
- else if (isType(TYPEMASK_GAMEOBJECT)) // gameobject case
+ else if (go) // gameobject case
{
for (uint16 index = 0; index < valCount; ++index)
{
@@ -877,7 +895,7 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask*
{
if (IsActivateToQuest)
{
- switch (ToGameObject()->GetGoType())
+ switch (go->GetGoType())
{
case GAMEOBJECT_TYPE_CHEST:
if (target->isGameMaster())
@@ -910,8 +928,8 @@ void Object::_BuildValuesUpdate(uint8 updatetype, ByteBuffer* data, UpdateMask*
else if (index == GAMEOBJECT_FLAGS)
{
uint32 flags = m_uint32Values[index];
- if (ToGameObject()->GetGoType() == GAMEOBJECT_TYPE_CHEST)
- if (ToGameObject()->GetGOInfo()->chest.groupLootRules && !ToGameObject()->IsLootAllowedFor(target))
+ if (go->GetGoType() == GAMEOBJECT_TYPE_CHEST)
+ if (go->GetGOInfo()->chest.groupLootRules && !go->IsLootAllowedFor(target))
flags |= GO_FLAG_LOCKED | GO_FLAG_NOT_SELECTABLE;
*data << flags;
@@ -1444,6 +1462,14 @@ bool Object::PrintIndexError(uint32 index, bool set) const
return false;
}
+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));
+}
+
bool Position::HasInLine(WorldObject const* target, float width) const
{
if (!HasInArc(M_PI, target))
@@ -2187,7 +2213,7 @@ bool WorldObject::CanDetect(WorldObject const* obj, bool ignoreStealth) const
const WorldObject* seer = this;
// Pets don't have detection, they use the detection of their masters
- if (const Unit* thisUnit = ToUnit())
+ if (Unit const* thisUnit = ToUnit())
if (Unit* controller = thisUnit->GetCharmerOrOwner())
seer = controller;
@@ -2239,8 +2265,9 @@ bool WorldObject::CanDetectStealthOf(WorldObject const* obj) const
float distance = GetExactDist(obj);
float combatReach = 0.0f;
- if (isType(TYPEMASK_UNIT))
- combatReach = ((Unit*)this)->GetCombatReach();
+ Unit const* unit = ToUnit();
+ if (unit)
+ combatReach = unit->GetCombatReach();
if (distance < combatReach)
return true;
@@ -2248,14 +2275,14 @@ bool WorldObject::CanDetectStealthOf(WorldObject const* obj) const
if (!HasInArc(M_PI, obj))
return false;
+ GameObject const* go = ToGameObject();
for (uint32 i = 0; i < TOTAL_STEALTH_TYPES; ++i)
{
if (!(obj->m_stealth.GetFlags() & (1 << i)))
continue;
- if (isType(TYPEMASK_UNIT))
- if (((Unit*)this)->HasAuraTypeWithMiscvalue(SPELL_AURA_DETECT_STEALTH, i))
- return true;
+ if (unit && unit->HasAuraTypeWithMiscvalue(SPELL_AURA_DETECT_STEALTH, i))
+ return true;
// Starting points
int32 detectionValue = 30;
@@ -2267,8 +2294,8 @@ bool WorldObject::CanDetectStealthOf(WorldObject const* obj) const
// Apply modifiers
detectionValue += m_stealthDetect.GetValue(StealthType(i));
- if (obj->isType(TYPEMASK_GAMEOBJECT))
- if (Unit* owner = ((GameObject*)obj)->GetOwner())
+ if (go)
+ if (Unit* owner = go->GetOwner())
detectionValue -= int32(owner->getLevelForTarget(this) - 1) * 5;
detectionValue -= obj->m_stealth.GetValue(StealthType(i));
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index 622b60cd7af..66d8f533a09 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -21,10 +21,8 @@
#include "Common.h"
#include "UpdateMask.h"
-#include "UpdateData.h"
#include "GridReference.h"
#include "ObjectDefines.h"
-#include "GridDefines.h"
#include "Map.h"
#include <set>
@@ -101,20 +99,20 @@ enum NotifyFlags
NOTIFY_ALL = 0xFF
};
-class WorldPacket;
-class UpdateData;
-class ByteBuffer;
-class WorldSession;
+class Corpse;
class Creature;
-class Player;
-class InstanceScript;
+class CreatureAI;
+class DynamicObject;
class GameObject;
+class InstanceScript;
+class Player;
class TempSummon;
-class Vehicle;
-class CreatureAI;
-class ZoneScript;
-class Unit;
class Transport;
+class Unit;
+class UpdateData;
+class WorldObject;
+class WorldPacket;
+class ZoneScript;
typedef UNORDERED_MAP<Player*, UpdateData> UpdateDataMapType;
@@ -351,17 +349,24 @@ struct Position
float m_orientation;
//public:
+ bool operator==(Position const &a);
+
+ inline bool operator!=(Position const &a)
+ {
+ return !(operator==(a));
+ }
+
void Relocate(float x, float y)
{ m_positionX = x; m_positionY = y;}
void Relocate(float x, float y, float z)
{ m_positionX = x; m_positionY = y; m_positionZ = z; }
void Relocate(float x, float y, float z, float orientation)
{ m_positionX = x; m_positionY = y; m_positionZ = z; SetOrientation(orientation); }
- void Relocate(const Position &pos)
+ void Relocate(Position const &pos)
{ m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; SetOrientation(pos.m_orientation); }
- void Relocate(const Position* pos)
+ void Relocate(Position const* pos)
{ m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; SetOrientation(pos->m_orientation); }
- void RelocateOffset(const Position &offset);
+ void RelocateOffset(Position const &offset);
void SetOrientation(float orientation)
{ m_orientation = NormalizeOrientation(orientation); }
@@ -397,37 +402,37 @@ struct Position
{ float dx = m_positionX - x; float dy = m_positionY - y; return dx*dx + dy*dy; }
float GetExactDist2d(const float x, const float y) const
{ return sqrt(GetExactDist2dSq(x, y)); }
- float GetExactDist2dSq(const Position* pos) const
+ float GetExactDist2dSq(Position const* pos) const
{ float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; return dx*dx + dy*dy; }
- float GetExactDist2d(const Position* pos) const
+ float GetExactDist2d(Position const* pos) const
{ return sqrt(GetExactDist2dSq(pos)); }
float GetExactDistSq(float x, float y, float z) const
{ float dz = m_positionZ - z; return GetExactDist2dSq(x, y) + dz*dz; }
float GetExactDist(float x, float y, float z) const
{ return sqrt(GetExactDistSq(x, y, z)); }
- float GetExactDistSq(const Position* pos) const
+ float GetExactDistSq(Position const* pos) const
{ float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; float dz = m_positionZ - pos->m_positionZ; return dx*dx + dy*dy + dz*dz; }
- float GetExactDist(const Position* pos) const
+ float GetExactDist(Position const* pos) const
{ return sqrt(GetExactDistSq(pos)); }
- void GetPositionOffsetTo(const Position & endPos, Position & retOffset) const;
+ void GetPositionOffsetTo(Position const & endPos, Position & retOffset) const;
- float GetAngle(const Position* pos) const;
+ float GetAngle(Position const* pos) const;
float GetAngle(float x, float y) const;
- float GetRelativeAngle(const Position* pos) 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; }
void GetSinCos(float x, float y, float &vsin, float &vcos) const;
bool IsInDist2d(float x, float y, float dist) const
{ return GetExactDist2dSq(x, y) < dist * dist; }
- bool IsInDist2d(const Position* pos, float dist) const
+ bool IsInDist2d(Position const* pos, float dist) const
{ return GetExactDist2dSq(pos) < dist * dist; }
bool IsInDist(float x, float y, float z, float dist) const
{ return GetExactDistSq(x, y, z) < dist * dist; }
- bool IsInDist(const Position* pos, float dist) const
+ bool IsInDist(Position const* pos, float dist) const
{ return GetExactDistSq(pos) < dist * dist; }
- bool HasInArc(float arcangle, const Position* pos, float border = 2.0f) const;
+ bool HasInArc(float arcangle, Position const* pos, float border = 2.0f) const;
bool HasInLine(WorldObject const* target, float width) const;
std::string ToString() const;
@@ -471,23 +476,15 @@ struct MovementInfo
// falling
uint32 fallTime;
// jumping
- float j_zspeed, j_cosAngle, j_sinAngle, j_xyspeed;
+ float j_zspeed, j_sinAngle, j_cosAngle, j_xyspeed;
// spline
float splineElevation;
- MovementInfo()
- {
- pos.Relocate(0, 0, 0, 0);
- guid = 0;
- flags = 0;
- flags2 = 0;
- time = t_time = t_time2 = t_time3 = fallTime = 0;
- splineElevation = 0;
- pitch = j_zspeed = j_sinAngle = j_cosAngle = j_xyspeed = 0.0f;
- t_guid = 0;
- t_pos.Relocate(0, 0, 0, 0);
- t_seat = -1;
- }
+ MovementInfo() :
+ guid(), flags(), flags2(), pos(), time(), t_guid(), t_pos(),
+ t_seat(-1), t_time(), t_time2(), pitch(), fallTime(),
+ j_zspeed(), j_sinAngle(), j_cosAngle(), j_xyspeed()
+ { }
uint32 GetMovementFlags() const { return flags; }
void SetMovementFlags(uint32 flag) { flags = flag; }
@@ -575,14 +572,14 @@ class WorldObject : public Object, public WorldLocation
void MovePositionToFirstCollision(Position &pos, float dist, float angle);
void GetFirstCollisionPosition(Position &pos, float dist, float angle);
void GetRandomNearPosition(Position &pos, float radius);
- void GetContactPoint(const WorldObject* obj, float &x, float &y, float &z, float distance2d = CONTACT_DISTANCE) const;
+ void GetContactPoint(WorldObject const* obj, float &x, float &y, float &z, float distance2d = CONTACT_DISTANCE) const;
float GetObjectSize() const;
void UpdateGroundPositionZ(float x, float y, float &z) const;
void UpdateAllowedPositionZ(float x, float y, float &z) const;
- void GetRandomPoint(const Position &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const;
- void GetRandomPoint(const Position &srcPos, float distance, Position &pos) const;
+ void GetRandomPoint(Position const &srcPos, float distance, float &rand_x, float &rand_y, float &rand_z) const;
+ void GetRandomPoint(Position const &srcPos, float distance, Position &pos) const;
uint32 GetInstanceId() const { return m_InstanceId; }
@@ -602,24 +599,24 @@ class WorldObject : public Object, public WorldLocation
virtual std::string const& GetNameForLocaleIdx(LocaleConstant /*locale_idx*/) const { return m_name; }
- float GetDistance(const WorldObject* obj) const;
- float GetDistance(const Position &pos) const;
+ float GetDistance(WorldObject const* obj) const;
+ float GetDistance(Position const &pos) const;
float GetDistance(float x, float y, float z) const;
- float GetDistance2d(const WorldObject* obj) const;
+ float GetDistance2d(WorldObject const* obj) const;
float GetDistance2d(float x, float y) const;
- float GetDistanceZ(const WorldObject* obj) const;
+ float GetDistanceZ(WorldObject const* obj) const;
- bool IsSelfOrInSameMap(const WorldObject* obj) const;
- bool IsInMap(const WorldObject* obj) const;
+ bool IsSelfOrInSameMap(WorldObject const* obj) const;
+ bool IsInMap(WorldObject const* obj) const;
bool IsWithinDist3d(float x, float y, float z, float dist) const;
- bool IsWithinDist3d(const Position* pos, float dist) const;
+ bool IsWithinDist3d(Position const* pos, float dist) const;
bool IsWithinDist2d(float x, float y, float dist) const;
- bool IsWithinDist2d(const Position* pos, float dist) const;
+ bool IsWithinDist2d(Position const* pos, float dist) const;
// use only if you will sure about placing both object at same map
bool IsWithinDist(WorldObject const* obj, float dist2compare, bool is3D = true) const;
bool IsWithinDistInMap(WorldObject const* obj, float dist2compare, bool is3D = true) const;
bool IsWithinLOS(float x, float y, float z) const;
- bool IsWithinLOSInMap(const WorldObject* obj) const;
+ bool IsWithinLOSInMap(WorldObject const* obj) const;
bool GetDistanceOrder(WorldObject const* obj1, WorldObject const* obj2, bool is3D = true) const;
bool IsInRange(WorldObject const* obj, float minRange, float maxRange, bool is3D = true) const;
bool IsInRange2d(float x, float y, float minRange, float maxRange) const;
@@ -627,7 +624,7 @@ class WorldObject : public Object, public WorldLocation
bool isInFront(WorldObject const* target, float arc = M_PI) const;
bool isInBack(WorldObject const* target, float arc = M_PI) const;
- bool IsInBetween(const WorldObject* obj1, const WorldObject* obj2, float size = 0) const;
+ bool IsInBetween(WorldObject const* obj1, WorldObject const* obj2, float size = 0) const;
virtual void CleanupsBeforeDelete(bool finalCleanup = true); // used in destructor or explicitly before mass creature delete to remove cross-references to already deleted units
@@ -658,7 +655,7 @@ class WorldObject : public Object, public WorldLocation
float GetGridActivationRange() const;
float GetVisibilityRange() const;
- float GetSightRange(const WorldObject* target = NULL) const;
+ float GetSightRange(WorldObject const* target = NULL) const;
bool canSeeOrDetect(WorldObject const* obj, bool ignoreStealth = false, bool distanceCheck = false) const;
FlaggedValuesArray32<int32, uint32, StealthType, TOTAL_STEALTH_TYPES> m_stealth;
@@ -685,7 +682,7 @@ class WorldObject : public Object, public WorldLocation
void SetZoneScript();
ZoneScript* GetZoneScript() const { return m_zoneScript; }
- TempSummon* SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0) const;
+ TempSummon* SummonCreature(uint32 id, Position const &pos, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0, uint32 vehId = 0) const;
TempSummon* SummonCreature(uint32 id, float x, float y, float z, float ang = 0, TempSummonType spwtype = TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime = 0) const;
GameObject* SummonGameObject(uint32 entry, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime);
Creature* SummonTrigger(float x, float y, float z, float ang, uint32 dur, CreatureAI* (*GetAI)(Creature*) = NULL);
@@ -787,13 +784,13 @@ namespace Trinity
class ObjectDistanceOrderPred
{
public:
- ObjectDistanceOrderPred(const WorldObject* pRefObj, bool ascending = true) : m_refObj(pRefObj), m_ascending(ascending) {}
- bool operator()(const WorldObject* pLeft, const WorldObject* pRight) const
+ ObjectDistanceOrderPred(WorldObject const* pRefObj, bool ascending = true) : m_refObj(pRefObj), m_ascending(ascending) {}
+ bool operator()(WorldObject const* pLeft, WorldObject const* pRight) const
{
return m_ascending ? m_refObj->GetDistanceOrder(pLeft, pRight) : !m_refObj->GetDistanceOrder(pLeft, pRight);
}
private:
- const WorldObject* m_refObj;
+ WorldObject const* m_refObj;
const bool m_ascending;
};
}
diff --git a/src/server/game/Entities/Object/Updates/UpdateData.h b/src/server/game/Entities/Object/Updates/UpdateData.h
index 7d84c991ef4..c782ec99929 100644
--- a/src/server/game/Entities/Object/Updates/UpdateData.h
+++ b/src/server/game/Entities/Object/Updates/UpdateData.h
@@ -20,6 +20,8 @@
#define __UPDATEDATA_H
#include "ByteBuffer.h"
+#include <set>
+
class WorldPacket;
enum OBJECT_UPDATE_TYPE
diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp
index 2d598d78236..b3cba647c7a 100644
--- a/src/server/game/Entities/Pet/Pet.cpp
+++ b/src/server/game/Entities/Pet/Pet.cpp
@@ -35,9 +35,10 @@
#define PET_XP_FACTOR 0.05f
-Pet::Pet(Player* owner, PetType type) : Guardian(NULL, owner, true),
- m_usedTalentCount(0), m_removed(false), m_petType(type), m_duration(0),
- m_auraRaidUpdateMask(0), m_loading(false), m_declinedname(NULL)
+Pet::Pet(Player* owner, PetType type) :
+ Guardian(NULL, owner, true), m_usedTalentCount(0), m_removed(false),
+ m_petType(type), m_duration(0), m_auraRaidUpdateMask(0), m_loading(false),
+ m_declinedname(NULL)
{
ASSERT(m_owner->GetTypeId() == TYPEID_PLAYER);
@@ -554,7 +555,7 @@ void Pet::Update(uint32 diff)
{
if (owner->GetPetGUID() != GetGUID())
{
- sLog->outError(LOG_FILTER_PETS, "Pet %u is not pet of owner %s, removed", GetEntry(), m_owner->GetName().c_str());
+ sLog->outError(LOG_FILTER_PETS, "Pet %u is not pet of owner %s, removed", GetEntry(), GetOwner()->GetName().c_str());
Remove(getPetType() == HUNTER_PET?PET_SAVE_AS_DELETED:PET_SAVE_NOT_IN_SLOT);
return;
}
@@ -788,19 +789,24 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
//Determine pet type
PetType petType = MAX_PET_TYPE;
- if (isPet() && m_owner->GetTypeId() == TYPEID_PLAYER)
+ if (isPet() && GetOwner()->GetTypeId() == TYPEID_PLAYER)
{
- if ((m_owner->getClass() == CLASS_WARLOCK)
- || (m_owner->getClass() == CLASS_SHAMAN) // Fire Elemental
- || (m_owner->getClass() == CLASS_DEATH_KNIGHT)) // Risen Ghoul
+ if (GetOwner()->getClass() == CLASS_WARLOCK
+ || GetOwner()->getClass() == CLASS_SHAMAN // Fire Elemental
+ || GetOwner()->getClass() == CLASS_DEATH_KNIGHT) // Risen Ghoul
+ {
petType = SUMMON_PET;
- else if (m_owner->getClass() == CLASS_HUNTER)
+ }
+ else if (GetOwner()->getClass() == CLASS_HUNTER)
{
petType = HUNTER_PET;
m_unitTypeMask |= UNIT_MASK_HUNTER_PET;
}
else
- sLog->outError(LOG_FILTER_PETS, "Unknown type pet %u is summoned by player class %u", GetEntry(), m_owner->getClass());
+ {
+ sLog->outError(LOG_FILTER_PETS, "Unknown type pet %u is summoned by player class %u",
+ GetEntry(), GetOwner()->getClass());
+ }
}
uint32 creature_ID = (petType == HUNTER_PET) ? 1 : cinfo->Entry;
@@ -868,12 +874,14 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
{
case SUMMON_PET:
{
- //the damage bonus used for pets is either fire or shadow damage, whatever is higher
- uint32 fire = m_owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE);
- uint32 shadow = m_owner->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW);
- uint32 val = (fire > shadow) ? fire : shadow;
- SetBonusDamage(int32 (val * 0.15f));
- //bonusAP += val * 0.57;
+ // the damage bonus used for pets is either fire or shadow damage, whatever is higher
+ int32 fire = GetOwner()->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_FIRE);
+ int32 shadow = GetOwner()->GetUInt32Value(PLAYER_FIELD_MOD_DAMAGE_DONE_POS + SPELL_SCHOOL_SHADOW);
+ int32 val = (fire > shadow) ? fire : shadow;
+ if (val < 0)
+ val = 0;
+
+ SetBonusDamage(val * 0.15f);
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4)));
@@ -898,14 +906,14 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
{
case 510: // mage Water Elemental
{
- SetBonusDamage(int32(m_owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FROST) * 0.33f));
+ SetBonusDamage(int32(GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FROST) * 0.33f));
break;
}
case 1964: //force of nature
{
if (!pInfo)
SetCreateHealth(30 + 30*petlevel);
- float bonusDmg = m_owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_NATURE) * 0.15f;
+ float bonusDmg = GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_NATURE) * 0.15f;
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 2.5f - (petlevel / 2) + bonusDmg));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 2.5f + (petlevel / 2) + bonusDmg));
break;
@@ -925,7 +933,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
SetCreateHealth(40*petlevel);
SetCreateMana(28 + 10*petlevel);
}
- SetBonusDamage(int32(m_owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE) * 0.5f));
+ SetBonusDamage(int32(GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FIRE) * 0.5f));
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel * 4 - petlevel));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel * 4 + petlevel));
break;
@@ -937,7 +945,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
SetCreateMana(28 + 10*petlevel);
SetCreateHealth(28 + 30*petlevel);
}
- int32 bonus_dmg = (int32(m_owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW)* 0.3f));
+ int32 bonus_dmg = int32(GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_SHADOW)* 0.3f);
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float((petlevel * 4 - petlevel) + bonus_dmg));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float((petlevel * 4 + petlevel) + bonus_dmg));
@@ -966,16 +974,16 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float((petlevel * 4 - petlevel)));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float((petlevel * 4 + petlevel)));
- SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(m_owner->GetArmor()) * 0.35f); // Bonus Armor (35% of player armor)
- SetModifierValue(UNIT_MOD_STAT_STAMINA, BASE_VALUE, float(m_owner->GetStat(STAT_STAMINA)) * 0.3f); // Bonus Stamina (30% of player stamina)
+ SetModifierValue(UNIT_MOD_ARMOR, BASE_VALUE, float(GetOwner()->GetArmor()) * 0.35f); // Bonus Armor (35% of player armor)
+ SetModifierValue(UNIT_MOD_STAT_STAMINA, BASE_VALUE, float(GetOwner()->GetStat(STAT_STAMINA)) * 0.3f); // Bonus Stamina (30% of player stamina)
if (!HasAura(58877))//prevent apply twice for the 2 wolves
AddAura(58877, this);//Spirit Hunt, passive, Spirit Wolves' attacks heal them and their master for 150% of damage done.
break;
}
case 31216: // Mirror Image
{
- SetBonusDamage(int32(m_owner->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FROST) * 0.33f));
- SetDisplayId(m_owner->GetDisplayId());
+ SetBonusDamage(int32(GetOwner()->SpellBaseDamageBonusDone(SPELL_SCHOOL_MASK_FROST) * 0.33f));
+ SetDisplayId(GetOwner()->GetDisplayId());
if (!pInfo)
{
SetCreateMana(28 + 30*petlevel);
@@ -990,7 +998,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
SetCreateMana(28 + 10*petlevel);
SetCreateHealth(28 + 30*petlevel);
}
- SetBonusDamage(int32(m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.5f));
+ SetBonusDamage(int32(GetOwner()->GetTotalAttackPowerValue(BASE_ATTACK) * 0.5f));
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - (petlevel / 4)));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel + (petlevel / 4)));
break;
@@ -998,7 +1006,7 @@ bool Guardian::InitStatsForLevel(uint8 petlevel)
case 28017: // Bloodworms
{
SetCreateHealth(4 * petlevel);
- SetBonusDamage(int32(m_owner->GetTotalAttackPowerValue(BASE_ATTACK) * 0.006f));
+ SetBonusDamage(int32(GetOwner()->GetTotalAttackPowerValue(BASE_ATTACK) * 0.006f));
SetBaseWeaponDamage(BASE_ATTACK, MINDAMAGE, float(petlevel - 30 - (petlevel / 4)));
SetBaseWeaponDamage(BASE_ATTACK, MAXDAMAGE, float(petlevel - 30 + (petlevel / 4)));
}
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 806026d9715..fb63f955524 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -11904,14 +11904,8 @@ InventoryResult Player::CanRollForItemInLFG(ItemTemplate const* proto, WorldObje
return EQUIP_ERR_OK;
}
-Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId)
-{
- AllowedLooterSet allowedLooters;
- return StoreNewItem(dest, item, update, randomPropertyId, allowedLooters);
-}
-
// Return stored item (if stored to stack, it can diff. from pItem). And pItem ca be deleted in this case.
-Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet& allowedLooters)
+Item* Player::StoreNewItem(ItemPosCountVec const& dest, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet const& allowedLooters)
{
uint32 count = 0;
for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr)
@@ -12028,7 +12022,6 @@ Item* Player::_StoreItem(uint16 pos, Item* pItem, uint32 count, bool clone, bool
AddEnchantmentDurations(pItem);
AddItemDurations(pItem);
-
const ItemTemplate* proto = pItem->GetTemplate();
for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
if (proto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE && proto->Spells[i].SpellId > 0) // On obtain trigger
@@ -16197,15 +16190,16 @@ void Player::KilledMonsterCredit(uint32 entry, uint64 guid)
{
uint16 addkillcount = 1;
uint32 real_entry = entry;
+ Creature* killed = NULL;
if (guid)
{
- Creature* killed = GetMap()->GetCreature(guid);
+ killed = GetMap()->GetCreature(guid);
if (killed && killed->GetEntry())
real_entry = killed->GetEntry();
}
StartTimedAchievement(ACHIEVEMENT_TIMED_TYPE_CREATURE, real_entry); // MUST BE CALLED FIRST
- UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, real_entry, addkillcount, 0, guid ? GetMap()->GetCreature(guid) : NULL);
+ UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_KILL_CREATURE, real_entry, addkillcount, 0, killed);
for (uint8 i = 0; i < MAX_QUEST_LOG_SIZE; ++i)
{
@@ -26575,7 +26569,7 @@ void Player::RefundItem(Item* item)
{
ItemPosCountVec dest;
InventoryResult msg = CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemid, count);
- ASSERT(msg == EQUIP_ERR_OK) /// Already checked before
+ ASSERT(msg == EQUIP_ERR_OK); /// Already checked before
Item* it = StoreNewItem(dest, itemid, true);
SendNewItem(it, count, true, false, true);
}
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index 097376970dd..e0b24c919a6 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1384,8 +1384,7 @@ class Player : public Unit, public GridObject<Player>
InventoryResult CanUseItem(ItemTemplate const* pItem) const;
InventoryResult CanUseAmmo(uint32 item) const;
InventoryResult CanRollForItemInLFG(ItemTemplate const* item, WorldObject const* lootedObject) const;
- Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0);
- Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId, AllowedLooterSet &allowedLooters);
+ Item* StoreNewItem(ItemPosCountVec const& pos, uint32 item, bool update, int32 randomPropertyId = 0, AllowedLooterSet const& allowedLooters = AllowedLooterSet());
Item* StoreItem(ItemPosCountVec const& pos, Item* pItem, bool update);
Item* EquipNewItem(uint16 pos, uint32 item, bool update);
Item* EquipItem(uint16 pos, Item* pItem, bool update);
@@ -2915,4 +2914,5 @@ template <class T> T Player::ApplySpellMod(uint32 spellId, SpellModOp op, T &bas
basevalue = T((float)basevalue + diff);
return T(diff);
}
+
#endif
diff --git a/src/server/game/Entities/Player/SocialMgr.cpp b/src/server/game/Entities/Player/SocialMgr.cpp
index 1b59a097ff3..dac60d30c69 100644
--- a/src/server/game/Entities/Player/SocialMgr.cpp
+++ b/src/server/game/Entities/Player/SocialMgr.cpp
@@ -28,15 +28,8 @@
#include "AccountMgr.h"
#include "WorldSession.h"
-PlayerSocial::PlayerSocial()
-{
- m_playerGUID = 0;
-}
-
-PlayerSocial::~PlayerSocial()
-{
- m_playerSocialMap.clear();
-}
+PlayerSocial::PlayerSocial(): m_playerGUID()
+{ }
uint32 PlayerSocial::GetNumberOfSocialsWithFlag(SocialFlag flag)
{
diff --git a/src/server/game/Entities/Player/SocialMgr.h b/src/server/game/Entities/Player/SocialMgr.h
index 0e73af8f809..4f2a4fdde72 100644
--- a/src/server/game/Entities/Player/SocialMgr.h
+++ b/src/server/game/Entities/Player/SocialMgr.h
@@ -104,7 +104,6 @@ class PlayerSocial
friend class SocialMgr;
public:
PlayerSocial();
- ~PlayerSocial();
// adding/removing
bool AddToSocialList(uint32 friend_guid, bool ignore);
void RemoveFromSocialList(uint32 friend_guid, bool ignore);
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 69fc0aa9d62..6c03808fea6 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -9000,7 +9000,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin
AddPct(DoneTotalMod, GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DAMAGE_DONE_FOR_MECHANIC, spellProto->Mechanic));
// done scripted mod (take it from owner)
- Unit const * const owner = GetOwner() ? GetOwner() : this;
+ Unit const* owner = GetOwner() ? GetOwner() : this;
AuraEffectList const& mOverrideClassScript= owner->GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
for (AuraEffectList::const_iterator i = mOverrideClassScript.begin(); i != mOverrideClassScript.end(); ++i)
{
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 44d56b3eb99..11e36ad5150 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -19,6 +19,7 @@
#ifndef __UNIT_H
#define __UNIT_H
+#include "DBCStructure.h"
#include "EventProcessor.h"
#include "FollowerReference.h"
#include "FollowerRefManager.h"
@@ -126,14 +127,32 @@ enum SpellValueMod
SPELLVALUE_AURA_STACK
};
-typedef std::pair<SpellValueMod, int32> CustomSpellValueMod;
-class CustomSpellValues : public std::vector<CustomSpellValueMod>
+class CustomSpellValues
{
- public:
- void AddSpellMod(SpellValueMod mod, int32 value)
- {
- push_back(std::make_pair(mod, value));
- }
+ typedef std::pair<SpellValueMod, int32> CustomSpellValueMod;
+ typedef std::vector<CustomSpellValueMod> StorageType;
+
+public:
+ typedef StorageType::const_iterator const_iterator;
+
+public:
+ void AddSpellMod(SpellValueMod mod, int32 value)
+ {
+ storage_.push_back(CustomSpellValueMod(mod, value));
+ }
+
+ const_iterator begin() const
+ {
+ return storage_.begin();
+ }
+
+ const_iterator end() const
+ {
+ return storage_.end();
+ }
+
+private:
+ StorageType storage_;
};
enum SpellFacingFlags
@@ -1424,10 +1443,13 @@ class Unit : public WorldObject
void ProcDamageAndSpell(Unit* victim, uint32 procAttacker, uint32 procVictim, uint32 procEx, uint32 amount, WeaponAttackType attType = BASE_ATTACK, SpellInfo const* procSpell = NULL, SpellInfo const* procAura = NULL);
void ProcDamageAndSpellFor(bool isVictim, Unit* target, uint32 procFlag, uint32 procExtra, WeaponAttackType attType, SpellInfo const* procSpell, uint32 damage, SpellInfo const* procAura = NULL);
- void GetProcAurasTriggeredOnEvent(std::list<AuraApplication*>& aurasTriggeringProc, std::list<AuraApplication*>* procAuras, ProcEventInfo eventInfo);
+ void GetProcAurasTriggeredOnEvent(AuraApplicationList& aurasTriggeringProc, AuraApplicationList* procAuras, ProcEventInfo eventInfo);
void TriggerAurasProcOnEvent(CalcDamageInfo& damageInfo);
- void TriggerAurasProcOnEvent(std::list<AuraApplication*>* myProcAuras, std::list<AuraApplication*>* targetProcAuras, Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget, uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell, DamageInfo* damageInfo, HealInfo* healInfo);
- void TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, std::list<AuraApplication*>& procAuras);
+ void TriggerAurasProcOnEvent(AuraApplicationList* myProcAuras, AuraApplicationList* targetProcAuras,
+ Unit* actionTarget, uint32 typeMaskActor, uint32 typeMaskActionTarget,
+ uint32 spellTypeMask, uint32 spellPhaseMask, uint32 hitMask, Spell* spell,
+ DamageInfo* damageInfo, HealInfo* healInfo);
+ void TriggerAurasProcOnEvent(ProcEventInfo& eventInfo, AuraApplicationList& procAuras);
void HandleEmoteCommand(uint32 anim_id);
void AttackerStateUpdate (Unit* victim, WeaponAttackType attType = BASE_ATTACK, bool extra = false);
diff --git a/src/server/game/Events/GameEventMgr.cpp b/src/server/game/Events/GameEventMgr.cpp
index e6d7fb58928..1b4f687d8c5 100644
--- a/src/server/game/Events/GameEventMgr.cpp
+++ b/src/server/game/Events/GameEventMgr.cpp
@@ -205,7 +205,7 @@ void GameEventMgr::LoadFromDB()
{
{
uint32 oldMSTime = getMSTime();
- // 0 1 2 3 4 5 6 7
+ // 0 1 2 3 4 5 6 7
QueryResult result = WorldDatabase.Query("SELECT eventEntry, UNIX_TIMESTAMP(start_time), UNIX_TIMESTAMP(end_time), occurence, length, holiday, description, world_event FROM game_event");
if (!result)
{
@@ -792,7 +792,7 @@ void GameEventMgr::LoadFromDB()
{
uint32 oldMSTime = getMSTime();
- // 0 1 2 3 4 5 6
+ // 0 1 2 3 4 5 6
QueryResult result = WorldDatabase.Query("SELECT eventEntry, guid, item, maxcount, incrtime, ExtendedCost, type FROM game_event_npc_vendor ORDER BY guid, slot ASC");
if (!result)
diff --git a/src/server/game/Globals/ObjectAccessor.cpp b/src/server/game/Globals/ObjectAccessor.cpp
index 0ea66a056fb..08075235bab 100644
--- a/src/server/game/Globals/ObjectAccessor.cpp
+++ b/src/server/game/Globals/ObjectAccessor.cpp
@@ -47,6 +47,35 @@ ObjectAccessor::~ObjectAccessor()
{
}
+template<class T> T* ObjectAccessor::GetObjectInWorld(uint32 mapid, float x, float y, uint64 guid, T* /*fake*/)
+{
+ T* obj = HashMapHolder<T>::Find(guid);
+ if (!obj || obj->GetMapId() != mapid)
+ return NULL;
+
+ CellCoord p = Trinity::ComputeCellCoord(x, y);
+ if (!p.IsCoordValid())
+ {
+ sLog->outError(LOG_FILTER_GENERAL, "ObjectAccessor::GetObjectInWorld: invalid coordinates supplied X:%f Y:%f grid cell [%u:%u]", x, y, p.x_coord, p.y_coord);
+ return NULL;
+ }
+
+ CellCoord q = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
+ if (!q.IsCoordValid())
+ {
+ sLog->outError(LOG_FILTER_GENERAL, "ObjectAccessor::GetObjecInWorld: object (GUID: %u TypeId: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), q.x_coord, q.y_coord);
+ return NULL;
+ }
+
+ int32 dx = int32(p.x_coord) - int32(q.x_coord);
+ int32 dy = int32(p.y_coord) - int32(q.y_coord);
+
+ if (dx > -2 && dx < 2 && dy > -2 && dy < 2)
+ return obj;
+ else
+ return NULL;
+}
+
Player* ObjectAccessor::GetObjectInWorld(uint64 guid, Player* /*typeSpecifier*/)
{
Player* player = HashMapHolder<Player>::Find(guid);
diff --git a/src/server/game/Globals/ObjectAccessor.h b/src/server/game/Globals/ObjectAccessor.h
index 6a53d58c57f..1abe3550729 100644
--- a/src/server/game/Globals/ObjectAccessor.h
+++ b/src/server/game/Globals/ObjectAccessor.h
@@ -138,34 +138,7 @@ class ObjectAccessor
return NULL;
}
- template<class T> static T* GetObjectInWorld(uint32 mapid, float x, float y, uint64 guid, T* /*fake*/)
- {
- T* obj = HashMapHolder<T>::Find(guid);
- if (!obj || obj->GetMapId() != mapid)
- return NULL;
-
- CellCoord p = Trinity::ComputeCellCoord(x, y);
- if (!p.IsCoordValid())
- {
- sLog->outError(LOG_FILTER_GENERAL, "ObjectAccessor::GetObjectInWorld: invalid coordinates supplied X:%f Y:%f grid cell [%u:%u]", x, y, p.x_coord, p.y_coord);
- return NULL;
- }
-
- CellCoord q = Trinity::ComputeCellCoord(obj->GetPositionX(), obj->GetPositionY());
- if (!q.IsCoordValid())
- {
- sLog->outError(LOG_FILTER_GENERAL, "ObjectAccessor::GetObjecInWorld: object (GUID: %u TypeId: %u) has invalid coordinates X:%f Y:%f grid cell [%u:%u]", obj->GetGUIDLow(), obj->GetTypeId(), obj->GetPositionX(), obj->GetPositionY(), q.x_coord, q.y_coord);
- return NULL;
- }
-
- int32 dx = int32(p.x_coord) - int32(q.x_coord);
- int32 dy = int32(p.y_coord) - int32(q.y_coord);
-
- if (dx > -2 && dx < 2 && dy > -2 && dy < 2)
- return obj;
- else
- return NULL;
- }
+ template<class T> static T* GetObjectInWorld(uint32 mapid, float x, float y, uint64 guid, T* /*fake*/);
// these functions return objects only if in map of specified object
static WorldObject* GetWorldObject(WorldObject const&, uint64);
diff --git a/src/server/game/Grids/GridDefines.h b/src/server/game/Grids/GridDefines.h
index 14c0588c3b4..ad48e4fd128 100644
--- a/src/server/game/Grids/GridDefines.h
+++ b/src/server/game/Grids/GridDefines.h
@@ -85,13 +85,11 @@ template<uint32 LIMIT>
struct CoordPair
{
CoordPair(uint32 x=0, uint32 y=0)
- : x_coord(x)
- , y_coord(y)
+ : x_coord(x), y_coord(y)
{}
CoordPair(const CoordPair<LIMIT> &obj)
- : x_coord(obj.x_coord)
- , y_coord(obj.y_coord)
+ : x_coord(obj.x_coord), y_coord(obj.y_coord)
{}
CoordPair<LIMIT> & operator=(const CoordPair<LIMIT> &obj)
diff --git a/src/server/game/Grids/NGrid.h b/src/server/game/Grids/NGrid.h
index f64c54c8c43..65cdd3a6033 100644
--- a/src/server/game/Grids/NGrid.h
+++ b/src/server/game/Grids/NGrid.h
@@ -78,15 +78,10 @@ class NGrid
{
public:
typedef Grid<ACTIVE_OBJECT, WORLD_OBJECT_TYPES, GRID_OBJECT_TYPES> GridType;
- NGrid(uint32 id, int32 x, int32 y, time_t expiry, bool unload = true)
- : i_gridId(id)
- , i_GridInfo(GridInfo(expiry, unload))
- , i_x(x)
- , i_y(y)
- , i_cellstate(GRID_STATE_INVALID)
- , i_GridObjectDataLoaded(false)
- {
- }
+ NGrid(uint32 id, int32 x, int32 y, time_t expiry, bool unload = true) :
+ i_gridId(id), i_GridInfo(GridInfo(expiry, unload)), i_x(x), i_y(y),
+ i_cellstate(GRID_STATE_INVALID), i_GridObjectDataLoaded(false)
+ { }
GridType& GetGridType(const uint32 x, const uint32 y)
{
diff --git a/src/server/game/Groups/Group.cpp b/src/server/game/Groups/Group.cpp
index 90c97562185..21341a44c5f 100644
--- a/src/server/game/Groups/Group.cpp
+++ b/src/server/game/Groups/Group.cpp
@@ -1369,8 +1369,7 @@ void Group::CountTheRoll(Rolls::iterator rollI)
item->is_looted = true;
roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
roll->getLoot()->unlootedCount--;
- AllowedLooterSet looters = item->GetAllowedLooters();
- player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
+ player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, item->GetAllowedLooters());
}
else
{
@@ -1422,8 +1421,7 @@ void Group::CountTheRoll(Rolls::iterator rollI)
item->is_looted = true;
roll->getLoot()->NotifyItemRemoved(roll->itemSlot);
roll->getLoot()->unlootedCount--;
- AllowedLooterSet looters = item->GetAllowedLooters();
- player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, looters);
+ player->StoreNewItem(dest, roll->itemid, true, item->randomPropertyId, item->GetAllowedLooters());
}
else
{
@@ -2174,7 +2172,7 @@ void Group::SetLfgRoles(uint64 guid, const uint8 roles)
return;
slot->roles = roles;
- SendUpdate();
+ SendUpdate();
}
bool Group::IsFull() const
@@ -2222,7 +2220,7 @@ uint32 Group::GetLowGUID() const
return GUID_LOPART(m_guid);
}
-const char * Group::GetLeaderName() const
+char const* Group::GetLeaderName() const
{
return m_leaderName.c_str();
}
diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp
index c4967e46623..498abbdc597 100644
--- a/src/server/game/Instances/InstanceSaveMgr.cpp
+++ b/src/server/game/Instances/InstanceSaveMgr.cpp
@@ -51,14 +51,13 @@ InstanceSaveManager::~InstanceSaveManager()
++next;
(*itr2)->UnbindInstance(save->GetMapId(), save->GetDifficulty(), true);
}
- save->m_playerList.clear();
for (InstanceSave::GroupListType::iterator itr2 = save->m_groupList.begin(), next = itr2; itr2 != save->m_groupList.end(); itr2 = next)
{
++next;
(*itr2)->UnbindInstance(save->GetMapId(), save->GetDifficulty(), true);
}
- save->m_groupList.clear();
+
delete save;
}
}
diff --git a/src/server/game/Loot/LootMgr.cpp b/src/server/game/Loot/LootMgr.cpp
index bf131fb2d33..d07aa528f86 100644
--- a/src/server/game/Loot/LootMgr.cpp
+++ b/src/server/game/Loot/LootMgr.cpp
@@ -1230,15 +1230,11 @@ void LootTemplate::LootGroup::CheckLootRefs(LootTemplateMap const& /*store*/, Lo
LootTemplate::~LootTemplate()
{
- while (!Entries.empty())
- {
- delete Entries.back();
- Entries.pop_back();
- }
+ for (LootStoreItemList::iterator i = Entries.begin(); i != Entries.end(); ++i)
+ delete *i;
for (size_t i = 0; i < Groups.size(); ++i)
delete Groups[i];
- Groups.clear();
}
// Adds an entry to the group (at loading stage)
diff --git a/src/server/game/Maps/MapInstanced.cpp b/src/server/game/Maps/MapInstanced.cpp
index c2079c22e76..62fec9e4b20 100644
--- a/src/server/game/Maps/MapInstanced.cpp
+++ b/src/server/game/Maps/MapInstanced.cpp
@@ -29,8 +29,6 @@
MapInstanced::MapInstanced(uint32 id, time_t expiry) : Map(id, expiry, 0, DUNGEON_DIFFICULTY_NORMAL)
{
- // initialize instanced maps list
- m_InstancedMaps.clear();
// fill with zero
memset(&GridMapReference, 0, MAX_NUMBER_OF_GRIDS*MAX_NUMBER_OF_GRIDS*sizeof(uint16));
}
diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h
index e007f6585a9..73832a632c3 100644
--- a/src/server/game/Spells/Auras/SpellAuras.h
+++ b/src/server/game/Spells/Auras/SpellAuras.h
@@ -23,7 +23,6 @@
#include "SpellInfo.h"
#include "Unit.h"
-class Unit;
class SpellInfo;
struct SpellModifier;
struct ProcTriggerSpell;
@@ -153,7 +152,15 @@ class Aura
bool IsArea() const;
bool IsPassive() const;
bool IsDeathPersistent() const;
- bool IsRemovedOnShapeLost(Unit* target) const { return (GetCasterGUID() == target->GetGUID() && m_spellInfo->Stances && !(m_spellInfo->AttributesEx2 & SPELL_ATTR2_NOT_NEED_SHAPESHIFT) && !(m_spellInfo->Attributes & SPELL_ATTR0_NOT_SHAPESHIFT)); }
+
+ bool IsRemovedOnShapeLost(Unit* target) const
+ {
+ return GetCasterGUID() == target->GetGUID()
+ && m_spellInfo->Stances
+ && !(m_spellInfo->AttributesEx2 & SPELL_ATTR2_NOT_NEED_SHAPESHIFT)
+ && !(m_spellInfo->Attributes & SPELL_ATTR0_NOT_SHAPESHIFT);
+ }
+
bool CanBeSaved() const;
bool IsRemoved() const { return m_isRemoved; }
bool CanBeSentToClient() const;
@@ -175,7 +182,7 @@ class Aura
// Helpers for targets
ApplicationMap const & GetApplicationMap() {return m_applications;}
- void GetApplicationList(std::list<AuraApplication*> & applicationList) const;
+ void GetApplicationList(Unit::AuraApplicationList& applicationList) const;
const AuraApplication * GetApplicationOfTarget (uint64 guid) const { ApplicationMap::const_iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; }
AuraApplication * GetApplicationOfTarget (uint64 guid) { ApplicationMap::iterator itr = m_applications.find(guid); if (itr != m_applications.end()) return itr->second; return NULL; }
bool IsAppliedOnTarget(uint64 guid) const { return m_applications.find(guid) != m_applications.end(); }
diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h
index 08a7b087be2..96189af7657 100644
--- a/src/server/game/Spells/Spell.h
+++ b/src/server/game/Spells/Spell.h
@@ -460,7 +460,7 @@ class Spell
void SetAutoRepeat(bool rep) { m_autoRepeat = rep; }
void ReSetTimer() { m_timer = m_casttime > 0 ? m_casttime : 0; }
bool IsNextMeleeSwingSpell() const;
- bool IsTriggered() const { return _triggeredCastFlags & TRIGGERED_FULL_MASK; };
+ bool IsTriggered() const { return _triggeredCastFlags & TRIGGERED_FULL_MASK; }
bool IsChannelActive() const { return m_caster->GetUInt32Value(UNIT_CHANNEL_SPELL) != 0; }
bool IsAutoActionResetSpell() const;
@@ -495,7 +495,7 @@ class Spell
Unit* const m_caster;
- SpellValue * const m_spellValue;
+ SpellValue* const m_spellValue;
uint64 m_originalCasterGUID; // real source of cast (aura caster/etc), used for spell targets selection
// e.g. damage around area spell trigered by victim aura and damage enemies of aura caster
diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp
index 40e74baf09f..7d508b154eb 100644
--- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp
+++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp
@@ -19,7 +19,6 @@
#include "ScriptMgr.h"
#include "ScriptedCreature.h"
#include "SpellAuras.h"
-#include "MapManager.h"
#include "MoveSplineInit.h"
#include "Player.h"
#include "icecrown_citadel.h"
diff --git a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp
index 38f02622e5a..0a6c09093f1 100644
--- a/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp
+++ b/src/server/scripts/Outland/CoilfangReservoir/SerpentShrine/boss_fathomlord_karathress.cpp
@@ -672,7 +672,7 @@ public:
if (Creature* Cyclone = me->SummonCreature(CREATURE_CYCLONE, me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), float(rand()%5), TEMPSUMMON_TIMED_DESPAWN, 15000))
{
- Cyclone->ToCreature()->SetObjectScale(3.0f);
+ Cyclone->SetObjectScale(3.0f);
Cyclone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
Cyclone->setFaction(me->getFaction());
Cyclone->CastSpell(Cyclone, SPELL_CYCLONE_CYCLONE, true);
diff --git a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp
index 2cfe73ea719..a13d91e8bff 100644
--- a/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp
+++ b/src/server/scripts/Outland/HellfireCitadel/ShatteredHalls/boss_warchief_kargath_bladefist.cpp
@@ -164,24 +164,24 @@ class boss_warchief_kargath_bladefist : public CreatureScript
{
for (std::vector<uint64>::const_iterator itr = adds.begin(); itr!= adds.end(); ++itr)
{
- Unit* temp = Unit::GetUnit(*me, *itr);
- if (temp && temp->isAlive())
+ Creature* creature = Unit::GetCreature(*me, *itr);
+ if (creature && creature->isAlive())
{
- temp->GetMotionMaster()->Clear(true);
- me->DealDamage(temp, temp->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
- temp->ToCreature()->RemoveCorpse();
+ creature->GetMotionMaster()->Clear(true);
+ me->DealDamage(creature, creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
+ creature->RemoveCorpse();
}
}
adds.clear();
for (std::vector<uint64>::const_iterator itr = assassins.begin(); itr!= assassins.end(); ++itr)
{
- Unit* temp = Unit::GetUnit(*me, *itr);
- if (temp && temp->isAlive())
+ Creature* creature = Unit::GetCreature(*me, *itr);
+ if (creature && creature->isAlive())
{
- temp->GetMotionMaster()->Clear(true);
- me->DealDamage(temp, temp->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
- temp->ToCreature()->RemoveCorpse();
+ creature->GetMotionMaster()->Clear(true);
+ me->DealDamage(creature, creature->GetHealth(), NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
+ creature->RemoveCorpse();
}
}
assassins.clear();
diff --git a/src/server/scripts/Outland/zone_shattrath_city.cpp b/src/server/scripts/Outland/zone_shattrath_city.cpp
index 95ba9476905..4af11191708 100644
--- a/src/server/scripts/Outland/zone_shattrath_city.cpp
+++ b/src/server/scripts/Outland/zone_shattrath_city.cpp
@@ -474,16 +474,16 @@ public:
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
me->setFaction(1194);
- if (Unit* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20))
+ if (Creature* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20))
{
- Creepjack->ToCreature()->AI()->EnterEvadeMode();
+ Creepjack->AI()->EnterEvadeMode();
Creepjack->setFaction(1194);
Creepjack->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
}
- if (Unit* Malone = me->FindNearestCreature(NPC_MALONE, 20))
+ if (Creature* Malone = me->FindNearestCreature(NPC_MALONE, 20))
{
- Malone->ToCreature()->AI()->EnterEvadeMode();
+ Malone->AI()->EnterEvadeMode();
Malone->setFaction(1194);
Malone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
}
@@ -521,31 +521,31 @@ public:
{
if (Event)
SayTimer = NextStep(++Step);
- } else SayTimer -= diff;
+ }
+ else
+ SayTimer -= diff;
if (Attack)
{
- Player* player = Unit::GetPlayer(*me, PlayerGUID);
me->setFaction(14);
me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- if (player)
- {
- Unit* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20);
- if (Creepjack)
- {
- Creepjack->Attack(player, true);
- Creepjack->setFaction(14);
- Creepjack->GetMotionMaster()->MoveChase(player);
- Creepjack->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- }
- Unit* Malone = me->FindNearestCreature(NPC_MALONE, 20);
- if (Malone)
+ if (Player* player = Unit::GetPlayer(*me, PlayerGUID))
{
- Malone->Attack(player, true);
- Malone->setFaction(14);
- Malone->GetMotionMaster()->MoveChase(player);
- Malone->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
- }
+ if (Creature* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20))
+ {
+ Creepjack->Attack(player, true);
+ Creepjack->setFaction(14);
+ Creepjack->GetMotionMaster()->MoveChase(player);
+ Creepjack->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+ }
+
+ if (Creature* Malone = me->FindNearestCreature(NPC_MALONE, 20))
+ {
+ Malone->Attack(player, true);
+ Malone->setFaction(14);
+ Malone->GetMotionMaster()->MoveChase(player);
+ Malone->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
+ }
DoStartMovement(player);
AttackStart(player);
}
@@ -557,17 +557,17 @@ public:
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
me->RemoveAllAuras();
- if (Unit* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20))
+ if (Creature* Creepjack = me->FindNearestCreature(NPC_CREEPJACK, 20))
{
- Creepjack->ToCreature()->AI()->EnterEvadeMode();
+ Creepjack->AI()->EnterEvadeMode();
Creepjack->setFaction(1194);
Creepjack->GetMotionMaster()->MoveTargetedHome();
Creepjack->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
}
- if (Unit* Malone = me->FindNearestCreature(NPC_MALONE, 20))
+ if (Creature* Malone = me->FindNearestCreature(NPC_MALONE, 20))
{
- Malone->ToCreature()->AI()->EnterEvadeMode();
+ Malone->AI()->EnterEvadeMode();
Malone->setFaction(1194);
Malone->GetMotionMaster()->MoveTargetedHome();
Malone->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
diff --git a/src/server/scripts/Spells/spell_item.cpp b/src/server/scripts/Spells/spell_item.cpp
index c9c75cdb134..0c9817ba167 100644
--- a/src/server/scripts/Spells/spell_item.cpp
+++ b/src/server/scripts/Spells/spell_item.cpp
@@ -813,6 +813,7 @@ class spell_item_scroll_of_recall : public SpellScriptLoader
enum ShadowsFate
{
SPELL_SOUL_FEAST = 71203,
+ NPC_SINDRAGOSA = 36853
};
class spell_item_unsated_craving : public SpellScriptLoader
@@ -831,7 +832,7 @@ class spell_item_unsated_craving : public SpellScriptLoader
return false;
Unit* target = procInfo.GetActionTarget();
- if (!target || target->GetTypeId() != TYPEID_UNIT || target->GetCreatureType() == CREATURE_TYPE_CRITTER || target->isSummon())
+ if (!target || target->GetTypeId() != TYPEID_UNIT || target->GetCreatureType() == CREATURE_TYPE_CRITTER || (target->GetEntry() != NPC_SINDRAGOSA && target->isSummon()))
return false;
return true;
diff --git a/src/server/shared/CMakeLists.txt b/src/server/shared/CMakeLists.txt
index 01ccf648b31..447819b0431 100644
--- a/src/server/shared/CMakeLists.txt
+++ b/src/server/shared/CMakeLists.txt
@@ -16,6 +16,7 @@ file(GLOB_RECURSE sources_Configuration Configuration/*.cpp Configuration/*.h)
file(GLOB_RECURSE sources_Cryptography Cryptography/*.cpp Cryptography/*.h)
file(GLOB_RECURSE sources_Database Database/*.cpp Database/*.h)
file(GLOB_RECURSE sources_DataStores DataStores/*.cpp DataStores/*.h)
+file(GLOB_RECURSE sources_Debugging Debugging/*.cpp Debugging/*.h)
file(GLOB_RECURSE sources_Dynamic Dynamic/*.cpp Dynamic/*.h)
file(GLOB_RECURSE sources_Logging Logging/*.cpp Logging/*.h)
file(GLOB_RECURSE sources_Packets Packets/*.cpp Packets/*.h)
@@ -39,13 +40,13 @@ set(shared_STAT_SRCS
${sources_Cryptography}
${sources_Database}
${sources_DataStores}
+ ${sources_Debugging}
${sources_Dynamic}
${sources_Logging}
${sources_Packets}
${sources_Threading}
${sources_Utilities}
${sources_localdir}
- Debugging/Errors.h
)
include_directories(
diff --git a/src/server/shared/Containers.h b/src/server/shared/Containers.h
index 83c691a99e2..b33954d7ea4 100644
--- a/src/server/shared/Containers.h
+++ b/src/server/shared/Containers.h
@@ -18,6 +18,7 @@
#ifndef TRINITY_CONTAINERS_H
#define TRINITY_CONTAINERS_H
+#include "Define.h"
#include <list>
//! Because circular includes are bad
diff --git a/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp b/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp
index 0f68fcb6c37..003c09e4589 100644
--- a/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp
+++ b/src/server/shared/Cryptography/Authentication/AuthCrypt.cpp
@@ -20,15 +20,10 @@
#include "Cryptography/HMACSHA1.h"
#include "Cryptography/BigNumber.h"
-AuthCrypt::AuthCrypt() : _clientDecrypt(SHA_DIGEST_LENGTH), _serverEncrypt(SHA_DIGEST_LENGTH)
- , _initialized(false)
-{
-}
-
-AuthCrypt::~AuthCrypt()
-{
-
-}
+AuthCrypt::AuthCrypt() :
+ _clientDecrypt(SHA_DIGEST_LENGTH), _serverEncrypt(SHA_DIGEST_LENGTH),
+ _initialized(false)
+{ }
void AuthCrypt::Init(BigNumber* K)
{
diff --git a/src/server/shared/Cryptography/Authentication/AuthCrypt.h b/src/server/shared/Cryptography/Authentication/AuthCrypt.h
index 200681afd08..95e773b586e 100644
--- a/src/server/shared/Cryptography/Authentication/AuthCrypt.h
+++ b/src/server/shared/Cryptography/Authentication/AuthCrypt.h
@@ -27,7 +27,6 @@ class AuthCrypt
{
public:
AuthCrypt();
- ~AuthCrypt();
void Init(BigNumber* K);
void DecryptRecv(uint8 *, size_t);
diff --git a/src/server/shared/Cryptography/BigNumber.cpp b/src/server/shared/Cryptography/BigNumber.cpp
index 37778cceab8..06ea57b662e 100644
--- a/src/server/shared/Cryptography/BigNumber.cpp
+++ b/src/server/shared/Cryptography/BigNumber.cpp
@@ -24,18 +24,15 @@
#include <algorithm>
BigNumber::BigNumber()
- : _bn(BN_new())
- , _array(NULL)
+ : _bn(BN_new()), _array(NULL)
{ }
BigNumber::BigNumber(BigNumber const& bn)
- : _bn(BN_dup(bn._bn))
- , _array(NULL)
+ : _bn(BN_dup(bn._bn)), _array(NULL)
{ }
BigNumber::BigNumber(uint32 val)
- : _bn(BN_new())
- , _array(NULL)
+ : _bn(BN_new()), _array(NULL)
{
BN_set_word(_bn, val);
}
diff --git a/src/server/shared/Cryptography/HMACSHA1.cpp b/src/server/shared/Cryptography/HMACSHA1.cpp
index ab50eb9981a..297b4e90316 100644
--- a/src/server/shared/Cryptography/HMACSHA1.cpp
+++ b/src/server/shared/Cryptography/HMACSHA1.cpp
@@ -40,7 +40,7 @@ void HmacHash::Finalize()
{
uint32 length = 0;
HMAC_Final(&m_ctx, (uint8*)m_digest, &length);
- ASSERT(length == SHA_DIGEST_LENGTH)
+ ASSERT(length == SHA_DIGEST_LENGTH);
}
uint8 *HmacHash::ComputeHash(BigNumber* bn)
diff --git a/src/server/shared/DataStores/DB2Store.h b/src/server/shared/DataStores/DB2Store.h
index 08f3294b188..77d6c4144e5 100644
--- a/src/server/shared/DataStores/DB2Store.h
+++ b/src/server/shared/DataStores/DB2Store.h
@@ -19,6 +19,7 @@
#define DB2STORE_H
#include "DB2FileLoader.h"
+#include "Common.h"
#include "ByteBuffer.h"
#include <vector>
@@ -229,4 +230,4 @@ private:
StringPoolList m_stringPoolList;
};
-#endif \ No newline at end of file
+#endif
diff --git a/src/server/shared/Database/DatabaseWorkerPool.h b/src/server/shared/Database/DatabaseWorkerPool.h
index 524a3de2628..a197610c6b5 100644
--- a/src/server/shared/Database/DatabaseWorkerPool.h
+++ b/src/server/shared/Database/DatabaseWorkerPool.h
@@ -55,8 +55,8 @@ class DatabaseWorkerPool
memset(_connectionCount, 0, sizeof(_connectionCount));
_connections.resize(IDX_SIZE);
- WPFatal (mysql_thread_safe(), "Used MySQL library isn't thread-safe.");
- WPFatal (mysql_get_client_version() >= MIN_MYSQL_CLIENT_VERSION, "TrinityCore does not support MySQL versions below 5.1");
+ WPFatal(mysql_thread_safe(), "Used MySQL library isn't thread-safe.");
+ WPFatal(mysql_get_client_version() >= MIN_MYSQL_CLIENT_VERSION, "TrinityCore does not support MySQL versions below 5.1");
}
~DatabaseWorkerPool()
diff --git a/src/server/shared/Debugging/Errors.cpp b/src/server/shared/Debugging/Errors.cpp
new file mode 100644
index 00000000000..bd299906de0
--- /dev/null
+++ b/src/server/shared/Debugging/Errors.cpp
@@ -0,0 +1,38 @@
+#include "Errors.h"
+#include "Log.h"
+
+#include <ace/Stack_Trace.h>
+#include <ace/OS_NS_unistd.h>
+
+namespace Trinity {
+
+void Assert(char const *file, int line, char const *function, char const *message)
+{
+ ACE_Stack_Trace st;
+ fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n%s\n",
+ file, line, function, message, st.c_str());
+ *((volatile int*)NULL) = 0;
+}
+
+void Fatal(char const *file, int line, char const *function, char const *message)
+{
+ sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s FATAL ERROR:\n %s\n",
+ file, line, function, message);
+ ACE_OS::sleep(10);
+ *((volatile int*)NULL) = 0;
+}
+
+void Error(char const *file, int line, char const *function, char const *message)
+{
+ sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s ERROR:\n %s\n",
+ file, line, function, message);
+ *((volatile int*)NULL) = 0;
+}
+
+void Warning(char const *file, int line, char const *function, char const *message)
+{
+ sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s WARNING:\n %s\n",
+ file, line, function, message);
+}
+
+} // namespace Trinity
diff --git a/src/server/shared/Debugging/Errors.h b/src/server/shared/Debugging/Errors.h
index 10e94634e9a..554b20c3648 100644
--- a/src/server/shared/Debugging/Errors.h
+++ b/src/server/shared/Debugging/Errors.h
@@ -19,15 +19,23 @@
#ifndef TRINITYCORE_ERRORS_H
#define TRINITYCORE_ERRORS_H
-#include "Common.h"
-#include "Log.h"
-#include <ace/Stack_Trace.h>
-#include <ace/OS_NS_unistd.h>
+namespace Trinity {
-#define WPAssert(assertion) { if (!(assertion)) { ACE_Stack_Trace st; fprintf(stderr, "\n%s:%i in %s ASSERTION FAILED:\n %s\n%s\n", __FILE__, __LINE__, __FUNCTION__, #assertion, st.c_str()); *((volatile int*)NULL) = 0; } }
-#define WPError(assertion, errmsg) { if (!(assertion)) { sLog->outError(LOG_FILTER_GENERAL, "%\n%s:%i in %s ERROR:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg); *((volatile int*)NULL) = 0; } }
-#define WPWarning(assertion, errmsg) { if (!(assertion)) { sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s WARNING:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg); } }
-#define WPFatal(assertion, errmsg) { if (!(assertion)) { sLog->outError(LOG_FILTER_GENERAL, "\n%s:%i in %s FATAL ERROR:\n %s\n", __FILE__, __LINE__, __FUNCTION__, (char *)errmsg); ACE_OS::sleep(10); *((volatile int*)NULL) = 0; } }
+void Assert(char const *file, int line, char const *function, char const *message);
+
+void Fatal(char const *file, int line, char const *function, char const *message);
+
+void Error(char const *file, int line, char const *function, char const *message);
+
+void Warning(char const *file, int line, char const *function, char const *message);
+
+} // namespace Trinity
+
+#define WPAssert(cond) do { if (!(cond)) Trinity::Assert(__FILE__, __LINE__, __FUNCTION__, #cond); } while(0)
+#define WPFatal(cond, msg) do { if (!(cond)) Trinity::Fatal(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0)
+#define WPError(cond, msg) do { if (!(cond)) Trinity::Error(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0)
+#define WPWarning(cond, msg) do { if (!(cond)) Trinity::Warning(__FILE__, __LINE__, __FUNCTION__, (msg)); } while(0)
#define ASSERT WPAssert
+
#endif
diff --git a/src/server/shared/Debugging/WheatyExceptionReport.cpp b/src/server/shared/Debugging/WheatyExceptionReport.cpp
index d07e579ab5d..d4bd630ca25 100644
--- a/src/server/shared/Debugging/WheatyExceptionReport.cpp
+++ b/src/server/shared/Debugging/WheatyExceptionReport.cpp
@@ -3,6 +3,8 @@
// MSDN Magazine, 2002
// FILE: WheatyExceptionReport.CPP
//==========================================
+#include "CompilerDefs.h"
+
#if PLATFORM == PLATFORM_WINDOWS && !defined(__MINGW32__)
#define WIN32_LEAN_AND_MEAN
#pragma warning(disable:4996)
diff --git a/src/server/shared/Logging/Appender.cpp b/src/server/shared/Logging/Appender.cpp
index efb141d1060..cde94fe3a7c 100644
--- a/src/server/shared/Logging/Appender.cpp
+++ b/src/server/shared/Logging/Appender.cpp
@@ -218,6 +218,8 @@ char const* Appender::getLogFilterTypeString(LogFilterType type)
return "SOAP";
case LOG_FILTER_RBAC:
return "RBAC";
+ case LOG_FILTER_CHEAT:
+ return "CHEAT";
default:
break;
}
diff --git a/src/server/shared/Logging/Appender.h b/src/server/shared/Logging/Appender.h
index e11bc40c42f..983f6a5ddbe 100644
--- a/src/server/shared/Logging/Appender.h
+++ b/src/server/shared/Logging/Appender.h
@@ -68,10 +68,11 @@ enum LogFilterType
LOG_FILTER_SERVER_LOADING = 40,
LOG_FILTER_OPCODES = 41,
LOG_FILTER_SOAP = 42,
- LOG_FILTER_RBAC = 43
+ LOG_FILTER_RBAC = 43,
+ LOG_FILTER_CHEAT = 44
};
-const uint8 MaxLogFilter = 43;
+const uint8 MaxLogFilter = 45;
// Values assigned have their equivalent in enum ACE_Log_Priority
enum LogLevel
@@ -108,12 +109,8 @@ enum AppenderFlags
struct LogMessage
{
LogMessage(LogLevel _level, LogFilterType _type, std::string _text)
- : level(_level)
- , type(_type)
- , text(_text)
- {
- mtime = time(NULL);
- }
+ : level(_level), type(_type), text(_text), mtime(time(NULL))
+ { }
static std::string getTimeStr(time_t time);
std::string getTimeStr();
diff --git a/src/server/shared/Logging/LogOperation.h b/src/server/shared/Logging/LogOperation.h
index 0a0dde3bb61..40017cb87f4 100644
--- a/src/server/shared/Logging/LogOperation.h
+++ b/src/server/shared/Logging/LogOperation.h
@@ -25,8 +25,7 @@ class LogOperation
{
public:
LogOperation(Logger* _logger, LogMessage* _msg)
- : logger(_logger)
- , msg(_msg)
+ : logger(_logger), msg(_msg)
{ }
~LogOperation();
diff --git a/src/server/shared/Packets/ByteBuffer.cpp b/src/server/shared/Packets/ByteBuffer.cpp
new file mode 100644
index 00000000000..a14cf3477af
--- /dev/null
+++ b/src/server/shared/Packets/ByteBuffer.cpp
@@ -0,0 +1,95 @@
+#include "ByteBuffer.h"
+#include "Log.h"
+
+#include <ace/Stack_Trace.h>
+#include <sstream>
+
+ByteBufferPositionException::ByteBufferPositionException(bool add, size_t pos,
+ size_t size, size_t valueSize)
+{
+ std::ostringstream ss;
+ ACE_Stack_Trace trace;
+
+ ss << "Attempted to " << (add ? "put" : "get") << " value with size: "
+ << valueSize << " in ByteBuffer (pos: " << pos << " size: " << size
+ << ")\n\n" << trace.c_str();
+
+ message().assign(ss.str());
+}
+
+ByteBufferSourceException::ByteBufferSourceException(size_t pos, size_t size,
+ size_t valueSize)
+{
+ std::ostringstream ss;
+ ACE_Stack_Trace trace;
+
+ ss << "Attempted to put a "
+ << (valueSize > 0 ? "NULL-pointer" : "zero-sized value")
+ << " in ByteBuffer (pos: " << pos << " size: " << size << ")\n\n"
+ << trace.c_str();
+
+ message().assign(ss.str());
+}
+
+void ByteBuffer::print_storage() const
+{
+ if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled trace output
+ return;
+
+ std::ostringstream o;
+ o << "STORAGE_SIZE: " << size();
+ for (uint32 i = 0; i < size(); ++i)
+ o << read<uint8>(i) << " - ";
+ o << " ";
+
+ sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str());
+}
+
+void ByteBuffer::textlike() const
+{
+ if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled trace output
+ return;
+
+ std::ostringstream o;
+ o << "STORAGE_SIZE: " << size();
+ for (uint32 i = 0; i < size(); ++i)
+ {
+ char buf[1];
+ snprintf(buf, 1, "%c", read<uint8>(i));
+ o << buf;
+ }
+ o << " ";
+ sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str());
+}
+
+void ByteBuffer::hexlike() const
+{
+ if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled trace output
+ return;
+
+ uint32 j = 1, k = 1;
+
+ std::ostringstream o;
+ o << "STORAGE_SIZE: " << size();
+
+ for (uint32 i = 0; i < size(); ++i)
+ {
+ char buf[3];
+ snprintf(buf, 1, "%2X ", read<uint8>(i));
+ if ((i == (j * 8)) && ((i != (k * 16))))
+ {
+ o << "| ";
+ ++j;
+ }
+ else if (i == (k * 16))
+ {
+ o << "\n";
+ ++k;
+ ++j;
+ }
+
+ o << buf;
+ }
+ o << " ";
+ sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str());
+}
diff --git a/src/server/shared/Packets/ByteBuffer.h b/src/server/shared/Packets/ByteBuffer.h
index 6504a645e2b..0f4221b53ff 100644
--- a/src/server/shared/Packets/ByteBuffer.h
+++ b/src/server/shared/Packets/ByteBuffer.h
@@ -19,66 +19,47 @@
#ifndef _BYTEBUFFER_H
#define _BYTEBUFFER_H
-#include "Common.h"
+#include "Define.h"
#include "Debugging/Errors.h"
-#include "Log.h"
#include "Utilities/ByteConverter.h"
+#include <exception>
+#include <list>
+#include <map>
+#include <string>
+#include <vector>
+#include <cstring>
-class ByteBufferException
+// Root of ByteBuffer exception hierarchy
+class ByteBufferException : public std::exception
{
- public:
- ByteBufferException(size_t pos, size_t size, size_t valueSize)
- : Pos(pos), Size(size), ValueSize(valueSize)
- {
- }
+public:
+ ~ByteBufferException() throw() { }
- protected:
- size_t Pos;
- size_t Size;
- size_t ValueSize;
+ char const * what() const throw() { return msg_.c_str(); }
+
+protected:
+ std::string & message() throw() { return msg_; }
+
+private:
+ std::string msg_;
};
class ByteBufferPositionException : public ByteBufferException
{
- public:
- ByteBufferPositionException(bool add, size_t pos, size_t size, size_t valueSize)
- : ByteBufferException(pos, size, valueSize), _add(add)
- {
- PrintError();
- }
-
- protected:
- void PrintError() const
- {
- ACE_Stack_Trace trace;
+public:
+ ByteBufferPositionException(bool add, size_t pos, size_t size, size_t valueSize);
- sLog->outError(LOG_FILTER_NETWORKIO, "Attempted to %s value with size: " SIZEFMTD " in ByteBuffer (pos: " SIZEFMTD " size: "SIZEFMTD")\n[Stack trace: %s]",
- (_add ? "put" : "get"), ValueSize, Pos, Size, trace.c_str());
- }
-
- private:
- bool _add;
+ ~ByteBufferPositionException() throw() { }
};
class ByteBufferSourceException : public ByteBufferException
{
- public:
- ByteBufferSourceException(size_t pos, size_t size, size_t valueSize)
- : ByteBufferException(pos, size, valueSize)
- {
- PrintError();
- }
+public:
+ ByteBufferSourceException(size_t pos, size_t size, size_t valueSize);
- protected:
- void PrintError() const
- {
- ACE_Stack_Trace trace;
-
- sLog->outError(LOG_FILTER_NETWORKIO, "Attempted to put a %s in ByteBuffer (pos: " SIZEFMTD " size: "SIZEFMTD ")\n[Stack trace: %s]",
- (ValueSize > 0 ? "NULL-pointer" : "zero-sized value"), Pos, Size, trace.c_str());
- }
+ ~ByteBufferSourceException() throw() { }
};
class ByteBuffer
@@ -453,7 +434,7 @@ class ByteBuffer
{
if (_rpos + len > size())
throw ByteBufferPositionException(false, _rpos, len, size());
- memcpy(dest, &_storage[_rpos], len);
+ std::memcpy(dest, &_storage[_rpos], len);
_rpos += len;
}
@@ -485,8 +466,7 @@ class ByteBuffer
{
if (!length)
return std::string();
- char* buffer = new char[length + 1];
- memset(buffer, 0, length + 1);
+ char* buffer = new char[length + 1]();
read((uint8*)buffer, length);
std::string retval = buffer;
delete[] buffer;
@@ -504,8 +484,7 @@ class ByteBuffer
uint32 ReadPackedTime()
{
uint32 packedDate = read<uint32>();
- tm lt;
- memset(&lt, 0, sizeof(lt));
+ tm lt = tm();
lt.tm_min = packedDate & 0x3F;
lt.tm_hour = (packedDate >> 6) & 0x1F;
@@ -565,7 +544,7 @@ class ByteBuffer
if (_storage.size() < _wpos + cnt)
_storage.resize(_wpos + cnt);
- memcpy(&_storage[_wpos], src, cnt);
+ std::memcpy(&_storage[_wpos], src, cnt);
_wpos += cnt;
}
@@ -618,71 +597,14 @@ class ByteBuffer
if (!src)
throw ByteBufferSourceException(_wpos, size(), cnt);
- memcpy(&_storage[pos], src, cnt);
+ std::memcpy(&_storage[pos], src, cnt);
}
- void print_storage() const
- {
- if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled debug output
- return;
+ void print_storage() const;
- std::ostringstream o;
- o << "STORAGE_SIZE: " << size();
- for (uint32 i = 0; i < size(); ++i)
- o << read<uint8>(i) << " - ";
- o << " ";
+ void textlike() const;
- sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str());
- }
-
- void textlike() const
- {
- if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled debug output
- return;
-
- std::ostringstream o;
- o << "STORAGE_SIZE: " << size();
- for (uint32 i = 0; i < size(); ++i)
- {
- char buf[1];
- snprintf(buf, 1, "%c", read<uint8>(i));
- o << buf;
- }
- o << " ";
- sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str());
- }
-
- void hexlike() const
- {
- if (!sLog->ShouldLog(LOG_FILTER_NETWORKIO, LOG_LEVEL_TRACE)) // optimize disabled debug output
- return;
-
- uint32 j = 1, k = 1;
-
- std::ostringstream o;
- o << "STORAGE_SIZE: " << size();
-
- for (uint32 i = 0; i < size(); ++i)
- {
- char buf[3];
- snprintf(buf, 1, "%2X ", read<uint8>(i));
- if ((i == (j * 8)) && ((i != (k * 16))))
- {
- o << "| ";
- ++j;
- }
- else if (i == (k * 16))
- {
- o << "\n";
- ++k;
- ++j;
- }
-
- o << buf;
- }
- o << " ";
- sLog->outTrace(LOG_FILTER_NETWORKIO, "%s", o.str().c_str());
- }
+ void hexlike() const;
protected:
size_t _rpos, _wpos, _bitpos;
diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist
index a4b279c4b0c..448ea2930e3 100644
--- a/src/server/worldserver/worldserver.conf.dist
+++ b/src/server/worldserver/worldserver.conf.dist
@@ -1097,7 +1097,7 @@ AccountInstancesPerHour = 5
# RBAC.DefaultGroups
# Description: Comma separated list of groups to be added to any account
# Check auth.rbac_groups for correct ids
-# Default: "" (No group)
+# Default: "" (No group)
RBAC.DefaultGroups = ""
@@ -2680,6 +2680,7 @@ Appenders=Console Server GM DBErrors Char RA Warden Chat
# 41 - Opcodes (just id and name sent / received)
# 42 - SOAP
# 43 - RBAC (Role Based Access Control)
+# 44 - Cheat (used to log cheat attempts)
#
# LogLevel
# 0 - (Disabled)