-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation on delta for GoldSrc demo #164
Comments
Sorry for the delayed reply! Thanks for the kind words. ❤️ I'm really glad you've found the documentation helpful. Unfortunately I have to admit that the fundamentals behind delta compression or even the bit packing/unpacking underlying it are still pretty opaque to me. I adapted hlviewer's implementation, mostly just to get something working with
I'll take a stab at generalizing what I do know (or what I think I know, at least 😄), but I've only had to decode them relying on the hlviewer implementation. Encoding from within a client or just trying to write the structures to file might be a little more nuanced. Delta compression in GoldSrc
Delta encoding
Delta decoding
Client/server communicationBig guesses to follow here... 1. Server loads delta encoders from
|
Message | When | |
---|---|---|
SVC_CLIENTDATA |
Every frame. Has client data, weapon data from the previous frame. | Message structure: SVC_CLIENTDATA. |
SVC_EVENT |
When some specific game events happen; can be queued / dropped. | Message structure: SVC_EVENT. |
SVC_EVENT_RELIABLE |
When some specific game events happen, but can't be queued / dropped. | Message structure: SVC_EVENT_RELIABLE. |
SVC_SPAWNBASELINE |
When entity spawns for the first time? | Message structure: SVC_SPAWNBASELINE. |
SVC_PACKETENTITIES |
Initial entity state? | Message structure: SVC_PACKETENTITIES. |
SVC_DELTAPACKETENTITIES |
Every frame? Same as SVC_PACKETENTITIES but this compares to a previous frame somehow. |
Message structure: SVC_DELTAPACKETENTITIES. |
"Reliable" terminology harkens back to Quake netcode stuff I believe: https://fabiensanglard.net/quakeSource/quakeSourceNetWork.php.
Compression algorithm
Bitpacking
There is bitwise magic afoot here, so I've never had a great understanding about this.
hlviewer is an excellent reference: https://github.com/skyrim/hlviewer.js/blob/master/src/BitReader.ts#L10-L48.
Roughly I believe it works like:
- You have
x
amount of bits in a byte. - Using some mask value you can read
n
number of those bits to read a value. - You have
x - n
bits left in the byte to store more data.
If a message is finished writing, usually it will fill up to the next byte boundary.
Reading a delta
Hey, thanks for the detailed reply. Since then I have found some (enough) details to understand the delta. Good enough to implement my own, and also a delta writer. |
Great work on this.
I am trying to write my own demo writer but now I am working through delta. I hope you won't mind writing documentation on it since apparently you are the best at writing docs for GoldSrc demo as of now.
Regardless, I am still plowing through it by reading your delta decoding snippet along with this and this.
The text was updated successfully, but these errors were encountered: