aboutsummaryrefslogtreecommitdiff
path: root/src/script
Commit message (Expand)AuthorAge
* Add option to not send pre v25 init packetest312016-03-15
* Much better API for auth.{cpp, h}est312016-03-15
* Allow nodes to specify which sides to connect to.Auke Kok2016-03-12
* Nodebox: Allow nodeboxes to "connect"Auke Kok2016-03-12
* Add consistent monotonic day counter - get_day_count()Auke Kok2016-03-09
* Add AreaStore custom ID APIShadowNinja2016-03-07
* Implement AreaStore serializationShadowNinja2016-03-07
* Move AreaStore container selection logic into getOptimalImplementationShadowNinja2016-03-07
* Move AreaStore to utilShadowNinja2016-03-07
* Simplify AreaStore ID managementShadowNinja2016-03-07
* s_env.{cpp, h} cleanupsest312016-03-07
* Add minetest.register_lbm() to run code on block load onlyest312016-03-07
* Use LuaErrors in security check macrosShadowNinja2016-03-07
* Require minetest.request_http_api to be called from the mod's main scopeJeija2016-03-03
* Fix main menu being unable to set secure settingsShadowNinja2016-03-03
* Remove debug.getupvalue from the Lua sandbox whitelistShadowNinja2016-03-03
* Fix minetest.request_insecure_environment() always returning nilJeija2016-02-26
* Add Lua interface to HTTPFetchRequestJeija2016-02-22
* Ignore spaces in secure.trusted_mods settingJeija2016-02-19
* Require request_insecure_environment to be called from the mod's main scopeShadowNinja2016-02-19
* v2d & aabbox3d<f32> & sky cleanupsnerzhul2016-02-11
* Add '/clearobjects quick'Kahrl2016-02-11
* Don't print whole json data buffer to errorstream on errorest312016-01-28
* Fix C++11 compilabilityest312016-01-23
* Allow per-tiles culling.Auke Kok2016-01-20
* Show infotext with description for item entitiesRealBadAngel2016-01-18
* Make ItemStack:set_count(0) clear the item stacksfan52016-01-15
* Liquids: Flow into and destroy 'floodable' nodesparamat2016-01-07
* Revert "Add support for using arbitrary meshes as items"Sapier2015-12-29
* Add support for using arbitrary meshes as itemsSapier2015-12-29
* Fix lua object:get_properties() being brokenSapier2015-12-21
* Fix missing popest312015-12-20
* Add support for limiting rotation of automatic face movement dir entitysSapier2015-12-19
* Add option to give every object a nametagBlockMen2015-12-15
* Fix threshold typeest312015-12-07
* Mapgen: Add propagate_shadow bool to calcLightingparamat2015-12-07
* Fix spelling of noise_thresholdJun Zhang2015-12-06
* Add on_secondary_use when right clicking an item in the airAlex Ford2015-12-02
* Add LuaSecureRandomest312015-11-08
* Add support for audio feedback if placing node failedBlockMen2015-11-07
* Add server side ncurses terminalest312015-11-06
* Schematics: Add core.place_schematic_on_vmanip APIkwolekr2015-11-05
* Add callback parameter for core.emerge_area()kwolekr2015-11-02
* Fix Lua scripting synchronizationkwolekr2015-11-01
* Fix server crashing on Lua errorsShadowNinja2015-10-31
* SAPI: Fix seed parameter truncation for LuaPseudoRandom constructorkwolekr2015-10-26
* SAPI: Move core.get_us_time() to Util modulekwolekr2015-10-26
* Remove some abort() callsest312015-10-26
* SAPI: Throw runtime error instead of if l_get_mapgen_object called in incorre...kwolekr2015-10-25
* SAPI: Mark all Lua API functions requiring envlockkwolekr2015-10-25
serialize(os); } void NodeMetadata::deSerialize(std::istream &is, u8 version) { clear(); int num_vars = readU32(is); for(int i=0; i<num_vars; i++){ std::string name = deSerializeString16(is); std::string var = deSerializeString32(is); m_stringvars[name] = var; if (version >= 2) { if (readU8(is) == 1) markPrivate(name, true); } } m_inventory->deSerialize(is); } void NodeMetadata::clear() { Metadata::clear(); m_privatevars.clear(); m_inventory->clear(); } bool NodeMetadata::empty() const { return Metadata::empty() && m_inventory->getLists().empty(); } void NodeMetadata::markPrivate(const std::string &name, bool set) { if (set) m_privatevars.insert(name); else m_privatevars.erase(name); } int NodeMetadata::countNonPrivate() const { // m_privatevars can contain names not actually present // DON'T: return m_stringvars.size() - m_privatevars.size(); int n = 0; for (const auto &sv : m_stringvars) { if (!isPrivate(sv.first)) n++; } return n; } /* NodeMetadataList */ void NodeMetadataList::serialize(std::ostream &os, u8 blockver, bool disk, bool absolute_pos) const { /* Version 0 is a placeholder for "nothing to see here; go away." */ u16 count = countNonEmpty(); if (count == 0) { writeU8(os, 0); // version return; } u8 version = (blockver > 27) ? 2 : 1; writeU8(os, version); writeU16(os, count); for (NodeMetadataMap::const_iterator i = m_data.begin(); i != m_data.end(); ++i) { v3s16 p = i->first; NodeMetadata *data = i->second; if (data->empty()) continue; if (absolute_pos) { writeS16(os, p.X); writeS16(os, p.Y); writeS16(os, p.Z); } else { // Serialize positions within a mapblock u16 p16 = (p.Z * MAP_BLOCKSIZE + p.Y) * MAP_BLOCKSIZE + p.X; writeU16(os, p16); } data->serialize(os, version, disk); } } void NodeMetadataList::deSerialize(std::istream &is, IItemDefManager *item_def_mgr, bool absolute_pos) { clear(); u8 version = readU8(is); if (version == 0) { // Nothing return; } if (version > 2) { std::string err_str = std::string(FUNCTION_NAME) + ": version " + itos(version) + " not supported"; infostream << err_str << std::endl; throw SerializationError(err_str); } u16 count = readU16(is); for (u16 i = 0; i < count; i++) { v3s16 p; if (absolute_pos) { p.X = readS16(is); p.Y = readS16(is); p.Z = readS16(is); } else { u16 p16 = readU16(is); p.X = p16 & (MAP_BLOCKSIZE - 1); p16 /= MAP_BLOCKSIZE; p.Y = p16 & (MAP_BLOCKSIZE - 1); p16 /= MAP_BLOCKSIZE; p.Z = p16; } if (m_data.find(p) != m_data.end()) { warningstream << "NodeMetadataList::deSerialize(): " << "already set data at position " << PP(p) << ": Ignoring." << std::endl; continue; } NodeMetadata *data = new NodeMetadata(item_def_mgr); data->deSerialize(is, version); m_data[p] = data; } } NodeMetadataList::~NodeMetadataList() { clear(); } std::vector<v3s16> NodeMetadataList::getAllKeys() { std::vector<v3s16> keys; keys.reserve(m_data.size()); for (const auto &it : m_data) keys.push_back(it.first); return keys; } NodeMetadata *NodeMetadataList::get(v3s16 p) { NodeMetadataMap::const_iterator n = m_data.find(p); if (n == m_data.end()) return nullptr; return n->second; } void NodeMetadataList::remove(v3s16 p) { NodeMetadata *olddata = get(p); if (olddata) { if (m_is_metadata_owner) delete olddata; m_data.erase(p); } } void NodeMetadataList::set(v3s16 p, NodeMetadata *d) { remove(p); m_data.emplace(p, d); } void NodeMetadataList::clear() { if (m_is_metadata_owner) { NodeMetadataMap::const_iterator it; for (it = m_data.begin(); it != m_data.end(); ++it) delete it->second; } m_data.clear(); } int NodeMetadataList::countNonEmpty() const { int n = 0; for (const auto &it : m_data) { if (!it.second->empty()) n++; } return n; }