Changeset - r1214:2ed99b1b4b97
[Not reviewed]
master
0 12 0
tron - 19 years ago 2005-01-29 15:12:40
tron@openttd.org
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
This makes it necessary to rename TileType() to GetTileType() because a type and a function may not share the same name.
12 files changed with 47 insertions and 44 deletions:
0 comments (0 inline, 0 general)
disaster_cmd.c
Show inline comments
 
@@ -19,7 +19,7 @@ static void DisasterClearSquare(TileInde
 
	if (!EnsureNoVehicle(tile))
 
		return;
 

	
 
	switch (TileType(tile)) {
 
	switch (GetTileType(tile)) {
 
		case MP_RAILWAY:
 
			if (IS_HUMAN_PLAYER(_map_owner[tile])) DoClearSquare(tile);
 
			break;
industry_cmd.c
Show inline comments
 
@@ -857,7 +857,7 @@ static const byte _plantfarmfield_type[]
 

	
 
static bool IsBadFarmFieldTile(TileIndex tile)
 
{
 
	switch (TileType(tile)) {
 
	switch (GetTileType(tile)) {
 
		case MP_CLEAR: {
 
			byte m5 = _map5[tile] & 0x1C;
 
			return m5 == 0xC || m5 == 0x10;
 
@@ -873,7 +873,7 @@ static bool IsBadFarmFieldTile(TileIndex
 

	
 
static bool IsBadFarmFieldTile2(TileIndex tile)
 
{
 
	switch (TileType(tile)) {
 
	switch (GetTileType(tile)) {
 
		case MP_CLEAR: {
 
			byte m5 = _map5[tile] & 0x1C;
 
			return m5 == 0x10;
landscape.c
Show inline comments
 
@@ -87,7 +87,7 @@ void FindLandscapeHeightByTile(TileInfo 
 

	
 
	ti->tile = tile;
 
	ti->map5 = _map5[tile];
 
	ti->type = TileType(tile);
 
	ti->type = GetTileType(tile);
 
	ti->tileh = GetTileSlope(tile, &ti->z);
 
}
 

	
 
@@ -288,28 +288,28 @@ void DoClearSquare(uint tile)
 

	
 
uint32 GetTileTrackStatus(uint tile, TransportType mode)
 
{
 
	return _tile_type_procs[TileType(tile)]->get_tile_track_status_proc(tile, mode);
 
	return _tile_type_procs[GetTileType(tile)]->get_tile_track_status_proc(tile, mode);
 
}
 

	
 
void ChangeTileOwner(uint tile, byte old_player, byte new_player)
 
{
 
	_tile_type_procs[TileType(tile)]->change_tile_owner_proc(tile, old_player, new_player);
 
	_tile_type_procs[GetTileType(tile)]->change_tile_owner_proc(tile, old_player, new_player);
 
}
 

	
 
void GetAcceptedCargo(uint tile, AcceptedCargo ac)
 
{
 
	memset(ac, 0, sizeof(AcceptedCargo));
 
	_tile_type_procs[TileType(tile)]->get_accepted_cargo_proc(tile, ac);
 
	_tile_type_procs[GetTileType(tile)]->get_accepted_cargo_proc(tile, ac);
 
}
 

	
 
void AnimateTile(uint tile)
 
{
 
	_tile_type_procs[TileType(tile)]->animate_tile_proc(tile);
 
	_tile_type_procs[GetTileType(tile)]->animate_tile_proc(tile);
 
}
 

	
 
void ClickTile(uint tile)
 
{
 
	_tile_type_procs[TileType(tile)]->click_tile_proc(tile);
 
	_tile_type_procs[GetTileType(tile)]->click_tile_proc(tile);
 
}
 

	
 
void DrawTile(TileInfo *ti)
 
@@ -319,7 +319,7 @@ void DrawTile(TileInfo *ti)
 

	
 
void GetTileDesc(uint tile, TileDesc *td)
 
{
 
	_tile_type_procs[TileType(tile)]->get_tile_desc_proc(tile, td);
 
	_tile_type_procs[GetTileType(tile)]->get_tile_desc_proc(tile, td);
 
}
 

	
 
/* Clear a piece of landscape
 
@@ -333,7 +333,7 @@ int32 CmdLandscapeClear(int x, int y, ui
 
	SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
 

	
 
	tile = TILE_FROM_XY(x,y);
 
	return _tile_type_procs[TileType(tile)]->clear_tile_proc(tile, flags);
 
	return _tile_type_procs[GetTileType(tile)]->clear_tile_proc(tile, flags);
 
}
 

	
 
// p1 = end tile
 
@@ -446,7 +446,7 @@ void RunTileLoop(void)
 
	assert( (tile & ~TILELOOP_ASSERTMASK) == 0);
 
	count = (MapSizeX() / TILELOOP_SIZE) * (MapSizeY() / TILELOOP_SIZE);
 
	do {
 
		_tile_type_procs[TileType(tile)]->tile_loop_proc(tile);
 
		_tile_type_procs[GetTileType(tile)]->tile_loop_proc(tile);
 

	
 
		if (TileX(tile) < MapSizeX() - TILELOOP_SIZE) {
 
			tile += TILELOOP_SIZE; /* no overflow */
order_gui.c
Show inline comments
 
@@ -185,7 +185,7 @@ static Order GetOrderCmdFromTile(Vehicle
 

	
 
	// check depot first
 
	if (_patches.gotodepot) {
 
		switch (TileType(tile)) {
 
		switch (GetTileType(tile)) {
 
		case MP_RAILWAY:
 
			if (v->type == VEH_Train && _map_owner[tile] == _local_player) {
 
				if ((_map5[tile]&0xFC)==0xC0) {
 
@@ -228,6 +228,9 @@ static Order GetOrderCmdFromTile(Vehicle
 
				order.station = GetDepotByTile(tile);
 
				return order;
 
			}
 

	
 
			default:
 
				break;
 
		}
 
	}
 

	
road_cmd.c
Show inline comments
 
@@ -26,7 +26,7 @@ static bool HasTileRoadAt(uint tile, int
 
	int mask;
 
	byte b;
 

	
 
	switch (TileType(tile)) {
 
	switch (GetTileType(tile)) {
 
	case MP_STREET:
 
		b = _map5[tile];
 

	
smallmap_gui.c
Show inline comments
 
@@ -298,7 +298,7 @@ static inline uint32 GetSmallMapCountour
 
{
 
	uint t;
 

	
 
	t = TileType(tile);
 
	t = GetTileType(tile);
 
	if (t == MP_TUNNELBRIDGE) {
 
		t = _map5[tile];
 
		if ((t & 0x80) == 0) t>>=1;
 
@@ -328,7 +328,7 @@ static inline uint32 GetSmallMapVehicles
 
{
 
	uint t;
 

	
 
	t = TileType(tile);
 
	t = GetTileType(tile);
 
	if (t == MP_TUNNELBRIDGE) {
 
		t = _map5[tile];
 
		if ((t & 0x80) == 0) t>>=1;
 
@@ -381,7 +381,7 @@ static inline uint32 GetSmallMapIndustri
 
{
 
	int t;
 

	
 
	t = TileType(tile);
 
	t = GetTileType(tile);
 
	if (t == MP_INDUSTRY) {
 
		byte color = _industry_smallmap_colors[_map5[tile]];
 
		return color + (color << 8) + (color << 16) + (color << 24);
 
@@ -414,7 +414,7 @@ static inline uint32 GetSmallMapRoutesPi
 
	int t;
 
	uint32 bits;
 

	
 
	t = TileType(tile);
 
	t = GetTileType(tile);
 
	if (t == MP_STATION) {
 
		byte m5 = _map5[tile];
 
		(bits = MKCOLOR(0x56565656), m5 < 8) ||			//   8 - railroad station (green)
 
@@ -470,7 +470,7 @@ static inline uint32 GetSmallMapVegetati
 
	int i,t;
 
	uint32 bits;
 

	
 
	t = TileType(tile);
 
	t = GetTileType(tile);
 
	if (t == MP_CLEAR) {
 
		i = (_map5[tile] & 0x1F) - 4;
 
		if (i >= 0) i = (i >> 2);
 
@@ -515,7 +515,7 @@ static inline uint32 GetSmallMapOwnerPix
 
{
 
	int t;
 

	
 
	t = TileType(tile);
 
	t = GetTileType(tile);
 
	if (t == MP_HOUSE || _map_owner[tile] == OWNER_TOWN) {
 
		t = 0x80;
 
	} else if (t == MP_INDUSTRY) {
station_cmd.c
Show inline comments
 
@@ -436,7 +436,7 @@ void GetProductionAroundTiles(uint *prod
 
			if (!(IS_INSIDE_1D(xc, x, w) && IS_INSIDE_1D(yc, y, h))) {
 
				GetProducedCargoProc *gpc;
 
				uint tile = TILE_XY(xc, yc);
 
				gpc = _tile_type_procs[TileType(tile)]->get_produced_cargo_proc;
 
				gpc = _tile_type_procs[GetTileType(tile)]->get_produced_cargo_proc;
 
				if (gpc != NULL) {
 
					cargos[0] = cargos[1] = 0xFF;
 
					gpc(tile, cargos);
tile.h
Show inline comments
 
@@ -3,6 +3,20 @@
 

	
 
#include "map.h"
 

	
 
typedef enum TileType {
 
	MP_CLEAR,
 
	MP_RAILWAY,
 
	MP_STREET,
 
	MP_HOUSE,
 
	MP_TREES,
 
	MP_STATION,
 
	MP_WATER,
 
	MP_VOID, // invisible tiles at the SW and SE border
 
	MP_INDUSTRY,
 
	MP_TUNNELBRIDGE,
 
	MP_UNMOVABLE
 
} TileType;
 

	
 
void SetMapExtraBits(TileIndex tile, byte flags);
 
uint GetMapExtraBits(TileIndex tile);
 

	
 
@@ -25,22 +39,22 @@ static inline uint TilePixelHeight(TileI
 
	return TileHeight(tile) * 8;
 
}
 

	
 
static inline int TileType(TileIndex tile)
 
static inline TileType GetTileType(TileIndex tile)
 
{
 
	assert(tile < MapSize());
 
	return _map_type_and_height[tile] >> 4;
 
}
 

	
 
static inline void SetTileType(TileIndex tile, uint type)
 
static inline void SetTileType(TileIndex tile, TileType type)
 
{
 
	assert(tile < MapSize());
 
	_map_type_and_height[tile] &= ~0xF0;
 
	_map_type_and_height[tile] |= type << 4;
 
}
 

	
 
static inline bool IsTileType(TileIndex tile, int type)
 
static inline bool IsTileType(TileIndex tile, TileType type)
 
{
 
	return TileType(tile) == type;
 
	return GetTileType(tile) == type;
 
}
 

	
 
#endif
train_cmd.c
Show inline comments
 
@@ -2079,7 +2079,7 @@ static int GetDirectionToVehicle(Vehicle
 
/* Check if the vehicle is compatible with the specified tile */
 
static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
 
{
 
	switch (TileType(tile)) {
 
	switch (GetTileType(tile)) {
 
		case MP_RAILWAY:
 
		case MP_STATION:
 
			// normal tracks, jump to owner check
ttd.h
Show inline comments
 
@@ -86,20 +86,6 @@ enum SwitchModes {
 
	SM_START_SCENARIO = 10,
 
};
 

	
 
enum MapTileTypes {
 
	MP_CLEAR,
 
	MP_RAILWAY,
 
	MP_STREET,
 
	MP_HOUSE,
 
	MP_TREES,
 
	MP_STATION,
 
	MP_WATER,
 
	MP_VOID, // invisible tiles at the SW and SE border
 
	MP_INDUSTRY,
 
	MP_TUNNELBRIDGE,
 
	MP_UNMOVABLE
 
};
 

	
 
typedef enum TransportTypes {
 
	/* These constants are for now linked to the representation of bridges
 
	 * and tunnels, so they can be used by GetTileTrackStatus_TunnelBridge
vehicle.c
Show inline comments
 
@@ -1733,13 +1733,13 @@ byte GetDirectionTowards(Vehicle *v, int
 
uint32 VehicleEnterTile(Vehicle *v, uint tile, int x, int y)
 
{
 
	uint old_tile = v->tile;
 
	uint32 result = _tile_type_procs[TileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y);
 
	uint32 result = _tile_type_procs[GetTileType(tile)]->vehicle_enter_tile_proc(v, tile, x, y);
 

	
 
	/* When vehicle_enter_tile_proc returns 8, that apparently means that
 
	 * we cannot enter the tile at all. In that case, don't call
 
	 * leave_tile. */
 
	if (!(result & 8) && old_tile != tile) {
 
		VehicleLeaveTileProc *proc = _tile_type_procs[TileType(old_tile)]->vehicle_leave_tile_proc;
 
		VehicleLeaveTileProc *proc = _tile_type_procs[GetTileType(old_tile)]->vehicle_leave_tile_proc;
 
		if (proc != NULL)
 
			proc(v, old_tile, x, y);
 
	}
water_cmd.c
Show inline comments
 
@@ -320,7 +320,7 @@ static bool IsWateredTile(TileIndex tile
 
{
 
	byte m5 = _map5[tile];
 

	
 
	switch (TileType(tile)) {
 
	switch (GetTileType(tile)) {
 
		case MP_WATER:
 
			// true, if not coast/riverbank
 
			return m5 != 1;
 
@@ -502,7 +502,7 @@ static void TileLoopWaterHelper(TileInde
 
	if (TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[3]))) != 0 ||
 
			TileHeight(TILE_ADD(tile, ToTileIndexDiff(offs[4]))) != 0) {
 
		// make coast..
 
		switch (TileType(target)) {
 
		switch (GetTileType(target)) {
 
			case MP_RAILWAY: {
 
				uint slope = GetTileSlope(target, NULL);
 
				byte tracks = _map5[target] & 0x3F;
0 comments (0 inline, 0 general)