Re-add the ability to request simplified copies of Constructions, Engravings, and Plants; also fix the "isValid" checks for those modules to actually be meaningful

develop
Quietust 2012-01-26 20:29:59 -06:00
parent cfca04f2d2
commit fe34e07d2b
6 changed files with 104 additions and 15 deletions

@ -42,9 +42,22 @@ namespace Simple
{ {
namespace Constructions namespace Constructions
{ {
// "Simplified" copy of construction
struct t_construction {
df::coord pos;
df::item_type item_type;
int16_t unk;
int16_t mat_type;
int32_t mat_index;
df::construction_flags flags;
int16_t original_tile;
// Pointer to original object, in case you want to modify it
df::construction *origin;
};
DFHACK_EXPORT bool isValid(); DFHACK_EXPORT bool isValid();
DFHACK_EXPORT uint32_t getCount(); DFHACK_EXPORT uint32_t getCount();
DFHACK_EXPORT df::construction *getConstruction (const int32_t index); DFHACK_EXPORT bool copyConstruction (const int32_t index, t_construction &out);
} }
} }
} }

@ -41,9 +41,24 @@ namespace Simple
{ {
namespace Engravings namespace Engravings
{ {
// "Simplified" copy of engraving
struct t_engraving {
int32_t artist;
int32_t masterpiece_event;
int32_t skill_rating;
df::coord pos;
df::engraving_flags flags;
int8_t tile;
int32_t type;
int16_t subtype;
df::item_quality quality;
// Pointer to original object, in case you want to modify it
df::engraving *origin;
};
DFHACK_EXPORT bool isValid(); DFHACK_EXPORT bool isValid();
DFHACK_EXPORT uint32_t getCount(); DFHACK_EXPORT uint32_t getCount();
DFHACK_EXPORT df::engraving *getEngraving (const int32_t index); DFHACK_EXPORT bool copyEngraving (const int32_t index, t_engraving &out);
} }
} }
} }

@ -42,9 +42,30 @@ namespace Vegetation
{ {
const uint32_t sapling_to_tree_threshold = 120 * 28 * 12 * 3; // 3 years const uint32_t sapling_to_tree_threshold = 120 * 28 * 12 * 3; // 3 years
// "Simplified" copy of plant
struct t_plant {
df::language_name name;
df::plant_flags flags;
int16_t material;
df::coord pos;
int32_t grow_counter;
uint16_t temperature_1;
uint16_t temperature_2;
int32_t is_burning;
int32_t hitpoints;
int16_t update_order;
//std::vector<void *> unk1;
//int32_t unk2;
//uint16_t temperature_3;
//uint16_t temperature_4;
//uint16_t temperature_5;
// Pointer to original object, in case you want to modify it
df::plant *origin;
};
DFHACK_EXPORT bool isValid(); DFHACK_EXPORT bool isValid();
DFHACK_EXPORT uint32_t getCount(); DFHACK_EXPORT uint32_t getCount();
DFHACK_EXPORT df::plant *getPlant (const int32_t index); DFHACK_EXPORT bool copyPlant (const int32_t index, t_plant &out);
} }
} }
} }

@ -43,7 +43,7 @@ using df::global::world;
bool Constructions::isValid() bool Constructions::isValid()
{ {
return (world->constructions.size() > 0); return (world != NULL);
} }
uint32_t Constructions::getCount() uint32_t Constructions::getCount()
@ -51,9 +51,19 @@ uint32_t Constructions::getCount()
return world->constructions.size(); return world->constructions.size();
} }
df::construction *Constructions::getConstruction(const int32_t index) bool Constructions::copyConstruction(const int32_t index, t_construction &out)
{ {
if (index < 0 || index >= getCount()) if (index < 0 || index >= getCount())
return NULL; return false;
return world->constructions[index];
out.origin = world->constructions[index];
out.pos = out.origin->pos;
out.item_type = out.origin->item_type;
out.unk = out.origin->anon_1;
out.mat_type = out.origin->mat_type;
out.mat_index = out.origin->mat_index;
out.flags = out.origin->flags;
out.original_tile = out.origin->original_tile;
return true;
} }

@ -44,7 +44,7 @@ using df::global::world;
bool Engravings::isValid() bool Engravings::isValid()
{ {
return (world->engravings.size() > 0); return (world != NULL);
} }
uint32_t Engravings::getCount() uint32_t Engravings::getCount()
@ -52,9 +52,21 @@ uint32_t Engravings::getCount()
return world->engravings.size(); return world->engravings.size();
} }
df::engraving *Engravings::getEngraving(const int32_t index) bool Engravings::copyEngraving(const int32_t index, t_engraving &out)
{ {
if (index < 0 || index >= getCount()) if (index < 0 || index >= getCount())
return NULL; return false;
return world->engravings[index];
out.origin = world->engravings[index];
out.artist = out.origin->artist;
out.masterpiece_event = out.origin->masterpiece_event;
out.skill_rating = out.origin->skill_rating;
out.pos = out.origin->pos;
out.flags = out.origin->flags;
out.tile = out.origin->tile;
out.type = out.origin->type;
out.subtype = out.origin->subtype;
out.quality = out.origin->quality;
return true;
} }

@ -45,7 +45,7 @@ using df::global::world;
bool Vegetation::isValid() bool Vegetation::isValid()
{ {
return (world->plants.all.size() > 0); return (world != NULL);
} }
uint32_t Vegetation::getCount() uint32_t Vegetation::getCount()
@ -53,9 +53,27 @@ uint32_t Vegetation::getCount()
return world->plants.all.size(); return world->plants.all.size();
} }
df::plant *Vegetation::getPlant(const int32_t index) bool Vegetation::copyPlant(const int32_t index, t_plant &out)
{ {
if (index < 0 || index >= getCount()) if (index < 0 || index >= getCount())
return NULL; return false;
return world->plants.all[index];
out.origin = world->plants.all[index];
out.name = out.origin->name;
out.flags = out.origin->flags;
out.material = out.origin->material;
out.pos = out.origin->pos;
out.grow_counter = out.origin->grow_counter;
out.temperature_1 = out.origin->temperature_1;
out.temperature_2 = out.origin->temperature_2;
out.is_burning = out.origin->is_burning;
out.hitpoints = out.origin->hitpoints;
out.update_order = out.origin->update_order;
//out.unk1 = out.origin->anon_1;
//out.unk2 = out.origin->anon_2;
//out.temperature_3 = out.origin->temperature_3;
//out.temperature_4 = out.origin->temperature_4;
//out.temperature_5 = out.origin->temperature_5;
return true;
} }