Skip to content

Commit

Permalink
Update version to v0.40.14 and hack things so they compile.
Browse files Browse the repository at this point in the history
Also make the find-offsets script less likely to crash if the
unit structure is misaligned and add more integrity checks.
  • Loading branch information
angavrilov committed Oct 26, 2014
1 parent beebd62 commit 04ec2c9
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 26 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
2 changes: 1 addition & 1 deletion library/modules/Units.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down
2 changes: 1 addition & 1 deletion library/xml
4 changes: 2 additions & 2 deletions plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion plugins/autolabor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
7 changes: 4 additions & 3 deletions plugins/manipulator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions plugins/strangemood.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
{
Expand Down Expand Up @@ -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;
Expand Down
46 changes: 32 additions & 14 deletions scripts/devel/find-offsets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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([[
Expand Down Expand Up @@ -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')

Expand Down

0 comments on commit 04ec2c9

Please sign in to comment.