From 2be4b388ec645e20fb4fa676cd70f049c927436a Mon Sep 17 00:00:00 2001 From: Darkvater Date: Sat, 18 Mar 2006 15:31:34 +0000 Subject: [PATCH] (svn r3958) Change HASBIT() to return 0/1 instead of 0/value of tested bit. Backport of r3747 from trunk --- macros.h | 2 +- pathfind.c | 4 ++-- rail.h | 2 +- rail_gui.c | 4 ++-- road_gui.c | 2 +- vehicle.c | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/macros.h b/macros.h index e4fce51d3b..8330442df1 100644 --- a/macros.h +++ b/macros.h @@ -57,7 +57,7 @@ static inline int64 BIGMULS(int32 a, int32 b) { #define IS_INSIDE_1D(x, base, size) ( (uint)((x) - (base)) < ((uint)(size)) ) -#define HASBIT(x,y) ((x) & (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))) diff --git a/pathfind.c b/pathfind.c index 9552129bce..b6e7847e27 100644 --- a/pathfind.c +++ b/pathfind.c @@ -388,8 +388,8 @@ void FollowTrack(TileIndex tile, uint16 flags, byte direction, TPFEnumProc *enum tpf.var2 = HASBIT(flags, 15) ? 0x43 : 0xFF; /* 0x8000 */ - tpf.disable_tile_hash = HASBIT(flags, 12) != 0; /* 0x1000 */ - tpf.hasbit_13 = HASBIT(flags, 13) != 0; /* 0x2000 */ + tpf.disable_tile_hash = HASBIT(flags, 12); /* 0x1000 */ + tpf.hasbit_13 = HASBIT(flags, 13); /* 0x2000 */ tpf.tracktype = (byte)flags; diff --git a/rail.h b/rail.h index c2dfbf2072..493f4ef4d0 100644 --- a/rail.h +++ b/rail.h @@ -552,7 +552,7 @@ static inline SignalType GetSignalType(TileIndex tile, Track track) static inline bool HasSemaphores(TileIndex tile, Track track) { assert(IsValidTrack(track)); - return (_m[tile].m4 & SIG_SEMAPHORE_MASK); + return (_m[tile].m4 & SIG_SEMAPHORE_MASK) != 0; } /** diff --git a/rail_gui.c b/rail_gui.c index 846d7016d7..057843f481 100644 --- a/rail_gui.c +++ b/rail_gui.c @@ -291,8 +291,8 @@ static void BuildRailClick_Remove(Window *w) SndPlayFx(SND_15_BEEP); TOGGLEBIT(w->click_state, 16); - _remove_button_clicked = HASBIT(w->click_state, 16) != 0; - SetSelectionRed(HASBIT(w->click_state, 16) != 0); + _remove_button_clicked = HASBIT(w->click_state, 16); + SetSelectionRed(HASBIT(w->click_state, 16)); // handle station builder if (HASBIT(w->click_state, 16)) { diff --git a/road_gui.c b/road_gui.c index 4fc159bb62..067125d8ca 100644 --- a/road_gui.c +++ b/road_gui.c @@ -158,7 +158,7 @@ static void BuildRoadClick_Remove(Window *w) SetWindowDirty(w); SndPlayFx(SND_15_BEEP); TOGGLEBIT(w->click_state, 11); - SetSelectionRed(HASBIT(w->click_state, 11) != 0); + SetSelectionRed(HASBIT(w->click_state, 11)); } static void BuildRoadClick_Landscaping(Window *w) diff --git a/vehicle.c b/vehicle.c index 7dd32be539..dfd52f24cf 100644 --- a/vehicle.c +++ b/vehicle.c @@ -689,7 +689,7 @@ bool CanFillVehicle(Vehicle *v) bool CanRefitTo(EngineID engine_type, CargoID cid_to) { CargoID cid = _global_cargo_id[_opt_ptr->landscape][cid_to]; - return HASBIT(_engine_info[engine_type].refit_mask, cid) != 0; + return HASBIT(_engine_info[engine_type].refit_mask, cid); } static void DoDrawVehicle(const Vehicle *v)