Animation fixes

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

Post Reply
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Animation fixes

Post by Csaboka »

Hi folks!

Attached are my first[1] attempts at changing OTTD code. I hope they are in the right format, but feel free to apply a clue-by-four if they're not. I may be an experienced TTDPatch developer, but I'm still a newbie at OTTD coding :D

The first patch fixes a bug Rubidium has accidentally introduced with the new flexible animation array, and could cause memory overwrite when loading an old save game.

The second tries to revert the logic of the animation handler to the original TTD logic. The memmove may seem to be an overkill, and the original logic more convoluted, but this is to ensure that all tiles are always animated, and the animation order stays consistent. I hope the comments explain what the change does exactly.

[1] OK, actually second because I've started the smooth production changes patch, too, but that was long ago.

[Edit] fixed the first patch, there was a return statement missing
Attachments
ottd-animation-order-fix.patch
Fix for the animation handler - it could skip some tiles
(1.7 KiB) Downloaded 124 times
ottd-oldlader-animation-fix.patch
Fix animation array loading for old savegames [fixed]
(1.72 KiB) Downloaded 83 times
Last edited by Csaboka on 09 Oct 2007 20:03, edited 1 time in total.
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
Draakon
Director
Director
Posts: 542
Joined: 11 Mar 2007 16:50

Re: Animation fixes

Post by Draakon »

it is good to see that even Patch devs are helping OTTD.
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Re: Animation fixes

Post by belugas »

Thanks Csaboka.
Rest assure, you are doing quite fine ;) Code style is flawless.
I think i'll commit it as soon as i can.
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Re: Animation fixes

Post by Csaboka »

belugas wrote:Rest assure, you are doing quite fine ;) Code style is flawless.
Hehe, Visual Studio doesn't think so: "LoadOldAnimTileList: Not all code paths return a value" :D
I've forgot to add a "return true" statement to the end, so it returned an undefined value when successful. I've edited the first post to fix the patch.

While testing, I've also found a minor off-by-one error in the industry tile animation handler. You can check it by looking at Pikka's oil wells. The "nodding donkey" pumps have a tiny pause in every cycle because their last stage lasts twice as long. That's because the code initializes num_frames as the real number of frames, but then assumes it contains one less than the number of frames. I've modified the initialization rather than the usage because that's how the same code is written for houses, so it's at least consistent, although a bit confusing.
Attachments
ottd-industry-animation-fix.patch
Fix industry tile animation
(657 Bytes) Downloaded 97 times
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
User avatar
Born Acorn
Tycoon
Tycoon
Posts: 7596
Joined: 10 Dec 2002 20:36
Skype: bornacorn
Location: Wrexham, Wales
Contact:

Re: Animation fixes

Post by Born Acorn »

Csaboka wrote:You can check it by looking at Pikka's oil wells. The "nodding donkey" pumps have a tiny pause in every cycle because their last stage lasts twice as long.
I actually noticed this myself. I just dismissed it as some sort of limit. :p
Image
User avatar
belugas
OpenTTD Developer
OpenTTD Developer
Posts: 1507
Joined: 05 Apr 2005 01:48
Location: Deep down the deepest blue
Contact:

Re: Animation fixes

Post by belugas »

Csaboka wrote:
belugas wrote:Rest assure, you are doing quite fine ;) Code style is flawless.
Hehe, Visual Studio doesn't think so: "LoadOldAnimTileList: Not all code paths return a value" :D
Hey... I've only talked about code style :)
I cannot do anything compilation and testing wise from work, thus waiting to get home (and family put to sleep) in order to work on it.
Using Visual Studio myself, it would have shown too :)
If you are not ready to work a bit for your ideas, it means they don't count much for you.
OpenTTD and Realism? Well... Here are a few thoughs on the matter.
He he he he
------------------------------------------------------------
Music from the Bloody Time Zones
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Re: Animation fixes

Post by Csaboka »

I see you've committed the off-by-one animation fix, thank you.

Can I ask why you didn't commit the remaining two patches? I can accept if you devs decide they shouldn't go to the trunk, I'd just like to know the reason.
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
TrueBrain
OpenTTD Developer
OpenTTD Developer
Posts: 1370
Joined: 31 May 2004 09:21

Re: Animation fixes

Post by TrueBrain »

Csaboka wrote:I see you've committed the off-by-one animation fix, thank you.

Can I ask why you didn't commit the remaining two patches? I can accept if you devs decide they shouldn't go to the trunk, I'd just like to know the reason.
Most likely as Belugas doesn't know much about the oldloader for example. Which brings it to me, and I have a question about it: how does TTDp store moreanimations? As this always loads 256 entries... might be nice to make it also load TTDp games correctly :)

Hmm, reminds me, I should look into the TTDp loader again, I still want it to load more TTDp games correctly, even more now OTTD has most of the things too, in some way... sorry, offtopic :)
The only thing necessary for the triumph of evil is for good men to do nothing.
User avatar
Csaboka
Tycoon
Tycoon
Posts: 1202
Joined: 25 Nov 2002 16:30
Location: Tiszavasvári, Hungary
Contact:

Re: Animation fixes

Post by Csaboka »

TrueLight wrote:Most likely as Belugas doesn't know much about the oldloader for example.
Devs don't blindly commit code they can't understand. Makes sense :D Can I ask who is responsible for AnimateTiles & co., then?
TrueLight wrote:Which brings it to me, and I have a question about it: how does TTDp store moreanimations? As this always loads 256 entries... might be nice to make it also load TTDp games correctly :)
First of all, the old 256-element animation array is still saved in the savegame, but its contents are bogus. The real animated tile list is saved as an extra TTDPatch chunk, with id=5. It doesn't have any special header; the chunk length will tell you the length of the animation array (ie. what moreanimation was set to when the game was saved). You can use the same logic for loading it as used for loading the old animation array, except that the size isn't fixed at 256 bytes.
TrueLight wrote:Hmm, reminds me, I should look into the TTDp loader again, I still want it to load more TTDp games correctly, even more now OTTD has most of the things too, in some way... sorry, offtopic :)
Feel free to PM me about what the different chunk IDs mean and what their format is. I can certainly help with chunks I've added, and probably the others as well.
Reality is that which, when you stop believing in it, doesn't go away.—Philip K. Dick
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 8 guests