]> git.xonotic.org Git - xonotic/darkplaces.git/blob - sv_send.c
Add EOF newlines
[xonotic/darkplaces.git] / sv_send.c
1 /*
2 Copyright (C) 1996-1997 Id Software, Inc.
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
13 See the GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
18
19 */
20
21 #include "quakedef.h"
22
23 /*
24 =================
25 SV_ClientPrint
26
27 Sends text across to be displayed
28 FIXME: make this just a stuffed echo?
29 =================
30 */
31 void SV_ClientPrint(const char *msg)
32 {
33         if (host_client->netconnection)
34         {
35                 MSG_WriteByte(&host_client->netconnection->message, svc_print);
36                 MSG_WriteString(&host_client->netconnection->message, msg);
37         }
38 }
39
40 /*
41 =================
42 SV_ClientPrintf
43
44 Sends text across to be displayed
45 FIXME: make this just a stuffed echo?
46 =================
47 */
48 void SV_ClientPrintf(const char *fmt, ...)
49 {
50         va_list argptr;
51         char msg[MAX_INPUTLINE];
52
53         va_start(argptr,fmt);
54         dpvsnprintf(msg,sizeof(msg),fmt,argptr);
55         va_end(argptr);
56
57         SV_ClientPrint(msg);
58 }
59
60 /*
61 =================
62 SV_BroadcastPrint
63
64 Sends text to all active clients
65 =================
66 */
67 void SV_BroadcastPrint(const char *msg)
68 {
69         int i;
70         client_t *client;
71
72         for (i = 0, client = svs.clients;i < svs.maxclients;i++, client++)
73         {
74                 if (client->active && client->netconnection)
75                 {
76                         MSG_WriteByte(&client->netconnection->message, svc_print);
77                         MSG_WriteString(&client->netconnection->message, msg);
78                 }
79         }
80
81         if (sv_echobprint.integer && cls.state == ca_dedicated)
82                 Con_Print(msg);
83 }
84
85 /*
86 =================
87 SV_BroadcastPrintf
88
89 Sends text to all active clients
90 =================
91 */
92 void SV_BroadcastPrintf(const char *fmt, ...)
93 {
94         va_list argptr;
95         char msg[MAX_INPUTLINE];
96
97         va_start(argptr,fmt);
98         dpvsnprintf(msg,sizeof(msg),fmt,argptr);
99         va_end(argptr);
100
101         SV_BroadcastPrint(msg);
102 }
103
104 /*
105 =================
106 SV_ClientCommands
107
108 Send text over to the client to be executed
109 =================
110 */
111 void SV_ClientCommands(const char *fmt, ...)
112 {
113         va_list argptr;
114         char string[MAX_INPUTLINE];
115
116         if (!host_client->netconnection)
117                 return;
118
119         va_start(argptr,fmt);
120         dpvsnprintf(string, sizeof(string), fmt, argptr);
121         va_end(argptr);
122
123         MSG_WriteByte(&host_client->netconnection->message, svc_stufftext);
124         MSG_WriteString(&host_client->netconnection->message, string);
125 }