diff src/station_cmd.cpp @ 5990:3ccf6528ac1f draft

(svn r8694) -Codechange: make RoadStop's status accessible via accessor functions.
author rubidium <rubidium@openttd.org>
date Tue, 13 Feb 2007 00:25:42 +0000 (2007-02-13)
parents 9d9c1c80f583
children 1b793d99b5ba
line wrap: on
line diff
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -2278,25 +2278,17 @@
 				/* Attempt to allocate a parking bay in a road stop */
 				RoadStop *rs = GetRoadStopByTile(tile, GetRoadStopType(tile));
 
-				/* rs->status bits 0 and 1 describe current the two parking spots.
-				 * 0 means occupied, 1 means free. */
-
-				// Check if station is busy or if there are no free bays.
-				if (HASBIT(rs->status, 7) || GB(rs->status, 0, 2) == 0)
-					return 8;
+				/* Check if station is busy or if there are no free bays. */
+				if (rs->IsEntranceBusy() || !rs->HasFreeBay()) return 8;
 
 				v->u.road.state += 32;
 
-				// if the first bay is free, allocate that, else the second bay must be free.
-				if (HASBIT(rs->status, 0)) {
-					CLRBIT(rs->status, 0);
-				} else {
-					CLRBIT(rs->status, 1);
-					v->u.road.state += 2;
-				}
-
-				// mark the station as busy
-				SETBIT(rs->status, 7);
+				/* Allocate a bay and update the road state */
+				uint bay_nr = rs->AllocateBay();
+				SB(v->u.road.state, 1, 1, bay_nr);
+
+				/* Mark the station entrace as busy */
+				rs->SetEntranceBusy(true);
 			}
 		}
 	}