Vessel entity updates
This commit is contained in:
parent
88e36a1c30
commit
f58c53cadb
2 changed files with 8 additions and 10 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
entity_id vessel_entity::__global_id = 0;
|
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;
|
this->_id = ++vessel_entity::__global_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -11,8 +11,8 @@ entity_id vessel_entity::id() const {
|
||||||
return this->_id;
|
return this->_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dpoint_entity vessel_entity::harbor() const {
|
entity_id vessel_entity::harbor() const {
|
||||||
return this->_harbor;
|
return this->_harbor_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int vessel_entity::capacity() const {
|
unsigned int vessel_entity::capacity() const {
|
||||||
|
|
@ -24,8 +24,7 @@ const QVector<cargo_entity> vessel_entity::cargo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void vessel_entity::serialize(QDataStream &output) {
|
void vessel_entity::serialize(QDataStream &output) {
|
||||||
output << this->_id;
|
output << this->_id << this->_harbor_id;
|
||||||
this->_harbor.serialize(output);
|
|
||||||
output << this->_capacity << this->_cargo.size();
|
output << this->_capacity << this->_cargo.size();
|
||||||
for (auto item : this->_cargo) {
|
for (auto item : this->_cargo) {
|
||||||
item.serialize(output);
|
item.serialize(output);
|
||||||
|
|
@ -33,8 +32,7 @@ void vessel_entity::serialize(QDataStream &output) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void vessel_entity::deserialize(QDataStream &input) {
|
void vessel_entity::deserialize(QDataStream &input) {
|
||||||
input >> this->_id;
|
input >> this->_id >> this->_harbor_id;
|
||||||
this->_harbor.deserialize(input);
|
|
||||||
int icnt;
|
int icnt;
|
||||||
input >> this->_capacity >> icnt;
|
input >> this->_capacity >> icnt;
|
||||||
this->_cargo.resize(icnt);
|
this->_cargo.resize(icnt);
|
||||||
|
|
|
||||||
|
|
@ -11,16 +11,16 @@ private:
|
||||||
static entity_id __global_id;
|
static entity_id __global_id;
|
||||||
|
|
||||||
entity_id _id;
|
entity_id _id;
|
||||||
dpoint_entity _harbor;
|
entity_id _harbor_id;
|
||||||
unsigned int _capacity;
|
unsigned int _capacity;
|
||||||
QVector<cargo_entity> _cargo;
|
QVector<cargo_entity> _cargo;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
vessel_entity() = default;
|
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;
|
entity_id id() const;
|
||||||
const dpoint_entity harbor() const;
|
entity_id harbor() const;
|
||||||
unsigned int capacity() const;
|
unsigned int capacity() const;
|
||||||
const QVector<cargo_entity> cargo();
|
const QVector<cargo_entity> cargo();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue