Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Sun Oct 21, 2018 11:15 am

All times are UTC




Post new topic  Reply to topic  [ 27 posts ]  Go to page 1 2 Next
Author Message
PostPosted: Thu Jun 21, 2007 9:43 pm 
Offline
Engineer
Engineer

Joined: Thu May 20, 2004 5:21 pm
Posts: 116
I'm experimenting with cutting train movement code in smaller chunks, and putting some movement functions into the vehicle class.

Functions like:

Tick()
Controller()
SingleVehicleMove()
FullVehicleMove()

I've attached what i have so far, no functional changes have been done.

The traincontroller function has been cut up into smaller parts, the rest has seen little modification. Aircraft just have a hook, because they work very differently.

I'd appreciate idea on how you would structure it, i also need to know if this viable, otherwise i will not continue working on it.

Note: This is a question to programmmers, not users wanting to test a feature.

EDIT: The entire train controller has been overhauled, with considerable performance improvement.

This also adds an m8, which contains slope information atm (5 of 8 bits).

Note: This includes a modified and optimized acceleration function based on the work of Zojj. I tried to contact him, but no responce for several days (and no post on this forum for about a week). I assume he's away, if objections from him arise i will modify the remainder of the code so it does not resemble his.


Attachments:
File comment: trunk revision r10454
split_new_19.patch [140.86 KiB]
Downloaded 168 times


Last edited by madman2003 on Fri Jul 06, 2007 4:45 pm, edited 14 times in total.
Top
   
 Post subject:
PostPosted: Sat Jun 23, 2007 9:41 am 
Offline
Engineer
Engineer

Joined: Thu May 20, 2004 5:21 pm
Posts: 116
This last version (which i already posted yesterday) has a single Tick function for all vehicles.
If there are any ideas to further unify things, then don't hesitate to post.


Top
   
 Post subject:
PostPosted: Sat Jun 23, 2007 6:28 pm 
Offline
Engineer
Engineer

Joined: Thu May 20, 2004 5:21 pm
Posts: 116
I've mostly unified the vehicle controllers, not perfect yet, but it's getting there.

EDIT: You are allowed to reply ;-)


Top
   
 Post subject:
PostPosted: Sat Jun 23, 2007 11:31 pm 
Offline
Transport Coordinator
Transport Coordinator

Joined: Wed Mar 29, 2006 10:42 pm
Posts: 285
8) . Nice idea i like it. Just one question does it have much of an impact on game / network performance? I see you have also change the code to C++ nice work.


Top
   
 Post subject:
PostPosted: Sun Jun 24, 2007 9:55 am 
Offline
Engineer
Engineer

Joined: Thu May 20, 2004 5:21 pm
Posts: 116
l_Blue_l wrote:
8) . Nice idea i like it. Just one question does it have much of an impact on game / network performance? I see you have also change the code to C++ nice work.


It's not very easy to compare with profiling, but i fairly sure the difference is minimal. The trunk seems to be a little bit slower(i did a cpu compare on a large savegame, this is a rough indication, nothing more), which is probably due to one performance optimisation i did.


Top
   
 Post subject:
PostPosted: Sun Jun 24, 2007 10:41 am 
Offline
Engineer
Engineer

Joined: Thu May 20, 2004 5:21 pm
Posts: 116
Some functions were made private and some small changes.


Top
   
 Post subject:
PostPosted: Sun Jun 24, 2007 11:21 am 
Offline
Route Supervisor
Route Supervisor

Joined: Mon Apr 02, 2007 8:13 pm
Posts: 399
Location: Nørup, Denmark
madman2003 wrote:
Some functions were made private and some small changes.


Making functions private where appropriate is a very good idea :)

_________________
Code:
if (YouAreHappyAndYouKnowIt) {
    ClapYourHands();
}


Top
   
 Post subject:
PostPosted: Sun Jun 24, 2007 12:01 pm 
Offline
Route Supervisor
Route Supervisor

Joined: Mon Apr 02, 2007 8:13 pm
Posts: 399
Location: Nørup, Denmark
Now that I have read the patch in a side by side diff I can tell you that it almost made me cry with joy.

I'm very pleased by the simple things like replacing self referencing variables with "this". For me at least it makes the code much more readable.

I like the unification effort as well, it should make it easier to make changes in the future.

About the need for a smoke handler in Vehicle that you question because it is only trains that has that currently: I think it is the right place for it, because some day some grf author might decide to put smoke on his latest steam ship or something like that.

If you keep this up I might start sending you fan mail ;)

_________________
Code:
if (YouAreHappyAndYouKnowIt) {
    ClapYourHands();
}


Top
   
 Post subject:
PostPosted: Tue Jun 26, 2007 9:13 am 
Offline
Transport Coordinator
Transport Coordinator
User avatar

Joined: Wed Oct 08, 2003 2:07 pm
Posts: 323
But is it going to get applied to the trunk? :?

_________________
Open source tycoon games
--
Free Gamer - open source and Free Software games
FreeGameDev forums - open source game development community


Top
   
 Post subject:
PostPosted: Tue Jun 26, 2007 4:50 pm 
Offline
Engineer
Engineer

Joined: Thu May 20, 2004 5:21 pm
Posts: 116
charlieg wrote:
But is it going to get applied to the trunk? :?


I'm trying to redo train handling atm, not very succesfull so far, but once i feel it's ready i will ask for trunk inclusion.


