From 72524100055522869ca1107b50765b434a907028 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Fri, 22 Sep 2023 14:13:20 +0300 Subject: [PATCH 20/20] Add altitude info presence info Currently always FALSE See osdn #48668 Signed-off-by: Marko Lindqvist --- client/packhand.c | 8 +++++--- common/map.c | 1 + common/map_types.h | 11 ++++++----- common/networking/packets.def | 1 + server/maphand.c | 1 + server/savegame/savecompat.c | 4 ++++ server/savegame/savegame3.c | 11 +++++++++-- 7 files changed, 27 insertions(+), 10 deletions(-) diff --git a/client/packhand.c b/client/packhand.c index 9d27bb6f62..229c0a5815 100644 --- a/client/packhand.c +++ b/client/packhand.c @@ -2229,8 +2229,8 @@ void handle_set_topology(int topology_id, int wrap_id) } /************************************************************************//** - Receive information about the map size and topology from the server. We - initialize some global variables at the same time. + Receive information about the map size and topology from the server. + We initialize some global variables at the same time. ****************************************************************************/ void handle_map_info(const struct packet_map_info *packet) { @@ -2246,8 +2246,10 @@ void handle_map_info(const struct packet_map_info *packet) wld.map.north_latitude = packet->north_latitude; wld.map.south_latitude = packet->south_latitude; + wld.map.altitude_info = packet->altitude_info; - if (tileset_map_topo_compatible(packet->topology_id, tileset, &ts_topo) == TOPO_INCOMP_HARD) { + if (tileset_map_topo_compatible(packet->topology_id, + tileset, &ts_topo) == TOPO_INCOMP_HARD) { tileset_error(LOG_NORMAL, tileset_name_get(tileset), _("Map topology (%s) and tileset (%s) incompatible."), describe_topology(packet->topology_id), describe_topology(ts_topo)); diff --git a/common/map.c b/common/map.c index 080e871df3..afdb5177d7 100644 --- a/common/map.c +++ b/common/map.c @@ -158,6 +158,7 @@ void map_init(struct civ_map *imap, bool server_side) { imap->topology_id = MAP_DEFAULT_TOPO; imap->wrap_id = MAP_DEFAULT_WRAP; + imap->altitude_info = FALSE; imap->num_continents = 0; imap->num_oceans = 0; imap->tiles = nullptr; diff --git a/common/map_types.h b/common/map_types.h index efaaf1e6e4..3f5672316c 100644 --- a/common/map_types.h +++ b/common/map_types.h @@ -71,23 +71,24 @@ enum map_startpos { struct civ_map { int topology_id; int wrap_id; + bool altitude_info; enum direction8 valid_dirs[8], cardinal_dirs[8]; int num_valid_dirs, num_cardinal_dirs; struct iter_index *iterate_outwards_indices; int num_iterate_outwards_indices; - int xsize, ysize; /* native dimensions */ + int xsize, ysize; /* Native dimensions */ int north_latitude; int south_latitude; int num_continents; - int num_oceans; /* not updated at the client */ + int num_oceans; /* Not updated at the client */ struct tile *tiles; struct startpos_hash *startpos_table; union { struct { - enum mapsize_type mapsize; /* how the map size is defined */ - int size; /* used to calculate [xy]size */ - int tilesperplayer; /* tiles per player; used to calculate size */ + enum mapsize_type mapsize; /* How the map size is defined */ + int size; /* Used to calculate [xy]size */ + int tilesperplayer; /* Tiles per player; used to calculate size */ randseed seed_setting; randseed seed; int riches; diff --git a/common/networking/packets.def b/common/networking/packets.def index 1eeda3577d..3584a5d9b0 100644 --- a/common/networking/packets.def +++ b/common/networking/packets.def @@ -649,6 +649,7 @@ PACKET_MAP_INFO = 17; sc, lsend UINT8 wrap_id; SINT16 north_latitude; SINT16 south_latitude; + BOOL altitude_info; end PACKET_NUKE_TILE_INFO = 18; sc, dsend, lsend, handle-via-fields diff --git a/server/maphand.c b/server/maphand.c index b7fad4c199..4eb77b6900 100644 --- a/server/maphand.c +++ b/server/maphand.c @@ -647,6 +647,7 @@ void send_map_info(struct conn_list *dest) minfo.wrap_id = wld.map.wrap_id; minfo.north_latitude = wld.map.north_latitude; minfo.south_latitude = wld.map.south_latitude; + minfo.altitude_info = wld.map.altitude_info; lsend_packet_map_info(dest, &minfo); } diff --git a/server/savegame/savecompat.c b/server/savegame/savecompat.c index 0af485ef76..b9d23bbc3f 100644 --- a/server/savegame/savecompat.c +++ b/server/savegame/savecompat.c @@ -2434,6 +2434,8 @@ static void compat_load_030300(struct loaddata *loading, log_debug("Upgrading data from savegame to version 3.3.0"); + secfile_insert_bool(loading->file, FALSE, "map.altitude"); + { int ssa_count; @@ -3236,6 +3238,8 @@ static void compat_load_dev(struct loaddata *loading) if (game_version < 3029200) { /* Before version number bump to 3.2.92 */ + secfile_insert_bool(loading->file, FALSE, "map.altitude"); + } /* Version < 3.2.92 */ #endif /* FREECIV_DEV_SAVE_COMPAT_3_3 */ diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c index f802595276..fdbb9a6c06 100644 --- a/server/savegame/savegame3.c +++ b/server/savegame/savegame3.c @@ -1198,7 +1198,7 @@ static Tech_type_id technology_load(struct section_file *file, name = secfile_lookup_str(file, path_with_name, plrno); if (!name || name[0] == '\0') { - /* used by researching_saved */ + /* Used by researching_saved */ return A_UNKNOWN; } if (fc_strcasecmp(name, "A_FUTURE") == 0) { @@ -1231,7 +1231,7 @@ static void technology_save(struct section_file *file, "%s_name", path); switch (tech) { - case A_UNKNOWN: /* used by researching_saved */ + case A_UNKNOWN: /* Used by researching_saved */ name = ""; break; case A_NONE: @@ -2739,6 +2739,11 @@ static void sg_load_map(struct loaddata *loading) * 2) when map is actually generated, it re-initialize this to FALSE. */ wld.map.server.have_huts = secfile_lookup_bool_default(loading->file, TRUE, "map.have_huts"); + + sg_failure_ret(secfile_lookup_bool(loading->file, &wld.map.altitude_info, + "map.altitude"), + "%s", secfile_error()); + game.scenario.have_resources = secfile_lookup_bool_default(loading->file, TRUE, "map.have_resources"); @@ -2798,6 +2803,8 @@ static void sg_save_map(struct savedata *saving) secfile_insert_bool(saving->file, TRUE, "map.have_resources"); } + secfile_insert_bool(saving->file, wld.map.altitude_info, "map.altitude"); + /* For debugging purposes only. * Do not save it if it's 0 (not known); * this confuses people reading this 'document' less than -- 2.40.1