Skip to content

Commit 04ec2c9

Browse files
committed
Update version to v0.40.14 and hack things so they compile.
Also make the find-offsets script less likely to crash if the unit structure is misaligned and add more integrity checks.
1 parent beebd62 commit 04ec2c9

8 files changed

Lines changed: 45 additions & 26 deletions

File tree

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ if (NOT EXISTS ${dfhack_SOURCE_DIR}/library/xml/codegen.pl OR NOT EXISTS ${dfhac
5858
endif()
5959

6060
# set up versioning.
61-
set(DF_VERSION "0.40.13")
62-
SET(DFHACK_RELEASE "r1" CACHE STRING "Current release revision.")
61+
set(DF_VERSION "0.40.14")
62+
SET(DFHACK_RELEASE "r0" CACHE STRING "Current release revision.")
6363

6464
set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")
6565
add_definitions(-DDFHACK_VERSION="${DFHACK_VERSION}")

library/modules/Units.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ void Units::CopyCreature(df::unit * source, t_unit & furball)
154154
// profession
155155
furball.profession = source->profession;
156156
// happiness
157-
furball.happiness = source->status.happiness;
157+
furball.happiness = 100;//source->status.happiness;
158158
// physical attributes
159159
memcpy(&furball.strength, source->body.physical_attrs, sizeof(source->body.physical_attrs));
160160

plugins/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ if (BUILD_SUPPORTED)
110110
DFHACK_PLUGIN(digFlood digFlood.cpp)
111111
add_subdirectory(diggingInvaders)
112112
DFHACK_PLUGIN(drybuckets drybuckets.cpp)
113-
DFHACK_PLUGIN(dwarfmonitor dwarfmonitor.cpp)
113+
#DFHACK_PLUGIN(dwarfmonitor dwarfmonitor.cpp)
114114
DFHACK_PLUGIN(embark-tools embark-tools.cpp)
115115
DFHACK_PLUGIN(eventful eventful.cpp LINK_LIBRARIES lua)
116116
DFHACK_PLUGIN(fastdwarf fastdwarf.cpp)
@@ -132,7 +132,7 @@ if (BUILD_SUPPORTED)
132132
DFHACK_PLUGIN(liquids liquids.cpp Brushes.h LINK_LIBRARIES lua)
133133
DFHACK_PLUGIN(manipulator manipulator.cpp)
134134
DFHACK_PLUGIN(mode mode.cpp)
135-
DFHACK_PLUGIN(misery misery.cpp)
135+
#DFHACK_PLUGIN(misery misery.cpp)
136136
DFHACK_PLUGIN(mousequery mousequery.cpp)
137137
DFHACK_PLUGIN(petcapRemover petcapRemover.cpp)
138138
DFHACK_PLUGIN(plants plants.cpp)

plugins/autolabor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ static void assign_labor(unit_labor::unit_labor labor,
819819

820820
// bias by happiness
821821

822-
value += dwarfs[dwarf]->status.happiness;
822+
//value += dwarfs[dwarf]->status.happiness;
823823

824824
values[dwarf] = value;
825825

plugins/manipulator.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,11 @@ bool sortBySquad (const UnitInfo *d1, const UnitInfo *d2)
313313

314314
bool sortByHappiness (const UnitInfo *d1, const UnitInfo *d2)
315315
{
316-
if (descending)
316+
return sortByName(d1, d2);
317+
/*if (descending)
317318
return (d1->unit->status.happiness > d2->unit->status.happiness);
318319
else
319-
return (d1->unit->status.happiness < d2->unit->status.happiness);
320+
return (d1->unit->status.happiness < d2->unit->status.happiness);*/
320321
}
321322

322323
bool sortByArrival (const UnitInfo *d1, const UnitInfo *d2)
@@ -1043,7 +1044,7 @@ void viewscreen_unitlaborsst::render()
10431044
df::unit *unit = cur->unit;
10441045
int8_t fg = 15, bg = 0;
10451046

1046-
int happy = cur->unit->status.happiness;
1047+
int happy = 100;//cur->unit->status.happiness;
10471048
string happiness = stl_sprintf("%4i", happy);
10481049
if (happy == 0) // miserable
10491050
fg = 13; // 5:1

plugins/strangemood.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
631631
// If no mood type was specified, pick one randomly
632632
if (type == mood_type::None)
633633
{
634-
if (rng.df_trandom(100) > unit->status.happiness)
634+
if (rng.df_trandom(100) > 90)//rng.df_trandom(100) > unit->status.happiness)
635635
{
636636
switch (rng.df_trandom(2))
637637
{
@@ -691,7 +691,7 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
691691
unit->relations.mood_copy = unit->mood;
692692
Gui::showAutoAnnouncement(announcement_type::STRANGE_MOOD, unit->pos, msg, color, bright);
693693

694-
unit->status.happiness = 100;
694+
//unit->status.happiness = 100;
695695
// TODO: make sure unit drops any wrestle items
696696
unit->job.mood_timeout = 50000;
697697
unit->flags1.bits.has_mood = true;

scripts/devel/find-offsets.lua

Lines changed: 32 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,15 +131,24 @@ local function zoomed_searcher(startn, end_or_sz)
131131
end
132132

133133
local finder_searches = {}
134-
local function exec_finder(finder, names)
134+
local function exec_finder(finder, names, validators)
135135
if type(names) ~= 'table' then
136136
names = { names }
137137
end
138+
if type(validators) ~= 'table' then
139+
validators = { validators }
140+
end
138141
local search = force_scan['all']
139-
for _,v in ipairs(names) do
142+
for k,v in ipairs(names) do
140143
if force_scan[v] or not is_known(v) then
141144
table.insert(finder_searches, v)
142145
search = true
146+
elseif validators[k] then
147+
if not validators[k](df.global[v]) then
148+
dfhack.printerr('Validation failed for '..v..', will try to find again')
149+
table.insert(finder_searches, v)
150+
search = true
151+
end
143152
end
144153
end
145154
if search then
@@ -505,6 +514,7 @@ end
505514

506515
local function is_valid_world(world)
507516
if not ms.is_valid_vector(world.units.all, 4)
517+
or not ms.is_valid_vector(world.units.active, 4)
508518
or not ms.is_valid_vector(world.units.bad, 4)
509519
or not ms.is_valid_vector(world.history.figures, 4)
510520
or not ms.is_valid_vector(world.features.map_features, 4)
@@ -776,11 +786,6 @@ end
776786
--
777787

778788
local function find_current_weather()
779-
print('\nPlease load the save previously processed with prepare-save.')
780-
if not utils.prompt_yes_no('Proceed?', true) then
781-
return
782-
end
783-
784789
local zone
785790
if os_type == 'windows' then
786791
zone = zoomed_searcher('crime_next_id', 512)
@@ -839,7 +844,14 @@ local function find_ui_selected_unit()
839844
end
840845

841846
for i,unit in ipairs(df.global.world.units.active) do
842-
dfhack.units.setNickname(unit, i)
847+
-- This function does a lot of things and accesses histfigs, souls and so on:
848+
--dfhack.units.setNickname(unit, i)
849+
850+
-- Instead use just a simple bit of code that only requires the start of the
851+
-- unit to be valid. It may not work properly with vampires or reset later
852+
-- if unpaused, but is sufficient for this script and won't crash:
853+
unit.name.nickname = tostring(i)
854+
unit.name.has_name = true
843855
end
844856

845857
local addr = searcher:find_menu_cursor([[
@@ -1506,17 +1518,23 @@ print('\nInitial globals (need title screen):\n')
15061518
exec_finder(find_gview, 'gview')
15071519
exec_finder(find_cursor, { 'cursor', 'selection_rect', 'gamemode', 'gametype' })
15081520
exec_finder(find_announcements, 'announcements')
1509-
exec_finder(find_d_init, 'd_init')
1510-
exec_finder(find_enabler, 'enabler')
1511-
exec_finder(find_gps, 'gps')
1521+
exec_finder(find_d_init, 'd_init', is_valid_d_init)
1522+
exec_finder(find_enabler, 'enabler', is_valid_enabler)
1523+
exec_finder(find_gps, 'gps', is_valid_gps)
15121524

15131525
print('\nCompound globals (need loaded world):\n')
15141526

1515-
exec_finder(find_world, 'world')
1516-
exec_finder(find_ui, 'ui')
1527+
print('\nPlease load the save previously processed with prepare-save.')
1528+
if not utils.prompt_yes_no('Proceed?', true) then
1529+
searcher:reset()
1530+
return
1531+
end
1532+
1533+
exec_finder(find_world, 'world', is_valid_world)
1534+
exec_finder(find_ui, 'ui', is_valid_ui)
15171535
exec_finder(find_ui_sidebar_menus, 'ui_sidebar_menus')
15181536
exec_finder(find_ui_build_selector, 'ui_build_selector')
1519-
exec_finder(find_init, 'init')
1537+
exec_finder(find_init, 'init', is_valid_init)
15201538

15211539
print('\nPrimitive globals:\n')
15221540

0 commit comments

Comments
 (0)