Skip to content

Commit

Permalink
Fixed three defects.
Browse files Browse the repository at this point in the history
  • Loading branch information
klei1984 committed Sep 24, 2024
1 parent f3d66b8 commit 8833083
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions defects.md
Original file line number Diff line number Diff line change
Expand Up @@ -780,13 +780,13 @@ As the video clip demonstrates there are at least four more odd behaviors:
<br>
<br>

221. Military units can increase maximum shots by buying upgrades for credits or by research. Buying upgrades is only possible until the upgrade cost remains below 800 credits while research is unlimited. Increasing unit ammunition by research is not possible which means that it is possible to upgrade shots beyond the number of available ammunition. It makes no sense to display more shots than the maximum ammunition on the Unit Info and Unit Statistics windows. The rationale is that on turn start the available shots is reset to the number of available ammunition which means that it was not a design intent to be able to fire shots till ammo depletes, then reload the unit within the same turn by a supply truck or comparable and fire again.
221. **[Fixed]** Military units can increase maximum shots by buying upgrades for credits or by research. Buying upgrades is only possible until the upgrade cost remains below 800 credits while research is unlimited. Increasing unit ammunition by research is not possible which means that it is possible to upgrade shots beyond the number of available ammunition. It makes no sense to display more shots than the maximum ammunition on the Unit Info and Unit Statistics windows. The rationale is that on turn start the available shots is reset to the number of available ammunition which means that it was not a design intent to be able to fire shots till ammo depletes, then reload the unit within the same turn by a supply truck or comparable and fire again.

222. **[Fixed]** The Unit Info and Unit Statistics windows display the unit actual and maximum hit points. The maximum hit points is stored as `unsigned short` by the UnitValues class, while unit current hit points are stored as `unsigned char` by the UnitInfo class. In case the maximum hit points of a building, or an alien concord unit, overflows the maximum value of `unsigned char` and unit current hit points become smaller than unit maximum hit points, then the automatic repair feature of buildings (cseg01:000F0D4C) connected to complexes with sufficient raw materials, or regeneration of alien concord units, kicks in. This leads to never ending cycles of wasting raw materials on automatic building repairs just to overflow the limit of current hit points again. See also defect 185 for reference. To properly fix the defect the save file format version needs to be updated. A temporary workaround to prevent this defective behavior could be to cap maximum unit hit points to the limit of `unsigned char`.

223. Research topic allocations are managed by a single function (cseg01:000D322D) by computer players, but the function is called from half a dozen call sites and in corner cases these call sites act upon research allocations inconsistently making it possible to end up with negative topic allocation values. When a new turn is started the game checks whether research center allocation of a topic is non zero in which case the turns to complete topic value is decreased by the allocation to topic value. In the corner case when allocation is negative this means that the turns to complete value actually increases due to subtraction of a negative value from it. The proposed defect fix is to make the algorithm more robust and do not allow negative allocations to be used in calculations.
223. **[Fixed]** Research topic allocations are managed by a single function (cseg01:000D322D) by computer players, but the function is called from half a dozen call sites and in corner cases these call sites act upon research allocations inconsistently making it possible to end up with negative topic allocation values. When a new turn is started the game checks whether research center allocation of a topic is non zero in which case the turns to complete topic value is decreased by the allocation to topic value. In the corner case when allocation is negative this means that the turns to complete value actually increases due to subtraction of a negative value from it. The proposed defect fix is to make the algorithm more robust and do not allow negative allocations to be used in calculations.

224. There is a class to plausibility test resource production and consumption and if needed make automated adjustments to satisfy constraints and needs. The class has a method (cseg01:00041984) to check whether it is helpful to power off a non critical stationary building to satisfy resource consumption of more important buildings. For example if a heavy plant needs power to operate, but there is not enough fuel or power generating capacity, but there is a powered on research center, then the algorithm is allowed to power off the research center. The aforementioned method checks whether the non critical stationary building’s unit order is ORDER_POWER_OFF in which case it does not qualify for shutting off as it is assumed to be already powered off.
224. **[Fixed]** There is a class to plausibility test resource production and consumption and if needed make automated adjustments to satisfy constraints and needs. The class has a method (cseg01:00041984) to check whether it is helpful to power off a non critical stationary building to satisfy resource consumption of more important buildings. For example if a heavy plant needs power to operate, but there is not enough fuel or power generating capacity, but there is a powered on research center, then the algorithm is allowed to power off the research center. The aforementioned method checks whether the non critical stationary building’s unit order is ORDER_POWER_OFF in which case it does not qualify for shutting off as it is assumed to be already powered off.
Computer players execute a complex class method (cseg01:0005B2EF) at the beginning of each turn and if ten or more fuel is stored in fuel storage units, then all currently powered off non critical stationary buildings are attempted to be turned back on. The algorithm does not check which complex has the fuel reserves or whether there are power generators or power stations that could be turned on within the complex.
There is a corner case where units are requested to be turned back on, with order ORDER_POWER_ON in order state ORDER_STATE_INIT, and they are eventually shut off again in the process even though they were not even on in the first place which means that certain events that shall only be executed once a unit is changing operating state from on to off are incorrectly triggered.
For example the computer player requests all currently powered off research centers, having order ORDER_POWER_OFF and order state ORDER_STATE_EXECUTING_ORDER, to be powered back on again at the beginning of a new turn by issuing order ORDER_POWER_ON and order state ORDER_STATE_INIT. Then the method from before checks whether there is sufficient power to turn on one of the affected research centers and it finds that no it is not possible so it orders some or all of the research centers to get turned off again including the one that is getting turned on right now by issuing order ORDER_POWER_OFF and order state ORDER_STATE_INIT again. Why can the plausibility test method qualify the affected research centers for an order to power off? Because they currently do not have order ORDER_POWER_OFF as the computer player changed their order in the beginning of the turn to be ORDER_POWER_ON and those orders are not yet processed for most of the affected units. All this means that an already powered off research center can get a new order to power on and before that order gets served the unit can get another order to get powered off again in which case the research topic allocation of the affected research center will be decremented incorrectly, eventually reaching a negative allocation. Unit orders shall not be allowed to change orders and order states inconsistently like this. The proposed defect fix is to make the plasuibility testing method more robust against the corner case. A more appropriate, but complex change would be to move all unit order and order state transition management into the UnitInfo class itself and only allow manager classes to request operations on UnitInfo objects via an encapsulated abstract API level.

0 comments on commit 8833083

Please sign in to comment.