From 2484f89542cf0b969d0dd056a1f91a0cfd9aac17 Mon Sep 17 00:00:00 2001 From: lethosor Date: Sat, 8 Nov 2014 14:54:28 -0500 Subject: [PATCH] Update dwarfmonitor's happiness display --- plugins/CMakeLists.txt | 2 +- plugins/dwarfmonitor.cpp | 34 +++++++++++++++++----------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index bdf8d1402..ec25367d1 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -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) diff --git a/plugins/dwarfmonitor.cpp b/plugins/dwarfmonitor.cpp index e443f9f0e..74884a09d 100644 --- a/plugins/dwarfmonitor.cpp +++ b/plugins/dwarfmonitor.cpp @@ -71,7 +71,7 @@ static map> work_history; static int misery[] = { 0, 0, 0, 0, 0, 0, 0 }; static bool misery_upto_date = false; -static color_value monitor_colors[] = +static color_value monitor_colors[] = { COLOR_LIGHTRED, COLOR_RED, @@ -84,20 +84,20 @@ static color_value monitor_colors[] = static int get_happiness_cat(df::unit *unit) { - int happy = unit->status.happiness; - if (happy == 0) // miserable + int stress = unit->status.current_soul->personality.stress_level; + if (stress >= 500000) return 0; - else if (happy <= 25) // very unhappy + else if (stress >= 250000) return 1; - else if (happy <= 50) // unhappy + else if (stress >= 100000) return 2; - else if (happy <= 75) // fine + else if (stress >= 60000) return 3; - else if (happy <= 125) // quite content + else if (stress >= 30000) return 4; - else if (happy <= 150) // happy + else if (stress >= 0) return 5; - else // ecstatic + else return 6; } @@ -688,7 +688,7 @@ public: case job_type::FertilizeField: real_activity = JOB_AGRICULTURE; break; - + case job_type::ButcherAnimal: case job_type::PrepareRawFish: case job_type::MillPlants: @@ -913,7 +913,7 @@ public: populateDwarfColumn(); populateCategoryBreakdownColumn(); } - + return; } @@ -1015,7 +1015,7 @@ private: map> dwarf_activity_values; size_t fort_activity_count; size_t window_days; - + vector listed_activities; void validateColumn() @@ -1227,7 +1227,7 @@ public: if (!unit->status.current_soul) continue; - for (auto it = unit->status.current_soul->preferences.begin(); + for (auto it = unit->status.current_soul->preferences.begin(); it != unit->status.current_soul->preferences.end(); it++) { @@ -1639,7 +1639,7 @@ static void update_dwarf_stats(bool is_paused) add_work_history(unit, JOB_LEISURE); continue; } - + add_work_history(unit, unit->job.current_job->job_type); } } @@ -1654,7 +1654,7 @@ DFhackCExport command_result plugin_onupdate (color_ostream &out) return CR_OK; static decltype(world->frame_counter) last_frame_count = 0; - + bool is_paused = DFHack::World::ReadPauseState(); if (is_paused) { @@ -1841,11 +1841,11 @@ DFhackCExport command_result plugin_init(color_ostream &out, std::vector \n" " Start monitoring \n" " can be \"work\", \"misery\", or \"all\"\n"