mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r1549) Clean up some functions:
uint tile -> TileIndex tile if () cascade -> switch ()
This commit is contained in:
parent
d4beff7954
commit
fb0c3c8061
|
@ -13,25 +13,31 @@
|
||||||
#include "airport_movement.h"
|
#include "airport_movement.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
|
||||||
static void DisasterClearSquare(uint tile)
|
static void DisasterClearSquare(TileIndex tile)
|
||||||
{
|
{
|
||||||
int type;
|
|
||||||
|
|
||||||
if (!EnsureNoVehicle(tile))
|
if (!EnsureNoVehicle(tile))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
type = TileType(tile);
|
switch (TileType(tile)) {
|
||||||
|
case MP_RAILWAY:
|
||||||
|
if (IS_HUMAN_PLAYER(_map_owner[tile])) DoClearSquare(tile);
|
||||||
|
break;
|
||||||
|
|
||||||
if (type == MP_RAILWAY) {
|
case MP_HOUSE: {
|
||||||
if (IS_HUMAN_PLAYER(_map_owner[tile]))
|
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);
|
DoClearSquare(tile);
|
||||||
} else if (type == MP_HOUSE) {
|
break;
|
||||||
byte p = _current_player;
|
|
||||||
_current_player = OWNER_NONE;
|
default:
|
||||||
DoCommandByTile(tile, 0, 0, DC_EXEC, CMD_LANDSCAPE_CLEAR);
|
break;
|
||||||
_current_player = p;
|
|
||||||
} else if (type == MP_TREES || type == MP_CLEAR) {
|
|
||||||
DoClearSquare(tile);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 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)) {
|
switch (TileType(tile)) {
|
||||||
byte m5 = _map5[tile] & 0x1C;
|
case MP_CLEAR: {
|
||||||
if (m5 == 0xC || m5 == 0x10)
|
byte m5 = _map5[tile] & 0x1C;
|
||||||
|
return m5 == 0xC || m5 == 0x10;
|
||||||
|
}
|
||||||
|
|
||||||
|
case MP_TREES:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
default:
|
||||||
return true;
|
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)) {
|
switch (TileType(tile)) {
|
||||||
byte m5 = _map5[tile] & 0x1C;
|
case MP_CLEAR: {
|
||||||
if (m5 == 0x10)
|
byte m5 = _map5[tile] & 0x1C;
|
||||||
|
return m5 == 0x10;
|
||||||
|
}
|
||||||
|
|
||||||
|
case MP_TREES:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
default:
|
||||||
return true;
|
return true;
|
||||||
return false;
|
|
||||||
} else if (IsTileType(tile, MP_TREES)) {
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
51
train_cmd.c
51
train_cmd.c
|
@ -1893,36 +1893,39 @@ static int GetDirectionToVehicle(Vehicle *v, int x, int y)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the vehicle is compatible with the specified tile */
|
/* 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)) {
|
switch (TileType(tile)) {
|
||||||
// normal tracks, jump to owner check
|
case MP_RAILWAY:
|
||||||
} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
case MP_STATION:
|
||||||
if ((_map5[tile] & 0xC0) == 0xC0) {// is bridge middle part?
|
// normal tracks, jump to owner check
|
||||||
TileInfo ti;
|
break;
|
||||||
FindLandscapeHeightByTile(&ti, tile);
|
|
||||||
|
|
||||||
// correct Z position of a train going under a bridge on slopes
|
case MP_TUNNELBRIDGE:
|
||||||
if (CORRECT_Z(ti.tileh))
|
if ((_map5[tile] & 0xC0) == 0xC0) { // is bridge middle part?
|
||||||
ti.z += 8;
|
TileInfo ti;
|
||||||
|
FindLandscapeHeightByTile(&ti, tile);
|
||||||
|
|
||||||
if(v->z_pos != ti.z) // train is going over bridge
|
// correct Z position of a train going under a bridge on slopes
|
||||||
return true;
|
if (CORRECT_Z(ti.tileh)) ti.z += 8;
|
||||||
}
|
|
||||||
} 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;
|
if (v->z_pos != ti.z) return true; // train is going over bridge
|
||||||
} else
|
}
|
||||||
return true;
|
break;
|
||||||
|
|
||||||
if (_map_owner[tile] != v->owner ||
|
case MP_STREET:
|
||||||
(v->subtype == 0 && (_map3_lo[tile] & 0xF) != v->u.rail.railtype))
|
// tracks over roads, do owner check of tracks (_map_owner[tile])
|
||||||
return false;
|
return
|
||||||
|
_map_owner[tile] == v->owner &&
|
||||||
|
(v->subtype != 0 || (_map3_hi[tile] & 0xF) == v->u.rail.railtype);
|
||||||
|
|
||||||
return true;
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
_map_owner[tile] == v->owner &&
|
||||||
|
(v->subtype != 0 || (_map3_lo[tile] & 0xF) == v->u.rail.railtype);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
30
water_cmd.c
30
water_cmd.c
|
@ -315,19 +315,27 @@ static int32 ClearTile_Water(uint tile, byte flags) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// return true if a tile is a water tile.
|
// return true if a tile is a water tile.
|
||||||
static bool IsWateredTile(uint tile)
|
static bool IsWateredTile(TileIndex tile)
|
||||||
{
|
{
|
||||||
byte m5 = _map5[tile];
|
byte m5 = _map5[tile];
|
||||||
if (IsTileType(tile, MP_WATER)) {
|
|
||||||
return m5 != 1;
|
switch (TileType(tile)) {
|
||||||
} else if (IsTileType(tile, MP_STATION)) {
|
case MP_WATER:
|
||||||
// returns true if it is a dock-station (m5 inside values is m5<75 all stations,
|
// true, if not coast/riverbank
|
||||||
// 83<=m5<=114 new airports
|
return m5 != 1;
|
||||||
return !(m5 < 75 || (m5 >= 83 && m5 <= 114));
|
|
||||||
} else if (IsTileType(tile, MP_TUNNELBRIDGE)) {
|
case MP_STATION:
|
||||||
return (m5 & 0xF8) == 0xC8;
|
// returns true if it is a dock-station
|
||||||
} else
|
// m5 inside values is m5 < 75 all stations, 83 <= m5 <= 114 new airports
|
||||||
return false;
|
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
|
// draw a canal styled water tile with dikes around
|
||||||
|
|
Loading…
Reference in New Issue