diff --git a/library/include/modules/Constructions.h b/library/include/modules/Constructions.h index 6e836ae65..2a7e03202 100644 --- a/library/include/modules/Constructions.h +++ b/library/include/modules/Constructions.h @@ -42,9 +42,22 @@ namespace Simple { 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 uint32_t getCount(); -DFHACK_EXPORT df::construction *getConstruction (const int32_t index); +DFHACK_EXPORT bool copyConstruction (const int32_t index, t_construction &out); } } } diff --git a/library/include/modules/Engravings.h b/library/include/modules/Engravings.h index df897c59e..d4cbe5adb 100644 --- a/library/include/modules/Engravings.h +++ b/library/include/modules/Engravings.h @@ -41,9 +41,24 @@ namespace Simple { 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 uint32_t getCount(); -DFHACK_EXPORT df::engraving *getEngraving (const int32_t index); +DFHACK_EXPORT bool copyEngraving (const int32_t index, t_engraving &out); } } } diff --git a/library/include/modules/Vegetation.h b/library/include/modules/Vegetation.h index c58970add..88f24eb6b 100644 --- a/library/include/modules/Vegetation.h +++ b/library/include/modules/Vegetation.h @@ -42,9 +42,30 @@ namespace Vegetation { 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 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 uint32_t getCount(); -DFHACK_EXPORT df::plant *getPlant (const int32_t index); +DFHACK_EXPORT bool copyPlant (const int32_t index, t_plant &out); } } } diff --git a/library/modules/Constructions.cpp b/library/modules/Constructions.cpp index 62c87424a..3ece46835 100644 --- a/library/modules/Constructions.cpp +++ b/library/modules/Constructions.cpp @@ -43,7 +43,7 @@ using df::global::world; bool Constructions::isValid() { - return (world->constructions.size() > 0); + return (world != NULL); } uint32_t Constructions::getCount() @@ -51,9 +51,19 @@ uint32_t Constructions::getCount() 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()) - return NULL; - return world->constructions[index]; + return false; + + 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; } diff --git a/library/modules/Engravings.cpp b/library/modules/Engravings.cpp index bff06154b..b4faba8f7 100644 --- a/library/modules/Engravings.cpp +++ b/library/modules/Engravings.cpp @@ -44,7 +44,7 @@ using df::global::world; bool Engravings::isValid() { - return (world->engravings.size() > 0); + return (world != NULL); } uint32_t Engravings::getCount() @@ -52,9 +52,21 @@ uint32_t Engravings::getCount() 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()) - return NULL; - return world->engravings[index]; + return false; + + 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; } diff --git a/library/modules/Vegetation.cpp b/library/modules/Vegetation.cpp index 268e818dd..da69ef589 100644 --- a/library/modules/Vegetation.cpp +++ b/library/modules/Vegetation.cpp @@ -45,7 +45,7 @@ using df::global::world; bool Vegetation::isValid() { - return (world->plants.all.size() > 0); + return (world != NULL); } uint32_t Vegetation::getCount() @@ -53,9 +53,27 @@ uint32_t Vegetation::getCount() 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()) - return NULL; - return world->plants.all[index]; + return false; + + 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; }