Rename general_ref vectors for consistency

develop
Quietust 2012-11-12 08:27:58 -06:00
parent bd75cad508
commit 766aca4911
15 changed files with 85 additions and 85 deletions

@ -1,4 +1,4 @@
/* /*
https://github.com/peterix/dfhack https://github.com/peterix/dfhack
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com) Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
@ -895,7 +895,7 @@ static bool linkForConstruct(df::job* &job, df::building *bld)
job = new df::job(); job = new df::job();
job->job_type = df::job_type::ConstructBuilding; job->job_type = df::job_type::ConstructBuilding;
job->pos = df::coord(bld->centerx, bld->centery, bld->z); job->pos = df::coord(bld->centerx, bld->centery, bld->z);
job->references.push_back(ref); job->general_refs.push_back(ref);
bld->jobs.push_back(job); bld->jobs.push_back(job);

@ -1,4 +1,4 @@
/* /*
https://github.com/peterix/dfhack https://github.com/peterix/dfhack
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com) Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
@ -509,7 +509,7 @@ df::general_ref *Items::getGeneralRef(df::item *item, df::general_ref_type type)
{ {
CHECK_NULL_POINTER(item); CHECK_NULL_POINTER(item);
return findRef(item->itemrefs, type); return findRef(item->general_refs, type);
} }
df::specific_ref *Items::getSpecificRef(df::item *item, df::specific_ref_type type) df::specific_ref *Items::getSpecificRef(df::item *item, df::specific_ref_type type)
@ -530,9 +530,9 @@ bool Items::setOwner(df::item *item, df::unit *unit)
{ {
CHECK_NULL_POINTER(item); CHECK_NULL_POINTER(item);
for (int i = item->itemrefs.size()-1; i >= 0; i--) for (int i = item->general_refs.size()-1; i >= 0; i--)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->general_refs[i];
if (!strict_virtual_cast<df::general_ref_unit_itemownerst>(ref)) if (!strict_virtual_cast<df::general_ref_unit_itemownerst>(ref))
continue; continue;
@ -546,7 +546,7 @@ bool Items::setOwner(df::item *item, df::unit *unit)
} }
delete ref; delete ref;
vector_erase_at(item->itemrefs, i); vector_erase_at(item->general_refs, i);
} }
item->flags.bits.owned = false; item->flags.bits.owned = false;
@ -561,7 +561,7 @@ bool Items::setOwner(df::item *item, df::unit *unit)
ref->unit_id = unit->id; ref->unit_id = unit->id;
insert_into_vector(unit->owned_items, item->id); insert_into_vector(unit->owned_items, item->id);
item->itemrefs.push_back(ref); item->general_refs.push_back(ref);
} }
return true; return true;
@ -580,9 +580,9 @@ void Items::getContainedItems(df::item *item, std::vector<df::item*> *items)
items->clear(); items->clear();
for (size_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->general_refs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->general_refs[i];
if (ref->getType() != general_ref_type::CONTAINS_ITEM) if (ref->getType() != general_ref_type::CONTAINS_ITEM)
continue; continue;
@ -617,9 +617,9 @@ df::coord Items::getPosition(df::item *item)
if (item->flags.bits.in_inventory) if (item->flags.bits.in_inventory)
{ {
for (size_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->general_refs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->general_refs[i];
switch (ref->getType()) switch (ref->getType())
{ {
@ -716,9 +716,9 @@ static bool detachItem(MapExtras::MapCache &mc, df::item *item)
if (item->world_data_id != -1) if (item->world_data_id != -1)
return false; return false;
for (size_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->general_refs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->general_refs[i];
switch (ref->getType()) switch (ref->getType())
{ {
@ -748,9 +748,9 @@ static bool detachItem(MapExtras::MapCache &mc, df::item *item)
{ {
bool found = false; bool found = false;
for (int i = item->itemrefs.size()-1; i >= 0; i--) for (int i = item->general_refs.size()-1; i >= 0; i--)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->general_refs[i];
switch (ref->getType()) switch (ref->getType())
{ {
@ -767,7 +767,7 @@ static bool detachItem(MapExtras::MapCache &mc, df::item *item)
item2->flags.bits.weight_computed = false; item2->flags.bits.weight_computed = false;
removeRef(item2->itemrefs, general_ref_type::CONTAINS_ITEM, item->id); removeRef(item2->general_refs, general_ref_type::CONTAINS_ITEM, item->id);
} }
break; break;
@ -799,7 +799,7 @@ static bool detachItem(MapExtras::MapCache &mc, df::item *item)
} }
found = true; found = true;
vector_erase_at(item->itemrefs, i); vector_erase_at(item->general_refs, i);
delete ref; delete ref;
} }
@ -878,10 +878,10 @@ bool DFHack::Items::moveToContainer(MapExtras::MapCache &mc, df::item *item, df:
container->flags.bits.weight_computed = false; container->flags.bits.weight_computed = false;
ref1->item_id = item->id; ref1->item_id = item->id;
container->itemrefs.push_back(ref1); container->general_refs.push_back(ref1);
ref2->item_id = container->id; ref2->item_id = container->id;
item->itemrefs.push_back(ref2); item->general_refs.push_back(ref2);
return true; return true;
} }
@ -912,7 +912,7 @@ bool DFHack::Items::moveToBuilding(MapExtras::MapCache &mc, df::item *item, df::
item->flags.bits.in_building=true; item->flags.bits.in_building=true;
ref->building_id=building->id; ref->building_id=building->id;
item->itemrefs.push_back(ref); item->general_refs.push_back(ref);
auto con=new df::building_actual::T_contained_items; auto con=new df::building_actual::T_contained_items;
con->item=item; con->item=item;
@ -955,7 +955,7 @@ bool DFHack::Items::moveToInventory(
unit->inventory.push_back(newInventoryItem); unit->inventory.push_back(newInventoryItem);
holderReference->unit_id = unit->id; holderReference->unit_id = unit->id;
item->itemrefs.push_back(holderReference); item->general_refs.push_back(holderReference);
resetUnitInvFlags(unit, newInventoryItem); resetUnitInvFlags(unit, newInventoryItem);
@ -1016,7 +1016,7 @@ df::proj_itemst *Items::makeProjectile(MapExtras::MapCache &mc, df::item *item)
proj->item = item; proj->item = item;
ref->projectile_id = proj->id; ref->projectile_id = proj->id;
item->itemrefs.push_back(ref); item->general_refs.push_back(ref);
linked_list_append(&world->proj_list, proj->link); linked_list_append(&world->proj_list, proj->link);

@ -1,4 +1,4 @@
/* /*
https://github.com/peterix/dfhack https://github.com/peterix/dfhack
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com) Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
@ -71,14 +71,14 @@ df::job *DFHack::Job::cloneJobStruct(df::job *job)
pnew->specific_refs.clear(); pnew->specific_refs.clear();
// Clone refs // Clone refs
for (int i = pnew->references.size()-1; i >= 0; i--) for (int i = pnew->general_refs.size()-1; i >= 0; i--)
{ {
df::general_ref *ref = pnew->references[i]; df::general_ref *ref = pnew->general_refs[i];
if (virtual_cast<df::general_ref_unit>(ref)) if (virtual_cast<df::general_ref_unit>(ref))
vector_erase_at(pnew->references, i); vector_erase_at(pnew->general_refs, i);
else else
pnew->references[i] = ref->clone(); pnew->general_refs[i] = ref->clone();
} }
// Clone items // Clone items
@ -96,8 +96,8 @@ void DFHack::Job::deleteJobStruct(df::job *job)
// Only allow free-floating job structs // Only allow free-floating job structs
assert(!job->list_link && job->items.empty() && job->specific_refs.empty()); assert(!job->list_link && job->items.empty() && job->specific_refs.empty());
for (int i = job->references.size()-1; i >= 0; i--) for (int i = job->general_refs.size()-1; i >= 0; i--)
delete job->references[i]; delete job->general_refs[i];
for (int i = job->job_items.size()-1; i >= 0; i--) for (int i = job->job_items.size()-1; i >= 0; i--)
delete job->job_items[i]; delete job->job_items[i];
@ -232,9 +232,9 @@ df::building *DFHack::Job::getHolder(df::job *job)
{ {
CHECK_NULL_POINTER(job); CHECK_NULL_POINTER(job);
for (size_t i = 0; i < job->references.size(); i++) for (size_t i = 0; i < job->general_refs.size(); i++)
{ {
VIRTUAL_CAST_VAR(ref, df::general_ref_building_holderst, job->references[i]); VIRTUAL_CAST_VAR(ref, df::general_ref_building_holderst, job->general_refs[i]);
if (ref) if (ref)
return ref->getBuilding(); return ref->getBuilding();
} }
@ -246,9 +246,9 @@ df::unit *DFHack::Job::getWorker(df::job *job)
{ {
CHECK_NULL_POINTER(job); CHECK_NULL_POINTER(job);
for (size_t i = 0; i < job->references.size(); i++) for (size_t i = 0; i < job->general_refs.size(); i++)
{ {
VIRTUAL_CAST_VAR(ref, df::general_ref_unit_workerst, job->references[i]); VIRTUAL_CAST_VAR(ref, df::general_ref_unit_workerst, job->general_refs[i]);
if (ref) if (ref)
return ref->getUnit(); return ref->getUnit();
} }

@ -1,4 +1,4 @@
/* /*
https://github.com/peterix/dfhack https://github.com/peterix/dfhack
Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com) Copyright (c) 2009-2012 Petr Mrázek (peterix@gmail.com)
@ -523,9 +523,9 @@ df::item *Units::getContainer(df::unit *unit)
{ {
CHECK_NULL_POINTER(unit); CHECK_NULL_POINTER(unit);
for (size_t i = 0; i < unit->refs.size(); i++) for (size_t i = 0; i < unit->general_refs.size(); i++)
{ {
df::general_ref *ref = unit->refs[i]; df::general_ref *ref = unit->general_refs[i];
if (ref->getType() == general_ref_type::CONTAINED_IN_ITEM) if (ref->getType() == general_ref_type::CONTAINED_IN_ITEM)
return ref->getItem(); return ref->getItem();
} }
@ -607,9 +607,9 @@ df::nemesis_record *Units::getNemesis(df::unit *unit)
if (!unit) if (!unit)
return NULL; return NULL;
for (unsigned i = 0; i < unit->refs.size(); i++) for (unsigned i = 0; i < unit->general_refs.size(); i++)
{ {
df::nemesis_record *rv = unit->refs[i]->getNemesis(); df::nemesis_record *rv = unit->general_refs[i]->getNemesis();
if (rv && rv->unit == unit) if (rv && rv->unit == unit)
return rv; return rv;
} }

@ -1 +1 @@
Subproject commit 4b2124957e282683480eaf05922e63c353364ec1 Subproject commit 327a9662be81627ebcbb3aea11ffbca3e536b7ee

@ -331,7 +331,7 @@ typedef std::pair<df::item*,InventoryMode> inv_item;
static void listContainerInventory(std::vector<inv_item> *list, df::item *container) static void listContainerInventory(std::vector<inv_item> *list, df::item *container)
{ {
auto &refs = container->itemrefs; auto &refs = container->general_refs;
for (size_t i = 0; i < refs.size(); i++) for (size_t i = 0; i < refs.size(); i++)
{ {
auto ref = refs[i]; auto ref = refs[i];
@ -372,9 +372,9 @@ void listUnitInventory(std::vector<inv_item> *list, df::unit *unit)
bool isShopItem(df::item *item) bool isShopItem(df::item *item)
{ {
for (size_t k = 0; k < item->itemrefs.size(); k++) for (size_t k = 0; k < item->general_refs.size(); k++)
{ {
auto ref = item->itemrefs[k]; auto ref = item->general_refs[k];
if (virtual_cast<df::general_ref_building_civzone_assignedst>(ref)) if (virtual_cast<df::general_ref_building_civzone_assignedst>(ref))
return true; return true;
} }
@ -404,7 +404,7 @@ int containsMetalItems(df::item *item, bool all, bool non_trader, bool rec = fal
{ {
int cnt = 0; int cnt = 0;
auto &refs = item->itemrefs; auto &refs = item->general_refs;
for (size_t i = 0; i < refs.size(); i++) for (size_t i = 0; i < refs.size(); i++)
{ {
auto ref = refs[i]; auto ref = refs[i];

@ -277,9 +277,9 @@ command_result df_autodump_destroy_item(color_ostream &out, vector <string> & pa
return CR_FAILURE; return CR_FAILURE;
} }
for (size_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->general_refs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->general_refs[i];
if (ref->getType() == general_ref_type::UNIT_HOLDER) if (ref->getType() == general_ref_type::UNIT_HOLDER)
{ {
out.printerr("Choosing not to destroy items in unit inventory.\n"); out.printerr("Choosing not to destroy items in unit inventory.\n");

@ -1582,9 +1582,9 @@ static int stockcheck(color_ostream &out, vector <string> & parameters)
df::unit *holder = 0; df::unit *holder = 0;
df::building *building = 0; df::building *building = 0;
for (size_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->general_refs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->general_refs[i];
switch (ref->getType()) switch (ref->getType())
{ {
@ -1611,9 +1611,9 @@ static int stockcheck(color_ostream &out, vector <string> & parameters)
while(nextcontainer) { while(nextcontainer) {
df::item *thiscontainer = nextcontainer; df::item *thiscontainer = nextcontainer;
nextcontainer = 0; nextcontainer = 0;
for (size_t i = 0; i < thiscontainer->itemrefs.size(); i++) for (size_t i = 0; i < thiscontainer->general_refs.size(); i++)
{ {
df::general_ref *ref = thiscontainer->itemrefs[i]; df::general_ref *ref = thiscontainer->general_refs[i];
switch (ref->getType()) switch (ref->getType())
{ {

@ -170,9 +170,9 @@ static command_result stockcheck(color_ostream &out, vector <string> & parameter
df::unit *holder = 0; df::unit *holder = 0;
df::building *building = 0; df::building *building = 0;
for (size_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->general_refs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->general_refs[i];
switch (ref->getType()) switch (ref->getType())
{ {
@ -199,9 +199,9 @@ static command_result stockcheck(color_ostream &out, vector <string> & parameter
while(nextcontainer) { while(nextcontainer) {
df::item *thiscontainer = nextcontainer; df::item *thiscontainer = nextcontainer;
nextcontainer = 0; nextcontainer = 0;
for (size_t i = 0; i < thiscontainer->itemrefs.size(); i++) for (size_t i = 0; i < thiscontainer->general_refs.size(); i++)
{ {
df::general_ref *ref = thiscontainer->itemrefs[i]; df::general_ref *ref = thiscontainer->general_refs[i];
switch (ref->getType()) switch (ref->getType())
{ {

@ -46,9 +46,9 @@ DFHACK_PLUGIN("stripcaged");
bool isContainedInItem(df::unit* unit) bool isContainedInItem(df::unit* unit)
{ {
bool contained = false; bool contained = false;
for (size_t r=0; r < unit->refs.size(); r++) for (size_t r=0; r < unit->general_refs.size(); r++)
{ {
df::general_ref * ref = unit->refs[r]; df::general_ref * ref = unit->general_refs[r];
auto rtype = ref->getType(); auto rtype = ref->getType();
if(rtype == df::general_ref_type::CONTAINED_IN_ITEM) if(rtype == df::general_ref_type::CONTAINED_IN_ITEM)
{ {

@ -528,7 +528,7 @@ static bool try_store_item(df::building *target, df::item *item)
// job <-> building link // job <-> building link
href->building_id = target->id; href->building_id = target->id;
target->jobs.push_back(job); target->jobs.push_back(job);
job->references.push_back(href); job->general_refs.push_back(href);
// Two of the jobs need this link to find the job in canStoreItem(). // Two of the jobs need this link to find the job in canStoreItem().
// They also don't actually need BUILDING_HOLDER, but it doesn't hurt. // They also don't actually need BUILDING_HOLDER, but it doesn't hurt.
@ -539,7 +539,7 @@ static bool try_store_item(df::building *target, df::item *item)
if (rdest) if (rdest)
{ {
rdest->building_id = target->id; rdest->building_id = target->id;
job->references.push_back(rdest); job->general_refs.push_back(rdest);
} }
} }

@ -275,7 +275,7 @@ module DFHack
job = Job.cpp_new job = Job.cpp_new
job.job_type = :ConstructBuilding job.job_type = :ConstructBuilding
job.pos = [bld.centerx, bld.centery, bld.z] job.pos = [bld.centerx, bld.centery, bld.z]
job.references << ref job.general_refs << ref
bld.jobs << job bld.jobs << job
job_link job job_link job
job job
@ -346,7 +346,7 @@ module DFHack
refbuildingholder = GeneralRefBuildingHolderst.cpp_new refbuildingholder = GeneralRefBuildingHolderst.cpp_new
job.job_type = :DestroyBuilding job.job_type = :DestroyBuilding
refbuildingholder.building_id = bld.id refbuildingholder.building_id = bld.id
job.references << refbuildingholder job.general_refs << refbuildingholder
bld.jobs << job bld.jobs << job
job_link job job_link job
job job

@ -49,9 +49,9 @@ command_result df_showmood (color_ostream &out, vector <string> & parameters)
found = true; found = true;
df::unit *unit = NULL; df::unit *unit = NULL;
df::building *building = NULL; df::building *building = NULL;
for (size_t i = 0; i < job->references.size(); i++) for (size_t i = 0; i < job->general_refs.size(); i++)
{ {
df::general_ref *ref = job->references[i]; df::general_ref *ref = job->general_refs[i];
if (ref->getType() == general_ref_type::UNIT_WORKER) if (ref->getType() == general_ref_type::UNIT_WORKER)
unit = ref->getUnit(); unit = ref->getUnit();
if (ref->getType() == general_ref_type::BUILDING_HOLDER) if (ref->getType() == general_ref_type::BUILDING_HOLDER)

@ -974,9 +974,9 @@ static void map_job_constraints(color_ostream &out)
static void dryBucket(df::item *item) static void dryBucket(df::item *item)
{ {
for (size_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->general_refs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->general_refs[i];
if (ref->getType() == general_ref_type::CONTAINS_ITEM) if (ref->getType() == general_ref_type::CONTAINS_ITEM)
{ {
df::item *obj = ref->getItem(); df::item *obj = ref->getItem();
@ -996,9 +996,9 @@ static bool itemBusy(df::item *item)
{ {
using namespace df::enums::item_type; using namespace df::enums::item_type;
for (size_t i = 0; i < item->itemrefs.size(); i++) for (size_t i = 0; i < item->general_refs.size(); i++)
{ {
df::general_ref *ref = item->itemrefs[i]; df::general_ref *ref = item->general_refs[i];
if (ref->getType() == general_ref_type::CONTAINS_ITEM) if (ref->getType() == general_ref_type::CONTAINS_ITEM)
{ {
df::item *obj = ref->getItem(); df::item *obj = ref->getItem();

@ -753,10 +753,10 @@ void unitInfo(color_ostream & out, df::unit* unit, bool verbose = false)
if(!verbose) if(!verbose)
return; return;
//out << "number of refs: " << creature->refs.size() << endl; //out << "number of refs: " << creature->general_refs.size() << endl;
for(size_t r = 0; r<unit->refs.size(); r++) for(size_t r = 0; r<unit->general_refs.size(); r++)
{ {
df::general_ref* ref = unit->refs.at(r); df::general_ref* ref = unit->general_refs.at(r);
df::general_ref_type refType = ref->getType(); df::general_ref_type refType = ref->getType();
out << " ref#" << r <<" refType#" << refType << " "; //endl; out << " ref#" << r <<" refType#" << refType << " "; //endl;
switch(refType) switch(refType)
@ -975,10 +975,10 @@ df::general_ref_building_civzone_assignedst * createCivzoneRef()
for(size_t i = 0; i < world->units.all.size(); i++) for(size_t i = 0; i < world->units.all.size(); i++)
{ {
df::unit * creature = world->units.all[i]; df::unit * creature = world->units.all[i];
for(size_t r = 0; r<creature->refs.size(); r++) for(size_t r = 0; r<creature->general_refs.size(); r++)
{ {
df::general_ref* ref; df::general_ref* ref;
ref = creature->refs.at(r); ref = creature->general_refs.at(r);
if(ref->getType() == df::general_ref_type::BUILDING_CIVZONE_ASSIGNED) if(ref->getType() == df::general_ref_type::BUILDING_CIVZONE_ASSIGNED)
{ {
if (strict_virtual_cast<df::general_ref_building_civzone_assignedst>(ref)) if (strict_virtual_cast<df::general_ref_building_civzone_assignedst>(ref))
@ -1007,9 +1007,9 @@ bool isInBuiltCage(df::unit* unit);
bool isAssigned(df::unit* unit) bool isAssigned(df::unit* unit)
{ {
bool assigned = false; bool assigned = false;
for (size_t r=0; r < unit->refs.size(); r++) for (size_t r=0; r < unit->general_refs.size(); r++)
{ {
df::general_ref * ref = unit->refs[r]; df::general_ref * ref = unit->general_refs[r];
auto rtype = ref->getType(); auto rtype = ref->getType();
if( rtype == df::general_ref_type::BUILDING_CIVZONE_ASSIGNED if( rtype == df::general_ref_type::BUILDING_CIVZONE_ASSIGNED
|| rtype == df::general_ref_type::BUILDING_CAGED || rtype == df::general_ref_type::BUILDING_CAGED
@ -1029,9 +1029,9 @@ bool isAssigned(df::unit* unit)
bool isChained(df::unit* unit) bool isChained(df::unit* unit)
{ {
bool contained = false; bool contained = false;
for (size_t r=0; r < unit->refs.size(); r++) for (size_t r=0; r < unit->general_refs.size(); r++)
{ {
df::general_ref * ref = unit->refs[r]; df::general_ref * ref = unit->general_refs[r];
auto rtype = ref->getType(); auto rtype = ref->getType();
if(rtype == df::general_ref_type::BUILDING_CHAIN) if(rtype == df::general_ref_type::BUILDING_CHAIN)
{ {
@ -1046,9 +1046,9 @@ bool isChained(df::unit* unit)
bool isContainedInItem(df::unit* unit) bool isContainedInItem(df::unit* unit)
{ {
bool contained = false; bool contained = false;
for (size_t r=0; r < unit->refs.size(); r++) for (size_t r=0; r < unit->general_refs.size(); r++)
{ {
df::general_ref * ref = unit->refs[r]; df::general_ref * ref = unit->general_refs[r];
auto rtype = ref->getType(); auto rtype = ref->getType();
if(rtype == df::general_ref_type::CONTAINED_IN_ITEM) if(rtype == df::general_ref_type::CONTAINED_IN_ITEM)
{ {
@ -1280,14 +1280,14 @@ size_t countFreeEgglayers()
bool unassignUnitFromBuilding(df::unit* unit) bool unassignUnitFromBuilding(df::unit* unit)
{ {
bool success = false; bool success = false;
for (std::size_t idx = 0; idx < unit->refs.size(); idx++) for (std::size_t idx = 0; idx < unit->general_refs.size(); idx++)
{ {
df::general_ref * oldref = unit->refs[idx]; df::general_ref * oldref = unit->general_refs[idx];
switch(oldref->getType()) switch(oldref->getType())
{ {
case df::general_ref_type::BUILDING_CIVZONE_ASSIGNED: case df::general_ref_type::BUILDING_CIVZONE_ASSIGNED:
{ {
unit->refs.erase(unit->refs.begin() + idx); unit->general_refs.erase(unit->general_refs.begin() + idx);
df::building_civzonest * oldciv = (df::building_civzonest *) oldref->getBuilding(); df::building_civzonest * oldciv = (df::building_civzonest *) oldref->getBuilding();
for(size_t oc=0; oc<oldciv->assigned_creature.size(); oc++) for(size_t oc=0; oc<oldciv->assigned_creature.size(); oc++)
{ {
@ -1305,7 +1305,7 @@ bool unassignUnitFromBuilding(df::unit* unit)
case df::general_ref_type::CONTAINED_IN_ITEM: case df::general_ref_type::CONTAINED_IN_ITEM:
{ {
// game does not erase the ref until creature gets removed from cage // game does not erase the ref until creature gets removed from cage
//unit->refs.erase(unit->refs.begin() + idx); //unit->general_refs.erase(unit->general_refs.begin() + idx);
// walk through buildings, check cages for inhabitants, compare ids // walk through buildings, check cages for inhabitants, compare ids
for (size_t b=0; b < world->buildings.all.size(); b++) for (size_t b=0; b < world->buildings.all.size(); b++)
@ -1335,7 +1335,7 @@ bool unassignUnitFromBuilding(df::unit* unit)
case df::general_ref_type::BUILDING_CHAIN: case df::general_ref_type::BUILDING_CHAIN:
{ {
// try not erasing the ref and see what happens // try not erasing the ref and see what happens
//unit->refs.erase(unit->refs.begin() + idx); //unit->general_refs.erase(unit->general_refs.begin() + idx);
// probably need to delete chain reference here // probably need to delete chain reference here
//success = true; //success = true;
break; break;
@ -1344,7 +1344,7 @@ bool unassignUnitFromBuilding(df::unit* unit)
case df::general_ref_type::BUILDING_CAGED: case df::general_ref_type::BUILDING_CAGED:
{ {
// not sure what to do here, doesn't seem to get used by the game // not sure what to do here, doesn't seem to get used by the game
//unit->refs.erase(unit->refs.begin() + idx); //unit->general_refs.erase(unit->general_refs.begin() + idx);
//success = true; //success = true;
break; break;
} }
@ -1396,7 +1396,7 @@ command_result assignUnitToZone(color_ostream& out, df::unit* unit, df::building
} }
ref->building_id = building->id; ref->building_id = building->id;
unit->refs.push_back(ref); unit->general_refs.push_back(ref);
df::building_civzonest * civz = (df::building_civzonest *) building; df::building_civzonest * civz = (df::building_civzonest *) building;
civz->assigned_creature.push_back(unit->id); civz->assigned_creature.push_back(unit->id);
@ -1437,7 +1437,7 @@ command_result assignUnitToCage(color_ostream& out, df::unit* unit, df::building
} }
//ref->building_id = building->id; //ref->building_id = building->id;
//unit->refs.push_back(ref); //unit->general_refs.push_back(ref);
df::building_cagest* civz = (df::building_cagest*) building; df::building_cagest* civz = (df::building_cagest*) building;
civz->assigned_creature.push_back(unit->id); civz->assigned_creature.push_back(unit->id);