Skip to content

Commit

Permalink
Changed push_back to emplace. Resolve conversation.
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel committed Apr 29, 2024
1 parent 12cdc1c commit 7f81baf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/creatures/players/cyclopedia/player_badge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ bool PlayerBadge::add(uint8_t id, uint32_t timestamp /* = 0*/) {

int toSaveTimeStamp = timestamp != 0 ? timestamp : (OTSYS_TIME() / 1000);
getUnlockedKV()->set(badge.m_name, toSaveTimeStamp);
m_badgesUnlocked.push_back({ badge, toSaveTimeStamp });
m_badgesUnlocked.emplace_back(badge, toSaveTimeStamp);
m_badgesUnlocked.shrink_to_fit();
return true;
}
Expand Down Expand Up @@ -94,7 +94,7 @@ void PlayerBadge::loadUnlockedBadges() {

g_logger().debug("[{}] - Badge {} found for player {}.", __FUNCTION__, badge.m_name, m_player.getName());

m_badgesUnlocked.push_back({ badge, getUnlockedKV()->get(badgeName)->getNumber() });
m_badgesUnlocked.emplace_back(badge, getUnlockedKV()->get(badgeName)->getNumber());
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/creatures/players/cyclopedia/player_badge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

#pragma once

#include "game/game_definitions.hpp"

class Player;
class KV;

Expand Down
3 changes: 2 additions & 1 deletion src/creatures/players/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ phmap::flat_hash_map<uint8_t, std::shared_ptr<Item>> Player::getAllSlotItems() c
}

phmap::flat_hash_map<Blessings_t, std::string> Player::getBlessingNames() const {
return {
static phmap::flat_hash_map<Blessings_t, std::string> blessingNames = {
{ TWIST_OF_FATE, "Twist of Fate" },
{ WISDOM_OF_SOLITUDE, "The Wisdom of Solitude" },
{ SPARK_OF_THE_PHOENIX, "The Spark of the Phoenix" },
Expand All @@ -640,6 +640,7 @@ phmap::flat_hash_map<Blessings_t, std::string> Player::getBlessingNames() const
{ BLOOD_OF_THE_MOUNTAIN, "Blood of the Mountain" },
{ HEARTH_OF_THE_MOUNTAIN, "Heart of the Mountain" },
};
return blessingNames;
}

void Player::setTraining(bool value) {
Expand Down

0 comments on commit 7f81baf

Please sign in to comment.