Quake-C Network Protocol

Qukae-C is not supposed to handle a lot of network messages, since most are already handled in C.

However, builtin functions have not been built for every kind of messages in the Quake protocol, so you migth end-up composing protocol messages in Quake-C. I highly recommend that you build a single function to handle a given message type, because the structure of those messages might change, and then all your code would have to be checked for bugs.

By that way, id software didn't even bothered to write a function to generate temporary entites, though they keep using this message. It's still a long way to ISO 9001, I'm afraid.

Definitions related to protocol messages

Values: How messages are sent

MSG_BROADCAST = 0;  // unreliable message, sent to all
MSG_ONE = 1;       // reliable message, sent to msg_entity
MSG_ALL = 2;       // reliable message, sent to all
MSG_INIT = 3;	// write to the init string

Values: Type of message

These are some of message types defined in the Quake network protocol.
SVC_SETVIEWPORT = 5;
SVC_SETANGLES = 10;
SVC_TEMPENTITY = 23;
SVC_KILLEDMONSTER = 27;
SVC_FOUNDSECRET = 28;
SVC_INTERMISSION = 30;
SVC_FINALE = 31;
SVC_CDTRACK = 32;
SVC_SELLSCREEN = 33;
SVC_UPDATE = 128;

Some message structures

Here are some of the messages defined in the Quake network protocol.

Beware, the structure of those messages might change in future version (Satan forbids!).

Message: Set View Position

  msg_entity = player
  WriteByte (MSG_ONE, SVC_SETVIEWPORT);
  WriteEntity( MSG_ONE, camera);
This message is meant for a single client player. It sets the view position to the position of the entity camera.

Message: Set View Angles

  msg_entity = player
  WriteByte (MSG_ONE, SVC_SETVIEWANGLES);
  WriteAngle( MSG_ONE, camera.angles_x); 
  WriteAngle( MSG_ONE, camera.angles_y);
  WriteAngle( MSG_ONE, camera.angles_z);
This message is meant for a single client player. It set the orientation of it's view to the same orientation than the entity camera.

Message: Temporary Entity

  WriteByte (MSG_BROADCAST, SVC_TEMPENTITY);
  WriteByte (MSG_BROADCAST, entityname);
  WriteCoord (MSG_BROADCAST, origin_x);
  WriteCoord (MSG_BROADCAST, origin_y);
  WriteCoord (MSG_BROADCAST, origin_z);

Message: Set CD Track

  WriteByte (MSG_ALL, SVC_CDTRACK);
  WriteByte (MSG_ALL, val1);        // CD start track
  WriteByte (MSG_ALL, val2);        // CD end track

Message: Final Message

  WriteByte (MSG_ALL, SVC_FINALE);
  WriteString (MSG_ALL, "any text you like\n");

Message: Sell Screen

WriteByte (MSG_ALL, SVC_SELLSCREEN);
Shows the infamous sell screen (like you needed it to understand).

Message: Inter Mission

WriteByte (MSG_ALL, SVC_INTERMISSION);
Shows the inter mission camera view.

Message: Killed Monster

WriteByte (MSG_ALL, SVC_KILLEDMONSTER);
Increase by one the count of killed monsters, as available to the client. Can be displayed with showscores.

Message: Found Secrets

WriteByte (MSG_ALL, SVC_FOUNDSECRET);
Increase by one the count of secrets founds.

Message: Update Entity

This message has a rather complex structure. I already generated some valid update messages, but since the message structure seems highly susceptible to change in the next versions of Quake, I would recommend that you never use such messages: as a matter of fact, Quake itslef is very capable of generating all the required messages... unless you start creating deathmatch cameras or the like.