Fix fencepost error in autolabor/autohauler/labormanager.

https://github.com/DFHack/dfhack/pull/1253#pullrequestreview-110903215
develop
Ben Lubar 2018-04-10 13:29:00 -05:00
parent afc2c476bb
commit f9ad71f682
No known key found for this signature in database
GPG Key ID: 018BAB45DB2D2B24
3 changed files with 3 additions and 3 deletions

@ -624,7 +624,7 @@ static void init_state()
df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autohauler/labors/")).c_str()); df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autohauler/labors/")).c_str());
// Ensure that the labor is defined in the existing list // Ensure that the labor is defined in the existing list
if (labor >= 0 && size_t(labor) <= labor_infos.size()) if (labor >= 0 && size_t(labor) < labor_infos.size())
{ {
// Link the labor treatment with the associated persistent data item // Link the labor treatment with the associated persistent data item
labor_infos[labor].set_config(*p); labor_infos[labor].set_config(*p);

@ -606,7 +606,7 @@ static void init_state()
{ {
string key = p->key(); string key = p->key();
df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autolabor/labors/")).c_str()); df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("autolabor/labors/")).c_str());
if (labor >= 0 && size_t(labor) <= labor_infos.size()) if (labor >= 0 && size_t(labor) < labor_infos.size())
{ {
labor_infos[labor].config = *p; labor_infos[labor].config = *p;
labor_infos[labor].is_exclusive = default_labor_infos[labor].is_exclusive; labor_infos[labor].is_exclusive = default_labor_infos[labor].is_exclusive;

@ -614,7 +614,7 @@ static void init_state()
{ {
string key = p->key(); string key = p->key();
df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("labormanager/2.0/labors/")).c_str()); df::unit_labor labor = (df::unit_labor) atoi(key.substr(strlen("labormanager/2.0/labors/")).c_str());
if (labor >= 0 && size_t(labor) <= labor_infos.size()) if (labor >= 0 && size_t(labor) < labor_infos.size())
{ {
labor_infos[labor].config = *p; labor_infos[labor].config = *p;
labor_infos[labor].active_dwarfs = 0; labor_infos[labor].active_dwarfs = 0;