mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 17:10:36 +00:00
fixed bugs with manual celllisters
This commit is contained in:
parent
d11044a80a
commit
cf8dffd6b8
24
complex.cpp
24
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;
|
if(cl.listed(c)) return;
|
||||||
calcdirs(c);
|
calcdirs(c);
|
||||||
if(qdirs != 1) return;
|
if(qdirs != 1) return;
|
||||||
@ -143,7 +143,7 @@ namespace whirlwind {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void move() {
|
void move() {
|
||||||
celllister cl(manual);
|
manual_celllister cl;
|
||||||
for(int i=0; i<isize(dcal); i++) {
|
for(int i=0; i<isize(dcal); i++) {
|
||||||
cell *c = dcal[i];
|
cell *c = dcal[i];
|
||||||
moveAt(c, cl);
|
moveAt(c, cl);
|
||||||
@ -349,7 +349,7 @@ namespace elec {
|
|||||||
c->wall = waMetal; */
|
c->wall = 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;
|
if(cl.listed(c)) return;
|
||||||
eCharge here = getCharge(c);
|
eCharge here = getCharge(c);
|
||||||
/* if(c->cpdist <= 2) {
|
/* if(c->cpdist <= 2) {
|
||||||
@ -370,8 +370,10 @@ namespace elec {
|
|||||||
void init() {
|
void init() {
|
||||||
chargecells.clear();
|
chargecells.clear();
|
||||||
if(!haveelec && !afterOrb) return;
|
if(!haveelec && !afterOrb) return;
|
||||||
celllister cl(manual);
|
if(1) {
|
||||||
for(int i=0; i<isize(dcal); i++) listChargedCells(dcal[i], cl);
|
manual_celllister cl;
|
||||||
|
for(int i=0; i<isize(dcal); i++) listChargedCells(dcal[i], cl);
|
||||||
|
}
|
||||||
|
|
||||||
charges.resize(2);
|
charges.resize(2);
|
||||||
charges[0].lowlink = 0; charges[1].lowlink = 1;
|
charges[0].lowlink = 0; charges[1].lowlink = 1;
|
||||||
@ -1011,7 +1013,7 @@ namespace whirlpool {
|
|||||||
generate(wto);
|
generate(wto);
|
||||||
}
|
}
|
||||||
|
|
||||||
void moveAt(cell *c, celllister& cl) {
|
void moveAt(cell *c, manual_celllister& cl) {
|
||||||
if(c->land != laWhirlpool) return;
|
if(c->land != laWhirlpool) return;
|
||||||
if(cl.listed(c)) return;
|
if(cl.listed(c)) return;
|
||||||
if(!(euclid || c->master->alt)) return;
|
if(!(euclid || c->master->alt)) return;
|
||||||
@ -1038,7 +1040,7 @@ namespace whirlpool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void move() {
|
void move() {
|
||||||
celllister cl(manual);
|
manual_celllister cl;
|
||||||
for(int i=0; i<isize(dcal); i++) {
|
for(int i=0; i<isize(dcal); i++) {
|
||||||
cell *c = dcal[i];
|
cell *c = dcal[i];
|
||||||
moveAt(c, cl);
|
moveAt(c, cl);
|
||||||
@ -1793,7 +1795,7 @@ namespace heat {
|
|||||||
|
|
||||||
vector<cell*> offscreen2;
|
vector<cell*> offscreen2;
|
||||||
|
|
||||||
celllister cl(manual);
|
manual_celllister cl;
|
||||||
|
|
||||||
int gr = gamerange();
|
int gr = gamerange();
|
||||||
|
|
||||||
@ -1940,7 +1942,7 @@ namespace heat {
|
|||||||
|
|
||||||
vector<cell*> offscreen2;
|
vector<cell*> offscreen2;
|
||||||
|
|
||||||
celllister cl(manual);
|
manual_celllister cl;
|
||||||
|
|
||||||
vector<cell*>& allcells = currentmap->allcells();
|
vector<cell*>& allcells = currentmap->allcells();
|
||||||
|
|
||||||
@ -2837,7 +2839,7 @@ namespace prairie {
|
|||||||
if(c2) c->mondir = neighborId(c, c2);
|
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;
|
if(!cl.add(c)) return;
|
||||||
vector<cell*> whirlline;
|
vector<cell*> whirlline;
|
||||||
whirlline.push_back(c);
|
whirlline.push_back(c);
|
||||||
@ -2888,7 +2890,7 @@ namespace prairie {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void move() {
|
void move() {
|
||||||
celllister cl(manual);
|
manual_celllister cl;
|
||||||
for(int i=0; i<isize(dcal); i++) {
|
for(int i=0; i<isize(dcal); i++) {
|
||||||
cell *c = dcal[i];
|
cell *c = dcal[i];
|
||||||
if(isriver(c)) moveAt(c, cl);
|
if(isriver(c)) moveAt(c, cl);
|
||||||
|
4
game.cpp
4
game.cpp
@ -5766,7 +5766,7 @@ void moveNormals(eMonster param) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void markAmbush(cell *c, celllister& cl) {
|
void markAmbush(cell *c, manual_celllister& cl) {
|
||||||
if(!cl.add(c)) return;
|
if(!cl.add(c)) return;
|
||||||
forCellEx(c2, c)
|
forCellEx(c2, c)
|
||||||
if(c2->cpdist < c->cpdist)
|
if(c2->cpdist < c->cpdist)
|
||||||
@ -5778,7 +5778,7 @@ bool ambushed;
|
|||||||
|
|
||||||
void checkAmbushState() {
|
void checkAmbushState() {
|
||||||
if(havewhat & HF_HUNTER) {
|
if(havewhat & HF_HUNTER) {
|
||||||
celllister cl(manual);
|
manual_celllister cl;
|
||||||
for(cell *c: dcal) {
|
for(cell *c: dcal) {
|
||||||
if(c->monst == moHunterDog) {
|
if(c->monst == moHunterDog) {
|
||||||
if(c->cpdist > ambush_distance)
|
if(c->cpdist > ambush_distance)
|
||||||
|
31
hyper.h
31
hyper.h
@ -2543,13 +2543,10 @@ extern vector<hrmap*> allmaps;
|
|||||||
|
|
||||||
// list all cells in distance at most maxdist, or until when maxcount cells are reached
|
// list all cells in distance at most maxdist, or until when maxcount cells are reached
|
||||||
|
|
||||||
extern struct manual_t {} manual;
|
struct manual_celllister {
|
||||||
|
|
||||||
struct celllister {
|
|
||||||
vector<cell*> lst;
|
vector<cell*> lst;
|
||||||
vector<int> tmps;
|
vector<int> tmps;
|
||||||
vector<int> dists;
|
|
||||||
|
|
||||||
bool listed(cell *c) {
|
bool listed(cell *c) {
|
||||||
return c->listindex >= 0 && c->listindex < isize(lst) && lst[c->listindex] == c;
|
return c->listindex >= 0 && c->listindex < isize(lst) && lst[c->listindex] == c;
|
||||||
}
|
}
|
||||||
@ -2557,29 +2554,31 @@ struct celllister {
|
|||||||
bool add(cell *c) {
|
bool add(cell *c) {
|
||||||
if(listed(c)) return false;
|
if(listed(c)) return false;
|
||||||
tmps.push_back(c->listindex);
|
tmps.push_back(c->listindex);
|
||||||
lst.push_back(c);
|
|
||||||
c->listindex = isize(lst);
|
c->listindex = isize(lst);
|
||||||
|
lst.push_back(c);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(cell *c, int d) {
|
~manual_celllister() {
|
||||||
|
for(int i=0; i<isize(lst); i++) lst[i]->listindex = tmps[i];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct celllister : manual_celllister {
|
||||||
|
vector<int> dists;
|
||||||
|
|
||||||
|
void add_at(cell *c, int d) {
|
||||||
if(add(c)) dists.push_back(d);
|
if(add(c)) dists.push_back(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
~celllister() {
|
|
||||||
for(int i=0; i<isize(lst); i++) lst[i]->listindex = tmps[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
celllister(manual_t) {
|
|
||||||
}
|
|
||||||
|
|
||||||
celllister(cell *orig, int maxdist, int maxcount, cell *breakon) {
|
celllister(cell *orig, int maxdist, int maxcount, cell *breakon) {
|
||||||
add(orig, 0);
|
add_at(orig, 0);
|
||||||
cell *last = orig;
|
cell *last = orig;
|
||||||
for(int i=0; i<isize(lst); i++) {
|
for(int i=0; i<isize(lst); i++) {
|
||||||
cell *c = lst[i];
|
cell *c = lst[i];
|
||||||
if(maxdist) forCellCM(c2, c) {
|
if(maxdist) forCellCM(c2, c) {
|
||||||
add(c2, dists[i]+1);
|
add_at(c2, dists[i]+1);
|
||||||
if(c2 == breakon) return;
|
if(c2 == breakon) return;
|
||||||
}
|
}
|
||||||
if(c == last) {
|
if(c == last) {
|
||||||
|
@ -60,7 +60,7 @@ bool reptilecheat = false;
|
|||||||
|
|
||||||
#define ONEMPTY if(d == 7 && passable(c, NULL, 0) && !safety)
|
#define ONEMPTY if(d == 7 && passable(c, NULL, 0) && !safety)
|
||||||
|
|
||||||
bool blizzard_no_escape1(cell *c, celllister &cl) {
|
bool blizzard_no_escape1(cell *c, manual_celllister &cl) {
|
||||||
if(!cl.add(c)) return true;
|
if(!cl.add(c)) return true;
|
||||||
if(c->item == itOrbSafety)
|
if(c->item == itOrbSafety)
|
||||||
return false;
|
return false;
|
||||||
@ -76,7 +76,7 @@ bool blizzard_no_escape1(cell *c, celllister &cl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool blizzard_no_escape(cell *c) {
|
bool blizzard_no_escape(cell *c) {
|
||||||
celllister cl(manual);
|
manual_celllister cl;
|
||||||
return blizzard_no_escape1(c, cl);
|
return blizzard_no_escape1(c, cl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,7 +621,7 @@ namespace mapeditor {
|
|||||||
|
|
||||||
vector<pair<cellwalker, cellwalker> > spill_list;
|
vector<pair<cellwalker, cellwalker> > 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.clear(); sval++;
|
||||||
spill_list.emplace_back(tgt, src);
|
spill_list.emplace_back(tgt, src);
|
||||||
int crad = 0, nextstepat = 0;
|
int crad = 0, nextstepat = 0;
|
||||||
@ -668,7 +668,7 @@ namespace mapeditor {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void editAt(cellwalker where, celllister& cl) {
|
void editAt(cellwalker where, manual_celllister& cl) {
|
||||||
|
|
||||||
if(painttype == 4 && radius) {
|
if(painttype == 4 && radius) {
|
||||||
if(where.c->type != copysource.c->type) return;
|
if(where.c->type != copysource.c->type) return;
|
||||||
@ -685,7 +685,7 @@ namespace mapeditor {
|
|||||||
|
|
||||||
void allInPattern(cellwalker where) {
|
void allInPattern(cellwalker where) {
|
||||||
|
|
||||||
celllister cl(manual);
|
manual_celllister cl;
|
||||||
if(!patterns::whichPattern) {
|
if(!patterns::whichPattern) {
|
||||||
editAt(where, cl);
|
editAt(where, cl);
|
||||||
return;
|
return;
|
||||||
|
@ -242,7 +242,7 @@ int getSeepcount() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool canReachPlayer(cell *cf, eMonster m) {
|
bool canReachPlayer(cell *cf, eMonster m) {
|
||||||
celllister cl(manual);
|
manual_celllister cl;
|
||||||
cl.add(cf);
|
cl.add(cf);
|
||||||
for(int i=0; i<isize(cl.lst) && i < 10000; i++) {
|
for(int i=0; i<isize(cl.lst) && i < 10000; i++) {
|
||||||
cell *c = cl.lst[i];
|
cell *c = cl.lst[i];
|
||||||
|
2
orbs.cpp
2
orbs.cpp
@ -247,7 +247,7 @@ bool distanceBound(cell *c1, cell *c2, int d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void checkFreedom(cell *cf) {
|
void checkFreedom(cell *cf) {
|
||||||
celllister cl(manual);
|
manual_celllister cl;
|
||||||
cl.add(cf);
|
cl.add(cf);
|
||||||
for(int i=0; i<isize(cl.lst); i++) {
|
for(int i=0; i<isize(cl.lst); i++) {
|
||||||
cell *c = cl.lst[i];
|
cell *c = cl.lst[i];
|
||||||
|
@ -1011,7 +1011,7 @@ namespace peace {
|
|||||||
clister.emplace_back(cp, cp);
|
clister.emplace_back(cp, cp);
|
||||||
|
|
||||||
int id = 0;
|
int id = 0;
|
||||||
celllister cl(manual);
|
manual_celllister cl;
|
||||||
while(id < isize(clister)) {
|
while(id < isize(clister)) {
|
||||||
cell *c = clister[id].first;
|
cell *c = clister[id].first;
|
||||||
cell *fr = clister[id].second;
|
cell *fr = clister[id].second;
|
||||||
|
Loading…
Reference in New Issue
Block a user