Page 1 of 2

[WIP] Road vehicles and level crossings

Posted: 02 Sep 2006 17:17
by gigajum
Oki i developed a patch that stops road vehicles in front of a level crossing and not on the rail if they have to wait.
Currently i'm trying to get it working with the overtaking function together, so that not every vehicle is checked twice (first time the overtake function, the other time if it has to stop before a level crossing) and that vehicles continue driving and do not stop befor a crossing, if the vehicle in front of it drives over the crossing rail.

edit1: added diff/patch file
Here are some screenshots :)

Posted: 02 Sep 2006 17:20
by Korenn
I don't get it... what exactly does this patch change?

Posted: 02 Sep 2006 17:24
by gigajum
That road vehicles do not wait on a crossing tile and a train crashes into them. It is possible that a train hits a vehicle, but then both are driving and not one of it is waiting at that tile.

Posted: 02 Sep 2006 17:25
by DeletedUser21
The vehicles will not stop 'on' the rail-road crossings, but infront of it if it notices a stop behind the crossing in that order preventing a crash. :wink:

EDIT: I was too late with my response. :wink:

Posted: 02 Sep 2006 21:04
by Bjarni
good idea. A diff would be nice, then people can give constructive feedback and also bugreports.
tip: add numbers to your diffs, so the first one is named _1.diff and so on. This is good if/when you update. People will be able to figure out if they are looking at the newest version :wink:

Posted: 02 Sep 2006 22:09
by suit
so its impossible to kill other players vehicles, right?

but will it be possible that a vehicle breaks down while exiting the level crossing and another vehicle closing up to it by going on the level crossing to get killed probably?

btw:
maybe you can check the behavior of trains killing vehicles too - there should be really a chance of derailment if a train crashes a bus/truck - for example 10%

Posted: 02 Sep 2006 23:11
by gigajum
suit wrote:so its impossible to kill other players vehicles, right?

but will it be possible that a vehicle breaks down while exiting the level crossing and another vehicle closing up to it by going on the level crossing to get killed probably?

btw:
maybe you can check the behavior of trains killing vehicles too - there should be really a chance of derailment if a train crashes a bus/truck - for example 10%
No, it is still possible to kill road vehicles. If they break down over the rail or if the can't drive fast enough over the crossing / train is fast enough.

Yeah great idea, but that should be a bit more realistic. 10% is a fix value, maybe calculate it is better. Ok i do not have an idea what formula to use there, but a train with 20+ coal or iron waagons will in all probability not derail, because it is too heavy. But a Small train with 5 passenger waggons will react different as a freight train (imo)
Bjarni wrote:good idea. A diff would be nice, then people can give constructive feedback and also bugreports.
tip: add numbers to your diffs, so the first one is named _1.diff and so on. This is good if/when you update. People will be able to figure out if they are looking at the newest version :wink:
I'll add one it if i find some free time today :)

Posted: 03 Sep 2006 08:12
by Korenn
oh I see now, it checks if there is a train in the signal block, not just the crossing tile, right? great, this was needed for a long time.

the other thing that occurs is that if you have a double track, the road vehicles will drive across the first crossing, then stop at the second because of a train and then get hit by a train on the first track while waiting. Is that fixable? :)

Posted: 03 Sep 2006 09:16
by sc79
oh I see now, it checks if there is a train in the signal block, not just the crossing tile, right?
No, it has nothing to do with the trains. It simply stops road vehicles from queueing on the actual track square, and therefore getting cleaned up by trains while waiting for the road to clear. Wont do anything for moving or broken down ones. Still a nice patch though; every little bit helps.

Posted: 03 Sep 2006 10:52
by dittert
What about patching the vehicle breakdown code so that a breakdown does not occur on railroad crossings or at least is very unlikely on them?

Posted: 03 Sep 2006 11:06
by DeletedUser21
that would make the game unrealistic, if you want to prevent a certain bus from having breakdowns you can make his complete route a railroad crossing. :P

Well IMHO it's just weird a vehicle can't have a breakdown on a level crossing. :wink:

Posted: 03 Sep 2006 13:15
by ddream
In real life most of collisions of trucks with trains have been caused by breakdown of truck, not because truck had to stay on crossing because there were cars standing in the way preventing truck from leaving it.

Posted: 03 Sep 2006 14:12
by suit
ddream wrote:In real life most of collisions of trucks with trains have been caused by breakdown of truck, not because truck had to stay on crossing because there were cars standing in the way preventing truck from leaving it.
good point - there is a rule, that a driver is only allowed to enter a crossing or level crossing if its possible to leave it before it gets red

most people ignore this rule and place their cars right on the level crossing to get hit by car

maybe truck-drivers in ottd are smart enough dont do that ;)
but crashes and desasters are part of the game and make it more challenging

but there should be a factor like "human fault" - a truck driver can simply nap a bit and/or ignore the traffic light at the level crossing (for example with 5% chance) if a train comes through right at this moment they will crash (allmost impossible in early game, but very likely in later game with lots of trains and vehicles)

---

according to my upper post: there should be a chance of derailment for the train - 10% als fixed value is bad

but the calculation based on weight suggested by gigajum is good

a small and light loco can easier derail than a heavy train - a fast train can also easier derail then a slow one

for calculating the chance of derailment following factors should be important

- weight of the road vehicle (empty = derailment is unlikely)
- speed of the train (slow = unlikely)
- weight of the train (heavy = unlikely)
- length of the train (short = unlikely) <- not sure about that

Posted: 03 Sep 2006 14:53
by gigajum
suit wrote:- length of the train (short = unlikely) <- not sure about that
It has more to do with the weigth of a train. Sure if you have a train which is a half kilometre long it wont derail complete. But a short one will derail completely. But there is one problem: What to do with the remaining not derailed waggons? In normal life you can send a new lok, but in openttd that is not possible. So i have to code that the complete train gets destroyed?

Posted: 03 Sep 2006 15:14
by suit
good question - derailing a 10-tile train with 19 cars by crashing an empty bus? unlikely

but i guess there is no other solution?

Posted: 03 Sep 2006 15:19
by gigajum
suit wrote:good question - derailing a 10-tile train with 19 cars by crashing an empty bus? unlikely

but i guess there is no other solution?
Not until someone invents shunting to openttd

Posted: 03 Sep 2006 16:00
by MeusH
This patch looks promising. Once I tried to do that but I didn't know where to start. Could you please upload a diff file?

Posted: 03 Sep 2006 16:30
by gigajum
done, about 30 min ago (see first post)

Posted: 05 Sep 2006 17:18
by gigajum
suit wrote:- weight of the road vehicle (empty = derailment is unlikely)
The problem is that only trains have a declaration of weight. So i only can calculate the weigth of their cargo and not of the whole vehicle. I'm glad, if anyone is able to figure out what's the weight of each road vehicle used in the game.

Please note: That feature will become an extra patch, because it has more to do with the disasters and it need no code from this patch.

Posted: 05 Sep 2006 18:58
by hertogjan
Use the MiniIN then. There the road vehicles do have weights, for the purpose of realistic acceleration. Also, road vehicles in newgrfs also have weight as one of their properties.