mirror of https://github.com/OpenTTD/OpenTTD
(svn r16498) -Codechange: Remove hardly used HASBITS.
parent
da57fe63f3
commit
0d782b0f96
|
@ -448,7 +448,7 @@ CommandCost CmdSellAircraft(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
|
if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
if (!v->IsStoppedInDepot()) return_cmd_error(STR_ERROR_AIRCRAFT_MUST_BE_STOPPED);
|
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);
|
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;
|
airport_flags |= current_pos->block;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HASBITS(st->airport_flags, airport_flags)) {
|
if (st->airport_flags & airport_flags) {
|
||||||
v->cur_speed = 0;
|
v->cur_speed = 0;
|
||||||
v->subspeed = 0;
|
v->subspeed = 0;
|
||||||
return true;
|
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;
|
if (current_pos->block == next->block) airport_flags ^= next->block;
|
||||||
|
|
||||||
Station *st = Station::Get(v->targetairport);
|
Station *st = Station::Get(v->targetairport);
|
||||||
if (HASBITS(st->airport_flags, airport_flags)) {
|
if (st->airport_flags & airport_flags) {
|
||||||
v->cur_speed = 0;
|
v->cur_speed = 0;
|
||||||
v->subspeed = 0;
|
v->subspeed = 0;
|
||||||
return false;
|
return false;
|
||||||
|
@ -1911,7 +1911,7 @@ static bool AirportFindFreeTerminal(Aircraft *v, const AirportFTAClass *apc)
|
||||||
|
|
||||||
while (temp != NULL) {
|
while (temp != NULL) {
|
||||||
if (temp->heading == 255) {
|
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?
|
/* read which group do we want to go to?
|
||||||
* (the first free group) */
|
* (the first free group) */
|
||||||
uint target_group = temp->next_position + 1;
|
uint target_group = temp->next_position + 1;
|
||||||
|
@ -1962,7 +1962,7 @@ static bool AirportFindFreeHelipad(Aircraft *v, const AirportFTAClass *apc)
|
||||||
|
|
||||||
while (temp != NULL) {
|
while (temp != NULL) {
|
||||||
if (temp->heading == 255) {
|
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?
|
/* read which group do we want to go to?
|
||||||
* (the first free group) */
|
* (the first free group) */
|
||||||
|
|
|
@ -613,7 +613,7 @@ CommandCost CmdAutoreplaceVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1
|
||||||
|
|
||||||
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
if (!CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
if (!v->IsInDepot()) 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;
|
bool free_wagon = false;
|
||||||
if (v->type == VEH_TRAIN) {
|
if (v->type == VEH_TRAIN) {
|
||||||
|
|
|
@ -91,18 +91,6 @@ static FORCEINLINE bool HasBit(const T x, const uint8 y)
|
||||||
return (x & ((T)1U << y)) != 0;
|
return (x & ((T)1U << y)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
* Set a bit in a variable.
|
||||||
*
|
*
|
||||||
|
|
|
@ -259,7 +259,7 @@ StringID AddGRFString(uint32 grfid, uint16 stringid, byte langid_to_add, bool ne
|
||||||
* actually translated.
|
* actually translated.
|
||||||
*/
|
*/
|
||||||
if (!new_scheme) {
|
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;
|
langid_to_add = GRFLX_ENGLISH;
|
||||||
} else {
|
} else {
|
||||||
StringID ret = STR_EMPTY;
|
StringID ret = STR_EMPTY;
|
||||||
|
|
|
@ -320,7 +320,7 @@ CommandCost CmdSellRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
|
||||||
RoadVehicle *v = RoadVehicle::GetIfValid(p1);
|
RoadVehicle *v = RoadVehicle::GetIfValid(p1);
|
||||||
if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
|
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()) {
|
if (!v->IsStoppedInDepot()) {
|
||||||
return_cmd_error(STR_ERROR_ROAD_MUST_BE_STOPPED_INSIDE_DEPOT);
|
return_cmd_error(STR_ERROR_ROAD_MUST_BE_STOPPED_INSIDE_DEPOT);
|
||||||
|
|
|
@ -845,7 +845,7 @@ CommandCost CmdSellShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p
|
||||||
Ship *v = Ship::GetIfValid(p1);
|
Ship *v = Ship::GetIfValid(p1);
|
||||||
if (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
|
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()) {
|
if (!v->IsStoppedInDepot()) {
|
||||||
return_cmd_error(STR_ERROR_SHIP_MUST_BE_STOPPED_IN_DEPOT);
|
return_cmd_error(STR_ERROR_SHIP_MUST_BE_STOPPED_IN_DEPOT);
|
||||||
|
|
|
@ -106,7 +106,7 @@ public:
|
||||||
Listing GetListing() const
|
Listing GetListing() const
|
||||||
{
|
{
|
||||||
Listing l;
|
Listing l;
|
||||||
l.order = HASBITS(this->flags, VL_DESC);
|
l.order = (this->flags & VL_DESC) != 0;
|
||||||
l.criteria = this->sort_type;
|
l.criteria = this->sort_type;
|
||||||
|
|
||||||
return l;
|
return l;
|
||||||
|
@ -159,7 +159,7 @@ public:
|
||||||
Filtering GetFiltering() const
|
Filtering GetFiltering() const
|
||||||
{
|
{
|
||||||
Filtering f;
|
Filtering f;
|
||||||
f.state = HASBITS(this->flags, VL_FILTER);
|
f.state = (this->flags & VL_FILTER) != 0;
|
||||||
f.criteria = this->filter_type;
|
f.criteria = this->filter_type;
|
||||||
|
|
||||||
return f;
|
return f;
|
||||||
|
@ -214,7 +214,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool IsDescSortOrder() const
|
bool IsDescSortOrder() const
|
||||||
{
|
{
|
||||||
return HASBITS(this->flags, VL_DESC);
|
return (this->flags & VL_DESC) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -241,7 +241,7 @@ public:
|
||||||
bool Sort(SortFunction *compare)
|
bool Sort(SortFunction *compare)
|
||||||
{
|
{
|
||||||
/* Do not sort if the resort bit is not set */
|
/* 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);
|
CLRBITS(this->flags, VL_RESORT);
|
||||||
|
|
||||||
|
@ -250,9 +250,9 @@ public:
|
||||||
/* Do not sort when the list is not sortable */
|
/* Do not sort when the list is not sortable */
|
||||||
if (!this->IsSortable()) return false;
|
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);
|
CLRBITS(this->flags, VL_FIRST_SORT);
|
||||||
|
|
||||||
QSortT(this->data, this->items, compare, desc);
|
QSortT(this->data, this->items, compare, desc);
|
||||||
|
@ -292,7 +292,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool IsFilterEnabled() const
|
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)
|
bool Filter(FilterFunction *decide, F filter_data)
|
||||||
{
|
{
|
||||||
/* Do not filter if the filter bit is not set */
|
/* 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;
|
bool changed = false;
|
||||||
for (uint iter = 0; iter < this->items;) {
|
for (uint iter = 0; iter < this->items;) {
|
||||||
|
@ -363,7 +363,7 @@ public:
|
||||||
*/
|
*/
|
||||||
bool NeedRebuild() const
|
bool NeedRebuild() const
|
||||||
{
|
{
|
||||||
return HASBITS(this->flags, VL_REBUILD);
|
return (this->flags & VL_REBUILD) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -959,7 +959,7 @@ static bool GrowTownWithBridge(const Town *t, const TileIndex tile, const DiagDi
|
||||||
/* Make sure the direction is compatible with the slope.
|
/* Make sure the direction is compatible with the slope.
|
||||||
* Well we check if the slope has an up bit set in the
|
* Well we check if the slope has an up bit set in the
|
||||||
* reverse direction. */
|
* 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 */
|
/* Assure that the bridge is connectable to the start side */
|
||||||
if (!(GetTownRoadBits(TileAddByDiagDir(tile, ReverseDiagDir(bridge_dir))) & DiagDirToRoadBits(bridge_dir))) return false;
|
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);
|
SetBit(oneof, TOWN_HAS_STADIUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HASBITS(t->flags12, oneof)) continue;
|
if (t->flags12 & oneof) continue;
|
||||||
|
|
||||||
/* Make sure there is no slope? */
|
/* Make sure there is no slope? */
|
||||||
bool noslope = (hs->building_flags & TILE_NOT_SLOPED) != 0;
|
bool noslope = (hs->building_flags & TILE_NOT_SLOPED) != 0;
|
||||||
|
|
|
@ -678,7 +678,7 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, DoCommandF
|
||||||
/* do not connect new wagon with crashed/flooded consists */
|
/* do not connect new wagon with crashed/flooded consists */
|
||||||
if (w->tile == tile && IsFreeWagon(w) &&
|
if (w->tile == tile && IsFreeWagon(w) &&
|
||||||
w->engine_type == engine &&
|
w->engine_type == engine &&
|
||||||
!HASBITS(w->vehstatus, VS_CRASHED)) {
|
!(w->vehstatus & VS_CRASHED)) {
|
||||||
u = GetLastVehicleInChain(w);
|
u = GetLastVehicleInChain(w);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -995,7 +995,7 @@ static Train *FindGoodVehiclePos(const Train *src)
|
||||||
|
|
||||||
Train *dst;
|
Train *dst;
|
||||||
FOR_ALL_TRAINS(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. */
|
/* check so all vehicles in the line have the same engine. */
|
||||||
Train *t = dst;
|
Train *t = dst;
|
||||||
while (t->engine_type == eng) {
|
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;
|
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 */
|
/* 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. */
|
/* if nothing is selected as destination, try and find a matching vehicle to drag to. */
|
||||||
Train *dst;
|
Train *dst;
|
||||||
|
@ -1076,7 +1076,7 @@ CommandCost CmdMoveRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, u
|
||||||
if (dst == NULL || !CheckOwnership(dst->owner)) return CMD_ERROR;
|
if (dst == NULL || !CheckOwnership(dst->owner)) return CMD_ERROR;
|
||||||
|
|
||||||
/* Do not allow appending to crashed vehicles, too */
|
/* 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 */
|
/* 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 (v == NULL || !CheckOwnership(v->owner)) return CMD_ERROR;
|
||||||
if (p2 > 1) 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();
|
while (IsArticulatedPart(v)) v = v->Previous();
|
||||||
Train *first = v->First();
|
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 */
|
* As there might be more than two trains involved, we have to do that for all vehicles */
|
||||||
const Train *u;
|
const Train *u;
|
||||||
FOR_ALL_TRAINS(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;
|
TrackBits trackbits = u->track;
|
||||||
if ((trackbits & TRACK_BIT_WORMHOLE) == TRACK_BIT_WORMHOLE) {
|
if ((trackbits & TRACK_BIT_WORMHOLE) == TRACK_BIT_WORMHOLE) {
|
||||||
/* Vehicle is inside a wormhole, v->track contains no useful value then. */
|
/* Vehicle is inside a wormhole, v->track contains no useful value then. */
|
||||||
|
@ -4457,7 +4457,7 @@ bool Train::Tick()
|
||||||
assert(IsFrontEngine(this));
|
assert(IsFrontEngine(this));
|
||||||
|
|
||||||
return TrainLocoHandler(this, true);
|
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 */
|
/* Delete flooded standalone wagon chain */
|
||||||
if (++this->crash_anim_pos >= 4400) {
|
if (++this->crash_anim_pos >= 4400) {
|
||||||
delete this;
|
delete this;
|
||||||
|
|
Loading…
Reference in New Issue