mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 07:29:44 +00:00
(svn r19485) -Codechange: Re-implement CalcBridgeLenCostFactor() in a more readable way without changing computed costs.
This commit is contained in:
parent
cced6b35cb
commit
c3471d98f3
@ -73,15 +73,16 @@ void ResetBridges()
|
|||||||
*/
|
*/
|
||||||
int CalcBridgeLenCostFactor(int length)
|
int CalcBridgeLenCostFactor(int length)
|
||||||
{
|
{
|
||||||
int n;
|
|
||||||
int r;
|
|
||||||
|
|
||||||
if (length < 2) return length;
|
if (length < 2) return length;
|
||||||
|
|
||||||
length -= 2;
|
length -= 2;
|
||||||
for (n = 0, r = 2;; n++) {
|
int sum = 2;
|
||||||
if (length <= n) return r + length * n;
|
for (int delta = 1;; delta++) {
|
||||||
r += n * n;
|
for (int count = 0; count < delta; count++) {
|
||||||
length -= n;
|
if (length == 0) return sum;
|
||||||
|
sum += delta;
|
||||||
|
length--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user