Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/game/AccountMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ AccountMgr::~AccountMgr()

AccountOpResult AccountMgr::CreateAccount(std::string username, std::string password)
{
if (utf8length(username) > MAX_ACCOUNT_STR)
if (utf8length(username).value_or(MAX_ACCOUNT_STR + 1) > MAX_ACCOUNT_STR)
return AOR_NAME_TOO_LONG; // username's too long

normalizeString(username);
Expand Down Expand Up @@ -119,10 +119,10 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accid, std::string new_uname,
if (!result)
return AOR_NAME_NOT_EXIST; // account doesn't exist

if (utf8length(new_uname) > MAX_ACCOUNT_STR)
if (utf8length(new_uname).value_or(MAX_ACCOUNT_STR + 1) > MAX_ACCOUNT_STR)
return AOR_NAME_TOO_LONG;

if (utf8length(new_passwd) > MAX_ACCOUNT_STR)
if (utf8length(new_passwd).value_or(MAX_ACCOUNT_STR + 1) > MAX_ACCOUNT_STR)
return AOR_PASS_TOO_LONG;

normalizeString(new_uname);
Expand Down Expand Up @@ -160,7 +160,7 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accid, std::string new_passwd,
else
normalizeString(username); // account doesn't exist

if (utf8length(new_passwd) > MAX_ACCOUNT_STR)
if (utf8length(new_passwd).value_or(MAX_ACCOUNT_STR + 1) > MAX_ACCOUNT_STR)
return AOR_PASS_TOO_LONG;

normalizeString(new_passwd);
Expand Down Expand Up @@ -376,7 +376,7 @@ void AccountMgr::LoadAccountBanList(bool silent)
sLog.Out(LOG_BASIC, LOG_LVL_MINIMAL, "Loading account_banned ...");

std::unique_ptr<QueryResult> banresult(LoginDatabase.PQuery("SELECT `id`, `unbandate`, `bandate` FROM `account_banned` WHERE `active` = 1 AND (`unbandate` > UNIX_TIMESTAMP() OR `bandate` = `unbandate`)"));

if (!banresult)
{
if (!silent)
Expand Down Expand Up @@ -539,7 +539,7 @@ AccountPersistentData& AccountMgr::GetAccountPersistentData(uint32 accountId)
if (itr != m_accountPersistentData.end())
return itr->second;
}

{
std::lock_guard<std::shared_timed_mutex> guard(m_accountPersistentDataMutex);
return m_accountPersistentData[accountId];
Expand Down
14 changes: 8 additions & 6 deletions src/game/Anticheat/WardenAnticheat/Warden.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ void Warden::ApplyPenalty(std::string message, WardenActions penalty, std::share
});
}

