aboutsummaryrefslogtreecommitdiff
path: root/games/minimal/mods/default
Commit message (Expand)AuthorAge
* Fix spelling of noise_thresholdJun Zhang2015-12-06
* Fix relief mapping issuesRealBadAngel2015-07-16
* Minimal: Remove recently added unnecessary nodesparamat2015-07-14
* Simpler patch for saplings trying to grow on unknown nodesShadowNinja2015-06-16
* Add list-ringsest312015-06-16
* Don't crash when saplings try to grow on unknown nodesy.st2015-06-15
* Minimal: Add snow biome and jungleleaves nodes. Add mapgen aliasesparamat2015-06-12
* Minimal: Edit mapgen aliases. Use blob ore for clay, update other ores. Updat...paramat2015-06-09
* Fix NDT_GLASSLIKE normalsKahrl2015-01-31
* Remove builtin_biome.lua from builtin and add simple biome minimalparamat2015-01-11
* Add minetest.swap_nodeNovatux2013-11-30
* Change default value of is_ground_content to truekwolekr2013-11-30
* Fix possible crash with grass ABM.Novatux2013-11-02
* Fix grass adding/removing ABM.Novatux2013-11-02
* Move the sapling growing and grass adding/removing ABMs to LuaNovatux2013-11-02
* Remove mapgen_air alias (#935)0gb.us2013-10-05
* Add mapgen_stair_cobble alias to minimalSfan52013-09-06
* Add support for different drowning damage and allow drowning in other nodetypesBlockMen2013-08-06
* Add drowningPilzAdam2013-06-19
* Compress texturesDavid Gumberg2013-06-18
* Move scriptapi to separate folder (by sapier)sapier2013-05-25
* Use the group "soil" for nodes that saplings grow onShadowNinja2013-05-20
* Add Mapgen V7, reorganize biomeskwolekr2013-04-07
* Add different place sound for nodesPilzAdam2013-03-29
* Use minetest.register_ore() in minimalPilzAdam2013-03-24
* Mapgen indev: float islands, larger far biomesproller2013-03-24
* Liquid fine tuningproller2013-03-14
* new adjustable finite liquidproller2013-02-24
* Readded and optimized mapgen V6kwolekr2013-01-21
* Add initial Lua biomedef support, fixed biome selectionkwolekr2013-01-21
* Add the group attached_nodePilzAdam2012-12-01
* Swap out pixel-perfect nyan cat by request of Chris TorresPerttu Ahola2012-11-09
* Add functions to the default mod of minimal game to support old codePilzAdam2012-11-01
* Move falling to builtinPilzAdam2012-10-31
* Fix crash when furnace is full (minimal game)Perttu Ahola2012-08-12
* Deprecate minetest.add_to_creative_inventory and use group not_in_creative_in...Perttu Ahola2012-07-25
* Add notice in the minimal gamePerttu Ahola2012-07-25
* Improve inventory callbacks a bitPerttu Ahola2012-07-25
* Detached inventory callbacks and reworked node metadata callbacksPerttu Ahola2012-07-25
* Move /give, /giveme, /spawnentity and /pulverize to builtin/chatcommands.luaPerttu Ahola2012-07-23
* Implement formspecdarkrose2012-07-22
* Custom boxy nodes (stairs, slabs) and collision changesKahrl2012-06-17
* Revert back proper crack texturePerttu Ahola2012-06-16
* Allow node cracking animations of any lengthPerttu Ahola2012-06-16
* Update field names to non-deprecated ones in node definition prototypePerttu Ahola2012-06-16
* Use new field names and reorder fields a bit in minimal gamePerttu Ahola2012-06-16
* Node texture animationPerttu Ahola2012-06-16
* Add InvRef:is_empty(listname) and make chests/furnaces not diggable if not em...darkrose2012-06-03
* fix locked chest to not destroy denied items (minimal game)darkrose2012-06-03
* Add fire visualization to minimal furnace menuPerttu Ahola2012-06-03
a[modname] = {} end if mod_statistics.data[modname][type] == nil then mod_statistics.data[modname][type] = 0 end mod_statistics.data[modname][type] = mod_statistics.data[modname][type] + time_in_us mod_statistics.step_total = mod_statistics.step_total + time_in_us end -------------------------------------------------------------------------------- function mod_statistics.update_statistics(dtime) for modname,types in pairs(mod_statistics.data) do if mod_statistics.stats[modname] == nil then mod_statistics.stats[modname] = { min_us = math.huge, max_us = 0, avg_us = 0, min_per = 100, max_per = 0, avg_per = 0 } end local modtime = 0 for type,time in pairs(types) do modtime = modtime + time if mod_statistics.stats[modname].types == nil then mod_statistics.stats[modname].types = {} end if mod_statistics.stats[modname].types[type] == nil then mod_statistics.stats[modname].types[type] = { min_us = math.huge, max_us = 0, avg_us = 0, min_per = 100, max_per = 0, avg_per = 0 } end local toupdate = mod_statistics.stats[modname].types[type] --update us values toupdate.min_us = math.min(time, toupdate.min_us) toupdate.max_us = math.max(time, toupdate.max_us) --TODO find better algorithm toupdate.avg_us = toupdate.avg_us * 0.99 + modtime * 0.01 --update percentage values local cur_per = (time/mod_statistics.step_total) * 100 toupdate.min_per = math.min(toupdate.min_per, cur_per) toupdate.max_per = math.max(toupdate.max_per, cur_per) --TODO find better algorithm toupdate.avg_per = toupdate.avg_per * 0.99 + cur_per * 0.01 mod_statistics.data[modname][type] = 0 end --per mod statistics --update us values mod_statistics.stats[modname].min_us = math.min(modtime, mod_statistics.stats[modname].min_us) mod_statistics.stats[modname].max_us = math.max(modtime, mod_statistics.stats[modname].max_us) --TODO find better algorithm mod_statistics.stats[modname].avg_us = mod_statistics.stats[modname].avg_us * 0.99 + modtime * 0.01 --update percentage values local cur_per = (modtime/mod_statistics.step_total) * 100 mod_statistics.stats[modname].min_per = math.min(mod_statistics.stats[modname].min_per, cur_per) mod_statistics.stats[modname].max_per = math.max(mod_statistics.stats[modname].max_per, cur_per) --TODO find better algorithm mod_statistics.stats[modname].avg_per = mod_statistics.stats[modname].avg_per * 0.99 + cur_per * 0.01 end --update "total" mod_statistics.stats["total"].min_us = math.min(mod_statistics.step_total, mod_statistics.stats["total"].min_us) mod_statistics.stats["total"].max_us = math.max(mod_statistics.step_total, mod_statistics.stats["total"].max_us) --TODO find better algorithm mod_statistics.stats["total"].avg_us = mod_statistics.stats["total"].avg_us * 0.99 + mod_statistics.step_total * 0.01 mod_statistics.step_total = 0 end -------------------------------------------------------------------------------- local function build_callback(log_id, fct) return function( toregister ) local modname = core.get_current_modname() fct(function(...) local starttime = core.get_us_time() -- note maximum 10 return values are supported unless someone finds -- a way to store a variable lenght return value list local r0, r1, r2, r3, r4, r5, r6, r7, r8, r9 = toregister(...) local delta = core.get_us_time() - starttime mod_statistics.log_time(log_id, modname, delta) return r0, r1, r2, r3, r4, r5, r6, r7, r8, r9 end ) end end -------------------------------------------------------------------------------- function profiling_print_log(cmd, filter) print("Filter:" .. dump(filter)) core.log("action", "Values below show times/percentages per server step.") core.log("action", "Following suffixes are used for entities:") core.log("action", "\t#oa := on_activate, #os := on_step, #op := on_punch, #or := on_rightclick, #gs := get_staticdata") core.log("action", string.format("%16s | %25s | %10s | %10s | %10s | %9s | %9s | %9s", "modname", "type" , "min µs", "max µs", "avg µs", "min %", "max %", "avg %") ) core.log("action", "-----------------+---------------------------+-----------+" .. "-----------+-----------+-----------+-----------+-----------") for modname,statistics in pairs(mod_statistics.stats) do if modname ~= "total" then if (filter == "") or (modname == filter) then if modname:len() > 16 then modname = "..." .. modname:sub(-13) end core.log("action", string.format("%16s | %25s | %9d | %9d | %9d | %9d | %9d | %9d", modname, " ", statistics.min_us, statistics.max_us, statistics.avg_us, statistics.min_per, statistics.max_per, statistics.avg_per) ) if core.setting_getbool("detailed_profiling") then if statistics.types ~= nil then for type,typestats in pairs(statistics.types) do if type:len() > 25 then type = "..." .. type:sub(-22) end core.log("action", string.format( "%16s | %25s | %9d | %9d | %9d | %9d | %9d | %9d", " ", type, typestats.min_us, typestats.max_us, typestats.avg_us, typestats.min_per, typestats.max_per, typestats.avg_per) ) end end end end end end core.log("action", "-----------------+---------------------------+-----------+" .. "-----------+-----------+-----------+-----------+-----------") if filter == "" then core.log("action", string.format("%16s | %25s | %9d | %9d | %9d | %9d | %9d | %9d", "total", " ", mod_statistics.stats["total"].min_us, mod_statistics.stats["total"].max_us, mod_statistics.stats["total"].avg_us, mod_statistics.stats["total"].min_per, mod_statistics.stats["total"].max_per, mod_statistics.stats["total"].avg_per) ) end core.log("action", " ") return true end -------------------------------------------------------------------------------- local function initialize_profiling() core.log("action", "Initialize tracing") mod_statistics.entity_callbacks = {} -- first register our own globalstep handler core.register_globalstep(mod_statistics.update_statistics) local rp_register_entity = core.register_entity core.register_entity = function(name, prototype) local modname = core.get_current_modname() local new_on_activate = nil local new_on_step = nil local new_on_punch = nil local new_rightclick = nil local new_get_staticdata = nil if prototype.on_activate ~= nil then local cbid = name .. "#oa" mod_statistics.entity_callbacks[cbid] = prototype.on_activate new_on_activate = function(self, staticdata, dtime_s) local starttime = core.get_us_time() mod_statistics.entity_callbacks[cbid](self, staticdata, dtime_s) local delta = core.get_us_time() -starttime mod_statistics.log_time(cbid, modname, delta) end end if prototype.on_step ~= nil then local cbid = name .. "#os" mod_statistics.entity_callbacks[cbid] = prototype.on_step new_on_step = function(self, dtime) local starttime = core.get_us_time() mod_statistics.entity_callbacks[cbid](self, dtime) local delta = core.get_us_time() -starttime mod_statistics.log_time(cbid, modname, delta) end end if prototype.on_punch ~= nil then local cbid = name .. "#op" mod_statistics.entity_callbacks[cbid] = prototype.on_punch new_on_punch = function(self, hitter) local starttime = core.get_us_time() mod_statistics.entity_callbacks[cbid](self, hitter) local delta = core.get_us_time() -starttime mod_statistics.log_time(cbid, modname, delta) end end if prototype.rightclick ~= nil then local cbid = name .. "#rc" mod_statistics.entity_callbacks[cbid] = prototype.rightclick new_rightclick = function(self, clicker) local starttime = core.get_us_time() mod_statistics.entity_callbacks[cbid](self, clicker) local delta = core.get_us_time() -starttime mod_statistics.log_time(cbid, modname, delta) end end if prototype.get_staticdata ~= nil then local cbid = name .. "#gs" mod_statistics.entity_callbacks[cbid] = prototype.get_staticdata new_get_staticdata = function(self) local starttime = core.get_us_time() local retval = mod_statistics.entity_callbacks[cbid](self) local delta = core.get_us_time() -starttime mod_statistics.log_time(cbid, modname, delta) return retval end end prototype.on_activate = new_on_activate prototype.on_step = new_on_step prototype.on_punch = new_on_punch prototype.rightclick = new_rightclick prototype.get_staticdata = new_get_staticdata rp_register_entity(name,prototype) end for i,v in ipairs(replacement_table) do local to_replace = core[v] core[v] = build_callback(v, to_replace) end local rp_register_abm = core.register_abm core.register_abm = function(spec) local modname = core.get_current_modname() local replacement_spec = { nodenames = spec.nodenames, neighbors = spec.neighbors, interval = spec.interval, chance = spec.chance, action = function(pos, node, active_object_count, active_object_count_wider) local starttime = core.get_us_time() spec.action(pos, node, active_object_count, active_object_count_wider) local delta = core.get_us_time() - starttime mod_statistics.log_time("abm", modname, delta) end } rp_register_abm(replacement_spec) end core.log("action", "Mod profiling initialized") end initialize_profiling()