diff options
author | paramat <paramat@users.noreply.github.com> | 2018-02-23 13:42:48 +0000 |
---|---|---|
committer | paramat <mat.gregory@virginmedia.com> | 2018-02-27 19:39:05 +0000 |
commit | c610643c4ca1d1c32ca3e400b5cb055f25401107 (patch) | |
tree | 73e1efd9fa3ba3c8269262d221a760e25a2b91e1 /src | |
parent | 6c9df2ffa7ee81a05b28fdd6123a926abd284c72 (diff) | |
download | minetest-c610643c4ca1d1c32ca3e400b5cb055f25401107.tar.gz minetest-c610643c4ca1d1c32ca3e400b5cb055f25401107.tar.bz2 minetest-c610643c4ca1d1c32ca3e400b5cb055f25401107.zip |
Place schematic (on vmanip): Enable use of 'place center' flags
For 'place schematic' and 'place schematic on vmanip' APIs.
Fix 'place center' code to properly centre schematics.
Fix some comments.
Diffstat (limited to 'src')
-rw-r--r-- | src/mapgen/mg_schematic.cpp | 16 | ||||
-rw-r--r-- | src/script/lua_api/l_mapgen.cpp | 19 | ||||
-rw-r--r-- | src/script/lua_api/l_mapgen.h | 11 |
3 files changed, 30 insertions, 16 deletions
diff --git a/src/mapgen/mg_schematic.cpp b/src/mapgen/mg_schematic.cpp index fc77194ac..ba619b2e0 100644 --- a/src/mapgen/mg_schematic.cpp +++ b/src/mapgen/mg_schematic.cpp @@ -188,15 +188,15 @@ bool Schematic::placeOnVManip(MMVManip *vm, v3s16 p, u32 flags, //// Adjust placement position if necessary if (flags & DECO_PLACE_CENTER_X) - p.X -= (s.X + 1) / 2; + p.X -= (s.X - 1) / 2; if (flags & DECO_PLACE_CENTER_Y) - p.Y -= (s.Y + 1) / 2; + p.Y -= (s.Y - 1) / 2; if (flags & DECO_PLACE_CENTER_Z) - p.Z -= (s.Z + 1) / 2; + p.Z -= (s.Z - 1) / 2; blitToVManip(vm, p, rot, force_place); - return vm->m_area.contains(VoxelArea(p, p + s - v3s16(1,1,1))); + return vm->m_area.contains(VoxelArea(p, p + s - v3s16(1, 1, 1))); } void Schematic::placeOnMap(ServerMap *map, v3s16 p, u32 flags, @@ -219,16 +219,16 @@ void Schematic::placeOnMap(ServerMap *map, v3s16 p, u32 flags, //// Adjust placement position if necessary if (flags & DECO_PLACE_CENTER_X) - p.X -= (s.X + 1) / 2; + p.X -= (s.X - 1) / 2; if (flags & DECO_PLACE_CENTER_Y) - p.Y -= (s.Y + 1) / 2; + p.Y -= (s.Y - 1) / 2; if (flags & DECO_PLACE_CENTER_Z) - p.Z -= (s.Z + 1) / 2; + p.Z -= (s.Z - 1) / 2; //// Create VManip for effected area, emerge our area, modify area //// inside VManip, then blit back. v3s16 bp1 = getNodeBlockPos(p); - v3s16 bp2 = getNodeBlockPos(p + s - v3s16(1,1,1)); + v3s16 bp2 = getNodeBlockPos(p + s - v3s16(1, 1, 1)); MMVManip vm(map); vm.initialEmerge(bp1, bp2); diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index 775f4a76d..ccbe9a4b0 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -1529,7 +1529,8 @@ int ModApiMapgen::l_create_schematic(lua_State *L) } -// place_schematic(p, schematic, rotation, replacement) +// place_schematic(p, schematic, rotation, +// replacements, force_placement, flagstring) int ModApiMapgen::l_place_schematic(lua_State *L) { MAP_LOCK_REQUIRED; @@ -1565,12 +1566,19 @@ int ModApiMapgen::l_place_schematic(lua_State *L) return 0; } - schem->placeOnMap(map, p, 0, (Rotation)rot, force_placement); + //// Read flags + u32 flags = 0; + read_flags(L, 6, flagdesc_deco, &flags, NULL); + + schem->placeOnMap(map, p, flags, (Rotation)rot, force_placement); lua_pushboolean(L, true); return 1; } + +// place_schematic_on_vmanip(vm, p, schematic, rotation, +// replacements, force_placement, flagstring) int ModApiMapgen::l_place_schematic_on_vmanip(lua_State *L) { NO_MAP_LOCK_REQUIRED; @@ -1606,13 +1614,18 @@ int ModApiMapgen::l_place_schematic_on_vmanip(lua_State *L) return 0; } + //// Read flags + u32 flags = 0; + read_flags(L, 7, flagdesc_deco, &flags, NULL); + bool schematic_did_fit = schem->placeOnVManip( - vm, p, 0, (Rotation)rot, force_placement); + vm, p, flags, (Rotation)rot, force_placement); lua_pushboolean(L, schematic_did_fit); return 1; } + // serialize_schematic(schematic, format, options={...}) int ModApiMapgen::l_serialize_schematic(lua_State *L) { diff --git a/src/script/lua_api/l_mapgen.h b/src/script/lua_api/l_mapgen.h index f6a821b4e..44073620b 100644 --- a/src/script/lua_api/l_mapgen.h +++ b/src/script/lua_api/l_mapgen.h @@ -70,10 +70,10 @@ private: // get_noiseparam_defaults(name) static int l_get_noiseparams(lua_State *L); - // set_gen_notify(flagstring) + // set_gen_notify(flags, {deco_id_table}) static int l_set_gen_notify(lua_State *L); - // set_gen_notify(flagstring) + // get_gen_notify() static int l_get_gen_notify(lua_State *L); // register_biome({lots of stuff}) @@ -109,11 +109,12 @@ private: // create_schematic(p1, p2, probability_list, filename) static int l_create_schematic(lua_State *L); - // place_schematic(p, schematic, rotation, replacements, force_placement) + // place_schematic(p, schematic, rotation, + // replacements, force_placement, flagstring) static int l_place_schematic(lua_State *L); - // place_schematic_on_vmanip(vm, p, schematic, - // rotation, replacements, force_placement) + // place_schematic_on_vmanip(vm, p, schematic, rotation, + // replacements, force_placement, flagstring) static int l_place_schematic_on_vmanip(lua_State *L); // serialize_schematic(schematic, format, options={...}) |