Add a guard against an invalid item pointer, and don't try to deduce construction labor for item_lost jobs

develop
Kelly Martin 2013-01-03 12:24:32 -06:00
parent 41615d0446
commit 796e387398
1 changed files with 4 additions and 1 deletions

@ -665,7 +665,7 @@ static df::building* get_building_from_job(df::job* j)
static df::unit_labor construction_build_labor (df::item* i) static df::unit_labor construction_build_labor (df::item* i)
{ {
MaterialInfo matinfo; MaterialInfo matinfo;
if (matinfo.decode(i)) if (i && matinfo.decode(i))
{ {
if (matinfo.material->flags.is_set(df::material_flags::IS_METAL)) if (matinfo.material->flags.is_set(df::material_flags::IS_METAL))
return df::unit_labor::METAL_CRAFT; return df::unit_labor::METAL_CRAFT;
@ -754,6 +754,9 @@ private:
public: public:
df::unit_labor get_labor(df::job* j) df::unit_labor get_labor(df::job* j)
{ {
if (j->flags.bits.item_lost)
return df::unit_labor::NONE;
df::building* bld = get_building_from_job (j); df::building* bld = get_building_from_job (j);
switch (bld->getType()) switch (bld->getType())
{ {