|
|
@ -69,6 +69,7 @@ using namespace std;
|
|
|
|
#include "df/general_ref_unit_itemownerst.h"
|
|
|
|
#include "df/general_ref_unit_itemownerst.h"
|
|
|
|
#include "df/general_ref_contains_itemst.h"
|
|
|
|
#include "df/general_ref_contains_itemst.h"
|
|
|
|
#include "df/general_ref_contained_in_itemst.h"
|
|
|
|
#include "df/general_ref_contained_in_itemst.h"
|
|
|
|
|
|
|
|
#include "df/vermin.h"
|
|
|
|
|
|
|
|
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace DFHack;
|
|
|
|
using namespace df::enums;
|
|
|
|
using namespace df::enums;
|
|
|
@ -512,9 +513,12 @@ df::coord Items::getPosition(df::item *item)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CHECK_NULL_POINTER(item);
|
|
|
|
CHECK_NULL_POINTER(item);
|
|
|
|
|
|
|
|
|
|
|
|
if (item->flags.bits.in_inventory ||
|
|
|
|
/* Function reverse-engineered from DF code. */
|
|
|
|
item->flags.bits.in_chest ||
|
|
|
|
|
|
|
|
item->flags.bits.in_building)
|
|
|
|
if (item->flags.bits.removed)
|
|
|
|
|
|
|
|
return df::coord();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (item->flags.bits.in_inventory)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (size_t i = 0; i < item->itemrefs.size(); i++)
|
|
|
|
for (size_t i = 0; i < item->itemrefs.size(); i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -532,15 +536,31 @@ df::coord Items::getPosition(df::item *item)
|
|
|
|
return Units::getPosition(unit);
|
|
|
|
return Units::getPosition(unit);
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case general_ref_type::BUILDING_HOLDER:
|
|
|
|
/*case general_ref_type::BUILDING_HOLDER:
|
|
|
|
if (auto bld = ref->getBuilding())
|
|
|
|
if (auto bld = ref->getBuilding())
|
|
|
|
return df::coord(bld->centerx, bld->centery, bld->z);
|
|
|
|
return df::coord(bld->centerx, bld->centery, bld->z);
|
|
|
|
|
|
|
|
break;*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < item->specific_refs.size(); i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
df::specific_ref *ref = item->specific_refs[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (ref->type)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case specific_ref_type::VERMIN_ESCAPED_PET:
|
|
|
|
|
|
|
|
return ref->vermin->pos;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return df::coord();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return item->pos;
|
|
|
|
return item->pos;
|
|
|
@ -625,6 +645,10 @@ bool DFHack::Items::moveToContainer(MapExtras::MapCache &mc, df::item *item, df:
|
|
|
|
CHECK_NULL_POINTER(item);
|
|
|
|
CHECK_NULL_POINTER(item);
|
|
|
|
CHECK_NULL_POINTER(container);
|
|
|
|
CHECK_NULL_POINTER(container);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
auto cpos = getPosition(container);
|
|
|
|
|
|
|
|
if (!cpos.isValid())
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
if (!detachItem(mc, item))
|
|
|
|
if (!detachItem(mc, item))
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
@ -635,7 +659,7 @@ bool DFHack::Items::moveToContainer(MapExtras::MapCache &mc, df::item *item, df:
|
|
|
|
{
|
|
|
|
{
|
|
|
|
delete ref1; delete ref2;
|
|
|
|
delete ref1; delete ref2;
|
|
|
|
Core::printerr("Could not allocate container refs.\n");
|
|
|
|
Core::printerr("Could not allocate container refs.\n");
|
|
|
|
putOnGround(mc, item, getPosition(container));
|
|
|
|
putOnGround(mc, item, cpos);
|
|
|
|
return false;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|