Skip to content

Commit fa74c55

Browse files
authored
Merge pull request #5495 from ab9rf/remove-unitst-curse
remove fake `curse` compound in `unitst`
2 parents e89efb4 + 985e283 commit fa74c55

File tree

6 files changed

+49
-49
lines changed

6 files changed

+49
-49
lines changed

library/RemoteTools.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -336,22 +336,22 @@ void DFHack::describeUnit(BasicUnitInfo *info, df::unit *unit,
336336
}
337337
}
338338

339-
if (unit->curse.add_tags1.whole ||
340-
unit->curse.add_tags2.whole ||
341-
unit->curse.rem_tags1.whole ||
342-
unit->curse.rem_tags2.whole ||
343-
unit->curse.name_visible)
339+
if (unit->uwss_add_caste_flag.whole ||
340+
unit->uwss_remove_caste_flag.whole ||
341+
unit->uwss_add_property.whole ||
342+
unit->uwss_remove_property.whole ||
343+
unit->uwss_use_display_name)
344344
{
345345
auto curse = info->mutable_curse();
346346

347-
curse->set_add_tags1(unit->curse.add_tags1.whole);
348-
curse->set_rem_tags1(unit->curse.rem_tags1.whole);
349-
curse->set_add_tags2(unit->curse.add_tags2.whole);
350-
curse->set_rem_tags2(unit->curse.rem_tags2.whole);
347+
curse->set_add_tags1(unit->uwss_add_caste_flag.whole);
348+
curse->set_rem_tags1(unit->uwss_add_property.whole);
349+
curse->set_add_tags2(unit->uwss_remove_caste_flag.whole);
350+
curse->set_rem_tags2(unit->uwss_remove_property.whole);
351351

352-
if (unit->curse.name_visible)
353-
describeNameTriple(curse->mutable_name(), unit->curse.name,
354-
unit->curse.name_plural, unit->curse.name_adjective);
352+
if (unit->uwss_use_display_name)
353+
describeNameTriple(curse->mutable_name(), unit->uwss_display_name_sing,
354+
unit->uwss_display_name_plur, unit->uwss_display_name_adj);
355355
}
356356

357357
for (size_t i = 0; i < unit->burrows.size(); i++)

library/modules/Units.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ using df::global::gametype;
108108
using df::global::plotinfo;
109109
using df::global::world;
110110

111-
#define IS_ACTIVE_CASTE_FLAG(cf) !unit->curse.rem_tags1.bits.cf && \
112-
(unit->curse.add_tags1.bits.cf || casteFlagSet(unit->race, unit->caste, caste_raw_flags::cf))
111+
#define IS_ACTIVE_CASTE_FLAG(cf) !unit->uwss_remove_caste_flag.bits.cf && \
112+
(unit->uwss_add_caste_flag.bits.cf || casteFlagSet(unit->race, unit->caste, caste_raw_flags::cf))
113113

