Core/Misc: Explicitly include required headers instead of relying on them to be included by other headers

This commit is contained in:
Shauren
2022-02-11 14:33:35 +01:00
parent 5b02c53fc5
commit cbcd149ce5
21 changed files with 41 additions and 28 deletions

View File

@@ -20,8 +20,10 @@
#include "DB2Meta.h"
#include "Errors.h"
#include "Log.h"
#include <limits>
#include <sstream>
#include <system_error>
#include <cstring>
enum class DB2ColumnCompression : uint32
{

View File

@@ -35,10 +35,12 @@
#if TRINITY_PLATFORM == TRINITY_PLATFORM_WINDOWS
#include <Windows.h>
#include <intrin.h>
#define Crash(message) \
ULONG_PTR execeptionArgs[] = { reinterpret_cast<ULONG_PTR>(strdup(message)), reinterpret_cast<ULONG_PTR>(_ReturnAddress()) }; \
RaiseException(EXCEPTION_ASSERTION_FAILURE, 0, 2, execeptionArgs);
#else
#include <cstring>
// should be easily accessible in gdb
extern "C" { TC_COMMON_API char const* TrinityAssertionFailedMessage = nullptr; }
#define Crash(message) \

View File

@@ -21,6 +21,7 @@
#ifdef _WIN32 // Windows
#include <Windows.h>
#elif defined(__linux__)
#include <cstring>
#include <sched.h>
#include <sys/resource.h>
#define PROCESS_HIGH_PRIORITY -15 // [-20, 19], default is 0

View File

@@ -19,6 +19,7 @@
#include "Errors.h"
#include "Log.h"
#include "MySQLHacks.h"
#include <cstring>
Field::Field()
{

View File

@@ -20,6 +20,7 @@
#include "Log.h"
#include "MySQLHacks.h"
#include "PreparedStatement.h"
#include <cstring>
template<typename T>
struct MySQLType { };

View File

@@ -21,6 +21,7 @@
#include "Log.h"
#include "MySQLHacks.h"
#include "MySQLWorkaround.h"
#include <cstring>
namespace
{

View File

@@ -23,6 +23,7 @@
#include <mysqld_error.h>
#include <sstream>
#include <thread>
#include <cstring>
std::mutex TransactionTask::_deadlockLock;

View File

@@ -26,9 +26,9 @@
#include "Util.h"
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/punctuation/comma_if.hpp>
#include <fmt/ostream.h>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <string_view>
#include <tuple>
@@ -154,7 +154,7 @@ namespace Trinity::ChatCommands
operator uint32() const { return _id; }
operator std::string const& () const { return _name; }
operator std::string_view() const { return { _name }; }
operator std::string_view() const { return _name; }
uint32 GetID() const { return _id; }
std::string const& GetName() const { return _name; }

View File

@@ -540,7 +540,7 @@ void LoadDB2(std::bitset<TOTAL_LOCALES>& availableDb2Locales, std::vector<std::s
{
if (e.code() == std::errc::no_such_file_or_directory)
{
errlist.push_back(Trinity::StringFormat("File %s does not exist", db2Path + localeNames[defaultLocale] + '/' + storage->GetFileName()));
errlist.push_back(Trinity::StringFormat("File %s%s/%s does not exist", db2Path.c_str(), localeNames[defaultLocale], storage->GetFileName().c_str()));
}
else
throw;

View File

@@ -740,7 +740,7 @@ void WorldSession::HandleAuctionSellCommodity(WorldPackets::AuctionHouse::Auctio
{
Item* logItem = items2.begin()->second.first;
sLog->outCommand(GetAccountId(), "GM %s (Account: %u) create auction: %s (Entry: %u Count: " UI64FMTD ")",
GetPlayerName().c_str(), GetAccountId(), logItem->GetNameForLocaleIdx(sWorld->GetDefaultDbcLocale()), logItem->GetEntry(), totalCount);
GetPlayerName().c_str(), GetAccountId(), logItem->GetNameForLocaleIdx(sWorld->GetDefaultDbcLocale()).c_str(), logItem->GetEntry(), totalCount);
}
CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();

View File

@@ -208,7 +208,7 @@ char const* Warden::ApplyPenalty(WardenCheck const* check)
std::string banReason = "Warden Anticheat Violation";
// Check can be NULL, for example if the client sent a wrong signature in the warden packet (CHECKSUM FAIL)
if (check)
banReason += Trinity::StringFormat(": %s (CheckId: %u", check->Comment, uint32(check->CheckId));
banReason += Trinity::StringFormat(": %s (CheckId: %u", check->Comment.c_str(), uint32(check->CheckId));
sWorld->BanAccount(BAN_ACCOUNT, accountName, sWorld->getIntConfig(CONFIG_WARDEN_CLIENT_BAN_DURATION), banReason, "Server");

View File

@@ -111,7 +111,7 @@ void WardenCheckMgr::LoadWardenChecks()
continue;
}
std::string str = fmt::sprintf("%04u", id);
std::string str = Trinity::StringFormat("%04u", id);
ASSERT(str.size() == 4);
std::copy(str.begin(), str.end(), wardenCheck.IdStr.begin());
}

View File

@@ -153,7 +153,7 @@ public:
}
// new suggestion, or no token specified, output TOTP parameters
handler->PSendSysMessage(LANG_2FA_SECRET_SUGGESTION, Trinity::Encoding::Base32::Encode(pair.first->second));
handler->PSendSysMessage(LANG_2FA_SECRET_SUGGESTION, Trinity::Encoding::Base32::Encode(pair.first->second).c_str());
handler->SetSentErrorMessage(true);
return false;
}
@@ -259,7 +259,7 @@ public:
switch (sAccountMgr->CreateAccount(accountName, password, email.value_or("")))
{
case AccountOpResult::AOR_OK:
handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName);
handler->PSendSysMessage(LANG_ACCOUNT_CREATED, accountName.c_str());
if (handler->GetSession())
{
TC_LOG_INFO("entities.player.character", "Account: %d (IP: %s) Character:[%s] %s) created Account %s (Email: '%s')",
@@ -281,11 +281,11 @@ public:
handler->SetSentErrorMessage(true);
return false;
case AccountOpResult::AOR_DB_INTERNAL_ERROR:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR, accountName);
handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED_SQL_ERROR, accountName.c_str());
handler->SetSentErrorMessage(true);
return false;
default:
handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED, accountName);
handler->PSendSysMessage(LANG_ACCOUNT_NOT_CREATED, accountName.c_str());
handler->SetSentErrorMessage(true);
return false;
}

