Page 1 of 1
CPU usage
Posted: 05 Apr 2005 12:38
by SHADOW-XIII
I remember there was some additions in TTDPatch that free CPU usage when game is paused ...
however it does work with wo faster speeds but it does not work on the fastest one (cpu usage is 100% when paused)
Posted: 05 Apr 2005 13:15
by Csaboka
This is because of the way gamespeed works: it decreases the amount of time that TTD waits between two gameticks. The fastest setting means "as fast as your computer can do it", i.e. no delay at all.
The old TTD code used an infinite loop to wait that time to pass. The new code uses the Windows function Sleep() instead, so Windows can do other tasks while TTD is waiting. If there's no delay at all, however, the new method can't do anything to release CPU time, so you end up with 100% CPU usage.
Posted: 05 Apr 2005 13:19
by SHADOW-XIII
so maybe possibility to:
invisible change to normal speed when game is paused (so that it won't use 100% CPU)
and after unpausing it becomes the same speed it was before
Posted: 05 Apr 2005 14:21
by Patchman
Well, there are reasons to leave it at a higher speed even when paused, for example you get smoother scrolling and faster updates of the window system. If you need to use your CPU for something else while paused, just hit the 'W' key

Posted: 05 Apr 2005 15:32
by Rob
There is another problem with the speedsetting : it isn't saved with the game.
The game always starts up with normal speed.
Could this be changed?
Posted: 05 Apr 2005 17:31
by Patchman
It could be, but I'm not sure it's appropriate. The game speed is really a property of the game engine or the computer, rather than the savegame.
Maybe it would be better to allow a parameter to the gamespeed switch that sets the initial speed instead.
Posted: 05 Apr 2005 19:34
by Rob
That would be nice, yes.

My game is rather slow,

and trains run somewhat jerky.
I have to hit the Q-key twice, to get them moving smooth again, so I am in favor of the parameter.
Posted: 16 Apr 2005 13:15
by SHADOW-XIII
relating to the 100% CPU .. TTD is said to use max CPU as it can at fastest game speed ... maybe doing max_CPU-1 should fix that

Posted: 17 Apr 2005 17:56
by Csaboka
I don't see how this would be better. If you don't use all the CPU time, it isn't the fastest possible setting, is it? Let's say we put the minimal amount of sleep (1 millisecond) between ticks. Now, depending on the speed of your CPU, the CPU load drops and the game slows down accordingly.
I've experienced with this a bit on my machine:
Code: Select all
With 1 ms sleep between ticks
CPU usage: 10-20%
Time to simulate one year: 2:21
With no sleep between ticks
CPU usage: 100%
Time to simulate one year: 1:50
As you can see, this minimal delay would slow down the simulation so it wouldn't be the fastest anymore.