From f635fdb38d609227f4f0e56a65e171825d978397 Mon Sep 17 00:00:00 2001
From: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Date: Sat, 21 Nov 2026 16:28:40 -0800
Subject: [PATCH] infracache: Keep extra values as adv_want

The worker cache stores tile action values as adv_want, but
adv_city_worker_extra_set/get() and adv_city_worker_rmextra_set/get()
still took and returned int. A tile value can carry a half point
(SHIELD_WEIGHTING / 2 for a tile with shields), so the value cached
for an extra that adds no output came out half a point below the tile
as it is. Auto workers then count such an extra as making the tile
worse, and a road's move bonus is dropped.

Make the four functions take and return adv_want.

See RM #2497

Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
---
 server/advisors/infracache.c | 16 ++++++++++------
 server/advisors/infracache.h | 16 ++++++++++------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/server/advisors/infracache.c b/server/advisors/infracache.c
index 77b9243b8c..75d46135a7 100644
--- a/server/advisors/infracache.c
+++ b/server/advisors/infracache.c
@@ -376,7 +376,8 @@ adv_want adv_city_worker_act_get(const struct city *pcity,
   city 'pcity'.
 **************************************************************************/
 void adv_city_worker_extra_set(struct city *pcity, int city_tile_index,
-                               const struct extra_type *pextra, int value)
+                               const struct extra_type *pextra,
+                               adv_want value)
 {
   if (pcity->server.adv->act_cache_radius_sq
       != city_map_radius_sq_get(pcity)) {
@@ -402,7 +403,8 @@ void adv_city_worker_extra_set(struct city *pcity, int city_tile_index,
   city 'pcity'.
 **************************************************************************/
 void adv_city_worker_rmextra_set(struct city *pcity, int city_tile_index,
-                                 const struct extra_type *pextra, int value)
+                                 const struct extra_type *pextra,
+                                 adv_want value)
 {
   if (pcity->server.adv->act_cache_radius_sq
       != city_map_radius_sq_get(pcity)) {
@@ -427,8 +429,9 @@ void adv_city_worker_rmextra_set(struct city *pcity, int city_tile_index,
   Return the value for extra on tile 'city_tile_index' of
   city 'pcity'.
 **************************************************************************/
-int adv_city_worker_extra_get(const struct city *pcity, int city_tile_index,
-                              const struct extra_type *pextra)
+adv_want adv_city_worker_extra_get(const struct city *pcity,
+                                   int city_tile_index,
+                                   const struct extra_type *pextra)
 {
   fc_assert_ret_val(pcity != nullptr, 0);
   fc_assert_ret_val(pcity->server.adv != nullptr, 0);
@@ -444,8 +447,9 @@ int adv_city_worker_extra_get(const struct city *pcity, int city_tile_index,
   Return the value for extra removal on tile 'city_tile_index' of
   city 'pcity'.
 **************************************************************************/
-int adv_city_worker_rmextra_get(const struct city *pcity, int city_tile_index,
-                                const struct extra_type *pextra)
+adv_want adv_city_worker_rmextra_get(const struct city *pcity,
+                                     int city_tile_index,
+                                     const struct extra_type *pextra)
 {
   fc_assert_ret_val(pcity != nullptr, 0);
   fc_assert_ret_val(pcity->server.adv != nullptr, 0);
diff --git a/server/advisors/infracache.h b/server/advisors/infracache.h
index d0de7bee76..16a3a93c9a 100644
--- a/server/advisors/infracache.h
+++ b/server/advisors/infracache.h
@@ -50,12 +50,16 @@ void adv_city_worker_act_set(struct city *pcity, int city_tile_index,
 adv_want adv_city_worker_act_get(const struct city *pcity, int city_tile_index,
                                  enum unit_activity act_id);
 void adv_city_worker_extra_set(struct city *pcity, int city_tile_index,
-                               const struct extra_type *pextra, int value);
-int adv_city_worker_extra_get(const struct city *pcity, int city_tile_index,
-                              const struct extra_type *pextra);
+                               const struct extra_type *pextra,
+                               adv_want value);
+adv_want adv_city_worker_extra_get(const struct city *pcity,
+                                   int city_tile_index,
+                                   const struct extra_type *pextra);
 void adv_city_worker_rmextra_set(struct city *pcity, int city_tile_index,
-                                 const struct extra_type *pextra, int value);
-int adv_city_worker_rmextra_get(const struct city *pcity, int city_tile_index,
-                                const struct extra_type *pextra);
+                                 const struct extra_type *pextra,
+                                 adv_want value);
+adv_want adv_city_worker_rmextra_get(const struct city *pcity,
+                                     int city_tile_index,
+                                     const struct extra_type *pextra);
 
 #endif /* FC__INFRACACHE_H */
-- 
2.55.0

