Skip to content

Commit 9f5ee8a

Browse files
committed
Many fixes, still many to go.
1 parent 1c8249c commit 9f5ee8a

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

library/modules/Buildings.cpp

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,36 @@ Buildings::Buildings(DFContextShared * d_)
7272
d = new Private;
7373
d->d = d_;
7474
d->owner = d_->p;
75+
d->p_bld = NULL;
7576
d->Inited = d->Started = d->hasCustomWorkshops = false;
7677
VersionInfo * mem = d->d->offset_descriptor;
7778
OffsetGroup * OG_build = mem->getGroup("Buildings");
78-
d->buildings_vector = OG_build->getAddress ("buildings_vector");
79+
d->Inited = true;
7980
try
8081
{
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");
8783
}
8884
catch(DFHack::Error::AllMemdef &e)
8985
{
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+
}
91104
}
92-
d->Inited = true;
93105
}
94106

95107
Buildings::~Buildings()
@@ -101,6 +113,8 @@ Buildings::~Buildings()
101113

102114
bool Buildings::Start(uint32_t & numbuildings)
103115
{
116+
if(!d->Inited)
117+
return false;
104118
d->p_bld = new DfVector <uint32_t> (d->owner, d->buildings_vector);
105119
numbuildings = d->p_bld->size();
106120
d->Started = true;

library/modules/Creatures.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ Creatures::Creatures(DFContextShared* _d)
7272
d->owner = _d->p;
7373
d->Inited = false;
7474
d->Started = false;
75+
d->p_cre = NULL;
7576
d->d->InitReadNames(); // throws on error
7677
VersionInfo * minfo = d->d->offset_descriptor;
7778
OffsetGroup *OG_Creatures = minfo->getGroup("Creatures");
@@ -149,10 +150,14 @@ Creatures::~Creatures()
149150

150151
bool Creatures::Start( uint32_t &numcreatures )
151152
{
152-
d->p_cre = new DfVector <uint32_t> (d->owner, d->creatures.vector);
153-
d->Started = true;
154-
numcreatures = d->p_cre->size();
155-
return true;
153+
if(d->Ft_basic)
154+
{
155+
d->p_cre = new DfVector <uint32_t> (d->owner, d->creatures.vector);
156+
d->Started = true;
157+
numcreatures = d->p_cre->size();
158+
return true;
159+
}
160+
return false;
156161
}
157162

158163
bool Creatures::Finish()

0 commit comments

Comments
 (0)