Lag optimization fix
alster
Join Date: 2003-08-06 Member: 19124Members
Problem now:
Players with low and high ping experience and complain about lag at certain times when there is a spike in ping or drop in tick rates. This occurs when the client or server has to load or send data, eg. loading graphics, players joining, large number of players - constructs in one area, etc. It's almost bound to happen no matter how optimized network code becomes.
Combat between large groups with constructs in the area is especially laggy almost unplayable to a point.
Solution:
Lag "compensation" ... excuse my caveman code :) .... all numbers used are just random examples
max_marine_speed = 200
max_skulk_speed = 220
max_marine_turn_speed = 100
max_lmg_fire_rate = 30
max_lerk_spike_fire_rate = 10
lag_marine_speed = max_marine_speed - (ping/10) - (100/tick)
lag_marine_turn_speed = max_marine_turn_speed - (ping/50) - (20/tick)
lag_lmg_fire_rate = max_lmg_fire_rate - (ping/500) - (10/tick)
if player1 ping < 300 and player1 tick > 50 then "player 1 normal lag free speed"
marine_speed(player1) = max_marine_speed
marine_turn(player1) = max_marine_turn_speed
marine_lmg_fire_rate = max_lmg_fire_rate
lag_counter(player1) = 0
else "player 1 too much lag - slow him down"
marine_speed(player1) = lag_marine_speed
marine_turn(player1) = lag_marine_turn_speed
marine_lmg_fire_rate = lag_lmg_fire_rate
+1 to lag_couner(player1)
if lag_counter(player1) > 50 then "player 1 keeps lagging for too long"
message(player1) "You have a connection problem!"
lag_counter(player1) = 0
Sounds logical? I hope it makes sense.
It should also make lag free players look like they move faster than lagged players by increasing the lag free players speed and animation when they travel from point A to B when the server updates their position to the lagged players instead of the lag free players suddenly jumping from point A to B. Another side effect is lag free players look like they shoot and turn faster to the lagged players.
What players experience:
Gameplay is kept smooth instead of freezing, jerkiness, sudden turn spins, players appearing suddenly, bullets firing fast but not hitting anything, players can accurately aim a little slower during combat with high numbers of players or constructs in the area.
Most players will probably never know that their ping spiked and they have been "lagged compensated" unless of course they really have a bad connection for a long time.
Finally, players won't have to rage so much about the lag anymore. ;)
Players with low and high ping experience and complain about lag at certain times when there is a spike in ping or drop in tick rates. This occurs when the client or server has to load or send data, eg. loading graphics, players joining, large number of players - constructs in one area, etc. It's almost bound to happen no matter how optimized network code becomes.
Combat between large groups with constructs in the area is especially laggy almost unplayable to a point.
Solution:
Lag "compensation" ... excuse my caveman code :) .... all numbers used are just random examples
max_marine_speed = 200
max_skulk_speed = 220
max_marine_turn_speed = 100
max_lmg_fire_rate = 30
max_lerk_spike_fire_rate = 10
lag_marine_speed = max_marine_speed - (ping/10) - (100/tick)
lag_marine_turn_speed = max_marine_turn_speed - (ping/50) - (20/tick)
lag_lmg_fire_rate = max_lmg_fire_rate - (ping/500) - (10/tick)
if player1 ping < 300 and player1 tick > 50 then "player 1 normal lag free speed"
marine_speed(player1) = max_marine_speed
marine_turn(player1) = max_marine_turn_speed
marine_lmg_fire_rate = max_lmg_fire_rate
lag_counter(player1) = 0
else "player 1 too much lag - slow him down"
marine_speed(player1) = lag_marine_speed
marine_turn(player1) = lag_marine_turn_speed
marine_lmg_fire_rate = lag_lmg_fire_rate
+1 to lag_couner(player1)
if lag_counter(player1) > 50 then "player 1 keeps lagging for too long"
message(player1) "You have a connection problem!"
lag_counter(player1) = 0
Sounds logical? I hope it makes sense.
It should also make lag free players look like they move faster than lagged players by increasing the lag free players speed and animation when they travel from point A to B when the server updates their position to the lagged players instead of the lag free players suddenly jumping from point A to B. Another side effect is lag free players look like they shoot and turn faster to the lagged players.
What players experience:
Gameplay is kept smooth instead of freezing, jerkiness, sudden turn spins, players appearing suddenly, bullets firing fast but not hitting anything, players can accurately aim a little slower during combat with high numbers of players or constructs in the area.
Most players will probably never know that their ping spiked and they have been "lagged compensated" unless of course they really have a bad connection for a long time.
Finally, players won't have to rage so much about the lag anymore. ;)
Comments
I hate to sound pretentious, but.... um.... this is like netcode 101 and if it isn't in NS2 already they have failed as programmer, developers, and so on.
Mind you not your exact implementation, but lag compensation and correction is basic stuff.
Nothing is as disappointing as evading a volley of bullets by jumping around a corner - and still dieing.
If you don't have broadband, annoy the people responsible. Not fellow players.
Nothing is as disappointing as evading a volley of bullets by jumping around a corner - and still dieing.
If you don't have broadband, annoy the people responsible. Not fellow players.<!--QuoteEnd--></div><!--QuoteEEnd-->
The positives far outweigh the negatives. If anyone used to play quake on 56k, you had to lead targets. Not only that, but when you joined you had to fight for a bit to work out how much to lead the targets based upon the ping.
Also, you had to lead further in front the quicker they were going.
What this comes down to is the efficiency of the servers. They still need heavy optimization. Once that's done, I doubt people will be complaining about lag issues. I've played several games where I've had a 190-250 average ping and it was playable. The current Technical items on the Progress page will provide MUCH greater optimization to server performance than the OP's proposed idea. No need to reinvent the wheel here.