diff options
| author | Petr Mrázek | 2012-03-01 00:01:24 +0100 |
|---|---|---|
| committer | Petr Mrázek | 2012-03-01 00:01:24 +0100 |
| commit | 07b4044336176e8277f3adaa2e03c406e77b6b76 (patch) | |
| tree | 9019b2ea3ff92b8c77dc464c46d8026d63bbd7ac /needs_porting/lair.cpp | |
| parent | 1f2782d5b86ee62d821ec0c7e33833048fc06b20 (diff) | |
| download | dfhack-07b4044336176e8277f3adaa2e03c406e77b6b76.tar.gz dfhack-07b4044336176e8277f3adaa2e03c406e77b6b76.tar.bz2 dfhack-07b4044336176e8277f3adaa2e03c406e77b6b76.tar.xz | |
Nuke more!
Diffstat (limited to 'needs_porting/lair.cpp')
| -rw-r--r-- | needs_porting/lair.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/needs_porting/lair.cpp b/needs_porting/lair.cpp new file mode 100644 index 00000000..7bf3ddc2 --- /dev/null +++ b/needs_porting/lair.cpp @@ -0,0 +1,74 @@ +// This is a simple bit writer... it marks the whole map as a creature lair, preventing item scatter. + +#include <iostream> +#include <vector> +#include <map> +using namespace std; +#include <DFHack.h> +#include <extra/termutil.h> + +int main (void) +{ + bool temporary_terminal = TemporaryTerminal(); + uint32_t x_max,y_max,z_max; + DFHack::occupancies40d occupancies; + + DFHack::ContextManager DFMgr("Memory.xml"); + DFHack::Context *DF; + try + { + DF = DFMgr.getSingleContext(); + DF->Attach(); + } + catch (exception& e) + { + cerr << e.what() << endl; + if(temporary_terminal) + cin.ignore(); + return 1; + } + + DFHack::Maps *Maps =DF->getMaps(); + + // init the map + if(!Maps->Start()) + { + cerr << "Can't init map." << endl; + if(temporary_terminal) + cin.ignore(); + return 1; + } + + cout << "Designating, please wait..." << endl; + + Maps->getSize(x_max,y_max,z_max); + for(uint32_t x = 0; x< x_max;x++) + { + for(uint32_t y = 0; y< y_max;y++) + { + for(uint32_t z = 0; z< z_max;z++) + { + if(Maps->isValidBlock(x,y,z)) + { + // read block designations + Maps->ReadOccupancy(x,y,z, &occupancies); + //Maps->ReadTileTypes(x,y,z, &tiles); + // change the monster_lair flag to 1 + for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++) + { + // add tile type chack here + occupancies[i][j].bits.monster_lair = 1; + } + // write the designations back + Maps->WriteOccupancy(x,y,z, &occupancies); + } + } + } + } + if(temporary_terminal) + { + cout << "The map has been marked as a creature lair. Items shouldn't scatter." << endl; + cin.ignore(); + } + return 0; +} |