View File

@@ -62,7 +62,7 @@ public:
{
if (sArenaTeamMgr->GetArenaTeamByName(name))
{
handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_EXISTS, name);
handler->PSendSysMessage(LANG_ARENA_ERROR_NAME_EXISTS, name.c_str());
handler->SetSentErrorMessage(true);
return false;
}

View File

@@ -909,7 +909,7 @@ public:
return false;
}
handler->PSendSysMessage("Threat info for %s (%s):", target->GetName(), target->GetGUID().ToString().c_str());
handler->PSendSysMessage("Threat info for %s (%s):", target->GetName().c_str(), target->GetGUID().ToString().c_str());
ThreatManager const& mgr = target->GetThreatManager();
@@ -1468,7 +1468,7 @@ public:
ASSERT(groupData); // checked by objectmgr on load
if (explain)
{
handler->PSendSysMessage(" |-- '%s' (%u)", groupData->name, pair.first);
handler->PSendSysMessage(" |-- '%s' (%u)", groupData->name.c_str(), pair.first);
bool isBlocked = false, isSpawned = false;
for (auto const& tuple : pair.second)
{
@@ -1481,29 +1481,29 @@ public:
{
isSpawned = true;
if (isBlocked)
handler->PSendSysMessage(" | |-- '%s' would be allowed to spawn by boss state %u being %s, but this is overruled", groupData->name, bossStateId, InstanceScript::GetBossStateName(actualState));
handler->PSendSysMessage(" | |-- '%s' would be allowed to spawn by boss state %u being %s, but this is overruled", groupData->name.c_str(), bossStateId, InstanceScript::GetBossStateName(actualState));
else
handler->PSendSysMessage(" | |-- '%s' is allowed to spawn because boss state %u is %s.", groupData->name, bossStateId, InstanceScript::GetBossStateName(bossStateId));
handler->PSendSysMessage(" | |-- '%s' is allowed to spawn because boss state %u is %s.", groupData->name.c_str(), bossStateId, InstanceScript::GetBossStateName(bossStateId));
}
else
{
isBlocked = true;
handler->PSendSysMessage(" | |-- '%s' is blocked from spawning because boss state %u is %s.", groupData->name, bossStateId, InstanceScript::GetBossStateName(bossStateId));
handler->PSendSysMessage(" | |-- '%s' is blocked from spawning because boss state %u is %s.", groupData->name.c_str(), bossStateId, InstanceScript::GetBossStateName(bossStateId));
}
}
else
handler->PSendSysMessage(" | |-- '%s' could've been %s if boss state %u matched mask 0x%02x; but it is %s -> 0x%02x, which does not match.",
groupData->name, isSpawn ? "allowed to spawn" : "blocked from spawning", bossStateId, std::get<2>(tuple), InstanceScript::GetBossStateName(actualState), (1 << actualState));
groupData->name.c_str(), isSpawn ? "allowed to spawn" : "blocked from spawning", bossStateId, std::get<2>(tuple), InstanceScript::GetBossStateName(actualState), (1 << actualState));
}
if (isBlocked)
handler->PSendSysMessage(" | |=> '%s' is not active due to a blocking rule being matched", groupData->name);
handler->PSendSysMessage(" | |=> '%s' is not active due to a blocking rule being matched", groupData->name.c_str());
else if (isSpawned)
handler->PSendSysMessage(" | |=> '%s' is active due to a spawn rule being matched", groupData->name);
handler->PSendSysMessage(" | |=> '%s' is active due to a spawn rule being matched", groupData->name.c_str());
else
handler->PSendSysMessage(" | |=> '%s' is not active due to none of its rules being matched", groupData->name);
handler->PSendSysMessage(" | |=> '%s' is not active due to none of its rules being matched", groupData->name.c_str());
}
else
handler->PSendSysMessage(" - '%s' (%u) is %sactive", groupData->name, pair.first, map->IsSpawnGroupActive(pair.first) ? "" : "not ");
handler->PSendSysMessage(" - '%s' (%u) is %sactive", groupData->name.c_str(), pair.first, map->IsSpawnGroupActive(pair.first) ? "" : "not ");
}
return true;
}

