The International Simutrans Forum

Simutrans Extended => Simutrans-Extended bug reports => Simutrans-Extended development => Simutrans-Extended closed bug reports => Topic started by: Ranran on May 10, 2020, 05:07:08 AM

Title: Why not allow part of convoy protrudes from the station?
Post by: Ranran on May 10, 2020, 05:07:08 AM
I posted a bug on another thread (,18496.0.html) that didn't keep your wording and had a different theme than the thread. - my apologies.

I've surveyed a little bit of code on this subject so I separate it into a new thread.

First the relevant post from the original thread is below:
Quote from: Ranran on January 09, 2020, 03:46:54 PMdepot.txt says:

The length is important because, if a convoy is too long for a stop, the vehicles at the back will be left out of the stop and will not be able to load/unload there.

Standard has such specifications, but Extended does not have such specifications and convoy is stuck if convoy exceeds station tile length . Therefore, this description seems to be incorrect.
By the way, point is, why does extended not allow exceeding station length? 
At worst, this bug should avoid getting stuck if the length of the station platform can be exceeded. (Note that the vehicle is still considered unexpectedly exceed the station. But think better than the stuck.)
And there are many examples in Japan and Asia that the train exceed the length of the station.
Actually, passengers can get off by moving to the previous vehicle. Or sometimes exceeding vehicles are mail and cargo vehicle that will not be load/unloaded at the station on the way.

Quote from: Vladki on January 09, 2020, 04:31:58 PMIt happens occasionally on czech railways too. Passengers are told in advance that if they want to get off at some station, they have to go to the first car. But there is no such mechanism in extended. In standard, you at least know which cars are exceeding the platform, and arrange the train accordingly, but in extended it won't work due to reversal mechanics.

Quote from: Freahk on January 09, 2020, 05:06:48 PMSame for Germany, at least these days, at some stations where platforms were not upgraded in time. This also happened in Britain with class 373 trains in GNER service from London to York and Leeds.

However, stucking because of being too long for a platform is still better than standards behavior, where people to a short station will stack up at cars that can't unload at the station and will never get out of it, effectively making that car useless ballast.

When allowing trains to be longer than the platform, we should in my opinion, at least warn players in lines status about "some vehicle is too long for some station in the line" and let passengers leave the train at increased loading times if a car does not fit in the station.
Also keep choose signals in mind. These should never route a train to a platform that is shorther than the scheduled one.

In addition, I don't think this special length calculation for the last car is a good idea. I already had some trains stucking after they reversed because of this.
If you think this is a good idea, we should really warn the player in the depot window if the train will be longer after reversing.

Quote from: jamespetts on January 09, 2020, 06:48:19 PMThank you for noting this. The correct behaviour where a train is too long for a station should be that it takes longer to load/unload as passengers may have to move through the train to get off. I will have to check the code when I get home (eventually - there is an extremely long queue of things for me to do) to see whether this is what happens and, if so, amend the help text accordingly.
Title: Re: Why not allow part of convoy protrudes from the station?
Post by: Ranran on May 10, 2020, 05:37:36 AM
First, from James' point of view, "NO ROUTE" when the vehicle is longer than the platform is considered a bug. So I would like to solve this cause first.
The problem is that convoy goes NO_ROUTE when route_result_t calc_route() returns route_t::valid_route_halt_too_short.

route_result_t takes the following values:
typedef enum { no_route = 0, valid_route = 1, valid_route_halt_too_short = 3, route_too_complex = 4, no_control_tower = 5 } route_result_t;

The route should be found even if there is a problem with the station length. It seems that calc_route correctly returns valid_route_halt_too_short when the station is short. This part is not much different from standard.

