Bouncing units and alliance break

What would you like to see in Freeciv? Do you have a good idea what should be improved or how?
Wahazar
Elite
Posts: 338
Joined: Mon Jul 02, 2018 1:49 pm

Bouncing units and alliance break

Postby Wahazar » Tue Jun 30, 2020 12:44 am

I'm trying to understand, how stack conflicts are resolved in case of unit being transported on allied ships, while alliance was broken.
There are two functions (freeciv 2.6) in server/unittools.c: throw_units_from_illegal_cities and resolve_stack_conflicts.
First function is using unit_transport_unload_send to handle units on transports, while second units is using bounce_unit function,
which move unit at no movement points cost.

If second function is called for units outside cities, there are at least 3 exploits possible:
1. teleport unit from land tile to adjacent land tile at no mp cost
2. unload any unit from transport at no mp cost - this unit can attack instantly, in same turn
3. unload unit, which is not provided for unloading (no disembark flag for unreachable transport).

Is it possible to fix above exploits by:
a) changing unit_move(punit, ptile, 0, NULL) to unit_move(punit, ptile, punit->moves_left, NULL)
b) adding iteration of unit unloading inresolve_stack_conflicts, similar to throw_units_from_illegal_cities?
Augmented2 ruleset/modpack for freeciv2.6: viewtopic.php?f=11&t=91047

Wahazar
Elite
Posts: 338
Joined: Mon Jul 02, 2018 1:49 pm

Re: Bouncing units and alliance break

Postby Wahazar » Tue Jun 30, 2020 8:56 am

Correction to above fix: deducting all mp is too harsh and also doesn't resolve all issues (bounce exploit can be still used to move units with 0 moves left).
1 mp should be used, if unit have some mp left, if there is no moves left, unit is killed - bad luck.

So instead of

Code: Select all

unit_move(punit, ptile, 0, NULL);

should be

Code: Select all

unit_move(punit, ptile, 1, NULL);

and additional check of punit->moves_left>0 before square_iterate
Augmented2 ruleset/modpack for freeciv2.6: viewtopic.php?f=11&t=91047

Ignatus
Elite
Posts: 338
Joined: Mon Nov 06, 2017 12:05 pm
Location: St.Petersburg, Russia
Contact:

Re: Bouncing units and alliance break

Postby Ignatus » Tue Jun 30, 2020 5:08 pm

I have once made a workaround for slowing invasions, and also to not reset UWT:Ihnatus/LT2_6 branch.

Maybe bouncing is not a good solution at all - just let's leave wrong stacks as they are, just block the units from any action except leaving their position for a right one.

Wahazar
Elite
Posts: 338
Joined: Mon Jul 02, 2018 1:49 pm

Re: Bouncing units and alliance break

Postby Wahazar » Tue Jun 30, 2020 5:40 pm

Ignatus wrote:Maybe bouncing is not a good solution at all - just let's leave wrong stacks as they are, just block the units from any action except leaving their position for a right one.

It would be optimal, but I'm not sure if some assertions will strike back?
Augmented2 ruleset/modpack for freeciv2.6: viewtopic.php?f=11&t=91047

Wahazar
Elite
Posts: 338
Joined: Mon Jul 02, 2018 1:49 pm

Re: Bouncing units and alliance break

Postby Wahazar » Thu Jul 02, 2020 3:20 pm

After some discussion on discord, conclusion is that disbanding all units from conflicting stack is the most elegant and simple method of handling such problem, because:
  • teleporting units to nearest city/capital creates another exploit
  • leaving stack as is - you can't break alliance with bad guy effectively, he may still sit inside your stack
  • fixing existing bounce function is over-complicated and doesn't solve problem of back-stabbing - bad guy who breaks alliance can arrange situation when your units will be disbanded anyway
  • hijacking transport is also bad idea - create exploit of units transfer

Thus my proposal of handling on-field stack with mixed nationality is:
  • disband all conflicting players units standing on enemy land
  • disband all conflicting enemy units standing on player's land
  • disband all conflicting units on transports
  • disband units one-by-one until stack on neutral land is coherent.

Above consideration is valid for resolving on-field conflicting stacks function in unittools.c: resolve_stack_conflicts.
City conflicting units are resolved differently with use of throw_units_from_illegal_cities() and it can stay as is, because is not as abusive as resolve_stack_conflicts.
Augmented2 ruleset/modpack for freeciv2.6: viewtopic.php?f=11&t=91047