diff options
| author | Quietust | 2012-01-19 21:44:17 -0600 |
|---|---|---|
| committer | Quietust | 2012-01-19 21:44:17 -0600 |
| commit | e7ecda143413105d9e780bd9888ee17b095d9fe8 (patch) | |
| tree | 0ba9272f91f9fac61589e2ce470e02fc968a4be2 /plugins/reveal.cpp | |
| parent | e7dcd4c66ab78ca0dfbd3236fd6a5e808a557124 (diff) | |
| download | dfhack-e7ecda143413105d9e780bd9888ee17b095d9fe8.tar.gz dfhack-e7ecda143413105d9e780bd9888ee17b095d9fe8.tar.bz2 dfhack-e7ecda143413105d9e780bd9888ee17b095d9fe8.tar.xz | |
Kill the Maps module
Diffstat (limited to 'plugins/reveal.cpp')
| -rw-r--r-- | plugins/reveal.cpp | 58 |
1 files changed, 23 insertions, 35 deletions
diff --git a/plugins/reveal.cpp b/plugins/reveal.cpp index d0e72ff5..12577f3e 100644 --- a/plugins/reveal.cpp +++ b/plugins/reveal.cpp @@ -16,21 +16,20 @@ using namespace DFHack; /* * Anything that might reveal Hell is unsafe. */ -bool isSafe(uint32_t x, uint32_t y, uint32_t z, DFHack::Maps *Maps) +bool isSafe(uint32_t x, uint32_t y, uint32_t z) { - DFHack::t_feature *local_feature = NULL; - DFHack::t_feature *global_feature = NULL; + DFHack::t_feature local_feature; + DFHack::t_feature global_feature; // get features of block // error -> obviously not safe to manipulate - if(!Maps->ReadFeatures(x,y,z,&local_feature,&global_feature)) - { + if(!Maps::ReadFeatures(x,y,z,&local_feature,&global_feature)) return false; - } + // Adamantine tubes and temples lead to Hell - if (local_feature && (local_feature->type == df::feature_type::deep_special_tube || local_feature->type == df::feature_type::deep_surface_portal)) + if (local_feature.type == df::feature_type::deep_special_tube || local_feature.type == df::feature_type::deep_surface_portal) return false; // And Hell *is* Hell. - if (global_feature && global_feature->type == df::feature_type::feature_underworld_from_layer) + if (global_feature.type == df::feature_type::feature_underworld_from_layer) return false; // otherwise it's safe. return true; @@ -160,7 +159,6 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> & } c->Suspend(); - DFHack::Maps *Maps =c->getMaps(); DFHack::World *World =c->getWorld(); t_gamemodes gm; World->ReadGameMode(gm); @@ -170,21 +168,14 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> & c->Resume(); return CR_FAILURE; } - if(!Maps->Start()) + if (!Maps::IsValid()) { - con.printerr("Can't init map.\n"); + c->con.printerr("Map is not available!\n"); c->Resume(); return CR_FAILURE; } - if(no_hell && !Maps->StartFeatures()) - { - con.printerr("Unable to read local features; can't reveal map safely.\n"); - c->Resume(); - return CR_FAILURE; - } - - Maps->getSize(x_max,y_max,z_max); + Maps::getSize(x_max,y_max,z_max); hidesaved.reserve(x_max * y_max * z_max); for(uint32_t x = 0; x< x_max;x++) { @@ -192,11 +183,11 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector<std::string> & { for(uint32_t z = 0; z< z_max;z++) { - df::map_block *block = Maps->getBlock(x,y,z); + df::map_block *block = Maps::getBlock(x,y,z); if(block) { // in 'no-hell'/'safe' mode, don't reveal blocks with hell and adamantine - if (no_hell && !isSafe(x, y, z, Maps)) + if (no_hell && !isSafe(x, y, z)) continue; hideblock hb; hb.x = x; @@ -255,7 +246,7 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string> return CR_FAILURE; } c->Suspend(); - DFHack::Maps *Maps =c->getMaps(); + DFHack::World *World =c->getWorld(); t_gamemodes gm; World->ReadGameMode(gm); @@ -265,17 +256,16 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string> c->Resume(); return CR_FAILURE; } - Maps = c->getMaps(); - if(!Maps->Start()) + if (!Maps::IsValid()) { - con.printerr("Can't init map.\n"); + c->con.printerr("Map is not available!\n"); c->Resume(); return CR_FAILURE; } // Sanity check: map size uint32_t x_max_b, y_max_b, z_max_b; - Maps->getSize(x_max_b,y_max_b,z_max_b); + Maps::getSize(x_max_b,y_max_b,z_max_b); if(x_max != x_max_b || y_max != y_max_b || z_max != z_max_b) { con.printerr("The map is not of the same size...\n"); @@ -288,7 +278,7 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector<std::string> for(size_t i = 0; i < hidesaved.size();i++) { hideblock & hb = hidesaved[i]; - df::map_block * b = Maps->getBlock(hb.x,hb.y,hb.z); + df::map_block * b = Maps::getBlock(hb.x,hb.y,hb.z); for (uint32_t i = 0; i < 16;i++) for (uint32_t j = 0; j < 16;j++) { b->designation[i][j].bits.hidden = hb.hiddens[i][j]; @@ -336,13 +326,11 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string> } c->Suspend(); uint32_t x_max,y_max,z_max; - Maps * Maps = c->getMaps(); Gui * Gui = c->getGui(); World * World = c->getWorld(); - // init the map - if(!Maps->Start()) + if (!Maps::IsValid()) { - c->con.printerr("Can't init map. Make sure you have a map loaded in DF.\n"); + c->con.printerr("Map is not available!\n"); c->Resume(); return CR_FAILURE; } @@ -361,7 +349,7 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string> return CR_FAILURE; } int32_t cx, cy, cz; - Maps->getSize(x_max,y_max,z_max); + Maps::getSize(x_max,y_max,z_max); uint32_t tx_max = x_max * 16; uint32_t ty_max = y_max * 16; @@ -373,7 +361,7 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string> return CR_FAILURE; } DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz); - MapCache * MCache = new MapCache(Maps); + MapCache * MCache = new MapCache; int16_t tt = MCache->tiletypeAt(xy); if(isWallTerrain(tt)) { @@ -383,7 +371,7 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string> return CR_FAILURE; } // hide all tiles, flush cache - Maps->getSize(x_max,y_max,z_max); + Maps::getSize(x_max,y_max,z_max); for(uint32_t x = 0; x< x_max;x++) { @@ -391,7 +379,7 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector<std::string> { for(uint32_t z = 0; z< z_max;z++) { - df::map_block * b = Maps->getBlock(x,y,z); + df::map_block * b = Maps::getBlock(x,y,z); if(b) { // change the hidden flag to 0 |
