Project

General

Profile

Bug #761808

Leader and an enemy unit overlap in the same tile

Added by fomalhaut pa about 2 years ago. Updated about 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:

Description

2.6.0-beta3

This bug occurs under the following conditions;
-Player has only one city and the city population is 1.
-The city supports a ferryboat.
-The ferryboat is sailing with Leader.

If an enemy unit occupy and destroy the city, Leader and an enemy unit overlap.
Because Leader escapes to the same tile.

---displayed message---
in begin_phase() [../../../../server/srv_main.c::1134]: assertion 'pplayers_allied(((punit)->owner), ((punit2)->owner))' failed.
( 19, 23) at "Plains"
Please report this message at https://www.hostedredmine.com/projects/freeciv
in begin_phase() [../../../../server/srv_main.c::1134]: assertion 'pplayers_allied(((punit)->owner), ((punit2)->owner))' failed.
( 19, 23) at "Plains"
Please report this message at https://www.hostedredmine.com/projects/freeciv

overlap.sav.bz2 (14.4 KB) overlap.sav.bz2 fomalhaut pa, 2018-06-25 03:45 PM
m-30-noble-cargo-teleport-homecity.patch (5.37 KB) m-30-noble-cargo-teleport-homecity.patch Jacob Nevins, 2018-06-26 11:48 PM
26-noble-cargo-teleport-homecity.patch (5.38 KB) 26-noble-cargo-teleport-homecity.patch Jacob Nevins, 2018-06-26 11:48 PM
25-noble-cargo-teleport-homecity.patch (5.4 KB) 25-noble-cargo-teleport-homecity.patch Jacob Nevins, 2018-06-26 11:48 PM
overlap2.sav.bz2 (15.2 KB) overlap2.sav.bz2 S2_6 test savegame with two victim cities Jacob Nevins, 2018-06-26 11:48 PM
25_leader_cargo.sav.bz2 (13.6 KB) 25_leader_cargo.sav.bz2 S2_5 test savegame Jacob Nevins, 2018-06-26 11:49 PM

History

#1 Updated by Jacob Nevins about 2 years ago

I think I understand the setup, but just in case we can't reproduce it, do you have a save game (preferably from before the city is conquered)?

#2 Updated by fomalhaut pa about 2 years ago

I think the escaping message is inappropriate when the city goes into ruin.
(Leader escaped the destruction of "Unit name", and fled to "City name".)

#3 Updated by Jacob Nevins about 2 years ago

Confirmed, and I can see we don't handle this case.
unit_enter_city() -> remove_city() -> wipe_unit() -> wipe_unit_full() -> try_to_save_unit(cargo)
At this point, the doomed city still exists, so the leader goes there.
Not sure what to do. Could add a server.dying flag like units. In that case the leader definitely dies and the victim loses the game.
Could maybe check to see if there is an enemy unit on tile, and if not (e.g. occupychance=0), teleport into the doomed city? That gives the victim a (slim) chance at survival.

#4 Updated by Jacob Nevins about 2 years ago

Actually, occupychance is irrelevant here. By the time we're trying to save cargo, the conquering unit is already in the city.

Two easy-ish approaches:
  1. Add a check in try_to_save_unit() or a callee for whether the destination tile has a non-allied unit on it. That would catch this case; if there is some corner case where a city is destroyed without being conquered (disaster? migration?), then the Leader could turn up in the ruins, rather than immediately losing the game.
  2. When wipe_unit_full() is called with ULR_CITY_LOST, use that to pass a pexclcity to find_closest_city() (via try_to_save_unit()). In that case, destruction of the Leader's transport's home city would always kill the Leader (and lose the game).

#5 Updated by Marko Lindqvist about 2 years ago

Jacob Nevins wrote:

  1. When wipe_unit_full() is called with ULR_CITY_LOST, use that to pass a pexclcity to find_closest_city() (via try_to_save_unit()). In that case, destruction of the Leader's transport's home city would always kill the Leader (and lose the game).

Doesn't it find an alternative city in that case? (assuming it's not the last city)

#6 Updated by Jacob Nevins about 2 years ago

Yes; I was only thinking of the OP's predicament (where the conquered city is the last one).

This situation is also relevant where there is more than one; option 1 would kill the Leader unnecessarily in that situation. So we should do option 2.

#7 Updated by Jacob Nevins about 2 years ago

Attached patches implement option 2.

Attached some more savegames to demonstrate the issue/fix.

#8 Updated by Jacob Nevins about 2 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF