Skip to content
Permalink
Browse files

Server/Misc: Fixed some static analysis issues

Signed-off-by: AriDEV <aridev666@gmail.com>
  • Loading branch information
AriDEV committed Feb 10, 2020
1 parent 1e49116 commit 39eb6f0111d5897cbe7a8939f9a65ca4144828fc
@@ -36,14 +36,14 @@ AccountMgr::~AccountMgr()
AccountOpResult AccountMgr::CreateAccount(std::string username, std::string password, std::string email = "")
{
if (utf8length(username) > MAX_ACCOUNT_STR)
return AOR_NAME_TOO_LONG; // username's too long
return AccountOpResult::AOR_NAME_TOO_LONG; // username's too long

normalizeString(username);
normalizeString(password);
normalizeString(email);

if (GetId(username))
return AOR_NAME_ALREADY_EXIST; // username does already exist
return AccountOpResult::AOR_NAME_ALREADY_EXIST; // username does already exist

PreparedStatement* stmt = LoginDatabase.GetPreparedStatement(LOGIN_INS_ACCOUNT);

@@ -66,7 +66,7 @@ AccountOpResult AccountMgr::CreateAccount(std::string username, std::string pass
LoginDatabase.Execute(stmt);
}

return AOR_OK; // everything's fine
return AccountOpResult::AOR_OK; // everything's fine
}

AccountOpResult AccountMgr::DeleteAccount(uint32 accountId)
@@ -77,7 +77,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accountId)
PreparedQueryResult result = LoginDatabase.Query(stmt);

if (!result)
return AOR_NAME_NOT_EXIST;
return AccountOpResult::AOR_NAME_NOT_EXIST;

// Obtain accounts characters
stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_CHARS_BY_ACCOUNT_ID);
@@ -138,7 +138,7 @@ AccountOpResult AccountMgr::DeleteAccount(uint32 accountId)

LoginDatabase.CommitTransaction(trans);

return AOR_OK;
return AccountOpResult::AOR_OK;
}

AccountOpResult AccountMgr::ChangeUsername(uint32 accountId, std::string newUsername, std::string newPassword)
@@ -149,13 +149,13 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accountId, std::string newUser
PreparedQueryResult result = LoginDatabase.Query(stmt);

if (!result)
return AOR_NAME_NOT_EXIST;
return AccountOpResult::AOR_NAME_NOT_EXIST;

if (utf8length(newUsername) > MAX_ACCOUNT_STR)
return AOR_NAME_TOO_LONG;
return AccountOpResult::AOR_NAME_TOO_LONG;

if (utf8length(newPassword) > MAX_ACCOUNT_STR)
return AOR_PASS_TOO_LONG;
return AccountOpResult::AOR_PASS_TOO_LONG;

normalizeString(newUsername);
normalizeString(newPassword);
@@ -168,18 +168,18 @@ AccountOpResult AccountMgr::ChangeUsername(uint32 accountId, std::string newUser

LoginDatabase.Execute(stmt);

return AOR_OK;
return AccountOpResult::AOR_OK;
}

