From 1840ae8d82b1a6d52a2af0b77b54242f54630fe5 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Wed, 18 Jan 2023 17:53:32 +0200
Subject: [PATCH 40/40] expl_act_not_enabl(): Remove unnecessary
 unit_owner(punit) calls

Use the local variable containing the owner when we already
have that.

See osdn #46543

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 server/unithand.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/server/unithand.c b/server/unithand.c
index b563d2ab08..d5c8c83fd0 100644
--- a/server/unithand.c
+++ b/server/unithand.c
@@ -1417,7 +1417,7 @@ static struct ane_expl *expl_act_not_enabl(struct unit *punit,
   struct player *must_war_player;
   const struct action *paction;
   struct action *blocker;
-  const struct player *act_player = unit_owner(punit);
+  struct player *act_player = unit_owner(punit);
   struct player *tgt_player = NULL;
   struct ane_expl *explnat = fc_malloc(sizeof(struct ane_expl));
   bool can_exist = can_unit_exist_at_tile(&(wld.map), punit, unit_tile(punit));
@@ -1500,7 +1500,7 @@ static struct ane_expl *expl_act_not_enabl(struct unit *punit,
       break;
     case ATK_SELF:
       /* A unit acting against itself. */
-      tgt_player = unit_owner(punit);
+      tgt_player = act_player;
       break;
     case ATK_COUNT:
       fc_assert(action_get_target_kind(paction) != ATK_COUNT);
@@ -1612,8 +1612,8 @@ static struct ane_expl *expl_act_not_enabl(struct unit *punit,
     explnat->no_act_terrain = tile_terrain(target_tile);
   } else if ((action_has_result_safe(paction, ACTRES_PARADROP)
               || action_has_result_safe(paction, ACTRES_PARADROP_CONQUER))
-             && target_tile
-             && map_is_known_and_seen(target_tile, unit_owner(punit),
+             && target_tile != NULL
+             && map_is_known_and_seen(target_tile, act_player,
                                       V_MAIN)
              && (!can_unit_exist_at_tile(&(wld.map), punit, target_tile)
                  && (!BV_ISSET(paction->sub_results, ACT_SUB_RES_MAY_EMBARK)
@@ -1676,25 +1676,25 @@ static struct ane_expl *expl_act_not_enabl(struct unit *punit,
     explnat->no_war_with = must_war_player;
   } else if (action_mp_full_makes_legal(punit, act_id)) {
     explnat->kind = ANEK_LOW_MP;
-  } else if (tgt_player
-             && unit_owner(punit) != tgt_player
+  } else if (tgt_player != NULL
+             && act_player != tgt_player
              && !can_utype_do_act_if_tgt_diplrel(unit_type_get(punit),
                                                  act_id,
                                                  DRO_FOREIGN,
                                                  TRUE)) {
     explnat->kind = ANEK_FOREIGN;
-  } else if (tgt_player
-             && unit_owner(punit) == tgt_player
+  } else if (tgt_player != NULL
+             && act_player == tgt_player
              && !can_utype_do_act_if_tgt_diplrel(unit_type_get(punit),
                                                  act_id,
                                                  DRO_FOREIGN,
                                                  FALSE)) {
     explnat->kind = ANEK_DOMESTIC;
-  } else if (punit
+  } else if (punit != NULL
              && does_nation_block_action(act_id, FALSE,
-                                         punit, unit_owner(punit)->nation)) {
+                                         punit, act_player->nation)) {
     explnat->kind = ANEK_NATION_ACT;
-    explnat->no_act_nation = unit_owner(punit)->nation;
+    explnat->no_act_nation = act_player->nation;
   } else if (tgt_player
              && does_nation_block_action(act_id, TRUE,
                                          punit, tgt_player->nation)) {
@@ -1816,8 +1816,8 @@ static struct ane_expl *expl_act_not_enabl(struct unit *punit,
     explnat->kind = ANEK_CITY_TOO_CLOSE_TGT;
   } else if ((action_has_result_safe(paction, ACTRES_PARADROP_CONQUER)
               || action_has_result_safe(paction, ACTRES_PARADROP))
-             && target_tile
-             && !map_is_known(target_tile, unit_owner(punit))) {
+             && target_tile != NULL
+             && !map_is_known(target_tile, act_player)) {
     explnat->kind = ANEK_TGT_TILE_UNKNOWN;
   } else if ((action_has_result_safe(paction, ACTRES_CONQUER_CITY)
               || action_id_has_result_safe(act_id, ACTRES_CONQUER_EXTRAS)
@@ -1845,7 +1845,7 @@ static struct ane_expl *expl_act_not_enabl(struct unit *punit,
       break;
     }
   } else if (action_has_result_safe(paction, ACTRES_SPY_BRIBE_UNIT)
-             && utype_player_already_has_this_unique(unit_owner(punit),
+             && utype_player_already_has_this_unique(act_player,
                  unit_type_get(target_unit))) {
     explnat->kind = ANEK_TGT_IS_UNIQUE_ACT_HAS;
     explnat->no_tgt_utype = unit_type_get(target_unit);
-- 
2.39.0