This is the mail archive of the
xconq7@sources.redhat.com
mailing list for the Xconq project.
Re: Bug in the attack/fire code?
- From: Lincoln Peters <peters2000 at mindspring dot com>
- To: Hans Ronne <hronne at pp dot sbbs dot se>
- Cc: Xconq mailing list <xconq7 at sources dot redhat dot com>
- Date: 06 Aug 2002 16:35:50 -0700
- Subject: Re: Bug in the attack/fire code?
- References: <l03130300b975fb40292f@[217.115.38.26]>
On Tue, 2002-08-06 at 15:58, Hans Ronne wrote:
> Yes. There are two strange things here. First, the unit should not be able
> to fire at all if it does not have enough torpedoes. So it should never
> reach a supply of -1. From a quick look at the code, I think I have
> identified the bug. check_fire_at_action calls enough_ammo, which checks if:
>
> unit->supply[m] < um_consumption_per_attack(unit->type, m))
>
> However, this is the material used for direct attack (in your case
> "antimatter"), Clearly check_fire_at_action needs to check
> um_consumption_per_fire (torpedoes) instead. The fire code will use
> um_consumption_per_attack, but only as a fallback if
> um_consumption_per_fire is not defined (similar to its using the hit-chance
> table as a fallback if fire-hit-chance is not defined). So in this case the
> code should check um_consumption_per_fire first and then
> um_consumption_per_attack. Which it blatantly fails to do.
Then it makes sense that such a crazy thing happened. And I've never
seen what happens when a starship runs out of antimatter, because, like
in galaxy.g, a ship that is out of antimatter is both unable to fight
and unable to move, and so I've tried to avoid that situation like the
plague.
>
> The other strange thing is that a direct attack should still work if the
> unit runs out of torpedoes. The relevant piece of code (from
> advance_into_cell) looks loke this:
>
> /* Somebody else's unit, try to victimize it in
> various ways, trying coexistence only as a last
> resort. */
> rslt = check_capture_action(unit, unit, other);
> if (valid(rslt)) {
> net_prep_capture_action(unit, unit, other);
> return TRUE;
> }
> rslt = check_overrun_action(unit, unit, x, y, z, 100);
> if (valid(rslt)) {
> net_prep_overrun_action(unit, unit, x, y, z, 100);
> return TRUE;
> }
> if (reason && rslt == A_ANY_NO_AMMO)
> *reason = (HistEventType)rslt;
> rslt = check_attack_action(unit, unit, other, 100);
> if (valid(rslt)) {
> net_prep_attack_action(unit, unit, other, 100);
> return TRUE;
> }
> if (reason && rslt == A_ANY_NO_AMMO)
> *reason = (HistEventType)rslt;
> rslt = check_fire_at_action(unit, unit, other, -1);
> if (valid(rslt)) {
> net_prep_fire_at_action(unit, unit, other, -1);
> return TRUE;
> }
Shouldn't there be some "else" statements in there to prevent more than
one possible course of action being chosen?