changeset 11539:299754b9228a draft

(svn r15900) -Fix (r5076): Adding settings is not enough, you also have to use them.
author frosch <frosch@openttd.org>
date Mon, 30 Mar 2009 20:19:25 +0000
parents 2d0b1d73ccb7
children 90fff0ff5623
files src/yapf/yapf_costrail.hpp
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/yapf/yapf_costrail.hpp
+++ b/src/yapf/yapf_costrail.hpp
@@ -244,13 +244,13 @@
 		assert(v != NULL);
 		assert(v->type == VEH_TRAIN);
 		assert(v->u.rail.cached_total_length != 0);
-		int needed_platform_length = (v->u.rail.cached_total_length + TILE_SIZE - 1) / TILE_SIZE;
-		if (platform_length > needed_platform_length) {
+		int missing_platform_length = (v->u.rail.cached_total_length + TILE_SIZE - 1) / TILE_SIZE - platform_length;
+		if (missing_platform_length < 0) {
 			/* apply penalty for longer platform than needed */
-			cost += Yapf().PfGetSettings().rail_longer_platform_penalty;
-		} else if (needed_platform_length > platform_length) {
+			cost += Yapf().PfGetSettings().rail_longer_platform_penalty + Yapf().PfGetSettings().rail_longer_platform_per_tile_penalty * -missing_platform_length;
+		} else if (missing_platform_length > 0) {
 			/* apply penalty for shorter platform than needed */
-			cost += Yapf().PfGetSettings().rail_shorter_platform_penalty;
+			cost += Yapf().PfGetSettings().rail_shorter_platform_penalty + Yapf().PfGetSettings().rail_shorter_platform_per_tile_penalty * missing_platform_length;
 		}
 		return cost;
 	}