Follow-up Comment #3, bug #23605 (project freeciv):

(gdb) print punittype
$4 = (const struct unit_type *) 0x9cdfa0 <improvement_types+26112>
(gdb) print (struct impr_type)*punittype
$5 = {item_number = 68, name = {
    _private_translated_ = 0x9cdfb0 <improvement_types+26128> "Stable", 
    _private_vernacular_ = "Stable", '\000' <repeats 41 times>, 
    _private_rulename_ = "Stable", '\000' <repeats 41 times>}, 
[...]
(gdb) up
[...]
(gdb) print *choice
$7 = {type = CT_BUILDING, value = {
    advance = 0x9cdfa0 <improvement_types+26112>, 
[...]


I think the problem is that kill_something_with() calls
dai_choose_role_unit(..., L_FERRYBOAT, ...) (line 1298) and then assumes that
'choice' contains a unit type.

The player knows no ferry units, so dai_choose_role_unit() probably returned
FALSE, which kill_something_with() would have ignored.

In this case 'choice' contained Stable, presumably left over from some
previous deliberations.

I don't see anything about the code path that's specific to the 'Horse'
ruleset. Perhaps in most rulesets 'choice' happens to contain a unit type and
we get away with it?

I suspect the answer is that kill_something_with() should check the return of
dai_choose_role_unit() here, and possibly choice->type too.

However, no caller of dai_choose_role_unit() checks its return value. In at
least one case it looks like the caller relies on the old value at 'choice'
persisting if dai_choose_role_unit() can't find a unit. So I'm not sure if
that is the correct fix.

    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?23605>

_______________________________________________
  Message sent via/by Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
[email protected]
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to