Does cargo time "tick" when not on a vehicle? [SOLVED]

OpenTTD is a fully open-sourced reimplementation of TTD, written in C++, boasting improved gameplay and many new features.

Moderator: OpenTTD Developers

Post Reply
Cadde
Transport Coordinator
Transport Coordinator
Posts: 290
Joined: 07 Oct 2004 12:51

Does cargo time "tick" when not on a vehicle? [SOLVED]

Post by Cadde »

I get it that cargo transport time ticks away when you are loading at a station. Making full load orders tick away the time of the cargo to it's max of 255.
But does that time still tick when cargo is delivered to a station via a transfer order? Or, in the case of CargoDist, as cargo is automatically transferred from one vehicle to another to reach it's final destination, even if the transfer vehicle isn't in station at the time?

For example:

I pick up passengers at station A on day 0 and travel for 30 days to station B where they are unloaded. Their time variable is now 12. (because ~2.5 days per cargo time tick)
Another vehicle arrives at station B on day 60 to pick those passengers up and arrives at station C (the passengers final destination) on day 90.

Is their time variable set to 24 (60 days of travel) or 36 (90 days of travel) when arriving at station C?


Thank you!
Cadde
Transport Coordinator
Transport Coordinator
Posts: 290
Joined: 07 Oct 2004 12:51

Re: Does cargo time "tick" when not on a vehicle? [SOLVED]

Post by Cadde »

Well, now that i have freshened up i loaded up the hell that is the OTTD source code and had a look for myself.

I think it's safe to assume that cargo only ages when it's in a vehicle's cargo list.
As in, it only ages while being loaded, while carried and while being unloaded from a vehicle. It does NOT age while in station.

The only reference to AgeCargo() i found was in here:

Code: Select all

void CallVehicleTicks()
...
	FOR_ALL_VEHICLES(v) {
			case VEH_TRAIN:
...
				/* FALL THROUGH */
			case VEH_ROAD:
			case VEH_AIRCRAFT:
			case VEH_SHIP: {
...
				if (v->vcache.cached_cargo_age_period != 0) {
					v->cargo_age_counter = min(v->cargo_age_counter, v->vcache.cached_cargo_age_period);
					if (--v->cargo_age_counter == 0) {
						v->cargo.AgeCargo();
						v->cargo_age_counter = v->vcache.cached_cargo_age_period;
					}
				}
So basically, only if...
  • On a vehicle and...
  • cargo_age_period isn't zero and...
  • Using whichever is smaller, the vehicles cargo_age_counter or the vehicles cached_cargo_age_period, check if... (In other words, if the vehicle's specifications change due to NewGRF reload etc then don't wait 5 trillion ticks needlessly for the old value to trigger)
  • Vehicles cargo_age_counter (decreases every tick) is equal to zero. (By default, I.E not overridden by GRF, this is set to 185 after it reaches zero.)
Then and only then does AgeCargo() get called. Whose job it is to increase the cargo packets "days_in_transit" variable by one as long as it's not 255 already. Or it would overflow.

Thanks to all who viewed but didn't know the answer to this question. I hope now you do!
Post Reply

Return to “General OpenTTD”

Who is online

Users browsing this forum: No registered users and 31 guests