2001-02-19 21:15:25 +00:00
|
|
|
/*
|
|
|
|
teamplay.c
|
|
|
|
|
|
|
|
Teamplay enhancements ("proxy features")
|
|
|
|
|
|
|
|
Copyright (C) 2000 Anton Gavrilov (tonik@quake.ru)
|
|
|
|
|
|
|
|
This program 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.
|
|
|
|
|
|
|
|
This program 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 this program; if not, write to:
|
|
|
|
|
|
|
|
Free Software Foundation, Inc.
|
|
|
|
59 Temple Place - Suite 330
|
|
|
|
Boston, MA 02111-1307, USA
|
|
|
|
|
|
|
|
*/
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
2003-01-15 15:31:36 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
2001-11-05 07:23:51 +00:00
|
|
|
#include <ctype.h>
|
|
|
|
|
2002-07-31 05:19:03 +00:00
|
|
|
#include "QF/cbuf.h"
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cmd.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2022-05-26 07:11:50 +00:00
|
|
|
#include "QF/dstring.h"
|
2007-11-06 10:17:14 +00:00
|
|
|
#include "QF/gib.h"
|
2001-04-10 06:55:28 +00:00
|
|
|
#include "QF/model.h"
|
2001-11-05 07:23:51 +00:00
|
|
|
#include "QF/va.h"
|
|
|
|
#include "QF/skin.h"
|
2007-11-06 10:17:14 +00:00
|
|
|
#include "QF/sys.h"
|
|
|
|
#include "QF/teamplay.h"
|
2001-05-09 17:57:57 +00:00
|
|
|
|
2022-05-05 05:41:46 +00:00
|
|
|
#include "QF/scene/scene.h"
|
|
|
|
|
2001-08-28 03:47:10 +00:00
|
|
|
#include "compat.h"
|
2001-02-19 21:15:25 +00:00
|
|
|
|
2021-03-11 02:38:33 +00:00
|
|
|
#include "client/locs.h"
|
2022-03-04 16:48:10 +00:00
|
|
|
#include "client/world.h"
|
2021-03-11 02:38:33 +00:00
|
|
|
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "qw/bothdefs.h"
|
|
|
|
#include "qw/include/cl_input.h"
|
|
|
|
#include "qw/include/client.h"
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
static qboolean died = false, recorded_location = false;
|
2021-03-11 07:19:49 +00:00
|
|
|
static vec4f_t death_location, last_recorded_location;
|
2001-08-28 03:47:10 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
int cl_deadbodyfilter;
|
|
|
|
static cvar_t cl_deadbodyfilter_cvar = {
|
|
|
|
.name = "cl_deadbodyfilter",
|
|
|
|
.description =
|
|
|
|
"Hide dead player models",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &cl_deadbodyfilter },
|
|
|
|
};
|
|
|
|
int cl_gibfilter;
|
|
|
|
static cvar_t cl_gibfilter_cvar = {
|
|
|
|
.name = "cl_gibfilter",
|
|
|
|
.description =
|
|
|
|
"Hide gibs",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &cl_gibfilter },
|
|
|
|
};
|
|
|
|
int cl_parsesay;
|
|
|
|
static cvar_t cl_parsesay_cvar = {
|
|
|
|
.name = "cl_parsesay",
|
|
|
|
.description =
|
|
|
|
"Use .loc files to find your present location when you put %l in "
|
|
|
|
"messages",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &cl_parsesay },
|
|
|
|
};
|
|
|
|
int cl_nofake;
|
|
|
|
static cvar_t cl_nofake_cvar = {
|
|
|
|
.name = "cl_nofake",
|
|
|
|
.description =
|
|
|
|
"Unhide fake messages",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &cl_nofake },
|
|
|
|
};
|
|
|
|
float cl_freply;
|
|
|
|
static cvar_t cl_freply_cvar = {
|
|
|
|
.name = "cl_freply",
|
|
|
|
.description =
|
|
|
|
"Delay between replies to f_*. 0 disables. Minimum suggested setting "
|
|
|
|
"is 20",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_float, .value = &cl_freply },
|
|
|
|
};
|
2001-08-28 03:47:10 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
Team_BestWeaponImpulse (void)
|
|
|
|
{
|
2002-09-11 18:58:19 +00:00
|
|
|
int best, i, imp, items;
|
2001-08-28 03:47:10 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
items = cl.stats[STAT_ITEMS];
|
|
|
|
best = 0;
|
|
|
|
|
|
|
|
for (i = Cmd_Argc () - 1; i > 0; i--) {
|
|
|
|
imp = atoi (Cmd_Argv (i));
|
|
|
|
if (imp < 1 || imp > 8)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
switch (imp) {
|
2001-08-28 03:47:10 +00:00
|
|
|
case 1:
|
|
|
|
if (items & IT_AXE)
|
|
|
|
best = 1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (items & IT_SHOTGUN && cl.stats[STAT_SHELLS] >= 1)
|
|
|
|
best = 2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (items & IT_SUPER_SHOTGUN && cl.stats[STAT_SHELLS] >= 2)
|
|
|
|
best = 3;
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (items & IT_NAILGUN && cl.stats[STAT_NAILS] >= 1)
|
|
|
|
best = 4;
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (items & IT_SUPER_NAILGUN && cl.stats[STAT_NAILS] >= 2)
|
|
|
|
best = 5;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
if (items & IT_GRENADE_LAUNCHER && cl.stats[STAT_ROCKETS] >= 1)
|
|
|
|
best = 6;
|
|
|
|
break;
|
|
|
|
case 7:
|
|
|
|
if (items & IT_ROCKET_LAUNCHER && cl.stats[STAT_ROCKETS] >= 1)
|
|
|
|
best = 7;
|
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
if (items & IT_LIGHTNING && cl.stats[STAT_CELLS] >= 1)
|
|
|
|
best = 8;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (best)
|
|
|
|
in_impulse = best;
|
|
|
|
}
|
|
|
|
|
2018-08-19 15:05:00 +00:00
|
|
|
//FIXME slow use of dstring
|
|
|
|
const char *
|
|
|
|
Team_ParseSay (dstring_t *buf, const char *s)
|
2001-02-19 21:15:25 +00:00
|
|
|
{
|
2018-08-19 15:05:00 +00:00
|
|
|
char chr, t2[128], t3[2];
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *t1;
|
2003-04-17 00:01:48 +00:00
|
|
|
size_t i, bracket;
|
2001-02-19 21:15:25 +00:00
|
|
|
static location_t *location = NULL;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (!cl_parsesay || (cl.fpd & FPD_NO_MACROS))
|
2001-02-19 21:15:25 +00:00
|
|
|
return s;
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
while (*s && (i <= sizeof (buf))) {
|
2001-10-27 04:34:53 +00:00
|
|
|
if ((*s == '%') && (s[1] != '\0')) {
|
2001-02-19 21:15:25 +00:00
|
|
|
t1 = NULL;
|
|
|
|
memset (t2, '\0', sizeof (t2));
|
|
|
|
memset (t3, '\0', sizeof (t3));
|
|
|
|
|
|
|
|
if ((s[1] == '[') && (s[3] == ']')) {
|
|
|
|
bracket = 1;
|
|
|
|
chr = s[2];
|
|
|
|
s += 4;
|
|
|
|
} else {
|
|
|
|
bracket = 0;
|
|
|
|
chr = s[1];
|
|
|
|
s += 2;
|
|
|
|
}
|
2002-09-11 18:58:19 +00:00
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
switch (chr) {
|
2001-08-28 03:47:10 +00:00
|
|
|
case '%':
|
|
|
|
t2[0] = '%';
|
|
|
|
t2[1] = 0;
|
|
|
|
t1 = t2;
|
|
|
|
break;
|
2004-05-17 00:31:56 +00:00
|
|
|
case 'S':
|
2001-08-28 03:47:10 +00:00
|
|
|
bracket = 0;
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
t1 = skin;
|
2001-08-28 03:47:10 +00:00
|
|
|
break;
|
|
|
|
case 'd':
|
|
|
|
bracket = 0;
|
|
|
|
if (died) {
|
|
|
|
location = locs_find (death_location);
|
2001-02-19 21:15:25 +00:00
|
|
|
if (location) {
|
|
|
|
recorded_location = true;
|
2021-03-11 07:19:49 +00:00
|
|
|
last_recorded_location = death_location;
|
2001-02-19 21:15:25 +00:00
|
|
|
t1 = location->name;
|
2001-08-28 03:47:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
goto location;
|
|
|
|
case 'r':
|
|
|
|
bracket = 0;
|
|
|
|
if (recorded_location) {
|
|
|
|
location = locs_find (last_recorded_location);
|
|
|
|
if (location) {
|
|
|
|
t1 = location->name;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
goto location;
|
|
|
|
case 'l':
|
|
|
|
location:
|
|
|
|
bracket = 0;
|
2022-03-01 02:43:23 +00:00
|
|
|
location = locs_find (cl.viewstate.player_origin);
|
2001-08-28 03:47:10 +00:00
|
|
|
if (location) {
|
|
|
|
recorded_location = true;
|
2022-03-01 02:43:23 +00:00
|
|
|
last_recorded_location = cl.viewstate.player_origin;
|
2001-08-28 03:47:10 +00:00
|
|
|
t1 = location->name;
|
|
|
|
} else
|
2003-04-10 01:36:02 +00:00
|
|
|
snprintf (t2, sizeof (t2), "Unknown!");
|
2001-08-28 03:47:10 +00:00
|
|
|
break;
|
|
|
|
case 'a':
|
|
|
|
if (bracket) {
|
|
|
|
if (cl.stats[STAT_ARMOR] > 50)
|
|
|
|
bracket = 0;
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
if (cl.stats[STAT_ITEMS] & IT_ARMOR3)
|
2022-03-30 18:00:24 +00:00
|
|
|
t3[0] = (char) ('R' | 0x80);
|
2001-02-19 21:15:25 +00:00
|
|
|
else if (cl.stats[STAT_ITEMS] & IT_ARMOR2)
|
2022-03-30 18:00:24 +00:00
|
|
|
t3[0] = (char) ('Y' | 0x80);
|
2001-02-19 21:15:25 +00:00
|
|
|
else if (cl.stats[STAT_ITEMS] & IT_ARMOR1)
|
2022-03-30 18:00:24 +00:00
|
|
|
t3[0] = (char) ('G' | 0x80);
|
2001-02-19 21:15:25 +00:00
|
|
|
else {
|
2022-03-30 18:00:24 +00:00
|
|
|
t2[0] = (char) ('N' | 0x80);
|
|
|
|
t2[1] = (char) ('O' | 0x80);
|
|
|
|
t2[2] = (char) ('N' | 0x80);
|
|
|
|
t2[3] = (char) ('E' | 0x80);
|
|
|
|
t2[4] = (char) ('!' | 0x80);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-08-28 03:47:10 +00:00
|
|
|
|
|
|
|
snprintf (t2, sizeof (t2), "%sa:%i", t3,
|
|
|
|
cl.stats[STAT_ARMOR]);
|
2018-08-19 15:05:00 +00:00
|
|
|
} else {
|
2001-08-28 03:47:10 +00:00
|
|
|
snprintf (t2, sizeof (t2), "%i", cl.stats[STAT_ARMOR]);
|
2018-08-19 15:05:00 +00:00
|
|
|
}
|
2001-08-28 03:47:10 +00:00
|
|
|
break;
|
|
|
|
case 'A':
|
|
|
|
bracket = 0;
|
|
|
|
if (cl.stats[STAT_ITEMS] & IT_ARMOR3)
|
2022-03-30 18:00:24 +00:00
|
|
|
t2[0] = (char) ('R' | 0x80);
|
2001-08-28 03:47:10 +00:00
|
|
|
else if (cl.stats[STAT_ITEMS] & IT_ARMOR2)
|
2022-03-30 18:00:24 +00:00
|
|
|
t2[0] = (char) ('Y' | 0x80);
|
2001-08-28 03:47:10 +00:00
|
|
|
else if (cl.stats[STAT_ITEMS] & IT_ARMOR1)
|
2022-03-30 18:00:24 +00:00
|
|
|
t2[0] = (char) ('G' | 0x80);
|
2001-08-28 03:47:10 +00:00
|
|
|
else {
|
2022-03-30 18:00:24 +00:00
|
|
|
t2[0] = (char) ('N' | 0x80);
|
|
|
|
t2[1] = (char) ('O' | 0x80);
|
|
|
|
t2[2] = (char) ('N' | 0x80);
|
|
|
|
t2[3] = (char) ('E' | 0x80);
|
|
|
|
t2[4] = (char) ('!' | 0x80);
|
2001-08-28 03:47:10 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'h':
|
|
|
|
if (bracket) {
|
|
|
|
if (cl.stats[STAT_HEALTH] > 50)
|
|
|
|
bracket = 0;
|
|
|
|
snprintf (t2, sizeof (t2), "h:%i",
|
|
|
|
cl.stats[STAT_HEALTH]);
|
|
|
|
} else
|
|
|
|
snprintf (t2, sizeof (t2), "%i", cl.stats[STAT_HEALTH]);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
bracket = 0;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!t1) {
|
|
|
|
if (!t2[0]) {
|
|
|
|
t2[0] = '%';
|
|
|
|
t2[1] = chr;
|
|
|
|
}
|
|
|
|
|
|
|
|
t1 = t2;
|
|
|
|
}
|
|
|
|
|
2018-08-19 15:05:00 +00:00
|
|
|
if (bracket) {
|
|
|
|
dstring_appendstr (buf, "\x90"); // '['
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
if (t1) {
|
2018-08-19 15:05:00 +00:00
|
|
|
dstring_appendstr (buf, t1);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2018-08-19 15:05:00 +00:00
|
|
|
if (bracket) {
|
|
|
|
dstring_appendstr (buf, "\x91"); // ']'
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
|
|
|
|
continue;
|
|
|
|
}
|
2018-08-19 15:05:00 +00:00
|
|
|
dstring_appendsubstr (buf, s++, 1);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2018-08-19 15:05:00 +00:00
|
|
|
return buf->str;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Team_Dead (void)
|
|
|
|
{
|
|
|
|
died = true;
|
2022-03-01 02:43:23 +00:00
|
|
|
death_location = cl.viewstate.player_origin;
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Team_NewMap (void)
|
|
|
|
{
|
|
|
|
char *mapname, *t1, *t2;
|
|
|
|
|
|
|
|
died = false;
|
|
|
|
recorded_location = false;
|
2022-05-05 05:41:46 +00:00
|
|
|
mapname = strdup (cl_world.scene->worldmodel->path);
|
|
|
|
t2 = malloc (sizeof (cl_world.scene->worldmodel->path));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!mapname || !t2)
|
|
|
|
Sys_Error ("Can't duplicate mapname!");
|
2001-08-28 03:47:10 +00:00
|
|
|
map_to_loc (mapname,t2);
|
2001-02-19 21:15:25 +00:00
|
|
|
t1 = strrchr (t2, '/');
|
|
|
|
if (!t1)
|
|
|
|
Sys_Error ("Can't find /!");
|
|
|
|
t1++; // skip over /
|
|
|
|
locs_reset ();
|
|
|
|
locs_load (t1);
|
|
|
|
free (mapname);
|
|
|
|
free (t2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Team_Init_Cvars (void)
|
|
|
|
{
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
Cvar_Register (&cl_deadbodyfilter_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_gibfilter_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_parsesay_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_nofake_cvar, 0, 0);
|
|
|
|
Cvar_Register (&cl_freply_cvar, 0, 0);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2001-08-28 03:47:10 +00:00
|
|
|
locs_loc
|
|
|
|
|
|
|
|
Location marker manipulation
|
2001-02-19 21:15:25 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-19 21:15:25 +00:00
|
|
|
locs_loc (void)
|
|
|
|
{
|
2001-08-28 03:47:10 +00:00
|
|
|
char locfile[MAX_OSPATH];
|
2002-08-27 16:28:58 +00:00
|
|
|
char *mapname;
|
2001-07-15 07:04:17 +00:00
|
|
|
const char *desc = NULL;
|
2002-08-27 16:28:58 +00:00
|
|
|
|
2001-08-28 03:47:10 +00:00
|
|
|
// FIXME: need to check to ensure you are actually in the game and alive.
|
2007-09-15 02:55:16 +00:00
|
|
|
if (Cmd_Argc () == 1 || strcmp (Cmd_Argv (1), "help") == 0) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("loc <add|delete|rename|move|save|zsave> [<description>] "
|
2001-08-28 03:47:10 +00:00
|
|
|
":Modifies location data, add|rename take <description> "
|
|
|
|
"parameter\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
return;
|
|
|
|
}
|
2022-05-05 05:41:46 +00:00
|
|
|
if (!cl_world.scene->worldmodel) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("No map loaded. Unable to work with location markers.\n");
|
2007-09-15 02:55:16 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-02-19 21:15:25 +00:00
|
|
|
if (Cmd_Argc () >= 3)
|
2001-07-10 18:25:54 +00:00
|
|
|
desc = Cmd_Args (2);
|
2022-05-05 05:41:46 +00:00
|
|
|
mapname = malloc (sizeof (cl_world.scene->worldmodel->path));
|
2001-02-19 21:15:25 +00:00
|
|
|
if (!mapname)
|
|
|
|
Sys_Error ("Can't duplicate mapname!");
|
2022-05-05 05:41:46 +00:00
|
|
|
map_to_loc (cl_world.scene->worldmodel->path, mapname);
|
2003-05-23 17:17:01 +00:00
|
|
|
snprintf (locfile, sizeof (locfile), "%s/%s",
|
2003-02-14 22:36:10 +00:00
|
|
|
qfs_gamedir->dir.def, mapname);
|
2003-03-21 21:25:44 +00:00
|
|
|
free (mapname);
|
2002-08-27 16:28:58 +00:00
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
if (strcasecmp (Cmd_Argv (1), "save") == 0) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (Cmd_Argc () == 2) {
|
2002-06-10 23:04:34 +00:00
|
|
|
locs_save (locfile, false);
|
2002-08-27 16:28:58 +00:00
|
|
|
} else
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("loc save :saves locs from memory into a .loc file\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
if (strcasecmp (Cmd_Argv (1), "zsave") == 0) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (Cmd_Argc () == 2) {
|
2002-06-10 23:04:34 +00:00
|
|
|
locs_save (locfile, true);
|
2001-02-19 21:15:25 +00:00
|
|
|
} else
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("loc save :saves locs from memory into a .loc file\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2002-08-27 16:28:58 +00:00
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
if (strcasecmp (Cmd_Argv (1), "add") == 0) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (Cmd_Argc () >= 3)
|
2022-03-01 02:43:23 +00:00
|
|
|
locs_mark (cl.viewstate.player_origin, desc);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("loc add <description> :marks the current location "
|
2001-08-28 03:47:10 +00:00
|
|
|
"with the description and records the information "
|
|
|
|
"into a loc file.\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
if (strcasecmp (Cmd_Argv (1), "rename") == 0) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (Cmd_Argc () >= 3)
|
2022-03-01 02:43:23 +00:00
|
|
|
locs_edit (cl.viewstate.player_origin, desc);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("loc rename <description> :changes the description of "
|
2001-08-28 03:47:10 +00:00
|
|
|
"the nearest location marker\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2002-08-27 16:28:58 +00:00
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
if (strcasecmp (Cmd_Argv (1),"delete") == 0) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (Cmd_Argc () == 2)
|
2022-03-01 02:43:23 +00:00
|
|
|
locs_del (cl.viewstate.player_origin);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("loc delete :removes nearest location marker\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2002-08-27 16:28:58 +00:00
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
if (strcasecmp (Cmd_Argv (1),"move") == 0) {
|
2001-02-19 21:15:25 +00:00
|
|
|
if (Cmd_Argc () == 2)
|
2022-03-01 02:43:23 +00:00
|
|
|
locs_edit (cl.viewstate.player_origin, NULL);
|
2001-02-19 21:15:25 +00:00
|
|
|
else
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("loc move :moves the nearest location marker to your "
|
2002-09-11 18:58:19 +00:00
|
|
|
"current location\n");
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2002-11-11 01:57:34 +00:00
|
|
|
Locs_Loc_Get (void)
|
2002-08-24 05:14:46 +00:00
|
|
|
{
|
|
|
|
location_t *location;
|
2002-09-11 18:58:19 +00:00
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
if (GIB_Argc () != 1)
|
2003-02-14 08:06:01 +00:00
|
|
|
GIB_USAGE ("");
|
2002-08-24 05:14:46 +00:00
|
|
|
else {
|
2022-03-01 02:43:23 +00:00
|
|
|
location = locs_find (cl.viewstate.player_origin);
|
2002-08-24 05:14:46 +00:00
|
|
|
GIB_Return (location ? location->name : "unknown");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-02-19 21:15:25 +00:00
|
|
|
void
|
|
|
|
Locs_Init (void)
|
|
|
|
{
|
2001-08-28 03:47:10 +00:00
|
|
|
Cmd_AddCommand ("loc", locs_loc, "Location marker editing commands: 'loc "
|
|
|
|
"help' for more");
|
2003-01-28 22:37:34 +00:00
|
|
|
GIB_Builtin_Add ("loc::get", Locs_Loc_Get);
|
2001-02-19 21:15:25 +00:00
|
|
|
}
|
2001-11-05 07:23:51 +00:00
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static const char *
|
2001-11-05 07:23:51 +00:00
|
|
|
Team_F_Version (char *args)
|
|
|
|
{
|
2021-01-31 07:01:20 +00:00
|
|
|
return va (0, "say %s", PACKAGE_STRING);
|
2001-11-05 07:23:51 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static const char *
|
2001-11-05 07:23:51 +00:00
|
|
|
Team_F_Skins (char *args)
|
|
|
|
{
|
2002-09-11 18:58:19 +00:00
|
|
|
int totalfb, l;
|
2004-07-11 01:41:01 +00:00
|
|
|
float allfb = 0.0;
|
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
allfb = min (cl.fbskins, cl_fb_players);
|
2004-07-11 01:41:01 +00:00
|
|
|
|
|
|
|
if (allfb >= 1.0) {
|
|
|
|
return "say Player models fullbright";
|
|
|
|
}
|
2001-11-05 07:23:51 +00:00
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
while (isspace ((byte) *args))
|
2001-11-05 07:23:51 +00:00
|
|
|
args++;
|
2002-09-11 18:58:19 +00:00
|
|
|
for (l = 0; args[l] && !isspace ((byte) args[l]); l++);
|
2001-11-05 07:23:51 +00:00
|
|
|
|
|
|
|
if (l == 0) {
|
2012-01-23 07:16:30 +00:00
|
|
|
//XXXtotalfb = Skin_FbPercent (0);
|
|
|
|
totalfb = 0;
|
2021-01-31 07:01:20 +00:00
|
|
|
return va (0, "say Player models have %f%% brightness\n"
|
2004-07-11 01:41:01 +00:00
|
|
|
"say Average percent fullbright for all loaded skins is "
|
|
|
|
"%d.%d%%", allfb * 100, totalfb / 10, totalfb % 10);
|
2001-11-05 07:23:51 +00:00
|
|
|
}
|
|
|
|
|
2012-01-23 07:16:30 +00:00
|
|
|
//XXX totalfb = Skin_FbPercent (args);
|
|
|
|
totalfb = 0;
|
2001-11-05 07:23:51 +00:00
|
|
|
|
2001-12-04 20:13:12 +00:00
|
|
|
if (totalfb >= 0)
|
2021-01-31 07:01:20 +00:00
|
|
|
return va (0, "say \"Skin %s is %d.%d%% fullbright\"",
|
|
|
|
args, totalfb / 10, totalfb % 10);
|
2001-11-05 07:23:51 +00:00
|
|
|
else
|
|
|
|
return ("say \"Skin not currently loaded.\"");
|
|
|
|
}
|
|
|
|
|
2002-08-27 16:28:58 +00:00
|
|
|
static freply_t f_replies[] = {
|
2001-11-05 07:23:51 +00:00
|
|
|
{"f_version", Team_F_Version, 0},
|
|
|
|
{"f_skins", Team_F_Skins, 0},
|
|
|
|
};
|
|
|
|
|
2002-08-27 16:28:58 +00:00
|
|
|
void
|
2001-11-05 07:23:51 +00:00
|
|
|
Team_ParseChat (const char *string)
|
|
|
|
{
|
2002-09-11 18:58:19 +00:00
|
|
|
char *s;
|
2003-04-17 00:01:48 +00:00
|
|
|
unsigned int i;
|
2001-11-05 07:23:51 +00:00
|
|
|
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
if (!cl_freply)
|
2001-11-12 03:32:04 +00:00
|
|
|
return;
|
|
|
|
|
2003-03-21 21:25:44 +00:00
|
|
|
if (!(s = strchr (string, ':')))
|
2001-11-12 03:32:04 +00:00
|
|
|
return;
|
|
|
|
s++;
|
2002-09-11 18:58:19 +00:00
|
|
|
while (isspace ((byte) *s))
|
2002-08-27 16:28:58 +00:00
|
|
|
s++;
|
2001-11-05 07:23:51 +00:00
|
|
|
|
2002-09-11 19:26:44 +00:00
|
|
|
for (i = 0; i < sizeof (f_replies) / sizeof (f_replies[0]); i++) {
|
2002-09-11 18:58:19 +00:00
|
|
|
if (!strncmp (f_replies[i].name, s, strlen (f_replies[i].name))
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
&& realtime - f_replies[i].lasttime >= cl_freply) {
|
2002-09-11 18:58:19 +00:00
|
|
|
while (*s && !isspace ((byte) *s))
|
2001-11-12 03:32:04 +00:00
|
|
|
s++;
|
2002-09-11 18:58:19 +00:00
|
|
|
Cbuf_AddText (cl_cbuf, f_replies[i].func (s));
|
|
|
|
Cbuf_AddText (cl_cbuf, "\n");
|
2001-11-12 03:32:04 +00:00
|
|
|
f_replies[i].lasttime = realtime;
|
2001-11-05 07:23:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-08-27 16:28:58 +00:00
|
|
|
|
2001-11-05 07:23:51 +00:00
|
|
|
void
|
|
|
|
Team_ResetTimers (void)
|
|
|
|
{
|
2003-04-17 00:01:48 +00:00
|
|
|
unsigned int i;
|
2002-09-11 18:58:19 +00:00
|
|
|
|
2002-10-25 21:07:20 +00:00
|
|
|
for (i = 0; i < sizeof (f_replies) / sizeof (f_replies[0]); i++)
|
[cvar] Make cvars properly typed
This is an extremely extensive patch as it hits every cvar, and every
usage of the cvars. Cvars no longer store the value they control,
instead, they use a cexpr value object to reference the value and
specify the value's type (currently, a null type is used for strings).
Non-string cvars are passed through cexpr, allowing expressions in the
cvars' settings. Also, cvars have returned to an enhanced version of the
original (id quake) registration scheme.
As a minor benefit, relevant code having direct access to the
cvar-controlled variables is probably a slight optimization as it
removed a pointer dereference, and the variables can be located for data
locality.
The static cvar descriptors are made private as an additional safety
layer, though there's nothing stopping external modification via
Cvar_FindVar (which is needed for adding listeners).
While not used yet (partly due to working out the design), cvars can
have a validation function.
Registering a cvar allows a primary listener (and its data) to be
specified: it will always be called first when the cvar is modified. The
combination of proper listeners and direct access to the controlled
variable greatly simplifies the more complex cvar interactions as much
less null checking is required, and there's no need for one cvar's
callback to call another's.
nq-x11 is known to work at least well enough for the demos. More testing
will come.
2022-04-23 03:22:45 +00:00
|
|
|
f_replies[i].lasttime = realtime - cl_freply;
|
2001-11-05 07:23:51 +00:00
|
|
|
return;
|
|
|
|
}
|