aboutsummaryrefslogtreecommitdiff
path: root/src/content_nodemeta.cpp
Commit message (Collapse)AuthorAge
* (se)SerializeString: Include max length in the nameSmallJoker2020-10-01
| | | | | | | This commit clarifies the maximal length of the serialized strings. It will avoid accidental use of serializeString() when a larger string can be expected. Removes unused Wide String serialization functions
* C++11 patchset 9: move hardcoded init parameters to class definitions (part ↵Loïc Blot2017-06-16
| | | | | | | | | | | | | | | | | | | | | | | | 1) (#5984) * C++11 patchset 9: move hardcoded init parameters to class definitions C++11 introduced the possibility to define the default values directly in class definitions, do it on current code Also remove some unused attributes * CollisionInfo::bouncy * collisionMoveResult::collides_xy * collisionMoveResult::standing_on_unloaded * Clouds::speed * More constructor cleanups + some variables removal * remove only write guiFormSpecMenu::m_old_tooltip * move header included inside defintions in genericobject.h * remove some unused since years exception classes * remove unused & empty debug_stacks_init * remove unused & empty content_nodemeta_serialize_legacy * remove forgotten useless bool (bouncy) in collision.cpp code
* Make node timers more efficientEkdohibs2016-06-11
|
* Rename macros with two leading underscoresShadowNinja2015-10-14
| | | | These names are reserved for the compiler/library implementations.
* Use warningstream for log messages with WARNINGShadowNinja2015-10-14
| | | | Remove DTIME macro and its uses, too
* Various style cleanups + unused code removalest312015-09-19
| | | | | | | | | | -> Don't pass pointer to whole IGameDef to NodeMetadata constructors and deserializers, but only to IItemDefManager, which is needed -> Remove the unused content_mapnode_get_new_name() method -> Fix style for MapBlock::deSerialize and MapBlock::deSerialize_pre22, improving accuracy of error messages a bit -> Fix style at other serialisation methods too -> Improve accuracy of some comments
* Omnicleanup: header cleanup, add ModApiUtil shared between game and mainmenuKahrl2013-08-14
|
* Update Copyright YearsSfan52013-02-24
|
* Change Minetest-c55 to MinetestPilzAdam2013-02-24
|
* Implement formspecdarkrose2012-07-22
|
* Properly and efficiently use split utility headersPerttu Ahola2012-06-17
|
* Switch the license to be LGPLv2/later, with small parts still remaining as ↵Perttu Ahola2012-06-05
| | | | GPLv2/later, by agreement of major contributors
* Fix loading of old signsPerttu Ahola2012-06-04
|
* Fix loading of legacy chestsPerttu Ahola2012-06-03
|
* Implement sign using form field protocolPerttu Ahola2012-06-03
|
* Convert legacy chest inventory list "0" to "main"Perttu Ahola2012-06-03
|
* Strip unneeded variables from NodeMetadatadarkrose2012-06-03
|
* WIP node metadata, node timersKahrl2012-06-03
|
* Fix server hang when stepping a furnace with a huge dtimeKahrl2012-02-02
|
* The huge item definition and item namespace unification patch (itemdef), see ↵Kahrl2012-01-12
| | | | http://c55.me/minetest/wiki/doku.php?id=changes:itemdef
* Move NodeMetadata prototype containers to content_nodemeta.cpp to fix them ↵Perttu Ahola2011-12-01
| | | | not being filled correctly on some systems and compilers
* GenericNodeMetadata and an example furnacePerttu Ahola2011-11-29
|
* Mode node definition loading from Lua (still not finished), fix metadata ↵Perttu Ahola2011-11-29
| | | | creation from name
* Add names to NodeMetadataPerttu Ahola2011-11-29
|
* Do not expose CONTENT_* stuff in content_mapnode.h and use a name converter ↵Perttu Ahola2011-11-29
| | | | wrapper in old code
* Remove burn time definitions from FurnaceNodeMetadataPerttu Ahola2011-11-29
|
* Clean mapnode.h and fix other files accordinglyPerttu Ahola2011-11-29
|
* Create framework for getting rid of global definitions of ↵Perttu Ahola2011-11-29
| | | | node/tool/item/whatever types
* Switch more stuff to use the logging thing and fix segfault on player leave ↵Perttu Ahola2011-10-16
| | | | from server as introduced in a previous switch-to-logging commit
* added locking chests - clean patchdarkrose2011-09-22
|
* Furnace was crashing stuff againJacobF2011-09-02
|
* * Furnace would say it was overloaded when it had a non-cookable sourceJacobF2011-09-01
| | | | | * I didn't understand that expression last fix and now the furnace would burn fuel even when it had no source item.
* If there was no source item in a furnace it would cause a segmentation fault.JacobF2011-08-30
|
* Merge remote-tracking branch 'queatz/furnace-is-not-blackhole'Perttu Ahola2011-08-30
|\
| * Don't remove furnace if something is inside it.JacobF2011-08-24
| |
* | Merged 2 branches because they relied on each other.JacobF2011-08-25
|/ | | | | | | | | | | This one contains these changes from main c55: * Adds a function to check if there is room for a specific item * Using that, you can now pick up rats if you have a full inventory and a not full rat stack * Furnace would cook only 1 item if that item used the last available result slot, now it will continue * Furnace will say it's overloaded * Furnace won't wait until the next step to start on the next item - This caused small fuels to cook slower than meant to - Also caused furnaces to say they were out of fuel after finishing the last fuel item
* Some inventory const-ificationGiuseppe Bilotta2011-08-11
|
* made more things burnable in furnacePerttu Ahola2011-07-30
|
* fixed wrong furnace menu layoutPerttu Ahola2011-06-18
|
* moved inventory menu definition of chest and furnace to content_nodemeta.{h,cpp}Perttu Ahola2011-06-18
|
* Created and moved stuff to content_nodemeta.{h,cpp}Perttu Ahola2011-06-18
/span> 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()