-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Server: Backport 0017-Fix-city-removal-server-crashes.patch
Signed-off-by: Marko Lindqvist <[email protected]>
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
freeciv/patches/backports/0017-Fix-city-removal-server-crashes.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
From 37508b45f7591f3acb749afb223aeefcaeb76749 Mon Sep 17 00:00:00 2001 | ||
From: Marko Lindqvist <[email protected]> | ||
Date: Wed, 27 Dec 2023 15:11:56 +0200 | ||
Subject: [PATCH 17/17] Fix city removal server crashes | ||
|
||
When city removal wipes a unit that's not homed to the city, | ||
but on the same tile, recursive city refresh was crashing | ||
due to city vision and advisor data being already deleted. | ||
|
||
See RM #81 | ||
|
||
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 f760deb3e0..87917e0b77 100644 | ||
--- a/server/citytools.c | ||
+++ b/server/citytools.c | ||
@@ -3416,11 +3416,13 @@ void city_landlocked_sell_coastal_improvements(struct tile *ptile) | ||
****************************************************************************/ | ||
void city_refresh_vision(struct city *pcity) | ||
{ | ||
- v_radius_t vision_radius_sq | ||
- = V_RADIUS(get_city_bonus(pcity, EFT_CITY_VISION_RADIUS_SQ), 2, 2); | ||
+ if (pcity->server.vision != nullptr) { | ||
+ v_radius_t vision_radius_sq | ||
+ = V_RADIUS(get_city_bonus(pcity, EFT_CITY_VISION_RADIUS_SQ), 2, 2); | ||
|
||
- vision_change_sight(pcity->server.vision, vision_radius_sq); | ||
- ASSERT_VISION(pcity->server.vision); | ||
+ vision_change_sight(pcity->server.vision, vision_radius_sq); | ||
+ ASSERT_VISION(pcity->server.vision); | ||
+ } | ||
} | ||
|
||
/************************************************************************//** | ||
@@ -3525,8 +3527,11 @@ bool city_map_update_radius_sq(struct city *pcity) | ||
city_refresh_vision(pcity); | ||
} | ||
|
||
- /* If city is under AI control, update it */ | ||
- adv_city_update(pcity); | ||
+ /* City removal might be ongoing, and advisor data already deleted */ | ||
+ if (pcity->server.adv != nullptr) { | ||
+ /* If city is under AI control, update it */ | ||
+ adv_city_update(pcity); | ||
+ } | ||
|
||
notify_player(city_owner(pcity), city_tile(pcity), E_CITY_RADIUS_SQ, | ||
ftc_server, _("The size of the city map of %s is %s."), | ||
-- | ||
2.43.0 | ||
|