summaryrefslogtreecommitdiff
path: root/src/station.cpp
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-02-14 09:34:12 +0000
committerrubidium <rubidium@openttd.org>2007-02-14 09:34:12 +0000
commitecfbfbd98cca2df5b9a33916263a06773e3836ea (patch)
tree1350c4fc7f65bb1ea2ec7a1f81e80e9017e375b9 /src/station.cpp
parentf3dc5596ad3b0e77819e78cc9ee803364d43a7c7 (diff)
downloadopenttd-ecfbfbd98cca2df5b9a33916263a06773e3836ea.tar.xz
(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.
Diffstat (limited to 'src/station.cpp')
-rw-r--r--src/station.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/station.cpp b/src/station.cpp
index e6e68631d..ec8be930a 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -509,17 +509,14 @@ bool RoadStop::HasFreeBay() const
*/
uint RoadStop::AllocateBay()
{
+ assert(HasFreeBay());
+
/* 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;
- }
- }
+ uint bay_nr = 0;
+ while (!HASBIT(status, bay_nr)) bay_nr++;
- /* There has to be a free bay (precondition) */
- NOT_REACHED();
- return 0;
+ 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);
}