by Spike » Wed Oct 20, 2010 3:48 pm
the easy way from QC is to writebyte(msg_foo, svc_updatestat); writebyte(msg_foo, stat_mine); writelong(msg_foo, myvaluehere);
probably msg_foo=msg_one.
stat_mine is whatever value you want. if its <32 you'll not break network compatibility. DP, FTE, and other QW clients have specific interpretations for many <32 stats. CSQC states that 32-128 are for mod use. If you don't care about compatibility then it doesn't matter, just be aware that you might end up changing DP/FTE's zoom and stuff :)
myvaluehere is whatever value your mod wants to send for that stat.
then you can send what you want, when you want to send it. don't flood it! make it a function to be used to set a field and delta check it. that works too. logically you're limited to integer values, though really all that matters is that its 4 bytes. you can mangle them clientside if you really wanted to send a float instead, but you'd need a union or a *(float*)&cl.stats[foo] or something. If you want to send a full 32bit int bitmask, send two shorts, the first is the lower 16 bits, the second is the upper (floats can only retain precision to about 24 bits).
An NQ engine will flood the client with regular stat updates once per frame, but at least its only one byte per stat (see svc_clientdata), while QuakeWorld deltas them, but knowing this isn't too important.
The QC-directed stat sending is the easiest to explain. An engine could easily be configured to send fields, but that's far far more lines of code (field access with delta storage+delta code, or protocol changes, depending on how you want it).
.