diff options
| author | Quietust | 2012-01-21 17:54:57 -0600 |
|---|---|---|
| committer | Quietust | 2012-01-21 17:54:57 -0600 |
| commit | ccf22bed10a78504701bbdb1f8177a16cf9ffdde (patch) | |
| tree | d867a8135512c572de2cffbf1c95e63e048fe875 /plugins/plants.cpp | |
| parent | d2c78646ea55c11429b452b83a4d7a0d7f50f835 (diff) | |
| download | dfhack-ccf22bed10a78504701bbdb1f8177a16cf9ffdde.tar.gz dfhack-ccf22bed10a78504701bbdb1f8177a16cf9ffdde.tar.bz2 dfhack-ccf22bed10a78504701bbdb1f8177a16cf9ffdde.tar.xz | |
Replace df_plant with df::plant - this leaves the Vegetation module a bit empty, but I'll leave it in case we decide to add something new there
Diffstat (limited to 'plugins/plants.cpp')
| -rw-r--r-- | plugins/plants.cpp | 43 |
1 files changed, 15 insertions, 28 deletions
diff --git a/plugins/plants.cpp b/plugins/plants.cpp index 99a8d1b6..9bfe5081 100644 --- a/plugins/plants.cpp +++ b/plugins/plants.cpp @@ -19,6 +19,8 @@ using std::vector; using std::string; using namespace DFHack; +using df::global::world; + DFhackCExport command_result df_grow (Core * c, vector <string> & parameters); DFhackCExport command_result df_immolate (Core * c, vector <string> & parameters); DFhackCExport command_result df_extirpate (Core * c, vector <string> & parameters); @@ -109,19 +111,13 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre uint32_t x_max, y_max, z_max; Maps::getSize(x_max, y_max, z_max); MapExtras::MapCache map; - DFHack::Vegetation *veg = c->getVegetation(); - if (!veg->all_plants) - { - std::cerr << "Unable to read vegetation!" << std::endl; - return CR_FAILURE; - } if(shrubs || trees) { int destroyed = 0; - for(size_t i = 0 ; i < veg->all_plants->size(); i++) + for(size_t i = 0 ; i < world->plants.all.size(); i++) { - DFHack::df_plant *p = veg->all_plants->at(i); - if(shrubs && p->is_shrub || trees && !p->is_shrub) + df::plant *p = world->plants.all[i]; + if(shrubs && p->flags.bits.is_shrub || trees && !p->flags.bits.is_shrub) { if (what == do_immolate) p->is_burning = true; @@ -136,14 +132,14 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre int32_t x,y,z; if(Gui->getCursorCoords(x,y,z)) { - vector<DFHack::df_plant *> * alltrees; + vector<df::plant *> * alltrees; if(Maps::ReadVegetation(x/16,y/16,z,alltrees)) { bool didit = false; for(size_t i = 0 ; i < alltrees->size(); i++) { - DFHack::df_plant * tree = alltrees->at(i); - if(tree->x == x && tree->y == y && tree->z == z) + df::plant * tree = alltrees->at(i); + if(tree->pos.x == x && tree->pos.y == y && tree->pos.z == z) { if(what == do_immolate) tree->is_burning = true; @@ -166,7 +162,6 @@ static command_result immolations (Core * c, do_what what, bool shrubs, bool tre } } // Cleanup - veg->Finish(); c->Resume(); return CR_OK; } @@ -218,24 +213,17 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters) return CR_FAILURE; } MapExtras::MapCache map; - DFHack::Vegetation *veg = c->getVegetation(); - if (!veg->all_plants) - { - con.printerr("Unable to read vegetation!\n"); - c->Resume(); - return CR_FAILURE; - } DFHack::Gui *Gui = c->getGui(); int32_t x,y,z; if(Gui->getCursorCoords(x,y,z)) { - vector<DFHack::df_plant *> * alltrees; + vector<df::plant *> * alltrees; if(Maps::ReadVegetation(x/16,y/16,z,alltrees)) { for(size_t i = 0 ; i < alltrees->size(); i++) { - DFHack::df_plant * tree = alltrees->at(i); - if(tree->x == x && tree->y == y && tree->z == z) + df::plant * tree = alltrees->at(i); + if(tree->pos.x == x && tree->pos.y == y && tree->pos.z == z) { if(DFHack::tileShape(map.tiletypeAt(DFHack::DFCoord(x,y,z))) == DFHack::SAPLING_OK) { @@ -249,11 +237,11 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters) else { int grown = 0; - for(size_t i = 0 ; i < veg->all_plants->size(); i++) + for(size_t i = 0 ; i < world->plants.all.size(); i++) { - DFHack::df_plant *p = veg->all_plants->at(i); - uint16_t ttype = map.tiletypeAt(DFHack::DFCoord(p->x,p->y,p->z)); - if(!p->is_shrub && DFHack::tileShape(ttype) == DFHack::SAPLING_OK) + df::plant *p = world->plants.all[i]; + uint16_t ttype = map.tiletypeAt(df::coord(p->pos.x,p->pos.y,p->pos.z)); + if(!p->flags.bits.is_shrub && DFHack::tileShape(ttype) == DFHack::SAPLING_OK) { p->grow_counter = DFHack::sapling_to_tree_threshold; } @@ -261,7 +249,6 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters) } // Cleanup - veg->Finish(); c->Resume(); return CR_OK; } |
