FS#1160 - Tram deadlock, r10975

Attached to Project: OpenTTD
Opened by sedlacl (sedlacl) - Sunday, 26 August 2007, 09:46 GMT
Last edited by Remko Bijker (Rubidium) - Monday, 27 August 2007, 21:24 GMT
Type Bug
Category Vehicles → Trams
Status Closed
Assigned To Zdeněk Sojka (SmatZ)
Operating System All
Severity Medium
Priority Normal
Reported Version trunk
Due in Version 0.6.0
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


Hi, I found an ugly bug - don't know if reported by anyone else. If you build tram track without end loop, you can get serious trouble. The tram is trying to find path, but no exists. Tram is continuously accelerating from 0 to 8km/h, can't be reversed and of course title can't be modified, because of train on it => so when you can't build depot (track doesn't help, try it) in next title, you have uncontrolable tram...
This task depends upon
 FS#1228 - depot flooding 

Closed by  Remko Bijker (Rubidium)
Saturday, 17 November 2007, 12:42 GMT
Reason for closing:  Fixed
Additional comments about closing:  In r11449.
Comment by Zdeněk Sojka (SmatZ) - Sunday, 26 August 2007, 10:19 GMT
Maybe a connected problem - when a train is reversing on a curved line, it goes out of the track
Comment by Zdeněk Sojka (SmatZ) - Sunday, 26 August 2007, 10:27 GMT
It may even be a straight line, train cannot be reversed...
(wasn't this solved once?)
Comment by Remko Bijker (Rubidium) - Sunday, 26 August 2007, 10:44 GMT
Trams can only reverse when there is a tile after the current tile.

Once the tram has reached the "end" of the line it cannot be turned (easily) as it cannot be hooked (nicely) into a "turning vehicle" state, basically because it has overshot the entrance point for that "state".
Comment by Zdeněk Sojka (SmatZ) - Sunday, 26 August 2007, 11:57 GMT
What about adding the ability to manually crash vehicles? (say, by clicking Ctrl+start/stop)
(wouldn't that be a generally useful feature?)
Comment by Remko Bijker (Rubidium) - Sunday, 26 August 2007, 12:27 GMT
Crash as in "normally" crash, or just obliterating the vehicle so it will not block other vehicles for the next few months? And then, should crashing/obliterating influence the station ratings in the neighbourhood? I think it should so people won't use it as an easy way to get rid of redundant vehicles.
Comment by Zdeněk Sojka (SmatZ) - Sunday, 26 August 2007, 13:36 GMT
I agree, the rating should be decreased and vehicle should block others - otherwise it could be overused instead of sending vehicles to a depot.

I did just a little change to the code - but there are some more things that should be done and decided:

can vehicle be crashed while stopped? while stopped in a depot? (if so,can the vehicle be sold?) while in a station? what about the newgrf callbacks? can vehicle be crashed, when it cannot be stopped?
new newspaper message should be done - drivers and passangers won't die. should vehicle have the explosion animation? and rotate itself?
what about aircrafts? can they be crashed while flying, landing and taking-off?
and ships? i think ships cannot crash under any circumstances in the current code... ships can be blocked by building land around them and purchasing the land by other player, so there may be some need to crash them

should the "crash" cost money - eg. for area clearing? should the price be added to normal crashes?
Comment by Remko Bijker (Rubidium) - Sunday, 26 August 2007, 13:46 GMT
I think:
- crashing should only be possible when the vehicle is not stopped in a depot (except for aircraft as you do not know which blocks they have "taken", so you can't free them, or we have to wait for NewGRF ports which makes that easy)
- crashing should not block other vehicles; just blow (with animation) the vehicle and be done with it. This makes crashing aircraft in-sky/ships "simple".
- manual crashes must reduce the rating (probably even more than normal crashes)
- just use the <vehicle crashed> news message (and just kill the drivers and passangers ;))
- crashing should cost money; I think the current value of the whole consist, but normal crashes should not cost anything.

Furthermore there should be some "are you sure" dialog.
Comment by Zdeněk Sojka (SmatZ) - Sunday, 26 August 2007, 21:38 GMT
Well, I did something...

it is not 100% okay -> messages are wrong, aircrafts crash in the air, ships just disappear...

use: Ctrl+click on the start/stop button

is it worth continuing on that code?
Comment by Bilbo (bilbo) - Monday, 12 November 2007, 01:25 GMT
I am not sure if the ability to explode your own vehicles is the proper solution. But the tram-deadlock should be fixed. I think best way would be to implement rotating the tram (probably by using some crane, so this would be expensive and time-consuming) or allowing the tram to move backwards temporarily (with some very low speed) in some emergency situations like that, allowing yo to fix the deadlock (I assume, that when you reverse the tram, it will start going back until it hits some junction or depot or you stop it)
Comment by someone583 (someone583) - Wednesday, 14 November 2007, 10:43 GMT
A simpler solution is to allow to build tramways on front of the stuck tram and making sure the tram will go over it.
and a message that says the tram is stuck or lost.
Comment by Bilbo (bilbo) - Wednesday, 14 November 2007, 11:25 GMT
someone: unfortunately, that is not (always) possible, as here we have case where tram is stuck on the last tile and building more track in front of the tram is not possible - because the tile on which the track need to be built is occupied by something unbulldozeable (industry, lighthouse, something built by competitor, edge of map ...)

But the message "the tram is stuck" may be useful ... as are the "train is lost" messages to inform you of some bug in routes ...