From 0c2c94fa92f27290fc499f4542179ed9a0f2a7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 29 Mar 2012 20:18:14 +0200 Subject: [PATCH] Remove random bad asserts --- plugins/autolabor.cpp | 12 ++++++++++++ plugins/mode.cpp | 3 ++- plugins/tiletypes.cpp | 3 ++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/plugins/autolabor.cpp b/plugins/autolabor.cpp index eee10e3eb..60a574ce2 100644 --- a/plugins/autolabor.cpp +++ b/plugins/autolabor.cpp @@ -590,8 +590,10 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out ) if (labor == df::enums::unit_labor::NONE) continue; + /* assert(labor >= 0); assert(labor < ARRAY_COUNT(labor_infos)); + */ if (labor_infos[labor].is_exclusive && dwarfs[dwarf]->status.labors[labor]) dwarf_info[dwarf].mastery_penalty -= 100; @@ -636,8 +638,10 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out ) { int job = dwarfs[dwarf]->job.current_job->job_type; + /* assert(job >= 0); assert(job < ARRAY_COUNT(dwarf_states)); + */ dwarf_info[dwarf].state = dwarf_states[job]; } @@ -656,8 +660,10 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out ) int labor = ENUM_ATTR(job_skill, labor, skill); if (labor != df::enums::unit_labor::NONE) { + /* assert(labor >= 0); assert(labor < ARRAY_COUNT(labor_to_skill)); + */ labor_to_skill[labor] = skill; } @@ -670,8 +676,10 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out ) if (labor == df::enums::unit_labor::NONE) continue; + /* assert(labor >= 0); assert(labor < ARRAY_COUNT(labor_infos)); + */ labors.push_back(labor); } @@ -684,8 +692,10 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out ) { auto labor = *lp; + /* assert(labor >= 0); assert(labor < ARRAY_COUNT(labor_infos)); + */ df::job_skill skill = labor_to_skill[labor]; @@ -864,8 +874,10 @@ DFhackCExport command_result plugin_onupdate ( color_ostream &out ) if (labor == df::enums::unit_labor::NONE) continue; + /* assert(labor >= 0); assert(labor < ARRAY_COUNT(labor_infos)); + */ if (labor_infos[labor].mode != HAULERS) continue; diff --git a/plugins/mode.cpp b/plugins/mode.cpp index d87fd5392..33dd5875f 100644 --- a/plugins/mode.cpp +++ b/plugins/mode.cpp @@ -95,7 +95,8 @@ void printCurrentModes(t_gamemodes gm, Console & con) command_result mode (color_ostream &out_, vector & parameters) { - assert(out_.is_console()); + if(!out_.is_console()) + return CR_FAILURE; Console &out = static_cast(out_); string command = ""; diff --git a/plugins/tiletypes.cpp b/plugins/tiletypes.cpp index 2b2bcf2e7..61b4ec8e7 100644 --- a/plugins/tiletypes.cpp +++ b/plugins/tiletypes.cpp @@ -524,7 +524,8 @@ command_result df_tiletypes (color_ostream &out, vector & parameters) } } - assert(out.is_console()); + if(!out.is_console()) + return CR_FAILURE; Console &con = static_cast(out); TileType filter, paint;