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.
develop
Alexander Gavrilov 2014-10-26 16:40:39 +03:00
parent beebd624e7
commit 04ec2c9932
8 changed files with 45 additions and 26 deletions

@ -58,8 +58,8 @@ if (NOT EXISTS ${dfhack_SOURCE_DIR}/library/xml/codegen.pl OR NOT EXISTS ${dfhac
endif()
# set up versioning.
set(DF_VERSION "0.40.13")
SET(DFHACK_RELEASE "r1" CACHE STRING "Current release revision.")
set(DF_VERSION "0.40.14")
SET(DFHACK_RELEASE "r0" CACHE STRING "Current release revision.")
set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")
add_definitions(-DDFHACK_VERSION="${DFHACK_VERSION}")

@ -154,7 +154,7 @@ void Units::CopyCreature(df::unit * source, t_unit & furball)
// profession
furball.profession = source->profession;
// happiness
furball.happiness = source->status.happiness;
furball.happiness = 100;//source->status.happiness;
// physical attributes
memcpy(&furball.strength, source->body.physical_attrs, sizeof(source->body.physical_attrs));

@ -1 +1 @@
Subproject commit aed9a7644cd1d4a599c10d5f579fc742ced6bc3f
Subproject commit 62dcffa67998643966267763526b82bd7674b583

@ -110,7 +110,7 @@ if (BUILD_SUPPORTED)
DFHACK_PLUGIN(digFlood digFlood.cpp)
add_subdirectory(diggingInvaders)
DFHACK_PLUGIN(drybuckets drybuckets.cpp)
DFHACK_PLUGIN(dwarfmonitor dwarfmonitor.cpp)
#DFHACK_PLUGIN(dwarfmonitor dwarfmonitor.cpp)
DFHACK_PLUGIN(embark-tools embark-tools.cpp)
DFHACK_PLUGIN(eventful eventful.cpp LINK_LIBRARIES lua)
DFHACK_PLUGIN(fastdwarf fastdwarf.cpp)
@ -132,7 +132,7 @@ if (BUILD_SUPPORTED)
DFHACK_PLUGIN(liquids liquids.cpp Brushes.h LINK_LIBRARIES lua)
DFHACK_PLUGIN(manipulator manipulator.cpp)
DFHACK_PLUGIN(mode mode.cpp)
DFHACK_PLUGIN(misery misery.cpp)
#DFHACK_PLUGIN(misery misery.cpp)
DFHACK_PLUGIN(mousequery mousequery.cpp)
DFHACK_PLUGIN(petcapRemover petcapRemover.cpp)
DFHACK_PLUGIN(plants plants.cpp)

@ -819,7 +819,7 @@ static void assign_labor(unit_labor::unit_labor labor,
// bias by happiness
value += dwarfs[dwarf]->status.happiness;
//value += dwarfs[dwarf]->status.happiness;
values[dwarf] = value;

@ -313,10 +313,11 @@ bool sortBySquad (const UnitInfo *d1, const UnitInfo *d2)
bool sortByHappiness (const UnitInfo *d1, const UnitInfo *d2)
{
if (descending)
return sortByName(d1, d2);
/*if (descending)
return (d1->unit->status.happiness > d2->unit->status.happiness);
else
return (d1->unit->status.happiness < d2->unit->status.happiness);
return (d1->unit->status.happiness < d2->unit->status.happiness);*/
}
bool sortByArrival (const UnitInfo *d1, const UnitInfo *d2)
@ -1043,7 +1044,7 @@ void viewscreen_unitlaborsst::render()
df::unit *unit = cur->unit;
int8_t fg = 15, bg = 0;
int happy = cur->unit->status.happiness;
int happy = 100;//cur->unit->status.happiness;
string happiness = stl_sprintf("%4i", happy);
if (happy == 0) // miserable
fg = 13; // 5:1

@ -631,7 +631,7 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
// If no mood type was specified, pick one randomly
if (type == mood_type::None)
{
if (rng.df_trandom(100) > unit->status.happiness)
if (rng.df_trandom(100) > 90)//rng.df_trandom(100) > unit->status.happiness)
{
switch (rng.df_trandom(2))
{
@ -691,7 +691,7 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
unit->relations.mood_copy = unit->mood;
Gui::showAutoAnnouncement(announcement_type::STRANGE_MOOD, unit->pos, msg, color, bright);
unit->status.happiness = 100;
//unit->status.happiness = 100;
// TODO: make sure unit drops any wrestle items
unit->job.mood_timeout = 50000;
unit->flags1.bits.has_mood = true;

@ -131,15 +131,24 @@ local function zoomed_searcher(startn, end_or_sz)
end
local finder_searches = {}
local function exec_finder(finder, names)
local function exec_finder(finder, names, validators)
if type(names) ~= 'table' then
names = { names }
end
if type(validators) ~= 'table' then
validators = { validators }
end
local search = force_scan['all']
for _,v in ipairs(names) do
for k,v in ipairs(names) do
if force_scan[v] or not is_known(v) then
table.insert(finder_searches, v)
search = true
elseif validators[k] then
if not validators[k](df.global[v]) then
dfhack.printerr('Validation failed for '..v..', will try to find again')
table.insert(finder_searches, v)
search = true
end
end
end
if search then
@ -505,6 +514,7 @@ end
local function is_valid_world(world)
if not ms.is_valid_vector(world.units.all, 4)
or not ms.is_valid_vector(world.units.active, 4)
or not ms.is_valid_vector(world.units.bad, 4)
or not ms.is_valid_vector(world.history.figures, 4)
or not ms.is_valid_vector(world.features.map_features, 4)
@ -776,11 +786,6 @@ end
--
local function find_current_weather()
print('\nPlease load the save previously processed with prepare-save.')
if not utils.prompt_yes_no('Proceed?', true) then
return
end
local zone
if os_type == 'windows' then
zone = zoomed_searcher('crime_next_id', 512)
@ -839,7 +844,14 @@ local function find_ui_selected_unit()
end
for i,unit in ipairs(df.global.world.units.active) do
dfhack.units.setNickname(unit, i)
-- This function does a lot of things and accesses histfigs, souls and so on:
--dfhack.units.setNickname(unit, i)
-- Instead use just a simple bit of code that only requires the start of the
-- unit to be valid. It may not work properly with vampires or reset later
-- if unpaused, but is sufficient for this script and won't crash:
unit.name.nickname = tostring(i)
unit.name.has_name = true
end
local addr = searcher:find_menu_cursor([[
@ -1506,17 +1518,23 @@ print('\nInitial globals (need title screen):\n')
exec_finder(find_gview, 'gview')
exec_finder(find_cursor, { 'cursor', 'selection_rect', 'gamemode', 'gametype' })
exec_finder(find_announcements, 'announcements')
exec_finder(find_d_init, 'd_init')
exec_finder(find_enabler, 'enabler')
exec_finder(find_gps, 'gps')
exec_finder(find_d_init, 'd_init', is_valid_d_init)
exec_finder(find_enabler, 'enabler', is_valid_enabler)
exec_finder(find_gps, 'gps', is_valid_gps)
print('\nCompound globals (need loaded world):\n')
exec_finder(find_world, 'world')
exec_finder(find_ui, 'ui')
print('\nPlease load the save previously processed with prepare-save.')
if not utils.prompt_yes_no('Proceed?', true) then
searcher:reset()
return
end
exec_finder(find_world, 'world', is_valid_world)
exec_finder(find_ui, 'ui', is_valid_ui)
exec_finder(find_ui_sidebar_menus, 'ui_sidebar_menus')
exec_finder(find_ui_build_selector, 'ui_build_selector')
exec_finder(find_init, 'init')
exec_finder(find_init, 'init', is_valid_init)
print('\nPrimitive globals:\n')