From cd1b32f87128de8cc948d4f6cfa1da67291c970b Mon Sep 17 00:00:00 2001 From: totycro Date: Sat, 9 Apr 2011 16:05:52 +0200 Subject: added .proto file and generated sources --- pacman-c++/client.cpp | 2 +- pacman-c++/constants.h | 1 + pacman-c++/pacman.pb.cc | 552 +++++++++++++++++++++++++++++++++++++++++++ pacman-c++/pacman.pb.h | 276 ++++++++++++++++++++++ pacman-c++/pacman.pro | 9 +- pacman-c++/pacman.proto | 7 + pacman-c++/pacman.server.pro | 9 +- pacman-c++/sceneholder.cpp | 2 +- pacman-c++/server.cpp | 3 +- 9 files changed, 854 insertions(+), 7 deletions(-) create mode 100644 pacman-c++/pacman.pb.cc create mode 100644 pacman-c++/pacman.pb.h create mode 100644 pacman-c++/pacman.proto (limited to 'pacman-c++') diff --git a/pacman-c++/client.cpp b/pacman-c++/client.cpp index 2142278..d4324b7 100644 --- a/pacman-c++/client.cpp +++ b/pacman-c++/client.cpp @@ -30,7 +30,7 @@ void Client::createMenu() QImage img(muted ? ":/soundoff" : ":/soundon"); img.setColor(1, menuBar()->palette().color( muted ? QPalette::Disabled : QPalette::Active, - dQPalette::ButtonText).rgba()); + QPalette::ButtonText).rgba()); toggleSound->setPixmap(QPixmap::fromImage(img)); if (sound) diff --git a/pacman-c++/constants.h b/pacman-c++/constants.h index 8977b08..44999f7 100644 --- a/pacman-c++/constants.h +++ b/pacman-c++/constants.h @@ -1,5 +1,6 @@ #ifndef CONSTANTS_H #define CONSTANTS_H +#include namespace Constants { const struct diff --git a/pacman-c++/pacman.pb.cc b/pacman-c++/pacman.pb.cc new file mode 100644 index 0000000..8777326 --- /dev/null +++ b/pacman-c++/pacman.pb.cc @@ -0,0 +1,552 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! + +#define INTERNAL_SUPPRESS_PROTOBUF_FIELD_DEPRECATION +#include "pacman.pb.h" + +#include + +#include +#include +#include +#include +#include +#include +// @@protoc_insertion_point(includes) + +namespace { + +const ::google::protobuf::Descriptor* KeyPressUpdate_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + KeyPressUpdate_reflection_ = NULL; +const ::google::protobuf::Descriptor* MapUpdate_descriptor_ = NULL; +const ::google::protobuf::internal::GeneratedMessageReflection* + MapUpdate_reflection_ = NULL; + +} // namespace + + +void protobuf_AssignDesc_pacman_2eproto() { + protobuf_AddDesc_pacman_2eproto(); + const ::google::protobuf::FileDescriptor* file = + ::google::protobuf::DescriptorPool::generated_pool()->FindFileByName( + "pacman.proto"); + GOOGLE_CHECK(file != NULL); + KeyPressUpdate_descriptor_ = file->message_type(0); + static const int KeyPressUpdate_offsets_[1] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(KeyPressUpdate, newkey_), + }; + KeyPressUpdate_reflection_ = + new ::google::protobuf::internal::GeneratedMessageReflection( + KeyPressUpdate_descriptor_, + KeyPressUpdate::default_instance_, + KeyPressUpdate_offsets_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(KeyPressUpdate, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(KeyPressUpdate, _unknown_fields_), + -1, + ::google::protobuf::DescriptorPool::generated_pool(), + ::google::protobuf::MessageFactory::generated_factory(), + sizeof(KeyPressUpdate)); + MapUpdate_descriptor_ = file->message_type(1); + static const int MapUpdate_offsets_[1] = { + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapUpdate, field_), + }; + MapUpdate_reflection_ = + new ::google::protobuf::internal::GeneratedMessageReflection( + MapUpdate_descriptor_, + MapUpdate::default_instance_, + MapUpdate_offsets_, + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapUpdate, _has_bits_[0]), + GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(MapUpdate, _unknown_fields_), + -1, + ::google::protobuf::DescriptorPool::generated_pool(), + ::google::protobuf::MessageFactory::generated_factory(), + sizeof(MapUpdate)); +} + +namespace { + +GOOGLE_PROTOBUF_DECLARE_ONCE(protobuf_AssignDescriptors_once_); +inline void protobuf_AssignDescriptorsOnce() { + ::google::protobuf::GoogleOnceInit(&protobuf_AssignDescriptors_once_, + &protobuf_AssignDesc_pacman_2eproto); +} + +void protobuf_RegisterTypes(const ::std::string&) { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + KeyPressUpdate_descriptor_, &KeyPressUpdate::default_instance()); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedMessage( + MapUpdate_descriptor_, &MapUpdate::default_instance()); +} + +} // namespace + +void protobuf_ShutdownFile_pacman_2eproto() { + delete KeyPressUpdate::default_instance_; + delete KeyPressUpdate_reflection_; + delete MapUpdate::default_instance_; + delete MapUpdate_reflection_; +} + +void protobuf_AddDesc_pacman_2eproto() { + static bool already_here = false; + if (already_here) return; + already_here = true; + GOOGLE_PROTOBUF_VERIFY_VERSION; + + ::google::protobuf::DescriptorPool::InternalAddGeneratedFile( + "\n\014pacman.proto\" \n\016KeyPressUpdate\022\016\n\006newK" + "ey\030\001 \002(\r\"\036\n\tMapUpdate\022\021\n\005field\030\001 \003(\rB\002\020\001", 80); + ::google::protobuf::MessageFactory::InternalRegisterGeneratedFile( + "pacman.proto", &protobuf_RegisterTypes); + KeyPressUpdate::default_instance_ = new KeyPressUpdate(); + MapUpdate::default_instance_ = new MapUpdate(); + KeyPressUpdate::default_instance_->InitAsDefaultInstance(); + MapUpdate::default_instance_->InitAsDefaultInstance(); + ::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_pacman_2eproto); +} + +// Force AddDescriptors() to be called at static initialization time. +struct StaticDescriptorInitializer_pacman_2eproto { + StaticDescriptorInitializer_pacman_2eproto() { + protobuf_AddDesc_pacman_2eproto(); + } +} static_descriptor_initializer_pacman_2eproto_; + + +// =================================================================== + +#ifndef _MSC_VER +const int KeyPressUpdate::kNewKeyFieldNumber; +#endif // !_MSC_VER + +KeyPressUpdate::KeyPressUpdate() + : ::google::protobuf::Message() { + SharedCtor(); +} + +void KeyPressUpdate::InitAsDefaultInstance() { +} + +KeyPressUpdate::KeyPressUpdate(const KeyPressUpdate& from) + : ::google::protobuf::Message() { + SharedCtor(); + MergeFrom(from); +} + +void KeyPressUpdate::SharedCtor() { + _cached_size_ = 0; + newkey_ = 0u; + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +KeyPressUpdate::~KeyPressUpdate() { + SharedDtor(); +} + +void KeyPressUpdate::SharedDtor() { + if (this != default_instance_) { + } +} + +void KeyPressUpdate::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* KeyPressUpdate::descriptor() { + protobuf_AssignDescriptorsOnce(); + return KeyPressUpdate_descriptor_; +} + +const KeyPressUpdate& KeyPressUpdate::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_pacman_2eproto(); return *default_instance_; +} + +KeyPressUpdate* KeyPressUpdate::default_instance_ = NULL; + +KeyPressUpdate* KeyPressUpdate::New() const { + return new KeyPressUpdate; +} + +void KeyPressUpdate::Clear() { + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + newkey_ = 0u; + } + ::memset(_has_bits_, 0, sizeof(_has_bits_)); + mutable_unknown_fields()->Clear(); +} + +bool KeyPressUpdate::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) return false + ::google::protobuf::uint32 tag; + while ((tag = input->ReadTag()) != 0) { + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // required uint32 newKey = 1; + case 1: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_VARINT) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, &newkey_))); + set_has_newkey(); + } else { + goto handle_uninterpreted; + } + if (input->ExpectAtEnd()) return true; + break; + } + + default: { + handle_uninterpreted: + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + return true; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } + return true; +#undef DO_ +} + +void KeyPressUpdate::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // required uint32 newKey = 1; + if (has_newkey()) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32(1, this->newkey(), output); + } + + if (!unknown_fields().empty()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } +} + +::google::protobuf::uint8* KeyPressUpdate::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // required uint32 newKey = 1; + if (has_newkey()) { + target = ::google::protobuf::internal::WireFormatLite::WriteUInt32ToArray(1, this->newkey(), target); + } + + if (!unknown_fields().empty()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + return target; +} + +int KeyPressUpdate::ByteSize() const { + int total_size = 0; + + if (_has_bits_[0 / 32] & (0xffu << (0 % 32))) { + // required uint32 newKey = 1; + if (has_newkey()) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::UInt32Size( + this->newkey()); + } + + } + if (!unknown_fields().empty()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void KeyPressUpdate::MergeFrom(const ::google::protobuf::Message& from) { + GOOGLE_CHECK_NE(&from, this); + const KeyPressUpdate* source = + ::google::protobuf::internal::dynamic_cast_if_available( + &from); + if (source == NULL) { + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + MergeFrom(*source); + } +} + +void KeyPressUpdate::MergeFrom(const KeyPressUpdate& from) { + GOOGLE_CHECK_NE(&from, this); + if (from._has_bits_[0 / 32] & (0xffu << (0 % 32))) { + if (from.has_newkey()) { + set_newkey(from.newkey()); + } + } + mutable_unknown_fields()->MergeFrom(from.unknown_fields()); +} + +void KeyPressUpdate::CopyFrom(const ::google::protobuf::Message& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void KeyPressUpdate::CopyFrom(const KeyPressUpdate& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool KeyPressUpdate::IsInitialized() const { + if ((_has_bits_[0] & 0x00000001) != 0x00000001) return false; + + return true; +} + +void KeyPressUpdate::Swap(KeyPressUpdate* other) { + if (other != this) { + std::swap(newkey_, other->newkey_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _unknown_fields_.Swap(&other->_unknown_fields_); + std::swap(_cached_size_, other->_cached_size_); + } +} + +::google::protobuf::Metadata KeyPressUpdate::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = KeyPressUpdate_descriptor_; + metadata.reflection = KeyPressUpdate_reflection_; + return metadata; +} + + +// =================================================================== + +#ifndef _MSC_VER +const int MapUpdate::kFieldFieldNumber; +#endif // !_MSC_VER + +MapUpdate::MapUpdate() + : ::google::protobuf::Message() { + SharedCtor(); +} + +void MapUpdate::InitAsDefaultInstance() { +} + +MapUpdate::MapUpdate(const MapUpdate& from) + : ::google::protobuf::Message() { + SharedCtor(); + MergeFrom(from); +} + +void MapUpdate::SharedCtor() { + _cached_size_ = 0; + ::memset(_has_bits_, 0, sizeof(_has_bits_)); +} + +MapUpdate::~MapUpdate() { + SharedDtor(); +} + +void MapUpdate::SharedDtor() { + if (this != default_instance_) { + } +} + +void MapUpdate::SetCachedSize(int size) const { + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); +} +const ::google::protobuf::Descriptor* MapUpdate::descriptor() { + protobuf_AssignDescriptorsOnce(); + return MapUpdate_descriptor_; +} + +const MapUpdate& MapUpdate::default_instance() { + if (default_instance_ == NULL) protobuf_AddDesc_pacman_2eproto(); return *default_instance_; +} + +MapUpdate* MapUpdate::default_instance_ = NULL; + +MapUpdate* MapUpdate::New() const { + return new MapUpdate; +} + +void MapUpdate::Clear() { + field_.Clear(); + ::memset(_has_bits_, 0, sizeof(_has_bits_)); + mutable_unknown_fields()->Clear(); +} + +bool MapUpdate::MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input) { +#define DO_(EXPRESSION) if (!(EXPRESSION)) return false + ::google::protobuf::uint32 tag; + while ((tag = input->ReadTag()) != 0) { + switch (::google::protobuf::internal::WireFormatLite::GetTagFieldNumber(tag)) { + // repeated uint32 field = 1 [packed = true]; + case 1: { + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED) { + DO_((::google::protobuf::internal::WireFormatLite::ReadPackedPrimitive< + ::google::protobuf::uint32, ::google::protobuf::internal::WireFormatLite::TYPE_UINT32>( + input, this->mutable_field()))); + } 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, 10, input, this->mutable_field()))); + } else { + goto handle_uninterpreted; + } + if (input->ExpectAtEnd()) return true; + break; + } + + default: { + handle_uninterpreted: + if (::google::protobuf::internal::WireFormatLite::GetTagWireType(tag) == + ::google::protobuf::internal::WireFormatLite::WIRETYPE_END_GROUP) { + return true; + } + DO_(::google::protobuf::internal::WireFormat::SkipField( + input, tag, mutable_unknown_fields())); + break; + } + } + } + return true; +#undef DO_ +} + +void MapUpdate::SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const { + // repeated uint32 field = 1 [packed = true]; + if (this->field_size() > 0) { + ::google::protobuf::internal::WireFormatLite::WriteTag(1, ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, output); + output->WriteVarint32(_field_cached_byte_size_); + } + for (int i = 0; i < this->field_size(); i++) { + ::google::protobuf::internal::WireFormatLite::WriteUInt32NoTag( + this->field(i), output); + } + + if (!unknown_fields().empty()) { + ::google::protobuf::internal::WireFormat::SerializeUnknownFields( + unknown_fields(), output); + } +} + +::google::protobuf::uint8* MapUpdate::SerializeWithCachedSizesToArray( + ::google::protobuf::uint8* target) const { + // repeated uint32 field = 1 [packed = true]; + if (this->field_size() > 0) { + target = ::google::protobuf::internal::WireFormatLite::WriteTagToArray( + 1, + ::google::protobuf::internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED, + target); + target = ::google::protobuf::io::CodedOutputStream::WriteVarint32ToArray( + _field_cached_byte_size_, target); + } + for (int i = 0; i < this->field_size(); i++) { + target = ::google::protobuf::internal::WireFormatLite:: + WriteUInt32NoTagToArray(this->field(i), target); + } + + if (!unknown_fields().empty()) { + target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray( + unknown_fields(), target); + } + return target; +} + +int MapUpdate::ByteSize() const { + int total_size = 0; + + // repeated uint32 field = 1 [packed = true]; + { + int data_size = 0; + for (int i = 0; i < this->field_size(); i++) { + data_size += ::google::protobuf::internal::WireFormatLite:: + UInt32Size(this->field(i)); + } + if (data_size > 0) { + total_size += 1 + + ::google::protobuf::internal::WireFormatLite::Int32Size(data_size); + } + _field_cached_byte_size_ = data_size; + total_size += data_size; + } + + if (!unknown_fields().empty()) { + total_size += + ::google::protobuf::internal::WireFormat::ComputeUnknownFieldsSize( + unknown_fields()); + } + GOOGLE_SAFE_CONCURRENT_WRITES_BEGIN(); + _cached_size_ = total_size; + GOOGLE_SAFE_CONCURRENT_WRITES_END(); + return total_size; +} + +void MapUpdate::MergeFrom(const ::google::protobuf::Message& from) { + GOOGLE_CHECK_NE(&from, this); + const MapUpdate* source = + ::google::protobuf::internal::dynamic_cast_if_available( + &from); + if (source == NULL) { + ::google::protobuf::internal::ReflectionOps::Merge(from, this); + } else { + MergeFrom(*source); + } +} + +void MapUpdate::MergeFrom(const MapUpdate& from) { + GOOGLE_CHECK_NE(&from, this); + field_.MergeFrom(from.field_); + mutable_unknown_fields()->MergeFrom(from.unknown_fields()); +} + +void MapUpdate::CopyFrom(const ::google::protobuf::Message& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +void MapUpdate::CopyFrom(const MapUpdate& from) { + if (&from == this) return; + Clear(); + MergeFrom(from); +} + +bool MapUpdate::IsInitialized() const { + + return true; +} + +void MapUpdate::Swap(MapUpdate* other) { + if (other != this) { + field_.Swap(&other->field_); + std::swap(_has_bits_[0], other->_has_bits_[0]); + _unknown_fields_.Swap(&other->_unknown_fields_); + std::swap(_cached_size_, other->_cached_size_); + } +} + +::google::protobuf::Metadata MapUpdate::GetMetadata() const { + protobuf_AssignDescriptorsOnce(); + ::google::protobuf::Metadata metadata; + metadata.descriptor = MapUpdate_descriptor_; + metadata.reflection = MapUpdate_reflection_; + return metadata; +} + + +// @@protoc_insertion_point(namespace_scope) + +// @@protoc_insertion_point(global_scope) diff --git a/pacman-c++/pacman.pb.h b/pacman-c++/pacman.pb.h new file mode 100644 index 0000000..6f94834 --- /dev/null +++ b/pacman-c++/pacman.pb.h @@ -0,0 +1,276 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: pacman.proto + +#ifndef PROTOBUF_pacman_2eproto__INCLUDED +#define PROTOBUF_pacman_2eproto__INCLUDED + +#include + +#include + +#if GOOGLE_PROTOBUF_VERSION < 2004000 +#error This file was generated by a newer version of protoc which is +#error incompatible with your Protocol Buffer headers. Please update +#error your headers. +#endif +#if 2004000 < GOOGLE_PROTOBUF_MIN_PROTOC_VERSION +#error This file was generated by an older version of protoc which is +#error incompatible with your Protocol Buffer headers. Please +#error regenerate this file with a newer version of protoc. +#endif + +#include +#include +#include +#include +// @@protoc_insertion_point(includes) + +// Internal implementation detail -- do not call these. +void protobuf_AddDesc_pacman_2eproto(); +void protobuf_AssignDesc_pacman_2eproto(); +void protobuf_ShutdownFile_pacman_2eproto(); + +class KeyPressUpdate; +class MapUpdate; + +// =================================================================== + +class KeyPressUpdate : public ::google::protobuf::Message { + public: + KeyPressUpdate(); + virtual ~KeyPressUpdate(); + + KeyPressUpdate(const KeyPressUpdate& from); + + inline KeyPressUpdate& operator=(const KeyPressUpdate& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const KeyPressUpdate& default_instance(); + + void Swap(KeyPressUpdate* other); + + // implements Message ---------------------------------------------- + + KeyPressUpdate* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const KeyPressUpdate& from); + void MergeFrom(const KeyPressUpdate& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // required uint32 newKey = 1; + inline bool has_newkey() const; + inline void clear_newkey(); + static const int kNewKeyFieldNumber = 1; + inline ::google::protobuf::uint32 newkey() const; + inline void set_newkey(::google::protobuf::uint32 value); + + // @@protoc_insertion_point(class_scope:KeyPressUpdate) + private: + inline void set_has_newkey(); + inline void clear_has_newkey(); + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::google::protobuf::uint32 newkey_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; + + friend void protobuf_AddDesc_pacman_2eproto(); + friend void protobuf_AssignDesc_pacman_2eproto(); + friend void protobuf_ShutdownFile_pacman_2eproto(); + + void InitAsDefaultInstance(); + static KeyPressUpdate* default_instance_; +}; +// ------------------------------------------------------------------- + +class MapUpdate : public ::google::protobuf::Message { + public: + MapUpdate(); + virtual ~MapUpdate(); + + MapUpdate(const MapUpdate& from); + + inline MapUpdate& operator=(const MapUpdate& from) { + CopyFrom(from); + return *this; + } + + inline const ::google::protobuf::UnknownFieldSet& unknown_fields() const { + return _unknown_fields_; + } + + inline ::google::protobuf::UnknownFieldSet* mutable_unknown_fields() { + return &_unknown_fields_; + } + + static const ::google::protobuf::Descriptor* descriptor(); + static const MapUpdate& default_instance(); + + void Swap(MapUpdate* other); + + // implements Message ---------------------------------------------- + + MapUpdate* New() const; + void CopyFrom(const ::google::protobuf::Message& from); + void MergeFrom(const ::google::protobuf::Message& from); + void CopyFrom(const MapUpdate& from); + void MergeFrom(const MapUpdate& from); + void Clear(); + bool IsInitialized() const; + + int ByteSize() const; + bool MergePartialFromCodedStream( + ::google::protobuf::io::CodedInputStream* input); + void SerializeWithCachedSizes( + ::google::protobuf::io::CodedOutputStream* output) const; + ::google::protobuf::uint8* SerializeWithCachedSizesToArray(::google::protobuf::uint8* output) const; + int GetCachedSize() const { return _cached_size_; } + private: + void SharedCtor(); + void SharedDtor(); + void SetCachedSize(int size) const; + public: + + ::google::protobuf::Metadata GetMetadata() const; + + // nested types ---------------------------------------------------- + + // accessors ------------------------------------------------------- + + // repeated uint32 field = 1 [packed = true]; + inline int field_size() const; + inline void clear_field(); + static const int kFieldFieldNumber = 1; + inline ::google::protobuf::uint32 field(int index) const; + inline void set_field(int index, ::google::protobuf::uint32 value); + inline void add_field(::google::protobuf::uint32 value); + inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& + field() const; + inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* + mutable_field(); + + // @@protoc_insertion_point(class_scope:MapUpdate) + private: + + ::google::protobuf::UnknownFieldSet _unknown_fields_; + + ::google::protobuf::RepeatedField< ::google::protobuf::uint32 > field_; + mutable int _field_cached_byte_size_; + + mutable int _cached_size_; + ::google::protobuf::uint32 _has_bits_[(1 + 31) / 32]; + + friend void protobuf_AddDesc_pacman_2eproto(); + friend void protobuf_AssignDesc_pacman_2eproto(); + friend void protobuf_ShutdownFile_pacman_2eproto(); + + void InitAsDefaultInstance(); + static MapUpdate* default_instance_; +}; +// =================================================================== + + +// =================================================================== + +// KeyPressUpdate + +// required uint32 newKey = 1; +inline bool KeyPressUpdate::has_newkey() const { + return (_has_bits_[0] & 0x00000001u) != 0; +} +inline void KeyPressUpdate::set_has_newkey() { + _has_bits_[0] |= 0x00000001u; +} +inline void KeyPressUpdate::clear_has_newkey() { + _has_bits_[0] &= ~0x00000001u; +} +inline void KeyPressUpdate::clear_newkey() { + newkey_ = 0u; + clear_has_newkey(); +} +inline ::google::protobuf::uint32 KeyPressUpdate::newkey() const { + return newkey_; +} +inline void KeyPressUpdate::set_newkey(::google::protobuf::uint32 value) { + set_has_newkey(); + newkey_ = value; +} + +// ------------------------------------------------------------------- + +// MapUpdate + +// repeated uint32 field = 1 [packed = true]; +inline int MapUpdate::field_size() const { + return field_.size(); +} +inline void MapUpdate::clear_field() { + field_.Clear(); +} +inline ::google::protobuf::uint32 MapUpdate::field(int index) const { + return field_.Get(index); +} +inline void MapUpdate::set_field(int index, ::google::protobuf::uint32 value) { + field_.Set(index, value); +} +inline void MapUpdate::add_field(::google::protobuf::uint32 value) { + field_.Add(value); +} +inline const ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >& +MapUpdate::field() const { + return field_; +} +inline ::google::protobuf::RepeatedField< ::google::protobuf::uint32 >* +MapUpdate::mutable_field() { + return &field_; +} + + +// @@protoc_insertion_point(namespace_scope) + +#ifndef SWIG +namespace google { +namespace protobuf { + + +} // namespace google +} // namespace protobuf +#endif // SWIG + +// @@protoc_insertion_point(global_scope) + +#endif // PROTOBUF_pacman_2eproto__INCLUDED diff --git a/pacman-c++/pacman.pro b/pacman-c++/pacman.pro index dd08568..32f2151 100644 --- a/pacman-c++/pacman.pro +++ b/pacman-c++/pacman.pro @@ -10,7 +10,8 @@ SOURCES += pixmapitem.cpp \ audioplayer.cpp \ clicklabel.cpp \ sceneholder.cpp \ - util.cpp + util.cpp \ + pacman.pb.cc HEADERS += pixmapitem.h \ actor.h \ animationmanager.h \ @@ -23,7 +24,8 @@ HEADERS += pixmapitem.h \ audioplayer.h \ clicklabel.h \ sceneholder.h \ - util.h + util.h \ + pacman.pb.h RESOURCES += pacman.qrc OBJECTS_DIR = .obj @@ -33,3 +35,6 @@ RC_FILE = pacman.rc OTHER_FILES += \ style.qss \ pacman.rc + +LIBS += -lprotobuf + diff --git a/pacman-c++/pacman.proto b/pacman-c++/pacman.proto new file mode 100644 index 0000000..39c68f7 --- /dev/null +++ b/pacman-c++/pacman.proto @@ -0,0 +1,7 @@ +message KeyPressUpdate { + required uint32 newKey = 1; +} + +message MapUpdate { + repeated uint32 field = 1 [packed=true]; +} diff --git a/pacman-c++/pacman.server.pro b/pacman-c++/pacman.server.pro index c7ca9aa..5a31ffe 100644 --- a/pacman-c++/pacman.server.pro +++ b/pacman-c++/pacman.server.pro @@ -10,7 +10,8 @@ SOURCES += pixmapitem.cpp \ audioplayer.cpp \ sceneholder.cpp \ util.cpp \ - clicklabel.cpp + clicklabel.cpp \ + pacman.pb.cc HEADERS += pixmapitem.h \ actor.h \ animationmanager.h \ @@ -23,7 +24,8 @@ HEADERS += pixmapitem.h \ audioplayer.h \ sceneholder.h \ util.h \ - clicklabel.h + clicklabel.h \ + pacman.pb.h HEADERS += pixmapitem.h \ RESOURCES += pacman.qrc @@ -36,3 +38,6 @@ OTHER_FILES += \ pacman.rc DEFINES += SERVER + +LIBS += -lprotobuf + diff --git a/pacman-c++/sceneholder.cpp b/pacman-c++/sceneholder.cpp index dbc3ca5..0cb7d15 100644 --- a/pacman-c++/sceneholder.cpp +++ b/pacman-c++/sceneholder.cpp @@ -34,7 +34,7 @@ void SceneHolder::updateMap(const Transmission::map_t& map) //qDebug() << "col=" << color; PixmapItem* item = NULL; - if (cur == 0) { // no update + if (cur == Transmission::none) { // no update } else if (cur & Transmission::empty) { PixmapItem* oldItem = visualMap[x][y]; // remove elements (in case it's not an actor) diff --git a/pacman-c++/server.cpp b/pacman-c++/server.cpp index be24da0..8539410 100644 --- a/pacman-c++/server.cpp +++ b/pacman-c++/server.cpp @@ -2,6 +2,8 @@ #include "util.h" +#include "pacman.pb.h" + Server::Server(QWidget *parent) : SceneHolder(parent) { @@ -46,7 +48,6 @@ Transmission::map_t Server::calculateUpdates() map[newMapPosition.x()][newMapPosition.y()] = Transmission::pacman | i.key() | Util::actorMovementToTransmission(i.value()) ; - } return map; } -- cgit v1.2.3