From fdf83820f2908fd63e7a342ccd579d186f409c38 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Thu, 21 Mar 2024 20:15:45 +0100 Subject: [PATCH] ls:: landscape land structure --- bigstuff.cpp | 3 +++ config.cpp | 7 ++++++- landgen.cpp | 16 ++++++++++++++-- landlock.cpp | 9 +++++++-- menus.cpp | 2 ++ yendor.cpp | 8 ++++++++ 6 files changed, 40 insertions(+), 5 deletions(-) diff --git a/bigstuff.cpp b/bigstuff.cpp index a9f14955..8517ef35 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -1132,6 +1132,7 @@ EX void setLandSphere(cell *c) { vector euland; map euland3; map euland3_hash; +EX map, eLand> landscape_lands; EX eLand& get_euland(int c) { euland.resize(max_vec); @@ -1144,6 +1145,8 @@ EX void clear_euland(eLand first) { if(!nonisotropic) euland[0] = euland[1] = euland[max_vec-1] = first; euland3.clear(); euland3[0] = first; + landscape_lands.clear(); + landscape_lands[{0,0,0}] = first; } bool valid_wall_at(int c) { diff --git a/config.cpp b/config.cpp index 7af7b662..040c50ad 100644 --- a/config.cpp +++ b/config.cpp @@ -3330,7 +3330,12 @@ EX int config3 = addHook(hooks_configfile, 100, [] { "larger values might produce horodisks with errors or crashing into each other.", 'H'); param_i(randomwalk_size, "randomwalk_size", 10)->editable(2, 100, 1, "land size in randomwalk mode", - "The average size of a land in randomwalk mode.", 'R'); + "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') + ->set_reaction([] { if(game_active) { stop_game(); start_game(); } }); param_f(global_boundary_ratio, "global_boundary_ratio") ->editable(0, 5, 0.1, "Width of cell boundaries", diff --git a/landgen.cpp b/landgen.cpp index 2bb047d8..f277e100 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -2900,13 +2900,25 @@ EX void share_land(cell *c, cell *c2) { c->land = c2->land; } -EX void set_land_for_geometry(cell *c) { +EX int landscape_div = 32; +EX void set_land_for_geometry(cell *c) { if(!c->land && isize(currentlands)) { if(land_structure == lsTotalChaos) { setland(c, random_land()); 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(l == laNone) l = random_land(); + setland(c, l); + return; + } /* note: Nil patched chaos done in setLandNil */ if(ls::patched_chaos() && (cgflags & qFRACTAL)) { share_land(c, fractal_rep(c)); @@ -3008,7 +3020,7 @@ EX void setdist(cell *c, int d, cell *from) { } #endif - if(!c->land && from && (WDIM == 3 || !among(from->land, laBarrier, laElementalWall, laHauntedWall, laOceanWall)) && !quotient && ls::chaoticity() < 60) { + if(!c->land && from && (WDIM == 3 || !among(from->land, laBarrier, laElementalWall, laHauntedWall, laOceanWall)) && !quotient && ls::chaoticity() < 60 && land_structure != lsLandscape) { if(!hasbardir(c)) setland(c, from->land); } if(c->land == laTemple && ls::any_order()) setland(c, laRlyeh); diff --git a/landlock.cpp b/landlock.cpp index cb32b452..5d7de5d3 100644 --- a/landlock.cpp +++ b/landlock.cpp @@ -81,7 +81,7 @@ EX eLand firstland = laIce; EX eLand specialland = laIce; #if HDR -enum eLandStructure { lsNiceWalls, lsChaos, lsPatchedChaos, lsTotalChaos, lsChaosRW, lsWallChaos, lsSingle, lsNoWalls, lsHorodisks, lsVoronoi, lsGUARD }; +enum eLandStructure { lsNiceWalls, lsChaos, lsPatchedChaos, lsTotalChaos, lsChaosRW, lsWallChaos, lsSingle, lsNoWalls, lsHorodisks, lsVoronoi, lsLandscape, lsGUARD }; #endif EX eLandStructure land_structure; @@ -90,7 +90,7 @@ EX namespace ls { EX bool single() { return land_structure == lsSingle; } -EX bool any_chaos() { return among(land_structure, lsChaos, lsPatchedChaos, lsWallChaos, lsTotalChaos, lsChaosRW); } +EX bool any_chaos() { return among(land_structure, lsChaos, lsPatchedChaos, lsWallChaos, lsTotalChaos, lsChaosRW, lsLandscape); } EX bool std_chaos() { return land_structure == lsChaos; } EX bool wall_chaos() { return land_structure == lsWallChaos; } EX bool patched_chaos() { return land_structure == lsPatchedChaos; } @@ -110,6 +110,7 @@ EX int chaoticity() { if(land_structure == lsChaosRW) return 80; if(land_structure == lsPatchedChaos) return 60; if(land_structure == lsChaos) return 40; + if(land_structure == lsLandscape) return 35; if(land_structure == lsWallChaos) return 30; if(land_structure == lsVoronoi) return 20; if(land_structure == lsSingle) return 0; @@ -139,6 +140,8 @@ EX string land_structure_name(bool which) { return XLAT("horodisks"); case lsVoronoi: return XLAT("ideal Voronoi"); + case lsLandscape: + return XLAT("landscape"); case lsNoWalls: return XLAT("wall-less"); default: @@ -151,6 +154,8 @@ EX void fix_land_structure_choice() { if(land_structure != lsTotalChaos && land_structure != lsChaosRW) land_structure = lsSingle; } + if(land_structure == lsLandscape && !geometry_supports_cdata()) + land_structure = lsChaosRW; if(tactic::on || princess::challenge) land_structure = lsSingle; if(yendor::on) diff --git a/menus.cpp b/menus.cpp index b7dba73a..691a8f56 100644 --- a/menus.cpp +++ b/menus.cpp @@ -464,6 +464,8 @@ EX void show_chaos() { add_edit(horodisk_from); else if(land_structure == lsChaosRW) add_edit(randomwalk_size); + else if(land_structure == lsLandscape) + add_edit(landscape_div); else dialog::addBreak(100); dialog::addBack(); diff --git a/yendor.cpp b/yendor.cpp index a225352a..4d23ed46 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -1004,6 +1004,10 @@ EX void save_mode_data(hstream& f) { f.write(5); f.write(randomwalk_size); } + if(land_structure == lsLandscape) { + f.write(6); + f.write(landscape_div); + } } EX void load_mode_data_with_zero(hstream& f) { @@ -1062,6 +1066,10 @@ EX void load_mode_data_with_zero(hstream& f) { randomwalk_size = f.get(); break; + case 6: + landscape_div = f.get(); + break; + default: throw hstream_exception(); }