Core/Misc: Replace Trinity::make_unique with std (#24869)

(cherry picked from commit bab5fd87a3)
This commit is contained in:
Peter Keresztes Schmidt
2020-06-23 08:54:12 +02:00
parent dc41aae042
commit b210bb3713
15 changed files with 35 additions and 40 deletions

View File

@@ -121,9 +121,4 @@ TC_COMMON_API LocaleConstant GetLocaleByName(std::string const& name);
#define MAX_QUERY_LEN 32*1024
namespace Trinity
{
using std::make_unique;
}
#endif

View File

@@ -152,7 +152,7 @@ void Log::CreateLoggerFromConfig(std::string const& appenderName)
if (level < lowestLogLevel)
lowestLogLevel = level;
logger = Trinity::make_unique<Logger>(name, level);
logger = std::make_unique<Logger>(name, level);
//fprintf(stdout, "Log::CreateLoggerFromConfig: Created Logger %s, Level %u\n", name.c_str(), level);
std::istringstream ss(*iter);
@@ -215,12 +215,12 @@ void Log::RegisterAppender(uint8 index, AppenderCreatorFn appenderCreateFn)
void Log::outMessage(std::string const& filter, LogLevel level, std::string&& message)
{
write(Trinity::make_unique<LogMessage>(level, filter, std::move(message)));
write(std::make_unique<LogMessage>(level, filter, std::move(message)));
}
void Log::outCommand(std::string&& message, std::string&& param1)
{
write(Trinity::make_unique<LogMessage>(LOG_LEVEL_INFO, "commands.gm", std::move(message), std::move(param1)));
write(std::make_unique<LogMessage>(LOG_LEVEL_INFO, "commands.gm", std::move(message), std::move(param1)));
}
void Log::write(std::unique_ptr<LogMessage>&& msg) const

View File

@@ -27,10 +27,10 @@
void Metric::Initialize(std::string const& realmName, Trinity::Asio::IoContext& ioContext, std::function<void()> overallStatusLogger)
{
_dataStream = Trinity::make_unique<boost::asio::ip::tcp::iostream>();
_dataStream = std::make_unique<boost::asio::ip::tcp::iostream>();
_realmName = FormatInfluxDBTagValue(realmName);
_batchTimer = Trinity::make_unique<Trinity::Asio::DeadlineTimer>(ioContext);
_overallStatusTimer = Trinity::make_unique<Trinity::Asio::DeadlineTimer>(ioContext);
_batchTimer = std::make_unique<Trinity::Asio::DeadlineTimer>(ioContext);
_overallStatusTimer = std::make_unique<Trinity::Asio::DeadlineTimer>(ioContext);
_overallStatusLogger = overallStatusLogger;
LoadFromConfigs();
}

View File

@@ -68,7 +68,7 @@ template <class T>
void DatabaseWorkerPool<T>::SetConnectionInfo(std::string const& infoString,
uint8 const asyncThreads, uint8 const synchThreads)
{
_connectionInfo = Trinity::make_unique<MySQLConnectionInfo>(infoString);
_connectionInfo = std::make_unique<MySQLConnectionInfo>(infoString);
_async_threads = asyncThreads;
_synch_threads = synchThreads;
@@ -365,9 +365,9 @@ uint32 DatabaseWorkerPool<T>::OpenConnections(InternalIndex type, uint8 numConne
switch (type)
{
case IDX_ASYNC:
return Trinity::make_unique<T>(_queue.get(), *_connectionInfo);
return std::make_unique<T>(_queue.get(), *_connectionInfo);
case IDX_SYNCH:
return Trinity::make_unique<T>(*_connectionInfo);
return std::make_unique<T>(*_connectionInfo);
default:
ABORT();
}

View File

@@ -65,7 +65,7 @@ m_Mysql(nullptr),
m_connectionInfo(connInfo),
m_connectionFlags(CONNECTION_ASYNC)
{
m_worker = Trinity::make_unique<DatabaseWorker>(m_queue, this);
m_worker = std::make_unique<DatabaseWorker>(m_queue, this);
}
MySQLConnection::~MySQLConnection()
@@ -509,7 +509,7 @@ void MySQLConnection::PrepareStatement(uint32 index, std::string const& sql, Con
m_prepareError = true;
}
else
m_stmts[index] = Trinity::make_unique<MySQLPreparedStatement>(reinterpret_cast<MySQLStmt*>(stmt), sql);
m_stmts[index] = std::make_unique<MySQLPreparedStatement>(reinterpret_cast<MySQLStmt*>(stmt), sql);
}
}

View File

@@ -41,7 +41,7 @@ UpdateFetcher::UpdateFetcher(Path const& sourceDirectory,
std::function<void(std::string const&)> const& apply,
std::function<void(Path const& path)> const& applyFile,
std::function<QueryResult(std::string const&)> const& retrieve) :
_sourceDirectory(Trinity::make_unique<Path>(sourceDirectory)), _apply(apply), _applyFile(applyFile),
_sourceDirectory(std::make_unique<Path>(sourceDirectory)), _apply(apply), _applyFile(applyFile),
_retrieve(retrieve)
{
}

View File

@@ -2676,7 +2676,7 @@ private:
GameObjectModel* GameObject::CreateModel()
{
return GameObjectModel::Create(Trinity::make_unique<GameObjectModelOwnerImpl>(this), sWorld->GetDataPath());
return GameObjectModel::Create(std::make_unique<GameObjectModelOwnerImpl>(this), sWorld->GetDataPath());
}
std::string GameObject::GetDebugInfo() const

View File

@@ -3713,7 +3713,7 @@ void ObjectMgr::LoadPetLevelInfo()
auto& pInfoMapEntry = _petInfoStore[creature_id];
if (!pInfoMapEntry)
pInfoMapEntry = Trinity::make_unique<PetLevelInfo[]>(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
pInfoMapEntry = std::make_unique<PetLevelInfo[]>(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
// data for level 1 stored in [0] array element, ...
PetLevelInfo* pLevelInfo = &pInfoMapEntry[current_level - 1];
@@ -3871,7 +3871,7 @@ void ObjectMgr::LoadPlayerInfo()
continue;
}
std::unique_ptr<PlayerInfo> info = Trinity::make_unique<PlayerInfo>();
std::unique_ptr<PlayerInfo> info = std::make_unique<PlayerInfo>();
info->mapId = mapId;
info->areaId = areaId;
info->positionX = positionX;
@@ -4235,8 +4235,8 @@ void ObjectMgr::LoadPlayerInfo()
auto& info = _playerClassInfo[current_class];
if (!info)
{
info = Trinity::make_unique<PlayerClassInfo>();
info->levelInfo = Trinity::make_unique<PlayerClassLevelInfo[]>(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
info = std::make_unique<PlayerClassInfo>();
info->levelInfo = std::make_unique<PlayerClassLevelInfo[]>(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
}
PlayerClassLevelInfo& levelInfo = info->levelInfo[current_level - 1];
@@ -4327,7 +4327,7 @@ void ObjectMgr::LoadPlayerInfo()
if (auto& info = _playerInfo[current_race][current_class])
{
if (!info->levelInfo)
info->levelInfo = Trinity::make_unique<PlayerLevelInfo[]>(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
info->levelInfo = std::make_unique<PlayerLevelInfo[]>(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL));
PlayerLevelInfo& levelInfo = info->levelInfo[current_level - 1];
for (uint8 i = 0; i < MAX_STATS; ++i)
@@ -6091,7 +6091,7 @@ void ObjectMgr::LoadInstanceEncounters()
}
DungeonEncounterList& encounters = _dungeonEncounterStore[MAKE_PAIR32(dungeonEncounter->mapId, dungeonEncounter->difficulty)];
encounters.emplace_back(Trinity::make_unique<DungeonEncounter>(dungeonEncounter, EncounterCreditType(creditType), creditEntry, lastEncounterDungeon));
encounters.emplace_back(std::make_unique<DungeonEncounter>(dungeonEncounter, EncounterCreditType(creditType), creditEntry, lastEncounterDungeon));
++count;
} while (result->NextRow());
@@ -7169,7 +7169,7 @@ void ObjectMgr::LoadAccessRequirements()
uint32 requirement_ID = MAKE_PAIR32(mapid, difficulty);
auto& ar = _accessRequirementStore[requirement_ID];
ar = Trinity::make_unique<AccessRequirement>();
ar = std::make_unique<AccessRequirement>();
ar->levelMin = fields[2].GetUInt8();
ar->levelMax = fields[3].GetUInt8();

View File

@@ -4639,7 +4639,7 @@ Weather* Map::GetOrGenerateZoneDefaultWeather(uint32 zoneId)
ZoneDynamicInfo& info = _zoneDynamicInfo[zoneId];
if (!info.DefaultWeather)
{
info.DefaultWeather = Trinity::make_unique<Weather>(zoneId, weatherData);
info.DefaultWeather = std::make_unique<Weather>(zoneId, weatherData);
info.DefaultWeather->ReGenerate();
info.DefaultWeather->UpdateWeather();
}

View File

@@ -223,7 +223,7 @@ public:
void QueueForDelayedDelete(T&& any)
{
_delayed_delete_queue.push_back(
Trinity::make_unique<
std::make_unique<
DeleteableObject<typename std::decay<T>::type>
>(std::forward<T>(any))
);

View File

@@ -936,7 +936,7 @@ private:
}
// Create the source listener
auto listener = Trinity::make_unique<SourceUpdateListener>(
auto listener = std::make_unique<SourceUpdateListener>(
sScriptReloadMgr->GetSourceDirectory() / module_name,
module_name);

View File

@@ -5505,7 +5505,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint
float objSize = target->GetCombatReach();
float range = m_spellInfo->GetMaxRange(true, unitCaster, this) * 1.5f + objSize; // can't be overly strict
m_preGeneratedPath = Trinity::make_unique<PathGenerator>(unitCaster);
m_preGeneratedPath = std::make_unique<PathGenerator>(unitCaster);
m_preGeneratedPath->SetPathLengthLimit(range);
// first try with raycast, if it fails fall back to normal path
@@ -8090,7 +8090,7 @@ WorldObjectSpellTargetCheck::WorldObjectSpellTargetCheck(WorldObject* caster, Wo
_targetSelectionType(selectionType), _condSrcInfo(nullptr), _condList(condList)
{
if (condList)
_condSrcInfo = Trinity::make_unique<ConditionSourceInfo>(nullptr, caster);
_condSrcInfo = std::make_unique<ConditionSourceInfo>(nullptr, caster);
}
WorldObjectSpellTargetCheck::~WorldObjectSpellTargetCheck()

View File

@@ -82,8 +82,8 @@ char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable)
indexTable = tmpIdxTable;
}
std::unique_ptr<char[]> dataTable = Trinity::make_unique<char[]>(result->GetRowCount() * _recordSize);
std::unique_ptr<uint32[]> newIndexes = Trinity::make_unique<uint32[]>(result->GetRowCount());
std::unique_ptr<char[]> dataTable = std::make_unique<char[]>(result->GetRowCount() * _recordSize);
std::unique_ptr<uint32[]> newIndexes = std::make_unique<uint32[]>(result->GetRowCount());
uint32 newRecords = 0;
// Insert sql data into the data array

View File

@@ -42,8 +42,8 @@ RealmList* RealmList::Instance()
void RealmList::Initialize(Trinity::Asio::IoContext& ioContext, uint32 updateInterval)
{
_updateInterval = updateInterval;
_updateTimer = Trinity::make_unique<Trinity::Asio::DeadlineTimer>(ioContext);
_resolver = Trinity::make_unique<boost::asio::ip::tcp::resolver>(ioContext);
_updateTimer = std::make_unique<Trinity::Asio::DeadlineTimer>(ioContext);
_resolver = std::make_unique<boost::asio::ip::tcp::resolver>(ioContext);
LoadBuildInfo();
// Get the content of the realmlist table in the database
@@ -103,11 +103,11 @@ void RealmList::UpdateRealm(RealmHandle const& id, uint32 build, std::string con
realm.AllowedSecurityLevel = allowedSecurityLevel;
realm.PopulationLevel = population;
if (!realm.ExternalAddress || *realm.ExternalAddress != address)
realm.ExternalAddress = Trinity::make_unique<boost::asio::ip::address>(std::move(address));
realm.ExternalAddress = std::make_unique<boost::asio::ip::address>(std::move(address));
if (!realm.LocalAddress || *realm.LocalAddress != localAddr)
realm.LocalAddress = Trinity::make_unique<boost::asio::ip::address>(std::move(localAddr));
realm.LocalAddress = std::make_unique<boost::asio::ip::address>(std::move(localAddr));
if (!realm.LocalSubnetMask || *realm.LocalSubnetMask != localSubmask)
realm.LocalSubnetMask = Trinity::make_unique<boost::asio::ip::address>(std::move(localSubmask));
realm.LocalSubnetMask = std::make_unique<boost::asio::ip::address>(std::move(localSubmask));
realm.Port = port;
}

View File

@@ -520,7 +520,7 @@ bool LoadRealmInfo(Trinity::Asio::IoContext& ioContext)
return false;
}
realm.ExternalAddress = Trinity::make_unique<boost::asio::ip::address>(externalAddress->address());
realm.ExternalAddress = std::make_unique<boost::asio::ip::address>(externalAddress->address());
Optional<boost::asio::ip::tcp::endpoint> localAddress = Trinity::Net::Resolve(resolver, boost::asio::ip::tcp::v4(), fields[3].GetString(), "");
if (!localAddress)
@@ -529,7 +529,7 @@ bool LoadRealmInfo(Trinity::Asio::IoContext& ioContext)
return false;
}
realm.LocalAddress = Trinity::make_unique<boost::asio::ip::address>(localAddress->address());
realm.LocalAddress = std::make_unique<boost::asio::ip::address>(localAddress->address());
Optional<boost::asio::ip::tcp::endpoint> localSubmask = Trinity::Net::Resolve(resolver, boost::asio::ip::tcp::v4(), fields[4].GetString(), "");
if (!localSubmask)
@@ -538,7 +538,7 @@ bool LoadRealmInfo(Trinity::Asio::IoContext& ioContext)
return false;
}
realm.LocalSubnetMask = Trinity::make_unique<boost::asio::ip::address>(localSubmask->address());
realm.LocalSubnetMask = std::make_unique<boost::asio::ip::address>(localSubmask->address());
realm.Port = fields[5].GetUInt16();
realm.Type = fields[6].GetUInt8();