summaryrefslogtreecommitdiff
path: root/station_cmd.c
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-04-03 14:25:32 +0000
committercelestar <celestar@openttd.org>2006-04-03 14:25:32 +0000
commit5931b34aff7f774ec2a591e5658d25706fe01066 (patch)
tree93820da9b941ae74b1d1ae37cd47bc46b37c3434 /station_cmd.c
parent961b44e697111245a43d3aa98d606e15fe97ad5d (diff)
downloadopenttd-5931b34aff7f774ec2a591e5658d25706fe01066.tar.xz
(svn r4259) -[multistop] Fix/Feature/Codechange:
1) Improved the road vehicle allocation (aka slotting) for multistop. Stops can now accept unlimited, er... 256, vehicles. 2) Removed the "wait for stop" feature, because it did not work in practise. 3) Slotting now ignores unreachable stations. Uses NPF at the moment because the old pathfinder cannot do it (yet) 4) Now matter how many vehicles approach a station, they will always be distributed evenly over existing stops. 5) Hopefully the last fundamental change to multistop
Diffstat (limited to 'station_cmd.c')
-rw-r--r--station_cmd.c41
1 files changed, 4 insertions, 37 deletions
diff --git a/station_cmd.c b/station_cmd.c
index c73072782..17edbd950 100644
--- a/station_cmd.c
+++ b/station_cmd.c
@@ -87,15 +87,13 @@ static void MarkStationDirty(const Station* st)
static void InitializeRoadStop(RoadStop *road_stop, RoadStop *previous, TileIndex tile, StationID index)
{
- int i;
road_stop->xy = tile;
road_stop->used = true;
road_stop->status = 3; //stop is free
road_stop->next = NULL;
road_stop->prev = previous;
road_stop->station = index;
-
- for (i = 0; i < NUM_SLOTS; i++) road_stop->slot[i] = INVALID_VEHICLE;
+ road_stop->num_vehicles = 0;
}
RoadStop* GetPrimaryRoadStop(const Station* st, RoadStopType type)
@@ -1412,17 +1410,8 @@ static int32 RemoveRoadStop(Station *st, uint32 flags, TileIndex tile)
if (!EnsureNoVehicle(tile)) return CMD_ERROR;
if (flags & DC_EXEC) {
- uint i;
DoClearSquare(tile);
- /* Clear all vehicles destined for this station */
- for (i = 0; i != NUM_SLOTS; i++) {
- if (cur_stop->slot[i] != INVALID_VEHICLE) {
- Vehicle *v = GetVehicle(cur_stop->slot[i]);
- ClearSlot(v);
- }
- }
-
cur_stop->used = false;
if (cur_stop->prev != NULL) cur_stop->prev->next = cur_stop->next;
if (cur_stop->next != NULL) cur_stop->next->prev = cur_stop->prev;
@@ -2254,27 +2243,6 @@ void DeleteAllPlayerStations(void)
}
}
-static void CheckOrphanedSlots(const Station *st, RoadStopType rst)
-{
- RoadStop *rs;
- uint k;
-
- for (rs = GetPrimaryRoadStop(st, rst); rs != NULL; rs = rs->next) {
- for (k = 0; k < NUM_SLOTS; k++) {
- if (rs->slot[k] != INVALID_VEHICLE) {
- const Vehicle *v = GetVehicle(rs->slot[k]);
-
- if (v->type != VEH_Road || v->u.road.slot != rs) {
- DEBUG(ms, 0) (
- "Multistop: Orphaned %s slot at 0x%X of station %d (don't panic)",
- (rst == RS_BUS) ? "bus" : "truck", rs->xy, st->index);
- rs->slot[k] = INVALID_VEHICLE;
- }
- }
- }
- }
-}
-
/* this function is called for one station each tick */
static void StationHandleBigTick(Station *st)
{
@@ -2282,9 +2250,6 @@ static void StationHandleBigTick(Station *st)
if (st->facilities == 0 && ++st->delete_ctr >= 8) DeleteStation(st);
- // Here we saveguard against orphaned slots
- CheckOrphanedSlots(st, RS_BUS);
- CheckOrphanedSlots(st, RS_TRUCK);
}
static inline void byte_inc_sat(byte *p) { byte b = *p + 1; if (b != 0) *p = b; }
@@ -2783,7 +2748,8 @@ static const SaveLoad _roadstop_desc[] = {
SLE_REF(RoadStop,next, REF_ROADSTOPS),
SLE_REF(RoadStop,prev, REF_ROADSTOPS),
- SLE_ARR(RoadStop,slot, SLE_UINT16, NUM_SLOTS),
+ SLE_CONDNULL(4, 0, 24),
+ SLE_CONDVAR(RoadStop, num_vehicles, SLE_UINT8, 25, SL_MAX_VERSION),
SLE_END()
};
@@ -2952,6 +2918,7 @@ static void Load_ROADSTOP(void)
error("RoadStops: failed loading savegame: too many RoadStops");
rs = GetRoadStop(index);
+ rs->num_vehicles = 0;
SlObject(rs, _roadstop_desc);
}
}