Fix VehiclePositionIsAllowed triggering assertions on virtual trains.

This fixes the bug where a bankruptcy/company reset when another
company owned a virtual train caused an assertion failure.
This commit is contained in:
Jonathan G Rennison
2016-03-10 00:03:40 +00:00
parent 910edffee0
commit 320233fc9b

View File

@@ -98,8 +98,10 @@ void PayDailyTrackSharingFee(Train *v)
*/
static bool VehiclePositionIsAllowed(const Vehicle *v, Owner owner = INVALID_OWNER)
{
if (!IsValidTile(v->tile)) return true;
switch (v->type) {
case VEH_TRAIN:
if (HasBit(Train::From(v)->subtype, GVSF_VIRTUAL)) return true;
for (const Vehicle *u = v; u != NULL; u = u->Next()) {
if (!IsInfraTileUsageAllowed(VEH_TRAIN, v->owner, u->tile) || GetTileOwner(u->tile) == owner) return false;
}