Skip to content

Commit

Permalink
Merge pull request #860 from cazfi/srvup
Browse files Browse the repository at this point in the history
  • Loading branch information
cazfi authored Jun 23, 2024
2 parents be3bfd5 + 53f5f77 commit 531968b
Show file tree
Hide file tree
Showing 4 changed files with 213 additions and 2 deletions.
8 changes: 8 additions & 0 deletions freeciv/apply_patches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
# 0068-AI-Remove-shared-vision-from-pending-war-target-once.patch
# AI assert fix
# RM #701
# 0038-map_init_topology-Operate-on-any-map.patch
# Dependency of 0030-Tex-Initialize-map-topology.patch
# RM #707
# 0030-Tex-Initialize-map-topology.patch
# Tex AI map topology fix
# RM #663

# Not in the upstream Freeciv server
# ----------------------------------
Expand Down Expand Up @@ -65,6 +71,8 @@ declare -a PATCHLIST=(
"backports/0074-Meson-Make-fc_server-to-depend-on-verhdr"
"backports/0077-city_freeze_workers_queue-Set-needs_arrange-for-citi"
"backports/0068-AI-Remove-shared-vision-from-pending-war-target-once"
"backports/0038-map_init_topology-Operate-on-any-map"
"backports/0030-Tex-Initialize-map-topology"
"RevertAmplio2ExtraUnits"
"meson_webperimental"
"metachange"
Expand Down
27 changes: 27 additions & 0 deletions freeciv/patches/backports/0030-Tex-Initialize-map-topology.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
From 386dd9dc4411f87981f91773c8eff220ef22be53 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <[email protected]>
Date: Sun, 16 Jun 2024 02:09:45 +0300
Subject: [PATCH 30/30] Tex: Initialize map topology

See RM #663

Signed-off-by: Marko Lindqvist <[email protected]>
---
ai/tex/texaiworld.c | 1 +
1 file changed, 1 insertion(+)

diff --git a/ai/tex/texaiworld.c b/ai/tex/texaiworld.c
index 26f9d63ea2..97d6c55e1f 100644
--- a/ai/tex/texaiworld.c
+++ b/ai/tex/texaiworld.c
@@ -85,6 +85,7 @@ void texai_world_close(void)
void texai_map_init(void)
{
map_init(&(texai_world.map), TRUE);
+ map_init_topology(&(texai_world.map));
map_allocate(&(texai_world.map));
}

--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
From 03af55537a12e1b76012c807a8843f028884d149 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <[email protected]>
Date: Sat, 8 Jun 2024 20:14:33 +0300
Subject: [PATCH 38/39] map_init_topology(): Operate on any map

Take map as parameter, instead of assuming main map.

Requested by Alina Lenk

See RM #707

Signed-off-by: Marko Lindqvist <[email protected]>
---
client/packhand.c | 2 +-
common/map.c | 20 ++++++++++----------
common/map.h | 2 +-
server/generator/mapgen_topology.c | 10 +++++-----
server/savegame/savegame2.c | 2 +-
server/savegame/savegame3.c | 2 +-
6 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/client/packhand.c b/client/packhand.c
index 879f2b77e9..1a6f847a96 100644
--- a/client/packhand.c
+++ b/client/packhand.c
@@ -2259,7 +2259,7 @@ void handle_map_info(const struct packet_map_info *packet)
wld.map.topology_id = packet->topology_id;
wld.map.wrap_id = packet->wrap_id;

- map_init_topology();
+ map_init_topology(&(wld.map));
main_map_allocate();
client_player_maps_reset();
init_client_goto();
diff --git a/common/map.c b/common/map.c
index 963faf509e..664b2b66ca 100644
--- a/common/map.c
+++ b/common/map.c
@@ -164,7 +164,7 @@ void map_init(struct civ_map *imap, bool server_side)
imap->startpos_table = nullptr;
imap->iterate_outwards_indices = nullptr;

- /* The [xy]size values are set in map_init_topology. It is initialized
+ /* The [xy]size values are set in map_init_topology(). It is initialized
* to a non-zero value because some places erroneously use these values
* before they're initialized. */
imap->xsize = MAP_DEFAULT_LINEAR_SIZE;
@@ -312,7 +312,7 @@ static void generate_map_indices(void)
This is done by the map generator code (server), when loading a savegame
or a scenario with map (server), and packhand code (client).
***********************************************************************/
-void map_init_topology(void)
+void map_init_topology(struct civ_map *nmap)
{
enum direction8 dir;

@@ -328,7 +328,7 @@ void map_init_topology(void)
fc_assert(map_num_tiles() >= MAP_MIN_SIZE * 1000);
fc_assert(map_num_tiles() <= MAP_MAX_SIZE * 1000);

- wld.map.num_valid_dirs = wld.map.num_cardinal_dirs = 0;
+ nmap->num_valid_dirs = nmap->num_cardinal_dirs = 0;

/* Values for direction8_invalid() */
fc_assert(direction8_invalid() == 8);
@@ -338,23 +338,23 @@ void map_init_topology(void)
/* Values for actual directions */
for (dir = 0; dir < 8; dir++) {
if (is_valid_dir_calculate(dir)) {
- wld.map.valid_dirs[wld.map.num_valid_dirs] = dir;
- wld.map.num_valid_dirs++;
+ nmap->valid_dirs[nmap->num_valid_dirs] = dir;
+ nmap->num_valid_dirs++;
dir_validity[dir] = TRUE;
} else {
dir_validity[dir] = FALSE;
}
if (is_cardinal_dir_calculate(dir)) {
- wld.map.cardinal_dirs[wld.map.num_cardinal_dirs] = dir;
- wld.map.num_cardinal_dirs++;
+ nmap->cardinal_dirs[nmap->num_cardinal_dirs] = dir;
+ nmap->num_cardinal_dirs++;
dir_cardinality[dir] = TRUE;
} else {
dir_cardinality[dir] = FALSE;
}
}
- fc_assert(wld.map.num_valid_dirs > 0 && wld.map.num_valid_dirs <= 8);
- fc_assert(wld.map.num_cardinal_dirs > 0
- && wld.map.num_cardinal_dirs <= wld.map.num_valid_dirs);
+ fc_assert(nmap->num_valid_dirs > 0 && nmap->num_valid_dirs <= 8);
+ fc_assert(nmap->num_cardinal_dirs > 0
+ && nmap->num_cardinal_dirs <= nmap->num_valid_dirs);
}

/*******************************************************************//**
diff --git a/common/map.h b/common/map.h
index 338dbcb36f..18804f1c15 100644
--- a/common/map.h
+++ b/common/map.h
@@ -49,7 +49,7 @@ static const bool C_PERCENT = TRUE;

bool map_is_empty(void);
void map_init(struct civ_map *imap, bool server_side);
-void map_init_topology(void);
+void map_init_topology(struct civ_map *nmap);
void map_allocate(struct civ_map *amap);
void main_map_allocate(void);
void map_free(struct civ_map *fmap, bool server_side);
diff --git a/server/generator/mapgen_topology.c b/server/generator/mapgen_topology.c
index 8ba29db74b..38b904abc0 100644
--- a/server/generator/mapgen_topology.c
+++ b/server/generator/mapgen_topology.c
@@ -226,20 +226,20 @@ void generator_init_topology(bool autosize)

sqsize = get_sqsize();

- /* initialize the ICE_BASE_LEVEL */
+ /* Initialize the ICE_BASE_LEVEL */

- /* if maps has strip like poles we get smaller poles
+ /* If maps has strip like poles we get smaller poles
* (less playables than island poles)
* 5% for little maps
* 2% for big ones, if map.server.temperature == 50
* except if separate poles is set */
if (wld.map.server.separatepoles) {
- /* with separatepoles option strip poles are useless */
+ /* With separatepoles option strip poles are useless */
ice_base_colatitude =
(MAX(0, 100 * COLD_LEVEL / 3 - 1 * MAX_COLATITUDE)
+ 1 * MAX_COLATITUDE * sqsize) / (100 * sqsize);
} else {
- /* any way strip poles are not so playable as isle poles */
+ /* Any way strip poles are not so playable as isle poles */
ice_base_colatitude =
(MAX(0, 100 * COLD_LEVEL / 3 - 2 * MAX_COLATITUDE)
+ 2 * MAX_COLATITUDE * sqsize) / (100 * sqsize);
@@ -262,7 +262,7 @@ void generator_init_topology(bool autosize)
wld.map.server.huts_absolute = -1;
}

- map_init_topology();
+ map_init_topology(&(wld.map));
}

