town_cmd.c
changeset 1638 4779658c2d03
parent 1529 3a8196d15b01
child 1793 b9a37c98b468
equal deleted inserted replaced
1637:ee2049729147 1638:4779658c2d03
  1805 Town *ClosestTownFromTile(uint tile, uint threshold)
  1805 Town *ClosestTownFromTile(uint tile, uint threshold)
  1806 {
  1806 {
  1807 	Town *t;
  1807 	Town *t;
  1808 	uint dist, best = threshold;
  1808 	uint dist, best = threshold;
  1809 	Town *best_town = NULL;
  1809 	Town *best_town = NULL;
  1810 
  1810 	byte owner;
  1811 	if ((IsTileType(tile, MP_STREET) && _map_owner[tile] == OWNER_TOWN) || IsTileType(tile, MP_HOUSE))
  1811 
       
  1812 	// XXX - Fix this so for a given tiletype the owner of the type is in the same variable
       
  1813 	if (IsTileType(tile, MP_STREET) && (_map5[tile] & 0xF0) == 0x10) { // rail crossing
       
  1814 		owner = _map3_lo[tile];
       
  1815 	} else
       
  1816 		owner = _map_owner[tile];
       
  1817 
       
  1818 	if ((IsTileType(tile, MP_STREET) && owner == OWNER_TOWN) || IsTileType(tile, MP_HOUSE))
  1812 		return GetTown(_map2[tile]);
  1819 		return GetTown(_map2[tile]);
  1813 
  1820 
  1814 	FOR_ALL_TOWNS(t) {
  1821 	FOR_ALL_TOWNS(t) {
  1815 		if (t->xy != 0) {
  1822 		if (t->xy != 0) {
  1816 			dist = DistanceManhattan(tile, t->xy);
  1823 			dist = DistanceManhattan(tile, t->xy);