From c39a882b575686e62b0da2d0f978845ee8731623 Mon Sep 17 00:00:00 2001 From: Pauli Date: Fri, 29 Jun 2018 16:13:56 +0300 Subject: [PATCH 1/2] Add missing Unit::isDiplomat Fixes #1324 --- docs/changelog.txt | 3 +++ library/LuaApi.cpp | 1 + library/include/modules/Units.h | 1 + library/modules/Units.cpp | 7 +++++++ 4 files changed, 12 insertions(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 056bb52e8..165f781a1 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -37,6 +37,9 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ================================================================================ # Future +## Fixes +- `fix/dead-units`: Fixed script trying to use missing isDiplomat function + # 0.44.11-alpha1 ## Structures diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index e735eeb4b..ceb637249 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -1626,6 +1626,7 @@ static const LuaWrapper::FunctionReg dfhack_units_module[] = { WRAPM(Units, isMale), WRAPM(Units, isFemale), WRAPM(Units, isMerchant), + WRAPM(Units, isDiplomat), WRAPM(Units, isForest), WRAPM(Units, isMarkedForSlaughter), WRAPM(Units, isTame), diff --git a/library/include/modules/Units.h b/library/include/modules/Units.h index b6aa78bad..2a7364dbf 100644 --- a/library/include/modules/Units.h +++ b/library/include/modules/Units.h @@ -139,6 +139,7 @@ DFHACK_EXPORT bool isTamable(df::unit* unit); DFHACK_EXPORT bool isMale(df::unit* unit); DFHACK_EXPORT bool isFemale(df::unit* unit); DFHACK_EXPORT bool isMerchant(df::unit* unit); +DFHACK_EXPORT bool isDiplomat(df::unit* unit); DFHACK_EXPORT bool isForest(df::unit* unit); DFHACK_EXPORT bool isMarkedForSlaughter(df::unit* unit); DFHACK_EXPORT bool isTame(df::unit* unit); diff --git a/library/modules/Units.cpp b/library/modules/Units.cpp index 8a2aa76c8..fc2f20c6a 100644 --- a/library/modules/Units.cpp +++ b/library/modules/Units.cpp @@ -1476,6 +1476,13 @@ bool Units::isMerchant(df::unit* unit) return unit->flags1.bits.merchant == 1; } +bool Units::isDiplomat(df::unit* unit) +{ + CHECK_NULL_POINTER(unit); + + return unit->flags1.bits.diplomat == 1; +} + bool Units::isForest(df::unit* unit) { CHECK_NULL_POINTER(unit); From 5d1141e1ec3c78ed337ac9a2ce6dff5c5186f33b Mon Sep 17 00:00:00 2001 From: Lethosor Date: Fri, 29 Jun 2018 09:26:16 -0400 Subject: [PATCH 2/2] Add isDiplomat to API section too --- docs/changelog.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 165f781a1..9ae8209ad 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -38,7 +38,11 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: # Future ## Fixes -- `fix/dead-units`: Fixed script trying to use missing isDiplomat function +- `fix/dead-units`: fixed script trying to use missing isDiplomat function + +## API +- New functions: + - ``Units::isDiplomat(unit)`` # 0.44.11-alpha1