mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +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 n;
|
||||
int r;
|
||||
|
||||
if (length < 2) return length;
|
||||
|
||||
length -= 2;
|
||||
for (n = 0, r = 2;; n++) {
|
||||
if (length <= n) return r + length * n;
|
||||
r += n * n;
|
||||
length -= n;
|
||||
int sum = 2;
|
||||
for (int delta = 1;; delta++) {
|
||||
for (int count = 0; count < delta; count++) {
|
||||
if (length == 0) return sum;
|
||||
sum += delta;
|
||||
length--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user