00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #include "server.h"
00030
00031
00032
00033
00034
00035
00036
00040 void SV_ClientCommand (client_t *client, const char *fmt, ...)
00041 {
00042 va_list ap;
00043 char str[1024];
00044 struct dbuffer *msg = new_dbuffer();
00045
00046 NET_WriteByte(msg, svc_stufftext);
00047
00048 va_start(ap, fmt);
00049 NET_VPrintf(msg, fmt, ap, str, sizeof(str));
00050 va_end(ap);
00051
00052 NET_WriteMsg(client->stream, msg);
00053 }
00054
00058 void SV_ClientPrintf (client_t * cl, int level, const char *fmt, ...)
00059 {
00060 va_list argptr;
00061 struct dbuffer *msg;
00062 char str[1024];
00063
00064 if (level > cl->messagelevel)
00065 return;
00066
00067 msg = new_dbuffer();
00068 NET_WriteByte(msg, svc_print);
00069 NET_WriteByte(msg, level);
00070
00071 va_start(argptr, fmt);
00072 NET_VPrintf(msg, fmt, argptr, str, sizeof(str));
00073 va_end(argptr);
00074
00075 NET_WriteMsg(cl->stream, msg);
00076 }
00077
00081 void SV_BroadcastPrintf (int level, const char *fmt, ...)
00082 {
00083 va_list argptr;
00084 struct dbuffer *msg;
00085 client_t *cl;
00086 char str[1024];
00087
00088 msg = new_dbuffer();
00089 NET_WriteByte(msg, svc_print);
00090 NET_WriteByte(msg, level);
00091
00092 va_start(argptr, fmt);
00093 NET_VPrintf(msg, fmt, argptr, str, sizeof(str));
00094 va_end(argptr);
00095
00096
00097 if (sv_dedicated->integer) {
00098 char copy[1024];
00099 int i;
00100 const int length = sizeof(copy) - 1;
00101
00102 va_start(argptr, fmt);
00103 Q_vsnprintf(copy, sizeof(copy), fmt, argptr);
00104 va_end(argptr);
00105
00106
00107 for (i = 0; i < length && copy[i]; i++)
00108 copy[i] = copy[i] & 127;
00109 copy[i] = '\0';
00110 Com_Printf("%s", copy);
00111 }
00112
00113 cl = NULL;
00114 while ((cl = SV_GetNextClient(cl)) != NULL) {
00115 if (level > cl->messagelevel)
00116 continue;
00117 if (cl->state < cs_connected)
00118 continue;
00119 NET_WriteConstMsg(cl->stream, msg);
00120 }
00121
00122 free_dbuffer(msg);
00123 }
00124
00130 void SV_Multicast (int mask, struct dbuffer *msg)
00131 {
00132 client_t *cl;
00133 int j;
00134
00135
00136 cl = NULL;
00137 j = -1;
00138 while ((cl = SV_GetNextClient(cl)) != NULL) {
00139 j++;
00140 if (cl->state < cs_connected)
00141 continue;
00142 if (!(mask & (1 << j)))
00143 continue;
00144
00145
00146 NET_WriteConstMsg(cl->stream, msg);
00147 }
00148
00149 free_dbuffer(msg);
00150 }
00151
00155 void SV_StartSound (int mask, const vec3_t origin, const edict_t *entity, const char *sound)
00156 {
00157 vec3_t origin_v;
00158 struct dbuffer *msg;
00159
00160
00161 if (!origin) {
00162 origin = origin_v;
00163 if (entity->solid == SOLID_BSP) {
00164 VectorCenterFromMinsMaxs(entity->mins, entity->maxs, origin_v);
00165 VectorAdd(entity->origin, origin_v, origin_v);
00166 } else {
00167 VectorCopy(entity->origin, origin_v);
00168 }
00169 }
00170
00171 msg = new_dbuffer();
00172
00173 NET_WriteByte(msg, svc_sound);
00174 NET_WriteString(msg, sound);
00175 NET_WritePos(msg, origin);
00176
00177 SV_Multicast(mask, msg);
00178 }