From f60e44c395a475f015a2a55a6ef1820a95e65c9b Mon Sep 17 00:00:00 2001 From: expwnent Date: Thu, 3 Jan 2013 13:11:11 -0500 Subject: [PATCH] DiggingInvaders: minor changes. --- plugins/diggingInvaders/diggingInvaders.cpp | 25 ++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/plugins/diggingInvaders/diggingInvaders.cpp b/plugins/diggingInvaders/diggingInvaders.cpp index 76feb4c90..f53df36d5 100644 --- a/plugins/diggingInvaders/diggingInvaders.cpp +++ b/plugins/diggingInvaders/diggingInvaders.cpp @@ -197,7 +197,7 @@ void doDiggingInvaders(color_ostream& out, void* ptr) { xMax *= 16; yMax *= 16; MapExtras::MapCache cache; - df::unit* firstInvader = NULL; + vector invaders; //TODO: look for invaders with buildingdestroyer:3 @@ -216,12 +216,16 @@ void doDiggingInvaders(color_ostream& out, void* ptr) { invaderPts.insert(unit->pos); costMap[unit->pos] = 0; fringe.insert(unit->pos); - if ( firstInvader == NULL ) - firstInvader = unit; + invaders.push_back(unit); } else { continue; } } + + if ( invaders.empty() ) { + return; + } + df::unit* firstInvader = invaders[0]; out << firstInvader->id << endl; out << firstInvader->pos.x << ", " << firstInvader->pos.y << ", " << firstInvader->pos.z << endl; @@ -297,12 +301,14 @@ void doDiggingInvaders(color_ostream& out, void* ptr) { if ( Maps::canStepBetween(pt, parent) ) { } else { - if ( pt.z < parent.z ) { - requiresZNeg.insert(parent); - requiresZPos.insert(pt); - } else if ( pt.z > parent.z ) { - requiresZNeg.insert(pt); - requiresZPos.insert(parent); + if ( pt.x == parent.x && pt.y == parent.y ) { + if ( pt.z < parent.z ) { + requiresZNeg.insert(parent); + requiresZPos.insert(pt); + } else if ( pt.z > parent.z ) { + requiresZNeg.insert(pt); + requiresZPos.insert(parent); + } } //if ( workNeeded[pt] > workNeeded[parent] ) { importantEdges.push_front(Edge(pt,parent,0)); @@ -407,7 +413,6 @@ void doDiggingInvaders(color_ostream& out, void* ptr) { df::tiletype_shape shape1 = ENUM_ATTR(tiletype, shape, *type1); df::tiletype_shape shape2 = ENUM_ATTR(tiletype, shape, *type2); bool construction2 = ENUM_ATTR(tiletype, material, *type2) == df::enums::tiletype_material::CONSTRUCTION; - //out.print("shape1 = %d, shape2 = %d, "); if ( construction2 ) { out.print("%s, line %d. Removing construction (%d,%d,%d)\n", __FILE__, __LINE__, pt2.x,pt2.y,pt2.z); df::job* job = new df::job();