<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://manicpop.org/gewiki/index.php?action=history&amp;feed=atom&amp;title=Classic_bug%3A_Maintenance_omits_cloak_repair</id>
	<title>Classic bug: Maintenance omits cloak repair - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://manicpop.org/gewiki/index.php?action=history&amp;feed=atom&amp;title=Classic_bug%3A_Maintenance_omits_cloak_repair"/>
	<link rel="alternate" type="text/html" href="https://manicpop.org/gewiki/index.php?title=Classic_bug:_Maintenance_omits_cloak_repair&amp;action=history"/>
	<updated>2026-10-20T14:44:05Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.2</generator>
	<entry>
		<id>https://manicpop.org/gewiki/index.php?title=Classic_bug:_Maintenance_omits_cloak_repair&amp;diff=1559&amp;oldid=prev</id>
		<title>CodexBot: Link first command references to command pages</title>
		<link rel="alternate" type="text/html" href="https://manicpop.org/gewiki/index.php?title=Classic_bug:_Maintenance_omits_cloak_repair&amp;diff=1559&amp;oldid=prev"/>
		<updated>2026-10-12T02:14:47Z</updated>

		<summary type="html">&lt;p&gt;Link first command references to command pages&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Classic bug&lt;br /&gt;
|id=GE-BUG-044&lt;br /&gt;
|affected=Classic 3.2e and published classic source&lt;br /&gt;
|status=Verified in source; corrected and later refined in ge-next&lt;br /&gt;
|fixed=ge-next 0.2; maintenance system overhauled in 0.3&lt;br /&gt;
|source=&amp;lt;code&amp;gt;cmd_maint()&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;repairship()&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;cloakstat()&amp;lt;/code&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
Classic maintenance does not repair a damaged cloaking device when paid maintenance finishes. It repairs the hull and explicitly restores every other classic damageable system, then announces that repairs and general maintenance are complete while the cloak can remain damaged and unusable.&lt;br /&gt;
&lt;br /&gt;
The cloak does eventually repair itself through the ordinary background system repair logic. That does not make the maintenance result correct: the player has paid for complete maintenance, received a completion announcement, and can still be left with a system listed as damaged.&lt;br /&gt;
&lt;br /&gt;
== Classic maintenance duration ==&lt;br /&gt;
The [[Maintenance command|&amp;lt;code&amp;gt;MAINT&amp;lt;/code&amp;gt;]] command bases its initial repair counter only on hull damage:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
warsptr-&amp;gt;repair = (unsigned)(warsptr-&amp;gt;damage / 3.0) + 1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each maintenance update removes three points of hull damage. It then derives a new counter from the remaining hull damage:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
if (ptr-&amp;gt;damage &amp;gt; 3.0)&lt;br /&gt;
    ptr-&amp;gt;damage -= 3.0;&lt;br /&gt;
else&lt;br /&gt;
    ptr-&amp;gt;damage = 0.0;&lt;br /&gt;
