@@ -72,24 +72,36 @@ Buildings::Buildings(DFContextShared * d_)
72
72
d = new Private;
73
73
d->d = d_;
74
74
d->owner = d_->p ;
75
+ d->p_bld = NULL ;
75
76
d->Inited = d->Started = d->hasCustomWorkshops = false ;
76
77
VersionInfo * mem = d->d ->offset_descriptor ;
77
78
OffsetGroup * OG_build = mem->getGroup (" Buildings" );
78
- d->buildings_vector = OG_build-> getAddress ( " buildings_vector " ) ;
79
+ d->Inited = true ;
79
80
try
80
81
{
81
- d->custom_workshop_vector = OG_build->getAddress (" custom_workshop_vector" );
82
- d->building_custom_workshop_type = OG_build->getOffset (" building_custom_workshop_type" );
83
- d->custom_workshop_type = OG_build->getOffset (" custom_workshop_type" );
84
- d->custom_workshop_name = OG_build->getOffset (" custom_workshop_name" );
85
- mem->resolveClassnameToClassID (" building_custom_workshop" , d->custom_workshop_id );
86
- d->hasCustomWorkshops = true ;
82
+ d->buildings_vector = OG_build->getAddress (" buildings_vector" );
87
83
}
88
84
catch (DFHack::Error::AllMemdef &e)
89
85
{
90
- cerr << " Custom workshops not available. Memory Definition: " << e.what () << endl;
86
+ cerr << " Buildings not available... " << e.what () << endl;
87
+ d->Inited = false ;
88
+ }
89
+ if (d->Inited )
90
+ {
91
+ try
92
+ {
93
+ d->custom_workshop_vector = OG_build->getAddress (" custom_workshop_vector" );
94
+ d->building_custom_workshop_type = OG_build->getOffset (" building_custom_workshop_type" );
95
+ d->custom_workshop_type = OG_build->getOffset (" custom_workshop_type" );
96
+ d->custom_workshop_name = OG_build->getOffset (" custom_workshop_name" );
97
+ mem->resolveClassnameToClassID (" building_custom_workshop" , d->custom_workshop_id );
98
+ d->hasCustomWorkshops = true ;
99
+ }
100
+ catch (DFHack::Error::AllMemdef &e)
101
+ {
102
+ cerr << " Custom workshops not available. Memory Definition: " << e.what () << endl;
103
+ }
91
104
}
92
- d->Inited = true ;
93
105
}
94
106
95
107
Buildings::~Buildings ()
@@ -101,6 +113,8 @@ Buildings::~Buildings()
101
113
102
114
bool Buildings::Start (uint32_t & numbuildings)
103
115
{
116
+ if (!d->Inited )
117
+ return false ;
104
118
d->p_bld = new DfVector <uint32_t > (d->owner , d->buildings_vector );
105
119
numbuildings = d->p_bld ->size ();
106
120
d->Started = true ;
0 commit comments