When valid_route_halt_too_short, it seems that the convoy status is NO_ROUTE for some reason. I searched for the cause.
I think this is caused by valid_route_halt_too_short being caught in the judgment of line 1565 of (, and as a result it was set to NO_ROUTE at line 1567.

This change seems to solve the NO ROUTE problem. This fix is attached to this post as a patch file. (EDIT: The first patch had an uncorrected route search when leaving the depot.)
Same as standard, exceeding the length of the station is indicated by annoying warning message spam.

This was unintentional NO ROUTE until now, but I do not know whether the protruding vehicle is loaded correctly. We will have to deal with it carefully.
Maybe it's done in convoi_t::hat_gehalten, but we can see comments by neroden and james there (

// We only unload & load vehicles which are within the station.
// To fix: this creates undesired behavior for long trains, because the
// cars in the back will not load/unload in "short" platforms.
// Proposed fix: load passengers from back of the train to the front,
// selectively delaying loading passengers destined for "short" platforms
// in order to get them into the cars in the front of the station.  Just like
// real conductors do.
// Query: this makes sense only for passenger carriages with gangways.
// Is it really sensible to implement this for all vehicles, including
// older passenger carriages without gangways, mail carriages and goods
// trucks, where passing through the train is not possible?
// This will require tracking platform length in the schedule object.
// --neroden

The murals of this excavated site are 3-7 years old.
I haven't cracked this cipher yet, but given that it remains, I suspect these plans are still unimplemented.

Apart from that, the length change problem due to reverse - Since this is a problem using "fake" length, I think that it can be solved by using the "true" length for determining the platform length when calculating the route.

// station too short => warning!
if(max_len > platform_size)
return valid_route_halt_too_short;

That is, use true convoy_length for max_len.
It is impractical to increase the required platform length if vehicles of the same configuration are reversed. Therefore, prepare another function that returns the true length of convoy and use it.

I pushed the branch with the last change. The no route bug due to reversing is fixed. Maybe only the railway?
The repository is here: (

This means that the value of the tile displayed in convoy detail etc. may be inconsistent (´ ・ ω ・ `)
It includes 0-8 padding length, so reversining may increase the length.
You can check by this saved game (
Reversing will increase the convoy tile length to 2, but it won't get stuck and no warning will be issued. If you really have a convoy of tile length 2, you will get a warning.

It seems that the first station on the schedule cannot be exited from the depot unless it fits within the tile length. This behavior is different from the standard. fixed.
Title: Re: Why not allow part of convoy protrudes from the station?
Post by: jamespetts on May 16, 2020, 08:39:02 PM
Thank you for this: I have now incorporated the fix. The correct behaviour when a train is too long for its stop, I think, would be:

(1) to disallow any loading to the rear carriages/wagons that exceed the length; and
(2) if there be any unloading to be done from these, drastically extend the stop dwell time to simulate the train having to pull forward and stop again.
Title: Re: Why not allow part of convoy protrudes from the station?
Post by: Sirius on May 16, 2020, 09:52:24 PM
I don't think that is done in practice, not even in the UK.

What you describe might be practical for carriages without a corridor, but definitely not for corridor trains, where simply doors that don't fit on the platform stay closed.
Passengers have to walk to a door that is at a platform, which usually does not at all increase loading times more than the linar scale of doors in use, as this is communicated before the train stops, thus pasengers will be waiting at door that actually open.

Same was done with Eurostars in GNER service from London to York and Leeds, as mentioned.
Title: Re: Why not allow part of convoy protrudes from the station?
Post by: Ranran on May 16, 2020, 10:41:03 PM
Thank you for incorporating.
Note that there may still be some work to do.

I have not confirmed in detail about the handling of vehicles that have run off the station.
But I think it's been the intended behavior.

Resolving the length display conflict requires solving the convoy length calculation problem for other threads ...

What happened when passengers tried to get off at a station without a platform in the days when there was a vehicle without a corridor?
Did they refuse to board the vehicle? I guess that they can move to the previous vehicle at the station where it stopped in advance. Also, in the old days, it wasn't much attention to getting off the tracks in Japan. So it's possible that they were getting off to the track ... and old platform was very low.
Title: Re: Why not allow part of convoy protrudes from the station?
Post by: accord2 on May 17, 2020, 09:48:13 AM
I don't know much about what how it is done in England or Japan. But in Portugal in Summer it's normal to have longer trains which usually don't fit the platforms. Trains will take a bit longer to unload at each station to make sure everyone had time to get out (because people may have large travel bags). Last century, the plaforms were minimal, usually one carriage size at smaller stations. Everyone would simple jump to the tracks or use the plaform if they had some mobility problem/carried large bags.

Edit: Maybe loading times can be the same for older trains (before automatic doors era) and a bit longer for more modern times? I don't know if this can be put into code.... But this would allow smaller companies to save money in 19th and early 20th century and also make the railways more expensive thus making the player prepare better in modern times.
Title: Re: Why not allow part of convoy protrudes from the station?
Post by: Sirius on May 17, 2020, 10:46:12 AM
Quote from: accord2 on May 17, 2020, 09:48:13 AMMaybe loading times can be the same for older trains (before automatic doors era) and a bit longer for more modern times?
We cannot distinguish automatic doors from manual doors. Furthermore, the platform height will likely play a huge role in this. Old Trains designed for low platforms are equipped with strairs, so there it shouln't be a problem, apart from security concerns, to load outside of platforms.
Modern trains designed for high platforms won't allow passengers to enter the train without a platform, no matter if the high entrance has automatic or manual doors.
Such aspects are reflected in vehicles loading times already, so for simplicity, I don't think we should distinguish these.

Imho opinion, for simplicity reasons, carriages with a corridor should allow for loading at too short platforms, using a time penalty relative to how much percent of the train fits to the station.

Trains without a corridor should either be handled just the same, for simplicity reasons, or use a longer time penalty, simulating stopping multiple times.
Title: Re: Why not allow part of convoy protrudes from the station?
Post by: Vladki on May 17, 2020, 01:13:35 PM
There must be some penalty for using longer trains than platforms. Also in real world even if the platform is shorter, the train must at least fit between points (switches) at both ends of station.
Corridors between carriages are relevant only for passengers. Cargo and mail will not move on its own. So imho the best solution would be:
- do not load carriages that are off the platform
- check the length of platform where the cargo (or mail or pax) is to be unloaded (transfer or final dest.) and load it only to the carriages that will be on the destination platform
- that will avoid the problem how to unload carriages that are off the platform (it may still happen if recombination is implemented).
- also avoiding cargo stuck at the end of train forever, due to short destination platform

I agree that this might be quite complicated to implement, so a simpler interim solution would be to increase the loading time to simulate shunting, people pushing their way through the train to the right door, shouting on everyone "please wait, I have to take off here !!!", or people jumping out of random doors, falling into bushes, touching 3rd rail, etc... Such penalty should be higher for overcrowded convoys.

An easy to do calculation would be to multiply the loading time by the proportion of train that is not on the platform. I.e. if only 1/3 of train is on platform, loading time will be 3x longer. (Simulates shunting with cargo train). Minimum penalty would be 2x longer. That would be good for overcrowded trains too, so we may not need to distinguish overcrowded or not, corridor or not. Or make a bonus for non-overcrowded passenger trains, to make the minimum penalty only 1.5x longer loading time. (To account for some intelligence in passengers that they will somewhat prepare for unloading in shorter platform).

In both cases this information should be prominently displayed to player as it is now, just with the difference that the train will not get stuck because of short platform.
Title: Re: Why not allow part of convoy protrudes from the station?
Post by: Ranran on May 17, 2020, 01:24:37 PM
Penalty calculation should be divided into passenger, mail and goods. People can walk on their own.
Freight vehicles that have to be shunted will incur significant penalties for each.

We also need to check if vehicle want to unload. Each protruded vehicle needs to be checked for unloading.
For example, don't take a penalty at a station that doesn't handle mail, even if mail vehicle doesn't have a its platform.
Overhanging the brake van is not a problem.