Debian Codegraph @

code/cgame/cg_servercmds.c

raw ◀ ▶
1 Debian patch touch this file
1 /*
2 ===========================================================================
3 Copyright (C) 1999-2005 Id Software, Inc.
4
5 This file is part of Quake III Arena source code.
6
7 Quake III Arena source code is free software; you can redistribute it
8 and/or modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2 of the License,
10 or (at your option) any later version.
11
12 Quake III Arena source code is distributed in the hope that it will be
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Quake III Arena source code; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 ===========================================================================
21 */
22 //
23 // cg_servercmds.c -- reliably sequenced text commands sent by the server
24 // these are processed at snapshot transition time, so there will definately
25 // be a valid snapshot this frame
26
27 #include "cg_local.h"
28 #include "../../ui/menudef.h" // bk001205 - for Q3_ui as well
29
30 typedef struct {
31 const char *order;
32 int taskNum;
33 } orderTask_t;
34
35 static const orderTask_t validOrders[] = {
36 { VOICECHAT_GETFLAG, TEAMTASK_OFFENSE },
37 { VOICECHAT_OFFENSE, TEAMTASK_OFFENSE },
38 { VOICECHAT_DEFEND, TEAMTASK_DEFENSE },
39 { VOICECHAT_DEFENDFLAG, TEAMTASK_DEFENSE },
40 { VOICECHAT_PATROL, TEAMTASK_PATROL },
41 { VOICECHAT_CAMP, TEAMTASK_CAMP },
42 { VOICECHAT_FOLLOWME, TEAMTASK_FOLLOW },
43 { VOICECHAT_RETURNFLAG, TEAMTASK_RETRIEVE },
44 { VOICECHAT_FOLLOWFLAGCARRIER, TEAMTASK_ESCORT }
45 };
46
47 static const int numValidOrders = sizeof(validOrders) / sizeof(orderTask_t);
48
49 #ifdef MISSIONPACK // bk001204
50 static int CG_ValidOrder(const char *p) {
51 int i;
52 for (i = 0; i < numValidOrders; i++) {
53 if (Q_stricmp(p, validOrders[i].order) == 0) {
54 return validOrders[i].taskNum;
55 }
56 }
57 return -1;
58 }
59 #endif
60
61 /*
62 =================
63 CG_ParseScores
64
65 =================
66 */
67 static void CG_ParseScores( void ) {
68 int i, powerups;
69
70 cg.numScores = atoi( CG_Argv( 1 ) );
71 if ( cg.numScores > MAX_CLIENTS ) {
72 cg.numScores = MAX_CLIENTS;
73 }
74
75 cg.teamScores[0] = atoi( CG_Argv( 2 ) );
76 cg.teamScores[1] = atoi( CG_Argv( 3 ) );
77
78 cgs.roundStartTime = atoi( CG_Argv( 4 ) );
79
80 //Update thing in lower-right corner
81 if(cgs.gametype == GT_ELIMINATION || cgs.gametype == GT_CTF_ELIMINATION)
82 {
83 cgs.scores1 = cg.teamScores[0];
84 cgs.scores2 = cg.teamScores[1];
85 }
86
87 memset( cg.scores, 0, sizeof( cg.scores ) );
88
89 #define NUM_DATA 15
90 #define FIRST_DATA 4
91
92 for ( i = 0 ; i < cg.numScores ; i++ ) {
93 //
94 cg.scores[i].client = atoi( CG_Argv( i * NUM_DATA + FIRST_DATA + 1 ) );
95 cg.scores[i].score = atoi( CG_Argv( i * NUM_DATA + FIRST_DATA + 2 ) );
96 cg.scores[i].ping = atoi( CG_Argv( i * NUM_DATA + FIRST_DATA + 3 ) );
97 cg.scores[i].time = atoi( CG_Argv( i * NUM_DATA + FIRST_DATA + 4 ) );
98 cg.scores[i].scoreFlags = atoi( CG_Argv( i * NUM_DATA + FIRST_DATA + 5 ) );
99 powerups = atoi( CG_Argv( i * NUM_DATA + FIRST_DATA + 6 ) );
100 cg.scores[i].accuracy = atoi(CG_Argv(i * NUM_DATA + FIRST_DATA + 7));
101 cg.scores[i].impressiveCount = atoi(CG_Argv(i * NUM_DATA + FIRST_DATA + 8));
102 cg.scores[i].excellentCount = atoi(CG_Argv(i * NUM_DATA + FIRST_DATA + 9));
103 cg.scores[i].guantletCount = atoi(CG_Argv(i * NUM_DATA + FIRST_DATA + 10));
104 cg.scores[i].defendCount = atoi(CG_Argv(i * NUM_DATA + FIRST_DATA + 11));
105 cg.scores[i].assistCount = atoi(CG_Argv(i * NUM_DATA + FIRST_DATA + 12));
106 cg.scores[i].perfect = atoi(CG_Argv(i * NUM_DATA + FIRST_DATA + 13));
107 cg.scores[i].captures = atoi(CG_Argv(i * NUM_DATA + FIRST_DATA + 14));
108 cg.scores[i].isDead = atoi(CG_Argv(i * NUM_DATA + FIRST_DATA + 15));
109 //cgs.roundStartTime =
110
111 if ( cg.scores[i].client < 0 || cg.scores[i].client >= MAX_CLIENTS ) {
112 cg.scores[i].client = 0;
113 }
114 cgs.clientinfo[ cg.scores[i].client ].score = cg.scores[i].score;
115 cgs.clientinfo[ cg.scores[i].client ].powerups = powerups;
116 cgs.clientinfo[ cg.scores[i].client ].isDead = cg.scores[i].isDead;
117
118 cg.scores[i].team = cgs.clientinfo[cg.scores[i].client].team;
119 }
120 #ifdef MISSIONPACK
121 CG_SetScoreSelection(NULL);
122 #endif
123
124 }
125
126 static void CG_ParseAccuracy( void ) {
127 int i;
128
129 for ( i = WP_MACHINEGUN ; i < WP_NUM_WEAPONS ; i++ ) {
130 cg.accuracys[i-WP_MACHINEGUN][0] = atoi( CG_Argv( (i-WP_MACHINEGUN)*2 + 1 ) );
131 cg.accuracys[i-WP_MACHINEGUN][1] = atoi( CG_Argv( (i-WP_MACHINEGUN)*2 + 2 ) );
132 #if DEBUG
133 CG_Printf("W: %i shots: %i Hits: %i\n", i,cg.accuracys[i][0], cg.accuracys[i][1]);
134 #endif
135 }
136
137 }
138
139
140 /*
141 =================
142 CG_ParseElimination
143
144 =================
145 */
146 static void CG_ParseElimination( void ) {
147 if(cgs.gametype == GT_ELIMINATION || cgs.gametype == GT_CTF_ELIMINATION)
148 {
149 cgs.scores1 = atoi( CG_Argv( 1 ) );
150 cgs.scores2 = atoi( CG_Argv( 2 ) );
151 }
152 cgs.roundStartTime = atoi( CG_Argv( 3 ) );
153 }
154
155 /*
156 =================
157 CG_ParseMappage
158 Sago: This parses values from the server rather directly. Some checks are performed, but beware if you change it or new
159 security holes are found
160 =================
161 */
162 static void CG_ParseMappage( void ) {
163 char command[1024];
164 const char *temp;
165 const char* c;
166 int i;
167
168 temp = CG_Argv( 1 );
169 for( c = temp; *c; ++c) {
170 switch(*c) {
171 case '\n':
172 case '\r':
173 case ';':
174 //The server tried something bad!
175 return;
176 break;
177 }
178 }
179 Q_strncpyz(command,va("ui_mappage %s",temp),1024);
180 for(i=2;i<12;i++) {
181 temp = CG_Argv( i );
182 for( c = temp; *c; ++c) {
183 switch(*c) {
184 case '\n':
185 case '\r':
186 case ';':
187 //The server tried something bad!
188 return;
189 break;
190 }
191 }
192 if(strlen(temp)<1)
193 temp = "---";
194 Q_strcat(command,1024,va(" %s ",temp));
195 }
196 trap_SendConsoleCommand(command);
197
198 }
199
200 /*
201 =================
202 CG_ParseDDtimetaken
203
204 =================
205 */
206 static void CG_ParseDDtimetaken( void ) {
207 cgs.timetaken = atoi( CG_Argv( 1 ) );
208 }
209
210 /*
211 =================
212 CG_ParseDomPointNames
213 =================
214 */
215
216 static void CG_ParseDomPointNames( void ) {
217 int i,j;
218 cgs.domination_points_count = atoi( CG_Argv( 1 ) );
219 if(cgs.domination_points_count>=MAX_DOMINATION_POINTS)
220 cgs.domination_points_count = MAX_DOMINATION_POINTS;
221 for(i = 0;i<cgs.domination_points_count;i++) {
222 Q_strncpyz(cgs.domination_points_names[i],CG_Argv(2)+i*MAX_DOMINATION_POINTS_NAMES,MAX_DOMINATION_POINTS_NAMES-1);
223 for(j=MAX_DOMINATION_POINTS_NAMES-1; cgs.domination_points_names[i][j] < '0' && j>0; j--) {
224 cgs.domination_points_names[i][j] = 0;
225 }
226 }
227 }
228
229 /*
230 =================
231 CG_ParseDomScores
232 =================
233 */
234
235 static void CG_ParseDomStatus( void ) {
236 int i;
237 if( cgs.domination_points_count!=atoi( CG_Argv(1) ) ) {
238 cgs.domination_points_count = 0;
239 return;
240 }
241 for(i = 0;i<cgs.domination_points_count;i++) {
242 cgs.domination_points_status[i] = atoi( CG_Argv(2+i) );
243 }
244 }
245
246 /*
247 =================
248 CG_ParseChallenge
249 =================
250 */
251
252 static void CG_ParseChallenge( void ) {
253 addChallenge(atoi( CG_Argv(1) ) );
254 }
255
256 static void CG_ParseObeliskHealth( void ) {
257 cg.redObeliskHealth = atoi( CG_Argv(1) );
258 cg.blueObeliskHealth = atoi( CG_Argv(2) );
259 }
260
261 /**
262 * Sets the respawn counter for the client.
263 */
264 static void CG_ParseRespawnTime( void ) {
265 cg.respawnTime = atoi( CG_Argv(1) );
266 }
267
268 /*
269 =================
270 CG_ParseTeam
271 =================
272 */
273
274 static void CG_ParseTeam( void ) {
275 //TODO: Add code here
276 if(cg_voip_teamonly.integer)
277 trap_Cvar_Set("cl_voipSendTarget",CG_Argv(1));
278 }
279
280 /*
281 =================
282 CG_ParseAttackingTeam
283
284 =================
285 */
286 static void CG_ParseAttackingTeam( void ) {
287 int temp;
288 temp = atoi( CG_Argv( 1 ) );
289 if(temp==TEAM_RED)
290 cgs.attackingTeam = TEAM_RED;
291 else if (temp==TEAM_BLUE)
292 cgs.attackingTeam = TEAM_BLUE;
293 else
294 cgs.attackingTeam = TEAM_NONE; //Should never happen.
295 }
296
297 /*
298 =================
299 CG_ParseTeamInfo
300
301 =================
302 */
303 static void CG_ParseTeamInfo( void ) {
304 int i;
305 int client;
306
307 numSortedTeamPlayers = atoi( CG_Argv( 1 ) );
308 if( numSortedTeamPlayers < 0 || numSortedTeamPlayers > TEAM_MAXOVERLAY )
309 {
310 CG_Error( "CG_ParseTeamInfo: numSortedTeamPlayers out of range (%d)",
311 numSortedTeamPlayers );
312 return;
313 }
314
315 for ( i = 0 ; i < numSortedTeamPlayers ; i++ ) {
316 client = atoi( CG_Argv( i * 6 + 2 ) );
317 if( client < 0 || client >= MAX_CLIENTS )
318 {
319 CG_Error( "CG_ParseTeamInfo: bad client number: %d", client );
320 return;
321 }
322
323
324 sortedTeamPlayers[i] = client;
325
326 cgs.clientinfo[ client ].location = atoi( CG_Argv( i * 6 + 3 ) );
327 cgs.clientinfo[ client ].health = atoi( CG_Argv( i * 6 + 4 ) );
328 cgs.clientinfo[ client ].armor = atoi( CG_Argv( i * 6 + 5 ) );
329 cgs.clientinfo[ client ].curWeapon = atoi( CG_Argv( i * 6 + 6 ) );
330 cgs.clientinfo[ client ].powerups = atoi( CG_Argv( i * 6 + 7 ) );
331 }
332 }
333
334
335 /*
336 ================
337 CG_ParseServerinfo
338
339 This is called explicitly when the gamestate is first received,
340 and whenever the server updates any serverinfo flagged cvars
341 ================
342 */
343 void CG_ParseServerinfo( void ) {
344 const char *info;
345 char *mapname;
346
347 info = CG_ConfigString( CS_SERVERINFO );
348 cgs.gametype = atoi( Info_ValueForKey( info, "g_gametype" ) );
349 //By default do as normal:
350 cgs.ffa_gt = 0;
351 //See if ffa gametype
352 if(cgs.gametype == GT_LMS)
353 cgs.ffa_gt = 1;
354 trap_Cvar_Set("g_gametype", va("%i", cgs.gametype));
355 cgs.dmflags = atoi( Info_ValueForKey( info, "dmflags" ) );
356 cgs.videoflags = atoi( Info_ValueForKey( info, "videoflags" ) );
357 cgs.elimflags = atoi( Info_ValueForKey( info, "elimflags" ) );
358 cgs.teamflags = atoi( Info_ValueForKey( info, "teamflags" ) );
359 cgs.fraglimit = atoi( Info_ValueForKey( info, "fraglimit" ) );
360 cgs.capturelimit = atoi( Info_ValueForKey( info, "capturelimit" ) );
361 cgs.timelimit = atoi( Info_ValueForKey( info, "timelimit" ) );
362 cgs.maxclients = atoi( Info_ValueForKey( info, "sv_maxclients" ) );
363 cgs.roundtime = atoi( Info_ValueForKey( info, "elimination_roundtime" ) );
364 cgs.nopickup = atoi( Info_ValueForKey( info, "g_rockets" ) ) + atoi( Info_ValueForKey( info, "g_instantgib" ) ) + atoi( Info_ValueForKey( info, "g_elimination" ) );
365 cgs.lms_mode = atoi( Info_ValueForKey( info, "g_lms_mode" ) );
366 cgs.altExcellent = atoi( Info_ValueForKey( info, "g_altExcellent" ) );
367 mapname = Info_ValueForKey( info, "mapname" );
368 Com_sprintf( cgs.mapname, sizeof( cgs.mapname ), "maps/%s.bsp", mapname );
369 Q_strncpyz( cgs.redTeam, Info_ValueForKey( info, "g_redTeam" ), sizeof(cgs.redTeam) );
370 trap_Cvar_Set("g_redTeam", cgs.redTeam);
371 Q_strncpyz( cgs.blueTeam, Info_ValueForKey( info, "g_blueTeam" ), sizeof(cgs.blueTeam) );
372 trap_Cvar_Set("g_blueTeam", cgs.blueTeam);
373
374 //unlagged - server options
375 // we'll need this for deciding whether or not to predict weapon effects
376 cgs.delagHitscan = atoi( Info_ValueForKey( info, "g_delagHitscan" ) );
377 trap_Cvar_Set("g_delagHitscan", va("%i", cgs.delagHitscan));
378 //unlagged - server options
379
380 //Copy allowed votes directly to the client:
381 trap_Cvar_Set("cg_voteflags",Info_ValueForKey( info, "voteflags" ) );
382 }
383
384 /*
385 ==================
386 CG_ParseWarmup
387 ==================
388 */
389 static void CG_ParseWarmup( void ) {
390 const char *info;
391 int warmup;
392
393 info = CG_ConfigString( CS_WARMUP );
394
395 warmup = atoi( info );
396 cg.warmupCount = -1;
397
398 if ( warmup == 0 && cg.warmup ) {
399
400 } else if ( warmup > 0 && cg.warmup <= 0 ) {
401 #ifdef MISSIONPACK
402 if (cgs.gametype >= GT_CTF && cgs.gametype < GT_MAX_GAME_TYPE && !cgs.ffa_gt) {
403 trap_S_StartLocalSound( cgs.media.countPrepareTeamSound, CHAN_ANNOUNCER );
404 } else
405 #endif
406 {
407 trap_S_StartLocalSound( cgs.media.countPrepareSound, CHAN_ANNOUNCER );
408 }
409 }
410
411 cg.warmup = warmup;
412 }
413
414 /*
415 ================
416 CG_SetConfigValues
417
418 Called on load to set the initial values from configure strings
419 ================
420 */
421 void CG_SetConfigValues( void ) {
422 const char *s;
423
424 cgs.scores1 = atoi( CG_ConfigString( CS_SCORES1 ) );
425 cgs.scores2 = atoi( CG_ConfigString( CS_SCORES2 ) );
426 cgs.levelStartTime = atoi( CG_ConfigString( CS_LEVEL_START_TIME ) );
427 if( cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_DOUBLE_D) {
428 s = CG_ConfigString( CS_FLAGSTATUS );
429 cgs.redflag = s[0] - '0';
430 cgs.blueflag = s[1] - '0';
431 }
432 //#ifdef MISSIONPACK
433 else if( cgs.gametype == GT_1FCTF ) {
434 s = CG_ConfigString( CS_FLAGSTATUS );
435 cgs.flagStatus = s[0] - '0';
436 }
437 //#endif
438 cg.warmup = atoi( CG_ConfigString( CS_WARMUP ) );
439 }
440
441 /*
442 =====================
443 CG_ShaderStateChanged
444 =====================
445 */
446 void CG_ShaderStateChanged(void) {
447 char originalShader[MAX_QPATH];
448 char newShader[MAX_QPATH];
449 char timeOffset[16];
450 const char *o;
451 char *n,*t;
452
453 o = CG_ConfigString( CS_SHADERSTATE );
454 while (o && *o) {
455 n = strstr(o, "=");
456 if (n && *n) {
•457 Q_strncpyz(originalShader, o, n-o+1);
458 n++;
459 t = strstr(n, ":");
460 if (t && *t) {
•461 Q_strncpyz(newShader, n, t-n+1);
462 } else {
463 break;
464 }
465 t++;
466 o = strstr(t, "@");
467 if (o) {
•468 Q_strncpyz(timeOffset, t, o-t+1);
469 o++;
470 trap_R_RemapShader( originalShader, newShader, timeOffset );
471 }
472 } else {
473 break;
474 }
475 }
476 }
477
478 /*
479 ================
480 CG_ConfigStringModified
481
482 ================
483 */
484 static void CG_ConfigStringModified( void ) {
485 const char *str;
486 int num;
487
488 num = atoi( CG_Argv( 1 ) );
489
490 // get the gamestate from the client system, which will have the
491 // new configstring already integrated
492 trap_GetGameState( &cgs.gameState );
493
494 // look up the individual string that was modified
495 str = CG_ConfigString( num );
496
497 // do something with it if necessary
498 if ( num == CS_MUSIC ) {
499 CG_StartMusic();
500 } else if ( num == CS_SERVERINFO ) {
501 CG_ParseServerinfo();
502 } else if ( num == CS_WARMUP ) {
503 CG_ParseWarmup();
504 } else if ( num == CS_SCORES1 ) {
505 cgs.scores1 = atoi( str );
506 } else if ( num == CS_SCORES2 ) {
507 cgs.scores2 = atoi( str );
508 } else if ( num == CS_LEVEL_START_TIME ) {
509 cgs.levelStartTime = atoi( str );
510 } else if ( num == CS_VOTE_TIME ) {
511 cgs.voteTime = atoi( str );
512 cgs.voteModified = qtrue;
513 } else if ( num == CS_VOTE_YES ) {
514 cgs.voteYes = atoi( str );
515 cgs.voteModified = qtrue;
516 } else if ( num == CS_VOTE_NO ) {
517 cgs.voteNo = atoi( str );
518 cgs.voteModified = qtrue;
519 } else if ( num == CS_VOTE_STRING ) {
520 Q_strncpyz( cgs.voteString, str, sizeof( cgs.voteString ) );
521 #ifdef MISSIONPACK
522 trap_S_StartLocalSound( cgs.media.voteNow, CHAN_ANNOUNCER );
523 #endif //MISSIONPACK
524 } else if ( num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1) {
525 cgs.teamVoteTime[num-CS_TEAMVOTE_TIME] = atoi( str );
526 cgs.teamVoteModified[num-CS_TEAMVOTE_TIME] = qtrue;
527 } else if ( num >= CS_TEAMVOTE_YES && num <= CS_TEAMVOTE_YES + 1) {
528 cgs.teamVoteYes[num-CS_TEAMVOTE_YES] = atoi( str );
529 cgs.teamVoteModified[num-CS_TEAMVOTE_YES] = qtrue;
530 } else if ( num >= CS_TEAMVOTE_NO && num <= CS_TEAMVOTE_NO + 1) {
531 cgs.teamVoteNo[num-CS_TEAMVOTE_NO] = atoi( str );
532 cgs.teamVoteModified[num-CS_TEAMVOTE_NO] = qtrue;
533 } else if ( num >= CS_TEAMVOTE_STRING && num <= CS_TEAMVOTE_STRING + 1) {
534 Q_strncpyz( cgs.teamVoteString[num-CS_TEAMVOTE_STRING], str, sizeof( cgs.teamVoteString ) );
535 #ifdef MISSIONPACK
536 trap_S_StartLocalSound( cgs.media.voteNow, CHAN_ANNOUNCER );
537 #endif
538 } else if ( num == CS_INTERMISSION ) {
539 cg.intermissionStarted = atoi( str );
540 } else if ( num >= CS_MODELS && num < CS_MODELS+MAX_MODELS ) {
541 cgs.gameModels[ num-CS_MODELS ] = trap_R_RegisterModel( str );
542 } else if ( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS ) {
543 if ( str[0] != '*' ) { // player specific sounds don't register here
544 cgs.gameSounds[ num-CS_SOUNDS] = trap_S_RegisterSound( str, qfalse );
545 }
546 } else if ( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS ) {
547 CG_NewClientInfo( num - CS_PLAYERS );
548 CG_BuildSpectatorString();
549 } else if ( num == CS_FLAGSTATUS ) {
550 if( cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_DOUBLE_D) {
551 // format is rb where its red/blue, 0 is at base, 1 is taken, 2 is dropped
552 cgs.redflag = str[0] - '0';
553 cgs.blueflag = str[1] - '0';
554 }
555 //#ifdef MISSIONPACK
556 else if( cgs.gametype == GT_1FCTF ) {
557 cgs.flagStatus = str[0] - '0';
558 }
559 //#endif
560 }
561 else if ( num == CS_SHADERSTATE ) {
562 CG_ShaderStateChanged();
563 }
564
565 }
566
567
568 /*
569 =======================
570 CG_AddToTeamChat
571
572 =======================
573 */
574 static void CG_AddToTeamChat( const char *str ) {
575 int len;
576 char *p, *ls;
577 int lastcolor;
578 int chatHeight;
579
580 if (cg_teamChatHeight.integer < TEAMCHAT_HEIGHT) {
581 chatHeight = cg_teamChatHeight.integer;
582 } else {
583 chatHeight = TEAMCHAT_HEIGHT;
584 }
585
586 if (chatHeight <= 0 || cg_teamChatTime.integer <= 0) {
587 // team chat disabled, dump into normal chat
588 cgs.teamChatPos = cgs.teamLastChatPos = 0;
589 return;
590 }
591
592 len = 0;
593
594 p = cgs.teamChatMsgs[cgs.teamChatPos % chatHeight];
595 *p = 0;
596
597 lastcolor = '7';
598
599 ls = NULL;
600 while (*str) {
601 if (len > TEAMCHAT_WIDTH - 1) {
602 if (ls) {
603 str -= (p - ls);
604 str++;
605 p -= (p - ls);
606 }
607 *p = 0;
608
609 cgs.teamChatMsgTimes[cgs.teamChatPos % chatHeight] = cg.time;
610
611 cgs.teamChatPos++;
612 p = cgs.teamChatMsgs[cgs.teamChatPos % chatHeight];
613 *p = 0;
614 *p++ = Q_COLOR_ESCAPE;
615 *p++ = lastcolor;
616 len = 0;
617 ls = NULL;
618 }
619
620 if ( Q_IsColorString( str ) ) {
621 *p++ = *str++;
622 lastcolor = *str;
623 *p++ = *str++;
624 continue;
625 }
626 if (*str == ' ') {
627 ls = p;
628 }
629 *p++ = *str++;
630 len++;
631 }
632 *p = 0;
633
634 cgs.teamChatMsgTimes[cgs.teamChatPos % chatHeight] = cg.time;
635 cgs.teamChatPos++;
636
637 if (cgs.teamChatPos - cgs.teamLastChatPos > chatHeight)
638 cgs.teamLastChatPos = cgs.teamChatPos - chatHeight;
639 }
640
641 /*
642 ===============
643 CG_MapRestart
644
645 The server has issued a map_restart, so the next snapshot
646 is completely new and should not be interpolated to.
647
648 A tournement restart will clear everything, but doesn't
649 require a reload of all the media
650 ===============
651 */
652 static void CG_MapRestart( void ) {
653 if ( cg_showmiss.integer ) {
654 CG_Printf( "CG_MapRestart\n" );
655 }
656
657 CG_InitLocalEntities();
658 CG_InitMarkPolys();
659 CG_ClearParticles ();
660
661 // make sure the "3 frags left" warnings play again
662 cg.fraglimitWarnings = 0;
663
664 cg.timelimitWarnings = 0;
665
666 cg.intermissionStarted = qfalse;
667
668 cgs.voteTime = 0;
669
670 cg.mapRestart = qtrue;
671
672 CG_StartMusic();
673
674 trap_S_ClearLoopingSounds(qtrue);
675
676 // we really should clear more parts of cg here and stop sounds
677
678 // play the "fight" sound if this is a restart without warmup
679 if ( cg.warmup == 0 /* && cgs.gametype == GT_TOURNAMENT */) {
680 trap_S_StartLocalSound( cgs.media.countFightSound, CHAN_ANNOUNCER );
681 CG_CenterPrint( "FIGHT!", 120, GIANTCHAR_WIDTH*2 );
682 }
683 #ifdef MISSIONPACK
684 if (cg_singlePlayerActive.integer) {
685 trap_Cvar_Set("ui_matchStartTime", va("%i", cg.time));
686 if (cg_recordSPDemo.integer && cg_recordSPDemoName.string && *cg_recordSPDemoName.string) {
687 trap_SendConsoleCommand(va("set g_synchronousclients 1 ; record %s \n", cg_recordSPDemoName.string));
688 }
689 }
690 #endif
691 trap_Cvar_Set("cg_thirdPerson", "0");
692 }
693
694 #define MAX_VOICEFILESIZE 16384
695 #define MAX_VOICEFILES 8
696 #define MAX_VOICECHATS 64
697 #define MAX_VOICESOUNDS 64
698 #define MAX_CHATSIZE 64
699 #define MAX_HEADMODELS 64
700
701 typedef struct voiceChat_s
702 {
703 char id[64];
704 int numSounds;
705 sfxHandle_t sounds[MAX_VOICESOUNDS];
706 char chats[MAX_VOICESOUNDS][MAX_CHATSIZE];
707 } voiceChat_t;
708
709 typedef struct voiceChatList_s
710 {
711 char name[64];
712 int gender;
713 int numVoiceChats;
714 voiceChat_t voiceChats[MAX_VOICECHATS];
715 } voiceChatList_t;
716
717 typedef struct headModelVoiceChat_s
718 {
719 char headmodel[64];
720 int voiceChatNum;
721 } headModelVoiceChat_t;
722
723 voiceChatList_t voiceChatLists[MAX_VOICEFILES];
724 headModelVoiceChat_t headModelVoiceChat[MAX_HEADMODELS];
725
726 /*
727 =================
728 CG_ParseVoiceChats
729 =================
730 */
731 int CG_ParseVoiceChats( const char *filename, voiceChatList_t *voiceChatList, int maxVoiceChats ) {
732 int len, i;
733 fileHandle_t f;
734 char buf[MAX_VOICEFILESIZE];
735 char **p, *ptr;
736 char *token;
737 voiceChat_t *voiceChats;
738 qboolean compress;
739 sfxHandle_t sound;
740
741 compress = qtrue;
742 if (cg_buildScript.integer) {
743 compress = qfalse;
744 }
745
746 len = trap_FS_FOpenFile( filename, &f, FS_READ );
747 if ( !f ) {
748 trap_Print( va( S_COLOR_RED "voice chat file not found: %s\n", filename ) );
749 return qfalse;
750 }
751 if ( len >= MAX_VOICEFILESIZE ) {
752 trap_Print( va( S_COLOR_RED "voice chat file too large: %s is %i, max allowed is %i\n", filename, len, MAX_VOICEFILESIZE ) );
753 trap_FS_FCloseFile( f );
754 return qfalse;
755 }
756
757 trap_FS_Read( buf, len, f );
758 buf[len] = 0;
759 trap_FS_FCloseFile( f );
760
761 ptr = buf;
762 p = &ptr;
763
764 Com_sprintf(voiceChatList->name, sizeof(voiceChatList->name), "%s", filename);
765 voiceChats = voiceChatList->voiceChats;
766 for ( i = 0; i < maxVoiceChats; i++ ) {
767 voiceChats[i].id[0] = 0;
768 }
769 token = COM_ParseExt(p, qtrue);
770 if (!token || token[0] == 0) {
771 return qtrue;
772 }
773 if (!Q_stricmp(token, "female")) {
774 voiceChatList->gender = GENDER_FEMALE;
775 }
776 else if (!Q_stricmp(token, "male")) {
777 voiceChatList->gender = GENDER_MALE;
778 }
779 else if (!Q_stricmp(token, "neuter")) {
780 voiceChatList->gender = GENDER_NEUTER;
781 }
782 else {
783 trap_Print( va( S_COLOR_RED "expected gender not found in voice chat file: %s\n", filename ) );
784 return qfalse;
785 }
786
787 voiceChatList->numVoiceChats = 0;
788 while ( 1 ) {
789 token = COM_ParseExt(p, qtrue);
790 if (!token || token[0] == 0) {
791 return qtrue;
792 }
793 Com_sprintf(voiceChats[voiceChatList->numVoiceChats].id, sizeof( voiceChats[voiceChatList->numVoiceChats].id ), "%s", token);
794 token = COM_ParseExt(p, qtrue);
795 if (Q_stricmp(token, "{")) {
796 trap_Print( va( S_COLOR_RED "expected { found %s in voice chat file: %s\n", token, filename ) );
797 return qfalse;
798 }
799 voiceChats[voiceChatList->numVoiceChats].numSounds = 0;
800 while(1) {
801 token = COM_ParseExt(p, qtrue);
802 if (!token || token[0] == 0) {
803 return qtrue;
804 }
805 if (!Q_stricmp(token, "}"))
806 break;
807 sound = trap_S_RegisterSound( token, compress );
808 voiceChats[voiceChatList->numVoiceChats].sounds[voiceChats[voiceChatList->numVoiceChats].numSounds] = sound;
809 token = COM_ParseExt(p, qtrue);
810 if (!token || token[0] == 0) {
811 return qtrue;
812 }
813 Com_sprintf(voiceChats[voiceChatList->numVoiceChats].chats[
814 voiceChats[voiceChatList->numVoiceChats].numSounds], MAX_CHATSIZE, "%s", token);
815 if (sound)
816 voiceChats[voiceChatList->numVoiceChats].numSounds++;
817 if (voiceChats[voiceChatList->numVoiceChats].numSounds >= MAX_VOICESOUNDS)
818 break;
819 }
820 voiceChatList->numVoiceChats++;
821 if (voiceChatList->numVoiceChats >= maxVoiceChats)
822 return qtrue;
823 }
824 return qtrue;
825 }
826
827 /*
828 =================
829 CG_LoadVoiceChats
830 =================
831 */
832 void CG_LoadVoiceChats( void ) {
833 int size;
834
835 size = trap_MemoryRemaining();
836 CG_ParseVoiceChats( "scripts/female1.voice", &voiceChatLists[0], MAX_VOICECHATS );
837 CG_ParseVoiceChats( "scripts/female2.voice", &voiceChatLists[1], MAX_VOICECHATS );
838 CG_ParseVoiceChats( "scripts/female3.voice", &voiceChatLists[2], MAX_VOICECHATS );
839 CG_ParseVoiceChats( "scripts/male1.voice", &voiceChatLists[3], MAX_VOICECHATS );
840 CG_ParseVoiceChats( "scripts/male2.voice", &voiceChatLists[4], MAX_VOICECHATS );
841 CG_ParseVoiceChats( "scripts/male3.voice", &voiceChatLists[5], MAX_VOICECHATS );
842 CG_ParseVoiceChats( "scripts/male4.voice", &voiceChatLists[6], MAX_VOICECHATS );
843 CG_ParseVoiceChats( "scripts/male5.voice", &voiceChatLists[7], MAX_VOICECHATS );
844 CG_Printf("voice chat memory size = %d\n", size - trap_MemoryRemaining());
845 }
846
847 /*
848 =================
849 CG_HeadModelVoiceChats
850 =================
851 */
852 int CG_HeadModelVoiceChats( char *filename ) {
853 int len, i;
854 fileHandle_t f;
855 char buf[MAX_VOICEFILESIZE];
856 char **p, *ptr;
857 char *token;
858
859 len = trap_FS_FOpenFile( filename, &f, FS_READ );
860 if ( !f ) {
861 //trap_Print( va( "voice chat file not found: %s\n", filename ) );
862 return -1;
863 }
864 if ( len >= MAX_VOICEFILESIZE ) {
865 trap_Print( va( S_COLOR_RED "voice chat file too large: %s is %i, max allowed is %i\n", filename, len, MAX_VOICEFILESIZE ) );
866 trap_FS_FCloseFile( f );
867 return -1;
868 }
869
870 trap_FS_Read( buf, len, f );
871 buf[len] = 0;
872 trap_FS_FCloseFile( f );
873
874 ptr = buf;
875 p = &ptr;
876
877 token = COM_ParseExt(p, qtrue);
878 if (!token || token[0] == 0) {
879 return -1;
880 }
881
882 for ( i = 0; i < MAX_VOICEFILES; i++ ) {
883 if ( !Q_stricmp(token, voiceChatLists[i].name) ) {
884 return i;
885 }
886 }
887
888 //FIXME: maybe try to load the .voice file which name is stored in token?
889
890 return -1;
891 }
892
893
894 /*
895 =================
896 CG_GetVoiceChat
897 =================
898 */
899 int CG_GetVoiceChat( voiceChatList_t *voiceChatList, const char *id, sfxHandle_t *snd, char **chat) {
900 int i, rnd;
901
902 for ( i = 0; i < voiceChatList->numVoiceChats; i++ ) {
903 if ( !Q_stricmp( id, voiceChatList->voiceChats[i].id ) ) {
904 rnd = random() * voiceChatList->voiceChats[i].numSounds;
905 *snd = voiceChatList->voiceChats[i].sounds[rnd];
906 *chat = voiceChatList->voiceChats[i].chats[rnd];
907 return qtrue;
908 }
909 }
910 return qfalse;
911 }
912
913 /*
914 =================
915 CG_VoiceChatListForClient
916 =================
917 */
918 voiceChatList_t *CG_VoiceChatListForClient( int clientNum ) {
919 clientInfo_t *ci;
920 int voiceChatNum, i, j, k, gender;
921 char filename[MAX_QPATH], headModelName[MAX_QPATH];
922
923 if ( clientNum < 0 || clientNum >= MAX_CLIENTS ) {
924 clientNum = 0;
925 }
926 ci = &cgs.clientinfo[ clientNum ];
927
928 for ( k = 0; k < 2; k++ ) {
929 if ( k == 0 ) {
930 if (ci->headModelName[0] == '*') {
931 Com_sprintf( headModelName, sizeof(headModelName), "%s/%s", ci->headModelName+1, ci->headSkinName );
932 }
933 else {
934 Com_sprintf( headModelName, sizeof(headModelName), "%s/%s", ci->headModelName, ci->headSkinName );
935 }
936 }
937 else {
938 if (ci->headModelName[0] == '*') {
939 Com_sprintf( headModelName, sizeof(headModelName), "%s", ci->headModelName+1 );
940 }
941 else {
942 Com_sprintf( headModelName, sizeof(headModelName), "%s", ci->headModelName );
943 }
944 }
945 // find the voice file for the head model the client uses
946 for ( i = 0; i < MAX_HEADMODELS; i++ ) {
947 if (!Q_stricmp(headModelVoiceChat[i].headmodel, headModelName)) {
948 break;
949 }
950 }
951 if (i < MAX_HEADMODELS) {
952 return &voiceChatLists[headModelVoiceChat[i].voiceChatNum];
953 }
954 // find a <headmodelname>.vc file
955 for ( i = 0; i < MAX_HEADMODELS; i++ ) {
956 if (!strlen(headModelVoiceChat[i].headmodel)) {
957 Com_sprintf(filename, sizeof(filename), "scripts/%s.vc", headModelName);
958 voiceChatNum = CG_HeadModelVoiceChats(filename);
959 if (voiceChatNum == -1)
960 break;
961 Com_sprintf(headModelVoiceChat[i].headmodel, sizeof ( headModelVoiceChat[i].headmodel ),
962 "%s", headModelName);
963 headModelVoiceChat[i].voiceChatNum = voiceChatNum;
964 return &voiceChatLists[headModelVoiceChat[i].voiceChatNum];
965 }
966 }
967 }
968 gender = ci->gender;
969 for (k = 0; k < 2; k++) {
970 // just pick the first with the right gender
971 for ( i = 0; i < MAX_VOICEFILES; i++ ) {
972 if (strlen(voiceChatLists[i].name)) {
973 if (voiceChatLists[i].gender == gender) {
974 // store this head model with voice chat for future reference
975 for ( j = 0; j < MAX_HEADMODELS; j++ ) {
976 if (!strlen(headModelVoiceChat[j].headmodel)) {
977 Com_sprintf(headModelVoiceChat[j].headmodel, sizeof ( headModelVoiceChat[j].headmodel ),
978 "%s", headModelName);
979 headModelVoiceChat[j].voiceChatNum = i;
980 break;
981 }
982 }
983 return &voiceChatLists[i];
984 }
985 }
986 }
987 // fall back to male gender because we don't have neuter in the mission pack
988 if (gender == GENDER_MALE)
989 break;
990 gender = GENDER_MALE;
991 }
992 // store this head model with voice chat for future reference
993 for ( j = 0; j < MAX_HEADMODELS; j++ ) {
994 if (!strlen(headModelVoiceChat[j].headmodel)) {
995 Com_sprintf(headModelVoiceChat[j].headmodel, sizeof ( headModelVoiceChat[j].headmodel ),
996 "%s", headModelName);
997 headModelVoiceChat[j].voiceChatNum = 0;
998 break;
999 }
1000 }
1001 // just return the first voice chat list
1002 return &voiceChatLists[0];
1003 }
1004
1005 #define MAX_VOICECHATBUFFER 32
1006
1007 typedef struct bufferedVoiceChat_s
1008 {
1009 int clientNum;
1010 sfxHandle_t snd;
1011 int voiceOnly;
1012 char cmd[MAX_SAY_TEXT];
1013 char message[MAX_SAY_TEXT];
1014 } bufferedVoiceChat_t;
1015
1016 bufferedVoiceChat_t voiceChatBuffer[MAX_VOICECHATBUFFER];
1017
1018 /*
1019 =================
1020 CG_PlayVoiceChat
1021 =================
1022 */
1023 void CG_PlayVoiceChat( bufferedVoiceChat_t *vchat ) {
1024 #ifdef MISSIONPACK
1025 // if we are going into the intermission, don't start any voices
1026 if ( cg.intermissionStarted ) {
1027 return;
1028 }
1029
1030 if ( !cg_noVoiceChats.integer ) {
1031 trap_S_StartLocalSound( vchat->snd, CHAN_VOICE);
1032 if (vchat->clientNum != cg.snap->ps.clientNum) {
1033 int orderTask = CG_ValidOrder(vchat->cmd);
1034 if (orderTask > 0) {
1035 cgs.acceptOrderTime = cg.time + 5000;
1036 Q_strncpyz(cgs.acceptVoice, vchat->cmd, sizeof(cgs.acceptVoice));
1037 cgs.acceptTask = orderTask;
1038 cgs.acceptLeader = vchat->clientNum;
1039 }
1040 // see if this was an order
1041 CG_ShowResponseHead();
1042 }
1043 }
1044 if (!vchat->voiceOnly && !cg_noVoiceText.integer) {
1045 CG_AddToTeamChat( vchat->message );
1046 CG_Printf( "%s\n", vchat->message );
1047 }
1048 voiceChatBuffer[cg.voiceChatBufferOut].snd = 0;
1049 #endif
1050 }
1051
1052 /*
1053 =====================
1054 CG_PlayBufferedVoieChats
1055 =====================
1056 */
1057 void CG_PlayBufferedVoiceChats( void ) {
1058 #ifdef MISSIONPACK
1059 if ( cg.voiceChatTime < cg.time ) {
1060 if (cg.voiceChatBufferOut != cg.voiceChatBufferIn && voiceChatBuffer[cg.voiceChatBufferOut].snd) {
1061 //
1062 CG_PlayVoiceChat(&voiceChatBuffer[cg.voiceChatBufferOut]);
1063 //
1064 cg.voiceChatBufferOut = (cg.voiceChatBufferOut + 1) % MAX_VOICECHATBUFFER;
1065 cg.voiceChatTime = cg.time + 1000;
1066 }
1067 }
1068 #endif
1069 }
1070
1071 /*
1072 =====================
1073 CG_AddBufferedVoiceChat
1074 =====================
1075 */
1076 void CG_AddBufferedVoiceChat( bufferedVoiceChat_t *vchat ) {
1077 #ifdef MISSIONPACK
1078 // if we are going into the intermission, don't start any voices
1079 if ( cg.intermissionStarted ) {
1080 return;
1081 }
1082
1083 memcpy(&voiceChatBuffer[cg.voiceChatBufferIn], vchat, sizeof(bufferedVoiceChat_t));
1084 cg.voiceChatBufferIn = (cg.voiceChatBufferIn + 1) % MAX_VOICECHATBUFFER;
1085 if (cg.voiceChatBufferIn == cg.voiceChatBufferOut) {
1086 CG_PlayVoiceChat( &voiceChatBuffer[cg.voiceChatBufferOut] );
1087 cg.voiceChatBufferOut++;
1088 }
1089 #endif
1090 }
1091
1092 /*
1093 =================
1094 CG_VoiceChatLocal
1095 =================
1096 */
1097 void CG_VoiceChatLocal( int mode, qboolean voiceOnly, int clientNum, int color, const char *cmd ) {
1098 #ifdef MISSIONPACK
1099 char *chat;
1100 voiceChatList_t *voiceChatList;
1101 clientInfo_t *ci;
1102 sfxHandle_t snd;
1103 bufferedVoiceChat_t vchat;
1104
1105 // if we are going into the intermission, don't start any voices
1106 if ( cg.intermissionStarted ) {
1107 return;
1108 }
1109
1110 if ( clientNum < 0 || clientNum >= MAX_CLIENTS ) {
1111 clientNum = 0;
1112 }
1113 ci = &cgs.clientinfo[ clientNum ];
1114
1115 cgs.currentVoiceClient = clientNum;
1116
1117 voiceChatList = CG_VoiceChatListForClient( clientNum );
1118
1119 if ( CG_GetVoiceChat( voiceChatList, cmd, &snd, &chat ) ) {
1120 //
1121 if ( mode == SAY_TEAM || !cg_teamChatsOnly.integer ) {
1122 vchat.clientNum = clientNum;
1123 vchat.snd = snd;
1124 vchat.voiceOnly = voiceOnly;
1125 Q_strncpyz(vchat.cmd, cmd, sizeof(vchat.cmd));
1126 if ( mode == SAY_TELL ) {
1127 Com_sprintf(vchat.message, sizeof(vchat.message), "[%s]: %c%c%s", ci->name, Q_COLOR_ESCAPE, color, chat);
1128 }
1129 else if ( mode == SAY_TEAM ) {
1130 Com_sprintf(vchat.message, sizeof(vchat.message), "(%s): %c%c%s", ci->name, Q_COLOR_ESCAPE, color, chat);
1131 }
1132 else {
1133 Com_sprintf(vchat.message, sizeof(vchat.message), "%s: %c%c%s", ci->name, Q_COLOR_ESCAPE, color, chat);
1134 }
1135 CG_AddBufferedVoiceChat(&vchat);
1136 }
1137 }
1138 #endif
1139 }
1140
1141 /*
1142 =================
1143 CG_VoiceChat
1144 =================
1145 */
1146 void CG_VoiceChat( int mode ) {
1147 #ifdef MISSIONPACK
1148 const char *cmd;
1149 int clientNum, color;
1150 qboolean voiceOnly;
1151
1152 voiceOnly = atoi(CG_Argv(1));
1153 clientNum = atoi(CG_Argv(2));
1154 color = atoi(CG_Argv(3));
1155 cmd = CG_Argv(4);
1156
1157 if (cg_noTaunt.integer != 0) {
1158 if (!strcmp(cmd, VOICECHAT_KILLINSULT) || !strcmp(cmd, VOICECHAT_TAUNT) || \
1159 !strcmp(cmd, VOICECHAT_DEATHINSULT) || !strcmp(cmd, VOICECHAT_KILLGAUNTLET) || \
1160 !strcmp(cmd, VOICECHAT_PRAISE)) {
1161 return;
1162 }
1163 }
1164
1165 CG_VoiceChatLocal( mode, voiceOnly, clientNum, color, cmd );
1166 #endif
1167 }
1168
1169 /*
1170 =================
1171 CG_RemoveChatEscapeChar
1172 =================
1173 */
1174 static void CG_RemoveChatEscapeChar( char *text ) {
1175 int i, l;
1176
1177 l = 0;
1178 for ( i = 0; text[i]; i++ ) {
1179 if (text[i] == '\x19')
1180 continue;
1181 text[l++] = text[i];
1182 }
1183 text[l] = '\0';
1184 }
1185
1186 /*
1187 =================
1188 CG_ServerCommand
1189
1190 The string has been tokenized and can be retrieved with
1191 Cmd_Argc() / Cmd_Argv()
1192 =================
1193 */
1194 static void CG_ServerCommand( void ) {
1195 const char *cmd;
1196 char text[MAX_SAY_TEXT];
1197
1198 cmd = CG_Argv(0);
1199
1200 if ( !cmd[0] ) {
1201 // server claimed the command
1202 return;
1203 }
1204
1205 if ( !strcmp( cmd, "cp" ) ) {
1206 CG_CenterPrint( CG_Argv(1), SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH );
1207 return;
1208 }
1209
1210 if ( !strcmp( cmd, "cs" ) ) {
1211 CG_ConfigStringModified();
1212 return;
1213 }
1214
1215 if ( !strcmp( cmd, "print" ) ) {
1216 CG_Printf( "%s", CG_Argv(1) );
1217 #ifdef MISSIONPACK
1218 cmd = CG_Argv(1); // yes, this is obviously a hack, but so is the way we hear about
1219 // votes passing or failing
1220 if ( !Q_stricmpn( cmd, "vote failed", 11 ) || !Q_stricmpn( cmd, "team vote failed", 16 )) {
1221 trap_S_StartLocalSound( cgs.media.voteFailed, CHAN_ANNOUNCER );
1222 } else if ( !Q_stricmpn( cmd, "vote passed", 11 ) || !Q_stricmpn( cmd, "team vote passed", 16 ) ) {
1223 trap_S_StartLocalSound( cgs.media.votePassed, CHAN_ANNOUNCER );
1224 }
1225 #endif
1226 return;
1227 }
1228
1229 if ( !strcmp( cmd, "chat" ) ) {
1230 if ( !cg_teamChatsOnly.integer ) {
1231 if( cg_chatBeep.integer )
1232 trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
1233 Q_strncpyz( text, CG_Argv(1), MAX_SAY_TEXT );
1234 CG_RemoveChatEscapeChar( text );
1235 CG_Printf( "%s\n", text );
1236 }
1237 return;
1238 }
1239
1240 if ( !strcmp( cmd, "tchat" ) ) {
1241 if( cg_teamChatBeep.integer )
1242 trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND );
1243 Q_strncpyz( text, CG_Argv(1), MAX_SAY_TEXT );
1244 CG_RemoveChatEscapeChar( text );
1245 CG_AddToTeamChat( text );
1246 CG_Printf( "%s\n", text );
1247 return;
1248 }
1249 if ( !strcmp( cmd, "vchat" ) ) {
1250 CG_VoiceChat( SAY_ALL );
1251 return;
1252 }
1253
1254 if ( !strcmp( cmd, "vtchat" ) ) {
1255 CG_VoiceChat( SAY_TEAM );
1256 return;
1257 }
1258
1259 if ( !strcmp( cmd, "vtell" ) ) {
1260 CG_VoiceChat( SAY_TELL );
1261 return;
1262 }
1263
1264 if ( !strcmp( cmd, "scores" ) ) {
1265 CG_ParseScores();
1266 return;
1267 }
1268
1269
1270 if ( !strcmp( cmd, "accs" ) ) {
1271 CG_ParseAccuracy();
1272 return;
1273 }
1274
1275
1276 if ( !strcmp( cmd, "ddtaken" ) ) {
1277 CG_ParseDDtimetaken();
1278 return;
1279 }
1280
1281 if ( !strcmp( cmd, "dompointnames" ) ) {
1282 CG_ParseDomPointNames();
1283 return;
1284 }
1285
1286 if ( !strcmp( cmd, "domStatus" ) ) {
1287 CG_ParseDomStatus();
1288 return;
1289 }
1290
1291 if ( !strcmp( cmd, "elimination" ) ) {
1292 CG_ParseElimination();
1293 return;
1294 }
1295
1296 if ( !strcmp( cmd, "mappage" ) ) {
1297 CG_ParseMappage();
1298 return;
1299 }
1300
1301 if ( !strcmp( cmd, "attackingteam" ) ) {
1302 CG_ParseAttackingTeam();
1303 return;
1304 }
1305
1306 if ( !strcmp( cmd, "tinfo" ) ) {
1307 CG_ParseTeamInfo();
1308 return;
1309 }
1310
1311 if ( !strcmp( cmd, "map_restart" ) ) {
1312 CG_MapRestart();
1313 return;
1314 }
1315
1316 if ( Q_stricmp (cmd, "remapShader") == 0 )
1317 {
1318 if (trap_Argc() == 4)
1319 {
1320 char shader1[MAX_QPATH];
1321 char shader2[MAX_QPATH];
1322 char shader3[MAX_QPATH];
1323
1324 Q_strncpyz(shader1, CG_Argv(1), sizeof(shader1));
1325 Q_strncpyz(shader2, CG_Argv(2), sizeof(shader2));
1326 Q_strncpyz(shader3, CG_Argv(3), sizeof(shader3));
1327
1328 trap_R_RemapShader(shader1, shader2, shader3);
1329 }
1330
1331 return;
1332 }
1333
1334 // loaddeferred can be both a servercmd and a consolecmd
1335 if ( !strcmp( cmd, "loaddefered" ) ) { // FIXME: spelled wrong, but not changing for demo
1336 CG_LoadDeferredPlayers();
1337 return;
1338 }
1339
1340 // clientLevelShot is sent before taking a special screenshot for
1341 // the menu system during development
1342 if ( !strcmp( cmd, "clientLevelShot" ) ) {
1343 cg.levelShot = qtrue;
1344 return;
1345 }
1346
1347 // challenge completed is determened by the server. A client should consider this message valid:
1348 if ( !strcmp( cmd, "ch" ) ) {
1349 CG_ParseChallenge();
1350 return;
1351 }
1352
1353 if ( !strcmp (cmd, "oh") ) {
1354 CG_ParseObeliskHealth();
1355 return;
1356 }
1357
1358 if ( !strcmp( cmd, "respawn" ) ) {
1359 CG_ParseRespawnTime();
1360 return;
1361 }
1362
1363 if ( !strcmp( cmd, "team" ) ) {
1364 CG_ParseTeam();
1365 return;
1366 }
1367
1368 if ( !strcmp( cmd, "customvotes" ) ) {
1369 char infoString[1024];
1370 int i;
1371 //TODO: Create a ParseCustomvotes function
1372 memset(&infoString,0,sizeof(infoString));
1373 for(i=1;i<=12;i++) {
1374 Q_strcat(infoString,sizeof(infoString),CG_Argv( i ));
1375 Q_strcat(infoString,sizeof(infoString)," ");
1376 }
1377 trap_Cvar_Set("cg_vote_custom_commands",infoString);
1378 return;
1379 }
1380
1381 CG_Printf( "Unknown client game command: %s\n", cmd );
1382 }
1383
1384
1385 /*
1386 ====================
1387 CG_ExecuteNewServerCommands
1388
1389 Execute all of the server commands that were received along
1390 with this this snapshot.
1391 ====================
1392 */
1393 void CG_ExecuteNewServerCommands( int latestSequence ) {
1394 while ( cgs.serverCommandSequence < latestSequence ) {
1395 if ( trap_GetServerCommand( ++cgs.serverCommandSequence ) ) {
1396 CG_ServerCommand();
1397 }
1398 }
1399 }