AccountOpResult AccountMgr::ChangePassword(uint32 accountId, std::string newPassword)
{
std::string username;

if (!GetName(accountId, username))
return AOR_NAME_NOT_EXIST; // account doesn't exist
return AccountOpResult::AOR_NAME_NOT_EXIST; // account doesn't exist

if (utf8length(newPassword) > MAX_ACCOUNT_STR)
return AOR_PASS_TOO_LONG;
return AccountOpResult::AOR_PASS_TOO_LONG;

normalizeString(username);
normalizeString(newPassword);
@@ -199,18 +199,18 @@ AccountOpResult AccountMgr::ChangePassword(uint32 accountId, std::string newPass

LoginDatabase.Execute(stmt);

return AOR_OK;
return AccountOpResult::AOR_OK;
}

AccountOpResult AccountMgr::ChangeEmail(uint32 accountId, std::string newEmail)
{
std::string username;

if (!GetName(accountId, username))
return AOR_NAME_NOT_EXIST; // account doesn't exist
return AccountOpResult::AOR_NAME_NOT_EXIST; // account doesn't exist

if (utf8length(newEmail) > MAX_EMAIL_STR)
return AOR_EMAIL_TOO_LONG;
return AccountOpResult::AOR_EMAIL_TOO_LONG;

normalizeString(username);
normalizeString(newEmail);
@@ -222,18 +222,18 @@ AccountOpResult AccountMgr::ChangeEmail(uint32 accountId, std::string newEmail)

LoginDatabase.Execute(stmt);

return AOR_OK;
return AccountOpResult::AOR_OK;
}

AccountOpResult AccountMgr::ChangeRegEmail(uint32 accountId, std::string newEmail)
{
std::string username;

if (!GetName(accountId, username))
return AOR_NAME_NOT_EXIST; // account doesn't exist
return AccountOpResult::AOR_NAME_NOT_EXIST; // account doesn't exist

if (utf8length(newEmail) > MAX_EMAIL_STR)
return AOR_EMAIL_TOO_LONG;
return AccountOpResult::AOR_EMAIL_TOO_LONG;

normalizeString(username);
normalizeString(newEmail);
@@ -245,7 +245,7 @@ AccountOpResult AccountMgr::ChangeRegEmail(uint32 accountId, std::string newEmai

LoginDatabase.Execute(stmt);

return AOR_OK;
return AccountOpResult::AOR_OK;
}

uint32 AccountMgr::GetId(std::string const& username)
@@ -23,7 +23,7 @@
#include "RBAC.h"
#include <ace/Singleton.h>

enum AccountOpResult
enum class AccountOpResult
{
AOR_OK,
AOR_NAME_TOO_LONG,
@@ -58,23 +58,23 @@ RBACCommandResult RBACData::GrantPermission(uint32 permissionId, int32 realmId /
{
SF_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission does not exists",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_ID_DOES_NOT_EXISTS;
return RBACCommandResult::RBAC_ID_DOES_NOT_EXISTS;
}

// Check if already added in denied list
if (HasDeniedPermission(permissionId))
{
SF_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission in deny list",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_IN_DENIED_LIST;
return RBACCommandResult::RBAC_IN_DENIED_LIST;
}

// Already added?
if (HasGrantedPermission(permissionId))
{
SF_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission already granted",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_CANT_ADD_ALREADY_ADDED;
return RBACCommandResult::RBAC_CANT_ADD_ALREADY_ADDED;
}

AddGrantedPermission(permissionId);
@@ -91,7 +91,7 @@ RBACCommandResult RBACData::GrantPermission(uint32 permissionId, int32 realmId /
SF_LOG_TRACE("rbac", "RBACData::GrantPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok",
GetId(), GetName().c_str(), permissionId, realmId);

return RBAC_OK;
return RBACCommandResult::RBAC_OK;
}

RBACCommandResult RBACData::DenyPermission(uint32 permissionId, int32 realmId /* = 0*/)
@@ -102,23 +102,23 @@ RBACCommandResult RBACData::DenyPermission(uint32 permissionId, int32 realmId /*
{
SF_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission does not exists",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_ID_DOES_NOT_EXISTS;
return RBACCommandResult::RBAC_ID_DOES_NOT_EXISTS;
}

// Check if already added in granted list
if (HasGrantedPermission(permissionId))
{
SF_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission in grant list",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_IN_GRANTED_LIST;
return RBACCommandResult::RBAC_IN_GRANTED_LIST;
}

// Already added?
if (HasDeniedPermission(permissionId))
{
SF_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Permission already denied",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_CANT_ADD_ALREADY_ADDED;
return RBACCommandResult::RBAC_CANT_ADD_ALREADY_ADDED;
}

AddDeniedPermission(permissionId);
@@ -135,7 +135,7 @@ RBACCommandResult RBACData::DenyPermission(uint32 permissionId, int32 realmId /*
SF_LOG_TRACE("rbac", "RBACData::DenyPermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok",
GetId(), GetName().c_str(), permissionId, realmId);

return RBAC_OK;
return RBACCommandResult::RBAC_OK;
}

void RBACData::SavePermission(uint32 permission, bool granted, int32 realmId)
@@ -155,7 +155,7 @@ RBACCommandResult RBACData::RevokePermission(uint32 permissionId, int32 realmId
{
SF_LOG_TRACE("rbac", "RBACData::RevokePermission [Id: %u Name: %s] (Permission %u, RealmId %d). Not granted or revoked",
GetId(), GetName().c_str(), permissionId, realmId);
return RBAC_CANT_REVOKE_NOT_IN_LIST;
return RBACCommandResult::RBAC_CANT_REVOKE_NOT_IN_LIST;
}

RemoveGrantedPermission(permissionId);
@@ -178,7 +178,7 @@ RBACCommandResult RBACData::RevokePermission(uint32 permissionId, int32 realmId
SF_LOG_TRACE("rbac", "RBACData::RevokePermission [Id: %u Name: %s] (Permission %u, RealmId %d). Ok",
GetId(), GetName().c_str(), permissionId, realmId);

return RBAC_OK;
return RBACCommandResult::RBAC_OK;
}

void RBACData::LoadFromDB()
@@ -711,7 +711,7 @@ enum RBACPermissions
RBAC_PERM_MAX
};

enum RBACCommandResult
enum class RBACCommandResult
{
RBAC_OK,
RBAC_CANT_ADD_ALREADY_ADDED,

void Player::outDebugValues() const
{
if (!sLog->ShouldLog("entities.unit", LOG_LEVEL_DEBUG))
if (!sLog->ShouldLog("entities.unit", LogLevel::LOG_LEVEL_DEBUG))
return;

SF_LOG_DEBUG("entities.unit", "HP is: \t\t\t%u\t\tMP is: \t\t\t%u", GetMaxHealth(), GetMaxPower(POWER_MANA));
@@ -3542,7 +3542,7 @@ void Guild::_BroadcastEvent(GuildEvents guildEvent, uint64 guid, const char* par

BroadcastPacket(&data);

if (sLog->ShouldLog("guild", LOG_LEVEL_DEBUG))
if (sLog->ShouldLog("guild", LogLevel::LOG_LEVEL_DEBUG))
SF_LOG_DEBUG("guild", "SMSG_GUILD_EVENT [Broadcast] Event: %s (%u)", _GetGuildEventString(guildEvent).c_str(), guildEvent);
}

@@ -804,7 +804,7 @@ void WorldSession::HandleCharDeleteOpcode(WorldPacket& recvData)
SF_LOG_INFO("entities.player.character", "Account: %d, IP: %s deleted character: %s, GUID: %u, Level: %u", accountId, IP_str.c_str(), name.c_str(), GUID_LOPART(guid), level);
sScriptMgr->OnPlayerDelete(guid);

if (sLog->ShouldLog("entities.player.dump", LOG_LEVEL_INFO)) // optimize GetPlayerDump call
if (sLog->ShouldLog("entities.player.dump", LogLevel::LOG_LEVEL_INFO)) // optimize GetPlayerDump call
{
std::string dump;
if (PlayerDumpWriter().GetDump(GUID_LOPART(guid), dump))
@@ -292,7 +292,7 @@ void WorldSession::LogUnexpectedOpcode(WorldPacket* packet, const char* status,
/// Logging helper for unexpected opcodes
void WorldSession::LogUnprocessedTail(WorldPacket* packet)
{
if (!sLog->ShouldLog("network.opcode", LOG_LEVEL_TRACE) || packet->rpos() >= packet->wpos())
if (!sLog->ShouldLog("network.opcode", LogLevel::LOG_LEVEL_TRACE) || packet->rpos() >= packet->wpos())
return;

SF_LOG_TRACE("network.opcode", "Unprocessed tail data (read stop at %u from %u) Opcode %s from %s",
@@ -275,7 +275,7 @@ WorldSocketMgr::StartReactiveIO (ACE_UINT16 port, const char* address)
int
WorldSocketMgr::StartNetwork (ACE_UINT16 port, const char* address)
{
if (!sLog->ShouldLog("misc", LOG_LEVEL_DEBUG))
if (!sLog->ShouldLog("misc", LogLevel::LOG_LEVEL_DEBUG))
ACE_Log_Msg::instance()->priority_mask (LM_ERROR, ACE_Log_Msg::PROCESS);

if (StartReactiveIO(port, address) == -1)

0 comments on commit 39eb6f0

Please sign in to comment.
You can’t perform that action at this time.