From f58c53cadbd717b958108562a99677ef48e5ea7e Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Tue, 22 Dec 2020 22:16:34 +0700 Subject: [PATCH] Vessel entity updates --- sea_transport/entities/vessel_entity.cpp | 12 +++++------- sea_transport/entities/vessel_entity.h | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/sea_transport/entities/vessel_entity.cpp b/sea_transport/entities/vessel_entity.cpp index b4ccdc7..34f1b2b 100644 --- a/sea_transport/entities/vessel_entity.cpp +++ b/sea_transport/entities/vessel_entity.cpp @@ -3,7 +3,7 @@ entity_id vessel_entity::__global_id = 0; -vessel_entity::vessel_entity(const dpoint_entity &harbor, unsigned int capacity) : _harbor(harbor), _capacity(capacity) { +vessel_entity::vessel_entity(entity_id harbor_id, unsigned int capacity) : _harbor_id(harbor_id), _capacity(capacity) { this->_id = ++vessel_entity::__global_id; } @@ -11,8 +11,8 @@ entity_id vessel_entity::id() const { return this->_id; } -const dpoint_entity vessel_entity::harbor() const { - return this->_harbor; +entity_id vessel_entity::harbor() const { + return this->_harbor_id; } unsigned int vessel_entity::capacity() const { @@ -24,8 +24,7 @@ const QVector vessel_entity::cargo() { } void vessel_entity::serialize(QDataStream &output) { - output << this->_id; - this->_harbor.serialize(output); + output << this->_id << this->_harbor_id; output << this->_capacity << this->_cargo.size(); for (auto item : this->_cargo) { item.serialize(output); @@ -33,8 +32,7 @@ void vessel_entity::serialize(QDataStream &output) { } void vessel_entity::deserialize(QDataStream &input) { - input >> this->_id; - this->_harbor.deserialize(input); + input >> this->_id >> this->_harbor_id; int icnt; input >> this->_capacity >> icnt; this->_cargo.resize(icnt); diff --git a/sea_transport/entities/vessel_entity.h b/sea_transport/entities/vessel_entity.h index f381f37..e96ecfe 100644 --- a/sea_transport/entities/vessel_entity.h +++ b/sea_transport/entities/vessel_entity.h @@ -11,16 +11,16 @@ private: static entity_id __global_id; entity_id _id; - dpoint_entity _harbor; + entity_id _harbor_id; unsigned int _capacity; QVector _cargo; public: vessel_entity() = default; - vessel_entity(const dpoint_entity &harbor, unsigned int capacity); + vessel_entity(entity_id harbor_id, unsigned int capacity); entity_id id() const; - const dpoint_entity harbor() const; + entity_id harbor() const; unsigned int capacity() const; const QVector cargo();