Expose Units::casteFlagSet()

develop
lethosor 2015-12-19 11:07:35 -05:00
parent 15d3815f26
commit 5a1e5e1464
3 changed files with 8 additions and 16 deletions

@ -31,11 +31,13 @@ distribution.
#include "Export.h"
#include "modules/Items.h"
#include "DataDefs.h"
#include "df/unit.h"
#include "df/caste_raw_flags.h"
#include "df/job_skill.h"
#include "df/mental_attribute_type.h"
#include "df/misc_trait_type.h"
#include "df/physical_attribute_type.h"
#include "df/mental_attribute_type.h"
#include "df/job_skill.h"
#include "df/unit.h"
namespace df
{
@ -219,6 +221,7 @@ DFHACK_EXPORT df::nemesis_record *getNemesis(df::unit *unit);
DFHACK_EXPORT bool isHidingCurse(df::unit *unit);
DFHACK_EXPORT int getPhysicalAttrValue(df::unit *unit, df::physical_attribute_type attr);
DFHACK_EXPORT int getMentalAttrValue(df::unit *unit, df::mental_attribute_type attr);
DFHACK_EXPORT bool casteFlagSet(int race, int caste, df::caste_raw_flags flag);
DFHACK_EXPORT bool isCrazed(df::unit *unit);
DFHACK_EXPORT bool isOpposedToLife(df::unit *unit);

@ -680,7 +680,7 @@ int Units::getMentalAttrValue(df::unit *unit, df::mental_attribute_type attr)
return std::max(0, value);
}
static bool casteFlagSet(int race, int caste, df::caste_raw_flags flag)
bool Units::casteFlagSet(int race, int caste, df::caste_raw_flags flag)
{
auto creature = df::creature_raw::find(race);
if (!creature)

@ -49,17 +49,6 @@ using df::global::debug_nomoods;
Random::MersenneRNG rng;
static bool casteFlagSet(int race, int caste, df::caste_raw_flags flag)
{
auto creature = df::creature_raw::find(race);
if (!creature)
return false;
auto craw = vector_get(creature->caste, caste);
if (!craw)
return false;
return craw->flags.is_set(flag);
}
bool isUnitMoodable (df::unit *unit)
{
if (!Units::isCitizen(unit))
@ -70,7 +59,7 @@ bool isUnitMoodable (df::unit *unit)
return false;
if (!ENUM_ATTR(profession,moodable,unit->profession))
return false;
if (!casteFlagSet(unit->race, unit->caste, caste_raw_flags::STRANGE_MOODS))
if (!Units::casteFlagSet(unit->race, unit->caste, caste_raw_flags::STRANGE_MOODS))
return false;
return true;
}