Skip to content

Commit

Permalink
reinstate functions still used by stonesense
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Feb 8, 2024
1 parent 56bffd6 commit 240b984
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
33 changes: 33 additions & 0 deletions library/include/modules/Buildings.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,46 @@ class color_ostream;

namespace Buildings
{
/**
* Structure for holding a read DF building object
* \ingroup grp_buildings
*/
struct t_building
{
uint32_t x1;
uint32_t y1;
uint32_t x2;
uint32_t y2;
uint32_t z;
t_matglossPair material;
df::building_type type;
union
{
int16_t subtype;
df::civzone_type civzone_type;
df::furnace_type furnace_type;
df::workshop_type workshop_type;
df::construction_type construction_type;
df::shop_type shop_type;
df::siegeengine_type siegeengine_type;
df::trap_type trap_type;
};
int32_t custom_type;
df::building * origin;
};

/**
* The Buildings module - allows reading DF buildings
* \ingroup grp_modules
* \ingroup grp_buildings
*/
DFHACK_EXPORT uint32_t getNumBuildings ();

/**
* read building by index
*/
DFHACK_EXPORT bool Read (const uint32_t index, t_building & building);

/**
* read mapping from custom_type value to building RAW name
* custom_type of -1 implies ordinary building
Expand Down
18 changes: 18 additions & 0 deletions library/modules/Buildings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,24 @@ uint32_t Buildings::getNumBuildings()
return world->buildings.all.size();
}

bool Buildings::Read (const uint32_t index, t_building & building)
{
df::building *bld = world->buildings.all[index];

building.x1 = bld->x1;
building.x2 = bld->x2;
building.y1 = bld->y1;
building.y2 = bld->y2;
building.z = bld->z;
building.material.index = bld->mat_index;
building.material.type = bld->mat_type;
building.type = bld->getType();
building.subtype = bld->getSubtype();
building.custom_type = bld->getCustomType();
building.origin = bld;
return true;
}

bool Buildings::ReadCustomWorkshopTypes(map <uint32_t, string> & btypes)
{
vector <building_def *> & bld_def = world->raws.buildings.all;
Expand Down

0 comments on commit 240b984

Please sign in to comment.