aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_env.cpp
Commit message (Expand)AuthorAge
* Spacing fixesShadowNinja2022-04-08
* Disentangle map implementations (#12148)Jude Melton-Houghton2022-04-07
* Fix find_nodes_in_area misbehaving with out-of-map coordinates (#11770)sfan52021-11-26
* Fix item duplication if player dies during interact callback (alternative) (#...sfan52021-10-25
* Add core.compare_block_status function (#11247)SmallJoker2021-05-30
* script: Replace calls to depreated luaL_openlibsfan52021-05-30
* Add minetest.get_objects_in_area (#10668)Elias Fleckenstein2020-12-29
* Fix float argument check in minetest.set_timeofday() (#10483)Zughy2020-10-13
* Add minetest.get_artificial_light and minetest.get_natural_light (#5680)HybridDog2020-10-06
* Clean up server-side translations, remove global variable (#10075)rubenwardy2020-09-16
* Implement grouped mode for find_nodes_in_area (#9888)sfan52020-07-14
* Rework functionality of leveled nodes (#9852)Wuzzy2020-05-19
* CSM: Bugfixes to camera:get_pos() and camera:get_fov()sfan52020-05-14
* script: Fix add_entity returning unusable ref if object deleted in on_activatesfan52020-04-27
* Add server side translations capability (#9733)EvidenceB Kidscode2020-04-25
* Optimize get_objects_inside_radius calls (#9671)Loïc Blot2020-04-16
* scriptapi: Some small optimizations to value pushing (#9669)sfan52020-04-14
* Reduce ServerEnvironment propagation (#9642)Loïc Blot2020-04-11
* Drop content_sao.{cpp,h}Loic Blot2020-04-11
* Move PlayerSAO to dedicated filesLoic Blot2020-04-11
* scriptapi: Sort out ServerEnvironment / Environment distinction properlysfan52020-04-11
* minetest,get_connected_players: Return empty table at load time (#9493)sfan52020-03-10
* Fix pathfinder bugs: returning nil frequently, broken A*, jump through solid ...Wuzzy2020-03-05
* Fix core.get_player_by_name() returning unusable ObjectRefsfan52020-03-03
* Fix core.get_connected_players() returning unusable ObjectRefssfan52020-03-03
* Fix potential problem with core.get_connected_players()sfan52020-02-25
* Move core.get_connected_players() implementation to C++sfan52020-02-23
* [CSM] Expose more env functionssfan52019-11-11
* Refactor CSM restriction code a bitsfan52019-11-11
* [CSM] Remove non-functional minetest.get_day_count()sfan52019-11-09
* Fix some reference counters (memleak) (#8981)SmallJoker2019-09-24
* Merge pull request #8776 from osjc/FixGetNodeJozef Behran2019-08-10
* Add minetest.load_area (#8023)HybridDog2018-12-31
* Move client-specific files to 'src/client' (#7902)Quentin Bazin2018-11-28
* Raycast: export exact pointing location (#6304)Dániel Juhász2018-08-16
* Modernize lua read (part 2 & 3): C++ templating assurance (#7410)Loïc Blot2018-06-30
* Rename CSM flavours to restrictionsSmallJoker2018-06-26
* Modernize lua read (part 1): C++ templating insurance (#7394)Loïc Blot2018-06-04
* Find nodes in area (under air): Raise volume limit and document itparamat2018-02-21
* Node definition manager refactor (#7016)Dániel Juhász2018-02-10
* Add minetest.bulk_set_node call + optimize Environment::set_node call (#6958)Loïc Blot2018-01-30
* Line_of_sight: Improve using VoxelLineIteratorDániel Juhász2017-12-26
* Clearobjects: Send progress messages to terminal using actionstreamparamat2017-11-24
* Move files to subdirectories (#6599)Vitaliy2017-11-08
* Set placer to nil instead of a non-functional one in item_OnPlace (#6449)DTA72017-09-21
* ServerEnv: Clean up object lifecycle handling (#6414)sfan52017-09-15
* Make INodeDefManager::getIds return a vector, not a setKahrl2017-09-12
* core.get_objects_inside_radius: Omit removed objects (#6318)you2017-08-27
* Modernize source code: last part (#6285)Loïc Blot2017-08-20
* Code modernization: subfolders (#6283)Loïc Blot2017-08-19
l slc">-- 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() 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_step", "on_punch", "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, }