From 0908420750c666bb2e4867a1c429e56a47e94895 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Mon, 14 Sep 2026 22:12:54 +0300
Subject: [PATCH 69/69] Send access area info to client connecting midturn

See RM #2131

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 server/aahand.c      | 41 +++++++++++++++++++++++++++++++++++++++++
 server/aahand.h      |  1 +
 server/connecthand.c |  6 ++++--
 3 files changed, 46 insertions(+), 2 deletions(-)

diff --git a/server/aahand.c b/server/aahand.c
index 77ba892223..d23549a035 100644
--- a/server/aahand.c
+++ b/server/aahand.c
@@ -125,3 +125,44 @@ void access_areas_refresh(struct civ_map *nmap, struct player *plr)
     unit_virtual_destroy(access_unit);
   }
 }
+
+/*********************************************************************//**
+  Just send existing access area info.
+  @param pconn Connection to send the information for and to
+*************************************************************************/
+void send_access_area_info(struct connection *pconn)
+{
+  if (pconn->playing != nullptr
+      && access_info_access_unit() != nullptr) {
+    struct aarea_list *alist = area_list_for_player(pconn->playing);
+    struct packet_access_area aarea_packet;
+
+    aarea_packet.player = player_number(pconn->playing);
+
+    aarea_list_iterate(alist, aarea) {
+      BV_CLR_ALL(aarea_packet.tiledefs);
+
+      tiledef_iterate(td) {
+        int tn = tiledef_number(td);
+
+        if (BV_ISSET(aarea->tiledefs, tn)) {
+          BV_SET(aarea_packet.tiledefs, tn);
+        }
+      } tiledef_iterate_end;
+
+      aarea_packet.index = aarea->index;
+      aarea_packet.capital = aarea->capital;
+
+      send_packet_access_area(pconn, &aarea_packet);
+    } aarea_list_iterate_end;
+
+    city_list_iterate(pconn->playing->cities, pcity) {
+      struct packet_city_access_area caarea_packet;
+
+      caarea_packet.city = pcity->id;
+      caarea_packet.aarea = pcity->aarea->index;
+
+      send_packet_city_access_area(pconn, &caarea_packet);
+    } city_list_iterate_end;
+  }
+}
diff --git a/server/aahand.h b/server/aahand.h
index ebf0abe729..2a5eee7e7e 100644
--- a/server/aahand.h
+++ b/server/aahand.h
@@ -14,5 +14,6 @@
 #define FC__AAHAND_H
 
 void access_areas_refresh(struct civ_map *nmap, struct player *plr);
+void send_access_area_info(struct connection *pconn);
 
 #endif /* FC__AAHAND_H */
diff --git a/server/connecthand.c b/server/connecthand.c
index b594c2412d..aa07499684 100644
--- a/server/connecthand.c
+++ b/server/connecthand.c
@@ -34,6 +34,7 @@
 #include "version.h"
 
 /* server */
+#include "aahand.h"
 #include "aiiface.h"
 #include "auth.h"
 #include "diplhand.h"
@@ -177,7 +178,7 @@ void establish_new_connection(struct connection *pconn)
                 freeciv_name_version(), srvarg.port);
   }
 
-  /* FIXME: this (getting messages about others logging on) should be
+  /* FIXME: This (getting messages about others logging on) should be
    * a message option for the client with event */
 
   /* Notify the console that you're here. */
@@ -742,7 +743,7 @@ static bool connection_attach_real(struct connection *pconn,
   send_conn_info(pconn->self, game.est_connections);    /* Client side. */
   conn_reset_delta_state(pconn);                        /* Server side. */
 
-  /* Initial packets don't need to be resent.  See comment for
+  /* Initial packets don't need to be resent. See comment for
    * connecthand.c::establish_new_connection(). */
   switch (server_state()) {
   case S_S_INITIAL:
@@ -763,6 +764,7 @@ static bool connection_attach_real(struct connection *pconn,
     send_diplomatic_meetings(pconn);
     send_pending_events(pconn, connecting);
     send_running_votes(pconn, !connecting);
+    send_access_area_info(pconn);
     break;
 
   case S_S_OVER:
-- 
2.53.0

