From 7a46a6595c650b54fb7db753406c22ccbc748998 Mon Sep 17 00:00:00 2001 From: "Michael Cook (mackal)" Date: Tue, 23 Feb 2021 19:30:46 -0500 Subject: [PATCH] [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 --- common/eq_limits.cpp | 4 +- common/net/console_server.cpp | 2 +- common/net/servertalk_client_connection.cpp | 2 +- .../servertalk_legacy_client_connection.cpp | 2 +- common/net/servertalk_server.cpp | 2 +- common/net/websocket_server.cpp | 8 ++-- common/net/websocket_server_connection.cpp | 2 +- common/shareddb.cpp | 26 +++++----- eqlaunch/worldserver.cpp | 4 +- loginserver/server_manager.cpp | 4 +- loginserver/world_server.cpp | 4 +- queryserv/worldserver.cpp | 4 +- ucs/worldserver.cpp | 2 +- world/clientlist.cpp | 2 +- world/expedition.cpp | 8 ++-- world/launcher_link.cpp | 4 +- world/login_server.cpp | 20 ++++---- world/main.cpp | 4 +- world/ucs.cpp | 2 +- world/web_interface.cpp | 2 +- world/zonelist.cpp | 4 +- world/zoneserver.cpp | 4 +- zone/client.cpp | 18 +++---- zone/corpse.cpp | 2 +- zone/dynamiczone.cpp | 4 +- zone/expedition.cpp | 48 +++++++++---------- zone/main.cpp | 4 +- zone/mob_ai.cpp | 18 +++---- zone/mob_movement_manager.cpp | 2 +- zone/pathfinder_nav_mesh.cpp | 2 +- zone/worldserver.cpp | 4 +- 31 files changed, 109 insertions(+), 109 deletions(-) diff --git a/common/eq_limits.cpp b/common/eq_limits.cpp index 72c82f450..188c8f888 100644 --- a/common/eq_limits.cpp +++ b/common/eq_limits.cpp @@ -794,7 +794,7 @@ void EQ::inventory::InitializeDynamicLookups() { continue; // direct manipulation of lookup indices is safe so long as (int)ClientVersion:: == (int)MobVersion:: - inventory_dynamic_nongm_lookup_entries[iter] = std::unique_ptr(new LookupEntry(inventory_static_lookup_entries[iter])); + inventory_dynamic_nongm_lookup_entries[iter] = std::make_unique(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:: == (int)MobVersion:: - inventory_dynamic_gm_lookup_entries[iter] = std::unique_ptr(new LookupEntry(inventory_static_lookup_entries[iter])); + inventory_dynamic_gm_lookup_entries[iter] = std::make_unique(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 diff --git a/common/net/console_server.cpp b/common/net/console_server.cpp index ab420bd42..31b597bfb 100644 --- a/common/net/console_server.cpp +++ b/common/net/console_server.cpp @@ -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(); m_server->Listen(addr, port, false, [this](std::shared_ptr connection) { ConsoleServerConnection *c = new ConsoleServerConnection(this, connection); m_connections.insert(std::make_pair(c->GetUUID(), std::unique_ptr(c))); diff --git a/common/net/servertalk_client_connection.cpp b/common/net/servertalk_client_connection.cpp index 0a5dceac6..88cfc021a 100644 --- a/common/net/servertalk_client_connection.cpp +++ b/common/net/servertalk_client_connection.cpp @@ -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(new EQ::Timer(100, true, std::bind(&EQ::Net::ServertalkClient::Connect, this)))) + : m_timer(std::make_unique(100, true, std::bind(&EQ::Net::ServertalkClient::Connect, this))) { m_port = port; m_ipv6 = ipv6; diff --git a/common/net/servertalk_legacy_client_connection.cpp b/common/net/servertalk_legacy_client_connection.cpp index 3cbe1c85a..8be329e65 100644 --- a/common/net/servertalk_legacy_client_connection.cpp +++ b/common/net/servertalk_legacy_client_connection.cpp @@ -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(new EQ::Timer(100, true, std::bind(&EQ::Net::ServertalkLegacyClient::Connect, this)))) + : m_timer(std::make_unique(100, true, std::bind(&EQ::Net::ServertalkLegacyClient::Connect, this))) { m_port = port; m_ipv6 = ipv6; diff --git a/common/net/servertalk_server.cpp b/common/net/servertalk_server.cpp index fcbea917c..297d4cd31 100644 --- a/common/net/servertalk_server.cpp +++ b/common/net/servertalk_server.cpp @@ -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(); m_server->Listen(opts.port, opts.ipv6, [this](std::shared_ptr connection) { m_unident_connections.push_back(std::make_shared(connection, this, m_encrypted, m_allow_downgrade)); }); diff --git a/common/net/websocket_server.cpp b/common/net/websocket_server.cpp index b46fc7953..dda1a4a96 100644 --- a/common/net/websocket_server.cpp +++ b/common/net/websocket_server.cpp @@ -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->server = std::make_unique(); _impl->server->Listen(addr, port, false, [this](std::shared_ptr 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(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))); diff --git a/common/net/websocket_server_connection.cpp b/common/net/websocket_server_connection.cpp index 50b117062..3c1271518 100644 --- a/common/net/websocket_server_connection.cpp +++ b/common/net/websocket_server_connection.cpp @@ -20,7 +20,7 @@ EQ::Net::WebsocketServerConnection::WebsocketServerConnection(WebsocketServer *p std::shared_ptr connection, std::shared_ptr ws_connection) { - _impl.reset(new Impl()); + _impl = std::make_unique(); _impl->parent = parent; _impl->connection = connection; _impl->id = EQ::Util::UUID::Generate().ToString(); diff --git a/common/shareddb.cpp b/common/shareddb.cpp index d26d2d820..6f2af55a3 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -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(new EQ::MemoryMappedFile(file_name)); - items_hash = std::unique_ptr>(new EQ::FixedMemoryHashSet(reinterpret_cast(items_mmf->Get()), items_mmf->Size())); + items_mmf = std::make_unique(file_name); + items_hash = std::make_unique>(reinterpret_cast(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(new EQ::MemoryMappedFile(file_name)); - faction_hash = std::unique_ptr>(new EQ::FixedMemoryHashSet(reinterpret_cast(faction_mmf->Get()), faction_mmf->Size())); + faction_mmf = std::make_unique(file_name); + faction_hash = std::make_unique>(reinterpret_cast(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(new EQ::MemoryMappedFile(file_name)); + skill_caps_mmf = std::make_unique(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(new EQ::MemoryMappedFile(file_name)); + spells_mmf = std::make_unique(file_name); LogInfo("[Shared Memory] Attempting to load file [{}]", file_name); *records = *reinterpret_cast(spells_mmf->Get()); *sp = reinterpret_cast((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(new EQ::MemoryMappedFile(file_name)); + base_data_mmf = std::make_unique(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(new EQ::MemoryMappedFile(file_name_lt)); - loot_table_hash = std::unique_ptr>(new EQ::FixedMemoryVariableHashSet( + loot_table_mmf = std::make_unique(file_name_lt); + loot_table_hash = std::make_unique>( reinterpret_cast(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(new EQ::MemoryMappedFile(file_name_ld)); - loot_drop_hash = std::unique_ptr>(new EQ::FixedMemoryVariableHashSet( + loot_drop_mmf = std::make_unique(file_name_ld); + loot_drop_hash = std::make_unique>( reinterpret_cast(loot_drop_mmf->Get()), - loot_drop_mmf->Size())); + loot_drop_mmf->Size()); mutex.Unlock(); } catch(std::exception &ex) { LogError("Error loading loot: {}", ex.what()); diff --git a/eqlaunch/worldserver.cpp b/eqlaunch/worldserver.cpp index ea0eee4ac..c50b58e09 100644 --- a/eqlaunch/worldserver.cpp +++ b/eqlaunch/worldserver.cpp @@ -29,7 +29,7 @@ WorldServer::WorldServer(std::map &zones, const char m_config(config), m_zones(zones) { - m_connection.reset(new EQ::Net::ServertalkClient(config->WorldIP, config->WorldTCPPort, false, "Launcher", config->SharedKey)); + m_connection = std::make_unique(config->WorldIP, config->WorldTCPPort, false, "Launcher", config->SharedKey); m_connection->OnConnect([this](EQ::Net::ServertalkClient *client) { OnConnected(); }); @@ -138,4 +138,4 @@ void WorldServer::SendStatus(const char *short_name, uint32 start_count, bool ru m_connection->SendPacket(pack); safe_delete(pack); -} \ No newline at end of file +} diff --git a/loginserver/server_manager.cpp b/loginserver/server_manager.cpp index 5cd01a8f9..1761e1b15 100644 --- a/loginserver/server_manager.cpp +++ b/loginserver/server_manager.cpp @@ -33,7 +33,7 @@ ServerManager::ServerManager() { int listen_port = server.config.GetVariableInt("general", "listen_port", 5998); - server_connection.reset(new EQ::Net::ServertalkServer()); + server_connection = std::make_unique(); EQ::Net::ServertalkServerOptions opts; opts.port = listen_port; opts.ipv6 = false; @@ -68,7 +68,7 @@ ServerManager::ServerManager() ++iter; } - world_servers.push_back(std::unique_ptr(new WorldServer(world_connection))); + world_servers.push_back(std::make_unique(world_connection)); } ); diff --git a/loginserver/world_server.cpp b/loginserver/world_server.cpp index 765c108da..43846af32 100644 --- a/loginserver/world_server.cpp +++ b/loginserver/world_server.cpp @@ -72,7 +72,7 @@ WorldServer::WorldServer(std::shared_ptr wo std::bind(&WorldServer::ProcessLSAccountUpdate, this, std::placeholders::_1, std::placeholders::_2) ); - m_keepalive.reset(new EQ::Timer(5000, true, std::bind(&WorldServer::OnKeepAlive, this, std::placeholders::_1))); + m_keepalive = std::make_unique(5000, true, std::bind(&WorldServer::OnKeepAlive, this, std::placeholders::_1)); } WorldServer::~WorldServer() = default; @@ -1317,4 +1317,4 @@ void WorldServer::OnKeepAlive(EQ::Timer *t) { ServerPacket pack(ServerOP_KeepAlive, 0); connection->SendPacket(&pack); -} \ No newline at end of file +} diff --git a/queryserv/worldserver.cpp b/queryserv/worldserver.cpp index ec34ce7bb..1c65b92fd 100644 --- a/queryserv/worldserver.cpp +++ b/queryserv/worldserver.cpp @@ -52,7 +52,7 @@ WorldServer::~WorldServer() void WorldServer::Connect() { - m_connection.reset(new EQ::Net::ServertalkClient(Config->WorldIP, Config->WorldTCPPort, false, "QueryServ", Config->SharedKey)); + m_connection = std::make_unique(Config->WorldIP, Config->WorldTCPPort, false, "QueryServ", Config->SharedKey); m_connection->OnMessage(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2)); } @@ -185,4 +185,4 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) break; } } -} \ No newline at end of file +} diff --git a/ucs/worldserver.cpp b/ucs/worldserver.cpp index 88cff5afd..64bdfc2a7 100644 --- a/ucs/worldserver.cpp +++ b/ucs/worldserver.cpp @@ -48,7 +48,7 @@ void Client55ToServerSayLink(std::string& serverSayLink, const std::string& clie WorldServer::WorldServer() { - m_connection.reset(new EQ::Net::ServertalkClient(Config->WorldIP, Config->WorldTCPPort, false, "UCS", Config->SharedKey)); + m_connection = std::make_unique(Config->WorldIP, Config->WorldTCPPort, false, "UCS", Config->SharedKey); m_connection->OnMessage(std::bind(&WorldServer::ProcessMessage, this, std::placeholders::_1, std::placeholders::_2)); } diff --git a/world/clientlist.cpp b/world/clientlist.cpp index 0149b3b9f..eb2690871 100644 --- a/world/clientlist.cpp +++ b/world/clientlist.cpp @@ -46,7 +46,7 @@ ClientList::ClientList() { NextCLEID = 1; - m_tick.reset(new EQ::Timer(5000, true, std::bind(&ClientList::OnTick, this, std::placeholders::_1))); + m_tick = std::make_unique(5000, true, std::bind(&ClientList::OnTick, this, std::placeholders::_1)); } ClientList::~ClientList() { diff --git a/world/expedition.cpp b/world/expedition.cpp index 2f1a8f0be..b3b1dd682 100644 --- a/world/expedition.cpp +++ b/world/expedition.cpp @@ -112,7 +112,7 @@ bool Expedition::SetNewLeader(uint32_t character_id) void Expedition::SendZonesExpeditionDeleted() { uint32_t pack_size = sizeof(ServerExpeditionID_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionDeleted, pack_size)); + auto pack = std::make_unique(ServerOP_ExpeditionDeleted, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->expedition_id = GetID(); zoneserver_list.SendPacket(pack.get()); @@ -121,7 +121,7 @@ void Expedition::SendZonesExpeditionDeleted() void Expedition::SendZonesDurationUpdate() { uint32_t packsize = sizeof(ServerExpeditionUpdateDuration_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionDzDuration, packsize)); + auto pack = std::make_unique(ServerOP_ExpeditionDzDuration, packsize); auto packbuf = reinterpret_cast(pack->pBuffer); packbuf->expedition_id = GetID(); packbuf->new_duration_seconds = static_cast(m_duration.count()); @@ -131,7 +131,7 @@ void Expedition::SendZonesDurationUpdate() void Expedition::SendZonesExpireWarning(uint32_t minutes_remaining) { uint32_t pack_size = sizeof(ServerExpeditionExpireWarning_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionExpireWarning, pack_size)); + auto pack = std::make_unique(ServerOP_ExpeditionExpireWarning, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->expedition_id = GetID(); buf->minutes_remaining = minutes_remaining; @@ -141,7 +141,7 @@ void Expedition::SendZonesExpireWarning(uint32_t minutes_remaining) void Expedition::SendZonesLeaderChanged() { uint32_t pack_size = sizeof(ServerExpeditionLeaderID_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionLeaderChanged, pack_size)); + auto pack = std::make_unique(ServerOP_ExpeditionLeaderChanged, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->expedition_id = GetID(); buf->leader_id = m_leader_id; diff --git a/world/launcher_link.cpp b/world/launcher_link.cpp index d60933b41..8f3fa1aaf 100644 --- a/world/launcher_link.cpp +++ b/world/launcher_link.cpp @@ -45,7 +45,7 @@ LauncherLink::LauncherLink(int id, std::shared_ptrOnMessage(std::bind(&LauncherLink::ProcessMessage, this, std::placeholders::_1, std::placeholders::_2)); - m_process_timer.reset(new EQ::Timer(100, true, std::bind(&LauncherLink::Process, this, std::placeholders::_1))); + m_process_timer = std::make_unique(100, true, std::bind(&LauncherLink::Process, this, std::placeholders::_1)); } LauncherLink::~LauncherLink() { @@ -296,4 +296,4 @@ void LauncherLink::Shutdown() { auto pack = new ServerPacket(ServerOP_ShutdownAll); SendPacket(pack); delete pack; -} \ No newline at end of file +} diff --git a/world/login_server.cpp b/world/login_server.cpp index 2533a9bad..590a3f0db 100644 --- a/world/login_server.cpp +++ b/world/login_server.cpp @@ -342,7 +342,7 @@ bool LoginServer::Connect() } if (IsLegacy) { - legacy_client.reset(new EQ::Net::ServertalkLegacyClient(LoginServerAddress, LoginServerPort, false)); + legacy_client = std::make_unique(LoginServerAddress, LoginServerPort, false); legacy_client->OnConnect( [this](EQ::Net::ServertalkLegacyClient *client) { if (client) { @@ -356,12 +356,12 @@ bool LoginServer::Connect() SendStatus(); zoneserver_list.SendLSZones(); - statusupdate_timer.reset( - new EQ::Timer( + statusupdate_timer = std::make_unique( + LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) { SendStatus(); } - ) + ); } else { @@ -448,7 +448,7 @@ bool LoginServer::Connect() ); } else { - client.reset(new EQ::Net::ServertalkClient(LoginServerAddress, LoginServerPort, false, "World", "")); + client = std::make_unique(LoginServerAddress, LoginServerPort, false, "World", ""); client->OnConnect( [this](EQ::Net::ServertalkClient *client) { if (client) { @@ -461,12 +461,12 @@ bool LoginServer::Connect() SendStatus(); zoneserver_list.SendLSZones(); - statusupdate_timer.reset( - new EQ::Timer( + statusupdate_timer = std::make_unique( + LoginServer_StatusUpdateInterval, true, [this](EQ::Timer *t) { SendStatus(); } - )); + ); } else { LogInfo( @@ -552,7 +552,7 @@ bool LoginServer::Connect() ); } - m_keepalive.reset(new EQ::Timer(5000, true, std::bind(&LoginServer::OnKeepAlive, this, std::placeholders::_1))); + m_keepalive = std::make_unique(5000, true, std::bind(&LoginServer::OnKeepAlive, this, std::placeholders::_1)); return true; } @@ -649,4 +649,4 @@ void LoginServer::OnKeepAlive(EQ::Timer *t) { ServerPacket pack(ServerOP_KeepAlive, 0); SendPacket(&pack); -} \ No newline at end of file +} diff --git a/world/main.cpp b/world/main.cpp index b426d13ff..c5c67ab87 100644 --- a/world/main.cpp +++ b/world/main.cpp @@ -445,13 +445,13 @@ int main(int argc, char** argv) { std::unique_ptr console; if (Config->TelnetEnabled) { LogInfo("Console (TCP) listener started"); - console.reset(new EQ::Net::ConsoleServer(Config->TelnetIP, Config->TelnetTCPPort)); + console = std::make_unique(Config->TelnetIP, Config->TelnetTCPPort); RegisterConsoleFunctions(console); } zoneserver_list.Init(); std::unique_ptr server_connection; - server_connection.reset(new EQ::Net::ServertalkServer()); + server_connection = std::make_unique(); EQ::Net::ServertalkServerOptions server_opts; server_opts.port = Config->WorldTCPPort; diff --git a/world/ucs.cpp b/world/ucs.cpp index 170e49dea..0af363051 100644 --- a/world/ucs.cpp +++ b/world/ucs.cpp @@ -32,7 +32,7 @@ void UCSConnection::SetConnection(std::shared_ptr(1000, true, std::bind(&UCSConnection::OnKeepAlive, this, std::placeholders::_1)); } const std::shared_ptr &UCSConnection::GetConnection() const diff --git a/world/web_interface.cpp b/world/web_interface.cpp index 773e955b6..234031770 100644 --- a/world/web_interface.cpp +++ b/world/web_interface.cpp @@ -146,7 +146,7 @@ WebInterfaceList::~WebInterfaceList() void WebInterfaceList::AddConnection(std::shared_ptr connection) { - m_interfaces.insert(std::make_pair(connection->GetUUID(), std::unique_ptr(new WebInterface(connection)))); + m_interfaces.insert(std::make_pair(connection->GetUUID(), std::make_unique(connection))); } void WebInterfaceList::RemoveConnection(std::shared_ptr connection) diff --git a/world/zonelist.cpp b/world/zonelist.cpp index 3fcc198cd..2687e1b86 100644 --- a/world/zonelist.cpp +++ b/world/zonelist.cpp @@ -42,8 +42,8 @@ ZSList::ZSList() CurGroupID = 1; memset(pLockedZones, 0, sizeof(pLockedZones)); - m_tick.reset(new EQ::Timer(5000, true, std::bind(&ZSList::OnTick, this, std::placeholders::_1))); - m_keepalive.reset(new EQ::Timer(2500, true, std::bind(&ZSList::OnKeepAlive, this, std::placeholders::_1))); + m_tick = std::make_unique(5000, true, std::bind(&ZSList::OnTick, this, std::placeholders::_1)); + m_keepalive = std::make_unique(2500, true, std::bind(&ZSList::OnKeepAlive, this, std::placeholders::_1)); } ZSList::~ZSList() { diff --git a/world/zoneserver.cpp b/world/zoneserver.cpp index f09d08db1..e08ec8460 100644 --- a/world/zoneserver.cpp +++ b/world/zoneserver.cpp @@ -70,12 +70,12 @@ ZoneServer::ZoneServer(std::shared_ptr conn tcpc->OnMessage(std::bind(&ZoneServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2)); - boot_timer_obj.reset(new EQ::Timer(100, true, [this](EQ::Timer *obj) { + boot_timer_obj = std::make_unique(100, true, [this](EQ::Timer *obj) { if (zone_boot_timer.Check()) { LSBootUpdate(GetZoneID(), true); zone_boot_timer.Disable(); } - })); + }); this->console = console; } diff --git a/zone/client.cpp b/zone/client.cpp index cdd32ee69..1a9247259 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -756,7 +756,7 @@ bool Client::AddPacket(const EQApplicationPacket *pApp, bool bAckreq) { return(false); } - auto c = std::unique_ptr(new CLIENTPACKET); + auto c = std::make_unique(); c->ack_req = bAckreq; c->app = pApp->Copy(); @@ -773,7 +773,7 @@ bool Client::AddPacket(EQApplicationPacket** pApp, bool bAckreq) { //drop the packet because it will never get sent. return(false); } - auto c = std::unique_ptr(new CLIENTPACKET); + auto c = std::make_unique(); c->ack_req = bAckreq; c->app = *pApp; @@ -3221,7 +3221,7 @@ void Client::MessageString(const CZClientMessageString_Struct* msg) else { uint32_t outsize = sizeof(FormattedMessage_Struct) + msg->args_size; - auto outapp = std::unique_ptr(new EQApplicationPacket(OP_FormattedMessage, outsize)); + auto outapp = std::make_unique(OP_FormattedMessage, outsize); auto outbuf = reinterpret_cast(outapp->pBuffer); outbuf->string_id = msg->string_id; outbuf->type = msg->chat_type; @@ -9511,7 +9511,7 @@ void Client::SendCrossZoneMessage( else if (!character_name.empty() && !message.empty()) { uint32_t pack_size = sizeof(CZMessagePlayer_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_CZMessagePlayer, pack_size)); + auto pack = std::make_unique(ServerOP_CZMessagePlayer, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->type = chat_type; strn0cpy(buf->character_name, character_name.c_str(), sizeof(buf->character_name)); @@ -9544,7 +9544,7 @@ void Client::SendCrossZoneMessageString( uint32_t args_size = static_cast(argument_buffer.size()); uint32_t pack_size = sizeof(CZClientMessageString_Struct) + args_size; - auto pack = std::unique_ptr(new ServerPacket(ServerOP_CZClientMessageString, pack_size)); + auto pack = std::make_unique(ServerOP_CZClientMessageString, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->string_id = string_id; buf->chat_type = chat_type; @@ -9791,7 +9791,7 @@ void Client::SendExpeditionLockoutTimers() uint32_t lockout_count = static_cast(lockout_entries.size()); uint32_t lockout_entries_size = sizeof(ExpeditionLockoutTimerEntry_Struct) * lockout_count; uint32_t outsize = sizeof(ExpeditionLockoutTimers_Struct) + lockout_entries_size; - auto outapp = std::unique_ptr(new EQApplicationPacket(OP_DzExpeditionLockoutTimers, outsize)); + auto outapp = std::make_unique(OP_DzExpeditionLockoutTimers, outsize); auto outbuf = reinterpret_cast(outapp->pBuffer); outbuf->count = lockout_count; if (!lockout_entries.empty()) @@ -9804,7 +9804,7 @@ void Client::SendExpeditionLockoutTimers() void Client::RequestPendingExpeditionInvite() { uint32_t packsize = sizeof(ServerExpeditionCharacterID_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionRequestInvite, packsize)); + auto pack = std::make_unique(ServerOP_ExpeditionRequestInvite, packsize); auto packbuf = reinterpret_cast(pack->pBuffer); packbuf->character_id = CharacterID(); worldserver.SendPacket(pack.get()); @@ -9894,7 +9894,7 @@ void Client::SendDzCompassUpdate() uint32 count = static_cast(compass_entries.size()); uint32 entries_size = sizeof(DynamicZoneCompassEntry_Struct) * count; uint32 outsize = sizeof(DynamicZoneCompass_Struct) + entries_size; - auto outapp = std::unique_ptr(new EQApplicationPacket(OP_DzCompass, outsize)); + auto outapp = std::make_unique(OP_DzCompass, outsize); auto outbuf = reinterpret_cast(outapp->pBuffer); outbuf->count = count; memcpy(outbuf->entries, compass_entries.data(), entries_size); @@ -9972,7 +9972,7 @@ void Client::MovePCDynamicZone(uint32 zone_id, int zone_version, bool msg_if_inv uint32 count = static_cast(client_dzs.size()); uint32 entries_size = sizeof(DynamicZoneChooseZoneEntry_Struct) * count; uint32 outsize = sizeof(DynamicZoneChooseZone_Struct) + entries_size; - auto outapp = std::unique_ptr(new EQApplicationPacket(OP_DzChooseZone, outsize)); + auto outapp = std::make_unique(OP_DzChooseZone, outsize); auto outbuf = reinterpret_cast(outapp->pBuffer); outbuf->count = count; for (int i = 0; i < client_dzs.size(); ++i) diff --git a/zone/corpse.cpp b/zone/corpse.cpp index ad75521a7..5113b6fdf 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -1631,7 +1631,7 @@ void Corpse::LoadPlayerCorpseDecayTime(uint32 corpse_db_id){ void Corpse::SendWorldSpawnPlayerCorpseInZone(uint32_t zone_id) { - auto pack = std::unique_ptr(new ServerPacket(ServerOP_SpawnPlayerCorpse, sizeof(SpawnPlayerCorpse_Struct))); + auto pack = std::make_unique(ServerOP_SpawnPlayerCorpse, sizeof(SpawnPlayerCorpse_Struct)); SpawnPlayerCorpse_Struct* spc = reinterpret_cast(pack->pBuffer); spc->player_corpse_id = corpse_db_id; spc->zone_id = zone_id; diff --git a/zone/dynamiczone.cpp b/zone/dynamiczone.cpp index 9eeb7596d..ba367351e 100644 --- a/zone/dynamiczone.cpp +++ b/zone/dynamiczone.cpp @@ -380,7 +380,7 @@ void DynamicZone::RemoveAllCharacters(bool enable_removal_timers) else if (GetInstanceID() != 0) { uint32_t packsize = sizeof(ServerDzCharacter_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_DzRemoveAllCharacters, packsize)); + auto pack = std::make_unique(ServerOP_DzRemoveAllCharacters, packsize); auto packbuf = reinterpret_cast(pack->pBuffer); packbuf->zone_id = GetZoneID(); packbuf->instance_id = GetInstanceID(); @@ -429,7 +429,7 @@ void DynamicZone::SendInstanceCharacterChange(uint32_t character_id, bool remove else if (GetInstanceID() != 0) { uint32_t packsize = sizeof(ServerDzCharacter_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_DzCharacterChange, packsize)); + auto pack = std::make_unique(ServerOP_DzCharacterChange, packsize); auto packbuf = reinterpret_cast(pack->pBuffer); packbuf->zone_id = GetZoneID(); packbuf->instance_id = GetInstanceID(); diff --git a/zone/expedition.cpp b/zone/expedition.cpp index cf9ebc0c1..7b6d053c2 100644 --- a/zone/expedition.cpp +++ b/zone/expedition.cpp @@ -102,7 +102,7 @@ Expedition* Expedition::TryCreate( if (expedition_id) { - auto expedition = std::unique_ptr(new Expedition( + auto expedition = std::make_unique( expedition_id, expedition_uuid, dynamiczone, @@ -110,7 +110,7 @@ Expedition* Expedition::TryCreate( ExpeditionMember{ request.GetLeaderID(), request.GetLeaderName() }, request.GetMinPlayers(), request.GetMaxPlayers() - )); + ); LogExpeditions( "Created [{}] [{}] instance id: [{}] leader: [{}] minplayers: [{}] maxplayers: [{}]", @@ -172,7 +172,7 @@ void Expedition::CacheExpeditions(MySQLRequestResult& results) dynamic_zone_ids.emplace_back(dynamic_zone_id); - std::unique_ptr expedition = std::unique_ptr(new Expedition( + std::unique_ptr expedition = std::make_unique( expedition_id, row[col::uuid], // expedition uuid DynamicZone{ dynamic_zone_id }, @@ -180,7 +180,7 @@ void Expedition::CacheExpeditions(MySQLRequestResult& results) ExpeditionMember{ leader_id, row[col::leader_name] }, // expedition leader id, name strtoul(row[col::min_players], nullptr, 10), // min_players strtoul(row[col::max_players], nullptr, 10) // max_players - )); + ); bool add_replay_on_join = (strtoul(row[col::add_replay_on_join], nullptr, 10) != 0); bool is_locked = (strtoul(row[col::is_locked], nullptr, 10) != 0); @@ -1429,7 +1429,7 @@ void Expedition::SendWorldPendingInvite(const ExpeditionInvite& invite, const st std::unique_ptr Expedition::CreateExpireWarningPacket(uint32_t minutes_remaining) { uint32_t outsize = sizeof(ExpeditionExpireWarning); - auto outapp = std::unique_ptr(new EQApplicationPacket(OP_DzExpeditionEndsWarning, outsize)); + auto outapp = std::make_unique(OP_DzExpeditionEndsWarning, outsize); auto buf = reinterpret_cast(outapp->pBuffer); buf->minutes_remaining = minutes_remaining; return outapp; @@ -1438,7 +1438,7 @@ std::unique_ptr Expedition::CreateExpireWarningPacket(uint3 std::unique_ptr Expedition::CreateInfoPacket(bool clear) { uint32_t outsize = sizeof(ExpeditionInfo_Struct); - auto outapp = std::unique_ptr(new EQApplicationPacket(OP_DzExpeditionInfo, outsize)); + auto outapp = std::make_unique(OP_DzExpeditionInfo, outsize); auto info = reinterpret_cast(outapp->pBuffer); if (!clear) { @@ -1454,7 +1454,7 @@ std::unique_ptr Expedition::CreateInvitePacket( const std::string& inviter_name, const std::string& swap_remove_name) { uint32_t outsize = sizeof(ExpeditionInvite_Struct); - auto outapp = std::unique_ptr(new EQApplicationPacket(OP_DzExpeditionInvite, outsize)); + auto outapp = std::make_unique(OP_DzExpeditionInvite, outsize); auto outbuf = reinterpret_cast(outapp->pBuffer); strn0cpy(outbuf->inviter_name, inviter_name.c_str(), sizeof(outbuf->inviter_name)); strn0cpy(outbuf->expedition_name, m_expedition_name.c_str(), sizeof(outbuf->expedition_name)); @@ -1470,7 +1470,7 @@ std::unique_ptr Expedition::CreateMemberListPacket(bool cle uint32_t member_count = clear ? 0 : static_cast(m_members.size()); uint32_t member_entries_size = sizeof(ExpeditionMemberEntry_Struct) * member_count; uint32_t outsize = sizeof(ExpeditionMemberList_Struct) + member_entries_size; - auto outapp = std::unique_ptr(new EQApplicationPacket(OP_DzMemberList, outsize)); + auto outapp = std::make_unique(OP_DzMemberList, outsize); auto buf = reinterpret_cast(outapp->pBuffer); buf->member_count = member_count; @@ -1491,7 +1491,7 @@ std::unique_ptr Expedition::CreateMemberListNamePacket( const std::string& name, bool remove_name) { uint32_t outsize = sizeof(ExpeditionMemberListName_Struct); - auto outapp = std::unique_ptr(new EQApplicationPacket(OP_DzMemberListName, outsize)); + auto outapp = std::make_unique(OP_DzMemberListName, outsize); auto buf = reinterpret_cast(outapp->pBuffer); buf->add_name = !remove_name; strn0cpy(buf->name, name.c_str(), sizeof(buf->name)); @@ -1503,7 +1503,7 @@ std::unique_ptr Expedition::CreateMemberListStatusPacket( { // member list status uses member list struct with a single entry uint32_t outsize = sizeof(ExpeditionMemberList_Struct) + sizeof(ExpeditionMemberEntry_Struct); - auto outapp = std::unique_ptr(new EQApplicationPacket(OP_DzMemberListStatus, outsize)); + auto outapp = std::make_unique(OP_DzMemberListStatus, outsize); auto buf = reinterpret_cast(outapp->pBuffer); buf->member_count = 1; @@ -1517,7 +1517,7 @@ std::unique_ptr Expedition::CreateMemberListStatusPacket( std::unique_ptr Expedition::CreateLeaderNamePacket() { uint32_t outsize = sizeof(ExpeditionSetLeaderName_Struct); - auto outapp = std::unique_ptr(new EQApplicationPacket(OP_DzSetLeaderName, outsize)); + auto outapp = std::make_unique(OP_DzSetLeaderName, outsize); auto buf = reinterpret_cast(outapp->pBuffer); strn0cpy(buf->leader_name, m_leader.name.c_str(), sizeof(buf->leader_name)); return outapp; @@ -1526,7 +1526,7 @@ std::unique_ptr Expedition::CreateLeaderNamePacket() void Expedition::SendWorldExpeditionUpdate(uint16_t server_opcode) { uint32_t pack_size = sizeof(ServerExpeditionID_Struct); - auto pack = std::unique_ptr(new ServerPacket(server_opcode, pack_size)); + auto pack = std::make_unique(server_opcode, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->expedition_id = GetID(); buf->sender_zone_id = zone ? zone->GetZoneID() : 0; @@ -1539,7 +1539,7 @@ void Expedition::SendWorldAddPlayerInvite( { auto server_opcode = pending ? ServerOP_ExpeditionSaveInvite : ServerOP_ExpeditionDzAddPlayer; uint32_t pack_size = sizeof(ServerDzCommand_Struct); - auto pack = std::unique_ptr(new ServerPacket(server_opcode, pack_size)); + auto pack = std::make_unique(server_opcode, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->expedition_id = GetID(); buf->is_char_online = false; @@ -1553,7 +1553,7 @@ void Expedition::SendWorldLockoutDuration( const ExpeditionLockoutTimer& lockout, int seconds, bool members_only) { uint32_t pack_size = sizeof(ServerExpeditionLockout_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionLockoutDuration, pack_size)); + auto pack = std::make_unique(ServerOP_ExpeditionLockoutDuration, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->expedition_id = GetID(); buf->expire_time = lockout.GetExpireTime(); @@ -1570,7 +1570,7 @@ void Expedition::SendWorldLockoutUpdate( const ExpeditionLockoutTimer& lockout, bool remove, bool members_only) { uint32_t pack_size = sizeof(ServerExpeditionLockout_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionLockout, pack_size)); + auto pack = std::make_unique(ServerOP_ExpeditionLockout, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->expedition_id = GetID(); buf->expire_time = lockout.GetExpireTime(); @@ -1586,7 +1586,7 @@ void Expedition::SendWorldLockoutUpdate( void Expedition::SendWorldMakeLeaderRequest(uint32_t requester_id, const std::string& new_leader_name) { uint32_t pack_size = sizeof(ServerDzCommandMakeLeader_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionDzMakeLeader, pack_size)); + auto pack = std::make_unique(ServerOP_ExpeditionDzMakeLeader, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->expedition_id = GetID(); buf->requester_id = requester_id; @@ -1598,7 +1598,7 @@ void Expedition::SendWorldMemberChanged(const std::string& char_name, uint32_t c { // notify other zones of added or removed member uint32_t pack_size = sizeof(ServerExpeditionMemberChange_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionMemberChange, pack_size)); + auto pack = std::make_unique(ServerOP_ExpeditionMemberChange, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->expedition_id = GetID(); buf->sender_zone_id = zone ? zone->GetZoneID() : 0; @@ -1612,7 +1612,7 @@ void Expedition::SendWorldMemberChanged(const std::string& char_name, uint32_t c void Expedition::SendWorldMemberStatus(uint32_t character_id, ExpeditionMemberStatus status) { uint32_t pack_size = sizeof(ServerExpeditionMemberStatus_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionMemberStatus, pack_size)); + auto pack = std::make_unique(ServerOP_ExpeditionMemberStatus, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->expedition_id = GetID(); buf->sender_zone_id = zone ? zone->GetZoneID() : 0; @@ -1625,7 +1625,7 @@ void Expedition::SendWorldMemberStatus(uint32_t character_id, ExpeditionMemberSt void Expedition::SendWorldDzLocationUpdate(uint16_t server_opcode, const DynamicZoneLocation& location) { uint32_t pack_size = sizeof(ServerDzLocation_Struct); - auto pack = std::unique_ptr(new ServerPacket(server_opcode, pack_size)); + auto pack = std::make_unique(server_opcode, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->owner_id = GetID(); buf->dz_zone_id = m_dynamiczone.GetZoneID(); @@ -1644,7 +1644,7 @@ void Expedition::SendWorldMemberSwapped( const std::string& remove_char_name, uint32_t remove_char_id, const std::string& add_char_name, uint32_t add_char_id) { uint32_t pack_size = sizeof(ServerExpeditionMemberSwap_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionMemberSwap, pack_size)); + auto pack = std::make_unique(ServerOP_ExpeditionMemberSwap, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->expedition_id = GetID(); buf->sender_zone_id = zone ? zone->GetZoneID() : 0; @@ -1659,7 +1659,7 @@ void Expedition::SendWorldMemberSwapped( void Expedition::SendWorldSettingChanged(uint16_t server_opcode, bool setting_value) { uint32_t pack_size = sizeof(ServerExpeditionSetting_Struct); - auto pack = std::unique_ptr(new ServerPacket(server_opcode, pack_size)); + auto pack = std::make_unique(server_opcode, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->expedition_id = GetID(); buf->sender_zone_id = zone ? zone->GetZoneID() : 0; @@ -1675,7 +1675,7 @@ void Expedition::SendWorldGetOnlineMembers( uint32_t count = static_cast(expedition_character_ids.size()); uint32_t entries_size = sizeof(ServerExpeditionCharacterEntry_Struct) * count; uint32_t pack_size = sizeof(ServerExpeditionCharacters_Struct) + entries_size; - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionGetOnlineMembers, pack_size)); + auto pack = std::make_unique(ServerOP_ExpeditionGetOnlineMembers, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->sender_zone_id = zone ? zone->GetZoneID() : 0; buf->sender_instance_id = zone ? zone->GetInstanceID() : 0; @@ -1695,7 +1695,7 @@ void Expedition::SendWorldCharacterLockout( uint32_t character_id, const ExpeditionLockoutTimer& lockout, bool remove) { uint32_t pack_size = sizeof(ServerExpeditionCharacterLockout_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionCharacterLockout, pack_size)); + auto pack = std::make_unique(ServerOP_ExpeditionCharacterLockout, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->remove = remove; buf->character_id = character_id; @@ -1710,7 +1710,7 @@ void Expedition::SendWorldCharacterLockout( void Expedition::SendWorldSetSecondsRemaining(uint32_t seconds_remaining) { uint32_t pack_size = sizeof(ServerExpeditionUpdateDuration_Struct); - auto pack = std::unique_ptr(new ServerPacket(ServerOP_ExpeditionSecondsRemaining, pack_size)); + auto pack = std::make_unique(ServerOP_ExpeditionSecondsRemaining, pack_size); auto buf = reinterpret_cast(pack->pBuffer); buf->expedition_id = GetID(); buf->new_duration_seconds = seconds_remaining; diff --git a/zone/main.cpp b/zone/main.cpp index fe32fc0db..c30c9322e 100644 --- a/zone/main.cpp +++ b/zone/main.cpp @@ -484,7 +484,7 @@ int main(int argc, char** argv) { */ if (!websocker_server_opened && Config->ZonePort != 0) { LogInfo("Websocket Server listener started ([{}]:[{}])", Config->TelnetIP.c_str(), Config->ZonePort); - ws_server.reset(new EQ::Net::WebsocketServer(Config->TelnetIP, Config->ZonePort)); + ws_server = std::make_unique(Config->TelnetIP, Config->ZonePort); RegisterApiService(ws_server); websocker_server_opened = true; } @@ -501,7 +501,7 @@ int main(int argc, char** argv) { opts.daybreak_options.resend_delay_min = RuleI(Network, ResendDelayMinMS); opts.daybreak_options.resend_delay_max = RuleI(Network, ResendDelayMaxMS); opts.daybreak_options.outgoing_data_rate = RuleR(Network, ClientDataRate); - eqsm.reset(new EQ::Net::EQStreamManager(opts)); + eqsm = std::make_unique(opts); eqsf_open = true; eqsm->OnNewConnection([&stream_identifier](std::shared_ptr stream) { diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 03651cb3f..6f2fbba61 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -435,13 +435,13 @@ void Mob::AI_Start(uint32 iMoveDelay) { time_until_can_move = 0; pAIControlled = true; - AI_think_timer = std::unique_ptr(new Timer(AIthink_duration)); + AI_think_timer = std::make_unique(AIthink_duration); AI_think_timer->Trigger(); - AI_walking_timer = std::unique_ptr(new Timer(0)); - AI_movement_timer = std::unique_ptr(new Timer(AImovement_duration)); - AI_target_check_timer = std::unique_ptr(new Timer(AItarget_check_duration)); - AI_feign_remember_timer = std::unique_ptr(new Timer(AIfeignremember_delay)); + AI_walking_timer = std::make_unique(0); + AI_movement_timer = std::make_unique(AImovement_duration); + AI_target_check_timer = std::make_unique(AItarget_check_duration); + AI_feign_remember_timer = std::make_unique(AIfeignremember_delay); AI_scan_door_open_timer = std::make_unique(AI_scan_door_open_interval); if (GetBodyType() == BT_Animal && !RuleB(NPC, AnimalsOpenDoors)) { @@ -453,9 +453,9 @@ void Mob::AI_Start(uint32 iMoveDelay) { } if (CastToNPC()->WillAggroNPCs()) - AI_scan_area_timer = std::unique_ptr(new Timer(RandomTimer(RuleI(NPC, NPCToNPCAggroTimerMin), RuleI(NPC, NPCToNPCAggroTimerMax)))); + AI_scan_area_timer = std::make_unique(RandomTimer(RuleI(NPC, NPCToNPCAggroTimerMin), RuleI(NPC, NPCToNPCAggroTimerMax))); - AI_check_signal_timer = std::unique_ptr(new Timer(AI_check_signal_timer_delay)); + AI_check_signal_timer = std::make_unique(AI_check_signal_timer_delay); if (GetAggroRange() == 0) @@ -488,10 +488,10 @@ void NPC::AI_Start(uint32 iMoveDelay) { return; if (AIspells.empty()) { - AIautocastspell_timer = std::unique_ptr(new Timer(1000)); + AIautocastspell_timer = std::make_unique(1000); AIautocastspell_timer->Disable(); } else { - AIautocastspell_timer = std::unique_ptr(new Timer(500)); + AIautocastspell_timer = std::make_unique(500); AIautocastspell_timer->Start(RandomTimer(0, 300), false); } diff --git a/zone/mob_movement_manager.cpp b/zone/mob_movement_manager.cpp index 795a118de..ecef56c3a 100644 --- a/zone/mob_movement_manager.cpp +++ b/zone/mob_movement_manager.cpp @@ -679,7 +679,7 @@ struct MobMovementManager::Implementation { MobMovementManager::MobMovementManager() { - _impl.reset(new Implementation()); + _impl = std::make_unique(); } MobMovementManager::~MobMovementManager() diff --git a/zone/pathfinder_nav_mesh.cpp b/zone/pathfinder_nav_mesh.cpp index 4af9fc0f6..c644a45e0 100644 --- a/zone/pathfinder_nav_mesh.cpp +++ b/zone/pathfinder_nav_mesh.cpp @@ -20,7 +20,7 @@ struct PathfinderNavmesh::Implementation PathfinderNavmesh::PathfinderNavmesh(const std::string &path) { - m_impl.reset(new Implementation()); + m_impl = std::make_unique(); m_impl->nav_mesh = nullptr; m_impl->query = nullptr; Load(path); diff --git a/zone/worldserver.cpp b/zone/worldserver.cpp index a6eadfe82..804a680e2 100644 --- a/zone/worldserver.cpp +++ b/zone/worldserver.cpp @@ -80,14 +80,14 @@ WorldServer::~WorldServer() { void WorldServer::Connect() { - m_connection.reset(new EQ::Net::ServertalkClient(Config->WorldIP, Config->WorldTCPPort, false, "Zone", Config->SharedKey)); + m_connection = std::make_unique(Config->WorldIP, Config->WorldTCPPort, false, "Zone", Config->SharedKey); m_connection->OnConnect([this](EQ::Net::ServertalkClient *client) { OnConnected(); }); m_connection->OnMessage(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2)); - m_keepalive.reset(new EQ::Timer(2500, true, std::bind(&WorldServer::OnKeepAlive, this, std::placeholders::_1))); + m_keepalive = std::make_unique(2500, true, std::bind(&WorldServer::OnKeepAlive, this, std::placeholders::_1)); } bool WorldServer::SendPacket(ServerPacket *pack)