Warning: does not work. Temp commit!

develop
expwnent 2012-08-24 11:40:51 -04:00
parent cb24f1e53a
commit 45efcfc763
3 changed files with 33 additions and 9 deletions

@ -173,5 +173,10 @@ DFHACK_EXPORT bool constructWithFilters(df::building *bld, std::vector<df::job_i
*/
DFHACK_EXPORT bool deconstruct(df::building *bld);
/**
* Immediately deconstructs a building.
*/
DFHACK_EXPORT bool deconstructImmediately(df::building *bld);
}
}

@ -977,16 +977,27 @@ bool Buildings::deconstruct(df::building *bld)
bld->queueDestroy();
return false;
}
return deconstructImmediately(bld);
}
bool Buildings::deconstructImmediately(df::building *bld)
{
using df::global::ui;
using df::global::world;
using df::global::ui_look_list;
CHECK_NULL_POINTER(bld);
/* Immediate destruction code path.
Should only happen for abstract and unconstructed buildings.*/
if (bld->isSettingOccupancy())
{
markBuildingTiles(bld, true);
bld->cleanupMap();
}
bld->removeUses(false, false);
// Assume: no parties.
unlinkRooms(bld);
@ -997,16 +1008,16 @@ bool Buildings::deconstruct(df::building *bld)
// Assume: does not affect pathfinding
bld->deconstructItems(false, false);
// Don't clear arrows.
bld->uncategorize();
delete bld;
if (world->selected_building == bld)
{
world->selected_building = NULL;
world->update_selected_building = true;
}
for (int i = ui_look_list->items.size()-1; i >= 0; i--)
{
auto item = ui_look_list->items[i];
@ -1017,10 +1028,10 @@ bool Buildings::deconstruct(df::building *bld)
delete item;
}
}
Job::checkBuildingsNow();
Job::checkDesignationsNow();
return true;
}

@ -10,8 +10,12 @@
#include "df/ui.h"
#include "df/unit.h"
#include "df/world.h"
#include "modules/World.h"
#include "Types.h"
#include "modules/Buildings.h"
//crashes without Types.h
#include "modules/MapCache.h"
#include "modules/World.h"
#include <vector>
#include <algorithm>
@ -293,7 +297,11 @@ command_result diggingInvadersFunc(color_ostream &out, std::vector <std::string>
//found it!
foundIt = true;
//destroy it
building->deconstructItems(false, false);
out.print("deconstructImmediately...\n");
DFHack::Buildings::deconstructImmediately(building);
out.print("done\n");
building = NULL;
//building->deconstructItems(false, false);
//building->removeUses(false, false);
break;
}