Work on spectator mode - joining as spectator now possible (on server side).

This commit is contained in:
lotodore
2013-06-29 16:23:10 +02:00
parent cbd6b40f85
commit ef489dae8a
12 changed files with 732 additions and 118 deletions
+58 -6
View File
@@ -4569,6 +4569,7 @@ const int GameListNewMessage::kIsPrivateFieldNumber;
const int GameListNewMessage::kPlayerIdsFieldNumber;
const int GameListNewMessage::kAdminPlayerIdFieldNumber;
const int GameListNewMessage::kGameInfoFieldNumber;
const int GameListNewMessage::kSpectatorIdsFieldNumber;
#endif // !_MSC_VER
GameListNewMessage::GameListNewMessage()
@@ -4646,6 +4647,7 @@ void GameListNewMessage::Clear() {
}
}
playerids_.Clear();
spectatorids_.Clear();
::memset(_has_bits_, 0, sizeof(_has_bits_));
}
@@ -4752,6 +4754,27 @@ bool GameListNewMessage::MergePartialFromCodedStream(
} else {
goto handle_uninterpreted;
}
if (input->ExpectTag(58)) goto parse_spectatorIds;
break;
}
// repeated uint32 spectatorIds = 7 [packed = true];
case 7: {
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) {
parse_spectatorIds:
DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive<
::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
input, this->mutable_spectatorids())));
} else if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag)
== ::google::protobuf::internal::WireFormatLite::
WIRETYPE_VARINT) {
DO_((::google::protobuf::internal::WireFormatLite::ReadRepeatedPrimitiveNoInline<
::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>(
1, 58, input, this->mutable_spectatorids())));
} else {
goto handle_uninterpreted;
}
if (input->ExpectAtEnd()) return true;
break;
}
@@ -4810,6 +4833,16 @@ void GameListNewMessage::SerializeWithCachedSizes(
6, this->gameinfo(), output);
}
// repeated uint32 spectatorIds = 7 [packed = true];
if (this->spectatorids_size() > 0) {
::google::protobuf::internal::WireFormatLite::WriteTag(7, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output);
output->WriteVarint32(_spectatorids_cached_byte_size_);
}
for (int i = 0; i < this->spectatorids_size(); i++) {
::google::protobuf::internal::WireFormatLite::WriteUInt32NoTag(
this->spectatorids(i), output);
}
}
int GameListNewMessage::ByteSize() const {
@@ -4866,6 +4899,23 @@ int GameListNewMessage::ByteSize() const {
total_size += data_size;
}
// repeated uint32 spectatorIds = 7 [packed = true];
{
int data_size = 0;
for (int i = 0; i < this->spectatorids_size(); i++) {
data_size += ::google::protobuf::internal::WireFormatLite::
UInt32Size(this->spectatorids(i));
}
if (data_size > 0) {
total_size += 1 +
::google::protobuf::internal::WireFormatLite::Int32Size(data_size);
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_spectatorids_cached_byte_size_ = data_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
total_size += data_size;
}
GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN();
_cached_size_ = total_size;
GOOGLE_SAFE_CONCURRENT_WRITES_END();
@@ -4880,6 +4930,7 @@ void GameListNewMessage::CheckTypeAndMergeFrom(
void GameListNewMessage::MergeFrom(const GameListNewMessage& from) {
GOOGLE_CHECK_NE(&from, this);
playerids_.MergeFrom(from.playerids_);
spectatorids_.MergeFrom(from.spectatorids_);
if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) {
if (from.has_gameid()) {
set_gameid(from.gameid());
@@ -4922,6 +4973,7 @@ void GameListNewMessage::Swap(GameListNewMessage* other) {
playerids_.Swap(&other->playerids_);
std::swap(adminplayerid_, other->adminplayerid_);
std::swap(gameinfo_, other->gameinfo_);
spectatorids_.Swap(&other->spectatorids_);
std::swap(_has_bits_[0], other->_has_bits_[0]);
std::swap(_cached_size_, other->_cached_size_);
}
@@ -7394,7 +7446,7 @@ bool JoinExistingGameMessage::MergePartialFromCodedStream(
break;
}
// optional bool autoLeave = 3;
// optional bool autoLeave = 3 [default = false];
case 3: {
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
@@ -7410,7 +7462,7 @@ bool JoinExistingGameMessage::MergePartialFromCodedStream(
break;
}
// optional bool spectateOnly = 4;
// optional bool spectateOnly = 4 [default = false];
case 4: {
if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) ==
::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) {
@@ -7454,12 +7506,12 @@ void JoinExistingGameMessage::SerializeWithCachedSizes(
2, this->password(), output);
}
// optional bool autoLeave = 3;
// optional bool autoLeave = 3 [default = false];
if (has_autoleave()) {
::google::protobuf::internal::WireFormatLite::WriteBool(3, this->autoleave(), output);
}
// optional bool spectateOnly = 4;
// optional bool spectateOnly = 4 [default = false];
if (has_spectateonly()) {
::google::protobuf::internal::WireFormatLite::WriteBool(4, this->spectateonly(), output);
}
@@ -7484,12 +7536,12 @@ int JoinExistingGameMessage::ByteSize() const {
this->password());
}
// optional bool autoLeave = 3;
// optional bool autoLeave = 3 [default = false];
if (has_autoleave()) {
total_size += 1 + 1;
}
// optional bool spectateOnly = 4;
// optional bool spectateOnly = 4 [default = false];
if (has_spectateonly()) {
total_size += 1 + 1;
}
+44 -5
View File
@@ -2443,6 +2443,18 @@ class GameListNewMessage : public ::google::protobuf::MessageLite {
inline ::NetGameInfo* release_gameinfo();
inline void set_allocated_gameinfo(::NetGameInfo* gameinfo);
// repeated uint32 spectatorIds = 7 [packed = true];
inline int spectatorids_size() const;
inline void clear_spectatorids();
static const int kSpectatorIdsFieldNumber = 7;
inline ::google::protobuf::uint32 spectatorids(int index) const;
inline void set_spectatorids(int index, ::google::protobuf::uint32 value);
inline void add_spectatorids(::google::protobuf::uint32 value);
inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
spectatorids() const;
inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
mutable_spectatorids();
// @@protoc_insertion_point(class_scope:GameListNewMessage)
private:
inline void set_has_gameid();
@@ -2463,9 +2475,11 @@ class GameListNewMessage : public ::google::protobuf::MessageLite {
bool isprivate_;
::google::protobuf::uint32 adminplayerid_;
::NetGameInfo* gameinfo_;
::google::protobuf::RepeatedField< ::google::protobuf::uint32 > spectatorids_;
mutable int _spectatorids_cached_byte_size_;
mutable int _cached_size_;
::google::protobuf::uint32 _has_bits_[(6 + 31) / 32];
::google::protobuf::uint32 _has_bits_[(7 + 31) / 32];
#ifdef GOOGLE_PROTOBUF_NO_STATIC_INITIALIZER
friend void protobuf_AddDesc_pokerth_2eproto_impl();
@@ -3625,14 +3639,14 @@ class JoinExistingGameMessage : public ::google::protobuf::MessageLite {
inline ::std::string* release_password();
inline void set_allocated_password(::std::string* password);
// optional bool autoLeave = 3;
// optional bool autoLeave = 3 [default = false];
inline bool has_autoleave() const;
inline void clear_autoleave();
static const int kAutoLeaveFieldNumber = 3;
inline bool autoleave() const;
inline void set_autoleave(bool value);
// optional bool spectateOnly = 4;
// optional bool spectateOnly = 4 [default = false];
inline bool has_spectateonly() const;
inline void clear_spectateonly();
static const int kSpectateOnlyFieldNumber = 4;
@@ -13381,6 +13395,31 @@ inline void GameListNewMessage::set_allocated_gameinfo(::NetGameInfo* gameinfo)
}
}
// repeated uint32 spectatorIds = 7 [packed = true];
inline int GameListNewMessage::spectatorids_size() const {
return spectatorids_.size();
}
inline void GameListNewMessage::clear_spectatorids() {
spectatorids_.Clear();
}
inline ::google::protobuf::uint32 GameListNewMessage::spectatorids(int index) const {
return spectatorids_.Get(index);
}
inline void GameListNewMessage::set_spectatorids(int index, ::google::protobuf::uint32 value) {
spectatorids_.Set(index, value);
}
inline void GameListNewMessage::add_spectatorids(::google::protobuf::uint32 value) {
spectatorids_.Add(value);
}
inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >&
GameListNewMessage::spectatorids() const {
return spectatorids_;
}
inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >*
GameListNewMessage::mutable_spectatorids() {
return &spectatorids_;
}
// -------------------------------------------------------------------
// GameListUpdateMessage
@@ -14218,7 +14257,7 @@ inline void JoinExistingGameMessage::set_allocated_password(::std::string* passw
}
}
// optional bool autoLeave = 3;
// optional bool autoLeave = 3 [default = false];
inline bool JoinExistingGameMessage::has_autoleave() const {
return (_has_bits_[0] & 0x00000004u) != 0;
}
@@ -14240,7 +14279,7 @@ inline void JoinExistingGameMessage::set_autoleave(bool value) {
autoleave_ = value;
}
// optional bool spectateOnly = 4;
// optional bool spectateOnly = 4 [default = false];
inline bool JoinExistingGameMessage::has_spectateonly() const {
return (_has_bits_[0] & 0x00000008u) != 0;
}