CAP_FIELD part 1

This commit is contained in:
? 2019-02-17 18:33:15 +01:00 committed by Zeno Rogue
parent b25730d5c9
commit c5a771c888
15 changed files with 103 additions and 5 deletions

View File

@ -1087,6 +1087,7 @@ void buildBigStuff(cell *c, cell *from) {
else if(c->land == laCrossroads2 && BITRUNCATED)
buildCrossroads2(c);
#if CAP_FIELD
else if(c->land == laPrairie && c->LHU.fi.walldist == 0 && !euclid) {
for(int bd=0; bd<7; bd++) {
int fval2 = createStep(c->master, bd)->fieldval;
@ -1097,6 +1098,7 @@ void buildBigStuff(cell *c, cell *from) {
}
}
}
#endif
else if(ctof(c) && c->land && hrand(I10000) < wallchance(c, deepOcean))
{

View File

@ -43,6 +43,7 @@ blizzardcell* getbcell(cell *c) {
}
void drawBlizzards() {
#if CAP_POLY && CAP_FIELD
poly_outline = OUTLINE_NONE;
auto it = blizzardcells.begin();
bcells.clear();
@ -201,6 +202,7 @@ void drawBlizzards() {
for(auto bc: bcells)
bc->c->listindex = bc->tmp;
#endif
}
vector<cell*> arrowtraps;

View File

@ -768,10 +768,12 @@ struct hrmap_quotient : hrmap {
connections.clear();
switch(geometry) {
#if CAP_FIELD
case gFieldQuotient: {
connections = currfp.connections;
break;
}
#endif
case gZebraQuotient: {
heptspin hs(base.origin);
@ -1241,7 +1243,9 @@ void initcells() {
allmaps.push_back(currentmap);
#if CAP_FIELD
windmap::create();
#endif
// origin->emeraldval =
}
@ -1822,8 +1826,10 @@ int celldistance(cell *c1, cell *c2) {
return torusconfig::cyldist(decodeId(c1->master), decodeId(c2->master));
}
#if CAP_FIELD
if(geometry == gFieldQuotient && !GOLDBERG)
return currfp.getdist(fieldpattern::fieldval(c1), fieldpattern::fieldval(c2));
#endif
if(bounded) {

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,7 @@
// Hyperbolic Rogue -- implementation of the quotient geometries based on fields
// Copyright (C) 2011-2018 Zeno Rogue, see 'hyper.cpp' for details
#if CAP_FIELD
namespace hr {
namespace fieldpattern {
@ -791,3 +792,4 @@ int currfp_inverses(int i) { return currfp.inverses[i]; }
int currfp_distwall(int i) { return currfp.distwall[i]; }
}
#endif

View File

@ -741,6 +741,7 @@ bool againstWind(cell *cto, cell *cfrom) {
if(!cfrom || !cto) return false;
int dcto = airdist(cto), dcfrom = airdist(cfrom);
if(dcto < dcfrom) return true;
#if CAP_FIELD
if(cfrom->land == laBlizzard && !shmup::on && cto->land == laBlizzard && dcto == 3 && dcfrom == 3) {
char vfrom = windmap::at(cfrom);
char vto = windmap::at(cto);
@ -748,6 +749,7 @@ bool againstWind(cell *cto, cell *cfrom) {
if(z >= windmap::NOWINDBELOW && z < windmap::NOWINDFROM)
return true;
}
#endif
whirlwind::calcdirs(cfrom);
int d = neighborId(cfrom, cto);
if(whirlwind::winddir(d) == -1) return true;
@ -2805,10 +2807,12 @@ bool recalcTide;
#define LANDDIST LHU.bytes[1]
#define CHAOSPARAM LHU.bytes[2]
#if CAP_FIELD
int lavatide(cell *c, int t) {
int tc = (shmup::on ? shmup::curtime/400 : turncount);
return (windmap::at(c) + (tc+t)*4) & 255;
}
#endif
void checkTide(cell *c) {
if(c->land == laOcean) {
@ -2841,6 +2845,7 @@ void checkTide(cell *c) {
if(isFire(c) && t >= tidalphase)
c->wall = waSea;
}
#if CAP_FIELD
if(c->land == laVolcano) {
int id = lavatide(c, 0);
if(id < 96) {
@ -2856,6 +2861,7 @@ void checkTide(cell *c) {
}
else if(c->wall == waMagma) c->wall = waNone;
}
#endif
}
void buildAirmap() {

View File

@ -32,6 +32,7 @@ string euchelp =
"* Halloween is specially designed for spherical geometry.\n"
"* To see the difference, try Hunting Grounds in Euclidean -- it is impossible.\n";
#if CAP_FIELD
void showQuotientConfig() {
using namespace fieldpattern;
gamescreen(2);
@ -88,6 +89,7 @@ void showQuotientConfig() {
dialog::display();
}
#endif
bool torus_bitrunc;
@ -392,6 +394,7 @@ void ge_select_tiling(const vector<eGeometry>& lst) {
dynamicval<eGeometry> cg(geometry, eGeometry(i));
if(archimedean && !CAP_ARCM) continue;
if(geometry == gCrystal && !CAP_CRYSTAL) continue;
if(geometry == gFieldQuotient && !CAP_FIELD) continue;
dialog::addBoolItem(XLAT(ginf[i].menu_displayed_name), on, letter++);
dialog::lastItem().value += validclasses[land_validity(specialland).quality_level];
dialog::add_action([i] {
@ -412,9 +415,11 @@ void ge_select_tiling(const vector<eGeometry>& lst) {
prepare_torusconfig();
pushScreen(showTorusConfig);
}
#if CAP_FIELD
if(geometry == gFieldQuotient) {
pushScreen(showQuotientConfig);
}
#endif
});
});
}
@ -635,8 +640,10 @@ void showEuclideanMenu() {
else if(euwrap)
prepare_torusconfig(),
pushScreen(showTorusConfig);
#if CAP_FIELD
else if(geometry == gFieldQuotient)
pushScreen(showQuotientConfig);
#endif
});
}
else dialog::addBreak(100);
@ -729,7 +736,9 @@ void runGeometryExperiments() {
#if CAP_COMMANDLINE
int read_geom_args() {
using namespace arg;
if(argis("-qpar")) {
if(0) ;
#if CAP_FIELD
else if(argis("-qpar")) {
int p;
shift(); sscanf(argcs(), "%d,%d,%d",
&p, &quotientspace::rvadd, &quotientspace::rvdir
@ -761,6 +770,7 @@ int read_geom_args() {
cheat();
currfp.findsubpath();
}
#endif
else if(argis("-tpar")) {
torusconfig::torus_mode = torusconfig::tmSingle;
shift(); sscanf(argcs(), "%d,%d,%d",
@ -795,6 +805,7 @@ int read_geom_args() {
set_variation(eVariation::goldberg);
}
#endif
#if CAP_FIELD
else if(argis("-fi")) {
fieldpattern::info();
exit(0);
@ -805,6 +816,7 @@ int read_geom_args() {
}
else if(argis("-d:quotient"))
launch_dialog(showQuotientConfig);
#endif
else if(argis("-d:torus")) {
launch_dialog(showTorusConfig);
prepare_torusconfig();

View File

@ -2813,9 +2813,12 @@ void setcolors(cell *c, color_t& wcol, color_t& fcol) {
// water colors
if(isWateryOrBoat(c) || c->wall == waReptileBridge) {
if(c->land == laOcean)
fcol = (c->landparam > 25 && !chaosmode) ? (
0x90 + 8 * sintick(1000, windmap::windcodes[windmap::getId(c)] / 256.)
) :
fcol =
#if CAP_FIELD
(c->landparam > 25 && !chaosmode) ? (
0x90 + 8 * sintick(1000, windmap::windcodes[windmap::getId(c)] / 256.)
) :
#endif
0x1010C0 + int(32 * sintick(500, (chaosmode ? c->CHAOSPARAM : c->landparam)*.75/M_PI));
else if(c->land == laOceanWall)
fcol = 0x2020FF;
@ -2897,6 +2900,7 @@ void setcolors(cell *c, color_t& wcol, color_t& fcol) {
}
#endif
#if CAP_FIELD
case laVolcano: {
int id = lavatide(c, -1)/4;
if(c->wall == waMagma) {
@ -2916,6 +2920,7 @@ void setcolors(cell *c, color_t& wcol, color_t& fcol) {
} */
break;
}
#endif
case laMinefield:
fcol = floorcolors[c->land];
@ -3061,6 +3066,7 @@ void setcolors(cell *c, color_t& wcol, color_t& fcol) {
break;
}
#if CAP_FIELD
case laPrairie:
if(prairie::isriver(c)) {
fcol = ((c->LHU.fi.rval & 1) ? 0x402000: 0x503000);
@ -3071,6 +3077,7 @@ void setcolors(cell *c, color_t& wcol, color_t& fcol) {
// fcol += 0x1 * (511 / (1 + max((int) c->LHU.fi.walldist2, 1)));
}
break;
#endif
case laCamelot: {
int d = showoff ? 0 : ((eubinary||c->master->alt) ? celldistAltRelative(c) : 0);
@ -6083,7 +6090,9 @@ auto graphcm = addHook(clearmemory, 0, [] () {
void resetGeometry() {
precalc();
#if CAP_FIELD
if(hyperbolic && &currfp != &fieldpattern::fp_invalid) currfp.analyze();
#endif
#if CAP_GL
resetGL();
#endif

View File

@ -2646,6 +2646,7 @@ bool allowChangeRange();
static inline bool orbProtection(eItem it) { return false; } // not implemented
#if CAP_FIELD
namespace windmap {
void create();
@ -2655,6 +2656,7 @@ namespace windmap {
int getId(cell *c);
int at(cell *c);
}
#endif
extern int wavephase;
@ -3062,6 +3064,7 @@ struct celllister : manual_celllister {
hrmap *newAltMap(heptagon *o);
#if CAP_FIELD
#define currfp fieldpattern::getcurrfp()
namespace fieldpattern {
struct fpattern& getcurrfp();
@ -3070,6 +3073,7 @@ namespace fieldpattern {
int currfp_gmul(int a, int b);
int currfp_inverses(int i);
int currfp_distwall(int i);
#endif
const char *dnameof(eMonster m);
const char *dnameof(eLand l);
@ -3915,6 +3919,7 @@ namespace torusconfig {
flagtype tmflags();
}
#if CAP_FIELD
namespace fieldpattern {
extern int current_extra;
@ -3934,6 +3939,7 @@ namespace fieldpattern {
extern vector<fgeomextra> fgeomextras;
extern void enableFieldChange();
}
#endif
bool incompatible(eLand l1, eLand l2);
eOrbLandRelation getOLR(eItem it, eLand l);

View File

@ -86,8 +86,12 @@ bool out_ruin(cell *c) {
cd &= 31;
return cd >= 16;
}
#if CAP_FIELD
else
return windmap::at(c) >= 128;
#else
else return false;
#endif
}
eMonster genRuinMonster(cell *c) {
@ -154,6 +158,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
case laPrairie: // -------------------------------------------------------------
#if CAP_FIELD
if(d == 7) {
if(prairie::isriver(c)) {
if(shmup::on) prairie::beaststogen.push_back(c);
@ -166,6 +171,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
}
prairie::generateTreasure(c);
}
#endif
break;
case laDungeon: // -------------------------------------------------------------
@ -947,6 +953,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
break;
case laVolcano:
#if CAP_FIELD
if(d == 9) {
c->wall = waNone;
if(hrand(20000) < (items[itLavaLily] + yendor::hardness()))
@ -961,9 +968,11 @@ void giantLandSwitch(cell *c, int d, cell *from) {
if(hrand(8000) < (items[itLavaLily] + yendor::hardness()))
c->monst = moLavaWolf;
}
#endif
break;
case laBlizzard:
#if CAP_FIELD
if(d == 9) {
bool windless = true;
int w = windmap::at(c);
@ -987,7 +996,7 @@ void giantLandSwitch(cell *c, int d, cell *from) {
}
if((d == 7 || d == 6) && blizzard_no_escape(c))
c->item = itOrbSafety, c->monst = moNone;
#endif
break;
case laTerracotta:
@ -2458,8 +2467,10 @@ void setdist(cell *c, int d, cell *from) {
c->wall = waInvisibleFloor;
}
#if CAP_FIELD
if(d >= BARLEV-1 && c->land == laPrairie)
prairie::spread(c, from);
#endif
if(d < BARLEV && c->land == laPrairie && !c->landparam) {
printf("d=%d/%d\n", d, BARLEV);

View File

@ -1137,6 +1137,7 @@ namespace lv {
land_validity_t sloppy_pattern = {1, q1 | one_and_half, "Somewhat sloppy pattern."};
land_validity_t no_fractal_landscapes = {1, q1 | one_and_half, "Fractal landscapes not implemented in this geometry."};
land_validity_t simplified_walls = { 1, q1, "Only simplified walls implemented."};
land_validity_t disabled = {0, q0, "This land has been disabled with compilation flags."};
}
// old Daily Challenges should keep their validity forever
@ -1149,6 +1150,11 @@ land_validity_t& land_validity(eLand l) {
using namespace lv;
#if !CAP_FIELD
if(among(l, laPrairie, laBlizzard, laVolcano))
return disabled;
#endif
if(l == laBrownian) {
if(quotient || !hyperbolic || geometry == gCrystal) return dont_work;
}

View File

@ -340,6 +340,7 @@ int zebra3(cell *c) {
}
}
#if CAP_FIELD
namespace fieldpattern {
pair<int, bool> fieldval(cell *c) {
@ -415,6 +416,7 @@ pair<int, int> subval(cell *c, int _subpathid = subpathid, int _subpathorder = s
}
}
#endif
int getHemisphere(heptagon *h, int which) {
int id = h->fiftyval;
@ -1063,6 +1065,7 @@ namespace patterns {
si.dir = downdir(c, coastvalEdge);
}
#if CAP_FIELD
else if(pat == PAT_FIELD) {
if(euclid)
// use the torus ID
@ -1075,6 +1078,7 @@ namespace patterns {
si.id = windmap::getId(c);
// todo dir
}
#endif
else if(sphere && pat == PAT_SIBLING) {
val_all(c, si, sub, pat);
@ -1433,6 +1437,7 @@ namespace patterns {
#endif
case 'B':
return colortables['B'][c->type & 15];
#if CAP_FIELD
case 'C': {
if(!hyperbolic) return canvasback;
using namespace fieldpattern;
@ -1458,11 +1463,14 @@ namespace patterns {
if(z > z2) return 0xC00000;
return 0xCCCC00;
}
#endif
case 'M':
return gradient(0, canvasback, 0, min(1.8/(1+celldist(c)), 1.), 1);
#if CAP_FIELD
case 'S':
if(!hyperbolic) return canvasback;
return 0x3F1F0F * fieldpattern::subval(c).second + 0x000080;
#endif
case 'g':
return canvasback;
case 'r':
@ -1552,12 +1560,14 @@ namespace patterns {
dialog::addSelItem(XLAT("random black-and-white"), "current", 'w');
#if CAP_FIELD
if(!sphere) {
dialog::addSelItem(XLAT("field pattern C"), "field", 'C');
dialog::addSelItem(XLAT("field pattern D"), "field", 'D');
dialog::addSelItem(XLAT("field pattern N"), "field", 'N');
dialog::addSelItem(XLAT("field pattern S"), "field", 'S');
}
#endif
if(archimedean)
dialog::addSelItem(XLAT("Archimedean"), "Archimedean", 'A');

View File

@ -1340,6 +1340,7 @@ bool airCurrents(transmatrix& nat, monster *m, int delta) {
}
}
}
#if CAP_FIELD
if(c->land == laBlizzard) {
int wmc = windmap::at(c);
forCellEx(c2, c) {
@ -1360,6 +1361,7 @@ bool airCurrents(transmatrix& nat, monster *m, int delta) {
}
}
}
#endif
return carried;
}
@ -2575,6 +2577,7 @@ void moveMonster(monster *m, int delta) {
direct = true;
directi = 0;
}
#if CAP_FIELD
else if(m->type == moHerdBull) {
cell *cnext = prairie::next(c);
if(cnext && gmatrix.count(cnext)) {
@ -2584,6 +2587,7 @@ void moveMonster(monster *m, int delta) {
}
else m->dead = true;
}
#endif
else if(m->type == moButterfly) {
int d = neighborId(m->base, m->torigin);
cell *cnext = NULL;

View File

@ -467,3 +467,6 @@ union SDL_Event;
#define CAP_BT CAP_GEOMETRY
#endif
#ifndef CAP_FIELD
#define CAP_FIELD (!(ISMINI))
#endif

View File

@ -1063,11 +1063,13 @@ int modecode() {
}
}
#if CAP_FIELD
if(geometry == gFieldQuotient) {
using namespace fieldpattern;
mct += ll(current_extra) << 29;
mct += ll(fgeomextras[current_extra].current_prime_id) << 37;
}
#endif
#if CAP_CRYSTAL
if(geometry == gCrystal) {