Use general_ref::getType() instead of strict_virtual_cast<>

develop
Quietust 2012-01-15 13:59:34 -06:00
parent d972b07d57
commit f3cbf07a01
2 changed files with 6 additions and 6 deletions

@ -338,7 +338,7 @@ DFhackCExport command_result df_autodump_destroy_item(Core * c, vector <string>
for (unsigned i = 0; i < item->itemrefs.size(); i++) for (unsigned i = 0; i < item->itemrefs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->itemrefs[i];
if (strict_virtual_cast<df::general_ref_unit_holderst>(ref)) if (ref->getType() == df::general_ref_type::unit_holder)
{ {
c->con.printerr("Choosing not to destroy items in unit inventory.\n"); c->con.printerr("Choosing not to destroy items in unit inventory.\n");
return CR_FAILURE; return CR_FAILURE;

@ -977,7 +977,7 @@ static void dryBucket(df::item *item)
for (unsigned i = 0; i < item->itemrefs.size(); i++) for (unsigned i = 0; i < item->itemrefs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->itemrefs[i];
if (strict_virtual_cast<df::general_ref_contains_itemst>(ref)) if (ref->getType() == df::general_ref_type::contains_item)
{ {
df::item *obj = ref->getItem(); df::item *obj = ref->getItem();
@ -999,20 +999,20 @@ static bool itemBusy(df::item *item)
for (unsigned i = 0; i < item->itemrefs.size(); i++) for (unsigned i = 0; i < item->itemrefs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->itemrefs[i];
if (strict_virtual_cast<df::general_ref_contains_itemst>(ref)) if (ref->getType() == df::general_ref_type::contains_item)
{ {
df::item *obj = ref->getItem(); df::item *obj = ref->getItem();
if (obj && !obj->flags.bits.garbage_colect) if (obj && !obj->flags.bits.garbage_colect)
return true; return true;
} }
else if (strict_virtual_cast<df::general_ref_contains_unitst>(ref)) else if (ref->getType() == df::general_ref_type::contains_unit)
return true; return true;
else if (strict_virtual_cast<df::general_ref_unit_holderst>(ref)) else if (ref->getType() == df::general_ref_type::unit_holder)
{ {
if (!item->flags.bits.in_job) if (!item->flags.bits.in_job)
return true; return true;
} }
else if (strict_virtual_cast<df::general_ref_contained_in_itemst>(ref)) else if (ref->getType() == df::general_ref_type::contained_in_item)
{ {
df::item *obj = ref->getItem(); df::item *obj = ref->getItem();
if (!obj) if (!obj)