Skip to content

Commit

Permalink
Merge pull request #841 from cazfi/srvup
Browse files Browse the repository at this point in the history
  • Loading branch information
cazfi authored May 7, 2024
2 parents 103f4e7 + cf90a4f commit ed58a33
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 9 deletions.
11 changes: 6 additions & 5 deletions freeciv-web/src/main/webapp/javascript/fc_types.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,11 +283,12 @@ var ACTION_TRANSFORM_TERRAIN = 130;
var ACTION_TRANSFORM_TERRAIN2 = 131;

var ACTION_GAIN_VETERANCY = 132;
var ACTION_USER_ACTION1 = 133;
var ACTION_USER_ACTION2 = 134;
var ACTION_USER_ACTION3 = 135;
var ACTION_USER_ACTION4 = 136;
var ACTION_COUNT = 137;
var ACTION_ESCAPE = 133;
var ACTION_USER_ACTION1 = 134;
var ACTION_USER_ACTION2 = 135;
var ACTION_USER_ACTION3 = 136;
var ACTION_USER_ACTION4 = 137;
var ACTION_COUNT = 138;

/* The action_decision enum */
/* Doesn't need the player to decide what action to take. */
Expand Down
4 changes: 2 additions & 2 deletions freeciv-web/src/main/webapp/javascript/unittype.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ var UCF_ATTACK_NON_NATIVE = 9;
var UCF_KILLCITIZEN = 10;
var UCF_HUT_FRIGHTEN = 11;

var UTYF_FLAGLESS = 30;
var UTYF_PROVIDES_RANSOM = 31;
var UTYF_FLAGLESS = 29;
var UTYF_PROVIDES_RANSOM = 30;

/**********************************************************************//**
Return true iff units of the given type can do the specified generalized
Expand Down
8 changes: 8 additions & 0 deletions freeciv/apply_patches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
# 0060-Check-C23-nullptr-usability-as-a-sentinel.patch
# C23 compile fix
# RM #475
# 0048-Handle-CoastStrict-units-correctly-on-city-removal.patch
# Fix to unit placement after city destruction
# RM #525
# 0061-savegame-Correct-loading-last-turn-change-time.patch
# Savegame loading fix
# RM #545

# Not in the upstream Freeciv server
# ----------------------------------
Expand Down Expand Up @@ -61,6 +67,8 @@ declare -a PATCHLIST=(
"backports/0054-Fix-inconsistent-city-workers-after-vision-loss"
"backports/0049-Trigger-action-system-when-client-requests-activity-"
"backports/0060-Check-C23-nullptr-usability-as-a-sentinel"
"backports/0048-Handle-CoastStrict-units-correctly-on-city-removal"
"backports/0061-savegame-Correct-loading-last-turn-change-time"
"RevertAmplio2ExtraUnits"
"meson_webperimental"
"metachange"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
From 89783a69caa289e5300ef7f49fe3d0678d170464 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <[email protected]>
Date: Thu, 2 May 2024 19:46:44 +0300
Subject: [PATCH 48/49] Handle CoastStrict units correctly on city removal

See RM #525

Signed-off-by: Marko Lindqvist <[email protected]>
---
server/citytools.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/server/citytools.c b/server/citytools.c
index 24fc2bad71..efe6df6691 100644
--- a/server/citytools.c
+++ b/server/citytools.c
@@ -1710,6 +1710,7 @@ void remove_city(struct city *pcity)
struct dbv tile_processed;
struct tile_list *process_queue;
const char *ctl = city_tile_link(pcity);
+ const struct civ_map *nmap = &(wld.map);

CALL_PLR_AI_FUNC(city_lost, powner, powner, pcity);
CALL_FUNC_EACH_AI(city_destroyed, pcity);
@@ -1742,19 +1743,23 @@ void remove_city(struct city *pcity)
bool moved;
const struct unit_type *punittype = unit_type_get(punit);

- if (is_native_tile(punittype, pcenter)) {
+ /* can_exist_at_tile() would give wrong results, as
+ * the city is still on map. */
+ if (is_native_tile(punittype, pcenter)
+ && (!utype_has_flag(punittype, UTYF_COAST_STRICT)
+ || is_safe_ocean(nmap, pcenter))) {
continue;
}

