server crash and inconsistency fix

This commit is contained in:
Max-Wilhelm Bruker 2010-11-23 02:07:56 +01:00
parent 4387f05ffa
commit ec602aefe1
2 changed files with 8 additions and 9 deletions

View file

@ -37,15 +37,11 @@ Server_Card::~Server_Card()
void Server_Card::resetState() void Server_Card::resetState()
{ {
setCoords(0, 0);
counters.clear(); counters.clear();
setTapped(false); setTapped(false);
setAttacking(false); setAttacking(false);
setFaceDown(false);
setColor(QString());
setPT(QString()); setPT(QString());
setAnnotation(QString()); setAnnotation(QString());
setDestroyOnZoneChange(false);
setDoesntUntap(false); setDoesntUntap(false);
} }

View file

@ -623,6 +623,8 @@ ResponseCode Server_ProtocolHandler::moveCard(Server_Game *game, Server_Player *
y = 0; y = 0;
if (x == -1) if (x == -1)
x = targetzone->cards.size(); x = targetzone->cards.size();
card->resetState();
} else if (x == -1) } else if (x == -1)
x = targetzone->getFreeGridColumn(y); x = targetzone->getFreeGridColumn(y);
@ -680,7 +682,7 @@ ResponseCode Server_ProtocolHandler::moveCard(Server_Game *game, Server_Player *
if (tapped) if (tapped)
setCardAttrHelper(cont, game, player, targetzone->getName(), card->getId(), "tapped", "1"); setCardAttrHelper(cont, game, player, targetzone->getName(), card->getId(), "tapped", "1");
return RespOk; return RespOk;
} }
@ -1197,11 +1199,12 @@ ResponseCode Server_ProtocolHandler::cmdRevealCards(Command_RevealCards *cmd, Co
for (int i = 0; i < cardsToReveal.size(); ++i) { for (int i = 0; i < cardsToReveal.size(); ++i) {
Server_Card *card = cardsToReveal[i]; Server_Card *card = cardsToReveal[i];
QList<ServerInfo_CardCounter *> cardCounterList; QList<ServerInfo_CardCounter *> cardCounterListPrivate, cardCounterListOmniscient;
QMapIterator<int, int> cardCounterIterator(card->getCounters()); QMapIterator<int, int> cardCounterIterator(card->getCounters());
while (cardCounterIterator.hasNext()) { while (cardCounterIterator.hasNext()) {
cardCounterIterator.next(); cardCounterIterator.next();
cardCounterList.append(new ServerInfo_CardCounter(cardCounterIterator.key(), cardCounterIterator.value())); cardCounterListPrivate.append(new ServerInfo_CardCounter(cardCounterIterator.key(), cardCounterIterator.value()));
cardCounterListOmniscient.append(new ServerInfo_CardCounter(cardCounterIterator.key(), cardCounterIterator.value()));
} }
int attachPlayerId = -1; int attachPlayerId = -1;
@ -1214,8 +1217,8 @@ ResponseCode Server_ProtocolHandler::cmdRevealCards(Command_RevealCards *cmd, Co
} }
if (cmd->getPlayerId() != -1) if (cmd->getPlayerId() != -1)
respCardListPrivate.append(new ServerInfo_Card(card->getId(), card->getName(), card->getX(), card->getY(), card->getTapped(), card->getAttacking(), card->getColor(), card->getPT(), card->getAnnotation(), card->getDestroyOnZoneChange(), cardCounterList, attachPlayerId, attachZone, attachCardId)); respCardListPrivate.append(new ServerInfo_Card(card->getId(), card->getName(), card->getX(), card->getY(), card->getTapped(), card->getAttacking(), card->getColor(), card->getPT(), card->getAnnotation(), card->getDestroyOnZoneChange(), cardCounterListPrivate, attachPlayerId, attachZone, attachCardId));
respCardListOmniscient.append(new ServerInfo_Card(card->getId(), card->getName(), card->getX(), card->getY(), card->getTapped(), card->getAttacking(), card->getColor(), card->getPT(), card->getAnnotation(), card->getDestroyOnZoneChange(), cardCounterList, attachPlayerId, attachZone, attachCardId)); respCardListOmniscient.append(new ServerInfo_Card(card->getId(), card->getName(), card->getX(), card->getY(), card->getTapped(), card->getAttacking(), card->getColor(), card->getPT(), card->getAnnotation(), card->getDestroyOnZoneChange(), cardCounterListOmniscient, attachPlayerId, attachZone, attachCardId));
} }
if (cmd->getPlayerId() == -1) if (cmd->getPlayerId() == -1)