Server_CardZone::getFreeGridColumn() now runs in O(log n), which should remove the performance bottleneck when processing insertCard(x = -1) commands on a large zone, e.g. createToken

This commit is contained in:
Max-Wilhelm Bruker 2013-01-20 16:40:15 +01:00
parent 590ab2f598
commit 60a1f5d7d1
3 changed files with 76 additions and 34 deletions

View file

@ -42,6 +42,10 @@ private:
bool alwaysRevealTopCard;
QList<Server_Card *> cards;
QMap<int, QMap<int, Server_Card *> > coordinateMap; // y -> (x -> card)
QMap<int, QMultiMap<QString, int> > freePilesMap; // y -> (cardName -> x)
QMap<int, int> freeSpaceMap; // y -> x
void removeCardFromCoordMap(Server_Card *card, int oldX, int oldY);
void insertCardIntoCoordMap(Server_Card *card, int x, int y);
public:
Server_CardZone(Server_Player *_player, const QString &_name, bool _has_coords, ServerInfo_Zone::ZoneType _type);
~Server_CardZone();