aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api
Commit message (Expand)AuthorAge
...
* Use LuaErrors in security check macrosShadowNinja2016-03-07
* Remove debug.getupvalue from the Lua sandbox whitelistShadowNinja2016-03-03
* Fix C++11 compilabilityest312016-01-23
* Add on_secondary_use when right clicking an item in the airAlex Ford2015-12-02
* Add callback parameter for core.emerge_area()kwolekr2015-11-02
* Fix Lua scripting synchronizationkwolekr2015-11-01
* Fix server crashing on Lua errorsShadowNinja2015-10-31
* Remove some abort() callsest312015-10-26
* ABMs: Make catch-up behaviour optionalparamat2015-10-18
* Add new ContentParamType2 "CPT2_DEGROTATE"est312015-10-04
* Push error handler afresh each time lua_pcall is usedKahrl2015-08-27
* Use numeric indices and raw table access with LUA_REGISTRYINDEXKahrl2015-08-27
* Clean up threadingShadowNinja2015-08-23
* SAPI: Track last executed mod and include in error messageskwolekr2015-08-12
* Display Lua memory usage at the time of Out-of-Memory errorkwolekr2015-08-10
* Improve Script CPP API diagnosticskwolekr2015-08-05
* Optional reconnect functionalityest312015-07-23
* Fix code style from recent commits and add misc. optimizationskwolekr2015-07-02
* Add Lua errors to error dialogrubenwardy2015-06-29
* Add minetest.register_on_player_hpchangeTeTpaAka2015-06-13
* dofile error reporting for syntax errorsest312015-06-12
* Fix uninitialized variable errorest312015-06-02
* Fix Windows build, clean up included headersSmallJoker2015-05-22
* Replace instances of std::map<std::string, std::string> with StringMapkwolekr2015-05-19
* Add mod securityShadowNinja2015-05-16
* Add minetest.register_on_punchplayerBrandon2015-05-15
* Clean up and tweak build systemShadowNinja2015-03-27
* For usages of assert() that are meant to persist in Release builds (when NDEB...Craig Robbins2015-03-07
* Performance fixes.onkrot2015-01-13
* Expose mapgen parameters on scripting initkwolekr2014-12-29
* Expose mapgen chunksize in on_mapgen_init callbackskwolekr2014-12-14
* Simplify loading of Android version of menuShadowNinja2014-11-20
* Add meshnode drawtype.RealBadAngel2014-10-18
* Fix object reference pushing functions when called from coroutinesShadowNinja2014-10-07
* Add optional framed glasslike drawtypeBlockMen2014-10-02
* Add firelike drawtypeTriBlade92014-09-21
* Don't call a player event without having player to do a event forsapier2014-08-21
* Fix over-poping and only push the core onceShadowNinja2014-05-30
* Use "core" namespace internallyShadowNinja2014-05-08
* Organize builtin into subdirectoriesShadowNinja2014-05-07
* Fix heart + bubble bar size on different texture packssapier2014-05-07
* Fix code style of async APIShadowNinja2014-04-27
* Remove dependency on marshal and many other async changesShadowNinja2014-04-27
* Only push the Lua error handler onceShadowNinja2014-04-27
* Fix all warnings reported by clangSfan52014-04-15
* Add more informative error messages for inventory and item method errorsShadowNinja2014-03-15
* Remove lua_State parameter from LuaError::LuaErrorShadowNinja2014-03-15
* Revert "Make sure we get a stacktrace for as many lua errors as possible"ShadowNinja2014-03-15
* Make sure we get a stacktrace for as many lua errors as possibleSfan52014-03-15
* Pass arguments by referenceSelat2014-03-12
> } void clear() { MutexAutoLock lock(m_mutex); for(std::map<std::string, float>::iterator i = m_data.begin(); i != m_data.end(); ++i) { i->second = 0; } m_avgcounts.clear(); } void print(std::ostream &o) { printPage(o, 1, 1); } float getValue(const std::string &name) const { std::map<std::string, float>::const_iterator numerator = m_data.find(name); if (numerator == m_data.end()) return 0.f; std::map<std::string, int>::const_iterator denominator = m_avgcounts.find(name); if (denominator != m_avgcounts.end()){ if (denominator->second >= 1) return numerator->second / denominator->second; } return numerator->second; } void printPage(std::ostream &o, u32 page, u32 pagecount) { MutexAutoLock lock(m_mutex); u32 minindex, maxindex; paging(m_data.size(), page, pagecount, minindex, maxindex); for(std::map<std::string, float>::iterator i = m_data.begin(); i != m_data.end(); ++i) { if(maxindex == 0) break; maxindex--; if(minindex != 0) { minindex--; continue; } std::string name = i->first; int avgcount = 1; std::map<std::string, int>::iterator n = m_avgcounts.find(name); if(n != m_avgcounts.end()){ if(n->second >= 1) avgcount = n->second; } o<<" "<<name<<": "; s32 clampsize = 40; s32 space = clampsize - name.size(); for(s32 j=0; j<space; j++) { if(j%2 == 0 && j < space - 1) o<<"-"; else o<<" "; } o<<(i->second / avgcount); o<<std::endl; } } typedef std::map<std::string, float> GraphValues; void graphAdd(const std::string &id, float value) { MutexAutoLock lock(m_mutex); std::map<std::string, float>::iterator i = m_graphvalues.find(id); if(i == m_graphvalues.end()) m_graphvalues[id] = value; else i->second += value; } void graphGet(GraphValues &result) { MutexAutoLock lock(m_mutex); result = m_graphvalues; m_graphvalues.clear(); } void remove(const std::string& name) { MutexAutoLock lock(m_mutex); m_avgcounts.erase(name); m_data.erase(name); } private: Mutex m_mutex; std::map<std::string, float> m_data; std::map<std::string, int> m_avgcounts; std::map<std::string, float> m_graphvalues; }; enum ScopeProfilerType{ SPT_ADD, SPT_AVG, SPT_GRAPH_ADD }; class ScopeProfiler { public: ScopeProfiler(Profiler *profiler, const std::string &name, enum ScopeProfilerType type = SPT_ADD): m_profiler(profiler), m_name(name), m_timer(NULL), m_type(type) { if(m_profiler) m_timer = new TimeTaker(m_name.c_str()); } // name is copied ScopeProfiler(Profiler *profiler, const char *name, enum ScopeProfilerType type = SPT_ADD): m_profiler(profiler), m_name(name), m_timer(NULL), m_type(type) { if(m_profiler) m_timer = new TimeTaker(m_name.c_str()); } ~ScopeProfiler() { if(m_timer) { float duration_ms = m_timer->stop(true); float duration = duration_ms / 1000.0; if(m_profiler){ switch(m_type){ case SPT_ADD: m_profiler->add(m_name, duration); break; case SPT_AVG: m_profiler->avg(m_name, duration); break; case SPT_GRAPH_ADD: m_profiler->graphAdd(m_name, duration); break; } } delete m_timer; } } private: Profiler *m_profiler; std::string m_name; TimeTaker *m_timer; enum ScopeProfilerType m_type; }; #endif