aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2015-04-21 12:09:32 +0100
committerparamat <mat.gregory@virginmedia.com>2015-04-23 02:44:25 +0100
commitac6efa25390cbe522ac4fb3efc68c22081a023c4 (patch)
tree4873fd9f1848375ff665b5a767376cfee0004729 /src
parentccc09abc2d4a712c17de833d52cb5aa91b7bf980 (diff)
downloadminetest-ac6efa25390cbe522ac4fb3efc68c22081a023c4.tar.gz
minetest-ac6efa25390cbe522ac4fb3efc68c22081a023c4.tar.bz2
minetest-ac6efa25390cbe522ac4fb3efc68c22081a023c4.zip
DecoSchematic: Fix missing trees in rough terrain
Move place_on check to before place_center_x/y/z displacement of p Reduce displacement of p by place_center_x/y/z flags to correctly position schematics
Diffstat (limited to 'src')
-rw-r--r--src/mg_decoration.cpp21
1 files changed, 9 insertions, 12 deletions
diff --git a/src/mg_decoration.cpp b/src/mg_decoration.cpp
index ec2d3e8b0..84f60b029 100644
--- a/src/mg_decoration.cpp
+++ b/src/mg_decoration.cpp
@@ -324,26 +324,23 @@ size_t DecoSchematic::generate(MMVManip *vm, PseudoRandom *pr, v3s16 p)
if (schematic == NULL)
return 0;
- if (flags & DECO_PLACE_CENTER_X)
- p.X -= (schematic->size.X + 1) / 2;
- if (flags & DECO_PLACE_CENTER_Y)
- p.Y -= (schematic->size.Y + 1) / 2;
- if (flags & DECO_PLACE_CENTER_Z)
- p.Z -= (schematic->size.Z + 1) / 2;
-
- bool force_placement = (flags & DECO_FORCE_PLACEMENT);
-
- if (!vm->m_area.contains(p))
- return 0;
-
u32 vi = vm->m_area.index(p);
content_t c = vm->m_data[vi].getContent();
if (!CONTAINS(c_place_on, c))
return 0;
+ if (flags & DECO_PLACE_CENTER_X)
+ p.X -= (schematic->size.X - 1) / 2;
+ if (flags & DECO_PLACE_CENTER_Y)
+ p.Y -= (schematic->size.Y - 1) / 2;
+ if (flags & DECO_PLACE_CENTER_Z)
+ p.Z -= (schematic->size.Z - 1) / 2;
+
Rotation rot = (rotation == ROTATE_RAND) ?
(Rotation)pr->range(ROTATE_0, ROTATE_270) : rotation;
+ bool force_placement = (flags & DECO_FORCE_PLACEMENT);
+
schematic->blitToVManip(p, vm, rot, force_placement, m_ndef);
return 1;