Add de/serialization to object subsystem

This commit is contained in:
Andrew nuark G 2020-12-16 00:09:49 +07:00
parent 44ccc07360
commit f20bb7c2d9
2 changed files with 50 additions and 3 deletions

View file

@ -1,6 +1,32 @@
#include "object_system.h"
object_system::object_system()
{
void object_system::init(QDataStream &stream) {
int dicnt;
stream >> dicnt;
this->_dpoints.resize(dicnt);
for (int i = 0; i < dicnt; i++) {
this->_dpoints[i].deserialize(stream);
}
int vicnt;
stream >> vicnt;
this->_vessels.resize(vicnt);
for (int i = 0; i < vicnt; i++) {
this->_vessels[i].deserialize(stream);
}
}
void object_system::shutdown(QDataStream &stream) {
stream << this->_dpoints.size();
for (auto &item : this->_dpoints) {
item.serialize(stream);
}
stream << this->_vessels.size();
for (auto &item : this->_vessels) {
item.serialize(stream);
}
}