News:

Use the "Forum Search"
It may help you to find anything in the forum ;).

City Cars and Timestep bug?

Started by Eusebio Ptolomeu, November 07, 2017, 10:27:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Eusebio Ptolomeu

  I changed the Global time multiplier, in pak128, to make days longer. However, it seems that this affects the City Car generation: no car is generated anymore, even with traffic density checked. In fact, if I try to create a city car using the Public Service Player, it doesn't appear at all. If I pause the game and put a city car, it appears, but once I unpause the simulation, it quickly desappears. I know this is a issue with the global multiplier setting, for once I changed it back to the original, city cars start appearing again. Does anybody knows why this happens?

P.S. I am changing the bits per month to a real high value, like 28, which makes the game only about 4 times faster than real life.

prissi

#1
I suspect the lifetime timer overflows. It is initialised by

time_to_life = welt->get_settings().get_stadtauto_duration() << welt->ticks_per_world_month_shift;

All these are singed 32 bit variables. If you set the shift to 28, then get_stadtauto_duration() must be less than 8 or the value is negative immeadiately. But default is 36, which was tailored for bits_per_month=20

Since the city car density should not depend on the bits_per_month setting, it should be probably normalised by 20 or you will drown in city cars soon.

DrSuperGood

#2
QuoteSince the city car density should not depend on the bits_per_month setting, it should be probably normalised by 20 or you will drown in city cars soon.
One must then make sure that the car spawn rate is also normalised and invariant with month length, if this is not the case already.

There is two ways such car spawning could be implemented.

I suspect the current one is meant to spawn a fixed number of cars per month, and each of these cars lasts a fixed number of months as defined by the settings. This would average out at the same traffic density as the cars spawn slower but last longer. However with very long months it would be highly prone to overflow due to how large the numbers can become, as you explained.

The other approach, which is what you are suggesting, is that both spawn rate of cars and duration of cars is fixed. This results in the same traffic density no matter the month length. Month length only determines how many cars spawn/expire per month, a stat that users likely do not care about. Since no scaling is used it will work for any month length as well. It also fits the same scaling mechanics as passengers and goods, with more being transported per month proportional to month length so one can think of it as more cars being created/expiring proportional to month length. I would suggest implementing this approach, as long as both spawn rate and duration remain month invariant.

It might be a good idea to revise all month length scaling code. A while ago I spotted incorrect scaling logic for power income, why making profit with power was near impossible in most games. Who knows what else might be scaling incorrectly.

prissi

It had been tested up to 26. Higher number are not very meaningful, since one would never see a year completed (Since at 28 it takes about 3 month for a year ... )