# HG changeset patch # User frosch # Date 2009-06-01 15:01:54 # Node ID 850e45fd8022cf67096489f41fddef46575f5860 # Parent 8950978c84335388173c9ee201449f1ca38e04ef (svn r16498) -Codechange: Remove hardly used HASBITS. diff --git a/src/aircraft_cmd.cpp b/src/aircraft_cmd.cpp --- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -448,7 +448,7 @@ CommandCost CmdSellAircraft(TileIndex ti 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, 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 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(Airc 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(Aircr 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 --- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -613,7 +613,7 @@ CommandCost CmdAutoreplaceVehicle(TileIn 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 --- a/src/core/bitmath_func.hpp +++ b/src/core/bitmath_func.hpp @@ -92,18 +92,6 @@ static FORCEINLINE bool HasBit(const T x } /** - * 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 --- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -259,7 +259,7 @@ StringID AddGRFString(uint32 grfid, uint * 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 --- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -320,7 +320,7 @@ CommandCost CmdSellRoadVeh(TileIndex til 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 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -845,7 +845,7 @@ CommandCost CmdSellShip(TileIndex tile, 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 --- 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 --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -959,7 +959,7 @@ static bool GrowTownWithBridge(const Tow /* 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, 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 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -678,7 +678,7 @@ static CommandCost CmdBuildRailWagon(Eng /* 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 T 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 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 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 t 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(Veh * 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;