2011-02-18 14:31:32 +00:00
|
|
|
/*
|
|
|
|
===========================================================================
|
|
|
|
Copyright (C) 1999-2005 Id Software, Inc.
|
2021-03-24 20:13:01 +00:00
|
|
|
Copyright (C) 2002-2021 Q3Rally Team (Per Thormann - q3rally@gmail.com)
|
2011-02-18 14:31:32 +00:00
|
|
|
|
|
|
|
This file is part of q3rally source code.
|
|
|
|
|
|
|
|
q3rally source code is free software; you can redistribute it
|
|
|
|
and/or modify it under the terms of the GNU General Public License as
|
|
|
|
published by the Free Software Foundation; either version 2 of the License,
|
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
q3rally source code is distributed in the hope that it will be
|
|
|
|
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with q3rally; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
===========================================================================
|
|
|
|
*/
|
|
|
|
//
|
|
|
|
#include "g_local.h"
|
|
|
|
|
2012-09-15 03:03:44 +00:00
|
|
|
#ifdef MISSIONPACK
|
2011-02-18 14:31:32 +00:00
|
|
|
#include "../../ui/menudef.h" // for the voice chats
|
2012-09-15 03:03:44 +00:00
|
|
|
#endif
|
2011-02-18 14:31:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
DeathmatchScoreboardMessage
|
|
|
|
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void DeathmatchScoreboardMessage( gentity_t *ent ) {
|
|
|
|
char entry[1024];
|
2017-07-10 01:33:41 +00:00
|
|
|
char string[1000];
|
2011-02-18 14:31:32 +00:00
|
|
|
int stringlength;
|
|
|
|
int i, j;
|
|
|
|
gclient_t *cl;
|
|
|
|
int numSorted, scoreFlags, accuracy, perfect;
|
|
|
|
|
2017-07-10 01:33:41 +00:00
|
|
|
// don't send scores to bots, they don't parse it
|
|
|
|
if ( ent->r.svFlags & SVF_BOT ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
// send the latest information on all clients
|
|
|
|
string[0] = 0;
|
|
|
|
stringlength = 0;
|
|
|
|
scoreFlags = 0;
|
|
|
|
|
|
|
|
numSorted = level.numConnectedClients;
|
|
|
|
|
|
|
|
for (i=0 ; i < numSorted ; i++) {
|
|
|
|
int ping;
|
|
|
|
// STONELANCE
|
|
|
|
int time;
|
|
|
|
// END
|
|
|
|
|
|
|
|
cl = &level.clients[level.sortedClients[i]];
|
|
|
|
|
|
|
|
// STONELANCE
|
|
|
|
/*
|
|
|
|
if (cl->sess.sessionTeam == TEAM_SPECTATOR
|
|
|
|
&& !cl->finishRaceTime)
|
|
|
|
time = cl->sess.spectatorTime;
|
|
|
|
else
|
|
|
|
time = level.startRaceTime;
|
|
|
|
*/
|
2023-12-17 19:45:22 +00:00
|
|
|
if ( isRallyRace() || g_gametype.integer == GT_DERBY || g_gametype.integer == GT_LCS )
|
2011-02-18 14:31:32 +00:00
|
|
|
time = level.startRaceTime;
|
|
|
|
else
|
|
|
|
time = cl->switchTeamTime;
|
|
|
|
// END
|
|
|
|
|
|
|
|
if ( cl->pers.connected == CON_CONNECTING ) {
|
|
|
|
ping = -1;
|
|
|
|
} else {
|
|
|
|
ping = cl->ps.ping < 999 ? cl->ps.ping : 999;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( cl->accuracy_shots ) {
|
|
|
|
accuracy = cl->accuracy_hits * 100 / cl->accuracy_shots;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
accuracy = 0;
|
|
|
|
}
|
|
|
|
perfect = ( cl->ps.persistant[PERS_RANK] == 0 && cl->ps.persistant[PERS_KILLED] == 0 ) ? 1 : 0;
|
|
|
|
|
|
|
|
Com_sprintf (entry, sizeof(entry),
|
|
|
|
// STONELANCE
|
|
|
|
// " %i %i %i %i %i %i %i %i %i %i %i %i %i %i", level.sortedClients[i],
|
|
|
|
" %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i %i", level.sortedClients[i],
|
|
|
|
// cl->ps.persistant[PERS_SCORE], ping, (level.time - cl->pers.enterTime)/60000,
|
|
|
|
cl->ps.persistant[PERS_SCORE], ping, time,
|
|
|
|
// END
|
|
|
|
scoreFlags, g_entities[level.sortedClients[i]].s.powerups, accuracy,
|
|
|
|
cl->ps.persistant[PERS_IMPRESSIVE_COUNT],
|
2022-02-05 20:49:34 +00:00
|
|
|
cl->ps.persistant[PERS_IMPRESSIVETELEFRAG_COUNT],
|
2011-02-18 14:31:32 +00:00
|
|
|
cl->ps.persistant[PERS_EXCELLENT_COUNT],
|
|
|
|
cl->ps.persistant[PERS_GAUNTLET_FRAG_COUNT],
|
|
|
|
cl->ps.persistant[PERS_DEFEND_COUNT],
|
|
|
|
cl->ps.persistant[PERS_ASSIST_COUNT],
|
|
|
|
perfect,
|
|
|
|
// STONELANCE
|
|
|
|
// cl->ps.persistant[PERS_CAPTURES]);
|
|
|
|
cl->ps.persistant[PERS_CAPTURES],
|
|
|
|
cl->ps.stats[STAT_DAMAGE_DEALT],
|
|
|
|
cl->ps.stats[STAT_DAMAGE_TAKEN],
|
|
|
|
cl->ps.stats[STAT_POSITION]
|
|
|
|
);
|
|
|
|
// END
|
|
|
|
|
|
|
|
j = strlen(entry);
|
2011-07-26 08:52:24 +00:00
|
|
|
if (stringlength + j >= sizeof(string))
|
2011-02-18 14:31:32 +00:00
|
|
|
break;
|
|
|
|
strcpy (string + stringlength, entry);
|
|
|
|
stringlength += j;
|
|
|
|
}
|
|
|
|
|
|
|
|
// STONELANCE
|
|
|
|
// trap_SendServerCommand( ent-g_entities, va("scores %i %i %i%s", i,
|
|
|
|
// level.teamScores[TEAM_RED], level.teamScores[TEAM_BLUE],
|
|
|
|
// string ) );
|
|
|
|
trap_SendServerCommand( ent-g_entities, va("scores %i %i %i %i %i%s", i,
|
|
|
|
level.teamScores[TEAM_RED], level.teamScores[TEAM_BLUE],
|
|
|
|
level.teamScores[TEAM_GREEN], level.teamScores[TEAM_YELLOW],
|
|
|
|
string ) );
|
|
|
|
// END
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_Score_f
|
|
|
|
|
|
|
|
Request current scoreboard information
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Cmd_Score_f( gentity_t *ent ) {
|
|
|
|
DeathmatchScoreboardMessage( ent );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
CheatsOk
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
qboolean CheatsOk( gentity_t *ent ) {
|
|
|
|
if ( !g_cheats.integer ) {
|
2012-09-15 03:03:44 +00:00
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Cheats are not enabled on this server.\n\"");
|
2011-02-18 14:31:32 +00:00
|
|
|
return qfalse;
|
|
|
|
}
|
|
|
|
if ( ent->health <= 0 ) {
|
2012-09-15 03:03:44 +00:00
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"You must be alive to use this command.\n\"");
|
2011-02-18 14:31:32 +00:00
|
|
|
return qfalse;
|
|
|
|
}
|
|
|
|
return qtrue;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
ConcatArgs
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
char *ConcatArgs( int start ) {
|
|
|
|
int i, c, tlen;
|
|
|
|
static char line[MAX_STRING_CHARS];
|
|
|
|
int len;
|
|
|
|
char arg[MAX_STRING_CHARS];
|
|
|
|
|
|
|
|
len = 0;
|
|
|
|
c = trap_Argc();
|
|
|
|
for ( i = start ; i < c ; i++ ) {
|
|
|
|
trap_Argv( i, arg, sizeof( arg ) );
|
|
|
|
tlen = strlen( arg );
|
|
|
|
if ( len + tlen >= MAX_STRING_CHARS - 1 ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
memcpy( line + len, arg, tlen );
|
|
|
|
len += tlen;
|
|
|
|
if ( i != c - 1 ) {
|
|
|
|
line[len] = ' ';
|
|
|
|
len++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
line[len] = 0;
|
|
|
|
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
SanitizeString
|
|
|
|
|
|
|
|
Remove case and control characters
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void SanitizeString( char *in, char *out ) {
|
|
|
|
while ( *in ) {
|
|
|
|
if ( *in == 27 ) {
|
|
|
|
in += 2; // skip color code
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if ( *in < 32 ) {
|
|
|
|
in++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
*out++ = tolower( *in++ );
|
|
|
|
}
|
|
|
|
|
|
|
|
*out = 0;
|
|
|
|
}
|
|
|
|
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
StringIsInteger
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
qboolean StringIsInteger( const char * s ) {
|
|
|
|
int i;
|
|
|
|
int len;
|
|
|
|
qboolean foundDigit;
|
|
|
|
|
|
|
|
len = strlen( s );
|
|
|
|
foundDigit = qfalse;
|
|
|
|
|
|
|
|
for ( i=0 ; i < len ; i++ ) {
|
|
|
|
if ( !isdigit( s[i] ) ) {
|
|
|
|
return qfalse;
|
|
|
|
}
|
|
|
|
|
|
|
|
foundDigit = qtrue;
|
|
|
|
}
|
|
|
|
|
|
|
|
return foundDigit;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
/*
|
|
|
|
==================
|
|
|
|
ClientNumberFromString
|
|
|
|
|
|
|
|
Returns a player number for either a number or name string
|
|
|
|
Returns -1 if invalid
|
|
|
|
==================
|
|
|
|
*/
|
2017-07-10 01:33:41 +00:00
|
|
|
int ClientNumberFromString( gentity_t *to, char *s, qboolean checkNums, qboolean checkNames ) {
|
2011-02-18 14:31:32 +00:00
|
|
|
gclient_t *cl;
|
|
|
|
int idnum;
|
|
|
|
char s2[MAX_STRING_CHARS];
|
|
|
|
char n2[MAX_STRING_CHARS];
|
|
|
|
|
2017-07-10 01:33:41 +00:00
|
|
|
if ( checkNums ) {
|
|
|
|
// numeric values could be slot numbers
|
|
|
|
if ( StringIsInteger( s ) ) {
|
|
|
|
idnum = atoi( s );
|
|
|
|
if ( idnum >= 0 && idnum < level.maxclients ) {
|
|
|
|
cl = &level.clients[idnum];
|
|
|
|
if ( cl->pers.connected == CON_CONNECTED ) {
|
|
|
|
return idnum;
|
|
|
|
}
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
}
|
2011-02-18 14:31:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-10 01:33:41 +00:00
|
|
|
if ( checkNames ) {
|
|
|
|
// check for a name match
|
|
|
|
SanitizeString( s, s2 );
|
|
|
|
for ( idnum=0,cl=level.clients ; idnum < level.maxclients ; idnum++,cl++ ) {
|
|
|
|
if ( cl->pers.connected != CON_CONNECTED ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
SanitizeString( cl->pers.netname, n2 );
|
|
|
|
if ( !strcmp( n2, s2 ) ) {
|
|
|
|
return idnum;
|
|
|
|
}
|
2011-02-18 14:31:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trap_SendServerCommand( to-g_entities, va("print \"User %s is not on the server\n\"", s));
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_Give_f
|
|
|
|
|
|
|
|
Give items to a client
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Cmd_Give_f (gentity_t *ent)
|
|
|
|
{
|
|
|
|
char *name;
|
|
|
|
gitem_t *it;
|
|
|
|
int i;
|
|
|
|
qboolean give_all;
|
|
|
|
gentity_t *it_ent;
|
|
|
|
trace_t trace;
|
|
|
|
|
|
|
|
if ( !CheatsOk( ent ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
name = ConcatArgs( 1 );
|
|
|
|
|
|
|
|
if (Q_stricmp(name, "all") == 0)
|
|
|
|
give_all = qtrue;
|
|
|
|
else
|
|
|
|
give_all = qfalse;
|
|
|
|
|
|
|
|
if (give_all || Q_stricmp( name, "health") == 0)
|
|
|
|
{
|
|
|
|
ent->health = ent->client->ps.stats[STAT_MAX_HEALTH];
|
|
|
|
if (!give_all)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// STONELANCE
|
|
|
|
// if (give_all || Q_stricmp(name, "weapons") == 0)
|
|
|
|
if ((give_all || Q_stricmp(name, "weapons") == 0)
|
|
|
|
&& (g_gametype.integer != GT_RACING && g_gametype.integer != GT_TEAM_RACING))
|
|
|
|
// END
|
|
|
|
{
|
|
|
|
// STONELANCE
|
|
|
|
ent->client->ps.stats[STAT_WEAPONS] = (1 << RWP_SMOKE) - 1 -
|
|
|
|
- ( 1 << WP_NONE );
|
|
|
|
// ent->client->ps.stats[STAT_WEAPONS] = (1 << WP_NUM_WEAPONS) - 1 -
|
|
|
|
// ( 1 << WP_GRAPPLING_HOOK ) - ( 1 << WP_NONE );
|
|
|
|
// END
|
|
|
|
if (!give_all)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (give_all || Q_stricmp(name, "ammo") == 0)
|
|
|
|
{
|
|
|
|
// STONELANCE
|
|
|
|
for ( i = 0 ; i < RWP_SMOKE ; i++ ) {
|
|
|
|
// for ( i = 0 ; i < MAX_WEAPONS ; i++ ) {
|
|
|
|
// END
|
|
|
|
ent->client->ps.ammo[i] = 999;
|
|
|
|
}
|
|
|
|
// STONELANCE
|
|
|
|
for ( ; i < MAX_WEAPONS ; i++ ) {
|
|
|
|
ent->client->ps.ammo[i] = 99;
|
|
|
|
}
|
|
|
|
// END
|
|
|
|
if (!give_all)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (give_all || Q_stricmp(name, "armor") == 0)
|
|
|
|
{
|
|
|
|
ent->client->ps.stats[STAT_ARMOR] = 200;
|
|
|
|
|
|
|
|
if (!give_all)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Q_stricmp(name, "excellent") == 0) {
|
|
|
|
ent->client->ps.persistant[PERS_EXCELLENT_COUNT]++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Q_stricmp(name, "impressive") == 0) {
|
|
|
|
ent->client->ps.persistant[PERS_IMPRESSIVE_COUNT]++;
|
|
|
|
return;
|
|
|
|
}
|
2022-02-05 20:49:34 +00:00
|
|
|
if (Q_stricmp(name, "impressive telefrag") == 0) {
|
|
|
|
ent->client->ps.persistant[PERS_IMPRESSIVETELEFRAG_COUNT]++;
|
|
|
|
return;
|
|
|
|
}
|
2011-02-18 14:31:32 +00:00
|
|
|
if (Q_stricmp(name, "gauntletaward") == 0) {
|
|
|
|
ent->client->ps.persistant[PERS_GAUNTLET_FRAG_COUNT]++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Q_stricmp(name, "defend") == 0) {
|
|
|
|
ent->client->ps.persistant[PERS_DEFEND_COUNT]++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Q_stricmp(name, "assist") == 0) {
|
|
|
|
ent->client->ps.persistant[PERS_ASSIST_COUNT]++;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// spawn a specific item right on the player
|
|
|
|
if ( !give_all ) {
|
|
|
|
it = BG_FindItem (name);
|
|
|
|
if (!it) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
it_ent = G_Spawn();
|
|
|
|
VectorCopy( ent->r.currentOrigin, it_ent->s.origin );
|
|
|
|
it_ent->classname = it->classname;
|
|
|
|
G_SpawnItem (it_ent, it);
|
|
|
|
FinishSpawningItem(it_ent );
|
|
|
|
memset( &trace, 0, sizeof( trace ) );
|
|
|
|
Touch_Item (it_ent, ent, &trace);
|
|
|
|
if (it_ent->inuse) {
|
|
|
|
G_FreeEntity( it_ent );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_God_f
|
|
|
|
|
|
|
|
Sets client to godmode
|
|
|
|
|
|
|
|
argv(0) god
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Cmd_God_f (gentity_t *ent)
|
|
|
|
{
|
|
|
|
char *msg;
|
|
|
|
|
|
|
|
if ( !CheatsOk( ent ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ent->flags ^= FL_GODMODE;
|
|
|
|
if (!(ent->flags & FL_GODMODE) )
|
|
|
|
msg = "godmode OFF\n";
|
|
|
|
else
|
|
|
|
msg = "godmode ON\n";
|
|
|
|
|
|
|
|
trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_Notarget_f
|
|
|
|
|
|
|
|
Sets client to notarget
|
|
|
|
|
|
|
|
argv(0) notarget
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Cmd_Notarget_f( gentity_t *ent ) {
|
|
|
|
char *msg;
|
|
|
|
|
|
|
|
if ( !CheatsOk( ent ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ent->flags ^= FL_NOTARGET;
|
|
|
|
if (!(ent->flags & FL_NOTARGET) )
|
|
|
|
msg = "notarget OFF\n";
|
|
|
|
else
|
|
|
|
msg = "notarget ON\n";
|
|
|
|
|
|
|
|
trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_Noclip_f
|
|
|
|
|
|
|
|
argv(0) noclip
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Cmd_Noclip_f( gentity_t *ent ) {
|
|
|
|
char *msg;
|
|
|
|
|
|
|
|
if ( !CheatsOk( ent ) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ent->client->noclip ) {
|
|
|
|
msg = "noclip OFF\n";
|
|
|
|
} else {
|
|
|
|
msg = "noclip ON\n";
|
|
|
|
}
|
|
|
|
ent->client->noclip = !ent->client->noclip;
|
|
|
|
|
|
|
|
trap_SendServerCommand( ent-g_entities, va("print \"%s\"", msg));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_LevelShot_f
|
|
|
|
|
|
|
|
This is just to help generate the level pictures
|
|
|
|
for the menus. It goes to the intermission immediately
|
|
|
|
and sends over a command to the client to resize the view,
|
|
|
|
hide the scoreboard, and take a special screenshot
|
|
|
|
==================
|
|
|
|
*/
|
2011-07-26 08:52:24 +00:00
|
|
|
void Cmd_LevelShot_f(gentity_t *ent)
|
|
|
|
{
|
|
|
|
if(!ent->client->pers.localClient)
|
|
|
|
{
|
|
|
|
trap_SendServerCommand(ent-g_entities,
|
|
|
|
"print \"The levelshot command must be executed by a local client\n\"");
|
2011-02-18 14:31:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-07-26 08:52:24 +00:00
|
|
|
if(!CheatsOk(ent))
|
|
|
|
return;
|
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
// doesn't work in single player
|
2011-07-26 08:52:24 +00:00
|
|
|
if(g_gametype.integer == GT_SINGLE_PLAYER)
|
|
|
|
{
|
|
|
|
trap_SendServerCommand(ent-g_entities,
|
|
|
|
"print \"Must not be in singleplayer mode for levelshot\n\"" );
|
2011-02-18 14:31:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
BeginIntermission();
|
2011-07-26 08:52:24 +00:00
|
|
|
trap_SendServerCommand(ent-g_entities, "clientLevelShot");
|
2011-02-18 14:31:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
2011-07-26 08:52:24 +00:00
|
|
|
Cmd_TeamTask_f
|
2011-02-18 14:31:32 +00:00
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Cmd_TeamTask_f( gentity_t *ent ) {
|
|
|
|
char userinfo[MAX_INFO_STRING];
|
|
|
|
char arg[MAX_TOKEN_CHARS];
|
|
|
|
int task;
|
|
|
|
int client = ent->client - level.clients;
|
|
|
|
|
|
|
|
if ( trap_Argc() != 2 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
trap_Argv( 1, arg, sizeof( arg ) );
|
|
|
|
task = atoi( arg );
|
|
|
|
|
|
|
|
trap_GetUserinfo(client, userinfo, sizeof(userinfo));
|
|
|
|
Info_SetValueForKey(userinfo, "teamtask", va("%d", task));
|
|
|
|
trap_SetUserinfo(client, userinfo);
|
|
|
|
ClientUserinfoChanged(client);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Cmd_Kill_f
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void Cmd_Kill_f( gentity_t *ent ) {
|
|
|
|
if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (ent->health <= 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ent->flags &= ~FL_GODMODE;
|
|
|
|
ent->client->ps.stats[STAT_HEALTH] = ent->health = -999;
|
|
|
|
player_die (ent, ent, ent, 100000, MOD_SUICIDE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
2017-07-10 01:33:41 +00:00
|
|
|
BroadcastTeamChange
|
2011-02-18 14:31:32 +00:00
|
|
|
|
|
|
|
Let everyone know about a team change
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void BroadcastTeamChange( gclient_t *client, int oldTeam )
|
|
|
|
{
|
|
|
|
if ( client->sess.sessionTeam == TEAM_RED ) {
|
|
|
|
trap_SendServerCommand( -1, va("cp \"%s" S_COLOR_WHITE " joined the red team.\n\"",
|
|
|
|
client->pers.netname) );
|
|
|
|
} else if ( client->sess.sessionTeam == TEAM_BLUE ) {
|
|
|
|
trap_SendServerCommand( -1, va("cp \"%s" S_COLOR_WHITE " joined the blue team.\n\"",
|
|
|
|
client->pers.netname));
|
|
|
|
}
|
|
|
|
// STONELANCE
|
|
|
|
else if ( client->sess.sessionTeam == TEAM_GREEN ) {
|
|
|
|
trap_SendServerCommand( -1, va("cp \"%s" S_COLOR_WHITE " joined the green team.\n\"",
|
|
|
|
client->pers.netname));
|
|
|
|
}
|
|
|
|
else if ( client->sess.sessionTeam == TEAM_YELLOW ) {
|
|
|
|
trap_SendServerCommand( -1, va("cp \"%s" S_COLOR_WHITE " joined the yellow team.\n\"",
|
|
|
|
client->pers.netname));
|
|
|
|
}
|
|
|
|
// END
|
|
|
|
else if ( client->sess.sessionTeam == TEAM_SPECTATOR && oldTeam != TEAM_SPECTATOR ) {
|
|
|
|
trap_SendServerCommand( -1, va("cp \"%s" S_COLOR_WHITE " joined the spectators.\n\"",
|
|
|
|
client->pers.netname));
|
|
|
|
} else if ( client->sess.sessionTeam == TEAM_FREE ) {
|
|
|
|
trap_SendServerCommand( -1, va("cp \"%s" S_COLOR_WHITE " joined the battle.\n\"",
|
|
|
|
client->pers.netname));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
SetTeam
|
|
|
|
=================
|
|
|
|
*/
|
2017-07-10 01:33:41 +00:00
|
|
|
void SetTeam( gentity_t *ent, const char *s ) {
|
2011-02-18 14:31:32 +00:00
|
|
|
int team, oldTeam;
|
|
|
|
gclient_t *client;
|
|
|
|
int clientNum;
|
|
|
|
spectatorState_t specState;
|
|
|
|
int specClient;
|
|
|
|
// STONELANCE
|
|
|
|
qboolean specWilling;
|
|
|
|
// END
|
|
|
|
int teamLeader;
|
|
|
|
|
|
|
|
//
|
|
|
|
// see what change is requested
|
|
|
|
//
|
|
|
|
client = ent->client;
|
|
|
|
|
|
|
|
clientNum = client - level.clients;
|
|
|
|
specClient = 0;
|
|
|
|
specState = SPECTATOR_NOT;
|
|
|
|
// STONELANCE
|
|
|
|
specWilling = qtrue;
|
|
|
|
// END
|
|
|
|
|
|
|
|
if ( !Q_stricmp( s, "scoreboard" ) || !Q_stricmp( s, "score" ) ) {
|
|
|
|
team = TEAM_SPECTATOR;
|
|
|
|
specState = SPECTATOR_SCOREBOARD;
|
|
|
|
} else if ( !Q_stricmp( s, "follow1" ) ) {
|
|
|
|
team = TEAM_SPECTATOR;
|
|
|
|
specState = SPECTATOR_FOLLOW;
|
|
|
|
specClient = -1;
|
|
|
|
} else if ( !Q_stricmp( s, "follow2" ) ) {
|
|
|
|
team = TEAM_SPECTATOR;
|
|
|
|
specState = SPECTATOR_FOLLOW;
|
|
|
|
specClient = -2;
|
|
|
|
} else if ( !Q_stricmp( s, "spectator" ) || !Q_stricmp( s, "s" ) ) {
|
|
|
|
team = TEAM_SPECTATOR;
|
|
|
|
specState = SPECTATOR_FREE;
|
|
|
|
}
|
|
|
|
// STONELANCE
|
|
|
|
else if ( !Q_stricmp( s, "racerSpectator" ) ) {
|
|
|
|
team = TEAM_SPECTATOR;
|
|
|
|
specState = SPECTATOR_FREE;
|
|
|
|
specWilling = qfalse;
|
|
|
|
}
|
2023-12-17 19:45:22 +00:00
|
|
|
else if ((isRallyRace() || g_gametype.integer == GT_DERBY || g_gametype.integer == GT_LCS) && level.startRaceTime){
|
2011-02-18 14:31:32 +00:00
|
|
|
trap_SendServerCommand( clientNum, "cp \"Cannot change teams\nduring a race.\n\"");
|
|
|
|
return; // dont allow any change except to spectator during a race.
|
|
|
|
}
|
|
|
|
// END
|
|
|
|
else if ( g_gametype.integer >= GT_TEAM ) {
|
|
|
|
// if running a team game, assign player to one of the teams
|
|
|
|
specState = SPECTATOR_NOT;
|
|
|
|
if ( !Q_stricmp( s, "red" ) || !Q_stricmp( s, "r" ) ) {
|
|
|
|
team = TEAM_RED;
|
|
|
|
} else if ( !Q_stricmp( s, "blue" ) || !Q_stricmp( s, "b" ) ) {
|
|
|
|
team = TEAM_BLUE;
|
|
|
|
}
|
|
|
|
// STONELANCE
|
|
|
|
else if ( !Q_stricmp( s, "green" ) || !Q_stricmp( s, "g" ) ) {
|
|
|
|
if (g_gametype.integer == GT_CTF)
|
|
|
|
return; // no green in ctf
|
|
|
|
team = TEAM_GREEN;
|
|
|
|
} else if ( !Q_stricmp( s, "yellow" ) || !Q_stricmp( s, "y" ) ) {
|
|
|
|
if (g_gametype.integer == GT_CTF)
|
|
|
|
return; // no yellow in ctf
|
|
|
|
team = TEAM_YELLOW;
|
|
|
|
}
|
|
|
|
// END
|
|
|
|
else {
|
|
|
|
// pick the team with the least number of players
|
|
|
|
team = PickTeam( clientNum );
|
|
|
|
}
|
|
|
|
|
2017-07-10 01:33:41 +00:00
|
|
|
if ( g_teamForceBalance.integer && !client->pers.localClient && !( ent->r.svFlags & SVF_BOT ) ) {
|
2011-02-18 14:31:32 +00:00
|
|
|
int counts[TEAM_NUM_TEAMS];
|
|
|
|
|
2017-11-17 03:37:02 +00:00
|
|
|
counts[TEAM_BLUE] = TeamCount( clientNum, TEAM_BLUE );
|
|
|
|
counts[TEAM_RED] = TeamCount( clientNum, TEAM_RED );
|
2011-02-18 14:31:32 +00:00
|
|
|
// STONELANCE
|
2017-11-17 03:37:02 +00:00
|
|
|
counts[TEAM_GREEN] = TeamCount( clientNum, TEAM_GREEN );
|
|
|
|
counts[TEAM_YELLOW] = TeamCount( clientNum, TEAM_YELLOW );
|
2011-02-18 14:31:32 +00:00
|
|
|
|
|
|
|
// We allow a spread of two
|
|
|
|
/*
|
|
|
|
if ( team == TEAM_RED && counts[TEAM_RED] - counts[TEAM_BLUE] > 1 ) {
|
2017-11-17 03:37:02 +00:00
|
|
|
trap_SendServerCommand( clientNum,
|
2011-02-18 14:31:32 +00:00
|
|
|
"cp \"Red team has too many players.\n\"" );
|
|
|
|
return; // ignore the request
|
|
|
|
}
|
|
|
|
if ( team == TEAM_BLUE && counts[TEAM_BLUE] - counts[TEAM_RED] > 1 ) {
|
2017-11-17 03:37:02 +00:00
|
|
|
trap_SendServerCommand( clientNum,
|
2011-02-18 14:31:32 +00:00
|
|
|
"cp \"Blue team has too many players.\n\"" );
|
|
|
|
return; // ignore the request
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
if ( team == TEAM_RED && counts[TEAM_RED] - counts[TEAM_BLUE] > 1
|
|
|
|
&& counts[TEAM_RED] - counts[TEAM_GREEN] > 1
|
|
|
|
&& counts[TEAM_RED] - counts[TEAM_YELLOW] > 1) {
|
2017-11-17 03:37:02 +00:00
|
|
|
trap_SendServerCommand( clientNum,
|
2011-02-18 14:31:32 +00:00
|
|
|
"cp \"Red team has too many players.\n\"" );
|
|
|
|
return; // ignore the request
|
|
|
|
}
|
|
|
|
if ( team == TEAM_BLUE && counts[TEAM_BLUE] - counts[TEAM_RED] > 1
|
|
|
|
&& counts[TEAM_BLUE] - counts[TEAM_GREEN] > 1
|
|
|
|
&& counts[TEAM_YELLOW] - counts[TEAM_YELLOW] > 1) {
|
2017-11-17 03:37:02 +00:00
|
|
|
trap_SendServerCommand( clientNum,
|
2011-02-18 14:31:32 +00:00
|
|
|
"cp \"Blue team has too many players.\n\"" );
|
|
|
|
return; // ignore the request
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( team == TEAM_GREEN && counts[TEAM_GREEN] - counts[TEAM_RED] > 1
|
|
|
|
&& counts[TEAM_GREEN] - counts[TEAM_BLUE] > 1
|
|
|
|
&& counts[TEAM_GREEN] - counts[TEAM_YELLOW] > 1) {
|
2017-11-17 03:37:02 +00:00
|
|
|
trap_SendServerCommand( clientNum,
|
2011-02-18 14:31:32 +00:00
|
|
|
"cp \"Green team has too many players.\n\"" );
|
|
|
|
return; // ignore the request
|
|
|
|
}
|
|
|
|
if ( team == TEAM_YELLOW && counts[TEAM_YELLOW] - counts[TEAM_RED] > 1
|
|
|
|
&& counts[TEAM_YELLOW] - counts[TEAM_BLUE] > 1
|
|
|
|
&& counts[TEAM_YELLOW] - counts[TEAM_GREEN] > 1) {
|
2017-11-17 03:37:02 +00:00
|
|
|
trap_SendServerCommand( clientNum,
|
2011-02-18 14:31:32 +00:00
|
|
|
"cp \"Yellow team has too many players.\n\"" );
|
|
|
|
return; // ignore the request
|
|
|
|
}
|
|
|
|
// END
|
|
|
|
// It's ok, the team we are switching to has less or same number of players
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// force them to spectators if there aren't any spots free
|
|
|
|
team = TEAM_FREE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// override decision if limiting the players
|
|
|
|
// STONELANCE
|
|
|
|
/*
|
|
|
|
if ( (g_gametype.integer == GT_TOURNAMENT)
|
|
|
|
&& level.numNonSpectatorClients >= 2 ) {
|
|
|
|
team = TEAM_SPECTATOR;
|
|
|
|
} else
|
|
|
|
*/
|
|
|
|
// END
|
|
|
|
if ( g_maxGameClients.integer > 0 &&
|
|
|
|
level.numNonSpectatorClients >= g_maxGameClients.integer ) {
|
|
|
|
team = TEAM_SPECTATOR;
|
|
|
|
// STONELANCE
|
|
|
|
specWilling = qfalse;
|
|
|
|
// END
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// decide if we will allow the change
|
|
|
|
//
|
|
|
|
oldTeam = client->sess.sessionTeam;
|
|
|
|
if ( team == oldTeam && team != TEAM_SPECTATOR ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// execute the team change
|
|
|
|
//
|
|
|
|
|
2017-07-10 01:33:41 +00:00
|
|
|
// if the player was dead leave the body, but only if they're actually in game
|
|
|
|
if ( client->ps.stats[STAT_HEALTH] <= 0 && client->pers.connected == CON_CONNECTED ) {
|
2011-02-18 14:31:32 +00:00
|
|
|
CopyToBodyQue(ent);
|
|
|
|
}
|
|
|
|
|
|
|
|
// he starts at 'base'
|
|
|
|
client->pers.teamState.state = TEAM_BEGIN;
|
|
|
|
if ( oldTeam != TEAM_SPECTATOR
|
|
|
|
// STONELANCE
|
|
|
|
&& !client->finishRaceTime
|
|
|
|
// END
|
|
|
|
) {
|
|
|
|
// Kill him (makes sure he loses flags, etc)
|
|
|
|
ent->flags &= ~FL_GODMODE;
|
|
|
|
ent->client->ps.stats[STAT_HEALTH] = ent->health = 0;
|
|
|
|
player_die (ent, ent, ent, 100000, MOD_SUICIDE);
|
|
|
|
|
|
|
|
}
|
2011-07-26 08:52:24 +00:00
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
// they go to the end of the line for tournements
|
2011-07-26 08:52:24 +00:00
|
|
|
if(team == TEAM_SPECTATOR && oldTeam != team)
|
|
|
|
AddTournamentQueue(client);
|
2011-02-18 14:31:32 +00:00
|
|
|
|
|
|
|
client->sess.sessionTeam = team;
|
|
|
|
client->sess.spectatorState = specState;
|
|
|
|
client->sess.spectatorClient = specClient;
|
|
|
|
// STONELANCE
|
|
|
|
client->sess.spectatorWilling = specWilling;
|
|
|
|
// END
|
|
|
|
|
|
|
|
client->sess.teamLeader = qfalse;
|
|
|
|
// STONELANCE
|
|
|
|
// if ( team == TEAM_RED || team == TEAM_BLUE ) {
|
|
|
|
if ( team == TEAM_RED || team == TEAM_BLUE || team == TEAM_GREEN || team == TEAM_YELLOW ) {
|
|
|
|
// END
|
|
|
|
teamLeader = TeamLeader( team );
|
|
|
|
// if there is no team leader or the team leader is a bot and this client is not a bot
|
|
|
|
if ( teamLeader == -1 || ( !(g_entities[clientNum].r.svFlags & SVF_BOT) && (g_entities[teamLeader].r.svFlags & SVF_BOT) ) ) {
|
|
|
|
SetLeader( team, clientNum );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// make sure there is a team leader on the team the player came from
|
|
|
|
// STONELANCE
|
|
|
|
// if ( oldTeam == TEAM_RED || oldTeam == TEAM_BLUE ) {
|
|
|
|
if ( oldTeam == TEAM_RED || oldTeam == TEAM_BLUE || oldTeam == TEAM_GREEN || oldTeam == TEAM_YELLOW ) {
|
|
|
|
// END
|
|
|
|
CheckTeamLeader( oldTeam );
|
|
|
|
}
|
|
|
|
|
2017-12-03 10:09:52 +00:00
|
|
|
// get and distribute relevant parameters
|
2011-02-18 14:31:32 +00:00
|
|
|
ClientUserinfoChanged( clientNum );
|
|
|
|
|
2017-07-10 01:33:41 +00:00
|
|
|
// client hasn't spawned yet, they sent an early team command, teampref userinfo, or g_teamAutoJoin is enabled
|
|
|
|
if ( client->pers.connected != CON_CONNECTED ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-03-15 19:40:23 +00:00
|
|
|
BroadcastTeamChange( client, oldTeam );
|
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
ClientBegin( clientNum );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
StopFollowing
|
|
|
|
|
|
|
|
If the client being followed leaves the game, or you just want to drop
|
|
|
|
to free floating spectator mode
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void StopFollowing( gentity_t *ent ) {
|
|
|
|
// STONELANCE
|
|
|
|
// ent->client->ps.persistant[ PERS_TEAM ] = TEAM_SPECTATOR;
|
|
|
|
// ent->client->sess.sessionTeam = TEAM_SPECTATOR;
|
|
|
|
// END
|
|
|
|
ent->client->sess.spectatorState = SPECTATOR_FREE;
|
|
|
|
ent->client->ps.pm_flags &= ~PMF_FOLLOW;
|
|
|
|
ent->r.svFlags &= ~SVF_BOT;
|
|
|
|
ent->client->ps.clientNum = ent - g_entities;
|
2017-07-10 01:33:41 +00:00
|
|
|
|
|
|
|
SetClientViewAngle( ent, ent->client->ps.viewangles );
|
|
|
|
|
|
|
|
// don't use dead view angles
|
|
|
|
if ( ent->client->ps.stats[STAT_HEALTH] <= 0 ) {
|
|
|
|
ent->client->ps.stats[STAT_HEALTH] = 1;
|
|
|
|
}
|
2011-02-18 14:31:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Cmd_Team_f
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void Cmd_Team_f( gentity_t *ent ) {
|
|
|
|
int oldTeam;
|
|
|
|
char s[MAX_TOKEN_CHARS];
|
|
|
|
|
|
|
|
if ( trap_Argc() != 2 ) {
|
|
|
|
oldTeam = ent->client->sess.sessionTeam;
|
|
|
|
switch ( oldTeam ) {
|
|
|
|
case TEAM_BLUE:
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Blue team\n\"" );
|
|
|
|
break;
|
|
|
|
case TEAM_RED:
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Red team\n\"" );
|
|
|
|
break;
|
|
|
|
// STONELANCE
|
|
|
|
case TEAM_GREEN:
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Green team\n\"" );
|
|
|
|
break;
|
|
|
|
case TEAM_YELLOW:
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Yellow team\n\"" );
|
|
|
|
break;
|
|
|
|
// END
|
|
|
|
case TEAM_FREE:
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Free team\n\"" );
|
|
|
|
break;
|
|
|
|
case TEAM_SPECTATOR:
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Spectator team\n\"" );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ent->client->switchTeamTime > level.time ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"May not switch teams more than once per 5 seconds.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if they are playing a tournement game, count as a loss
|
|
|
|
// STONELANCE - removed gametype
|
|
|
|
/*
|
|
|
|
if ( (g_gametype.integer == GT_TOURNAMENT )
|
|
|
|
&& ent->client->sess.sessionTeam == TEAM_FREE ) {
|
|
|
|
ent->client->sess.losses++;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
// END
|
|
|
|
|
|
|
|
trap_Argv( 1, s, sizeof( s ) );
|
|
|
|
|
|
|
|
SetTeam( ent, s );
|
|
|
|
|
|
|
|
ent->client->switchTeamTime = level.time + 5000;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Cmd_Follow_f
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void Cmd_Follow_f( gentity_t *ent ) {
|
|
|
|
int i;
|
|
|
|
char arg[MAX_TOKEN_CHARS];
|
|
|
|
|
|
|
|
if ( trap_Argc() != 2 ) {
|
|
|
|
if ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) {
|
|
|
|
StopFollowing( ent );
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
trap_Argv( 1, arg, sizeof( arg ) );
|
2017-07-10 01:33:41 +00:00
|
|
|
i = ClientNumberFromString( ent, arg, qtrue, qtrue );
|
2011-02-18 14:31:32 +00:00
|
|
|
if ( i == -1 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// can't follow self
|
|
|
|
if ( &level.clients[ i ] == ent->client ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// can't follow another spectator
|
|
|
|
if ( level.clients[ i ].sess.sessionTeam == TEAM_SPECTATOR ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if they are playing a tournement game, count as a loss
|
|
|
|
// STONELANCE - removed gametype
|
|
|
|
/*
|
|
|
|
if ( (g_gametype.integer == GT_TOURNAMENT )
|
|
|
|
&& ent->client->sess.sessionTeam == TEAM_FREE ) {
|
|
|
|
ent->client->sess.losses++;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
// END
|
|
|
|
|
|
|
|
// first set them to spectator
|
|
|
|
if ( ent->client->sess.sessionTeam != TEAM_SPECTATOR ) {
|
|
|
|
SetTeam( ent, "spectator" );
|
|
|
|
}
|
|
|
|
|
|
|
|
ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
|
|
|
|
ent->client->sess.spectatorClient = i;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Cmd_FollowCycle_f
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void Cmd_FollowCycle_f( gentity_t *ent, int dir ) {
|
|
|
|
int clientnum;
|
|
|
|
int original;
|
|
|
|
|
|
|
|
// if they are playing a tournement game, count as a loss
|
|
|
|
// STONELANCE - removed gametype
|
|
|
|
/*
|
|
|
|
if ( (g_gametype.integer == GT_TOURNAMENT )
|
|
|
|
&& ent->client->sess.sessionTeam == TEAM_FREE ) {
|
|
|
|
ent->client->sess.losses++;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
// END
|
|
|
|
// first set them to spectator
|
|
|
|
if ( ent->client->sess.spectatorState == SPECTATOR_NOT ) {
|
|
|
|
SetTeam( ent, "spectator" );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( dir != 1 && dir != -1 ) {
|
|
|
|
G_Error( "Cmd_FollowCycle_f: bad dir %i", dir );
|
|
|
|
}
|
|
|
|
|
2012-09-15 03:03:44 +00:00
|
|
|
// if dedicated follow client, just switch between the two auto clients
|
|
|
|
if (ent->client->sess.spectatorClient < 0) {
|
|
|
|
if (ent->client->sess.spectatorClient == -1) {
|
|
|
|
ent->client->sess.spectatorClient = -2;
|
|
|
|
} else if (ent->client->sess.spectatorClient == -2) {
|
|
|
|
ent->client->sess.spectatorClient = -1;
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
clientnum = ent->client->sess.spectatorClient;
|
|
|
|
original = clientnum;
|
|
|
|
do {
|
|
|
|
clientnum += dir;
|
|
|
|
if ( clientnum >= level.maxclients ) {
|
|
|
|
clientnum = 0;
|
|
|
|
}
|
|
|
|
if ( clientnum < 0 ) {
|
|
|
|
clientnum = level.maxclients - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// can only follow connected clients
|
|
|
|
if ( level.clients[ clientnum ].pers.connected != CON_CONNECTED ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// can't follow another spectator
|
|
|
|
if ( level.clients[ clientnum ].sess.sessionTeam == TEAM_SPECTATOR ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// STONELANCE
|
|
|
|
// can't follow another spectator
|
|
|
|
if ( isRaceObserver( clientnum ) ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// END
|
|
|
|
|
|
|
|
// this is good, we can use it
|
|
|
|
ent->client->sess.spectatorClient = clientnum;
|
|
|
|
// STONELANCE
|
|
|
|
if( ent->client->sess.spectatorState == SPECTATOR_OBSERVE )
|
|
|
|
{
|
|
|
|
vec3_t origin, angles;
|
|
|
|
if ( ent->client->sess.spectatorClient >= 0 && FindBestObserverSpot(ent, &g_entities[ent->client->sess.spectatorClient], origin, angles) )
|
|
|
|
{
|
|
|
|
G_SetOrigin(ent, origin);
|
|
|
|
VectorCopy(origin, ent->client->ps.origin);
|
|
|
|
VectorCopy(angles, ent->client->ps.viewangles);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ent->client->sess.spectatorState != SPECTATOR_FOLLOW &&
|
|
|
|
ent->client->sess.spectatorState != SPECTATOR_OBSERVE )
|
|
|
|
ent->client->sess.spectatorState = SPECTATOR_OBSERVE;
|
|
|
|
// ent->client->sess.spectatorState = SPECTATOR_FOLLOW;
|
|
|
|
// END
|
|
|
|
return;
|
|
|
|
} while ( clientnum != original );
|
|
|
|
|
|
|
|
// leave it where it was
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
G_Say
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
|
|
|
|
static void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, const char *name, const char *message ) {
|
|
|
|
if (!other) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!other->inuse) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!other->client) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( other->client->pers.connected != CON_CONNECTED ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( mode == SAY_TEAM && !OnSameTeam(ent, other) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// no chatting to players in tournements
|
|
|
|
// STONELANCE - removed gametype
|
|
|
|
/*
|
|
|
|
if ( (g_gametype.integer == GT_TOURNAMENT )
|
|
|
|
&& other->client->sess.sessionTeam == TEAM_FREE
|
|
|
|
&& ent->client->sess.sessionTeam != TEAM_FREE ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
// END
|
|
|
|
|
|
|
|
trap_SendServerCommand( other-g_entities, va("%s \"%s%c%c%s\"",
|
|
|
|
mode == SAY_TEAM ? "tchat" : "chat",
|
|
|
|
name, Q_COLOR_ESCAPE, color, message));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define EC "\x19"
|
|
|
|
|
|
|
|
void G_Say( gentity_t *ent, gentity_t *target, int mode, const char *chatText ) {
|
|
|
|
int j;
|
|
|
|
gentity_t *other;
|
|
|
|
int color;
|
|
|
|
char name[64];
|
|
|
|
// don't let text be too long for malicious reasons
|
|
|
|
char text[MAX_SAY_TEXT];
|
|
|
|
char location[64];
|
|
|
|
|
|
|
|
if ( g_gametype.integer < GT_TEAM && mode == SAY_TEAM ) {
|
|
|
|
mode = SAY_ALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch ( mode ) {
|
|
|
|
default:
|
|
|
|
case SAY_ALL:
|
|
|
|
G_LogPrintf( "say: %s: %s\n", ent->client->pers.netname, chatText );
|
|
|
|
Com_sprintf (name, sizeof(name), "%s%c%c"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );
|
|
|
|
color = COLOR_GREEN;
|
|
|
|
break;
|
|
|
|
case SAY_TEAM:
|
|
|
|
G_LogPrintf( "sayteam: %s: %s\n", ent->client->pers.netname, chatText );
|
|
|
|
if (Team_GetLocationMsg(ent, location, sizeof(location)))
|
|
|
|
Com_sprintf (name, sizeof(name), EC"(%s%c%c"EC") (%s)"EC": ",
|
|
|
|
ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location);
|
|
|
|
else
|
|
|
|
Com_sprintf (name, sizeof(name), EC"(%s%c%c"EC")"EC": ",
|
|
|
|
ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );
|
|
|
|
color = COLOR_CYAN;
|
|
|
|
break;
|
|
|
|
case SAY_TELL:
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
if (target && target->inuse && target->client && g_gametype.integer >= GT_TEAM &&
|
2011-02-18 14:31:32 +00:00
|
|
|
target->client->sess.sessionTeam == ent->client->sess.sessionTeam &&
|
|
|
|
Team_GetLocationMsg(ent, location, sizeof(location)))
|
|
|
|
Com_sprintf (name, sizeof(name), EC"[%s%c%c"EC"] (%s)"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, location );
|
|
|
|
else
|
|
|
|
Com_sprintf (name, sizeof(name), EC"[%s%c%c"EC"]"EC": ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE );
|
|
|
|
color = COLOR_MAGENTA;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Q_strncpyz( text, chatText, sizeof(text) );
|
|
|
|
|
|
|
|
if ( target ) {
|
|
|
|
G_SayTo( ent, target, mode, color, name, text );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// echo the text to the console
|
|
|
|
if ( g_dedicated.integer ) {
|
|
|
|
G_Printf( "%s%s\n", name, text);
|
|
|
|
}
|
|
|
|
|
2017-12-03 10:09:52 +00:00
|
|
|
// send it to all the appropriate clients
|
2011-02-18 14:31:32 +00:00
|
|
|
for (j = 0; j < level.maxclients; j++) {
|
|
|
|
other = &g_entities[j];
|
|
|
|
G_SayTo( ent, other, mode, color, name, text );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-30 07:09:41 +00:00
|
|
|
static void SanitizeChatText( char *text ) {
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for ( i = 0; text[i]; i++ ) {
|
|
|
|
if ( text[i] == '\n' || text[i] == '\r' ) {
|
|
|
|
text[i] = ' ';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_Say_f
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
static void Cmd_Say_f( gentity_t *ent, int mode, qboolean arg0 ) {
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
if ( trap_Argc () < 2 && !arg0 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arg0)
|
|
|
|
{
|
|
|
|
p = ConcatArgs( 0 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p = ConcatArgs( 1 );
|
|
|
|
}
|
|
|
|
|
2017-08-30 07:09:41 +00:00
|
|
|
SanitizeChatText( p );
|
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
G_Say( ent, NULL, mode, p );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_Tell_f
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
static void Cmd_Tell_f( gentity_t *ent ) {
|
|
|
|
int targetNum;
|
|
|
|
gentity_t *target;
|
|
|
|
char *p;
|
|
|
|
char arg[MAX_TOKEN_CHARS];
|
|
|
|
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
if ( trap_Argc () < 3 ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Usage: tell <player id> <message>\n\"" );
|
2011-02-18 14:31:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
trap_Argv( 1, arg, sizeof( arg ) );
|
2017-07-10 01:33:41 +00:00
|
|
|
targetNum = ClientNumberFromString( ent, arg, qtrue, qtrue );
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
if ( targetNum == -1 ) {
|
2011-02-18 14:31:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
target = &g_entities[targetNum];
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
if ( !target->inuse || !target->client ) {
|
2011-02-18 14:31:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
p = ConcatArgs( 2 );
|
|
|
|
|
2017-08-30 07:09:41 +00:00
|
|
|
SanitizeChatText( p );
|
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
G_LogPrintf( "tell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, p );
|
|
|
|
G_Say( ent, target, SAY_TELL, p );
|
|
|
|
// don't tell to the player self if it was already directed to this player
|
|
|
|
// also don't send the chat back to a bot
|
|
|
|
if ( ent != target && !(ent->r.svFlags & SVF_BOT)) {
|
|
|
|
G_Say( ent, ent, SAY_TELL, p );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-15 03:03:44 +00:00
|
|
|
#ifdef MISSIONPACK
|
2011-02-18 14:31:32 +00:00
|
|
|
static void G_VoiceTo( gentity_t *ent, gentity_t *other, int mode, const char *id, qboolean voiceonly ) {
|
|
|
|
int color;
|
|
|
|
char *cmd;
|
|
|
|
|
|
|
|
if (!other) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!other->inuse) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!other->client) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( mode == SAY_TEAM && !OnSameTeam(ent, other) ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// no chatting to players in tournements
|
|
|
|
// STONELANCE - removed gametype
|
|
|
|
/*
|
2011-12-10 00:15:42 +00:00
|
|
|
if ( g_gametype.integer == GT_TOURNAMENT ) {
|
2011-02-18 14:31:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
// END
|
|
|
|
|
|
|
|
if (mode == SAY_TEAM) {
|
|
|
|
color = COLOR_CYAN;
|
|
|
|
cmd = "vtchat";
|
|
|
|
}
|
|
|
|
else if (mode == SAY_TELL) {
|
|
|
|
color = COLOR_MAGENTA;
|
|
|
|
cmd = "vtell";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
color = COLOR_GREEN;
|
|
|
|
cmd = "vchat";
|
|
|
|
}
|
|
|
|
|
|
|
|
trap_SendServerCommand( other-g_entities, va("%s %d %d %d %s", cmd, voiceonly, ent->s.number, color, id));
|
|
|
|
}
|
|
|
|
|
|
|
|
void G_Voice( gentity_t *ent, gentity_t *target, int mode, const char *id, qboolean voiceonly ) {
|
|
|
|
int j;
|
|
|
|
gentity_t *other;
|
|
|
|
|
|
|
|
if ( g_gametype.integer < GT_TEAM && mode == SAY_TEAM ) {
|
|
|
|
mode = SAY_ALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( target ) {
|
|
|
|
G_VoiceTo( ent, target, mode, id, voiceonly );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// echo the text to the console
|
|
|
|
if ( g_dedicated.integer ) {
|
|
|
|
G_Printf( "voice: %s %s\n", ent->client->pers.netname, id);
|
|
|
|
}
|
|
|
|
|
2017-12-03 10:09:52 +00:00
|
|
|
// send it to all the appropriate clients
|
2011-02-18 14:31:32 +00:00
|
|
|
for (j = 0; j < level.maxclients; j++) {
|
|
|
|
other = &g_entities[j];
|
|
|
|
G_VoiceTo( ent, other, mode, id, voiceonly );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_Voice_f
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
static void Cmd_Voice_f( gentity_t *ent, int mode, qboolean arg0, qboolean voiceonly ) {
|
|
|
|
char *p;
|
|
|
|
|
|
|
|
if ( trap_Argc () < 2 && !arg0 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (arg0)
|
|
|
|
{
|
|
|
|
p = ConcatArgs( 0 );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
p = ConcatArgs( 1 );
|
|
|
|
}
|
|
|
|
|
2017-08-30 07:09:41 +00:00
|
|
|
SanitizeChatText( p );
|
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
G_Voice( ent, NULL, mode, p, voiceonly );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_VoiceTell_f
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
static void Cmd_VoiceTell_f( gentity_t *ent, qboolean voiceonly ) {
|
|
|
|
int targetNum;
|
|
|
|
gentity_t *target;
|
|
|
|
char *id;
|
|
|
|
char arg[MAX_TOKEN_CHARS];
|
|
|
|
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
if ( trap_Argc () < 3 ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, va( "print \"Usage: %s <player id> <voice id>\n\"", voiceonly ? "votell" : "vtell" ) );
|
2011-02-18 14:31:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
trap_Argv( 1, arg, sizeof( arg ) );
|
2017-07-10 01:33:41 +00:00
|
|
|
targetNum = ClientNumberFromString( ent, arg, qtrue, qtrue );
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
if ( targetNum == -1 ) {
|
2011-02-18 14:31:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
target = &g_entities[targetNum];
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
if ( !target->inuse || !target->client ) {
|
2011-02-18 14:31:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
id = ConcatArgs( 2 );
|
|
|
|
|
2017-08-30 07:09:41 +00:00
|
|
|
SanitizeChatText( id );
|
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
G_LogPrintf( "vtell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, id );
|
|
|
|
G_Voice( ent, target, SAY_TELL, id, voiceonly );
|
|
|
|
// don't tell to the player self if it was already directed to this player
|
|
|
|
// also don't send the chat back to a bot
|
|
|
|
if ( ent != target && !(ent->r.svFlags & SVF_BOT)) {
|
|
|
|
G_Voice( ent, ent, SAY_TELL, id, voiceonly );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_VoiceTaunt_f
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
static void Cmd_VoiceTaunt_f( gentity_t *ent ) {
|
|
|
|
gentity_t *who;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!ent->client) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// insult someone who just killed you
|
|
|
|
if (ent->enemy && ent->enemy->client && ent->enemy->client->lastkilled_client == ent->s.number) {
|
|
|
|
// i am a dead corpse
|
|
|
|
if (!(ent->enemy->r.svFlags & SVF_BOT)) {
|
|
|
|
G_Voice( ent, ent->enemy, SAY_TELL, VOICECHAT_DEATHINSULT, qfalse );
|
|
|
|
}
|
|
|
|
if (!(ent->r.svFlags & SVF_BOT)) {
|
|
|
|
G_Voice( ent, ent, SAY_TELL, VOICECHAT_DEATHINSULT, qfalse );
|
|
|
|
}
|
|
|
|
ent->enemy = NULL;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// insult someone you just killed
|
|
|
|
if (ent->client->lastkilled_client >= 0 && ent->client->lastkilled_client != ent->s.number) {
|
|
|
|
who = g_entities + ent->client->lastkilled_client;
|
|
|
|
if (who->client) {
|
|
|
|
// who is the person I just killed
|
|
|
|
if (who->client->lasthurt_mod == MOD_GAUNTLET) {
|
|
|
|
if (!(who->r.svFlags & SVF_BOT)) {
|
|
|
|
G_Voice( ent, who, SAY_TELL, VOICECHAT_KILLGAUNTLET, qfalse ); // and I killed them with a gauntlet
|
|
|
|
}
|
|
|
|
if (!(ent->r.svFlags & SVF_BOT)) {
|
|
|
|
G_Voice( ent, ent, SAY_TELL, VOICECHAT_KILLGAUNTLET, qfalse );
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!(who->r.svFlags & SVF_BOT)) {
|
|
|
|
G_Voice( ent, who, SAY_TELL, VOICECHAT_KILLINSULT, qfalse ); // and I killed them with something else
|
|
|
|
}
|
|
|
|
if (!(ent->r.svFlags & SVF_BOT)) {
|
|
|
|
G_Voice( ent, ent, SAY_TELL, VOICECHAT_KILLINSULT, qfalse );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ent->client->lastkilled_client = -1;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (g_gametype.integer >= GT_TEAM) {
|
|
|
|
// praise a team mate who just got a reward
|
|
|
|
for(i = 0; i < MAX_CLIENTS; i++) {
|
|
|
|
who = g_entities + i;
|
|
|
|
if (who->client && who != ent && who->client->sess.sessionTeam == ent->client->sess.sessionTeam) {
|
|
|
|
if (who->client->rewardTime > level.time) {
|
|
|
|
if (!(who->r.svFlags & SVF_BOT)) {
|
|
|
|
G_Voice( ent, who, SAY_TELL, VOICECHAT_PRAISE, qfalse );
|
|
|
|
}
|
|
|
|
if (!(ent->r.svFlags & SVF_BOT)) {
|
|
|
|
G_Voice( ent, ent, SAY_TELL, VOICECHAT_PRAISE, qfalse );
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// just say something
|
|
|
|
G_Voice( ent, NULL, SAY_ALL, VOICECHAT_TAUNT, qfalse );
|
|
|
|
}
|
2012-09-15 03:03:44 +00:00
|
|
|
#endif
|
2011-02-18 14:31:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static char *gc_orders[] = {
|
|
|
|
"hold your position",
|
|
|
|
"hold this position",
|
|
|
|
"come here",
|
|
|
|
"cover me",
|
|
|
|
"guard location",
|
|
|
|
"search and destroy",
|
|
|
|
"report"
|
|
|
|
};
|
|
|
|
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
static const int numgc_orders = ARRAY_LEN( gc_orders );
|
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
void Cmd_GameCommand_f( gentity_t *ent ) {
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
int targetNum;
|
|
|
|
gentity_t *target;
|
|
|
|
int order;
|
|
|
|
char arg[MAX_TOKEN_CHARS];
|
2011-02-18 14:31:32 +00:00
|
|
|
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
if ( trap_Argc() != 3 ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, va( "print \"Usage: gc <player id> <order 0-%d>\n\"", numgc_orders - 1 ) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
trap_Argv( 2, arg, sizeof( arg ) );
|
|
|
|
order = atoi( arg );
|
|
|
|
|
|
|
|
if ( order < 0 || order >= numgc_orders ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, va("print \"Bad order: %i\n\"", order));
|
|
|
|
return;
|
|
|
|
}
|
2011-02-18 14:31:32 +00:00
|
|
|
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
trap_Argv( 1, arg, sizeof( arg ) );
|
2017-07-10 01:33:41 +00:00
|
|
|
targetNum = ClientNumberFromString( ent, arg, qtrue, qtrue );
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
if ( targetNum == -1 ) {
|
2011-02-18 14:31:32 +00:00
|
|
|
return;
|
|
|
|
}
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
|
|
|
|
target = &g_entities[targetNum];
|
|
|
|
if ( !target->inuse || !target->client ) {
|
2011-02-18 14:31:32 +00:00
|
|
|
return;
|
|
|
|
}
|
ioquake3 resync to revision 2369 from 2317.
Some revision messages:
Cache servers for each master server in q3_ui, otherwise servers from last updated master for shown for all Internet# sources.
Play correct team sounds when in spectator mode and following a player.
Check last listener number instead of clc.clientNum in S_AL_HearingThroughEntity so sound work correctly when spectate following a client. (Related to bug 5741.)
When in third person, don't play player's sounds as full volume in Base sound system. OpenAL already does this. (Related to bug 5741.)
really fix the confusion with game entity and refentity numbers
to further reduce confusion, rename constants like MAX_ENTITIES to MAX_REFENTITIES
Added Rend2, an alternate renderer. (Bug #4358)
Fix restoring fs_game when default.cfg is missing.
Fix restoring old fs_game upon leaving a server. Patch by Ensiform.
Change more operator commands to require sv_running to be usable. Patch by Ensiform.
Fix some "> MAX_*" to be ">= MAX_*".
Fix follow command to find clients whose name begins with a number.
Fix up "gc" command, make it more like "tell". Based on patch by Ensiform.
Add usage messages for gc, tell, vtell, and votell commands.
Check player names in gc, tell, vtell, and votell commands.
#5799 - Change messagemode text box to display colors like in console input box.
Improve "play" command, based on a patch from Ensiform.
Check for invalid filename in OpenAL's RegisterSound function.
Changed Base sound system to warn not error when sound filename is empty or too long.
Remove references to non-existent functions CM_MarkFragments and CM_LerpTag.
2012-12-06 07:07:19 +00:00
|
|
|
|
|
|
|
G_LogPrintf( "tell: %s to %s: %s\n", ent->client->pers.netname, target->client->pers.netname, gc_orders[order] );
|
|
|
|
G_Say( ent, target, SAY_TELL, gc_orders[order] );
|
|
|
|
// don't tell to the player self if it was already directed to this player
|
|
|
|
// also don't send the chat back to a bot
|
|
|
|
if ( ent != target && !(ent->r.svFlags & SVF_BOT)) {
|
|
|
|
G_Say( ent, ent, SAY_TELL, gc_orders[order] );
|
|
|
|
}
|
2011-02-18 14:31:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_Where_f
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Cmd_Where_f( gentity_t *ent ) {
|
2011-08-10 21:49:38 +00:00
|
|
|
trap_SendServerCommand( ent-g_entities, va("print \"%s\n\"", vtos(ent->r.currentOrigin) ) );
|
2011-02-18 14:31:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const char *gameNames[] = {
|
|
|
|
"Free For All",
|
|
|
|
"Tournament",
|
|
|
|
"Single Player",
|
|
|
|
"Team Deathmatch",
|
|
|
|
"Capture the Flag",
|
|
|
|
"One Flag CTF",
|
|
|
|
"Overload",
|
|
|
|
"Harvester"
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_CallVote_f
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Cmd_CallVote_f( gentity_t *ent ) {
|
2017-11-17 03:37:02 +00:00
|
|
|
char* c;
|
2011-02-18 14:31:32 +00:00
|
|
|
int i;
|
|
|
|
char arg1[MAX_STRING_TOKENS];
|
|
|
|
char arg2[MAX_STRING_TOKENS];
|
|
|
|
|
|
|
|
if ( !g_allowVote.integer ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Voting not allowed here.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( level.voteTime ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"A vote is already in progress.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( ent->client->pers.voteCount >= MAX_VOTE_COUNT ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"You have called the maximum number of votes.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Q3Rally Code Start - fixed callvote error
|
|
|
|
|
|
|
|
if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Not allowed to call a vote as spectator.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// END
|
|
|
|
|
|
|
|
// make sure it is a valid command to vote on
|
|
|
|
trap_Argv( 1, arg1, sizeof( arg1 ) );
|
|
|
|
trap_Argv( 2, arg2, sizeof( arg2 ) );
|
|
|
|
|
2017-11-17 03:37:02 +00:00
|
|
|
// check for command separators in arg2
|
|
|
|
for( c = arg2; *c; ++c) {
|
|
|
|
switch(*c) {
|
|
|
|
case '\n':
|
|
|
|
case '\r':
|
|
|
|
case ';':
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string.\n\"" );
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
2011-02-18 14:31:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// STONELANCE
|
|
|
|
if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR &&
|
|
|
|
( !Q_stricmp( arg1, "kick" ) || !Q_stricmp( arg1, "clientkick" ) ) ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Not allowed to call a vote as spectator.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// END
|
|
|
|
|
|
|
|
if ( !Q_stricmp( arg1, "map_restart" ) ) {
|
|
|
|
} else if ( !Q_stricmp( arg1, "nextmap" ) ) {
|
|
|
|
} else if ( !Q_stricmp( arg1, "map" ) ) {
|
|
|
|
} else if ( !Q_stricmp( arg1, "g_gametype" ) ) {
|
|
|
|
} else if ( !Q_stricmp( arg1, "kick" ) ) {
|
|
|
|
} else if ( !Q_stricmp( arg1, "clientkick" ) ) {
|
|
|
|
} else if ( !Q_stricmp( arg1, "g_doWarmup" ) ) {
|
|
|
|
} else if ( !Q_stricmp( arg1, "timelimit" ) ) {
|
|
|
|
} else if ( !Q_stricmp( arg1, "fraglimit" ) ) {
|
|
|
|
} else {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string.\n\"" );
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Vote commands are: map_restart, nextmap, map <mapname>, g_gametype <n>, kick <player>, clientkick <clientnum>, g_doWarmup, timelimit <time>, fraglimit <frags>.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// if there is still a vote to be executed
|
|
|
|
if ( level.voteExecuteTime ) {
|
2017-07-10 01:33:41 +00:00
|
|
|
// don't start a vote when map change or restart is in progress
|
|
|
|
if ( !Q_stricmpn( level.voteString, "map", 3 )
|
|
|
|
|| !Q_stricmpn( level.voteString, "nextmap", 7 ) ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Vote after map change.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
level.voteExecuteTime = 0;
|
|
|
|
trap_SendConsoleCommand( EXEC_APPEND, va("%s\n", level.voteString ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// special case for g_gametype, check for bad values
|
|
|
|
if ( !Q_stricmp( arg1, "g_gametype" ) ) {
|
|
|
|
i = atoi( arg2 );
|
|
|
|
// STONELANCE - removed gametype
|
|
|
|
// if( i == GT_SINGLE_PLAYER || i < GT_FFA || i >= GT_MAX_GAME_TYPE) {
|
|
|
|
if( i == GT_SINGLE_PLAYER || i < GT_RACING || i >= GT_MAX_GAME_TYPE) {
|
|
|
|
// END
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Invalid gametype.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Com_sprintf( level.voteString, sizeof( level.voteString ), "%s %d", arg1, i );
|
|
|
|
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s %s", arg1, gameNames[i] );
|
|
|
|
} else if ( !Q_stricmp( arg1, "map" ) ) {
|
|
|
|
// special case for map changes, we want to reset the nextmap setting
|
|
|
|
// this allows a player to change maps, but not upset the map rotation
|
|
|
|
char s[MAX_STRING_CHARS];
|
|
|
|
|
|
|
|
trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof(s) );
|
|
|
|
if (*s) {
|
|
|
|
Com_sprintf( level.voteString, sizeof( level.voteString ), "%s %s; set nextmap \"%s\"", arg1, arg2, s );
|
|
|
|
} else {
|
|
|
|
Com_sprintf( level.voteString, sizeof( level.voteString ), "%s %s", arg1, arg2 );
|
|
|
|
}
|
|
|
|
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
|
|
|
|
} else if ( !Q_stricmp( arg1, "nextmap" ) ) {
|
|
|
|
char s[MAX_STRING_CHARS];
|
|
|
|
|
|
|
|
trap_Cvar_VariableStringBuffer( "nextmap", s, sizeof(s) );
|
|
|
|
if (!*s) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"nextmap not set.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Com_sprintf( level.voteString, sizeof( level.voteString ), "vstr nextmap");
|
|
|
|
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
|
2017-07-10 01:33:41 +00:00
|
|
|
} else if ( !Q_stricmp( arg1, "clientkick" ) || !Q_stricmp( arg1, "kick" ) ) {
|
|
|
|
i = ClientNumberFromString( ent, arg2, !Q_stricmp( arg1, "clientkick" ), !Q_stricmp( arg1, "kick" ) );
|
|
|
|
if ( i == -1 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( level.clients[i].pers.localClient ) {
|
|
|
|
trap_SendServerCommand( ent - g_entities, "print \"Cannot kick host player.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Com_sprintf( level.voteString, sizeof( level.voteString ), "clientkick %d", i );
|
|
|
|
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "kick %s", level.clients[i].pers.netname );
|
2011-02-18 14:31:32 +00:00
|
|
|
} else {
|
|
|
|
Com_sprintf( level.voteString, sizeof( level.voteString ), "%s \"%s\"", arg1, arg2 );
|
|
|
|
Com_sprintf( level.voteDisplayString, sizeof( level.voteDisplayString ), "%s", level.voteString );
|
|
|
|
}
|
|
|
|
|
|
|
|
trap_SendServerCommand( -1, va("print \"%s called a vote.\n\"", ent->client->pers.netname ) );
|
|
|
|
|
2017-07-10 01:33:41 +00:00
|
|
|
// start the voting, the caller automatically votes yes
|
2011-02-18 14:31:32 +00:00
|
|
|
level.voteTime = level.time;
|
|
|
|
level.voteYes = 1;
|
|
|
|
level.voteNo = 0;
|
|
|
|
|
|
|
|
for ( i = 0 ; i < level.maxclients ; i++ ) {
|
|
|
|
level.clients[i].ps.eFlags &= ~EF_VOTED;
|
|
|
|
}
|
|
|
|
ent->client->ps.eFlags |= EF_VOTED;
|
|
|
|
|
|
|
|
trap_SetConfigstring( CS_VOTE_TIME, va("%i", level.voteTime ) );
|
|
|
|
trap_SetConfigstring( CS_VOTE_STRING, level.voteDisplayString );
|
|
|
|
trap_SetConfigstring( CS_VOTE_YES, va("%i", level.voteYes ) );
|
|
|
|
trap_SetConfigstring( CS_VOTE_NO, va("%i", level.voteNo ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_Vote_f
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Cmd_Vote_f( gentity_t *ent ) {
|
|
|
|
char msg[64];
|
|
|
|
|
|
|
|
if ( !level.voteTime ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"No vote in progress.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( ent->client->ps.eFlags & EF_VOTED ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Vote already cast.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Not allowed to vote as spectator.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Vote cast.\n\"" );
|
|
|
|
|
|
|
|
ent->client->ps.eFlags |= EF_VOTED;
|
|
|
|
|
|
|
|
trap_Argv( 1, msg, sizeof( msg ) );
|
|
|
|
|
2017-07-10 01:33:41 +00:00
|
|
|
if ( tolower( msg[0] ) == 'y' || msg[0] == '1' ) {
|
2011-02-18 14:31:32 +00:00
|
|
|
level.voteYes++;
|
|
|
|
trap_SetConfigstring( CS_VOTE_YES, va("%i", level.voteYes ) );
|
|
|
|
} else {
|
|
|
|
level.voteNo++;
|
|
|
|
trap_SetConfigstring( CS_VOTE_NO, va("%i", level.voteNo ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// a majority will be determined in CheckVote, which will also account
|
|
|
|
// for players entering or leaving
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_CallTeamVote_f
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Cmd_CallTeamVote_f( gentity_t *ent ) {
|
2017-08-30 07:09:41 +00:00
|
|
|
char* c;
|
2011-02-18 14:31:32 +00:00
|
|
|
int i, team, cs_offset;
|
|
|
|
char arg1[MAX_STRING_TOKENS];
|
|
|
|
char arg2[MAX_STRING_TOKENS];
|
|
|
|
|
|
|
|
team = ent->client->sess.sessionTeam;
|
|
|
|
if ( team == TEAM_RED )
|
|
|
|
cs_offset = 0;
|
|
|
|
else if ( team == TEAM_BLUE )
|
|
|
|
cs_offset = 1;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( !g_allowVote.integer ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Voting not allowed here.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( level.teamVoteTime[cs_offset] ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"A team vote is already in progress.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( ent->client->pers.teamVoteCount >= MAX_VOTE_COUNT ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"You have called the maximum number of team votes.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Not allowed to call a vote as spectator.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// make sure it is a valid command to vote on
|
|
|
|
trap_Argv( 1, arg1, sizeof( arg1 ) );
|
|
|
|
arg2[0] = '\0';
|
|
|
|
for ( i = 2; i < trap_Argc(); i++ ) {
|
|
|
|
if (i > 2)
|
|
|
|
strcat(arg2, " ");
|
|
|
|
trap_Argv( i, &arg2[strlen(arg2)], sizeof( arg2 ) - strlen(arg2) );
|
|
|
|
}
|
|
|
|
|
2017-08-30 07:09:41 +00:00
|
|
|
// check for command separators in arg2
|
|
|
|
for( c = arg2; *c; ++c) {
|
|
|
|
switch(*c) {
|
|
|
|
case '\n':
|
|
|
|
case '\r':
|
|
|
|
case ';':
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string.\n\"" );
|
|
|
|
return;
|
|
|
|
break;
|
|
|
|
}
|
2011-02-18 14:31:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !Q_stricmp( arg1, "leader" ) ) {
|
|
|
|
char netname[MAX_NETNAME], leader[MAX_NETNAME];
|
|
|
|
|
|
|
|
if ( !arg2[0] ) {
|
|
|
|
i = ent->client->ps.clientNum;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// numeric values are just slot numbers
|
|
|
|
for (i = 0; i < 3; i++) {
|
|
|
|
if ( !arg2[i] || arg2[i] < '0' || arg2[i] > '9' )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( i >= 3 || !arg2[i]) {
|
|
|
|
i = atoi( arg2 );
|
|
|
|
if ( i < 0 || i >= level.maxclients ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, va("print \"Bad client slot: %i\n\"", i) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !g_entities[i].inuse ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, va("print \"Client %i is not active\n\"", i) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Q_strncpyz(leader, arg2, sizeof(leader));
|
|
|
|
Q_CleanStr(leader);
|
|
|
|
for ( i = 0 ; i < level.maxclients ; i++ ) {
|
|
|
|
if ( level.clients[i].pers.connected == CON_DISCONNECTED )
|
|
|
|
continue;
|
|
|
|
if (level.clients[i].sess.sessionTeam != team)
|
|
|
|
continue;
|
|
|
|
Q_strncpyz(netname, level.clients[i].pers.netname, sizeof(netname));
|
|
|
|
Q_CleanStr(netname);
|
|
|
|
if ( !Q_stricmp(netname, leader) ) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( i >= level.maxclients ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, va("print \"%s is not a valid player on your team.\n\"", arg2) );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Com_sprintf(arg2, sizeof(arg2), "%d", i);
|
|
|
|
} else {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Invalid vote string.\n\"" );
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Team vote commands are: leader <player>.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Com_sprintf( level.teamVoteString[cs_offset], sizeof( level.teamVoteString[cs_offset] ), "%s %s", arg1, arg2 );
|
|
|
|
|
|
|
|
for ( i = 0 ; i < level.maxclients ; i++ ) {
|
|
|
|
if ( level.clients[i].pers.connected == CON_DISCONNECTED )
|
|
|
|
continue;
|
|
|
|
if (level.clients[i].sess.sessionTeam == team)
|
|
|
|
trap_SendServerCommand( i, va("print \"%s called a team vote.\n\"", ent->client->pers.netname ) );
|
|
|
|
}
|
|
|
|
|
2017-07-10 01:33:41 +00:00
|
|
|
// start the voting, the caller automatically votes yes
|
2011-02-18 14:31:32 +00:00
|
|
|
level.teamVoteTime[cs_offset] = level.time;
|
|
|
|
level.teamVoteYes[cs_offset] = 1;
|
|
|
|
level.teamVoteNo[cs_offset] = 0;
|
|
|
|
|
|
|
|
for ( i = 0 ; i < level.maxclients ; i++ ) {
|
|
|
|
if (level.clients[i].sess.sessionTeam == team)
|
|
|
|
level.clients[i].ps.eFlags &= ~EF_TEAMVOTED;
|
|
|
|
}
|
|
|
|
ent->client->ps.eFlags |= EF_TEAMVOTED;
|
|
|
|
|
|
|
|
trap_SetConfigstring( CS_TEAMVOTE_TIME + cs_offset, va("%i", level.teamVoteTime[cs_offset] ) );
|
|
|
|
trap_SetConfigstring( CS_TEAMVOTE_STRING + cs_offset, level.teamVoteString[cs_offset] );
|
|
|
|
trap_SetConfigstring( CS_TEAMVOTE_YES + cs_offset, va("%i", level.teamVoteYes[cs_offset] ) );
|
|
|
|
trap_SetConfigstring( CS_TEAMVOTE_NO + cs_offset, va("%i", level.teamVoteNo[cs_offset] ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
==================
|
|
|
|
Cmd_TeamVote_f
|
|
|
|
==================
|
|
|
|
*/
|
|
|
|
void Cmd_TeamVote_f( gentity_t *ent ) {
|
|
|
|
int team, cs_offset;
|
|
|
|
char msg[64];
|
|
|
|
|
|
|
|
team = ent->client->sess.sessionTeam;
|
|
|
|
if ( team == TEAM_RED )
|
|
|
|
cs_offset = 0;
|
|
|
|
else if ( team == TEAM_BLUE )
|
|
|
|
cs_offset = 1;
|
|
|
|
else
|
|
|
|
return;
|
|
|
|
|
|
|
|
if ( !level.teamVoteTime[cs_offset] ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"No team vote in progress.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( ent->client->ps.eFlags & EF_TEAMVOTED ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Team vote already cast.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) {
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Not allowed to vote as spectator.\n\"" );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Team vote cast.\n\"" );
|
|
|
|
|
|
|
|
ent->client->ps.eFlags |= EF_TEAMVOTED;
|
|
|
|
|
|
|
|
trap_Argv( 1, msg, sizeof( msg ) );
|
|
|
|
|
2017-07-10 01:33:41 +00:00
|
|
|
if ( tolower( msg[0] ) == 'y' || msg[0] == '1' ) {
|
2011-02-18 14:31:32 +00:00
|
|
|
level.teamVoteYes[cs_offset]++;
|
|
|
|
trap_SetConfigstring( CS_TEAMVOTE_YES + cs_offset, va("%i", level.teamVoteYes[cs_offset] ) );
|
|
|
|
} else {
|
|
|
|
level.teamVoteNo[cs_offset]++;
|
|
|
|
trap_SetConfigstring( CS_TEAMVOTE_NO + cs_offset, va("%i", level.teamVoteNo[cs_offset] ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
// a majority will be determined in TeamCheckVote, which will also account
|
|
|
|
// for players entering or leaving
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Cmd_SetViewpos_f
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void Cmd_SetViewpos_f( gentity_t *ent ) {
|
|
|
|
vec3_t origin, angles;
|
|
|
|
char buffer[MAX_TOKEN_CHARS];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if ( !g_cheats.integer ) {
|
2012-09-15 03:03:44 +00:00
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"Cheats are not enabled on this server.\n\"");
|
2011-02-18 14:31:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( trap_Argc() != 5 ) {
|
2012-09-15 03:03:44 +00:00
|
|
|
trap_SendServerCommand( ent-g_entities, "print \"usage: setviewpos x y z yaw\n\"");
|
2011-02-18 14:31:32 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
VectorClear( angles );
|
|
|
|
for ( i = 0 ; i < 3 ; i++ ) {
|
|
|
|
trap_Argv( i + 1, buffer, sizeof( buffer ) );
|
|
|
|
origin[i] = atof( buffer );
|
|
|
|
}
|
|
|
|
|
|
|
|
trap_Argv( 4, buffer, sizeof( buffer ) );
|
|
|
|
angles[YAW] = atof( buffer );
|
|
|
|
|
|
|
|
TeleportPlayer( ent, origin, angles );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-11-17 03:37:02 +00:00
|
|
|
|
2011-02-18 14:31:32 +00:00
|
|
|
/*
|
|
|
|
=================
|
|
|
|
Cmd_Stats_f
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void Cmd_Stats_f( gentity_t *ent ) {
|
|
|
|
/*
|
|
|
|
int max, n, i;
|
|
|
|
|
|
|
|
max = trap_AAS_PointReachabilityAreaIndex( NULL );
|
|
|
|
|
|
|
|
n = 0;
|
|
|
|
for ( i = 0; i < max; i++ ) {
|
|
|
|
if ( ent->client->areabits[i >> 3] & (1 << (i & 7)) )
|
|
|
|
n++;
|
|
|
|
}
|
|
|
|
|
|
|
|
//trap_SendServerCommand( ent-g_entities, va("print \"visited %d of %d areas\n\"", n, max));
|
|
|
|
trap_SendServerCommand( ent-g_entities, va("print \"%d%% level coverage\n\"", n * 100 / max));
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
// STONELANCE
|
|
|
|
void Cmd_SaveBPoints_f( gentity_t *other )
|
|
|
|
{
|
2021-05-05 18:38:41 +00:00
|
|
|
int i, j;
|
2011-02-18 14:31:32 +00:00
|
|
|
fileHandle_t f;
|
|
|
|
char buffer[256];
|
|
|
|
char serverinfo[MAX_INFO_STRING];
|
|
|
|
gentity_t *ent;
|
|
|
|
|
|
|
|
trap_GetServerinfo( serverinfo, sizeof(serverinfo) );
|
|
|
|
|
2021-05-05 18:38:41 +00:00
|
|
|
Com_sprintf( buffer, sizeof(buffer), "bezier/%s_bpd.txt", Info_ValueForKey( serverinfo, "mapname" ) );
|
2011-02-18 14:31:32 +00:00
|
|
|
Com_Printf( "Writing out bezier path information to: '%s'\n", buffer );
|
|
|
|
trap_FS_FOpenFile( buffer, &f, FS_WRITE );
|
|
|
|
|
|
|
|
for (i = 1; i < 40; i++)
|
|
|
|
{
|
|
|
|
ent = NULL;
|
|
|
|
while ((ent = G_Find (ent, FOFS(classname), "rally_checkpoint")) != NULL) {
|
|
|
|
if ( ent->number == i )
|
|
|
|
{
|
|
|
|
Com_sprintf( buffer, sizeof(buffer), "%i:\n\"bezierPos\" \"%i %i %i\"\n\"bezierDir\" \"%i %i %i\"\n", i, (int)ent->s.origin2[0], (int)ent->s.origin2[1], (int)ent->s.origin2[2], (int)ent->s.angles2[0], (int)ent->s.angles2[1], (int)ent->s.angles2[2] );
|
|
|
|
trap_FS_Write( buffer, strlen(buffer), f );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( ent == NULL )
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
trap_FS_FCloseFile( f );
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cmd_MoveBPoint_f( gentity_t *other )
|
|
|
|
{
|
|
|
|
char buffer[16];
|
|
|
|
int curCheckpoint;
|
|
|
|
vec3_t delta;
|
|
|
|
gentity_t *ent = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
trap_Argv( 1, buffer, sizeof( buffer ) );
|
|
|
|
curCheckpoint = atoi(buffer);
|
|
|
|
|
|
|
|
trap_Argv( 2, buffer, sizeof( buffer ) );
|
|
|
|
delta[0] = atof(buffer);
|
|
|
|
|
|
|
|
trap_Argv( 3, buffer, sizeof( buffer ) );
|
|
|
|
delta[1] = atof(buffer);
|
|
|
|
|
|
|
|
trap_Argv( 4, buffer, sizeof( buffer ) );
|
|
|
|
delta[2] = atof(buffer);
|
|
|
|
|
|
|
|
Com_Printf( "Moving Checkpoint %i by (%f %f %f)\n", curCheckpoint, delta[0], delta[1], delta[2] );
|
|
|
|
|
|
|
|
while ((ent = G_Find (ent, FOFS(classname), "rally_checkpoint")) != NULL) {
|
|
|
|
if ( ent->number == curCheckpoint )
|
|
|
|
{
|
|
|
|
VectorAdd( ent->s.origin2, delta, ent->s.origin2 );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Cmd_MoveBHandle_f( gentity_t *other )
|
|
|
|
{
|
|
|
|
char buffer[16];
|
|
|
|
int curCheckpoint;
|
|
|
|
vec3_t delta;
|
|
|
|
gentity_t *ent = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
trap_Argv( 1, buffer, sizeof( buffer ) );
|
|
|
|
curCheckpoint = atoi(buffer);
|
|
|
|
|
|
|
|
trap_Argv( 2, buffer, sizeof( buffer ) );
|
|
|
|
delta[0] = atof(buffer);
|
|
|
|
|
|
|
|
trap_Argv( 3, buffer, sizeof( buffer ) );
|
|
|
|
delta[1] = atof(buffer);
|
|
|
|
|
|
|
|
trap_Argv( 4, buffer, sizeof( buffer ) );
|
|
|
|
delta[2] = atof(buffer);
|
|
|
|
|
|
|
|
Com_Printf( "Moving Checkpoint %i by (%f %f %f)\n", curCheckpoint, delta[0], delta[1], delta[2] );
|
|
|
|
|
|
|
|
while ((ent = G_Find (ent, FOFS(classname), "rally_checkpoint")) != NULL) {
|
|
|
|
if ( ent->number == curCheckpoint )
|
|
|
|
{
|
|
|
|
VectorAdd( ent->s.angles2, delta, ent->s.angles2 );
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// END
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
=================
|
|
|
|
ClientCommand
|
|
|
|
=================
|
|
|
|
*/
|
|
|
|
void ClientCommand( int clientNum ) {
|
|
|
|
gentity_t *ent;
|
|
|
|
char cmd[MAX_TOKEN_CHARS];
|
|
|
|
// STONELANCE
|
|
|
|
char buffer[MAX_TOKEN_CHARS];
|
|
|
|
char name[MAX_TOKEN_CHARS];
|
|
|
|
// END
|
|
|
|
|
|
|
|
ent = g_entities + clientNum;
|
2012-09-15 03:03:44 +00:00
|
|
|
if (!ent->client || ent->client->pers.connected != CON_CONNECTED) {
|
2017-07-10 01:33:41 +00:00
|
|
|
if (ent->client && ent->client->pers.localClient) {
|
|
|
|
// Handle early team command sent by UI when starting a local
|
|
|
|
// team play game.
|
|
|
|
trap_Argv( 0, cmd, sizeof( cmd ) );
|
|
|
|
if (Q_stricmp (cmd, "team") == 0) {
|
|
|
|
Cmd_Team_f (ent);
|
|
|
|
}
|
|
|
|
}
|
2011-02-18 14:31:32 +00:00
|
|
|
return; // not fully in game yet
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
trap_Argv( 0, cmd, sizeof( cmd ) );
|
|
|
|
|
|
|
|
if (Q_stricmp (cmd, "say") == 0) {
|
|
|
|
Cmd_Say_f (ent, SAY_ALL, qfalse);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Q_stricmp (cmd, "say_team") == 0) {
|
|
|
|
Cmd_Say_f (ent, SAY_TEAM, qfalse);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Q_stricmp (cmd, "tell") == 0) {
|
|
|
|
Cmd_Tell_f ( ent );
|
|
|
|
return;
|
|
|
|
}
|
2012-09-15 03:03:44 +00:00
|
|
|
#ifdef MISSIONPACK
|
2011-02-18 14:31:32 +00:00
|
|
|
if (Q_stricmp (cmd, "vsay") == 0) {
|
|
|
|
Cmd_Voice_f (ent, SAY_ALL, qfalse, qfalse);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Q_stricmp (cmd, "vsay_team") == 0) {
|
|
|
|
Cmd_Voice_f (ent, SAY_TEAM, qfalse, qfalse);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Q_stricmp (cmd, "vtell") == 0) {
|
|
|
|
Cmd_VoiceTell_f ( ent, qfalse );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Q_stricmp (cmd, "vosay") == 0) {
|
|
|
|
Cmd_Voice_f (ent, SAY_ALL, qfalse, qtrue);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Q_stricmp (cmd, "vosay_team") == 0) {
|
|
|
|
Cmd_Voice_f (ent, SAY_TEAM, qfalse, qtrue);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Q_stricmp (cmd, "votell") == 0) {
|
|
|
|
Cmd_VoiceTell_f ( ent, qtrue );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Q_stricmp (cmd, "vtaunt") == 0) {
|
|
|
|
Cmd_VoiceTaunt_f ( ent );
|
|
|
|
return;
|
|
|
|
}
|
2012-09-15 03:03:44 +00:00
|
|
|
#endif
|
2011-02-18 14:31:32 +00:00
|
|
|
if (Q_stricmp (cmd, "score") == 0) {
|
|
|
|
Cmd_Score_f (ent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ignore all other commands when at intermission
|
|
|
|
if (level.intermissiontime) {
|
|
|
|
Cmd_Say_f (ent, qfalse, qtrue);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Q_stricmp (cmd, "give") == 0)
|
|
|
|
Cmd_Give_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "god") == 0)
|
|
|
|
Cmd_God_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "notarget") == 0)
|
|
|
|
Cmd_Notarget_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "noclip") == 0)
|
|
|
|
Cmd_Noclip_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "kill") == 0)
|
|
|
|
Cmd_Kill_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "teamtask") == 0)
|
|
|
|
Cmd_TeamTask_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "levelshot") == 0)
|
|
|
|
Cmd_LevelShot_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "follow") == 0)
|
|
|
|
Cmd_Follow_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "follownext") == 0)
|
|
|
|
Cmd_FollowCycle_f (ent, 1);
|
|
|
|
else if (Q_stricmp (cmd, "followprev") == 0)
|
|
|
|
Cmd_FollowCycle_f (ent, -1);
|
|
|
|
else if (Q_stricmp (cmd, "team") == 0)
|
|
|
|
Cmd_Team_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "where") == 0)
|
|
|
|
Cmd_Where_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "callvote") == 0)
|
|
|
|
Cmd_CallVote_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "vote") == 0)
|
|
|
|
Cmd_Vote_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "callteamvote") == 0)
|
|
|
|
Cmd_CallTeamVote_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "teamvote") == 0)
|
|
|
|
Cmd_TeamVote_f (ent);
|
|
|
|
else if (Q_stricmp (cmd, "gc") == 0)
|
|
|
|
Cmd_GameCommand_f( ent );
|
|
|
|
else if (Q_stricmp (cmd, "setviewpos") == 0)
|
|
|
|
Cmd_SetViewpos_f( ent );
|
|
|
|
else if (Q_stricmp (cmd, "stats") == 0)
|
|
|
|
Cmd_Stats_f( ent );
|
|
|
|
// STONELANCE
|
|
|
|
else if (Q_stricmp (cmd, "gearUp") == 0){
|
|
|
|
if (!ent->client->pers.manualShift)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ent->client->car.gear < 1)
|
|
|
|
ent->client->car.gear++;
|
|
|
|
}
|
|
|
|
else if (Q_stricmp (cmd, "gearDown") == 0){
|
|
|
|
if (!ent->client->pers.manualShift)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (ent->client->car.gear > 0)
|
|
|
|
ent->client->car.gear = 0;
|
|
|
|
else if (ent->client->car.gear > -1)
|
|
|
|
ent->client->car.gear--;
|
|
|
|
}
|
|
|
|
/* automatically reset car after 3 seconds
|
|
|
|
else if (Q_stricmp (cmd, "resetCar") == 0){
|
|
|
|
Cmd_ResetCar_f( ent );
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
else if (Q_stricmp (cmd, "dropWeapon") == 0){
|
|
|
|
G_DropRearWeapon( ent );
|
|
|
|
}
|
|
|
|
else if (Q_stricmp (cmd, "mapstats") == 0){
|
|
|
|
trap_Argv( 1, buffer, sizeof( buffer ) );
|
|
|
|
trap_Argv( 2, name, sizeof( name ) );
|
|
|
|
|
|
|
|
G_PrintMapStats( ent, atoi(buffer), name );
|
|
|
|
}
|
|
|
|
else if (Q_stricmp (cmd, "times") == 0) {
|
|
|
|
Cmd_Times_f (ent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
else if (Q_stricmp (cmd, "headlights") == 0) {
|
|
|
|
Cmd_Headlight_Toggle_f (ent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
else if (Q_stricmp (cmd, "saveBPoints") == 0) {
|
|
|
|
Cmd_SaveBPoints_f (ent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (Q_stricmp (cmd, "moveBPoint") == 0) {
|
|
|
|
Cmd_MoveBPoint_f (ent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (Q_stricmp (cmd, "moveBHandle") == 0) {
|
|
|
|
Cmd_MoveBHandle_f (ent);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// END
|
|
|
|
else
|
|
|
|
trap_SendServerCommand( clientNum, va("print \"unknown cmd %s\n\"", cmd ) );
|
|
|
|
}
|
|
|
|
|