Changed default settings to bring a better gameplay.

Reduced viewing_range_nodes_max

viewing_range_nodes_max tends to actually push more than it should.

Matching the example with the default settings.

And adding a further description about it.

Missed changing curl timeout. Now set to 4000

Fix leaking global in texture pack menu

Simplify loading of Android version of menu

Mgv5 get ground level at point function. Fast spawn player version

Mgv5 1 up 1 down overgeneration for biome surface continuity

Optimise getTileInfo()

getTileInfo() ~1.5x faster
getSmoothLight ~2.0x faster

Optimise functions from CNodeDefManager and VoxelManipulator

CNodeDefManager::get()
VoxelManipulator::addArea()

serialize.h: use machine native byte swapping if available, fall-back to previous generic method if not (supported for GCC using endian.h, detection done in cmake) write/readARGB8() - just write 32-bit color in one op, instead of 4 1-byte ops cleanup: removed unneeded buffer init for some serialize-out functions use a #define for the fixed point factor in read/writeF1000()

nodemetadata.cpp, nodetimer.cpp
	optimzation: simpler deserialize node position method

staticobject.cpp:
	cleanup: use util/serialize.h inlines instead of its own de/serialization

serialize.cpp:
	minor optimization/cleanup: avoid generation of unneeded string temporary

CMakeLists.txt, cmake_config.h.in: detection of endian.h

config.h: added HAVE_ENDIAN_H

Commits due to feedback squashed

Signed-off-by: Craig Robbins <kde.psych@gmail.com>

Update credits menu
This commit is contained in:
Megaf 2014-11-20 17:26:42 +00:00
parent b9bc8dadb2
commit de0cbd5534
24 changed files with 399 additions and 341 deletions

View File

@ -38,21 +38,25 @@ dofile(menupath .. DIR_DELIM .. "gamemgr.lua")
dofile(menupath .. DIR_DELIM .. "modmgr.lua")
dofile(menupath .. DIR_DELIM .. "store.lua")
dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua")
dofile(menupath .. DIR_DELIM .. "dlg_create_world.lua")
dofile(menupath .. DIR_DELIM .. "dlg_delete_mod.lua")
dofile(menupath .. DIR_DELIM .. "dlg_delete_world.lua")
dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua")
dofile(menupath .. DIR_DELIM .. "tab_credits.lua")
dofile(menupath .. DIR_DELIM .. "tab_mods.lua")
dofile(menupath .. DIR_DELIM .. "tab_multiplayer.lua")
dofile(menupath .. DIR_DELIM .. "tab_server.lua")
dofile(menupath .. DIR_DELIM .. "tab_settings.lua")
dofile(menupath .. DIR_DELIM .. "tab_singleplayer.lua")
dofile(menupath .. DIR_DELIM .. "tab_texturepacks.lua")
dofile(menupath .. DIR_DELIM .. "textures.lua")
if PLATFORM ~= "Android" then
dofile(menupath .. DIR_DELIM .. "dlg_create_world.lua")
dofile(menupath .. DIR_DELIM .. "dlg_delete_mod.lua")
dofile(menupath .. DIR_DELIM .. "dlg_delete_world.lua")
dofile(menupath .. DIR_DELIM .. "dlg_rename_modpack.lua")
dofile(menupath .. DIR_DELIM .. "tab_multiplayer.lua")
dofile(menupath .. DIR_DELIM .. "tab_server.lua")
dofile(menupath .. DIR_DELIM .. "tab_singleplayer.lua")
dofile(menupath .. DIR_DELIM .. "tab_texturepacks.lua")
dofile(menupath .. DIR_DELIM .. "textures.lua")
else
dofile(menupath .. DIR_DELIM .. "tab_simple_main.lua")
end
--------------------------------------------------------------------------------
local function main_event_handler(tabview,event)
local function main_event_handler(tabview, event)
if event == "MenuQuit" then
core.close()
end
@ -61,55 +65,95 @@ end
--------------------------------------------------------------------------------
local function init_globals()
--init gamedata
-- Init gamedata
gamedata.worldindex = 0
menudata.worldlist = filterlist.create(
core.get_worlds,
compare_worlds,
function(element,uid)
if element.name == uid then
return true
end
return false
end, --unique id compare fct
function(element,gameid)
if element.gameid == gameid then
return true
end
return false
end --filter fct
)
menudata.worldlist:add_sort_mechanism("alphabetic",sort_worlds_alphabetic)
menudata.worldlist:set_sortmode("alphabetic")
if PLATFORM ~= "Android" then
menudata.worldlist = filterlist.create(
core.get_worlds,
compare_worlds,
-- Unique id comparison function
function(element, uid)
return element.name == uid
end,
-- Filter function
function(element, gameid)
return element.gameid == gameid
end
)
if not core.setting_get("menu_last_game") then
local default_game = core.setting_get("default_game") or "minetest"
core.setting_set("menu_last_game", default_game )
menudata.worldlist:add_sort_mechanism("alphabetic", sort_worlds_alphabetic)
menudata.worldlist:set_sortmode("alphabetic")
if not core.setting_get("menu_last_game") then
local default_game = core.setting_get("default_game") or "minetest"
core.setting_set("menu_last_game", default_game )
end
mm_texture.init()
else
local world_list = core.get_worlds()
local found_singleplayerworld = false
for world in pairs(world_list) do
if world.name == "singleplayerworld" then
found_singleplayerworld = true
gamedata.worldindex = i
break
end
end
if not found_singleplayerworld then
core.create_world("singleplayerworld", 1)
local world_list = core.get_worlds()
for world in pairs(world_list) do
if world.name == "singleplayerworld" then
gamedata.worldindex = i
return
end
end
end
end
mm_texture.init()
--create main tabview
-- Create main tabview
local tv_main = tabview_create("maintab",{x=12,y=5.2},{x=0,y=0})
tv_main:set_autosave_tab(true)
tv_main:add(tab_singleplayer)
tv_main:add(tab_multiplayer)
tv_main:add(tab_server)
if PLATFORM ~= "Android" then
tv_main:set_autosave_tab(true)
end
if PLATFORM ~= "Android" then
tv_main:add(tab_singleplayer)
tv_main:add(tab_multiplayer)
tv_main:add(tab_server)
else
tv_main:add(tab_simple_main)
end
tv_main:add(tab_settings)
tv_main:add(tab_texturepacks)
if PLATFORM ~= "Android" then
tv_main:add(tab_texturepacks)
end
tv_main:add(tab_mods)
tv_main:add(tab_credits)
tv_main:set_global_event_handler(main_event_handler)
tv_main:set_tab(core.setting_get("maintab_LAST"))
if PLATFORM == "Android" then
tv_main:set_fixed_size(false)
else
tv_main:set_tab(core.setting_get("maintab_LAST"))
end
ui.set_default("maintab")
tv_main:show()
--create modstore ui
modstore.init({x=12,y=8},4,3)
-- Create modstore ui
if PLATFORM == "Android" then
modstore.init({x=12, y=6}, 3, 2)
else
modstore.init({x=12, y=8}, 4, 3)
end
ui.update()
@ -117,3 +161,4 @@ local function init_globals()
end
init_globals()

