bugFreeciv - Bugs: bug #20747, Units in nested transport...

Show feedback again

bug #20747: Units in nested transport considered defensive units

Submitted by:  Emmet Hikory <persia>
Submitted on:  Sat Apr 20 04:48:01 2013  
Category: generalSeverity: 3 - Normal
Priority: 5 - NormalStatus: Fixed
Assigned to: Marko Lindqvist <cazfi>Open/Closed: Closed
Release: 2.4.99-r22731Operating System: GNU/Linux
Planned Release: 2.4.0, 2.5.0, 2.6.0Contains string changes: None

Add a New Comment (Rich MarkupRich Markup):

You are not logged in

Please log in, so followups can be emailed to you.


Tue Apr 30 08:13:22 2013, SVN revision 22793:

Transported unit that cannot be unloaded cannot be chosen as defender.

Patch by Emmet Hikory

See bug #20747

(Browse SVN revision 22793)

Marko Lindqvist <cazfi>
Project AdministratorIn charge of this item.
Tue Apr 30 08:13:16 2013, SVN revision 22792:

Transported unit that cannot be unloaded cannot be chosen as defender.

Patch by Emmet Hikory

See bug #20747

(Browse SVN revision 22792)

Marko Lindqvist <cazfi>
Project AdministratorIn charge of this item.
Sun Apr 21 00:45:05 2013, comment #3:

The same patch applies to S2_4 with a 1-line offset, and should be suitable there as well.

Emmet Hikory <persia>
Project Member
Sat Apr 20 23:53:46 2013, comment #2:

From code inspection, it appears that the same patch could also be applied to S2_4 (I'll test when my current autogames are complete), and that it would provide a similar benefit.

About combat.c:

get_virtual_defense_power() uses can_unit_exist_at_tile as a proxy for being able to defend, but in this function we don't know the actual unit (and it may not even currently exist for calls from advmilitary.c), so can't check to see if it happens to be transported when under attack. The specific unit certainly doesn't exist in unittools.c:find_a_good_partisan_spot(), although these aren't likely to be placed in transport, so it matters less.

can_unit_attack_all_at_tile() and can_unit_attack_any_at_tile() are potentially open to gameplay irregularities from players choosing when to load/unload unreachable units if unreachable protects/doesn't protect, and depending on the targets vectors of potential attackers. It would take a lot more than this type of check to work around that.

It may be that can_unit_attack_unit_at_tile() should check to see if the potential defender is capable of defense, but I suspect it is better not to do this, as units that can't defend just die, which is likely the desired behaviour, rather than anything that might prevent the attack.

Am I missing something else that might be related to this?

Emmet Hikory <persia>
Project Member
Sat Apr 20 23:03:40 2013, comment #1:

This affects both S2_4 and TRUNK, or? Also, I remember there being equivalent logic of "transported unit stepping out to defend" in defense value calculation in combat.c. Have you checked if it's ok in this respect?

Marko Lindqvist <cazfi>
Project AdministratorIn charge of this item.
Sat Apr 20 04:48:01 2013, original submission:

Units in nested transport are considered potential defensive units, although they are unable to unload or attack. Test case is to alter experimental ruleset to give Cruise Missile a defensive rating of 4, then load Cruise Missile in Mech. Inf. in Transport. Attack with something, and the missile is considered the defender.

From comments in the code, I suspect that having Missiles be potential defenders of Submarines and Stealth Fighters|Bombers being potential defenders of Carriers may similarly be bugs (these also don't happen because of the coincidental relation between the defense ratings of the transport and the cargo).

Discovered when considering allowing AttFromNonNative units to be able to also defend when non-native: thoughts on that idea appreciated, but the attached bugfix patch likely gets priority.

Emmet Hikory <persia>
Project Member


(Note: upload size limit is set to 1024 kB, after insertion of the required escape characters.)

Attach File(s):

Attached Files
file #17778:  check-unload-to-defend.patch added by persia (1kB - application/octet-stream)


Depends on the following items: None found

   bug dependencies.


Carbon-Copy List
  • -unavailable- added by cazfi (Posted a comment)
  • -unavailable- added by persia (Submitted the item)

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.


    Error: not logged in



    Follow 7 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue Apr 30 08:13:42 2013cazfiStatusReady For Test=>Fixed
    Sun Apr 28 23:38:10 2013cazfiDependencies-=>bugs #20722 is dependent
    Sun Apr 28 09:08:42 2013cazfiAssigned toNone=>cazfi
      Planned Release=>2.4.0, 2.5.0, 2.6.0
    Sun Apr 28 09:08:41 2013cazfiStatusNone=>Ready For Test
    Sat Apr 20 04:48:02 2013persiaAttached File-=>Added check-unload-to-defend.patch, #17778
    Show feedback again

    Back to the top

    Powered by Savane 3.1-cleanup