News:

Simutrans Tools
Know our tools that can help you to create add-ons, install and customize Simutrans.

Overtaking. Fun patch.

Started by isidoro, September 10, 2008, 02:47:39 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

snide

If you make a class virtual (having at least one virtual function), you should also have a virtual destructor.

Here is a patch that does just this :

=== vehicle/overtaker.h
==================================================================
--- vehicle/overtaker.h (revision 131)
+++ vehicle/overtaker.h (local)
@@ -56,6 +56,9 @@

        // since citycars and convois can react quite different
        virtual bool can_overtake(overtaker_t *other_overtaker, int other_speed, int steps_other, int diagonal_length) = 0;
+
+       // Virtual destructor since there is at least one virtual function
+       virtual ~overtaker_t() { /* do nothing*/ };
};

#endif



Very nice patch btw.

prissi

Well, only if you are not sure, that the virtual function is not called during destruction, which could not happen. But it is better style anyway.

isidoro

Quote from: jatypc on September 29, 2008, 08:37:52 AM
From what I see on many central-european highways, it is very realistic to work with the maximum achievable speed given the load of a convoy.
[...]

I don't know the right answer.  I only think: if I cannot see inside the truck, how will I know if it is fully loaded or not to begin overtaking?

Quote from: jatypc on September 29, 2008, 08:37:52 AM
[...]
One more remark for improvement: it seems to me that the overtaking does not take place if all conditions are satisfied, but the first (slower) car is turning to the right (whereas the overtaking car continues straight on). In such a case, the overtaking should take place (if it is not difficult to code) because the overtaken car will actually be overtaken sooner...

The  problem with crossings is that calculations complicate quite a lot (traffic can go away as in your example, but can also appear, you should look at all possibilities and that may not be feasible).  With city cars, it is ever more complicated because, in normal configuration, they have no route.  When they reach a crossing they choose an exit at random.  Besides, if I'm not wrong, at least where I live, overtaking is not allowed in crossings.

PatrickN

What about a T intersection, where there is a turn off to one side but not the other.  While passing a car in a 4-way stop would be illegal, it should be perfectly fine to pass a vehicle when there is a road to the right because the straight road doesn't stop.

Painter, in and out of retirement.

jatypc

#74
Quote from: isidoro on September 29, 2008, 10:19:08 PM
The  problem with crossings is that calculations complicate quite a lot (traffic can go away as in your example, but can also appear, you should look at all possibilities and that may not be feasible).  With city cars, it is ever more complicated because, in normal configuration, they have no route.  When they reach a crossing they choose an exit at random.  Besides, if I'm not wrong, at least where I live, overtaking is not allowed in crossings.

All points very correct - I agree. My mistake I have not realized all these things.

Quote from: isidoro on September 29, 2008, 10:19:08 PM
I don't know the right answer.  I only think: if I cannot see inside the truck, how will I know if it is fully loaded or not to begin overtaking?

In reality, you do not know the load of the truck, but the trucks typically go at the maximum economical speed (we do not have that in simutrans, but we have a maximum achievable speed) - unless there is an obstacle such as hill, crossing, city, but that is excluded already in "simu-overtaking". Thus, the second truck driving behind the first one sees the speed when he is driving a little while after the first truck and based on this information (if their economical speed is higher) they decide to overtake. The truck drivers make sometimes (not very often) mistakes in their guess, but then the overtaken truck lets them pass at the end, and moreover, the mistakes are not possible in simutrans. The same situation occurs when you drive in a car behind a truck - after short while you know whether the truck can keep up with the maximum allowed speed (e.g., 90 km/h), for instance, or whether it is too slow (e.g., less powerful or heavily loaded). If you see he is slow, you decide to overtake...

Thus, I think it is realistic that the cars/trucks overtake each depending on the maximum achievable speed - it is only that the maximum achievable speed computed in simutrans (which requires the knowledge of the weight/load) replaces observing the speed in the real world (which would be difficult to implement I guess).


prissi

Overtaking on exits only for citycars is not possible, since the overtaking citycars can exist too ... and rarely convois overtake citycars (at least in pak64), usually it is reverse. This would add a lot of tests for not real win, imho.

And in most middle europeen countries overtaking on crossings is strictly forbidden.

CX257

Sorry for my stupid question, but just wanna ask where should I locate this .PATCH file ?
(Well ... using patch is still a new stuff for me x[ )

By the way, I remember that there is a overtaking function in a ancient version of simutrans ...  ::)

IgorEliezer

See posts of this topic. If I remember correctly, there are some patch files attached at post's footers.

prissi

Anyway, it is in the trunk since a month or so.

KingTy

where do i get this patch and where do i put it after downloading?

vilvoh

This patch is already included as a feature in the latest stable releases (102) have a look at the changelog.

Escala Real...a blog about Simutrans in Spanish...

jamespetts

Perhaps this thread should be moved to the "incorporated patches" section?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

KingTy

in pak 128 the city cars will over take other city cars but will not over take my cars and my cars will not over take city cars    will this download make it so they do that or no?

Combuijs

This is incorporated in version 0.102. Cars will only overtake if it is safe, e.g. no cars coming from the other side, no crossings or junctions, no cars waiting in front. Sometimes speed difference is not much and opportunities for taking over are rare. But it certainly works!
Bob Marley: No woman, no cry

Programmer: No user, no bugs



jamespetts

Overtaking works much better on faster roads, I have found.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Severous

Ah.  Didnt know overtaking could happen.  Will look closer in Ragoland challenge next time I load it up.
Regards
Sev.

Isaac Eiland-Hall

Tips to see overtaking:
1. Long straight stretches of road (15-20 tiles) are condusive.
2. Divided highways (e.g. using do-not-enter signs of some sort to restrain traffic flow) ensure no oncoming traffic, and are therefore also condusive.

Divided highways have another trivial benefit now with overtaking (the flow control they already provided, if carefully set up, was moderately marginal, and now overtaking has helped them become slightly more useful yet :) )