Jump to content

Classic bug: Revolt troop losses are reversed: Difference between revisions

From Galactic Empire wiki
Remove source-only line breaks from bug article
 
(No difference)

Latest revision as of 19:28, 8 October 2026

Bug ID GE-BUG-033
Affected versions Classic 3.2e message file and published source
Status Verified in source and message definition
Fixed in ge-next 0.01 (message-file release running on the classic 3.2e DLL)
Primary source Revolt calculation in plarti() and MESG30

Summary

When a planet revolts in classic GE, the distress message reverses the number of troops that joined the revolt and the number that were lost. It describes the surviving troops as slaughtered and says that all the others joined the revolt.

The revolt itself is processed correctly. The planet becomes free and retains the calculated number of surviving troops. Only the description in MESG30 is wrong.

Revolt calculation

During a planetary update, classic first determines whether population pressure and the tax rate make a revolt possible. If the population-based revolt value exceeds the defending troop count, a one-in-ten random check can trigger the revolt.

The troop result is then calculated as follows:

cnt = plptr->items[I_TROOPS].qty / ((gernd() % 8) + 2);
plptr->items[I_TROOPS].qty = cnt;

The random divisor is from 2 through 9. cnt is assigned back to the planet's troop inventory, so it is the number of troops that remain after the conflict. Once the planet owner is changed to **Free**, those troops are effectively the forces that survived and joined the revolt.

The same value is placed in the distress mail record:

mail.long1 = cnt;

When the mail is rendered, mail.long1 is passed to MESG30.

Reversed report

Classic defines MESG30 to say that the supplied number of troops were slaughtered and that the rest joined the revolt. That is the opposite of what the code did.

For example, suppose the planet had 9,000 troops and the random divisor was 3:

Troops before revolt:       9,000
Troops retained on planet:  3,000
Troops lost:                6,000

Classic passes 3,000 to the message, which reports that 3,000 troops were slaughtered and the remaining 6,000 joined the revolt. The database contains the reverse: 3,000 remain on the free planet and 6,000 are gone.

The error can make revolts appear much less or much more destructive than they really were. A planet owner reading the mail cannot use it to determine the actual troop strength left on the newly free planet without scanning it.

Cause

The value passed to the message was interpreted incorrectly when the message text was written. cnt is a survivor count, not a casualty count. The actual number lost would be:

original troop count - cnt

Classic does not preserve or pass that subtraction for the report. It passes only cnt, so the message must describe cnt as the troops that joined the revolt.

Correction in ge-next

ge-next 0.01 was a revised MSG/help/configuration package that ran on the unchanged classic 3.2e DLL. It corrected MESG30 to match the value already supplied by the executable:

...%s troops joined the revolt, the rest were lost.

No revolt probability, troop calculation, planet record, or executable code changed. The corrected message simply identifies the retained troop count properly.