aboutsummaryrefslogtreecommitdiff
path: root/builtin/common
Commit message (Collapse)AuthorAge
* Faster insertion into tableRui9142016-03-06
|
* Refactor loggingShadowNinja2015-10-14
| | | | | | | | | - Add warning log level - Change debug_log_level setting to enumeration string - Map Irrlicht log events to MT log events - Encapsulate log_* functions and global variables into a class, Logger - Unify dstream with standard logging mechanism - Unify core.debug() with standard core.log() script API
* Add /emergeblocks command and core.emerge_area() Lua APIkwolekr2015-09-23
|
* Allow random menu images for subgamessfan52015-07-21
|
* Fix wrong replace from previous commitest312015-06-02
|
* Localize inside whole misc_helpers.luaest312015-06-01
|
* Add minetest.global_exists()ShadowNinja2015-04-21
|
* Fix serialization of floating point numbersShadowNinja2015-02-21
|
* Server: announce MIN/MAX protocol version supported to serverlist. Client: ↵est312015-02-18
| | | | | | | check serverlist Client now informs about incompatible servers from the list, this permits to prevent the protocol movements. Server announces its supported protocol versions to master server
* Fix crash on passing false as value in table to table.copy(t)est312015-02-14
| | | | Fixes #2293.
* Change assignment to global in a function to warningrubenwardy2015-02-04
|
* Fix imprecise serialization of large numbersShadowNinja2015-01-25
|
* Simplify deleteblocks chat command argument parsingkwolekr2015-01-15
| | | | | Add optional core.pos_to_string decimal place rounding Move core.string_to_pos to builtin/common/misc_helpers.lua for consistency
* Fix typo in `serialize.lua`.Diego Martínez2015-01-15
|
* Fix off-by-one error in `string:split` implementation.Diego Martínez2015-01-04
|
* Faster string.split implementation.Diego Martinez2014-12-28
|
* Revert "Adjust the values of dirs1 and dirs2 so that rotate_and_place ↵Craig Robbins2014-12-12
| | | | | | | | orients textures correctly" This reverts commit 9878e8de4fdf232ebb77b396766c339786c01218. See: https://github.com/minetest/minetest/issues/1939 and IRC log for discussion
* Fix undeclared globals in functions and shorten lines in misc_helpers.lua.paramat2014-12-11
|
* Add Lua helper functions vector.apply(v) math.sign(x, tolerance)SmallJoker2014-12-06
|
* Add minetest.copy_table(table) To get rid off the "table references"SmallJoker2014-11-27
| | | | Signed-off-by: Craig Robbins <kde.psych@gmail.com>
* Adjust the values of dirs1 and dirs2 so that rotate_and_place orients ↵dvere2014-11-25
| | | | | | textures correctly According to doc/lua_api.txt if paramtype2 == "facedir" the two least significant bits of parm2 orient the texture around the axis. For dirs1 (looking at a wall) these would be 0, 1, 2, 3 and for dirs2 (looking at the ceiling) 2, 1, 0, 3
* Make duplicate warning checks file and line specificShadowNinja2014-11-23
|
* Fix console spaming by debug function on mod checking for global variable to ↵sapier2014-11-23
| | | | exist.
* Add strict moduleShadowNinja2014-11-19
| | | | Also fix leaking globals found by it.
* Tweak core.serializeShadowNinja2014-11-19
| | | | This adds proper support for nested tables and improves performance a bit.
* Fix dump() indentation with non-tab indentsShadowNinja2014-11-08
|
* Add last_login field to auth.txtRyan Newell2014-11-08
| | | | Also shortens some related code and adds more parameters to string.split.
* Make dump's output prettierShadowNinja2014-09-21
| | | | | | | | Changes: * Indentation with tabs by default. * Array keys dumped without "[i] = " prefix. * String keys that are valid identifiers aren't enclosed in '[""]'. * Basic support for multiple references (as specified in the comment).
* Remove vector assertionsShadowNinja2014-07-19
| | | | | These were initially added to get tracebacks for invalid vector errors, but it didn't work and tracebacks have since been properly fixed in the core.
* Add srollbar formspec elementsapier2014-07-16
|
* Rework dumping functionsShadowNinja2014-05-24
| | | | | | | | | Changes: * Add comments to explain the dumping code * Add support for dumping values of any type (as '<' <type> '>') * Add support for tables as keys in dump2() * Make dump2() return it's result (like dump()) rather than printing it * Simplify and optimize function serialization via serialize()
* Fix a bunch of small bugs due to mainmenu cleanupsapier2014-05-24
| | | | | | | Fix doubleclick not working in singleplayer Fix of by one issue on accessing raw list Fix this->self Fix copy&paste error for scroll button
* Add formspec toolkit and refactor mainmenu to use itsapier2014-05-16
| | | | | Fix crash on using cursor keys in client menu without selected server Add support for non fixed size tabviews
* Use "core" namespace internallyShadowNinja2014-05-08
|
* Organize builtin into subdirectoriesShadowNinja2014-05-07
hl opt">; return true; } std::list<Value> getValues() { std::list<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; }; #endif /* 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; }; /* FIFO queue (well, actually a FILO also) */ template<typename T> class Queue { public: Queue(): m_list_size(0) {} void push_back(T t) { m_list.push_back(t); ++m_list_size; } void push_front(T t) { m_list.push_front(t); ++m_list_size; } T pop_front() { if(m_list.empty()) throw ItemNotFoundException("Queue: queue is empty"); typename std::list<T>::iterator begin = m_list.begin(); T t = *begin; m_list.erase(begin); --m_list_size; return t; } T pop_back() { if(m_list.empty()) throw ItemNotFoundException("Queue: queue is empty"); typename std::list<T>::iterator last = m_list.back(); T t = *last; m_list.erase(last); --m_list_size; return t; } u32 size() { return m_list_size; } bool empty() { return m_list.empty(); } protected: std::list<T> m_list; u32 m_list_size; }; /* 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_size.GetValue() == 0); } void push_back(T t) { JMutexAutoLock lock(m_mutex); m_list.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); typename std::list<T>::iterator begin = m_list.begin(); T t = *begin; m_list.erase(begin); 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); typename std::list<T>::iterator begin = m_list.begin(); T t = *begin; m_list.erase(begin); return t; } else { throw ItemNotFoundException("MutexedQueue: queue is empty"); } } T pop_frontNoEx() { m_size.Wait(); JMutexAutoLock lock(m_mutex); typename std::list<T>::iterator begin = m_list.begin(); T t = *begin; m_list.erase(begin); return t; } T pop_back(u32 wait_time_max_ms=0) { if (m_size.Wait(wait_time_max_ms)) { JMutexAutoLock lock(m_mutex); typename std::list<T>::iterator last = m_list.end(); last--; T t = *last; m_list.erase(last); 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); typename std::list<T>::iterator last = m_list.end(); last--; T t = *last; m_list.erase(last); return t; } else { return T(); } } T pop_backNoEx() { m_size.Wait(); JMutexAutoLock lock(m_mutex); typename std::list<T>::iterator last = m_list.end(); last--; T t = *last; m_list.erase(last); return t; } protected: JMutex & getMutex() { return m_mutex; } // NEVER EVER modify the >>list<< you got by using this function! // You may only modify it's content std::list<T> & getList() { return m_list; } JMutex m_mutex; std::list<T> m_list; JSemaphore m_size; }; #endif