&lt;br /&gt;
ptr-&amp;gt;repair = (int)(ptr-&amp;gt;damage / 3.0);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
No system-damage value contributes to this duration. A badly damaged system does not make maintenance take longer than the hull alone requires.&lt;br /&gt;
&lt;br /&gt;
== Systems restored at completion ==&lt;br /&gt;
When the hull-derived counter reaches its completion threshold, classic resets the hull and these systems:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
ptr-&amp;gt;damage = 0.0;&lt;br /&gt;
ptr-&amp;gt;phasr = 100;&lt;br /&gt;
ptr-&amp;gt;tactical = 0;&lt;br /&gt;
ptr-&amp;gt;helm = 0;&lt;br /&gt;
ptr-&amp;gt;firecntl = 0;&lt;br /&gt;
ptr-&amp;gt;shieldstat = SHIELDDN;&lt;br /&gt;
ptr-&amp;gt;shield = 0;&lt;br /&gt;
ptr-&amp;gt;topspeed = shipclass[ptr-&amp;gt;shpclass].max_warp;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It then prints &amp;lt;code&amp;gt;MAINT7&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Repairs and general maintenance have been completed Sir!&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The classic damage model can damage six system categories: shields, phasers, fire control, cloak, tactical display, and helm. Five appear in the completion block. The cloak is the only one omitted.&lt;br /&gt;
&lt;br /&gt;
== Cloak damage remains ==&lt;br /&gt;
Random system damage stores cloak damage as a negative value:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
ptr-&amp;gt;cloak = 0 - (int)rndm((ptr-&amp;gt;damage + 10.0));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The [[Cloak command|&amp;lt;code&amp;gt;CLOAK&amp;lt;/code&amp;gt;]] command rejects a negative value and reports that the device is damaged. &amp;lt;code&amp;gt;REP SYS&amp;lt;/code&amp;gt; likewise lists the damaged cloaking device.&lt;br /&gt;
&lt;br /&gt;
Nothing in classic &amp;lt;code&amp;gt;repairship()&amp;lt;/code&amp;gt; changes that value. A ship can therefore receive the maintenance-complete announcement and immediately still receive the damaged-device response when trying to cloak.&lt;br /&gt;
&lt;br /&gt;
== Why the cloak eventually recovers ==&lt;br /&gt;
Classic also has passive system repair. &amp;lt;code&amp;gt;cloakstat()&amp;lt;/code&amp;gt; advances a damaged cloak by one point on every ship-state update:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
if (ptr-&amp;gt;cloak &amp;lt; 0)&lt;br /&gt;
{&lt;br /&gt;
    ++ptr-&amp;gt;cloak;&lt;br /&gt;
    if (ptr-&amp;gt;cloak == 0)&lt;br /&gt;
        prfmsg(CLREPR);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The main ship-state loop calls the relevant routines in this order:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
repairship(wptr, zothusn);&lt;br /&gt;
shieldstat(wptr, zothusn);&lt;br /&gt;
cloakstat(wptr, zothusn);&lt;br /&gt;
...&lt;br /&gt;
checkdam(wptr, zothusn);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On the final maintenance update, &amp;lt;code&amp;gt;repairship()&amp;lt;/code&amp;gt; first announces that maintenance is complete without touching the cloak. &amp;lt;code&amp;gt;cloakstat()&amp;lt;/code&amp;gt; then repairs only one point. Unless that point reaches zero, the cloak remains damaged after the completion announcement.&lt;br /&gt;
&lt;br /&gt;
This passive repair can make the defect seem intermittent. A lightly damaged cloak may naturally reach zero before paid maintenance finishes. A more severely damaged cloak does not.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Consider a ship that begins maintenance with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Hull damage:   60&lt;br /&gt;
Cloak status: -50&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Classic maintenance reduces 60 points of hull damage by three per maintenance update and enters its completion block after 19 updates. During those updates, the separate cloak routine repairs approximately 19 points. The exact cloak value around the completion call depends on where in the update cadence the damage and command occurred, but it can still be roughly &amp;lt;code&amp;gt;-31&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The player sees the general maintenance-complete message, yet the cloak still requires about 31 more ship-state updates before &amp;lt;code&amp;gt;cloakstat()&amp;lt;/code&amp;gt; reaches zero and reports that the device is operational. Paid maintenance has repaired the hull and every explicitly listed system, but not the cloak.&lt;br /&gt;
&lt;br /&gt;
== Related classic shield behavior ==&lt;br /&gt;
Classic&amp;#039;s completion block is also unnecessarily destructive toward healthy shields:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
ptr-&amp;gt;shieldstat = SHIELDDN;&lt;br /&gt;
ptr-&amp;gt;shield = 0;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Those assignments run regardless of whether the shields are damaged. If a healthy shield system is up or retains a positive charge when maintenance finishes, classic lowers it and discards that charge. This is not the same omission as the cloak bug, because damaged shields are repaired; it is the opposite state-management problem. Maintenance changes a healthy operating system when it only needs to normalize a damaged one.&lt;br /&gt;
&lt;br /&gt;
This behavior informed the later ge-next cloak refinement.&lt;br /&gt;
&lt;br /&gt;
== Initial correction in ge-next 0.2 ==&lt;br /&gt;
During development of ge-next 0.2, the maintenance completion block was expanded to assign zero to &amp;lt;code&amp;gt;cloak&amp;lt;/code&amp;gt;. A negative damage value was therefore cleared when maintenance completed instead of being left for passive repair.&lt;br /&gt;
&lt;br /&gt;
The same January 2025 maintenance change refined shield handling. Instead of always lowering shields and erasing their charge, ge-next changed the reset to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
if (ptr-&amp;gt;shieldstat == SHIELDDM)&lt;br /&gt;
    ptr-&amp;gt;shieldstat = SHIELDDN;&lt;br /&gt;
if (ptr-&amp;gt;shield &amp;lt; 1)&lt;br /&gt;
    ptr-&amp;gt;shield = 0;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Damaged shields were normalized to a safe down state, and a negative shield value was cleared. Healthy shields and positive charge were preserved. This was the appropriate general rule: maintenance should repair a damaged system without unnecessarily disabling a healthy active one.&lt;br /&gt;
&lt;br /&gt;
The initial cloak correction did not yet follow that rule. It assigned zero unconditionally. That fixed the classic omission, but it could also turn off an operational cloak if maintenance completed while the cloak had a positive state.&lt;br /&gt;
&lt;br /&gt;
== Refinement in ge-next 0.2.6 ==&lt;br /&gt;
ge-next 0.2.6 made the cloak correction conditional in the same manner as the earlier shield adjustment:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
if (ptr-&amp;gt;cloak &amp;lt; 1)&lt;br /&gt;
    ptr-&amp;gt;cloak = 0;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
A negative cloak value is repaired, and an already inactive value remains inactive. A positive value representing an operational cloak is left alone. Maintenance therefore no longer finishes with cloak damage, but it also no longer uncloaks a ship merely because repairs completed.&lt;br /&gt;
&lt;br /&gt;
== Maintenance overhaul in ge-next 0.3 ==&lt;br /&gt;
ge-next 0.3 replaced the hull-only completion model with a unified accounting of outstanding repairs. Hull, shields, cloak, helm, tactical display, phasers, weapon controls, the additional launcher systems introduced by ge-next, and warp damage are considered by the maintenance routines.&lt;br /&gt;
&lt;br /&gt;
Damaged systems are repaired progressively instead of all being reset on the last hull-repair update. Maintenance does not announce completion until &amp;lt;code&amp;gt;repair_needed()&amp;lt;/code&amp;gt; confirms that no applicable hull or system damage remains. The cloak is explicitly counted and repaired in that process.&lt;br /&gt;
&lt;br /&gt;
This later design removes the broader assumption that a timer derived solely from hull damage can represent complete ship maintenance.&lt;br /&gt;
&lt;br /&gt;
[[Category:Classic bugs: Ships]]&lt;br /&gt;
[[Category:Classic bugs: User interface]]&lt;br /&gt;
&lt;br /&gt;
{{GE navigation}}&lt;/div&gt;</summary>
		<author><name>CodexBot</name></author>
	</entry>
</feed>