(svn r17492) -Codechange: don't store the town index for road depots.

This commit is contained in:
rubidium 2009-09-10 14:27:43 +00:00
parent 96e2435aa8
commit bb94724a09
4 changed files with 9 additions and 10 deletions

View File

@ -882,7 +882,7 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
Depot *dep = new Depot(tile); Depot *dep = new Depot(tile);
dep->town_index = ClosestTownFromTile(tile, UINT_MAX)->index; dep->town_index = ClosestTownFromTile(tile, UINT_MAX)->index;
MakeRoadDepot(tile, _current_company, dir, rt, dep->town_index); MakeRoadDepot(tile, _current_company, dir, rt);
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);
} }
return cost.AddCost(_price.build_road_depot); return cost.AddCost(_price.build_road_depot);

View File

@ -407,11 +407,11 @@ static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner tram, Owner r
} }
static inline void MakeRoadDepot(TileIndex t, Owner owner, DiagDirection dir, RoadType rt, TownID town) static inline void MakeRoadDepot(TileIndex t, Owner owner, DiagDirection dir, RoadType rt)
{ {
SetTileType(t, MP_ROAD); SetTileType(t, MP_ROAD);
SetTileOwner(t, owner); SetTileOwner(t, owner);
_m[t].m2 = town; _m[t].m2 = 0;
_m[t].m3 = 0; _m[t].m3 = 0;
_m[t].m4 = 0; _m[t].m4 = 0;
_m[t].m5 = ROAD_TILE_DEPOT << 6 | dir; _m[t].m5 = ROAD_TILE_DEPOT << 6 | dir;

View File

@ -842,7 +842,7 @@ bool AfterLoadGame()
case ROAD_TILE_DEPOT: case ROAD_TILE_DEPOT:
break; break;
} }
if (!HasTownOwnedRoad(t)) { if (!IsRoadDepot(t) && !HasTownOwnedRoad(t)) {
const Town *town = CalcClosestTownFromTile(t); const Town *town = CalcClosestTownFromTile(t);
if (town != NULL) SetTownIndex(t, town->index); if (town != NULL) SetTownIndex(t, town->index);
} }

View File

@ -12,32 +12,31 @@
#ifndef TOWN_MAP_H #ifndef TOWN_MAP_H
#define TOWN_MAP_H #define TOWN_MAP_H
#include "tile_map.h" #include "road_map.h"
#include "town_type.h" #include "town_type.h"
#include "house.h" #include "house.h"
/** /**
* Get the index of which town this house/street is attached to. * Get the index of which town this house/street is attached to.
* @param t the tile * @param t the tile
* @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) * @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) but not a road depot
* @return TownID * @return TownID
*/ */
static inline TownID GetTownIndex(TileIndex t) static inline TownID GetTownIndex(TileIndex t)
{ {
assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_ROAD)); // XXX incomplete assert(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)));
return _m[t].m2; return _m[t].m2;
} }
/** /**
* Set the town index for a road or house tile. * Set the town index for a road or house tile.
* @param t the tile * @param t the tile
* @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD)
* @param index the index of the town * @param index the index of the town
* @pre IsTileType(t, MP_ROAD) || IsTileType(t, MP_HOUSE) * @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) but not a road depot
*/ */
static inline void SetTownIndex(TileIndex t, TownID index) static inline void SetTownIndex(TileIndex t, TownID index)
{ {
assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_ROAD)); assert(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)));
_m[t].m2 = index; _m[t].m2 = index;
} }