Question about CB 32

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Post Reply
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Question about CB 32

Post by michael blunck »

How does CB 32 exactly work in OTTD? The specs says:
nfospecs wrote: 32-day callback (32)

This callback is called every 32 game days for each vehicle, although not for all vehicles on the same day. [...]
But OTTD sources seem to suggest that it is run for all vehicles on the same game day:
trunk/src/vehicle.cpp wrote: 849 /* Call the 32-day callback if needed */
850 if ((v->day_counter & 0x1F) == 0 && v->HasEngineType()) {
851 uint16 callback = GetVehicleCallback(CBID_VEHICLE_32DAY_CALLBACK, 0, 0, v->engine_type, v);
852 if (callback != CALLBACK_FAILED) {
853 if (HasBit(callback, 0)) {
854 TriggerVehicle(v, VEHICLE_TRIGGER_CALLBACK_32); // Trigger vehicle trigger 10
855 }
byte day_counter // Increased by one for each day.
I presume day_counter isn´t engine specific but global, am I right?

regards
Michael
Image
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: Question about CB 32

Post by Eddi »

when "v" is a vehicle, "v->day_counter" is a vehicle-specific value, not a global value.

i suppose it is initialized on vehicle construction, and then incremented on new day. that means, unless it is initialized to a random value, all vehicles purchased on the same day will be called synchronously on the same day later on.

PS: use

Code: Select all

 tags to preserve indentation.
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: Question about CB 32

Post by michael blunck »

Eddi wrote: "v->day_counter" is a vehicle-specific value, not a global value.

i suppose it is initialized on vehicle construction, and then incremented on new day.
Right, now I found the vehicle structure. I think I should rephrase the specs a bit, because now it seems to suggest some form of randomisation included.
Eddi wrote: PS: use

Code: Select all

 tags to preserve indentation.
[/quote]
Sorry, I forgot about. :cool:

regards
Michael
Image
Post Reply

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 9 guests