View File

@ -1,102 +0,0 @@
--Minetest
--Copyright (C) 2014 sapier
--
--This program is free software; you can redistribute it and/or modify
--it under the terms of the GNU Lesser General Public License as published by
--the Free Software Foundation; either version 2.1 of the License, or
--(at your option) any later version.
--
--This program is distributed in the hope that it will be useful,
--but WITHOUT ANY WARRANTY; without even the implied warranty of
--MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
--GNU Lesser General Public License for more details.
--
--You should have received a copy of the GNU Lesser General Public License along
--with this program; if not, write to the Free Software Foundation, Inc.,
--51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
mt_color_grey = "#AAAAAA"
mt_color_blue = "#0000DD"
mt_color_green = "#00DD00"
mt_color_dark_green = "#003300"
--marker for android specific code
ANDROID = true
local menupath = core.get_mainmenu_path()
local basepath = core.get_builtin_path()
defaulttexturedir = core.get_texturepath_share() .. DIR_DELIM .. "base" ..
DIR_DELIM .. "pack" .. DIR_DELIM
dofile(basepath .. DIR_DELIM .. "common" .. DIR_DELIM .. "async_event.lua")
dofile(basepath .. DIR_DELIM .. "common" .. DIR_DELIM .. "filterlist.lua")
dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "buttonbar.lua")
dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "dialog.lua")
dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "tabview.lua")
dofile(basepath .. DIR_DELIM .. "fstk" .. DIR_DELIM .. "ui.lua")
dofile(menupath .. DIR_DELIM .. "common.lua")
dofile(menupath .. DIR_DELIM .. "gamemgr.lua")
dofile(menupath .. DIR_DELIM .. "modmgr.lua")
dofile(menupath .. DIR_DELIM .. "store.lua")
dofile(menupath .. DIR_DELIM .. "dlg_config_world.lua")
dofile(menupath .. DIR_DELIM .. "tab_simple_main.lua")
dofile(menupath .. DIR_DELIM .. "tab_credits.lua")
dofile(menupath .. DIR_DELIM .. "tab_mods.lua")
dofile(menupath .. DIR_DELIM .. "tab_settings.lua")
--------------------------------------------------------------------------------
local function main_event_handler(tabview,event)
if event == "MenuQuit" then
core.close()
end
return true
end
local function init_globals()
--init gamedata
gamedata.worldindex = 0
local worldlist = core.get_worlds()
local found_singleplayerworld = false
for i=1,#worldlist,1 do
if worldlist[i].name == "singleplayerworld" then
found_singleplayerworld = true
gamedata.worldindex = i
end
end
if not found_singleplayerworld then
core.create_world("singleplayerworld", 1)
local worldlist = core.get_worlds()
for i=1,#worldlist,1 do
if worldlist[i].name == "singleplayerworld" then
gamedata.worldindex = i
end
end
end
--create main tabview
local tv_main = tabview_create("maintab",{x=12,y=5.2},{x=-0,y=-0})
tv_main:add(tab_simple_main)
tv_main:add(tab_mods)
tv_main:add(tab_settings)
tv_main:add(tab_credits)
tv_main:set_global_event_handler(main_event_handler)
tv_main:set_fixed_size(false)
ui.set_default("maintab")
tv_main:show()
--create modstore ui
modstore.init({x=12,y=6},3,2)
ui.update()
core.sound_play("main_menu", true)
end
init_globals()

View File