View File

@@ -321,12 +321,12 @@ public:
if (GameObject::DeleteFromDB(spawnId))
{
handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, std::to_string(spawnId));
handler->PSendSysMessage(LANG_COMMAND_DELOBJMESSAGE, std::to_string(spawnId).c_str());
return true;
}
else
{
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(spawnId));
handler->PSendSysMessage(LANG_COMMAND_OBJNOTFOUND, std::to_string(spawnId).c_str());
handler->SetSentErrorMessage(true);
return false;
}
@@ -560,7 +560,7 @@ public:
{
float yaw, pitch, roll;
spawnData->rotation.toEulerAnglesZYX(yaw, pitch, roll);
handler->PSendSysMessage(LANG_SPAWNINFO_SPAWNID_LOCATION, std::to_string(spawnData->spawnId), spawnData->spawnPoint.GetPositionX(), spawnData->spawnPoint.GetPositionY(), spawnData->spawnPoint.GetPositionZ());
handler->PSendSysMessage(LANG_SPAWNINFO_SPAWNID_LOCATION, std::to_string(spawnData->spawnId).c_str(), spawnData->spawnPoint.GetPositionX(), spawnData->spawnPoint.GetPositionY(), spawnData->spawnPoint.GetPositionZ());
handler->PSendSysMessage(LANG_SPAWNINFO_ROTATION, yaw, pitch, roll);
}

View File

@@ -336,7 +336,7 @@ public:
}
else
{
handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, std::to_string(spawnId));
handler->PSendSysMessage(LANG_COMMAND_CREATGUIDNOTFOUND, std::to_string(spawnId).c_str());
handler->SetSentErrorMessage(true);
return false;
}
@@ -1190,7 +1190,7 @@ public:
if (!pair.second)
continue;
Player const* player = ObjectAccessor::FindConnectedPlayer(pair.first);
handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_SUBLABEL, player ? player->GetName() : Trinity::StringFormat("Offline player (GUID %s)", pair.first.ToString()).c_str(), pair.second->size());
handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_SUBLABEL, player ? player->GetName().c_str() : Trinity::StringFormat("Offline player (GUID %s)", pair.first.ToString().c_str()).c_str(), pair.second->size());
for (auto it = pair.second->cbegin(); it != pair.second->cend(); ++it)
{
@@ -1213,12 +1213,12 @@ public:
Loot const& loot = creatureTarget->loot;
if (!creatureTarget->isDead() || loot.empty())
{
handler->PSendSysMessage(LANG_COMMAND_NOT_DEAD_OR_NO_LOOT, creatureTarget->GetName());
handler->PSendSysMessage(LANG_COMMAND_NOT_DEAD_OR_NO_LOOT, creatureTarget->GetName().c_str());
handler->SetSentErrorMessage(true);
return false;
}
handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_HEADER, creatureTarget->GetName(), creatureTarget->GetEntry());
handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_HEADER, creatureTarget->GetName().c_str(), creatureTarget->GetEntry());
handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_MONEY, loot.gold / GOLD, (loot.gold%GOLD) / SILVER, loot.gold%SILVER);
if (!all)

View File

@@ -21,6 +21,7 @@
#include "DB2Meta.h"
#include "Errors.h"
#include "Log.h"
#include <cstring>
DB2LoadInfo::DB2LoadInfo(DB2FieldMeta const* fields, std::size_t fieldCount, DB2Meta const* meta, HotfixDatabaseStatements statement)
: DB2FileLoadInfo(fields, fieldCount, meta), Statement(statement)

View File

@@ -22,6 +22,7 @@
#include "Util.h"
#include <utf8.h>
#include <sstream>
#include <cmath>
#include <ctime>
ByteBuffer::ByteBuffer(MessageBuffer&& buffer) : _rpos(0), _wpos(0), _bitpos(InitialBitPos), _curbitval(0), _storage(buffer.Move())

View File

@@ -26,6 +26,7 @@
#include "vmapexport.h"
#include "wdtfile.h"
#include "wmo.h"
#include <algorithm>
#include <CascLib.h>
#include <boost/filesystem/operations.hpp>
#include <fstream>

View File

@@ -23,6 +23,7 @@
#include "vec3d.h"
#include "VMapDefinitions.h"
#include "wmo.h"
#include <algorithm>
#include <fstream>
#include <map>
#include <cstdio>