Fixed serialization

This commit is contained in:
Andrew nuark G 2020-12-15 20:43:19 +07:00
parent 48ad2f1817
commit 7d60d579b6
5 changed files with 26 additions and 16 deletions

View file

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