aboutsummaryrefslogtreecommitdiff
path: root/src/script
Commit message (Expand)AuthorAge
* Decorations: Generalise 'spawn by' to be used by all decoration typesparamat2016-09-14
* Return nil on empty get_area() (#4508)James Stevenson2016-09-10
* Make getStackMax return the correct maximal stack sizeSmallJoker2016-09-08
* Add minetest.unregister_item and minetest.register_alias_forcepaly22016-09-08
* Make plantlike drawtype more funAuke Kok2016-08-26
* Script API: Make the craft recipe field 'method' consistentSmallJoker2016-08-18
* couple of memory leaks fixes.David Carlier2016-08-10
* Lua->C getintfield() use lua_tointeger (#4408)Tomas2016-08-10
* Fixes for compiling with a newer (system) jsoncpp (#4429)Rogier-52016-08-10
* Permit usage of std::unordered_map & std::unorderered_set on c++11 compilers ...Ner'zhul2016-08-10
* Fix l_request_insecure_environment not ignoring all whitespace (#4395)Dorian Wouters2016-08-04
* Adding minetest.clear_craftFoghrye42016-07-05
* Add MapSettingsManager and new mapgen setting script API functionskwolekr2016-07-03
* Mapgen: Refactor mapgen creation and managementkwolekr2016-07-03
* Player: New get_look, set_look APIraymoo2016-06-24
* Make node timers more efficientEkdohibs2016-06-11
* Server: Add reason for leave to `on_leaveplayer` callbacksDiego Martinez2016-06-11
* Biome API: Add per-biome riverbed material and depthparamat2016-06-05
* Change internal type for seeds to s32kwolekr2016-06-04
* Add minetest.check_password_entry callbackest312016-05-30
* Remove unused code in s_security.cpp (#4172)Zeno-2016-05-30
* Particles: Add option to remove particles on collisionAuke Kok2016-05-28
* Add base64 encoding and decoding to the lua api. (#3919)red-0012016-05-27
* Fix MgStoneType and BiomeType enum nameskwolekr2016-05-27
* Move biome calculation to BiomeGenkwolekr2016-05-27
* Pathfinder: Fix styleest312016-05-01
* 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
pan>"%s", label):trim() elseif label == false then return format("%s", class or func_name):trim() end local index_id = def.mod .. (class or func_name) local index = counts[index_id] or 1 counts[index_id] = index + 1 return format("%s[%d] %s", class or func_name, index, class and func_name or ""):trim() end --- -- Keep `measure` and the closure in `instrument` lean, as these, and their -- directly called functions are the overhead that is caused by instrumentation. -- local time, log = core.get_us_time, sampler.log local function measure(modname, instrument_name, start, ...) log(modname, instrument_name, time() - start) return ... end --- Automatically instrument a function to measure and log to the sampler. -- def = { -- mod = "", -- class = "", -- func_name = "", -- -- if nil, will create a label based on registration order -- label = "" | false, -- } local function instrument(def) if not def or not def.func then return end def.mod = def.mod or get_current_modname() or "??" local modname = def.mod local instrument_name = generate_name(def) local func = def.func if not instrument_builtin and modname == "*builtin*" then return func end return function(...) -- This tail-call allows passing all return values of `func` -- also called https://en.wikipedia.org/wiki/Continuation_passing_style -- Compared to table creation and unpacking it won't lose `nil` returns -- and is expected to be faster -- `measure` will be executed after time() and func(...) return measure(modname, instrument_name, time(), func(...)) end end local function can_be_called(func) -- It has to be a function or callable table return type(func) == "function" or ((type(func) == "table" or type(func) == "userdata") and getmetatable(func) and getmetatable(func).__call) end local function assert_can_be_called(func, func_name, level) if not can_be_called(func) then -- Then throw an *helpful* error, by pointing on our caller instead of us. error(format("Invalid argument to %s. Expected function-like type instead of '%s'.", func_name, type(func)), level + 1) end end --- -- Wraps a registration function `func` in such a way, -- that it will automatically instrument any callback function passed as first argument. -- local function instrument_register(func, func_name) local register_name = func_name:gsub("^register_", "", 1) return function(callback, ...) assert_can_be_called(callback, func_name, 2) register_functions[func_name] = register_functions[func_name] + 1 return func(instrument { func = callback, func_name = register_name }, ...) end end local function init_chatcommand() if get_bool_default("instrument.chatcommand", true) then local orig_register_chatcommand = core.register_chatcommand core.register_chatcommand = function(cmd, def) def.func = instrument { func = def.func, label = "/" .. cmd, } orig_register_chatcommand(cmd, def) end end end --- -- Start instrumenting selected functions -- local function init() if get_bool_default("instrument.entity", true) then -- Explicitly declare entity api-methods. -- Simple iteration would ignore lookup via __index. local entity_instrumentation = { "on_activate", "on_deactivate", "on_step", "on_punch", "on_rightclick", "get_staticdata", } -- Wrap register_entity() to instrument them on registration. local orig_register_entity = core.register_entity core.register_entity = function(name, prototype) local modname = get_current_modname() for _, func_name in pairs(entity_instrumentation) do prototype[func_name] = instrument { func = prototype[func_name], mod = modname, func_name = func_name, label = prototype.label, } end orig_register_entity(name,prototype) end end if get_bool_default("instrument.abm", true) then -- Wrap register_abm() to automatically instrument abms. local orig_register_abm = core.register_abm core.register_abm = function(spec) spec.action = instrument { func = spec.action, class = "ABM", label = spec.label, } orig_register_abm(spec) end end if get_bool_default("instrument.lbm", true) then -- Wrap register_lbm() to automatically instrument lbms. local orig_register_lbm = core.register_lbm core.register_lbm = function(spec) spec.action = instrument { func = spec.action, class = "LBM", label = spec.label or spec.name, } orig_register_lbm(spec) end end if get_bool_default("instrument.global_callback", true) then for func_name, _ in pairs(register_functions) do core[func_name] = instrument_register(core[func_name], func_name) end end if get_bool_default("instrument.profiler", false) then -- Measure overhead of instrumentation, but keep it down for functions -- So keep the `return` for better optimization. profiler.empty_instrument = instrument { func = function() return end, mod = "*profiler*", class = "Instrumentation overhead", label = false, } end end return { register_functions = register_functions, instrument = instrument, init = init, init_chatcommand = init_chatcommand, }