@ -31,7 +31,6 @@ tab_credits = {
"Perttu Ahola (celeron55) <celeron55@gmail.com>,"..
"Ryan Kwolek (kwolekr) <kwolekr@minetest.net>,"..
"PilzAdam <pilzadam@minetest.net>," ..
"Ilya Zhuravlev (xyz) <xyz@minetest.net>,"..
"Lisa Milne (darkrose) <lisa@ltmnet.com>,"..
"Maciej Kasatkin (RealBadAngel) <mk@realbadangel.pl>,"..
"sfan5 <sfan5@live.de>,"..
@ -40,16 +39,22 @@ tab_credits = {
"ShadowNinja <shadowninja@minetest.net>,"..
"Nathanael Courant (Nore/Novatux) <nore@mesecons.net>,"..
"BlockMen,"..
"Craig Robbins (Zeno),"..
","..
"#FFFF00" .. fgettext("Active Contributors") .. "," ..
"TriBlade9 <triblade9@mail.com>,"..
"SmallJoker <mk939@ymail.com>,"..
"Zefram <zefram@fysh.org>,"..
"," ..
"#FFFF00" .. fgettext("Previous Contributors") .. "," ..
"Vanessa Ezekowitz (VanessaE) <vanessaezekowitz@gmail.com>,"..
"Jurgen Doser (doserj) <jurgen.doser@gmail.com>,"..
"Jeija <jeija@mesecons.net>,"..
"MirceaKitsune <mirceakitsune@gmail.com>,"..
"dannydark <the_skeleton_of_a_child@yahoo.co.uk>,"..
"0gb.us <0gb.us@0gb.us>,"..
"," ..
"#FFFF00" .. fgettext("Previous Contributors") .. "," ..
"proller <proler@gmail.com>,"..
"Ilya Zhuravlev (xyz) <xyz@minetest.net>,"..
"Guiseppe Bilotta (Oblomov) <guiseppe.bilotta@gmail.com>,"..
"Jonathan Neuschafer <j.neuschaefer@gmx.net>,"..
"Nils Dagsson Moskopp (erlehmann) <nils@dieweltistgarnichtso.net>,"..

View File

@ -160,7 +160,7 @@ local function formspec(tabview, name, tabdata)
"box[7.75,0;4,4;#999999]" ..
"checkbox[8,0;cb_shaders;".. fgettext("Shaders") .. ";"
.. dump(core.setting_getbool("enable_shaders")) .. "]"
if not ANDROID then
if PLATFORM ~= "Android" then
tab_string = tab_string ..
"button[8,4.75;3.75,0.5;btn_change_keys;".. fgettext("Change keys") .. "]"
else
@ -176,7 +176,7 @@ local function formspec(tabview, name, tabdata)
fgettext("Scaling factor applied to menu elements: ") ..
dump(core.setting_get("gui_scaling")) .. "]"
if ANDROID then
if PLATFORM == "Android" then
tab_string = tab_string ..
"box[4.25,2.75;3.25,2.15;#999999]" ..
"checkbox[4.5,2.75;cb_touchscreen_target;".. fgettext("Touch free target") .. ";"

View File

@ -17,10 +17,10 @@
--------------------------------------------------------------------------------
local function filter_texture_pack_list(list)
retval = {"None"}
for _,i in ipairs(list) do
if i~="base" then
table.insert(retval, i)
local retval = {"None"}
for _, item in ipairs(list) do
if item ~= "base" then
table.insert(retval, item)
end
end
return retval

View File

@ -54,7 +54,7 @@
# Double-tapping the jump key toggles fly mode
#doubletap_jump = false
# If false aux1 is used to fly fast
#always_fly_fast = true
#always_fly_fast = false
# Some (temporary) keys for debugging
#keymap_print_debug_stacks = KEY_KEY_P
#keymap_quicktune_prev = KEY_HOME
@ -70,9 +70,10 @@
#fps_max = 60
# Maximum FPS when game is paused
#pause_fps_max = 20
# The allowed adjustment range for the automatic rendering range adjustment
#viewing_range_nodes_max = 160
#viewing_range_nodes_min = 35
# The allowed adjustment range for the automatic rendering range adjustment.
# You can change this option on gameplay too. Press "-" to reduce and "+" to increase the minimum viewing range.
#viewing_range_nodes_max = 120
#viewing_range_nodes_min = 30
# Initial window size
#screenW = 800
#screenH = 600
@ -88,7 +89,7 @@
# Enable random user input, for testing
#random_input = false
# Timeout for client to remove unused map data from memory
#client_unload_unused_data_timeout = 600
#client_unload_unused_data_timeout = 300
# Whether to fog out the end of the visible area
#enable_fog = true
# Whether to show the client debug info (has the same effect as hitting F5)
@ -130,7 +131,7 @@
# Amount of view bobbing (0 = no view bobbing, 1.0 = normal, 2.0 = double)
#view_bobbing_amount = 1.0
# Amount of fall bobbing (0 = no fall bobbing, 1.0 = normal, 2.0 = double)
#fall_bobbing_amount = 0.0
#fall_bobbing_amount = 0.6
# 3d support,
# right now:
# "none" = no 3d output,
@ -215,7 +216,7 @@
# Default timeout for cURL, in milliseconds
# Only has an effect if compiled with cURL
#curl_timeout = 5000
#curl_timeout = 4000
# Limits number of parallel HTTP requests. Affects:
# - Media fetch if server uses remote_media setting
# - Serverlist download and server announcement

View File

@ -2,6 +2,7 @@ project(minetest)
cmake_minimum_required( VERSION 2.6 )
INCLUDE(CheckCSourceRuns)
INCLUDE(CheckIncludeFiles)
# Set some random things default to not being visible in the GUI
mark_as_advanced(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH)
@ -313,6 +314,8 @@ if(ENABLE_REDIS)
endif(REDIS_LIBRARY AND REDIS_INCLUDE_DIR)
endif(ENABLE_REDIS)
CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H)
configure_file(
"${PROJECT_SOURCE_DIR}/cmake_config.h.in"
"${PROJECT_BINARY_DIR}/cmake_config.h"

View File

@ -20,6 +20,7 @@
#define CMAKE_VERSION_PATCH @VERSION_PATCH@
#define CMAKE_VERSION_PATCH_ORIG @VERSION_PATCH_ORIG@
#define CMAKE_VERSION_EXTRA_STRING "@VERSION_EXTRA@"
#define CMAKE_HAVE_ENDIAN_H @HAVE_ENDIAN_H@
#ifdef NDEBUG
#define CMAKE_BUILD_TYPE "Release"

View File

@ -36,6 +36,8 @@
#define USE_REDIS 0
#endif
#define HAVE_ENDIAN_H 0
#ifdef USE_CMAKE_CONFIG_H
#include "cmake_config.h"
#undef PROJECT_NAME
@ -72,6 +74,8 @@
#define PRODUCT_VERSION_STRING CMAKE_PRODUCT_VERSION_STRING
#undef VERSION_EXTRA_STRING
#define VERSION_EXTRA_STRING CMAKE_VERSION_EXTRA_STRING
#undef HAVE_ENDIAN_H
#define HAVE_ENDIAN_H CMAKE_HAVE_ENDIAN_H
#endif
#ifdef __ANDROID__

View File

@ -62,7 +62,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("3d_paralax_strength", "0.025");
settings->setDefault("aux1_descends", "false");
settings->setDefault("doubletap_jump", "false");
settings->setDefault("always_fly_fast", "true");
settings->setDefault("always_fly_fast", "false");
settings->setDefault("directional_colored_fog", "true");
settings->setDefault("tooltip_show_delay", "400");
@ -84,8 +84,8 @@ void set_default_settings(Settings *settings)
settings->setDefault("fps_max", "60");
settings->setDefault("pause_fps_max", "20");
// A bit more than the server will send around the player, to make fog blend well
settings->setDefault("viewing_range_nodes_max", "240");
settings->setDefault("viewing_range_nodes_min", "35");
settings->setDefault("viewing_range_nodes_max", "120");
settings->setDefault("viewing_range_nodes_min", "30");
settings->setDefault("screenW", "800");
settings->setDefault("screenH", "600");
settings->setDefault("fullscreen", "false");
@ -94,7 +94,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("vsync", "false");
settings->setDefault("address", "");
settings->setDefault("random_input", "false");
settings->setDefault("client_unload_unused_data_timeout", "600");
settings->setDefault("client_unload_unused_data_timeout", "300");
settings->setDefault("enable_fog", "true");
settings->setDefault("fov", "72");
settings->setDefault("view_bobbing", "true");
@ -113,7 +113,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("enable_clouds", "true");
settings->setDefault("screenshot_path", ".");
settings->setDefault("view_bobbing_amount", "1.0");
settings->setDefault("fall_bobbing_amount", "0.0");
settings->setDefault("fall_bobbing_amount", "0.6");
settings->setDefault("enable_3d_clouds", "true");
settings->setDefault("cloud_height", "120");
settings->setDefault("menu_clouds", "true");
@ -156,7 +156,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("enable_particles", "true");
settings->setDefault("enable_mesh_cache", "true");
settings->setDefault("curl_timeout", "5000");
settings->setDefault("curl_timeout", "4000");
settings->setDefault("curl_parallel_limit", "8");
settings->setDefault("curl_file_download_timeout", "300000");
settings->setDefault("curl_verify_cert", "true");
@ -289,7 +289,6 @@ void set_default_settings(Settings *settings)
settings->setDefault("enable_particles", "false");
settings->setDefault("video_driver", "ogles1");
settings->setDefault("touchtarget", "true");
settings->setDefault("main_menu_script","/sdcard/Minetest/builtin/mainmenu/init_android.lua");
settings->setDefault("TMPFolder","/sdcard/Minetest/tmp/");
settings->setDefault("touchscreen_threshold","20");
settings->setDefault("smooth_lighting", "false");

View File

@ -65,8 +65,9 @@ void MeshMakeData::fill(MapBlock *block)
// Allocate this block + neighbors
m_vmanip.clear();
m_vmanip.addArea(VoxelArea(blockpos_nodes-v3s16(1,1,1)*MAP_BLOCKSIZE,
blockpos_nodes+v3s16(1,1,1)*MAP_BLOCKSIZE*2-v3s16(1,1,1)));
VoxelArea voxel_area(blockpos_nodes - v3s16(1,1,1) * MAP_BLOCKSIZE,
blockpos_nodes + v3s16(1,1,1) * MAP_BLOCKSIZE*2-v3s16(1,1,1));
m_vmanip.addArea(voxel_area);
{
//TimeTaker timer("copy central block data");
@ -221,11 +222,11 @@ u16 getFaceLight(MapNode n, MapNode n2, v3s16 face_dir, INodeDefManager *ndef)
/*
Calculate smooth lighting at the XYZ- corner of p.
Single light bank.
Both light banks
*/
static u8 getSmoothLight(enum LightBank bank, v3s16 p, MeshMakeData *data)
static u16 getSmoothLightCombined(v3s16 p, MeshMakeData *data)
{
static v3s16 dirs8[8] = {
static const v3s16 dirs8[8] = {
v3s16(0,0,0),
v3s16(0,0,1),
v3s16(0,1,0),
@ -239,10 +240,12 @@ static u8 getSmoothLight(enum LightBank bank, v3s16 p, MeshMakeData *data)
INodeDefManager *ndef = data->m_gamedef->ndef();
u16 ambient_occlusion = 0;
u16 light = 0;
u16 light_count = 0;
u8 light_source_max = 0;
for(u32 i=0; i<8; i++)
u16 light_day = 0;
u16 light_night = 0;
for(u32 i = 0; i < 8; i++)
{
MapNode n = data->m_vmanip.getNodeNoEx(p - dirs8[i]);
@ -256,48 +259,44 @@ static u8 getSmoothLight(enum LightBank bank, v3s16 p, MeshMakeData *data)
light_source_max = f.light_source;
// Check f.solidness because fast-style leaves look
// better this way
if(f.param_type == CPT_LIGHT && f.solidness != 2)
{
light += decode_light(n.getLight(bank, ndef));
if (f.param_type == CPT_LIGHT && f.solidness != 2) {
light_day += decode_light(n.getLight(LIGHTBANK_DAY, ndef));
light_night += decode_light(n.getLight(LIGHTBANK_NIGHT, ndef));
light_count++;
}
else {
} else {
ambient_occlusion++;
}
}
if(light_count == 0)
return 255;
return 0xffff;
light /= light_count;
light_day /= light_count;
light_night /= light_count;
// Boost brightness around light sources
if(decode_light(light_source_max) >= light)
//return decode_light(undiminish_light(light_source_max));
return decode_light(light_source_max);
bool skip_ambient_occlusion = false;
if(decode_light(light_source_max) >= light_day) {
light_day = decode_light(light_source_max);
skip_ambient_occlusion = true;
}
if(decode_light(light_source_max) >= light_night) {
light_night = decode_light(light_source_max);
skip_ambient_occlusion = true;
}
if(ambient_occlusion > 4)
if(ambient_occlusion > 4 && !skip_ambient_occlusion)
{
//calculate table index for gamma space multiplier
ambient_occlusion -= 5;
//table of precalculated gamma space multiply factors
//light^2.2 * factor (0.75, 0.5, 0.25, 0.0), so table holds factor ^ (1 / 2.2)
const float light_amount[4] = {0.877424315, 0.729740053, 0.532520545, 0.0};
light = core::clamp(core::round32(light*light_amount[ambient_occlusion]), 0, 255);
static const float light_amount[4] = {0.877424315, 0.729740053, 0.532520545, 0.0};
light_day = rangelim(core::round32(light_day*light_amount[ambient_occlusion]), 0, 255);
light_night = rangelim(core::round32(light_night*light_amount[ambient_occlusion]), 0, 255);
}
return light;
}
/*
Calculate smooth lighting at the XYZ- corner of p.
Both light banks.
*/
static u16 getSmoothLight(v3s16 p, MeshMakeData *data)
{
u16 day = getSmoothLight(LIGHTBANK_DAY, p, data);
u16 night = getSmoothLight(LIGHTBANK_NIGHT, p, data);
return day | (night << 8);
return light_day | (light_night << 8);
}
/*
@ -307,13 +306,13 @@ static u16 getSmoothLight(v3s16 p, MeshMakeData *data)
u16 getSmoothLight(v3s16 p, v3s16 corner, MeshMakeData *data)
{
if(corner.X == 1) p.X += 1;
else assert(corner.X == -1);
// else corner.X == -1
if(corner.Y == 1) p.Y += 1;
else assert(corner.Y == -1);
// else corner.Y == -1
if(corner.Z == 1) p.Z += 1;
else assert(corner.Z == -1);
// else corner.Z == -1
return getSmoothLight(p, data);
return getSmoothLightCombined(p, data);
}
/*

View File

@ -63,7 +63,7 @@ MapgenV5::MapgenV5(int mapgenid, MapgenParams *params, EmergeManager *emerge_) {
// amount of elements to skip for the next index
// for noise/height/biome maps (not vmanip)
this->ystride = csize.X;
this->zstride = csize.X * csize.Y;
this->zstride = csize.X * (csize.Y + 2);
this->biomemap = new u8[csize.X * csize.Z];
this->heightmap = new s16[csize.X * csize.Z];
@ -78,11 +78,11 @@ MapgenV5::MapgenV5(int mapgenid, MapgenParams *params, EmergeManager *emerge_) {
noise_height = new Noise(&sp->np_height, seed, csize.X, csize.Z);
// 3D terrain noise
noise_cave1 = new Noise(&sp->np_cave1, seed, csize.X, csize.Y, csize.Z);
noise_cave2 = new Noise(&sp->np_cave2, seed, csize.X, csize.Y, csize.Z);
noise_ground = new Noise(&sp->np_ground, seed, csize.X, csize.Y, csize.Z);
noise_crumble = new Noise(&sp->np_crumble, seed, csize.X, csize.Y, csize.Z);
noise_wetness = new Noise(&sp->np_wetness, seed, csize.X, csize.Y, csize.Z);
noise_cave1 = new Noise(&sp->np_cave1, seed, csize.X, csize.Y + 2, csize.Z);
noise_cave2 = new Noise(&sp->np_cave2, seed, csize.X, csize.Y + 2, csize.Z);
noise_ground = new Noise(&sp->np_ground, seed, csize.X, csize.Y + 2, csize.Z);
noise_crumble = new Noise(&sp->np_crumble, seed, csize.X, csize.Y + 2, csize.Z);
noise_wetness = new Noise(&sp->np_wetness, seed, csize.X, csize.Y + 2, csize.Z);
// Biome noise
noise_heat = new Noise(bmgr->np_heat, seed, csize.X, csize.Z);
@ -192,15 +192,48 @@ void MapgenV5Params::writeParams(Settings *settings) {
}
int MapgenV5::getGroundLevelAtPoint(v2s16 p) {
//TimeTaker t("getGroundLevelAtPoint", NULL, PRECISION_MICRO);
float f = 0.55 + NoisePerlin2D(noise_factor->np, p.X, p.Y, seed);
if(f < 0.01)
f = 0.01;
else if(f >= 1.0)
f *= 1.6;
float h = water_level + NoisePerlin2D(noise_height->np, p.X, p.Y, seed);
s16 search_top = water_level + 15;
s16 search_base = water_level;
// Use these 2 lines instead for a slower search returning highest ground level
//s16 search_top = h + f * noise_ground->np->octaves * noise_ground->np->scale;
//s16 search_base = h - f * noise_ground->np->octaves * noise_ground->np->scale;
s16 level = -31000;
for (s16 y = search_top; y >= search_base; y--) {
float n_ground = NoisePerlin3DEased(noise_ground->np, p.X, y, p.Y, seed);
if(n_ground * f > y - h) {
if(y >= search_top - 7)
break;
else
level = y;
break;
}
}
//printf("getGroundLevelAtPoint: %dus\n", t.stop());
return level;
}
void MapgenV5::makeChunk(BlockMakeData *data) {
assert(data->vmanip);
assert(data->nodedef);
assert(data->blockpos_requested.X >= data->blockpos_min.X &&
data->blockpos_requested.Y >= data->blockpos_min.Y &&
data->blockpos_requested.Z >= data->blockpos_min.Z);
data->blockpos_requested.Y >= data->blockpos_min.Y &&
data->blockpos_requested.Z >= data->blockpos_min.Z);
assert(data->blockpos_requested.X <= data->blockpos_max.X &&
data->blockpos_requested.Y <= data->blockpos_max.Y &&
data->blockpos_requested.Z <= data->blockpos_max.Z);
data->blockpos_requested.Y <= data->blockpos_max.Y &&
data->blockpos_requested.Z <= data->blockpos_max.Z);
generating = true;
vm = data->vmanip;
@ -258,8 +291,8 @@ void MapgenV5::makeChunk(BlockMakeData *data) {
// Calculate lighting
if (flags & MG_LIGHT)
calcLighting(node_min - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
node_max + v3s16(1, 0, 1) * MAP_BLOCKSIZE);
calcLighting(node_min - v3s16(0, 1, 0) - v3s16(1, 0, 1) * MAP_BLOCKSIZE,
node_max + v3s16(0, 1, 0) + v3s16(1, 0, 1) * MAP_BLOCKSIZE);
this->generating = false;
}
@ -268,7 +301,7 @@ void MapgenV5::makeChunk(BlockMakeData *data) {
void MapgenV5::calculateNoise() {
//TimeTaker t("calculateNoise", NULL, PRECISION_MICRO);
int x = node_min.X;
int y = node_min.Y;
int y = node_min.Y - 1;
int z = node_min.Z;
noise_filler_depth->perlinMap2D(x, z);
@ -319,7 +352,7 @@ void MapgenV5::generateBaseTerrain() {
u32 index2d = 0;
for(s16 z=node_min.Z; z<=node_max.Z; z++) {
for(s16 y=node_min.Y; y<=node_max.Y; y++) {
for(s16 y=node_min.Y - 1; y<=node_max.Y + 1; y++) {
u32 i = vm->m_area.index(node_min.X, y, z);
for(s16 x=node_min.X; x<=node_max.X; x++, i++, index++, index2d++) {
if(vm->m_data[i].getContent() != CONTENT_IGNORE)
@ -333,6 +366,7 @@ void MapgenV5::generateBaseTerrain() {
float h = water_level + noise_height->result[index2d];
float d1 = contour(noise_cave1->result[index]);
float d2 = contour(noise_cave2->result[index]);
if(noise_ground->result[index] * f < y - h) {
if(y <= water_level)
vm->m_data[i] = MapNode(c_water_source);
@ -356,7 +390,7 @@ void MapgenV5::generateBlobs() {
u32 index = 0;
for(s16 z=node_min.Z; z<=node_max.Z; z++) {
for(s16 y=node_min.Y; y<=node_max.Y; y++) {
for(s16 y=node_min.Y - 1; y<=node_max.Y + 1; y++) {
u32 i = vm->m_area.index(node_min.X, y, z);
for(s16 x=node_min.X; x<=node_max.X; x++, i++, index++) {
content_t c = vm->m_data[i].getContent();
@ -398,7 +432,7 @@ void MapgenV5::generateBiomes() {
Biome *biome = (Biome *)bmgr->get(biomemap[index]);
s16 dfiller = biome->depth_filler + noise_filler_depth->result[index];
s16 y0_top = biome->depth_top;
s16 y0_filler = biome->depth_filler + biome->depth_top + dfiller;
s16 y0_filler = biome->depth_top + dfiller;
s16 nplaced = 0;
u32 i = vm->m_area.index(x, node_max.Y, z);
@ -462,7 +496,7 @@ void MapgenV5::dustTopNodes() {
if (biome->c_dust == CONTENT_IGNORE)
continue;
s16 y = node_max.Y;
s16 y = node_max.Y + 1;
u32 vi = vm->m_area.index(x, y, z);
for (; y >= node_min.Y; y--) {
if (vm->m_data[vi].getContent() != CONTENT_AIR)
@ -473,12 +507,13 @@ void MapgenV5::dustTopNodes() {
content_t c = vm->m_data[vi].getContent();
if (c == biome->c_water && biome->c_dust_water != CONTENT_IGNORE) {
if (y < node_min.Y)
if (y < node_min.Y - 1)
continue;
vm->m_data[vi] = MapNode(biome->c_dust_water);
} else if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE) {
if (y == node_max.Y)
} else if (!ndef->get(c).buildable_to && c != CONTENT_IGNORE
&& c != biome->c_dust) {
if (y == node_max.Y + 1)
continue;
vm->m_area.add_y(em, vi, 1);

View File

@ -94,6 +94,7 @@ public:
~MapgenV5();
virtual void makeChunk(BlockMakeData *data);
int getGroundLevelAtPoint(v2s16 p);
void calculateNoise();
void generateBaseTerrain();
void generateBlobs();

View File

@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "serialization.h" // For ser_ver_supported
#include "util/serialize.h"
#include "log.h"
#include "util/numeric.h"
#include <string>
#include <sstream>
@ -77,19 +78,14 @@ u8 MapNode::getLight(enum LightBank bank, INodeDefManager *nodemgr) const
{
// Select the brightest of [light source, propagated light]
const ContentFeatures &f = nodemgr->get(*this);
u8 light = 0;
u8 light;
if(f.param_type == CPT_LIGHT)
{
if(bank == LIGHTBANK_DAY)
light = param1 & 0x0f;
else if(bank == LIGHTBANK_NIGHT)
light = (param1>>4)&0x0f;
else
assert(0);
}
if(f.light_source > light)
light = f.light_source;
return light;
light = bank == LIGHTBANK_DAY ? param1 & 0x0f : (param1 >> 4) & 0x0f;
else
light = 0;
return MYMAX(f.light_source, light);
}
bool MapNode::getLightBanks(u8 &lightday, u8 &lightnight, INodeDefManager *nodemgr) const

View File

@ -389,8 +389,8 @@ public:
virtual ~CNodeDefManager();
void clear();
virtual IWritableNodeDefManager *clone();
virtual const ContentFeatures& get(content_t c) const;
virtual const ContentFeatures& get(const MapNode &n) const;
inline virtual const ContentFeatures& get(content_t c) const;
inline virtual const ContentFeatures& get(const MapNode &n) const;
virtual bool getId(const std::string &name, content_t &result) const;
virtual content_t getId(const std::string &name) const;
virtual void getIds(const std::string &name, std::set<content_t> &result) const;
@ -530,16 +530,14 @@ IWritableNodeDefManager *CNodeDefManager::clone()
}
const ContentFeatures& CNodeDefManager::get(content_t c) const
inline const ContentFeatures& CNodeDefManager::get(content_t c) const
{
if (c < m_content_features.size())
return m_content_features[c];
else
return m_content_features[CONTENT_UNKNOWN];
return c < m_content_features.size()
? m_content_features[c] : m_content_features[CONTENT_UNKNOWN];
}
const ContentFeatures& CNodeDefManager::get(const MapNode &n) const
inline const ContentFeatures& CNodeDefManager::get(const MapNode &n) const
{
return get(n.getContent());
}

View File

@ -130,12 +130,12 @@ void NodeMetadataList::deSerialize(std::istream &is, IGameDef *gamedef)
{
u16 p16 = readU16(is);
v3s16 p(0,0,0);
p.Z += p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
p16 -= p.Z * MAP_BLOCKSIZE * MAP_BLOCKSIZE;
p.Y += p16 / MAP_BLOCKSIZE;
p16 -= p.Y * MAP_BLOCKSIZE;
p.X += p16;
v3s16 p;
p.Z = p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
p16 &= MAP_BLOCKSIZE * MAP_BLOCKSIZE - 1;
p.Y = p16 / MAP_BLOCKSIZE;
p16 &= MAP_BLOCKSIZE - 1;
p.X = p16;
if(m_data.find(p) != m_data.end())
{

View File

@ -96,12 +96,12 @@ void NodeTimerList::deSerialize(std::istream &is, u8 map_format_version)
{
u16 p16 = readU16(is);
v3s16 p(0,0,0);
p.Z += p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
p16 -= p.Z * MAP_BLOCKSIZE * MAP_BLOCKSIZE;
p.Y += p16 / MAP_BLOCKSIZE;
p16 -= p.Y * MAP_BLOCKSIZE;
p.X += p16;
v3s16 p;
p.Z = p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
p16 &= MAP_BLOCKSIZE * MAP_BLOCKSIZE - 1;
p.Y = p16 / MAP_BLOCKSIZE;
p16 &= MAP_BLOCKSIZE - 1;
p.X = p16;
NodeTimer t;
t.deSerialize(is);

View File

@ -371,6 +371,46 @@ v2u32 getDisplaySize();
v2u32 getWindowSize();
#endif
inline const char * getPlatformName()
{
return
#if defined(ANDROID)
"Android"
#elif defined(linux) || defined(__linux) || defined(__linux__)
"Linux"
#elif defined(_WIN32) || defined(_WIN64)
"Windows"
#elif defined(__DragonFly__) || defined(__FreeBSD__) || \
defined(__NetBSD__) || defined(__OpenBSD__)
"BSD"
#elif defined(__APPLE__) && defined(__MACH__)
#if TARGET_OS_MAC
"OSX"
#elif TARGET_OS_IPHONE
"iOS"
#else
"Apple"
#endif
#elif defined(_AIX)
"AIX"
#elif defined(__hpux)
"HP-UX"
#elif defined(__sun) && defined(__SVR4)
"Solaris"
#elif defined(__CYGWIN__)
"Cygwin"
#elif defined(__unix__) || defined(__unix)
#if defined(_POSIX_VERSION)
"Posix"
#else
"Unix"
#endif
#else
"?"
#endif
;
}
} // namespace porting
#ifdef __ANDROID__

View File

@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "filesys.h"
#include "log.h"
#include "mods.h"
#include "porting.h"
#include "util/string.h"
@ -98,6 +99,9 @@ ScriptApiBase::ScriptApiBase()
lua_pushstring(m_luastack, DIR_DELIM);
lua_setglobal(m_luastack, "DIR_DELIM");
lua_pushstring(m_luastack, porting::getPlatformName());
lua_setglobal(m_luastack, "PLATFORM");
m_server = NULL;
m_environment = NULL;
m_guiengine = NULL;

View File

@ -22,42 +22,31 @@ with this program; if not, write to the Free Software Foundation, Inc.,
void StaticObject::serialize(std::ostream &os)
{
char buf[12];
// type
buf[0] = type;
os.write(buf, 1);
writeU8(os, type);
// pos
writeV3S32((u8*)buf, v3s32(pos.X*1000,pos.Y*1000,pos.Z*1000));
os.write(buf, 12);
writeV3F1000(os, pos);
// data
os<<serializeString(data);
}
void StaticObject::deSerialize(std::istream &is, u8 version)
{
char buf[12];
// type
is.read(buf, 1);
type = buf[0];
type = readU8(is);
// pos
is.read(buf, 12);
v3s32 intp = readV3S32((u8*)buf);
pos.X = (f32)intp.X/1000;
pos.Y = (f32)intp.Y/1000;
pos.Z = (f32)intp.Z/1000;
pos = readV3F1000(is);
// data
data = deSerializeString(is);
}
void StaticObjectList::serialize(std::ostream &os)
{
char buf[12];
// version
buf[0] = 0;
os.write(buf, 1);
u8 version = 0;
writeU8(os, version);
// count
u16 count = m_stored.size() + m_active.size();
writeU16((u8*)buf, count);
os.write(buf, 2);
writeU16(os, count);
for(std::list<StaticObject>::iterator
i = m_stored.begin();
i != m_stored.end(); ++i)
@ -75,13 +64,10 @@ void StaticObjectList::serialize(std::ostream &os)
}
void StaticObjectList::deSerialize(std::istream &is)
{
char buf[12];
// version
is.read(buf, 1);
u8 version = buf[0];
u8 version = readU8(is);
// count
is.read(buf, 2);
u16 count = readU16((u8*)buf);
u16 count = readU16(is);
for(u16 i=0; i<count; i++)
{
StaticObject s_obj;

View File

@ -68,11 +68,11 @@ std::string deSerializeString(std::istream &is)
if(is.gcount() != 2)
throw SerializationError("deSerializeString: size not read");
u16 s_size = readU16((u8*)buf);
std::string s;
if(s_size == 0)
return "";
return s;
Buffer<char> buf2(s_size);
is.read(&buf2[0], s_size);
std::string s;
s.reserve(s_size);
s.append(&buf2[0], s_size);
return s;
@ -86,9 +86,9 @@ std::wstring deSerializeWideString(std::istream &is)
if(is.gcount() != 2)
throw SerializationError("deSerializeString: size not read");
u16 s_size = readU16((u8*)buf);
if(s_size == 0)
return L"";
std::wstring s;
if(s_size == 0)
return s;
s.reserve(s_size);
for(u32 i=0; i<s_size; i++)
{
@ -118,11 +118,11 @@ std::string deSerializeLongString(std::istream &is)
if(is.gcount() != 4)
throw SerializationError("deSerializeLongString: size not read");
u32 s_size = readU32((u8*)buf);
std::string s;
if(s_size == 0)
return "";
return s;
Buffer<char> buf2(s_size);
is.read(&buf2[0], s_size);
std::string s;
s.reserve(s_size);
s.append(&buf2[0], s_size);
return s;

View File

@ -21,9 +21,63 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#define UTIL_SERIALIZE_HEADER
#include "../irrlichttypes_bloated.h"
#include "config.h"
#if HAVE_ENDIAN_H
#include <endian.h>
#include <string.h> // for memcpy
#endif
#include <iostream>
#include <string>
#define FIXEDPOINT_FACTOR 1000.0f
#define FIXEDPOINT_INVFACTOR (1.0f/FIXEDPOINT_FACTOR)
#if HAVE_ENDIAN_H
// use machine native byte swapping routines
// Note: memcpy below is optimized out by modern compilers
inline void writeU64(u8* data, u64 i)
{
u64 val = htobe64(i);
memcpy(data, &val, 8);
}
inline void writeU32(u8* data, u32 i)
{
u32 val = htobe32(i);
memcpy(data, &val, 4);
}
inline void writeU16(u8* data, u16 i)
{
u16 val = htobe16(i);
memcpy(data, &val, 2);
}
inline u64 readU64(const u8* data)
{
u64 val;
memcpy(&val, data, 8);
return be64toh(val);
}
inline u32 readU32(const u8* data)
{
u32 val;
memcpy(&val, data, 4);
return be32toh(val);
}
inline u16 readU16(const u8* data)
{
u16 val;
memcpy(&val, data, 2);
return be16toh(val);
}
#else
// generic byte-swapping implementation
inline void writeU64(u8 *data, u64 i)
{
data[0] = ((i>>56)&0xff);
@ -50,11 +104,6 @@ inline void writeU16(u8 *data, u16 i)
data[1] = ((i>> 0)&0xff);
}
inline void writeU8(u8 *data, u8 i)
{
data[0] = ((i>> 0)&0xff);
}
inline u64 readU64(const u8 *data)
{
return ((u64)data[0]<<56) | ((u64)data[1]<<48)
@ -73,6 +122,13 @@ inline u16 readU16(const u8 *data)
return (data[0]<<8) | (data[1]<<0);
}
#endif
inline void writeU8(u8 *data, u8 i)
{
data[0] = ((i>> 0)&0xff);
}
inline u8 readU8(const u8 *data)
{
return (data[0]<<0);
@ -100,10 +156,10 @@ inline s8 readS8(const u8 *data){
}
inline void writeF1000(u8 *data, f32 i){
writeS32(data, i*1000);
writeS32(data, i*FIXEDPOINT_FACTOR);
}
inline f32 readF1000(const u8 *data){
return (f32)readS32(data)/1000.;
return (f32)readS32(data)*FIXEDPOINT_INVFACTOR;
}
inline void writeV3S32(u8 *data, v3s32 p)
@ -195,20 +251,12 @@ inline v3s16 readV3S16(const u8 *data)
inline void writeARGB8(u8 *data, video::SColor p)
{
writeU8(&data[0], p.getAlpha());
writeU8(&data[1], p.getRed());
writeU8(&data[2], p.getGreen());
writeU8(&data[3], p.getBlue());
writeU32(data, p.color);
}
inline video::SColor readARGB8(const u8 *data)
{
video::SColor p(
readU8(&data[0]),
readU8(&data[1]),
readU8(&data[2]),
readU8(&data[3])
);
video::SColor p(readU32(data));
return p;
}
@ -218,7 +266,7 @@ inline video::SColor readARGB8(const u8 *data)
inline void writeU8(std::ostream &os, u8 p)
{
char buf[1] = {0};
char buf[1];
writeU8((u8*)buf, p);
os.write(buf, 1);
}
@ -231,7 +279,7 @@ inline u8 readU8(std::istream &is)
inline void writeU16(std::ostream &os, u16 p)
{
char buf[2] = {0};
char buf[2];
writeU16((u8*)buf, p);
os.write(buf, 2);
}
@ -244,7 +292,7 @@ inline u16 readU16(std::istream &is)
inline void writeU32(std::ostream &os, u32 p)
{
char buf[4] = {0};
char buf[4];
writeU32((u8*)buf, p);
os.write(buf, 4);
}
@ -257,46 +305,34 @@ inline u32 readU32(std::istream &is)
inline void writeS32(std::ostream &os, s32 p)
{
char buf[4] = {0};
writeS32((u8*)buf, p);
os.write(buf, 4);
writeU32(os, (u32) p);
}
inline s32 readS32(std::istream &is)
{
char buf[4] = {0};
is.read(buf, 4);
return readS32((u8*)buf);
return (s32)readU32(is);
}
inline void writeS16(std::ostream &os, s16 p)
{
char buf[2] = {0};
writeS16((u8*)buf, p);
os.write(buf, 2);
writeU16(os, (u16) p);
}
inline s16 readS16(std::istream &is)
{
char buf[2] = {0};
is.read(buf, 2);
return readS16((u8*)buf);
return (s16)readU16(is);
}
inline void writeS8(std::ostream &os, s8 p)
{
char buf[1] = {0};
writeS8((u8*)buf, p);
os.write(buf, 1);
writeU8(os, (u8) p);
}
inline s8 readS8(std::istream &is)
{
char buf[1] = {0};
is.read(buf, 1);
return readS8((u8*)buf);
return (s8)readU8(is);
}
inline void writeF1000(std::ostream &os, f32 p)
{
char buf[4] = {0};
char buf[4];
writeF1000((u8*)buf, p);
os.write(buf, 4);
}
@ -322,7 +358,7 @@ inline v3f readV3F1000(std::istream &is)
inline void writeV2F1000(std::ostream &os, v2f p)
{
char buf[8] = {0};
char buf[8];
writeV2F1000((u8*)buf, p);
os.write(buf, 8);
}
@ -335,7 +371,7 @@ inline v2f readV2F1000(std::istream &is)
inline void writeV2S16(std::ostream &os, v2s16 p)
{
char buf[4] = {0};
char buf[4];
writeV2S16((u8*)buf, p);
os.write(buf, 4);
}
@ -348,7 +384,7 @@ inline v2s16 readV2S16(std::istream &is)
inline void writeV2S32(std::ostream &os, v2s32 p)
{
char buf[8] = {0};
char buf[8];
writeV2S32((u8*)buf, p);
os.write(buf, 8);
}
@ -361,7 +397,7 @@ inline v2s32 readV2S32(std::istream &is)
inline void writeV3S16(std::ostream &os, v3s16 p)
{
char buf[6] = {0};
char buf[6];
writeV3S16((u8*)buf, p);
os.write(buf, 6);
}
@ -374,7 +410,7 @@ inline v3s16 readV3S16(std::istream &is)
inline void writeARGB8(std::ostream &os, video::SColor p)
{
char buf[4] = {0};
char buf[4];
writeARGB8((u8*)buf, p);
os.write(buf, 4);
}

View File

@ -142,7 +142,7 @@ void VoxelManipulator::print(std::ostream &o, INodeDefManager *ndef,
}
}
void VoxelManipulator::addArea(VoxelArea area)
void VoxelManipulator::addArea(const VoxelArea &area)
{
// Cancel if requested area has zero volume
if(area.getExtent() == v3s16(0,0,0))
@ -310,7 +310,8 @@ void VoxelManipulator::unspreadLight(enum LightBank bank, v3s16 p, u8 oldlight,
v3s16(-1,0,0), // left
};
addArea(VoxelArea(p - v3s16(1,1,1), p + v3s16(1,1,1)));
VoxelArea voxel_area(p - v3s16(1,1,1), p + v3s16(1,1,1));
addArea(voxel_area);
// Loop through 6 neighbors
for(u16 i=0; i<6; i++)
@ -515,7 +516,8 @@ void VoxelManipulator::spreadLight(enum LightBank bank, v3s16 p,
v3s16(-1,0,0), // left
};
addArea(VoxelArea(p - v3s16(1,1,1), p + v3s16(1,1,1)));
VoxelArea voxel_area(p - v3s16(1,1,1), p + v3s16(1,1,1));
addArea(voxel_area);
u32 i = m_area.index(p);
@ -619,7 +621,8 @@ void VoxelManipulator::spreadLight(enum LightBank bank,
{
v3s16 pos = *j;
addArea(VoxelArea(pos - v3s16(1,1,1), pos + v3s16(1,1,1)));
VoxelArea voxel_area(pos - v3s16(1,1,1), pos + v3s16(1,1,1));
addArea(voxel_area);
u32 i = m_area.index(pos);

View File

@ -80,7 +80,7 @@ public:
Modifying methods
*/
void addArea(VoxelArea &a)
void addArea(const VoxelArea &a)
{
if(getExtent() == v3s16(0,0,0))
{
@ -94,7 +94,7 @@ public:
if(a.MaxEdge.Y > MaxEdge.Y) MaxEdge.Y = a.MaxEdge.Y;
if(a.MaxEdge.Z > MaxEdge.Z) MaxEdge.Z = a.MaxEdge.Z;
}
void addPoint(v3s16 p)
void addPoint(const v3s16 &p)
{
if(getExtent() == v3s16(0,0,0))
{
@ -111,7 +111,7 @@ public:
}
// Pad with d nodes
void pad(v3s16 d)
void pad(const v3s16 &d)
{
MinEdge -= d;
MaxEdge += d;
@ -366,7 +366,8 @@ public:
*/
MapNode getNode(v3s16 p)
{
addArea(p);
VoxelArea voxel_area(p);
addArea(voxel_area);
if(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA)
{
@ -383,7 +384,8 @@ public:
}
MapNode getNodeNoEx(v3s16 p)
{
addArea(p);
VoxelArea voxel_area(p);
addArea(voxel_area);
if(m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA)
{
@ -417,7 +419,8 @@ public:
}
MapNode & getNodeRef(v3s16 p)
{
addArea(p);
VoxelArea voxel_area(p);
addArea(voxel_area);
if(getFlagsRefUnsafe(p) & VOXELFLAG_NO_DATA)
{
/*dstream<<"EXCEPT: VoxelManipulator::getNode(): "
@ -432,7 +435,8 @@ public:
}
void setNode(v3s16 p, const MapNode &n)
{
addArea(p);
VoxelArea voxel_area(p);
addArea(voxel_area);
m_data[m_area.index(p)] = n;
m_flags[m_area.index(p)] &= ~VOXELFLAG_NO_DATA;
@ -499,7 +503,7 @@ public:
void print(std::ostream &o, INodeDefManager *nodemgr,
VoxelPrintMode mode=VOXELPRINT_MATERIAL);
void addArea(VoxelArea area);
void addArea(const VoxelArea &area);
/*
Copy data and set flags to 0