Update t_building, change subtype into a union of all possible subtypes (depending on type)

develop
Quietust 2012-02-18 11:34:52 -06:00
parent 7b20690db0
commit d394dc406b
2 changed files with 30 additions and 15 deletions

@ -26,6 +26,12 @@ distribution.
#include "Export.h" #include "Export.h"
#include "DataDefs.h" #include "DataDefs.h"
#include "df/building.h" #include "df/building.h"
#include "df/furnace_type.h"
#include "df/workshop_type.h"
#include "df/construction_type.h"
#include "df/shop_type.h"
#include "df/siegeengine_type.h"
#include "df/trap_type.h"
namespace DFHack namespace DFHack
{ {
@ -45,8 +51,17 @@ struct t_building
uint32_t y2; uint32_t y2;
uint32_t z; uint32_t z;
t_matglossPair material; t_matglossPair material;
int32_t type; df::building_type type;
int16_t subtype; union
{
int16_t subtype;
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; int32_t custom_type;
df::building * origin; df::building * origin;
}; };

@ -57,19 +57,19 @@ uint32_t Buildings::getNumBuildings()
bool Buildings::Read (const uint32_t index, t_building & building) bool Buildings::Read (const uint32_t index, t_building & building)
{ {
Core & c = Core::getInstance(); Core & c = Core::getInstance();
df::building *bld_40d = world->buildings.all[index]; df::building *bld = world->buildings.all[index];
building.x1 = bld_40d->x1; building.x1 = bld->x1;
building.x2 = bld_40d->x2; building.x2 = bld->x2;
building.y1 = bld_40d->y1; building.y1 = bld->y1;
building.y2 = bld_40d->y2; building.y2 = bld->y2;
building.z = bld_40d->z; building.z = bld->z;
building.material.index = bld_40d->mat_index; building.material.index = bld->mat_index;
building.material.type = bld_40d->mat_type; building.material.type = bld->mat_type;
building.type = bld_40d->getType(); building.type = bld->getType();
building.subtype = bld_40d->getSubtype(); building.subtype = bld->getSubtype();
building.custom_type = bld_40d->getCustomType(); building.custom_type = bld->getCustomType();
building.origin = bld_40d; building.origin = bld;
return true; return true;
} }