unit_activity_handling(punit, ACTIVITY_IDLE, ACTION_NONE);
moved = FALSE;
- adjc_iterate(&(wld.map), pcenter, tile1) {
+ adjc_iterate(nmap, pcenter, tile1) {
struct unit *ptrans;

- if (!moved && is_native_tile(punittype, tile1)) {
+ if (!moved && can_exist_at_tile(nmap, punittype, tile1)) {
if (adv_could_unit_move_to_tile(punit, tile1) == 1) {
/* Move */
- if (!can_unit_survive_at_tile(&(wld.map), punit, tile1)) {
+ if (!can_unit_survive_at_tile(nmap, punit, tile1)) {
/* It may be impossible to survive at the tile even if it is
* native. See UTYF_COAST_STRICT */
ptrans = transporter_for_unit_at(punit, tile1);
@@ -1798,7 +1803,7 @@ void remove_city(struct city *pcity)

tile_list_pop_front(process_queue);
dbv_set(&tile_processed, tile_index(ptile));
- adjc_iterate(&(wld.map), ptile, piter) {
+ adjc_iterate(nmap, ptile, piter) {
struct city *other_city;

if (dbv_isset(&tile_processed, tile_index(piter))) {
@@ -1814,7 +1819,7 @@ void remove_city(struct city *pcity)

if (!uclass_has_flag(pclass, UCF_BUILD_ANYWHERE)
&& !is_native_tile(punit->utype, piter)
- && !is_city_channel_tile(&(wld.map), pclass, piter, pcenter)) {
+ && !is_city_channel_tile(nmap, pclass, piter, pcenter)) {
notify_player(unit_owner(punit), unit_tile(punit),
E_UNIT_LOST_MISC, ftc_server,
_("When %s was disbanded your %s in %s was trapped, "
--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
From bc38b9d85bc11632745a040edfd12bfe0954b160 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <[email protected]>
Date: Fri, 3 May 2024 23:34:48 +0300
Subject: [PATCH 61/61] savegame: Correct loading last turn change time

The value was erroneously rounded down to full seconds,
while it's stored with 1/100 second accuracy in the savegame.

Reported by alain_bkr

See RM #545

Signed-off-by: Marko Lindqvist <[email protected]>
---
server/savegame/savegame2.c | 2 +-
server/savegame/savegame3.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/server/savegame/savegame2.c b/server/savegame/savegame2.c
index f5bbd75fdf..ad319a2033 100644
--- a/server/savegame/savegame2.c
+++ b/server/savegame/savegame2.c
@@ -1971,7 +1971,7 @@ static void sg_load_game(struct loaddata *loading)
= !secfile_lookup_bool_default(loading->file, TRUE, "game.save_players");

game.server.turn_change_time
- = secfile_lookup_int_default(loading->file, 0, "game.last_turn_change_time") / 100;
+ = secfile_lookup_int_default(loading->file, 0, "game.last_turn_change_time") / 100.0;
}

/* =======================================================================
diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c
index 31a2ed11e0..f3d8fbed42 100644
--- a/server/savegame/savegame3.c
+++ b/server/savegame/savegame3.c
@@ -2234,7 +2234,7 @@ static void sg_load_game(struct loaddata *loading)
= !secfile_lookup_bool_default(loading->file, TRUE, "game.save_players");

game.server.turn_change_time
- = secfile_lookup_int_default(loading->file, 0, "game.last_turn_change_time") / 100;
+ = secfile_lookup_int_default(loading->file, 0, "game.last_turn_change_time") / 100.0;
}

/************************************************************************//**
--
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=16570b44e264909b17651615ca58d3d9b74f8a64
FCREV=c9cc2581acba9f7c7dd7abd1be856f3722902eb1

ORIGCAPSTR="+Freeciv.Devel-\${MAIN_VERSION}-2024.Apr.09"
ORIGCAPSTR="+Freeciv.Devel-\${MAIN_VERSION}-2024.Apr.17"

# 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 ed58a33

Please sign in to comment.