Kill the Vegetation module, replacing it with the same 3 simple methods used in Engravings

develop
Quietust 2012-01-24 12:02:12 -06:00
parent 6d1af090c5
commit 8861e93848
6 changed files with 29 additions and 43 deletions

@ -1091,7 +1091,6 @@ TYPE * Core::get##TYPE() \
MODULE_GETTER(Gui); MODULE_GETTER(Gui);
MODULE_GETTER(World); MODULE_GETTER(World);
MODULE_GETTER(Materials); MODULE_GETTER(Materials);
MODULE_GETTER(Vegetation);
MODULE_GETTER(Constructions); MODULE_GETTER(Constructions);
MODULE_GETTER(Notes); MODULE_GETTER(Notes);
MODULE_GETTER(Graphic); MODULE_GETTER(Graphic);

@ -55,7 +55,6 @@ namespace DFHack
class Gui; class Gui;
class World; class World;
class Materials; class Materials;
class Vegetation;
class Constructions; class Constructions;
class Notes; class Notes;
class VersionInfo; class VersionInfo;
@ -100,8 +99,6 @@ namespace DFHack
World * getWorld(); World * getWorld();
/// get the materials module /// get the materials module
Materials * getMaterials(); Materials * getMaterials();
/// get the vegetation module
Vegetation * getVegetation();
/// get the constructions module /// get the constructions module
Constructions * getConstructions(); Constructions * getConstructions();
/// get the notes module /// get the notes module
@ -155,7 +152,6 @@ namespace DFHack
Gui * pGui; Gui * pGui;
World * pWorld; World * pWorld;
Materials * pMaterials; Materials * pMaterials;
Vegetation * pVegetation;
Constructions * pConstructions; Constructions * pConstructions;
Notes * pNotes; Notes * pNotes;
Graphic * pGraphic; Graphic * pGraphic;

@ -31,27 +31,21 @@ distribution.
*/ */
#include "Export.h" #include "Export.h"
#include "Module.h"
#include "Types.h"
#include "DataDefs.h" #include "DataDefs.h"
#include "df/plant.h" #include "df/plant.h"
namespace DFHack namespace DFHack
{ {
/** namespace Simple
* \ingroup grp_vegetation
*/
const uint32_t sapling_to_tree_threshold = 0x1D880;
/**
* The Vegetation module
* \ingroup grp_vegetation
* \ingroup grp_modules
*/
class DFHACK_EXPORT Vegetation : public Module
{ {
public: namespace Vegetation
Vegetation(); {
~Vegetation(); const uint32_t sapling_to_tree_threshold = 120 * 28 * 12 * 3; // 3 years
bool Finish(){return true;};
}; DFHACK_EXPORT bool isValid();
DFHACK_EXPORT uint32_t getCount();
DFHACK_EXPORT df::plant *getPlant (const int32_t index);
}
}
} }
#endif #endif

@ -33,23 +33,29 @@ using namespace std;
#include "VersionInfo.h" #include "VersionInfo.h"
#include "MemAccess.h" #include "MemAccess.h"
#include "Types.h" #include "Types.h"
#include "modules/Vegetation.h"
#include "modules/Translation.h"
#include "ModuleFactory.h"
#include "Core.h" #include "Core.h"
using namespace DFHack; using namespace DFHack;
Module* DFHack::createVegetation() #include "modules/Vegetation.h"
#include "df/world.h"
using namespace DFHack;
using namespace DFHack::Simple;
using df::global::world;
bool Vegetation::isValid()
{ {
return new Vegetation(); return (world->plants.all.size() > 0);
} }
Vegetation::Vegetation() uint32_t Vegetation::getCount()
{ {
return world->plants.all.size();
} }
Vegetation::~Vegetation() df::plant *Vegetation::getPlant(const int32_t index)
{ {
if (index < 0 || index >= getCount())
return NULL;
return world->plants.all[index];
} }

@ -222,7 +222,7 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
{ {
if(DFHack::tileShape(map.tiletypeAt(DFHack::DFCoord(x,y,z))) == DFHack::SAPLING_OK) if(DFHack::tileShape(map.tiletypeAt(DFHack::DFCoord(x,y,z))) == DFHack::SAPLING_OK)
{ {
tree->grow_counter = DFHack::sapling_to_tree_threshold; tree->grow_counter = Vegetation::sapling_to_tree_threshold;
} }
break; break;
} }
@ -238,7 +238,7 @@ DFhackCExport command_result df_grow (Core * c, vector <string> & parameters)
uint16_t ttype = map.tiletypeAt(df::coord(p->pos.x,p->pos.y,p->pos.z)); 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) if(!p->flags.bits.is_shrub && DFHack::tileShape(ttype) == DFHack::SAPLING_OK)
{ {
p->grow_counter = DFHack::sapling_to_tree_threshold; p->grow_counter = Vegetation::sapling_to_tree_threshold;
} }
} }
} }

@ -253,11 +253,6 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
matdata tubeTiles; matdata tubeTiles;
uint32_t vegCount = 0; uint32_t vegCount = 0;
DFHack::Vegetation *veg = c->getVegetation();
if (showPlants && !veg->Start())
{
con.printerr("Unable to read vegetation; plants won't be listed!\n" );
}
for(uint32_t z = 0; z < z_max; z++) for(uint32_t z = 0; z < z_max; z++)
{ {
@ -489,10 +484,6 @@ DFhackCExport command_result prospector (DFHack::Core * c, vector <string> & par
} }
// Cleanup // Cleanup
if (showPlants)
{
veg->Finish();
}
mats->Finish(); mats->Finish();
con << std::endl; con << std::endl;
return CR_OK; return CR_OK;