Preparing "allow spectators" flag in network protocol (#215).
This commit is contained in:
+7
-6
@@ -72,13 +72,14 @@ enum AfterManualBlindsMode {
|
||||
|
||||
// For the sake of simplicity, this is a struct.
|
||||
struct GameData {
|
||||
GameData() : gameType(GAME_TYPE_NORMAL), maxNumberOfPlayers(0), startMoney(0),
|
||||
firstSmallBlind(0), raiseIntervalMode(RAISE_ON_HANDNUMBER),
|
||||
raiseSmallBlindEveryHandsValue(8), raiseSmallBlindEveryMinutesValue(1),
|
||||
raiseMode(DOUBLE_BLINDS), afterManualBlindsMode(AFTERMB_DOUBLE_BLINDS),
|
||||
afterMBAlwaysRaiseValue(0), guiSpeed(4), delayBetweenHandsSec(6),
|
||||
playerActionTimeoutSec(20) {}
|
||||
GameData() : gameType(GAME_TYPE_NORMAL), allowSpectators(true),
|
||||
maxNumberOfPlayers(0), startMoney(0), firstSmallBlind(0),
|
||||
raiseIntervalMode(RAISE_ON_HANDNUMBER), raiseSmallBlindEveryHandsValue(8),
|
||||
raiseSmallBlindEveryMinutesValue(1), raiseMode(DOUBLE_BLINDS),
|
||||
afterManualBlindsMode(AFTERMB_DOUBLE_BLINDS), afterMBAlwaysRaiseValue(0),
|
||||
guiSpeed(4), delayBetweenHandsSec(6), playerActionTimeoutSec(20) {}
|
||||
GameType gameType;
|
||||
bool allowSpectators;
|
||||
int maxNumberOfPlayers;
|
||||
int startMoney;
|
||||
int firstSmallBlind;
|
||||
|
||||
@@ -352,6 +352,7 @@ void gameLobbyDialogImpl::createGame()
|
||||
gameData.delayBetweenHandsSec = myCreateInternetGameDialog->spinBox_netDelayBetweenHands->value();
|
||||
gameData.playerActionTimeoutSec = myCreateInternetGameDialog->spinBox_netTimeOutPlayerAction->value();
|
||||
gameData.gameType = GameType(myCreateInternetGameDialog->comboBox_gameType->itemData(myCreateInternetGameDialog->comboBox_gameType->currentIndex(), Qt::UserRole).toInt());
|
||||
gameData.allowSpectators = myCreateInternetGameDialog->checkBox_allowSpectators->isChecked();
|
||||
|
||||
currentGameName = myCreateInternetGameDialog->lineEdit_gameName->text().simplified();
|
||||
|
||||
@@ -384,7 +385,6 @@ void gameLobbyDialogImpl::createGame()
|
||||
label_StartCash->setText(QString("%L1").arg(gameData.startMoney));
|
||||
updateDialogBlinds(gameData);
|
||||
label_GameTiming->setText(QString::number(gameData.playerActionTimeoutSec)+" "+tr("sec (action)")+"\n"+QString::number(gameData.delayBetweenHandsSec)+" "+tr("sec (hand delay)"));
|
||||
// TODO gameData.allowSpectators = myCreateInternetGameDialog->checkBox_allowSpectators->isChecked();
|
||||
|
||||
mySession->clientCreateGame(gameData, currentGameName.toUtf8().constData(), myCreateInternetGameDialog->lineEdit_Password->text().toUtf8().constData());
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ void
|
||||
NetPacket::SetGameData(const GameData &inData, NetGameInfo &outData)
|
||||
{
|
||||
outData.set_netgametype(static_cast<NetGameInfo::NetGameType>(inData.gameType));
|
||||
outData.set_allowspectators(inData.allowSpectators);
|
||||
outData.set_maxnumplayers(inData.maxNumberOfPlayers);
|
||||
outData.set_raiseintervalmode(static_cast<NetGameInfo::RaiseIntervalMode>(inData.raiseIntervalMode));
|
||||
if (inData.raiseIntervalMode == RAISE_ON_HANDNUMBER) {
|
||||
@@ -124,6 +125,7 @@ NetPacket::GetGameData(const NetGameInfo &inData, GameData &outData)
|
||||
int numManualBlinds = inData.manualblinds_size();
|
||||
|
||||
outData.gameType = static_cast<GameType>(inData.netgametype());
|
||||
outData.allowSpectators = inData.allowspectators();
|
||||
outData.maxNumberOfPlayers = inData.maxnumplayers();
|
||||
outData.raiseIntervalMode = static_cast<RaiseIntervalMode>(inData.raiseintervalmode());
|
||||
outData.raiseSmallBlindEveryHandsValue = outData.raiseSmallBlindEveryMinutesValue = 0;
|
||||
|
||||
@@ -1144,7 +1144,8 @@ ServerGame::CheckSettings(const GameData &data, const string &password, ServerMo
|
||||
|| (data.raiseIntervalMode != RAISE_ON_HANDNUMBER)
|
||||
|| (data.raiseMode != DOUBLE_BLINDS)
|
||||
|| (data.raiseSmallBlindEveryHandsValue != RANKING_GAME_RAISE_EVERY_HAND)
|
||||
|| (!password.empty())) {
|
||||
|| (!password.empty())
|
||||
|| (!data.allowSpectators)) {
|
||||
retVal = false;
|
||||
}
|
||||
}
|
||||
|
||||
+33
@@ -465,6 +465,7 @@ const int NetGameInfo::kPlayerActionTimeoutFieldNumber;
|
||||
const int NetGameInfo::kFirstSmallBlindFieldNumber;
|
||||
const int NetGameInfo::kStartMoneyFieldNumber;
|
||||
const int NetGameInfo::kManualBlindsFieldNumber;
|
||||
const int NetGameInfo::kAllowSpectatorsFieldNumber;
|
||||
#endif // !_MSC_VER
|
||||
|
||||
NetGameInfo::NetGameInfo()
|
||||
@@ -496,6 +497,7 @@ void NetGameInfo::SharedCtor() {
|
||||
playeractiontimeout_ = 0u;
|
||||
firstsmallblind_ = 0u;
|
||||
startmoney_ = 0u;
|
||||
allowspectators_ = true;
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
}
|
||||
|
||||
@@ -556,6 +558,7 @@ void NetGameInfo::Clear() {
|
||||
playeractiontimeout_ = 0u;
|
||||
firstsmallblind_ = 0u;
|
||||
startmoney_ = 0u;
|
||||
allowspectators_ = true;
|
||||
}
|
||||
manualblinds_.Clear();
|
||||
::memset(_has_bits_, 0, sizeof(_has_bits_));
|
||||
@@ -798,6 +801,22 @@ bool NetGameInfo::MergePartialFromCodedStream(
|
||||
} else {
|
||||
goto handle_uninterpreted;
|
||||
}
|
||||
if (input->ExpectTag(120)) goto parse_allowSpectators;
|
||||
break;
|
||||
}
|
||||
|
||||
// optional bool allowSpectators = 15 [default = true];
|
||||
case 15: {
|
||||
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
|
||||
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
|
||||
parse_allowSpectators:
|
||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
|
||||
input, &allowspectators_)));
|
||||
set_has_allowspectators();
|
||||
} else {
|
||||
goto handle_uninterpreted;
|
||||
}
|
||||
if (input->ExpectAtEnd()) return true;
|
||||
break;
|
||||
}
|
||||
@@ -898,6 +917,11 @@ void NetGameInfo::SerializeWithCachedSizes(
|
||||
this->manualblinds(i), output);
|
||||
}
|
||||
|
||||
// optional bool allowSpectators = 15 [default = true];
|
||||
if (has_allowspectators()) {
|
||||
::google::protobuf::internal::WireFormatLite::WriteBool(15, this->allowspectators(), output);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int NetGameInfo::ByteSize() const {
|
||||
@@ -994,6 +1018,11 @@ int NetGameInfo::ByteSize() const {
|
||||
this->startmoney());
|
||||
}
|
||||
|
||||
// optional bool allowSpectators = 15 [default = true];
|
||||
if (has_allowspectators()) {
|
||||
total_size += 1 + 1;
|
||||
}
|
||||
|
||||
}
|
||||
// repeated uint32 manualBlinds = 14 [packed = true];
|
||||
{
|
||||
@@ -1068,6 +1097,9 @@ void NetGameInfo::MergeFrom(const NetGameInfo& from) {
|
||||
if (from.has_startmoney()) {
|
||||
set_startmoney(from.startmoney());
|
||||
}
|
||||
if (from.has_allowspectators()) {
|
||||
set_allowspectators(from.allowspectators());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1099,6 +1131,7 @@ void NetGameInfo::Swap(NetGameInfo* other) {
|
||||
std::swap(firstsmallblind_, other->firstsmallblind_);
|
||||
std::swap(startmoney_, other->startmoney_);
|
||||
manualblinds_.Swap(&other->manualblinds_);
|
||||
std::swap(allowspectators_, other->allowspectators_);
|
||||
std::swap(_has_bits_[0], other->_has_bits_[0]);
|
||||
std::swap(_cached_size_, other->_cached_size_);
|
||||
}
|
||||
|
||||
+33
-1
@@ -746,6 +746,13 @@ class NetGameInfo : public ::google::protobuf::MessageLite {
|
||||
inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
|
||||
mutable_manualblinds();
|
||||
|
||||
// optional bool allowSpectators = 15 [default = true];
|
||||
inline bool has_allowspectators() const;
|
||||
inline void clear_allowspectators();
|
||||
static const int kAllowSpectatorsFieldNumber = 15;
|
||||
inline bool allowspectators() const;
|
||||
inline void set_allowspectators(bool value);
|
||||
|
||||
// @@protoc_insertion_point(class_scope:NetGameInfo)
|
||||
private:
|
||||
inline void set_has_gamename();
|
||||
@@ -774,6 +781,8 @@ class NetGameInfo : public ::google::protobuf::MessageLite {
|
||||
inline void clear_has_firstsmallblind();
|
||||
inline void set_has_startmoney();
|
||||
inline void clear_has_startmoney();
|
||||
inline void set_has_allowspectators();
|
||||
inline void clear_has_allowspectators();
|
||||
|
||||
::std::string* gamename_;
|
||||
int netgametype_;
|
||||
@@ -790,9 +799,10 @@ class NetGameInfo : public ::google::protobuf::MessageLite {
|
||||
::google::protobuf::uint32 startmoney_;
|
||||
::google::protobuf::RepeatedField< ::google::protobuf::uint32 > manualblinds_;
|
||||
mutable int _manualblinds_cached_byte_size_;
|
||||
bool allowspectators_;
|
||||
|
||||
mutable int _cached_size_;
|
||||
::google::protobuf::uint32 _has_bits_[(14 + 31) / 32];
|
||||
::google::protobuf::uint32 _has_bits_[(15 + 31) / 32];
|
||||
|
||||
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
|
||||
friend void protobuf_AddDesc_pokerth_2eproto_impl();
|
||||
@@ -11668,6 +11678,28 @@ NetGameInfo::mutable_manualblinds() {
|
||||
return &manualblinds_;
|
||||
}
|
||||
|
||||
// optional bool allowSpectators = 15 [default = true];
|
||||
inline bool NetGameInfo::has_allowspectators() const {
|
||||
return (_has_bits_[0] & 0x00004000u) != 0;
|
||||
}
|
||||
inline void NetGameInfo::set_has_allowspectators() {
|
||||
_has_bits_[0] |= 0x00004000u;
|
||||
}
|
||||
inline void NetGameInfo::clear_has_allowspectators() {
|
||||
_has_bits_[0] &= ~0x00004000u;
|
||||
}
|
||||
inline void NetGameInfo::clear_allowspectators() {
|
||||
allowspectators_ = true;
|
||||
clear_has_allowspectators();
|
||||
}
|
||||
inline bool NetGameInfo::allowspectators() const {
|
||||
return allowspectators_;
|
||||
}
|
||||
inline void NetGameInfo::set_allowspectators(bool value) {
|
||||
set_has_allowspectators();
|
||||
allowspectators_ = value;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
// PlayerResult
|
||||
|
||||
Reference in New Issue
Block a user