(svn r18404) -Codechange: link drive through stops better together

-Feature: make penalty for road stop occupancy user configurable
-Fix [FS#1944]: road vehicles would not pick an empty drive through stop. Now they will *if* the penalty for driving around is less than the occupancy penalty
-Fix [FS#1495]: long (articulated) road vehicles could block loading of others when the following road vehicle already got 'permission' to go to the next bay even when it could not reach it
-Change: improve the throughput of the drive through road stops by letting them stop closer together
This commit is contained in:
rubidium
2009-12-04 20:52:19 +00:00
parent 53416773ee
commit 0fed86a779
16 changed files with 459 additions and 50 deletions

View File

@@ -25,9 +25,46 @@ struct RoadStop : RoadStopPool::PoolItem<&_roadstop_pool> {
RSSFB_BAY0_FREE = 0, ///< Non-zero when bay 0 is free
RSSFB_BAY1_FREE = 1, ///< Non-zero when bay 1 is free
RSSFB_BAY_COUNT = 2, ///< Max. number of bays
RSSFB_BASE_ENTRY = 6, ///< Non-zero when the entries on this road stop are the primary, i.e. the ones to delete
RSSFB_ENTRY_BUSY = 7, ///< Non-zero when roadstop entry is busy
};
/** Container for each entry point of a drive through road stop */
struct Entry {
private:
int length; ///< The length of the stop in tile 'units'
int occupied; ///< The amount of occupied stop in tile 'units'
public:
friend class RoadStop; ///< Oh yeah, the road stop may play with me.
/** Create an entry */
Entry() : length(0), occupied(0) {}
/**
* Get the length of this drive through stop.
* @return the length in tile units.
*/
FORCEINLINE int GetLength() const
{
return this->length;
}
/**
* Get the amount of occupied space in this drive through stop.
* @return the occupied space in tile units.
*/
FORCEINLINE int GetOccupied() const
{
return this->occupied;
}
void Leave(const RoadVehicle *rv);
void Enter(const RoadVehicle *rv);
void CheckIntegrity(const RoadStop *rs) const;
void Rebuild(const RoadStop *rs, int side = -1);
};
static const uint LIMIT = 16; ///< The maximum amount of roadstops that are allowed at a single station
TileIndex xy; ///< Position on the map
@@ -80,6 +117,29 @@ struct RoadStop : RoadStopPool::PoolItem<&_roadstop_pool> {
SB(this->status, RSSFB_ENTRY_BUSY, 1, busy);
}
/**
* Get the drive through road stop entry struct for the given direction.
* @param direction the direciton to get the entry for
* @return the entry
*/
FORCEINLINE const Entry *GetEntry(DiagDirection dir) const
{
return HasBit((int)dir, 1) ? this->west : this->east;
}
/**
* Get the drive through road stop entry struct for the given direction.
* @param direction the direciton to get the entry for
* @return the entry
*/
FORCEINLINE Entry *GetEntry(DiagDirection dir)
{
return HasBit((int)dir, 1) ? this->west : this->east;
}
void MakeDriveThrough();
void ClearDriveThrough();
void Leave(RoadVehicle *rv);
bool Enter(RoadVehicle *rv);
@@ -87,7 +147,12 @@ struct RoadStop : RoadStopPool::PoolItem<&_roadstop_pool> {
static RoadStop *GetByTile(TileIndex tile, RoadStopType type);
static bool IsDriveThroughRoadStopContinuation(TileIndex rs, TileIndex next);
private:
Entry *east; ///< The vehicles that entered from the east
Entry *west; ///< The vehicles that entered from the west
/**
* Allocates a bay
* @return the allocated bay number