Announcement

Collapse
No announcement yet.

Optimize cycling through all pawns

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Optimize cycling through all pawns

    I've written a mutator that logs the location of all players every X seconds. I'd like to call my timer function quickly enough to yield accurate location data (I'm using an inteval of 0.5 seconds currently). But not too suprisingly these operations cause the game to bog down once multiple players join.

    Anyone know if is is possible to write the following code more efficiently so the game won't bog down as much?

    Code:
    function Timer()
    {
      local Controller C;
    
      for (C = Level.ControllerList; C != None; C = C.NextController) 
      {
        if (C.Pawn != None)
          Log(Level.Timeseconds $ ", " $ C.Pawn.location $ ", " $ C.PlayerReplicationInfo.PlayerName, 'LOG_LOC');
      }
      super.Timer();
    }
    Thanks!

    #2
    that code most certainly should not have any particular performance impact, especially not if it's only being run twice per second. The most likely cause of the slowdown (assuming you are sure it is that particulary piece of code causing your problem) is writing so much data to disc.

    Comment


      #3
      Hmmm interesting, thanks for the info. So now I'm thinking that buffering the file output will result in some performance increase.

      It looks like the FileLog class is buffered, so that may help. Or maybe I could manually accumulate my output in memory and then write it out less frequently, like every 5 seconds.

      Comment

      Working...
      X