Merge branch 'master' into Playerbot

This commit is contained in:
Yunfan Li
2023-12-12 20:52:42 +08:00
1088 changed files with 35633 additions and 19812 deletions

View File

@@ -20,10 +20,10 @@
#include "MapDefines.h"
#include "MapTree.h"
#include "VMapDefinitions.h"
#include <boost/filesystem.hpp>
#include <iomanip>
#include <set>
#include <sstream>
#include <boost/filesystem.hpp>
using G3D::Vector3;
using G3D::AABox;

View File

@@ -16,6 +16,7 @@
*/
#include "OpenSSLCrypto.h"
#include "Errors.h"
#include <openssl/crypto.h> // NOTE: this import is NEEDED (even though some IDEs report it as unused)
#if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER < 0x1010000fL

View File

@@ -20,10 +20,10 @@
#include "Define.h"
#include <map>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include <memory>
/** ObjectRegistry holds all registry item of the same type
*/

View File

@@ -68,13 +68,13 @@ public:
bool SetLogLevel(std::string const& name, int32 level, bool isLogger = true);
template<typename... Args>
inline void outMessage(std::string const& filter, LogLevel const level, std::string_view fmt, Args&&... args)
inline void outMessage(std::string const& filter, LogLevel const level, Acore::FormatString<Args...> fmt, Args&&... args)
{
_outMessage(filter, level, Acore::StringFormatFmt(fmt, std::forward<Args>(args)...));
}
template<typename... Args>
void outCommand(uint32 account, std::string_view fmt, Args&&... args)
void outCommand(uint32 account, Acore::FormatString<Args...> fmt, Args&&... args)
{
if (!ShouldLog("commands.gm", LOG_LEVEL_INFO))
{

View File

@@ -15,8 +15,8 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "LogCommon.h"
#include "Define.h"
#include "LogCommon.h"
#include "SmartEnum.h"
#include <stdexcept>

View File

@@ -71,7 +71,7 @@ void Metric::LoadFromConfigs()
{
bool previousValue = _enabled;
_enabled = sConfigMgr->GetOption<bool>("Metric.Enable", false);
_updateInterval = sConfigMgr->GetOption<int32>("Metric.Interval", 10);
_updateInterval = sConfigMgr->GetOption<int32>("Metric.Interval", 1);
if (_updateInterval < 1)
{

View File

@@ -16,11 +16,11 @@
*/
#include "ProcessPriority.h"
#include "Log.h"
#ifdef _WIN32 // Windows
#include <Windows.h>
#elif defined(__linux__)
#include "Log.h"
#include <sched.h>
#include <sys/resource.h>
#define PROCESS_HIGH_PRIORITY -15 // [-20, 19], default is 0

View File

@@ -21,7 +21,6 @@
#include "Define.h"
#include "Duration.h"
#include "Random.h"
#include "advstd.h"
#include <map>
#include <type_traits>
@@ -90,7 +89,7 @@ class LambdaBasicEvent : public BasicEvent
};
template<typename T>
using is_lambda_event = std::enable_if_t<!std::is_base_of_v<BasicEvent, std::remove_pointer_t<advstd::remove_cvref_t<T>>>>;
using is_lambda_event = std::enable_if_t<!std::is_base_of_v<BasicEvent, std::remove_pointer_t<std::remove_cvref_t<T>>>>;
typedef std::multimap<uint64, BasicEvent*> EventList;

View File

@@ -17,7 +17,6 @@
#include "StringFormat.h"
#include "Define.h"
#include <locale>
template<class Str>
AC_COMMON_API Str Acore::String::Trim(const Str& s, const std::locale& loc /*= std::locale()*/)

View File

@@ -21,6 +21,7 @@
#include "Define.h"
#include <fmt/format.h>
#include <fmt/printf.h>
#include <locale>
namespace Acore
{
@@ -39,17 +40,20 @@ namespace Acore
}
}
template<typename... Args>
using FormatString = fmt::format_string<Args...>;
// Default string format function.
template<typename... Args>
inline std::string StringFormatFmt(std::string_view fmt, Args&&... args)
inline std::string StringFormatFmt(FormatString<Args...> fmt, Args&&... args)
{
try
{
return fmt::format(fmt, std::forward<Args>(args)...);
}
catch (const fmt::format_error& formatError)
catch (std::exception const& e)
{
return fmt::format("An error occurred formatting string \"{}\": {}", fmt, formatError.what());
return fmt::format("Wrong format occurred ({}). Fmt string: '{}'", e.what(), fmt.get());
}
}
@@ -76,4 +80,9 @@ namespace Acore::String
AC_COMMON_API std::string AddSuffixIfNotExists(std::string str, const char suffix);
}
// Add support enum for fmt
//template <typename T, std::enable_if_t<std::is_enum_v<T>, int> = 0>
template <typename T, FMT_ENABLE_IF(std::is_enum_v<T>)>
auto format_as(T f) { return fmt::underlying(f); }
#endif

View File

@@ -18,8 +18,6 @@
#ifndef _TYPES_H_
#define _TYPES_H_
#include "advstd.h"
namespace Acore
{
// end "iterator" tag for find_type_if
@@ -35,7 +33,7 @@ namespace Acore
};
template<template<typename...> typename Check, typename T1, typename... Ts>
struct find_type_if<Check, T1, Ts...> : std::conditional_t<Check<T1>::value, advstd::type_identity<T1>, find_type_if<Check, Ts...>>
struct find_type_if<Check, T1, Ts...> : std::conditional_t<Check<T1>::value, std::type_identity<T1>, find_type_if<Check, Ts...>>
{
};

View File

@@ -24,22 +24,6 @@
// this namespace holds implementations of upcoming stdlib features that our c++ version doesn't have yet
namespace advstd
{
// This workaround for std::remove_cvref_t, std::type_identify is needed for GCC 8...
/// @todo: remove when we drop GCC 8 support. https://en.cppreference.com/w/cpp/compiler_support/20
// C++20 advstd::remove_cvref_t
template <class T>
using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
// C++20 std::type_identity
template <typename T>
struct type_identity
{
using type = T;
};
// C++20 std::type_identity_t
template <typename T>
using type_identity_t = typename type_identity<T>::type;
}
#endif // _ADV_STD_H_