Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trains may suddenly loose their power on (el)rails #105

Closed
DorpsGek opened this issue Apr 8, 2006 · 6 comments
Closed

Trains may suddenly loose their power on (el)rails #105

DorpsGek opened this issue Apr 8, 2006 · 6 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

DorpsGek commented Apr 8, 2006

michi_cc opened the ticket and wrote:

I found a strange bug during testing the physics patch. As the fault appears to be in trunk code, I don't suspect the patch causes this.

I can't confirm it, but this bugs seems to happen only with trains (electric or not ) on elrail. No occurance noticed on normal rail.

The symptoms are that trains suddenly have 0 hp, which sometimes fixes itself magically. As the train power is cached and all, it normal not to encounter this symptom. The physics patch reuses a part of the power calculations for tractive effort (TE), which goes to 0 sometimes, too; only it's much more visible then as trains will suddenly move very slowly for no apparent reason.

Calculation and caching of these values happens in TrainCargoChanged(). To debug it, I added a line to GetTrainAcceleration() that calls TrainCargoChanged() every time power or TE are 0. It's very likely that bridges (and maybe tunnels) have something to with it, as I observed a train that passed below a bridge and fixed itself, while it wasn't able to do so on the about 15 tiles of elrail before.

I was able to pin it down to the following code part from train_cmd.c line 92 inside TrainPowerChanged(). In most cases, all test should be negative an no variable setto false. The bug occurs when one of these test produces a false positive.

if (IsBridgeTile(u->tile) && IsBridgeMiddle(u->tile) && DiagDirToAxis(DirToDiagDir(u->direction)) == GetBridgeAxis(u->tile)) {
if (!HasPowerOnRail(u->u.rail.railtype, GetRailTypeOnBridge(u->tile))) engine_has_power = false;
if (!HasPowerOnRail(v->u.rail.railtype, GetRailTypeOnBridge(u->tile))) wagon_has_power = false;
} else if (IsLevelCrossing(u->tile)) {
if (!HasPowerOnRail(u->u.rail.railtype, GetRailTypeCrossing(u->tile))) engine_has_power = false;
if (!HasPowerOnRail(v->u.rail.railtype, GetRailTypeCrossing(u->tile))) wagon_has_power = false;
} else {
if (!HasPowerOnRail(u->u.rail.railtype, GetRailType(u->tile))) engine_has_power = false;
if (!HasPowerOnRail(v->u.rail.railtype, GetRailType(u->tile))) wagon_has_power = false;
}

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/105
@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 9, 2006

Eddi wrote:

i got this problem, too. especially, i noticed that the same engines repeatedly get affected by this.

i have a savegame here.

Watch the BR 103 (Train 25, center of the screen, can't miss it) going downhill. right when it hits the bottom, the power changes to 0hp. (as there was talking about caching, i assume the problem occures earlier, but the symptom shows at this time)

it then runs out until it goes uphill at the next city, where it stops half way through, blocking all following traffic. reversing the train usually fixes the problem.

to reproduce: simply wait for the next 103 to come along that point of the track (there are 3 of them on that route)


This comment was imported from FlySpray: https://bugs.openttd.org/task/105#comment183

@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 9, 2006

Eddi wrote:

forgot to add openttd.cfg...

also... the ICE1 seems to be affected by this also, only the effect is less, because it is dualheaded, and fixes itself quickly.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/105#comment184

@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 9, 2006

michi_cc wrote:

It was reported on IRC that reversing the train may magically fix it, but could cause it as well.


This comment was imported from FlySpray: https://bugs.openttd.org/task/105#comment185

@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 9, 2006

ledow wrote:

I've had this same problem on plain OpenTTD SVN (4335 and some revisions below that) with the realistic acceleration patch turned on. Reversing the train twice does usually fix it but I also notice strange ultra-slow acceleration symptoms too i.e. a train that has broken down or been told to reverse literally gaining about 1 or 2 mph per second, even though it's not on a hill and double-reversing the train sees it accelerate at normal speed (about five or six times faster?).


This comment was imported from FlySpray: https://bugs.openttd.org/task/105#comment187

@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 9, 2006

Eddi wrote:

in my savegame, the problem gets fixed, when i put an elrail under the empty bridge tile (does not work with conventional rail), so it seems to check for the rail under the bridge, not on the bridge

as for the reversing train causing 0hp problem, that was nowhere near a bridge, and i could not get this reproduceable... it seems to be related, but probably the occurence is at a completely different piece of code.


This comment was imported from FlySpray: https://bugs.openttd.org/task/105#comment188

@DorpsGek
Copy link
Member Author

DorpsGek commented Apr 9, 2006

Celestar closed the ticket.

Reason for closing: Fixed


This comment was imported from FlySpray: https://bugs.openttd.org/task/105

@DorpsGek DorpsGek closed this as completed Apr 9, 2006
@DorpsGek DorpsGek added Electrified rails flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant