mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 00:24:47 -07:00
deck storage is fully working again, cleaned up some unnecessarily large messages
This commit is contained in:
parent
d4aaf9fff5
commit
0c9a2b061c
13 changed files with 110 additions and 66 deletions
9
common/pb/proto/response_deck_list.proto
Normal file
9
common/pb/proto/response_deck_list.proto
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import "response.proto";
|
||||
import "serverinfo_deckstorage.proto";
|
||||
|
||||
message Response_DeckList {
|
||||
extend Response {
|
||||
optional Response_DeckList ext = 1006;
|
||||
}
|
||||
optional ServerInfo_DeckStorage_Folder root = 1;
|
||||
}
|
||||
9
common/pb/proto/response_deck_upload.proto
Normal file
9
common/pb/proto/response_deck_upload.proto
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import "response.proto";
|
||||
import "serverinfo_deckstorage.proto";
|
||||
|
||||
message Response_DeckUpload {
|
||||
extend Response {
|
||||
optional Response_DeckUpload ext = 1008;
|
||||
}
|
||||
optional ServerInfo_DeckStorage_TreeItem new_file = 1;
|
||||
}
|
||||
14
common/pb/proto/serverinfo_deckstorage.proto
Normal file
14
common/pb/proto/serverinfo_deckstorage.proto
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
message ServerInfo_DeckStorage_File {
|
||||
optional uint64 creation_time = 1;
|
||||
}
|
||||
|
||||
message ServerInfo_DeckStorage_Folder {
|
||||
repeated ServerInfo_DeckStorage_TreeItem items = 1;
|
||||
}
|
||||
|
||||
message ServerInfo_DeckStorage_TreeItem {
|
||||
optional uint32 id = 1;
|
||||
optional string name = 2;
|
||||
optional ServerInfo_DeckStorage_File file = 10;
|
||||
optional ServerInfo_DeckStorage_Folder folder = 11;
|
||||
}
|
||||
|
|
@ -135,7 +135,7 @@ void Server::broadcastRoomUpdate()
|
|||
|
||||
ServerInfo_Room *roomInfo = event.add_room_list();
|
||||
room->roomMutex.lock();
|
||||
roomInfo->CopyFrom(room->getInfo(false));
|
||||
roomInfo->CopyFrom(room->getInfo(false, false, true));
|
||||
room->roomMutex.unlock();
|
||||
|
||||
SessionEvent *se = Server_ProtocolHandler::prepareSessionEvent(event);
|
||||
|
|
|
|||
|
|
@ -583,11 +583,11 @@ ServerInfo_Game Server_Game::getInfo() const
|
|||
ServerInfo_Game result;
|
||||
result.set_room_id(room->getId());
|
||||
result.set_game_id(getGameId());
|
||||
result.set_max_players(getMaxPlayers());
|
||||
if (!players.isEmpty()) {
|
||||
for (int i = 0; i < gameTypes.size(); ++i)
|
||||
result.add_game_types(gameTypes[i]);
|
||||
|
||||
result.set_max_players(getMaxPlayers());
|
||||
result.set_description(getDescription().toStdString());
|
||||
result.set_with_password(!getPassword().isEmpty());
|
||||
result.set_player_count(getPlayerCount());
|
||||
|
|
|
|||
|
|
@ -195,7 +195,8 @@ ServerInfo_PlayerProperties Server_Player::getProperties()
|
|||
result.set_spectator(spectator);
|
||||
result.set_conceded(conceded);
|
||||
result.set_ready_start(readyStart);
|
||||
result.set_deck_hash(deck ? deck->getDeckHash().toStdString() : std::string());
|
||||
if (deck)
|
||||
result.set_deck_hash(deck->getDeckHash().toStdString());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,17 +32,20 @@ Server *Server_Room::getServer() const
|
|||
return static_cast<Server *>(parent());
|
||||
}
|
||||
|
||||
ServerInfo_Room Server_Room::getInfo(bool complete, bool showGameTypes) const
|
||||
ServerInfo_Room Server_Room::getInfo(bool complete, bool showGameTypes, bool updating) const
|
||||
{
|
||||
QMutexLocker locker(&roomMutex);
|
||||
|
||||
ServerInfo_Room result;
|
||||
result.set_room_id(id);
|
||||
result.set_name(name.toStdString());
|
||||
result.set_description(description.toStdString());
|
||||
result.set_game_count(games.size());
|
||||
result.set_player_count(size());
|
||||
result.set_auto_join(autoJoin);
|
||||
|
||||
if (!updating) {
|
||||
result.set_name(name.toStdString());
|
||||
result.set_description(description.toStdString());
|
||||
result.set_auto_join(autoJoin);
|
||||
}
|
||||
|
||||
if (complete) {
|
||||
QMapIterator<int, Server_Game *> gameIterator(games);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public:
|
|||
QString getJoinMessage() const { return joinMessage; }
|
||||
const QMap<int, Server_Game *> &getGames() const { return games; }
|
||||
Server *getServer() const;
|
||||
ServerInfo_Room getInfo(bool complete, bool showGameTypes = false) const;
|
||||
ServerInfo_Room getInfo(bool complete, bool showGameTypes = false, bool updating = false) const;
|
||||
int getGamesCreatedByUser(const QString &name) const;
|
||||
QList<ServerInfo_Game> getGamesOfUser(const QString &name) const;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue