develop
Jeremy Apthorp 2019-12-07 19:27:35 -08:00
parent 195db1bad9
commit 910f965838
5 changed files with 15 additions and 0 deletions

@ -1611,6 +1611,7 @@ static const LuaWrapper::FunctionReg dfhack_units_module[] = {
WRAPM(Units, isOwnCiv), WRAPM(Units, isOwnCiv),
WRAPM(Units, isOwnGroup), WRAPM(Units, isOwnGroup),
WRAPM(Units, isOwnRace), WRAPM(Units, isOwnRace),
WRAPM(Units, getDescription),
WRAPM(Units, getRaceName), WRAPM(Units, getRaceName),
WRAPM(Units, getRaceNamePlural), WRAPM(Units, getRaceNamePlural),
WRAPM(Units, getRaceBabyName), WRAPM(Units, getRaceBabyName),

@ -120,6 +120,7 @@ DFHACK_EXPORT bool isVisible(df::unit* unit);
DFHACK_EXPORT std::string getRaceNameById(int32_t race_id); DFHACK_EXPORT std::string getRaceNameById(int32_t race_id);
DFHACK_EXPORT std::string getRaceName(df::unit* unit); DFHACK_EXPORT std::string getRaceName(df::unit* unit);
DFHACK_EXPORT std::string getDescription(df::unit* unit);
DFHACK_EXPORT std::string getRaceNamePluralById(int32_t race_id); DFHACK_EXPORT std::string getRaceNamePluralById(int32_t race_id);
DFHACK_EXPORT std::string getRaceNamePlural(df::unit* unit); DFHACK_EXPORT std::string getRaceNamePlural(df::unit* unit);
DFHACK_EXPORT std::string getRaceBabyNameById(int32_t race_id); DFHACK_EXPORT std::string getRaceBabyNameById(int32_t race_id);

@ -541,6 +541,16 @@ string Units::getRaceName(df::unit* unit)
return getRaceNameById(unit->race); return getRaceNameById(unit->race);
} }
typedef void (*df_unit_desc_fn)(df::unit*, std::string*);
static df_unit_desc_fn df_unit_desc = reinterpret_cast<df_unit_desc_fn>(0x100cbb890);
string Units::getDescription(df::unit* unit)
{
CHECK_NULL_POINTER(unit);
std::string str;
df_unit_desc(unit, &str);
return str;
}
// get plural of race name (used for display in autobutcher UI and for sorting the watchlist) // get plural of race name (used for display in autobutcher UI and for sorting the watchlist)
string Units::getRaceNamePluralById(int32_t id) string Units::getRaceNamePluralById(int32_t id)
{ {

@ -420,6 +420,7 @@ message UnitAppearance
optional Hair beard = 6; optional Hair beard = 6;
optional Hair moustache = 7; optional Hair moustache = 7;
optional Hair sideburns = 8; optional Hair sideburns = 8;
optional string description = 9;
} }
message InventoryItem message InventoryItem

@ -1750,6 +1750,8 @@ static command_result GetUnitListInside(color_ostream &stream, const BlockReques
appearance->add_colors(unit->appearance.colors[j]); appearance->add_colors(unit->appearance.colors[j]);
appearance->set_size_modifier(unit->appearance.size_modifier); appearance->set_size_modifier(unit->appearance.size_modifier);
appearance->set_description(Units::getDescription(unit));
send_unit->set_profession_id(unit->profession); send_unit->set_profession_id(unit->profession);
std::vector<Units::NoblePosition> pvec; std::vector<Units::NoblePosition> pvec;