Summary: Incorrect sabotage handling for diplomats
                 Project: Freeciv
            Submitted by: None
            Submitted on: Monday 07/26/2010 at 19:31 CEST
                Category: None
                Severity: 3 - Normal
                Priority: 5 - Normal
                  Status: None
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
                 Release: 2.2.1
         Discussion Lock: Any
        Operating System: None
         Planned Release: 



The base sabotage chance for a diplomat is half that of the spy, yet could be
the same by changing the client.

This is either a bug (when the base sabotage chance should be the same for
both) or a security flaw (when it should not be possible to upgrade the
sabotage chance on the client). Since I don't know the intended behavior, I
cannot asses this.

In server/diplomats.c:835, function diplomat_sabotage(), the base success
probability is chosen depending on whether a specific target is chosen, or

  int success_prob = (improvement >= B_LAST ? game.info.diplchance
                      : game.info.diplchance / 2);

A few lines further down (line 848) the improvement is set to B_LAST if the
unit is not a spy:

  if (!unit_has_type_flag(pdiplomat, F_SPY))
    improvement = B_LAST;

So on line 835, the 'improvement' comes straight from the client unmodified,
and based on that, the base success chance is chosen.

This value is set in the gui, for example in
client/gui-gtk-2.0/diplomat_dialog.c:120, function

    request_diplomat_action(DIPLOMAT_SABOTAGE, diplomat_id,
                            diplomat_target_id, -1);

The last parameter (-1) is the improvement which will be the parameter
'improvement' in diplomat_sabotage() in server/diplomats.c:835. Since -1 <
B_LAST, this means that a diplomat will sabotage with half the base success
chance. This can be changed on the client by simply sending B_LAST as the
last parameter on request_diplomat_action()


Reply to this item at:


  Message sent via/by Gna!

Freeciv-dev mailing list

Reply via email to