114114
// Common flags to exclude for fort members
115115
constexpr uint32_t exclude_flags1 = (
@@ -208,7 +208,7 @@ bool Units::isOwnRace(df::unit *unit) {
208208

209209
bool Units::isAlive(df::unit *unit) {
210210
CHECK_NULL_POINTER(unit);
211-
return !isDead(unit) && !unit->curse.add_tags1.bits.NOT_LIVING;
211+
return !isDead(unit) && !unit->uwss_add_caste_flag.bits.NOT_LIVING;
212212
}
213213

214214
bool Units::isDead(df::unit *unit) {
@@ -606,7 +606,7 @@ bool Units::isInvader(df::unit *unit) {
606606

607607
bool Units::isUndead(df::unit *unit, bool hiding_curse) {
608608
CHECK_NULL_POINTER(unit);
609-
const auto &cb = unit->curse.add_tags1.bits;
609+
const auto &cb = unit->uwss_add_caste_flag.bits;
610610
return unit->flags3.bits.ghostly ||
611611
((cb.OPPOSED_TO_LIFE || cb.NOT_LIVING) && (hiding_curse || !isHidingCurse(unit)));
612612
}
@@ -1014,7 +1014,7 @@ int Units::getPhysicalAttrValue(df::unit *unit, df::physical_attribute_type attr
10141014
auto &aobj = unit->body.physical_attrs[attr];
10151015
int value = max(0, aobj.value - aobj.soft_demotion);
10161016

1017-
if (auto mod = unit->curse.attr_change)
1017+
if (auto mod = unit->uwss_att_change)
10181018
{
10191019
int mvalue = (value * mod->phys_att_perc[attr] / 100) + mod->phys_att_add[attr];
10201020
if (isHidingCurse(unit))
@@ -1033,7 +1033,7 @@ int Units::getMentalAttrValue(df::unit *unit, df::mental_attribute_type attr) {
10331033
auto &aobj = soul->mental_attrs[attr];
10341034
int value = max(0, aobj.value - aobj.soft_demotion);
10351035

1036-
if (auto mod = unit->curse.attr_change)
1036+
if (auto mod = unit->uwss_att_change)
10371037
{
10381038
int mvalue = (value * mod->ment_att_perc[attr] / 100) + mod->ment_att_add[attr];
10391039
if (isHidingCurse(unit))
@@ -1192,8 +1192,8 @@ string Units::getReadableName(df::unit *unit, bool skip_english) {
11921192
CHECK_NULL_POINTER(unit);
11931193
string prof_name = getProfessionName(unit, false, false, true);
11941194

1195-
if (unit->curse.name_visible) // Necromancer, etc.
1196-
prof_name += " " + unit->curse.name;
1195+
if (unit->uwss_use_display_name) // Necromancer, etc.
1196+
prof_name += " " + unit->uwss_display_name_sing;
11971197
else if (isGhost(unit)) // TODO: Should be "Ghost" instead of "Ghostly Peasant"
11981198
prof_name = "Ghostly " + prof_name;
11991199
// TODO: impersonating deity/force

library/xml

plugins/cursecheck.cpp

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ curses determineCurse(df::unit * unit)
9090
cursetype = curses::Ghost;
9191

9292
// zombies: undead or hate life (according to ag), not bloodsuckers
93-
if( (unit->curse.add_tags1.bits.OPPOSED_TO_LIFE || unit->curse.add_tags1.bits.NOT_LIVING)
94-
&& !unit->curse.add_tags1.bits.BLOODSUCKER )
93+
if( (unit->uwss_add_caste_flag.bits.OPPOSED_TO_LIFE || unit->uwss_add_caste_flag.bits.NOT_LIVING)
94+
&& !unit->uwss_add_caste_flag.bits.BLOODSUCKER)
9595
cursetype = curses::Zombie;
9696

9797
// necromancers: alive, don't eat, don't drink, don't age
98-
if(!unit->curse.add_tags1.bits.NOT_LIVING
99-
&& unit->curse.add_tags1.bits.NO_EAT
100-
&& unit->curse.add_tags1.bits.NO_DRINK
101-
&& unit->curse.add_tags2.bits.NO_AGING
98+
if (!unit->uwss_add_caste_flag.bits.NOT_LIVING
99+
&& unit->uwss_add_caste_flag.bits.NO_EAT
100+
&& unit->uwss_add_caste_flag.bits.NO_DRINK
101+
&& unit->uwss_add_property.bits.NO_AGING
102102
)
103103
cursetype = curses::Necromancer;
104104

@@ -108,21 +108,21 @@ curses determineCurse(df::unit * unit)
108108
auto syndrome = df::syndrome::find(active_syndrome->type);
109109
if (syndrome) {
110110
for (auto classname : syndrome->syn_class)
111-
if (classname && *classname == "WERECURSE") {
112-
cursetype = curses::Werebeast;
113-
break;
114-
}
111+
if (classname && *classname == "WERECURSE") {
112+
cursetype = curses::Werebeast;
113+
break;
114+
}
115115
}
116116
}
117117

118118
// vampires: bloodsucker (obvious enough)
119-
if(unit->curse.add_tags1.bits.BLOODSUCKER)
119+
if (unit->uwss_add_caste_flag.bits.BLOODSUCKER)
120120
cursetype = curses::Vampire;
121121

122122
return cursetype;
123123
}
124124

125-
command_result cursecheck (color_ostream &out, vector <string> & parameters)
125+
command_result cursecheck(color_ostream& out, vector <string>& parameters)
126126
{
127127
df::unit* selected_unit = Gui::getSelectedUnit(out, true);
128128

@@ -133,19 +133,19 @@ command_result cursecheck (color_ostream &out, vector <string> & parameters)
133133
bool verbose = false;
134134
size_t cursecount = 0;
135135

136-
for(auto parameter : parameters)
136+
for (auto parameter : parameters)
137137
{
138-
if(parameter == "help" || parameter == "?")
138+
if (parameter == "help" || parameter == "?")
139139
return CR_WRONG_USAGE;
140-
if(parameter == "detail")
140+
if (parameter == "detail")
141141
giveDetails = true;
142-
if(parameter == "ids")
142+
if (parameter == "ids")
143143
giveUnitID = true;
144-
if(parameter == "nick")
144+
if (parameter == "nick")
145145
giveNick = true;
146-
if(parameter == "all")
146+
if (parameter == "all")
147147
ignoreDead = false;
148-
if(parameter == "verbose")
148+
if (parameter == "verbose")
149149
{
150150
// verbose makes no sense without enabling details
151151
giveDetails = true;
@@ -157,11 +157,11 @@ command_result cursecheck (color_ostream &out, vector <string> & parameters)
157157
vector<df::unit*> to_check;
158158
if (selected_unit)
159159
to_check.push_back(selected_unit);
160-
for(df::unit *unit : to_check.size() ? to_check : world->units.all)
160+
for (df::unit* unit : to_check.size() ? to_check : world->units.all)
161161
{
162162
// filter out all "living" units that are currently removed from play
163163
// don't spam all completely dead creatures if not explicitly wanted
164-
if((!Units::isActive(unit) && !Units::isKilled(unit)) || (Units::isKilled(unit) && ignoreDead))
164+
if ((!Units::isActive(unit) && !Units::isKilled(unit)) || (Units::isKilled(unit) && ignoreDead))
165165
{
166166
continue;
167167
}
@@ -170,9 +170,9 @@ command_result cursecheck (color_ostream &out, vector <string> & parameters)
170170

171171
if (cursetype != curses::None)
172172
{
173-
cursecount++;
173+
cursecount++;
174174

175-
if(giveNick)
175+
if (giveNick)
176176
{
177177
Units::setNickname(unit, curse_names[cursetype]); //"CURSED");
178178
}
@@ -196,8 +196,8 @@ command_result cursecheck (color_ostream &out, vector <string> & parameters)
196196
if (verbose)
197197
{
198198
out << "Curse flags: "
199-
<< bitfield_to_string(unit->curse.add_tags1) << std::endl
200-
<< bitfield_to_string(unit->curse.add_tags2) << std::endl;
199+
<< bitfield_to_string(unit->uwss_add_caste_flag) << std::endl
200+
<< bitfield_to_string(unit->uwss_add_property) << std::endl;
201201
}
202202
}
203203

plugins/lua/sort.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ local function get_active_idx_cache()
4343
end
4444

4545
local function is_original_dwarf(unit)
46-
return df.global.plotinfo.fortress_age == unit.curse.interaction.time_on_site // 10
46+
return df.global.plotinfo.fortress_age == unit.usable_interaction.time_on_site // 10
4747
end
4848

4949
local WAVE_END_GAP = 10000
@@ -53,7 +53,7 @@ local function get_most_recent_wave_oldest_active_idx(cache)
5353
for idx=#active_units-1,0,-1 do
5454
local unit = active_units[idx]
5555
if not dfhack.units.isCitizen(unit) then goto continue end
56-
if oldest_unit and unit.curse.interaction.time_on_site - oldest_unit.curse.interaction.time_on_site > WAVE_END_GAP then
56+
if oldest_unit and unit.usable_interaction.time_on_site - oldest_unit.usable_interaction.time_on_site > WAVE_END_GAP then
5757
return cache[oldest_unit.id]
5858
else
5959
oldest_unit = unit

0 commit comments

Comments
 (0)