From 7f09bb6259e629429a071d7def0b0275e1bf8412 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sat, 14 Dec 2019 12:31:20 +0100 Subject: [PATCH] replaced macro VALENCE with function valence() --- barriers.cpp | 12 ++++++------ bigstuff.cpp | 2 +- cell.cpp | 10 +++++++++- complex2.cpp | 4 ++-- crystal.cpp | 2 +- expansion.cpp | 8 ++++---- landgen.cpp | 2 +- landlock.cpp | 4 ++-- pattern2.cpp | 2 +- yendor.cpp | 4 ++-- 10 files changed, 29 insertions(+), 21 deletions(-) diff --git a/barriers.cpp b/barriers.cpp index 3ec31ce1..e2e87a60 100644 --- a/barriers.cpp +++ b/barriers.cpp @@ -68,7 +68,7 @@ EX bool checkBarriersBack(cellwalker bb, int q IS(5), bool cross IS(false)) { /** warp coasts use a different algorithm for nowall barriers when has_nice_dual() is on. Check whether we should use this different algorithm when the lands are l1 and l2 */ EX bool warped_version(eLand l1, eLand l2) { - return (has_nice_dual() && (l1 == laWarpCoast || l1 == laWarpSea || l2 == laWarpSea || l2 == laWarpCoast)) || (VALENCE == 3); + return (has_nice_dual() && (l1 == laWarpCoast || l1 == laWarpSea || l2 == laWarpSea || l2 == laWarpCoast)) || (valence() == 3); } EX bool checkBarriersNowall(cellwalker bb, int q, int dir, eLand l1 IS(laNone), eLand l2 IS(laNone)) { @@ -101,7 +101,7 @@ EX bool checkBarriersNowall(cellwalker bb, int q, int dir, eLand l1 IS(laNone), if(warped_version(l1, l2)) { bb = bb + wstep + (2*dir) + wstep + dir; } - else if(VALENCE > 3) { + else if(valence() > 3) { bb = bb + dir + wstep + dir; dir = -dir; swap(l1, l2); @@ -264,7 +264,7 @@ EX void extendNowall(cell *c) { cw += wstep; setland(cw.at, c->barright); } - else if(VALENCE > 3) { + else if(valence() > 3) { auto cw2 = cw + wstep; setland(cw2.at, c->barright); cw2.at->barleft = NOWALLSEP_USED; @@ -277,7 +277,7 @@ EX void extendNowall(cell *c) { if(warpv) { cw0 = cw + (2*i) + wstep; } - else if(VALENCE > 3) { + else if(valence() > 3) { cw0 = cw + i + wstep + i; } else { @@ -286,7 +286,7 @@ EX void extendNowall(cell *c) { } if(cw0.at->barleft != NOWALLSEP_USED) { cw0.at->barleft = NOWALLSEP; - if(VALENCE > 3) { + if(valence() > 3) { cw0.at->barright = c->barright; cw0.at->bardir = cw0.spin; setland(cw0.at, c->land); @@ -846,7 +846,7 @@ EX bool buildBarrierNowall(cell *c, eLand l2, int forced_dir IS(NODIR)) { for(int j=0; jtype; j++) swap(ds[j], ds[hrand(j+1)]); for(int i=0; itype; i++) { - int d = forced_dir != NODIR ? forced_dir : (VALENCE>3) ? (2+(i&1)) : ds[i]; + int d = forced_dir != NODIR ? forced_dir : (valence()>3) ? (2+(i&1)) : ds[i]; /* if(warpv && GOLDBERG) { d = hrand(c->type); */ if(warpv && c->move(d) && c->move(d)->mpdist < c->mpdist) continue; diff --git a/bigstuff.cpp b/bigstuff.cpp index 9b2bbde5..801ff096 100644 --- a/bigstuff.cpp +++ b/bigstuff.cpp @@ -1581,7 +1581,7 @@ EX bool no_barriers_in_radius(cell *c, int rad) { EX eMonster camelot_monster() { eMonster ms[3] = { moHedge, moLancer, moFlailer }; eMonster m = ms[hrand(3)]; - if(m == moHedge && VALENCE > 3) + if(m == moHedge && valence() > 3) m = moPyroCultist; if(getDistLimit() <= 2 && m == moLancer) m = moGoblin; if(getDistLimit() <= 3 && m == moPyroCultist) m = moCultist; diff --git a/cell.cpp b/cell.cpp index 149ace19..ca1a05dd 100644 --- a/cell.cpp +++ b/cell.cpp @@ -1141,7 +1141,7 @@ EX int mine_adjacency_rule = 0; EX map> adj_memo; EX bool geometry_has_alt_mine_rule() { - if(WDIM == 2) return VALENCE > 3; + if(WDIM == 2) return valence() > 3; if(WDIM == 3) return !among(geometry, gHoroHex, gCell5, gBitrunc3, gCell8, gECell8, gCell120, gECell120); return true; } @@ -1241,4 +1241,12 @@ EX bool standard_tiling() { return !arcm::in() && !kite::in() && !bt::in(); } +EX int valence() { + if(BITRUNCATED) return 3; + #if CAP_ARCM + if(arcm::in()) return arcm::valence(); + #endif + return S3; + } + } diff --git a/complex2.cpp b/complex2.cpp index 90f150ef..7ed63efb 100644 --- a/complex2.cpp +++ b/complex2.cpp @@ -300,7 +300,7 @@ array features {{ {0x181418, 5, moSkeleton, VF { if(c->wall == waNone && !c->monst && hrand_monster(80000) < 25 + items[itVarTreasure]) c->monst = moSkeleton, c->hitpoints = 3; } }, {0x180000, 5, moPyroCultist, VF { if(c->wall == waNone && !c->monst && hrand_monster(80000) < 25 + items[itVarTreasure]) c->monst = moPyroCultist; } }, {0x00000C, 2, moFlailer, VF { if(c->wall == waNone && !c->monst && hrand_monster(80000) < 25 + items[itVarTreasure]) c->monst = moFlailer; } }, - {0x1C0700, 1, moHedge, VF { if(c->wall == waNone && !c->monst && hrand_monster(80000) < 25 + items[itVarTreasure] && VALENCE == 3) c->monst = moHedge; } }, + {0x1C0700, 1, moHedge, VF { if(c->wall == waNone && !c->monst && hrand_monster(80000) < 25 + items[itVarTreasure] && valence() == 3) c->monst = moHedge; } }, {0x000c00,-1, moNone, VF { if(hrand(1500) < 30) createArrowTrapAt(c, laVariant); } }, {0x001200,-1, moNone, VF { if(hrand(1500) < 50 && c->wall == waNone) c->wall = waTrapdoor; } }, {0x000c18,-1, moNone, VF { if(hrand(1500) < 30) build_pool(c, true); } }, @@ -779,7 +779,7 @@ EX int ambush(cell *c, eItem what) { vector around; cell *clast = NULL; cell *ccur = c0; - int v = VALENCE; + int v = valence(); if(v > 4) { for(cell *c: cl.lst) if(cl.getdist(c) == d) around.push_back(c); hrandom_shuffle(&around[0], isize(around)); diff --git a/crystal.cpp b/crystal.cpp index 347d9bbe..ca942aa0 100644 --- a/crystal.cpp +++ b/crystal.cpp @@ -1147,7 +1147,7 @@ EX void build_rugdata() { ldcoord vcoord[MAX_EDGE]; for(int i=0; itype; i++) - if(VALENCE == 4) + if(valence() == 4) vcoord[i] = ((m->get_coord(c->cmove(i)) + m->get_coord(c->cmodmove(i-1))) / 2); else vcoord[i] = ((m->get_coord(c->cmove(i)) + m->get_coord(c->cmodmove(i-1)) + co) / 3); diff --git a/expansion.cpp b/expansion.cpp index 9d6a290f..7f0ea5dd 100644 --- a/expansion.cpp +++ b/expansion.cpp @@ -599,21 +599,21 @@ EX namespace ts { EX cell *left_of(cell *c, const cellfunction& cf) { int pid = parent_id(c, 1, cf); if(pid == -1) return c; - if(VALENCE == 3) return c->cmodmove(pid+1); + if(valence() == 3) return c->cmodmove(pid+1); else return (cellwalker(c, pid) + wstep - 1).cpeek(); } EX cell *right_of(cell *c, const cellfunction& cf) { int pid = parent_id(c, -1, cf); if(pid == -1) return c; - if(VALENCE == 3) return c->cmodmove(pid-1); + if(valence() == 3) return c->cmodmove(pid-1); else return (cellwalker(c, pid) + wstep + 1).cpeek(); } EX cell *child_number(cell *c, int id, const cellfunction& cf) { int pid = parent_id(c, 1, cf); if(pid == -1) return c->cmove(id); - return c->cmodmove(pid + (VALENCE == 3 ? 2 : 1) + id); + return c->cmodmove(pid + (valence() == 3 ? 2 : 1) + id); } #if HDR @@ -1047,7 +1047,7 @@ EX int hyperbolic_celldistance(cell *c1, cell *c2) { if(d1 == d2) { if(cl1 == c1 && in_segment(cl2, c1, cr2)) return d; if(cl2 == c2 && in_segment(cl1, c2, cr1)) return d; - if(VALENCE == 3) { + if(valence() == 3) { int dx = min(sibling_distance(cr1, cl2, sibling_limit), sibling_distance(cr2, cl1, sibling_limit)); if(d + dx <= found_distance) { found_distance = d + dx; diff --git a/landgen.cpp b/landgen.cpp index b98f8b33..179fb7e0 100644 --- a/landgen.cpp +++ b/landgen.cpp @@ -1984,7 +1984,7 @@ EX void giantLandSwitch(cell *c, int d, cell *from) { if(t == 50) { c->item = itNone; break; } cell *dog1 = dogcells[hrand(isize(dogcells))]; cell *dog2 = dogcells[hrand(isize(dogcells))]; - if(VALENCE != 3 || isNeighbor(dog1, dog2)) { + if(valence() != 3 || isNeighbor(dog1, dog2)) { dog1->monst = moHunterGuard; dog1->landparam = 0; dog2->monst = moHunterGuard; diff --git a/landlock.cpp b/landlock.cpp index eb2e1aa2..d4c789fd 100644 --- a/landlock.cpp +++ b/landlock.cpp @@ -1041,7 +1041,7 @@ EX land_validity_t& land_validity(eLand l) { if(l == laWarpCoast && quotient && geometry != gZebraQuotient && !randomPatternsMode) return pattern_incompatibility; - if(among(l, laEmerald, laCamelot, laDryForest) && VALENCE != 3 && old_daily_id >= 65) + if(among(l, laEmerald, laCamelot, laDryForest) && valence() != 3 && old_daily_id >= 65) return hedgehogs; // laPower and laEmerald and laPalace -> [partial] in quotients and hyperbolic_non37 @@ -1052,7 +1052,7 @@ EX land_validity_t& land_validity(eLand l) { else if(quotient) return pattern_incompatibility; } - if(among(l, laEmerald, laCamelot, laDryForest) && VALENCE != 3) + if(among(l, laEmerald, laCamelot, laDryForest) && valence() != 3) return hedgehogs; if(l == laWineyard && sol) diff --git a/pattern2.cpp b/pattern2.cpp index a19305f1..8c808f1b 100644 --- a/pattern2.cpp +++ b/pattern2.cpp @@ -1204,7 +1204,7 @@ EX bool geosupport_chessboard() { #endif (bt::in() || kite::in()) ? 0 : (S3 >= OINF) ? true : - (VALENCE % 2 == 0); + (valence() % 2 == 0); } EX int geosupport_threecolor() { diff --git a/yendor.cpp b/yendor.cpp index d40ba9a6..7597b7ef 100644 --- a/yendor.cpp +++ b/yendor.cpp @@ -325,7 +325,7 @@ EX namespace yendor { if(i == 1) onlychild = true; if(!onlychild) ycw++; - if(VALENCE == 3) ycw++; + if(valence() == 3) ycw++; onlychild = false; @@ -451,7 +451,7 @@ EX namespace yendor { if(i == 1) onlychild = true; if(!onlychild) ycw++; - if(VALENCE == 3) ycw++; + if(valence() == 3) ycw++; onlychild = false;