changeset 19010:5c9c720a7ae3 draft

(svn r23866) -Feature: [NewGRF] Give NewGRF defined level crossings and rail depots access to the townzone.
author frosch <frosch@openttd.org>
date Sat, 28 Jan 2012 19:36:22 +0000
parents c182079bb17f
children b1aa80cd0b5b
files src/newgrf_railtype.cpp
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/newgrf_railtype.cpp
+++ b/src/newgrf_railtype.cpp
@@ -14,6 +14,7 @@
 #include "newgrf_spritegroup.h"
 #include "date_func.h"
 #include "depot_base.h"
+#include "town.h"
 
 static uint32 RailTypeGetRandomBits(const ResolverObject *object)
 {
@@ -41,6 +42,7 @@
 			case 0x41: return 0;
 			case 0x42: return 0;
 			case 0x43: return _date;
+			case 0x44: return HZB_TOWN_EDGE;
 		}
 	}
 
@@ -51,6 +53,15 @@
 		case 0x43:
 			if (IsRailDepotTile(tile)) return Depot::GetByTile(tile)->build_date;
 			return _date;
+		case 0x44: {
+			const Town *t = NULL;
+			if (IsRailDepotTile(tile)) {
+				t = Depot::GetByTile(tile)->town;
+			} else if (IsLevelCrossingTile(tile)) {
+				t = ClosestTownFromTile(tile, UINT_MAX);
+			}
+			return t != NULL ? GetTownRadiusGroup(t, tile) : HZB_TOWN_EDGE;
+		}
 	}
 
 	DEBUG(grf, 1, "Unhandled rail type tile variable 0x%X", variable);