diff options
163 files changed, 1076 insertions, 219 deletions
diff --git a/.gitignore b/.gitignore index c8f21e504..db131c29f 100644 --- a/.gitignore +++ b/.gitignore @@ -59,4 +59,7 @@ CPackSourceConfig.cmake Makefile cmake_install.cmake locale/ +*.cbp +*.layout +*.o diff --git a/CMakeLists.txt b/CMakeLists.txt index 446fff075..5c8753e78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string") # Also remember to set PROTOCOL_VERSION in clientserver.h when releasing set(VERSION_MAJOR 0) set(VERSION_MINOR 4) -set(VERSION_PATCH 6) +set(VERSION_PATCH 7) if(VERSION_EXTRA) set(VERSION_PATCH ${VERSION_PATCH}-${VERSION_EXTRA}) endif() @@ -28,6 +28,13 @@ else() set(RUN_IN_PLACE 0 CACHE BOOL "Run directly in source directory structure") endif() +# RUN_IN_PLACE is exported as a #define value, ensure it's 1/0 instead of ON/OFF +if(RUN_IN_PLACE) + set(RUN_IN_PLACE 1) +else() + set(RUN_IN_PLACE 0) +endif() + set(BUILD_CLIENT 1 CACHE BOOL "Build client") if(WIN32) set(BUILD_SERVER 0 CACHE BOOL "Build server") diff --git a/builtin/misc_helpers.lua b/builtin/misc_helpers.lua index 8b0db6c5a..743a9cfd3 100644 --- a/builtin/misc_helpers.lua +++ b/builtin/misc_helpers.lua @@ -57,7 +57,7 @@ function dump(o, dumped) dumped[o] = true local t = {} for k,v in pairs(o) do - t[#t+1] = "" .. k .. " = " .. dump(v, dumped) + t[#t+1] = "[" .. dump(k, dumped) .. "] = " .. dump(v, dumped) end return "{" .. table.concat(t, ", ") .. "}" elseif type(o) == "boolean" then diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 5143c2ef3..a19174548 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -1,6 +1,7 @@ -Minetest Lua Modding API Reference 0.4.6 +Minetest Lua Modding API Reference 0.4.7 ======================================== -More information at http://c55.me/minetest/ +More information at http://www.minetest.net/ +Developer Wiki: http://dev.minetest.net/ Introduction ------------- @@ -409,6 +410,18 @@ Currently supported flags: absheight Also produce this same ore between the height range of -height_max and -height_min. Useful for having ore in sky realms without having to duplicate ore entries. +Decoration types +------------------- +The varying types of decorations that can be placed. +The default value is simple, and is currently the only type supported. + +- simple + Creates a 1xHx1 column of a specified node (or a random node from a list, if a decoration + list is specified). Can specify a certain node it must spawn next to, such as water or lava, + for example. Can also generate a decoration of random height between a specified lower and + upper bound. This type of decoration is intended for placement of grass, flowers, cacti, + papyrus, and so on. + HUD element types ------------------- The position field is used for all element types. @@ -945,6 +958,7 @@ minetest.register_craftitem(name, item definition) minetest.register_alias(name, convert_to) minetest.register_craft(recipe) minetest.register_ore(ore definition) +minetest.register_decoration(decoration definition) Global callback registration functions: (Call these only at load time) minetest.register_globalstep(func(dtime)) @@ -1004,7 +1018,6 @@ minetest.setting_get(name) -> string or nil minetest.setting_getbool(name) -> boolean value or nil minetest.setting_get_pos(name) -> position or nil minetest.setting_save() -> nil, save all settings to config file -minetest.add_to_creative_inventory(itemstring) Authentication: minetest.notify_authentication_modified(name) @@ -1279,15 +1292,6 @@ minetest.object_refs minetest.luaentities ^ List of lua entities, indexed by active object id -Deprecated but defined for backwards compatibility: -minetest.digprop_constanttime(time) -minetest.digprop_stonelike(toughness) -minetest.digprop_dirtlike(toughness) -minetest.digprop_gravellike(toughness) -minetest.digprop_woodlike(toughness) -minetest.digprop_leaveslike(toughness) -minetest.digprop_glasslike(toughness) - Class reference ---------------- NodeMetaRef: Node metadata - reference extra data and functionality stored @@ -1696,6 +1700,7 @@ Node definition (register_node) liquid_alternative_source = "", -- Source version of flowing liquid liquid_viscosity = 0, -- Higher viscosity = slower flow (max. 7) liquid_renewable = true, -- Can new liquid source be created by placing + drowning = true, -- Player will drown in these two or more sources nearly? light_source = 0, -- Amount of light emitted by node damage_per_second = 0, -- If player is inside node, this damage is caused @@ -1834,7 +1839,7 @@ Recipe for register_craft (furnace fuel) Ore definition (register_ore) { - ore_type = "scatter" -- See "Ore types" + ore_type = "scatter", -- See "Ore types" ore = "default:stone_with_coal", wherein = "default:stone", clust_scarcity = 8*8*8, @@ -1856,6 +1861,41 @@ Ore definition (register_ore) ^ Needed for sheet ore_type. Omit from scatter ore_type for a uniform ore distribution } +Decoration definition (register_decoration) +{ + deco_type = "simple", -- See "Decoration types" + place_on = "default:dirt_with_grass", + ^ Node that decoration can be placed on + sidelen = 8, + ^ Size of divisions made in the chunk being generated. + ^ If the chunk size is not evenly divisible by sidelen, sidelen is made equal to the chunk size. + fill_ratio = 0.02, + ^ Ratio of the area to be uniformly filled by the decoration. + ^ Used only if noise_params is not specified. + noise_params = {offset=0, scale=.45, spread={x=100, y=100, z=100}, seed=354, octaves=3, persist=0.7}, + ^ NoiseParams structure describing the perlin noise used for decoration distribution. + ^ The result of this is multiplied by the 2d area of the division being decorated. + biomes = {"Oceanside", "Hills", "Plains"}, + ^ List of biomes in which this decoration occurs. Occurs in all biomes if this is omitted, + ^ and ignored if the Mapgen being used does not support biomes. + + ----- Simple-type parameters + decoration = "default:grass", + ^ The node name used as the decoration. + ^ If instead a list of strings, a randomly selected node from the list is placed as the decoration. + height = 1, + ^ Number of nodes high the decoration is made. + ^ If height_max is not 0, this is the lower bound of the randomly selected height. + height_max = 0, + ^ Number of nodes the decoration can be at maximum. + ^ If absent, the parameter 'height' is used as a constant. + spawn_by = "default:water", + ^ Node that the decoration only spawns next to, in a 1-node square radius. + num_spawn_by = 1, + ^ Number of spawn_by nodes that must be surrounding the decoration position to occur. + ^ If absent or -1, decorations occur next to any nodes. +} + Chatcommand definition (register_chatcommand) { params = "<name> <privilege>", -- short parameter description diff --git a/doc/minetest.6 b/doc/minetest.6 index 64dfdd149..c690229df 100644 --- a/doc/minetest.6 +++ b/doc/minetest.6 @@ -88,7 +88,7 @@ This man page was originally written by Juhani Numminen <juhaninumminen0@gmail.com>. .SH WWW -http://c55.me/minetest/ +http://www.minetest.net/ .SH "SEE ALSO" .BR minetestserver(6) diff --git a/doc/minetestserver.6 b/doc/minetestserver.6 index 93c354e79..5a9b0a08b 100644 --- a/doc/minetestserver.6 +++ b/doc/minetestserver.6 @@ -64,7 +64,7 @@ This man page was originally written by Juhani Numminen <juhaninumminen0@gmail.com>. .SH WWW -http://c55.me/minetest/ +http://www.minetest.net/ .SH "SEE ALSO" .BR minetest(6) diff --git a/games/minimal/menu/background.png b/games/minimal/menu/background.png Binary files differindex e020f909d..ea5fbdce5 100644 --- a/games/minimal/menu/background.png +++ b/games/minimal/menu/background.png diff --git a/games/minimal/menu/icon.png b/games/minimal/menu/icon.png Binary files differindex fa8d7cd7f..8ef675023 100644 --- a/games/minimal/menu/icon.png +++ b/games/minimal/menu/icon.png diff --git a/games/minimal/mods/bucket/textures/bucket.png b/games/minimal/mods/bucket/textures/bucket.png Binary files differindex f165fd209..b775a9fd3 100644 --- a/games/minimal/mods/bucket/textures/bucket.png +++ b/games/minimal/mods/bucket/textures/bucket.png diff --git a/games/minimal/mods/bucket/textures/bucket_lava.png b/games/minimal/mods/bucket/textures/bucket_lava.png Binary files differindex 7cf27cd1f..889ed61d4 100644 --- a/games/minimal/mods/bucket/textures/bucket_lava.png +++ b/games/minimal/mods/bucket/textures/bucket_lava.png diff --git a/games/minimal/mods/bucket/textures/bucket_water.png b/games/minimal/mods/bucket/textures/bucket_water.png Binary files differindex f220ec51e..a3c9d72f7 100644 --- a/games/minimal/mods/bucket/textures/bucket_water.png +++ b/games/minimal/mods/bucket/textures/bucket_water.png diff --git a/games/minimal/mods/default/textures/bubble.png b/games/minimal/mods/default/textures/bubble.png Binary files differnew file mode 100644 index 000000000..3bca7e11c --- /dev/null +++ b/games/minimal/mods/default/textures/bubble.png diff --git a/games/minimal/mods/default/textures/crack_anylength.png b/games/minimal/mods/default/textures/crack_anylength.png Binary files differindex 6832c5118..d9b49f911 100644 --- a/games/minimal/mods/default/textures/crack_anylength.png +++ b/games/minimal/mods/default/textures/crack_anylength.png diff --git a/games/minimal/mods/default/textures/default_apple.png b/games/minimal/mods/default/textures/default_apple.png Binary files differindex 9593f28f6..4473dca28 100644 --- a/games/minimal/mods/default/textures/default_apple.png +++ b/games/minimal/mods/default/textures/default_apple.png diff --git a/games/minimal/mods/default/textures/default_book.png b/games/minimal/mods/default/textures/default_book.png Binary files differindex 176fb6aa9..ea14a372a 100644 --- a/games/minimal/mods/default/textures/default_book.png +++ b/games/minimal/mods/default/textures/default_book.png diff --git a/games/minimal/mods/default/textures/default_bookshelf.png b/games/minimal/mods/default/textures/default_bookshelf.png Binary files differindex 5ecc50ff3..f225e3449 100644 --- a/games/minimal/mods/default/textures/default_bookshelf.png +++ b/games/minimal/mods/default/textures/default_bookshelf.png diff --git a/games/minimal/mods/default/textures/default_brick.png b/games/minimal/mods/default/textures/default_brick.png Binary files differindex 32d77f347..def1cf0b1 100644 --- a/games/minimal/mods/default/textures/default_brick.png +++ b/games/minimal/mods/default/textures/default_brick.png diff --git a/games/minimal/mods/default/textures/default_cactus_side.png b/games/minimal/mods/default/textures/default_cactus_side.png Binary files differindex fc479fde6..128a4d28a 100644 --- a/games/minimal/mods/default/textures/default_cactus_side.png +++ b/games/minimal/mods/default/textures/default_cactus_side.png diff --git a/games/minimal/mods/default/textures/default_cactus_top.png b/games/minimal/mods/default/textures/default_cactus_top.png Binary files differindex f9e68df51..eda1a0bb6 100644 --- a/games/minimal/mods/default/textures/default_cactus_top.png +++ b/games/minimal/mods/default/textures/default_cactus_top.png diff --git a/games/minimal/mods/default/textures/default_chest_front.png b/games/minimal/mods/default/textures/default_chest_front.png Binary files differindex c5628af94..55b076c35 100644 --- a/games/minimal/mods/default/textures/default_chest_front.png +++ b/games/minimal/mods/default/textures/default_chest_front.png diff --git a/games/minimal/mods/default/textures/default_chest_lock.png b/games/minimal/mods/default/textures/default_chest_lock.png Binary files differindex ae038fae5..4b2d1af6c 100644 --- a/games/minimal/mods/default/textures/default_chest_lock.png +++ b/games/minimal/mods/default/textures/default_chest_lock.png diff --git a/games/minimal/mods/default/textures/default_chest_side.png b/games/minimal/mods/default/textures/default_chest_side.png Binary files differindex 916dd784d..ae4847cb6 100644 --- a/games/minimal/mods/default/textures/default_chest_side.png +++ b/games/minimal/mods/default/textures/default_chest_side.png diff --git a/games/minimal/mods/default/textures/default_chest_top.png b/games/minimal/mods/default/textures/default_chest_top.png Binary files differindex 58c79674d..ac41551b0 100644 --- a/games/minimal/mods/default/textures/default_chest_top.png +++ b/games/minimal/mods/default/textures/default_chest_top.png diff --git a/games/minimal/mods/default/textures/default_clay.png b/games/minimal/mods/default/textures/default_clay.png Binary files differindex 3557429d8..070b69e48 100644 --- a/games/minimal/mods/default/textures/default_clay.png +++ b/games/minimal/mods/default/textures/default_clay.png diff --git a/games/minimal/mods/default/textures/default_clay_brick.png b/games/minimal/mods/default/textures/default_clay_brick.png Binary files differindex e36648e48..e25633b70 100644 --- a/games/minimal/mods/default/textures/default_clay_brick.png +++ b/games/minimal/mods/default/textures/default_clay_brick.png diff --git a/games/minimal/mods/default/textures/default_clay_lump.png b/games/minimal/mods/default/textures/default_clay_lump.png Binary files differindex be0bab9d7..ceed6fa75 100644 --- a/games/minimal/mods/default/textures/default_clay_lump.png +++ b/games/minimal/mods/default/textures/default_clay_lump.png diff --git a/games/minimal/mods/default/textures/default_cloud.png b/games/minimal/mods/default/textures/default_cloud.png Binary files differindex 24091a377..faf0ec13d 100644 --- a/games/minimal/mods/default/textures/default_cloud.png +++ b/games/minimal/mods/default/textures/default_cloud.png diff --git a/games/minimal/mods/default/textures/default_coal_lump.png b/games/minimal/mods/default/textures/default_coal_lump.png Binary files differindex bad901efa..dae47e342 100644 --- a/games/minimal/mods/default/textures/default_coal_lump.png +++ b/games/minimal/mods/default/textures/default_coal_lump.png diff --git a/games/minimal/mods/default/textures/default_cobble.png b/games/minimal/mods/default/textures/default_cobble.png Binary files differindex 7d0447419..2a28d25a5 100644 --- a/games/minimal/mods/default/textures/default_cobble.png +++ b/games/minimal/mods/default/textures/default_cobble.png diff --git a/games/minimal/mods/default/textures/default_fence.png b/games/minimal/mods/default/textures/default_fence.png Binary files differindex 0b99f0eb5..e3510c52a 100644 --- a/games/minimal/mods/default/textures/default_fence.png +++ b/games/minimal/mods/default/textures/default_fence.png diff --git a/games/minimal/mods/default/textures/default_furnace_fire_bg.png b/games/minimal/mods/default/textures/default_furnace_fire_bg.png Binary files differindex 1272e101e..e3370f438 100644 --- a/games/minimal/mods/default/textures/default_furnace_fire_bg.png +++ b/games/minimal/mods/default/textures/default_furnace_fire_bg.png diff --git a/games/minimal/mods/default/textures/default_furnace_fire_fg.png b/games/minimal/mods/default/textures/default_furnace_fire_fg.png Binary files differindex fbb19df74..7a126e325 100644 --- a/games/minimal/mods/default/textures/default_furnace_fire_fg.png +++ b/games/minimal/mods/default/textures/default_furnace_fire_fg.png diff --git a/games/minimal/mods/default/textures/default_furnace_front.png b/games/minimal/mods/default/textures/default_furnace_front.png Binary files differindex 1620a27c3..4da398c0a 100644 --- a/games/minimal/mods/default/textures/default_furnace_front.png +++ b/games/minimal/mods/default/textures/default_furnace_front.png diff --git a/games/minimal/mods/default/textures/default_furnace_front_active.png b/games/minimal/mods/default/textures/default_furnace_front_active.png Binary files differindex e4d8a5b81..06c4ab3ef 100644 --- a/games/minimal/mods/default/textures/default_furnace_front_active.png +++ b/games/minimal/mods/default/textures/default_furnace_front_active.png diff --git a/games/minimal/mods/default/textures/default_furnace_side.png b/games/minimal/mods/default/textures/default_furnace_side.png Binary files differindex 63cb162fe..c729de9bf 100644 --- a/games/minimal/mods/default/textures/default_furnace_side.png +++ b/games/minimal/mods/default/textures/default_furnace_side.png diff --git a/games/minimal/mods/default/textures/default_glass.png b/games/minimal/mods/default/textures/default_glass.png Binary files differindex ade0196fe..fd665a40c 100644 --- a/games/minimal/mods/default/textures/default_glass.png +++ b/games/minimal/mods/default/textures/default_glass.png diff --git a/games/minimal/mods/default/textures/default_grass.png b/games/minimal/mods/default/textures/default_grass.png Binary files differindex 3610bb2bc..1d76708a0 100644 --- a/games/minimal/mods/default/textures/default_grass.png +++ b/games/minimal/mods/default/textures/default_grass.png diff --git a/games/minimal/mods/default/textures/default_grass_footsteps.png b/games/minimal/mods/default/textures/default_grass_footsteps.png Binary files differindex 57e063d8c..8349033d6 100644 --- a/games/minimal/mods/default/textures/default_grass_footsteps.png +++ b/games/minimal/mods/default/textures/default_grass_footsteps.png diff --git a/games/minimal/mods/default/textures/default_gravel.png b/games/minimal/mods/default/textures/default_gravel.png Binary files differindex f08666ad9..4b47e2346 100644 --- a/games/minimal/mods/default/textures/default_gravel.png +++ b/games/minimal/mods/default/textures/default_gravel.png diff --git a/games/minimal/mods/default/textures/default_iron_lump.png b/games/minimal/mods/default/textures/default_iron_lump.png Binary files differindex edb931018..6b515f66d 100644 --- a/games/minimal/mods/default/textures/default_iron_lump.png +++ b/games/minimal/mods/default/textures/default_iron_lump.png diff --git a/games/minimal/mods/default/textures/default_junglegrass.png b/games/minimal/mods/default/textures/default_junglegrass.png Binary files differindex eea87c07c..7066f7dd9 100644 --- a/games/minimal/mods/default/textures/default_junglegrass.png +++ b/games/minimal/mods/default/textures/default_junglegrass.png diff --git a/games/minimal/mods/default/textures/default_jungletree.png b/games/minimal/mods/default/textures/default_jungletree.png Binary files differindex ccd20ac74..a1fd36a51 100644 --- a/games/minimal/mods/default/textures/default_jungletree.png +++ b/games/minimal/mods/default/textures/default_jungletree.png diff --git a/games/minimal/mods/default/textures/default_jungletree_top.png b/games/minimal/mods/default/textures/default_jungletree_top.png Binary files differindex 2a9b51373..a13fdae4a 100644 --- a/games/minimal/mods/default/textures/default_jungletree_top.png +++ b/games/minimal/mods/default/textures/default_jungletree_top.png diff --git a/games/minimal/mods/default/textures/default_ladder.png b/games/minimal/mods/default/textures/default_ladder.png Binary files differindex 11056359d..46757b884 100644 --- a/games/minimal/mods/default/textures/default_ladder.png +++ b/games/minimal/mods/default/textures/default_ladder.png diff --git a/games/minimal/mods/default/textures/default_lava.png b/games/minimal/mods/default/textures/default_lava.png Binary files differindex cb02ada13..a4cf649f1 100644 --- a/games/minimal/mods/default/textures/default_lava.png +++ b/games/minimal/mods/default/textures/default_lava.png diff --git a/games/minimal/mods/default/textures/default_lava_flowing_animated.png b/games/minimal/mods/default/textures/default_lava_flowing_animated.png Binary files differindex cef8e3611..0bbd13606 100644 --- a/games/minimal/mods/default/textures/default_lava_flowing_animated.png +++ b/games/minimal/mods/default/textures/default_lava_flowing_animated.png diff --git a/games/minimal/mods/default/textures/default_lava_source_animated.png b/games/minimal/mods/default/textures/default_lava_source_animated.png Binary files differindex 9339a684e..aa9d57cf1 100644 --- a/games/minimal/mods/default/textures/default_lava_source_animated.png +++ b/games/minimal/mods/default/textures/default_lava_source_animated.png diff --git a/games/minimal/mods/default/textures/default_leaves.png b/games/minimal/mods/default/textures/default_leaves.png Binary files differindex 7a25126e9..00ce4471c 100644 --- a/games/minimal/mods/default/textures/default_leaves.png +++ b/games/minimal/mods/default/textures/default_leaves.png diff --git a/games/minimal/mods/default/textures/default_mese.png b/games/minimal/mods/default/textures/default_mese.png Binary files differindex 4c876cdc5..123f0f4b9 100644 --- a/games/minimal/mods/default/textures/default_mese.png +++ b/games/minimal/mods/default/textures/default_mese.png diff --git a/games/minimal/mods/default/textures/default_mineral_coal.png b/games/minimal/mods/default/textures/default_mineral_coal.png Binary files differindex 3ff9692fb..0f52062af 100644 --- a/games/minimal/mods/default/textures/default_mineral_coal.png +++ b/games/minimal/mods/default/textures/default_mineral_coal.png diff --git a/games/minimal/mods/default/textures/default_mineral_iron.png b/games/minimal/mods/default/textures/default_mineral_iron.png Binary files differindex 51b15d95d..6c894ce1c 100644 --- a/games/minimal/mods/default/textures/default_mineral_iron.png +++ b/games/minimal/mods/default/textures/default_mineral_iron.png diff --git a/games/minimal/mods/default/textures/default_mossycobble.png b/games/minimal/mods/default/textures/default_mossycobble.png Binary files differindex fad1b33ff..5082953a6 100644 --- a/games/minimal/mods/default/textures/default_mossycobble.png +++ b/games/minimal/mods/default/textures/default_mossycobble.png diff --git a/games/minimal/mods/default/textures/default_nc_back.png b/games/minimal/mods/default/textures/default_nc_back.png Binary files differindex febd7384a..e479ace83 100644 --- a/games/minimal/mods/default/textures/default_nc_back.png +++ b/games/minimal/mods/default/textures/default_nc_back.png diff --git a/games/minimal/mods/default/textures/default_nc_front.png b/games/minimal/mods/default/textures/default_nc_front.png Binary files differindex 53b02d174..c9dd6a330 100644 --- a/games/minimal/mods/default/textures/default_nc_front.png +++ b/games/minimal/mods/default/textures/default_nc_front.png diff --git a/games/minimal/mods/default/textures/default_nc_rb.png b/games/minimal/mods/default/textures/default_nc_rb.png Binary files differindex 7183e6986..685a22ccf 100644 --- a/games/minimal/mods/default/textures/default_nc_rb.png +++ b/games/minimal/mods/default/textures/default_nc_rb.png diff --git a/games/minimal/mods/default/textures/default_nc_side.png b/games/minimal/mods/default/textures/default_nc_side.png Binary files differindex 0a34c8bef..bc85427ae 100644 --- a/games/minimal/mods/default/textures/default_nc_side.png +++ b/games/minimal/mods/default/textures/default_nc_side.png diff --git a/games/minimal/mods/default/textures/default_paper.png b/games/minimal/mods/default/textures/default_paper.png Binary files differindex ae5c06bc6..3c31f77c2 100644 --- a/games/minimal/mods/default/textures/default_paper.png +++ b/games/minimal/mods/default/textures/default_paper.png diff --git a/games/minimal/mods/default/textures/default_papyrus.png b/games/minimal/mods/default/textures/default_papyrus.png Binary files differindex bf0dec7fe..3707e4081 100644 --- a/games/minimal/mods/default/textures/default_papyrus.png +++ b/games/minimal/mods/default/textures/default_papyrus.png diff --git a/games/minimal/mods/default/textures/default_rail.png b/games/minimal/mods/default/textures/default_rail.png Binary files differindex 18176d9f3..777e10c00 100644 --- a/games/minimal/mods/default/textures/default_rail.png +++ b/games/minimal/mods/default/textures/default_rail.png diff --git a/games/minimal/mods/default/textures/default_rail_crossing.png b/games/minimal/mods/default/textures/default_rail_crossing.png Binary files differindex 984640577..a988c4740 100644 --- a/games/minimal/mods/default/textures/default_rail_crossing.png +++ b/games/minimal/mods/default/textures/default_rail_crossing.png diff --git a/games/minimal/mods/default/textures/default_rail_curved.png b/games/minimal/mods/default/textures/default_rail_curved.png Binary files differindex 62afa3d2b..f87e826c9 100644 --- a/games/minimal/mods/default/textures/default_rail_curved.png +++ b/games/minimal/mods/default/textures/default_rail_curved.png diff --git a/games/minimal/mods/default/textures/default_rail_t_junction.png b/games/minimal/mods/default/textures/default_rail_t_junction.png Binary files differindex 9985f63cd..fd25b5ba6 100644 --- a/games/minimal/mods/default/textures/default_rail_t_junction.png +++ b/games/minimal/mods/default/textures/default_rail_t_junction.png diff --git a/games/minimal/mods/default/textures/default_sand.png b/games/minimal/mods/default/textures/default_sand.png Binary files differindex 15101a7eb..1a56cc737 100644 --- a/games/minimal/mods/default/textures/default_sand.png +++ b/games/minimal/mods/default/textures/default_sand.png diff --git a/games/minimal/mods/default/textures/default_sandstone.png b/games/minimal/mods/default/textures/default_sandstone.png Binary files differindex c4759b4d0..bd9cb8692 100644 --- a/games/minimal/mods/default/textures/default_sandstone.png +++ b/games/minimal/mods/default/textures/default_sandstone.png diff --git a/games/minimal/mods/default/textures/default_sapling.png b/games/minimal/mods/default/textures/default_sapling.png Binary files differindex 73f502306..93602322c 100644 --- a/games/minimal/mods/default/textures/default_sapling.png +++ b/games/minimal/mods/default/textures/default_sapling.png diff --git a/games/minimal/mods/default/textures/default_scorched_stuff.png b/games/minimal/mods/default/textures/default_scorched_stuff.png Binary files differindex 9ced2fbe8..c7efc7e58 100644 --- a/games/minimal/mods/default/textures/default_scorched_stuff.png +++ b/games/minimal/mods/default/textures/default_scorched_stuff.png diff --git a/games/minimal/mods/default/textures/default_sign_wall.png b/games/minimal/mods/default/textures/default_sign_wall.png Binary files differindex 06eac1ee9..93c075a2d 100644 --- a/games/minimal/mods/default/textures/default_sign_wall.png +++ b/games/minimal/mods/default/textures/default_sign_wall.png diff --git a/games/minimal/mods/default/textures/default_steel_block.png b/games/minimal/mods/default/textures/default_steel_block.png Binary files differindex 8e2020081..9c0a0e248 100644 --- a/games/minimal/mods/default/textures/default_steel_block.png +++ b/games/minimal/mods/default/textures/default_steel_block.png diff --git a/games/minimal/mods/default/textures/default_steel_ingot.png b/games/minimal/mods/default/textures/default_steel_ingot.png Binary files differindex f6c9414e7..ad133bc12 100644 --- a/games/minimal/mods/default/textures/default_steel_ingot.png +++ b/games/minimal/mods/default/textures/default_steel_ingot.png diff --git a/games/minimal/mods/default/textures/default_stick.png b/games/minimal/mods/default/textures/default_stick.png Binary files differindex 2d31797f0..055a6ac04 100644 --- a/games/minimal/mods/default/textures/default_stick.png +++ b/games/minimal/mods/default/textures/default_stick.png diff --git a/games/minimal/mods/default/textures/default_stone.png b/games/minimal/mods/default/textures/default_stone.png Binary files differindex cad0dbe2b..a835fe002 100644 --- a/games/minimal/mods/default/textures/default_stone.png +++ b/games/minimal/mods/default/textures/default_stone.png diff --git a/games/minimal/mods/default/textures/default_tnt_bottom.png b/games/minimal/mods/default/textures/default_tnt_bottom.png Binary files differindex 8ba2fca0b..4eda0603f 100644 --- a/games/minimal/mods/default/textures/default_tnt_bottom.png +++ b/games/minimal/mods/default/textures/default_tnt_bottom.png diff --git a/games/minimal/mods/default/textures/default_tnt_side.png b/games/minimal/mods/default/textures/default_tnt_side.png Binary files differindex d9a2bc4eb..c259726d6 100644 --- a/games/minimal/mods/default/textures/default_tnt_side.png +++ b/games/minimal/mods/default/textures/default_tnt_side.png diff --git a/games/minimal/mods/default/textures/default_tnt_top.png b/games/minimal/mods/default/textures/default_tnt_top.png Binary files differindex a84ffc9af..a031a34ad 100644 --- a/games/minimal/mods/default/textures/default_tnt_top.png +++ b/games/minimal/mods/default/textures/default_tnt_top.png diff --git a/games/minimal/mods/default/textures/default_tool_mesepick.png b/games/minimal/mods/default/textures/default_tool_mesepick.png Binary files differindex a1f3812e0..2b5e12cdb 100644 --- a/games/minimal/mods/default/textures/default_tool_mesepick.png +++ b/games/minimal/mods/default/textures/default_tool_mesepick.png diff --git a/games/minimal/mods/default/textures/default_tool_steelaxe.png b/games/minimal/mods/default/textures/default_tool_steelaxe.png Binary files differindex 0ad23c93b..fae19dd0d 100644 --- a/games/minimal/mods/default/textures/default_tool_steelaxe.png +++ b/games/minimal/mods/default/textures/default_tool_steelaxe.png diff --git a/games/minimal/mods/default/textures/default_tool_steelpick.png b/games/minimal/mods/default/textures/default_tool_steelpick.png Binary files differindex 7982dafeb..3a8f58643 100644 --- a/games/minimal/mods/default/textures/default_tool_steelpick.png +++ b/games/minimal/mods/default/textures/default_tool_steelpick.png diff --git a/games/minimal/mods/default/textures/default_tool_steelshovel.png b/games/minimal/mods/default/textures/default_tool_steelshovel.png Binary files differindex ed8413846..d5b1bc6bc 100644 --- a/games/minimal/mods/default/textures/default_tool_steelshovel.png +++ b/games/minimal/mods/default/textures/default_tool_steelshovel.png diff --git a/games/minimal/mods/default/textures/default_tool_steelsword.png b/games/minimal/mods/default/textures/default_tool_steelsword.png Binary files differindex a74581238..efc61a0d1 100644 --- a/games/minimal/mods/default/textures/default_tool_steelsword.png +++ b/games/minimal/mods/default/textures/default_tool_steelsword.png diff --git a/games/minimal/mods/default/textures/default_tool_stoneaxe.png b/games/minimal/mods/default/textures/default_tool_stoneaxe.png Binary files differindex 698ac918f..532e16fbc 100644 --- a/games/minimal/mods/default/textures/default_tool_stoneaxe.png +++ b/games/minimal/mods/default/textures/default_tool_stoneaxe.png diff --git a/games/minimal/mods/default/textures/default_tool_stonepick.png b/games/minimal/mods/default/textures/default_tool_stonepick.png Binary files differindex b34de6f32..d9156ee3a 100644 --- a/games/minimal/mods/default/textures/default_tool_stonepick.png +++ b/games/minimal/mods/default/textures/default_tool_stonepick.png diff --git a/games/minimal/mods/default/textures/default_tool_stoneshovel.png b/games/minimal/mods/default/textures/default_tool_stoneshovel.png Binary files differindex ba5243101..7bbd2d407 100644 --- a/games/minimal/mods/default/textures/default_tool_stoneshovel.png +++ b/games/minimal/mods/default/textures/default_tool_stoneshovel.png diff --git a/games/minimal/mods/default/textures/default_tool_stonesword.png b/games/minimal/mods/default/textures/default_tool_stonesword.png Binary files differindex 8f8191f92..533b8734f 100644 --- a/games/minimal/mods/default/textures/default_tool_stonesword.png +++ b/games/minimal/mods/default/textures/default_tool_stonesword.png diff --git a/games/minimal/mods/default/textures/default_tool_woodaxe.png b/games/minimal/mods/default/textures/default_tool_woodaxe.png Binary files differindex 3daa4af72..6e70f4a21 100644 --- a/games/minimal/mods/default/textures/default_tool_woodaxe.png +++ b/games/minimal/mods/default/textures/default_tool_woodaxe.png diff --git a/games/minimal/mods/default/textures/default_tool_woodpick.png b/games/minimal/mods/default/textures/default_tool_woodpick.png Binary files differindex ea728cca3..15c61f408 100644 --- a/games/minimal/mods/default/textures/default_tool_woodpick.png +++ b/games/minimal/mods/default/textures/default_tool_woodpick.png diff --git a/games/minimal/mods/default/textures/default_tool_woodshovel.png b/games/minimal/mods/default/textures/default_tool_woodshovel.png Binary files differindex 649ab4c38..e0b3608db 100644 --- a/games/minimal/mods/default/textures/default_tool_woodshovel.png +++ b/games/minimal/mods/default/textures/default_tool_woodshovel.png diff --git a/games/minimal/mods/default/textures/default_tool_woodsword.png b/games/minimal/mods/default/textures/default_tool_woodsword.png Binary files differindex d6c6be325..8099af139 100644 --- a/games/minimal/mods/default/textures/default_tool_woodsword.png +++ b/games/minimal/mods/default/textures/default_tool_woodsword.png diff --git a/games/minimal/mods/default/textures/default_torch.png b/games/minimal/mods/default/textures/default_torch.png Binary files differindex 7a953c222..21d98bdbb 100644 --- a/games/minimal/mods/default/textures/default_torch.png +++ b/games/minimal/mods/default/textures/default_torch.png diff --git a/games/minimal/mods/default/textures/default_torch_on_ceiling.png b/games/minimal/mods/default/textures/default_torch_on_ceiling.png Binary files differindex 6965d380e..dccd380b2 100644 --- a/games/minimal/mods/default/textures/default_torch_on_ceiling.png +++ b/games/minimal/mods/default/textures/default_torch_on_ceiling.png diff --git a/games/minimal/mods/default/textures/default_torch_on_floor.png b/games/minimal/mods/default/textures/default_torch_on_floor.png Binary files differindex 76d1dd5ac..c22010750 100644 --- a/games/minimal/mods/default/textures/default_torch_on_floor.png +++ b/games/minimal/mods/default/textures/default_torch_on_floor.png diff --git a/games/minimal/mods/default/textures/default_tree_top.png b/games/minimal/mods/default/textures/default_tree_top.png Binary files differindex 2cdd94f80..3e6bd5262 100644 --- a/games/minimal/mods/default/textures/default_tree_top.png +++ b/games/minimal/mods/default/textures/default_tree_top.png diff --git a/games/minimal/mods/default/textures/default_water.png b/games/minimal/mods/default/textures/default_water.png Binary files differindex e5f8cdc25..3e385ae8b 100644 --- a/games/minimal/mods/default/textures/default_water.png +++ b/games/minimal/mods/default/textures/default_water.png diff --git a/games/minimal/mods/default/textures/heart.png b/games/minimal/mods/default/textures/heart.png Binary files differindex 6bc183e04..c25f43b9a 100644 --- a/games/minimal/mods/default/textures/heart.png +++ b/games/minimal/mods/default/textures/heart.png diff --git a/games/minimal/mods/default/textures/player.png b/games/minimal/mods/default/textures/player.png Binary files differindex 90adf9747..cf5d83f10 100644 --- a/games/minimal/mods/default/textures/player.png +++ b/games/minimal/mods/default/textures/player.png diff --git a/games/minimal/mods/default/textures/player_back.png b/games/minimal/mods/default/textures/player_back.png Binary files differindex 530aa7519..d498674eb 100644 --- a/games/minimal/mods/default/textures/player_back.png +++ b/games/minimal/mods/default/textures/player_back.png diff --git a/games/minimal/mods/default/textures/treeprop.png b/games/minimal/mods/default/textures/treeprop.png Binary files differindex 77ea4d6d4..eb8a8e6c4 100644 --- a/games/minimal/mods/default/textures/treeprop.png +++ b/games/minimal/mods/default/textures/treeprop.png diff --git a/games/minimal/mods/default/textures/wieldhand.png b/games/minimal/mods/default/textures/wieldhand.png Binary files differindex c4549e5ed..dbed6ad0c 100644 --- a/games/minimal/mods/default/textures/wieldhand.png +++ b/games/minimal/mods/default/textures/wieldhand.png diff --git a/games/minimal/mods/experimental/textures/experimental_dummyball.png b/games/minimal/mods/experimental/textures/experimental_dummyball.png Binary files differindex 084676552..256414f46 100644 --- a/games/minimal/mods/experimental/textures/experimental_dummyball.png +++ b/games/minimal/mods/experimental/textures/experimental_dummyball.png diff --git a/games/minimal/mods/experimental/textures/experimental_tester_tool_1.png b/games/minimal/mods/experimental/textures/experimental_tester_tool_1.png Binary files differindex 8b5bc0b41..587923c86 100644 --- a/games/minimal/mods/experimental/textures/experimental_tester_tool_1.png +++ b/games/minimal/mods/experimental/textures/experimental_tester_tool_1.png diff --git a/games/minimal/mods/legacy/textures/apple_iron.png b/games/minimal/mods/legacy/textures/apple_iron.png Binary files differindex 2dffdf014..db5945856 100644 --- a/games/minimal/mods/legacy/textures/apple_iron.png +++ b/games/minimal/mods/legacy/textures/apple_iron.png diff --git a/games/minimal/mods/legacy/textures/cooked_rat.png b/games/minimal/mods/legacy/textures/cooked_rat.png Binary files differindex daad3be0d..776dc4ee0 100644 --- a/games/minimal/mods/legacy/textures/cooked_rat.png +++ b/games/minimal/mods/legacy/textures/cooked_rat.png diff --git a/games/minimal/mods/legacy/textures/dungeon_master.png b/games/minimal/mods/legacy/textures/dungeon_master.png Binary files differindex 3457c8228..d52d8ccd7 100644 --- a/games/minimal/mods/legacy/textures/dungeon_master.png +++ b/games/minimal/mods/legacy/textures/dungeon_master.png diff --git a/games/minimal/mods/legacy/textures/fireball.png b/games/minimal/mods/legacy/textures/fireball.png Binary files differindex 523142850..124469ce4 100644 --- a/games/minimal/mods/legacy/textures/fireball.png +++ b/games/minimal/mods/legacy/textures/fireball.png diff --git a/games/minimal/mods/legacy/textures/firefly.png b/games/minimal/mods/legacy/textures/firefly.png Binary files differindex 40df7fa1c..ea95a6a84 100644 --- a/games/minimal/mods/legacy/textures/firefly.png +++ b/games/minimal/mods/legacy/textures/firefly.png diff --git a/games/minimal/mods/legacy/textures/oerkki1.png b/games/minimal/mods/legacy/textures/oerkki1.png Binary files differindex 33cbac9e7..061709c80 100644 --- a/games/minimal/mods/legacy/textures/oerkki1.png +++ b/games/minimal/mods/legacy/textures/oerkki1.png diff --git a/games/minimal/mods/legacy/textures/oerkki1_damaged.png b/games/minimal/mods/legacy/textures/oerkki1_damaged.png Binary files differindex 9b777387c..b2a30337e 100644 --- a/games/minimal/mods/legacy/textures/oerkki1_damaged.png +++ b/games/minimal/mods/legacy/textures/oerkki1_damaged.png diff --git a/games/minimal/mods/legacy/textures/rat.png b/games/minimal/mods/legacy/textures/rat.png Binary files differindex d1a0e2ae2..04cf9b865 100644 --- a/games/minimal/mods/legacy/textures/rat.png +++ b/games/minimal/mods/legacy/textures/rat.png diff --git a/minetest.conf.example b/minetest.conf.example index 1f9780f40..4306740e9 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -8,7 +8,7 @@ # Uncomment settings by removing the preceding #. # # Further documentation: -# http://c55.me/minetest/wiki/doku.php +# http://wiki.minetest.com/ # # NOTE: This file might not be up-to-date, refer to the # defaultsettings.cpp file for an up-to-date list: @@ -93,11 +93,17 @@ #new_style_water = false # Constant volume liquids #liquid_finite = false +# Max liquids processed per step +#liquid_loop_max = 1000 # Update liquids every .. recommend for finite: 0.2 #liquid_update = 1.0 -# When finite liquid: relax flowing blocks to source if level near max and N nearby source blocks, more realistic, but not true constant. values: 0,1,2,3,4 : 0 - disable, 1 - most aggresive +# Relax flowing blocks to source if level near max and N nearby +# source blocks, more realistic, but not true constant. +# values: 0,1,2,3,4 : 0 - disable, 1 - most aggresive +# (for finite liquids) #liquid_relax = 2 # Optimization: faster cave flood (and not true constant) +# (for finite liquids) #liquid_fast_flood = 1 # Underground water and lava springs, its infnity sources if liquid_finite enabled #underground_springs = 1 @@ -254,6 +260,10 @@ #max_block_send_distance = 10 # From how far blocks are generated for clients (value * 16 nodes) #max_block_generate_distance = 6 +# Number of extra blocks that can be loaded by /clearobjects at once +# This is a trade-off between sqlite transaction overhead and +# memory consumption (4096=100MB, as a rule of thumb) +#max_clearobjects_extra_loaded_blocks = 4096 # Interval of sending time of day to clients #time_send_interval = 5 # Length of day/night cycle. 72=20min, 360=4min, 1=24hour, 0=day/night/whatever stays unchanged diff --git a/misc/minetest-icon-24x24.png b/misc/minetest-icon-24x24.png Binary files differindex 4d587c410..334e2f6d6 100644 --- a/misc/minetest-icon-24x24.png +++ b/misc/minetest-icon-24x24.png diff --git a/src/biome.cpp b/src/biome.cpp index b50c562a0..bc84d4bc1 100644 --- a/src/biome.cpp +++ b/src/biome.cpp @@ -168,3 +168,13 @@ Biome *BiomeDefManager::getBiome(float heat, float humidity, s16 y) { return biome_closest ? biome_closest : biomes[0]; } + + +u8 BiomeDefManager::getBiomeIdByName(const char *name) { + for (size_t i = 0; i != biomes.size(); i++) { + if (!strcasecmp(name, biomes[i]->name.c_str())) + return i; + } + + return 0; +} diff --git a/src/biome.h b/src/biome.h index 17703db5a..535dc4989 100644 --- a/src/biome.h +++ b/src/biome.h @@ -84,6 +84,7 @@ public: void addBiome(Biome *b); void resolveNodeNames(INodeDefManager *ndef); + u8 getBiomeIdByName(const char *name); }; #endif diff --git a/src/client.cpp b/src/client.cpp index 6b1789fe0..5f53e14f7 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -2680,6 +2680,13 @@ u16 Client::getHP() return player->hp; } +u16 Client::getBreath() +{ + Player *player = m_env.getLocalPlayer(); + assert(player != NULL); + return player->breath; +} + bool Client::getChatMessage(std::wstring &message) { if(m_chat_queue.size() == 0) diff --git a/src/client.h b/src/client.h index f0cc55868..1d231a5a3 100644 --- a/src/client.h +++ b/src/client.h @@ -349,6 +349,7 @@ public: void setCrack(int level, v3s16 pos); u16 getHP(); + u16 getBreath(); bool checkPrivilege(const std::string &priv) { return (m_privileges.count(priv) != 0); } diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index f270a47aa..ffaa7a3c7 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -175,6 +175,7 @@ void set_default_settings(Settings *settings) settings->setDefault("max_simultaneous_block_sends_server_total", "20"); settings->setDefault("max_block_send_distance", "9"); settings->setDefault("max_block_generate_distance", "7"); + settings->setDefault("max_clearobjects_extra_loaded_blocks", "4096"); settings->setDefault("time_send_interval", "5"); settings->setDefault("time_speed", "72"); settings->setDefault("server_unload_unused_data_timeout", "29"); @@ -208,6 +209,7 @@ void set_default_settings(Settings *settings) //liquid stuff settings->setDefault("liquid_finite", "false"); + settings->setDefault("liquid_loop_max", "1000"); settings->setDefault("liquid_update", "1.0"); settings->setDefault("liquid_relax", "2"); settings->setDefault("liquid_fast_flood", "1"); @@ -238,7 +240,7 @@ void set_default_settings(Settings *settings) settings->setDefault("mgv7_np_terrain_mod", "0, 1, (350, 350, 350), 85039, 5, 0.6"); settings->setDefault("mgv7_np_terrain_persist", "0, 1, (500, 500, 500), 539, 3, 0.6"); settings->setDefault("mgv7_np_height_select", "0.5, 0.5, (250, 250, 250), 4213, 5, 0.69"); - settings->setDefault("mgv7_np_ridge", "0.5, 1, (100, 100, 100), 6467, 4, 0.75"); + settings->setDefault("mgv7_np_ridge", "0, 1, (100, 100, 100), 6467, 4, 0.75"); settings->setDefault("mgindev_np_terrain_base", "-4, 20, (250, 250, 250), 82341, 5, 0.6, 10, 10"); settings->setDefault("mgindev_np_terrain_higher", "20, 16, (500, 500, 500), 85039, 5, 0.6, 10, 10"); diff --git a/src/emerge.cpp b/src/emerge.cpp index fd6c0e91f..9edc42b7b 100644 --- a/src/emerge.cpp +++ b/src/emerge.cpp @@ -101,6 +101,10 @@ EmergeManager::~EmergeManager() { for (unsigned int i = 0; i < ores.size(); i++) delete ores[i]; ores.clear(); + + for (unsigned int i = 0; i < decorations.size(); i++) + delete decorations[i]; + decorations.clear(); for (std::map<std::string, MapgenFactory *>::iterator iter = mglist.begin(); iter != mglist.end(); iter ++) { @@ -119,9 +123,13 @@ void EmergeManager::initMapgens(MapgenParams *mgparams) { return; biomedef->resolveNodeNames(ndef); + for (size_t i = 0; i != ores.size(); i++) + ores[i]->resolveNodeNames(ndef); + for (size_t i = 0; i != decorations.size(); i++) + decorations[i]->resolveNodeNames(ndef); this->params = mgparams; - for (unsigned int i = 0; i != emergethread.size(); i++) { + for (size_t i = 0; i != emergethread.size(); i++) { mg = createMapgen(params->mg_name, 0, params); if (!mg) { infostream << "EmergeManager: falling back to mapgen v6" << std::endl; diff --git a/src/emerge.h b/src/emerge.h index b42e82d38..084956932 100644 --- a/src/emerge.h +++ b/src/emerge.h @@ -87,6 +87,7 @@ public: //Mapgen-related structures BiomeDefManager *biomedef; std::vector<Ore *> ores; + std::vector<Decoration *> decorations; EmergeManager(IGameDef *gamedef); ~EmergeManager(); diff --git a/src/environment.cpp b/src/environment.cpp index 83ae59014..99da5190c 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -40,6 +40,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef SERVER #include "clientmap.h" #include "localplayer.h" +#include "event.h" #endif #include "daynightratio.h" #include "map.h" @@ -945,6 +946,16 @@ void ServerEnvironment::clearAllObjects() m_active_objects.erase(*i); } + // Get list of loaded blocks + std::list<v3s16> loaded_blocks; + infostream<<"ServerEnvironment::clearAllObjects(): " + <<"Listing all loaded blocks"<<std::endl; + m_map->listAllLoadedBlocks(loaded_blocks); + infostream<<"ServerEnvironment::clearAllObjects(): " + <<"Done listing all loaded blocks: " + <<loaded_blocks.size()<<std::endl; + + // Get list of loadable blocks std::list<v3s16> loadable_blocks; infostream<<"ServerEnvironment::clearAllObjects(): " <<"Listing all loadable blocks"<<std::endl; @@ -953,6 +964,20 @@ void ServerEnvironment::clearAllObjects() <<"Done listing all loadable blocks: " <<loadable_blocks.size() <<", now clearing"<<std::endl; + + // Grab a reference on each loaded block to avoid unloading it + for(std::list<v3s16>::iterator i = loaded_blocks.begin(); + i != loaded_blocks.end(); ++i) + { + v3s16 p = *i; + MapBlock *block = m_map->getBlockNoCreateNoEx(p); + assert(block); + block->refGrab(); + } + + // Remove objects in all loadable blocks + u32 unload_interval = g_settings->getS32("max_clearobjects_extra_loaded_blocks"); + unload_interval = MYMAX(unload_interval, 1); u32 report_interval = loadable_blocks.size() / 10; u32 num_blocks_checked = 0; u32 num_blocks_cleared = 0; @@ -987,7 +1012,22 @@ void ServerEnvironment::clearAllObjects() <<" in "<<num_blocks_cleared<<" blocks (" <<percent<<"%)"<<std::endl; } + if(num_blocks_checked % unload_interval == 0){ + m_map->unloadUnreferencedBlocks(); + } } + m_map->unloadUnreferencedBlocks(); + + // Drop references that were added above + for(std::list<v3s16>::iterator i = loaded_blocks.begin(); + i != loaded_blocks.end(); ++i) + { + v3s16 p = *i; + MapBlock *block = m_map->getBlockNoCreateNoEx(p); + assert(block); + block->refDrop(); + } + infostream<<"ServerEnvironment::clearAllObjects(): " <<"Finished: Cleared "<<num_objs_cleared<<" objects" <<" in "<<num_blocks_cleared<<" blocks"<<std::endl; @@ -2151,8 +2191,11 @@ void ClientEnvironment::step(float dtime) { f32 damage_f = (speed - tolerance)/BS * post_factor; u16 damage = (u16)(damage_f+0.5); - if(damage != 0) + if(damage != 0){ damageLocalPlayer(damage, true); + MtEvent *e = new SimpleTriggerEvent("PlayerFallingDamage"); + m_gamedef->event()->put(e); + } } } @@ -2184,7 +2227,45 @@ void ClientEnvironment::step(float dtime) damageLocalPlayer(damage_per_second, true); } } - + + /* + Drowning + */ + if(m_drowning_interval.step(dtime, 2.0)) + { + v3f pf = lplayer->getPosition(); + + // head + v3s16 p = floatToInt(pf + v3f(0, BS*1.6, 0), BS); + MapNode n = m_map->getNodeNoEx(p); + ContentFeatures c = m_gamedef->ndef()->get(n); + + if(c.isLiquid() && c.drowning){ + if(lplayer->breath > 10) + lplayer->breath = 11; + if(lplayer->breath > 0) + lplayer->breath -= 1; + } + + if(lplayer->breath == 0){ + damageLocalPlayer(1, true); + } + } + if(m_breathing_interval.step(dtime, 0.5)) + { + v3f pf = lplayer->getPosition(); + + // head + v3s16 p = floatToInt(pf + v3f(0, BS*1.6, 0), BS); + MapNode n = m_map->getNodeNoEx(p); + ContentFeatures c = m_gamedef->ndef()->get(n); + + if(!c.isLiquid() || !c.drowning){ + if(lplayer->breath <= 10) + lplayer->breath += 1; + } + } + /* Stuff that can be done in an arbitarily large dtime */ @@ -2221,6 +2302,7 @@ void ClientEnvironment::step(float dtime) Step active objects and update lighting of them */ + g_profiler->avg("CEnv: num of objects", m_active_objects.size()); bool update_lighting = m_active_object_light_update_interval.step(dtime, 0.21); for(std::map<u16, ClientActiveObject*>::iterator i = m_active_objects.begin(); @@ -2250,6 +2332,7 @@ void ClientEnvironment::step(float dtime) /* Step and handle simple objects */ + g_profiler->avg("CEnv: num of simple objects", m_simple_objects.size()); for(std::list<ClientSimpleObject*>::iterator i = m_simple_objects.begin(); i != m_simple_objects.end();) { diff --git a/src/environment.h b/src/environment.h index a62173a11..ac479999c 100644 --- a/src/environment.h +++ b/src/environment.h @@ -494,6 +494,8 @@ private: Queue<ClientEnvEvent> m_client_event_queue; IntervalLimiter m_active_object_light_update_interval; IntervalLimiter m_lava_hurt_interval; + IntervalLimiter m_drowning_interval; + IntervalLimiter m_breathing_interval; std::list<std::string> m_player_names; }; diff --git a/src/game.cpp b/src/game.cpp index 22bd8c429..833117959 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -729,6 +729,18 @@ public: sm->m_sound->playSound(sm->m_ndef->get(nde->n).sound_dug, false); } + static void playerDamage(MtEvent *e, void *data) + { + SoundMaker *sm = (SoundMaker*)data; + sm->m_sound->playSound(SimpleSoundSpec("player_damage", 0.5), false); + } + + static void playerFallingDamage(MtEvent *e, void *data) + { + SoundMaker *sm = (SoundMaker*)data; + sm->m_sound->playSound(SimpleSoundSpec("player_falling_damage", 0.5), false); + } + void registerReceiver(MtEventManager *mgr) { mgr->reg("ViewBobbingStep", SoundMaker::viewBobbingStep, this); @@ -737,6 +749,8 @@ public: mgr->reg("CameraPunchLeft", SoundMaker::cameraPunchLeft, this); mgr->reg("CameraPunchRight", SoundMaker::cameraPunchRight, this); mgr->reg("NodeDug", SoundMaker::nodeDug, this); + mgr->reg("PlayerDamage", SoundMaker::playerDamage, this); + mgr->reg("PlayerFallingDamage", SoundMaker::playerFallingDamage, this); } void step(float dtime) @@ -820,7 +834,7 @@ public: } }; -void nodePlacementPrediction(Client &client, +bool nodePlacementPrediction(Client &client, const ItemDefinition &playeritem_def, v3s16 nodepos, v3s16 neighbourpos) { @@ -840,7 +854,7 @@ void nodePlacementPrediction(Client &client, if(nodedef->get(n_under).buildable_to) p = nodepos; else if (!nodedef->get(map.getNode(p)).buildable_to) - return; + return false; }catch(InvalidPositionException &e){} // Find id of predicted node content_t id; @@ -850,7 +864,7 @@ void nodePlacementPrediction(Client &client, <<playeritem_def.name<<" (places " <<prediction <<") - Name not known"<<std::endl; - return; + return false; } // Predict param2 for facedir and wallmounted nodes u8 param2 = 0; @@ -889,13 +903,14 @@ void nodePlacementPrediction(Client &client, else pp = p + v3s16(0,-1,0); if(!nodedef->get(map.getNode(pp)).walkable) - return; + return false; } // Add node to client map MapNode n(id, 0, param2); try{ // This triggers the required mesh update too client.addNode(p, n); + return true; }catch(InvalidPositionException &e){ errorstream<<"Node placement prediction failed for " <<playeritem_def.name<<" (places " @@ -903,6 +918,7 @@ void nodePlacementPrediction(Client &client, <<") - Position not loaded"<<std::endl; } } + return false; } @@ -1366,6 +1382,7 @@ void the_game( false, false); guitext_profiler->setBackgroundColor(video::SColor(120,0,0,0)); guitext_profiler->setVisible(false); + guitext_profiler->setWordWrap(true); /* Some statistics are collected in these @@ -1684,6 +1701,10 @@ void the_game( { input->clear(); } + if (!guienv->hasFocus(gui_chat_console) && gui_chat_console->isOpen()) + { + gui_chat_console->closeConsoleAtOnce(); + } // Input handler step() (used by the random input generator) input->step(dtime); @@ -2198,6 +2219,9 @@ void the_game( player->hurt_tilt_timer = 1.5; player->hurt_tilt_strength = event.player_damage.amount/2; player->hurt_tilt_strength = rangelim(player->hurt_tilt_strength, 2.0, 10.0); + + MtEvent *e = new SimpleTriggerEvent("PlayerDamage"); + gamedef->event()->put(e); } else if(event.type == CE_PLAYER_FORCE_MOVE) { @@ -2567,7 +2591,8 @@ void the_game( Handle digging */ - if(nodig_delay_timer <= 0.0 && input->getLeftState()) + if(nodig_delay_timer <= 0.0 && input->getLeftState() + && client.checkPrivilege("interact")) { if(!digging) { @@ -2684,13 +2709,20 @@ void the_game( gamedef->event()->put(e); } - dig_time += dtime; + if(dig_time_complete < 100000.0) + dig_time += dtime; + else { + dig_time = 0; + client.setCrack(-1, nodepos); + } camera.setDigging(0); // left click animation } - if(input->getRightClicked() || - repeat_rightclick_timer >= g_settings->getFloat("repeat_rightclick_time")) + if((input->getRightClicked() || + repeat_rightclick_timer >= + g_settings->getFloat("repeat_rightclick_time")) && + client.checkPrivilege("interact")) { repeat_rightclick_timer = 0; infostream<<"Ground right-clicked"<<std::endl; @@ -2744,13 +2776,17 @@ void the_game( // If the wielded item has node placement prediction, // make that happen - nodePlacementPrediction(client, + bool placed = nodePlacementPrediction(client, playeritem_def, nodepos, neighbourpos); // Read the sound - soundmaker.m_player_rightpunch_sound = - playeritem_def.sound_place; + if(placed) + soundmaker.m_player_rightpunch_sound = + playeritem_def.sound_place; + else + soundmaker.m_player_rightpunch_sound = + SimpleSoundSpec(); } } } @@ -3283,7 +3319,7 @@ void the_game( if (show_hud) { hud.drawHotbar(v2s32(displaycenter.X, screensize.Y), - client.getHP(), client.getPlayerItem()); + client.getHP(), client.getPlayerItem(), client.getBreath()); } /* diff --git a/src/guiChatConsole.cpp b/src/guiChatConsole.cpp index 3dfd0090a..daec18efc 100644 --- a/src/guiChatConsole.cpp +++ b/src/guiChatConsole.cpp @@ -134,6 +134,11 @@ void GUIChatConsole::openConsole(f32 height) reformatConsole(); } +bool GUIChatConsole::isOpen() const +{ + return m_open; +} + bool GUIChatConsole::isOpenInhibited() const { return m_open_inhibited > 0; @@ -545,7 +550,13 @@ bool GUIChatConsole::OnEvent(const SEvent& event) } else if(event.KeyInput.Char != 0 && !event.KeyInput.Control) { - m_chat_backend->getPrompt().input(event.KeyInput.Char); + #if (defined(linux) || defined(__linux)) + wchar_t wc = L'_'; + mbtowc( &wc, (char *) &event.KeyInput.Char, sizeof(event.KeyInput.Char) ); + m_chat_backend->getPrompt().input(wc); + #else + m_chat_backend->getPrompt().input(event.KeyInput.Char); + #endif return true; } } diff --git a/src/guiChatConsole.h b/src/guiChatConsole.h index c896aae28..5991157b2 100644 --- a/src/guiChatConsole.h +++ b/src/guiChatConsole.h @@ -39,6 +39,9 @@ public: // This doesn't open immediately but initiates an animation. // You should call isOpenInhibited() before this. void openConsole(f32 height); + + bool isOpen() const; + // Check if the console should not be opened at the moment // This is to avoid reopening the console immediately after closing bool isOpenInhibited() const; diff --git a/src/guiFormSpecMenu.cpp b/src/guiFormSpecMenu.cpp index 3e0d7fd46..c1b256f08 100644 --- a/src/guiFormSpecMenu.cpp +++ b/src/guiFormSpecMenu.cpp @@ -698,7 +698,7 @@ void GUIFormSpecMenu::drawList(const ListDrawSpec &s, int phase) bool selected = m_selected_item && m_invmgr->getInventory(m_selected_item->inventoryloc) == inv && m_selected_item->listname == s.listname - && m_selected_item->i == i; + && m_selected_item->i == item_i; bool hovering = rect.isPointInside(m_pointer); if(phase == 0) @@ -912,11 +912,20 @@ void GUIFormSpecMenu::drawMenu() void GUIFormSpecMenu::updateSelectedItem() { + // If the selected stack has become empty for some reason, deselect it. + // If the selected stack has become inaccessible, deselect it. + // If the selected stack has become smaller, adjust m_selected_amount. + ItemStack selected = verifySelectedItem(); + // WARNING: BLACK MAGIC // See if there is a stack suited for our current guess. // If such stack does not exist, clear the guess. - if(m_selected_content_guess.name != "") - { + if(m_selected_content_guess.name != "" && + selected.name == m_selected_content_guess.name && + selected.count == m_selected_content_guess.count){ + // Selected item fits the guess. Skip the black magic. + } + else if(m_selected_content_guess.name != ""){ bool found = false; for(u32 i=0; i<m_inventorylists.size() && !found; i++){ const ListDrawSpec &s = m_inventorylists[i]; @@ -934,23 +943,12 @@ void GUIFormSpecMenu::updateSelectedItem() if(stack.name == m_selected_content_guess.name && stack.count == m_selected_content_guess.count){ found = true; - if(m_selected_item){ - // If guessed stack is already selected, all is fine - if(m_selected_item->inventoryloc == s.inventoryloc && - m_selected_item->listname == s.listname && - m_selected_item->i == (s32)item_i && - m_selected_amount == stack.count){ - break; - } - delete m_selected_item; - m_selected_item = NULL; - } infostream<<"Client: Changing selected content guess to " <<s.inventoryloc.dump()<<" "<<s.listname <<" "<<item_i<<std::endl; + delete m_selected_item; m_selected_item = new ItemSpec(s.inventoryloc, s.listname, item_i); m_selected_amount = stack.count; - break; } } } @@ -960,35 +958,6 @@ void GUIFormSpecMenu::updateSelectedItem() m_selected_content_guess.name = ""; } } - // If the selected stack has become empty for some reason, deselect it. - // If the selected stack has become smaller, adjust m_selected_amount. - if(m_selected_item) - { - bool selection_valid = false; - if(m_selected_item->isValid()) - { - Inventory *inv = m_invmgr->getInventory(m_selected_item->inventoryloc); - if(inv) - { - InventoryList *list = inv->getList(m_selected_item->listname); - if(list && (u32) m_selected_item->i < list->getSize()) - { - ItemStack stack = list->getItem(m_selected_item->i); - if(m_selected_amount > stack.count) - m_selected_amount = stack.count; - if(!stack.empty()) - selection_valid = true; - } - } - } - if(!selection_valid) - { - delete m_selected_item; - m_selected_item = NULL; - m_selected_amount = 0; - m_selected_dragging = false; - } - } // If craftresult is nonempty and nothing else is selected, select it now. if(!m_selected_item) @@ -1017,12 +986,43 @@ void GUIFormSpecMenu::updateSelectedItem() // If craftresult is selected, keep the whole stack selected if(m_selected_item && m_selected_item->listname == "craftresult") { - Inventory *inv = m_invmgr->getInventory(m_selected_item->inventoryloc); - assert(inv); - InventoryList *list = inv->getList(m_selected_item->listname); - assert(list); - m_selected_amount = list->getItem(m_selected_item->i).count; + m_selected_amount = verifySelectedItem().count; + } +} + +ItemStack GUIFormSpecMenu::verifySelectedItem() +{ + // If the selected stack has become empty for some reason, deselect it. + // If the selected stack has become inaccessible, deselect it. + // If the selected stack has become smaller, adjust m_selected_amount. + // Return the selected stack. + + if(m_selected_item) + { + if(m_selected_item->isValid()) + { + Inventory *inv = m_invmgr->getInventory(m_selected_item->inventoryloc); + if(inv) + { + InventoryList *list = inv->getList(m_selected_item->listname); + if(list && (u32) m_selected_item->i < list->getSize()) + { + ItemStack stack = list->getItem(m_selected_item->i); + if(m_selected_amount > stack.count) + m_selected_amount = stack.count; + if(!stack.empty()) + return stack; + } + } + } + + // selection was not valid + delete m_selected_item; + m_selected_item = NULL; + m_selected_amount = 0; + m_selected_dragging = false; } + return ItemStack(); } void GUIFormSpecMenu::acceptInput() diff --git a/src/guiFormSpecMenu.h b/src/guiFormSpecMenu.h index 17b202b18..ae985adde 100644 --- a/src/guiFormSpecMenu.h +++ b/src/guiFormSpecMenu.h @@ -186,6 +186,7 @@ public: void drawSelectedItem(); void drawMenu(); void updateSelectedItem(); + ItemStack verifySelectedItem(); void acceptInput(); bool OnEvent(const SEvent& event); diff --git a/src/hud.cpp b/src/hud.cpp index a3ae38bcb..9404ed997 100644 --- a/src/hud.cpp +++ b/src/hud.cpp @@ -278,7 +278,7 @@ void Hud::drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture, s } -void Hud::drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem) { +void Hud::drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem, s32 breath) { InventoryList *mainlist = inventory->getList("main"); if (mainlist == NULL) { errorstream << "draw_hotbar(): mainlist == NULL" << std::endl; @@ -295,6 +295,9 @@ void Hud::drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem) { if (player->hud_flags & HUD_FLAG_HEALTHBAR_VISIBLE) drawStatbar(pos - v2s32(0, 4), HUD_CORNER_LOWER, HUD_DIR_LEFT_RIGHT, "heart.png", halfheartcount, v2s32(0, 0)); + if (player->hud_flags & HUD_FLAG_BREATHBAR_VISIBLE && breath <= 10) + drawStatbar(pos - v2s32(-180, 4), HUD_CORNER_LOWER, HUD_DIR_LEFT_RIGHT, + "bubble.png", breath*2, v2s32(0, 0)); } @@ -35,6 +35,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #define HUD_FLAG_HEALTHBAR_VISIBLE (1 << 1) #define HUD_FLAG_CROSSHAIR_VISIBLE (1 << 2) #define HUD_FLAG_WIELDITEM_VISIBLE (1 << 3) +#define HUD_FLAG_BREATHBAR_VISIBLE (1 << 4) #define HUD_PARAM_HOTBAR_ITEMCOUNT 1 @@ -122,7 +123,7 @@ public: void drawStatbar(v2s32 pos, u16 corner, u16 drawdir, std::string texture, s32 count, v2s32 offset); - void drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem); + void drawHotbar(v2s32 centerlowerpos, s32 halfheartcount, u16 playeritem, s32 breath); void resizeHotbar(); void drawCrosshair(); diff --git a/src/map.cpp b/src/map.cpp index 43502253b..001ae1609 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1510,6 +1510,11 @@ void Map::timerUpdate(float dtime, float unload_timeout, } } +void Map::unloadUnreferencedBlocks(std::list<v3s16> *unloaded_blocks) +{ + timerUpdate(0.0, -1.0, unloaded_blocks); +} + void Map::deleteSectors(std::list<v2s16> &list) { for(std::list<v2s16>::iterator j = list.begin(); @@ -1646,10 +1651,12 @@ void Map::transformLiquidsFinite(std::map<v3s16, MapBlock*> & modified_blocks) // List of MapBlocks that will require a lighting update (due to lava) std::map<v3s16, MapBlock*> lighting_modified_blocks; + u16 loop_max = g_settings->getU16("liquid_loop_max"); + while (m_transforming_liquid.size() > 0) { // This should be done here so that it is done when continue is used - if (loopcount >= initial_size || loopcount >= 1000) + if (loopcount >= initial_size || loopcount >= loop_max) break; loopcount++; /* @@ -1988,10 +1995,12 @@ void Map::transformLiquids(std::map<v3s16, MapBlock*> & modified_blocks) // List of MapBlocks that will require a lighting update (due to lava) std::map<v3s16, MapBlock*> lighting_modified_blocks; + u16 loop_max = g_settings->getU16("liquid_loop_max"); + while(m_transforming_liquid.size() != 0) { // This should be done here so that it is done when continue is used - if(loopcount >= initial_size || loopcount >= 10000) + if(loopcount >= initial_size || loopcount >= loop_max) break; loopcount++; @@ -3409,6 +3418,26 @@ void ServerMap::listAllLoadableBlocks(std::list<v3s16> &dst) } } +void ServerMap::listAllLoadedBlocks(std::list<v3s16> &dst) +{ + for(std::map<v2s16, MapSector*>::iterator si = m_sectors.begin(); + si != m_sectors.end(); ++si) + { + MapSector *sector = si->second; + + std::list<MapBlock*> blocks; + sector->getBlocks(blocks); + + for(std::list<MapBlock*>::iterator i = blocks.begin(); + i != blocks.end(); ++i) + { + MapBlock *block = (*i); + v3s16 p = block->getPos(); + dst.push_back(p); + } + } +} + void ServerMap::saveMapMeta() { DSTACK(__FUNCTION_NAME); @@ -279,6 +279,12 @@ public: void timerUpdate(float dtime, float unload_timeout, std::list<v3s16> *unloaded_blocks=NULL); + /* + Unloads all blocks with a zero refCount(). + Saves modified blocks before unloading on MAPTYPE_SERVER. + */ + void unloadUnreferencedBlocks(std::list<v3s16> *unloaded_blocks=NULL); + // Deletes sectors and their blocks from memory // Takes cache into account // If deleted sector is in sector cache, clears cache @@ -433,8 +439,8 @@ public: void endSave(); void save(ModifiedState save_level); - //void loadAll(); void listAllLoadableBlocks(std::list<v3s16> &dst); + void listAllLoadedBlocks(std::list<v3s16> &dst); // Saves map seed and possibly other stuff void saveMapMeta(); void loadMapMeta(); diff --git a/src/mapblock_mesh.cpp b/src/mapblock_mesh.cpp index 0f83e863c..be88b1973 100644 --- a/src/mapblock_mesh.cpp +++ b/src/mapblock_mesh.cpp @@ -717,8 +717,7 @@ TileSpec getNodeTile(MapNode mn, v3s16 p, v3s16 dir, MeshMakeData *data) u16 tile_index=facedir*16 + dir_i; TileSpec spec = getNodeTileN(mn, p, dir_to_tile[tile_index], data); spec.rotation=dir_to_tile[tile_index + 1]; - std::string name = data->m_gamedef->tsrc()->getTextureName(spec.texture.id); - spec.texture = data->m_gamedef->tsrc()->getTexture(name); + spec.texture = data->m_gamedef->tsrc()->getTexture(spec.texture.id); return spec; } @@ -1200,7 +1199,6 @@ MapBlockMesh::MapBlockMesh(MeshMakeData *data): */ translateMesh(m_mesh, intToFloat(data->m_blockpos * MAP_BLOCKSIZE, BS)); - m_mesh->recalculateBoundingBox(); // translateMesh already does this if(m_mesh) { diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 835c14be1..72757f4fa 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -87,7 +87,7 @@ void Ore::resolveNodeNames(INodeDefManager *ndef) { wherein = CONTENT_AIR; } } - + if (wherein == CONTENT_IGNORE) { wherein = ndef->getId(wherein_name); if (wherein == CONTENT_IGNORE) { @@ -109,10 +109,7 @@ void Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) { if (!in_range) return; - resolveNodeNames(mg->ndef); - int ymin, ymax; - if (in_range & ORE_RANGE_MIRROR) { ymin = MYMAX(nmin.Y, -height_max); ymax = MYMIN(nmax.Y, -height_min); @@ -122,7 +119,7 @@ void Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) { } if (clust_size >= ymax - ymin + 1) return; - + nmin.Y = ymin; nmax.Y = ymax; generate(mg->vm, mg->seed, blockseed, nmin, nmax); @@ -130,7 +127,7 @@ void Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) { void OreScatter::generate(ManualMapVoxelManipulator *vm, int seed, - u32 blockseed, v3s16 nmin, v3s16 nmax) { + u32 blockseed, v3s16 nmin, v3s16 nmax) { PseudoRandom pr(blockseed); MapNode n_ore(ore, 0, ore_param2); @@ -145,16 +142,16 @@ void OreScatter::generate(ManualMapVoxelManipulator *vm, int seed, int x0 = pr.range(nmin.X, nmax.X - csize + 1); int y0 = pr.range(nmin.Y, nmax.Y - csize + 1); int z0 = pr.range(nmin.Z, nmax.Z - csize + 1); - + if (np && (NoisePerlin3D(np, x0, y0, z0, seed) < nthresh)) continue; - + for (int z1 = 0; z1 != csize; z1++) for (int y1 = 0; y1 != csize; y1++) for (int x1 = 0; x1 != csize; x1++) { if (pr.range(1, orechance) != 1) continue; - + u32 i = vm->m_area.index(x0 + x1, y0 + y1, z0 + z1); if (vm->m_data[i].getContent() == wherein) vm->m_data[i] = n_ore; @@ -167,10 +164,10 @@ void OreSheet::generate(ManualMapVoxelManipulator *vm, int seed, u32 blockseed, v3s16 nmin, v3s16 nmax) { PseudoRandom pr(blockseed + 4234); MapNode n_ore(ore, 0, ore_param2); - + int max_height = clust_size; int y_start = pr.range(nmin.Y, nmax.Y - max_height); - + if (!noise) { int sx = nmax.X - nmin.X + 1; int sz = nmax.Z - nmin.Z + 1; @@ -178,14 +175,14 @@ void OreSheet::generate(ManualMapVoxelManipulator *vm, int seed, } noise->seed = seed + y_start; noise->perlinMap2D(nmin.X, nmin.Z); - + int index = 0; for (int z = nmin.Z; z <= nmax.Z; z++) for (int x = nmin.X; x <= nmax.X; x++) { float noiseval = noise->result[index++]; if (noiseval < nthresh) continue; - + int height = max_height * (1. / pr.range(1, 3)); int y0 = y_start + np->scale * noiseval; //pr.range(1, 3) - 1; int y1 = y0 + height; @@ -193,7 +190,7 @@ void OreSheet::generate(ManualMapVoxelManipulator *vm, int seed, u32 i = vm->m_area.index(x, y, z); if (!vm->m_area.contains(i)) continue; - + if (vm->m_data[i].getContent() == wherein) vm->m_data[i] = n_ore; } @@ -201,6 +198,325 @@ void OreSheet::generate(ManualMapVoxelManipulator *vm, int seed, } +Decoration *createDecoration(DecorationType type) { + switch (type) { + case DECO_SIMPLE: + return new DecoSimple; + //case DECO_SCHEMATIC: + // return new DecoSchematic; + //case DECO_LSYSTEM: + // return new DecoLSystem; + default: + return NULL; + } +} + + +Decoration::~Decoration() { + delete np; +} + + +void Decoration::resolveNodeNames(INodeDefManager *ndef) { + if (c_place_on == CONTENT_IGNORE) + c_place_on = ndef->getId(place_on_name); +} + + +void Decoration::placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) { + PseudoRandom ps(blockseed + 53); + int carea_size = nmax.X - nmin.X + 1; + + // Divide area into parts + if (carea_size % sidelen) { + errorstream << "Decoration::placeDeco: chunk size is not divisible by " + "sidelen; setting sidelen to " << carea_size << std::endl; + sidelen = carea_size; + } + + s16 divlen = carea_size / sidelen; + int area = sidelen * sidelen; + + for (s16 z0 = 0; z0 < divlen; z0++) + for (s16 x0 = 0; x0 < divlen; x0++) { + v2s16 p2d_center( // Center position of part of division + nmin.X + sidelen / 2 + sidelen * x0, + nmin.Z + sidelen / 2 + sidelen * z0 + ); + v2s16 p2d_min( // Minimum edge of part of division + nmin.X + sidelen * x0, + nmin.Z + sidelen * z0 + ); + v2s16 p2d_max( // Maximum edge of part of division + nmin.X + sidelen + sidelen * x0 - 1, + nmin.Z + sidelen + sidelen * z0 - 1 + ); + + // Amount of decorations + float nval = np ? + NoisePerlin2D(np, p2d_center.X, p2d_center.Y, mapseed) : + fill_ratio; + u32 deco_count = area * MYMAX(nval, 0.f); + + for (u32 i = 0; i < deco_count; i++) { + s16 x = ps.range(p2d_min.X, p2d_max.X); + s16 z = ps.range(p2d_min.Y, p2d_max.Y); + + int mapindex = carea_size * (z - nmin.Z) + (x - nmin.X); + + s16 y = mg->heightmap ? + mg->heightmap[mapindex] : + mg->findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y); + + if (y < nmin.Y || y > nmax.Y) + continue; + + int height = getHeight(); + int max_y = nmax.Y + MAP_BLOCKSIZE; + if (y + 1 + height > max_y) { + continue; +#if 0 + printf("Decoration at (%d %d %d) cut off\n", x, y, z); + //add to queue + JMutexAutoLock cutofflock(cutoff_mutex); + cutoffs.push_back(CutoffData(x, y, z, height)); +#endif + } + + if (mg->biomemap) { + std::set<u8>::iterator iter; + + if (biomes.size()) { + iter = biomes.find(mg->biomemap[mapindex]); + if (iter == biomes.end()) + continue; + } + } + + generate(mg, &ps, max_y, 0, v3s16(x, y, z)); + } + } +} + + +#if 0 +void Decoration::placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) { + PseudoRandom pr(blockseed + 53); + std::vector<CutoffData> handled_cutoffs; + + // Copy over the cutoffs we're interested in so we don't needlessly hold a lock + { + JMutexAutoLock cutofflock(cutoff_mutex); + for (std::list<CutoffData>::iterator i = cutoffs.begin(); + i != cutoffs.end(); ++i) { + CutoffData cutoff = *i; + v3s16 p = cutoff.p; + s16 height = cutoff.height; + if (p.X < nmin.X || p.X > nmax.X || + p.Z < nmin.Z || p.Z > nmax.Z) + continue; + if (p.Y + height < nmin.Y || p.Y > nmax.Y) + continue; + + handled_cutoffs.push_back(cutoff); + } + } + + // Generate the cutoffs + for (size_t i = 0; i != handled_cutoffs.size(); i++) { + v3s16 p = handled_cutoffs[i].p; + s16 height = handled_cutoffs[i].height; + + if (p.Y + height > nmax.Y) { + //printf("Decoration at (%d %d %d) cut off again!\n", p.X, p.Y, p.Z); + cuttoffs.push_back(v3s16(p.X, p.Y, p.Z)); + } + + generate(mg, &pr, nmax.Y, nmin.Y - p.Y, v3s16(p.X, nmin.Y, p.Z)); + } + + // Remove cutoffs that were handled from the cutoff list + { + JMutexAutoLock cutofflock(cutoff_mutex); + for (std::list<CutoffData>::iterator i = cutoffs.begin(); + i != cutoffs.end(); ++i) { + + for (size_t j = 0; j != handled_cutoffs.size(); j++) { + CutoffData coff = *i; + if (coff.p == handled_cutoffs[j].p) + i = cutoffs.erase(i); + } + } + } +} +#endif + + +void DecoSimple::resolveNodeNames(INodeDefManager *ndef) { + Decoration::resolveNodeNames(ndef); + + if (c_deco == CONTENT_IGNORE) { + c_deco = ndef->getId(deco_name); + if (c_deco == CONTENT_IGNORE) { + errorstream << "DecoSimple::resolveNodeNames: decoration node '" + << deco_name << "' not defined"; + c_deco = CONTENT_AIR; + } + } + if (c_spawnby == CONTENT_IGNORE) { + c_spawnby = ndef->getId(spawnby_name); + if (c_spawnby == CONTENT_IGNORE) { + errorstream << "DecoSimple::resolveNodeNames: spawnby node '" + << deco_name << "' not defined"; + nspawnby = -1; + c_spawnby = CONTENT_AIR; + } + } + + if (c_decolist.size()) + return; + + for (size_t i = 0; i != decolist_names.size(); i++) { + content_t c = ndef->getId(decolist_names[i]); + if (c == CONTENT_IGNORE) { + errorstream << "DecoSimple::resolveNodeNames: decolist node '" + << decolist_names[i] << "' not defined"; + c = CONTENT_AIR; + } + c_decolist.push_back(c); + } +} + + +void DecoSimple::generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, s16 start_y, v3s16 p) { + ManualMapVoxelManipulator *vm = mg->vm; + + u32 vi = vm->m_area.index(p); + if (vm->m_data[vi].getContent() != c_place_on && + c_place_on != CONTENT_IGNORE) + return; + + if (nspawnby != -1) { + int nneighs = 0; + v3s16 dirs[8] = { // a Moore neighborhood + v3s16( 0, 0, 1), + v3s16( 0, 0, -1), + v3s16( 1, 0, 0), + v3s16(-1, 0, 0), + v3s16( 1, 0, 1), + v3s16(-1, 0, 1), + v3s16(-1, 0, -1), + v3s16( 1, 0, -1) + }; + + for (int i = 0; i != 8; i++) { + u32 index = vm->m_area.index(p + dirs[i]); + if (vm->m_area.contains(index) && + vm->m_data[index].getContent() == c_spawnby) + nneighs++; + } + + if (nneighs < nspawnby) + return; + } + + size_t ndecos = c_decolist.size(); + content_t c_place = ndecos ? c_decolist[pr->range(0, ndecos - 1)] : c_deco; + + s16 height = (deco_height_max > 0) ? + pr->range(deco_height, deco_height_max) : deco_height; + + height = MYMIN(height, max_y - p.Y); + + v3s16 em = vm->m_area.getExtent(); + for (int i = start_y; i < height; i++) { + vm->m_area.add_y(em, vi, 1); + + content_t c = vm->m_data[vi].getContent(); + if (c != CONTENT_AIR && c != CONTENT_IGNORE) + break; + + vm->m_data[vi] = MapNode(c_place); + } +} + + +int DecoSimple::getHeight() { + return (deco_height_max > 0) ? deco_height_max : deco_height; +} + + +std::string DecoSimple::getName() { + return deco_name; +} + + +/////////////////////////////////////////////////////////////////////////////// + + +Mapgen::Mapgen() { + seed = 0; + water_level = 0; + generating = false; + id = -1; + vm = NULL; + ndef = NULL; + heightmap = NULL; + biomemap = NULL; +} + + +// Returns Y one under area minimum if not found +s16 Mapgen::findGroundLevelFull(v2s16 p2d) { + v3s16 em = vm->m_area.getExtent(); + s16 y_nodes_max = vm->m_area.MaxEdge.Y; + s16 y_nodes_min = vm->m_area.MinEdge.Y; + u32 i = vm->m_area.index(p2d.X, y_nodes_max, p2d.Y); + s16 y; + + for (y = y_nodes_max; y >= y_nodes_min; y--) { + MapNode &n = vm->m_data[i]; + if (ndef->get(n).walkable) + break; + + vm->m_area.add_y(em, i, -1); + } + return (y >= y_nodes_min) ? y : y_nodes_min - 1; +} + + +s16 Mapgen::findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax) { + v3s16 em = vm->m_area.getExtent(); + u32 i = vm->m_area.index(p2d.X, ymax, p2d.Y); + s16 y; + + for (y = ymax; y >= ymin; y--) { + MapNode &n = vm->m_data[i]; + if (ndef->get(n).walkable) + break; + + vm->m_area.add_y(em, i, -1); + } + return y; +} + + +void Mapgen::updateHeightmap(v3s16 nmin, v3s16 nmax) { + if (!heightmap) + return; + + //TimeTaker t("Mapgen::updateHeightmap", NULL, PRECISION_MICRO); + int index = 0; + for (s16 z = nmin.Z; z <= nmax.Z; z++) { + for (s16 x = nmin.X; x <= nmax.X; x++) { + s16 y = findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y); + heightmap[index++] = y; + } + } + //printf("updateHeightmap: %dus\n", t.stop()); +} + + void Mapgen::updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax) { bool isliquid, wasliquid; v3s16 em = vm->m_area.getExtent(); @@ -208,11 +524,11 @@ void Mapgen::updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nm for (s16 z = nmin.Z; z <= nmax.Z; z++) { for (s16 x = nmin.X; x <= nmax.X; x++) { wasliquid = true; - + u32 i = vm->m_area.index(x, nmax.Y, z); for (s16 y = nmax.Y; y >= nmin.Y; y--) { isliquid = ndef->get(vm->m_data[i]).isLiquid(); - + // there was a change between liquid and nonliquid, add to queue if (isliquid != wasliquid) trans_liquid->push_back(v3s16(x, y, z)); @@ -242,7 +558,7 @@ void Mapgen::setLighting(v3s16 nmin, v3s16 nmax, u8 light) { void Mapgen::lightSpread(VoxelArea &a, v3s16 p, u8 light) { if (light <= 1 || !a.contains(p)) return; - + u32 vi = vm->m_area.index(p); MapNode &nn = vm->m_data[vi]; @@ -250,9 +566,9 @@ void Mapgen::lightSpread(VoxelArea &a, v3s16 p, u8 light) { // should probably compare masked, but doesn't seem to make a difference if (light <= nn.param1 || !ndef->get(nn).light_propagates) return; - + nn.param1 = light; - + lightSpread(a, p + v3s16(0, 0, 1), light); lightSpread(a, p + v3s16(0, 1, 0), light); lightSpread(a, p + v3s16(1, 0, 0), light); @@ -282,7 +598,7 @@ void Mapgen::calcLighting(v3s16 nmin, v3s16 nmax) { continue; } vm->m_area.add_y(em, i, -1); - + for (int y = a.MaxEdge.Y; y >= a.MinEdge.Y; y--) { MapNode &n = vm->m_data[i]; if (!ndef->get(n).sunlight_propagates) @@ -292,7 +608,7 @@ void Mapgen::calcLighting(v3s16 nmin, v3s16 nmax) { } } } - + // now spread the sunlight and light up any sources for (int z = a.MinEdge.Z; z <= a.MaxEdge.Z; z++) { for (int y = a.MinEdge.Y; y <= a.MaxEdge.Y; y++) { @@ -302,11 +618,11 @@ void Mapgen::calcLighting(v3s16 nmin, v3s16 nmax) { if (n.getContent() == CONTENT_IGNORE || !ndef->get(n).light_propagates) continue; - + u8 light_produced = ndef->get(n).light_source & 0x0F; if (light_produced) n.param1 = light_produced; - + u8 light = n.param1 & 0x0F; if (light) { lightSpread(a, v3s16(x, y, z + 1), light); @@ -319,7 +635,7 @@ void Mapgen::calcLighting(v3s16 nmin, v3s16 nmax) { } } } - + //printf("updateLighting: %dms\n", t.stop()); } @@ -331,24 +647,24 @@ void Mapgen::calcLightingOld(v3s16 nmin, v3s16 nmax) { bool sunlight = !block_is_underground; ScopeProfiler sp(g_profiler, "EmergeThread: mapgen lighting update", SPT_AVG); - + for (int i = 0; i < 2; i++) { enum LightBank bank = banks[i]; std::set<v3s16> light_sources; std::map<v3s16, u8> unlight_from; voxalgo::clearLightAndCollectSources(*vm, a, bank, ndef, - light_sources, unlight_from); + light_sources, unlight_from); voxalgo::propagateSunlight(*vm, a, sunlight, light_sources, ndef); vm->unspreadLight(bank, unlight_from, light_sources, ndef); vm->spreadLight(bank, light_sources, ndef); } } - - + + //////////////////////// Mapgen V6 parameter read/write - + bool MapgenV6Params::readParams(Settings *settings) { freq_desert = settings->getFloat("mgv6_freq_desert"); freq_beach = settings->getFloat("mgv6_freq_beach"); @@ -367,12 +683,12 @@ bool MapgenV6Params::readParams(Settings *settings) { settings->getNoiseParams("mgv6_np_apple_trees", np_apple_trees); return success; } - - + + void MapgenV6Params::writeParams(Settings *settings) { settings->setFloat("mgv6_freq_desert", freq_desert); settings->setFloat("mgv6_freq_beach", freq_beach); - + settings->setNoiseParams("mgv6_np_terrain_base", np_terrain_base); settings->setNoiseParams("mgv6_np_terrain_higher", np_terrain_higher); settings->setNoiseParams("mgv6_np_steepness", np_steepness); @@ -411,7 +727,6 @@ void MapgenV7Params::writeParams(Settings *settings) { /////////////////////////////////// legacy static functions for farmesh - s16 Mapgen::find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision) { //just need to return something s16 level = 5; @@ -421,9 +736,9 @@ s16 Mapgen::find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision) { bool Mapgen::get_have_beach(u64 seed, v2s16 p2d) { double sandnoise = noise2d_perlin( - 0.2+(float)p2d.X/250, 0.7+(float)p2d.Y/250, - seed+59420, 3, 0.50); - + 0.2+(float)p2d.X/250, 0.7+(float)p2d.Y/250, + seed+59420, 3, 0.50); + return (sandnoise > 0.15); } diff --git a/src/mapgen.h b/src/mapgen.h index 5d1e3bdf0..f3d90a14e 100644 --- a/src/mapgen.h +++ b/src/mapgen.h @@ -86,9 +86,15 @@ public: int id; ManualMapVoxelManipulator *vm; INodeDefManager *ndef; + s16 *heightmap; + u8 *biomemap; + Mapgen(); virtual ~Mapgen() {} + s16 findGroundLevelFull(v2s16 p2d); + s16 findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax); + void updateHeightmap(v3s16 nmin, v3s16 nmax); void updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nmax); void setLighting(v3s16 nmin, v3s16 nmax, u8 light); void lightSpread(VoxelArea &a, v3s16 p, u8 light); @@ -166,5 +172,90 @@ class OreSheet : public Ore { Ore *createOre(OreType type); + +enum DecorationType { + DECO_SIMPLE, + DECO_SCHEMATIC, + DECO_LSYSTEM +}; + +#if 0 +struct CutoffData { + VoxelArea a; + Decoration *deco; + //v3s16 p; + //v3s16 size; + //s16 height; + + CutoffData(s16 x, s16 y, s16 z, s16 h) { + p = v3s16(x, y, z); + height = h; + } +}; +#endif + +class Decoration { +public: + int mapseed; + std::string place_on_name; + content_t c_place_on; + s16 sidelen; + float fill_ratio; + NoiseParams *np; + + std::set<u8> biomes; + //std::list<CutoffData> cutoffs; + //JMutex cutoff_mutex; + + virtual ~Decoration(); + + virtual void resolveNodeNames(INodeDefManager *ndef); + void placeDeco(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); + void placeCutoffs(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); + + virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, + s16 start_y, v3s16 p) = 0; + virtual int getHeight() = 0; + virtual std::string getName() = 0; +}; + +class DecoSimple : public Decoration { +public: + std::string deco_name; + std::string spawnby_name; + content_t c_deco; + content_t c_spawnby; + s16 deco_height; + s16 deco_height_max; + s16 nspawnby; + + std::vector<std::string> decolist_names; + std::vector<content_t> c_decolist; + + ~DecoSimple() {} + + void resolveNodeNames(INodeDefManager *ndef); + virtual void generate(Mapgen *mg, PseudoRandom *pr, s16 max_y, + s16 start_y, v3s16 p); + virtual int getHeight(); + virtual std::string getName(); +}; + +/* +class DecoSchematic : public Decoration { +public: + virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); +}; +*/ + +/* +class DecoLSystem : public Decoration { +public: + virtual void generate(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); +}; +*/ + +Decoration *createDecoration(DecorationType type); + #endif diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp index eaca33988..d3db00dc2 100644 --- a/src/mapgen_v6.cpp +++ b/src/mapgen_v6.cpp @@ -79,7 +79,7 @@ MapgenV6::MapgenV6(int mapgenid, MapgenV6Params *params, EmergeManager *emerge) this->freq_beach = params->freq_beach; this->ystride = csize.X; //////fix this - + np_cave = ¶ms->np_cave; np_humidity = ¶ms->np_humidity; np_trees = ¶ms->np_trees; @@ -108,23 +108,6 @@ MapgenV6::~MapgenV6() { //////////////////////// Some helper functions for the map generator -// Returns Y one under area minimum if not found -s16 MapgenV6::find_ground_level(v2s16 p2d) { - v3s16 em = vm->m_area.getExtent(); - s16 y_nodes_max = vm->m_area.MaxEdge.Y; - s16 y_nodes_min = vm->m_area.MinEdge.Y; - u32 i = vm->m_area.index(p2d.X, y_nodes_max, p2d.Y); - s16 y; - - for (y = y_nodes_max; y >= y_nodes_min; y--) { - MapNode &n = vm->m_data[i]; - if(ndef->get(n).walkable) - break; - - vm->m_area.add_y(em, i, -1); - } - return (y >= y_nodes_min) ? y : y_nodes_min - 1; -} // Returns Y one under area minimum if not found s16 MapgenV6::find_stone_level(v2s16 p2d) { @@ -462,6 +445,12 @@ void MapgenV6::makeChunk(BlockMakeData *data) { // Generate some trees, and add grass, if a jungle if (flags & MG_TREES) placeTreesAndJungleGrass(); + + // Generate the registered decorations + for (unsigned int i = 0; i != emerge->decorations.size(); i++) { + Decoration *deco = emerge->decorations[i]; + deco->placeDeco(this, blockseed + i, node_min, node_max); + } // Generate the registered ores for (unsigned int i = 0; i != emerge->ores.size(); i++) { @@ -849,7 +838,7 @@ void MapgenV6::placeTreesAndJungleGrass() { s16 x = grassrandom.range(p2d_min.X, p2d_max.X); s16 z = grassrandom.range(p2d_min.Y, p2d_max.Y); - s16 y = find_ground_level(v2s16(x, z)); ////////////////optimize this! + s16 y = findGroundLevelFull(v2s16(x, z)); ////////////////optimize this! if (y < water_level || y < node_min.Y || y > node_max.Y) continue; @@ -866,7 +855,7 @@ void MapgenV6::placeTreesAndJungleGrass() { for (u32 i = 0; i < tree_count; i++) { s16 x = myrand_range(p2d_min.X, p2d_max.X); s16 z = myrand_range(p2d_min.Y, p2d_max.Y); - s16 y = find_ground_level(v2s16(x, z)); ////////////////////optimize this! + s16 y = findGroundLevelFull(v2s16(x, z)); ////////////////////optimize this! // Don't make a tree under water level // Don't make a tree so high that it doesn't fit if(y < water_level || y > node_max.Y - 6) diff --git a/src/mapgen_v6.h b/src/mapgen_v6.h index 8f456fd3f..f4ffd25f3 100644 --- a/src/mapgen_v6.h +++ b/src/mapgen_v6.h @@ -132,7 +132,6 @@ public: virtual float baseTerrainLevelFromMap(v2s16 p); virtual float baseTerrainLevelFromMap(int index); - s16 find_ground_level(v2s16 p2d); s16 find_stone_level(v2s16 p2d); bool block_is_underground(u64 seed, v3s16 blockpos); s16 find_ground_level_from_noise(u64 seed, v2s16 p2d, s16 precision); diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp index 6daa5fc6a..2439c95b3 100644 --- a/src/mapgen_v7.cpp +++ b/src/mapgen_v7.cpp @@ -52,7 +52,7 @@ NoiseParams nparams_v7_def_terrain_persist = NoiseParams nparams_v7_def_height_select = {0.5, 0.5, v3f(250.0, 250.0, 250.0), 4213, 5, 0.69}; NoiseParams nparams_v7_def_ridge = - {0.5, 1.0, v3f(100.0, 100.0, 100.0), 6467, 4, 0.75}; + {0, 1.0, v3f(100.0, 100.0, 100.0), 6467, 4, 0.75}; /* NoiseParams nparams_v6_def_beach = {0.0, 1.0, v3f(250.0, 250.0, 250.0), 59420, 3, 0.50}; @@ -121,15 +121,19 @@ int MapgenV7::getGroundLevelAtPoint(v2s16 p) { Biome *b = bmgr->getBiome(heat, humidity, groundlevel); s16 y = groundlevel; - if (y > water_level) { - int iters = 1024; // don't even bother iterating more than 1024 times.. - while (iters--) { - float ridgenoise = NoisePerlin3D(noise_ridge->np, p.X, y, p.Y, seed); - if (ridgenoise * (float)(y * y) < 15.0) - break; - y--; - } + int iters = 1024; // don't even bother iterating more than 64 times.. + while (iters--) { + if (y <= water_level) + break; + + float ridgenoise = NoisePerlin3D(noise_ridge->np, p.X, y, p.Y, seed); + if (ridgenoise * (float)(y * y) < 15.0) + break; + + y--; } + if (iters == 0) + printf("iters exhausted at %d %d\n", p.X, p.Y); return y + b->top_depth; } @@ -182,15 +186,24 @@ void MapgenV7::makeChunk(BlockMakeData *data) { generateTerrain(); carveRidges(); + + if (flags & MG_CAVES) + generateCaves(stone_surface_max_y); - generateCaves(stone_surface_max_y); addTopNodes(); + + updateHeightmap(node_min, node_max); if (flags & MG_DUNGEONS) { DungeonGen dgen(ndef, data->seed, water_level); dgen.generate(vm, blockseed, full_node_min, full_node_max); } + for (size_t i = 0; i != emerge->decorations.size(); i++) { + Decoration *deco = emerge->decorations[i]; + deco->placeDeco(this, blockseed + i, node_min, node_max); + } + for (size_t i = 0; i != emerge->ores.size(); i++) { Ore *ore = emerge->ores[i]; ore->placeOre(this, blockseed + i, node_min, node_max); diff --git a/src/mapgen_v7.h b/src/mapgen_v7.h index b6b03689d..d7177862d 100644 --- a/src/mapgen_v7.h +++ b/src/mapgen_v7.h @@ -67,9 +67,7 @@ public: v3s16 full_node_min; v3s16 full_node_max; - s16 *heightmap; s16 *ridge_heightmap; - u8 *biomemap; Noise *noise_terrain_base; Noise *noise_terrain_alt; diff --git a/src/modalMenu.h b/src/modalMenu.h index d19b4e27c..62bfabc06 100644 --- a/src/modalMenu.h +++ b/src/modalMenu.h @@ -99,6 +99,7 @@ public: allowFocusRemoval(true); // This removes Environment's grab on us Environment->removeFocus(this); + m_menumgr->deletingMenu(this); this->remove(); } diff --git a/src/nodedef.cpp b/src/nodedef.cpp index ba3e42e98..7d8ce70d3 100644 --- a/src/nodedef.cpp +++ b/src/nodedef.cpp @@ -211,6 +211,7 @@ void ContentFeatures::reset() liquid_alternative_source = ""; liquid_viscosity = 0; liquid_renewable = true; + drowning = true; light_source = 0; damage_per_second = 0; node_box = NodeBox(); @@ -279,6 +280,7 @@ void ContentFeatures::serialize(std::ostream &os, u16 protocol_version) writeU8(os, rightclickable); // Stuff below should be moved to correct place in a version that otherwise changes // the protocol version + writeU8(os, drowning); } void ContentFeatures::deSerialize(std::istream &is) @@ -343,6 +345,7 @@ void ContentFeatures::deSerialize(std::istream &is) try{ // Stuff below should be moved to correct place in a version that // otherwise changes the protocol version + drowning = readU8(is); }catch(SerializationError &e) {}; } diff --git a/src/nodedef.h b/src/nodedef.h index 2691aca33..e397d20e0 100644 --- a/src/nodedef.h +++ b/src/nodedef.h @@ -219,6 +219,7 @@ struct ContentFeatures u8 liquid_viscosity; // Is liquid renewable (new liquid source will be created between 2 existing) bool liquid_renewable; + bool drowning; // Amount of light the node emits u8 light_source; u32 damage_per_second; diff --git a/src/player.cpp b/src/player.cpp index 4eb5955c0..a199c9a6c 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -36,6 +36,7 @@ Player::Player(IGameDef *gamedef): camera_barely_in_ceiling(false), inventory(gamedef->idef()), hp(PLAYER_MAX_HP), + breath(-1), peer_id(PEER_ID_INEXISTENT), // protected m_gamedef(gamedef), @@ -80,7 +81,8 @@ Player::Player(IGameDef *gamedef): physics_override_gravity = 1; hud_flags = HUD_FLAG_HOTBAR_VISIBLE | HUD_FLAG_HEALTHBAR_VISIBLE | - HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE; + HUD_FLAG_CROSSHAIR_VISIBLE | HUD_FLAG_WIELDITEM_VISIBLE | + HUD_FLAG_BREATHBAR_VISIBLE; hud_hotbar_itemcount = HUD_HOTBAR_ITEMCOUNT_DEFAULT; } diff --git a/src/player.h b/src/player.h index d3738fd52..517bd354d 100644 --- a/src/player.h +++ b/src/player.h @@ -232,6 +232,7 @@ public: float physics_override_gravity; u16 hp; + u16 breath; float hurt_tilt_timer; float hurt_tilt_strength; diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index c7966a0be..64c76ef7c 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -389,6 +389,7 @@ ContentFeatures read_content_features(lua_State *L, int index) f.liquid_viscosity = getintfield_default(L, index, "liquid_viscosity", f.liquid_viscosity); getboolfield(L, index, "liquid_renewable", f.liquid_renewable); + getboolfield(L, index, "drowning", f.drowning); // Amount of light the node emits f.light_source = getintfield_default(L, index, "light_source", f.light_source); diff --git a/src/script/common/c_content.h b/src/script/common/c_content.h index 251a72e27..58be7118c 100644 --- a/src/script/common/c_content.h +++ b/src/script/common/c_content.h @@ -39,19 +39,19 @@ extern "C" { #include "irrlichttypes_bloated.h" #include "util/string.h" -class MapNode; +struct MapNode; class INodeDefManager; -class PointedThing; -class ItemStack; -class ItemDefinition; -class ToolCapabilities; -class ObjectProperties; -class SimpleSoundSpec; -class ServerSoundParams; +struct PointedThing; +struct ItemStack; +struct ItemDefinition; +struct ToolCapabilities; +struct ObjectProperties; +struct SimpleSoundSpec; +struct ServerSoundParams; class Inventory; -class NodeBox; -class ContentFeatures; -class TileDef; +struct NodeBox; +struct ContentFeatures; +struct TileDef; class Server; struct DigParams; struct HitParams; diff --git a/src/script/cpp_api/s_entity.h b/src/script/cpp_api/s_entity.h index b95b6b4b4..8df9d7f00 100644 --- a/src/script/cpp_api/s_entity.h +++ b/src/script/cpp_api/s_entity.h @@ -23,8 +23,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "cpp_api/s_base.h" #include "irr_v3d.h" -class ObjectProperties; -class ToolCapabilities; +struct ObjectProperties; +struct ToolCapabilities; class ScriptApiEntity : virtual public ScriptApiBase diff --git a/src/script/cpp_api/s_inventory.h b/src/script/cpp_api/s_inventory.h index bf3b5de85..d1a81de80 100644 --- a/src/script/cpp_api/s_inventory.h +++ b/src/script/cpp_api/s_inventory.h @@ -22,7 +22,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "cpp_api/s_base.h" -class ItemStack; +struct ItemStack; class ScriptApiDetached : virtual public ScriptApiBase diff --git a/src/script/cpp_api/s_item.h b/src/script/cpp_api/s_item.h index 28ac444f6..0f2b16042 100644 --- a/src/script/cpp_api/s_item.h +++ b/src/script/cpp_api/s_item.h @@ -23,10 +23,10 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "cpp_api/s_base.h" #include "irr_v3d.h" -class PointedThing; -class ItemStack; +struct PointedThing; +struct ItemStack; class ServerActiveObject; -class ItemDefinition; +struct ItemDefinition; class LuaItemStack; class ModApiItemMod; diff --git a/src/script/cpp_api/s_node.h b/src/script/cpp_api/s_node.h index bff6072b9..a8c9b3a79 100644 --- a/src/script/cpp_api/s_node.h +++ b/src/script/cpp_api/s_node.h @@ -26,7 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "cpp_api/s_base.h" #include "cpp_api/s_nodemeta.h" -class MapNode; +struct MapNode; class ServerActiveObject; class ScriptApiNode diff --git a/src/script/cpp_api/s_nodemeta.h b/src/script/cpp_api/s_nodemeta.h index 9be126c62..c2ebeba6d 100644 --- a/src/script/cpp_api/s_nodemeta.h +++ b/src/script/cpp_api/s_nodemeta.h @@ -24,7 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "cpp_api/s_item.h" #include "irr_v3d.h" -class ItemStack; +struct ItemStack; class ScriptApiNodemeta : virtual public ScriptApiBase, diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 58cf337ed..a287281a9 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -550,7 +550,7 @@ int ModApiEnvMod::l_line_of_sight(lua_State *L) { GET_ENV_PTR; // read position 1 from lua - v3f pos1 = checkFloatPos(L, 2); + v3f pos1 = checkFloatPos(L, 1); // read position 2 from lua v3f pos2 = checkFloatPos(L, 2); //read step size from lua @@ -566,14 +566,14 @@ int ModApiEnvMod::l_find_path(lua_State *L) { GET_ENV_PTR; - v3s16 pos1 = read_v3s16(L, 2); - v3s16 pos2 = read_v3s16(L, 3); - unsigned int searchdistance = luaL_checkint(L, 4); - unsigned int max_jump = luaL_checkint(L, 5); - unsigned int max_drop = luaL_checkint(L, 6); + v3s16 pos1 = read_v3s16(L, 1); + v3s16 pos2 = read_v3s16(L, 2); + unsigned int searchdistance = luaL_checkint(L, 3); + unsigned int max_jump = luaL_checkint(L, 4); + unsigned int max_drop = luaL_checkint(L, 5); algorithm algo = A_PLAIN_NP; - if(! lua_isnil(L, 7)) { - std::string algorithm = luaL_checkstring(L,7); + if(! lua_isnil(L, 6)) { + std::string algorithm = luaL_checkstring(L,6); if (algorithm == "A*") algo = A_PLAIN; @@ -680,6 +680,8 @@ bool ModApiEnvMod::Initialize(lua_State *L,int top) retval &= API_FCT(get_perlin_map); retval &= API_FCT(clear_objects); retval &= API_FCT(spawn_tree); + retval &= API_FCT(find_path); + retval &= API_FCT(line_of_sight); return retval; } diff --git a/src/script/lua_api/l_inventory.cpp b/src/script/lua_api/l_inventory.cpp index 1404c3c8a..f57a4e8cd 100644 --- a/src/script/lua_api/l_inventory.cpp +++ b/src/script/lua_api/l_inventory.cpp @@ -121,6 +121,9 @@ int InvRef::l_set_size(lua_State *L) const char *listname = luaL_checkstring(L, 2); int newsize = luaL_checknumber(L, 3); Inventory *inv = getinv(L, ref); + if(inv == NULL){ + return 0; + } if(newsize == 0){ inv->deleteList(listname); reportInventoryChange(L, ref); @@ -144,6 +147,9 @@ int InvRef::l_set_width(lua_State *L) const char *listname = luaL_checkstring(L, 2); int newwidth = luaL_checknumber(L, 3); Inventory *inv = getinv(L, ref); + if(inv == NULL){ + return 0; + } InventoryList *list = inv->getList(listname); if(list){ list->setWidth(newwidth); @@ -195,7 +201,11 @@ int InvRef::l_get_list(lua_State *L) InvRef *ref = checkobject(L, 1); const char *listname = luaL_checkstring(L, 2); Inventory *inv = getinv(L, ref); - push_inventory_list(inv, listname, L); + if(inv){ + push_inventory_list(inv, listname, L); + } else { + lua_pushnil(L); + } return 1; } @@ -206,6 +216,9 @@ int InvRef::l_set_list(lua_State *L) InvRef *ref = checkobject(L, 1); const char *listname = luaL_checkstring(L, 2); Inventory *inv = getinv(L, ref); + if(inv == NULL){ + return 0; + } InventoryList *list = inv->getList(listname); if(list) read_inventory_list(inv, listname, L, 3, diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 1e45610a6..f90b59285 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -62,6 +62,7 @@ struct EnumString es_HudBuiltinElement[] = {HUD_FLAG_HEALTHBAR_VISIBLE, "healthbar"}, {HUD_FLAG_CROSSHAIR_VISIBLE, "crosshair"}, {HUD_FLAG_WIELDITEM_VISIBLE, "wielditem"}, + {HUD_FLAG_BREATHBAR_VISIBLE, "breathbar"}, {0, NULL}, }; diff --git a/src/script/lua_api/luaapi.cpp b/src/script/lua_api/luaapi.cpp index b75304b3a..e19c90952 100644 --- a/src/script/lua_api/luaapi.cpp +++ b/src/script/lua_api/luaapi.cpp @@ -43,6 +43,14 @@ struct EnumString ModApiBasic::es_OreType[] = {0, NULL}, }; +struct EnumString ModApiBasic::es_DecorationType[] = +{ + {DECO_SIMPLE, "simple"}, + {DECO_SCHEMATIC, "schematic"}, + {DECO_LSYSTEM, "lsystem"}, + {0, NULL}, +}; + ModApiBasic::ModApiBasic() : ModApiBase() { } @@ -72,7 +80,7 @@ bool ModApiBasic::Initialize(lua_State* L,int top) { retval &= API_FCT(get_ban_list); retval &= API_FCT(get_ban_description); retval &= API_FCT(ban_player); - retval &= API_FCT(unban_player_of_ip); + retval &= API_FCT(unban_player_or_ip); retval &= API_FCT(get_password_hash); retval &= API_FCT(notify_authentication_modified); @@ -92,17 +100,36 @@ bool ModApiBasic::Initialize(lua_State* L,int top) { retval &= API_FCT(rollback_revert_actions_by); retval &= API_FCT(register_ore); + retval &= API_FCT(register_decoration); return retval; } -// debug(text) +// debug(...) // Writes a line to dstream int ModApiBasic::l_debug(lua_State *L) { NO_MAP_LOCK_REQUIRED; - std::string text = lua_tostring(L, 1); - dstream << text << std::endl; + // Handle multiple parameters to behave like standard lua print() + int n = lua_gettop(L); + lua_getglobal(L, "tostring"); + for(int i = 1; i <= n; i++){ + /* + Call tostring(i-th argument). + This is what print() does, and it behaves a bit + differently from directly calling lua_tostring. + */ + lua_pushvalue(L, -1); /* function to be called */ + lua_pushvalue(L, i); /* value to print */ + lua_call(L, 1, 1); + const char *s = lua_tostring(L, -1); + if(i>1) + dstream << "\t"; + if(s) + dstream << s; + lua_pop(L, 1); + } + dstream << std::endl; return 0; } @@ -162,30 +189,28 @@ int ModApiBasic::l_register_biome(lua_State *L) } enum BiomeTerrainType terrain = (BiomeTerrainType)getenumfield(L, index, - "terrain_type", es_BiomeTerrainType, BIOME_TERRAIN_NORMAL); + "terrain_type", es_BiomeTerrainType, BIOME_TERRAIN_NORMAL); Biome *b = bmgr->createBiome(terrain); - b->name = getstringfield_default(L, index, "name", ""); - b->top_nodename = getstringfield_default(L, index, "top_node", ""); - b->top_depth = getintfield_default(L, index, "top_depth", 0); + b->name = getstringfield_default(L, index, "name", ""); + b->top_nodename = getstringfield_default(L, index, "top_node", ""); + b->top_depth = getintfield_default(L, index, "top_depth", 0); b->filler_nodename = getstringfield_default(L, index, "filler_node", ""); - b->filler_height = getintfield_default(L, index, "filler_height", 0); - b->height_min = getintfield_default(L, index, "height_min", 0); - b->height_max = getintfield_default(L, index, "height_max", 0); - b->heat_point = getfloatfield_default(L, index, "heat_point", 0.); - b->humidity_point = getfloatfield_default(L, index, "humidity_point", 0.); - - b->flags = 0; //reserved - b->c_top = CONTENT_IGNORE; + b->filler_height = getintfield_default(L, index, "filler_height", 0); + b->height_min = getintfield_default(L, index, "height_min", 0); + b->height_max = getintfield_default(L, index, "height_max", 0); + b->heat_point = getfloatfield_default(L, index, "heat_point", 0.); + b->humidity_point = getfloatfield_default(L, index, "humidity_point", 0.); + + b->flags = 0; //reserved + b->c_top = CONTENT_IGNORE; b->c_filler = CONTENT_IGNORE; + verbosestream << "register_biome: " << b->name << std::endl; bmgr->addBiome(b); - verbosestream << "register_biome: " << b->name << std::endl; return 0; } - - // setting_set(name, value) int ModApiBasic::l_setting_set(lua_State *L) { @@ -353,7 +378,7 @@ int ModApiBasic::l_ban_player(lua_State *L) } // unban_player_or_ip() -int ModApiBasic::l_unban_player_of_ip(lua_State *L) +int ModApiBasic::l_unban_player_or_ip(lua_State *L) { NO_MAP_LOCK_REQUIRED; const char * ip_or_name = luaL_checkstring(L, 1); @@ -650,4 +675,111 @@ int ModApiBasic::l_register_ore(lua_State *L) return 0; } +// register_decoration({lots of stuff}) +int ModApiBasic::l_register_decoration(lua_State *L) +{ + int index = 1; + luaL_checktype(L, index, LUA_TTABLE); + + EmergeManager *emerge = getServer(L)->getEmergeManager(); + BiomeDefManager *bdef = emerge->biomedef; + + enum DecorationType decotype = (DecorationType)getenumfield(L, index, + "deco_type", es_DecorationType, -1); + if (decotype == -1) { + errorstream << "register_decoration: unrecognized " + "decoration placement type"; + return 0; + } + + Decoration *deco = createDecoration(decotype); + if (!deco) { + errorstream << "register_decoration: decoration placement type " + << decotype << " not implemented"; + return 0; + } + + deco->c_place_on = CONTENT_IGNORE; + deco->place_on_name = getstringfield_default(L, index, "place_on", "ignore"); + deco->sidelen = getintfield_default(L, index, "sidelen", 8); + deco->fill_ratio = getfloatfield_default(L, index, "fill_ratio", 0.02); + + lua_getfield(L, index, "noise_params"); + deco->np = read_noiseparams(L, -1); + lua_pop(L, 1); + + lua_getfield(L, index, "biomes"); + if (lua_istable(L, -1)) { + lua_pushnil(L); + while (lua_next(L, -2)) { + const char *s = lua_tostring(L, -1); + u8 biomeid = bdef->getBiomeIdByName(s); + if (biomeid) + deco->biomes.insert(biomeid); + + lua_pop(L, 1); + } + lua_pop(L, 1); + } + + switch (decotype) { + case DECO_SIMPLE: { + DecoSimple *dsimple = (DecoSimple *)deco; + dsimple->c_deco = CONTENT_IGNORE; + dsimple->c_spawnby = CONTENT_IGNORE; + dsimple->spawnby_name = getstringfield_default(L, index, "spawn_by", "air"); + dsimple->deco_height = getintfield_default(L, index, "height", 1); + dsimple->deco_height_max = getintfield_default(L, index, "height_max", 0); + dsimple->nspawnby = getintfield_default(L, index, "num_spawn_by", -1); + + lua_getfield(L, index, "decoration"); + if (lua_istable(L, -1)) { + lua_pushnil(L); + while (lua_next(L, -2)) { + const char *s = lua_tostring(L, -1); + std::string str(s); + dsimple->decolist_names.push_back(str); + + lua_pop(L, 1); + } + } else if (lua_isstring(L, -1)) { + dsimple->deco_name = std::string(lua_tostring(L, -1)); + } else { + dsimple->deco_name = std::string("air"); + } + lua_pop(L, 1); + + if (dsimple->deco_height <= 0) { + errorstream << "register_decoration: simple decoration height" + " must be greater than 0" << std::endl; + delete dsimple; + return 0; + } + + break; } + case DECO_SCHEMATIC: { + //DecoSchematic *decoschematic = (DecoSchematic *)deco; + + break; } + case DECO_LSYSTEM: { + //DecoLSystem *decolsystem = (DecoLSystem *)deco; + + break; } + } + + if (deco->sidelen <= 0) { + errorstream << "register_decoration: sidelen must be " + "greater than 0" << std::endl; + delete deco; + return 0; + } + + emerge->decorations.push_back(deco); + + verbosestream << "register_decoration: decoration '" << deco->getName() + << "' registered" << std::endl; + return 0; +} + + ModApiBasic modapibasic_prototype; diff --git a/src/script/lua_api/luaapi.h b/src/script/lua_api/luaapi.h index 592046965..d03c14117 100644 --- a/src/script/lua_api/luaapi.h +++ b/src/script/lua_api/luaapi.h @@ -45,9 +45,6 @@ private: // get_server_status() static int l_get_server_status(lua_State *L); - // register_biome_groups({frequencies}) - static int l_register_biome_groups(lua_State *L); - // register_biome({lots of stuff}) static int l_register_biome(lua_State *L); @@ -85,7 +82,7 @@ private: static int l_ban_player(lua_State *L); // unban_player_or_ip() - static int l_unban_player_of_ip(lua_State *L); + static int l_unban_player_or_ip(lua_State *L); // show_formspec(playername,formname,formspec) static int l_show_formspec(lua_State *L); @@ -130,9 +127,15 @@ private: // rollback_revert_actions_by(actor, seconds) -> bool, log messages static int l_rollback_revert_actions_by(lua_State *L); + // register_ore(oredesc) static int l_register_ore(lua_State *L); + + // register_decoration(deco) + static int l_register_decoration(lua_State *L); static struct EnumString es_OreType[]; + static struct EnumString es_DecorationType[]; + }; diff --git a/src/server.cpp b/src/server.cpp index 4268bb809..7963aeaae 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2401,6 +2401,18 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id) setInventoryModified(da->from_inv); + /* + Disable dropping items out of craftpreview + */ + if(da->from_list == "craftpreview") + { + infostream<<"Ignoring IDropAction from " + <<(da->from_inv.dump())<<":"<<da->from_list + <<" because src is "<<da->from_list<<std::endl; + delete a; + return; + } + // Disallow dropping items if not allowed to interact if(!checkPriv(player->getName(), "interact")) { diff --git a/src/test.cpp b/src/test.cpp index 3a0316e17..5267b2768 100644 --- a/src/test.cpp +++ b/src/test.cpp @@ -1452,7 +1452,7 @@ struct TestConnection: public TestBase // Server should not have added client yet UASSERT(hand_server.count == 0); - sleep_ms(50); + sleep_ms(100); try { diff --git a/src/tile.cpp b/src/tile.cpp index 5f25e123b..f176d1549 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -364,14 +364,14 @@ public: // Gets a separate texture video::ITexture* getTextureRaw(const std::string &name) { - AtlasPointer ap = getTexture(name + "^[forcesingle"); + AtlasPointer ap = getTexture(name + m_forcesingle_suffix); return ap.atlas; } // Gets a separate texture atlas pointer AtlasPointer getTextureRawAP(const AtlasPointer &ap) { - return getTexture(getTextureName(ap.id) + "^[forcesingle"); + return getTexture(getTextureName(ap.id) + m_forcesingle_suffix); } // Returns a pointer to the irrlicht device @@ -437,9 +437,14 @@ private: // Main texture atlas. This is filled at startup and is then not touched. video::IImage *m_main_atlas_image; video::ITexture *m_main_atlas_texture; + std::string m_forcesingle_suffix; // Queued texture fetches (to be processed by the main thread) RequestQueue<std::string, u32, u8, u8> m_get_texture_queue; + + // Textures that have been overwritten with other ones + // but can't be deleted because the ITexture* might still be used + std::list<video::ITexture*> m_texture_trash; }; IWritableTextureSource* createTextureSource(IrrlichtDevice *device) @@ -485,6 +490,16 @@ TextureSource::~TextureSource() } m_atlaspointer_cache.clear(); + for (std::list<video::ITexture*>::iterator iter = + m_texture_trash.begin(); iter != m_texture_trash.end(); + iter++) + { + video::ITexture *t = *iter; + + //cleanup trashed texture + driver->removeTexture(t); + } + infostream << "~TextureSource() "<< textures_before << "/" << driver->getTextureCount() << std::endl; } @@ -870,7 +885,7 @@ void TextureSource::rebuildImagesAndTextures() sap->intsize = img->getDimension(); if (t_old != 0) - driver->removeTexture(t_old); + m_texture_trash.push_back(t_old); } } @@ -1123,6 +1138,8 @@ void TextureSource::buildMainAtlas(class IGameDef *gamedef) <<atlaspath<<std::endl; fs::RecursiveDelete(atlaspath); driver->writeImageToFile(atlas_img, atlaspath.c_str());*/ + + m_forcesingle_suffix = "^[forcesingle"; } video::IImage* generate_image_from_scratch(std::string name, diff --git a/textures/base/pack/fontdejavusansmono.png b/textures/base/pack/fontdejavusansmono.png Binary files differindex 416a74f8a..02ad41352 100644 --- a/textures/base/pack/fontdejavusansmono.png +++ b/textures/base/pack/fontdejavusansmono.png diff --git a/textures/base/pack/fontlucida.png b/textures/base/pack/fontlucida.png Binary files differindex c63fa02b7..ab7bb70b8 100644 --- a/textures/base/pack/fontlucida.png +++ b/textures/base/pack/fontlucida.png diff --git a/textures/base/pack/logo.png b/textures/base/pack/logo.png Binary files differindex f341e8892..89be884a2 100644 --- a/textures/base/pack/logo.png +++ b/textures/base/pack/logo.png diff --git a/textures/base/pack/menu_header.png b/textures/base/pack/menu_header.png Binary files differindex c22192d0f..abf24038e 100644 --- a/textures/base/pack/menu_header.png +++ b/textures/base/pack/menu_header.png diff --git a/textures/base/pack/smoke_puff.png b/textures/base/pack/smoke_puff.png Binary files differindex e346d204c..e0f038f0a 100644 --- a/textures/base/pack/smoke_puff.png +++ b/textures/base/pack/smoke_puff.png diff --git a/textures/base/pack/sunrisebg.png b/textures/base/pack/sunrisebg.png Binary files differindex d8b010ebb..1d03dd3c3 100644 --- a/textures/base/pack/sunrisebg.png +++ b/textures/base/pack/sunrisebg.png diff --git a/textures/base/pack/unknown_item.png b/textures/base/pack/unknown_item.png Binary files differindex 35cabf0ad..27a3450eb 100644 --- a/textures/base/pack/unknown_item.png +++ b/textures/base/pack/unknown_item.png diff --git a/textures/base/pack/unknown_node.png b/textures/base/pack/unknown_node.png Binary files differindex 9cae26d5c..cb59ff467 100644 --- a/textures/base/pack/unknown_node.png +++ b/textures/base/pack/unknown_node.png diff --git a/textures/base/pack/unknown_object.png b/textures/base/pack/unknown_object.png Binary files differindex 4d6a98d56..c0166c31f 100644 --- a/textures/base/pack/unknown_object.png +++ b/textures/base/pack/unknown_object.png |