aboutsummaryrefslogtreecommitdiff
path: root/src/nodedef.cpp
Commit message (Expand)AuthorAge
...
* Remove texture atlas / AtlasPointer, rename getTextureRaw to getTextureKahrl2013-07-02
* Add drowningPilzAdam2013-06-19
* Add new drawtype GLASSLIKE_FRAMEDRealBadAngel2013-04-24
* Add option to use texture alpha channelkwolekr2013-04-23
* unkn own block -> unkn own nodekhonkhortisan2013-04-05
* Fix MapgenV6::generateCaves possible division by 0 and misc. cosmetic fixeskwolekr2013-03-30
* Optimize CNodeDefManager::getIdskwolekr2013-03-30
* Move rightclickable to the proper placePilzAdam2013-03-23
* Include backface_culling flag in serialization format for TileDefsJürgen Doser2013-03-23
* Update Copyright YearsSfan52013-02-24
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
* Disable placement prediction for nodes that use on_rightclickJeija2013-02-19
* Disable backface culling for drawtype plantlike and only draw 2 faces instead...Jürgen Doser2013-02-10
* The new mapgen, noise functions, et al.kwolekr2013-01-21
* Fix tile MaterialType to make sense and make lava surface be shader'd lower l...Perttu Ahola2012-12-02
* Support serialization of protocol 13 ContentFeaturesPerttu Ahola2012-11-29
* Proper versioning of new network-serialized stuffPerttu Ahola2012-11-26
* Update ContentFeatures serialization format now as PROTOCOL_VERSION was changedPerttu Ahola2012-11-25
* Fix more things I forgot for attached players. Such players will now properly...MirceaKitsune2012-11-25
* Fix some remaining issues with attachments, now they work. Tested with object...MirceaKitsune2012-11-25
* Fix unnecessary network protocol incompatibility in ContentFeaturesPerttu Ahola2012-11-08
* Add liquid_renewable property.Ilya Zhuravlev2012-09-07
* Fix black display inside opaque waterMatthew I2012-08-31
* Fix map deserialization and remove old serialization codePerttu Ahola2012-07-23
* Increment protocol versionPerttu Ahola2012-06-17
* Custom boxy nodes (stairs, slabs) and collision changesKahrl2012-06-17
* Properly and efficiently use split utility headersPerttu Ahola2012-06-17
* Node texture animationPerttu Ahola2012-06-16
* Node placement client-side predictionPerttu Ahola2012-06-10
* Add after_destruct and cache the existence of on_construct, on_destruct and a...Perttu Ahola2012-06-05
* Switch the license to be LGPLv2/later, with small parts still remaining as GP...Perttu Ahola2012-06-05
* WIP node metadata, node timersKahrl2012-06-03
* Allow group:groupname in ABM definition and implement minetest.hash_node_posi...Perttu Ahola2012-03-31
* Some serialization version stuffPerttu Ahola2012-03-25
* Add sound.digPerttu Ahola2012-03-24
* Add sounds, tune thingsPerttu Ahola2012-03-24
* Add event manager and use it to trigger soundsPerttu Ahola2012-03-24
* Unknown nodes can be dugPerttu Ahola2012-03-19
* MapBlockMesh, mesh animation system, urgent mesh updates, athmospheric light,...Kahrl2012-03-15
* Clean up log messages everywherePerttu Ahola2012-03-11
* itemgroup.h and ItemGroupList typedefPerttu Ahola2012-03-10
* Digging time groups WIPPerttu Ahola2012-03-10
* Cleanup (some stuff went wrong when reverting 4-byte mapnodes); fix legacy_wa...Kahrl2012-01-22
* Node placement / mineral / serialization / iron freq / node_dig callbackKahrl2012-01-22
* The huge item definition and item namespace unification patch (itemdef), see ...Kahrl2012-01-12
* Make ToolItem and MaterialItem to convert names by aliases at creation time t...Perttu Ahola2011-12-04
* Modify a commit in tooldef.cpp and nodedef.cppPerttu Ahola2011-12-04
* Add serialization for node aliases to let client show inventory images correctlyPerttu Ahola2011-12-04
* Node definition aliasesPerttu Ahola2011-12-03
* Allow digging unknown nodesPerttu Ahola2011-12-03
span>(); } private: std::set<Value> m_set; std::queue<Value> m_queue; }; template<typename Key, typename Value> class MutexedMap { public: MutexedMap() { } void set(const Key &name, const Value &value) { JMutexAutoLock lock(m_mutex); m_values[name] = value; } bool get(const Key &name, Value *result) { JMutexAutoLock lock(m_mutex); typename std::map<Key, Value>::iterator n; n = m_values.find(name); if(n == m_values.end()) return false; if(result != NULL) *result = n->second; return true; } std::vector<Value> getValues() { std::vector<Value> result; for(typename std::map<Key, Value>::iterator i = m_values.begin(); i != m_values.end(); ++i){ result.push_back(i->second); } return result; } void clear () { m_values.clear(); } private: std::map<Key, Value> m_values; JMutex m_mutex; }; /* Generates ids for comparable values. Id=0 is reserved for "no value". Is fast at: - Returning value by id (very fast) - Returning id by value - Generating a new id for a value Is not able to: - Remove an id/value pair (is possible to implement but slow) */ template<typename T> class MutexedIdGenerator { public: MutexedIdGenerator() { } // Returns true if found bool getValue(u32 id, T &value) { if(id == 0) return false; JMutexAutoLock lock(m_mutex); if(m_id_to_value.size() < id) return false; value = m_id_to_value[id-1]; return true; } // If id exists for value, returns the id. // Otherwise generates an id for the value. u32 getId(const T &value) { JMutexAutoLock lock(m_mutex); typename std::map<T, u32>::iterator n; n = m_value_to_id.find(value); if(n != m_value_to_id.end()) return n->second; m_id_to_value.push_back(value); u32 new_id = m_id_to_value.size(); m_value_to_id.insert(value, new_id); return new_id; } private: JMutex m_mutex; // Values are stored here at id-1 position (id 1 = [0]) std::vector<T> m_id_to_value; std::map<T, u32> m_value_to_id; }; /* Thread-safe FIFO queue (well, actually a FILO also) */ template<typename T> class MutexedQueue { public: template<typename Key, typename U, typename Caller, typename CallerData> friend class RequestQueue; MutexedQueue() { } bool empty() { JMutexAutoLock lock(m_mutex); return (m_queue.size() == 0); } void push_back(T t) { JMutexAutoLock lock(m_mutex); m_queue.push_back(t); m_size.Post(); } /* this version of pop_front returns a empty element of T on timeout. * Make sure default constructor of T creates a recognizable "empty" element */ T pop_frontNoEx(u32 wait_time_max_ms) { if (m_size.Wait(wait_time_max_ms)) { JMutexAutoLock lock(m_mutex); T t = m_queue.front(); m_queue.pop_front(); return t; } else { return T(); } } T pop_front(u32 wait_time_max_ms) { if (m_size.Wait(wait_time_max_ms)) { JMutexAutoLock lock(m_mutex); T t = m_queue.front(); m_queue.pop_front(); return t; } else { throw ItemNotFoundException("MutexedQueue: queue is empty"); } } T pop_frontNoEx() { m_size.Wait(); JMutexAutoLock lock(m_mutex); T t = m_queue.front(); m_queue.pop_front(); return t; } T pop_back(u32 wait_time_max_ms=0) { if (m_size.Wait(wait_time_max_ms)) { JMutexAutoLock lock(m_mutex); T t = m_queue.back(); m_queue.pop_back(); return t; } else { throw ItemNotFoundException("MutexedQueue: queue is empty"); } } /* this version of pop_back returns a empty element of T on timeout. * Make sure default constructor of T creates a recognizable "empty" element */ T pop_backNoEx(u32 wait_time_max_ms=0) { if (m_size.Wait(wait_time_max_ms)) { JMutexAutoLock lock(m_mutex); T t = m_queue.back(); m_queue.pop_back(); return t; } else { return T(); } } T pop_backNoEx() { m_size.Wait(); JMutexAutoLock lock(m_mutex); T t = m_queue.back(); m_queue.pop_back(); return t; } protected: JMutex & getMutex() { return m_mutex; } std::deque<T> & getQueue() { return m_queue; } std::deque<T> m_queue; JMutex m_mutex; JSemaphore m_size; }; #endif