mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-11 00:24:47 -07:00
interface & client tab for replay transfer
This commit is contained in:
parent
faf6b2c5cb
commit
c6c6a970c6
36 changed files with 702 additions and 52 deletions
|
|
@ -12,6 +12,7 @@ SET(PROTO_FILES
|
|||
command_deck_del_dir.proto
|
||||
command_deck_del.proto
|
||||
command_deck_download.proto
|
||||
command_deck_list.proto
|
||||
command_deck_new_dir.proto
|
||||
command_deck_select.proto
|
||||
command_deck_upload.proto
|
||||
|
|
@ -29,6 +30,8 @@ SET(PROTO_FILES
|
|||
command_mulligan.proto
|
||||
command_next_turn.proto
|
||||
command_ready_start.proto
|
||||
command_replay_list.proto
|
||||
command_replay_download.proto
|
||||
command_reveal_cards.proto
|
||||
command_roll_die.proto
|
||||
command_set_active_phase.proto
|
||||
|
|
@ -107,6 +110,8 @@ SET(PROTO_FILES
|
|||
response_join_room.proto
|
||||
response_list_users.proto
|
||||
response_login.proto
|
||||
response_replay_download.proto
|
||||
response_replay_list.proto
|
||||
response.proto
|
||||
room_commands.proto
|
||||
room_event.proto
|
||||
|
|
@ -120,6 +125,7 @@ SET(PROTO_FILES
|
|||
serverinfo_playerping.proto
|
||||
serverinfo_playerproperties.proto
|
||||
serverinfo_player.proto
|
||||
serverinfo_replay.proto
|
||||
serverinfo_room.proto
|
||||
serverinfo_user.proto
|
||||
serverinfo_zone.proto
|
||||
|
|
|
|||
7
common/pb/command_deck_list.proto
Normal file
7
common/pb/command_deck_list.proto
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import "session_commands.proto";
|
||||
|
||||
message Command_DeckList {
|
||||
extend SessionCommand {
|
||||
optional Command_DeckList ext = 1008;
|
||||
}
|
||||
}
|
||||
8
common/pb/command_replay_download.proto
Normal file
8
common/pb/command_replay_download.proto
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import "session_commands.proto";
|
||||
|
||||
message Command_ReplayDownload {
|
||||
extend SessionCommand {
|
||||
optional Command_ReplayDownload ext = 1101;
|
||||
}
|
||||
optional sint32 game_id = 1 [default = -1];
|
||||
}
|
||||
7
common/pb/command_replay_list.proto
Normal file
7
common/pb/command_replay_list.proto
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
import "session_commands.proto";
|
||||
|
||||
message Command_ReplayList {
|
||||
extend SessionCommand {
|
||||
optional Command_ReplayList ext = 1100;
|
||||
}
|
||||
}
|
||||
|
|
@ -20,6 +20,7 @@ message Response {
|
|||
RespWouldOverwriteOldSession = 17;
|
||||
RespChatFlood = 18;
|
||||
RespUserIsBanned = 19;
|
||||
RespAccessDenied = 20;
|
||||
}
|
||||
enum ResponseType {
|
||||
JOIN_ROOM = 1000;
|
||||
|
|
@ -31,6 +32,8 @@ message Response {
|
|||
DECK_LIST = 1006;
|
||||
DECK_DOWNLOAD = 1007;
|
||||
DECK_UPLOAD = 1008;
|
||||
REPLAY_LIST = 1100;
|
||||
REPLAY_DOWNLOAD = 1101;
|
||||
}
|
||||
required uint64 cmd_id = 1;
|
||||
optional ResponseCode response_code = 2;
|
||||
|
|
|
|||
9
common/pb/response_replay_download.proto
Normal file
9
common/pb/response_replay_download.proto
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import "response.proto";
|
||||
|
||||
message Response_ReplayDownload {
|
||||
extend Response {
|
||||
optional Response_ReplayDownload ext = 1101;
|
||||
}
|
||||
optional bytes replay_data = 1;
|
||||
}
|
||||
|
||||
9
common/pb/response_replay_list.proto
Normal file
9
common/pb/response_replay_list.proto
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import "response.proto";
|
||||
import "serverinfo_replay.proto";
|
||||
|
||||
message Response_ReplayList {
|
||||
extend Response {
|
||||
optional Response_ReplayList ext = 1100;
|
||||
}
|
||||
repeated ServerInfo_Replay replay_list = 1;
|
||||
}
|
||||
9
common/pb/serverinfo_replay.proto
Normal file
9
common/pb/serverinfo_replay.proto
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
message ServerInfo_Replay {
|
||||
optional sint32 game_id = 1 [default = -1];
|
||||
optional string room_name = 2;
|
||||
optional uint32 time_started = 3;
|
||||
optional uint32 length = 4;
|
||||
optional string game_name = 5;
|
||||
optional string replay_name = 6;
|
||||
repeated string player_names = 7;
|
||||
}
|
||||
|
|
@ -18,4 +18,5 @@ message ServerInfo_User {
|
|||
optional Gender gender = 5 [default = GenderUnknown];
|
||||
optional string country = 6;
|
||||
optional bytes avatar_bmp = 7;
|
||||
optional sint32 id = 8 [default = -1];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ message SessionCommand {
|
|||
DECK_UPLOAD = 1013;
|
||||
LIST_ROOMS = 1014;
|
||||
JOIN_ROOM = 1015;
|
||||
REPLAY_LIST = 1100;
|
||||
REPLAY_DOWNLOAD = 1101;
|
||||
}
|
||||
extensions 100 to max;
|
||||
}
|
||||
|
|
@ -78,12 +80,6 @@ message Command_RemoveFromList {
|
|||
optional string user_name = 2;
|
||||
}
|
||||
|
||||
message Command_DeckList {
|
||||
extend SessionCommand {
|
||||
optional Command_DeckList ext = 1008;
|
||||
}
|
||||
}
|
||||
|
||||
message Command_ListRooms {
|
||||
extend SessionCommand {
|
||||
optional Command_ListRooms ext = 1014;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
|||
if ((authState == NotLoggedIn) || (authState == UserIsBanned))
|
||||
return authState;
|
||||
|
||||
ServerInfo_User data = getUserData(name);
|
||||
ServerInfo_User data = getUserData(name, true);
|
||||
data.set_address(session->getAddress().toStdString());
|
||||
name = QString::fromStdString(data.name()); // Compensate for case indifference
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public:
|
|||
virtual bool isInBuddyList(const QString &whoseList, const QString &who) { return false; }
|
||||
virtual bool isInIgnoreList(const QString &whoseList, const QString &who) { return false; }
|
||||
|
||||
virtual void storeGameInformation(int secondsElapsed, const QStringList &allPlayersEver, const GameReplay &replay) { }
|
||||
virtual void storeGameInformation(int secondsElapsed, const QSet<QString> &allPlayersEver, const QSet<QString> &allSpectatorsEver, const GameReplay &replay) { }
|
||||
protected:
|
||||
void prepareDestroy();
|
||||
QList<Server_ProtocolHandler *> clients;
|
||||
|
|
@ -59,7 +59,7 @@ protected:
|
|||
virtual void endSession(int sessionId) { }
|
||||
virtual bool userExists(const QString &user) { return false; }
|
||||
virtual AuthenticationResult checkUserPassword(Server_ProtocolHandler *handler, const QString &user, const QString &password, QString &reason) { return UnknownUser; }
|
||||
virtual ServerInfo_User getUserData(const QString &name) = 0;
|
||||
virtual ServerInfo_User getUserData(const QString &name, bool withId = false) = 0;
|
||||
int getUsersCount() const;
|
||||
int getGamesCount() const;
|
||||
int nextGameId;
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ Server_Game::Server_Game(Server_ProtocolHandler *_creator, int _gameId, const QS
|
|||
: QObject(), room(_room), hostId(0), creatorInfo(new ServerInfo_User(_creator->copyUserInfo(false))), gameStarted(false), gameId(_gameId), description(_description), password(_password), maxPlayers(_maxPlayers), gameTypes(_gameTypes), activePlayer(-1), activePhase(-1), onlyBuddies(_onlyBuddies), onlyRegistered(_onlyRegistered), spectatorsAllowed(_spectatorsAllowed), spectatorsNeedPassword(_spectatorsNeedPassword), spectatorsCanTalk(_spectatorsCanTalk), spectatorsSeeEverything(_spectatorsSeeEverything), inactivityCounter(0), secondsElapsed(0), startTime(QDateTime::currentDateTime()), gameMutex(QMutex::Recursive)
|
||||
{
|
||||
replay = new GameReplay;
|
||||
replay->mutable_game_info()->CopyFrom(getInfo());
|
||||
|
||||
connect(this, SIGNAL(sigStartGameIfReady()), this, SLOT(doStartGameIfReady()), Qt::QueuedConnection);
|
||||
|
||||
addPlayer(_creator, false, false);
|
||||
replay->mutable_game_info()->CopyFrom(getInfo());
|
||||
|
||||
if (room->getServer()->getGameShouldPing()) {
|
||||
pingClock = new QTimer(this);
|
||||
|
|
@ -80,7 +80,7 @@ Server_Game::~Server_Game()
|
|||
gameMutex.unlock();
|
||||
room->roomMutex.unlock();
|
||||
|
||||
room->getServer()->storeGameInformation(secondsElapsed, allPlayersEver.toList(), *replay);
|
||||
room->getServer()->storeGameInformation(secondsElapsed, allPlayersEver, allSpectatorsEver, *replay);
|
||||
delete replay;
|
||||
|
||||
qDebug() << "Server_Game destructor: gameId=" << gameId;
|
||||
|
|
@ -324,7 +324,10 @@ Server_Player *Server_Game::addPlayer(Server_ProtocolHandler *handler, bool spec
|
|||
joinEvent.mutable_player_properties()->CopyFrom(newPlayer->getProperties(true));
|
||||
sendGameEventContainer(prepareGameEvent(joinEvent, -1));
|
||||
|
||||
allPlayersEver.insert(QString::fromStdString(newPlayer->getUserInfo()->name()));
|
||||
if (spectator)
|
||||
allSpectatorsEver.insert(QString::fromStdString(newPlayer->getUserInfo()->name()));
|
||||
else
|
||||
allPlayersEver.insert(QString::fromStdString(newPlayer->getUserInfo()->name()));
|
||||
players.insert(playerId, newPlayer);
|
||||
if (newPlayer->getUserInfo()->name() == creatorInfo->name()) {
|
||||
hostId = playerId;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ private:
|
|||
int hostId;
|
||||
ServerInfo_User *creatorInfo;
|
||||
QMap<int, Server_Player *> players;
|
||||
QSet<QString> allPlayersEver;
|
||||
QSet<QString> allPlayersEver, allSpectatorsEver;
|
||||
bool gameStarted;
|
||||
int gameId;
|
||||
QString description;
|
||||
|
|
|
|||
|
|
@ -42,11 +42,14 @@
|
|||
#include "pb/command_shuffle.pb.h"
|
||||
#include "pb/command_stop_dump_zone.pb.h"
|
||||
#include "pb/command_undo_draw.pb.h"
|
||||
#include "pb/command_deck_list.pb.h"
|
||||
#include "pb/command_deck_upload.pb.h"
|
||||
#include "pb/command_deck_download.pb.h"
|
||||
#include "pb/command_deck_new_dir.pb.h"
|
||||
#include "pb/command_deck_del_dir.pb.h"
|
||||
#include "pb/command_deck_del.pb.h"
|
||||
#include "pb/command_replay_list.pb.h"
|
||||
#include "pb/command_replay_download.pb.h"
|
||||
#include "pb/response.pb.h"
|
||||
#include "pb/response_login.pb.h"
|
||||
#include "pb/response_list_users.pb.h"
|
||||
|
|
@ -137,8 +140,10 @@ ServerInfo_User Server_ProtocolHandler::copyUserInfo(bool complete, bool moderat
|
|||
ServerInfo_User result;
|
||||
if (userInfo) {
|
||||
result.CopyFrom(*userInfo);
|
||||
if (!moderatorInfo)
|
||||
if (!moderatorInfo) {
|
||||
result.clear_address();
|
||||
result.clear_id();
|
||||
}
|
||||
if (!complete)
|
||||
result.clear_avatar_bmp();
|
||||
}
|
||||
|
|
@ -234,6 +239,8 @@ Response::ResponseCode Server_ProtocolHandler::processSessionCommandContainer(co
|
|||
case SessionCommand::DECK_DEL: resp = cmdDeckDel(sc.GetExtension(Command_DeckDel::ext), rc); break;
|
||||
case SessionCommand::DECK_UPLOAD: resp = cmdDeckUpload(sc.GetExtension(Command_DeckUpload::ext), rc); break;
|
||||
case SessionCommand::DECK_DOWNLOAD: resp = cmdDeckDownload(sc.GetExtension(Command_DeckDownload::ext), rc); break;
|
||||
case SessionCommand::REPLAY_LIST: resp = cmdReplayList(sc.GetExtension(Command_ReplayList::ext), rc); break;
|
||||
case SessionCommand::REPLAY_DOWNLOAD: resp = cmdReplayDownload(sc.GetExtension(Command_ReplayDownload::ext), rc); break;
|
||||
case SessionCommand::GET_GAMES_OF_USER: resp = cmdGetGamesOfUser(sc.GetExtension(Command_GetGamesOfUser::ext), rc); break;
|
||||
case SessionCommand::GET_USER_INFO: resp = cmdGetUserInfo(sc.GetExtension(Command_GetUserInfo::ext), rc); break;
|
||||
case SessionCommand::LIST_ROOMS: resp = cmdListRooms(sc.GetExtension(Command_ListRooms::ext), rc); break;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ class Command_DeckDelDir;
|
|||
class Command_DeckDel;
|
||||
class Command_DeckDownload;
|
||||
class Command_DeckUpload;
|
||||
class Command_ReplayList;
|
||||
class Command_ReplayDownload;
|
||||
class Command_ListRooms;
|
||||
class Command_JoinRoom;
|
||||
class Command_LeaveRoom;
|
||||
|
|
@ -119,6 +121,8 @@ private:
|
|||
virtual Response::ResponseCode cmdDeckDel(const Command_DeckDel &cmd, ResponseContainer &rc) = 0;
|
||||
virtual Response::ResponseCode cmdDeckUpload(const Command_DeckUpload &cmd, ResponseContainer &rc) = 0;
|
||||
virtual Response::ResponseCode cmdDeckDownload(const Command_DeckDownload &cmd, ResponseContainer &rc) = 0;
|
||||
virtual Response::ResponseCode cmdReplayList(const Command_ReplayList &cmd, ResponseContainer &rc) = 0;
|
||||
virtual Response::ResponseCode cmdReplayDownload(const Command_ReplayDownload &cmd, ResponseContainer &rc) = 0;
|
||||
Response::ResponseCode cmdGetGamesOfUser(const Command_GetGamesOfUser &cmd, ResponseContainer &rc);
|
||||
Response::ResponseCode cmdGetUserInfo(const Command_GetUserInfo &cmd, ResponseContainer &rc);
|
||||
Response::ResponseCode cmdListRooms(const Command_ListRooms &cmd, ResponseContainer &rc);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ public:
|
|||
QString getDescription() const { return description; }
|
||||
bool getAutoJoin() const { return autoJoin; }
|
||||
QString getJoinMessage() const { return joinMessage; }
|
||||
const QStringList &getGameTypes() const { return gameTypes; }
|
||||
const QMap<int, Server_Game *> &getGames() const { return games; }
|
||||
Server *getServer() const;
|
||||
ServerInfo_Room getInfo(bool complete, bool showGameTypes = false, bool updating = false) const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue