Page 1 of 4

Smoother realistic_acceleration

Posted: 14 Sep 2005 12:22
by SirkoZ
Well - since quite many Integrated nightly users and nightly users complained over the "kick-start" "feature" of realistic acceleration, introduced in the latest nightlies, I have created a patch, that omits the "kick-start" for trains and while I was at it, I also corrected the train behaviour on the stations and partly in depots.

The last two things can yet be improved, but looking at the time passage in O/TTD, the current behaviour is quite correct, in my opinion.

Here's the diff/patch (for source r2946+):

Posted: 26 Sep 2005 19:02
by SirkoZ
1.2:

Posted: 26 Sep 2005 23:16
by gkirilov
what's the speed for entering depots?

Posted: 27 Sep 2005 09:04
by SirkoZ
The minimal is 61, like before, but you can suggest a different one. ;)

Posted: 27 Sep 2005 12:16
by webfreakz.nl
SirkoZ wrote:The minimal is 61, like before, but you can suggest a different one. ;)
the maximum speed of the train :P



but in the patch, if i change this:

Code: Select all

 		if (_curve_neighbours90[dir][0] == ndir ||
 				_curve_neighbours90[dir][1] == ndir) {
-			max_speed = 61;
to:

Code: Select all

 		if (_curve_neighbours90[dir][0] == ndir ||
 				_curve_neighbours90[dir][1] == ndir) {
-			max_speed = 120;
then the max_speed the train if allowed to enter the depot is 120mp/h ?

i'll compile it..... 8)

Posted: 27 Sep 2005 12:21
by SirkoZ
:lol:

Well - you can try - it's opensource. 8)

Posted: 27 Sep 2005 12:33
by webfreakz.nl
--------------------Configuration: openttd - Win32 Release--------------------
Compiling...
train_cmd.c
Linking...

openttd.exe - 0 error(s), 0 warning(s)
and:

Code: Select all

		max_speed = 164 + (v->cur_speed >> 2);
8)

let's see the effect....

hmm i guess i've to change more pieces of code than this one :P

when the train enters the depot, the speed drops to about 61/64 and than increases back to 164.

so it goes like: 643km/h --> 64 km/h --> 164 km/h

very strange to see :lol:

Posted: 27 Sep 2005 13:06
by }T{Reme [Q_G]
As soon as the train exits the depot... its travelling at near zero speed... that expression pretty much reads max_speed = 164 + (0 / 4)

Posted: 27 Sep 2005 13:08
by SirkoZ
:D

Well - for faster compiling/testing, change to "Debug" in "Configuration Manager" and only use "Release" for final compile (debug versions run ~1/2 slower in "Fast Forward" mode).

Posted: 27 Sep 2005 13:09
by SirkoZ
}T{Reme [Q_G] wrote:As soon as the train exits the depot... its travelling at near zero speed... that expression pretty much reads max_speed = 164 + (0 / 4)
I think we are all aware of that. :shock:

Posted: 27 Sep 2005 13:10
by webfreakz.nl
( 0 / 4 )


???

Posted: 27 Sep 2005 13:19
by SirkoZ
x >> 2 = x/ 2^2 = x/4 (x >> 3 = x/8...),

reverse: x << 2 = x * 2^2 = x * 4 (x << 4 = x * 16...).

In any case - it's only 0 the first four km/h, so please don't make a big deal out of it.

Posted: 27 Sep 2005 13:43
by webfreakz.nl
damn... i should really learn C :P


well i thougt 0/4 = error according my calculator.... :lol:

Posted: 27 Sep 2005 13:51
by SirkoZ
It's not real division, it's only bit shifting, so there's no problem if the x = 0. It's equal to mul./div. with powers of 2.

And if it's 0, it's still 64+0 according to upper equation.

Look it up in Google, bit+shift.

Posted: 27 Sep 2005 14:37
by Yoeri
SirkoZ wrote:x >> 2 = x/ 2^2 = x/4 (x >> 3 = x/8...),

reverse: x << 2 = x * 2^2 = x * 4 (x << 4 = x * 16...).

In any case - it's only 0 the first four km/h, so please don't make a big deal out of it.
:shock:
would be great to be able to do such thing. does anyone knows a good C tutorial?

Posted: 27 Sep 2005 14:45
by webfreakz.nl
Yoeri wrote:
SirkoZ wrote:x >> 2 = x/ 2^2 = x/4 (x >> 3 = x/8...),

reverse: x << 2 = x * 2^2 = x * 4 (x << 4 = x * 16...).

In any case - it's only 0 the first four km/h, so please don't make a big deal out of it.
:shock:
would be great to be able to do such thing. does anyone knows a good C tutorial?
Ik denk dat ik maar naar de bieb ga en een handbook "C voor dummies" ga halen ofzo :lol:

translation:

I think I should better go to the library and get a "C for dummies" handbook :lol:


I now how to script in PHP/MySQL but C is kinda different.....

Posted: 27 Sep 2005 16:36
by SirkoZ
For C tutorials/handbooks search your local library/internet. ;-)

Well - from what I've heard, C and PHP are quite similar.....in a way - so - who knows C has no problems learning PHP. I don't know about reverse. :)

BTW - you can also learn quite a lot from the source itself. :)

Posted: 28 Sep 2005 00:50
by }T{Reme [Q_G]
Pretty much all you can type in PHP, can be typed in C/C++ too.. that includes bit shifting. (Altho it depends on the internal structure of the Zend engine if this actually happends). Syntax is pretty much the same indeed. Many known C functions behave the same in PHP as they do in C (printf, fopen etc)

Posted: 28 Sep 2005 06:45
by webfreakz.nl
Well, C(++) uses that much of declarations:

static void
void
public void
public constant
enum
typedef void

:S

In PHP4 it's just like:

function

class

and that's it:P

Last year at school we had to program Java for our 'computer classes' (don't know what it should be) and had to draw pictures with Java. So we had to call a little class which would perform the actions:

forward(100);
left(90);
forward(100);
left(90);
forward(100);
left(90);
forward(100);

and guess what I drew right here!
8)

Posted: 28 Sep 2005 11:24
by SirkoZ
Staircase or a jaggied line? :)

In any case - the source pretty much speaks for itself, you just have to listen. :)