Commit d71ff122 authored by Chen Bill's avatar Chen Bill

ClientCard: add destructor

parent 75bbf24b
......@@ -5,7 +5,28 @@
namespace ygo {
ClientCard::ClientCard() {}
ClientCard::~ClientCard() {
ClearTarget();
if (equipTarget)
equipTarget->equipped.erase(this);
for (auto card : equipped) {
card->equipTarget = nullptr;
}
equipped.clear();
if (overlayTarget) {
for (auto it = overlayTarget->overlayed.begin(); it != overlayTarget->overlayed.end(); ) {
if (*it == this) {
it = overlayTarget->overlayed.erase(it);
}
else
++it;
}
}
for (auto card : overlayed) {
card->overlayTarget = nullptr;
}
overlayed.clear();
}
void ClientCard::SetCode(int code) {
if((location == LOCATION_HAND) && (this->code != (unsigned int)code)) {
this->code = code;
......@@ -184,6 +205,9 @@ void ClientCard::ClearData() {
rscstring[0] = 0;
lscstring[0] = 0;
counters.clear();
for (auto card : equipped) {
card->equipTarget = nullptr;
}
equipped.clear();
}
bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) {
......
......@@ -111,7 +111,8 @@ public:
wchar_t lscstring[16]{ 0 };
wchar_t rscstring[16]{ 0 };
ClientCard();
ClientCard() = default;
~ClientCard();
void SetCode(int code);
void UpdateInfo(unsigned char* buf);
void ClearTarget();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment