From 58ff110908237ba91c6a1b49fd128334e2ddff34 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Wed, 19 Jul 2017 21:00:27 +0200 Subject: [PATCH] fix remip for some border cases in editing some cases need a little more area remipped - and in edit mode, we don't need to be stingy --- source/src/editing.cpp | 12 ++++-------- source/src/protos.h | 1 + source/src/world.cpp | 10 ++++++++++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/source/src/editing.cpp b/source/src/editing.cpp index aaa77004..40f5eda7 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -10,7 +10,7 @@ bool editmode = false; vector sels; -#define loopselxy(sel, b) { makeundo(sel); loop(x,(sel).xs) loop(y,(sel).ys) { sqr *s = S((sel).x+x, (sel).y+y); b; } remip(sel); } +#define loopselxy(sel, b) { makeundo(sel); loop(x,(sel).xs) loop(y,(sel).ys) { sqr *s = S((sel).x+x, (sel).y+y); b; } remipgenerous(sel); } #define loopselsxy(b) { loopv(sels) loopselxy(sels[i], b); } int cx, cy, ch; @@ -934,7 +934,6 @@ COMMAND(equalize, "i"); void setvdeltaxy(int delta, block &sel) { loopselxy(sel, s->vdelta = max(s->vdelta+delta, 0)); - remipmore(sel); } void setvdelta(int *delta) @@ -973,7 +972,6 @@ void archxy(int sidedelta, int *averts, block &sel) sel.xs>sel.ys ? (averts[x] + (y==0 || y==sel.ys-1 ? sidedelta : 0)) : (averts[y] + (x==0 || x==sel.xs-1 ? sidedelta : 0))); - remipmore(sel); } void arch(int *sidedelta) @@ -1002,7 +1000,6 @@ void slopexy(int xd, int yd, block &sel) sel.xs++; sel.ys++; loopselxy(sel, s->vdelta = xd * x + yd * y + off); - remipmore(sel); } void slope(int *xd, int *yd) @@ -1022,7 +1019,6 @@ void stairsxy(int xd, int yd, block &sel) { int off = xd || yd ? 1 : 0, xo = xd < 0 ? 1 - sel.xs : 0, yo = yd < 0 ? 1 - sel.ys : 0; loopselxy(sel, s->floor += (xd ? (x + xo) / xd : 0) + (yd ? (y + yo) / yd : 0) + off); - remipmore(sel); } void stairs(int *xd, int *yd) @@ -1051,7 +1047,7 @@ void perlin(int *scale, int *seed, int *psize) perlinarea(sel, *scale, *seed, *psize); sel.xs++; sel.ys++; - remipmore(sel); + remipgenerous(sel); if(!enlargearchslopeselections) { sel.xs--; sel.ys--; } } } @@ -1170,7 +1166,7 @@ void selfliprotate(block &sel, int dir) for(y = y2; y >= y1; y--) for(x = x1; x <= x2; x++) *S(x,y) = *q++; break; } - remipmore(sel); + remipgenerous(sel); freeblock(org); } @@ -1258,7 +1254,7 @@ void selectionwalk(char *action, char *beginsel, char *endsel) netblockpaste(*b, sel.x, sel.y, true); freeblockp(b); } - remip(sel); + remipgenerous(sel); } if(*endsel) execute(endsel); } diff --git a/source/src/protos.h b/source/src/protos.h index 290603ff..ad7b1364 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -625,6 +625,7 @@ extern bool worldbordercheck(int x1, int x2, int y1, int y2, int z1, int z2); extern bool empty_world(int factor, bool force); extern void remip(const block &b, int level = 0); extern void remipmore(const block &b, int level = 0); +extern void remipgenerous(const block &b); extern bool pinnedclosestent; extern int closestent(); extern void deletesoundentity(entity &e); diff --git a/source/src/world.cpp b/source/src/world.cpp index 577c0ffd..873e0896 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -116,6 +116,16 @@ void remipmore(const block &b, int level) remip(bb, level); } +void remipgenerous(const block &b) +{ + block bb = b; + if(bb.x>1) bb.x--; + if(bb.y>1) bb.y--; + bb.xs = min(ssize - bb.x - 1, bb.xs + 2); + bb.ys = min(ssize - bb.y - 1, bb.ys + 2); + remip(bb); +} + static int clentsel = 0, clenttype = NOTUSED, pinnedent = -1; bool pinnedclosestent = false, pointingatents = false;