Smoother realistic_acceleration

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

User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Smoother realistic_acceleration

Post 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+):
Attachments
real_acceleration_sz_1-1_r2946.patch
kick the kick-start :)
(1.39 KiB) Downloaded 603 times
Last edited by SirkoZ on 08 Apr 2006 19:34, edited 1 time in total.
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

1.2:
Attachments
real_acceleration_sz_1-2_r2967.patch
diff r2967+
(1.28 KiB) Downloaded 587 times
User avatar
gkirilov
Chief Executive
Chief Executive
Posts: 696
Joined: 03 May 2005 09:32
Location: Othala

Post by gkirilov »

what's the speed for entering depots?
OTTDCoop NewGRF Pack|Different sets of GRFs for TTDPatch (some of them work in OTTD) - 1|- 2|GRF sets for OTTD|OTTD nightly
Image
I hooked up my accelerator to my brake lights. I hit the gas, people behind me stop, and I'm gone.
Understeer is when you hit the wall with the front of the car. Oversteer is when you hit the wall with the rear of the car. Horsepower is how fast you hit the wall. Torque is how far you take the wall with you. Spoilers and bodykits are how much of the wall you take with you. Rollcages and windownets are how much of a mess you leave on the wall.
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

The minimal is 61, like before, but you can suggest a different one. ;)
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post 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)
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

:lol:

Well - you can try - it's opensource. 8)
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post 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:
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
}T{Reme [Q_G]
Route Supervisor
Route Supervisor
Posts: 389
Joined: 04 Feb 2004 23:24
Contact:

Post 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)
Siggy not gonna work unless someone allows javascripting...
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post 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).
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post 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:
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

( 0 / 4 )


???
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post 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.
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post by webfreakz.nl »

damn... i should really learn C :P


well i thougt 0/4 = error according my calculator.... :lol:
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post 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.
User avatar
Yoeri
Route Supervisor
Route Supervisor
Posts: 470
Joined: 08 Aug 2005 13:42
Location: The Netherlands

Post 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?
Image
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post 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.....
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post 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. :)
}T{Reme [Q_G]
Route Supervisor
Route Supervisor
Posts: 389
Joined: 04 Feb 2004 23:24
Contact:

Post 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)
Siggy not gonna work unless someone allows javascripting...
User avatar
webfreakz.nl
Director
Director
Posts: 627
Joined: 11 Aug 2005 08:22
Location: Localhost, 127.0.0.1, [The Netherlands: South Holland-> Westland]
Contact:

Post 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)
# Programming is like sex, one mistake and you have to support it for the rest of your life. (Michael Sinz)
User avatar
SirkoZ
Tycoon
Tycoon
Posts: 1518
Joined: 06 Mar 2004 23:51
Location: The sunny side of Alps

Post by SirkoZ »

Staircase or a jaggied line? :)

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

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 11 guests