Skip to content

Commit

Permalink
WITCHER: Catch exceptions in NWScript function StringToFloat
Browse files Browse the repository at this point in the history
On error, it should return 0.0.
  • Loading branch information
DrMcCoy committed Nov 13, 2016
1 parent e02d3a6 commit 3eecb4e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/engines/witcher/nwscript/functions_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,12 @@ void Functions::stringToInt(Aurora::NWScript::FunctionContext &ctx) {
}

void Functions::stringToFloat(Aurora::NWScript::FunctionContext &ctx) {
float f = 0;
Common::parseString(ctx.getParams()[0].getString(), f);
float f = 0.0f;

try {
Common::parseString(ctx.getParams()[0].getString(), f);
} catch (...) {
}

ctx.getReturn() = f;
}
Expand Down

0 comments on commit 3eecb4e

Please sign in to comment.