FS#105 - Trains may suddenly loose their power on (el)rails
Attached to Project:
OpenTTD
Opened by Michael Lutz (michi_cc) - Saturday, 08 April 2006, 11:15 GMT
Opened by Michael Lutz (michi_cc) - Saturday, 08 April 2006, 11:15 GMT
|
DetailsI 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; } |
This task depends upon
Closed by Celestar (Celestar)
Sunday, 09 April 2006, 18:02 GMT
Reason for closing: Fixed
Sunday, 09 April 2006, 18:02 GMT
Reason for closing: Fixed
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)
also... the ICE1 seems to be affected by this also, only the effect is less, because it is dualheaded, and fixes itself quickly.
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.