Catch invalid argument exception for stoi in unit advancement. Resolves #7402.
This commit is contained in:
parent
fb095b8abb
commit
1745a8bbca
1 changed files with 7 additions and 1 deletions
|
@ -478,7 +478,13 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_unit, child, use_undo, /*show*/, /*error_
|
|||
return false;
|
||||
}
|
||||
if (name == "advances" ) {
|
||||
int int_value = std::stoi(value);
|
||||
int int_value = 0;
|
||||
try {
|
||||
int_value = std::stoi(value);
|
||||
} catch (const std::invalid_argument&) {
|
||||
WRN_REPLAY << "Warning: Invalid unit advancement argument: " << value;
|
||||
return false;
|
||||
}
|
||||
for (int levels=0; levels<int_value; levels++) {
|
||||
i->set_experience(i->max_experience());
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue