aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Server
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-06-19 23:20:06 -0300
committerariel- <ariel-@users.noreply.github.com>2017-06-19 23:20:06 -0300
commit85a7d5ce9ac68b30da2277cc91d4b70358f1880d (patch)
treedf3d2084ee2e35008903c03178039b9c986e2d08 /src/server/game/Server
parent052fc24315ace866ea1cf610e85df119b68100c9 (diff)
Core: ported headers cleanup from master branch
Diffstat (limited to 'src/server/game/Server')
-rw-r--r--src/server/game/Server/Packet.cpp49
-rw-r--r--src/server/game/Server/Packet.h23
-rw-r--r--src/server/game/Server/Packets/PacketUtilities.cpp33
-rw-r--r--src/server/game/Server/Packets/PacketUtilities.h63
-rw-r--r--src/server/game/Server/Protocol/Opcodes.cpp46
-rw-r--r--src/server/game/Server/Protocol/Opcodes.h44
-rw-r--r--src/server/game/Server/Protocol/PacketLog.cpp6
-rw-r--r--src/server/game/Server/Protocol/PacketLog.h2
-rw-r--r--src/server/game/Server/WorldSession.cpp90
-rw-r--r--src/server/game/Server/WorldSession.h26
-rw-r--r--src/server/game/Server/WorldSocket.cpp14
-rw-r--r--src/server/game/Server/WorldSocketMgr.h2
12 files changed, 229 insertions, 169 deletions
diff --git a/src/server/game/Server/Packet.cpp b/src/server/game/Server/Packet.cpp
new file mode 100644
index 00000000000..bc4812a765d
--- /dev/null
+++ b/src/server/game/Server/Packet.cpp
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2008-2017 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/>.
+ */
+
+#include "Packet.h"
+#include "Errors.h"
+
+WorldPackets::Packet::Packet(WorldPacket&& worldPacket) : _worldPacket(std::move(worldPacket))
+{
+}
+
+WorldPackets::ServerPacket::ServerPacket(OpcodeServer opcode, size_t initialSize /*= 200*/) : Packet(WorldPacket(opcode, initialSize))
+{
+}
+
+void WorldPackets::ServerPacket::Read()
+{
+ ASSERT(!"Read not implemented for server packets.");
+}
+
+WorldPackets::ClientPacket::ClientPacket(OpcodeClient expectedOpcode, WorldPacket&& packet) : Packet(std::move(packet))
+{
+ ASSERT(GetOpcode() == expectedOpcode);
+}
+
+WorldPackets::ClientPacket::ClientPacket(WorldPacket&& packet)
+ : Packet(std::move(packet))
+{
+}
+
+WorldPacket const* WorldPackets::ClientPacket::Write()
+{
+ ASSERT(!"Write not allowed for client packets.");
+ // Shut up some compilers
+ return nullptr;
+}
diff --git a/src/server/game/Server/Packet.h b/src/server/game/Server/Packet.h
index 780e3850a27..8302e6b1353 100644
--- a/src/server/game/Server/Packet.h
+++ b/src/server/game/Server/Packet.h
@@ -25,7 +25,7 @@ namespace WorldPackets
class TC_GAME_API Packet
{
public:
- Packet(WorldPacket&& worldPacket) : _worldPacket(std::move(worldPacket)) { }
+ Packet(WorldPacket&& worldPacket);
virtual ~Packet() = default;
@@ -42,12 +42,12 @@ namespace WorldPackets
WorldPacket _worldPacket;
};
- class ServerPacket : public Packet
+ class TC_GAME_API ServerPacket : public Packet
{
public:
- ServerPacket(OpcodeServer opcode, size_t initialSize = 200) : Packet(WorldPacket(opcode, initialSize)) { }
+ ServerPacket(OpcodeServer opcode, size_t initialSize = 200);
- void Read() override final { ASSERT(!"Read not implemented for server packets."); }
+ void Read() override final;
void Clear() { _worldPacket.clear(); }
WorldPacket&& Move() { return std::move(_worldPacket); }
@@ -55,18 +55,13 @@ namespace WorldPackets
OpcodeServer GetOpcode() const { return OpcodeServer(_worldPacket.GetOpcode()); }
};
- class ClientPacket : public Packet
+ class TC_GAME_API ClientPacket : public Packet
{
public:
- ClientPacket(WorldPacket&& packet) : Packet(std::move(packet)) { }
- ClientPacket(OpcodeClient expectedOpcode, WorldPacket&& packet) : Packet(std::move(packet)) { ASSERT(GetOpcode() == expectedOpcode); }
-
- WorldPacket const* Write() override final
- {
- ASSERT(!"Write not allowed for client packets.");
- // Shut up some compilers
- return nullptr;
- }
+ ClientPacket(WorldPacket&& packet);
+ ClientPacket(OpcodeClient expectedOpcode, WorldPacket&& packet);
+
+ WorldPacket const* Write() override final;
OpcodeClient GetOpcode() const { return OpcodeClient(_worldPacket.GetOpcode()); }
};
diff --git a/src/server/game/Server/Packets/PacketUtilities.cpp b/src/server/game/Server/Packets/PacketUtilities.cpp
new file mode 100644
index 00000000000..4d87feaabc5
--- /dev/null
+++ b/src/server/game/Server/Packets/PacketUtilities.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2008-2017 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/>.
+ */
+
+#include "PacketUtilities.h"
+#include "Errors.h"
+#include <sstream>
+#include <array>
+
+WorldPackets::PacketArrayMaxCapacityException::PacketArrayMaxCapacityException(std::size_t requestedSize, std::size_t sizeLimit)
+{
+ std::ostringstream builder;
+ builder << "Attempted to read more array elements from packet " << requestedSize << " than allowed " << sizeLimit;
+ message().assign(builder.str());
+}
+
+void WorldPackets::CheckCompactArrayMaskOverflow(std::size_t index, std::size_t limit)
+{
+ ASSERT(index < limit, "Attempted to insert " SZFMTD " values into CompactArray but it can only hold " SZFMTD, index, limit);
+}
diff --git a/src/server/game/Server/Packets/PacketUtilities.h b/src/server/game/Server/Packets/PacketUtilities.h
index e4f40580a30..e1229e1ae1c 100644
--- a/src/server/game/Server/Packets/PacketUtilities.h
+++ b/src/server/game/Server/Packets/PacketUtilities.h
@@ -19,46 +19,13 @@
#define PacketUtilities_h__
#include "ByteBuffer.h"
-#include <G3D/Vector2.h>
-#include <G3D/Vector3.h>
-#include <sstream>
-#include <array>
-
-inline ByteBuffer& operator<<(ByteBuffer& data, G3D::Vector2 const& v)
-{
- data << v.x << v.y;
- return data;
-}
-
-inline ByteBuffer& operator>>(ByteBuffer& data, G3D::Vector2& v)
-{
- data >> v.x >> v.y;
- return data;
-}
-
-inline ByteBuffer& operator<<(ByteBuffer& data, G3D::Vector3 const& v)
-{
- data << v.x << v.y << v.z;
- return data;
-}
-
-inline ByteBuffer& operator>>(ByteBuffer& data, G3D::Vector3& v)
-{
- data >> v.x >> v.y >> v.z;
- return data;
-}
namespace WorldPackets
{
class PacketArrayMaxCapacityException : public ByteBufferException
{
public:
- PacketArrayMaxCapacityException(std::size_t requestedSize, std::size_t sizeLimit)
- {
- std::ostringstream builder;
- builder << "Attempted to read more array elements from packet " << requestedSize << " than allowed " << sizeLimit;
- message().assign(builder.str());
- }
+ PacketArrayMaxCapacityException(std::size_t requestedSize, std::size_t sizeLimit);
};
/**
@@ -129,6 +96,8 @@ namespace WorldPackets
size_type _limit;
};
+ void CheckCompactArrayMaskOverflow(std::size_t index, std::size_t limit);
+
template <typename T>
class CompactArray
{
@@ -144,14 +113,14 @@ namespace WorldPackets
right._mask = 0;
}
- CompactArray& operator= (CompactArray const& right)
+ CompactArray& operator=(CompactArray const& right)
{
_mask = right._mask;
_contents = right._contents;
return *this;
}
- CompactArray& operator= (CompactArray&& right)
+ CompactArray& operator=(CompactArray&& right)
{
_mask = right._mask;
right._mask = 0;
@@ -160,12 +129,12 @@ namespace WorldPackets
}
uint32 GetMask() const { return _mask; }
- T const& operator[](size_t index) const { return _contents.at(index); }
- size_t GetSize() const { return _contents.size(); }
+ T const& operator[](std::size_t index) const { return _contents.at(index); }
+ std::size_t GetSize() const { return _contents.size(); }
- void Insert(size_t index, T const& value)
+ void Insert(std::size_t index, T const& value)
{
- ASSERT(index < 0x20);
+ CheckCompactArrayMaskOverflow(index, sizeof(_mask) * 8);
_mask |= 1 << index;
if (_contents.size() <= index)
@@ -199,11 +168,9 @@ namespace WorldPackets
{
uint32 mask = v.GetMask();
data << uint32(mask);
- for (size_t i = 0; i < v.GetSize(); ++i)
- {
+ for (std::size_t i = 0; i < v.GetSize(); ++i)
if (mask & (1 << i))
data << v[i];
- }
return data;
}
@@ -214,15 +181,9 @@ namespace WorldPackets
uint32 mask;
data >> mask;
- for (size_t index = 0; mask != 0; mask >>= 1, ++index)
- {
+ for (std::size_t index = 0; mask != 0; mask >>= 1, ++index)
if ((mask & 1) != 0)
- {
- T value;
- data >> value;
- v.Insert(index, value);
- }
- }
+ v.Insert(index, data.read<T>());
return data;
}
diff --git a/src/server/game/Server/Protocol/Opcodes.cpp b/src/server/game/Server/Protocol/Opcodes.cpp
index 316335ffd47..ce095d36a72 100644
--- a/src/server/game/Server/Protocol/Opcodes.cpp
+++ b/src/server/game/Server/Protocol/Opcodes.cpp
@@ -17,8 +17,11 @@
*/
#include "Opcodes.h"
+#include "Log.h"
#include "WorldSession.h"
#include "Packets/AllPackets.h"
+#include <iomanip>
+#include <sstream>
template<class PacketClass, void(WorldSession::*HandlerFunction)(PacketClass&)>
class PacketHandler : public ClientOpcodeHandler
@@ -59,6 +62,17 @@ struct get_packet_class<void(WorldSession::*)(PacketClass&)>
using type = PacketClass;
};
+OpcodeTable::OpcodeTable()
+{
+ memset(_internalTableClient, 0, sizeof(_internalTableClient));
+}
+
+OpcodeTable::~OpcodeTable()
+{
+ for (uint16 i = 0; i < NUM_OPCODE_HANDLERS; ++i)
+ delete _internalTableClient[i];
+}
+
template<typename Handler, Handler HandlerFunction>
void OpcodeTable::ValidateAndSetClientOpcode(OpcodeClient opcode, char const* name, SessionStatus status, PacketProcessing processing)
{
@@ -74,7 +88,7 @@ void OpcodeTable::ValidateAndSetClientOpcode(OpcodeClient opcode, char const* na
return;
}
- if (_internalTableClient[opcode] != NULL)
+ if (_internalTableClient[opcode] != nullptr)
{
TC_LOG_ERROR("network", "Tried to override client handler of %s with %s (opcode %u)", opcodeTable[opcode]->Name, name, opcode);
return;
@@ -97,7 +111,7 @@ void OpcodeTable::ValidateAndSetServerOpcode(OpcodeServer opcode, char const* na
return;
}
- if (_internalTableClient[opcode] != NULL)
+ if (_internalTableClient[opcode] != nullptr)
{
TC_LOG_ERROR("network", "Tried to override server handler of %s with %s (opcode %u)", opcodeTable[opcode]->Name, name, opcode);
return;
@@ -1430,4 +1444,30 @@ void OpcodeTable::Initialize()
#undef DEFINE_HANDLER
#undef DEFINE_SERVER_OPCODE_HANDLER
-}; \ No newline at end of file
+}
+
+template<typename T>
+inline std::string GetOpcodeNameForLoggingImpl(T id)
+{
+ uint16 opcode = uint16(id);
+ std::ostringstream ss;
+ ss << '[';
+
+ if (static_cast<uint16>(id) < NUM_OPCODE_HANDLERS)
+ {
+ if (OpcodeHandler const* handler = opcodeTable[id])
+ ss << handler->Name;
+ else
+ ss << "UNKNOWN OPCODE";
+ }
+ else
+ ss << "INVALID OPCODE";
+
+ ss << " 0x" << std::hex << std::setw(4) << std::setfill('0') << std::uppercase << opcode << std::nouppercase << std::dec << " (" << opcode << ")]";
+ return ss.str();
+}
+
+std::string GetOpcodeNameForLogging(Opcodes opcode)
+{
+ return GetOpcodeNameForLoggingImpl(opcode);
+}
diff --git a/src/server/game/Server/Protocol/Opcodes.h b/src/server/game/Server/Protocol/Opcodes.h
index 9437da07d0b..85e9b395f56 100644
--- a/src/server/game/Server/Protocol/Opcodes.h
+++ b/src/server/game/Server/Protocol/Opcodes.h
@@ -23,8 +23,8 @@
#ifndef _OPCODES_H
#define _OPCODES_H
-#include "Common.h"
-#include <iomanip>
+#include "Define.h"
+#include <string>
enum Opcodes : uint16
{
@@ -1371,8 +1371,6 @@ enum PacketProcessing
class WorldSession;
class WorldPacket;
-#pragma pack(push, 1)
-
class OpcodeHandler
{
public:
@@ -1404,21 +1402,12 @@ public:
class OpcodeTable
{
public:
- OpcodeTable()
- {
- memset(_internalTableClient, 0, sizeof(_internalTableClient));
- }
+ OpcodeTable();
OpcodeTable(OpcodeTable const&) = delete;
OpcodeTable& operator=(OpcodeTable const&) = delete;
- ~OpcodeTable()
- {
- for (uint16 i = 0; i < NUM_OPCODE_HANDLERS; ++i)
- {
- delete _internalTableClient[i];
- }
- }
+ ~OpcodeTable();
void Initialize();
@@ -1438,29 +1427,8 @@ class OpcodeTable
extern OpcodeTable opcodeTable;
-#pragma pack(pop)
-
-/// Lookup opcode name for human understandable logging (T = OpcodeClient|OpcodeServer)
-template<typename T>
-inline std::string GetOpcodeNameForLogging(T id)
-{
- uint16 opcode = uint16(id);
- std::ostringstream ss;
- ss << '[';
-
- if (static_cast<uint16>(id) < NUM_OPCODE_HANDLERS)
- {
- if (OpcodeHandler const* handler = opcodeTable[id])
- ss << handler->Name;
- else
- ss << "UNKNOWN OPCODE";
- }
- else
- ss << "INVALID OPCODE";
-
- ss << " 0x" << std::hex << std::setw(4) << std::setfill('0') << std::uppercase << opcode << std::nouppercase << std::dec << " (" << opcode << ")]";
- return ss.str();
-}
+/// Lookup opcode name for human understandable logging
+std::string GetOpcodeNameForLogging(Opcodes opcode);
#endif
/// @}
diff --git a/src/server/game/Server/Protocol/PacketLog.cpp b/src/server/game/Server/Protocol/PacketLog.cpp
index 0bbaf9c6e98..50e8786defa 100644
--- a/src/server/game/Server/Protocol/PacketLog.cpp
+++ b/src/server/game/Server/Protocol/PacketLog.cpp
@@ -56,7 +56,7 @@ struct PacketHeader
#pragma pack(pop)
-PacketLog::PacketLog() : _file(NULL)
+PacketLog::PacketLog() : _file(nullptr)
{
std::call_once(_initializeFlag, &PacketLog::Initialize, this);
}
@@ -66,7 +66,7 @@ PacketLog::~PacketLog()
if (_file)
fclose(_file);
- _file = NULL;
+ _file = nullptr;
}
PacketLog* PacketLog::instance()
@@ -95,7 +95,7 @@ void PacketLog::Initialize()
header.Build = 12340;
header.Locale[0] = 'e'; header.Locale[1] = 'n'; header.Locale[2] = 'U'; header.Locale[3] = 'S';
std::memset(header.SessionKey, 0, sizeof(header.SessionKey));
- header.SniffStartUnixtime = time(NULL);
+ header.SniffStartUnixtime = time(nullptr);
header.SniffStartTicks = getMSTime();
header.OptionalDataSize = 0;
diff --git a/src/server/game/Server/Protocol/PacketLog.h b/src/server/game/Server/Protocol/PacketLog.h
index e6082940197..0830f5a583b 100644
--- a/src/server/game/Server/Protocol/PacketLog.h
+++ b/src/server/game/Server/Protocol/PacketLog.h
@@ -43,7 +43,7 @@ class TC_GAME_API PacketLog
static PacketLog* instance();
void Initialize();
- bool CanLogPacket() const { return (_file != NULL); }
+ bool CanLogPacket() const { return (_file != nullptr); }
void LogPacket(WorldPacket const& packet, Direction direction, boost::asio::ip::address const& addr, uint16 port);
private:
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index 7eda06aefec..a7a959bd0ea 100644
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -20,33 +20,36 @@
\ingroup u2w
*/
-#include "WorldSocket.h"
+#include "WorldSession.h"
+#include "AccountMgr.h"
+#include "AddonMgr.h"
+#include "BattlegroundMgr.h"
#include "Config.h"
#include "Common.h"
#include "DatabaseEnv.h"
-#include "QueryCallback.h"
-#include "AccountMgr.h"
-#include "Log.h"
-#include "Opcodes.h"
-#include "WorldPacket.h"
-#include "WorldSession.h"
-#include "Player.h"
-#include "Vehicle.h"
-#include "ObjectMgr.h"
-#include "GuildMgr.h"
+#include "DBCStructure.h"
#include "Group.h"
#include "Guild.h"
-#include "World.h"
-#include "BattlegroundMgr.h"
+#include "GuildMgr.h"
+#include "Log.h"
+#include "Map.h"
+#include "Metric.h"
+#include "MoveSpline.h"
+#include "ObjectMgr.h"
+#include "Opcodes.h"
#include "OutdoorPvPMgr.h"
-#include "SocialMgr.h"
+#include "PacketUtilities.h"
+#include "Player.h"
+#include "Realm.h"
#include "ScriptMgr.h"
-#include "WardenWin.h"
-#include "MoveSpline.h"
+#include "SocialMgr.h"
+#include "QueryHolder.h"
+#include "Vehicle.h"
#include "WardenMac.h"
-#include "PacketUtilities.h"
-#include "Metric.h"
-
+#include "WardenWin.h"
+#include "World.h"
+#include "WorldPacket.h"
+#include "WorldSocket.h"
#include <zlib.h>
namespace {
@@ -104,13 +107,13 @@ WorldSession::WorldSession(uint32 id, std::string&& name, std::shared_ptr<WorldS
m_timeOutTime(0),
AntiDOS(this),
m_GUIDLow(0),
- _player(NULL),
+ _player(nullptr),
m_Socket(sock),
_security(sec),
_accountId(id),
_accountName(std::move(name)),
m_expansion(expansion),
- _warden(NULL),
+ _warden(nullptr),
_logoutTime(0),
m_inQueue(false),
m_playerLoading(false),
@@ -124,7 +127,7 @@ WorldSession::WorldSession(uint32 id, std::string&& name, std::shared_ptr<WorldS
m_TutorialsChanged(TUTORIALS_FLAG_NONE),
recruiterId(recruiter),
isRecruiter(isARecruiter),
- _RBACData(NULL),
+ _RBACData(nullptr),
expireTime(60000), // 1 min after socket loss, session is deleted
forceExit(false),
m_currentBankerGUID()
@@ -158,7 +161,7 @@ WorldSession::~WorldSession()
delete _RBACData;
///- empty incoming packet queue
- WorldPacket* packet = NULL;
+ WorldPacket* packet = nullptr;
while (_recvQueue.next(packet))
delete packet;
@@ -167,7 +170,7 @@ WorldSession::~WorldSession()
std::string const & WorldSession::GetPlayerName() const
{
- return _player != NULL ? _player->GetName() : DefaultPlayerName;
+ return _player != nullptr ? _player->GetName() : DefaultPlayerName;
}
std::string WorldSession::GetPlayerInfo() const
@@ -202,21 +205,21 @@ void WorldSession::SendPacket(WorldPacket const* packet)
static uint64 sendPacketCount = 0;
static uint64 sendPacketBytes = 0;
- static time_t firstTime = time(NULL);
+ static time_t firstTime = time(nullptr);
static time_t lastTime = firstTime; // next 60 secs start time
static uint64 sendLastPacketCount = 0;
static uint64 sendLastPacketBytes = 0;
- time_t cur_time = time(NULL);
+ time_t cur_time = time(nullptr);
if ((cur_time - lastTime) < 60)
{
- sendPacketCount+=1;
- sendPacketBytes+=packet->size();
+ sendPacketCount += 1;
+ sendPacketBytes += packet->size();
- sendLastPacketCount+=1;
- sendLastPacketBytes+=packet->size();
+ sendLastPacketCount += 1;
+ sendLastPacketBytes += packet->size();
}
else
{
@@ -244,7 +247,7 @@ void WorldSession::QueuePacket(WorldPacket* new_packet)
}
/// Logging helper for unexpected opcodes
-void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char* status, const char *reason)
+void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, char const* status, const char *reason)
{
TC_LOG_ERROR("network.opcode", "Received unexpected opcode %s Status: %s Reason: %s from %s",
GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str(), status, reason, GetPlayerInfo().c_str());
@@ -274,12 +277,12 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
///- Retrieve packets from the receive queue and call the appropriate handlers
/// not process packets if socket already closed
- WorldPacket* packet = NULL;
+ WorldPacket* packet = nullptr;
//! Delete packet after processing by default
bool deletePacket = true;
std::vector<WorldPacket*> requeuePackets;
uint32 processedPackets = 0;
- time_t currentTime = time(NULL);
+ time_t currentTime = time(nullptr);
while (m_Socket && _recvQueue.next(packet, updater))
{
@@ -403,7 +406,7 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
//logout procedure should happen only in World::UpdateSessions() method!!!
if (updater.ProcessLogout())
{
- time_t currTime = time(NULL);
+ time_t currTime = time(nullptr);
///- If necessary, log the player out
if (ShouldLogOut(currTime) && !m_playerLoading)
LogoutPlayer(true);
@@ -493,7 +496,7 @@ void WorldSession::LogoutPlayer(bool save)
}
}
- // Repop at GraveYard or other player far teleport will prevent saving player because of not present map
+ // Repop at Graveyard or other player far teleport will prevent saving player because of not present map
// Teleport player immediately for correct player save
while (_player->IsBeingTeleportedFar())
HandleMoveWorldportAck();
@@ -503,7 +506,7 @@ void WorldSession::LogoutPlayer(bool save)
guild->HandleMemberLogout(this);
///- Remove pet
- _player->RemovePet(NULL, PET_SAVE_AS_CURRENT, true);
+ _player->RemovePet(nullptr, PET_SAVE_AS_CURRENT, true);
///- Clear whisper whitelist
_player->ClearWhisperWhiteList();
@@ -560,7 +563,7 @@ void WorldSession::LogoutPlayer(bool save)
if (Map* _map = _player->FindMap())
_map->RemovePlayerFromMap(_player, true);
- SetPlayer(NULL); //! Pointer already deleted during RemovePlayerFromMap
+ SetPlayer(nullptr); //! Pointer already deleted during RemovePlayerFromMap
//! Send the 'logout complete' packet to the client
//! Client will respond by sending 3x CMSG_CANCEL_TRADE, which we currently dont handle
@@ -630,6 +633,11 @@ char const* WorldSession::GetTrinityString(uint32 entry) const
return sObjectMgr->GetTrinityString(entry, GetSessionDbLocaleIndex());
}
+void WorldSession::ResetTimeOutTime()
+{
+ m_timeOutTime = int32(sWorld->getIntConfig(CONFIG_SOCKET_TIMEOUTTIME));
+}
+
void WorldSession::Handle_NULL(WorldPacket& null)
{
TC_LOG_ERROR("network.opcode", "Received unhandled opcode %s from %s", GetOpcodeNameForLogging(static_cast<OpcodeClient>(null.GetOpcode())).c_str(), GetPlayerInfo().c_str());
@@ -737,7 +745,7 @@ void WorldSession::SetAccountData(AccountDataType type, time_t tm, std::string c
void WorldSession::SendAccountDataTimes(uint32 mask)
{
WorldPacket data(SMSG_ACCOUNT_DATA_TIMES, 4 + 1 + 4 + NUM_ACCOUNT_DATA_TYPES * 4);
- data << uint32(time(NULL)); // Server time
+ data << uint32(time(nullptr)); // Server time
data << uint8(1);
data << uint32(mask); // type mask
for (uint32 i = 0; i < NUM_ACCOUNT_DATA_TYPES; ++i)
@@ -1221,7 +1229,7 @@ void WorldSession::InvalidateRBACData()
TC_LOG_DEBUG("rbac", "WorldSession::Invalidaterbac::RBACData [AccountId: %u, Name: %s, realmId: %d]",
_RBACData->GetId(), _RBACData->GetName().c_str(), realm.Id.Realm);
delete _RBACData;
- _RBACData = NULL;
+ _RBACData = nullptr;
}
bool WorldSession::DosProtection::EvaluateOpcode(WorldPacket& p, time_t time) const
@@ -1515,3 +1523,7 @@ uint32 WorldSession::DosProtection::GetMaxPacketCounterAllowed(uint16 opcode) co
return maxPacketCounterAllowed;
}
+
+WorldSession::DosProtection::DosProtection(WorldSession* s) : Session(s), _policy((Policy)sWorld->getIntConfig(CONFIG_PACKET_SPOOF_POLICY))
+{
+}
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index eea430ac1b5..9271fb06e06 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -24,15 +24,15 @@
#define __WORLDSESSION_H
#include "Common.h"
-#include "SharedDefines.h"
-#include "AddonMgr.h"
-#include "DatabaseEnv.h"
-#include "World.h"
+#include "DatabaseEnvFwd.h"
+#include "LockedQueue.h"
+#include "ObjectGuid.h"
#include "Packet.h"
-#include "Cryptography/BigNumber.h"
-#include "AccountMgr.h"
-#include <unordered_set>
+#include "QueryCallbackProcessor.h"
+#include "SharedDefines.h"
+#include <unordered_map>
+class BigNumber;
class Creature;
class GameObject;
class InstanceSave;
@@ -46,6 +46,7 @@ class Unit;
class Warden;
class WorldPacket;
class WorldSocket;
+struct AddonInfo;
struct AreaTableEntry;
struct AuctionEntry;
struct DeclinedName;
@@ -284,7 +285,7 @@ class TC_GAME_API WorldSession
void SendNotification(uint32 string_id, ...);
void SendPetNameInvalid(uint32 error, std::string const& name, DeclinedName *declinedName);
void SendPartyResult(PartyOperation operation, std::string const& member, PartyResult res, uint32 val = 0);
- void SendAreaTriggerMessage(const char* Text, ...) ATTR_PRINTF(2, 3);
+ void SendAreaTriggerMessage(char const* Text, ...) ATTR_PRINTF(2, 3);
void SendSetPhaseShift(uint32 phaseShift);
void SendQueryTimeResponse();
@@ -438,10 +439,7 @@ class TC_GAME_API WorldSession
m_timeOutTime -= int32(diff);
}
- void ResetTimeOutTime()
- {
- m_timeOutTime = int32(sWorld->getIntConfig(CONFIG_SOCKET_TIMEOUTTIME));
- }
+ void ResetTimeOutTime();
bool IsConnectionIdle() const
{
@@ -999,7 +997,7 @@ class TC_GAME_API WorldSession
{
friend class World;
public:
- DosProtection(WorldSession* s) : Session(s), _policy((Policy)sWorld->getIntConfig(CONFIG_PACKET_SPOOF_POLICY)) { }
+ DosProtection(WorldSession* s);
bool EvaluateOpcode(WorldPacket& p, time_t time) const;
protected:
enum Policy
@@ -1030,7 +1028,7 @@ class TC_GAME_API WorldSession
bool CanUseBank(ObjectGuid bankerGUID = ObjectGuid::Empty) const;
// logging helper
- void LogUnexpectedOpcode(WorldPacket* packet, const char* status, const char *reason);
+ void LogUnexpectedOpcode(WorldPacket* packet, char const* status, const char *reason);
void LogUnprocessedTail(WorldPacket* packet);
// EnumData helpers
diff --git a/src/server/game/Server/WorldSocket.cpp b/src/server/game/Server/WorldSocket.cpp
index ae8b3fd0998..699c5a38a92 100644
--- a/src/server/game/Server/WorldSocket.cpp
+++ b/src/server/game/Server/WorldSocket.cpp
@@ -18,12 +18,16 @@
#include "WorldSocket.h"
#include "BigNumber.h"
+#include "DatabaseEnv.h"
#include "Opcodes.h"
-#include "QueryCallback.h"
+#include "PacketLog.h"
+#include "Random.h"
+#include "RBAC.h"
+#include "Realm.h"
#include "ScriptMgr.h"
#include "SHA1.h"
-#include "PacketLog.h"
-
+#include "World.h"
+#include "WorldSession.h"
#include <memory>
class EncryptablePacket : public WorldPacket
@@ -505,7 +509,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
sha.UpdateData((uint8*)&t, 4);
sha.UpdateData((uint8*)&authSession->LocalChallenge, 4);
sha.UpdateData((uint8*)&_authSeed, 4);
- sha.UpdateBigNumbers(&account.SessionKey, NULL);
+ sha.UpdateBigNumbers(&account.SessionKey, nullptr);
sha.Finalize();
if (memcmp(sha.GetDigest(), authSession->Digest, SHA_DIGEST_LENGTH) != 0)
@@ -546,7 +550,7 @@ void WorldSocket::HandleAuthSessionCallback(std::shared_ptr<AuthSession> authSes
//! Negative mutetime indicates amount of seconds to be muted effective on next login - which is now.
if (mutetime < 0)
{
- mutetime = time(NULL) + llabs(mutetime);
+ mutetime = time(nullptr) + llabs(mutetime);
PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_UPD_MUTE_TIME_LOGIN);
stmt->setInt64(0, mutetime);
diff --git a/src/server/game/Server/WorldSocketMgr.h b/src/server/game/Server/WorldSocketMgr.h
index ce81acfea78..e409f8d2ea8 100644
--- a/src/server/game/Server/WorldSocketMgr.h
+++ b/src/server/game/Server/WorldSocketMgr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2013 TrinityCore <http://www.trinitycore.org/>
+ * Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/>
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*
* This program is free software; you can redistribute it and/or modify it