+/*
+===============================================================================
+MESSAGE WRITING
+
+used only for client and menu
+severs uses VM_SV_...
+
+Write*(* data, float type, float to)
+
+===============================================================================
+*/
+
+#define MSG_BROADCAST 0 // unreliable to all
+#define MSG_ONE 1 // reliable to one (msg_entity)
+#define MSG_ALL 2 // reliable to all
+#define MSG_INIT 3 // write to the init string
+
+sizebuf_t *VM_WriteDest (void)
+{
+ int dest;
+ int destclient;
+
+ if(!sv.active)
+ PRVM_ERROR("VM_WriteDest: game is not server (%s)\n", PRVM_NAME);
+
+ dest = PRVM_G_FLOAT(OFS_PARM1);
+ switch (dest)
+ {
+ case MSG_BROADCAST:
+ return &sv.datagram;
+
+ case MSG_ONE:
+ destclient = (int) PRVM_G_FLOAT(OFS_PARM2);
+ if (destclient < 0 || destclient >= svs.maxclients || !svs.clients[destclient].active)
+ PRVM_ERROR("VM_clientcommand: %s: invalid client !\n", PRVM_NAME);
+
+ return &svs.clients[destclient].message;
+
+ case MSG_ALL:
+ return &sv.reliable_datagram;
+
+ case MSG_INIT:
+ return &sv.signon;
+
+ default:
+ PRVM_ERROR ("WriteDest: bad destination");
+ break;
+ }
+
+ return NULL;
+}
+
+void VM_M_WriteByte (void)
+{
+ MSG_WriteByte (VM_WriteDest(), PRVM_G_FLOAT(OFS_PARM0));
+}
+
+void VM_M_WriteChar (void)
+{
+ MSG_WriteChar (VM_WriteDest(), PRVM_G_FLOAT(OFS_PARM0));
+}
+
+void VM_M_WriteShort (void)
+{
+ MSG_WriteShort (VM_WriteDest(), PRVM_G_FLOAT(OFS_PARM0));
+}
+
+void VM_M_WriteLong (void)
+{
+ MSG_WriteLong (VM_WriteDest(), PRVM_G_FLOAT(OFS_PARM0));
+}
+
+void VM_M_WriteAngle (void)
+{
+ MSG_WriteAngle (VM_WriteDest(), PRVM_G_FLOAT(OFS_PARM0), sv.protocol);
+}
+
+void VM_M_WriteCoord (void)
+{
+ MSG_WriteCoord (VM_WriteDest(), PRVM_G_FLOAT(OFS_PARM0), sv.protocol);
+}
+
+void VM_M_WriteString (void)
+{
+ MSG_WriteString (VM_WriteDest(), PRVM_G_STRING(OFS_PARM0));
+}
+
+void VM_M_WriteEntity (void)
+{
+ MSG_WriteShort (VM_WriteDest(), PRVM_G_EDICTNUM(OFS_PARM0));
+}
+