(svn r19670) -Codechange: Add CeilDiv() and RoundDiv() to simplify integer divisions with rounding.

This commit is contained in:
frosch
2010-04-18 14:56:05 +00:00
parent 4e5b8a1614
commit a4413f4cf6
15 changed files with 50 additions and 30 deletions

View File

@@ -259,7 +259,7 @@ public:
assert(v != NULL);
assert(v->type == VEH_TRAIN);
assert(v->tcache.cached_total_length != 0);
int missing_platform_length = (v->tcache.cached_total_length + TILE_SIZE - 1) / TILE_SIZE - platform_length;
int missing_platform_length = CeilDiv(v->tcache.cached_total_length, TILE_SIZE) - platform_length;
if (missing_platform_length < 0) {
/* apply penalty for longer platform than needed */
cost += Yapf().PfGetSettings().rail_longer_platform_penalty + Yapf().PfGetSettings().rail_longer_platform_per_tile_penalty * -missing_platform_length;