From df15d256d5177839a6c43eb5f173b401b9e06dd9 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Fri, 24 Jan 2020 22:22:30 -0500 Subject: [PATCH] Avoid crafting_success_roll returning NaN The crafting_success_roll could end up computing 0.0/0.0. This happened to work, but more by luck than design, so check for that case explicitly. (NaN values are unsafe given that we're compiling with -ffast-math). --- src/crafting.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/crafting.cpp b/src/crafting.cpp index 00869459eb0c3..7cec55fba8e1a 100644 --- a/src/crafting.cpp +++ b/src/crafting.cpp @@ -908,6 +908,11 @@ double player::crafting_success_roll( const recipe &making ) const const double skill_roll = dice( skill_dice, skill_sides ); const double diff_roll = dice( diff_dice, diff_sides ); + if( diff_roll == 0 ) { + // Automatic success + return 2; + } + return skill_roll / diff_roll; }