|
|
@ -29,6 +29,7 @@ distribution.
|
|
|
|
#include "dfhack/DFProcess.h"
|
|
|
|
#include "dfhack/DFProcess.h"
|
|
|
|
#include "dfhack/DFVector.h"
|
|
|
|
#include "dfhack/DFVector.h"
|
|
|
|
#include "dfhack/DFTypes.h"
|
|
|
|
#include "dfhack/DFTypes.h"
|
|
|
|
|
|
|
|
#include "dfhack/DFError.h"
|
|
|
|
//#include "dfhack/modules/Translation.h"
|
|
|
|
//#include "dfhack/modules/Translation.h"
|
|
|
|
#include "dfhack/modules/Buildings.h"
|
|
|
|
#include "dfhack/modules/Buildings.h"
|
|
|
|
|
|
|
|
|
|
|
@ -62,6 +63,7 @@ struct Buildings::Private
|
|
|
|
DFContextShared *d;
|
|
|
|
DFContextShared *d;
|
|
|
|
Process * owner;
|
|
|
|
Process * owner;
|
|
|
|
bool Inited;
|
|
|
|
bool Inited;
|
|
|
|
|
|
|
|
bool hasCustomWorkshops;
|
|
|
|
bool Started;
|
|
|
|
bool Started;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -70,15 +72,23 @@ Buildings::Buildings(DFContextShared * d_)
|
|
|
|
d = new Private;
|
|
|
|
d = new Private;
|
|
|
|
d->d = d_;
|
|
|
|
d->d = d_;
|
|
|
|
d->owner = d_->p;
|
|
|
|
d->owner = d_->p;
|
|
|
|
d->Inited = d->Started = false;
|
|
|
|
d->Inited = d->Started = d->hasCustomWorkshops = false;
|
|
|
|
VersionInfo * mem = d->d->offset_descriptor;
|
|
|
|
VersionInfo * mem = d->d->offset_descriptor;
|
|
|
|
OffsetGroup * OG_build = mem->getGroup("Buildings");
|
|
|
|
OffsetGroup * OG_build = mem->getGroup("Buildings");
|
|
|
|
|
|
|
|
d->buildings_vector = OG_build->getAddress ("buildings_vector");
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
d->custom_workshop_vector = OG_build->getAddress("custom_workshop_vector");
|
|
|
|
d->custom_workshop_vector = OG_build->getAddress("custom_workshop_vector");
|
|
|
|
d->building_custom_workshop_type = OG_build->getOffset("building_custom_workshop_type");
|
|
|
|
d->building_custom_workshop_type = OG_build->getOffset("building_custom_workshop_type");
|
|
|
|
d->custom_workshop_type = OG_build->getOffset("custom_workshop_type");
|
|
|
|
d->custom_workshop_type = OG_build->getOffset("custom_workshop_type");
|
|
|
|
d->custom_workshop_name = OG_build->getOffset("custom_workshop_name");
|
|
|
|
d->custom_workshop_name = OG_build->getOffset("custom_workshop_name");
|
|
|
|
d->buildings_vector = OG_build->getAddress ("buildings_vector");
|
|
|
|
|
|
|
|
mem->resolveClassnameToClassID("building_custom_workshop", d->custom_workshop_id);
|
|
|
|
mem->resolveClassnameToClassID("building_custom_workshop", d->custom_workshop_id);
|
|
|
|
|
|
|
|
d->hasCustomWorkshops = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch(DFHack::Error::UnsetMemoryDefinition &e)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cerr << "Custom workshops not available. Unset Memory Definition: " << e.what() << endl;
|
|
|
|
|
|
|
|
}
|
|
|
|
d->Inited = true;
|
|
|
|
d->Inited = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -140,6 +150,8 @@ bool Buildings::ReadCustomWorkshopTypes(map <uint32_t, string> & btypes)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!d->Started)
|
|
|
|
if(!d->Started)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if(!d->hasCustomWorkshops)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
Process * p = d->owner;
|
|
|
|
Process * p = d->owner;
|
|
|
|
DfVector <uint32_t> p_matgloss (p, d->custom_workshop_vector);
|
|
|
|
DfVector <uint32_t> p_matgloss (p, d->custom_workshop_vector);
|
|
|
@ -162,6 +174,8 @@ int32_t Buildings::GetCustomWorkshopType(t_building & building)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!d->Inited)
|
|
|
|
if(!d->Inited)
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if(!d->hasCustomWorkshops)
|
|
|
|
|
|
|
|
return false;
|
|
|
|
int32_t type = (int32_t)building.type;
|
|
|
|
int32_t type = (int32_t)building.type;
|
|
|
|
int32_t ret = -1;
|
|
|
|
int32_t ret = -1;
|
|
|
|
if(type != -1 && type == d->custom_workshop_id)
|
|
|
|
if(type != -1 && type == d->custom_workshop_id)
|
|
|
|