Update Manipulator to respect entity permitted_labor settings

This has the effect of locking out the Alchemy labor, which is how it's
supposed to work in-game (but doesn't due to bug #6511)
develop
Quietust 2014-06-24 08:36:36 -05:00
parent 14697174fc
commit 9625d56384
1 changed files with 18 additions and 6 deletions

@ -26,6 +26,8 @@
#include "df/creature_graphics_role.h"
#include "df/creature_raw.h"
#include "df/caste_raw.h"
#include "df/historical_entity.h"
#include "df/entity_raw.h"
using std::set;
using std::vector;
@ -82,6 +84,14 @@ struct SkillColumn
df::job_skill skill; // displayed rating
char label[3]; // column header
bool special; // specified labor is mutually exclusive with all other special labors
bool isValidLabor (df::historical_entity *entity = NULL) const
{
if (labor == unit_labor::NONE)
return false;
if (entity && entity->entity_raw && !entity->entity_raw->jobs.permitted_labor[labor])
return false;
return true;
}
};
#define NUM_COLUMNS (sizeof(columns) / sizeof(SkillColumn))
@ -851,7 +861,7 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
}
UnitInfo *cur = units[input_row];
if (events->count(interface_key::SELECT) && (cur->allowEdit) && (columns[input_column].labor != unit_labor::NONE))
if (events->count(interface_key::SELECT) && (cur->allowEdit) && columns[input_column].isValidLabor(ui->main.fortress_entity))
{
df::unit *unit = cur->unit;
const SkillColumn &col = columns[input_column];
@ -870,15 +880,17 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
}
unit->status.labors[col.labor] = newstatus;
}
if (events->count(interface_key::SELECT_ALL) && (cur->allowEdit))
if (events->count(interface_key::SELECT_ALL) && (cur->allowEdit) && columns[input_column].isValidLabor(ui->main.fortress_entity))
{
df::unit *unit = cur->unit;
const SkillColumn &col = columns[input_column];
bool newstatus = (col.labor == unit_labor::NONE) ? true : !unit->status.labors[col.labor];
bool newstatus = !unit->status.labors[col.labor];
for (int i = 0; i < NUM_COLUMNS; i++)
{
if (columns[i].group != col.group)
continue;
if (!columns[i].isValidLabor(ui->main.fortress_entity))
continue;
if (columns[i].special)
{
if (newstatus)
@ -1175,7 +1187,7 @@ void viewscreen_unitlaborsst::render()
}
canToggle = (cur->allowEdit) && (columns[sel_column].labor != unit_labor::NONE);
canToggle = (cur->allowEdit) && columns[sel_column].isValidLabor(ui->main.fortress_entity);
}
int x = 2, y = dim.y - 3;