diff --git a/game.cpp b/game.cpp index 66256abc..89173aa4 100644 --- a/game.cpp +++ b/game.cpp @@ -129,8 +129,8 @@ vector targets; // list of monster targets // monsters of specific types to move vector worms, ivies, ghosts, golems, hexsnakes; -vector temps; // temporary changes during bfs -vector tempval; // restore temps +/** temporary changes during bfs */ +vector> tempmonsters; // a bit nicer way of DFS vector reachedfrom; @@ -2754,7 +2754,8 @@ EX bool cellEdgeUnstable(cell *c, flagtype flags IS(0)) { // find worms and ivies EX void settemp(cell *c) { - temps.push_back(c); tempval.push_back(c->monst); c->monst = moNone; + tempmonsters.emplace_back(c, (eMonster) c->monst); + c->monst = moNone; } EX void findWormIvy(cell *c) { @@ -3135,7 +3136,7 @@ EX void bfs() { int dcs = isize(dcal); for(int i=0; icpdist = INFD; worms.clear(); ivies.clear(); ghosts.clear(); golems.clear(); - temps.clear(); tempval.clear(); targets.clear(); + tempmonsters.clear(); targets.clear(); statuecount = 0; hexsnakes.clear(); @@ -3368,8 +3369,7 @@ EX void bfs() { for(int i=0; imonst = tempval[i]; + for(auto& t: tempmonsters) t.first->monst = t.second; buildAirmap(); }