diff options
author | rubidium <rubidium@openttd.org> | 2008-10-25 13:51:47 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-10-25 13:51:47 +0000 |
commit | a14ad77a36c836fd3f6940eadeb8161e7ad02f92 (patch) | |
tree | ba7c12966aad60d82c8e03bb0593bce949ec2b86 /src/road_map.h | |
parent | 9075a2bbfc7c33a089fe100c42b96b831521d6d8 (diff) | |
download | openttd-a14ad77a36c836fd3f6940eadeb8161e7ad02f92.tar.xz |
(svn r14528) -Codechange: cache the closest town for all road tiles instead of only roads owned by tiles. This replaces a O(n) search over all towns from the road's tileloop with a O(1) lookup (PhilSophus)
Diffstat (limited to 'src/road_map.h')
-rw-r--r-- | src/road_map.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/road_map.h b/src/road_map.h index dfd88ae3f..bc6639245 100644 --- a/src/road_map.h +++ b/src/road_map.h @@ -189,7 +189,7 @@ static inline void SetRoadOwner(TileIndex t, RoadType rt, Owner o) static inline bool IsRoadOwner(TileIndex t, RoadType rt, Owner o) { - assert(HasTileRoadType(t, rt)); + assert(rt == ROADTYPE_ROAD || HasTileRoadType(t, rt)); return (GetRoadOwner(t, rt) == o); } @@ -451,11 +451,11 @@ static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner tram, Owner h } -static inline void MakeRoadDepot(TileIndex t, Owner owner, DiagDirection dir, RoadType rt) +static inline void MakeRoadDepot(TileIndex t, Owner owner, DiagDirection dir, RoadType rt, TownID town) { SetTileType(t, MP_ROAD); SetTileOwner(t, owner); - _m[t].m2 = 0; + _m[t].m2 = town; _m[t].m3 = 0; _m[t].m4 = 0; _m[t].m5 = ROAD_TILE_DEPOT << 6 | dir; |