Classic bug: Attacking troop surrender overwrite

Bug ID GE-BUG-035
Affected versions Classic 3.2e and published classic source
Status Verified in source
Fixed in ge-next 0.3.3
Primary source GECMDS.C: attack_men()

Summary

When a badly outmatched attacking troop force surrenders, classic says those troops joined the planetary force, but a later assignment discards them. The same assignment can also undo troop losses reported as collateral damage during an attack.

Symptoms

The defender receives a surrender message, yet the planet retains only the surviving defenders. Surrendered attackers disappear. In a separate path, the attack can report planetary troops destroyed as collateral damage while leaving those troops in the planet's inventory.

Cause

attack_men() tracks surviving defenders in the local variable left2. The surrender branch adds surviving attackers directly to the planet's stored troop quantity, and the collateral-damage loop can subtract troops directly from that same quantity. Near the end of the routine, an unconditional assignment replaces the stored quantity with left2, losing either earlier change.

Correction in ge-next 0.3.3

Both the 16-bit and 32-bit implementations now keep surrendered attackers and troop collateral losses in left2. The routine writes that final count to the planet record once, after resolving the attack. Other item collateral losses still update their own inventory fields directly. If collateral damage removes the last defenders, the existing victory check now sees that result.

Porting guidance

Resolve every change to the defending troop count in one working value, then commit it once. Do not mix direct record writes with a later assignment from a separate combat-result variable.