Vessel entity updates

This commit is contained in:
Andrew nuark G 2020-12-22 22:16:34 +07:00
parent 88e36a1c30
commit f58c53cadb
2 changed files with 8 additions and 10 deletions

View file

@ -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<cargo_entity> 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);

View file

@ -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_entity> _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_entity> cargo();