Skip to content

Commit

Permalink
Fixed a crash when city removal left a unit stranded RM#81
Browse files Browse the repository at this point in the history
https://redmine.freeciv.org/issues/81

author: @cazfi
(nullptr changed to NULL by me)
  • Loading branch information
Lexxie9952 committed Feb 10, 2024
1 parent b6e1060 commit f2c31fa
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions freeciv/freeciv/server/citytools.c
Original file line number Diff line number Diff line change
Expand Up @@ -3464,14 +3464,17 @@ void city_landlocked_sell_coastal_improvements(struct tile *ptile)
****************************************************************************/
void city_refresh_vision(struct city *pcity)
{
v_radius_t vision_radius_sq = V_RADIUS(
(short int) get_city_bonus(pcity, EFT_CITY_VISION_RADIUS_SQ, V_MAIN),
(short int) get_city_bonus(pcity, EFT_CITY_VISION_RADIUS_SQ, V_INVIS),
(short int) get_city_bonus(pcity, EFT_CITY_VISION_RADIUS_SQ, V_SUBSURFACE)
);

vision_change_sight(pcity->server.vision, vision_radius_sq);
ASSERT_VISION(pcity->server.vision);
if (pcity->server.vision != NULL) {

v_radius_t vision_radius_sq = V_RADIUS(
(short int) get_city_bonus(pcity, EFT_CITY_VISION_RADIUS_SQ, V_MAIN),
(short int) get_city_bonus(pcity, EFT_CITY_VISION_RADIUS_SQ, V_INVIS),
(short int) get_city_bonus(pcity, EFT_CITY_VISION_RADIUS_SQ, V_SUBSURFACE)
);

vision_change_sight(pcity->server.vision, vision_radius_sq);
ASSERT_VISION(pcity->server.vision);
}
}

/************************************************************************//**
Expand Down Expand Up @@ -3576,8 +3579,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 != NULL) {
/* 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."),
Expand Down

0 comments on commit f2c31fa

Please sign in to comment.