[-] Fixed action freeze when speeds are lower than 100
This commit is contained in:
parent
70d2627204
commit
e0542ff0e1
5 changed files with 10 additions and 10 deletions
|
@ -346,7 +346,7 @@ void COrder_Built::Progress(CUnit &unit, int amount)
|
|||
Boost(unit, amount, HP_INDEX);
|
||||
Boost(unit, amount, SHIELD_INDEX);
|
||||
|
||||
this->ProgressCounter += amount * unit.Player->SpeedBuild / SPEEDUP_FACTOR;
|
||||
this->ProgressCounter += std::max(1, amount * unit.Player->SpeedBuild / SPEEDUP_FACTOR);
|
||||
UpdateConstructionFrame(unit);
|
||||
}
|
||||
|
||||
|
@ -354,7 +354,7 @@ void COrder_Built::ProgressHp(CUnit &unit, int amount)
|
|||
{
|
||||
Boost(unit, amount, HP_INDEX);
|
||||
|
||||
this->ProgressCounter += amount * unit.Player->SpeedBuild / SPEEDUP_FACTOR;
|
||||
this->ProgressCounter += std::max(1, amount * unit.Player->SpeedBuild / SPEEDUP_FACTOR);
|
||||
UpdateConstructionFrame(unit);
|
||||
}
|
||||
|
||||
|
@ -365,7 +365,7 @@ void COrder_Built::Boost(CUnit &building, int amount, int varIndex) const
|
|||
|
||||
const int costs = building.Stats->Costs[TimeCost] * 600;
|
||||
const int progress = this->ProgressCounter;
|
||||
const int newProgress = progress + amount * building.Player->SpeedBuild / SPEEDUP_FACTOR;
|
||||
const int newProgress = progress + std::max(1, amount * building.Player->SpeedBuild / SPEEDUP_FACTOR);
|
||||
const int maxValue = building.Variable[varIndex].Max;
|
||||
|
||||
int ¤tValue = building.Variable[varIndex].Value;
|
||||
|
|
|
@ -131,7 +131,7 @@
|
|||
}
|
||||
#endif
|
||||
CPlayer &player = *unit.Player;
|
||||
player.UpgradeTimers.Upgrades[upgrade.ID] += player.SpeedResearch / SPEEDUP_FACTOR;
|
||||
player.UpgradeTimers.Upgrades[upgrade.ID] += std::max(1, player.SpeedResearch / SPEEDUP_FACTOR);
|
||||
if (player.UpgradeTimers.Upgrades[upgrade.ID] >= upgrade.Costs[TimeCost]) {
|
||||
player.Notify(NotifyGreen, unit.tilePos, _("%s: research complete"), type.Name.c_str());
|
||||
if (&player == ThisPlayer) {
|
||||
|
|
|
@ -470,7 +470,7 @@ int COrder_Resource::StartGathering(CUnit &unit)
|
|||
#endif
|
||||
UnitHeadingFromDeltaXY(unit, this->goalPos - unit.tilePos);
|
||||
if (resinfo.WaitAtResource) {
|
||||
this->TimeToHarvest = resinfo.WaitAtResource / unit.Player->SpeedResourcesHarvest[resinfo.ResourceId] * SPEEDUP_FACTOR;
|
||||
this->TimeToHarvest = std::max<int>(1, resinfo.WaitAtResource * SPEEDUP_FACTOR / unit.Player->SpeedResourcesHarvest[resinfo.ResourceId]);
|
||||
} else {
|
||||
this->TimeToHarvest = 1;
|
||||
}
|
||||
|
@ -538,7 +538,7 @@ int COrder_Resource::StartGathering(CUnit &unit)
|
|||
goal->Resource.Active++;
|
||||
|
||||
if (resinfo.WaitAtResource) {
|
||||
this->TimeToHarvest = resinfo.WaitAtResource / unit.Player->SpeedResourcesHarvest[resinfo.ResourceId] * SPEEDUP_FACTOR;
|
||||
this->TimeToHarvest = std::max<int>(1, resinfo.WaitAtResource * SPEEDUP_FACTOR / unit.Player->SpeedResourcesHarvest[resinfo.ResourceId]);
|
||||
} else {
|
||||
this->TimeToHarvest = 1;
|
||||
}
|
||||
|
@ -671,7 +671,7 @@ int COrder_Resource::GatherResource(CUnit &unit)
|
|||
while (!this->DoneHarvesting && this->TimeToHarvest < 0) {
|
||||
//FIXME: rb - how should it look for WaitAtResource == 0
|
||||
if (resinfo.WaitAtResource) {
|
||||
this->TimeToHarvest += resinfo.WaitAtResource * SPEEDUP_FACTOR / unit.Player->SpeedResourcesHarvest[resinfo.ResourceId];
|
||||
this->TimeToHarvest += std::max<int>(1, resinfo.WaitAtResource * SPEEDUP_FACTOR / unit.Player->SpeedResourcesHarvest[resinfo.ResourceId]);
|
||||
} else {
|
||||
this->TimeToHarvest += 1;
|
||||
}
|
||||
|
@ -954,7 +954,7 @@ int COrder_Resource::MoveToDepot(CUnit &unit)
|
|||
unit.CurrentResource = 0;
|
||||
|
||||
if (unit.Wait) {
|
||||
unit.Wait /= unit.Player->SpeedResourcesReturn[resinfo.ResourceId] / SPEEDUP_FACTOR;
|
||||
unit.Wait /= std::max(1, unit.Player->SpeedResourcesReturn[resinfo.ResourceId] / SPEEDUP_FACTOR);
|
||||
if (unit.Wait) {
|
||||
unit.Wait--;
|
||||
}
|
||||
|
|
|
@ -183,7 +183,7 @@ static void AnimateActionTrain(CUnit &unit)
|
|||
CPlayer &player = *unit.Player;
|
||||
const CUnitType &nType = *this->Type;
|
||||
const int cost = nType.Stats[player.Index].Costs[TimeCost];
|
||||
this->Ticks += player.SpeedTrain / SPEEDUP_FACTOR;
|
||||
this->Ticks += std::max(1, player.SpeedTrain / SPEEDUP_FACTOR);
|
||||
|
||||
if (this->Ticks < cost) {
|
||||
unit.Wait = CYCLES_PER_SECOND / 6;
|
||||
|
|
|
@ -260,7 +260,7 @@ static void AnimateActionUpgradeTo(CUnit &unit)
|
|||
const CUnitType &newtype = *this->Type;
|
||||
const CUnitStats &newstats = newtype.Stats[player.Index];
|
||||
|
||||
this->Ticks += player.SpeedUpgrade / SPEEDUP_FACTOR;
|
||||
this->Ticks += std::max(1, player.SpeedUpgrade / SPEEDUP_FACTOR);
|
||||
if (this->Ticks < newstats.Costs[TimeCost]) {
|
||||
unit.Wait = CYCLES_PER_SECOND / 6;
|
||||
return ;
|
||||
|
|
Loading…
Add table
Reference in a new issue