Fixed serialization
This commit is contained in:
parent
48ad2f1817
commit
7d60d579b6
5 changed files with 26 additions and 16 deletions
|
|
@ -21,9 +21,17 @@ const QVector<cargo_entity> storage_entity::cargo() {
|
|||
}
|
||||
|
||||
void storage_entity::serialize(QDataStream &output) {
|
||||
output << this->_id << this->_capacity << this->_cargo;
|
||||
output << this->_id << this->_capacity << this->_cargo.size();
|
||||
for (auto item : this->_cargo) {
|
||||
item.serialize(output);
|
||||
}
|
||||
}
|
||||
|
||||
void storage_entity::deserialize(QDataStream &input) {
|
||||
input >> this->_id >> this->_capacity >> this->_cargo;
|
||||
int icnt;
|
||||
input >> this->_id >> this->_capacity >> icnt;
|
||||
this->_cargo.resize(icnt);
|
||||
for (int i = 0; i < icnt; i++) {
|
||||
this->_cargo[i].deserialize(input);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue