fixed cmdDeckSelect (2)
This commit is contained in:
parent
1d151d2d12
commit
2789116d03
7 changed files with 20 additions and 17 deletions
|
@ -158,7 +158,7 @@ AuthenticationResult Server::loginUser(Server_ProtocolHandler *session, QString
|
|||
clients[i]->sendProtocolItem(*se);
|
||||
delete se;
|
||||
|
||||
event.mutable_user_info()->CopyFrom(session->copyUserInfo(true, true));
|
||||
event.mutable_user_info()->CopyFrom(session->copyUserInfo(true, true, true));
|
||||
locker.unlock();
|
||||
|
||||
se = Server_ProtocolHandler::prepareSessionEvent(event);
|
||||
|
|
|
@ -390,7 +390,7 @@ void Server_Game::addPlayer(Server_AbstractUserInterface *userInterface, Respons
|
|||
{
|
||||
QMutexLocker locker(&gameMutex);
|
||||
|
||||
Server_Player *newPlayer = new Server_Player(this, nextPlayerId++, userInterface->copyUserInfo(true), spectator, userInterface);
|
||||
Server_Player *newPlayer = new Server_Player(this, nextPlayerId++, userInterface->copyUserInfo(true, true), spectator, userInterface);
|
||||
newPlayer->moveToThread(thread());
|
||||
|
||||
Event_Join joinEvent;
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
#include <QDebug>
|
||||
|
||||
Server_Player::Server_Player(Server_Game *_game, int _playerId, const ServerInfo_User &_userInfo, bool _spectator, Server_AbstractUserInterface *_userInterface)
|
||||
: game(_game), userInterface(_userInterface), userInfo(new ServerInfo_User(_userInfo)), deck(0), pingTime(0), playerId(_playerId), spectator(_spectator), nextCardId(0), readyStart(false), conceded(false), sideboardLocked(true)
|
||||
: ServerInfo_User_Container(_userInfo), game(_game), userInterface(_userInterface), deck(0), pingTime(0), playerId(_playerId), spectator(_spectator), nextCardId(0), readyStart(false), conceded(false), sideboardLocked(true)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -101,9 +101,6 @@ void Server_Player::prepareDestroy()
|
|||
userInterface->playerRemovedFromGame(game);
|
||||
playerMutex.unlock();
|
||||
|
||||
delete userInfo;
|
||||
userInfo = 0;
|
||||
|
||||
clearZones();
|
||||
|
||||
deleteLater();
|
||||
|
@ -244,7 +241,7 @@ void Server_Player::getProperties(ServerInfo_PlayerProperties &result, bool with
|
|||
{
|
||||
result.set_player_id(playerId);
|
||||
if (withUserInfo)
|
||||
result.mutable_user_info()->CopyFrom(*userInfo);
|
||||
copyUserInfo(*(result.mutable_user_info()), true);
|
||||
result.set_spectator(spectator);
|
||||
if (!spectator) {
|
||||
result.set_conceded(conceded);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define PLAYER_H
|
||||
|
||||
#include "server_arrowtarget.h"
|
||||
#include "serverinfo_user_container.h"
|
||||
#include <QString>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
|
@ -60,13 +61,12 @@ class Command_DeckSelect;
|
|||
class Command_SetSideboardLock;
|
||||
class Command_ChangeZoneProperties;
|
||||
|
||||
class Server_Player : public Server_ArrowTarget {
|
||||
class Server_Player : public Server_ArrowTarget, public ServerInfo_User_Container {
|
||||
Q_OBJECT
|
||||
private:
|
||||
class MoveCardCompareFunctor;
|
||||
Server_Game *game;
|
||||
Server_AbstractUserInterface *userInterface;
|
||||
ServerInfo_User *userInfo;
|
||||
DeckList *deck;
|
||||
QMap<QString, Server_CardZone *> zones;
|
||||
QMap<int, Server_Counter *> counters;
|
||||
|
@ -96,7 +96,6 @@ public:
|
|||
bool getSpectator() const { return spectator; }
|
||||
bool getConceded() const { return conceded; }
|
||||
void setConceded(bool _conceded) { conceded = _conceded; }
|
||||
ServerInfo_User *getUserInfo() const { return userInfo; }
|
||||
DeckList *getDeck() const { return deck; }
|
||||
Server_Game *getGame() const { return game; }
|
||||
const QMap<QString, Server_CardZone *> &getZones() const { return zones; }
|
||||
|
|
|
@ -448,7 +448,7 @@ Response::ResponseCode Server_ProtocolHandler::cmdGetUserInfo(const Command_GetU
|
|||
else
|
||||
return Response::RespNameNotFound;
|
||||
|
||||
re->mutable_user_info()->CopyFrom(infoSource->copyUserInfo(true, userInfo->user_level() & ServerInfo_User::IsModerator));
|
||||
re->mutable_user_info()->CopyFrom(infoSource->copyUserInfo(true, false, userInfo->user_level() & ServerInfo_User::IsModerator));
|
||||
}
|
||||
|
||||
rc.setResponseExtension(re);
|
||||
|
|
|
@ -30,18 +30,24 @@ void ServerInfo_User_Container::setUserInfo(const ServerInfo_User &_userInfo)
|
|||
userInfo->CopyFrom(_userInfo);
|
||||
}
|
||||
|
||||
ServerInfo_User ServerInfo_User_Container::copyUserInfo(bool complete, bool moderatorInfo) const
|
||||
ServerInfo_User &ServerInfo_User_Container::copyUserInfo(ServerInfo_User &result, bool complete, bool internalInfo, bool sessionInfo) const
|
||||
{
|
||||
ServerInfo_User result;
|
||||
if (userInfo) {
|
||||
result.CopyFrom(*userInfo);
|
||||
if (!moderatorInfo) {
|
||||
if (!sessionInfo) {
|
||||
result.clear_session_id();
|
||||
result.clear_address();
|
||||
result.clear_id();
|
||||
}
|
||||
if (!internalInfo)
|
||||
result.clear_id();
|
||||
if (!complete)
|
||||
result.clear_avatar_bmp();
|
||||
}
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
|
||||
ServerInfo_User ServerInfo_User_Container::copyUserInfo(bool complete, bool internalInfo, bool sessionInfo) const
|
||||
{
|
||||
ServerInfo_User result;
|
||||
return copyUserInfo(result, complete, internalInfo, sessionInfo);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,8 @@ public:
|
|||
virtual ~ServerInfo_User_Container();
|
||||
ServerInfo_User *getUserInfo() const { return userInfo; }
|
||||
void setUserInfo(const ServerInfo_User &_userInfo);
|
||||
ServerInfo_User copyUserInfo(bool complete, bool moderatorInfo = false) const;
|
||||
ServerInfo_User ©UserInfo(ServerInfo_User &result, bool complete, bool internalInfo = false, bool sessionInfo = false) const;
|
||||
ServerInfo_User copyUserInfo(bool complete, bool internalInfo = false, bool sessionInfo = false) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue