From 49c0266e6042a7f091e5e1f27d5bfd839c9989f3 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 16 Aug 2026 18:21:54 +0300
Subject: [PATCH 48/48] Maintain aarea->cities at the client side

See RM #2137

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/packhand.c | 3 ++-
 common/city.c     | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/client/packhand.c b/client/packhand.c
index 80c1d1a95c..e10fcd89a8 100644
--- a/client/packhand.c
+++ b/client/packhand.c
@@ -5871,7 +5871,7 @@ void handle_access_area(const struct packet_access_area *packet)
 
   aarea = fc_malloc(sizeof(struct access_area));
 
-  aarea->cities = nullptr;
+  aarea->cities = city_list_new();
   aarea->index = packet->index;
   aarea->capital = packet->capital;
   aarea->tiledefs = packet->tiledefs;
@@ -5904,6 +5904,7 @@ void handle_city_access_area(const struct packet_city_access_area *packet)
       fc_assert(pcity->aarea == nullptr);
 
       pcity->aarea = aarea;
+      city_list_append(aarea->cities, pcity);
       break;
     }
   } aarea_list_iterate_end;
diff --git a/common/city.c b/common/city.c
index f730370792..075aa07668 100644
--- a/common/city.c
+++ b/common/city.c
@@ -3648,6 +3648,11 @@ void destroy_city_virtual(struct city *pcity)
   /* Free rally points */
   city_rally_point_clear(pcity);
 
+  if (pcity->aarea != nullptr) {
+    city_list_remove(pcity->aarea->cities, pcity);
+    pcity->aarea = nullptr;
+  }
+
   unit_list_destroy(pcity->units_supported);
   trade_route_list_destroy(pcity->routes);
   if (pcity->tile_cache != nullptr) {
-- 
2.53.0