/************************************************************************//**
diff --git a/server/savegame/savegame2.c b/server/savegame/savegame2.c
index e752b790ca..97792a6a92 100644
--- a/server/savegame/savegame2.c
+++ b/server/savegame/savegame2.c
@@ -2261,7 +2261,7 @@ static void sg_load_map_tiles(struct loaddata *loading)

/* Initialize the map for the current topology. 'map.xsize' and
* 'map.ysize' must be set. */
- map_init_topology();
+ map_init_topology(&(wld.map));

/* Allocate map. */
main_map_allocate();
diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c
index ee1d62cff3..00cfbaffe6 100644
--- a/server/savegame/savegame3.c
+++ b/server/savegame/savegame3.c
@@ -2922,7 +2922,7 @@ static void sg_load_map_tiles(struct loaddata *loading)

/* Initialize the map for the current topology. 'map.xsize' and
* 'map.ysize' must be set. */
- map_init_topology();
+ map_init_topology(&(wld.map));

/* Allocate map. */
main_map_allocate();
--
2.43.0

4 changes: 2 additions & 2 deletions freeciv/version.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# The Git SHA hash for the commit to checkout from
# https://github.com/freeciv/freeciv

FCREV=e3e8c0ac909aa585efa9890eac48bdef78f4564c
FCREV=447c01a2ae88937c2caaee6f59118052b445d49e

ORIGCAPSTR="+Freeciv.Devel-\${MAIN_VERSION}-2024.May.06"
ORIGCAPSTR="+Freeciv.Devel-\${MAIN_VERSION}-2024.May.09"

# There's no need to bump this constantly as current freeciv-web
# makes no connections to outside world - all connections are
Expand Down

0 comments on commit 531968b

Please sign in to comment.