mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2025-12-21 23:00:24 -08:00
sanity checks; server crash fix
This commit is contained in:
@@ -99,6 +99,10 @@ void CardZone::addCard(CardItem *card, bool reorganize, int x, int y)
|
||||
CardItem *CardZone::getCard(int cardId, const QString &cardName)
|
||||
{
|
||||
CardItem *c = cards.findCard(cardId, false);
|
||||
if (!c) {
|
||||
qDebug() << "CardZone::getCard: card id=" << cardId << "not found";
|
||||
return 0;
|
||||
}
|
||||
// If the card's id is -1, this zone is invisible,
|
||||
// so we need to give the card an id and a name as it comes out.
|
||||
// It can be assumed that in an invisible zone, all cards are equal.
|
||||
|
||||
@@ -563,6 +563,10 @@ void Player::eventSetCardAttr(Event_SetCardAttr *event)
|
||||
emit logSetTapped(this, QString("-1"), event->getAttrValue() == "1");
|
||||
} else {
|
||||
CardItem *card = zone->getCard(event->getCardId(), QString());
|
||||
if (!card) {
|
||||
qDebug() << "Player::eventSetCardAttr: card id=" << event->getCardId() << "not found";
|
||||
return;
|
||||
}
|
||||
setCardAttrHelper(card, event->getAttrName(), event->getAttrValue(), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,8 +65,7 @@ void Server::closeOldSession(const QString &playerName)
|
||||
}
|
||||
if (session) {
|
||||
qDebug() << "found";
|
||||
removeClient(session);
|
||||
delete session;
|
||||
delete session; // ~Server_ProtocolHandler() will call Server::removeClient
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user