mirror of https://github.com/OpenTTD/OpenTTD
(svn r5115) Move helper functions to where they belong
parent
45ea5388fe
commit
12a68cc7c3
|
@ -0,0 +1,64 @@
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
#ifndef BRIDGE_MAP_H
|
||||||
|
#define BRIDGE_MAP_H
|
||||||
|
|
||||||
|
#include "direction.h"
|
||||||
|
#include "macros.h"
|
||||||
|
#include "map.h"
|
||||||
|
#include "rail.h"
|
||||||
|
#include "tile.h"
|
||||||
|
|
||||||
|
|
||||||
|
static inline bool IsBridge(TileIndex t)
|
||||||
|
{
|
||||||
|
assert(IsTileType(t, MP_TUNNELBRIDGE));
|
||||||
|
return HASBIT(_m[t].m5, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool IsBridgeTile(TileIndex t)
|
||||||
|
{
|
||||||
|
return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline bool IsBridgeRamp(TileIndex t)
|
||||||
|
{
|
||||||
|
assert(IsBridgeTile(t));
|
||||||
|
return !HASBIT(_m[t].m5, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline bool IsBridgeMiddle(TileIndex t)
|
||||||
|
{
|
||||||
|
assert(IsBridgeTile(t));
|
||||||
|
return HASBIT(_m[t].m5, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the direction pointing onto the bridge
|
||||||
|
*/
|
||||||
|
static inline DiagDirection GetBridgeRampDirection(TileIndex t)
|
||||||
|
{
|
||||||
|
assert(IsBridgeRamp(t));
|
||||||
|
/* Heavy wizardry to convert the X/Y (bit 0) + N/S (bit 5) encoding of
|
||||||
|
* bridges to a DiagDirection
|
||||||
|
*/
|
||||||
|
return (DiagDirection)((6 - (_m[t].m5 >> 4 & 2) - (_m[t].m5 & 1)) % 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline Axis GetBridgeAxis(TileIndex t)
|
||||||
|
{
|
||||||
|
assert(IsBridgeMiddle(t));
|
||||||
|
return (Axis)GB(_m[t].m5, 0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline bool IsTransportUnderBridge(TileIndex t)
|
||||||
|
{
|
||||||
|
assert(IsBridgeMiddle(t));
|
||||||
|
return HASBIT(_m[t].m5, 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,30 @@
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
#ifndef DIRECTION_H
|
||||||
|
#define DIRECTION_H
|
||||||
|
|
||||||
|
|
||||||
|
/* the 2 axis */
|
||||||
|
typedef enum Axis {
|
||||||
|
AXIS_X = 0,
|
||||||
|
AXIS_Y = 1,
|
||||||
|
AXIS_END
|
||||||
|
} Axis;
|
||||||
|
|
||||||
|
|
||||||
|
static inline Axis DiagDirToAxis(uint d)
|
||||||
|
{
|
||||||
|
return (Axis)(d & 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Converts an Axis to a DiagDirection
|
||||||
|
* Points always in the positive direction, i.e. S[EW]
|
||||||
|
*/
|
||||||
|
static inline uint AxisToDiagDir(Axis a)
|
||||||
|
{
|
||||||
|
return (uint)(2 - a);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
|
#include "bridge_map.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
#include "rail.h"
|
#include "rail.h"
|
||||||
|
#include "rail_map.h"
|
||||||
#include "pathfind.h"
|
#include "pathfind.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "variables.h"
|
#include "variables.h"
|
||||||
|
@ -672,12 +674,6 @@ static const byte _length_of_track[16] = {
|
||||||
DIAG_FACTOR,DIAG_FACTOR,STR_FACTOR,STR_FACTOR,STR_FACTOR,STR_FACTOR,0,0
|
DIAG_FACTOR,DIAG_FACTOR,STR_FACTOR,STR_FACTOR,STR_FACTOR,STR_FACTOR,0,0
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline bool IsBridgeMiddle(TileIndex t) {return HASBIT(_m[t].m5, 6);}
|
|
||||||
static inline uint GetBridgeAxis(TileIndex t) {return GB(_m[t].m5, 0, 1);}
|
|
||||||
static inline uint DiagDirToAxis(DiagDirection d) {return (d & 1);}
|
|
||||||
static inline bool IsBridge(TileIndex t) {return HASBIT(_m[t].m5, 7);}
|
|
||||||
static inline bool IsBridgeTile(TileIndex t) {return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t);}
|
|
||||||
static inline RailType GetRailTypeCrossing(TileIndex t) {return (RailType)GB(_m[t].m4, 0, 4);}
|
|
||||||
|
|
||||||
// new more optimized pathfinder for trains...
|
// new more optimized pathfinder for trains...
|
||||||
// Tile is the tile the train is at.
|
// Tile is the tile the train is at.
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
#ifndef RAIL_MAP_H
|
||||||
|
#define RAIL_MAP_H
|
||||||
|
|
||||||
|
#include "tile.h"
|
||||||
|
|
||||||
|
// TODO remove this by moving to the same bits as GetRailType()
|
||||||
|
static inline RailType GetRailTypeCrossing(TileIndex t)
|
||||||
|
{
|
||||||
|
return (RailType)GB(_m[t].m4, 0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -0,0 +1,23 @@
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
|
#ifndef TUNNEL_MAP_H
|
||||||
|
#define TUNNEL_MAP_H
|
||||||
|
|
||||||
|
#include "macros.h"
|
||||||
|
#include "map.h"
|
||||||
|
|
||||||
|
|
||||||
|
static inline bool IsTunnel(TileIndex t)
|
||||||
|
{
|
||||||
|
assert(IsTileType(t, MP_TUNNELBRIDGE));
|
||||||
|
return !HASBIT(_m[t].m5, 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static inline uint GetTunnelDirection(TileIndex t)
|
||||||
|
{
|
||||||
|
assert(IsTunnelTile(t));
|
||||||
|
return (uint)GB(_m[t].m5, 0, 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -7,11 +7,13 @@
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
|
#include "bridge_map.h"
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
|
#include "tunnel_map.h"
|
||||||
#include "vehicle.h"
|
#include "vehicle.h"
|
||||||
#include "viewport.h"
|
#include "viewport.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
@ -1200,13 +1202,6 @@ static void DrawTile_TunnelBridge(TileInfo *ti)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool IsTunnel(TileIndex t) {return !HASBIT(_m[t].m5, 7);}
|
|
||||||
static inline uint DiagDirToAxis(DiagDirection d) {return (d & 1);}
|
|
||||||
static inline DiagDirection GetTunnelDirection(TileIndex t) {return (DiagDirection)GB(_m[t].m5, 0, 2);}
|
|
||||||
static inline bool IsBridgeRamp(TileIndex t) {return !HASBIT(_m[t].m5, 6);}
|
|
||||||
static inline DiagDirection GetBridgeRampDirection(TileIndex t) {return (DiagDirection)((6 - (_m[t].m5 >> 4 & 2) - (_m[t].m5 & 1)) % 4);}
|
|
||||||
static inline bool IsTransportUnderBridge(TileIndex t) {return HASBIT(_m[t].m5, 5);}
|
|
||||||
static inline uint GetBridgeAxis(TileIndex t) {return GB(_m[t].m5, 0, 1);}
|
|
||||||
|
|
||||||
static uint GetSlopeZ_TunnelBridge(const TileInfo* ti)
|
static uint GetSlopeZ_TunnelBridge(const TileInfo* ti)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue