[Cleanup] Cleanup uses of insert/push_back when a temp object is used. (#3170)

This commit is contained in:
Aeadoin 2023-04-03 16:45:01 -04:00 committed by GitHub
parent 2bb15271c5
commit f752b57a55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
42 changed files with 104 additions and 104 deletions

View File

@ -145,7 +145,7 @@ void EQStreamIdentifier::Process() {
}
void EQStreamIdentifier::AddStream(std::shared_ptr<EQStreamInterface> eqs) {
m_streams.push_back(Record(eqs));
m_streams.emplace_back(Record(eqs));
eqs = nullptr;
}

View File

@ -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)));
}
}

View File

@ -7,7 +7,7 @@ EQ::Net::ConsoleServer::ConsoleServer(const std::string &addr, int port)
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)));
m_connections.emplace(std::make_pair(c->GetUUID(), std::unique_ptr<ConsoleServerConnection>(c)));
});
}

View File

@ -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<size_t>((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<size_t>((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<size_t>((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);

View File

@ -22,7 +22,7 @@ void EQ::Net::EQStreamManager::SetOptions(const EQStreamManagerInterfaceOptions
void EQ::Net::EQStreamManager::DaybreakNewConnection(std::shared_ptr<DaybreakConnection> connection)
{
std::shared_ptr<EQStream> 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);
}

View File

@ -45,7 +45,7 @@ void EQ::Net::ServertalkClient::SendPacket(ServerPacket *p)
void EQ::Net::ServertalkClient::OnMessage(uint16_t opcode, std::function<void(uint16_t, EQ::Net::Packet&)> 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<void(uint16_t, EQ::Net::Packet&)> cb)

View File

@ -41,7 +41,7 @@ void EQ::Net::ServertalkLegacyClient::SendPacket(ServerPacket *p)
void EQ::Net::ServertalkLegacyClient::OnMessage(uint16_t opcode, std::function<void(uint16_t, EQ::Net::Packet&)> 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<void(uint16_t, EQ::Net::Packet&)> cb)

View File

@ -19,12 +19,12 @@ void EQ::Net::ServertalkServer::Listen(const ServertalkServerOptions& opts)
void EQ::Net::ServertalkServer::OnConnectionIdentified(const std::string &type, std::function<void(std::shared_ptr<ServertalkServerConnection>)> 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<void(std::shared_ptr<ServertalkServerConnection>)> 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<std::shared_ptr<EQ::Net::ServertalkServerConnection>> 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);

View File

@ -100,7 +100,7 @@ void EQ::Net::ServertalkServerConnection::SendPacket(ServerPacket *p)
void EQ::Net::ServertalkServerConnection::OnMessage(uint16_t opcode, std::function<void(uint16_t, EQ::Net::Packet&)> 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<void(uint16_t, EQ::Net::Packet&)> cb)

View File

@ -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,

View File

@ -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(

View File

@ -76,7 +76,7 @@ std::vector<std::string> 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;
}

View File

@ -219,7 +219,7 @@ std::vector<std::string> join_pair(
std::vector<std::string> output;
for (const std::pair<T1, T2> &src_iter: src) {
output.push_back(
output.emplace_back(
fmt::format(
"{}{}{}{}{}{}{}",
@ -253,7 +253,7 @@ std::vector<std::string> join_tuple(
for (const std::tuple<T1, T2, T3, T4> &src_iter: src) {
output.push_back(
output.emplace_back(
fmt::format(
"{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}",

View File

@ -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

View File

@ -122,11 +122,11 @@ std::vector<std::string> 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;
}

View File

@ -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>(loginserver));
m_list.emplace_back(std::unique_ptr<LoginServer>(loginserver));
}
bool LoginServerList::SendStatus() {

View File

@ -21,7 +21,7 @@ void QueryServConnection::AddConnection(std::shared_ptr<EQ::Net::ServertalkServe
//Set handlers
connection->OnMessage(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<EQ::Timer>(1000, true, std::bind(&QueryServConnection::OnKeepAlive, this, std::placeholders::_1));
}

View File

@ -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;

View File

@ -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<EQ::Net::ServertalkServerConnection> connection)
{
m_interfaces.insert(std::make_pair(connection->GetUUID(), std::make_unique<WebInterface>(connection)));
m_interfaces.emplace(std::make_pair(connection->GetUUID(), std::make_unique<WebInterface>(connection)));
}
void WebInterfaceList::RemoveConnection(std::shared_ptr<EQ::Net::ServertalkServerConnection> connection)

View File

@ -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>(zoneserver));
zone_server_list.emplace_back(std::unique_ptr<ZoneServer>(zoneserver));
zoneserver->SendGroupIDs();
}

View File

@ -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<std::string, uint8>(working_bcl_iter.first, working_bcl_iter.second->access));
injected_bot_command_settings.emplace_back(std::pair<std::string, uint8>(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(),

View File

@ -1173,7 +1173,7 @@ bool BotDatabase::LoadItemSlots(const uint32 bot_id, std::map<uint16, uint32>& m
if (!l.empty()) {
for (const auto& e : l) {
m.insert(std::pair<uint16, uint32>(e.slot_id, e.item_id));
m.emplace(std::pair<uint16, uint32>(e.slot_id, e.item_id));
}
}

View File

@ -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<RaidMember> 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];
}

View File

@ -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{};

View File

@ -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<std::string, uint16>(cds->CorpseName, corpse->GetID()));
DraggedCorpses.emplace_back(std::pair<std::string, uint16>(cds->CorpseName, corpse->GetID()));
MessageString(Chat::DefaultText, CORPSEDRAG_BEGIN, cds->CorpseName);
}

View File

@ -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<std::string, uint8>(w.first, w.second->admin));
injected_command_settings.emplace_back(std::pair<std::string, uint8>(w.first, w.second->admin));
LogInfo(
"New Command [{}] found... Adding to `command_settings` table with admin [{}]...",
w.first,

View File

@ -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*/

View File

@ -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<std::string, std::string>(
bracket_message,
bracket_message.substr(EQ::constants::SAY_LINK_BODY_SIZE + 1)

View File

@ -329,8 +329,8 @@ bool EntityList::CanAddHateForMob(Mob *p)
void EntityList::AddClient(Client *client)
{
client->SetID(GetFreeID());
client_list.insert(std::pair<uint16, Client *>(client->GetID(), client));
mob_list.insert(std::pair<uint16, Mob *>(client->GetID(), client));
client_list.emplace(std::pair<uint16, Client *>(client->GetID(), client));
mob_list.emplace(std::pair<uint16, Mob *>(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<uint16, Corpse *>(corpse->GetID(), corpse));
corpse_list.emplace(std::pair<uint16, Corpse *>(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<uint16, NPC *>(npc->GetID(), npc));
mob_list.insert(std::pair<uint16, Mob *>(npc->GetID(), npc));
npc_list.emplace(std::pair<uint16, NPC *>(npc->GetID(), npc));
mob_list.emplace(std::pair<uint16, Mob *>(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<uint16, Merc *>(merc->GetID(), merc));
mob_list.insert(std::pair<uint16, Mob *>(merc->GetID(), merc));
merc_list.emplace(std::pair<uint16, Merc *>(merc->GetID(), merc));
mob_list.emplace(std::pair<uint16, Mob *>(merc->GetID(), merc));
}
}
@ -770,7 +770,7 @@ void EntityList::AddObject(Object *obj, bool SendSpawnPacket)
QueueClients(0, &app,false);
}
object_list.insert(std::pair<uint16, Object *>(obj->GetID(), obj));
object_list.emplace(std::pair<uint16, Object *>(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<uint16, Doors *>(door->GetEntityID(), door));
door_list.emplace(std::pair<uint16, Doors *>(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<uint16, Trap *>(trap->GetID(), trap));
trap_list.emplace(std::pair<uint16, Trap *>(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<uint16, Beacon *>(beacon->GetID(), beacon));
beacon_list.emplace(std::pair<uint16, Beacon *>(beacon->GetID(), beacon));
}
void EntityList::AddEncounter(Encounter *encounter)
{
encounter->SetID(GetFreeID());
encounter_list.insert(std::pair<uint16, Encounter *>(encounter->GetID(), encounter));
encounter_list.emplace(std::pair<uint16, Encounter *>(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<uint16, Mob *>(mob->GetID(), mob));
close_mobs.emplace(std::pair<uint16, Mob *>(mob->GetID(), mob));
if (add_self_to_other_lists && scanning_mob->GetID() > 0) {
bool has_mob = false;

View File

@ -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++;
}

View File

@ -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),

View File

@ -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,

View File

@ -16,7 +16,7 @@ void command_suspendmulti(Client *c, const Seperator *sep)
const auto& n = Strings::Split(sep->arg[1], "|");
std::vector<std::string> 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]);

View File

@ -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;
}

View File

@ -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<bonus)
{
faction_bonuses.erase(pFactionID);
faction_bonuses.insert(NewFactionBonus(pFactionID,bonus));
faction_bonuses.emplace(NewFactionBonus(pFactionID,bonus));
}
}
}
@ -6072,14 +6072,14 @@ void Mob::AddItemFactionBonus(uint32 pFactionID,int32 bonus) {
faction_bonus = item_faction_bonuses.find(pFactionID);
if(faction_bonus == item_faction_bonuses.end())
{
item_faction_bonuses.insert(NewFactionBonus(pFactionID,bonus));
item_faction_bonuses.emplace(NewFactionBonus(pFactionID,bonus));
}
else
{
if((bonus > 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));
}
}
}

View File

@ -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];
}

View File

@ -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<IMovementCommand>(new TeleportToCommand(x, y, z, heading)));
ent.Commands.emplace_back(std::unique_ptr<IMovementCommand>(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<IMovementCommand>(new MoveToCommand(x, y, z, mob_movement_mode)));
ent.Commands.emplace_back(std::unique_ptr<IMovementCommand>(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<IMovementCommand>(new SwimToCommand(x, y, z, mob_movement_mode)));
ent.Commands.emplace_back(std::unique_ptr<IMovementCommand>(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<IMovementCommand>(new RotateToCommand(to, diff > 0 ? 1.0 : -1.0, mob_movement_mode)));
ent.Commands.emplace_back(std::unique_ptr<IMovementCommand>(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<IMovementCommand>(new FlyToCommand(x, y, z, mob_movement_mode)));
ent.Commands.emplace_back(std::unique_ptr<IMovementCommand>(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<IMovementCommand>(new StopMovingCommand()));
mob_movement_entry.Commands.emplace_back(std::unique_ptr<IMovementCommand>(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<IMovementCommand>(new EvadeCombatCommand()));
mob_movement_entry.Commands.emplace_back(std::unique_ptr<IMovementCommand>(new EvadeCombatCommand()));
}
/**

View File

@ -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;

View File

@ -278,7 +278,7 @@ bool NpcScaleManager::LoadScaleData()
scale_data.zone_id = Strings::ToUnsignedInt(s.zone_id_list);
scale_data.instance_version = static_cast<uint16>(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<uint16>(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<uint16>(Strings::ToUnsignedInt(v));
npc_global_base_scaling_data.insert(
npc_global_base_scaling_data.emplace(
std::make_pair(
std::make_tuple(
scale_data.type,

View File

@ -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;
}
}

View File

@ -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<uint32,uint8>(item, num));
spec->onsuccess.emplace_back(std::pair<uint32,uint8>(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<uint32, uint8>(item, num));
spec->onfail.emplace_back(std::pair<uint32, uint8>(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<uint32, uint8>(item, num));
spec->salvage.emplace_back(std::pair<uint32, uint8>(item, num));
}
}

View File

@ -1684,7 +1684,7 @@ void ZoneDatabase::ListCharacterInvSnapshots(uint32 character_id, std::list<std:
return;
for (auto row : results)
is_list.push_back(std::pair<uint32, int>(Strings::ToUnsignedInt(row[0]), Strings::ToInt(row[1])));
is_list.emplace_back(std::pair<uint32, int>(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<int16, uint32>(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1])));
parse_list.emplace_back(std::pair<int16, uint32>(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1])));
}
void ZoneDatabase::DivergeCharacterInvSnapshotFromInventory(uint32 character_id, uint32 timestamp, std::list<std::pair<int16, uint32>> &compare_list) {
@ -1778,7 +1778,7 @@ void ZoneDatabase::DivergeCharacterInvSnapshotFromInventory(uint32 character_id,
return;
for (auto row : results)
compare_list.push_back(std::pair<int16, uint32>(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1])));
compare_list.emplace_back(std::pair<int16, uint32>(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1])));
}
void ZoneDatabase::DivergeCharacterInventoryFromInvSnapshot(uint32 character_id, uint32 timestamp, std::list<std::pair<int16, uint32>> &compare_list) {
@ -1819,7 +1819,7 @@ void ZoneDatabase::DivergeCharacterInventoryFromInvSnapshot(uint32 character_id,
return;
for (auto row : results)
compare_list.push_back(std::pair<int16, uint32>(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1])));
compare_list.emplace_back(std::pair<int16, uint32>(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++;
}