Fix manipulator crash when selecting from empty custom profession list

develop
lethosor 2015-07-31 16:46:00 -04:00
parent 01e04c24c5
commit e02815dc30
2 changed files with 8 additions and 0 deletions

@ -34,6 +34,7 @@ DFHack Future
buildingplan: Now supports hatch covers buildingplan: Now supports hatch covers
gui/hack-wish now properly assigns quality to items. gui/hack-wish now properly assigns quality to items.
gui/gm-editor handles lua tables properly gui/gm-editor handles lua tables properly
manipulator: fixed crash when selecting custom professions when none are found
search: fixed crash in unit list after cancelling a job search: fixed crash in unit list after cancelling a job
stockpiles: now checks/sanitizes filenames when saving stockpiles: now checks/sanitizes filenames when saving
stocks: fixed a crash when right-clicking stocks: fixed a crash when right-clicking

@ -998,6 +998,8 @@ public:
} }
void select_profession(size_t selected) void select_profession(size_t selected)
{ {
if (selected >= manager.templates.size())
return;
ProfessionTemplate prof = manager.templates[selected - 1]; ProfessionTemplate prof = manager.templates[selected - 1];
for (auto it = units.begin(); it != units.end(); ++it) for (auto it = units.begin(); it != units.end(); ++it)
@ -1013,6 +1015,11 @@ public:
Screen::clear(); Screen::clear();
int x = 2, y = 2; int x = 2, y = 2;
Screen::drawBorder(" Dwarf Manipulator - Custom Profession "); Screen::drawBorder(" Dwarf Manipulator - Custom Profession ");
if (!manager.templates.size())
{
OutputString(COLOR_LIGHTRED, x, y, "No saved professions");
return;
}
if (selection_empty) if (selection_empty)
{ {
OutputString(COLOR_LIGHTRED, x, y, "No dwarves selected!"); OutputString(COLOR_LIGHTRED, x, y, "No dwarves selected!");