Mercurial > hg > openttd
changeset 12089:482bdd64bbe8 draft
(svn r16498) -Codechange: Remove hardly used HASBITS.
author | frosch <frosch@openttd.org> |
---|---|
date | Mon, 01 Jun 2009 15:01:54 +0000 |
parents | 7f4295a66bff |
children | b05797c0b360 |
files | src/aircraft_cmd.cpp src/autoreplace_cmd.cpp src/core/bitmath_func.hpp src/newgrf_text.cpp src/roadveh_cmd.cpp src/ship_cmd.cpp src/sortlist_type.h src/town_cmd.cpp src/train_cmd.cpp |
diffstat | 9 files changed, 27 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/src/aircraft_cmd.cpp +++ b/src/aircraft_cmd.cpp @@ -448,7 +448,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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) */
--- a/src/autoreplace_cmd.cpp +++ b/src/autoreplace_cmd.cpp @@ -613,7 +613,7 @@ 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) {
--- a/src/core/bitmath_func.hpp +++ b/src/core/bitmath_func.hpp @@ -92,18 +92,6 @@ } /** - * 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
--- a/src/newgrf_text.cpp +++ b/src/newgrf_text.cpp @@ -259,7 +259,7 @@ * 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;
--- a/src/roadveh_cmd.cpp +++ b/src/roadveh_cmd.cpp @@ -320,7 +320,7 @@ 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);
--- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -845,7 +845,7 @@ 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);
--- a/src/sortlist_type.h +++ b/src/sortlist_type.h @@ -106,7 +106,7 @@ 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 @@ 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 @@ */ bool IsDescSortOrder() const { - return HASBITS(this->flags, VL_DESC); + return (this->flags & VL_DESC) != 0; } /** @@ -241,7 +241,7 @@ 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 @@ /* 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 @@ */ bool IsFilterEnabled() const { - return HASBITS(this->flags, VL_FILTER); + return (this->flags & VL_FILTER) != 0; } /** @@ -319,7 +319,7 @@ 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 @@ */ bool NeedRebuild() const { - return HASBITS(this->flags, VL_REBUILD); + return (this->flags & VL_REBUILD) != 0; } /**
--- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -959,7 +959,7 @@ /* 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 @@ 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;
--- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -678,7 +678,7 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ * 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 @@ 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;