Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Fri Oct 19, 2018 6:52 pm

All times are UTC




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sat May 05, 2018 9:59 pm 
Offline
Engineer
Engineer

Joined: Tue Aug 01, 2017 4:32 am
Posts: 3
Hey all, going through the code and trying to understand it, and had a couple of questions.

1)
Code:
_cur.AddSpriteSets(feature, _cur.spriteid, first_set, num_sets, num_ents);
from newgrf.cpp, line 4523 in the code that I have.

Using the zbase base set, I am seeing it call this twice, both times with the first_set = 0. Am I missing something, or does the line
Code:
SpriteSet &set = this->spritesets[feature][first_set + i];
mean it is going to set the same sprites on both calls?

Am I reading this right?

2) ResetNewGrfData

Code:
   /* Reset the objects. */
   ObjectClass::Reset();
   ResetCustomObjects();
   ResetObjects();


Won't the call to ObjectClass::Reset add in the cls_ids for the two objects, and then ResetObjects will just memcpy over it?


Top
   
PostPosted: Tue May 08, 2018 2:34 pm 
Offline
Tycoon
Tycoon

Joined: Wed Jan 17, 2007 12:14 am
Posts: 7160
jackdw wrote:
Using the zbase base set, I am seeing it call this twice, both times with the first_set = 0.
I haven't looked at the code, but i'm assuming it's calling once for the 8bpp and once for the 32bpp sprites, as they are defined in separate places in the GRF

_________________
You might not exactly be interested in Ferion, but if you are, have fun :)


Top
   
PostPosted: Wed May 09, 2018 7:33 pm 
Offline
OpenTTD Developer
OpenTTD Developer

Joined: Wed Dec 20, 2006 1:31 pm
Posts: 978
Location: Aschaffenburg
jackdw wrote:
it is going to set the same sprites on both calls?

Am I reading this right?
Yes, NewGRF are loaded in multiple stages to resolve dependencies between NewGRF.
This involves quite some magic (https://newgrf-specs.tt-wiki.net/wiki/GrfLoadingStages), but usually you do not need to know the details.

In this case the first call is likely the reservation stage, which is essentially a test-run.
The second call is the activation stage, where stuff is done for real.

jackdw wrote:
Won't the call to ObjectClass::Reset add in the cls_ids for the two objects, and then ResetObjects will just memcpy over it?
Hmm, yes, looks weird. Possibly the ObjectSpec->Class mapping is not used for the default objects, so noone noticed.
Would you like to submit a fix via https://github.com/OpenTTD/OpenTTD/pulls ? :)

Eddi wrote:
I haven't looked at the code, but i'm assuming it's calling once for the 8bpp and once for the 32bpp sprites, as they are defined in separate places in the GRF
Nope. 8bpp/32bpp sprites may be defined in different places in NML, but they are in the same spot in the compiled NewGRF.

_________________
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 3 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.