From 652a9e55b41d911ae944e38a741663df1dcaf5d7 Mon Sep 17 00:00:00 2001 From: lotodore Date: Thu, 1 Apr 2010 17:09:49 +0000 Subject: [PATCH] Adding country code to protocol (currently broken). --- docs/pokerth.asn1 | 1 + src/net/common/clientstate.cpp | 6 +++++- src/net/common/serverlobbythread.cpp | 9 ++++++++- src/playerdata.h | 1 + 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/docs/pokerth.asn1 b/docs/pokerth.asn1 index 147101b0..f4d140fd 100644 --- a/docs/pokerth.asn1 +++ b/docs/pokerth.asn1 @@ -249,6 +249,7 @@ PlayerInfoData ::= SEQUENCE { playerName UTF8String (SIZE(1..32)), isHuman BOOLEAN, playerRights PlayerInfoRights, + countryCode UTF8String (SIZE(2)) OPTIONAL, avatarData SEQUENCE { avatarType NetAvatarType, avatar AvatarHash diff --git a/src/net/common/clientstate.cpp b/src/net/common/clientstate.cpp index 0293385d..4f7f7073 100644 --- a/src/net/common/clientstate.cpp +++ b/src/net/common/clientstate.cpp @@ -670,7 +670,11 @@ AbstractClientStateReceiving::HandlePacket(boost::shared_ptr clien tmpInfo.playerName = STL_STRING_FROM_OCTET_STRING(netInfo->playerName); tmpInfo.ptype = netInfo->isHuman ? PLAYER_TYPE_HUMAN : PLAYER_TYPE_COMPUTER; tmpInfo.isGuest = netInfo->playerRights == PlayerInfoRights_playerRightsGuest; - if (netInfo->avatarData != NULL) + if (netInfo->countryCode) + { + tmpInfo.countryCode = STL_STRING_FROM_OCTET_STRING(*netInfo->countryCode); + } + if (netInfo->avatarData) { tmpInfo.hasAvatar = true; memcpy(tmpInfo.avatar.GetData(), netInfo->avatarData->avatar.buf, MD5_DATA_SIZE); diff --git a/src/net/common/serverlobbythread.cpp b/src/net/common/serverlobbythread.cpp index 67bc6dc7..5a3301b0 100644 --- a/src/net/common/serverlobbythread.cpp +++ b/src/net/common/serverlobbythread.cpp @@ -1205,7 +1205,7 @@ ServerLobbyThread::HandleNetPacketRetrievePlayerInfo(SessionWrapper session, con PlayerInfoReplyMessage_t *netPlayerInfoReply = &packet->GetMsg()->choice.playerInfoReplyMessage; netPlayerInfoReply->playerId = tmpPlayer->GetUniqueId(); - if (tmpPlayer.get()) + if (tmpPlayer) { // Send player info to client. netPlayerInfoReply->playerInfoResult.present = playerInfoResult_PR_playerInfoData; @@ -1217,6 +1217,13 @@ ServerLobbyThread::HandleNetPacketRetrievePlayerInfo(SessionWrapper session, con &data->playerName, tmpPlayer->GetName().c_str(), tmpPlayer->GetName().length()); + if (!tmpPlayer->GetCountry().empty()) + { + data->countryCode = OCTET_STRING_new_fromBuf( + &asn_DEF_UTF8String, + tmpPlayer->GetCountry().c_str(), + tmpPlayer->GetCountry().length()); + } if (!tmpPlayer->GetAvatarMD5().IsZero()) { data->avatarData = (struct PlayerInfoData::avatarData *)calloc(1, sizeof(struct PlayerInfoData::avatarData)); diff --git a/src/playerdata.h b/src/playerdata.h index 6807cc52..7ee50900 100644 --- a/src/playerdata.h +++ b/src/playerdata.h @@ -67,6 +67,7 @@ struct PlayerInfo std::string playerName; PlayerType ptype; bool isGuest; + std::string countryCode; bool hasAvatar; MD5Buf avatar; AvatarFileType avatarType;