Extending player rights by guest mode. Kind of broken, because it interferes with the current system where you automatically gain admin rights when creating a game.

This commit is contained in:
lotodore
2010-03-24 15:54:04 +00:00
parent 01dcbd84d6
commit f10e4c3423
5 changed files with 15 additions and 11 deletions
+2
View File
@@ -124,6 +124,7 @@ HEADERS += src/third_party/asn1/AllInShowCardsMessage.h \
src/third_party/asn1/per_support.h \
src/third_party/asn1/PlayerAllIn.h \
src/third_party/asn1/PlayerInfoData.h \
src/third_party/asn1/PlayerInfoRights.h \
src/third_party/asn1/PlayerInfoReplyMessage.h \
src/third_party/asn1/PlayerInfoRequestMessage.h \
src/third_party/asn1/PlayerListMessage.h \
@@ -192,6 +193,7 @@ SOURCES += src/third_party/asn1/ChatCleanerMessage.c \
src/third_party/asn1/PlayerInfoRequestMessage.c \
src/third_party/asn1/PlayerInfoReplyMessage.c \
src/third_party/asn1/PlayerInfoData.c \
src/third_party/asn1/PlayerInfoRights.c \
src/third_party/asn1/PlayerAllIn.c \
src/third_party/asn1/PlayerListMessage.c \
src/third_party/asn1/per_support.c \
+5 -7
View File
@@ -668,10 +668,8 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr<ClientThread> clien
PlayerInfo tmpInfo;
PlayerInfoData_t *netInfo = &tmpPacket->GetMsg()->choice.playerInfoReplyMessage.playerInfoResult.choice.playerInfoData;
tmpInfo.playerName = STL_STRING_FROM_OCTET_STRING(netInfo->playerName);
if (netInfo->isHuman)
tmpInfo.ptype = PLAYER_TYPE_HUMAN;
else
tmpInfo.ptype = PLAYER_TYPE_COMPUTER;
tmpInfo.ptype = netInfo->isHuman ? PLAYER_TYPE_HUMAN : PLAYER_TYPE_COMPUTER;
tmpInfo.isGuest = netInfo->playerRights == PlayerInfoRights_playerRightsGuest;
if (netInfo->avatarData != NULL)
{
tmpInfo.hasAvatar = true;
@@ -1360,7 +1358,7 @@ ClientStateWaitJoin::InternalHandlePacket(boost::shared_ptr<ClientThread> client
// Player number is 0 on init. Will be set when the game starts.
boost::shared_ptr<PlayerData> playerData(
new PlayerData(client->GetGuiPlayerId(), 0, PLAYER_TYPE_HUMAN,
netJoinAck->areYouAdmin ? PLAYER_RIGHTS_ADMIN : PLAYER_RIGHTS_NORMAL));
static_cast<PlayerRights>(netJoinAck->yourRights)));
playerData->SetName(context.GetPlayerName());
playerData->SetAvatarFile(context.GetAvatarFile());
client->AddPlayerData(playerData);
@@ -1446,7 +1444,7 @@ ClientStateWaitGame::InternalHandlePacket(boost::shared_ptr<ClientThread> client
if (client->GetCachedPlayerInfo(netPlayerJoined->playerId, info))
{
playerData.reset(
new PlayerData(netPlayerJoined->playerId, 0, info.ptype, netPlayerJoined->isAdmin ? PLAYER_RIGHTS_ADMIN : PLAYER_RIGHTS_NORMAL));
new PlayerData(netPlayerJoined->playerId, 0, info.ptype, static_cast<PlayerRights>(netPlayerJoined->curPlayerRights)));
playerData->SetName(info.playerName);
if (info.hasAvatar)
{
@@ -1466,7 +1464,7 @@ ClientStateWaitGame::InternalHandlePacket(boost::shared_ptr<ClientThread> client
client->RequestPlayerInfo(netPlayerJoined->playerId, true);
// Use temporary data until the PlayerInfo request is completed.
playerData.reset(
new PlayerData(netPlayerJoined->playerId, 0, PLAYER_TYPE_HUMAN, netPlayerJoined->isAdmin ? PLAYER_RIGHTS_ADMIN : PLAYER_RIGHTS_NORMAL));
new PlayerData(netPlayerJoined->playerId, 0, PLAYER_TYPE_HUMAN, static_cast<PlayerRights>(netPlayerJoined->curPlayerRights)));
playerData->SetName(name.str());
}
client->AddPlayerData(playerData);
+3 -2
View File
@@ -339,7 +339,8 @@ ServerGameStateInit::HandleNewSession(boost::shared_ptr<ServerGame> server, Sess
netJoinReply->gameId = server->GetId();
netJoinReply->joinGameResult.present = joinGameResult_PR_joinGameAck;
JoinGameAck_t *joinAck = &netJoinReply->joinGameResult.choice.joinGameAck;
joinAck->areYouAdmin = session.playerData->GetRights() == PLAYER_RIGHTS_ADMIN;
joinAck->yourRights = static_cast<PlayerInfoRights>(session.playerData->GetRights());
NetPacket::SetGameData(server->GetGameData(), &joinAck->gameInfo);
OCTET_STRING_fromBuf(
&joinAck->gameInfo.gameName,
@@ -487,7 +488,7 @@ ServerGameStateInit::CreateNetPacketPlayerJoined(unsigned gameId, const PlayerDa
netGamePlayer->gamePlayerNotification.present = gamePlayerNotification_PR_gamePlayerJoined;
GamePlayerJoined_t *playerJoined = &netGamePlayer->gamePlayerNotification.choice.gamePlayerJoined;
playerJoined->playerId = playerData.GetUniqueId();
playerJoined->isAdmin = playerData.GetRights() == PLAYER_RIGHTS_ADMIN;
playerJoined->curPlayerRights = static_cast<PlayerInfoRights>(playerData.GetRights());
return packet;
}
+2 -1
View File
@@ -1042,7 +1042,7 @@ ServerLobbyThread::HandleNetPacketInit(SessionWrapper session, const InitMessage
// Create player data object.
boost::shared_ptr<PlayerData> tmpPlayerData(
new PlayerData(GetNextUniquePlayerId(), 0, PLAYER_TYPE_HUMAN, PLAYER_RIGHTS_NORMAL));
new PlayerData(GetNextUniquePlayerId(), 0, PLAYER_TYPE_HUMAN, validGuest ? PLAYER_RIGHTS_GUEST : PLAYER_RIGHTS_NORMAL));
tmpPlayerData->SetName(playerName);
tmpPlayerData->SetNetSessionData(session.sessionData);
tmpPlayerData->SetAvatarMD5(avatarMD5);
@@ -1197,6 +1197,7 @@ ServerLobbyThread::HandleNetPacketRetrievePlayerInfo(SessionWrapper session, con
PlayerInfoData *data = &netPlayerInfoReply->playerInfoResult.choice.playerInfoData;
data->isHuman = tmpPlayer->GetType() == PLAYER_TYPE_HUMAN;
data->playerRights = static_cast<PlayerInfoRights>(tmpPlayer->GetRights());
OCTET_STRING_fromBuf(
&data->playerName,
tmpPlayer->GetName().c_str(),
+3 -1
View File
@@ -40,6 +40,7 @@ enum PlayerType
enum PlayerRights
{
PLAYER_RIGHTS_GUEST = 1,
PLAYER_RIGHTS_NORMAL,
PLAYER_RIGHTS_ADMIN
};
@@ -62,9 +63,10 @@ struct AvatarFile
struct PlayerInfo
{
PlayerInfo() : ptype(PLAYER_TYPE_HUMAN), hasAvatar(false), avatarType(AVATAR_FILE_TYPE_UNKNOWN) {}
PlayerInfo() : ptype(PLAYER_TYPE_HUMAN), isGuest(false), hasAvatar(false), avatarType(AVATAR_FILE_TYPE_UNKNOWN) {}
std::string playerName;
PlayerType ptype;
bool isGuest;
bool hasAvatar;
MD5Buf avatar;
AvatarFileType avatarType;