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

develop
lethosor 2015-12-19 10:58:38 -05:00
commit 15d3815f26
1 changed files with 28 additions and 7 deletions

@ -26,6 +26,9 @@
#include "df/entity_raw.h"
#include "df/builtin_mats.h"
#include "df/general_ref_unit_workerst.h"
#include "df/creature_raw.h"
#include "df/caste_raw.h"
#include "df/caste_raw_flags.h"
using std::string;
using std::vector;
@ -46,6 +49,17 @@ using df::global::debug_nomoods;
Random::MersenneRNG rng;
static bool casteFlagSet(int race, int caste, df::caste_raw_flags flag)
{
auto creature = df::creature_raw::find(race);
if (!creature)
return false;
auto craw = vector_get(creature->caste, caste);
if (!craw)
return false;
return craw->flags.is_set(flag);
}
bool isUnitMoodable (df::unit *unit)
{
if (!Units::isCitizen(unit))
@ -56,6 +70,8 @@ bool isUnitMoodable (df::unit *unit)
return false;
if (!ENUM_ATTR(profession,moodable,unit->profession))
return false;
if (!casteFlagSet(unit->race, unit->caste, caste_raw_flags::STRANGE_MOODS))
return false;
return true;
}
@ -104,11 +120,11 @@ df::job_skill getMoodSkill (df::unit *unit)
}
if (!skills.size() && civ)
{
if (civ->entity_raw->jobs.permitted_job[profession::WOODCRAFTER])
if (civ->resources.permitted_skill[job_skill::WOODCRAFT])
skills.push_back(job_skill::WOODCRAFT);
if (civ->entity_raw->jobs.permitted_job[profession::STONECRAFTER])
if (civ->resources.permitted_skill[job_skill::STONECRAFT])
skills.push_back(job_skill::STONECRAFT);
if (civ->entity_raw->jobs.permitted_job[profession::BONE_CARVER])
if (civ->resources.permitted_skill[job_skill::BONECARVE])
skills.push_back(job_skill::BONECARVE);
}
if (!skills.size())
@ -728,6 +744,8 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
case job_skill::WOODCRAFT:
case job_skill::STONECRAFT:
case job_skill::BONECARVE:
case job_skill::PAPERMAKING: // These aren't actually moodable skills
case job_skill::BOOKBINDING: // but the game still checks for them anyways
job->job_type = job_type::StrangeMoodCrafter;
break;
case job_skill::TANNER:
@ -861,6 +879,8 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
case job_skill::CARPENTRY:
case job_skill::WOODCRAFT:
case job_skill::BOWYER:
case job_skill::PAPERMAKING:
case job_skill::BOOKBINDING:
job->job_items.push_back(item = new df::job_item());
item->item_type = item_type::WOOD;
item->quantity = base_item_count;
@ -960,6 +980,7 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
case job_skill::FORGE_WEAPON:
case job_skill::FORGE_ARMOR:
// there are actually 2 distinct cases here, but they're identical
case job_skill::FORGE_FURNITURE:
case job_skill::METALCRAFT:
filter = NULL;
@ -990,7 +1011,7 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
item->item_type = item_type::BAR;
item->mat_type = filter->getMaterial();
item->mat_index = filter->getMaterialIndex();
item->quantity = base_item_count * 150;
item->quantity = base_item_count * 150; // BUGFIX - the game does not adjust here!
item->min_dimension = 150;
}
else
@ -1012,7 +1033,7 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
}
if (mats.size())
item->mat_index = mats[rng.df_trandom(mats.size())];
item->quantity = base_item_count * 150;
item->quantity = base_item_count * 150; // BUGFIX - the game does not adjust here!
item->min_dimension = 150;
}
break;
@ -1264,12 +1285,12 @@ command_result df_strangemood (color_ostream &out, vector <string> & parameters)
item->quantity = 1;
if (item_type == item_type::BAR)
{
item->quantity *= 150;
item->quantity *= 150; // BUGFIX - the game does not adjust here!
item->min_dimension = 150;
}
if (item_type == item_type::CLOTH)
{
item->quantity *= 10000;
item->quantity *= 10000; // BUGFIX - the game does not adjust here!
item->min_dimension = 10000;
}
}