• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] How to detect if players are lagging?

Status
Not open for further replies.
Level 1
Joined
Jan 27, 2019
Messages
4
Hi, does anyone know of an event that fires when players are lagging? I set up a timer that restarts itself every time it completes. I use it for all the gameplay updates, lots of writing to and reading from hashtables for example. R_Update_Time is initially set to 1.00 seconds, however I'd like to be able to increase that if people are lagging.

  • Updating Game Time
    • Events
      • Time - T_Update expires
    • Conditions
    • Actions
      • Countdown Timer - Start T_Update as a One-shot timer that will expire in R_Update_Time seconds
Does anyone know of a way to do that? I was thinking something like:

  • Lagging Players
    • Events
      • Players are lagging
    • Conditions
    • Actions
      • Set variable R_Update_Time = R_Update_Time + 0.50
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
There is no such event since lag is part of synchronization and does not directly impact game state.

It however does indirectly impact game state in the form of TriggerSleepAction (GUI Wait action) returns. TriggerSleepAction will still progress and can return while the game is paused, including on the waiting for player screen. Hence one can detect lag by detecting lost game time with respect to TriggerSleepAction. If one measures the time of a 1 second TriggerSleepAction using a timer it should remain approximately constant for a given game speed and multiplayer configuration. If however this measured time sharply decreases that means that lag is occurring. Or at least that is the theory...
 
Level 1
Joined
Jan 27, 2019
Messages
4
So maybe something like this? Two triggers:


  • Updating Game Wait
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set R_Game_Time_Elapsed_Wait = (R_Game_Time_Elapsed_Wait + 1.00)
Notice I have two real variables, one has "Wait" at the end and the other has "Timer"

  • Updating Game Time
    • Events
      • Time - T_Update expires
    • Conditions
    • Actions
      • Set R_Game_Time_Elapsed_Timer = (R_Game_Time_Elapsed_Timer + R_Update_Time)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • R_Game_Time_Elapsed_Timer Less than R_Game_Time_Elapsed_Wait
        • Then - Actions
          • Set R_Update_Time = (R_Update_Time + 0.25)
        • Else - Actions
      • Countdown Timer - Start T_Update as a One-shot timer that will expire in R_Update_Time seconds
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
So maybe something like this?
Nope something like that will not work at all. Timers and trigger events are synced to game time and hence will progress at the same speed together and will ait for players.

To summarize what I said before. This might be possible by using TriggerSleepAction (The GUI Wait action which is not Wait Game Time) in combination with a timer. TriggerSleepAction should not be effected by slowdown while timers are. Hence if slowdown occurs one will notice the TriggerSleepAction loop running faster with respect to the timer. It will also detect when the game is paused (TriggerSleepAction keeps running when paused while timers do not) but it might not detect lag (depends how TriggerSleepAction is implemented, needs testing).

I assume you want this for some sort of dynamic performance system? By the time a game client slows down the game is as good as unplayable for the owner of the client hence it might not be that useful. If lag is detected then that has little to do with trigger execution count unless network synchronization functions are being called and hence again it is not likely to be too useful. Rather design the game around near perfect 60 FPS on lower hardware than look to hack in dynamic performance.
 
Level 1
Joined
Jan 27, 2019
Messages
4
Darn, it was an idea I had but it seems unfeasible. Thanks for your help! I think I'll just try and design my triggers such that they're more... Staggered, instead of all running off of one gametime timer. That way it'll seem smoother.
 
Status
Not open for further replies.
Top