@@ -95,14 +95,6 @@ struct SkillColumn
9595 df::job_skill skill; // displayed rating
9696 char label[3 ]; // column header
9797 bool special; // specified labor is mutually exclusive with all other special labors
98- bool isValidLabor (df::historical_entity *entity = NULL ) const
99- {
100- if (labor == unit_labor::NONE )
101- return false ;
102- if (entity && entity->entity_raw && !entity->entity_raw ->jobs .permitted_labor [labor])
103- return false ;
104- return true ;
105- }
10698};
10799
108100#define NUM_COLUMNS (sizeof (columns) / sizeof (SkillColumn))
@@ -1631,9 +1623,10 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
16311623 }
16321624
16331625 UnitInfo *cur = units[input_row];
1634- if (events->count (interface_key::SELECT ) && (cur->allowEdit ) && columns[input_column].isValidLabor (ui->main .fortress_entity ))
1626+ df::unit *unit = cur->unit ;
1627+ df::unit_labor cur_labor = columns[input_column].labor ;
1628+ if (events->count (interface_key::SELECT ) && (cur->allowEdit ) && Units::isValidLabor (unit, cur_labor))
16351629 {
1636- df::unit *unit = cur->unit ;
16371630 const SkillColumn &col = columns[input_column];
16381631 bool newstatus = !unit->status .labors [col.labor ];
16391632 if (col.special )
@@ -1650,16 +1643,15 @@ void viewscreen_unitlaborsst::feed(set<df::interface_key> *events)
16501643 }
16511644 unit->status .labors [col.labor ] = newstatus;
16521645 }
1653- if (events->count (interface_key::SELECT_ALL ) && (cur->allowEdit ) && columns[input_column]. isValidLabor (ui-> main . fortress_entity ))
1646+ if (events->count (interface_key::SELECT_ALL ) && (cur->allowEdit ) && Units:: isValidLabor (unit, cur_labor ))
16541647 {
1655- df::unit *unit = cur->unit ;
16561648 const SkillColumn &col = columns[input_column];
16571649 bool newstatus = !unit->status .labors [col.labor ];
16581650 for (int i = 0 ; i < NUM_COLUMNS ; i++)
16591651 {
16601652 if (columns[i].group != col.group )
16611653 continue ;
1662- if (!columns[i].isValidLabor (ui-> main . fortress_entity ))
1654+ if (!Units::isValidLabor (unit, columns[i].labor ))
16631655 continue ;
16641656 if (columns[i].special )
16651657 {
@@ -2055,7 +2047,7 @@ void viewscreen_unitlaborsst::render()
20552047
20562048 }
20572049
2058- canToggle = (cur->allowEdit ) && columns[sel_column].isValidLabor (ui-> main . fortress_entity );
2050+ canToggle = (cur->allowEdit ) && Units::isValidLabor (unit, columns[sel_column].labor );
20592051 }
20602052
20612053 int x = 2 , y = dim.y - 4 ;
0 commit comments