equal
deleted
inserted
replaced
507 * @return the allocated bay number |
507 * @return the allocated bay number |
508 * @pre this->HasFreeBay() |
508 * @pre this->HasFreeBay() |
509 */ |
509 */ |
510 uint RoadStop::AllocateBay() |
510 uint RoadStop::AllocateBay() |
511 { |
511 { |
|
512 assert(HasFreeBay()); |
|
513 |
512 /* Find the first free bay. If the bit is set, the bay is free. */ |
514 /* Find the first free bay. If the bit is set, the bay is free. */ |
513 for (uint bay_nr = 0; bay_nr < MAX_BAY_COUNT; bay_nr++) { |
515 uint bay_nr = 0; |
514 if (HASBIT(status, bay_nr)) { |
516 while (!HASBIT(status, bay_nr)) bay_nr++; |
515 CLRBIT(status, bay_nr); |
517 |
516 return bay_nr; |
518 CLRBIT(status, bay_nr); |
517 } |
519 return bay_nr; |
518 } |
|
519 |
|
520 /* There has to be a free bay (precondition) */ |
|
521 NOT_REACHED(); |
|
522 return 0; |
|
523 } |
520 } |
524 |
521 |
525 /** |
522 /** |
526 * Frees the given bay |
523 * Frees the given bay |
527 * @param nr the number of the bay to free |
524 * @param nr the number of the bay to free |
540 } |
537 } |
541 |
538 |
542 /** Makes an entrance occupied or free */ |
539 /** Makes an entrance occupied or free */ |
543 void RoadStop::SetEntranceBusy(bool busy) |
540 void RoadStop::SetEntranceBusy(bool busy) |
544 { |
541 { |
545 SB(status, 7, 1, !!busy); |
542 SB(status, 7, 1, busy); |
546 } |
543 } |