[Feedback wanted] Different style vehicle movement code
Moderator: OpenTTD Developers
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
[Feedback wanted] Different style vehicle movement code
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.
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
-
- split_new_19.patch
- trunk revision r10454
- (140.86 KiB) Downloaded 247 times
Last edited by madman2003 on 06 Jul 2007 16:45, edited 14 times in total.
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
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.l_Blue_l wrote: . 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.
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
Making functions private where appropriate is a very good ideamadman2003 wrote:Some functions were made private and some small changes.
Code: Select all
if (YouAreHappyAndYouKnowIt) {
ClapYourHands();
}
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
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: Select all
if (YouAreHappyAndYouKnowIt) {
ClapYourHands();
}
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
--
Free Gamer - open source and Free Software games
FreeGameDev forums - open source game development community
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
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.
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.
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
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.
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.
Ok by me!madman2003 wrote:this includes an acceleretion based on the work of Zojj.
I'm on the Zoloft to keep me from killing yall
My patches: Better graphs - Train acceleration - Crash rates
My patches: Better graphs - Train acceleration - Crash rates
Why won't maglevs go over mountains? I don't understand why it is realistic to assume that maglev trains cannot climb hills.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.
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
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.hertogjan wrote:Why won't maglevs go over mountains? I don't understand why it is realistic to assume that maglev trains cannot climb hills.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.
-
- Engineer
- Posts: 116
- Joined: 20 May 2004 17:21
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.
nice, better take a look thenmadman2003 wrote:The bugs that i know are solved now.
Code: Select all
if (YouAreHappyAndYouKnowIt) {
ClapYourHands();
}
It looks like you ripped this line from my patch:madman2003 wrote:if anyone has a simple idea to restrict the massive acceleration of maglevs without killing the ability going over mountains.
Code: Select all
max_te = num * 10000; ///< 10,000N per car, limits early acceleration
I'm on the Zoloft to keep me from killing yall
My patches: Better graphs - Train acceleration - Crash rates
My patches: Better graphs - Train acceleration - Crash rates
Who is online
Users browsing this forum: No registered users and 16 guests