[WIP] Road vehicles and level crossings

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

[WIP] Road vehicles and level crossings

Post 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 :)
Attachments
Only a test if it works with road stops, too
Only a test if it works with road stops, too
Ilsenmünster Transport, 25th Dec 1950.png (37.5 KiB) Viewed 7669 times
only a quick test if all vehicles are doing their job right, and have a look at the CPU usage (there are 103 vehicles on the screen, if somebody wants to know)
only a quick test if all vehicles are doing their job right, and have a look at the CPU usage (there are 103 vehicles on the screen, if somebody wants to know)
Freudenberg Transport, 20th May 1952.png (64.96 KiB) Viewed 7670 times
rv_crossings_1.diff
(5.04 KiB) Downloaded 316 times
Last edited by gigajum on 03 Sep 2006 15:54, edited 2 times in total.
User avatar
Korenn
Tycoon
Tycoon
Posts: 1735
Joined: 26 Mar 2004 01:27
Location: Netherlands
Contact:

Post by Korenn »

I don't get it... what exactly does this patch change?
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post 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.
DeletedUser21
Tycoon
Tycoon
Posts: 11501
Joined: 20 Sep 2004 22:45

Post 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:
Bjarni
Tycoon
Tycoon
Posts: 2088
Joined: 08 Mar 2004 13:10

Post 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:
suit
Engineer
Engineer
Posts: 42
Joined: 22 Jul 2006 12:29
Location: Austria

Post 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%
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post 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 :)
User avatar
Korenn
Tycoon
Tycoon
Posts: 1735
Joined: 26 Mar 2004 01:27
Location: Netherlands
Contact:

Post 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? :)
sc79
Director
Director
Posts: 586
Joined: 22 Feb 2005 09:51

Post 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.
dittert
Engineer
Engineer
Posts: 3
Joined: 03 Mar 2005 20:00

Post 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?
DeletedUser21
Tycoon
Tycoon
Posts: 11501
Joined: 20 Sep 2004 22:45

Post 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:
ddream
Engineer
Engineer
Posts: 68
Joined: 28 May 2006 09:21
Location: 52° 13' N 21° 2' E

Post 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.
suit
Engineer
Engineer
Posts: 42
Joined: 22 Jul 2006 12:29
Location: Austria

Post 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
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post 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?
suit
Engineer
Engineer
Posts: 42
Joined: 22 Jul 2006 12:29
Location: Austria

Post 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?
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post 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
MeusH
Tycoon
Tycoon
Posts: 4349
Joined: 25 Oct 2004 15:39
Location: Mississauga

Post 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?
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post by gigajum »

done, about 30 min ago (see first post)
gigajum
Route Supervisor
Route Supervisor
Posts: 511
Joined: 08 Mar 2006 08:33
Location: Germany

Post 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.
hertogjan
Director
Director
Posts: 560
Joined: 03 Jan 2006 20:45
Location: Netherlands

Post 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.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: Google Adsense [Bot] and 9 guests