Changeset - r1048:e77c229656dc
[Not reviewed]
master
0 4 0
tron - 19 years ago 2005-01-17 09:41:46
tron@openttd.org
(svn r1549) Clean up some functions:
uint tile -> TileIndex tile
if () cascade -> switch ()
4 files changed with 92 insertions and 71 deletions:
0 comments (0 inline, 0 general)
disaster_cmd.c
Show inline comments
 
@@ -13,25 +13,31 @@
 
#include "airport_movement.h"
 
#include "sound.h"
 

	
 
static void DisasterClearSquare(uint tile)
 
static void DisasterClearSquare(TileIndex tile)
 
{
 
	int type;
 

	
 
	if (!EnsureNoVehicle(tile))
 
		return;
 

	
 
	type = TileType(tile);
 
	switch (TileType(tile)) {
 
		case MP_RAILWAY:
 
			if (IS_HUMAN_PLAYER(_map_owner[tile])) DoClearSquare(tile);
 
			break;
 

	
 
	if (type == MP_RAILWAY) {
 
		if (IS_HUMAN_PLAYER(_map_owner[tile]))
 
		case MP_HOUSE: {
 
			byte p = _current_player;
 
			_current_player = OWNER_NONE;
 
			DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
			_current_player = p;
 
			break;
 
		}
 

	
 
		case MP_TREES:
 
		case MP_CLEAR:
 
			DoClearSquare(tile);
 
	} else if (type == MP_HOUSE) {
 
		byte p = _current_player;
 
		_current_player = OWNER_NONE;
 
		DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
 
		_current_player = p;
 
	} else if (type == MP_TREES || type == MP_CLEAR) {
 
		DoClearSquare(tile);
 
			break;
 

	
 
		default:
 
			break;
 
	}
 
}
 

	
industry_cmd.c
Show inline comments
 
@@ -854,31 +854,35 @@ void DeleteIndustry(Industry *i)
 

	
 
static const byte _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6};
 

	
 
static bool IsBadFarmFieldTile(uint tile)
 
static bool IsBadFarmFieldTile(TileIndex tile)
 
