Update for 64-bit unit changes

Includes xml, stonesense, scripts

Ref DFHack/df-structures@25cb373
develop
lethosor 2016-08-10 23:50:00 -04:00
parent acc4a6a0b1
commit 215afa34f3
12 changed files with 87 additions and 79 deletions

@ -77,6 +77,7 @@ using namespace DFHack;
#include "df/ui.h"
#include "df/ui_look_list.h"
#include "df/unit.h"
#include "df/unit_relationship_type.h"
#include "df/world.h"
using namespace df::enums;
@ -224,7 +225,7 @@ bool Buildings::setOwner(df::building *bld, df::unit *unit)
auto &blist = bld->owner->owned_buildings;
vector_erase_at(blist, linear_index(blist, bld));
if (auto spouse = df::unit::find(bld->owner->relations.spouse_id))
if (auto spouse = df::unit::find(bld->owner->relationship_ids[df::unit_relationship_type::Spouse]))
{
auto &blist = spouse->owned_buildings;
vector_erase_at(blist, linear_index(blist, bld));
@ -237,7 +238,7 @@ bool Buildings::setOwner(df::building *bld, df::unit *unit)
{
unit->owned_buildings.push_back(bld);
if (auto spouse = df::unit::find(unit->relations.spouse_id))
if (auto spouse = df::unit::find(unit->relationship_ids[df::unit_relationship_type::Spouse]))
{
auto &blist = spouse->owned_buildings;
if (bld->canUseSpouseRoom() && linear_index(blist, bld) < 0)
@ -1269,14 +1270,14 @@ bool Buildings::isHospital(df::building * building)
return false;
return ((df::building_civzonest*) building)->zone_flags.bits.hospital != 0;
}
bool Buildings::isAnimalTraining(df::building * building)
{
if (!isActivityZone(building))
return false;
return ((df::building_civzonest*) building)->zone_flags.bits.animal_training != 0;
}
// returns building of pen/pit at cursor position (NULL if nothing found)
df::building* Buildings::findPenPitAt(df::coord coord)
{

@ -70,6 +70,7 @@ using namespace std;
#include "df/ui.h"
#include "df/unit_inventory_item.h"
#include "df/unit_misc_trait.h"
#include "df/unit_relationship_type.h"
#include "df/unit_skill.h"
#include "df/unit_soul.h"
#include "df/unit_wound.h"
@ -170,9 +171,9 @@ void Units::CopyCreature(df::unit * source, t_unit & furball)
// labors
memcpy(&furball.labors, &source->status.labors, sizeof(furball.labors));
furball.birth_year = source->relations.birth_year;
furball.birth_time = source->relations.birth_time;
furball.pregnancy_timer = source->relations.pregnancy_timer;
furball.birth_year = source->birth_year;
furball.birth_time = source->birth_time;
furball.pregnancy_timer = source->pregnancy_timer;
// appearance
furball.nbcolors = source->appearance.colors.size();
if(furball.nbcolors>MAX_COLORS)
@ -1085,10 +1086,10 @@ double Units::getAge(df::unit *unit, bool true_age)
return -1;
double year_ticks = 403200.0;
double birth_time = unit->relations.birth_year + unit->relations.birth_time/year_ticks;
double birth_time = unit->birth_year + unit->birth_time/year_ticks;
double cur_time = *cur_year + *cur_year_tick / year_ticks;
if (!true_age && unit->relations.curse_year >= 0)
if (!true_age && unit->curse_year >= 0)
{
if (auto identity = getIdentity(unit))
{
@ -1453,7 +1454,8 @@ int Units::computeMovementSpeed(df::unit *unit)
// Activity state
if (unit->relations.draggee_id != -1) speed += 1000;
if (unit->relationship_ids[df::unit_relationship_type::Draggee] != -1)
speed += 1000;
if (unit->flags1.bits.on_ground)
speed += 2000;
@ -1522,7 +1524,7 @@ int Units::computeMovementSpeed(df::unit *unit)
if (is_adventure)
{
auto player = vector_get(world->units.active, 0);
if (player && player->id == unit->relations.group_leader_id)
if (player && player->id == unit->relationship_ids[df::unit_relationship_type::GroupLeader])
speed = std::min(speed, computeMovementSpeed(player));
}
@ -1551,14 +1553,14 @@ float Units::computeSlowdownFactor(df::unit *unit)
{
if (!unit->flags1.bits.marauder &&
casteFlagSet(unit->race, unit->caste, caste_raw_flags::MEANDERER) &&
!(unit->relations.following && isCitizen(unit)) &&
!(unit->following && isCitizen(unit)) &&
linear_index(unit->inventory, &df::unit_inventory_item::mode,
df::unit_inventory_item::Hauled) < 0)
{
coeff *= 4.0f;
}
if (unit->relations.group_leader_id < 0 &&
if (unit->relationship_ids[df::unit_relationship_type::GroupLeader] < 0 &&
unit->flags1.bits.active_invader &&
!unit->job.current_job && !unit->flags3.bits.no_meandering &&
unit->profession != profession::THIEF && unit->profession != profession::MASTER_THIEF &&

@ -1 +1 @@
Subproject commit 40288996152af8460e747a7479ebc6dc0e617cd9
Subproject commit d5036d8336d266bcb13e27e702a0acada01227a4

@ -229,7 +229,7 @@ command_result cursecheck (color_ostream &out, vector <string> & parameters)
}
// non-cursed creatures have curse_year == -1
if(unit->relations.curse_year != -1)
if(unit->curse_year != -1)
{
cursecount++;
@ -268,8 +268,8 @@ command_result cursecheck (color_ostream &out, vector <string> & parameters)
}
out.print("born in %d, cursed in %d to be a %s. (%s%s%s)\n",
unit->relations.birth_year,
unit->relations.curse_year,
unit->birth_year,
unit->curse_year,
cursetype.c_str(),
// technically most cursed creatures are undead,
// therefore output 'active' if they are not completely dead

@ -48,7 +48,7 @@ static void eggscan(color_ostream &out)
if (nb->claimed_by != -1)
{
df::unit* u = df::unit::find(nb->claimed_by);
if (u && u->relations.pregnancy_timer > 0)
if (u && u->pregnancy_timer > 0)
fertile = true;
}
for (int j = 1; j < nb->contained_items.size(); j++)

@ -1,16 +1,17 @@
#include "Core.h"
#include "Console.h"
#include "DataDefs.h"
#include "Export.h"
#include "PluginManager.h"
#include "modules/Units.h"
#include "modules/Maps.h"
#include "DataDefs.h"
#include "df/world.h"
#include "df/map_block.h"
#include "df/unit.h"
#include "df/unit_action.h"
#include "df/map_block.h"
#include "df/unit_relationship_type.h"
#include "df/units_other_id.h"
#include "df/world.h"
using std::string;
using std::vector;
@ -56,11 +57,12 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
if (enable_teledwarf) do
{
// skip dwarves that are dragging creatures or being dragged
if ((unit->relations.draggee_id != -1) || (unit->relations.dragger_id != -1))
if ((unit->relationship_ids[df::unit_relationship_type::Draggee] != -1) ||
(unit->relationship_ids[df::unit_relationship_type::Dragger] != -1))
break;
// skip dwarves that are following other units
if (unit->relations.following != 0)
if (unit->following != 0)
break;
// skip unconscious units
@ -105,7 +107,7 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out )
for (size_t j = 0; j < world->units.other[units_other_id::ANY_RIDER].size(); j++)
{
df::unit *rider = world->units.other[units_other_id::ANY_RIDER][j];
if (rider->relations.rider_mount_id == unit->id)
if (rider->relationship_ids[df::unit_relationship_type::RiderMount] == unit->id)
rider->pos = unit->pos;
}
}

@ -67,7 +67,7 @@ void impregnateMany() {
if ( unit->flags1.bits.dead || unit->flags1.bits.active_invader || unit->flags2.bits.underworld || unit->flags2.bits.visitor_uninvited || unit->flags2.bits.visitor )
continue;
popcount[unit->race]++;
if ( unit->relations.pregnancy_genes ) {
if ( unit->pregnancy_genes ) {
//already pregnant
//for player convenience and population stability, count the fetus toward the population cap
popcount[unit->race]++;
@ -122,14 +122,14 @@ void impregnateMany() {
bool impregnate(df::unit* female, df::unit* male) {
if ( !female || !male )
return false;
if ( female->relations.pregnancy_genes )
if ( female->pregnancy_genes )
return false;
df::unit_genes* preg = new df::unit_genes;
*preg = male->appearance.genes;
female->relations.pregnancy_genes = preg;
female->relations.pregnancy_timer = pregtime; //300000 for dwarves
female->relations.pregnancy_caste = male->caste;
female->pregnancy_genes = preg;
female->pregnancy_timer = pregtime; //300000 for dwarves
female->pregnancy_caste = male->caste;
return true;
}

@ -22,40 +22,41 @@
#include <string.h>
#include <VTableInterpose.h>
#include "df/graphic.h"
#include "df/building_drawbuffer.h"
#include "df/building_siegeenginest.h"
#include "df/builtin_mats.h"
#include "df/world.h"
#include "df/building_stockpilest.h"
#include "df/buildings_other_id.h"
#include "df/job.h"
#include "df/building_drawbuffer.h"
#include "df/ui.h"
#include "df/viewscreen_dwarfmodest.h"
#include "df/ui_build_selector.h"
#include "df/flow_info.h"
#include "df/report.h"
#include "df/proj_itemst.h"
#include "df/unit.h"
#include "df/unit_soul.h"
#include "df/unit_skill.h"
#include "df/physical_attribute_type.h"
#include "df/creature_raw.h"
#include "df/builtin_mats.h"
#include "df/caste_raw.h"
#include "df/caste_raw_flags.h"
#include "df/identity.h"
#include "df/creature_raw.h"
#include "df/flow_info.h"
#include "df/flow_type.h"
#include "df/game_mode.h"
#include "df/unit_misc_trait.h"
#include "df/job.h"
#include "df/job_item.h"
#include "df/graphic.h"
#include "df/identity.h"
#include "df/invasion_info.h"
#include "df/item_actual.h"
#include "df/items_other_id.h"
#include "df/building_stockpilest.h"
#include "df/job.h"
#include "df/job.h"
#include "df/job_item.h"
#include "df/material.h"
#include "df/physical_attribute_type.h"
#include "df/proj_itemst.h"
#include "df/report.h"
#include "df/stockpile_links.h"
#include "df/workshop_profile.h"
#include "df/strain_type.h"
#include "df/material.h"
#include "df/flow_type.h"
#include "df/invasion_info.h"
#include "df/ui.h"
#include "df/ui_build_selector.h"
#include "df/unit.h"
#include "df/unit_misc_trait.h"
#include "df/unit_relationship_type.h"
#include "df/unit_skill.h"
#include "df/unit_soul.h"
#include "df/viewscreen_dwarfmodest.h"
#include "df/workshop_profile.h"
#include "df/world.h"
#include "MiscUtils.h"
@ -1193,7 +1194,7 @@ struct UnitPath {
{
if (unit->flags1.bits.rider)
{
auto mount = df::unit::find(unit->relations.rider_mount_id);
auto mount = df::unit::find(unit->relationship_ids[df::unit_relationship_type::RiderMount]);
if (mount)
{

@ -1 +1 @@
Subproject commit bd6e8f9f90af1586f5b1eb0003d7e0e133acecc8
Subproject commit 9270ceb5463657a6d039bdc3389fe69c78a0784b

@ -2,6 +2,7 @@
#include "Core.h"
#include "Console.h"
#include "DataDefs.h"
#include "Export.h"
#include "PluginManager.h"
#include "modules/Gui.h"
@ -11,24 +12,24 @@
#include "modules/Translation.h"
#include "modules/Random.h"
#include "DataDefs.h"
#include "df/builtin_mats.h"
#include "df/caste_raw.h"
#include "df/caste_raw_flags.h"
#include "df/creature_raw.h"
#include "df/d_init.h"
#include "df/world.h"
#include "df/entity_raw.h"
#include "df/general_ref_unit_workerst.h"
#include "df/historical_entity.h"
#include "df/job.h"
#include "df/job_item.h"
#include "df/map_block.h"
#include "df/ui.h"
#include "df/unit.h"
#include "df/unit_soul.h"
#include "df/unit_skill.h"
#include "df/unit_preference.h"
#include "df/map_block.h"
#include "df/job.h"
#include "df/job_item.h"
#include "df/historical_entity.h"
#include "df/entity_raw.h"
#include "df/builtin_mats.h"
#include "df/general_ref_unit_workerst.h"
#include "df/creature_raw.h"
#include "df/caste_raw.h"
#include "df/caste_raw_flags.h"
#include "df/unit_relationship_type.h"
#include "df/unit_skill.h"
#include "df/unit_soul.h"
#include "df/world.h"
using std::string;
using std::vector;
@ -579,9 +580,9 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
df::unit *cur = moodable_units[i];
if (cur->flags1.bits.had_mood)
continue;
if (cur->relations.dragger_id != -1)
if (cur->relationship_ids[df::unit_relationship_type::Dragger] != -1)
continue;
if (cur->relations.draggee_id != -1)
if (cur->relationship_ids[df::unit_relationship_type::Draggee] != -1)
continue;
tickets.push_back(i);
for (int j = 0; j < 5; j++)
@ -699,7 +700,7 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
}
unit->mood = type;
unit->relations.mood_copy = unit->mood;
unit->mood_copy = unit->mood;
Gui::showAutoAnnouncement(announcement_type::STRANGE_MOOD, unit->pos, msg, color, bright);
// TODO: make sure unit drops any wrestle items

@ -72,6 +72,7 @@
#include "df/general_ref_building_civzone_assignedst.h"
#include <df/creature_raw.h>
#include <df/caste_raw.h>
#include "df/unit_relationship_type.h"
#include "df/unit_soul.h"
#include "df/unit_wound.h"
#include "df/viewscreen_dwarfmodest.h"
@ -982,7 +983,7 @@ command_result assignUnitToCage(color_ostream& out, df::unit* unit, df::building
}
// don't assign owned pets to a cage. the owner will release them, resulting into infinite hauling (df bug)
if(unit->relations.pet_owner_id != -1)
if(unit->relationship_ids[df::unit_relationship_type::Pet] != -1)
return CR_OK;
// check if unit is already pastured or caged, remove refs where necessary
@ -2362,8 +2363,8 @@ bool compareUnitAgesYounger(df::unit* i, df::unit* j)
int32_t age_j = (int32_t) getAge(j, true);
if(age_i == 0 && age_j == 0)
{
age_i = i->relations.birth_time;
age_j = j->relations.birth_time;
age_i = i->birth_time;
age_j = j->birth_time;
}
return (age_i < age_j);
}
@ -2373,8 +2374,8 @@ bool compareUnitAgesOlder(df::unit* i, df::unit* j)
int32_t age_j = (int32_t) getAge(j, true);
if(age_i == 0 && age_j == 0)
{
age_i = i->relations.birth_time;
age_j = j->relations.birth_time;
age_i = i->birth_time;
age_j = j->birth_time;
}
return (age_i > age_j);
}

@ -1 +1 @@
Subproject commit b1e7544d87a59e86ae74a2468b18c0b319526932
Subproject commit 9558feba77c57168a7970e1ebcbc1c7b3a82ab97