Top
   
 Post subject:
PostPosted: Tue Jun 26, 2007 5:17 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Thu Feb 09, 2006 7:15 pm
Posts: 3815
Do not expect that we just apply your huge patch in one go. Small and simple patches is the way to go.


Top
   
 Post subject:
PostPosted: Tue Jul 03, 2007 2:53 pm 
Offline
Engineer
Engineer

Joined: Thu May 20, 2004 5:21 pm
Posts: 116
Now is the time to show you what i've been doing the last week. I've changed the train controller, with considerable performance improvements. It has reached an acceptable state, so i've uploaded it. Due to the price (cpu power) of slope calculations, this is now stored in the map array (m8 has been added, first 5bits are used).

Let me know what you think of it.

EDIT: i would like to add that there are still minor graphical glitches, which need to be resolved.


Top
   
 Post subject:
PostPosted: Thu Jul 05, 2007 8:13 pm 
Offline
Engineer
Engineer

Joined: Thu May 20, 2004 5:21 pm
Posts: 116
This is pretty much the final version, this includes an acceleretion based on the work of Zojj. I have been unable to reach him so far, if problems arise i will modify the code that resembles his.

I did cleanups, added more comment, some fixes.

There is one problem that i know, if a train hits the end of rail it will turn around and the distance between the first and second vehicle will be one unit longer. I will look at that problem in the near future.

Note that this acceleration is more realistic for maglevs (they won't go over mountains for example), i included an option old style beheaviour for people who have existing savegames.

It's time to speak up and let me know what you think.

If you have ideas how to split this for merging, then please tell, because as far as i know i could split it in 2 patches, maybe 3. Preferable is a single merge, but i know that isn't likely.


Top
   
 Post subject:
PostPosted: Fri Jul 06, 2007 4:11 am 
Offline
Engineer
Engineer
User avatar

Joined: Fri Apr 27, 2007 5:58 pm
Posts: 97
Location: Vegas baby
madman2003 wrote:
this includes an acceleretion based on the work of Zojj.

Ok by me!

_________________
I'm on the Zoloft to keep me from killing yall

My patches: Better graphs - Train acceleration - Crash rates


Top
   
 Post subject:
PostPosted: Fri Jul 06, 2007 8:19 am 
Offline
Director
Director

Joined: Tue Jan 03, 2006 8:45 pm
Posts: 560
Location: Netherlands
madman2003 wrote:
Note that this acceleration is more realistic for maglevs (they won't go over mountains for example), i included an option old style beheaviour for people who have existing savegames.

Why won't maglevs go over mountains? I don't understand why it is realistic to assume that maglev trains cannot climb hills.


Top
   
 Post subject:
PostPosted: Fri Jul 06, 2007 8:57 am 
Offline
Engineer
Engineer

Joined: Thu May 20, 2004 5:21 pm
Posts: 116
hertogjan wrote:
madman2003 wrote:
Note that this acceleration is more realistic for maglevs (they won't go over mountains for example), i included an option old style beheaviour for people who have existing savegames.

Why won't maglevs go over mountains? I don't understand why it is realistic to assume that maglev trains cannot climb hills.


This is mistake and it has been corrected in my working copy, a few people complained about this. I was blinded by a more tamed maglev beheaviour :-) I reverted it to old style beheaviour, so if anyone has a simple idea to restrict the massive acceleration of maglevs without killing the ability going over mountains.


Top
   
 Post subject:
PostPosted: Fri Jul 06, 2007 9:26 am 
Offline
Engineer
Engineer

Joined: Thu May 20, 2004 5:21 pm
Posts: 116
Updated version, it fixes the bug were the mass_on_slope would become incorrect when reversing on a slope. This also adds "this->" to all class based variables and functions (except static ones). As as i said, i undid the maglev thing. Feedback on what maglev should behave like and possible ideas to change beheaviour are considered.


Top
   
 Post subject:
PostPosted: Fri Jul 06, 2007 4:46 pm 
Offline
Engineer
Engineer

Joined: Thu May 20, 2004 5:21 pm
Posts: 116
The bugs that i know are solved now.


Top
   
 Post subject:
PostPosted: Fri Jul 06, 2007 5:13 pm 
Offline
Route Supervisor
Route Supervisor

Joined: Mon Apr 02, 2007 8:13 pm
Posts: 399
Location: Nørup, Denmark
madman2003 wrote:
The bugs that i know are solved now.


nice, better take a look then :)

_________________
Code:
if (YouAreHappyAndYouKnowIt) {
    ClapYourHands();
}


Top
   
 Post subject:
PostPosted: Fri Jul 06, 2007 5:44 pm 
Offline
Engineer
Engineer
User avatar

Joined: Fri Apr 27, 2007 5:58 pm
Posts: 97
Location: Vegas baby
madman2003 wrote:
if anyone has a simple idea to restrict the massive acceleration of maglevs without killing the ability going over mountains.

It looks like you ripped this line from my patch:
Code:
max_te      =  num * 10000;  ///< 10,000N per car, limits early acceleration

Did it not work for you?

_________________
I'm on the Zoloft to keep me from killing yall

My patches: Better graphs - Train acceleration - Crash rates


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 27 posts ]  Go to page 1 2 Next

All times are UTC


Who is online

Users browsing this forum: piratescooby and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2018 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2018.
Hosted by Zernebok Hosting.