(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.
This commit is contained in:
		| @@ -19,7 +19,7 @@ static void DisasterClearSquare(TileIndex tile) | ||||
| 	if (!EnsureNoVehicle(tile)) | ||||
| 		return; | ||||
|  | ||||
| 	switch (TileType(tile)) { | ||||
| 	switch (GetTileType(tile)) { | ||||
| 		case MP_RAILWAY: | ||||
| 			if (IS_HUMAN_PLAYER(_map_owner[tile])) DoClearSquare(tile); | ||||
| 			break; | ||||
|   | ||||
| @@ -857,7 +857,7 @@ static const byte _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, | ||||
|  | ||||
| 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 tile) | ||||
|  | ||||
| static bool IsBadFarmFieldTile2(TileIndex tile) | ||||
| { | ||||
| 	switch (TileType(tile)) { | ||||
| 	switch (GetTileType(tile)) { | ||||
| 		case MP_CLEAR: { | ||||
| 			byte m5 = _map5[tile] & 0x1C; | ||||
| 			return m5 == 0x10; | ||||
|   | ||||
							
								
								
									
										18
									
								
								landscape.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								landscape.c
									
									
									
									
									
								
							| @@ -87,7 +87,7 @@ void FindLandscapeHeightByTile(TileInfo *ti, TileIndex tile) | ||||
|  | ||||
| 	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, uint32 flags, uint32 p1, uint32 p2) | ||||
| 	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 */ | ||||
|   | ||||
| @@ -185,7 +185,7 @@ static Order GetOrderCmdFromTile(Vehicle *v, uint tile) | ||||
|  | ||||
| 	// 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 *v, uint tile) | ||||
| 				order.station = GetDepotByTile(tile); | ||||
| 				return order; | ||||
| 			} | ||||
|  | ||||
| 			default: | ||||
| 				break; | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
|   | ||||
| @@ -26,7 +26,7 @@ static bool HasTileRoadAt(uint tile, int i) | ||||
| 	int mask; | ||||
| 	byte b; | ||||
|  | ||||
| 	switch (TileType(tile)) { | ||||
| 	switch (GetTileType(tile)) { | ||||
| 	case MP_STREET: | ||||
| 		b = _map5[tile]; | ||||
|  | ||||
|   | ||||
| @@ -298,7 +298,7 @@ static inline uint32 GetSmallMapCountoursPixels(uint tile) | ||||
| { | ||||
| 	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 GetSmallMapVehiclesPixels(uint tile) | ||||
| { | ||||
| 	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 GetSmallMapIndustriesPixels(uint tile) | ||||
| { | ||||
| 	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 GetSmallMapRoutesPixels(uint tile) | ||||
| 	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 GetSmallMapVegetationPixels(uint tile) | ||||
| 	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 GetSmallMapOwnerPixels(uint tile) | ||||
| { | ||||
| 	int t; | ||||
|  | ||||
| 	t = TileType(tile); | ||||
| 	t = GetTileType(tile); | ||||
| 	if (t == MP_HOUSE || _map_owner[tile] == OWNER_TOWN) { | ||||
| 		t = 0x80; | ||||
| 	} else if (t == MP_INDUSTRY) { | ||||
|   | ||||
| @@ -436,7 +436,7 @@ void GetProductionAroundTiles(uint *produced, uint tile, int w, int h, int rad) | ||||
| 			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); | ||||
|   | ||||
							
								
								
									
										22
									
								
								tile.h
									
									
									
									
									
								
							
							
						
						
									
										22
									
								
								tile.h
									
									
									
									
									
								
							| @@ -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(TileIndex tile) | ||||
| 	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 | ||||
|   | ||||
| @@ -2079,7 +2079,7 @@ static int GetDirectionToVehicle(Vehicle *v, int x, int y) | ||||
| /* 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 | ||||
|   | ||||
							
								
								
									
										14
									
								
								ttd.h
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								ttd.h
									
									
									
									
									
								
							| @@ -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 | ||||
|   | ||||
| @@ -1733,13 +1733,13 @@ byte GetDirectionTowards(Vehicle *v, int x, int y) | ||||
| 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); | ||||
| 	} | ||||
|   | ||||
| @@ -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(TileIndex tile, const TileIndexDiffC *offs) | ||||
| 	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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 tron
					tron