diff --git a/src/common/game_state/cards/deck.cpp b/src/common/game_state/cards/deck.cpp index 70f40b7eaa6e9be515ec9b18be83491d59c6996d..728ba86d00c448557338852106682bae76b1e720 100644 --- a/src/common/game_state/cards/deck.cpp +++ b/src/common/game_state/cards/deck.cpp @@ -52,12 +52,7 @@ deck::deck() : unique_serializable() _all_cards.push_back(new card(0, 0)); } - // make a copy of _all_cards - _remaining_cards = std::vector<card*>(); - for (card* & c : _all_cards) - { - _remaining_cards.push_back(new card(*c)); - } + _remaining_cards = _all_cards; } deck::~deck() { @@ -65,11 +60,6 @@ deck::~deck() { for (card* & _card : _all_cards) { delete _card; } - _all_cards.clear(); - // delete _remaining_cards_vector - for (card* & _card : _remaining_cards) { - delete _card; - } _remaining_cards.clear(); } @@ -89,12 +79,7 @@ unsigned int deck::get_number_of_remaining_cards() const noexcept // state update functions void deck::setup_round() { - // make a copy of _all_cards - _remaining_cards = std::vector<card*>(); - for (card* & c : _all_cards) - { - _remaining_cards.push_back(new card(*c)); - } + _remaining_cards = _all_cards; } bool deck::draw_cards(const player* player, const int round_number, std::string& err) diff --git a/src/common/game_state/cards/trick.cpp b/src/common/game_state/cards/trick.cpp index de288e67614bae1b566cecc765cf4bab5ec3502c..aed02c78b0e319bd332c5559bafffc2f13226f25 100644 --- a/src/common/game_state/cards/trick.cpp +++ b/src/common/game_state/cards/trick.cpp @@ -30,10 +30,6 @@ trick::trick(const int trump) trick::~trick() { - for (int i = 0; i < _cards.size(); i++) { - delete _cards[i].first; // delete the `card*` - delete _cards[i].second; // delete the `player*` - } delete _trick_color; delete _trump_color; _cards.clear(); @@ -104,10 +100,6 @@ player* trick::wrap_up_trick(std::string& err) { void trick::set_up_round(std::string& err, int trump) { // remove all cards (if any) - for (int i = 0; i < _cards.size(); i++) { - delete _cards[i].first; // delete the `card*` - delete _cards[i].second; // delete the `player*` - } _cards.clear(); *_trump_color = trump; *_trick_color = 0; diff --git a/src/common/game_state/player/hand.cpp b/src/common/game_state/player/hand.cpp index 38c9b884196c1b6e7de078dadf12cdfc9fd3954b..6d7b68cccf3017bee575b899c8b59ce0b67899e1 100644 --- a/src/common/game_state/player/hand.cpp +++ b/src/common/game_state/player/hand.cpp @@ -14,10 +14,6 @@ hand::hand(const std::string& id, const std::vector<card*>& cards) : unique_seri } hand::~hand() { - for (auto & card : _cards) { - delete card; - card = nullptr; - } _cards.clear(); }