| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
#include "cg_local.h" |
| 28 |
#ifdef MISSIONPACK |
| 29 |
#include "../../ui/menudef.h" |
| 30 |
|
| 31 |
typedef struct { |
| 32 |
const char *order; |
| 33 |
int taskNum; |
| 34 |
} orderTask_t; |
| 35 |
|
| 36 |
static const orderTask_t validOrders[] = { |
| 37 |
{ VOICECHAT_GETFLAG, TEAMTASK_OFFENSE }, |
| 38 |
{ VOICECHAT_OFFENSE, TEAMTASK_OFFENSE }, |
| 39 |
{ VOICECHAT_DEFEND, TEAMTASK_DEFENSE }, |
| 40 |
{ VOICECHAT_DEFENDFLAG, TEAMTASK_DEFENSE }, |
| 41 |
{ VOICECHAT_PATROL, TEAMTASK_PATROL }, |
| 42 |
{ VOICECHAT_CAMP, TEAMTASK_CAMP }, |
| 43 |
{ VOICECHAT_FOLLOWME, TEAMTASK_FOLLOW }, |
| 44 |
{ VOICECHAT_RETURNFLAG, TEAMTASK_RETRIEVE }, |
| 45 |
{ VOICECHAT_FOLLOWFLAGCARRIER, TEAMTASK_ESCORT } |
| 46 |
}; |
| 47 |
|
| 48 |
static const int numValidOrders = ARRAY_LEN(validOrders); |
| 49 |
|
| 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 |
|
| 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 |
memset( cg.scores, 0, sizeof( cg.scores ) ); |
| 79 |
for ( i = 0 ; i < cg.numScores ; i++ ) { |
| 80 |
|
| 81 |
cg.scores[i].client = atoi( CG_Argv( i * 14 + 4 ) ); |
| 82 |
cg.scores[i].score = atoi( CG_Argv( i * 14 + 5 ) ); |
| 83 |
cg.scores[i].ping = atoi( CG_Argv( i * 14 + 6 ) ); |
| 84 |
cg.scores[i].time = atoi( CG_Argv( i * 14 + 7 ) ); |
| 85 |
cg.scores[i].scoreFlags = atoi( CG_Argv( i * 14 + 8 ) ); |
| 86 |
powerups = atoi( CG_Argv( i * 14 + 9 ) ); |
| 87 |
cg.scores[i].accuracy = atoi(CG_Argv(i * 14 + 10)); |
| 88 |
cg.scores[i].impressiveCount = atoi(CG_Argv(i * 14 + 11)); |
| 89 |
cg.scores[i].excellentCount = atoi(CG_Argv(i * 14 + 12)); |
| 90 |
cg.scores[i].guantletCount = atoi(CG_Argv(i * 14 + 13)); |
| 91 |
cg.scores[i].defendCount = atoi(CG_Argv(i * 14 + 14)); |
| 92 |
cg.scores[i].assistCount = atoi(CG_Argv(i * 14 + 15)); |
| 93 |
cg.scores[i].perfect = atoi(CG_Argv(i * 14 + 16)); |
| 94 |
cg.scores[i].captures = atoi(CG_Argv(i * 14 + 17)); |
| 95 |
|
| 96 |
if ( cg.scores[i].client < 0 || cg.scores[i].client >= MAX_CLIENTS ) { |
| 97 |
cg.scores[i].client = 0; |
| 98 |
} |
| 99 |
cgs.clientinfo[ cg.scores[i].client ].score = cg.scores[i].score; |
| 100 |
cgs.clientinfo[ cg.scores[i].client ].powerups = powerups; |
| 101 |
|
| 102 |
cg.scores[i].team = cgs.clientinfo[cg.scores[i].client].team; |
| 103 |
} |
| 104 |
#ifdef MISSIONPACK |
| 105 |
CG_SetScoreSelection(NULL); |
| 106 |
#endif |
| 107 |
|
| 108 |
} |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
static void CG_ParseTeamInfo( void ) { |
| 117 |
int i; |
| 118 |
int client; |
| 119 |
|
| 120 |
numSortedTeamPlayers = atoi( CG_Argv( 1 ) ); |
| 121 |
if( numSortedTeamPlayers < 0 || numSortedTeamPlayers > TEAM_MAXOVERLAY ) |
| 122 |
{ |
| 123 |
CG_Error( "CG_ParseTeamInfo: numSortedTeamPlayers out of range (%d)", |
| 124 |
numSortedTeamPlayers ); |
| 125 |
return; |
| 126 |
} |
| 127 |
|
| 128 |
for ( i = 0 ; i < numSortedTeamPlayers ; i++ ) { |
| 129 |
client = atoi( CG_Argv( i * 6 + 2 ) ); |
| 130 |
if( client < 0 || client >= MAX_CLIENTS ) |
| 131 |
{ |
| 132 |
CG_Error( "CG_ParseTeamInfo: bad client number: %d", client ); |
| 133 |
return; |
| 134 |
} |
| 135 |
|
| 136 |
sortedTeamPlayers[i] = client; |
| 137 |
|
| 138 |
cgs.clientinfo[ client ].location = atoi( CG_Argv( i * 6 + 3 ) ); |
| 139 |
cgs.clientinfo[ client ].health = atoi( CG_Argv( i * 6 + 4 ) ); |
| 140 |
cgs.clientinfo[ client ].armor = atoi( CG_Argv( i * 6 + 5 ) ); |
| 141 |
cgs.clientinfo[ client ].curWeapon = atoi( CG_Argv( i * 6 + 6 ) ); |
| 142 |
cgs.clientinfo[ client ].powerups = atoi( CG_Argv( i * 6 + 7 ) ); |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
|
| 155 |
void CG_ParseServerinfo( void ) { |
| 156 |
const char *info; |
| 157 |
char *mapname; |
| 158 |
|
| 159 |
info = CG_ConfigString( CS_SERVERINFO ); |
| 160 |
cgs.gametype = atoi( Info_ValueForKey( info, "g_gametype" ) ); |
| 161 |
trap_Cvar_Set("g_gametype", va("%i", cgs.gametype)); |
| 162 |
cgs.dmflags = atoi( Info_ValueForKey( info, "dmflags" ) ); |
| 163 |
cgs.teamflags = atoi( Info_ValueForKey( info, "teamflags" ) ); |
| 164 |
cgs.fraglimit = atoi( Info_ValueForKey( info, "fraglimit" ) ); |
| 165 |
cgs.capturelimit = atoi( Info_ValueForKey( info, "capturelimit" ) ); |
| 166 |
cgs.timelimit = atoi( Info_ValueForKey( info, "timelimit" ) ); |
| 167 |
cgs.maxclients = atoi( Info_ValueForKey( info, "sv_maxclients" ) ); |
| 168 |
mapname = Info_ValueForKey( info, "mapname" ); |
| 169 |
Com_sprintf( cgs.mapname, sizeof( cgs.mapname ), "maps/%s.bsp", mapname ); |
| 170 |
Q_strncpyz( cgs.redTeam, Info_ValueForKey( info, "g_redTeam" ), sizeof(cgs.redTeam) ); |
| 171 |
trap_Cvar_Set("g_redTeam", cgs.redTeam); |
| 172 |
Q_strncpyz( cgs.blueTeam, Info_ValueForKey( info, "g_blueTeam" ), sizeof(cgs.blueTeam) ); |
| 173 |
trap_Cvar_Set("g_blueTeam", cgs.blueTeam); |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
static void CG_ParseWarmup( void ) { |
| 182 |
const char *info; |
| 183 |
int warmup; |
| 184 |
|
| 185 |
info = CG_ConfigString( CS_WARMUP ); |
| 186 |
|
| 187 |
warmup = atoi( info ); |
| 188 |
cg.warmupCount = -1; |
| 189 |
|
| 190 |
if ( warmup == 0 && cg.warmup ) { |
| 191 |
|
| 192 |
} else if ( warmup > 0 && cg.warmup <= 0 ) { |
| 193 |
#ifdef MISSIONPACK |
| 194 |
if (cgs.gametype >= GT_CTF && cgs.gametype <= GT_HARVESTER) { |
| 195 |
trap_S_StartLocalSound( cgs.media.countPrepareTeamSound, CHAN_ANNOUNCER ); |
| 196 |
} else |
| 197 |
#endif |
| 198 |
{ |
| 199 |
trap_S_StartLocalSound( cgs.media.countPrepareSound, CHAN_ANNOUNCER ); |
| 200 |
} |
| 201 |
} |
| 202 |
|
| 203 |
cg.warmup = warmup; |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
void CG_SetConfigValues( void ) { |
| 214 |
const char *s; |
| 215 |
|
| 216 |
cgs.scores1 = atoi( CG_ConfigString( CS_SCORES1 ) ); |
| 217 |
cgs.scores2 = atoi( CG_ConfigString( CS_SCORES2 ) ); |
| 218 |
cgs.levelStartTime = atoi( CG_ConfigString( CS_LEVEL_START_TIME ) ); |
| 219 |
if( cgs.gametype == GT_CTF ) { |
| 220 |
s = CG_ConfigString( CS_FLAGSTATUS ); |
| 221 |
cgs.redflag = s[0] - '0'; |
| 222 |
cgs.blueflag = s[1] - '0'; |
| 223 |
} |
| 224 |
#ifdef MISSIONPACK |
| 225 |
else if( cgs.gametype == GT_1FCTF ) { |
| 226 |
s = CG_ConfigString( CS_FLAGSTATUS ); |
| 227 |
cgs.flagStatus = s[0] - '0'; |
| 228 |
} |
| 229 |
#endif |
| 230 |
cg.warmup = atoi( CG_ConfigString( CS_WARMUP ) ); |
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
void CG_ShaderStateChanged(void) { |
| 239 |
char originalShader[MAX_QPATH]; |
| 240 |
char newShader[MAX_QPATH]; |
| 241 |
char timeOffset[16]; |
| 242 |
const char *o; |
| 243 |
char *n,*t; |
| 244 |
int length; |
| 245 |
|
| 246 |
o = CG_ConfigString( CS_SHADERSTATE ); |
| 247 |
while (o && *o) { |
| 248 |
n = strstr(o, "="); |
| 249 |
if (n && *n) { |
| 250 |
length = n-o+1; |
| 251 |
if (length > sizeof(originalShader)) { |
| 252 |
length = sizeof(originalShader); |
| 253 |
} |
| 254 |
Q_strncpyz(originalShader, o, length); |
| 255 |
n++; |
| 256 |
t = strstr(n, ":"); |
| 257 |
if (t && *t) { |
| 258 |
length = t-n+1; |
| 259 |
if (length > sizeof(newShader)) { |
| 260 |
length = sizeof(newShader); |
| 261 |
} |
| 262 |
Q_strncpyz(newShader, n, length); |
| 263 |
} else { |
| 264 |
break; |
| 265 |
} |
| 266 |
t++; |
| 267 |
o = strstr(t, "@"); |
| 268 |
if (o) { |
| 269 |
length = o-t+1; |
| 270 |
if (length > sizeof(timeOffset)) { |
| 271 |
length = sizeof(timeOffset); |
| 272 |
} |
| 273 |
Q_strncpyz(timeOffset, t, length); |
| 274 |
o++; |
| 275 |
trap_R_RemapShader( originalShader, newShader, timeOffset ); |
| 276 |
} |
| 277 |
} else { |
| 278 |
break; |
| 279 |
} |
| 280 |
} |
| 281 |
} |
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
static void CG_ConfigStringModified( void ) { |
| 290 |
const char *str; |
| 291 |
int num; |
| 292 |
|
| 293 |
num = atoi( CG_Argv( 1 ) ); |
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
trap_GetGameState( &cgs.gameState ); |
| 298 |
|
| 299 |
|
| 300 |
str = CG_ConfigString( num ); |
| 301 |
|
| 302 |
|
| 303 |
if ( num == CS_MUSIC ) { |
| 304 |
CG_StartMusic(); |
| 305 |
} else if ( num == CS_SERVERINFO ) { |
| 306 |
CG_ParseServerinfo(); |
| 307 |
} else if ( num == CS_WARMUP ) { |
| 308 |
CG_ParseWarmup(); |
| 309 |
} else if ( num == CS_SCORES1 ) { |
| 310 |
cgs.scores1 = atoi( str ); |
| 311 |
} else if ( num == CS_SCORES2 ) { |
| 312 |
cgs.scores2 = atoi( str ); |
| 313 |
} else if ( num == CS_LEVEL_START_TIME ) { |
| 314 |
cgs.levelStartTime = atoi( str ); |
| 315 |
} else if ( num == CS_VOTE_TIME ) { |
| 316 |
cgs.voteTime = atoi( str ); |
| 317 |
cgs.voteModified = qtrue; |
| 318 |
} else if ( num == CS_VOTE_YES ) { |
| 319 |
cgs.voteYes = atoi( str ); |
| 320 |
cgs.voteModified = qtrue; |
| 321 |
} else if ( num == CS_VOTE_NO ) { |
| 322 |
cgs.voteNo = atoi( str ); |
| 323 |
cgs.voteModified = qtrue; |
| 324 |
} else if ( num == CS_VOTE_STRING ) { |
| 325 |
Q_strncpyz( cgs.voteString, str, sizeof( cgs.voteString ) ); |
| 326 |
#ifdef MISSIONPACK |
| 327 |
trap_S_StartLocalSound( cgs.media.voteNow, CHAN_ANNOUNCER ); |
| 328 |
#endif |
| 329 |
} else if ( num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1) { |
| 330 |
cgs.teamVoteTime[num-CS_TEAMVOTE_TIME] = atoi( str ); |
| 331 |
cgs.teamVoteModified[num-CS_TEAMVOTE_TIME] = qtrue; |
| 332 |
} else if ( num >= CS_TEAMVOTE_YES && num <= CS_TEAMVOTE_YES + 1) { |
| 333 |
cgs.teamVoteYes[num-CS_TEAMVOTE_YES] = atoi( str ); |
| 334 |
cgs.teamVoteModified[num-CS_TEAMVOTE_YES] = qtrue; |
| 335 |
} else if ( num >= CS_TEAMVOTE_NO && num <= CS_TEAMVOTE_NO + 1) { |
| 336 |
cgs.teamVoteNo[num-CS_TEAMVOTE_NO] = atoi( str ); |
| 337 |
cgs.teamVoteModified[num-CS_TEAMVOTE_NO] = qtrue; |
| 338 |
} else if ( num >= CS_TEAMVOTE_STRING && num <= CS_TEAMVOTE_STRING + 1) { |
| 339 |
Q_strncpyz( cgs.teamVoteString[num-CS_TEAMVOTE_STRING], str, sizeof( cgs.teamVoteString[0] ) ); |
| 340 |
#ifdef MISSIONPACK |
| 341 |
trap_S_StartLocalSound( cgs.media.voteNow, CHAN_ANNOUNCER ); |
| 342 |
#endif |
| 343 |
} else if ( num == CS_INTERMISSION ) { |
| 344 |
cg.intermissionStarted = atoi( str ); |
| 345 |
} else if ( num >= CS_MODELS && num < CS_MODELS+MAX_MODELS ) { |
| 346 |
cgs.gameModels[ num-CS_MODELS ] = trap_R_RegisterModel( str ); |
| 347 |
} else if ( num >= CS_SOUNDS && num < CS_SOUNDS+MAX_SOUNDS ) { |
| 348 |
if ( str[0] != '*' ) { |
| 349 |
cgs.gameSounds[ num-CS_SOUNDS] = trap_S_RegisterSound( str, qfalse ); |
| 350 |
} |
| 351 |
} else if ( num >= CS_PLAYERS && num < CS_PLAYERS+MAX_CLIENTS ) { |
| 352 |
CG_NewClientInfo( num - CS_PLAYERS ); |
| 353 |
CG_BuildSpectatorString(); |
| 354 |
} else if ( num == CS_FLAGSTATUS ) { |
| 355 |
if( cgs.gametype == GT_CTF ) { |
| 356 |
|
| 357 |
cgs.redflag = str[0] - '0'; |
| 358 |
cgs.blueflag = str[1] - '0'; |
| 359 |
} |
| 360 |
#ifdef MISSIONPACK |
| 361 |
else if( cgs.gametype == GT_1FCTF ) { |
| 362 |
cgs.flagStatus = str[0] - '0'; |
| 363 |
} |
| 364 |
#endif |
| 365 |
} |
| 366 |
else if ( num == CS_SHADERSTATE ) { |
| 367 |
CG_ShaderStateChanged(); |
| 368 |
} |
| 369 |
|
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
static void CG_AddToTeamChat( const char *str ) { |
| 380 |
int len; |
| 381 |
char *p, *ls; |
| 382 |
int lastcolor; |
| 383 |
int chatHeight; |
| 384 |
|
| 385 |
if (cg_teamChatHeight.integer < TEAMCHAT_HEIGHT) { |
| 386 |
chatHeight = cg_teamChatHeight.integer; |
| 387 |
} else { |
| 388 |
chatHeight = TEAMCHAT_HEIGHT; |
| 389 |
} |
| 390 |
|
| 391 |
if (chatHeight <= 0 || cg_teamChatTime.integer <= 0) { |
| 392 |
|
| 393 |
cgs.teamChatPos = cgs.teamLastChatPos = 0; |
| 394 |
return; |
| 395 |
} |
| 396 |
|
| 397 |
len = 0; |
| 398 |
|
| 399 |
p = cgs.teamChatMsgs[cgs.teamChatPos % chatHeight]; |
| 400 |
*p = 0; |
| 401 |
|
| 402 |
lastcolor = '7'; |
| 403 |
|
| 404 |
ls = NULL; |
| 405 |
while (*str) { |
| 406 |
if (len > TEAMCHAT_WIDTH - 1) { |
| 407 |
if (ls) { |
| 408 |
str -= (p - ls); |
| 409 |
str++; |
| 410 |
p -= (p - ls); |
| 411 |
} |
| 412 |
*p = 0; |
| 413 |
|
| 414 |
cgs.teamChatMsgTimes[cgs.teamChatPos % chatHeight] = cg.time; |
| 415 |
|
| 416 |
cgs.teamChatPos++; |
| 417 |
p = cgs.teamChatMsgs[cgs.teamChatPos % chatHeight]; |
| 418 |
*p = 0; |
| 419 |
*p++ = Q_COLOR_ESCAPE; |
| 420 |
*p++ = lastcolor; |
| 421 |
len = 0; |
| 422 |
ls = NULL; |
| 423 |
} |
| 424 |
|
| 425 |
if ( Q_IsColorString( str ) ) { |
| 426 |
*p++ = *str++; |
| 427 |
lastcolor = *str; |
| 428 |
*p++ = *str++; |
| 429 |
continue; |
| 430 |
} |
| 431 |
if (*str == ' ') { |
| 432 |
ls = p; |
| 433 |
} |
| 434 |
*p++ = *str++; |
| 435 |
len++; |
| 436 |
} |
| 437 |
*p = 0; |
| 438 |
|
| 439 |
cgs.teamChatMsgTimes[cgs.teamChatPos % chatHeight] = cg.time; |
| 440 |
cgs.teamChatPos++; |
| 441 |
|
| 442 |
if (cgs.teamChatPos - cgs.teamLastChatPos > chatHeight) |
| 443 |
cgs.teamLastChatPos = cgs.teamChatPos - chatHeight; |
| 444 |
} |
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
static void CG_MapRestart( void ) { |
| 458 |
if ( cg_showmiss.integer ) { |
| 459 |
CG_Printf( "CG_MapRestart\n" ); |
| 460 |
} |
| 461 |
|
| 462 |
CG_InitLocalEntities(); |
| 463 |
CG_InitMarkPolys(); |
| 464 |
CG_ClearParticles (); |
| 465 |
|
| 466 |
|
| 467 |
cg.fraglimitWarnings = 0; |
| 468 |
|
| 469 |
cg.timelimitWarnings = 0; |
| 470 |
cg.rewardTime = 0; |
| 471 |
cg.rewardStack = 0; |
| 472 |
cg.intermissionStarted = qfalse; |
| 473 |
cg.levelShot = qfalse; |
| 474 |
|
| 475 |
cgs.voteTime = 0; |
| 476 |
|
| 477 |
cg.mapRestart = qtrue; |
| 478 |
|
| 479 |
CG_StartMusic(); |
| 480 |
|
| 481 |
trap_S_ClearLoopingSounds(qtrue); |
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
if ( cg.warmup == 0 ) { |
| 487 |
trap_S_StartLocalSound( cgs.media.countFightSound, CHAN_ANNOUNCER ); |
| 488 |
CG_CenterPrint( "FIGHT!", 120, GIANTCHAR_WIDTH*2 ); |
| 489 |
} |
| 490 |
#ifdef MISSIONPACK |
| 491 |
if (cg_singlePlayerActive.integer) { |
| 492 |
trap_Cvar_Set("ui_matchStartTime", va("%i", cg.time)); |
| 493 |
if (cg_recordSPDemo.integer && *cg_recordSPDemoName.string) { |
| 494 |
trap_SendConsoleCommand(va("set g_synchronousclients 1 ; record %s \n", cg_recordSPDemoName.string)); |
| 495 |
} |
| 496 |
} |
| 497 |
#endif |
| 498 |
trap_Cvar_Set("cg_thirdPerson", "0"); |
| 499 |
} |
| 500 |
|
| 501 |
#ifdef MISSIONPACK |
| 502 |
|
| 503 |
#define MAX_VOICEFILESIZE 16384 |
| 504 |
#define MAX_VOICEFILES 8 |
| 505 |
#define MAX_VOICECHATS 64 |
| 506 |
#define MAX_VOICESOUNDS 64 |
| 507 |
#define MAX_CHATSIZE 64 |
| 508 |
#define MAX_HEADMODELS 64 |
| 509 |
|
| 510 |
typedef struct voiceChat_s |
| 511 |
{ |
| 512 |
char id[64]; |
| 513 |
int numSounds; |
| 514 |
sfxHandle_t sounds[MAX_VOICESOUNDS]; |
| 515 |
char chats[MAX_VOICESOUNDS][MAX_CHATSIZE]; |
| 516 |
} voiceChat_t; |
| 517 |
|
| 518 |
typedef struct voiceChatList_s |
| 519 |
{ |
| 520 |
char name[64]; |
| 521 |
int gender; |
| 522 |
int numVoiceChats; |
| 523 |
voiceChat_t voiceChats[MAX_VOICECHATS]; |
| 524 |
} voiceChatList_t; |
| 525 |
|
| 526 |
typedef struct headModelVoiceChat_s |
| 527 |
{ |
| 528 |
char headmodel[64]; |
| 529 |
int voiceChatNum; |
| 530 |
} headModelVoiceChat_t; |
| 531 |
|
| 532 |
voiceChatList_t voiceChatLists[MAX_VOICEFILES]; |
| 533 |
headModelVoiceChat_t headModelVoiceChat[MAX_HEADMODELS]; |
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
int CG_ParseVoiceChats( const char *filename, voiceChatList_t *voiceChatList, int maxVoiceChats ) { |
| 541 |
int len, i; |
| 542 |
fileHandle_t f; |
| 543 |
char buf[MAX_VOICEFILESIZE]; |
| 544 |
char **p, *ptr; |
| 545 |
char *token; |
| 546 |
voiceChat_t *voiceChats; |
| 547 |
qboolean compress; |
| 548 |
sfxHandle_t sound; |
| 549 |
|
| 550 |
compress = qtrue; |
| 551 |
if (cg_buildScript.integer) { |
| 552 |
compress = qfalse; |
| 553 |
} |
| 554 |
|
| 555 |
len = trap_FS_FOpenFile( filename, &f, FS_READ ); |
| 556 |
if ( !f ) { |
| 557 |
trap_Print( va( S_COLOR_RED "voice chat file not found: %s\n", filename ) ); |
| 558 |
return qfalse; |
| 559 |
} |
| 560 |
if ( len >= MAX_VOICEFILESIZE ) { |
| 561 |
trap_Print( va( S_COLOR_RED "voice chat file too large: %s is %i, max allowed is %i\n", filename, len, MAX_VOICEFILESIZE ) ); |
| 562 |
trap_FS_FCloseFile( f ); |
| 563 |
return qfalse; |
| 564 |
} |
| 565 |
|
| 566 |
trap_FS_Read( buf, len, f ); |
| 567 |
buf[len] = 0; |
| 568 |
trap_FS_FCloseFile( f ); |
| 569 |
|
| 570 |
ptr = buf; |
| 571 |
p = &ptr; |
| 572 |
|
| 573 |
Com_sprintf(voiceChatList->name, sizeof(voiceChatList->name), "%s", filename); |
| 574 |
voiceChats = voiceChatList->voiceChats; |
| 575 |
for ( i = 0; i < maxVoiceChats; i++ ) { |
| 576 |
voiceChats[i].id[0] = 0; |
| 577 |
} |
| 578 |
token = COM_ParseExt(p, qtrue); |
| 579 |
if (!token[0]) { |
| 580 |
return qtrue; |
| 581 |
} |
| 582 |
if (!Q_stricmp(token, "female")) { |
| 583 |
voiceChatList->gender = GENDER_FEMALE; |
| 584 |
} |
| 585 |
else if (!Q_stricmp(token, "male")) { |
| 586 |
voiceChatList->gender = GENDER_MALE; |
| 587 |
} |
| 588 |
else if (!Q_stricmp(token, "neuter")) { |
| 589 |
voiceChatList->gender = GENDER_NEUTER; |
| 590 |
} |
| 591 |
else { |
| 592 |
trap_Print( va( S_COLOR_RED "expected gender not found in voice chat file: %s\n", filename ) ); |
| 593 |
return qfalse; |
| 594 |
} |
| 595 |
|
| 596 |
voiceChatList->numVoiceChats = 0; |
| 597 |
while ( 1 ) { |
| 598 |
token = COM_ParseExt(p, qtrue); |
| 599 |
if (!token[0]) { |
| 600 |
return qtrue; |
| 601 |
} |
| 602 |
Com_sprintf(voiceChats[voiceChatList->numVoiceChats].id, sizeof( voiceChats[voiceChatList->numVoiceChats].id ), "%s", token); |
| 603 |
token = COM_ParseExt(p, qtrue); |
| 604 |
if (Q_stricmp(token, "{")) { |
| 605 |
trap_Print( va( S_COLOR_RED "expected { found %s in voice chat file: %s\n", token, filename ) ); |
| 606 |
return qfalse; |
| 607 |
} |
| 608 |
voiceChats[voiceChatList->numVoiceChats].numSounds = 0; |
| 609 |
while(1) { |
| 610 |
token = COM_ParseExt(p, qtrue); |
| 611 |
if (!token[0]) { |
| 612 |
return qtrue; |
| 613 |
} |
| 614 |
if (!Q_stricmp(token, "}")) |
| 615 |
break; |
| 616 |
sound = trap_S_RegisterSound( token, compress ); |
| 617 |
voiceChats[voiceChatList->numVoiceChats].sounds[voiceChats[voiceChatList->numVoiceChats].numSounds] = sound; |
| 618 |
token = COM_ParseExt(p, qtrue); |
| 619 |
if (!token[0]) { |
| 620 |
return qtrue; |
| 621 |
} |
| 622 |
Com_sprintf(voiceChats[voiceChatList->numVoiceChats].chats[ |
| 623 |
voiceChats[voiceChatList->numVoiceChats].numSounds], MAX_CHATSIZE, "%s", token); |
| 624 |
if (sound) |
| 625 |
voiceChats[voiceChatList->numVoiceChats].numSounds++; |
| 626 |
if (voiceChats[voiceChatList->numVoiceChats].numSounds >= MAX_VOICESOUNDS) |
| 627 |
break; |
| 628 |
} |
| 629 |
voiceChatList->numVoiceChats++; |
| 630 |
if (voiceChatList->numVoiceChats >= maxVoiceChats) |
| 631 |
return qtrue; |
| 632 |
} |
| 633 |
return qtrue; |
| 634 |
} |
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
void CG_LoadVoiceChats( void ) { |
| 642 |
int size; |
| 643 |
|
| 644 |
size = trap_MemoryRemaining(); |
| 645 |
CG_ParseVoiceChats( "scripts/female1.voice", &voiceChatLists[0], MAX_VOICECHATS ); |
| 646 |
CG_ParseVoiceChats( "scripts/female2.voice", &voiceChatLists[1], MAX_VOICECHATS ); |
| 647 |
CG_ParseVoiceChats( "scripts/female3.voice", &voiceChatLists[2], MAX_VOICECHATS ); |
| 648 |
CG_ParseVoiceChats( "scripts/male1.voice", &voiceChatLists[3], MAX_VOICECHATS ); |
| 649 |
CG_ParseVoiceChats( "scripts/male2.voice", &voiceChatLists[4], MAX_VOICECHATS ); |
| 650 |
CG_ParseVoiceChats( "scripts/male3.voice", &voiceChatLists[5], MAX_VOICECHATS ); |
| 651 |
CG_ParseVoiceChats( "scripts/male4.voice", &voiceChatLists[6], MAX_VOICECHATS ); |
| 652 |
CG_ParseVoiceChats( "scripts/male5.voice", &voiceChatLists[7], MAX_VOICECHATS ); |
| 653 |
CG_Printf("voice chat memory size = %d\n", size - trap_MemoryRemaining()); |
| 654 |
} |
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
int CG_HeadModelVoiceChats( char *filename ) { |
| 662 |
int len, i; |
| 663 |
fileHandle_t f; |
| 664 |
char buf[MAX_VOICEFILESIZE]; |
| 665 |
char **p, *ptr; |
| 666 |
char *token; |
| 667 |
|
| 668 |
len = trap_FS_FOpenFile( filename, &f, FS_READ ); |
| 669 |
if ( !f ) { |
| 670 |
|
| 671 |
return -1; |
| 672 |
} |
| 673 |
if ( len >= MAX_VOICEFILESIZE ) { |
| 674 |
trap_Print( va( S_COLOR_RED "voice chat file too large: %s is %i, max allowed is %i\n", filename, len, MAX_VOICEFILESIZE ) ); |
| 675 |
trap_FS_FCloseFile( f ); |
| 676 |
return -1; |
| 677 |
} |
| 678 |
|
| 679 |
trap_FS_Read( buf, len, f ); |
| 680 |
buf[len] = 0; |
| 681 |
trap_FS_FCloseFile( f ); |
| 682 |
|
| 683 |
ptr = buf; |
| 684 |
p = &ptr; |
| 685 |
|
| 686 |
token = COM_ParseExt(p, qtrue); |
| 687 |
if ( !token[0] ) { |
| 688 |
return -1; |
| 689 |
} |
| 690 |
|
| 691 |
for ( i = 0; i < MAX_VOICEFILES; i++ ) { |
| 692 |
if ( !Q_stricmp(token, voiceChatLists[i].name) ) { |
| 693 |
return i; |
| 694 |
} |
| 695 |
} |
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
return -1; |
| 700 |
} |
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
int CG_GetVoiceChat( voiceChatList_t *voiceChatList, const char *id, sfxHandle_t *snd, char **chat) { |
| 709 |
int i, rnd; |
| 710 |
|
| 711 |
for ( i = 0; i < voiceChatList->numVoiceChats; i++ ) { |
| 712 |
if ( !Q_stricmp( id, voiceChatList->voiceChats[i].id ) ) { |
| 713 |
rnd = random() * voiceChatList->voiceChats[i].numSounds; |
| 714 |
*snd = voiceChatList->voiceChats[i].sounds[rnd]; |
| 715 |
*chat = voiceChatList->voiceChats[i].chats[rnd]; |
| 716 |
return qtrue; |
| 717 |
} |
| 718 |
} |
| 719 |
return qfalse; |
| 720 |
} |
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
voiceChatList_t *CG_VoiceChatListForClient( int clientNum ) { |
| 728 |
clientInfo_t *ci; |
| 729 |
int voiceChatNum, i, j, k, gender; |
| 730 |
char filename[MAX_QPATH], headModelName[MAX_QPATH]; |
| 731 |
|
| 732 |
if ( clientNum < 0 || clientNum >= MAX_CLIENTS ) { |
| 733 |
clientNum = 0; |
| 734 |
} |
| 735 |
ci = &cgs.clientinfo[ clientNum ]; |
| 736 |
|
| 737 |
for ( k = 0; k < 2; k++ ) { |
| 738 |
if ( k == 0 ) { |
| 739 |
if (ci->headModelName[0] == '*') { |
| 740 |
Com_sprintf( headModelName, sizeof(headModelName), "%s/%s", ci->headModelName+1, ci->headSkinName ); |
| 741 |
} |
| 742 |
else { |
| 743 |
Com_sprintf( headModelName, sizeof(headModelName), "%s/%s", ci->headModelName, ci->headSkinName ); |
| 744 |
} |
| 745 |
} |
| 746 |
else { |
| 747 |
if (ci->headModelName[0] == '*') { |
| 748 |
Com_sprintf( headModelName, sizeof(headModelName), "%s", ci->headModelName+1 ); |
| 749 |
} |
| 750 |
else { |
| 751 |
Com_sprintf( headModelName, sizeof(headModelName), "%s", ci->headModelName ); |
| 752 |
} |
| 753 |
} |
| 754 |
|
| 755 |
for ( i = 0; i < MAX_HEADMODELS; i++ ) { |
| 756 |
if (!Q_stricmp(headModelVoiceChat[i].headmodel, headModelName)) { |
| 757 |
break; |
| 758 |
} |
| 759 |
} |
| 760 |
if (i < MAX_HEADMODELS) { |
| 761 |
return &voiceChatLists[headModelVoiceChat[i].voiceChatNum]; |
| 762 |
} |
| 763 |
|
| 764 |
for ( i = 0; i < MAX_HEADMODELS; i++ ) { |
| 765 |
if (!strlen(headModelVoiceChat[i].headmodel)) { |
| 766 |
Com_sprintf(filename, sizeof(filename), "scripts/%s.vc", headModelName); |
| 767 |
voiceChatNum = CG_HeadModelVoiceChats(filename); |
| 768 |
if (voiceChatNum == -1) |
| 769 |
break; |
| 770 |
Com_sprintf(headModelVoiceChat[i].headmodel, sizeof ( headModelVoiceChat[i].headmodel ), |
| 771 |
"%s", headModelName); |
| 772 |
headModelVoiceChat[i].voiceChatNum = voiceChatNum; |
| 773 |
return &voiceChatLists[headModelVoiceChat[i].voiceChatNum]; |
| 774 |
} |
| 775 |
} |
| 776 |
} |
| 777 |
gender = ci->gender; |
| 778 |
for (k = 0; k < 2; k++) { |
| 779 |
|
| 780 |
for ( i = 0; i < MAX_VOICEFILES; i++ ) { |
| 781 |
if (strlen(voiceChatLists[i].name)) { |
| 782 |
if (voiceChatLists[i].gender == gender) { |
| 783 |
|
| 784 |
for ( j = 0; j < MAX_HEADMODELS; j++ ) { |
| 785 |
if (!strlen(headModelVoiceChat[j].headmodel)) { |
| 786 |
Com_sprintf(headModelVoiceChat[j].headmodel, sizeof ( headModelVoiceChat[j].headmodel ), |
| 787 |
"%s", headModelName); |
| 788 |
headModelVoiceChat[j].voiceChatNum = i; |
| 789 |
break; |
| 790 |
} |
| 791 |
} |
| 792 |
return &voiceChatLists[i]; |
| 793 |
} |
| 794 |
} |
| 795 |
} |
| 796 |
|
| 797 |
if (gender == GENDER_MALE) |
| 798 |
break; |
| 799 |
gender = GENDER_MALE; |
| 800 |
} |
| 801 |
|
| 802 |
for ( j = 0; j < MAX_HEADMODELS; j++ ) { |
| 803 |
if (!strlen(headModelVoiceChat[j].headmodel)) { |
| 804 |
Com_sprintf(headModelVoiceChat[j].headmodel, sizeof ( headModelVoiceChat[j].headmodel ), |
| 805 |
"%s", headModelName); |
| 806 |
headModelVoiceChat[j].voiceChatNum = 0; |
| 807 |
break; |
| 808 |
} |
| 809 |
} |
| 810 |
|
| 811 |
return &voiceChatLists[0]; |
| 812 |
} |
| 813 |
|
| 814 |
#define MAX_VOICECHATBUFFER 32 |
| 815 |
|
| 816 |
typedef struct bufferedVoiceChat_s |
| 817 |
{ |
| 818 |
int clientNum; |
| 819 |
sfxHandle_t snd; |
| 820 |
int voiceOnly; |
| 821 |
char cmd[MAX_SAY_TEXT]; |
| 822 |
char message[MAX_SAY_TEXT]; |
| 823 |
} bufferedVoiceChat_t; |
| 824 |
|
| 825 |
bufferedVoiceChat_t voiceChatBuffer[MAX_VOICECHATBUFFER]; |
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
void CG_PlayVoiceChat( bufferedVoiceChat_t *vchat ) { |
| 833 |
|
| 834 |
if ( cg.intermissionStarted ) { |
| 835 |
return; |
| 836 |
} |
| 837 |
|
| 838 |
if ( !cg_noVoiceChats.integer ) { |
| 839 |
trap_S_StartLocalSound( vchat->snd, CHAN_VOICE); |
| 840 |
if (vchat->clientNum != cg.snap->ps.clientNum) { |
| 841 |
int orderTask = CG_ValidOrder(vchat->cmd); |
| 842 |
if (orderTask > 0) { |
| 843 |
cgs.acceptOrderTime = cg.time + 5000; |
| 844 |
Q_strncpyz(cgs.acceptVoice, vchat->cmd, sizeof(cgs.acceptVoice)); |
| 845 |
cgs.acceptTask = orderTask; |
| 846 |
cgs.acceptLeader = vchat->clientNum; |
| 847 |
} |
| 848 |
|
| 849 |
CG_ShowResponseHead(); |
| 850 |
} |
| 851 |
} |
| 852 |
if (!vchat->voiceOnly && !cg_noVoiceText.integer) { |
| 853 |
CG_AddToTeamChat( vchat->message ); |
| 854 |
CG_Printf( "%s\n", vchat->message ); |
| 855 |
} |
| 856 |
voiceChatBuffer[cg.voiceChatBufferOut].snd = 0; |
| 857 |
} |
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
void CG_PlayBufferedVoiceChats( void ) { |
| 865 |
if ( cg.voiceChatTime < cg.time ) { |
| 866 |
if (cg.voiceChatBufferOut != cg.voiceChatBufferIn && voiceChatBuffer[cg.voiceChatBufferOut].snd) { |
| 867 |
|
| 868 |
CG_PlayVoiceChat(&voiceChatBuffer[cg.voiceChatBufferOut]); |
| 869 |
|
| 870 |
cg.voiceChatBufferOut = (cg.voiceChatBufferOut + 1) % MAX_VOICECHATBUFFER; |
| 871 |
cg.voiceChatTime = cg.time + 1000; |
| 872 |
} |
| 873 |
} |
| 874 |
} |
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
void CG_AddBufferedVoiceChat( bufferedVoiceChat_t *vchat ) { |
| 882 |
|
| 883 |
if ( cg.intermissionStarted ) { |
| 884 |
return; |
| 885 |
} |
| 886 |
|
| 887 |
memcpy(&voiceChatBuffer[cg.voiceChatBufferIn], vchat, sizeof(bufferedVoiceChat_t)); |
| 888 |
cg.voiceChatBufferIn = (cg.voiceChatBufferIn + 1) % MAX_VOICECHATBUFFER; |
| 889 |
if (cg.voiceChatBufferIn == cg.voiceChatBufferOut) { |
| 890 |
CG_PlayVoiceChat( &voiceChatBuffer[cg.voiceChatBufferOut] ); |
| 891 |
cg.voiceChatBufferOut++; |
| 892 |
} |
| 893 |
} |
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
void CG_VoiceChatLocal( int mode, qboolean voiceOnly, int clientNum, int color, const char *cmd ) { |
| 901 |
char *chat; |
| 902 |
voiceChatList_t *voiceChatList; |
| 903 |
clientInfo_t *ci; |
| 904 |
sfxHandle_t snd; |
| 905 |
bufferedVoiceChat_t vchat; |
| 906 |
|
| 907 |
|
| 908 |
if ( cg.intermissionStarted ) { |
| 909 |
return; |
| 910 |
} |
| 911 |
|
| 912 |
if ( mode == SAY_ALL && cgs.gametype >= GT_TEAM && cg_teamChatsOnly.integer ) { |
| 913 |
return; |
| 914 |
} |
| 915 |
|
| 916 |
if ( clientNum < 0 || clientNum >= MAX_CLIENTS ) { |
| 917 |
clientNum = 0; |
| 918 |
} |
| 919 |
ci = &cgs.clientinfo[ clientNum ]; |
| 920 |
|
| 921 |
cgs.currentVoiceClient = clientNum; |
| 922 |
|
| 923 |
voiceChatList = CG_VoiceChatListForClient( clientNum ); |
| 924 |
|
| 925 |
if ( CG_GetVoiceChat( voiceChatList, cmd, &snd, &chat ) ) { |
| 926 |
vchat.clientNum = clientNum; |
| 927 |
vchat.snd = snd; |
| 928 |
vchat.voiceOnly = voiceOnly; |
| 929 |
Q_strncpyz(vchat.cmd, cmd, sizeof(vchat.cmd)); |
| 930 |
if ( mode == SAY_TELL ) { |
| 931 |
Com_sprintf(vchat.message, sizeof(vchat.message), "[%s]: %c%c%s", ci->name, Q_COLOR_ESCAPE, color, chat); |
| 932 |
} |
| 933 |
else if ( mode == SAY_TEAM ) { |
| 934 |
Com_sprintf(vchat.message, sizeof(vchat.message), "(%s): %c%c%s", ci->name, Q_COLOR_ESCAPE, color, chat); |
| 935 |
} |
| 936 |
else { |
| 937 |
Com_sprintf(vchat.message, sizeof(vchat.message), "%s: %c%c%s", ci->name, Q_COLOR_ESCAPE, color, chat); |
| 938 |
} |
| 939 |
CG_AddBufferedVoiceChat(&vchat); |
| 940 |
} |
| 941 |
} |
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
void CG_VoiceChat( int mode ) { |
| 949 |
const char *cmd; |
| 950 |
int clientNum, color; |
| 951 |
qboolean voiceOnly; |
| 952 |
|
| 953 |
voiceOnly = atoi(CG_Argv(1)); |
| 954 |
clientNum = atoi(CG_Argv(2)); |
| 955 |
color = atoi(CG_Argv(3)); |
| 956 |
cmd = CG_Argv(4); |
| 957 |
|
| 958 |
if (cg_noTaunt.integer != 0) { |
| 959 |
if (!strcmp(cmd, VOICECHAT_KILLINSULT) || !strcmp(cmd, VOICECHAT_TAUNT) || \ |
| 960 |
!strcmp(cmd, VOICECHAT_DEATHINSULT) || !strcmp(cmd, VOICECHAT_KILLGAUNTLET) || \ |
| 961 |
!strcmp(cmd, VOICECHAT_PRAISE)) { |
| 962 |
return; |
| 963 |
} |
| 964 |
} |
| 965 |
|
| 966 |
CG_VoiceChatLocal( mode, voiceOnly, clientNum, color, cmd ); |
| 967 |
} |
| 968 |
#endif |
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
static void CG_RemoveChatEscapeChar( char *text ) { |
| 976 |
int i, l; |
| 977 |
|
| 978 |
l = 0; |
| 979 |
for ( i = 0; text[i]; i++ ) { |
| 980 |
if (text[i] == '\x19') |
| 981 |
continue; |
| 982 |
text[l++] = text[i]; |
| 983 |
} |
| 984 |
text[l] = '\0'; |
| 985 |
} |
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
static void CG_ServerCommand( void ) { |
| 996 |
const char *cmd; |
| 997 |
char text[MAX_SAY_TEXT]; |
| 998 |
|
| 999 |
cmd = CG_Argv(0); |
| 1000 |
|
| 1001 |
if ( !cmd[0] ) { |
| 1002 |
|
| 1003 |
return; |
| 1004 |
} |
| 1005 |
|
| 1006 |
if ( !strcmp( cmd, "cp" ) ) { |
| 1007 |
CG_CenterPrint( CG_Argv(1), SCREEN_HEIGHT * 0.30, BIGCHAR_WIDTH ); |
| 1008 |
return; |
| 1009 |
} |
| 1010 |
|
| 1011 |
if ( !strcmp( cmd, "cs" ) ) { |
| 1012 |
CG_ConfigStringModified(); |
| 1013 |
return; |
| 1014 |
} |
| 1015 |
|
| 1016 |
if ( !strcmp( cmd, "print" ) ) { |
| 1017 |
CG_Printf( "%s", CG_Argv(1) ); |
| 1018 |
#ifdef MISSIONPACK |
| 1019 |
cmd = CG_Argv(1); |
| 1020 |
|
| 1021 |
if ( !Q_stricmpn( cmd, "vote failed", 11 ) || !Q_stricmpn( cmd, "team vote failed", 16 )) { |
| 1022 |
trap_S_StartLocalSound( cgs.media.voteFailed, CHAN_ANNOUNCER ); |
| 1023 |
} else if ( !Q_stricmpn( cmd, "vote passed", 11 ) || !Q_stricmpn( cmd, "team vote passed", 16 ) ) { |
| 1024 |
trap_S_StartLocalSound( cgs.media.votePassed, CHAN_ANNOUNCER ); |
| 1025 |
} |
| 1026 |
#endif |
| 1027 |
return; |
| 1028 |
} |
| 1029 |
|
| 1030 |
if ( !strcmp( cmd, "chat" ) ) { |
| 1031 |
if ( cgs.gametype >= GT_TEAM && cg_teamChatsOnly.integer ) { |
| 1032 |
return; |
| 1033 |
} |
| 1034 |
|
| 1035 |
trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND ); |
| 1036 |
Q_strncpyz( text, CG_Argv(1), MAX_SAY_TEXT ); |
| 1037 |
CG_RemoveChatEscapeChar( text ); |
| 1038 |
CG_Printf( "%s\n", text ); |
| 1039 |
return; |
| 1040 |
} |
| 1041 |
|
| 1042 |
if ( !strcmp( cmd, "tchat" ) ) { |
| 1043 |
trap_S_StartLocalSound( cgs.media.talkSound, CHAN_LOCAL_SOUND ); |
| 1044 |
Q_strncpyz( text, CG_Argv(1), MAX_SAY_TEXT ); |
| 1045 |
CG_RemoveChatEscapeChar( text ); |
| 1046 |
CG_AddToTeamChat( text ); |
| 1047 |
CG_Printf( "%s\n", text ); |
| 1048 |
return; |
| 1049 |
} |
| 1050 |
|
| 1051 |
#ifdef MISSIONPACK |
| 1052 |
if ( !strcmp( cmd, "vchat" ) ) { |
| 1053 |
CG_VoiceChat( SAY_ALL ); |
| 1054 |
return; |
| 1055 |
} |
| 1056 |
|
| 1057 |
if ( !strcmp( cmd, "vtchat" ) ) { |
| 1058 |
CG_VoiceChat( SAY_TEAM ); |
| 1059 |
return; |
| 1060 |
} |
| 1061 |
|
| 1062 |
if ( !strcmp( cmd, "vtell" ) ) { |
| 1063 |
CG_VoiceChat( SAY_TELL ); |
| 1064 |
return; |
| 1065 |
} |
| 1066 |
#endif |
| 1067 |
|
| 1068 |
if ( !strcmp( cmd, "scores" ) ) { |
| 1069 |
CG_ParseScores(); |
| 1070 |
return; |
| 1071 |
} |
| 1072 |
|
| 1073 |
if ( !strcmp( cmd, "tinfo" ) ) { |
| 1074 |
CG_ParseTeamInfo(); |
| 1075 |
return; |
| 1076 |
} |
| 1077 |
|
| 1078 |
if ( !strcmp( cmd, "map_restart" ) ) { |
| 1079 |
CG_MapRestart(); |
| 1080 |
return; |
| 1081 |
} |
| 1082 |
|
| 1083 |
if ( Q_stricmp (cmd, "remapShader") == 0 ) |
| 1084 |
{ |
| 1085 |
if (trap_Argc() == 4) |
| 1086 |
{ |
| 1087 |
char shader1[MAX_QPATH]; |
| 1088 |
char shader2[MAX_QPATH]; |
| 1089 |
char shader3[MAX_QPATH]; |
| 1090 |
|
| 1091 |
Q_strncpyz(shader1, CG_Argv(1), sizeof(shader1)); |
| 1092 |
Q_strncpyz(shader2, CG_Argv(2), sizeof(shader2)); |
| 1093 |
Q_strncpyz(shader3, CG_Argv(3), sizeof(shader3)); |
| 1094 |
|
| 1095 |
trap_R_RemapShader(shader1, shader2, shader3); |
| 1096 |
} |
| 1097 |
|
| 1098 |
return; |
| 1099 |
} |
| 1100 |
|
| 1101 |
|
| 1102 |
if ( !strcmp( cmd, "loaddefered" ) ) { |
| 1103 |
CG_LoadDeferredPlayers(); |
| 1104 |
return; |
| 1105 |
} |
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
if ( !strcmp( cmd, "clientLevelShot" ) ) { |
| 1110 |
cg.levelShot = qtrue; |
| 1111 |
return; |
| 1112 |
} |
| 1113 |
|
| 1114 |
CG_Printf( "Unknown client game command: %s\n", cmd ); |
| 1115 |
} |
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
|
| 1126 |
void CG_ExecuteNewServerCommands( int latestSequence ) { |
| 1127 |
while ( cgs.serverCommandSequence < latestSequence ) { |
| 1128 |
if ( trap_GetServerCommand( ++cgs.serverCommandSequence ) ) { |
| 1129 |
CG_ServerCommand(); |
| 1130 |
} |
| 1131 |
} |
| 1132 |
} |