Classic bug: Replacement systems retain old charge
| Bug ID | GE-BUG-049 |
|---|---|
| Affected versions | Classic 3.2e and ge-next through 0.3.2 |
| Status | Verified in source; corrected in ge-next |
| Fixed in | ge-next 0.3.3 |
| Primary source | cmd_new() in GECMDS.C
|
Summary
Buying a different shield or phaser Mark replaces the installed system but does not reset the charge stored in that system. The charge belonging to the old hardware is therefore carried into the replacement.
This is most visible when downgrading shields. Shield capacity depends on the installed Mark, so a lower-Mark replacement can retain more charge than it is designed to hold. Phaser charge is stored differently and cannot exceed its normal 100-percent limit through this bug, but a replacement phaser still inherits the old unit's arbitrary charge rather than receiving a defined initial charge of its own.
Shield behavior
Shield charge is stored as a raw integer. Its normal maximum is:
40 + (shieldtype * 10)
A fully charged Mark-19 shield therefore stores 230 charge units. A Mark-1 shield normally holds only 50.
When NEW SHIELD succeeds, classic changes only the class:
warsptr->shieldtype = type;
It does not alter shield or shieldstat. Downgrading a fully charged Mark-19 shield to Mark-1 consequently leaves 230 units in a system whose capacity is 50. REPORT SYSTEMS can show the Mark-1 shield at 460 percent charge.
The condition is functional, not merely cosmetic. shieldchg() does nothing while charge is already at or above the new maximum, but it also does not clamp that charge. Incoming hits consume the oversized bank, giving the lower-Mark shield substantially more stored charge than it should have. The new Mark still controls the shield's other class-dependent behavior, so the result is an inconsistent mixture of the new shield class and the old shield bank.
Upgrading has the opposite numerical effect: the old raw charge occupies a smaller percentage of the larger bank. In either direction, energy stored in the removed system is incorrectly transferred to its replacement.
Phaser behavior
Phaser charge is stored as a percentage from 0 through 100 rather than as a class-dependent raw capacity. Phaser Mark controls properties such as range, damage, and recharge rate, while phasr records the current charge percentage.
Classic again changes only the class:
warsptr->phasrtype = type;
Consequently, a 100-percent charged phaser remains at 100 percent after either an upgrade or downgrade and can be fired immediately. A partially charged phaser preserves the same percentage. This does not create a percentage above 100, but it still transfers the old unit's stored charge into brand-new hardware.
Reproduction
The shield overcharge can be reproduced as follows:
- Install a high-Mark shield and allow it to charge fully.
- Orbit Zygor and buy a substantially lower shield Mark with
NEW SHIELD. - Raise the shield if necessary and run
REPORT SYSTEMS.
The report identifies the newly purchased lower Mark but can show charge well above 100 percent. Combat consumes that excess charge before the shield bank returns to its ordinary range.
For phasers, charge a phaser bank, buy another Mark, and run REPORT SYSTEMS. The replacement retains the old percentage and remains immediately usable if that percentage meets the firing threshold.
Correction in ge-next 0.3.3
ge-next 0.3.3 treats each purchase as installation of a new system rather than allowing it to inherit the previous system's charge. After a successful shield purchase it installs the selected Mark, places the shield in the down state, and clears its charge:
warsptr->shieldtype = (byte)type;
warsptr->shieldstat = SHIELDDN;
warsptr->shield = 0;
After a successful phaser purchase it installs the selected Mark with a full charge:
warsptr->phasrtype = (byte)type;
warsptr->phasr = 100;
The new shield must be raised and charged normally. The new phaser is immediately ready to fire. This matches the fully charged phasers installed on new ships and avoids starting an automatic recharge cycle immediately after a new phaser is purchased.
Home · Play · Reference · Versions & history · Sysop · Development · Classic bugs