mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 19:47:46 -07:00
Buffer decklists to display until player processing is done instead of reordering player creation. (#6080)
Took 28 seconds Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
e87b35e0bb
commit
3e6510b935
1 changed files with 33 additions and 45 deletions
|
|
@ -851,42 +851,7 @@ void TabGame::eventGameStateChanged(const Event_GameStateChanged &event,
|
||||||
{
|
{
|
||||||
const int playerListSize = event.player_list_size();
|
const int playerListSize = event.player_list_size();
|
||||||
|
|
||||||
// Always process the local player first so we have an established deckViewcontainer
|
QVector<QPair<int, QPair<QString, QString>>> opponentDecksToDisplay;
|
||||||
|
|
||||||
for (int i = 0; i < playerListSize; ++i) {
|
|
||||||
const ServerInfo_Player &playerInfo = event.player_list(i);
|
|
||||||
const ServerInfo_PlayerProperties &prop = playerInfo.properties();
|
|
||||||
const int playerId = prop.player_id();
|
|
||||||
QString playerName = "@" + QString::fromStdString(prop.user_info().name());
|
|
||||||
if (sayEdit && !autocompleteUserList.contains(playerName)) {
|
|
||||||
autocompleteUserList << playerName;
|
|
||||||
sayEdit->setCompletionList(autocompleteUserList);
|
|
||||||
}
|
|
||||||
if (!prop.spectator()) {
|
|
||||||
Player *player = players.value(playerId, 0);
|
|
||||||
if (!player) {
|
|
||||||
if (clients.size() > 1 || playerId == localPlayerId) {
|
|
||||||
player = addPlayer(playerId, prop.user_info());
|
|
||||||
playerListWidget->addPlayer(prop);
|
|
||||||
player->processPlayerInfo(playerInfo);
|
|
||||||
if (player->getLocal()) {
|
|
||||||
TabbedDeckViewContainer *deckViewContainer = deckViewContainers.value(playerId);
|
|
||||||
if (playerInfo.has_deck_list()) {
|
|
||||||
DeckLoader newDeck(QString::fromStdString(playerInfo.deck_list()));
|
|
||||||
PictureLoader::cacheCardPixmaps(
|
|
||||||
CardDatabaseManager::getInstance()->getCards(newDeck.getCardRefList()));
|
|
||||||
deckViewContainer->playerDeckView->setDeck(newDeck);
|
|
||||||
player->setDeck(newDeck);
|
|
||||||
}
|
|
||||||
deckViewContainer->playerDeckView->setReadyStart(prop.ready_start());
|
|
||||||
deckViewContainer->playerDeckView->setSideboardLocked(prop.sideboard_locked());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// then process every non-local player.
|
|
||||||
|
|
||||||
for (int i = 0; i < playerListSize; ++i) {
|
for (int i = 0; i < playerListSize; ++i) {
|
||||||
const ServerInfo_Player &playerInfo = event.player_list(i);
|
const ServerInfo_Player &playerInfo = event.player_list(i);
|
||||||
|
|
@ -909,16 +874,24 @@ void TabGame::eventGameStateChanged(const Event_GameStateChanged &event,
|
||||||
playerListWidget->addPlayer(prop);
|
playerListWidget->addPlayer(prop);
|
||||||
}
|
}
|
||||||
player->processPlayerInfo(playerInfo);
|
player->processPlayerInfo(playerInfo);
|
||||||
if (player->getLocal() || !gameInfo.share_decklists_on_load()) {
|
if (player->getLocal()) {
|
||||||
continue;
|
TabbedDeckViewContainer *deckViewContainer = deckViewContainers.value(playerId);
|
||||||
}
|
if (playerInfo.has_deck_list()) {
|
||||||
|
DeckLoader newDeck(QString::fromStdString(playerInfo.deck_list()));
|
||||||
|
PictureLoader::cacheCardPixmaps(
|
||||||
|
CardDatabaseManager::getInstance()->getCards(newDeck.getCardRefList()));
|
||||||
|
deckViewContainer->playerDeckView->setDeck(newDeck);
|
||||||
|
player->setDeck(newDeck);
|
||||||
|
}
|
||||||
|
deckViewContainer->playerDeckView->setReadyStart(prop.ready_start());
|
||||||
|
deckViewContainer->playerDeckView->setSideboardLocked(prop.sideboard_locked());
|
||||||
|
} else {
|
||||||
|
if (!gameInfo.share_decklists_on_load()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
DeckList loader;
|
opponentDecksToDisplay.append(
|
||||||
loader.loadFromString_Native(QString::fromStdString(playerInfo.deck_list()));
|
qMakePair(playerId, qMakePair(playerName, QString::fromStdString(playerInfo.deck_list()))));
|
||||||
QMapIterator<int, TabbedDeckViewContainer *> i(deckViewContainers);
|
|
||||||
while (i.hasNext()) {
|
|
||||||
i.next();
|
|
||||||
i.value()->addOpponentDeckView(loader, playerId, player->getName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -933,6 +906,21 @@ void TabGame::eventGameStateChanged(const Event_GameStateChanged &event,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const auto &entry : opponentDecksToDisplay) {
|
||||||
|
int playerId = entry.first;
|
||||||
|
QString playerName = entry.second.first;
|
||||||
|
QString deckList = entry.second.second;
|
||||||
|
|
||||||
|
DeckList loader;
|
||||||
|
loader.loadFromString_Native(deckList);
|
||||||
|
|
||||||
|
QMapIterator<int, TabbedDeckViewContainer *> it(deckViewContainers);
|
||||||
|
while (it.hasNext()) {
|
||||||
|
it.next();
|
||||||
|
it.value()->addOpponentDeckView(loader, playerId, playerName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
secondsElapsed = event.seconds_elapsed();
|
secondsElapsed = event.seconds_elapsed();
|
||||||
|
|
||||||
if (event.game_started() && !gameInfo.started()) {
|
if (event.game_started() && !gameInfo.started()) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue