void NodeTimerList::serialize(std::ostream &os, u8 map_format_version) const { if (map_format_version == 24) { // Version 0 is a placeholder for "nothing to see here; go away." if (m_timers.empty()) { writeU8(os, 0); // version return; } writeU8(os, 1); // version writeU16(os, m_timers.size()); } if (map_format_version >= 25) { writeU8(os, 2 + 4 + 4); // length of the data for a single timer writeU16(os, m_timers.size()); } for (const auto &timer : m_timers) { NodeTimer t = timer.second; NodeTimer nt = NodeTimer(t.timeout, t.timeout - (f32)(timer.first - m_time), t.position); v3s16 p = t.position; u16 p16 = p.Z * MAP_BLOCKSIZE * MAP_BLOCKSIZE + p.Y * MAP_BLOCKSIZE + p.X; writeU16(os, p16); nt.serialize(os); } }
void NodeTimerList::serialize(std::ostream &os) const { /* Version 0 is a placeholder for "nothing to see here; go away." */ if(m_data.size() == 0){ writeU8(os, 0); // version return; } writeU8(os, 1); // version writeU16(os, m_data.size()); for(std::map<v3s16, NodeTimer>::const_iterator i = m_data.begin(); i != m_data.end(); i++){ v3s16 p = i->first; NodeTimer t = i->second; u16 p16 = p.Z*MAP_BLOCKSIZE*MAP_BLOCKSIZE + p.Y*MAP_BLOCKSIZE + p.X; writeU16(os, p16); t.serialize(os); } }
void NodeTimerList::serialize(std::ostream &os, u8 map_format_version) const { if(map_format_version == 24){ // Version 0 is a placeholder for "nothing to see here; go away." if(m_data.empty()){ writeU8(os, 0); // version return; } writeU8(os, 1); // version writeU16(os, m_data.size()); } if(map_format_version >= 25){ writeU8(os, 2+4+4); writeU16(os, m_data.size()); } for(std::map<v3s16, NodeTimer>::const_iterator i = m_data.begin(); i != m_data.end(); i++){ v3s16 p = i->first; NodeTimer t = i->second; u16 p16 = p.Z*MAP_BLOCKSIZE*MAP_BLOCKSIZE + p.Y*MAP_BLOCKSIZE + p.X; writeU16(os, p16); t.serialize(os); } }