From 4986a012b64320005213741a627fc449a68fe488 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Thu, 18 Jun 2026 02:38:09 +0300
Subject: [PATCH 36/36] Initialize access_info at the client side

See RM #2054

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/packhand.c             | 7 +++++++
 common/networking/packets.def | 1 +
 server/ruleset/ruleload.c     | 6 +++++-
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/client/packhand.c b/client/packhand.c
index c6b9a7745c..00250f9dbc 100644
--- a/client/packhand.c
+++ b/client/packhand.c
@@ -4682,11 +4682,18 @@ void handle_ruleset_trade(const struct packet_ruleset_trade *p)
 void handle_ruleset_terrain_control
     (const struct packet_ruleset_terrain_control *p)
 {
+  struct unit_type *access_unit = nullptr;
+
   /* Since terrain_control is the same as packet_ruleset_terrain_control
    * we can just copy the data directly. */
   terrain_control = *p;
   /* terrain_control.move_fragments likely changed */
   init_move_fragments();
+
+  if (p->access_unit >= 0) {
+    access_unit = utype_by_number(p->access_unit);
+  }
+  access_info_init(access_unit);
 }
 
 /************************************************************************//**
diff --git a/common/networking/packets.def b/common/networking/packets.def
index 3a961a7eb7..760b6bd4aa 100644
--- a/common/networking/packets.def
+++ b/common/networking/packets.def
@@ -1596,6 +1596,7 @@ PACKET_RULESET_TERRAIN_CONTROL = 146; sc, lsend
   BOOL infrapoints;
   STRING gui_type_base0[MAX_LEN_NAME];
   STRING gui_type_base1[MAX_LEN_NAME];
+  SINT16 access_unit;
 end
 
 PACKET_RULESETS_READY = 225; sc, lsend
diff --git a/server/ruleset/ruleload.c b/server/ruleset/ruleload.c
index c05d1eb274..65e2ebcfe2 100644
--- a/server/ruleset/ruleload.c
+++ b/server/ruleset/ruleload.c
@@ -3146,7 +3146,7 @@ static bool load_ruleset_terrain(struct section_file *file,
   int *res_freq;
   bool ok = TRUE;
 
-  /* parameters */
+  /* Parameters */
 
   terrain_control.ocean_reclaim_requirement_pct
     = secfile_lookup_int_default(file, 101,
@@ -7646,6 +7646,8 @@ static bool load_ruleset_game(struct section_file *file, bool act,
                                                    "aarea.access_unit");
     const struct unit_type *access_unit = nullptr;
 
+    terrain_control.access_unit = -1;
+
     if (uname != nullptr && uname[0] != '\0') {
       access_unit = unit_type_by_rule_name(uname);
 
@@ -7653,6 +7655,8 @@ static bool load_ruleset_game(struct section_file *file, bool act,
         ruleset_error(nullptr, LOG_ERROR, "%s: access unit %s unknown.",
                       filename, uname);
         ok = FALSE;
+      } else {
+        terrain_control.access_unit = utype_number(access_unit);
       }
     }
 
-- 
2.53.0

