2001-02-26 20:52:14 +00:00
|
|
|
/*
|
|
|
|
sv_progs.c
|
|
|
|
|
|
|
|
Quick QuakeC server code
|
|
|
|
|
|
|
|
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-02-26 20:52:14 +00:00
|
|
|
#ifdef HAVE_STRING_H
|
2010-01-13 06:29:36 +00:00
|
|
|
# include <string.h>
|
2001-02-26 20:52:14 +00:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_STRINGS_H
|
2010-01-13 06:29:36 +00:00
|
|
|
# include <strings.h>
|
2001-02-26 20:52:14 +00:00
|
|
|
#endif
|
|
|
|
|
2001-03-27 20:33:07 +00:00
|
|
|
#include "QF/cmd.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
#include "QF/cvar.h"
|
2003-01-10 22:47:18 +00:00
|
|
|
#include "QF/quakefs.h"
|
2007-11-06 10:17:14 +00:00
|
|
|
#include "QF/sys.h"
|
2001-05-31 03:41:35 +00:00
|
|
|
|
2004-01-06 07:00:39 +00:00
|
|
|
#include "compat.h"
|
2001-02-26 20:52:14 +00:00
|
|
|
#include "world.h"
|
2001-03-28 17:17:56 +00:00
|
|
|
|
2020-06-21 14:15:17 +00:00
|
|
|
#include "nq/include/host.h"
|
|
|
|
#include "nq/include/server.h"
|
|
|
|
#include "nq/include/sv_progs.h"
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
progs_t sv_pr_state;
|
2001-03-03 08:31:58 +00:00
|
|
|
sv_globals_t sv_globals;
|
|
|
|
sv_funcs_t sv_funcs;
|
|
|
|
sv_fields_t sv_fields;
|
2001-02-28 00:56:03 +00:00
|
|
|
|
2013-01-17 05:11:54 +00:00
|
|
|
edict_t sv_edicts[MAX_EDICTS];
|
2010-12-09 05:27:36 +00:00
|
|
|
sv_data_t sv_data[MAX_EDICTS];
|
|
|
|
|
[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 *sv_progs;
|
|
|
|
static cvar_t sv_progs_cvar = {
|
|
|
|
.name = "sv_progs",
|
|
|
|
.description =
|
|
|
|
"Override the default game progs.",
|
|
|
|
.default_value = "",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = 0, .value = &sv_progs },
|
|
|
|
};
|
|
|
|
int sv_progs_zone;
|
|
|
|
static cvar_t sv_progs_zone_cvar = {
|
|
|
|
.name = "sv_progs_zone",
|
|
|
|
.description =
|
|
|
|
"size of the zone for progs in kb",
|
|
|
|
.default_value = "256",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &sv_progs_zone },
|
|
|
|
};
|
|
|
|
int sv_progs_stack;
|
|
|
|
static cvar_t sv_progs_stack_cvar = {
|
|
|
|
.name = "sv_progs_stack",
|
|
|
|
.description =
|
|
|
|
"size of the stack for progs in kb",
|
|
|
|
.default_value = "256",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = &cexpr_int, .value = &sv_progs_stack },
|
|
|
|
};
|
|
|
|
char *sv_progs_ext;
|
|
|
|
static cvar_t sv_progs_ext_cvar = {
|
|
|
|
.name = "sv_progs_ext",
|
|
|
|
.description =
|
|
|
|
"extention mapping to use: none, id, qf",
|
|
|
|
.default_value = "qf",
|
|
|
|
.flags = CVAR_NONE,
|
|
|
|
.value = { .type = 0, .value = &sv_progs_ext },
|
|
|
|
};
|
2022-04-24 11:04:06 +00:00
|
|
|
float pr_checkextensions;
|
[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 pr_checkextensions_cvar = {
|
|
|
|
.name = "pr_checkextensions",
|
|
|
|
.description =
|
|
|
|
"indicate the presence of the checkextentions qc function",
|
|
|
|
.default_value = "1",
|
|
|
|
.flags = CVAR_ROM,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &pr_checkextensions },
|
[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
|
|
|
float nomonsters;
|
[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 nomonsters_cvar = {
|
|
|
|
.name = "nomonsters",
|
|
|
|
.description =
|
|
|
|
"No Description",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &nomonsters },
|
[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
|
|
|
float gamecfg;
|
[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 gamecfg_cvar = {
|
|
|
|
.name = "gamecfg",
|
|
|
|
.description =
|
|
|
|
"No Description",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &gamecfg },
|
[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
|
|
|
float scratch1;
|
[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 scratch1_cvar = {
|
|
|
|
.name = "scratch1",
|
|
|
|
.description =
|
|
|
|
"No Description",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &scratch1 },
|
[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
|
|
|
float scratch2;
|
[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 scratch2_cvar = {
|
|
|
|
.name = "scratch2",
|
|
|
|
.description =
|
|
|
|
"No Description",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &scratch2 },
|
[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
|
|
|
float scratch3;
|
[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 scratch3_cvar = {
|
|
|
|
.name = "scratch3",
|
|
|
|
.description =
|
|
|
|
"No Description",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &scratch3 },
|
[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
|
|
|
float scratch4;
|
[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 scratch4_cvar = {
|
|
|
|
.name = "scratch4",
|
|
|
|
.description =
|
|
|
|
"No Description",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_NONE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &scratch4 },
|
[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
|
|
|
float savedgamecfg;
|
[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 savedgamecfg_cvar = {
|
|
|
|
.name = "savedgamecfg",
|
|
|
|
.description =
|
|
|
|
"No Description",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &savedgamecfg },
|
[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
|
|
|
float saved1;
|
[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 saved1_cvar = {
|
|
|
|
.name = "saved1",
|
|
|
|
.description =
|
|
|
|
"No Description",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &saved1 },
|
[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
|
|
|
float saved2;
|
[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 saved2_cvar = {
|
|
|
|
.name = "saved2",
|
|
|
|
.description =
|
|
|
|
"No Description",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &saved2 },
|
[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
|
|
|
float saved3;
|
[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 saved3_cvar = {
|
|
|
|
.name = "saved3",
|
|
|
|
.description =
|
|
|
|
"No Description",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &saved3 },
|
[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
|
|
|
float saved4;
|
[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 saved4_cvar = {
|
|
|
|
.name = "saved4",
|
|
|
|
.description =
|
|
|
|
"No Description",
|
|
|
|
.default_value = "0",
|
|
|
|
.flags = CVAR_ARCHIVE,
|
2022-04-24 11:04:06 +00:00
|
|
|
.value = { .type = &cexpr_float, .value = &saved4 },
|
[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-02-28 00:56:03 +00:00
|
|
|
|
2004-01-06 07:00:39 +00:00
|
|
|
static int sv_range;
|
|
|
|
|
|
|
|
static unsigned
|
|
|
|
bi_map (progs_t *pr, unsigned binum)
|
|
|
|
{
|
|
|
|
unsigned range;
|
|
|
|
|
|
|
|
if (sv_range != PR_RANGE_NONE) {
|
|
|
|
range = (binum & PR_RANGE_MASK) >> PR_RANGE_SHIFT;
|
|
|
|
|
|
|
|
if (!range && binum > PR_RANGE_ID_MAX)
|
|
|
|
binum |= sv_range << PR_RANGE_SHIFT;
|
|
|
|
}
|
|
|
|
return binum;
|
|
|
|
}
|
|
|
|
|
2001-03-27 22:39:21 +00:00
|
|
|
static int
|
|
|
|
prune_edict (progs_t *pr, edict_t *ent)
|
2001-02-28 00:56:03 +00:00
|
|
|
{
|
|
|
|
// remove things from different skill levels or deathmatch
|
[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 (deathmatch) {
|
2001-08-08 20:28:53 +00:00
|
|
|
if (((int) SVfloat (ent, spawnflags)
|
2001-06-29 15:42:53 +00:00
|
|
|
& SPAWNFLAG_NOT_DEATHMATCH)) {
|
2001-02-28 00:56:03 +00:00
|
|
|
return 1;
|
|
|
|
}
|
2001-06-29 15:42:53 +00:00
|
|
|
} else if ((current_skill == 0
|
2001-08-08 20:28:53 +00:00
|
|
|
&& ((int) SVfloat (ent, spawnflags)
|
2001-06-29 15:42:53 +00:00
|
|
|
& SPAWNFLAG_NOT_EASY))
|
2001-02-28 00:56:03 +00:00
|
|
|
|| (current_skill == 1
|
2001-08-08 20:28:53 +00:00
|
|
|
&& ((int) SVfloat (ent, spawnflags)
|
2001-06-29 15:42:53 +00:00
|
|
|
& SPAWNFLAG_NOT_MEDIUM))
|
2001-02-28 00:56:03 +00:00
|
|
|
|| (current_skill >= 2
|
2001-08-08 20:28:53 +00:00
|
|
|
&& ((int) SVfloat (ent, spawnflags)
|
2001-06-29 15:42:53 +00:00
|
|
|
& SPAWNFLAG_NOT_HARD))) {
|
2001-02-28 00:56:03 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 20:52:14 +00:00
|
|
|
ED_PrintEdicts_f (void)
|
|
|
|
{
|
2001-07-19 03:18:11 +00:00
|
|
|
ED_PrintEdicts (&sv_pr_state, Cmd_Argv (1));
|
2001-02-26 20:52:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-01-13 06:29:36 +00:00
|
|
|
ED_PrintEdict_f
|
2001-02-26 20:52:14 +00:00
|
|
|
|
2010-01-13 06:29:36 +00:00
|
|
|
For debugging, prints a single edict
|
2001-02-26 20:52:14 +00:00
|
|
|
*/
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 20:52:14 +00:00
|
|
|
ED_PrintEdict_f (void)
|
|
|
|
{
|
|
|
|
int i;
|
2021-07-25 00:54:08 +00:00
|
|
|
const char *fieldname = 0;
|
2001-02-26 20:52:14 +00:00
|
|
|
|
2021-07-25 00:54:08 +00:00
|
|
|
if (Cmd_Argc () < 2) {
|
|
|
|
Sys_Printf ("edict num [fieldname]\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (Cmd_Argc () >= 3) {
|
|
|
|
fieldname = Cmd_Argv (2);
|
|
|
|
}
|
2001-02-26 20:52:14 +00:00
|
|
|
i = atoi (Cmd_Argv (1));
|
2021-07-25 00:54:08 +00:00
|
|
|
ED_PrintNum (&sv_pr_state, i, fieldname);
|
2001-02-26 20:52:14 +00:00
|
|
|
}
|
|
|
|
|
2003-01-06 18:28:13 +00:00
|
|
|
static void
|
2001-02-26 20:52:14 +00:00
|
|
|
ED_Count_f (void)
|
|
|
|
{
|
|
|
|
ED_Count (&sv_pr_state);
|
|
|
|
}
|
|
|
|
|
2004-11-05 11:49:00 +00:00
|
|
|
static void
|
2001-02-26 20:52:14 +00:00
|
|
|
PR_Profile_f (void)
|
|
|
|
{
|
2003-05-15 20:46:16 +00:00
|
|
|
if (!sv_pr_state.progs) {
|
2007-11-06 10:17:14 +00:00
|
|
|
Sys_Printf ("no progs loaded\n");
|
2003-05-15 20:46:16 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-02-26 20:52:14 +00:00
|
|
|
PR_Profile (&sv_pr_state);
|
|
|
|
}
|
|
|
|
|
2010-01-13 06:29:36 +00:00
|
|
|
static void
|
|
|
|
watch_f (void)
|
|
|
|
{
|
|
|
|
PR_Debug_Watch (&sv_pr_state, Cmd_Argc () < 2 ? 0 : Cmd_Args (1));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_f (void)
|
|
|
|
{
|
|
|
|
PR_Debug_Print (&sv_pr_state, Cmd_Argc () < 2 ? 0 : Cmd_Args (1));
|
|
|
|
}
|
|
|
|
|
2001-03-27 22:39:21 +00:00
|
|
|
static int
|
2001-07-15 07:04:17 +00:00
|
|
|
parse_field (progs_t *pr, const char *key, const char *value)
|
2001-02-26 20:52:14 +00:00
|
|
|
{
|
2010-12-10 03:58:32 +00:00
|
|
|
if (strequal (key, "sky")
|
|
|
|
|| strequal (key, "skyname")
|
|
|
|
|| strequal (key, "qlsky")
|
|
|
|
|| strequal (key, "fog"))
|
|
|
|
return 1;
|
2010-12-16 00:34:29 +00:00
|
|
|
if (strequal (key, "mapversion")) // ignore HL(?) version field
|
|
|
|
return 1;
|
2007-04-07 01:02:14 +00:00
|
|
|
if (*key == '_') // ignore _fields
|
|
|
|
return 1;
|
2001-02-26 20:52:14 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2004-01-21 08:09:47 +00:00
|
|
|
typedef struct sv_def_s {
|
|
|
|
etype_t type;
|
|
|
|
unsigned short offset;
|
|
|
|
const char *name;
|
|
|
|
void *field;
|
|
|
|
} sv_def_t;
|
|
|
|
|
2004-02-17 05:12:50 +00:00
|
|
|
static sv_def_t nq_self[] = {
|
|
|
|
{ev_entity, 28, "self", &sv_globals.self},
|
|
|
|
{ev_entity, 28, ".self", &sv_globals.self},
|
|
|
|
{ev_void, 0, 0},
|
|
|
|
};
|
|
|
|
|
2004-01-21 08:09:47 +00:00
|
|
|
static sv_def_t nq_defs[] = {
|
|
|
|
{ev_entity, 29, "other", &sv_globals.other},
|
|
|
|
{ev_entity, 30, "world", &sv_globals.world},
|
|
|
|
{ev_float, 31, "time", &sv_globals.time},
|
|
|
|
{ev_float, 32, "frametime", &sv_globals.frametime},
|
|
|
|
{ev_float, 33, "force_retouch", &sv_globals.force_retouch},
|
|
|
|
{ev_string, 34, "mapname", &sv_globals.mapname},
|
|
|
|
{ev_float, 35, "deathmatch", &sv_globals.deathmatch},
|
|
|
|
{ev_float, 36, "coop", &sv_globals.coop},
|
|
|
|
{ev_float, 37, "teamplay", &sv_globals.teamplay},
|
|
|
|
{ev_float, 38, "serverflags", &sv_globals.serverflags},
|
|
|
|
{ev_float, 39, "total_secrets", &sv_globals.total_secrets},
|
|
|
|
{ev_float, 40, "total_monsters", &sv_globals.total_monsters},
|
|
|
|
{ev_float, 41, "found_secrets", &sv_globals.found_secrets},
|
|
|
|
{ev_float, 42, "killed_monsters", &sv_globals.killed_monsters},
|
|
|
|
//parm1-16 form an array
|
|
|
|
{ev_float, 43, "parm1", &sv_globals.parms},
|
|
|
|
{ev_vector, 59, "v_forward", &sv_globals.v_forward},
|
|
|
|
{ev_vector, 62, "v_up", &sv_globals.v_up},
|
|
|
|
{ev_vector, 65, "v_right", &sv_globals.v_right},
|
|
|
|
{ev_float, 68, "trace_allsolid", &sv_globals.trace_allsolid},
|
|
|
|
{ev_float, 69, "trace_startsolid", &sv_globals.trace_startsolid},
|
|
|
|
{ev_float, 70, "trace_fraction", &sv_globals.trace_fraction},
|
|
|
|
{ev_vector, 71, "trace_endpos", &sv_globals.trace_endpos},
|
|
|
|
{ev_vector, 74, "trace_plane_normal", &sv_globals.trace_plane_normal},
|
|
|
|
{ev_float, 77, "trace_plane_dist", &sv_globals.trace_plane_dist},
|
|
|
|
{ev_entity, 78, "trace_ent", &sv_globals.trace_ent},
|
|
|
|
{ev_float, 79, "trace_inopen", &sv_globals.trace_inopen},
|
|
|
|
{ev_float, 80, "trace_inwater", &sv_globals.trace_inwater},
|
|
|
|
{ev_entity, 81, "msg_entity", &sv_globals.msg_entity},
|
|
|
|
{ev_void, 0, 0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static sv_def_t nq_funcs[] = {
|
|
|
|
{ev_func, 82, "main", &sv_funcs.main},
|
|
|
|
{ev_func, 83, "StartFrame", &sv_funcs.StartFrame},
|
|
|
|
{ev_func, 84, "PlayerPreThink", &sv_funcs.PlayerPreThink},
|
|
|
|
{ev_func, 85, "PlayerPostThink", &sv_funcs.PlayerPostThink},
|
|
|
|
{ev_func, 86, "ClientKill", &sv_funcs.ClientKill},
|
|
|
|
{ev_func, 87, "ClientConnect", &sv_funcs.ClientConnect},
|
|
|
|
{ev_func, 88, "PutClientInServer", &sv_funcs.PutClientInServer},
|
|
|
|
{ev_func, 89, "ClientDisconnect", &sv_funcs.ClientDisconnect},
|
|
|
|
{ev_func, 90, "SetNewParms", &sv_funcs.SetNewParms},
|
|
|
|
{ev_func, 91, "SetChangeParms", &sv_funcs.SetChangeParms},
|
|
|
|
{ev_void, 0, 0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static sv_def_t nq_fields[] = {
|
|
|
|
{ev_float, 0, "modelindex", &sv_fields.modelindex},
|
|
|
|
{ev_vector, 1, "absmin", &sv_fields.absmin},
|
|
|
|
{ev_vector, 4, "absmax", &sv_fields.absmax},
|
|
|
|
{ev_float, 7, "ltime", &sv_fields.ltime},
|
|
|
|
{ev_float, 8, "movetype", &sv_fields.movetype},
|
|
|
|
{ev_float, 9, "solid", &sv_fields.solid},
|
|
|
|
{ev_vector, 10, "origin", &sv_fields.origin},
|
|
|
|
{ev_vector, 13, "oldorigin", &sv_fields.oldorigin},
|
|
|
|
{ev_vector, 16, "velocity", &sv_fields.velocity},
|
|
|
|
{ev_vector, 19, "angles", &sv_fields.angles},
|
|
|
|
{ev_vector, 22, "avelocity", &sv_fields.avelocity},
|
|
|
|
{ev_vector, 25, "punchangle", &sv_fields.punchangle},
|
|
|
|
{ev_string, 28, "classname", &sv_fields.classname},
|
|
|
|
{ev_string, 29, "model", &sv_fields.model},
|
|
|
|
{ev_float, 30, "frame", &sv_fields.frame},
|
|
|
|
{ev_float, 31, "skin", &sv_fields.skin},
|
|
|
|
{ev_float, 32, "effects", &sv_fields.effects},
|
|
|
|
{ev_vector, 33, "mins", &sv_fields.mins},
|
|
|
|
{ev_vector, 36, "maxs", &sv_fields.maxs},
|
|
|
|
{ev_vector, 39, "size", &sv_fields.size},
|
|
|
|
{ev_func, 42, "touch", &sv_fields.touch},
|
|
|
|
{ev_func, 44, "think", &sv_fields.think},
|
|
|
|
{ev_func, 45, "blocked", &sv_fields.blocked},
|
|
|
|
{ev_float, 46, "nextthink", &sv_fields.nextthink},
|
|
|
|
{ev_entity, 47, "groundentity", &sv_fields.groundentity},
|
|
|
|
{ev_float, 48, "health", &sv_fields.health},
|
|
|
|
{ev_float, 49, "frags", &sv_fields.frags},
|
|
|
|
{ev_float, 50, "weapon", &sv_fields.weapon},
|
|
|
|
{ev_string, 51, "weaponmodel", &sv_fields.weaponmodel},
|
|
|
|
{ev_float, 52, "weaponframe", &sv_fields.weaponframe},
|
|
|
|
{ev_float, 53, "currentammo", &sv_fields.currentammo},
|
|
|
|
{ev_float, 54, "ammo_shells", &sv_fields.ammo_shells},
|
|
|
|
{ev_float, 55, "ammo_nails", &sv_fields.ammo_nails},
|
|
|
|
{ev_float, 56, "ammo_rockets", &sv_fields.ammo_rockets},
|
|
|
|
{ev_float, 57, "ammo_cells", &sv_fields.ammo_cells},
|
|
|
|
{ev_float, 58, "items", &sv_fields.items},
|
|
|
|
{ev_float, 59, "takedamage", &sv_fields.takedamage},
|
|
|
|
{ev_entity, 60, "chain", &sv_fields.chain},
|
|
|
|
{ev_vector, 62, "view_ofs", &sv_fields.view_ofs},
|
|
|
|
{ev_float, 65, "button0", &sv_fields.button0},
|
|
|
|
{ev_float, 66, "button1", &sv_fields.button1},
|
|
|
|
{ev_float, 67, "button2", &sv_fields.button2},
|
|
|
|
{ev_float, 68, "impulse", &sv_fields.impulse},
|
|
|
|
{ev_float, 69, "fixangle", &sv_fields.fixangle},
|
|
|
|
{ev_vector, 70, "v_angle", &sv_fields.v_angle},
|
|
|
|
{ev_float, 73, "idealpitch", &sv_fields.idealpitch},
|
|
|
|
{ev_string, 74, "netname", &sv_fields.netname},
|
|
|
|
{ev_entity, 75, "enemy", &sv_fields.enemy},
|
|
|
|
{ev_float, 76, "flags", &sv_fields.flags},
|
|
|
|
{ev_float, 77, "colormap", &sv_fields.colormap},
|
|
|
|
{ev_float, 78, "team", &sv_fields.team},
|
|
|
|
{ev_float, 80, "teleport_time", &sv_fields.teleport_time},
|
|
|
|
{ev_float, 82, "armorvalue", &sv_fields.armorvalue},
|
|
|
|
{ev_float, 83, "waterlevel", &sv_fields.waterlevel},
|
|
|
|
{ev_float, 84, "watertype", &sv_fields.watertype},
|
|
|
|
{ev_float, 85, "ideal_yaw", &sv_fields.ideal_yaw},
|
|
|
|
{ev_float, 86, "yaw_speed", &sv_fields.yaw_speed},
|
|
|
|
{ev_entity, 88, "goalentity", &sv_fields.goalentity},
|
|
|
|
{ev_float, 89, "spawnflags", &sv_fields.spawnflags},
|
|
|
|
{ev_float, 92, "dmg_take", &sv_fields.dmg_take},
|
|
|
|
{ev_float, 93, "dmg_save", &sv_fields.dmg_save},
|
|
|
|
{ev_entity, 94, "dmg_inflictor", &sv_fields.dmg_inflictor},
|
|
|
|
{ev_entity, 95, "owner", &sv_fields.owner},
|
|
|
|
{ev_vector, 96, "movedir", &sv_fields.movedir},
|
|
|
|
{ev_string, 99, "message", &sv_fields.message},
|
|
|
|
{ev_float, 100, "sounds", &sv_fields.sounds},
|
|
|
|
{ev_void, 0, 0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static sv_def_t nq_opt_defs[] = {
|
|
|
|
{ev_entity, 0, "newmis", &sv_globals.newmis},
|
|
|
|
{ev_void, 0, 0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static sv_def_t nq_opt_funcs[] = {
|
2010-12-08 12:20:35 +00:00
|
|
|
{ev_func, 0, "EndFrame", &sv_funcs.EndFrame},
|
2004-01-21 08:09:47 +00:00
|
|
|
{ev_void, 0, 0},
|
|
|
|
};
|
|
|
|
|
|
|
|
static sv_def_t nq_opt_fields[] = {
|
2022-01-18 04:21:06 +00:00
|
|
|
{ev_int, 0, "rotated_bbox", &sv_fields.rotated_bbox},
|
2010-12-16 00:34:29 +00:00
|
|
|
{ev_float, 0, "alpha", &sv_fields.alpha},
|
2010-01-13 06:29:36 +00:00
|
|
|
{ev_float, 0, "gravity", &sv_fields.gravity},
|
2004-01-21 08:09:47 +00:00
|
|
|
{ev_float, 0, "items2", &sv_fields.items2},
|
|
|
|
{ev_float, 0, "lastruntime", &sv_fields.lastruntime},
|
|
|
|
{ev_void, 0, 0},
|
|
|
|
};
|
|
|
|
|
2007-04-06 00:47:41 +00:00
|
|
|
static const pr_uint_t nq_crc = 5927;
|
2004-01-21 08:09:47 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
set_address (sv_def_t *def, void *address)
|
|
|
|
{
|
|
|
|
switch (def->type) {
|
|
|
|
case ev_void:
|
|
|
|
case ev_short:
|
2022-01-18 13:08:37 +00:00
|
|
|
case ev_ushort:
|
2011-01-09 10:41:24 +00:00
|
|
|
case ev_invalid:
|
2004-01-21 08:09:47 +00:00
|
|
|
case ev_type_count:
|
|
|
|
break;
|
|
|
|
case ev_float:
|
|
|
|
case ev_vector:
|
2022-01-18 06:48:43 +00:00
|
|
|
case ev_quaternion:
|
2004-01-21 08:09:47 +00:00
|
|
|
*(float **)def->field = (float *) address;
|
|
|
|
break;
|
2020-02-14 07:38:37 +00:00
|
|
|
case ev_double:
|
|
|
|
*(double **)def->field = (double *) address;
|
|
|
|
break;
|
2004-01-21 08:09:47 +00:00
|
|
|
case ev_string:
|
|
|
|
case ev_entity:
|
|
|
|
case ev_field:
|
|
|
|
case ev_func:
|
2022-01-18 05:36:06 +00:00
|
|
|
case ev_ptr:
|
2022-01-18 04:21:06 +00:00
|
|
|
case ev_int:
|
|
|
|
case ev_uint:
|
2022-01-05 13:32:07 +00:00
|
|
|
*(pr_int_t **)def->field = (pr_int_t *) address;
|
|
|
|
break;
|
|
|
|
case ev_long:
|
|
|
|
case ev_ulong:
|
|
|
|
*(pr_long_t **)def->field = (pr_long_t *) address;
|
2004-01-21 08:09:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2004-11-05 11:49:00 +00:00
|
|
|
resolve_globals (progs_t *pr, sv_def_t *def, int mode)
|
2004-01-21 08:09:47 +00:00
|
|
|
{
|
2020-02-22 13:33:44 +00:00
|
|
|
pr_def_t *ddef;
|
2004-11-05 11:49:00 +00:00
|
|
|
int ret = 1;
|
2004-01-21 08:09:47 +00:00
|
|
|
|
2004-11-05 11:49:00 +00:00
|
|
|
if (mode == 2) {
|
|
|
|
for (; def->name; def++)
|
|
|
|
set_address (def, &G_FLOAT (pr, def->offset));
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
for (; def->name; def++) {
|
|
|
|
ddef = PR_FindGlobal (pr, def->name);
|
|
|
|
if (ddef) {
|
|
|
|
set_address (def, &G_FLOAT(pr, ddef->ofs));
|
|
|
|
} else if (mode) {
|
|
|
|
PR_Undefined (pr, "global", def->name);
|
|
|
|
ret = 0;
|
2004-01-21 08:09:47 +00:00
|
|
|
}
|
2004-11-05 11:49:00 +00:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
resolve_functions (progs_t *pr, sv_def_t *def, int mode)
|
|
|
|
{
|
|
|
|
dfunction_t *dfunc;
|
|
|
|
int ret = 1;
|
|
|
|
|
|
|
|
if (mode == 2) {
|
|
|
|
for (; def->name; def++)
|
2022-01-18 06:32:43 +00:00
|
|
|
*(pr_func_t *) def->field = G_FUNCTION (pr, def->offset);
|
2004-11-05 11:49:00 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
for (; def->name; def++) {
|
|
|
|
dfunc = PR_FindFunction (pr, def->name);
|
|
|
|
if (dfunc) {
|
2022-01-18 06:32:43 +00:00
|
|
|
*(pr_func_t *) def->field = dfunc - pr->pr_functions;
|
2004-11-05 11:49:00 +00:00
|
|
|
} else if (mode) {
|
|
|
|
PR_Undefined (pr, "function", def->name);
|
|
|
|
ret = 0;
|
2004-01-21 08:09:47 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-05 11:49:00 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
resolve_fields (progs_t *pr, sv_def_t *def, int mode)
|
|
|
|
{
|
2020-02-22 13:33:44 +00:00
|
|
|
pr_def_t *ddef;
|
2004-11-05 11:49:00 +00:00
|
|
|
int ret = 1;
|
|
|
|
|
|
|
|
if (mode == 2) {
|
|
|
|
for (; def->name; def++)
|
|
|
|
*(int *) def->field = def->offset;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
for (; def->name; def++) {
|
|
|
|
*(int *)def->field = -1;
|
|
|
|
ddef = PR_FindField (pr, def->name);
|
2004-01-21 08:09:47 +00:00
|
|
|
if (ddef) {
|
2004-11-05 11:49:00 +00:00
|
|
|
*(int *)def->field = ddef->ofs;
|
|
|
|
} else if (mode) {
|
|
|
|
PR_Undefined (pr, "field", def->name);
|
|
|
|
ret = 0;
|
2004-01-21 08:09:47 +00:00
|
|
|
}
|
|
|
|
}
|
2004-11-05 11:49:00 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
resolve (progs_t *pr)
|
|
|
|
{
|
|
|
|
int ret = 1;
|
|
|
|
if (pr->progs->crc == nq_crc) {
|
|
|
|
resolve_globals (pr, nq_self, 2);
|
|
|
|
resolve_globals (pr, nq_defs, 2);
|
|
|
|
resolve_functions (pr, nq_funcs, 2);
|
|
|
|
resolve_fields (pr, nq_fields, 2);
|
|
|
|
} else {
|
|
|
|
if (!resolve_globals (pr, nq_self, 0))
|
|
|
|
ret = 0;
|
|
|
|
if (!resolve_globals (pr, nq_defs, 1))
|
|
|
|
ret = 0;
|
|
|
|
if (!resolve_functions (pr, nq_funcs, 1))
|
|
|
|
ret = 0;
|
|
|
|
if (!resolve_fields (pr, nq_fields, 1))
|
|
|
|
ret = 0;
|
2004-01-21 08:09:47 +00:00
|
|
|
}
|
2004-11-05 11:49:00 +00:00
|
|
|
resolve_globals (pr, nq_opt_defs, 0);
|
|
|
|
resolve_functions (pr, nq_opt_funcs, 0);
|
|
|
|
resolve_fields (pr, nq_opt_fields, 0);
|
2004-01-21 08:09:47 +00:00
|
|
|
// progs engine needs these globals anyway
|
|
|
|
sv_pr_state.globals.self = sv_globals.self;
|
2022-01-16 10:32:47 +00:00
|
|
|
sv_pr_state.globals.ftime = sv_globals.time;//FIXME double time
|
2004-11-05 11:49:00 +00:00
|
|
|
return ret;
|
2004-01-21 08:09:47 +00:00
|
|
|
}
|
|
|
|
|
2013-01-17 05:11:54 +00:00
|
|
|
static int
|
|
|
|
sv_init_edicts (progs_t *pr)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
memset (sv_edicts, 0, sizeof (sv_edicts));
|
|
|
|
memset (sv_data, 0, sizeof (sv_data));
|
|
|
|
|
|
|
|
// init the data field of the edicts
|
|
|
|
for (i = 0; i < sv.max_edicts; i++) {
|
|
|
|
edict_t *ent = EDICT_NUM (&sv_pr_state, i);
|
|
|
|
ent->pr = &sv_pr_state;
|
|
|
|
ent->entnum = i;
|
|
|
|
ent->edict = EDICT_TO_PROG (&sv_pr_state, ent);
|
|
|
|
ent->edata = &sv_data[i];
|
|
|
|
SVdata (ent)->edict = ent;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-02-26 20:52:14 +00:00
|
|
|
void
|
|
|
|
SV_LoadProgs (void)
|
|
|
|
{
|
2003-01-10 22:47:18 +00:00
|
|
|
const char *progs_name = "progs.dat";
|
2004-01-06 07:00:39 +00:00
|
|
|
const char *range;
|
2002-02-25 22:57:17 +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 (strequal (sv_progs_ext, "qf")) {
|
2004-01-06 07:00:39 +00:00
|
|
|
sv_range = PR_RANGE_QF;
|
|
|
|
range = "QF";
|
[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
|
|
|
} else if (strequal (sv_progs_ext, "id")) {
|
2004-01-06 07:00:39 +00:00
|
|
|
sv_range = PR_RANGE_ID;
|
|
|
|
range = "ID";
|
|
|
|
} else {
|
|
|
|
sv_range = PR_RANGE_NONE;
|
|
|
|
range = "None";
|
|
|
|
}
|
2021-03-29 10:58:00 +00:00
|
|
|
Sys_MaskPrintf (SYS_dev, "Using %s builtin extention mapping\n", range);
|
2004-01-06 07:00:39 +00:00
|
|
|
|
2010-01-13 06:29:36 +00:00
|
|
|
memset (&sv_globals, 0, sizeof (sv_funcs));
|
|
|
|
memset (&sv_funcs, 0, sizeof (sv_funcs));
|
|
|
|
|
|
|
|
if (qfs_gamedir->gamecode && *qfs_gamedir->gamecode)
|
|
|
|
progs_name = qfs_gamedir->gamecode;
|
[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 (*sv_progs)
|
|
|
|
progs_name = sv_progs;
|
2010-01-13 06:29:36 +00:00
|
|
|
|
2018-10-11 01:06:48 +00:00
|
|
|
sv_pr_state.max_edicts = sv.max_edicts;
|
[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
|
|
|
sv_pr_state.zone_size = sv_progs_zone * 1024;
|
|
|
|
sv_pr_state.stack_size = sv_progs_stack * 1024;
|
2013-01-17 05:11:54 +00:00
|
|
|
sv.edicts = sv_edicts;
|
2021-03-25 13:01:31 +00:00
|
|
|
|
2018-10-11 01:06:48 +00:00
|
|
|
PR_LoadProgs (&sv_pr_state, progs_name);
|
2001-02-26 20:52:14 +00:00
|
|
|
if (!sv_pr_state.progs)
|
2003-01-10 22:47:18 +00:00
|
|
|
Host_Error ("SV_LoadProgs: couldn't load %s", progs_name);
|
2001-02-26 20:52:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SV_Progs_Init (void)
|
|
|
|
{
|
2020-02-23 06:56:36 +00:00
|
|
|
SV_Progs_Init_Cvars ();
|
|
|
|
|
2010-01-13 06:29:36 +00:00
|
|
|
pr_gametype = "netquake";
|
2013-01-17 05:11:54 +00:00
|
|
|
sv_pr_state.pr_edicts = &sv.edicts;
|
2001-02-26 20:52:14 +00:00
|
|
|
sv_pr_state.num_edicts = &sv.num_edicts;
|
2001-02-28 09:12:01 +00:00
|
|
|
sv_pr_state.reserved_edicts = &svs.maxclients;
|
2001-02-26 20:52:14 +00:00
|
|
|
sv_pr_state.unlink = SV_UnlinkEdict;
|
2001-03-27 22:39:21 +00:00
|
|
|
sv_pr_state.parse_field = parse_field;
|
|
|
|
sv_pr_state.prune_edict = prune_edict;
|
2004-01-06 07:00:39 +00:00
|
|
|
sv_pr_state.bi_map = bi_map;
|
2004-01-21 08:09:47 +00:00
|
|
|
sv_pr_state.resolve = resolve;
|
2001-02-26 20:52:14 +00:00
|
|
|
|
2013-01-17 05:11:54 +00:00
|
|
|
PR_AddLoadFunc (&sv_pr_state, sv_init_edicts);
|
2020-02-23 06:56:36 +00:00
|
|
|
PR_Init (&sv_pr_state);
|
2013-01-17 05:11:54 +00:00
|
|
|
|
2001-08-03 06:40:28 +00:00
|
|
|
SV_PR_Cmds_Init ();
|
|
|
|
|
2001-08-27 07:13:32 +00:00
|
|
|
Cmd_AddCommand ("edict", ED_PrintEdict_f, "Report information on a given "
|
|
|
|
"edict in the game. (edict (edict number))");
|
2001-02-26 20:52:14 +00:00
|
|
|
Cmd_AddCommand ("edicts", ED_PrintEdicts_f,
|
|
|
|
"Display information on all edicts in the game.");
|
|
|
|
Cmd_AddCommand ("edictcount", ED_Count_f,
|
|
|
|
"Display summary information on the edicts in the game.");
|
2010-01-13 06:29:36 +00:00
|
|
|
Cmd_AddCommand ("profile", PR_Profile_f, "FIXME: Report information about "
|
|
|
|
"QuakeC Stuff (\?\?\?) No Description");
|
|
|
|
Cmd_AddCommand ("watch", watch_f, "set watchpoint");
|
|
|
|
Cmd_AddCommand ("print", print_f, "print value at location");
|
2001-02-26 20:52:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SV_Progs_Init_Cvars (void)
|
|
|
|
{
|
2020-02-23 06:56:36 +00:00
|
|
|
PR_Init_Cvars ();
|
[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 (&sv_progs_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_progs_zone_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_progs_stack_cvar, 0, 0);
|
|
|
|
Cvar_Register (&sv_progs_ext_cvar, 0, 0);
|
|
|
|
Cvar_Register (&pr_checkextensions_cvar, 0, 0);
|
|
|
|
|
|
|
|
Cvar_Register (&nomonsters_cvar, 0, 0);
|
|
|
|
Cvar_Register (&gamecfg_cvar, 0, 0);
|
|
|
|
Cvar_Register (&scratch1_cvar, 0, 0);
|
|
|
|
Cvar_Register (&scratch2_cvar, 0, 0);
|
|
|
|
Cvar_Register (&scratch3_cvar, 0, 0);
|
|
|
|
Cvar_Register (&scratch4_cvar, 0, 0);
|
|
|
|
Cvar_Register (&savedgamecfg_cvar, 0, 0);
|
|
|
|
Cvar_Register (&saved1_cvar, 0, 0);
|
|
|
|
Cvar_Register (&saved2_cvar, 0, 0);
|
|
|
|
Cvar_Register (&saved3_cvar, 0, 0);
|
|
|
|
Cvar_Register (&saved4_cvar, 0, 0);
|
2001-02-26 20:52:14 +00:00
|
|
|
}
|