diff options
| author | Espen Wiborg | 2012-01-26 13:56:45 +0100 |
|---|---|---|
| committer | Espen Wiborg | 2012-01-26 13:56:45 +0100 |
| commit | b48c110438c7cedf1d0686e4ceaa455fcc57da2c (patch) | |
| tree | 5681c0162caf4a2042c7c1a93165ccc18df4e9a1 /plugins/liquids.cpp | |
| parent | 0cf3ee3dc6ee99818ca5727862c78c7dec3e517d (diff) | |
| parent | 0375be549cd2febd4c33ffb46957607403628f62 (diff) | |
| download | dfhack-b48c110438c7cedf1d0686e4ceaa455fcc57da2c.tar.gz dfhack-b48c110438c7cedf1d0686e4ceaa455fcc57da2c.tar.bz2 dfhack-b48c110438c7cedf1d0686e4ceaa455fcc57da2c.tar.xz | |
Merge git://github.com/peterix/dfhack
Diffstat (limited to 'plugins/liquids.cpp')
| -rw-r--r-- | plugins/liquids.cpp | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/plugins/liquids.cpp b/plugins/liquids.cpp index 2c74de9d..3f6d330f 100644 --- a/plugins/liquids.cpp +++ b/plugins/liquids.cpp @@ -21,8 +21,8 @@ using std::set; #include "modules/MapCache.h" using namespace MapExtras; using namespace DFHack; - -typedef vector <DFHack::DFCoord> coord_vec; +using namespace df::enums; +typedef vector <df::coord> coord_vec; class Brush { @@ -225,9 +225,7 @@ DFhackCExport command_result plugin_shutdown ( Core * c ) DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters) { int32_t x,y,z; - uint32_t x_max,y_max,z_max; - DFHack::Maps * Maps; DFHack::Gui * Position; for(int i = 0; i < parameters.size();i++) { @@ -239,6 +237,13 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters) return CR_OK; } } + + if (!Maps::IsValid()) + { + c->con.printerr("Map is not available!\n"); + return CR_FAILURE; + } + Brush * brush = new RectangleBrush(1,1); string brushname = "point"; bool end = false; @@ -425,17 +430,14 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters) amount = 7; else if(command.empty()) { - c->Suspend(); - Maps = c->getMaps(); - Maps->Start(); - Maps->getSize(x_max,y_max,z_max); + CoreSuspender suspend(c); Position = c->getGui(); do { - if(!Maps->Start()) + if (!Maps::IsValid()) { c->con << "Can't see any DF map loaded." << endl; - break; + break;; } if(!Position->getCursorCoords(x,y,z)) { @@ -443,7 +445,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters) break; } c->con << "cursor coords: " << x << "/" << y << "/" << z << endl; - MapCache mcache(Maps); + MapCache mcache; DFHack::DFCoord cursor(x,y,z); coord_vec all_tiles = brush->points(mcache,cursor); c->con << "working..." << endl; @@ -455,7 +457,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters) mcache.setTiletypeAt(*iter, 331); mcache.setTemp1At(*iter,10015); mcache.setTemp2At(*iter,10015); - DFHack::t_designation des = mcache.designationAt(*iter); + df::tile_designation des = mcache.designationAt(*iter); des.bits.flow_size = 0; mcache.setDesignationAt(*iter, des); iter ++; @@ -477,8 +479,8 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters) { mcache.setTiletypeAt(*iter, 90); - DFHack::t_designation a = mcache.designationAt(*iter); - a.bits.liquid_type = DFHack::liquid_water; + df::tile_designation a = mcache.designationAt(*iter); + a.bits.liquid_type = tile_liquid::Water; a.bits.liquid_static = false; a.bits.flow_size = 7; mcache.setTemp1At(*iter,10015); @@ -500,7 +502,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters) while (iter != all_tiles.end()) { DFHack::DFCoord current = *iter; - DFHack::t_designation des = mcache.designationAt(current); + df::tile_designation des = mcache.designationAt(current); des.bits.water_salt = false; des.bits.water_stagnant = false; mcache.setDesignationAt(current,des); @@ -521,9 +523,8 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters) iter ++; continue; } - DFHack::t_designation des = mcache.designationAt(current); + df::tile_designation des = mcache.designationAt(current); uint16_t tt = mcache.tiletypeAt(current); - DFHack::naked_designation & flow = des.bits; // don't put liquids into places where they don't belong... if(!DFHack::FlowPassable(tt)) { @@ -534,27 +535,27 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters) { if(setmode == "s.") { - flow.flow_size = amount; + des.bits.flow_size = amount; } else if(setmode == "s+") { - if(flow.flow_size < amount) - flow.flow_size = amount; + if(des.bits.flow_size < amount) + des.bits.flow_size = amount; } else if(setmode == "s-") { - if (flow.flow_size > amount) - flow.flow_size = amount; + if (des.bits.flow_size > amount) + des.bits.flow_size = amount; } if(amount != 0 && mode == "magma") { - flow.liquid_type = DFHack::liquid_magma; + des.bits.liquid_type = tile_liquid::Magma; mcache.setTemp1At(current,12000); mcache.setTemp2At(current,12000); } else if(amount != 0 && mode == "water") { - flow.liquid_type = DFHack::liquid_water; + des.bits.liquid_type = tile_liquid::Water; mcache.setTemp1At(current,10015); mcache.setTemp2At(current,10015); } @@ -597,9 +598,7 @@ DFhackCExport command_result df_liquids (Core * c, vector <string> & parameters) c->con << "OK" << endl; else c->con << "Something failed horribly! RUN!" << endl; - Maps->Finish(); } while (0); - c->Resume(); } else { |
