diff --git a/complex.cpp b/complex.cpp index 4bf4bed5..655d6d00 100644 --- a/complex.cpp +++ b/complex.cpp @@ -104,7 +104,7 @@ namespace whirlwind { } } - void moveAt(cell *c, celllister& cl) { + void moveAt(cell *c, manual_celllister& cl) { if(cl.listed(c)) return; calcdirs(c); if(qdirs != 1) return; @@ -143,7 +143,7 @@ namespace whirlwind { } void move() { - celllister cl(manual); + manual_celllister cl; for(int i=0; iwall = waMetal; */ } - void listChargedCells(cell *c, celllister& cl, eCharge last = ecConductor) { + void listChargedCells(cell *c, manual_celllister& cl, eCharge last = ecConductor) { if(cl.listed(c)) return; eCharge here = getCharge(c); /* if(c->cpdist <= 2) { @@ -370,8 +370,10 @@ namespace elec { void init() { chargecells.clear(); if(!haveelec && !afterOrb) return; - celllister cl(manual); - for(int i=0; iland != laWhirlpool) return; if(cl.listed(c)) return; if(!(euclid || c->master->alt)) return; @@ -1038,7 +1040,7 @@ namespace whirlpool { } void move() { - celllister cl(manual); + manual_celllister cl; for(int i=0; i offscreen2; - celllister cl(manual); + manual_celllister cl; int gr = gamerange(); @@ -1940,7 +1942,7 @@ namespace heat { vector offscreen2; - celllister cl(manual); + manual_celllister cl; vector& allcells = currentmap->allcells(); @@ -2837,7 +2839,7 @@ namespace prairie { if(c2) c->mondir = neighborId(c, c2); } - void moveAt(cell *c, celllister& cl) { + void moveAt(cell *c, manual_celllister& cl) { if(!cl.add(c)) return; vector whirlline; whirlline.push_back(c); @@ -2888,7 +2890,7 @@ namespace prairie { } void move() { - celllister cl(manual); + manual_celllister cl; for(int i=0; icpdist < c->cpdist) @@ -5778,7 +5778,7 @@ bool ambushed; void checkAmbushState() { if(havewhat & HF_HUNTER) { - celllister cl(manual); + manual_celllister cl; for(cell *c: dcal) { if(c->monst == moHunterDog) { if(c->cpdist > ambush_distance) diff --git a/hyper.h b/hyper.h index ff6b4508..f2f10235 100644 --- a/hyper.h +++ b/hyper.h @@ -2543,13 +2543,10 @@ extern vector allmaps; // list all cells in distance at most maxdist, or until when maxcount cells are reached -extern struct manual_t {} manual; - -struct celllister { +struct manual_celllister { vector lst; vector tmps; - vector dists; - + bool listed(cell *c) { return c->listindex >= 0 && c->listindex < isize(lst) && lst[c->listindex] == c; } @@ -2557,29 +2554,31 @@ struct celllister { bool add(cell *c) { if(listed(c)) return false; tmps.push_back(c->listindex); - lst.push_back(c); c->listindex = isize(lst); + lst.push_back(c); return true; } - void add(cell *c, int d) { + ~manual_celllister() { + for(int i=0; ilistindex = tmps[i]; + } + }; + + +struct celllister : manual_celllister { + vector dists; + + void add_at(cell *c, int d) { if(add(c)) dists.push_back(d); } - ~celllister() { - for(int i=0; ilistindex = tmps[i]; - } - - celllister(manual_t) { - } - celllister(cell *orig, int maxdist, int maxcount, cell *breakon) { - add(orig, 0); + add_at(orig, 0); cell *last = orig; for(int i=0; iitem == itOrbSafety) return false; @@ -76,7 +76,7 @@ bool blizzard_no_escape1(cell *c, celllister &cl) { } bool blizzard_no_escape(cell *c) { - celllister cl(manual); + manual_celllister cl; return blizzard_no_escape1(c, cl); } diff --git a/mapeditor.cpp b/mapeditor.cpp index 7fe592ef..29e4ed67 100644 --- a/mapeditor.cpp +++ b/mapeditor.cpp @@ -621,7 +621,7 @@ namespace mapeditor { vector > spill_list; - void list_spill(cellwalker tgt, cellwalker src, celllister& cl) { + void list_spill(cellwalker tgt, cellwalker src, manual_celllister& cl) { spill_list.clear(); sval++; spill_list.emplace_back(tgt, src); int crad = 0, nextstepat = 0; @@ -668,7 +668,7 @@ namespace mapeditor { } #endif - void editAt(cellwalker where, celllister& cl) { + void editAt(cellwalker where, manual_celllister& cl) { if(painttype == 4 && radius) { if(where.c->type != copysource.c->type) return; @@ -685,7 +685,7 @@ namespace mapeditor { void allInPattern(cellwalker where) { - celllister cl(manual); + manual_celllister cl; if(!patterns::whichPattern) { editAt(where, cl); return; diff --git a/monstergen.cpp b/monstergen.cpp index 43cf6786..ea76470c 100644 --- a/monstergen.cpp +++ b/monstergen.cpp @@ -242,7 +242,7 @@ int getSeepcount() { } bool canReachPlayer(cell *cf, eMonster m) { - celllister cl(manual); + manual_celllister cl; cl.add(cf); for(int i=0; i