Merge remote-tracking branch 'quietust/develop' into develop

Conflicts:
	plugins/manipulator.cpp
develop
expwnent 2014-11-02 04:05:51 -05:00
commit 87443035a9
11 changed files with 84 additions and 61 deletions

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

@ -119,7 +119,7 @@ function isValidTarget(unit,syndrome)
end end
for caste,creature in ipairs(syndrome.syn_affected_creature) do for caste,creature in ipairs(syndrome.syn_affected_creature) do
local affectedCreature = creature.value local affectedCreature = creature.value
local affectedCaste = syndrome.syn_affectedCaste[caste].value local affectedCaste = syndrome.syn_affected_caste[caste].value
if affectedCreature == unitRaceName and (affectedCaste == unitCasteName or affectedCaste == "ALL") then if affectedCreature == unitRaceName and (affectedCaste == unitCasteName or affectedCaste == "ALL") then
affected = true affected = true
end end

@ -154,7 +154,7 @@ void Units::CopyCreature(df::unit * source, t_unit & furball)
// profession // profession
furball.profession = source->profession; furball.profession = source->profession;
// happiness // happiness
furball.happiness = source->status.happiness; furball.happiness = 100;//source->status.happiness;
// physical attributes // physical attributes
memcpy(&furball.strength, source->body.physical_attrs, sizeof(source->body.physical_attrs)); 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) DFHACK_PLUGIN(digFlood digFlood.cpp)
add_subdirectory(diggingInvaders) add_subdirectory(diggingInvaders)
DFHACK_PLUGIN(drybuckets drybuckets.cpp) DFHACK_PLUGIN(drybuckets drybuckets.cpp)
DFHACK_PLUGIN(dwarfmonitor dwarfmonitor.cpp) #DFHACK_PLUGIN(dwarfmonitor dwarfmonitor.cpp)
DFHACK_PLUGIN(embark-tools embark-tools.cpp) DFHACK_PLUGIN(embark-tools embark-tools.cpp)
DFHACK_PLUGIN(eventful eventful.cpp LINK_LIBRARIES lua) DFHACK_PLUGIN(eventful eventful.cpp LINK_LIBRARIES lua)
DFHACK_PLUGIN(fastdwarf fastdwarf.cpp) DFHACK_PLUGIN(fastdwarf fastdwarf.cpp)
@ -132,7 +132,7 @@ if (BUILD_SUPPORTED)
DFHACK_PLUGIN(liquids liquids.cpp Brushes.h LINK_LIBRARIES lua) DFHACK_PLUGIN(liquids liquids.cpp Brushes.h LINK_LIBRARIES lua)
DFHACK_PLUGIN(manipulator manipulator.cpp) DFHACK_PLUGIN(manipulator manipulator.cpp)
DFHACK_PLUGIN(mode mode.cpp) DFHACK_PLUGIN(mode mode.cpp)
DFHACK_PLUGIN(misery misery.cpp) #DFHACK_PLUGIN(misery misery.cpp)
DFHACK_PLUGIN(mousequery mousequery.cpp) DFHACK_PLUGIN(mousequery mousequery.cpp)
DFHACK_PLUGIN(petcapRemover petcapRemover.cpp) DFHACK_PLUGIN(petcapRemover petcapRemover.cpp)
DFHACK_PLUGIN(plants plants.cpp) DFHACK_PLUGIN(plants plants.cpp)

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

