feat(Core/Misc): includes cleanup (#5953)

This commit is contained in:
Kargatum
2021-05-26 19:00:08 +07:00
committed by GitHub
parent 7d3129a737
commit 78e1719c80
46 changed files with 132 additions and 191 deletions

View File

@@ -6,6 +6,7 @@
#include "MMapFactory.h"
#include <set>
#include <cstring>
namespace MMAP
{

View File

@@ -13,6 +13,7 @@
#include "DetourExtended.h"
#include <unordered_map>
#include <shared_mutex>
#include <vector>
// memory management
inline void* dtCustomAlloc(size_t size, dtAllocHint /*hint*/)

View File

@@ -5,7 +5,6 @@
*/
#include "MapTree.h"
#include "Common.h"
#include "ModelInstance.h"
#include "VMapManager2.h"
#include "VMapDefinitions.h"
@@ -20,7 +19,6 @@ using G3D::Vector3;
namespace VMAP
{
class MapRayCallback
{
public:
@@ -144,7 +142,7 @@ namespace VMAP
{
float maxDist = (pos2 - pos1).magnitude();
// return false if distance is over max float, in case of cheater teleporting to the end of the universe
if (maxDist == std::numeric_limits<float>::max() || !myisfinite(maxDist))
if (maxDist == std::numeric_limits<float>::max() || !std::isfinite(maxDist))
return false;
// valid map coords should *never ever* produce float overflow, but this would produce NaNs too

View File

@@ -7,120 +7,36 @@
#ifndef AZEROTHCORE_COMMON_H
#define AZEROTHCORE_COMMON_H
// config.h needs to be included 1st
/// @todo this thingy looks like hack, but its not, need to
// make separate header however, because It makes mess here.
#ifdef HAVE_CONFIG_H
// Remove Some things that we will define
// This is in case including another config.h
// before trinity config.h
#ifdef PACKAGE
#undef PACKAGE
#endif //PACKAGE
#ifdef PACKAGE_BUGREPORT
#undef PACKAGE_BUGREPORT
#endif //PACKAGE_BUGREPORT
#ifdef PACKAGE_NAME
#undef PACKAGE_NAME
#endif //PACKAGE_NAME
#ifdef PACKAGE_STRING
#undef PACKAGE_STRING
#endif //PACKAGE_STRING
#ifdef PACKAGE_TARNAME
#undef PACKAGE_TARNAME
#endif //PACKAGE_TARNAME
#ifdef PACKAGE_VERSION
#undef PACKAGE_VERSION
#endif //PACKAGE_VERSION
#ifdef VERSION
#undef VERSION
#endif //VERSION
# include "Config.h"
#undef PACKAGE
#undef PACKAGE_BUGREPORT
#undef PACKAGE_NAME
#undef PACKAGE_STRING
#undef PACKAGE_TARNAME
#undef PACKAGE_VERSION
#undef VERSION
#endif //HAVE_CONFIG_H
#include "Define.h"
#include <cassert>
#include <cerrno>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#if AC_PLATFORM == AC_PLATFORM_WINDOWS
#define STRCASECMP stricmp
#else
#define STRCASECMP strcasecmp
#endif
#include <set>
#include <list>
#include <array>
#include <memory>
#include <string>
#include <map>
#include <queue>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <vector>
#include "Threading/LockedQueue.h"
#include "Threading/Threading.h"
#include <ace/Stack_Trace.h>
#include <utility>
#if AC_PLATFORM == AC_PLATFORM_WINDOWS
# include <ace/config-all.h>
// XP winver - needed to compile with standard leak check in MemoryLeaks.h
// uncomment later if needed
//#define _WIN32_WINNT 0x0501
# include <ws2tcpip.h>
//#undef WIN32_WINNT
#include <ws2tcpip.h>
#if AC_COMPILER == AC_COMPILER_INTEL
# if !defined(BOOST_ASIO_HAS_MOVE)
# define BOOST_ASIO_HAS_MOVE
# endif // !defined(BOOST_ASIO_HAS_MOVE)
# endif // if WARHEAD_COMPILER == WARHEAD_COMPILER_INTEL
#else
# include <sys/types.h>
# include <sys/ioctl.h>
# include <sys/socket.h>
# include <netinet/in.h>
# include <unistd.h>
# include <netdb.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <netdb.h>
#include <cstdlib>
#endif
#if AC_COMPILER == AC_COMPILER_MICROSOFT
#include <float.h>
#define I32FMT "%08I32X"
#define I64FMT "%016I64X"
#define atoll _atoi64
#define vsnprintf _vsnprintf
#define llabs _abs64
#else
#define stricmp strcasecmp
#define strnicmp strncasecmp
#define I32FMT "%08X"
#define I64FMT "%016llX"
#endif
using namespace std;
inline float finiteAlways(float f) { return isfinite(f) ? f : 0.0f; }
inline bool myisfinite(float f) { return isfinite(f) && !isnan(f); }
#define STRINGIZE(a) #a
#define MAX_NETCLIENT_PACKET_SIZE (32767 - 1) // Client hardcap: int16 with trailing zero space otherwise crash on memory free
@@ -155,21 +71,20 @@ enum LocaleConstant
LOCALE_zhTW = 5,
LOCALE_esES = 6,
LOCALE_esMX = 7,
LOCALE_ruRU = 8
LOCALE_ruRU = 8,
TOTAL_LOCALES
};
const uint8 TOTAL_LOCALES = 9;
#define DEFAULT_LOCALE LOCALE_enUS
#define MAX_LOCALES 8
#define MAX_ACCOUNT_TUTORIAL_VALUES 8
extern char const* localeNames[TOTAL_LOCALES];
AC_COMMON_API extern char const* localeNames[TOTAL_LOCALES];
LocaleConstant GetLocaleByName(const std::string& name);
void CleanStringForMysqlQuery(std::string& str);
typedef std::vector<std::string> StringVector;
AC_COMMON_API LocaleConstant GetLocaleByName(const std::string& name);
AC_COMMON_API void CleanStringForMysqlQuery(std::string& str);
// we always use stdlibc++ std::max/std::min, undefine some not C++ standard defines (Win API and some other platforms)
#ifdef max

View File

@@ -7,17 +7,10 @@
#ifndef ACORE_DEFINE_H
#define ACORE_DEFINE_H
#include "CompilerDefs.h"
#include <cstddef>
#include <cstdint>
#include <cinttypes>
#include <climits>
#include <cstring>
#include <sys/types.h>
#include "CompilerDefs.h"
#if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__)
#define OS_WIN
#endif
#define ACORE_LITTLEENDIAN 0
#define ACORE_BIGENDIAN 1

View File

@@ -11,11 +11,10 @@
#ifndef _ACORE_GEOMETRY_H
#define _ACORE_GEOMETRY_H
#include <cmath>
#include "Define.h"
#include <iostream>
#include <cstdlib>
using namespace std;
#include <math.h>
[[nodiscard]] inline float getAngle(float startX, float startY, float destX, float destY)
{

View File

@@ -8,6 +8,7 @@
#include "Common.h"
#include <string_view>
#include <vector>
namespace acore
{

View File

@@ -6,14 +6,18 @@
#include "Util.h"
#include "Common.h"
#include "utf8.h"
#include "Log.h"
#include "Errors.h"
#include "TypeList.h"
#include "Errors.h" // for ASSERT
#include <array>
#include <cwchar>
#include "Containers.h"
// #include "IpAddress.h"
#include "StringConvert.h"
#include "StringFormat.h"
#include <utf8.h>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <string>
#include <cctype>
#include <cstdarg>
#include <ctime>
#include <ace/Default_Constants.h>
Tokenizer::Tokenizer(const std::string& src, const char sep, uint32 vectorReserve)

View File

@@ -4,23 +4,25 @@
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
*/
#include "AuthSocket.h"
#include "AES.h"
#include "Common.h"
#include "CryptoGenerics.h"
#include "CryptoRandom.h"
#include "CryptoHash.h"
#include "DatabaseEnv.h"
#include "AuthCodes.h"
#include "ByteBuffer.h"
#include "Common.h"
#include "Config.h"
#include "CryptoGenerics.h"
#include "CryptoHash.h"
#include "CryptoRandom.h"
#include "DatabaseEnv.h"
#include "Log.h"
#include "RealmList.h"
#include "AuthSocket.h"
#include "AuthCodes.h"
#include "SecretMgr.h"
#include "TOTP.h"
#include "Threading.h"
#include <algorithm>
#include <openssl/crypto.h>
#include <openssl/md5.h>
#include <sstream>
#define ChunkSize 2048

View File

@@ -12,9 +12,10 @@
#include "Optional.h"
#include "RealmSocket.h"
#include "SRP6.h"
#include <mutex>
class ACE_INET_Addr;
class Fields;
class Field;
struct Realm;
enum eStatus

View File

@@ -10,6 +10,7 @@
#include "Duration.h"
#include <mysqld_error.h>
#include <errmsg.h>
#include <thread>
template <class T>
DatabaseLoader& DatabaseLoader::AddDatabase(DatabaseWorkerPool<T>& pool, std::string const& name)

View File

@@ -7,6 +7,7 @@
#include "PreparedStatement.h"
#include "MySQLConnection.h"
#include "Log.h"
#include <sstream>
PreparedStatement::PreparedStatement(uint32 index) :
m_stmt(nullptr),

View File

@@ -161,4 +161,5 @@ protected:
bool m_has_result;
PreparedQueryResultFuture m_result;
};
#endif

View File

@@ -7,9 +7,9 @@
#ifndef _TRANSACTION_H
#define _TRANSACTION_H
#include <utility>
#include "SQLOperation.h"
#include <list>
#include <utility>
//- Forward declare (don't include header to prevent circular includes)
class PreparedStatement;

View File

@@ -98,9 +98,9 @@ namespace FactorySelector
/* if (mv_factory == nullptr)
{
int best_val = -1;
StringVector l;
std::vector<std::string> l;
mv_registry.GetRegisteredItems(l);
for (StringVector::iterator iter = l.begin(); iter != l.end(); ++iter)
for (std::vector<std::string>::iterator iter = l.begin(); iter != l.end(); ++iter)
{
const MovementGeneratorCreator *factory = mv_registry.GetRegistryItem((*iter).c_str());
const SelectableMovement *p = dynamic_cast<const SelectableMovement *>(factory);

View File

@@ -233,8 +233,8 @@ typedef std::map<uint32, AchievementReward> AchievementRewards;
struct AchievementRewardLocale
{
StringVector Subject;
StringVector Text;
std::vector<std::string> Subject;
std::vector<std::string> Text;
};
typedef std::map<uint32, AchievementRewardLocale> AchievementRewardLocales;

View File

@@ -8,6 +8,7 @@
#define AZEROTHCORE_CHATLINK_H
#include "SharedDefines.h"
#include <cstring>
#include <list>
#include <sstream>

View File

@@ -11,6 +11,7 @@
#include "DBCStore.h"
#include "DBCStructure.h"
#include <list>
#include <unordered_map>
typedef std::list<uint32> SimpleFactionsList;
typedef std::vector<FlyByCamera> FlyByCameraCollection;

View File

@@ -12,8 +12,9 @@
#include "ObjectGuid.h"
#include "SharedDefines.h"
#include "WorldPacket.h"
#include <array>
#include <map>
#include <sstream>
namespace lfg
{

View File

@@ -224,19 +224,19 @@ typedef std::unordered_map<uint16, CreatureBaseStats> CreatureBaseStatsContainer
struct CreatureLocale
{
StringVector Name;
StringVector Title;
std::vector<std::string> Name;
std::vector<std::string> Title;
};
struct GossipMenuItemsLocale
{
StringVector OptionText;
StringVector BoxText;
std::vector<std::string> OptionText;
std::vector<std::string> BoxText;
};
struct PointOfInterestLocale
{
StringVector Name;
std::vector<std::string> Name;
};
struct EquipmentInfo

View File

@@ -662,8 +662,8 @@ union GameObjectValue
struct GameObjectLocale
{
StringVector Name;
StringVector CastBarCaption;
std::vector<std::string> Name;
std::vector<std::string> CastBarCaption;
};
// `gameobject_addon` table

View File

@@ -824,8 +824,8 @@ typedef std::unordered_map<uint32, ItemTemplate> ItemTemplateContainer;
struct ItemLocale
{
StringVector Name;
StringVector Description;
std::vector<std::string> Name;
std::vector<std::string> Description;
};
struct ItemSetNameEntry
@@ -836,7 +836,7 @@ struct ItemSetNameEntry
struct ItemSetNameLocale
{
StringVector Name;
std::vector<std::string> Name;
};
#endif

View File

@@ -7,9 +7,9 @@
#ifndef _OBJECT_POS_SELECTOR_H
#define _OBJECT_POS_SELECTOR_H
#include<Common.h>
#include<map>
#include "Define.h"
#include <math.h>
#include <map>
enum UsedPosType { USED_POS_PLUS, USED_POS_MINUS };

View File

@@ -27001,6 +27001,8 @@ void Player::_SaveCharacter(bool create, SQLTransaction& trans)
PreparedStatement* stmt = nullptr;
uint8 index = 0;
auto finiteAlways = [](float f) { return std::isfinite(f) ? f : 0.0f; };
if (create)
{
//! Insert query

View File

@@ -3924,9 +3924,6 @@ void Unit::HandleSafeUnitPointersOnDelete(Unit* thisUnit)
for (std::set<SafeUnitPointer*>::iterator itr = thisUnit->SafeUnitPointerSet.begin(); itr != thisUnit->SafeUnitPointerSet.end(); ++itr)
(*itr)->UnitDeleted();
thisUnit->SafeUnitPointerSet.clear();
ACE_Stack_Trace trace(0, 50);
LOG_INFO("misc", "Unit::HandleSafeUnitPointersOnDelete CALL STACK (1):\n%s\n", trace.c_str());
}
bool Unit::IsInWater(bool allowAbove) const
@@ -17604,8 +17601,6 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const* au
if (!charmer->IsInWorld() || charmer->IsDuringRemoveFromWorld())
{
ACE_Stack_Trace trace(0, 50);
LOG_INFO("misc", "Unit::SetCharmedBy CALL STACK (1):\n%s\n", trace.c_str());
return false;
}

View File

@@ -10,6 +10,7 @@
#include "Common.h"
#include "ObjectGuid.h"
#include "SharedDefines.h"
#include <map>
#define max_ge_check_delay DAY // 1 day in seconds

View File

@@ -361,7 +361,7 @@ ObjectMgr* ObjectMgr::instance()
return &instance;
}
void ObjectMgr::AddLocaleString(std::string&& s, LocaleConstant locale, StringVector& data)
void ObjectMgr::AddLocaleString(std::string&& s, LocaleConstant locale, std::vector<std::string>& data)
{
if (!s.empty())
{
@@ -6893,8 +6893,8 @@ void ObjectMgr::LoadPetNumber()
std::string ObjectMgr::GeneratePetName(uint32 entry)
{
StringVector& list0 = _petHalfName0[entry];
StringVector& list1 = _petHalfName1[entry];
std::vector<std::string>& list0 = _petHalfName0[entry];
std::vector<std::string>& list1 = _petHalfName1[entry];
if (list0.empty() || list1.empty())
{

View File

@@ -429,8 +429,8 @@ struct BroadcastText
uint32 Id{0};
uint32 Language{0};
StringVector MaleText;
StringVector FemaleText;
std::vector<std::string> MaleText;
std::vector<std::string> FemaleText;
uint32 EmoteId0{0};
uint32 EmoteId1{0};
uint32 EmoteId2{0};
@@ -483,7 +483,7 @@ typedef std::unordered_map<uint32/*(mapid, spawnMode) pair*/, CellObjectGuidsMap
struct AcoreString
{
StringVector Content;
std::vector<std::string> Content;
};
typedef std::map<ObjectGuid, ObjectGuid> LinkedRespawnContainer;
@@ -1326,8 +1326,8 @@ public:
return _gossipMenuItemsStore.equal_range(uiMenuId);
}
static void AddLocaleString(std::string&& s, LocaleConstant locale, StringVector& data);
static inline void GetLocaleString(const StringVector& data, int loc_idx, std::string& value)
static void AddLocaleString(std::string&& s, LocaleConstant locale, std::vector<std::string>& data);
static inline void GetLocaleString(const std::vector<std::string>& data, int loc_idx, std::string& value)
{
if (data.size() > size_t(loc_idx) && !data[loc_idx].empty())
value = data[loc_idx];
@@ -1451,7 +1451,7 @@ private:
typedef std::map<uint32, int32> FishingBaseSkillContainer; // [areaId][base skill level]
FishingBaseSkillContainer _fishingBaseForAreaStore;
typedef std::map<uint32, StringVector> HalfNameContainer;
typedef std::map<uint32, std::vector<std::string>> HalfNameContainer;
HalfNameContainer _petHalfName0;
HalfNameContainer _petHalfName1;

View File

@@ -204,7 +204,7 @@ namespace acore
inline bool IsValidMapCoord(float c)
{
return isfinite(c) && (std::fabs(c) <= MAP_HALFSIZE - 0.5f);
return std::isfinite(c) && (std::fabs(c) <= MAP_HALFSIZE - 0.5f);
}
inline bool IsValidMapCoord(float x, float y)
@@ -219,7 +219,7 @@ namespace acore
inline bool IsValidMapCoord(float x, float y, float z, float o)
{
return IsValidMapCoord(x, y, z) && isfinite(o);
return IsValidMapCoord(x, y, z) && std::isfinite(o);
}
}
#endif

View File

@@ -7,6 +7,9 @@
#ifndef __NPCHANDLER_H
#define __NPCHANDLER_H
#include "Define.h"
#include <vector>
struct QEmote
{
uint32 _Emote;
@@ -34,14 +37,14 @@ struct GossipText
struct PageTextLocale
{
StringVector Text;
std::vector<std::string> Text;
};
struct NpcTextLocale
{
NpcTextLocale() { Text_0.resize(8); Text_1.resize(8); }
std::vector<StringVector> Text_0;
std::vector<StringVector> Text_1;
std::vector<std::vector<std::string>> Text_0;
std::vector<std::vector<std::string>> Text_1;
};
#endif

View File

@@ -15,6 +15,7 @@
#include "SharedDefines.h"
#include <list>
#include <map>
#include <unordered_map>
#include <vector>
enum RollType

View File

@@ -5,6 +5,7 @@
#include "EventProcessor.h"
#include "WorldPacket.h"
#include "ObjectGuid.h"
#include <mutex>
class AuctionListOwnerItemsDelayEvent : public BasicEvent
{

View File

@@ -2,6 +2,7 @@
#define __AVGDIFFTRACKER_H
#include "Common.h"
#include <cstring>
#define AVG_DIFF_COUNT 500

View File

@@ -3,6 +3,8 @@
#include "Common.h"
#include "SharedDefines.h"
#include <map>
#include <unordered_map>
struct GraveyardStruct
{

View File

@@ -2,6 +2,8 @@
#define __SAVINGSYSTEM_H
#include "Common.h"
#include <list>
#include <mutex>
// to evenly distribute saving players to db

View File

@@ -165,14 +165,14 @@ struct QuestLocale
{
QuestLocale() { ObjectiveText.resize(QUEST_OBJECTIVES_COUNT); }
StringVector Title;
StringVector Details;
StringVector Objectives;
StringVector OfferRewardText;
StringVector RequestItemsText;
StringVector AreaDescription;
StringVector CompletedText;
std::vector< StringVector > ObjectiveText;
std::vector<std::string> Title;
std::vector<std::string> Details;
std::vector<std::string> Objectives;
std::vector<std::string> OfferRewardText;
std::vector<std::string> RequestItemsText;
std::vector<std::string> AreaDescription;
std::vector<std::string> CompletedText;
std::vector< std::vector<std::string> > ObjectiveText;
};
struct QuestRequestItemsLocale

View File

@@ -40,7 +40,7 @@ struct CreatureTextEntry
struct CreatureTextLocale
{
StringVector Text;
std::vector<std::string> Text;
};
struct CreatureTextId

View File

@@ -14,6 +14,7 @@
#include "Callback.h"
#include "Common.h"
#include "IWorld.h"
#include "LockedQueue.h"
#include "ObjectGuid.h"
#include "QueryResult.h"
#include "SharedDefines.h"

View File

@@ -7,6 +7,7 @@
#include "blackrock_depths.h"
#include "ScriptedCreature.h"
#include "ScriptMgr.h"
#include <vector>
enum Spells
{
@@ -38,7 +39,7 @@ const Position SummonPositions[7] =
{1012.252747f, -206.696487f, -61.980618f, 3.617599f},
};
vector<int> gobjectDwarfRunesEntry { 170578, 170579, 170580, 170581, 170582, 170583, 170584 };
std::vector<int> gobjectDwarfRunesEntry { 170578, 170579, 170580, 170581, 170582, 170583, 170584 };
class boss_ambassador_flamelash : public CreatureScript
{
@@ -60,7 +61,7 @@ public:
SummonList summons;
// This will allow to find a valid position to spawn them
vector<int> validPosition;
std::vector<int> validPosition;
bool foundValidPosition = false;
void JustSummoned(Creature* cr) override { summons.Summon(cr); }

View File

@@ -131,7 +131,7 @@ public:
}
}
counter = 0;
list<Unit*, std::allocator<Unit*>>::iterator itr;
std::list<Unit*, std::allocator<Unit*>>::iterator itr;
for (itr = meleeRangeTargets.begin(); itr != meleeRangeTargets.end(); ++itr, ++counter)
{
// if there is only one target available

View File

@@ -12,6 +12,7 @@
#include "Errors.h"
#include <G3D/AABox.h>
#include <G3D/Vector3.h>
#include <cstring>
#include <vector>
// Structures for M4 file. Source: https://wowdev.wiki

View File

@@ -7,11 +7,12 @@
#ifndef ACORE_DBCSTRUCTURE_H
#define ACORE_DBCSTRUCTURE_H
#include "Common.h"
#include "DBCEnums.h"
#include "Define.h"
#include "DBCEnums.h"
#include "SharedDefines.h"
#include "Util.h"
#include <set>
#include <map>
// Structures using to access raw DBC data and required packing to portability

View File

@@ -11,6 +11,8 @@
#ifndef __CLIRUNNABLE_H
#define __CLIRUNNABLE_H
#include "Threading.h"
/// Command Line Interface handling thread
class CliRunnable : public acore::Runnable
{

View File

@@ -12,6 +12,7 @@
#define _ACORE_RARUNNABLE_H_
#include "Common.h"
#include "Threading.h"
#include <ace/Reactor.h>
class RARunnable : public acore::Runnable

View File

@@ -11,6 +11,8 @@
#ifndef __WORLDRUNNABLE_H
#define __WORLDRUNNABLE_H
#include "Threading.h"
/// Heartbeat thread for the World
class WorldRunnable : public acore::Runnable
{

View File

@@ -13,11 +13,14 @@
#ifndef _WIN32
#include <cstddef>
#include <cstring>
#include <dirent.h>
#else
#include <Windows.h>
#endif
#ifdef __linux__
#include <errno.h>
#ifndef _WIN32
#include <cerrno>
#endif
namespace MMAP