void Warden::HandlePacket(WorldPacket& recvData)
void Warden::HandlePacket(ByteBuffer recvData)
{
// initialize decrypt packet
DecryptData(const_cast<uint8*>(recvData.contents()), recvData.size());
Expand Down Expand Up @@ -658,18 +658,20 @@ void Warden::HandlePacket(WorldPacket& recvData)
void Warden::Update()
{
{
std::vector<WorldPacket> packetQueue;
std::queue<std::vector<uint8>> packetQueue;

{
std::lock_guard<std::mutex> lock(m_packetQueueMutex);
std::swap(packetQueue, m_packetQueue);
std::lock_guard<std::mutex> lock(m_packetDataQueueMutex);
std::swap(packetQueue, m_packetDataQueue);
}

for (auto& packet : packetQueue)
while (packetQueue.size())
{
std::vector<uint8> packetData = std::move(packetQueue.front());
packetQueue.pop();
try
{
HandlePacket(packet);
HandlePacket(ByteBuffer::from(std::move(packetData)));
}
catch (ByteBufferException &)
{
Expand Down
6 changes: 3 additions & 3 deletions src/game/Anticheat/WardenAnticheat/Warden.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class Warden

static void LoadScriptedScans();

void HandlePacket(WorldPacket& recvData);
void HandlePacket(ByteBuffer recvData);

bool IsUsingMaiev() const { return m_maiev; }
WardenModule const* GetModule() const { return m_module; }
Expand All @@ -183,8 +183,8 @@ class Warden
virtual void GetPlayerInfo(std::string& clock, std::string& fingerprint, std::string& hypervisors,
std::string& renderer, std::string& proxifier) const = 0;

std::vector<WorldPacket> m_packetQueue;
std::mutex m_packetQueueMutex;
std::queue<std::vector<uint8>> m_packetDataQueue;
std::mutex m_packetDataQueueMutex;

// used by maiev string hash check
mutable std::string m_hashString;
Expand Down
1 change: 0 additions & 1 deletion src/game/AuctionHouse/AuctionHouseMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ struct AuctionHouseClientQuery
uint8 levelmax;
uint8 usable;
uint32 listfrom, auctionSlotID, auctionMainCategory, auctionSubCategory, quality;
uint32 outbiddedCount;
std::vector<uint32> outbiddedAuctionIds;
};

Expand Down
7 changes: 4 additions & 3 deletions src/game/Battlegrounds/BattleGround.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "Formulas.h"
#include "GridNotifiersImpl.h"
#include "Chat.h"
#include "ScriptMgr.h"

namespace MaNGOS
{
Expand Down Expand Up @@ -690,7 +691,7 @@ void BattleGround::EndBattleGround(Team winner)
if (team == winner)
RewardMark(pPlayer, true);
// World of Warcraft Client Patch 1.8.4 (2005-12-06)
// - Battles must now last at least ten minutes after the start of the
// - Battles must now last at least ten minutes after the start of the
// battle in order for the losing team to receive a Mark of honor.
else if (GetStartTime() > 10 * MINUTE * IN_MILLISECONDS)
RewardMark(pPlayer, false);
Expand Down Expand Up @@ -1199,7 +1200,7 @@ void BattleGround::DecreaseInvitedCount(Team team)
}
}
void BattleGround::IncreaseInvitedCount(Team team)
{
{
switch (team)
{
case ALLIANCE:
Expand Down Expand Up @@ -1283,7 +1284,7 @@ bool BattleGround::AddObject(uint32 type, uint32 entry, float x, float y, float
delete go;
return false;
}

// add to world, so it can be later looked up from HashMapHolder
go->AddToWorld();
m_bgObjects[type] = go->GetObjectGuid();
Expand Down
52 changes: 52 additions & 0 deletions src/game/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,36 @@ set (game_SRCS
PlayerBots/PlayerBotAI.cpp
PlayerBots/PlayerBotMgr.cpp
Server/Protocol/Opcodes.cpp
Server/Packets/Battleground.cpp
Server/Packets/AuctionHouse.cpp
Server/Packets/Channel.cpp
Server/Packets/Character.cpp
Server/Packets/Chat.cpp
Server/Packets/Combat.cpp
Server/Packets/Duel.cpp
Server/Packets/GmTicket.cpp
Server/Packets/Group.cpp
Server/Packets/Guild.cpp
Server/Packets/Item.cpp
Server/Packets/Loot.cpp
Server/Packets/Mail.cpp
Server/Packets/Misc.cpp
Server/Packets/Movement.cpp
Server/Packets/Npc.cpp
Server/Packets/Pet.cpp
Server/Packets/Petition.cpp
Server/Packets/Query.cpp
Server/Packets/Quest.cpp
Server/Packets/Skill.cpp
Server/Packets/Spell.cpp
Server/Packets/Taxi.cpp
Server/Packets/Trade.cpp
Server/WorldSession.cpp
Server/WorldSocket.cpp
Server/WorldSocketMgr.cpp
Spells/Spell.cpp
Spells/SpellAuras.cpp
Spells/SpellCastTargetsInfo.cpp
Spells/SpellEffects.cpp
Spells/SpellEntry.cpp
Spells/SpellMgr.cpp
Expand Down Expand Up @@ -419,13 +444,40 @@ set (game_SRCS
PlayerBots/PlayerBotAI.h
PlayerBots/PlayerBotMgr.h
Server/Protocol/Opcodes.h
Server/Protocol/Opcodes_active.h
Server/Packet.h
Server/Packets/Battleground.h
Server/Packets/AuctionHouse.h
Server/Packets/Channel.h
Server/Packets/Character.h
Server/Packets/Chat.h
Server/Packets/Combat.h
Server/Packets/Duel.h
Server/Packets/GmTicket.h
Server/Packets/Group.h
Server/Packets/Guild.h
Server/Packets/Item.h
Server/Packets/Loot.h
Server/Packets/Mail.h
Server/Packets/Misc.h
Server/Packets/Movement.h
Server/Packets/Npc.h
Server/Packets/Pet.h
Server/Packets/Petition.h
Server/Packets/Query.h
Server/Packets/Quest.h
Server/Packets/Skill.h
Server/Packets/Spell.h
Server/Packets/Taxi.h
Server/Packets/Trade.h
Server/WorldPacket.h
Server/WorldSession.h
Server/WorldSocket.h
Server/WorldSocketMgr.h
Spells/Spell.h
Spells/SpellAuraDefines.h
Spells/SpellAuras.h
Spells/SpellCastTargetsInfo.h
Spells/SpellClassMask.h
Spells/SpellDefines.h
Spells/SpellEntry.h
Expand Down
22 changes: 12 additions & 10 deletions src/game/Chat/Chat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ ChatCommand * ChatHandler::getCommandTable()
{ "", SEC_TICKETMASTER, true, &ChatHandler::HandleGMTicketGetByIdOrNameCommand, "", nullptr },
{ nullptr, 0, false, nullptr, "", nullptr }
};

static ChatCommand serviceCommandTable[] =
{
{ "del_characters", SEC_ADMINISTRATOR, true, &ChatHandler::HandleServiceDeleteCharacters, "", nullptr },
Expand Down Expand Up @@ -1411,7 +1411,7 @@ void ChatHandler::LoadRbacPermissions()
sLog.Out(LOG_DBERROR, LOG_LVL_ERROR, "Unknown RBAC permission id %u assigned to command '%s'!", permissionId, command.c_str());
continue;
}

SetPermissionMaskForCommandInTable(commandTable, command.c_str(), permissionId);

} while (result->NextRow());
Expand Down Expand Up @@ -2020,7 +2020,7 @@ bool ChatHandler::SetDataForCommandInTable(ChatCommand *commandTable, char const
return false;
}

bool ChatHandler::ParseCommands(char const* text)
ParseCommandResult ChatHandler::ParseCommands(char const* text)
{
MANGOS_ASSERT(text);
MANGOS_ASSERT(*text);
Expand All @@ -2029,19 +2029,19 @@ bool ChatHandler::ParseCommands(char const* text)
if (m_session)
{
if (text[0] != '!' && text[0] != '.')
return false;
return ParseCommandResult::WasNotHandled;

// ignore single . and ! in line
if (strlen(text) < 2)
return false;
return ParseCommandResult::WasNotHandled;

if (m_session->GetSecurity() == SEC_PLAYER && !sWorld.getConfig(CONFIG_BOOL_PLAYER_COMMANDS))
return false;
return ParseCommandResult::WasNotHandled;
}

// ignore messages staring from many dots.
if ((text[0] == '.' && text[1] == '.') || (text[0] == '!' && text[1] == '!'))
return false;
return ParseCommandResult::WasNotHandled;

// skip first . or ! (in console allowed use command with . and ! and without its)
if (text[0] == '!' || text[0] == '.')
Expand Down Expand Up @@ -2073,7 +2073,7 @@ bool ChatHandler::ParseCommands(char const* text)
else
ExecuteCommand(text);

return true;
return ParseCommandResult::CommandDetectedAndHandled;
}

bool ChatHandler::ShowHelpForSubCommands(ChatCommand *table, char const* cmd)
Expand Down Expand Up @@ -2160,7 +2160,7 @@ bool ChatHandler::ShowHelpForCommand(ChatCommand *table, char const* cmd)
return command || childCommands;
}

bool ChatHandler::isValidChatMessage(char const* message)
bool ChatHandler::isValidChatMessage(std::string const& msg)
{
/*

Expand All @@ -2174,9 +2174,11 @@ bool ChatHandler::isValidChatMessage(char const* message)
| will be escaped to ||
*/

if (strlen(message) > 255)
if (msg.length() > 255)
return false;

char const* message = msg.c_str();

char const validSequence[6] = "cHhhr";
char const* validSequenceIterator = validSequence;

Expand Down
18 changes: 12 additions & 6 deletions src/game/Chat/Chat.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ enum PlayerChatTag
CHAT_TAG_GM = 3,
};

enum class ParseCommandResult
Comment thread
0blu marked this conversation as resolved.
{
CommandDetectedAndHandled,
WasNotHandled,
};

class PartyBotAI;
class BattleBotAI;

Expand Down Expand Up @@ -119,10 +125,10 @@ class ChatHandler
void PSendSysMessage(int32 entry, ... );
std::string PGetParseString(int32 entry, ...);

bool ParseCommands(char const* text);
ParseCommandResult ParseCommands(char const* text);
ChatCommand const* FindCommand(char const* text);

bool isValidChatMessage(char const* msg);
bool isValidChatMessage(std::string const& msg);
bool HasSentErrorMessage() { return m_sentErrorMessage;}

std::string playerLink(std::string const& name) const { return m_session ? "|cffffffff|Hplayer:"+name+"|h["+name+"]|h|r" : name; }
Expand Down Expand Up @@ -189,7 +195,7 @@ class ChatHandler
void CheckIntegrity(ChatCommand *table, ChatCommand *parentCommand);
static void FillFullCommandsName(ChatCommand* table, std::string prefix);
static ChatCommand* getCommandTable();

bool HandleAnticheatCommand(char*);
bool HandleReloadAnticheatCommand(char*);
bool HandleViewLogCommand(char*);
Expand Down Expand Up @@ -390,8 +396,8 @@ class ChatHandler
bool HandleDebugControlCommand(char *args);
bool HandlePvPCommand(char *args);
// Channel
bool HandleChannelJoinCommand(char*);
bool HandleChannelLeaveCommand(char*);
bool HandleChannelJoinCommand(char* args);
bool HandleChannelLeaveCommand(char* args);

bool HandleAccountCommand(char* args);
bool HandleAccountCharactersCommand(char* args);
Expand Down Expand Up @@ -471,7 +477,7 @@ class ChatHandler
bool HandleDebugPlaySoundCommand(char* args);
bool HandleDebugPlayScriptText(char* args);
bool HandleDebugPlayMusicCommand(char* args);

bool HandleDebugSendBuyErrorCommand(char* args);
bool HandleDebugSendChannelNotifyCommand(char* args);
bool HandleDebugSendChatMsgCommand(char* args);
Expand Down
Loading
Loading