diff --git a/common/eq_stream_ident.cpp b/common/eq_stream_ident.cpp index 8222e471a..764c77143 100644 --- a/common/eq_stream_ident.cpp +++ b/common/eq_stream_ident.cpp @@ -145,7 +145,7 @@ void EQStreamIdentifier::Process() { } void EQStreamIdentifier::AddStream(std::shared_ptr eqs) { - m_streams.push_back(Record(eqs)); + m_streams.emplace_back(Record(eqs)); eqs = nullptr; } diff --git a/common/event/task_scheduler.h b/common/event/task_scheduler.h index 26f45cfe9..7f4c0401b 100644 --- a/common/event/task_scheduler.h +++ b/common/event/task_scheduler.h @@ -38,7 +38,7 @@ namespace EQ _running = true; for (size_t i = 0; i < threads; ++i) { - _threads.push_back(std::thread(std::bind(&TaskScheduler::ProcessWork, this))); + _threads.emplace_back(std::thread(std::bind(&TaskScheduler::ProcessWork, this))); } } diff --git a/common/net/console_server.cpp b/common/net/console_server.cpp index 1b8e8af32..a5276f4cf 100644 --- a/common/net/console_server.cpp +++ b/common/net/console_server.cpp @@ -7,7 +7,7 @@ EQ::Net::ConsoleServer::ConsoleServer(const std::string &addr, int port) 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))); + m_connections.emplace(std::make_pair(c->GetUUID(), std::unique_ptr(c))); }); } diff --git a/common/net/daybreak_connection.cpp b/common/net/daybreak_connection.cpp index 7edb41244..0fefc9982 100644 --- a/common/net/daybreak_connection.cpp +++ b/common/net/daybreak_connection.cpp @@ -97,7 +97,7 @@ void EQ::Net::DaybreakConnectionManager::Connect(const std::string &addr, int po m_on_new_connection(connection); } - m_connections.insert(std::make_pair(std::make_pair(addr, port), connection)); + m_connections.emplace(std::make_pair(std::make_pair(addr, port), connection)); } void EQ::Net::DaybreakConnectionManager::Process() @@ -234,7 +234,7 @@ void EQ::Net::DaybreakConnectionManager::ProcessPacket(const std::string &endpoi if (m_on_new_connection) { m_on_new_connection(connection); } - m_connections.insert(std::make_pair(std::make_pair(endpoint, port), connection)); + m_connections.emplace(std::make_pair(std::make_pair(endpoint, port), connection)); connection->ProcessPacket(p); } else if (data[1] != OP_OutOfSession) { @@ -527,7 +527,7 @@ void EQ::Net::DaybreakConnection::AddToQueue(int stream, uint16_t seq, const Pac DynamicPacket *out = new DynamicPacket(); out->PutPacket(0, p); - s->packet_queue.insert(std::make_pair(seq, out)); + s->packet_queue.emplace(std::make_pair(seq, out)); } } @@ -1427,7 +1427,7 @@ void EQ::Net::DaybreakConnection::InternalQueuePacket(Packet &p, int stream_id, static_cast((m_rolling_ping * m_owner->m_options.resend_delay_factor) + m_owner->m_options.resend_delay_ms), m_owner->m_options.resend_delay_min, m_owner->m_options.resend_delay_max); - stream->sent_packets.insert(std::make_pair(stream->sequence_out, sent)); + stream->sent_packets.emplace(std::make_pair(stream->sequence_out, sent)); stream->sequence_out++; InternalBufferedSend(first_packet); @@ -1459,7 +1459,7 @@ void EQ::Net::DaybreakConnection::InternalQueuePacket(Packet &p, int stream_id, static_cast((m_rolling_ping * m_owner->m_options.resend_delay_factor) + m_owner->m_options.resend_delay_ms), m_owner->m_options.resend_delay_min, m_owner->m_options.resend_delay_max); - stream->sent_packets.insert(std::make_pair(stream->sequence_out, sent)); + stream->sent_packets.emplace(std::make_pair(stream->sequence_out, sent)); stream->sequence_out++; InternalBufferedSend(packet); @@ -1483,7 +1483,7 @@ void EQ::Net::DaybreakConnection::InternalQueuePacket(Packet &p, int stream_id, static_cast((m_rolling_ping * m_owner->m_options.resend_delay_factor) + m_owner->m_options.resend_delay_ms), m_owner->m_options.resend_delay_min, m_owner->m_options.resend_delay_max); - stream->sent_packets.insert(std::make_pair(stream->sequence_out, sent)); + stream->sent_packets.emplace(std::make_pair(stream->sequence_out, sent)); stream->sequence_out++; InternalBufferedSend(packet); diff --git a/common/net/eqstream.cpp b/common/net/eqstream.cpp index c72ad1c4f..34ad10e41 100644 --- a/common/net/eqstream.cpp +++ b/common/net/eqstream.cpp @@ -22,7 +22,7 @@ void EQ::Net::EQStreamManager::SetOptions(const EQStreamManagerInterfaceOptions void EQ::Net::EQStreamManager::DaybreakNewConnection(std::shared_ptr connection) { std::shared_ptr stream(new EQStream(this, connection)); - m_streams.insert(std::make_pair(connection, stream)); + m_streams.emplace(std::make_pair(connection, stream)); if (m_on_new_connection) { m_on_new_connection(stream); } diff --git a/common/net/servertalk_client_connection.cpp b/common/net/servertalk_client_connection.cpp index 0c789330d..d873d43ca 100644 --- a/common/net/servertalk_client_connection.cpp +++ b/common/net/servertalk_client_connection.cpp @@ -45,7 +45,7 @@ void EQ::Net::ServertalkClient::SendPacket(ServerPacket *p) void EQ::Net::ServertalkClient::OnMessage(uint16_t opcode, std::function cb) { - m_message_callbacks.insert(std::make_pair(opcode, cb)); + m_message_callbacks.emplace(std::make_pair(opcode, cb)); } void EQ::Net::ServertalkClient::OnMessage(std::function cb) diff --git a/common/net/servertalk_legacy_client_connection.cpp b/common/net/servertalk_legacy_client_connection.cpp index 8be329e65..8f2260dd6 100644 --- a/common/net/servertalk_legacy_client_connection.cpp +++ b/common/net/servertalk_legacy_client_connection.cpp @@ -41,7 +41,7 @@ void EQ::Net::ServertalkLegacyClient::SendPacket(ServerPacket *p) void EQ::Net::ServertalkLegacyClient::OnMessage(uint16_t opcode, std::function cb) { - m_message_callbacks.insert(std::make_pair(opcode, cb)); + m_message_callbacks.emplace(std::make_pair(opcode, cb)); } void EQ::Net::ServertalkLegacyClient::OnMessage(std::function cb) diff --git a/common/net/servertalk_server.cpp b/common/net/servertalk_server.cpp index d362362d3..33e1293f9 100644 --- a/common/net/servertalk_server.cpp +++ b/common/net/servertalk_server.cpp @@ -19,12 +19,12 @@ void EQ::Net::ServertalkServer::Listen(const ServertalkServerOptions& opts) void EQ::Net::ServertalkServer::OnConnectionIdentified(const std::string &type, std::function)> cb) { - m_on_ident.insert(std::make_pair(type, cb)); + m_on_ident.emplace(std::make_pair(type, cb)); } void EQ::Net::ServertalkServer::OnConnectionRemoved(const std::string &type, std::function)> cb) { - m_on_disc.insert(std::make_pair(type, cb)); + m_on_disc.emplace(std::make_pair(type, cb)); } void EQ::Net::ServertalkServer::ConnectionDisconnected(ServertalkServerConnection *conn) @@ -75,7 +75,7 @@ void EQ::Net::ServertalkServer::ConnectionIdentified(ServertalkServerConnection else { std::vector> vec; vec.push_back(*iter); - m_ident_connections.insert(std::make_pair(conn->GetIdentifier(), vec)); + m_ident_connections.emplace(std::make_pair(conn->GetIdentifier(), vec)); } m_unident_connections.erase(iter); diff --git a/common/net/servertalk_server_connection.cpp b/common/net/servertalk_server_connection.cpp index 405f85f73..ad86727ef 100644 --- a/common/net/servertalk_server_connection.cpp +++ b/common/net/servertalk_server_connection.cpp @@ -100,7 +100,7 @@ void EQ::Net::ServertalkServerConnection::SendPacket(ServerPacket *p) void EQ::Net::ServertalkServerConnection::OnMessage(uint16_t opcode, std::function cb) { - m_message_callbacks.insert(std::make_pair(opcode, cb)); + m_message_callbacks.emplace(std::make_pair(opcode, cb)); } void EQ::Net::ServertalkServerConnection::OnMessage(std::function cb) diff --git a/common/rulesys.cpp b/common/rulesys.cpp index 95b72dc59..0fbd2fa89 100644 --- a/common/rulesys.cpp +++ b/common/rulesys.cpp @@ -369,7 +369,7 @@ void RuleManager::_SaveRule(Database *db, RuleType type, uint16 index) { break; } - const auto rule_notes = _GetRuleNotes(type, index); + const auto& rule_notes = _GetRuleNotes(type, index); const auto& l = RuleValuesRepository::GetWhere( *db, diff --git a/common/stacktrace/backward.hpp b/common/stacktrace/backward.hpp index c2a81628e..12771df08 100644 --- a/common/stacktrace/backward.hpp +++ b/common/stacktrace/backward.hpp @@ -658,11 +658,11 @@ typedef pdb_symbol current; size_t next = 0; size_t delimiter_size = sizeof(kBackwardPathDelimiter) - 1; while ((next = s.find(kBackwardPathDelimiter, last)) != std::string::npos) { - out.push_back(s.substr(last, next - last)); + out.emplace_back(s.substr(last, next - last)); last = next + delimiter_size; } if (last <= s.length()) { - out.push_back(s.substr(last)); + out.emplace_back(s.substr(last)); } return out; } @@ -3760,7 +3760,7 @@ private: continue; started = true; } - lines.push_back(make_pair(line_idx, line)); + lines.emplace_back(make_pair(line_idx, line)); } lines.erase( diff --git a/common/strings.cpp b/common/strings.cpp index dc50b0020..570874b54 100644 --- a/common/strings.cpp +++ b/common/strings.cpp @@ -76,7 +76,7 @@ std::vector Strings::Split(const std::string& s, const std::string& res.push_back(token); } - res.push_back(s.substr(pos_start)); + res.emplace_back(s.substr(pos_start)); return res; } diff --git a/common/strings.h b/common/strings.h index f74da2407..b2d4dfef5 100644 --- a/common/strings.h +++ b/common/strings.h @@ -219,7 +219,7 @@ std::vector join_pair( std::vector output; for (const std::pair &src_iter: src) { - output.push_back( + output.emplace_back( fmt::format( "{}{}{}{}{}{}{}", @@ -253,7 +253,7 @@ std::vector join_tuple( for (const std::tuple &src_iter: src) { - output.push_back( + output.emplace_back( fmt::format( "{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}", diff --git a/loginserver/loginserver_webserver.cpp b/loginserver/loginserver_webserver.cpp index e7f3f5a3b..f7c353181 100644 --- a/loginserver/loginserver_webserver.cpp +++ b/loginserver/loginserver_webserver.cpp @@ -490,7 +490,7 @@ namespace LoginserverWebserver { token_data.can_write ); - server.token_manager->loaded_api_tokens.insert( + server.token_manager->loaded_api_tokens.emplace( std::make_pair( token_data.token, token_data diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp index 62918b0c7..cbb6e0910 100644 --- a/ucs/clientlist.cpp +++ b/ucs/clientlist.cpp @@ -122,11 +122,11 @@ std::vector ParseRecipients(std::string RecipientString) { if (Comma == std::string::npos) { - RecipientList.push_back(RecipientString.substr(CurrentPos)); + RecipientList.emplace_back(RecipientString.substr(CurrentPos)); break; } - RecipientList.push_back(RecipientString.substr(CurrentPos, Comma - CurrentPos)); + RecipientList.emplace_back(RecipientString.substr(CurrentPos, Comma - CurrentPos)); CurrentPos = Comma + 2; } diff --git a/world/login_server_list.cpp b/world/login_server_list.cpp index efd9c1d91..30285c72a 100644 --- a/world/login_server_list.cpp +++ b/world/login_server_list.cpp @@ -52,7 +52,7 @@ LoginServerList::~LoginServerList() { void LoginServerList::Add(const char* iAddress, uint16 iPort, const char* Account, const char* Password, bool Legacy) { auto loginserver = new LoginServer(iAddress, iPort, Account, Password, Legacy); - m_list.push_back(std::unique_ptr(loginserver)); + m_list.emplace_back(std::unique_ptr(loginserver)); } bool LoginServerList::SendStatus() { diff --git a/world/queryserv.cpp b/world/queryserv.cpp index 8708b6c31..0611e7d50 100644 --- a/world/queryserv.cpp +++ b/world/queryserv.cpp @@ -21,7 +21,7 @@ void QueryServConnection::AddConnection(std::shared_ptrOnMessage(ServerOP_QueryServGeneric, std::bind(&QueryServConnection::HandleGenericMessage, this, std::placeholders::_1, std::placeholders::_2)); connection->OnMessage(ServerOP_LFGuildUpdate, std::bind(&QueryServConnection::HandleLFGuildUpdateMessage, this, std::placeholders::_1, std::placeholders::_2)); - m_streams.insert(std::make_pair(connection->GetUUID(), connection)); + m_streams.emplace(std::make_pair(connection->GetUUID(), connection)); m_keepalive = std::make_unique(1000, true, std::bind(&QueryServConnection::OnKeepAlive, this, std::placeholders::_1)); } diff --git a/world/shared_task_manager.cpp b/world/shared_task_manager.cpp index 50a3f5b1d..42e0a41fa 100644 --- a/world/shared_task_manager.cpp +++ b/world/shared_task_manager.cpp @@ -1545,7 +1545,7 @@ bool SharedTaskManager::CanAddPlayer(SharedTask *s, uint32_t character_id, std:: void SharedTaskManager::RecordSharedTaskCompletion(SharedTask *s) { // shared task - auto t = s->GetDbSharedTask(); + auto& t = s->GetDbSharedTask(); auto ct = CompletedSharedTasksRepository::NewEntity(); ct.id = t.id; diff --git a/world/web_interface.cpp b/world/web_interface.cpp index 234031770..1de21b4e4 100644 --- a/world/web_interface.cpp +++ b/world/web_interface.cpp @@ -123,7 +123,7 @@ void WebInterface::SendEvent(const Json::Value &value) void WebInterface::AddCall(const std::string &method, WebInterfaceCall call) { - m_calls.insert(std::make_pair(method, call)); + m_calls.emplace(std::make_pair(method, call)); } void WebInterface::SendResponse(const std::string &id, const Json::Value &response) @@ -146,7 +146,7 @@ WebInterfaceList::~WebInterfaceList() void WebInterfaceList::AddConnection(std::shared_ptr connection) { - m_interfaces.insert(std::make_pair(connection->GetUUID(), std::make_unique(connection))); + m_interfaces.emplace(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 7ba848929..701fc2400 100644 --- a/world/zonelist.cpp +++ b/world/zonelist.cpp @@ -64,7 +64,7 @@ void ZSList::ShowUpTime(WorldTCPConnection* con, const char* adminname) { } void ZSList::Add(ZoneServer* zoneserver) { - zone_server_list.push_back(std::unique_ptr(zoneserver)); + zone_server_list.emplace_back(std::unique_ptr(zoneserver)); zoneserver->SendGroupIDs(); } diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index a891cf852..8c682a3b3 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -1481,7 +1481,7 @@ int bot_command_init(void) auto bcs_iter = bot_command_settings.find(working_bcl_iter.first); if (bcs_iter == bot_command_settings.end()) { - injected_bot_command_settings.push_back(std::pair(working_bcl_iter.first, working_bcl_iter.second->access)); + injected_bot_command_settings.emplace_back(std::pair(working_bcl_iter.first, working_bcl_iter.second->access)); LogInfo( "New Bot Command [{}] found... Adding to `bot_command_settings` table with access [{}]", working_bcl_iter.first.c_str(), diff --git a/zone/bot_database.cpp b/zone/bot_database.cpp index a47174665..e44bca40d 100644 --- a/zone/bot_database.cpp +++ b/zone/bot_database.cpp @@ -1173,7 +1173,7 @@ bool BotDatabase::LoadItemSlots(const uint32 bot_id, std::map& m if (!l.empty()) { for (const auto& e : l) { - m.insert(std::pair(e.slot_id, e.item_id)); + m.emplace(std::pair(e.slot_id, e.item_id)); } } diff --git a/zone/botspellsai.cpp b/zone/botspellsai.cpp index b42e4d2cf..76f95c4db 100644 --- a/zone/botspellsai.cpp +++ b/zone/botspellsai.cpp @@ -242,7 +242,7 @@ bool Bot::BotCastCure(Mob* tar, uint8 botClass, BotSpell& botSpell, Raid* raid) uint32 r_group = raid->GetGroup(GetName()); if (r_group) { std::vector raid_group_members = raid->GetRaidGroupMembers(r_group); - for (auto iter: raid_group_members) { + for (auto& iter: raid_group_members) { if ( iter.member && !iter.member->qglobal && @@ -3433,7 +3433,7 @@ DBbotspells_Struct* ZoneDatabase::GetBotSpells(uint32 bot_spell_id) } } - bot_spells_cache.insert(std::make_pair(bot_spell_id, spell_set)); + bot_spells_cache.emplace(std::make_pair(bot_spell_id, spell_set)); return &bot_spells_cache[bot_spell_id]; } diff --git a/zone/client.cpp b/zone/client.cpp index 3aa05cd05..ca23ee496 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -8180,7 +8180,7 @@ void Client::TryItemTimer(int slot) continue; } - auto item_timers = a_inst->GetTimers(); + auto& item_timers = a_inst->GetTimers(); auto it_iter = item_timers.begin(); while(it_iter != item_timers.end()) { if(it_iter->second.Check()) { @@ -9984,7 +9984,7 @@ void Client::SendDzCompassUpdate() for (const auto& client_dz : GetDynamicZones()) { - auto compass = client_dz->GetCompassLocation(); + auto& compass = client_dz->GetCompassLocation(); if (zone && zone->IsZone(compass.zone_id, 0)) { DynamicZoneCompassEntry_Struct entry{}; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index c6e89406a..81088d182 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1720,7 +1720,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) auto dz = zone->GetDynamicZone(); if (dz && dz->GetSafeReturnLocation().zone_id != 0) { - auto safereturn = dz->GetSafeReturnLocation(); + auto& safereturn = dz->GetSafeReturnLocation(); auto safereturn_entry = CharacterInstanceSafereturnsRepository::NewEntity(); safereturn_entry.character_id = CharacterID(); @@ -5366,7 +5366,7 @@ void Client::Handle_OP_CorpseDrag(const EQApplicationPacket *app) if (!corpse->CastToCorpse()->Summon(this, false, true)) return; - DraggedCorpses.push_back(std::pair(cds->CorpseName, corpse->GetID())); + DraggedCorpses.emplace_back(std::pair(cds->CorpseName, corpse->GetID())); MessageString(Chat::DefaultText, CORPSEDRAG_BEGIN, cds->CorpseName); } diff --git a/zone/command.cpp b/zone/command.cpp index 883fecc5e..979d782bf 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -396,7 +396,7 @@ int command_init(void) for (const auto& w : working_cl) { auto cs = command_settings.find(w.first); if (cs == command_settings.end()) { - injected_command_settings.push_back(std::pair(w.first, w.second->admin)); + injected_command_settings.emplace_back(std::pair(w.first, w.second->admin)); LogInfo( "New Command [{}] found... Adding to `command_settings` table with admin [{}]...", w.first, diff --git a/zone/corpse.cpp b/zone/corpse.cpp index ff3bbdba1..ea6bd14de 100644 --- a/zone/corpse.cpp +++ b/zone/corpse.cpp @@ -749,7 +749,7 @@ bool Corpse::Save() { e.ornamentidfile = item->ornamentidfile; e.ornament_hero_model = item->ornament_hero_model; - ce.items.push_back(std::move(e)); + ce.items.emplace_back(std::move(e)); } /* Create New Corpse*/ diff --git a/zone/dialogue_window.cpp b/zone/dialogue_window.cpp index 3f28d472d..1b3d0203b 100644 --- a/zone/dialogue_window.cpp +++ b/zone/dialogue_window.cpp @@ -284,7 +284,7 @@ void DialogueWindow::Render(Client *c, std::string markdown) size_t link_open = bracket_message.find('\x12'); size_t link_close = bracket_message.find_last_of('\x12'); if (link_open != link_close && (bracket_message.length() - link_open) > EQ::constants::SAY_LINK_BODY_SIZE) { - replacements.insert( + replacements.emplace( std::pair( bracket_message, bracket_message.substr(EQ::constants::SAY_LINK_BODY_SIZE + 1) diff --git a/zone/entity.cpp b/zone/entity.cpp index ea4e0e4d2..12725a3d6 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -329,8 +329,8 @@ bool EntityList::CanAddHateForMob(Mob *p) void EntityList::AddClient(Client *client) { client->SetID(GetFreeID()); - client_list.insert(std::pair(client->GetID(), client)); - mob_list.insert(std::pair(client->GetID(), client)); + client_list.emplace(std::pair(client->GetID(), client)); + mob_list.emplace(std::pair(client->GetID(), client)); } @@ -652,7 +652,7 @@ void EntityList::AddCorpse(Corpse *corpse, uint32 in_id) corpse->SetID(in_id); corpse->CalcCorpseName(); - corpse_list.insert(std::pair(corpse->GetID(), corpse)); + corpse_list.emplace(std::pair(corpse->GetID(), corpse)); if (!corpse_timer.Enabled()) corpse_timer.Start(); @@ -671,8 +671,8 @@ void EntityList::AddNPC(NPC *npc, bool send_spawn_packet, bool dont_queue) } } - npc_list.insert(std::pair(npc->GetID(), npc)); - mob_list.insert(std::pair(npc->GetID(), npc)); + npc_list.emplace(std::pair(npc->GetID(), npc)); + mob_list.emplace(std::pair(npc->GetID(), npc)); if (parse->HasQuestSub(npc->GetNPCTypeID(), EVENT_SPAWN)) { parse->EventNPC(EVENT_SPAWN, npc, nullptr, "", 0); @@ -752,8 +752,8 @@ void EntityList::AddMerc(Merc *merc, bool SendSpawnPacket, bool dontqueue) } } - merc_list.insert(std::pair(merc->GetID(), merc)); - mob_list.insert(std::pair(merc->GetID(), merc)); + merc_list.emplace(std::pair(merc->GetID(), merc)); + mob_list.emplace(std::pair(merc->GetID(), merc)); } } @@ -770,7 +770,7 @@ void EntityList::AddObject(Object *obj, bool SendSpawnPacket) QueueClients(0, &app,false); } - object_list.insert(std::pair(obj->GetID(), obj)); + object_list.emplace(std::pair(obj->GetID(), obj)); if (!object_timer.Enabled()) object_timer.Start(); @@ -779,7 +779,7 @@ void EntityList::AddObject(Object *obj, bool SendSpawnPacket) void EntityList::AddDoor(Doors *door) { door->SetEntityID(GetFreeID()); - door_list.insert(std::pair(door->GetEntityID(), door)); + door_list.emplace(std::pair(door->GetEntityID(), door)); if (!door_timer.Enabled()) door_timer.Start(); @@ -788,7 +788,7 @@ void EntityList::AddDoor(Doors *door) void EntityList::AddTrap(Trap *trap) { trap->SetID(GetFreeID()); - trap_list.insert(std::pair(trap->GetID(), trap)); + trap_list.emplace(std::pair(trap->GetID(), trap)); if (!trap_timer.Enabled()) trap_timer.Start(); } @@ -796,13 +796,13 @@ void EntityList::AddTrap(Trap *trap) void EntityList::AddBeacon(Beacon *beacon) { beacon->SetID(GetFreeID()); - beacon_list.insert(std::pair(beacon->GetID(), beacon)); + beacon_list.emplace(std::pair(beacon->GetID(), beacon)); } void EntityList::AddEncounter(Encounter *encounter) { encounter->SetID(GetFreeID()); - encounter_list.insert(std::pair(encounter->GetID(), encounter)); + encounter_list.emplace(std::pair(encounter->GetID(), encounter)); } void EntityList::AddToSpawnQueue(uint16 entityid, NewSpawn_Struct **ns) @@ -2984,7 +2984,7 @@ void EntityList::ScanCloseMobs( float distance = DistanceSquared(scanning_mob->GetPosition(), mob->GetPosition()); if (distance <= scan_range || mob->GetAggroRange() >= scan_range) { - close_mobs.insert(std::pair(mob->GetID(), mob)); + close_mobs.emplace(std::pair(mob->GetID(), mob)); if (add_self_to_other_lists && scanning_mob->GetID() > 0) { bool has_mob = false; diff --git a/zone/gm_commands/dye.cpp b/zone/gm_commands/dye.cpp index 4f2d39c1d..7fa4c73a2 100755 --- a/zone/gm_commands/dye.cpp +++ b/zone/gm_commands/dye.cpp @@ -32,7 +32,7 @@ void command_dye(Client *c, const Seperator *sep) c->Message(Chat::White, "Red, Green, and Blue go from 0 to 255."); for (const auto &slot : dye_slots) { - slot_messages.push_back(fmt::format("({}) {}", slot_id, slot)); + slot_messages.emplace_back(fmt::format("({}) {}", slot_id, slot)); slot_id++; } diff --git a/zone/gm_commands/mysql.cpp b/zone/gm_commands/mysql.cpp index 38cb60430..1b915f471 100755 --- a/zone/gm_commands/mysql.cpp +++ b/zone/gm_commands/mysql.cpp @@ -56,7 +56,7 @@ void command_mysql(Client *c, const Seperator *sep) row_index < results.ColumnCount(); row_index++ ) { - lines.push_back( + lines.emplace_back( fmt::format( "{} | {} ", results.FieldName(row_index), diff --git a/zone/gm_commands/set_adventure_points.cpp b/zone/gm_commands/set_adventure_points.cpp index 160344fd2..89a309b94 100755 --- a/zone/gm_commands/set_adventure_points.cpp +++ b/zone/gm_commands/set_adventure_points.cpp @@ -35,7 +35,7 @@ void command_set_adventure_points(Client *c, const Seperator *sep) auto theme_id = Strings::ToUnsignedInt(sep->arg[1]); if (!EQ::ValueWithin(theme_id, LDoNThemes::Unused, LDoNThemes::TAK)) { c->Message(Chat::White, "Valid themes are as follows."); - auto theme_map = EQ::constants::GetLDoNThemeMap(); + auto& theme_map = EQ::constants::GetLDoNThemeMap(); for (const auto& theme : theme_map) { c->Message( Chat::White, diff --git a/zone/gm_commands/suspendmulti.cpp b/zone/gm_commands/suspendmulti.cpp index b2ff2fb1c..1d087b486 100755 --- a/zone/gm_commands/suspendmulti.cpp +++ b/zone/gm_commands/suspendmulti.cpp @@ -16,7 +16,7 @@ void command_suspendmulti(Client *c, const Seperator *sep) const auto& n = Strings::Split(sep->arg[1], "|"); std::vector v; for (const auto& c : n) { - v.push_back(fmt::format("'{}'", Strings::ToLower(c))); + v.emplace_back(fmt::format("'{}'", Strings::ToLower(c))); } auto days = Strings::ToUnsignedInt(sep->arg[2]); diff --git a/zone/lua_entity_list.cpp b/zone/lua_entity_list.cpp index fac098d11..0b9438fd3 100644 --- a/zone/lua_entity_list.cpp +++ b/zone/lua_entity_list.cpp @@ -347,7 +347,7 @@ Lua_Mob_List Lua_EntityList::GetMobList() { auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_Mob(iter->second)); + ret.entries.emplace_back(Lua_Mob(iter->second)); ++iter; } @@ -361,7 +361,7 @@ Lua_Client_List Lua_EntityList::GetClientList() { auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_Client(iter->second)); + ret.entries.emplace_back(Lua_Client(iter->second)); ++iter; } @@ -385,7 +385,7 @@ Lua_Bot_List Lua_EntityList::GetBotList() { if (bot_list.size()) { for (auto bot : bot_list) { - ret.entries.push_back(Lua_Bot(bot)); + ret.entries.emplace_back(Lua_Bot(bot)); } } @@ -409,7 +409,7 @@ Lua_Bot_List Lua_EntityList::GetBotListByCharacterID(uint32 character_id) { if (bot_list.size()) { for (auto bot : bot_list) { - ret.entries.push_back(Lua_Bot(bot)); + ret.entries.emplace_back(Lua_Bot(bot)); } } @@ -423,7 +423,7 @@ Lua_Bot_List Lua_EntityList::GetBotListByCharacterID(uint32 character_id, uint8 if (bot_list.size()) { for (auto bot : bot_list) { - ret.entries.push_back(Lua_Bot(bot)); + ret.entries.emplace_back(Lua_Bot(bot)); } } @@ -437,7 +437,7 @@ Lua_Bot_List Lua_EntityList::GetBotListByClientName(std::string client_name) { if (bot_list.size()) { for (auto bot : bot_list) { - ret.entries.push_back(Lua_Bot(bot)); + ret.entries.emplace_back(Lua_Bot(bot)); } } @@ -451,7 +451,7 @@ Lua_Bot_List Lua_EntityList::GetBotListByClientName(std::string client_name, uin if (bot_list.size()) { for (auto bot : bot_list) { - ret.entries.push_back(Lua_Bot(bot)); + ret.entries.emplace_back(Lua_Bot(bot)); } } @@ -485,7 +485,7 @@ Lua_Client_List Lua_EntityList::GetShuffledClientList() { auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_Client(iter->second)); + ret.entries.emplace_back(Lua_Client(iter->second)); ++iter; } @@ -501,7 +501,7 @@ Lua_NPC_List Lua_EntityList::GetNPCList() { auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_NPC(iter->second)); + ret.entries.emplace_back(Lua_NPC(iter->second)); ++iter; } @@ -515,7 +515,7 @@ Lua_Corpse_List Lua_EntityList::GetCorpseList() { auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_Corpse(iter->second)); + ret.entries.emplace_back(Lua_Corpse(iter->second)); ++iter; } @@ -529,7 +529,7 @@ Lua_Object_List Lua_EntityList::GetObjectList() { auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_Object(iter->second)); + ret.entries.emplace_back(Lua_Object(iter->second)); ++iter; } @@ -543,7 +543,7 @@ Lua_Doors_List Lua_EntityList::GetDoorsList() { auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_Door(iter->second)); + ret.entries.emplace_back(Lua_Door(iter->second)); ++iter; } @@ -558,7 +558,7 @@ Lua_Spawn_List Lua_EntityList::GetSpawnList() { auto iter = t_list.begin(); while(iter != t_list.end()) { - ret.entries.push_back(Lua_Spawn(*iter)); + ret.entries.emplace_back(Lua_Spawn(*iter)); ++iter; } diff --git a/zone/mob.cpp b/zone/mob.cpp index 4b697b2d6..8823a9e12 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -6052,14 +6052,14 @@ void Mob::AddFactionBonus(uint32 pFactionID,int32 bonus) { faction_bonus = faction_bonuses.find(pFactionID); if(faction_bonus == faction_bonuses.end()) { - faction_bonuses.insert(NewFactionBonus(pFactionID,bonus)); + faction_bonuses.emplace(NewFactionBonus(pFactionID,bonus)); } else { if(faction_bonus->second 0 && faction_bonus->second < bonus) || (bonus < 0 && faction_bonus->second > bonus)) { item_faction_bonuses.erase(pFactionID); - item_faction_bonuses.insert(NewFactionBonus(pFactionID,bonus)); + item_faction_bonuses.emplace(NewFactionBonus(pFactionID,bonus)); } } } diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 5f2ceb568..e0c08bf58 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -2919,7 +2919,7 @@ DBnpcspells_Struct *ZoneDatabase::GetNPCSpells(uint32 iDBSpellsID) spell_set.entries.push_back(entry); } - npc_spells_cache.insert(std::make_pair(iDBSpellsID, spell_set)); + npc_spells_cache.emplace(std::make_pair(iDBSpellsID, spell_set)); return &npc_spells_cache[iDBSpellsID]; } diff --git a/zone/mob_movement_manager.cpp b/zone/mob_movement_manager.cpp index 530fd3f5a..1b4af7cd0 100644 --- a/zone/mob_movement_manager.cpp +++ b/zone/mob_movement_manager.cpp @@ -1395,7 +1395,7 @@ void MobMovementManager::UpdatePathBoat(Mob *who, float x, float y, float z, Mob */ void MobMovementManager::PushTeleportTo(MobMovementEntry &ent, float x, float y, float z, float heading) { - ent.Commands.push_back(std::unique_ptr(new TeleportToCommand(x, y, z, heading))); + ent.Commands.emplace_back(std::unique_ptr(new TeleportToCommand(x, y, z, heading))); } /** @@ -1407,7 +1407,7 @@ void MobMovementManager::PushTeleportTo(MobMovementEntry &ent, float x, float y, */ void MobMovementManager::PushMoveTo(MobMovementEntry &ent, float x, float y, float z, MobMovementMode mob_movement_mode) { - ent.Commands.push_back(std::unique_ptr(new MoveToCommand(x, y, z, mob_movement_mode))); + ent.Commands.emplace_back(std::unique_ptr(new MoveToCommand(x, y, z, mob_movement_mode))); } /** @@ -1419,7 +1419,7 @@ void MobMovementManager::PushMoveTo(MobMovementEntry &ent, float x, float y, flo */ void MobMovementManager::PushSwimTo(MobMovementEntry &ent, float x, float y, float z, MobMovementMode mob_movement_mode) { - ent.Commands.push_back(std::unique_ptr(new SwimToCommand(x, y, z, mob_movement_mode))); + ent.Commands.emplace_back(std::unique_ptr(new SwimToCommand(x, y, z, mob_movement_mode))); } /** @@ -1447,7 +1447,7 @@ void MobMovementManager::PushRotateTo(MobMovementEntry &ent, Mob *who, float to, diff -= 512.0; } - ent.Commands.push_back(std::unique_ptr(new RotateToCommand(to, diff > 0 ? 1.0 : -1.0, mob_movement_mode))); + ent.Commands.emplace_back(std::unique_ptr(new RotateToCommand(to, diff > 0 ? 1.0 : -1.0, mob_movement_mode))); } /** @@ -1459,7 +1459,7 @@ void MobMovementManager::PushRotateTo(MobMovementEntry &ent, Mob *who, float to, */ void MobMovementManager::PushFlyTo(MobMovementEntry &ent, float x, float y, float z, MobMovementMode mob_movement_mode) { - ent.Commands.push_back(std::unique_ptr(new FlyToCommand(x, y, z, mob_movement_mode))); + ent.Commands.emplace_back(std::unique_ptr(new FlyToCommand(x, y, z, mob_movement_mode))); } /** @@ -1467,7 +1467,7 @@ void MobMovementManager::PushFlyTo(MobMovementEntry &ent, float x, float y, floa */ void MobMovementManager::PushStopMoving(MobMovementEntry &mob_movement_entry) { - mob_movement_entry.Commands.push_back(std::unique_ptr(new StopMovingCommand())); + mob_movement_entry.Commands.emplace_back(std::unique_ptr(new StopMovingCommand())); } /** @@ -1475,7 +1475,7 @@ void MobMovementManager::PushStopMoving(MobMovementEntry &mob_movement_entry) */ void MobMovementManager::PushEvadeCombat(MobMovementEntry &mob_movement_entry) { - mob_movement_entry.Commands.push_back(std::unique_ptr(new EvadeCombatCommand())); + mob_movement_entry.Commands.emplace_back(std::unique_ptr(new EvadeCombatCommand())); } /** diff --git a/zone/npc.cpp b/zone/npc.cpp index e461541ab..2ebb86482 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -1918,7 +1918,7 @@ void NPC::PickPocket(Client* thief) if (item_test->Magic || !item_test->NoDrop || item_test->IsClassBag() || thief->CheckLoreConflict(item_test) || item_iter->equip_slot != EQ::invslot::SLOT_INVALID) continue; - loot_selection.push_back(std::make_pair(item_test, ((item_test->Stackable) ? (1) : (item_iter->charges)))); + loot_selection.emplace_back(std::make_pair(item_test, ((item_test->Stackable) ? (1) : (item_iter->charges)))); } if (loot_selection.empty()) { steal_item = false; diff --git a/zone/npc_scale_manager.cpp b/zone/npc_scale_manager.cpp index dca176e47..5831cafea 100644 --- a/zone/npc_scale_manager.cpp +++ b/zone/npc_scale_manager.cpp @@ -278,7 +278,7 @@ bool NpcScaleManager::LoadScaleData() scale_data.zone_id = Strings::ToUnsignedInt(s.zone_id_list); scale_data.instance_version = static_cast(Strings::ToUnsignedInt(s.instance_version_list)); - npc_global_base_scaling_data.insert( + npc_global_base_scaling_data.emplace( std::make_pair( std::make_tuple( scale_data.type, @@ -297,7 +297,7 @@ bool NpcScaleManager::LoadScaleData() for (const auto &z : zones) { scale_data.zone_id = Strings::ToUnsignedInt(z); - npc_global_base_scaling_data.insert( + npc_global_base_scaling_data.emplace( std::make_pair( std::make_tuple( scale_data.type, @@ -317,7 +317,7 @@ bool NpcScaleManager::LoadScaleData() for (const auto &v : versions) { scale_data.instance_version = static_cast(Strings::ToUnsignedInt(v)); - npc_global_base_scaling_data.insert( + npc_global_base_scaling_data.emplace( std::make_pair( std::make_tuple( scale_data.type, @@ -339,7 +339,7 @@ bool NpcScaleManager::LoadScaleData() for (const auto &v : versions) { scale_data.instance_version = static_cast(Strings::ToUnsignedInt(v)); - npc_global_base_scaling_data.insert( + npc_global_base_scaling_data.emplace( std::make_pair( std::make_tuple( scale_data.type, diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index cdf961298..8d5cf1d1f 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -483,7 +483,7 @@ void QuestManager::settimer(const char* timer_name, int seconds, Mob* mob) { ++cur; } - QTimerList.push_back(QuestTimer(seconds * 1000, owner, timer_name)); + QTimerList.emplace_back(QuestTimer(seconds * 1000, owner, timer_name)); } void QuestManager::settimerMS(const char* timer_name, int milliseconds) { @@ -507,7 +507,7 @@ void QuestManager::settimerMS(const char* timer_name, int milliseconds) { ++cur; } - QTimerList.push_back(QuestTimer(milliseconds, owner, timer_name)); + QTimerList.emplace_back(QuestTimer(milliseconds, owner, timer_name)); } void QuestManager::settimerMS(const char* timer_name, int milliseconds, EQ::ItemInstance *inst) { @@ -530,7 +530,7 @@ void QuestManager::settimerMS(const char* timer_name, int milliseconds, Mob *mob ++cur; } - QTimerList.push_back(QuestTimer(milliseconds, mob, timer_name)); + QTimerList.emplace_back(QuestTimer(milliseconds, mob, timer_name)); } void QuestManager::stoptimer(const char* timer_name) { @@ -685,7 +685,7 @@ void QuestManager::resumetimer(const char* timer_name, Mob* mob) { ++cur; } - QTimerList.push_back(QuestTimer(milliseconds, m, timer_name)); + QTimerList.emplace_back(QuestTimer(milliseconds, m, timer_name)); LogQuests("Creating a new timer and resuming [{}] for [{}] with [{}] ms remaining", timer_name, owner->GetName(), milliseconds); } @@ -1466,10 +1466,10 @@ void QuestManager::itemlink(int item_id) { void QuestManager::signalwith(int npc_id, int signal_id, int wait_ms) { if(wait_ms > 0) { - STimerList.push_back(SignalTimer(wait_ms, npc_id, signal_id)); + STimerList.emplace_back(SignalTimer(wait_ms, npc_id, signal_id)); return; } else { - STimerList.push_back(SignalTimer(0, npc_id, signal_id)); + STimerList.emplace_back(SignalTimer(0, npc_id, signal_id)); return; } } diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index c07e75ede..a76fd1150 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -1609,7 +1609,7 @@ bool ZoneDatabase::GetTradeRecipe( for(auto row = results.begin(); row != results.end(); ++row) { uint32 item = (uint32)Strings::ToInt(row[0]); uint8 num = (uint8) Strings::ToInt(row[1]); - spec->onsuccess.push_back(std::pair(item, num)); + spec->onsuccess.emplace_back(std::pair(item, num)); } spec->onfail.clear(); @@ -1623,7 +1623,7 @@ bool ZoneDatabase::GetTradeRecipe( for (auto row = results.begin(); row != results.end(); ++row) { uint32 item = (uint32) Strings::ToInt(row[0]); uint8 num = (uint8) Strings::ToInt(row[1]); - spec->onfail.push_back(std::pair(item, num)); + spec->onfail.emplace_back(std::pair(item, num)); } } @@ -1646,7 +1646,7 @@ bool ZoneDatabase::GetTradeRecipe( for (auto row = results.begin(); row != results.end(); ++row) { uint32 item = (uint32) Strings::ToInt(row[0]); uint8 num = (uint8) Strings::ToInt(row[1]); - spec->salvage.push_back(std::pair(item, num)); + spec->salvage.emplace_back(std::pair(item, num)); } } diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index d0450674c..95c3d324a 100755 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -1684,7 +1684,7 @@ void ZoneDatabase::ListCharacterInvSnapshots(uint32 character_id, std::list(Strings::ToUnsignedInt(row[0]), Strings::ToInt(row[1]))); + is_list.emplace_back(std::pair(Strings::ToUnsignedInt(row[0]), Strings::ToInt(row[1]))); } bool ZoneDatabase::ValidateCharacterInvSnapshotTimestamp(uint32 character_id, uint32 timestamp) { @@ -1734,7 +1734,7 @@ void ZoneDatabase::ParseCharacterInvSnapshot(uint32 character_id, uint32 timesta return; for (auto row : results) - parse_list.push_back(std::pair(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1]))); + parse_list.emplace_back(std::pair(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1]))); } void ZoneDatabase::DivergeCharacterInvSnapshotFromInventory(uint32 character_id, uint32 timestamp, std::list> &compare_list) { @@ -1778,7 +1778,7 @@ void ZoneDatabase::DivergeCharacterInvSnapshotFromInventory(uint32 character_id, return; for (auto row : results) - compare_list.push_back(std::pair(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1]))); + compare_list.emplace_back(std::pair(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1]))); } void ZoneDatabase::DivergeCharacterInventoryFromInvSnapshot(uint32 character_id, uint32 timestamp, std::list> &compare_list) { @@ -1819,7 +1819,7 @@ void ZoneDatabase::DivergeCharacterInventoryFromInvSnapshot(uint32 character_id, return; for (auto row : results) - compare_list.push_back(std::pair(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1]))); + compare_list.emplace_back(std::pair(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1]))); } bool ZoneDatabase::RestoreCharacterInvSnapshot(uint32 character_id, uint32 timestamp) { @@ -4140,7 +4140,7 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, CharacterCorpseEntr item.ornamentidfile = Strings::ToUnsignedInt(row[r++]); item.ornament_hero_model = Strings::ToUnsignedInt(row[r++]); - corpse.items.push_back(std::move(item)); + corpse.items.emplace_back(std::move(item)); r = 0; i++; }