@ -270,7 +270,7 @@ struct UnitInfo
enum altsort_mode { enum altsort_mode {
ALTSORT_NAME, ALTSORT_NAME,
ALTSORT_PROFESSION_OR_SQUAD, ALTSORT_PROFESSION_OR_SQUAD,
ALTSORT_HAPPINESS, ALTSORT_STRESS,
ALTSORT_ARRIVAL, ALTSORT_ARRIVAL,
ALTSORT_MAX ALTSORT_MAX
}; };
@ -311,12 +311,17 @@ bool sortBySquad (const UnitInfo *d1, const UnitInfo *d2)
return descending ? gt : !gt; return descending ? gt : !gt;
} }
bool sortByHappiness (const UnitInfo *d1, const UnitInfo *d2) bool sortByStress (const UnitInfo *d1, const UnitInfo *d2)
{ {
if (!d1->unit->status.current_soul)
return !descending;
if (!d2->unit->status.current_soul)
return descending;
if (descending) if (descending)
return (d1->unit->status.happiness > d2->unit->status.happiness); return (d1->unit->status.current_soul->personality.stress_level > d2->unit->status.current_soul->personality.stress_level);
else else
return (d1->unit->status.happiness < d2->unit->status.happiness); return (d1->unit->status.current_soul->personality.stress_level < d2->unit->status.current_soul->personality.stress_level);
} }
bool sortByArrival (const UnitInfo *d1, const UnitInfo *d2) bool sortByArrival (const UnitInfo *d1, const UnitInfo *d2)
@ -367,7 +372,7 @@ bool sortBySkill (const UnitInfo *d1, const UnitInfo *d2)
} }
enum display_columns { enum display_columns {
DISP_COLUMN_HAPPINESS, DISP_COLUMN_STRESS,
DISP_COLUMN_NAME, DISP_COLUMN_NAME,
DISP_COLUMN_PROFESSION_OR_SQUAD, DISP_COLUMN_PROFESSION_OR_SQUAD,
DISP_COLUMN_LABORS, DISP_COLUMN_LABORS,
@ -509,13 +514,13 @@ void viewscreen_unitlaborsst::calcSize()
// min/max width of columns // min/max width of columns
int col_minwidth[DISP_COLUMN_MAX]; int col_minwidth[DISP_COLUMN_MAX];
int col_maxwidth[DISP_COLUMN_MAX]; int col_maxwidth[DISP_COLUMN_MAX];
col_minwidth[DISP_COLUMN_HAPPINESS] = 4; col_minwidth[DISP_COLUMN_STRESS] = 6;
col_maxwidth[DISP_COLUMN_HAPPINESS] = 4; col_maxwidth[DISP_COLUMN_STRESS] = 6;
col_minwidth[DISP_COLUMN_NAME] = 16; col_minwidth[DISP_COLUMN_NAME] = 16;
col_maxwidth[DISP_COLUMN_NAME] = 16; // adjusted in the loop below col_maxwidth[DISP_COLUMN_NAME] = 16; // adjusted in the loop below
col_minwidth[DISP_COLUMN_PROFESSION_OR_SQUAD] = 10; col_minwidth[DISP_COLUMN_PROFESSION_OR_SQUAD] = 10;
col_maxwidth[DISP_COLUMN_PROFESSION_OR_SQUAD] = 10; // adjusted in the loop below col_maxwidth[DISP_COLUMN_PROFESSION_OR_SQUAD] = 10; // adjusted in the loop below
col_minwidth[DISP_COLUMN_LABORS] = num_columns*3/5; // 60% col_minwidth[DISP_COLUMN_LABORS] = 1;
col_maxwidth[DISP_COLUMN_LABORS] = NUM_COLUMNS; col_maxwidth[DISP_COLUMN_LABORS] = NUM_COLUMNS;
// get max_name/max_prof from strings length // get max_name/max_prof from strings length
@ -778,10 +783,10 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
switch (click_header) switch (click_header)
{ {
case DISP_COLUMN_HAPPINESS: case DISP_COLUMN_STRESS:
if (enabler->mouse_lbut || enabler->mouse_rbut) if (enabler->mouse_lbut || enabler->mouse_rbut)
{ {
input_sort = ALTSORT_HAPPINESS; input_sort = ALTSORT_STRESS;
if (enabler->mouse_lbut) if (enabler->mouse_lbut)
events->insert(interface_key::SECONDSCROLL_PAGEUP); events->insert(interface_key::SECONDSCROLL_PAGEUP);
if (enabler->mouse_rbut) if (enabler->mouse_rbut)
@ -825,7 +830,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
switch (click_body) switch (click_body)
{ {
case DISP_COLUMN_HAPPINESS: case DISP_COLUMN_STRESS:
// do nothing // do nothing
break; break;
@ -931,8 +936,8 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
case ALTSORT_PROFESSION_OR_SQUAD: case ALTSORT_PROFESSION_OR_SQUAD:
std::stable_sort(units.begin(), units.end(), show_squad ? sortBySquad : sortByProfession); std::stable_sort(units.begin(), units.end(), show_squad ? sortBySquad : sortByProfession);
break; break;
case ALTSORT_HAPPINESS: case ALTSORT_STRESS:
std::stable_sort(units.begin(), units.end(), sortByHappiness); std::stable_sort(units.begin(), units.end(), sortByStress);
break; break;
case ALTSORT_ARRIVAL: case ALTSORT_ARRIVAL:
std::stable_sort(units.begin(), units.end(), sortByArrival); std::stable_sort(units.begin(), units.end(), sortByArrival);
@ -947,9 +952,9 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
altsort = ALTSORT_PROFESSION_OR_SQUAD; altsort = ALTSORT_PROFESSION_OR_SQUAD;
break; break;
case ALTSORT_PROFESSION_OR_SQUAD: case ALTSORT_PROFESSION_OR_SQUAD:
altsort = ALTSORT_HAPPINESS; altsort = ALTSORT_STRESS;
break; break;
case ALTSORT_HAPPINESS: case ALTSORT_STRESS:
altsort = ALTSORT_ARRIVAL; altsort = ALTSORT_ARRIVAL;
break; break;
case ALTSORT_ARRIVAL: case ALTSORT_ARRIVAL:
@ -1000,7 +1005,7 @@ void viewscreen_unitlaborsst::render()
Screen::clear(); Screen::clear();
Screen::drawBorder(" Dwarf Manipulator - Manage Labors "); Screen::drawBorder(" Dwarf Manipulator - Manage Labors ");
Screen::paintString(Screen::Pen(' ', 7, 0), col_offsets[DISP_COLUMN_HAPPINESS], 2, "Hap."); Screen::paintString(Screen::Pen(' ', 7, 0), col_offsets[DISP_COLUMN_STRESS], 2, "Stress");
Screen::paintString(Screen::Pen(' ', 7, 0), col_offsets[DISP_COLUMN_NAME], 2, "Name"); Screen::paintString(Screen::Pen(' ', 7, 0), col_offsets[DISP_COLUMN_NAME], 2, "Name");
Screen::paintString(Screen::Pen(' ', 7, 0), col_offsets[DISP_COLUMN_PROFESSION_OR_SQUAD], 2, show_squad ? "Squad" : "Profession"); Screen::paintString(Screen::Pen(' ', 7, 0), col_offsets[DISP_COLUMN_PROFESSION_OR_SQUAD], 2, show_squad ? "Squad" : "Profession");
@ -1043,23 +1048,22 @@ void viewscreen_unitlaborsst::render()
df::unit *unit = cur->unit; df::unit *unit = cur->unit;
int8_t fg = 15, bg = 0; int8_t fg = 15, bg = 0;
int happy = cur->unit->status.happiness; int stress_lvl = unit->status.current_soul ? unit->status.current_soul->personality.stress_level : 0;
string happiness = stl_sprintf("%4i", happy); // cap at 6 digits
if (happy == 0) // miserable if (stress_lvl < -99999) stress_lvl = -99999;
if (stress_lvl > 999999) stress_lvl = 999999;
string stress = stl_sprintf("%6i", stress_lvl);
if (stress_lvl >= 500000)
fg = 13; // 5:1 fg = 13; // 5:1
else if (happy <= 25) // very unhappy else if (stress_lvl >= 250000)
fg = 12; // 4:1 fg = 12; // 4:1
else if (happy <= 50) // unhappy else if (stress_lvl >= 100000)
fg = 4; // 4:0
else if (happy < 75) // fine
fg = 14; // 6:1 fg = 14; // 6:1
else if (happy < 125) // quite content else if (stress_lvl >= 0)
fg = 6; // 6:0
else if (happy < 150) // happy
fg = 2; // 2:0 fg = 2; // 2:0
else // ecstatic else
fg = 10; // 2:1 fg = 10; // 2:1
Screen::paintString(Screen::Pen(' ', fg, bg), col_offsets[DISP_COLUMN_HAPPINESS], 4 + row, happiness); Screen::paintString(Screen::Pen(' ', fg, bg), col_offsets[DISP_COLUMN_STRESS], 4 + row, stress);
fg = 15; fg = 15;
if (row_offset == sel_row) if (row_offset == sel_row)
@ -1232,8 +1236,8 @@ void viewscreen_unitlaborsst::render()
case ALTSORT_PROFESSION_OR_SQUAD: case ALTSORT_PROFESSION_OR_SQUAD:
OutputString(15, x, y, show_squad ? "Squad" : "Profession"); OutputString(15, x, y, show_squad ? "Squad" : "Profession");
break; break;
case ALTSORT_HAPPINESS: case ALTSORT_STRESS:
OutputString(15, x, y, "Happiness"); OutputString(15, x, y, "Stress Level");
break; break;
case ALTSORT_ARRIVAL: case ALTSORT_ARRIVAL:
OutputString(15, x, y, "Arrival"); OutputString(15, x, y, "Arrival");

@ -631,7 +631,11 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
// If no mood type was specified, pick one randomly // If no mood type was specified, pick one randomly
if (type == mood_type::None) if (type == mood_type::None)
{ {
if (rng.df_trandom(100) > unit->status.happiness) if (soul && (
(soul->personality.stress_level >= 500000) ||
(soul->personality.stress_level >= 250000 && !rng.df_trandom(2)) ||
(soul->personality.stress_level >= 100000 && !rng.df_trandom(10))
))
{ {
switch (rng.df_trandom(2)) switch (rng.df_trandom(2))
{ {
@ -691,7 +695,6 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
unit->relations.mood_copy = unit->mood; unit->relations.mood_copy = unit->mood;
Gui::showAutoAnnouncement(announcement_type::STRANGE_MOOD, unit->pos, msg, color, bright); Gui::showAutoAnnouncement(announcement_type::STRANGE_MOOD, unit->pos, msg, color, bright);
unit->status.happiness = 100;
// TODO: make sure unit drops any wrestle items // TODO: make sure unit drops any wrestle items
unit->job.mood_timeout = 50000; unit->job.mood_timeout = 50000;
unit->flags1.bits.has_mood = true; unit->flags1.bits.has_mood = true;
@ -1144,7 +1147,7 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
{ {
if ((job->job_type == job_type::StrangeMoodBrooding) && (rng.df_trandom(2))) if ((job->job_type == job_type::StrangeMoodBrooding) && (rng.df_trandom(2)))
{ {
switch (rng.df_trandom(3)) switch (rng.df_trandom(2))
{ {
case 0: case 0:
job->job_items.push_back(item = new df::job_item()); job->job_items.push_back(item = new df::job_item());
@ -1159,10 +1162,6 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
item->flags2.bits.body_part = true; item->flags2.bits.body_part = true;
item->quantity = 1; item->quantity = 1;
break; break;
case 2:
// in older versions, they would request additional skulls
// in 0.34.11, the request becomes "nothing"
break;
} }
} }
else else

@ -765,6 +765,7 @@ struct military_assign_hook : df::viewscreen_layer_militaryst {
IMPLEMENT_VMETHOD_INTERPOSE(military_assign_hook, feed); IMPLEMENT_VMETHOD_INTERPOSE(military_assign_hook, feed);
IMPLEMENT_VMETHOD_INTERPOSE(military_assign_hook, render); IMPLEMENT_VMETHOD_INTERPOSE(military_assign_hook, render);
/*
// Unit updates are executed based on an action divisor variable, // Unit updates are executed based on an action divisor variable,
// which is computed from the alive unit count and has range 10-100. // which is computed from the alive unit count and has range 10-100.
static int adjust_unit_divisor(int value) { static int adjust_unit_divisor(int value) {
@ -943,6 +944,7 @@ struct military_training_ct_hook : df::activity_event_combat_trainingst {
} }
} }
}; };
*/
/* /*
IMPLEMENT_VMETHOD_INTERPOSE(military_training_ct_hook, process); IMPLEMENT_VMETHOD_INTERPOSE(military_training_ct_hook, process);

@ -131,15 +131,24 @@ local function zoomed_searcher(startn, end_or_sz)
end end
local finder_searches = {} local finder_searches = {}
local function exec_finder(finder, names) local function exec_finder(finder, names, validators)
if type(names) ~= 'table' then if type(names) ~= 'table' then
names = { names } names = { names }
end end
if type(validators) ~= 'table' then
validators = { validators }
end
local search = force_scan['all'] 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 if force_scan[v] or not is_known(v) then
table.insert(finder_searches, v) table.insert(finder_searches, v)
search = true 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
end end
if search then if search then
@ -505,6 +514,7 @@ end
local function is_valid_world(world) local function is_valid_world(world)
if not ms.is_valid_vector(world.units.all, 4) 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.units.bad, 4)
or not ms.is_valid_vector(world.history.figures, 4) or not ms.is_valid_vector(world.history.figures, 4)
or not ms.is_valid_vector(world.features.map_features, 4) or not ms.is_valid_vector(world.features.map_features, 4)
@ -776,11 +786,6 @@ end
-- --
local function find_current_weather() 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 local zone
if os_type == 'windows' then if os_type == 'windows' then
zone = zoomed_searcher('crime_next_id', 512) zone = zoomed_searcher('crime_next_id', 512)
@ -839,7 +844,14 @@ local function find_ui_selected_unit()
end end
for i,unit in ipairs(df.global.world.units.active) do 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 end
local addr = searcher:find_menu_cursor([[ 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_gview, 'gview')
exec_finder(find_cursor, { 'cursor', 'selection_rect', 'gamemode', 'gametype' }) exec_finder(find_cursor, { 'cursor', 'selection_rect', 'gamemode', 'gametype' })
exec_finder(find_announcements, 'announcements') exec_finder(find_announcements, 'announcements')
exec_finder(find_d_init, 'd_init') exec_finder(find_d_init, 'd_init', is_valid_d_init)
exec_finder(find_enabler, 'enabler') exec_finder(find_enabler, 'enabler', is_valid_enabler)
exec_finder(find_gps, 'gps') exec_finder(find_gps, 'gps', is_valid_gps)
print('\nCompound globals (need loaded world):\n') print('\nCompound globals (need loaded world):\n')
exec_finder(find_world, 'world') print('\nPlease load the save previously processed with prepare-save.')
exec_finder(find_ui, 'ui') 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_sidebar_menus, 'ui_sidebar_menus')
exec_finder(find_ui_build_selector, 'ui_build_selector') 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') print('\nPrimitive globals:\n')

@ -24,13 +24,13 @@ if args.help then
print this help message print this help message
repeat -cancel bob repeat -cancel bob
cancels the repetition with the name bob cancels the repetition with the name bob
repeat -name jim -time delay -timeUnits units -printResult true -command printArgs 3 1 2 repeat -name jim -time delay -timeUnits units -printResult true -command [ printArgs 3 1 2 ]
-name sets the name for the purposes of cancelling and making sure you don't schedule the same repeating event twice -name sets the name for the purposes of cancelling and making sure you don't schedule the same repeating event twice
if not specified, it's set to the first argument after -command if not specified, it's set to the first argument after -command
-time delay -timeUnits units -time delay -timeUnits units
delay is some positive integer delay is some positive integer
units is some valid time unit for dfhack.timeout(delay,timeUnits,function) units is some valid time unit for dfhack.timeout(delay,timeUnits,function)
-command ... -command [ ... ]
specify the command to be run specify the command to be run
]]) ]])
return return