mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 15:41:15 +00:00
(svn r8726) -Codechange: bools are 1 or 0 according to the C++ standard and refactor RoadStop::AllocateBay to remove a loop condition. Suggestions by Tron.
This commit is contained in:
parent
f3dc5596ad
commit
ecfbfbd98c
@ -519,7 +519,7 @@ static void ClearCrashedStation(Vehicle *v)
|
||||
rs->SetEntranceBusy(false);
|
||||
|
||||
/* Free the parking bay */
|
||||
rs->FreeBay(HASBIT(v->u.road.state, RVS_USING_SECOND_BAY) ? 1 : 0);
|
||||
rs->FreeBay(HASBIT(v->u.road.state, RVS_USING_SECOND_BAY));
|
||||
}
|
||||
|
||||
static void RoadVehDelete(Vehicle *v)
|
||||
@ -1437,7 +1437,7 @@ again:
|
||||
RoadStop *rs = GetRoadStopByTile(v->tile, GetRoadStopType(v->tile));
|
||||
|
||||
/* Vehicle is leaving a road stop tile, mark bay as free and clear the usage bit */
|
||||
rs->FreeBay(HASBIT(v->u.road.state, RVS_USING_SECOND_BAY) ? 1 : 0);
|
||||
rs->FreeBay(HASBIT(v->u.road.state, RVS_USING_SECOND_BAY));
|
||||
rs->SetEntranceBusy(false);
|
||||
}
|
||||
}
|
||||
|
@ -509,17 +509,14 @@ bool RoadStop::HasFreeBay() const
|
||||
*/
|
||||
uint RoadStop::AllocateBay()
|
||||
{
|
||||
/* Find the first free bay. If the bit is set, the bay is free. */
|
||||
for (uint bay_nr = 0; bay_nr < MAX_BAY_COUNT; bay_nr++) {
|
||||
if (HASBIT(status, bay_nr)) {
|
||||
CLRBIT(status, bay_nr);
|
||||
return bay_nr;
|
||||
}
|
||||
}
|
||||
assert(HasFreeBay());
|
||||
|
||||
/* There has to be a free bay (precondition) */
|
||||
NOT_REACHED();
|
||||
return 0;
|
||||
/* Find the first free bay. If the bit is set, the bay is free. */
|
||||
uint bay_nr = 0;
|
||||
while (!HASBIT(status, bay_nr)) bay_nr++;
|
||||
|
||||
CLRBIT(status, bay_nr);
|
||||
return bay_nr;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -542,5 +539,5 @@ bool RoadStop::IsEntranceBusy() const
|
||||
/** Makes an entrance occupied or free */
|
||||
void RoadStop::SetEntranceBusy(bool busy)
|
||||
{
|
||||
SB(status, 7, 1, !!busy);
|
||||
SB(status, 7, 1, busy);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user