2001-05-11 22:47:15 +00:00
|
|
|
/*
|
|
|
|
skin.c
|
|
|
|
|
|
|
|
(description)
|
|
|
|
|
|
|
|
Copyright (C) 1996-1997 Id Software, Inc.
|
|
|
|
|
|
|
|
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-05-11 22:47:15 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
# include <string.h>
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "QF/cmd.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2001-05-11 22:47:15 +00:00
|
|
|
#include "QF/msg.h"
|
|
|
|
#include "QF/screen.h"
|
2012-01-23 10:24:12 +00:00
|
|
|
#include "QF/skin.h"
|
2007-11-06 10:17:14 +00:00
|
|
|
#include "QF/sys.h"
|
2001-05-11 22:47:15 +00:00
|
|
|
#include "QF/va.h"
|
|
|
|
|
2001-08-28 23:05:45 +00:00
|
|
|
#include "compat.h"
|
2020-06-21 14:15:17 +00:00
|
|
|
|
|
|
|
#include "qw/include/cl_parse.h"
|
|
|
|
#include "qw/include/cl_skin.h"
|
|
|
|
#include "qw/include/client.h"
|
|
|
|
#include "qw/include/host.h"
|
2001-05-11 22:47:15 +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 noskins;
|
|
|
|
static cvar_t noskins_cvar = {
|
|
|
|
.name = "noskins",
|
|
|
|
.description =
|
|
|
|
"set to 1 to not download new skins",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &noskins },
|
|
|
|
};
|
|
|
|
char *skin;
|
|
|
|
static cvar_t skin_cvar = {
|
|
|
|
.name = "skin",
|
|
|
|
.description =
|
|
|
|
"Players skin",
|
|
|
|
.default_value = "",
|
|
|
|
.flags = CVAR_ARCHIVE | CVAR_USERINFO,
|
|
|
|
.value = { .type = 0, .value = &skin },
|
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
int topcolor;
|
[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
|
|
|
static cvar_t topcolor_cvar = {
|
|
|
|
.name = "topcolor",
|
|
|
|
.description =
|
|
|
|
"Players color on top",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE | CVAR_USERINFO,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_int, .value = &topcolor },
|
[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
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
int bottomcolor;
|
[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
|
|
|
static cvar_t bottomcolor_cvar = {
|
|
|
|
.name = "bottomcolor",
|
|
|
|
.description =
|
|
|
|
"Players color on bottom",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE | CVAR_USERINFO,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_int, .value = &bottomcolor },
|
[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
|
|
|
};
|
2001-05-11 22:47:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
Skin_NextDownload (void)
|
|
|
|
{
|
|
|
|
int i;
|
2001-08-28 23:05:45 +00:00
|
|
|
player_info_t *sc;
|
2001-05-11 22:47:15 +00:00
|
|
|
|
2002-06-25 17:07:52 +00:00
|
|
|
if (cls.state == ca_disconnected)
|
|
|
|
return;
|
|
|
|
|
2001-05-11 22:47:15 +00:00
|
|
|
if (cls.downloadnumber == 0) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Checking skins...\n");
|
2001-05-23 06:33:23 +00:00
|
|
|
CL_UpdateScreen (realtime);
|
2001-05-11 22:47:15 +00:00
|
|
|
}
|
|
|
|
cls.downloadtype = dl_skin;
|
|
|
|
|
|
|
|
for (; cls.downloadnumber != MAX_CLIENTS; cls.downloadnumber++) {
|
|
|
|
sc = &cl.players[cls.downloadnumber];
|
2012-05-21 14:04:47 +00:00
|
|
|
if (!sc->name || !sc->name->value[0])
|
2001-05-11 22:47:15 +00:00
|
|
|
continue;
|
2012-01-23 07:16:30 +00:00
|
|
|
//XXX Skin_Find (sc);
|
[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 (noskins) //XXX FIXME
|
2001-05-11 22:47:15 +00:00
|
|
|
continue;
|
2021-01-31 07:01:20 +00:00
|
|
|
//XXX if (!CL_CheckOrDownloadFile (va (0, "skins/%s.pcx",
|
|
|
|
// sc->skin->name)))
|
2012-01-23 07:16:30 +00:00
|
|
|
//XXX return; // started a download
|
2001-05-11 22:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cls.downloadtype = dl_none;
|
|
|
|
|
|
|
|
// now load them in for real
|
|
|
|
for (i = 0; i < MAX_CLIENTS; i++) {
|
|
|
|
sc = &cl.players[i];
|
2012-05-21 14:04:47 +00:00
|
|
|
if (!sc->name || !sc->name->value[0])
|
2001-05-11 22:47:15 +00:00
|
|
|
continue;
|
2012-01-23 07:16:30 +00:00
|
|
|
//XXX Skin_Find (sc);
|
|
|
|
//XXX Skin_Cache (sc->skin);
|
|
|
|
//XXX sc->skin = NULL;
|
2001-05-11 22:47:15 +00:00
|
|
|
}
|
|
|
|
|
2007-03-23 14:52:10 +00:00
|
|
|
if (cls.state != ca_active) {
|
|
|
|
if (!cls.demoplayback) {
|
|
|
|
// get next signon phase
|
|
|
|
MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
|
2012-11-14 11:54:35 +00:00
|
|
|
MSG_WriteString (&cls.netchan.message,
|
2021-01-31 07:01:20 +00:00
|
|
|
va (0, "begin %i", cl.servercount));
|
2007-03-23 14:52:10 +00:00
|
|
|
Cache_Report (); // print remaining memory
|
|
|
|
}
|
2007-03-18 21:56:14 +00:00
|
|
|
CL_SetState (ca_active);
|
2001-05-11 22:47:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_Skins_f
|
|
|
|
|
|
|
|
Refind all skins, downloading if needed.
|
|
|
|
*/
|
2012-01-23 07:16:30 +00:00
|
|
|
static void
|
2001-05-11 22:47:15 +00:00
|
|
|
CL_Skins_f (void)
|
|
|
|
{
|
2012-01-23 07:16:30 +00:00
|
|
|
//XXX Skin_Flush ();
|
2002-06-25 17:07:52 +00:00
|
|
|
|
|
|
|
if (cls.state == ca_disconnected)
|
|
|
|
return;
|
|
|
|
|
2001-05-11 22:47:15 +00:00
|
|
|
cls.downloadnumber = 0;
|
|
|
|
cls.downloadtype = dl_skin;
|
|
|
|
Skin_NextDownload ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
CL_AllSkins_f
|
|
|
|
|
|
|
|
Sets all skins to one specific one
|
|
|
|
*/
|
2012-01-23 07:16:30 +00:00
|
|
|
static void
|
2001-05-11 22:47:15 +00:00
|
|
|
CL_AllSkins_f (void)
|
|
|
|
{
|
2002-06-25 17:07:52 +00:00
|
|
|
if (Cmd_Argc () == 2) {
|
2012-01-23 07:16:30 +00:00
|
|
|
//XXX strcpy (allskins, Cmd_Argv (1));
|
2002-06-25 17:07:52 +00:00
|
|
|
} else if (Cmd_Argc () == 1) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("clearing allskins\n");
|
2012-01-23 07:16:30 +00:00
|
|
|
//XXX allskins[0] = 0;
|
2002-06-25 17:07:52 +00:00
|
|
|
} else {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("Usage: allskins [name]\n");
|
2002-06-25 17:07:52 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-05-11 22:47:15 +00:00
|
|
|
CL_Skins_f ();
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-05-11 22:47:15 +00:00
|
|
|
CL_Color_f (void)
|
|
|
|
{
|
|
|
|
// just for quake compatability...
|
|
|
|
char num[16];
|
2001-08-28 23:05:45 +00:00
|
|
|
int top, bottom;
|
2001-05-11 22:47:15 +00:00
|
|
|
|
|
|
|
if (Cmd_Argc () == 1) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("\"color\" is \"%s %s\"\n",
|
2001-05-11 22:47:15 +00:00
|
|
|
Info_ValueForKey (cls.userinfo, "topcolor"),
|
|
|
|
Info_ValueForKey (cls.userinfo, "bottomcolor"));
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("color <0-13> [0-13]\n");
|
2001-05-11 22:47:15 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Cmd_Argc () == 2)
|
|
|
|
top = bottom = atoi (Cmd_Argv (1));
|
|
|
|
else {
|
|
|
|
top = atoi (Cmd_Argv (1));
|
|
|
|
bottom = atoi (Cmd_Argv (2));
|
|
|
|
}
|
|
|
|
|
|
|
|
top &= 15;
|
|
|
|
if (top > 13)
|
|
|
|
top = 13;
|
|
|
|
bottom &= 15;
|
|
|
|
if (bottom > 13)
|
|
|
|
bottom = 13;
|
|
|
|
|
|
|
|
snprintf (num, sizeof (num), "%i", top);
|
[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_Set ("topcolor", num);
|
2001-05-11 22:47:15 +00:00
|
|
|
snprintf (num, sizeof (num), "%i", bottom);
|
[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_Set ("bottomcolor", num);
|
2001-05-11 22:47:15 +00:00
|
|
|
}
|
|
|
|
|
2001-11-04 19:06:50 +00:00
|
|
|
static 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
|
|
|
skin_f (void *data, const cvar_t *cvar)
|
2001-11-04 19:06:50 +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
|
|
|
char *s = Hunk_TempAlloc (0, strlen (skin) + 1);
|
|
|
|
QFS_StripExtension (skin, s);
|
2022-05-12 10:47:11 +00:00
|
|
|
free (skin); // cvar allocated one FIXME do in validator?
|
[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
|
|
|
skin = strdup (s);
|
|
|
|
Cvar_Info (0, cvar);
|
2001-11-04 19:06:50 +00:00
|
|
|
}
|
|
|
|
|
2001-05-11 22:47:15 +00:00
|
|
|
void
|
2012-01-23 07:16:30 +00:00
|
|
|
CL_Skin_Init (void)
|
2001-05-11 22:47:15 +00:00
|
|
|
{
|
2012-01-23 07:16:30 +00:00
|
|
|
Cmd_AddCommand ("skins", CL_Skins_f, "Download all skins that are "
|
|
|
|
"currently in use");
|
|
|
|
Cmd_AddCommand ("allskins", CL_AllSkins_f, "Force all player skins to "
|
|
|
|
"one skin");
|
|
|
|
Cmd_AddCommand ("color", CL_Color_f, "The pant and shirt color (color "
|
|
|
|
"shirt pants) Note that if only shirt color is given, "
|
|
|
|
"pants will match");
|
|
|
|
|
[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 (&noskins_cvar, 0, 0);
|
|
|
|
Cvar_Register (&skin_cvar, skin_f, 0);
|
|
|
|
Cvar_Register (&topcolor_cvar, Cvar_Info, &topcolor);
|
|
|
|
Cvar_Register (&bottomcolor_cvar, Cvar_Info, &bottomcolor);
|
2001-05-11 22:47:15 +00:00
|
|
|
}
|