Polish the streambuffer API a bit

This commit is contained in:
2021-07-19 17:32:24 -04:00
parent f8f8a9843f
commit 08ca274444
5 changed files with 303 additions and 195 deletions

View File

@@ -433,7 +433,7 @@ void World::serialize(StreamBuffer *sb) {
lua_snap_.serialize(sb);
id_global_pool_.serialize(sb);
thread_sched_.serialize(sb);
sb->write_size(tangibles_.size());
sb->write_uint32(tangibles_.size());
for (const auto &p : tangibles_) {
sb->write_int64(p.first);
p.second->serialize(sb);
@@ -454,7 +454,7 @@ void World::deserialize(StreamBuffer *sb) {
p.second->plane_item_.set_id(0);
}
// Deserialize tangibles.
size_t ntan = sb->read_size();
size_t ntan = sb->read_uint32();
for (size_t i = 0; i < ntan; i++) {
int64_t id = sb->read_int64();
std::unique_ptr<Tangible> &t = tangibles_[id];