mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-07 06:46:43 +00:00
(svn r8732) -Codechange/Fix(r8705): Turned the bit-handling macros into template functions. Fixes a problem with MSVC and 64-bit shifts.
This commit is contained in:
parent
447b16930e
commit
59a814c6d3
@ -372,9 +372,9 @@ static void AyStar_AiPathFinder_GetNeighbours(AyStar *aystar, OpenListNode *curr
|
||||
extern uint GetRailFoundation(Slope tileh, TrackBits bits); // XXX function declaration in .c
|
||||
extern uint GetRoadFoundation(Slope tileh, RoadBits bits); // XXX function declaration in .c
|
||||
extern uint GetBridgeFoundation(Slope tileh, Axis); // XXX function declaration in .c
|
||||
enum {
|
||||
typedef enum BridgeFoundations{
|
||||
BRIDGE_NO_FOUNDATION = 1 << 0 | 1 << 3 | 1 << 6 | 1 << 9 | 1 << 12,
|
||||
};
|
||||
} BridgeFoundation;
|
||||
|
||||
// The most important function: it calculates the g-value
|
||||
static int32 AyStar_AiPathFinder_CalculateG(AyStar *aystar, AyStarNode *current, OpenListNode *parent)
|
||||
|
27
src/macros.h
27
src/macros.h
@ -62,11 +62,30 @@ static inline int64 BIGMULS(int32 a, int32 b) {
|
||||
//#define IS_INSIDE_1D(x, base, size) ((x) >= (base) && (x) < (base) + (size))
|
||||
#define IS_INSIDE_1D(x, base, size) ( (uint)((x) - (base)) < ((uint)(size)) )
|
||||
|
||||
template <typename T>
|
||||
static inline bool HASBIT(T x, int y)
|
||||
{
|
||||
return (x & (((T)1) << y)) != 0;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static inline T SETBIT(T& x, int y)
|
||||
{
|
||||
return x |= (((T)1) << y);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static inline T CLRBIT(T& x, int y)
|
||||
{
|
||||
return x &= ~(((T)1) << y);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static inline T TOGGLEBIT(T& x, int y)
|
||||
{
|
||||
return x ^= (((T)1) << y);
|
||||
}
|
||||
|
||||
#define HASBIT(x,y) (((x) & (1 << (y))) != 0)
|
||||
#define SETBIT(x,y) ((x) |= (1 << (y)))
|
||||
#define CLRBIT(x,y) ((x) &= ~(1 << (y)))
|
||||
#define TOGGLEBIT(x,y) ((x) ^= (1 << (y)))
|
||||
|
||||
// checking more bits. Maybe unneccessary, but easy to use
|
||||
#define HASBITS(x,y) ((x) & (y))
|
||||
|
@ -77,7 +77,7 @@ int CalcBridgeLenCostFactor(int x)
|
||||
}
|
||||
|
||||
#define M(x) (1 << (x))
|
||||
enum {
|
||||
typedef enum BridgeFoundations{
|
||||
// foundation, whole tile is leveled up --> 3 corners raised
|
||||
BRIDGE_FULL_LEVELED_FOUNDATION = M(SLOPE_WSE) | M(SLOPE_NWS) | M(SLOPE_ENW) | M(SLOPE_SEN),
|
||||
// foundation, tile is partly leveled up --> 1 corner raised
|
||||
@ -85,7 +85,7 @@ enum {
|
||||
// no foundations (X,Y direction)
|
||||
BRIDGE_NO_FOUNDATION = M(SLOPE_FLAT) | M(SLOPE_SW) | M(SLOPE_SE) | M(SLOPE_NW) | M(SLOPE_NE),
|
||||
BRIDGE_HORZ_RAMP = (BRIDGE_PARTLY_LEVELED_FOUNDATION | BRIDGE_NO_FOUNDATION) & ~M(SLOPE_FLAT)
|
||||
};
|
||||
} BridgeFoundataion;
|
||||
#undef M
|
||||
|
||||
static inline const PalSpriteID *GetBridgeSpriteTable(int index, byte table)
|
||||
|
Loading…
Reference in New Issue
Block a user