Jump to content


Photo

Game slowdown issue


  • Please log in to reply
7 replies to this topic

#1 PezzA

PezzA

    Squaddie

  • Xenocide Programming Department
  • 5 posts

Posted 16 November 2009 - 06:44 PM

It's not because its taking to long to do something, but because it's doing stuff too fast (or possibly not doing it at all)!

When you get the game freeze, it's actually reporting 0.0001ms between frames. Game time is advanced using the time between frames as a multiplier. close to zero frame ms period means close to zero game-time advancement.

I did a quick if(ms < 16) ms = 16 and presto, no more game freezes!

But why the < 1ms interval? Thats the next question.

I've attached a patch for the hack i did to get over the freeze in lieu of having an actual fix. Hopefully this will make the game a bit more playable untill then.

Attached File  gamefreezetempfix.zip   531bytes   17 downloads

Edited by PezzA, 16 November 2009 - 06:55 PM.


#2 Darkhomb

Darkhomb

    Captain

  • Xenocide Artwork Department
  • 628 posts

Posted 16 November 2009 - 07:40 PM

Great news, Good work.

#3 kafros

kafros

    Creative Text Department

  • Xenocide Creative-Text Departmen
  • 1,800 posts

Posted 17 November 2009 - 03:11 AM

Hahaha, hear hear! Nice catch :)

So, is it a XNA issue, or just a default behaviour which should be changed?

Edited by kafros, 17 November 2009 - 03:11 AM.


#4 Mad

Mad

    Creative Text Department

  • [Xenocide Senior Members]
  • 1,958 posts

Posted 17 November 2009 - 02:28 PM

Good work - this explains why this problem is more severe on faster machines than on slower machines...
Keep smiling while dying

Of course I have gone mad with power! It would be completely ridiculous to go mad without power!
And no, this is not a quote from the Simpson's movie, I want it on paper, that I actually wrote that quite some time before the movie came out.

Posted Image

#5 PezzA

PezzA

    Squaddie

  • Xenocide Programming Department
  • 5 posts

Posted 17 November 2009 - 04:45 PM

This sounds like our problem it has some possible solutions as well. Which do people think is best?

Edited by PezzA, 17 November 2009 - 04:50 PM.


#6 kafros

kafros

    Creative Text Department

  • Xenocide Creative-Text Departmen
  • 1,800 posts

Posted 18 November 2009 - 07:16 AM

We should wait for dteviot's opinion on this one.

#7 dteviot

dteviot

    Programming Department

  • [Xenocide Senior Members]
  • 1,479 posts

Posted 18 November 2009 - 12:50 PM

We should wait for dteviot's opinion on this one.

Firstly, PezzA, thanks very much for tracking down the problem. Now that you've pointed it out, I can recall that I had a lot of problems with ElapsedRealTime vs. ElapsedGameTime. However, that was back with XNA 1.1.
My opinion is ask one the people suffering from the slowdown to try using ElapsedGameTime in GeoData.PumpUpdate (file Source\Model\Geoscape\GeoData.cs)
e.g.
public void PumpUpdate(GameTime gameTime)
		{
			// get elapsed time plus any leftover time from last iteration
			double gameMilliseconds = GeoTime.RealTimeToGameTime(gameTime.ElapsedRealTime) + leftoverTimeStep;
			leftoverTimeStep = 0.0;
becomes
public void PumpUpdate(GameTime gameTime)
		{
			// get elapsed time plus any leftover time from last iteration
			double gameMilliseconds = GeoTime.RealTimeToGameTime(gameTime.ElapsedGamelTime) + leftoverTimeStep;
			leftoverTimeStep = 0.0;
And checking that RealTimeToGameTime() in GeoTime (file Source\Model\Geoscape\GeoTime.cs) does NOT have your tempory fix. i.e. Function should look like this:
public double RealTimeToGameTime(TimeSpan timespan)
		{
			return timespan.TotalMilliseconds * timeRatio;
		}
If this fixes the problem, then it's the simplest solution. If it doesn't work, then we're going to need to do the time measuring ourselves. Probably using a Stopwatch as suggested.

Edited by dteviot, 18 November 2009 - 12:50 PM.

Saving the world from the scum of the universe is hard work. Especially when you have to create the scum to begin with.

#8 PezzA

PezzA

    Squaddie

  • Xenocide Programming Department
  • 5 posts

Posted 18 November 2009 - 02:40 PM

I could reliably recreate the issue, and elapsedgametime appears to resolve it.