From 350963852cf3bd23758e4d024ae85e625fd3b591 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 21 Mar 2024 22:50:42 +0100 Subject: [PATCH] landscape structure is now based on BCC honeycomb --- config.cpp | 7 ++++--- landgen.cpp | 27 ++++++++++++++++++++------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/config.cpp b/config.cpp index 040c50ad..744571fd 100644 --- a/config.cpp +++ b/config.cpp @@ -3332,9 +3332,10 @@ EX int config3 = addHook(hooks_configfile, 100, [] { "land size in randomwalk mode", "The average size of a land in randomwalk mode.", 'R') ->set_reaction([] { if(game_active) { stop_game(); start_game(); } }); - param_i(landscape_div, "landscape_div", 32)->editable(1, 100, 1, - "land size in landscape mode", - "The bigger the value, the larger the lands.", 'R') + param_i(landscape_div, "landscape_div")->editable(1, 100, 1, + "land size in landscape structure", + "Each cell gets three coordinates, each of which change smoothly, using the same method as used for the generation of landscapes e.g. in Dragon Chasms. " + "Then, we find a cell of the bitruncated cubic honeycomb at these cordinates, and this cell determines which land it is. The bigger the value, the larger the lands.", 'R') ->set_reaction([] { if(game_active) { stop_game(); start_game(); } }); param_f(global_boundary_ratio, "global_boundary_ratio") diff --git a/landgen.cpp b/landgen.cpp index f277e100..ed46eeb4 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -2900,7 +2900,8 @@ EX void share_land(cell *c, cell *c2) { c->land = c2->land; } -EX int landscape_div = 32; +// odd landscape_div are better +EX int landscape_div = 25; EX void set_land_for_geometry(cell *c) { if(!c->land && isize(currentlands)) { @@ -2909,12 +2910,24 @@ EX void set_land_for_geometry(cell *c) { return; } if(land_structure == lsLandscape) { - if(landscape_div < 0) landscape_div = 0; - int shift = landscape_div / 2; - int a0 = getCdata(c, 0) + shift; - int a1 = getCdata(c, 1) + shift; - int a2 = getCdata(c, 2) + shift; - eLand& l = landscape_lands[{a0/landscape_div,a1/landscape_div,a2/landscape_div}]; + if(landscape_div < 0) landscape_div = 1; + array a; + for(int i=0; i<3; i++) a[i] = getCdata(c, i); + auto ca = a; + auto& ld = landscape_div; + auto ld2 = ld * 2; + int sh = 0; + for(int i=0; i<3; i++) { + int x = a[i]; + x = gmod(x, ld2); + if(x >= ld) sh += x - ld; + else sh += ld - 1 - x; + } + for(int i=0; i<3; i++) { + if(sh * 2 < ld * 3) a[i] = gdiv(a[i], ld2)*2+1; + else a[i] = gdiv(a[i]+ld, ld2)*2; + } + eLand& l = landscape_lands[{a[0], a[1], a[2]}]; if(l == laNone) l = random_land(); setland(c, l); return;