callofduty4x / CoD4x_Server

Extended Call of Duty 4 server
https://cod4x.ovh
GNU Affero General Public License v3.0
335 stars 121 forks source link

Demo: Fix non delta frames #394

Closed Iswenzz closed 1 year ago

Iswenzz commented 1 year ago

when recording demos the server sends a non delta frame every power of 2 frames, this can cause lag if the server has many entities to send, especially at the beginning of the demo.

making the server send only 1 non delta frame at the beginning of the demo is enough for the demos to work and avoid the lag.

is there any reason to send these non delta frames ?

Iswenzz commented 1 year ago

the code of this PR doesn't work very well if the non delta frame is dropped by the player (i think ?) im currently saving a non delta frame to the demo file without sending the frame to the player at all (huge perf improvement for the player), it works well but the code is not very clean and it might have some issues as well so i'll close the PR.

Iswenzz commented 1 year ago

i tested a new solution for a month on my server and it works, the solution is to have a separate function that can write a snapshot only for the demo file (this function does not send to the client). and then use this function to create the first non delta frame for the demo, this function will write demo snapshots until the player deltaMessage is synced with the server. once its done, the original snapshot function can write to the demo. this ensure that the frames correctly points to the first non delta frame.

Iswenzz commented 1 year ago

i updated the code, it can be improved to maybe not include a whole copy of the write snapshot function, i didn't risk to edit the main one as it needs different function parameters to make it generic and specify which frame to delta. need review on this :)

Zoro-6191 commented 1 year ago

nice work