Fix crash which could occur when adding/updating text effects

When DParam 0 or 1 contained a leftover string

See: #612
This commit is contained in:
Jonathan G Rennison
2023-11-20 19:25:23 +00:00
parent c929f7075e
commit b80e2dff19
3 changed files with 18 additions and 19 deletions

View File

@@ -620,8 +620,7 @@ void ShowCostOrIncomeAnimation(int x, int y, int z, Money cost)
cost = -cost;
msg = STR_INCOME_FLOAT_INCOME;
}
SetDParam(0, cost);
AddTextEffect(msg, pt.x, pt.y, DAY_TICKS, TE_RISING);
AddTextEffect(msg, pt.x, pt.y, DAY_TICKS, TE_RISING, cost);
}
/**
@@ -638,17 +637,15 @@ void ShowFeederIncomeAnimation(int x, int y, int z, Money transfer, Money income
Point pt = RemapCoords(x, y, z);
SetDParam(0, transfer);
if (income == 0) {
AddTextEffect(STR_FEEDER, pt.x, pt.y, DAY_TICKS, TE_RISING);
AddTextEffect(STR_FEEDER, pt.x, pt.y, DAY_TICKS, TE_RISING, transfer);
} else {
StringID msg = STR_FEEDER_COST;
if (income < 0) {
income = -income;
msg = STR_FEEDER_INCOME;
}
SetDParam(1, income);
AddTextEffect(msg, pt.x, pt.y, DAY_TICKS, TE_RISING);
AddTextEffect(msg, pt.x, pt.y, DAY_TICKS, TE_RISING, transfer, income);
}
}
@@ -667,8 +664,7 @@ TextEffectID ShowFillingPercent(int x, int y, int z, uint8 percent, StringID str
assert(string != STR_NULL);
SetDParam(0, percent);
return AddTextEffect(string, pt.x, pt.y, 0, TE_STATIC);
return AddTextEffect(string, pt.x, pt.y, 0, TE_STATIC, percent);
}
/**
@@ -680,8 +676,7 @@ void UpdateFillingPercent(TextEffectID te_id, uint8 percent, StringID string)
{
assert(string != STR_NULL);
SetDParam(0, percent);
UpdateTextEffect(te_id, string);
UpdateTextEffect(te_id, string, percent);
}
/**