From d4247e7b133cc1842bba053b03ba94b8a7eb62ad Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Mon, 18 Sep 2023 14:34:46 +0200 Subject: [PATCH] ls:: (reverse) ivory tower joins the game again in H/V --- celldrawer.cpp | 3 +- complex.cpp | 100 ++++++++++++++++++++++--------------------------- landlock.cpp | 2 +- mapeffects.cpp | 2 + system.cpp | 3 +- 5 files changed, 51 insertions(+), 59 deletions(-) diff --git a/celldrawer.cpp b/celldrawer.cpp index 67ce8c28..b71eb484 100644 --- a/celldrawer.cpp +++ b/celldrawer.cpp @@ -1335,7 +1335,7 @@ void celldrawer::set_land_floor(const shiftmatrix& Vf) { if(shmup::on || GDIM == 3) shmup_gravity_floor(); else - set_towerfloor(); + set_towerfloor(ls::hv_structure() ? celldistAltPlus : coastvalEdge); break; case laBrownian: @@ -1960,6 +1960,7 @@ void celldrawer::check_rotations() { int side = 0; if(cwt.at->land == laDungeon) side = 2; if(cwt.at->land == laWestWall) side = 1; + if(cwt.at->land == laIvoryTower && ls::hv_structure()) side = 2; if(models::do_rotate >= 1) use_if_less(edgeDepth(c), edgeDepth(old), cwt.at->landparam / 10., side); } diff --git a/complex.cpp b/complex.cpp index 77bcae59..406cf98c 100644 --- a/complex.cpp +++ b/complex.cpp @@ -3999,9 +3999,15 @@ EX } EX namespace dungeon { + /* use coastvalEdge normally, but celldistAlt in hv_structure */ + bool cvfun(cell *c) { + if(ls::hv_structure()) return celldistAlt(c); + return coastvalEdge(c); + } + void towerError(cell *c) { // only care in the standard geometry -- weird ones are intentionally left buggy - if(!weirdhyperbolic && !sphere && !quotient) + if(!weirdhyperbolic && !sphere && !quotient && !ls::hv_structure()) raiseBuggyGeneration(c, "ivory tower/dungeon generation error"); } @@ -4063,15 +4069,17 @@ EX namespace dungeon { if(cnt) c->wall = waPlatform; else if(below && coastvalEdge(c) < 3) c->wall = waPlatform; } - + else if(true) { - + + auto cvfun = ls::hv_structure() ? celldistAlt : coastvalEdge; + cell *c2 = c; cell *c3 = c; bool rdepths[5]; for(int i=0; i<5; i++) { - if(coastvalEdge(c2) == 0) { + if(cvfun(c2) == 0) { rdepths[i] = false; } else { @@ -4084,50 +4092,35 @@ EX namespace dungeon { if(c2) generate_around(c2); if(c3) generate_around(c3); - if(ls::horodisk_structure()) { - c2 = ts::left_child(c2, celldistAlt); - c3 = ts::right_child(c3, celldistAlt); - if(!c2 || !c3) return; - } - else { - c2 = ts::left_parent(c2, coastvalEdge); - c3 = ts::right_parent(c3, coastvalEdge); - if(!c2) { towerError(c); return; } - if(!c3) { towerError(c); return; } - } + c2 = ts::left_parent(c2, cvfun); + c3 = ts::right_parent(c3, cvfun); + if(!c2) { towerError(c); return; } + if(!c3) { towerError(c); return; } } } if(rdepths[3]) { c->wall = waPlatform; - // if(!c4->item) c4->item = itPalace; } - else if(!rdepths[2] && !rdepths[4] && !rdepths[1]) { + if(!rdepths[2] && !rdepths[4] && !rdepths[1]) { c2 = c; c3 = c; generate_around(c); - cell *c4 = ts::left_of(c, coastvalEdge); - cell *c5 = ts::right_of(c, coastvalEdge); + cell *c4 = ts::left_of(c, cvfun); + cell *c5 = ts::right_of(c, cvfun); for(int i=0; i<3; i++) { if(coastvalEdge(c2) == 0) break; for(cell *cx: {c2, c3, c4, c5}) if(cx) generate_around(cx); - if(c2 && c4 && c4->landflags == 3 && c2->landflags != 3 && c4 == ts::left_of(c2, coastvalEdge)) + if(c2 && c4 && c4->landflags == 3 && c2->landflags != 3 && c4 == ts::left_of(c2, cvfun)) c->wall = waLadder; - if(c3 && c5 && c5->landflags == 3 && c3->landflags != 3 && c5 == ts::right_of(c3, coastvalEdge)) + if(c3 && c5 && c5->landflags == 3 && c3->landflags != 3 && c5 == ts::right_of(c3, cvfun)) c->wall = waLadder; buildEquidistant(c4); buildEquidistant(c5); - if(ls::horodisk_structure()) { - c2 = ts::left_child(c2, celldistAlt); - c3 = ts::right_child(c3, celldistAlt); - if(!c2 || !c3) return; - } - else { - if(c2) c2 = ts::left_parent(c2, coastvalEdge); - if(c3) c3 = ts::right_parent(c3, coastvalEdge); - if(c4) c4 = ts::left_parent(c4, coastvalEdge); - if(c5) c5 = ts::right_parent(c5, coastvalEdge); - } + if(c2) c2 = ts::left_parent(c2, cvfun); + if(c3) c3 = ts::right_parent(c3, cvfun); + if(c4) c4 = ts::left_parent(c4, cvfun); + if(c5) c5 = ts::right_parent(c5, cvfun); } } } @@ -4139,22 +4132,23 @@ EX namespace dungeon { buildEquidistant(c); bool rdepths[5]; int switchcount = 0; + auto cvfun = ls::hv_structure() ? celldistAlt : coastvalEdge; if(WDIM == 3) { for(int i=0; i<5; i++) rdepths[i] = false; manual_celllister cl; cl.add(c); - int d = coastvalEdge(c); + int d = cvfun(c); for(int i=0; ilandflags == 3) rdepths[d1] = true; if(c1->landflags == 1) switchcount++; if(d1 == 4) break; - forCellEx(c2, c1) if(coastvalEdge(c2) < coastvalEdge(c1)) + forCellEx(c2, c1) if(cvfun(c2) < cvfun(c1)) cl.add(c2); } } @@ -4165,7 +4159,7 @@ EX namespace dungeon { cell *c3 = c; for(int i=0; i<5; i++) { - if(coastvalEdge(c2) == 0) { + if(cvfun(c2) == 0) { rdepths[i] = false; } else { @@ -4179,17 +4173,10 @@ EX namespace dungeon { switchcount++; generate_around(c2); generate_around(c3); - if(ls::horodisk_structure()) { - c2 = ts::left_child(c2, celldistAlt); - c3 = ts::right_child(c3, celldistAlt); - if(!c2 || !c3) return 0; - } - else { - c2 = ts::left_parent(c2, coastvalEdge); - c3 = ts::right_parent(c3, coastvalEdge); - if(!c2) { towerError(c); return 0; } - if(!c3) { towerError(c); return 0; } - } + c2 = ts::left_parent(c2, cvfun); + c3 = ts::right_parent(c3, cvfun); + if(!c2) { towerError(c); return 0; } + if(!c3) { towerError(c); return 0; } } } } @@ -4235,9 +4222,10 @@ EX namespace dungeon { c->wall = waCamelot; */ + auto cvfun = ls::hv_structure() ? celldistAlt : coastvalEdge; if(true) { - if(coastvalEdge(c) == 1) forCellEx(c2, c) + if(cvfun(c) == 1) forCellEx(c2, c) if(c2->land != laBarrier && c2->land != laDungeon) { c->wall = waLadder; c->wparam = 3; @@ -4247,8 +4235,8 @@ EX namespace dungeon { if(df&1) { generate_around(c); - int df1 = WDIM == 3 ? 0 : dungeonFlags(ts::left_of(c, coastvalEdge)); - int df2 = WDIM == 3 ? 0 : dungeonFlags(ts::right_of(c, coastvalEdge)); + int df1 = WDIM == 3 ? 0 : dungeonFlags(ts::left_of(c, cvfun)); + int df2 = WDIM == 3 ? 0 : dungeonFlags(ts::right_of(c, cvfun)); c->wparam = 0; if(hrand(100) < (c->landparam % 5 == 0 ? 80 : 20)) { @@ -4268,11 +4256,11 @@ EX namespace dungeon { if(c->wparam) { cell *c2 = - WDIM == 3 ? random_child(c, coastvalEdge) : - c->wparam == 1 ? ts::add(c, 1, 2, coastvalEdge) : - c->wparam == 2 ? ts::add(c, -1, -2, coastvalEdge) : - c->wparam == 3 ? ts::add(c, 1, 3, coastvalEdge) : - c->wparam == 4 ? ts::add(c, -1, -3, coastvalEdge) : + WDIM == 3 ? random_child(c, cvfun) : + c->wparam == 1 ? ts::add(c, 1, 2, cvfun) : + c->wparam == 2 ? ts::add(c, -1, -2, cvfun) : + c->wparam == 3 ? ts::add(c, 1, 3, cvfun) : + c->wparam == 4 ? ts::add(c, -1, -3, cvfun) : NULL; if(c2) { @@ -4294,7 +4282,7 @@ EX namespace dungeon { int neargateEq = 0; int qup = 0; forCellEx(c2, c) { - int d = coastvalEdge(c2) - coastvalEdge(c); + int d = cvfun(c2) - cvfun(c); if(isGate(c2->wall)) { neargate++; if(d>0) neargateDown++; diff --git a/landlock.cpp b/landlock.cpp index 8a9825a3..1e6e460d 100644 --- a/landlock.cpp +++ b/landlock.cpp @@ -863,7 +863,7 @@ EX land_validity_t& land_validity(eLand l) { if(l == laMirrorOld && !shmup::on) return not_implemented; } - if(ls::hv_structure() && among(l, laPrairie, laIvoryTower, laDungeon, laEndorian, laBrownian, laElementalWall, laWarpCoast, laWarpSea, laHive, laPrincessQuest)) return not_in_hv; + if(ls::hv_structure() && among(l, laPrairie, laDungeon, laEndorian, laBrownian, laElementalWall, laWarpCoast, laWarpSea, laHive, laPrincessQuest)) return not_in_hv; if(ls::voronoi_structure() && among(l, laCamelot, laWhirlpool, laClearing)) return not_in_hv; if(ls::horodisk_structure() && l != laCrossroads && isCrossroads(l)) return not_in_hv; diff --git a/mapeffects.cpp b/mapeffects.cpp index 0c48f526..33ba07b0 100644 --- a/mapeffects.cpp +++ b/mapeffects.cpp @@ -577,6 +577,8 @@ EX bool destroyHalfvine(cell *c, eWall newwall IS(waNone), int tval IS(6)) { EX int coastvalEdge(cell *c) { return coastval(c, laIvoryTower); } EX int gravityLevel(cell *c) { + if(c->land == laIvoryTower && ls::hv_structure()) + return celldistAlt(c); if(c->land == laIvoryTower || c->land == laEndorian) return coastval(c, laIvoryTower); if(c->land == laDungeon) diff --git a/system.cpp b/system.cpp index 44ed4ab5..281bf821 100644 --- a/system.cpp +++ b/system.cpp @@ -194,9 +194,10 @@ EX void initgame() { if(firstland == laHauntedWall) firstland = laGraveyard; if(firstland == laHaunted && !tactic::on) firstland = laGraveyard; if(firstland == laMercuryRiver) firstland = laTerracotta; - if(firstland == laMountain && !tactic::on) firstland = laJungle; + if(firstland == laMountain && !tactic::on && !ls::hv_structure()) firstland = laJungle; if(firstland == laPrincessQuest) firstland = laPalace; if(firstland == laMemory) firstland = laIce; + if(!ls::hv_structure()) if((isGravityLand(firstland) && !isCyclic(firstland)) || (firstland == laOcean && !safety && !yendor::on)) { firstland = weirdhyperbolic ? laCrossroads4 : laCrossroads; easy_specialland = 3;