From a87cf5bdccfd5aa8497bd014e1ec0b93c52a886d Mon Sep 17 00:00:00 2001
From: Hilde Iren Lagnason Bye <lagnason@hotmail.com>
Date: Wed, 31 Mar 2021 12:10:57 +0200
Subject: [PATCH] Run action_dice_roll_odds() only when relevant.

The function action_prob_pre_action_dice_roll() will only use the result of
is_effect_val_known() when the value of EFT_ACTION_ODDS_PCT is known.

See osdn #41928
---
 common/actions.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/common/actions.c b/common/actions.c
index 8670a3efd7..60df99a511 100644
--- a/common/actions.c
+++ b/common/actions.c
@@ -5344,14 +5344,15 @@ action_prob_pre_action_dice_roll(const struct player *act_player,
                                  const struct player *tgt_player,
                                  const struct action *paction)
 {
-  int unconverted = action_dice_roll_odds(act_player, act_unit, tgt_city,
-                                          tgt_player, paction);
-  struct act_prob result = { .min = unconverted * ACTPROB_VAL_1_PCT,
-                             .max = unconverted * ACTPROB_VAL_1_PCT };
-
   if (is_effect_val_known(EFT_ACTION_ODDS_PCT, act_player,
                           tgt_player, tgt_player, tgt_city,
                           NULL, NULL, act_unit, NULL, NULL)) {
+
+      int unconverted = action_dice_roll_odds(act_player, act_unit, tgt_city,
+                                              tgt_player, paction);
+
+      struct act_prob result = { .min = unconverted * ACTPROB_VAL_1_PCT,
+                                 .max = unconverted * ACTPROB_VAL_1_PCT };
       return result;
     } else {
       /* Could be improved to return a more exact probability in some cases.
-- 
2.30.2