diff options
author | frosch <frosch@openttd.org> | 2009-06-01 15:01:54 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2009-06-01 15:01:54 +0000 |
commit | 0d782b0f96f01e7d9ac02120b8e5ca84fe9bc9f2 (patch) | |
tree | 9247ff8c6b63c62820520758d14a26b3a47f973e | |
parent | da57fe63f348a1f4628b9f17df171f4c54f0d2e7 (diff) | |
download | openttd-0d782b0f96f01e7d9ac02120b8e5ca84fe9bc9f2.tar.xz |
(svn r16498) -Codechange: Remove hardly used HASBITS.
-rw-r--r-- | src/aircraft_cmd.cpp | 10 | ||||
-rw-r--r-- | src/autoreplace_cmd.cpp | 2 | ||||
-rw-r--r-- | src/core/bitmath_func.hpp | 12 | ||||
-rw-r--r-- | src/newgrf_text.cpp | 2 | ||||
-rw-r--r-- | src/roadveh_cmd.cpp | 2 | ||||
-rw-r--r-- | src/ship_cmd.cpp | 2 | ||||
-rw-r--r-- | src/sortlist_type.h | 18 | ||||
-rw-r--r-- | src/town_cmd.cpp | 4 | ||||
-rw-r--r-- | src/train_cmd.cpp | 14 |
9 files changed, 27 insertions, 39 deletions
diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp index 817895f35..6a7c9258e 100644 --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -448,7 +448,7 @@ CommandCost CmdSellAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uint if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR; if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED); - if (HASBITS(v->vehstatus, VS_CRASHED)) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE); + if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE); CommandCost ret(EXPENSES_NEW_VEHICLES, -v->value); @@ -1816,7 +1816,7 @@ static bool AirportHasBlock(Aircraft *v, const AirportFTA *current_pos, const Ai airport_flags |= current_pos->block; } - if (HASBITS(st->airport_flags, airport_flags)) { + if (st->airport_flags & airport_flags) { v->cur_speed = 0; v->subspeed = 0; return true; @@ -1857,7 +1857,7 @@ static bool AirportSetBlocks(Aircraft *v, const AirportFTA *current_pos, const A if (current_pos->block == next->block) airport_flags ^= next->block; Station *st = Station::Get(v->targetairport); - if (HASBITS(st->airport_flags, airport_flags)) { + if (st->airport_flags & airport_flags) { v->cur_speed = 0; v->subspeed = 0; return false; @@ -1911,7 +1911,7 @@ static bool AirportFindFreeTerminal(Aircraft *v, const AirportFTAClass *apc) while (temp != NULL) { if (temp->heading == 255) { - if (!HASBITS(st->airport_flags, temp->block)) { + if (!(st->airport_flags & temp->block)) { /* read which group do we want to go to? * (the first free group) */ uint target_group = temp->next_position + 1; @@ -1962,7 +1962,7 @@ static bool AirportFindFreeHelipad(Aircraft *v, const AirportFTAClass *apc) while (temp != NULL) { if (temp->heading == 255) { - if (!HASBITS(st->airport_flags, temp->block)) { + if (!(st->airport_flags & temp->block)) { /* read which group do we want to go to? * (the first free group) */ diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp index fd1228501..948286d69 100644 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -613,7 +613,7 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1 if (!CheckOwnership(v->owner)) return CMD_ERROR; if (!v->IsInDepot()) return CMD_ERROR; - if (HASBITS(v->vehstatus, VS_CRASHED)) return CMD_ERROR; + if (v->vehstatus & VS_CRASHED) return CMD_ERROR; bool free_wagon = false; if (v->type == VEH_TRAIN) { diff --git a/src/core/bitmath_func.hpp b/src/core/bitmath_func.hpp index f32aee67c..2da6d89ac 100644 --- a/src/core/bitmath_func.hpp +++ b/src/core/bitmath_func.hpp @@ -92,18 +92,6 @@ static FORCEINLINE bool HasBit(const T x, const uint8 y) } /** - * Check several bits in a value. - * - * This macro checks if a value contains at least one bit of an other - * value. - * - * @param x The first value - * @param y The second value - * @return True if at least one bit is set in both values, false else. - */ -#define HASBITS(x, y) (((x) & (y)) != 0) - -/** * Set a bit in a variable. * * This function sets a bit in a variable. The variable is changed diff --git a/src/newgrf_text.cpp b/src/newgrf_text.cpp index 50e111e4a..acf5e8585 100644 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -259,7 +259,7 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne * actually translated. */ if (!new_scheme) { - if (HASBITS(langid_to_add, GRFLB_AMERICAN | GRFLB_ENGLISH)) { + if (langid_to_add & (GRFLB_AMERICAN | GRFLB_ENGLISH)) { langid_to_add = GRFLX_ENGLISH; } else { StringID ret = STR_EMPTY; diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp index 59166a46a..8943b44d6 100644 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -320,7 +320,7 @@ CommandCost CmdSellRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 RoadVehicle *v = RoadVehicle::GetIfValid(p1); if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR; - if (HASBITS(v->vehstatus, VS_CRASHED)) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE); + if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE); if (!v->IsStoppedInDepot()) { return_cmd_error(STR_ERROR_ROAD_MUST_BE_STOPPED_INSIDE_DEPOT); diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index a5c8b9195..226460ce1 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -845,7 +845,7 @@ CommandCost CmdSellShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p Ship *v = Ship::GetIfValid(p1); if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR; - if (HASBITS(v->vehstatus, VS_CRASHED)) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE); + if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE); if (!v->IsStoppedInDepot()) { return_cmd_error(STR_ERROR_SHIP_MUST_BE_STOPPED_IN_DEPOT); diff --git a/src/sortlist_type.h b/src/sortlist_type.h index 29c7cc4c3..101d11152 100644 --- a/src/sortlist_type.h +++ b/src/sortlist_type.h @@ -106,7 +106,7 @@ public: Listing GetListing() const { Listing l; - l.order = HASBITS(this->flags, VL_DESC); + l.order = (this->flags & VL_DESC) != 0; l.criteria = this->sort_type; return l; @@ -159,7 +159,7 @@ public: Filtering GetFiltering() const { Filtering f; - f.state = HASBITS(this->flags, VL_FILTER); + f.state = (this->flags & VL_FILTER) != 0; f.criteria = this->filter_type; return f; @@ -214,7 +214,7 @@ public: */ bool IsDescSortOrder() const { - return HASBITS(this->flags, VL_DESC); + return (this->flags & VL_DESC) != 0; } /** @@ -241,7 +241,7 @@ public: bool Sort(SortFunction *compare) { /* Do not sort if the resort bit is not set */ - if (!HASBITS(this->flags, VL_RESORT)) return false; + if (!(this->flags & VL_RESORT)) return false; CLRBITS(this->flags, VL_RESORT); @@ -250,9 +250,9 @@ public: /* Do not sort when the list is not sortable */ if (!this->IsSortable()) return false; - const bool desc = HASBITS(this->flags, VL_DESC); + const bool desc = (this->flags & VL_DESC) != 0; - if (HASBITS(this->flags, VL_FIRST_SORT)) { + if (this->flags & VL_FIRST_SORT) { CLRBITS(this->flags, VL_FIRST_SORT); QSortT(this->data, this->items, compare, desc); @@ -292,7 +292,7 @@ public: */ bool IsFilterEnabled() const { - return HASBITS(this->flags, VL_FILTER); + return (this->flags & VL_FILTER) != 0; } /** @@ -319,7 +319,7 @@ public: bool Filter(FilterFunction *decide, F filter_data) { /* Do not filter if the filter bit is not set */ - if (!HASBITS(this->flags, VL_FILTER)) return false; + if (!(this->flags & VL_FILTER)) return false; bool changed = false; for (uint iter = 0; iter < this->items;) { @@ -363,7 +363,7 @@ public: */ bool NeedRebuild() const { - return HASBITS(this->flags, VL_REBUILD); + return (this->flags & VL_REBUILD) != 0; } /** diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp index dc42786cb..6bf8c7941 100644 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -959,7 +959,7 @@ static bool GrowTownWithBridge(const Town *t, const TileIndex tile, const DiagDi /* Make sure the direction is compatible with the slope. * Well we check if the slope has an up bit set in the * reverse direction. */ - if (HASBITS(slope, InclinedSlope(bridge_dir))) return false; + if (slope & InclinedSlope(bridge_dir)) return false; /* Assure that the bridge is connectable to the start side */ if (!(GetTownRoadBits(TileAddByDiagDir(tile, ReverseDiagDir(bridge_dir))) & DiagDirToRoadBits(bridge_dir))) return false; @@ -2121,7 +2121,7 @@ static bool BuildTownHouse(Town *t, TileIndex tile) SetBit(oneof, TOWN_HAS_STADIUM); } - if (HASBITS(t->flags12, oneof)) continue; + if (t->flags12 & oneof) continue; /* Make sure there is no slope? */ bool noslope = (hs->building_flags & TILE_NOT_SLOPED) != 0; diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 6ad8707c6..7a377098c 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -678,7 +678,7 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, DoCommandF /* do not connect new wagon with crashed/flooded consists */ if (w->tile == tile && IsFreeWagon(w) && w->engine_type == engine && - !HASBITS(w->vehstatus, VS_CRASHED)) { + !(w->vehstatus & VS_CRASHED)) { u = GetLastVehicleInChain(w); break; } @@ -995,7 +995,7 @@ static Train *FindGoodVehiclePos(const Train *src) Train *dst; FOR_ALL_TRAINS(dst) { - if (IsFreeWagon(dst) && dst->tile == tile && !HASBITS(dst->vehstatus, VS_CRASHED)) { + if (IsFreeWagon(dst) && dst->tile == tile && !(dst->vehstatus & VS_CRASHED)) { /* check so all vehicles in the line have the same engine. */ Train *t = dst; while (t->engine_type == eng) { @@ -1065,7 +1065,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u if (src == NULL || !CheckOwnership(src->owner)) return CMD_ERROR; /* Do not allow moving crashed vehicles inside the depot, it is likely to cause asserts later */ - if (HASBITS(src->vehstatus, VS_CRASHED)) return CMD_ERROR; + if (src->vehstatus & VS_CRASHED) return CMD_ERROR; /* if nothing is selected as destination, try and find a matching vehicle to drag to. */ Train *dst; @@ -1076,7 +1076,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u if (dst == NULL || !CheckOwnership(dst->owner)) return CMD_ERROR; /* Do not allow appending to crashed vehicles, too */ - if (HASBITS(dst->vehstatus, VS_CRASHED)) return CMD_ERROR; + if (dst->vehstatus & VS_CRASHED) return CMD_ERROR; } /* if an articulated part is being handled, deal with its parent vehicle */ @@ -1416,7 +1416,7 @@ CommandCost CmdSellRailWagon(TileIndex tile, DoCommandFlag flags, uint32 p1, uin if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR; if (p2 > 1) return CMD_ERROR; - if (HASBITS(v->vehstatus, VS_CRASHED)) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE); + if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_CAN_T_SELL_DESTROYED_VEHICLE); while (IsArticulatedPart(v)) v = v->Previous(); Train *first = v->First(); @@ -3574,7 +3574,7 @@ static Vehicle *FindTrainCollideEnum(Vehicle *v, void *data) * As there might be more than two trains involved, we have to do that for all vehicles */ const Train *u; FOR_ALL_TRAINS(u) { - if (HASBITS(u->vehstatus, VS_CRASHED) && (u->track & TRACK_BIT_DEPOT) == TRACK_BIT_NONE) { + if ((u->vehstatus & VS_CRASHED) && (u->track & TRACK_BIT_DEPOT) == TRACK_BIT_NONE) { TrackBits trackbits = u->track; if ((trackbits & TRACK_BIT_WORMHOLE) == TRACK_BIT_WORMHOLE) { /* Vehicle is inside a wormhole, v->track contains no useful value then. */ @@ -4457,7 +4457,7 @@ bool Train::Tick() assert(IsFrontEngine(this)); return TrainLocoHandler(this, true); - } else if (IsFreeWagon(this) && HASBITS(this->vehstatus, VS_CRASHED)) { + } else if (IsFreeWagon(this) && (this->vehstatus & VS_CRASHED)) { /* Delete flooded standalone wagon chain */ if (++this->crash_anim_pos >= 4400) { delete this; |