Forum

The Write functions?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

The Write functions?

Postby Mexicouger » Thu Feb 17, 2011 12:16 am

I have been wondering for the longest time how to correctly use the WriteByte and other Write functions. Can someone be kind enough to give me a brief overview of each of the functions, and an example for use?

That would be most helpful!
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby Spike » Thu Feb 17, 2011 3:12 am

WriteByte and friends are an ugly hack. You don't use them unless you know what you're doing, unless there's no other choice to achieve the effect you want.
They permit you to write 'custom' messages from the server to the client, except that those messages *must* be in a form that the client understands.
This means if something is documented as a coord, use writecoord. Don't use writeshort and imagine that its all the same. Because it varies from engine to engine what a coord actually is.

messages start with some SVC_FOO byte, and then its svc-specific what should be written after. Look in the sourcecode of your target quake client to see the exact details on an svc-by-svc basis.

you can achieve some things that are not otherwise possible, prydon gate's centerprint string concatination is one example, but for the most part, existing extensions are simply much easier to use.

If you use DP or FTE, you should never need to do writebytes. There is a proper builtin to do it for you, somewhere. At least that's the theory. No new standard extensions expect you to use writebyte.

'illegible server message' means you broke it.

I confess that I'm somewhat anti-writebyte as it makes translation between nq and qw mods harder, which is something my engine does a lot of... :)

So yeah, my point is, look at the svcs, if you see a nice looking one, look for a builtin instead first, as its more reliable to do so.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby leileilol » Thu Feb 17, 2011 3:16 am

I love writebytes. They're the easiest to implement as features in engines. :D

the pf builtins are more slicker, though, but are tougher...


btw is there any necessary room for proposing a "pf_sound2"? This is one pf_ I feel that's needed for altered pitch and loop options... combine it with "pf_soundparm" to ramp volume and pitch with a duration on a channel
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: The Write functions?

Postby OneManClan » Sat Feb 19, 2011 1:48 am

Mexicouger wrote:...Can someone be kind enough to give me a brief overview of each of the functions, and an example for use?

That would be most helpful!


Here's an example of a problem solved by the use of WriteByte, along w my newbie questions, and answers by Spike.
OneManClan
 
Posts: 243
Joined: Sat Feb 28, 2009 2:38 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest