XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

GameTime.TotalGameTime incrementing roughly 1 sec every 10 seconds in 2 player session over subnet

Last post 09-25-2008 8:45 PM by Sheemalakameeda. 3 replies.
  • 09-13-2008 5:33 AM

    GameTime.TotalGameTime incrementing roughly 1 sec every 10 seconds in 2 player session over subnet

    First off, I made a huge mistake, I starting learning XNA January of 08 and began writing a game that I intended to allow 8 player Xbox live multiplayer but because I was new to XNA and writing network session code I decided to wait until the end of development to add my Client Server architecture into the game.

    Now I am in the final stages of development and the only thing left to do is add the client server architecture.  The problem is that my game works perfectly with 4 players locally, and I can link up a session between two computers and get all the way to the gameplay state, but once the players enter the match everything starts updating at a ridiculously slow rate, even the GameTime object is updating at about 1 second per every 10 seconds.

    Most of the client server code isn't actually written yet, I am not sending or receiving packets. In my update function I am updating several parts of my game that will need to be performed for each client machine, these functions mainly consist of running timers to trigger AI, gameplay state changes and handle input for Local gamers only.  Now I know the game won't work properly in a connected session without the sending and receiving and all, that's why I'm working on adding it, but each client should update without any delay since they aren't really tied to each other except for sharing the networksession object.

    The wierd thing is when I step through the code all the update functions run at a normal speed if i put a breakpoint at the bottom and let them run from the function head, however when I step through the main Update function the GameTime.ElapsedGameTime is incrementing roughly 1 second every 10 seconds (I am getting this estimate while the game is running from watching the game time limit, not while the execution is paused on a breakpoint).

    The second I disconnect one of the sessions the other session starts running at normal speed again, any ideas???

    I know I know, if you fail to plan, you plan to fail, lesson learned.  Any help would be greatly appreciated, thanks.

  • 09-13-2008 9:36 AM In reply to

    Re: GameTime.TotalGameTime incrementing roughly 1 sec every 10 seconds in 2 player session over subnet

    I know you said that youre not sending or recieveing data, but are you still calling NetworkSession.Update every cycle? THe framework needs this to keep things in sync I beleive, so this could be the cause fo the problem.
  • 09-13-2008 6:37 PM In reply to

    Re: GameTime.TotalGameTime incrementing roughly 1 sec every 10 seconds in 2 player session over subnet

    I figured it out!!, it was one stupid little line, hopefully if anyone else has a similar issue in the future this post will help them.

    In the game I'm drawing each players GamerProfile picture, so I was iterating through networksession.AllGamers and calling GetProfile() for each player to get the picture and then draw it.  I was calling this from the main Draw every frame, apparently that's a big no no.

    For example:

     

    protected override Draw(GameTime gameTime)

    {

        foreach (NetworkGamer gamer in _networkSession.AllGamers)

        {

           GamerProfile gamerProfile = gamer.GetProfile(); // THIS IS VERY BAD!!!

     

         }

    }

    The solution is to load each gamers profile picture when the gamer joins and store it.

     

     

  • 09-25-2008 8:45 PM In reply to

    Re: GameTime.TotalGameTime incrementing roughly 1 sec every 10 seconds in 2 player session over subnet

    RuthlessSD:

    I figured it out!!, it was one stupid little line, hopefully if anyone else has a similar issue in the future this post will help them.

    In the game I'm drawing each players GamerProfile picture, so I was iterating through networksession.AllGamers and calling GetProfile() for each player to get the picture and then draw it.  I was calling this from the main Draw every frame, apparently that's a big no no.

    For example:

     

    protected override Draw(GameTime gameTime)

    {

        foreach (NetworkGamer gamer in _networkSession.AllGamers)

        {

           GamerProfile gamerProfile = gamer.GetProfile(); // THIS IS VERY BAD!!!

     

         }

    }

    The solution is to load each gamers profile picture when the gamer joins and store it.

     

     

    LOL! I had to learn that the hard way too. It worked great on the PC, but as soon as I sent to my 360, the game brought it to it's knees.

Page 1 of 1 (4 items) Previous Next