[Cleanup] use std::make_unique (#1259)

* Convert common/eq_limits.cpp to use make_unique

* Convert common/net/console_server.cpp to use make_unique

* Convert common/net/servertalk_client_connection.cpp to use make_unique

* Convert common/net/servertalk_legacy_client_connection.cpp to use make_unique

* Convert common/net/servertalk_server.cpp to use make_unique

* Convert common/net/websocket_server.cpp to use make_unique

* Convert common/net/websocket_server_connection.cpp to use make_unique

* Convert common/shareddb.cpp to use make_unique

* Convert eqlaunch/worldserver.cpp to use make_unique

* Convert loginserver/server_manager.cpp to use make_unique

* Convert loginserver/world_server.cpp to use make_unique

* Convert queryserv/worldserver.cpp to use make_unique

* Convert ucs/worldserver.cpp to use make_unique

* Convert world/clientlist.cpp to use make_unique

* Convert world/expedition.cpp to use make_unique

* Convert world/launcher_link.cpp to use make_unique

* Convert world/login_server.cpp to use make_unique

* Convert world/main.cpp to use make_unique

* Convert world/ucs.cpp to use make_unique

* Convert world/web_interface.cpp to use make_unique

* Convert world/zonelist.cpp to use make_unique

* Convert world/zoneserver.cpp to use make_unique

* Convert zone/client.cpp to use make_unique

* Convert zone/corpse.cpp to use make_unique

* Convert zone/dynamiczone.cpp to use make_unique

* Convert zone/expedition.cpp to use make_unique

* Convert zone/main.cpp to use make_unique

* Convert zone/mob_ai.cpp to use make_unique

* Convert zone/mob_movement_manager.cpp to use make_unique

* Convert zone/pathfinder_nav_mesh.cpp to use make_unique

* Convert zone/worldserver.cpp to use make_unique
This commit is contained in:
Michael Cook (mackal)
2021-02-23 19:30:46 -05:00
committed by GitHub
parent fa9478ac44
commit 7a46a6595c
31 changed files with 109 additions and 109 deletions
+2 -2
View File
@@ -794,7 +794,7 @@ void EQ::inventory::InitializeDynamicLookups() {
continue;
// direct manipulation of lookup indices is safe so long as (int)ClientVersion::<mob> == (int)MobVersion::<mob>
inventory_dynamic_nongm_lookup_entries[iter] = std::unique_ptr<LookupEntry>(new LookupEntry(inventory_static_lookup_entries[iter]));
inventory_dynamic_nongm_lookup_entries[iter] = std::make_unique<LookupEntry>(inventory_static_lookup_entries[iter]);
// clamp affected fields to the lowest standard
inventory_dynamic_nongm_lookup_entries[iter]->InventoryTypeSize.Bank = Titanium::invtype::BANK_SIZE; // bank size
@@ -864,7 +864,7 @@ void EQ::inventory::InitializeDynamicLookups() {
}
// direct manipulation of lookup indices is safe so long as (int)ClientVersion::<client> == (int)MobVersion::<client>
inventory_dynamic_gm_lookup_entries[iter] = std::unique_ptr<LookupEntry>(new LookupEntry(inventory_static_lookup_entries[iter]));
inventory_dynamic_gm_lookup_entries[iter] = std::make_unique<LookupEntry>(inventory_static_lookup_entries[iter]);
inventory_dynamic_gm_lookup_entries[iter]->PossessionsBitmask = 0; // we'll fix later
inventory_dynamic_gm_lookup_entries[iter]->CorpseBitmask = 0; // we'll fix later
+1 -1
View File
@@ -4,7 +4,7 @@
EQ::Net::ConsoleServer::ConsoleServer(const std::string &addr, int port)
{
m_server.reset(new EQ::Net::TCPServer());
m_server = std::make_unique<EQ::Net::TCPServer>();
m_server->Listen(addr, port, false, [this](std::shared_ptr<EQ::Net::TCPConnection> connection) {
ConsoleServerConnection *c = new ConsoleServerConnection(this, connection);
m_connections.insert(std::make_pair(c->GetUUID(), std::unique_ptr<ConsoleServerConnection>(c)));
+1 -1
View File
@@ -3,7 +3,7 @@
#include "../eqemu_logsys.h"
EQ::Net::ServertalkClient::ServertalkClient(const std::string &addr, int port, bool ipv6, const std::string &identifier, const std::string &credentials)
: m_timer(std::unique_ptr<EQ::Timer>(new EQ::Timer(100, true, std::bind(&EQ::Net::ServertalkClient::Connect, this))))
: m_timer(std::make_unique<EQ::Timer>(100, true, std::bind(&EQ::Net::ServertalkClient::Connect, this)))
{
m_port = port;
m_ipv6 = ipv6;
@@ -3,7 +3,7 @@
#include "../eqemu_logsys.h"
EQ::Net::ServertalkLegacyClient::ServertalkLegacyClient(const std::string &addr, int port, bool ipv6)
: m_timer(std::unique_ptr<EQ::Timer>(new EQ::Timer(100, true, std::bind(&EQ::Net::ServertalkLegacyClient::Connect, this))))
: m_timer(std::make_unique<EQ::Timer>(100, true, std::bind(&EQ::Net::ServertalkLegacyClient::Connect, this)))
{
m_port = port;
m_ipv6 = ipv6;
+1 -1
View File
@@ -13,7 +13,7 @@ void EQ::Net::ServertalkServer::Listen(const ServertalkServerOptions& opts)
m_encrypted = opts.encrypted;
m_credentials = opts.credentials;
m_allow_downgrade = opts.allow_downgrade;
m_server.reset(new EQ::Net::TCPServer());
m_server = std::make_unique<EQ::Net::TCPServer>();
m_server->Listen(opts.port, opts.ipv6, [this](std::shared_ptr<EQ::Net::TCPConnection> connection) {
m_unident_connections.push_back(std::make_shared<ServertalkServerConnection>(connection, this, m_encrypted, m_allow_downgrade));
});
+4 -4
View File
@@ -34,8 +34,8 @@ struct EQ::Net::WebsocketServer::Impl
EQ::Net::WebsocketServer::WebsocketServer(const std::string &addr, int port)
{
_impl.reset(new Impl());
_impl->server.reset(new EQ::Net::TCPServer());
_impl = std::make_unique<Impl>();
_impl->server = std::make_unique<EQ::Net::TCPServer>();
_impl->server->Listen(addr, port, false, [this](std::shared_ptr<EQ::Net::TCPConnection> connection) {
auto wsc = _impl->ws_server.get_connection();
WebsocketServerConnection *c = new WebsocketServerConnection(this, connection, wsc);
@@ -53,7 +53,7 @@ EQ::Net::WebsocketServer::WebsocketServer(const std::string &addr, int port)
return websocketpp::lib::error_code();
});
_impl->ping_timer.reset(new EQ::Timer(5000, true, [this](EQ::Timer *t) {
_impl->ping_timer = std::make_unique<EQ::Timer>(5000, true, [this](EQ::Timer *t) {
auto iter = _impl->connections.begin();
while (iter != _impl->connections.end()) {
@@ -67,7 +67,7 @@ EQ::Net::WebsocketServer::WebsocketServer(const std::string &addr, int port)
iter++;
}
}));
});
_impl->methods.insert(std::make_pair("login", MethodHandlerEntry(std::bind(&WebsocketServer::Login, this, std::placeholders::_1, std::placeholders::_2), 0)));
_impl->methods.insert(std::make_pair("subscribe", MethodHandlerEntry(std::bind(&WebsocketServer::Subscribe, this, std::placeholders::_1, std::placeholders::_2), 0)));
+1 -1
View File
@@ -20,7 +20,7 @@ EQ::Net::WebsocketServerConnection::WebsocketServerConnection(WebsocketServer *p
std::shared_ptr<TCPConnection> connection,
std::shared_ptr<websocket_connection> ws_connection)
{
_impl.reset(new Impl());
_impl = std::make_unique<Impl>();
_impl->parent = parent;
_impl->connection = connection;
_impl->id = EQ::Util::UUID::Generate().ToString();
+13 -13
View File
@@ -928,8 +928,8 @@ bool SharedDatabase::LoadItems(const std::string &prefix) {
mutex.Lock();
std::string file_name = Config->SharedMemDir + prefix + std::string("items");
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
items_mmf = std::unique_ptr<EQ::MemoryMappedFile>(new EQ::MemoryMappedFile(file_name));
items_hash = std::unique_ptr<EQ::FixedMemoryHashSet<EQ::ItemData>>(new EQ::FixedMemoryHashSet<EQ::ItemData>(reinterpret_cast<uint8*>(items_mmf->Get()), items_mmf->Size()));
items_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
items_hash = std::make_unique<EQ::FixedMemoryHashSet<EQ::ItemData>>(reinterpret_cast<uint8*>(items_mmf->Get()), items_mmf->Size());
mutex.Unlock();
} catch(std::exception& ex) {
LogError("Error Loading Items: {}", ex.what());
@@ -1353,8 +1353,8 @@ bool SharedDatabase::LoadNPCFactionLists(const std::string &prefix) {
mutex.Lock();
std::string file_name = Config->SharedMemDir + prefix + std::string("faction");
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
faction_mmf = std::unique_ptr<EQ::MemoryMappedFile>(new EQ::MemoryMappedFile(file_name));
faction_hash = std::unique_ptr<EQ::FixedMemoryHashSet<NPCFactionList>>(new EQ::FixedMemoryHashSet<NPCFactionList>(reinterpret_cast<uint8*>(faction_mmf->Get()), faction_mmf->Size()));
faction_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
faction_hash = std::make_unique<EQ::FixedMemoryHashSet<NPCFactionList>>(reinterpret_cast<uint8*>(faction_mmf->Get()), faction_mmf->Size());
mutex.Unlock();
} catch(std::exception& ex) {
LogError("Error Loading npc factions: {}", ex.what());
@@ -1555,7 +1555,7 @@ bool SharedDatabase::LoadSkillCaps(const std::string &prefix) {
mutex.Lock();
std::string file_name = Config->SharedMemDir + prefix + std::string("skill_caps");
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
skill_caps_mmf = std::unique_ptr<EQ::MemoryMappedFile>(new EQ::MemoryMappedFile(file_name));
skill_caps_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
mutex.Unlock();
} catch(std::exception &ex) {
LogError("Error loading skill caps: {}", ex.what());
@@ -1712,7 +1712,7 @@ bool SharedDatabase::LoadSpells(const std::string &prefix, int32 *records, const
mutex.Lock();
std::string file_name = Config->SharedMemDir + prefix + std::string("spells");
spells_mmf = std::unique_ptr<EQ::MemoryMappedFile>(new EQ::MemoryMappedFile(file_name));
spells_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
LogInfo("[Shared Memory] Attempting to load file [{}]", file_name);
*records = *reinterpret_cast<uint32*>(spells_mmf->Get());
*sp = reinterpret_cast<const SPDat_Spell_Struct*>((char*)spells_mmf->Get() + 4);
@@ -1920,7 +1920,7 @@ bool SharedDatabase::LoadBaseData(const std::string &prefix) {
mutex.Lock();
std::string file_name = Config->SharedMemDir + prefix + std::string("base_data");
base_data_mmf = std::unique_ptr<EQ::MemoryMappedFile>(new EQ::MemoryMappedFile(file_name));
base_data_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name);
mutex.Unlock();
} catch(std::exception& ex) {
LogError("Error Loading Base Data: {}", ex.what());
@@ -2223,15 +2223,15 @@ bool SharedDatabase::LoadLoot(const std::string &prefix) {
EQ::IPCMutex mutex("loot");
mutex.Lock();
std::string file_name_lt = Config->SharedMemDir + prefix + std::string("loot_table");
loot_table_mmf = std::unique_ptr<EQ::MemoryMappedFile>(new EQ::MemoryMappedFile(file_name_lt));
loot_table_hash = std::unique_ptr<EQ::FixedMemoryVariableHashSet<LootTable_Struct>>(new EQ::FixedMemoryVariableHashSet<LootTable_Struct>(
loot_table_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name_lt);
loot_table_hash = std::make_unique<EQ::FixedMemoryVariableHashSet<LootTable_Struct>>(
reinterpret_cast<uint8*>(loot_table_mmf->Get()),
loot_table_mmf->Size()));
loot_table_mmf->Size());
std::string file_name_ld = Config->SharedMemDir + prefix + std::string("loot_drop");
loot_drop_mmf = std::unique_ptr<EQ::MemoryMappedFile>(new EQ::MemoryMappedFile(file_name_ld));
loot_drop_hash = std::unique_ptr<EQ::FixedMemoryVariableHashSet<LootDrop_Struct>>(new EQ::FixedMemoryVariableHashSet<LootDrop_Struct>(
loot_drop_mmf = std::make_unique<EQ::MemoryMappedFile>(file_name_ld);
loot_drop_hash = std::make_unique<EQ::FixedMemoryVariableHashSet<LootDrop_Struct>>(
reinterpret_cast<uint8*>(loot_drop_mmf->Get()),
loot_drop_mmf->Size()));
loot_drop_mmf->Size());
mutex.Unlock();
} catch(std::exception &ex) {
LogError("Error loading loot: {}", ex.what());