From 2cc6bcf0e97dbdf60492067cd71dc79432a35687 Mon Sep 17 00:00:00 2001 From: Quietust Date: Sat, 21 Jan 2012 18:31:15 -0600 Subject: [PATCH] Use CoreSuspender and namespace df::enums --- plugins/autodump.cpp | 8 +- plugins/cleaners.cpp | 18 +- plugins/cleanowned.cpp | 25 +-- plugins/colonies.cpp | 22 +-- plugins/deramp.cpp | 8 +- plugins/drybuckets.cpp | 47 ++--- plugins/filltraffic.cpp | 399 +++++++++++++++++++--------------------- plugins/fixwagons.cpp | 139 +++++++------- plugins/flows.cpp | 11 +- plugins/initflags.cpp | 2 +- plugins/liquids.cpp | 13 +- plugins/plants.cpp | 11 +- plugins/probe.cpp | 13 +- plugins/prospector.cpp | 17 +- plugins/regrass.cpp | 90 ++++----- plugins/reveal.cpp | 24 +-- plugins/seedwatch.cpp | 21 +-- plugins/tiletypes.cpp | 8 +- plugins/tubefill.cpp | 11 +- plugins/vdig.cpp | 277 ++++++++++++++-------------- plugins/weather.cpp | 39 ++-- 21 files changed, 582 insertions(+), 621 deletions(-) diff --git a/plugins/autodump.cpp b/plugins/autodump.cpp index ccac5d395..f726502ce 100644 --- a/plugins/autodump.cpp +++ b/plugins/autodump.cpp @@ -26,6 +26,8 @@ using namespace std; #include "df/general_ref.h" using namespace DFHack; +using namespace df::enums; + using MapExtras::Block; using MapExtras::MapCache; using df::global::world; @@ -291,9 +293,9 @@ DFhackCExport command_result df_autodump_destroy_item(Core * c, vector return CR_FAILURE; // Allow undoing the destroy - if (df::global::world->frame_counter != last_frame) + if (world->frame_counter != last_frame) { - last_frame = df::global::world->frame_counter; + last_frame = world->frame_counter; pending_destroy.clear(); } @@ -327,7 +329,7 @@ DFhackCExport command_result df_autodump_destroy_item(Core * c, vector for (unsigned i = 0; i < item->itemrefs.size(); i++) { df::general_ref *ref = item->itemrefs[i]; - if (ref->getType() == df::general_ref_type::UNIT_HOLDER) + if (ref->getType() == general_ref_type::UNIT_HOLDER) { c->con.printerr("Choosing not to destroy items in unit inventory.\n"); return CR_FAILURE; diff --git a/plugins/cleaners.cpp b/plugins/cleaners.cpp index 00498a7fc..f8a5ba59e 100644 --- a/plugins/cleaners.cpp +++ b/plugins/cleaners.cpp @@ -17,6 +17,7 @@ using std::vector; using std::string; using namespace DFHack; using namespace DFHack::Simple; +using namespace df::enums; using df::global::world; using df::global::cursor; @@ -40,20 +41,20 @@ command_result cleanmap (Core * c, bool snow, bool mud) for (int j = 0; j < block->block_events.size(); j++) { df::block_square_event *evt = block->block_events[j]; - if (evt->getType() != df::block_square_event_type::material_spatter) + if (evt->getType() != block_square_event_type::material_spatter) continue; // type verified - recast to subclass df::block_square_event_material_spatterst *spatter = (df::block_square_event_material_spatterst *)evt; // filter snow if(!snow - && spatter->mat_type == df::builtin_mats::WATER - && spatter->mat_state == df::matter_state::Powder) + && spatter->mat_type == builtin_mats::WATER + && spatter->mat_state == matter_state::Powder) continue; // filter mud if(!mud - && spatter->mat_type == df::builtin_mats::MUD - && spatter->mat_state == df::matter_state::Solid) + && spatter->mat_type == builtin_mats::MUD + && spatter->mat_state == matter_state::Solid) continue; delete evt; @@ -119,7 +120,7 @@ DFhackCExport command_result spotclean (Core * c, vector & parameters) if (cursor->x == -30000) { c->con.printerr("The cursor is not active.\n"); - return CR_FAILURE; + return CR_WRONG_USAGE; } df::map_block *block = Maps::getBlockAbs(cursor->x, cursor->y, cursor->z); if (block == NULL) @@ -131,7 +132,7 @@ DFhackCExport command_result spotclean (Core * c, vector & parameters) for (int i = 0; i < block->block_events.size(); i++) { df::block_square_event *evt = block->block_events[i]; - if (evt->getType() != df::block_square_event_type::material_spatter) + if (evt->getType() != block_square_event_type::material_spatter) continue; // type verified - recast to subclass df::block_square_event_material_spatterst *spatter = (df::block_square_event_material_spatterst *)evt; @@ -189,14 +190,13 @@ DFhackCExport command_result clean (Core * c, vector & parameters) ); return CR_OK; } - c->Suspend(); + CoreSuspender suspend(c); if(map) cleanmap(c,snow,mud); if(units) cleanunits(c); if(items) cleanitems(c); - c->Resume(); return CR_OK; } diff --git a/plugins/cleanowned.cpp b/plugins/cleanowned.cpp index be6012b7f..719e58f04 100644 --- a/plugins/cleanowned.cpp +++ b/plugins/cleanowned.cpp @@ -18,11 +18,13 @@ using namespace std; #include "modules/Units.h" #include "modules/Materials.h" #include "modules/Translation.h" -using namespace DFHack; -using namespace DFHack::Simple; #include "DataDefs.h" #include "df/world.h" +using namespace DFHack; +using namespace DFHack::Simple; +using namespace df::enums; + using df::global::world; DFhackCExport command_result df_cleanowned (Core * c, vector & parameters); @@ -91,7 +93,9 @@ DFhackCExport command_result df_cleanowned (Core * c, vector & paramete return CR_FAILURE; } } - c->Suspend(); + + CoreSuspender suspend(c); + DFHack::Materials *Materials = c->getMaterials(); DFHack::Units *Creatures = c->getUnits(); DFHack::Translation *Tran = c->getTranslation(); @@ -132,13 +136,13 @@ DFhackCExport command_result df_cleanowned (Core * c, vector & paramete else if (item->flags.bits.on_ground) { int32_t type = item->getType(); - if(type == df::item_type::MEAT || - type == df::item_type::FISH || - type == df::item_type::VERMIN || - type == df::item_type::PET || - type == df::item_type::PLANT || - type == df::item_type::CHEESE || - type == df::item_type::FOOD + if(type == item_type::MEAT || + type == item_type::FISH || + type == item_type::VERMIN || + type == item_type::PET || + type == item_type::PLANT || + type == item_type::CHEESE || + type == item_type::FOOD ) { confiscate = true; @@ -207,6 +211,5 @@ DFhackCExport command_result df_cleanowned (Core * c, vector & paramete c->con.print("\n"); } } - c->Resume(); return CR_OK; } diff --git a/plugins/colonies.cpp b/plugins/colonies.cpp index ba1e16cc7..9ebbc8a92 100644 --- a/plugins/colonies.cpp +++ b/plugins/colonies.cpp @@ -23,8 +23,8 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector { commands.clear(); commands.push_back(PluginCommand("colonies", - "List or change wild colonies (ants hills and such)", - colonies)); + "List or change wild colonies (ants hills and such)", + colonies)); return CR_OK; } @@ -57,19 +57,18 @@ DFhackCExport command_result colonies (Core * c, vector & parameters) if(help) { c->con.print("Without any options, this command lists all the vermin colonies present.\n" - "Options:\n" - "kill - destroy colonies\n" - "bees - turn colonies into honey bees\n" - ); + "Options:\n" + "kill - destroy colonies\n" + "bees - turn colonies into honey bees\n" + ); return CR_OK; } if (destroy && convert) { c->con.printerr("Kill or make bees? DECIDE!\n"); - c->Resume(); return CR_FAILURE; } - c->Suspend(); + CoreSuspender suspend(c); Materials * materials = c->getMaterials(); @@ -84,7 +83,6 @@ DFhackCExport command_result colonies (Core * c, vector & parameters) materials->Finish(); - c->Resume(); return CR_OK; } @@ -110,11 +108,13 @@ void convertColonies(Materials *Materials) { int bee_idx = -1; for (size_t i = 0; i < Materials->raceEx.size(); i++) + { if (Materials->raceEx[i].id == "HONEY_BEE") { bee_idx = i; break; } + } if (bee_idx == -1) { @@ -153,8 +153,8 @@ void showColonies(Core *c, Materials *Materials) if(sp.race != -1) race = Materials->raceEx[sp.race].id; - c->con.print("Colony %u: %s at %d:%d:%d\n", i, - race.c_str(), sp.x, sp.y, sp.z); + c->con.print("Colony %u: %s at %d:%d:%d\n", i, + race.c_str(), sp.x, sp.y, sp.z); } } diff --git a/plugins/deramp.cpp b/plugins/deramp.cpp index bdeb0a072..233397568 100644 --- a/plugins/deramp.cpp +++ b/plugins/deramp.cpp @@ -12,10 +12,10 @@ using std::vector; using std::string; using namespace DFHack; +using namespace DFHack::Simple; +using namespace df::enums; using df::global::world; -using namespace DFHack; -using namespace DFHack::Simple; DFhackCExport command_result df_deramp (Core * c, vector & parameters) { @@ -48,7 +48,7 @@ DFhackCExport command_result df_deramp (Core * c, vector & parameters) { int16_t oldT = block->tiletype[x][y]; if ((tileShape(oldT) == RAMP) && - (block->designation[x][y].bits.dig == df::tile_dig_designation::Default)) + (block->designation[x][y].bits.dig == tile_dig_designation::Default)) { // Current tile is a ramp. // Set current tile, as accurately as can be expected @@ -59,7 +59,7 @@ DFhackCExport command_result df_deramp (Core * c, vector & parameters) continue; // Set new tile type, clear designation block->tiletype[x][y] = newT; - block->designation[x][y].bits.dig = df::tile_dig_designation::No; + block->designation[x][y].bits.dig = tile_dig_designation::No; // Check the tile above this one, in case a downward slope needs to be removed. if ((above) && (tileShape(above->tiletype[x][y]) == RAMP_TOP)) diff --git a/plugins/drybuckets.cpp b/plugins/drybuckets.cpp index abe692c0a..582c7133f 100644 --- a/plugins/drybuckets.cpp +++ b/plugins/drybuckets.cpp @@ -13,44 +13,45 @@ using std::string; using std::vector; using namespace DFHack; +using namespace df::enums; using df::global::world; DFhackCExport command_result df_drybuckets (Core * c, vector & parameters) { - if (!parameters.empty()) - return CR_WRONG_USAGE; - - CoreSuspender suspend(c); - - int dried_total = 0; - for (int i = 0; i < world->items.all.size(); i++) - { - df::item *item = world->items.all[i]; - if ((item->getType() == df::item_type::LIQUID_MISC) && (item->getMaterial() == df::builtin_mats::WATER)) - { - item->flags.bits.garbage_colect = 1; - dried_total++; - } - } - if (dried_total) - c->con.print("Done. %d buckets of water marked for emptying.\n", dried_total); - return CR_OK; + if (!parameters.empty()) + return CR_WRONG_USAGE; + + CoreSuspender suspend(c); + + int dried_total = 0; + for (int i = 0; i < world->items.all.size(); i++) + { + df::item *item = world->items.all[i]; + if ((item->getType() == item_type::LIQUID_MISC) && (item->getMaterial() == builtin_mats::WATER)) + { + item->flags.bits.garbage_colect = 1; + dried_total++; + } + } + if (dried_total) + c->con.print("Done. %d buckets of water marked for emptying.\n", dried_total); + return CR_OK; } DFhackCExport const char * plugin_name ( void ) { - return "drybuckets"; + return "drybuckets"; } DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); - commands.push_back(PluginCommand("drybuckets", "Removes water from buckets.", df_drybuckets)); - return CR_OK; + commands.clear(); + commands.push_back(PluginCommand("drybuckets", "Removes water from buckets.", df_drybuckets)); + return CR_OK; } DFhackCExport command_result plugin_shutdown ( Core * c ) { - return CR_OK; + return CR_OK; } diff --git a/plugins/filltraffic.cpp b/plugins/filltraffic.cpp index c87b50165..ef5a9b617 100644 --- a/plugins/filltraffic.cpp +++ b/plugins/filltraffic.cpp @@ -15,6 +15,7 @@ using std::stack; using MapExtras::MapCache; using namespace DFHack; +using namespace df::enums; //Function pointer type for whole-map tile checks. typedef void (*checkTile)(DFHack::DFCoord, MapExtras::MapCache &); @@ -25,8 +26,8 @@ DFhackCExport command_result alltraffic(DFHack::Core * c, std::vector &commands) { commands.clear(); - commands.push_back(PluginCommand("filltraffic","Flood-fill with selected traffic designation from cursor",filltraffic)); - commands.push_back(PluginCommand("alltraffic","Set traffic for the entire map",alltraffic)); + commands.push_back(PluginCommand("filltraffic","Flood-fill with selected traffic designation from cursor",filltraffic)); + commands.push_back(PluginCommand("alltraffic","Set traffic for the entire map",alltraffic)); return CR_OK; } @@ -54,69 +55,68 @@ DFhackCExport command_result plugin_shutdown ( Core * c ) DFhackCExport command_result filltraffic(DFHack::Core * c, std::vector & params) { - //Maximum map size. - uint32_t x_max,y_max,z_max; - //Source and target traffic types. - df::tile_traffic source = df::tile_traffic::Normal; - df::tile_traffic target = df::tile_traffic::Normal; - //Option flags - bool updown = false; - bool checkpit = true; - bool checkbuilding = true; - - //Loop through parameters + //Maximum map size. + uint32_t x_max,y_max,z_max; + //Source and target traffic types. + df::tile_traffic source = tile_traffic::Normal; + df::tile_traffic target = tile_traffic::Normal; + //Option flags + bool updown = false; + bool checkpit = true; + bool checkbuilding = true; + + //Loop through parameters for(int i = 0; i < params.size();i++) { if(params[i] == "help" || params[i] == "?") { c->con.print("Flood-fill selected traffic type from the cursor.\n" - "Traffic Type Codes:\n" - "\tH: High Traffic\n" - "\tN: Normal Traffic\n" - "\tL: Low Traffic\n" - "\tR: Restricted Traffic\n" - "Other Options:\n" - "\tX: Fill across z-levels.\n" - "\tB: Include buildings and stockpiles.\n" - "\tP: Include empty space.\n" - "Example:\n" - "'filltraffic H' - When used in a room with doors,\n" - " it will set traffic to HIGH in just that room." - ); + "Traffic Type Codes:\n" + "\tH: High Traffic\n" + "\tN: Normal Traffic\n" + "\tL: Low Traffic\n" + "\tR: Restricted Traffic\n" + "Other Options:\n" + "\tX: Fill across z-levels.\n" + "\tB: Include buildings and stockpiles.\n" + "\tP: Include empty space.\n" + "Example:\n" + "'filltraffic H' - When used in a room with doors,\n" + " it will set traffic to HIGH in just that room." + ); return CR_OK; } switch (toupper(params[i][0])) { - case 'H': - target = df::tile_traffic::High; break; - case 'N': - target = df::tile_traffic::Normal; break; - case 'L': - target = df::tile_traffic::Low; break; - case 'R': - target = df::tile_traffic::Restricted; break; - case 'X': - updown = true; break; - case 'B': - checkbuilding = false; break; - case 'P': - checkpit = false; break; + case 'H': + target = tile_traffic::High; break; + case 'N': + target = tile_traffic::Normal; break; + case 'L': + target = tile_traffic::Low; break; + case 'R': + target = tile_traffic::Restricted; break; + case 'X': + updown = true; break; + case 'B': + checkbuilding = false; break; + case 'P': + checkpit = false; break; } } //Initialization. - c->Suspend(); + CoreSuspender suspend(c); DFHack::Gui * Gui = c->getGui(); if (!Maps::IsValid()) { c->con.printerr("Map is not available!\n"); - c->Resume(); return CR_FAILURE; } - int32_t cx, cy, cz; + int32_t cx, cy, cz; Maps::getSize(x_max,y_max,z_max); uint32_t tx_max = x_max * 16; uint32_t ty_max = y_max * 16; @@ -124,7 +124,6 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vectorcon.printerr("Cursor is not active.\n"); - c->Resume(); return CR_FAILURE; } @@ -142,96 +141,91 @@ DFhackCExport command_result filltraffic(DFHack::Core * c, std::vectorcon.printerr("This tile is already set to the target traffic type.\n"); - c->Resume(); return CR_FAILURE; } if(DFHack::isWallTerrain(tt)) { c->con.printerr("This tile is a wall. Please select a passable tile.\n"); - c->Resume(); return CR_FAILURE; } - if(checkpit && DFHack::isOpenTerrain(tt)) - { - c->con.printerr("This tile is a hole. Please select a passable tile.\n"); - c->Resume(); + if(checkpit && DFHack::isOpenTerrain(tt)) + { + c->con.printerr("This tile is a hole. Please select a passable tile.\n"); return CR_FAILURE; - } + } - if(checkbuilding && oc.bits.building) - { - c->con.printerr("This tile contains a building. Please select an empty tile.\n"); - c->Resume(); + if(checkbuilding && oc.bits.building) + { + c->con.printerr("This tile contains a building. Please select an empty tile.\n"); return CR_FAILURE; - } - - c->con.print("%d/%d/%d ... FILLING!\n", cx,cy,cz); - - //Naive four-way or six-way flood fill with possible tiles on a stack. - stack flood; - flood.push(xy); - - while(!flood.empty()) - { - xy = flood.top(); - flood.pop(); - - des = MCache.designationAt(xy); - if (des.bits.traffic != source) continue; - - tt = MCache.tiletypeAt(xy); - - if(DFHack::isWallTerrain(tt)) continue; - if(checkpit && DFHack::isOpenTerrain(tt)) continue; - - if (checkbuilding) - { - oc = MCache.occupancyAt(xy); - if(oc.bits.building) continue; - } - - //This tile is ready. Set its traffic level and add surrounding tiles. - if (MCache.testCoord(xy)) - { - des.bits.traffic = target; - MCache.setDesignationAt(xy,des); - - if (xy.x > 0) - { - flood.push(DFHack::DFCoord(xy.x - 1, xy.y, xy.z)); - } - if (xy.x < tx_max - 1) - { - flood.push(DFHack::DFCoord(xy.x + 1, xy.y, xy.z)); - } - if (xy.y > 0) - { - flood.push(DFHack::DFCoord(xy.x, xy.y - 1, xy.z)); - } - if (xy.y < ty_max - 1) - { - flood.push(DFHack::DFCoord(xy.x, xy.y + 1, xy.z)); - } - - if (updown) - { - if (xy.z > 0 && DFHack::LowPassable(tt)) - { - flood.push(DFHack::DFCoord(xy.x, xy.y, xy.z - 1)); - } - if (xy.z < z_max && DFHack::HighPassable(tt)) - { - flood.push(DFHack::DFCoord(xy.x, xy.y, xy.z + 1)); - } - } - - } - } - - MCache.WriteAll(); - c->Resume(); + } + + c->con.print("%d/%d/%d ... FILLING!\n", cx,cy,cz); + + //Naive four-way or six-way flood fill with possible tiles on a stack. + stack flood; + flood.push(xy); + + while(!flood.empty()) + { + xy = flood.top(); + flood.pop(); + + des = MCache.designationAt(xy); + if (des.bits.traffic != source) continue; + + tt = MCache.tiletypeAt(xy); + + if(DFHack::isWallTerrain(tt)) continue; + if(checkpit && DFHack::isOpenTerrain(tt)) continue; + + if (checkbuilding) + { + oc = MCache.occupancyAt(xy); + if(oc.bits.building) continue; + } + + //This tile is ready. Set its traffic level and add surrounding tiles. + if (MCache.testCoord(xy)) + { + des.bits.traffic = target; + MCache.setDesignationAt(xy,des); + + if (xy.x > 0) + { + flood.push(DFHack::DFCoord(xy.x - 1, xy.y, xy.z)); + } + if (xy.x < tx_max - 1) + { + flood.push(DFHack::DFCoord(xy.x + 1, xy.y, xy.z)); + } + if (xy.y > 0) + { + flood.push(DFHack::DFCoord(xy.x, xy.y - 1, xy.z)); + } + if (xy.y < ty_max - 1) + { + flood.push(DFHack::DFCoord(xy.x, xy.y + 1, xy.z)); + } + + if (updown) + { + if (xy.z > 0 && DFHack::LowPassable(tt)) + { + flood.push(DFHack::DFCoord(xy.x, xy.y, xy.z - 1)); + } + if (xy.z < z_max && DFHack::HighPassable(tt)) + { + flood.push(DFHack::DFCoord(xy.x, xy.y, xy.z + 1)); + } + } + + } + } + + MCache.WriteAll(); return CR_OK; } @@ -239,35 +233,35 @@ enum e_checktype {no_check, check_equal, check_nequal}; DFhackCExport command_result alltraffic(DFHack::Core * c, std::vector & params) { - void (*proc)(DFHack::DFCoord, MapExtras::MapCache &) = allNormal; - - //Loop through parameters + void (*proc)(DFHack::DFCoord, MapExtras::MapCache &) = allNormal; + + //Loop through parameters for(int i = 0; i < params.size();i++) { if(params[i] == "help" || params[i] == "?") { c->con.print("Set traffic types for all tiles on the map.\n" - "Traffic Type Codes:\n" - " H: High Traffic\n" - " N: Normal Traffic\n" - " L: Low Traffic\n" - " R: Restricted Traffic\n" - ); + "Traffic Type Codes:\n" + " H: High Traffic\n" + " N: Normal Traffic\n" + " L: Low Traffic\n" + " R: Restricted Traffic\n" + ); return CR_OK; } - //Pick traffic type. Possibly set bounding rectangle later. - switch (toupper(params[i][0])) - { - case 'H': - proc = allHigh; break; - case 'N': - proc = allNormal; break; - case 'L': - proc = allLow; break; - case 'R': - proc = allRestricted; break; - } + //Pick traffic type. Possibly set bounding rectangle later. + switch (toupper(params[i][0])) + { + case 'H': + proc = allHigh; break; + case 'N': + proc = allNormal; break; + case 'L': + proc = allLow; break; + case 'R': + proc = allRestricted; break; + } } return setAllMatching(c, proc); @@ -278,95 +272,90 @@ DFhackCExport command_result alltraffic(DFHack::Core * c, std::vectorSuspend(); + //Initialization. + CoreSuspender suspend(c); DFHack::Gui * Gui = c->getGui(); if (!Maps::IsValid()) { c->con.printerr("Map is not available!\n"); - c->Resume(); return CR_FAILURE; } - //Maximum map size. - uint32_t x_max,y_max,z_max; + //Maximum map size. + uint32_t 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; - //Ensure maximum coordinate is within map. Truncate to map edge. - maxCoord.x = std::min((uint32_t) maxCoord.x, tx_max); - maxCoord.y = std::min((uint32_t) maxCoord.y, ty_max); - maxCoord.z = std::min((uint32_t) maxCoord.z, z_max); + //Ensure maximum coordinate is within map. Truncate to map edge. + maxCoord.x = std::min((uint32_t) maxCoord.x, tx_max); + maxCoord.y = std::min((uint32_t) maxCoord.y, ty_max); + maxCoord.z = std::min((uint32_t) maxCoord.z, z_max); - //Check minimum co-ordinates against maximum map size - if (minCoord.x > maxCoord.x) - { - c->con.printerr("Minimum x coordinate is greater than maximum x coordinate.\n"); - c->Resume(); + //Check minimum co-ordinates against maximum map size + if (minCoord.x > maxCoord.x) + { + c->con.printerr("Minimum x coordinate is greater than maximum x coordinate.\n"); return CR_FAILURE; - } - if (minCoord.y > maxCoord.y) - { - c->con.printerr("Minimum y coordinate is greater than maximum y coordinate.\n"); - c->Resume(); + } + if (minCoord.y > maxCoord.y) + { + c->con.printerr("Minimum y coordinate is greater than maximum y coordinate.\n"); return CR_FAILURE; - } - if (minCoord.z > maxCoord.y) - { - c->con.printerr("Minimum z coordinate is greater than maximum z coordinate.\n"); - c->Resume(); + } + if (minCoord.z > maxCoord.y) + { + c->con.printerr("Minimum z coordinate is greater than maximum z coordinate.\n"); return CR_FAILURE; - } - - MapExtras::MapCache MCache; - - c->con.print("Setting traffic...\n"); - - //Loop through every single tile - for(uint32_t x = minCoord.x; x <= maxCoord.x; x++) - { - for(uint32_t y = minCoord.y; y <= maxCoord.y; y++) - { - for(uint32_t z = minCoord.z; z <= maxCoord.z; z++) - { - DFHack::DFCoord tile = DFHack::DFCoord(x, y, z); - checkProc(tile, MCache); - } - } - } - - MCache.WriteAll(); - c->con.print("Complete!\n"); - c->Resume(); + } + + MapExtras::MapCache MCache; + + c->con.print("Setting traffic...\n"); + + //Loop through every single tile + for(uint32_t x = minCoord.x; x <= maxCoord.x; x++) + { + for(uint32_t y = minCoord.y; y <= maxCoord.y; y++) + { + for(uint32_t z = minCoord.z; z <= maxCoord.z; z++) + { + DFHack::DFCoord tile = DFHack::DFCoord(x, y, z); + checkProc(tile, MCache); + } + } + } + + MCache.WriteAll(); + c->con.print("Complete!\n"); return CR_OK; } //Unconditionally set map to target traffic type void allHigh(DFHack::DFCoord coord, MapExtras::MapCache &map) { - df::tile_designation des = map.designationAt(coord); - des.bits.traffic = df::tile_traffic::High; - map.setDesignationAt(coord, des); + df::tile_designation des = map.designationAt(coord); + des.bits.traffic = tile_traffic::High; + map.setDesignationAt(coord, des); } void allNormal(DFHack::DFCoord coord, MapExtras::MapCache &map) { - df::tile_designation des = map.designationAt(coord); - des.bits.traffic = df::tile_traffic::Normal; - map.setDesignationAt(coord, des); + df::tile_designation des = map.designationAt(coord); + des.bits.traffic = tile_traffic::Normal; + map.setDesignationAt(coord, des); } void allLow(DFHack::DFCoord coord, MapExtras::MapCache &map) { - df::tile_designation des = map.designationAt(coord); - des.bits.traffic = df::tile_traffic::Low; - map.setDesignationAt(coord, des); + df::tile_designation des = map.designationAt(coord); + des.bits.traffic = tile_traffic::Low; + map.setDesignationAt(coord, des); } void allRestricted(DFHack::DFCoord coord, MapExtras::MapCache &map) { - df::tile_designation des = map.designationAt(coord); - des.bits.traffic = df::tile_traffic::Restricted; - map.setDesignationAt(coord, des); -} + df::tile_designation des = map.designationAt(coord); + des.bits.traffic = tile_traffic::Restricted; + map.setDesignationAt(coord, des); +} \ No newline at end of file diff --git a/plugins/fixwagons.cpp b/plugins/fixwagons.cpp index 9f9a4732f..31d0a9dad 100644 --- a/plugins/fixwagons.cpp +++ b/plugins/fixwagons.cpp @@ -15,92 +15,93 @@ using std::string; using std::vector; using namespace DFHack; +using namespace df::enums; using df::global::world; command_result df_fixwagons (Core *c, vector ¶meters) { - if (!parameters.empty()) - return CR_WRONG_USAGE; + if (!parameters.empty()) + return CR_WRONG_USAGE; - CoreSuspender suspend(c); - int32_t wagon_creature = -1, wagon_puller_creature = -1; - df::creature_raw *wagon, *wagon_puller; - for (int i = 0; i < world->raws.creatures.all.size(); i++) - { - df::creature_raw *cr = world->raws.creatures.all[i]; - if (cr->flags.is_set(df::creature_raw_flags::EQUIPMENT_WAGON) && (wagon_creature == -1)) - { - wagon = cr; - wagon_creature = i; - } - if ((cr->creature_id == "HORSE") && (wagon_puller_creature == -1)) - { - wagon_puller = cr; - wagon_puller_creature = i; - } - } - if (wagon_creature == -1) - { - c->con.printerr("Couldn't find a valid wagon creature!\n"); - return CR_FAILURE; - } - if (wagon_puller_creature == -1) - { - c->con.printerr("Couldn't find 'HORSE' creature for default wagon puller!\n"); - return CR_FAILURE; - } - int count = 0; - for (int i = 0; i < world->entities.all.size(); i++) - { - bool updated = false; - df::historical_entity *ent = world->entities.all[i]; - if (!ent->entity_raw->flags.is_set(df::entity_raw_flags::COMMON_DOMESTIC_PULL)) - continue; - if (ent->resources.animals.wagon_races.size() == 0) - { - updated = true; - for (int j = 0; j < wagon->caste.size(); j++) - { - ent->resources.animals.wagon_races.push_back(wagon_creature); - ent->resources.animals.wagon_castes.push_back(j); - } - } - if (ent->resources.animals.wagon_puller_races.size() == 0) - { - updated = true; - for (int j = 0; j < wagon_puller->caste.size(); j++) - { - ent->resources.animals.wagon_puller_races.push_back(wagon_puller_creature); - ent->resources.animals.wagon_puller_castes.push_back(j); - } - } - if (updated) - count++; - } - if(count) - c->con.print("Fixed %d civilizations to bring wagons once again.\n", count); - return CR_OK; + CoreSuspender suspend(c); + int32_t wagon_creature = -1, wagon_puller_creature = -1; + df::creature_raw *wagon, *wagon_puller; + for (int i = 0; i < world->raws.creatures.all.size(); i++) + { + df::creature_raw *cr = world->raws.creatures.all[i]; + if (cr->flags.is_set(creature_raw_flags::EQUIPMENT_WAGON) && (wagon_creature == -1)) + { + wagon = cr; + wagon_creature = i; + } + if ((cr->creature_id == "HORSE") && (wagon_puller_creature == -1)) + { + wagon_puller = cr; + wagon_puller_creature = i; + } + } + if (wagon_creature == -1) + { + c->con.printerr("Couldn't find a valid wagon creature!\n"); + return CR_FAILURE; + } + if (wagon_puller_creature == -1) + { + c->con.printerr("Couldn't find 'HORSE' creature for default wagon puller!\n"); + return CR_FAILURE; + } + int count = 0; + for (int i = 0; i < world->entities.all.size(); i++) + { + bool updated = false; + df::historical_entity *ent = world->entities.all[i]; + if (!ent->entity_raw->flags.is_set(entity_raw_flags::COMMON_DOMESTIC_PULL)) + continue; + if (ent->resources.animals.wagon_races.size() == 0) + { + updated = true; + for (int j = 0; j < wagon->caste.size(); j++) + { + ent->resources.animals.wagon_races.push_back(wagon_creature); + ent->resources.animals.wagon_castes.push_back(j); + } + } + if (ent->resources.animals.wagon_puller_races.size() == 0) + { + updated = true; + for (int j = 0; j < wagon_puller->caste.size(); j++) + { + ent->resources.animals.wagon_puller_races.push_back(wagon_puller_creature); + ent->resources.animals.wagon_puller_castes.push_back(j); + } + } + if (updated) + count++; + } + if(count) + c->con.print("Fixed %d civilizations to bring wagons once again.\n", count); + return CR_OK; } DFhackCExport const char * plugin_name ( void ) { - return "fixwagons"; + return "fixwagons"; } DFhackCExport command_result plugin_init ( Core * c, std::vector &commands) { - commands.clear(); - commands.push_back(PluginCommand( - "fixwagons", "Fix all civilizations to be able to bring wagons.", - df_fixwagons, false, - " Since DF v0.31.1 merchants no longer bring wagons due to a bug.\n" - " This command re-enables them for all appropriate civilizations.\n" + commands.clear(); + commands.push_back(PluginCommand( + "fixwagons", "Fix all civilizations to be able to bring wagons.", + df_fixwagons, false, + " Since DF v0.31.1 merchants no longer bring wagons due to a bug.\n" + " This command re-enables them for all appropriate civilizations.\n" )); - return CR_OK; + return CR_OK; } DFhackCExport command_result plugin_shutdown ( Core * c ) { - return CR_OK; + return CR_OK; } diff --git a/plugins/flows.cpp b/plugins/flows.cpp index 757bf9710..163152a12 100644 --- a/plugins/flows.cpp +++ b/plugins/flows.cpp @@ -13,6 +13,7 @@ using std::string; using std::vector; using namespace DFHack; +using namespace df::enums; using df::global::world; @@ -26,11 +27,11 @@ DFhackCExport command_result df_flows (Core * c, vector & parameters) for (int i = 0; i < world->map.map_blocks.size(); i++) { df::map_block *cur = world->map.map_blocks[i]; - if (cur->flags.is_set(df::block_flags::UpdateLiquid)) + if (cur->flags.is_set(block_flags::UpdateLiquid)) flow1++; - if (cur->flags.is_set(df::block_flags::UpdateLiquidTwice)) + if (cur->flags.is_set(block_flags::UpdateLiquidTwice)) flow2++; - if (cur->flags.is_set(df::block_flags::UpdateLiquid) && cur->flags.is_set(df::block_flags::UpdateLiquidTwice)) + if (cur->flags.is_set(block_flags::UpdateLiquid) && cur->flags.is_set(block_flags::UpdateLiquidTwice)) flowboth++; for (int x = 0; x < 16; x++) { @@ -39,9 +40,9 @@ DFhackCExport command_result df_flows (Core * c, vector & parameters) // only count tiles with actual liquid in them if (cur->designation[x][y].bits.flow_size == 0) continue; - if (cur->designation[x][y].bits.liquid_type == df::tile_liquid::Magma) + if (cur->designation[x][y].bits.liquid_type == tile_liquid::Magma) magma++; - if (cur->designation[x][y].bits.liquid_type == df::tile_liquid::Water) + if (cur->designation[x][y].bits.liquid_type == tile_liquid::Water) water++; } } diff --git a/plugins/initflags.cpp b/plugins/initflags.cpp index d6d03811e..fd54b4883 100644 --- a/plugins/initflags.cpp +++ b/plugins/initflags.cpp @@ -43,7 +43,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c ) DFhackCExport command_result twaterlvl(Core * c, vector & parameters) { // HOTKEY COMMAND: CORE ALREADY SUSPENDED - df::global::d_init->flags1.toggle(d_init_flags1::SHOW_FLOW_AMOUNTS); + d_init->flags1.toggle(d_init_flags1::SHOW_FLOW_AMOUNTS); c->con << "Toggled the display of water/magma depth." << endl; return CR_OK; } diff --git a/plugins/liquids.cpp b/plugins/liquids.cpp index d0170fce4..bc930ff30 100644 --- a/plugins/liquids.cpp +++ b/plugins/liquids.cpp @@ -20,8 +20,8 @@ using std::set; #include "modules/MapCache.h" using namespace MapExtras; using namespace DFHack; - -typedef vector coord_vec; +using namespace df::enums; +typedef vector coord_vec; class Brush { @@ -358,7 +358,7 @@ DFhackCExport command_result df_liquids (Core * c, vector & parameters) amount = 7; else if(command.empty()) { - c->Suspend(); + CoreSuspender suspend(c); Maps::getSize(x_max,y_max,z_max); Position = c->getGui(); do @@ -409,7 +409,7 @@ DFhackCExport command_result df_liquids (Core * c, vector & parameters) mcache.setTiletypeAt(*iter, 90); df::tile_designation a = mcache.designationAt(*iter); - a.bits.liquid_type = df::tile_liquid::Water; + a.bits.liquid_type = tile_liquid::Water; a.bits.liquid_static = false; a.bits.flow_size = 7; mcache.setTemp1At(*iter,10015); @@ -478,13 +478,13 @@ DFhackCExport command_result df_liquids (Core * c, vector & parameters) } if(amount != 0 && mode == "magma") { - des.bits.liquid_type = df::tile_liquid::Magma; + des.bits.liquid_type = tile_liquid::Magma; mcache.setTemp1At(current,12000); mcache.setTemp2At(current,12000); } else if(amount != 0 && mode == "water") { - des.bits.liquid_type = df::tile_liquid::Water; + des.bits.liquid_type = tile_liquid::Water; mcache.setTemp1At(current,10015); mcache.setTemp2At(current,10015); } @@ -528,7 +528,6 @@ DFhackCExport command_result df_liquids (Core * c, vector & parameters) else c->con << "Something failed horribly! RUN!" << endl; } while (0); - c->Resume(); } else { diff --git a/plugins/plants.cpp b/plugins/plants.cpp index 9bfe5081f..399d02ee6 100644 --- a/plugins/plants.cpp +++ b/plugins/plants.cpp @@ -18,7 +18,6 @@ using std::vector; using std::string; using namespace DFHack; - using df::global::world; DFhackCExport command_result df_grow (Core * c, vector & parameters); @@ -100,11 +99,10 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre ); return CR_OK; } - c->Suspend(); + CoreSuspender suspend(c); if (!Maps::IsValid()) { c->con.printerr("Map is not available!\n"); - c->Resume(); return CR_FAILURE; } DFHack::Gui * Gui = c->getGui(); @@ -161,8 +159,6 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre c->con.printerr("No mass destruction and no cursor...\n" ); } } - // Cleanup - c->Resume(); return CR_OK; } @@ -204,12 +200,11 @@ DFhackCExport command_result df_grow (Core * c, vector & parameters) return CR_OK; } } - c->Suspend(); + CoreSuspender suspend(c); Console & con = c->con; if (!Maps::IsValid()) { c->con.printerr("Map is not available!\n"); - c->Resume(); return CR_FAILURE; } MapExtras::MapCache map; @@ -248,8 +243,6 @@ DFhackCExport command_result df_grow (Core * c, vector & parameters) } } - // Cleanup - c->Resume(); return CR_OK; } diff --git a/plugins/probe.cpp b/plugins/probe.cpp index 43c6f0572..8d588f283 100644 --- a/plugins/probe.cpp +++ b/plugins/probe.cpp @@ -24,6 +24,7 @@ using namespace std; using std::vector; using std::string; using namespace DFHack; +using namespace df::enums; DFhackCExport command_result df_probe (Core * c, vector & parameters); DFhackCExport command_result df_cprobe (Core * c, vector & parameters); @@ -53,7 +54,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c ) DFhackCExport command_result df_cprobe (Core * c, vector & parameters) { Console & con = c->con; - c->Suspend(); + CoreSuspender suspend(c); DFHack::Gui *Gui = c->getGui(); DFHack::Units * cr = c->getUnits(); int32_t cursorX, cursorY, cursorZ; @@ -76,7 +77,6 @@ DFhackCExport command_result df_cprobe (Core * c, vector & parameters) } } } - c->Resume(); return CR_OK; } @@ -93,8 +93,7 @@ DFhackCExport command_result df_probe (Core * c, vector & parameters) } */ - BEGIN_PROBE: - c->Suspend(); + CoreSuspender suspend(c); DFHack::Gui *Gui = c->getGui(); DFHack::Materials *Materials = c->getMaterials(); @@ -105,7 +104,6 @@ DFhackCExport command_result df_probe (Core * c, vector & parameters) if (!Maps::IsValid()) { c->con.printerr("Map is not available!\n"); - c->Resume(); return CR_FAILURE; } MapExtras::MapCache mc; @@ -118,7 +116,6 @@ DFhackCExport command_result df_probe (Core * c, vector & parameters) if(cursorX == -30000) { con.printerr("No cursor; place cursor over tile to probe.\n"); - c->Resume(); return CR_FAILURE; } DFCoord cursor (cursorX,cursorY,cursorZ); @@ -132,7 +129,6 @@ DFhackCExport command_result df_probe (Core * c, vector & parameters) if(!b && !b->valid) { con.printerr("No data.\n"); - c->Resume(); return CR_OK; } mapblock40d & block = b->raw; @@ -220,7 +216,7 @@ DFhackCExport command_result df_probe (Core * c, vector & parameters) // liquids if(des.bits.flow_size) { - if(des.bits.liquid_type == df::tile_liquid::Magma) + if(des.bits.liquid_type == tile_liquid::Magma) con <<"magma: "; else con <<"water: "; con << des.bits.flow_size << std::endl; @@ -275,6 +271,5 @@ DFhackCExport command_result df_probe (Core * c, vector & parameters) << endl; con << "mystery: " << block.mystery << endl; con << std::endl; - c->Resume(); return CR_OK; } diff --git a/plugins/prospector.cpp b/plugins/prospector.cpp index a3d5344bf..0fa32c846 100644 --- a/plugins/prospector.cpp +++ b/plugins/prospector.cpp @@ -23,6 +23,7 @@ using namespace std; #include "df/world.h" using namespace DFHack; +using namespace df::enums; using df::global::world; struct matdata @@ -223,11 +224,10 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector & par } } uint32_t x_max = 0, y_max = 0, z_max = 0; - c->Suspend(); + CoreSuspender suspend(c); if (!Maps::IsValid()) { c->con.printerr("Map is not available!\n"); - c->Resume(); return CR_FAILURE; } Maps::getSize(x_max, y_max, z_max); @@ -283,7 +283,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector & par Maps::GetLocalFeature(blockFeatureLocal, blockCoord, index); } - int global_z = df::global::world->map.region_z + z; + int global_z = world->map.region_z + z; // Iterate over all the tiles in the block for(uint32_t y = 0; y < 16; y++) @@ -316,7 +316,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector & par // Check for liquid if (des.bits.flow_size) { - if (des.bits.liquid_type == df::tile_liquid::Magma) + if (des.bits.liquid_type == tile_liquid::Magma) liquidMagma.add(global_z); else liquidWater.add(global_z); @@ -344,7 +344,7 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector & par so as to exclude any holes mined by the player. */ if (info->material == DFHack::AIR && des.bits.feature_local && des.bits.hidden && - blockFeatureLocal.type == df::feature_type::deep_special_tube) + blockFeatureLocal.type == feature_type::deep_special_tube) { tubeTiles.add(global_z); } @@ -368,20 +368,20 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector & par case DFHack::FEATSTONE: if (blockFeatureLocal.type != -1 && des.bits.feature_local) { - if (blockFeatureLocal.type == df::feature_type::deep_special_tube + if (blockFeatureLocal.type == feature_type::deep_special_tube && blockFeatureLocal.main_material == 0) // stone { veinMats[blockFeatureLocal.sub_material].add(global_z); } else if (showTemple - && blockFeatureLocal.type == df::feature_type::deep_surface_portal) + && blockFeatureLocal.type == feature_type::deep_surface_portal) { hasDemonTemple = true; } } if (showSlade && blockFeatureGlobal.type != -1 && des.bits.feature_global - && blockFeatureGlobal.type == df::feature_type::feature_underworld_from_layer + && blockFeatureGlobal.type == feature_type::feature_underworld_from_layer && blockFeatureGlobal.main_material == 0) // stone { layerMats[blockFeatureGlobal.sub_material].add(global_z); @@ -494,7 +494,6 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector & par veg->Finish(); } mats->Finish(); - c->Resume(); con << std::endl; return CR_OK; } diff --git a/plugins/regrass.cpp b/plugins/regrass.cpp index 53733fc29..e28f75e36 100644 --- a/plugins/regrass.cpp +++ b/plugins/regrass.cpp @@ -19,64 +19,64 @@ using df::global::world; DFhackCExport command_result df_regrass (Core * c, vector & parameters) { - if (!parameters.empty()) - return CR_WRONG_USAGE; + if (!parameters.empty()) + return CR_WRONG_USAGE; - CoreSuspender suspend(c); + CoreSuspender suspend(c); - int count = 0; - for (int i = 0; i < world->map.map_blocks.size(); i++) - { - df::map_block *cur = world->map.map_blocks[i]; - for (int x = 0; x < 16; x++) - { - for (int y = 0; y < 16; y++) - { - if (DFHack::tileShape(cur->tiletype[x][y]) != DFHack::FLOOR) - continue; - if (DFHack::tileMaterial(cur->tiletype[x][y]) != DFHack::SOIL) - continue; - if (cur->designation[x][y].bits.subterranean) - continue; - if (cur->occupancy[x][y].bits.building) - continue; + int count = 0; + for (int i = 0; i < world->map.map_blocks.size(); i++) + { + df::map_block *cur = world->map.map_blocks[i]; + for (int x = 0; x < 16; x++) + { + for (int y = 0; y < 16; y++) + { + if (DFHack::tileShape(cur->tiletype[x][y]) != DFHack::FLOOR) + continue; + if (DFHack::tileMaterial(cur->tiletype[x][y]) != DFHack::SOIL) + continue; + if (cur->designation[x][y].bits.subterranean) + continue; + if (cur->occupancy[x][y].bits.building) + continue; - switch (rand() % 8) - { - // light grass - case 0: cur->tiletype[x][y] = 0x015C; break; - case 1: cur->tiletype[x][y] = 0x015D; break; - case 2: cur->tiletype[x][y] = 0x015E; break; - case 3: cur->tiletype[x][y] = 0x015F; break; - // dark grass - case 4: cur->tiletype[x][y] = 0x018E; break; - case 5: cur->tiletype[x][y] = 0x018F; break; - case 6: cur->tiletype[x][y] = 0x0190; break; - case 7: cur->tiletype[x][y] = 0x0191; break; - } - count++; - } - } - } + switch (rand() % 8) + { + // light grass + case 0: cur->tiletype[x][y] = 0x015C; break; + case 1: cur->tiletype[x][y] = 0x015D; break; + case 2: cur->tiletype[x][y] = 0x015E; break; + case 3: cur->tiletype[x][y] = 0x015F; break; + // dark grass + case 4: cur->tiletype[x][y] = 0x018E; break; + case 5: cur->tiletype[x][y] = 0x018F; break; + case 6: cur->tiletype[x][y] = 0x0190; break; + case 7: cur->tiletype[x][y] = 0x0191; break; + } + count++; + } + } + } - if (count) - c->con.print("Regrew %d tiles of grass.\n", count); - return CR_OK; + if (count) + c->con.print("Regrew %d tiles of grass.\n", count); + return CR_OK; } DFhackCExport const char *plugin_name ( void ) { - return "regrass"; + return "regrass"; } DFhackCExport command_result plugin_init (Core *c, std::vector &commands) { - commands.clear(); - commands.push_back(PluginCommand("regrass", "Regrows all surface grass, restoring outdoor plant growth for pre-0.31.19 worlds.", df_regrass)); - return CR_OK; + commands.clear(); + commands.push_back(PluginCommand("regrass", "Regrows all surface grass, restoring outdoor plant growth for pre-0.31.19 worlds.", df_regrass)); + return CR_OK; } DFhackCExport command_result plugin_shutdown ( Core * c ) { - return CR_OK; -} + return CR_OK; +} \ No newline at end of file diff --git a/plugins/reveal.cpp b/plugins/reveal.cpp index a2818dc14..51a3d3730 100644 --- a/plugins/reveal.cpp +++ b/plugins/reveal.cpp @@ -12,6 +12,7 @@ #include "modules/Gui.h" using MapExtras::MapCache; using namespace DFHack; +using namespace df::enums; using df::global::world; /* @@ -27,10 +28,10 @@ bool isSafe(df::coord c) return false; // Adamantine tubes and temples lead to Hell - if (local_feature.type == df::feature_type::deep_special_tube || local_feature.type == df::feature_type::deep_surface_portal) + if (local_feature.type == feature_type::deep_special_tube || local_feature.type == feature_type::deep_surface_portal) return false; // And Hell *is* Hell. - if (global_feature.type == df::feature_type::feature_underworld_from_layer) + if (global_feature.type == feature_type::feature_underworld_from_layer) return false; // otherwise it's safe. return true; @@ -157,20 +158,18 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector & return CR_FAILURE; } - c->Suspend(); + CoreSuspender suspend(c); DFHack::World *World =c->getWorld(); t_gamemodes gm; World->ReadGameMode(gm); if(gm.g_mode != GAMEMODE_DWARF) { con.printerr("Only in fortress mode.\n"); - c->Resume(); return CR_FAILURE; } if (!Maps::IsValid()) { c->con.printerr("Map is not available!\n"); - c->Resume(); return CR_FAILURE; } @@ -209,7 +208,6 @@ DFhackCExport command_result reveal(DFHack::Core * c, std::vector & else revealed = DEMON_REVEALED; } - c->Resume(); con.print("Map revealed.\n"); if(!no_hell) con.print("Unpausing can unleash the forces of hell, so it has been temporarily disabled.\n"); @@ -233,7 +231,7 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector con.printerr("There's nothing to revert!\n"); return CR_FAILURE; } - c->Suspend(); + CoreSuspender suspend(c); DFHack::World *World =c->getWorld(); t_gamemodes gm; @@ -241,13 +239,11 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector if(gm.g_mode != GAMEMODE_DWARF) { con.printerr("Only in fortress mode.\n"); - c->Resume(); return CR_FAILURE; } if (!Maps::IsValid()) { c->con.printerr("Map is not available!\n"); - c->Resume(); return CR_FAILURE; } @@ -257,7 +253,6 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector 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"); - c->Resume(); return CR_FAILURE; } @@ -274,7 +269,6 @@ DFhackCExport command_result unreveal(DFHack::Core * c, std::vector hidesaved.clear(); revealed = NOT_REVEALED; con.print("Map hidden!\n"); - c->Resume(); return CR_OK; } @@ -310,20 +304,18 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector return CR_OK; } } - c->Suspend(); + CoreSuspender suspend(c); uint32_t x_max,y_max,z_max; Gui * Gui = c->getGui(); World * World = c->getWorld(); if (!Maps::IsValid()) { c->con.printerr("Map is not available!\n"); - c->Resume(); return CR_FAILURE; } if(revealed != NOT_REVEALED) { c->con.printerr("This is only safe to use with non-revealed map.\n"); - c->Resume(); return CR_FAILURE; } t_gamemodes gm; @@ -331,7 +323,6 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector if(gm.g_type != GAMETYPE_DWARF_MAIN && gm.g_mode != GAMEMODE_DWARF ) { c->con.printerr("Only in proper dwarf mode.\n"); - c->Resume(); return CR_FAILURE; } int32_t cx, cy, cz; @@ -343,7 +334,6 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector if(cx == -30000) { c->con.printerr("Cursor is not active. Point the cursor at some empty space you want to be unhidden.\n"); - c->Resume(); return CR_FAILURE; } DFCoord xy ((uint32_t)cx,(uint32_t)cy,cz); @@ -353,7 +343,6 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector { c->con.printerr("Point the cursor at some empty space you want to be unhidden.\n"); delete MCache; - c->Resume(); return CR_FAILURE; } // hide all tiles, flush cache @@ -467,6 +456,5 @@ DFhackCExport command_result revflood(DFHack::Core * c, std::vector } MCache->WriteAll(); delete MCache; - c->Resume(); return CR_OK; } diff --git a/plugins/seedwatch.cpp b/plugins/seedwatch.cpp index 43de41490..9631ef091 100755 --- a/plugins/seedwatch.cpp +++ b/plugins/seedwatch.cpp @@ -17,7 +17,7 @@ using namespace DFHack; using namespace DFHack::Simple; - +using namespace df::enums; using df::global::world; const int buffer = 20; // seed number buffer - 20 is reasonable @@ -48,11 +48,11 @@ void printHelp(Core& core) // prints help "Each plant type can be assigned a limit. If their number falls below,\n" "the plants and seeds of that type will be excluded from cookery.\n" "If the number rises above the limit + %i, then cooking will be allowed.\n", buffer - ); + ); core.con.printerr( "The plugin needs a fortress to be loaded and will deactivate automatically otherwise.\n" "You have to reactivate with 'seedwatch start' after you load the game.\n" - ); + ); core.con.print( "Options:\n" "seedwatch all - Adds all plants from the abbreviation list to the watch list.\n" @@ -60,7 +60,7 @@ void printHelp(Core& core) // prints help "seedwatch stop - Stop watching.\n" "seedwatch info - Display whether seedwatch is watching, and the watch list.\n" "seedwatch clear - Clears the watch list.\n\n" - ); + ); if(!abbreviations.empty()) { core.con.print("You can use these abbreviations for the plant tokens:\n"); @@ -79,7 +79,7 @@ void printHelp(Core& core) // prints help " is the same as 'seedwatch MUSHROOM_HELMET_PLUMP 30'\n" "seedwatch all 30\n" " adds all plants from the abbreviation list to the watch list, the limit being 30.\n" - ); + ); }; // searches abbreviations, returns expansion if so, returns original if not @@ -102,7 +102,7 @@ DFhackCExport command_result df_seedwatch(Core* pCore, std::vector& { return CR_FAILURE; } - core.Suspend(); + CoreSuspender suspend(pCore); std::map materialsReverser; for(std::size_t i = 0; i < world->raws.plants.all.size(); ++i) @@ -119,7 +119,6 @@ DFhackCExport command_result df_seedwatch(Core* pCore, std::vector& { // just print the help printHelp(core); - core.Resume(); return CR_OK; } @@ -184,7 +183,6 @@ DFhackCExport command_result df_seedwatch(Core* pCore, std::vector& /* else if(par == "dumpmaps") { - core.con.print("Plants:\n"); for(auto i = plantMaterialTypes.begin(); i != plantMaterialTypes.end(); i++) { @@ -242,7 +240,6 @@ DFhackCExport command_result df_seedwatch(Core* pCore, std::vector& break; } - core.Resume(); return CR_OK; } @@ -328,10 +325,10 @@ DFhackCExport command_result plugin_onupdate(Core* pCore) t_materialIndex materialIndex = item->getMaterialIndex(); switch(item->getType()) { - case df::item_type::SEEDS: + case item_type::SEEDS: if(!ignoreSeeds(item->flags)) ++seedCount[materialIndex]; break; - case df::item_type::PLANT: + case item_type::PLANT: break; } } @@ -356,4 +353,4 @@ DFhackCExport command_result plugin_onupdate(Core* pCore) DFhackCExport command_result plugin_shutdown(Core* pCore) { return CR_OK; -} +} \ No newline at end of file diff --git a/plugins/tiletypes.cpp b/plugins/tiletypes.cpp index c06a63827..ea154ed19 100644 --- a/plugins/tiletypes.cpp +++ b/plugins/tiletypes.cpp @@ -22,6 +22,7 @@ using std::set; #include "df/tile_dig_designation.h" using namespace MapExtras; using namespace DFHack; +using namespace df::enums; //zilpin: These two functions were giving me compile errors in VS2008, so I cheated with the C style loop below, just to get it to build. //Original code is commented out. @@ -753,12 +754,11 @@ DFhackCExport command_result df_tiletypes (Core * c, vector & parameter continue; } - c->Suspend(); + CoreSuspender suspend(c); gui = c->getGui(); if (!Maps::IsValid()) { c->con.printerr("Map is not available!\n"); - c->Resume(); return CR_FAILURE; } Maps::getSize(x_max, y_max, z_max); @@ -766,7 +766,6 @@ DFhackCExport command_result df_tiletypes (Core * c, vector & parameter if (!(gui->Start() && gui->getCursorCoords(x,y,z))) { c->con.printerr("Can't get cursor coords! Make sure you have a cursor active in DF.\n"); - c->Resume(); return CR_FAILURE; } c->con.print("Cursor coords: (%d, %d, %d)\n",x,y,z); @@ -785,7 +784,7 @@ DFhackCExport command_result df_tiletypes (Core * c, vector & parameter || (filter.material > -1 && filter.material != source->material) || (filter.special > -1 && filter.special != source->special) || (filter.variant > -1 && filter.variant != source->variant) - || (filter.dig > -1 && (filter.dig != 0) != (des.bits.dig != df::tile_dig_designation::No)) + || (filter.dig > -1 && (filter.dig != 0) != (des.bits.dig != tile_dig_designation::No)) ) { continue; @@ -890,7 +889,6 @@ DFhackCExport command_result df_tiletypes (Core * c, vector & parameter { c->con.printerr("Something failed horribly! RUN!\n"); } - c->Resume(); } } return CR_OK; diff --git a/plugins/tubefill.cpp b/plugins/tubefill.cpp index 114b786f9..1d0c4b287 100644 --- a/plugins/tubefill.cpp +++ b/plugins/tubefill.cpp @@ -15,6 +15,7 @@ using namespace DFHack; using namespace DFHack::Simple; +using namespace df::enums; using df::global::world; DFhackCExport command_result tubefill(DFHack::Core * c, std::vector & params); @@ -45,16 +46,15 @@ DFhackCExport command_result tubefill(DFHack::Core * c, std::vector if(params[i] == "help" || params[i] == "?") { c->con.print("Replenishes mined out adamantine and hollow adamantine tubes.\n" - "May cause !!FUN!!\n" - ); + "May cause !!FUN!!\n" + ); return CR_OK; } } - c->Suspend(); + CoreSuspender suspend(c); if (!Maps::IsValid()) { c->con.printerr("Map is not available!\n"); - c->Resume(); return CR_FAILURE; } @@ -69,7 +69,7 @@ DFhackCExport command_result tubefill(DFHack::Core * c, std::vector DFCoord coord(block->map_pos.x >> 4, block->map_pos.y >> 4, block->map_pos.z); if (!Maps::GetLocalFeature(feature, coord, block->local_feature)) continue; - if (feature.type != df::feature_type::deep_special_tube) + if (feature.type != feature_type::deep_special_tube) continue; for (uint32_t x = 0; x < 16; x++) { @@ -106,7 +106,6 @@ DFhackCExport command_result tubefill(DFHack::Core * c, std::vector } } } - c->Resume(); c->con.print("Found and changed %d tiles.\n", count); return CR_OK; } diff --git a/plugins/vdig.cpp b/plugins/vdig.cpp index bb53f43cc..bf131a767 100644 --- a/plugins/vdig.cpp +++ b/plugins/vdig.cpp @@ -14,6 +14,7 @@ using std::vector; using std::string; using std::stack; using namespace DFHack; +using namespace df::enums; DFhackCExport command_result vdig (Core * c, vector & parameters); DFhackCExport command_result vdigx (Core * c, vector & parameters); @@ -35,12 +36,12 @@ DFhackCExport command_result plugin_init ( Core * c, std::vector " Designates a whole vein under the cursor for digging.\n" "Options:\n" " x - follow veins through z-levels with stairs.\n" - )); + )); commands.push_back(PluginCommand( "vdigx","Dig a whole vein, following through z-levels.",vdigx,cursor_hotkey, " Designates a whole vein under the cursor for digging.\n" " Also follows the vein between z-levels with stairs, like 'vdig x' would.\n" - )); + )); commands.push_back(PluginCommand("expdig","Select or designate an exploratory pattern. Use 'expdig ?' for help.",expdig)); commands.push_back(PluginCommand("digcircle","Dig desingate a circle (filled or hollow) with given radius.",digcircle)); //commands.push_back(PluginCommand("autodig","Mark a tile for continuous digging.",autodig)); @@ -53,9 +54,9 @@ DFhackCExport command_result plugin_shutdown ( Core * c ) } template -bool from_string(T& t, - const std::string& s, - std::ios_base& (*f)(std::ios_base&)) +bool from_string(T& t, + const std::string& s, + std::ios_base& (*f)(std::ios_base&)) { std::istringstream iss(s); return !(iss >> f >> t).fail(); @@ -69,11 +70,11 @@ enum circle_what }; bool dig (MapExtras::MapCache & MCache, - circle_what what, - df::tile_dig_designation type, - int32_t x, int32_t y, int32_t z, - int x_max, int y_max - ) + circle_what what, + df::tile_dig_designation type, + int32_t x, int32_t y, int32_t z, + int x_max, int y_max + ) { DFCoord at (x,y,z); auto b = MCache.BlockAt(at/16); @@ -107,15 +108,15 @@ bool dig (MapExtras::MapCache & MCache, break; } if(isFloorTerrain(tt) - && (type == df::tile_dig_designation::DownStair || type == df::tile_dig_designation::Channel) - && ts != TREE_OK - && ts != TREE_DEAD - ) + && (type == tile_dig_designation::DownStair || type == tile_dig_designation::Channel) + && ts != TREE_OK + && ts != TREE_DEAD + ) { std::cerr << "allowing tt" << tt << ", is floor\n"; break; } - if(isStairTerrain(tt) && type == df::tile_dig_designation::Channel ) + if(isStairTerrain(tt) && type == tile_dig_designation::Channel ) break; return false; } @@ -123,28 +124,28 @@ bool dig (MapExtras::MapCache & MCache, } switch(what) { - case circle_set: - if(des.bits.dig == df::tile_dig_designation::No) - { - des.bits.dig = type; - } - break; - case circle_unset: - if (des.bits.dig != df::tile_dig_designation::No) - { - des.bits.dig = df::tile_dig_designation::No; - } - break; - case circle_invert: - if(des.bits.dig == df::tile_dig_designation::No) - { - des.bits.dig = type; - } - else - { - des.bits.dig = df::tile_dig_designation::No; - } - break; + case circle_set: + if(des.bits.dig == tile_dig_designation::No) + { + des.bits.dig = type; + } + break; + case circle_unset: + if (des.bits.dig != tile_dig_designation::No) + { + des.bits.dig = tile_dig_designation::No; + } + break; + case circle_invert: + if(des.bits.dig == tile_dig_designation::No) + { + des.bits.dig = type; + } + else + { + des.bits.dig = tile_dig_designation::No; + } + break; } std::cerr << "allowing tt" << tt << "\n"; MCache.setDesignationAt(at,des); @@ -152,11 +153,11 @@ bool dig (MapExtras::MapCache & MCache, }; bool lineX (MapExtras::MapCache & MCache, - circle_what what, - df::tile_dig_designation type, - int32_t y1, int32_t y2, int32_t x, int32_t z, - int x_max, int y_max - ) + circle_what what, + df::tile_dig_designation type, + int32_t y1, int32_t y2, int32_t x, int32_t z, + int x_max, int y_max + ) { for(int32_t y = y1; y <= y2; y++) { @@ -166,11 +167,11 @@ bool lineX (MapExtras::MapCache & MCache, }; bool lineY (MapExtras::MapCache & MCache, - circle_what what, - df::tile_dig_designation type, - int32_t x1, int32_t x2, int32_t y, int32_t z, - int x_max, int y_max - ) + circle_what what, + df::tile_dig_designation type, + int32_t x1, int32_t x2, int32_t y, int32_t z, + int x_max, int y_max + ) { for(int32_t x = x1; x <= x2; x++) { @@ -183,7 +184,7 @@ DFhackCExport command_result digcircle (Core * c, vector & parameters) { static bool filled = false; static circle_what what = circle_set; - static df::tile_dig_designation type = df::tile_dig_designation::Default; + static df::tile_dig_designation type = tile_dig_designation::Default; static int diameter = 0; auto saved_d = diameter; bool force_help = false; @@ -215,27 +216,27 @@ DFhackCExport command_result digcircle (Core * c, vector & parameters) } else if(parameters[i] == "dig") { - type = df::tile_dig_designation::Default; + type = tile_dig_designation::Default; } else if(parameters[i] == "ramp") { - type = df::tile_dig_designation::Ramp; + type = tile_dig_designation::Ramp; } else if(parameters[i] == "dstair") { - type = df::tile_dig_designation::DownStair; + type = tile_dig_designation::DownStair; } else if(parameters[i] == "ustair") { - type = df::tile_dig_designation::UpStair; + type = tile_dig_designation::UpStair; } else if(parameters[i] == "xstair") { - type = df::tile_dig_designation::UpDownStair; + type = tile_dig_designation::UpDownStair; } else if(parameters[i] == "chan") { - type = df::tile_dig_designation::Channel; + type = tile_dig_designation::Channel; } else if (!from_string(diameter,parameters[i], std::dec)) { @@ -246,39 +247,39 @@ DFhackCExport command_result digcircle (Core * c, vector & parameters) diameter = -diameter; if(force_help || diameter == 0) { - c->con.print( "A command for easy designation of filled and hollow circles.\n" - "\n" - "Options:\n" - " hollow = Set the circle to hollow (default)\n" - " filled = Set the circle to filled\n" - "\n" - " set = set designation\n" - " unset = unset current designation\n" - " invert = invert current designation\n" - "\n" - " dig = normal digging\n" - " ramp = ramp digging\n" - " ustair = staircase up\n" - " dstair = staircase down\n" - " xstair = staircase up/down\n" - " chan = dig channel\n" - "\n" - " # = diameter in tiles (default = 0)\n" - "\n" - "After you have set the options, the command called with no options\n" - "repeats with the last selected parameters:\n" - "'digcircle filled 3' = Dig a filled circle with radius = 3.\n" - "'digcircle' = Do it again.\n" - ); + c->con.print( + "A command for easy designation of filled and hollow circles.\n" + "\n" + "Options:\n" + " hollow = Set the circle to hollow (default)\n" + " filled = Set the circle to filled\n" + "\n" + " set = set designation\n" + " unset = unset current designation\n" + " invert = invert current designation\n" + "\n" + " dig = normal digging\n" + " ramp = ramp digging\n" + " ustair = staircase up\n" + " dstair = staircase down\n" + " xstair = staircase up/down\n" + " chan = dig channel\n" + "\n" + " # = diameter in tiles (default = 0)\n" + "\n" + "After you have set the options, the command called with no options\n" + "repeats with the last selected parameters:\n" + "'digcircle filled 3' = Dig a filled circle with radius = 3.\n" + "'digcircle' = Do it again.\n" + ); return CR_OK; } int32_t cx, cy, cz; - c->Suspend(); + CoreSuspender suspend(c); Gui * gui = c->getGui(); if (!Maps::IsValid()) { c->con.printerr("Map is not available!\n"); - c->Resume(); return CR_FAILURE; } @@ -288,7 +289,6 @@ DFhackCExport command_result digcircle (Core * c, vector & parameters) MapExtras::MapCache MCache; if(!gui->getCursorCoords(cx,cy,cz) || cx == -30000) { - c->Resume(); c->con.printerr("Can't get the cursor coords...\n"); return CR_FAILURE; } @@ -359,7 +359,6 @@ DFhackCExport command_result digcircle (Core * c, vector & parameters) lastwhole = whole; } MCache.WriteAll(); - c->Resume(); return CR_OK; } typedef char digmask[16][16]; @@ -477,8 +476,8 @@ static digmask diag5r[5] = {0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0}, {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}, {0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0}, - }, - { + }, + { {0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0}, {0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0}, {0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0}, @@ -495,8 +494,8 @@ static digmask diag5r[5] = {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}, {0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0}, {0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0}, - }, - { + }, + { {0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0}, {0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0}, {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}, @@ -513,8 +512,8 @@ static digmask diag5r[5] = {0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0}, {0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0}, {0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0}, - }, - { + }, + { {0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0}, {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}, {0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0}, @@ -531,8 +530,8 @@ static digmask diag5r[5] = {0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0}, {0,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0}, {0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,0}, - }, - { + }, + { {1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1}, {0,1,0,0,0,0,1,0,0,0,0,1,0,0,0,0}, {0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,0}, @@ -726,9 +725,9 @@ enum explo_what }; bool stamp_pattern (uint32_t bx, uint32_t by, int z_level, - digmask & dm, explo_how how, explo_what what, - int x_max, int y_max - ) + digmask & dm, explo_how how, explo_what what, + int x_max, int y_max + ) { df::map_block * bl = Maps::getBlock(bx,by,z_level); if(!bl) @@ -756,25 +755,25 @@ bool stamp_pattern (uint32_t bx, uint32_t by, int z_level, continue; if(how == EXPLO_CLEAR) { - des.bits.dig = df::tile_dig_designation::No; + des.bits.dig = tile_dig_designation::No; continue; } if(dm[y][x]) { if(what == EXPLO_ALL - || des.bits.dig == df::tile_dig_designation::Default && what == EXPLO_DESIGNATED + || des.bits.dig == tile_dig_designation::Default && what == EXPLO_DESIGNATED || des.bits.hidden && what == EXPLO_HIDDEN) { - des.bits.dig = df::tile_dig_designation::Default; + des.bits.dig = tile_dig_designation::Default; } } else if(what == EXPLO_DESIGNATED) { - des.bits.dig = df::tile_dig_designation::No; + des.bits.dig = tile_dig_designation::No; } } } - bl->flags.set(df::block_flags::Designated); + bl->flags.set(block_flags::Designated); return true; }; @@ -828,42 +827,41 @@ DFhackCExport command_result expdig (Core * c, vector & parameters) } if(force_help || how == EXPLO_NOTHING) { - c->con.print("This command can be used for exploratory mining.\n" - "http://df.magmawiki.com/index.php/DF2010:Exploratory_mining\n" - "\n" - "There are two variables that can be set: pattern and filter.\n" - "Patterns:\n" - " diag5 = diagonals separated by 5 tiles\n" - " diag5r = diag5 rotated 90 degrees\n" - " ladder = A 'ladder' pattern\n" - "ladderr = ladder rotated 90 degrees\n" - " clear = Just remove all dig designations\n" - " cross = A cross, exactly in the middle of the map.\n" - "Filters:\n" - " all = designate whole z-level\n" - " hidden = designate only hidden tiles of z-level (default)\n" - " designated = Take current designation and apply pattern to it.\n" - "\n" - "After you have a pattern set, you can use 'expdig' to apply it:\n" - "'expdig diag5 hidden' = set filter to hidden, pattern to diag5.\n" - "'expdig' = apply the pattern with filter.\n" - ); + c->con.print( + "This command can be used for exploratory mining.\n" + "http://df.magmawiki.com/index.php/DF2010:Exploratory_mining\n" + "\n" + "There are two variables that can be set: pattern and filter.\n" + "Patterns:\n" + " diag5 = diagonals separated by 5 tiles\n" + " diag5r = diag5 rotated 90 degrees\n" + " ladder = A 'ladder' pattern\n" + "ladderr = ladder rotated 90 degrees\n" + " clear = Just remove all dig designations\n" + " cross = A cross, exactly in the middle of the map.\n" + "Filters:\n" + " all = designate whole z-level\n" + " hidden = designate only hidden tiles of z-level (default)\n" + " designated = Take current designation and apply pattern to it.\n" + "\n" + "After you have a pattern set, you can use 'expdig' to apply it:\n" + "'expdig diag5 hidden' = set filter to hidden, pattern to diag5.\n" + "'expdig' = apply the pattern with filter.\n" + ); return CR_OK; } - c->Suspend(); + CoreSuspender suspend(c); Gui * gui = c->getGui(); uint32_t x_max, y_max, z_max; if (!Maps::IsValid()) { c->con.printerr("Map is not available!\n"); - c->Resume(); return CR_FAILURE; } Maps::getSize(x_max,y_max,z_max); int32_t xzzz,yzzz,z_level; if(!gui->getViewCoords(xzzz,yzzz,z_level)) { - c->Resume(); c->con.printerr("Can't get view coords...\n"); return CR_FAILURE; } @@ -876,7 +874,7 @@ DFhackCExport command_result expdig (Core * c, vector & parameters) { which = (4*x + y) % 5; stamp_pattern(x,y_max - 1 - y, z_level, diag5[which], - how, what, x_max, y_max); + how, what, x_max, y_max); } } } @@ -889,7 +887,7 @@ DFhackCExport command_result expdig (Core * c, vector & parameters) { which = (4*x + 1000-y) % 5; stamp_pattern(x,y_max - 1 - y, z_level, diag5r[which], - how, what, x_max, y_max); + how, what, x_max, y_max); } } } @@ -915,7 +913,7 @@ DFhackCExport command_result expdig (Core * c, vector & parameters) for(uint32_t x = 0; x < x_max; x++) { stamp_pattern(x, y, z_level, ladderr[which], - how, what, x_max, y_max); + how, what, x_max, y_max); } } } @@ -939,21 +937,20 @@ DFhackCExport command_result expdig (Core * c, vector & parameters) continue; if(cross[y][x]) { - des.bits.dig = df::tile_dig_designation::Default; + des.bits.dig = tile_dig_designation::Default; mx.setDesignationAt(pos,des); } } - mx.WriteAll(); + mx.WriteAll(); } else for(uint32_t x = 0; x < x_max; x++) { for(int32_t y = 0 ; y < y_max; y++) { stamp_pattern(x, y, z_level, all_tiles, - how, what, x_max, y_max); + how, what, x_max, y_max); } } - c->Resume(); return CR_OK; } @@ -1090,32 +1087,32 @@ DFhackCExport command_result vdig (Core * c, vector & parameters) { flood.push(current-1); - if(des_minus.bits.dig == df::tile_dig_designation::DownStair) - des_minus.bits.dig = df::tile_dig_designation::UpDownStair; + if(des_minus.bits.dig == tile_dig_designation::DownStair) + des_minus.bits.dig = tile_dig_designation::UpDownStair; else - des_minus.bits.dig = df::tile_dig_designation::UpStair; + des_minus.bits.dig = tile_dig_designation::UpStair; MCache->setDesignationAt(current-1,des_minus); - des.bits.dig = df::tile_dig_designation::DownStair; + des.bits.dig = tile_dig_designation::DownStair; } if(current.z < z_max - 1 && above && vmat_plus == vmat2) { flood.push(current+ 1); - if(des_plus.bits.dig == df::tile_dig_designation::UpStair) - des_plus.bits.dig = df::tile_dig_designation::UpDownStair; + if(des_plus.bits.dig == tile_dig_designation::UpStair) + des_plus.bits.dig = tile_dig_designation::UpDownStair; else - des_plus.bits.dig = df::tile_dig_designation::DownStair; + des_plus.bits.dig = tile_dig_designation::DownStair; MCache->setDesignationAt(current+1,des_plus); - if(des.bits.dig == df::tile_dig_designation::DownStair) - des.bits.dig = df::tile_dig_designation::UpDownStair; + if(des.bits.dig == tile_dig_designation::DownStair) + des.bits.dig = tile_dig_designation::UpDownStair; else - des.bits.dig = df::tile_dig_designation::UpStair; + des.bits.dig = tile_dig_designation::UpStair; } } - if(des.bits.dig == df::tile_dig_designation::No) - des.bits.dig = df::tile_dig_designation::Default; + if(des.bits.dig == tile_dig_designation::No) + des.bits.dig = tile_dig_designation::Default; MCache->setDesignationAt(current,des); } } diff --git a/plugins/weather.cpp b/plugins/weather.cpp index efe4ecaec..73eda774c 100644 --- a/plugins/weather.cpp +++ b/plugins/weather.cpp @@ -59,11 +59,11 @@ DFhackCExport command_result weather (Core * c, vector & parameters) if(help) { c->con.print("Prints the current weather map by default.\n" - "Options:\n" - "snow - make it snow everywhere.\n" - "rain - make it rain.\n" - "clear - clear the sky.\n" - ); + "Options:\n" + "snow - make it snow everywhere.\n" + "rain - make it rain.\n" + "clear - clear the sky.\n" + ); return CR_OK; } if(lock && unlock) @@ -81,12 +81,12 @@ DFhackCExport command_result weather (Core * c, vector & parameters) return CR_FAILURE; } bool something = lock || unlock || rain || snow || clear; - c->Suspend(); + + CoreSuspender suspend(c); DFHack::World * w = c->getWorld(); if(!w->wmap) { con << "Weather support seems broken :(" << std::endl; - c->Resume(); return CR_FAILURE; } if(!something) @@ -99,18 +99,18 @@ DFhackCExport command_result weather (Core * c, vector & parameters) { switch((*w->wmap)[x][y]) { - case DFHack::CLEAR: - con << "C "; - break; - case DFHack::RAINING: - con << "R "; - break; - case DFHack::SNOWING: - con << "S "; - break; - default: - con << (int) (*w->wmap)[x][y] << " "; - break; + case CLEAR: + con << "C "; + break; + case RAINING: + con << "R "; + break; + case SNOWING: + con << "S "; + break; + default: + con << (int) (*w->wmap)[x][y] << " "; + break; } } con << std::endl; @@ -136,6 +136,5 @@ DFhackCExport command_result weather (Core * c, vector & parameters) } // FIXME: weather lock needs map ID to work reliably... needs to be implemented. } - c->Resume(); return CR_OK; }