{
 
	if (IsTileType(tile, MP_CLEAR)) {
 
		byte m5 = _map5[tile] & 0x1C;
 
		if (m5 == 0xC || m5 == 0x10)
 
	switch (TileType(tile)) {
 
		case MP_CLEAR: {
 
			byte m5 = _map5[tile] & 0x1C;
 
			return m5 == 0xC || m5 == 0x10;
 
		}
 

	
 
		case MP_TREES:
 
			return false;
 

	
 
		default:
 
			return true;
 
		return false;
 
	} else if (IsTileType(tile, MP_TREES)) {
 
		return false;
 
	} else {
 
		return true;
 
	}
 
}
 

	
 
static bool IsBadFarmFieldTile2(uint tile)
 
static bool IsBadFarmFieldTile2(TileIndex tile)
 
{
 
	if (IsTileType(tile, MP_CLEAR)) {
 
		byte m5 = _map5[tile] & 0x1C;
 
		if (m5 == 0x10)
 
	switch (TileType(tile)) {
 
		case MP_CLEAR: {
 
			byte m5 = _map5[tile] & 0x1C;
 
			return m5 == 0x10;
 
		}
 

	
 
		case MP_TREES:
 
			return false;
 

	
 
		default:
 
			return true;
 
		return false;
 
	} else if (IsTileType(tile, MP_TREES)) {
 
		return false;
 
	} else {
 
		return true;
 
	}
 
}
 

	
train_cmd.c
Show inline comments
 
@@ -1893,36 +1893,39 @@ static int GetDirectionToVehicle(Vehicle
 
}
 

	
 
/* Check if the vehicle is compatible with the specified tile */
 
static bool CheckCompatibleRail(Vehicle *v, uint tile)
 
static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
 
{
 
	if (IsTileType(tile, MP_RAILWAY) || IsTileType(tile, MP_STATION)) {
 
		// normal tracks, jump to owner check
 
	} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
		if ((_map5[tile] & 0xC0) == 0xC0) {// is bridge middle part?
 
			TileInfo ti;
 
			FindLandscapeHeightByTile(&ti, tile);
 

	
 
			// correct Z position of a train going under a bridge on slopes
 
			if (CORRECT_Z(ti.tileh))
 
				ti.z += 8;
 

	
 
			if(v->z_pos != ti.z) // train is going over bridge
 
				return true;
 
		}
 
	} else if (IsTileType(tile, MP_STREET)) { // train is going over a road-crossing
 
		// tracks over roads, do owner check of tracks (_map_owner[tile])
 
		if (_map_owner[tile] != v->owner || (v->subtype == 0 && (_map3_hi[tile] & 0xF) != v->u.rail.railtype))
 
			return false;
 

	
 
		return true;
 
	} else
 
		return true;
 

	
 
	if (_map_owner[tile] != v->owner ||
 
			(v->subtype == 0 && (_map3_lo[tile] & 0xF) != v->u.rail.railtype))
 
		return false;
 

	
 
	return true;
 
	switch (TileType(tile)) {
 
		case MP_RAILWAY:
 
		case MP_STATION:
 
			// normal tracks, jump to owner check
 
			break;
 

	
 
		case MP_TUNNELBRIDGE:
 
			if ((_map5[tile] & 0xC0) == 0xC0) { // is bridge middle part?
 
				TileInfo ti;
 
				FindLandscapeHeightByTile(&ti, tile);
 

	
 
				// correct Z position of a train going under a bridge on slopes
 
				if (CORRECT_Z(ti.tileh)) ti.z += 8;
 

	
 
				if (v->z_pos != ti.z) return true; // train is going over bridge
 
			}
 
			break;
 

	
 
		case MP_STREET:
 
			// tracks over roads, do owner check of tracks (_map_owner[tile])
 
			return
 
				_map_owner[tile] == v->owner &&
 
				(v->subtype != 0 || (_map3_hi[tile] & 0xF) == v->u.rail.railtype);
 

	
 
		default:
 
			return true;
 
	}
 

	
 
	return
 
		_map_owner[tile] == v->owner &&
 
		(v->subtype != 0 || (_map3_lo[tile] & 0xF) == v->u.rail.railtype);
 
}
 

	
 
typedef struct {
water_cmd.c
Show inline comments
 
@@ -315,19 +315,27 @@ static int32 ClearTile_Water(uint tile, 
 
}
 

	
 
// return true if a tile is a water tile.
 
static bool IsWateredTile(uint tile)
 
static bool IsWateredTile(TileIndex tile)
 
{
 
	byte m5 = _map5[tile];
 
	if (IsTileType(tile, MP_WATER)) {
 
		return m5 != 1;
 
	} else if (IsTileType(tile, MP_STATION)) {
 
		// returns true if it is a dock-station (m5 inside values is m5<75 all stations,
 
		// 83<=m5<=114 new airports
 
		return !(m5 < 75 || (m5 >= 83 && m5 <= 114));
 
	} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
 
		return (m5 & 0xF8) == 0xC8;
 
	} else
 
		return false;
 

	
 
	switch (TileType(tile)) {
 
		case MP_WATER:
 
			// true, if not coast/riverbank
 
			return m5 != 1;
 

	
 
		case MP_STATION:
 
			// returns true if it is a dock-station
 
			// m5 inside values is m5 < 75 all stations, 83 <= m5 <= 114 new airports
 
			return !(m5 < 75 || (m5 >= 83 && m5 <= 114));
 

	
 
		case MP_TUNNELBRIDGE:
 
			// true, if tile is middle part of bridge with water underneath
 
			return (m5 & 0xF8) == 0xC8;
 

	
 
		default:
 
			return false;
 
	}
 
}
 

	
 
// draw a canal styled water tile with dikes around
0 comments (0 inline, 0 general)